Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 31

Thread: Enom account balance in whmcs admin cp

  1. #16
    Join Date
    Sep 2006
    Location
    UK - Manchester
    Posts
    241

    Default enom balance

    I use this to show the enom balance in whmcs admin. it ain't pretty but it works.

    <?php
    $url = "http://reseller.enom.com/interface.asp?command=GetBalance&uid=userid&pw=pas sword&paramname=AvailableBalance&responsetype=text ";

    $str = file_get_contents($url);
    $str = substr($str, 91, 6);
    echo "Enom Avail Balance: $$str";
    ?>

    change the userid and password and upload it to the whmcs folder. you can add it to the admin templates using
    {php}include('/home/username/public_html/whmcs/enombalance.php'); {/php}

    or do what i do and just place a link to open the file in a new window. then if your in whmcs and want to check your enom balance you can.

  2. #17
    Join Date
    Sep 2006
    Location
    UK - Manchester
    Posts
    241

    Default

    here is a better way than what i posted above:

    <?php
    $url = "http://reseller.enom.com/interface.asp?command=GetBalance&uid=userid&pw=pas sword&paramname=AvailableBalance&responsetype=text ";
    $string = file_get_contents($url);
    $newstring =strstr ($string, "AvailableBalance=");
    $newstring2 = substr($newstring, 0, strpos($newstring, "Price="));
    $newstring3 = str_replace("AvailableBalance=", "Enom Balance:-$", $newstring2 );
    echo "$newstring3";
    ?>

  3. #18
    Join Date
    Feb 2007
    Location
    London, United Kingdom.
    Posts
    3,891

    Default

    $newstring =strstr ($string, strpos($string,"AvailableBalance="));
    Rob Golding UK Web Hosting est 1996 - Cloud/VPS/Servers in own UK London Docklands DataCentre - ICANN Accredited Registrar (PM me for a free WHMCS domain reseller module)
    WHMCS Modules: Registrars:CentralNIC, RRPProxy, AstutiumDomains, Cacti Bridge, APC/Raritan Power Control, Linux-Ensim, DNS Manager, VAT Reports, Samba Control

  4. #19
    Join Date
    Sep 2007
    Posts
    268

    Default

    Quote Originally Posted by othellotech View Post
    $newstring =strstr ($string, strpos($string,"AvailableBalance="));
    I don't get it.. what is this doing differently?

  5. #20
    Join Date
    Feb 2007
    Location
    London, United Kingdom.
    Posts
    3,891

    Default

    Quote Originally Posted by apollo1 View Post
    I don't get it.. what is this doing differently?
    my code cuts the string at the position of the text.

    the original code does nothing on some versions of php, so you get a whole load of the responses of the API also shown along with the balance.

    just makes it work more genericly.
    Rob Golding UK Web Hosting est 1996 - Cloud/VPS/Servers in own UK London Docklands DataCentre - ICANN Accredited Registrar (PM me for a free WHMCS domain reseller module)
    WHMCS Modules: Registrars:CentralNIC, RRPProxy, AstutiumDomains, Cacti Bridge, APC/Raritan Power Control, Linux-Ensim, DNS Manager, VAT Reports, Samba Control

  6. #21
    Join Date
    Feb 2007
    Location
    London, United Kingdom.
    Posts
    3,891

    Default

    and if you want to extend your "registrar" information on the homepage, you can add domains registered/expired (and compare it to the WHMCS counts for the same) ...

    {php}include('-path-to-whmcs/admin/templates/enombalance.php'); {/php}

    Code:
    <?php
    $enomuser = "youruser";
    $enompassword="yourpass";
    $enomurl = "http://reseller.enom.com/interface.asp?command=GetDomainCount&uid=$enomuser&pw=$enompassword&responsetype=text";
    $enomstr = file_get_contents($enomurl); //echo "$enomstr";
    
    // get registered count
    $enomstr2 = substr($enomstr, strpos($enomstr, "RegisteredCount="));
    $enomstr2 = substr($enomstr2, 0, strpos($enomstr2, "HostCount="));
    $count_registered = str_replace("RegisteredCount=", "", $enomstr2 );
    
    // get expired count
    $enomstr2 = substr($enomstr, strpos($enomstr, "ExpiredDomainsCount="));
    $enomstr2 = substr($enomstr2, 0, strpos($enomstr2, "RegisteredCount="));
    $count_expired = str_replace("ExpiredDomainsCount=", "", $enomstr2 );
    
    // show WHMCS counts
    // select status, count(*) from tbldomains group by status order by status;
    
    $registered_count=0;
    $query = "SELECT COUNT(*) FROM tbldomains WHERE status='Active' AND registrar='enom'";
    $result = mysql_query($query);
    $data = mysql_fetch_array($result);
    $registered_count=$data['COUNT(*)'];
    
    $expired_count=0;
    $query = "SELECT COUNT(*) FROM tbldomains WHERE status='Expired' AND registrar='enom'";
    $result = mysql_query($query);
    $data = mysql_fetch_array($result);
    $expired_count=$data['COUNT(*)'];
    
    echo "$count_registered ($count_expired) | WHMCS:$registered_count ($expired_count)";
    ?>
    Rob Golding UK Web Hosting est 1996 - Cloud/VPS/Servers in own UK London Docklands DataCentre - ICANN Accredited Registrar (PM me for a free WHMCS domain reseller module)
    WHMCS Modules: Registrars:CentralNIC, RRPProxy, AstutiumDomains, Cacti Bridge, APC/Raritan Power Control, Linux-Ensim, DNS Manager, VAT Reports, Samba Control

  7. #22
    Join Date
    Mar 2008
    Posts
    103

    Default

    Instead of doing loads of those str_pos, here's the same thing in 4 lines

    PHP Code:
    <?php
        $url 
    "http://reseller.enom.com/interface.asp?command=GetBalance&uid=ENOMUSERNAME&pw=ENOMPASSWORD&paramname=AvailableBalance&responsetype=text ";
        
    $string file_get_contents($url);
        
    preg_match("/AvailableBalance\=([0-9.]*)/"$string$match);
        echo 
    'Enom Balance:-$' $match[1];
    ?>

  8. #23
    Join Date
    Sep 2006
    Location
    UK - Manchester
    Posts
    241

    Default

    Thanks ben. It works perfectly.

  9. #24
    Join Date
    Sep 2007
    Posts
    268

    Default

    Quote Originally Posted by othellotech View Post
    my code cuts the string at the position of the text.
    My server is running PHP 5.2.5... I tried your code and it didn't produce any output at all. The code posted by SimplyBe worked just fine.

  10. #25
    Join Date
    Mar 2008
    Posts
    103

    Default

    Quote Originally Posted by simplybe View Post
    Thanks ben. It works perfectly.
    No problem.

    Regular Expressions can be fantastically useful things - all kinds of uses and infinitely expandable

  11. #26
    Join Date
    Jun 2007
    Posts
    886

    Default

    Quote Originally Posted by othellotech View Post
    and if you want to extend your "registrar" information on the homepage, you can add domains registered/expired (and compare it to the WHMCS counts for the same) ...

    {php}include('-path-to-whmcs/admin/templates/enombalance.php'); {/php}

    Code:
    <?php
    $enomuser = "youruser";
    $enompassword="yourpass";
    $enomurl = "http://reseller.enom.com/interface.asp?command=GetDomainCount&uid=$enomuser&pw=$enompassword&responsetype=text";
    $enomstr = file_get_contents($enomurl); //echo "$enomstr";
    
    // get registered count
    $enomstr2 = substr($enomstr, strpos($enomstr, "RegisteredCount="));
    $enomstr2 = substr($enomstr2, 0, strpos($enomstr2, "HostCount="));
    $count_registered = str_replace("RegisteredCount=", "", $enomstr2 );
    
    // get expired count
    $enomstr2 = substr($enomstr, strpos($enomstr, "ExpiredDomainsCount="));
    $enomstr2 = substr($enomstr2, 0, strpos($enomstr2, "RegisteredCount="));
    $count_expired = str_replace("ExpiredDomainsCount=", "", $enomstr2 );
    
    // show WHMCS counts
    // select status, count(*) from tbldomains group by status order by status;
    
    $registered_count=0;
    $query = "SELECT COUNT(*) FROM tbldomains WHERE status='Active' AND registrar='enom'";
    $result = mysql_query($query);
    $data = mysql_fetch_array($result);
    $registered_count=$data['COUNT(*)'];
    
    $expired_count=0;
    $query = "SELECT COUNT(*) FROM tbldomains WHERE status='Expired' AND registrar='enom'";
    $result = mysql_query($query);
    $data = mysql_fetch_array($result);
    $expired_count=$data['COUNT(*)'];
    
    echo "$count_registered ($count_expired) | WHMCS:$registered_count ($expired_count)";
    ?>
    Mine didn't work with this code, I'm running PHP 5.2.5.

  12. #27
    Join Date
    Sep 2006
    Location
    UK - Manchester
    Posts
    241

    Default

    EDIT>>>>
    never mind i misread a post

  13. #28
    Join Date
    Feb 2007
    Location
    London, United Kingdom.
    Posts
    3,891

    Default

    Quote Originally Posted by BAJI26 View Post
    Mine didn't work with this code, I'm running PHP 5.2.5.
    you did the obvious thing of putting your enom username and password in the 1st two fields ?
    just run it from ssh and see what output you get, uncomment the echo at the top and look at what that returns
    Rob Golding UK Web Hosting est 1996 - Cloud/VPS/Servers in own UK London Docklands DataCentre - ICANN Accredited Registrar (PM me for a free WHMCS domain reseller module)
    WHMCS Modules: Registrars:CentralNIC, RRPProxy, AstutiumDomains, Cacti Bridge, APC/Raritan Power Control, Linux-Ensim, DNS Manager, VAT Reports, Samba Control

  14. #29
    Join Date
    Jun 2008
    Location
    South West Florida, USA
    Posts
    48

    Default

    Just wondering why it was set to run on http, instead of https?

  15. #30
    Join Date
    Sep 2007
    Posts
    268

    Default

    Probably just a small oversight. Add an 's' and you good to go!

Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. WHMCS - Users current account balance
    By arctic-ice-cool in forum Customisation & Integration Questions
    Replies: 3
    Last Post: 04-07-13, 09:14 PM
  2. Show Clients Account Balance outside of WHMCS
    By sitewes in forum Customisation & Integration Questions
    Replies: 0
    Last Post: 10-05-09, 11:54 PM