From 4c5114c14d4c7880740f9cbefaf5ef917ac2194f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Fri, 28 Jul 2017 14:36:03 +0200 Subject: [PATCH] [ticket/15276] Use storage to download avatar PHPBB3-15276 --- phpBB/includes/functions_download.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/phpBB/includes/functions_download.php b/phpBB/includes/functions_download.php index cee7c39035..55bed7ea79 100644 --- a/phpBB/includes/functions_download.php +++ b/phpBB/includes/functions_download.php @@ -25,7 +25,9 @@ if (!defined('IN_PHPBB')) */ function send_avatar_to_browser($file, $browser) { - global $config, $phpbb_root_path; + global $config, $phpbb_container; + + $storage = $phpbb_container->get('storage.avatar'); $prefix = $config['avatar_salt'] . '_'; $image_dir = $config['avatar_path']; @@ -41,15 +43,12 @@ function send_avatar_to_browser($file, $browser) { $image_dir = ''; } - $file_path = $phpbb_root_path . $image_dir . '/' . $prefix . $file; + $file_path = $image_dir . '/' . $prefix . $file; - if ((@file_exists($file_path) && @is_readable($file_path)) && !headers_sent()) + if ($storage->exists($file_path) && !headers_sent()) { header('Cache-Control: public'); - $image_data = @getimagesize($file_path); - header('Content-Type: ' . image_type_to_mime_type($image_data[2])); - if ((strpos(strtolower($browser), 'msie') !== false) && !phpbb_is_greater_ie_version($browser, 7)) { header('Content-Disposition: attachment; ' . header_filename($file)); @@ -69,12 +68,6 @@ function send_avatar_to_browser($file, $browser) header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); } - $size = @filesize($file_path); - if ($size) - { - header("Content-Length: $size"); - } - if (@readfile($file_path) == false) { $fp = @fopen($file_path, 'rb'); @@ -89,6 +82,8 @@ function send_avatar_to_browser($file, $browser) } } + echo $storage->get_contents($file_path); + flush(); } else