From 304e0f09d760428d2c2195d371e8abfe705bab13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Tue, 28 Nov 2017 19:03:17 +0100 Subject: [PATCH] Adapt `viewer` plugin to absolute paths --- plugins/viewer/view.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/viewer/view.php b/plugins/viewer/view.php index 4b2eddd..cacd392 100644 --- a/plugins/viewer/view.php +++ b/plugins/viewer/view.php @@ -24,7 +24,13 @@ require "$bizouRootFromHere/functions.php"; // extract /path/to/image.jpg from /view.php/path/to/image.jpg $simpleImagePath = getPathInfo(); -if (! is_file("$bizouRootFromHere/".IMAGES_DIR.$simpleImagePath)) { +$imageBaseDir = "$bizouRootFromHere/".IMAGES_DIR; +if (IMAGES_DIR[0] == '/') { + $imageBaseDir = IMAGES_DIR; +} +$imagePath = $imageBaseDir . $simpleImagePath; + +if (! is_file($imagePath)) { header("HTTP/1.1 404 Not Found"); die("File Not Found"); } @@ -32,7 +38,7 @@ if (! is_file("$bizouRootFromHere/".IMAGES_DIR.$simpleImagePath)) { // get all images in an array $images = array(); -$files = scandir("$bizouRootFromHere/".IMAGES_DIR.dirname($simpleImagePath)); +$files = scandir($imageBaseDir . dirname($simpleImagePath)); foreach ($files as $file) if ($file[0] != '.') { $ext = strtolower(substr($file, -4)); @@ -59,7 +65,7 @@ if (substr($bizouRootUrl, -1) !== '/') $bizouRootUrl.='/'; // add a trailing / // bizouRootUrl = /path/to/bizou/ // template variables -$imageUrl = $bizouRootUrl.IMAGES_DIR.$simpleImagePath; +$imageUrl = $bizouRootUrl.IMAGES_URL.$simpleImagePath; if ($nextImage === '') { $nextImageUrl = '';