server_monitor.php 29 KB

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