]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/guest/what-login.php
Added update_year.sh (still not fully flexible) and updated all years with it.
[mailer.git] / inc / modules / guest / what-login.php
index 62cca5a2383fdcd99fbab3ccefe91e742cddc05e..7d2e4378957614d9d2534441e28777ce64f0eb0d 100644 (file)
  * Kurzbeschreibung  : Loginbereich (leitet an das richtige Lgin-Modul  *
  *                     weiter)                                          *
  * -------------------------------------------------------------------- *
- * $Revision::                                                        $ *
- * $Date::                                                            $ *
- * $Tag:: 0.2.1-FINAL                                                 $ *
- * $Author::                                                          $ *
- * Needs to be in all Files and every File needs "svn propset           *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
- * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
- * For more information visit: http://www.mxchange.org                  *
+ * Copyright (c) 2009 - 2015 by Mailer Developer Team                   *
+ * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  * it under the terms of the GNU General Public License as published by *
 
 // Some security stuff...
 if (!defined('__SECURITY')) {
-       die();
-}
+       exit();
+} // END - if
 
 // Add description as navigation point
-addMenuDescription('guest', __FILE__);
+addYouAreHereLink('guest', __FILE__);
 
 if ((!isExtensionActive('user')) && (!isAdmin())) {
-       loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('user'));
+       displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=user%}');
        return;
 } // END - if
 
-// Initialize variables
+// Initialize variables as not logged in
 $errorCode = '0';
-$userid = false;
+$userid = NULL;
 $hash = '';
-$URL = '';
+$url = '';
 $add = '';
 
 // Already logged in?
 if ((isMemberIdSet()) && (isSessionVariableSet('u_hash'))) {
        // Maybe, then continue with it
        $userid = getMemberId();
-} elseif ((isPostRequestParameterSet('id')) && (isPostRequestParameterSet('password')) && (isFormSent())) {
+} elseif ((isPostRequestElementSet('id')) && (isPostRequestElementSet('password')) && (isFormSent('login'))) {
        // Set userid and crypt password when login data was submitted
-       if ((isExtensionActive('nickname')) && (isNicknameUsed(postRequestParameter('id')))) {
+       if (isNicknameUsed(postRequestElement('id'))) {
                // Nickname entered
-               $userid = SQL_ESCAPE(postRequestParameter('id'));
+               $userid = sqlEscapeString(postRequestElement('id'));
        } else {
                // Direct userid entered
-               $userid  = bigintval(postRequestParameter('id'));
+               $userid  = bigintval(postRequestElement('id'));
        }
-} elseif (isPostRequestParameterSet('new_pass')) {
+} elseif (isPostRequestElementSet('new_pass')) {
        // New password requested
-       $userid = '0';
-       if ((isPostRequestParameterSet('id')) && (postRequestParameter('id') > 0)) $userid = bigintval(postRequestParameter('id'));
-} else {
-       // Not logged in
-       $userid = '0'; $hash = '';
+       $userid = NULL;
+       if (isPostRequestElementSet('email')) {
+               // Email is set
+               $userid = sqlEscapeString(postRequestElement('email'));
+       } elseif (isPostRequestElementSet('id')) {
+               // Is there nickname or userid?
+               if (isNicknameUsed(postRequestElement('id'))) {
+                       // Nickname entered
+                       $userid = sqlEscapeString(postRequestElement('id'));
+               } else {
+                       // Direct userid entered
+                       $userid  = bigintval(postRequestElement('id'));
+               }
+       } // END - if
 }
 
 if (isMember()) {
        // Login immidiately...
-       $URL = 'modules.php?module=login';
-} elseif ((isFormSent()) && ('' . $userid . '' != '' . postRequestParameter('id') . '')) {
+       $url = 'modules.php?module=login';
+} elseif ((isFormSent('login')) && ('' . $userid . '' != '' . postRequestElement('id') . '')) {
        // Invalid input (no nickname extension installed but nickname entered)
        $errorCode = getCode('EXTENSION_PROBLEM');
-} elseif (isFormSent()) {
-       // Try the login (see inc/libs/user_functions.php)
-       $URL = doUserLogin(postRequestParameter('id'), postRequestParameter('password'));
-} elseif ((isPostRequestParameterSet('new_pass')) && (isset($userid))) {
+} elseif (isFormSent('login')) {
+       // Are both 'id' and 'password' set?
+       if ((isPostRequestElementSet('id')) && (isPostRequestElementSet('password'))) {
+               // Try the login (see inc/libs/user_functions.php)
+               $url = doUserLogin(postRequestElement('id'), postRequestElement('password'));
+       } elseif (!isPostRequestElementSet('id')) {
+               // Empty 'id'
+               $errorCode = getCode('LOGIN_EMPTY_ID');
+       } else {
+               // Empty 'password'
+               $errorCode = getCode('LOGIN_EMPTY_PASSWORD');
+       }
+} elseif ((isPostRequestElementSet('new_pass')) && (!empty($userid))) {
        // Try the userid/email lookup (see inc/libs/user_functions.php)
-       $errorCode = doNewUserPassword(postRequestParameter('email'), $userid);
+       $errorCode = doNewUserPassword(postRequestElement('email'), $userid);
 }
 
 // Login problems?
-if (isGetRequestParameterSet('login')) {
+if (isGetRequestElementSet('login')) {
        // Use code from URL
-       $errorCode = getRequestParameter('login');
+       $errorCode = getRequestElement('login');
 } // END  - if
 
 // No problems, no output by detault
@@ -105,43 +116,32 @@ $content['message'] = '';
 
 // Login problems?
 if (!empty($errorCode)) {
-       // @TODO Move this HTML code into a template
-       $message = "<tr>
-  <td colspan=\"4\" align=\"center\">
-    <span class=\"guest_failed\">";
-
-       // Do we have a userid set?
-       if (isSessionVariableSet('current_userid')) {
+       // Is there a userid set?
+       if (isSessionVariableSet('userid')) {
                // Then prefetch data for this account
-               fetchUserData(getSession('current_userid'));
+               fetchUserData(getSession('userid'));
        } // END - if
 
-       // Convert the code to message
-       $message .= getMessageFromErrorCode($errorCode);
-
-       // Continue with HTML
-       $message .= "</span>
-  </td>
-</tr>\n";
-       $content['message'] = $message;
+       // Add message code
+       $content['message'] = loadTemplate('guest_login_error_message', TRUE, $errorCode);
 } // END - if
 
 // Display login form with resend-password form
 if (isExtensionActive('nickname')) {
-       loadTemplate('guest_nickname_login', false, $content);
+       loadTemplate('guest_nickname_login', FALSE, $content);
 } else {
-       loadTemplate('guest_login', false, $content);
+       loadTemplate('guest_login', FALSE, $content);
 }
 
 // Was an URL constructed?
-if (!empty($URL)) {
+if (!empty($url)) {
        // URL was constructed
-       if (getTotalFatalErrors() > 0) {
+       if (ifFatalErrorsDetected()) {
                // Handle fatal errors
                runFilterChain('handle_fatal_errors');
        } else {
                // Load URL
-               redirectToUrl($URL);
+               redirectToUrl($url);
        }
 } // END - if