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(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 ((!empty($_POST['id'])) && (!empty($_POST['password'])) && (isset($_POST['ok']))) {
62 // Set userid and crypt password when login data was submitted
63 if ((EXT_IS_ACTIVE("nickname")) && (NICKNAME_PROBE_ON_USERID($_POST['id']))) {
65 $uid = SQL_ESCAPE($_POST['id']);
67 // Direct userid entered
68 $uid = bigintval($_POST['id']);
70 } elseif (!empty($_POST['new_pass'])) {
71 // New password requested
73 if (!empty($_POST['id'])) $uid = $_POST['id'];
79 // Set unset variables
80 if (empty($_POST['new_pass'])) $_POST['new_pass'] = "";
81 if (empty($_GET['login'])) $_GET['login'] = "";
84 // Login immidiately...
85 $URL = "modules.php?module=login";
86 } elseif ((isset($_POST['ok'])) && ("".$uid."" != "".$_POST['id']."")) {
87 // Invalid input (no nickname extension installed but nickname entered)
88 $ERROR = CODE_EXTENSION_PROBLEM;
89 } elseif (isset($_POST['ok'])) {
90 // Try the login (see inc/libs/user_functions.php)
91 $URL = USER_DO_LOGIN($_POST['id'], $_POST['password']);
92 } elseif ((!empty($_POST['new_pass'])) && (isset($uid))) {
93 // Try the userid/email lookup (see inc/libs/user_functions.php)
94 $ERROR = USER_DO_NEW_PASSWORD($_POST['email'], $uid);
98 if (!empty($_GET['login'])) {
100 $ERROR = SQL_ESCAPE($_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 CODE_WRONG_PASS:
113 $MSG .= LOGIN_WRONG_PASS;
117 $MSG .= LOGIN_WRONG_ID;
121 $MSG .= LOGIN_ID_LOCKED;
124 case CODE_ID_UNCONFIRMED:
125 $MSG .= LOGIN_ID_UNCONFIRMED;
128 case CODE_NO_COOKIES:
129 $MSG .= LOGIN_NO_COOKIES;
132 case CODE_EXTENSION_PROBLEM:
134 $MSG .= sprintf(EXTENSION_PROBLEM_NOT_INSTALLED, "nickname");
136 $MSG .= LOGIN_WRONG_ID;
141 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unhandled error code %s detected.", $ERROR));
142 $MSG .= 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 require_once(PATH."inc/fatal_errors.php");