Hi I'm looking for a free WHOIS script in ASP/PHP for my website. I want something like they have at http://whois.net/ I need it so that I can just have the form on a page of my site and it calls a results page just like their site does. I have looked around but many of them are crap.
I wrote one from scratch for .com and .net. ***This is not an eyecandy script, use it as a template and create your own theme and style sheet on it.*** <form method='post'> Domain: <input type='text' name='domain'><input type='submit'> </form> <?php /** Pre Processing **/ if (empty($_POST)) exit; list($domain, $ext) = explode(".", $_POST['domain']); /** Output **/ echo whois($domain, $ext); /** Function **/ function whois($domain, $ext){ $url = $domain.".".$ext; switch ($ext) { case "com": $whois = "whois.verisign-grs.com"; break; case "net": $whois = "whois.verisign-grs.com"; break; } $url = trim($url); $f = fsockopen($whois, 43, $errno, $errstr, 30); fputs($f, "$url\r\n"); $data = ""; while (!feof($f)) { $data .= fread($f, 128); } fclose($f); $url = strtoupper($url); return (strpos($data, "No match for \"{$url}\"") ? "This domain is available for registration" : $data); } ?> PHP:
Here is a small script I've build to get the year a domain was registered: function getRegisteredYear($domain) { if (strpos($domain, '.biz')) { $cmd = 'whois '.$domain.' | grep -i \'Registration Date\' | head -n1 | egrep -o \'[[:digit:]]{4}\''; } elseif (strpos($domain, '.us')) { $cmd = 'whois '.$domain.' | grep -i \'Domain Registration Date\' | head -n1 | egrep -o \'[[:digit:]]{4}\''; } else { $cmd = 'whois '.$domain.' | grep -i \'creat\' | head -n1 | egrep -o \'[[:digit:]]{4}\''; } $res = exec($cmd); return $res; } Code (markup): You do need to be able to execute command via the exec command. If you just want to get the WHOIS-data use this: function getWhoisData($domain) { return exec('whois '.$domain.'); } Code (markup):