From 163b50b15f3b163a392327692aede68e31a6204e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 16 Aug 2018 11:56:51 +0300 Subject: cache_media: only show downloading debug message when actually downloading --- classes/rssutils.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/rssutils.php b/classes/rssutils.php index bd20a6b48..554d89f5a 100755 --- a/classes/rssutils.php +++ b/classes/rssutils.php @@ -1239,9 +1239,11 @@ class RSSUtils { $local_filename = CACHE_DIR . "/images/" . sha1($src); - if ($debug) _debug("cache_media: downloading: $src to $local_filename"); + if ($debug) _debug("cache_media: checking $src"); if (!file_exists($local_filename)) { + if ($debug) _debug("cache_media: downloading: $src to $local_filename"); + $file_content = fetch_file_contents($src); if ($file_content && strlen($file_content) > MIN_CACHE_FILE_SIZE) { -- cgit v1.2.3-54-g00ecf From 88adf3da1b8ed0ecc3bb17d34d2322e344cb06a6 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 16 Aug 2018 12:16:51 +0300 Subject: send_local_file: add application/octet-stream hack cached_url: return original requested filename to save as --- classes/handler/public.php | 6 +++--- include/functions.php | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) mode change 100644 => 100755 classes/handler/public.php (limited to 'classes') diff --git a/classes/handler/public.php b/classes/handler/public.php old mode 100644 new mode 100755 index 8440bc355..e892a9797 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -934,17 +934,17 @@ class Handler_Public extends Handler { } function cached_url() { - @$hash = basename($_GET['hash']); + @$req_filename = basename($_GET['hash']); // we don't need an extension to find the file, hash is a complete URL - $hash = preg_replace("/\.[^\.]*$/", "", $hash); + $hash = preg_replace("/\.[^\.]*$/", "", $req_filename); if ($hash) { $filename = CACHE_DIR . '/images/' . $hash; if (file_exists($filename)) { - header("Content-Disposition: inline; filename=\"$hash\""); + header("Content-Disposition: inline; filename=\"$req_filename\""); send_local_file($filename); diff --git a/include/functions.php b/include/functions.php index 7ebbe38b3..b6e49716c 100755 --- a/include/functions.php +++ b/include/functions.php @@ -2574,6 +2574,13 @@ } $mimetype = mime_content_type($filename); + + // this is hardly ideal but 1) only media is cached in images/ and 2) seemingly only mp4 + // video files are detected as octet-stream by mime_content_type() + + if ($mimetype == "application/octet-stream") + $mimetype = "video/mp4"; + header("Content-type: $mimetype"); $stamp = gmdate("D, d M Y H:i:s", filemtime($filename)) . " GMT"; -- cgit v1.2.3-54-g00ecf