@@ -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 | * This defines every profile field known to man. |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | global $sourcedir, $profile_vars; |
30 | 31 | |
31 | 32 | // Don't load this twice! |
32 | - if (!empty($profile_fields) && !$force_reload) |
|
33 | - return; |
|
33 | + if (!empty($profile_fields) && !$force_reload) { |
|
34 | + return; |
|
35 | + } |
|
34 | 36 | |
35 | 37 | /* This horrific array defines all the profile fields in the whole world! |
36 | 38 | In general each "field" has one array - the key of which is the database column name associated with said field. Each item |
@@ -103,13 +105,14 @@ discard block |
||
103 | 105 | if (isset($_POST['bday2'], $_POST['bday3']) && $value > 0 && $_POST['bday2'] > 0) |
104 | 106 | { |
105 | 107 | // Set to blank? |
106 | - if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) |
|
107 | - $value = '1004-01-01'; |
|
108 | - else |
|
109 | - $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01'; |
|
108 | + if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) { |
|
109 | + $value = '1004-01-01'; |
|
110 | + } else { |
|
111 | + $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01'; |
|
112 | + } |
|
113 | + } else { |
|
114 | + $value = '1004-01-01'; |
|
110 | 115 | } |
111 | - else |
|
112 | - $value = '1004-01-01'; |
|
113 | 116 | |
114 | 117 | $profile_vars['birthdate'] = $value; |
115 | 118 | $cur_profile['birthdate'] = $value; |
@@ -127,8 +130,7 @@ discard block |
||
127 | 130 | { |
128 | 131 | $value = checkdate($dates[2], $dates[3], $dates[1] < 4 ? 4 : $dates[1]) ? sprintf('%04d-%02d-%02d', $dates[1] < 4 ? 4 : $dates[1], $dates[2], $dates[3]) : '1004-01-01'; |
129 | 132 | return true; |
130 | - } |
|
131 | - else |
|
133 | + } else |
|
132 | 134 | { |
133 | 135 | $value = empty($cur_profile['birthdate']) ? '1004-01-01' : $cur_profile['birthdate']; |
134 | 136 | return false; |
@@ -150,10 +152,11 @@ discard block |
||
150 | 152 | return $txt['invalid_registration'] . ' ' . strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%H:%M:%S'), forum_time(false)); |
151 | 153 | } |
152 | 154 | // As long as it doesn't equal "N/A"... |
153 | - elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) |
|
154 | - $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
155 | - else |
|
156 | - $value = $cur_profile['date_registered']; |
|
155 | + elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) { |
|
156 | + $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
157 | + } else { |
|
158 | + $value = $cur_profile['date_registered']; |
|
159 | + } |
|
157 | 160 | |
158 | 161 | return true; |
159 | 162 | }, |
@@ -177,8 +180,9 @@ discard block |
||
177 | 180 | { |
178 | 181 | global $context, $old_profile, $profile_vars, $sourcedir, $modSettings; |
179 | 182 | |
180 | - if (strtolower($value) == strtolower($old_profile['email_address'])) |
|
181 | - return false; |
|
183 | + if (strtolower($value) == strtolower($old_profile['email_address'])) { |
|
184 | + return false; |
|
185 | + } |
|
182 | 186 | |
183 | 187 | $isValid = profileValidateEmail($value, $context['id_member']); |
184 | 188 | |
@@ -254,11 +258,11 @@ discard block |
||
254 | 258 | |
255 | 259 | if (isset($context['profile_languages'][$value])) |
256 | 260 | { |
257 | - if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) |
|
258 | - $_SESSION['language'] = $value; |
|
261 | + if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) { |
|
262 | + $_SESSION['language'] = $value; |
|
263 | + } |
|
259 | 264 | return true; |
260 | - } |
|
261 | - else |
|
265 | + } else |
|
262 | 266 | { |
263 | 267 | $value = $cur_profile['lngfile']; |
264 | 268 | return false; |
@@ -282,13 +286,14 @@ discard block |
||
282 | 286 | |
283 | 287 | // Maybe they are trying to change their password as well? |
284 | 288 | $resetPassword = true; |
285 | - if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) |
|
286 | - $resetPassword = false; |
|
289 | + if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) { |
|
290 | + $resetPassword = false; |
|
291 | + } |
|
287 | 292 | |
288 | 293 | // Do the reset... this will send them an email too. |
289 | - if ($resetPassword) |
|
290 | - resetPassword($context['id_member'], $value); |
|
291 | - elseif ($value !== null) |
|
294 | + if ($resetPassword) { |
|
295 | + resetPassword($context['id_member'], $value); |
|
296 | + } elseif ($value !== null) |
|
292 | 297 | { |
293 | 298 | validateUsername($context['id_member'], 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' : ''), ' ', $value))); |
294 | 299 | updateMemberData($context['id_member'], array('member_name' => $value)); |
@@ -312,20 +317,23 @@ discard block |
||
312 | 317 | 'input_validate' => function(&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile) |
313 | 318 | { |
314 | 319 | // If we didn't try it then ignore it! |
315 | - if ($value == '') |
|
316 | - return false; |
|
320 | + if ($value == '') { |
|
321 | + return false; |
|
322 | + } |
|
317 | 323 | |
318 | 324 | // Do the two entries for the password even match? |
319 | - if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) |
|
320 | - return 'bad_new_password'; |
|
325 | + if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) { |
|
326 | + return 'bad_new_password'; |
|
327 | + } |
|
321 | 328 | |
322 | 329 | // Let's get the validation function into play... |
323 | 330 | require_once($sourcedir . '/Subs-Auth.php'); |
324 | 331 | $passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])); |
325 | 332 | |
326 | 333 | // Were there errors? |
327 | - if ($passwordErrors != null) |
|
328 | - return 'password_' . $passwordErrors; |
|
334 | + if ($passwordErrors != null) { |
|
335 | + return 'password_' . $passwordErrors; |
|
336 | + } |
|
329 | 337 | |
330 | 338 | // Set up the new password variable... ready for storage. |
331 | 339 | $value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value)); |
@@ -350,8 +358,9 @@ discard block |
||
350 | 358 | 'permission' => 'profile_blurb', |
351 | 359 | 'input_validate' => function(&$value) use ($smcFunc) |
352 | 360 | { |
353 | - if ($smcFunc['strlen']($value) > 50) |
|
354 | - return 'personal_text_too_long'; |
|
361 | + if ($smcFunc['strlen']($value) > 50) { |
|
362 | + return 'personal_text_too_long'; |
|
363 | + } |
|
355 | 364 | |
356 | 365 | return true; |
357 | 366 | }, |
@@ -386,10 +395,11 @@ discard block |
||
386 | 395 | 'permission' => 'moderate_forum', |
387 | 396 | 'input_validate' => function(&$value) |
388 | 397 | { |
389 | - if (!is_numeric($value)) |
|
390 | - return 'digits_only'; |
|
391 | - else |
|
392 | - $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
398 | + if (!is_numeric($value)) { |
|
399 | + return 'digits_only'; |
|
400 | + } else { |
|
401 | + $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
402 | + } |
|
393 | 403 | return true; |
394 | 404 | }, |
395 | 405 | ), |
@@ -405,15 +415,16 @@ discard block |
||
405 | 415 | { |
406 | 416 | $value = 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' : ''), ' ', $value)); |
407 | 417 | |
408 | - if (trim($value) == '') |
|
409 | - return 'no_name'; |
|
410 | - elseif ($smcFunc['strlen']($value) > 60) |
|
411 | - return 'name_too_long'; |
|
412 | - elseif ($cur_profile['real_name'] != $value) |
|
418 | + if (trim($value) == '') { |
|
419 | + return 'no_name'; |
|
420 | + } elseif ($smcFunc['strlen']($value) > 60) { |
|
421 | + return 'name_too_long'; |
|
422 | + } elseif ($cur_profile['real_name'] != $value) |
|
413 | 423 | { |
414 | 424 | require_once($sourcedir . '/Subs-Members.php'); |
415 | - if (isReservedName($value, $context['id_member'])) |
|
416 | - return 'name_taken'; |
|
425 | + if (isReservedName($value, $context['id_member'])) { |
|
426 | + return 'name_taken'; |
|
427 | + } |
|
417 | 428 | } |
418 | 429 | return true; |
419 | 430 | }, |
@@ -471,8 +482,9 @@ discard block |
||
471 | 482 | 'selected' => $set == $context['member']['smiley_set']['id'] |
472 | 483 | ); |
473 | 484 | |
474 | - if ($context['smiley_sets'][$i]['selected']) |
|
475 | - $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
485 | + if ($context['smiley_sets'][$i]['selected']) { |
|
486 | + $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
487 | + } |
|
476 | 488 | } |
477 | 489 | return true; |
478 | 490 | }, |
@@ -481,8 +493,9 @@ discard block |
||
481 | 493 | global $modSettings; |
482 | 494 | |
483 | 495 | $smiley_sets = explode(',', $modSettings['smiley_sets_known']); |
484 | - if (!in_array($value, $smiley_sets) && $value != 'none') |
|
485 | - $value = ''; |
|
496 | + if (!in_array($value, $smiley_sets) && $value != 'none') { |
|
497 | + $value = ''; |
|
498 | + } |
|
486 | 499 | return true; |
487 | 500 | }, |
488 | 501 | ), |
@@ -497,8 +510,9 @@ discard block |
||
497 | 510 | loadLanguage('Settings'); |
498 | 511 | |
499 | 512 | $context['allow_no_censored'] = false; |
500 | - if ($user_info['is_admin'] || $context['user']['is_owner']) |
|
501 | - $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
513 | + if ($user_info['is_admin'] || $context['user']['is_owner']) { |
|
514 | + $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
515 | + } |
|
502 | 516 | |
503 | 517 | return true; |
504 | 518 | }, |
@@ -545,8 +559,9 @@ discard block |
||
545 | 559 | 'input_validate' => function($value) |
546 | 560 | { |
547 | 561 | $tz = smf_list_timezones(); |
548 | - if (!isset($tz[$value])) |
|
549 | - return 'bad_timezone'; |
|
562 | + if (!isset($tz[$value])) { |
|
563 | + return 'bad_timezone'; |
|
564 | + } |
|
550 | 565 | |
551 | 566 | return true; |
552 | 567 | }, |
@@ -561,8 +576,9 @@ discard block |
||
561 | 576 | 'enabled' => !empty($modSettings['titlesEnable']), |
562 | 577 | 'input_validate' => function(&$value) use ($smcFunc) |
563 | 578 | { |
564 | - if ($smcFunc['strlen']($value) > 50) |
|
565 | - return 'user_title_too_long'; |
|
579 | + if ($smcFunc['strlen']($value) > 50) { |
|
580 | + return 'user_title_too_long'; |
|
581 | + } |
|
566 | 582 | |
567 | 583 | return true; |
568 | 584 | }, |
@@ -584,10 +600,12 @@ discard block |
||
584 | 600 | // Fix the URL... |
585 | 601 | 'input_validate' => function(&$value) |
586 | 602 | { |
587 | - if (strlen(trim($value)) > 0 && strpos($value, '://') === false) |
|
588 | - $value = 'http://' . $value; |
|
589 | - if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) |
|
590 | - $value = ''; |
|
603 | + if (strlen(trim($value)) > 0 && strpos($value, '://') === false) { |
|
604 | + $value = 'http://' . $value; |
|
605 | + } |
|
606 | + if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) { |
|
607 | + $value = ''; |
|
608 | + } |
|
591 | 609 | return true; |
592 | 610 | }, |
593 | 611 | 'link_with' => 'website', |
@@ -601,16 +619,19 @@ discard block |
||
601 | 619 | foreach ($profile_fields as $key => $field) |
602 | 620 | { |
603 | 621 | // Do we have permission to do this? |
604 | - if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) |
|
605 | - unset($profile_fields[$key]); |
|
622 | + if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) { |
|
623 | + unset($profile_fields[$key]); |
|
624 | + } |
|
606 | 625 | |
607 | 626 | // Is it enabled? |
608 | - if (isset($field['enabled']) && !$field['enabled']) |
|
609 | - unset($profile_fields[$key]); |
|
627 | + if (isset($field['enabled']) && !$field['enabled']) { |
|
628 | + unset($profile_fields[$key]); |
|
629 | + } |
|
610 | 630 | |
611 | 631 | // Is it specifically disabled? |
612 | - if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) |
|
613 | - unset($profile_fields[$key]); |
|
632 | + if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) { |
|
633 | + unset($profile_fields[$key]); |
|
634 | + } |
|
614 | 635 | } |
615 | 636 | } |
616 | 637 | |
@@ -635,9 +656,10 @@ discard block |
||
635 | 656 | loadProfileFields(true); |
636 | 657 | |
637 | 658 | // First check for any linked sets. |
638 | - foreach ($profile_fields as $key => $field) |
|
639 | - if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
659 | + foreach ($profile_fields as $key => $field) { |
|
660 | + if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
640 | 661 | $fields[] = $key; |
662 | + } |
|
641 | 663 | |
642 | 664 | $i = 0; |
643 | 665 | $last_type = ''; |
@@ -649,38 +671,46 @@ discard block |
||
649 | 671 | $cur_field = &$profile_fields[$field]; |
650 | 672 | |
651 | 673 | // Does it have a preload and does that preload succeed? |
652 | - if (isset($cur_field['preload']) && !$cur_field['preload']()) |
|
653 | - continue; |
|
674 | + if (isset($cur_field['preload']) && !$cur_field['preload']()) { |
|
675 | + continue; |
|
676 | + } |
|
654 | 677 | |
655 | 678 | // If this is anything but complex we need to do more cleaning! |
656 | 679 | if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden') |
657 | 680 | { |
658 | - if (!isset($cur_field['label'])) |
|
659 | - $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
681 | + if (!isset($cur_field['label'])) { |
|
682 | + $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
683 | + } |
|
660 | 684 | |
661 | 685 | // Everything has a value! |
662 | - if (!isset($cur_field['value'])) |
|
663 | - $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
686 | + if (!isset($cur_field['value'])) { |
|
687 | + $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
688 | + } |
|
664 | 689 | |
665 | 690 | // Any input attributes? |
666 | 691 | $cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : ''; |
667 | 692 | } |
668 | 693 | |
669 | 694 | // Was there an error with this field on posting? |
670 | - if (isset($context['profile_errors'][$field])) |
|
671 | - $cur_field['is_error'] = true; |
|
695 | + if (isset($context['profile_errors'][$field])) { |
|
696 | + $cur_field['is_error'] = true; |
|
697 | + } |
|
672 | 698 | |
673 | 699 | // Any javascript stuff? |
674 | - if (!empty($cur_field['js_submit'])) |
|
675 | - $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
676 | - if (!empty($cur_field['js'])) |
|
677 | - $context['profile_javascript'] .= $cur_field['js']; |
|
700 | + if (!empty($cur_field['js_submit'])) { |
|
701 | + $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
702 | + } |
|
703 | + if (!empty($cur_field['js'])) { |
|
704 | + $context['profile_javascript'] .= $cur_field['js']; |
|
705 | + } |
|
678 | 706 | |
679 | 707 | // Any template stuff? |
680 | - if (!empty($cur_field['prehtml'])) |
|
681 | - $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
682 | - if (!empty($cur_field['posthtml'])) |
|
683 | - $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
708 | + if (!empty($cur_field['prehtml'])) { |
|
709 | + $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
710 | + } |
|
711 | + if (!empty($cur_field['posthtml'])) { |
|
712 | + $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
713 | + } |
|
684 | 714 | |
685 | 715 | // Finally put it into context? |
686 | 716 | if ($cur_field['type'] != 'hidden') |
@@ -713,12 +743,14 @@ discard block |
||
713 | 743 | }, false);' : ''), true); |
714 | 744 | |
715 | 745 | // Any onsubmit javascript? |
716 | - if (!empty($context['profile_onsubmit_javascript'])) |
|
717 | - addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
746 | + if (!empty($context['profile_onsubmit_javascript'])) { |
|
747 | + addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
748 | + } |
|
718 | 749 | |
719 | 750 | // Any totally custom stuff? |
720 | - if (!empty($context['profile_javascript'])) |
|
721 | - addInlineJavaScript($context['profile_javascript'], true); |
|
751 | + if (!empty($context['profile_javascript'])) { |
|
752 | + addInlineJavaScript($context['profile_javascript'], true); |
|
753 | + } |
|
722 | 754 | |
723 | 755 | // Free up some memory. |
724 | 756 | unset($profile_fields); |
@@ -739,8 +771,9 @@ discard block |
||
739 | 771 | |
740 | 772 | // This allows variables to call activities when they save - by default just to reload their settings |
741 | 773 | $context['profile_execute_on_save'] = array(); |
742 | - if ($context['user']['is_owner']) |
|
743 | - $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
774 | + if ($context['user']['is_owner']) { |
|
775 | + $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
776 | + } |
|
744 | 777 | |
745 | 778 | // Assume we log nothing. |
746 | 779 | $context['log_changes'] = array(); |
@@ -748,8 +781,9 @@ discard block |
||
748 | 781 | // Cycle through the profile fields working out what to do! |
749 | 782 | foreach ($profile_fields as $key => $field) |
750 | 783 | { |
751 | - if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) |
|
752 | - continue; |
|
784 | + if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) { |
|
785 | + continue; |
|
786 | + } |
|
753 | 787 | |
754 | 788 | // What gets updated? |
755 | 789 | $db_key = isset($field['save_key']) ? $field['save_key'] : $key; |
@@ -777,12 +811,13 @@ discard block |
||
777 | 811 | $field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type']; |
778 | 812 | |
779 | 813 | // Finally, clean up certain types. |
780 | - if ($field['cast_type'] == 'int') |
|
781 | - $_POST[$key] = (int) $_POST[$key]; |
|
782 | - elseif ($field['cast_type'] == 'float') |
|
783 | - $_POST[$key] = (float) $_POST[$key]; |
|
784 | - elseif ($field['cast_type'] == 'check') |
|
785 | - $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
814 | + if ($field['cast_type'] == 'int') { |
|
815 | + $_POST[$key] = (int) $_POST[$key]; |
|
816 | + } elseif ($field['cast_type'] == 'float') { |
|
817 | + $_POST[$key] = (float) $_POST[$key]; |
|
818 | + } elseif ($field['cast_type'] == 'check') { |
|
819 | + $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
820 | + } |
|
786 | 821 | |
787 | 822 | // If we got here we're doing OK. |
788 | 823 | if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key])) |
@@ -793,11 +828,12 @@ discard block |
||
793 | 828 | $cur_profile[$key] = $_POST[$key]; |
794 | 829 | |
795 | 830 | // Are we logging it? |
796 | - if (!empty($field['log_change']) && isset($old_profile[$key])) |
|
797 | - $context['log_changes'][$key] = array( |
|
831 | + if (!empty($field['log_change']) && isset($old_profile[$key])) { |
|
832 | + $context['log_changes'][$key] = array( |
|
798 | 833 | 'previous' => $old_profile[$key], |
799 | 834 | 'new' => $_POST[$key], |
800 | 835 | ); |
836 | + } |
|
801 | 837 | } |
802 | 838 | |
803 | 839 | // Logging group changes are a bit different... |
@@ -830,10 +866,11 @@ discard block |
||
830 | 866 | { |
831 | 867 | foreach ($groups as $id => $group) |
832 | 868 | { |
833 | - if (isset($context['member_groups'][$group])) |
|
834 | - $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
835 | - else |
|
836 | - unset($additional_groups[$type][$id]); |
|
869 | + if (isset($context['member_groups'][$group])) { |
|
870 | + $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
871 | + } else { |
|
872 | + unset($additional_groups[$type][$id]); |
|
873 | + } |
|
837 | 874 | } |
838 | 875 | $additional_groups[$type] = implode(', ', $additional_groups[$type]); |
839 | 876 | } |
@@ -844,10 +881,11 @@ discard block |
||
844 | 881 | } |
845 | 882 | |
846 | 883 | // @todo Temporary |
847 | - if ($context['user']['is_owner']) |
|
848 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
849 | - else |
|
850 | - $changeOther = allowedTo('profile_extra_any'); |
|
884 | + if ($context['user']['is_owner']) { |
|
885 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
886 | + } else { |
|
887 | + $changeOther = allowedTo('profile_extra_any'); |
|
888 | + } |
|
851 | 889 | if ($changeOther && empty($post_errors)) |
852 | 890 | { |
853 | 891 | makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
@@ -855,8 +893,9 @@ discard block |
||
855 | 893 | { |
856 | 894 | $custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true); |
857 | 895 | |
858 | - if (!empty($custom_fields_errors)) |
|
859 | - $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
896 | + if (!empty($custom_fields_errors)) { |
|
897 | + $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
898 | + } |
|
860 | 899 | } |
861 | 900 | } |
862 | 901 | |
@@ -882,9 +921,9 @@ discard block |
||
882 | 921 | if ($context['user']['is_owner']) |
883 | 922 | { |
884 | 923 | $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own')); |
924 | + } else { |
|
925 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
885 | 926 | } |
886 | - else |
|
887 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
888 | 927 | |
889 | 928 | // Arrays of all the changes - makes things easier. |
890 | 929 | $profile_bools = array(); |
@@ -895,22 +934,25 @@ discard block |
||
895 | 934 | 'ignore_boards', |
896 | 935 | ); |
897 | 936 | |
898 | - if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) |
|
899 | - $_POST['ignore_brd'] = array(); |
|
937 | + if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) { |
|
938 | + $_POST['ignore_brd'] = array(); |
|
939 | + } |
|
900 | 940 | |
901 | 941 | unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing. Kinda like our minds. |
902 | 942 | if (isset($_POST['ignore_brd'])) |
903 | 943 | { |
904 | - if (!is_array($_POST['ignore_brd'])) |
|
905 | - $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
944 | + if (!is_array($_POST['ignore_brd'])) { |
|
945 | + $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
946 | + } |
|
906 | 947 | |
907 | 948 | foreach ($_POST['ignore_brd'] as $k => $d) |
908 | 949 | { |
909 | 950 | $d = (int) $d; |
910 | - if ($d != 0) |
|
911 | - $_POST['ignore_brd'][$k] = $d; |
|
912 | - else |
|
913 | - unset($_POST['ignore_brd'][$k]); |
|
951 | + if ($d != 0) { |
|
952 | + $_POST['ignore_brd'][$k] = $d; |
|
953 | + } else { |
|
954 | + unset($_POST['ignore_brd'][$k]); |
|
955 | + } |
|
914 | 956 | } |
915 | 957 | $_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']); |
916 | 958 | unset($_POST['ignore_brd']); |
@@ -923,21 +965,26 @@ discard block |
||
923 | 965 | makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
924 | 966 | //makeAvatarChanges($memID, $post_errors); |
925 | 967 | |
926 | - if (!empty($_REQUEST['sa'])) |
|
927 | - makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
968 | + if (!empty($_REQUEST['sa'])) { |
|
969 | + makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
970 | + } |
|
928 | 971 | |
929 | - foreach ($profile_bools as $var) |
|
930 | - if (isset($_POST[$var])) |
|
972 | + foreach ($profile_bools as $var) { |
|
973 | + if (isset($_POST[$var])) |
|
931 | 974 | $profile_vars[$var] = empty($_POST[$var]) ? '0' : '1'; |
932 | - foreach ($profile_ints as $var) |
|
933 | - if (isset($_POST[$var])) |
|
975 | + } |
|
976 | + foreach ($profile_ints as $var) { |
|
977 | + if (isset($_POST[$var])) |
|
934 | 978 | $profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : ''; |
935 | - foreach ($profile_floats as $var) |
|
936 | - if (isset($_POST[$var])) |
|
979 | + } |
|
980 | + foreach ($profile_floats as $var) { |
|
981 | + if (isset($_POST[$var])) |
|
937 | 982 | $profile_vars[$var] = (float) $_POST[$var]; |
938 | - foreach ($profile_strings as $var) |
|
939 | - if (isset($_POST[$var])) |
|
983 | + } |
|
984 | + foreach ($profile_strings as $var) { |
|
985 | + if (isset($_POST[$var])) |
|
940 | 986 | $profile_vars[$var] = $_POST[$var]; |
987 | + } |
|
941 | 988 | } |
942 | 989 | } |
943 | 990 | |
@@ -971,8 +1018,9 @@ discard block |
||
971 | 1018 | ); |
972 | 1019 | |
973 | 1020 | // Can't change reserved vars. |
974 | - if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) |
|
975 | - fatal_lang_error('no_access', false); |
|
1021 | + if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) { |
|
1022 | + fatal_lang_error('no_access', false); |
|
1023 | + } |
|
976 | 1024 | |
977 | 1025 | // Don't allow any overriding of custom fields with default or non-default options. |
978 | 1026 | $request = $smcFunc['db_query']('', ' |
@@ -984,8 +1032,9 @@ discard block |
||
984 | 1032 | ) |
985 | 1033 | ); |
986 | 1034 | $custom_fields = array(); |
987 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
988 | - $custom_fields[] = $row['col_name']; |
|
1035 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1036 | + $custom_fields[] = $row['col_name']; |
|
1037 | + } |
|
989 | 1038 | $smcFunc['db_free_result']($request); |
990 | 1039 | |
991 | 1040 | // These are the theme changes... |
@@ -994,33 +1043,39 @@ discard block |
||
994 | 1043 | { |
995 | 1044 | foreach ($_POST['options'] as $opt => $val) |
996 | 1045 | { |
997 | - if (in_array($opt, $custom_fields)) |
|
998 | - continue; |
|
1046 | + if (in_array($opt, $custom_fields)) { |
|
1047 | + continue; |
|
1048 | + } |
|
999 | 1049 | |
1000 | 1050 | // These need to be controlled. |
1001 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
1002 | - $val = max(0, min($val, 50)); |
|
1051 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
1052 | + $val = max(0, min($val, 50)); |
|
1053 | + } |
|
1003 | 1054 | // We don't set this per theme anymore. |
1004 | - elseif ($opt == 'allow_no_censored') |
|
1005 | - continue; |
|
1055 | + elseif ($opt == 'allow_no_censored') { |
|
1056 | + continue; |
|
1057 | + } |
|
1006 | 1058 | |
1007 | 1059 | $themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val); |
1008 | 1060 | } |
1009 | 1061 | } |
1010 | 1062 | |
1011 | 1063 | $erase_options = array(); |
1012 | - if (isset($_POST['default_options']) && is_array($_POST['default_options'])) |
|
1013 | - foreach ($_POST['default_options'] as $opt => $val) |
|
1064 | + if (isset($_POST['default_options']) && is_array($_POST['default_options'])) { |
|
1065 | + foreach ($_POST['default_options'] as $opt => $val) |
|
1014 | 1066 | { |
1015 | 1067 | if (in_array($opt, $custom_fields)) |
1016 | 1068 | continue; |
1069 | + } |
|
1017 | 1070 | |
1018 | 1071 | // These need to be controlled. |
1019 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
1020 | - $val = max(0, min($val, 50)); |
|
1072 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
1073 | + $val = max(0, min($val, 50)); |
|
1074 | + } |
|
1021 | 1075 | // Only let admins and owners change the censor. |
1022 | - elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) |
|
1023 | - continue; |
|
1076 | + elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) { |
|
1077 | + continue; |
|
1078 | + } |
|
1024 | 1079 | |
1025 | 1080 | $themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
1026 | 1081 | $erase_options[] = $opt; |
@@ -1056,8 +1111,9 @@ discard block |
||
1056 | 1111 | |
1057 | 1112 | // Admins can choose any theme, even if it's not enabled... |
1058 | 1113 | $themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']); |
1059 | - foreach ($themes as $t) |
|
1060 | - cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
1114 | + foreach ($themes as $t) { |
|
1115 | + cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
1116 | + } |
|
1061 | 1117 | } |
1062 | 1118 | } |
1063 | 1119 | |
@@ -1076,8 +1132,9 @@ discard block |
||
1076 | 1132 | if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards'])) |
1077 | 1133 | { |
1078 | 1134 | // Make sure only integers are deleted. |
1079 | - foreach ($_POST['notify_boards'] as $index => $id) |
|
1080 | - $_POST['notify_boards'][$index] = (int) $id; |
|
1135 | + foreach ($_POST['notify_boards'] as $index => $id) { |
|
1136 | + $_POST['notify_boards'][$index] = (int) $id; |
|
1137 | + } |
|
1081 | 1138 | |
1082 | 1139 | // id_board = 0 is reserved for topic notifications. |
1083 | 1140 | $_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0)); |
@@ -1096,8 +1153,9 @@ discard block |
||
1096 | 1153 | // We are editing topic notifications...... |
1097 | 1154 | elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics'])) |
1098 | 1155 | { |
1099 | - foreach ($_POST['notify_topics'] as $index => $id) |
|
1100 | - $_POST['notify_topics'][$index] = (int) $id; |
|
1156 | + foreach ($_POST['notify_topics'] as $index => $id) { |
|
1157 | + $_POST['notify_topics'][$index] = (int) $id; |
|
1158 | + } |
|
1101 | 1159 | |
1102 | 1160 | // Make sure there are no zeros left. |
1103 | 1161 | $_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0)); |
@@ -1111,16 +1169,18 @@ discard block |
||
1111 | 1169 | 'selected_member' => $memID, |
1112 | 1170 | ) |
1113 | 1171 | ); |
1114 | - foreach ($_POST['notify_topics'] as $topic) |
|
1115 | - setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
1172 | + foreach ($_POST['notify_topics'] as $topic) { |
|
1173 | + setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
1174 | + } |
|
1116 | 1175 | } |
1117 | 1176 | |
1118 | 1177 | // We are removing topic preferences |
1119 | 1178 | elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics'])) |
1120 | 1179 | { |
1121 | 1180 | $prefs = array(); |
1122 | - foreach ($_POST['notify_topics'] as $topic) |
|
1123 | - $prefs[] = 'topic_notify_' . $topic; |
|
1181 | + foreach ($_POST['notify_topics'] as $topic) { |
|
1182 | + $prefs[] = 'topic_notify_' . $topic; |
|
1183 | + } |
|
1124 | 1184 | deleteNotifyPrefs($memID, $prefs); |
1125 | 1185 | } |
1126 | 1186 | |
@@ -1128,8 +1188,9 @@ discard block |
||
1128 | 1188 | elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards'])) |
1129 | 1189 | { |
1130 | 1190 | $prefs = array(); |
1131 | - foreach ($_POST['notify_boards'] as $board) |
|
1132 | - $prefs[] = 'board_notify_' . $board; |
|
1191 | + foreach ($_POST['notify_boards'] as $board) { |
|
1192 | + $prefs[] = 'board_notify_' . $board; |
|
1193 | + } |
|
1133 | 1194 | deleteNotifyPrefs($memID, $prefs); |
1134 | 1195 | } |
1135 | 1196 | } |
@@ -1150,8 +1211,9 @@ discard block |
||
1150 | 1211 | |
1151 | 1212 | $errors = array(); |
1152 | 1213 | |
1153 | - if ($sanitize && isset($_POST['customfield'])) |
|
1154 | - $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
1214 | + if ($sanitize && isset($_POST['customfield'])) { |
|
1215 | + $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
1216 | + } |
|
1155 | 1217 | |
1156 | 1218 | $where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}'; |
1157 | 1219 | |
@@ -1176,26 +1238,29 @@ discard block |
||
1176 | 1238 | - The data is not invisible to users but editable by the owner (or if it is the user is not the owner) |
1177 | 1239 | - The area isn't registration, and if it is that the field is not supposed to be shown there. |
1178 | 1240 | */ |
1179 | - if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) |
|
1180 | - continue; |
|
1241 | + if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) { |
|
1242 | + continue; |
|
1243 | + } |
|
1181 | 1244 | |
1182 | 1245 | // Validate the user data. |
1183 | - if ($row['field_type'] == 'check') |
|
1184 | - $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
1185 | - elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
1246 | + if ($row['field_type'] == 'check') { |
|
1247 | + $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
1248 | + } elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
1186 | 1249 | { |
1187 | 1250 | $value = $row['default_value']; |
1188 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
1189 | - if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
1251 | + foreach (explode(',', $row['field_options']) as $k => $v) { |
|
1252 | + if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
1190 | 1253 | $value = $v; |
1254 | + } |
|
1191 | 1255 | } |
1192 | 1256 | // Otherwise some form of text! |
1193 | 1257 | else |
1194 | 1258 | { |
1195 | 1259 | $value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : ''; |
1196 | 1260 | |
1197 | - if ($row['field_length']) |
|
1198 | - $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
1261 | + if ($row['field_length']) { |
|
1262 | + $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
1263 | + } |
|
1199 | 1264 | |
1200 | 1265 | // Any masks? |
1201 | 1266 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
@@ -1204,36 +1269,34 @@ discard block |
||
1204 | 1269 | $valueReference = un_htmlspecialchars($value); |
1205 | 1270 | |
1206 | 1271 | // Try and avoid some checks. '0' could be a valid non-empty value. |
1207 | - if (empty($value) && !is_numeric($value)) |
|
1208 | - $value = ''; |
|
1272 | + if (empty($value) && !is_numeric($value)) { |
|
1273 | + $value = ''; |
|
1274 | + } |
|
1209 | 1275 | |
1210 | 1276 | if ($row['mask'] == 'nohtml' && ($valueReference != strip_tags($valueReference) || $value != filter_var($value, FILTER_SANITIZE_STRING) || preg_match('/<(.+?)[\s]*\/?[\s]*>/si', $valueReference))) |
1211 | 1277 | { |
1212 | - if ($returnErrors) |
|
1213 | - $errors[] = 'custom_field_nohtml_fail'; |
|
1214 | - |
|
1215 | - else |
|
1216 | - $value = ''; |
|
1217 | - } |
|
1218 | - elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
|
1278 | + if ($returnErrors) { |
|
1279 | + $errors[] = 'custom_field_nohtml_fail'; |
|
1280 | + } else { |
|
1281 | + $value = ''; |
|
1282 | + } |
|
1283 | + } elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
|
1219 | 1284 | { |
1220 | - if ($returnErrors) |
|
1221 | - $errors[] = 'custom_field_mail_fail'; |
|
1222 | - |
|
1223 | - else |
|
1224 | - $value = ''; |
|
1225 | - } |
|
1226 | - elseif ($row['mask'] == 'number') |
|
1285 | + if ($returnErrors) { |
|
1286 | + $errors[] = 'custom_field_mail_fail'; |
|
1287 | + } else { |
|
1288 | + $value = ''; |
|
1289 | + } |
|
1290 | + } elseif ($row['mask'] == 'number') |
|
1227 | 1291 | { |
1228 | 1292 | $value = (int) $value; |
1229 | - } |
|
1230 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
1293 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
1231 | 1294 | { |
1232 | - if ($returnErrors) |
|
1233 | - $errors[] = 'custom_field_regex_fail'; |
|
1234 | - |
|
1235 | - else |
|
1236 | - $value = ''; |
|
1295 | + if ($returnErrors) { |
|
1296 | + $errors[] = 'custom_field_regex_fail'; |
|
1297 | + } else { |
|
1298 | + $value = ''; |
|
1299 | + } |
|
1237 | 1300 | } |
1238 | 1301 | |
1239 | 1302 | unset($valueReference); |
@@ -1261,8 +1324,9 @@ discard block |
||
1261 | 1324 | |
1262 | 1325 | $hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize)); |
1263 | 1326 | |
1264 | - if (!empty($hook_errors) && is_array($hook_errors)) |
|
1265 | - $errors = array_merge($errors, $hook_errors); |
|
1327 | + if (!empty($hook_errors) && is_array($hook_errors)) { |
|
1328 | + $errors = array_merge($errors, $hook_errors); |
|
1329 | + } |
|
1266 | 1330 | |
1267 | 1331 | // Make those changes! |
1268 | 1332 | if (!empty($changes) && empty($context['password_auth_failed']) && empty($errors)) |
@@ -1280,9 +1344,10 @@ discard block |
||
1280 | 1344 | } |
1281 | 1345 | } |
1282 | 1346 | |
1283 | - if ($returnErrors) |
|
1284 | - return $errors; |
|
1285 | -} |
|
1347 | + if ($returnErrors) { |
|
1348 | + return $errors; |
|
1349 | + } |
|
1350 | + } |
|
1286 | 1351 | |
1287 | 1352 | /** |
1288 | 1353 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1294,8 +1359,9 @@ discard block |
||
1294 | 1359 | global $context, $txt, $modSettings; |
1295 | 1360 | |
1296 | 1361 | // Do a quick check to ensure people aren't getting here illegally! |
1297 | - if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) |
|
1298 | - fatal_lang_error('no_access', false); |
|
1362 | + if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) { |
|
1363 | + fatal_lang_error('no_access', false); |
|
1364 | + } |
|
1299 | 1365 | |
1300 | 1366 | // Can we email the user direct? |
1301 | 1367 | $context['can_moderate_forum'] = allowedTo('moderate_forum'); |
@@ -1325,9 +1391,10 @@ discard block |
||
1325 | 1391 | $context['sub_template'] = $subActions[$context['list_area']][0]; |
1326 | 1392 | $call = call_helper($subActions[$context['list_area']][0], true); |
1327 | 1393 | |
1328 | - if (!empty($call)) |
|
1329 | - call_user_func($call, $memID); |
|
1330 | -} |
|
1394 | + if (!empty($call)) { |
|
1395 | + call_user_func($call, $memID); |
|
1396 | + } |
|
1397 | + } |
|
1331 | 1398 | |
1332 | 1399 | /** |
1333 | 1400 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1341,9 +1408,10 @@ discard block |
||
1341 | 1408 | |
1342 | 1409 | // For making changes! |
1343 | 1410 | $buddiesArray = explode(',', $user_profile[$memID]['buddy_list']); |
1344 | - foreach ($buddiesArray as $k => $dummy) |
|
1345 | - if ($dummy == '') |
|
1411 | + foreach ($buddiesArray as $k => $dummy) { |
|
1412 | + if ($dummy == '') |
|
1346 | 1413 | unset($buddiesArray[$k]); |
1414 | + } |
|
1347 | 1415 | |
1348 | 1416 | // Removing a buddy? |
1349 | 1417 | if (isset($_GET['remove'])) |
@@ -1355,10 +1423,11 @@ discard block |
||
1355 | 1423 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
1356 | 1424 | |
1357 | 1425 | // Heh, I'm lazy, do it the easy way... |
1358 | - foreach ($buddiesArray as $key => $buddy) |
|
1359 | - if ($buddy == (int) $_GET['remove']) |
|
1426 | + foreach ($buddiesArray as $key => $buddy) { |
|
1427 | + if ($buddy == (int) $_GET['remove']) |
|
1360 | 1428 | { |
1361 | 1429 | unset($buddiesArray[$key]); |
1430 | + } |
|
1362 | 1431 | $_SESSION['prf-save'] = true; |
1363 | 1432 | } |
1364 | 1433 | |
@@ -1368,8 +1437,7 @@ discard block |
||
1368 | 1437 | |
1369 | 1438 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
1370 | 1439 | redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID); |
1371 | - } |
|
1372 | - elseif (isset($_POST['new_buddy'])) |
|
1440 | + } elseif (isset($_POST['new_buddy'])) |
|
1373 | 1441 | { |
1374 | 1442 | checkSession(); |
1375 | 1443 | |
@@ -1382,8 +1450,9 @@ discard block |
||
1382 | 1450 | { |
1383 | 1451 | $new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => ''')); |
1384 | 1452 | |
1385 | - if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
1386 | - unset($new_buddies[$k]); |
|
1453 | + if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
1454 | + unset($new_buddies[$k]); |
|
1455 | + } |
|
1387 | 1456 | } |
1388 | 1457 | |
1389 | 1458 | call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies)); |
@@ -1403,16 +1472,18 @@ discard block |
||
1403 | 1472 | ) |
1404 | 1473 | ); |
1405 | 1474 | |
1406 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1407 | - $_SESSION['prf-save'] = true; |
|
1475 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1476 | + $_SESSION['prf-save'] = true; |
|
1477 | + } |
|
1408 | 1478 | |
1409 | 1479 | // Add the new member to the buddies array. |
1410 | 1480 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1411 | 1481 | { |
1412 | - if (in_array($row['id_member'], $buddiesArray)) |
|
1413 | - continue; |
|
1414 | - else |
|
1415 | - $buddiesArray[] = (int) $row['id_member']; |
|
1482 | + if (in_array($row['id_member'], $buddiesArray)) { |
|
1483 | + continue; |
|
1484 | + } else { |
|
1485 | + $buddiesArray[] = (int) $row['id_member']; |
|
1486 | + } |
|
1416 | 1487 | } |
1417 | 1488 | $smcFunc['db_free_result']($request); |
1418 | 1489 | |
@@ -1442,18 +1513,20 @@ discard block |
||
1442 | 1513 | |
1443 | 1514 | $context['custom_pf'] = array(); |
1444 | 1515 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
1445 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1446 | - if (!isset($disabled_fields[$row['col_name']])) |
|
1516 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1517 | + if (!isset($disabled_fields[$row['col_name']])) |
|
1447 | 1518 | $context['custom_pf'][$row['col_name']] = array( |
1448 | 1519 | 'label' => $row['field_name'], |
1449 | 1520 | 'type' => $row['field_type'], |
1450 | 1521 | 'bbc' => !empty($row['bbc']), |
1451 | 1522 | 'enclose' => $row['enclose'], |
1452 | 1523 | ); |
1524 | + } |
|
1453 | 1525 | |
1454 | 1526 | // Gotta disable the gender option. |
1455 | - if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') |
|
1456 | - unset($context['custom_pf']['cust_gender']); |
|
1527 | + if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') { |
|
1528 | + unset($context['custom_pf']['cust_gender']); |
|
1529 | + } |
|
1457 | 1530 | |
1458 | 1531 | $smcFunc['db_free_result']($request); |
1459 | 1532 | |
@@ -1470,8 +1543,9 @@ discard block |
||
1470 | 1543 | 'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1, |
1471 | 1544 | ) |
1472 | 1545 | ); |
1473 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1474 | - $buddies[] = $row['id_member']; |
|
1546 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1547 | + $buddies[] = $row['id_member']; |
|
1548 | + } |
|
1475 | 1549 | $smcFunc['db_free_result']($result); |
1476 | 1550 | } |
1477 | 1551 | |
@@ -1499,30 +1573,32 @@ discard block |
||
1499 | 1573 | continue; |
1500 | 1574 | } |
1501 | 1575 | |
1502 | - if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) |
|
1503 | - $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
1504 | - |
|
1505 | - elseif ($column['type'] == 'check') |
|
1506 | - $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
1576 | + if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
1577 | + $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
1578 | + } elseif ($column['type'] == 'check') { |
|
1579 | + $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
1580 | + } |
|
1507 | 1581 | |
1508 | 1582 | // Enclosing the user input within some other text? |
1509 | - if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) |
|
1510 | - $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
1583 | + if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
1584 | + $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
1511 | 1585 | '{SCRIPTURL}' => $scripturl, |
1512 | 1586 | '{IMAGES_URL}' => $settings['images_url'], |
1513 | 1587 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1514 | 1588 | '{INPUT}' => $context['buddies'][$buddy]['options'][$key], |
1515 | 1589 | )); |
1590 | + } |
|
1516 | 1591 | } |
1517 | 1592 | } |
1518 | 1593 | } |
1519 | 1594 | |
1520 | 1595 | if (isset($_SESSION['prf-save'])) |
1521 | 1596 | { |
1522 | - if ($_SESSION['prf-save'] === true) |
|
1523 | - $context['saved_successful'] = true; |
|
1524 | - else |
|
1525 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
1597 | + if ($_SESSION['prf-save'] === true) { |
|
1598 | + $context['saved_successful'] = true; |
|
1599 | + } else { |
|
1600 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
1601 | + } |
|
1526 | 1602 | |
1527 | 1603 | unset($_SESSION['prf-save']); |
1528 | 1604 | } |
@@ -1542,9 +1618,10 @@ discard block |
||
1542 | 1618 | |
1543 | 1619 | // For making changes! |
1544 | 1620 | $ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']); |
1545 | - foreach ($ignoreArray as $k => $dummy) |
|
1546 | - if ($dummy == '') |
|
1621 | + foreach ($ignoreArray as $k => $dummy) { |
|
1622 | + if ($dummy == '') |
|
1547 | 1623 | unset($ignoreArray[$k]); |
1624 | + } |
|
1548 | 1625 | |
1549 | 1626 | // Removing a member from the ignore list? |
1550 | 1627 | if (isset($_GET['remove'])) |
@@ -1554,10 +1631,11 @@ discard block |
||
1554 | 1631 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
1555 | 1632 | |
1556 | 1633 | // Heh, I'm lazy, do it the easy way... |
1557 | - foreach ($ignoreArray as $key => $id_remove) |
|
1558 | - if ($id_remove == (int) $_GET['remove']) |
|
1634 | + foreach ($ignoreArray as $key => $id_remove) { |
|
1635 | + if ($id_remove == (int) $_GET['remove']) |
|
1559 | 1636 | { |
1560 | 1637 | unset($ignoreArray[$key]); |
1638 | + } |
|
1561 | 1639 | $_SESSION['prf-save'] = true; |
1562 | 1640 | } |
1563 | 1641 | |
@@ -1567,8 +1645,7 @@ discard block |
||
1567 | 1645 | |
1568 | 1646 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
1569 | 1647 | redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID); |
1570 | - } |
|
1571 | - elseif (isset($_POST['new_ignore'])) |
|
1648 | + } elseif (isset($_POST['new_ignore'])) |
|
1572 | 1649 | { |
1573 | 1650 | checkSession(); |
1574 | 1651 | // Prepare the string for extraction... |
@@ -1580,8 +1657,9 @@ discard block |
||
1580 | 1657 | { |
1581 | 1658 | $new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => ''')); |
1582 | 1659 | |
1583 | - if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
1584 | - unset($new_entries[$k]); |
|
1660 | + if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
1661 | + unset($new_entries[$k]); |
|
1662 | + } |
|
1585 | 1663 | } |
1586 | 1664 | |
1587 | 1665 | $_SESSION['prf-save'] = $txt['could_not_add_person']; |
@@ -1599,16 +1677,18 @@ discard block |
||
1599 | 1677 | ) |
1600 | 1678 | ); |
1601 | 1679 | |
1602 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1603 | - $_SESSION['prf-save'] = true; |
|
1680 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1681 | + $_SESSION['prf-save'] = true; |
|
1682 | + } |
|
1604 | 1683 | |
1605 | 1684 | // Add the new member to the buddies array. |
1606 | 1685 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1607 | 1686 | { |
1608 | - if (in_array($row['id_member'], $ignoreArray)) |
|
1609 | - continue; |
|
1610 | - else |
|
1611 | - $ignoreArray[] = (int) $row['id_member']; |
|
1687 | + if (in_array($row['id_member'], $ignoreArray)) { |
|
1688 | + continue; |
|
1689 | + } else { |
|
1690 | + $ignoreArray[] = (int) $row['id_member']; |
|
1691 | + } |
|
1612 | 1692 | } |
1613 | 1693 | $smcFunc['db_free_result']($request); |
1614 | 1694 | |
@@ -1637,8 +1717,9 @@ discard block |
||
1637 | 1717 | 'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1, |
1638 | 1718 | ) |
1639 | 1719 | ); |
1640 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1641 | - $ignored[] = $row['id_member']; |
|
1720 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1721 | + $ignored[] = $row['id_member']; |
|
1722 | + } |
|
1642 | 1723 | $smcFunc['db_free_result']($result); |
1643 | 1724 | } |
1644 | 1725 | |
@@ -1657,10 +1738,11 @@ discard block |
||
1657 | 1738 | |
1658 | 1739 | if (isset($_SESSION['prf-save'])) |
1659 | 1740 | { |
1660 | - if ($_SESSION['prf-save'] === true) |
|
1661 | - $context['saved_successful'] = true; |
|
1662 | - else |
|
1663 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
1741 | + if ($_SESSION['prf-save'] === true) { |
|
1742 | + $context['saved_successful'] = true; |
|
1743 | + } else { |
|
1744 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
1745 | + } |
|
1664 | 1746 | |
1665 | 1747 | unset($_SESSION['prf-save']); |
1666 | 1748 | } |
@@ -1676,8 +1758,9 @@ discard block |
||
1676 | 1758 | global $context, $txt; |
1677 | 1759 | |
1678 | 1760 | loadThemeOptions($memID); |
1679 | - if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) |
|
1680 | - loadCustomFields($memID, 'account'); |
|
1761 | + if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) { |
|
1762 | + loadCustomFields($memID, 'account'); |
|
1763 | + } |
|
1681 | 1764 | |
1682 | 1765 | $context['sub_template'] = 'edit_options'; |
1683 | 1766 | $context['page_desc'] = $txt['account_info']; |
@@ -1704,8 +1787,9 @@ discard block |
||
1704 | 1787 | global $context, $txt; |
1705 | 1788 | |
1706 | 1789 | loadThemeOptions($memID); |
1707 | - if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) |
|
1708 | - loadCustomFields($memID, 'forumprofile'); |
|
1790 | + if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) { |
|
1791 | + loadCustomFields($memID, 'forumprofile'); |
|
1792 | + } |
|
1709 | 1793 | |
1710 | 1794 | $context['sub_template'] = 'edit_options'; |
1711 | 1795 | $context['page_desc'] = $txt['forumProfile_info']; |
@@ -1738,18 +1822,21 @@ discard block |
||
1738 | 1822 | $dirs = array(); |
1739 | 1823 | $files = array(); |
1740 | 1824 | |
1741 | - if (!$dir) |
|
1742 | - return array(); |
|
1825 | + if (!$dir) { |
|
1826 | + return array(); |
|
1827 | + } |
|
1743 | 1828 | |
1744 | 1829 | while ($line = $dir->read()) |
1745 | 1830 | { |
1746 | - if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) |
|
1747 | - continue; |
|
1831 | + if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) { |
|
1832 | + continue; |
|
1833 | + } |
|
1748 | 1834 | |
1749 | - if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) |
|
1750 | - $dirs[] = $line; |
|
1751 | - else |
|
1752 | - $files[] = $line; |
|
1835 | + if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) { |
|
1836 | + $dirs[] = $line; |
|
1837 | + } else { |
|
1838 | + $files[] = $line; |
|
1839 | + } |
|
1753 | 1840 | } |
1754 | 1841 | $dir->close(); |
1755 | 1842 | |
@@ -1770,14 +1857,15 @@ discard block |
||
1770 | 1857 | foreach ($dirs as $line) |
1771 | 1858 | { |
1772 | 1859 | $tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1); |
1773 | - if (!empty($tmp)) |
|
1774 | - $result[] = array( |
|
1860 | + if (!empty($tmp)) { |
|
1861 | + $result[] = array( |
|
1775 | 1862 | 'filename' => $smcFunc['htmlspecialchars']($line), |
1776 | 1863 | 'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false, |
1777 | 1864 | 'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']', |
1778 | 1865 | 'is_dir' => true, |
1779 | 1866 | 'files' => $tmp |
1780 | 1867 | ); |
1868 | + } |
|
1781 | 1869 | unset($tmp); |
1782 | 1870 | } |
1783 | 1871 | |
@@ -1787,8 +1875,9 @@ discard block |
||
1787 | 1875 | $extension = substr(strrchr($line, '.'), 1); |
1788 | 1876 | |
1789 | 1877 | // Make sure it is an image. |
1790 | - if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) |
|
1791 | - continue; |
|
1878 | + if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) { |
|
1879 | + continue; |
|
1880 | + } |
|
1792 | 1881 | |
1793 | 1882 | $result[] = array( |
1794 | 1883 | 'filename' => $smcFunc['htmlspecialchars']($line), |
@@ -1796,8 +1885,9 @@ discard block |
||
1796 | 1885 | 'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)), |
1797 | 1886 | 'is_dir' => false |
1798 | 1887 | ); |
1799 | - if ($level == 1) |
|
1800 | - $context['avatar_list'][] = $directory . '/' . $line; |
|
1888 | + if ($level == 1) { |
|
1889 | + $context['avatar_list'][] = $directory . '/' . $line; |
|
1890 | + } |
|
1801 | 1891 | } |
1802 | 1892 | |
1803 | 1893 | return $result; |
@@ -1816,8 +1906,9 @@ discard block |
||
1816 | 1906 | loadSubTemplate('options'); |
1817 | 1907 | |
1818 | 1908 | loadThemeOptions($memID); |
1819 | - if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) |
|
1820 | - loadCustomFields($memID, 'theme'); |
|
1909 | + if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { |
|
1910 | + loadCustomFields($memID, 'theme'); |
|
1911 | + } |
|
1821 | 1912 | |
1822 | 1913 | $context['sub_template'] = 'edit_options'; |
1823 | 1914 | $context['page_desc'] = $txt['theme_info']; |
@@ -1871,16 +1962,19 @@ discard block |
||
1871 | 1962 | { |
1872 | 1963 | global $txt, $context, $modSettings, $smcFunc, $sourcedir; |
1873 | 1964 | |
1874 | - if (!isset($context['token_check'])) |
|
1875 | - $context['token_check'] = 'profile-nt' . $memID; |
|
1965 | + if (!isset($context['token_check'])) { |
|
1966 | + $context['token_check'] = 'profile-nt' . $memID; |
|
1967 | + } |
|
1876 | 1968 | |
1877 | 1969 | is_not_guest(); |
1878 | - if (!$context['user']['is_owner']) |
|
1879 | - isAllowedTo('profile_extra_any'); |
|
1970 | + if (!$context['user']['is_owner']) { |
|
1971 | + isAllowedTo('profile_extra_any'); |
|
1972 | + } |
|
1880 | 1973 | |
1881 | 1974 | // Set the post action if we're coming from the profile... |
1882 | - if (!isset($context['action'])) |
|
1883 | - $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
1975 | + if (!isset($context['action'])) { |
|
1976 | + $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
1977 | + } |
|
1884 | 1978 | |
1885 | 1979 | // What options are set |
1886 | 1980 | loadThemeOptions($memID); |
@@ -1967,28 +2061,34 @@ discard block |
||
1967 | 2061 | ); |
1968 | 2062 | |
1969 | 2063 | // There are certain things that are disabled at the group level. |
1970 | - if (empty($modSettings['cal_enabled'])) |
|
1971 | - unset($alert_types['calendar']); |
|
2064 | + if (empty($modSettings['cal_enabled'])) { |
|
2065 | + unset($alert_types['calendar']); |
|
2066 | + } |
|
1972 | 2067 | |
1973 | 2068 | // Disable paid subscriptions at group level if they're disabled |
1974 | - if (empty($modSettings['paid_enabled'])) |
|
1975 | - unset($alert_types['paidsubs']); |
|
2069 | + if (empty($modSettings['paid_enabled'])) { |
|
2070 | + unset($alert_types['paidsubs']); |
|
2071 | + } |
|
1976 | 2072 | |
1977 | 2073 | // Disable membergroup requests at group level if they're disabled |
1978 | - if (empty($modSettings['show_group_membership'])) |
|
1979 | - unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
2074 | + if (empty($modSettings['show_group_membership'])) { |
|
2075 | + unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
2076 | + } |
|
1980 | 2077 | |
1981 | 2078 | // Disable mentions if they're disabled |
1982 | - if (empty($modSettings['enable_mentions'])) |
|
1983 | - unset($alert_types['msg']['msg_mention']); |
|
2079 | + if (empty($modSettings['enable_mentions'])) { |
|
2080 | + unset($alert_types['msg']['msg_mention']); |
|
2081 | + } |
|
1984 | 2082 | |
1985 | 2083 | // Disable likes if they're disabled |
1986 | - if (empty($modSettings['enable_likes'])) |
|
1987 | - unset($alert_types['msg']['msg_like']); |
|
2084 | + if (empty($modSettings['enable_likes'])) { |
|
2085 | + unset($alert_types['msg']['msg_like']); |
|
2086 | + } |
|
1988 | 2087 | |
1989 | 2088 | // Disable buddy requests if they're disabled |
1990 | - if (empty($modSettings['enable_buddylist'])) |
|
1991 | - unset($alert_types['members']['buddy_request']); |
|
2089 | + if (empty($modSettings['enable_buddylist'])) { |
|
2090 | + unset($alert_types['members']['buddy_request']); |
|
2091 | + } |
|
1992 | 2092 | |
1993 | 2093 | // Now, now, we could pass this through global but we should really get into the habit of |
1994 | 2094 | // passing content to hooks, not expecting hooks to splatter everything everywhere. |
@@ -2016,15 +2116,17 @@ discard block |
||
2016 | 2116 | $perms_cache['manage_membergroups'] = in_array($memID, $members); |
2017 | 2117 | } |
2018 | 2118 | |
2019 | - if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) |
|
2020 | - unset($alert_types['members']['request_group']); |
|
2119 | + if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) { |
|
2120 | + unset($alert_types['members']['request_group']); |
|
2121 | + } |
|
2021 | 2122 | |
2022 | 2123 | foreach ($alert_types as $group => $items) |
2023 | 2124 | { |
2024 | 2125 | foreach ($items as $alert_key => $alert_value) |
2025 | 2126 | { |
2026 | - if (!isset($alert_value['permission'])) |
|
2027 | - continue; |
|
2127 | + if (!isset($alert_value['permission'])) { |
|
2128 | + continue; |
|
2129 | + } |
|
2028 | 2130 | if (!isset($perms_cache[$alert_value['permission']['name']])) |
2029 | 2131 | { |
2030 | 2132 | $in_board = !empty($alert_value['permission']['is_board']) ? 0 : null; |
@@ -2032,12 +2134,14 @@ discard block |
||
2032 | 2134 | $perms_cache[$alert_value['permission']['name']] = in_array($memID, $members); |
2033 | 2135 | } |
2034 | 2136 | |
2035 | - if (!$perms_cache[$alert_value['permission']['name']]) |
|
2036 | - unset ($alert_types[$group][$alert_key]); |
|
2137 | + if (!$perms_cache[$alert_value['permission']['name']]) { |
|
2138 | + unset ($alert_types[$group][$alert_key]); |
|
2139 | + } |
|
2037 | 2140 | } |
2038 | 2141 | |
2039 | - if (empty($alert_types[$group])) |
|
2040 | - unset ($alert_types[$group]); |
|
2142 | + if (empty($alert_types[$group])) { |
|
2143 | + unset ($alert_types[$group]); |
|
2144 | + } |
|
2041 | 2145 | } |
2042 | 2146 | } |
2043 | 2147 | |
@@ -2069,9 +2173,9 @@ discard block |
||
2069 | 2173 | $update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0; |
2070 | 2174 | break; |
2071 | 2175 | case 'select': |
2072 | - if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) |
|
2073 | - $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
2074 | - else |
|
2176 | + if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) { |
|
2177 | + $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
2178 | + } else |
|
2075 | 2179 | { |
2076 | 2180 | // We didn't have a sane value. Let's grab the first item from the possibles. |
2077 | 2181 | $keys = array_keys($this_option['opts']); |
@@ -2091,23 +2195,28 @@ discard block |
||
2091 | 2195 | $this_value = 0; |
2092 | 2196 | foreach ($context['alert_bits'] as $type => $bitvalue) |
2093 | 2197 | { |
2094 | - if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') |
|
2095 | - $this_value |= $bitvalue; |
|
2198 | + if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') { |
|
2199 | + $this_value |= $bitvalue; |
|
2200 | + } |
|
2201 | + } |
|
2202 | + if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) { |
|
2203 | + $update_prefs[$item_key] = $this_value; |
|
2096 | 2204 | } |
2097 | - if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) |
|
2098 | - $update_prefs[$item_key] = $this_value; |
|
2099 | 2205 | } |
2100 | 2206 | } |
2101 | 2207 | |
2102 | - if (!empty($_POST['opt_alert_timeout'])) |
|
2103 | - $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
2208 | + if (!empty($_POST['opt_alert_timeout'])) { |
|
2209 | + $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
2210 | + } |
|
2104 | 2211 | |
2105 | - if (!empty($_POST['notify_announcements'])) |
|
2106 | - $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
2212 | + if (!empty($_POST['notify_announcements'])) { |
|
2213 | + $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
2214 | + } |
|
2107 | 2215 | |
2108 | 2216 | setNotifyPrefs((int) $memID, $update_prefs); |
2109 | - foreach ($update_prefs as $pref => $value) |
|
2110 | - $context['alert_prefs'][$pref] = $value; |
|
2217 | + foreach ($update_prefs as $pref => $value) { |
|
2218 | + $context['alert_prefs'][$pref] = $value; |
|
2219 | + } |
|
2111 | 2220 | |
2112 | 2221 | makeNotificationChanges($memID); |
2113 | 2222 | |
@@ -2137,8 +2246,9 @@ discard block |
||
2137 | 2246 | |
2138 | 2247 | // Now we're all set up. |
2139 | 2248 | is_not_guest(); |
2140 | - if (!$context['user']['is_owner']) |
|
2141 | - fatal_error('no_access'); |
|
2249 | + if (!$context['user']['is_owner']) { |
|
2250 | + fatal_error('no_access'); |
|
2251 | + } |
|
2142 | 2252 | |
2143 | 2253 | checkSession('get'); |
2144 | 2254 | |
@@ -2170,8 +2280,9 @@ discard block |
||
2170 | 2280 | { |
2171 | 2281 | global $smcFunc; |
2172 | 2282 | |
2173 | - if (empty($toMark) || empty($memID)) |
|
2174 | - return false; |
|
2283 | + if (empty($toMark) || empty($memID)) { |
|
2284 | + return false; |
|
2285 | + } |
|
2175 | 2286 | |
2176 | 2287 | $toMark = (array) $toMark; |
2177 | 2288 | |
@@ -2205,8 +2316,9 @@ discard block |
||
2205 | 2316 | { |
2206 | 2317 | global $smcFunc; |
2207 | 2318 | |
2208 | - if (empty($toDelete)) |
|
2209 | - return false; |
|
2319 | + if (empty($toDelete)) { |
|
2320 | + return false; |
|
2321 | + } |
|
2210 | 2322 | |
2211 | 2323 | $toDelete = (array) $toDelete; |
2212 | 2324 | |
@@ -2241,8 +2353,9 @@ discard block |
||
2241 | 2353 | { |
2242 | 2354 | global $smcFunc; |
2243 | 2355 | |
2244 | - if (empty($memID)) |
|
2245 | - return false; |
|
2356 | + if (empty($memID)) { |
|
2357 | + return false; |
|
2358 | + } |
|
2246 | 2359 | |
2247 | 2360 | $request = $smcFunc['db_query']('', ' |
2248 | 2361 | SELECT id_alert |
@@ -2319,8 +2432,9 @@ discard block |
||
2319 | 2432 | { |
2320 | 2433 | $link = $topic['link']; |
2321 | 2434 | |
2322 | - if ($topic['new']) |
|
2323 | - $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2435 | + if ($topic['new']) { |
|
2436 | + $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2437 | + } |
|
2324 | 2438 | |
2325 | 2439 | $link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>'; |
2326 | 2440 | |
@@ -2471,8 +2585,9 @@ discard block |
||
2471 | 2585 | { |
2472 | 2586 | $link = $board['link']; |
2473 | 2587 | |
2474 | - if ($board['new']) |
|
2475 | - $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2588 | + if ($board['new']) { |
|
2589 | + $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2590 | + } |
|
2476 | 2591 | |
2477 | 2592 | return $link; |
2478 | 2593 | }, |
@@ -2672,8 +2787,8 @@ discard block |
||
2672 | 2787 | ) |
2673 | 2788 | ); |
2674 | 2789 | $notification_boards = array(); |
2675 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2676 | - $notification_boards[] = array( |
|
2790 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2791 | + $notification_boards[] = array( |
|
2677 | 2792 | 'id' => $row['id_board'], |
2678 | 2793 | 'name' => $row['name'], |
2679 | 2794 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
@@ -2681,6 +2796,7 @@ discard block |
||
2681 | 2796 | 'new' => $row['board_read'] < $row['id_msg_updated'], |
2682 | 2797 | 'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0), |
2683 | 2798 | ); |
2799 | + } |
|
2684 | 2800 | $smcFunc['db_free_result']($request); |
2685 | 2801 | |
2686 | 2802 | return $notification_boards; |
@@ -2695,17 +2811,18 @@ discard block |
||
2695 | 2811 | { |
2696 | 2812 | global $context, $options, $cur_profile, $smcFunc; |
2697 | 2813 | |
2698 | - if (isset($_POST['default_options'])) |
|
2699 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
2814 | + if (isset($_POST['default_options'])) { |
|
2815 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
2816 | + } |
|
2700 | 2817 | |
2701 | 2818 | if ($context['user']['is_owner']) |
2702 | 2819 | { |
2703 | 2820 | $context['member']['options'] = $options; |
2704 | - if (isset($_POST['options']) && is_array($_POST['options'])) |
|
2705 | - foreach ($_POST['options'] as $k => $v) |
|
2821 | + if (isset($_POST['options']) && is_array($_POST['options'])) { |
|
2822 | + foreach ($_POST['options'] as $k => $v) |
|
2706 | 2823 | $context['member']['options'][$k] = $v; |
2707 | - } |
|
2708 | - else |
|
2824 | + } |
|
2825 | + } else |
|
2709 | 2826 | { |
2710 | 2827 | $request = $smcFunc['db_query']('', ' |
2711 | 2828 | SELECT id_member, variable, value |
@@ -2726,8 +2843,9 @@ discard block |
||
2726 | 2843 | continue; |
2727 | 2844 | } |
2728 | 2845 | |
2729 | - if (isset($_POST['options'][$row['variable']])) |
|
2730 | - $row['value'] = $_POST['options'][$row['variable']]; |
|
2846 | + if (isset($_POST['options'][$row['variable']])) { |
|
2847 | + $row['value'] = $_POST['options'][$row['variable']]; |
|
2848 | + } |
|
2731 | 2849 | $context['member']['options'][$row['variable']] = $row['value']; |
2732 | 2850 | } |
2733 | 2851 | $smcFunc['db_free_result']($request); |
@@ -2735,8 +2853,9 @@ discard block |
||
2735 | 2853 | // Load up the default theme options for any missing. |
2736 | 2854 | foreach ($temp as $k => $v) |
2737 | 2855 | { |
2738 | - if (!isset($context['member']['options'][$k])) |
|
2739 | - $context['member']['options'][$k] = $v; |
|
2856 | + if (!isset($context['member']['options'][$k])) { |
|
2857 | + $context['member']['options'][$k] = $v; |
|
2858 | + } |
|
2740 | 2859 | } |
2741 | 2860 | } |
2742 | 2861 | } |
@@ -2751,8 +2870,9 @@ discard block |
||
2751 | 2870 | global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir; |
2752 | 2871 | |
2753 | 2872 | // Have the admins enabled this option? |
2754 | - if (empty($modSettings['allow_ignore_boards'])) |
|
2755 | - fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
2873 | + if (empty($modSettings['allow_ignore_boards'])) { |
|
2874 | + fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
2875 | + } |
|
2756 | 2876 | |
2757 | 2877 | // Find all the boards this user is allowed to see. |
2758 | 2878 | $request = $smcFunc['db_query']('order_by_board_order', ' |
@@ -2772,12 +2892,13 @@ discard block |
||
2772 | 2892 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2773 | 2893 | { |
2774 | 2894 | // This category hasn't been set up yet.. |
2775 | - if (!isset($context['categories'][$row['id_cat']])) |
|
2776 | - $context['categories'][$row['id_cat']] = array( |
|
2895 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
2896 | + $context['categories'][$row['id_cat']] = array( |
|
2777 | 2897 | 'id' => $row['id_cat'], |
2778 | 2898 | 'name' => $row['cat_name'], |
2779 | 2899 | 'boards' => array() |
2780 | 2900 | ); |
2901 | + } |
|
2781 | 2902 | |
2782 | 2903 | // Set this board up, and let the template know when it's a child. (indent them..) |
2783 | 2904 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -2807,18 +2928,20 @@ discard block |
||
2807 | 2928 | } |
2808 | 2929 | |
2809 | 2930 | $max_boards = ceil(count($temp_boards) / 2); |
2810 | - if ($max_boards == 1) |
|
2811 | - $max_boards = 2; |
|
2931 | + if ($max_boards == 1) { |
|
2932 | + $max_boards = 2; |
|
2933 | + } |
|
2812 | 2934 | |
2813 | 2935 | // Now, alternate them so they can be shown left and right ;). |
2814 | 2936 | $context['board_columns'] = array(); |
2815 | 2937 | for ($i = 0; $i < $max_boards; $i++) |
2816 | 2938 | { |
2817 | 2939 | $context['board_columns'][] = $temp_boards[$i]; |
2818 | - if (isset($temp_boards[$i + $max_boards])) |
|
2819 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
2820 | - else |
|
2821 | - $context['board_columns'][] = array(); |
|
2940 | + if (isset($temp_boards[$i + $max_boards])) { |
|
2941 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
2942 | + } else { |
|
2943 | + $context['board_columns'][] = array(); |
|
2944 | + } |
|
2822 | 2945 | } |
2823 | 2946 | |
2824 | 2947 | loadThemeOptions($memID); |
@@ -2887,8 +3010,9 @@ discard block |
||
2887 | 3010 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2888 | 3011 | { |
2889 | 3012 | // We should skip the administrator group if they don't have the admin_forum permission! |
2890 | - if ($row['id_group'] == 1 && !allowedTo('admin_forum')) |
|
2891 | - continue; |
|
3013 | + if ($row['id_group'] == 1 && !allowedTo('admin_forum')) { |
|
3014 | + continue; |
|
3015 | + } |
|
2892 | 3016 | |
2893 | 3017 | $context['member_groups'][$row['id_group']] = array( |
2894 | 3018 | 'id' => $row['id_group'], |
@@ -2934,16 +3058,17 @@ discard block |
||
2934 | 3058 | $context['max_signature_length'] = $context['signature_limits']['max_length']; |
2935 | 3059 | // Warning message for signature image limits? |
2936 | 3060 | $context['signature_warning'] = ''; |
2937 | - if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) |
|
2938 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
2939 | - elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) |
|
2940 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
3061 | + if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) { |
|
3062 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
3063 | + } elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) { |
|
3064 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
3065 | + } |
|
2941 | 3066 | |
2942 | 3067 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
2943 | 3068 | |
2944 | - if (empty($context['do_preview'])) |
|
2945 | - $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
2946 | - else |
|
3069 | + if (empty($context['do_preview'])) { |
|
3070 | + $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
3071 | + } else |
|
2947 | 3072 | { |
2948 | 3073 | $signature = !empty($_POST['signature']) ? $_POST['signature'] : ''; |
2949 | 3074 | $validation = profileValidateSignature($signature); |
@@ -2953,8 +3078,9 @@ discard block |
||
2953 | 3078 | $context['post_errors'] = array(); |
2954 | 3079 | } |
2955 | 3080 | $context['post_errors'][] = 'signature_not_yet_saved'; |
2956 | - if ($validation !== true && $validation !== false) |
|
2957 | - $context['post_errors'][] = $validation; |
|
3081 | + if ($validation !== true && $validation !== false) { |
|
3082 | + $context['post_errors'][] = $validation; |
|
3083 | + } |
|
2958 | 3084 | |
2959 | 3085 | censorText($context['member']['signature']); |
2960 | 3086 | $context['member']['current_signature'] = $context['member']['signature']; |
@@ -2964,8 +3090,9 @@ discard block |
||
2964 | 3090 | } |
2965 | 3091 | |
2966 | 3092 | // Load the spell checker? |
2967 | - if ($context['show_spellchecking']) |
|
2968 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
3093 | + if ($context['show_spellchecking']) { |
|
3094 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
3095 | + } |
|
2969 | 3096 | |
2970 | 3097 | return true; |
2971 | 3098 | } |
@@ -2999,8 +3126,7 @@ discard block |
||
2999 | 3126 | 'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11) |
3000 | 3127 | ); |
3001 | 3128 | $context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']); |
3002 | - } |
|
3003 | - elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
3129 | + } elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
3004 | 3130 | { |
3005 | 3131 | $context['member']['avatar'] += array( |
3006 | 3132 | 'choice' => 'upload', |
@@ -3010,33 +3136,34 @@ discard block |
||
3010 | 3136 | $context['member']['avatar']['href'] = empty($cur_profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $cur_profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $cur_profile['filename']; |
3011 | 3137 | } |
3012 | 3138 | // Use "avatar_original" here so we show what the user entered even if the image proxy is enabled |
3013 | - elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) |
|
3014 | - $context['member']['avatar'] += array( |
|
3139 | + elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) { |
|
3140 | + $context['member']['avatar'] += array( |
|
3015 | 3141 | 'choice' => 'external', |
3016 | 3142 | 'server_pic' => 'blank.png', |
3017 | 3143 | 'external' => $cur_profile['avatar_original'] |
3018 | 3144 | ); |
3019 | - elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) |
|
3020 | - $context['member']['avatar'] += array( |
|
3145 | + } elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) { |
|
3146 | + $context['member']['avatar'] += array( |
|
3021 | 3147 | 'choice' => 'server_stored', |
3022 | 3148 | 'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'], |
3023 | 3149 | 'external' => 'http://' |
3024 | 3150 | ); |
3025 | - else |
|
3026 | - $context['member']['avatar'] += array( |
|
3151 | + } else { |
|
3152 | + $context['member']['avatar'] += array( |
|
3027 | 3153 | 'choice' => 'none', |
3028 | 3154 | 'server_pic' => 'blank.png', |
3029 | 3155 | 'external' => 'http://' |
3030 | 3156 | ); |
3157 | + } |
|
3031 | 3158 | |
3032 | 3159 | // Get a list of all the avatars. |
3033 | 3160 | if ($context['member']['avatar']['allow_server_stored']) |
3034 | 3161 | { |
3035 | 3162 | $context['avatar_list'] = array(); |
3036 | 3163 | $context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array(); |
3164 | + } else { |
|
3165 | + $context['avatars'] = array(); |
|
3037 | 3166 | } |
3038 | - else |
|
3039 | - $context['avatars'] = array(); |
|
3040 | 3167 | |
3041 | 3168 | // Second level selected avatar... |
3042 | 3169 | $context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1); |
@@ -3065,19 +3192,22 @@ discard block |
||
3065 | 3192 | ) |
3066 | 3193 | ); |
3067 | 3194 | $protected_groups = array(1); |
3068 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3069 | - $protected_groups[] = $row['id_group']; |
|
3195 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3196 | + $protected_groups[] = $row['id_group']; |
|
3197 | + } |
|
3070 | 3198 | $smcFunc['db_free_result']($request); |
3071 | 3199 | |
3072 | 3200 | $protected_groups = array_unique($protected_groups); |
3073 | 3201 | } |
3074 | 3202 | |
3075 | 3203 | // The account page allows the change of your id_group - but not to a protected group! |
3076 | - if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) |
|
3077 | - $value = (int) $value; |
|
3204 | + if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) { |
|
3205 | + $value = (int) $value; |
|
3206 | + } |
|
3078 | 3207 | // ... otherwise it's the old group sir. |
3079 | - else |
|
3080 | - $value = $old_profile['id_group']; |
|
3208 | + else { |
|
3209 | + $value = $old_profile['id_group']; |
|
3210 | + } |
|
3081 | 3211 | |
3082 | 3212 | // Find the additional membergroups (if any) |
3083 | 3213 | if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups'])) |
@@ -3086,16 +3216,18 @@ discard block |
||
3086 | 3216 | foreach ($_POST['additional_groups'] as $group_id) |
3087 | 3217 | { |
3088 | 3218 | $group_id = (int) $group_id; |
3089 | - if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) |
|
3090 | - $additional_groups[] = $group_id; |
|
3219 | + if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) { |
|
3220 | + $additional_groups[] = $group_id; |
|
3221 | + } |
|
3091 | 3222 | } |
3092 | 3223 | |
3093 | 3224 | // Put the protected groups back in there if you don't have permission to take them away. |
3094 | 3225 | $old_additional_groups = explode(',', $old_profile['additional_groups']); |
3095 | 3226 | foreach ($old_additional_groups as $group_id) |
3096 | 3227 | { |
3097 | - if (!empty($protected_groups) && in_array($group_id, $protected_groups)) |
|
3098 | - $additional_groups[] = $group_id; |
|
3228 | + if (!empty($protected_groups) && in_array($group_id, $protected_groups)) { |
|
3229 | + $additional_groups[] = $group_id; |
|
3230 | + } |
|
3099 | 3231 | } |
3100 | 3232 | |
3101 | 3233 | if (implode(',', $additional_groups) !== $old_profile['additional_groups']) |
@@ -3127,18 +3259,20 @@ discard block |
||
3127 | 3259 | list ($another) = $smcFunc['db_fetch_row']($request); |
3128 | 3260 | $smcFunc['db_free_result']($request); |
3129 | 3261 | |
3130 | - if (empty($another)) |
|
3131 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
3262 | + if (empty($another)) { |
|
3263 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
3264 | + } |
|
3132 | 3265 | } |
3133 | 3266 | } |
3134 | 3267 | |
3135 | 3268 | // If we are changing group status, update permission cache as necessary. |
3136 | 3269 | if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups'])) |
3137 | 3270 | { |
3138 | - if ($context['user']['is_owner']) |
|
3139 | - $_SESSION['mc']['time'] = 0; |
|
3140 | - else |
|
3141 | - updateSettings(array('settings_updated' => time())); |
|
3271 | + if ($context['user']['is_owner']) { |
|
3272 | + $_SESSION['mc']['time'] = 0; |
|
3273 | + } else { |
|
3274 | + updateSettings(array('settings_updated' => time())); |
|
3275 | + } |
|
3142 | 3276 | } |
3143 | 3277 | |
3144 | 3278 | // Announce to any hooks that we have changed groups, but don't allow them to change it. |
@@ -3159,8 +3293,9 @@ discard block |
||
3159 | 3293 | global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context; |
3160 | 3294 | |
3161 | 3295 | $memID = $context['id_member']; |
3162 | - if (empty($memID) && !empty($context['password_auth_failed'])) |
|
3163 | - return false; |
|
3296 | + if (empty($memID) && !empty($context['password_auth_failed'])) { |
|
3297 | + return false; |
|
3298 | + } |
|
3164 | 3299 | |
3165 | 3300 | require_once($sourcedir . '/ManageAttachments.php'); |
3166 | 3301 | |
@@ -3171,8 +3306,9 @@ discard block |
||
3171 | 3306 | $downloadedExternalAvatar = false; |
3172 | 3307 | if ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external'])) |
3173 | 3308 | { |
3174 | - if (!is_writable($uploadDir)) |
|
3175 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
3309 | + if (!is_writable($uploadDir)) { |
|
3310 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
3311 | + } |
|
3176 | 3312 | |
3177 | 3313 | require_once($sourcedir . '/Subs-Package.php'); |
3178 | 3314 | |
@@ -3216,19 +3352,18 @@ discard block |
||
3216 | 3352 | |
3217 | 3353 | // Get rid of their old avatar. (if uploaded.) |
3218 | 3354 | removeAttachments(array('id_member' => $memID)); |
3219 | - } |
|
3220 | - elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
3355 | + } elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
3221 | 3356 | { |
3222 | 3357 | // One wasn't specified, or it's not allowed to use extra email addresses, or it's not a valid one, reset to default Gravatar. |
3223 | - if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) |
|
3224 | - $profile_vars['avatar'] = 'gravatar://'; |
|
3225 | - else |
|
3226 | - $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
3358 | + if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) { |
|
3359 | + $profile_vars['avatar'] = 'gravatar://'; |
|
3360 | + } else { |
|
3361 | + $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
3362 | + } |
|
3227 | 3363 | |
3228 | 3364 | // Get rid of their old avatar. (if uploaded.) |
3229 | 3365 | removeAttachments(array('id_member' => $memID)); |
3230 | - } |
|
3231 | - elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
3366 | + } elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
3232 | 3367 | { |
3233 | 3368 | // We need these clean... |
3234 | 3369 | $cur_profile['id_attach'] = 0; |
@@ -3240,11 +3375,13 @@ discard block |
||
3240 | 3375 | |
3241 | 3376 | $profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal'])); |
3242 | 3377 | |
3243 | - if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') |
|
3244 | - $profile_vars['avatar'] = ''; |
|
3378 | + if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') { |
|
3379 | + $profile_vars['avatar'] = ''; |
|
3380 | + } |
|
3245 | 3381 | // Trying to make us do something we'll regret? |
3246 | - elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') |
|
3247 | - return 'bad_avatar_invalid_url'; |
|
3382 | + elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') { |
|
3383 | + return 'bad_avatar_invalid_url'; |
|
3384 | + } |
|
3248 | 3385 | // Should we check dimensions? |
3249 | 3386 | elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external'])) |
3250 | 3387 | { |
@@ -3254,9 +3391,9 @@ discard block |
||
3254 | 3391 | if (is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external'])))) |
3255 | 3392 | { |
3256 | 3393 | // Houston, we have a problem. The avatar is too large!! |
3257 | - if ($modSettings['avatar_action_too_large'] == 'option_refuse') |
|
3258 | - return 'bad_avatar_too_large'; |
|
3259 | - elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
3394 | + if ($modSettings['avatar_action_too_large'] == 'option_refuse') { |
|
3395 | + return 'bad_avatar_too_large'; |
|
3396 | + } elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
3260 | 3397 | { |
3261 | 3398 | // @todo remove this if appropriate |
3262 | 3399 | require_once($sourcedir . '/Subs-Graphics.php'); |
@@ -3266,26 +3403,27 @@ discard block |
||
3266 | 3403 | $cur_profile['id_attach'] = $modSettings['new_avatar_data']['id']; |
3267 | 3404 | $cur_profile['filename'] = $modSettings['new_avatar_data']['filename']; |
3268 | 3405 | $cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type']; |
3406 | + } else { |
|
3407 | + return 'bad_avatar'; |
|
3269 | 3408 | } |
3270 | - else |
|
3271 | - return 'bad_avatar'; |
|
3272 | 3409 | } |
3273 | 3410 | } |
3274 | 3411 | } |
3275 | - } |
|
3276 | - elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
3412 | + } elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
3277 | 3413 | { |
3278 | 3414 | if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar) |
3279 | 3415 | { |
3280 | 3416 | // Get the dimensions of the image. |
3281 | 3417 | if (!$downloadedExternalAvatar) |
3282 | 3418 | { |
3283 | - if (!is_writable($uploadDir)) |
|
3284 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
3419 | + if (!is_writable($uploadDir)) { |
|
3420 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
3421 | + } |
|
3285 | 3422 | |
3286 | 3423 | $new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true); |
3287 | - if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) |
|
3288 | - fatal_lang_error('attach_timeout', 'critical'); |
|
3424 | + if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) { |
|
3425 | + fatal_lang_error('attach_timeout', 'critical'); |
|
3426 | + } |
|
3289 | 3427 | |
3290 | 3428 | $_FILES['attachment']['tmp_name'] = $new_filename; |
3291 | 3429 | } |
@@ -3398,17 +3536,19 @@ discard block |
||
3398 | 3536 | $profile_vars['avatar'] = ''; |
3399 | 3537 | |
3400 | 3538 | // Delete any temporary file. |
3401 | - if (file_exists($_FILES['attachment']['tmp_name'])) |
|
3402 | - @unlink($_FILES['attachment']['tmp_name']); |
|
3539 | + if (file_exists($_FILES['attachment']['tmp_name'])) { |
|
3540 | + @unlink($_FILES['attachment']['tmp_name']); |
|
3541 | + } |
|
3403 | 3542 | } |
3404 | 3543 | // Selected the upload avatar option and had one already uploaded before or didn't upload one. |
3405 | - else |
|
3544 | + else { |
|
3545 | + $profile_vars['avatar'] = ''; |
|
3546 | + } |
|
3547 | + } elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) { |
|
3548 | + $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
3549 | + } else { |
|
3406 | 3550 | $profile_vars['avatar'] = ''; |
3407 | 3551 | } |
3408 | - elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) |
|
3409 | - $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
3410 | - else |
|
3411 | - $profile_vars['avatar'] = ''; |
|
3412 | 3552 | |
3413 | 3553 | // Setup the profile variables so it shows things right on display! |
3414 | 3554 | $cur_profile['avatar'] = $profile_vars['avatar']; |
@@ -3456,9 +3596,9 @@ discard block |
||
3456 | 3596 | $smiley_parsed = $unparsed_signature; |
3457 | 3597 | parsesmileys($smiley_parsed); |
3458 | 3598 | $smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img'); |
3459 | - if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) |
|
3460 | - return 'signature_allow_smileys'; |
|
3461 | - elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
3599 | + if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) { |
|
3600 | + return 'signature_allow_smileys'; |
|
3601 | + } elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
3462 | 3602 | { |
3463 | 3603 | $txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]); |
3464 | 3604 | return 'signature_max_smileys'; |
@@ -3471,14 +3611,15 @@ discard block |
||
3471 | 3611 | { |
3472 | 3612 | $limit_broke = 0; |
3473 | 3613 | // Attempt to allow all sizes of abuse, so to speak. |
3474 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
3475 | - $limit_broke = $sig_limits[7] . 'px'; |
|
3476 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
3477 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
3478 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
3479 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
3480 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
3481 | - $limit_broke = 'large'; |
|
3614 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
3615 | + $limit_broke = $sig_limits[7] . 'px'; |
|
3616 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
3617 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
3618 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
3619 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
3620 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
3621 | + $limit_broke = 'large'; |
|
3622 | + } |
|
3482 | 3623 | |
3483 | 3624 | if ($limit_broke) |
3484 | 3625 | { |
@@ -3520,24 +3661,26 @@ discard block |
||
3520 | 3661 | $width = -1; $height = -1; |
3521 | 3662 | |
3522 | 3663 | // Does it have predefined restraints? Width first. |
3523 | - if ($matches[6][$key]) |
|
3524 | - $matches[2][$key] = $matches[6][$key]; |
|
3664 | + if ($matches[6][$key]) { |
|
3665 | + $matches[2][$key] = $matches[6][$key]; |
|
3666 | + } |
|
3525 | 3667 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
3526 | 3668 | { |
3527 | 3669 | $width = $sig_limits[5]; |
3528 | 3670 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
3671 | + } elseif ($matches[2][$key]) { |
|
3672 | + $width = $matches[2][$key]; |
|
3529 | 3673 | } |
3530 | - elseif ($matches[2][$key]) |
|
3531 | - $width = $matches[2][$key]; |
|
3532 | 3674 | // ... and height. |
3533 | 3675 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
3534 | 3676 | { |
3535 | 3677 | $height = $sig_limits[6]; |
3536 | - if ($width != -1) |
|
3537 | - $width = $width * ($height / $matches[4][$key]); |
|
3678 | + if ($width != -1) { |
|
3679 | + $width = $width * ($height / $matches[4][$key]); |
|
3680 | + } |
|
3681 | + } elseif ($matches[4][$key]) { |
|
3682 | + $height = $matches[4][$key]; |
|
3538 | 3683 | } |
3539 | - elseif ($matches[4][$key]) |
|
3540 | - $height = $matches[4][$key]; |
|
3541 | 3684 | |
3542 | 3685 | // If the dimensions are still not fixed - we need to check the actual image. |
3543 | 3686 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -3555,21 +3698,24 @@ discard block |
||
3555 | 3698 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
3556 | 3699 | { |
3557 | 3700 | $height = $sig_limits[6]; |
3558 | - if ($width == -1) |
|
3559 | - $width = $sizes[0]; |
|
3701 | + if ($width == -1) { |
|
3702 | + $width = $sizes[0]; |
|
3703 | + } |
|
3560 | 3704 | $width = $width * ($height / $sizes[1]); |
3705 | + } elseif ($width != -1) { |
|
3706 | + $height = $sizes[1]; |
|
3561 | 3707 | } |
3562 | - elseif ($width != -1) |
|
3563 | - $height = $sizes[1]; |
|
3564 | 3708 | } |
3565 | 3709 | } |
3566 | 3710 | |
3567 | 3711 | // Did we come up with some changes? If so remake the string. |
3568 | - if ($width != -1 || $height != -1) |
|
3569 | - $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
3712 | + if ($width != -1 || $height != -1) { |
|
3713 | + $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
3714 | + } |
|
3715 | + } |
|
3716 | + if (!empty($replaces)) { |
|
3717 | + $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
3570 | 3718 | } |
3571 | - if (!empty($replaces)) |
|
3572 | - $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
3573 | 3719 | } |
3574 | 3720 | } |
3575 | 3721 | |
@@ -3613,10 +3759,12 @@ discard block |
||
3613 | 3759 | $email = strtr($email, array(''' => '\'')); |
3614 | 3760 | |
3615 | 3761 | // Check the name and email for validity. |
3616 | - if (trim($email) == '') |
|
3617 | - return 'no_email'; |
|
3618 | - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) |
|
3619 | - return 'bad_email'; |
|
3762 | + if (trim($email) == '') { |
|
3763 | + return 'no_email'; |
|
3764 | + } |
|
3765 | + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
3766 | + return 'bad_email'; |
|
3767 | + } |
|
3620 | 3768 | |
3621 | 3769 | // Email addresses should be and stay unique. |
3622 | 3770 | $request = $smcFunc['db_query']('', ' |
@@ -3631,8 +3779,9 @@ discard block |
||
3631 | 3779 | ) |
3632 | 3780 | ); |
3633 | 3781 | |
3634 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
3635 | - return 'email_taken'; |
|
3782 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
3783 | + return 'email_taken'; |
|
3784 | + } |
|
3636 | 3785 | $smcFunc['db_free_result']($request); |
3637 | 3786 | |
3638 | 3787 | return true; |
@@ -3645,8 +3794,9 @@ discard block |
||
3645 | 3794 | { |
3646 | 3795 | global $modSettings, $context, $cur_profile; |
3647 | 3796 | |
3648 | - if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') |
|
3649 | - setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
3797 | + if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') { |
|
3798 | + setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
3799 | + } |
|
3650 | 3800 | |
3651 | 3801 | loadUserSettings(); |
3652 | 3802 | writeLog(); |
@@ -3662,8 +3812,9 @@ discard block |
||
3662 | 3812 | require_once($sourcedir . '/Subs-Post.php'); |
3663 | 3813 | |
3664 | 3814 | // Shouldn't happen but just in case. |
3665 | - if (empty($profile_vars['email_address'])) |
|
3666 | - return; |
|
3815 | + if (empty($profile_vars['email_address'])) { |
|
3816 | + return; |
|
3817 | + } |
|
3667 | 3818 | |
3668 | 3819 | $replacements = array( |
3669 | 3820 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'], |
@@ -3686,8 +3837,9 @@ discard block |
||
3686 | 3837 | $_SESSION['log_time'] = 0; |
3687 | 3838 | $_SESSION['login_' . $cookiename] = $smcFunc['json_encode'](array(0, '', 0)); |
3688 | 3839 | |
3689 | - if (isset($_COOKIE[$cookiename])) |
|
3690 | - $_COOKIE[$cookiename] = ''; |
|
3840 | + if (isset($_COOKIE[$cookiename])) { |
|
3841 | + $_COOKIE[$cookiename] = ''; |
|
3842 | + } |
|
3691 | 3843 | |
3692 | 3844 | loadUserSettings(); |
3693 | 3845 | |
@@ -3720,11 +3872,13 @@ discard block |
||
3720 | 3872 | $groups[] = $curMember['id_group']; |
3721 | 3873 | |
3722 | 3874 | // Ensure the query doesn't croak! |
3723 | - if (empty($groups)) |
|
3724 | - $groups = array(0); |
|
3875 | + if (empty($groups)) { |
|
3876 | + $groups = array(0); |
|
3877 | + } |
|
3725 | 3878 | // Just to be sure... |
3726 | - foreach ($groups as $k => $v) |
|
3727 | - $groups[$k] = (int) $v; |
|
3879 | + foreach ($groups as $k => $v) { |
|
3880 | + $groups[$k] = (int) $v; |
|
3881 | + } |
|
3728 | 3882 | |
3729 | 3883 | // Get all the membergroups they can join. |
3730 | 3884 | $request = $smcFunc['db_query']('', ' |
@@ -3754,12 +3908,14 @@ discard block |
||
3754 | 3908 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
3755 | 3909 | { |
3756 | 3910 | // Can they edit their primary group? |
3757 | - if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) |
|
3758 | - $context['can_edit_primary'] = true; |
|
3911 | + if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) { |
|
3912 | + $context['can_edit_primary'] = true; |
|
3913 | + } |
|
3759 | 3914 | |
3760 | 3915 | // If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it. |
3761 | - if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) |
|
3762 | - continue; |
|
3916 | + if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) { |
|
3917 | + continue; |
|
3918 | + } |
|
3763 | 3919 | |
3764 | 3920 | $context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array( |
3765 | 3921 | 'id' => $row['id_group'], |
@@ -3788,13 +3944,15 @@ discard block |
||
3788 | 3944 | ); |
3789 | 3945 | |
3790 | 3946 | // No changing primary one unless you have enough groups! |
3791 | - if (count($context['groups']['member']) < 2) |
|
3792 | - $context['can_edit_primary'] = false; |
|
3947 | + if (count($context['groups']['member']) < 2) { |
|
3948 | + $context['can_edit_primary'] = false; |
|
3949 | + } |
|
3793 | 3950 | |
3794 | 3951 | // In the special case that someone is requesting membership of a group, setup some special context vars. |
3795 | - if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) |
|
3796 | - $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
3797 | -} |
|
3952 | + if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) { |
|
3953 | + $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
3954 | + } |
|
3955 | + } |
|
3798 | 3956 | |
3799 | 3957 | /** |
3800 | 3958 | * This function actually makes all the group changes |
@@ -3809,10 +3967,12 @@ discard block |
||
3809 | 3967 | global $user_info, $context, $user_profile, $modSettings, $smcFunc; |
3810 | 3968 | |
3811 | 3969 | // Let's be extra cautious... |
3812 | - if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) |
|
3813 | - isAllowedTo('manage_membergroups'); |
|
3814 | - if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) |
|
3815 | - fatal_lang_error('no_access', false); |
|
3970 | + if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) { |
|
3971 | + isAllowedTo('manage_membergroups'); |
|
3972 | + } |
|
3973 | + if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) { |
|
3974 | + fatal_lang_error('no_access', false); |
|
3975 | + } |
|
3816 | 3976 | |
3817 | 3977 | checkSession(isset($_GET['gid']) ? 'get' : 'post'); |
3818 | 3978 | |
@@ -3831,8 +3991,9 @@ discard block |
||
3831 | 3991 | $foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false; |
3832 | 3992 | |
3833 | 3993 | // Sanity check!! |
3834 | - if ($group_id == 1) |
|
3835 | - isAllowedTo('admin_forum'); |
|
3994 | + if ($group_id == 1) { |
|
3995 | + isAllowedTo('admin_forum'); |
|
3996 | + } |
|
3836 | 3997 | // Protected groups too! |
3837 | 3998 | else |
3838 | 3999 | { |
@@ -3849,8 +4010,9 @@ discard block |
||
3849 | 4010 | list ($is_protected) = $smcFunc['db_fetch_row']($request); |
3850 | 4011 | $smcFunc['db_free_result']($request); |
3851 | 4012 | |
3852 | - if ($is_protected == 1) |
|
3853 | - isAllowedTo('admin_forum'); |
|
4013 | + if ($is_protected == 1) { |
|
4014 | + isAllowedTo('admin_forum'); |
|
4015 | + } |
|
3854 | 4016 | } |
3855 | 4017 | |
3856 | 4018 | // What ever we are doing, we need to determine if changing primary is possible! |
@@ -3872,36 +4034,43 @@ discard block |
||
3872 | 4034 | $group_name = $row['group_name']; |
3873 | 4035 | |
3874 | 4036 | // Does the group type match what we're doing - are we trying to request a non-requestable group? |
3875 | - if ($changeType == 'request' && $row['group_type'] != 2) |
|
3876 | - fatal_lang_error('no_access', false); |
|
4037 | + if ($changeType == 'request' && $row['group_type'] != 2) { |
|
4038 | + fatal_lang_error('no_access', false); |
|
4039 | + } |
|
3877 | 4040 | // What about leaving a requestable group we are not a member of? |
3878 | - elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) |
|
3879 | - fatal_lang_error('no_access', false); |
|
3880 | - elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) |
|
3881 | - fatal_lang_error('no_access', false); |
|
4041 | + elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) { |
|
4042 | + fatal_lang_error('no_access', false); |
|
4043 | + } elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) { |
|
4044 | + fatal_lang_error('no_access', false); |
|
4045 | + } |
|
3882 | 4046 | |
3883 | 4047 | // We can't change the primary group if this is hidden! |
3884 | - if ($row['hidden'] == 2) |
|
3885 | - $canChangePrimary = false; |
|
4048 | + if ($row['hidden'] == 2) { |
|
4049 | + $canChangePrimary = false; |
|
4050 | + } |
|
3886 | 4051 | } |
3887 | 4052 | |
3888 | 4053 | // If this is their old primary, can we change it? |
3889 | - if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) |
|
3890 | - $canChangePrimary = 1; |
|
4054 | + if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) { |
|
4055 | + $canChangePrimary = 1; |
|
4056 | + } |
|
3891 | 4057 | |
3892 | 4058 | // If we are not doing a force primary move, don't do it automatically if current primary is not 0. |
3893 | - if ($changeType != 'primary' && $old_profile['id_group'] != 0) |
|
3894 | - $canChangePrimary = false; |
|
4059 | + if ($changeType != 'primary' && $old_profile['id_group'] != 0) { |
|
4060 | + $canChangePrimary = false; |
|
4061 | + } |
|
3895 | 4062 | |
3896 | 4063 | // If this is the one we are acting on, can we even act? |
3897 | - if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) |
|
3898 | - $canChangePrimary = false; |
|
4064 | + if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) { |
|
4065 | + $canChangePrimary = false; |
|
4066 | + } |
|
3899 | 4067 | } |
3900 | 4068 | $smcFunc['db_free_result']($request); |
3901 | 4069 | |
3902 | 4070 | // Didn't find the target? |
3903 | - if (!$foundTarget) |
|
3904 | - fatal_lang_error('no_access', false); |
|
4071 | + if (!$foundTarget) { |
|
4072 | + fatal_lang_error('no_access', false); |
|
4073 | + } |
|
3905 | 4074 | |
3906 | 4075 | // Final security check, don't allow users to promote themselves to admin. |
3907 | 4076 | if ($context['can_manage_membergroups'] && !allowedTo('admin_forum')) |
@@ -3921,8 +4090,9 @@ discard block |
||
3921 | 4090 | list ($disallow) = $smcFunc['db_fetch_row']($request); |
3922 | 4091 | $smcFunc['db_free_result']($request); |
3923 | 4092 | |
3924 | - if ($disallow) |
|
3925 | - isAllowedTo('admin_forum'); |
|
4093 | + if ($disallow) { |
|
4094 | + isAllowedTo('admin_forum'); |
|
4095 | + } |
|
3926 | 4096 | } |
3927 | 4097 | |
3928 | 4098 | // If we're requesting, add the note then return. |
@@ -3940,8 +4110,9 @@ discard block |
||
3940 | 4110 | 'status_open' => 0, |
3941 | 4111 | ) |
3942 | 4112 | ); |
3943 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
3944 | - fatal_lang_error('profile_error_already_requested_group'); |
|
4113 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
4114 | + fatal_lang_error('profile_error_already_requested_group'); |
|
4115 | + } |
|
3945 | 4116 | $smcFunc['db_free_result']($request); |
3946 | 4117 | |
3947 | 4118 | // Log the request. |
@@ -3975,10 +4146,11 @@ discard block |
||
3975 | 4146 | // Are we leaving? |
3976 | 4147 | if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id])) |
3977 | 4148 | { |
3978 | - if ($old_profile['id_group'] == $group_id) |
|
3979 | - $newPrimary = 0; |
|
3980 | - else |
|
3981 | - unset($addGroups[$group_id]); |
|
4149 | + if ($old_profile['id_group'] == $group_id) { |
|
4150 | + $newPrimary = 0; |
|
4151 | + } else { |
|
4152 | + unset($addGroups[$group_id]); |
|
4153 | + } |
|
3982 | 4154 | } |
3983 | 4155 | // ... if not, must be joining. |
3984 | 4156 | else |
@@ -3986,36 +4158,42 @@ discard block |
||
3986 | 4158 | // Can we change the primary, and do we want to? |
3987 | 4159 | if ($canChangePrimary) |
3988 | 4160 | { |
3989 | - if ($old_profile['id_group'] != 0) |
|
3990 | - $addGroups[$old_profile['id_group']] = -1; |
|
4161 | + if ($old_profile['id_group'] != 0) { |
|
4162 | + $addGroups[$old_profile['id_group']] = -1; |
|
4163 | + } |
|
3991 | 4164 | $newPrimary = $group_id; |
3992 | 4165 | } |
3993 | 4166 | // Otherwise it's an additional group... |
3994 | - else |
|
3995 | - $addGroups[$group_id] = -1; |
|
4167 | + else { |
|
4168 | + $addGroups[$group_id] = -1; |
|
4169 | + } |
|
3996 | 4170 | } |
3997 | 4171 | } |
3998 | 4172 | // Finally, we must be setting the primary. |
3999 | 4173 | elseif ($canChangePrimary) |
4000 | 4174 | { |
4001 | - if ($old_profile['id_group'] != 0) |
|
4002 | - $addGroups[$old_profile['id_group']] = -1; |
|
4003 | - if (isset($addGroups[$group_id])) |
|
4004 | - unset($addGroups[$group_id]); |
|
4175 | + if ($old_profile['id_group'] != 0) { |
|
4176 | + $addGroups[$old_profile['id_group']] = -1; |
|
4177 | + } |
|
4178 | + if (isset($addGroups[$group_id])) { |
|
4179 | + unset($addGroups[$group_id]); |
|
4180 | + } |
|
4005 | 4181 | $newPrimary = $group_id; |
4006 | 4182 | } |
4007 | 4183 | |
4008 | 4184 | // Finally, we can make the changes! |
4009 | - foreach ($addGroups as $id => $dummy) |
|
4010 | - if (empty($id)) |
|
4185 | + foreach ($addGroups as $id => $dummy) { |
|
4186 | + if (empty($id)) |
|
4011 | 4187 | unset($addGroups[$id]); |
4188 | + } |
|
4012 | 4189 | $addGroups = implode(',', array_flip($addGroups)); |
4013 | 4190 | |
4014 | 4191 | // Ensure that we don't cache permissions if the group is changing. |
4015 | - if ($context['user']['is_owner']) |
|
4016 | - $_SESSION['mc']['time'] = 0; |
|
4017 | - else |
|
4018 | - updateSettings(array('settings_updated' => time())); |
|
4192 | + if ($context['user']['is_owner']) { |
|
4193 | + $_SESSION['mc']['time'] = 0; |
|
4194 | + } else { |
|
4195 | + updateSettings(array('settings_updated' => time())); |
|
4196 | + } |
|
4019 | 4197 | |
4020 | 4198 | updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups)); |
4021 | 4199 | |
@@ -4038,8 +4216,9 @@ discard block |
||
4038 | 4216 | if (empty($user_settings['tfa_secret']) && $context['user']['is_owner']) |
4039 | 4217 | { |
4040 | 4218 | // Check to ensure we're forcing SSL for authentication |
4041 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
4042 | - fatal_lang_error('login_ssl_required'); |
|
4219 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
4220 | + fatal_lang_error('login_ssl_required'); |
|
4221 | + } |
|
4043 | 4222 | |
4044 | 4223 | // In some cases (forced 2FA or backup code) they would be forced to be redirected here, |
4045 | 4224 | // we do not want too much AJAX to confuse them. |
@@ -4076,8 +4255,7 @@ discard block |
||
4076 | 4255 | $context['sub_template'] = 'tfasetup_backup'; |
4077 | 4256 | |
4078 | 4257 | return; |
4079 | - } |
|
4080 | - else |
|
4258 | + } else |
|
4081 | 4259 | { |
4082 | 4260 | $context['tfa_secret'] = $_SESSION['tfa_secret']; |
4083 | 4261 | $context['tfa_error'] = !$valid_code; |
@@ -4085,8 +4263,7 @@ discard block |
||
4085 | 4263 | $context['tfa_pass_value'] = $_POST['passwd']; |
4086 | 4264 | $context['tfa_value'] = $_POST['tfa_code']; |
4087 | 4265 | } |
4088 | - } |
|
4089 | - else |
|
4266 | + } else |
|
4090 | 4267 | { |
4091 | 4268 | $totp = new \TOTP\Auth(); |
4092 | 4269 | $secret = $totp->generateCode(); |
@@ -4096,17 +4273,16 @@ discard block |
||
4096 | 4273 | } |
4097 | 4274 | |
4098 | 4275 | $context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']); |
4099 | - } |
|
4100 | - elseif (isset($_REQUEST['disable'])) |
|
4276 | + } elseif (isset($_REQUEST['disable'])) |
|
4101 | 4277 | { |
4102 | 4278 | updateMemberData($memID, array( |
4103 | 4279 | 'tfa_secret' => '', |
4104 | 4280 | 'tfa_backup' => '', |
4105 | 4281 | )); |
4106 | 4282 | redirectexit('action=profile;area=account;u=' . $memID); |
4283 | + } else { |
|
4284 | + redirectexit('action=profile;area=account;u=' . $memID); |
|
4285 | + } |
|
4107 | 4286 | } |
4108 | - else |
|
4109 | - redirectexit('action=profile;area=account;u=' . $memID); |
|
4110 | -} |
|
4111 | 4287 | |
4112 | 4288 | ?> |
4113 | 4289 | \ No newline at end of file |