Home > Panele > Minecraft ststystyki

Minecraft ststystyki

Dodane przez: piciu
opis:
MC serwer lady (Pokazuje graczy online głowy)
Kod:
  1. openside("Serverio statusas");
  2. class Minequery {
  3.  
  4. public static function query($address, $port = 25566, $timeout = 30) {
  5. $query = array();
  6.  
  7. $beginning_time = microtime(true);
  8.  
  9. $socket = @fsockopen($address, $port, $errno, $errstr, $timeout);
  10.  
  11. if (!$socket) {
  12.  
  13. }
  14.  
  15. $end_time = microtime(true);
  16.  
  17. fwrite($socket, "QUERY\n");
  18.  
  19. $response = "";
  20.  
  21. while(!feof($socket)) {
  22. $response .= fgets($socket, 1024);
  23. }
  24.  
  25. $response = explode("\n", $response);
  26.  
  27.  
  28. $query['serverPort'] = explode(" ", $response[0], 2);
  29. $query['serverPort'] = $query['serverPort'][1];
  30.  
  31.  
  32. $query['playerCount'] = explode(" ", $response[1], 2);
  33. $query['playerCount'] = $query['playerCount'][1];
  34.  
  35.  
  36. $query['maxPlayers'] = explode(" ", $response[2], 2);
  37. $query['maxPlayers'] = $query['maxPlayers'][1];
  38.  
  39.  
  40. $query['playerList'] = explode(" ", $response[3], 2);
  41. $query['playerList'] = explode(", ", trim($query['playerList'][1], "[]"));
  42.  
  43. $query['latency'] = ($end_time - $beginning_time) * 1000;
  44.  
  45. return $query;
  46. }
  47.  
  48.  
  49. public static function query_json($address, $port = 25566, $timeout = 30) {
  50. $beginning_time = microtime(true);
  51.  
  52. $socket = @fsockopen($address, $port, $errno, $errstr, $timeout);
  53.  
  54. if (!$socket) {
  55.  
  56. }
  57.  
  58. $end_time = microtime(true);
  59.  
  60. fwrite($socket, "QUERY_JSON\n");
  61.  
  62. $response = "";
  63.  
  64. while(!feof($socket)) {
  65. $response .= fgets($socket, 1024);
  66. }
  67.  
  68. $query = json_decode($response);
  69. $query->latency = ($end_time - $beginning_time) * 1000;
  70.  
  71. return $query;
  72. }
  73. }
  74. $s = Minequery::query("play.mc-rule.lt");
  75. echo "<b>Serverio IP:</b> play.mc-rule.lt
  76. <br/>";
  77. if($s){
  78. echo "<b>Statusas: <font style='color:#00CC33'>ON</font></b><br/>";
  79. if($s['playerCount']>0){
  80. $i=0;
  81. foreach($s['playerList'] as $player)
  82. {
  83. if($i!=0){
  84. }
  85. echo "<img title='$player' src='http://mc-rule.lt/avatar.php?u=$player&s=60' />";
  86. $i++;
  87. }
  88. }
  89.  
  90. echo "<b>Statusas: <font style='color:#993333'>OFF</font></b><br/>";
  91.  
  92. }
  93. echo "<br /><b>Serverio versija: <font style='color:#cc9900'>1.4.7,</font><font style='color:#993333'></font></b><br/>";
  94. closeside();

©