server_monitor.php 27 KB

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