示例#1
0
/**
 * Gets the actual download list included all subfolders and files
 * @param string $dir An optional different folder to generate the list that overrides the folder set on the option.
 * 										This could be a subfolder of the main download folder set on the plugin's options. You have to include the base directory as like this:
 * 										"folder" or "folder/subfolder" or "../folder"
 * 										You can also set any folder within or without the root of your Zenphoto installation as a download folder with this directly
 * @param string $listtype "ol" or "ul" for the type of HTML list you want to use
 * @param array $filters an array of files to exclude from the list. Standard items are '.', '..','.DS_Store','Thumbs.db','.htaccess','.svn'
 * @param array $excludesuffixes an array of file suffixes (without trailing dot to exclude from the list (e.g. "jpg")
 * @param string $sort 'asc" or "desc" (default) for alphabetical ascending or descending list
 * @return array
 */
function getdownloadList($dir, $filters, $excludesuffixes, $sort)
{
    if (empty($dir)) {
        $dir = getOption('downloadList_directory');
    }
    if (empty($excludesuffixes)) {
        $excludesuffixes = getOption('downloadList_excludesuffixes');
    }
    if (empty($excludesuffixes)) {
        $excludesuffixes = array();
    } elseif (!is_array($excludesuffixes)) {
        $excludesuffixes = explode(',', $excludesuffixes);
    }
    if ($sort == 'asc') {
        $direction = 0;
    } else {
        $direction = 1;
    }
    $dirs = array_diff(scandir($dir, $direction), array_merge(array('.', '..', '.DS_Store', 'Thumbs.db', '.htaccess', '.svn'), $filters));
    $dir_array = array();
    if ($sort == 'asc') {
        natsort($dirs);
    }
    foreach ($dirs as $file) {
        if (is_dir($dir . '/' . $file)) {
            $dir_array[$file] = getdownloadList($dir . "/" . $file, $filters, $excludesuffixes, $sort);
        } else {
            if (!in_array(getSuffix($file), $excludesuffixes)) {
                $dir_array[$file] = $dir . '/' . $file;
            }
        }
    }
    return $dir_array;
}
示例#2
0
/**
 * Gets the actual download list included all subfolders and files
 * @param string $dir8 An optional different folder to generate the list that overrides the folder set on the option.
 * 										This could be a subfolder of the main download folder set on the plugin's options. You have to include the base directory as like this:
 * 										"folder" or "folder/subfolder" or "../folder"
 * 										You can also set any folder within or without the root of your Zenphoto installation as a download folder with this directly
 * @param string $listtype "ol" or "ul" for the type of HTML list you want to use
 * @param array $filters8 an array of files to exclude from the list. Standard items are '.', '..','.DS_Store','Thumbs.db','.htaccess','.svn'
 * @param array $excludesuffixes an array of file suffixes (without trailing dot to exclude from the list (e.g. "jpg")
 * @param string $sort 'asc" or "desc" (default) for alphabetical ascending or descending list
 * @return array
 */
function getdownloadList($dir8, $filters8, $excludesuffixes, $sort)
{
    $filters = array('Thumbs.db');
    foreach ($filters8 as $key => $file) {
        $filters[$key] = internalToFilesystem($file);
    }
    if (empty($dir8)) {
        $dir = SERVERPATH . '/' . getOption('downloadList_directory');
    } else {
        if (substr($dir8, 0, 1) == '/' || strpos($dir8, ':') !== false) {
            $dir = internalToFilesystem($dir8);
        } else {
            $dir = SERVERPATH . '/' . internalToFilesystem($dir8);
        }
    }
    if (empty($excludesuffixes)) {
        $excludesuffixes = getOption('downloadList_excludesuffixes');
    }
    if (empty($excludesuffixes)) {
        $excludesuffixes = array();
    } elseif (!is_array($excludesuffixes)) {
        $excludesuffixes = explode(',', $excludesuffixes);
    }
    if ($sort == 'asc') {
        $direction = 0;
    } else {
        $direction = 1;
    }
    $dirs = array_diff(scandir($dir, $direction), $filters);
    $dir_array = array();
    if ($sort == 'asc') {
        natsort($dirs);
    }
    foreach ($dirs as $file) {
        if (@$file[0] != '.') {
            //	exclude "hidden" files
            if (is_dir(internalToFilesystem($dir) . '/' . $file)) {
                $dirN = filesystemToInternal($dir) . "/" . filesystemToInternal($file);
                $dir_array[$file] = getdownloadList($dirN, $filters8, $excludesuffixes, $sort);
            } else {
                if (!in_array(getSuffix($file), $excludesuffixes)) {
                    $dir_array[$file] = $dir . '/' . filesystemToInternal($file);
                }
            }
        }
    }
    return $dir_array;
}