server_monitor.php 29 KB

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