domain name availability

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
haan
Forum Newbie
Posts: 4
Joined: Thu Sep 03, 2009 2:19 am

domain name availability

Post by haan »

hi...
im looking for domain checker code for malaysian .com.my domain name..any one have the coding?

I have problem at this line--> '.com.my' => array('whois.mynic.my','No match for')
When check for XXXxxx.com.my, the result will return is taken, although the domain name still available.

Below is my code, thanks lot...

Code: Select all

<?
error_reporting(0);
set_time_limit(0);
ob_start();
 
$ext = array(
   '.com'       => array('whois.crsnic.net','No match for'),
   '.net'       => array('whois.crsnic.net','No match for'),   
   '.biz'       => array('whois.biz','Not found'),
   '.mobi'      => array('whois.dotmobiregistry.net', 'NOT FOUND'),
   '.tv'       => array('whois.nic.tv', 'No match for'),
   '.in'       => array('whois.inregistry.net', 'NOT FOUND'),
   '.info'    => array('whois.afilias.net','NOT FOUND'),   
   [color=#BF0000]'.com.my'    => array('whois.mynic.my','No match for'),   [/color]
   '.co.uk'    => array('whois.nic.uk','No match'),      
   '.co.ug'    => array('wawa.eahd.or.ug','No entries found'),   
   '.or.ug'    => array('wawa.eahd.or.ug','No entries found'),
   '.nl'       => array('whois.domain-registry.nl','not a registered domain'),
   '.ro'       => array('whois.rotld.ro','No entries found for the selected'),
   '.com.au'   => array('whois.ausregistry.net.au','No data Found'),
   '.ca'       => array('whois.cira.ca', 'AVAIL'),
   '.org.uk'   => array('whois.nic.uk','No match'),
   '.name'    => array('whois.nic.name','No match'),
   '.us'       => array('whois.nic.us','Not Found'),
   '.ac.ug'    => array('wawa.eahd.or.ug','No entries found'),
   '.ne.ug'    => array('wawa.eahd.or.ug','No entries found'),
   '.sc.ug'    => array('wawa.eahd.or.ug','No entries found'),
   '.ws'      => array('whois.website.ws','No Match'),
   '.be'       => array('whois.ripe.net','No entries'),
   '.com.cn'    => array('whois.cnnic.cn','no matching record'),
   '.net.cn'    => array('whois.cnnic.cn','no matching record'),
   '.org.cn'    => array('whois.cnnic.cn','no matching record'),
   '.no'      => array('whois.norid.no','no matches'),
   '.se'       => array('whois.nic-se.se','No data found'),
   '.nu'       => array('whois.nic.nu','NO MATCH for'),
   '.com.tw'    => array('whois.twnic.net','No such Domain Name'),
   '.net.tw'    => array('whois.twnic.net','No such Domain Name'),
   '.org.tw'    => array('whois.twnic.net','No such Domain Name'),
   '.cc'       => array('whois.nic.cc','No match'),
   '.nl'       => array('whois.domain-registry.nl','is free'),
   '.pl'       => array('whois.dns.pl','No information about'),
   '.pt'       => array('whois.dns.pt','No match')
);
function return_status($domain, $status)
{   
   global $extension;
   $domain = trim($domain);
   $wt = ($status == 'available') ? 'bold' : 'normal';
    $color = ($status == 'available') ? 'green' : 'red';
     $decoration = ($status == 'invalid'     && $extension == 'org') ? 'underline' : 'none';
   if($status == 'invalid' && $extension == 'org') { $status .= ' (.org WHOIS prevents request)'; }   
      
  echo "<div style=    \"font-weight:$weight;color:$color;      text-decoration:$decoration\">      $domain is $status!</div>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Domain Name Availability Checker</title>
</head>
<body>
<table width="500" border="0" align="center" cellpadding="1" cellspacing="1">
   <tr>
     <td colspan="2" align="center"><h3>Domain Name Availability Checker</h3>     
       <form action="" method="post" name="frmsearchposition" class="frmstyle" id="frmsearchposition">
         <table width="80%"   border="0" cellspacing="1" cellpadding="1">
           
            <tr align="left">
              <td width="33%" align="left" valign="middle">Enter Domains -<br />
(Ex: google.com) </td>
               <td width="2%" align="left" valign="top">:</td>
               <td width="48%" valign="top"><input name="domains" type="text" class="frmelements_ta" id="domains"><?=$sUrl?>
</textarea></td>
               <td width="17%" valign="top"><input type="submit" name="Submit" value="Check" /></td>
            </tr>
         </table>
     </form></td>
   </tr>
   <tr>
     <td width="40%" align="center">&nbsp;</td>
      <td width="60%" valign="top"><?
                     if(strlen($_POST['domains']) > 0)
                     {
                        $domains = explode("\n", $_POST['domains']);
                        
                        echo (isset($_POST['save'])) ? 'Processing results, Please wait...<br /><br />' : null;
                        
                        foreach($domains as $domain)
                        {
                           unset($buffer);
                           preg_match('@^(http://www\.|http://|www\.)?([^/]+)@i', $domain, $matches);
                           $domain = $matches[2];
                           
                           $tld = explode('.', $domain, 2);
                           $extension = strtolower(trim($tld[1]));
                           
                           if(strlen($domain) > 0 && array_key_exists('.' . $extension, $ext))
                           {
                              $server = $ext['.' .$extension][0];
                              
                              $sock = fsockopen($server, 43) or die('Error Connecting To Server:' . $server);
                              fputs($sock, "$domain\r\n");
                              
                              while( !feof($sock) )
                              {
                                 $buffer .= fgets($sock,128);
                              }
                           
                              fclose($sock);
                              if($extension == 'org') echo nl2br($buffer);
                              
                              if(eregi($ext['.' . $extension][1], $buffer)) { return_status($domain, 'available'); }
                              
                              else { return_status($domain, 'taken'); }
                           }
                           else
                           {
                              if(strlen($domain) > 0)    { return_status($domain, 'invalid'); }
                           }
                        
                           ob_flush();
                           flush();
                           sleep(0.1);
                        }
                        
                     }
                     else
                     {
                        echo 'Please enter one or more domains!';
                     }
                     ?>
         <table width="100%" border="0" align="center" cellpadding="1" cellspacing="1">
            <tr>
               <td align="left" class="tbl_texttd"></td>
            </tr>
         </table>
      </td>
   </tr>
</table>
</body>
</html>
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: domain name availability

Post by John Cartwright »

Duplicate. Locked.
Locked