Hey,
Ich versuche derzeit per HTML & PHP die Useranzahl von einem server anzeigen zu lassen..
Jedoch zeigt er nur denn code in der html datei an...
Der code:
HTML
<html>
<head>
<title>Statusanzeige</title>
</head>
<body>
<?
function ping($host="149.202.78.4", $port=41497, $timeout=1) {
$handle = fsockopen($host, $port, $errno, $errstr, $timeout);
try {
fwrite($handle, "\xFE");
$d = fread($handle, 256);
if ($d[0] != "\xFF") return array('motd' => "", 'players' => "?", 'max_players' => "?");
$d = substr($d, 3);
$d = mb_convert_encoding($d, 'auto', 'UCS-2');
$d = explode("\xA7", $d);
fclose($handle);
} catch(Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "n";
}
return array('motd' => $d[0], 'players' => (int)$d[1], 'max_players' => (int)$d[2]);
}
$status = ping("149.202.78.4");
echo "Message of the day: ".$status['motd']."<br>";
echo "Spieler online: ".$status['players']."<br>";
echo "Slots (Maximale Spieler): ".$status['max_players'];
?>
</body>
</html>
Alles anzeigen