]> git.mxchange.org Git - mailer.git/blob - inc/modules/guest/what-login.php
49228e9cf397cb6e8a404bc2f423a6744a2b42eb
[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 - 2012 by Mailer Developer Team                   *
21  * For more information visit: http://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         exit();
42 } // END - if
43
44 // Add description as navigation point
45 addYouAreHereLink('guest', __FILE__);
46
47 if ((!isExtensionActive('user')) && (!isAdmin())) {
48         displayMessage('{%pipe,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 ((isPostRequestElementSet('id')) && (isPostRequestElementSet('password')) && (isFormSent('login'))) {
64         // Set userid and crypt password when login data was submitted
65         if (isNicknameUsed(postRequestElement('id'))) {
66                 // Nickname entered
67                 $userid = SQL_ESCAPE(postRequestElement('id'));
68         } else {
69                 // Direct userid entered
70                 $userid  = bigintval(postRequestElement('id'));
71         }
72 } elseif (isPostRequestElementSet('new_pass')) {
73         // New password requested
74         $userid = NULL;
75         if (isPostRequestElementSet('email')) {
76                 // Email is set
77                 $userid = SQL_ESCAPE(postRequestElement('email'));
78         } elseif (isPostRequestElementSet('id')) {
79                 // Do we have nickname or userid?
80                 if (isNicknameUsed(postRequestElement('id'))) {
81                         // Nickname entered
82                         $userid = SQL_ESCAPE(postRequestElement('id'));
83                 } else {
84                         // Direct userid entered
85                         $userid  = bigintval(postRequestElement('id'));
86                 }
87         } // END - if
88 } else {
89         // Not logged in
90         $userid = NULL;
91         $hash = '';
92 }
93
94 if (isMember()) {
95         // Login immidiately...
96         $url = 'modules.php?module=login';
97 } elseif ((isFormSent('login')) && ('' . $userid . '' != '' . postRequestElement('id') . '')) {
98         // Invalid input (no nickname extension installed but nickname entered)
99         $errorCode = getCode('EXTENSION_PROBLEM');
100 } elseif (isFormSent('login')) {
101         // Are both 'id' and 'password' set?
102         if ((isPostRequestElementSet('id')) && (isPostRequestElementSet('password'))) {
103                 // Try the login (see inc/libs/user_functions.php)
104                 $url = doUserLogin(postRequestElement('id'), postRequestElement('password'));
105         } elseif (!isPostRequestElementSet('id')) {
106                 // Empty 'id'
107                 $errorCode = getCode('LOGIN_EMPTY_ID');
108         } else {
109                 // Empty 'password'
110                 $errorCode = getCode('LOGIN_EMPTY_PASSWORD');
111         }
112 } elseif ((isPostRequestElementSet('new_pass')) && (!empty($userid))) {
113         // Try the userid/email lookup (see inc/libs/user_functions.php)
114         $errorCode = doNewUserPassword(postRequestElement('email'), $userid);
115 }
116
117 // Login problems?
118 if (isGetRequestElementSet('login')) {
119         // Use code from URL
120         $errorCode = getRequestElement('login');
121 } // END  - if
122
123 // No problems, no output by detault
124 $content['message'] = '';
125
126 // Login problems?
127 if (!empty($errorCode)) {
128         // Do we have a userid set?
129         if (isSessionVariableSet('userid')) {
130                 // Then prefetch data for this account
131                 fetchUserData(getSession('userid'));
132         } // END - if
133
134         // @TODO Move this HTML code into a template
135         $content['message'] = loadTemplate('guest_login_error_message', true, $errorCode);
136 } // END - if
137
138 // Display login form with resend-password form
139 if (isExtensionActive('nickname')) {
140         loadTemplate('guest_nickname_login', false, $content);
141 } else {
142         loadTemplate('guest_login', false, $content);
143 }
144
145 // Was an URL constructed?
146 if (!empty($url)) {
147         // URL was constructed
148         if (ifFatalErrorsDetected()) {
149                 // Handle fatal errors
150                 runFilterChain('handle_fatal_errors');
151         } else {
152                 // Load URL
153                 redirectToUrl($url);
154         }
155 } // END - if
156
157 // [EOF]
158 ?>