aboutsummaryrefslogtreecommitdiff
path: root/action.php
diff options
context:
space:
mode:
Diffstat (limited to 'action.php')
-rw-r--r--action.php20
1 files changed, 11 insertions, 9 deletions
diff --git a/action.php b/action.php
index f15f776..a4d47f1 100644
--- a/action.php
+++ b/action.php
@@ -351,30 +351,32 @@ JG Adlershof";
redirect("foto");
break;
case("downloadGallery"):
- if ( $_SERVER['REQUEST_METHOD'] != 'POST' ){
+ if ( $_SERVER['REQUEST_METHOD'] != 'GET' ){
header($_SERVER["SERVER_PROTOCOL"] . " 405 Method Not Allowed");
ob_clean();
echo "Method not allowed";
exit;
}
lredirect( "gallery;gallery=".htmlentities($_GET["gallery"]) );
- if ( ! isset($_GET["gallery"]) || $_GET["gallery"] == "" || ! preg_match("/^[0-9]+$", $_GET["gallery"]) ){
+ if ( ! isset($_GET["gallery"]) || $_GET["gallery"] == "" || ! preg_match("/^[0-9]+$/", $_GET["gallery"]) ){
redirect( "gallery;gallery=".htmlentities($_SESSION["gallery"]) );
}
- $zname = '/tmp/jg_fotoalbum_'.$_GET["gallery"];
- $zip = new ZipArchive;
- if ( $zip->open($zname) === TRUE ){
- $images = array_diff( scandir(IMAGE_PATH . $_GET["gallery"]), array('..', '.') );
+ $zname = '/tmp/jg_fotoalbum.zip';
+ $zip = new ZipArchive();
+ if ( $zip->open($zname, ZipArchive::CREATE) == TRUE ){
+ $images = array_diff( scandir(IMAGE_PATH . $_GET["gallery"].'/'), array('..', '.') );
foreach( $images as $image){
- if ( is_file($image) ){
- $zip->addFile($image, basename($image));
+ if ( is_file(IMAGE_PATH . $_GET["gallery"] . '/' . $image) ){
+ //$zip->addFile($image, basename($image));
+ $zip->addFile(IMAGE_PATH . $_GET["gallery"] . '/' . $image, $image);
}
}
$zip->close();
ob_end_clean();
+ $name = $c->get2(CACHEPREFIX . $_GET["gallery"]);
header("Content-Type: application/zip");
header("Content-Length: " . filesize($zname));
- header("Content-Disposition: attachment; filename=jg_fotoalbum_".$_GET["gallery"]);
+ header("Content-Disposition: attachment; filename=\"".$name.".zip\"");
readfile($zname);
unlink($zname);
exit;