X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FCGI%2FLOGlist.pm;h=35fdda48e545f24f40dde1de6ac4e027e52512f6;hp=71b7d81248f15cf04ae3b7cfe735abaf5cd69355;hb=f9796d809e6a7d4ed2c356f0f32f1a3d628d3d1f;hpb=a7e968ce327855f2ba2624ca8517069a936c9b5b diff --git a/lib/BackupPC/CGI/LOGlist.pm b/lib/BackupPC/CGI/LOGlist.pm index 71b7d81..35fdda4 100644 --- a/lib/BackupPC/CGI/LOGlist.pm +++ b/lib/BackupPC/CGI/LOGlist.pm @@ -10,7 +10,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2003 Craig Barratt +# Copyright (C) 2003-2009 Craig Barratt # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 2.1.0_CVS, released 3 Jul 2003. +# Version 3.2.0, released 31 Jul 2010. # # 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 } my $content = eval("qq{$Lang->{Log_File_History__hdr}}"); - Header($Lang->{BackupPC__Log_File_History}, $content); + 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;