Verifying a Domain URL

This sections will contains code regarding different PHP & MySQL features and contains help about php/mysql issues.

Verifying a Domain URL

Postby Shahzad Butt on July 24th, 2008, 5:08 am

The below php code enables you to verify that a domain is LIVE or not with the help of fsockopen() php function. The fsockopen() function actually tries to connect a socket to the listed site. The first parameter listed "www.geosourcecode.com" would be the URL of the website you want to check. It is important that you do not put http:// in front of the URL or else the script does not work. The second parameter, 80, would be the port, which should just be left alone. The next two parameters are just standard PHP errors, and the last one, 30, is the amount of time to wait in seconds before assuming its a timeout. The next few lines checks to see if the connection went through and if it did then put the link up. Again, an easy and useful script.

Code: Select all
<?
$up = @fsockopen("www.geosourcecode.com", 80, $errno, $errstr, 30); 
if($up)

   echo "<a href=\"http://www.geosourcecode.com\">LIVE</a>"; 
}
else
{
   echo "<a href=\"http://www.geosourcecode.com\">Broken</a>";
}
?>
Regards
Shahzad Butt
http://www.GeoSourceCode.com
Shahzad Butt
 
Posts: 19
Joined: July 9th, 2008, 11:16 am
Location: Pakistan

Return to PHP / MySQL / XML

Who is online

Users browsing this forum: No registered users and 0 guests

cron