Jump to content


Photo

Server Status Script


  • Please log in to reply
1 reply to this topic

#1 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 03 June 2006 - 08:41 PM

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:

<?
 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>";
   }
  }
 }
?>

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

<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); ?>

So anyway... my question is... is there a more efficient way to go about doing the same thing?
Why doesn't anyone ever say hi, hey, or whad up world?

#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 03 June 2006 - 08:42 PM

You can use fopen or similar functions to try to reach the various mirros.

If you don't get a response, most likely they are down.

[a href=\"http://www.php.net/fopen\" target=\"_blank\"]http://www.php.net/fopen[/a]
~ D Kuang




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users