Example #1
0
    // Allow only 1x and 2x sizes, in order to avoid hack that creates many x versions
    $size_x = 1;
}
// TODO: dh> this failed with filenames containing multiple dots!
if (false !== strpos(urldecode($path), '..')) {
    debug_die('Relative pathnames not allowed!');
}
// Load fileroot info:
$FileRootCache =& get_FileRootCache();
$FileRoot =& $FileRootCache->get_by_ID($root);
// Load file object (not the file content):
$File = new File($FileRoot->type, $FileRoot->in_type_ID, $path);
// Check if the request has an If-Modified-Since date
if (array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) {
    $if_modified_since = strtotime(preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']));
    $file_lastmode_ts = $File->get_lastmod_ts();
    if ($file_lastmode_ts <= $if_modified_since) {
        // file was not modified since if_modified_since ts
        header_http_response('304 Not Modified');
        exit(0);
    }
}
if (!empty($size) && $File->is_image()) {
    // We want a thumbnail:
    // fp> TODO: for more efficient caching, this should probably redirect to the static file right after creating it (when $public_access_to_media=true OF COURSE)
    global $thumbnail_sizes;
    load_funcs('/files/model/_image.funcs.php');
    $size_name = $size;
    if (!isset($thumbnail_sizes[$size])) {
        // this file size alias is not defined, use default:
        // TODO: dh> this causes links for e.g. "fit-50x50" to work also, but with the drawback of images not getting served from the