Domain availability Checking

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
agriz
Forum Contributor
Posts: 106
Joined: Sun Nov 23, 2008 9:29 pm

Domain availability Checking

Post by agriz »

Hi,

I need a script to check availability of the following domains.
.do
.com.do .edu.do .org.do .art.do .gov.do gob.do .sld.go .web.do .net.do .mil.do
I have a open source script which checks .com, .org, .net...

The script i am using is here
agriz
Forum Contributor
Posts: 106
Joined: Sun Nov 23, 2008 9:29 pm

Re: Domain availability Checking

Post by agriz »

Code: Select all

<?php ini_set('display_errors', 0); ?> 
<?php
error_reporting(0);
$fp = fsockopen("www.agriz.biz", 80, $errno, $errstr, 30);
if (!$fp) {
    echo "Domain Not available";exit;
} else {
    $out = "GET / HTTP/1.1\r\n";
    $out .= "Host: www.example.com\r\n";
    $out .= "Connection: Close\r\n\r\n";
    fwrite($fp, $out);
    while (!feof($fp)) {
        $status .= fgets($fp, 128);
    }
    fclose($fp);
}

if(strpos($status,"HTTP/1.1 200 OK") === false){
	echo "Domain Not available";
}
else{
	echo "Domain Is Available";
}
?>
I wrote this script to check the header status of the domain. If it is "HTTP/1.1 200 OK" I assume the domain is already registered. otherwise it is not registered.

Is this correct idea?
Post Reply