home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / src / PHP / whois.php3.txt < prev   
Encoding:
Text File  |  2002-05-06  |  2.3 KB  |  67 lines

  1. whois.php3 
  2.  
  3. Recent changes in the way Internic handles domain registration data has rendered the old whois program hard to use, so I cobbed together this PHP substitute that fetches registry info from Internic, then goes directly to the registry to get the details. This works for .com, .net, .org; country-specific registries are not supported. 
  4.  
  5.  
  6. <?PHP
  7. if ($domain)
  8. {
  9. if ($domain)
  10.         {
  11.         // first get the domain server from internic
  12.  
  13.         $fp = fsockopen("rs.internic.net", 43, &$errno, &$errstr, 10);
  14.         if (!$fp) 
  15.     {
  16.         echo "$errstr ($errno)<br>\n";
  17.         }
  18.         else
  19.         {
  20.         fputs($fp,"$domain\r\n");
  21.         while(!feof($fp))
  22.                 {
  23.                 $buf = fgets($fp,128);
  24.                 if (ereg("Whois Server:", $buf))
  25.                         {
  26.                         $server = str_replace("Whois Server: ", "", $buf);
  27.                         $server = trim($server);
  28.                         }
  29.                 }
  30.         fclose($fp);
  31.         }
  32.         if ($server)
  33.                 {
  34.                 echo "<B>$domain is registered at $server:</B><BR>";
  35.                 echo "<PRE>";
  36.                 $fp = fsockopen($server, 43, &$errno, &$errstr, 10);
  37.                 if(!$fp)
  38.                         {
  39.                         echo "Could not open connection to $server on port 43.\n";
  40.                         echo "$errstr ($errno)<br>\n";
  41.                         }
  42.                 else
  43.                         {
  44.                         fputs($fp,"$domain\r\n");
  45.                         while(!feof($fp))
  46.                                 {
  47.                                 echo fgets($fp,128);
  48.                                 }
  49.                         fclose($fp);
  50.                         }
  51.                 }
  52.         else    {
  53.                 echo("<b>$domain does not appear to be registered.</b><BR>");
  54.                 }
  55.         echo ("</PRE><BR>");
  56.         }
  57.  
  58. }
  59. ?>
  60. <FORM ACTION="<?PHP echo($PHP_SELF); ?>" METHOD="post">
  61.   This will find .com, .org, and .net domains<br>
  62.   domain: <INPUT TYPE="text" NAME="domain" SIZE="40" MAXLENGTH="100">
  63.   <INPUT TYPE=submit VALUE="Find out"><INPUT TYPE=reset VALUE="Reset">
  64. </FORM>
  65.                                                                                           
  66.  
  67.