From 2dda0f27a6cec50dcd3e6852cd6abc439cff28a1 Mon Sep 17 00:00:00 2001 From: Marc MAURICE Date: Thu, 30 Dec 2010 18:35:44 +0100 Subject: [PATCH] Renammed scriptUrlPath to scriptUrl and added rootUrl --- index.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/index.php b/index.php index 337e96f..a52392a 100644 --- a/index.php +++ b/index.php @@ -97,14 +97,17 @@ 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(); } @@ -132,7 +135,7 @@ foreach (scandir($realDir) as $file) if ($file != '.' and $file != '..') { if (is_dir("$realDir/$file")) { - $folders[] = array( "name" => $file, "link" => "$scriptUrlPath$simplePath/$file", "preview" => getAlbumPreview("$realDir/$file") ); + $folders[] = array( "name" => $file, "link" => "$scriptUrl$simplePath/$file", "preview" => getAlbumPreview("$realDir/$file") ); } else { @@ -140,13 +143,13 @@ foreach (scandir($realDir) as $file) if ($file != '.' and $file != '..') if ($ext == ".jpg" or $ext == ".png") { $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($simplePath) !== '') - $parentLink = $scriptUrlPath.dirname($simplePath); + $parentLink = $scriptUrl.dirname($simplePath); else $parentLink = ""; @@ -192,7 +195,7 @@ a { } - " /> + " /> -- 1.7.10.4