Dokuwiki search and list all files under a directory

depth=1 will just show one level
depth=0 will show all levels under a namespace

        $pagearrays = array(); 
        $depth=0;
        search($pagearrays, $conf['datadir'], 'search_allpages', array('depth' => $depth), $dir);
        if (is_array($pagearrays)) {
 
                foreach ($pagearrays as $pagearray) {
                    if (!isHiddenPage($pagearray['id'])) {// skip hidden pages
                        $fname=$pagearray['id'];
                        $ID=$fname;
                        if(auth_quickaclcheck($ID) < AUTH_READ) {
                            continue; //skip the files without read permission
                        }else {
                            echo $fname;
                        }

                    }
                    
                    
                }
        }