Created
September 19, 2011 07:08
-
-
Save anonymous/1226084 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ip = "192.168.1.190"; // Minecraft IP | |
$port = "25566"; // Minecraft port | |
$fp = fsockopen($ip, $port, $errno, $errstr, 5); // Socket for connecting to server | |
if (!$fp) { | |
echo "Error"; | |
} else { | |
$out = "\xFE"; // Hex needed for server info | |
fwrite($fp, $out); | |
while (!feof($fp)) { | |
$result .= fgets($fp, 128); | |
} | |
fclose($fp); | |
// Remove extra spaces between characters | |
$result = str_replace("\x00", "", $result); | |
$result = str_replace("\x1A", "", $result); | |
$result = str_replace("\xFF", "", $result); | |
$srvinfo = explode("\xA7",$result); | |
echo "motd: " . $srvinfo[0] . "\n"; | |
echo "players: " . $srvinfo[1] . "\n"; | |
echo "max_players: " . $srvinfo[2] . "\n"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment