Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 15 of 39
  1. #1
    Member
    Join Date
    Jan 2002
    Location
    UK
    Posts
    248

    Default Cpanel PHP Accounting functions

    I notice that the Perl version of the accounting has been expanded quite significantly to include a whole list of new integration features.

    Any chance the same will be done to the PHP version soon?

    Thanks.

  2. #2
    Member
    Join Date
    Jun 2002
    Location
    UK
    Posts
    152

    Default

    Hi,
    I dont see any extra features with the perl accounting module,
    however, if you post the extra features you have found I would be happy to add them into the php accounting module for you,
    Thanks

  3. #3
    Member
    Join Date
    Jun 2002
    Location
    UK
    Posts
    152

    Default

    By the way, if anyone else would like some extra functions for the accounting module, I heard that some people wanted password modification features etc, I would be happy to add them,
    when tested working maybe the cpanel staff will add the new file into the distribution so its easier for everyone

  4. #4
    gic
    gic is offline
    Member
    Join Date
    Jun 2002
    Posts
    69

    Default

    Yes. Thanks to jimcarter, I too now understand how this stuff works. If you need functions written, let me know. I have upgrade/downgrade, password mod, create, remove, and I am going to setup suspend/unsuspend. They are very easy to understand.

    I can also create new functions for you.

  5. #5
    Member
    Join Date
    Jan 2002
    Location
    UK
    Posts
    248

    Default

    Ok, I consider myself fairly proficient in PHP.

    Any chance you guys could give us a rundown on how these little babies work?

  6. #6
    gic
    gic is offline
    Member
    Join Date
    Jun 2002
    Posts
    69

    Default

    Okay. The two parts. First off is how to use the fuctions. That is pretty straight forward. We will use the createacct for an example.

    PHP Code:
    <?
    require '/usr/local/cpanel/Cpanel/Accounting.php.inc';
        
    $host "localhost";
        
    $user "root";
        
    $accesshash 'ACCESS HASH SHOULD BE PASTED HERE';    
        
    $usessl "0";

    $do createacct($host,$user,$accesshash,$usessl,$acctdomain,$acctuser,$acctpass,$acctplan);
    if (!
    eregi("wwwacct creation finished",$do)){
        echo 
    "Oh no.  There was a problem.";
    }
    else {
        echo 
    "Great, the account $acctuser was created successfully.";
    }
    ?>
    For this example, all that you need to give it are:
    $host = your hostname (usually localhost)
    $user = your WHM username (either root or reseller name)
    $accesshash = the access hash pasted directly from WHM
    $usessl = 1 means to use cURL, 0 means to use socket_connect
    $acctdomain = the domain name of the new account
    $acctuser = the username of the new account
    $acctpass = the password of the new account
    $acctplan = the plan name of the new account. (if the plan name has a space, replace it with a + sign)

    Just send those variable to this PHP file and it will create the account. If the account is created, it says "Great, the account $acctuser was created successfully". Otherwise it says "Oh no. There was a problem".

    -----------------

    Next, we look at functions... This came out of my Accounting.php.inc file.
    PHP Code:
    function changepass ($host,$user,$accesshash,$usessl,$acctpass,$acctuser) {
        
    $result whmreq("/scripts/passwd?remote=1&nohtml=1&password=${acctpass}&domain=${acctuser}&user=${acctuser}&submit-domain=Change%0D%0A++++++Password",$host,$user,$accesshash,$usessl);
        if (
    $cpanelaccterr != "") { return; }
        return 
    $result;

    This is a new function that I made. It allows you to change the password of an account.

    The part after result (/scripts/passwd) was taken directly from WHM when you submit the form to change the password. Then I inlclude the variables that the password script needs.

    Now, I just have to provide the following in a PHP file:
    PHP Code:
    <?
    require '/usr/local/cpanel/Cpanel/Accounting.php.inc';
        
    $host "localhost";
        
    $user "root";
        
    $accesshash 'ACCESS HASH GOES HERE';    
        
    $usessl "0";

    $do changepass($host,$user,$accesshash,$usessl,$acctpass,$acctuser);
    if (
    eregi("syntax mismatch",$do)){
        echo 
    "OOps, you broke it.  I don't think that the username was correct.";
    }
    else {
        echo 
    "Great job!  Your password has been changed to $acctpass.";
    }
    ?>
    Okay, in the example above, you just provide:

    $host = hostname (localhost usually)
    $user = your WHM username (root or reseller name)
    $accesshash = the access hash directly from WHM
    $usessl = 1 means to use cURL, 2 means socket_connect
    $acctpass = the new password of the account in cpanel
    $acctuser = the username of the account you want to change

    If it is successful, it prints "Great job! Your password has been changed to $acctpass". If it isn't, it prints "OOps, you broke it. I don't think that the username was correct".

    If you have any other questions, post 'em here.

  7. #7
    Member
    Join Date
    Jan 2002
    Location
    UK
    Posts
    248

    Default

    Simply call to the /scripts or /scripts2 links that WHM uses during normal operations then?

    Seems simple, I shall give it a go

    Thanks!

  8. #8
    gic
    gic is offline
    Member
    Join Date
    Jun 2002
    Posts
    69

    Default

    yeppers

  9. #9
    Member
    Join Date
    Jan 2002
    Posts
    222

    Default

    Hi,

    Id like to see the ability to upgrade/downgrade, password modification and the creation/removal of reseller accounts.

    Anyone got these functions setup?

    Kind Regards,

    Neil

  10. #10
    Registered User
    Join Date
    Apr 2003
    Posts
    3

    Default

    I'm useing this exact same script (minus the code and the user), almost the very same example script that cpanel offers, but this thing doesn't work.

    <?php
    require '/usr/local/cpanel/Cpanel/Accounting.php.inc';
    $host2 = "localhost";
    $user2 = "<user here>";
    $usessl = "0";
    $accesshash = '<access here>';

    $pkgs = listpkgs($host2,$user2,$accesshash,0);
    print_r($pkgs);

    ?>

    Any thought as to why it might not work?

  11. #11
    Member
    Join Date
    Apr 2003
    Posts
    13

    Default yep

    Might be same problem I had.

    curl was not installed, and there is a bug with using new PHP and the Accounting scripts sockets part. I fixed the bug myself and tkoweb reported it.

  12. #12
    Member
    Join Date
    Oct 2002
    Posts
    94

    Default

    I would greatly appreciate it if someone was able to create a script to auto create reseller accounts. The current way of doing it a bit tedious and long.

  13. #13
    Member
    Join Date
    Jun 2002
    Location
    UK
    Posts
    152

    Default

    it is not too hard to do something like this depending on how you want the accounts to be automatically created, i.e. maybe you want them created through your billing system or something,
    unfortunately I dont feel like giving all my reseller scripts away
    thanks

  14. #14
    Member
    Join Date
    Jun 2003
    Location
    UK
    Posts
    23

    Default

    I used the code by gic to create accounts and filled in all the variables etc but the error it returned was 'Please use the this syntax wwwacct'.

    Anybody know what I should do to fix this?

    cPanel.net Support Ticket Number:

  15. #15
    Member
    Join Date
    Jun 2003
    Location
    UK
    Posts
    23

    Default

    Anyone? I need some help with this.

    Thanks.

    cPanel.net Support Ticket Number:

Similar Threads & Tags
Similar threads

  1. Accounting.inc.php Functions AND Definitions
    By Brett19 in forum cPanel and WHM Discussions
    Replies: 7
    Last Post: 01-28-2006, 11:48 PM
  2. PHP Accounting Functions
    By jlimited in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 12-27-2005, 08:26 PM
  3. Adding functions to Accounting.php.inc
    By giggsey in forum cPanel Developers
    Replies: 2
    Last Post: 08-05-2005, 07:22 AM
  4. Changing user email with PHP Accounting functions
    By remik in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 02-24-2005, 05:44 PM
  5. Accounting.php.inc functions
    By whiteadi in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 05-15-2004, 12:14 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube