|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file helps the administrator setting registration settings and policy |
|
5
|
|
|
* as well as allow the administrator to register new members themselves. |
|
6
|
|
|
* |
|
7
|
|
|
* Simple Machines Forum (SMF) |
|
8
|
|
|
* |
|
9
|
|
|
* @package SMF |
|
10
|
|
|
* @author Simple Machines https://www.simplemachines.org |
|
11
|
|
|
* @copyright 2020 Simple Machines and individual contributors |
|
12
|
|
|
* @license https://www.simplemachines.org/about/smf/license.php BSD |
|
13
|
|
|
* |
|
14
|
|
|
* @version 2.1 RC3 |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
if (!defined('SMF')) |
|
18
|
|
|
die('No direct access...'); |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Entrance point for the registration center, it checks permissions and forwards |
|
22
|
|
|
* to the right function based on the subaction. |
|
23
|
|
|
* Accessed by ?action=admin;area=regcenter. |
|
24
|
|
|
* Requires either the moderate_forum or the admin_forum permission. |
|
25
|
|
|
* |
|
26
|
|
|
* Uses Login language file |
|
27
|
|
|
* Uses Register template. |
|
28
|
|
|
*/ |
|
29
|
|
|
function RegCenter() |
|
30
|
|
|
{ |
|
31
|
|
|
global $context, $txt; |
|
32
|
|
|
|
|
33
|
|
|
// Old templates might still request this. |
|
34
|
|
|
if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse') |
|
35
|
|
|
redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : '')); |
|
36
|
|
|
|
|
37
|
|
|
$subActions = array( |
|
38
|
|
|
'register' => array('AdminRegister', 'moderate_forum'), |
|
39
|
|
|
'agreement' => array('EditAgreement', 'admin_forum'), |
|
40
|
|
|
'policy' => array('EditPrivacyPolicy', 'admin_forum'), |
|
41
|
|
|
'reservednames' => array('SetReserved', 'admin_forum'), |
|
42
|
|
|
'settings' => array('ModifyRegistrationSettings', 'admin_forum'), |
|
43
|
|
|
); |
|
44
|
|
|
|
|
45
|
|
|
// Work out which to call... |
|
46
|
|
|
$context['sub_action'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (allowedTo('moderate_forum') ? 'register' : 'settings'); |
|
47
|
|
|
|
|
48
|
|
|
// Must have sufficient permissions. |
|
49
|
|
|
isAllowedTo($subActions[$context['sub_action']][1]); |
|
50
|
|
|
|
|
51
|
|
|
// Loading, always loading. |
|
52
|
|
|
loadLanguage('Login'); |
|
53
|
|
|
loadTemplate('Register'); |
|
54
|
|
|
|
|
55
|
|
|
// Next create the tabs for the template. |
|
56
|
|
|
$context[$context['admin_menu_name']]['tab_data'] = array( |
|
57
|
|
|
'title' => $txt['registration_center'], |
|
58
|
|
|
'help' => 'registrations', |
|
59
|
|
|
'description' => $txt['admin_settings_desc'], |
|
60
|
|
|
'tabs' => array( |
|
61
|
|
|
'register' => array( |
|
62
|
|
|
'description' => $txt['admin_register_desc'], |
|
63
|
|
|
), |
|
64
|
|
|
'agreement' => array( |
|
65
|
|
|
'description' => $txt['registration_agreement_desc'], |
|
66
|
|
|
), |
|
67
|
|
|
'policy' => array( |
|
68
|
|
|
'description' => $txt['privacy_policy_desc'], |
|
69
|
|
|
), |
|
70
|
|
|
'reservednames' => array( |
|
71
|
|
|
'description' => $txt['admin_reserved_desc'], |
|
72
|
|
|
), |
|
73
|
|
|
'settings' => array( |
|
74
|
|
|
'description' => $txt['admin_settings_desc'], |
|
75
|
|
|
) |
|
76
|
|
|
) |
|
77
|
|
|
); |
|
78
|
|
|
|
|
79
|
|
|
call_integration_hook('integrate_manage_registrations', array(&$subActions)); |
|
80
|
|
|
|
|
81
|
|
|
// Finally, get around to calling the function... |
|
82
|
|
|
call_helper($subActions[$context['sub_action']][0]); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* This function allows the admin to register a new member by hand. |
|
87
|
|
|
* It also allows assigning a primary group to the member being registered. |
|
88
|
|
|
* Accessed by ?action=admin;area=regcenter;sa=register |
|
89
|
|
|
* Requires the moderate_forum permission. |
|
90
|
|
|
* |
|
91
|
|
|
* @uses template_admin_register() |
|
92
|
|
|
*/ |
|
93
|
|
|
function AdminRegister() |
|
94
|
|
|
{ |
|
95
|
|
|
global $txt, $context, $sourcedir, $scripturl, $smcFunc; |
|
96
|
|
|
|
|
97
|
|
|
// Are there any custom profile fields required during registration? |
|
98
|
|
|
require_once($sourcedir . '/Profile.php'); |
|
99
|
|
|
loadCustomFields(0, 'register'); |
|
100
|
|
|
|
|
101
|
|
|
if (!empty($_POST['regSubmit'])) |
|
102
|
|
|
{ |
|
103
|
|
|
checkSession(); |
|
104
|
|
|
validateToken('admin-regc'); |
|
105
|
|
|
|
|
106
|
|
|
foreach ($_POST as $key => $value) |
|
107
|
|
|
if (!is_array($_POST[$key])) |
|
108
|
|
|
$_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); |
|
109
|
|
|
|
|
110
|
|
|
$regOptions = array( |
|
111
|
|
|
'interface' => 'admin', |
|
112
|
|
|
'username' => $_POST['user'], |
|
113
|
|
|
'email' => $_POST['email'], |
|
114
|
|
|
'password' => $_POST['password'], |
|
115
|
|
|
'password_check' => $_POST['password'], |
|
116
|
|
|
'check_reserved_name' => true, |
|
117
|
|
|
'check_password_strength' => false, |
|
118
|
|
|
'check_email_ban' => false, |
|
119
|
|
|
'send_welcome_email' => isset($_POST['emailPassword']) || empty($_POST['password']), |
|
120
|
|
|
'require' => isset($_POST['emailActivate']) ? 'activation' : 'nothing', |
|
121
|
|
|
'memberGroup' => empty($_POST['group']) || !allowedTo('manage_membergroups') ? 0 : (int) $_POST['group'], |
|
122
|
|
|
); |
|
123
|
|
|
|
|
124
|
|
|
require_once($sourcedir . '/Subs-Members.php'); |
|
125
|
|
|
$memberID = registerMember($regOptions); |
|
126
|
|
|
if (!empty($memberID)) |
|
127
|
|
|
{ |
|
128
|
|
|
// We'll do custom fields after as then we get to use the helper function! |
|
129
|
|
|
if (!empty($_POST['customfield'])) |
|
130
|
|
|
{ |
|
131
|
|
|
require_once($sourcedir . '/Profile-Modify.php'); |
|
132
|
|
|
makeCustomFieldChanges($memberID, 'register'); |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
$context['new_member'] = array( |
|
136
|
|
|
'id' => $memberID, |
|
137
|
|
|
'name' => $_POST['user'], |
|
138
|
|
|
'href' => $scripturl . '?action=profile;u=' . $memberID, |
|
139
|
|
|
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $memberID . '">' . $_POST['user'] . '</a>', |
|
140
|
|
|
); |
|
141
|
|
|
$context['registration_done'] = sprintf($txt['admin_register_done'], $context['new_member']['link']); |
|
142
|
|
|
} |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
// Load the assignable member groups. |
|
146
|
|
|
if (allowedTo('manage_membergroups')) |
|
147
|
|
|
{ |
|
148
|
|
|
$request = $smcFunc['db_query']('', ' |
|
149
|
|
|
SELECT group_name, id_group |
|
150
|
|
|
FROM {db_prefix}membergroups |
|
151
|
|
|
WHERE id_group != {int:moderator_group} |
|
152
|
|
|
AND min_posts = {int:min_posts}' . (allowedTo('admin_forum') ? '' : ' |
|
153
|
|
|
AND id_group != {int:admin_group} |
|
154
|
|
|
AND group_type != {int:is_protected}') . ' |
|
155
|
|
|
AND hidden != {int:hidden_group} |
|
156
|
|
|
ORDER BY min_posts, CASE WHEN id_group < {int:newbie_group} THEN id_group ELSE 4 END, group_name', |
|
157
|
|
|
array( |
|
158
|
|
|
'moderator_group' => 3, |
|
159
|
|
|
'min_posts' => -1, |
|
160
|
|
|
'admin_group' => 1, |
|
161
|
|
|
'is_protected' => 1, |
|
162
|
|
|
'hidden_group' => 2, |
|
163
|
|
|
'newbie_group' => 4, |
|
164
|
|
|
) |
|
165
|
|
|
); |
|
166
|
|
|
$context['member_groups'] = array(0 => $txt['admin_register_group_none']); |
|
167
|
|
|
while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
168
|
|
|
$context['member_groups'][$row['id_group']] = $row['group_name']; |
|
169
|
|
|
$smcFunc['db_free_result']($request); |
|
170
|
|
|
} |
|
171
|
|
|
else |
|
172
|
|
|
$context['member_groups'] = array(); |
|
173
|
|
|
|
|
174
|
|
|
// Basic stuff. |
|
175
|
|
|
$context['sub_template'] = 'admin_register'; |
|
176
|
|
|
$context['page_title'] = $txt['registration_center']; |
|
177
|
|
|
createToken('admin-regc'); |
|
178
|
|
|
loadJavaScriptFile('register.js', array('defer' => false, 'minimize' => true), 'smf_register'); |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* Allows the administrator to edit the registration agreement, and choose whether |
|
183
|
|
|
* it should be shown or not. It writes and saves the agreement to the agreement.txt |
|
184
|
|
|
* file. |
|
185
|
|
|
* Accessed by ?action=admin;area=regcenter;sa=agreement. |
|
186
|
|
|
* Requires the admin_forum permission. |
|
187
|
|
|
* |
|
188
|
|
|
* @uses template_edit_agreement() |
|
189
|
|
|
*/ |
|
190
|
|
|
function EditAgreement() |
|
191
|
|
|
{ |
|
192
|
|
|
// I hereby agree not to be a lazy bum. |
|
193
|
|
|
global $txt, $boarddir, $context, $modSettings, $smcFunc, $user_info; |
|
194
|
|
|
|
|
195
|
|
|
// By default we look at agreement.txt. |
|
196
|
|
|
$context['current_agreement'] = ''; |
|
197
|
|
|
|
|
198
|
|
|
// Is there more than one to edit? |
|
199
|
|
|
$context['editable_agreements'] = array( |
|
200
|
|
|
'' => $txt['admin_agreement_default'], |
|
201
|
|
|
); |
|
202
|
|
|
|
|
203
|
|
|
// Get our languages. |
|
204
|
|
|
getLanguages(); |
|
205
|
|
|
|
|
206
|
|
|
// Try to figure out if we have more agreements. |
|
207
|
|
|
foreach ($context['languages'] as $lang) |
|
208
|
|
|
{ |
|
209
|
|
|
if (file_exists($boarddir . '/agreement.' . $lang['filename'] . '.txt')) |
|
210
|
|
|
{ |
|
211
|
|
|
$context['editable_agreements']['.' . $lang['filename']] = $lang['name']; |
|
212
|
|
|
// Are we editing this? |
|
213
|
|
|
if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename']) |
|
214
|
|
|
$context['current_agreement'] = '.' . $lang['filename']; |
|
215
|
|
|
} |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
$agreement_lang = empty($context['current_agreement']) ? 'default' : substr($context['current_agreement'], 1); |
|
219
|
|
|
|
|
220
|
|
|
$context['agreement'] = file_exists($boarddir . '/agreement' . $context['current_agreement'] . '.txt') ? str_replace("\r", '', file_get_contents($boarddir . '/agreement' . $context['current_agreement'] . '.txt')) : ''; |
|
221
|
|
|
|
|
222
|
|
|
if (isset($_POST['agreement']) && str_replace("\r", '', $_POST['agreement']) != $context['agreement']) |
|
223
|
|
|
{ |
|
224
|
|
|
checkSession(); |
|
225
|
|
|
validateToken('admin-rega'); |
|
226
|
|
|
|
|
227
|
|
|
// Off it goes to the agreement file. |
|
228
|
|
|
$to_write = str_replace("\r", '', $_POST['agreement']); |
|
229
|
|
|
$bytes = file_put_contents($boarddir . '/agreement' . $context['current_agreement'] . '.txt', $to_write, LOCK_EX); |
|
230
|
|
|
|
|
231
|
|
|
$agreement_settings['agreement_updated_' . $agreement_lang] = time(); |
|
|
|
|
|
|
232
|
|
|
|
|
233
|
|
|
if ($bytes == strlen($to_write)) |
|
234
|
|
|
$context['saved_successful'] = true; |
|
235
|
|
|
else |
|
236
|
|
|
$context['could_not_save'] = true; |
|
237
|
|
|
|
|
238
|
|
|
// Writing it counts as agreeing to it, right? |
|
239
|
|
|
$smcFunc['db_insert']('replace', |
|
240
|
|
|
'{db_prefix}themes', |
|
241
|
|
|
array('id_member' => 'int', 'id_theme' => 'int', 'variable' => 'string', 'value' => 'string'), |
|
242
|
|
|
array($user_info['id'], 1, 'agreement_accepted', time()), |
|
243
|
|
|
array('id_member', 'id_theme', 'variable') |
|
244
|
|
|
); |
|
245
|
|
|
logAction('agreement_updated', array('language' => $context['editable_agreements'][$context['current_agreement']]), 'admin'); |
|
246
|
|
|
logAction('agreement_accepted', array('applicator' => $user_info['id']), 'user'); |
|
247
|
|
|
|
|
248
|
|
|
updateSettings($agreement_settings); |
|
249
|
|
|
|
|
250
|
|
|
$context['agreement'] = str_replace("\r", '', $_POST['agreement']); |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
$context['agreement_info'] = sprintf($txt['admin_agreement_info'], empty($modSettings['agreement_updated_' . $agreement_lang]) ? $txt['never'] : timeformat($modSettings['agreement_updated_' . $agreement_lang])); |
|
254
|
|
|
|
|
255
|
|
|
$context['agreement'] = $smcFunc['htmlspecialchars']($context['agreement']); |
|
256
|
|
|
$context['warning'] = is_writable($boarddir . '/agreement' . $context['current_agreement'] . '.txt') ? '' : $txt['agreement_not_writable']; |
|
257
|
|
|
|
|
258
|
|
|
$context['sub_template'] = 'edit_agreement'; |
|
259
|
|
|
$context['page_title'] = $txt['registration_agreement']; |
|
260
|
|
|
|
|
261
|
|
|
createToken('admin-rega'); |
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
|
|
/** |
|
265
|
|
|
* Set the names under which users are not allowed to register. |
|
266
|
|
|
* Accessed by ?action=admin;area=regcenter;sa=reservednames. |
|
267
|
|
|
* Requires the admin_forum permission. |
|
268
|
|
|
* |
|
269
|
|
|
* @uses template_edit_reserved_words() |
|
270
|
|
|
*/ |
|
271
|
|
|
function SetReserved() |
|
272
|
|
|
{ |
|
273
|
|
|
global $txt, $context, $modSettings; |
|
274
|
|
|
|
|
275
|
|
|
// Submitting new reserved words. |
|
276
|
|
|
if (!empty($_POST['save_reserved_names'])) |
|
277
|
|
|
{ |
|
278
|
|
|
checkSession(); |
|
279
|
|
|
validateToken('admin-regr'); |
|
280
|
|
|
|
|
281
|
|
|
// Set all the options.... |
|
282
|
|
|
updateSettings(array( |
|
283
|
|
|
'reserveWord' => (isset($_POST['matchword']) ? '1' : '0'), |
|
284
|
|
|
'reserveCase' => (isset($_POST['matchcase']) ? '1' : '0'), |
|
285
|
|
|
'reserveUser' => (isset($_POST['matchuser']) ? '1' : '0'), |
|
286
|
|
|
'reserveName' => (isset($_POST['matchname']) ? '1' : '0'), |
|
287
|
|
|
'reserveNames' => str_replace("\r", '', $_POST['reserved']) |
|
288
|
|
|
)); |
|
289
|
|
|
$context['saved_successful'] = true; |
|
290
|
|
|
} |
|
291
|
|
|
|
|
292
|
|
|
// Get the reserved word options and words. |
|
293
|
|
|
$modSettings['reserveNames'] = str_replace('\n', "\n", $modSettings['reserveNames']); |
|
294
|
|
|
$context['reserved_words'] = explode("\n", $modSettings['reserveNames']); |
|
295
|
|
|
$context['reserved_word_options'] = array(); |
|
296
|
|
|
$context['reserved_word_options']['match_word'] = $modSettings['reserveWord'] == '1'; |
|
297
|
|
|
$context['reserved_word_options']['match_case'] = $modSettings['reserveCase'] == '1'; |
|
298
|
|
|
$context['reserved_word_options']['match_user'] = $modSettings['reserveUser'] == '1'; |
|
299
|
|
|
$context['reserved_word_options']['match_name'] = $modSettings['reserveName'] == '1'; |
|
300
|
|
|
|
|
301
|
|
|
// Ready the template...... |
|
302
|
|
|
$context['sub_template'] = 'edit_reserved_words'; |
|
303
|
|
|
$context['page_title'] = $txt['admin_reserved_set']; |
|
304
|
|
|
createToken('admin-regr'); |
|
305
|
|
|
} |
|
306
|
|
|
|
|
307
|
|
|
/** |
|
308
|
|
|
* This function handles registration settings, and provides a few pretty stats too while it's at it. |
|
309
|
|
|
* General registration settings and Coppa compliance settings. |
|
310
|
|
|
* Accessed by ?action=admin;area=regcenter;sa=settings. |
|
311
|
|
|
* Requires the admin_forum permission. |
|
312
|
|
|
* |
|
313
|
|
|
* @param bool $return_config Whether or not to return the config_vars array (used for admin search) |
|
314
|
|
|
* @return void|array Returns nothing or returns the $config_vars array if $return_config is true |
|
315
|
|
|
*/ |
|
316
|
|
|
function ModifyRegistrationSettings($return_config = false) |
|
317
|
|
|
{ |
|
318
|
|
|
global $txt, $context, $scripturl, $modSettings, $sourcedir; |
|
319
|
|
|
global $language, $boarddir; |
|
320
|
|
|
|
|
321
|
|
|
// This is really quite wanting. |
|
322
|
|
|
require_once($sourcedir . '/ManageServer.php'); |
|
323
|
|
|
|
|
324
|
|
|
// Do we have at least default versions of the agreement and privacy policy? |
|
325
|
|
|
$agreement = file_exists($boarddir . '/agreement.' . $language . '.txt') || file_exists($boarddir . '/agreement.txt'); |
|
326
|
|
|
$policy = !empty($modSettings['policy_' . $language]); |
|
327
|
|
|
|
|
328
|
|
|
$config_vars = array( |
|
329
|
|
|
array('select', 'registration_method', array($txt['setting_registration_standard'], $txt['setting_registration_activate'], $txt['setting_registration_approval'], $txt['setting_registration_disabled'])), |
|
330
|
|
|
array('check', 'send_welcomeEmail'), |
|
331
|
|
|
'', |
|
332
|
|
|
array('check', 'requireAgreement', 'text_label' => $txt['admin_agreement'], 'value' => !empty($modSettings['requireAgreement'])), |
|
333
|
|
|
array('warning', empty($agreement) ? 'error_no_agreement' : ''), |
|
334
|
|
|
array('check', 'requirePolicyAgreement', 'text_label' => $txt['admin_privacy_policy'], 'value' => !empty($modSettings['requirePolicyAgreement'])), |
|
335
|
|
|
array('warning', empty($policy) ? 'error_no_privacy_policy' : ''), |
|
336
|
|
|
'', |
|
337
|
|
|
array('int', 'coppaAge', 'subtext' => $txt['zero_to_disable'], 'onchange' => 'checkCoppa();'), |
|
338
|
|
|
array('select', 'coppaType', array($txt['setting_coppaType_reject'], $txt['setting_coppaType_approval']), 'onchange' => 'checkCoppa();'), |
|
339
|
|
|
array('large_text', 'coppaPost', 'subtext' => $txt['setting_coppaPost_desc']), |
|
340
|
|
|
array('text', 'coppaFax'), |
|
341
|
|
|
array('text', 'coppaPhone'), |
|
342
|
|
|
); |
|
343
|
|
|
|
|
344
|
|
|
call_integration_hook('integrate_modify_registration_settings', array(&$config_vars)); |
|
345
|
|
|
|
|
346
|
|
|
if ($return_config) |
|
347
|
|
|
return $config_vars; |
|
348
|
|
|
|
|
349
|
|
|
// Setup the template |
|
350
|
|
|
$context['sub_template'] = 'show_settings'; |
|
351
|
|
|
$context['page_title'] = $txt['registration_center']; |
|
352
|
|
|
|
|
353
|
|
|
if (isset($_GET['save'])) |
|
354
|
|
|
{ |
|
355
|
|
|
checkSession(); |
|
356
|
|
|
|
|
357
|
|
|
// Are there some contacts missing? |
|
358
|
|
|
if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax'])) |
|
359
|
|
|
fatal_lang_error('admin_setting_coppa_require_contact'); |
|
360
|
|
|
|
|
361
|
|
|
// Post needs to take into account line breaks. |
|
362
|
|
|
$_POST['coppaPost'] = str_replace("\n", '<br>', empty($_POST['coppaPost']) ? '' : $_POST['coppaPost']); |
|
363
|
|
|
|
|
364
|
|
|
call_integration_hook('integrate_save_registration_settings'); |
|
365
|
|
|
|
|
366
|
|
|
saveDBSettings($config_vars); |
|
367
|
|
|
$_SESSION['adm-save'] = true; |
|
368
|
|
|
redirectexit('action=admin;area=regcenter;sa=settings'); |
|
369
|
|
|
} |
|
370
|
|
|
|
|
371
|
|
|
$context['post_url'] = $scripturl . '?action=admin;area=regcenter;save;sa=settings'; |
|
372
|
|
|
$context['settings_title'] = $txt['settings']; |
|
373
|
|
|
|
|
374
|
|
|
// Define some javascript for COPPA. |
|
375
|
|
|
$context['settings_post_javascript'] = ' |
|
376
|
|
|
function checkCoppa() |
|
377
|
|
|
{ |
|
378
|
|
|
var coppaDisabled = document.getElementById(\'coppaAge\').value == 0; |
|
379
|
|
|
document.getElementById(\'coppaType\').disabled = coppaDisabled; |
|
380
|
|
|
|
|
381
|
|
|
var disableContacts = coppaDisabled || document.getElementById(\'coppaType\').options[document.getElementById(\'coppaType\').selectedIndex].value != 1; |
|
382
|
|
|
document.getElementById(\'coppaPost\').disabled = disableContacts; |
|
383
|
|
|
document.getElementById(\'coppaFax\').disabled = disableContacts; |
|
384
|
|
|
document.getElementById(\'coppaPhone\').disabled = disableContacts; |
|
385
|
|
|
} |
|
386
|
|
|
checkCoppa();'; |
|
387
|
|
|
|
|
388
|
|
|
// Turn the postal address into something suitable for a textbox. |
|
389
|
|
|
$modSettings['coppaPost'] = !empty($modSettings['coppaPost']) ? preg_replace('~<br ?/?' . '>~', "\n", $modSettings['coppaPost']) : ''; |
|
390
|
|
|
|
|
391
|
|
|
prepareDBSettingContext($config_vars); |
|
392
|
|
|
} |
|
393
|
|
|
|
|
394
|
|
|
// Sure, you can sell my personal info for profit (...or not) |
|
395
|
|
|
function EditPrivacyPolicy() |
|
396
|
|
|
{ |
|
397
|
|
|
global $txt, $boarddir, $context, $modSettings, $smcFunc, $user_info; |
|
398
|
|
|
|
|
399
|
|
|
// By default, edit the current language's policy |
|
400
|
|
|
$context['current_policy_lang'] = $user_info['language']; |
|
401
|
|
|
|
|
402
|
|
|
// We need a policy for every language |
|
403
|
|
|
getLanguages(); |
|
404
|
|
|
|
|
405
|
|
|
foreach ($context['languages'] as $lang) |
|
406
|
|
|
{ |
|
407
|
|
|
$context['editable_policies'][$lang['filename']] = $lang['name']; |
|
408
|
|
|
|
|
409
|
|
|
// Are we editing this one? |
|
410
|
|
|
if (isset($_POST['policy_lang']) && $_POST['policy_lang'] == $lang['filename']) |
|
411
|
|
|
$context['current_policy_lang'] = $lang['filename']; |
|
412
|
|
|
} |
|
413
|
|
|
|
|
414
|
|
|
$context['privacy_policy'] = empty($modSettings['policy_' . $context['current_policy_lang']]) ? '' : $modSettings['policy_' . $context['current_policy_lang']]; |
|
415
|
|
|
|
|
416
|
|
|
if (isset($_POST['policy'])) |
|
417
|
|
|
{ |
|
418
|
|
|
checkSession(); |
|
419
|
|
|
validateToken('admin-regp'); |
|
420
|
|
|
|
|
421
|
|
|
// Make sure there are no creepy-crawlies in it |
|
422
|
|
|
$policy_text = $smcFunc['htmlspecialchars'](str_replace("\r", '', $_POST['policy'])); |
|
423
|
|
|
|
|
424
|
|
|
$policy_settings = array( |
|
425
|
|
|
'policy_' . $context['current_policy_lang'] => $policy_text, |
|
426
|
|
|
); |
|
427
|
|
|
|
|
428
|
|
|
$policy_settings['policy_updated_' . $context['current_policy_lang']] = time(); |
|
429
|
|
|
|
|
430
|
|
|
// Writing it counts as agreeing to it, right? |
|
431
|
|
|
$smcFunc['db_insert']('replace', |
|
432
|
|
|
'{db_prefix}themes', |
|
433
|
|
|
array('id_member' => 'int', 'id_theme' => 'int', 'variable' => 'string', 'value' => 'string'), |
|
434
|
|
|
array($user_info['id'], 1, 'policy_accepted', time()), |
|
435
|
|
|
array('id_member', 'id_theme', 'variable') |
|
436
|
|
|
); |
|
437
|
|
|
logAction('policy_updated', array('language' => $context['editable_policies'][$context['current_policy_lang']]), 'admin'); |
|
438
|
|
|
logAction('policy_accepted', array('applicator' => $user_info['id']), 'user'); |
|
439
|
|
|
|
|
440
|
|
|
if ($context['privacy_policy'] !== $policy_text) |
|
441
|
|
|
$context['saved_successful'] = true; |
|
442
|
|
|
|
|
443
|
|
|
updateSettings($policy_settings); |
|
444
|
|
|
|
|
445
|
|
|
$context['privacy_policy'] = $policy_text; |
|
446
|
|
|
} |
|
447
|
|
|
|
|
448
|
|
|
$context['privacy_policy_info'] = sprintf($txt['admin_agreement_info'], empty($modSettings['policy_updated_' . $context['current_policy_lang']]) ? $txt['never'] : timeformat($modSettings['policy_updated_' . $context['current_policy_lang']])); |
|
449
|
|
|
|
|
450
|
|
|
$context['sub_template'] = 'edit_privacy_policy'; |
|
451
|
|
|
$context['page_title'] = $txt['privacy_policy']; |
|
452
|
|
|
|
|
453
|
|
|
createToken('admin-regp'); |
|
454
|
|
|
} |
|
455
|
|
|
|
|
456
|
|
|
?> |