Fix #11417: Allow EVENT_MENU_MAIN plugin events to return null
[mantis/radio.git] / lost_pwd.php
blob08fef97de95e92e425c7478a55b3baa13e970a7a
1 <?php
2 # MantisBT - A PHP based bugtracking system
4 # MantisBT is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 2 of the License, or
7 # (at your option) any later version.
9 # MantisBT is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * @package MantisBT
19 * @author Marcello Scata' <marcelloscata at users.sourceforge.net> ITALY
20 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
21 * @copyright Copyright (C) 2002 - 2010 MantisBT Team - mantisbt-dev@lists.sourceforge.net
22 * @link http://www.mantisbt.org
24 * @uses core.php
25 * @uses authentication_api.php
26 * @uses config_api.php
27 * @uses constant_inc.php
28 * @uses database_api.php
29 * @uses email_api.php
30 * @uses form_api.php
31 * @uses gpc_api.php
32 * @uses html_api.php
33 * @uses lang_api.php
34 * @uses print_api.php
35 * @uses user_api.php
36 * @uses utility_api.php
39 require_once( 'core.php' );
40 require_api( 'authentication_api.php' );
41 require_api( 'config_api.php' );
42 require_api( 'constant_inc.php' );
43 require_api( 'database_api.php' );
44 require_api( 'email_api.php' );
45 require_api( 'form_api.php' );
46 require_api( 'gpc_api.php' );
47 require_api( 'html_api.php' );
48 require_api( 'lang_api.php' );
49 require_api( 'print_api.php' );
50 require_api( 'user_api.php' );
51 require_api( 'utility_api.php' );
53 form_security_validate( 'lost_pwd' );
55 # lost password feature disabled or reset password via email disabled -> stop here!
56 if( OFF == config_get( 'lost_password_feature' ) ||
57 OFF == config_get( 'send_reset_password' ) ||
58 OFF == config_get( 'enable_email_notification' ) ) {
59 trigger_error( ERROR_LOST_PASSWORD_NOT_ENABLED, ERROR );
62 # force logout on the current user if already authenticated
63 if( auth_is_user_authenticated() ) {
64 auth_logout();
67 $f_username = gpc_get_string('username');
68 $f_email = gpc_get_string('email');
70 $f_email = email_append_domain( $f_email );
71 email_ensure_valid( $f_email );
73 $t_user_table = db_get_table( 'user' );
75 /** @todo Consider moving this query to user_api.php */
76 $query = 'SELECT id FROM ' . $t_user_table . ' WHERE username = ' . db_param() . ' AND email = ' . db_param() . ' AND enabled=' . db_param();
77 $result = db_query_bound( $query, Array( $f_username, $f_email, true ) );
79 if ( 0 == db_num_rows( $result ) ) {
80 trigger_error( ERROR_LOST_PASSWORD_NOT_MATCHING_DATA, ERROR );
83 if( is_blank( $f_email ) ) {
84 trigger_error( ERROR_LOST_PASSWORD_NO_EMAIL_SPECIFIED, ERROR );
87 $row = db_fetch_array( $result );
88 $t_user_id = $row['id'];
90 if( user_is_protected( $t_user_id ) ) {
91 trigger_error( ERROR_PROTECTED_ACCOUNT, ERROR );
94 if( !user_is_lost_password_request_allowed( $t_user_id ) ) {
95 trigger_error( ERROR_LOST_PASSWORD_MAX_IN_PROGRESS_ATTEMPTS_REACHED, ERROR );
98 $t_confirm_hash = auth_generate_confirm_hash( $t_user_id );
99 email_send_confirm_hash_url( $t_user_id, $t_confirm_hash );
101 user_increment_lost_password_in_progress_count( $t_user_id );
103 form_security_purge( 'lost_pwd' );
105 $t_redirect_url = 'login_page.php';
107 html_page_top();
110 <br />
111 <div align="center">
112 <table class="width50" cellspacing="1">
113 <tr>
114 <td class="center">
115 <b><?php echo lang_get( 'lost_password_done_title' ) ?></b>
116 </td>
117 </tr>
118 <tr>
119 <td>
120 <br/>
121 <?php echo lang_get( 'reset_request_in_progress_msg' ) ?>
122 <br/><br/>
123 </td>
124 </tr>
125 </table>
126 <br />
127 <?php print_bracket_link( 'login_page.php', lang_get( 'proceed' ) ); ?>
128 </div>
130 <?php
131 html_page_bottom1a( __FILE__ );