summaryrefslogtreecommitdiff
path: root/classes/handler/public.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/handler/public.php')
-rwxr-xr-xclasses/handler/public.php27
1 files changed, 12 insertions, 15 deletions
diff --git a/classes/handler/public.php b/classes/handler/public.php
index 27e984be9..901844e36 100755
--- a/classes/handler/public.php
+++ b/classes/handler/public.php
@@ -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 ($hash) {
-
- $filename = CACHE_DIR . '/images/' . $hash;
-
- if (file_exists($filename)) {
- header("Content-Disposition: inline; filename=\"$req_filename\"");
+ if (strpos($filename, "/") !== FALSE) {
+ list ($cache_dir, $filename) = explode("/", $filename, 2);
+ } else {
+ $cache_dir = "images";
+ }
- send_local_file($filename);
+ $cache = new DiskCache($cache_dir);
- } 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.";
}
}