5
* @version $Id: ucp_remind.php,v 1.33 2007/10/05 14:36:34 acydburn Exp $
6
* @copyright (c) 2005 phpBB Group
7
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
14
if (!defined('IN_PHPBB'))
21
* Sending password reminders
28
function main($id, $mode)
30
global $config, $phpbb_root_path, $phpEx;
31
global $db, $user, $auth, $template;
33
$username = request_var('username', '', true);
34
$email = strtolower(request_var('email', ''));
35
$submit = (isset($_POST['submit'])) ? true : false;
39
$sql = 'SELECT user_id, username, user_email, user_jabber, user_notify_type, user_type, user_lang, user_inactive_reason
40
FROM ' . USERS_TABLE . "
41
WHERE user_email = '" . $db->sql_escape($email) . "'
42
AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
43
$result = $db->sql_query($sql);
44
$user_row = $db->sql_fetchrow($result);
45
$db->sql_freeresult($result);
49
trigger_error('NO_EMAIL_USER');
52
if ($user_row['user_type'] == USER_IGNORE)
54
trigger_error('NO_USER');
57
if ($user_row['user_type'] == USER_INACTIVE)
59
if ($user_row['user_inactive_reason'] == INACTIVE_MANUAL)
61
trigger_error('ACCOUNT_DEACTIVATED');
65
trigger_error('ACCOUNT_NOT_ACTIVATED');
69
$server_url = generate_board_url();
71
$key_len = 54 - strlen($server_url);
72
$key_len = max(6, $key_len); // we want at least 6
73
$key_len = ($config['max_pass_chars']) ? min($key_len, $config['max_pass_chars']) : $key_len; // we want at most $config['max_pass_chars']
74
$user_actkey = substr(gen_rand_string(10), 0, $key_len);
75
$user_password = gen_rand_string(8);
77
$sql = 'UPDATE ' . USERS_TABLE . "
78
SET user_newpasswd = '" . $db->sql_escape(phpbb_hash($user_password)) . "', user_actkey = '" . $db->sql_escape($user_actkey) . "'
79
WHERE user_id = " . $user_row['user_id'];
82
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
84
$messenger = new messenger(false);
86
$messenger->template('user_activate_passwd', $user_row['user_lang']);
88
$messenger->to($user_row['user_email'], $user_row['username']);
89
$messenger->im($user_row['user_jabber'], $user_row['username']);
91
$messenger->assign_vars(array(
92
'USERNAME' => htmlspecialchars_decode($user_row['username']),
93
'PASSWORD' => htmlspecialchars_decode($user_password),
94
'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k=$user_actkey")
97
$messenger->send($user_row['user_notify_type']);
99
meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
101
$message = $user->lang['PASSWORD_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
102
trigger_error($message);
105
$template->assign_vars(array(
106
'USERNAME' => $username,
108
'S_PROFILE_ACTION' => append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=sendpassword'))
111
$this->tpl_name = 'ucp_remind';
112
$this->page_title = 'UCP_REMIND';
b'\\ No newline at end of file'