server_monitor.php 30 KB

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