View

Domain finder – PHP

  1. //– Class
  2. class whois
  3. {
  4.     const timeout = 30;
  5.     const whoishost = ‘whois.internic.net’;
  6.     public static function lookup($domain){
  7.        $result = “”;
  8.        $errno = 0;
  9.        $errstr=;
  10.        $fd = fsockopen(whois::whoishost,43, $errno, $errstr, whois::timeout);
  11.        if ($fd){
  12.              fputs($fd, $domain.\015\012″);
  13.            while (!feof($fd))    {
  14.             $result .= fgets($fd,128) . “<br />”;
  15.            }
  16.            fclose($fd);
  17.         }
  18.          return $result;
  19.      }
  20. }
  21. //– Example
  22. $domain = ‘search-for.com’;
  23. $result = whois::lookup($domain);
  24. if(strstr($result, “No match”)){
  25.        echo $domain . “seems to be available”;
  26. }else{
  27.     echo $domain . “is in use”;
  28.     //echo “<hr>”;
  29.     //echo $result;
  30. }

You may also like