[SOLVED] UDT: Is domain free?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
RichardC
Forum Members
Forum Members
Posts: 59
Joined: Tue Aug 08, 2006 11:04 am

[SOLVED] UDT: Is domain free?

Post by RichardC »

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
Last edited by RichardC on Fri Nov 05, 2010 9:35 am, edited 1 time in total.
clj83
Forum Members
Forum Members
Posts: 195
Joined: Tue Jul 07, 2009 4:09 pm

Re: UDT: Is domain free?

Post by clj83 »

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.
RichardC
Forum Members
Forum Members
Posts: 59
Joined: Tue Aug 08, 2006 11:04 am

Re: UDT: Is domain free?

Post by RichardC »

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...
EricG
Forum Members
Forum Members
Posts: 29
Joined: Tue May 02, 2006 1:46 pm
Location: Apeldoorn

Re: UDT: Is domain free?

Post by EricG »

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...
Nice,

Can you give us the code for your solutiuon of it?
Post Reply

Return to “Modules/Add-Ons”