How to interact with your cPanel / WHM Server…
Ever wanted to know how to create accounts in PHP without messing around in WHM…?
Start off by using the line:
1: #!/usr/local/cpanel/3rdparty/bin/php
This MUST be the first line in your page otherwise it wont be able to interact with cpanel…
Now lets gather the cpanel::accounting module…
2: <?php
3: require ‘/usr/local/cpanel/Cpanel/Accounting.php.inc’;
4: ?>
Start sending the rest of your output and your page design…
lets say you want to list the accounts on your server…
so you want to create a foreach loop with the results from your request… and contain the results within a table… as in:
5: <?php
6: $lres = listaccts ( "localhost" , "WHMUsername" , "WHM Hash code" , "0" );
7: echo "<table border=\"1\">";
8: echo "<tr><th>Domain</th><th>Package</th></tr>";
9: foreach ( $lres as $name => $value )
10:{
11: echo "<tr><td class=\"here\">$value[0]</td><td class=\"here\">$value[1]</td></tr>";
12:}
13:echo "</table>";
Then upload it… and run it… and it should output all acounts created by that user…


