Web Development Network  |  Sites:    Webmaster Resouces    Capital Tutorials    Arcade Games
Depiction- Webmaster Resources
Stock Image


Contributors: Flash Tutorials  |  Free Flash Tutorials  |  Monster Banner Exchange  |  Candles

Online Casino Bonus  |  Debt Consolidation  |  Best Web Hosting |  Search Engine Optimization

Misc Links: Submit Tutorials l Advertising l Site Map

Tutorials > PHP > Site Status

 

Track all server ports to see if they are working properly.


This code snippet, which web hosts may find very useful, can easily track all server ports and display whether they are working properly.

Code:
------------------------------------------------------------------------
<?

function lookup_ports($hport,$who)
{
$fp = fsockopen($who, $hport,$errno,$errstr, 4);
if (!$fp){
$data = "<font color=red>".Failed."</font>";
} else {
$data = "<font color=green>".OK."</font>";
fclose($fp);
}
return $data;
}
$domain = ($domain) ? strip_tags($domain) : str_replace("www.","",$HTTP_SERVER_VARS["HTTP_HOST"]) ;
echo "<li><b>".DOMAIN.":</b> $domain</li>";

echo "<li><b>HTTP:</b> <i>".PORT." 80 = <b>".lookup_ports("80",$domain)."</b></i></li>";

echo "<li><b>HTTPS:</b> <i>".PORT." 443 = <b>".lookup_ports("443",$domain)."</b></i></li>";

echo "<li><b>FTP:</b> <i>".PORT." 21 = <b>".lookup_ports("21",$domain)."</b></i></li>";

echo "<li><b>SSH:</b> <i>".PORT." 22 = <b>".lookup_ports("22",$domain)."</b></i></li>";

echo "<li><b>SMTP:</b> <i>".PORT." 25 = <b>".lookup_ports("25",$domain)."</b></i></li>";

echo "<li><b>POP:</b> <i>".PORT." 110 = <b>".lookup_ports("110",$domain)."</b></i></li>";

echo "<li><b>MySQL:</b> <i>".PORT." 3306 = <b>".lookup_ports("3306",$domain)."</b></i></li>";
?>
------------------------------------------------------------------------

This script pulls the domain name that it is currently on and uses that in the check, there is no need to declare a domain name unless you would prefer it that way.

Change

$domain = ($domain) ? strip_tags($domain) : str_replace("www.","",$HTTP_SERVER_VARS["HTTP_HOST"]) ;

to

$domain = 'yourdomain.com';

In Action:


 
Tutorial Submitted by: Solan

 
 

Affiliates

Visual Design Core FotoFects
Tutorial Man Wallpaper Stock  More

Resources


Fluid Mask