本文整理汇总了PHP中ca_users::setLastLogout方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_users::setLastLogout方法的具体用法?PHP ca_users::setLastLogout怎么用?PHP ca_users::setLastLogout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_users
的用法示例。
在下文中一共展示了ca_users::setLastLogout方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doAuthentication
//.........这里部分代码省略.........
}
if ($vb_login_successful) {
// Login was successful
$this->session->setVar($vs_app_name . "_lastping", time());
// set last time we heard from client in session
$this->user->setLastPing(time());
$AUTH_CURRENT_USER_ID = $vn_user_id;
//$this->user->close(); ** will be called externally **
return $vb_login_successful;
}
}
if (!$vb_login_successful) {
$this->user = new ca_users();
// add user object
$vs_tmp1 = $vs_tmp2 = null;
if ($vn_auth_type = $this->user->authenticate($vs_tmp1, $vs_tmp2, $pa_options["options"])) {
# error means user_id in session is invalid
if ($pa_options['noPublicUsers'] && $this->user->isPublicUser() || !$this->user->isActive()) {
$o_event_log->log(array("CODE" => "LOGF", "SOURCE" => "Auth", "MESSAGE" => "Failed login for user id '" . $vn_user_id . "' (" . $_SERVER['REQUEST_URI'] . "); IP=" . $_SERVER["REMOTE_ADDR"] . "; user agent='" . $_SERVER["HTTP_USER_AGENT"] . "'"));
$vb_login_successful = false;
} else {
$vb_login_successful = true;
$vn_user_id = $this->user->getUserID();
}
}
if (!$vb_login_successful) {
// throw user to login screen
if (!$pa_options["dont_redirect_to_login"]) {
$o_event_log->log(array("CODE" => "LOGF", "SOURCE" => "Auth", "MESSAGE" => "Failed login with redirect for user id '" . $vn_user_id . "' (" . $_SERVER['REQUEST_URI'] . "); IP=" . $_SERVER["REMOTE_ADDR"] . "; user agent='" . $_SERVER["HTTP_USER_AGENT"] . "'"));
$vs_redirect = $this->getRequestUrl(true);
if (strpos($vs_redirect, $this->config->get("auth_login_path") !== -1)) {
$vs_redirect = '';
} else {
$vs_redirect = '?redirect=' . urlencode($vs_redirect);
}
$this->opo_response->addHeader("Location", $this->getBaseUrlPath() . '/' . $this->getScriptName() . '/' . $this->config->get("auth_login_path") . $vs_redirect);
}
return false;
}
}
}
//
// incoming login
//
if ($pa_options["user_name"]) {
$vb_login_successful = false;
$this->user = new ca_users();
if ($vn_auth_type = $this->user->authenticate($pa_options["user_name"], $pa_options["password"], $pa_options["options"])) {
# error means user_id in session is invalid
if ($pa_options['noPublicUsers'] && $this->user->isPublicUser() || !$this->user->isActive()) {
$vb_login_successful = false;
} else {
$vb_login_successful = true;
$vn_user_id = $this->user->getUserID();
}
}
}
if (!$vb_login_successful) {
$this->user = null;
// auth failed
// throw user to login screen
if ($pa_options["user_name"]) {
$o_event_log->log(array("CODE" => "LOGF", "SOURCE" => "Auth", "MESSAGE" => "Failed login for '" . $pa_options["user_name"] . "' (" . $_SERVER['REQUEST_URI'] . "); IP=" . $_SERVER["REMOTE_ADDR"] . "; user agent='" . $_SERVER["HTTP_USER_AGENT"] . "'"));
}
if (!$pa_options["dont_redirect_to_login"]) {
$vs_auth_login_url = $this->getBaseUrlPath() . '/' . $this->getScriptName() . '/' . $this->config->get("auth_login_path");
$this->opo_response->addHeader("Location", $vs_auth_login_url);
}
return false;
} else {
$o_event_log->log(array("CODE" => "LOGN", "SOURCE" => "Auth", "MESSAGE" => "Successful login for '" . $pa_options["user_name"] . "'; IP=" . $_SERVER["REMOTE_ADDR"] . "; user agent=" . $_SERVER["HTTP_USER_AGENT"]));
$this->session->setVar($vs_app_name . "_user_auth_type", $vn_auth_type);
// type of auth used: 1=username/password; 2=ip-base auth
$this->session->setVar($vs_app_name . "_user_id", $vn_user_id);
// auth succeeded; set user_id in session
$this->session->setVar($vs_app_name . "_logintime", time());
// also set login time (unix timestamp) in session
$this->session->setVar($vs_app_name . "_lastping", time());
$this->session->setVar("screen_width", isset($_REQUEST["_screen_width"]) ? intval($_REQUEST["_screen_width"]) : 0);
$this->session->setVar("screen_height", isset($_REQUEST["_screen_height"]) ? intval($_REQUEST["_screen_height"]) : 0);
$this->session->setVar("has_pdf_plugin", isset($_REQUEST["_has_pdf_plugin"]) ? intval($_REQUEST["_has_pdf_plugin"]) : 0);
$this->user->setVar('last_login', time(), array('volatile' => true));
$this->user->setLastLogout($this->user->getLastPing(), array('volatile' => true));
//$this->user->close(); ** will be called externally **
$AUTH_CURRENT_USER_ID = $vn_user_id;
if ($pa_options['redirect']) {
// redirect to specified URL
$this->opo_response->setRedirect($pa_options['redirect']);
$this->opo_response->sendResponse();
exit;
}
if (!$pa_options["dont_redirect_to_welcome"]) {
// redirect to "welcome" page
$this->opo_response->setRedirect($this->getBaseUrlPath() . '/' . $this->getScriptName() . '/' . $this->config->get("auth_login_welcome_path"));
$this->opo_response->sendResponse();
exit;
}
return true;
}
}