Exemple #1
0
 /**
  * Authenticate user.
  */
 protected function authenticateUser()
 {
     $sessionId = CWebUser::checkAuthentication(CWebUser::getSessionCookie());
     if (!$sessionId) {
         CWebUser::setDefault();
     }
     // set the authentication token for the API
     API::getWrapper()->auth = $sessionId;
     // enable debug mode in the API
     API::getWrapper()->debug = CWebUser::getDebugMode();
 }
    }
} elseif (getRequest('action') === 'valuemap.delete' && hasRequest('valuemapids')) {
    $valuemapids = getRequest('valuemapids', []);
    $result = (bool) API::ValueMap()->delete($valuemapids);
    if ($result) {
        unset($_REQUEST['form']);
        uncheckTableRows();
    }
    $deleted = count($valuemapids);
    show_messages($result, _n('Value map deleted', 'Value maps deleted', $deleted), _n('Cannot delete value map', 'Cannot delete value maps', $deleted));
}
/*
 * Display
 */
if (hasRequest('form')) {
    $data = ['form' => getRequest('form', ''), 'valuemapid' => getRequest('valuemapid', 0), 'valuemap_count' => 0, 'sid' => substr(CWebUser::getSessionCookie(), 16, 16)];
    if ($data['valuemapid'] != 0 && !hasRequest('form_refresh')) {
        $valuemaps = API::ValueMap()->get(['output' => ['valuemapid', 'name'], 'selectMappings' => ['value', 'newvalue'], 'valuemapids' => [$data['valuemapid']]]);
        $valuemap = reset($valuemaps);
        $data = zbx_array_merge($data, $valuemap);
        order_result($data['mappings'], 'value');
    } else {
        $data['name'] = getRequest('name', '');
        $data['mappings'] = getRequest('mappings', []);
    }
    if ($data['valuemapid'] != 0) {
        $data['valuemap_count'] += API::Item()->get(['countOutput' => true, 'webitems' => true, 'filter' => ['valuemapid' => $data['valuemapid']]]);
        $data['valuemap_count'] += API::ItemPrototype()->get(['countOutput' => true, 'filter' => ['valuemapid' => $data['valuemapid']]]);
    }
    if (!$data['mappings']) {
        $data['mappings'][] = ['value' => '', 'newvalue' => ''];
Exemple #3
0
        if (CWebUser::$data['autologin'] != $autoLogin) {
            API::User()->updateProfile($user);
        }
        $request = getRequest('request');
        $url = zbx_empty($request) ? CWebUser::$data['url'] : $request;
        if (zbx_empty($url) || $url == $page['file']) {
            $url = 'dashboard.php';
        }
        redirect($url);
        exit;
    } else {
        CWebUser::checkAuthentication(null);
    }
} else {
    // login the user from the session, if the session id is empty - login as a guest
    CWebUser::checkAuthentication(CWebUser::getSessionCookie());
}
// the user is not logged in, display the login form
if (!CWebUser::$data['alias'] || CWebUser::$data['alias'] == ZBX_GUEST_USER) {
    switch ($config['authentication_type']) {
        case ZBX_AUTH_HTTP:
            echo _('User name does not match with DB');
            break;
        case ZBX_AUTH_LDAP:
        case ZBX_AUTH_INTERNAL:
            if (isset($_REQUEST['enter'])) {
                $_REQUEST['autologin'] = getRequest('autologin', 0);
            }
            if ($messages = clear_messages()) {
                $messages = array_pop($messages);
                $_REQUEST['message'] = $messages['message'];
 /**
  * Validate session ID (SID).
  *
  * @return var
  */
 protected function checkSID()
 {
     $sessionid = CWebUser::getSessionCookie();
     if ($sessionid === null || !isset($_REQUEST['sid'])) {
         return false;
     }
     return $_REQUEST['sid'] === substr($sessionid, 16, 16);
 }