Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Edit this ->
- define( 'MQ_SERVER_ADDR', 'localhost' ); //remplacez 'localhost' par l'adresse de votre serveur
- define( 'MQ_SERVER_PORT', 25565 ); //remplacez 25565 par le port de votre serveur
- define( 'MQ_TIMEOUT', 1 );
- // Edit this <-
- // Display everything in browser, because some people can't look in logs for errors
- Error_Reporting( E_ALL | E_STRICT );
- Ini_Set( 'display_errors', true );
- require __DIR__ . '/MinecraftQuery.class.php'; //ligne qui inclut la class MinecraftQuery
- $Timer = MicroTime( true );
- $Query = new MinecraftQuery( );
- try
- {
- $Query->Connect( MQ_SERVER_ADDR, MQ_SERVER_PORT, MQ_TIMEOUT );
- }
- catch( MinecraftQueryException $e )
- {
- $Error = $e->getMessage( );
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Minecraft Query PHP Class</title>
- <link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
- <style type="text/css">
- footer {
- margin-top: 45px;
- padding: 35px 0 36px;
- border-top: 1px solid #e5e5e5;
- }
- footer p {
- margin-bottom: 0;
- color: #555;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <div class="page-header">
- <h1>Minecraft Query PHP Class</h1>
- </div>
- <?php if( isset( $Error ) ): ?>
- <div class="alert alert-info">
- <h4 class="alert-heading">Exception:</h4>
- <?php echo htmlspecialchars( $Error ); ?>
- </div>
- <?php else: ?>
- <div class="row">
- <div class="span6">
- <table class="table table-bordered table-striped">
- <thead>
- <tr>
- <th colspan="2">Server info</th>
- </tr>
- </thead>
- <tbody>
- <?php if( ( $Info = $Query->GetInfo( ) ) !== false ): ?>
- <?php foreach( $Info as $InfoKey => $InfoValue ): ?>
- <tr>
- <td><?php echo htmlspecialchars( $InfoKey ); ?></td>
- <td><?php
- if( Is_Array( $InfoValue ) )
- {
- echo "<pre>";
- print_r( $InfoValue );
- echo "</pre>";
- }
- else
- {
- echo htmlspecialchars( $InfoValue );
- }
- ?></td>
- </tr>
- <?php endforeach; ?>
- <?php endif; ?>
- </tbody>
- </table>
- </div>
- <div class="span6">
- <table class="table table-bordered table-striped">
- <thead>
- <tr>
- <th>Players</th>
- </tr>
- </thead>
- <tbody>
- <?php if( ( $Players = $Query->GetPlayers( ) ) !== false ): ?>
- <?php foreach( $Players as $Player ): ?>
- <tr>
- <td><?php echo htmlspecialchars( $Player ); ?></td>
- </tr>
- <?php endforeach; ?>
- <?php else: ?>
- <tr>
- <td>No players in da house!</td>
- </tr>
- <?php endif; ?>
- </tbody>
- </table>
- </div>
- </div>
- <?php endif; ?>
- <footer>
- <p class="pull-right">Generated in <span class="badge badge-success"><?php echo Number_Format( ( MicroTime( true ) - $Timer ), 4, '.', '' ); ?>s</span></p>
- <p>Written by <a href="http://xpaw.ru" target="_blank">xPaw</a></p>
- <p>Code licensed under the <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/" target="_blank">CC BY-NC-SA 3.0</a></p>
- <p>Sourcecode available on <a href="https://github.com/xPaw/PHP-Minecraft-Query" target="_blank">GitHub</a></p>
- </footer>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment