 | Add "Domain Availability Search" functionality. |  |
|
sabersrock18
|
 |
Posted: Wed Oct 03, 2007 5:23 pm |
|
 |
 |
 |
 |
I am basically trying to figure out if it is possible to add the ability for my clients to Lookup Domain Availability from my website. I want them to purchase it through me and then I will purchase it through hostmysite. That way I can mark it up a little.
Any ideas.
|
|
|
|
Jason101
Forum Regular
| Joined: 14 Mar 2006 |
| Posts: 570 |
| Location: Harrisburg, PA |
|
 |
Posted: Wed Oct 03, 2007 7:15 pm |
|
 |
 |
 |
 |
You most certainly can. It's fairy easy. But first, what language do you want to use?
|
|
|
|
sabersrock18
|
 |
Posted: Tue Nov 18, 2008 11:36 pm |
|
 |
 |
 |
 |
I completally forgot about this post...
if you are still out there, i am most comfortable with php
|
|
|
 |
 | |  |
 |
 | |  |
|
nathacof
Forum Admin
| Joined: 24 Oct 2006 |
| Posts: 192 |
| Location: Dover, DE |
|
 |
Posted: Mon Jun 29, 2009 4:07 pm |
|
 |
 |
 |
 |
I wrote my own WHOIS lookup script:
http://neranjara.org/tools/whois
http://neranjara.org/tools/ipwhois
It's fairly straightforward once you read the relevant documentation.
Simply open up a socket to the whois server and shoot the domain through. Once there the whois server will spit back the info you're looking for.
http://en.wikipedia.org/wiki/WHOIS
whois-servers.net is a great domain whose subdomains point to the corresponding whois server IE:
$ dig +short org.whois-servers.net
whois.publicinterestregistry.net.
149.17.192.7
$ dig +short net.whois-servers.net
whois.verisign-grs.com.
199.7.51.74
|
So you simply connect on port 43 to the corresponding domain, write your domain on the socket followed by a carriage return and line feed ("\r\n"), and read the resulting output.
This is how the whois tool on Linux works at least, so I modeled my tool after it, and it works wonders. IPWhois is a similar scenario only there are a limited number of IPWHOIS servers:
<?php
$servers = array('ARIN' => 'whois.arin.net',
'RIPE' => 'whois.ripe.net',
'APNIC' => 'whois.apnic.net',
'LACNIC' => 'whois.lacnic.net',
'AfriNIC' => 'whois.afrinic.net' );
|
|
|
Last edited by nathacof on Mon Jun 29, 2009 11:56 pm; edited 7 times in total
|
 |
 | |  |
|
nathacof
Forum Admin
| Joined: 24 Oct 2006 |
| Posts: 192 |
| Location: Dover, DE |
|
 |
Posted: Mon Jun 29, 2009 4:29 pm |
|
 |
 |
 |
 |
I rewrote this based on my personal code:
<?php
/*
* Function accepts the domain for
* which we want the WHOIS information
* default value is example.com
*/
function getWhoisText($domain = 'example.com') {
/*
* whois-servers.net provides
* information pertaining to relevant
* whois servers
*/
$WHOIS = 'whois-servers.net';
/*
* This code breaks a domain into it's
* atomic parts and reverses their order
*/
$tmp = array_reverse(explode('.', $domain));
/*
* Here we set the the appropriate WHOIS
* server based on the Top Level Domain
*/
$server = $tmp[0] . "." . $WHOIS;
/*
* Connect to the WHOIS server
*/
if(!$link = fsockopen($server, 43, $errno, $errstr, 15)) {
trigger_error("Error (" . $errno . "): " . $errstr .
"Could not connect to " . $server,
E_USER_ERROR);
return false;
}
/*
* write the domain to the socket
*/
if(!fwrite($link, $domain. "\r\n")){
trigger_error("Error: Could not write to socket",
E_USER_ERROR);
return false;
}
/*
* collect the returned data
*/
while (!feof($link)){
$string .= fgets($link, 4096);
}
/*
* close the socket
*/
fclose($link);
/*
* return whois information
*/
return $string;
}
|
/*
* Function accepts the IP for
* which we want the WHOIS information
*/
function getIpWhoisText($ip, $server = 'ARIN') {
/*
* Validate IP Address
*/
if(!ip2long($ip)) {
trigger_error("Invalid IP Address",
E_USER_NOTICE);
return false;
}
/*
* List of servers
*/
$SERVERS = array('ARIN' => 'whois.arin.net',
'RIPE' => 'whois.ripe.net',
'APNIC' => 'whois.apnic.net',
'LACNIC' => 'whois.lacnic.net',
'AfriNIC' => 'whois.afrinic.net' );
/*
* Check that the server exists in our array
*/
if(!array_key_exists($server, $SERVERS)) {
trigger_error("Invalid Server type, must be one of, " .
implode(", ", array_keys($SERVERS)) . ".",
E_USER_NOTICE);
return false;
}
/*
* Here we set the the appropriate WHOIS
* server
*/
$server = $SERVERS[$server];
/*
* Connect to the WHOIS server
*/
if(!$link = fsockopen($server, 43, $errno, $errstr, 15)) {
trigger_error("Error (" . $errno . "): " . $errstr .
"Could not connect to " . $server,
E_USER_NOTICE);
return false;
}
/*
* write the ip to the socket
*/
if(!fwrite($link, $ip. "\r\n")){
trigger_error("Error: Could not write to socket",
E_USER_NOTICE);
return false;
}
/*
* collect the returned data
*/
while (!feof($link)){
$string .= fgets($link, 4096);
}
/*
* close the socket
*/
fclose($link);
/*
* return whois information
*/
return $string;
} |
|
|
|
 |
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
All times are GMT
Page 1 of 1
|
|
|
|
|