Ignore:
Timestamp:
11/10/08 09:01:22 (4 years ago)
Author:
OlivierRaginel
Message:

Item38: Changed r497 not to use any external commands at all

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/PageStatsPlugin/lib/TWiki/Plugins/PageStatsPlugin.pm

    r497 r517  
    7676    my $dd = TWiki::Func::getDataDir(); 
    7777    #my @pagestats = `grep $web\\.$topic $dd/log*.txt | grep -E \\(view\\|save\\)`; 
    78     use TWiki::Sandbox; 
    79     my $sandbox = TWiki::Sandbox->new(); 
    80     my ($lsresp, $lsexit) = $sandbox->sysCommand("ls -1 $dd"); 
    81     my @resp = split(/\n/, $lsresp); 
    82     my @logs = grep(/log2.*.txt/, @resp); 
    83     my $logs = ""; 
    84     foreach my $l (@logs) { 
    85         $logs .= "$dd/$l "; 
     78    opendir DATADIR, $dd or die "Can't open DataDir: $!"; 
     79    my @pagestats = (); 
     80    foreach my $l ( grep /log.*.txt/, readdir DATADIR ) { 
     81        open( my $logfile, "< $dd/$l" ) or next; 
     82        while( <$logfile> ) { 
     83            push @pagestats, $_ if /$web\.$topic/ && /view|save/; 
     84        } 
    8685    } 
    87     my $pat = "$web.$topic"; 
    88     my $x = 'grep -e '.$pat.' -e view -e save '.$logs; 
    89     my ($grepresp, $grepexit) = $sandbox->sysCommand('grep -e '.$pat.' -e view -e save '.$logs); 
    90     my @pagestats = split(/$/, $grepresp); 
     86    closedir DATADIR; 
    9187 
    9288    my $maxEntries = scalar &TWiki::Func::extractNameValuePair( $attributes, "max" ) || scalar @pagestats; 
Note: See TracChangeset for help on using the changeset viewer.