Source
$ip_range_parser = new CIPRangeParser(['v6' => ZBX_HAVE_IPV6, 'dns' => false, 'max_ipv4_cidr' => 30]);
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
class CActionCondValidator extends CValidator {
/**
* Returns true if the given $value is valid, or set's an error and returns false otherwise.
*
* @param array $condition
*
* @return bool
*/
public function validate($condition) {
// Build validators.
$discoveryCheckTypeValidator = new CLimitedSetValidator([
'values' => array_keys(discovery_check_type2str())
]);
$discoveryObjectStatusValidator = new CLimitedSetValidator([
'values' => array_keys(discovery_object_status2str())
]);
$triggerSeverityValidator = new CLimitedSetValidator([
'values' => [
TRIGGER_SEVERITY_NOT_CLASSIFIED,
TRIGGER_SEVERITY_INFORMATION,
TRIGGER_SEVERITY_WARNING,
TRIGGER_SEVERITY_AVERAGE,
TRIGGER_SEVERITY_HIGH,
TRIGGER_SEVERITY_DISASTER
]
]);
$discoveryObjectValidator = new CLimitedSetValidator([
'values' => array_keys(discovery_object2str())
]);
$eventTypeValidator = new CLimitedSetValidator([
'values' => array_keys(eventType())
]);
// Validate condition values depending on condition type.
switch ($condition['conditiontype']) {
case ZBX_CONDITION_TYPE_HOST_GROUP:
case ZBX_CONDITION_TYPE_TEMPLATE:
case ZBX_CONDITION_TYPE_TRIGGER:
case ZBX_CONDITION_TYPE_HOST:
case ZBX_CONDITION_TYPE_DRULE:
case ZBX_CONDITION_TYPE_PROXY:
case ZBX_CONDITION_TYPE_SERVICE:
if (zbx_empty($condition['value']) || $condition['value'] == 0) {
$this->setError(_s('Incorrect value for field "%1$s": %2$s.', 'value', _('cannot be empty')));
}
elseif (is_array($condition['value'])) {