diff options
author | Bharat Mediratta <bharat@menalto.com> | 2011-01-08 18:10:43 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2011-01-08 18:10:43 -0800 |
commit | 713bd4eb6a9bc91a244680828ce881ee8ea5f836 (patch) | |
tree | cbe97976918c4a7c6ad5e49b8ed63cc169d071b4 | |
parent | e8bbf537083a8f2ce6d70beb11057e41917f3499 (diff) |
Improve gallery::find_file() to do a better job of detecting the modules/themes directories.
Fixes #1590.
-rw-r--r-- | modules/gallery/helpers/gallery.php | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 69aabc4f..282289b5 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -153,8 +153,15 @@ class gallery_Core { if (is_string($file_name)) { // make relative to DOCROOT $parts = explode("/", $file_name); + $count = count($parts); foreach ($parts as $idx => $part) { - if (in_array($part, array("application", "modules", "themes", "lib"))) { + // If this part is "modules" or "themes" make sure that the part 2 after this + // is the target directory, and if it is then we're done. This check makes + // sure that if Gallery is installed in a directory called "modules" or "themes" + // We don't parse the directory structure incorrectly. + if (in_array($part, array("modules", "themes")) && + $idx + 2 < $count && + $parts[$idx + 2] == $directory) { break; } unset($parts[$idx]); |