i wrote a simple php script to check whether the website or Ip address is online or offline. All you have to do is specify a website url or ip address and the script will return with ONLINE or OFFLINE. I used php fsockopen() to accomplish this.
/* Usage:
$status = GetServerStatus('http://domain.com',80)
or
$status = GetServerStatus('IPAddress',80)
*/
<?php
function GetServerStatus($site, $port)
{
$status = array("OFFLINE", "ONLINE");
$fp = @fsockopen($site, $port, $errno, $errstr, 2);
if (!$fp) {
return $status[0];
} else
{ return $status[1];}
}
?>
If you want to ping a server to check connectivity, you can use php ping scripts.
Similar Posts:
- Domain with WWW not resolving problem!
- DNS-Test :: Free dns checking tool script!
- Using htaccess to redirect domain without http://
- BSNL Dataone – Common Error Messages & Code Numbers
- Most Popular Open Source PHP Scripts
- PHP – How to get domain name from URL?
- Sample DNS Zone File for BIND
- How to secure your DNS server
- Port 443 – Secure HTTP with SSL (https)
- Perl Net DNS Tutorial for Querying DNS Servers


March 5, 2009
Good script. I would just return true or false though, this way you can use the result however you want (and it’s easier to do so).
March 30, 2009
tnx for script – its just what i was looking for
October 14, 2009
thanx man really helpful
March 21, 2010
Keep in mind, not all web hosts allow fSock to connect directly to their server resulting in OFFLINE even when it is actually ONLINE. But for everyone else, it works well.