Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Display errors on-page for those who don't want to (or can't) view their error.log
- // It can be safely removed
- Error_Reporting( E_ALL | E_STRICT );
- Ini_Set( 'display_errors', true );
- require "ServerQuery.class.php";
- $timer = microtime(true);
- $query = new ServerQuery();
- try {
- $query -> connect(SERVER_ADDR, SERVER_PORT, TIMEOUT);
- } catch(ServerQueryException $ex) {
- $exception = $ex;
- }
- // Display script runtime in milliseconds
- $timer = number_format((microtime(true) - $timer) * 1000, 0, '.', '');
- // To display runtime in seconds instead, uncomment next line and comment line 19
- //$timer = number_format((microtime(true) - $timer), 2, '.', '');
- ?>
- <?php if(isset($exception)): ?>
- <p><?php echo htmlspecialchars($exception -> getMessage()); ?></p>
- <?php else: ?>
- <table width="100%">
- <thead><tr><th colspan=2>Server Info <em>(queried in <?php echo $timer; ?>ms)</em></th></tr></thead>
- <tbody>
- <?php if(($info = $query -> getServerInfo()) !== false): ?>
- <?php foreach($info as $infoKey => $infoValue): ?>
- <tr><td><?php echo "<strong>" . htmlspecialchars($infoKey) . "</strong>"; ?></td>
- <td><?php
- if(is_array($infoValue)) {
- echo "<pre>";
- print_r($infoValue);
- echo "</pre>";
- } else {
- echo htmlspecialchars($infoValue);
- } ?>
- </td></tr>
- <?php endforeach; ?>
- <?php else: ?>
- <tr><td colspan=2>No data received.</td></tr>
- <?php endif; ?>
- </tbody>
- </table>
- <table width="100%">
- <thead>
- <tr><th>Players Online</th></tr>
- </thead>
- <tbody>
- <?php if(($players = $query -> getPlayerList()) !== false): ?>
- <?php foreach($players as $player): ?>
- <tr><td><?php echo htmlspecialchars($player); ?></td></tr>
- <?php endforeach; ?>
- <?php else: ?>
- <tr><td><em>There is no one online.</em></td></tr>
- <?php endif; ?>
- </tbody>
- </table>
- <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement