mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-29 06:38:52 +00:00
[ticket/9627] Make use of 'static' since the function is called more than once
PHPBB3-9627
This commit is contained in:
parent
56b0268d1d
commit
18e5570851
1 changed files with 28 additions and 9 deletions
|
@ -447,30 +447,49 @@ function file_gc()
|
||||||
*/
|
*/
|
||||||
function http_byte_range($filesize)
|
function http_byte_range($filesize)
|
||||||
{
|
{
|
||||||
|
// The range request array;
|
||||||
|
// contains all requested ranges.
|
||||||
|
static $request_array;
|
||||||
|
|
||||||
if (!$filesize)
|
if (!$filesize)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (array($_SERVER, $_ENV) as $global)
|
if (!isset($request_array))
|
||||||
{
|
{
|
||||||
if (isset($global['HTTP_RANGE']))
|
$request_array = false;
|
||||||
|
|
||||||
|
$globals = array(
|
||||||
|
array('_SERVER', 'HTTP_RANGE'),
|
||||||
|
array('_ENV', 'HTTP_RANGE'),
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($globals as $array)
|
||||||
{
|
{
|
||||||
$http_range = $global['HTTP_RANGE'];
|
$global = $array[0];
|
||||||
break;
|
$key = $array[1];
|
||||||
|
|
||||||
|
// Make sure range request starts with "bytes="
|
||||||
|
if (isset($GLOBALS[$global][$key]) && strpos($GLOBALS[$global][$key], 'bytes=') === 0)
|
||||||
|
{
|
||||||
|
// Strip leading 'bytes='
|
||||||
|
// Multiple ranges can be separated by a comma
|
||||||
|
$request_array = explode(',', substr($GLOBALS[$global][$key], 6));
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return if no range requested
|
// Return if no range requested
|
||||||
// Make sure range request starts with "bytes="
|
if (empty($request_array))
|
||||||
if (empty($http_range) || strpos($http_range, 'bytes=') !== 0)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strip leading 'bytes='
|
// Go through all ranges
|
||||||
// Multiple ranges can be separated by a comma
|
foreach ($request_array as $range_string)
|
||||||
foreach (explode(',', substr($http_range, 6)) as $range_string)
|
|
||||||
{
|
{
|
||||||
$range = explode('-', trim($range_string));
|
$range = explode('-', trim($range_string));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue