Brett Posted March 21, 2008 Share Posted March 21, 2008 Adds a domain suggestion feature to WHMCS to show different domain names based on what was searched for. It uses the eNom NameSpinner function from their API. For all the latest features, updates and information please visit the wiki. http://wiki.whmcs.com/Contribution:Name_Spinner Click here to see a demo. 0 Quote Link to comment Share on other sites More sharing options...
Brett Posted March 21, 2008 Author Share Posted March 21, 2008 Please tell me how you think this should be designed. I have a demo link above. Once the design is finalized, I will release the code for all to use. 0 Quote Link to comment Share on other sites More sharing options...
chickendippers Posted March 21, 2008 Share Posted March 21, 2008 Perhaps instead of showing the .com .net and .tv tlds for each suggestion, you could just list them? Thus getting rid of that rather ugly table. So instead of: IWantIcePick .com .net .tv IWantRinkCream .com .net .tv You had: IWantIcePick.com IWantRinkCream.tv 0 Quote Link to comment Share on other sites More sharing options...
Redsign Posted March 21, 2008 Share Posted March 21, 2008 I was thinking this the other day! Like how it works (good job!), but as you said it needs to be presented differently- I think the drop downs need changing somehow, although for the life of me I can't think how... Ben 0 Quote Link to comment Share on other sites More sharing options...
zigzam Posted March 21, 2008 Share Posted March 21, 2008 Great idea. I also recommend that you get rid of the current table. I'm not sure how you could change it, but right now its a little overwhelming. 0 Quote Link to comment Share on other sites More sharing options...
Brett Posted March 21, 2008 Author Share Posted March 21, 2008 See, that is where I am stuck... I just don't know how to design it so it looks "nice". Any other suggestions? 0 Quote Link to comment Share on other sites More sharing options...
Redsign Posted March 21, 2008 Share Posted March 21, 2008 I think chickendippers suggestion would work, kinda show the list as WHMCS currently does, just with repeated suggestions for different TLD's. Goodluck, and thanks for the contrib Ben 0 Quote Link to comment Share on other sites More sharing options...
nielsenj Posted March 21, 2008 Share Posted March 21, 2008 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. 0 Quote Link to comment Share on other sites More sharing options...
Lucas Posted March 21, 2008 Share Posted March 21, 2008 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. 0 Quote Link to comment Share on other sites More sharing options...
Brett Posted March 21, 2008 Author Share Posted March 21, 2008 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? 0 Quote Link to comment Share on other sites More sharing options...
bear Posted March 22, 2008 Share Posted March 22, 2008 Nice work, Brett... /subscribes to thread 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted March 22, 2008 Share Posted March 22, 2008 Just give us the stock code and leave the "prettyness" to the user. You really shouldnt be making it "pretty" for competitors anyway. Isnt that how matt does it with whmcs templates? =P 0 Quote Link to comment Share on other sites More sharing options...
othellotech Posted March 23, 2008 Share Posted March 23, 2008 looking good, although a little confused why the top serach checks com/net/org, but the suggestions are com/net/tv post the code and we can all have a "play" with the layout/styling ... 0 Quote Link to comment Share on other sites More sharing options...
Brett Posted March 23, 2008 Author Share Posted March 23, 2008 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. 0 Quote Link to comment Share on other sites More sharing options...
Brett Posted March 23, 2008 Author Share Posted March 23, 2008 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. 0 Quote Link to comment Share on other sites More sharing options...
SilverNodashi Posted March 31, 2008 Share Posted March 31, 2008 nice mod! How will it work if I use eNom and other registrars? 0 Quote Link to comment Share on other sites More sharing options...
Brett Posted March 31, 2008 Author Share Posted March 31, 2008 It would have no effect if you are using other registrars. It just uses your eNom account to query eNom and displays a list of recommendations. 0 Quote Link to comment Share on other sites More sharing options...
SilverNodashi Posted April 5, 2008 Share Posted April 5, 2008 ok, but it won't work with domains that eNom can't query / register, right? 0 Quote Link to comment Share on other sites More sharing options...
Brett Posted April 5, 2008 Author Share Posted April 5, 2008 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. 0 Quote Link to comment Share on other sites More sharing options...
InterWebUK Posted May 14, 2008 Share Posted May 14, 2008 Hi Brett, can this be made to use the Domain Tools | Name Spinner API, which is where Enom gets it from. Thanks John 0 Quote Link to comment Share on other sites More sharing options...
Brett Posted May 14, 2008 Author Share Posted May 14, 2008 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. 0 Quote Link to comment Share on other sites More sharing options...
nowares Posted August 2, 2008 Share Posted August 2, 2008 This is a great idea! Good work guys, just need to integrate it somewhere now. 0 Quote Link to comment Share on other sites More sharing options...
wyatt121 Posted August 11, 2008 Share Posted August 11, 2008 Anyone try to integrate this with opensrs? Wyatt 0 Quote Link to comment Share on other sites More sharing options...
fetish-hosting Posted February 23, 2009 Share Posted February 23, 2009 Hi Brett Havent implemented this yet but am interested as I think it would be a great add-on. Is there likely to be a further releases / bug fixes in the future Thanks Ian 0 Quote Link to comment Share on other sites More sharing options...
Brett Posted February 23, 2009 Author Share Posted February 23, 2009 I will be releasing updates in about 2-3 months. I have been working on some other projects, but will be getting back the this project soon. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.