Jump to content

Get your enom summary without slowing down WHMCS


keliix06

Recommended Posts

So enom was really slow earlier this week, so bad that I had to remove our code provided by the enom addon to get our account summary just to get into the WHMCS homepage. I knew I should be able to get to all of the data with ajax so as to keep WHMCS fast.

 

This is the code I used. I also load the PayPal balance using this, but that's mostly someone elses code so I won't include that here.

 

In /admin/templates/v4/header.tpl

 

Find

{literal}<script>
 $(document).ready(function(){

 

and just below that add

 

$("#financeajax").load("finance_ajax.php");

 

 

In /admin/templates/v4/homepage.tpl

 

Find

 

<div class="contentbox" style="font-size:18px;"><a href="transactions.php"><img src="images/icons/transactions.png" align="absmiddle" border="0"> <b>Income</b></a> Today: <span class="textgreen"><b>{$stats.income.today}</b></span> This Month: <span class="textred"><b>{$stats.income.thismonth}</b></span> This Year: <span class="textblack"><b>{$stats.income.thisyear}</b></span></div>

 

and just below that add

 

<br />
<div id="financeajax"></div>

 

 

Create a new file at /admin/finance_ajax.php and use the following code

 

<?php
include('enomajax.php');
?>
<link href="../modules/admin/enom_extended/templates/eestyle.css" rel="stylesheet" type="text/css" />
<div class="errorbox">eNom Summary   »   <span style="color:#000000;"> Balance: <?php echo $enom->Balance; ?>   -   Available Balance: <?php echo $enom->AvailableBalance; ?>   -   Active Domains: <?php echo $enom->DomainCount; ?></span></div>

 

 

Create a new file at /admin/enomajax.php and use the following code. Replace YOURUID and YOURPW accordingly. This would be better with cURL, which I'll probably work on today, but I threw this together in about 20 minutes, most of which was spent learning the enom API. This also uses simplexml, which I believe is PHP5 only, but it gets rid of about 50 lines of parsing code.

 

<?php
$write = file_get_contents('https://reseller.enom.com/interface.asp?command=GetBalance&uid=YOURUID&pw=YOURPW&responsetype=xml');
$fp = fopen('enom.xml','w');
fwrite($fp,$write);
fclose($fp);

$enom = simplexml_load_file('enom.xml');
?>

 

Now you should be able to go into your WHMCS homepage and after a couple of seconds you'll see the enom data load. Those are seconds that normally everything would have been waiting to load which is highly annoying. So in 10 lines of code life should now be better :D

Link to comment
Share on other sites

  • 4 months later...

Thanks for this, Doyle.

 

It took me a few minutes to figure out how to make it work. I needed to included a full path to a writeable tmp directory in enomajax.php, as follows:

 

<?php
$write = file_get_contents('https://reseller.enom.com/interface.asp?command=GetBalance&uid=myUserName&pw=myPassword&responsetype=xml');
$fp = fopen('/var/www/vhosts/myDomain/httpdocs/tmp/enom.xml','w');
fwrite($fp,$write);
fclose($fp);

$enom = simplexml_load_file('/var/www/vhosts/myDomain/httpdocs/tmp/enom.xml');
?>

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