| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package API::DirectAdmin::Mysql; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1399
|
use Modern::Perl '2010'; |
|
|
1
|
|
|
|
|
53
|
|
|
|
1
|
|
|
|
|
64
|
|
|
4
|
1
|
|
|
1
|
|
177
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
71
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
64
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use base 'API::DirectAdmin::Component'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
606
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 0.05; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Create database for user |
|
12
|
|
|
|
|
|
|
# Connection data MUST BE for user: auth_user => 'admin_login|user_login' |
|
13
|
|
|
|
|
|
|
# auth_passwd => 'admin_passwd' |
|
14
|
|
|
|
|
|
|
# INPUT |
|
15
|
|
|
|
|
|
|
# name => 'DBNAME', |
|
16
|
|
|
|
|
|
|
# passwd => 'DBPASSWD', |
|
17
|
|
|
|
|
|
|
# passwd2 => 'DBPASSWD', |
|
18
|
|
|
|
|
|
|
# user => 'DBLOGIN', |
|
19
|
|
|
|
|
|
|
sub adddb { |
|
20
|
1
|
|
|
1
|
0
|
3
|
my ($self, $params ) = @_; |
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
3
|
$params->{action} = 'create'; |
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
50
|
|
|
|
4
|
carp 'params ' . Dumper($params) if $self->{debug}; |
|
25
|
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
8
|
my $responce = $self->directadmin->query( |
|
27
|
|
|
|
|
|
|
command => 'CMD_API_DATABASES', |
|
28
|
|
|
|
|
|
|
method => 'POST', |
|
29
|
|
|
|
|
|
|
params => $params, |
|
30
|
|
|
|
|
|
|
allowed_fields => 'action |
|
31
|
|
|
|
|
|
|
name |
|
32
|
|
|
|
|
|
|
passwd |
|
33
|
|
|
|
|
|
|
passwd2 |
|
34
|
|
|
|
|
|
|
user', |
|
35
|
|
|
|
|
|
|
); |
|
36
|
|
|
|
|
|
|
|
|
37
|
1
|
50
|
|
|
|
4
|
carp '$responce ' . Dumper(\$responce) if $self->{debug}; |
|
38
|
|
|
|
|
|
|
|
|
39
|
1
|
50
|
|
|
|
5
|
return $responce if $responce; |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
return 'FAIL'; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Delete database for user |
|
45
|
|
|
|
|
|
|
# Connection data MUST BE for user: auth_user => 'admin_login|user_login' |
|
46
|
|
|
|
|
|
|
# auth_passwd => 'admin_passwd' |
|
47
|
|
|
|
|
|
|
# INPUT |
|
48
|
|
|
|
|
|
|
# select0 => 'DBNAME', |
|
49
|
|
|
|
|
|
|
# domain => 'DOMAIN.COM', |
|
50
|
|
|
|
|
|
|
sub deldb { |
|
51
|
0
|
|
|
0
|
0
|
|
my ($self, $params ) = @_; |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$params->{action} = 'delete'; |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
carp 'params ' . Dumper($params) if $self->{debug}; |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $responce = $self->directadmin->query( |
|
58
|
|
|
|
|
|
|
command => 'CMD_API_DATABASES', |
|
59
|
|
|
|
|
|
|
method => 'POST', |
|
60
|
|
|
|
|
|
|
params => $params, |
|
61
|
|
|
|
|
|
|
allowed_fields => 'action |
|
62
|
|
|
|
|
|
|
select0', |
|
63
|
|
|
|
|
|
|
); |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
carp '$responce ' . Dumper(\$responce) if $self->{debug}; |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
return $responce if $responce; |
|
68
|
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return 'FAIL'; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# Get list of databases for authorized user. |
|
73
|
|
|
|
|
|
|
# No params. |
|
74
|
|
|
|
|
|
|
sub list { |
|
75
|
0
|
|
|
0
|
0
|
|
my ($self ) = @_; |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $responce = $self->directadmin->query( |
|
78
|
|
|
|
|
|
|
command => 'CMD_API_DATABASES', |
|
79
|
|
|
|
|
|
|
method => 'GET', |
|
80
|
|
|
|
|
|
|
); |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
0
|
|
|
|
|
carp '$responce ' . Dumper($responce) if $self->{debug}; |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
0
|
|
|
|
|
return $responce->{list} if ref $responce eq 'HASH'; |
|
85
|
0
|
|
|
|
|
|
return []; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |