]> git.mxchange.org Git - mailer.git/blob - inc/modules/guest/what-login.php
822a6f6f5a92f52d30d5210c49756fe7e4492400
[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  * $Revision::                                                        $ *
15  * $Date::                                                            $ *
16  * $Tag:: 0.2.1-FINAL                                                 $ *
17  * $Author::                                                          $ *
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                  *
23  *                                                                      *
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.                                  *
28  *                                                                      *
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.                         *
33  *                                                                      *
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,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
42         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
43         require($INC);
44 } elseif ((!EXT_IS_ACTIVE('user')) && (!IS_ADMIN())) {
45         addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), 'user');
46         return;
47 }
48
49 // Add description as navigation point
50 ADD_DESCR('guest', __FILE__);
51
52 global $DATA;
53
54 // Initialize variables
55 $errorCode = 0;
56 $probe_nickname = false;
57 $uid = false;
58 $hash = '';
59 $URL = '';
60 $add = '';
61
62 // Already logged in?
63 if ((isUserIdSet()) && (isSessionVariableSet('u_hash'))) {
64         // Maybe, then continue with it
65         $uid = getUserId();
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')))) {
69                 // Nickname entered
70                 $uid = SQL_ESCAPE(REQUEST_POST('id'));
71         } else {
72                 // Direct userid entered
73                 $uid  = bigintval(REQUEST_POST('id'));
74         }
75 } elseif (REQUEST_ISSET_POST(('new_pass'))) {
76         // New password requested
77         $uid = 0;
78         if (REQUEST_ISSET_POST(('id'))) $uid = REQUEST_POST('id');
79 } else {
80         // Not logged in
81         $uid = 0; $hash = '';
82 }
83
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'    , '');
87
88 if (IS_MEMBER()) {
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);
100 }
101
102 // Login problems?
103 if (REQUEST_ISSET_GET(('login'))) {
104         // Use code from URL
105         $errorCode = REQUEST_GET(('login'));
106 } // END  - if
107
108 // Login problems?
109 if (!empty($errorCode)) {
110         // Ok, which one now?
111         $message = "<tr>
112   <td width=\"10\" class=\"seperator\">&nbsp;</td>
113   <td colspan=\"7\" align=\"center\">
114     <span class=\"guest_failed\">";
115
116         switch ($errorCode) {
117                 case getCode('WRONG_PASS'):
118                         $message .= getMessage('LOGIN_WRONG_PASS');
119                         break;
120
121                 case getCode('WRONG_ID'):
122                         $message .= getMessage('LOGIN_WRONG_ID');
123                         break;
124
125                 case getCode('ID_LOCKED'):
126                         $message .= getMessage('LOGIN_ID_LOCKED');
127                         break;
128
129                 case getCode('ID_UNCONFIRMED'):
130                         $message .= getMessage('LOGIN_ID_UNCONFIRMED');
131                         break;
132
133                 case getCode('NO_COOKIES'):
134                         $message .= getMessage('LOGIN_NO_COOKIES');
135                         break;
136
137                 case getCode('EXTENSION_PROBLEM'):
138                         if (IS_ADMIN()) {
139                                 $message .= sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), 'nickname');
140                         } else {
141                                 $message .= getMessage('LOGIN_WRONG_ID');
142                         }
143                         break;
144
145                 default:
146                         DEBUG_LOG(__FILE__, __LINE__, sprintf("Unhandled error code %s detected.", $errorCode));
147                         $message .= getMessage('LOGIN_WRONG_ID');
148                         break;
149                 }
150                 $message .= "</span>
151   </td>
152   <td width=\"10\" class=\"seperator\">&nbsp;</td>
153 </tr>\n";
154                 define('LOGIN_FAILURE_MSG', $message);
155 } else {
156         // No problems, no output
157         define('LOGIN_FAILURE_MSG', '');
158 }
159
160 // Display login form with resend-password form
161 if (EXT_IS_ACTIVE('nickname')) {
162         LOAD_TEMPLATE("guest_nickname_login");
163 } else {
164         LOAD_TEMPLATE("guest_login");
165 }
166
167 // Was an URL constructed?
168 if (!empty($URL)) {
169         // URL was constructed
170         if (getTotalFatalErrors()) {
171                 // Fatal errors!
172                 LOAD_INC_ONCE("inc/fatal_errors.php");
173         } else {
174                 // Load URL
175                 LOAD_URL($URL);
176         }
177 } // END - if
178
179 //
180 ?>