Page 1 of 12 12311 ... LastLast
Results 1 to 15 of 173

Thread: New Enom Name Spinner

  1. #1

    Thumbs up New Enom Name Spinner

    Here is template code to use Enom's Namespinner on your adddomain.tpl

    Features:
    • Only displays when ordering a new domain name
    • Uses live pricing from your database
    • Formatted to match WHMCS's bulk domain checker layout
    • Uses SSL connection to enom for better securrity
    • Does not suggest unavailable domain names


    Limitations:
    • Requires PHP5, cUrl and SimpleXML
    • Will not output anything if there was an error communicating with Enom
    • Because of the complexity of pulling encrypted passwords from WHMCS's database, you still need to put your Enom username and password into the appropriate variables.


    Installing:
    Insert this code between the line:
    Code:
    <p align="center"><input type="submit" value="{$LANG.addtocart}" /></p>
    and
    Code:
    </form>
    The code to insert:
    Code:
    {if $domain neq "transfer"}
    	{php}
    		/**
    		 * @version 1.0
    		 * @since WHMCS 3.8
    		 * @copyright 2009 http://ideamesh.com This script is owned and licensed by Ideamesh, Inc.
    		 * You may use this script in commercial applications, however you may not resell
    		 * this script without permission of Ideamesh, Inc.<br>
    		 * Please contact (sales [at] ideamesh [dot] com) for more information
    		 */
    
    		// Extract Smarty variables
    		extract($this->_tpl_vars);
    
    		//Edit these to your actual enom username and password
    		$enomid = "enomuser";
    		$enompw = "enompass";
    
    		//Max number of spins to generate
    		$maxspins = 20;
    
    		//Choose which options to show in the spin results
    		$showdotcom = true;
    		$showdotnet = true;
    		$showdotcc = false;
    		$showdottv = false;
    
    		//Set this to "True" for blocking sensitive content or "False" to allow sensitive content
    		$sensitivecontent = "True";
    
    		//Setup the namespinner url
    		$namespinnerurl = "https://reseller.enom.com/interface.asp?command=namespinner&uid=".$enomid."&pw=".$enompw."&SLD=".$sld."&TLD=".$tld."&SensitiveContent=".$sensitivecontent."&MaxResults=".$maxspins."&ResponseType=XML";
    
    		// Use cURL to get the XML response
    		$ch = curl_init($namespinnerurl);
    		curl_setopt($ch, CURLOPT_HEADER, false);
    		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    		$xml = curl_exec($ch);
    		curl_close($ch);
    
    		if ($xml) {
    			$spinnerresults = new SimpleXmlElement($xml, LIBXML_NOCDATA);
    
    			if ($spinnerresults->ErrCount == 0) {
    				for($i=0; $i<$maxspins; $i++){
    					if ($showdotcom && (string)$spinnerresults->namespin->domains->domain[$i]['com'] == "y")
    						$spinner[] = array(
    							'domain' => (string)$spinnerresults->namespin->domains->domain[$i]['name'].".com",
    							'sld' => (string)$spinnerresults->namespin->domains->domain[$i]['name'],
    							'tld' => '.com');
    					if ($showdotnet && (string)$spinnerresults->namespin->domains->domain[$i]['net'] == "y")
    						$spinner[] = array(
    							'domain' => (string)$spinnerresults->namespin->domains->domain[$i]['name'].".net",
    							'sld' => (string)$spinnerresults->namespin->domains->domain[$i]['name'],
    							'tld' => '.net');
    					if ($showdotcc && (string)$spinnerresults->namespin->domains->domain[$i]['cc'] == "y")
    						$spinner[] = array(
    							'domain' => (string)$spinnerresults->namespin->domains->domain[$i]['name'].".cc",
    							'sld' => (string)$spinnerresults->namespin->domains->domain[$i]['name'],
    							'tld' => '.cc');
    					if ($showdottv && (string)$spinnerresults->namespin->domains->domain[$i]['tv'] == "y")
    						$spinner[] = array(
    							'domain' => (string)$spinnerresults->namespin->domains->domain[$i]['name'].".tv",
    							'sld' => (string)$spinnerresults->namespin->domains->domain[$i]['name'],
    							'tld' => '.tv');
    				}
    				$gotnamespinner = true;
    			} else {
    				$gotnamespinner = false;
    			}
    		} else {
    			$gotnamespinner = false;
    		}
    
    		//Get domain pricing for .com, .net, .cc and .tv
    		$sql = "SELECT extension, register, registrationperiod FROM tbldomainpricing WHERE extension in ('.com', '.net', '.cc', '.tv');";
    		$query = mysql_query ($sql);
    		while ($row = @mysql_fetch_array ($query, MYSQL_ASSOC)) {
    			$domainprices[$row['extension']][$row['registrationperiod']] = $row['register'];
    		}
    
    		//Send some variables back to the template
    		$this->assign('spinner', $spinner);
    		$this->assign('gotnamespinner', $gotnamespinner);
    		$this->assign('domainprices', $domainprices);
    	{/php}
    
    	{if $gotnamespinner}
    		<p class="cartsubheading">We also recommend</p>
    
    		<table class="clientareatable" style="width:90%;" align="center" cellspacing="1">
    		<tr class="clientareatableheading"><td>{$LANG.domainname}</td><td>{$LANG.domainstatus}</td><td>{$LANG.domainmoreinfo}</td></tr>
    		{foreach key=num item=result from=$spinner}
    			<tr class="clientareatableactive">
    				<td width="33%">{$result.domain}</td>
    				<td width="33%" class="domaincheckeravailable"><input type="checkbox" name="domains[]" value="{$result.domain|lower}"{if $result.domain|lower|in_array:$domains} checked{/if} /> {$LANG.domainavailable}</td>
    				<td width="33%"><select name="domainsregperiod[{$result.domain|lower}]">
    					{assign var=thistld value=$result.tld}
    					{foreach key=years item=regoption from=$domainprices.$thistld}
    						<option value="{$years}">{$years} {$LANG.orderyears} @ {$currencysymbol}{$regoption} {$currency}</option>
    					{/foreach}</select>
    				</td>
    			</tr>
    		{/foreach}
    		</table>
    
    		<p align="center"><input type="submit" value="{$LANG.addtocart}" /></p>
    	{/if}
    {/if}
    Final steps:
    • Edit the variables $enomid and $enompw
    • Change $maxspins variable to adjust number of suggested names
    • Change $showdotcom, $showdotnet, $showdotcc, $showdottv to your liking


    Try it out here: https://ideamesh.com/cart.php?a=add&domain=register

    Hope you enjoy it! Please see my note on securing your .tpl files using .htaccess at : http://forum.whmcs.com/showthread.php?p=96394
    Last edited by WebWorker; 03-15-09 at 09:59 PM.

  2. #2

    Default

    Can anyone help me figure out how to add this to the wiki? Lol

    Every time I try to edit the contributions page, it shows a blank edit screen with none of the current content.
    Last edited by WebWorker; 03-15-09 at 10:01 PM.

  3. #3
    Join Date
    May 2006
    Posts
    2,547

    Default

    how about putting the enom information within a regular php file and then just including that? Its a bit more secure that way that just putting it within the templates. I know i can do it and will, just figured you might want to add that for others.
    DISCLAIMER: I am in no way associated with WHMCS. My statements only come from years of programming, experience using WHMCS, and just my honest opinion.

  4. #4
    Join Date
    Jul 2008
    Posts
    82

    Default

    Here you go m8 made a wiki page for you:

    Contribution:Enom_Name_Spinner

    Should you wish to edit it just go to that page and click the edit button up top.

  5. #5
    Join Date
    Nov 2008
    Posts
    138

    Default

    Quote Originally Posted by MACscr View Post
    how about putting the enom information within a regular php file and then just including that? Its a bit more secure that way that just putting it within the templates. I know i can do it and will, just figured you might want to add that for others.
    After you do are you going to share it?

  6. #6

    Default

    Simply create a second file called enomlogin.php and put these three lines in there between the php tags:
    Code:
    <?php
    //Edit these to your actual enom username and password
    $enomid = "enomuser";
    $enompw = "enompass";
    ?>
    Then replace those three lines from the template with:
    Code:
    include('/path/to/enomlogin.php');

  7. #7
    Join Date
    Nov 2008
    Posts
    138

    Default

    It is not working for me.

    I have tried a domain regrwxjerj.com on your demo link and it works fine I have tried the same on mine and no good it doesn't return anything at all.

    I have also made sure I have the paths set correctly for the enomlogin.php

    I do have the PHP, curl, simplexml installed.

    I also have a custom theme could this be the problem?
    I have made the changes to the adddomain.tpl in the order forms>>default folder as this is what I have set in the config.

  8. #8

    Default

    If you are testing on a development box you need to make sure that you have authorized it's IP address at enom for API access.

  9. #9
    Join Date
    Nov 2008
    Posts
    138

    Default

    Not on a development box, ENOM IP authorized also.

  10. #10

    Default

    After the line:

    Code:
    curl_close($ch);
    Add this


    Code:
    echo "<pre>";
    echo htmlentities($xml);
    echo "</pre>";
    To see the xml response from enom

  11. #11
    Join Date
    Nov 2008
    Posts
    138

    Default

    Hello WebWorker I have changed everything back and then added the code from your original post and it is working. So at least we know it is all good.

    I am trying to set it up with the include and that is not working so it has to be something with the paths, I will mess with it a bit until I get the path that is correct not sure why thisone is giving me a hard time I have set the paths for a couple of other little things and no problems so I will just reproduce that.

    Thanks again great addition.

  12. #12
    Join Date
    Nov 2008
    Posts
    138

    Default

    Now it would be great if we could get the output "We also recommend" results sorted by extension rather than alphabetically.

  13. #13

    Default

    You can use the php command getcwd() to see where the script thinks it currently is and adjust the path relative to that. Otherwise do the full path /home/username/public_html/whmcs/enomlogin.php

  14. #14
    Join Date
    Nov 2008
    Posts
    138

    Default

    I found my problem I added
    PHP Code:
    $showdotinfo true
    and messed up the
    PHP Code:
    if ($showdotcom && (string)$spinnerresults-> 
    part stupid mistake on my part but once I fixed it all is working just fine path is all good.

  15. #15

    Default

    Enom only gives results for the four TLD's I provided in the code. You won't be able to add extra TLD's unless you figure out some other namespinner code.

Page 1 of 12 12311 ... LastLast

Similar Threads

  1. Enom Name Spinner
    By wildman in forum Customisation and Integration Questions
    Replies: 0
    Last Post: 05-12-11, 11:26 AM
  2. domain name spinner?
    By tiameg in forum Technical Issues and Questions
    Replies: 0
    Last Post: 06-16-09, 01:54 AM
  3. Name Spinner: Domain Name Suggestions (eNom)
    By Brett in forum User Contributions
    Replies: 30
    Last Post: 03-15-09, 09:45 PM
iron-diatonic