fixed bytes conversion when used on 32-bits systems
This commit is contained in:
parent
a010ed4721
commit
b3ae29d4f8
@ -23,20 +23,29 @@ class ServerParams
|
||||
*/
|
||||
public function getPostMaxSize()
|
||||
{
|
||||
$iniMax = $this->getNormalizedIniPostMaxSize();
|
||||
$iniMax = strtolower($this->getNormalizedIniPostMaxSize());
|
||||
|
||||
if ('' === $iniMax) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (preg_match('#^\+?(0X?)?(.*?)([KMG]?)$#', $iniMax, $match)) {
|
||||
$shifts = array('' => 0, 'K' => 10, 'M' => 20, 'G' => 30);
|
||||
$bases = array('' => 10, '0' => 8, '0X' => 16);
|
||||
|
||||
return intval($match[2], $bases[$match[1]]) << $shifts[$match[3]];
|
||||
$max = ltrim($iniMax, '+');
|
||||
if (0 === strpos($max, '0x')) {
|
||||
$max = intval($max, 16);
|
||||
} elseif (0 === strpos($max, '0')) {
|
||||
$max = intval($max, 8);
|
||||
} else {
|
||||
$max = intval($max);
|
||||
}
|
||||
|
||||
return 0;
|
||||
switch (substr($iniMax, -1)) {
|
||||
case 't': $max *= 1024;
|
||||
case 'g': $max *= 1024;
|
||||
case 'm': $max *= 1024;
|
||||
case 'k': $max *= 1024;
|
||||
}
|
||||
|
||||
return $max;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -262,20 +262,29 @@ class UploadedFile extends File
|
||||
*/
|
||||
public static function getMaxFilesize()
|
||||
{
|
||||
$max = strtolower(ini_get('upload_max_filesize'));
|
||||
$iniMax = strtolower(ini_get('upload_max_filesize'));
|
||||
|
||||
if ('' === $max) {
|
||||
if ('' === $iniMax) {
|
||||
return PHP_INT_MAX;
|
||||
}
|
||||
|
||||
if (preg_match('#^\+?(0x?)?(.*?)([kmg]?)$#', $max, $match)) {
|
||||
$shifts = array('' => 0, 'k' => 10, 'm' => 20, 'g' => 30);
|
||||
$bases = array('' => 10, '0' => 8, '0x' => 16);
|
||||
|
||||
return intval($match[2], $bases[$match[1]]) << $shifts[$match[3]];
|
||||
$max = ltrim($iniMax, '+');
|
||||
if (0 === strpos($max, '0x')) {
|
||||
$max = intval($max, 16);
|
||||
} elseif (0 === strpos($max, '0')) {
|
||||
$max = intval($max, 8);
|
||||
} else {
|
||||
$max = intval($max);
|
||||
}
|
||||
|
||||
return 0;
|
||||
switch (substr($iniMax, -1)) {
|
||||
case 't': $max *= 1024;
|
||||
case 'g': $max *= 1024;
|
||||
case 'm': $max *= 1024;
|
||||
case 'k': $max *= 1024;
|
||||
}
|
||||
|
||||
return $max;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,7 +25,7 @@ class MemoryDataCollector extends DataCollector
|
||||
{
|
||||
$this->data = array(
|
||||
'memory' => 0,
|
||||
'memory_limit' => $this->convertToBytes(strtolower(ini_get('memory_limit'))),
|
||||
'memory_limit' => $this->convertToBytes(ini_get('memory_limit')),
|
||||
);
|
||||
}
|
||||
|
||||
@ -79,13 +79,22 @@ class MemoryDataCollector extends DataCollector
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (preg_match('#^\+?(0x?)?(.*?)([kmg]?)$#', $memoryLimit, $match)) {
|
||||
$shifts = array('' => 0, 'k' => 10, 'm' => 20, 'g' => 30);
|
||||
$bases = array('' => 10, '0' => 8, '0x' => 16);
|
||||
|
||||
return intval($match[2], $bases[$match[1]]) << $shifts[$match[3]];
|
||||
$max = strtolower(ltrim($memoryLimit, '+'));
|
||||
if (0 === strpos($max, '0x')) {
|
||||
$max = intval($max, 16);
|
||||
} elseif (0 === strpos($max, '0')) {
|
||||
$max = intval($max, 8);
|
||||
} else {
|
||||
$max = intval($max);
|
||||
}
|
||||
|
||||
return 0;
|
||||
switch (substr($memoryLimit, -1)) {
|
||||
case 't': $max *= 1024;
|
||||
case 'g': $max *= 1024;
|
||||
case 'm': $max *= 1024;
|
||||
case 'k': $max *= 1024;
|
||||
}
|
||||
|
||||
return $max;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user