27 lines
392 B
PHP
27 lines
392 B
PHP
|
<?php
|
||
|
// Functions for common input checks
|
||
|
|
||
|
|
||
|
|
||
|
// Check 32 bit integer
|
||
|
function InpChk_IsValidInt32 (&$value): bool {
|
||
|
if (is_null($value))
|
||
|
return false;
|
||
|
|
||
|
if (is_string($value)) {
|
||
|
if (strlen($value) > 24)
|
||
|
return false;
|
||
|
if (!ctype_digit($value))
|
||
|
return false;
|
||
|
$value = intval($value);
|
||
|
}
|
||
|
|
||
|
if ($value > 0xffffffff || $value < -(0xffffffff))
|
||
|
return false;
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
?>
|