2 /************************************************************************
3 * MXChange v0.2.1 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 * -------------------------------------------------------------------- *
16 * $Tag:: 0.2.1-FINAL $ *
18 * Needs to be in all Files and every File needs "svn propset *
19 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
20 * -------------------------------------------------------------------- *
21 * Copyright (c) 2003 - 2008 by Roland Haeder *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
42 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
44 } elseif ((!EXT_IS_ACTIVE('user')) && (!IS_ADMIN())) {
45 addFatalMessage(__FILE__, __LINE__, generateExtensionInactiveNotInstalledMessage('user'));
49 // Add description as navigation point
50 ADD_DESCR('guest', __FILE__);
54 // Initialize variables
62 if ((isUserIdSet()) && (isSessionVariableSet('u_hash'))) {
63 // Maybe, then continue with it
65 } elseif ((REQUEST_ISSET_POST('id')) && (REQUEST_ISSET_POST(('password'))) && (isFormSent())) {
66 // Set userid and crypt password when login data was submitted
67 if ((EXT_IS_ACTIVE('nickname')) && (NICKNAME_PROBE_ON_USERID(REQUEST_POST('id')))) {
69 $uid = SQL_ESCAPE(REQUEST_POST('id'));
71 // Direct userid entered
72 $uid = bigintval(REQUEST_POST('id'));
74 } elseif (REQUEST_ISSET_POST(('new_pass'))) {
75 // New password requested
77 if (REQUEST_ISSET_POST('id')) $uid = REQUEST_POST('id');
83 // Set unset variables
84 if (!REQUEST_ISSET_POST(('new_pass'))) REQUEST_SET_POST('new_pass', '');
85 if (!REQUEST_ISSET_GET('login')) REQUEST_SET_GET('login' , '');
88 // Login immidiately...
89 $URL = 'modules.php?module=login';
90 } elseif ((isFormSent()) && (''.$uid.'' != ''.REQUEST_POST('id') . '')) {
91 // Invalid input (no nickname extension installed but nickname entered)
92 $errorCode = getCode('EXTENSION_PROBLEM');
93 } elseif (isFormSent()) {
94 // Try the login (see inc/libs/user_functions.php)
95 $URL = USER_DO_LOGIN(REQUEST_POST('id'), REQUEST_POST('password'));
96 } elseif ((REQUEST_ISSET_POST(('new_pass'))) && (isset($uid))) {
97 // Try the userid/email lookup (see inc/libs/user_functions.php)
98 $errorCode = USER_DO_NEW_PASSWORD(REQUEST_POST('email'), $uid);
102 if (REQUEST_ISSET_GET('login')) {
104 $errorCode = REQUEST_GET('login');
108 if (!empty($errorCode)) {
109 // Ok, which one now?
111 <td width=\"10\" class=\"seperator\"> </td>
112 <td colspan=\"7\" align=\"center\">
113 <span class=\"guest_failed\">";
115 switch ($errorCode) {
116 case getCode('WRONG_PASS'):
117 $message .= getMessage('LOGIN_WRONG_PASS');
120 case getCode('WRONG_ID'):
121 $message .= getMessage('LOGIN_WRONG_ID');
124 case getCode('ID_LOCKED'):
125 $message .= getMessage('LOGIN_ID_LOCKED');
128 case getCode('ID_UNCONFIRMED'):
129 $message .= getMessage('LOGIN_ID_UNCONFIRMED');
132 case getCode('NO_COOKIES'):
133 $message .= getMessage('LOGIN_NO_COOKIES');
136 case getCode('EXTENSION_PROBLEM'):
138 $message .= sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), 'nickname');
140 $message .= getMessage('LOGIN_WRONG_ID');
145 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unhandled error code %s detected.", $errorCode));
146 $message .= getMessage('LOGIN_WRONG_ID');
151 <td width=\"10\" class=\"seperator\"> </td>
153 define('LOGIN_FAILURE_MSG', $message);
155 // No problems, no output
156 define('LOGIN_FAILURE_MSG', '');
159 // Display login form with resend-password form
160 if (EXT_IS_ACTIVE('nickname')) {
161 LOAD_TEMPLATE('guest_nickname_login');
163 LOAD_TEMPLATE('guest_login');
166 // Was an URL constructed?
168 // URL was constructed
169 if (getTotalFatalErrors()) {
171 loadIncludeOnce('inc/fatal_errors.php');