2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 10/14/2003 *
4 * =================== Last change: 04/28/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-login.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Login area (redirects to the real login module) *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Loginbereich (leitet an das richtige Lgin-Modul *
13 * -------------------------------------------------------------------- *
14 * Copyright (c) 2003 - 2009 by Roland Haeder *
15 * Copyright (c) 2009 - 2013 by Mailer Developer Team *
16 * For more information visit: http://mxchange.org *
18 * This program is free software; you can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 * This program is distributed in the hope that it will be useful, *
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
26 * GNU General Public License for more details. *
28 * You should have received a copy of the GNU General Public License *
29 * along with this program; if not, write to the Free Software *
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
32 ************************************************************************/
34 // Some security stuff...
35 if (!defined('__SECURITY')) {
39 // Add description as navigation point
40 addYouAreHereLink('guest', __FILE__);
42 if ((!isExtensionActive('user')) && (!isAdmin())) {
43 displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=user%}');
47 // Initialize variables as not logged in
55 if ((isMemberIdSet()) && (isSessionVariableSet('u_hash'))) {
56 // Maybe, then continue with it
57 $userid = getMemberId();
58 } elseif ((isPostRequestElementSet('id')) && (isPostRequestElementSet('password')) && (isFormSent('login'))) {
59 // Set userid and crypt password when login data was submitted
60 if (isNicknameUsed(postRequestElement('id'))) {
62 $userid = sqlEscapeString(postRequestElement('id'));
64 // Direct userid entered
65 $userid = bigintval(postRequestElement('id'));
67 } elseif (isPostRequestElementSet('new_pass')) {
68 // New password requested
70 if (isPostRequestElementSet('email')) {
72 $userid = sqlEscapeString(postRequestElement('email'));
73 } elseif (isPostRequestElementSet('id')) {
74 // Is there nickname or userid?
75 if (isNicknameUsed(postRequestElement('id'))) {
77 $userid = sqlEscapeString(postRequestElement('id'));
79 // Direct userid entered
80 $userid = bigintval(postRequestElement('id'));
86 // Login immidiately...
87 $url = 'modules.php?module=login';
88 } elseif ((isFormSent('login')) && ('' . $userid . '' != '' . postRequestElement('id') . '')) {
89 // Invalid input (no nickname extension installed but nickname entered)
90 $errorCode = getCode('EXTENSION_PROBLEM');
91 } elseif (isFormSent('login')) {
92 // Are both 'id' and 'password' set?
93 if ((isPostRequestElementSet('id')) && (isPostRequestElementSet('password'))) {
94 // Try the login (see inc/libs/user_functions.php)
95 $url = doUserLogin(postRequestElement('id'), postRequestElement('password'));
96 } elseif (!isPostRequestElementSet('id')) {
98 $errorCode = getCode('LOGIN_EMPTY_ID');
101 $errorCode = getCode('LOGIN_EMPTY_PASSWORD');
103 } elseif ((isPostRequestElementSet('new_pass')) && (!empty($userid))) {
104 // Try the userid/email lookup (see inc/libs/user_functions.php)
105 $errorCode = doNewUserPassword(postRequestElement('email'), $userid);
109 if (isGetRequestElementSet('login')) {
111 $errorCode = getRequestElement('login');
114 // No problems, no output by detault
115 $content['message'] = '';
118 if (!empty($errorCode)) {
119 // Is there a userid set?
120 if (isSessionVariableSet('userid')) {
121 // Then prefetch data for this account
122 fetchUserData(getSession('userid'));
126 $content['message'] = loadTemplate('guest_login_error_message', TRUE, $errorCode);
129 // Display login form with resend-password form
130 if (isExtensionActive('nickname')) {
131 loadTemplate('guest_nickname_login', FALSE, $content);
133 loadTemplate('guest_login', FALSE, $content);
136 // Was an URL constructed?
138 // URL was constructed
139 if (ifFatalErrorsDetected()) {
140 // Handle fatal errors
141 runFilterChain('handle_fatal_errors');