mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00: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:
commit
72ce0ec309
1 changed files with 2 additions and 24 deletions
|
@ -248,30 +248,8 @@ function send_file_to_browser($attachment, $category)
|
||||||
|
|
||||||
if ($fp !== false)
|
if ($fp !== false)
|
||||||
{
|
{
|
||||||
// Deliver file partially if requested
|
$output = fopen('php://output', 'w+b');
|
||||||
if ($range = phpbb_http_byte_range($size))
|
stream_copy_to_stream($fp, $output);
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue