• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 788
  • Last Modified:

PHP Whois Script au Problem

Hi,

I obtained a whois script to check from domain availability from here: www.soaptray.com

The script works perfectly well, except for .au domains. They always give me the result as "Not Available"

I have tried changing the server settings but to no effect. Does anyone have any ideas on how to fix this?


<?PHP
	//----------------------------------------------------------------
	// 	PHP FORM
	//----------------------------------------------------------------	
 
		if (empty($user_domain)){
			$domain_error = "Domain Name Cannot Be empty";
		} else {
		
			if (eregi('^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)*[a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?$',$user_domain) != 1){			
				$domain_error = 'Invalid domain (Letters, numbers and hyphens only): "'.$user_domain.'"';			
			} else {		
		
				//no errors, perform search
	
				//$domain = 'enterit';
				
				$whois = new whois;
				$result = $whois->available($user_domain);
			
			}
		
		}
?>
 
<?PHP
 
	//----------------------------------------------------------------
	// 	WHOIS LOOKUP CLASS
	//----------------------------------------------------------------	
	
	class whois {
	
		public $ext = array(
			'.com.au' => array('whois.ausregistry.com.au','No data Found'),
			'.net.au' => array('whois.ausregistry.com.au','No data Found'),
			'.com' => array('whois.crsnic.net','No match for'),
			'.net' => array('whois.crsnic.net','No match for'),	  
			'.org' => array('whois.publicinterestregistry.net','NOT FOUND'),	
			
			'.biz' => array('whois.biz','Not found'),
			'.info' => array('whois.afilias.net','NOT FOUND'),	
			'.mobi' => array('whois.dotmobiregistry.net', 'NOT FOUND'),
			'.tel' => array('whois.nic.tel','No match'),
			'.tv' => array('whois.nic.tv', 'No match for'),
			'.in' => array('whois.inregistry.net', 'NOT FOUND'),
			'.us' => array('whois.nic.us','Not Found'),
			'.name' => array('whois.nic.name','No match'),
			);
		
		public $error;
 
		function available($domain){
		
			$avail_domains = $taken_domains = "";
		
		
			$domain = trim($domain);
			
			//check for extention (probably want to remove this)
			preg_match('@^(http://www\.|http://|www\.)?([^/]+)@i', $domain, $preg_metch_result);
			$f_result = '';
			$domain = $preg_metch_result[2];
			$domain_name_array = explode('.', $domain);
			$domain_domain = strtolower(trim($domain_name_array[count($domain_name_array)-1]));
			
			$ext_in_list = false;			
			if (array_key_exists('.'.$domain_domain, $this->ext)){
				$ext_in_list = true;
			}
			
			if(strlen($domain) > 0){		
				//echo count($this->ext) . " item in array<br /><br />";
				
				foreach ($this->ext as $key => $value){
	
					$server = '';
					$server = $this->ext[$key][0];	
					
					echo $domain.$key;
					
					$lookup_result = gethostbyname($server);
					
					/*
					if ($lookup_result == $server){
						$error = 'Error: Invalid extension - '.$key.'. / server has outgoing connections blocked to '.$server.'.';
						//return false;
						
						echo "<span style='color:#FF0000'>$error</span><br />";
					}*/		
					
					$fs = fsockopen($server, 43,$errno,$errstr,10);		
					
					/*
					if (!$fs || ($errstr != "")){
						$error = 'Error: ('.$server.') '.$errstr.' ('.$errno.')';
						//return false;
						echo "<span style='color:#FF0000'>$error</span><br />";
					}*/
					
					fputs($fs, "$domain\r\n");
					while( !feof($fs) ) {
						$f_result .= fgets($fs,128);
					}
					
					fclose($fs);				
						
					if($domain_domain == 'org'){
						nl2br($f_result);
					}
					
					if(eregi($this->ext[$key][1], $f_result)){
						//return true;
						
						echo "<span style='color:#00FF00'>AVAILABLE</span><br />";
						
					} else {
						//return false;
						
						echo "<span style='color:#FF0000'>NOT AVAILABLE</span><br />";
					}
								
				}
			}
		}
	}
?>

Open in new window

0
jset_expert
Asked:
jset_expert
1 Solution
 
jset_expertAuthor Commented:
Hi, the problem here is not the .au extention.

I actually have the same problem for ALL 2nd level domain names. e.g. .co.uk also does not work.

Should I be connecting to the whois server differently?

Any help is much appreciated
0
 
basic612Commented:
Your script works fine for me, except in testing it out I soon blacklisted my IP address for excessive lookups:

Debug $f_result

BLACKLISTED: You have exceeded the query limit for your network or IP address and have been blacklisted.

Could this be the problem you are seeing? My test code (which produced valid lookups for a short while) is below:
<?PHP
        //----------------------------------------------------------------
        //      PHP FORM
        //----------------------------------------------------------------      
 
$user_domain = 'lookthisup';
                if (empty($user_domain)){
                        $domain_error = "Domain Name Cannot Be empty";
                } else {
                
                        if (eregi('^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)*[a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?$',$user_domain) != 1){                        
                                $domain_error = 'Invalid domain (Letters, numbers and hyphens only): "'.$user_domain.'"';                       
                        } else {                
                
                                //no errors, perform search
        
                                //$domain = 'enterit';
                                
                                $whois = new whois;
                                $result = $whois->available($user_domain);
                        
                        }
                
                }
?>
 
<?PHP
 
        //----------------------------------------------------------------
        //      WHOIS LOOKUP CLASS
        //----------------------------------------------------------------      
        
        class whois {
        
                public $ext = array(
                        '.com.au' => array('whois.ausregistry.com.au','No data Found'),
                        '.net.au' => array('whois.ausregistry.com.au','No data Found'),
                        '.com' => array('whois.crsnic.net','No match for'),
                        '.net' => array('whois.crsnic.net','No match for'),       
                        '.org' => array('whois.publicinterestregistry.net','NOT FOUND'),        
                        
                        '.biz' => array('whois.biz','Not found'),
                        '.info' => array('whois.afilias.net','NOT FOUND'),      
                        '.mobi' => array('whois.dotmobiregistry.net', 'NOT FOUND'),
                        '.tel' => array('whois.nic.tel','No match'),
                        '.tv' => array('whois.nic.tv', 'No match for'),
                        '.in' => array('whois.inregistry.net', 'NOT FOUND'),
                        '.us' => array('whois.nic.us','Not Found'),
                        '.name' => array('whois.nic.name','No match'),
                        );
                
                public $error;
 
                function available($domain){
                
                        $avail_domains = $taken_domains = "";
                
                
                        $domain = trim($domain);
                        
                        //check for extention (probably want to remove this)
                        preg_match('@^(http://www\.|http://|www\.)?([^/]+)@i', $domain, $preg_metch_result);
                        $f_result = '';
                        $domain = $preg_metch_result[2];
                        $domain_name_array = explode('.', $domain);
                        $domain_domain = strtolower(trim($domain_name_array[count($domain_name_array)-1]));
                        
                        $ext_in_list = false;                   
                        if (array_key_exists('.'.$domain_domain, $this->ext)){
                                $ext_in_list = true;
                        }
                        
                        if(strlen($domain) > 0){                
                                //echo count($this->ext) . " item in array<br /><br />";
                                
                                foreach ($this->ext as $key => $value){
        
                                        $server = '';
                                        $server = $this->ext[$key][0];  
                                        
                                        echo $domain.$key;
                                        
                                        $lookup_result = gethostbyname($server);
                                        
                                        /*
                                        if ($lookup_result == $server){
                                                $error = 'Error: Invalid extension - '.$key.'. / server has outgoing connections blocked to '.$server.'.';
                                                //return false;
                                                
                                                echo "<span style='color:#FF0000'>$error</span><br />";
                                        }*/             
                                        
                                        $fs = fsockopen($server, 43,$errno,$errstr,10);         
                                        
                                        /*
                                        if (!$fs || ($errstr != "")){
                                                $error = 'Error: ('.$server.') '.$errstr.' ('.$errno.')';
                                                //return false;
                                                echo "<span style='color:#FF0000'>$error</span><br />";
                                        }*/
                                        
                                        fputs($fs, "$domain\r\n");
                                        while( !feof($fs) ) {
                                                $f_result .= fgets($fs,128);
                                        }
                                        
                                        fclose($fs);                            
                                                
                                        if($domain_domain == 'org'){
                                                nl2br($f_result);
                                        }
                                        
                                        if(eregi($this->ext[$key][1], $f_result)){
                                                //return true;
                                        	
                                                echo "<span style='color:#00FF00'>AVAILABLE</span><br />";
                                                
                                        } else {
                                                //return false;
                                                // Debug $f_result
                                                echo '<hr noshade /><strong>Debug $f_result</strong><pre>'.print_r($f_result,true)."</pre><hr noshade />\n";
                                                
                                                
                                                echo "<span style='color:#FF0000'>NOT AVAILABLE</span><br />";
                                        }
                                                                
                                }
                        }
                }
        }
?>

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now