define("IN_NWN2MONITOR", TRUE);
require("functions_nwn2monitor.php");
require("template.php");
//Petite sécurité assez utile, donc toujours que pour le plaisir.
$ip = $_GET["ip"];
if (strlen($ip) > 16) DIE("Exeption détectée");
$port = $_GET["port"];
if (strlen($port) > 7) DIE("Exeption détectée");
//Initialisation SQL.
SQLConnect();
mysql_set_charset("utf8");
//Chargement du template.
$template = new Template('./templates/');
$template->set_filenames(array('body' => './templates/viewmodule.tpl'));
//On va chercher les données du module!
$query = "SELECT s.*, c.groupname FROM serverlists s, chatroom c WHERE s.ip='".$ip."' AND s.port='".$port."' AND s.groupid = c.groupid";
$result = mysql_query($query);
if ($row = mysql_fetch_array($result))
{
$hostname = ($row["hostname"]=="")?"Serveur sans nom":$row["hostname"];
$module_name = $row['modulename'];
$url_website = $row['moduleurl'];
$url_pwc = $row['pwcurl'];
$joueurs = $row['numplayers'];
$maxjoueurs = $row['maxplayers'];
switch($row['gameversion'])
{
case 870:
$version = "1.04.870";
break;
case 912:
$version = "1.05.912";
break;
case 972:
$version = "1.06.972";
break;
case 973:
$version = "1.06.973";
break;
case 980:
$version = "1.06.980";
break;
case 1115:
$version = "1.10.1115";
break;
case 1116:
$version = "1.10.1116";
break;
default:
$version = $row['gameversion'];
break;
}
$expansion = ($row['expansions']==1)?"
MotB":"Aucune";
$mdp = ($row['haspassword']==1)?"Oui":"Non";
$niveau = $row['levelrangelow']."-".$row['levelrangehigh'];
$pvp = $row['pvp'];
switch($row['language'])
{
case 0:
$langue = "Anglais";
break;
case 1:
$langue = "Français";
break;
case 2:
$langue = "Allemand";
break;
case 3:
$langue = "Italien";
break;
case 4:
$langue = "Espagnol";
break;
case 5:
$langue = "Polonais";
break;
case 129:
$langue = "Chinois";
break;
default:
$langue = "Non définie";
break;
}
$groupe = ($row['onepartyonly']==1)?"Oui":"Non";
$pause = ($row['playerpause']==1)?"Oui":"Non";
$legal_char = ($row['legalchars']==1)?"Oui":"Non";
$item_restrict = ($row['itemrestrict']==1)?"Oui":"Non";
$save_serveur = ($row['localvault']==1)?"Non":"Oui";
$details = make_clickable(utf8_decode($row['details']));
$graph = "http://stats.nwn2.fr/graph.php?ip=".$row['ip']."&port=".$row['port'];
$nom_salle = $row['groupname'];
$salle = $row['groupid'];
$url_salle = "stats-".base64_encode("page#section|salle#".$salle).".html";
$url_serveur = "stats-".base64_encode("page#module|ip#".$ip."|port#".$port).".html";
$template->assign_vars(array('SERVEUR' => $hostname,
'MODULE' => $module_name,
'U_WEBSITE' => $url_website,
'U_PWC' => $url_pwc,
'IP' => $ip,
'Port' => $port,
'JOUEURS' => $joueurs."/".$maxjoueurs,
'VERSION' => $version,
'EXTENSION' => $expansion,
'MDP' => $mdp,
'NIVEAU' => $niveau,
'PVP' => $pvp,
'LANGUE' => $langue,
'GROUP' => $groupe,
'PAUSE' => $pause,
'PERSO_LEGAUX' => $legal_char,
'RESTRICTION' => $item_restrict,
'SAVE_SERVEUR' => $save_serveur,
'DETAILS' => $details,
'GRAPHIQUE' => $graph,
'U_SALLE_NAME' => $url_salle,
'SALLE_NAME' => $nom_salle,
'U_MODULE_NAME' => $url_serveur,
'MODULE_NAME' => $hostname
));
}
$template->pparse('body');
?>