<?php
$ServNum = 0; // start off the server aray at 0 (first array posistion)
$ServSlots = 0; //start to count the total slot that can be filled
$ServFSlots = 0; // Count the filled slots
// Build the array the hard way
//----------------------------------
$CSSserver[] = "noodels.demon.nl"; //Ip address
$CSSport[] = "27015"; //Port Number CS:S default is 27015
$CSSserver[] = "000.000.000.000"; //Ip address
$CSSport[] = "27015"; //Port Number CS:S default is 27015
$CSSserver[] = "000.000.000.000"; //Ip address
$CSSport[] = "27015"; //Port Number CS:S default is 27015
//----------------------------------
while($ServNum<3){
$CSSourceServer = "udp://" . $CSSserver[$ServNum];
$CSSourceServerPort = $CSSport[$ServNum];
//----------------------------------
// For More information on the fsockopen
// [url]http://www.php.net/manual/en/function.fsockopen.php[/url]
// resource fsockopen ( string target, int port [, int &errno [, string &errstr [, float timeout]]] )
//
$CSSfeed = fsockopen($CSSourceServer, $CSSourceServerPort, $errno, $errstr, 30);
if ($CSSfeed){
fwrite($CSSfeed,"\xFF\xFF\xFF\xFF\x54");
fread($CSSfeed,6);
$byte = "A";
$string = "";
for($i = 0; $i < 4; ){
$byte = fread($CSSfeed,1);
if(!ord($byte)){
$array[] = $string;
$i++;
$string = "";
continue;
}
$string .= $byte;
}
fread($CSSfeed,2);
$players = ord(fread($CSSfeed,1)); //start to count the total slots that can be filled
$slots = ord(fread($CSSfeed,1)); // Count the filled slots
$css_players = $players . "/" . $slots;
$ServFSlots = $ServFSlots + $players; // get the total amount of players playing
$ServSlots = $ServSlots + $slots; // Get the total amount of possable connections
fread($CSSfeed,1);
fread($CSSfeed,1);
$css_os = ((fread($CSSfeed,1) == "w") ? "Windows" : "Linux");
//Print the info as it's gotten
//-----------------------------
$ShowServer[] = "<b>Server Name</b>:<br>\n $array[0]<br>\n
<b>Server IP</b>:<br>\n $CSSserver[$ServNum]:$CSSport[$ServNum] <br>\n
<b>Map Name</b>:<br>\n $array[1] <br>\n
<b>Players</b>:<br>\n $css_players <br>\n
<b>Server OS</b>:<br>\n $css_os <br>\n";
fclose($CSSfeed);
}else{
echo "$errstr ($errno)";
}
unset($array); // This deletes the whole array
$ServNum++;
}
//Fast Dump Should be counted and looped.
echo $ShowServer[0] . " <br>\n";
//echo $ShowServer[1] . "<br>\n";
//echo $ShowServer[2] . "<br>\n";
echo "<b>Used connections</b>: " . $ServFSlots . " <br>\n";
echo "<b>Max connections</b>: " . $ServSlots . " <br>\n";
?>