aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormoehm2014-10-19 06:59:54 +0200
committermoehm2014-10-19 06:59:54 +0200
commitfe229655401abfa5aea2dc6c8830c8b9ed71aa64 (patch)
treea635fd473c9c3ddc7c5df08e23658fa6479fa92b
parent0de0bc0a7f0241aa29b2034a5cec3e9a91c1113e (diff)
downloadjungegemeinde-fe229655401abfa5aea2dc6c8830c8b9ed71aa64.tar.gz
Download zip archiv with all images.
-rw-r--r--action.php34
-rw-r--r--functions.php2
2 files changed, 35 insertions, 1 deletions
diff --git a/action.php b/action.php
index e2d0098..f15f776 100644
--- a/action.php
+++ b/action.php
@@ -342,7 +342,7 @@ JG Adlershof";
}
lredirect( "gallery;gallery=".htmlentities($_GET["gallery"]) );
if ( ! isset($_GET["gallery"]) || $_GET["gallery"] == "" ){
- redirect( "gallery;gallery=".htmlentities($_GET["gallery"]) );
+ redirect( "gallery;gallery=".htmlentities($_SESSION["gallery"]) );
}
rrmdir( IMAGE_PATH . $_GET["gallery"] );
$sql = $db->prepare("DELETE FROM " . DBPREFIX . "gallery WHERE id = %d;", $_GET["gallery"]);
@@ -350,6 +350,38 @@ JG Adlershof";
$c->flush2();
redirect("foto");
break;
+ case("downloadGallery"):
+ if ( $_SERVER['REQUEST_METHOD'] != 'POST' ){
+ 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"]) ){
+ 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('..', '.') );
+ foreach( $images as $image){
+ if ( is_file($image) ){
+ $zip->addFile($image, basename($image));
+ }
+ }
+ $zip->close();
+ ob_end_clean();
+ header("Content-Type: application/zip");
+ header("Content-Length: " . filesize($zname));
+ header("Content-Disposition: attachment; filename=jg_fotoalbum_".$_GET["gallery"]);
+ readfile($zname);
+ unlink($zname);
+ exit;
+ } else {
+ redirect("gallery&gallery=".$_GET["gallery"]);
+ }
+ break;
default:
print_404();
break;
diff --git a/functions.php b/functions.php
index 31eeb94..eba19f9 100644
--- a/functions.php
+++ b/functions.php
@@ -735,6 +735,8 @@ function show_gallery(){
<li><a href="#change" role="tab" onclick="$('#modal-edit-gallery').modal('show');"><span class="glyphicon glyphicon-cog"></span> Ändern</a></li>
<li><a href="#new" role="tab" onclick="$('#modal-new-gallery').modal('show')"><span class="fa fa-plus"></span> Neu</a></li>
<li><a href="#delete" role="tab" onclick="$('#modal-delete-gallery').modal('show')"><span class="glyphicon glyphicon-trash"></span> Löschen</a></li>
+ <li><a href="/?page=downloadGallery&amp;gallery=<?php echo htmlentities($_GET["gallery"]); ?>" role="tab"><i class="fa fa-download"></i>
+ Download</a></li>
</ul>
<div class="tab-content">
<?php