Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.60 KB | None | 0 0
  1. function getvalue($uid, $what)
  2. {
  3.     $ip = "127.0.0.1";
  4.     $port = 20101;
  5.     $rcon = "test";
  6.     $server = fsockopen("udp://$ip", $port, $errno, $errstr, 1);
  7.     stream_set_timeout($server, 0, 200000);
  8.     fwrite($server, "\xFF\xFF\xFF\xFF rcon ".$rcon." status");
  9.     $return = stream_get_contents($server);
  10.    
  11.     $status = str_replace("\xFF\xFF\xFF\xFF print\n","",$return);
  12.    
  13.     $status = trim($status);
  14.    
  15.     $saved_status = $status;
  16.    
  17.    
  18.     $saved_explode = explode("\n",$status);
  19.    
  20.     unset($saved_explode[0]);
  21.     unset($saved_explode[1]);
  22.     unset($saved_explode[2]);
  23.    
  24.     $status = ereg_replace(" +"," ",$status);
  25.     $explode = explode("\n",$status);
  26.    
  27.     unset($explode[0]);
  28.     unset($explode[1]);
  29.     unset($explode[2]);
  30.    
  31.     foreach ($explode as $key => $value) {
  32.    
  33.         $fp = "No";
  34.         $guid = "n/a";
  35.         $fpban = "";
  36.    
  37.         $spliff = explode(" ",$value);
  38.    
  39.         $id = $spliff[1];
  40.         $score = $spliff[2];
  41.         $ping = $spliff[3];
  42.    
  43.         $rate = $spliff[count($spliff)-1];
  44.         $qport = $spliff[count($spliff)-2];
  45.    
  46.         $address_temp = $spliff[count($spliff)-3];
  47.    
  48.         $address = substr($address_temp,0,strpos($address_temp,":"));
  49.         $gameport = substr($address_temp,strpos($address_temp,":")+1);
  50.    
  51.         $lastmsg = $spliff[count($spliff)-4];
  52.    
  53.         $pos = strpos($saved_explode[$key]," $ping ") + strlen(" $ping ");
  54.         $lastpos = strrpos($saved_explode[$key]," $lastmsg ");
  55.    
  56.         $name = str_replace("'","",str_replace("#","",htmlentities(trim(substr($saved_explode[$key]," $pos ",$lastpos - $pos)))));
  57.    
  58.         if ($what == "name")
  59.         {
  60.             return $name;
  61.         }
  62.         else if ($what == "ip")
  63.         {
  64.             return $address;
  65.         }
  66.        
  67.    
  68.     }
  69.    
  70.    
  71.     fclose($server);
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement