]> git.wh0rd.org - tt-rss.git/commitdiff
af_zz_imgproxy: use inline disposition, misc updates
authorAndrew Dolgov <noreply@madoka.volgo-balt.ru>
Fri, 10 Feb 2017 09:37:21 +0000 (12:37 +0300)
committerAndrew Dolgov <noreply@madoka.volgo-balt.ru>
Fri, 10 Feb 2017 09:37:21 +0000 (12:37 +0300)
classes/handler/public.php
plugins/af_zz_imgproxy/init.php

index 459a535a40cf880b776f11e4cc59ef3e4fff7fdb..c7c86d4638bde8cab6c8e03852de9d717af4d41c 100644 (file)
@@ -1054,7 +1054,8 @@ class Handler_Public extends Handler {
                        $filename = CACHE_DIR . '/images/' . $hash;
 
                        if (file_exists($filename)) {
-                               header("Content-Disposition: attachment; filename=\"$hash\"");
+                               header("Content-Disposition: inline; filename=\"$hash\"");
+                               $mimetype = mime_content_type($filename);
 
                                /* See if we can use X-Sendfile */
                                $xsendfile = false;
@@ -1064,10 +1065,10 @@ class Handler_Public extends Handler {
 
                                if ($xsendfile) {
                                        header("X-Sendfile: $filename");
-                                       header("Content-type: application/octet-stream");
-                                       header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
+                                       header("Content-type: $mimetype");
+                                       header('Content-Disposition: inline; filename="' . basename($filename) . '"');
                                } else {
-                                       header("Content-type: image/png");
+                                       header("Content-type: $mimetype");
                                        $stamp = gmdate("D, d M Y H:i:s", filemtime($filename)). " GMT";
                                        header("Last-Modified: $stamp", true);
                                        readfile($filename);
index df8f34dbe2c8c27bf4df343671bc1b75202e24ed..bbeb8e8d427119de11868322f023035dab350a8d 100644 (file)
@@ -35,16 +35,26 @@ class Af_Zz_ImgProxy extends Plugin {
                $extension = $kind == 1 ? '.mp4' : '.png';
                $local_filename = CACHE_DIR . "/images/" . sha1($url) . $extension;
 
-               if ($_REQUEST["debug"] == "1") { print $local_filename; die; }
+               //if ($_REQUEST["debug"] == "1") { print $local_filename; die; }
 
-               header("Content-Disposition: attachment; filename=\"".basename($local_filename)."\"");
+               header("Content-Disposition: inline; filename=\"".basename($local_filename)."\"");
 
                if (file_exists($local_filename)) {
+                       $mimetype = mime_content_type($local_filename);
+                       header("Content-type: $mimetype");
+
+                       $stamp = gmdate("D, d M Y H:i:s", filemtime($local_filename)). " GMT";
+                       header("Last-Modified: $stamp", true);
+
                        readfile($local_filename);
                } else {
                        $data = fetch_file_contents(array("url" => $url));
                        if ($data) {
-                               file_put_contents($local_filename, $data);
+                               if (file_put_contents($local_filename, $data)) {
+                                       $mimetype = mime_content_type($local_filename);
+                                       header("Content-type: $mimetype");
+                               }
+
                                print $data;
                        }
                }