From f00992d66cab3efa8cbec8cc8623c4ea830cc5e3 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Fri, 28 Mar 2008 14:13:14 +0000 Subject: moved the $_recursion conditional in get_filenames() to fix a bug where a bad submitted path would result in the system using / as the source directory. --- system/helpers/file_helper.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'system') diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index 7eb93dab2..e1a4ff31a 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -168,17 +168,16 @@ if (! function_exists('get_filenames')) function get_filenames($source_dir, $include_path = FALSE, $_recursion = FALSE) { static $_filedata = array(); - - // reset the array and make sure $source_dir has a trailing slash on the initial call - if ($_recursion === FALSE) - { - $_filedata = array(); - $source_dir = realpath($source_dir).'/'; - } - - + if ($fp = @opendir($source_dir)) { + // reset the array and make sure $source_dir has a trailing slash on the initial call + if ($_recursion === FALSE) + { + $_filedata = array(); + $source_dir = realpath($source_dir).'/'; + } + while (FALSE !== ($file = readdir($fp))) { if (@is_dir($source_dir.$file) && substr($file, 0, 1) != '.') -- cgit v1.2.3-24-g4f1b