Source
info(_s('Incorrect value "%1$s" for "%2$s" field: must be between %3$s and %4$s, and have no more than %5$s digits after the decimal point.',
<?php
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
function unset_request($key) {
unset($_GET[$key], $_POST[$key], $_REQUEST[$key]);
}
/**
* Validation expression for min/max number range.
*
* @param int $min
* @param int $max
* @param string $var
*
* @return string
*/
function BETWEEN($min, $max, $var = '') {
return '({'.$var.'}>='.$min.'&&{'.$var.'}<='.$max.')&&';
}
/**
* Validation expression for min/max range and max number of digits after the decimal point.
*
* @param int $min
* @param int $max
* @param int $scale
* @param string $var
*
* @return string
*/
function BETWEEN_DBL($min, $max, $scale, $var = '') {
return BETWEEN($min, $max, $var).'(round({'.$var.'},'.$scale.')=={'.$var.'})&&';
}
function IN($array, $var = '') {
if (is_array($array)) {
$array = implode(',', $array);
}
return 'str_in_array({'.$var.'},array('.$array.'))&&';
}
function HEX($var = null) {
return 'preg_match("/^([a-zA-Z0-9]+)$/",{'.$var.'})&&';
}
function validate_port_list($str) {
foreach (explode(',', $str) as $port_range) {
$port_range = explode('-', $port_range);
if (count($port_range) > 2) {
return false;
}
foreach ($port_range as $port) {
if (!validatePortNumber($port)) {
return false;
}
}
}
return true;
}
function calc_exp($fields, $field, $expression) {
if (strpos($expression, '{}') !== false) {
if (!isset($_REQUEST[$field])) {
return false;
}
if (!is_array($_REQUEST[$field])) {
$expression = str_replace('{}', '$_REQUEST["'.$field.'"]', $expression);
}
if (is_array($_REQUEST[$field])) {
foreach ($_REQUEST[$field] as $key => $val) {
if (!preg_match('/^([a-zA-Z0-9_]+)$/', $key)) {
return false;