示例#1
0
 function runfolder($dir, $f = 1, $d = 0, $sub = false, $exts = false, &$filelist = array(), $pre = '')
 {
     if (is_dir($dir) && ($dh = opendir($dir))) {
         while (($file = readdir($dh)) !== false) {
             if ($file[0] == '.') {
                 continue;
             }
             if ($file == 'vendor') {
                 continue;
             }
             if ($file[0] == '~') {
                 continue;
             }
             $path = $dir . $file;
             if (is_file($path) && $exts) {
                 preg_match('/\\.(\\w{0,4})$/', $file, $math);
                 //Расширение при поиске не учитываем
                 $ext = strtolower($math[1]);
                 if (!in_array($ext, $exts)) {
                     continue;
                 }
             }
             //$count++;
             //if($count<$lims)continue;
             //if($count>=($lims+$limc))break;
             if (!$f && is_file($path) && (!$d || !is_dir($path))) {
                 continue;
             }
             //Файлы не надо
             //if(!$f && is_file($path))continue;//Файлы не надо
             if (is_dir($path)) {
                 if ($sub) {
                     runfolder($path . '/', $f, $d, $sub, $exts, $filelist, $pre . $file . '/');
                 }
                 if (!$d) {
                     continue;
                 }
                 //Папки не надо
             }
             if ($d && preg_match("/\\.files\$/", $file)) {
                 continue;
             }
             //$weblife->modified(false,$path);
             array_push($filelist, $pre . $file);
         }
         closedir($dh);
     }
     return $filelist;
 }
示例#2
0
文件: list.php 项目: akiyatkin/pages
 function runfolder($dir, $hidden, $sub, $f, $d, &$filelist = array(), $pre = '')
 {
     if (is_dir($dir) && ($dh = opendir($dir))) {
         while (($file = readdir($dh)) !== false) {
             if (!$hidden && $file[0] == '.') {
                 continue;
             }
             if ($file[0] == '~') {
                 continue;
             }
             if ($file == 'Thumbs.db') {
                 continue;
             }
             //$count++;
             //if($count<$lims)continue;
             //if($count>=($lims+$limc))break;
             $path = $dir . $file;
             if (!$f && is_file($path) && (!$d || !is_dir($path))) {
                 continue;
             }
             //Файлы не надо
             if (is_dir($path)) {
                 if ($sub) {
                     runfolder($path . '/', $hidden, $sub, $f, $d, $filelist, $pre . infra_toutf($file) . '/');
                 }
                 if (!$d) {
                     continue;
                 }
                 //Папки не надо
             }
             if ($d && preg_match("/\\.files\$/", $file)) {
                 continue;
             }
             //$weblife->modified(false,$path);
             $file = infra_toutf($file);
             array_push($filelist, $pre . $file);
         }
         closedir($dh);
     }
     return $filelist;
 }