X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FCGI%2FLOGlist.pm;h=f717a84c539adb87cccdd8536b5d15f723c14f92;hp=18cbdcddb1b470bbd7001aabc7c9633fb8e26114;hb=617af75f7419e95a9c3ea05b05cf21957acc331c;hpb=cfeb65d0e5ef33ef54cf0e5aaa7b3790bf80bff3 diff --git a/lib/BackupPC/CGI/LOGlist.pm b/lib/BackupPC/CGI/LOGlist.pm index 18cbdcd..f717a84 100644 --- a/lib/BackupPC/CGI/LOGlist.pm +++ b/lib/BackupPC/CGI/LOGlist.pm @@ -47,29 +47,24 @@ sub action ErrorExit($Lang->{Only_privileged_users_can_view_log_files}); } my $host = $In{host}; - my($url0, $hdr, $root, $str); + my($url0, $hdr, @files, $str); if ( $host ne "" ) { - $root = "$TopDir/pc/$host/LOG"; $url0 = "&host=${EscURI($host)}"; $hdr = "for host $host"; } else { - $root = "$LogDir/LOG"; $url0 = ""; $hdr = ""; } - for ( my $i = -1 ; ; $i++ ) { - my $url1 = ""; - my $file = $root; - if ( $i >= 0 ) { - $file .= ".$i"; - $url1 = "&num=$i"; - } - $file .= ".z" if ( !-f $file && -f "$file.z" ); - last if ( !-f $file ); + + foreach my $file ( $bpc->sortedPCLogFiles($host) ) { + my $url1 = "&num=$1" if ( $file =~ /LOG\.(\d+)(\.z)?$/ ); + $url1 = "&num=" if ( $file =~ /LOG(\.z)?$/ ); + next if ( !-f $file ); my $mtimeStr = $bpc->timeStamp((stat($file))[9], 1); my $size = (stat($file))[7]; + (my $fStr = $file) =~ s{.*/}{}; $str .= < $file + $fStr $size $mtimeStr EOF @@ -80,4 +75,29 @@ EOF Trailer(); } +sub compareLOGName +{ + #my($a, $b) = @_; + + my $na = $1 if ( $a =~ /LOG\.(\d+)/ ); + my $nb = $1 if ( $b =~ /LOG\.(\d+)/ ); + + if ( length($na) >= 5 && length($nb) >= 5 ) { + # + # Both new style. Bigger numbers are more recent. + # + return $nb <=> $na; + } elsif ( length($na) >= 5 && length($nb) < 5 ) { + return -1; + } elsif ( length($na) < 5 && length($nb) >= 5 ) { + return 1; + } else { + # + # Both old style. Smaller numbers are more recent. + # + return $na - $nb; + } +} + + 1;