mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/15276] Use storage to download avatar
PHPBB3-15276
This commit is contained in:
parent
286b1bbe33
commit
4c5114c14d
1 changed files with 7 additions and 12 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue