API-CPanel
view release on metacpan or search on metacpan
lib/API/CPanel/Ip.pm
lib/API/CPanel/Misc.pm
lib/API/CPanel/Package.pm
lib/API/CPanel/User.pm
lib/API/CPanel/Domain.pm
lib/API/CPanel/Mysql.pm
Makefile.PL
MANIFEST This list of files
README
t/01-test.t
META.yml Module meta-data (added by MakeMaker)
lib/API/CPanel.pm view on Meta::CPAN
sub get_error {
my $answer = shift;
return '' if is_success( $answer ); # ok == no error
return Dumper( $answer->{statusmsg } );
}
# Get data from @_
sub get_params {
my @params = @_;
if (scalar @params == 1 && ref $params[0] eq 'HASH' ) {
return { %{ $params[0] } };
} else {
return { @params };
}
}
lib/API/CPanel.pm view on Meta::CPAN
# STATIC(REF: our_ref)
sub refs {
my $ref = shift;
return '' unless $ref;
return ref $ref;
}
# INTERNAL!!! Check server answer result
# STATIC(data_block)
sub is_success {
my $data_block = shift;
my $want_hash = shift;
if ( $data_block &&
ref $data_block eq 'HASH' &&
(( $data_block->{status} &&
$data_block->{status} eq '1' ) ||
( $data_block->{result} &&
$data_block->{result} eq '1' ))
) {
return 1;
} else {
return $want_hash ? {} : '';
}
}
# all params derived from get_auth_hash
sub query_abstract {
my %params = @_;
lib/API/CPanel/Package.pm view on Meta::CPAN
# Äîáàâèòü ïàêåò
# name* (string) -- Name of package.
# featurelist (string) -- Name of the feature list to be used when creating a new package.
# quota (integer) -- Disk space quota in Megabytes.
# ip (string) -- Whether or not the domain has a dedicated IP address.
# cgi (boolean) -- Whether or not the domain has CGI access.
# frontpage (boolean) -- Whether or not the domain has FrontPage extensions installed.
# cpmod (string) -- cPanel theme name.
# language (string) -- Language to use in the account's cPanel interface.
# maxftp (string) -- Maximum number of FTP accounts the user can create.
# maxsql (string) -- Maximum number of SQL databases the user can create.
# maxpop (string) -- Maximum number of email accounts the user can create.
# maxlst (string) -- Maximum number of mailing lists the user can create.
# maxsub (string) -- Maximum number of subdomains the user can create.
# maxpark (string) -- Maximum number of parked domains the user can create.
# maxaddon (string) -- Maximum number of addon domains the user can create.
# hasshell (boolean) -- Whether or not the domain has shell/SSH access.
# bwlimit (string) -- Bandiwdth limit in Megabytes.
# According to http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/AddPackage
sub add {
lib/API/CPanel/Package.pm view on Meta::CPAN
# Ðåäàêòèðîâàòü ïàêåò
# name* (string) -- Name of package.
# featurelist (string) -- Name of the feature list to be used when creating a new package.
# quota (integer) -- Disk space quota in Megabytes.
# ip (string) -- Whether or not the domain has a dedicated IP address.
# cgi (boolean) -- Whether or not the domain has CGI access.
# frontpage (boolean) -- Whether or not the domain has FrontPage extensions installed.
# cpmod (string) -- cPanel theme name.
# language (string) -- Language to use in the account's cPanel interface.
# maxftp (string) -- Maximum number of FTP accounts the user can create.
# maxsql (string) -- Maximum number of SQL databases the user can create.
# maxpop (string) -- Maximum number of email accounts the user can create.
# maxlst (string) -- Maximum number of mailing lists the user can create.
# maxsub (string) -- Maximum number of subdomains the user can create.
# maxpark (string) -- Maximum number of parked domains the user can create.
# maxaddon (string) -- Maximum number of addon domains the user can create.
# hasshell (boolean) -- Whether or not the domain has shell/SSH access.
# bwlimit (string) -- Bandiwdth limit in Megabytes.
# According to http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/EditPackage
sub edit {
lib/API/CPanel/User.pm view on Meta::CPAN
# featurelist (string) -- Name of the feature list to be used when creating a new package.
# quota (integer) -- Disk space quota in Megabytes.
# password (string) -- Password for accessing cPanel.
# ip (string) -- Whether or not the domain has a dedicated IP address.
# cgi (boolean) -- Whether or not the domain has CGI access.
# frontpage (boolean) -- Whether or not the domain has FrontPage extensions installed.
# hasshell (boolean) -- Whether or not the domain has shell/SSH access.
# contactemail (string) -- Contact email address for the account.
# cpmod (string) -- cPanel theme name.
# maxftp (string) -- Maximum number of FTP accounts the user can create.
# maxsql (string) -- Maximum number of SQL databases the user can create.
# maxpop (string) -- Maximum number of email accounts the user can create.
# maxlst (string) -- Maximum number of mailing lists the user can create.
# maxsub (string) -- Maximum number of subdomains the user can create.
# maxpark (string) -- Maximum number of parked domains the user can create.
# maxaddon (string) -- Maximum number of addon domains the user can create.
# bwlimit (string) -- Bandiwdth limit in Megabytes.
# customip (string) -- Specific IP address for the site.
# language (string) -- Language to use in the account's cPanel interface.
# useregns (boolean) -- Use the registered nameservers for the domain instead of the ones configured on the server.
# hasuseregns (boolean) -- Set to 1 if you are using the above option.
lib/API/CPanel/User.pm view on Meta::CPAN
customip
language
useregns
hasuseregns
reseller
forcedns
mxcheck',
);
}
# Edit user data
# user* (string) -- User name of the account.
# domain (string) -- Domain name.
# newuser (string) -- Used when changing the username of an account. This will be the new username.
# owner (string) -- Change the owner of the account to the specified owner.
# CPTHEME (string) -- cPanel theme name.
# HASCGI (boolean) -- Whether or not the domain has CGI access.
# LANG (string) -- Language to use in the account's cPanel interface.
# LOCALE (string) -- Locale to use in the account's cPanel interface.
# maxftp (string) -- Maximum number of FTP accounts the user can create.
# maxsql (string) -- Maximum number of SQL databases the user can create.
# maxpop (string) -- Maximum number of email accounts the user can create.
# maxlst (string) -- Maximum number of mailing lists the user can create.
# maxsub (string) -- Maximum number of subdomains the user can create.
# maxpark (string) -- Maximum number of parked domains the user can create.
# maxaddon (string) -- Maximum number of addon domains the user can create.
# shell (boolean) -- Whether or not the domain has shell/SSH access.
# According to http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ModifyAccount
sub edit {
my $params = shift;
t/01-test.t view on Meta::CPAN
is( refs( undef ), '', $a);
is( refs( {} ), 'HASH', $a );
is( refs( [] ), 'ARRAY', $a );
is( refs( sub {} ), 'CODE', $a );
is( refs( \$a ), 'SCALAR', $a );
$a = 'is_success';
ok(! is_success(), $a);
ok(! is_success( { error => {}, data => {} } ), $a);
ok(! is_success( { data => {} } ), $a);
ok(! is_success( { } ), $a);
ok( is_success( { status => 1 } ), $a);
$a = 'filter_hash';
is_deeply( API::CPanel::filter_hash( { }, [ ]), {}, $a );
is_deeply( API::CPanel::filter_hash( { aaa => 555, bbb => 111 }, [ 'aaa' ]), { aaa => 555 }, $a );
is_deeply( API::CPanel::filter_hash( { aaa => 555, bbb => 111 }, [ ]), { }, $a );
is_deeply( API::CPanel::filter_hash( { }, [ 'aaa' ]), { }, $a );
$a = 'mk_query_string';
t/01-test.t view on Meta::CPAN
);
is( $result, 1, 'API::CPanel::Ip::remove');
$API::CPanel::FAKE_ANSWER = ! $ONLINE ? <<THEEND : undef;
<removeacct>
<result>
<rawout>Running pre removal script (/scripts/prekillacct)......DoneCollecting Domain Name and IP...User: zseasd
Domain: zse1.ru
...DoneKilling all processes owned by user......DoneCleaning passwd,shadow,group......DoneRemoving User from Group..........DoneRemoving Web Logs......DoneRemoving Bandwidth Files......DoneRemoving Crontab......DoneRemoving Virtual Hosts...Removed zs...
Removed Entry from httpd.conf
...DoneRemoving MySQL databases and users......DoneRemoving PostgreSQL databases and users......DoneRemoving System User......DoneRemoving Group......DoneRemoving DNS Entries...zse1.ru => deleted from www.
...DoneRemoving Email Setup...Removing /etc/valiases/zse1.ru
...DoneRemoving mailman lists......DoneUpdating Databases......DoneRemoving Counter Data......DoneAdding ip back to the ip address pool...System has 2 free ips.
...DoneRemoving users cPanel Databases & Updating......DoneReloading Services......DoneRemoving mail and service configs...
...DoneSending Contacts......DoneUpdating internal databases...Updating ftp passwords for zseasd
Purging ftp user zseasd
Ftp password files updated.
Ftp vhost passwords synced
...DoneRunning post removal scripts (/scripts/legacypostkillacct, /scripts/postkillacct)......DoneAccount Removal Complete!!!...zseasd account removed...Done</rawout>
<status>1</status>
<statusmsg>zseasd account removed</statusmsg>
</result>
</removeacct>
THEEND
t/01-test.t view on Meta::CPAN
# Mysql òåñòû
$API::CPanel::FAKE_ANSWER = ! $ONLINE ? <<THEEND : undef;
<?xml version="1.0" ?>
<cpanelresult>
<module>Mysql</module>
<func>adduser</func>
<type>event</type>
<source>internal</source>
<apiversion>1</apiversion>
<data>
<result></result>
</data>
<event>
<result>1</result>
</event>
</cpanelresult>
THEEND
$result = API::CPanel::Mysql::adduser(
{
%correct_params,
do_as_user => 'zsezse5',
t/01-test.t view on Meta::CPAN
is( $result, 1, 'API::CPanel::Mysql::adduser');
$API::CPanel::FAKE_ANSWER = ! $ONLINE ? <<THEEND : undef;
<?xml version="1.0" ?>
<cpanelresult>
<module>Mysql</module>
<func>adddb</func>
<type>event</type>
<source>internal</source>
<apiversion>1</apiversion>
<data>
<result></result>
</data>
<event>
<result>1</result>
</event>
</cpanelresult>
THEEND
$result = API::CPanel::Mysql::adddb(
{
%correct_params,
do_as_user => 'zsezse5',
t/01-test.t view on Meta::CPAN
$API::CPanel::FAKE_ANSWER = ! $ONLINE ? <<THEEND : undef;
<?xml version="1.0" ?>
<cpanelresult>
<module>Mysql</module>
<func>adduserdb</func>
<type>event</type>
<source>internal</source>
<apiversion>1</apiversion>
<data>
<result></result>
</data>
<event>
<result>1</result>
</event>
</cpanelresult>
THEEND
$result = API::CPanel::Mysql::grant_perms(
{
%correct_params,
do_as_user => 'zsezse5',
t/01-test.t view on Meta::CPAN
dbuser => 'zsezse5_test13',
perms_list => 'all',
}
);
is( $result, 1, 'API::CPanel::Mysql::grant_perms');
$API::CPanel::FAKE_ANSWER = ! $ONLINE ? <<THEEND : undef;
<?xml version="1.0" ?>
<cpanelresult>
<apiversion>2</apiversion>
<data>
<reason>
aaaaa.asdasd.ru was successfully parked on top of aaaaa.x
</reason>
<result>1</result>
</data>
<event>
<result>1</result>
</event>
<func>addaddondomain</func>
<module>AddonDomain</module>
</cpanelresult>
THEEND
my $addondomain = 'ssssss.ru';
my $subdomain = 'ssssss';
$result = API::CPanel::Domain::add_addon_domain(
{
%correct_params,
do_as_user => 'zsezse5',
dir => "public_html/$addondomain",
newdomain => $addondomain,
pass => 'asdsadasdsad',
subdomain => $subdomain,
}
);
is( $result->{data}->{result}, 1 , 'API::CPanel::Domain::add_addon_domain');
( run in 0.351 second using v1.01-cache-2.11-cpan-8d75d55dd25 )