Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("starmade_query.inc.php");
- //Helper function to fetch the server data.
- function get_status($hostname)
- {
- try
- {
- $server = new TwoSphere\Starmade\server($hostname);
- $server->query();
- return $server;
- }
- catch(Exception $e)
- {
- echo "There was a problem fetching the server information.<br>";
- echo $e->getMessage()."<br>";
- return false;
- }
- }
- ?>
- <html>
- <head>
- <title>Starmade Server Query Example.</title>
- </head>
- <body>
- <form>
- <input name="host" type="text" value="<?=isset($_GET['host'])?$_GET['host']:"starmade.twosphere.net.au"?>"><input type="submit" value="Query">
- </form>
- <div>
- <?php
- //If the form has been submitted, then request the server status and display the result.
- $server = get_status('kab-s.de');
- {
- echo "<ul>";
- echo "<li><b>Name:</b> ".$server->name."</li>";
- echo "<li><b>Description:</b> ".$server->description."</li>";
- echo "<li><b>Version:</b> ".round($server->version,3)."</li>";
- echo "<li><b>Players:</b> ".$server->connected." / ".$server->capacity."</li>";
- echo "</ul>";
- }
- ?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement