detailed php account creation scripts

dululu

Member
Dec 29, 2002
11
0
151
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.
 

jimcarter

Well-Known Member
Jun 30, 2002
152
0
166
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 :)
 

Darth

Member
Dec 24, 2002
8
0
151
Could someone make a form so the user can specify the plan, domain, username, password.

Thanks! :)
 

dululu

Member
Dec 29, 2002
11
0
151
Thanks jimcarter

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

Thanks and a happy new year to everyone
 

dululu

Member
Dec 29, 2002
11
0
151
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.
 

dululu

Member
Dec 29, 2002
11
0
151
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?
 

jimcarter

Well-Known Member
Jun 30, 2002
152
0
166
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
 

dululu

Member
Dec 29, 2002
11
0
151
Clarification

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

dululu

Member
Dec 29, 2002
11
0
151
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?
 

jimcarter

Well-Known Member
Jun 30, 2002
152
0
166
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 :)
 

dululu

Member
Dec 29, 2002
11
0
151
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.
 

jimcarter

Well-Known Member
Jun 30, 2002
152
0
166
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
 

dululu

Member
Dec 29, 2002
11
0
151
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.
 

electric

Well-Known Member
Nov 5, 2001
777
8
318
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!
 

dululu

Member
Dec 29, 2002
11
0
151
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
 

aurelien

Registered
Mar 14, 2005
1
0
151
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 !