Skip to content

Commit 7c1a85a

Browse files
committed
strict/warn
1 parent 7d0087d commit 7c1a85a

8 files changed

+123
-80
lines changed

cgi_args.pl

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use strict;
2+
use warnings;
3+
our $module_name;
14

25
do 'virtualmin-google-analytics-lib.pl';
36

edit.cgi

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#!/usr/local/bin/perl
22
# Show a form for setting the analytics account for some domain
3+
use strict;
4+
use warnings;
5+
our (%text, %in);
6+
our @tracking_services;
37

48
require './virtualmin-google-analytics-lib.pl';
59
&ReadParse();
6-
$d = &virtual_server::get_domain($in{'dom'});
10+
my $d = &virtual_server::get_domain($in{'dom'});
711
&virtual_server::can_edit_domain($d) || &error($text{'edit_ecannot'});
812
&has_analytics_directives($d) || &error($text{'edit_ehas'});
913

@@ -14,20 +18,21 @@ print &ui_hidden("virtualmin", $in{'virtualmin'}),"\n";
1418
print &ui_hidden("dom", $in{'dom'}),"\n";
1519
print &ui_table_start($text{'edit_header'}, undef, 2);
1620

17-
$dname = defined(&virtual_server::show_domain_name) ?
21+
my $dname = defined(&virtual_server::show_domain_name) ?
1822
&virtual_server::show_domain_name($d) : $d->{'dom'};
1923
print &ui_table_row($text{'edit_dom'}, "<tt>$dname</tt>");
2024

2125
# Show ID input for each account
22-
foreach $s (@tracking_services) {
23-
$account = &{$s->[1]}($d);
26+
foreach my $s (@tracking_services) {
27+
my $account = &{$s->[1]}($d);
2428
print &ui_table_row(&hlink($text{'edit_'.$s->[0]}, $s->[0]),
2529
&ui_opt_textbox($s->[0], $account, 20,
2630
$text{'edit_dis'}, $text{'edit_ena'}));
2731
}
2832

2933
# Show base URL for Piwik
30-
$vurl = &get_perlsetvar($d, "PiwikURL");
34+
my $vurl = &get_perlsetvar($d, "PiwikURL");
35+
my $urlin;
3136
if ($vurl) {
3237
$urlin = &ui_opt_textbox("piwikurl", $vurl, 40, $text{'edit_notset'});
3338
}
@@ -38,12 +43,12 @@ else {
3843
print &ui_table_row(&hlink($text{'edit_piwikurl'}, 'piwikurl'), $urlin);
3944

4045
# Show field for arbitrary head and body javascript
41-
$headjs_file = &get_perlsetvar($d, "HeadJavascriptFile");
42-
$headjs = $headjs_file ? &read_file_contents($headjs_file) : undef;
46+
my $headjs_file = &get_perlsetvar($d, "HeadJavascriptFile");
47+
my $headjs = $headjs_file ? &read_file_contents($headjs_file) : undef;
4348
print &ui_table_row(&hlink($text{'edit_headjs'}, 'headjs'),
4449
&ui_textarea("headjs", $headjs, 5, 60));
45-
$bodyjs_file = &get_perlsetvar($d, "BodyJavascriptFile");
46-
$bodyjs = $bodyjs_file ? &read_file_contents($bodyjs_file) : undef;
50+
my $bodyjs_file = &get_perlsetvar($d, "BodyJavascriptFile");
51+
my $bodyjs = $bodyjs_file ? &read_file_contents($bodyjs_file) : undef;
4752
print &ui_table_row(&hlink($text{'edit_bodyjs'}, 'bodyjs'),
4853
&ui_textarea("bodyjs", $bodyjs, 5, 60));
4954

index.cgi

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,45 @@
11
#!/usr/local/bin/perl
22
# Show domains that have analytics enabled
3+
use strict;
4+
use warnings;
5+
our %text;
6+
our $module_name;
7+
our @tracking_services;
38

49
require './virtualmin-google-analytics-lib.pl';
510
&ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
611

7-
@doms = grep { &virtual_server::can_edit_domain($_) && !$_->{'alias'} }
12+
my @doms = grep { &virtual_server::can_edit_domain($_) && !$_->{'alias'} }
813
&virtual_server::list_domains();
14+
no warnings "once"; # XXX sniffy.
915
if (!@doms) {
1016
# User has no domains
1117
print "<b>$text{'index_nodoms'}</b>\n";
1218
}
1319
elsif (&indexof($module_name, @virtual_server::confplugins) < 0) {
1420
# Plugin is not enabled
15-
$cgi = $virtual_server::module_info{'version'} >= 3.47 ?
21+
my $cgi = $virtual_server::module_info{'version'} >= 3.47 ?
1622
"edit_newfeatures.cgi" : "edit_newplugins.cgi";
1723
print "<b>",&text('index_eplugin',
1824
"../virtual-server/$cgi"),"</b><p>\n";
1925
}
2026
else {
2127
# Make table rows
22-
@table = ( );
23-
foreach $d (@doms) {
24-
$has = &has_analytics_directives($d);
25-
@accounts = ( );
28+
my @table;
29+
foreach my $d (@doms) {
30+
my $has = &has_analytics_directives($d);
31+
my @accounts;
2632
if ($has) {
2733
# Find all tracking services
28-
foreach $s (@tracking_services) {
29-
$a = &{$s->[1]}($d);
34+
foreach my $s (@tracking_services) {
35+
my $a = &{$s->[1]}($d);
3036
if ($a) {
3137
push(@accounts,
3238
&text('index_'.$s->[0], $a));
3339
}
3440
}
3541
}
36-
@actions = ( );
42+
my @actions;
3743
push(@actions, "<a href='edit.cgi?dom=$d->{'id'}'>".
3844
"$text{'index_edit'}</a>") if ($has);
3945
my $prog = &virtual_server::can_config_domain($d) ?
@@ -55,6 +61,7 @@ else {
5561
[ $text{'index_dom'}, $text{'index_status'}, $text{'index_actions'} ],
5662
100, \@table, undef, 1);
5763
}
64+
use warnings "once";
5865

5966
&ui_print_footer("/", $text{'index'});
6067

log_parser.pl

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# log_parser.pl
22
# Functions for parsing this module's logs
3+
use strict;
4+
use warnings;
35

46
do 'virtualmin-google-analytics-lib.pl';
57

68
# parse_webmin_log(user, script, action, type, object, &params)
79
# Converts logged information from this module into human-readable form
810
sub parse_webmin_log
911
{
10-
local ($user, $script, $action, $type, $object, $p) = @_;
12+
my ($user, $script, $action, $type, $object, $p) = @_;
1113
if ($action eq 'save') {
1214
return &text('log_save', "<tt>".&html_escape($object)."</tt>");
1315
}

postinstall.pl

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use strict;
2+
use warnings;
3+
14
do 'virtualmin-google-analytics-lib.pl';
25

36
sub module_install

save.cgi

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
#!/usr/local/bin/perl
22
# Update the analytics account for some domain
3+
use strict;
4+
use warnings;
5+
our (%text, %in);
6+
our @tracking_services;
7+
our $module_config_directory;
38

49
require './virtualmin-google-analytics-lib.pl';
510
&ReadParse();
611
&error_setup($text{'save_err'});
712

813
# Validate inputs
9-
$d = &virtual_server::get_domain($in{'dom'});
14+
my $d = &virtual_server::get_domain($in{'dom'});
1015
&virtual_server::can_edit_domain($d) || &error($text{'edit_ecannot'});
1116
&has_analytics_directives($d) || &error($text{'edit_ehas'});
12-
foreach $s (@tracking_services) {
17+
foreach my $s (@tracking_services) {
1318
$in{$s->[0].'_def'} || $in{$s->[0]} =~ /^$s->[3]$/ ||
1419
&error($text{'save_e'.$s->[0]});
1520
}
1621

1722
# Update the server
1823
&virtual_server::set_all_null_print();
19-
foreach $s (@tracking_services) {
24+
foreach my $s (@tracking_services) {
2025
&{$s->[2]}($d, $in{$s->[0].'_def'} ? undef : $in{$s->[0]});
2126
}
2227
if (!$in{'piwik_def'} && $in{'piwikurl_def'}) {
@@ -31,24 +36,28 @@ if (!$in{'piwikurl_def'}) {
3136
}
3237

3338
# Save head and body javascript
34-
$headjs_file = &get_perlsetvar($d, "HeadJavascriptFile");
39+
my $headjs_file = &get_perlsetvar($d, "HeadJavascriptFile");
3540
if ($in{'headjs'} =~ /\S/) {
3641
$headjs_file = "$module_config_directory/$d->{'id'}.head.js";
42+
no strict "subs";
3743
&open_tempfile(HEAD, ">$headjs_file");
3844
&print_tempfile(HEAD, $in{'headjs'});
3945
&close_tempfile(HEAD);
46+
use strict "subs";
4047
&set_ownership_permissions(undef, undef, 0755, $headjs_file);
4148
&save_perlsetvar($d, $headjs_file, "HeadJavascriptFile");
4249
}
4350
else {
4451
&save_perlsetvar($d, undef, "HeadJavascriptFile");
4552
}
46-
$bodyjs_file = &get_perlsetvar($d, "BodyJavascriptFile");
53+
my $bodyjs_file = &get_perlsetvar($d, "BodyJavascriptFile");
4754
if ($in{'bodyjs'} =~ /\S/) {
4855
$bodyjs_file = "$module_config_directory/$d->{'id'}.body.js";
56+
no strict "subs";
4957
&open_tempfile(HEAD, ">$bodyjs_file");
5058
&print_tempfile(HEAD, $in{'bodyjs'});
5159
&close_tempfile(HEAD);
60+
use strict "subs";
5261
&set_ownership_permissions(undef, undef, 0755, $bodyjs_file);
5362
&save_perlsetvar($d, $bodyjs_file, "BodyJavascriptFile");
5463
}

virtual_feature.pl

+32-27
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# Defines functions for this feature
2+
use strict;
3+
use warnings;
4+
our %text;
5+
our $module_name;
6+
our $apachemod_lib_cmd;
27

38
require 'virtualmin-google-analytics-lib.pl';
49

@@ -21,7 +26,7 @@ sub feature_losing
2126
# editing form
2227
sub feature_label
2328
{
24-
local ($edit) = @_;
29+
my ($edit) = @_;
2530
return $edit ? $text{'feat_label2'} : $text{'feat_label'};
2631
}
2732

@@ -50,15 +55,15 @@ sub feature_check
5055
# or an error message if not
5156
sub feature_depends
5257
{
53-
local ($d, $oldd) = @_;
58+
my ($d, $oldd) = @_;
5459
return $text{'feat_edepweb'} if (!$d->{'web'});
5560
if (defined(&virtual_server::list_domain_php_inis) &&
5661
&foreign_check("phpini") &&
5762
(!$oldd || !$oldd->{$module_name})) {
5863
&foreign_require("phpini", "phpini-lib.pl");
5964
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(
6267
"zlib.output_compression", $pconf);
6368
if (lc($comp) =~ /on|true|yes/) {
6469
return &text('feat_ezlib',
@@ -84,7 +89,7 @@ sub feature_clash
8489
# parent domains
8590
sub feature_suitable
8691
{
87-
local ($parentdom, $aliasdom, $subdom) = @_;
92+
my ($parentdom, $aliasdom, $subdom) = @_;
8893
return $aliasdom ? 0 : 1; # not for alias domains
8994
}
9095

@@ -93,44 +98,44 @@ sub feature_suitable
9398
# or 0 if not
9499
sub feature_import
95100
{
96-
local ($dname, $user, $db) = @_;
97-
local $fakedom = { 'dom' => $dname };
101+
my ($dname, $user, $db) = @_;
102+
my $fakedom = { 'dom' => $dname };
98103
return &has_analytics_directives($fakedom);
99104
}
100105

101106
# feature_setup(&domain)
102107
# Called when this feature is added, with the domain object as a parameter
103108
sub feature_setup
104109
{
105-
local ($d) = @_;
110+
my ($d) = @_;
106111
&$virtual_server::first_print($text{'feat_setup'});
107112
&virtual_server::obtain_lock_web($_[0])
108113
if (defined(&virtual_server::obtain_lock_web));
109114

110115
&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'} );
113118
push(@ports, $d->{'web_sslport'}) if ($d->{'ssl'});
114-
local $done = 0;
119+
my $done = 0;
115120
foreach my $p (@ports) {
116-
local ($virt, $vconf) =
121+
my ($virt, $vconf) =
117122
&virtual_server::get_apache_virtual($d->{'dom'}, $p);
118123
next if (!$virt);
119124

120125
# Add PerlRequire for apachemod.pl, which sets lib path
121126
&lock_file($virt->{'file'});
122-
local @prq = &apache::find_directive("PerlRequire", $vconf);
127+
my @prq = &apache::find_directive("PerlRequire", $vconf);
123128
push(@prq, $apachemod_lib_cmd);
124129
&apache::save_directive("PerlRequire", \@prq, $vconf, $conf);
125130

126131
# Add filter directive
127-
local @pof = &apache::find_directive("PerlOutputFilterHandler", $vconf);
132+
my @pof = &apache::find_directive("PerlOutputFilterHandler", $vconf);
128133
push(@pof, "Virtualmin::GoogleAnalytics");
129134
&apache::save_directive("PerlOutputFilterHandler", \@pof, $vconf,$conf);
130135

131136
# Add PerlSetVar SSL
132137
if ($p == $d->{'web_sslport'}) {
133-
local @psv = &apache::find_directive("PerlSetVar", $vconf);
138+
my @psv = &apache::find_directive("PerlSetVar", $vconf);
134139
@psv = &unique(@psv, "SSL 1");
135140
&apache::save_directive("PerlSetVar", \@psv, $vconf, $conf);
136141
}
@@ -169,29 +174,29 @@ sub feature_modify
169174
# Called when this feature is disabled, or when the domain is being deleted
170175
sub feature_delete
171176
{
172-
local ($d) = @_;
177+
my ($d) = @_;
173178
&$virtual_server::first_print($text{'feat_delete'});
174179
&virtual_server::obtain_lock_web($_[0])
175180
if (defined(&virtual_server::obtain_lock_web));
176181

177182
&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'} );
180185
push(@ports, $d->{'web_sslport'}) if ($d->{'ssl'});
181-
local $done = 0;
186+
my $done = 0;
182187
foreach my $p (@ports) {
183-
local ($virt, $vconf) =
188+
my ($virt, $vconf) =
184189
&virtual_server::get_apache_virtual($d->{'dom'}, $p);
185190
next if (!$virt);
186191

187192
# Remove PerlRequire and PerlOutputFilterHandler
188193
&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;
191196
&apache::save_directive("PerlRequire", \@newprq,
192197
$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;
195200
&apache::save_directive("PerlOutputFilterHandler", \@newpof,
196201
$vconf, $conf);
197202

@@ -218,7 +223,7 @@ sub feature_delete
218223
# the Webmin user when this feature is enabled
219224
sub feature_webmin
220225
{
221-
local @doms = map { $_->{'dom'} } grep { $_->{$module_name} } @{$_[1]};
226+
my @doms = map { $_->{'dom'} } grep { $_->{$module_name} } @{$_[1]};
222227
if (@doms) {
223228
return ( [ $module_name,
224229
{ 'domains' => join(" ", @doms),
@@ -234,7 +239,7 @@ sub feature_webmin
234239
# Returns an array of link objects for webmin modules for this feature
235240
sub feature_links
236241
{
237-
local ($d) = @_;
242+
my ($d) = @_;
238243
return ( { 'mod' => $module_name,
239244
'desc' => $text{'links_link'},
240245
'page' => 'edit.cgi?dom='.&urlize($d->{'id'})."&virtualmin=1",
@@ -249,7 +254,7 @@ sub feature_modules
249254

250255
sub feature_validate
251256
{
252-
local ($d) = @_;
257+
my ($d) = @_;
253258
return &has_analytics_directives($d) ? undef : $text{'feat_notvalid'};
254259
}
255260

0 commit comments

Comments
 (0)