8 |
use DateTime; |
use DateTime; |
9 |
use vars qw(%In $MyURL); |
use vars qw(%In $MyURL); |
10 |
use Time::HiRes qw/time/; |
use Time::HiRes qw/time/; |
11 |
|
use XML::Writer; |
12 |
|
use IO::File; |
13 |
|
|
14 |
my $on_page = 100; |
my $on_page = 100; |
15 |
my $pager_pages = 10; |
my $pager_pages = 10; |
307 |
|
|
308 |
} |
} |
309 |
|
|
310 |
|
sub get_tgz_size_by_name($) { |
311 |
|
my $name = shift; |
312 |
|
|
313 |
|
my $tgz = $Conf{InstallDir}.'/'.$Conf{GzipTempDir}.'/'.$name; |
314 |
|
|
315 |
|
my $size = -1; |
316 |
|
|
317 |
|
if (-f $tgz) { |
318 |
|
$size = (stat($tgz))[7]; |
319 |
|
} elsif (-d $tgz) { |
320 |
|
opendir(my $dir, $tgz) || die "can't opendir $tgz: $!"; |
321 |
|
my @parts = grep { !/^\./ && -f "$tgz/$_" } readdir($dir); |
322 |
|
$size = 0; |
323 |
|
foreach my $part (@parts) { |
324 |
|
$size += (stat("$tgz/$part"))[7] || die "can't stat $tgz/$part: $!"; |
325 |
|
} |
326 |
|
closedir $dir; |
327 |
|
} |
328 |
|
|
329 |
|
return $size; |
330 |
|
} |
331 |
|
|
332 |
sub getGzipSize($$) |
sub getGzipSize($$) |
333 |
{ |
{ |
334 |
my ($hostID, $backupNum) = @_; |
my ($hostID, $backupNum) = @_; |
|
my $ret; |
|
335 |
my $sql; |
my $sql; |
336 |
my $dbh = get_dbh(); |
my $dbh = get_dbh(); |
337 |
|
|
349 |
$sth->execute($hostID, $backupNum); |
$sth->execute($hostID, $backupNum); |
350 |
|
|
351 |
my $row = $sth->fetchrow_hashref(); |
my $row = $sth->fetchrow_hashref(); |
352 |
|
|
353 |
my (undef,undef,undef,undef,undef,undef,undef,$ret,undef,undef,undef,undef,undef) = |
return get_tgz_size_by_name( |
354 |
stat( $Conf{InstallDir}.'/'.$Conf{GzipTempDir}.'/'. |
getGzipName($row->{'host'}, $row->{share}, $row->{'backupnum'}) |
355 |
getGzipName($row->{'host'}, $row->{share}, $row->{'backupnum'})); |
); |
|
|
|
|
return $ret; |
|
356 |
} |
} |
357 |
|
|
358 |
sub getBackupsNotBurned() { |
sub getBackupsNotBurned() { |
369 |
backups.date AS date, |
backups.date AS date, |
370 |
backups.size AS size, |
backups.size AS size, |
371 |
backups.id AS id, |
backups.id AS id, |
372 |
backups.inc_size AS inc_size |
backups.inc_size AS inc_size, |
373 |
|
backups.parts AS parts |
374 |
FROM backups |
FROM backups |
375 |
INNER JOIN shares ON backups.shareID=shares.ID |
INNER JOIN shares ON backups.shareID=shares.ID |
376 |
INNER JOIN hosts ON backups.hostID = hosts.ID |
INNER JOIN hosts ON backups.hostID = hosts.ID |
386 |
backups.type, |
backups.type, |
387 |
backups.date, |
backups.date, |
388 |
backups.size, |
backups.size, |
389 |
backups.inc_size |
backups.inc_size, |
390 |
|
backups.parts |
391 |
ORDER BY backups.date |
ORDER BY backups.date |
392 |
}; |
}; |
393 |
my $sth = $dbh->prepare( $sql ); |
my $sth = $dbh->prepare( $sql ); |
513 |
z-index: 3; |
z-index: 3; |
514 |
background-color: transparent; |
background-color: transparent; |
515 |
} |
} |
516 |
|
|
517 |
|
#parts { |
518 |
|
padding: 0.4em; |
519 |
|
display: none; |
520 |
|
width: 100%; |
521 |
|
font-size: 80%; |
522 |
|
color: #ff0000; |
523 |
|
text-align: center; |
524 |
|
} |
525 |
--> |
--> |
526 |
</style> |
</style> |
527 |
<script type="text/javascript"> |
<script type="text/javascript"> |
536 |
$retHTML .= <<'EOF3'; |
$retHTML .= <<'EOF3'; |
537 |
|
|
538 |
function debug(msg) { |
function debug(msg) { |
539 |
// return; // Disable debugging |
return; // Disable debugging |
540 |
|
|
541 |
if (! debug_div) debug_div = document.getElementById('debug'); |
if (! debug_div) debug_div = document.getElementById('debug'); |
542 |
|
|
592 |
update_sum(suma); |
update_sum(suma); |
593 |
} |
} |
594 |
|
|
595 |
function update_sum(suma) { |
function update_sum(suma, suma_disp) { |
596 |
element_id('forma').elements['totalsize'].value = suma; |
if (! suma_disp) suma_disp = suma; |
597 |
|
element_id('forma').elements['totalsize'].value = suma_disp; |
598 |
pbar_set(suma, media_size); |
pbar_set(suma, media_size); |
599 |
debug('total size: ' + suma); |
debug('total size: ' + suma); |
600 |
} |
} |
609 |
} else { |
} else { |
610 |
suma -= size; |
suma -= size; |
611 |
} |
} |
612 |
|
|
613 |
|
var parts = parseInt( element_id("prt" + e.name.substr(3)).value); |
614 |
|
if (suma > media_size && suma == size && parts > 1) { |
615 |
|
element_id("parts").innerHTML = "This will take "+parts+" mediums!"; |
616 |
|
element_id("parts").style.display = 'block'; |
617 |
|
update_sum(media_size, suma); |
618 |
|
suma = media_size; |
619 |
|
return suma; |
620 |
|
} else { |
621 |
|
element_id("parts").style.display = 'none'; |
622 |
|
} |
623 |
|
|
624 |
|
if (suma < 0) suma = 0; |
625 |
} else { |
} else { |
626 |
suma = 0; |
suma = 0; |
627 |
for (var i = 0; i < len; i++) { |
for (var i = 0; i < len; i++) { |
719 |
</div> |
</div> |
720 |
<br/> |
<br/> |
721 |
|
|
722 |
|
<div id="parts"> </div> |
723 |
|
|
724 |
Note: |
Note: |
725 |
<textarea name="note" cols="10" rows="5" id="note"></textarea> |
<textarea name="note" cols="10" rows="5" id="note"></textarea> |
726 |
|
|
785 |
'<td align="center">' . $backup->{'age'} . '</td>' . |
'<td align="center">' . $backup->{'age'} . '</td>' . |
786 |
'<td align="right">' . $backup->{'size'} . '</td>' . |
'<td align="right">' . $backup->{'size'} . '</td>' . |
787 |
'<td align="right">' . $backup->{'inc_size'} . |
'<td align="right">' . $backup->{'inc_size'} . |
788 |
'<input type="hidden" iD="fss'.$checkbox_key .'" value="'. $backup->{'inc_size'} .'"></td>' . |
'<input type="hidden" id="fss'.$checkbox_key .'" value="'. $backup->{'inc_size'} .'"></td>' . |
789 |
|
'<input type="hidden" id="prt'.$checkbox_key .'" value="'. $backup->{'parts'} .'"></td>' . |
790 |
|
|
791 |
"</tr>\n"; |
"</tr>\n"; |
792 |
} |
} |
862 |
return sprintf(qq{<a href="?action=%s&host=%s&num=%d&share=%s&dir=%s">%s</a>}, $action, @_); |
return sprintf(qq{<a href="?action=%s&host=%s&num=%d&share=%s&dir=%s">%s</a>}, $action, @_); |
863 |
} |
} |
864 |
|
|
865 |
|
my $sth_archived; |
866 |
|
my %archived_cache; |
867 |
|
|
868 |
|
sub check_archived($$$) { |
869 |
|
my ($host, $share, $num) = @_; |
870 |
|
|
871 |
|
if (my $html = $archived_cache{"$host $share $num"}) { |
872 |
|
return $html; |
873 |
|
} |
874 |
|
|
875 |
|
$sth_archived ||= $dbh->prepare(qq{ |
876 |
|
select |
877 |
|
dvd_nr, note, |
878 |
|
count(archive_burned.copy) as copies |
879 |
|
from archive |
880 |
|
inner join archive_burned on archive_burned.archive_id = archive.id |
881 |
|
inner join archive_backup on archive.id = archive_backup.archive_id |
882 |
|
inner join backups on backups.id = archive_backup.backup_id |
883 |
|
inner join hosts on hosts.id = backups.hostid |
884 |
|
inner join shares on shares.id = backups.shareid |
885 |
|
where hosts.name = ? and shares.name = ? and backups.num = ? |
886 |
|
group by dvd_nr, note |
887 |
|
}); |
888 |
|
|
889 |
|
my @mediums; |
890 |
|
|
891 |
|
$sth_archived->execute($host, $share, $num); |
892 |
|
while (my $row = $sth_archived->fetchrow_hashref()) { |
893 |
|
push @mediums, '<abbr title="' . |
894 |
|
$row->{'note'} . |
895 |
|
' [' . $row->{'copies'} . ']' . |
896 |
|
'">' .$row->{'dvd_nr'} . |
897 |
|
'</abbr>'; |
898 |
|
} |
899 |
|
|
900 |
|
my $html = join(", ",@mediums); |
901 |
|
$archived_cache{"$host $share $num"} = $html; |
902 |
|
return $html; |
903 |
|
} |
904 |
|
|
905 |
my $i = $offset * $on_page; |
my $i = $offset * $on_page; |
906 |
|
|
907 |
foreach $file (@{ $files }) { |
foreach $file (@{ $files }) { |
918 |
qq{<td class="fviewborder" align="center">} . restore_link( $typeStr, ${EscURI( $file->{'hname'} )}, $file->{'backupnum'}, ${EscURI( $file->{'sname'})}, ${EscURI( $file->{'filepath'} )}, $file->{'backupnum'} ) . qq{</td>} . |
qq{<td class="fviewborder" align="center">} . restore_link( $typeStr, ${EscURI( $file->{'hname'} )}, $file->{'backupnum'}, ${EscURI( $file->{'sname'})}, ${EscURI( $file->{'filepath'} )}, $file->{'backupnum'} ) . qq{</td>} . |
919 |
qq{<td class="fviewborder" align="right">} . $file->{'size'} . qq{</td>} . |
qq{<td class="fviewborder" align="right">} . $file->{'size'} . qq{</td>} . |
920 |
qq{<td class="fviewborder">} . epoch_to_iso( $file->{'date'} ) . qq{</td>} . |
qq{<td class="fviewborder">} . epoch_to_iso( $file->{'date'} ) . qq{</td>} . |
921 |
qq{<td class="fviewborder">} . '?' . qq{</td>}; |
qq{<td class="fviewborder">} . check_archived( $file->{'hname'}, $file->{'sname'}, $file->{'backupnum'} ) . qq{</td>}; |
922 |
|
|
923 |
$retHTML .= "</tr>"; |
$retHTML .= "</tr>"; |
924 |
} |
} |