Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $ip = explode(':', $_GET['ip']);
- if(empty($_GET['ip'])) {
- echo('unset');
- exit;
- }
- $address = $ip[0];
- $port = $ip[1];
- if(empty($port)) {
- $port = 25565;
- }
- $socket = @fsockopen($address, $port, $errno, $errstr, 1.0);
- if ($socket === false){
- echo('connectionfailed');
- exit;
- }
- fwrite($socket, "\xfe\x01");
- $data = fread($socket, 256);
- if (substr($data, 0, 1) != "\xff"){
- echo('minecraftfailed');
- exit;
- }
- if (substr($data, 3, 5) == "\x00\xa7\x00\x31\x00"){
- $data = explode("\x00", mb_convert_encoding(substr($data, 15), 'UTF-8', 'UCS-2'));
- }else{
- $data = explode('ยง', mb_convert_encoding(substr($data, 3), 'UTF-8', 'UCS-2'));
- }
- $info = array(
- 'version' => $data[0],
- 'motd' => $data[1],
- 'players' => intval($data[2]),
- 'max_players' => intval($data[3]),
- );
- print_r($info);
- ?>
Add Comment
Please, Sign In to add comment