function local_generateHeader($data)
{
    // only needed for zbx_construct_menu
    global $page;
    header('Content-Type: text/html; charset=UTF-8');
    // construct menu
    $main_menu = [];
    $sub_menus = [];
    zbx_construct_menu($main_menu, $sub_menus, $page, $data['controller']['action']);
    $pageHeader = new CView('layout.htmlpage.header', ['javascript' => ['files' => $data['javascript']['files']], 'page' => ['title' => $data['page']['title']], 'user' => ['lang' => CWebUser::$data['lang'], 'theme' => CWebUser::$data['theme']]]);
    echo $pageHeader->getOutput();
    if ($data['fullscreen'] == 0) {
        global $ZBX_SERVER_NAME;
        $pageMenu = new CView('layout.htmlpage.menu', ['server_name' => isset($ZBX_SERVER_NAME) ? $ZBX_SERVER_NAME : '', 'menu' => ['main_menu' => $main_menu, 'sub_menus' => $sub_menus, 'selected' => $page['menu']], 'user' => ['is_guest' => CWebUser::isGuest(), 'alias' => CWebUser::$data['alias'], 'name' => CWebUser::$data['name'], 'surname' => CWebUser::$data['surname']]]);
        echo $pageMenu->getOutput();
    }
    echo '<div class="' . ZBX_STYLE_ARTICLE . '">';
    // should be replaced with addPostJS() at some point
    zbx_add_post_js('initMessages({});');
    // if a user logs in after several unsuccessful attempts, display a warning
    if ($failedAttempts = CProfile::get('web.login.attempt.failed', 0)) {
        $attempt_ip = CProfile::get('web.login.attempt.ip', '');
        $attempt_date = CProfile::get('web.login.attempt.clock', 0);
        $error_msg = _n('%4$s failed login attempt logged. Last failed attempt was from %1$s on %2$s at %3$s.', '%4$s failed login attempts logged. Last failed attempt was from %1$s on %2$s at %3$s.', $attempt_ip, zbx_date2str(DATE_FORMAT, $attempt_date), zbx_date2str(TIME_FORMAT, $attempt_date), $failedAttempts);
        error($error_msg);
        CProfile::update('web.login.attempt.failed', 0, PROFILE_TYPE_INT);
    }
    show_messages();
}
 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     $status = get_status();
     $server = $status['zabbix_server'] == _('Yes') ? (new CSpan(_('running')))->addClass(ZBX_STYLE_GREEN) : (new CSpan(_('not running')))->addClass(ZBX_STYLE_RED);
     $user_link = CWebUser::$data['alias'];
     if (!CWebUser::isGuest()) {
         $user_link = new CLink($user_link, 'profile.php');
     }
     $server_link = _('Zabbix server');
     if (CWebUser::$data['type'] == USER_TYPE_SUPER_ADMIN) {
         $server_link = new CLink($server_link, 'zabbix.php?action=report.status');
     }
     $table = new CTableInfo();
     $table->addRow(_('Users (online)') . NAME_DELIMITER . $status['users_count'] . '(' . $status['users_online'] . ')');
     $table->addRow(new CCol([_('Logged in as'), SPACE, $user_link]));
     $table->addRow(new CCol([$server_link, SPACE, _('is'), SPACE, $server]));
     $table->addRow(new CCol([_('Hosts (m/n/t)') . NAME_DELIMITER . $status['hosts_count'] . '(', (new CSpan($status['hosts_count_monitored']))->addClass(ZBX_STYLE_GREEN), '/', (new CSpan($status['hosts_count_not_monitored']))->addClass(ZBX_STYLE_RED), '/', (new CSpan($status['hosts_count_template']))->addClass(ZBX_STYLE_GREY), ')']));
     $table->addRow(new CCol([_('Items (m/d/n)') . NAME_DELIMITER . $status['items_count'] . '(', (new CSpan($status['items_count_monitored']))->addClass(ZBX_STYLE_GREEN), '/', (new CSpan($status['items_count_disabled']))->addClass(ZBX_STYLE_RED), '/', (new CSpan($status['items_count_not_supported']))->addClass(ZBX_STYLE_GREY), ')']));
     $table->addRow(new CCol([_('Triggers (e/d)[p/o]') . NAME_DELIMITER . $status['triggers_count'] . '(' . $status['triggers_count_enabled'] . '/' . $status['triggers_count_disabled'] . ')[', (new CSpan($status['triggers_count_on']))->addClass(ZBX_STYLE_GREEN), '/', (new CSpan($status['triggers_count_off']))->addClass(ZBX_STYLE_RED), ']']));
     $footer = (new CList())->addItem(_s('Updated: %s', zbx_date2str(TIME_FORMAT_SECONDS)))->addClass(ZBX_STYLE_DASHBRD_WIDGET_FOOT);
     return $this->getOutput((new CUiWidget(uniqid(), [$table, $footer]))->setHeader(_('Zabbix server info')));
 }
Exemple #3
0
/**
 * Renders an "access denied" message and stops the execution of the script.
 *
 * The $mode parameters controls the layout of the message:
 * - ACCESS_DENY_OBJECT     - render the message when denying access to a specific object
 * - ACCESS_DENY_PAGE       - render a complete access denied page
 *
 * @param int $mode
 */
function access_deny($mode = ACCESS_DENY_OBJECT)
{
    // deny access to an object
    if ($mode == ACCESS_DENY_OBJECT) {
        require_once dirname(__FILE__) . '/page_header.php';
        show_error_message(_('No permissions to referred object or it does not exist!'));
        require_once dirname(__FILE__) . '/page_footer.php';
    } else {
        // url to redirect the user to after he loggs in
        $url = new CUrl(!empty($_REQUEST['request']) ? $_REQUEST['request'] : '');
        $url->setArgument('sid', null);
        $url = urlencode($url->toString());
        // if the user is logged in - render the access denied message
        if (CWebUser::isLoggedIn()) {
            $header = _('Access denied.');
            $message = array(_('Your are logged in as'), ' ', bold(CWebUser::$data['alias']), '. ', _('You have no permissions to access this page.'), BR(), _('If you think this message is wrong, please consult your administrators about getting the necessary permissions.'));
            $buttons = array();
            // display the login button only for guest users
            if (CWebUser::isGuest()) {
                $buttons[] = new CButton('login', _('Login'), 'javascript: document.location = "index.php?request=' . $url . '";', 'formlist');
            }
            $buttons[] = new CButton('back', _('Go to dashboard'), 'javascript: document.location = "dashboard.php"', 'formlist');
        } else {
            $header = _('You are not logged in.');
            $message = array(_('You must login to view this page.'), BR(), _('If you think this message is wrong, please consult your administrators about getting the necessary permissions.'));
            $buttons = array(new CButton('login', _('Login'), 'javascript: document.location = "index.php?request=' . $url . '";', 'formlist'));
        }
        $warning = new CWarning($header, $message);
        $warning->setButtons($buttons);
        $warningView = new CView('general.warning', array('warning' => $warning));
        $warningView->render();
        exit;
    }
}
Exemple #4
0
 $help = new CLink(_('Help'), 'http://www.zabbix.com/documentation/', 'small_font', null, 'nosid');
 $help->setTarget('_blank');
 $support = new CLink(_('Get support'), 'http://www.zabbix.com/support.php', 'small_font', null, 'nosid');
 $support->setTarget('_blank');
 $printview = new CLink(_('Print'), '', 'small_font print-link', null, 'nosid');
 $page_header_r_col = array($help, '|', $support, '|', $printview, '|');
 if (!CWebUser::isGuest()) {
     array_push($page_header_r_col, new CLink(_('Profile'), 'profile.php', 'small_font', null, 'nosid'), '|');
 }
 if (isset(CWebUser::$data['debug_mode']) && CWebUser::$data['debug_mode'] == GROUP_DEBUG_MODE_ENABLED) {
     $debug = new CLink(_('Debug'), '#debug', 'small_font', null, 'nosid');
     $d_script = " if (!isset('state', this)) { this.state = 'none'; }" . " if (this.state == 'none') { this.state = 'block'; }" . " else { this.state = 'none'; }" . " showHideByName('zbx_debug_info', this.state);";
     $debug->setAttribute('onclick', 'javascript: ' . $d_script);
     array_push($page_header_r_col, $debug, '|');
 }
 if (CWebUser::isGuest()) {
     $page_header_r_col[] = array(new CLink(_('Login'), 'index.php?reconnect=1', 'small_font', null, null));
 } else {
     // it is not possible to logout from HTTP authentication
     $chck = $page['file'] == 'authentication.php' && isset($_REQUEST['save'], $_REQUEST['config']);
     if ($chck && $_REQUEST['config'] == ZBX_AUTH_HTTP || !$chck && isset($config) && $config['authentication_type'] == ZBX_AUTH_HTTP) {
         $logout = new CLink(_('Logout'), '', 'small_font', null, 'nosid');
         $logout->setHint(_s('It is not possible to logout from HTTP authentication.'), null, null, false);
     } else {
         $logout = new CLink(_('Logout'), 'index.php?reconnect=1', 'small_font', null, null);
     }
     array_push($page_header_r_col, $logout);
 }
 $logo = new CLink(new CDiv(SPACE, 'zabbix_logo'), 'http://www.zabbix.com/', 'image', null, 'nosid');
 $logo->setTarget('_blank');
 $top_page_row = array(new CCol($logo, 'page_header_l'), new CCol($page_header_r_col, 'maxwidth page_header_r'));
Exemple #5
0
/**
 * Renders an "access denied" message and stops the execution of the script.
 *
 * The $mode parameters controls the layout of the message for logged in users:
 * - ACCESS_DENY_OBJECT     - render the message when denying access to a specific object
 * - ACCESS_DENY_PAGE       - render a complete access denied page
 *
 * If visitor is without any access permission then layout of the message is same as in ACCESS_DENY_PAGE mode.
 *
 * @param int $mode
 */
function access_deny($mode = ACCESS_DENY_OBJECT)
{
    // deny access to an object
    if ($mode == ACCESS_DENY_OBJECT && CWebUser::isLoggedIn()) {
        require_once dirname(__FILE__) . '/page_header.php';
        show_error_message(_('No permissions to referred object or it does not exist!'));
        require_once dirname(__FILE__) . '/page_footer.php';
    } else {
        // url to redirect the user to after he loggs in
        $url = (new CUrl(!empty($_REQUEST['request']) ? $_REQUEST['request'] : ''))->removeArgument('sid');
        $url = urlencode($url->toString());
        // if the user is logged in - render the access denied message
        if (CWebUser::isLoggedIn()) {
            $data = ['header' => _('Access denied'), 'messages' => [_s('You are logged in as "%1$s".', CWebUser::$data['alias']) . ' ' . _('You have no permissions to access this page.'), _('If you think this message is wrong, please consult your administrators about getting the necessary permissions.')], 'buttons' => []];
            // display the login button only for guest users
            if (CWebUser::isGuest()) {
                $data['buttons'][] = (new CButton('login', _('Login')))->onClick('javascript: document.location = "index.php?request=' . $url . '";');
            }
            $data['buttons'][] = (new CButton('back', _('Go to dashboard')))->onClick('javascript: document.location = "zabbix.php?action=dashboard.view"');
        } else {
            $data = ['header' => _('You are not logged in'), 'messages' => [_('You must login to view this page.'), _('If you think this message is wrong, please consult your administrators about getting the necessary permissions.')], 'buttons' => [(new CButton('login', _('Login')))->onClick('javascript: document.location = "index.php?request=' . $url . '";')]];
        }
        $data['theme'] = getUserTheme(CWebUser::$data);
        (new CView('general.warning', $data))->render();
        exit;
    }
}
if (CSession::keyExists('messageOk') || CSession::keyExists('messageError')) {
    if (CSession::keyExists('messages')) {
        $messages = CSession::getValue('messages');
        CSession::unsetValue(['messages']);
    }
    if (CSession::keyExists('messageOk')) {
        $message_good = true;
        $message_ok = CSession::getValue('messageOk');
    } else {
        $message_good = false;
        $message_error = CSession::getValue('messageError');
    }
    CSession::unsetValue(['messageOk', 'messageError']);
}
if (!defined('ZBX_PAGE_NO_MENU')) {
    $pageMenu = new CView('layout.htmlpage.menu', ['server_name' => isset($ZBX_SERVER_NAME) ? $ZBX_SERVER_NAME : '', 'menu' => ['main_menu' => $main_menu, 'sub_menus' => $sub_menus, 'selected' => $page['menu']], 'user' => ['is_guest' => CWebUser::isGuest(), 'alias' => CWebUser::$data['alias'], 'name' => CWebUser::$data['name'], 'surname' => CWebUser::$data['surname']]]);
    echo $pageMenu->getOutput();
}
if ($page['type'] == PAGE_TYPE_HTML) {
    echo '<div class="' . ZBX_STYLE_ARTICLE . '">';
}
// unset multiple variables
unset($table, $top_page_row, $menu_table, $main_menu_row, $sub_menu_table, $sub_menu_rows);
if ($page['type'] == PAGE_TYPE_HTML && $showGuiMessaging) {
    zbx_add_post_js('initMessages({});');
}
// if a user logs in after several unsuccessful attempts, display a warning
if ($failedAttempts = CProfile::get('web.login.attempt.failed', 0)) {
    $attempip = CProfile::get('web.login.attempt.ip', '');
    $attempdate = CProfile::get('web.login.attempt.clock', 0);
    $error_msg = _n('%4$s failed login attempt logged. Last failed attempt was from %1$s on %2$s at %3$s.', '%4$s failed login attempts logged. Last failed attempt was from %1$s on %2$s at %3$s.', $attempip, zbx_date2str(DATE_FORMAT, $attempdate), zbx_date2str(TIME_FORMAT, $attempdate), $failedAttempts);
Exemple #7
0
$fields = array('type' => array(T_ZBX_STR, O_OPT, null, IN('"' . ZBX_DB_MYSQL . '","' . ZBX_DB_POSTGRESQL . '","' . ZBX_DB_ORACLE . '","' . ZBX_DB_DB2 . '","' . ZBX_DB_SQLITE3 . '"'), null), 'server' => array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, null, _('Database host')), 'port' => array(T_ZBX_INT, O_OPT, null, BETWEEN(0, 65535), null, _('Database port')), 'database' => array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, null, _('Database name')), 'user' => array(T_ZBX_STR, O_OPT, null, null, null), 'password' => array(T_ZBX_STR, O_OPT, null, null, null), 'schema' => array(T_ZBX_STR, O_OPT, null, null, null), 'zbx_server' => array(T_ZBX_STR, O_OPT, null, null, null), 'zbx_server_name' => array(T_ZBX_STR, O_OPT, null, null, null), 'zbx_server_port' => array(T_ZBX_INT, O_OPT, null, BETWEEN(0, 65535), null, _('Port')), 'message' => array(T_ZBX_STR, O_OPT, null, null, null), 'save_config' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'retry' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'cancel' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'finish' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'next' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'back' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'form' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'form_refresh' => array(T_ZBX_INT, O_OPT, null, null, null));
// config
$ZBX_CONFIG = get_cookie('ZBX_CONFIG', null);
$ZBX_CONFIG = isset($ZBX_CONFIG) ? unserialize($ZBX_CONFIG) : array();
$ZBX_CONFIG['check_fields_result'] = check_fields($fields, false);
if (!isset($ZBX_CONFIG['step'])) {
    $ZBX_CONFIG['step'] = 0;
}
// if a guest or a non-super admin user is logged in
if (CWebUser::$data && CWebUser::getType() < USER_TYPE_SUPER_ADMIN) {
    // on the last step of the setup we always have a guest user logged in;
    // when he presses the "Finish" button he must be redirected to the login screen
    if (CWebUser::isGuest() && $ZBX_CONFIG['step'] == 5 && hasRequest('finish')) {
        zbx_unsetcookie('ZBX_CONFIG');
        redirect('index.php');
    } elseif (!(CWebUser::isGuest() && $ZBX_CONFIG['step'] == 5)) {
        access_deny(ACCESS_DENY_PAGE);
    }
} elseif (hasRequest('cancel') || hasRequest('finish')) {
    zbx_unsetcookie('ZBX_CONFIG');
    redirect('index.php');
}
/*
 * Setup wizard
 */
$ZBX_SETUP_WIZARD = new CSetupWizard($ZBX_CONFIG);
zbx_setcookie('ZBX_CONFIG', serialize($ZBX_CONFIG));
// page title
$pageTitle = '';
if (isset($ZBX_SERVER_NAME) && !zbx_empty($ZBX_SERVER_NAME)) {
    $pageTitle = $ZBX_SERVER_NAME . NAME_DELIMITER;
Exemple #8
0
** 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.
**/
require_once dirname(__FILE__) . '/include/config.inc.php';
require_once dirname(__FILE__) . '/include/users.inc.php';
require_once dirname(__FILE__) . '/include/forms.inc.php';
require_once dirname(__FILE__) . '/include/media.inc.php';
$page['title'] = _('User profile');
$page['file'] = 'profile.php';
$page['scripts'] = ['class.cviewswitcher.js'];
ob_start();
if (CWebUser::isGuest() || !CWebUser::isLoggedIn()) {
    access_deny(ACCESS_DENY_PAGE);
}
require_once dirname(__FILE__) . '/include/page_header.php';
$themes = array_keys(Z::getThemes());
$themes[] = THEME_DEFAULT;
//	VAR			TYPE	OPTIONAL FLAGS	VALIDATION	EXCEPTION
$fields = ['password1' => [T_ZBX_STR, O_OPT, null, null, 'isset({update}) && isset({form}) && ({form} != "update") && isset({change_password})'], 'password2' => [T_ZBX_STR, O_OPT, null, null, 'isset({update}) && isset({form}) && ({form} != "update") && isset({change_password})'], 'lang' => [T_ZBX_STR, O_OPT, null, null, null], 'theme' => [T_ZBX_STR, O_OPT, null, IN('"' . implode('","', $themes) . '"'), 'isset({update})'], 'autologin' => [T_ZBX_INT, O_OPT, null, IN('1'), null], 'autologout' => [T_ZBX_INT, O_OPT, null, BETWEEN(90, 10000), null, _('Auto-logout (min 90 seconds)')], 'autologout_visible' => [T_ZBX_STR, O_OPT, null, IN('1'), null], 'url' => [T_ZBX_STR, O_OPT, null, null, 'isset({update})'], 'refresh' => [T_ZBX_INT, O_OPT, null, BETWEEN(0, SEC_PER_HOUR), 'isset({update})', _('Refresh (in seconds)')], 'rows_per_page' => [T_ZBX_INT, O_OPT, null, BETWEEN(1, 999999), 'isset({update})', _('Rows per page')], 'change_password' => [T_ZBX_STR, O_OPT, null, null, null], 'user_medias' => [T_ZBX_STR, O_OPT, null, NOT_EMPTY, null], 'user_medias_to_del' => [T_ZBX_STR, O_OPT, null, null, null], 'new_media' => [T_ZBX_STR, O_OPT, null, null, null], 'enable_media' => [T_ZBX_INT, O_OPT, null, null, null], 'disable_media' => [T_ZBX_INT, O_OPT, null, null, null], 'messages' => [T_ZBX_STR, O_OPT, null, null, null], 'update' => [T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null], 'cancel' => [T_ZBX_STR, O_OPT, P_SYS, null, null], 'del_user_media' => [T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null], 'form' => [T_ZBX_STR, O_OPT, P_SYS, null, null], 'form_refresh' => [T_ZBX_INT, O_OPT, null, null, null]];
check_fields($fields);
$_REQUEST['autologin'] = getRequest('autologin', 0);
// secondary actions
if (isset($_REQUEST['new_media'])) {
    $_REQUEST['user_medias'] = getRequest('user_medias', []);
    array_push($_REQUEST['user_medias'], $_REQUEST['new_media']);
} elseif (isset($_REQUEST['user_medias']) && isset($_REQUEST['enable_media'])) {
    if (isset($_REQUEST['user_medias'][$_REQUEST['enable_media']])) {
Exemple #9
0
}
// VAR	TYPE	OPTIONAL	FLAGS	VALIDATION	EXCEPTION
$fields = ['type' => [T_ZBX_STR, O_OPT, null, IN('"' . ZBX_DB_MYSQL . '","' . ZBX_DB_POSTGRESQL . '","' . ZBX_DB_ORACLE . '","' . ZBX_DB_DB2 . '","' . ZBX_DB_SQLITE3 . '"'), null], 'server' => [T_ZBX_STR, O_OPT, null, null, null], 'port' => [T_ZBX_INT, O_OPT, null, BETWEEN(0, 65535), null, _('Database port')], 'database' => [T_ZBX_STR, O_OPT, null, NOT_EMPTY, null, _('Database name')], 'user' => [T_ZBX_STR, O_OPT, null, null, null], 'password' => [T_ZBX_STR, O_OPT, null, null, null], 'schema' => [T_ZBX_STR, O_OPT, null, null, null], 'zbx_server' => [T_ZBX_STR, O_OPT, null, null, null], 'zbx_server_name' => [T_ZBX_STR, O_OPT, null, null, null], 'zbx_server_port' => [T_ZBX_INT, O_OPT, null, BETWEEN(0, 65535), null, _('Port')], 'save_config' => [T_ZBX_STR, O_OPT, P_SYS, null, null], 'retry' => [T_ZBX_STR, O_OPT, P_SYS, null, null], 'cancel' => [T_ZBX_STR, O_OPT, P_SYS, null, null], 'finish' => [T_ZBX_STR, O_OPT, P_SYS, null, null], 'next' => [T_ZBX_STR, O_OPT, P_SYS, null, null], 'back' => [T_ZBX_STR, O_OPT, P_SYS, null, null]];
CSession::start();
CSession::setValue('check_fields_result', check_fields($fields, false));
if (!CSession::keyExists('step')) {
    CSession::setValue('step', 0);
}
// if a guest or a non-super admin user is logged in
if (CWebUser::$data && CWebUser::getType() < USER_TYPE_SUPER_ADMIN) {
    // on the last step of the setup we always have a guest user logged in;
    // when he presses the "Finish" button he must be redirected to the login screen
    if (CWebUser::isGuest() && CSession::getValue('step') == 5 && hasRequest('finish')) {
        CSession::clear();
        redirect('index.php');
    } elseif (!(CWebUser::isGuest() && CSession::getValue('step') == 5)) {
        access_deny(ACCESS_DENY_PAGE);
    }
} elseif (hasRequest('cancel') || hasRequest('finish')) {
    CSession::clear();
    redirect('index.php');
}
$theme = CWebUser::$data ? getUserTheme(CWebUser::$data) : ZBX_DEFAULT_THEME;
DBclose();
/*
 * Setup wizard
 */
$ZBX_SETUP_WIZARD = new CSetupWizard();
// if init fails due to missing configuration, set user as guest with default en_GB language
if (!CWebUser::$data) {
    CWebUser::setDefault();
Exemple #10
0
** 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.
**/
require_once dirname(__FILE__) . '/include/config.inc.php';
require_once dirname(__FILE__) . '/include/triggers.inc.php';
require_once dirname(__FILE__) . '/include/forms.inc.php';
require_once dirname(__FILE__) . '/include/js.inc.php';
$page['title'] = _('Media');
$page['file'] = 'popup_media.php';
if (CWebUser::getType() < USER_TYPE_ZABBIX_ADMIN || CWebUser::isGuest() && CWebUser::getType() < USER_TYPE_SUPER_ADMIN) {
    access_deny(ACCESS_DENY_PAGE);
}
define('ZBX_PAGE_NO_MENU', 1);
require_once dirname(__FILE__) . '/include/page_header.php';
//		VAR			TYPE	OPTIONAL FLAGS	VALIDATION	EXCEPTION
$fields = ['dstfrm' => [T_ZBX_STR, O_MAND, P_SYS, NOT_EMPTY, null], 'media' => [T_ZBX_INT, O_OPT, P_SYS, null, null], 'mediatypeid' => [T_ZBX_INT, O_OPT, P_SYS, DB_ID, 'isset({add})'], 'sendto' => [T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({add})'], 'period' => [T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({add})'], 'active' => [T_ZBX_INT, O_OPT, null, IN([MEDIA_STATUS_ACTIVE, MEDIA_STATUS_DISABLED]), null], 'severity' => [T_ZBX_INT, O_OPT, null, NOT_EMPTY, null], 'add' => [T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null], 'form' => [T_ZBX_STR, O_OPT, P_SYS, null, null], 'form_refresh' => [T_ZBX_INT, O_OPT, null, null, null]];
check_fields($fields);
insert_js_function('add_media');
if (isset($_REQUEST['add'])) {
    $validator = new CTimePeriodValidator();
    if ($validator->validate($_REQUEST['period'])) {
        $severity = 0;
        $_REQUEST['severity'] = getRequest('severity', []);
        foreach ($_REQUEST['severity'] as $id) {
            $severity |= 1 << $id;