diff --git a/photostest.php b/photostest.php index 8801ac3..d2c4c16 100644 --- a/photostest.php +++ b/photostest.php @@ -17,8 +17,8 @@ function getActivePath() $currentPath = ""; foreach ($folders as $value) { if ($value != ".." && $value != "." && $value != "") { - $currentPath .= DIRECTORY_SEPARATOR . $value; - } + $currentPath .= DIRECTORY_SEPARATOR . $value; + } } return $currentPath; } @@ -30,8 +30,8 @@ function getActivePath() */ function GetActiveFolder($path) { - $dir = explode(DIRECTORY_SEPARATOR, $path); - return $dir[sizeof($dir) - 1]; // Last item after / + $dir = explode(DIRECTORY_SEPARATOR, $path); + return $dir[sizeof($dir) - 1]; // Last item after / } /** @@ -41,15 +41,15 @@ function GetActiveFolder($path) */ function isAlbumAvailable($path) { - $dir = photoRoot . $path; - $files = scandir($dir); - $valid = false; - foreach ($files as $key => $value) { - $path = realpath($dir . DIRECTORY_SEPARATOR . $value); - if (!is_dir($path)) { - $valid = pathinfo($path, PATHINFO_EXTENSION) == "zip"; - if ($valid) - break; + $dir = photoRoot . $path; + $files = scandir($dir); + $valid = false; + foreach ($files as $key => $value) { + $path = realpath($dir . DIRECTORY_SEPARATOR . $value); + if (!is_dir($path)) { + $valid = pathinfo($path, PATHINFO_EXTENSION) == "zip"; + if ($valid) + break; } } return $valid; @@ -61,18 +61,18 @@ function isAlbumAvailable($path) */ function createDirectories($path) { - $path = photoRoot . $path; - $displayedItems = 0; - $folders = getDirectories($path); - foreach ($folders as $key => $value) { - $folderTitle = $value; - $photos = getTotalPhotoCount($path . DIRECTORY_SEPARATOR . $value); - $albums = getTotalAlbumCount($path . DIRECTORY_SEPARATOR . $value); - $folderLink = "?" . urlParam . "=" . getActivePath() . DIRECTORY_SEPARATOR . $value; - include("includes/photos/folder_template.php"); - $displayedItems++; + $path = photoRoot . $path; + $displayedItems = 0; + $folders = getDirectories($path); + foreach ($folders as $key => $value) { + $folderTitle = $value; + $photos = getTotalPhotoCount($path . DIRECTORY_SEPARATOR . $value); + $albums = getTotalAlbumCount($path . DIRECTORY_SEPARATOR . $value); + $folderLink = "?" . urlParam . "=" . getActivePath() . DIRECTORY_SEPARATOR . $value; + include("includes/photos/folder_template.php"); + $displayedItems++; - } + } } @@ -83,16 +83,16 @@ function createDirectories($path) function createPhotos($path) { $path = photoRoot . "_thumb" . $path; - $files = scandir($path); - $displayedItems = 0; - foreach ($files as $key => $value) { - $realPath = realpath($path . DIRECTORY_SEPARATOR . $value); - if (isValidImage($realPath)) { - $imageSrc = $path . DIRECTORY_SEPARATOR . $value; - $imageId = "photo-" . $displayedItems; - include("includes/photos/photo_template.php"); - $displayedItems++; - } + $files = scandir($path); + $displayedItems = 0; + foreach ($files as $key => $value) { + $realPath = realpath($path . DIRECTORY_SEPARATOR . $value); + if (isValidImage($realPath)) { + $imageSrc = $path . DIRECTORY_SEPARATOR . $value; + $imageId = "photo-" . $displayedItems; + include("includes/photos/photo_template.php"); + $displayedItems++; + } } } @@ -103,13 +103,13 @@ function createPhotos($path) */ function getDirectories($path) { - $files = scandir($path); - $folders = []; - foreach ($files as $key => $value) { - $realPath = realpath($path . DIRECTORY_SEPARATOR . $value); - if (isValidDirectory($realPath, $value)) { - array_push($folders, $value); - } + $files = scandir($path); + $folders = []; + foreach ($files as $key => $value) { + $realPath = realpath($path . DIRECTORY_SEPARATOR . $value); + if (isValidDirectory($realPath, $value)) { + array_push($folders, $value); + } } return $folders; } @@ -121,13 +121,13 @@ function getDirectories($path) */ function getDirectoriesCount($path) { - $files = scandir($path); - $dirCount = 0; - foreach ($files as $key => $value) { - $realPath = realpath($path . DIRECTORY_SEPARATOR . $value); - if (isValidDirectory($realPath, $value)) { - $dirCount++; - } + $files = scandir($path); + $dirCount = 0; + foreach ($files as $key => $value) { + $realPath = realpath($path . DIRECTORY_SEPARATOR . $value); + if (isValidDirectory($realPath, $value)) { + $dirCount++; + } } return $dirCount; } @@ -140,12 +140,12 @@ function getDirectoriesCount($path) function getPhotoCount($path) { $files = scandir($path); - $fileCount = 0; - foreach ($files as $key => $value) { - $realPath = realpath($path . DIRECTORY_SEPARATOR . $value); - if (isValidImage($realPath)) { - $fileCount++; - } + $fileCount = 0; + foreach ($files as $key => $value) { + $realPath = realpath($path . DIRECTORY_SEPARATOR . $value); + if (isValidImage($realPath)) { + $fileCount++; + } } return $fileCount; } @@ -157,21 +157,21 @@ function getPhotoCount($path) */ function getTotalAlbumCount($path) { - $folders = getDirectories($path); - $total = sizeof($folders); - foreach ($folders as $key => $value) { - $total += getTotalAlbumCount($path . DIRECTORY_SEPARATOR . $value); - } + $folders = getDirectories($path); + $total = sizeof($folders); + foreach ($folders as $key => $value) { + $total += getTotalAlbumCount($path . DIRECTORY_SEPARATOR . $value); + } return $total; -} + } function getTotalPhotoCount($path) { - $folders = getDirectories($path); - $total = getPhotoCount($path); - foreach ($folders as $key => $value) { - $total += getTotalPhotoCount($path . DIRECTORY_SEPARATOR . $value); - } + $folders = getDirectories($path); + $total = getPhotoCount($path); + foreach ($folders as $key => $value) { + $total += getTotalPhotoCount($path . DIRECTORY_SEPARATOR . $value); + } return $total; } @@ -182,8 +182,8 @@ function getTotalPhotoCount($path) */ function isValidImage($imagePath) { - $ext = pathinfo($imagePath, PATHINFO_EXTENSION); - return !is_dir($imagePath) && ($ext == "jpg" || $ext == "JPG" || $ext == "jpeg" || $ext == "JPEG" || $ext == "png" || $ext == "PNG"); + $ext = pathinfo($imagePath, PATHINFO_EXTENSION); + return !is_dir($imagePath) && ($ext == "jpg" || $ext == "JPG" || $ext == "jpeg" || $ext == "JPEG" || $ext == "png" || $ext == "PNG"); } /** @@ -194,7 +194,7 @@ function isValidImage($imagePath) */ function isValidDirectory($directoryPath, $directory) { - return is_dir($directoryPath) && $directory != "." && $directory != ".." && substr($directory, 0, 1) !== "."; + return is_dir($directoryPath) && $directory != "." && $directory != ".." && substr($directory, 0, 1) !== "."; } @@ -204,89 +204,91 @@ function isValidDirectory($directoryPath, $directory) */ function generatePath($path) { - $folders = explode(DIRECTORY_SEPARATOR, $path); - $currentPath = ""; - $pathTitle = "Menu"; - $pathLink = "?" . urlParam . "="; - include("includes/photos/path_template.php"); - foreach ($folders as $value) { - if ($value != "") { - $pathTitle = $value; - $currentPath .= DIRECTORY_SEPARATOR . $value; - $pathLink = "?" . urlParam . "=" . $currentPath; - include("includes/photos/path_template.php"); - } + $folders = explode(DIRECTORY_SEPARATOR, $path); + $currentPath = ""; + $pathTitle = "Menu"; + $pathLink = "?" . urlParam . "="; + include("includes/photos/path_template.php"); + foreach ($folders as $value) { + if ($value != "") { + $pathTitle = $value; + $currentPath .= DIRECTORY_SEPARATOR . $value; + $pathLink = "?" . urlParam . "=" . $currentPath; + include("includes/photos/path_template.php"); + } } } ?>
- -
- 0): ?> -
- -
- - - - Télécharger - photos - - - 0): ?> -
- -
- -
- - +