Replace local with my
authorJamie Cameron <jcameron@webmin.com>
Mon, 25 Apr 2011 06:58:05 +0000 (23:58 -0700)
committerJamie Cameron <jcameron@webmin.com>
Mon, 25 Apr 2011 06:58:05 +0000 (23:58 -0700)
webminlog/acl_security.pl
webminlog/log_parser.pl
webminlog/rollback.cgi
webminlog/search.cgi
webminlog/view.cgi
webminlog/webminlog-lib.pl

index a66a9cc..f0cf7d8 100755 (executable)
@@ -14,7 +14,7 @@ printf "<input type=radio name=mods_def value=0 %s> %s<br>\n",
        $_[0]->{'mods'} eq "*" ? "" : "checked", $text{'acl_sel'};
 local %gotmod = map { $_, 1 } split(/\s+/, $_[0]->{'mods'});
 print "<select name=mods multiple size=10 width=400>\n";
-local $m;
+my $m;
 foreach $m (sort { $a->{'desc'} cmp $b->{'desc'} } &get_all_module_infos()) {
        printf "<option value=%s %s>%s\n",
                $m->{'dir'}, $gotmod{$m->{'dir'}} ? "selected" : "",
@@ -30,7 +30,7 @@ printf "<input type=radio name=users_def value=0 %s> %s<br>\n",
        $_[0]->{'users'} eq "*" ? "" : "checked", $text{'acl_sel'};
 local %gotuser = map { $_, 1 } split(/\s+/, $_[0]->{'users'});
 print "<select name=users multiple size=10 width=400>\n";
-local $u;
+my $u;
 foreach $u (sort { $a->{'name'} cmp $b->{'name'} } &acl::list_users()) {
        printf "<option value=%s %s>%s\n",
                $u->{'name'}, $gotuser{$u->{'name'}} ? "selected" : "",
index eee1578..a903d2b 100755 (executable)
@@ -7,7 +7,7 @@ do 'webminlog-lib.pl';
 # Converts logged information from this module into human-readable form
 sub parse_webmin_log
 {
-local ($user, $script, $action, $type, $object, $p) = @_;
+my ($user, $script, $action, $type, $object, $p) = @_;
 if ($action eq 'rollback') {
        return &text('log_rollback', "<i>".$p->{'desc'}."</i>",
                                     "<i>".$p->{'mdesc'}."</i>");
index b8396ad..2c8f128 100755 (executable)
@@ -101,7 +101,7 @@ else {
                elsif (-l $f->{'file'} && $f->{'type'} == 2 ||
                       !-e $f->{'file'} && $f->{'type'} == 2) {
                        # Was a link, and is one now
-                       local $lnk = readlink($f->{'file'});
+                       my $lnk = readlink($f->{'file'});
                        if (!-e $f->{'file'}) {
                                print &text('rollback_clink', "<tt>$f->{'data'}</tt>");
                                $count++;
@@ -117,7 +117,7 @@ else {
                elsif (-e $f->{'file'} && -l $f->{'file'} &&
                       $f->{'type'} == 0) {
                        # Was a file, but is now a link
-                       local $lnk = readlink($f->{'file'});
+                       my $lnk = readlink($f->{'file'});
                        print &text('rollback_makefile', "<tt>$lnk</tt>");
                        print "<pre>$f->{'data'}</pre>";
                        $count++;
@@ -147,12 +147,12 @@ else {
                        }
                else {
                        # Was a file, and is one now
-                       local $qnew = quotemeta($f->{'file'});
-                       local $temp = &transname();
+                       my $qnew = quotemeta($f->{'file'});
+                       my $temp = &transname();
                        open(TEMP, ">$temp");
                        print TEMP $f->{'data'};
                        close(TEMP);
-                       local $out = `diff $qnew $temp`;
+                       my $out = &backquote_command("diff $qnew $temp");
                        if ($out) {
                                print $text{'rollback_changes'};
                                print "<pre>$out</pre>";
index cbbf6ad..080e81c 100755 (executable)
@@ -56,7 +56,7 @@ else {
 &build_log_index(\%index);
 open(LOG, $webmin_logfile);
 while(($id, $idx) = each %index) {
-       local ($pos, $time, $user, $module, $sid) = split(/\s+/, $idx);
+       my ($pos, $time, $user, $module, $sid) = split(/\s+/, $idx);
        if (($in{'uall'} == 1 ||
             $in{'uall'} == 0 && $in{'user'} eq $user ||
             $in{'uall'} == 3 && $in{'ouser'} eq $user ||
@@ -76,12 +76,12 @@ while(($id, $idx) = each %index) {
                # Check modified files
                if ($gconfig{'logfiles'} && (!$in{'fall'} || !$in{'dall'})) {
                        # Make sure the specified file was modified
-                       local $found = 0;
+                       my $found = 0;
                        foreach $d (&list_diffs($act)) {
-                               local $filematch = $in{'fall'} ||
+                               my $filematch = $in{'fall'} ||
                                        $d->{'object'} &&
                                        $d->{'object'} eq $in{'file'};
-                               local $diffmatch = $in{'dall'} ||
+                               my $diffmatch = $in{'dall'} ||
                                        $d->{'diff'} =~ /\Q$in{'diff'}\E/i;
                                if ($filematch && $diffmatch) {
                                        $found++;
@@ -127,10 +127,10 @@ if ($in{'csv'}) {
                                { 'desc' => $text{'search_global'} } :
                                $minfo_cache{$m};
                if (!$minfo) {
-                       local %minfo = &get_module_info($m);
+                       my %minfo = &get_module_info($m);
                        $minfo = $minfo_cache{$m} = \%minfo;
                        }
-               local $desc = &get_action_description($act, 0);
+               my $desc = &get_action_description($act, 0);
                $desc =~ s/<[^>]+>//g;
                @cols = ( $desc, 
                          $minfo->{'desc'},
@@ -170,21 +170,21 @@ elsif (@match) {
                  $text{'search_date'},
                  $text{'search_time'} ], "100");
        foreach $act (sort { $b->{'time'} <=> $a->{'time'} } @match) {
-               local @tm = localtime($act->{'time'});
-               local $m = $act->{'module'};
-               local $d;
+               my @tm = localtime($act->{'time'});
+               my $m = $act->{'module'};
+               my $d;
                $minfo = $m eq "global" ? 
                                { 'desc' => $text{'search_global'} } :
                                $minfo_cache{$m};
                if (!$minfo) {
                        # first time seeing module ..
-                       local %minfo = &get_module_info($m);
+                       my %minfo = &get_module_info($m);
                        $minfo = $minfo_cache{$m} = \%minfo;
                        }
 
-               local @cols;
-               local $desc = &get_action_description($act, 0);
-               local $anno = &get_annotation($act);
+               my @cols;
+               my $desc = &get_action_description($act, 0);
+               my $anno = &get_annotation($act);
                push(@cols, "<a href='view.cgi?id=$act->{'id'}".
                      "&return=".&urlize($in{'return'}).
                      "&returndesc=".&urlize($in{'returndesc'}).
@@ -224,7 +224,7 @@ local $d = $in{"$_[0]_d"};
 local $m = $in{"$_[0]_m"};
 local $y = $in{"$_[0]_y"};
 return 0 if (!$d && !$y);
-local $rv;
+my $rv;
 eval { $rv = timelocal(0, 0, 0, $d, $m, $y-1900) };
 &error($text{'search_etime'}) if ($@);
 return $rv;
index 392ba51..15449bb 100755 (executable)
@@ -111,13 +111,13 @@ $rbcount = 0;
 $i = 0;
 $fhtml = "";
 foreach $d (&list_diffs($act)) {
-       local $t = $text{"view_type_".$d->{'type'}};
-       local $rb;
+       my $t = $text{"view_type_".$d->{'type'}};
+       my $rb;
        if ($d->{'type'} eq 'create' || $d->{'type'} eq 'modify' ||
            $d->{'type'} eq 'delete') {
                ($rb) = grep { $_->{'file'} eq $d->{'object'} } @files;
                }
-       local $cbox = @files ?
+       my $cbox = @files ?
                &ui_checkbox("r", $d->{'object'}, "", $rb, undef, !$rb) : undef;
        $rbcount++ if ($rb);
        if ($t =~ /\$2/ || !$d->{'diff'}) {
index 55944eb..769064e 100755 (executable)
@@ -35,13 +35,13 @@ following parameters :
 =cut
 sub list_webmin_log
 {
-local ($onlyuser, $onlymodule, $start, $end) = @_;
-local %index;
+my ($onlyuser, $onlymodule, $start, $end) = @_;
+my %index;
 &build_log_index(\%index);
-local @rv;
+my @rv;
 open(LOG, $webmin_logfile);
 while(($id, $idx) = each %index) {
-       local ($pos, $time, $user, $module, $sid) = split(/\s+/, $idx);
+       my ($pos, $time, $user, $module, $sid) = split(/\s+/, $idx);
        next if (defined($onlyuser) && $user ne $onlyuser);
        next if (defined($onlymodule) && $module ne $onlymodule);
        next if (defined($start) && $time < $start);
@@ -89,13 +89,13 @@ sub parse_logline
 {
 if ($_[0] =~ /^(\d+)\.(\S+)\s+\[.*\]\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+"([^"]+)"\s+"([^"]+)"\s+"([^"]+)"(.*)/ ||
     $_[0] =~ /^(\d+)\.(\S+)\s+\[.*\]\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)(.*)/) {
-       local $rv = { 'time' => $1, 'id' => "$1.$2",
+       my $rv = { 'time' => $1, 'id' => "$1.$2",
                      'user' => $3, 'sid' => $4,
                      'ip' => $5, 'module' => $6,
                      'script' => $7, 'action' => $8,
                      'type' => $9, 'object' => $10 };
-       local %param;
-       local $p = $11;
+       my %param;
+       my $p = $11;
        while($p =~ /^\s*([^=\s]+)='([^']*)'(.*)$/) {
                if (defined($param{$1})) {
                        $param{$1} .= "\0".$2;
@@ -136,19 +136,19 @@ hash ref with the keys :
 =cut
 sub list_diffs
 {
-local $i = 0;
-local @rv;
-local $idprefix = substr($act->{'id'}, 0, 5);
-local $oldbase = "$ENV{'WEBMIN_VAR'}/diffs/$idprefix/$act->{'id'}";
-local $base = "$ENV{'WEBMIN_VAR'}/diffs/$act->{'id'}";
+my $i = 0;
+my @rv;
+my $idprefix = substr($act->{'id'}, 0, 5);
+my $oldbase = "$ENV{'WEBMIN_VAR'}/diffs/$idprefix/$act->{'id'}";
+my $base = "$ENV{'WEBMIN_VAR'}/diffs/$act->{'id'}";
 return ( ) if (!-d $base && !-d $oldbase);
-local @files = &expand_base_dir(-d $base ? $base : $oldbase);
+my @files = &expand_base_dir(-d $base ? $base : $oldbase);
 
 # Read the diff files
 foreach my $file (@files) {
-        local ($type, $object, $diff, $input);
+        my ($type, $object, $diff, $input);
        open(DIFF, $file);
-        local $line = <DIFF>;
+        my $line = <DIFF>;
         while(<DIFF>) { $diff .= $_; }
         close(DIFF);
        if ($line =~ /^(\/.*)/) {
@@ -187,18 +187,18 @@ ref containing keys :
 =cut
 sub list_files
 {
-local $i = 0;
-local @rv;
-local $idprefix = substr($act->{'id'}, 0, 5);
-local $oldbase = "$ENV{'WEBMIN_VAR'}/files/$idprefix/$act->{'id'}";
-local $base = "$ENV{'WEBMIN_VAR'}/files/$act->{'id'}";
+my $i = 0;
+my @rv;
+my $idprefix = substr($act->{'id'}, 0, 5);
+my $oldbase = "$ENV{'WEBMIN_VAR'}/files/$idprefix/$act->{'id'}";
+my $base = "$ENV{'WEBMIN_VAR'}/files/$act->{'id'}";
 return ( ) if (!-d $base && !-d $oldbase);
-local @files = &expand_base_dir(-d $base ? $base : $oldbase);
+my @files = &expand_base_dir(-d $base ? $base : $oldbase);
 
 foreach my $file (@files) {
-        local ($type, $object, $data);
+        my ($type, $object, $data);
        open(FILE, $file);
-        local $line = <FILE>;
+        my $line = <FILE>;
        $line =~ s/\r|\n//g;
         while(<FILE>) { $data .= $_; }
         close(FILE);
@@ -228,7 +228,7 @@ Returns the text of the log annotation for this action, or undef if none.
 =cut
 sub get_annotation
 {
-local ($act) = @_;
+my ($act) = @_;
 return &read_file_contents("$ENV{'WEBMIN_VAR'}/annotations/$act->{'id'}");
 }
 
@@ -239,9 +239,9 @@ Updates the annotation for some action.
 =cut
 sub save_annotation
 {
-local ($act, $text) = @_;
-local $dir = "$ENV{'WEBMIN_VAR'}/annotations";
-local $file = "$dir/$act->{'id'}";
+my ($act, $text) = @_;
+my $dir = "$ENV{'WEBMIN_VAR'}/annotations";
+my $file = "$dir/$act->{'id'}";
 if ($text eq '') {
        unlink($file);
        }
@@ -260,8 +260,8 @@ Returns the text of the page that generated this action, or undef if none.
 =cut
 sub get_action_output
 {
-local ($act) = @_;
-local $idprefix = substr($act->{'id'}, 0, 5);
+my ($act) = @_;
+my $idprefix = substr($act->{'id'}, 0, 5);
 return &read_file_contents("$ENV{'WEBMIN_VAR'}/output/$idprefix/$act->{'id'}")
        ||
        &read_file_contents("$ENV{'WEBMIN_VAR'}/output/$act->{'id'}");
@@ -275,8 +275,8 @@ directory.
 =cut
 sub expand_base_dir
 {
-local ($base) = @_;
-local @files;
+my ($base) = @_;
+my @files;
 if (-d $base) {
        # Find files in the dir
        opendir(DIR, $base);
@@ -323,14 +323,14 @@ as returned by parse_logline.
 =cut
 sub get_action
 {
-local %index;
+my %index;
 &build_log_index(\%index);
-local $act;
+my $act;
 open(LOG, $webmin_logfile);
 local @idx = split(/\s+/, $index{$_[0]});
 seek(LOG, $idx[0], 0);
-local $line = <LOG>;
-local $act = &parse_logline($line);
+my $line = <LOG>;
+my $act = &parse_logline($line);
 close(LOG);
 return $act->{'id'} eq $_[0] ? $act : undef;
 }
@@ -343,10 +343,10 @@ For internal use only really.
 =cut
 sub build_log_index
 {
-local ($index) = @_;
-local $ifile = "$module_config_directory/logindex";
+my ($index) = @_;
+my $ifile = "$module_config_directory/logindex";
 dbmopen(%$index, $ifile, 0600);
-local @st = stat($webmin_logfile);
+my @st = stat($webmin_logfile);
 if ($st[9] > $index->{'lastchange'}) {
        # Log has changed .. perhaps need to rebuild
        open(LOG, $webmin_logfile);
@@ -384,7 +384,7 @@ for the action, it will be returned.
 =cut
 sub get_action_description
 {
-local ($act, $long) = @_;
+my ($act, $long) = @_;
 if (!defined($parser_cache{$act->{'module'}})) {
        # Bring in module parser library for the first time
        if (-r "$root_directory/$act->{'module'}/log_parser.pl") {
@@ -395,7 +395,7 @@ if (!defined($parser_cache{$act->{'module'}})) {
                $parser_cache{$act->{'module'}} = 0;
                }
        }
-local $d;
+my $d;
 if ($parser_cache{$act->{'module'}}) {
        # Module can return string
        $d = &foreign_call($act->{'module'}, "parse_webmin_log",