Need to get registrar and expiry of $domain - PAID

SpaceshipSpaceship
Watch

bobby9101

VIP Member
Impact
33
Hi, if I could provide a list of whois servers, could anyone tell me how to get the registrar and expiry date of a variable $domani.
Please tell me how much you would charge.
I would be integrating this into and existing script, so it would need to be small.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
every whois server is different...

here is a basic script for you, but you will have to go through and change it to suit your needs... I think it should all pretty much work:
PHP:
<?php
  include "tlds.php"; // you need to put all the tlds and servers in here...

  //lets explode the domain...
  // incase they put http:// infront of it...
  if(substr($domain,0,7) == "http://"){
    $q = substr($domain,7);
  }
  // incase there is still/oringinally was www. in front of it...
  if(substr($q,0,4) == "www."){
    $q = substr($q,4);
  }
  $newq = $q.".end";
  $bits = explode(".",$newq);
  $w = count($bits);

  if($w == 4){
    // we have 4 bits in the domain
    // domain.xx.xx.end
    // therefore:
    $thetld = $bits['1'].".".$bits['2']; // eg: co.uk (domain = 0, co = 1, uk = 2, end = 3)
    if(!isset($tlds[$thetld])){
      // thetld = co.uk
      $bits = explode(".",$thetld);
      // 0 = co, 1 = uk
      $thetld = $bits['1'];
    }
  }
  elseif($w == 3){
    // we have 3 bits in the domain
    // domain.xxx.end
    // therefore:
    $thetld = $bits['1']; // eg: com (domain = 0, com = 1, end = 2)
  }
  else{
    // there must be something wrong...
	echo "Domain is wrong format...";
  }
  
  if(!isset($tlds[$thetld])&&!isset($message)){
      echo "TLD not recognised";
  }

  if(isset($thetld) && isset($tlds[$thetld])){
    $xserver = $tlds[$thetld];
    $xdomain = $q;
    $result = ""; // empty the $result var
    $sock = fsockopen($xserver,43) or die("Error Connecting To Whois Server"); // connect to server

    fputs($sock,"$xdomain\r\n");

    while(!feof($sock)){
        $result .= fgets($sock,1024);
    }

    fclose($sock);

    if(eregi("Whois Server: ",$result)){
      preg_match("/Whois Server: (.*)<br \/>/", nl2br($result), $matches);
      $new_server = substr($matches[0], strlen("Whois Server: "), strlen($matches[0])-(strlen("<br />")+strlen("Whois Server: ")));
      $xserver = $new_server;
      $xdomain = $q;
      $result = ""; // empty the $result var
      $sock = fsockopen($xserver,43) or die("Error Connecting To Whois Server"); // connect to server

      fputs($sock,"$xdomain\r\n");

      while(!feof($sock)){
          $result .= fgets($sock,1024);
      }
    }
    ##################################################################
    ##################################################################
	##
	## EVERY WHOIS SERVER IS DIFFERENT... SO YOU WANT TO FIND OUT
	## HOW TO "EXTRACT" THE DATA YOU WANT USING PHP. WHEN YOU GET
	## THAT CODE... PUT IT HERE. :D
	##
	## $result HOLDS THE OUTPUT FROM THE WHOIS SERVER... YOU JUST
	## GOTTA SEARCH THAT FOR THE STRING YOU ARE LOOKING FOR.
	##    
    ##################################################################
    ##################################################################
  }
?>

AND AND AND
this is what tlds.php looks like:

PHP:
<?php

$avail = array(
  "ac" => "No match for",
  "ac.uk" => "No such domain",
  "aero" => "not registered",
  "ag" => "NOT FOUND",
  "am" => "No match",
  "as" => "Domain Not Found",
  "at" => "nothing found",
  "au" => "No Data Found",
  "au.com" => "No domains matched your search",
  "be" => "Status: FREE",
  "biz" => "Not found",
  "br" => "No match for domain",
  "ca" => "Status: AVAIL",
  "cc" => "No match for",
  "ch" => "We do not have an entry in our database matching your query",
  "cl" => "no existe",
  "cn" => "no matching record",
  "com" => "Can't get information",
  "coop" => "No domain records were found to match",
  "cz" => "No data found",
  "de" => "Status: free",
  "dk" => "No entries found for the selected source",
  "edu" => "No match for",
  "ee" => "NOT FOUND",
  "eu" => "Status: FREE",
  "eu.org" => "No entries found for the selected source",
  "fr" => "No entries found",
  "gg" => "Domain not found in WHOIS database",
  "gov.uk" => "No such domain",
  "gs" => "is not registered",
  "hk" => "Domain name not found",
  "hm" => "(null)",
  "hu" => "No match",
  "ie" => "Not Registered",
  "il" => "No data was found to match the request criteria",
  "info" => "NOT FOUND",
  "int" => "not found",
  "io" => "No match for",
  "ir" => "no entries found",
  "is" => "No entries found",
  "it" => "No entries found",
  "je" => "Domain not found",
  "ke" => "No match found",
  "kr" => "not registered",
  "li" => "We do not have an entry in our database matching your query",
  "lt" => "No matches found",
  "lu" => "No such domain",
  "lv" => "Nothing found",
  "ms" => "is not registered",
  "museum" => "has not been delegated",
  "mx" => "No Encontradas",
  "name" => "No match",
  "net" => "No match for",
  "nl" => "is free",
  "no" => "no matches",
  "nu" => "NO MATCH",
  "org" => "NOT FOUND",
  "pl" => "No information about domain",
  "re" => "No entries found",
  "ro" => "No entries found",
  "ru" => "No entries found",
  "se" => "No data found",
  "sg" => "NOMATCH",
  "sh" => "No match for",
  "si" => "No entries found",
  "st" => "No entries found",
  "tc" => "is not registered",
  "th" => "No entries found ",
  "tk" => "domain name not known",
  "tm" => "No match for",
  "to" => "No match for",
  "tr" => "No match found for",
  "tv" => "Whois information is not available for domain",
  "tw" => "No Found",
  "ua" => "No entries found for domain",
  "ug" => "No entries found for the selected source",
  "uk" => "This domain name has not been registered",
  "us" => "Not found",
  "vg" => "is not registered",
  "ws" => "No match for",
);

?>
 
0
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
NameMaxi - Your Domain Has Buyers
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back