keliix06 Posted August 7, 2009 Share Posted August 7, 2009 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 0 Quote Link to comment Share on other sites More sharing options...
lemurtech Posted December 29, 2009 Share Posted December 29, 2009 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'); ?> 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.