X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FCGI%2FArchive.pm;h=c6f2d40b62b224cd39b98dc9bc8b47288c12f3c0;hp=80416174f50c45ef59f1820ddd029db9015dd724;hb=169d1cb4e1293f707c33b6d386ae3e1f6592d66c;hpb=4cdaa6b8a9f5161ee2da4371d68cbbad41248ea0 diff --git a/lib/BackupPC/CGI/Archive.pm b/lib/BackupPC/CGI/Archive.pm index 8041617..c6f2d40 100644 --- a/lib/BackupPC/CGI/Archive.pm +++ b/lib/BackupPC/CGI/Archive.pm @@ -10,7 +10,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2003 Craig Barratt +# Copyright (C) 2003-2009 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 3.0.0beta0, released 11 Jul 2006. +# Version 3.2.0, released 31 Jul 2010. # # See http://backuppc.sourceforge.net. # @@ -39,6 +39,7 @@ package BackupPC::CGI::Archive; use strict; use BackupPC::CGI::Lib qw(:all); use Data::Dumper; +use DBI; sub action { @@ -60,6 +61,8 @@ sub action my($fullDur, $incrCnt, $fullSize, $fullRate); my @Backups = $bpc->BackupInfoRead($host); my $fullCnt = $incrCnt = 0; + my $all_backup_numbers; + for ( my $i = 0 ; $i < @Backups ; $i++ ) { if ( $Backups[$i]{type} eq "full" ) { $fullSize = $Backups[$i]{size} / (1024 * 1024); @@ -68,9 +71,55 @@ sub action $incrSizeTot = $Backups[$i]{size} / (1024 * 1024); } $backupnumber = $Backups[$i]{num}; + $all_backup_numbers->{$backupnumber}++; } $fullSizeTot += $fullSize + $incrSizeTot; $fullSize = sprintf("%.2f", ($fullSize + $incrSizeTot) / 1000); + + $bpc->ConfigRead($archHost); + %Conf = $bpc->Conf(); + +use Data::Dump qw(dump); + + my $dbh = DBI->connect($Conf{SearchDSN}, $Conf{SearchUser}, "", { RaiseError => 1, AutoCommit => 0 }); + my $sth = $dbh->prepare(qq{ + select + backups.num as num, + inc_size, + size, + inc_deleted + from backups + join hosts on hosts.id = hostid + where hosts.name = ? + }); + $sth->execute($host); + # and inc_size < 0 and size > 0 and not inc_deleted + while( my $row = $sth->fetchrow_hashref ) { +warn "# row ",dump $row; + $all_backup_numbers->{ $row->{num} } = + $row->{inc_deleted} ? 0 : + $row->{size} == 0 ? 0 : + $row->{inc_size} < 0 ? 1 : + $row->{size} > 0 ? 1 : + 0; + } + +warn dump($all_backup_numbers); + my @backup_nums = + sort + grep { $all_backup_numbers->{$_} } + keys %$all_backup_numbers; + + my $checkboxes; + foreach my $backupnumber ( @backup_nums ) { + $checkboxes .= qq| + +$backupnumber + |; + $checkBoxCnt++; + } + +=for ASA extension removed this $str = <  ${HostLink($host)} @@ -78,6 +127,20 @@ sub action $fullSize EOF $checkBoxCnt++; +=cut + + $str = < + +${HostLink($host)} +$checkboxes + + +${UserLink($Hosts->{$host}{user})} + + $fullSize +EOF + if ( @Backups == 0 ) { $hostCntNone++; $strNone .= $str; @@ -124,6 +187,7 @@ EOF next if ( !defined($In{"fcb$i"}) ); my $name = $In{"fcb$i"}; my $backupno = $In{"backup$i"}; + next unless defined $backupno; # ASA - skip hosts without backups checked push(@HostList, $name); push(@BackupList, $backupno); $hiddenStr .= < EOF $HostListStr .= < ${EscHTML($name)} +
  • ${EscHTML($name)} $i EOF } $hiddenStr .= <