Source
<?php declare(strict_types = 0);
/*
** 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 CControllerWebScenarioStepCheck extends CController {
protected function init(): void {
$this->setPostContentType(self::POST_CONTENT_TYPE_JSON);
$this->disableCsrfValidation();
}
protected function checkInput(): bool {
$fields = [
'httpstepid' => 'db httpstep.httpstepid',
'name' => 'required|not_empty|db httpstep.name',
'old_name' => 'string',
'names' => 'array',
'url' => 'required|not_empty|db httpstep.url',
'timeout' => 'required|not_empty|db httpstep.timeout',
'posts' => 'db httpstep.posts',
'required' => 'db httpstep.required',
'status_codes' => 'db httpstep.status_codes',
'follow_redirects' => 'db httpstep.follow_redirects|in '.implode(',', [HTTPTEST_STEP_FOLLOW_REDIRECTS_OFF, HTTPTEST_STEP_FOLLOW_REDIRECTS_ON]),
'retrieve_mode' => 'db httpstep.retrieve_mode|in '.implode(',', [HTTPTEST_STEP_RETRIEVE_MODE_CONTENT, HTTPTEST_STEP_RETRIEVE_MODE_HEADERS, HTTPTEST_STEP_RETRIEVE_MODE_BOTH]),
'post_type' => 'db httpstep.post_type|in '.implode(',', [ZBX_POSTTYPE_RAW, ZBX_POSTTYPE_FORM]),
'query_fields' => 'array',
'post_fields' => 'array',
'variables' => 'array',
'headers' => 'array'
];
$ret = $this->validateInput($fields) && $this->validateFields();
if (!$ret) {
$this->setResponse(
(new CControllerResponseData(['main_block' => json_encode([
'error' => [
'title' => $this->getInput('old_name', '') === ''
? _('Cannot create web scenario step')
: _('Cannot update web scenario step'),
'messages' => array_column(get_and_clear_messages(), 'message')
]
])]))->disableView()
);
}
return $ret;
}
private function validateFields(): bool {
$ret = true;