00001 <?php
00035 function fileList($directory_, $type_ = 'ALL', $recursive_ = true, $sort_ = true)
00036 {
00037
00038
00039
00040 $directory_ = rtrim($directory_, '/') . '/';
00041 $type_ = strtoupper($type_);
00042
00043 $result = array();
00044 if(is_dir($directory_))
00045 {
00046 $thisDir = dir($directory_);
00047
00048 while(!empty($thisDir) && $entry = $thisDir->read())
00049 {
00050 if (($entry != '.') && ($entry != '..'))
00051 {
00052 $path = $directory_.$entry;
00053 if (is_file($path) && ($type_ == 'ALL' || $type_ == 'FILE'))
00054 {
00055 $result[] = $path;
00056 }
00057 elseif (is_dir($path))
00058 {
00059 if (($type_ == 'ALL' || $type_ == 'DIR'))
00060 {
00061 $result[] = $path;
00062 }
00063
00064 if ($recursive_)
00065 {
00066 $result = array_merge($result, fileList($path, $type_, true, false));
00067 }
00068 }
00069 }
00070 }
00071 }
00072
00073 if (!empty($result) && $sort_)
00074 {
00075 asort($result);
00076 }
00077
00078 return $result;
00079 }
00080
00081 ?>