|
indvdum@0
|
1 |
<?php
|
|
indvdum@0
|
2 |
/**
|
|
indvdum@0
|
3 |
*
|
|
indvdum@0
|
4 |
* @package ucp
|
|
indvdum@0
|
5 |
* @version $Id$
|
|
indvdum@0
|
6 |
* @copyright (c) 2005 phpBB Group
|
|
indvdum@0
|
7 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
indvdum@0
|
8 |
*
|
|
indvdum@0
|
9 |
*/
|
|
indvdum@0
|
10 |
|
|
indvdum@0
|
11 |
/**
|
|
indvdum@0
|
12 |
* @ignore
|
|
indvdum@0
|
13 |
*/
|
|
indvdum@0
|
14 |
if (!defined('IN_PHPBB'))
|
|
indvdum@0
|
15 |
{
|
|
indvdum@0
|
16 |
exit;
|
|
indvdum@0
|
17 |
}
|
|
indvdum@0
|
18 |
|
|
indvdum@0
|
19 |
/**
|
|
indvdum@0
|
20 |
* ucp_remind
|
|
indvdum@0
|
21 |
* Sending password reminders
|
|
indvdum@0
|
22 |
* @package ucp
|
|
indvdum@0
|
23 |
*/
|
|
indvdum@0
|
24 |
class ucp_remind
|
|
indvdum@0
|
25 |
{
|
|
indvdum@0
|
26 |
var $u_action;
|
|
indvdum@0
|
27 |
|
|
indvdum@0
|
28 |
function main($id, $mode)
|
|
indvdum@0
|
29 |
{
|
|
indvdum@0
|
30 |
global $config, $phpbb_root_path, $phpEx;
|
|
indvdum@0
|
31 |
global $db, $user, $auth, $template;
|
|
indvdum@0
|
32 |
|
|
indvdum@0
|
33 |
$username = request_var('username', '', true);
|
|
indvdum@0
|
34 |
$email = strtolower(request_var('email', ''));
|
|
indvdum@0
|
35 |
$submit = (isset($_POST['submit'])) ? true : false;
|
|
indvdum@0
|
36 |
|
|
indvdum@0
|
37 |
if ($submit)
|
|
indvdum@0
|
38 |
{
|
|
indvdum@0
|
39 |
$sql = 'SELECT user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type, user_lang, user_inactive_reason
|
|
indvdum@0
|
40 |
FROM ' . USERS_TABLE . "
|
|
indvdum@0
|
41 |
WHERE user_email_hash = '" . $db->sql_escape(phpbb_email_hash($email)) . "'
|
|
indvdum@0
|
42 |
AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
|
|
indvdum@0
|
43 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
44 |
$user_row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
45 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
46 |
|
|
indvdum@0
|
47 |
if (!$user_row)
|
|
indvdum@0
|
48 |
{
|
|
indvdum@0
|
49 |
trigger_error('NO_EMAIL_USER');
|
|
indvdum@0
|
50 |
}
|
|
indvdum@0
|
51 |
|
|
indvdum@0
|
52 |
if ($user_row['user_type'] == USER_IGNORE)
|
|
indvdum@0
|
53 |
{
|
|
indvdum@0
|
54 |
trigger_error('NO_USER');
|
|
indvdum@0
|
55 |
}
|
|
indvdum@0
|
56 |
|
|
indvdum@0
|
57 |
if ($user_row['user_type'] == USER_INACTIVE)
|
|
indvdum@0
|
58 |
{
|
|
indvdum@0
|
59 |
if ($user_row['user_inactive_reason'] == INACTIVE_MANUAL)
|
|
indvdum@0
|
60 |
{
|
|
indvdum@0
|
61 |
trigger_error('ACCOUNT_DEACTIVATED');
|
|
indvdum@0
|
62 |
}
|
|
indvdum@0
|
63 |
else
|
|
indvdum@0
|
64 |
{
|
|
indvdum@0
|
65 |
trigger_error('ACCOUNT_NOT_ACTIVATED');
|
|
indvdum@0
|
66 |
}
|
|
indvdum@0
|
67 |
}
|
|
indvdum@0
|
68 |
|
|
indvdum@0
|
69 |
// Check users permissions
|
|
indvdum@0
|
70 |
$auth2 = new auth();
|
|
indvdum@0
|
71 |
$auth2->acl($user_row);
|
|
indvdum@0
|
72 |
|
|
indvdum@0
|
73 |
if (!$auth2->acl_get('u_chgpasswd'))
|
|
indvdum@0
|
74 |
{
|
|
indvdum@0
|
75 |
trigger_error('NO_AUTH_PASSWORD_REMINDER');
|
|
indvdum@0
|
76 |
}
|
|
indvdum@0
|
77 |
|
|
indvdum@0
|
78 |
$server_url = generate_board_url();
|
|
indvdum@0
|
79 |
|
|
indvdum@0
|
80 |
// Make password at least 8 characters long, make it longer if admin wants to.
|
|
indvdum@0
|
81 |
// gen_rand_string() however has a limit of 12 or 13.
|
|
indvdum@0
|
82 |
$user_password = gen_rand_string_friendly(max(8, mt_rand((int) $config['min_pass_chars'], (int) $config['max_pass_chars'])));
|
|
indvdum@0
|
83 |
|
|
indvdum@0
|
84 |
// For the activation key a random length between 6 and 10 will do.
|
|
indvdum@0
|
85 |
$user_actkey = gen_rand_string(mt_rand(6, 10));
|
|
indvdum@0
|
86 |
|
|
indvdum@0
|
87 |
$sql = 'UPDATE ' . USERS_TABLE . "
|
|
indvdum@0
|
88 |
SET user_newpasswd = '" . $db->sql_escape(phpbb_hash($user_password)) . "', user_actkey = '" . $db->sql_escape($user_actkey) . "'
|
|
indvdum@0
|
89 |
WHERE user_id = " . $user_row['user_id'];
|
|
indvdum@0
|
90 |
$db->sql_query($sql);
|
|
indvdum@0
|
91 |
|
|
indvdum@0
|
92 |
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
|
indvdum@0
|
93 |
|
|
indvdum@0
|
94 |
$messenger = new messenger(false);
|
|
indvdum@0
|
95 |
|
|
indvdum@0
|
96 |
$messenger->template('user_activate_passwd', $user_row['user_lang']);
|
|
indvdum@0
|
97 |
|
|
indvdum@0
|
98 |
$messenger->to($user_row['user_email'], $user_row['username']);
|
|
indvdum@0
|
99 |
$messenger->im($user_row['user_jabber'], $user_row['username']);
|
|
indvdum@0
|
100 |
|
|
indvdum@0
|
101 |
$messenger->assign_vars(array(
|
|
indvdum@0
|
102 |
'USERNAME' => htmlspecialchars_decode($user_row['username']),
|
|
indvdum@0
|
103 |
'PASSWORD' => htmlspecialchars_decode($user_password),
|
|
indvdum@0
|
104 |
'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k=$user_actkey")
|
|
indvdum@0
|
105 |
);
|
|
indvdum@0
|
106 |
|
|
indvdum@0
|
107 |
$messenger->send($user_row['user_notify_type']);
|
|
indvdum@0
|
108 |
|
|
indvdum@0
|
109 |
meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
|
|
indvdum@0
|
110 |
|
|
indvdum@0
|
111 |
$message = $user->lang['PASSWORD_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
|
|
indvdum@0
|
112 |
trigger_error($message);
|
|
indvdum@0
|
113 |
}
|
|
indvdum@0
|
114 |
|
|
indvdum@0
|
115 |
$template->assign_vars(array(
|
|
indvdum@0
|
116 |
'USERNAME' => $username,
|
|
indvdum@0
|
117 |
'EMAIL' => $email,
|
|
indvdum@0
|
118 |
'S_PROFILE_ACTION' => append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=sendpassword'))
|
|
indvdum@0
|
119 |
);
|
|
indvdum@0
|
120 |
|
|
indvdum@0
|
121 |
$this->tpl_name = 'ucp_remind';
|
|
indvdum@0
|
122 |
$this->page_title = 'UCP_REMIND';
|
|
indvdum@0
|
123 |
}
|
|
indvdum@0
|
124 |
}
|
|
indvdum@0
|
125 |
|
|
indvdum@0
|
126 |
?> |