- Added masterserver files to svn

This commit is contained in:
Mark Vejvoda
2010-07-27 15:14:58 +00:00
parent e73324d317
commit 0d41ef7ae7
8 changed files with 603 additions and 0 deletions

View File

@@ -0,0 +1,175 @@
<?php
define( 'INCLUSION_PERMITTED', true );
require_once( 'config.php' );
require_once( 'functions.php' );
// Consider using HTTP POST instead of HTTP GET here, data should always be sent via POST for privacy and security reasons
// Alternatively, do not retrieve (and transmit) this data at all via HTTP (other than the IP address the game servers advertises) but fetch it from the game server instead
// general info:
$glestVersion = (string) clean_str( $_GET['glestVersion'] );
$platform = (string) clean_str( $_GET['platform'] );
$binaryCompileDate = (string) clean_str( $_GET['binaryCompileDate'] );
// game info:
$serverTitle = (string) clean_str( $_GET['serverTitle'] );
$remote_ip = (string) clean_str( $_SERVER['REMOTE_ADDR'] );
// If the clients' IP address belongs to a RFC1918 IP range...
if ( strncmp( $remote_ip, get_localsubnet_ip_prefix(), strlen( get_localsubnet_ip_prefix() ) ) == 0 )
{
// ...then replace it by the master servers' public IP address.
$remote_ip = get_external_ip();
}
$service_port = (int) clean_str( $_GET['externalconnectport'] );
// If the game server port was not transmitted...
if ( $service_port == '' || $service_port == 0 )
{
// ..then assume the default port
$service_port = 61357;
// ... alternatively, refuse such servers
/*
header( 'Content-Type: text/plain; charset=utf-8' );
die( 'Invalid external connect port.');
*/
}
// game setup info:
$tech = (string) clean_str( $_GET['tech'] );
$map = (string) clean_str( $_GET['map'] );
$tileset = (string) clean_str( $_GET['tileset'] );
$activeSlots = (int) clean_str( $_GET['activeSlots'] );
$networkSlots = (int) clean_str( $_GET['networkSlots'] );
$connectedClients = (int) clean_str( $_GET['connectedClients'] );
define( 'DB_LINK', db_connect() );
// consider replacing this by a cron job
cleanupServerList( MYSQL_DATABASE );
$server_in_db = @mysql_db_query( MYSQL_DATABASE, 'SELECT ip, externalServerPort FROM glestserver WHERE ip=\'' . mysql_real_escape_string( $remote_ip ) . '\' && externalServerPort=\'' . mysql_real_escape_string( $service_port ) . '\';' );
$server = @mysql_fetch_row( $server_in_db );
// Representation starts here (but it should really be starting much later, there is way too much logic behind this point)
header( 'Content-Type: text/plain; charset=utf-8' );
if ( $connectedClients == $networkSlots ) // game servers' slots are all full
{ // delete server; no checks are performed
mysql_db_query( MYSQL_DATABASE, 'DELETE FROM glestserver WHERE ip=\'' . mysql_real_escape_string( $remote_ip ) . '\' && externalServerPort=\'' . mysql_real_escape_string( $service_port ) . '\';' );
echo 'OK' ;
}
else if ( $remote_ip == $server[0] && $service_port == $server[1] ) // this server is contained in the database
{ // update database info on this game server; no checks are performed
mysql_db_query( MYSQL_DATABASE, 'UPDATE glestserver SET ' .
'glestVersion=\'' . mysql_real_escape_string( $glestVersion ) . '\', ' .
'platform=\'' . mysql_real_escape_string( $platform ) . '\', ' .
'binaryCompileDate=\'' . mysql_real_escape_string( $binaryCompileDate ) . '\', ' .
'serverTitle=\'' . mysql_real_escape_string( $serverTitle ) . '\', ' .
'tech=\'' . mysql_real_escape_string( $tech ) . '\', ' .
'map=\'' . mysql_real_escape_string( $map ) . '\', ' .
'tileset=\'' . mysql_real_escape_string( $tileset ) . '\', ' .
'activeSlots=\'' . mysql_real_escape_string( $activeSlots ) . '\', ' .
'networkSlots=\'' . mysql_real_escape_string( $networkSlots ) . '\', ' .
'connectedClients=\'' . mysql_real_escape_string( $connectedClients ) . '\', ' .
'externalServerPort=\''. mysql_real_escape_string( $service_port ) . '\', ' .
'lasttime=' . 'now()' . ' ' .
'where ip=\'' . mysql_real_escape_string( $remote_ip ) . '\' && externalServerPort=\'' . mysql_real_escape_string( $service_port ) . '\';' );
echo 'OK';
}
else // this game server is not listed in the database, yet
{ // check whether this game server is available from the Internet; if it is, add it to the database
$socket = socket_create( AF_INET, SOCK_STREAM, SOL_TCP );
if ( $socket < 0 ) {
echo 'socket_create() failed.' . PHP_EOL . ' Reason: ' . socket_strerror( $socket ) . PHP_EOL;
}
socket_set_nonblock( $socket )
or die( 'Unable to set nonblock on socket.' );
$timeout = 10; //timeout in seconds
echo 'Trying to connect to \'' . $remote_ip . '\' using port \'' . $service_port . '\'...' . PHP_EOL;
$canconnect = true;
$time = time();
error_reporting( E_ERROR );
for ( ; !@socket_connect( $socket, $remote_ip, $service_port ); )
{
$socket_last_error = socket_last_error( $socket );
if ( $socket_last_error == 115 || $socket_last_error == 114 )
{
if ( ( time() - $time ) >= $timeout )
{
$canconnect = false;
echo 'socket_connect() failed.' . PHP_EOL . ' Reason: (' . $socket_last_error . ') ' . socket_strerror( $socket_last_error ) . PHP_EOL;
break;
}
sleep( 1 );
continue;
}
$canconnect = false;
echo 'socket_connect() failed.' . PHP_EOL . ' Reason: (' . $socket_last_error . ') ' . socket_strerror( $socket_last_error ) . PHP_EOL;
break;
}
socket_set_block( $socket )
or die( 'Unable to set block on socket.' );
//echo "and now read ....";
//$buf = socket_read($socket, 161);
//echo $buf ."\n";
// Make sure its a glest server connecting
//
// struct Data{
// int8 messageType;
// NetworkString<maxVersionStringSize> versionString;
// NetworkString<maxNameSize> name;
// int16 playerIndex;
// int8 gameState;
// };
if ( $canconnect == true ) {
$data_from_server = socket_read( $socket, 1 );
}
socket_close( $socket );
error_reporting( E_ALL );
if ( $canconnect == false )
{
echo 'wrong router setup';
}
/*
else if ( $data_from_server != 1 ) // insert serious verification here
{
echo "invalid handshake!";
}
*/
else // connection to game server succeeded, protocol verification succeeded
{ // add this game server to the database
mysql_db_query( MYSQL_DATABASE, 'INSERT INTO glestserver SET ' .
'glestVersion=\'' . mysql_real_escape_string( $glestVersion ) . '\', ' .
'platform=\'' . mysql_real_escape_string( $platform ) . '\', ' .
'binaryCompileDate=\'' . mysql_real_escape_string( $binaryCompileDate ) . '\', ' .
'serverTitle=\'' . mysql_real_escape_string( $serverTitle ) . '\', ' .
'ip=\'' . mysql_real_escape_string( $remote_ip ) . '\', ' .
'tech=\'' . mysql_real_escape_string( $tech ) . '\', ' .
'map=\'' . mysql_real_escape_string( $map ) . '\', ' .
'tileset=\'' . mysql_real_escape_string( $tileset ) . '\', ' .
'activeSlots=\'' . mysql_real_escape_string( $activeSlots ) . '\', ' .
'networkSlots=\'' . mysql_real_escape_string( $networkSlots ) . '\', ' .
'connectedClients=\'' . mysql_real_escape_string( $connectedClients ) . '\', ' .
'externalServerPort=\''. mysql_real_escape_string( $service_port ) . '\'
;' );
echo 'OK';
}
}
db_disconnect( DB_LINK );
?>

View File

@@ -0,0 +1,175 @@
<?php
define( 'INCLUSION_PERMITTED', true );
require_once( 'config.php' );
require_once( 'functions.php' );
// Consider using HTTP POST instead of HTTP GET here, data should always be sent via POST for privacy and security reasons
// Alternatively, do not retrieve (and transmit) this data at all via HTTP (other than the IP address the game servers advertises) but fetch it from the game server instead
// general info:
$glestVersion = (string) clean_str( $_GET['glestVersion'] );
$platform = (string) clean_str( $_GET['platform'] );
$binaryCompileDate = (string) clean_str( $_GET['binaryCompileDate'] );
// game info:
$serverTitle = (string) clean_str( $_GET['serverTitle'] );
$remote_ip = (string) clean_str( $_SERVER['REMOTE_ADDR'] );
// If the clients' IP address belongs to a RFC1918 IP range...
if ( strncmp( $remote_ip, get_localsubnet_ip_prefix(), strlen( get_localsubnet_ip_prefix() ) ) == 0 )
{
// ...then replace it by the master servers' public IP address.
$remote_ip = get_external_ip();
}
$service_port = (int) clean_str( $_GET['externalconnectport'] );
// If the game server port was not transmitted...
if ( $service_port == '' || $service_port == 0 )
{
// ..then assume the default port
$service_port = 61357;
// ... alternatively, refuse such servers
/*
header( 'Content-Type: text/plain; charset=utf-8' );
die( 'Invalid external connect port.');
*/
}
// game setup info:
$tech = (string) clean_str( $_GET['tech'] );
$map = (string) clean_str( $_GET['map'] );
$tileset = (string) clean_str( $_GET['tileset'] );
$activeSlots = (int) clean_str( $_GET['activeSlots'] );
$networkSlots = (int) clean_str( $_GET['networkSlots'] );
$connectedClients = (int) clean_str( $_GET['connectedClients'] );
define( 'DB_LINK', db_connect() );
// consider replacing this by a cron job
cleanupServerList( MYSQL_DATABASE );
$server_in_db = @mysql_db_query( MYSQL_DATABASE, 'SELECT ip, externalServerPort FROM glestserver WHERE ip=\'' . mysql_real_escape_string( $remote_ip ) . '\' && externalServerPort=\'' . mysql_real_escape_string( $service_port ) . ';' );
$server = @mysql_fetch_row( $server_in_db );
// Representation starts here (but it should really be starting much later, there is way too much logic behind this point)
header( 'Content-Type: text/plain; charset=utf-8' );
if ( $connectedClients == $networkSlots ) // game servers' slots are all full
{ // delete server; no checks are performed
mysql_db_query( MYSQL_DATABASE, 'DELETE FROM glestserver WHERE ip=\'' . mysql_real_escape_string( $remote_ip ) . '\' && externalServerPort=\'' . mysql_real_escape_string( $service_port ) . ';' );
echo 'OK' ;
}
else if ( $remote_ip == $server[0] && $service_port == $server[1] ) // this server is contained in the database
{ // update database info on this game server; no checks are performed
mysql_db_query( MYSQL_DATABASE, 'UPDATE glestserver SET ' .
'glestVersion=\'' . mysql_real_escape_string( $glestVersion ) . '\', ' .
'platform=\'' . mysql_real_escape_string( $platform ) . '\', ' .
'binaryCompileDate=\'' . mysql_real_escape_string( $binaryCompileDate ) . '\', ' .
'serverTitle=\'' . mysql_real_escape_string( $serverTitle ) . '\', ' .
'tech=\'' . mysql_real_escape_string( $tech ) . '\', ' .
'map=\'' . mysql_real_escape_string( $map ) . '\', ' .
'tileset=\'' . mysql_real_escape_string( $tileset ) . '\', ' .
'activeSlots=\'' . mysql_real_escape_string( $activeSlots ) . '\', ' .
'networkSlots=\'' . mysql_real_escape_string( $networkSlots ) . '\', ' .
'connectedClients=\'' . mysql_real_escape_string( $connectedClients ) . '\', ' .
'externalServerPort=\''. mysql_real_escape_string( $service_port ) . '\', ' .
'lasttime=' . 'now()' . ' ' .
'where ip=\'' . mysql_real_escape_string( $remote_ip ) . '\' && externalServerPort=\'' . mysql_real_escape_string( $service_port ) . '\';' );
echo 'OK';
}
else // this game server is not listed in the database, yet
{ // check whether this game server is available from the Internet; if it is, add it to the database
$socket = socket_create( AF_INET, SOCK_STREAM, SOL_TCP );
if ( $socket < 0 ) {
echo 'socket_create() failed.' . PHP_EOL . ' Reason: ' . socket_strerror( $socket ) . PHP_EOL;
}
socket_set_nonblock( $socket )
or die( 'Unable to set nonblock on socket.' );
$timeout = 10; //timeout in seconds
echo 'Trying to connect to \'' . $remote_ip . '\' using port \'' . $service_port . '\'...' . PHP_EOL;
$canconnect = true;
$time = time();
error_reporting( E_ERROR );
for ( ; !@socket_connect( $socket, $remote_ip, $service_port ); )
{
$socket_last_error = socket_last_error( $socket );
if ( $socket_last_error == 115 || $socket_last_error == 114 )
{
if ( ( time() - $time ) >= $timeout )
{
$canconnect = false;
echo 'socket_connect() failed.' . PHP_EOL . ' Reason: (' . $socket_last_error . ') ' . socket_strerror( $socket_last_error ) . PHP_EOL;
break;
}
sleep( 1 );
continue;
}
$canconnect = false;
echo 'socket_connect() failed.' . PHP_EOL . ' Reason: (' . $socket_last_error . ') ' . socket_strerror( $socket_last_error ) . PHP_EOL;
break;
}
socket_set_block( $socket )
or die( 'Unable to set block on socket.' );
//echo "and now read ....";
//$buf = socket_read($socket, 161);
//echo $buf ."\n";
// Make sure its a glest server connecting
//
// struct Data{
// int8 messageType;
// NetworkString<maxVersionStringSize> versionString;
// NetworkString<maxNameSize> name;
// int16 playerIndex;
// int8 gameState;
// };
if ( $canconnect == true ) {
$data_from_server = socket_read( $socket, 1 );
}
socket_close( $socket );
error_reporting( E_ALL );
if ( $canconnect == false )
{
echo 'wrong router setup';
}
/*
else if ( $data_from_server != 1 ) // insert serious verification here
{
echo "invalid handshake!";
}
*/
else // connection to game server succeeded, protocol verification succeeded
{ // add this game server to the database
mysql_db_query( MYSQL_DATABASE, 'INSERT INTO glestserver SET ' .
'glestVersion=\'' . mysql_real_escape_string( $glestVersion ) . '\', ' .
'platform=\'' . mysql_real_escape_string( $platform ) . '\', ' .
'binaryCompileDate=\'' . mysql_real_escape_string( $binaryCompileDate ) . '\', ' .
'serverTitle=\'' . mysql_real_escape_string( $serverTitle ) . '\', ' .
'ip=\'' . mysql_real_escape_string( $remote_ip ) . '\', ' .
'tech=\'' . mysql_real_escape_string( $tech ) . '\', ' .
'map=\'' . mysql_real_escape_string( $map ) . '\', ' .
'tileset=\'' . mysql_real_escape_string( $tileset ) . '\', ' .
'activeSlots=\'' . mysql_real_escape_string( $activeSlots ) . '\', ' .
'networkSlots=\'' . mysql_real_escape_string( $networkSlots ) . '\', ' .
'connectedClients=\'' . mysql_real_escape_string( $connectedClients ) . '\', ' .
'externalServerPort=\''. mysql_real_escape_string( $service_port ) . '\'
;' );
echo 'OK';
}
}
db_disconnect( DB_LINK );
?>

View File

@@ -0,0 +1,14 @@
<?php
// This script can be invoked directly by a cron job on a regular basis:
// /path/to/php -f /path/to/script.php
define( 'INCLUSION_PERMITTED', true );
require_once( 'config.php' );
require_once( 'functions.php' );
define( 'DB_LINK', db_connect() );
cleanupServerList( MYSQL_DATABASE );
db_disconnect( DB_LINK );
?>

View File

@@ -0,0 +1,13 @@
<?php
if ( !defined('INCLUSION_PERMITTED') || ( defined('INCLUSION_PERMITTED') && INCLUSION_PERMITTED !== true ) ) { die( 'This file must not be invoked directly.' ); }
define( 'MYSQL_HOST', '127.0.0.1' );
define( 'MYSQL_DATABASE', 'glest' );
define( 'MYSQL_USER', 'root' );
define( 'MYSQL_PASSWORD', 'your_pwd' );
// Allow using persistent MYSQL database server connections
// This _can_ improve performance remarkably but _can_ also break stuff completely, so read up:
// http://php.net/manual/function.mysql-pconnect.php
// http://php.net/manual/features.persistent-connections.php
define( 'MYSQL_LINK_PERSIST', false );
?>

View File

@@ -0,0 +1,45 @@
-- phpMyAdmin SQL Dump
-- version 2.11.9.6
-- http://www.phpmyadmin.net
--
-- Host: mysql.goneo.de
-- Erstellungszeit: 12. Mai 2010 um 03:08
-- Server Version: 5.0.90
-- PHP-Version: 4.4.9
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Datenbank: `17632m6025_1`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `glestserver`
--
CREATE TABLE IF NOT EXISTS `glestserver` (
`lasttime` timestamp NOT NULL default CURRENT_TIMESTAMP,
`glestVersion` varchar(30) collate utf8_unicode_ci NOT NULL,
`platform` varchar(30) collate utf8_unicode_ci NOT NULL,
`binaryCompileDate` varchar(30) collate utf8_unicode_ci NOT NULL,
`serverTitle` varchar(100) collate utf8_unicode_ci NOT NULL,
`ip` varchar(15) collate utf8_unicode_ci NOT NULL,
`tech` varchar(100) collate utf8_unicode_ci NOT NULL,
`map` varchar(100) collate utf8_unicode_ci NOT NULL,
`tileset` varchar(100) collate utf8_unicode_ci NOT NULL,
`activeSlots` int(11) NOT NULL,
`networkSlots` int(11) NOT NULL,
`connectedClients` int(11) NOT NULL,
`externalServerPort` int(11) NOT NULL,
KEY `lasttime` (`lasttime`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Daten für Tabelle `glestserver`
--
INSERT INTO `glestserver` (`lasttime`, `glestVersion`, `platform`, `binaryCompileDate`, `serverTitle`, `ip`, `tech`, `map`, `tileset`, `activeSlots`, `networkSlots`, `connectedClients`,`externalServerPort`) VALUES
('2010-05-12 01:41:43', '', '', '', '', '', '', '', '', 0, 0, 0, 0);

View File

@@ -0,0 +1,57 @@
<?php
if ( !defined('INCLUSION_PERMITTED') || ( defined('INCLUSION_PERMITTED') && INCLUSION_PERMITTED !== true ) ) { die( 'This file must not be invoked directly.' ); }
# This function cleans out special characters
function clean_str( $text )
{ // tomreyn says: I'm afraid this function is more likely to cause to trouble than to fix stuff (you have mysql escaping and html escaping elsewhere where it makes more sense, but strip off < and > here already, but then you don't filter non-visible bytes here)
//$text=strtolower($text);
$code_entities_match = array('!','@','#','$','%','^','&','*','(',')','_','+','{','}','|','"','<','>','?','[',']','\\',';',"'",',','/','*','+','~','`','=');
$code_entities_replace = array('','','','','','','','','','','','','','','','','','','','','');
$text = str_replace( $code_entities_match, $code_entities_replace, $text );
return $text;
}
function db_connect()
{
// If we may use persistent MYSQL database server links...
if ( defined( 'MYSQL_LINK_PERSIST' ) && MYSQL_LINK_PERSIST === true )
{
// ...then reuse an existing link or create a new one, ...
$linkid = mysql_pconnect( MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD );
}
else
{
// ...otherwise create a standard link
$linkid = mysql_connect( MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD );
}
return $linkid;
}
function db_disconnect( $linkid )
{
// note that mysql_close() only closes non-persistent connections
return mysql_close( $linkid );
}
function get_localsubnet_ip_prefix()
{
// If this is supposed to match any RFC1918 or even any unroutable IP address space then this is far from complete.
// Consider using something like the 'IANA Private list' provided at http://sites.google.com/site/blocklist/ instead.
// The data in this list is a subset of what IANA makes available at http://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.xhtml
// Note that you may want/need to add in the IPv6 equivalent, too: http://www.iana.org/assignments/ipv6-address-space/ipv6-address-space.xhtml
return "192.";
}
function get_external_ip()
{
return $_SERVER['SERVER_ADDR'];
//return "209.52.70.192";
}
function cleanupServerList( $mysql_database )
{
// on a busy server, this function should be invoked by cron in regular intervals instead (one SQL query less for the script)
return mysql_db_query( $mysql_database, 'DELETE FROM glestserver WHERE lasttime<DATE_add(NOW(), INTERVAL -1 minute);' );
//return mysql_db_query( $mysql_database, 'UPDATE glestserver SET status=\'???\' WHERE lasttime<DATE_add(NOW(), INTERVAL -2 minute);' );
}
?>

View File

@@ -0,0 +1,91 @@
<?php
define( 'INCLUSION_PERMITTED', true );
require_once( 'config.php' );
require_once( 'functions.php' );
define( 'DB_LINK', db_connect() );
// consider replacing this by a cron job
cleanupServerList( MYSQL_DATABASE );
$servers_in_db = mysql_db_query( MYSQL_DATABASE, 'SELECT * FROM glestserver ORDER BY lasttime DESC;' );
$all_servers = array();
while ( $server = mysql_fetch_array( $servers_in_db ) )
{
array_push( $all_servers, $server );
}
unset( $servers_in_db );
unset( $server );
db_disconnect( DB_LINK );
unset( $linkid );
// Representation starts here
header( 'Content-Type: text/html; charset=utf-8' );
echo <<<END
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<style type="text/css">
body {
}
table {
width: 100%;
border: 2px solid black;
}
th, td {
width: 300;
border: 1px solid black;
text-align: left;
}
</style>
</head>
<body>
<table>
<tr>
<th>glestVersion</th>
<th>platform</th>
<th>binaryCompileDate</th>
<th>serverTitle</th>
<th>ip</th>
<th>tech</th>
<th>map</th>
<th>tileset</th>
<th>activeSlots</th>
<th>networkSlots</th>
<th>connectedClients</th>
<th>externalServerPort</th>
</tr>
END;
foreach( $all_servers as $server )
{
//array_walk( $server, 'htmlspecialchars', 'ENT_QUOTES' );
echo "\t\t\t" . '<tr>' . PHP_EOL;
echo "\t\t\t\t<td>" . htmlspecialchars( $server['glestVersion'], ENT_QUOTES ) . '</td>' . PHP_EOL;
echo "\t\t\t\t<td>" . htmlspecialchars( $server['platform'], ENT_QUOTES ) . '</td>' . PHP_EOL;
echo "\t\t\t\t<td>" . htmlspecialchars( $server['binaryCompileDate'], ENT_QUOTES ) . '</td>' . PHP_EOL;
echo "\t\t\t\t<td>" . htmlspecialchars( $server['serverTitle'], ENT_QUOTES ) . '</td>' . PHP_EOL;
echo "\t\t\t\t<td>" . htmlspecialchars( $server['ip'], ENT_QUOTES ) . '</td>' . PHP_EOL;
echo "\t\t\t\t<td>" . htmlspecialchars( $server['tech'], ENT_QUOTES ) . '</td>' . PHP_EOL;
echo "\t\t\t\t<td>" . htmlspecialchars( $server['map'], ENT_QUOTES ) . '</td>' . PHP_EOL;
echo "\t\t\t\t<td>" . htmlspecialchars( $server['tileset'], ENT_QUOTES ) . '</td>' . PHP_EOL;
echo "\t\t\t\t<td>" . htmlspecialchars( $server['activeSlots'], ENT_QUOTES ) . '</td>' . PHP_EOL;
echo "\t\t\t\t<td>" . htmlspecialchars( $server['networkSlots'], ENT_QUOTES ) . '</td>' . PHP_EOL;
echo "\t\t\t\t<td>" . htmlspecialchars( $server['connectedClients'], ENT_QUOTES ) . '</td>' . PHP_EOL;
echo "\t\t\t\t<td>" . htmlspecialchars( $server['externalServerPort'], ENT_QUOTES ) . '</td>' . PHP_EOL;
echo "\t\t\t" . '</tr>' . PHP_EOL;
}
unset( $all_servers );
unset( $server );
echo <<<END
</table>
</body>
</html>
END;
?>

View File

@@ -0,0 +1,33 @@
<?php
define( 'INCLUSION_PERMITTED', true );
require_once( 'config.php' );
require_once( 'functions.php' );
define( 'DB_LINK', db_connect() );
// consider replacing this by a cron job
cleanupServerList( MYSQL_DATABASE );
$servers_in_db = mysql_db_query( MYSQL_DATABASE, 'SELECT * FROM glestserver ORDER BY lasttime DESC;' );
$all_servers = array();
while ( $server = mysql_fetch_array( $servers_in_db ) )
{
array_push( $all_servers, $server );
}
unset( $servers_in_db );
unset( $server );
db_disconnect( DB_LINK );
// Representation starts here
header( 'Content-Type: text/plain; charset=utf-8' );
foreach( $all_servers as &$server )
{
echo (
"${server['glestVersion']}|${server['platform']}|${server['binaryCompileDate']}|${server['serverTitle']}|${server['ip']}|${server['tech']}|${server['map']}|${server['tileset']}|${server['activeSlots']}|${server['networkSlots']}|${server['connectedClients']}|${server['externalServerPort']}|\n"
);
}
unset( $all_servers );
unset( $server );
?>