cPanel::Accounting Perl Module

 

The Cpanel::Accounting Perl module is designed to give programs that need access to create/remove/modify accounts an easy way to implement this in their Perl program.

For security reasons if you are connecting to a remote server you should set the usessl variable to 1.

You must have the Net::SSLeay Perl module installed for this to work.

Cpanel::Accounting supports the following methods:

new

Create a new Cpanel::Accounting Object.

showversion

Shows what version of WHM the remote server is running.

listaccts

Lists currently active accounts.

listpkgs

Lists packages available for creation.

addpkg

Add a Package.

editpkg

Edit a package.

createacct

Creates a new account on the server.

killacct

Terminates an account on the server.

suspend

Suspends an account on the server.

unsuspend

Unsuspends an account on the server.

Below is a sample Perl program:

#!/usr/bin/perl

BEGIN {

push (@INC,"/usr/local/cpanel");

}
use Cpanel::Accounting;

my($whm) = Cpanel::Accounting->new;

$whm->{host} = "localhost";

$whm->{user} = "";

$whm->{accesshash} = '';

$whm->{usessl} = 1;

my %ACCTS = $whm->listaccts();

if ($whm->{error} ne "") {

print "There was an error while processing your request:
Cpanel::Accounting returned [$whm->{error}]\n";

exit;

}

#$name,$hasshell,$bwlimit,$quota,$ip,$cgi,$frontpage,$cpmod,$maxftp,
$maxsql,$maxpop,$maxlst,$maxsub,$maxpark,$maxaddon

$response = $whm->editpkg("testpkg2",0,50000,5000,0,1,1,"bluelagoon",
10,10,10,10,10,10,10);

if ($whm->{error} ne "") {

print "There was an error while processing your request:
Cpanel::Accounting returned [$whm->{error}]\n";

exit;

}

foreach $acct (sort keys %ACCTS) {

@ACCTCT = @{$ACCTS{$acct}};

print "$acct @ACCTCT\n";

}

 

$response = $whm->killacct("");

if ($whm->{error} ne "") {

print "There was an error while processing your request:
Cpanel::Accounting returned [$whm->{error}]\n";

exit;

}

print $response;

my %PKGS = $whm->listpkgs();

if ($whm->{error} ne "") {

print "There was an error while processing your request:
Cpanel::Accounting returned [$whm->{error}]\n";

exit;

}

foreach $package (sort keys %PKGS) {

@PKCTS = @{$PKGS{$package}};

print "$package @PKCTS\n";

}

$response = $whm->createacct("","","","");

if ($whm->{error} ne "") {

print "There was an error while processing your request:
Cpanel::Accounting returned [$whm->{error}]\n";

exit;

}

print $response;

$response = $whm->suspend('');

if ($whm->{error} ne "") {

print "There was an error while processing your request:
Cpanel::Accounting returned [$whm->{error}]\n";

exit;

}

print $response . "\n";

$response = $whm->unsuspend('');

if ($whm->{error} ne "") {

print "There was an error while processing your request:
Cpanel::Accounting returned [$whm->{error}]\n";

exit

}

print $response . "\n";

cPanel Web Site Feedback Form

Find everything you were looking for? Yes No

If no, what were you looking for?

Is there anything we can do to improve your experience?

Comments:

Contact Email (optional):