require 'config.php';
// load plugins
-$plugins = scandir("plugins");
-array_shift($plugins); array_shift($plugins); // remove . and ..
-foreach ($plugins as $p) if (is_file("plugins/$p/functions.php"))
- require "plugins/$p/functions.php";
+$plugins = array();
+if (is_dir("plugins")) {
+ $plugins = scandir("plugins");
+ array_shift($plugins); array_shift($plugins); // remove . and ..
+ foreach ($plugins as $p) if (is_file("plugins/$p/functions.php"))
+ require "plugins/$p/functions.php";
+}
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;
}
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();
# 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");
{
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") {
- $link = dirname($scriptUrlPath)."/$realDir/$file";
- $link = getThumbTarget("$shortPath/$file");
-
- $imageFiles[] = array( "name" => $file, "url" => getPreview("$realDir/$file"), "link" => $link );
-
+ $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 = "";
}
</style>
<?php foreach ($plugins as $p) if (is_file("plugins/$p/style.css")) { ?>
- <link rel="stylesheet" type="text/css" href="<?php echo dirname($scriptUrlPath)."/plugins/$p/style.css" ?>" />
+ <link rel="stylesheet" type="text/css" href="<?php echo "$rootUrl/plugins/$p/style.css" ?>" />
<?php } ?>
</head>
<body>