<!DOCTYPE html> <html lang="en"> <?php require_once 'MinecraftServerStatus.class.php'; $Server_MC = new MinecraftServerStatus('127.0.0.1', 25564); ?> <!-- MC Online check --> <?php if ($Server_MC->Get('online')) { ?> <!-- MOTD --> <button class="btn btn-info disabled"></i> <?php echo $Server_MC->Get('hostname'); ?> </button> <?php } ?> <!-- MC Online check --> <?php if ($Server_MC->Get('online')) { ?> <button class="btn btn-success disabled"><i class="icon-ok icon-white"></i> Online</button> <?php } else { ?> <button class="btn btn-danger disabled"><i class="icon-remove icon-white"></i> Offline</button> <?php }
function getMinecraftPlayers($port) { $server = new MinecraftServerStatus('127.0.0.1', $port); $players = false; $numplayers = 0; if ($server->Get('numplayers') > "0") { $players = true; $numplayers = $server->Get('numplayers'); } return array($players, $numplayers); }
<?php // do DOS commands here and pipe output to $out require_once 'MineCraftServerStatus/MinecraftServerStatus.class.php'; $Server = new MinecraftServerStatus($_GET['host'], $_GET['port'], 2); $out = array('online' => $Server->Get('online'), 'hostport' => $Server->Get('hostport'), 'hostip' => $Server->Get('hostip'), 'motd' => $Server->Get('hostname'), 'numplayers' => $Server->Get('numplayers'), 'maxplayers' => $Server->Get('maxplayers'), 'version' => $Server->Get('version'), 'map' => $Server->Get('map'), 'gametype' => $Server->Get('gametype'), 'game_id' => $Server->Get('game_id'), 'software' => $Server->Get('software')); header('Content-type: application/json'); echo json_encode($out);
<!DOCTYPE html> <html lang="en"> <script> // Enable bootstrap tooltips $(function () { $("[rel=tooltip]").tooltip(); }); </script> <?php require_once 'MinecraftServerStatus.class.php'; $Server_FTB = new MinecraftServerStatus('127.0.0.1', 25565); ?> <!-- FTB Online Players --> <?php if ($Server_FTB->Get('numplayers') > "0") { foreach ($Server_FTB->Get('players') as $Player_FTB) { if (file_exists('/Users/zeus/Sites/d4rk.co/mc/img/avatars/' . $Player_FTB . '.png')) { echo '<img src="/mc/img/avatars/' . $Player_FTB . '.png" rel="tooltip" data-toggle="tooltip" title="' . $Player_FTB . '" style="margin-right: 1px; margin-left: 1px" class="img-polaroid">'; } else { $f = file_put_contents("/Users/zeus/Sites/d4rk.co/mc/img/avatars/" . $Player_FTB . ".png", fopen("https://minotar.net/helm/" . $Player_FTB . "/30.png", 'r')); if ($f) { echo '<img src="/mc/img/avatars/' . $Player_FTB . '.png" rel="tooltip" data-toggle="tooltip" title="' . $Player_FTB . '" style="margin-right: 1px; margin-left: 1px" class="img-polaroid">'; } else { echo '<p>Unable to download avatar</p>'; } } } }
<!DOCTYPE html> <html lang="en"> <script> // Enable bootstrap tooltips $(function () { $("[rel=tooltip]").tooltip(); }); </script> <?php require_once 'MinecraftServerStatus.class.php'; // Assign variables $Server_MC = new MinecraftServerStatus('127.0.0.1', 25564); // MC Online Players if ($Server_MC->Get('numplayers') > "0") { foreach ($Server_MC->Get('players') as $Player_MC) { $avatarLocal = '/Users/zeus/Sites/d4rk.co/mc/img/avatars/' . $Player_MC . '.png'; } // If our local avatar file exists and is less than 24 hours old if (file_exists($avatarLocal) && filemtime($avatarLocal) > time() - 60 * 60 * 24) { echo '<img src="/mc/img/avatars/' . $Player_MC . '.png" rel="tooltip" data-toggle="tooltip" title="' . $Player_MC . '" style="margin-right: 1px; margin-left: 1px" class="img-polaroid">'; } else { $f = file_put_contents($avatarLocal, fopen("https://minotar.net/helm/" . $Player_MC . "/30.png", 'r')); if ($f) { echo '<img src="/mc/img/avatars/' . $Player_MC . '.png" rel="tooltip" data-toggle="tooltip" title="' . $Player_MC . '" style="margin-right: 1px; margin-left: 1px" class="img-polaroid">'; } else { echo '<p>Unable to download avatar</p>'; } } }
#!/usr/bin/php <?php // Munin plugin for monitoring number of players connected to Minecraft // Written by pazpop and grobux for http://demineurs.fr/ // // Prerequisite : MinecraftServerStatus.class.php (https://github.com/NoxNebula/Minecraft-Server-Status) // Compatible and tested with : Minecraft Spigot 1.8.3 // // First release : (v0.1) 2015-10-29 // Last release : // Configuration $ip_host = '127.0.0.1'; $mc_port = '25565'; $path_class = '/usr/share/munin/plugins/MinecraftServerStatus.class.php'; // Main script if (count($argv) == 2 && $argv[1] == 'config') { echo "graph_title Minecraft Users\n"; echo "graph_vlabel Users\n"; echo "users.label Users\n"; echo "users.type GAUGE\n"; echo "graph_category Minecraft\n"; echo "graph_info Number of players connected to Minecraft\n"; exit; } require_once $path_class; $mc = new MinecraftServerStatus($ip_host, $mc_port); echo "users.value "; echo $mc->Get('numplayers') . "\n"; exit;
$Server = new MinecraftServerStatus('Your.servers.IP.address.when.port.number.equals.25565'); <br/> your server's current (static, if possible) IP address has replaced "Your.servers.IP.address.when.port.number.equals.25565". Also, make sure that your server jar has been renamed to: "minecraft_server" (dot 'jar' if using jre), and that all server components have been placed in the "/server/" directory. Enjoy! <br/><br/> Server Status Info: <br/><br/> <b>Online/Offline:</b> <?php $Server->Get('online'); ?> <br/> <b>Player Count:</b> <?php echo $Server->Get('numplayers') . ' / ' . $Server->Get('maxplayers'); ?> <br/> <b>Hostname:</b> <?php $Server->Get('hostname'); ?> <br/> <b>Gametype:</b> <?php $Server->Get('gametype');