X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fguest%2Fwhat-login.php;h=e888b2cbbb076e89571c46c7ea2043a801b36b43;hb=0f9bc55be42f9851cc87a06f3971c853a83425a7;hp=23d2f9df8b82fdebf3fd022d2562e034b499fe2e;hpb=3daede4c904e23905c3e48dd6749019deca0a0e0;p=mailer.git diff --git a/inc/modules/guest/what-login.php b/inc/modules/guest/what-login.php index 23d2f9df8b..e888b2cbbb 100644 --- a/inc/modules/guest/what-login.php +++ b/inc/modules/guest/what-login.php @@ -1,7 +1,7 @@ 0)) $userid = bigintval(postRequestParameter('id')); } else { // Not logged in - $uid = 0; $hash = ""; + $userid = '0'; $hash = ''; } -// Set unset variables -if (empty($_POST['new_pass'])) $_POST['new_pass'] = ""; -if (empty($_GET['login'])) $_GET['login'] = ""; - -if (IS_MEMBER()) { +if (isMember()) { // Login immidiately... - $URL = "modules.php?module=login"; -} elseif ((isset($_POST['ok'])) && ("".$uid."" != "".$_POST['id']."")) { + $url = 'modules.php?module=login'; +} elseif ((isFormSent()) && ('' . $userid . '' != '' . postRequestParameter('id') . '')) { // Invalid input (no nickname extension installed but nickname entered) - $ERROR = CODE_EXTENSION_PROBLEM; -} elseif (isset($_POST['ok'])) { + $errorCode = getCode('EXTENSION_PROBLEM'); +} elseif (isFormSent()) { // Try the login (see inc/libs/user_functions.php) - $URL = USER_DO_LOGIN($_POST['id'], $_POST['password']); -} elseif ((!empty($_POST['new_pass'])) && (isset($uid))) { + $url = doUserLogin(postRequestParameter('id'), postRequestParameter('password')); +} elseif ((isPostRequestParameterSet('new_pass')) && (isset($userid))) { // Try the userid/email lookup (see inc/libs/user_functions.php) - $ERROR = USER_DO_NEW_PASSWORD($_POST['email'], $uid); + $errorCode = doNewUserPassword(postRequestParameter('email'), $userid); } // Login problems? -if (!empty($_GET['login'])) { +if (isGetRequestParameterSet('login')) { // Use code from URL - $ERROR = SQL_ESCAPE($_GET['login']); + $errorCode = getRequestParameter('login'); } // END - if -// Login problems? -if (!empty($ERROR)) { - // Ok, which one now? - $MSG = " -   - - "; - - switch ($ERROR) { - case CODE_WRONG_PASS: - $MSG .= LOGIN_WRONG_PASS; - break; - - case CODE_WRONG_ID: - $MSG .= LOGIN_WRONG_ID; - break; +// No problems, no output by detault +$content['message'] = ''; - case CODE_ID_LOCKED: - $MSG .= LOGIN_ID_LOCKED; - break; - - case CODE_ID_UNCONFIRMED: - $MSG .= LOGIN_ID_UNCONFIRMED; - break; - - case CODE_NO_COOKIES: - $MSG .= LOGIN_NO_COOKIES; - break; - - case CODE_EXTENSION_PROBLEM: - if (IS_ADMIN()) { - $MSG .= sprintf(EXTENSION_PROBLEM_NOT_INSTALLED, "nickname"); - } else { - $MSG .= LOGIN_WRONG_ID; - } - break; - - default: - DEBUG_LOG(__FILE__, __LINE__, sprintf("Unhandled error code %s detected.", $ERROR)); - $MSG .= LOGIN_WRONG_ID; - break; - } - $MSG .= " +// Login problems? +if (!empty($errorCode)) { + // Do we have a userid set? + if (isSessionVariableSet('current_userid')) { + // Then prefetch data for this account + fetchUserData(getSession('current_userid')); + } // END - if + + // @TODO Move this HTML code into a template + $content['message'] = ' + + ' . getMessageFromErrorCode($errorCode) . ' -   -\n"; - define('LOGIN_FAILURE_MSG', $MSG); -} else { - // No problems, no output - define('LOGIN_FAILURE_MSG', ""); -} +'; +} // END - if // Display login form with resend-password form -if (EXT_IS_ACTIVE("nickname")) { - LOAD_TEMPLATE("guest_nickname_login"); +if (isExtensionActive('nickname')) { + loadTemplate('guest_nickname_login', false, $content); } else { - LOAD_TEMPLATE("guest_login"); + loadTemplate('guest_login', false, $content); } // Was an URL constructed? -if (!empty($URL)) { +if (!empty($url)) { // URL was constructed - if (getTotalFatalErrorMessages()) { - // Fatal errors! - require_once(PATH."inc/fatal_errors.php"); + if (ifFatalErrorsDetected()) { + // Handle fatal errors + runFilterChain('handle_fatal_errors'); } else { // Load URL - LOAD_URL($URL); + redirectToUrl($url); } } // END - if -// +// [EOF] ?>