1 #============================================================= -*-perl-*-
3 # BackupPC::CGI::RestoreInfo package
7 # This module implements the RestoreInfo action for the CGI interface.
10 # Craig Barratt <cbarratt@users.sourceforge.net>
13 # Copyright (C) 2003 Craig Barratt
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 2 of the License, or
18 # (at your option) any later version.
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.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #========================================================================
31 # Version 2.1.2, released 5 Sep 2005.
33 # See http://backuppc.sourceforge.net.
35 #========================================================================
37 package BackupPC::CGI::RestoreInfo;
40 use BackupPC::CGI::Lib qw(:all);
44 my $Privileged = CheckPermission($In{host});
45 my $host = $1 if ( $In{host} =~ /(.*)/ );
50 ErrorExit($Lang->{Only_privileged_users_can_view_restore_information});
53 # Find the requested restore
55 my @Restores = $bpc->RestoreInfoRead($host);
56 for ( $i = 0 ; $i < @Restores ; $i++ ) {
57 last if ( $Restores[$i]{num} == $num );
59 if ( $i >= @Restores ) {
60 ErrorExit(eval("qq{$Lang->{Restore_number__num_for_host__does_not_exist}}"));
64 do "$TopDir/pc/$host/RestoreInfo.$Restores[$i]{num}"
65 if ( -f "$TopDir/pc/$host/RestoreInfo.$Restores[$i]{num}" );
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));
76 foreach my $f ( @{$RestoreReq{fileList}} ) {
78 (my $strippedShareSrc = $RestoreReq{shareSrc}) =~ s/^\///;
79 (my $strippedShareDest = $RestoreReq{shareDest}) =~ s/^\///;
80 substr($targetFile, 0, length($RestoreReq{pathHdrSrc}))
81 = $RestoreReq{pathHdrDest};
82 $targetFile =~ s{//+}{/}g;
83 $fileListStr .= <<EOF;
84 <tr><td>$RestoreReq{hostSrc}:/$strippedShareSrc$f</td><td>$RestoreReq{hostDest}:/$strippedShareDest$targetFile</td></tr>
87 my $content = eval("qq{$Lang->{Restore___num_details_for__host2}}");
88 Header(eval("qq{$Lang->{Restore___num_details_for__host}}"),$content);