When looking at a domain name as part of a email address or URL, you simply do not get enough information from it. You can even go so far as visiting that URL and you still will not have enough information about the ownership of that particular domain. Most of the kind of information that you would want will be located in a WHOIS database. These databases are maintained by registrars and can provide information about the owners of a particular domain. To get the information from these databases you need to run a whois query from a client application. PHP provides this kind of client application through the PEAR package. PEAR has a class that enables you to query a whois database. This class is called Net_Whois. And is used like so: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <? require_once "Net/Whois.php"; $server = "whois.networksolutions.com"; $query = "metroworks.com"; $whois = new Net_Whois; $urlinfo = $whois->query($query, $server); var_dump($urlinfo); ?> </body> </html> First the code defines the server where the whois database is located: $server = "whois.networksolutions.com"; Then it defines the name of the domain on which it wants to run a query: $query = "metroworks.com"; Finally the query is run, after the Net_whois class is instantiated: $whois = new Net_Whois; $urlinfo = $whois->query($query, $server); and the information from the query is shown: var_dump($urlinfo); The var_dump() function will show the entire contents of the $urlinfo variable. Next week we will go over more PHP tools and functions that are useful in a network environment.
blog comments powered by Disqus |
|
|
|
|
|
|
|