Sydcul

http://mcstatus.sydcul.com/status.php

Mar 31st, 2013
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.99 KB | None | 0 0
  1. <?php
  2.  
  3.     $ip = explode(':', $_GET['ip']);
  4.    
  5.     if(empty($_GET['ip'])) {
  6.         echo('unset');
  7.         exit;
  8.     }
  9.    
  10.     $address = $ip[0];
  11.     $port = $ip[1];
  12.  
  13.     if(empty($port)) {
  14.         $port = 25565;
  15.     }
  16.  
  17.     $socket = @fsockopen($address, $port, $errno, $errstr, 1.0);
  18.      
  19.     if ($socket === false){
  20.         echo('connectionfailed');
  21.         exit;
  22.     }
  23.      
  24.     fwrite($socket, "\xfe\x01");
  25.      
  26.     $data = fread($socket, 256);
  27.      
  28.     if (substr($data, 0, 1) != "\xff"){
  29.         echo('minecraftfailed');
  30.         exit;
  31.     }
  32.      
  33.     if (substr($data, 3, 5) == "\x00\xa7\x00\x31\x00"){
  34.         $data = explode("\x00", mb_convert_encoding(substr($data, 15), 'UTF-8', 'UCS-2'));
  35.     }else{
  36.         $data = explode('ยง', mb_convert_encoding(substr($data, 3), 'UTF-8', 'UCS-2'));
  37.     }
  38.  
  39.     $info = array(
  40.         'version'        => $data[0],
  41.         'motd'            => $data[1],
  42.         'players'        => intval($data[2]),
  43.         'max_players'    => intval($data[3]),
  44.     );
  45.    
  46.     print_r($info);
  47. ?>
Add Comment
Please, Sign In to add comment