2011-07-17 23:31:26 +02:00
< ? php
2012-08-02 02:57:28 +02:00
// Copyright (C) 2012 Mark Vejvoda, Titus Tscharntke and Tom Reynolds
// The Megaglest Team, under GNU GPL v3.0
// ==============================================================
2011-07-17 23:31:26 +02:00
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 ();
2013-11-01 16:42:19 +01:00
$servers_in_db = mysql_query ( 'SELECT a.*,b.framesToCalculatePlaytime FROM glestserver a LEFT JOIN glestgamestats b ON a.gameUUID = b.gameUUID WHERE status <> 3 OR (status = 3 AND a.lasttime > DATE_add(NOW(), INTERVAL - ' . MAX_HOURS_OLD_GAMES . ' hour)) ORDER BY status, a.lasttime DESC, connectedClients > 0 DESC, (networkSlots - connectedClients), ip DESC;' );
2011-07-17 23:31:26 +02:00
$all_servers = array ();
while ( $server = mysql_fetch_array ( $servers_in_db ) )
{
2013-11-01 16:42:19 +01:00
// Game Stats
$rowIndex = count ( $all_servers );
$gameDuration = $server [ " framesToCalculatePlaytime " ];
$server [ " gameDuration " ] = getTimeString ( $gameDuration );
2011-07-17 23:31:26 +02:00
array_push ( $all_servers , $server );
2013-11-01 16:42:19 +01:00
2011-07-17 23:31:26 +02:00
}
unset ( $servers_in_db );
unset ( $server );
db_disconnect ( DB_LINK );
unset ( $linkid );
2013-11-22 22:17:38 +01:00
header ( 'Content-type: application/json' );
2011-07-17 23:31:26 +02:00
echo json_encode ( $all_servers );
unset ( $all_servers );
?>