X-Git-Url: http://positon.org/gitweb/?a=blobdiff_plain;f=index.php;h=a52392a12e982a1611ea70f255928cceab1d63e1;hb=ad9d78f8d7d11028438d6fc766f2dfee382c9a44;hp=8a690187072c770a8da08101ac971fd10b2ed2eb;hpb=8ed0bc08f5e9e151c7804e47aab402a523718568;p=bizou.git diff --git a/index.php b/index.php index 8a69018..a52392a 100644 --- a/index.php +++ b/index.php @@ -31,8 +31,8 @@ function plugins_include($phpFile) require "plugins/$p/$phpFile"; } -if (! function_exists('getThumbTarget')) { -function getThumbTarget($imageSimplePath) +if (! function_exists('getImageLink')) { +function getImageLink($imageSimplePath) { return dirname($_SERVER["SCRIPT_NAME"]).'/'.IMAGES_DIR.$imageSimplePath; } @@ -97,23 +97,26 @@ function getAlbumPreview($dir) return ''; } -$scriptUrlPath = $_SERVER["SCRIPT_NAME"]; +$scriptUrl = $_SERVER["SCRIPT_NAME"]; +$rootUrl = dirname($scriptUrl); +// $scriptUrl = "/path/to/bizou/index.php" +// $rootUrl = "/path/to/bizou" // if url == http://localhost/photos/index.php/toto/titi, path_info == /toto/titi // if url == http://localhost/photos/index.php, path_info is not set // if url == http://localhost/photos/, path_info is not set // if path_info is not set, we are at top level, so we redirect to /photos/index.php/ if (! isset($_SERVER["PATH_INFO"])) { - header("Location: $scriptUrlPath/"); + header("Location: $scriptUrl/"); exit(); } -# shortPath is the simple path to the image -# /index.php/toto/titi => shortPath == /toto/titi -$shortPath = $_SERVER["PATH_INFO"]; -if ($shortPath == '/') $shortPath = ''; +# simplePath is the simple path to the image +# /index.php/toto/titi => simplePath == /toto/titi +$simplePath = $_SERVER["PATH_INFO"]; +if ($simplePath == '/') $simplePath = ''; // extra security check to avoid /photos/index/../.. like urls, maybe useless but.. -if (strpos($shortPath, '..') !== false) die(".. found in url"); +if (strpos($simplePath, '..') !== false) die(".. found in url"); $folders = array(); $imageFiles = array(); @@ -121,7 +124,7 @@ $otherFiles = array(); # realDir is the directory in filesystem # seen from current script directory -$realDir = IMAGES_DIR.$shortPath; +$realDir = IMAGES_DIR.$simplePath; if (! is_dir($realDir)) { header("HTTP/1.1 404 Not Found"); @@ -132,21 +135,21 @@ foreach (scandir($realDir) as $file) if ($file != '.' and $file != '..') { if (is_dir("$realDir/$file")) { - $folders[] = array( "name" => $file, "link" => "$scriptUrlPath$shortPath/$file", "preview" => getAlbumPreview("$realDir/$file") ); + $folders[] = array( "name" => $file, "link" => "$scriptUrl$simplePath/$file", "preview" => getAlbumPreview("$realDir/$file") ); } else { $ext = strtolower(substr($file, -4)); if ($ext == ".jpg" or $ext == ".png") { - $imageFiles[] = array( "name" => $file, "url" => getPreview("$realDir/$file"), "link" => getThumbTarget("$shortPath/$file") ); + $imageFiles[] = array( "name" => $file, "url" => getPreview("$realDir/$file"), "link" => getImageLink("$simplePath/$file") ); } else { - $otherFiles[] = array( "name" => $file, "link" => dirname($scriptUrlPath)."/$realDir/$file" ); + $otherFiles[] = array( "name" => $file, "link" => "$rootUrl/$realDir/$file" ); } } } -if (dirname($shortPath) !== '') - $parentLink = $scriptUrlPath.dirname($shortPath); +if (dirname($simplePath) !== '') + $parentLink = $scriptUrl.dirname($simplePath); else $parentLink = ""; @@ -192,7 +195,7 @@ a { } - " /> + " />