Hello,
My domain registrar has an API enabled where I can make changes to domains, register domains and check wether or not a domain is free.
I've put the php code in a UDT, and it works fine for a hardcoded domain. However, I would like a user to enter a domain, and the UDT to return wether or not it is free. Is this possible in a UDT, or am I going to have to make a module for it?
Regards,
Richard
[SOLVED] UDT: Is domain free?
[SOLVED] UDT: Is domain free?
Last edited by RichardC on Fri Nov 05, 2010 9:35 am, edited 1 time in total.
Re: UDT: Is domain free?
Hi,
It is possible using a UDT as I have it working on another website. The UDT will need configuring depending on your requirements, i.e. .com/.co.uk/etc....
I have two UDT's, one with for the input and one for the results.
1. Domain_Check UDT
function checkDomain($domain,$server,$findText){
// Open a socket connection to the whois server
$con = fsockopen($server, 43);
if (!$con) return false;
// Send the requested doman name
fputs($con, $domain."\r\n");
// Read and store the server response
$response = ' :';
while(!feof($con)) {
$response .= fgets($con,128);
}
// Close the connection
fclose($con);
// Check the response stream whether the domain is available
if (strpos($response, $findText)){
return true;
}
else {
return false;
}
}
function showDomainResult($domain,$server,$findText){
if (checkDomain($domain,$server,$findText)){
echo "www.$domainGood News, The Domain Is Available
.hidden_domain {visibility: visible; height: 70px;}";
}
else echo "www.$domainSorry, The Domain Is Unavailable Please Try Another Address";
}
2. Domain_Check_Results UDT
// The form was submitted
if (isset($_GET['submitBtn'])){
$domainbase = (isset($_GET['cntnt01fbrp__62'])) ? $_GET['cntnt01fbrp__62'] : '';
$d_com = (isset($_GET['com'])) ? 'com' : '';
// Check domains only if the base name is big enough
if (strlen($domainbase)>2){
echo '';
if ($d_com != '')
showDomainResult($domainbase.".co.uk",'whois.nic.uk','No match for');
echo '';
}
}
Hope that helps.
It is possible using a UDT as I have it working on another website. The UDT will need configuring depending on your requirements, i.e. .com/.co.uk/etc....
I have two UDT's, one with for the input and one for the results.
1. Domain_Check UDT
function checkDomain($domain,$server,$findText){
// Open a socket connection to the whois server
$con = fsockopen($server, 43);
if (!$con) return false;
// Send the requested doman name
fputs($con, $domain."\r\n");
// Read and store the server response
$response = ' :';
while(!feof($con)) {
$response .= fgets($con,128);
}
// Close the connection
fclose($con);
// Check the response stream whether the domain is available
if (strpos($response, $findText)){
return true;
}
else {
return false;
}
}
function showDomainResult($domain,$server,$findText){
if (checkDomain($domain,$server,$findText)){
echo "www.$domainGood News, The Domain Is Available
.hidden_domain {visibility: visible; height: 70px;}";
}
else echo "www.$domainSorry, The Domain Is Unavailable Please Try Another Address";
}
2. Domain_Check_Results UDT
// The form was submitted
if (isset($_GET['submitBtn'])){
$domainbase = (isset($_GET['cntnt01fbrp__62'])) ? $_GET['cntnt01fbrp__62'] : '';
$d_com = (isset($_GET['com'])) ? 'com' : '';
// Check domains only if the base name is big enough
if (strlen($domainbase)>2){
echo '';
if ($d_com != '')
showDomainResult($domainbase.".co.uk",'whois.nic.uk','No match for');
echo '';
}
}
Hope that helps.
Re: UDT: Is domain free?
Thank you!
I've also found an UDT which displays a contact form in the tips & tricks, and used that to get my domain check to work.
It's a bit crude now, but it works! Check it out here...
I've also found an UDT which displays a contact form in the tips & tricks, and used that to get my domain check to work.
It's a bit crude now, but it works! Check it out here...
Re: UDT: Is domain free?
Nice,RichardC wrote: Thank you!
I've also found an UDT which displays a contact form in the tips & tricks, and used that to get my domain check to work.
It's a bit crude now, but it works! Check it out here...
Can you give us the code for your solutiuon of it?