This is just a quick tutorial containing an easy method to get whois data for your website. This guide is aimed at people with an intermediate level of website development knowledge, and a firm grasp of PHP scripting.
Whois is a standard command that looks up a domain name’s details, such as dates of registration and renewal, as well as contact details for the domain’s owner and/or administrator. Many websites offer this service, such as who.is, and most hosting and domain name registration companies will use some incarnation of the whois command to check if a domain name is available for purchase.
There are many CGI and PHP scripts on the net which will allow you to add whois functionality to your website, but these tend be quite complicated, and will only allow you to query certain domain name extensions. There is a much easier,and often overlooked way to add whois domain name look ups to a website, and that is to run the “whois” command on the server.
To do this, your website needs to be on a Linux/Unix server, and you must have the permission to run the command “shell_exec” from PHP. All of ClearVector’s hosting packages will allow this. Lets assume the domain you want to query is “google.com”, you would simply add the following line of code to a PHP file:
$whois = shell_exec(”whois google.com”);
The variable $whois will then contain the full out put of the whois command. You can then use a simple text search, or regular expressions to extract the information you need. It’s as simple as that.