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";
22 require "$bizouRootFromHere/functions.php";
24 // extract /path/to/image.jpg from /view.php/path/to/image.jpg
25 $simpleImagePath = getPathInfo();
27 if (! is_file("$bizouRootFromHere/".IMAGES_DIR.$simpleImagePath)) {
28 header("HTTP/1.1 404 Not Found");
29 die("File Not Found");
32 // get all images in an array
35 $files = scandir("$bizouRootFromHere/".IMAGES_DIR.dirname($simpleImagePath));
36 foreach ($files as $file) if ($file[0] != '.')
38 $ext = strtolower(substr($file, -4));
39 if ($ext == ".jpg" or $ext == ".png")
43 // find the image position
44 $pos = array_search(basename($simpleImagePath), $images);
45 if ($pos === false) die("Image not found");
47 // get prev and next images
51 $prevImage = $images[$pos-1];
52 if ($pos < sizeof($images)-1)
53 $nextImage = $images[$pos+1];
55 $scriptUrl = $_SERVER["SCRIPT_NAME"];
56 $bizouRootUrl = dirname(dirname(dirname($scriptUrl)));
57 if (substr($bizouRootUrl, -1) !== '/') $bizouRootUrl.='/'; // add a trailing / to rootUrl
58 // scriptUrl = /path/to/bizou/plugins/viewer/view.php
59 // bizouRootUrl = /path/to/bizou/
62 $imageUrl = $bizouRootUrl.IMAGES_DIR.$simpleImagePath;
64 if ($nextImage === '') {
68 $nextImageUrl = dirname($bizouRootUrl.IMAGES_DIR.$simpleImagePath)."/$nextImage";
69 $nextPageUrl = dirname($_SERVER["REQUEST_URI"])."/$nextImage";
71 if ($prevImage === '') $prevPageUrl = '';
72 else $prevPageUrl = dirname($_SERVER["REQUEST_URI"])."/$prevImage";
74 $directoryUrl = $bizouRootUrl."index.php".dirname($simpleImagePath);
76 $firefox = strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false;
78 ///// template starts here /////
79 header('Content-Type: text/html; charset=utf-8');
80 header('Cache-Control: max-age=3600');
82 require 'template.php';