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.

detailed php account creation scripts

Discussion in 'General Discussion' started by dululu, Jan 1, 2003.

  1. dululu

    dululu Member

    Joined:
    Dec 29, 2002
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Are there any detailed php account creation scripts? The one example available here http://www.cpanel.net/manual/remoteaccess-php.html is almost useless. I'm mostly interested in account creation and deletion scripts.

    Instructions on how to use them when PHP is in safe mode would also be greatly appreciated.
     
  2. jimcarter

    jimcarter Well-Known Member

    Joined:
    Jun 30, 2002
    Messages:
    152
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    UK
    Hello,
    the cpanel one should meet your needs,
    to create an account you just do:
    &?php
    require '/usr/local/cpanel/Cpanel/Accounting.php.inc';
    $host = &localhost&;
    $user = &&USERNAME HERE&&;
    $accesshash = '&REMOTE ACCESS KEY HERE&';
    createacct ($host,$user,$accesshash,$usessl,$acctdomain,$acctuser,$acctpass,$acctplan);
    ?&
    That will create an account with package acctplan, with username acctuser, domain acctdomain and password acctpass,
    the usessl variable is just whether to use SSL for the script to create the account,
    if you were looking for something a bit more sophisticated then you should try www.nixt.org for a free solution, and www.phpmanager.com and www.modernbill.com for paid solutions,
    thanls :)
     
  3. Darth

    Darth Member

    Joined:
    Dec 24, 2002
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Could someone make a form so the user can specify the plan, domain, username, password.

    Thanks! :)
     
  4. dululu

    dululu Member

    Joined:
    Dec 29, 2002
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Thanks jimcarter

    Thanks a lot for the info. I'll try it immediately and post results.

    Thanks and a happy new year to everyone
     
  5. dululu

    dululu Member

    Joined:
    Dec 29, 2002
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Used the script but the accounts are not being created. Is there any way of checking where the error is, so I can at least try to debug it? Following the perl examples I've tried using
    [b:c11c7dfbc6]$result = createacct($host,$user,$accesshash,$usessl,$acctdomain,$acctuser,$acct
    pass,$acctplan); [/b:c11c7dfbc6] , but [b:c11c7dfbc6] echo $result; [/b:c11c7dfbc6] shows blank.
     
  6. dululu

    dululu Member

    Joined:
    Dec 29, 2002
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Update

    Changing [b:4c6718386c]$usessl[/b:4c6718386c] to 0 now results in the following message from createacct : [b:4c6718386c]Account Creation Complete!!![/b:4c6718386c]. Problem is that the account is not created. It doesn't show up when I refresh the accounts list in WHM and it is not on disk.

    Any thoughts?
     
  7. jimcarter

    jimcarter Well-Known Member

    Joined:
    Jun 30, 2002
    Messages:
    152
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    UK
    check:
    that the username is not taken,
    that the plan you have specified is spelled correctly, I think that it is case sensitive,
    the username is not longer than 8 characters and doesnt begin with a number,
    that all the fields are correctly filled in
    let us know how you get on please
     
  8. dululu

    dululu Member

    Joined:
    Dec 29, 2002
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Clarification

    I'm assuming that plan == package, and I'm using the package names. I take it that's correct.
     
  9. dululu

    dululu Member

    Joined:
    Dec 29, 2002
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    jimcarter, u de man

    Thanks a lot. The problem was indeed with the package names. The creation now works.

    Once again, thank you.

    Strange thing now is that [b:1de8c33858] echo $result;[/b:1de8c33858] is showing blank again. Previously it would say that the account was created when it wasn't and now that the account is being created its not showing anything.

    Should I file this as a bug or am I doing something wrong?
     
  10. jimcarter

    jimcarter Well-Known Member

    Joined:
    Jun 30, 2002
    Messages:
    152
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    UK
    no problem at all :)
    usually I get a result, but not always, it could be a bug I am not sure,
    I usually do this to check if the account has been created:
    $do = createacct($host,$user,$accesshash,$usessl,$acctdomain,$acctuser,$acctpass,$acctplan);
    if (!eregi(&wwwacct creation finished&,$do)){ echo &Error!&; } else { echo &Success!&; }
    thanks :)
     
  11. dululu

    dululu Member

    Joined:
    Dec 29, 2002
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Thanks again.

    Another issue is bulk addition. Would it be possible to add a large number of domains in bulk without the overhead (reloading / restarting of services)? The current scripts operate on one domain at a time.
     
  12. jimcarter

    jimcarter Well-Known Member

    Joined:
    Jun 30, 2002
    Messages:
    152
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    UK
    this shouldnt cause any problem, you would simply make a loop, e.g. if you were selecting multiple orders from a database you would get all of the domains, username and passwords etc into an array, and then for each of the items in the array you would run the account creation script
    thanks
     
  13. dululu

    dululu Member

    Joined:
    Dec 29, 2002
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    That's what I'm currently coding up, but management had a lot of issues with server downtime. We are trying to minimise the amount of Apache & other server downtime as a result of configuration file changes, so I was hoping for something that would allow me to add or modify everything I wanted to and then apache would get restarted once when I'm done.
     
  14. electric

    electric Well-Known Member

    Joined:
    Nov 5, 2001
    Messages:
    697
    Likes Received:
    1
    Trophy Points:
    18
    I get an error:[quote:3c98cad8ee]Access Denied[/quote:3c98cad8ee] when I try to run the script.

    I have cut/paste the access key directly from WHM into the script.. is there some special formatting I should follow to make it work? Should it be one big long line of characters?

    Thanks!
     
  15. dululu

    dululu Member

    Joined:
    Dec 29, 2002
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    I just copied it over. Are you sure that there are no spaces, etc between the start/end of the key and the quotation marks? If everything is failing you might want to regenerate the key and try using a new one
     
  16. aurelien

    aurelien Registered

    Joined:
    Mar 14, 2005
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    How to know if an acctuser is already used ?

    Hi!

    All is in the title...
    Is there a function to know easily and quickly if an acctuser is already used, or may i have to write a code with listaccts ?

    Thanks a lot !
     
Loading...

Share This Page