From 2c6dda41c8207ffa704934a1fbde65769ce86992 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Tue, 26 Feb 2008 23:18:27 +0000 Subject: fixed recursion in get_filenames() (bug #3523) --- system/helpers/file_helper.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'system/helpers/file_helper.php') diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index 096d225d7..1b37af2fd 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -164,17 +164,22 @@ if (! function_exists('delete_files')) */ if (! function_exists('get_filenames')) { - function get_filenames($source_dir, $include_path = FALSE) + function get_filenames($source_dir, $include_path = FALSE, $recursion = FALSE) { - $_filedata = array(); - + static $_filedata = array(); + + if ($recursion === FALSE) + { + $_filedata = array(); + } + if ($fp = @opendir($source_dir)) { while (FALSE !== ($file = readdir($fp))) { if (@is_dir($source_dir.$file) && substr($file, 0, 1) != '.') { - get_filenames($source_dir.$file."/", $include_path); + get_filenames($source_dir.$file."/", $include_path, TRUE); } elseif (substr($file, 0, 1) != ".") { -- cgit v1.2.3-24-g4f1b