class CControllerPopupDiscoveryCheck extends CController {
const DEFAULT_TYPE = SVC_FTP;
protected function init() {
$this->disableSIDvalidation();
protected function checkInput() {
'type' => 'in '.implode(',', array_keys(discovery_check_type2str())),
'ports' => 'string|not_empty|db dchecks.ports',
'snmp_community' => 'string|not_empty|db dchecks.snmp_community',
'key_' => 'string|not_empty|db dchecks.key_',
'snmp_oid' => 'string|not_empty|db dchecks.key_',
'snmpv3_contextname' => 'string|db dchecks.snmpv3_contextname',
'snmpv3_securityname' => 'string|db dchecks.snmpv3_securityname',
'snmpv3_securitylevel' => 'db dchecks.snmpv3_securitylevel|in '.implode(',', [ITEM_SNMPV3_SECURITYLEVEL_NOAUTHNOPRIV, ITEM_SNMPV3_SECURITYLEVEL_AUTHNOPRIV, ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV]),
'snmpv3_authprotocol' => 'db dchecks.snmpv3_authprotocol|in '.implode(',', array_keys(getSnmpV3AuthProtocols())),
'snmpv3_authpassphrase' => 'string|db dchecks.snmpv3_authpassphrase',
'snmpv3_privprotocol' => 'db dchecks.snmpv3_privprotocol|in '.implode(',', array_keys(getSnmpV3PrivProtocols())),
'snmpv3_privpassphrase' => 'string|not_empty|db dchecks.snmpv3_privpassphrase'
$ret = $this->validateInput($fields);
if ($ret && $this->hasInput('ports') && !validate_port_list($this->getInput('ports'))) {
info(_('Incorrect port range.'));
if ($ret && $this->hasInput('type') && $this->getInput('type') == SVC_AGENT) {
$item_key_parser = new CItemKey();
if ($item_key_parser->parse($this->getInput('key_')) != CParser::PARSE_SUCCESS) {
info(_s('Invalid key "%1$s": %2$s.', $this->getInput('key_'), $item_key_parser->getError()));
if (($messages = getMessages()) !== null) {
$output['errors'] = $messages->toString();
(new CControllerResponseData(['main_block' => json_encode($output)]))->disableView()
protected function checkPermissions() {
protected function doAction() {
'type' => self::DEFAULT_TYPE,