<?php
$ip = "213.202.197.15";
$port = "27015";
$con = fsockopen("udp://".$ip, $port);
fwrite($con, sprintf('%c%c%c%c%s%c', 0xFF, 0xFF, 0xFF, 0xFF, "infostring", 0x00));
fread($con, 24); //******** wegfiltern
$status = socket_get_status($con);
if($status["unread_bytes"] != 0){
$data = "";
while($status["unread_bytes"] != 0){
$data .= fread($con, 1);
$status = socket_get_status($con);
}
$data = explode("\\",$data);
$info["players"] = $data[5];
$info["lan"] = ($data[9]=="0") ? false : true;
$info["maxplayers"] = $data[11];
$info["gamedir"] = $data[13];
$info["description"] = $data[15];
$info["hostname"] = $data[17];
$info["map"] = $data[19];
$info["dedicated"] = ($data[21]=="d") ? true : false;
$info["password"] = ($data[23]=="0") ? false : true;
$info["os"] = ($data[25]=="w") ? "Windows" : "Linux";
echo "Auf dem Server \"".$info["hostname"]."\" spielen zur Zeit ".$info["players"]." von ".$info["maxplayers"]."<br><br>
OS: ".$info["os"].", Passwort: ".$info["password"].", Dedicated: ".$info["dedicated"].", Map: ".$info["map"].", Description: ".$info["description"].",
Gamedir: ".$info["gamedir"].", Lan: ".$info["lan"];
}else{
//Keine Verbindung
}
?>