function GetDirArrayRecursive($dir, $filter = false)
{
    global $Amedia_types, $Ahide_files, $Ahide_folders, $Akeywords;
    if ($filter) {
        $Afilter = $filter;
    } else {
        $Afilter = $Amedia_types;
    }
    $Afiles = array();
    if (!$dir || $dir == "") {
        $dir = ".";
    }
    $handle = @opendir($dir);
    if ($dir) {
        if (is_dir($dir)) {
            while (false !== ($entry = @readdir($handle))) {
                if ($entry != '.' && $entry != '..') {
                    $entry = $dir . '/' . str_replace("\\", "/", $entry);
                    $pathinfo = path_parts($entry);
                    if (is_dir($entry)) {
                        if (!checkKeyWords($Ahide_folders, $pathinfo['filename']) && !checkKeyWords($Akeywords, $pathinfo['filename'])) {
                            $Afiles = array_merge($Afiles, GetDirArrayRecursive($entry, $Afilter));
                        }
                    } else {
                        if (in_array(strtolower($pathinfo['ext']), $Afilter)) {
                            if (!checkKeyWords($Ahide_files, $pathinfo['filename']) && !checkKeyWords($Akeywords, $pathinfo['filename'])) {
                                $Afiles[] = $entry;
                            }
                        }
                    }
                }
            }
        }
    }
    @closedir($handle);
    return $Afiles;
}
Пример #2
0
function GetDirArray($dir)
{
    global $Amedia_types, $Ahide_files, $Ahide_folders, $Akeywords;
    $Asee = array();
    $Aitems = array();
    $Adirs = array();
    $Afiles = array();
    $handle = @opendir($dir);
    //$d = dir(utf8_encode($dir));
    if ($dir) {
        while (false !== ($entry = @readdir($handle))) {
            //while (false !== ($entry = $d->read())) {
            if ($entry != '.' && $entry != '..' && substr($entry, 0, 1) != "..") {
                $entry = $dir . '/' . str_replace("\\", "/", $entry);
                $pathinfo = path_parts($entry);
                if (is_dir($entry)) {
                    if (!checkKeyWords($Ahide_folders, $pathinfo['filename']) && !checkKeyWords($Akeywords, $pathinfo['filename'])) {
                        $Adirs[] = $entry;
                    }
                } else {
                    if (in_array(strtolower($pathinfo['ext']), $Amedia_types)) {
                        if (!checkKeyWords($Ahide_files, $pathinfo['filename']) && !checkKeyWords($Akeywords, $pathinfo['filename'])) {
                            $Afiles[] = $entry;
                        }
                    }
                }
            }
        }
        @closedir($handle);
        //$d->close();
    }
    $Aitems['dirs'] = $Adirs;
    $Aitems['files'] = $Afiles;
    return $Aitems;
}