jset_expert
asked on
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?
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 />";
}
}
}
}
}
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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