"Fossies" - the Fresh Open Source Software Archive

Member "BackupPC-4.4.0/lib/BackupPC/CGI/RestoreInfo.pm" (20 Jun 2020, 3528 Bytes) of package /linux/privat/BackupPC-4.4.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "RestoreInfo.pm" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 4.3.2_vs_4.4.0.

    1 #============================================================= -*-perl-*-
    2 #
    3 # BackupPC::CGI::RestoreInfo package
    4 #
    5 # DESCRIPTION
    6 #
    7 #   This module implements the RestoreInfo action for the CGI interface.
    8 #
    9 # AUTHOR
   10 #   Craig Barratt  <cbarratt@users.sourceforge.net>
   11 #
   12 # COPYRIGHT
   13 #   Copyright (C) 2003-2020  Craig Barratt
   14 #
   15 #   This program is free software: you can redistribute it and/or modify
   16 #   it under the terms of the GNU General Public License as published by
   17 #   the Free Software Foundation, either version 3 of the License, or
   18 #   (at your option) any later version.
   19 #
   20 #   This program is distributed in the hope that it will be useful,
   21 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
   22 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   23 #   GNU General Public License for more details.
   24 #
   25 #   You should have received a copy of the GNU General Public License
   26 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
   27 #
   28 #========================================================================
   29 #
   30 # Version 4.4.0, released 20 Jun 2020.
   31 #
   32 # See http://backuppc.sourceforge.net.
   33 #
   34 #========================================================================
   35 
   36 package BackupPC::CGI::RestoreInfo;
   37 
   38 use strict;
   39 use BackupPC::CGI::Lib qw(:all);
   40 use Encode qw/decode_utf8/;
   41 
   42 sub action
   43 {
   44     my $Privileged = CheckPermission($In{host});
   45     my $host       = $1 if ( $In{host} =~ /(.*)/ );
   46     my $num        = $In{num};
   47     my $i;
   48 
   49     if ( !$Privileged ) {
   50         ErrorExit($Lang->{Only_privileged_users_can_view_restore_information});
   51     }
   52     #
   53     # Find the requested restore
   54     #
   55     my @Restores = $bpc->RestoreInfoRead($host);
   56     for ( $i = 0 ; $i < @Restores ; $i++ ) {
   57         last if ( $Restores[$i]{num} == $num );
   58     }
   59     if ( $i >= @Restores ) {
   60         ErrorExit(eval("qq{$Lang->{Restore_number__num_for_host__does_not_exist}}"));
   61     }
   62 
   63     %RestoreReq = ();
   64     do "$TopDir/pc/$host/RestoreInfo.$Restores[$i]{num}"
   65       if ( -f "$TopDir/pc/$host/RestoreInfo.$Restores[$i]{num}" );
   66 
   67     my $startTime = timeStamp2($Restores[$i]{startTime});
   68     my $reqTime   = timeStamp2($RestoreReq{reqTime});
   69     my $dur       = $Restores[$i]{endTime} - $Restores[$i]{startTime};
   70     $dur = 1 if ( $dur <= 0 );
   71     my $duration = sprintf("%.1f", $dur / 60);
   72     my $MB       = sprintf("%.1f", $Restores[$i]{size} / (1024 * 1024));
   73     my $MBperSec = sprintf("%.2f", $Restores[$i]{size} / (1024 * 1024 * $dur));
   74 
   75     my $fileListStr = "";
   76     foreach my $f ( @{$RestoreReq{fileList}} ) {
   77         my $targetFile = $f;
   78         (my $strippedShareSrc  = $RestoreReq{shareSrc})  =~ s/^\///;
   79         (my $strippedShareDest = $RestoreReq{shareDest}) =~ s/^\///;
   80         substr($targetFile, 0, length($RestoreReq{pathHdrSrc})) = $RestoreReq{pathHdrDest};
   81         $targetFile =~ s{//+}{/}g;
   82         $strippedShareDest = decode_utf8($strippedShareDest);
   83         $targetFile        = decode_utf8($targetFile);
   84         $strippedShareSrc  = decode_utf8($strippedShareSrc);
   85         $f                 = decode_utf8($f);
   86         $fileListStr .= <<EOF;
   87 <tr><td>$RestoreReq{hostSrc}:/$strippedShareSrc$f</td><td>$RestoreReq{hostDest}:/$strippedShareDest$targetFile</td></tr>
   88 EOF
   89     }
   90     $RestoreReq{shareSrc}  = decode_utf8($RestoreReq{shareSrc});
   91     $RestoreReq{shareDest} = decode_utf8($RestoreReq{shareDest});
   92     my $content = eval("qq{$Lang->{Restore___num_details_for__host2}}");
   93     Header(eval("qq{$Lang->{Restore___num_details_for__host}}"), $content);
   94     Trailer();
   95 }
   96 
   97 1;