aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul S. Owen <psotfx@users.sourceforge.net>2003-08-09 11:18:05 +0000
committerPaul S. Owen <psotfx@users.sourceforge.net>2003-08-09 11:18:05 +0000
commitf41a46c92f0915384cf9d8bd3e274071094fb74f (patch)
treea28fefb1ad47bd085dd2973c3238597252dfb587
parentd85c1e052d0da513d3fd56c67a70a0d464cb75f5 (diff)
downloadforums-f41a46c92f0915384cf9d8bd3e274071094fb74f.tar
forums-f41a46c92f0915384cf9d8bd3e274071094fb74f.tar.gz
forums-f41a46c92f0915384cf9d8bd3e274071094fb74f.tar.bz2
forums-f41a46c92f0915384cf9d8bd3e274071094fb74f.tar.xz
forums-f41a46c92f0915384cf9d8bd3e274071094fb74f.zip
Ensure consistent output from filelist
git-svn-id: file:///svn/phpbb/trunk@4354 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r--phpBB/includes/functions_admin.php23
1 files changed, 17 insertions, 6 deletions
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 85378c2491..c1d329f60b 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -161,20 +161,31 @@ function filelist($rootdir, $dir = '', $type = 'gif|jpg|jpeg|png')
{
$matches = array();
- $dh = opendir($rootdir . $dir);
+ // Remove initial / if present
+ $rootdir = (substr($rootdir, 0, 1) == '/') ? substr($rootdir, 1) : $rootdir;
+ // Add closing / if present
+ $rootdir = ($rootdir && substr($rootdir, -1) != '/') ? $rootdir . '/' : $rootdir;
+
+ // Remove initial / if present
+ $dir = (substr($dir, 0, 1) == '/') ? substr($dir, 1) : $dir;
+ // Add closing / if present
+ $dir = ($dir && substr($dir, -1) != '/') ? $dir . '/' : $dir;
+ $dh = opendir($rootdir . $dir);
while ($fname = readdir($dh))
{
- if (is_file("$rootdir$dir/$fname") && filesize("$rootdir$dir/$fname") && preg_match('#\.' . $type . '$#i', $fname))
+ if (is_file("$rootdir$dir$fname"))
{
- $matches[$dir][] = $fname;
+ if (filesize("$rootdir$dir$fname") && preg_match('#\.' . $type . '$#i', $fname))
+ {
+ $matches[$dir][] = $fname;
+ }
}
- else if ($fname{0} != '.' && is_dir("$rootdir$dir/$fname"))
+ else if ($fname{0} != '.' && is_dir("$rootdir$dir$fname"))
{
- $matches += filelist($rootdir, "$dir/$fname", $type);
+ $matches += filelist($rootdir, "$dir$fname", $type);
}
}
-
closedir($dh);
return $matches;