line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Axigen; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
33042
|
use 5.008008; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
49
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
34
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
32
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
8799
|
use Net::Telnet (); |
|
1
|
|
|
|
|
84756
|
|
|
1
|
|
|
|
|
26
|
|
8
|
1
|
|
|
1
|
|
2347
|
use Encode; |
|
1
|
|
|
|
|
17096
|
|
|
1
|
|
|
|
|
5391
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Exporter; |
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( ) ] ); |
13
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
14
|
|
|
|
|
|
|
our @EXPORT = qw( ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#================================================================== |
19
|
|
|
|
|
|
|
# new() |
20
|
|
|
|
|
|
|
#================================================================== |
21
|
|
|
|
|
|
|
sub new |
22
|
|
|
|
|
|
|
{ |
23
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
24
|
0
|
|
|
|
|
|
my $host = shift @_; |
25
|
0
|
|
|
|
|
|
my $port = shift @_; |
26
|
0
|
|
|
|
|
|
my $login = shift @_; |
27
|
0
|
|
|
|
|
|
my $password = shift @_; |
28
|
0
|
|
|
|
|
|
my $timeout = shift @_; |
29
|
0
|
|
|
|
|
|
my $self = {}; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
$self->{ host } = $host; |
32
|
0
|
|
|
|
|
|
$self->{ port } = $port; |
33
|
0
|
|
|
|
|
|
$self->{ login } = $login; |
34
|
0
|
|
|
|
|
|
$self->{ password } = $password; |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
if($timeout) { $self->{ timeout }=$timeout; } else { $self->{ timeout } = 10; } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
$self->{ t } = 0; |
39
|
0
|
|
|
|
|
|
$self->{ version_full } = ''; # Axigen version |
40
|
0
|
|
|
|
|
|
$self->{ version_major } = ''; |
41
|
0
|
|
|
|
|
|
$self->{ version_minor } = ''; |
42
|
0
|
|
|
|
|
|
$self->{ version_revision } = ''; |
43
|
0
|
|
|
|
|
|
$self->{ os_version_full } = ''; |
44
|
0
|
|
|
|
|
|
$self->{ os_name } = ''; |
45
|
0
|
|
|
|
|
|
$self->{ os_platform } = ''; |
46
|
0
|
|
|
|
|
|
$self->{ datadir } = ''; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$self->{ locale } = 'windows-1251'; # encoding for utf-8 convertor, default Cyrillic |
49
|
0
|
|
|
|
|
|
return(bless($self, $this)); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# ================================================================== |
53
|
|
|
|
|
|
|
# connect() |
54
|
|
|
|
|
|
|
# ================================================================== |
55
|
|
|
|
|
|
|
sub connect |
56
|
|
|
|
|
|
|
{ |
57
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$this->{t} = new Net::Telnet(Timeout => $this->{timeout}, Host => $this->{host}, Port => $this->{port}); |
60
|
0
|
|
|
|
|
|
my $login=$this->{login}; |
61
|
0
|
|
|
|
|
|
my $password=$this->{password}; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
$this->{t}->waitfor('/ *$/i'); |
64
|
0
|
|
|
|
|
|
my @result = $this->{t}->cmd(String => 'GET VERSION', Prompt => '/ *$/i'); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# The last string of the array contains result of execution of the command |
67
|
0
|
|
|
|
|
|
my $rc_str = @result[scalar(@result) - 1]; |
68
|
0
|
0
|
|
|
|
|
if(substr($rc_str,0,3) ne '+OK') { die 'Net::Axigen::connect, '.$rc_str; } |
|
0
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# We delete superfluous string from the end of the array |
71
|
0
|
|
|
|
|
|
pop @result; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# Sample of version full string |
74
|
|
|
|
|
|
|
# 7.0.0, (FreeBSD/i386)|FreeBSD|i386 |
75
|
0
|
|
|
|
|
|
($this->{version_full}, my $os) = split('\s+', $result[0]); |
76
|
0
|
|
|
|
|
|
($this->{version_major}, $this->{version_minor}, $this->{version_revision}) = split('\.+', $this->{version_full}); |
77
|
0
|
|
|
|
|
|
($this->{os_version_full}, $this->{os_name}, $this->{os_version_platform}) = split('\|+', $os); |
78
|
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
if($this->{os_name}=~m/bsd/i) { $this->{ datadir } = '/var/axigen'; } |
|
0
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
else { $this->{ datadir } = '/var/opt/axigen'; } |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
$this->{t}->print("USER $login"); |
83
|
0
|
|
|
|
|
|
$this->{t}->waitfor('/ *$/i'); |
84
|
0
|
|
|
|
|
|
$this->{t}->print($password); |
85
|
0
|
|
|
|
|
|
$this->{t}->waitfor('/<#> *$/i'); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# ================================================================== |
89
|
|
|
|
|
|
|
# close |
90
|
|
|
|
|
|
|
# ================================================================== |
91
|
|
|
|
|
|
|
sub close |
92
|
|
|
|
|
|
|
{ |
93
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
94
|
0
|
|
|
|
|
|
return($this->{t}->close); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# ================================================================== |
98
|
|
|
|
|
|
|
# get_version() |
99
|
|
|
|
|
|
|
# ================================================================== |
100
|
|
|
|
|
|
|
sub get_version |
101
|
|
|
|
|
|
|
{ |
102
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
103
|
0
|
|
|
|
|
|
return($this->{version_major}, $this->{version_minor}, $this->{version_revision}); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# ================================================================== |
107
|
|
|
|
|
|
|
# get_os_version() |
108
|
|
|
|
|
|
|
# ================================================================== |
109
|
|
|
|
|
|
|
sub get_os_version |
110
|
|
|
|
|
|
|
{ |
111
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
112
|
0
|
|
|
|
|
|
return($this->{os_version_full}, $this->{os_name}, $this->{os_version_platform}); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# ================================================================== |
116
|
|
|
|
|
|
|
# _cmd |
117
|
|
|
|
|
|
|
# ================================================================== |
118
|
|
|
|
|
|
|
sub _cmd |
119
|
|
|
|
|
|
|
{ |
120
|
0
|
|
|
0
|
|
|
my $this = shift @_; |
121
|
0
|
|
|
|
|
|
my $cmd = shift @_; |
122
|
0
|
|
|
|
|
|
my $context = shift @_; # wait this context after command execution |
123
|
0
|
|
|
|
|
|
my %r; # command execution result |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
my @result = $this->{t}->cmd(String => $cmd, Prompt => '/<'.$context.'#> *$/i'); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# The last string of the array contains result of execution of the command |
128
|
0
|
|
|
|
|
|
my $rc_str = @result[scalar(@result) - 1]; |
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
$r{rc_str} = $rc_str; # command execution results string |
131
|
0
|
|
|
|
|
|
$r{result} = \@result; # ref to string array returned by command |
132
|
|
|
|
|
|
|
|
133
|
0
|
0
|
|
|
|
|
if(substr($rc_str,0,3) eq '+OK') { $r{ rc } = 1; } # success |
|
0
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
else { $r{ rc } = 0; } # error |
135
|
0
|
|
|
|
|
|
return \%r; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# ================================================================== |
139
|
|
|
|
|
|
|
# listDomains |
140
|
|
|
|
|
|
|
# ================================================================== |
141
|
|
|
|
|
|
|
sub listDomains |
142
|
|
|
|
|
|
|
{ |
143
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
144
|
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
|
my $r=$this->_cmd('LIST Domains', ''); |
146
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::listDomains: ".$r->{rc_str}; } |
|
0
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
my @domain_list; |
149
|
0
|
|
|
|
|
|
my $domains=$r->{result}; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# Delete superfluous string from the beginning and the end of the array |
152
|
0
|
|
|
|
|
|
splice(@$domains, 0, 5); |
153
|
0
|
|
|
|
|
|
pop @$domains; pop @$domains; |
|
0
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# Select names of domains, the total and used size |
156
|
0
|
|
|
|
|
|
foreach my $line(@$domains) |
157
|
|
|
|
|
|
|
{ |
158
|
0
|
|
|
|
|
|
(my $domain, my $size_total, my $size_used) = split('\s+', $line); |
159
|
0
|
|
|
|
|
|
push(@domain_list, $domain); |
160
|
|
|
|
|
|
|
} |
161
|
0
|
|
|
|
|
|
return \@domain_list; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
# ================================================================== |
165
|
|
|
|
|
|
|
# listDomainsEx |
166
|
|
|
|
|
|
|
# ================================================================== |
167
|
|
|
|
|
|
|
sub listDomainsEx |
168
|
|
|
|
|
|
|
{ |
169
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
170
|
0
|
|
|
|
|
|
my %domain_info=(); |
171
|
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
my $r=$this->_cmd('LIST Domains', ''); |
173
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::listDomainsEx: ".$r->{rc_str};} |
|
0
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
my $domains=$r->{result}; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
# Delete superfluous string from the beginning and the end of the array |
177
|
0
|
|
|
|
|
|
splice(@$domains, 0, 5); |
178
|
0
|
|
|
|
|
|
pop @$domains; pop @$domains; |
|
0
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
# Select names of domains, the total and used size |
181
|
0
|
|
|
|
|
|
foreach my $line(@$domains) |
182
|
|
|
|
|
|
|
{ |
183
|
0
|
|
|
|
|
|
(my $domain, my $size_total, my $size_used) = split('\s+', $line); |
184
|
0
|
|
|
|
|
|
my %ds = ('total' => $size_total, 'used' => $size_used); |
185
|
0
|
|
|
|
|
|
$domain_info{ $domain }= \%ds; |
186
|
|
|
|
|
|
|
} |
187
|
0
|
|
|
|
|
|
return \%domain_info; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# ================================================================== |
191
|
|
|
|
|
|
|
# _listAccounts |
192
|
|
|
|
|
|
|
# ================================================================== |
193
|
|
|
|
|
|
|
sub _listAccounts |
194
|
|
|
|
|
|
|
{ |
195
|
0
|
|
|
0
|
|
|
my $this = shift @_; |
196
|
0
|
|
|
|
|
|
my $r=$this->_cmd('LIST ACCOUNTS', 'domain'); |
197
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::_listAccounts: ".$r->{rc_str}.": ".'LIST ACCOUNTS'; } |
|
0
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
|
199
|
0
|
|
|
|
|
|
my $accounts=$r->{result}; |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
# Delete superfluous string from the beginning and the end of the accounts array |
202
|
0
|
|
|
|
|
|
splice(@$accounts, 0, 5); |
203
|
0
|
|
|
|
|
|
pop @$accounts; pop @$accounts; |
|
0
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
# Delete CRLF |
206
|
0
|
|
|
|
|
|
foreach my $line(@$accounts) { chomp ($line); } |
|
0
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
|
return $accounts; |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
# ================================================================== |
211
|
|
|
|
|
|
|
# listAccounts |
212
|
|
|
|
|
|
|
# ================================================================== |
213
|
|
|
|
|
|
|
sub listAccounts |
214
|
|
|
|
|
|
|
{ |
215
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
216
|
0
|
|
|
|
|
|
my $domain = shift @_; |
217
|
0
|
|
|
|
|
|
my $r; |
218
|
|
|
|
|
|
|
|
219
|
0
|
0
|
|
|
|
|
if($this->_hasDomain($domain)) |
220
|
|
|
|
|
|
|
{ |
221
|
0
|
|
|
|
|
|
$r=$this->_cmd("UPDATE DOMAIN NAME $domain", 'domain'); |
222
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::listAccounts: ".$r->{rc_str}.": "."UPDATE DOMAIN NAME $domain"; } |
|
0
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
|
224
|
0
|
|
|
|
|
|
my $accounts_list = $this->_listAccounts($domain); |
225
|
0
|
|
|
|
|
|
$r=$this->_cmd("BACK", ''); |
226
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::listAccounts: ".$r->{rc_str}.": "."BACK"; } |
|
0
|
|
|
|
|
|
|
227
|
0
|
|
|
|
|
|
return $accounts_list; |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
else |
230
|
|
|
|
|
|
|
{ |
231
|
0
|
|
|
|
|
|
die 'ERROR Net::Axigen::listAccounts: Domain '.$domain.' does not exist in AXIGEN'; |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
# ================================================================== |
236
|
|
|
|
|
|
|
# listAccountsEx |
237
|
|
|
|
|
|
|
# ================================================================== |
238
|
|
|
|
|
|
|
sub listAccountsEx |
239
|
|
|
|
|
|
|
{ |
240
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
241
|
0
|
|
|
|
|
|
my $domain = shift @_; |
242
|
0
|
|
|
|
|
|
my $r; |
243
|
0
|
|
|
|
|
|
my %accounts_info=(); |
244
|
|
|
|
|
|
|
|
245
|
0
|
0
|
|
|
|
|
if($this->_hasDomain($domain)) |
246
|
|
|
|
|
|
|
{ |
247
|
0
|
|
|
|
|
|
$r=$this->_cmd("UPDATE DOMAIN NAME $domain", 'domain'); |
248
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::listAccountsEx: ".$r->{rc_str}.": "."UPDATE DOMAIN NAME $domain"; } |
|
0
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
|
250
|
0
|
|
|
|
|
|
my $accounts_list = $this->_listAccounts($domain); |
251
|
0
|
|
|
|
|
|
foreach my $ptr(@$accounts_list) |
252
|
|
|
|
|
|
|
{ |
253
|
0
|
|
|
|
|
|
my %acc = ('firstName' => $this->_getAccountAttr($ptr, 'firstName'), 'lastName' => $this->_getAccountAttr($ptr, 'lastName')); |
254
|
0
|
|
|
|
|
|
$accounts_info{ $ptr }= \%acc; |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
|
257
|
0
|
|
|
|
|
|
$r=$this->_cmd("BACK", ''); |
258
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::listAccountsEx: ".$r->{rc_str}.": "."BACK"; } |
|
0
|
|
|
|
|
|
|
259
|
0
|
|
|
|
|
|
return \%accounts_info; |
260
|
|
|
|
|
|
|
} |
261
|
|
|
|
|
|
|
else |
262
|
|
|
|
|
|
|
{ |
263
|
0
|
|
|
|
|
|
die 'ERROR Net::Axigen::listAccountsEx: Domain '.$domain.' does not exist in AXIGEN'; |
264
|
|
|
|
|
|
|
} |
265
|
|
|
|
|
|
|
} |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
# ================================================================== |
268
|
|
|
|
|
|
|
# _getAccountAttr |
269
|
|
|
|
|
|
|
# ================================================================== |
270
|
|
|
|
|
|
|
sub _getAccountAttr |
271
|
|
|
|
|
|
|
{ |
272
|
0
|
|
|
0
|
|
|
my $this = shift @_; |
273
|
0
|
|
|
|
|
|
my $account = shift @_; |
274
|
0
|
|
|
|
|
|
my $attr = shift @_; |
275
|
0
|
|
|
|
|
|
my $r; |
276
|
|
|
|
|
|
|
|
277
|
0
|
|
|
|
|
|
$r=$this->_cmd("UPDATE ACCOUNT $account", 'domain-account'); |
278
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::_getAccountAttr: ".$r->{rc_str}.": "."UPDATE ACCOUNT $account"; } |
|
0
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
|
280
|
0
|
|
|
|
|
|
$r=$this->_cmd("CONFIG ContactInfo", 'domain-account-contactInfo'); |
281
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::_getAccountAttr: ".$r->{rc_str}.": "."CONFIG ContactInfo"; } |
|
0
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
|
283
|
0
|
|
|
|
|
|
$r=$this->_cmd("SHOW ATTR $attr", 'domain-account-contactInfo'); |
284
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::_getAccountAttr: ".$r->{rc_str}.": "."show attr $attr"; } |
|
0
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
|
286
|
0
|
|
|
|
|
|
(my $atr_name, my $eq, my $attr_val) = split('\s+', $r->{result}[0]); |
287
|
0
|
|
|
|
|
|
$attr_val =~ s/"//g; |
288
|
|
|
|
|
|
|
|
289
|
0
|
|
|
|
|
|
$r=$this->_cmd("BACK", 'domain-account'); |
290
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::_getAccountAttr: ".$r->{rc_str}.": "."BACK"; } |
|
0
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
|
292
|
0
|
|
|
|
|
|
$r=$this->_cmd("BACK", 'domain'); |
293
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::_getAccountAttr: ".$r->{rc_str}.": "."BACK"; } |
|
0
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
|
295
|
0
|
|
|
|
|
|
return $attr_val; |
296
|
|
|
|
|
|
|
} |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
# ================================================================== |
299
|
|
|
|
|
|
|
# createDomain |
300
|
|
|
|
|
|
|
# ================================================================== |
301
|
|
|
|
|
|
|
sub createDomain |
302
|
|
|
|
|
|
|
{ |
303
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
304
|
0
|
|
|
|
|
|
my $domain = shift @_; |
305
|
0
|
|
|
|
|
|
my $postmaster_pwd = shift @_; |
306
|
0
|
|
|
|
|
|
my $maxFiles = shift @_; # Quantity of files of storage. Storage file size: maxFileSize KByte |
307
|
0
|
|
|
|
|
|
my $maxFileSize=262144; # 256 MByte |
308
|
|
|
|
|
|
|
|
309
|
0
|
|
|
|
|
|
my $r; |
310
|
|
|
|
|
|
|
|
311
|
0
|
0
|
|
|
|
|
if(!$this->_hasDomain($domain)) |
312
|
|
|
|
|
|
|
{ |
313
|
|
|
|
|
|
|
# Full path to domain folder |
314
|
0
|
|
|
|
|
|
my $domain_location= $this->{datadir}.'/domains/'.$domain; |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
# Axigen cmd sample: |
317
|
|
|
|
|
|
|
# CREATE DOMAIN NAME ddomain.ru DOMAINLOCATION /var/axigen/domains/ddomain.ru POSTMASTERPASSWD test123 |
318
|
|
|
|
|
|
|
# add messageslocation /var/axigen/domains/ddomain.ru/messages?maxFileSize=262144&maxFiles=128 |
319
|
|
|
|
|
|
|
|
320
|
0
|
|
|
|
|
|
my $cmd = "CREATE DOMAIN NAME $domain DOMAINLOCATION $domain_location POSTMASTERPASSWD $postmaster_pwd"; |
321
|
0
|
|
|
|
|
|
$r=$this->_cmd($cmd, 'domain-create'); |
322
|
0
|
0
|
|
|
|
|
if($r->{rc}) |
323
|
|
|
|
|
|
|
{ |
324
|
|
|
|
|
|
|
# GroupWare support |
325
|
0
|
|
|
|
|
|
my $cmd1 = "SET maclSupport yes"; |
326
|
0
|
|
|
|
|
|
$r=$this->_cmd($cmd1, 'domain-create'); |
327
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::createDomain: ".$r->{rc_str}.": ".$cmd1; } |
|
0
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
# Messages file storage limit - 4 files on 256 Mbyte |
330
|
|
|
|
|
|
|
|
331
|
0
|
0
|
|
|
|
|
if($maxFiles > 128) { $maxFiles=128;} |
|
0
|
|
|
|
|
|
|
332
|
0
|
0
|
|
|
|
|
if($maxFiles < 1) { $maxFiles=1;} |
|
0
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
|
334
|
0
|
|
|
|
|
|
$cmd1 = "add messageslocation $domain_location".'/messages?maxFileSize='.$maxFileSize.'&maxFiles='.$maxFiles; |
335
|
0
|
|
|
|
|
|
$r=$this->_cmd($cmd1, 'domain-create'); |
336
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::createDomain: ".$r->{rc_str}.": ".$cmd1; } |
|
0
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
|
338
|
0
|
|
|
|
|
|
$r=$this->_cmd("COMMIT", ''); |
339
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::createDomain: ".$r->{rc_str}.": ".$cmd; } |
|
0
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
} |
341
|
0
|
|
|
|
|
|
else { die "Net::Axigen::createDomain: ".$r->{rc_str}.": ".$cmd; } |
342
|
0
|
|
|
|
|
|
$this->saveConfig(); |
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
# ================================================================== |
347
|
|
|
|
|
|
|
# registerDomain |
348
|
|
|
|
|
|
|
# ================================================================== |
349
|
|
|
|
|
|
|
sub registerDomain |
350
|
|
|
|
|
|
|
{ |
351
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
352
|
0
|
|
|
|
|
|
my $domain = shift @_; |
353
|
0
|
|
|
|
|
|
my $r; |
354
|
|
|
|
|
|
|
|
355
|
0
|
0
|
|
|
|
|
if(!$this->_hasDomain($domain)) |
356
|
|
|
|
|
|
|
{ |
357
|
|
|
|
|
|
|
# Full path to domain folder |
358
|
0
|
|
|
|
|
|
my $domain_location= $this->{datadir}.'/domains/'.$domain; |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
# REGISTER DOMAIN DOMAINLOCATION /var/axigen/domains/ddomain.ru |
361
|
0
|
|
|
|
|
|
my $cmd = "REGISTER DOMAIN DOMAINLOCATION $domain_location"; |
362
|
0
|
|
|
|
|
|
$r=$this->_cmd($cmd, 'domain-register'); |
363
|
0
|
0
|
|
|
|
|
if($r->{rc}) |
364
|
|
|
|
|
|
|
{ |
365
|
0
|
|
|
|
|
|
$r=$this->_cmd("COMMIT", ''); |
366
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::registerDomain: ".$r->{rc_str}.": ".$cmd; } |
|
0
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
} |
368
|
0
|
|
|
|
|
|
else { die "Net::Axigen::registerDomain: ".$r->{rc_str}.": ".$cmd; } |
369
|
0
|
|
|
|
|
|
$this->saveConfig(); |
370
|
|
|
|
|
|
|
} |
371
|
|
|
|
|
|
|
} |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
# ================================================================== |
374
|
|
|
|
|
|
|
# unregisterDomain |
375
|
|
|
|
|
|
|
# ================================================================== |
376
|
|
|
|
|
|
|
sub unregisterDomain |
377
|
|
|
|
|
|
|
{ |
378
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
379
|
0
|
|
|
|
|
|
my $domain = shift @_; |
380
|
0
|
|
|
|
|
|
my $r; |
381
|
|
|
|
|
|
|
|
382
|
0
|
0
|
|
|
|
|
if($this->_hasDomain($domain)) |
383
|
|
|
|
|
|
|
{ |
384
|
0
|
|
|
|
|
|
my $cmd = "UNREGISTER DOMAIN NAME $domain"; |
385
|
0
|
|
|
|
|
|
$r=$this->_cmd($cmd, ''); |
386
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::unregisterDomain: ".$r->{rc_str}.": ".$cmd; } |
|
0
|
|
|
|
|
|
|
387
|
0
|
|
|
|
|
|
$this->saveConfig(); |
388
|
|
|
|
|
|
|
} |
389
|
|
|
|
|
|
|
} |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
# ================================================================== |
392
|
|
|
|
|
|
|
# _hasDomain |
393
|
|
|
|
|
|
|
# ================================================================== |
394
|
|
|
|
|
|
|
sub _hasDomain |
395
|
|
|
|
|
|
|
{ |
396
|
0
|
|
|
0
|
|
|
my $this = shift @_; |
397
|
0
|
|
|
|
|
|
my $domain = shift @_; |
398
|
0
|
|
|
|
|
|
my $domain_list = $this->listDomains(); |
399
|
0
|
|
|
|
|
|
return grep { $_ eq $domain } @$domain_list; |
|
0
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
} |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
# ================================================================== |
403
|
|
|
|
|
|
|
# _hasAccount |
404
|
|
|
|
|
|
|
# ================================================================== |
405
|
|
|
|
|
|
|
sub _hasAccount |
406
|
|
|
|
|
|
|
{ |
407
|
0
|
|
|
0
|
|
|
my $this = shift @_; |
408
|
0
|
|
|
|
|
|
my $domain = shift @_; |
409
|
0
|
|
|
|
|
|
my $account = shift @_; |
410
|
0
|
|
|
|
|
|
my $accounts_list = $this->_listAccounts($domain); |
411
|
0
|
|
|
|
|
|
return grep { $_ eq $account } @$accounts_list; |
|
0
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
} |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
# ================================================================== |
415
|
|
|
|
|
|
|
# addAccount |
416
|
|
|
|
|
|
|
# ================================================================== |
417
|
|
|
|
|
|
|
sub addAccount |
418
|
|
|
|
|
|
|
{ |
419
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
420
|
0
|
|
|
|
|
|
my $domain = shift @_; |
421
|
0
|
|
|
|
|
|
my $user = shift @_; |
422
|
0
|
|
|
|
|
|
my $pwd = shift @_; |
423
|
|
|
|
|
|
|
|
424
|
0
|
|
|
|
|
|
my $r; |
425
|
|
|
|
|
|
|
my $cmd; |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
# The domain exists |
428
|
0
|
0
|
|
|
|
|
if($this->_hasDomain($domain)) |
429
|
|
|
|
|
|
|
{ |
430
|
0
|
|
|
|
|
|
$r=$this->_cmd("UPDATE DOMAIN NAME $domain", 'domain'); |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
# The account does not exist |
433
|
0
|
0
|
|
|
|
|
if(!$this->_hasAccount($domain, $user)) |
434
|
|
|
|
|
|
|
{ |
435
|
0
|
|
|
|
|
|
$cmd="ADD ACCOUNT NAME $user PASSWD $pwd"; |
436
|
0
|
|
|
|
|
|
$r=$this->_cmd($cmd, 'domain-account'); |
437
|
0
|
|
|
|
|
|
$r=$this->_cmd('COMMIT', 'domain'); |
438
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::addAccount: ".$r->{rc_str}.": ".$cmd; } |
|
0
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
|
440
|
0
|
|
|
|
|
|
$r=$this->_cmd('COMMIT', ''); |
441
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::addAccount: ".$r->{rc_str}.": ".$cmd; } |
|
0
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
} |
443
|
|
|
|
|
|
|
else |
444
|
|
|
|
|
|
|
{ |
445
|
0
|
|
|
|
|
|
$r=$this->_cmd('BACK', ''); |
446
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::addAccount: ".$r->{rc_str}.": ".$cmd; } |
|
0
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
} |
448
|
|
|
|
|
|
|
} |
449
|
|
|
|
|
|
|
else |
450
|
|
|
|
|
|
|
{ |
451
|
0
|
|
|
|
|
|
die 'ERROR Net::Axigen::addAccount: Domain '.$domain.' does not exist in AXIGEN'; |
452
|
|
|
|
|
|
|
} |
453
|
|
|
|
|
|
|
} |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
# ================================================================== |
456
|
|
|
|
|
|
|
# removeAccount |
457
|
|
|
|
|
|
|
# ================================================================== |
458
|
|
|
|
|
|
|
sub removeAccount |
459
|
|
|
|
|
|
|
{ |
460
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
461
|
0
|
|
|
|
|
|
my $domain = shift @_; |
462
|
0
|
|
|
|
|
|
my $user = shift @_; |
463
|
|
|
|
|
|
|
|
464
|
0
|
|
|
|
|
|
my $r; |
465
|
|
|
|
|
|
|
my $cmd; |
466
|
|
|
|
|
|
|
|
467
|
0
|
0
|
|
|
|
|
if($this->_hasDomain($domain)) |
468
|
|
|
|
|
|
|
{ |
469
|
0
|
|
|
|
|
|
$cmd="UPDATE DOMAIN NAME $domain"; |
470
|
0
|
|
|
|
|
|
$r=$this->_cmd($cmd, 'domain'); |
471
|
|
|
|
|
|
|
|
472
|
0
|
0
|
|
|
|
|
if($this->_hasAccount($domain, $user)) |
473
|
|
|
|
|
|
|
{ |
474
|
0
|
|
|
|
|
|
$cmd="REMOVE ACCOUNT NAME $user"; |
475
|
0
|
|
|
|
|
|
$r=$this->_cmd($cmd, 'domain'); |
476
|
0
|
|
|
|
|
|
$r=$this->_cmd('COMMIT', ''); |
477
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::removeAccount: ".$r->{rc_str}.": ".$cmd; } |
|
0
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
} |
479
|
|
|
|
|
|
|
else |
480
|
|
|
|
|
|
|
{ |
481
|
0
|
|
|
|
|
|
$r=$this->_cmd('BACK', ''); |
482
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::removeAccount: ".$r->{rc_str}.": ".$cmd; } |
|
0
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
} |
484
|
|
|
|
|
|
|
} |
485
|
|
|
|
|
|
|
else |
486
|
|
|
|
|
|
|
{ |
487
|
0
|
|
|
|
|
|
die 'ERROR Net::Axigen::removeAccount: Domain '.$domain.' does not exist in AXIGEN'; |
488
|
|
|
|
|
|
|
} |
489
|
|
|
|
|
|
|
} |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
# ================================================================== |
492
|
|
|
|
|
|
|
# setAccountContactData |
493
|
|
|
|
|
|
|
# ================================================================== |
494
|
|
|
|
|
|
|
sub setAccountContactData |
495
|
|
|
|
|
|
|
{ |
496
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
497
|
0
|
|
|
|
|
|
my $domain = shift @_; |
498
|
0
|
|
|
|
|
|
my $user = shift @_; |
499
|
0
|
|
|
|
|
|
my $firstName = shift @_; |
500
|
0
|
|
|
|
|
|
my $lastName = shift @_; |
501
|
|
|
|
|
|
|
|
502
|
0
|
|
|
|
|
|
my $r; |
503
|
|
|
|
|
|
|
my $cmd; |
504
|
|
|
|
|
|
|
|
505
|
0
|
|
|
|
|
|
$firstName=$this->to_utf8($firstName); |
506
|
0
|
|
|
|
|
|
$lastName=$this->to_utf8($lastName); |
507
|
|
|
|
|
|
|
|
508
|
0
|
0
|
|
|
|
|
if($this->_hasDomain($domain)) |
509
|
|
|
|
|
|
|
{ |
510
|
0
|
|
|
|
|
|
$cmd="UPDATE DOMAIN NAME $domain"; |
511
|
0
|
|
|
|
|
|
$r=$this->_cmd($cmd, 'domain'); |
512
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setAccountContactData: ".$r->{rc_str}.": ".$cmd; } |
|
0
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
|
514
|
0
|
0
|
|
|
|
|
if($this->_hasAccount($domain, $user)) |
515
|
|
|
|
|
|
|
{ |
516
|
0
|
|
|
|
|
|
$cmd="UPDATE ACCOUNT NAME $user"; |
517
|
0
|
|
|
|
|
|
$r=$this->_cmd($cmd, 'domain-account'); |
518
|
0
|
|
|
|
|
|
$r=$this->_cmd("CONFIG CONTACTINFO", 'domain-account-contactInfo'); |
519
|
|
|
|
|
|
|
|
520
|
0
|
|
|
|
|
|
$r=$this->_cmd("set firstName \"$firstName\"", 'domain-account-contactInfo'); |
521
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setAccountContactData: ".$r->{rc_str}.": ".$cmd; } |
|
0
|
|
|
|
|
|
|
522
|
0
|
|
|
|
|
|
$r=$this->_cmd("set lastName \"$lastName\"", 'domain-account-contactInfo'); |
523
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setAccountContactData: ".$r->{rc_str}.": ".$cmd; } |
|
0
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
|
525
|
0
|
|
|
|
|
|
$r=$this->_cmd('DONE', 'domain-account'); |
526
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setAccountContactData: ".$r->{rc_str}.": ".$cmd; } |
|
0
|
|
|
|
|
|
|
527
|
0
|
|
|
|
|
|
$r=$this->_cmd('COMMIT', 'domain'); |
528
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setAccountContactData: ".$r->{rc_str}.": ".$cmd; } |
|
0
|
|
|
|
|
|
|
529
|
0
|
|
|
|
|
|
$r=$this->_cmd('COMMIT', ''); |
530
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setAccountContactData: ".$r->{rc_str}.": ".$cmd; } |
|
0
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
} |
532
|
|
|
|
|
|
|
else |
533
|
|
|
|
|
|
|
{ |
534
|
0
|
|
|
|
|
|
$r=$this->_cmd('BACK', ''); |
535
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setAccountContactData: ".$r->{rc_str}.": ".'BACK'; } |
|
0
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
} |
537
|
|
|
|
|
|
|
} |
538
|
|
|
|
|
|
|
else |
539
|
|
|
|
|
|
|
{ |
540
|
0
|
|
|
|
|
|
die 'ERROR: Net::Axigen::setAccountContactData Domain '.$domain.' does not exist in AXIGEN'; |
541
|
|
|
|
|
|
|
} |
542
|
|
|
|
|
|
|
} |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
# ================================================================== |
545
|
|
|
|
|
|
|
# setQuotaLimitNotification |
546
|
|
|
|
|
|
|
# ================================================================== |
547
|
|
|
|
|
|
|
sub setQuotaLimitNotification |
548
|
|
|
|
|
|
|
{ |
549
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
550
|
0
|
|
|
|
|
|
my $domain = shift @_; |
551
|
0
|
|
|
|
|
|
my $user = shift @_; |
552
|
0
|
|
|
|
|
|
my $notificationSubject = shift @_; |
553
|
0
|
|
|
|
|
|
my $notificationMsg = shift @_; |
554
|
|
|
|
|
|
|
|
555
|
0
|
|
|
|
|
|
my $r; |
556
|
|
|
|
|
|
|
my $cmd; |
557
|
|
|
|
|
|
|
|
558
|
0
|
|
|
|
|
|
$notificationMsg=$this->to_utf8($notificationMsg); |
559
|
0
|
|
|
|
|
|
$notificationSubject=$this->to_utf8($notificationSubject); |
560
|
|
|
|
|
|
|
|
561
|
0
|
0
|
|
|
|
|
if($this->_hasDomain($domain)) |
562
|
|
|
|
|
|
|
{ |
563
|
0
|
|
|
|
|
|
$cmd="UPDATE DOMAIN NAME $domain"; |
564
|
0
|
|
|
|
|
|
$r=$this->_cmd($cmd, 'domain'); |
565
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setQuotaLimitNotification: ".$r->{rc_str}.": ".$cmd; } |
|
0
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
|
567
|
0
|
0
|
|
|
|
|
if($this->_hasAccount($domain, $user)) |
568
|
|
|
|
|
|
|
{ |
569
|
0
|
|
|
|
|
|
$cmd="UPDATE ACCOUNT NAME $user"; |
570
|
0
|
|
|
|
|
|
$r=$this->_cmd($cmd, 'domain-account'); |
571
|
0
|
|
|
|
|
|
$r=$this->_cmd("CONFIG Quotas", 'domain-account-quotas'); |
572
|
|
|
|
|
|
|
|
573
|
0
|
|
|
|
|
|
$r=$this->_cmd("SET quotaLimitNotificationSubject \"$notificationSubject\"", 'domain-account-quotas'); |
574
|
|
|
|
|
|
|
|
575
|
0
|
|
|
|
|
|
$this->{t}->print("ESET quotaLimitNotificationBody"); |
576
|
0
|
|
|
|
|
|
$this->{t}->print("$notificationMsg"); |
577
|
0
|
|
|
|
|
|
$this->{t}->print("."); |
578
|
0
|
|
|
|
|
|
$this->{t}->waitfor('/ *$/i'); |
579
|
|
|
|
|
|
|
|
580
|
0
|
|
|
|
|
|
$r=$this->_cmd('DONE', 'domain-account'); |
581
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setQuotaLimitNotification: ".$r->{rc_str}.": ".$cmd; } |
|
0
|
|
|
|
|
|
|
582
|
0
|
|
|
|
|
|
$r=$this->_cmd('COMMIT', 'domain'); |
583
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setQuotaLimitNotification: ".$r->{rc_str}.": ".$cmd; } |
|
0
|
|
|
|
|
|
|
584
|
0
|
|
|
|
|
|
$r=$this->_cmd('COMMIT', ''); |
585
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setQuotaLimitNotification: ".$r->{rc_str}.": ".$cmd; } |
|
0
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
} |
587
|
|
|
|
|
|
|
else |
588
|
|
|
|
|
|
|
{ |
589
|
0
|
|
|
|
|
|
$r=$this->_cmd('BACK', ''); |
590
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setQuotaLimitNotification: ".$r->{rc_str}.": ".'BACK'; } |
|
0
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
} |
592
|
|
|
|
|
|
|
} |
593
|
|
|
|
|
|
|
else |
594
|
|
|
|
|
|
|
{ |
595
|
0
|
|
|
|
|
|
die 'ERROR: Net::Axigen::setQuotaLimitNotification Domain '.$domain.' does not exist in AXIGEN'; |
596
|
|
|
|
|
|
|
} |
597
|
|
|
|
|
|
|
} |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
# ================================================================== |
601
|
|
|
|
|
|
|
# setAccountPassword |
602
|
|
|
|
|
|
|
# ================================================================== |
603
|
|
|
|
|
|
|
sub setAccountPassword |
604
|
|
|
|
|
|
|
{ |
605
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
606
|
0
|
|
|
|
|
|
my $domain = shift @_; |
607
|
0
|
|
|
|
|
|
my $user = shift @_; |
608
|
0
|
|
|
|
|
|
my $passwd = shift @_; |
609
|
|
|
|
|
|
|
|
610
|
0
|
|
|
|
|
|
my $r; |
611
|
|
|
|
|
|
|
my $cmd; |
612
|
|
|
|
|
|
|
|
613
|
0
|
0
|
|
|
|
|
if($this->_hasDomain($domain)) |
614
|
|
|
|
|
|
|
{ |
615
|
0
|
|
|
|
|
|
$r=$this->_cmd("UPDATE DOMAIN NAME $domain", 'domain'); |
616
|
0
|
0
|
|
|
|
|
if($this->_hasAccount($domain, $user)) |
617
|
|
|
|
|
|
|
{ |
618
|
0
|
|
|
|
|
|
$r=$this->_cmd("UPDATE ACCOUNT NAME $user", 'domain-account'); |
619
|
0
|
|
|
|
|
|
$r=$this->_cmd("set password $passwd", 'domain-account'); |
620
|
0
|
|
|
|
|
|
$r=$this->_cmd('COMMIT', 'domain'); |
621
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setAccountPassword: ".$r->{rc_str}.": ".'COMMIT'; } |
|
0
|
|
|
|
|
|
|
622
|
0
|
|
|
|
|
|
$r=$this->_cmd('COMMIT', ''); |
623
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setAccountPassword: ".$r->{rc_str}.": ".'COMMIT'; } |
|
0
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
} |
625
|
|
|
|
|
|
|
else |
626
|
|
|
|
|
|
|
{ |
627
|
0
|
|
|
|
|
|
$r=$this->_cmd('BACK', ''); |
628
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setAccountPassword: ".$r->{rc_str}.": ".'BACK'; } |
|
0
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
} |
630
|
|
|
|
|
|
|
} |
631
|
|
|
|
|
|
|
else |
632
|
|
|
|
|
|
|
{ |
633
|
0
|
|
|
|
|
|
die 'ERROR: Net::Axigen::setAccountPassword Domain '.$domain.' does not exist in AXIGEN'; |
634
|
|
|
|
|
|
|
} |
635
|
|
|
|
|
|
|
} |
636
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
# ================================================================== |
638
|
|
|
|
|
|
|
# setAccountWebMailLanguage |
639
|
|
|
|
|
|
|
# ================================================================== |
640
|
|
|
|
|
|
|
sub setAccountWebMailLanguage |
641
|
|
|
|
|
|
|
{ |
642
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
643
|
0
|
|
|
|
|
|
my $domain = shift @_; |
644
|
0
|
|
|
|
|
|
my $user = shift @_; |
645
|
0
|
|
|
|
|
|
my $lang = shift @_; |
646
|
|
|
|
|
|
|
|
647
|
0
|
|
|
|
|
|
my $r; |
648
|
|
|
|
|
|
|
my $cmd; |
649
|
0
|
0
|
|
|
|
|
if($this->_hasDomain($domain)) |
650
|
|
|
|
|
|
|
{ |
651
|
0
|
|
|
|
|
|
$r=$this->_cmd("UPDATE DOMAIN NAME $domain", 'domain'); |
652
|
0
|
0
|
|
|
|
|
if($this->_hasAccount($domain, $user)) |
653
|
|
|
|
|
|
|
{ |
654
|
0
|
|
|
|
|
|
$r=$this->_cmd("UPDATE ACCOUNT NAME $user", 'domain-account'); |
655
|
0
|
|
|
|
|
|
$r=$this->_cmd("CONFIG WebmailData", 'domain-account-webmaildata'); |
656
|
0
|
|
|
|
|
|
$r=$this->_cmd("set language $lang", 'domain-account-webmaildata'); |
657
|
|
|
|
|
|
|
|
658
|
0
|
|
|
|
|
|
$r=$this->_cmd('DONE', 'domain-account'); |
659
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setAccountWebMailLanguage: ".$r->{rc_str}.": ".'DONE'; } |
|
0
|
|
|
|
|
|
|
660
|
0
|
|
|
|
|
|
$r=$this->_cmd('COMMIT', 'domain'); |
661
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setAccountWebMailLanguage: ".$r->{rc_str}.": ".'COMMIT'; } |
|
0
|
|
|
|
|
|
|
662
|
0
|
|
|
|
|
|
$r=$this->_cmd('COMMIT', ''); |
663
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setAccountWebMailLanguage: ".$r->{rc_str}.": ".'COMMIT'; } |
|
0
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
} |
665
|
|
|
|
|
|
|
else |
666
|
|
|
|
|
|
|
{ |
667
|
0
|
|
|
|
|
|
$r=$this->_cmd('BACK', ''); |
668
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setAccountWebMailLanguage: ".$r->{rc_str}.": ".'BACK'; } |
|
0
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
} |
670
|
|
|
|
|
|
|
} |
671
|
|
|
|
|
|
|
else |
672
|
|
|
|
|
|
|
{ |
673
|
0
|
|
|
|
|
|
die 'ERROR: Net::Axigen::setAccountWebMailLanguage Domain '.$domain.' does not exist in AXIGEN'; |
674
|
|
|
|
|
|
|
} |
675
|
|
|
|
|
|
|
} |
676
|
|
|
|
|
|
|
|
677
|
|
|
|
|
|
|
# ================================================================== |
678
|
|
|
|
|
|
|
# setDomainQuotas |
679
|
|
|
|
|
|
|
# ================================================================== |
680
|
|
|
|
|
|
|
sub setDomainQuotas |
681
|
|
|
|
|
|
|
{ |
682
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
683
|
0
|
|
|
|
|
|
my $domain = shift @_; |
684
|
0
|
|
|
|
|
|
my $q = shift @_; |
685
|
|
|
|
|
|
|
|
686
|
0
|
|
|
|
|
|
my $r; |
687
|
|
|
|
|
|
|
|
688
|
0
|
0
|
|
|
|
|
if($this->_hasDomain($domain)) |
689
|
|
|
|
|
|
|
{ |
690
|
0
|
|
|
|
|
|
$r=$this->_cmd("UPDATE DOMAIN NAME $domain", 'domain'); |
691
|
0
|
|
|
|
|
|
$r=$this->_cmd('CONFIG adminLimits', 'domain-adminLimits'); |
692
|
0
|
|
|
|
|
|
$r=$this->_cmd('set maxAccounts '.$q->{ maxAccounts }, 'domain-adminLimits'); |
693
|
0
|
|
|
|
|
|
$r=$this->_cmd('set maxAccountMessageSizeQuota '.$q->{ maxAccountMessageSizeQuota }, 'domain-adminLimits'); |
694
|
0
|
|
|
|
|
|
$r=$this->_cmd('set maxPublicFolderMessageSizeQuota '.$q->{ maxPublicFolderMessageSizeQuota }, 'domain-adminLimits'); |
695
|
0
|
|
|
|
|
|
$r=$this->_cmd('COMMIT', 'domain'); |
696
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setDomainQuotas: ".$r->{rc_str}.": ".$domain; } |
|
0
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
|
698
|
0
|
|
|
|
|
|
$r=$this->_cmd('CONFIG accountDefaultQuotas', 'domain-accountDefaultQuotas'); |
699
|
0
|
|
|
|
|
|
$r=$this->_cmd('set quotaLimitNotificationEnabled yes', 'domain-accountDefaultQuotas'); |
700
|
|
|
|
|
|
|
|
701
|
|
|
|
|
|
|
# Default maximum size in KB of messages in a folder |
702
|
0
|
|
|
|
|
|
$r=$this->_cmd('set messageSize '.$q->{ messageSize }, 'domain-accountDefaultQuotas'); |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
# Maximum size in KB of all messages in all folders |
705
|
0
|
|
|
|
|
|
$r=$this->_cmd('set totalMessageSize '.$q->{ totalMessageSize }, 'domain-accountDefaultQuotas'); |
706
|
|
|
|
|
|
|
|
707
|
0
|
|
|
|
|
|
$r=$this->_cmd('DONE', 'domain'); |
708
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setDomainQuotas: ".$r->{rc_str}.": ".$domain; } |
|
0
|
|
|
|
|
|
|
709
|
0
|
|
|
|
|
|
$r=$this->_cmd('COMMIT', ''); |
710
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::setDomainQuotas: ".$r->{rc_str}.": ".$domain; } |
|
0
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
} |
712
|
|
|
|
|
|
|
else |
713
|
|
|
|
|
|
|
{ |
714
|
0
|
|
|
|
|
|
die 'ERROR: Net::Axigen::setDomainQuotas Domain '.$domain.' does not exist in AXIGEN'; |
715
|
|
|
|
|
|
|
} |
716
|
|
|
|
|
|
|
} |
717
|
|
|
|
|
|
|
|
718
|
|
|
|
|
|
|
# ================================================================== |
719
|
|
|
|
|
|
|
# saveConfig |
720
|
|
|
|
|
|
|
# ================================================================== |
721
|
|
|
|
|
|
|
sub saveConfig |
722
|
|
|
|
|
|
|
{ |
723
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
724
|
0
|
|
|
|
|
|
my $r=$this->_cmd('SAVE CONFIG', ''); |
725
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::saveConfig: ".$r->{rc_str}; } |
|
0
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
} |
727
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
# ================================================================== |
729
|
|
|
|
|
|
|
# compactAll |
730
|
|
|
|
|
|
|
# ================================================================== |
731
|
|
|
|
|
|
|
sub compactAll |
732
|
|
|
|
|
|
|
{ |
733
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
734
|
0
|
|
|
|
|
|
my $domain = shift @_; # compacted domain |
735
|
0
|
|
|
|
|
|
my $forced = shift @_; # force compacting |
736
|
|
|
|
|
|
|
|
737
|
0
|
|
|
|
|
|
my $r; |
738
|
|
|
|
|
|
|
|
739
|
0
|
0
|
|
|
|
|
if($this->_hasDomain($domain)) |
740
|
|
|
|
|
|
|
{ |
741
|
0
|
|
|
|
|
|
$r=$this->_cmd("UPDATE DOMAIN NAME $domain", 'domain'); |
742
|
|
|
|
|
|
|
|
743
|
0
|
|
|
|
|
|
my $cmd='COMPACT ALL'; |
744
|
0
|
0
|
|
|
|
|
if($forced) { $cmd=$cmd.' FORCED'; } |
|
0
|
|
|
|
|
|
|
745
|
0
|
|
|
|
|
|
my $r=$this->_cmd($cmd, 'domain'); |
746
|
|
|
|
|
|
|
|
747
|
0
|
|
|
|
|
|
$r=$this->_cmd('COMMIT', ''); |
748
|
0
|
0
|
|
|
|
|
if(!$r->{rc}) { die "Net::Axigen::compactAll: ".$r->{rc_str}.": ".$domain; } |
|
0
|
|
|
|
|
|
|
749
|
|
|
|
|
|
|
} |
750
|
|
|
|
|
|
|
else |
751
|
|
|
|
|
|
|
{ |
752
|
0
|
|
|
|
|
|
die 'ERROR: Net::Axigen::compactAll Domain '.$domain.' does not exist in AXIGEN'; |
753
|
|
|
|
|
|
|
} |
754
|
|
|
|
|
|
|
} |
755
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
# ================================================================== |
757
|
|
|
|
|
|
|
# compactAllDomains |
758
|
|
|
|
|
|
|
# ================================================================== |
759
|
|
|
|
|
|
|
sub compactAllDomains |
760
|
|
|
|
|
|
|
{ |
761
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
762
|
0
|
|
|
|
|
|
my $forced = shift @_; |
763
|
|
|
|
|
|
|
|
764
|
0
|
|
|
|
|
|
my $domain_list = $this->listDomains(); |
765
|
0
|
|
|
|
|
|
foreach my $domain(@$domain_list) |
766
|
|
|
|
|
|
|
{ |
767
|
0
|
|
|
|
|
|
$this->compactAll($domain, $forced); |
768
|
|
|
|
|
|
|
} |
769
|
|
|
|
|
|
|
} |
770
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
# ================================================ |
772
|
|
|
|
|
|
|
# to_utf8 |
773
|
|
|
|
|
|
|
# Преобразовать из win1251 в UTF8 |
774
|
|
|
|
|
|
|
# ================================================ |
775
|
|
|
|
|
|
|
sub to_utf8($) |
776
|
|
|
|
|
|
|
{ |
777
|
0
|
|
|
0
|
1
|
|
my $this = shift @_; |
778
|
0
|
|
|
|
|
|
my $str = shift @_; |
779
|
0
|
|
|
|
|
|
Encode::from_to($str, $this->{ locale }, 'utf-8'); |
780
|
0
|
|
|
|
|
|
return $str; |
781
|
|
|
|
|
|
|
} |
782
|
|
|
|
|
|
|
|
783
|
|
|
|
|
|
|
1; |
784
|
|
|
|
|
|
|
|
785
|
|
|
|
|
|
|
__END__ |