Skip to content

Commit

Permalink
Fixed: Non well formed numeric value encountered in utils_getPhpValue…
Browse files Browse the repository at this point in the history
…InBytes() function
  • Loading branch information
nuxwin committed May 4, 2017
1 parent 586ff19 commit 38dfc28
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -20,6 +20,7 @@ DISTRIBUTION

FRONTEND
Fixed: Allow auto-completion for login form (regression fix)
Fixed: Non well formed numeric value encountered in utils_getPhpValueInBytes() function

LISTENERS
Added: Missing mail, imap, pop, pop3, relay and smtp records entries for subdomains (20_named_dualstack.pl listener)
Expand Down
32 changes: 20 additions & 12 deletions gui/library/Functions/Shared.php
Expand Up @@ -1277,20 +1277,28 @@ function utils_getMaxFileUpload()
*/
function utils_getPhpValueInBytes($value)
{
$val = trim($value);
$last = strtolower($val[strlen($value) - 1]);

switch ($last) {
case 'g':
$val *= 1024;
case 'm':
$val *= 1024;
case 'k':
$val *= 1024;
break;
$value = trim($value);

if (ctype_digit($value)) {
return $value;
}

$unit = strtolower($value[strlen($value) - 1]);
$value = substr($value, 0, -1);

if ($unit == 'g') {
return ($value * 1024);
}

if ($unit == 'm') {
return ($value * 1024 * 1024);
}

if ($unit == 'k') {
return ($value * 1024 * 1024 * 1024);
}

return $val;
return $value;
}

/**
Expand Down

0 comments on commit 38dfc28

Please sign in to comment.