Using PHP classes to navigate distributed whois databases - Tying it all together (
Page 6 of 7 )
When all is said and done, and you simply want to look up pretty well
any 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 handlers
go, $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 we
can use the handy-dandy showObject() function in utils.whois, which
is bundled for debugging and diagnostics purposes (along with a couple
of other goodies.)
So, to lookup devshed.com and then examine the actual object we get back
we 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 that
the 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's
whois 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 server
we 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 have
stopped 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 registrar
whois servers at NetSol allow wildcard matching on arbitrary strings.