Source
TIMEPERIOD_TYPE_MONTHLY => ['day', 'dayofweek', 'month', 'months', 'month_date_type', 'monthly_days',
<?php
/*
** Zabbix
** Copyright (C) 2001-2022 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.
**/
class CControllerPopupMaintenancePeriod extends CController {
protected function checkInput() {
$fields = [
'update' => 'in 0,1',
'refresh' => 'in 0,1',
'index' => 'required|int32',
'days' => 'array',
'months' => 'array',
'month_date_type' => 'in 0,1',
'period_days' => 'int32',
'hour' => 'int32|ge 0|le 23',
'minute' => 'int32|ge 0|le 59',
'period_hours' => 'int32|ge 0|le 23',
'period_minutes' => 'int32|ge 0|le 59',
'start_date' => 'string',
'monthly_days' => 'array',
'timeperiodid' => 'id',
'timeperiod_type' => 'in '.implode(',', [TIMEPERIOD_TYPE_ONETIME, TIMEPERIOD_TYPE_DAILY,
TIMEPERIOD_TYPE_WEEKLY, TIMEPERIOD_TYPE_MONTHLY]
),
'every' => 'db timeperiods.every',
'month' => 'db timeperiods.month',
'dayofweek' => 'db timeperiods.dayofweek',
'day' => 'db timeperiods.day',
'start_time' => 'db timeperiods.start_time',
'period' => 'db timeperiods.period'
];
$ret = $this->validateInput($fields);
$ret = ($ret && $this->getInput('refresh', 0)) ? $this->validateTypeSpecificInput() : $ret;
if (!$ret) {
$this->setResponse(
(new CControllerResponseData(['main_block' => json_encode([
'error' => [
'messages' => array_column(get_and_clear_messages(), 'message')
]
])]))->disableView()
);
}
return $ret;
}
protected function validateTypeSpecificInput() {
$rules = [
'period' => 'int32'
];
$data = [
'period' => strval(($this->getInput('period_days', 0) * SEC_PER_DAY)
+ ($this->getInput('period_hours', 0) * SEC_PER_HOUR)
+ ($this->getInput('period_minutes', 0) * SEC_PER_MIN))
];
switch ($this->getInput('timeperiod_type', null)) {
case TIMEPERIOD_TYPE_ONETIME:
$parser = new CAbsoluteTimeParser();
$failed = ($parser->parse($this->getInput('start_date')) != CParser::PARSE_SUCCESS);
$start_date = $parser->getDateTime(true);
if ($failed || !validateDateInterval($start_date->format('Y'), $start_date->format('m'),
$start_date->format('d'))) {
error(_('Incorrect maintenance - date must be between 1970.01.01 and 2038.01.18'));
return false;
}
break;