The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Why is an account of unlimited space and bandwidth being created, if I'm my package has limits?

Discussion in 'cPanel Developers' started by desbest, Jan 13, 2014.

  1. desbest

    desbest Member

    Joined:
    Jan 7, 2009
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    My php code uses this to create a cpanel account.
    PHP:
    $task2=$whm->createAccount('testdomain.com','testuser','changeme','testpassword123','hostingz_HL5');
    The package has 500MB space and 1500MB bandwidth.
    /http://imageshack.com/a/img6/5731/qgp4.png

    But when I check my email or the account created in WHM, it says that the account has unlimited space and bandwidth.
    /http://imagizer.imageshack.us/v2/800x600q90/43/r6m8.png

    How can I stop this unlimited space and bandwidth giving, and have WHM respect the package's limits when creating an account?
     
    #1 desbest, Jan 13, 2014
    Last edited: Jan 14, 2014
  2. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    In that account creation email, the package is HL5 not hostingz_FH5. If you've copied and pasted the php code, you are missing a closing single quote after the package name.

    It's not clear how you are calling the API as I'm not familiar with the $whm object you are using but you may want to follow the createacct example in the Examples for cPanel's PHP API class: https://github.com/CpanelInc/xmlapi-php
     
  3. desbest

    desbest Member

    Joined:
    Jan 7, 2009
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    I've updated the post to get rid of the php error and update the image.
    I'd prefer not to use Cpanel's php api class, because when creating an account, it doesn't allow the developer to choose the hosting package the person wants. https://github.com/CpanelInc/xmlapi-php/blob/master/xmlapi.php#L944

    I'm using Cpanel's 2004 accounting.php.inc for my script in other places, but as createacct doesn't work in accounting.php.inc, I'm using whm.php from Php Classes in this instance.
     
    #3 desbest, Jan 14, 2014
    Last edited: Jan 14, 2014
  4. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    Please post the source of $whm->createAccount(). That appears to be a custom function you wrote so without us seeing the code, we have no idea what it does or why it's going wrong.

    Thanks!
     
  5. MesinHosting

    MesinHosting Member

    Joined:
    Mar 25, 2011
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    from what i know. cpanel api
    (/https://github.com/CpanelInc/xmlapi-php/blob/master/xmlapi.php)

    can be use to create and modify such as change package cpanel account as well. and, from what we have know, php was run very fast. so i think, based on that opinion, call the createacct can be run first, and after that you can update for the package.

    modify an account can be done based on changepackage function
    (/https://github.com/CpanelInc/xmlapi-php/blob/master/xmlapi.php#L1203)

    create account can be done based on function createacct
    (/https://github.com/CpanelInc/xmlapi-php/blob/master/xmlapi.php#L956)

    this will i do, if i were in your position

    PHP:
    include_once ('xmlapi.php');
    $call = new xmlapi($ip);
    $call -> password_auth('root',$yourpassword);
    $call -> set_debug(1);
    $account = array(username => 'theusername',password => 'thepassword',domain => 'thedomain.tld');
    $call -> createacct($account);
    $call -> changepackage('theusername','package_name');
    hope that's help
     
  6. desbest

    desbest Member

    Joined:
    Jan 7, 2009
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Thanks for the code sample. I'll try the code sample if the whm.php class file cannot be used.
    I never thought about using code to change the package, after the account is created.

    Here's the whm.php file code I was using.
    The problem is that even when I specify the package to use when creating the hosting account, it creates an unlimited account instead of respecting the package I chose to use.
     
  7. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,461
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Our API class does let your specify a package during account creation. As the documentation you linked to states:
    Documentation for createaccount is here: Create an Account — createacct

    This means you can construct a function call like:

    Code:
    include_once ('xmlapi.php'); 
    $call = new xmlapi($ip); 
    $call -> password_auth('root',$yourpassword); 
    $call -> set_debug(1); 
    $account = array(username => 'theusername',password => 'thepassword',domain => 'thedomain.tld', 'plan' => 'my_plan'); 
    $call -> createacct($account); 
    
     
  8. fabioliotta

    fabioliotta Registered

    Joined:
    Feb 23, 2014
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    i have the same problem, if i use 'quota'

    example
    $account = array(username => 'theusername', password => 'thepassword', domain => 'thedomain.tld', 'quota' => '3500');

    doesn't working, if i check WHM i see unlimited as quota instead of 3500

    How is possible fixing this problem ?

    any help please?

    thanks in advance
     
Loading...

Share This Page