- Joined
- Dec 24, 2006
- Messages
- 71
- Reaction score
- 37
I wasn't gonna release it at first. But what the heck, here you go guys. A advanced php server status coded by me. Use it if you know php, I won't make a 'stupid guide' if something goes wrong or you want to change it. Tells you if the server is offline or not and if its lagging or not. I would advise changing ping values cause a server pinging a server will have a good connection, so try evening it out, for people using it localhost. It will always say great, so....yea. HF
Code:
<?php
$server = "localhost";
$port = "2106";
function pingDomain($server){
$starttime = microtime(true);//Server 1 Port
$file = fsockopen ($domain, 2106, $errno, $errstr, 10);
$stoptime = microtime(true);
$status = 0;
if (!$file) $status = -1;
else {
fclose($file);
$status = ($stoptime - $starttime) * 1000;
$status = floor($status);
}
return $status;
}
$status = pingDomain($serverbase);
if ($status <= 50) $MessageStatus = "Great";
elseif ($status <= 80) $MessageStatus = "Good";
elseif ($status <= 100) $MessageStatus = "Ok";
elseif ($status <= 150) $MessageStatus = "Bad";
elseif ($status <= 999) $MessageStatus = "Poor";
else $MessageStatus = "Disconnected";
$upmessage = "<font size='1' color='white'><br>Stability: </font><font color='gray'
size='1'>$MessageStatus</font><br>";
$downmessage = "<font size='1' color='white'><br>Stability: </font><font color='gray'
size='1'>Disconnected</font><br>";
$tout = "5";
$server1 = @fsockopen ($server, $port, $errno, $errstr, $tout);
if(!$server1){ echo"<br><font color='C8B560' size='2' style='Arial'><strong>Login</strong></font><br><font
size='1' color='white'>Status:</font><font color='red' size='1' style='Arial'> Off</font>$downmessage"; }
else { echo"<br><font color='C8B560' size='2' style='Arial'><strong>Login</strong></font><br><font size='1'
color='white'>Status:</font><font color='green' size='1' style='Arial'> On</font>$upmessage"; }
$server2 = "localhost";
$port2 = "7777";
function pingDomain2($server2){
$starttime2 = microtime(true);//Server 2 Port
$file2 = fsockopen ($domain2, 7777, $errno, $errstr, 10);
$stoptime2 = microtime(true);
$status2 = 0;
if (!$file2) $status2 = -1;
else {
fclose($file2);
$status2 = ($stoptime2 - $starttime2) * 1000;
$status2 = floor($status2);
}
}
$status2 = pingDomain2($serverbase2);
if ($status2 <= 50) $MessageStatus2 = "Great";
elseif ($status2 <= 80) $MessageStatus2 = "Good";
elseif ($status2 <= 100) $MessageStatus2 = "Ok";
elseif ($status2 <= 150) $MessageStatus2 = "Bad";
elseif ($status2 <= 999) $MessageStatus2 = "Poor";
else $MessageStatus2 = "Disconnected";
$upmessage2 = "<font size='1' color='white'><br>Stability: </font><font color='gray'
size='1'>$MessageStatus2</font><br>";
$downmessage2 = "<font size='1' color='white'><br>Stability: </font><font color='gray'
size='1'>Disconnected</font><br>";
$tout = "5";
$server2 = @fsockopen ($server2, $port2, $errno, $errstr, $tout);
if(!$server2){ echo"<br><font color='C8B560' size='2'
style='Arial'><strong>Gameserver</strong></font><br><font size='1' color='white'>Status:</font><font
color='red' size='1' style='Arial'> Off</font>$downmessage2"; }
else { echo"<br><font color='C8B560' size='2' style='Arial'><strong>Gameserver</strong></font><br><font
size='1' color='white'>Status:</font><font color='green' size='1' style='Arial'> On</font>$upmessage2"; }
?>

