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:
<?
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:
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:
<?
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.