X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FCGI%2FLOGlist.pm;h=e8fdbb370484aaf48d5a7e818b89be7715fb5d79;hp=25e4060d1349b137de857d92f92c66fcfd0968e9;hb=fda25dc88a63ccac1c80efa2e4994bf0725ca9b7;hpb=ce708288691ba7dd95a8dac7a468bc0e4c1d6588 diff --git a/lib/BackupPC/CGI/LOGlist.pm b/lib/BackupPC/CGI/LOGlist.pm index 25e4060..e8fdbb3 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-2007 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.0beta0, released 20 Mar 2004. +# Version 3.1.0, released 25 Nov 2007. # # See http://backuppc.sourceforge.net. # @@ -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 = "$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 @@ -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;