server_monitor.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. <script type="text/javascript" src="js/modules/gamemanager.js"></script>
  2. <?php
  3. /*
  4. *
  5. * OGP - Open Game Panel
  6. * Copyright (C) 2008 - 2018 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:$paramType}]'" . $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 class='gameMonitor " . ($db->isAdmin( $_SESSION['user_id'] ) ? "isAdminUser" : "") . "'>". 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"] && !(isset($_GET['limit']) and !empty($_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'] == get_lang('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. if( isset( $_GET['home_id-mod_id-ip-port']) )
  252. list( $post_home_id,
  253. $post_mod_id,
  254. $post_ip,
  255. $post_port ) = explode( "-", $_GET['home_id-mod_id-ip-port'] );
  256. $j = 1;
  257. foreach( $server_homes as $server_home )
  258. {
  259. if( ( $show_all or isset($_GET['home_cfg_id']) ) AND ( !isset($server_home['ip']) or !isset($server_home['mod_id']) ) ){
  260. $j++;
  261. continue;
  262. }
  263. // Count the number of servers.
  264. $stats_servers++;
  265. if( $show_all
  266. OR ( isset( $_GET['home_id'] ) and $_GET['home_id'] == $server_home['home_id'] )
  267. 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'] )
  268. OR ( isset( $_GET['home_cfg_id'] ) and $_GET['home_cfg_id'] == $server_home['home_cfg_id'] )
  269. )
  270. {
  271. //Unset variables.
  272. unset($map,
  273. $trclass,
  274. $first,
  275. $second,
  276. $onlineT,
  277. $ts3opt,
  278. $offlineT,
  279. $halfT,
  280. $ministart,
  281. $player_list,
  282. $groupsus,
  283. $name,
  284. $mod_name,
  285. $SrvCtrl,
  286. $user,
  287. $pos,
  288. $ctrlChkBoxes,
  289. $expiration_dates);
  290. if ( $isAdmin )
  291. $server_home['access_rights'] = $db->getFullAccessRightsString();
  292. if ($server_home['mod_name'] == "none" OR $server_home['mod_name'] == "None")
  293. $mod_name = "";
  294. elseif($server_home['mod_name'] != $server_home['game_name'])
  295. $mod_name = " ( ".$server_home['mod_name']." )";
  296. $expiration_dates = "";
  297. if(isset($server_home['server_expiration_date']) and $server_home['server_expiration_date'] != "X")
  298. $expiration_dates .= get_lang("server_expiration_date") . ": " . date('d/m/Y H:i:s', $server_home["server_expiration_date"]) . "<br>";
  299. if(isset($server_home['user_expiration_date']) and $server_home['user_expiration_date'] != "X")
  300. $expiration_dates .= get_lang("assign_expiration_date") . " (" . user . "): " . date('d/m/Y H:i:s', $server_home["user_expiration_date"]) . "<br>";
  301. if(isset($server_home['user_group_expiration_date']) and $server_home['user_expiration_date'] != "X")
  302. $expiration_dates .= get_lang("assign_expiration_date") . " (" . group . "): " . date('d/m/Y H:i:s', $server_home["user_group_expiration_date"]);
  303. if( !isset($server_home['mod_id']) )
  304. {
  305. $ministart = get_lang("fail_no_mods");
  306. if ( $isAdmin )
  307. {
  308. $ministart .= " <a href='?m=user_games&amp;p=edit&amp;home_id=".$server_home['home_id']."'>" . get_lang("configure_mods") . "</a>";
  309. }
  310. }
  311. $server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$server_home['home_cfg_file']);
  312. $mod = $server_home['mod_key'];
  313. // If query name does not exist use mod key instead.
  314. if ($server_xml->protocol == "gameq")
  315. $query_name = $server_xml->gameq_query_name;
  316. elseif ($server_xml->protocol == "lgsl")
  317. $query_name = $server_xml->lgsl_query_name;
  318. elseif ($server_xml->protocol == "teamspeak3")
  319. $query_name = 'ts3';
  320. else
  321. $query_name = $mod;
  322. //----------+ getting the lgsl image icon
  323. $icon_paths = array("images/icons/$mod.png",
  324. "images/icons/$query_name.png",
  325. "protocol/lgsl/other/icon_unknown.gif");
  326. $icon_path = get_first_existing_file($icon_paths);
  327. //Properties for all servers
  328. if(isset($post_home_id) && $post_home_id == $server_home['home_id'] OR isset($_GET['home_id']) && $_GET['home_id'] == $server_home['home_id'] )
  329. $trclass = " expandme";
  330. $groupusers = $db->getGroupUsersByHomeId($server_home['home_id']);
  331. $groupsus = "";
  332. if($groupusers)
  333. {
  334. foreach($groupusers as $groupu)
  335. {
  336. if($groupu['user_id'] == $server_home['user_id_main'])
  337. continue;
  338. $groupsus .= $groupu['users_login']."<br>";
  339. }
  340. }
  341. $groupsus = $groupsus != "" ? $groupsus = "<b>". get_lang("group_users") ."</b><br>".$groupsus : "";
  342. $owners = $db->getUsersByHomeId($server_home['home_id']);
  343. $other_owners = "";
  344. if($owners)
  345. {
  346. foreach($owners as $owner)
  347. {
  348. if($owner['user_id'] == $server_home['user_id_main'])
  349. continue;
  350. $other_owners .= $owner['users_login'].'<br>';
  351. }
  352. }
  353. $other_owners = $other_owners != "" ? $other_owners = "<b>". get_lang("assigned_to") ."</b><br>".$other_owners : "";
  354. $btns = get_monitor_buttons($server_home, $server_xml);
  355. //End
  356. $remote = new OGPRemoteLibrary($server_home['agent_ip'], $server_home['agent_port'], $server_home['encryption_key'], $server_home['timeout']);
  357. $host_stat = $remote->status_chk();
  358. if( $host_stat === 1)
  359. {
  360. $ip = $server_home['ip'];
  361. $query_ip = checkDisplayPublicIP($server_home['display_public_ip'], ($server_home['use_nat'] == 1 ? $server_home['agent_ip'] : $ip));
  362. $displayIP = checkDisplayPublicIP($server_home['display_public_ip'], $ip);
  363. $address = $displayIP . ":" . $server_home['port'];
  364. $screen_running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME,$server_home['home_id']) === 1;
  365. $update_in_progress = $remote->is_screen_running(OGP_SCREEN_TYPE_UPDATE,$server_home['home_id']) === 1;
  366. if($screen_running)
  367. {
  368. // Check if the screen running the server is running.
  369. $status = "online";
  370. $order = 1 + $j;
  371. if ($server_xml->protocol == "lgsl")
  372. {
  373. $get_q_and_s = lgsl_port_conversion($query_name, $server_home['port'], "", "");
  374. //Connection port
  375. $c_port = $get_q_and_s['0'];
  376. //query port
  377. $q_port = $get_q_and_s['1'];
  378. //software port
  379. $s_port = $get_q_and_s['2'];
  380. $address = "<a href='" . lgsl_software_link($query_name, $query_ip, $c_port, $q_port, $s_port) . "'>".$displayIP.":".$server_home['port']."</a>";
  381. }
  382. if ($server_xml->protocol == "teamspeak3")
  383. $address = "<a href='ts3server://" . $query_ip . ":" . $server_home['port'] . "'>".$displayIP.":".$server_home['port']."</a>";
  384. if($server_xml->protocol == "gameq" and $server_xml->installer == 'steamcmd')
  385. $address = "<a href='steam://connect/" . $query_ip . ":" . $server_home['port'] . "'>" . $displayIP . ":" . $server_home['port'] . "</a>";
  386. $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']);
  387. if ($server_xml->protocol == "teamspeak3")
  388. {
  389. require('protocol/TeamSpeak3/functions.php');
  390. }
  391. $startup_file_exists = $remote->rfile_exists( "startups/".$server_home['ip']."-".$server_home['port'] ) === 1;
  392. 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")) )
  393. {
  394. $ctrlChkBoxes .= '<div id="server_icon" class="action-stop'.$server_home['home_id'].'" ><div>'.
  395. '<input id="action-stop" class="action-stop'.$server_home['home_id'].'" name="action-'.$server_home['home_id'].'" value="stop-'.
  396. $server_home['home_id'].'-'.$server_home['mod_id'].'-'.$server_home['ip'].'-'.$server_home['port'].
  397. '" type="radio"><img style="border:0;height:15px;" src="' . check_theme_image("images/stop.png") . '"/></div><div>&nbsp;'.
  398. get_lang("stop_server") .'</div></div><div id="server_icon" class="action-restart'.$server_home['home_id'].'" ><div>'.
  399. '<input id="action-restart" class="action-restart'.$server_home['home_id'].'" name="action-'.$server_home['home_id'].'" value="restart-'.
  400. $server_home['home_id'].'-'.$server_home['mod_id'].'-'.$server_home['ip'].'-'.$server_home['port'].
  401. '" type="radio"><img style="border:0;height:15px;" src="' . check_theme_image("images/restart.png") . '"/></div><div>&nbsp;'.
  402. get_lang("restart_server") .'</div></div>';
  403. }
  404. $stats_servers_online++;
  405. }
  406. else
  407. {
  408. $status = "offline";
  409. if ($server_home['last_param'] != "" and isset($server_home['ip']) and isset($server_home['mod_id']))
  410. {
  411. if($update_in_progress)
  412. $ctrlChkBoxes .= '<div id="server_icon" class="action-start'.$server_home['home_id'].'" >&nbsp;'. get_lang("update_in_progress") .'</div>';
  413. else
  414. $ctrlChkBoxes .= '<div id="server_icon" class="action-start'.$server_home['home_id'].'" >
  415. <div>
  416. <input id="action-start" class="action-start'.$server_home['home_id'].'" name="action-'.$server_home['home_id'].'" value="start-'.
  417. $server_home['home_id'].'-'.$server_home['mod_id'].'-'.$server_home['ip'].'-'.$server_home['port'].
  418. '" type="radio"><img style="border:0;height:15px;" src="' . check_theme_image("images/start.png") . '"/></div><div>&nbsp;'.
  419. get_lang("start_server") .'</div></div>';
  420. }
  421. $order = 1000 + $j;
  422. if(isset($server_home['mod_id']))
  423. {
  424. ob_start();
  425. require('modules/gamemanager/mini_start.php');
  426. $ministart = ob_get_contents();
  427. ob_end_clean();
  428. }
  429. if($update_in_progress)
  430. $offlineT = '<div id="server_icon" class="action-start'.$server_home['home_id'].'" >&nbsp;'. get_lang("update_in_progress") .'</div>';
  431. else
  432. $offlineT = $ministart;
  433. }
  434. }
  435. else{
  436. $status = "offline";
  437. $order = 1000 + $j;
  438. $address = "<span style='color:darkred;font-weight:bold;'>Agent Offline</span>";
  439. }
  440. $user = $db->getUserById($server_home['user_id_main']);
  441. // Template
  442. @$first = "<tr class='maintr$trclass'>";
  443. $first .= "<td class='collapsible' data-status='$status' data-pos='$pos'><span class='hidden'>$order</span>" . "<img src='" . check_theme_image("images/$status.png") . "' />" . "</td>";
  444. $first .= "<td class='collapsible'>" . "<span class='hidden'>$mod</span><img src='$icon_path' />" . "</td>";
  445. $first .= "<td class='collapsible serverId hide'>" . $server_home["home_id"] . "</td>";
  446. $first .= "<td class='collapsible' data-status='$status' data-pos='$pos'><b>" . htmlentities($server_home['home_name']) . "</b>$mod_name</td>";
  447. $first .= "<td class='collapsible'>" . $address . "</td>";
  448. $first .= "<td class='owner collapsible'>" . $user['users_login'] . "</td>";
  449. $first .= "<td style='width:328px;padding:0px;'>$ctrlChkBoxes</td>";
  450. $first .= "</tr>";
  451. $second = "<tr class='expand-child'>";
  452. @$second .= "<td colspan='4'>" . $refresh->getdiv($pos,"width:100%;") . "$offlineT</td>";
  453. $second .= "<td class='owner' >$other_owners$groupsus</td>";
  454. if( $server_xml->protocol != "teamspeak3" OR ($startup_file_exists and $server_xml->protocol == "teamspeak3") OR ($status == "offline" and $server_xml->protocol == "teamspeak3") )
  455. @$second .= "<td class='operations'><div class='inline-block monitorButtonContainer'>" . trim($btns) . trim($ts3opt) . "<b class='failure' style='float:left;' >$expiration_dates</b></div></td>";
  456. else
  457. $second .= "<td class='operations' >$ts3opt</td>";
  458. $second .= "</tr>";
  459. //Echo them all
  460. echo "$first$second";
  461. }
  462. $j++;
  463. }
  464. echo "</tbody>";
  465. echo "<tfoot style='border:1px solid grey;'>
  466. <tr>
  467. <td colspan='7' >
  468. <div class='bloc' >
  469. <img src='" . check_theme_image("images/magnifglass.png") . "' /> ". get_lang("statistics") .": $stats_servers_online/$stats_servers ". get_lang("servers") ."\n</div>
  470. <div class='right bloc' >
  471. <label>". get_lang("execute_selected_server_operations") ."</label>
  472. <input id='execute_operations' type='submit' value='". get_lang("execute_operations") ."' >\n
  473. </div>
  474. </td>
  475. </tr>
  476. </tfoot>";
  477. echo "</table>";
  478. if ($isAdmin) {
  479. $homes_count = $db->getHomesFor_count('admin', $_SESSION['user_id'], $home_cfg_id,$search_field);
  480. } else {
  481. $isSubUser = $db->isSubUser($_SESSION['user_id']);
  482. if ($isSubUser) {
  483. $homes_count = $db->getHomesFor_count('subuser',$_SESSION['user_id'], $home_cfg_id,$search_field);
  484. } else {
  485. $homes_count = $db->getHomesFor_count('user_and_group',$_SESSION['user_id'], $home_cfg_id,$search_field);
  486. }
  487. }
  488. if(isset($_GET['home_cfg_id']) && !empty($_GET['home_cfg_id'])){
  489. $uri = '?m=gamemanager&p=game_monitor&home_cfg_id='.$_GET['home_cfg_id'].''.($search_field ? "&search=$search_field" : "").'&limit='.$home_limit.'&page=';
  490. }
  491. else{
  492. $uri = '?m=gamemanager&p=game_monitor'.($search_field ? "&search=$search_field" : "").'&limit='.$home_limit.'&page=';
  493. }
  494. if(!isset($_GET['home_id-mod_id-ip-port']) && !isset($_GET['home_id']))
  495. {echo paginationPages($homes_count[0]['total'], $home_page, $home_limit, $uri, 3, 'serverMonitor');}
  496. echo "<div id=translation data-title='". get_lang("upload_map_image") .
  497. "' data-upload_button='". get_lang("upload_image") .
  498. "' data-bad_file='". get_lang("jpg_gif_png_less_than_1mb") .
  499. "' data-upload_failure='". get_lang("check_dev_console") .
  500. "' ></div>\n";
  501. ?>
  502. <script type="text/javascript">
  503. <?php echo $refresh->build(isset($settings['query_cache_life']) ? $settings['query_cache_life'] * 2000 : 60000); ?>
  504. </script>
  505. <?php
  506. }
  507. ?>