1 # Simple Photo Gallery: Archiving
2 # (c) 2003--2012 Martin Mares <mj@ucw.cz>
4 package UCW::Gallery::Archive;
13 sub send_archive($$) {
14 my ($gal, $meta) = @_;
16 if (!$gal->get('WebAllowArchives')) {
17 UCW::CGI::http_error('403 Archiving forbidden by server configuration');
21 my $zip = Archive::Zip->new;
23 for my $id (@{$meta->{sequence}}) {
24 $zip->addFile(File::Spec->catfile($gal->get('PhotoDir'), "$id.jpg"), sprintf("%03d.jpg", $cnt)) or die;
28 print "Content-type: application/zip\n";
29 print "Content-Disposition: attachment; filename=gallery.zip\n";
31 $zip->writeToFileHandle(\*STDOUT, 0);