Godleydemon

test.php

Oct 23rd, 2020
752
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <?php
  3.     require __DIR__ . '/src/MinecraftPing.php';
  4.     require __DIR__ . '/src/MinecraftPingException.php';
  5.    
  6.     use xPaw\MinecraftPing;
  7.     use xPaw\MinecraftPingException;
  8.    
  9.    
  10. function print_array($title,$array){
  11.  
  12.         if(is_array($array)){
  13.  
  14.             echo $title."<br/>"."<pre>";
  15.             print_r($array);
  16.             echo "</pre>".$title."<br/>"."<br/>";
  17.  
  18.         }else{
  19.              echo $title." is not an array.";
  20.         }
  21. }
  22.    
  23.     try
  24.     {
  25.         /*$Query = new MinecraftPing( '142.44.136.23', 25565 );
  26.         print_array("description", $Query->Query());
  27.         print("<pre>" .print_r($Query->Query())."</pre>" );*/
  28.        
  29.         $Server = new MinecraftPing( '142.44.136.23', 25565 );
  30.         $info = $Server->Query();
  31.        
  32.         echo '<table style="border:1px solid black, padding: 30px"><th style="border:1px solid black">Icon</th><th style="border:1px solid black">Server</th><th style="border:1px solid black">Description</th><th style="border:1px solid black">Players</th><tr>';
  33.         echo '<td style="border:1px solid black"><img width="64" height="64" src="' . Str_Replace( "\n", "", $info[ 'favicon' ] ) . '"></td>';
  34.         echo '<td style="border:1px solid black">Outcasted ATM6</td>';
  35.         echo '<td style="border:1px solid black">' . $info['description']['text'] . '</td>';
  36.         echo '<td style="border:1px solid black"><center>' . $info['players']['online'] . ' / ' . $info['players']['max'] . '</center></td>';
  37.         //print_r(array_keys($info));
  38.         foreach($info['forgeData']['mods'] as $key => $value) {  
  39.             echo '<tr><td style="border:1px solid black">' . $key . '</td><td style="border:1px solid black">' . $value['modId'] . '</td><td style="border:1px solid black">' . $value['modmarker'] . "</td></tr>";  
  40.         }
  41.         foreach($info['players']['sample'] as $key => $value) {  
  42.             echo '<tr><td style="border:1px solid black">' . $value['name'] . '</td></tr>';  
  43.         }
  44.     }
  45.     catch( MinecraftPingException $e )
  46.     {
  47.         echo $e->getMessage();
  48.     }
  49.     finally
  50.     {
  51.         if( $Server )
  52.         {
  53.             $Server->Close();
  54.         }
  55.     }
  56. ?>
RAW Paste Data