]>
Commit | Line | Data |
---|---|---|
236ac05c | 1 | <?php |
88e8fb3a AD |
2 | set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
3 | get_include_path()); | |
107d0cf3 | 4 | |
bc0f0785 | 5 | require_once "config.php"; |
236ac05c | 6 | |
f0bd8e65 AD |
7 | // backwards compatible wrapper for old-style image caching |
8 | /* if (isset($_GET['url'])) { | |
9 | $url = base64_decode($_GET['url']); | |
487f0750 | 10 | |
f0bd8e65 | 11 | $filename = CACHE_DIR . '/images/' . sha1($url) . '.png'; |
3c696512 | 12 | |
f0bd8e65 AD |
13 | if (file_exists($filename)) { |
14 | header("Content-type: image/png"); | |
15 | echo file_get_contents($filename); | |
16 | } else { | |
17 | header("Location: $url"); | |
18 | } | |
19 | ||
20 | return; | |
21 | } */ | |
22 | ||
23 | @$hash = basename($_GET['hash']); | |
24 | ||
25 | if ($hash) { | |
26 | ||
27 | $filename = CACHE_DIR . '/images/' . $hash . '.png'; | |
28 | ||
29 | if (file_exists($filename)) { | |
2d0838e6 MF |
30 | /* See if we can use X-Sendfile */ |
31 | $xsendfile = false; | |
32 | if (function_exists('apache_get_modules') && | |
33 | array_search('mod_xsendfile', apache_get_modules())) | |
34 | $xsendfile = true; | |
35 | ||
36 | if ($xsendfile) { | |
37 | header("X-Sendfile: $filename"); | |
38 | header("Content-type: application/octet-stream"); | |
39 | header('Content-Disposition: attachment; filename="' . basename($filename) . '"'); | |
40 | } else { | |
41 | header("Content-type: image/png"); | |
42 | $stamp = gmdate("D, d M Y H:i:s", filemtime($filename)). " GMT"; | |
43 | header("Last-Modified: $stamp", true); | |
c26b93ab MS |
44 | ob_clean(); // discard any data in the output buffer (if possible) |
45 | flush(); // flush headers (if possible) | |
2d0838e6 MF |
46 | readfile($filename); |
47 | } | |
f0bd8e65 AD |
48 | } else { |
49 | header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); | |
50 | echo "File not found."; | |
51 | } | |
3c696512 | 52 | } |
f0bd8e65 | 53 | |
236ac05c | 54 | ?> |