| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MPMinus::Helper::Util; # $Id: Util.pm 224 2017-04-04 10:27:41Z minus $ |
|
2
|
1
|
|
|
1
|
|
15761
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
48
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
MPMinus::Helper::Util - MPMinus Helper's utility |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Version 1.03 |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use MPMinus::Helper::Util; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
MPMinus Helper's utility |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=over 8 |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=item B<cleanProjectName> |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $name = cleanProjectName( "foo" ); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Returns clean name of project |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=item B<cleanServerName> |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $name = cleanServerName( "localhost:80" ); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Returns clean name of server |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=item B<cleanServerNameF> |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $name = cleanServerNameF( "localhost" ); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Returns clean name of server as file |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=item B<getApache>, B<getApache2> |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $hash = getApache(); |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Returns HTTPD_ROOT, SERVER_CONFIG_FILE, SERVER_VERSION and APACHE_VERSION as hash structure |
|
47
|
|
|
|
|
|
|
(reference). |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item B<newconfig> |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $config = newconfig( $c ); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Returns new configuration |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item B<to_void> |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $v = to_void( $value ); |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Returns '' (void) if undefined $value else - returns $value |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=back |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 AUTHOR |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Sergey Lepenkov (Serz Minus) L<http://www.serzik.com> E<lt>minus@serzik.comE<gt> |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Copyright (C) 1998-2017 D&D Corporation. All Rights Reserved |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 LICENSE |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify |
|
74
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
|
75
|
|
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or |
|
76
|
|
|
|
|
|
|
(at your option) any later version. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
|
79
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
80
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
81
|
|
|
|
|
|
|
GNU General Public License for more details. |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
See C<LICENSE> file |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
|
86
|
|
|
|
|
|
|
|
|
87
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
59
|
|
|
88
|
|
|
|
|
|
|
$VERSION = 1.03; |
|
89
|
|
|
|
|
|
|
|
|
90
|
1
|
|
|
1
|
|
6
|
use base qw /Exporter/; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
85
|
|
|
91
|
|
|
|
|
|
|
our @EXPORT = qw( |
|
92
|
|
|
|
|
|
|
getApache getApache2 |
|
93
|
|
|
|
|
|
|
newconfig |
|
94
|
|
|
|
|
|
|
to_void |
|
95
|
|
|
|
|
|
|
cleanProjectName |
|
96
|
|
|
|
|
|
|
cleanServerName |
|
97
|
|
|
|
|
|
|
cleanServerNameF |
|
98
|
|
|
|
|
|
|
); |
|
99
|
|
|
|
|
|
|
|
|
100
|
1
|
|
|
1
|
|
554
|
use CTK::Util qw/ :ALL /; |
|
|
1
|
|
|
|
|
119601
|
|
|
|
1
|
|
|
|
|
479
|
|
|
101
|
1
|
|
|
1
|
|
373
|
use CTK::ConfGenUtil; |
|
|
1
|
|
|
|
|
686
|
|
|
|
1
|
|
|
|
|
56
|
|
|
102
|
1
|
|
|
1
|
|
381
|
use Try::Tiny; |
|
|
1
|
|
|
|
|
1419
|
|
|
|
1
|
|
|
|
|
1222
|
|
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub getApache2 { |
|
105
|
|
|
|
|
|
|
# Ïðîöåäóðà ïîëó÷åíèÿ (HTTP_ROOT, SERVER_CONFIG_FILE, SERVER_VERSION, APACHE_VERSION) èñõîäÿ èç äàííûõ çàïóùåííîãî APACHE |
|
106
|
1
|
|
|
1
|
1
|
1
|
my $httpdata; |
|
107
|
|
|
|
|
|
|
my $httpdpath; |
|
108
|
1
|
50
|
|
|
|
5
|
if (isostype("Windows")) { |
|
109
|
0
|
|
|
|
|
0
|
$httpdpath = execute(q{pv.exe -e 2>NUL}); |
|
110
|
0
|
0
|
|
|
|
0
|
if ($httpdpath =~ /^httpd.exe\s+\d+\s+\S+\s+(.+?)\s*$/m) { |
|
111
|
0
|
|
|
|
|
0
|
$httpdpath = $1; |
|
112
|
0
|
|
|
|
|
0
|
$httpdata = execute(qq{$httpdpath -V}); |
|
113
|
|
|
|
|
|
|
} else { |
|
114
|
0
|
0
|
|
|
|
0
|
if ($httpdpath =~ /^(apache.+?)\s+\d+\s+\S+\s+(.+?)\1\s*$/im) { |
|
115
|
0
|
|
|
|
|
0
|
$httpdpath = catfile($2,'httpd.exe'); |
|
116
|
0
|
|
|
|
|
0
|
$httpdata = execute(qq{$httpdpath -V}); |
|
117
|
|
|
|
|
|
|
} else { |
|
118
|
0
|
|
|
|
|
0
|
$httpdpath = ''; |
|
119
|
0
|
|
|
|
|
0
|
$httpdata = ''; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
} else { |
|
123
|
|
|
|
|
|
|
# Fix #198 |
|
124
|
1
|
|
|
|
|
39
|
my @err; |
|
125
|
1
|
|
|
|
|
2
|
foreach my $httpd (qw/httpd apache apachectl apache2ctl apache2 apache22/) { |
|
126
|
6
|
|
|
|
|
17
|
my $cmd = qq{$httpd -V}; |
|
127
|
|
|
|
|
|
|
try { |
|
128
|
6
|
|
|
6
|
|
273
|
$httpdata = execute($cmd) |
|
129
|
|
|
|
|
|
|
} catch { |
|
130
|
6
|
|
|
6
|
|
19646
|
push @err, sprintf("%s: %s", $cmd, $_) |
|
131
|
6
|
|
|
|
|
40
|
}; |
|
132
|
6
|
50
|
33
|
|
|
143
|
last if $httpdata && $httpdata =~ /HTTPD_ROOT/im; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
1
|
50
|
33
|
|
|
232
|
carp(join "\n", @err) if (!$httpdata) && @err |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
1
|
50
|
|
|
|
30
|
my $httpd_root = $httpdata =~ /HTTPD_ROOT\="(.+?)"/m ? $1 : ''; |
|
138
|
1
|
50
|
|
|
|
13
|
my $server_config_file = $httpdata =~ /SERVER_CONFIG_FILE\="(.+?)"/m ? $1 : ''; |
|
139
|
1
|
50
|
|
|
|
13
|
my $sver = $httpdata =~ /version\:\s+[a-z]+\/([0-9.]+)/im ? $1 : ''; |
|
140
|
1
|
|
|
|
|
4
|
my $aver = 0; |
|
141
|
|
|
|
|
|
|
|
|
142
|
1
|
50
|
|
|
|
11
|
if ($sver =~ /([0-9]+)\.([0-9]+)\.([0-9]+)/) { |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
0
|
$aver = $1 + ($2/100) + ($3/10000); |
|
144
|
|
|
|
|
|
|
} elsif ($sver =~ /([0-9]+)\.([0-9]+)/) { |
|
145
|
0
|
|
|
|
|
0
|
$aver = $1 + ($2/100); |
|
146
|
|
|
|
|
|
|
} elsif ($sver =~ /([0-9]+)/) { |
|
147
|
0
|
|
|
|
|
0
|
$aver = $1; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
1
|
|
|
|
|
2
|
my $httpdconfig = ''; |
|
151
|
1
|
50
|
33
|
|
|
7
|
if ($server_config_file && $httpd_root) { |
|
152
|
0
|
|
|
|
|
0
|
$httpdconfig = catfile($httpd_root,$server_config_file); |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
|
|
155
|
1
|
|
|
|
|
5
|
my $acc = ''; |
|
156
|
1
|
50
|
33
|
|
|
4
|
unless ($httpdconfig && -e $httpdconfig) { |
|
157
|
1
|
|
|
|
|
16
|
foreach (split /[\/\\]/, $httpdpath) { |
|
158
|
0
|
0
|
|
|
|
0
|
$acc = $acc ? catfile($acc,$_) : $_; |
|
159
|
|
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
0
|
$httpdconfig = catfile($acc,$server_config_file); |
|
161
|
0
|
0
|
0
|
|
|
0
|
if ($httpdconfig && (-e $httpdconfig) && ((-f $httpdconfig) || (-l $httpdconfig))) { |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
162
|
0
|
|
|
|
|
0
|
last; |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
return { |
|
168
|
1
|
|
33
|
|
|
24
|
HTTPD_ROOT => $acc || $httpd_root, |
|
|
|
|
50
|
|
|
|
|
|
169
|
|
|
|
|
|
|
SERVER_CONFIG_FILE => $httpdconfig || '', |
|
170
|
|
|
|
|
|
|
SERVER_VERSION => $sver, |
|
171
|
|
|
|
|
|
|
APACHE_VERSION => $aver, |
|
172
|
|
|
|
|
|
|
}; |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
} |
|
175
|
1
|
|
|
1
|
1
|
16
|
sub getApache { goto &getApache2 } |
|
176
|
|
|
|
|
|
|
sub newconfig { |
|
177
|
|
|
|
|
|
|
# Çàïðîñ äàííûõ êîíôèãóðàöèè |
|
178
|
0
|
|
|
0
|
1
|
|
my $c = shift; |
|
179
|
0
|
|
|
|
|
|
my $cfg = $c->config(); |
|
180
|
|
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
my %newcfg = ( |
|
182
|
|
|
|
|
|
|
Include => 'conf/*.conf', |
|
183
|
|
|
|
|
|
|
); |
|
184
|
|
|
|
|
|
|
|
|
185
|
0
|
|
|
|
|
|
my ($k,$v,$d) = ('','',''); |
|
186
|
0
|
|
|
|
|
|
my $apache = getApache(); |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
# Apache HTTPD_ROOT |
|
189
|
0
|
|
|
|
|
|
$k = "HttpdRoot"; |
|
190
|
0
|
|
0
|
|
|
|
$newcfg{$k} = $c->cli_prompt('Apache HTTPD_ROOT:', _void(value($cfg,lc($k)) || $apache->{HTTPD_ROOT})); |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
# Apache SERVER_CONFIG_FILE |
|
193
|
0
|
|
|
|
|
|
$k = "ServerConfigFile"; |
|
194
|
0
|
|
0
|
|
|
|
$newcfg{$k} = $c->cli_prompt('Apache SERVER_CONFIG_FILE:', _void(value($cfg,lc($k)) || $apache->{SERVER_CONFIG_FILE})); |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
# Apache configuration |
|
197
|
0
|
|
|
|
|
|
my %apacheconfig; |
|
198
|
0
|
0
|
0
|
|
|
|
if ((-e $newcfg{ServerConfigFile}) && -e $newcfg{HttpdRoot}) { |
|
199
|
|
|
|
|
|
|
my $apacheconf = new Config::General( |
|
200
|
|
|
|
|
|
|
-ConfigFile => $newcfg{ServerConfigFile}, |
|
201
|
0
|
|
|
|
|
|
-ConfigPath => [$newcfg{HttpdRoot}], |
|
202
|
|
|
|
|
|
|
-ApacheCompatible => 1, |
|
203
|
|
|
|
|
|
|
-LowerCaseNames => 1, |
|
204
|
|
|
|
|
|
|
); |
|
205
|
0
|
|
|
|
|
|
%apacheconfig = $apacheconf->getall; |
|
206
|
|
|
|
|
|
|
} |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
# ModperlRoot |
|
209
|
0
|
|
|
|
|
|
$k = "ModperlRoot"; |
|
210
|
0
|
|
|
|
|
|
my @mpvs = ('none', _void(webdir()), 'custom' |
|
211
|
|
|
|
|
|
|
); |
|
212
|
0
|
|
0
|
|
|
|
my $vks = value($apacheconfig{documentroot} || ''); |
|
213
|
0
|
0
|
|
|
|
|
unshift(@mpvs,$vks) if $vks; |
|
214
|
0
|
|
|
|
|
|
$v = $c->cli_select('ModperlRoot directory:',\@mpvs,1); |
|
215
|
0
|
0
|
0
|
|
|
|
$v = $c->cli_prompt('ModperlRoot directory:',_void(value($cfg,lc($k))),) if ($v && $v eq 'custom'); |
|
216
|
0
|
0
|
0
|
|
|
|
$newcfg{$k} = ($v && $v eq 'none') ? undef : $v; |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
# NameVirtualHost |
|
219
|
0
|
|
|
|
|
|
$k = "NameVirtualHost"; |
|
220
|
0
|
|
0
|
|
|
|
my $namevirtualhost = array($apacheconfig{namevirtualhost} || ['*:80']); |
|
221
|
0
|
|
|
|
|
|
push @$namevirtualhost, 'custom','none'; |
|
222
|
0
|
|
|
|
|
|
$v = $c->cli_select('NameVirtualHost:', $namevirtualhost, 1); |
|
223
|
0
|
0
|
0
|
|
|
|
$v = $c->cli_prompt('NameVirtualHost:',_void(value($cfg,lc($k))),) if ($v && $v eq 'custom'); |
|
224
|
0
|
0
|
0
|
|
|
|
$newcfg{$k} = ($v && $v eq 'none') ? undef : $v; |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
# ServerName |
|
227
|
0
|
|
|
|
|
|
$k = "ServerName"; |
|
228
|
0
|
|
0
|
|
|
|
my $servername = array($apacheconfig{servername} || ['localhost']); |
|
229
|
0
|
|
|
|
|
|
push @$servername, 'custom','none'; |
|
230
|
0
|
|
|
|
|
|
$v = $c->cli_select('ServerName (host):', $servername, 1); |
|
231
|
0
|
0
|
0
|
|
|
|
$v = $c->cli_prompt('ServerName (host):',_void(value($cfg,lc($k))),) if ($v && $v eq 'custom'); |
|
232
|
0
|
0
|
0
|
|
|
|
$newcfg{$k} = ($v && $v eq 'none') ? undef : $v; |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
# ErrorMail |
|
235
|
0
|
|
|
|
|
|
$k = "ErrorMail"; |
|
236
|
0
|
|
0
|
|
|
|
my $errormail = array($apacheconfig{serveradmin} || ['root@localhost']); |
|
237
|
0
|
|
|
|
|
|
push @$errormail, 'custom','none'; |
|
238
|
0
|
|
|
|
|
|
$v = $c->cli_select('ErrorMail (ServerAdmin):', $errormail, 1); |
|
239
|
0
|
0
|
0
|
|
|
|
$v = $c->cli_prompt('ErrorMail: (ServerAdmin):',_void(value($cfg,lc($k))),) if ($v && $v eq 'custom'); |
|
240
|
0
|
0
|
0
|
|
|
|
$newcfg{$k} = ($v && $v eq 'none') ? undef : $v; |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
# SMTP |
|
243
|
0
|
|
|
|
|
|
$k = "SMTP"; |
|
244
|
0
|
|
|
|
|
|
$newcfg{$k} = $c->cli_prompt('SMTP server:', _void(value($cfg,lc($k)))); |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
# MailTo |
|
247
|
0
|
|
|
|
|
|
$k = "MailTo"; |
|
248
|
0
|
|
0
|
|
|
|
$newcfg{$k} = $c->cli_prompt('Address MailTO:', _void(value($cfg,lc($k)) || $newcfg{ErrorMail})); |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
# MailCC |
|
251
|
0
|
|
|
|
|
|
$k = "MailCC"; |
|
252
|
0
|
|
|
|
|
|
$newcfg{$k} = $c->cli_prompt('Address MailCC:', _void(value($cfg,lc($k)))); |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
# MailFrom |
|
255
|
0
|
|
|
|
|
|
$k = "MailFrom"; |
|
256
|
0
|
|
0
|
|
|
|
$newcfg{$k} = $c->cli_prompt('Address MailFrom:', _void(value($cfg,lc($k)) || $newcfg{ErrorMail})); |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
# MailCharset |
|
259
|
0
|
|
|
|
|
|
$k = "MailCharset"; |
|
260
|
0
|
|
0
|
|
|
|
$newcfg{$k} = $c->cli_prompt('Mail Charset for translating into UTF8:', _void(value($cfg,lc($k)) || 'Windows-1251')); |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
# MailCmd |
|
263
|
0
|
|
|
|
|
|
$k = "MailCmd"; |
|
264
|
0
|
|
0
|
|
|
|
$newcfg{$k} = $c->cli_prompt('Mail program (sendmail):', _void(value($cfg,lc($k)) || '/usr/sbin/sendmail')); |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
# MailFlag |
|
267
|
0
|
|
|
|
|
|
$k = "MailFlag"; |
|
268
|
0
|
|
0
|
|
|
|
$newcfg{$k} = $c->cli_prompt('Mail program\'s flag:', _void(value($cfg,lc($k)) || '-t')); |
|
269
|
|
|
|
|
|
|
|
|
270
|
0
|
|
|
|
|
|
return { %newcfg }; |
|
271
|
|
|
|
|
|
|
} |
|
272
|
0
|
|
|
0
|
1
|
|
sub to_void { goto &_void } |
|
273
|
|
|
|
|
|
|
sub cleanProjectName { |
|
274
|
|
|
|
|
|
|
# Ïðàâêà (÷èñòêà) èìåíè ïðîåêòà |
|
275
|
0
|
|
|
0
|
1
|
|
my $pn = _void(shift); |
|
276
|
0
|
|
|
|
|
|
$pn =~ s/[^a-z0-9_]/X/ig; |
|
277
|
0
|
|
|
|
|
|
return $pn; |
|
278
|
|
|
|
|
|
|
} |
|
279
|
|
|
|
|
|
|
sub cleanServerName { |
|
280
|
|
|
|
|
|
|
# Ïðàâêà (÷èñòêà) èìåíè ñåðâåðà (ñàéòà) |
|
281
|
0
|
|
|
0
|
1
|
|
my $sn = _void(shift); |
|
282
|
0
|
|
|
|
|
|
$sn =~ s/[^a-z0-9_\-.:]/X/ig; |
|
283
|
0
|
|
|
|
|
|
return $sn; |
|
284
|
|
|
|
|
|
|
} |
|
285
|
|
|
|
|
|
|
sub cleanServerNameF { |
|
286
|
|
|
|
|
|
|
# Ïðàâêà (÷èñòêà) èìåíè ñåðâåðà (ñàéòà) â ñòàíäàðòå èìåí ôàéëîâ |
|
287
|
0
|
|
|
0
|
1
|
|
my $sn = _void(shift); |
|
288
|
0
|
|
|
|
|
|
$sn =~ s/[^a-z0-9_\-.]//ig; |
|
289
|
0
|
|
|
|
|
|
return $sn; |
|
290
|
|
|
|
|
|
|
} |
|
291
|
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
sub _void { |
|
293
|
|
|
|
|
|
|
# Âîçâðàùàåò '' (void) ìåñòî undef |
|
294
|
0
|
|
|
0
|
|
|
my $v = shift; |
|
295
|
0
|
0
|
|
|
|
|
return '' unless defined $v; |
|
296
|
0
|
|
|
|
|
|
return $v; |
|
297
|
|
|
|
|
|
|
} |
|
298
|
|
|
|
|
|
|
1; |
|
299
|
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
__END__ |
|
301
|
|
|
|
|
|
|
|