whois script

Go down

whois script Empty whois script

Post by jamied_uk on 27th September 2011, 18:53

function ae_whois($query, $server)

define('AE_WHOIS_TIMEOUT', 15); // connection timeout
global $ae_whois_errno, $ae_whois_errstr;

// connecting
$f = fsockopen($server, 43, $ae_whois_errno, $ae_whois_errstr, AE_WHOIS_TIMEOUT);
if (!$f)
return false; // connection failed

// sending query
fwrite($f, $query."\r\n");

// receving response
$response = '';
while (!feof($f))
$response .= fgets($f, 1024);

// closing connection

return $response;

// copy-paste function ae_whois(see above) here

echo ae_whois('iphone.com', 'whois.verisign-grs.com');

As you can see, function takes two arguments: whois query and whois server. Function returns server response (if everything was fine), or 'false' constant(that means connection failed). fsockopen error code and error string are written to global variables $ae_whois_errno and $ae_whois_errstr.

You can also change connection timeout by modifying AE_WHOIS_TIMEOUT constant.

Usage example: getting information about domain 'iphone.com'
source code: php

Posts : 2471
Join date : 2010-05-09
Age : 36
Location : UK


Back to top Go down

Back to top

Permissions in this forum:
You cannot reply to topics in this forum