Source
'templated_hosts' => array_key_exists('templated_hosts', $data) ? $data['templated_hosts'] : null,
<?php
/*
** Zabbix
** 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 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.
**/
require_once dirname(__FILE__).'/include/func.inc.php';
require_once dirname(__FILE__).'/include/defines.inc.php';
require_once dirname(__FILE__).'/include/classes/user/CWebUser.php';
require_once dirname(__FILE__).'/include/classes/core/CHttpRequest.php';
$requestType = getRequest('type', PAGE_TYPE_JSON);
if ($requestType == PAGE_TYPE_JSON) {
$http_request = new CHttpRequest();
$data = json_decode($http_request->body(), true);
}
else {
$data = $_REQUEST;
}
if (is_array($data) && array_key_exists('method', $data) && $data['method'] === 'zabbix.status') {
CWebUser::disableSessionExtension();
}
require_once dirname(__FILE__).'/include/config.inc.php';
$page['title'] = 'RPC';
$page['file'] = 'jsrpc.php';
$page['type'] = detect_page_type($requestType);
require_once dirname(__FILE__).'/include/page_header.php';
if (!is_array($data) || !isset($data['method'])
|| ($requestType == PAGE_TYPE_JSON && (!isset($data['params']) || !is_array($data['params'])))) {
fatal_error('Wrong RPC call to JS RPC!');
}
$result = [];
$limit = CSettingsHelper::get(CSettingsHelper::SEARCH_LIMIT);
switch ($data['method']) {
case 'search':
$result = API::Host()->get([
'output' => ['hostid', 'name'],
'search' => ['name' => $data['params']['search'], 'host' => $data['params']['search']],
'searchByAny' => true,
'sortfield' => 'name',
'limit' => 15