PHP Forums Archive

Whois Class: Adding more tlds

Tags: php, whois, how-to, snippet, tld, .com.mx

Olaf posted on 2007-12-28 15:35:43 #

Adding more Tlds is very easy, just edit the file "server_list.php" and add new array values like:


$servers['xx']['address'] = "whois.xx";
$servers['xx']['free'] = "FREE";
$servers['x']['param'] = "";

Replace xx with your new tld
address is the address you need for your query (search the website from the local domain publisher for this information or search google for "whois xx tld")

The free string is something you can find on the Internet or while using this small snippet:


<?php
function get_whois_data($test_server, $test_domain) {
$msg = "";
$connection = fsockopen($test_server, 43, $errno, $errstr, 10);
if (!$connection) {
$msg = "Can't connect to the server!";
} else {
sleep(2);
fputs($connection, $test_domain."\r\n");
while (!feof($connection)) {
$msg[] = fgets($connection, 4096);
}
fclose($connection);
}
return $msg;
}
print_r(get_whois_data("whois.nic.us", "finalwebsites.us"));
?>

The last value param is only used for a few tlds, let it empty if not needed.

There was also a forum thread on the previous support forum.

Comments / discussions

emagen posted on 2008-10-15 22:47:10 #

Olaf
I just added the tld .com.mx and the whois is working fine, I am only having trouble when using the multiple whois, it shows the correct availability but the detail page shows the domain's info without the .mx part. For example:

domain.com is dregistered Detail >> correct details
domain.com.mx is registered Detail >> it shows details for domain.com

I think I have to modify the code in multi_whois_detail.php:

if (isset($_GET['det'])) {
	$dom_parts = explode(".", $_GET['det']);

but I'm not sure what change I must do

Could you please help me

Thanks

Cecilia M

Olaf posted on 2008-10-17 07:41:55 #

Cecilia, please open a new thread if you need help.
Thanks