public static function setDefault() { self::$data = array('alias' => ZBX_GUEST_USER, 'userid' => 0, 'lang' => 'en_gb', 'type' => '0', 'node' => array('name' => '- unknown -', 'nodeid' => 0)); }
public static function setDefault() { self::$data = array('alias' => ZBX_GUEST_USER, 'userid' => 0, 'lang' => 'en_gb', 'type' => '0', 'debug_mode' => false); }
/** * Check if session id is authenticated. * * @param string $sessionid session id * * @return array an array of user data */ public function checkAuthentication($sessionid) { global $ZBX_LOCALNODEID; // access DB only once per page load if (!is_null(self::$userData)) { return self::$userData; } $time = time(); $userInfo = DBfetch(DBselect('SELECT u.userid,u.autologout,s.lastaccess' . ' FROM sessions s,users u' . ' WHERE s.sessionid=' . zbx_dbstr($sessionid) . ' AND s.status=' . ZBX_SESSION_ACTIVE . ' AND s.userid=u.userid' . ' AND (s.lastaccess+u.autologout>' . $time . ' OR u.autologout=0)' . andDbNode('u.userid', $ZBX_LOCALNODEID))); if (!$userInfo) { self::exception(ZBX_API_ERROR_PARAMETERS, _('Session terminated, re-login, please.')); } // don't check permissions on the same second if ($time != $userInfo['lastaccess']) { if (!check_perm2system($userInfo['userid'])) { self::exception(ZBX_API_ERROR_PARAMETERS, _('No permissions for system access.')); } if ($userInfo['autologout'] > 0) { DBexecute('DELETE FROM sessions WHERE userid=' . $userInfo['userid'] . ' AND lastaccess<' . (time() - $userInfo['autologout'])); } DBexecute('UPDATE sessions SET lastaccess=' . time() . ' WHERE userid=' . $userInfo['userid'] . ' AND sessionid=' . zbx_dbstr($sessionid)); } $dbAccess = DBfetch(DBselect('SELECT MAX(g.gui_access) AS gui_access' . ' FROM usrgrp g,users_groups ug' . ' WHERE ug.userid=' . $userInfo['userid'] . ' AND g.usrgrpid=ug.usrgrpid')); if (!zbx_empty($dbAccess['gui_access'])) { $guiAccess = $dbAccess['gui_access']; } else { $guiAccess = GROUP_GUI_ACCESS_SYSTEM; } $userData = $this->_getUserData($userInfo['userid']); $userData['sessionid'] = $sessionid; $userData['gui_access'] = $guiAccess; CWebUser::$data = self::$userData = $userData; return $userData; }