diff --git a/flake.nix b/flake.nix index d1a3f4f..82afb98 100644 --- a/flake.nix +++ b/flake.nix @@ -65,7 +65,6 @@ # - Make "trusted.url.domains" dynamic based on the current host:port # - Do not download composer.phar with curl(!) # - Relicense the project to GPL or something - # - Move gallery/slideshow images to an external directory (configurable) # - Write a module for the project }; diff --git a/www/galleri/bilder/slideshow/.gitkeep b/www/galleri/bilder/slideshow/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/www/galleri/index.php b/www/galleri/index.php index cba76e1..35d25f4 100644 --- a/www/galleri/index.php +++ b/www/galleri/index.php @@ -18,23 +18,24 @@ if(!$loginname) { exit(); } +# Sourced from config.php through include.php +$galleryDir = $GALLERY_DIRECTORY; +$serverPath = $GALLERY_SERVER_PATH; -$unamefile = __DIR__ . '/usernames.txt'; -$relativePath = "/bilder/pvv-photos/"; $allowedExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'svg', 'webp']; +$unamefile = $galleryDir . "/usernames.txt"; $unamepairs = file($unamefile); -$fullPath = getcwd() . $relativePath; function getDirContents($dir, &$results = array()) { $files = scandir($dir); foreach ($files as $key => $value) { $path = realpath($dir . DIRECTORY_SEPARATOR . $value); if (!is_dir($path)) { - //Remove the full path on disk, keep username and relative path to image. ( $results[] = str_replace($GLOBALS["fullPath"], "", $path); is insecure.) - $pos = strpos($path, $GLOBALS["fullPath"]); + //Remove the full path on disk, keep username and relative path to image. + $pos = strpos($path, $GLOBALS["galleryDir"]); if ($pos !== false) { - $cleanPath = substr_replace($path, "", $pos, strlen($GLOBALS["fullPath"])); + $cleanPath = substr_replace($path, "", $pos, strlen($GLOBALS["galleryDir"])); } //Check if the file is an image @@ -49,7 +50,7 @@ function getDirContents($dir, &$results = array()) { } return $results; } -$images = getDirContents($fullPath); +$images = getDirContents($galleryDir); $imageTemplate = '