View Single Post
Old 07-15-2005, 01:45 PM   #1 (permalink)
jaswinder_rana
The Acquainted
 
Join Date: May 2005
Posts: 106
Thanks: 0
jaswinder_rana is on a distinguished road
Default How to access functions of Cpanel!

Hi,
this is not a question, as you might have thought, but a little insight into how to automatically access functions of Capanel, like creating accounts and accessing accounts.

Cpanel has script(on some servers its class, mainly new ones), which is here
require '/usr/local/cpanel/Cpanel/Accounting.php.inc';
on some servers it is Account-class.php.inc, if its a class.

you include this and set up host name and user and access hash for WHM and then you can use any function.
if the file is simple like its not a class. then the following will do
PHP Code:
<?php

require '/usr/local/cpanel/Cpanel/Accounting.php.inc';
$host "localhost";
$user "";
$accesshash '';

$accts listaccts($host,$user,$accesshash,0);
print_r($accts);
?>
and if its a class then following would do
PHP Code:
$obj = new accounting();
$obj->host 'localhost';
$obj->user 'root';
$obj->accesshash 'cbff2cf02a6e55b04c9a0eb5d67a6b14
.................................................
75dc188960bb2a008821b34fddf95c02'
;
$accts $obj->listaccts();
print_r($accts); 
So, both above written scripts will list all the domains hosted on that server.
the only difference is the second one is class based.

hope this helps somebody
__________________
---------------------------
Errors = Improved Programming.
Portfolio

Last edited by jaswinder_rana : 07-15-2005 at 06:23 PM.
Send a message via MSN to jaswinder_rana
jaswinder_rana is offline  
Reply With Quote