- $urlhash = 'pic:' . sha1($_REQUEST['url']);
- // Double encoded url - happens with Diaspora
- $urlhash2 = 'pic:' . sha1(urldecode($_REQUEST['url']));
-
- $cachefile = get_cachefile(hash("md5", $_REQUEST['url']));
- if ($cachefile != '') {
- if (file_exists($cachefile)) {
- $img_str = file_get_contents($cachefile);
- $mime = image_type_to_mime_type(exif_imagetype($cachefile));
-
- header("Content-type: $mime");
- header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
- header('Etag: "'.md5($img_str).'"');
- header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT");
- header("Cache-Control: max-age=31536000");
-
- // reduce quality - if it isn't a GIF
- if ($mime != "image/gif") {
- $img = new Photo($img_str, $mime);
- if($img->is_valid())
- $img_str = $img->imageString();
+ if (!$direct_cache) {
+ $urlhash = 'pic:' . sha1($_REQUEST['url']);
+ // Double encoded url - happens with Diaspora
+ $urlhash2 = 'pic:' . sha1(urldecode($_REQUEST['url']));
+
+ $cachefile = get_cachefile(hash("md5", $_REQUEST['url']));
+ if ($cachefile != '') {
+ if (file_exists($cachefile)) {
+ $img_str = file_get_contents($cachefile);
+ $mime = image_type_to_mime_type(exif_imagetype($cachefile));
+
+ header("Content-type: $mime");
+ header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
+ header('Etag: "'.md5($img_str).'"');
+ header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT");
+ header("Cache-Control: max-age=31536000");
+
+ // reduce quality - if it isn't a GIF
+ if ($mime != "image/gif") {
+ $img = new Photo($img_str, $mime);
+ if($img->is_valid()) {
+ $img_str = $img->imageString();
+ }
+ }
+
+ echo $img_str;
+ killme();