@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Begin the registration process. |
@@ -29,19 +30,23 @@ discard block |
||
29 | 30 | global $language, $scripturl, $smcFunc, $sourcedir, $cur_profile; |
30 | 31 | |
31 | 32 | // Is this an incoming AJAX check? |
32 | - if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') |
|
33 | - return RegisterCheckUsername(); |
|
33 | + if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') { |
|
34 | + return RegisterCheckUsername(); |
|
35 | + } |
|
34 | 36 | |
35 | 37 | // Check if the administrator has it disabled. |
36 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') |
|
37 | - fatal_lang_error('registration_disabled', false); |
|
38 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') { |
|
39 | + fatal_lang_error('registration_disabled', false); |
|
40 | + } |
|
38 | 41 | |
39 | 42 | // If this user is an admin - redirect them to the admin registration page. |
40 | - if (allowedTo('moderate_forum') && !$user_info['is_guest']) |
|
41 | - redirectexit('action=admin;area=regcenter;sa=register'); |
|
43 | + if (allowedTo('moderate_forum') && !$user_info['is_guest']) { |
|
44 | + redirectexit('action=admin;area=regcenter;sa=register'); |
|
45 | + } |
|
42 | 46 | // You are not a guest, so you are a member - and members don't get to register twice! |
43 | - elseif (empty($user_info['is_guest'])) |
|
44 | - redirectexit(); |
|
47 | + elseif (empty($user_info['is_guest'])) { |
|
48 | + redirectexit(); |
|
49 | + } |
|
45 | 50 | |
46 | 51 | loadLanguage('Login'); |
47 | 52 | loadTemplate('Register'); |
@@ -82,16 +87,18 @@ discard block |
||
82 | 87 | } |
83 | 88 | } |
84 | 89 | // Make sure they don't squeeze through without agreeing. |
85 | - elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) |
|
86 | - $current_step = 1; |
|
90 | + elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) { |
|
91 | + $current_step = 1; |
|
92 | + } |
|
87 | 93 | |
88 | 94 | // Show the user the right form. |
89 | 95 | $context['sub_template'] = $current_step == 1 ? 'registration_agreement' : 'registration_form'; |
90 | 96 | $context['page_title'] = $current_step == 1 ? $txt['registration_agreement'] : $txt['registration_form']; |
91 | 97 | |
92 | 98 | // Kinda need this. |
93 | - if ($context['sub_template'] == 'registration_form') |
|
94 | - loadJavaScriptFile('register.js', array('defer' => false), 'smf_register'); |
|
99 | + if ($context['sub_template'] == 'registration_form') { |
|
100 | + loadJavaScriptFile('register.js', array('defer' => false), 'smf_register'); |
|
101 | + } |
|
95 | 102 | |
96 | 103 | // Add the register chain to the link tree. |
97 | 104 | $context['linktree'][] = array( |
@@ -100,24 +107,26 @@ discard block |
||
100 | 107 | ); |
101 | 108 | |
102 | 109 | // Prepare the time gate! Do it like so, in case later steps want to reset the limit for any reason, but make sure the time is the current one. |
103 | - if (!isset($_SESSION['register'])) |
|
104 | - $_SESSION['register'] = array( |
|
110 | + if (!isset($_SESSION['register'])) { |
|
111 | + $_SESSION['register'] = array( |
|
105 | 112 | 'timenow' => time(), |
106 | 113 | 'limit' => 10, // minimum number of seconds required on this page for registration |
107 | 114 | ); |
108 | - else |
|
109 | - $_SESSION['register']['timenow'] = time(); |
|
115 | + } else { |
|
116 | + $_SESSION['register']['timenow'] = time(); |
|
117 | + } |
|
110 | 118 | |
111 | 119 | // If you have to agree to the agreement, it needs to be fetched from the file. |
112 | 120 | if ($context['require_agreement']) |
113 | 121 | { |
114 | 122 | // Have we got a localized one? |
115 | - if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) |
|
116 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
117 | - elseif (file_exists($boarddir . '/agreement.txt')) |
|
118 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
119 | - else |
|
120 | - $context['agreement'] = ''; |
|
123 | + if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) { |
|
124 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
125 | + } elseif (file_exists($boarddir . '/agreement.txt')) { |
|
126 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
127 | + } else { |
|
128 | + $context['agreement'] = ''; |
|
129 | + } |
|
121 | 130 | |
122 | 131 | // Nothing to show, lets disable registration and inform the admin of this error |
123 | 132 | if (empty($context['agreement'])) |
@@ -133,8 +142,9 @@ discard block |
||
133 | 142 | $selectedLanguage = empty($_SESSION['language']) ? $language : $_SESSION['language']; |
134 | 143 | |
135 | 144 | // Do we have any languages? |
136 | - if (empty($context['languages'])) |
|
137 | - getLanguages(); |
|
145 | + if (empty($context['languages'])) { |
|
146 | + getLanguages(); |
|
147 | + } |
|
138 | 148 | |
139 | 149 | // Try to find our selected language. |
140 | 150 | foreach ($context['languages'] as $key => $lang) |
@@ -142,8 +152,9 @@ discard block |
||
142 | 152 | $context['languages'][$key]['name'] = strtr($lang['name'], array('-utf8' => '')); |
143 | 153 | |
144 | 154 | // Found it! |
145 | - if ($selectedLanguage == $lang['filename']) |
|
146 | - $context['languages'][$key]['selected'] = true; |
|
155 | + if ($selectedLanguage == $lang['filename']) { |
|
156 | + $context['languages'][$key]['selected'] = true; |
|
157 | + } |
|
147 | 158 | } |
148 | 159 | } |
149 | 160 | |
@@ -170,16 +181,19 @@ discard block |
||
170 | 181 | if (in_array('website', $reg_fields)) |
171 | 182 | { |
172 | 183 | unset($reg_fields['website']); |
173 | - if (isset($_POST['website_title'])) |
|
174 | - $cur_profile['website_title'] = $smcFunc['htmlspecialchars']($_POST['website_title']); |
|
175 | - if (isset($_POST['website_url'])) |
|
176 | - $cur_profile['website_url'] = $smcFunc['htmlspecialchars']($_POST['website_url']); |
|
184 | + if (isset($_POST['website_title'])) { |
|
185 | + $cur_profile['website_title'] = $smcFunc['htmlspecialchars']($_POST['website_title']); |
|
186 | + } |
|
187 | + if (isset($_POST['website_url'])) { |
|
188 | + $cur_profile['website_url'] = $smcFunc['htmlspecialchars']($_POST['website_url']); |
|
189 | + } |
|
177 | 190 | } |
178 | 191 | |
179 | 192 | // We might have had some submissions on this front - go check. |
180 | - foreach ($reg_fields as $field) |
|
181 | - if (isset($_POST[$field])) |
|
193 | + foreach ($reg_fields as $field) { |
|
194 | + if (isset($_POST[$field])) |
|
182 | 195 | $cur_profile[$field] = $smcFunc['htmlspecialchars']($_POST[$field]); |
196 | + } |
|
183 | 197 | |
184 | 198 | // Load all the fields in question. |
185 | 199 | setupProfileContext($reg_fields); |
@@ -196,8 +210,9 @@ discard block |
||
196 | 210 | $context['visual_verification_id'] = $verificationOptions['id']; |
197 | 211 | } |
198 | 212 | // Otherwise we have nothing to show. |
199 | - else |
|
200 | - $context['visual_verification'] = false; |
|
213 | + else { |
|
214 | + $context['visual_verification'] = false; |
|
215 | + } |
|
201 | 216 | |
202 | 217 | |
203 | 218 | $context += array( |
@@ -208,8 +223,9 @@ discard block |
||
208 | 223 | |
209 | 224 | // Were there any errors? |
210 | 225 | $context['registration_errors'] = array(); |
211 | - if (!empty($reg_errors)) |
|
212 | - $context['registration_errors'] = $reg_errors; |
|
226 | + if (!empty($reg_errors)) { |
|
227 | + $context['registration_errors'] = $reg_errors; |
|
228 | + } |
|
213 | 229 | |
214 | 230 | createToken('register'); |
215 | 231 | } |
@@ -226,27 +242,32 @@ discard block |
||
226 | 242 | validateToken('register'); |
227 | 243 | |
228 | 244 | // Check to ensure we're forcing SSL for authentication |
229 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
230 | - fatal_lang_error('register_ssl_required'); |
|
245 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
246 | + fatal_lang_error('register_ssl_required'); |
|
247 | + } |
|
231 | 248 | |
232 | 249 | // Start collecting together any errors. |
233 | 250 | $reg_errors = array(); |
234 | 251 | |
235 | 252 | // You can't register if it's disabled. |
236 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) |
|
237 | - fatal_lang_error('registration_disabled', false); |
|
253 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) { |
|
254 | + fatal_lang_error('registration_disabled', false); |
|
255 | + } |
|
238 | 256 | |
239 | 257 | // Well, if you don't agree, you can't register. |
240 | - if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) |
|
241 | - redirectexit(); |
|
258 | + if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) { |
|
259 | + redirectexit(); |
|
260 | + } |
|
242 | 261 | |
243 | 262 | // Make sure they came from *somewhere*, have a session. |
244 | - if (!isset($_SESSION['old_url'])) |
|
245 | - redirectexit('action=signup'); |
|
263 | + if (!isset($_SESSION['old_url'])) { |
|
264 | + redirectexit('action=signup'); |
|
265 | + } |
|
246 | 266 | |
247 | 267 | // If we don't require an agreement, we need a extra check for coppa. |
248 | - if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) |
|
249 | - $_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']); |
|
268 | + if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) { |
|
269 | + $_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']); |
|
270 | + } |
|
250 | 271 | // Are they under age, and under age users are banned? |
251 | 272 | if (!empty($modSettings['coppaAge']) && empty($modSettings['coppaType']) && empty($_SESSION['skip_coppa'])) |
252 | 273 | { |
@@ -255,8 +276,9 @@ discard block |
||
255 | 276 | } |
256 | 277 | |
257 | 278 | // Check the time gate for miscreants. First make sure they came from somewhere that actually set it up. |
258 | - if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) |
|
259 | - redirectexit('action=signup'); |
|
279 | + if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) { |
|
280 | + redirectexit('action=signup'); |
|
281 | + } |
|
260 | 282 | // Failing that, check the time on it. |
261 | 283 | if (time() - $_SESSION['register']['timenow'] < $_SESSION['register']['limit']) |
262 | 284 | { |
@@ -276,15 +298,17 @@ discard block |
||
276 | 298 | if (is_array($context['visual_verification'])) |
277 | 299 | { |
278 | 300 | loadLanguage('Errors'); |
279 | - foreach ($context['visual_verification'] as $error) |
|
280 | - $reg_errors[] = $txt['error_' . $error]; |
|
301 | + foreach ($context['visual_verification'] as $error) { |
|
302 | + $reg_errors[] = $txt['error_' . $error]; |
|
303 | + } |
|
281 | 304 | } |
282 | 305 | } |
283 | 306 | |
284 | 307 | foreach ($_POST as $key => $value) |
285 | 308 | { |
286 | - if (!is_array($_POST[$key])) |
|
287 | - $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); |
|
309 | + if (!is_array($_POST[$key])) { |
|
310 | + $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); |
|
311 | + } |
|
288 | 312 | } |
289 | 313 | |
290 | 314 | // Collect all extra registration fields someone might have filled in. |
@@ -314,12 +338,14 @@ discard block |
||
314 | 338 | $reg_fields = explode(',', $modSettings['registration_fields']); |
315 | 339 | |
316 | 340 | // Website is a little different |
317 | - if (in_array('website', $reg_fields)) |
|
318 | - $possible_strings = array_merge(array('website_url', 'website_title'), $possible_strings); |
|
341 | + if (in_array('website', $reg_fields)) { |
|
342 | + $possible_strings = array_merge(array('website_url', 'website_title'), $possible_strings); |
|
343 | + } |
|
319 | 344 | } |
320 | 345 | |
321 | - if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') |
|
322 | - $_POST['secret_answer'] = md5($_POST['secret_answer']); |
|
346 | + if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') { |
|
347 | + $_POST['secret_answer'] = md5($_POST['secret_answer']); |
|
348 | + } |
|
323 | 349 | |
324 | 350 | // Needed for isReservedName() and registerMember(). |
325 | 351 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -328,8 +354,9 @@ discard block |
||
328 | 354 | if (isset($_POST['real_name'])) |
329 | 355 | { |
330 | 356 | // Are you already allowed to edit the displayed name? |
331 | - if (allowedTo('profile_displayed_name') || allowedTo('moderate_forum')) |
|
332 | - $canEditDisplayName = true; |
|
357 | + if (allowedTo('profile_displayed_name') || allowedTo('moderate_forum')) { |
|
358 | + $canEditDisplayName = true; |
|
359 | + } |
|
333 | 360 | |
334 | 361 | // If you are a guest, will you be allowed to once you register? |
335 | 362 | else |
@@ -353,33 +380,38 @@ discard block |
||
353 | 380 | $_POST['real_name'] = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $_POST['real_name'])); |
354 | 381 | |
355 | 382 | // Only set it if we are sure it is good |
356 | - if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60) |
|
357 | - $possible_strings[] = 'real_name'; |
|
383 | + if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60) { |
|
384 | + $possible_strings[] = 'real_name'; |
|
385 | + } |
|
358 | 386 | } |
359 | 387 | } |
360 | 388 | |
361 | 389 | // Handle a string as a birthdate... |
362 | - if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') |
|
363 | - $_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate'])); |
|
390 | + if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') { |
|
391 | + $_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate'])); |
|
392 | + } |
|
364 | 393 | // Or birthdate parts... |
365 | - elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) |
|
366 | - $_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']); |
|
394 | + elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) { |
|
395 | + $_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']); |
|
396 | + } |
|
367 | 397 | |
368 | 398 | // Validate the passed language file. |
369 | 399 | if (isset($_POST['lngfile']) && !empty($modSettings['userLanguage'])) |
370 | 400 | { |
371 | 401 | // Do we have any languages? |
372 | - if (empty($context['languages'])) |
|
373 | - getLanguages(); |
|
402 | + if (empty($context['languages'])) { |
|
403 | + getLanguages(); |
|
404 | + } |
|
374 | 405 | |
375 | 406 | // Did we find it? |
376 | - if (isset($context['languages'][$_POST['lngfile']])) |
|
377 | - $_SESSION['language'] = $_POST['lngfile']; |
|
378 | - else |
|
407 | + if (isset($context['languages'][$_POST['lngfile']])) { |
|
408 | + $_SESSION['language'] = $_POST['lngfile']; |
|
409 | + } else { |
|
410 | + unset($_POST['lngfile']); |
|
411 | + } |
|
412 | + } else { |
|
379 | 413 | unset($_POST['lngfile']); |
380 | 414 | } |
381 | - else |
|
382 | - unset($_POST['lngfile']); |
|
383 | 415 | |
384 | 416 | // Set the options needed for registration. |
385 | 417 | $regOptions = array( |
@@ -399,22 +431,27 @@ discard block |
||
399 | 431 | ); |
400 | 432 | |
401 | 433 | // Include the additional options that might have been filled in. |
402 | - foreach ($possible_strings as $var) |
|
403 | - if (isset($_POST[$var])) |
|
434 | + foreach ($possible_strings as $var) { |
|
435 | + if (isset($_POST[$var])) |
|
404 | 436 | $regOptions['extra_register_vars'][$var] = $smcFunc['htmlspecialchars']($_POST[$var], ENT_QUOTES); |
405 | - foreach ($possible_ints as $var) |
|
406 | - if (isset($_POST[$var])) |
|
437 | + } |
|
438 | + foreach ($possible_ints as $var) { |
|
439 | + if (isset($_POST[$var])) |
|
407 | 440 | $regOptions['extra_register_vars'][$var] = (int) $_POST[$var]; |
408 | - foreach ($possible_floats as $var) |
|
409 | - if (isset($_POST[$var])) |
|
441 | + } |
|
442 | + foreach ($possible_floats as $var) { |
|
443 | + if (isset($_POST[$var])) |
|
410 | 444 | $regOptions['extra_register_vars'][$var] = (float) $_POST[$var]; |
411 | - foreach ($possible_bools as $var) |
|
412 | - if (isset($_POST[$var])) |
|
445 | + } |
|
446 | + foreach ($possible_bools as $var) { |
|
447 | + if (isset($_POST[$var])) |
|
413 | 448 | $regOptions['extra_register_vars'][$var] = empty($_POST[$var]) ? 0 : 1; |
449 | + } |
|
414 | 450 | |
415 | 451 | // Registration options are always default options... |
416 | - if (isset($_POST['default_options'])) |
|
417 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
452 | + if (isset($_POST['default_options'])) { |
|
453 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
454 | + } |
|
418 | 455 | $regOptions['theme_vars'] = isset($_POST['options']) && is_array($_POST['options']) ? $_POST['options'] : array(); |
419 | 456 | |
420 | 457 | // Make sure they are clean, dammit! |
@@ -434,12 +471,14 @@ discard block |
||
434 | 471 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
435 | 472 | { |
436 | 473 | // Don't allow overriding of the theme variables. |
437 | - if (isset($regOptions['theme_vars'][$row['col_name']])) |
|
438 | - unset($regOptions['theme_vars'][$row['col_name']]); |
|
474 | + if (isset($regOptions['theme_vars'][$row['col_name']])) { |
|
475 | + unset($regOptions['theme_vars'][$row['col_name']]); |
|
476 | + } |
|
439 | 477 | |
440 | 478 | // Not actually showing it then? |
441 | - if (!$row['show_reg']) |
|
442 | - continue; |
|
479 | + if (!$row['show_reg']) { |
|
480 | + continue; |
|
481 | + } |
|
443 | 482 | |
444 | 483 | // Prepare the value! |
445 | 484 | $value = isset($_POST['customfield'][$row['col_name']]) ? trim($_POST['customfield'][$row['col_name']]) : ''; |
@@ -448,24 +487,27 @@ discard block |
||
448 | 487 | if (!in_array($row['field_type'], array('check', 'select', 'radio'))) |
449 | 488 | { |
450 | 489 | // Is it too long? |
451 | - if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value)) |
|
452 | - $custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length'])); |
|
490 | + if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value)) { |
|
491 | + $custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length'])); |
|
492 | + } |
|
453 | 493 | |
454 | 494 | // Any masks to apply? |
455 | 495 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
456 | 496 | { |
457 | - if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
|
458 | - $custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name'])); |
|
459 | - elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value)) |
|
460 | - $custom_field_errors[] = array('custom_field_not_number', array($row['field_name'])); |
|
461 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
462 | - $custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name'])); |
|
497 | + if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) { |
|
498 | + $custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name'])); |
|
499 | + } elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value)) { |
|
500 | + $custom_field_errors[] = array('custom_field_not_number', array($row['field_name'])); |
|
501 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) { |
|
502 | + $custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name'])); |
|
503 | + } |
|
463 | 504 | } |
464 | 505 | } |
465 | 506 | |
466 | 507 | // Is this required but not there? |
467 | - if (trim($value) == '' && $row['show_reg'] > 1) |
|
468 | - $custom_field_errors[] = array('custom_field_empty', array($row['field_name'])); |
|
508 | + if (trim($value) == '' && $row['show_reg'] > 1) { |
|
509 | + $custom_field_errors[] = array('custom_field_empty', array($row['field_name'])); |
|
510 | + } |
|
469 | 511 | } |
470 | 512 | $smcFunc['db_free_result']($request); |
471 | 513 | |
@@ -473,8 +515,9 @@ discard block |
||
473 | 515 | if (!empty($custom_field_errors)) |
474 | 516 | { |
475 | 517 | loadLanguage('Errors'); |
476 | - foreach ($custom_field_errors as $error) |
|
477 | - $reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]); |
|
518 | + foreach ($custom_field_errors as $error) { |
|
519 | + $reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]); |
|
520 | + } |
|
478 | 521 | } |
479 | 522 | |
480 | 523 | // Lets check for other errors before trying to register the member. |
@@ -519,8 +562,9 @@ discard block |
||
519 | 562 | } |
520 | 563 | |
521 | 564 | // If COPPA has been selected then things get complicated, setup the template. |
522 | - if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) |
|
523 | - redirectexit('action=coppa;member=' . $memberID); |
|
565 | + if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) { |
|
566 | + redirectexit('action=coppa;member=' . $memberID); |
|
567 | + } |
|
524 | 568 | // Basic template variable setup. |
525 | 569 | elseif (!empty($modSettings['registration_method'])) |
526 | 570 | { |
@@ -532,8 +576,7 @@ discard block |
||
532 | 576 | 'sub_template' => 'after', |
533 | 577 | 'description' => $modSettings['registration_method'] == 2 ? $txt['approval_after_registration'] : $txt['activate_after_registration'] |
534 | 578 | ); |
535 | - } |
|
536 | - else |
|
579 | + } else |
|
537 | 580 | { |
538 | 581 | call_integration_hook('integrate_activate', array($regOptions['username'])); |
539 | 582 | |
@@ -553,16 +596,18 @@ discard block |
||
553 | 596 | global $context, $txt, $modSettings, $scripturl, $sourcedir, $smcFunc, $language, $user_info; |
554 | 597 | |
555 | 598 | // Logged in users should not bother to activate their accounts |
556 | - if (!empty($user_info['id'])) |
|
557 | - redirectexit(); |
|
599 | + if (!empty($user_info['id'])) { |
|
600 | + redirectexit(); |
|
601 | + } |
|
558 | 602 | |
559 | 603 | loadLanguage('Login'); |
560 | 604 | loadTemplate('Login'); |
561 | 605 | |
562 | 606 | if (empty($_REQUEST['u']) && empty($_POST['user'])) |
563 | 607 | { |
564 | - if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3') |
|
565 | - fatal_lang_error('no_access', false); |
|
608 | + if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3') { |
|
609 | + fatal_lang_error('no_access', false); |
|
610 | + } |
|
566 | 611 | |
567 | 612 | $context['member_id'] = 0; |
568 | 613 | $context['sub_template'] = 'resend'; |
@@ -602,11 +647,13 @@ discard block |
||
602 | 647 | // Change their email address? (they probably tried a fake one first :P.) |
603 | 648 | if (isset($_POST['new_email'], $_REQUEST['passwd']) && hash_password($row['member_name'], $_REQUEST['passwd']) == $row['passwd'] && ($row['is_activated'] == 0 || $row['is_activated'] == 2)) |
604 | 649 | { |
605 | - if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3) |
|
606 | - fatal_lang_error('no_access', false); |
|
650 | + if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3) { |
|
651 | + fatal_lang_error('no_access', false); |
|
652 | + } |
|
607 | 653 | |
608 | - if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) |
|
609 | - fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false); |
|
654 | + if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) { |
|
655 | + fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false); |
|
656 | + } |
|
610 | 657 | |
611 | 658 | // Make sure their email isn't banned. |
612 | 659 | isBannedEmail($_POST['new_email'], 'cannot_register', $txt['ban_register_prohibited']); |
@@ -622,8 +669,9 @@ discard block |
||
622 | 669 | ) |
623 | 670 | ); |
624 | 671 | |
625 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
626 | - fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email']))); |
|
672 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
673 | + fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email']))); |
|
674 | + } |
|
627 | 675 | $smcFunc['db_free_result']($request); |
628 | 676 | |
629 | 677 | updateMemberData($row['id_member'], array('email_address' => $_POST['new_email'])); |
@@ -661,9 +709,9 @@ discard block |
||
661 | 709 | // Quit if this code is not right. |
662 | 710 | if (empty($_REQUEST['code']) || $row['validation_code'] != $_REQUEST['code']) |
663 | 711 | { |
664 | - if (!empty($row['is_activated'])) |
|
665 | - fatal_lang_error('already_activated', false); |
|
666 | - elseif ($row['validation_code'] == '') |
|
712 | + if (!empty($row['is_activated'])) { |
|
713 | + fatal_lang_error('already_activated', false); |
|
714 | + } elseif ($row['validation_code'] == '') |
|
667 | 715 | { |
668 | 716 | loadLanguage('Profile'); |
669 | 717 | fatal_error(sprintf($txt['registration_not_approved'], $scripturl . '?action=activate;user=' . $row['member_name']), false); |
@@ -713,8 +761,9 @@ discard block |
||
713 | 761 | loadTemplate('Register'); |
714 | 762 | |
715 | 763 | // No User ID?? |
716 | - if (!isset($_GET['member'])) |
|
717 | - fatal_lang_error('no_access', false); |
|
764 | + if (!isset($_GET['member'])) { |
|
765 | + fatal_lang_error('no_access', false); |
|
766 | + } |
|
718 | 767 | |
719 | 768 | // Get the user details... |
720 | 769 | $request = $smcFunc['db_query']('', ' |
@@ -727,8 +776,9 @@ discard block |
||
727 | 776 | 'is_coppa' => 5, |
728 | 777 | ) |
729 | 778 | ); |
730 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
731 | - fatal_lang_error('no_access', false); |
|
779 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
780 | + fatal_lang_error('no_access', false); |
|
781 | + } |
|
732 | 782 | list ($username) = $smcFunc['db_fetch_row']($request); |
733 | 783 | $smcFunc['db_free_result']($request); |
734 | 784 | |
@@ -766,8 +816,7 @@ discard block |
||
766 | 816 | echo $data; |
767 | 817 | obExit(false); |
768 | 818 | } |
769 | - } |
|
770 | - else |
|
819 | + } else |
|
771 | 820 | { |
772 | 821 | $context += array( |
773 | 822 | 'page_title' => $txt['coppa_title'], |
@@ -820,8 +869,9 @@ discard block |
||
820 | 869 | { |
821 | 870 | require_once($sourcedir . '/Subs-Graphics.php'); |
822 | 871 | |
823 | - if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) |
|
824 | - header('HTTP/1.1 400 Bad Request'); |
|
872 | + if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) { |
|
873 | + header('HTTP/1.1 400 Bad Request'); |
|
874 | + } |
|
825 | 875 | |
826 | 876 | // Otherwise just show a pre-defined letter. |
827 | 877 | elseif (isset($_REQUEST['letter'])) |
@@ -839,14 +889,13 @@ discard block |
||
839 | 889 | header('Content-Type: image/gif'); |
840 | 890 | die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B"); |
841 | 891 | } |
842 | - } |
|
843 | - |
|
844 | - elseif ($_REQUEST['format'] === '.wav') |
|
892 | + } elseif ($_REQUEST['format'] === '.wav') |
|
845 | 893 | { |
846 | 894 | require_once($sourcedir . '/Subs-Sound.php'); |
847 | 895 | |
848 | - if (!createWaveFile($code)) |
|
849 | - header('HTTP/1.1 400 Bad Request'); |
|
896 | + if (!createWaveFile($code)) { |
|
897 | + header('HTTP/1.1 400 Bad Request'); |
|
898 | + } |
|
850 | 899 | } |
851 | 900 | |
852 | 901 | // We all die one day... |