]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/guest/what-login.php
Rewrote 'we' word a little, rewrote mail order to use SQL_INSERTID() instead of anoth...
[mailer.git] / inc / modules / guest / what-login.php
index 3cad847ee16e55f3d1f926961c2b1536abae077b..708239941d06f04deed6cd2a484f4d378b6f4c9c 100644 (file)
@@ -17,8 +17,8 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
- * For more information visit: http://www.mxchange.org                  *
+ * Copyright (c) 2009 - 2012 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 *
@@ -38,7 +38,7 @@
 
 // Some security stuff...
 if (!defined('__SECURITY')) {
-       die();
+       exit();
 } // END - if
 
 // Add description as navigation point
@@ -60,55 +60,64 @@ $add = '';
 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 (isNicknameUsed(postRequestParameter('id'))) {
+       if (isNicknameUsed(postRequestElement('id'))) {
                // Nickname entered
-               $userid = SQL_ESCAPE(postRequestParameter('id'));
+               $userid = SQL_ESCAPE(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('email')) {
+       $userid = NULL;
+       if (isPostRequestElementSet('email')) {
                // Email is set
-               $userid = SQL_ESCAPE(postRequestParameter('email'));
-       } elseif (isPostRequestParameterSet('id')) {
-               // Do we have nickname or userid?
-               if (isNicknameUsed(postRequestParameter('id'))) {
+               $userid = SQL_ESCAPE(postRequestElement('email'));
+       } elseif (isPostRequestElementSet('id')) {
+               // Is there nickname or userid?
+               if (isNicknameUsed(postRequestElement('id'))) {
                        // Nickname entered
-                       $userid = SQL_ESCAPE(postRequestParameter('id'));
+                       $userid = SQL_ESCAPE(postRequestElement('id'));
                } else {
                        // Direct userid entered
-                       $userid  = bigintval(postRequestParameter('id'));
+                       $userid  = bigintval(postRequestElement('id'));
                }
        } // END - if
 } else {
        // Not logged in
-       $userid = '0';
+       $userid = NULL;
        $hash = '';
 }
 
 if (isMember()) {
        // Login immidiately...
        $url = 'modules.php?module=login';
-} elseif ((isFormSent()) && ('' . $userid . '' != '' . postRequestParameter('id') . '')) {
+} 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
@@ -116,18 +125,14 @@ $content['message'] = '';
 
 // Login problems?
 if (!empty($errorCode)) {
-       // 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
 
        // @TODO Move this HTML code into a template
-       $content['message'] = '<tr>
-  <td colspan="4" align="center">
-    <span class="notice">' . getMessageFromErrorCode($errorCode) . '</span>
-  </td>
-</tr>';
+       $content['message'] = loadTemplate('guest_login_error_message', true, $errorCode);
 } // END - if
 
 // Display login form with resend-password form