function do_login() { $aExtra = array(); $oUser =& KTInterceptorRegistry::checkInterceptorsForAuthenticated(); if (is_a($oUser, 'User')) { $res = $this->performLogin($oUser); if ($res) { $oUser = array($res); } } if (is_array($oUser)) { foreach ($oUser as $oError) { if (is_a($oError, 'KTNoLocalUser')) { $aExtra = kt_array_merge($aExtra, $oError->aExtra); } } } KTInterceptorRegistry::checkInterceptorsForTakeOver(); $this->check(); global $default; $language = KTUtil::arrayGet($_REQUEST, 'language'); if (empty($language)) { $language = $default->defaultLanguage; } setcookie("kt_language", $language, 2147483647, '/'); $redirect = strip_tags(KTUtil::arrayGet($_REQUEST, 'redirect')); $url = $_SERVER["PHP_SELF"]; $queryParams = array(); if (!empty($redirect)) { $queryParams[] = 'redirect=' . urlencode($redirect); } $username = KTUtil::arrayGet($_REQUEST, 'username'); $password = KTUtil::arrayGet($_REQUEST, 'password'); if (empty($username)) { $this->simpleRedirectToMain(_kt('Please enter your username.'), $url, $queryParams); } $oUser =& User::getByUsername($username); if (PEAR::isError($oUser) || $oUser === false) { if (is_a($oUser, 'ktentitynoobjects')) { $this->handleUserDoesNotExist($username, $password, $aExtra); } $this->simpleRedirectToMain(_kt('Login failed. Please check your username and password, and try again.'), $url, $queryParams); exit(0); } if (empty($password)) { $this->simpleRedirectToMain(_kt('Please enter your password.'), $url, $queryParams); } $authenticated = KTAuthenticationUtil::checkPassword($oUser, $password); if (PEAR::isError($authenticated)) { $this->simpleRedirectToMain(_kt('Authentication failure. Please try again.'), $url, $queryParams); exit(0); } if ($authenticated !== true) { $this->simpleRedirectToMain(_kt('Login failed. Please check your username and password, and try again.'), $url, $queryParams); exit(0); } $res = $this->performLogin($oUser); if ($res) { $this->simpleRedirectToMain($res->getMessage(), $url, $queryParams); exit(0); } }