1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-03-25 18:13:28 +01:00

Merge pull request #5271 from rubencm/ticket/15286-2

[ticket/15286] Download remote attachments properly

* github.com:/phpbb/phpbb:
  [ticket/15286] Download remote attachments properly
This commit is contained in:
Tristan Darricau 2018-07-08 18:58:08 +02:00
commit 72ce0ec309

View File

@ -248,30 +248,8 @@ function send_file_to_browser($attachment, $category)
if ($fp !== false)
{
// Deliver file partially if requested
if ($range = phpbb_http_byte_range($size))
{
fseek($fp, $range['byte_pos_start']);
send_status_line(206, 'Partial Content');
header('Content-Range: bytes ' . $range['byte_pos_start'] . '-' . $range['byte_pos_end'] . '/' . $range['bytes_total']);
header('Content-Length: ' . $range['bytes_requested']);
// First read chunks
while (!feof($fp) && ftell($fp) < $range['byte_pos_end'] - 8192)
{
echo fread($fp, 8192);
}
// Then, read the remainder
echo fread($fp, $range['bytes_requested'] % 8192);
}
else
{
while (!feof($fp))
{
echo fread($fp, 8192);
}
}
$output = fopen('php://output', 'w+b');
stream_copy_to_stream($fp, $output);
fclose($fp);
}