DEFINE("IN_NWN2MONITOR", TRUE);
require("template.php");
require("functions_nwn2monitor.php");
SQLConnect();
$template = new Template('./templates/');
$template->set_filenames(array('body' => './templates/stats.tpl'));
//Génération de la partie haute.
//On cherche les salles gamespy et pour chaqu'une d'entre elle on charge son affichage
$query = "SELECT * FROM chatroom";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result))
{
$room_id = $row[0];
$room_name = $row[1];
$room_desc = $row[2];
if ($room_name == "")
{
continue;
}
$query_1 = "SELECT SUM(numplayers),COUNT(groupid) FROM serverlists WHERE groupid='".$room_id."' AND UNIX_TIMESTAMP(refreshdate)>=(UNIX_TIMESTAMP(NOW())-530)";
$result_1 = mysql_query($query_1);
if ($row_1 = mysql_fetch_array($result_1))
{
if ($row_1[0] == NULL) $row_1[0] = 0;
$page_url = "stats-".base64_encode("page#section|salle#".$room_id).".html";
$minigraph_url = "http://stats.nwn2.fr/graph.php?ip=room&port=".$room_id."&x=120&y=61";
$template->assign_block_vars('statsrow', array('SALLE_URL' => $page_url,
'SALLE_NAME' => $room_name,
'SALLE_DESC' => $room_desc,
'SERVEURS' => $row_1[1],
'JOUEURS' => $row_1[0],
'MINIGRAPH' => $minigraph_url
));
}
mysql_free_result($result_1);
}
mysql_free_result($result);
//Génération de la partie basse.
$query = "SELECT SUM(numplayers),COUNT(groupid) FROM serverlists WHERE UNIX_TIMESTAMP(refreshdate) >= (UNIX_TIMESTAMP(NOW())-530)";
$result = mysql_query($query);
if ($row = mysql_fetch_array($result))
{
if ($row[0] == NULL) $row[0] = 0;
$total_servers = $row[1];
$total_joueurs = $row[0];
}
mysql_free_result($result);
$query = "SELECT record_joueurs FROM global";
$result = mysql_query($query);
if ($row = mysql_fetch_array($result))
{
$record_joueurs = $row[0];
}
$template->assign_vars(array('TOTAL_SERVEURS' => $total_servers,
'TOTAL_JOUEURS' => $total_joueurs,
'RECORD_JOUEURS' => $record_joueurs,
'RECORD_DATE' => 0));
$template->pparse('body');
?>