php: Server Stats
Posted: Tue Oct 14, 2003 4:38 pm
Server Stats for Quake2, but can b easily tweaked for other games like Quake1, Quake3, HL. This Code is not for some1 who's new to coding
Im workin on a v3 of this code. Its using SQL and will have some 'funny' things soon!
Current version: http://den.dark-millennium.de/serverstats.php
Old version:
Im workin on a v3 of this code. Its using SQL and will have some 'funny' things soon!
Current version: http://den.dark-millennium.de/serverstats.php
Old version:
Code: Select all
<?php
$fp = fsockopen("udp://" . $ip, $port, $errno, $errstr, 10);
if (!$fp) {
echo "ERROR: $errno - $errstr<br>\n";
} else {
fwrite($fp,"ÿÿÿÿstatus\x00");
$header = fread($fp,10);
// Read in the info from the server.
$do = true;
$result = "";
while($do)
{
$str = fread($fp,1);
$result .= $str;
if ( $str == "\n" ) $do = false;
}
$serverinfo = explode("\\",$result);
echo "<br><br>";
socket_set_blocking($fp,0);
$do = true;
$i = 0;
while ($do)
{
$temp = fgets($fp, 100);
if ($temp == "")
{
$do = false;
}
else
{
$tempplayers[$i] = $temp;
}
$i++;
}
// Display all server settings
for ($i = 0; $i <= sizeof($serverinfo); $i++) {
echo $serverinfo[$i] . "<br>";
}
// Display all players with pings and frags
echo "frags | ping | name<br>";
for ($i = 0; $i <= sizeof($tempplayers); $i++) {
echo $tempplayers[$i] . "<br>";
}
fclose($fp);
}
?>