Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Returns an array containing sub-directories which are potentially
- * a category.
- * Directories named ".svn", "thumbnail", "pwg_high" or "pwg_representative"
- * are omitted.
- * Directories are sorted by mtime.
- *
- * @param string $basedir (eg: ./galleries)
- * @return string[]
- */
- function get_fs_directories($path, $recursive = true)
- {
- global $conf;
- $lsdir = array();
- $dirs = array();
- $path = rtrim($path, '/');
- $exclude_folders = array_merge(
- $conf['sync_exclude_folders'],
- array(
- '.', '..', '.svn',
- 'thumbnail', 'pwg_high',
- 'pwg_representative',
- )
- );
- $exclude_folders = array_flip($exclude_folders);
- if (is_dir($path))
- {
- $lsdir = glob("$path/{,.}*", GLOB_ONLYDIR | GLOB_BRACE);
- usort($lsdir, function($a, $b) {
- return filemtime($a) > filemtime($b);
- });
- foreach ($lsdir as $i => $node)
- {
- if (!isset($exclude_folders[preg_replace("/.*\//", '', $node)]))
- {
- $dirs[] = $node;
- if ($recursive)
- {
- $dirs = array_merge($dirs, get_fs_directories($node));
- }
- }
- }
- }
- return $dirs;
- }
Advertisement
Add Comment
Please, Sign In to add comment