diff --git a/application/models/mydir.php b/application/models/mydir.php index 06f0607b..f06c56e5 100755 --- a/application/models/mydir.php +++ b/application/models/mydir.php @@ -33,5 +33,43 @@ class mydir{ function getLast() { return $this->list[count($this->list)-1]; + } + + function array_flat($array) + { + foreach($array as $a) + { + if(is_array($a)) + { + $tmp = array_merge($tmp, $this->array_flat($a)); + }else { + $tmp[] = $a; + } + } + return $tmp; } + + function recursive($dir) + { + $files = array(); + if ($handle = opendir($dir)) + { + while (false !== ($file = readdir($handle))) + { + if ($file != "." && $file != "..") + { + if(is_dir($dir.'/'.$file)) + { + $dir2 = $dir.'/'.$file; + $files[]=$dir2.'/'; + $files[] = $this->recursive($dir2); + } else { + $files[] = $dir.'/'.$file; + } + } + } + closedir($handle); + } + return $this->array_flat($files); + } } \ No newline at end of file