whois script

View previous topic View next topic Go down

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
fclose($f);

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
avatar
jamied_uk
Admin

Posts : 2289
Join date : 2010-05-09
Age : 34
Location : UK

http://address-shortner.co.uk

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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