PrintLogo

Using Whois With PHP




If you would like to provide whois queries via PHP, a good package to use is available here. An example script that uses this package is:

<?php
include("whois/main.whois");
$whois = new Whois($_GET['query']);
$result = $whois->Lookup();
echo "<pre>";
for($i=0;$i<count($result[rawdata]);$i++)
{
$row = each($result[rawdata]);
echo $row["value"]."\n";
}
echo "</pre>";
?>

The query variable is arbitrary. You can call that anything you want. The whois function has an array in it called rawdata. The for loop just iterates through all values of the array. Simply call this with url?query=domain.com, and it will return the whois information. This will work with IP addresses as well, so you can easily add this to your log viewer to click on the address to get the whois info.



This article comes from NetAdminTools:
http://www.netadmintools.com/

The URL for this story is:
http://www.netadmintools.com/art388.html

Copyright 1997-2008 NetAdminTools.com. Read our Terms of Use.