예제 #1
0
파일: functions.php 프로젝트: jbyers/scry
function directory_data($path, $url_path)
{
    global $CFG_image_valid, $CFG_url_album, $CFG_thumb_width, $CFG_thumb_height, $CFG_image_width, $CFG_image_height, $CFG_path_images, $CFG_cache_outside_docroot;
    // put CFG_image_valid array into eregi form
    //
    $valid_extensions = '(.' . implode('|.', $CFG_image_valid) . ')$';
    path_security_check($path, $CFG_path_images);
    // load raw directory first, sort, and reprocess
    //
    $files_raw = array();
    $dirs_raw = array();
    if ($h_dir = opendir($path)) {
        // FS READ
        while (false !== ($filename = readdir($h_dir))) {
            // FS READ
            if ($filename != '.' && $filename != '..') {
                // set complete url
                //
                if ($url_path == '') {
                    $url = $filename;
                } else {
                    $url = "{$url_path}/{$filename}";
                }
                path_security_check("{$path}/{$filename}", $CFG_path_images);
                if (is_readable("{$path}/{$filename}") && is_file("{$path}/{$filename}") && eregi($valid_extensions, $filename)) {
                    $files_raw[] = array('name' => $filename, 'url' => $url);
                } else {
                    if (is_readable("{$path}/{$filename}") && is_dir("{$path}/{$filename}") && substr($filename, 0, 1) != '_') {
                        // FS READ
                        $dirs_raw[] = array('name' => $filename, 'url' => $url);
                    }
                }
                // if ... else is_file or is_dir
            }
            // if
        }
        // while
        closedir($h_dir);
        // FS READ
    }
    // if opendir
    // sort directory arrays by filename
    //
    function cmp($a, $b)
    {
        return strcasecmp($a['name'], $b['name']);
    }
    // function cmp
    @usort($dirs_raw, 'cmp');
    @usort($files_raw, 'cmp');
    // reprocess arrays
    //
    $files = array();
    $dirs = array();
    $file_count = 0;
    $dir_count = 0;
    while (list($k, $v) = each($files_raw)) {
        // set thumbnail cached vs. not
        //
        $thumb = cache_test($v['url'], $CFG_thumb_width, $CFG_thumb_height);
        // FS FUNCTION
        $image = cache_test($v['url'], $CFG_view_width, $CFG_view_height);
        // FS FUNCTION
        if ($CFG_cache_outside_docroot || !$thumb['is_cached']) {
            $thumb_url = build_url('image', $CFG_thumb_width . 'x' . $CFG_thumb_height, $v['url']);
        } else {
            $thumb_url = $thumb['cache_url'];
        }
        if ($CFG_cache_outside_docroot || !$image['is_cached']) {
            $image_url = build_url('image', $CFG_image_width . 'x' . $CFG_image_height, $v['url']);
        } else {
            $image_url = $image['cache_url'];
        }
        path_security_check("{$path}/{$v['name']}", $CFG_path_images);
        $files[] = array('name' => $v['name'], 'index' => $file_count, 'path' => "{$path}/{$v['name']}", 'thumb_url' => $thumb_url, 'image_url' => $image_url, 'view_url' => build_url('view', $file_count, $v['url']), 'raw_url' => build_url('image', '0', $v['url']));
        // 0 index for raw image
        $file_count++;
    }
    while (list($k, $v) = each($dirs_raw)) {
        $dirs[] = array('name' => $v['name'], 'index' => $dir_count, 'list_url' => build_url('list', '0', $v['url']));
        $dir_count++;
    }
    return array('files' => $files, 'directories' => $dirs);
}
예제 #2
0
파일: index.php 프로젝트: jbyers/scry
    $PATH_BASEDIR = "{$CFG_path_images}/{$IMAGE_DIR}";
} else {
    if ($IMAGE_FILE == '' && $IMAGE_DIR != '') {
        $PATH = "{$CFG_path_images}/{$IMAGE_DIR}";
        $PATH_BASEDIR = "{$CFG_path_images}/{$IMAGE_DIR}";
    } else {
        if ($IMAGE_FILE != '') {
            $PATH = "{$CFG_path_images}/{$IMAGE_FILE}";
            $PATH_BASEDIR = $CFG_path_images;
        } else {
            $PATH = $CFG_path_images;
            $PATH_BASEDIR = $CFG_path_images;
        }
    }
}
path_security_check($PATH, $CFG_path_images);
if (!is_readable($PATH)) {
    // FS READ
    die("{$PATH} does not exist or is not readable by the webserver - please verify settings in setup.php");
} else {
    if (($VIEW == 'image' || $VIEW == 'view') && !is_file($PATH)) {
        // FS READ
        die("{$PATH} is not a valid image file or cannot be read");
    } else {
        if ($VIEW == 'list' && !is_dir($PATH)) {
            // FS READ
            die("{$PATH} is not a directory or cannot be read");
        }
    }
}
//////////////////////////////////////////////////////////////////////////////