]> git.mxchange.org Git - mailer.git/blob - inc/modules/guest/what-login.php
Removed unneccessary eval() command in overview-inc.php, internal TODO closed
[mailer.git] / inc / modules / guest / what-login.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 10/14/2003 *
4  * ===============                              Last change: 04/28/2004 *
5  *                                                                      *
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  *
12  *                     weiter)                                          *
13  * -------------------------------------------------------------------- *
14  *                                                                      *
15  * -------------------------------------------------------------------- *
16  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
17  * For more information visit: http://www.mxchange.org                  *
18  *                                                                      *
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.                                  *
23  *                                                                      *
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.                         *
28  *                                                                      *
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,               *
32  * MA  02110-1301  USA                                                  *
33  ************************************************************************/
34
35 // Some security stuff...
36 if (!defined('__SECURITY')) {
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38         require($INC);
39 } elseif ((!EXT_IS_ACTIVE("user")) && (!IS_ADMIN())) {
40         addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), "user");
41         return;
42 }
43
44 // Add description as navigation point
45 ADD_DESCR("guest", __FILE__);
46
47 global $DATA, $ERROR;
48
49 // Initialize variables
50 $ERROR = 0;
51 $probe_nickname = false;
52 $uid = false;
53 $hash = "";
54 $URL = "";
55 $ADD = "";
56
57 // Already logged in?
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')))) {
64                 // Nickname entered
65                 $uid = SQL_ESCAPE(REQUEST_POST('id'));
66         } else {
67                 // Direct userid entered
68                 $uid  = bigintval(REQUEST_POST('id'));
69         }
70 } elseif (REQUEST_ISSET_POST(('new_pass'))) {
71         // New password requested
72         $uid = 0;
73         if (REQUEST_ISSET_POST(('id'))) $uid = REQUEST_POST('id');
74 } else {
75         // Not logged in
76         $uid = 0; $hash = "";
77 }
78
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'    , "");
82
83 if (IS_MEMBER()) {
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);
95 }
96
97 // Login problems?
98 if (REQUEST_ISSET_GET(('login'))) {
99         // Use code from URL
100         $ERROR = REQUEST_GET(('login'));
101 } // END  - if
102
103 // Login problems?
104 if (!empty($ERROR)) {
105         // Ok, which one now?
106         $MSG = "<tr>
107   <td width=\"10\" class=\"seperator\">&nbsp;</td>
108   <td colspan=\"7\" align=\"center\">
109     <span class=\"guest_failed\">";
110
111         switch ($ERROR) {
112                 case constant('CODE_WRONG_PASS'):
113                         $MSG .= getMessage('LOGIN_WRONG_PASS');
114                         break;
115
116                 case constant('CODE_WRONG_ID'):
117                         $MSG .= getMessage('LOGIN_WRONG_ID');
118                         break;
119
120                 case constant('CODE_ID_LOCKED'):
121                         $MSG .= getMessage('LOGIN_ID_LOCKED');
122                         break;
123
124                 case constant('CODE_ID_UNCONFIRMED'):
125                         $MSG .= getMessage('LOGIN_ID_UNCONFIRMED');
126                         break;
127
128                 case constant('CODE_NO_COOKIES'):
129                         $MSG .= getMessage('LOGIN_NO_COOKIES');
130                         break;
131
132                 case constant('CODE_EXTENSION_PROBLEM'):
133                         if (IS_ADMIN()) {
134                                 $MSG .= sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), "nickname");
135                         } else {
136                                 $MSG .= getMessage('LOGIN_WRONG_ID');
137                         }
138                         break;
139
140                 default:
141                         DEBUG_LOG(__FILE__, __LINE__, sprintf("Unhandled error code %s detected.", $ERROR));
142                         $MSG .= getMessage('LOGIN_WRONG_ID');
143                         break;
144                 }
145                 $MSG .= "</span>
146   </td>
147   <td width=\"10\" class=\"seperator\">&nbsp;</td>
148 </tr>\n";
149                 define('LOGIN_FAILURE_MSG', $MSG);
150 } else {
151         // No problems, no output
152         define('LOGIN_FAILURE_MSG', "");
153 }
154
155 // Display login form with resend-password form
156 if (EXT_IS_ACTIVE("nickname")) {
157         LOAD_TEMPLATE("guest_nickname_login");
158 } else {
159         LOAD_TEMPLATE("guest_login");
160 }
161
162 // Was an URL constructed?
163 if (!empty($URL)) {
164         // URL was constructed
165         if (getTotalFatalErrors()) {
166                 // Fatal errors!
167                 LOAD_INC_ONCE("inc/fatal_errors.php");
168         } else {
169                 // Load URL
170                 LOAD_URL($URL);
171         }
172 } // END - if
173
174 //
175 ?>