summaryrefslogtreecommitdiffstats
path: root/system/helpers/file_helper.php
diff options
context:
space:
mode:
authorDerek Jones <derek.jones@ellislab.com>2008-03-28 15:13:14 +0100
committerDerek Jones <derek.jones@ellislab.com>2008-03-28 15:13:14 +0100
commitf00992d66cab3efa8cbec8cc8623c4ea830cc5e3 (patch)
tree2df6b111f9f3428d8c37bb7809c239d1d4eab8c0 /system/helpers/file_helper.php
parent560efb353a1395f51a170f32b974c2afb897a712 (diff)
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.
Diffstat (limited to 'system/helpers/file_helper.php')
-rw-r--r--system/helpers/file_helper.php17
1 files changed, 8 insertions, 9 deletions
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) != '.')