WHM/cPanel via PHP

Hello

I’m trying to automate the creation of accounts by using a PHP script to automatically create the new account in WHM.

I have found an old script (see below) but I am trying decipher the commands in the script and what they do.

The section I am having problems with is the “msel=” setting.

&msel=n,y,unlimited,y,unlimited,unlimited,unlimited,unlimited,unlimited,unlimited,unlimited,y,0,0

Here is the complete line :

// Fine! Set the options now.
$options = “sign=&plan=hansvdp_tp&domain=tgz33.com&username=tg33&password=test&quota=6&ip=0&cgi=1&frontpage=1&maxftp=unlimited&maxpop=unlimited&maxlst=unlimited&maxsql=unlimited&maxsub=unlimited&maxpark=5&maxaddon=3&bwlimit=50&cpmod=x&msel=n,y,unlimited,y,unlimited,unlimited,unlimited,unlimited,unlimited,unlimited,unlimited,y,0,0&contactemail=hansvdp@gmail.com”;

More of the script:

// Create account now
// First going to this form; required, else wont work
$text = $curl->get(“http://” . WHM_USER . “:” . WHM_PASS . “@” . WHM_DOMAIN .“:2086/scripts2/wwwacctform”);

// Fine! Set the options now.
$options = “sign=&plan=hansvdp_tp&domain=tgz33.com&username=tg33&password=test&quota=6&ip=0&cgi=1&frontpage=1&maxftp=unlimited&maxpop=unlimited&maxlst=unlimited&maxsql=unlimited&maxsub=unlimited&maxpark=5&maxaddon=3&bwlimit=50&cpmod=x&msel=n,y,unlimited,y,unlimited,unlimited,unlimited,unlimited,unlimited,unlimited,unlimited,y,0,0&contactemail=hansvdp@gmail.com”;

// And post it!
$text = $curl->post(“http://” . WHM_USER . “:” . WHM_PASS . “@” . WHM_DOMAIN .“:2086/scripts/wwwacct”, $options);

Any help would be appreciated!

If your server has security tokens enabled (which it should, to curb CSRF/XSRF attacks), the above will not work. However, we have some PHP code you can use for creating accounts in WHM:

http://sdk.cpanel.net/lib/xmlapi/php/cp_xmlapi_php_v1.0.5.tar.gz

Since the code I linked to relies on the APIs instead of triggering URLs, it will continue to work through interface redesigns etc. and thus be much more reliable over time. You may also want to look through our APIs for other nifty things you can automate:

http://sdk.cPanel.net