WHOIS is a protocol that is widely used for querying server databases in order to determine the registrant or assignee of a domain name or IP address (range). In its simplest form, building a small PHP script to query the appropriate WHOIS server and outputting readable information is quite simple, yet complex solutions are usually required to extract full functionality from the WHOIS system.
This code was first posted to martinetics over 10 years ago before it was migrated to Internoetics in 2009. Since then, it's seen tens of thousands of downloads, and it's even been referenced in a few text books. You'll now see the crappy code copied all over the web.
Included in the download below is a very simple yet featured script to output the registrant of a domain name stored in WHOIS records. There's little security, and the code doesn't do much other than check the registrant. The code can be quickly modified (via the config file) into a turnkey-style website. You can see a copy of the example code in action here.
While the code was written in the same time it takes most people to brush their teeth, there are a few features:
- Config file to alter text. Find it in
custom/config.inc.php
. - Some validation is performed on the input.
- Automatically checks for updates.
- Social integration.
- You may optionally use a simple captcha.
- Data will be cached as per your defined cache period. We use the Simple Cache code. Define your cache directory in your
config.inc.php
file. - The code is basic. Since we expect to improve the code and add a few features, ensure
BELIEFMEDIA_CHECK_UPDATES
is set toTRUE
incustom/config.inc.php
. A notice will be displayed, and the script will send you an email when an update is available.
The code is an example, not a solution. However, it'll be developed into something aesthetically pleasing over time (update notifications are automated). Modify the custom/config.inc.php file with the required information to enable the website. Updates will generally leave the custom
directory alone.
PHP Code
In its simplest form, the request to a WHOIS server is as per the below example. The full list of WHOIS servers for each domain extension is included in the download.
Considerations
- WHOIS information on Wikipedia
- Delegation details of top-level domains (iana.org)
- We're in the process of rebuilding the entire WHOIS server database. If you find an error or addition, please let us know.
Video Introduction
Download
Title: Simple WHOIS Lookup With PHP
Description: Simple WHOIS Lookup With PHP. Download includes full sample website.
Download • Version 0.2, 832.2K, zip, Category: PHP Code & Snippets