X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FCGI%2FBrowse.pm;h=e0c33463c8b55b3618a97498778800c1cdc3c7ce;hp=3993b940985b9406f24e21d0ecd8aa3940304dd9;hb=e951f787a66c5bd9e9955c3f657a5b44289c0fe1;hpb=329e870f56fb6572fa697998d33676588034c149 diff --git a/lib/BackupPC/CGI/Browse.pm b/lib/BackupPC/CGI/Browse.pm index 3993b94..e0c3346 100644 --- a/lib/BackupPC/CGI/Browse.pm +++ b/lib/BackupPC/CGI/Browse.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 2.1.0_CVS, released 3 Jul 2003. +# Version 2.1.0, released 20 Jun 2004. # # See http://backuppc.sourceforge.net. # @@ -60,6 +60,15 @@ sub action # Find the requested backup and the previous filled backup # my @Backups = $bpc->BackupInfoRead($host); + + # + # default to the newest backup + # + if ( !defined($In{num}) && defined(@Backups) ) { + $i = @Backups - 1; + $num = $Backups[$i]{num}; + } + for ( $i = 0 ; $i < @Backups ; $i++ ) { last if ( $Backups[$i]{num} == $num ); } @@ -84,6 +93,9 @@ sub action $dir = "/$dir" if ( $dir !~ /^\// ); my $relDir = $dir; my $currDir = undef; + if ( $dir =~ m{(^|/)\.\.(/|$)} ) { + ErrorExit($Lang->{Nice_try__but_you_can_t_put}); + } # # Loop up the directory tree until we hit the top. @@ -126,28 +138,28 @@ sub action # Display directory if it exists in current backup. # First find out if there are subdirs # - my($bold, $unbold, $BGcolor); + my $tdStyle; + my $linkStyle = "fview"; $img |= 1 << 6; $img |= 1 << 5 if ( $attr->{$f}{nlink} > 2 ); if ( $dirOpen ) { - $bold = ""; - $unbold = ""; + $linkStyle = "fviewbold"; $img |= 1 << 2; $img |= 1 << 3 if ( $attr->{$f}{nlink} > 2 ); } my $imgFileName = sprintf("%07b.gif", $img); $imgStr = ""; if ( "$relDir/$f" eq $dir ) { - $BGcolor = " bgcolor=\"$Conf{CgiHeaderBgColor}\""; + $tdStyle = "fviewon"; } else { - $BGcolor = ""; + $tdStyle = "fviewoff"; } my $dirName = $f; $dirName =~ s/ / /g; push(@DirStr, {needTick => 1, - tdArgs => $BGcolor, + tdArgs => " class=\"$tdStyle\"", link => <$imgStr $bold$dirName$unbold +$imgStr $dirName EOF $fileCnt++; $gotDir = 1; @@ -181,34 +193,41 @@ EOF # # This is the selected directory, so display all the files # - my $attrStr; + my ($attrStr, $iconStr); if ( defined($a = $attr->{$f}) ) { my $mtimeStr = $bpc->timeStamp($a->{mtime}); # UGH -> fix this my $typeStr = BackupPC::Attrib::fileType2Text(undef, $a->{type}); my $modeStr = sprintf("0%o", $a->{mode} & 07777); + $iconStr = < +EOF $attrStr .= <$typeStr - $modeStr - $a->{backupNum} - $a->{size} - $mtimeStr + $typeStr + $modeStr + $a->{backupNum} + $a->{size} + $mtimeStr EOF } else { - $attrStr .= " \n"; + $attrStr .= " \n"; } (my $fDisp = "${EscHTML($f)}") =~ s/ / /g; if ( $gotDir ) { $fileStr .= < $fDisp + +  $iconStr $fDisp + $attrStr EOF } else { $fileStr .= < $fDisp + +  $iconStr $fDisp + $attrStr EOF @@ -243,7 +262,6 @@ EOF my $numF = join(", #", @mergeNums); $filledBackup = eval("qq{$Lang->{This_display_is_merged_with_backup}}"); } - Header(eval("qq{$Lang->{Browse_backup__num_for__host}}")); foreach my $d ( @DirStrPrev ) { $dirStr .= "{tdArgs}>$d->{link}\n"; @@ -264,20 +282,23 @@ EOF } else { $fileStr = eval("qq{$Lang->{The_directory_is_empty}}"); } - my @otherDirs; my $pathURI = $dir; my $shareURI = $share; $pathURI =~ s/([^\w.\/-])/uc sprintf("%%%02x", ord($1))/eg; $shareURI =~ s/([^\w.\/-])/uc sprintf("%%%02x", ord($1))/eg; - foreach my $i ( $view->backupList($share, $dir) ) { - push(@otherDirs, "$i"); - } - if ( @otherDirs ) { - my $otherDirs = join(",\n", @otherDirs); + if ( my @otherDirs = $view->backupList($share, $dir) ) { + my $otherDirs; + foreach my $i ( @otherDirs ) { + my $selected; + my $showDate = timeStamp2($Backups[$i]{startTime}); + my $backupNum = $Backups[$i]{num}; + $selected = " selected" if ( $backupNum == $num ); + $otherDirs .= "\n"; + } $filledBackup .= eval("qq{$Lang->{Visit_this_directory_in_backup}}"); } - print (eval("qq{$Lang->{Backup_browse_for__host}}")); + my $content = eval("qq{$Lang->{Backup_browse_for__host}}"); + Header(eval("qq{$Lang->{Browse_backup__num_for__host}}"), $content); Trailer(); }