Source
if (strpos('" ', $param[0]) === false && strpos($param, ',') === false && strpos($param, ']') === false) {
<?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 is used to validate and parse item keys.
*/
class CItemKey extends CParser {
const STATE_NEW = 0;
const STATE_END = 1;
const STATE_UNQUOTED = 2;
const STATE_QUOTED = 3;
const STATE_END_OF_PARAMS = 4;
const PARAM_ARRAY = 0;
const PARAM_UNQUOTED = 1;
const PARAM_QUOTED = 2;
private $key = ''; // main part of the key (for 'key[1, 2, 3]' key id would be 'key')
private $parameters = [];
/**
* An options array
*
* Supported options:
* '18_simple_checks' => true with support for old-style simple checks like "ftp,{$PORT}"
*
* @var array
*/
private $options = ['18_simple_checks' => false];
/**
* @param array $options
*/
public function __construct($options = []) {
$this->error_msgs['empty'] = _('key is empty');
$this->error_msgs['unexpected_end'] = _('unexpected end of key');
if (array_key_exists('18_simple_checks', $options)) {
$this->options['18_simple_checks'] = $options['18_simple_checks'];
}
}
/**
* Check if given character is a valid key id char
* this function is a copy of zbx_is_key_char() from src/libs/zbxexpr/expr.c
* don't forget to take look in there before changing anything.
*
* @param string $char
* @return bool