Jump to content

Extending WHMCS NameSpinner


Recommended Posts

I am developing a registrar module specific to a single TLD, and it seems that lookup provider idea was based on the assumption that the registrar module would handle availability checks for all TLDs. 

So, I need to find a way to either:

1) Have WHMCS standard NameSpinner do the lookups but for some TLDs, call the module CheckAvailability function

2) Have the registrar module handle all the lookups, but calling NameSpinner when outside its own remit. 

Is any of those options feasible ? 

Thanks,

Rubens

 

 

 

Link to comment
Share on other sites

Besides the interoperability with other TLDs/registrars module issue above, even for a single TLD deployment the CheckAvailability functions are not working. The availability check never ends. The current CheckAvailability function looks like this:

 

function registrobr_CheckAvailability($params)
{
    // registrar configuration values

    
    $target = ($params['TestMode'] == 'Beta') ?  'https://beta.registro.br/v2/ajax/avail/raw/' : 'https://registro.br/v2/ajax/avail/raw/' ;

    // availability check parameters
    $searchTerm = $params['searchTerm'];
    $tldsToInclude = $params['tldsToInclude'];

    array_push ($tldsToInclude,$params['tld']);
    $tldsToInclude = array_unique($tldsToInclude);
    
    if (!set($searchTerm)) {
        $searchTerm = $params['sld'];
    }
    
    logModuleCall('registrobr', 'Avail before ResultsList', $searchTerm , $tldsToInclude,'','');
    
    $results = new ResultsList();

    logModuleCall('registrobr', 'Avail after ResultsList', $searchTerm , $tldsToInclude,'','');
    
    foreach ($tldsToInclude as $tld) {
        try {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $target . $searchTerm . $tld);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
            curl_setopt($ch, CURLOPT_TIMEOUT, 100);
            $response = curl_exec($ch);
            logModuleCall('registrobr', 'Avail after curl', $target . $searchTerm . $tld , $response,'','');
            if (curl_errno($ch)) {
                throw new \Exception('Connection Error: ' . curl_errno($ch) . ' - ' . curl_error($ch));
            }
            curl_close($ch);
          
            $result = json_decode($response, true);
            if ($result === null && json_last_error() !== JSON_ERROR_NONE) {
                        throw new \Exception('Bad response received from Ajax Avail');
                }
            
            $searchResult = new SearchResult($searchTerm, $tld);
            
            switch ($result['status']) {
                case 0:
                    $searchResult->setStatus(SearchResult::STATUS_NOT_REGISTERED);
                    break;
                case 2:
                    $searchResult->setStatus(SearchResult::STATUS_REGISTERED);
                    break;
                case 1:
                case 3:
                case 5:
                case 6:
                case 7:
                case 9:
                    $searchResult->setStatus(SearchResult::STATUS_RESERVED);
                    break;
                case 4:
                case 8:
                default:
                    $searchResult->setStatus(SearchResult::STATUS_UNKNOWN);
                    break;
                    
            $results->append($searchResult);
                    
            }
            
            
            
        } catch (\Exception $e) {
            return array(
                'error' => $e->getMessage(),
            );
        }
    }
    
    return $results;
    
}

None of the log entries that logModuleCall would trigger ever happens. So there is something else happening in WHMCS before that is causing this. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated