Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 92 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
ucp_resend | |
0.00% |
0 / 90 |
|
0.00% |
0 / 2 |
600 | |
0.00% |
0 / 1 |
main | |
0.00% |
0 / 82 |
|
0.00% |
0 / 1 |
552 | |||
update_activation_expiration | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * |
4 | * This file is part of the phpBB Forum Software package. |
5 | * |
6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
7 | * @license GNU General Public License, version 2 (GPL-2.0) |
8 | * |
9 | * For full copyright and license information, please see |
10 | * the docs/CREDITS.txt file. |
11 | * |
12 | */ |
13 | |
14 | /** |
15 | * @ignore |
16 | */ |
17 | if (!defined('IN_PHPBB')) |
18 | { |
19 | exit; |
20 | } |
21 | |
22 | /** |
23 | * ucp_resend |
24 | * Resending activation emails |
25 | */ |
26 | class ucp_resend |
27 | { |
28 | var $u_action; |
29 | |
30 | function main($id, $mode) |
31 | { |
32 | global $config, $phpbb_root_path, $phpEx; |
33 | global $db, $user, $auth, $template, $request; |
34 | |
35 | $username = $request->variable('username', '', true); |
36 | $email = strtolower($request->variable('email', '')); |
37 | $submit = (isset($_POST['submit'])) ? true : false; |
38 | |
39 | add_form_key('ucp_resend'); |
40 | |
41 | if ($submit) |
42 | { |
43 | if (!check_form_key('ucp_resend')) |
44 | { |
45 | trigger_error('FORM_INVALID'); |
46 | } |
47 | |
48 | $sql = 'SELECT user_id, group_id, username, user_email, user_type, user_lang, user_actkey, user_actkey_expiration, user_inactive_reason |
49 | FROM ' . USERS_TABLE . " |
50 | WHERE user_email = '" . $db->sql_escape($email) . "' |
51 | AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; |
52 | $result = $db->sql_query($sql); |
53 | $user_row = $db->sql_fetchrow($result); |
54 | $db->sql_freeresult($result); |
55 | |
56 | if (!$user_row) |
57 | { |
58 | trigger_error('NO_EMAIL_USER'); |
59 | } |
60 | |
61 | if ($user_row['user_type'] == USER_IGNORE) |
62 | { |
63 | trigger_error('NO_USER'); |
64 | } |
65 | |
66 | if (!$user_row['user_actkey'] && $user_row['user_type'] != USER_INACTIVE) |
67 | { |
68 | trigger_error('ACCOUNT_ALREADY_ACTIVATED'); |
69 | } |
70 | |
71 | if (!$user_row['user_actkey'] || ($user_row['user_type'] == USER_INACTIVE && $user_row['user_inactive_reason'] == INACTIVE_MANUAL)) |
72 | { |
73 | trigger_error('ACCOUNT_DEACTIVATED'); |
74 | } |
75 | |
76 | // Do not resend activation email if valid one still exists |
77 | if (!empty($user_row['user_actkey']) && (int) $user_row['user_actkey_expiration'] >= time()) |
78 | { |
79 | trigger_error('ACTIVATION_ALREADY_SENT'); |
80 | } |
81 | |
82 | // Determine coppa status on group (REGISTERED(_COPPA)) |
83 | $sql = 'SELECT group_name, group_type |
84 | FROM ' . GROUPS_TABLE . ' |
85 | WHERE group_id = ' . $user_row['group_id']; |
86 | $result = $db->sql_query($sql); |
87 | $row = $db->sql_fetchrow($result); |
88 | $db->sql_freeresult($result); |
89 | |
90 | if (!$row) |
91 | { |
92 | trigger_error('NO_GROUP'); |
93 | } |
94 | |
95 | $coppa = ($row['group_name'] == 'REGISTERED_COPPA' && $row['group_type'] == GROUP_SPECIAL) ? true : false; |
96 | |
97 | include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); |
98 | $messenger = new messenger(false); |
99 | |
100 | if ($config['require_activation'] == USER_ACTIVATION_SELF || $coppa) |
101 | { |
102 | $messenger->template(($coppa) ? 'coppa_resend_inactive' : 'user_resend_inactive', $user_row['user_lang']); |
103 | $messenger->set_addresses($user_row); |
104 | |
105 | $messenger->anti_abuse_headers($config, $user); |
106 | |
107 | $messenger->assign_vars(array( |
108 | 'WELCOME_MSG' => html_entity_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename']), ENT_COMPAT), |
109 | 'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT), |
110 | 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}") |
111 | ); |
112 | |
113 | if ($coppa) |
114 | { |
115 | $messenger->assign_vars(array( |
116 | 'FAX_INFO' => $config['coppa_fax'], |
117 | 'MAIL_INFO' => $config['coppa_mail'], |
118 | 'EMAIL_ADDRESS' => $user_row['user_email']) |
119 | ); |
120 | } |
121 | |
122 | $messenger->send(NOTIFY_EMAIL); |
123 | } |
124 | |
125 | if ($config['require_activation'] == USER_ACTIVATION_ADMIN) |
126 | { |
127 | // Grab an array of user_id's with a_user permissions ... these users can activate a user |
128 | $admin_ary = $auth->acl_get_list(false, 'a_user', false); |
129 | |
130 | $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type |
131 | FROM ' . USERS_TABLE . ' |
132 | WHERE ' . $db->sql_in_set('user_id', $admin_ary[0]['a_user']); |
133 | $result = $db->sql_query($sql); |
134 | |
135 | while ($row = $db->sql_fetchrow($result)) |
136 | { |
137 | $messenger->template('admin_activate', $row['user_lang']); |
138 | $messenger->set_addresses($row); |
139 | |
140 | $messenger->anti_abuse_headers($config, $user); |
141 | |
142 | $messenger->assign_vars(array( |
143 | 'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT), |
144 | 'U_USER_DETAILS' => generate_board_url() . "/memberlist.$phpEx?mode=viewprofile&u={$user_row['user_id']}", |
145 | 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}") |
146 | ); |
147 | |
148 | $messenger->send($row['user_notify_type']); |
149 | } |
150 | $db->sql_freeresult($result); |
151 | } |
152 | |
153 | $this->update_activation_expiration(); |
154 | |
155 | meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx")); |
156 | |
157 | $message = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? $user->lang['ACTIVATION_EMAIL_SENT_ADMIN'] : $user->lang['ACTIVATION_EMAIL_SENT']; |
158 | $message .= '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>'); |
159 | trigger_error($message); |
160 | } |
161 | |
162 | $template->assign_vars(array( |
163 | 'USERNAME' => $username, |
164 | 'EMAIL' => $email, |
165 | 'S_PROFILE_ACTION' => append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=resend_act')) |
166 | ); |
167 | |
168 | $this->tpl_name = 'ucp_resend'; |
169 | $this->page_title = 'UCP_RESEND'; |
170 | } |
171 | |
172 | /** |
173 | * Update activation expiration to 1 day from now |
174 | * |
175 | * @return void |
176 | */ |
177 | protected function update_activation_expiration(): void |
178 | { |
179 | global $db, $user; |
180 | |
181 | $sql_ary = [ |
182 | 'user_actkey_expiration' => $user::get_token_expiration(), |
183 | ]; |
184 | |
185 | $sql = 'UPDATE ' . USERS_TABLE . ' |
186 | SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' |
187 | WHERE user_id = ' . (int) $user->id(); |
188 | $db->sql_query($sql); |
189 | } |
190 | } |