Jump to content

Server Status Script


corbin

Recommended Posts

Well, I run a small site which checks the status (online/offline) of several servers (13) and the way i have it working is i have the [a href=\"http://l2status.no-ip.org\" target=\"_blank\"]main site[/a] include a page through an IFRAME which includes 4 other pages through IFRAMES. index.php has an IFRAME to status.php which opens IFRAME's to servers/1.php servers/2.php so on. And then in the servers/X.php pages it includes servers/config.php which is this:

[code]<?
error_reporting(0);
while(list($ServerName,$Host)=each($IP))
{
  list($IPAddress,$Port)=explode(":",$Host);
  if($fp=fsockopen($IPAddress,$Port,$ERROR_NO,$ERROR_STR,(float)0.5))
  {
   $server[$ServerName]="<font color=\"#00ff00\">Online</font>";
   fclose($fp);
  }else{
  if($fp=fsockopen($IPAddress,$Port,$ERROR_NO,$ERROR_STR,(float)0.5))
  {
  $server[$ServerName]="<font color=\"#00ff00\">Online</font>";
   fclose($fp);
  }
  else{
   $server[$ServerName]="<font color=\"#ff0000\">Offline</font>";
   }
  }
}
?>[/code]

and an example servers/X.php file is (i changed the IP addresses):

[code]
<body bgcolor="black"text="#FFFFFF">
<?
error_reporting(0);
$IP = array(
  "ia_login" =>"000.000.000.000:2106",
  "ia_aria"=>"000.000.000.000:7777",
  "ia_victoria" =>"000.000.000.000:7777",
);
fclose($fp);
include("config.php"); ?>
<b>
<div align="center" style="font-size: 12; font: bold;">
Login: <?  echo $server['ia_login']; ?><br>
Aria: <? echo $server['ia_aria']; ?><br>
Victoria <? echo $server['ia_victoria']; ?><br>
<div align="center">
<? fclose($fp); ?>
[/code]

So anyway... my question is... is there a more efficient way to go about doing the same thing?
Link to comment
https://forums.phpfreaks.com/topic/11116-server-status-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.