Zend - The PHP Company




Utilities

Add Code


ShWhois  

Type: code fragment
Added by: vahabzadeh
Entered: 22/08/2006
Last modified: 31/10/2005
Rating: - (fewer than 3 votes)
Views: 2579
A Power Full Whois Script By "Shahab Vahabzadeh" With Error Handeling! You Are Able to Add Multi Servers to Its Code


<?php
// This Script Developed By "Shahab Vahabzadeh" (Vahabzadeh_sh@Yahoo.com)
// Contact Me With Email : Vahabzadeh_sh@Yahoo.com
$status="";
//submit
if(isset($_POST['Submit'])){
$domain=$_POST['domain'];
$ext=$_POST['ext'];
$whoisServer="";
switch(
$ext){
case 
".com":
case 
".net":
case 
".edu":
$whoisServer="whois.internic.net";
break;
case 
".org":
$whoisServer="whois.publicinterestregistry.net";
break;
case 
".biz":
$whoisServer="whois.neulevel.biz";
break;
case 
".info":
$whoisServer="whois.afilias.info";
break;
case 
".ir":
case 
".id.ir":
case 
".co.ir":
case 
".net.ir":
$whoisServer="whois.nic.ir";
break;
//insert new whois servers here
default: 
$whoisServer"whois.networksolutions.com"
}
//domian name is valid
if(namecheck($domain)){
    if((
$output=dolookup($domain.$ext$whoisServer))){
    
        if(!(
$data=check_exist($output))){
            
$status="<font color=red dir=rtl>This Domain is FREE</font>";
                      
        }else{
            
$status="<font color=red dir=rtl>This Domain Has Been Registered</font> <br> {$data}";
        }
    }

}
}
//functions
//This checks the name for invaild characters
function namecheck($domain)
{
    if(
$domain==""){echo"Domain Field is Empty<br>n";
    echo
"Click <a href="javascript:history.back()">here</a> to go back"; return false;}
    if(
strlen($domain)< 3){echo"The domain name  <b>$domain</b>  is too short"; return false;}
    if(
strlen($domain)>57){echo"The domain name  <b>$domain </b>  is too long"; return false;}
    if(@
ereg("^-|-$",$domain)){echo"Domains cannot begin or end with a hypen"; return false;}
    if(!
ereg("([a-z]|[A-Z]|[0-9]|-){".strlen($domain)."}",$domain))
    {echo
"Domain names cannot contain special characters"; return false;}
    return 
true;

}
//
function check_exist($output)
{
    
//compare what has been returned by the server
    
if (eregi("Can't get information",$output) || eregi("No entries found",$output) || eregi("NOT FOUND",$output) || eregi("No match",$output) ){
        return 
0;
    }else{
        return 
nl2br($output);
    }
}
//
    
function dolookup($domain$server){
        
$domain strtolower($domain);
        
$server strtolower($server);
        if( 
$domain == '' || $server == '' ) return false;
        
$data "";
        
$fp = @fsockopen($server43,$errno$errstr5);
        if( 
$fp ){
            @
fputs($fp$domain."rn");
            @
socket_set_timeout($fp30);
            while( !@
feof($fp) ){
                
$data .= @fread($fp4096);
            }
            @
fclose($fp);
            return 
$data;
        }else{
            echo 
"nError - could not open a connection to <b>$server</b>nn";
            return 
0;
        }
    }
?>


Usage Example




Rate This Script





Search



This Category All Categories