require_once dirname(__FILE__).'/include/config.inc.php';
require_once dirname(__FILE__).'/include/hosts.inc.php';
$page['title'] = _('Availability report');
$page['file'] = 'report2.php';
$page['scripts'] = ['class.calendar.js', 'gtlc.js', 'report2.js'];
$page['type'] = detect_page_type(PAGE_TYPE_HTML);
require_once dirname(__FILE__).'/include/page_header.php';
'mode' => [T_ZBX_INT, O_OPT, P_SYS, IN(implode(',', [AVAILABILITY_REPORT_BY_HOST, AVAILABILITY_REPORT_BY_TEMPLATE])), null],
'hostgroupid' => [T_ZBX_INT, O_OPT, P_SYS, DB_ID, null],
'tpl_triggerid' => [T_ZBX_INT, O_OPT, P_SYS, DB_ID, null],
'triggerid' => [T_ZBX_INT, O_OPT, P_SYS|P_NZERO, DB_ID, null],
'filter_groupid' => [T_ZBX_INT, O_OPT, P_SYS, DB_ID, null],
'filter_groups' => [T_ZBX_INT, O_OPT, P_SYS|P_ONLY_ARRAY, DB_ID, null],
'filter_hostids' => [T_ZBX_INT, O_OPT, P_SYS|P_ONLY_ARRAY, DB_ID, null],
'filter_templateid' => [T_ZBX_INT, O_OPT, P_SYS, DB_ID, null],
'filter_rst'=> [T_ZBX_STR, O_OPT, P_SYS, null, null],
'filter_set' => [T_ZBX_STR, O_OPT, P_SYS, null, null],
'from' => [T_ZBX_RANGE_TIME, O_OPT, P_SYS, null, null],
'to' => [T_ZBX_RANGE_TIME, O_OPT, P_SYS, null, null]
validateTimeSelectorPeriod(getRequest('from'), getRequest('to'));
$report_mode = getRequest('mode', CProfile::get('web.avail_report.mode', AVAILABILITY_REPORT_BY_HOST));
CProfile::update('web.avail_report.mode', $report_mode, PROFILE_TYPE_INT);
if ($report_mode == AVAILABILITY_REPORT_BY_TEMPLATE) {
if (getRequest('hostgroupid') && !isReadableHostGroups([getRequest('hostgroupid')])) {
if (getRequest('filter_groupid') && !isReadableTemplateGroups([getRequest('filter_groupid')])) {
if (getRequest('filter_templateid') && !isReadableTemplates([getRequest('filter_templateid')])) {
if (getRequest('tpl_triggerid')) {
$trigger = API::Trigger()->get([
'triggerids' => $_REQUEST['tpl_triggerid'],
'output' => ['triggerid'],
'filter' => ['flags' => null]
if (getRequest('triggerid') && !isReadableTriggers([getRequest('triggerid')])) {
$key_prefix = 'web.avail_report.'.$report_mode;
if (hasRequest('filter_set')) {
if ($report_mode == AVAILABILITY_REPORT_BY_TEMPLATE) {
CProfile::update($key_prefix.'.groupid', getRequest('filter_groupid', 0), PROFILE_TYPE_ID);
CProfile::update($key_prefix.'.hostid', getRequest('filter_templateid', 0), PROFILE_TYPE_ID);
CProfile::update($key_prefix.'.tpl_triggerid', getRequest('tpl_triggerid', 0), PROFILE_TYPE_ID);