Merge pull request 'server class' (#1) from test into main
Reviewed-on: #1
This commit is contained in:
46
index.php
46
index.php
@@ -1,34 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
|
error_reporting(0);
|
||||||
|
//Offline servers will splash error text. That is why error_reporting(0); is set.
|
||||||
|
|
||||||
include('minecraft_status.php');
|
include('minecraft_status.php');
|
||||||
|
|
||||||
|
$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_HOST[1]='kokorogamers.com';
|
function displayserver($s){
|
||||||
$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();
|
$status = new ServerStatusQuery();
|
||||||
$patterns = array ('/§7/','/§4/','/§kA/','/§2/','/§a/','/§f/','/§r/','/§b/','/§e/');
|
$patterns = array ('/§6/','/§7/','/§8/','/§4/','/§kA/','/§2/','/§a/','/§f/','/§r/','/§b/','/§e/');
|
||||||
$replacements=array('','','','','','','','','');
|
$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>";
|
echo "<h2>".$GLOBALS['ServerList'][$s]->NAME."</h2><h3>".$GLOBALS['ServerList'][$s]->HOST.":".$GLOBALS['ServerList'][$s]->PORT."</h3>";
|
||||||
if($GLOBALS['CHK_SERVER'][$s]){$info = $status->getServerInfo($GLOBALS['S_HOST'][$s], $GLOBALS['S_PORT'][$s]);}
|
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>";}
|
if($info == false){echo "<span style='color:#F00;'>OFFLINE</span><br>";}
|
||||||
else{
|
else{
|
||||||
echo "<span style='color:#0F0;'>ONLINE</span><br>";
|
echo "<span style='color:#0F0;'>ONLINE</span><br>";
|
||||||
@@ -45,6 +34,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Minecraft Server Status</title>
|
<title>Minecraft Server Status</title>
|
||||||
|
<link rel="stylesheet" href="styles.css?v=<?php echo time();?>">
|
||||||
<style>.info{vertical-align:top; padding:25px 0 25px 0; width:50%;}</style>
|
<style>.info{vertical-align:top; padding:25px 0 25px 0; width:50%;}</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -61,8 +51,8 @@
|
|||||||
<td class='info'><?php displayserver(3); ?></td>
|
<td class='info'><?php displayserver(3); ?></td>
|
||||||
<td class='info'><?php displayserver(4); ?></td>
|
<td class='info'><?php displayserver(4); ?></td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
<td class='info'><h1>Wonderbit</h1><?php displayserver(5); ?></td>
|
<td class='info'><?php displayserver(5); ?></td>
|
||||||
<td class='info'><h1>Blockgame Server</h1><?php displayserver(6); ?></td>
|
<td class='info'><?php displayserver(6); ?></td>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
<br><br>
|
<br><br>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
function ping($host, $port, $timeout){return fSockOpen($host, $port, $errno, $errstr, $timeout);}
|
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 {
|
class ServerStatus {
|
||||||
private $status = array();
|
private $status = array();
|
||||||
|
|||||||
41
styles.css
Normal file
41
styles.css
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
h1{color:#EFEF88;}
|
||||||
|
h2{color:#EFEF88;}
|
||||||
|
a:link{color:#8888EF;}
|
||||||
|
a:visited{color:#8888EF;}
|
||||||
|
a:hover{color:#8888EF;}
|
||||||
|
a:active{color:#8888EF;}
|
||||||
|
body {background-color:#222; color:#CCC; margin:0;}
|
||||||
|
.banner{display:block;}
|
||||||
|
.banner img {
|
||||||
|
float: left;
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.banner h1 {
|
||||||
|
position: relative;
|
||||||
|
top: 18px;
|
||||||
|
left: 10px;
|
||||||
|
}
|
||||||
|
.banner h2 {
|
||||||
|
position: relative;
|
||||||
|
top: 2px;
|
||||||
|
left: 10px;
|
||||||
|
}
|
||||||
|
.banner h3 {
|
||||||
|
color:#EFEF88;
|
||||||
|
position: relative;
|
||||||
|
top: 2px;
|
||||||
|
left: 10px;
|
||||||
|
}
|
||||||
|
.banner a:link{text-decoration: none;position: relative;}
|
||||||
|
.banner a:visited{text-decoration: none;position: relative;}
|
||||||
|
.banner a:hover{text-decoration: none;position: relative;}
|
||||||
|
.banner a:active{text-decoration: none;position: relative;}
|
||||||
|
.notice{display: block;}
|
||||||
|
.notice{background-color: #EFEF88;color: #000000;}
|
||||||
|
.warning{display: block}
|
||||||
|
.warning{background-color: #efaf88;color: #000000;}
|
||||||
|
input{background-color: #555555; color: #CCC;}
|
||||||
|
textarea{background-color: #555555; color: #CCC;}
|
||||||
|
select{background-color: #555555; color: #CCC;}
|
||||||
Reference in New Issue
Block a user