Ci-dessous, les différences entre deux révisions de la page.
— |
welcome:fedora:f23_bug_into_backuppc [2016/02/09 21:35] (Version actuelle) |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | {{howhard> | ||
+ | By Fedora 23, an error occurs by browsing the archives: [[https:// | ||
+ | |||
+ | The solution is given [[https:// | ||
+ | # | ||
+ | # | ||
+ | # BackupPC:: | ||
+ | # | ||
+ | # DESCRIPTION | ||
+ | # | ||
+ | # This module implements the Browse action for the CGI interface. | ||
+ | # | ||
+ | # AUTHOR | ||
+ | # Craig Barratt | ||
+ | # | ||
+ | # COPYRIGHT | ||
+ | # | ||
+ | # | ||
+ | # 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 | ||
+ | # the Free Software Foundation; either version 2 of the License, or | ||
+ | # (at your option) any later version. | ||
+ | # | ||
+ | # This program is distributed in the hope that it will be useful, | ||
+ | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
+ | # | ||
+ | # GNU General Public License for more details. | ||
+ | # | ||
+ | # You should have received a copy of the GNU General Public License | ||
+ | # along with this program; if not, write to the Free Software | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # Version 3.3.1, released 11 Jan 2015. | ||
+ | # | ||
+ | # See http:// | ||
+ | # | ||
+ | # | ||
+ | |||
+ | package BackupPC:: | ||
+ | |||
+ | use strict; | ||
+ | use Encode qw/ | ||
+ | use BackupPC:: | ||
+ | use BackupPC:: | ||
+ | use BackupPC:: | ||
+ | |||
+ | sub action | ||
+ | { | ||
+ | my $Privileged = CheckPermission($In{host}); | ||
+ | my($i, $dirStr, $fileStr, $attr); | ||
+ | my $checkBoxCnt = 0; | ||
+ | |||
+ | if ( !$Privileged ) { | ||
+ | ErrorExit(eval(" | ||
+ | } | ||
+ | my $host = $In{host}; | ||
+ | my $num = $In{num}; | ||
+ | my $share = $In{share}; | ||
+ | my $dir = $In{dir}; | ||
+ | |||
+ | ErrorExit($Lang-> | ||
+ | # | ||
+ | # Find the requested backup and the previous filled backup | ||
+ | # | ||
+ | my @Backups = $bpc-> | ||
+ | |||
+ | # | ||
+ | # default to the newest backup | ||
+ | # | ||
+ | #if ( !defined($In{num}) && defined(@Backups) && @Backups > 0 ) { | ||
+ | if ( !$In{num} && @Backups > 0 ) { | ||
+ | $i = @Backups - 1; | ||
+ | $num = $Backups[$i]{num}; | ||
+ | } | ||
+ | |||
+ | for ( $i = 0 ; $i < @Backups ; $i++ ) { | ||
+ | last if ( $Backups[$i]{num} == $num ); | ||
+ | } | ||
+ | if ( $i >= @Backups || $num !~ /^\d+$/ ) { | ||
+ | ErrorExit(" | ||
+ | . " not exist." | ||
+ | } | ||
+ | my $backupTime = timeStamp2($Backups[$i]{startTime}); | ||
+ | my $backupAge = sprintf(" | ||
+ | / (24 * 3600)); | ||
+ | my $view = BackupPC:: | ||
+ | |||
+ | if ( $dir eq "" | ||
+ | $attr = $view-> | ||
+ | if ( keys(%$attr) > 0 ) { | ||
+ | $share = (sort(keys(%$attr)))[0]; | ||
+ | $dir = '/'; | ||
+ | } else { | ||
+ | ErrorExit(eval(" | ||
+ | } | ||
+ | } | ||
+ | $dir = "/ | ||
+ | my $relDir | ||
+ | my $currDir = undef; | ||
+ | if ( $dir =~ m{(^|/ | ||
+ | ErrorExit($Lang-> | ||
+ | } | ||
+ | |||
+ | # | ||
+ | # Loop up the directory tree until we hit the top. | ||
+ | # | ||
+ | my(@DirStrPrev); | ||
+ | while ( 1 ) { | ||
+ | my($fLast, $fLastum, @DirStr); | ||
+ | |||
+ | $attr = $view-> | ||
+ | # | ||
+ | if ( !$attr ) { | ||
+ | | ||
+ | ErrorExit(eval(" | ||
+ | } | ||
+ | |||
+ | my $fileCnt = 0; # file counter | ||
+ | $fLast = $dirStr = ""; | ||
+ | |||
+ | # | ||
+ | # Loop over each of the files in this directory | ||
+ | # | ||
+ | foreach my $f ( sort {uc($a) cmp uc($b)} keys(%$attr) ) { | ||
+ | my($dirOpen, | ||
+ | my $fURI = $f; # URI escaped $f | ||
+ | my $shareURI = $share; | ||
+ | if ( $relDir eq "" | ||
+ | $path = "/ | ||
+ | } else { | ||
+ | ($path = " | ||
+ | } | ||
+ | if ( $shareURI eq "" | ||
+ | $shareURI = $f; | ||
+ | $path | ||
+ | } | ||
+ | $path =~ s{^/+}{/}; | ||
+ | $path =~ s/ | ||
+ | $fURI =~ s/ | ||
+ | $shareURI =~ s/ | ||
+ | # $dirOpen | ||
+ | $dirOpen | ||
+ | if ( $attr-> | ||
+ | # | ||
+ | # Display directory if it exists in current backup. | ||
+ | # First find out if there are subdirs | ||
+ | # | ||
+ | my $tdStyle; | ||
+ | my $linkStyle = " | ||
+ | $img |= 1 << 6; | ||
+ | $img |= 1 << 5 if ( $attr-> | ||
+ | if ( $dirOpen ) { | ||
+ | $linkStyle = " | ||
+ | $img |= 1 << 2; | ||
+ | $img |= 1 << 3 if ( $attr-> | ||
+ | } | ||
+ | my $imgFileName = sprintf(" | ||
+ | $imgStr = "< | ||
+ | if ( " | ||
+ | $tdStyle = " | ||
+ | } else { | ||
+ | $tdStyle = " | ||
+ | } | ||
+ | my $dirName = $f; | ||
+ | $dirName =~ s/ /& | ||
+ | $dirName = decode_utf8($dirName); | ||
+ | push(@DirStr, | ||
+ | | ||
+ | | ||
+ | <a href=" | ||
+ | EOF | ||
+ | $fileCnt++; | ||
+ | $gotDir = 1; | ||
+ | if ( $dirOpen ) { | ||
+ | my($lastTick, | ||
+ | foreach my $d ( @DirStrPrev ) { | ||
+ | $lastTick = $d if ( $d-> | ||
+ | } | ||
+ | # $doneLastTick = 1 if ( !defined($lastTick) ); | ||
+ | $doneLastTick = 1 if ( !$lastTick ); | ||
+ | foreach my $d ( @DirStrPrev ) { | ||
+ | $img = 0; | ||
+ | if ( $d-> | ||
+ | $img |= 1 << 0; | ||
+ | } | ||
+ | if ( $d == $lastTick ) { | ||
+ | $img |= 1 << 4; | ||
+ | $doneLastTick = 1; | ||
+ | } elsif ( !$doneLastTick ) { | ||
+ | $img |= 1 << 3 | 1 << 4; | ||
+ | } | ||
+ | my $imgFileName = sprintf(" | ||
+ | $imgStr = "< | ||
+ | push(@DirStr, | ||
+ | | ||
+ | | ||
+ | }); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | if ( $relDir eq $dir ) { | ||
+ | # | ||
+ | # This is the selected directory, so display all the files | ||
+ | # | ||
+ | my ($attrStr, $iconStr); | ||
+ | # if ( defined($a = $attr-> | ||
+ | if ( $a = $attr-> | ||
+ | my $mtimeStr = $bpc-> | ||
+ | # UGH -> fix this | ||
+ | my $typeStr | ||
+ | | ||
+ | my $modeStr | ||
+ | $iconStr = << | ||
+ | <img src=" | ||
+ | EOF | ||
+ | $attrStr .= << | ||
+ | <td align=" | ||
+ | <td align=" | ||
+ | <td align=" | ||
+ | <td align=" | ||
+ | <td align=" | ||
+ | </tr> | ||
+ | EOF | ||
+ | } else { | ||
+ | $attrStr .= "< | ||
+ | } | ||
+ | (my $fDisp = " | ||
+ | $fDisp = decode_utf8($fDisp); | ||
+ | if ( $gotDir ) { | ||
+ | $fileStr .= << | ||
+ | < | ||
+ | <input type=" | ||
+ | </td> | ||
+ | $attrStr | ||
+ | </tr> | ||
+ | EOF | ||
+ | } else { | ||
+ | $fileStr .= << | ||
+ | < | ||
+ | <input type=" | ||
+ | </td> | ||
+ | $attrStr | ||
+ | </tr> | ||
+ | EOF | ||
+ | } | ||
+ | $checkBoxCnt++; | ||
+ | } | ||
+ | } | ||
+ | @DirStrPrev = @DirStr; | ||
+ | last if ( $relDir eq "" | ||
+ | # | ||
+ | # Prune the last directory off $relDir, or at the very end | ||
+ | # do the top-level directory. | ||
+ | # | ||
+ | if ( $relDir eq "" | ||
+ | $currDir = $share; | ||
+ | $share = ""; | ||
+ | $relDir = ""; | ||
+ | } else { | ||
+ | $relDir | ||
+ | $currDir = $2; | ||
+ | } | ||
+ | } | ||
+ | $share = $currDir; | ||
+ | my $shareURI = $share; | ||
+ | $shareURI =~ s/ | ||
+ | |||
+ | # | ||
+ | # allow each level of the directory path to be navigated to | ||
+ | # | ||
+ | my($thisPath, | ||
+ | my $dirClean = $dir; | ||
+ | $dirClean =~ s{//+}{/}g; | ||
+ | $dirClean =~ s{/+$}{}; | ||
+ | my @dirElts = split(/\//, $dirClean); | ||
+ | @dirElts = ("/" | ||
+ | foreach my $d ( @dirElts ) { | ||
+ | my($thisDir); | ||
+ | |||
+ | if ( $thisPath eq "" | ||
+ | $thisDir | ||
+ | $thisPath = "/"; | ||
+ | } else { | ||
+ | $thisPath .= "/" | ||
+ | $thisPath .= " | ||
+ | $thisDir = decode_utf8($d); | ||
+ | } | ||
+ | my $thisPathURI = $thisPath; | ||
+ | $thisPathURI =~ s/ | ||
+ | $dirDisplay .= "/" | ||
+ | $dirDisplay .= "<a href=\" | ||
+ | } | ||
+ | |||
+ | my $filledBackup; | ||
+ | |||
+ | if ( (my @mergeNums = @{$view-> | ||
+ | shift(@mergeNums); | ||
+ | my $numF = join(", | ||
+ | $filledBackup = eval(" | ||
+ | } | ||
+ | |||
+ | foreach my $d ( @DirStrPrev ) { | ||
+ | $dirStr .= "< | ||
+ | } | ||
+ | |||
+ | ### hide checkall button if there are no files | ||
+ | my ($topCheckAll, | ||
+ | if ( $fileStr ) { | ||
+ | $fileHeader = eval(" | ||
+ | |||
+ | $checkAll = $Lang-> | ||
+ | |||
+ | # and put a checkall box on top if there are at least 20 files | ||
+ | if ( $checkBoxCnt >= 20 ) { | ||
+ | $topCheckAll = $checkAll; | ||
+ | $topCheckAll =~ s{allFiles}{allFilestop}g; | ||
+ | } | ||
+ | } else { | ||
+ | $fileStr = eval(" | ||
+ | } | ||
+ | my $pathURI | ||
+ | $pathURI | ||
+ | if ( my @otherDirs = $view-> | ||
+ | my $otherDirs; | ||
+ | foreach my $i ( @otherDirs ) { | ||
+ | my $selected; | ||
+ | my $showDate | ||
+ | my $backupNum = $Backups[$i]{num}; | ||
+ | $selected | ||
+ | $otherDirs .= "< | ||
+ | } | ||
+ | $filledBackup .= eval(" | ||
+ | } | ||
+ | $dir = decode_utf8($dir); | ||
+ | $share = decode_utf8($share); | ||
+ | |||
+ | my $content = eval(" | ||
+ | Header(eval(" | ||
+ | Trailer(); | ||
+ | } | ||
+ | |||
+ | 1; </ |