@@ -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 | * The main designating function for modifying profiles. Loads up info, determins what to do, etc. |
@@ -29,18 +30,21 @@ discard block |
||
29 | 30 | global $modSettings, $memberContext, $profile_vars, $post_errors, $smcFunc; |
30 | 31 | |
31 | 32 | // Don't reload this as we may have processed error strings. |
32 | - if (empty($post_errors)) |
|
33 | - loadLanguage('Profile+Drafts'); |
|
33 | + if (empty($post_errors)) { |
|
34 | + loadLanguage('Profile+Drafts'); |
|
35 | + } |
|
34 | 36 | loadTemplate('Profile'); |
35 | 37 | |
36 | 38 | require_once($sourcedir . '/Subs-Menu.php'); |
37 | 39 | |
38 | 40 | // Did we get the user by name... |
39 | - if (isset($_REQUEST['user'])) |
|
40 | - $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
41 | + if (isset($_REQUEST['user'])) { |
|
42 | + $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
43 | + } |
|
41 | 44 | // ... or by id_member? |
42 | - elseif (!empty($_REQUEST['u'])) |
|
43 | - $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
45 | + elseif (!empty($_REQUEST['u'])) { |
|
46 | + $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
47 | + } |
|
44 | 48 | // If it was just ?action=profile, edit your own profile, but only if you're not a guest. |
45 | 49 | else |
46 | 50 | { |
@@ -50,8 +54,9 @@ discard block |
||
50 | 54 | } |
51 | 55 | |
52 | 56 | // Check if loadMemberData() has returned a valid result. |
53 | - if (!$memberResult) |
|
54 | - fatal_lang_error('not_a_user', false, 404); |
|
57 | + if (!$memberResult) { |
|
58 | + fatal_lang_error('not_a_user', false, 404); |
|
59 | + } |
|
55 | 60 | |
56 | 61 | // If all went well, we have a valid member ID! |
57 | 62 | list ($memID) = $memberResult; |
@@ -67,8 +72,9 @@ discard block |
||
67 | 72 | |
68 | 73 | // Group management isn't actually a permission. But we need it to be for this, so we need a phantom permission. |
69 | 74 | // And we care about what the current user can do, not what the user whose profile it is. |
70 | - if ($user_info['mod_cache']['gq'] != '0=1') |
|
71 | - $user_info['permissions'][] = 'approve_group_requests'; |
|
75 | + if ($user_info['mod_cache']['gq'] != '0=1') { |
|
76 | + $user_info['permissions'][] = 'approve_group_requests'; |
|
77 | + } |
|
72 | 78 | |
73 | 79 | // If paid subscriptions are enabled, make sure we actually have at least one subscription available... |
74 | 80 | $context['subs_available'] = false; |
@@ -436,21 +442,25 @@ discard block |
||
436 | 442 | foreach ($section['areas'] as $area_id => $area) |
437 | 443 | { |
438 | 444 | // If it said no permissions that meant it wasn't valid! |
439 | - if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) |
|
440 | - $profile_areas[$section_id]['areas'][$area_id]['enabled'] = false; |
|
445 | + if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) { |
|
446 | + $profile_areas[$section_id]['areas'][$area_id]['enabled'] = false; |
|
447 | + } |
|
441 | 448 | // Otherwise pick the right set. |
442 | - else |
|
443 | - $profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any']; |
|
449 | + else { |
|
450 | + $profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any']; |
|
451 | + } |
|
444 | 452 | |
445 | 453 | // Password required in most cases |
446 | - if (!empty($area['password'])) |
|
447 | - $context['password_areas'][] = $area_id; |
|
454 | + if (!empty($area['password'])) { |
|
455 | + $context['password_areas'][] = $area_id; |
|
456 | + } |
|
448 | 457 | } |
449 | 458 | } |
450 | 459 | |
451 | 460 | // Is there an updated message to show? |
452 | - if (isset($_GET['updated'])) |
|
453 | - $context['profile_updated'] = $txt['profile_updated_own']; |
|
461 | + if (isset($_GET['updated'])) { |
|
462 | + $context['profile_updated'] = $txt['profile_updated_own']; |
|
463 | + } |
|
454 | 464 | |
455 | 465 | // Set a few options for the menu. |
456 | 466 | $menuOptions = array( |
@@ -465,8 +475,9 @@ discard block |
||
465 | 475 | $profile_include_data = createMenu($profile_areas, $menuOptions); |
466 | 476 | |
467 | 477 | // No menu means no access. |
468 | - if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) |
|
469 | - fatal_lang_error('no_access', false); |
|
478 | + if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) { |
|
479 | + fatal_lang_error('no_access', false); |
|
480 | + } |
|
470 | 481 | |
471 | 482 | // Make a note of the Unique ID for this menu. |
472 | 483 | $context['profile_menu_id'] = $context['max_menu_id']; |
@@ -492,8 +503,9 @@ discard block |
||
492 | 503 | if ($current_area == $area_id) |
493 | 504 | { |
494 | 505 | // This can't happen - but is a security check. |
495 | - if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) |
|
496 | - fatal_lang_error('no_access', false); |
|
506 | + if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) { |
|
507 | + fatal_lang_error('no_access', false); |
|
508 | + } |
|
497 | 509 | |
498 | 510 | // Are we saving data in a valid area? |
499 | 511 | if (isset($area['sc']) && (isset($_REQUEST['save']) || $context['do_preview'])) |
@@ -512,12 +524,14 @@ discard block |
||
512 | 524 | } |
513 | 525 | |
514 | 526 | // Does this require session validating? |
515 | - if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) |
|
516 | - $security_checks['validate'] = true; |
|
527 | + if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) { |
|
528 | + $security_checks['validate'] = true; |
|
529 | + } |
|
517 | 530 | |
518 | 531 | // Permissions for good measure. |
519 | - if (!empty($profile_include_data['permission'])) |
|
520 | - $security_checks['permission'] = $profile_include_data['permission']; |
|
532 | + if (!empty($profile_include_data['permission'])) { |
|
533 | + $security_checks['permission'] = $profile_include_data['permission']; |
|
534 | + } |
|
521 | 535 | |
522 | 536 | // Either way got something. |
523 | 537 | $found_area = true; |
@@ -526,21 +540,26 @@ discard block |
||
526 | 540 | } |
527 | 541 | |
528 | 542 | // Oh dear, some serious security lapse is going on here... we'll put a stop to that! |
529 | - if (!$found_area) |
|
530 | - fatal_lang_error('no_access', false); |
|
543 | + if (!$found_area) { |
|
544 | + fatal_lang_error('no_access', false); |
|
545 | + } |
|
531 | 546 | |
532 | 547 | // Release this now. |
533 | 548 | unset($profile_areas); |
534 | 549 | |
535 | 550 | // Now the context is setup have we got any security checks to carry out additional to that above? |
536 | - if (isset($security_checks['session'])) |
|
537 | - checkSession($security_checks['session']); |
|
538 | - if (isset($security_checks['validate'])) |
|
539 | - validateSession(); |
|
540 | - if (isset($security_checks['validateToken'])) |
|
541 | - validateToken($token_name, $token_type); |
|
542 | - if (isset($security_checks['permission'])) |
|
543 | - isAllowedTo($security_checks['permission']); |
|
551 | + if (isset($security_checks['session'])) { |
|
552 | + checkSession($security_checks['session']); |
|
553 | + } |
|
554 | + if (isset($security_checks['validate'])) { |
|
555 | + validateSession(); |
|
556 | + } |
|
557 | + if (isset($security_checks['validateToken'])) { |
|
558 | + validateToken($token_name, $token_type); |
|
559 | + } |
|
560 | + if (isset($security_checks['permission'])) { |
|
561 | + isAllowedTo($security_checks['permission']); |
|
562 | + } |
|
544 | 563 | |
545 | 564 | // Create a token if needed. |
546 | 565 | if (isset($security_checks['needsToken']) || isset($security_checks['validateToken'])) |
@@ -550,8 +569,9 @@ discard block |
||
550 | 569 | } |
551 | 570 | |
552 | 571 | // File to include? |
553 | - if (isset($profile_include_data['file'])) |
|
554 | - require_once($sourcedir . '/' . $profile_include_data['file']); |
|
572 | + if (isset($profile_include_data['file'])) { |
|
573 | + require_once($sourcedir . '/' . $profile_include_data['file']); |
|
574 | + } |
|
555 | 575 | |
556 | 576 | // Build the link tree. |
557 | 577 | $context['linktree'][] = array( |
@@ -559,17 +579,19 @@ discard block |
||
559 | 579 | 'name' => sprintf($txt['profile_of_username'], $context['member']['name']), |
560 | 580 | ); |
561 | 581 | |
562 | - if (!empty($profile_include_data['label'])) |
|
563 | - $context['linktree'][] = array( |
|
582 | + if (!empty($profile_include_data['label'])) { |
|
583 | + $context['linktree'][] = array( |
|
564 | 584 | 'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'], |
565 | 585 | 'name' => $profile_include_data['label'], |
566 | 586 | ); |
587 | + } |
|
567 | 588 | |
568 | - if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) |
|
569 | - $context['linktree'][] = array( |
|
589 | + if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) { |
|
590 | + $context['linktree'][] = array( |
|
570 | 591 | 'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'] . ';sa=' . $profile_include_data['current_subsection'], |
571 | 592 | 'name' => $profile_include_data['subsections'][$profile_include_data['current_subsection']][0], |
572 | 593 | ); |
594 | + } |
|
573 | 595 | |
574 | 596 | // Set the template for this area and add the profile layer. |
575 | 597 | $context['sub_template'] = $profile_include_data['function']; |
@@ -595,12 +617,14 @@ discard block |
||
595 | 617 | if ($check_password) |
596 | 618 | { |
597 | 619 | // Check to ensure we're forcing SSL for authentication |
598 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
599 | - fatal_lang_error('login_ssl_required'); |
|
620 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
621 | + fatal_lang_error('login_ssl_required'); |
|
622 | + } |
|
600 | 623 | |
601 | 624 | // You didn't even enter a password! |
602 | - if (trim($_POST['oldpasswrd']) == '') |
|
603 | - $post_errors[] = 'no_password'; |
|
625 | + if (trim($_POST['oldpasswrd']) == '') { |
|
626 | + $post_errors[] = 'no_password'; |
|
627 | + } |
|
604 | 628 | |
605 | 629 | // Since the password got modified due to all the $_POST cleaning, lets undo it so we can get the correct password |
606 | 630 | $_POST['oldpasswrd'] = un_htmlspecialchars($_POST['oldpasswrd']); |
@@ -609,42 +633,43 @@ discard block |
||
609 | 633 | $good_password = in_array(true, call_integration_hook('integrate_verify_password', array($cur_profile['member_name'], $_POST['oldpasswrd'], false)), true); |
610 | 634 | |
611 | 635 | // Bad password!!! |
612 | - if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) |
|
613 | - $post_errors[] = 'bad_password'; |
|
636 | + if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) { |
|
637 | + $post_errors[] = 'bad_password'; |
|
638 | + } |
|
614 | 639 | |
615 | 640 | // Warn other elements not to jump the gun and do custom changes! |
616 | - if (in_array('bad_password', $post_errors)) |
|
617 | - $context['password_auth_failed'] = true; |
|
641 | + if (in_array('bad_password', $post_errors)) { |
|
642 | + $context['password_auth_failed'] = true; |
|
643 | + } |
|
618 | 644 | } |
619 | 645 | |
620 | 646 | // Change the IP address in the database. |
621 | - if ($context['user']['is_owner']) |
|
622 | - $profile_vars['member_ip'] = $user_info['ip']; |
|
647 | + if ($context['user']['is_owner']) { |
|
648 | + $profile_vars['member_ip'] = $user_info['ip']; |
|
649 | + } |
|
623 | 650 | |
624 | 651 | // Now call the sub-action function... |
625 | 652 | if ($current_area == 'activateaccount') |
626 | 653 | { |
627 | - if (empty($post_errors)) |
|
628 | - activateAccount($memID); |
|
629 | - } |
|
630 | - elseif ($current_area == 'deleteaccount') |
|
654 | + if (empty($post_errors)) { |
|
655 | + activateAccount($memID); |
|
656 | + } |
|
657 | + } elseif ($current_area == 'deleteaccount') |
|
631 | 658 | { |
632 | 659 | if (empty($post_errors)) |
633 | 660 | { |
634 | 661 | deleteAccount2($memID); |
635 | 662 | redirectexit(); |
636 | 663 | } |
637 | - } |
|
638 | - elseif ($current_area == 'groupmembership' && empty($post_errors)) |
|
664 | + } elseif ($current_area == 'groupmembership' && empty($post_errors)) |
|
639 | 665 | { |
640 | 666 | $msg = groupMembership2($profile_vars, $post_errors, $memID); |
641 | 667 | |
642 | 668 | // Whatever we've done, we have nothing else to do here... |
643 | 669 | redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=groupmembership' . (!empty($msg) ? ';msg=' . $msg : '')); |
644 | - } |
|
645 | - elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) |
|
646 | - saveProfileFields(); |
|
647 | - else |
|
670 | + } elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) { |
|
671 | + saveProfileFields(); |
|
672 | + } else |
|
648 | 673 | { |
649 | 674 | $force_redirect = true; |
650 | 675 | // Ensure we include this. |
@@ -660,34 +685,36 @@ discard block |
||
660 | 685 | // Load the language file so we can give a nice explanation of the errors. |
661 | 686 | loadLanguage('Errors'); |
662 | 687 | $context['post_errors'] = $post_errors; |
663 | - } |
|
664 | - elseif (!empty($profile_vars)) |
|
688 | + } elseif (!empty($profile_vars)) |
|
665 | 689 | { |
666 | 690 | // If we've changed the password, notify any integration that may be listening in. |
667 | - if (isset($profile_vars['passwd'])) |
|
668 | - call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2'])); |
|
691 | + if (isset($profile_vars['passwd'])) { |
|
692 | + call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2'])); |
|
693 | + } |
|
669 | 694 | |
670 | 695 | updateMemberData($memID, $profile_vars); |
671 | 696 | |
672 | 697 | // What if this is the newest member? |
673 | - if ($modSettings['latestMember'] == $memID) |
|
674 | - updateStats('member'); |
|
675 | - elseif (isset($profile_vars['real_name'])) |
|
676 | - updateSettings(array('memberlist_updated' => time())); |
|
698 | + if ($modSettings['latestMember'] == $memID) { |
|
699 | + updateStats('member'); |
|
700 | + } elseif (isset($profile_vars['real_name'])) { |
|
701 | + updateSettings(array('memberlist_updated' => time())); |
|
702 | + } |
|
677 | 703 | |
678 | 704 | // If the member changed his/her birthdate, update calendar statistics. |
679 | - if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) |
|
680 | - updateSettings(array( |
|
705 | + if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) { |
|
706 | + updateSettings(array( |
|
681 | 707 | 'calendar_updated' => time(), |
682 | 708 | )); |
709 | + } |
|
683 | 710 | |
684 | 711 | // Anything worth logging? |
685 | 712 | if (!empty($context['log_changes']) && !empty($modSettings['modlog_enabled'])) |
686 | 713 | { |
687 | 714 | $log_changes = array(); |
688 | 715 | require_once($sourcedir . '/Logging.php'); |
689 | - foreach ($context['log_changes'] as $k => $v) |
|
690 | - $log_changes[] = array( |
|
716 | + foreach ($context['log_changes'] as $k => $v) { |
|
717 | + $log_changes[] = array( |
|
691 | 718 | 'action' => $k, |
692 | 719 | 'log_type' => 'user', |
693 | 720 | 'extra' => array_merge($v, array( |
@@ -695,14 +722,16 @@ discard block |
||
695 | 722 | 'member_affected' => $memID, |
696 | 723 | )), |
697 | 724 | ); |
725 | + } |
|
698 | 726 | |
699 | 727 | logActions($log_changes); |
700 | 728 | } |
701 | 729 | |
702 | 730 | // Have we got any post save functions to execute? |
703 | - if (!empty($context['profile_execute_on_save'])) |
|
704 | - foreach ($context['profile_execute_on_save'] as $saveFunc) |
|
731 | + if (!empty($context['profile_execute_on_save'])) { |
|
732 | + foreach ($context['profile_execute_on_save'] as $saveFunc) |
|
705 | 733 | $saveFunc(); |
734 | + } |
|
706 | 735 | |
707 | 736 | // Let them know it worked! |
708 | 737 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $cur_profile['member_name']); |
@@ -716,27 +745,31 @@ discard block |
||
716 | 745 | if (!empty($post_errors)) |
717 | 746 | { |
718 | 747 | // Set all the errors so the template knows what went wrong. |
719 | - foreach ($post_errors as $error_type) |
|
720 | - $context['modify_error'][$error_type] = true; |
|
748 | + foreach ($post_errors as $error_type) { |
|
749 | + $context['modify_error'][$error_type] = true; |
|
750 | + } |
|
721 | 751 | } |
722 | 752 | // If it's you then we should redirect upon save. |
723 | - elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) |
|
724 | - redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated'); |
|
725 | - elseif (!empty($force_redirect)) |
|
726 | - redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area); |
|
753 | + elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) { |
|
754 | + redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated'); |
|
755 | + } elseif (!empty($force_redirect)) { |
|
756 | + redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area); |
|
757 | + } |
|
727 | 758 | |
728 | 759 | |
729 | 760 | // Get the right callable. |
730 | 761 | $call = call_helper($profile_include_data['function'], true); |
731 | 762 | |
732 | 763 | // Is it valid? |
733 | - if (!empty($call)) |
|
734 | - call_user_func($call, $memID); |
|
764 | + if (!empty($call)) { |
|
765 | + call_user_func($call, $memID); |
|
766 | + } |
|
735 | 767 | |
736 | 768 | // Set the page title if it's not already set... |
737 | - if (!isset($context['page_title'])) |
|
738 | - $context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : ''); |
|
739 | -} |
|
769 | + if (!isset($context['page_title'])) { |
|
770 | + $context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : ''); |
|
771 | + } |
|
772 | + } |
|
740 | 773 | |
741 | 774 | /** |
742 | 775 | * Set up the requirements for the profile popup - the area that is shown as the popup menu for the current user. |
@@ -859,16 +892,18 @@ discard block |
||
859 | 892 | if (!allowedTo('admin_forum') && $area != 'register') |
860 | 893 | { |
861 | 894 | // If it's the owner they can see two types of private fields, regardless. |
862 | - if ($memID == $user_info['id']) |
|
863 | - $where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
864 | - else |
|
865 | - $where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
895 | + if ($memID == $user_info['id']) { |
|
896 | + $where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
897 | + } else { |
|
898 | + $where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
899 | + } |
|
866 | 900 | } |
867 | 901 | |
868 | - if ($area == 'register') |
|
869 | - $where .= ' AND show_reg != 0'; |
|
870 | - elseif ($area != 'summary') |
|
871 | - $where .= ' AND show_profile = {string:area}'; |
|
902 | + if ($area == 'register') { |
|
903 | + $where .= ' AND show_reg != 0'; |
|
904 | + } elseif ($area != 'summary') { |
|
905 | + $where .= ' AND show_profile = {string:area}'; |
|
906 | + } |
|
872 | 907 | |
873 | 908 | // Load all the relevant fields - and data. |
874 | 909 | $request = $smcFunc['db_query']('', ' |
@@ -894,13 +929,15 @@ discard block |
||
894 | 929 | if (isset($_POST['customfield']) && isset($_POST['customfield'][$row['col_name']])) |
895 | 930 | { |
896 | 931 | $value = $smcFunc['htmlspecialchars']($_POST['customfield'][$row['col_name']]); |
897 | - if (in_array($row['field_type'], array('select', 'radio'))) |
|
898 | - $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
932 | + if (in_array($row['field_type'], array('select', 'radio'))) { |
|
933 | + $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
934 | + } |
|
899 | 935 | } |
900 | 936 | |
901 | 937 | // Don't show the "disabled" option for the "gender" field if we are on the "summary" area. |
902 | - if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'None') |
|
903 | - continue; |
|
938 | + if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'None') { |
|
939 | + continue; |
|
940 | + } |
|
904 | 941 | |
905 | 942 | // HTML for the input form. |
906 | 943 | $output_html = $value; |
@@ -909,8 +946,7 @@ discard block |
||
909 | 946 | $true = (!$exists && $row['default_value']) || $value; |
910 | 947 | $input_html = '<input type="checkbox" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($true ? ' checked' : '') . '>'; |
911 | 948 | $output_html = $true ? $txt['yes'] : $txt['no']; |
912 | - } |
|
913 | - elseif ($row['field_type'] == 'select') |
|
949 | + } elseif ($row['field_type'] == 'select') |
|
914 | 950 | { |
915 | 951 | $input_html = '<select name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"><option value="-1"></option>'; |
916 | 952 | $options = explode(',', $row['field_options']); |
@@ -918,13 +954,13 @@ discard block |
||
918 | 954 | { |
919 | 955 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
920 | 956 | $input_html .= '<option value="' . $k . '"' . ($true ? ' selected' : '') . '>' . $v . '</option>'; |
921 | - if ($true) |
|
922 | - $output_html = $v; |
|
957 | + if ($true) { |
|
958 | + $output_html = $v; |
|
959 | + } |
|
923 | 960 | } |
924 | 961 | |
925 | 962 | $input_html .= '</select>'; |
926 | - } |
|
927 | - elseif ($row['field_type'] == 'radio') |
|
963 | + } elseif ($row['field_type'] == 'radio') |
|
928 | 964 | { |
929 | 965 | $input_html = '<fieldset>'; |
930 | 966 | $options = explode(',', $row['field_options']); |
@@ -932,36 +968,37 @@ discard block |
||
932 | 968 | { |
933 | 969 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
934 | 970 | $input_html .= '<label for="customfield_' . $row['col_name'] . '_' . $k . '"><input type="radio" name="customfield[' . $row['col_name'] . ']" id="customfield_' . $row['col_name'] . '_' . $k . '" value="' . $k . '"' . ($true ? ' checked' : '') . '>' . $v . '</label><br>'; |
935 | - if ($true) |
|
936 | - $output_html = $v; |
|
971 | + if ($true) { |
|
972 | + $output_html = $v; |
|
973 | + } |
|
937 | 974 | } |
938 | 975 | $input_html .= '</fieldset>'; |
939 | - } |
|
940 | - elseif ($row['field_type'] == 'text') |
|
976 | + } elseif ($row['field_type'] == 'text') |
|
941 | 977 | { |
942 | 978 | $input_html = '<input type="text" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($row['field_length'] != 0 ? ' maxlength="' . $row['field_length'] . '"' : '') . ' size="' . ($row['field_length'] == 0 || $row['field_length'] >= 50 ? 50 : ($row['field_length'] > 30 ? 30 : ($row['field_length'] > 10 ? 20 : 10))) . '" value="' . un_htmlspecialchars($value) . '"' . ($row['show_reg'] == 2 ? ' required' : '') . '>'; |
943 | - } |
|
944 | - else |
|
979 | + } else |
|
945 | 980 | { |
946 | 981 | @list ($rows, $cols) = @explode(',', $row['default_value']); |
947 | 982 | $input_html = '<textarea name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . (!empty($rows) ? ' rows="' . $rows . '"' : '') . (!empty($cols) ? ' cols="' . $cols . '"' : '') . ($row['show_reg'] == 2 ? ' required' : '') . '>' . un_htmlspecialchars($value) . '</textarea>'; |
948 | 983 | } |
949 | 984 | |
950 | 985 | // Parse BBCode |
951 | - if ($row['bbc']) |
|
952 | - $output_html = parse_bbc($output_html); |
|
953 | - elseif ($row['field_type'] == 'textarea') |
|
954 | - // Allow for newlines at least |
|
986 | + if ($row['bbc']) { |
|
987 | + $output_html = parse_bbc($output_html); |
|
988 | + } elseif ($row['field_type'] == 'textarea') { |
|
989 | + // Allow for newlines at least |
|
955 | 990 | $output_html = strtr($output_html, array("\n" => '<br>')); |
991 | + } |
|
956 | 992 | |
957 | 993 | // Enclosing the user input within some other text? |
958 | - if (!empty($row['enclose']) && !empty($output_html)) |
|
959 | - $output_html = strtr($row['enclose'], array( |
|
994 | + if (!empty($row['enclose']) && !empty($output_html)) { |
|
995 | + $output_html = strtr($row['enclose'], array( |
|
960 | 996 | '{SCRIPTURL}' => $scripturl, |
961 | 997 | '{IMAGES_URL}' => $settings['images_url'], |
962 | 998 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
963 | 999 | '{INPUT}' => un_htmlspecialchars($output_html), |
964 | 1000 | )); |
1001 | + } |
|
965 | 1002 | |
966 | 1003 | $context['custom_fields'][] = array( |
967 | 1004 | 'name' => $row['field_name'], |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Load the $modSettings array. |
@@ -25,13 +26,14 @@ discard block |
||
25 | 26 | global $cache_enable, $sourcedir, $context; |
26 | 27 | |
27 | 28 | // Most database systems have not set UTF-8 as their default input charset. |
28 | - if (!empty($db_character_set)) |
|
29 | - $smcFunc['db_query']('', ' |
|
29 | + if (!empty($db_character_set)) { |
|
30 | + $smcFunc['db_query']('', ' |
|
30 | 31 | SET NAMES {string:db_character_set}', |
31 | 32 | array( |
32 | 33 | 'db_character_set' => $db_character_set, |
33 | 34 | ) |
34 | 35 | ); |
36 | + } |
|
35 | 37 | |
36 | 38 | // We need some caching support, maybe. |
37 | 39 | loadCacheAccelerator(); |
@@ -46,28 +48,36 @@ discard block |
||
46 | 48 | ) |
47 | 49 | ); |
48 | 50 | $modSettings = array(); |
49 | - if (!$request) |
|
50 | - display_db_error(); |
|
51 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
52 | - $modSettings[$row[0]] = $row[1]; |
|
51 | + if (!$request) { |
|
52 | + display_db_error(); |
|
53 | + } |
|
54 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
55 | + $modSettings[$row[0]] = $row[1]; |
|
56 | + } |
|
53 | 57 | $smcFunc['db_free_result']($request); |
54 | 58 | |
55 | 59 | // Do a few things to protect against missing settings or settings with invalid values... |
56 | - if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) |
|
57 | - $modSettings['defaultMaxTopics'] = 20; |
|
58 | - if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) |
|
59 | - $modSettings['defaultMaxMessages'] = 15; |
|
60 | - if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) |
|
61 | - $modSettings['defaultMaxMembers'] = 30; |
|
62 | - if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) |
|
63 | - $modSettings['defaultMaxListItems'] = 15; |
|
60 | + if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) { |
|
61 | + $modSettings['defaultMaxTopics'] = 20; |
|
62 | + } |
|
63 | + if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) { |
|
64 | + $modSettings['defaultMaxMessages'] = 15; |
|
65 | + } |
|
66 | + if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) { |
|
67 | + $modSettings['defaultMaxMembers'] = 30; |
|
68 | + } |
|
69 | + if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) { |
|
70 | + $modSettings['defaultMaxListItems'] = 15; |
|
71 | + } |
|
64 | 72 | |
65 | 73 | // We excpiclity do not use $smcFunc['json_decode'] here yet, as $smcFunc is not fully loaded. |
66 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
67 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
74 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
75 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
76 | + } |
|
68 | 77 | |
69 | - if (!empty($cache_enable)) |
|
70 | - cache_put_data('modSettings', $modSettings, 90); |
|
78 | + if (!empty($cache_enable)) { |
|
79 | + cache_put_data('modSettings', $modSettings, 90); |
|
80 | + } |
|
71 | 81 | } |
72 | 82 | |
73 | 83 | $modSettings['cache_enable'] = $cache_enable; |
@@ -87,8 +97,9 @@ discard block |
||
87 | 97 | }; |
88 | 98 | $fix_utf8mb4 = function($string) use ($utf8, $smcFunc) |
89 | 99 | { |
90 | - if (!$utf8 || $smcFunc['db_mb4']) |
|
91 | - return $string; |
|
100 | + if (!$utf8 || $smcFunc['db_mb4']) { |
|
101 | + return $string; |
|
102 | + } |
|
92 | 103 | |
93 | 104 | $i = 0; |
94 | 105 | $len = strlen($string); |
@@ -100,18 +111,15 @@ discard block |
||
100 | 111 | { |
101 | 112 | $new_string .= $string[$i]; |
102 | 113 | $i++; |
103 | - } |
|
104 | - elseif ($ord < 224) |
|
114 | + } elseif ($ord < 224) |
|
105 | 115 | { |
106 | 116 | $new_string .= $string[$i] . $string[$i + 1]; |
107 | 117 | $i += 2; |
108 | - } |
|
109 | - elseif ($ord < 240) |
|
118 | + } elseif ($ord < 240) |
|
110 | 119 | { |
111 | 120 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
112 | 121 | $i += 3; |
113 | - } |
|
114 | - elseif ($ord < 248) |
|
122 | + } elseif ($ord < 248) |
|
115 | 123 | { |
116 | 124 | // Magic happens. |
117 | 125 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -155,8 +163,7 @@ discard block |
||
155 | 163 | { |
156 | 164 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
157 | 165 | return is_int($result) ? $result + $offset : false; |
158 | - } |
|
159 | - else |
|
166 | + } else |
|
160 | 167 | { |
161 | 168 | $needle_arr = preg_split('~(&#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . ';|"|&|<|>| |.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
162 | 169 | $needle_size = count($needle_arr); |
@@ -165,8 +172,9 @@ discard block |
||
165 | 172 | while ((int) $result === $result) |
166 | 173 | { |
167 | 174 | $offset += $result; |
168 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
169 | - return $offset; |
|
175 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
176 | + return $offset; |
|
177 | + } |
|
170 | 178 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
171 | 179 | } |
172 | 180 | return false; |
@@ -204,8 +212,9 @@ discard block |
||
204 | 212 | $string = $ent_check($string); |
205 | 213 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
206 | 214 | $string = $matches[0]; |
207 | - while (strlen($string) > $length) |
|
208 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
215 | + while (strlen($string) > $length) { |
|
216 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
217 | + } |
|
209 | 218 | return $string; |
210 | 219 | }, |
211 | 220 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -215,8 +224,9 @@ discard block |
||
215 | 224 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
216 | 225 | { |
217 | 226 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
218 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
219 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
227 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
228 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
229 | + } |
|
220 | 230 | return implode('', $words); |
221 | 231 | } : 'ucwords', |
222 | 232 | 'json_decode' => 'smf_json_decode', |
@@ -224,16 +234,17 @@ discard block |
||
224 | 234 | ); |
225 | 235 | |
226 | 236 | // Setting the timezone is a requirement for some functions. |
227 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
228 | - date_default_timezone_set($modSettings['default_timezone']); |
|
229 | - else |
|
237 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
238 | + date_default_timezone_set($modSettings['default_timezone']); |
|
239 | + } else |
|
230 | 240 | { |
231 | 241 | // Get PHP's default timezone, if set |
232 | 242 | $ini_tz = ini_get('date.timezone'); |
233 | - if (!empty($ini_tz)) |
|
234 | - $modSettings['default_timezone'] = $ini_tz; |
|
235 | - else |
|
236 | - $modSettings['default_timezone'] = ''; |
|
243 | + if (!empty($ini_tz)) { |
|
244 | + $modSettings['default_timezone'] = $ini_tz; |
|
245 | + } else { |
|
246 | + $modSettings['default_timezone'] = ''; |
|
247 | + } |
|
237 | 248 | |
238 | 249 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
239 | 250 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -251,22 +262,26 @@ discard block |
||
251 | 262 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
252 | 263 | { |
253 | 264 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
254 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
255 | - $modSettings['load_average'] = (float) $matches[1]; |
|
256 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
257 | - $modSettings['load_average'] = (float) $matches[1]; |
|
258 | - else |
|
259 | - unset($modSettings['load_average']); |
|
265 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
266 | + $modSettings['load_average'] = (float) $matches[1]; |
|
267 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
268 | + $modSettings['load_average'] = (float) $matches[1]; |
|
269 | + } else { |
|
270 | + unset($modSettings['load_average']); |
|
271 | + } |
|
260 | 272 | |
261 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
262 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
273 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
274 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
275 | + } |
|
263 | 276 | } |
264 | 277 | |
265 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
266 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
278 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
279 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
280 | + } |
|
267 | 281 | |
268 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
269 | - display_loadavg_error(); |
|
282 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
283 | + display_loadavg_error(); |
|
284 | + } |
|
270 | 285 | } |
271 | 286 | |
272 | 287 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -287,8 +302,9 @@ discard block |
||
287 | 302 | if (defined('SMF_INTEGRATION_SETTINGS')) |
288 | 303 | { |
289 | 304 | $integration_settings = $smcFunc['json_decode'](SMF_INTEGRATION_SETTINGS, true); |
290 | - foreach ($integration_settings as $hook => $function) |
|
291 | - add_integration_function($hook, $function, '', false); |
|
305 | + foreach ($integration_settings as $hook => $function) { |
|
306 | + add_integration_function($hook, $function, '', false); |
|
307 | + } |
|
292 | 308 | } |
293 | 309 | |
294 | 310 | // Any files to pre include? |
@@ -298,8 +314,9 @@ discard block |
||
298 | 314 | foreach ($pre_includes as $include) |
299 | 315 | { |
300 | 316 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
301 | - if (file_exists($include)) |
|
302 | - require_once($include); |
|
317 | + if (file_exists($include)) { |
|
318 | + require_once($include); |
|
319 | + } |
|
303 | 320 | } |
304 | 321 | } |
305 | 322 | |
@@ -405,27 +422,28 @@ discard block |
||
405 | 422 | break; |
406 | 423 | } |
407 | 424 | } |
425 | + } else { |
|
426 | + $id_member = 0; |
|
408 | 427 | } |
409 | - else |
|
410 | - $id_member = 0; |
|
411 | 428 | |
412 | 429 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
413 | 430 | { |
414 | 431 | $cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false); |
415 | 432 | |
416 | - if (empty($cookie_data)) |
|
417 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
433 | + if (empty($cookie_data)) { |
|
434 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
435 | + } |
|
418 | 436 | |
419 | 437 | list ($id_member, $password) = $cookie_data; |
420 | 438 | $id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0; |
421 | - } |
|
422 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
439 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
423 | 440 | { |
424 | 441 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
425 | 442 | $cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
426 | 443 | |
427 | - if (empty($cookie_data)) |
|
428 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
444 | + if (empty($cookie_data)) { |
|
445 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
446 | + } |
|
429 | 447 | |
430 | 448 | list ($id_member, $password, $login_span) = $cookie_data; |
431 | 449 | $id_member = !empty($id_member) && strlen($password) == 128 && $login_span > time() ? (int) $id_member : 0; |
@@ -450,30 +468,34 @@ discard block |
||
450 | 468 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
451 | 469 | $smcFunc['db_free_result']($request); |
452 | 470 | |
453 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) |
|
454 | - $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
471 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) { |
|
472 | + $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
473 | + } |
|
455 | 474 | |
456 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
457 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
475 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
476 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
477 | + } |
|
458 | 478 | } |
459 | 479 | |
460 | 480 | // Did we find 'im? If not, junk it. |
461 | 481 | if (!empty($user_settings)) |
462 | 482 | { |
463 | 483 | // As much as the password should be right, we can assume the integration set things up. |
464 | - if (!empty($already_verified) && $already_verified === true) |
|
465 | - $check = true; |
|
484 | + if (!empty($already_verified) && $already_verified === true) { |
|
485 | + $check = true; |
|
486 | + } |
|
466 | 487 | // SHA-512 hash should be 128 characters long. |
467 | - elseif (strlen($password) == 128) |
|
468 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
469 | - else |
|
470 | - $check = false; |
|
488 | + elseif (strlen($password) == 128) { |
|
489 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
490 | + } else { |
|
491 | + $check = false; |
|
492 | + } |
|
471 | 493 | |
472 | 494 | // Wrong password or not activated - either way, you're going nowhere. |
473 | 495 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
496 | + } else { |
|
497 | + $id_member = 0; |
|
474 | 498 | } |
475 | - else |
|
476 | - $id_member = 0; |
|
477 | 499 | |
478 | 500 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
479 | 501 | if (!$id_member) |
@@ -502,8 +524,9 @@ discard block |
||
502 | 524 | |
503 | 525 | list ($tfamember, $tfasecret) = $tfa_data; |
504 | 526 | |
505 | - if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) |
|
506 | - $tfasecret = null; |
|
527 | + if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) { |
|
528 | + $tfasecret = null; |
|
529 | + } |
|
507 | 530 | } |
508 | 531 | |
509 | 532 | if (empty($tfasecret) || hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']) != $tfasecret) |
@@ -523,10 +546,12 @@ discard block |
||
523 | 546 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
524 | 547 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
525 | 548 | { |
526 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
549 | + if ($modSettings['tfa_mode'] == 2) { |
|
550 | + //only do this if we are just forcing SOME membergroups |
|
527 | 551 | { |
528 | 552 | //Build an array of ALL user membergroups. |
529 | 553 | $full_groups = array($user_settings['id_group']); |
554 | + } |
|
530 | 555 | if (!empty($user_settings['additional_groups'])) |
531 | 556 | { |
532 | 557 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -546,15 +571,17 @@ discard block |
||
546 | 571 | ); |
547 | 572 | $row = $smcFunc['db_fetch_assoc']($request); |
548 | 573 | $smcFunc['db_free_result']($request); |
574 | + } else { |
|
575 | + $row['total'] = 1; |
|
549 | 576 | } |
550 | - else |
|
551 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
577 | + //simplifies logics in the next "if" |
|
552 | 578 | |
553 | 579 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
554 | 580 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
555 | 581 | |
556 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
557 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
582 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
583 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
584 | + } |
|
558 | 585 | } |
559 | 586 | } |
560 | 587 | |
@@ -591,33 +618,37 @@ discard block |
||
591 | 618 | updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'])); |
592 | 619 | $user_settings['last_login'] = time(); |
593 | 620 | |
594 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
595 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
621 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
622 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
623 | + } |
|
596 | 624 | |
597 | - if (!empty($modSettings['cache_enable'])) |
|
598 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
625 | + if (!empty($modSettings['cache_enable'])) { |
|
626 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
627 | + } |
|
599 | 628 | } |
629 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
630 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
600 | 631 | } |
601 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
602 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
603 | 632 | |
604 | 633 | $username = $user_settings['member_name']; |
605 | 634 | |
606 | - if (empty($user_settings['additional_groups'])) |
|
607 | - $user_info = array( |
|
635 | + if (empty($user_settings['additional_groups'])) { |
|
636 | + $user_info = array( |
|
608 | 637 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
609 | 638 | ); |
610 | - else |
|
611 | - $user_info = array( |
|
639 | + } else { |
|
640 | + $user_info = array( |
|
612 | 641 | 'groups' => array_merge( |
613 | 642 | array($user_settings['id_group'], $user_settings['id_post_group']), |
614 | 643 | explode(',', $user_settings['additional_groups']) |
615 | 644 | ) |
616 | 645 | ); |
646 | + } |
|
617 | 647 | |
618 | 648 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
619 | - foreach ($user_info['groups'] as $k => $v) |
|
620 | - $user_info['groups'][$k] = (int) $v; |
|
649 | + foreach ($user_info['groups'] as $k => $v) { |
|
650 | + $user_info['groups'][$k] = (int) $v; |
|
651 | + } |
|
621 | 652 | |
622 | 653 | // This is a logged in user, so definitely not a spider. |
623 | 654 | $user_info['possibly_robot'] = false; |
@@ -631,8 +662,7 @@ discard block |
||
631 | 662 | $time_system = new DateTime('now', $tz_system); |
632 | 663 | $time_user = new DateTime('now', $tz_user); |
633 | 664 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
634 | - } |
|
635 | - else |
|
665 | + } else |
|
636 | 666 | { |
637 | 667 | // !!! Compatibility. |
638 | 668 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -646,8 +676,9 @@ discard block |
||
646 | 676 | $user_info = array('groups' => array(-1)); |
647 | 677 | $user_settings = array(); |
648 | 678 | |
649 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
650 | - $_COOKIE[$cookiename] = ''; |
|
679 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
680 | + $_COOKIE[$cookiename] = ''; |
|
681 | + } |
|
651 | 682 | |
652 | 683 | // Expire the 2FA cookie |
653 | 684 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
@@ -664,19 +695,20 @@ discard block |
||
664 | 695 | } |
665 | 696 | |
666 | 697 | // Create a login token if it doesn't exist yet. |
667 | - if (!isset($_SESSION['token']['post-login'])) |
|
668 | - createToken('login'); |
|
669 | - else |
|
670 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
698 | + if (!isset($_SESSION['token']['post-login'])) { |
|
699 | + createToken('login'); |
|
700 | + } else { |
|
701 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
702 | + } |
|
671 | 703 | |
672 | 704 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
673 | 705 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
674 | 706 | { |
675 | 707 | require_once($sourcedir . '/ManageSearchEngines.php'); |
676 | 708 | $user_info['possibly_robot'] = SpiderCheck(); |
709 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
710 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
677 | 711 | } |
678 | - elseif (!empty($modSettings['spider_mode'])) |
|
679 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
680 | 712 | // If we haven't turned on proper spider hunts then have a guess! |
681 | 713 | else |
682 | 714 | { |
@@ -724,8 +756,9 @@ discard block |
||
724 | 756 | $user_info['groups'] = array_unique($user_info['groups']); |
725 | 757 | |
726 | 758 | // Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems. |
727 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
728 | - unset($user_info['ignoreboards'][$tmp]); |
|
759 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
760 | + unset($user_info['ignoreboards'][$tmp]); |
|
761 | + } |
|
729 | 762 | |
730 | 763 | // Allow the user to change their language. |
731 | 764 | if (!empty($modSettings['userLanguage'])) |
@@ -738,13 +771,14 @@ discard block |
||
738 | 771 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
739 | 772 | |
740 | 773 | // Make it permanent for members. |
741 | - if (!empty($user_info['id'])) |
|
742 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
743 | - else |
|
744 | - $_SESSION['language'] = $user_info['language']; |
|
774 | + if (!empty($user_info['id'])) { |
|
775 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
776 | + } else { |
|
777 | + $_SESSION['language'] = $user_info['language']; |
|
778 | + } |
|
779 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
780 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
745 | 781 | } |
746 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
747 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
748 | 782 | } |
749 | 783 | |
750 | 784 | $temp = build_query_board($user_info['id']); |
@@ -807,9 +841,9 @@ discard block |
||
807 | 841 | } |
808 | 842 | |
809 | 843 | // Remember redirection is the key to avoiding fallout from your bosses. |
810 | - if (!empty($topic)) |
|
811 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
812 | - else |
|
844 | + if (!empty($topic)) { |
|
845 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
846 | + } else |
|
813 | 847 | { |
814 | 848 | loadPermissions(); |
815 | 849 | loadTheme(); |
@@ -827,10 +861,11 @@ discard block |
||
827 | 861 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
828 | 862 | { |
829 | 863 | // @todo SLOW? |
830 | - if (!empty($topic)) |
|
831 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
832 | - else |
|
833 | - $temp = cache_get_data('board-' . $board, 120); |
|
864 | + if (!empty($topic)) { |
|
865 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
866 | + } else { |
|
867 | + $temp = cache_get_data('board-' . $board, 120); |
|
868 | + } |
|
834 | 869 | |
835 | 870 | if (!empty($temp)) |
836 | 871 | { |
@@ -868,8 +903,9 @@ discard block |
||
868 | 903 | $row = $smcFunc['db_fetch_assoc']($request); |
869 | 904 | |
870 | 905 | // Set the current board. |
871 | - if (!empty($row['id_board'])) |
|
872 | - $board = $row['id_board']; |
|
906 | + if (!empty($row['id_board'])) { |
|
907 | + $board = $row['id_board']; |
|
908 | + } |
|
873 | 909 | |
874 | 910 | // Basic operating information. (globals... :/) |
875 | 911 | $board_info = array( |
@@ -905,21 +941,23 @@ discard block |
||
905 | 941 | |
906 | 942 | do |
907 | 943 | { |
908 | - if (!empty($row['id_moderator'])) |
|
909 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
944 | + if (!empty($row['id_moderator'])) { |
|
945 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
910 | 946 | 'id' => $row['id_moderator'], |
911 | 947 | 'name' => $row['real_name'], |
912 | 948 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
913 | 949 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
914 | 950 | ); |
951 | + } |
|
915 | 952 | |
916 | - if (!empty($row['id_moderator_group'])) |
|
917 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
953 | + if (!empty($row['id_moderator_group'])) { |
|
954 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
918 | 955 | 'id' => $row['id_moderator_group'], |
919 | 956 | 'name' => $row['group_name'], |
920 | 957 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
921 | 958 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
922 | 959 | ); |
960 | + } |
|
923 | 961 | } |
924 | 962 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
925 | 963 | |
@@ -951,12 +989,12 @@ discard block |
||
951 | 989 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
952 | 990 | { |
953 | 991 | // @todo SLOW? |
954 | - if (!empty($topic)) |
|
955 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
992 | + if (!empty($topic)) { |
|
993 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
994 | + } |
|
956 | 995 | cache_put_data('board-' . $board, $board_info, 120); |
957 | 996 | } |
958 | - } |
|
959 | - else |
|
997 | + } else |
|
960 | 998 | { |
961 | 999 | // Otherwise the topic is invalid, there are no moderators, etc. |
962 | 1000 | $board_info = array( |
@@ -970,8 +1008,9 @@ discard block |
||
970 | 1008 | $smcFunc['db_free_result']($request); |
971 | 1009 | } |
972 | 1010 | |
973 | - if (!empty($topic)) |
|
974 | - $_GET['board'] = (int) $board; |
|
1011 | + if (!empty($topic)) { |
|
1012 | + $_GET['board'] = (int) $board; |
|
1013 | + } |
|
975 | 1014 | |
976 | 1015 | if (!empty($board)) |
977 | 1016 | { |
@@ -981,10 +1020,12 @@ discard block |
||
981 | 1020 | // Now check if the user is a moderator. |
982 | 1021 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
983 | 1022 | |
984 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
985 | - $board_info['error'] = 'access'; |
|
986 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
987 | - $board_info['error'] = 'access'; |
|
1023 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
1024 | + $board_info['error'] = 'access'; |
|
1025 | + } |
|
1026 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
1027 | + $board_info['error'] = 'access'; |
|
1028 | + } |
|
988 | 1029 | |
989 | 1030 | // Build up the linktree. |
990 | 1031 | $context['linktree'] = array_merge( |
@@ -1007,8 +1048,9 @@ discard block |
||
1007 | 1048 | $context['current_board'] = $board; |
1008 | 1049 | |
1009 | 1050 | // No posting in redirection boards! |
1010 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
1011 | - $board_info['error'] == 'post_in_redirect'; |
|
1051 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
1052 | + $board_info['error'] == 'post_in_redirect'; |
|
1053 | + } |
|
1012 | 1054 | |
1013 | 1055 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
1014 | 1056 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1034,24 +1076,23 @@ discard block |
||
1034 | 1076 | ob_end_clean(); |
1035 | 1077 | header('HTTP/1.1 403 Forbidden'); |
1036 | 1078 | die; |
1037 | - } |
|
1038 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
1079 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
1039 | 1080 | { |
1040 | 1081 | // Slightly different error message here... |
1041 | 1082 | fatal_lang_error('cannot_post_redirect', false); |
1042 | - } |
|
1043 | - elseif ($user_info['is_guest']) |
|
1083 | + } elseif ($user_info['is_guest']) |
|
1044 | 1084 | { |
1045 | 1085 | loadLanguage('Errors'); |
1046 | 1086 | is_not_guest($txt['topic_gone']); |
1087 | + } else { |
|
1088 | + fatal_lang_error('topic_gone', false); |
|
1047 | 1089 | } |
1048 | - else |
|
1049 | - fatal_lang_error('topic_gone', false); |
|
1050 | 1090 | } |
1051 | 1091 | |
1052 | - if ($user_info['is_mod']) |
|
1053 | - $user_info['groups'][] = 3; |
|
1054 | -} |
|
1092 | + if ($user_info['is_mod']) { |
|
1093 | + $user_info['groups'][] = 3; |
|
1094 | + } |
|
1095 | + } |
|
1055 | 1096 | |
1056 | 1097 | /** |
1057 | 1098 | * Load this user's permissions. |
@@ -1072,8 +1113,9 @@ discard block |
||
1072 | 1113 | asort($cache_groups); |
1073 | 1114 | $cache_groups = implode(',', $cache_groups); |
1074 | 1115 | // If it's a spider then cache it different. |
1075 | - if ($user_info['possibly_robot']) |
|
1076 | - $cache_groups .= '-spider'; |
|
1116 | + if ($user_info['possibly_robot']) { |
|
1117 | + $cache_groups .= '-spider'; |
|
1118 | + } |
|
1077 | 1119 | |
1078 | 1120 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
1079 | 1121 | { |
@@ -1081,9 +1123,9 @@ discard block |
||
1081 | 1123 | banPermissions(); |
1082 | 1124 | |
1083 | 1125 | return; |
1126 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
1127 | + list ($user_info['permissions'], $removals) = $temp; |
|
1084 | 1128 | } |
1085 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
1086 | - list ($user_info['permissions'], $removals) = $temp; |
|
1087 | 1129 | } |
1088 | 1130 | |
1089 | 1131 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1105,23 +1147,26 @@ discard block |
||
1105 | 1147 | $removals = array(); |
1106 | 1148 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1107 | 1149 | { |
1108 | - if (empty($row['add_deny'])) |
|
1109 | - $removals[] = $row['permission']; |
|
1110 | - else |
|
1111 | - $user_info['permissions'][] = $row['permission']; |
|
1150 | + if (empty($row['add_deny'])) { |
|
1151 | + $removals[] = $row['permission']; |
|
1152 | + } else { |
|
1153 | + $user_info['permissions'][] = $row['permission']; |
|
1154 | + } |
|
1112 | 1155 | } |
1113 | 1156 | $smcFunc['db_free_result']($request); |
1114 | 1157 | |
1115 | - if (isset($cache_groups)) |
|
1116 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1158 | + if (isset($cache_groups)) { |
|
1159 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1160 | + } |
|
1117 | 1161 | } |
1118 | 1162 | |
1119 | 1163 | // Get the board permissions. |
1120 | 1164 | if (!empty($board)) |
1121 | 1165 | { |
1122 | 1166 | // Make sure the board (if any) has been loaded by loadBoard(). |
1123 | - if (!isset($board_info['profile'])) |
|
1124 | - fatal_lang_error('no_board'); |
|
1167 | + if (!isset($board_info['profile'])) { |
|
1168 | + fatal_lang_error('no_board'); |
|
1169 | + } |
|
1125 | 1170 | |
1126 | 1171 | $request = $smcFunc['db_query']('', ' |
1127 | 1172 | SELECT permission, add_deny |
@@ -1137,20 +1182,23 @@ discard block |
||
1137 | 1182 | ); |
1138 | 1183 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1139 | 1184 | { |
1140 | - if (empty($row['add_deny'])) |
|
1141 | - $removals[] = $row['permission']; |
|
1142 | - else |
|
1143 | - $user_info['permissions'][] = $row['permission']; |
|
1185 | + if (empty($row['add_deny'])) { |
|
1186 | + $removals[] = $row['permission']; |
|
1187 | + } else { |
|
1188 | + $user_info['permissions'][] = $row['permission']; |
|
1189 | + } |
|
1144 | 1190 | } |
1145 | 1191 | $smcFunc['db_free_result']($request); |
1146 | 1192 | } |
1147 | 1193 | |
1148 | 1194 | // Remove all the permissions they shouldn't have ;). |
1149 | - if (!empty($modSettings['permission_enable_deny'])) |
|
1150 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1195 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
1196 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1197 | + } |
|
1151 | 1198 | |
1152 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
1153 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1199 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
1200 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1201 | + } |
|
1154 | 1202 | |
1155 | 1203 | // Banned? Watch, don't touch.. |
1156 | 1204 | banPermissions(); |
@@ -1162,17 +1210,18 @@ discard block |
||
1162 | 1210 | { |
1163 | 1211 | require_once($sourcedir . '/Subs-Auth.php'); |
1164 | 1212 | rebuildModCache(); |
1213 | + } else { |
|
1214 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
1165 | 1215 | } |
1166 | - else |
|
1167 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
1168 | 1216 | |
1169 | 1217 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
1170 | 1218 | // For example this drastically simplifies certain changes to the profile area. |
1171 | 1219 | $user_info['permissions'][] = 'is_not_guest'; |
1172 | 1220 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
1173 | 1221 | $user_info['permissions'][] = 'profile_view_own'; |
1174 | - if (in_array('profile_view', $user_info['permissions'])) |
|
1175 | - $user_info['permissions'][] = 'profile_view_any'; |
|
1222 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
1223 | + $user_info['permissions'][] = 'profile_view_any'; |
|
1224 | + } |
|
1176 | 1225 | } |
1177 | 1226 | } |
1178 | 1227 | |
@@ -1190,8 +1239,9 @@ discard block |
||
1190 | 1239 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
1191 | 1240 | |
1192 | 1241 | // Can't just look for no users :P. |
1193 | - if (empty($users)) |
|
1194 | - return array(); |
|
1242 | + if (empty($users)) { |
|
1243 | + return array(); |
|
1244 | + } |
|
1195 | 1245 | |
1196 | 1246 | // Pass the set value |
1197 | 1247 | $context['loadMemberContext_set'] = $set; |
@@ -1206,8 +1256,9 @@ discard block |
||
1206 | 1256 | for ($i = 0, $n = count($users); $i < $n; $i++) |
1207 | 1257 | { |
1208 | 1258 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
1209 | - if ($data == null) |
|
1210 | - continue; |
|
1259 | + if ($data == null) { |
|
1260 | + continue; |
|
1261 | + } |
|
1211 | 1262 | |
1212 | 1263 | $loaded_ids[] = $data['id_member']; |
1213 | 1264 | $user_profile[$data['id_member']] = $data; |
@@ -1274,16 +1325,19 @@ discard block |
||
1274 | 1325 | $row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : ''; |
1275 | 1326 | |
1276 | 1327 | // Take care of proxying avatar if required, do this here for maximum reach |
1277 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) |
|
1278 | - $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
1328 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) { |
|
1329 | + $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
1330 | + } |
|
1279 | 1331 | |
1280 | 1332 | // Keep track of the member's normal member group |
1281 | 1333 | $row['primary_group'] = $row['member_group']; |
1282 | 1334 | |
1283 | - if (isset($row['member_ip'])) |
|
1284 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1285 | - if (isset($row['member_ip2'])) |
|
1286 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1335 | + if (isset($row['member_ip'])) { |
|
1336 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1337 | + } |
|
1338 | + if (isset($row['member_ip2'])) { |
|
1339 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1340 | + } |
|
1287 | 1341 | $new_loaded_ids[] = $row['id_member']; |
1288 | 1342 | $loaded_ids[] = $row['id_member']; |
1289 | 1343 | $row['options'] = array(); |
@@ -1302,8 +1356,9 @@ discard block |
||
1302 | 1356 | 'loaded_ids' => $new_loaded_ids, |
1303 | 1357 | ) |
1304 | 1358 | ); |
1305 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1306 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1359 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1360 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1361 | + } |
|
1307 | 1362 | $smcFunc['db_free_result']($request); |
1308 | 1363 | } |
1309 | 1364 | |
@@ -1314,10 +1369,11 @@ discard block |
||
1314 | 1369 | { |
1315 | 1370 | foreach ($loaded_ids as $a_member) |
1316 | 1371 | { |
1317 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
1318 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1319 | - else |
|
1320 | - $groups = array($user_profile[$a_member]['id_group']); |
|
1372 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
1373 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1374 | + } else { |
|
1375 | + $groups = array($user_profile[$a_member]['id_group']); |
|
1376 | + } |
|
1321 | 1377 | |
1322 | 1378 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
1323 | 1379 | |
@@ -1330,8 +1386,9 @@ discard block |
||
1330 | 1386 | |
1331 | 1387 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
1332 | 1388 | { |
1333 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
1334 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1389 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
1390 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1391 | + } |
|
1335 | 1392 | } |
1336 | 1393 | |
1337 | 1394 | // Are we loading any moderators? If so, fix their group data... |
@@ -1357,14 +1414,17 @@ discard block |
||
1357 | 1414 | foreach ($temp_mods as $id) |
1358 | 1415 | { |
1359 | 1416 | // By popular demand, don't show admins or global moderators as moderators. |
1360 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
1361 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
1417 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
1418 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
1419 | + } |
|
1362 | 1420 | |
1363 | 1421 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
1364 | - if (!empty($row['icons'])) |
|
1365 | - $user_profile[$id]['icons'] = $row['icons']; |
|
1366 | - if (!empty($row['member_group_color'])) |
|
1367 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1422 | + if (!empty($row['icons'])) { |
|
1423 | + $user_profile[$id]['icons'] = $row['icons']; |
|
1424 | + } |
|
1425 | + if (!empty($row['member_group_color'])) { |
|
1426 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1427 | + } |
|
1368 | 1428 | } |
1369 | 1429 | } |
1370 | 1430 | |
@@ -1386,12 +1446,14 @@ discard block |
||
1386 | 1446 | static $loadedLanguages = array(); |
1387 | 1447 | |
1388 | 1448 | // If this person's data is already loaded, skip it. |
1389 | - if (isset($dataLoaded[$user])) |
|
1390 | - return true; |
|
1449 | + if (isset($dataLoaded[$user])) { |
|
1450 | + return true; |
|
1451 | + } |
|
1391 | 1452 | |
1392 | 1453 | // We can't load guests or members not loaded by loadMemberData()! |
1393 | - if ($user == 0) |
|
1394 | - return false; |
|
1454 | + if ($user == 0) { |
|
1455 | + return false; |
|
1456 | + } |
|
1395 | 1457 | if (!isset($user_profile[$user])) |
1396 | 1458 | { |
1397 | 1459 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1417,12 +1479,16 @@ discard block |
||
1417 | 1479 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
1418 | 1480 | |
1419 | 1481 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
1420 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
1482 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
1483 | + //icon is set and exists |
|
1421 | 1484 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
1422 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
1485 | + } elseif (isset($profile['icons'][1])) { |
|
1486 | + //icon is set and doesn't exist, fallback to default |
|
1423 | 1487 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
1424 | - else //not set, bye bye |
|
1488 | + } else { |
|
1489 | + //not set, bye bye |
|
1425 | 1490 | $group_icon_url = ''; |
1491 | + } |
|
1426 | 1492 | |
1427 | 1493 | // These minimal values are always loaded |
1428 | 1494 | $memberContext[$user] = array( |
@@ -1441,8 +1507,9 @@ discard block |
||
1441 | 1507 | if ($context['loadMemberContext_set'] != 'minimal') |
1442 | 1508 | { |
1443 | 1509 | // Go the extra mile and load the user's native language name. |
1444 | - if (empty($loadedLanguages)) |
|
1445 | - $loadedLanguages = getLanguages(); |
|
1510 | + if (empty($loadedLanguages)) { |
|
1511 | + $loadedLanguages = getLanguages(); |
|
1512 | + } |
|
1446 | 1513 | |
1447 | 1514 | $memberContext[$user] += array( |
1448 | 1515 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1497,31 +1564,33 @@ discard block |
||
1497 | 1564 | { |
1498 | 1565 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
1499 | 1566 | { |
1500 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
1501 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1502 | - else |
|
1503 | - $image = get_gravatar_url($profile['email_address']); |
|
1504 | - } |
|
1505 | - else |
|
1567 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
1568 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1569 | + } else { |
|
1570 | + $image = get_gravatar_url($profile['email_address']); |
|
1571 | + } |
|
1572 | + } else |
|
1506 | 1573 | { |
1507 | 1574 | // So it's stored in the member table? |
1508 | 1575 | if (!empty($profile['avatar'])) |
1509 | 1576 | { |
1510 | 1577 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
1578 | + } elseif (!empty($profile['filename'])) { |
|
1579 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1511 | 1580 | } |
1512 | - elseif (!empty($profile['filename'])) |
|
1513 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1514 | 1581 | // Right... no avatar...use the default one |
1515 | - else |
|
1516 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
1582 | + else { |
|
1583 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
1584 | + } |
|
1517 | 1585 | } |
1518 | - if (!empty($image)) |
|
1519 | - $memberContext[$user]['avatar'] = array( |
|
1586 | + if (!empty($image)) { |
|
1587 | + $memberContext[$user]['avatar'] = array( |
|
1520 | 1588 | 'name' => $profile['avatar'], |
1521 | 1589 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
1522 | 1590 | 'href' => $image, |
1523 | 1591 | 'url' => $image, |
1524 | 1592 | ); |
1593 | + } |
|
1525 | 1594 | } |
1526 | 1595 | |
1527 | 1596 | // Are we also loading the members custom fields into context? |
@@ -1529,13 +1598,15 @@ discard block |
||
1529 | 1598 | { |
1530 | 1599 | $memberContext[$user]['custom_fields'] = array(); |
1531 | 1600 | |
1532 | - if (!isset($context['display_fields'])) |
|
1533 | - $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1601 | + if (!isset($context['display_fields'])) { |
|
1602 | + $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1603 | + } |
|
1534 | 1604 | |
1535 | 1605 | foreach ($context['display_fields'] as $custom) |
1536 | 1606 | { |
1537 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
1538 | - continue; |
|
1607 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
1608 | + continue; |
|
1609 | + } |
|
1539 | 1610 | |
1540 | 1611 | $value = $profile['options'][$custom['col_name']]; |
1541 | 1612 | |
@@ -1543,30 +1614,34 @@ discard block |
||
1543 | 1614 | $currentKey = 0; |
1544 | 1615 | |
1545 | 1616 | // Create a key => value array for multiple options fields |
1546 | - if (!empty($custom['options'])) |
|
1547 | - foreach ($custom['options'] as $k => $v) |
|
1617 | + if (!empty($custom['options'])) { |
|
1618 | + foreach ($custom['options'] as $k => $v) |
|
1548 | 1619 | { |
1549 | 1620 | $fieldOptions[] = $v; |
1621 | + } |
|
1550 | 1622 | $currentKey = $v == $value ? $k : 0; |
1551 | 1623 | } |
1552 | 1624 | |
1553 | 1625 | // BBC? |
1554 | - if ($custom['bbc']) |
|
1555 | - $value = parse_bbc($value); |
|
1626 | + if ($custom['bbc']) { |
|
1627 | + $value = parse_bbc($value); |
|
1628 | + } |
|
1556 | 1629 | |
1557 | 1630 | // ... or checkbox? |
1558 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
1559 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
1631 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
1632 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
1633 | + } |
|
1560 | 1634 | |
1561 | 1635 | // Enclosing the user input within some other text? |
1562 | - if (!empty($custom['enclose'])) |
|
1563 | - $value = strtr($custom['enclose'], array( |
|
1636 | + if (!empty($custom['enclose'])) { |
|
1637 | + $value = strtr($custom['enclose'], array( |
|
1564 | 1638 | '{SCRIPTURL}' => $scripturl, |
1565 | 1639 | '{IMAGES_URL}' => $settings['images_url'], |
1566 | 1640 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1567 | 1641 | '{INPUT}' => $value, |
1568 | 1642 | '{KEY}' => $currentKey, |
1569 | 1643 | )); |
1644 | + } |
|
1570 | 1645 | |
1571 | 1646 | $memberContext[$user]['custom_fields'][] = array( |
1572 | 1647 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1593,8 +1668,9 @@ discard block |
||
1593 | 1668 | global $smcFunc, $txt, $scripturl, $settings; |
1594 | 1669 | |
1595 | 1670 | // Do not waste my time... |
1596 | - if (empty($users) || empty($params)) |
|
1597 | - return false; |
|
1671 | + if (empty($users) || empty($params)) { |
|
1672 | + return false; |
|
1673 | + } |
|
1598 | 1674 | |
1599 | 1675 | // Make sure it's an array. |
1600 | 1676 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1621,40 +1697,46 @@ discard block |
||
1621 | 1697 | $currentKey = 0; |
1622 | 1698 | |
1623 | 1699 | // Create a key => value array for multiple options fields |
1624 | - if (!empty($row['field_options'])) |
|
1625 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
1700 | + if (!empty($row['field_options'])) { |
|
1701 | + foreach (explode(',', $row['field_options']) as $k => $v) |
|
1626 | 1702 | { |
1627 | 1703 | $fieldOptions[] = $v; |
1704 | + } |
|
1628 | 1705 | $currentKey = $v == $row['value'] ? $k : 0; |
1629 | 1706 | } |
1630 | 1707 | |
1631 | 1708 | // BBC? |
1632 | - if (!empty($row['bbc'])) |
|
1633 | - $row['value'] = parse_bbc($row['value']); |
|
1709 | + if (!empty($row['bbc'])) { |
|
1710 | + $row['value'] = parse_bbc($row['value']); |
|
1711 | + } |
|
1634 | 1712 | |
1635 | 1713 | // ... or checkbox? |
1636 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
1637 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1714 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
1715 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1716 | + } |
|
1638 | 1717 | |
1639 | 1718 | // Enclosing the user input within some other text? |
1640 | - if (!empty($row['enclose'])) |
|
1641 | - $row['value'] = strtr($row['enclose'], array( |
|
1719 | + if (!empty($row['enclose'])) { |
|
1720 | + $row['value'] = strtr($row['enclose'], array( |
|
1642 | 1721 | '{SCRIPTURL}' => $scripturl, |
1643 | 1722 | '{IMAGES_URL}' => $settings['images_url'], |
1644 | 1723 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1645 | 1724 | '{INPUT}' => un_htmlspecialchars($row['value']), |
1646 | 1725 | '{KEY}' => $currentKey, |
1647 | 1726 | )); |
1727 | + } |
|
1648 | 1728 | |
1649 | 1729 | // Send a simple array if there is just 1 param |
1650 | - if (count($params) == 1) |
|
1651 | - $return[$row['id_member']] = $row; |
|
1730 | + if (count($params) == 1) { |
|
1731 | + $return[$row['id_member']] = $row; |
|
1732 | + } |
|
1652 | 1733 | |
1653 | 1734 | // More than 1? knock yourself out... |
1654 | 1735 | else |
1655 | 1736 | { |
1656 | - if (!isset($return[$row['id_member']])) |
|
1657 | - $return[$row['id_member']] = array(); |
|
1737 | + if (!isset($return[$row['id_member']])) { |
|
1738 | + $return[$row['id_member']] = array(); |
|
1739 | + } |
|
1658 | 1740 | |
1659 | 1741 | $return[$row['id_member']][$row['variable']] = $row; |
1660 | 1742 | } |
@@ -1688,8 +1770,9 @@ discard block |
||
1688 | 1770 | global $context; |
1689 | 1771 | |
1690 | 1772 | // Don't know any browser! |
1691 | - if (empty($context['browser'])) |
|
1692 | - detectBrowser(); |
|
1773 | + if (empty($context['browser'])) { |
|
1774 | + detectBrowser(); |
|
1775 | + } |
|
1693 | 1776 | |
1694 | 1777 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
1695 | 1778 | } |
@@ -1707,8 +1790,9 @@ discard block |
||
1707 | 1790 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
1708 | 1791 | |
1709 | 1792 | // The theme was specified by parameter. |
1710 | - if (!empty($id_theme)) |
|
1711 | - $id_theme = (int) $id_theme; |
|
1793 | + if (!empty($id_theme)) { |
|
1794 | + $id_theme = (int) $id_theme; |
|
1795 | + } |
|
1712 | 1796 | // The theme was specified by REQUEST. |
1713 | 1797 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
1714 | 1798 | { |
@@ -1716,54 +1800,61 @@ discard block |
||
1716 | 1800 | $_SESSION['id_theme'] = $id_theme; |
1717 | 1801 | } |
1718 | 1802 | // The theme was specified by REQUEST... previously. |
1719 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
1720 | - $id_theme = (int) $_SESSION['id_theme']; |
|
1803 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
1804 | + $id_theme = (int) $_SESSION['id_theme']; |
|
1805 | + } |
|
1721 | 1806 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
1722 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
1723 | - $id_theme = $user_info['theme']; |
|
1807 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
1808 | + $id_theme = $user_info['theme']; |
|
1809 | + } |
|
1724 | 1810 | // The theme was specified by the board. |
1725 | - elseif (!empty($board_info['theme'])) |
|
1726 | - $id_theme = $board_info['theme']; |
|
1811 | + elseif (!empty($board_info['theme'])) { |
|
1812 | + $id_theme = $board_info['theme']; |
|
1813 | + } |
|
1727 | 1814 | // The theme is the forum's default. |
1728 | - else |
|
1729 | - $id_theme = $modSettings['theme_guests']; |
|
1815 | + else { |
|
1816 | + $id_theme = $modSettings['theme_guests']; |
|
1817 | + } |
|
1730 | 1818 | |
1731 | 1819 | // We already load the basic stuff? |
1732 | 1820 | if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme ) |
1733 | 1821 | { |
1734 | 1822 | // Verify the id_theme... no foul play. |
1735 | 1823 | // Always allow the board specific theme, if they are overriding. |
1736 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
1737 | - $id_theme = $board_info['theme']; |
|
1824 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
1825 | + $id_theme = $board_info['theme']; |
|
1826 | + } |
|
1738 | 1827 | // If they have specified a particular theme to use with SSI allow it to be used. |
1739 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
1740 | - $id_theme = (int) $id_theme; |
|
1741 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1828 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
1829 | + $id_theme = (int) $id_theme; |
|
1830 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1742 | 1831 | { |
1743 | 1832 | $themes = explode(',', $modSettings['enableThemes']); |
1744 | - if (!in_array($id_theme, $themes)) |
|
1745 | - $id_theme = $modSettings['theme_guests']; |
|
1746 | - else |
|
1747 | - $id_theme = (int) $id_theme; |
|
1833 | + if (!in_array($id_theme, $themes)) { |
|
1834 | + $id_theme = $modSettings['theme_guests']; |
|
1835 | + } else { |
|
1836 | + $id_theme = (int) $id_theme; |
|
1837 | + } |
|
1838 | + } else { |
|
1839 | + $id_theme = (int) $id_theme; |
|
1748 | 1840 | } |
1749 | - else |
|
1750 | - $id_theme = (int) $id_theme; |
|
1751 | 1841 | |
1752 | 1842 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
1753 | 1843 | |
1754 | 1844 | // Disable image proxy if we don't have SSL enabled |
1755 | - if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) |
|
1756 | - $image_proxy_enabled = false; |
|
1845 | + if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) { |
|
1846 | + $image_proxy_enabled = false; |
|
1847 | + } |
|
1757 | 1848 | |
1758 | 1849 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated']) |
1759 | 1850 | { |
1760 | 1851 | $themeData = $temp; |
1761 | 1852 | $flag = true; |
1853 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
1854 | + $themeData = $temp + array($member => array()); |
|
1855 | + } else { |
|
1856 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1762 | 1857 | } |
1763 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
1764 | - $themeData = $temp + array($member => array()); |
|
1765 | - else |
|
1766 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1767 | 1858 | |
1768 | 1859 | if (empty($flag)) |
1769 | 1860 | { |
@@ -1782,31 +1873,37 @@ discard block |
||
1782 | 1873 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1783 | 1874 | { |
1784 | 1875 | // There are just things we shouldn't be able to change as members. |
1785 | - if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) |
|
1786 | - continue; |
|
1876 | + if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) { |
|
1877 | + continue; |
|
1878 | + } |
|
1787 | 1879 | |
1788 | 1880 | // If this is the theme_dir of the default theme, store it. |
1789 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
1790 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1881 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
1882 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1883 | + } |
|
1791 | 1884 | |
1792 | 1885 | // If this isn't set yet, is a theme option, or is not the default theme.. |
1793 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
1794 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1886 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
1887 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1888 | + } |
|
1795 | 1889 | } |
1796 | 1890 | $smcFunc['db_free_result']($result); |
1797 | 1891 | |
1798 | - if (!empty($themeData[-1])) |
|
1799 | - foreach ($themeData[-1] as $k => $v) |
|
1892 | + if (!empty($themeData[-1])) { |
|
1893 | + foreach ($themeData[-1] as $k => $v) |
|
1800 | 1894 | { |
1801 | 1895 | if (!isset($themeData[$member][$k])) |
1802 | 1896 | $themeData[$member][$k] = $v; |
1897 | + } |
|
1803 | 1898 | } |
1804 | 1899 | |
1805 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
1806 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1900 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
1901 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1902 | + } |
|
1807 | 1903 | // Only if we didn't already load that part of the cache... |
1808 | - elseif (!isset($temp)) |
|
1809 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1904 | + elseif (!isset($temp)) { |
|
1905 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1906 | + } |
|
1810 | 1907 | } |
1811 | 1908 | |
1812 | 1909 | $settings = $themeData[0]; |
@@ -1823,17 +1920,20 @@ discard block |
||
1823 | 1920 | $settings['template_dirs'][] = $settings['theme_dir']; |
1824 | 1921 | |
1825 | 1922 | // Based on theme (if there is one). |
1826 | - if (!empty($settings['base_theme_dir'])) |
|
1827 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1923 | + if (!empty($settings['base_theme_dir'])) { |
|
1924 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1925 | + } |
|
1828 | 1926 | |
1829 | 1927 | // Lastly the default theme. |
1830 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
1831 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1928 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
1929 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1930 | + } |
|
1832 | 1931 | } |
1833 | 1932 | |
1834 | 1933 | |
1835 | - if (!$initialize) |
|
1836 | - return; |
|
1934 | + if (!$initialize) { |
|
1935 | + return; |
|
1936 | + } |
|
1837 | 1937 | |
1838 | 1938 | // Check to see if we're forcing SSL |
1839 | 1939 | if (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 && empty($maintenance) && |
@@ -1854,8 +1954,9 @@ discard block |
||
1854 | 1954 | $detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; |
1855 | 1955 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
1856 | 1956 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
1857 | - if ($temp != '/') |
|
1858 | - $detected_url .= $temp; |
|
1957 | + if ($temp != '/') { |
|
1958 | + $detected_url .= $temp; |
|
1959 | + } |
|
1859 | 1960 | } |
1860 | 1961 | if (isset($detected_url) && $detected_url != $boardurl) |
1861 | 1962 | { |
@@ -1867,8 +1968,9 @@ discard block |
||
1867 | 1968 | foreach ($aliases as $alias) |
1868 | 1969 | { |
1869 | 1970 | // Rip off all the boring parts, spaces, etc. |
1870 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
1871 | - $do_fix = true; |
|
1971 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
1972 | + $do_fix = true; |
|
1973 | + } |
|
1872 | 1974 | } |
1873 | 1975 | } |
1874 | 1976 | |
@@ -1876,21 +1978,23 @@ discard block |
||
1876 | 1978 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
1877 | 1979 | { |
1878 | 1980 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
1879 | - if (empty($_GET)) |
|
1880 | - redirectexit('wwwRedirect'); |
|
1881 | - else |
|
1981 | + if (empty($_GET)) { |
|
1982 | + redirectexit('wwwRedirect'); |
|
1983 | + } else |
|
1882 | 1984 | { |
1883 | 1985 | $k = key($_GET); |
1884 | 1986 | $v = current($_GET); |
1885 | 1987 | |
1886 | - if ($k != 'wwwRedirect') |
|
1887 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1988 | + if ($k != 'wwwRedirect') { |
|
1989 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1990 | + } |
|
1888 | 1991 | } |
1889 | 1992 | } |
1890 | 1993 | |
1891 | 1994 | // #3 is just a check for SSL... |
1892 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
1893 | - $do_fix = true; |
|
1995 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
1996 | + $do_fix = true; |
|
1997 | + } |
|
1894 | 1998 | |
1895 | 1999 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
1896 | 2000 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1925,8 +2029,9 @@ discard block |
||
1925 | 2029 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
1926 | 2030 | } |
1927 | 2031 | } |
1928 | - foreach ($context['linktree'] as $k => $dummy) |
|
1929 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2032 | + foreach ($context['linktree'] as $k => $dummy) { |
|
2033 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2034 | + } |
|
1930 | 2035 | } |
1931 | 2036 | } |
1932 | 2037 | // Set up the contextual user array. |
@@ -1945,16 +2050,16 @@ discard block |
||
1945 | 2050 | 'email' => $user_info['email'], |
1946 | 2051 | 'ignoreusers' => $user_info['ignoreusers'], |
1947 | 2052 | ); |
1948 | - if (!$context['user']['is_guest']) |
|
1949 | - $context['user']['name'] = $user_info['name']; |
|
1950 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
1951 | - $context['user']['name'] = $txt['guest_title']; |
|
2053 | + if (!$context['user']['is_guest']) { |
|
2054 | + $context['user']['name'] = $user_info['name']; |
|
2055 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
2056 | + $context['user']['name'] = $txt['guest_title']; |
|
2057 | + } |
|
1952 | 2058 | |
1953 | 2059 | // Determine the current smiley set. |
1954 | 2060 | $user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set']; |
1955 | 2061 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
1956 | - } |
|
1957 | - else |
|
2062 | + } else |
|
1958 | 2063 | { |
1959 | 2064 | // What to do when there is no $user_info (e.g., an error very early in the login process) |
1960 | 2065 | $context['user'] = array( |
@@ -1988,18 +2093,24 @@ discard block |
||
1988 | 2093 | } |
1989 | 2094 | |
1990 | 2095 | // Some basic information... |
1991 | - if (!isset($context['html_headers'])) |
|
1992 | - $context['html_headers'] = ''; |
|
1993 | - if (!isset($context['javascript_files'])) |
|
1994 | - $context['javascript_files'] = array(); |
|
1995 | - if (!isset($context['css_files'])) |
|
1996 | - $context['css_files'] = array(); |
|
1997 | - if (!isset($context['css_header'])) |
|
1998 | - $context['css_header'] = array(); |
|
1999 | - if (!isset($context['javascript_inline'])) |
|
2000 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
2001 | - if (!isset($context['javascript_vars'])) |
|
2002 | - $context['javascript_vars'] = array(); |
|
2096 | + if (!isset($context['html_headers'])) { |
|
2097 | + $context['html_headers'] = ''; |
|
2098 | + } |
|
2099 | + if (!isset($context['javascript_files'])) { |
|
2100 | + $context['javascript_files'] = array(); |
|
2101 | + } |
|
2102 | + if (!isset($context['css_files'])) { |
|
2103 | + $context['css_files'] = array(); |
|
2104 | + } |
|
2105 | + if (!isset($context['css_header'])) { |
|
2106 | + $context['css_header'] = array(); |
|
2107 | + } |
|
2108 | + if (!isset($context['javascript_inline'])) { |
|
2109 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
2110 | + } |
|
2111 | + if (!isset($context['javascript_vars'])) { |
|
2112 | + $context['javascript_vars'] = array(); |
|
2113 | + } |
|
2003 | 2114 | |
2004 | 2115 | $context['login_url'] = (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl) . '?action=login2'; |
2005 | 2116 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -2011,16 +2122,18 @@ discard block |
||
2011 | 2122 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
2012 | 2123 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
2013 | 2124 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
2014 | - if (isset($modSettings['load_average'])) |
|
2015 | - $context['load_average'] = $modSettings['load_average']; |
|
2125 | + if (isset($modSettings['load_average'])) { |
|
2126 | + $context['load_average'] = $modSettings['load_average']; |
|
2127 | + } |
|
2016 | 2128 | |
2017 | 2129 | // Detect the browser. This is separated out because it's also used in attachment downloads |
2018 | 2130 | detectBrowser(); |
2019 | 2131 | |
2020 | 2132 | // Set the top level linktree up. |
2021 | 2133 | // Note that if we're dealing with certain very early errors (e.g., login) the linktree might not be set yet... |
2022 | - if (empty($context['linktree'])) |
|
2023 | - $context['linktree'] = array(); |
|
2134 | + if (empty($context['linktree'])) { |
|
2135 | + $context['linktree'] = array(); |
|
2136 | + } |
|
2024 | 2137 | array_unshift($context['linktree'], array( |
2025 | 2138 | 'url' => $scripturl, |
2026 | 2139 | 'name' => $context['forum_name_html_safe'] |
@@ -2029,8 +2142,9 @@ discard block |
||
2029 | 2142 | // This allows sticking some HTML on the page output - useful for controls. |
2030 | 2143 | $context['insert_after_template'] = ''; |
2031 | 2144 | |
2032 | - if (!isset($txt)) |
|
2033 | - $txt = array(); |
|
2145 | + if (!isset($txt)) { |
|
2146 | + $txt = array(); |
|
2147 | + } |
|
2034 | 2148 | |
2035 | 2149 | $simpleActions = array( |
2036 | 2150 | 'findmember', |
@@ -2076,9 +2190,10 @@ discard block |
||
2076 | 2190 | |
2077 | 2191 | // See if theres any extra param to check. |
2078 | 2192 | $requiresXML = false; |
2079 | - foreach ($extraParams as $key => $extra) |
|
2080 | - if (isset($_REQUEST[$extra])) |
|
2193 | + foreach ($extraParams as $key => $extra) { |
|
2194 | + if (isset($_REQUEST[$extra])) |
|
2081 | 2195 | $requiresXML = true; |
2196 | + } |
|
2082 | 2197 | |
2083 | 2198 | // Output is fully XML, so no need for the index template. |
2084 | 2199 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2093,37 +2208,39 @@ discard block |
||
2093 | 2208 | { |
2094 | 2209 | loadLanguage('index+Modifications'); |
2095 | 2210 | $context['template_layers'] = array(); |
2096 | - } |
|
2097 | - |
|
2098 | - else |
|
2211 | + } else |
|
2099 | 2212 | { |
2100 | 2213 | // Custom templates to load, or just default? |
2101 | - if (isset($settings['theme_templates'])) |
|
2102 | - $templates = explode(',', $settings['theme_templates']); |
|
2103 | - else |
|
2104 | - $templates = array('index'); |
|
2214 | + if (isset($settings['theme_templates'])) { |
|
2215 | + $templates = explode(',', $settings['theme_templates']); |
|
2216 | + } else { |
|
2217 | + $templates = array('index'); |
|
2218 | + } |
|
2105 | 2219 | |
2106 | 2220 | // Load each template... |
2107 | - foreach ($templates as $template) |
|
2108 | - loadTemplate($template); |
|
2221 | + foreach ($templates as $template) { |
|
2222 | + loadTemplate($template); |
|
2223 | + } |
|
2109 | 2224 | |
2110 | 2225 | // ...and attempt to load their associated language files. |
2111 | 2226 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
2112 | 2227 | loadLanguage($required_files, '', false); |
2113 | 2228 | |
2114 | 2229 | // Custom template layers? |
2115 | - if (isset($settings['theme_layers'])) |
|
2116 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2117 | - else |
|
2118 | - $context['template_layers'] = array('html', 'body'); |
|
2230 | + if (isset($settings['theme_layers'])) { |
|
2231 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2232 | + } else { |
|
2233 | + $context['template_layers'] = array('html', 'body'); |
|
2234 | + } |
|
2119 | 2235 | } |
2120 | 2236 | |
2121 | 2237 | // Initialize the theme. |
2122 | 2238 | loadSubTemplate('init', 'ignore'); |
2123 | 2239 | |
2124 | 2240 | // Allow overriding the board wide time/number formats. |
2125 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
2126 | - $user_info['time_format'] = $txt['time_format']; |
|
2241 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
2242 | + $user_info['time_format'] = $txt['time_format']; |
|
2243 | + } |
|
2127 | 2244 | |
2128 | 2245 | // Set the character set from the template. |
2129 | 2246 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2131,12 +2248,14 @@ discard block |
||
2131 | 2248 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
2132 | 2249 | |
2133 | 2250 | // Guests may still need a name. |
2134 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
2135 | - $context['user']['name'] = $txt['guest_title']; |
|
2251 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
2252 | + $context['user']['name'] = $txt['guest_title']; |
|
2253 | + } |
|
2136 | 2254 | |
2137 | 2255 | // Any theme-related strings that need to be loaded? |
2138 | - if (!empty($settings['require_theme_strings'])) |
|
2139 | - loadLanguage('ThemeStrings', '', false); |
|
2256 | + if (!empty($settings['require_theme_strings'])) { |
|
2257 | + loadLanguage('ThemeStrings', '', false); |
|
2258 | + } |
|
2140 | 2259 | |
2141 | 2260 | // Make a special URL for the language. |
2142 | 2261 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2147,8 +2266,9 @@ discard block |
||
2147 | 2266 | // Here is my luvly Responsive CSS |
2148 | 2267 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true), 'smf_responsive'); |
2149 | 2268 | |
2150 | - if ($context['right_to_left']) |
|
2151 | - loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
2269 | + if ($context['right_to_left']) { |
|
2270 | + loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
2271 | + } |
|
2152 | 2272 | |
2153 | 2273 | // We allow theme variants, because we're cool. |
2154 | 2274 | $context['theme_variant'] = ''; |
@@ -2156,14 +2276,17 @@ discard block |
||
2156 | 2276 | if (!empty($settings['theme_variants'])) |
2157 | 2277 | { |
2158 | 2278 | // Overriding - for previews and that ilk. |
2159 | - if (!empty($_REQUEST['variant'])) |
|
2160 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2279 | + if (!empty($_REQUEST['variant'])) { |
|
2280 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2281 | + } |
|
2161 | 2282 | // User selection? |
2162 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
2163 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2283 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
2284 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2285 | + } |
|
2164 | 2286 | // If not a user variant, select the default. |
2165 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
2166 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2287 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
2288 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2289 | + } |
|
2167 | 2290 | |
2168 | 2291 | // Do this to keep things easier in the templates. |
2169 | 2292 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2172,20 +2295,23 @@ discard block |
||
2172 | 2295 | if (!empty($context['theme_variant'])) |
2173 | 2296 | { |
2174 | 2297 | loadCSSFile('index' . $context['theme_variant'] . '.css', array(), 'smf_index' . $context['theme_variant']); |
2175 | - if ($context['right_to_left']) |
|
2176 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
2298 | + if ($context['right_to_left']) { |
|
2299 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
2300 | + } |
|
2177 | 2301 | } |
2178 | 2302 | } |
2179 | 2303 | |
2180 | 2304 | // Let's be compatible with old themes! |
2181 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
2182 | - $context['template_layers'] = array('main'); |
|
2305 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
2306 | + $context['template_layers'] = array('main'); |
|
2307 | + } |
|
2183 | 2308 | |
2184 | 2309 | $context['tabindex'] = 1; |
2185 | 2310 | |
2186 | 2311 | // Compatibility. |
2187 | - if (!isset($settings['theme_version'])) |
|
2188 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2312 | + if (!isset($settings['theme_version'])) { |
|
2313 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2314 | + } |
|
2189 | 2315 | |
2190 | 2316 | // Default JS variables for use in every theme |
2191 | 2317 | $context['javascript_vars'] = array( |
@@ -2204,18 +2330,18 @@ discard block |
||
2204 | 2330 | ); |
2205 | 2331 | |
2206 | 2332 | // Add the JQuery library to the list of files to load. |
2207 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
2208 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2209 | - |
|
2210 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
2211 | - loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2212 | - |
|
2213 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
2214 | - loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2333 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
2334 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2335 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
2336 | + loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2337 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
2338 | + loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2339 | + } |
|
2215 | 2340 | |
2216 | 2341 | // Auto loading? template_javascript() will take care of the local half of this. |
2217 | - else |
|
2218 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2342 | + else { |
|
2343 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2344 | + } |
|
2219 | 2345 | |
2220 | 2346 | // Queue our JQuery plugins! |
2221 | 2347 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2238,12 +2364,12 @@ discard block |
||
2238 | 2364 | require_once($sourcedir . '/ScheduledTasks.php'); |
2239 | 2365 | |
2240 | 2366 | // What to do, what to do?! |
2241 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
2242 | - AutoTask(); |
|
2243 | - else |
|
2244 | - ReduceMailQueue(); |
|
2245 | - } |
|
2246 | - else |
|
2367 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
2368 | + AutoTask(); |
|
2369 | + } else { |
|
2370 | + ReduceMailQueue(); |
|
2371 | + } |
|
2372 | + } else |
|
2247 | 2373 | { |
2248 | 2374 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
2249 | 2375 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2294,8 +2420,9 @@ discard block |
||
2294 | 2420 | foreach ($theme_includes as $include) |
2295 | 2421 | { |
2296 | 2422 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
2297 | - if (file_exists($include)) |
|
2298 | - require_once($include); |
|
2423 | + if (file_exists($include)) { |
|
2424 | + require_once($include); |
|
2425 | + } |
|
2299 | 2426 | } |
2300 | 2427 | } |
2301 | 2428 | |
@@ -2325,16 +2452,19 @@ discard block |
||
2325 | 2452 | // Do any style sheets first, cause we're easy with those. |
2326 | 2453 | if (!empty($style_sheets)) |
2327 | 2454 | { |
2328 | - if (!is_array($style_sheets)) |
|
2329 | - $style_sheets = array($style_sheets); |
|
2455 | + if (!is_array($style_sheets)) { |
|
2456 | + $style_sheets = array($style_sheets); |
|
2457 | + } |
|
2330 | 2458 | |
2331 | - foreach ($style_sheets as $sheet) |
|
2332 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
2459 | + foreach ($style_sheets as $sheet) { |
|
2460 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
2461 | + } |
|
2333 | 2462 | } |
2334 | 2463 | |
2335 | 2464 | // No template to load? |
2336 | - if ($template_name === false) |
|
2337 | - return true; |
|
2465 | + if ($template_name === false) { |
|
2466 | + return true; |
|
2467 | + } |
|
2338 | 2468 | |
2339 | 2469 | $loaded = false; |
2340 | 2470 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2349,12 +2479,14 @@ discard block |
||
2349 | 2479 | |
2350 | 2480 | if ($loaded) |
2351 | 2481 | { |
2352 | - if ($db_show_debug === true) |
|
2353 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2482 | + if ($db_show_debug === true) { |
|
2483 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2484 | + } |
|
2354 | 2485 | |
2355 | 2486 | // If they have specified an initialization function for this template, go ahead and call it now. |
2356 | - if (function_exists('template_' . $template_name . '_init')) |
|
2357 | - call_user_func('template_' . $template_name . '_init'); |
|
2487 | + if (function_exists('template_' . $template_name . '_init')) { |
|
2488 | + call_user_func('template_' . $template_name . '_init'); |
|
2489 | + } |
|
2358 | 2490 | } |
2359 | 2491 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
2360 | 2492 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2374,13 +2506,14 @@ discard block |
||
2374 | 2506 | loadTemplate($template_name); |
2375 | 2507 | } |
2376 | 2508 | // Cause an error otherwise. |
2377 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
2378 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2379 | - elseif ($fatal) |
|
2380 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
2381 | - else |
|
2382 | - return false; |
|
2383 | -} |
|
2509 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
2510 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2511 | + } elseif ($fatal) { |
|
2512 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
2513 | + } else { |
|
2514 | + return false; |
|
2515 | + } |
|
2516 | + } |
|
2384 | 2517 | |
2385 | 2518 | /** |
2386 | 2519 | * Load a sub-template. |
@@ -2398,17 +2531,19 @@ discard block |
||
2398 | 2531 | { |
2399 | 2532 | global $context, $txt, $db_show_debug; |
2400 | 2533 | |
2401 | - if ($db_show_debug === true) |
|
2402 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
2534 | + if ($db_show_debug === true) { |
|
2535 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
2536 | + } |
|
2403 | 2537 | |
2404 | 2538 | // Figure out what the template function is named. |
2405 | 2539 | $theme_function = 'template_' . $sub_template_name; |
2406 | - if (function_exists($theme_function)) |
|
2407 | - $theme_function(); |
|
2408 | - elseif ($fatal === false) |
|
2409 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2410 | - elseif ($fatal !== 'ignore') |
|
2411 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
2540 | + if (function_exists($theme_function)) { |
|
2541 | + $theme_function(); |
|
2542 | + } elseif ($fatal === false) { |
|
2543 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2544 | + } elseif ($fatal !== 'ignore') { |
|
2545 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
2546 | + } |
|
2412 | 2547 | |
2413 | 2548 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
2414 | 2549 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2445,8 +2580,9 @@ discard block |
||
2445 | 2580 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2446 | 2581 | |
2447 | 2582 | // If this is an external file, automatically set this to false. |
2448 | - if (!empty($params['external'])) |
|
2449 | - $params['minimize'] = false; |
|
2583 | + if (!empty($params['external'])) { |
|
2584 | + $params['minimize'] = false; |
|
2585 | + } |
|
2450 | 2586 | |
2451 | 2587 | // Account for shorthand like admin.css?alp21 filenames |
2452 | 2588 | $has_seed = strpos($fileName, '.css?'); |
@@ -2463,13 +2599,10 @@ discard block |
||
2463 | 2599 | { |
2464 | 2600 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2465 | 2601 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2602 | + } else { |
|
2603 | + $fileUrl = false; |
|
2466 | 2604 | } |
2467 | - |
|
2468 | - else |
|
2469 | - $fileUrl = false; |
|
2470 | - } |
|
2471 | - |
|
2472 | - else |
|
2605 | + } else |
|
2473 | 2606 | { |
2474 | 2607 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2475 | 2608 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2484,12 +2617,14 @@ discard block |
||
2484 | 2617 | } |
2485 | 2618 | |
2486 | 2619 | // Add it to the array for use in the template |
2487 | - if (!empty($fileName)) |
|
2488 | - $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2620 | + if (!empty($fileName)) { |
|
2621 | + $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2622 | + } |
|
2489 | 2623 | |
2490 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
2491 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2492 | -} |
|
2624 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
2625 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2626 | + } |
|
2627 | + } |
|
2493 | 2628 | |
2494 | 2629 | /** |
2495 | 2630 | * Add a block of inline css code to be executed later |
@@ -2506,8 +2641,9 @@ discard block |
||
2506 | 2641 | global $context; |
2507 | 2642 | |
2508 | 2643 | // Gotta add something... |
2509 | - if (empty($css)) |
|
2510 | - return false; |
|
2644 | + if (empty($css)) { |
|
2645 | + return false; |
|
2646 | + } |
|
2511 | 2647 | |
2512 | 2648 | $context['css_header'][] = $css; |
2513 | 2649 | } |
@@ -2542,8 +2678,9 @@ discard block |
||
2542 | 2678 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2543 | 2679 | |
2544 | 2680 | // If this is an external file, automatically set this to false. |
2545 | - if (!empty($params['external'])) |
|
2546 | - $params['minimize'] = false; |
|
2681 | + if (!empty($params['external'])) { |
|
2682 | + $params['minimize'] = false; |
|
2683 | + } |
|
2547 | 2684 | |
2548 | 2685 | // Account for shorthand like admin.js?alp21 filenames |
2549 | 2686 | $has_seed = strpos($fileName, '.js?'); |
@@ -2560,16 +2697,12 @@ discard block |
||
2560 | 2697 | { |
2561 | 2698 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2562 | 2699 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2563 | - } |
|
2564 | - |
|
2565 | - else |
|
2700 | + } else |
|
2566 | 2701 | { |
2567 | 2702 | $fileUrl = false; |
2568 | 2703 | $filePath = false; |
2569 | 2704 | } |
2570 | - } |
|
2571 | - |
|
2572 | - else |
|
2705 | + } else |
|
2573 | 2706 | { |
2574 | 2707 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2575 | 2708 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2584,9 +2717,10 @@ discard block |
||
2584 | 2717 | } |
2585 | 2718 | |
2586 | 2719 | // Add it to the array for use in the template |
2587 | - if (!empty($fileName)) |
|
2588 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2589 | -} |
|
2720 | + if (!empty($fileName)) { |
|
2721 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2722 | + } |
|
2723 | + } |
|
2590 | 2724 | |
2591 | 2725 | /** |
2592 | 2726 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2600,9 +2734,10 @@ discard block |
||
2600 | 2734 | { |
2601 | 2735 | global $context; |
2602 | 2736 | |
2603 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
2604 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2605 | -} |
|
2737 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
2738 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2739 | + } |
|
2740 | + } |
|
2606 | 2741 | |
2607 | 2742 | /** |
2608 | 2743 | * Add a block of inline Javascript code to be executed later |
@@ -2619,8 +2754,9 @@ discard block |
||
2619 | 2754 | { |
2620 | 2755 | global $context; |
2621 | 2756 | |
2622 | - if (empty($javascript)) |
|
2623 | - return false; |
|
2757 | + if (empty($javascript)) { |
|
2758 | + return false; |
|
2759 | + } |
|
2624 | 2760 | |
2625 | 2761 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
2626 | 2762 | } |
@@ -2641,15 +2777,18 @@ discard block |
||
2641 | 2777 | static $already_loaded = array(); |
2642 | 2778 | |
2643 | 2779 | // Default to the user's language. |
2644 | - if ($lang == '') |
|
2645 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2780 | + if ($lang == '') { |
|
2781 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2782 | + } |
|
2646 | 2783 | |
2647 | 2784 | // Do we want the English version of language file as fallback? |
2648 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
2649 | - loadLanguage($template_name, 'english', false); |
|
2785 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
2786 | + loadLanguage($template_name, 'english', false); |
|
2787 | + } |
|
2650 | 2788 | |
2651 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
2652 | - return $lang; |
|
2789 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
2790 | + return $lang; |
|
2791 | + } |
|
2653 | 2792 | |
2654 | 2793 | // Make sure we have $settings - if not we're in trouble and need to find it! |
2655 | 2794 | if (empty($settings['default_theme_dir'])) |
@@ -2660,8 +2799,9 @@ discard block |
||
2660 | 2799 | |
2661 | 2800 | // What theme are we in? |
2662 | 2801 | $theme_name = basename($settings['theme_url']); |
2663 | - if (empty($theme_name)) |
|
2664 | - $theme_name = 'unknown'; |
|
2802 | + if (empty($theme_name)) { |
|
2803 | + $theme_name = 'unknown'; |
|
2804 | + } |
|
2665 | 2805 | |
2666 | 2806 | // For each file open it up and write it out! |
2667 | 2807 | foreach (explode('+', $template_name) as $template) |
@@ -2703,8 +2843,9 @@ discard block |
||
2703 | 2843 | $found = true; |
2704 | 2844 | |
2705 | 2845 | // setlocale is required for basename() & pathinfo() to work properly on the selected language |
2706 | - if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) |
|
2707 | - setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2846 | + if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) { |
|
2847 | + setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2848 | + } |
|
2708 | 2849 | |
2709 | 2850 | break; |
2710 | 2851 | } |
@@ -2744,8 +2885,9 @@ discard block |
||
2744 | 2885 | } |
2745 | 2886 | |
2746 | 2887 | // Keep track of what we're up to soldier. |
2747 | - if ($db_show_debug === true) |
|
2748 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2888 | + if ($db_show_debug === true) { |
|
2889 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2890 | + } |
|
2749 | 2891 | |
2750 | 2892 | // Remember what we have loaded, and in which language. |
2751 | 2893 | $already_loaded[$template_name] = $lang; |
@@ -2791,8 +2933,9 @@ discard block |
||
2791 | 2933 | ) |
2792 | 2934 | ); |
2793 | 2935 | // In the EXTREMELY unlikely event this happens, give an error message. |
2794 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
2795 | - fatal_lang_error('parent_not_found', 'critical'); |
|
2936 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
2937 | + fatal_lang_error('parent_not_found', 'critical'); |
|
2938 | + } |
|
2796 | 2939 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2797 | 2940 | { |
2798 | 2941 | if (!isset($boards[$row['id_board']])) |
@@ -2809,8 +2952,8 @@ discard block |
||
2809 | 2952 | ); |
2810 | 2953 | } |
2811 | 2954 | // If a moderator exists for this board, add that moderator for all children too. |
2812 | - if (!empty($row['id_moderator'])) |
|
2813 | - foreach ($boards as $id => $dummy) |
|
2955 | + if (!empty($row['id_moderator'])) { |
|
2956 | + foreach ($boards as $id => $dummy) |
|
2814 | 2957 | { |
2815 | 2958 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
2816 | 2959 | 'id' => $row['id_moderator'], |
@@ -2818,11 +2961,12 @@ discard block |
||
2818 | 2961 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
2819 | 2962 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
2820 | 2963 | ); |
2964 | + } |
|
2821 | 2965 | } |
2822 | 2966 | |
2823 | 2967 | // If a moderator group exists for this board, add that moderator group for all children too |
2824 | - if (!empty($row['id_moderator_group'])) |
|
2825 | - foreach ($boards as $id => $dummy) |
|
2968 | + if (!empty($row['id_moderator_group'])) { |
|
2969 | + foreach ($boards as $id => $dummy) |
|
2826 | 2970 | { |
2827 | 2971 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
2828 | 2972 | 'id' => $row['id_moderator_group'], |
@@ -2830,6 +2974,7 @@ discard block |
||
2830 | 2974 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
2831 | 2975 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
2832 | 2976 | ); |
2977 | + } |
|
2833 | 2978 | } |
2834 | 2979 | } |
2835 | 2980 | $smcFunc['db_free_result']($result); |
@@ -2856,23 +3001,27 @@ discard block |
||
2856 | 3001 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
2857 | 3002 | { |
2858 | 3003 | // If we don't have our ucwords function defined yet, let's load the settings data. |
2859 | - if (empty($smcFunc['ucwords'])) |
|
2860 | - reloadSettings(); |
|
3004 | + if (empty($smcFunc['ucwords'])) { |
|
3005 | + reloadSettings(); |
|
3006 | + } |
|
2861 | 3007 | |
2862 | 3008 | // If we don't have our theme information yet, let's get it. |
2863 | - if (empty($settings['default_theme_dir'])) |
|
2864 | - loadTheme(0, false); |
|
3009 | + if (empty($settings['default_theme_dir'])) { |
|
3010 | + loadTheme(0, false); |
|
3011 | + } |
|
2865 | 3012 | |
2866 | 3013 | // Default language directories to try. |
2867 | 3014 | $language_directories = array( |
2868 | 3015 | $settings['default_theme_dir'] . '/languages', |
2869 | 3016 | ); |
2870 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
2871 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
3017 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
3018 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
3019 | + } |
|
2872 | 3020 | |
2873 | 3021 | // We possibly have a base theme directory. |
2874 | - if (!empty($settings['base_theme_dir'])) |
|
2875 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
3022 | + if (!empty($settings['base_theme_dir'])) { |
|
3023 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
3024 | + } |
|
2876 | 3025 | |
2877 | 3026 | // Remove any duplicates. |
2878 | 3027 | $language_directories = array_unique($language_directories); |
@@ -2886,20 +3035,21 @@ discard block |
||
2886 | 3035 | foreach ($language_directories as $language_dir) |
2887 | 3036 | { |
2888 | 3037 | // Can't look in here... doesn't exist! |
2889 | - if (!file_exists($language_dir)) |
|
2890 | - continue; |
|
3038 | + if (!file_exists($language_dir)) { |
|
3039 | + continue; |
|
3040 | + } |
|
2891 | 3041 | |
2892 | 3042 | $dir = dir($language_dir); |
2893 | 3043 | while ($entry = $dir->read()) |
2894 | 3044 | { |
2895 | 3045 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
2896 | - if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) |
|
2897 | - continue; |
|
2898 | - |
|
2899 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
2900 | - $langName = $langList[$matches[1]]; |
|
3046 | + if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) { |
|
3047 | + continue; |
|
3048 | + } |
|
2901 | 3049 | |
2902 | - else |
|
3050 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
3051 | + $langName = $langList[$matches[1]]; |
|
3052 | + } else |
|
2903 | 3053 | { |
2904 | 3054 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
2905 | 3055 | |
@@ -2940,12 +3090,14 @@ discard block |
||
2940 | 3090 | } |
2941 | 3091 | |
2942 | 3092 | // Do we need to store the lang list? |
2943 | - if (empty($langList)) |
|
2944 | - updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3093 | + if (empty($langList)) { |
|
3094 | + updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3095 | + } |
|
2945 | 3096 | |
2946 | 3097 | // Let's cash in on this deal. |
2947 | - if (!empty($modSettings['cache_enable'])) |
|
2948 | - cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3098 | + if (!empty($modSettings['cache_enable'])) { |
|
3099 | + cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3100 | + } |
|
2949 | 3101 | } |
2950 | 3102 | |
2951 | 3103 | return $context['languages']; |
@@ -2968,8 +3120,9 @@ discard block |
||
2968 | 3120 | global $modSettings, $options, $txt; |
2969 | 3121 | static $censor_vulgar = null, $censor_proper; |
2970 | 3122 | |
2971 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
2972 | - return $text; |
|
3123 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
3124 | + return $text; |
|
3125 | + } |
|
2973 | 3126 | |
2974 | 3127 | // If they haven't yet been loaded, load them. |
2975 | 3128 | if ($censor_vulgar == null) |
@@ -2997,9 +3150,9 @@ discard block |
||
2997 | 3150 | { |
2998 | 3151 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
2999 | 3152 | $text = $func($censor_vulgar, $censor_proper, $text); |
3153 | + } else { |
|
3154 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
3000 | 3155 | } |
3001 | - else |
|
3002 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
3003 | 3156 | |
3004 | 3157 | return $text; |
3005 | 3158 | } |
@@ -3025,38 +3178,42 @@ discard block |
||
3025 | 3178 | @ini_set('track_errors', '1'); |
3026 | 3179 | |
3027 | 3180 | // Don't include the file more than once, if $once is true. |
3028 | - if ($once && in_array($filename, $templates)) |
|
3029 | - return; |
|
3181 | + if ($once && in_array($filename, $templates)) { |
|
3182 | + return; |
|
3183 | + } |
|
3030 | 3184 | // Add this file to the include list, whether $once is true or not. |
3031 | - else |
|
3032 | - $templates[] = $filename; |
|
3185 | + else { |
|
3186 | + $templates[] = $filename; |
|
3187 | + } |
|
3033 | 3188 | |
3034 | 3189 | // Are we going to use eval? |
3035 | 3190 | if (empty($modSettings['disableTemplateEval'])) |
3036 | 3191 | { |
3037 | 3192 | $file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false; |
3038 | 3193 | $settings['current_include_filename'] = $filename; |
3039 | - } |
|
3040 | - else |
|
3194 | + } else |
|
3041 | 3195 | { |
3042 | 3196 | $file_found = file_exists($filename); |
3043 | 3197 | |
3044 | - if ($once && $file_found) |
|
3045 | - require_once($filename); |
|
3046 | - elseif ($file_found) |
|
3047 | - require($filename); |
|
3198 | + if ($once && $file_found) { |
|
3199 | + require_once($filename); |
|
3200 | + } elseif ($file_found) { |
|
3201 | + require($filename); |
|
3202 | + } |
|
3048 | 3203 | } |
3049 | 3204 | |
3050 | 3205 | if ($file_found !== true) |
3051 | 3206 | { |
3052 | 3207 | ob_end_clean(); |
3053 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
3054 | - @ob_start('ob_gzhandler'); |
|
3055 | - else |
|
3056 | - ob_start(); |
|
3208 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
3209 | + @ob_start('ob_gzhandler'); |
|
3210 | + } else { |
|
3211 | + ob_start(); |
|
3212 | + } |
|
3057 | 3213 | |
3058 | - if (isset($_GET['debug'])) |
|
3059 | - header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3214 | + if (isset($_GET['debug'])) { |
|
3215 | + header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3216 | + } |
|
3060 | 3217 | |
3061 | 3218 | // Don't cache error pages!! |
3062 | 3219 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3075,12 +3232,13 @@ discard block |
||
3075 | 3232 | echo '<!DOCTYPE html> |
3076 | 3233 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
3077 | 3234 | <head>'; |
3078 | - if (isset($context['character_set'])) |
|
3079 | - echo ' |
|
3235 | + if (isset($context['character_set'])) { |
|
3236 | + echo ' |
|
3080 | 3237 | <meta charset="', $context['character_set'], '">'; |
3238 | + } |
|
3081 | 3239 | |
3082 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
3083 | - echo ' |
|
3240 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
3241 | + echo ' |
|
3084 | 3242 | <title>', $mtitle, '</title> |
3085 | 3243 | </head> |
3086 | 3244 | <body> |
@@ -3088,8 +3246,8 @@ discard block |
||
3088 | 3246 | ', $mmessage, ' |
3089 | 3247 | </body> |
3090 | 3248 | </html>'; |
3091 | - elseif (!allowedTo('admin_forum')) |
|
3092 | - echo ' |
|
3249 | + } elseif (!allowedTo('admin_forum')) { |
|
3250 | + echo ' |
|
3093 | 3251 | <title>', $txt['template_parse_error'], '</title> |
3094 | 3252 | </head> |
3095 | 3253 | <body> |
@@ -3097,16 +3255,18 @@ discard block |
||
3097 | 3255 | ', $txt['template_parse_error_message'], ' |
3098 | 3256 | </body> |
3099 | 3257 | </html>'; |
3100 | - else |
|
3258 | + } else |
|
3101 | 3259 | { |
3102 | 3260 | require_once($sourcedir . '/Subs-Package.php'); |
3103 | 3261 | |
3104 | 3262 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3105 | 3263 | $error_array = error_get_last(); |
3106 | - if (empty($error) && ini_get('track_errors') && !empty($error_array)) |
|
3107 | - $error = $error_array['message']; |
|
3108 | - if (empty($error)) |
|
3109 | - $error = $txt['template_parse_errmsg']; |
|
3264 | + if (empty($error) && ini_get('track_errors') && !empty($error_array)) { |
|
3265 | + $error = $error_array['message']; |
|
3266 | + } |
|
3267 | + if (empty($error)) { |
|
3268 | + $error = $txt['template_parse_errmsg']; |
|
3269 | + } |
|
3110 | 3270 | |
3111 | 3271 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
3112 | 3272 | |
@@ -3117,11 +3277,12 @@ discard block |
||
3117 | 3277 | <h3>', $txt['template_parse_error'], '</h3> |
3118 | 3278 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3119 | 3279 | |
3120 | - if (!empty($error)) |
|
3121 | - echo ' |
|
3280 | + if (!empty($error)) { |
|
3281 | + echo ' |
|
3122 | 3282 | <hr> |
3123 | 3283 | |
3124 | 3284 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
3285 | + } |
|
3125 | 3286 | |
3126 | 3287 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
3127 | 3288 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3131,10 +3292,11 @@ discard block |
||
3131 | 3292 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
3132 | 3293 | |
3133 | 3294 | // Fix the PHP code stuff... |
3134 | - if (!isBrowser('gecko')) |
|
3135 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3136 | - else |
|
3137 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3295 | + if (!isBrowser('gecko')) { |
|
3296 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3297 | + } else { |
|
3298 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3299 | + } |
|
3138 | 3300 | |
3139 | 3301 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
3140 | 3302 | $j = -1; |
@@ -3142,8 +3304,9 @@ discard block |
||
3142 | 3304 | { |
3143 | 3305 | $j++; |
3144 | 3306 | |
3145 | - if (substr_count($line, '<br>') == 0) |
|
3146 | - continue; |
|
3307 | + if (substr_count($line, '<br>') == 0) { |
|
3308 | + continue; |
|
3309 | + } |
|
3147 | 3310 | |
3148 | 3311 | $n = substr_count($line, '<br>'); |
3149 | 3312 | for ($i = 0; $i < $n; $i++) |
@@ -3162,38 +3325,42 @@ discard block |
||
3162 | 3325 | // Figure out what the color coding was before... |
3163 | 3326 | $line = max($match[1] - 9, 1); |
3164 | 3327 | $last_line = ''; |
3165 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
3166 | - if (strpos($data2[$line2], '<') !== false) |
|
3328 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
3329 | + if (strpos($data2[$line2], '<') !== false) |
|
3167 | 3330 | { |
3168 | 3331 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
3169 | 3332 | $last_line = $color_match[1]; |
3333 | + } |
|
3170 | 3334 | break; |
3171 | 3335 | } |
3172 | 3336 | |
3173 | 3337 | // Show the relevant lines... |
3174 | 3338 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
3175 | 3339 | { |
3176 | - if ($line == $match[1]) |
|
3177 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3340 | + if ($line == $match[1]) { |
|
3341 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3342 | + } |
|
3178 | 3343 | |
3179 | 3344 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
3180 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
3181 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3345 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
3346 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3347 | + } |
|
3182 | 3348 | |
3183 | 3349 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
3184 | 3350 | { |
3185 | 3351 | $last_line = $color_match[1]; |
3186 | 3352 | echo '</', substr($last_line, 1, 4), '>'; |
3353 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
3354 | + $last_line = ''; |
|
3355 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
3356 | + echo '</', substr($last_line, 1, 4), '>'; |
|
3187 | 3357 | } |
3188 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
3189 | - $last_line = ''; |
|
3190 | - elseif ($last_line != '' && $data2[$line] != '') |
|
3191 | - echo '</', substr($last_line, 1, 4), '>'; |
|
3192 | 3358 | |
3193 | - if ($line == $match[1]) |
|
3194 | - echo '</pre></div><pre style="margin: 0;">'; |
|
3195 | - else |
|
3196 | - echo "\n"; |
|
3359 | + if ($line == $match[1]) { |
|
3360 | + echo '</pre></div><pre style="margin: 0;">'; |
|
3361 | + } else { |
|
3362 | + echo "\n"; |
|
3363 | + } |
|
3197 | 3364 | } |
3198 | 3365 | |
3199 | 3366 | echo '</pre></div>'; |
@@ -3217,8 +3384,9 @@ discard block |
||
3217 | 3384 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port; |
3218 | 3385 | |
3219 | 3386 | // Figure out what type of database we are using. |
3220 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
3221 | - $db_type = 'mysql'; |
|
3387 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
3388 | + $db_type = 'mysql'; |
|
3389 | + } |
|
3222 | 3390 | |
3223 | 3391 | // Load the file for the database. |
3224 | 3392 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3226,8 +3394,9 @@ discard block |
||
3226 | 3394 | $db_options = array(); |
3227 | 3395 | |
3228 | 3396 | // Add in the port if needed |
3229 | - if (!empty($db_port)) |
|
3230 | - $db_options['port'] = $db_port; |
|
3397 | + if (!empty($db_port)) { |
|
3398 | + $db_options['port'] = $db_port; |
|
3399 | + } |
|
3231 | 3400 | |
3232 | 3401 | // If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use. |
3233 | 3402 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3246,13 +3415,15 @@ discard block |
||
3246 | 3415 | } |
3247 | 3416 | |
3248 | 3417 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
3249 | - if (!$db_connection) |
|
3250 | - display_db_error(); |
|
3418 | + if (!$db_connection) { |
|
3419 | + display_db_error(); |
|
3420 | + } |
|
3251 | 3421 | |
3252 | 3422 | // If in SSI mode fix up the prefix. |
3253 | - if (SMF == 'SSI') |
|
3254 | - db_fix_prefix($db_prefix, $db_name); |
|
3255 | -} |
|
3423 | + if (SMF == 'SSI') { |
|
3424 | + db_fix_prefix($db_prefix, $db_name); |
|
3425 | + } |
|
3426 | + } |
|
3256 | 3427 | |
3257 | 3428 | /** |
3258 | 3429 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3266,10 +3437,11 @@ discard block |
||
3266 | 3437 | global $sourcedir, $cacheAPI, $cache_accelerator; |
3267 | 3438 | |
3268 | 3439 | // Not overriding this and we have a cacheAPI, send it back. |
3269 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
3270 | - return $cacheAPI; |
|
3271 | - elseif (is_null($cacheAPI)) |
|
3272 | - $cacheAPI = false; |
|
3440 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
3441 | + return $cacheAPI; |
|
3442 | + } elseif (is_null($cacheAPI)) { |
|
3443 | + $cacheAPI = false; |
|
3444 | + } |
|
3273 | 3445 | |
3274 | 3446 | // Make sure our class is in session. |
3275 | 3447 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3290,8 +3462,9 @@ discard block |
||
3290 | 3462 | if (!$testAPI->isSupported()) |
3291 | 3463 | { |
3292 | 3464 | // Can we save ourselves? |
3293 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
3294 | - return loadCacheAccelerator(null, false); |
|
3465 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
3466 | + return loadCacheAccelerator(null, false); |
|
3467 | + } |
|
3295 | 3468 | return false; |
3296 | 3469 | } |
3297 | 3470 | |
@@ -3303,9 +3476,9 @@ discard block |
||
3303 | 3476 | { |
3304 | 3477 | $cacheAPI = $testAPI; |
3305 | 3478 | return $cacheAPI; |
3479 | + } else { |
|
3480 | + return $testAPI; |
|
3306 | 3481 | } |
3307 | - else |
|
3308 | - return $testAPI; |
|
3309 | 3482 | } |
3310 | 3483 | } |
3311 | 3484 | |
@@ -3325,8 +3498,9 @@ discard block |
||
3325 | 3498 | |
3326 | 3499 | // @todo Why are we doing this if caching is disabled? |
3327 | 3500 | |
3328 | - if (function_exists('call_integration_hook')) |
|
3329 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3501 | + if (function_exists('call_integration_hook')) { |
|
3502 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3503 | + } |
|
3330 | 3504 | |
3331 | 3505 | /* Refresh the cache if either: |
3332 | 3506 | 1. Caching is disabled. |
@@ -3340,16 +3514,19 @@ discard block |
||
3340 | 3514 | require_once($sourcedir . '/' . $file); |
3341 | 3515 | $cache_block = call_user_func_array($function, $params); |
3342 | 3516 | |
3343 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
3344 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3517 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
3518 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3519 | + } |
|
3345 | 3520 | } |
3346 | 3521 | |
3347 | 3522 | // Some cached data may need a freshening up after retrieval. |
3348 | - if (!empty($cache_block['post_retri_eval'])) |
|
3349 | - eval($cache_block['post_retri_eval']); |
|
3523 | + if (!empty($cache_block['post_retri_eval'])) { |
|
3524 | + eval($cache_block['post_retri_eval']); |
|
3525 | + } |
|
3350 | 3526 | |
3351 | - if (function_exists('call_integration_hook')) |
|
3352 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3527 | + if (function_exists('call_integration_hook')) { |
|
3528 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3529 | + } |
|
3353 | 3530 | |
3354 | 3531 | return $cache_block['data']; |
3355 | 3532 | } |
@@ -3376,8 +3553,9 @@ discard block |
||
3376 | 3553 | global $smcFunc, $cache_enable, $cacheAPI; |
3377 | 3554 | global $cache_hits, $cache_count, $db_show_debug; |
3378 | 3555 | |
3379 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3380 | - return; |
|
3556 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3557 | + return; |
|
3558 | + } |
|
3381 | 3559 | |
3382 | 3560 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3383 | 3561 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3390,12 +3568,14 @@ discard block |
||
3390 | 3568 | $value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value)); |
3391 | 3569 | $cacheAPI->putData($key, $value, $ttl); |
3392 | 3570 | |
3393 | - if (function_exists('call_integration_hook')) |
|
3394 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3571 | + if (function_exists('call_integration_hook')) { |
|
3572 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3573 | + } |
|
3395 | 3574 | |
3396 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
3397 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3398 | -} |
|
3575 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3576 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3577 | + } |
|
3578 | + } |
|
3399 | 3579 | |
3400 | 3580 | /** |
3401 | 3581 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3411,8 +3591,9 @@ discard block |
||
3411 | 3591 | global $smcFunc, $cache_enable, $cacheAPI; |
3412 | 3592 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
3413 | 3593 | |
3414 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3415 | - return; |
|
3594 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3595 | + return; |
|
3596 | + } |
|
3416 | 3597 | |
3417 | 3598 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3418 | 3599 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3432,16 +3613,18 @@ discard block |
||
3432 | 3613 | |
3433 | 3614 | if (empty($value)) |
3434 | 3615 | { |
3435 | - if (!is_array($cache_misses)) |
|
3436 | - $cache_misses = array(); |
|
3616 | + if (!is_array($cache_misses)) { |
|
3617 | + $cache_misses = array(); |
|
3618 | + } |
|
3437 | 3619 | |
3438 | 3620 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
3439 | 3621 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
3440 | 3622 | } |
3441 | 3623 | } |
3442 | 3624 | |
3443 | - if (function_exists('call_integration_hook') && isset($value)) |
|
3444 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3625 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
3626 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3627 | + } |
|
3445 | 3628 | |
3446 | 3629 | return empty($value) ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true)); |
3447 | 3630 | } |
@@ -3463,8 +3646,9 @@ discard block |
||
3463 | 3646 | global $cacheAPI; |
3464 | 3647 | |
3465 | 3648 | // If we can't get to the API, can't do this. |
3466 | - if (empty($cacheAPI)) |
|
3467 | - return; |
|
3649 | + if (empty($cacheAPI)) { |
|
3650 | + return; |
|
3651 | + } |
|
3468 | 3652 | |
3469 | 3653 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
3470 | 3654 | $cacheAPI->cleanCache($type); |
@@ -3489,8 +3673,9 @@ discard block |
||
3489 | 3673 | global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $image_proxy_secret; |
3490 | 3674 | |
3491 | 3675 | // Come on! |
3492 | - if (empty($data)) |
|
3493 | - return array(); |
|
3676 | + if (empty($data)) { |
|
3677 | + return array(); |
|
3678 | + } |
|
3494 | 3679 | |
3495 | 3680 | // Set a nice default var. |
3496 | 3681 | $image = ''; |
@@ -3498,11 +3683,11 @@ discard block |
||
3498 | 3683 | // Gravatar has been set as mandatory! |
3499 | 3684 | if (!empty($modSettings['gravatarOverride'])) |
3500 | 3685 | { |
3501 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
3502 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3503 | - |
|
3504 | - else if (!empty($data['email'])) |
|
3505 | - $image = get_gravatar_url($data['email']); |
|
3686 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
3687 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3688 | + } else if (!empty($data['email'])) { |
|
3689 | + $image = get_gravatar_url($data['email']); |
|
3690 | + } |
|
3506 | 3691 | } |
3507 | 3692 | |
3508 | 3693 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3514,54 +3699,60 @@ discard block |
||
3514 | 3699 | // Gravatar. |
3515 | 3700 | if (stristr($data['avatar'], 'gravatar://')) |
3516 | 3701 | { |
3517 | - if ($data['avatar'] == 'gravatar://') |
|
3518 | - $image = get_gravatar_url($data['email']); |
|
3519 | - |
|
3520 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
3521 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3702 | + if ($data['avatar'] == 'gravatar://') { |
|
3703 | + $image = get_gravatar_url($data['email']); |
|
3704 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
3705 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3706 | + } |
|
3522 | 3707 | } |
3523 | 3708 | |
3524 | 3709 | // External url. |
3525 | 3710 | else |
3526 | 3711 | { |
3527 | 3712 | // Using ssl? |
3528 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) |
|
3529 | - $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
3713 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) { |
|
3714 | + $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
3715 | + } |
|
3530 | 3716 | |
3531 | 3717 | // Just a plain external url. |
3532 | - else |
|
3533 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3718 | + else { |
|
3719 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3720 | + } |
|
3534 | 3721 | } |
3535 | 3722 | } |
3536 | 3723 | |
3537 | 3724 | // Perhaps this user has an attachment as avatar... |
3538 | - else if (!empty($data['filename'])) |
|
3539 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3725 | + else if (!empty($data['filename'])) { |
|
3726 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3727 | + } |
|
3540 | 3728 | |
3541 | 3729 | // Right... no avatar... use our default image. |
3542 | - else |
|
3543 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
3730 | + else { |
|
3731 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
3732 | + } |
|
3544 | 3733 | } |
3545 | 3734 | |
3546 | 3735 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
3547 | 3736 | |
3548 | 3737 | // At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed. |
3549 | - if (!empty($image)) |
|
3550 | - return array( |
|
3738 | + if (!empty($image)) { |
|
3739 | + return array( |
|
3551 | 3740 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
3552 | 3741 | 'image' => '<img class="avatar" src="' . $image . '" />', |
3553 | 3742 | 'href' => $image, |
3554 | 3743 | 'url' => $image, |
3555 | 3744 | ); |
3745 | + } |
|
3556 | 3746 | |
3557 | 3747 | // Fallback to make life easier for everyone... |
3558 | - else |
|
3559 | - return array( |
|
3748 | + else { |
|
3749 | + return array( |
|
3560 | 3750 | 'name' => '', |
3561 | 3751 | 'image' => '', |
3562 | 3752 | 'href' => '', |
3563 | 3753 | 'url' => '', |
3564 | 3754 | ); |
3565 | -} |
|
3755 | + } |
|
3756 | + } |
|
3566 | 3757 | |
3567 | 3758 | ?> |
3568 | 3759 | \ No newline at end of file |
@@ -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'] == 'None') |
|
1456 | - unset($context['custom_pf']['cust_gender']); |
|
1527 | + if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'None') { |
|
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 |