1
0

query_ref.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) 2008 - 2018 The OGP Development Team
  6. *
  7. * http://www.opengamepanel.org/
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. *
  23. */
  24. function print_player_list_ogp_dashboard($player_list,$players,$playersmax,$gamename)
  25. {
  26. $data = "<center><table class='currently-online' >".
  27. "<tr><td style='text-align:left;'>".
  28. $gamename." [".$players.'/'.$playersmax."] ".
  29. get_lang('players').":</td>\n</tr>";
  30. foreach( $player_list as $player )
  31. {
  32. $data .= "<tr><td style='text-align:center;color:#".rand(0,5).rand(0,5).rand(0,5).";' >".$player['name']."</td></tr>";
  33. }
  34. $data .= '</table></center><br><br>';
  35. return $data;
  36. }
  37. function exec_ogp_module()
  38. {
  39. $server_key = 'server_'.$_GET['ip'].'_'.$_GET['port'];
  40. if(isset($_GET['show']) and $_GET['show'] == "players")
  41. {
  42. if(isset($_SESSION[$server_key]['online_players']))
  43. {
  44. echo $_SESSION[$server_key]['online_players'];
  45. }
  46. return;
  47. }
  48. if(isset($_GET['show']) and $_GET['show'] == "player_statistics")
  49. {
  50. //if($_SESSION['player_statistics']['playersmax'] > 0)
  51. echo $_SESSION['player_statistics']['players'] . "/" . $_SESSION['player_statistics']['playersmax']. " " . players;
  52. return;
  53. }
  54. global $db;
  55. require('modules/gamemanager/home_handling_functions.php');
  56. require('modules/config_games/server_config_parser.php');
  57. $server_home = $_SESSION[$server_key];
  58. $server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$server_home['home_cfg_file']);
  59. $port = $server_home['port'];
  60. $query_name = "";
  61. $mod = "";
  62. $stats_players = 0;
  63. $stats_maxplayers = 0;
  64. $ip = $server_home['ip'];
  65. $port = $server_home['port'];
  66. // Check if the screen running the server is running.
  67. if ($server_xml->protocol == "gameq")
  68. {
  69. function print_player_list_gameq($player_list,$players,$playersmax){return FALSE;}
  70. require('protocol/GameQ/GameQMonitor.php');
  71. }
  72. else if ($server_xml->protocol == "lgsl")
  73. {
  74. require('protocol/lgsl/functions.php');
  75. require('protocol/lgsl/LGSLMonitor.php');
  76. }
  77. else if ($server_xml->protocol == "teamspeak3")
  78. {
  79. require('protocol/TeamSpeak3/TS3Monitor.php');
  80. }
  81. else
  82. {
  83. $status = "half";
  84. }
  85. if($status == "online")
  86. {
  87. echo "<div class='name' ><a title='".htmlentities($server_home['home_name']).
  88. "' href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=".
  89. $server_home['home_id']."-".$server_home['mod_id']."-".$server_home['ip']."-".$server_home['port'].
  90. "' ><img style='border:0;height:12px;' src='images/magnifglass.png'/><span>".
  91. htmlentities($server_home['home_name'])."</span></a></div>".
  92. "<div><div style='font-size:8pt;' >[".$players.'/'.$playersmax."]</div> " . ((isset($mapRaw) && !empty($mapRaw)) ? htmlentities($mapRaw) : $map) .'</div>'.
  93. "<div id='gamelink' >$address</div>";
  94. $_SESSION[$server_key]['playersmax'] = $playersmax;
  95. if ( $players >= 1 )
  96. {
  97. $_SESSION[$server_key]['online_players'] = print_player_list_ogp_dashboard($playersList,$players,$playersmax,$server_home['game_name']);
  98. }
  99. elseif(isset($_SESSION[$server_key]['online_players']))
  100. unset($_SESSION[$server_key]['online_players']);
  101. if ( isset($_SESSION[$server_key]['server_playersmax']) )
  102. {
  103. if( $_SESSION[$server_key]['server_playersmax'] != $playersmax )
  104. {
  105. $_SESSION['player_statistics']['playersmax'] += ($playersmax - $_SESSION['player_statistics']['playersmax']);
  106. $_SESSION[$server_key]['server_playersmax'] = $playersmax;
  107. }
  108. }
  109. else
  110. {
  111. $_SESSION['player_statistics']['playersmax'] += $playersmax;
  112. $_SESSION[$server_key]['server_playersmax'] = $playersmax;
  113. }
  114. if ( isset($_SESSION[$server_key]['server_players']) )
  115. {
  116. if($_SESSION[$server_key]['server_players'] != $players)
  117. {
  118. $_SESSION['player_statistics']['players'] += ($players - $_SESSION[$server_key]['server_players']);
  119. $_SESSION[$server_key]['server_players'] = $players;
  120. }
  121. }
  122. else
  123. {
  124. $_SESSION['player_statistics']['players'] += $players;
  125. $_SESSION[$server_key]['server_players'] = $players;
  126. }
  127. }
  128. elseif($status == "half")
  129. {
  130. echo "<div class='name' ><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=" .
  131. $server_home['home_id'] . "-" . $server_home['mod_id'] . "-" . $server_home['ip'] . "-" .
  132. $server_home['port'] . "' ><img style='border:0;height:12px;' src='images/magnifglass.png'/>" .
  133. htmlentities($server_home['home_name']) . "</a></div>".
  134. "<div><div style='font-size:8pt;' ></div> </div>".
  135. "<div id='gamelink' >" . $server_home['ip'] . ":$port</div>";
  136. if(isset($_SESSION[$server_key]['online_players']))
  137. unset($_SESSION[$server_key]['online_players']);
  138. }
  139. else
  140. {
  141. if(isset($_SESSION[$server_key]['online_players']))
  142. unset($_SESSION[$server_key]['online_players']);
  143. }
  144. }