]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/guest/what-login.php
Cleanups and all "base scripts" fixed:
[mailer.git] / inc / modules / guest / what-login.php
index 901f7b8c69dfadb4dd53372f62ab0634abd85b58..60228452a64087e401424d8b2d586f4a6ad6044f 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 10/14/2003 *
- * ===============                              Last change: 04/28/2004 *
+ * Mailer v0.2.1-FINAL                                Start: 10/14/2003 *
+ * ===================                          Last change: 04/28/2004 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : what-login.php                                   *
  * $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                           *
- * For more information visit: http://www.mxchange.org                  *
+ * Copyright (c) 2009 - 2011 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();
-}
+} // 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
 
@@ -54,7 +53,7 @@ if ((!isExtensionActive('user')) && (!isAdmin())) {
 $errorCode = '0';
 $userid = false;
 $hash = '';
-$URL = '';
+$url = '';
 $add = '';
 
 // Already logged in?
@@ -63,7 +62,7 @@ if ((isMemberIdSet()) && (isSessionVariableSet('u_hash'))) {
        $userid = getMemberId();
 } elseif ((isPostRequestElementSet('id')) && (isPostRequestElementSet('password')) && (isFormSent())) {
        // Set userid and crypt password when login data was submitted
-       if ((isExtensionActive('nickname')) && (isNicknameOrUserid(postRequestElement('id')))) {
+       if (isNicknameUsed(postRequestElement('id'))) {
                // Nickname entered
                $userid = SQL_ESCAPE(postRequestElement('id'));
        } else {
@@ -72,23 +71,36 @@ if ((isMemberIdSet()) && (isSessionVariableSet('u_hash'))) {
        }
 } elseif (isPostRequestElementSet('new_pass')) {
        // New password requested
-       $userid = '0';
-       if (isPostRequestElementSet('id')) $userid = bigintval(postRequestElement('id'));
+       $userid = NULL;
+       if (isPostRequestElementSet('email')) {
+               // Email is set
+               $userid = SQL_ESCAPE(postRequestElement('email'));
+       } elseif (isPostRequestElementSet('id')) {
+               // Do we have nickname or userid?
+               if (isNicknameUsed(postRequestElement('id'))) {
+                       // Nickname entered
+                       $userid = SQL_ESCAPE(postRequestElement('id'));
+               } else {
+                       // Direct userid entered
+                       $userid  = bigintval(postRequestElement('id'));
+               }
+       } // END - if
 } else {
        // Not logged in
-       $userid = '0'; $hash = '';
+       $userid = NULL;
+       $hash = '';
 }
 
 if (isMember()) {
        // Login immidiately...
-       $URL = 'modules.php?module=login';
+       $url = 'modules.php?module=login';
 } elseif ((isFormSent()) && ('' . $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(postRequestElement('id'), postRequestElement('password'));
-} elseif ((isPostRequestElementSet('new_pass')) && (isset($userid))) {
+       $url = doUserLogin(postRequestElement('id'), postRequestElement('password'));
+} elseif ((isPostRequestElementSet('new_pass')) && (!empty($userid))) {
        // Try the userid/email lookup (see inc/libs/user_functions.php)
        $errorCode = doNewUserPassword(postRequestElement('email'), $userid);
 }
@@ -104,21 +116,18 @@ $content['message'] = '';
 
 // Login problems?
 if (!empty($errorCode)) {
-       // @TODO Move this HTML code into a template
-       $message = "<tr>
-  <td width=\"10\" class=\"seperator\">&nbsp;</td>
-  <td colspan=\"7\" align=\"center\">
-    <span class=\"guest_failed\">";
+       // Do we have a userid set?
+       if (isSessionVariableSet('current_userid')) {
+               // Then prefetch data for this account
+               fetchUserData(getSession('current_userid'));
+       } // END - if
 
-       // Convert the code to message
-       $message .= getMessageFromErrorCode($errorCode);
-
-       // Continue with HTML
-       $message .= "</span>
+       // @TODO Move this HTML code into a template
+       $content['message'] = '<tr>
+  <td colspan="4" align="center">
+    <span class="bad">' . getMessageFromErrorCode($errorCode) . '</span>
   </td>
-  <td width=\"10\" class=\"seperator\">&nbsp;</td>
-</tr>\n";
-       $content['message'] = $message;
+</tr>';
 } // END - if
 
 // Display login form with resend-password form
@@ -129,14 +138,14 @@ if (isExtensionActive('nickname')) {
 }
 
 // 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