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