server_monitor.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  1. <style>
  2. .monitorbutton{
  3. display:inline;
  4. width:auto !important;
  5. }
  6. .monitorbutton tr td{
  7. cursor:pointer;
  8. color: #323232;
  9. background-color:#F0F0F6;
  10. transition: background-color 0.5s;
  11. -webkit-transition: background-color 0.5s;
  12. border: 1px solid grey;
  13. width:145px !important;
  14. height:72px !important;
  15. background-color: #F0F0F6 !important;
  16. vertical-align: middle !important;
  17. }
  18. .monitorbutton tr td:hover {
  19. background-color:#D9D9D9 !important;
  20. transition: background-color 0.5s;
  21. -webkit-transition: background-color 0.5s;
  22. cursor:pointer;
  23. }
  24. .monitorbutton tr td a:hover {
  25. text-decoration:none;
  26. }
  27. button:active, button[type="submit"]:active, input[type="submit"]:active, .monitorbutton tr td:active {
  28. background-color:#0F0 !important;
  29. transition: background-color 0.25s;
  30. -webkit-transition: background-color 0.25s;
  31. }
  32. #server_icon{
  33. display:block;
  34. float:left;
  35. overflow:hidden;
  36. margin:2px;
  37. margin-right:10px;
  38. padding-top:1px;
  39. padding-bottom:2px;
  40. padding-right:5px;
  41. border:1px solid gray;
  42. background:transparent;
  43. cursor:pointer;
  44. background-color:white;
  45. border-radius:3px;
  46. font-weight:bold;
  47. }
  48. #server_icon div{
  49. display:inline-block;
  50. vertical-align:middle;
  51. }
  52. </style>
  53. <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
  54. <script type="text/javascript" src="js/jquery.quicksearch.js"></script>
  55. <script type="text/javascript" src="js/jquery.tablesorter.mod.js"></script>
  56. <script type="text/javascript" src="js/jquery.tablesorter.collapsible.js"></script>
  57. <?php
  58. /*
  59. *
  60. * OGP - Open Game Panel
  61. * Copyright (C) Copyright (C) 2008 - 2013 The OGP Development Team
  62. *
  63. * http://www.opengamepanel.org/
  64. *
  65. * This program is free software; you can redistribute it and/or
  66. * modify it under the terms of the GNU General Public License
  67. * as published by the Free Software Foundation; either version 2
  68. * of the License, or any later version.
  69. *
  70. * This program is distributed in the hope that it will be useful,
  71. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  72. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  73. * GNU General Public License for more details.
  74. *
  75. * You should have received a copy of the GNU General Public License
  76. * along with this program; if not, write to the Free Software
  77. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  78. *
  79. */
  80. require_once('modules/gamemanager/home_handling_functions.php');
  81. require_once("modules/config_games/server_config_parser.php");
  82. require_once("includes/refreshed.php");
  83. require_once('includes/lib_remote.php');
  84. function renderParam($param, $param_access_enabled, $home_id)
  85. {
  86. global $db;
  87. $attributesString = "";
  88. foreach ($param->attribute as $attribute)
  89. $attributesString .= $attribute['key']. "='$attribute' ";
  90. $disabledString = ($param_access_enabled) ? "" : "disabled ";
  91. //get last used param or get default
  92. $last_param = json_decode($db->getLastParam($home_id), True);
  93. if (array_key_exists((string)$param['key'], $last_param))
  94. $paramValue = (string)$last_param[(string)$param['key']];
  95. else
  96. $paramValue = (string)$param->default;
  97. $idString = "id='".clean_id_string($param['key'])."'";
  98. $nameString = "name='params[".$param['key']."]'";
  99. $paramType = $param['type'];
  100. if ($paramType == "select")
  101. {
  102. $inputElementString = "<select $idString $nameString>";
  103. foreach ($param->option as $option)
  104. {
  105. $optionValue = (string)($option['value']);
  106. $selectedString = ($optionValue == $paramValue) ? "selected='selected'" : "";
  107. $valueString = "value='$optionValue'";
  108. $inputElementString .= "<option $selectedString $valueString>$option</option>";
  109. }
  110. $inputElementString .="</select>";
  111. } else
  112. {
  113. if ($paramType == "checkbox_key_value") {
  114. if ($paramValue) // convert the XML object to string
  115. $attributesString .= "checked='checked' ";
  116. $paramValue = $param['key'];
  117. $paramType = "checkbox";
  118. }
  119. else if ($paramType == "checkbox")
  120. {
  121. if ($paramValue) // convert the XML object to string
  122. $attributesString .= "checked='checked' ";
  123. }
  124. $inputElementString = "<input $idString $nameString ".
  125. "type='$paramType' value='$paramValue' ".
  126. "$disabledString $attributesString/>";
  127. }
  128. echo "<tr><td class='right'><label for='".clean_id_string($param['key'])."'>".$param['key'].
  129. ":</label></td><td class='left'>$inputElementString<label for='".clean_id_string($param['key'])."'>";
  130. if ( !empty($param->caption) )
  131. echo $param->caption;
  132. if ( !empty($param->desc) )
  133. echo "<br/><span class='info'>(".$param->desc.")</span>";
  134. echo "</label></td></tr>\n";
  135. }
  136. function get_sync_name($server_xml)
  137. {
  138. if( isset($server_xml->lgsl_query_name) )
  139. {
  140. $sync_name = $server_xml->lgsl_query_name;
  141. if($sync_name == "quake3")
  142. {
  143. if($server_xml->game_name == "Quake 3")
  144. $sync_name = "q3";
  145. }
  146. }
  147. elseif( isset($server_xml->gameq_query_name) )
  148. {
  149. $sync_name = $server_xml->gameq_query_name;
  150. if($sync_name == "minecraft")
  151. {
  152. if($server_xml->game_name == "Minecraft Tekkit")
  153. $sync_name = "tekkit";
  154. elseif($server_xml->game_name == "Minecraft Bukkit")
  155. $sync_name = "bukkit";
  156. }
  157. }
  158. elseif( isset($server_xml->protocol) )
  159. $sync_name = $server_xml->protocol;
  160. else
  161. $sync_name = $server_xml->mods->mod['key'];
  162. return $sync_name;
  163. }
  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. function exec_ogp_module() {
  173. global $db;
  174. echo "<h2>".get_lang('game_monitor')."</h2>";
  175. $refresh = new refreshed(100000);
  176. set_time_limit(0);
  177. $stats_servers_online = 0;
  178. $stats_servers = 0;
  179. $stats_players = 0;
  180. $stats_maxplayers = 0;
  181. $isAdmin = $db->isAdmin( $_SESSION['user_id'] );
  182. if ( $isAdmin )
  183. $server_homes = $db->getIpPorts();
  184. else
  185. $server_homes = $db->getIpPortsForUser($_SESSION['user_id']);
  186. if( $server_homes === FALSE )
  187. {
  188. // If there are no games, then there can not be any mods either.
  189. print_failure(get_lang('no_game_homes_assigned'));
  190. if ( $isAdmin )
  191. {
  192. echo "<p><a href='?m=user_games&amp;p=assign&amp;user_id=$_SESSION[user_id]'>".
  193. get_lang('assign_game_homes')."</a></p>";
  194. }
  195. return;
  196. }
  197. if ( empty( $_GET['home_id-mod_id-ip-port'] ) )
  198. unset( $_GET['home_id-mod_id-ip-port'] );
  199. if ( empty( $_GET['home_id'] ) )
  200. unset( $_GET['home_id'] );
  201. if ( $_GET['home_cfg_id'] == get_lang('game_type') )
  202. unset( $_GET['home_cfg_id'] );
  203. create_home_selector_game_type($_GET['m'], $_GET['p'], $server_homes);
  204. if (!isset($_GET['home_id-mod_id-ip-port']) and !isset($_GET['home_id']) and !isset($_GET['home_cfg_id']))
  205. {
  206. create_home_selector_address($_GET['m'], $_GET['p'], $server_homes);
  207. $show_all = TRUE;
  208. }
  209. else
  210. {
  211. create_home_selector_address($_GET['m'], $_GET['p'], $server_homes);
  212. create_home_selector($_GET['m'], $_GET['p'], "show_all");
  213. $show_all = FALSE;
  214. }
  215. require("protocol/lgsl/lgsl_protocol.php");
  216. ?>
  217. <form>
  218. <b><?php print_lang('search'); ?>:</b>
  219. <input type="text" id="search">
  220. </form>
  221. <?php
  222. $info = $db->getUser($_SESSION['users_login']);
  223. $chk_expire = $info['user_expires'];
  224. $exptime = read_expire($chk_expire);
  225. $time_to_expire = str_replace('hr', 'hours', $exptime);
  226. if($exptime != "X")
  227. {
  228. ?>
  229. <span style="color:black;font-weight:bold;">
  230. <center>
  231. <?php echo print_lang('account_expiration'); ?>: <span style="color:green;"><?php echo date( "l, F jS, Y, H:i:s", $chk_expire )." ( ".$time_to_expire.")"; ?></span>
  232. </center>
  233. </span>
  234. <?php
  235. }
  236. ?>
  237. <table id="servermonitor" class="tablesorter">
  238. <thead>
  239. <tr>
  240. <th style="width:16px;background-position: center;"></th>
  241. <th style="width:16px;background-position: center;"></th>
  242. <th><?php print_lang('server_name'); ?></th>
  243. <th><?php print_lang('address'); ?></th>
  244. <th><?php print_lang('owner'); ?></th>
  245. <th>
  246. <?php print_lang('operations'); ?>
  247. <img style="border:0;height:15px;" id="action-stop" src="images/stop.png"/>
  248. <img style="border:0;height:15px;" id="action-restart" src="images/restart.png"/>
  249. <img style="border:0;height:15px;" id="action-start" src="images/start.png"/>
  250. </th>
  251. </tr>
  252. </thead>
  253. <tbody>
  254. <?php
  255. foreach( $server_homes as $server_home )
  256. {
  257. $stats_servers++;
  258. //Unset variables.
  259. if( isset( $_GET['home_id-mod_id-ip-port']) )
  260. {
  261. $pieces = explode( "-", $_GET['home_id-mod_id-ip-port'] );
  262. $post_home_id = $pieces[0];
  263. $post_mod_id = $pieces[1];
  264. $post_ip = $pieces[2];
  265. $post_port = $pieces[3];
  266. }
  267. if( $show_all
  268. OR ( isset( $_GET['home_id'] ) and $_GET['home_id'] == $server_home['home_id'] )
  269. 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'] )
  270. OR ( isset( $_GET['home_cfg_id'] ) and $_GET['home_cfg_id'] == $server_home['home_cfg_id'] )
  271. )
  272. {
  273. unset(
  274. $map,
  275. $trclass,
  276. $first,
  277. $second,
  278. $onlineT,
  279. $ts3opt,
  280. $offlineT,
  281. $halfT,
  282. $ministart,
  283. $player_list,
  284. $groupsus,
  285. $name,
  286. $mod_name,
  287. $SrvCtrl,
  288. $lite_fm,
  289. $manager,
  290. $user,
  291. $pos,
  292. $ftp,
  293. $addonsmanager,
  294. $ctrlChkBoxes
  295. );
  296. //End
  297. if ( $isAdmin )
  298. {
  299. $server_home['access_rights'] = "ufpet";
  300. }
  301. else
  302. {
  303. $home_info = $db->getUserGameHome($_SESSION['user_id'],$server_home['home_id']);
  304. $server_home['access_rights'] = $home_info['access_rights'];
  305. }
  306. $litefm_installed = $db->isModuleInstalled('litefm');
  307. $ftp_installed = $db->isModuleInstalled('ftp');
  308. $addonsmanager_installed = $db->isModuleInstalled('addonsmanager');
  309. $mysql_installed = $db->isModuleInstalled('mysql');
  310. if ($server_home['mod_name'] == "none" OR $server_home['mod_name'] == "None")
  311. $mod_name = "";
  312. elseif($server_home['mod_name'] != $server_home['game_name'])
  313. $mod_name = " ( ".$server_home['mod_name']." )";
  314. $get_size = "<table align='left' class='monitorbutton' ><tr>".
  315. "<td align='middle' class='size' id='".$server_home["home_id"]."'>".
  316. "<img style='border:0;height:40px;vertical-align:middle;' src='images/file_size.png' title='".
  317. get_lang('get_size')."'/>\n<br /><span style='font-weight:bold;'>".get_lang('get_size')."</span></td></tr></table>";
  318. $manager = "<a href='?m=user_games&amp;p=edit&amp;home_id=".$server_home['home_id']."'>\n".
  319. "<table align='left' class='monitorbutton' ><tr><td align='middle' >".
  320. "<img style='border:0;height:40px;vertical-align:middle;' src='images/edit.png' title='".
  321. get_lang('edit')."'/>\n<br />".get_lang('edit')."\n</td></tr></table></a>";
  322. // Only show the filemanager link when the litefm is installed.
  323. if ( preg_match("/f/",$server_home['access_rights']) > 0 && $litefm_installed )
  324. {
  325. $lite_fm = "<a href='?m=litefm&amp;home_id=".$server_home['home_id']."'>\n".
  326. "<table align='left' class='monitorbutton' ><tr><td align='middle' >".
  327. "<img style='border:0;height:40px;vertical-align:middle;' src='images/txt.png' title='".
  328. get_lang('file_manager')."'/>\n<br />".get_lang('file_manager')."\n</td></tr></table></a>";
  329. }
  330. if ( preg_match("/t/",$server_home['access_rights']) > 0 && $ftp_installed )
  331. {
  332. $ftp = "<a href='?m=ftp&amp;home_id=".$server_home['home_id']."'>\n".
  333. "<table align='left' class='monitorbutton' ><tr><td align='middle' >".
  334. "<img style='border:0;height:40px;vertical-align:middle;' src='images/ftp.png' title='".
  335. get_lang('ftp')."'/>\n<br>".get_lang('ftp')."\n</td></tr></table></a>";
  336. }
  337. if ( $addonsmanager_installed )
  338. {
  339. $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']);
  340. $addons_qty = count($addons);
  341. if($addons and $addons_qty >= 1){
  342. $addonsmanager = "<a href='?m=addonsmanager&amp;p=user_addons&amp;home_id=".$server_home['home_id'].
  343. "&amp;ip=".$server_home['ip']."&amp;port=".$server_home['port']."'>\n".
  344. "<table align='left' class='monitorbutton' ><tr><td align='middle' >".
  345. "<img style='border:0;height:40px;vertical-align:middle;' src='modules/administration/images/addons_manager.png' title='".
  346. get_lang('addons')."'/>\n<br />".get_lang('addons')."\n<b style='font-size:0.9em' >(".
  347. $addons_qty.")</td></tr></table></a>";
  348. }
  349. }
  350. if ( $mysql_installed )
  351. {
  352. $mysql_dbs = $db->resultQuery("SELECT db_id FROM OGP_DB_PREFIXmysql_databases WHERE enabled=1 AND home_id=".$server_home['home_id']);
  353. if(!empty($mysql_dbs))
  354. $mysql = "<a href='?m=mysql&p=user_db&home_id=".$server_home['home_id']."'>\n".
  355. "<table align='left' class='monitorbutton' ><tr><td align='middle' >".
  356. "<img style='border:0;height:40px;vertical-align:middle;' src='modules/administration/images/mysql_admin.png' title='".
  357. get_lang('mysql_databases')."'/>\n<br />".get_lang('mysql_databases')."\n</td></tr></table></a>\n";
  358. }
  359. $mod_result = $db->getHomeMods($server_home['home_id']);
  360. if( $mod_result === FALSE )
  361. {
  362. print_failure(get_lang('fail_no_mods'));
  363. if ( $isAdmin )
  364. {
  365. $manager .= "<a href='?m=user_games&amp;p=edit&amp;home_id=".$server_home['home_id']."'>".get_lang('configure_mods')."</a>";
  366. }
  367. continue;
  368. }
  369. $server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$server_home['home_cfg_file']);
  370. $master_server_home_id = $db->getMasterServer( $server_home['remote_server_id'], $server_home['home_cfg_id'] );
  371. if ( $master_server_home_id != FALSE )
  372. {
  373. if ( !$db->getGameHomeWithoutMods($master_server_home_id) )
  374. {
  375. $db->setMasterServer("remove", $master_server_home_id, $server_home['home_cfg_id'], $server_home['remote_server_id']);
  376. $master_server_home_id = FALSE;
  377. }
  378. }
  379. if ( $server_xml )
  380. {
  381. if (preg_match("/u/",$server_home['access_rights']) > 0)
  382. {
  383. // In case game is compatible with steam we offer a way to use steam with the updates.
  384. if( $server_xml->installer == "steamcmd" )
  385. {
  386. if( $master_server_home_id != FALSE AND $master_server_home_id != $server_home['home_id'] )
  387. {
  388. $manager .= "<form name='steam_master_".$server_home['home_id']."_".$server_home['mod_id'].
  389. "_".str_replace(".","",$server_home['ip'])."_".$server_home['port']."' action='?m=gamemanager&amp;p=update&amp;home_id=".
  390. $server_home['home_id']."&amp;mod_id=".$server_home['mod_id']."&amp;update=update' method='POST' >\n".
  391. "<table align='left' class='monitorbutton' >\n".
  392. "<tr><td align='middle' onclick='document.steam_master_".$server_home['home_id']."_".
  393. $server_home['mod_id']."_".str_replace(".","",$server_home['ip'])."_".$server_home['port'].
  394. ".submit()' ><img style='border:0;height:40px;vertical-align:middle;' src='images/master.png' />".
  395. "<br /><span style='font-weight:bold;'>".get_lang('update_from_local_master_server').
  396. "</span><input id='master".$server_home['home_id'].
  397. "' type='hidden' name='master_server_home_id' value='".$master_server_home_id.
  398. "' /></td></tr>\n</table>\n</form>";
  399. }
  400. $manager .= "<form name='steam_".$server_home['home_id']."_".$server_home['mod_id']."_".
  401. str_replace(".","",$server_home['ip'])."_".$server_home['port']."' action='?m=gamemanager&amp;p=update&amp;home_id=".
  402. $server_home['home_id']."&amp;mod_id=".$server_home['mod_id']."&amp;update=update' method='POST' >\n".
  403. "<table align='left' class='monitorbutton' >\n".
  404. "<tr><td align='middle' onclick='document.steam_".$server_home['home_id']."_".$server_home['mod_id']."_".str_replace(".","",$server_home['ip']).
  405. "_".$server_home['port'].".submit()' ><img style='border:0;height:40px;vertical-align:middle;' src='images/steam.png' />".
  406. "<br /><span style='font-weight:bold;'>".get_lang('install_update_steam').
  407. "</span></td></tr>\n</table>\n</form>";
  408. }
  409. // In other cases manual update is provided.
  410. else
  411. {
  412. $manager .= "<a href='?m=gamemanager&amp;p=update_manual&amp;home_id=".$server_home['home_id'].
  413. "&amp;mod_id=".$server_home['mod_id']."&amp;update=update'>\n".
  414. "<table align='left' class='monitorbutton' ><tr><td align='middle' >".
  415. "<img style='border:0;height:40px;vertical-align:middle;' src='images/install.png' title='".
  416. get_lang('install_update_manual')."'/>\n<br>".get_lang('install_update_manual')."\n</td></td></table></a>";
  417. $sync_name = get_sync_name($server_xml);
  418. $sync_list = @file("modules/gamemanager/rsync.list", FILE_IGNORE_NEW_LINES);
  419. $master_server_home_id = $db->getMasterServer( $server_home['remote_server_id'], $server_home['home_cfg_id'] );
  420. if ( in_array($sync_name, $sync_list) OR ($master_server_home_id != FALSE and $master_server_home_id != $server_home['home_id']) )
  421. {
  422. $manager .= "<a href='?m=gamemanager&amp;p=rsync_install&amp;home_id=".$server_home['home_id'].
  423. "&amp;mod_id=".$server_home['mod_id']."&amp;update=update'>\n".
  424. "<table align='left' class='monitorbutton' ><tr><td align='middle' >".
  425. "<img style='border:0;height:40px;vertical-align:middle;' src='images/rsync.png' title='".
  426. get_lang('rsync_install')."'/>\n<br />".get_lang('rsync_install')."\n</td></td></table></a>";
  427. }
  428. }
  429. }
  430. }
  431. if( $isAdmin )
  432. {
  433. if ($server_xml->control_protocol == 'rcon' OR
  434. $server_xml->control_protocol == 'lcon' OR
  435. $server_xml->control_protocol == 'rcon2' OR
  436. @$server_xml->gameq_query_name == 'minecraft')
  437. {
  438. $manager .= "<form name='rcon_preset".$server_home['home_id']."' action='home.php?m=gamemanager&amp;p=rcon_presets&amp;home_id=".
  439. $server_home['home_id']."&amp;mod_id=".$server_home['mod_id']."' method='POST'>\n".
  440. "<table align='left' class='monitorbutton' >\n".
  441. "<tr>\n".
  442. "<td align='middle' onclick='document.rcon_preset".$server_home['home_id'].
  443. ".submit()' ><img style='border:0;height:40px;vertical-align:middle;' src='images/rcon_preset.png' /><br /><span style='font-weight:bold;'>".
  444. get_lang('rcon_presets').
  445. "</span></td>\n".
  446. "</tr>\n".
  447. "</table>\n".
  448. "</form>";
  449. }
  450. }
  451. $xml_installer = $server_xml->installer;
  452. // If query name does not exist use mod key instead.
  453. if ($server_xml->protocol == "gameq")
  454. $query_name = $server_xml->gameq_query_name;
  455. elseif ($server_xml->protocol == "lgsl")
  456. $query_name = $server_xml->lgsl_query_name;
  457. elseif ($server_xml->mods->mod['key'] == "none" OR $server_xml->mods->mod['key'] == "None")
  458. $query_name = "none";
  459. else
  460. $query_name = $server_xml->mods->mod['key'];
  461. if ($server_xml->mods->mod['key'] == "none" OR $server_xml->mods->mod['key'] == "None")
  462. $mod = "none";
  463. else
  464. $mod = $server_xml->mods->mod['key'];
  465. //----------+ getting the lgsl image icon
  466. $icon_paths = array("images/icons/$mod.png",
  467. "images/icons/$query_name.png",
  468. "protocol/lgsl/other/icon_unknown.gif");
  469. $icon_path = get_first_existing_file($icon_paths);
  470. //Properties for all servers
  471. if(isset($post_home_id) && $post_home_id == $server_home['home_id'] OR isset($_GET['home_id']) && $_GET['home_id'] == $server_home['home_id'] )
  472. $trclass = " expandme";
  473. $groupusers = $db->getGroupUsersByHomeId($server_home['home_id']);
  474. if($groupusers)
  475. {
  476. $groupsus = "<b>".get_lang('group_users')."</b><br>";
  477. foreach($groupusers as $groupu)
  478. $groupsus .= $groupu['users_login']."<br>";
  479. }else
  480. $groupsus = "";
  481. $view_log = "<a href='?m=gamemanager&amp;p=log&amp;home_id-mod_id-ip-port=".$server_home['home_id']."-".
  482. $server_home['mod_id']."-".$server_home['ip']."-".$server_home['port']."'>\n".
  483. "<table align='left' class='monitorbutton' ><tr><td align='middle' >".
  484. "<img style='border:0;height:40px;vertical-align:middle;' src='images/log.png' title='".
  485. get_lang('view_log')."'/>\n<br>".get_lang('view_log')."\n</td></tr></table></a>";
  486. $btns = $view_log.
  487. @$ftp.
  488. @$lite_fm.
  489. @$addonsmanager;
  490. //End
  491. $remote = new OGPRemoteLibrary($server_home['agent_ip'], $server_home['agent_port'], $server_home['encryption_key'], $server_home['timeout']);
  492. $host_stat = $remote->status_chk();
  493. if( $host_stat === 1)
  494. {
  495. if ( $server_home['use_nat'] == 1 )
  496. $query_ip = $server_home['agent_ip'];
  497. else
  498. $query_ip = $server_home['ip'];
  499. $address = $query_ip . ":" . $server_home['port'];
  500. $screen_running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME,$server_home['home_id']) === 1;
  501. $update_in_progress = $remote->is_screen_running(OGP_SCREEN_TYPE_UPDATE,$server_home['home_id']) === 1;
  502. if($screen_running)
  503. {
  504. // Check if the screen running the server is running.
  505. $status = "online";
  506. $order=1;
  507. if ($server_xml->protocol == "lgsl")
  508. {
  509. $get_q_and_s = lgsl_port_conversion((string)$query_name, $server_home['port'], "", "");
  510. //Connection port
  511. $c_port = $get_q_and_s['0'];
  512. //query port
  513. $q_port = $get_q_and_s['1'];
  514. //software port
  515. $s_port = $get_q_and_s['2'];
  516. $address = "<a href='" . lgsl_software_link($query_name, $query_ip, $c_port, $q_port, $s_port) . "'>".$query_ip.":".$server_home['port']."</a>";
  517. }
  518. if ($server_xml->protocol == "teamspeak3")
  519. {
  520. $address = "<a href='ts3server://" . $query_ip . ":" . $server_home['port'] . "'>".$query_ip.":".$server_home['port']."</a>";
  521. }
  522. $pos = $refresh->add("home.php?m=gamemanager&p=ref_servermonitor&type=cleared&server_home=". $server_home['home_id'] . "&ip=" . $server_home['ip'] . "&port=" . $server_home['port']);
  523. if ($server_xml->protocol == "teamspeak3")
  524. {
  525. require('protocol/TeamSpeak3/functions.php');
  526. }
  527. $startup_file_exists = $remote->rfile_exists( "startups/".$server_home['ip']."-".$server_home['port'] ) === 1;
  528. $ctrlChkBoxes .= '<div id="server_icon" class="action-stop'.$server_home['home_id'].'" >
  529. <div>
  530. <input id="action-stop" class="action-stop'.$server_home['home_id'].'" name="action-'.$server_home['home_id'].'" value="stop-'.
  531. $server_home['home_id'].'-'.$server_home['mod_id'].'-'.$server_home['ip'].'-'.$server_home['port'].
  532. '" type="radio"><img style="border:0;height:15px;" src="images/stop.png"/></div><div>&nbsp;'.
  533. get_lang('stop_server').'</div></div>';
  534. if($startup_file_exists)
  535. {
  536. $ctrlChkBoxes .= '<div id="server_icon" class="action-restart'.$server_home['home_id'].'" >
  537. <div>
  538. <input id="action-restart" class="action-restart'.$server_home['home_id'].'" name="action-'.$server_home['home_id'].'" value="restart-'.
  539. $server_home['home_id'].'-'.$server_home['mod_id'].'-'.$server_home['ip'].'-'.$server_home['port'].
  540. '" type="radio"><img style="border:0;height:15px;" src="images/restart.png"/></div><div>&nbsp;'
  541. .get_lang('restart_server').'</div></div>';
  542. }
  543. $stats_servers_online++;
  544. }
  545. else
  546. {
  547. $status = "offline";
  548. if ($db->getLastParam($server_home['home_id']) != FALSE)
  549. {
  550. if($update_in_progress)
  551. $ctrlChkBoxes .= '<div id="server_icon" class="action-start'.$server_home['home_id'].'" >&nbsp;'.get_lang('update_in_progress').'</div>';
  552. else
  553. $ctrlChkBoxes .= '<div id="server_icon" class="action-start'.$server_home['home_id'].'" >
  554. <div>
  555. <input id="action-start" class="action-start'.$server_home['home_id'].'" name="action-'.$server_home['home_id'].'" value="start-'.
  556. $server_home['home_id'].'-'.$server_home['mod_id'].'-'.$server_home['ip'].'-'.$server_home['port'].
  557. '" type="radio"><img style="border:0;height:15px;" src="images/start.png"/></div><div>&nbsp;'.
  558. get_lang('start_server').'</div></div>';
  559. }
  560. $order = 3;
  561. ob_start();
  562. require('modules/gamemanager/mini_start.php');
  563. $ministart = ob_get_contents();
  564. ob_end_clean();
  565. if($update_in_progress)
  566. $offlineT = '<div id="server_icon" class="action-start'.$server_home['home_id'].'" >&nbsp;'.get_lang('update_in_progress').'</div>';
  567. else
  568. $offlineT = $ministart;
  569. }
  570. }
  571. else{
  572. $status = "offline";
  573. $order = 3;
  574. $address = "<span style='color:darkred;font-weight:bold;'>Agent Offline</span>";
  575. }
  576. $user = $db->getUserById($server_home['user_id_main']);
  577. // Template
  578. @$first = "<tr class='maintr$trclass'>";
  579. $first .= "<td class='collapsible'><span class='hidden'>$order</span><a></a>" . "<img src='images/$status.png' />" . "</td>";
  580. $first .= "<td>" . "<span class='hidden'>$mod</span><img src='$icon_path' />" . "</td>";
  581. $first .= "<td class='collapsible'><a></a><b>" . $server_home['home_name'] . "</b>$mod_name</td>";
  582. $first .= "<td>" . $address . "</td>";
  583. $first .= "<td>" . $user['users_login'] . "</td>";
  584. $first .= "<td style='width:328px;padding:0px;'>$ctrlChkBoxes</td>";
  585. $first .= "</tr>";
  586. $second = "<tr class='expand-child'>";
  587. @$second .= "<td colspan='4'>" . $refresh->getdiv($pos,"width:100%;") . "$offlineT</td>";
  588. $second .= "<td width='80'>$groupsus</td>";
  589. @$second .= "<td>$btns$manager<br>$mysql<br>$get_size<br>$ts3opt</td>";
  590. $second .= "</tr>";
  591. //Echo them all
  592. echo "$first$second";
  593. }
  594. }
  595. echo "</tbody>";
  596. echo "<tfoot style='border:1px solid grey;'>
  597. <tr>
  598. <td colspan='6' >
  599. <div class='bloc' >
  600. <img src='images/magnifglass.png' /> ".get_lang('statistics').": $stats_servers_online/$stats_servers ".get_lang('servers')."\n</div>
  601. <div class='right bloc' >
  602. <label>".get_lang('execute_selected_server_operations')."</label>
  603. <input id='execute_operations' type='submit' value='".get_lang('execute_operations')."' >\n
  604. </div>
  605. </td>
  606. </tr>
  607. </tfoot>";
  608. echo "</table>";
  609. ?>
  610. <script type="text/javascript">
  611. $(document).ready(function()
  612. {
  613. <?php echo $refresh->build("8000"); ?>
  614. $('input#search').quicksearch('table#servermonitor tbody tr.maintr');
  615. $("#servermonitor")
  616. .collapsible("td.collapsible", {collapse: true})
  617. .tablesorter({sortList: [[0,0], [1,0]] , widgets: ['zebra','repeatHeaders']})
  618. ;
  619. }
  620. );
  621. $("div#server_icon").click(function(){
  622. var id = $(this).attr('class');
  623. if($("input[type=radio]."+id).attr('checked') == 'checked')
  624. {
  625. $("input[type=radio]."+id).prop('checked', false);
  626. }
  627. else
  628. {
  629. $("input[type=radio]."+id).prop('checked', true);
  630. }
  631. });
  632. $('.size').click(function(){
  633. var $id = $(this).attr('id');
  634. $.get( "home.php?m=user_games&type=cleared&p=get_size&home_id="+$id, function( data ) {
  635. $('#'+$id+".size").text( data );
  636. $('#'+$id+".size").css("font-size", "16pt");
  637. });
  638. });
  639. $('#execute_operations').click(function(){
  640. var addpost = {};
  641. $('input[type=radio]:checked').each(function( ){
  642. var name = $(this).attr('name');
  643. var value = $(this).val();
  644. addpost[ name ] = value;
  645. });
  646. $('.right.bloc').html('<img src="images/loading.gif" />');
  647. $.ajax({
  648. type: "POST",
  649. url: "home.php?m=gamemanager&p=game_monitor",
  650. data: addpost,
  651. complete: function(){
  652. document.location.reload();
  653. }
  654. });
  655. });
  656. $('img#action-stop').click(function(){
  657. $('input[type=radio]#action-stop').each(function( ){
  658. if( this.checked )
  659. {
  660. $(this).attr('checked', false);
  661. }
  662. else
  663. {
  664. $(this).attr('checked', true);
  665. }
  666. });
  667. });
  668. $('img#action-restart').click(function(){
  669. $('input[type=radio]#action-restart').each(function( ){
  670. if( this.checked )
  671. {
  672. $(this).attr('checked', false);
  673. }
  674. else
  675. {
  676. $(this).attr('checked', true);
  677. }
  678. });
  679. });
  680. $('img#action-start').click(function(){
  681. $('input[type=radio]#action-start').each(function( ){
  682. if( this.checked )
  683. {
  684. $(this).attr('checked', false);
  685. }
  686. else
  687. {
  688. $(this).attr('checked', true);
  689. }
  690. });
  691. });
  692. </script>
  693. <?php
  694. }
  695. ?>