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__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), 'user');
49 // Add description as navigation point
50 ADD_DESCR('guest', __FILE__);
54 // Initialize variables
56 $probe_nickname = false;
63 if ((isUserIdSet()) && (isSessionVariableSet('u_hash'))) {
64 // Maybe, then continue with it
66 } elseif ((REQUEST_ISSET_POST(('id'))) && (REQUEST_ISSET_POST(('password'))) && (IS_FORM_SENT())) {
67 // Set userid and crypt password when login data was submitted
68 if ((EXT_IS_ACTIVE('nickname')) && (NICKNAME_PROBE_ON_USERID(REQUEST_POST('id')))) {
70 $uid = SQL_ESCAPE(REQUEST_POST('id'));
72 // Direct userid entered
73 $uid = bigintval(REQUEST_POST('id'));
75 } elseif (REQUEST_ISSET_POST(('new_pass'))) {
76 // New password requested
78 if (REQUEST_ISSET_POST(('id'))) $uid = REQUEST_POST('id');
84 // Set unset variables
85 if (!REQUEST_ISSET_POST(('new_pass'))) REQUEST_SET_POST('new_pass', '');
86 if (!REQUEST_ISSET_GET(('login'))) REQUEST_SET_GET('login' , '');
89 // Login immidiately...
90 $URL = "modules.php?module=login";
91 } elseif ((IS_FORM_SENT()) && ("".$uid."" != "".REQUEST_POST('id')."")) {
92 // Invalid input (no nickname extension installed but nickname entered)
93 $errorCode = getCode('EXTENSION_PROBLEM');
94 } elseif (IS_FORM_SENT()) {
95 // Try the login (see inc/libs/user_functions.php)
96 $URL = USER_DO_LOGIN(REQUEST_POST('id'), REQUEST_POST('password'));
97 } elseif ((REQUEST_ISSET_POST(('new_pass'))) && (isset($uid))) {
98 // Try the userid/email lookup (see inc/libs/user_functions.php)
99 $errorCode = USER_DO_NEW_PASSWORD(REQUEST_POST('email'), $uid);
103 if (REQUEST_ISSET_GET(('login'))) {
105 $errorCode = REQUEST_GET(('login'));
109 if (!empty($errorCode)) {
110 // Ok, which one now?
112 <td width=\"10\" class=\"seperator\"> </td>
113 <td colspan=\"7\" align=\"center\">
114 <span class=\"guest_failed\">";
116 switch ($errorCode) {
117 case getCode('WRONG_PASS'):
118 $message .= getMessage('LOGIN_WRONG_PASS');
121 case getCode('WRONG_ID'):
122 $message .= getMessage('LOGIN_WRONG_ID');
125 case getCode('ID_LOCKED'):
126 $message .= getMessage('LOGIN_ID_LOCKED');
129 case getCode('ID_UNCONFIRMED'):
130 $message .= getMessage('LOGIN_ID_UNCONFIRMED');
133 case getCode('NO_COOKIES'):
134 $message .= getMessage('LOGIN_NO_COOKIES');
137 case getCode('EXTENSION_PROBLEM'):
139 $message .= sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), 'nickname');
141 $message .= getMessage('LOGIN_WRONG_ID');
146 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unhandled error code %s detected.", $errorCode));
147 $message .= getMessage('LOGIN_WRONG_ID');
152 <td width=\"10\" class=\"seperator\"> </td>
154 define('LOGIN_FAILURE_MSG', $message);
156 // No problems, no output
157 define('LOGIN_FAILURE_MSG', '');
160 // Display login form with resend-password form
161 if (EXT_IS_ACTIVE('nickname')) {
162 LOAD_TEMPLATE("guest_nickname_login");
164 LOAD_TEMPLATE("guest_login");
167 // Was an URL constructed?
169 // URL was constructed
170 if (getTotalFatalErrors()) {
172 LOAD_INC_ONCE("inc/fatal_errors.php");