FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


[HOW TO...] Server Staus Script





gidevelop
Below is a script that shows you the status of a domain. Al you need is 4 files.

status.php

Code:

<?php
$live = "http://www.your-domain.com/status/live.gif";
$dead = "http://www.your-domain.com/status/dead.gif";

$link = $_GET['link'].":";
$s_link = str_replace("::", ":", $link);
list($addr,$port)= explode (':',"$s_link");
if (empty($port)){
   $port = 80;
}
$churl = @fsockopen(server($addr), $port, $errno, $errstr, 20);
             if (!$churl){
          //echo $errstr;
                header("Location: $dead");
                }
             else {
                  header("Location: $live");             
        }
function server($addr){
         if(strstr($addr,"/")){$addr = substr($addr, 0, strpos($addr, "/"));}
         return $addr;
}
?>



test.html

Code:

<html>
<head>
<title>Server Status Script</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<table border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="77%"><font face="Arial, Helvetica, sans-serif" size="2">GIDevelop</font></td>
    <td width="23%"><img src="status.php?link=www.gidevelop.frih.net" width="37" height="20"></td>
  </tr>
</table>
</body>
</html>




EXTRAFILES
Check google Images for a live image and dead image. Images must have 32x32.

USAGE

1) In status.php adjust line 2 and 3 to match your needs
2) In test.html modify <img src="status.php?link=www.gidevelop.frih.net" width="37" height="20"> to mach your needs
3) In test.html you must add
Code:

<tr>
    <td width="77%"><font face="Arial, Helvetica, sans-serif" size="2">GIDevelop</font></td>
    <td width="23%"><img src="status.php?link=www.gidevelop.frih.net" width="37" height="20"></td>
  </tr>


for every server you want to watch.

WARNING !!!

You must have CURL Lib enabled !!!

Hope you like it!
phpc0d3r
It's a good idea, the only problem is if you host the script on your site, then when your servers down the script doesn't work. Although if you have another php account on a different host, this would work marvelously.
Diablosblizz
This should be under tutorials, not here.
gidevelop
Diablosblizz wrote:
This should be under tutorials, not here.


If u're an admin of frihosy please check AWIT - 1174. I have talk with tidruG and he said that is ok to post in here because tuts dont give points.
Diablosblizz
Okay, I was unaware that you talked with a staff from Frihost. Please accept my apologize.
mahirharoon
gidevelop wrote:
Below is a script that shows you the status of a domain. Al you need is 4 files.

status.php

Code:

<?php
$live = "http://www.your-domain.com/status/live.gif";
$dead = "http://www.your-domain.com/status/dead.gif";

$link = $_GET['link'].":";
$s_link = str_replace("::", ":", $link);
list($addr,$port)= explode (':',"$s_link");
if (empty($port)){
   $port = 80;
}
$churl = @fsockopen(server($addr), $port, $errno, $errstr, 20);
             if (!$churl){
          //echo $errstr;
                header("Location: $dead");
                }
             else {
                  header("Location: $live");             
        }
function server($addr){
         if(strstr($addr,"/")){$addr = substr($addr, 0, strpos($addr, "/"));}
         return $addr;
}
?>



test.html

Code:

<html>
<head>
<title>Server Status Script</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<table border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="77%"><font face="Arial, Helvetica, sans-serif" size="2">GIDevelop</font></td>
    <td width="23%"><img src="status.php?link=www.gidevelop.frih.net" width="37" height="20"></td>
  </tr>
</table>
</body>
</html>




EXTRAFILES
Check google Images for a live image and dead image. Images must have 32x32.

USAGE

1) In status.php adjust line 2 and 3 to match your needs
2) In test.html modify <img src="status.php?link=www.gidevelop.frih.net" width="37" height="20"> to mach your needs
3) In test.html you must add
Code:

<tr>
    <td width="77%"><font face="Arial, Helvetica, sans-serif" size="2">GIDevelop</font></td>
    <td width="23%"><img src="status.php?link=www.gidevelop.frih.net" width="37" height="20"></td>
  </tr>


for every server you want to watch.

WARNING !!!

You must have CURL Lib enabled !!!

Hope you like it!

when i checked it
curl is not initializing here!
curl should initialize
gidevelop
OOoops . Your right no curl here. i am working on a new version witch tests the FTP and Mail servers on a domain. that version uses CURL Lib. Bye!!
Related topics
Which script language do you like most?
how u get perfaction in php and myqsl programing
Php script Cod server stats
Secure Login on the first page without https://
HTML
form submit
do you know is it possoible to hide view source menu?
Who uses Perl instead of PHP?
The 5 Golden Rules of Professional Design
Poll in html
Server status script
Building Web Forms In Flash
How about adding server load to the server status script?
Mysql Down on Server 4
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.