Some language strings fixed, renamed. Copyright notice updated
[mailer.git] / inc / modules / guest / what-login.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                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  * -------------------------------------------------------------------- *
19  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
20  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41         die();
42 } // END - if
43
44 // Add description as navigation point
45 addYouAreHereLink('guest', __FILE__);
46
47 if ((!isExtensionActive('user')) && (!isAdmin())) {
48         loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('user'));
49         return;
50 } // END - if
51
52 // Initialize variables
53 $errorCode = '0';
54 $userid = false;
55 $hash = '';
56 $url = '';
57 $add = '';
58
59 // Already logged in?
60 if ((isMemberIdSet()) && (isSessionVariableSet('u_hash'))) {
61         // Maybe, then continue with it
62         $userid = getMemberId();
63 } elseif ((isPostRequestParameterSet('id')) && (isPostRequestParameterSet('password')) && (isFormSent())) {
64         // Set userid and crypt password when login data was submitted
65         if ((isExtensionActive('nickname')) && (isNicknameUsed(postRequestParameter('id')))) {
66                 // Nickname entered
67                 $userid = SQL_ESCAPE(postRequestParameter('id'));
68         } else {
69                 // Direct userid entered
70                 $userid  = bigintval(postRequestParameter('id'));
71         }
72 } elseif (isPostRequestParameterSet('new_pass')) {
73         // New password requested
74         $userid = '0';
75         if (isPostRequestParameterSet('id')) {
76                 // Do we have nickname or userid?
77                 if ((isExtensionActive('nickname')) && (isNicknameUsed(postRequestParameter('id')))) {
78                         // Nickname entered
79                         $userid = SQL_ESCAPE(postRequestParameter('id'));
80                 } else {
81                         // Direct userid entered
82                         $userid  = bigintval(postRequestParameter('id'));
83                 }
84         } // END - if
85 } else {
86         // Not logged in
87         $userid = '0'; $hash = '';
88 }
89
90 if (isMember()) {
91         // Login immidiately...
92         $url = 'modules.php?module=login';
93 } elseif ((isFormSent()) && ('' . $userid . '' != '' . postRequestParameter('id') . '')) {
94         // Invalid input (no nickname extension installed but nickname entered)
95         $errorCode = getCode('EXTENSION_PROBLEM');
96 } elseif (isFormSent()) {
97         // Try the login (see inc/libs/user_functions.php)
98         $url = doUserLogin(postRequestParameter('id'), postRequestParameter('password'));
99 } elseif ((isPostRequestParameterSet('new_pass')) && (isset($userid))) {
100         // Try the userid/email lookup (see inc/libs/user_functions.php)
101         $errorCode = doNewUserPassword(postRequestParameter('email'), $userid);
102 }
103
104 // Login problems?
105 if (isGetRequestParameterSet('login')) {
106         // Use code from URL
107         $errorCode = getRequestParameter('login');
108 } // END  - if
109
110 // No problems, no output by detault
111 $content['message'] = '';
112
113 // Login problems?
114 if (!empty($errorCode)) {
115         // Do we have a userid set?
116         if (isSessionVariableSet('current_userid')) {
117                 // Then prefetch data for this account
118                 fetchUserData(getSession('current_userid'));
119         } // END - if
120
121         // @TODO Move this HTML code into a template
122         $content['message'] = '<tr>
123   <td colspan="4" align="center">
124     <span class="notice">' . getMessageFromErrorCode($errorCode) . '</span>
125   </td>
126 </tr>';
127 } // END - if
128
129 // Display login form with resend-password form
130 if (isExtensionActive('nickname')) {
131         loadTemplate('guest_nickname_login', false, $content);
132 } else {
133         loadTemplate('guest_login', false, $content);
134 }
135
136 // Was an URL constructed?
137 if (!empty($url)) {
138         // URL was constructed
139         if (ifFatalErrorsDetected()) {
140                 // Handle fatal errors
141                 runFilterChain('handle_fatal_errors');
142         } else {
143                 // Load URL
144                 redirectToUrl($url);
145         }
146 } // END - if
147
148 // [EOF]
149 ?>