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 * -------------------------------------------------------------------- *
15 * -------------------------------------------------------------------- *
16 * Copyright (c) 2003 - 2008 by Roland Haeder *
17 * For more information visit: http://www.mxchange.org *
19 * This program is free software; you can redistribute it and/or modify *
20 * it under the terms of the GNU General Public License as published by *
21 * the Free Software Foundation; either version 2 of the License, or *
22 * (at your option) any later version. *
24 * This program is distributed in the hope that it will be useful, *
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27 * GNU General Public License for more details. *
29 * You should have received a copy of the GNU General Public License *
30 * along with this program; if not, write to the Free Software *
31 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
33 ************************************************************************/
35 // Some security stuff...
36 if (!defined('__SECURITY')) {
37 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
39 } elseif ((!EXT_IS_ACTIVE("user")) && (!IS_ADMIN())) {
40 addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), "user");
44 // Add description as navigation point
45 ADD_DESCR("guest", __FILE__);
49 // Initialize variables
51 $probe_nickname = false;
58 if ((!empty($GLOBALS['userid'])) && (isSessionVariableSet('u_hash'))) {
59 // Maybe, then continue with it
60 $uid = $GLOBALS['userid'];
61 } elseif ((REQUEST_ISSET_POST(('id'))) && (REQUEST_ISSET_POST(('password'))) && (IS_FORM_SENT())) {
62 // Set userid and crypt password when login data was submitted
63 if ((EXT_IS_ACTIVE("nickname")) && (NICKNAME_PROBE_ON_USERID(REQUEST_POST('id')))) {
65 $uid = SQL_ESCAPE(REQUEST_POST('id'));
67 // Direct userid entered
68 $uid = bigintval(REQUEST_POST('id'));
70 } elseif (REQUEST_ISSET_POST(('new_pass'))) {
71 // New password requested
73 if (REQUEST_ISSET_POST(('id'))) $uid = REQUEST_POST('id');
79 // Set unset variables
80 if (!REQUEST_ISSET_POST(('new_pass'))) REQUEST_SET_POST('new_pass', "");
81 if (!REQUEST_ISSET_GET(('login'))) REQUEST_SET_GET('login' , "");
84 // Login immidiately...
85 $URL = "modules.php?module=login";
86 } elseif ((IS_FORM_SENT()) && ("".$uid."" != "".REQUEST_POST('id')."")) {
87 // Invalid input (no nickname extension installed but nickname entered)
88 $ERROR = constant('CODE_EXTENSION_PROBLEM');
89 } elseif (IS_FORM_SENT()) {
90 // Try the login (see inc/libs/user_functions.php)
91 $URL = USER_DO_LOGIN(REQUEST_POST('id'), REQUEST_POST('password'));
92 } elseif ((REQUEST_ISSET_POST(('new_pass'))) && (isset($uid))) {
93 // Try the userid/email lookup (see inc/libs/user_functions.php)
94 $ERROR = USER_DO_NEW_PASSWORD(REQUEST_POST('email'), $uid);
98 if (REQUEST_ISSET_GET(('login'))) {
100 $ERROR = REQUEST_GET(('login'));
104 if (!empty($ERROR)) {
105 // Ok, which one now?
107 <td width=\"10\" class=\"seperator\"> </td>
108 <td colspan=\"7\" align=\"center\">
109 <span class=\"guest_failed\">";
112 case constant('CODE_WRONG_PASS'):
113 $MSG .= getMessage('LOGIN_WRONG_PASS');
116 case constant('CODE_WRONG_ID'):
117 $MSG .= getMessage('LOGIN_WRONG_ID');
120 case constant('CODE_ID_LOCKED'):
121 $MSG .= getMessage('LOGIN_ID_LOCKED');
124 case constant('CODE_ID_UNCONFIRMED'):
125 $MSG .= getMessage('LOGIN_ID_UNCONFIRMED');
128 case constant('CODE_NO_COOKIES'):
129 $MSG .= getMessage('LOGIN_NO_COOKIES');
132 case constant('CODE_EXTENSION_PROBLEM'):
134 $MSG .= sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), "nickname");
136 $MSG .= getMessage('LOGIN_WRONG_ID');
141 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unhandled error code %s detected.", $ERROR));
142 $MSG .= getMessage('LOGIN_WRONG_ID');
147 <td width=\"10\" class=\"seperator\"> </td>
149 define('LOGIN_FAILURE_MSG', $MSG);
151 // No problems, no output
152 define('LOGIN_FAILURE_MSG', "");
155 // Display login form with resend-password form
156 if (EXT_IS_ACTIVE("nickname")) {
157 LOAD_TEMPLATE("guest_nickname_login");
159 LOAD_TEMPLATE("guest_login");
162 // Was an URL constructed?
164 // URL was constructed
165 if (getTotalFatalErrors()) {
167 LOAD_INC_ONCE("inc/fatal_errors.php");