From 1321def3e191f616a03e901c3b8f7c987ca3f85c Mon Sep 17 00:00:00 2001 From: Keplyx Date: Sun, 22 Apr 2018 19:46:59 +0200 Subject: [PATCH] Display album download only if available --- photos.php | 73 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 23 deletions(-) diff --git a/photos.php b/photos.php index 581ed9d..5fabb5f 100644 --- a/photos.php +++ b/photos.php @@ -1,31 +1,55 @@ $value) { + $path = realpath($dir.DIRECTORY_SEPARATOR.$value); + if (!is_dir($path)) { + $valid = pathinfo($path, PATHINFO_EXTENSION) == "zip"; + if ($valid) + break; + } + } + return $valid; +} + + // Get all directories in the specified path function getDirectories($dir) { - $dir = "photos/".$dir; + $dir = "photos".$dir; $files = scandir($dir); $displayedItems = 0; foreach ($files as $key => $value) { $path = realpath($dir . DIRECTORY_SEPARATOR . $value); if (is_dir($path) && $value != "." && $value != "..") { $folderTitle = $value; - $folderLink = "?folder=" . getActiveFolder() . $value; - $folderClass = ""; + $folderLink = "?".urlParam."=".getActivePath().DIRECTORY_SEPARATOR.$value; include("includes/photos/folder_template.php"); $displayedItems++; } @@ -39,16 +63,16 @@ function getDirectories($dir) // Get all photos in the specified path function getPhotos($dir) { - $dir = "photos/".$dir; + $dir = "photos".$dir; $files = scandir($dir); $displayedItems = 0; foreach ($files as $key => $value) { - $path = realpath($dir . DIRECTORY_SEPARATOR . $value); + $path = realpath($dir.DIRECTORY_SEPARATOR.$value); if (!is_dir($path)) { $ext = pathinfo($path, PATHINFO_EXTENSION); - if ($ext == "bmp" || $ext == "jpg" || $ext == "jpeg" || $ext == "png") { - $imageSrc = $dir . $value; - $imageId = "photo-" . $displayedItems; + if ($ext == "bmp" || $ext == "jpg" || $ext == "jpeg" || $ext == "png" || $ext == "gif") { + $imageSrc = $dir.DIRECTORY_SEPARATOR.$value; + $imageId = "photo-".$displayedItems; include("includes/photos/photo_template.php"); $displayedItems++; } @@ -66,13 +90,13 @@ function generatePath($dir) $folders = explode(DIRECTORY_SEPARATOR, $dir); $currentPath = ""; $pathTitle = "Menu"; - $pathLink = "?folder="; + $pathLink = "?".urlParam."="; include("includes/photos/path_template.php"); foreach ($folders as $value) { if ($value != "") { $pathTitle = $value; - $currentPath .= $value . DIRECTORY_SEPARATOR; - $pathLink = "?folder=" . $currentPath; + $currentPath .= DIRECTORY_SEPARATOR.$value; + $pathLink = "?".urlParam."=".$currentPath; include("includes/photos/path_template.php"); } } @@ -107,21 +131,24 @@ function generatePath($dir)
-
- -

Télécharger l'album

-
+ + + +

Télécharger l'album

+
+ +