18 require_once SQ_CORE_PACKAGE_PATH.
'/system/authentication/authentication/authentication.inc';
61 $bind_vars = Array(
'user_name' => $username);
69 throw new Exception(
'Unable to locate user with user name "'.$username.
'" due to a database error: '.$e->getMessage());
72 if (isset($result[
'assetid']) && !empty($result[
'assetid'])) {
73 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($result[
'assetid']);
105 if(SQ_CONF_FORCE_LOWERCASE_USERNAME) {
106 $username_lowercase = strtolower($username);
107 $user_lowercase = $this->
locateUser($username_lowercase);
108 if(!is_null($user_lowercase) && in_array(get_class($user_lowercase), Array(
'User',
'Simple_Edit_User',
'Backend_User',
'System_User')))
109 $user = $user_lowercase;
115 if (is_null($user)) {
117 }
else if (!$user->comparePassword($password)) {
122 unset($_SESSION[
'user_login_attempts']);
144 if (SQ_CONF_MAX_LOGIN_ATTEMPTS == 0)
return;
146 $username = $user->attr(
'username');
147 if (!isset($_SESSION[
'user_login_attempts'])) {
148 $_SESSION[
'user_login_attempts'] = Array();
150 if (!isset($_SESSION[
'user_login_attempts'][$username])) {
151 $_SESSION[
'user_login_attempts'][$username] = 1;
153 $_SESSION[
'user_login_attempts'][$username]++;
156 if ($_SESSION[
'user_login_attempts'][$username] >= SQ_CONF_MAX_LOGIN_ATTEMPTS) {
157 unset($_SESSION[
'user_login_attempts']);
159 if (!is_null($user) && $user->canLogin()) {
161 $root_user = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_user');
162 if ($GLOBALS[
'SQ_SYSTEM']->setCurrentUser($root_user)) {
164 $changed_runlevel = FALSE;
167 if ($GLOBALS[
'SQ_SYSTEM']->runLevelEnables(SQ_SECURITY_STATUS_INTEGRITY)) {
169 $changed_runlevel = TRUE;
170 $GLOBALS[
'SQ_SYSTEM']->setRunLevel($GLOBALS[
'SQ_SYSTEM']->getRunLevel() - SQ_SECURITY_STATUS_INTEGRITY);
174 if ($user->processStatusChange(SQ_STATUS_UNDER_CONSTRUCTION)) {
177 $GLOBALS[
'SQ_SYSTEM']->restoreCurrentUser();
180 if ($changed_runlevel) {
181 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
188 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
189 $name = $user->name.
' (Id: #'.$user->id.
')';
191 'user_name' => $name,
192 'num_attempts' => (
int)SQ_CONF_MAX_LOGIN_ATTEMPTS,
194 $log = $ms->newMessage(Array(),
'system.security.locked', $msg_reps);
195 $log->parameters[
'remote_addr'] = $_SERVER[
'REMOTE_ADDR'];
196 $log->parameters[
'sessionid'] = session_id();
220 $bind_vars = Array(
'user_name' => $username);
222 if (empty($result)) {
225 $result = $result[0];
228 throw new Exception(
'Unable to locate user with user name "'.$username.
'" due to a database error: '.$e->getMessage());
232 if (isset($result[
'assetid']) && !empty($result[
'assetid'])) {
233 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($result[
'assetid']);