Home arrow PHP arrow Page 6 - Using PHP classes to navigate distributed whois databases

Tying it all together - PHP

Whois services changed radically this year with the introductionof competition at the registrar level in the .com/.net/.orgnamespace and with it the advent of the SRS (Shared Registry System). Find out how to navigate the new whois in your PHP scripts.

TABLE OF CONTENTS:
  1. Using PHP classes to navigate distributed whois databases
  2. Overview of the whois landscape
  3. Making sense of it with PHP classes
  4. Overview of Whois2.php
  5. Looking at the pieces
  6. Tying it all together
  7. Conclusion
By: Mark Jeftovic
Rating: starstarstarstarstar / 11
December 07, 1999

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

When all is said and done, and you simply want to look up pretty wellany domain name in your PHP scripts, you simply need do this:

$whois = new Whois("devshed.com"); $result = $whois->Lookup();
Depending on what we have under the hood as far as extended handlersgo, $result would contain:

In the case of no extended handlers:

$result["rawdata"]
will contain an array of the raw output from the whois server.

In the case of a .com/.net/.org domain with *NO* registrar handler:

$result["regyinfo"]
will contain parse key/value pairs of the registry output, including an array of "nameservers" and

$result["rawdata"]
will contain the unparsed raw output from the whois server defined in $result["regyinfo"]["whois"]

....and in the case of a .com/.net/.org/.edu that has a registrar handler you'll have the two as above plus $result["regrinfo"] which will be an array with key/value pairs from the registrar whois server.

To see exactly what we have in our $result or any parts therein wecan use the handy-dandy showObject() function in utils.whois, which is bundled for debugging and diagnostics purposes (along with a coupleof other goodies.)

So, to lookup devshed.com and then examine the actual object we get backwe can do this:

$whois = new Whois("devshed.com"); $result = $whois->Lookup(); include( "utils.whois"); $display = new utils; $display->ShowObject($result);
And the final result is:
A $result["regyinfo"] array with all the registry info, note thatthe nameserver list itself another array in $result["regyinfo"]["nameserver"]:

regyinfo->Array domain->DEVSHED.COM registrar->NETWORK SOLUTIONS, INC. whois->whois.networksolutions.com referrer->www.networksolutions.com nameserver->Array 0->NS1.INFOWEST.COM 1->NS2.INFOWEST.COM
A $result["rawdata"] array that has the raw data from the registrar'swhois server.

rawdata->Array 0->The Data in Network Solutions' WHOIS database is provided by Network 1->Solutions for information purposes, and to assist persons in obtaining 2->information about or related to a domain name registration record. 3->Network Solutions does not guarantee its accuracy. By submitting a 4->WHOIS query, you agree that you will use this Data only for lawful 5->purposes and that, under no circumstances will you use this Data to: 6->(1) allow, enable, or otherwise support the transmission of mass 7->unsolicited, commercial advertising or solicitations via e-mail 8->(spam); or (2) enable high volume, automated, electronic processes 9->that apply to Network Solutions (or its systems). Network Solutions 10->reserves the right to modify these terms at any time. By submitting 11->this query, you agree to abide by this policy. 12-> 13->Registrant: 14->InfoWest Global Internet Services, Inc. (DEVSHED-DOM) 15-> 1845 W. Sunset Blvd. 16-> St. George, UT 84770 17-> US 18-> 19-> Domain Name: DEVSHED.COM 20-> 21-> Administrative Contact: 22-> Cosby, David R (DRC4) dcosby@INFOWEST.COM 23-> 801.674.0165 24-> Technical Contact, Zone Contact: 25-> Gifford, Aaron D (AG44) agifford@INFOWEST.COM 26-> 435-674-0165 (801) 634-9567 (FAX) 435-674-9654 27-> Billing Contact: 28-> InfoWest Domain Services (IDS2-ORG) dns@INFOWEST.COM 29-> 435-674-0165 30->Fax- 435-674-9654 31-> 32-> Record last updated on 06-Aug-1997. 33-> Record created on 06-Aug-1997. 34-> Database last updated on 6-Dec-1999 16:08:49 EST. 35-> 36-> Domain servers in listed order: 37-> 38-> NS1.INFOWEST.COM 204.17.177.10 39-> NS2.INFOWEST.COM 204.17.177.20 40->
And finally a $result["regrinfo"] array, because we have a "netsol" handler to parse output from the Network Solutions registrar serverwe have the following data:

regrinfo->Array organization->InfoWest Global Internet Services, Inc. org_handle->DEVSHED-DOM org_address->1845 W. Sunset Blvd. St. George, UT 84770 US domain->DEVSHED.COM admin->Array name-> Cosby, David R handle->DRC4 email->dcosby@INFOWEST.COM tech->Array name-> Gifford, Aaron D handle->AG44 email->agifford@INFOWEST.COM billing->Array name-> InfoWest Domain Services handle->IDS2-ORG email->dns@INFOWEST.COM updated->06-Aug-1997 created->06-Aug-1997 db_updated->6-Dec-1999 16:08:49 EST ns->Array NS1.INFOWEST.COM->204.17.177.10 NS2.INFOWEST.COM->204.17.177.20
At the time of writing the only extended handler for registrar's is the netsol class. We need further classes for register.com, melbourneIT,COREnic and all the other registrars. Until then, our output would havestopped with the $result["rawdata"] array above.

Another Example:

Looking up something other than a domain name:

$STRING = "MJ177"; require("whois2.php3"); $whois = new Whois(); $whois->Query["server"]="whois.networksolutions.com"; $result = $whois->Lookup($STRING);
$STRING in this case is a Network Solutions contact handle (mine). It could just as easily be a host handle or any other string. The registrarwhois servers at NetSol allow wildcard matching on arbitrary strings.

 
 
>>> More PHP Articles          >>> More By Mark Jeftovic
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: