1
1
# Defines functions for this feature
2
+ use strict;
3
+ use warnings;
4
+ our %text ;
5
+ our $module_name ;
6
+ our $apachemod_lib_cmd ;
2
7
3
8
require ' virtualmin-google-analytics-lib.pl' ;
4
9
@@ -21,7 +26,7 @@ sub feature_losing
21
26
# editing form
22
27
sub feature_label
23
28
{
24
- local ($edit ) = @_ ;
29
+ my ($edit ) = @_ ;
25
30
return $edit ? $text {' feat_label2' } : $text {' feat_label' };
26
31
}
27
32
@@ -50,15 +55,15 @@ sub feature_check
50
55
# or an error message if not
51
56
sub feature_depends
52
57
{
53
- local ($d , $oldd ) = @_ ;
58
+ my ($d , $oldd ) = @_ ;
54
59
return $text {' feat_edepweb' } if (!$d -> {' web' });
55
60
if (defined (&virtual_server::list_domain_php_inis) &&
56
61
&foreign_check(" phpini" ) &&
57
62
(!$oldd || !$oldd -> {$module_name })) {
58
63
&foreign_require(" phpini" , " phpini-lib.pl" );
59
64
foreach my $ini (&virtual_server::list_domain_php_inis($d )) {
60
- local $pconf = &phpini::get_config($ini -> [1]);
61
- local $comp = &phpini::find_value(
65
+ my $pconf = &phpini::get_config($ini -> [1]);
66
+ my $comp = &phpini::find_value(
62
67
" zlib.output_compression" , $pconf );
63
68
if (lc ($comp ) =~ / on|true|yes/ ) {
64
69
return &text(' feat_ezlib' ,
@@ -84,7 +89,7 @@ sub feature_clash
84
89
# parent domains
85
90
sub feature_suitable
86
91
{
87
- local ($parentdom , $aliasdom , $subdom ) = @_ ;
92
+ my ($parentdom , $aliasdom , $subdom ) = @_ ;
88
93
return $aliasdom ? 0 : 1; # not for alias domains
89
94
}
90
95
@@ -93,44 +98,44 @@ sub feature_suitable
93
98
# or 0 if not
94
99
sub feature_import
95
100
{
96
- local ($dname , $user , $db ) = @_ ;
97
- local $fakedom = { ' dom' => $dname };
101
+ my ($dname , $user , $db ) = @_ ;
102
+ my $fakedom = { ' dom' => $dname };
98
103
return &has_analytics_directives($fakedom );
99
104
}
100
105
101
106
# feature_setup(&domain)
102
107
# Called when this feature is added, with the domain object as a parameter
103
108
sub feature_setup
104
109
{
105
- local ($d ) = @_ ;
110
+ my ($d ) = @_ ;
106
111
&$virtual_server::first_print ($text {' feat_setup' });
107
112
&virtual_server::obtain_lock_web($_ [0])
108
113
if (defined (&virtual_server::obtain_lock_web));
109
114
110
115
&virtual_server::require_apache();
111
- local $conf = &apache::get_config();
112
- local @ports = ( $d -> {' web_port' } );
116
+ my $conf = &apache::get_config();
117
+ my @ports = ( $d -> {' web_port' } );
113
118
push (@ports , $d -> {' web_sslport' }) if ($d -> {' ssl' });
114
- local $done = 0;
119
+ my $done = 0;
115
120
foreach my $p (@ports ) {
116
- local ($virt , $vconf ) =
121
+ my ($virt , $vconf ) =
117
122
&virtual_server::get_apache_virtual($d -> {' dom' }, $p );
118
123
next if (!$virt );
119
124
120
125
# Add PerlRequire for apachemod.pl, which sets lib path
121
126
&lock_file($virt -> {' file' });
122
- local @prq = &apache::find_directive(" PerlRequire" , $vconf );
127
+ my @prq = &apache::find_directive(" PerlRequire" , $vconf );
123
128
push (@prq , $apachemod_lib_cmd );
124
129
&apache::save_directive(" PerlRequire" , \@prq , $vconf , $conf );
125
130
126
131
# Add filter directive
127
- local @pof = &apache::find_directive(" PerlOutputFilterHandler" , $vconf );
132
+ my @pof = &apache::find_directive(" PerlOutputFilterHandler" , $vconf );
128
133
push (@pof , " Virtualmin::GoogleAnalytics" );
129
134
&apache::save_directive(" PerlOutputFilterHandler" , \@pof , $vconf ,$conf );
130
135
131
136
# Add PerlSetVar SSL
132
137
if ($p == $d -> {' web_sslport' }) {
133
- local @psv = &apache::find_directive(" PerlSetVar" , $vconf );
138
+ my @psv = &apache::find_directive(" PerlSetVar" , $vconf );
134
139
@psv = &unique(@psv , " SSL 1" );
135
140
&apache::save_directive(" PerlSetVar" , \@psv , $vconf , $conf );
136
141
}
@@ -169,29 +174,29 @@ sub feature_modify
169
174
# Called when this feature is disabled, or when the domain is being deleted
170
175
sub feature_delete
171
176
{
172
- local ($d ) = @_ ;
177
+ my ($d ) = @_ ;
173
178
&$virtual_server::first_print ($text {' feat_delete' });
174
179
&virtual_server::obtain_lock_web($_ [0])
175
180
if (defined (&virtual_server::obtain_lock_web));
176
181
177
182
&virtual_server::require_apache();
178
- local $conf = &apache::get_config();
179
- local @ports = ( $d -> {' web_port' } );
183
+ my $conf = &apache::get_config();
184
+ my @ports = ( $d -> {' web_port' } );
180
185
push (@ports , $d -> {' web_sslport' }) if ($d -> {' ssl' });
181
- local $done = 0;
186
+ my $done = 0;
182
187
foreach my $p (@ports ) {
183
- local ($virt , $vconf ) =
188
+ my ($virt , $vconf ) =
184
189
&virtual_server::get_apache_virtual($d -> {' dom' }, $p );
185
190
next if (!$virt );
186
191
187
192
# Remove PerlRequire and PerlOutputFilterHandler
188
193
&lock_file($virt -> {' file' });
189
- local @prq = &apache::find_directive(" PerlRequire" , $vconf );
190
- local @newprq = grep { $_ ne $apachemod_lib_cmd } @prq ;
194
+ my @prq = &apache::find_directive(" PerlRequire" , $vconf );
195
+ my @newprq = grep { $_ ne $apachemod_lib_cmd } @prq ;
191
196
&apache::save_directive(" PerlRequire" , \@newprq ,
192
197
$vconf , $conf );
193
- local @pof = &apache::find_directive(" PerlOutputFilterHandler" , $vconf );
194
- local @newpof = grep { $_ ne " Virtualmin::GoogleAnalytics" } @pof ;
198
+ my @pof = &apache::find_directive(" PerlOutputFilterHandler" , $vconf );
199
+ my @newpof = grep { $_ ne " Virtualmin::GoogleAnalytics" } @pof ;
195
200
&apache::save_directive(" PerlOutputFilterHandler" , \@newpof ,
196
201
$vconf , $conf );
197
202
@@ -218,7 +223,7 @@ sub feature_delete
218
223
# the Webmin user when this feature is enabled
219
224
sub feature_webmin
220
225
{
221
- local @doms = map { $_ -> {' dom' } } grep { $_ -> {$module_name } } @{$_ [1]};
226
+ my @doms = map { $_ -> {' dom' } } grep { $_ -> {$module_name } } @{$_ [1]};
222
227
if (@doms ) {
223
228
return ( [ $module_name ,
224
229
{ ' domains' => join (" " , @doms ),
@@ -234,7 +239,7 @@ sub feature_webmin
234
239
# Returns an array of link objects for webmin modules for this feature
235
240
sub feature_links
236
241
{
237
- local ($d ) = @_ ;
242
+ my ($d ) = @_ ;
238
243
return ( { ' mod' => $module_name ,
239
244
' desc' => $text {' links_link' },
240
245
' page' => ' edit.cgi?dom=' .&urlize($d -> {' id' })." &virtualmin=1" ,
@@ -249,7 +254,7 @@ sub feature_modules
249
254
250
255
sub feature_validate
251
256
{
252
- local ($d ) = @_ ;
257
+ my ($d ) = @_ ;
253
258
return &has_analytics_directives($d ) ? undef : $text {' feat_notvalid' };
254
259
}
255
260
0 commit comments