Exemplo n.º 1
0
Arquivo: feed.php Projeto: rair/yacs
        $text = @$result[1];
        // save in cache for the next request
        Cache::put($cache_id, $text, 'articles');
    }
    //
    // transfer to the user agent
    //
    // handle the output correctly
    render_raw('text/xml; charset=' . $context['charset']);
    // suggest a name on download
    if (!headers_sent()) {
        $file_name = utf8::to_ascii($context['site_name'] . '.section.' . $item['id'] . '.rss.xml');
        Safe::header('Content-Disposition: inline; filename="' . str_replace('"', '', $file_name) . '"');
    }
    // enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download
    http::expire(1800);
    // strong validator
    $etag = '"' . md5($text) . '"';
    // manage web cache
    if (http::validate(NULL, $etag)) {
        return;
    }
    // actual transmission except on a HEAD request
    if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
        echo $text;
    }
    // the post-processing hook, then exit
    finalize_page(TRUE);
}
// render the skin
render_skin();
Exemplo n.º 2
0
Arquivo: fetch.php Projeto: rair/yacs
             Safe::header('Content-Length: ' . $length);
             // actual transmission except on a HEAD request
             if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
                 fseek($handle, $offset);
                 $slice = fread($handle, $length);
                 echo $slice;
             }
             fclose($handle);
             // regular download
         } else {
             // file size
             Safe::header('Content-Length: ' . $stat['size']);
             // weak validator
             $last_modified = gmdate('D, d M Y H:i:s', $stat['mtime']) . ' GMT';
             // validate content in cache
             if (http::validate($last_modified)) {
                 return;
             }
             // actual transmission except on a HEAD request
             if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
                 fpassthru($handle);
             }
             fclose($handle);
         }
         // the post-processing hook, then exit even on HEAD
         finalize_page();
         return;
     }
     // redirect to the actual file
     $target_href = $context['url_to_home'] . $context['url_to_root'] . Files::get_path($item['anchor']) . '/' . rawurlencode($item['file_name']);
 }