From e379cedff7e48b88b07204bd4dd11272c8458b36 Mon Sep 17 00:00:00 2001 From: Joe Cooper Date: Tue, 5 Jul 2016 21:57:44 -0700 Subject: [PATCH] strict/warn --- virtual_feature.pl | 40 +++++++++++++++++++++++----------------- virtualmin-sqlite-lib.pl | 9 ++++++--- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/virtual_feature.pl b/virtual_feature.pl index 00c77ac..015351c 100755 --- a/virtual_feature.pl +++ b/virtual_feature.pl @@ -1,4 +1,8 @@ # Defines functions for this feature +use strict; +use warnings; +our (%text); +our $module_name; do 'virtualmin-sqlite-lib.pl'; @@ -21,7 +25,7 @@ sub feature_losing # editing form sub feature_label { -local ($edit) = @_; +my ($edit) = @_; return $edit ? $text{'feat_label2'} : $text{'feat_label'}; } @@ -84,7 +88,7 @@ sub feature_delete # the Webmin user when this feature is enabled sub feature_webmin { -local @doms = grep { $_->{$module_name} } @{$_[1]}; +my @doms = grep { $_->{$module_name} } @{$_[1]}; if (@doms) { return ( [ $module_name, { 'dir' => join("\t", map { $_->{'home'} } @doms), @@ -106,7 +110,7 @@ sub database_name # Returns a list of databases owned by a domain, according to this plugin sub database_list { -local @rv; +my @rv; foreach my $db (split(/\s+/, $_[0]->{'db_'.$module_name})) { push(@rv, { 'name' => $db, 'type' => $module_name, @@ -125,7 +129,7 @@ sub databases_all if ($_[0]) { return &databases_in_dir($_[0]->{'home'}); } -else { +else { return ( ); } } @@ -142,17 +146,17 @@ sub database_clash # report progress sub database_create { -local $file = "$_[0]->{'home'}/$_[1].sqlite"; +my $file = "$_[0]->{'home'}/$_[1].sqlite"; &$virtual_server::first_print(&text('db_creating', "$file")); -local $sqlite = &get_sqlite_command(); -local $cmd = &command_as_user($_[0]->{'user'}, 0, +my $sqlite = &get_sqlite_command(); +my $cmd = &command_as_user($_[0]->{'user'}, 0, "echo .tables | $sqlite ".quotemeta($file)); -local $out = &backquote_logged("$cmd 2>&1 &1 $out")); } else { - local @dbs = split(/\s+/, $_[0]->{'db_'.$module_name}); + my @dbs = split(/\s+/, $_[0]->{'db_'.$module_name}); push(@dbs, $_[1]); $_[0]->{'db_'.$module_name} = join(" ", @dbs); &$virtual_server::second_print($virtual_server::text{'setup_done'}); @@ -164,25 +168,28 @@ sub database_create # report progress sub database_delete { -local $file = "$_[0]->{'home'}/$_[1].sqlite"; +my $file = "$_[0]->{'home'}/$_[1].sqlite"; &$virtual_server::first_print(&text('db_deleting', "$file")); unlink($file); -local @dbs = split(/\s+/, $_[0]->{'db_'.$module_name}); +my @dbs = split(/\s+/, $_[0]->{'db_'.$module_name}); @dbs = grep { $_ ne $_[1] } @dbs; $_[0]->{'db_'.$module_name} = join(" ", @dbs); &$virtual_server::second_print($virtual_server::text{'setup_done'}); } -# database_size(&domain, dbname) +# database_size(&domain, dbname) # Returns the on-disk size and number of tables in a database sub database_size { -local $file = "$_[0]->{'home'}/$_[1].sqlite"; -local @st = stat($file); -local $sqlite = &get_sqlite_command(); -local $cmd = &command_as_user($_[0]->{'user'}, 0, +my $file = "$_[0]->{'home'}/$_[1].sqlite"; +my @st = stat($file); +my $sqlite = &get_sqlite_command(); +my $cmd = &command_as_user($_[0]->{'user'}, 0, "echo .tables | $sqlite ".quotemeta($file)); +no strict "subs"; &open_execute_command(OUT, $cmd, 1); +use strict "subs"; +my $tables; while() { s/\r|\n//g; $tables++ if (/^\S+$/); @@ -192,4 +199,3 @@ sub database_size } 1; - diff --git a/virtualmin-sqlite-lib.pl b/virtualmin-sqlite-lib.pl index bc99cb0..e103714 100755 --- a/virtualmin-sqlite-lib.pl +++ b/virtualmin-sqlite-lib.pl @@ -1,4 +1,8 @@ # Functions for the SQLite database +use strict; +use warnings; +our %text; +our $module_name; BEGIN { push(@INC, ".."); }; eval "use WebminCore;"; @@ -6,7 +10,7 @@ sub databases_in_dir { -local @rv; +my @rv; opendir(DIR, $_[0]); while(my $f = readdir(DIR)) { if ($f =~ /^(\S+)\.sqlite$/) { @@ -26,11 +30,10 @@ sub databases_in_dir sub get_sqlite_command { foreach my $c ("sqlite", "sqlite4", "sqlite3", "sqlite2", "sqlite1") { - local $p = &has_command($c); + my $p = &has_command($c); return $p if ($p); } return undef; } 1; -