Files
Minecraft-Server-Status/index.php
2025-08-15 07:34:06 -04:00

71 lines
2.5 KiB
PHP

<?php
include('minecraft_status.php');
$S_HOST[1]='kokorogamers.com';
$S_HOST[2]='kokorogamers.com';
$S_HOST[3]='kokorogamers.com';
$S_HOST[4]='kokorogamers.com';
$S_HOST[5]='wonderbit.xyz';
$S_HOST[6]='mc.blockgame.info';
$S_PORT[1]=35566;
$S_PORT[2]=35567;
$S_PORT[3]=35568;
$S_PORT[4]=35569;
$S_PORT[5]=25500;
$S_PORT[6]=25565;
$CHK_SERVER[1]=ping($S_HOST[1],$S_PORT[1],0.5);
$CHK_SERVER[2]=ping($S_HOST[2],$S_PORT[2],0.5);
$CHK_SERVER[3]=ping($S_HOST[3],$S_PORT[3],0.5);
$CHK_SERVER[4]=ping($S_HOST[4],$S_PORT[4],0.5);
$CHK_SERVER[5]=ping($S_HOST[5],$S_PORT[5],0.5);
$CHK_SERVER[6]=ping($S_HOST[6],$S_PORT[6],0.5);
function displayserver($s){
$status = new ServerStatusQuery();
$patterns = array ('/§7/','/§4/','/§kA/','/§2/','/§a/','/§f/','/§r/','/§b/','/§e/');
$replacements=array('','','','','','','','','');
echo $s!=5 && $s!=6?"<h2>Server ".$s."</h2><h3>".$GLOBALS['S_HOST'][$s].":".$GLOBALS['S_PORT'][$s]."</h3>":"<h3>".$GLOBALS['S_HOST'][$s].":".$GLOBALS['S_PORT'][$s]."</h3>";
if($GLOBALS['CHK_SERVER'][$s]){$info = $status->getServerInfo($GLOBALS['S_HOST'][$s], $GLOBALS['S_PORT'][$s]);}
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>.info{vertical-align:top; padding:25px 0 25px 0; width:50%;}</style>
</head>
<body>
<div align=center><div style='width:50vw;' align=left>
<br><br>
<div class="banner">
<h1>Minecraft Server Status</h1>
</div>
<table style='border-spacing: 30px;'><tr>
<td class='info'><?php displayserver(1); ?></td>
<td class='info'><?php displayserver(2); ?></td>
</tr><tr>
<td class='info'><?php displayserver(3); ?></td>
<td class='info'><?php displayserver(4); ?></td>
</tr><tr>
<td class='info'><h1>Wonderbit</h1><?php displayserver(5); ?></td>
<td class='info'><h1>Blockgame Server</h1><?php displayserver(6); ?></td>
</tr></table>
<br><br>
</div>
</body>
</html>