[PHP] Domain Checker

04/15/2012 09:43 Angellinho#1
It uses the get_headers function to verify the existing headers. Doesn`t matter if it`s or no, if exists menas the domain is registered. If doesn`t exist, the domain is free. Atleast in my vision. =)

PHP Code:
<form action="" method="GET">
                        <label>Domain name (e.g. elitepvpers.com)</label><br /><br />
                        <input type="text" size="30" name="domain" value="<?php echo @$_GET['domain'?>" autofocus />
                        <input type="submit" value="Check" />
                </form>
PHP Code:
<?php
                
if (isset($_GET['domain']) && $_GET['domain'] != '') {
                        
$headers = @get_headers('http://'.$_GET['domain']);
                        
$file = @file_get_contents('http://who.is/whois/'.$_GET['domain'].'/');
                        
$html explode("\n"$file);
                        if (
strlen($headers[0]) > 0) {
                                echo 
'Domain <span style="color:#C00;font-weight:bold">registered</span>.';
                        } else {
                                echo 
'Domain <span style="color:#0C0;font-weight:bold">not registered</span>.';
                                
$file = @file_get_contents('http://who.is/whois/'.$_GET['domain'].'/');
                                if (!
preg_match('/appears to be available/'$file)) {
                                        echo 
'<br />Although who.is says it is.<br />Just check for any HTTP headers. :/';
                                }
                                unset(
$file);
                                unset(
$html);
                        }
                }
        
?>