diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-03-04 02:03:05 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-03-04 02:03:05 +0000 |
commit | 4a5b005931750e729c67694d50f9c904e51cd53e (patch) | |
tree | cde269fa83c8901ca08c92bf251ab4dfee4aa0b5 | |
parent | 328a982546a202140697700b6688da3e32dbb2de (diff) |
Use Directory Iterator
-rw-r--r-- | modules/local_import/controllers/local_import.php | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/modules/local_import/controllers/local_import.php b/modules/local_import/controllers/local_import.php index 9dcb108b..c85c63a5 100644 --- a/modules/local_import/controllers/local_import.php +++ b/modules/local_import/controllers/local_import.php @@ -103,20 +103,22 @@ class Local_Import_Controller extends Controller { } private function _get_children($path) { + print $path . "\n"; $file_list = array(); - $files = scandir($path); + $files = new DirectoryIterator($path); foreach ($files as $file) { - if ($file[0] != ".") { - $full_path = "$path/$file"; - if (is_dir($full_path)) { - $file_list[$file] = - array("path" => $full_path, "is_dir" => true); + if ($file->isDot()) { + continue; + } + $filename = $file->getFilename(); + if ($filename[0] != ".") { + if ($file->isDir()) { + $file_list[$filename] = array("path" => $file->getPathname(), "is_dir" => true); } else { - $extension = strtolower(substr(strrchr($file, '.'), 1)); - // Make sure the file is readable - if (is_readable($full_path) && + $extension = strtolower(substr(strrchr($filename, '.'), 1)); + if ($file->isReadable() && in_array($extension, array("gif", "jpeg", "jpg", "png", "flv", "mp4"))) { - $file_list[$file] = array("path" => $full_path, "is_dir" => false); + $file_list[$filename] = array("path" => $file->getPathname(), "is_dir" => false); } } } |