mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 01:46:00 +00:00
* HOOK_ENCLOSURE_ENTRY: pass article_id to handler
* DiskCache: multiple fixes; support isWritable() for cache entries, set content-disposition for send() * public/cached_url: allow selecting files from sub-caches other than images * plugins/Cache_Starred_Images: rework to use DiskCache, can be enabled per-user, properly handles article enclosures, etc
This commit is contained in:
@@ -1202,24 +1202,21 @@ class Handler_Public extends Handler {
|
||||
}
|
||||
|
||||
function cached_url() {
|
||||
@$req_filename = basename($_GET['file']);
|
||||
$filename = $_GET['file'];
|
||||
|
||||
// we don't need an extension to find the file, hash is a complete URL
|
||||
$hash = preg_replace("/\.[^\.]*$/", "", $req_filename);
|
||||
if (strpos($filename, "/") !== FALSE) {
|
||||
list ($cache_dir, $filename) = explode("/", $filename, 2);
|
||||
} else {
|
||||
$cache_dir = "images";
|
||||
}
|
||||
|
||||
if ($hash) {
|
||||
$cache = new DiskCache($cache_dir);
|
||||
|
||||
$filename = CACHE_DIR . '/images/' . $hash;
|
||||
|
||||
if (file_exists($filename)) {
|
||||
header("Content-Disposition: inline; filename=\"$req_filename\"");
|
||||
|
||||
send_local_file($filename);
|
||||
|
||||
} else {
|
||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
||||
echo "File not found.";
|
||||
}
|
||||
if ($cache->exists($filename)) {
|
||||
$cache->send($filename);
|
||||
} else {
|
||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
||||
echo "File not found.";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user