3 Bizou - a (french) KISS php image gallery
4 Copyright (C) 2010 Marc MAURICE
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 $bizouRootFromHere = '../..';
21 require "$bizouRootFromHere/config.php";
23 $simpleImagePath = $_SERVER["PATH_INFO"];
24 if ($simpleImagePath == '/') $simpleImagePath = '';
25 // extra security check to avoid /photos/index/../.. like urls, maybe useless but..
26 if (strpos($simpleImagePath, '..') !== false) die(".. found in url");
29 if (! is_file("$bizouRootFromHere/".IMAGES_DIR.$simpleImagePath)) {
30 header("HTTP/1.1 404 Not Found");
31 die("File Not Found");
34 // get all images in an array
37 $files = scandir("$bizouRootFromHere/".IMAGES_DIR.dirname($simpleImagePath));
38 foreach ($files as $file) {
39 $ext = strtolower(substr($file, -4));
40 if ($ext == ".jpg" or $ext == ".png")
44 // find the image position
45 $pos = array_search(basename($simpleImagePath), $images);
46 if ($pos === false) die("Image not found");
48 // get prev and next images
52 $prevImage = $images[$pos-1];
53 if ($pos < sizeof($images)-1)
54 $nextImage = $images[$pos+1];
56 $scriptUrl = $_SERVER["SCRIPT_NAME"];
57 $bizouRootUrl = dirname(dirname(dirname($scriptUrl)));
58 if (substr($bizouRootUrl, -1) !== '/') $bizouRootUrl.='/'; // add a trailing / to rootUrl
59 // scriptUrl = /path/to/bizou/plugins/viewer/view.php
60 // bizouRootUrl = /path/to/bizou/
63 $imageUrl = $bizouRootUrl.IMAGES_DIR.$simpleImagePath;
65 if ($nextImage === '') {
69 $nextImageUrl = $bizouRootUrl.IMAGES_DIR.dirname($simpleImagePath)."/$nextImage";
70 $nextPageUrl = dirname($_SERVER["REQUEST_URI"])."/$nextImage";
72 if ($prevImage === '') $prevPageUrl = '';
73 else $prevPageUrl = dirname($_SERVER["REQUEST_URI"])."/$prevImage";
75 $directoryUrl = $bizouRootUrl."index.php".dirname($simpleImagePath);
77 $firefox = strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false;
79 ///// template starts here /////
80 header('Content-Type: text/html; charset=utf-8');
81 header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + 3600));
83 require 'template.php';