server_monitor.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. <script type="text/javascript" src="js/modules/gamemanager.js"></script>
  2. <?php
  3. /*
  4. *
  5. * OGP - Open Game Panel
  6. * Copyright (C) 2008 - 2017 The OGP Development Team
  7. *
  8. * http://www.opengamepanel.org/
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version 2
  13. * of the License, or any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  23. *
  24. */
  25. require_once('modules/gamemanager/home_handling_functions.php');
  26. require_once("modules/config_games/server_config_parser.php");
  27. require_once("includes/refreshed.php");
  28. require_once('includes/lib_remote.php');
  29. function renderParam($param, $last_param, $param_access_enabled, $home_id)
  30. {
  31. global $db;
  32. $isAdmin = $db->isAdmin($_SESSION['user_id']);
  33. $attributesString = "";
  34. foreach ($param->attribute as $attribute)
  35. $attributesString .= $attribute['key']. "='$attribute' ";
  36. $disabledString = ((($param_access_enabled) && (!property_exists($param, 'access') || $param->access != "admin")) || $isAdmin) ? "" : "disabled ";
  37. if (array_key_exists((string)$param['key'], $last_param))
  38. $paramValue = (string)$last_param[(string)$param['key']];
  39. else
  40. $paramValue = (string)$param->default;
  41. $idString = "id='".clean_id_string($param['key'])."'";
  42. $nameString = "name='params[".$param['key']."]'";
  43. $paramType = $param['type'];
  44. if ($paramType == "select")
  45. {
  46. $inputElementString = "<select $idString $nameString $disabledString>";
  47. foreach ($param->option as $option)
  48. {
  49. $optionValue = (string)($option['value']);
  50. $selectedString = ($optionValue == $paramValue) ? "selected='selected'" : "";
  51. $valueString = "value=\"".str_replace('"', "&quot;", strip_real_escape_string($optionValue))."\"";
  52. $inputElementString .= "<option $selectedString $valueString>$option</option>";
  53. }
  54. $inputElementString .="</select>";
  55. }else if($paramType == "other_game_server_path" || $paramType == "other_game_server_path_additional"){
  56. if($isAdmin){
  57. $dbTypeHomesStr = "admin";
  58. }else{
  59. $dbTypeHomesStr = "user_and_group";
  60. }
  61. // Get homes
  62. $homes = $db->getHomesFor($dbTypeHomesStr, $_SESSION['user_id']);
  63. // Move current home_id home_path to the front of the array so that it is selected by default if no other option has been selected.
  64. $homes = customShift($homes, "home_id", $home_id);
  65. $inputElementString = "<select $idString name='params[" . $param['key'] . "{DEPENDS:other_game_server_path_additional}]'" . $disabledString . ">";
  66. foreach($homes as $home){
  67. if($home["home_path"][strlen($home["home_path"])-1] != "/"){
  68. $home["home_path"] = $home["home_path"] . "/";
  69. }
  70. if(stripos($paramValue, $home["home_path"]) !== false){
  71. $selectedString = "selected='selected'";
  72. $selectedHome = $home["home_path"];
  73. }else{
  74. $selectedString = "";
  75. }
  76. $inputElementString .= '<option value="' . $home["home_path"] . '" ' . $selectedString . '>' . $home["home_path"] . '</option>';
  77. }
  78. $inputElementString .="</select>";
  79. if($paramType == "other_game_server_path_additional"){
  80. $inputElementString .="<input type='text' value='" . (stripos($paramValue, $selectedHome) !== false ? substr($paramValue, strlen($selectedHome)) : (hasValue((string)$param->default) ? (string)$param->default : "")) . "' name='params[other_game_server_path_additional]' " . $disabledString .">";
  81. }
  82. }else{
  83. if ($paramType == "checkbox_key_value") {
  84. if ($paramValue) // convert the XML object to string
  85. $attributesString .= "checked='checked' ";
  86. $paramValue = $param['key'];
  87. $paramType = "checkbox";
  88. }
  89. else if ($paramType == "checkbox")
  90. {
  91. if ($paramValue) // convert the XML object to string
  92. $attributesString .= "checked='checked' ";
  93. }
  94. $inputElementString = "<input $idString $nameString ".
  95. "type='$paramType' value=\"".str_replace('"', "&quot;", strip_real_escape_string($paramValue))."\" ".
  96. "$disabledString $attributesString/>";
  97. }
  98. echo "<tr><td class='right'><label for='".clean_id_string($param['key'])."'>".$param['key'].
  99. ":</label></td><td class='left'>$inputElementString<label for='".clean_id_string($param['key'])."'>";
  100. if ( !empty($param->caption) )
  101. echo $param->caption;
  102. if ( !empty($param->desc) )
  103. echo "<br/><span class='info'>(".$param->desc.")</span>";
  104. echo "</label></td></tr>\n";
  105. }
  106. function get_sync_name($server_xml)
  107. {
  108. if( $server_xml->lgsl_query_name )
  109. {
  110. $sync_name = $server_xml->lgsl_query_name;
  111. if($sync_name == "quake3")
  112. {
  113. if($server_xml->game_name == "Quake 3")
  114. $sync_name = "q3";
  115. }
  116. }
  117. elseif( $server_xml->gameq_query_name )
  118. {
  119. $sync_name = $server_xml->gameq_query_name;
  120. if($sync_name == "minecraft")
  121. {
  122. if($server_xml->game_name == "Bukkit")
  123. $sync_name = "bukkit";
  124. elseif($server_xml->game_name == "Tekkit")
  125. $sync_name = "tekkit";
  126. }
  127. }
  128. elseif( isset($server_xml->protocol) )
  129. $sync_name = $server_xml->protocol;
  130. else
  131. $sync_name = $server_xml->mods->mod['key'];
  132. return $sync_name;
  133. }
  134. function exec_ogp_module() {
  135. global $db, $settings, $loggedInUserInfo;
  136. echo "<h2>". get_lang("game_monitor") ."</h2>";
  137. $refresh = new refreshed();
  138. set_time_limit(0);
  139. $stats_servers_online = 0;
  140. $stats_servers = 0;
  141. $stats_players = 0;
  142. $stats_maxplayers = 0;
  143. $home_page = (isset($_GET['page']) && (int)$_GET['page'] > 0) ? (int)$_GET['page'] : 1;
  144. $home_limit = (isset($_GET['limit']) && (int)$_GET['limit'] > 0) ? (int)$_GET['limit'] : 10;
  145. $home_cfg_id = (isset($_GET['home_cfg_id']) && (int)$_GET['home_cfg_id'] > 0) ? (int)$_GET['home_cfg_id'] : false;
  146. $search_field = (isset($_GET['search']) && !empty($_GET['search'])) ? $_GET['search'] : false;
  147. if(hasValue($loggedInUserInfo) && is_array($loggedInUserInfo) && $loggedInUserInfo["users_page_limit"] && !hasValue($_GET['limit'])){
  148. $home_limit = $loggedInUserInfo["users_page_limit"];
  149. }
  150. $isAdmin = $db->isAdmin( $_SESSION['user_id'] );
  151. if ( $isAdmin )
  152. {
  153. $show_games_type = $db->getHomesFor('admin', $_SESSION['user_id']);
  154. if(isset($_GET['home_id']) OR isset($_GET['home_id-mod_id-ip-port']))
  155. $server_homes = $db->getHomesFor('admin', $_SESSION['user_id']);
  156. else
  157. $server_homes = $db->getHomesFor_limit('admin', $_SESSION['user_id'],$home_page,$home_limit,$home_cfg_id,$search_field);
  158. }
  159. else
  160. {
  161. $show_games_type = $db->getHomesFor('user_and_group', $_SESSION['user_id']);
  162. if(isset($_GET['home_id']) OR isset($_GET['home_id-mod_id-ip-port']))
  163. $server_homes = $db->getHomesFor('user_and_group', $_SESSION['user_id']);
  164. else
  165. $server_homes = $db->getHomesFor_limit('user_and_group', $_SESSION['user_id'],$home_page,$home_limit,$home_cfg_id,$search_field);
  166. }
  167. if( $server_homes === FALSE )
  168. {
  169. // If there are no games, then there can not be any mods either.
  170. if (!empty($search_field)) {
  171. print_failure(get_lang_f('no_results_found', htmlentities($search_field)));
  172. } else {
  173. print_failure(get_lang('no_game_homes_assigned'));
  174. }
  175. if ( $isAdmin )
  176. {
  177. echo "<p><a href='?m=user_games&amp;p=assign&amp;user_id=$_SESSION[user_id]'>".
  178. get_lang("assign_game_homes") ."</a></p>";
  179. }
  180. return;
  181. }
  182. ?>
  183. <form action="home.php" style="float:right;">
  184. <b><?php print_lang('search'); ?>:</b>
  185. <input type ="hidden" name="m" value="gamemanager" />
  186. <input type ="hidden" name="p" value="game_monitor" />
  187. <input name="search" type="text" id="search" value="<?php if(hasValue($search_field)){ echo $search_field; } ?>" />
  188. <input type="submit" value="<?php echo get_lang('search'); ?>" />
  189. </form>
  190. <?php
  191. foreach($_POST as $key => $value)
  192. {
  193. if( preg_match( "/^action/", $key ) )
  194. {
  195. list($action,$home_id,$mod_id,$ip,$port) = explode("-", $value);
  196. exec_operation( $action, $home_id, $mod_id, $ip, $port );
  197. }
  198. }
  199. if ( empty( $_GET['home_id-mod_id-ip-port'] ) )
  200. unset( $_GET['home_id-mod_id-ip-port'] );
  201. if ( empty( $_GET['home_id'] ) )
  202. unset( $_GET['home_id'] );
  203. if ( isset($_GET['home_cfg_id']) and $_GET['home_cfg_id'] == game_type )
  204. unset( $_GET['home_cfg_id'] );
  205. create_home_selector_game_type($_GET['m'], $_GET['p'], $show_games_type);
  206. if (!isset($_GET['home_id-mod_id-ip-port']) and !isset($_GET['home_id']) and !isset($_GET['home_cfg_id']))
  207. {
  208. create_home_selector_address($_GET['m'], $_GET['p'], $server_homes);
  209. $show_all = TRUE;
  210. }
  211. else
  212. {
  213. create_home_selector_address($_GET['m'], $_GET['p'], $server_homes);
  214. create_home_selector($_GET['m'], $_GET['p'], "show_all");
  215. $show_all = FALSE;
  216. }
  217. require("protocol/lgsl/lgsl_protocol.php");
  218. $info = $db->getUserById($_SESSION['user_id']);
  219. if($info['user_expires'] != "X")
  220. {
  221. ?>
  222. <span style="color:black;font-weight:bold;">
  223. <center>
  224. <?php echo print_lang('account_expiration'); ?>: <span style="color:green;"><?php echo date( "l, F jS, Y, H:i:s", $info['user_expires'] ).
  225. " ( ".str_replace('hr', 'hours', read_expire($info['user_expires'])).")"; ?></span>
  226. </center>
  227. </span>
  228. <?php
  229. }
  230. if($settings["show_server_id_game_monitor"]){
  231. echo "<p class='serverIdToggle' showtext='" . get_lang('show_server_id') . "' hidetext='" . get_lang('hide_server_id') . "'>" . get_lang('show_server_id') . "</p>";
  232. }
  233. echo "<table id='servermonitor' class='tablesorter' data-sortlist='[[0,0],[3,1]]'>".
  234. "<thead>".
  235. "<tr>".
  236. "\t<th style='width:16px;background-position: center;'></th>".
  237. "\t<th style='width:16px;background-position: center;'></th>".
  238. "\t<th class=\"hide serverId\">" . get_lang("server_id") . "</th>".
  239. "\t<th>" . get_lang("server_name") . "</th>".
  240. "\t<th>" . get_lang("address") . "</th>".
  241. "\t<th>" . get_lang("owner") . "</th>".
  242. "\t<th class='sorter-false'>".
  243. "\t\t" . get_lang("operations") . "".
  244. "\t\t<img style='border:0;height:15px;' id='action-stop' src='" . check_theme_image("images/stop.png") . "'/>".
  245. "\t\t<img style='border:0;height:15px;' id='action-restart' src='" . check_theme_image("images/restart.png") . "'/>".
  246. "\t\t<img style='border:0;height:15px;' id='action-start' src='" . check_theme_image("images/start.png") . "'/>".
  247. "\t</th>".
  248. "</tr>".
  249. "</thead>".
  250. "<tbody>";
  251. $litefm_installed = $db->isModuleInstalled('litefm');
  252. $ftp_installed = $db->isModuleInstalled('ftp');
  253. $addonsmanager_installed = $db->isModuleInstalled('addonsmanager');
  254. $mysql_installed = $db->isModuleInstalled('mysql');
  255. if( isset( $_GET['home_id-mod_id-ip-port']) )
  256. list( $post_home_id,
  257. $post_mod_id,
  258. $post_ip,
  259. $post_port ) = explode( "-", $_GET['home_id-mod_id-ip-port'] );
  260. foreach( $server_homes as $server_home )
  261. {
  262. if( ( $show_all or isset($_GET['home_cfg_id']) ) AND ( !isset($server_home['ip']) or !isset($server_home['mod_id']) ) )
  263. continue;
  264. // Count the number of servers.
  265. $stats_servers++;
  266. if( $show_all
  267. OR ( isset( $_GET['home_id'] ) and $_GET['home_id'] == $server_home['home_id'] )
  268. OR ( isset( $_GET['home_id-mod_id-ip-port'] ) and $server_home['home_id'] == $post_home_id and $server_home['mod_id'] == $post_mod_id and $post_ip == $server_home['ip'] and $post_port == $server_home['port'] )
  269. OR ( isset( $_GET['home_cfg_id'] ) and $_GET['home_cfg_id'] == $server_home['home_cfg_id'] )
  270. )
  271. {
  272. //Unset variables.
  273. unset($map,
  274. $trclass,
  275. $first,
  276. $second,
  277. $onlineT,
  278. $ts3opt,
  279. $offlineT,
  280. $halfT,
  281. $ministart,
  282. $player_list,
  283. $groupsus,
  284. $name,
  285. $mod_name,
  286. $SrvCtrl,
  287. $lite_fm,
  288. $manager,
  289. $user,
  290. $pos,
  291. $ftp,
  292. $addonsmanager,
  293. $ctrlChkBoxes,
  294. $expiration_dates);
  295. if ( $isAdmin )
  296. {
  297. $server_home['access_rights'] = "ufpetc";
  298. }
  299. if ($server_home['mod_name'] == "none" OR $server_home['mod_name'] == "None")
  300. $mod_name = "";
  301. elseif($server_home['mod_name'] != $server_home['game_name'])
  302. $mod_name = " ( ".$server_home['mod_name']." )";
  303. $expiration_dates = "";
  304. if(isset($server_home['server_expiration_date']) and $server_home['server_expiration_date'] != "X")
  305. $expiration_dates .= server_expiration_date . ": " . date('d/m/Y H:i:s', $server_home["server_expiration_date"]) . "<br>";
  306. if(isset($server_home['user_expiration_date']) and $server_home['user_expiration_date'] != "X")
  307. $expiration_dates .= assign_expiration_date . " (" . user . "): " . date('d/m/Y H:i:s', $server_home["user_expiration_date"]) . "<br>";
  308. if(isset($server_home['user_group_expiration_date']) and $server_home['user_expiration_date'] != "X")
  309. $expiration_dates .= assign_expiration_date . " (" . group . "): " . date('d/m/Y H:i:s', $server_home["user_group_expiration_date"]);
  310. $get_size = "<a class='monitorbutton size' data-home_id='".$server_home["home_id"]."'>
  311. <img src='" . check_theme_image("images/file_size.png") . "' title='". get_lang("get_size") ."'>
  312. <span>". get_lang("get_size") ."</span>
  313. </a>";
  314. $manager = "<a class='monitorbutton' href='?m=user_games&amp;p=edit&amp;home_id=".$server_home['home_id']."'>
  315. <img src='" . check_theme_image("images/edit.png") . "' title='". get_lang("edit") ."'>
  316. <span>". get_lang("edit") ."</span>
  317. </a>";
  318. // Only show the filemanager link when the litefm is installed.
  319. if ( preg_match("/f/",$server_home['access_rights']) > 0 && $litefm_installed )
  320. {
  321. $lite_fm = "<a class='monitorbutton' href='?m=litefm&amp;home_id=".$server_home['home_id']."'>
  322. <img src='" . check_theme_image("images/filemanager.png") . "' title='". get_lang("file_manager") ."'>
  323. <span>". get_lang("file_manager") ."</span>
  324. </a>";
  325. }
  326. if ( preg_match("/t/",$server_home['access_rights']) > 0 && $ftp_installed )
  327. {
  328. $ftp = "<a class='monitorbutton' href='?m=ftp&amp;home_id=".$server_home['home_id']."'>
  329. <img src='" . check_theme_image("images/ftp.png") . "' title='". get_lang("ftp") ."'>
  330. <span>". get_lang("ftp") ."</span>
  331. </a>";
  332. }
  333. if ( $addonsmanager_installed )
  334. {
  335. $addons = $db->resultQuery("SELECT DISTINCT addon_id FROM OGP_DB_PREFIXaddons NATURAL JOIN OGP_DB_PREFIXconfig_homes WHERE home_cfg_id=".$server_home['home_cfg_id']);
  336. $addons_qty = count($addons);
  337. if($addons and $addons_qty >= 1){
  338. $addonsmanager = "<a class='monitorbutton' href='?m=addonsmanager&amp;p=user_addons&amp;home_id=".
  339. $server_home['home_id']."&amp;mod_id=".$server_home['mod_id'].
  340. "&amp;ip=".$server_home['ip']."&amp;port=".$server_home['port']."'>
  341. <img src='" . check_theme_image("modules/administration/images/addons_manager.png") . "' title='". get_lang("addons") ."'>
  342. <span>". get_lang("addons") ." (".$addons_qty.")</span>
  343. </a>";
  344. }
  345. }
  346. if ( $mysql_installed )
  347. {
  348. $mysql_dbs = $db->resultQuery("SELECT db_id FROM OGP_DB_PREFIXmysql_databases WHERE enabled=1 AND home_id=".$server_home['home_id']);
  349. if(!empty($mysql_dbs))
  350. $mysql = "<a class='monitorbutton' href='?m=mysql&p=user_db&home_id=".$server_home['home_id']."'>
  351. <img src='" . check_theme_image("modules/administration/images/mysql_admin.png") . "' title='". get_lang("mysql_databases") ."'>
  352. <span>". get_lang("mysql_databases") ."</span>
  353. </a>";
  354. }
  355. if( !isset($server_home['mod_id']) )
  356. {
  357. $ministart = get_lang("fail_no_mods");
  358. if ( $isAdmin )
  359. {
  360. $ministart .= " <a href='?m=user_games&amp;p=edit&amp;home_id=".$server_home['home_id']."'>" . get_lang("configure_mods") . "</a>";
  361. }
  362. }
  363. $server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$server_home['home_cfg_file']);
  364. if ( $server_xml )
  365. {
  366. if (preg_match("/u/",$server_home['access_rights']))
  367. {
  368. $master_server_home_id = $db->getMasterServer( $server_home['remote_server_id'], $server_home['home_cfg_id'] );
  369. if ( $master_server_home_id != FALSE )
  370. {
  371. if ( !$db->getGameHomeWithoutMods($master_server_home_id) )
  372. {
  373. $db->setMasterServer("remove", $master_server_home_id, $server_home['home_cfg_id'], $server_home['remote_server_id']);
  374. $master_server_home_id = FALSE;
  375. }
  376. }
  377. // In case game is compatible with steam we offer a way to use steam with the updates.
  378. if( $server_xml->installer == "steamcmd" )
  379. {
  380. if( $master_server_home_id != FALSE AND $master_server_home_id != $server_home['home_id'] )
  381. {
  382. $manager .= "<a class='monitorbutton' href='?m=gamemanager&amp;p=update&amp;home_id=".$server_home['home_id']."&amp;mod_id=".$server_home['mod_id']."&amp;master_server_home_id=".$master_server_home_id."&amp;update=update'>
  383. <img src='" . check_theme_image("images/master.png") . "' title='". get_lang("update_from_local_master_server") ."'>
  384. <span>". get_lang("update_from_local_master_server") ."</span>
  385. </a>";
  386. }
  387. $manager .= "<a class='monitorbutton' href='?m=gamemanager&amp;p=update&amp;home_id=".$server_home['home_id']."&amp;mod_id=".$server_home['mod_id']."&amp;update=update'>
  388. <img src='" . check_theme_image("images/steam.png") ."' title='". get_lang("install_update_steam") ."'>
  389. <span>". get_lang("install_update_steam") ."</span>
  390. </a>";
  391. $manager .= "<a class='monitorbutton getAutoUpdateLink' copyfail='" . get_lang("auto_update_copy_me_fail") . "' copysuccess='" . get_lang("auto_update_copy_me_success") . "' autoupdatetext='" . get_lang("auto_update_title_popup") . "' autoupdatehtml='" . htmlentities(get_lang("auto_update_popup_html")) . "' copyme='" . get_lang("auto_update_copy_me") . "' autoupdatelink='" . getOGPSiteURL() . "/ogp_api.php?action=autoUpdateSteamHome&homeid=" . $server_home['home_id'] . "&controlpass=" . $server_home['control_password'] . "'>
  392. <img src='" . check_theme_image("images/auto_update.png") . "' title='". get_lang("get_steam_autoupdate_api_link") . "'>
  393. <span>". get_lang("get_steam_autoupdate_api_link") . "</span>
  394. </a>";
  395. }
  396. // In other cases manual update is provided.
  397. else
  398. {
  399. $manager .= "<a class='monitorbutton' href='?m=gamemanager&amp;p=update_manual&amp;home_id=".$server_home['home_id']."&amp;mod_id=".$server_home['mod_id']."&amp;update=update'>
  400. <img src='" . check_theme_image("images/install.png") . "' title='". get_lang("install_update_manual") ."'>
  401. <span>". get_lang("install_update_manual") ."</span>
  402. </a>";
  403. $sync_name = get_sync_name($server_xml);
  404. $sync_list = @file("modules/gamemanager/rsync.list", get_lang("FILE_IGNORE_NEW_LINES"));
  405. if ( in_array($sync_name, $sync_list) OR ($master_server_home_id != FALSE and $master_server_home_id != $server_home['home_id']) )
  406. {
  407. $manager .= "<a class='monitorbutton' href='?m=gamemanager&amp;p=rsync_install&amp;home_id=".$server_home['home_id']."&amp;mod_id=".$server_home['mod_id']."&amp;update=update'>
  408. <img src='" . check_theme_image("images/rsync.png") . "' title='". rsync_install ."'>
  409. <span>". get_lang("rsync_install") ."</span>
  410. </a>";
  411. }
  412. }
  413. }
  414. if ($db->isModuleInstalled("editconfigfiles") && !empty($server_xml->configuration_files)) {
  415. $manager .= "<a href=\"?m=editconfigfiles&home_id=".(int)$server_home['home_id']."\" class=\"monitorbutton\">
  416. <img src='" . check_theme_image("images/editconfig.png") . "' title='". get_lang("edit_configuration_files") ."'>
  417. <span>". get_lang("edit_configuration_files") ."</span>
  418. </a>";
  419. }
  420. if (preg_match("/c/",$server_home['access_rights'])){
  421. if( isset($server_xml->custom_fields) ) {
  422. $manager .= "<a href=\"?m=user_games&p=custom_fields&home_id=".$server_home['home_id']."\" class=\"monitorbutton\">
  423. <img src='" . check_theme_image("images/customfields.png") . "' title='". get_lang("custom_fields") ."'>
  424. <span>". get_lang("custom_fields") ."</span>
  425. </a>";
  426. }
  427. }
  428. }
  429. if( $isAdmin )
  430. {
  431. if ( ( $server_xml->control_protocol and preg_match("/^(rcon|lcon|rcon2)$/" ,$server_xml->control_protocol) ) OR
  432. ( $server_xml->gameq_query_name and $server_xml->gameq_query_name == 'minecraft' ) )
  433. {
  434. $manager .= "<a class='monitorbutton' href='home.php?m=gamemanager&amp;p=rcon_presets&amp;home_id=".$server_home['home_id']."&amp;mod_id=".$server_home['mod_id']."'>
  435. <img src='" . check_theme_image("images/rcon_preset.png") . "' title='".get_lang("rcon_presets")."'>
  436. <span>".get_lang("rcon_presets")."</span>
  437. </a>";
  438. }
  439. }
  440. $mod = $server_home['mod_key'];
  441. // If query name does not exist use mod key instead.
  442. if ($server_xml->protocol == "gameq")
  443. $query_name = $server_xml->gameq_query_name;
  444. elseif ($server_xml->protocol == "lgsl")
  445. $query_name = $server_xml->lgsl_query_name;
  446. elseif ($server_xml->protocol == "teamspeak3")
  447. $query_name = 'ts3';
  448. else
  449. $query_name = $mod;
  450. //----------+ getting the lgsl image icon
  451. $icon_paths = array("images/icons/$mod.png",
  452. "images/icons/$query_name.png",
  453. "protocol/lgsl/other/icon_unknown.gif");
  454. $icon_path = get_first_existing_file($icon_paths);
  455. //Properties for all servers
  456. if(isset($post_home_id) && $post_home_id == $server_home['home_id'] OR isset($_GET['home_id']) && $_GET['home_id'] == $server_home['home_id'] )
  457. $trclass = " expandme";
  458. $groupusers = $db->getGroupUsersByHomeId($server_home['home_id']);
  459. $groupsus = "";
  460. if($groupusers)
  461. {
  462. foreach($groupusers as $groupu)
  463. {
  464. if($groupu['user_id'] == $server_home['user_id_main'])
  465. continue;
  466. $groupsus .= $groupu['users_login']."<br>";
  467. }
  468. }
  469. $groupsus = $groupsus != "" ? $groupsus = "<b>". get_lang("group_users") ."</b><br>".$groupsus : "";
  470. $owners = $db->getUsersByHomeId($server_home['home_id']);
  471. $other_owners = "";
  472. if($owners)
  473. {
  474. foreach($owners as $owner)
  475. {
  476. if($owner['user_id'] == $server_home['user_id_main'])
  477. continue;
  478. $other_owners .= $owner['users_login'].'<br>';
  479. }
  480. }
  481. $other_owners = $other_owners != "" ? $other_owners = "<b>". assigned_to ."</b><br>".$other_owners : "";
  482. $view_log = "<a class='monitorbutton' href='?m=gamemanager&amp;p=log&amp;home_id-mod_id-ip-port=".$server_home['home_id']."-".$server_home['mod_id']."-".$server_home['ip']."-".$server_home['port']."'>
  483. <img src='" . check_theme_image("images/log.png") . "' title='". get_lang("view_log") ."'>
  484. <span>". get_lang("view_log") ."</span>
  485. </a>";
  486. $btns = $view_log.
  487. @$ftp.
  488. @$lite_fm.
  489. @$addonsmanager;
  490. //End
  491. $remote = new OGPRemoteLibrary($server_home['agent_ip'], $server_home['agent_port'], $server_home['encryption_key'], $server_home['timeout']);
  492. $host_stat = $remote->status_chk();
  493. if( $host_stat === 1)
  494. {
  495. if ( $server_home['use_nat'] == 1 ){
  496. $query_ip = $server_home['agent_ip'];
  497. }else{
  498. $query_ip = $server_home['ip'];
  499. }
  500. $query_ip = checkDisplayPublicIP($server_home['display_public_ip'],$query_ip);
  501. $address = $query_ip . ":" . $server_home['port'];
  502. $screen_running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME,$server_home['home_id']) === 1;
  503. $update_in_progress = $remote->is_screen_running(OGP_SCREEN_TYPE_UPDATE,$server_home['home_id']) === 1;
  504. if($screen_running)
  505. {
  506. // Check if the screen running the server is running.
  507. $status = "online";
  508. $order=1;
  509. if ($server_xml->protocol == "lgsl")
  510. {
  511. $get_q_and_s = lgsl_port_conversion($query_name, $server_home['port'], "", "");
  512. //Connection port
  513. $c_port = $get_q_and_s['0'];
  514. //query port
  515. $q_port = $get_q_and_s['1'];
  516. //software port
  517. $s_port = $get_q_and_s['2'];
  518. $address = "<a href='" . lgsl_software_link($query_name, $query_ip, $c_port, $q_port, $s_port) . "'>".$query_ip.":".$server_home['port']."</a>";
  519. }
  520. if ($server_xml->protocol == "teamspeak3")
  521. $address = "<a href='ts3server://" . $query_ip . ":" . $server_home['port'] . "'>".$query_ip.":".$server_home['port']."</a>";
  522. if($server_xml->protocol == "gameq" and $server_xml->installer == 'steamcmd')
  523. $address = "<a href='steam://connect/" . $query_ip . ":" . $server_home['port'] . "'>" . $query_ip . ":" . $server_home['port'] . "</a>";
  524. $pos = $refresh->add("home.php?m=gamemanager&p=ref_servermonitor&type=cleared&home_id=". $server_home['home_id'] . "&mod_id=". $server_home['mod_id'] . "&ip=" . $server_home['ip'] . "&port=" . $server_home['port']);
  525. if ($server_xml->protocol == "teamspeak3")
  526. {
  527. require('protocol/TeamSpeak3/functions.php');
  528. }
  529. $startup_file_exists = $remote->rfile_exists( "startups/".$server_home['ip']."-".$server_home['port'] ) === 1;
  530. if( isset($server_home['ip']) and isset($server_home['mod_id']) and ($server_xml->protocol != "teamspeak3" or ($startup_file_exists and $server_xml->protocol == "teamspeak3")) )
  531. {
  532. $ctrlChkBoxes .= '<div id="server_icon" class="action-stop'.$server_home['home_id'].'" ><div>'.
  533. '<input id="action-stop" class="action-stop'.$server_home['home_id'].'" name="action-'.$server_home['home_id'].'" value="stop-'.
  534. $server_home['home_id'].'-'.$server_home['mod_id'].'-'.$server_home['ip'].'-'.$server_home['port'].
  535. '" type="radio"><img style="border:0;height:15px;" src="' . check_theme_image("images/stop.png") . '"/></div><div>&nbsp;'.
  536. get_lang("stop_server") .'</div></div><div id="server_icon" class="action-restart'.$server_home['home_id'].'" ><div>'.
  537. '<input id="action-restart" class="action-restart'.$server_home['home_id'].'" name="action-'.$server_home['home_id'].'" value="restart-'.
  538. $server_home['home_id'].'-'.$server_home['mod_id'].'-'.$server_home['ip'].'-'.$server_home['port'].
  539. '" type="radio"><img style="border:0;height:15px;" src="' . check_theme_image("images/restart.png") . '"/></div><div>&nbsp;'.
  540. get_lang("restart_server") .'</div></div>';
  541. }
  542. $stats_servers_online++;
  543. }
  544. else
  545. {
  546. $status = "offline";
  547. if ($server_home['last_param'] != "" and isset($server_home['ip']) and isset($server_home['mod_id']))
  548. {
  549. if($update_in_progress)
  550. $ctrlChkBoxes .= '<div id="server_icon" class="action-start'.$server_home['home_id'].'" >&nbsp;'. get_lang("update_in_progress") .'</div>';
  551. else
  552. $ctrlChkBoxes .= '<div id="server_icon" class="action-start'.$server_home['home_id'].'" >
  553. <div>
  554. <input id="action-start" class="action-start'.$server_home['home_id'].'" name="action-'.$server_home['home_id'].'" value="start-'.
  555. $server_home['home_id'].'-'.$server_home['mod_id'].'-'.$server_home['ip'].'-'.$server_home['port'].
  556. '" type="radio"><img style="border:0;height:15px;" src="' . check_theme_image("images/start.png") . '"/></div><div>&nbsp;'.
  557. get_lang("start_server") .'</div></div>';
  558. }
  559. $order = 3;
  560. if(isset($server_home['mod_id']))
  561. {
  562. ob_start();
  563. require('modules/gamemanager/mini_start.php');
  564. $ministart = ob_get_contents();
  565. ob_end_clean();
  566. }
  567. if($update_in_progress)
  568. $offlineT = '<div id="server_icon" class="action-start'.$server_home['home_id'].'" >&nbsp;'. get_lang("update_in_progress") .'</div>';
  569. else
  570. $offlineT = $ministart;
  571. }
  572. }
  573. else{
  574. $status = "offline";
  575. $order = 3;
  576. $address = "<span style='color:darkred;font-weight:bold;'>Agent Offline</span>";
  577. }
  578. $user = $db->getUserById($server_home['user_id_main']);
  579. // Template
  580. @$first = "<tr class='maintr$trclass'>";
  581. $first .= "<td class='collapsible' data-status='$status' data-pos='$pos'><span class='hidden'>$order</span>" . "<img src='" . check_theme_image("images/$status.png") . "' />" . "</td>";
  582. $first .= "<td class='collapsible'>" . "<span class='hidden'>$mod</span><img src='$icon_path' />" . "</td>";
  583. $first .= "<td class='collapsible serverId hide'>" . $server_home["home_id"] . "</td>";
  584. $first .= "<td class='collapsible' data-status='$status' data-pos='$pos'><b>" . htmlentities($server_home['home_name']) . "</b>$mod_name</td>";
  585. $first .= "<td class='collapsible'>" . $address . "</td>";
  586. $first .= "<td class='owner collapsible'>" . $user['users_login'] . "</td>";
  587. $first .= "<td style='width:328px;padding:0px;'>$ctrlChkBoxes</td>";
  588. $first .= "</tr>";
  589. $second = "<tr class='expand-child'>";
  590. @$second .= "<td colspan='4'>" . $refresh->getdiv($pos,"width:100%;") . "$offlineT</td>";
  591. $second .= "<td class='owner' >$other_owners$groupsus</td>";
  592. if( $server_xml->protocol != "teamspeak3" OR ($startup_file_exists and $server_xml->protocol == "teamspeak3") OR ($status == "offline" and $server_xml->protocol == "teamspeak3") )
  593. @$second .= "<td class='operations'><div class='inline-block monitorButtonContainer'>" . trim($btns) . trim($manager) . trim($mysql) . trim($get_size) . trim($ts3opt) . "<b class='failure' style='float:left;' >$expiration_dates</b></div></td>";
  594. else
  595. $second .= "<td class='operations' >$ts3opt</td>";
  596. $second .= "</tr>";
  597. //Echo them all
  598. echo "$first$second";
  599. }
  600. }
  601. echo "</tbody>";
  602. echo "<tfoot style='border:1px solid grey;'>
  603. <tr>
  604. <td colspan='7' >
  605. <div class='bloc' >
  606. <img src='" . check_theme_image("images/magnifglass.png") . "' /> ". get_lang("statistics") .": $stats_servers_online/$stats_servers ". get_lang("servers") ."\n</div>
  607. <div class='right bloc' >
  608. <label>". get_lang("execute_selected_server_operations") ."</label>
  609. <input id='execute_operations' type='submit' value='". get_lang("execute_operations") ."' >\n
  610. </div>
  611. </td>
  612. </tr>
  613. </tfoot>";
  614. echo "</table>";
  615. if ($isAdmin) {
  616. $homes_count = $db->getHomesFor_count('admin', $_SESSION['user_id'], $home_cfg_id,$search_field);
  617. } else {
  618. $isSubUser = $db->isSubUser($_SESSION['user_id']);
  619. if ($isSubUser) {
  620. $homes_count = $db->getHomesFor_count('subuser',$_SESSION['user_id'], $home_cfg_id,$search_field);
  621. } else {
  622. $homes_count = $db->getHomesFor_count('user_and_group',$_SESSION['user_id'], $home_cfg_id,$search_field);
  623. }
  624. }
  625. if(isset($_GET['home_cfg_id']) && !empty($_GET['home_cfg_id'])){
  626. $uri = '?m=gamemanager&p=game_monitor&home_cfg_id='.$_GET['home_cfg_id'].''.($search_field ? "&search=$search_field" : "").'&limit='.$home_limit.'&page=';
  627. }
  628. else{
  629. $uri = '?m=gamemanager&p=game_monitor'.($search_field ? "&search=$search_field" : "").'&limit='.$home_limit.'&page=';
  630. }
  631. if(!isset($_GET['home_id-mod_id-ip-port']) && !isset($_GET['home_id']))
  632. {echo paginationPages($homes_count[0]['total'], $home_page, $home_limit, $uri, 3, 'serverMonitor');}
  633. echo "<div id=translation data-title='". upload_map_image .
  634. "' data-upload_button='". upload_image .
  635. "' data-bad_file='". jpg_gif_png_less_than_1mb .
  636. "' data-upload_failure='". check_dev_console .
  637. "' ></div>\n";
  638. ?>
  639. <script type="text/javascript">
  640. <?php echo $refresh->build(isset($settings['query_cache_life']) ? $settings['query_cache_life'] * 2000 : 60000); ?>
  641. </script>
  642. <?php
  643. }
  644. ?>