Jump to content

Name Spinner: Domain Name Suggestions (eNom)


Brett

Recommended Posts

Excellent,

 

I love it!

 

I think a more compact list would be nice as well, or maybe just a tick box beside each domain. Selecting multiple names would then take you to a subpage allowing you to select additional extensions for each domain that was marked on the first page.

Link to comment
Share on other sites

List more LTDs and instead of putting all that drop down and Available now! Just Put an X without selection button or a selection button if available and after you select the domain be able to choose yearly or monthly. It will make it smaller with a lot more of LTDs and nicer looking.

Link to comment
Share on other sites

OK, here is my problem with just having the check boxes. It looks like you have to put in

<select name="domainsregperiod[iwanticepick.net]"><option value="1">1 Year/s @ $14.95 USD</option></select>

 

in order for WHMCS to recognize the prices, otherwise it will go into the cart as "$0.00" which you obviously do not want.

 

As far as listing other tld's, eNom only has in their API the ability to check .com .net .tv and .cc

 

Once I release the code, there might be other ways of checking other tld's of the domains availability, but for now lets just concentrate on what we have to work with.

 

I think mirroring the WHMCS table above it and having each domain with all TLD's in the same td box and having it display the domain options at the end of the table is a good idea.

 

Any other idea's?

Link to comment
Share on other sites

a little confused why the top serach checks com/net/org, but the suggestions are com/net/tv :)

 

The reason for this is a limitation on eNom's part. It will only display the .com .net .tv and .cc

 

There is nothing that you can do about it. There might be a way though to have it check against other whois databases, but for right now I am just concentrating on the actual code. I will post the code in about 5 minutes.

Link to comment
Share on other sites

OK, I still have a ways to go on it, but here it is in it's ALPHA form. Any suggestions or recommendations are welcome. Also, please be aware that this is my first time to create ANYTHING in php, so there might (and probably are) better ways of doing what I did with it.

 

In the /templates/orderforms/cart/adddomain.php

 

After

<p align="center"><input type="submit" value="{$LANG.addtocart}" /></p>

 

Add

<p class="cartsubheading">We also recommend:</p>

{php}
// *************************************************************************
// * *
// * webHeadStudios - Website Development, Design and Hosting. *
// * Copyright (c) 2007-2008 webHeadStudios. All Rights Reserved, *
// * Release Date: 22nd March 2008 *
// * Version 0.5 *
// * *
// *************************************************************************
// * *
// * Email: support@webheadstudios.com *
// * Website: http://www.webheadstudios.com *
// * *
// *************************************************************************

// Used to extract Smarty variables
extract($this->_tpl_vars);

// Path to the eNom module
include("/home/user/public_html/whmcs/modules/registrars/enom/enom.php");

// Start the eNom interface
$Enom = new CEnomInterface;

// Your eNom username and password
$Enom->AddParam( "uid", "username" );
$Enom->AddParam( "pw", "password" );

// Command to run
$Enom->AddParam( "command", "namespinner" );
$Enom->AddParam( "sld", "$sld" );
$Enom->AddParam( "tld", "com" );

// Number of results to return
$Enom->AddParam( "MaxResults", "5" );

// Remove explicit material
$Enom->AddParam( "SensitiveContent", "True" );

// Response type seems to work best with html
$Enom->AddParam( "ResponceType", "html" );

$Enom->DoTransaction();

// Display or hide domain groups
$showCom = y; //show the .com group
$showNet = y; //show the .net group
$showTv = y; //show the .tv group
$showCc = n; //show the .cc group

$spincount = urldecode($Enom->Values['spincount']);

echo "<table class=\"clientareatable\" style=\"width:90%;\" align=\"center\" cellspacing=\"1\">\n";
echo "<tr class=\"clientareatableheading\"><td>Domain Name</td>";
if ($showCom == y){
echo "<td>com</td>";
}
if ($showNet == y){
echo "<td>net</td>";
}
if ($showTv == y){
echo "<td>tv</td>";
}
if ($showCc == y){
echo "<td>cc</td>";
}
echo "</tr>\n";

for ($i=1; $i<=$spincount; $i++){

// Enable the domain to go into the cart as lowercase.
$lowercaseDomain = urldecode($Enom->Values[ "DomainSld" . $i ]);
$lowercaseDomain = strtolower($lowercaseDomain);

echo "<tr class=\"clientareatableactive\"><td><a href=\"cart.php?a=add&domain=register&sld={$lowercaseDomain}&tld=.com\">{$Enom->Values[ "DomainSld" . $i ]}</a></td>\n";
//This is for the .COM
if ($showCom == y){
echo "<td class=\"";
if ($Enom->Values[ "Domain" . $i . "TldStatus1" ] == y ){
echo "domaincheckeravailable";
} else {
echo "domaincheckerunavailable";
}
echo "\">";
if ($Enom->Values[ "Domain" . $i . "TldStatus1" ] == y ){
echo "<input type=\"checkbox\" name=\"domains[]\" value=\"{$lowercaseDomain}.com\" /> Available! Order Now";
echo "<br /><br /><select name=\"domainsregperiod[{$lowercaseDomain}.com]\"><option value=\"1\">1 Year/s @ $14.95 USD</option><option value=\"2\">2 Year/s @ $24.95 USD</option><option value=\"3\">3 Year/s @ $34.95 USD</option></select>";
} else {
echo "Unavailable";
}
echo "</td>\n";
}
//This is for the .NET
if ($showNet == y){
echo "<td class=\"";
if ($Enom->Values[ "Domain" . $i . "TldStatus2" ] == y ){
echo "domaincheckeravailable";
} else {
echo "domaincheckerunavailable";
}
echo "\">";
if ($Enom->Values[ "Domain" . $i . "TldStatus2" ] == y ){
echo "<input type=\"checkbox\" name=\"domains[]\" value=\"{$lowercaseDomain}.net\" /> Available! Order Now";
echo "<br /><br /><select name=\"domainsregperiod[{$lowercaseDomain}.net]\"><option value=\"1\">1 Year/s @ $14.95 USD</option></select>";
} else {
echo "Unavailable";
}
echo "</td>\n";
}
//This is for the .TV
if ($showTv == y){
echo "<td class=\"";
if ($Enom->Values[ "Domain" . $i . "TldStatus3" ] == y ){
echo "domaincheckeravailable";
} else {
echo "domaincheckerunavailable";
}
echo "\">";
if ($Enom->Values[ "Domain" . $i . "TldStatus3" ] == y ){
echo "<input type=\"checkbox\" name=\"domains[]\" value=\"{$lowercaseDomain}.tv\" /> Available! Order Now";
echo "<br /><br /><select name=\"domainsregperiod[{$lowercaseDomain}.tv]\"><option value=\"1\">1 Year/s @ $24.95 USD</option></select>";
} else {
echo "Unavailable";
}
echo "</td>\n";
}
//This is for the .CC
if ($showCc == y){
echo "<td class=\"";
if ($Enom->Values[ "Domain" . $i . "TldStatus4" ] == y ){
echo "domaincheckeravailable";
} else {
echo "domaincheckerunavailable";
}
echo "\">";
if ($Enom->Values[ "Domain" . $i . "TldStatus4" ] == y ){
echo "<input type=\"checkbox\" name=\"domains[]\" value=\"{$lowercaseDomain}.cc\" /> Available! Order Now";
echo "<br /><br /><select name=\"domainsregperiod[{$lowercaseDomain}.cc]\"><option value=\"1\">1 Year/s @ $14.95 USD</option></select>";
} else {
echo "Unavailable";
}
echo "</td>\n";
}
}

echo "</tr></table>";

echo "<table class=\"clientareatable\" style=\"width:90%;\" align=\"center\" cellspacing=\"1\"><tr class=\"clientareatableactive\"><td><p>Click a domain name above for additional recommendations based on that name.</p></td></tr></table>";

// Get number of errors
$nNumErrors = $Enom->Values[ "ErrCount" ];

if ( $nNumErrors > 0 ) {

// There were errors
echo "<b>There were errors:</b><br />";
// Loop through all errors and print them out
for ( $i = 1; $i <= $nNumErrors; $i++ ) {
echo "$i) {$Enom->Values[ "Err" . $i ]}<br />";
}
}
{/php}

<p align="center"><input type="submit" value="{$LANG.addtocart}" /></p>

 

There are 3 things that are required for you to change in order for it to function properly.

 

The first thing to change is the location of the eNom module. You will find it in your /modules/registrars/enom/enom.php Make sure to provide the full path.

// Path to the eNom module
include("/home/user/public_html/whmcs/modules/registrars/enom/enom.php");

 

The second thing to change is the eNom username and password. Just replace username with your eNom username and password with your eNom password.

// Your eNom username and password
$Enom->AddParam( "uid", "username" );
$Enom->AddParam( "pw", "password" );

 

The third thing that needs to be changed is the pricing on the domains.

<option value=\"1\">1 Year/s @ $14.95 USD</option><option value=\"2\">2 Year/s @ $24.95 USD</option><option value=\"3\">3 Year/s @ $34.95 USD</option>

 

Lats say you only have 1 and 5 year registrations at 12.95 and 49.95, then you would use the following

<option value=\"1\">1 Year/s @ $12.95 USD</option><option value=\"5\">5 Year/s @ $49.95 USD</option>

 

Other options that you have available:

 

Domain recommendations to show.

You can have eNom return up to 99 domain recomendations. Just change 5 to the amount that you want returned.

// Number of results to return
$Enom->AddParam( "MaxResults", "5" );

 

Showing Groups

You can change any domain group to show or not. Just change from y to n for that domain group not to show

// Display or hide domain groups
$showCom = y; //show the .com group
$showNet = y; //show the .net group
$showTv = y; //show the .tv group
$showCc = n; //show the .cc group

 

Remove explicit material

You can just delete the following line if you want sexually explicit recommendations potentially mixed with results.

// Remove explicit material
$Enom->AddParam( "SensitiveContent", "True" );

 

##################################################

 

This script is far from being done. The things that I will be working on adding is an admin module to change all variables, and for the proper domain prices to show.

 

I would also recommend that the you use an include for this by creating another tpl file and adding to that.

 

########Known Issues########

 

When doing a domain transfer, it shows the recommendations. This is a known bug that will be fixed in the next release.

 

Just let me know what you think of the code and any recommendations and changes are more than welcome.

Link to comment
Share on other sites

  • 2 weeks later...

This script is 100% independent of WHMCS. So you don't even have to setup eNom in the WHMCS admin section to get this working.

 

This script is put into the templates section of your site. Once the user submits the query, it will send your username and password and other information to eNom. eNom will return the result and it will display it to the user.

 

So in short, you don't have to use your eNom reseller account to do ANY of the registrations.

Link to comment
Share on other sites

  • 1 month later...

Hello John,

 

I had a look at the DomainTools API and it seems that most of the code is already written for this. It has the name_spinner function ready to go!

 

<?php

function name_spinner ($query, $num_suggestions = 20) {

   // Configure these 3 variables
   $key = 'your-key-goes-right-here'; 
   $partner = 'YourPartnerName';
   $tlds = array('com', 'net', 'org', 'info', 'biz', 'us');


   // Construct the url to load
   $url = '/api.xml?';
   $url .= 'partner=' . $partner;
   $url .= '&key=' . $key;
   $url .= '&customer_ip=' . getenv('REMOTE_ADDR');
   $url .= '&appname=name_spinner';
   $url .= '&version=4';
   $url .= '&ext='. implode('|', $tlds); // The TLDs should be seperated by pipes
   $url .= '&q='. urlencode($query);
   $url .= '&rows=' . $num_suggestions;
   $url .= '&adult=auto';// 'auto', 'no', or  'yes'
   $url .= '&more='; // '' or 80 for more results

   $toReturn = array('suggestions' => array(), 'error' => '');

   $host = 'engine.whoisapi.com';
   $ip = gethostbyname($host);

   if (!$ip || $host == $ip) {
       $toReturn['error'] = 'Unable to resolve host';

   } else {

       // Download this page
       $fp = @fsockopen($host, 80, $errno, $errstr, 10);

       if (!$fp) {
           $toReturn['error'] = $errstr;

       } else {
         $header = "GET $url HTTP/1.0\n" .
         "Host: $host\n" .
         "User-Agent: Name Spinner SDK\n" .
         "Connection: close\r\n\r\n";

         fwrite($fp, $header);		

         $res = '';
         $start_time = time();
         while (!feof($fp)) {
           $res .= fread($fp, 100000); // 100kb

           $diff = time() - $start_time;
	    if ($diff > 10) {// Timeout at 10 seconds
  	  	    $toReturn['error'] = 'Read timed out';
		    return $toReturn;
	    }

         	if (!feof($fp)) {
         	    usleep(100);// 0.01 seconds
	    }

         }

         fclose($fp);

         // Strip the headers
         $res = substr($res, strpos($res, '<?xml'));

         $parser = xml_parser_create();
         xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
         xml_parse_into_struct($parser, $res, $xmlvals, $xmlindex);

         // if the API didn't return any data because an error occurred
         if (!isset($xmlindex['e_n'])) {
             $toReturn['error'] = 'The API returned an error. View the API XML to resolve the error. ';
         } else {

             // Always run htmlentities() on data being retrieved from an outside sources
             // so foreign HTML/Javascript cannot invade your site

             $toReturn['time'] = htmlentities($xmlvals[$xmlindex['querytime'][0]]['value']);
             $toReturn['query'] = htmlentities($xmlvals[$xmlindex['e_n'][0]]['value']);
             $toReturn['status'] = htmlentities($xmlvals[$xmlindex['e_s'][0]]['value']);

             $tlds = htmlentities( strtolower( $xmlvals[$xmlindex['extn'][0]]['value']));
             $toReturn['tlds'] = explode('|',  $tlds);

             foreach($xmlindex['id'] as $keyv => $i) {
                 $toReturn['suggestions'][$keyv] = array();
                 $toReturn['suggestions'][$keyv]['id'] = htmlentities($xmlvals[$i]['value']);
             }

             foreach($xmlindex['n'] as $keyv => $i) {
                 $toReturn['suggestions'][$keyv]['suggestion'] = htmlentities($xmlvals[$i]['value']);
             }

             foreach($xmlindex['s'] as $keyv => $i) {
                 $toReturn['suggestions'][$keyv]['status'] = htmlentities($xmlvals[$i]['value']);
             }
         }
         xml_parser_free($parser);

       }
   }

   return $toReturn;
}



?>
<?php echo '<?xml version="1.0" encoding="iso-8859-1"?' . ">\n"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
   <title>Name Spinner SDK Example</title>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
   <style type="text/css">
       table.results {
           border: solid 1px #aaa;
           border-bottom: none;
       }
       table.results td {
           border-bottom: solid 1px #aaa;
       }
   </style>
</head>
<body>

<h2>Name Spinner SDK Example</h2>

<form action="" method="get">
   <p>
       Search Name Spinner:
       <?php
       $v = '';
       if (isset($_GET['q'])) {
           $v = htmlentities( stripslashes($_GET['q']) );
       }
       ?>
       <input size="30" type="text" name="q" value="<?php echo $v; ?>" />
       <input type="submit" value="Submit"/>
   </p>
</form>


<?php
if (isset($_GET['q'])) {

   // Define a function to print the status for each TLD that was returned
   function formatStatus ($status, $tlds) {
       foreach ($tlds as $key => $valud) {
           // If it is available
           if ($status{$key} == 'q') {
               echo '<td>O</td>';
           } else {
               echo '<td>X</td>';
           }
       }
   }

   ?>
   <h3>Results</h3>
   <?php

   // Send the api our query and get back the results
   $results = name_spinner($_GET['q'], 30);

   if ($results['error'] == '') {
       ?>

       <p>
           <strong>Query Time:</strong> <?php echo $results['time']; ?> sec.
       </p>


       <table class="results" cellpadding="3" cellspacing="0">
           <tr>
               <td style="width: 1.5em;"></td>
               <td style="width: 13em;"><strong>Suggestion</strong></td>
               <?php
               // Print all the TLDs
               foreach ($results['tlds'] as $tld) {
                   ?>
               <td><strong><?php echo strtoupper($tld) ?></strong></td>
                   <?
               }
               ?>
           </tr>
           <tr>
               <td><strong>>></strong></td>
               <td><?php echo $results['query'] ?></td>
               <?php
               formatStatus($results['status'], $results['tlds']);
               ?>
           </tr>
           <?php

           foreach ($results['suggestions'] as $suggestion) {
           ?>
           <tr>
               <td><strong><?php echo $suggestion['id'] ?>.</strong></td>
               <td><?php echo $suggestion['suggestion'] ?></td>
               <?php
               formatStatus($suggestion['status'], $results['tlds']);
               ?>
           </tr>
           <?php

           }
           ?>
       </table>


       <?php
   } else {
       ?>

       <p>
           An error has occurred and we could not generate any suggestions 
           for you at this time. Please come back later.
       </p>

       <?php
   }
}
?>

</body>
</html>

 

You would just need to edit it some to get this working, but should not be too hard.

 

The only reason that I wrote that for eNom is because you get unlimited queries for free, which is quite nice.

Link to comment
Share on other sites

  • 2 months later...
  • 2 weeks later...
  • 6 months later...

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