Files
Minecraft-Server-Status/index.php
2025-08-16 12:14:11 -04:00

61 lines
2.4 KiB
PHP

<?php
error_reporting(0);
//Offline servers will splash error text. That is why error_reporting(0); is set.
include('minecraft_status.php');
$ServerList[1]=new Server(NAME:'Server 1', HOST:'kokorogamers.com', PORT:35566);
$ServerList[2]=new Server(NAME:'Server 2', HOST:'kokorogamers.com', PORT:35567);
$ServerList[3]=new Server(NAME:'Server 3', HOST:'kokorogamers.com', PORT:35568);
$ServerList[4]=new Server(NAME:'Server 4', HOST:'kokorogamers.com', PORT:35569);
$ServerList[5]=new Server(NAME:'Wonderbit', HOST:'wonderbit.xyz', PORT:25500);
$ServerList[6]=new Server(NAME:'Blockgame', HOST:'mc.blockgame.info', PORT:25565);
function displayserver($s){
$status = new ServerStatusQuery();
$patterns = array ('/§6/','/§7/','/§8/','/§4/','/§kA/','/§2/','/§a/','/§f/','/§r/','/§b/','/§e/');
$replacements=array('','','','','','','','','','','');
echo "<h2>".$GLOBALS['ServerList'][$s]->NAME."</h2><h3>".$GLOBALS['ServerList'][$s]->HOST.":".$GLOBALS['ServerList'][$s]->PORT."</h3>";
if($GLOBALS['ServerList'][$s]->PING){$info = $status->getServerInfo($GLOBALS['ServerList'][$s]->HOST, $GLOBALS['ServerList'][$s]->PORT);}
if($info == false){echo "<span style='color:#F00;'>OFFLINE</span><br>";}
else{
echo "<span style='color:#0F0;'>ONLINE</span><br>";
echo "MOTD: " . preg_replace($patterns, $replacements, $info->getMOTD()) . "<br>";
//echo "MOTD: " . $info->getMOTD() . "<br>";
echo "Version: " . $info->getVersion() . "<br>";
echo "Players: " . $info->getCurrentPlayers() . "<br>";
}
echo "<br>";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Minecraft Server Status</title>
<style>
html,body {background-color:#222; color:#CCC; margin:0;}
h1,h2,h3{color:#EFEF88;}
.center{width:50vw; margin:auto;}
.container{display: grid; grid-template-columns: auto auto;}
.content{margin-right: 60px;}
</style>
</head>
<body>
<div class='center'>
<br><br>
<h1>Minecraft Server Status</h1>
<div class='container'>
<div class='contnent'><?php displayserver(1); ?></div>
<div class='contnent'><?php displayserver(2); ?></div>
<div class='contnent'><?php displayserver(3); ?></div>
<div class='contnent'><?php displayserver(4); ?></div>
<div class='contnent'><?php displayserver(5); ?></div>
<div class='contnent'><?php displayserver(6); ?></div>
</div>
<br><br>
</div>
</body>
</html>