Codice PHP:
/*******        function to check referer    ************************************************/
function check_referer () {
    global 
$REFERERS$HTTP_REFERER;
    if (
$HTTP_REFERER != "")
        while (list(
$val$ref) = each($REFERERS))
        if (
preg_match("/^http:\/\/$ref/"$HTTP_REFERER))
        return;
        
$layout "<tr>\n<td>\n<font color=\"red\">\nAccess denied to: $HTTP_REFERER</font>\n
\nPlease dont link to this script <a href=\"http://www.topdog-software.com/scripts.php\">download</a> a copy
        and set it up on your site.
\n This is due to bandwidth usage ... leeching and Data mining</td>\n</tr>\n"
;
      
print_results($layout);
      exit;
}
/*******        Function to print the results into your template    ************************/
function print_results($layout)
{
    global 
$template,$registerlink,$domain,$ext,$server;
    if(!
is_file($template)){
        print
"The template file into which to print the results either does not exist or is
        not writeable

        please correct this if you are the webmaster of this site

        The script can not continue exiting......"
;
        exit;
    }
    
$template file ($template);
    
$numtlines count ($template);    //Number of lines in the template
    
$line 0;
    while (! 
stristr ($template[$line], "") && $line $numtlines) {
    echo 
$template[$line];
    
$line++;
    }
    if(
$layout=="0"){
        
$line++;
            print   
"\n<!-----------------\n";
            print    
"\tPOWERED BY\n\n";
            print    
"\tTOPDOG WHOIS & DOMAIN CHECK SCRIPT\n";
            print   
"\t&copy; KISSA ANDREW COLIN\n";
            print    
"\tkissandrew@yahoo.com\n";
            print    
"\twww.topdog-software.com\n";
            print    
"\n------------------->\n";
            print   
"<table width=\"100%\" border=\"0\" cellPadding=2 class=font1l>";
            print   
"<tr><td>[b]Domain query Results for \"$domain.$ext\"[/b]</td></tr>";
            print   
"<tr><td><hr></td></tr>";
            print   
"<tr><td>The domain is available <a href=\"$registerlink?domain=$domain.$ext\">register</a> it now</td></tr>";
            print   
"</table>";
    }
    elseif(
$layout=="1"){
        
$line++;
            print   
"\n<!-----------------\n";
            print    
"\tPOWERED BY\n\n";
            print    
"\tTOPDOG WHOIS & DOMAIN CHECK SCRIPT\n";
            print   
"\t&copy; KISSA ANDREW COLIN\n";
            print    
"\tkissandrew@yahoo.com\n";
            print    
"\twww.topdog-software.com\n";
            print    
"\n------------------->\n";
            print   
"<table width=\"100%\" border=\"0\" cellPadding=2 class=font1l>\n";
            print     
"<tr>\n<td>\n[b]\nDomain query Results for \"$domain.$ext\"[/b]\n
\n</td>\n</tr>\n"
;
            print   
"<tr>\n<td>\n<hr>\n</td>\n</tr>\n";
            print   
"<tr>\n<td>\n[b]\nThe domain is already taken <a href=\"$PHP_SELF?domain=$domain&ext=$ext&option=whois\">Check</a> the whois information
</td></tr>"
;
            print   
"<tr>\n<td>\nCheck another domain name <a href=\"javascript:history.back()\">here</a></td></tr>";
            print   
"</table>\n";
    }
     elseif(
$layout=="2"){
        
$line++;
        print   
"\n<!-----------------\n";
          print    
"\tPOWERED BY\n\n";
          print    
"\tTOPDOG WHOIS & DOMAIN CHECK SCRIPT\n";
          print   
"\t&copy; KISSA ANDREW COLIN\n";
          print    
"\tkissandrew@yahoo.com\n";
          print    
"\twww.topdog-software.com\n";
          print    
"\n------------------->\n";
        print   
"<table width=\"100%\" border=\"0\" cellPadding=2 class=font1l>\n";
        print     
"<tr>\n<td>\n[b]\nDomain query Results for \"$domain.$ext\"[/b]\n
\n</td>\n</tr>\n"
;
        print   
"<tr>\n<td>\n<hr>\n</td>\n</tr>\n";
        print   
"<tr>\n<td>\n[b]Could not contact the whois server $server[/b]\n
\n</td>\n</tr>\n"
;
        print   
"<tr>\n<td>\nCheck another domain name <a href=\"javascript:history.back()\">here</a>\n</td>\n</tr>\n";
        print   
"</table>\n";
    }
    else{
          
$line++;
        print   
"<table width=\"100%\" border=\"0\" cellPadding=2 class=font1l>\n";
        print     
"<tr>\n<td>\n[b]Domain query Results for \"$domain.$ext\"[/b]\n
\n</td>\n</tr>\n"
;
        print   
"<tr>\n<td>\n<hr>\n</td>\n</tr>\n";
        print     
$layout;
        print   
"<tr>\n<td>\nCheck another domain name <a href=\"javascript:history.back()\">here</a>\n</td>\n</tr>\n";
        print   
"</table>\n";
    }
    print 
"
\n
\n"
;
    print 
"<center>\n<font class=font1csm>\nsearch powered by <a href=\"http://www.topdog-software.com/scripts.php\">topdog whois scripts</a>\n</font>\n</center>\n";
    while (
$line $numtlines) {
     echo 
$template[$line];
     
$line++;
   }
}

/*******        Function to print whois results    *****************************************/
function print_whois($output){
    global 
$template,$domain,$ext;
    if(!
is_file($template)){
        print
"The template file into which to print the results either does not exist
        or is not writable

        please correct this if you are the webmaster of this site

        The script can not continue exiting......"
;
        exit;
    }
    
$template file ($template);
    
$numtlines count ($template);
    
$line 0;
    while (! 
stristr ($template[$line], "") && $line $numtlines) {
    echo 
$template[$line];
    
$line++;
    }
    
$line++;
     print   
"\n<!-----------------\n";
     print    
"\tPOWERED BY\n\n";
     print    
"\tTOPDOG WHOIS & DOMAIN CHECK SCRIPT\n";
     print   
"\t&copy; KISSA ANDREW COLIN\n";
     print    
"\tkissandrew@yahoo.com\n";
     print    
"\twww.topdog-software.com\n";
     print    
"\n------------------->\n";
    print   
"<table width=\"100%\" border=\"0\" cellPadding=2 class=font1l>\n";
    print   
"<tr>\n<td>\n[b]\nDomain whois query information for \"$domain.$ext\"[/b]\n</td>\n</tr>\n";
    print   
"<tr>\n<td>\n<hr>\n</td>\n</tr>\n";
    print   
"<tr>\n<td>\n";
    
$outputexplode("\n",$output);
    foreach (
$output as $value){
            print 
"$value
\n"
;
    }
    print 
"</td>\n</tr>\n</table>\n";
    print 
"
"
;
    print 
"<center>\n<font class=font1csm>\nsearch powered by <a href=\"http://www.topdog-software.com/scripts.php\">topdog whois scripts</a>\n</font>\n</center>\n";
    while (
$line $numtlines) {
    echo 
$template[$line];
    
$line++;
   }

}
/******    This checks the name for invaild characters    *******************************/
function namecheck($domain)
{
    if(
$domain==""){$layout "<tr>\n<td>\n<font color=\"red\">\nYou must enter a domain to be checked</font>\n
\n"
;
      
print_results($layout);exit;}
    if(
strlen($domain)< 3){$layout "<tr>\n<td>\n<font color=\"red\">\nThe domain name $domain is too short</font>\n</td>\n</tr>\n"print_results($layout);exit;}
    if(
strlen($domain)>57){$layout "<tr>\n<td>\n<font color=\"red\">\nThe domain name $domain is too long</font>\n</td>\n</tr>\n"print_results($layout);exit;}
    if(@
ereg("^-|-$",$domain)){$layout "<tr>\n<td>\n<font color=\"red\">\nDomains cannot begin or end with a hyphen</font>\n</td>\n</tr>\n"print_results($layout);exit;}
    if(!
ereg("([a-z]|[A-Z]|[0-9]|-){".strlen($domain)."}",$domain))
    {
$layout "<tr>\n<td>\n<font color=\"red\">\nDomain names cannot contain special characters</font>\n</td>\n</tr>\n"print_results($layout);exit;}

}
/*******    Function to check co.za whois via socket connection    *********************/
function cozacheck($domain){
        
$errno 0;
        
$errostr "";
        
$timeout 30;
        
$fp fsockopen("co.za",80,$errno,$errstr,$timeout);
        if(
$fp){
            
socket_set_timeout($fp,$timeout);
            
$url "GET /cgi-bin/whois.sh?Domain=$domain HTTP/1.0\r\n Host: co.za\r\n";
            
$url .= "Connection: Keep-Alive\r\n User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705)\r\n";
            
$url .= "Referer: [url]http://co.za/whois.shtml\r\n[/url] Accept: text/plain, text/html\r\n\r\n";
            
fputs($fp,$url);
            
$output "";
            while(!
feof($fp)){
                
$output .= fgets($fp,128);    
            }
            
fclose($fp);
            
$temp_code strip_tags($output); 
            if(
eregi("Match: One",$temp_code)){
                
//echo "The name is taken";
                
return 1;
            }else{
                
//echo "The name is available";
                
return 0;
            }
        }else{
            
$layout "<tr>\n<td>\nThe script could not connect to the co.za whois server
"
;
            
$layout .= "[b]DEBUG INFO:[/b]

"
;
            
$layout .= "Error No: $errno
Error Description:
$errstr</td>\n</tr>\n";
            
print_results($layout);
            exit;
        }

    }
/********    Function to check co.za whois via curl        ***************************/
    
function cozacurlcheck($domain){
        
$ch curl_init();
        
$url "http://co.za/cgi-bin/whois.sh?Domain=";
        
$url .= $domain;
        
curl_setopt($chCURLOPT_URL$url);
        
curl_setopt($chCURLOPT_FAILONERROR1);
        
curl_setopt($chCURLOPT_USERAGENT"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705)");
        
curl_setopt($chCURLOPT_FOLLOWLOCATION0);
        
curl_setopt($chCURLOPT_TIMEOUT4);
        
curl_setopt($chCURLOPT_REFERER"http://co.za/whois.shtml"); 
        
curl_setopt($chCURLOPT_RETURNTRANSFER1);
        
$data curl_exec($ch);
        if(
curl_error($ch) == ""){
            
curl_close($ch); 
            
$temp_code strip_tags($data);
            if(
eregi("Match: One",$temp_code)){
                
//echo "The name is taken";
                
return 1;
            }else{
                
//echo "The name is available";
                
return 0;
            }
        }else{
            
curl_close($ch);
            
$layout "<tr>\n<td>\nAn Error Occured in connecting to the whois server</td>\n</tr>\n";
            
print_results($layout);
            exit;
        }
    }
/**********        function to return whois record via socket    ***********************/
    
function cozawhois($domain){
        
$errno 0;
        
$errostr "";
        
$timeout 30;
        
$fp fsockopen("co.za",80,$errno,$errstr,$timeout);
        if(
$fp){
            
socket_set_timeout($fp,$timeout);
            
$url "GET /cgi-bin/whois.sh?Domain=$domain HTTP/1.0\r\n Host: co.za\r\n";
            
$url .= "Connection: Keep-Alive\r\n User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705)\r\n";
            
$url .= "Referer: [url]http://co.za/whois.shtml\r\n[/url] Accept: text/plain, text/html\r\n\r\n";
            
fputs($fp,$url);
            
$output "";
            while(!
feof($fp)){
                
$output .= fgets($fp,128);    
            }
            
fclose($fp);
            
$temp_code strip_tags($output);
            
$startp strpos($temp_code,"The CO.ZA simple whois server");
            
$dis substr($temp_code,$startp);
            
print_whois($dis);
        }else{
            
$layout "<tr>\n<td>\nThe script could not connect to the co.za whois server
"
;
            
$layout.= "[b]DEBUG INFO:[/b]

"
;
            
$layout.= "Error No: $errno
Error Description:
$errstr</td>\n</tr>\n";
            
print_results($layout);
            exit;
        }
    }
/**********        function to return whois record via curl        **********************/
    
function cozacurlwhois($domain){
        
$ch curl_init();
        
$url "http://co.za/cgi-bin/whois.sh?Domain=";
        
$url .= $domain;
        
curl_setopt($chCURLOPT_URL$url);
        
curl_setopt($chCURLOPT_FAILONERROR1);
        
curl_setopt($chCURLOPT_USERAGENT"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705)");
        
curl_setopt($chCURLOPT_FOLLOWLOCATION0);
        
curl_setopt($chCURLOPT_TIMEOUT4);
        
curl_setopt($chCURLOPT_REFERER"http://co.za/whois.shtml"); 
        
curl_setopt($chCURLOPT_RETURNTRANSFER1);
        
$data curl_exec($ch);
        if(
curl_error($ch) == ""){
            
curl_close($ch); 
            
$temp_code strip_tags($data);
            
$startp strpos($temp_code,"The CO.ZA simple whois server");
            
$dis substr($temp_code,$startp);
            
print_whois($dis);
        }else{
            
curl_close($ch);
            
$layout "<tr>\n<td>\nAn Error Occured in connecting to the whois         server</td>\n</tr>\n";
            
print_results($layout);
            exit;
        }

    }
/***<--------------------------------end functions------------------------------------>***/ 
un altra cosa che non capisco e: perche TANTI programmatori non usano i tag di chiusura del php?