本文整理汇总了PHP中UserRights::_InitSessionCache方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRights::_InitSessionCache方法的具体用法?PHP UserRights::_InitSessionCache怎么用?PHP UserRights::_InitSessionCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRights
的用法示例。
在下文中一共展示了UserRights::_InitSessionCache方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Login
//.........这里部分代码省略.........
}
break;
case 'external':
// Web server supplied authentication
$bExternalAuth = false;
$sExtAuthVar = MetaModel::GetConfig()->GetExternalAuthenticationVariable();
// In which variable is the info passed ?
eval('$sAuthUser = isset(' . $sExtAuthVar . ') ? ' . $sExtAuthVar . ' : false;');
// Retrieve the value
if ($sAuthUser && strlen($sAuthUser) > 0) {
$sAuthPwd = '';
// No password in this case the web server already authentified the user...
$sLoginMode = 'external';
$sAuthentication = 'external';
}
break;
case 'url':
// Credentials passed directly in the url
$sAuthUser = utils::ReadParam('auth_user', '', false, 'raw_data');
$sAuthPwd = utils::ReadParam('auth_pwd', null, false, 'raw_data');
if ($sAuthUser != '' && $sAuthPwd !== null) {
$sLoginMode = 'url';
}
break;
}
$index++;
}
//echo "\nsLoginMode: $sLoginMode (user: $sAuthUser / pwd: $sAuthPwd\n)";
if ($sLoginMode == '') {
// First connection
$sDesiredLoginMode = utils::ReadParam('login_mode');
if (in_array($sDesiredLoginMode, $aAllowedLoginTypes)) {
$sLoginMode = $sDesiredLoginMode;
} else {
$sLoginMode = $aAllowedLoginTypes[0];
// First in the list...
}
if (array_key_exists('HTTP_X_COMBODO_AJAX', $_SERVER)) {
// X-Combodo-Ajax is a special header automatically added to all ajax requests
// Let's reply that we're currently logged-out
header('HTTP/1.0 401 Unauthorized');
exit;
}
if ($iOnExit == self::EXIT_HTTP_401 || $sLoginMode == 'basic') {
header('WWW-Authenticate: Basic realm="' . Dict::Format('UI:iTopVersion:Short', ITOP_VERSION));
header('HTTP/1.0 401 Unauthorized');
header('Content-type: text/html; charset=iso-8859-1');
exit;
} else {
if ($iOnExit == self::EXIT_RETURN) {
if ($sAuthUser !== '' && $sAuthPwd === null) {
return self::EXIT_CODE_MISSINGPASSWORD;
} else {
return self::EXIT_CODE_MISSINGLOGIN;
}
} else {
$oPage = self::NewLoginWebPage();
$oPage->DisplayLoginForm($sLoginMode, false);
$oPage->output();
exit;
}
}
} else {
if (!UserRights::CheckCredentials($sAuthUser, $sAuthPwd, $sLoginMode, $sAuthentication)) {
//echo "Check Credentials returned false for user $sAuthUser!";
self::ResetSession();
if ($iOnExit == self::EXIT_HTTP_401 || $sLoginMode == 'basic') {
header('WWW-Authenticate: Basic realm="' . Dict::Format('UI:iTopVersion:Short', ITOP_VERSION));
header('HTTP/1.0 401 Unauthorized');
header('Content-type: text/html; charset=iso-8859-1');
exit;
} else {
if ($iOnExit == self::EXIT_RETURN) {
return self::EXIT_CODE_WRONGCREDENTIALS;
} else {
$oPage = self::NewLoginWebPage();
$oPage->DisplayLoginForm($sLoginMode, true);
$oPage->output();
exit;
}
}
} else {
// User is Ok, let's save it in the session and proceed with normal login
UserRights::Login($sAuthUser, $sAuthentication);
// Login & set the user's language
if (MetaModel::GetConfig()->Get('log_usage')) {
$oLog = new EventLoginUsage();
$oLog->Set('userinfo', UserRights::GetUser());
$oLog->Set('user_id', UserRights::GetUserObject()->GetKey());
$oLog->Set('message', 'Successful login');
$oLog->DBInsertNoReload();
}
$_SESSION['auth_user'] = $sAuthUser;
$_SESSION['login_mode'] = $sLoginMode;
UserRights::_InitSessionCache();
}
}
}
return self::EXIT_CODE_OK;
}