Moved the Agents into their own repo. Kept the agent.pl just for reference
|
|
@ -1,90 +0,0 @@
|
|||
<?php
|
||||
global $settings;
|
||||
// Skip server queries if there are too many total servers
|
||||
if(isset($_SESSION))
|
||||
$num_of_servers = $db->getNumberOfOwnedServersPerUser( $_SESSION['user_id'] );
|
||||
else
|
||||
$num_of_servers = 0;
|
||||
|
||||
if(isset($settings['query_num_servers_stop']) && is_numeric($settings['query_num_servers_stop']))
|
||||
$numberservers_to_skip_query = $settings['query_num_servers_stop'];
|
||||
else
|
||||
$numberservers_to_skip_query = 15;
|
||||
|
||||
if($num_of_servers < $numberservers_to_skip_query)
|
||||
{
|
||||
require_once("protocol/lgsl/lgsl_protocol.php");
|
||||
$ip_id = $db->getIpIdByIp($server_home['ip']);
|
||||
$statusCache = $db->getServerStatusCache($ip_id,$port);
|
||||
$query_cache_life = ( isset($settings['query_cache_life']) and is_numeric($settings['query_cache_life']) )? $settings['query_cache_life'] : 30;
|
||||
if( !empty($statusCache) AND date('YmdHis',$statusCache['date_timestamp'] + $query_cache_life) >= date('YmdHis') )
|
||||
{
|
||||
$data = $statusCache;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $server_home['use_nat'] == 1 )
|
||||
$internal_query_ip = $server_home['agent_ip'];
|
||||
else
|
||||
$internal_query_ip = $server_home['ip'];
|
||||
$port = $server_home['port'];
|
||||
$get_q_and_s = lgsl_port_conversion((string)$server_xml->lgsl_query_name, $port, "", "");
|
||||
//Connection port
|
||||
$c_port = $get_q_and_s['0'];
|
||||
//query port
|
||||
$q_port = $get_q_and_s['1'];
|
||||
|
||||
// Get any query port overrides (if any)
|
||||
require_once("includes/functions.php");
|
||||
$q_port = getQueryPortOverridesForGame((string)$server_xml->lgsl_query_name, $internal_query_ip, $port, $q_port);
|
||||
|
||||
//software port
|
||||
$s_port = $get_q_and_s['2'];
|
||||
$data = lgsl_query_live((string)$server_xml->lgsl_query_name, $internal_query_ip, $c_port, $q_port, $s_port, "sp");
|
||||
$data['link'] = "<a href='" . lgsl_software_link((string)$server_xml->lgsl_query_name, $internal_query_ip, $c_port, $q_port, $s_port) . "'>".$ip.":".$port."</a>";
|
||||
//-----------------------------------+
|
||||
$data['s']['game'] = preg_replace("/[^A-Za-z0-9 \_\-]/",
|
||||
"_", strtolower($data['s']['game']));
|
||||
|
||||
//-----------------------------------+
|
||||
if( $data['b']['status'] == "1" )
|
||||
{
|
||||
if( !isset( $data['s']['password']) )
|
||||
{
|
||||
$data['status'] = "ONLINE";
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['status'] = "ONLINE WITH PASSWORD";
|
||||
}
|
||||
}
|
||||
$db->saveServerStatusCache($ip_id,$port,$data);
|
||||
}
|
||||
|
||||
if($data['status'] == 'ONLINE' OR $data['status'] == 'ONLINE WITH PASSWORD')
|
||||
{
|
||||
$status = "online";
|
||||
$stats_players += $data['s']['players']; // COUNT VISIBLE NUMBER OF PLAYERS
|
||||
$stats_maxplayers += $data['s']['playersmax']; // COUNT VISIBLE NUMBER OF SLOTS
|
||||
$players = $data['s']['players'];
|
||||
$playersmax= $data['s']['playersmax'];
|
||||
$name = $data['s']['name'];
|
||||
$map = preg_replace("/[^a-z0-9_]/", "_", strtolower($data['s']['map']));
|
||||
$mapRaw = $data['s']['map'];
|
||||
$address = $data['link'];
|
||||
|
||||
if ( $data['s']['players'] > 0 )
|
||||
$player_list = print_player_list($data['p'],$players,$playersmax);
|
||||
|
||||
$playersList = $data['p'];
|
||||
$maplocation = get_map_path($query_name,$mod,$map);
|
||||
}
|
||||
else
|
||||
$status = "half";
|
||||
}
|
||||
else
|
||||
{
|
||||
$status = "half";
|
||||
$notifications = get_lang_f('queries_disabled_by_setting_disable_queries_after',$numberservers_to_skip_query,$num_of_servers);
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,381 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Murmur Query Class
|
||||
*
|
||||
* Based on GT MURMUR PLUGIN, which allows us to query a Murmur server
|
||||
* without having to install PHP ICE on the web server.
|
||||
* @link http://www.gametracker.com/downloads/gtmurmurplugin.php
|
||||
*
|
||||
* The response is constructed using Channel Viewer Protocol.
|
||||
* @link http://mumble.sourceforge.net/Channel_Viewer_Protocol
|
||||
*
|
||||
* @author Edmundas Kondrašovas <as@edmundask.lt>
|
||||
* @license http://www.opensource.org/licenses/MIT
|
||||
* @copyright Copyright (c) 2011 Edmundas Kondrašovas <as@edmundask.lt>
|
||||
* @version 0.6
|
||||
*
|
||||
*/
|
||||
|
||||
class MurmurQuery
|
||||
{
|
||||
/* Packets */
|
||||
const Q_XML = "\x78\x6D\x6C";
|
||||
const Q_JSON = "\x6A\x73\x6F\x6E";
|
||||
|
||||
private $users = array();
|
||||
private $channels = array();
|
||||
|
||||
private $socket;
|
||||
|
||||
private $host;
|
||||
private $port;
|
||||
private $timeout;
|
||||
private $format;
|
||||
|
||||
private $response;
|
||||
|
||||
private $status;
|
||||
private $raw;
|
||||
private $online = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
* @param string hostname
|
||||
* @param integer port (optional)
|
||||
* @param integer timeout in miliseconds (optional)
|
||||
* @param string format (optional)
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function __construct($host = '', $port = 27800, $timeout = 200, $format = 'json')
|
||||
{
|
||||
if(!empty($host))
|
||||
{
|
||||
$this->setup($host, $port, $timeout, $format);
|
||||
$this->query();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the parameters
|
||||
*
|
||||
* @access public
|
||||
* @param string/array hostname or settings array
|
||||
* @param integer port (optional)
|
||||
* @param integer timeout in miliseconds (optional)
|
||||
* @param string format (optional)
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function setup($host, $port = 27800, $timeout = 200, $format = 'json')
|
||||
{
|
||||
if(is_array($host))
|
||||
{
|
||||
$this->host = array_key_exists('host', $host) ? $host['host'] : '';
|
||||
$this->port = array_key_exists('port', $host) ? $host['port'] : $port;
|
||||
$this->timeout = array_key_exists('timeout', $host) ? $host['timeout'] : $timeout;
|
||||
$this->format = array_key_exists('format', $host) ? $host['format'] : $format;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->host = $host;
|
||||
$this->port = $port;
|
||||
$this->timeout = $timeout;
|
||||
$this->format = $format;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set data format
|
||||
*
|
||||
* @access public
|
||||
* @param string data format
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function set_format($format = 'json')
|
||||
{
|
||||
$this->format = $format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the server
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function query()
|
||||
{
|
||||
$this->_connect();
|
||||
$this->_send_query($this->format);
|
||||
$this->_catch_response();
|
||||
|
||||
if(!empty($this->response)) $this->online = true;
|
||||
|
||||
$this->_close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get server status
|
||||
*
|
||||
* @access public
|
||||
* @param boolean return raw response
|
||||
* @return mixed json/xml if set to return raw response or array otherwise
|
||||
*/
|
||||
|
||||
public function get_status($raw = false)
|
||||
{
|
||||
return ($raw) ? $this->raw : $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get users
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
|
||||
public function get_users()
|
||||
{
|
||||
return $this->users;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get channels
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
|
||||
public function get_channels()
|
||||
{
|
||||
return $this->channels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the server is online
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
public function is_online()
|
||||
{
|
||||
return $this->online;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establish a socket connection
|
||||
*
|
||||
* @access private
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
private function _connect()
|
||||
{
|
||||
// We need timeout in seconds for fsockopen()
|
||||
$timeout = ($this->timeout < 1000) ? 1 : ceil($this->timeout / 1000);
|
||||
$this->socket = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
|
||||
|
||||
if(!$this->socket) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send query to the server
|
||||
*
|
||||
* @access private
|
||||
* @param string query (should be one the constants defined)
|
||||
* @return void
|
||||
*/
|
||||
|
||||
private function _send_query($format)
|
||||
{
|
||||
$data = '';
|
||||
|
||||
switch($format)
|
||||
{
|
||||
case 'json':
|
||||
$data = self::Q_JSON;
|
||||
break;
|
||||
|
||||
case 'xml':
|
||||
$data = self::Q_XML;
|
||||
break;
|
||||
|
||||
default:
|
||||
$data = self::Q_JSON;
|
||||
break;
|
||||
}
|
||||
|
||||
if($this->socket)
|
||||
{
|
||||
@fwrite($this->socket, $data);
|
||||
stream_set_timeout($this->socket, 0, $this->timeout * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Receive response from the server
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
|
||||
private function _catch_response()
|
||||
{
|
||||
if($this->socket)
|
||||
{
|
||||
while($resp = @fread($this->socket, 1024)) $this->response .= $resp;
|
||||
stream_set_timeout($this->socket, 0, $this->timeout * 1000);
|
||||
|
||||
$this->raw = $this->response;
|
||||
$this->status = $this->parse_response($this->response, $this->format);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close socket connection
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
|
||||
private function _close()
|
||||
{
|
||||
if($this->socket) fclose($this->socket);
|
||||
|
||||
$this->response = NULL;
|
||||
$this->data = NULL;
|
||||
$this->socket = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse data returned from the server
|
||||
*
|
||||
* @access public
|
||||
* @param string xml/json
|
||||
* @param string format
|
||||
* @return array parsed data
|
||||
*/
|
||||
|
||||
public function parse_response($data, $format = 'json')
|
||||
{
|
||||
switch($format)
|
||||
{
|
||||
case 'json':
|
||||
$parsed_data = $this->_parse_json($data);
|
||||
break;
|
||||
|
||||
case 'xml':
|
||||
$parsed_data = $this->_parse_xml($data);
|
||||
break;
|
||||
|
||||
default:
|
||||
$parsed_data = $this->_parse_json($data);
|
||||
break;
|
||||
}
|
||||
|
||||
return $parsed_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse JSON
|
||||
*
|
||||
* @access private
|
||||
* @param string json
|
||||
* @return array parsed data
|
||||
*/
|
||||
|
||||
private function _parse_json($data)
|
||||
{
|
||||
$parsed_data = array();
|
||||
$decoded = json_decode($data, true);
|
||||
|
||||
$this->_parse_channels($decoded);
|
||||
|
||||
$parsed_data['channels'] = $this->channels;
|
||||
$parsed_data['users'] = $this->users;
|
||||
$parsed_data['original'] = $decoded;
|
||||
|
||||
return $parsed_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse XML
|
||||
*
|
||||
* @access private
|
||||
* @param string xml
|
||||
* @return array parsed data
|
||||
*/
|
||||
|
||||
// Does not work properly yet.
|
||||
private function _parse_xml($data)
|
||||
{
|
||||
$parsed_data = array();
|
||||
$decoded = simplexml_load_string($data);
|
||||
|
||||
$this->_parse_channels($decoded);
|
||||
|
||||
$parsed_data['channels'] = $this->channels;
|
||||
$parsed_data['users'] = $this->users;
|
||||
$parsed_data['original'] = $decoded;
|
||||
|
||||
return $parsed_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the channels
|
||||
*
|
||||
* @access private
|
||||
* @param array channels
|
||||
* @return void
|
||||
*/
|
||||
|
||||
private function _parse_channels($channels)
|
||||
{
|
||||
// We'll have to deal with the root channel separately
|
||||
if(array_key_exists('root', $channels))
|
||||
{
|
||||
if(count($channels['root']['users']) > 0)
|
||||
{
|
||||
foreach($channels['root']['users'] as $user) $this->users[] = $user;
|
||||
}
|
||||
|
||||
$tmp = $channels['root']['channels'];
|
||||
|
||||
unset($channels['root']['users']);
|
||||
unset($channels['root']['channels']);
|
||||
|
||||
$this->_parse_channels($tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(count($channels) > 0)
|
||||
{
|
||||
foreach($channels as $channel)
|
||||
{
|
||||
if(count($channel['users']) > 0)
|
||||
{
|
||||
foreach($channel['users'] as $user) $this->users[] = $user;
|
||||
}
|
||||
|
||||
if($channel['users'] > 0) unset($channel['users']);
|
||||
|
||||
$this->_parse_channels($channel['channels']);
|
||||
|
||||
if($channel['channels'] > 0) unset($channel['channels']);
|
||||
|
||||
$this->channels[] = $channel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
function print_player_list($player_list,$players,$playersmax)
|
||||
{
|
||||
$data = "<table class='player_monitor' style='border:none;'><thead>";
|
||||
$data .= "<tr><th>".get_lang('player_name')."</th><th>".get_lang('score')."</th><th>".get_lang('time')."</th></tr>";
|
||||
$data .= "</thead><tbody>";
|
||||
foreach ($player_list as $key => $row) {
|
||||
$name[$key] = $row['name'];
|
||||
$score[$key] = $row['score'];
|
||||
$time[$key] = $row['time'];
|
||||
|
||||
}
|
||||
//Sort by score, the 1st position in this array multisort, score, defines the row that sorts the array, if there are two equal scores then the next row, time, will sort this array.
|
||||
array_multisort($score, SORT_DESC,
|
||||
$time,
|
||||
$name, $player_list);
|
||||
$i = 0;
|
||||
foreach( $player_list as $player ){
|
||||
$data .= "<tr";
|
||||
if($i%2 == 0) $data .= 'class="odd"';
|
||||
$data .="><td>".htmlentities(@$player['name'])."</td><td>".@$player['score']."</td><td>".@$player['time']."</td></tr>";
|
||||
$i++;
|
||||
}
|
||||
$data .= "</tbody><tfooter><tr><td colspan='3'>".get_lang('players').": " . $players."/".$playersmax . "</td></tr>";
|
||||
$data .= "</tfooter></table>";
|
||||
return $data;
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
<?php
|
||||
|
||||
// Class by Boylett
|
||||
// Released under GNU/GPL.
|
||||
|
||||
// Designed for IVMP 0.1 Beta T4
|
||||
|
||||
class IVMPQuery
|
||||
{
|
||||
var $socket = false;
|
||||
var $ip = false;
|
||||
var $port = false;
|
||||
|
||||
function Query($ip,$port,&$errno,&$errstr,$timeout = 5,$gettimeout = 1)
|
||||
{
|
||||
$this->Close();
|
||||
$this->ip = $ip;
|
||||
$this->port = $port;
|
||||
$this->socket = @fsockopen('udp://'.$ip,$port,$errno,$errstr,$timeout);
|
||||
|
||||
if($this->socket === false) return false;
|
||||
@stream_set_timeout($this->socket,$gettimeout);
|
||||
return true;
|
||||
}
|
||||
|
||||
function Close()
|
||||
{
|
||||
if($this->socket !== false)
|
||||
{
|
||||
fclose($this->socket);
|
||||
$this->socket = false;
|
||||
}
|
||||
}
|
||||
|
||||
function GetPacketData($command)
|
||||
{
|
||||
$packet = 'IVMP';
|
||||
$packet .= $command;
|
||||
return $packet;
|
||||
}
|
||||
|
||||
function ServerData()
|
||||
{
|
||||
fputs($this->socket,$this->GetPacketData('i'));
|
||||
@fread($this->socket,5); // IVMPi
|
||||
|
||||
$len = ord(@fread($this->socket,4));
|
||||
$hostname = @fread($this->socket,$len); // read hostname
|
||||
$players = ord(@fread($this->socket,4)); // read players
|
||||
$maxplayers = ord(@fread($this->socket,4)); // read max players
|
||||
$passworded = ord(@fread($this->socket,1)); // 1 byte for password
|
||||
|
||||
return array(
|
||||
'hostname' => $hostname,
|
||||
'players' => $players,
|
||||
'maxplayers' => $maxplayers,
|
||||
'passworded' => (bool)$passworded
|
||||
);
|
||||
}
|
||||
|
||||
function Players()
|
||||
{
|
||||
fputs($this->socket,$this->GetPacketData('l'));
|
||||
@fread($this->socket,5); // IVMPl
|
||||
|
||||
$count = ord(@fread($this->socket,4));
|
||||
$arr = array();
|
||||
for($i = 0; $i < $count; $i++)
|
||||
{
|
||||
$id = ord(@fread($this->socket,4));
|
||||
$len = ord(@fread($this->socket,4));
|
||||
$arr[$id] = @fread($this->socket,$len);
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
If you want to get map images to the pages you can download
|
||||
the lgsl map files from:
|
||||
http://www.greycube.com/help/readme/lgsl/map_images/
|
||||
|
||||
|
Before Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 129 B |
|
Before Width: | Height: | Size: 277 B |
|
Before Width: | Height: | Size: 260 B |
|
Before Width: | Height: | Size: 266 B |
|
Before Width: | Height: | Size: 118 B |
|
Before Width: | Height: | Size: 118 B |
|
Before Width: | Height: | Size: 868 B |
|
Before Width: | Height: | Size: 860 B |
|
Before Width: | Height: | Size: 6 KiB |
|
Before Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 259 B |
|
Before Width: | Height: | Size: 358 B |