<?php declare(strict_types = 0);
class CControllerHostList extends CController {
protected function init() {
$this->disableCsrfValidation();
protected function checkInput(): bool {
'filter_host' => 'string',
'filter_templates' => 'array_db hosts.hostid',
'filter_groups' => 'array_db hosts_groups.groupid',
'filter_dns' => 'string',
'filter_port' => 'string',
'filter_status' => 'in -1,'.HOST_STATUS_MONITORED.','.HOST_STATUS_NOT_MONITORED,
'filter_monitored_by' => 'in '.implode(',', [ZBX_MONITORED_BY_ANY, ZBX_MONITORED_BY_SERVER, ZBX_MONITORED_BY_PROXY, ZBX_MONITORED_BY_PROXY_GROUP]),
'filter_proxyids' => 'array_db hosts.proxyid',
'filter_proxy_groupids' => 'array_db hosts.proxy_groupid',
'filter_evaltype' => 'in '.TAG_EVAL_TYPE_AND_OR.','.TAG_EVAL_TYPE_OR,
'filter_tags' => 'array',
'sort' => 'in name,status',
'sortorder' => 'in '.ZBX_SORT_DOWN.','.ZBX_SORT_UP,
$ret = $this->validateInput($fields);
$this->setResponse(new CControllerResponseFatal());
protected function checkPermissions(): bool {
return $this->checkAccess(CRoleHelper::UI_CONFIGURATION_HOSTS);
protected function doAction(): void {
if ($this->hasInput('filter_set')) {
CProfile::update('web.hosts.filter_ip', $this->getInput('filter_ip', ''), PROFILE_TYPE_STR);
CProfile::update('web.hosts.filter_dns', $this->getInput('filter_dns', ''), PROFILE_TYPE_STR);
CProfile::update('web.hosts.filter_host', $this->getInput('filter_host', ''), PROFILE_TYPE_STR);
CProfile::update('web.hosts.filter_port', $this->getInput('filter_port', ''), PROFILE_TYPE_STR);
CProfile::update('web.hosts.filter_status', $this->getInput('filter_status', -1), PROFILE_TYPE_INT);
CProfile::update('web.hosts.filter_monitored_by',
$this->getInput('filter_monitored_by', ZBX_MONITORED_BY_ANY), PROFILE_TYPE_INT
CProfile::updateArray('web.hosts.filter_templates', $this->getInput('filter_templates', []),
CProfile::updateArray('web.hosts.filter_groups', $this->getInput('filter_groups', []), PROFILE_TYPE_ID);
CProfile::updateArray('web.hosts.filter_proxyids', $this->getInput('filter_proxyids', []), PROFILE_TYPE_ID);
CProfile::updateArray('web.hosts.filter_proxy_groupids', $this->getInput('filter_proxy_groupids', []),
CProfile::update('web.hosts.filter.evaltype', $this->getInput('filter_evaltype', TAG_EVAL_TYPE_AND_OR),
$filter_tags = ['tags' => [], 'values' => [], 'operators' => []];
foreach ($this->getInput('filter_tags', []) as $filter_tag) {
if ($filter_tag['tag'] === '' && $filter_tag['value'] === '') {
$filter_tags['tags'][] = $filter_tag['tag'];
$filter_tags['values'][] = $filter_tag['value'];
$filter_tags['operators'][] = $filter_tag['operator'];
CProfile::updateArray('web.hosts.filter.tags.tag', $filter_tags['tags'], PROFILE_TYPE_STR);