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


Contributors: SSD VPS in Europe  |  SEO Las Vegas |  Best Las Vegas SEO Company

Park Shore Condos  |  Top Rated Binary Option Robots Advertise Here

Misc Links: Submit Tutorials (Earn $$) l Advertising l Privacy Policy | 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:


Notice: Undefined variable: domain in /home/depicaac/public_html/tutorials/php/sitestatus.php on line 134

Notice: Undefined index: HTTP_HOST in /home/depicaac/public_html/tutorials/php/sitestatus.php on line 134

Notice: Use of undefined constant DOMAIN - assumed 'DOMAIN' in /home/depicaac/public_html/tutorials/php/sitestatus.php on line 135


 
Tutorial Submitted by: Solan

 
 

Affiliates

PictureCorrect Photoshop Tutorials
Tutorial Man Wallpaper Stock  More

Resources