integers must be integers (checker added)

This commit is contained in:
Igor Barkov [iwork] 2019-02-15 15:26:42 +02:00
parent 1f06924bf2
commit c1cad30a9e
2 changed files with 8 additions and 3 deletions

View File

@ -18,9 +18,9 @@ if ($user['battle'] != 0) {
$get = urldecode(filter_input(INPUT_SERVER, 'QUERY_STRING'));
$itemCost = (int)filter_input(INPUT_GET, $_GET['kredit'], FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]);
$itemId = (int)filter_input(INPUT_GET, $_GET['n'], FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]);
$returningItemId = (int)filter_input(INPUT_GET, $_GET['back'], FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]);
$itemCost = checkIntInRange($_GET['kredit']);
$itemId = checkIntInRange($_GET['n']);
$returningItemId = checkIntInRange($_GET['back']);
if ($itemCost && $itemId) {
$commission = ceil($itemCost / 10); # 10% от суммы с округлением вверх.

View File

@ -2824,3 +2824,8 @@ function addOnePoint($name, $param = null)
} else echo "<span style='color: maroon;'>Ошибка: параметр достиг максимального значения!</span>";
} else return null;
}
function checkIntInRange($int, $min = 1, $max = PHP_INT_MAX)
{
return (int)filter_var($int, FILTER_VALIDATE_INT, ['options' => ['min_range' => $min,'max_range' => $max]]);
}