new server class

This commit is contained in:
2025-08-16 09:03:01 -04:00
parent 510a371b87
commit 35544d4e75
4 changed files with 28 additions and 29 deletions

View File

View File

@@ -1,34 +1,23 @@
<?php
error_reporting(0);
//Offline servers will splash error text. That is why error_reporting(0); is set.
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';
$ServerList[1]=new Server('Server 1', 'kokorogamers.com', 35566);
$ServerList[2]=new Server('Server 2', 'kokorogamers.com', 35567);
$ServerList[3]=new Server('Server 3', 'kokorogamers.com', 35568);
$ServerList[4]=new Server('Server 4', 'kokorogamers.com', 35569);
$ServerList[5]=new Server('Wonderbit', 'wonderbit.xyz', 25500);
$ServerList[6]=new Server('Blockgame', 'mc.blockgame.info', 25565);
$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){
function displayserver($s){
$status = new ServerStatusQuery();
$patterns = array ('/§7/','/§4/','/§kA/','/§2/','/§a/','/§f/','/§r/','/§b/','/§e/');
$replacements=array('','','','','','','','','');
$patterns = array ('/§6/','/§7/','/§8/','/§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]);}
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>";
@@ -62,8 +51,8 @@
<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>
<td class='info'><?php displayserver(5); ?></td>
<td class='info'><?php displayserver(6); ?></td>
</tr></table>
<br><br>
</div>

View File

@@ -1,6 +1,16 @@
<?php
function ping($host, $port, $timeout){return fSockOpen($host, $port, $errno, $errstr, $timeout);}
class Server{
public $NAME; public $HOST; public $PORT; public $PING;
public function __construct($NAME,$HOST,$PORT) {
$this->NAME = $NAME; $this->HOST = $HOST; $this->PORT = $PORT; $this->PING = ping($HOST, $PORT, 0.5);
}
function ping($host, $port, $timeout){return fSockOpen($host, $port, $errno, $errstr, $timeout);}
}
class ServerStatus {
private $status = array();
public function __construct($status) {$this->status = $status;}

View File

@@ -5,7 +5,7 @@ a:visited{color:#8888EF;}
a:hover{color:#8888EF;}
a:active{color:#8888EF;}
body {background-color:#222; color:#CCC; margin:0;}
.banner{display:block;height: 100px;}
.banner{display:block;}
.banner img {
float: left;
width: 100px;