]> 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 deca65efedc093c3e2ed0d29f96aaa426d7adca6..7d2e4378957614d9d2534441e28777ce64f0eb0d 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                                   *
  * Kurzbeschreibung  : Loginbereich (leitet an das richtige Lgin-Modul  *
  *                     weiter)                                          *
  * -------------------------------------------------------------------- *
- * $Revision:: 856                                                    $ *
- * $Date:: 2009-03-06 20:24:32 +0100 (Fr, 06. March 2009)             $ *
- * $Tag:: 0.2.1-FINAL                                                 $ *
- * $Author:: stelzi                                                   $ *
- * Needs to be in all Files and every File needs "svn propset           *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
- * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
- * For more information visit: http://www.mxchange.org                  *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * 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')) {
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
-       require($INC);
-} elseif ((!EXT_IS_ACTIVE("user")) && (!IS_ADMIN())) {
-       addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), "user");
-       return;
-}
+       exit();
+} // END - if
 
 // Add description as navigation point
-ADD_DESCR("guest", __FILE__);
+addYouAreHereLink('guest', __FILE__);
 
-global $DATA, $ERROR;
+if ((!isExtensionActive('user')) && (!isAdmin())) {
+       displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=user%}');
+       return;
+} // END - if
 
-// Initialize variables
-$ERROR = 0;
-$probe_nickname = false;
-$uid = false;
-$hash = "";
-$URL = "";
-$ADD = "";
+// Initialize variables as not logged in
+$errorCode = '0';
+$userid = NULL;
+$hash = '';
+$url = '';
+$add = '';
 
 // Already logged in?
-if ((isUserIdSet()) && (isSessionVariableSet('u_hash'))) {
+if ((isMemberIdSet()) && (isSessionVariableSet('u_hash'))) {
        // Maybe, then continue with it
-       $uid = getUserId();
-} elseif ((REQUEST_ISSET_POST(('id'))) && (REQUEST_ISSET_POST(('password'))) && (IS_FORM_SENT())) {
+       $userid = getMemberId();
+} elseif ((isPostRequestElementSet('id')) && (isPostRequestElementSet('password')) && (isFormSent('login'))) {
        // Set userid and crypt password when login data was submitted
-       if ((EXT_IS_ACTIVE("nickname")) && (NICKNAME_PROBE_ON_USERID(REQUEST_POST('id')))) {
+       if (isNicknameUsed(postRequestElement('id'))) {
                // Nickname entered
-               $uid = SQL_ESCAPE(REQUEST_POST('id'));
+               $userid = sqlEscapeString(postRequestElement('id'));
        } else {
                // Direct userid entered
-               $uid  = bigintval(REQUEST_POST('id'));
+               $userid  = bigintval(postRequestElement('id'));
        }
-} elseif (REQUEST_ISSET_POST(('new_pass'))) {
+} elseif (isPostRequestElementSet('new_pass')) {
        // New password requested
-       $uid = 0;
-       if (REQUEST_ISSET_POST(('id'))) $uid = REQUEST_POST('id');
-} else {
-       // Not logged in
-       $uid = 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
 }
 
-// Set unset variables
-if (!REQUEST_ISSET_POST(('new_pass'))) REQUEST_SET_POST('new_pass', "");
-if (!REQUEST_ISSET_GET(('login')))     REQUEST_SET_GET('login'    , "");
-
-if (IS_MEMBER()) {
+if (isMember()) {
        // Login immidiately...
-       $URL = "modules.php?module=login";
-} elseif ((IS_FORM_SENT()) && ("".$uid."" != "".REQUEST_POST('id')."")) {
+       $url = 'modules.php?module=login';
+} elseif ((isFormSent('login')) && ('' . $userid . '' != '' . postRequestElement('id') . '')) {
        // Invalid input (no nickname extension installed but nickname entered)
-       $ERROR = getCode('EXTENSION_PROBLEM');
-} elseif (IS_FORM_SENT()) {
-       // Try the login (see inc/libs/user_functions.php)
-       $URL = USER_DO_LOGIN(REQUEST_POST('id'), REQUEST_POST('password'));
-} elseif ((REQUEST_ISSET_POST(('new_pass'))) && (isset($uid))) {
+       $errorCode = getCode('EXTENSION_PROBLEM');
+} 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)
-       $ERROR = USER_DO_NEW_PASSWORD(REQUEST_POST('email'), $uid);
+       $errorCode = doNewUserPassword(postRequestElement('email'), $userid);
 }
 
 // Login problems?
-if (REQUEST_ISSET_GET(('login'))) {
+if (isGetRequestElementSet('login')) {
        // Use code from URL
-       $ERROR = REQUEST_GET(('login'));
+       $errorCode = getRequestElement('login');
 } // END  - if
 
-// Login problems?
-if (!empty($ERROR)) {
-       // Ok, which one now?
-       $MSG = "<tr>
-  <td width=\"10\" class=\"seperator\">&nbsp;</td>
-  <td colspan=\"7\" align=\"center\">
-    <span class=\"guest_failed\">";
+// No problems, no output by detault
+$content['message'] = '';
 
-       switch ($ERROR) {
-               case getCode('WRONG_PASS'):
-                       $MSG .= getMessage('LOGIN_WRONG_PASS');
-                       break;
-
-               case getCode('WRONG_ID'):
-                       $MSG .= getMessage('LOGIN_WRONG_ID');
-                       break;
-
-               case getCode('ID_LOCKED'):
-                       $MSG .= getMessage('LOGIN_ID_LOCKED');
-                       break;
-
-               case getCode('ID_UNCONFIRMED'):
-                       $MSG .= getMessage('LOGIN_ID_UNCONFIRMED');
-                       break;
-
-               case getCode('NO_COOKIES'):
-                       $MSG .= getMessage('LOGIN_NO_COOKIES');
-                       break;
-
-               case getCode('EXTENSION_PROBLEM'):
-                       if (IS_ADMIN()) {
-                               $MSG .= sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), "nickname");
-                       } else {
-                               $MSG .= getMessage('LOGIN_WRONG_ID');
-                       }
-                       break;
-
-               default:
-                       DEBUG_LOG(__FILE__, __LINE__, sprintf("Unhandled error code %s detected.", $ERROR));
-                       $MSG .= getMessage('LOGIN_WRONG_ID');
-                       break;
-               }
-               $MSG .= "</span>
-  </td>
-  <td width=\"10\" class=\"seperator\">&nbsp;</td>
-</tr>\n";
-               define('LOGIN_FAILURE_MSG', $MSG);
-} else {
-       // No problems, no output
-       define('LOGIN_FAILURE_MSG', "");
-}
+// Login problems?
+if (!empty($errorCode)) {
+       // Is there a userid set?
+       if (isSessionVariableSet('userid')) {
+               // Then prefetch data for this account
+               fetchUserData(getSession('userid'));
+       } // END - if
+
+       // Add message code
+       $content['message'] = loadTemplate('guest_login_error_message', TRUE, $errorCode);
+} // 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 (getTotalFatalErrors()) {
-               // Fatal errors!
-               LOAD_INC_ONCE("inc/fatal_errors.php");
+       if (ifFatalErrorsDetected()) {
+               // Handle fatal errors
+               runFilterChain('handle_fatal_errors');
        } else {
                // Load URL
-               LOAD_URL($URL);
+               redirectToUrl($url);
        }
 } // END - if
 
-//
+// [EOF]
 ?>