. */ $bizouRootFromHere = '../..'; require "$bizouRootFromHere/config.php"; $simpleImagePath = $_SERVER["PATH_INFO"]; if ($simpleImagePath == '/') $simpleImagePath = ''; // extra security check to avoid /photos/index/../.. like urls, maybe useless but.. if (strpos($simpleImagePath, '..') !== false) die(".. found in url"); if (! is_file("$bizouRootFromHere/".IMAGES_DIR.$simpleImagePath)) { header("HTTP/1.1 404 Not Found"); die("File Not Found"); } // get all images in an array $images = array(); $files = scandir("$bizouRootFromHere/".IMAGES_DIR.dirname($simpleImagePath)); foreach ($files as $file) { $ext = strtolower(substr($file, -4)); if ($ext == ".jpg" or $ext == ".png") $images[] = $file; } // find the image position $pos = array_search(basename($simpleImagePath), $images); if ($pos === false) die("Image not found"); // get prev and next images $prevImage = ''; $nextImage = ''; if ($pos > 0) $prevImage = $images[$pos-1]; if ($pos < sizeof($images)-1) $nextImage = $images[$pos+1]; $scriptUrl = $_SERVER["SCRIPT_NAME"]; $bizouRootUrl = dirname(dirname(dirname($scriptUrl))); // scriptUrl = /path/to/bizou/plugins/viewer/view.php // bizouRootUrl = /path/to/bizou // template variables $imageUrl = "$bizouRootUrl/".IMAGES_DIR.$simpleImagePath; if ($nextImage === '') { $nextImageUrl = ''; $nextPageUrl = ''; } else { $nextImageUrl = "$bizouRootUrl/".IMAGES_DIR.dirname($simpleImagePath)."/$nextImage"; $nextPageUrl = dirname($_SERVER["REQUEST_URI"])."/$nextImage"; } if ($prevImage === '') $prevPageUrl = ''; else $prevPageUrl = dirname($_SERVER["REQUEST_URI"])."/$prevImage"; $directoryUrl = "$bizouRootUrl/index.php".dirname($simpleImagePath); $firefox = strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false; header('Content-Type: text/html; charset=utf-8'); header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + 3600)); ?>
^