优化 dintval在PHP的兼容性调整

This commit is contained in:
康盛Discuz! 2016-12-20 23:04:05 -05:00
parent 031636902c
commit f845217e07
2 changed files with 20 additions and 3 deletions

View File

@ -170,6 +170,23 @@ function function_check(&$func_items) {
}
}
function dintval($int, $allowarray = false) {
$ret = floatval($int);
if($int == $ret || !$allowarray && is_array($int)) return $ret;
if($allowarray && is_array($int)) {
foreach($int as &$v) {
$v = dintval($v, true);
}
return $int;
} elseif($int <= 0xffffffff) {
$l = strlen($int);
$m = substr($int, 0, 1) == '-' ? 1 : 0;
if(($l - $m) === strspn($int,'0987654321', $m)) {
return $int;
}
}
return $ret;
}
function show_env_result(&$env_items, &$dirfile_items, &$func_items, &$filesock_items) {
$env_str = $file_str = $dir_str = $func_str = '';
@ -181,8 +198,8 @@ function show_env_result(&$env_items, &$dirfile_items, &$func_items, &$filesock_
}
$status = 1;
if($item['r'] != 'notset') {
if(intval($item['current']) && intval($item['r'])) {
if(intval($item['current']) < intval($item['r'])) {
if(dintval($item['current']) && dintval($item['r'])) {
if(dintval($item['current']) < dintval($item['r'])) {
$status = 0;
$error_code = ENV_CHECK_ERROR;
}

View File

@ -1993,7 +1993,7 @@ function userappprompt() {
}
function dintval($int, $allowarray = false) {
$ret = intval($int);
$ret = floatval($int);
if($int == $ret || !$allowarray && is_array($int)) return $ret;
if($allowarray && is_array($int)) {
foreach($int as &$v) {