X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FCGI%2FLOGlist.pm;h=f148ff2ce00b23f9f8e86b55bf20109005f8949f;hp=8e55b468016c4c11d472646f8d760cfa46b22993;hb=c2b072c9ad558447fb73fedf0cad170214b7d80e;hpb=329e870f56fb6572fa697998d33676588034c149 diff --git a/lib/BackupPC/CGI/LOGlist.pm b/lib/BackupPC/CGI/LOGlist.pm index 8e55b46..f148ff2 100644 --- a/lib/BackupPC/CGI/LOGlist.pm +++ b/lib/BackupPC/CGI/LOGlist.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 2.1.0_CVS, released 3 Jul 2003. +# Version 3.0.0, released 28 Jan 2007. # # See http://backuppc.sourceforge.net. # @@ -47,36 +47,57 @@ 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 = "$TopDir/log/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 } - Header($Lang->{BackupPC__Log_File_History}); - print (eval("qq{$Lang->{Log_File_History__hdr}}")); + my $content = eval("qq{$Lang->{Log_File_History__hdr}}"); + Header($Lang->{BackupPC__Log_File_History}, + $content, !-f "$TopDir/pc/$host/backups"); 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;