summaryrefslogtreecommitdiff
path: root/image.php
diff options
context:
space:
mode:
authorRichard Beales <[email protected]>2013-03-19 18:19:07 +0000
committerRichard Beales <[email protected]>2013-03-19 18:19:07 +0000
commit05809dfdf7cbf7699be6408c0f49d325585726b5 (patch)
treebfa33dcd1cf8707e65a05df98d27d563396520d2 /image.php
parent1d707e9f03d1a654e0807aadce7ab790befd0b95 (diff)
parent2229e6ed6b07d4a28b04689a21c645bdb83652f7 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'image.php')
-rw-r--r--image.php35
1 files changed, 28 insertions, 7 deletions
diff --git a/image.php b/image.php
index 91490ea22..cccda64b7 100644
--- a/image.php
+++ b/image.php
@@ -4,14 +4,35 @@
require_once "config.php";
- $url = base64_decode($_GET['url']);
+ // backwards compatible wrapper for old-style image caching
+ /* if (isset($_GET['url'])) {
+ $url = base64_decode($_GET['url']);
- $filename = CACHE_DIR . '/images/' . sha1($url) . '.png';
+ $filename = CACHE_DIR . '/images/' . sha1($url) . '.png';
- if (file_exists($filename)) {
- header("Content-type: image/png");
- echo file_get_contents($filename);
- } else {
- header("Location: $url");
+ if (file_exists($filename)) {
+ header("Content-type: image/png");
+ echo file_get_contents($filename);
+ } else {
+ header("Location: $url");
+ }
+
+ return;
+ } */
+
+ @$hash = basename($_GET['hash']);
+
+ if ($hash) {
+
+ $filename = CACHE_DIR . '/images/' . $hash . '.png';
+
+ if (file_exists($filename)) {
+ header("Content-type: image/png");
+ echo file_get_contents($filename);
+ } else {
+ header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
+ echo "File not found.";
+ }
}
+
?>