Advertisement
Guest User

Untitled

a guest
Aug 20th, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. <?php
  2.  
  3. include("starmade_query.inc.php");
  4.  
  5. //Helper function to fetch the server data.
  6. function get_status($hostname)
  7. {
  8. try
  9. {
  10. $server = new TwoSphere\Starmade\server($hostname);
  11. $server->query();
  12. return $server;
  13. }
  14. catch(Exception $e)
  15. {
  16. echo "There was a problem fetching the server information.<br>";
  17. echo $e->getMessage()."<br>";
  18. return false;
  19. }
  20. }
  21.  
  22. ?>
  23. <html>
  24. <head>
  25. <title>Starmade Server Query Example.</title>
  26. </head>
  27.  
  28. <body>
  29. <form>
  30. <input name="host" type="text" value="<?=isset($_GET['host'])?$_GET['host']:"starmade.twosphere.net.au"?>"><input type="submit" value="Query">
  31. </form>
  32.  
  33. <div>
  34. <?php
  35. //If the form has been submitted, then request the server status and display the result.
  36. $server = get_status('kab-s.de');
  37. {
  38. echo "<ul>";
  39. echo "<li><b>Name:</b> ".$server->name."</li>";
  40. echo "<li><b>Description:</b> ".$server->description."</li>";
  41. echo "<li><b>Version:</b> ".round($server->version,3)."</li>";
  42. echo "<li><b>Players:</b> ".$server->connected." / ".$server->capacity."</li>";
  43. echo "</ul>";
  44. }
  45. ?>
  46. </div>
  47. </body>
  48. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement