@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 3 |
| 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. |
@@ -30,18 +31,21 @@ discard block |
||
| 30 | 31 | global $smcFunc; |
| 31 | 32 | |
| 32 | 33 | // Don't reload this as we may have processed error strings. |
| 33 | - if (empty($post_errors)) |
|
| 34 | - loadLanguage('Profile+Drafts'); |
|
| 34 | + if (empty($post_errors)) { |
|
| 35 | + loadLanguage('Profile+Drafts'); |
|
| 36 | + } |
|
| 35 | 37 | loadTemplate('Profile'); |
| 36 | 38 | |
| 37 | 39 | require_once($sourcedir . '/Subs-Menu.php'); |
| 38 | 40 | |
| 39 | 41 | // Did we get the user by name... |
| 40 | - if (isset($_REQUEST['user'])) |
|
| 41 | - $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
| 42 | + if (isset($_REQUEST['user'])) { |
|
| 43 | + $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
| 44 | + } |
|
| 42 | 45 | // ... or by id_member? |
| 43 | - elseif (!empty($_REQUEST['u'])) |
|
| 44 | - $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
| 46 | + elseif (!empty($_REQUEST['u'])) { |
|
| 47 | + $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
| 48 | + } |
|
| 45 | 49 | // If it was just ?action=profile, edit your own profile, but only if you're not a guest. |
| 46 | 50 | else |
| 47 | 51 | { |
@@ -51,8 +55,9 @@ discard block |
||
| 51 | 55 | } |
| 52 | 56 | |
| 53 | 57 | // Check if loadMemberData() has returned a valid result. |
| 54 | - if (!$memberResult) |
|
| 55 | - fatal_lang_error('not_a_user', false, 404); |
|
| 58 | + if (!$memberResult) { |
|
| 59 | + fatal_lang_error('not_a_user', false, 404); |
|
| 60 | + } |
|
| 56 | 61 | |
| 57 | 62 | // If all went well, we have a valid member ID! |
| 58 | 63 | list ($memID) = $memberResult; |
@@ -68,8 +73,9 @@ discard block |
||
| 68 | 73 | |
| 69 | 74 | // Group management isn't actually a permission. But we need it to be for this, so we need a phantom permission. |
| 70 | 75 | // And we care about what the current user can do, not what the user whose profile it is. |
| 71 | - if ($user_info['mod_cache']['gq'] != '0=1') |
|
| 72 | - $user_info['permissions'][] = 'approve_group_requests'; |
|
| 76 | + if ($user_info['mod_cache']['gq'] != '0=1') { |
|
| 77 | + $user_info['permissions'][] = 'approve_group_requests'; |
|
| 78 | + } |
|
| 73 | 79 | |
| 74 | 80 | // If paid subscriptions are enabled, make sure we actually have at least one subscription available... |
| 75 | 81 | $context['subs_available'] = false; |
@@ -437,21 +443,25 @@ discard block |
||
| 437 | 443 | foreach ($section['areas'] as $area_id => $area) |
| 438 | 444 | { |
| 439 | 445 | // If it said no permissions that meant it wasn't valid! |
| 440 | - if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) |
|
| 441 | - $profile_areas[$section_id]['areas'][$area_id]['enabled'] = false; |
|
| 446 | + if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) { |
|
| 447 | + $profile_areas[$section_id]['areas'][$area_id]['enabled'] = false; |
|
| 448 | + } |
|
| 442 | 449 | // Otherwise pick the right set. |
| 443 | - else |
|
| 444 | - $profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any']; |
|
| 450 | + else { |
|
| 451 | + $profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any']; |
|
| 452 | + } |
|
| 445 | 453 | |
| 446 | 454 | // Password required in most cases |
| 447 | - if (!empty($area['password'])) |
|
| 448 | - $context['password_areas'][] = $area_id; |
|
| 455 | + if (!empty($area['password'])) { |
|
| 456 | + $context['password_areas'][] = $area_id; |
|
| 457 | + } |
|
| 449 | 458 | } |
| 450 | 459 | } |
| 451 | 460 | |
| 452 | 461 | // Is there an updated message to show? |
| 453 | - if (isset($_GET['updated'])) |
|
| 454 | - $context['profile_updated'] = $txt['profile_updated_own']; |
|
| 462 | + if (isset($_GET['updated'])) { |
|
| 463 | + $context['profile_updated'] = $txt['profile_updated_own']; |
|
| 464 | + } |
|
| 455 | 465 | |
| 456 | 466 | // Set a few options for the menu. |
| 457 | 467 | $menuOptions = array( |
@@ -466,8 +476,9 @@ discard block |
||
| 466 | 476 | $profile_include_data = createMenu($profile_areas, $menuOptions); |
| 467 | 477 | |
| 468 | 478 | // No menu means no access. |
| 469 | - if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) |
|
| 470 | - fatal_lang_error('no_access', false); |
|
| 479 | + if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) { |
|
| 480 | + fatal_lang_error('no_access', false); |
|
| 481 | + } |
|
| 471 | 482 | |
| 472 | 483 | // Make a note of the Unique ID for this menu. |
| 473 | 484 | $context['profile_menu_id'] = $context['max_menu_id']; |
@@ -493,8 +504,9 @@ discard block |
||
| 493 | 504 | if ($current_area == $area_id) |
| 494 | 505 | { |
| 495 | 506 | // This can't happen - but is a security check. |
| 496 | - if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) |
|
| 497 | - fatal_lang_error('no_access', false); |
|
| 507 | + if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) { |
|
| 508 | + fatal_lang_error('no_access', false); |
|
| 509 | + } |
|
| 498 | 510 | |
| 499 | 511 | // Are we saving data in a valid area? |
| 500 | 512 | if (isset($area['sc']) && (isset($_REQUEST['save']) || $context['do_preview'])) |
@@ -513,12 +525,14 @@ discard block |
||
| 513 | 525 | } |
| 514 | 526 | |
| 515 | 527 | // Does this require session validating? |
| 516 | - if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) |
|
| 517 | - $security_checks['validate'] = true; |
|
| 528 | + if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) { |
|
| 529 | + $security_checks['validate'] = true; |
|
| 530 | + } |
|
| 518 | 531 | |
| 519 | 532 | // Permissions for good measure. |
| 520 | - if (!empty($profile_include_data['permission'])) |
|
| 521 | - $security_checks['permission'] = $profile_include_data['permission']; |
|
| 533 | + if (!empty($profile_include_data['permission'])) { |
|
| 534 | + $security_checks['permission'] = $profile_include_data['permission']; |
|
| 535 | + } |
|
| 522 | 536 | |
| 523 | 537 | // Either way got something. |
| 524 | 538 | $found_area = true; |
@@ -527,21 +541,26 @@ discard block |
||
| 527 | 541 | } |
| 528 | 542 | |
| 529 | 543 | // Oh dear, some serious security lapse is going on here... we'll put a stop to that! |
| 530 | - if (!$found_area) |
|
| 531 | - fatal_lang_error('no_access', false); |
|
| 544 | + if (!$found_area) { |
|
| 545 | + fatal_lang_error('no_access', false); |
|
| 546 | + } |
|
| 532 | 547 | |
| 533 | 548 | // Release this now. |
| 534 | 549 | unset($profile_areas); |
| 535 | 550 | |
| 536 | 551 | // Now the context is setup have we got any security checks to carry out additional to that above? |
| 537 | - if (isset($security_checks['session'])) |
|
| 538 | - checkSession($security_checks['session']); |
|
| 539 | - if (isset($security_checks['validate'])) |
|
| 540 | - validateSession(); |
|
| 541 | - if (isset($security_checks['validateToken'])) |
|
| 542 | - validateToken($token_name, $token_type); |
|
| 543 | - if (isset($security_checks['permission'])) |
|
| 544 | - isAllowedTo($security_checks['permission']); |
|
| 552 | + if (isset($security_checks['session'])) { |
|
| 553 | + checkSession($security_checks['session']); |
|
| 554 | + } |
|
| 555 | + if (isset($security_checks['validate'])) { |
|
| 556 | + validateSession(); |
|
| 557 | + } |
|
| 558 | + if (isset($security_checks['validateToken'])) { |
|
| 559 | + validateToken($token_name, $token_type); |
|
| 560 | + } |
|
| 561 | + if (isset($security_checks['permission'])) { |
|
| 562 | + isAllowedTo($security_checks['permission']); |
|
| 563 | + } |
|
| 545 | 564 | |
| 546 | 565 | // Create a token if needed. |
| 547 | 566 | if (isset($security_checks['needsToken']) || isset($security_checks['validateToken'])) |
@@ -551,8 +570,9 @@ discard block |
||
| 551 | 570 | } |
| 552 | 571 | |
| 553 | 572 | // File to include? |
| 554 | - if (isset($profile_include_data['file'])) |
|
| 555 | - require_once($sourcedir . '/' . $profile_include_data['file']); |
|
| 573 | + if (isset($profile_include_data['file'])) { |
|
| 574 | + require_once($sourcedir . '/' . $profile_include_data['file']); |
|
| 575 | + } |
|
| 556 | 576 | |
| 557 | 577 | // Build the link tree. |
| 558 | 578 | $context['linktree'][] = array( |
@@ -560,17 +580,19 @@ discard block |
||
| 560 | 580 | 'name' => sprintf($txt['profile_of_username'], $context['member']['name']), |
| 561 | 581 | ); |
| 562 | 582 | |
| 563 | - if (!empty($profile_include_data['label'])) |
|
| 564 | - $context['linktree'][] = array( |
|
| 583 | + if (!empty($profile_include_data['label'])) { |
|
| 584 | + $context['linktree'][] = array( |
|
| 565 | 585 | 'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'], |
| 566 | 586 | 'name' => $profile_include_data['label'], |
| 567 | 587 | ); |
| 588 | + } |
|
| 568 | 589 | |
| 569 | - if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) |
|
| 570 | - $context['linktree'][] = array( |
|
| 590 | + if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) { |
|
| 591 | + $context['linktree'][] = array( |
|
| 571 | 592 | 'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'] . ';sa=' . $profile_include_data['current_subsection'], |
| 572 | 593 | 'name' => $profile_include_data['subsections'][$profile_include_data['current_subsection']][0], |
| 573 | 594 | ); |
| 595 | + } |
|
| 574 | 596 | |
| 575 | 597 | // Set the template for this area and add the profile layer. |
| 576 | 598 | $context['sub_template'] = $profile_include_data['function']; |
@@ -596,12 +618,14 @@ discard block |
||
| 596 | 618 | if ($check_password) |
| 597 | 619 | { |
| 598 | 620 | // Check to ensure we're forcing SSL for authentication |
| 599 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 600 | - fatal_lang_error('login_ssl_required'); |
|
| 621 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 622 | + fatal_lang_error('login_ssl_required'); |
|
| 623 | + } |
|
| 601 | 624 | |
| 602 | 625 | // You didn't even enter a password! |
| 603 | - if (trim($_POST['oldpasswrd']) == '') |
|
| 604 | - $post_errors[] = 'no_password'; |
|
| 626 | + if (trim($_POST['oldpasswrd']) == '') { |
|
| 627 | + $post_errors[] = 'no_password'; |
|
| 628 | + } |
|
| 605 | 629 | |
| 606 | 630 | // Since the password got modified due to all the $_POST cleaning, lets undo it so we can get the correct password |
| 607 | 631 | $_POST['oldpasswrd'] = un_htmlspecialchars($_POST['oldpasswrd']); |
@@ -610,33 +634,35 @@ discard block |
||
| 610 | 634 | $good_password = in_array(true, call_integration_hook('integrate_verify_password', array($cur_profile['member_name'], $_POST['oldpasswrd'], false)), true); |
| 611 | 635 | |
| 612 | 636 | // Bad password!!! |
| 613 | - if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) |
|
| 614 | - $post_errors[] = 'bad_password'; |
|
| 637 | + if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) { |
|
| 638 | + $post_errors[] = 'bad_password'; |
|
| 639 | + } |
|
| 615 | 640 | |
| 616 | 641 | // Warn other elements not to jump the gun and do custom changes! |
| 617 | - if (in_array('bad_password', $post_errors)) |
|
| 618 | - $context['password_auth_failed'] = true; |
|
| 642 | + if (in_array('bad_password', $post_errors)) { |
|
| 643 | + $context['password_auth_failed'] = true; |
|
| 644 | + } |
|
| 619 | 645 | } |
| 620 | 646 | |
| 621 | 647 | // Change the IP address in the database. |
| 622 | - if ($context['user']['is_owner']) |
|
| 623 | - $profile_vars['member_ip'] = $user_info['ip']; |
|
| 648 | + if ($context['user']['is_owner']) { |
|
| 649 | + $profile_vars['member_ip'] = $user_info['ip']; |
|
| 650 | + } |
|
| 624 | 651 | |
| 625 | 652 | // Now call the sub-action function... |
| 626 | 653 | if ($current_area == 'activateaccount') |
| 627 | 654 | { |
| 628 | - if (empty($post_errors)) |
|
| 629 | - activateAccount($memID); |
|
| 630 | - } |
|
| 631 | - elseif ($current_area == 'deleteaccount') |
|
| 655 | + if (empty($post_errors)) { |
|
| 656 | + activateAccount($memID); |
|
| 657 | + } |
|
| 658 | + } elseif ($current_area == 'deleteaccount') |
|
| 632 | 659 | { |
| 633 | 660 | if (empty($post_errors)) |
| 634 | 661 | { |
| 635 | 662 | deleteAccount2($memID); |
| 636 | 663 | redirectexit(); |
| 637 | 664 | } |
| 638 | - } |
|
| 639 | - elseif ($current_area == 'groupmembership' && empty($post_errors)) |
|
| 665 | + } elseif ($current_area == 'groupmembership' && empty($post_errors)) |
|
| 640 | 666 | { |
| 641 | 667 | $msg = groupMembership2($profile_vars, $post_errors, $memID); |
| 642 | 668 | |
@@ -647,10 +673,9 @@ discard block |
||
| 647 | 673 | elseif ($current_area == 'authentication') |
| 648 | 674 | { |
| 649 | 675 | authentication($memID, true); |
| 650 | - } |
|
| 651 | - elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) |
|
| 652 | - saveProfileFields(); |
|
| 653 | - else |
|
| 676 | + } elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) { |
|
| 677 | + saveProfileFields(); |
|
| 678 | + } else |
|
| 654 | 679 | { |
| 655 | 680 | $force_redirect = true; |
| 656 | 681 | // Ensure we include this. |
@@ -666,34 +691,36 @@ discard block |
||
| 666 | 691 | // Load the language file so we can give a nice explanation of the errors. |
| 667 | 692 | loadLanguage('Errors'); |
| 668 | 693 | $context['post_errors'] = $post_errors; |
| 669 | - } |
|
| 670 | - elseif (!empty($profile_vars)) |
|
| 694 | + } elseif (!empty($profile_vars)) |
|
| 671 | 695 | { |
| 672 | 696 | // If we've changed the password, notify any integration that may be listening in. |
| 673 | - if (isset($profile_vars['passwd'])) |
|
| 674 | - call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2'])); |
|
| 697 | + if (isset($profile_vars['passwd'])) { |
|
| 698 | + call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2'])); |
|
| 699 | + } |
|
| 675 | 700 | |
| 676 | 701 | updateMemberData($memID, $profile_vars); |
| 677 | 702 | |
| 678 | 703 | // What if this is the newest member? |
| 679 | - if ($modSettings['latestMember'] == $memID) |
|
| 680 | - updateStats('member'); |
|
| 681 | - elseif (isset($profile_vars['real_name'])) |
|
| 682 | - updateSettings(array('memberlist_updated' => time())); |
|
| 704 | + if ($modSettings['latestMember'] == $memID) { |
|
| 705 | + updateStats('member'); |
|
| 706 | + } elseif (isset($profile_vars['real_name'])) { |
|
| 707 | + updateSettings(array('memberlist_updated' => time())); |
|
| 708 | + } |
|
| 683 | 709 | |
| 684 | 710 | // If the member changed his/her birthdate, update calendar statistics. |
| 685 | - if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) |
|
| 686 | - updateSettings(array( |
|
| 711 | + if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) { |
|
| 712 | + updateSettings(array( |
|
| 687 | 713 | 'calendar_updated' => time(), |
| 688 | 714 | )); |
| 715 | + } |
|
| 689 | 716 | |
| 690 | 717 | // Anything worth logging? |
| 691 | 718 | if (!empty($context['log_changes']) && !empty($modSettings['modlog_enabled'])) |
| 692 | 719 | { |
| 693 | 720 | $log_changes = array(); |
| 694 | 721 | require_once($sourcedir . '/Logging.php'); |
| 695 | - foreach ($context['log_changes'] as $k => $v) |
|
| 696 | - $log_changes[] = array( |
|
| 722 | + foreach ($context['log_changes'] as $k => $v) { |
|
| 723 | + $log_changes[] = array( |
|
| 697 | 724 | 'action' => $k, |
| 698 | 725 | 'log_type' => 'user', |
| 699 | 726 | 'extra' => array_merge($v, array( |
@@ -701,14 +728,16 @@ discard block |
||
| 701 | 728 | 'member_affected' => $memID, |
| 702 | 729 | )), |
| 703 | 730 | ); |
| 731 | + } |
|
| 704 | 732 | |
| 705 | 733 | logActions($log_changes); |
| 706 | 734 | } |
| 707 | 735 | |
| 708 | 736 | // Have we got any post save functions to execute? |
| 709 | - if (!empty($context['profile_execute_on_save'])) |
|
| 710 | - foreach ($context['profile_execute_on_save'] as $saveFunc) |
|
| 737 | + if (!empty($context['profile_execute_on_save'])) { |
|
| 738 | + foreach ($context['profile_execute_on_save'] as $saveFunc) |
|
| 711 | 739 | $saveFunc(); |
| 740 | + } |
|
| 712 | 741 | |
| 713 | 742 | // Let them know it worked! |
| 714 | 743 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $cur_profile['member_name']); |
@@ -722,27 +751,31 @@ discard block |
||
| 722 | 751 | if (!empty($post_errors)) |
| 723 | 752 | { |
| 724 | 753 | // Set all the errors so the template knows what went wrong. |
| 725 | - foreach ($post_errors as $error_type) |
|
| 726 | - $context['modify_error'][$error_type] = true; |
|
| 754 | + foreach ($post_errors as $error_type) { |
|
| 755 | + $context['modify_error'][$error_type] = true; |
|
| 756 | + } |
|
| 727 | 757 | } |
| 728 | 758 | // If it's you then we should redirect upon save. |
| 729 | - elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) |
|
| 730 | - redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated'); |
|
| 731 | - elseif (!empty($force_redirect)) |
|
| 732 | - redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area); |
|
| 759 | + elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) { |
|
| 760 | + redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated'); |
|
| 761 | + } elseif (!empty($force_redirect)) { |
|
| 762 | + redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area); |
|
| 763 | + } |
|
| 733 | 764 | |
| 734 | 765 | |
| 735 | 766 | // Get the right callable. |
| 736 | 767 | $call = call_helper($profile_include_data['function'], true); |
| 737 | 768 | |
| 738 | 769 | // Is it valid? |
| 739 | - if (!empty($call)) |
|
| 740 | - call_user_func($call, $memID); |
|
| 770 | + if (!empty($call)) { |
|
| 771 | + call_user_func($call, $memID); |
|
| 772 | + } |
|
| 741 | 773 | |
| 742 | 774 | // Set the page title if it's not already set... |
| 743 | - if (!isset($context['page_title'])) |
|
| 744 | - $context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : ''); |
|
| 745 | -} |
|
| 775 | + if (!isset($context['page_title'])) { |
|
| 776 | + $context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : ''); |
|
| 777 | + } |
|
| 778 | + } |
|
| 746 | 779 | |
| 747 | 780 | /** |
| 748 | 781 | * Set up the requirements for the profile popup - the area that is shown as the popup menu for the current user. |
@@ -865,16 +898,18 @@ discard block |
||
| 865 | 898 | if (!allowedTo('admin_forum') && $area != 'register') |
| 866 | 899 | { |
| 867 | 900 | // If it's the owner they can see two types of private fields, regardless. |
| 868 | - if ($memID == $user_info['id']) |
|
| 869 | - $where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
| 870 | - else |
|
| 871 | - $where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
| 901 | + if ($memID == $user_info['id']) { |
|
| 902 | + $where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
| 903 | + } else { |
|
| 904 | + $where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
| 905 | + } |
|
| 872 | 906 | } |
| 873 | 907 | |
| 874 | - if ($area == 'register') |
|
| 875 | - $where .= ' AND show_reg != 0'; |
|
| 876 | - elseif ($area != 'summary') |
|
| 877 | - $where .= ' AND show_profile = {string:area}'; |
|
| 908 | + if ($area == 'register') { |
|
| 909 | + $where .= ' AND show_reg != 0'; |
|
| 910 | + } elseif ($area != 'summary') { |
|
| 911 | + $where .= ' AND show_profile = {string:area}'; |
|
| 912 | + } |
|
| 878 | 913 | |
| 879 | 914 | // Load all the relevant fields - and data. |
| 880 | 915 | $request = $smcFunc['db_query']('', ' |
@@ -900,13 +935,15 @@ discard block |
||
| 900 | 935 | if (isset($_POST['customfield']) && isset($_POST['customfield'][$row['col_name']])) |
| 901 | 936 | { |
| 902 | 937 | $value = $smcFunc['htmlspecialchars']($_POST['customfield'][$row['col_name']]); |
| 903 | - if (in_array($row['field_type'], array('select', 'radio'))) |
|
| 904 | - $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
| 938 | + if (in_array($row['field_type'], array('select', 'radio'))) { |
|
| 939 | + $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
| 940 | + } |
|
| 905 | 941 | } |
| 906 | 942 | |
| 907 | 943 | // Don't show the "disabled" option for the "gender" field if we are on the "summary" area. |
| 908 | - if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'Disabled') |
|
| 909 | - continue; |
|
| 944 | + if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'Disabled') { |
|
| 945 | + continue; |
|
| 946 | + } |
|
| 910 | 947 | |
| 911 | 948 | // HTML for the input form. |
| 912 | 949 | $output_html = $value; |
@@ -915,8 +952,7 @@ discard block |
||
| 915 | 952 | $true = (!$exists && $row['default_value']) || $value; |
| 916 | 953 | $input_html = '<input type="checkbox" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($true ? ' checked' : '') . ' class="input_check">'; |
| 917 | 954 | $output_html = $true ? $txt['yes'] : $txt['no']; |
| 918 | - } |
|
| 919 | - elseif ($row['field_type'] == 'select') |
|
| 955 | + } elseif ($row['field_type'] == 'select') |
|
| 920 | 956 | { |
| 921 | 957 | $input_html = '<select name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"><option value="-1"></option>'; |
| 922 | 958 | $options = explode(',', $row['field_options']); |
@@ -924,13 +960,13 @@ discard block |
||
| 924 | 960 | { |
| 925 | 961 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
| 926 | 962 | $input_html .= '<option value="' . $k . '"' . ($true ? ' selected' : '') . '>' . $v . '</option>'; |
| 927 | - if ($true) |
|
| 928 | - $output_html = $v; |
|
| 963 | + if ($true) { |
|
| 964 | + $output_html = $v; |
|
| 965 | + } |
|
| 929 | 966 | } |
| 930 | 967 | |
| 931 | 968 | $input_html .= '</select>'; |
| 932 | - } |
|
| 933 | - elseif ($row['field_type'] == 'radio') |
|
| 969 | + } elseif ($row['field_type'] == 'radio') |
|
| 934 | 970 | { |
| 935 | 971 | $input_html = '<fieldset>'; |
| 936 | 972 | $options = explode(',', $row['field_options']); |
@@ -938,36 +974,37 @@ discard block |
||
| 938 | 974 | { |
| 939 | 975 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
| 940 | 976 | $input_html .= '<label for="customfield_' . $row['col_name'] . '_' . $k . '"><input type="radio" name="customfield[' . $row['col_name'] . ']" class="input_radio" id="customfield_' . $row['col_name'] . '_' . $k . '" value="' . $k . '"' . ($true ? ' checked' : '') . '>' . $v . '</label><br>'; |
| 941 | - if ($true) |
|
| 942 | - $output_html = $v; |
|
| 977 | + if ($true) { |
|
| 978 | + $output_html = $v; |
|
| 979 | + } |
|
| 943 | 980 | } |
| 944 | 981 | $input_html .= '</fieldset>'; |
| 945 | - } |
|
| 946 | - elseif ($row['field_type'] == 'text') |
|
| 982 | + } elseif ($row['field_type'] == 'text') |
|
| 947 | 983 | { |
| 948 | 984 | $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) . '" class="input_text"' . ($row['show_reg'] == 2 ? ' required' : '') . '>'; |
| 949 | - } |
|
| 950 | - else |
|
| 985 | + } else |
|
| 951 | 986 | { |
| 952 | 987 | @list ($rows, $cols) = @explode(',', $row['default_value']); |
| 953 | 988 | $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>'; |
| 954 | 989 | } |
| 955 | 990 | |
| 956 | 991 | // Parse BBCode |
| 957 | - if ($row['bbc']) |
|
| 958 | - $output_html = parse_bbc($output_html); |
|
| 959 | - elseif ($row['field_type'] == 'textarea') |
|
| 960 | - // Allow for newlines at least |
|
| 992 | + if ($row['bbc']) { |
|
| 993 | + $output_html = parse_bbc($output_html); |
|
| 994 | + } elseif ($row['field_type'] == 'textarea') { |
|
| 995 | + // Allow for newlines at least |
|
| 961 | 996 | $output_html = strtr($output_html, array("\n" => '<br>')); |
| 997 | + } |
|
| 962 | 998 | |
| 963 | 999 | // Enclosing the user input within some other text? |
| 964 | - if (!empty($row['enclose']) && !empty($output_html)) |
|
| 965 | - $output_html = strtr($row['enclose'], array( |
|
| 1000 | + if (!empty($row['enclose']) && !empty($output_html)) { |
|
| 1001 | + $output_html = strtr($row['enclose'], array( |
|
| 966 | 1002 | '{SCRIPTURL}' => $scripturl, |
| 967 | 1003 | '{IMAGES_URL}' => $settings['images_url'], |
| 968 | 1004 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 969 | 1005 | '{INPUT}' => un_htmlspecialchars($output_html), |
| 970 | 1006 | )); |
| 1007 | + } |
|
| 971 | 1008 | |
| 972 | 1009 | $context['custom_fields'][] = array( |
| 973 | 1010 | 'name' => $row['field_name'], |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Handles showing the post screen, loading the post to be modified, and loading any post quoted. |
@@ -35,12 +36,14 @@ discard block |
||
| 35 | 36 | global $sourcedir, $smcFunc, $language; |
| 36 | 37 | |
| 37 | 38 | loadLanguage('Post'); |
| 38 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
| 39 | - loadLanguage('Drafts'); |
|
| 39 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
| 40 | + loadLanguage('Drafts'); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | // You can't reply with a poll... hacker. |
| 42 | - if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) |
|
| 43 | - unset($_REQUEST['poll']); |
|
| 44 | + if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) { |
|
| 45 | + unset($_REQUEST['poll']); |
|
| 46 | + } |
|
| 44 | 47 | |
| 45 | 48 | // Posting an event? |
| 46 | 49 | $context['make_event'] = isset($_REQUEST['calendar']); |
@@ -54,8 +57,9 @@ discard block |
||
| 54 | 57 | $context['auto_notify'] = !empty($context['notify_prefs']['msg_auto_notify']); |
| 55 | 58 | |
| 56 | 59 | // You must be posting to *some* board. |
| 57 | - if (empty($board) && !$context['make_event']) |
|
| 58 | - fatal_lang_error('no_board', false); |
|
| 60 | + if (empty($board) && !$context['make_event']) { |
|
| 61 | + fatal_lang_error('no_board', false); |
|
| 62 | + } |
|
| 59 | 63 | |
| 60 | 64 | require_once($sourcedir . '/Subs-Post.php'); |
| 61 | 65 | |
@@ -78,10 +82,11 @@ discard block |
||
| 78 | 82 | array( |
| 79 | 83 | 'msg' => (int) $_REQUEST['msg'], |
| 80 | 84 | )); |
| 81 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
| 82 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
| 83 | - else |
|
| 84 | - list ($topic) = $smcFunc['db_fetch_row']($request); |
|
| 85 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
| 86 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
| 87 | + } else { |
|
| 88 | + list ($topic) = $smcFunc['db_fetch_row']($request); |
|
| 89 | + } |
|
| 85 | 90 | $smcFunc['db_free_result']($request); |
| 86 | 91 | } |
| 87 | 92 | |
@@ -108,33 +113,36 @@ discard block |
||
| 108 | 113 | $smcFunc['db_free_result']($request); |
| 109 | 114 | |
| 110 | 115 | // If this topic already has a poll, they sure can't add another. |
| 111 | - if (isset($_REQUEST['poll']) && $pollID > 0) |
|
| 112 | - unset($_REQUEST['poll']); |
|
| 116 | + if (isset($_REQUEST['poll']) && $pollID > 0) { |
|
| 117 | + unset($_REQUEST['poll']); |
|
| 118 | + } |
|
| 113 | 119 | |
| 114 | 120 | if (empty($_REQUEST['msg'])) |
| 115 | 121 | { |
| 116 | - if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
|
| 117 | - is_not_guest(); |
|
| 122 | + if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) { |
|
| 123 | + is_not_guest(); |
|
| 124 | + } |
|
| 118 | 125 | |
| 119 | 126 | // By default the reply will be approved... |
| 120 | 127 | $context['becomes_approved'] = true; |
| 121 | 128 | if ($id_member_poster != $user_info['id'] || $user_info['is_guest']) |
| 122 | 129 | { |
| 123 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
| 124 | - $context['becomes_approved'] = false; |
|
| 125 | - else |
|
| 126 | - isAllowedTo('post_reply_any'); |
|
| 127 | - } |
|
| 128 | - elseif (!allowedTo('post_reply_any')) |
|
| 130 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
| 131 | + $context['becomes_approved'] = false; |
|
| 132 | + } else { |
|
| 133 | + isAllowedTo('post_reply_any'); |
|
| 134 | + } |
|
| 135 | + } elseif (!allowedTo('post_reply_any')) |
|
| 129 | 136 | { |
| 130 | - if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) |
|
| 131 | - $context['becomes_approved'] = false; |
|
| 132 | - else |
|
| 133 | - isAllowedTo('post_reply_own'); |
|
| 137 | + if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) { |
|
| 138 | + $context['becomes_approved'] = false; |
|
| 139 | + } else { |
|
| 140 | + isAllowedTo('post_reply_own'); |
|
| 141 | + } |
|
| 134 | 142 | } |
| 143 | + } else { |
|
| 144 | + $context['becomes_approved'] = true; |
|
| 135 | 145 | } |
| 136 | - else |
|
| 137 | - $context['becomes_approved'] = true; |
|
| 138 | 146 | |
| 139 | 147 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own')); |
| 140 | 148 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -146,18 +154,19 @@ discard block |
||
| 146 | 154 | $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky; |
| 147 | 155 | |
| 148 | 156 | // Check whether this is a really old post being bumped... |
| 149 | - if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) |
|
| 150 | - $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
| 151 | - } |
|
| 152 | - else |
|
| 157 | + if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) { |
|
| 158 | + $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
| 159 | + } |
|
| 160 | + } else |
|
| 153 | 161 | { |
| 154 | 162 | $context['becomes_approved'] = true; |
| 155 | 163 | if ((!$context['make_event'] || !empty($board))) |
| 156 | 164 | { |
| 157 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
| 158 | - $context['becomes_approved'] = false; |
|
| 159 | - else |
|
| 160 | - isAllowedTo('post_new'); |
|
| 165 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
| 166 | + $context['becomes_approved'] = false; |
|
| 167 | + } else { |
|
| 168 | + isAllowedTo('post_new'); |
|
| 169 | + } |
|
| 161 | 170 | } |
| 162 | 171 | |
| 163 | 172 | $locked = 0; |
@@ -193,20 +202,24 @@ discard block |
||
| 193 | 202 | } |
| 194 | 203 | |
| 195 | 204 | // Don't allow a post if it's locked and you aren't all powerful. |
| 196 | - if ($locked && !allowedTo('moderate_board')) |
|
| 197 | - fatal_lang_error('topic_locked', false); |
|
| 205 | + if ($locked && !allowedTo('moderate_board')) { |
|
| 206 | + fatal_lang_error('topic_locked', false); |
|
| 207 | + } |
|
| 198 | 208 | // Check the users permissions - is the user allowed to add or post a poll? |
| 199 | 209 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
| 200 | 210 | { |
| 201 | 211 | // New topic, new poll. |
| 202 | - if (empty($topic)) |
|
| 203 | - isAllowedTo('poll_post'); |
|
| 212 | + if (empty($topic)) { |
|
| 213 | + isAllowedTo('poll_post'); |
|
| 214 | + } |
|
| 204 | 215 | // This is an old topic - but it is yours! Can you add to it? |
| 205 | - elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) |
|
| 206 | - isAllowedTo('poll_add_own'); |
|
| 216 | + elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) { |
|
| 217 | + isAllowedTo('poll_add_own'); |
|
| 218 | + } |
|
| 207 | 219 | // If you're not the owner, can you add to any poll? |
| 208 | - else |
|
| 209 | - isAllowedTo('poll_add_any'); |
|
| 220 | + else { |
|
| 221 | + isAllowedTo('poll_add_any'); |
|
| 222 | + } |
|
| 210 | 223 | |
| 211 | 224 | require_once($sourcedir . '/Subs-Members.php'); |
| 212 | 225 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
@@ -235,8 +248,9 @@ discard block |
||
| 235 | 248 | if ($context['make_event']) |
| 236 | 249 | { |
| 237 | 250 | // They might want to pick a board. |
| 238 | - if (!isset($context['current_board'])) |
|
| 239 | - $context['current_board'] = 0; |
|
| 251 | + if (!isset($context['current_board'])) { |
|
| 252 | + $context['current_board'] = 0; |
|
| 253 | + } |
|
| 240 | 254 | |
| 241 | 255 | // Start loading up the event info. |
| 242 | 256 | $context['event'] = array(); |
@@ -250,10 +264,11 @@ discard block |
||
| 250 | 264 | isAllowedTo('calendar_post'); |
| 251 | 265 | |
| 252 | 266 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 253 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 254 | - $time_string = '%k:%M'; |
|
| 255 | - else |
|
| 256 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 267 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 268 | + $time_string = '%k:%M'; |
|
| 269 | + } else { |
|
| 270 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 271 | + } |
|
| 257 | 272 | |
| 258 | 273 | $js_time_string = str_replace( |
| 259 | 274 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -275,8 +290,7 @@ discard block |
||
| 275 | 290 | require_once($sourcedir . '/Subs-Calendar.php'); |
| 276 | 291 | $eventProperties = getEventProperties($context['event']['id']); |
| 277 | 292 | $context['event'] = array_merge($context['event'], $eventProperties); |
| 278 | - } |
|
| 279 | - else |
|
| 293 | + } else |
|
| 280 | 294 | { |
| 281 | 295 | // Get the current event information. |
| 282 | 296 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -284,15 +298,18 @@ discard block |
||
| 284 | 298 | $context['event'] = array_merge($context['event'], $eventProperties); |
| 285 | 299 | |
| 286 | 300 | // Make sure the year and month are in the valid range. |
| 287 | - if ($context['event']['month'] < 1 || $context['event']['month'] > 12) |
|
| 288 | - fatal_lang_error('invalid_month', false); |
|
| 289 | - if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) |
|
| 290 | - fatal_lang_error('invalid_year', false); |
|
| 301 | + if ($context['event']['month'] < 1 || $context['event']['month'] > 12) { |
|
| 302 | + fatal_lang_error('invalid_month', false); |
|
| 303 | + } |
|
| 304 | + if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) { |
|
| 305 | + fatal_lang_error('invalid_year', false); |
|
| 306 | + } |
|
| 291 | 307 | |
| 292 | 308 | // Get a list of boards they can post in. |
| 293 | 309 | $boards = boardsAllowedTo('post_new'); |
| 294 | - if (empty($boards)) |
|
| 295 | - fatal_lang_error('cannot_post_new', 'user'); |
|
| 310 | + if (empty($boards)) { |
|
| 311 | + fatal_lang_error('cannot_post_new', 'user'); |
|
| 312 | + } |
|
| 296 | 313 | |
| 297 | 314 | // Load a list of boards for this event in the context. |
| 298 | 315 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -411,10 +428,11 @@ discard block |
||
| 411 | 428 | |
| 412 | 429 | if (!empty($context['new_replies'])) |
| 413 | 430 | { |
| 414 | - if ($context['new_replies'] == 1) |
|
| 415 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 416 | - else |
|
| 417 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 431 | + if ($context['new_replies'] == 1) { |
|
| 432 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 433 | + } else { |
|
| 434 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 435 | + } |
|
| 418 | 436 | |
| 419 | 437 | $post_errors[] = 'new_replies'; |
| 420 | 438 | |
@@ -426,9 +444,9 @@ discard block |
||
| 426 | 444 | // Get a response prefix (like 'Re:') in the default forum language. |
| 427 | 445 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 428 | 446 | { |
| 429 | - if ($language === $user_info['language']) |
|
| 430 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 431 | - else |
|
| 447 | + if ($language === $user_info['language']) { |
|
| 448 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 449 | + } else |
|
| 432 | 450 | { |
| 433 | 451 | loadLanguage('index', $language, false); |
| 434 | 452 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -441,8 +459,9 @@ discard block |
||
| 441 | 459 | // Do we have a body, but an error happened. |
| 442 | 460 | if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error'])) |
| 443 | 461 | { |
| 444 | - if (isset($_REQUEST['quickReply'])) |
|
| 445 | - $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
| 462 | + if (isset($_REQUEST['quickReply'])) { |
|
| 463 | + $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
| 464 | + } |
|
| 446 | 465 | |
| 447 | 466 | // Validate inputs. |
| 448 | 467 | if (empty($context['post_error'])) |
@@ -450,15 +469,17 @@ discard block |
||
| 450 | 469 | // This means they didn't click Post and get an error. |
| 451 | 470 | $really_previewing = true; |
| 452 | 471 | |
| 453 | - } |
|
| 454 | - else |
|
| 472 | + } else |
|
| 455 | 473 | { |
| 456 | - if (!isset($_REQUEST['subject'])) |
|
| 457 | - $_REQUEST['subject'] = ''; |
|
| 458 | - if (!isset($_REQUEST['message'])) |
|
| 459 | - $_REQUEST['message'] = ''; |
|
| 460 | - if (!isset($_REQUEST['icon'])) |
|
| 461 | - $_REQUEST['icon'] = 'xx'; |
|
| 474 | + if (!isset($_REQUEST['subject'])) { |
|
| 475 | + $_REQUEST['subject'] = ''; |
|
| 476 | + } |
|
| 477 | + if (!isset($_REQUEST['message'])) { |
|
| 478 | + $_REQUEST['message'] = ''; |
|
| 479 | + } |
|
| 480 | + if (!isset($_REQUEST['icon'])) { |
|
| 481 | + $_REQUEST['icon'] = 'xx'; |
|
| 482 | + } |
|
| 462 | 483 | |
| 463 | 484 | // They are previewing if they asked to preview (i.e. came from quick reply). |
| 464 | 485 | $really_previewing = !empty($_POST['preview']); |
@@ -474,8 +495,9 @@ discard block |
||
| 474 | 495 | $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES); |
| 475 | 496 | |
| 476 | 497 | // Make sure the subject isn't too long - taking into account special characters. |
| 477 | - if ($smcFunc['strlen']($form_subject) > 100) |
|
| 478 | - $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
| 498 | + if ($smcFunc['strlen']($form_subject) > 100) { |
|
| 499 | + $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
| 500 | + } |
|
| 479 | 501 | |
| 480 | 502 | if (isset($_REQUEST['poll'])) |
| 481 | 503 | { |
@@ -487,8 +509,9 @@ discard block |
||
| 487 | 509 | $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']); |
| 488 | 510 | foreach ($_POST['options'] as $option) |
| 489 | 511 | { |
| 490 | - if (trim($option) == '') |
|
| 491 | - continue; |
|
| 512 | + if (trim($option) == '') { |
|
| 513 | + continue; |
|
| 514 | + } |
|
| 492 | 515 | |
| 493 | 516 | $context['choices'][] = array( |
| 494 | 517 | 'id' => $choice_id++, |
@@ -550,13 +573,14 @@ discard block |
||
| 550 | 573 | $context['preview_subject'] = $form_subject; |
| 551 | 574 | |
| 552 | 575 | censorText($context['preview_subject']); |
| 576 | + } else { |
|
| 577 | + $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
| 553 | 578 | } |
| 554 | - else |
|
| 555 | - $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
| 556 | 579 | |
| 557 | 580 | // Protect any CDATA blocks. |
| 558 | - if (isset($_REQUEST['xml'])) |
|
| 559 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
| 581 | + if (isset($_REQUEST['xml'])) { |
|
| 582 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]>< == 0) |
|
| 599 | - fatal_lang_error('no_board', false); |
|
| 622 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 623 | + fatal_lang_error('no_board', false); |
|
| 624 | + } |
|
| 600 | 625 | $row = $smcFunc['db_fetch_assoc']($request); |
| 601 | 626 | |
| 602 | 627 | $attachment_stuff = array($row); |
| 603 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
| 604 | - $attachment_stuff[] = $row2; |
|
| 628 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
| 629 | + $attachment_stuff[] = $row2; |
|
| 630 | + } |
|
| 605 | 631 | $smcFunc['db_free_result']($request); |
| 606 | 632 | |
| 607 | 633 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 608 | 634 | { |
| 609 | 635 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
| 610 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 611 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 612 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 613 | - isAllowedTo('modify_replies'); |
|
| 614 | - else |
|
| 615 | - isAllowedTo('modify_own'); |
|
| 636 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 637 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 638 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 639 | + isAllowedTo('modify_replies'); |
|
| 640 | + } else { |
|
| 641 | + isAllowedTo('modify_own'); |
|
| 642 | + } |
|
| 643 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 644 | + isAllowedTo('modify_replies'); |
|
| 645 | + } else { |
|
| 646 | + isAllowedTo('modify_any'); |
|
| 616 | 647 | } |
| 617 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 618 | - isAllowedTo('modify_replies'); |
|
| 619 | - else |
|
| 620 | - isAllowedTo('modify_any'); |
|
| 621 | 648 | |
| 622 | 649 | if ($context['can_announce'] && !empty($row['id_action'])) |
| 623 | 650 | { |
@@ -641,8 +668,9 @@ discard block |
||
| 641 | 668 | |
| 642 | 669 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 643 | 670 | { |
| 644 | - if ($row['filesize'] <= 0) |
|
| 645 | - continue; |
|
| 671 | + if ($row['filesize'] <= 0) { |
|
| 672 | + continue; |
|
| 673 | + } |
|
| 646 | 674 | $context['current_attachments'][$row['id_attach']] = array( |
| 647 | 675 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
| 648 | 676 | 'size' => $row['filesize'], |
@@ -712,29 +740,32 @@ discard block |
||
| 712 | 740 | ) |
| 713 | 741 | ); |
| 714 | 742 | // The message they were trying to edit was most likely deleted. |
| 715 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 716 | - fatal_lang_error('no_message', false); |
|
| 743 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 744 | + fatal_lang_error('no_message', false); |
|
| 745 | + } |
|
| 717 | 746 | $row = $smcFunc['db_fetch_assoc']($request); |
| 718 | 747 | |
| 719 | 748 | $attachment_stuff = array($row); |
| 720 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
| 721 | - $attachment_stuff[] = $row2; |
|
| 749 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
| 750 | + $attachment_stuff[] = $row2; |
|
| 751 | + } |
|
| 722 | 752 | $smcFunc['db_free_result']($request); |
| 723 | 753 | |
| 724 | 754 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 725 | 755 | { |
| 726 | 756 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
| 727 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 728 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 729 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 730 | - isAllowedTo('modify_replies'); |
|
| 731 | - else |
|
| 732 | - isAllowedTo('modify_own'); |
|
| 757 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 758 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 759 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 760 | + isAllowedTo('modify_replies'); |
|
| 761 | + } else { |
|
| 762 | + isAllowedTo('modify_own'); |
|
| 763 | + } |
|
| 764 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 765 | + isAllowedTo('modify_replies'); |
|
| 766 | + } else { |
|
| 767 | + isAllowedTo('modify_any'); |
|
| 733 | 768 | } |
| 734 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 735 | - isAllowedTo('modify_replies'); |
|
| 736 | - else |
|
| 737 | - isAllowedTo('modify_any'); |
|
| 738 | 769 | |
| 739 | 770 | if ($context['can_announce'] && !empty($row['id_action'])) |
| 740 | 771 | { |
@@ -761,15 +792,17 @@ discard block |
||
| 761 | 792 | $context['icon'] = $row['icon']; |
| 762 | 793 | |
| 763 | 794 | // Show an "approve" box if the user can approve it, and the message isn't approved. |
| 764 | - if (!$row['approved'] && !$context['show_approval']) |
|
| 765 | - $context['show_approval'] = allowedTo('approve_posts'); |
|
| 795 | + if (!$row['approved'] && !$context['show_approval']) { |
|
| 796 | + $context['show_approval'] = allowedTo('approve_posts'); |
|
| 797 | + } |
|
| 766 | 798 | |
| 767 | 799 | // Sort the attachments so they are in the order saved |
| 768 | 800 | $temp = array(); |
| 769 | 801 | foreach ($attachment_stuff as $attachment) |
| 770 | 802 | { |
| 771 | - if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) |
|
| 772 | - $temp[$attachment['id_attach']] = $attachment; |
|
| 803 | + if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) { |
|
| 804 | + $temp[$attachment['id_attach']] = $attachment; |
|
| 805 | + } |
|
| 773 | 806 | |
| 774 | 807 | } |
| 775 | 808 | ksort($temp); |
@@ -831,14 +864,16 @@ discard block |
||
| 831 | 864 | 'is_approved' => 1, |
| 832 | 865 | ) |
| 833 | 866 | ); |
| 834 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 835 | - fatal_lang_error('quoted_post_deleted', false); |
|
| 867 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 868 | + fatal_lang_error('quoted_post_deleted', false); |
|
| 869 | + } |
|
| 836 | 870 | list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request); |
| 837 | 871 | $smcFunc['db_free_result']($request); |
| 838 | 872 | |
| 839 | 873 | // Add 'Re: ' to the front of the quoted subject. |
| 840 | - if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 841 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 874 | + if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 875 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 876 | + } |
|
| 842 | 877 | |
| 843 | 878 | // Censor the message and subject. |
| 844 | 879 | censorText($form_message); |
@@ -851,10 +886,11 @@ discard block |
||
| 851 | 886 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
| 852 | 887 | { |
| 853 | 888 | // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. |
| 854 | - if ($i % 4 == 0) |
|
| 855 | - $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
| 889 | + if ($i % 4 == 0) { |
|
| 890 | + $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
| 856 | 891 | { |
| 857 | 892 | return '[html]' . preg_replace('~<br\s?/?' . '>~i', '<br /><br>', "$m[1]") . '[/html]'; |
| 893 | + } |
|
| 858 | 894 | }, $parts[$i]); |
| 859 | 895 | } |
| 860 | 896 | $form_message = implode('', $parts); |
@@ -863,8 +899,9 @@ discard block |
||
| 863 | 899 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message); |
| 864 | 900 | |
| 865 | 901 | // Remove any nested quotes, if necessary. |
| 866 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 867 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 902 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 903 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 904 | + } |
|
| 868 | 905 | |
| 869 | 906 | // Add a quote string on the front and end. |
| 870 | 907 | $form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]'; |
@@ -876,15 +913,15 @@ discard block |
||
| 876 | 913 | $form_subject = $first_subject; |
| 877 | 914 | |
| 878 | 915 | // Add 'Re: ' to the front of the subject. |
| 879 | - if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 880 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 916 | + if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 917 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 918 | + } |
|
| 881 | 919 | |
| 882 | 920 | // Censor the subject. |
| 883 | 921 | censorText($form_subject); |
| 884 | 922 | |
| 885 | 923 | $form_message = ''; |
| 886 | - } |
|
| 887 | - else |
|
| 924 | + } else |
|
| 888 | 925 | { |
| 889 | 926 | $form_subject = isset($_GET['subject']) ? $_GET['subject'] : ''; |
| 890 | 927 | $form_message = ''; |
@@ -902,13 +939,15 @@ discard block |
||
| 902 | 939 | if (isset($_REQUEST['msg'])) |
| 903 | 940 | { |
| 904 | 941 | $context['attachments']['quantity'] = count($context['current_attachments']); |
| 905 | - foreach ($context['current_attachments'] as $attachment) |
|
| 906 | - $context['attachments']['total_size'] += $attachment['size']; |
|
| 942 | + foreach ($context['current_attachments'] as $attachment) { |
|
| 943 | + $context['attachments']['total_size'] += $attachment['size']; |
|
| 944 | + } |
|
| 907 | 945 | } |
| 908 | 946 | |
| 909 | 947 | // A bit of house keeping first. |
| 910 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
| 911 | - unset($_SESSION['temp_attachments']); |
|
| 948 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
| 949 | + unset($_SESSION['temp_attachments']); |
|
| 950 | + } |
|
| 912 | 951 | |
| 913 | 952 | if (!empty($_SESSION['temp_attachments'])) |
| 914 | 953 | { |
@@ -917,9 +956,10 @@ discard block |
||
| 917 | 956 | { |
| 918 | 957 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 919 | 958 | { |
| 920 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 921 | - if (file_exists($attachment['tmp_name'])) |
|
| 959 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) { |
|
| 960 | + if (file_exists($attachment['tmp_name'])) |
|
| 922 | 961 | unlink($attachment['tmp_name']); |
| 962 | + } |
|
| 923 | 963 | } |
| 924 | 964 | $post_errors[] = 'temp_attachments_gone'; |
| 925 | 965 | $_SESSION['temp_attachments'] = array(); |
@@ -933,8 +973,9 @@ discard block |
||
| 933 | 973 | // See if any files still exist before showing the warning message and the files attached. |
| 934 | 974 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 935 | 975 | { |
| 936 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 937 | - continue; |
|
| 976 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 977 | + continue; |
|
| 978 | + } |
|
| 938 | 979 | |
| 939 | 980 | if (file_exists($attachment['tmp_name'])) |
| 940 | 981 | { |
@@ -944,20 +985,21 @@ discard block |
||
| 944 | 985 | break; |
| 945 | 986 | } |
| 946 | 987 | } |
| 947 | - } |
|
| 948 | - else |
|
| 988 | + } else |
|
| 949 | 989 | { |
| 950 | 990 | // Since, they don't belong here. Let's inform the user that they exist.. |
| 951 | - if (!empty($topic)) |
|
| 952 | - $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 953 | - else |
|
| 954 | - $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
| 991 | + if (!empty($topic)) { |
|
| 992 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 993 | + } else { |
|
| 994 | + $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
| 995 | + } |
|
| 955 | 996 | |
| 956 | 997 | // Compile a list of the files to show the user. |
| 957 | 998 | $file_list = array(); |
| 958 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 959 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 999 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
| 1000 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 960 | 1001 | $file_list[] = $attachment['name']; |
| 1002 | + } |
|
| 961 | 1003 | |
| 962 | 1004 | $_SESSION['temp_attachments']['post']['files'] = $file_list; |
| 963 | 1005 | $file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>'; |
@@ -969,8 +1011,7 @@ discard block |
||
| 969 | 1011 | |
| 970 | 1012 | $post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list)); |
| 971 | 1013 | $context['ignore_temp_attachments'] = true; |
| 972 | - } |
|
| 973 | - else |
|
| 1014 | + } else |
|
| 974 | 1015 | { |
| 975 | 1016 | $post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list)); |
| 976 | 1017 | $context['ignore_temp_attachments'] = true; |
@@ -978,16 +1019,19 @@ discard block |
||
| 978 | 1019 | } |
| 979 | 1020 | } |
| 980 | 1021 | |
| 981 | - if (!empty($context['we_are_history'])) |
|
| 982 | - $post_errors[] = $context['we_are_history']; |
|
| 1022 | + if (!empty($context['we_are_history'])) { |
|
| 1023 | + $post_errors[] = $context['we_are_history']; |
|
| 1024 | + } |
|
| 983 | 1025 | |
| 984 | 1026 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 985 | 1027 | { |
| 986 | - if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
|
| 987 | - break; |
|
| 1028 | + if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) { |
|
| 1029 | + break; |
|
| 1030 | + } |
|
| 988 | 1031 | |
| 989 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 990 | - continue; |
|
| 1032 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 1033 | + continue; |
|
| 1034 | + } |
|
| 991 | 1035 | |
| 992 | 1036 | if ($attachID == 'initial_error') |
| 993 | 1037 | { |
@@ -1002,15 +1046,17 @@ discard block |
||
| 1002 | 1046 | { |
| 1003 | 1047 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : ''; |
| 1004 | 1048 | $txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">'; |
| 1005 | - foreach ($attachment['errors'] as $error) |
|
| 1006 | - $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
| 1049 | + foreach ($attachment['errors'] as $error) { |
|
| 1050 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
| 1051 | + } |
|
| 1007 | 1052 | $txt['error_attach_errors'] .= '</div>'; |
| 1008 | 1053 | $post_errors[] = 'attach_errors'; |
| 1009 | 1054 | |
| 1010 | 1055 | // Take out the trash. |
| 1011 | 1056 | unset($_SESSION['temp_attachments'][$attachID]); |
| 1012 | - if (file_exists($attachment['tmp_name'])) |
|
| 1013 | - unlink($attachment['tmp_name']); |
|
| 1057 | + if (file_exists($attachment['tmp_name'])) { |
|
| 1058 | + unlink($attachment['tmp_name']); |
|
| 1059 | + } |
|
| 1014 | 1060 | continue; |
| 1015 | 1061 | } |
| 1016 | 1062 | |
@@ -1023,8 +1069,9 @@ discard block |
||
| 1023 | 1069 | |
| 1024 | 1070 | $context['attachments']['quantity']++; |
| 1025 | 1071 | $context['attachments']['total_size'] += $attachment['size']; |
| 1026 | - if (!isset($context['files_in_session_warning'])) |
|
| 1027 | - $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 1072 | + if (!isset($context['files_in_session_warning'])) { |
|
| 1073 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 1074 | + } |
|
| 1028 | 1075 | |
| 1029 | 1076 | $context['current_attachments'][$attachID] = array( |
| 1030 | 1077 | 'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>', |
@@ -1052,8 +1099,9 @@ discard block |
||
| 1052 | 1099 | } |
| 1053 | 1100 | |
| 1054 | 1101 | // If they came from quick reply, and have to enter verification details, give them some notice. |
| 1055 | - if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) |
|
| 1056 | - $post_errors[] = 'need_qr_verification'; |
|
| 1102 | + if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) { |
|
| 1103 | + $post_errors[] = 'need_qr_verification'; |
|
| 1104 | + } |
|
| 1057 | 1105 | |
| 1058 | 1106 | /* |
| 1059 | 1107 | * There are two error types: serious and minor. Serious errors |
@@ -1070,52 +1118,56 @@ discard block |
||
| 1070 | 1118 | { |
| 1071 | 1119 | loadLanguage('Errors'); |
| 1072 | 1120 | $context['error_type'] = 'minor'; |
| 1073 | - foreach ($post_errors as $post_error) |
|
| 1074 | - if (is_array($post_error)) |
|
| 1121 | + foreach ($post_errors as $post_error) { |
|
| 1122 | + if (is_array($post_error)) |
|
| 1075 | 1123 | { |
| 1076 | 1124 | $post_error_id = $post_error[0]; |
| 1125 | + } |
|
| 1077 | 1126 | $context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]); |
| 1078 | 1127 | |
| 1079 | 1128 | // If it's not a minor error flag it as such. |
| 1080 | - if (!in_array($post_error_id, $minor_errors)) |
|
| 1081 | - $context['error_type'] = 'serious'; |
|
| 1082 | - } |
|
| 1083 | - else |
|
| 1129 | + if (!in_array($post_error_id, $minor_errors)) { |
|
| 1130 | + $context['error_type'] = 'serious'; |
|
| 1131 | + } |
|
| 1132 | + } else |
|
| 1084 | 1133 | { |
| 1085 | 1134 | $context['post_error'][$post_error] = $txt['error_' . $post_error]; |
| 1086 | 1135 | |
| 1087 | 1136 | // If it's not a minor error flag it as such. |
| 1088 | - if (!in_array($post_error, $minor_errors)) |
|
| 1089 | - $context['error_type'] = 'serious'; |
|
| 1137 | + if (!in_array($post_error, $minor_errors)) { |
|
| 1138 | + $context['error_type'] = 'serious'; |
|
| 1139 | + } |
|
| 1090 | 1140 | } |
| 1091 | 1141 | } |
| 1092 | 1142 | |
| 1093 | 1143 | // What are you doing? Posting a poll, modifying, previewing, new post, or reply... |
| 1094 | - if (isset($_REQUEST['poll'])) |
|
| 1095 | - $context['page_title'] = $txt['new_poll']; |
|
| 1096 | - elseif ($context['make_event']) |
|
| 1097 | - $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
| 1098 | - elseif (isset($_REQUEST['msg'])) |
|
| 1099 | - $context['page_title'] = $txt['modify_msg']; |
|
| 1100 | - elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
|
| 1101 | - $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
| 1102 | - elseif (empty($topic)) |
|
| 1103 | - $context['page_title'] = $txt['start_new_topic']; |
|
| 1104 | - else |
|
| 1105 | - $context['page_title'] = $txt['post_reply']; |
|
| 1144 | + if (isset($_REQUEST['poll'])) { |
|
| 1145 | + $context['page_title'] = $txt['new_poll']; |
|
| 1146 | + } elseif ($context['make_event']) { |
|
| 1147 | + $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
| 1148 | + } elseif (isset($_REQUEST['msg'])) { |
|
| 1149 | + $context['page_title'] = $txt['modify_msg']; |
|
| 1150 | + } elseif (isset($_REQUEST['subject'], $context['preview_subject'])) { |
|
| 1151 | + $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
| 1152 | + } elseif (empty($topic)) { |
|
| 1153 | + $context['page_title'] = $txt['start_new_topic']; |
|
| 1154 | + } else { |
|
| 1155 | + $context['page_title'] = $txt['post_reply']; |
|
| 1156 | + } |
|
| 1106 | 1157 | |
| 1107 | 1158 | // Build the link tree. |
| 1108 | - if (empty($topic)) |
|
| 1109 | - $context['linktree'][] = array( |
|
| 1159 | + if (empty($topic)) { |
|
| 1160 | + $context['linktree'][] = array( |
|
| 1110 | 1161 | 'name' => '<em>' . $txt['start_new_topic'] . '</em>' |
| 1111 | 1162 | ); |
| 1112 | - else |
|
| 1113 | - $context['linktree'][] = array( |
|
| 1163 | + } else { |
|
| 1164 | + $context['linktree'][] = array( |
|
| 1114 | 1165 | 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'], |
| 1115 | 1166 | 'name' => $form_subject, |
| 1116 | 1167 | 'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>', |
| 1117 | 1168 | 'extra_after' => '<span><strong class="nav">)</strong></span>' |
| 1118 | 1169 | ); |
| 1170 | + } |
|
| 1119 | 1171 | |
| 1120 | 1172 | $context['subject'] = addcslashes($form_subject, '"'); |
| 1121 | 1173 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message); |
@@ -1159,8 +1211,9 @@ discard block |
||
| 1159 | 1211 | // Message icons - customized icons are off? |
| 1160 | 1212 | $context['icons'] = getMessageIcons($board); |
| 1161 | 1213 | |
| 1162 | - if (!empty($context['icons'])) |
|
| 1163 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1214 | + if (!empty($context['icons'])) { |
|
| 1215 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1216 | + } |
|
| 1164 | 1217 | |
| 1165 | 1218 | // Are we starting a poll? if set the poll icon as selected if its available |
| 1166 | 1219 | if (isset($_REQUEST['poll'])) |
@@ -1180,8 +1233,9 @@ discard block |
||
| 1180 | 1233 | for ($i = 0, $n = count($context['icons']); $i < $n; $i++) |
| 1181 | 1234 | { |
| 1182 | 1235 | $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value']; |
| 1183 | - if ($context['icons'][$i]['selected']) |
|
| 1184 | - $context['icon_url'] = $context['icons'][$i]['url']; |
|
| 1236 | + if ($context['icons'][$i]['selected']) { |
|
| 1237 | + $context['icon_url'] = $context['icons'][$i]['url']; |
|
| 1238 | + } |
|
| 1185 | 1239 | } |
| 1186 | 1240 | if (empty($context['icon_url'])) |
| 1187 | 1241 | { |
@@ -1195,8 +1249,9 @@ discard block |
||
| 1195 | 1249 | )); |
| 1196 | 1250 | } |
| 1197 | 1251 | |
| 1198 | - if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) |
|
| 1199 | - getTopic(); |
|
| 1252 | + if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) { |
|
| 1253 | + getTopic(); |
|
| 1254 | + } |
|
| 1200 | 1255 | |
| 1201 | 1256 | // If the user can post attachments prepare the warning labels. |
| 1202 | 1257 | if ($context['can_post_attachment']) |
@@ -1207,12 +1262,13 @@ discard block |
||
| 1207 | 1262 | $context['attachment_restrictions'] = array(); |
| 1208 | 1263 | $context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
| 1209 | 1264 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
| 1210 | - foreach ($attachmentRestrictionTypes as $type) |
|
| 1211 | - if (!empty($modSettings[$type])) |
|
| 1265 | + foreach ($attachmentRestrictionTypes as $type) { |
|
| 1266 | + if (!empty($modSettings[$type])) |
|
| 1212 | 1267 | { |
| 1213 | 1268 | // Show the max number of attachments if not 0. |
| 1214 | 1269 | if ($type == 'attachmentNumPerPostLimit') |
| 1215 | 1270 | $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
| 1271 | + } |
|
| 1216 | 1272 | } |
| 1217 | 1273 | } |
| 1218 | 1274 | |
@@ -1246,8 +1302,8 @@ discard block |
||
| 1246 | 1302 | |
| 1247 | 1303 | if (!empty($context['current_attachments'])) |
| 1248 | 1304 | { |
| 1249 | - foreach ($context['current_attachments'] as $key => $mock) |
|
| 1250 | - addInlineJavaScript(' |
|
| 1305 | + foreach ($context['current_attachments'] as $key => $mock) { |
|
| 1306 | + addInlineJavaScript(' |
|
| 1251 | 1307 | current_attachments.push({ |
| 1252 | 1308 | name: '. JavaScriptEscape($mock['name']) . ', |
| 1253 | 1309 | size: '. $mock['size'] . ', |
@@ -1256,6 +1312,7 @@ discard block |
||
| 1256 | 1312 | type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ', |
| 1257 | 1313 | thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . ' |
| 1258 | 1314 | });', true); |
| 1315 | + } |
|
| 1259 | 1316 | } |
| 1260 | 1317 | |
| 1261 | 1318 | // File Upload. |
@@ -1341,8 +1398,9 @@ discard block |
||
| 1341 | 1398 | |
| 1342 | 1399 | |
| 1343 | 1400 | // Finally, load the template. |
| 1344 | - if (!isset($_REQUEST['xml'])) |
|
| 1345 | - loadTemplate('Post'); |
|
| 1401 | + if (!isset($_REQUEST['xml'])) { |
|
| 1402 | + loadTemplate('Post'); |
|
| 1403 | + } |
|
| 1346 | 1404 | |
| 1347 | 1405 | call_integration_hook('integrate_post_end'); |
| 1348 | 1406 | } |
@@ -1363,13 +1421,14 @@ discard block |
||
| 1363 | 1421 | // Sneaking off, are we? |
| 1364 | 1422 | if (empty($_POST) && empty($topic)) |
| 1365 | 1423 | { |
| 1366 | - if (empty($_SERVER['CONTENT_LENGTH'])) |
|
| 1367 | - redirectexit('action=post;board=' . $board . '.0'); |
|
| 1368 | - else |
|
| 1369 | - fatal_lang_error('post_upload_error', false); |
|
| 1424 | + if (empty($_SERVER['CONTENT_LENGTH'])) { |
|
| 1425 | + redirectexit('action=post;board=' . $board . '.0'); |
|
| 1426 | + } else { |
|
| 1427 | + fatal_lang_error('post_upload_error', false); |
|
| 1428 | + } |
|
| 1429 | + } elseif (empty($_POST) && !empty($topic)) { |
|
| 1430 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 1370 | 1431 | } |
| 1371 | - elseif (empty($_POST) && !empty($topic)) |
|
| 1372 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 1373 | 1432 | |
| 1374 | 1433 | // No need! |
| 1375 | 1434 | $context['robot_no_index'] = true; |
@@ -1381,8 +1440,9 @@ discard block |
||
| 1381 | 1440 | $post_errors = array(); |
| 1382 | 1441 | |
| 1383 | 1442 | // If the session has timed out, let the user re-submit their form. |
| 1384 | - if (checkSession('post', '', false) != '') |
|
| 1385 | - $post_errors[] = 'session_timeout'; |
|
| 1443 | + if (checkSession('post', '', false) != '') { |
|
| 1444 | + $post_errors[] = 'session_timeout'; |
|
| 1445 | + } |
|
| 1386 | 1446 | |
| 1387 | 1447 | // Wrong verification code? |
| 1388 | 1448 | if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1))) |
@@ -1392,33 +1452,38 @@ discard block |
||
| 1392 | 1452 | 'id' => 'post', |
| 1393 | 1453 | ); |
| 1394 | 1454 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
| 1395 | - if (is_array($context['require_verification'])) |
|
| 1396 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 1455 | + if (is_array($context['require_verification'])) { |
|
| 1456 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 1457 | + } |
|
| 1397 | 1458 | } |
| 1398 | 1459 | |
| 1399 | 1460 | require_once($sourcedir . '/Subs-Post.php'); |
| 1400 | 1461 | loadLanguage('Post'); |
| 1401 | 1462 | |
| 1402 | 1463 | // Drafts enabled and needed? |
| 1403 | - if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) |
|
| 1404 | - require_once($sourcedir . '/Drafts.php'); |
|
| 1464 | + if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) { |
|
| 1465 | + require_once($sourcedir . '/Drafts.php'); |
|
| 1466 | + } |
|
| 1405 | 1467 | |
| 1406 | 1468 | // First check to see if they are trying to delete any current attachments. |
| 1407 | 1469 | if (isset($_POST['attach_del'])) |
| 1408 | 1470 | { |
| 1409 | 1471 | $keep_temp = array(); |
| 1410 | 1472 | $keep_ids = array(); |
| 1411 | - foreach ($_POST['attach_del'] as $dummy) |
|
| 1412 | - if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1473 | + foreach ($_POST['attach_del'] as $dummy) { |
|
| 1474 | + if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1413 | 1475 | $keep_temp[] = $dummy; |
| 1414 | - else |
|
| 1415 | - $keep_ids[] = (int) $dummy; |
|
| 1476 | + } |
|
| 1477 | + else { |
|
| 1478 | + $keep_ids[] = (int) $dummy; |
|
| 1479 | + } |
|
| 1416 | 1480 | |
| 1417 | - if (isset($_SESSION['temp_attachments'])) |
|
| 1418 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 1481 | + if (isset($_SESSION['temp_attachments'])) { |
|
| 1482 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 1419 | 1483 | { |
| 1420 | 1484 | if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
| 1421 | 1485 | continue; |
| 1486 | + } |
|
| 1422 | 1487 | |
| 1423 | 1488 | unset($_SESSION['temp_attachments'][$attachID]); |
| 1424 | 1489 | unlink($attachment['tmp_name']); |
@@ -1460,24 +1525,28 @@ discard block |
||
| 1460 | 1525 | $smcFunc['db_free_result']($request); |
| 1461 | 1526 | |
| 1462 | 1527 | // Though the topic should be there, it might have vanished. |
| 1463 | - if (!is_array($topic_info)) |
|
| 1464 | - fatal_lang_error('topic_doesnt_exist', 404); |
|
| 1528 | + if (!is_array($topic_info)) { |
|
| 1529 | + fatal_lang_error('topic_doesnt_exist', 404); |
|
| 1530 | + } |
|
| 1465 | 1531 | |
| 1466 | 1532 | // Did this topic suddenly move? Just checking... |
| 1467 | - if ($topic_info['id_board'] != $board) |
|
| 1468 | - fatal_lang_error('not_a_topic'); |
|
| 1533 | + if ($topic_info['id_board'] != $board) { |
|
| 1534 | + fatal_lang_error('not_a_topic'); |
|
| 1535 | + } |
|
| 1469 | 1536 | } |
| 1470 | 1537 | |
| 1471 | 1538 | // Replying to a topic? |
| 1472 | 1539 | if (!empty($topic) && !isset($_REQUEST['msg'])) |
| 1473 | 1540 | { |
| 1474 | 1541 | // Don't allow a post if it's locked. |
| 1475 | - if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
|
| 1476 | - fatal_lang_error('topic_locked', false); |
|
| 1542 | + if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) { |
|
| 1543 | + fatal_lang_error('topic_locked', false); |
|
| 1544 | + } |
|
| 1477 | 1545 | |
| 1478 | 1546 | // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P. |
| 1479 | - if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) |
|
| 1480 | - unset($_REQUEST['poll']); |
|
| 1547 | + if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) { |
|
| 1548 | + unset($_REQUEST['poll']); |
|
| 1549 | + } |
|
| 1481 | 1550 | |
| 1482 | 1551 | // Do the permissions and approval stuff... |
| 1483 | 1552 | $becomesApproved = true; |
@@ -1493,44 +1562,43 @@ discard block |
||
| 1493 | 1562 | |
| 1494 | 1563 | // Set a nice session var... |
| 1495 | 1564 | $_SESSION['becomesUnapproved'] = true; |
| 1496 | - } |
|
| 1497 | - |
|
| 1498 | - elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
| 1565 | + } elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
| 1499 | 1566 | { |
| 1500 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
| 1501 | - $becomesApproved = false; |
|
| 1502 | - |
|
| 1503 | - else |
|
| 1504 | - isAllowedTo('post_reply_any'); |
|
| 1505 | - } |
|
| 1506 | - elseif (!allowedTo('post_reply_any')) |
|
| 1567 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
| 1568 | + $becomesApproved = false; |
|
| 1569 | + } else { |
|
| 1570 | + isAllowedTo('post_reply_any'); |
|
| 1571 | + } |
|
| 1572 | + } elseif (!allowedTo('post_reply_any')) |
|
| 1507 | 1573 | { |
| 1508 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
|
| 1509 | - $becomesApproved = false; |
|
| 1510 | - |
|
| 1511 | - else |
|
| 1512 | - isAllowedTo('post_reply_own'); |
|
| 1574 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) { |
|
| 1575 | + $becomesApproved = false; |
|
| 1576 | + } else { |
|
| 1577 | + isAllowedTo('post_reply_own'); |
|
| 1578 | + } |
|
| 1513 | 1579 | } |
| 1514 | 1580 | |
| 1515 | 1581 | if (isset($_POST['lock'])) |
| 1516 | 1582 | { |
| 1517 | 1583 | // Nothing is changed to the lock. |
| 1518 | - if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
| 1519 | - unset($_POST['lock']); |
|
| 1584 | + if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
| 1585 | + unset($_POST['lock']); |
|
| 1586 | + } |
|
| 1520 | 1587 | |
| 1521 | 1588 | // You're have no permission to lock this topic. |
| 1522 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
| 1523 | - unset($_POST['lock']); |
|
| 1589 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
| 1590 | + unset($_POST['lock']); |
|
| 1591 | + } |
|
| 1524 | 1592 | |
| 1525 | 1593 | // You are allowed to (un)lock your own topic only. |
| 1526 | 1594 | elseif (!allowedTo('lock_any')) |
| 1527 | 1595 | { |
| 1528 | 1596 | // You cannot override a moderator lock. |
| 1529 | - if ($topic_info['locked'] == 1) |
|
| 1530 | - unset($_POST['lock']); |
|
| 1531 | - |
|
| 1532 | - else |
|
| 1533 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1597 | + if ($topic_info['locked'] == 1) { |
|
| 1598 | + unset($_POST['lock']); |
|
| 1599 | + } else { |
|
| 1600 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1601 | + } |
|
| 1534 | 1602 | } |
| 1535 | 1603 | // Hail mighty moderator, (un)lock this topic immediately. |
| 1536 | 1604 | else |
@@ -1538,19 +1606,21 @@ discard block |
||
| 1538 | 1606 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
| 1539 | 1607 | |
| 1540 | 1608 | // Did someone (un)lock this while you were posting? |
| 1541 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
| 1542 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1609 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
| 1610 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1611 | + } |
|
| 1543 | 1612 | } |
| 1544 | 1613 | } |
| 1545 | 1614 | |
| 1546 | 1615 | // So you wanna (un)sticky this...let's see. |
| 1547 | - if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
|
| 1548 | - unset($_POST['sticky']); |
|
| 1549 | - elseif (isset($_POST['sticky'])) |
|
| 1616 | + if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) { |
|
| 1617 | + unset($_POST['sticky']); |
|
| 1618 | + } elseif (isset($_POST['sticky'])) |
|
| 1550 | 1619 | { |
| 1551 | 1620 | // Did someone (un)sticky this while you were posting? |
| 1552 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
| 1553 | - $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
| 1621 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
| 1622 | + $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
| 1623 | + } |
|
| 1554 | 1624 | } |
| 1555 | 1625 | |
| 1556 | 1626 | // If drafts are enabled, then pass this off |
@@ -1577,26 +1647,31 @@ discard block |
||
| 1577 | 1647 | |
| 1578 | 1648 | // Do like, the permissions, for safety and stuff... |
| 1579 | 1649 | $becomesApproved = true; |
| 1580 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
| 1581 | - $becomesApproved = false; |
|
| 1582 | - else |
|
| 1583 | - isAllowedTo('post_new'); |
|
| 1650 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
| 1651 | + $becomesApproved = false; |
|
| 1652 | + } else { |
|
| 1653 | + isAllowedTo('post_new'); |
|
| 1654 | + } |
|
| 1584 | 1655 | |
| 1585 | 1656 | if (isset($_POST['lock'])) |
| 1586 | 1657 | { |
| 1587 | 1658 | // New topics are by default not locked. |
| 1588 | - if (empty($_POST['lock'])) |
|
| 1589 | - unset($_POST['lock']); |
|
| 1659 | + if (empty($_POST['lock'])) { |
|
| 1660 | + unset($_POST['lock']); |
|
| 1661 | + } |
|
| 1590 | 1662 | // Besides, you need permission. |
| 1591 | - elseif (!allowedTo(array('lock_any', 'lock_own'))) |
|
| 1592 | - unset($_POST['lock']); |
|
| 1663 | + elseif (!allowedTo(array('lock_any', 'lock_own'))) { |
|
| 1664 | + unset($_POST['lock']); |
|
| 1665 | + } |
|
| 1593 | 1666 | // A moderator-lock (1) can override a user-lock (2). |
| 1594 | - else |
|
| 1595 | - $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
| 1667 | + else { |
|
| 1668 | + $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
| 1669 | + } |
|
| 1596 | 1670 | } |
| 1597 | 1671 | |
| 1598 | - if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
|
| 1599 | - unset($_POST['sticky']); |
|
| 1672 | + if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) { |
|
| 1673 | + unset($_POST['sticky']); |
|
| 1674 | + } |
|
| 1600 | 1675 | |
| 1601 | 1676 | // Saving your new topic as a draft first? |
| 1602 | 1677 | if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft'])) |
@@ -1621,31 +1696,37 @@ discard block |
||
| 1621 | 1696 | 'id_msg' => $_REQUEST['msg'], |
| 1622 | 1697 | ) |
| 1623 | 1698 | ); |
| 1624 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1625 | - fatal_lang_error('cant_find_messages', false); |
|
| 1699 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1700 | + fatal_lang_error('cant_find_messages', false); |
|
| 1701 | + } |
|
| 1626 | 1702 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1627 | 1703 | $smcFunc['db_free_result']($request); |
| 1628 | 1704 | |
| 1629 | - if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
|
| 1630 | - fatal_lang_error('topic_locked', false); |
|
| 1705 | + if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) { |
|
| 1706 | + fatal_lang_error('topic_locked', false); |
|
| 1707 | + } |
|
| 1631 | 1708 | |
| 1632 | 1709 | if (isset($_POST['lock'])) |
| 1633 | 1710 | { |
| 1634 | 1711 | // Nothing changes to the lock status. |
| 1635 | - if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
| 1636 | - unset($_POST['lock']); |
|
| 1712 | + if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
| 1713 | + unset($_POST['lock']); |
|
| 1714 | + } |
|
| 1637 | 1715 | // You're simply not allowed to (un)lock this. |
| 1638 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
| 1639 | - unset($_POST['lock']); |
|
| 1716 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
| 1717 | + unset($_POST['lock']); |
|
| 1718 | + } |
|
| 1640 | 1719 | // You're only allowed to lock your own topics. |
| 1641 | 1720 | elseif (!allowedTo('lock_any')) |
| 1642 | 1721 | { |
| 1643 | 1722 | // You're not allowed to break a moderator's lock. |
| 1644 | - if ($topic_info['locked'] == 1) |
|
| 1645 | - unset($_POST['lock']); |
|
| 1723 | + if ($topic_info['locked'] == 1) { |
|
| 1724 | + unset($_POST['lock']); |
|
| 1725 | + } |
|
| 1646 | 1726 | // Lock it with a soft lock or unlock it. |
| 1647 | - else |
|
| 1648 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1727 | + else { |
|
| 1728 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1729 | + } |
|
| 1649 | 1730 | } |
| 1650 | 1731 | // You must be the moderator. |
| 1651 | 1732 | else |
@@ -1653,44 +1734,46 @@ discard block |
||
| 1653 | 1734 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
| 1654 | 1735 | |
| 1655 | 1736 | // Did someone (un)lock this while you were posting? |
| 1656 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
| 1657 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1737 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
| 1738 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1739 | + } |
|
| 1658 | 1740 | } |
| 1659 | 1741 | } |
| 1660 | 1742 | |
| 1661 | 1743 | // Change the sticky status of this topic? |
| 1662 | - if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
|
| 1663 | - unset($_POST['sticky']); |
|
| 1664 | - elseif (isset($_POST['sticky'])) |
|
| 1744 | + if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) { |
|
| 1745 | + unset($_POST['sticky']); |
|
| 1746 | + } elseif (isset($_POST['sticky'])) |
|
| 1665 | 1747 | { |
| 1666 | 1748 | // Did someone (un)sticky this while you were posting? |
| 1667 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
| 1668 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
| 1749 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
| 1750 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
| 1751 | + } |
|
| 1669 | 1752 | } |
| 1670 | 1753 | |
| 1671 | 1754 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 1672 | 1755 | { |
| 1673 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 1674 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 1675 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 1676 | - isAllowedTo('modify_replies'); |
|
| 1677 | - else |
|
| 1678 | - isAllowedTo('modify_own'); |
|
| 1679 | - } |
|
| 1680 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 1756 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 1757 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 1758 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 1759 | + isAllowedTo('modify_replies'); |
|
| 1760 | + } else { |
|
| 1761 | + isAllowedTo('modify_own'); |
|
| 1762 | + } |
|
| 1763 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 1681 | 1764 | { |
| 1682 | 1765 | isAllowedTo('modify_replies'); |
| 1683 | 1766 | |
| 1684 | 1767 | // If you're modifying a reply, I say it better be logged... |
| 1685 | 1768 | $moderationAction = true; |
| 1686 | - } |
|
| 1687 | - else |
|
| 1769 | + } else |
|
| 1688 | 1770 | { |
| 1689 | 1771 | isAllowedTo('modify_any'); |
| 1690 | 1772 | |
| 1691 | 1773 | // Log it, assuming you're not modifying your own post. |
| 1692 | - if ($row['id_member'] != $user_info['id']) |
|
| 1693 | - $moderationAction = true; |
|
| 1774 | + if ($row['id_member'] != $user_info['id']) { |
|
| 1775 | + $moderationAction = true; |
|
| 1776 | + } |
|
| 1694 | 1777 | } |
| 1695 | 1778 | |
| 1696 | 1779 | // If drafts are enabled, then lets send this off to save |
@@ -1727,20 +1810,24 @@ discard block |
||
| 1727 | 1810 | $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']); |
| 1728 | 1811 | $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
| 1729 | 1812 | |
| 1730 | - if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
|
| 1731 | - $post_errors[] = 'no_name'; |
|
| 1732 | - if ($smcFunc['strlen']($_POST['guestname']) > 25) |
|
| 1733 | - $post_errors[] = 'long_name'; |
|
| 1813 | + if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') { |
|
| 1814 | + $post_errors[] = 'no_name'; |
|
| 1815 | + } |
|
| 1816 | + if ($smcFunc['strlen']($_POST['guestname']) > 25) { |
|
| 1817 | + $post_errors[] = 'long_name'; |
|
| 1818 | + } |
|
| 1734 | 1819 | |
| 1735 | 1820 | if (empty($modSettings['guest_post_no_email'])) |
| 1736 | 1821 | { |
| 1737 | 1822 | // Only check if they changed it! |
| 1738 | 1823 | if (!isset($row) || $row['poster_email'] != $_POST['email']) |
| 1739 | 1824 | { |
| 1740 | - if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) |
|
| 1741 | - $post_errors[] = 'no_email'; |
|
| 1742 | - if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) |
|
| 1743 | - $post_errors[] = 'bad_email'; |
|
| 1825 | + if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) { |
|
| 1826 | + $post_errors[] = 'no_email'; |
|
| 1827 | + } |
|
| 1828 | + if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
| 1829 | + $post_errors[] = 'bad_email'; |
|
| 1830 | + } |
|
| 1744 | 1831 | } |
| 1745 | 1832 | |
| 1746 | 1833 | // Now make sure this email address is not banned from posting. |
@@ -1756,75 +1843,89 @@ discard block |
||
| 1756 | 1843 | } |
| 1757 | 1844 | |
| 1758 | 1845 | // Coming from the quickReply? |
| 1759 | - if (isset($_POST['quickReply'])) |
|
| 1760 | - $_POST['message'] = $_POST['quickReply']; |
|
| 1846 | + if (isset($_POST['quickReply'])) { |
|
| 1847 | + $_POST['message'] = $_POST['quickReply']; |
|
| 1848 | + } |
|
| 1761 | 1849 | |
| 1762 | 1850 | // Check the subject and message. |
| 1763 | - if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') |
|
| 1764 | - $post_errors[] = 'no_subject'; |
|
| 1765 | - if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') |
|
| 1766 | - $post_errors[] = 'no_message'; |
|
| 1767 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 1768 | - $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
| 1769 | - else |
|
| 1851 | + if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') { |
|
| 1852 | + $post_errors[] = 'no_subject'; |
|
| 1853 | + } |
|
| 1854 | + if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') { |
|
| 1855 | + $post_errors[] = 'no_message'; |
|
| 1856 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) { |
|
| 1857 | + $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
| 1858 | + } else |
|
| 1770 | 1859 | { |
| 1771 | 1860 | // Prepare the message a bit for some additional testing. |
| 1772 | 1861 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
| 1773 | 1862 | |
| 1774 | 1863 | // Preparse code. (Zef) |
| 1775 | - if ($user_info['is_guest']) |
|
| 1776 | - $user_info['name'] = $_POST['guestname']; |
|
| 1864 | + if ($user_info['is_guest']) { |
|
| 1865 | + $user_info['name'] = $_POST['guestname']; |
|
| 1866 | + } |
|
| 1777 | 1867 | preparsecode($_POST['message']); |
| 1778 | 1868 | |
| 1779 | 1869 | // Let's see if there's still some content left without the tags. |
| 1780 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
|
| 1781 | - $post_errors[] = 'no_message'; |
|
| 1870 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) { |
|
| 1871 | + $post_errors[] = 'no_message'; |
|
| 1872 | + } |
|
| 1873 | + } |
|
| 1874 | + if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
| 1875 | + $post_errors[] = 'no_event'; |
|
| 1782 | 1876 | } |
| 1783 | - if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
| 1784 | - $post_errors[] = 'no_event'; |
|
| 1785 | 1877 | // You are not! |
| 1786 | - if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) |
|
| 1787 | - fatal_error('Knave! Masquerader! Charlatan!', false); |
|
| 1878 | + if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) { |
|
| 1879 | + fatal_error('Knave! Masquerader! Charlatan!', false); |
|
| 1880 | + } |
|
| 1788 | 1881 | |
| 1789 | 1882 | // Validate the poll... |
| 1790 | 1883 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
| 1791 | 1884 | { |
| 1792 | - if (!empty($topic) && !isset($_REQUEST['msg'])) |
|
| 1793 | - fatal_lang_error('no_access', false); |
|
| 1885 | + if (!empty($topic) && !isset($_REQUEST['msg'])) { |
|
| 1886 | + fatal_lang_error('no_access', false); |
|
| 1887 | + } |
|
| 1794 | 1888 | |
| 1795 | 1889 | // This is a new topic... so it's a new poll. |
| 1796 | - if (empty($topic)) |
|
| 1797 | - isAllowedTo('poll_post'); |
|
| 1890 | + if (empty($topic)) { |
|
| 1891 | + isAllowedTo('poll_post'); |
|
| 1892 | + } |
|
| 1798 | 1893 | // Can you add to your own topics? |
| 1799 | - elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) |
|
| 1800 | - isAllowedTo('poll_add_own'); |
|
| 1894 | + elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) { |
|
| 1895 | + isAllowedTo('poll_add_own'); |
|
| 1896 | + } |
|
| 1801 | 1897 | // Can you add polls to any topic, then? |
| 1802 | - else |
|
| 1803 | - isAllowedTo('poll_add_any'); |
|
| 1898 | + else { |
|
| 1899 | + isAllowedTo('poll_add_any'); |
|
| 1900 | + } |
|
| 1804 | 1901 | |
| 1805 | - if (!isset($_POST['question']) || trim($_POST['question']) == '') |
|
| 1806 | - $post_errors[] = 'no_question'; |
|
| 1902 | + if (!isset($_POST['question']) || trim($_POST['question']) == '') { |
|
| 1903 | + $post_errors[] = 'no_question'; |
|
| 1904 | + } |
|
| 1807 | 1905 | |
| 1808 | 1906 | $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']); |
| 1809 | 1907 | |
| 1810 | 1908 | // Get rid of empty ones. |
| 1811 | - foreach ($_POST['options'] as $k => $option) |
|
| 1812 | - if ($option == '') |
|
| 1909 | + foreach ($_POST['options'] as $k => $option) { |
|
| 1910 | + if ($option == '') |
|
| 1813 | 1911 | unset($_POST['options'][$k], $_POST['options'][$k]); |
| 1912 | + } |
|
| 1814 | 1913 | |
| 1815 | 1914 | // What are you going to vote between with one choice?!? |
| 1816 | - if (count($_POST['options']) < 2) |
|
| 1817 | - $post_errors[] = 'poll_few'; |
|
| 1818 | - elseif (count($_POST['options']) > 256) |
|
| 1819 | - $post_errors[] = 'poll_many'; |
|
| 1915 | + if (count($_POST['options']) < 2) { |
|
| 1916 | + $post_errors[] = 'poll_few'; |
|
| 1917 | + } elseif (count($_POST['options']) > 256) { |
|
| 1918 | + $post_errors[] = 'poll_many'; |
|
| 1919 | + } |
|
| 1820 | 1920 | } |
| 1821 | 1921 | |
| 1822 | 1922 | if ($posterIsGuest) |
| 1823 | 1923 | { |
| 1824 | 1924 | // If user is a guest, make sure the chosen name isn't taken. |
| 1825 | 1925 | require_once($sourcedir . '/Subs-Members.php'); |
| 1826 | - if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) |
|
| 1827 | - $post_errors[] = 'bad_name'; |
|
| 1926 | + if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) { |
|
| 1927 | + $post_errors[] = 'bad_name'; |
|
| 1928 | + } |
|
| 1828 | 1929 | } |
| 1829 | 1930 | // If the user isn't a guest, get his or her name and email. |
| 1830 | 1931 | elseif (!isset($_REQUEST['msg'])) |
@@ -1855,8 +1956,9 @@ discard block |
||
| 1855 | 1956 | } |
| 1856 | 1957 | |
| 1857 | 1958 | // Make sure the user isn't spamming the board. |
| 1858 | - if (!isset($_REQUEST['msg'])) |
|
| 1859 | - spamProtection('post'); |
|
| 1959 | + if (!isset($_REQUEST['msg'])) { |
|
| 1960 | + spamProtection('post'); |
|
| 1961 | + } |
|
| 1860 | 1962 | |
| 1861 | 1963 | // At about this point, we're posting and that's that. |
| 1862 | 1964 | ignore_user_abort(true); |
@@ -1869,32 +1971,36 @@ discard block |
||
| 1869 | 1971 | $_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
| 1870 | 1972 | |
| 1871 | 1973 | // At this point, we want to make sure the subject isn't too long. |
| 1872 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
| 1873 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 1974 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
| 1975 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 1976 | + } |
|
| 1874 | 1977 | |
| 1875 | 1978 | // Same with the "why did you edit this" text. |
| 1876 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
| 1877 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 1979 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
| 1980 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 1981 | + } |
|
| 1878 | 1982 | |
| 1879 | 1983 | // Make the poll... |
| 1880 | 1984 | if (isset($_REQUEST['poll'])) |
| 1881 | 1985 | { |
| 1882 | 1986 | // Make sure that the user has not entered a ridiculous number of options.. |
| 1883 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
| 1884 | - $_POST['poll_max_votes'] = 1; |
|
| 1885 | - elseif ($_POST['poll_max_votes'] > count($_POST['options'])) |
|
| 1886 | - $_POST['poll_max_votes'] = count($_POST['options']); |
|
| 1887 | - else |
|
| 1888 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 1987 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
| 1988 | + $_POST['poll_max_votes'] = 1; |
|
| 1989 | + } elseif ($_POST['poll_max_votes'] > count($_POST['options'])) { |
|
| 1990 | + $_POST['poll_max_votes'] = count($_POST['options']); |
|
| 1991 | + } else { |
|
| 1992 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 1993 | + } |
|
| 1889 | 1994 | |
| 1890 | 1995 | $_POST['poll_expire'] = (int) $_POST['poll_expire']; |
| 1891 | 1996 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
| 1892 | 1997 | |
| 1893 | 1998 | // Just set it to zero if it's not there.. |
| 1894 | - if (!isset($_POST['poll_hide'])) |
|
| 1895 | - $_POST['poll_hide'] = 0; |
|
| 1896 | - else |
|
| 1897 | - $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
| 1999 | + if (!isset($_POST['poll_hide'])) { |
|
| 2000 | + $_POST['poll_hide'] = 0; |
|
| 2001 | + } else { |
|
| 2002 | + $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
| 2003 | + } |
|
| 1898 | 2004 | $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0; |
| 1899 | 2005 | |
| 1900 | 2006 | $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0; |
@@ -1903,16 +2009,19 @@ discard block |
||
| 1903 | 2009 | { |
| 1904 | 2010 | require_once($sourcedir . '/Subs-Members.php'); |
| 1905 | 2011 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
| 1906 | - if (!in_array(-1, $allowedVoteGroups['allowed'])) |
|
| 1907 | - $_POST['poll_guest_vote'] = 0; |
|
| 2012 | + if (!in_array(-1, $allowedVoteGroups['allowed'])) { |
|
| 2013 | + $_POST['poll_guest_vote'] = 0; |
|
| 2014 | + } |
|
| 1908 | 2015 | } |
| 1909 | 2016 | |
| 1910 | 2017 | // If the user tries to set the poll too far in advance, don't let them. |
| 1911 | - if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) |
|
| 1912 | - fatal_lang_error('poll_range_error', false); |
|
| 2018 | + if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) { |
|
| 2019 | + fatal_lang_error('poll_range_error', false); |
|
| 2020 | + } |
|
| 1913 | 2021 | // Don't allow them to select option 2 for hidden results if it's not time limited. |
| 1914 | - elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
| 1915 | - $_POST['poll_hide'] = 1; |
|
| 2022 | + elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
| 2023 | + $_POST['poll_hide'] = 1; |
|
| 2024 | + } |
|
| 1916 | 2025 | |
| 1917 | 2026 | // Clean up the question and answers. |
| 1918 | 2027 | $_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']); |
@@ -1926,13 +2035,15 @@ discard block |
||
| 1926 | 2035 | { |
| 1927 | 2036 | $attachIDs = array(); |
| 1928 | 2037 | $attach_errors = array(); |
| 1929 | - if (!empty($context['we_are_history'])) |
|
| 1930 | - $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
| 2038 | + if (!empty($context['we_are_history'])) { |
|
| 2039 | + $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
| 2040 | + } |
|
| 1931 | 2041 | |
| 1932 | 2042 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 1933 | 2043 | { |
| 1934 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 1935 | - continue; |
|
| 2044 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 2045 | + continue; |
|
| 2046 | + } |
|
| 1936 | 2047 | |
| 1937 | 2048 | // If there was an initial error just show that message. |
| 1938 | 2049 | if ($attachID == 'initial_error') |
@@ -1961,12 +2072,13 @@ discard block |
||
| 1961 | 2072 | if (createAttachment($attachmentOptions)) |
| 1962 | 2073 | { |
| 1963 | 2074 | $attachIDs[] = $attachmentOptions['id']; |
| 1964 | - if (!empty($attachmentOptions['thumb'])) |
|
| 1965 | - $attachIDs[] = $attachmentOptions['thumb']; |
|
| 2075 | + if (!empty($attachmentOptions['thumb'])) { |
|
| 2076 | + $attachIDs[] = $attachmentOptions['thumb']; |
|
| 2077 | + } |
|
| 1966 | 2078 | } |
| 2079 | + } else { |
|
| 2080 | + $attach_errors[] = '<dt> </dt>'; |
|
| 1967 | 2081 | } |
| 1968 | - else |
|
| 1969 | - $attach_errors[] = '<dt> </dt>'; |
|
| 1970 | 2082 | |
| 1971 | 2083 | if (!empty($attachmentOptions['errors'])) |
| 1972 | 2084 | { |
@@ -1978,14 +2090,16 @@ discard block |
||
| 1978 | 2090 | if (!is_array($error)) |
| 1979 | 2091 | { |
| 1980 | 2092 | $attach_errors[] = '<dd>' . $txt[$error] . '</dd>'; |
| 1981 | - if (in_array($error, $log_these)) |
|
| 1982 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 2093 | + if (in_array($error, $log_these)) { |
|
| 2094 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 2095 | + } |
|
| 2096 | + } else { |
|
| 2097 | + $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
| 1983 | 2098 | } |
| 1984 | - else |
|
| 1985 | - $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
| 1986 | 2099 | } |
| 1987 | - if (file_exists($attachment['tmp_name'])) |
|
| 1988 | - unlink($attachment['tmp_name']); |
|
| 2100 | + if (file_exists($attachment['tmp_name'])) { |
|
| 2101 | + unlink($attachment['tmp_name']); |
|
| 2102 | + } |
|
| 1989 | 2103 | } |
| 1990 | 2104 | } |
| 1991 | 2105 | unset($_SESSION['temp_attachments']); |
@@ -2026,24 +2140,24 @@ discard block |
||
| 2026 | 2140 | ); |
| 2027 | 2141 | |
| 2028 | 2142 | call_integration_hook('integrate_poll_add_edit', array($id_poll, false)); |
| 2143 | + } else { |
|
| 2144 | + $id_poll = 0; |
|
| 2029 | 2145 | } |
| 2030 | - else |
|
| 2031 | - $id_poll = 0; |
|
| 2032 | 2146 | |
| 2033 | 2147 | // Creating a new topic? |
| 2034 | 2148 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
| 2035 | 2149 | |
| 2036 | 2150 | // Check the icon. |
| 2037 | - if (!isset($_POST['icon'])) |
|
| 2038 | - $_POST['icon'] = 'xx'; |
|
| 2039 | - |
|
| 2040 | - else |
|
| 2151 | + if (!isset($_POST['icon'])) { |
|
| 2152 | + $_POST['icon'] = 'xx'; |
|
| 2153 | + } else |
|
| 2041 | 2154 | { |
| 2042 | 2155 | $_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']); |
| 2043 | 2156 | |
| 2044 | 2157 | // Need to figure it out if this is a valid icon name. |
| 2045 | - if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) |
|
| 2046 | - $_POST['icon'] = 'xx'; |
|
| 2158 | + if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) { |
|
| 2159 | + $_POST['icon'] = 'xx'; |
|
| 2160 | + } |
|
| 2047 | 2161 | } |
| 2048 | 2162 | |
| 2049 | 2163 | // Collect all parameters for the creation or modification of a post. |
@@ -2084,8 +2198,9 @@ discard block |
||
| 2084 | 2198 | } |
| 2085 | 2199 | |
| 2086 | 2200 | // This will save some time... |
| 2087 | - if (empty($approve_has_changed)) |
|
| 2088 | - unset($msgOptions['approved']); |
|
| 2201 | + if (empty($approve_has_changed)) { |
|
| 2202 | + unset($msgOptions['approved']); |
|
| 2203 | + } |
|
| 2089 | 2204 | |
| 2090 | 2205 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 2091 | 2206 | } |
@@ -2094,8 +2209,9 @@ discard block |
||
| 2094 | 2209 | { |
| 2095 | 2210 | createPost($msgOptions, $topicOptions, $posterOptions); |
| 2096 | 2211 | |
| 2097 | - if (isset($topicOptions['id'])) |
|
| 2098 | - $topic = $topicOptions['id']; |
|
| 2212 | + if (isset($topicOptions['id'])) { |
|
| 2213 | + $topic = $topicOptions['id']; |
|
| 2214 | + } |
|
| 2099 | 2215 | } |
| 2100 | 2216 | |
| 2101 | 2217 | // Assign the previously uploaded attachments to the brand new message. |
@@ -2107,8 +2223,9 @@ discard block |
||
| 2107 | 2223 | } |
| 2108 | 2224 | |
| 2109 | 2225 | // If we had a draft for this, its time to remove it since it was just posted |
| 2110 | - if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) |
|
| 2111 | - DeleteDraft($_POST['id_draft']); |
|
| 2226 | + if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) { |
|
| 2227 | + DeleteDraft($_POST['id_draft']); |
|
| 2228 | + } |
|
| 2112 | 2229 | |
| 2113 | 2230 | // Editing or posting an event? |
| 2114 | 2231 | if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) |
@@ -2127,8 +2244,7 @@ discard block |
||
| 2127 | 2244 | 'member' => $user_info['id'], |
| 2128 | 2245 | ); |
| 2129 | 2246 | insertEvent($eventOptions); |
| 2130 | - } |
|
| 2131 | - elseif (isset($_POST['calendar'])) |
|
| 2247 | + } elseif (isset($_POST['calendar'])) |
|
| 2132 | 2248 | { |
| 2133 | 2249 | $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
| 2134 | 2250 | |
@@ -2156,14 +2272,15 @@ discard block |
||
| 2156 | 2272 | } |
| 2157 | 2273 | |
| 2158 | 2274 | // Delete it? |
| 2159 | - if (isset($_REQUEST['deleteevent'])) |
|
| 2160 | - $smcFunc['db_query']('', ' |
|
| 2275 | + if (isset($_REQUEST['deleteevent'])) { |
|
| 2276 | + $smcFunc['db_query']('', ' |
|
| 2161 | 2277 | DELETE FROM {db_prefix}calendar |
| 2162 | 2278 | WHERE id_event = {int:id_event}', |
| 2163 | 2279 | array( |
| 2164 | 2280 | 'id_event' => $_REQUEST['eventid'], |
| 2165 | 2281 | ) |
| 2166 | 2282 | ); |
| 2283 | + } |
|
| 2167 | 2284 | // ... or just update it? |
| 2168 | 2285 | else |
| 2169 | 2286 | { |
@@ -2205,9 +2322,8 @@ discard block |
||
| 2205 | 2322 | array($user_info['id'], $topic, 0), |
| 2206 | 2323 | array('id_member', 'id_topic', 'id_board') |
| 2207 | 2324 | ); |
| 2208 | - } |
|
| 2209 | - elseif (!$newTopic) |
|
| 2210 | - $smcFunc['db_query']('', ' |
|
| 2325 | + } elseif (!$newTopic) { |
|
| 2326 | + $smcFunc['db_query']('', ' |
|
| 2211 | 2327 | DELETE FROM {db_prefix}log_notify |
| 2212 | 2328 | WHERE id_member = {int:current_member} |
| 2213 | 2329 | AND id_topic = {int:current_topic}', |
@@ -2216,16 +2332,20 @@ discard block |
||
| 2216 | 2332 | 'current_topic' => $topic, |
| 2217 | 2333 | ) |
| 2218 | 2334 | ); |
| 2335 | + } |
|
| 2219 | 2336 | |
| 2220 | 2337 | // Log an act of moderation - modifying. |
| 2221 | - if (!empty($moderationAction)) |
|
| 2222 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 2338 | + if (!empty($moderationAction)) { |
|
| 2339 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 2340 | + } |
|
| 2223 | 2341 | |
| 2224 | - if (isset($_POST['lock']) && $_POST['lock'] != 2) |
|
| 2225 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2342 | + if (isset($_POST['lock']) && $_POST['lock'] != 2) { |
|
| 2343 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2344 | + } |
|
| 2226 | 2345 | |
| 2227 | - if (isset($_POST['sticky'])) |
|
| 2228 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2346 | + if (isset($_POST['sticky'])) { |
|
| 2347 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2348 | + } |
|
| 2229 | 2349 | |
| 2230 | 2350 | // Returning to the topic? |
| 2231 | 2351 | if (!empty($_REQUEST['goback'])) |
@@ -2244,26 +2364,31 @@ discard block |
||
| 2244 | 2364 | ); |
| 2245 | 2365 | } |
| 2246 | 2366 | |
| 2247 | - if ($board_info['num_topics'] == 0) |
|
| 2248 | - cache_put_data('board-' . $board, null, 120); |
|
| 2367 | + if ($board_info['num_topics'] == 0) { |
|
| 2368 | + cache_put_data('board-' . $board, null, 120); |
|
| 2369 | + } |
|
| 2249 | 2370 | |
| 2250 | 2371 | call_integration_hook('integrate_post2_end'); |
| 2251 | 2372 | |
| 2252 | - if (!empty($_POST['announce_topic'])) |
|
| 2253 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2373 | + if (!empty($_POST['announce_topic'])) { |
|
| 2374 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2375 | + } |
|
| 2254 | 2376 | |
| 2255 | - if (!empty($_POST['move']) && allowedTo('move_any')) |
|
| 2256 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2377 | + if (!empty($_POST['move']) && allowedTo('move_any')) { |
|
| 2378 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2379 | + } |
|
| 2257 | 2380 | |
| 2258 | 2381 | // Return to post if the mod is on. |
| 2259 | - if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
|
| 2260 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 2261 | - elseif (!empty($_REQUEST['goback'])) |
|
| 2262 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 2382 | + if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) { |
|
| 2383 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 2384 | + } elseif (!empty($_REQUEST['goback'])) { |
|
| 2385 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 2386 | + } |
|
| 2263 | 2387 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
| 2264 | - else |
|
| 2265 | - redirectexit('board=' . $board . '.0'); |
|
| 2266 | -} |
|
| 2388 | + else { |
|
| 2389 | + redirectexit('board=' . $board . '.0'); |
|
| 2390 | + } |
|
| 2391 | + } |
|
| 2267 | 2392 | |
| 2268 | 2393 | /** |
| 2269 | 2394 | * Handle the announce topic function (action=announce). |
@@ -2281,8 +2406,9 @@ discard block |
||
| 2281 | 2406 | |
| 2282 | 2407 | validateSession(); |
| 2283 | 2408 | |
| 2284 | - if (empty($topic)) |
|
| 2285 | - fatal_lang_error('topic_gone', false); |
|
| 2409 | + if (empty($topic)) { |
|
| 2410 | + fatal_lang_error('topic_gone', false); |
|
| 2411 | + } |
|
| 2286 | 2412 | |
| 2287 | 2413 | loadLanguage('Post'); |
| 2288 | 2414 | loadTemplate('Post'); |
@@ -2309,8 +2435,9 @@ discard block |
||
| 2309 | 2435 | global $txt, $context, $topic, $board_info, $smcFunc; |
| 2310 | 2436 | |
| 2311 | 2437 | $groups = array_merge($board_info['groups'], array(1)); |
| 2312 | - foreach ($groups as $id => $group) |
|
| 2313 | - $groups[$id] = (int) $group; |
|
| 2438 | + foreach ($groups as $id => $group) { |
|
| 2439 | + $groups[$id] = (int) $group; |
|
| 2440 | + } |
|
| 2314 | 2441 | |
| 2315 | 2442 | $context['groups'] = array(); |
| 2316 | 2443 | if (in_array(0, $groups)) |
@@ -2353,8 +2480,9 @@ discard block |
||
| 2353 | 2480 | 'group_list' => $groups, |
| 2354 | 2481 | ) |
| 2355 | 2482 | ); |
| 2356 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2357 | - $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
| 2483 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2484 | + $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
| 2485 | + } |
|
| 2358 | 2486 | $smcFunc['db_free_result']($request); |
| 2359 | 2487 | |
| 2360 | 2488 | // Get the subject of the topic we're about to announce. |
@@ -2396,16 +2524,19 @@ discard block |
||
| 2396 | 2524 | $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
| 2397 | 2525 | $groups = array_merge($board_info['groups'], array(1)); |
| 2398 | 2526 | |
| 2399 | - if (isset($_POST['membergroups'])) |
|
| 2400 | - $_POST['who'] = explode(',', $_POST['membergroups']); |
|
| 2527 | + if (isset($_POST['membergroups'])) { |
|
| 2528 | + $_POST['who'] = explode(',', $_POST['membergroups']); |
|
| 2529 | + } |
|
| 2401 | 2530 | |
| 2402 | 2531 | // Check whether at least one membergroup was selected. |
| 2403 | - if (empty($_POST['who'])) |
|
| 2404 | - fatal_lang_error('no_membergroup_selected'); |
|
| 2532 | + if (empty($_POST['who'])) { |
|
| 2533 | + fatal_lang_error('no_membergroup_selected'); |
|
| 2534 | + } |
|
| 2405 | 2535 | |
| 2406 | 2536 | // Make sure all membergroups are integers and can access the board of the announcement. |
| 2407 | - foreach ($_POST['who'] as $id => $mg) |
|
| 2408 | - $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
| 2537 | + foreach ($_POST['who'] as $id => $mg) { |
|
| 2538 | + $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
| 2539 | + } |
|
| 2409 | 2540 | |
| 2410 | 2541 | // Get the topic subject and censor it. |
| 2411 | 2542 | $request = $smcFunc['db_query']('', ' |
@@ -2451,12 +2582,13 @@ discard block |
||
| 2451 | 2582 | if ($smcFunc['db_num_rows']($request) == 0) |
| 2452 | 2583 | { |
| 2453 | 2584 | logAction('announce_topic', array('topic' => $topic), 'user'); |
| 2454 | - if (!empty($_REQUEST['move']) && allowedTo('move_any')) |
|
| 2455 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2456 | - elseif (!empty($_REQUEST['goback'])) |
|
| 2457 | - redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
| 2458 | - else |
|
| 2459 | - redirectexit('board=' . $board . '.0'); |
|
| 2585 | + if (!empty($_REQUEST['move']) && allowedTo('move_any')) { |
|
| 2586 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2587 | + } elseif (!empty($_REQUEST['goback'])) { |
|
| 2588 | + redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
| 2589 | + } else { |
|
| 2590 | + redirectexit('board=' . $board . '.0'); |
|
| 2591 | + } |
|
| 2460 | 2592 | } |
| 2461 | 2593 | |
| 2462 | 2594 | $announcements = array(); |
@@ -2475,8 +2607,9 @@ discard block |
||
| 2475 | 2607 | foreach ($rows as $row) |
| 2476 | 2608 | { |
| 2477 | 2609 | // Force them to have it? |
| 2478 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
| 2479 | - continue; |
|
| 2610 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
| 2611 | + continue; |
|
| 2612 | + } |
|
| 2480 | 2613 | |
| 2481 | 2614 | $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; |
| 2482 | 2615 | |
@@ -2504,8 +2637,9 @@ discard block |
||
| 2504 | 2637 | } |
| 2505 | 2638 | |
| 2506 | 2639 | // For each language send a different mail - low priority... |
| 2507 | - foreach ($announcements as $lang => $mail) |
|
| 2508 | - sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
| 2640 | + foreach ($announcements as $lang => $mail) { |
|
| 2641 | + sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
| 2642 | + } |
|
| 2509 | 2643 | |
| 2510 | 2644 | $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1); |
| 2511 | 2645 | |
@@ -2515,9 +2649,10 @@ discard block |
||
| 2515 | 2649 | $context['sub_template'] = 'announcement_send'; |
| 2516 | 2650 | |
| 2517 | 2651 | // Go back to the correct language for the user ;). |
| 2518 | - if (!empty($modSettings['userLanguage'])) |
|
| 2519 | - loadLanguage('Post'); |
|
| 2520 | -} |
|
| 2652 | + if (!empty($modSettings['userLanguage'])) { |
|
| 2653 | + loadLanguage('Post'); |
|
| 2654 | + } |
|
| 2655 | + } |
|
| 2521 | 2656 | |
| 2522 | 2657 | /** |
| 2523 | 2658 | * Get the topic for display purposes. |
@@ -2530,12 +2665,13 @@ discard block |
||
| 2530 | 2665 | { |
| 2531 | 2666 | global $topic, $modSettings, $context, $smcFunc, $counter, $options; |
| 2532 | 2667 | |
| 2533 | - if (isset($_REQUEST['xml'])) |
|
| 2534 | - $limit = ' |
|
| 2668 | + if (isset($_REQUEST['xml'])) { |
|
| 2669 | + $limit = ' |
|
| 2535 | 2670 | LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']); |
| 2536 | - else |
|
| 2537 | - $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
| 2671 | + } else { |
|
| 2672 | + $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
| 2538 | 2673 | LIMIT ' . (int) $modSettings['topicSummaryPosts']; |
| 2674 | + } |
|
| 2539 | 2675 | |
| 2540 | 2676 | // If you're modifying, get only those posts before the current one. (otherwise get all.) |
| 2541 | 2677 | $request = $smcFunc['db_query']('', ' |
@@ -2573,8 +2709,9 @@ discard block |
||
| 2573 | 2709 | 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']), |
| 2574 | 2710 | ); |
| 2575 | 2711 | |
| 2576 | - if (!empty($context['new_replies'])) |
|
| 2577 | - $context['new_replies']--; |
|
| 2712 | + if (!empty($context['new_replies'])) { |
|
| 2713 | + $context['new_replies']--; |
|
| 2714 | + } |
|
| 2578 | 2715 | } |
| 2579 | 2716 | $smcFunc['db_free_result']($request); |
| 2580 | 2717 | } |
@@ -2591,8 +2728,9 @@ discard block |
||
| 2591 | 2728 | global $sourcedir, $smcFunc; |
| 2592 | 2729 | |
| 2593 | 2730 | loadLanguage('Post'); |
| 2594 | - if (!isset($_REQUEST['xml'])) |
|
| 2595 | - loadTemplate('Post'); |
|
| 2731 | + if (!isset($_REQUEST['xml'])) { |
|
| 2732 | + loadTemplate('Post'); |
|
| 2733 | + } |
|
| 2596 | 2734 | |
| 2597 | 2735 | include_once($sourcedir . '/Subs-Post.php'); |
| 2598 | 2736 | |
@@ -2623,8 +2761,9 @@ discard block |
||
| 2623 | 2761 | $smcFunc['db_free_result']($request); |
| 2624 | 2762 | |
| 2625 | 2763 | $context['sub_template'] = 'quotefast'; |
| 2626 | - if (!empty($row)) |
|
| 2627 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 2764 | + if (!empty($row)) { |
|
| 2765 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 2766 | + } |
|
| 2628 | 2767 | |
| 2629 | 2768 | if (!empty($can_view_post)) |
| 2630 | 2769 | { |
@@ -2657,8 +2796,9 @@ discard block |
||
| 2657 | 2796 | } |
| 2658 | 2797 | |
| 2659 | 2798 | // Remove any nested quotes. |
| 2660 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 2661 | - $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
| 2799 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 2800 | + $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
| 2801 | + } |
|
| 2662 | 2802 | |
| 2663 | 2803 | $lb = "\n"; |
| 2664 | 2804 | |
@@ -2684,14 +2824,14 @@ discard block |
||
| 2684 | 2824 | 'time' => '', |
| 2685 | 2825 | ), |
| 2686 | 2826 | ); |
| 2687 | - } |
|
| 2688 | - else |
|
| 2689 | - $context['quote'] = array( |
|
| 2827 | + } else { |
|
| 2828 | + $context['quote'] = array( |
|
| 2690 | 2829 | 'xml' => '', |
| 2691 | 2830 | 'mozilla' => '', |
| 2692 | 2831 | 'text' => '', |
| 2693 | 2832 | ); |
| 2694 | -} |
|
| 2833 | + } |
|
| 2834 | + } |
|
| 2695 | 2835 | |
| 2696 | 2836 | /** |
| 2697 | 2837 | * Used to edit the body or subject of a message inline |
@@ -2703,8 +2843,9 @@ discard block |
||
| 2703 | 2843 | global $user_info, $context, $smcFunc, $language, $board_info; |
| 2704 | 2844 | |
| 2705 | 2845 | // We have to have a topic! |
| 2706 | - if (empty($topic)) |
|
| 2707 | - obExit(false); |
|
| 2846 | + if (empty($topic)) { |
|
| 2847 | + obExit(false); |
|
| 2848 | + } |
|
| 2708 | 2849 | |
| 2709 | 2850 | checkSession('get'); |
| 2710 | 2851 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -2730,31 +2871,35 @@ discard block |
||
| 2730 | 2871 | 'guest_id' => 0, |
| 2731 | 2872 | ) |
| 2732 | 2873 | ); |
| 2733 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 2734 | - fatal_lang_error('no_board', false); |
|
| 2874 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 2875 | + fatal_lang_error('no_board', false); |
|
| 2876 | + } |
|
| 2735 | 2877 | $row = $smcFunc['db_fetch_assoc']($request); |
| 2736 | 2878 | $smcFunc['db_free_result']($request); |
| 2737 | 2879 | |
| 2738 | 2880 | // Change either body or subject requires permissions to modify messages. |
| 2739 | 2881 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
| 2740 | 2882 | { |
| 2741 | - if (!empty($row['locked'])) |
|
| 2742 | - isAllowedTo('moderate_board'); |
|
| 2883 | + if (!empty($row['locked'])) { |
|
| 2884 | + isAllowedTo('moderate_board'); |
|
| 2885 | + } |
|
| 2743 | 2886 | |
| 2744 | 2887 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 2745 | 2888 | { |
| 2746 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 2747 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 2748 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 2749 | - isAllowedTo('modify_replies'); |
|
| 2750 | - else |
|
| 2751 | - isAllowedTo('modify_own'); |
|
| 2889 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 2890 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 2891 | + } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 2892 | + isAllowedTo('modify_replies'); |
|
| 2893 | + } else { |
|
| 2894 | + isAllowedTo('modify_own'); |
|
| 2895 | + } |
|
| 2752 | 2896 | } |
| 2753 | 2897 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
| 2754 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 2755 | - isAllowedTo('modify_replies'); |
|
| 2756 | - else |
|
| 2757 | - isAllowedTo('modify_any'); |
|
| 2898 | + elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 2899 | + isAllowedTo('modify_replies'); |
|
| 2900 | + } else { |
|
| 2901 | + isAllowedTo('modify_any'); |
|
| 2902 | + } |
|
| 2758 | 2903 | |
| 2759 | 2904 | // Only log this action if it wasn't your message. |
| 2760 | 2905 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -2766,10 +2911,10 @@ discard block |
||
| 2766 | 2911 | $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => '')); |
| 2767 | 2912 | |
| 2768 | 2913 | // Maximum number of characters. |
| 2769 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
| 2770 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2771 | - } |
|
| 2772 | - elseif (isset($_POST['subject'])) |
|
| 2914 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
| 2915 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2916 | + } |
|
| 2917 | + } elseif (isset($_POST['subject'])) |
|
| 2773 | 2918 | { |
| 2774 | 2919 | $post_errors[] = 'no_subject'; |
| 2775 | 2920 | unset($_POST['subject']); |
@@ -2781,13 +2926,11 @@ discard block |
||
| 2781 | 2926 | { |
| 2782 | 2927 | $post_errors[] = 'no_message'; |
| 2783 | 2928 | unset($_POST['message']); |
| 2784 | - } |
|
| 2785 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 2929 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 2786 | 2930 | { |
| 2787 | 2931 | $post_errors[] = 'long_message'; |
| 2788 | 2932 | unset($_POST['message']); |
| 2789 | - } |
|
| 2790 | - else |
|
| 2933 | + } else |
|
| 2791 | 2934 | { |
| 2792 | 2935 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
| 2793 | 2936 | |
@@ -2803,31 +2946,34 @@ discard block |
||
| 2803 | 2946 | |
| 2804 | 2947 | if (isset($_POST['lock'])) |
| 2805 | 2948 | { |
| 2806 | - if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) |
|
| 2807 | - unset($_POST['lock']); |
|
| 2808 | - elseif (!allowedTo('lock_any')) |
|
| 2949 | + if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) { |
|
| 2950 | + unset($_POST['lock']); |
|
| 2951 | + } elseif (!allowedTo('lock_any')) |
|
| 2809 | 2952 | { |
| 2810 | - if ($row['locked'] == 1) |
|
| 2811 | - unset($_POST['lock']); |
|
| 2812 | - else |
|
| 2813 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 2953 | + if ($row['locked'] == 1) { |
|
| 2954 | + unset($_POST['lock']); |
|
| 2955 | + } else { |
|
| 2956 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 2957 | + } |
|
| 2958 | + } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) { |
|
| 2959 | + unset($_POST['lock']); |
|
| 2960 | + } else { |
|
| 2961 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
| 2814 | 2962 | } |
| 2815 | - elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) |
|
| 2816 | - unset($_POST['lock']); |
|
| 2817 | - else |
|
| 2818 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
| 2819 | 2963 | } |
| 2820 | 2964 | |
| 2821 | - if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
|
| 2822 | - unset($_POST['sticky']); |
|
| 2965 | + if (isset($_POST['sticky']) && !allowedTo('make_sticky')) { |
|
| 2966 | + unset($_POST['sticky']); |
|
| 2967 | + } |
|
| 2823 | 2968 | |
| 2824 | 2969 | if (isset($_POST['modify_reason'])) |
| 2825 | 2970 | { |
| 2826 | 2971 | $_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
| 2827 | 2972 | |
| 2828 | 2973 | // Maximum number of characters. |
| 2829 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
| 2830 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 2974 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
| 2975 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 2976 | + } |
|
| 2831 | 2977 | } |
| 2832 | 2978 | |
| 2833 | 2979 | if (empty($post_errors)) |
@@ -2864,8 +3010,9 @@ discard block |
||
| 2864 | 3010 | } |
| 2865 | 3011 | } |
| 2866 | 3012 | // If nothing was changed there's no need to add an entry to the moderation log. |
| 2867 | - else |
|
| 2868 | - $moderationAction = false; |
|
| 3013 | + else { |
|
| 3014 | + $moderationAction = false; |
|
| 3015 | + } |
|
| 2869 | 3016 | |
| 2870 | 3017 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 2871 | 3018 | |
@@ -2883,9 +3030,9 @@ discard block |
||
| 2883 | 3030 | // Get the proper (default language) response prefix first. |
| 2884 | 3031 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 2885 | 3032 | { |
| 2886 | - if ($language === $user_info['language']) |
|
| 2887 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 2888 | - else |
|
| 3033 | + if ($language === $user_info['language']) { |
|
| 3034 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 3035 | + } else |
|
| 2889 | 3036 | { |
| 2890 | 3037 | loadLanguage('index', $language, false); |
| 2891 | 3038 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -2907,8 +3054,9 @@ discard block |
||
| 2907 | 3054 | ); |
| 2908 | 3055 | } |
| 2909 | 3056 | |
| 2910 | - if (!empty($moderationAction)) |
|
| 2911 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 3057 | + if (!empty($moderationAction)) { |
|
| 3058 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 3059 | + } |
|
| 2912 | 3060 | } |
| 2913 | 3061 | |
| 2914 | 3062 | if (isset($_REQUEST['xml'])) |
@@ -2949,8 +3097,7 @@ discard block |
||
| 2949 | 3097 | ); |
| 2950 | 3098 | |
| 2951 | 3099 | censorText($context['message']['subject']); |
| 2952 | - } |
|
| 2953 | - else |
|
| 3100 | + } else |
|
| 2954 | 3101 | { |
| 2955 | 3102 | $context['message'] = array( |
| 2956 | 3103 | 'id' => $row['id_msg'], |
@@ -2962,15 +3109,16 @@ discard block |
||
| 2962 | 3109 | loadLanguage('Errors'); |
| 2963 | 3110 | foreach ($post_errors as $post_error) |
| 2964 | 3111 | { |
| 2965 | - if ($post_error == 'long_message') |
|
| 2966 | - $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
| 2967 | - else |
|
| 2968 | - $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
| 3112 | + if ($post_error == 'long_message') { |
|
| 3113 | + $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
| 3114 | + } else { |
|
| 3115 | + $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
| 3116 | + } |
|
| 2969 | 3117 | } |
| 2970 | 3118 | } |
| 3119 | + } else { |
|
| 3120 | + obExit(false); |
|
| 3121 | + } |
|
| 2971 | 3122 | } |
| 2972 | - else |
|
| 2973 | - obExit(false); |
|
| 2974 | -} |
|
| 2975 | 3123 | |
| 2976 | 3124 | ?> |
| 2977 | 3125 | \ No newline at end of file |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Our Cache API class |
@@ -27,8 +28,9 @@ discard block |
||
| 27 | 28 | { |
| 28 | 29 | $supported = function_exists('apc_fetch') && function_exists('apc_store'); |
| 29 | 30 | |
| 30 | - if ($test) |
|
| 31 | - return $supported; |
|
| 31 | + if ($test) { |
|
| 32 | + return $supported; |
|
| 33 | + } |
|
| 32 | 34 | return parent::isSupported() && $supported; |
| 33 | 35 | } |
| 34 | 36 | |
@@ -50,10 +52,11 @@ discard block |
||
| 50 | 52 | $key = $this->prefix . strtr($key, ':/', '-_'); |
| 51 | 53 | |
| 52 | 54 | // An extended key is needed to counteract a bug in APC. |
| 53 | - if ($value === null) |
|
| 54 | - return apc_delete($key . 'smf'); |
|
| 55 | - else |
|
| 56 | - return apc_store($key . 'smf', $value, $ttl); |
|
| 55 | + if ($value === null) { |
|
| 56 | + return apc_delete($key . 'smf'); |
|
| 57 | + } else { |
|
| 58 | + return apc_store($key . 'smf', $value, $ttl); |
|
| 59 | + } |
|
| 57 | 60 | } |
| 58 | 61 | |
| 59 | 62 | /** |
@@ -67,9 +70,9 @@ discard block |
||
| 67 | 70 | // Always returns true. |
| 68 | 71 | apc_clear_cache('user'); |
| 69 | 72 | apc_clear_cache('system'); |
| 73 | + } elseif ($type === 'user') { |
|
| 74 | + apc_clear_cache('user'); |
|
| 70 | 75 | } |
| 71 | - elseif ($type === 'user') |
|
| 72 | - apc_clear_cache('user'); |
|
| 73 | 76 | |
| 74 | 77 | $this->invalidateCache(); |
| 75 | 78 | return true; |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 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 | * Update some basic statistics. |
@@ -122,10 +123,11 @@ discard block |
||
| 122 | 123 | $smcFunc['db_free_result']($result); |
| 123 | 124 | |
| 124 | 125 | // Add this to the number of unapproved members |
| 125 | - if (!empty($changes['unapprovedMembers'])) |
|
| 126 | - $changes['unapprovedMembers'] += $coppa_approvals; |
|
| 127 | - else |
|
| 128 | - $changes['unapprovedMembers'] = $coppa_approvals; |
|
| 126 | + if (!empty($changes['unapprovedMembers'])) { |
|
| 127 | + $changes['unapprovedMembers'] += $coppa_approvals; |
|
| 128 | + } else { |
|
| 129 | + $changes['unapprovedMembers'] = $coppa_approvals; |
|
| 130 | + } |
|
| 129 | 131 | } |
| 130 | 132 | } |
| 131 | 133 | } |
@@ -133,9 +135,9 @@ discard block |
||
| 133 | 135 | break; |
| 134 | 136 | |
| 135 | 137 | case 'message': |
| 136 | - if ($parameter1 === true && $parameter2 !== null) |
|
| 137 | - updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true); |
|
| 138 | - else |
|
| 138 | + if ($parameter1 === true && $parameter2 !== null) { |
|
| 139 | + updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true); |
|
| 140 | + } else |
|
| 139 | 141 | { |
| 140 | 142 | // SUM and MAX on a smaller table is better for InnoDB tables. |
| 141 | 143 | $result = $smcFunc['db_query']('', ' |
@@ -175,23 +177,25 @@ discard block |
||
| 175 | 177 | $parameter2 = text2words($parameter2); |
| 176 | 178 | |
| 177 | 179 | $inserts = array(); |
| 178 | - foreach ($parameter2 as $word) |
|
| 179 | - $inserts[] = array($word, $parameter1); |
|
| 180 | + foreach ($parameter2 as $word) { |
|
| 181 | + $inserts[] = array($word, $parameter1); |
|
| 182 | + } |
|
| 180 | 183 | |
| 181 | - if (!empty($inserts)) |
|
| 182 | - $smcFunc['db_insert']('ignore', |
|
| 184 | + if (!empty($inserts)) { |
|
| 185 | + $smcFunc['db_insert']('ignore', |
|
| 183 | 186 | '{db_prefix}log_search_subjects', |
| 184 | 187 | array('word' => 'string', 'id_topic' => 'int'), |
| 185 | 188 | $inserts, |
| 186 | 189 | array('word', 'id_topic') |
| 187 | 190 | ); |
| 191 | + } |
|
| 188 | 192 | } |
| 189 | 193 | break; |
| 190 | 194 | |
| 191 | 195 | case 'topic': |
| 192 | - if ($parameter1 === true) |
|
| 193 | - updateSettings(array('totalTopics' => true), true); |
|
| 194 | - else |
|
| 196 | + if ($parameter1 === true) { |
|
| 197 | + updateSettings(array('totalTopics' => true), true); |
|
| 198 | + } else |
|
| 195 | 199 | { |
| 196 | 200 | // Get the number of topics - a SUM is better for InnoDB tables. |
| 197 | 201 | // We also ignore the recycle bin here because there will probably be a bunch of one-post topics there. |
@@ -212,8 +216,9 @@ discard block |
||
| 212 | 216 | |
| 213 | 217 | case 'postgroups': |
| 214 | 218 | // Parameter two is the updated columns: we should check to see if we base groups off any of these. |
| 215 | - if ($parameter2 !== null && !in_array('posts', $parameter2)) |
|
| 216 | - return; |
|
| 219 | + if ($parameter2 !== null && !in_array('posts', $parameter2)) { |
|
| 220 | + return; |
|
| 221 | + } |
|
| 217 | 222 | |
| 218 | 223 | $postgroups = cache_get_data('updateStats:postgroups', 360); |
| 219 | 224 | if ($postgroups == null || $parameter1 == null) |
@@ -228,8 +233,9 @@ discard block |
||
| 228 | 233 | ) |
| 229 | 234 | ); |
| 230 | 235 | $postgroups = array(); |
| 231 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 232 | - $postgroups[$row['id_group']] = $row['min_posts']; |
|
| 236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 237 | + $postgroups[$row['id_group']] = $row['min_posts']; |
|
| 238 | + } |
|
| 233 | 239 | $smcFunc['db_free_result']($request); |
| 234 | 240 | |
| 235 | 241 | // Sort them this way because if it's done with MySQL it causes a filesort :(. |
@@ -239,8 +245,9 @@ discard block |
||
| 239 | 245 | } |
| 240 | 246 | |
| 241 | 247 | // Oh great, they've screwed their post groups. |
| 242 | - if (empty($postgroups)) |
|
| 243 | - return; |
|
| 248 | + if (empty($postgroups)) { |
|
| 249 | + return; |
|
| 250 | + } |
|
| 244 | 251 | |
| 245 | 252 | // Set all membergroups from most posts to least posts. |
| 246 | 253 | $conditions = ''; |
@@ -298,10 +305,9 @@ discard block |
||
| 298 | 305 | { |
| 299 | 306 | $condition = 'id_member IN ({array_int:members})'; |
| 300 | 307 | $parameters['members'] = $members; |
| 301 | - } |
|
| 302 | - elseif ($members === null) |
|
| 303 | - $condition = '1=1'; |
|
| 304 | - else |
|
| 308 | + } elseif ($members === null) { |
|
| 309 | + $condition = '1=1'; |
|
| 310 | + } else |
|
| 305 | 311 | { |
| 306 | 312 | $condition = 'id_member = {int:member}'; |
| 307 | 313 | $parameters['member'] = $members; |
@@ -341,9 +347,9 @@ discard block |
||
| 341 | 347 | if (count($vars_to_integrate) != 0) |
| 342 | 348 | { |
| 343 | 349 | // Fetch a list of member_names if necessary |
| 344 | - if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) |
|
| 345 | - $member_names = array($user_info['username']); |
|
| 346 | - else |
|
| 350 | + if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) { |
|
| 351 | + $member_names = array($user_info['username']); |
|
| 352 | + } else |
|
| 347 | 353 | { |
| 348 | 354 | $member_names = array(); |
| 349 | 355 | $request = $smcFunc['db_query']('', ' |
@@ -352,14 +358,16 @@ discard block |
||
| 352 | 358 | WHERE ' . $condition, |
| 353 | 359 | $parameters |
| 354 | 360 | ); |
| 355 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 356 | - $member_names[] = $row['member_name']; |
|
| 361 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 362 | + $member_names[] = $row['member_name']; |
|
| 363 | + } |
|
| 357 | 364 | $smcFunc['db_free_result']($request); |
| 358 | 365 | } |
| 359 | 366 | |
| 360 | - if (!empty($member_names)) |
|
| 361 | - foreach ($vars_to_integrate as $var) |
|
| 367 | + if (!empty($member_names)) { |
|
| 368 | + foreach ($vars_to_integrate as $var) |
|
| 362 | 369 | call_integration_hook('integrate_change_member_data', array($member_names, $var, &$data[$var], &$knownInts, &$knownFloats)); |
| 370 | + } |
|
| 363 | 371 | } |
| 364 | 372 | } |
| 365 | 373 | |
@@ -367,16 +375,17 @@ discard block |
||
| 367 | 375 | foreach ($data as $var => $val) |
| 368 | 376 | { |
| 369 | 377 | $type = 'string'; |
| 370 | - if (in_array($var, $knownInts)) |
|
| 371 | - $type = 'int'; |
|
| 372 | - elseif (in_array($var, $knownFloats)) |
|
| 373 | - $type = 'float'; |
|
| 374 | - elseif ($var == 'birthdate') |
|
| 375 | - $type = 'date'; |
|
| 376 | - elseif ($var == 'member_ip') |
|
| 377 | - $type = 'inet'; |
|
| 378 | - elseif ($var == 'member_ip2') |
|
| 379 | - $type = 'inet'; |
|
| 378 | + if (in_array($var, $knownInts)) { |
|
| 379 | + $type = 'int'; |
|
| 380 | + } elseif (in_array($var, $knownFloats)) { |
|
| 381 | + $type = 'float'; |
|
| 382 | + } elseif ($var == 'birthdate') { |
|
| 383 | + $type = 'date'; |
|
| 384 | + } elseif ($var == 'member_ip') { |
|
| 385 | + $type = 'inet'; |
|
| 386 | + } elseif ($var == 'member_ip2') { |
|
| 387 | + $type = 'inet'; |
|
| 388 | + } |
|
| 380 | 389 | |
| 381 | 390 | // Doing an increment? |
| 382 | 391 | if ($type == 'int' && ($val === '+' || $val === '-')) |
@@ -390,8 +399,9 @@ discard block |
||
| 390 | 399 | { |
| 391 | 400 | if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match)) |
| 392 | 401 | { |
| 393 | - if ($match[1] != '+ ') |
|
| 394 | - $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
| 402 | + if ($match[1] != '+ ') { |
|
| 403 | + $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
| 404 | + } |
|
| 395 | 405 | $type = 'raw'; |
| 396 | 406 | } |
| 397 | 407 | } |
@@ -412,8 +422,9 @@ discard block |
||
| 412 | 422 | // Clear any caching? |
| 413 | 423 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !empty($members)) |
| 414 | 424 | { |
| 415 | - if (!is_array($members)) |
|
| 416 | - $members = array($members); |
|
| 425 | + if (!is_array($members)) { |
|
| 426 | + $members = array($members); |
|
| 427 | + } |
|
| 417 | 428 | |
| 418 | 429 | foreach ($members as $member) |
| 419 | 430 | { |
@@ -446,29 +457,32 @@ discard block |
||
| 446 | 457 | { |
| 447 | 458 | global $modSettings, $smcFunc; |
| 448 | 459 | |
| 449 | - if (empty($changeArray) || !is_array($changeArray)) |
|
| 450 | - return; |
|
| 460 | + if (empty($changeArray) || !is_array($changeArray)) { |
|
| 461 | + return; |
|
| 462 | + } |
|
| 451 | 463 | |
| 452 | 464 | $toRemove = array(); |
| 453 | 465 | |
| 454 | 466 | // Go check if there is any setting to be removed. |
| 455 | - foreach ($changeArray as $k => $v) |
|
| 456 | - if ($v === null) |
|
| 467 | + foreach ($changeArray as $k => $v) { |
|
| 468 | + if ($v === null) |
|
| 457 | 469 | { |
| 458 | 470 | // Found some, remove them from the original array and add them to ours. |
| 459 | 471 | unset($changeArray[$k]); |
| 472 | + } |
|
| 460 | 473 | $toRemove[] = $k; |
| 461 | 474 | } |
| 462 | 475 | |
| 463 | 476 | // Proceed with the deletion. |
| 464 | - if (!empty($toRemove)) |
|
| 465 | - $smcFunc['db_query']('', ' |
|
| 477 | + if (!empty($toRemove)) { |
|
| 478 | + $smcFunc['db_query']('', ' |
|
| 466 | 479 | DELETE FROM {db_prefix}settings |
| 467 | 480 | WHERE variable IN ({array_string:remove})', |
| 468 | 481 | array( |
| 469 | 482 | 'remove' => $toRemove, |
| 470 | 483 | ) |
| 471 | 484 | ); |
| 485 | + } |
|
| 472 | 486 | |
| 473 | 487 | // In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs. |
| 474 | 488 | if ($update) |
@@ -497,19 +511,22 @@ discard block |
||
| 497 | 511 | foreach ($changeArray as $variable => $value) |
| 498 | 512 | { |
| 499 | 513 | // Don't bother if it's already like that ;). |
| 500 | - if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) |
|
| 501 | - continue; |
|
| 514 | + if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) { |
|
| 515 | + continue; |
|
| 516 | + } |
|
| 502 | 517 | // If the variable isn't set, but would only be set to nothing'ness, then don't bother setting it. |
| 503 | - elseif (!isset($modSettings[$variable]) && empty($value)) |
|
| 504 | - continue; |
|
| 518 | + elseif (!isset($modSettings[$variable]) && empty($value)) { |
|
| 519 | + continue; |
|
| 520 | + } |
|
| 505 | 521 | |
| 506 | 522 | $replaceArray[] = array($variable, $value); |
| 507 | 523 | |
| 508 | 524 | $modSettings[$variable] = $value; |
| 509 | 525 | } |
| 510 | 526 | |
| 511 | - if (empty($replaceArray)) |
|
| 512 | - return; |
|
| 527 | + if (empty($replaceArray)) { |
|
| 528 | + return; |
|
| 529 | + } |
|
| 513 | 530 | |
| 514 | 531 | $smcFunc['db_insert']('replace', |
| 515 | 532 | '{db_prefix}settings', |
@@ -555,14 +572,17 @@ discard block |
||
| 555 | 572 | $start_invalid = $start < 0; |
| 556 | 573 | |
| 557 | 574 | // Make sure $start is a proper variable - not less than 0. |
| 558 | - if ($start_invalid) |
|
| 559 | - $start = 0; |
|
| 575 | + if ($start_invalid) { |
|
| 576 | + $start = 0; |
|
| 577 | + } |
|
| 560 | 578 | // Not greater than the upper bound. |
| 561 | - elseif ($start >= $max_value) |
|
| 562 | - $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
| 579 | + elseif ($start >= $max_value) { |
|
| 580 | + $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
| 581 | + } |
|
| 563 | 582 | // And it has to be a multiple of $num_per_page! |
| 564 | - else |
|
| 565 | - $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
| 583 | + else { |
|
| 584 | + $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
| 585 | + } |
|
| 566 | 586 | |
| 567 | 587 | $context['current_page'] = $start / $num_per_page; |
| 568 | 588 | |
@@ -592,77 +612,87 @@ discard block |
||
| 592 | 612 | |
| 593 | 613 | // Show all the pages. |
| 594 | 614 | $display_page = 1; |
| 595 | - for ($counter = 0; $counter < $max_value; $counter += $num_per_page) |
|
| 596 | - $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
| 615 | + for ($counter = 0; $counter < $max_value; $counter += $num_per_page) { |
|
| 616 | + $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
| 617 | + } |
|
| 597 | 618 | |
| 598 | 619 | // Show the right arrow. |
| 599 | 620 | $display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page); |
| 600 | - if ($start != $counter - $max_value && !$start_invalid) |
|
| 601 | - $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
| 602 | - } |
|
| 603 | - else |
|
| 621 | + if ($start != $counter - $max_value && !$start_invalid) { |
|
| 622 | + $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
| 623 | + } |
|
| 624 | + } else |
|
| 604 | 625 | { |
| 605 | 626 | // If they didn't enter an odd value, pretend they did. |
| 606 | 627 | $PageContiguous = (int) ($modSettings['compactTopicPagesContiguous'] - ($modSettings['compactTopicPagesContiguous'] % 2)) / 2; |
| 607 | 628 | |
| 608 | 629 | // Show the "prev page" link. (>prev page< 1 ... 6 7 [8] 9 10 ... 15 next page) |
| 609 | - if (!empty($start) && $show_prevnext) |
|
| 610 | - $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
| 611 | - else |
|
| 612 | - $pageindex .= ''; |
|
| 630 | + if (!empty($start) && $show_prevnext) { |
|
| 631 | + $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
| 632 | + } else { |
|
| 633 | + $pageindex .= ''; |
|
| 634 | + } |
|
| 613 | 635 | |
| 614 | 636 | // Show the first page. (prev page >1< ... 6 7 [8] 9 10 ... 15) |
| 615 | - if ($start > $num_per_page * $PageContiguous) |
|
| 616 | - $pageindex .= sprintf($base_link, 0, '1'); |
|
| 637 | + if ($start > $num_per_page * $PageContiguous) { |
|
| 638 | + $pageindex .= sprintf($base_link, 0, '1'); |
|
| 639 | + } |
|
| 617 | 640 | |
| 618 | 641 | // Show the ... after the first page. (prev page 1 >...< 6 7 [8] 9 10 ... 15 next page) |
| 619 | - if ($start > $num_per_page * ($PageContiguous + 1)) |
|
| 620 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 642 | + if ($start > $num_per_page * ($PageContiguous + 1)) { |
|
| 643 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 621 | 644 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
| 622 | 645 | '{FIRST_PAGE}' => $num_per_page, |
| 623 | 646 | '{LAST_PAGE}' => $start - $num_per_page * $PageContiguous, |
| 624 | 647 | '{PER_PAGE}' => $num_per_page, |
| 625 | 648 | )); |
| 649 | + } |
|
| 626 | 650 | |
| 627 | 651 | // Show the pages before the current one. (prev page 1 ... >6 7< [8] 9 10 ... 15 next page) |
| 628 | - for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) |
|
| 629 | - if ($start >= $num_per_page * $nCont) |
|
| 652 | + for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) { |
|
| 653 | + if ($start >= $num_per_page * $nCont) |
|
| 630 | 654 | { |
| 631 | 655 | $tmpStart = $start - $num_per_page * $nCont; |
| 656 | + } |
|
| 632 | 657 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
| 633 | 658 | } |
| 634 | 659 | |
| 635 | 660 | // Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page) |
| 636 | - if (!$start_invalid) |
|
| 637 | - $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
| 638 | - else |
|
| 639 | - $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
| 661 | + if (!$start_invalid) { |
|
| 662 | + $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
| 663 | + } else { |
|
| 664 | + $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
| 665 | + } |
|
| 640 | 666 | |
| 641 | 667 | // Show the pages after the current one... (prev page 1 ... 6 7 [8] >9 10< ... 15 next page) |
| 642 | 668 | $tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page; |
| 643 | - for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) |
|
| 644 | - if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
| 669 | + for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) { |
|
| 670 | + if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
| 645 | 671 | { |
| 646 | 672 | $tmpStart = $start + $num_per_page * $nCont; |
| 673 | + } |
|
| 647 | 674 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
| 648 | 675 | } |
| 649 | 676 | |
| 650 | 677 | // Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page) |
| 651 | - if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) |
|
| 652 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 678 | + if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) { |
|
| 679 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 653 | 680 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
| 654 | 681 | '{FIRST_PAGE}' => $start + $num_per_page * ($PageContiguous + 1), |
| 655 | 682 | '{LAST_PAGE}' => $tmpMaxPages, |
| 656 | 683 | '{PER_PAGE}' => $num_per_page, |
| 657 | 684 | )); |
| 685 | + } |
|
| 658 | 686 | |
| 659 | 687 | // Show the last number in the list. (prev page 1 ... 6 7 [8] 9 10 ... >15< next page) |
| 660 | - if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) |
|
| 661 | - $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
| 688 | + if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) { |
|
| 689 | + $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
| 690 | + } |
|
| 662 | 691 | |
| 663 | 692 | // Show the "next page" link. (prev page 1 ... 6 7 [8] 9 10 ... 15 >next page<) |
| 664 | - if ($start != $tmpMaxPages && $show_prevnext) |
|
| 665 | - $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
| 693 | + if ($start != $tmpMaxPages && $show_prevnext) { |
|
| 694 | + $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
| 695 | + } |
|
| 666 | 696 | } |
| 667 | 697 | $pageindex .= $settings['page_index']['extra_after']; |
| 668 | 698 | |
@@ -688,8 +718,9 @@ discard block |
||
| 688 | 718 | if ($decimal_separator === null) |
| 689 | 719 | { |
| 690 | 720 | // Not set for whatever reason? |
| 691 | - if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) |
|
| 692 | - return $number; |
|
| 721 | + if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) { |
|
| 722 | + return $number; |
|
| 723 | + } |
|
| 693 | 724 | |
| 694 | 725 | // Cache these each load... |
| 695 | 726 | $thousands_separator = $matches[1]; |
@@ -721,17 +752,20 @@ discard block |
||
| 721 | 752 | static $non_twelve_hour; |
| 722 | 753 | |
| 723 | 754 | // Offset the time. |
| 724 | - if (!$offset_type) |
|
| 725 | - $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 755 | + if (!$offset_type) { |
|
| 756 | + $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 757 | + } |
|
| 726 | 758 | // Just the forum offset? |
| 727 | - elseif ($offset_type == 'forum') |
|
| 728 | - $time = $log_time + $modSettings['time_offset'] * 3600; |
|
| 729 | - else |
|
| 730 | - $time = $log_time; |
|
| 759 | + elseif ($offset_type == 'forum') { |
|
| 760 | + $time = $log_time + $modSettings['time_offset'] * 3600; |
|
| 761 | + } else { |
|
| 762 | + $time = $log_time; |
|
| 763 | + } |
|
| 731 | 764 | |
| 732 | 765 | // We can't have a negative date (on Windows, at least.) |
| 733 | - if ($log_time < 0) |
|
| 734 | - $log_time = 0; |
|
| 766 | + if ($log_time < 0) { |
|
| 767 | + $log_time = 0; |
|
| 768 | + } |
|
| 735 | 769 | |
| 736 | 770 | // Today and Yesterday? |
| 737 | 771 | if ($modSettings['todayMod'] >= 1 && $show_today === true) |
@@ -748,46 +782,53 @@ discard block |
||
| 748 | 782 | { |
| 749 | 783 | $h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l'; |
| 750 | 784 | $today_fmt = $h . ':%M' . $s . ' %p'; |
| 785 | + } else { |
|
| 786 | + $today_fmt = '%H:%M' . $s; |
|
| 751 | 787 | } |
| 752 | - else |
|
| 753 | - $today_fmt = '%H:%M' . $s; |
|
| 754 | 788 | |
| 755 | 789 | // Same day of the year, same year.... Today! |
| 756 | - if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) |
|
| 757 | - return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 790 | + if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) { |
|
| 791 | + return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 792 | + } |
|
| 758 | 793 | |
| 759 | 794 | // Day-of-year is one less and same year, or it's the first of the year and that's the last of the year... |
| 760 | - if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) |
|
| 761 | - return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 795 | + if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) { |
|
| 796 | + return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 797 | + } |
|
| 762 | 798 | } |
| 763 | 799 | |
| 764 | 800 | $str = !is_bool($show_today) ? $show_today : $user_info['time_format']; |
| 765 | 801 | |
| 766 | 802 | if (setlocale(LC_TIME, $txt['lang_locale'])) |
| 767 | 803 | { |
| 768 | - if (!isset($non_twelve_hour)) |
|
| 769 | - $non_twelve_hour = trim(strftime('%p')) === ''; |
|
| 770 | - if ($non_twelve_hour && strpos($str, '%p') !== false) |
|
| 771 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 804 | + if (!isset($non_twelve_hour)) { |
|
| 805 | + $non_twelve_hour = trim(strftime('%p')) === ''; |
|
| 806 | + } |
|
| 807 | + if ($non_twelve_hour && strpos($str, '%p') !== false) { |
|
| 808 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 809 | + } |
|
| 772 | 810 | |
| 773 | - foreach (array('%a', '%A', '%b', '%B') as $token) |
|
| 774 | - if (strpos($str, $token) !== false) |
|
| 811 | + foreach (array('%a', '%A', '%b', '%B') as $token) { |
|
| 812 | + if (strpos($str, $token) !== false) |
|
| 775 | 813 | $str = str_replace($token, strftime($token, $time), $str); |
| 776 | - } |
|
| 777 | - else |
|
| 814 | + } |
|
| 815 | + } else |
|
| 778 | 816 | { |
| 779 | 817 | // Do-it-yourself time localization. Fun. |
| 780 | - foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) |
|
| 781 | - if (strpos($str, $token) !== false) |
|
| 818 | + foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) { |
|
| 819 | + if (strpos($str, $token) !== false) |
|
| 782 | 820 | $str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str); |
| 821 | + } |
|
| 783 | 822 | |
| 784 | - if (strpos($str, '%p') !== false) |
|
| 785 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 823 | + if (strpos($str, '%p') !== false) { |
|
| 824 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 825 | + } |
|
| 786 | 826 | } |
| 787 | 827 | |
| 788 | 828 | // Windows doesn't support %e; on some versions, strftime fails altogether if used, so let's prevent that. |
| 789 | - if ($context['server']['is_windows'] && strpos($str, '%e') !== false) |
|
| 790 | - $str = str_replace('%e', ltrim(strftime('%d', $time), '0'), $str); |
|
| 829 | + if ($context['server']['is_windows'] && strpos($str, '%e') !== false) { |
|
| 830 | + $str = str_replace('%e', ltrim(strftime('%d', $time), '0'), $str); |
|
| 831 | + } |
|
| 791 | 832 | |
| 792 | 833 | // Format any other characters.. |
| 793 | 834 | return strftime($str, $time); |
@@ -809,16 +850,19 @@ discard block |
||
| 809 | 850 | static $translation = array(); |
| 810 | 851 | |
| 811 | 852 | // Determine the character set... Default to UTF-8 |
| 812 | - if (empty($context['character_set'])) |
|
| 813 | - $charset = 'UTF-8'; |
|
| 853 | + if (empty($context['character_set'])) { |
|
| 854 | + $charset = 'UTF-8'; |
|
| 855 | + } |
|
| 814 | 856 | // Use ISO-8859-1 in place of non-supported ISO-8859 charsets... |
| 815 | - elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) |
|
| 816 | - $charset = 'ISO-8859-1'; |
|
| 817 | - else |
|
| 818 | - $charset = $context['character_set']; |
|
| 857 | + elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) { |
|
| 858 | + $charset = 'ISO-8859-1'; |
|
| 859 | + } else { |
|
| 860 | + $charset = $context['character_set']; |
|
| 861 | + } |
|
| 819 | 862 | |
| 820 | - if (empty($translation)) |
|
| 821 | - $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
| 863 | + if (empty($translation)) { |
|
| 864 | + $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
| 865 | + } |
|
| 822 | 866 | |
| 823 | 867 | return strtr($string, $translation); |
| 824 | 868 | } |
@@ -840,8 +884,9 @@ discard block |
||
| 840 | 884 | global $smcFunc; |
| 841 | 885 | |
| 842 | 886 | // It was already short enough! |
| 843 | - if ($smcFunc['strlen']($subject) <= $len) |
|
| 844 | - return $subject; |
|
| 887 | + if ($smcFunc['strlen']($subject) <= $len) { |
|
| 888 | + return $subject; |
|
| 889 | + } |
|
| 845 | 890 | |
| 846 | 891 | // Shorten it by the length it was too long, and strip off junk from the end. |
| 847 | 892 | return $smcFunc['substr']($subject, 0, $len) . '...'; |
@@ -860,10 +905,11 @@ discard block |
||
| 860 | 905 | { |
| 861 | 906 | global $user_info, $modSettings; |
| 862 | 907 | |
| 863 | - if ($timestamp === null) |
|
| 864 | - $timestamp = time(); |
|
| 865 | - elseif ($timestamp == 0) |
|
| 866 | - return 0; |
|
| 908 | + if ($timestamp === null) { |
|
| 909 | + $timestamp = time(); |
|
| 910 | + } elseif ($timestamp == 0) { |
|
| 911 | + return 0; |
|
| 912 | + } |
|
| 867 | 913 | |
| 868 | 914 | return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600; |
| 869 | 915 | } |
@@ -892,8 +938,9 @@ discard block |
||
| 892 | 938 | $array[$i] = $array[$j]; |
| 893 | 939 | $array[$j] = $temp; |
| 894 | 940 | |
| 895 | - for ($i = 1; $p[$i] == 0; $i++) |
|
| 896 | - $p[$i] = 1; |
|
| 941 | + for ($i = 1; $p[$i] == 0; $i++) { |
|
| 942 | + $p[$i] = 1; |
|
| 943 | + } |
|
| 897 | 944 | |
| 898 | 945 | $orders[] = $array; |
| 899 | 946 | } |
@@ -925,12 +972,14 @@ discard block |
||
| 925 | 972 | static $disabled; |
| 926 | 973 | |
| 927 | 974 | // Don't waste cycles |
| 928 | - if ($message === '') |
|
| 929 | - return ''; |
|
| 975 | + if ($message === '') { |
|
| 976 | + return ''; |
|
| 977 | + } |
|
| 930 | 978 | |
| 931 | 979 | // Just in case it wasn't determined yet whether UTF-8 is enabled. |
| 932 | - if (!isset($context['utf8'])) |
|
| 933 | - $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
| 980 | + if (!isset($context['utf8'])) { |
|
| 981 | + $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
| 982 | + } |
|
| 934 | 983 | |
| 935 | 984 | // Clean up any cut/paste issues we may have |
| 936 | 985 | $message = sanitizeMSCutPaste($message); |
@@ -942,13 +991,15 @@ discard block |
||
| 942 | 991 | return $message; |
| 943 | 992 | } |
| 944 | 993 | |
| 945 | - if ($smileys !== null && ($smileys == '1' || $smileys == '0')) |
|
| 946 | - $smileys = (bool) $smileys; |
|
| 994 | + if ($smileys !== null && ($smileys == '1' || $smileys == '0')) { |
|
| 995 | + $smileys = (bool) $smileys; |
|
| 996 | + } |
|
| 947 | 997 | |
| 948 | 998 | if (empty($modSettings['enableBBC']) && $message !== false) |
| 949 | 999 | { |
| 950 | - if ($smileys === true) |
|
| 951 | - parsesmileys($message); |
|
| 1000 | + if ($smileys === true) { |
|
| 1001 | + parsesmileys($message); |
|
| 1002 | + } |
|
| 952 | 1003 | |
| 953 | 1004 | return $message; |
| 954 | 1005 | } |
@@ -961,8 +1012,9 @@ discard block |
||
| 961 | 1012 | } |
| 962 | 1013 | |
| 963 | 1014 | // Ensure $modSettings['tld_regex'] contains a valid regex for the autolinker |
| 964 | - if (!empty($modSettings['autoLinkUrls'])) |
|
| 965 | - set_tld_regex(); |
|
| 1015 | + if (!empty($modSettings['autoLinkUrls'])) { |
|
| 1016 | + set_tld_regex(); |
|
| 1017 | + } |
|
| 966 | 1018 | |
| 967 | 1019 | // Allow mods access before entering the main parse_bbc loop |
| 968 | 1020 | call_integration_hook('integrate_pre_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
@@ -976,12 +1028,14 @@ discard block |
||
| 976 | 1028 | |
| 977 | 1029 | $temp = explode(',', strtolower($modSettings['disabledBBC'])); |
| 978 | 1030 | |
| 979 | - foreach ($temp as $tag) |
|
| 980 | - $disabled[trim($tag)] = true; |
|
| 1031 | + foreach ($temp as $tag) { |
|
| 1032 | + $disabled[trim($tag)] = true; |
|
| 1033 | + } |
|
| 981 | 1034 | } |
| 982 | 1035 | |
| 983 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 984 | - $disabled['flash'] = true; |
|
| 1036 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1037 | + $disabled['flash'] = true; |
|
| 1038 | + } |
|
| 985 | 1039 | |
| 986 | 1040 | /* The following bbc are formatted as an array, with keys as follows: |
| 987 | 1041 | |
@@ -1102,8 +1156,9 @@ discard block |
||
| 1102 | 1156 | $returnContext = ''; |
| 1103 | 1157 | |
| 1104 | 1158 | // BBC or the entire attachments feature is disabled |
| 1105 | - if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) |
|
| 1106 | - return $data; |
|
| 1159 | + if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) { |
|
| 1160 | + return $data; |
|
| 1161 | + } |
|
| 1107 | 1162 | |
| 1108 | 1163 | // Save the attach ID. |
| 1109 | 1164 | $attachID = $data; |
@@ -1114,8 +1169,9 @@ discard block |
||
| 1114 | 1169 | $currentAttachment = parseAttachBBC($attachID); |
| 1115 | 1170 | |
| 1116 | 1171 | // parseAttachBBC will return a string ($txt key) rather than diying with a fatal_error. Up to you to decide what to do. |
| 1117 | - if (is_string($currentAttachment)) |
|
| 1118 | - return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
| 1172 | + if (is_string($currentAttachment)) { |
|
| 1173 | + return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
| 1174 | + } |
|
| 1119 | 1175 | |
| 1120 | 1176 | if (!empty($currentAttachment['is_image'])) |
| 1121 | 1177 | { |
@@ -1131,15 +1187,17 @@ discard block |
||
| 1131 | 1187 | $height = ' height="' . $currentAttachment['height'] . '"'; |
| 1132 | 1188 | } |
| 1133 | 1189 | |
| 1134 | - if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
|
| 1135 | - $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>'; |
|
| 1136 | - else |
|
| 1137 | - $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
| 1190 | + if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) { |
|
| 1191 | + $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>'; |
|
| 1192 | + } else { |
|
| 1193 | + $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
| 1194 | + } |
|
| 1138 | 1195 | } |
| 1139 | 1196 | |
| 1140 | 1197 | // No image. Show a link. |
| 1141 | - else |
|
| 1142 | - $returnContext .= $currentAttachment['link']; |
|
| 1198 | + else { |
|
| 1199 | + $returnContext .= $currentAttachment['link']; |
|
| 1200 | + } |
|
| 1143 | 1201 | |
| 1144 | 1202 | // Gotta append what we just did. |
| 1145 | 1203 | $data = $returnContext; |
@@ -1170,8 +1228,9 @@ discard block |
||
| 1170 | 1228 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
| 1171 | 1229 | { |
| 1172 | 1230 | // Do PHP code coloring? |
| 1173 | - if ($php_parts[$php_i] != '<?php') |
|
| 1174 | - continue; |
|
| 1231 | + if ($php_parts[$php_i] != '<?php') { |
|
| 1232 | + continue; |
|
| 1233 | + } |
|
| 1175 | 1234 | |
| 1176 | 1235 | $php_string = ''; |
| 1177 | 1236 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1187,8 +1246,9 @@ discard block |
||
| 1187 | 1246 | $data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data); |
| 1188 | 1247 | |
| 1189 | 1248 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
| 1190 | - if ($context['browser']['is_opera']) |
|
| 1191 | - $data .= ' '; |
|
| 1249 | + if ($context['browser']['is_opera']) { |
|
| 1250 | + $data .= ' '; |
|
| 1251 | + } |
|
| 1192 | 1252 | } |
| 1193 | 1253 | }, |
| 1194 | 1254 | 'block_level' => true, |
@@ -1207,8 +1267,9 @@ discard block |
||
| 1207 | 1267 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
| 1208 | 1268 | { |
| 1209 | 1269 | // Do PHP code coloring? |
| 1210 | - if ($php_parts[$php_i] != '<?php') |
|
| 1211 | - continue; |
|
| 1270 | + if ($php_parts[$php_i] != '<?php') { |
|
| 1271 | + continue; |
|
| 1272 | + } |
|
| 1212 | 1273 | |
| 1213 | 1274 | $php_string = ''; |
| 1214 | 1275 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1224,8 +1285,9 @@ discard block |
||
| 1224 | 1285 | $data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]); |
| 1225 | 1286 | |
| 1226 | 1287 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
| 1227 | - if ($context['browser']['is_opera']) |
|
| 1228 | - $data[0] .= ' '; |
|
| 1288 | + if ($context['browser']['is_opera']) { |
|
| 1289 | + $data[0] .= ' '; |
|
| 1290 | + } |
|
| 1229 | 1291 | } |
| 1230 | 1292 | }, |
| 1231 | 1293 | 'block_level' => true, |
@@ -1263,11 +1325,13 @@ discard block |
||
| 1263 | 1325 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
| 1264 | 1326 | 'validate' => function (&$tag, &$data, $disabled) |
| 1265 | 1327 | { |
| 1266 | - if (isset($disabled['url'])) |
|
| 1267 | - $tag['content'] = '$1'; |
|
| 1328 | + if (isset($disabled['url'])) { |
|
| 1329 | + $tag['content'] = '$1'; |
|
| 1330 | + } |
|
| 1268 | 1331 | $scheme = parse_url($data[0], PHP_URL_SCHEME); |
| 1269 | - if (empty($scheme)) |
|
| 1270 | - $data[0] = '//' . ltrim($data[0], ':/'); |
|
| 1332 | + if (empty($scheme)) { |
|
| 1333 | + $data[0] = '//' . ltrim($data[0], ':/'); |
|
| 1334 | + } |
|
| 1271 | 1335 | }, |
| 1272 | 1336 | 'disabled_content' => '<a href="$1" target="_blank" class="new_win">$1</a>', |
| 1273 | 1337 | ), |
@@ -1281,10 +1345,11 @@ discard block |
||
| 1281 | 1345 | { |
| 1282 | 1346 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
| 1283 | 1347 | |
| 1284 | - if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) |
|
| 1285 | - $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
| 1286 | - else |
|
| 1287 | - $css = ''; |
|
| 1348 | + if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) { |
|
| 1349 | + $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
| 1350 | + } else { |
|
| 1351 | + $css = ''; |
|
| 1352 | + } |
|
| 1288 | 1353 | |
| 1289 | 1354 | $data = $class . $css; |
| 1290 | 1355 | }, |
@@ -1334,14 +1399,16 @@ discard block |
||
| 1334 | 1399 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1335 | 1400 | if ($image_proxy_enabled) |
| 1336 | 1401 | { |
| 1337 | - if (empty($scheme)) |
|
| 1338 | - $data = 'http://' . ltrim($data, ':/'); |
|
| 1402 | + if (empty($scheme)) { |
|
| 1403 | + $data = 'http://' . ltrim($data, ':/'); |
|
| 1404 | + } |
|
| 1339 | 1405 | |
| 1340 | - if ($scheme != 'https') |
|
| 1341 | - $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1406 | + if ($scheme != 'https') { |
|
| 1407 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1408 | + } |
|
| 1409 | + } elseif (empty($scheme)) { |
|
| 1410 | + $data = '//' . ltrim($data, ':/'); |
|
| 1342 | 1411 | } |
| 1343 | - elseif (empty($scheme)) |
|
| 1344 | - $data = '//' . ltrim($data, ':/'); |
|
| 1345 | 1412 | }, |
| 1346 | 1413 | 'disabled_content' => '($1)', |
| 1347 | 1414 | ), |
@@ -1357,14 +1424,16 @@ discard block |
||
| 1357 | 1424 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1358 | 1425 | if ($image_proxy_enabled) |
| 1359 | 1426 | { |
| 1360 | - if (empty($scheme)) |
|
| 1361 | - $data = 'http://' . ltrim($data, ':/'); |
|
| 1427 | + if (empty($scheme)) { |
|
| 1428 | + $data = 'http://' . ltrim($data, ':/'); |
|
| 1429 | + } |
|
| 1362 | 1430 | |
| 1363 | - if ($scheme != 'https') |
|
| 1364 | - $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1431 | + if ($scheme != 'https') { |
|
| 1432 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1433 | + } |
|
| 1434 | + } elseif (empty($scheme)) { |
|
| 1435 | + $data = '//' . ltrim($data, ':/'); |
|
| 1365 | 1436 | } |
| 1366 | - elseif (empty($scheme)) |
|
| 1367 | - $data = '//' . ltrim($data, ':/'); |
|
| 1368 | 1437 | }, |
| 1369 | 1438 | 'disabled_content' => '($1)', |
| 1370 | 1439 | ), |
@@ -1376,8 +1445,9 @@ discard block |
||
| 1376 | 1445 | { |
| 1377 | 1446 | $data = strtr($data, array('<br>' => '')); |
| 1378 | 1447 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1379 | - if (empty($scheme)) |
|
| 1380 | - $data = '//' . ltrim($data, ':/'); |
|
| 1448 | + if (empty($scheme)) { |
|
| 1449 | + $data = '//' . ltrim($data, ':/'); |
|
| 1450 | + } |
|
| 1381 | 1451 | }, |
| 1382 | 1452 | ), |
| 1383 | 1453 | array( |
@@ -1388,13 +1458,14 @@ discard block |
||
| 1388 | 1458 | 'after' => '</a>', |
| 1389 | 1459 | 'validate' => function (&$tag, &$data, $disabled) |
| 1390 | 1460 | { |
| 1391 | - if (substr($data, 0, 1) == '#') |
|
| 1392 | - $data = '#post_' . substr($data, 1); |
|
| 1393 | - else |
|
| 1461 | + if (substr($data, 0, 1) == '#') { |
|
| 1462 | + $data = '#post_' . substr($data, 1); |
|
| 1463 | + } else |
|
| 1394 | 1464 | { |
| 1395 | 1465 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1396 | - if (empty($scheme)) |
|
| 1397 | - $data = '//' . ltrim($data, ':/'); |
|
| 1466 | + if (empty($scheme)) { |
|
| 1467 | + $data = '//' . ltrim($data, ':/'); |
|
| 1468 | + } |
|
| 1398 | 1469 | } |
| 1399 | 1470 | }, |
| 1400 | 1471 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
@@ -1472,8 +1543,9 @@ discard block |
||
| 1472 | 1543 | { |
| 1473 | 1544 | $add_begin = substr(trim($data), 0, 5) != '<?'; |
| 1474 | 1545 | $data = highlight_php_code($add_begin ? '<?php ' . $data . '?>' : $data); |
| 1475 | - if ($add_begin) |
|
| 1476 | - $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
| 1546 | + if ($add_begin) { |
|
| 1547 | + $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
| 1548 | + } |
|
| 1477 | 1549 | } |
| 1478 | 1550 | }, |
| 1479 | 1551 | 'block_level' => false, |
@@ -1604,10 +1676,11 @@ discard block |
||
| 1604 | 1676 | 'content' => '$1', |
| 1605 | 1677 | 'validate' => function (&$tag, &$data, $disabled) |
| 1606 | 1678 | { |
| 1607 | - if (is_numeric($data)) |
|
| 1608 | - $data = timeformat($data); |
|
| 1609 | - else |
|
| 1610 | - $tag['content'] = '[time]$1[/time]'; |
|
| 1679 | + if (is_numeric($data)) { |
|
| 1680 | + $data = timeformat($data); |
|
| 1681 | + } else { |
|
| 1682 | + $tag['content'] = '[time]$1[/time]'; |
|
| 1683 | + } |
|
| 1611 | 1684 | }, |
| 1612 | 1685 | ), |
| 1613 | 1686 | array( |
@@ -1634,8 +1707,9 @@ discard block |
||
| 1634 | 1707 | { |
| 1635 | 1708 | $data = strtr($data, array('<br>' => '')); |
| 1636 | 1709 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1637 | - if (empty($scheme)) |
|
| 1638 | - $data = '//' . ltrim($data, ':/'); |
|
| 1710 | + if (empty($scheme)) { |
|
| 1711 | + $data = '//' . ltrim($data, ':/'); |
|
| 1712 | + } |
|
| 1639 | 1713 | }, |
| 1640 | 1714 | ), |
| 1641 | 1715 | array( |
@@ -1647,8 +1721,9 @@ discard block |
||
| 1647 | 1721 | 'validate' => function (&$tag, &$data, $disabled) |
| 1648 | 1722 | { |
| 1649 | 1723 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1650 | - if (empty($scheme)) |
|
| 1651 | - $data = '//' . ltrim($data, ':/'); |
|
| 1724 | + if (empty($scheme)) { |
|
| 1725 | + $data = '//' . ltrim($data, ':/'); |
|
| 1726 | + } |
|
| 1652 | 1727 | }, |
| 1653 | 1728 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
| 1654 | 1729 | 'disabled_after' => ' ($1)', |
@@ -1668,8 +1743,9 @@ discard block |
||
| 1668 | 1743 | // This is mainly for the bbc manager, so it's easy to add tags above. Custom BBC should be added above this line. |
| 1669 | 1744 | if ($message === false) |
| 1670 | 1745 | { |
| 1671 | - if (isset($temp_bbc)) |
|
| 1672 | - $bbc_codes = $temp_bbc; |
|
| 1746 | + if (isset($temp_bbc)) { |
|
| 1747 | + $bbc_codes = $temp_bbc; |
|
| 1748 | + } |
|
| 1673 | 1749 | usort($codes, function ($a, $b) { |
| 1674 | 1750 | return strcmp($a['tag'], $b['tag']); |
| 1675 | 1751 | }); |
@@ -1689,8 +1765,9 @@ discard block |
||
| 1689 | 1765 | ); |
| 1690 | 1766 | if (!isset($disabled['li']) && !isset($disabled['list'])) |
| 1691 | 1767 | { |
| 1692 | - foreach ($itemcodes as $c => $dummy) |
|
| 1693 | - $bbc_codes[$c] = array(); |
|
| 1768 | + foreach ($itemcodes as $c => $dummy) { |
|
| 1769 | + $bbc_codes[$c] = array(); |
|
| 1770 | + } |
|
| 1694 | 1771 | } |
| 1695 | 1772 | |
| 1696 | 1773 | // Shhhh! |
@@ -1711,12 +1788,14 @@ discard block |
||
| 1711 | 1788 | foreach ($codes as $code) |
| 1712 | 1789 | { |
| 1713 | 1790 | // Make it easier to process parameters later |
| 1714 | - if (!empty($code['parameters'])) |
|
| 1715 | - ksort($code['parameters'], SORT_STRING); |
|
| 1791 | + if (!empty($code['parameters'])) { |
|
| 1792 | + ksort($code['parameters'], SORT_STRING); |
|
| 1793 | + } |
|
| 1716 | 1794 | |
| 1717 | 1795 | // If we are not doing every tag only do ones we are interested in. |
| 1718 | - if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) |
|
| 1719 | - $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
| 1796 | + if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) { |
|
| 1797 | + $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
| 1798 | + } |
|
| 1720 | 1799 | } |
| 1721 | 1800 | $codes = null; |
| 1722 | 1801 | } |
@@ -1727,8 +1806,9 @@ discard block |
||
| 1727 | 1806 | // It's likely this will change if the message is modified. |
| 1728 | 1807 | $cache_key = 'parse:' . $cache_id . '-' . md5(md5($message) . '-' . $smileys . (empty($disabled) ? '' : implode(',', array_keys($disabled))) . json_encode($context['browser']) . $txt['lang_locale'] . $user_info['time_offset'] . $user_info['time_format']); |
| 1729 | 1808 | |
| 1730 | - if (($temp = cache_get_data($cache_key, 240)) != null) |
|
| 1731 | - return $temp; |
|
| 1809 | + if (($temp = cache_get_data($cache_key, 240)) != null) { |
|
| 1810 | + return $temp; |
|
| 1811 | + } |
|
| 1732 | 1812 | |
| 1733 | 1813 | $cache_t = microtime(); |
| 1734 | 1814 | } |
@@ -1760,8 +1840,9 @@ discard block |
||
| 1760 | 1840 | $disabled['flash'] = true; |
| 1761 | 1841 | |
| 1762 | 1842 | // @todo Change maybe? |
| 1763 | - if (!isset($_GET['images'])) |
|
| 1764 | - $disabled['img'] = true; |
|
| 1843 | + if (!isset($_GET['images'])) { |
|
| 1844 | + $disabled['img'] = true; |
|
| 1845 | + } |
|
| 1765 | 1846 | |
| 1766 | 1847 | // @todo Interface/setting to add more? |
| 1767 | 1848 | } |
@@ -1785,8 +1866,9 @@ discard block |
||
| 1785 | 1866 | $pos = isset($matches[0][1]) ? $matches[0][1] : false; |
| 1786 | 1867 | |
| 1787 | 1868 | // Failsafe. |
| 1788 | - if ($pos === false || $last_pos > $pos) |
|
| 1789 | - $pos = strlen($message) + 1; |
|
| 1869 | + if ($pos === false || $last_pos > $pos) { |
|
| 1870 | + $pos = strlen($message) + 1; |
|
| 1871 | + } |
|
| 1790 | 1872 | |
| 1791 | 1873 | // Can't have a one letter smiley, URL, or email! (sorry.) |
| 1792 | 1874 | if ($last_pos < $pos - 1) |
@@ -1805,8 +1887,9 @@ discard block |
||
| 1805 | 1887 | |
| 1806 | 1888 | // <br> should be empty. |
| 1807 | 1889 | $empty_tags = array('br', 'hr'); |
| 1808 | - foreach ($empty_tags as $tag) |
|
| 1809 | - $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '[' . $tag . ' /]', $data); |
|
| 1890 | + foreach ($empty_tags as $tag) { |
|
| 1891 | + $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '[' . $tag . ' /]', $data); |
|
| 1892 | + } |
|
| 1810 | 1893 | |
| 1811 | 1894 | // b, u, i, s, pre... basic tags. |
| 1812 | 1895 | $closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote'); |
@@ -1815,8 +1898,9 @@ discard block |
||
| 1815 | 1898 | $diff = substr_count($data, '<' . $tag . '>') - substr_count($data, '</' . $tag . '>'); |
| 1816 | 1899 | $data = strtr($data, array('<' . $tag . '>' => '<' . $tag . '>', '</' . $tag . '>' => '</' . $tag . '>')); |
| 1817 | 1900 | |
| 1818 | - if ($diff > 0) |
|
| 1819 | - $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
| 1901 | + if ($diff > 0) { |
|
| 1902 | + $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
| 1903 | + } |
|
| 1820 | 1904 | } |
| 1821 | 1905 | |
| 1822 | 1906 | // Do <img ...> - with security... action= -> action-. |
@@ -1829,8 +1913,9 @@ discard block |
||
| 1829 | 1913 | $alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^"|"$~', '', $matches[3][$match]); |
| 1830 | 1914 | |
| 1831 | 1915 | // Remove action= from the URL - no funny business, now. |
| 1832 | - if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) |
|
| 1833 | - $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
| 1916 | + if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) { |
|
| 1917 | + $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
| 1918 | + } |
|
| 1834 | 1919 | |
| 1835 | 1920 | // Check if the image is larger than allowed. |
| 1836 | 1921 | if (!empty($modSettings['max_image_width']) && !empty($modSettings['max_image_height'])) |
@@ -1851,9 +1936,9 @@ discard block |
||
| 1851 | 1936 | |
| 1852 | 1937 | // Set the new image tag. |
| 1853 | 1938 | $replaces[$matches[0][$match]] = '[img width=' . $width . ' height=' . $height . $alt . ']' . $imgtag . '[/img]'; |
| 1939 | + } else { |
|
| 1940 | + $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
| 1854 | 1941 | } |
| 1855 | - else |
|
| 1856 | - $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
| 1857 | 1942 | } |
| 1858 | 1943 | |
| 1859 | 1944 | $data = strtr($data, $replaces); |
@@ -1866,16 +1951,18 @@ discard block |
||
| 1866 | 1951 | $no_autolink_area = false; |
| 1867 | 1952 | if (!empty($open_tags)) |
| 1868 | 1953 | { |
| 1869 | - foreach ($open_tags as $open_tag) |
|
| 1870 | - if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
| 1954 | + foreach ($open_tags as $open_tag) { |
|
| 1955 | + if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
| 1871 | 1956 | $no_autolink_area = true; |
| 1957 | + } |
|
| 1872 | 1958 | } |
| 1873 | 1959 | |
| 1874 | 1960 | // Don't go backwards. |
| 1875 | 1961 | // @todo Don't think is the real solution.... |
| 1876 | 1962 | $lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0; |
| 1877 | - if ($pos < $lastAutoPos) |
|
| 1878 | - $no_autolink_area = true; |
|
| 1963 | + if ($pos < $lastAutoPos) { |
|
| 1964 | + $no_autolink_area = true; |
|
| 1965 | + } |
|
| 1879 | 1966 | $lastAutoPos = $pos; |
| 1880 | 1967 | |
| 1881 | 1968 | if (!$no_autolink_area) |
@@ -1984,17 +2071,19 @@ discard block |
||
| 1984 | 2071 | if ($scheme == 'mailto') |
| 1985 | 2072 | { |
| 1986 | 2073 | $email_address = str_replace('mailto:', '', $url); |
| 1987 | - if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) |
|
| 1988 | - return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
| 1989 | - else |
|
| 1990 | - return $url; |
|
| 2074 | + if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) { |
|
| 2075 | + return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
| 2076 | + } else { |
|
| 2077 | + return $url; |
|
| 2078 | + } |
|
| 1991 | 2079 | } |
| 1992 | 2080 | |
| 1993 | 2081 | // Are we linking a schemeless URL or naked domain name (e.g. "example.com")? |
| 1994 | - if (empty($scheme)) |
|
| 1995 | - $fullUrl = '//' . ltrim($url, ':/'); |
|
| 1996 | - else |
|
| 1997 | - $fullUrl = $url; |
|
| 2082 | + if (empty($scheme)) { |
|
| 2083 | + $fullUrl = '//' . ltrim($url, ':/'); |
|
| 2084 | + } else { |
|
| 2085 | + $fullUrl = $url; |
|
| 2086 | + } |
|
| 1998 | 2087 | |
| 1999 | 2088 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
| 2000 | 2089 | }, $data); |
@@ -2043,16 +2132,18 @@ discard block |
||
| 2043 | 2132 | } |
| 2044 | 2133 | |
| 2045 | 2134 | // Are we there yet? Are we there yet? |
| 2046 | - if ($pos >= strlen($message) - 1) |
|
| 2047 | - break; |
|
| 2135 | + if ($pos >= strlen($message) - 1) { |
|
| 2136 | + break; |
|
| 2137 | + } |
|
| 2048 | 2138 | |
| 2049 | 2139 | $tags = strtolower($message[$pos + 1]); |
| 2050 | 2140 | |
| 2051 | 2141 | if ($tags == '/' && !empty($open_tags)) |
| 2052 | 2142 | { |
| 2053 | 2143 | $pos2 = strpos($message, ']', $pos + 1); |
| 2054 | - if ($pos2 == $pos + 2) |
|
| 2055 | - continue; |
|
| 2144 | + if ($pos2 == $pos + 2) { |
|
| 2145 | + continue; |
|
| 2146 | + } |
|
| 2056 | 2147 | |
| 2057 | 2148 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
| 2058 | 2149 | |
@@ -2062,8 +2153,9 @@ discard block |
||
| 2062 | 2153 | do |
| 2063 | 2154 | { |
| 2064 | 2155 | $tag = array_pop($open_tags); |
| 2065 | - if (!$tag) |
|
| 2066 | - break; |
|
| 2156 | + if (!$tag) { |
|
| 2157 | + break; |
|
| 2158 | + } |
|
| 2067 | 2159 | |
| 2068 | 2160 | if (!empty($tag['block_level'])) |
| 2069 | 2161 | { |
@@ -2077,10 +2169,11 @@ discard block |
||
| 2077 | 2169 | // The idea is, if we are LOOKING for a block level tag, we can close them on the way. |
| 2078 | 2170 | if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]])) |
| 2079 | 2171 | { |
| 2080 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
| 2081 | - if ($temp['tag'] == $look_for) |
|
| 2172 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
| 2173 | + if ($temp['tag'] == $look_for) |
|
| 2082 | 2174 | { |
| 2083 | 2175 | $block_level = !empty($temp['block_level']); |
| 2176 | + } |
|
| 2084 | 2177 | break; |
| 2085 | 2178 | } |
| 2086 | 2179 | } |
@@ -2102,15 +2195,15 @@ discard block |
||
| 2102 | 2195 | { |
| 2103 | 2196 | $open_tags = $to_close; |
| 2104 | 2197 | continue; |
| 2105 | - } |
|
| 2106 | - elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
| 2198 | + } elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
| 2107 | 2199 | { |
| 2108 | 2200 | if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]])) |
| 2109 | 2201 | { |
| 2110 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
| 2111 | - if ($temp['tag'] == $look_for) |
|
| 2202 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
| 2203 | + if ($temp['tag'] == $look_for) |
|
| 2112 | 2204 | { |
| 2113 | 2205 | $block_level = !empty($temp['block_level']); |
| 2206 | + } |
|
| 2114 | 2207 | break; |
| 2115 | 2208 | } |
| 2116 | 2209 | } |
@@ -2118,8 +2211,9 @@ discard block |
||
| 2118 | 2211 | // We're not looking for a block level tag (or maybe even a tag that exists...) |
| 2119 | 2212 | if (!$block_level) |
| 2120 | 2213 | { |
| 2121 | - foreach ($to_close as $tag) |
|
| 2122 | - array_push($open_tags, $tag); |
|
| 2214 | + foreach ($to_close as $tag) { |
|
| 2215 | + array_push($open_tags, $tag); |
|
| 2216 | + } |
|
| 2123 | 2217 | continue; |
| 2124 | 2218 | } |
| 2125 | 2219 | } |
@@ -2132,14 +2226,17 @@ discard block |
||
| 2132 | 2226 | |
| 2133 | 2227 | // See the comment at the end of the big loop - just eating whitespace ;). |
| 2134 | 2228 | $whitespace_regex = ''; |
| 2135 | - if (!empty($tag['block_level'])) |
|
| 2136 | - $whitespace_regex .= '( |\s)*<br>'; |
|
| 2229 | + if (!empty($tag['block_level'])) { |
|
| 2230 | + $whitespace_regex .= '( |\s)*<br>'; |
|
| 2231 | + } |
|
| 2137 | 2232 | // Trim one line of whitespace after unnested tags, but all of it after nested ones |
| 2138 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
| 2139 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2233 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
| 2234 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2235 | + } |
|
| 2140 | 2236 | |
| 2141 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
| 2142 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2237 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
| 2238 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2239 | + } |
|
| 2143 | 2240 | } |
| 2144 | 2241 | |
| 2145 | 2242 | if (!empty($to_close)) |
@@ -2152,8 +2249,9 @@ discard block |
||
| 2152 | 2249 | } |
| 2153 | 2250 | |
| 2154 | 2251 | // No tags for this character, so just keep going (fastest possible course.) |
| 2155 | - if (!isset($bbc_codes[$tags])) |
|
| 2156 | - continue; |
|
| 2252 | + if (!isset($bbc_codes[$tags])) { |
|
| 2253 | + continue; |
|
| 2254 | + } |
|
| 2157 | 2255 | |
| 2158 | 2256 | $inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1]; |
| 2159 | 2257 | $tag = null; |
@@ -2162,44 +2260,52 @@ discard block |
||
| 2162 | 2260 | $pt_strlen = strlen($possible['tag']); |
| 2163 | 2261 | |
| 2164 | 2262 | // Not a match? |
| 2165 | - if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) |
|
| 2166 | - continue; |
|
| 2263 | + if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) { |
|
| 2264 | + continue; |
|
| 2265 | + } |
|
| 2167 | 2266 | |
| 2168 | 2267 | $next_c = $message[$pos + 1 + $pt_strlen]; |
| 2169 | 2268 | |
| 2170 | 2269 | // A test validation? |
| 2171 | - if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) |
|
| 2172 | - continue; |
|
| 2270 | + if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) { |
|
| 2271 | + continue; |
|
| 2272 | + } |
|
| 2173 | 2273 | // Do we want parameters? |
| 2174 | 2274 | elseif (!empty($possible['parameters'])) |
| 2175 | 2275 | { |
| 2176 | - if ($next_c != ' ') |
|
| 2177 | - continue; |
|
| 2178 | - } |
|
| 2179 | - elseif (isset($possible['type'])) |
|
| 2276 | + if ($next_c != ' ') { |
|
| 2277 | + continue; |
|
| 2278 | + } |
|
| 2279 | + } elseif (isset($possible['type'])) |
|
| 2180 | 2280 | { |
| 2181 | 2281 | // Do we need an equal sign? |
| 2182 | - if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') |
|
| 2183 | - continue; |
|
| 2282 | + if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') { |
|
| 2283 | + continue; |
|
| 2284 | + } |
|
| 2184 | 2285 | // Maybe we just want a /... |
| 2185 | - if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') |
|
| 2186 | - continue; |
|
| 2286 | + if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') { |
|
| 2287 | + continue; |
|
| 2288 | + } |
|
| 2187 | 2289 | // An immediate ]? |
| 2188 | - if ($possible['type'] == 'unparsed_content' && $next_c != ']') |
|
| 2189 | - continue; |
|
| 2290 | + if ($possible['type'] == 'unparsed_content' && $next_c != ']') { |
|
| 2291 | + continue; |
|
| 2292 | + } |
|
| 2190 | 2293 | } |
| 2191 | 2294 | // No type means 'parsed_content', which demands an immediate ] without parameters! |
| 2192 | - elseif ($next_c != ']') |
|
| 2193 | - continue; |
|
| 2295 | + elseif ($next_c != ']') { |
|
| 2296 | + continue; |
|
| 2297 | + } |
|
| 2194 | 2298 | |
| 2195 | 2299 | // Check allowed tree? |
| 2196 | - if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) |
|
| 2197 | - continue; |
|
| 2198 | - elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) |
|
| 2199 | - continue; |
|
| 2300 | + if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) { |
|
| 2301 | + continue; |
|
| 2302 | + } elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) { |
|
| 2303 | + continue; |
|
| 2304 | + } |
|
| 2200 | 2305 | // If this is in the list of disallowed child tags, don't parse it. |
| 2201 | - elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) |
|
| 2202 | - continue; |
|
| 2306 | + elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) { |
|
| 2307 | + continue; |
|
| 2308 | + } |
|
| 2203 | 2309 | |
| 2204 | 2310 | $pos1 = $pos + 1 + $pt_strlen + 1; |
| 2205 | 2311 | |
@@ -2211,8 +2317,9 @@ discard block |
||
| 2211 | 2317 | foreach ($open_tags as $open_quote) |
| 2212 | 2318 | { |
| 2213 | 2319 | // Every parent quote this quote has flips the styling |
| 2214 | - if ($open_quote['tag'] == 'quote') |
|
| 2215 | - $quote_alt = !$quote_alt; |
|
| 2320 | + if ($open_quote['tag'] == 'quote') { |
|
| 2321 | + $quote_alt = !$quote_alt; |
|
| 2322 | + } |
|
| 2216 | 2323 | } |
| 2217 | 2324 | // Add a class to the quote to style alternating blockquotes |
| 2218 | 2325 | $possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">')); |
@@ -2223,8 +2330,9 @@ discard block |
||
| 2223 | 2330 | { |
| 2224 | 2331 | // Build a regular expression for each parameter for the current tag. |
| 2225 | 2332 | $preg = array(); |
| 2226 | - foreach ($possible['parameters'] as $p => $info) |
|
| 2227 | - $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
| 2333 | + foreach ($possible['parameters'] as $p => $info) { |
|
| 2334 | + $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
| 2335 | + } |
|
| 2228 | 2336 | |
| 2229 | 2337 | // Extract the string that potentially holds our parameters. |
| 2230 | 2338 | $blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos)); |
@@ -2244,24 +2352,27 @@ discard block |
||
| 2244 | 2352 | |
| 2245 | 2353 | $match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0; |
| 2246 | 2354 | |
| 2247 | - if ($match) |
|
| 2248 | - $blob_counter = count($blobs) + 1; |
|
| 2355 | + if ($match) { |
|
| 2356 | + $blob_counter = count($blobs) + 1; |
|
| 2357 | + } |
|
| 2249 | 2358 | } |
| 2250 | 2359 | |
| 2251 | 2360 | // Didn't match our parameter list, try the next possible. |
| 2252 | - if (!$match) |
|
| 2253 | - continue; |
|
| 2361 | + if (!$match) { |
|
| 2362 | + continue; |
|
| 2363 | + } |
|
| 2254 | 2364 | |
| 2255 | 2365 | $params = array(); |
| 2256 | 2366 | for ($i = 1, $n = count($matches); $i < $n; $i += 2) |
| 2257 | 2367 | { |
| 2258 | 2368 | $key = strtok(ltrim($matches[$i]), '='); |
| 2259 | - if (isset($possible['parameters'][$key]['value'])) |
|
| 2260 | - $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
| 2261 | - elseif (isset($possible['parameters'][$key]['validate'])) |
|
| 2262 | - $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
| 2263 | - else |
|
| 2264 | - $params['{' . $key . '}'] = $matches[$i + 1]; |
|
| 2369 | + if (isset($possible['parameters'][$key]['value'])) { |
|
| 2370 | + $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
| 2371 | + } elseif (isset($possible['parameters'][$key]['validate'])) { |
|
| 2372 | + $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
| 2373 | + } else { |
|
| 2374 | + $params['{' . $key . '}'] = $matches[$i + 1]; |
|
| 2375 | + } |
|
| 2265 | 2376 | |
| 2266 | 2377 | // Just to make sure: replace any $ or { so they can't interpolate wrongly. |
| 2267 | 2378 | $params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '$', '{' => '{')); |
@@ -2269,23 +2380,26 @@ discard block |
||
| 2269 | 2380 | |
| 2270 | 2381 | foreach ($possible['parameters'] as $p => $info) |
| 2271 | 2382 | { |
| 2272 | - if (!isset($params['{' . $p . '}'])) |
|
| 2273 | - $params['{' . $p . '}'] = ''; |
|
| 2383 | + if (!isset($params['{' . $p . '}'])) { |
|
| 2384 | + $params['{' . $p . '}'] = ''; |
|
| 2385 | + } |
|
| 2274 | 2386 | } |
| 2275 | 2387 | |
| 2276 | 2388 | $tag = $possible; |
| 2277 | 2389 | |
| 2278 | 2390 | // Put the parameters into the string. |
| 2279 | - if (isset($tag['before'])) |
|
| 2280 | - $tag['before'] = strtr($tag['before'], $params); |
|
| 2281 | - if (isset($tag['after'])) |
|
| 2282 | - $tag['after'] = strtr($tag['after'], $params); |
|
| 2283 | - if (isset($tag['content'])) |
|
| 2284 | - $tag['content'] = strtr($tag['content'], $params); |
|
| 2391 | + if (isset($tag['before'])) { |
|
| 2392 | + $tag['before'] = strtr($tag['before'], $params); |
|
| 2393 | + } |
|
| 2394 | + if (isset($tag['after'])) { |
|
| 2395 | + $tag['after'] = strtr($tag['after'], $params); |
|
| 2396 | + } |
|
| 2397 | + if (isset($tag['content'])) { |
|
| 2398 | + $tag['content'] = strtr($tag['content'], $params); |
|
| 2399 | + } |
|
| 2285 | 2400 | |
| 2286 | 2401 | $pos1 += strlen($given_param_string); |
| 2287 | - } |
|
| 2288 | - else |
|
| 2402 | + } else |
|
| 2289 | 2403 | { |
| 2290 | 2404 | $tag = $possible; |
| 2291 | 2405 | $params = array(); |
@@ -2296,8 +2410,9 @@ discard block |
||
| 2296 | 2410 | // Item codes are complicated buggers... they are implicit [li]s and can make [list]s! |
| 2297 | 2411 | if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li'])) |
| 2298 | 2412 | { |
| 2299 | - if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) |
|
| 2300 | - continue; |
|
| 2413 | + if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) { |
|
| 2414 | + continue; |
|
| 2415 | + } |
|
| 2301 | 2416 | |
| 2302 | 2417 | $tag = $itemcodes[$message[$pos + 1]]; |
| 2303 | 2418 | |
@@ -2318,9 +2433,9 @@ discard block |
||
| 2318 | 2433 | { |
| 2319 | 2434 | array_pop($open_tags); |
| 2320 | 2435 | $code = '</li>'; |
| 2436 | + } else { |
|
| 2437 | + $code = ''; |
|
| 2321 | 2438 | } |
| 2322 | - else |
|
| 2323 | - $code = ''; |
|
| 2324 | 2439 | |
| 2325 | 2440 | // Now we open a new tag. |
| 2326 | 2441 | $open_tags[] = array( |
@@ -2367,12 +2482,14 @@ discard block |
||
| 2367 | 2482 | } |
| 2368 | 2483 | |
| 2369 | 2484 | // No tag? Keep looking, then. Silly people using brackets without actual tags. |
| 2370 | - if ($tag === null) |
|
| 2371 | - continue; |
|
| 2485 | + if ($tag === null) { |
|
| 2486 | + continue; |
|
| 2487 | + } |
|
| 2372 | 2488 | |
| 2373 | 2489 | // Propagate the list to the child (so wrapping the disallowed tag won't work either.) |
| 2374 | - if (isset($inside['disallow_children'])) |
|
| 2375 | - $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
| 2490 | + if (isset($inside['disallow_children'])) { |
|
| 2491 | + $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
| 2492 | + } |
|
| 2376 | 2493 | |
| 2377 | 2494 | // Is this tag disabled? |
| 2378 | 2495 | if (isset($disabled[$tag['tag']])) |
@@ -2382,14 +2499,13 @@ discard block |
||
| 2382 | 2499 | $tag['before'] = !empty($tag['block_level']) ? '<div>' : ''; |
| 2383 | 2500 | $tag['after'] = !empty($tag['block_level']) ? '</div>' : ''; |
| 2384 | 2501 | $tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1'); |
| 2385 | - } |
|
| 2386 | - elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
| 2502 | + } elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
| 2387 | 2503 | { |
| 2388 | 2504 | $tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : ''); |
| 2389 | 2505 | $tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : ''); |
| 2506 | + } else { |
|
| 2507 | + $tag['content'] = $tag['disabled_content']; |
|
| 2390 | 2508 | } |
| 2391 | - else |
|
| 2392 | - $tag['content'] = $tag['disabled_content']; |
|
| 2393 | 2509 | } |
| 2394 | 2510 | |
| 2395 | 2511 | // we use this a lot |
@@ -2399,8 +2515,9 @@ discard block |
||
| 2399 | 2515 | if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level'])) |
| 2400 | 2516 | { |
| 2401 | 2517 | $n = count($open_tags) - 1; |
| 2402 | - while (empty($open_tags[$n]['block_level']) && $n >= 0) |
|
| 2403 | - $n--; |
|
| 2518 | + while (empty($open_tags[$n]['block_level']) && $n >= 0) { |
|
| 2519 | + $n--; |
|
| 2520 | + } |
|
| 2404 | 2521 | |
| 2405 | 2522 | // Close all the non block level tags so this tag isn't surrounded by them. |
| 2406 | 2523 | for ($i = count($open_tags) - 1; $i > $n; $i--) |
@@ -2412,12 +2529,15 @@ discard block |
||
| 2412 | 2529 | |
| 2413 | 2530 | // Trim or eat trailing stuff... see comment at the end of the big loop. |
| 2414 | 2531 | $whitespace_regex = ''; |
| 2415 | - if (!empty($tag['block_level'])) |
|
| 2416 | - $whitespace_regex .= '( |\s)*<br>'; |
|
| 2417 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
| 2418 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2419 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
| 2420 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2532 | + if (!empty($tag['block_level'])) { |
|
| 2533 | + $whitespace_regex .= '( |\s)*<br>'; |
|
| 2534 | + } |
|
| 2535 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
| 2536 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2537 | + } |
|
| 2538 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
| 2539 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2540 | + } |
|
| 2421 | 2541 | |
| 2422 | 2542 | array_pop($open_tags); |
| 2423 | 2543 | } |
@@ -2435,16 +2555,19 @@ discard block |
||
| 2435 | 2555 | elseif ($tag['type'] == 'unparsed_content') |
| 2436 | 2556 | { |
| 2437 | 2557 | $pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1); |
| 2438 | - if ($pos2 === false) |
|
| 2439 | - continue; |
|
| 2558 | + if ($pos2 === false) { |
|
| 2559 | + continue; |
|
| 2560 | + } |
|
| 2440 | 2561 | |
| 2441 | 2562 | $data = substr($message, $pos1, $pos2 - $pos1); |
| 2442 | 2563 | |
| 2443 | - if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') |
|
| 2444 | - $data = substr($data, 4); |
|
| 2564 | + if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') { |
|
| 2565 | + $data = substr($data, 4); |
|
| 2566 | + } |
|
| 2445 | 2567 | |
| 2446 | - if (isset($tag['validate'])) |
|
| 2447 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2568 | + if (isset($tag['validate'])) { |
|
| 2569 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2570 | + } |
|
| 2448 | 2571 | |
| 2449 | 2572 | $code = strtr($tag['content'], array('$1' => $data)); |
| 2450 | 2573 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen); |
@@ -2460,34 +2583,40 @@ discard block |
||
| 2460 | 2583 | if (isset($tag['quoted'])) |
| 2461 | 2584 | { |
| 2462 | 2585 | $quoted = substr($message, $pos1, 6) == '"'; |
| 2463 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
| 2464 | - continue; |
|
| 2586 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
| 2587 | + continue; |
|
| 2588 | + } |
|
| 2465 | 2589 | |
| 2466 | - if ($quoted) |
|
| 2467 | - $pos1 += 6; |
|
| 2590 | + if ($quoted) { |
|
| 2591 | + $pos1 += 6; |
|
| 2592 | + } |
|
| 2593 | + } else { |
|
| 2594 | + $quoted = false; |
|
| 2468 | 2595 | } |
| 2469 | - else |
|
| 2470 | - $quoted = false; |
|
| 2471 | 2596 | |
| 2472 | 2597 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
| 2473 | - if ($pos2 === false) |
|
| 2474 | - continue; |
|
| 2598 | + if ($pos2 === false) { |
|
| 2599 | + continue; |
|
| 2600 | + } |
|
| 2475 | 2601 | |
| 2476 | 2602 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
| 2477 | - if ($pos3 === false) |
|
| 2478 | - continue; |
|
| 2603 | + if ($pos3 === false) { |
|
| 2604 | + continue; |
|
| 2605 | + } |
|
| 2479 | 2606 | |
| 2480 | 2607 | $data = array( |
| 2481 | 2608 | substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))), |
| 2482 | 2609 | substr($message, $pos1, $pos2 - $pos1) |
| 2483 | 2610 | ); |
| 2484 | 2611 | |
| 2485 | - if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') |
|
| 2486 | - $data[0] = substr($data[0], 4); |
|
| 2612 | + if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') { |
|
| 2613 | + $data[0] = substr($data[0], 4); |
|
| 2614 | + } |
|
| 2487 | 2615 | |
| 2488 | 2616 | // Validation for my parking, please! |
| 2489 | - if (isset($tag['validate'])) |
|
| 2490 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2617 | + if (isset($tag['validate'])) { |
|
| 2618 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2619 | + } |
|
| 2491 | 2620 | |
| 2492 | 2621 | $code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1])); |
| 2493 | 2622 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
@@ -2504,23 +2633,27 @@ discard block |
||
| 2504 | 2633 | elseif ($tag['type'] == 'unparsed_commas_content') |
| 2505 | 2634 | { |
| 2506 | 2635 | $pos2 = strpos($message, ']', $pos1); |
| 2507 | - if ($pos2 === false) |
|
| 2508 | - continue; |
|
| 2636 | + if ($pos2 === false) { |
|
| 2637 | + continue; |
|
| 2638 | + } |
|
| 2509 | 2639 | |
| 2510 | 2640 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
| 2511 | - if ($pos3 === false) |
|
| 2512 | - continue; |
|
| 2641 | + if ($pos3 === false) { |
|
| 2642 | + continue; |
|
| 2643 | + } |
|
| 2513 | 2644 | |
| 2514 | 2645 | // We want $1 to be the content, and the rest to be csv. |
| 2515 | 2646 | $data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1)); |
| 2516 | 2647 | $data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1); |
| 2517 | 2648 | |
| 2518 | - if (isset($tag['validate'])) |
|
| 2519 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2649 | + if (isset($tag['validate'])) { |
|
| 2650 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2651 | + } |
|
| 2520 | 2652 | |
| 2521 | 2653 | $code = $tag['content']; |
| 2522 | - foreach ($data as $k => $d) |
|
| 2523 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2654 | + foreach ($data as $k => $d) { |
|
| 2655 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2656 | + } |
|
| 2524 | 2657 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
| 2525 | 2658 | $pos += strlen($code) - 1 + 2; |
| 2526 | 2659 | } |
@@ -2528,24 +2661,28 @@ discard block |
||
| 2528 | 2661 | elseif ($tag['type'] == 'unparsed_commas') |
| 2529 | 2662 | { |
| 2530 | 2663 | $pos2 = strpos($message, ']', $pos1); |
| 2531 | - if ($pos2 === false) |
|
| 2532 | - continue; |
|
| 2664 | + if ($pos2 === false) { |
|
| 2665 | + continue; |
|
| 2666 | + } |
|
| 2533 | 2667 | |
| 2534 | 2668 | $data = explode(',', substr($message, $pos1, $pos2 - $pos1)); |
| 2535 | 2669 | |
| 2536 | - if (isset($tag['validate'])) |
|
| 2537 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2670 | + if (isset($tag['validate'])) { |
|
| 2671 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2672 | + } |
|
| 2538 | 2673 | |
| 2539 | 2674 | // Fix after, for disabled code mainly. |
| 2540 | - foreach ($data as $k => $d) |
|
| 2541 | - $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
| 2675 | + foreach ($data as $k => $d) { |
|
| 2676 | + $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
| 2677 | + } |
|
| 2542 | 2678 | |
| 2543 | 2679 | $open_tags[] = $tag; |
| 2544 | 2680 | |
| 2545 | 2681 | // Replace them out, $1, $2, $3, $4, etc. |
| 2546 | 2682 | $code = $tag['before']; |
| 2547 | - foreach ($data as $k => $d) |
|
| 2548 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2683 | + foreach ($data as $k => $d) { |
|
| 2684 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2685 | + } |
|
| 2549 | 2686 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1); |
| 2550 | 2687 | $pos += strlen($code) - 1 + 2; |
| 2551 | 2688 | } |
@@ -2556,28 +2693,33 @@ discard block |
||
| 2556 | 2693 | if (isset($tag['quoted'])) |
| 2557 | 2694 | { |
| 2558 | 2695 | $quoted = substr($message, $pos1, 6) == '"'; |
| 2559 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
| 2560 | - continue; |
|
| 2696 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
| 2697 | + continue; |
|
| 2698 | + } |
|
| 2561 | 2699 | |
| 2562 | - if ($quoted) |
|
| 2563 | - $pos1 += 6; |
|
| 2700 | + if ($quoted) { |
|
| 2701 | + $pos1 += 6; |
|
| 2702 | + } |
|
| 2703 | + } else { |
|
| 2704 | + $quoted = false; |
|
| 2564 | 2705 | } |
| 2565 | - else |
|
| 2566 | - $quoted = false; |
|
| 2567 | 2706 | |
| 2568 | 2707 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
| 2569 | - if ($pos2 === false) |
|
| 2570 | - continue; |
|
| 2708 | + if ($pos2 === false) { |
|
| 2709 | + continue; |
|
| 2710 | + } |
|
| 2571 | 2711 | |
| 2572 | 2712 | $data = substr($message, $pos1, $pos2 - $pos1); |
| 2573 | 2713 | |
| 2574 | 2714 | // Validation for my parking, please! |
| 2575 | - if (isset($tag['validate'])) |
|
| 2576 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2715 | + if (isset($tag['validate'])) { |
|
| 2716 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2717 | + } |
|
| 2577 | 2718 | |
| 2578 | 2719 | // For parsed content, we must recurse to avoid security problems. |
| 2579 | - if ($tag['type'] != 'unparsed_equals') |
|
| 2580 | - $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
| 2720 | + if ($tag['type'] != 'unparsed_equals') { |
|
| 2721 | + $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
| 2722 | + } |
|
| 2581 | 2723 | |
| 2582 | 2724 | $tag['after'] = strtr($tag['after'], array('$1' => $data)); |
| 2583 | 2725 | |
@@ -2589,34 +2731,40 @@ discard block |
||
| 2589 | 2731 | } |
| 2590 | 2732 | |
| 2591 | 2733 | // If this is block level, eat any breaks after it. |
| 2592 | - if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') |
|
| 2593 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
| 2734 | + if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') { |
|
| 2735 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
| 2736 | + } |
|
| 2594 | 2737 | |
| 2595 | 2738 | // Are we trimming outside this tag? |
| 2596 | - if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) |
|
| 2597 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
| 2739 | + if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) { |
|
| 2740 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
| 2741 | + } |
|
| 2598 | 2742 | } |
| 2599 | 2743 | |
| 2600 | 2744 | // Close any remaining tags. |
| 2601 | - while ($tag = array_pop($open_tags)) |
|
| 2602 | - $message .= "\n" . $tag['after'] . "\n"; |
|
| 2745 | + while ($tag = array_pop($open_tags)) { |
|
| 2746 | + $message .= "\n" . $tag['after'] . "\n"; |
|
| 2747 | + } |
|
| 2603 | 2748 | |
| 2604 | 2749 | // Parse the smileys within the parts where it can be done safely. |
| 2605 | 2750 | if ($smileys === true) |
| 2606 | 2751 | { |
| 2607 | 2752 | $message_parts = explode("\n", $message); |
| 2608 | - for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) |
|
| 2609 | - parsesmileys($message_parts[$i]); |
|
| 2753 | + for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) { |
|
| 2754 | + parsesmileys($message_parts[$i]); |
|
| 2755 | + } |
|
| 2610 | 2756 | |
| 2611 | 2757 | $message = implode('', $message_parts); |
| 2612 | 2758 | } |
| 2613 | 2759 | |
| 2614 | 2760 | // No smileys, just get rid of the markers. |
| 2615 | - else |
|
| 2616 | - $message = strtr($message, array("\n" => '')); |
|
| 2761 | + else { |
|
| 2762 | + $message = strtr($message, array("\n" => '')); |
|
| 2763 | + } |
|
| 2617 | 2764 | |
| 2618 | - if ($message !== '' && $message[0] === ' ') |
|
| 2619 | - $message = ' ' . substr($message, 1); |
|
| 2765 | + if ($message !== '' && $message[0] === ' ') { |
|
| 2766 | + $message = ' ' . substr($message, 1); |
|
| 2767 | + } |
|
| 2620 | 2768 | |
| 2621 | 2769 | // Cleanup whitespace. |
| 2622 | 2770 | $message = strtr($message, array(' ' => ' ', "\r" => '', "\n" => '<br>', '<br> ' => '<br> ', ' ' => "\n")); |
@@ -2625,15 +2773,16 @@ discard block |
||
| 2625 | 2773 | call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
| 2626 | 2774 | |
| 2627 | 2775 | // Cache the output if it took some time... |
| 2628 | - if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) |
|
| 2629 | - cache_put_data($cache_key, $message, 240); |
|
| 2776 | + if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) { |
|
| 2777 | + cache_put_data($cache_key, $message, 240); |
|
| 2778 | + } |
|
| 2630 | 2779 | |
| 2631 | 2780 | // If this was a force parse revert if needed. |
| 2632 | 2781 | if (!empty($parse_tags)) |
| 2633 | 2782 | { |
| 2634 | - if (empty($temp_bbc)) |
|
| 2635 | - $bbc_codes = array(); |
|
| 2636 | - else |
|
| 2783 | + if (empty($temp_bbc)) { |
|
| 2784 | + $bbc_codes = array(); |
|
| 2785 | + } else |
|
| 2637 | 2786 | { |
| 2638 | 2787 | $bbc_codes = $temp_bbc; |
| 2639 | 2788 | unset($temp_bbc); |
@@ -2660,8 +2809,9 @@ discard block |
||
| 2660 | 2809 | static $smileyPregSearch = null, $smileyPregReplacements = array(); |
| 2661 | 2810 | |
| 2662 | 2811 | // No smiley set at all?! |
| 2663 | - if ($user_info['smiley_set'] == 'none' || trim($message) == '') |
|
| 2664 | - return; |
|
| 2812 | + if ($user_info['smiley_set'] == 'none' || trim($message) == '') { |
|
| 2813 | + return; |
|
| 2814 | + } |
|
| 2665 | 2815 | |
| 2666 | 2816 | // If smileyPregSearch hasn't been set, do it now. |
| 2667 | 2817 | if (empty($smileyPregSearch)) |
@@ -2672,8 +2822,7 @@ discard block |
||
| 2672 | 2822 | $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)'); |
| 2673 | 2823 | $smileysto = array('evil.gif', 'cheesy.gif', 'rolleyes.gif', 'angry.gif', 'laugh.gif', 'smiley.gif', 'wink.gif', 'grin.gif', 'sad.gif', 'shocked.gif', 'cool.gif', 'tongue.gif', 'huh.gif', 'embarrassed.gif', 'lipsrsealed.gif', 'kiss.gif', 'cry.gif', 'undecided.gif', 'azn.gif', 'afro.gif', 'police.gif', 'angel.gif'); |
| 2674 | 2824 | $smileysdescs = array('', $txt['icon_cheesy'], $txt['icon_rolleyes'], $txt['icon_angry'], '', $txt['icon_smiley'], $txt['icon_wink'], $txt['icon_grin'], $txt['icon_sad'], $txt['icon_shocked'], $txt['icon_cool'], $txt['icon_tongue'], $txt['icon_huh'], $txt['icon_embarrassed'], $txt['icon_lips'], $txt['icon_kiss'], $txt['icon_cry'], $txt['icon_undecided'], '', '', '', ''); |
| 2675 | - } |
|
| 2676 | - else |
|
| 2825 | + } else |
|
| 2677 | 2826 | { |
| 2678 | 2827 | // Load the smileys in reverse order by length so they don't get parsed wrong. |
| 2679 | 2828 | if (($temp = cache_get_data('parsing_smileys', 480)) == null) |
@@ -2697,9 +2846,9 @@ discard block |
||
| 2697 | 2846 | $smcFunc['db_free_result']($result); |
| 2698 | 2847 | |
| 2699 | 2848 | cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480); |
| 2849 | + } else { |
|
| 2850 | + list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
| 2700 | 2851 | } |
| 2701 | - else |
|
| 2702 | - list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
| 2703 | 2852 | } |
| 2704 | 2853 | |
| 2705 | 2854 | // The non-breaking-space is a complex thing... |
@@ -2776,35 +2925,41 @@ discard block |
||
| 2776 | 2925 | global $scripturl, $context, $modSettings, $db_show_debug, $db_cache; |
| 2777 | 2926 | |
| 2778 | 2927 | // In case we have mail to send, better do that - as obExit doesn't always quite make it... |
| 2779 | - if (!empty($context['flush_mail'])) |
|
| 2780 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 2928 | + if (!empty($context['flush_mail'])) { |
|
| 2929 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 2781 | 2930 | AddMailQueue(true); |
| 2931 | + } |
|
| 2782 | 2932 | |
| 2783 | 2933 | $add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:'; |
| 2784 | 2934 | |
| 2785 | - if ($add) |
|
| 2786 | - $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
| 2935 | + if ($add) { |
|
| 2936 | + $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
| 2937 | + } |
|
| 2787 | 2938 | |
| 2788 | 2939 | // Put the session ID in. |
| 2789 | - if (defined('SID') && SID != '') |
|
| 2790 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
| 2940 | + if (defined('SID') && SID != '') { |
|
| 2941 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
| 2942 | + } |
|
| 2791 | 2943 | // Keep that debug in their for template debugging! |
| 2792 | - elseif (isset($_GET['debug'])) |
|
| 2793 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
| 2944 | + elseif (isset($_GET['debug'])) { |
|
| 2945 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
| 2946 | + } |
|
| 2794 | 2947 | |
| 2795 | 2948 | if (!empty($modSettings['queryless_urls']) && (empty($context['server']['is_cgi']) || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && (!empty($context['server']['is_apache']) || !empty($context['server']['is_lighttpd']) || !empty($context['server']['is_litespeed']))) |
| 2796 | 2949 | { |
| 2797 | - if (defined('SID') && SID != '') |
|
| 2798 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
| 2950 | + if (defined('SID') && SID != '') { |
|
| 2951 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
| 2799 | 2952 | function ($m) use ($scripturl) |
| 2800 | 2953 | { |
| 2801 | 2954 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
| 2955 | + } |
|
| 2802 | 2956 | }, $setLocation); |
| 2803 | - else |
|
| 2804 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
| 2957 | + else { |
|
| 2958 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
| 2805 | 2959 | function ($m) use ($scripturl) |
| 2806 | 2960 | { |
| 2807 | 2961 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
| 2962 | + } |
|
| 2808 | 2963 | }, $setLocation); |
| 2809 | 2964 | } |
| 2810 | 2965 | |
@@ -2815,8 +2970,9 @@ discard block |
||
| 2815 | 2970 | header('Location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302); |
| 2816 | 2971 | |
| 2817 | 2972 | // Debugging. |
| 2818 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 2819 | - $_SESSION['debug_redirect'] = $db_cache; |
|
| 2973 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 2974 | + $_SESSION['debug_redirect'] = $db_cache; |
|
| 2975 | + } |
|
| 2820 | 2976 | |
| 2821 | 2977 | obExit(false); |
| 2822 | 2978 | } |
@@ -2835,51 +2991,60 @@ discard block |
||
| 2835 | 2991 | |
| 2836 | 2992 | // Attempt to prevent a recursive loop. |
| 2837 | 2993 | ++$level; |
| 2838 | - if ($level > 1 && !$from_fatal_error && !$has_fatal_error) |
|
| 2839 | - exit; |
|
| 2840 | - if ($from_fatal_error) |
|
| 2841 | - $has_fatal_error = true; |
|
| 2994 | + if ($level > 1 && !$from_fatal_error && !$has_fatal_error) { |
|
| 2995 | + exit; |
|
| 2996 | + } |
|
| 2997 | + if ($from_fatal_error) { |
|
| 2998 | + $has_fatal_error = true; |
|
| 2999 | + } |
|
| 2842 | 3000 | |
| 2843 | 3001 | // Clear out the stat cache. |
| 2844 | 3002 | trackStats(); |
| 2845 | 3003 | |
| 2846 | 3004 | // If we have mail to send, send it. |
| 2847 | - if (!empty($context['flush_mail'])) |
|
| 2848 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 3005 | + if (!empty($context['flush_mail'])) { |
|
| 3006 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 2849 | 3007 | AddMailQueue(true); |
| 3008 | + } |
|
| 2850 | 3009 | |
| 2851 | 3010 | $do_header = $header === null ? !$header_done : $header; |
| 2852 | - if ($do_footer === null) |
|
| 2853 | - $do_footer = $do_header; |
|
| 3011 | + if ($do_footer === null) { |
|
| 3012 | + $do_footer = $do_header; |
|
| 3013 | + } |
|
| 2854 | 3014 | |
| 2855 | 3015 | // Has the template/header been done yet? |
| 2856 | 3016 | if ($do_header) |
| 2857 | 3017 | { |
| 2858 | 3018 | // Was the page title set last minute? Also update the HTML safe one. |
| 2859 | - if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) |
|
| 2860 | - $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
| 3019 | + if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) { |
|
| 3020 | + $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
| 3021 | + } |
|
| 2861 | 3022 | |
| 2862 | 3023 | // Start up the session URL fixer. |
| 2863 | 3024 | ob_start('ob_sessrewrite'); |
| 2864 | 3025 | |
| 2865 | - if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) |
|
| 2866 | - $buffers = explode(',', $settings['output_buffers']); |
|
| 2867 | - elseif (!empty($settings['output_buffers'])) |
|
| 2868 | - $buffers = $settings['output_buffers']; |
|
| 2869 | - else |
|
| 2870 | - $buffers = array(); |
|
| 3026 | + if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) { |
|
| 3027 | + $buffers = explode(',', $settings['output_buffers']); |
|
| 3028 | + } elseif (!empty($settings['output_buffers'])) { |
|
| 3029 | + $buffers = $settings['output_buffers']; |
|
| 3030 | + } else { |
|
| 3031 | + $buffers = array(); |
|
| 3032 | + } |
|
| 2871 | 3033 | |
| 2872 | - if (isset($modSettings['integrate_buffer'])) |
|
| 2873 | - $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
| 3034 | + if (isset($modSettings['integrate_buffer'])) { |
|
| 3035 | + $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
| 3036 | + } |
|
| 2874 | 3037 | |
| 2875 | - if (!empty($buffers)) |
|
| 2876 | - foreach ($buffers as $function) |
|
| 3038 | + if (!empty($buffers)) { |
|
| 3039 | + foreach ($buffers as $function) |
|
| 2877 | 3040 | { |
| 2878 | 3041 | $call = call_helper($function, true); |
| 3042 | + } |
|
| 2879 | 3043 | |
| 2880 | 3044 | // Is it valid? |
| 2881 | - if (!empty($call)) |
|
| 2882 | - ob_start($call); |
|
| 3045 | + if (!empty($call)) { |
|
| 3046 | + ob_start($call); |
|
| 3047 | + } |
|
| 2883 | 3048 | } |
| 2884 | 3049 | |
| 2885 | 3050 | // Display the screen in the logical order. |
@@ -2891,8 +3056,9 @@ discard block |
||
| 2891 | 3056 | loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main'); |
| 2892 | 3057 | |
| 2893 | 3058 | // Anything special to put out? |
| 2894 | - if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) |
|
| 2895 | - echo $context['insert_after_template']; |
|
| 3059 | + if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) { |
|
| 3060 | + echo $context['insert_after_template']; |
|
| 3061 | + } |
|
| 2896 | 3062 | |
| 2897 | 3063 | // Just so we don't get caught in an endless loop of errors from the footer... |
| 2898 | 3064 | if (!$footer_done) |
@@ -2901,14 +3067,16 @@ discard block |
||
| 2901 | 3067 | template_footer(); |
| 2902 | 3068 | |
| 2903 | 3069 | // (since this is just debugging... it's okay that it's after </html>.) |
| 2904 | - if (!isset($_REQUEST['xml'])) |
|
| 2905 | - displayDebug(); |
|
| 3070 | + if (!isset($_REQUEST['xml'])) { |
|
| 3071 | + displayDebug(); |
|
| 3072 | + } |
|
| 2906 | 3073 | } |
| 2907 | 3074 | } |
| 2908 | 3075 | |
| 2909 | 3076 | // Remember this URL in case someone doesn't like sending HTTP_REFERER. |
| 2910 | - if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) |
|
| 2911 | - $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
| 3077 | + if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) { |
|
| 3078 | + $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
| 3079 | + } |
|
| 2912 | 3080 | |
| 2913 | 3081 | // For session check verification.... don't switch browsers... |
| 2914 | 3082 | $_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']; |
@@ -2917,9 +3085,10 @@ discard block |
||
| 2917 | 3085 | call_integration_hook('integrate_exit', array($do_footer)); |
| 2918 | 3086 | |
| 2919 | 3087 | // Don't exit if we're coming from index.php; that will pass through normally. |
| 2920 | - if (!$from_index) |
|
| 2921 | - exit; |
|
| 2922 | -} |
|
| 3088 | + if (!$from_index) { |
|
| 3089 | + exit; |
|
| 3090 | + } |
|
| 3091 | + } |
|
| 2923 | 3092 | |
| 2924 | 3093 | /** |
| 2925 | 3094 | * Get the size of a specified image with better error handling. |
@@ -2938,8 +3107,9 @@ discard block |
||
| 2938 | 3107 | $url = str_replace(' ', '%20', $url); |
| 2939 | 3108 | |
| 2940 | 3109 | // Can we pull this from the cache... please please? |
| 2941 | - if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) |
|
| 2942 | - return $temp; |
|
| 3110 | + if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) { |
|
| 3111 | + return $temp; |
|
| 3112 | + } |
|
| 2943 | 3113 | $t = microtime(); |
| 2944 | 3114 | |
| 2945 | 3115 | // Get the host to pester... |
@@ -2949,12 +3119,10 @@ discard block |
||
| 2949 | 3119 | if ($url == '' || $url == 'http://' || $url == 'https://') |
| 2950 | 3120 | { |
| 2951 | 3121 | return false; |
| 2952 | - } |
|
| 2953 | - elseif (!isset($match[1])) |
|
| 3122 | + } elseif (!isset($match[1])) |
|
| 2954 | 3123 | { |
| 2955 | 3124 | $size = @getimagesize($url); |
| 2956 | - } |
|
| 2957 | - else |
|
| 3125 | + } else |
|
| 2958 | 3126 | { |
| 2959 | 3127 | // Try to connect to the server... give it half a second. |
| 2960 | 3128 | $temp = 0; |
@@ -2993,12 +3161,14 @@ discard block |
||
| 2993 | 3161 | } |
| 2994 | 3162 | |
| 2995 | 3163 | // If we didn't get it, we failed. |
| 2996 | - if (!isset($size)) |
|
| 2997 | - $size = false; |
|
| 3164 | + if (!isset($size)) { |
|
| 3165 | + $size = false; |
|
| 3166 | + } |
|
| 2998 | 3167 | |
| 2999 | 3168 | // If this took a long time, we may never have to do it again, but then again we might... |
| 3000 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) |
|
| 3001 | - cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
| 3169 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) { |
|
| 3170 | + cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
| 3171 | + } |
|
| 3002 | 3172 | |
| 3003 | 3173 | // Didn't work. |
| 3004 | 3174 | return $size; |
@@ -3016,8 +3186,9 @@ discard block |
||
| 3016 | 3186 | |
| 3017 | 3187 | // Under SSI this function can be called more then once. That can cause some problems. |
| 3018 | 3188 | // So only run the function once unless we are forced to run it again. |
| 3019 | - if ($loaded && !$forceload) |
|
| 3020 | - return; |
|
| 3189 | + if ($loaded && !$forceload) { |
|
| 3190 | + return; |
|
| 3191 | + } |
|
| 3021 | 3192 | |
| 3022 | 3193 | $loaded = true; |
| 3023 | 3194 | |
@@ -3029,14 +3200,16 @@ discard block |
||
| 3029 | 3200 | $context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news']))))); |
| 3030 | 3201 | for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++) |
| 3031 | 3202 | { |
| 3032 | - if (trim($context['news_lines'][$i]) == '') |
|
| 3033 | - continue; |
|
| 3203 | + if (trim($context['news_lines'][$i]) == '') { |
|
| 3204 | + continue; |
|
| 3205 | + } |
|
| 3034 | 3206 | |
| 3035 | 3207 | // Clean it up for presentation ;). |
| 3036 | 3208 | $context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i); |
| 3037 | 3209 | } |
| 3038 | - if (!empty($context['news_lines'])) |
|
| 3039 | - $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
| 3210 | + if (!empty($context['news_lines'])) { |
|
| 3211 | + $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
| 3212 | + } |
|
| 3040 | 3213 | |
| 3041 | 3214 | if (!$user_info['is_guest']) |
| 3042 | 3215 | { |
@@ -3045,40 +3218,48 @@ discard block |
||
| 3045 | 3218 | $context['user']['alerts'] = &$user_info['alerts']; |
| 3046 | 3219 | |
| 3047 | 3220 | // Personal message popup... |
| 3048 | - if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) |
|
| 3049 | - $context['user']['popup_messages'] = true; |
|
| 3050 | - else |
|
| 3051 | - $context['user']['popup_messages'] = false; |
|
| 3221 | + if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) { |
|
| 3222 | + $context['user']['popup_messages'] = true; |
|
| 3223 | + } else { |
|
| 3224 | + $context['user']['popup_messages'] = false; |
|
| 3225 | + } |
|
| 3052 | 3226 | $_SESSION['unread_messages'] = $user_info['unread_messages']; |
| 3053 | 3227 | |
| 3054 | - if (allowedTo('moderate_forum')) |
|
| 3055 | - $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
| 3228 | + if (allowedTo('moderate_forum')) { |
|
| 3229 | + $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
| 3230 | + } |
|
| 3056 | 3231 | |
| 3057 | 3232 | $context['user']['avatar'] = array(); |
| 3058 | 3233 | |
| 3059 | 3234 | // Check for gravatar first since we might be forcing them... |
| 3060 | 3235 | if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride'])) |
| 3061 | 3236 | { |
| 3062 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) |
|
| 3063 | - $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
| 3064 | - else |
|
| 3065 | - $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
| 3237 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) { |
|
| 3238 | + $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
| 3239 | + } else { |
|
| 3240 | + $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
| 3241 | + } |
|
| 3066 | 3242 | } |
| 3067 | 3243 | // Uploaded? |
| 3068 | - elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) |
|
| 3069 | - $context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar'; |
|
| 3244 | + elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) { |
|
| 3245 | + $context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar'; |
|
| 3246 | + } |
|
| 3070 | 3247 | // Full URL? |
| 3071 | - elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) |
|
| 3072 | - $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
| 3248 | + elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) { |
|
| 3249 | + $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
| 3250 | + } |
|
| 3073 | 3251 | // Otherwise we assume it's server stored. |
| 3074 | - elseif ($user_info['avatar']['url'] != '') |
|
| 3075 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
| 3252 | + elseif ($user_info['avatar']['url'] != '') { |
|
| 3253 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
| 3254 | + } |
|
| 3076 | 3255 | // No avatar at all? Fine, we have a big fat default avatar ;) |
| 3077 | - else |
|
| 3078 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
| 3256 | + else { |
|
| 3257 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
| 3258 | + } |
|
| 3079 | 3259 | |
| 3080 | - if (!empty($context['user']['avatar'])) |
|
| 3081 | - $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
| 3260 | + if (!empty($context['user']['avatar'])) { |
|
| 3261 | + $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
| 3262 | + } |
|
| 3082 | 3263 | |
| 3083 | 3264 | // Figure out how long they've been logged in. |
| 3084 | 3265 | $context['user']['total_time_logged_in'] = array( |
@@ -3086,8 +3267,7 @@ discard block |
||
| 3086 | 3267 | 'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600), |
| 3087 | 3268 | 'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60) |
| 3088 | 3269 | ); |
| 3089 | - } |
|
| 3090 | - else |
|
| 3270 | + } else |
|
| 3091 | 3271 | { |
| 3092 | 3272 | $context['user']['messages'] = 0; |
| 3093 | 3273 | $context['user']['unread_messages'] = 0; |
@@ -3095,12 +3275,14 @@ discard block |
||
| 3095 | 3275 | $context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0); |
| 3096 | 3276 | $context['user']['popup_messages'] = false; |
| 3097 | 3277 | |
| 3098 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) |
|
| 3099 | - $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
| 3278 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) { |
|
| 3279 | + $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
| 3280 | + } |
|
| 3100 | 3281 | |
| 3101 | 3282 | // If we've upgraded recently, go easy on the passwords. |
| 3102 | - if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) |
|
| 3103 | - $context['disable_login_hashing'] = true; |
|
| 3283 | + if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) { |
|
| 3284 | + $context['disable_login_hashing'] = true; |
|
| 3285 | + } |
|
| 3104 | 3286 | } |
| 3105 | 3287 | |
| 3106 | 3288 | // Setup the main menu items. |
@@ -3113,8 +3295,8 @@ discard block |
||
| 3113 | 3295 | $context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm'); |
| 3114 | 3296 | |
| 3115 | 3297 | // 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array. |
| 3116 | - if ($context['show_pm_popup']) |
|
| 3117 | - addInlineJavaScript(' |
|
| 3298 | + if ($context['show_pm_popup']) { |
|
| 3299 | + addInlineJavaScript(' |
|
| 3118 | 3300 | jQuery(document).ready(function($) { |
| 3119 | 3301 | new smc_Popup({ |
| 3120 | 3302 | heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ', |
@@ -3122,15 +3304,17 @@ discard block |
||
| 3122 | 3304 | icon_class: \'generic_icons mail_new\' |
| 3123 | 3305 | }); |
| 3124 | 3306 | });'); |
| 3307 | + } |
|
| 3125 | 3308 | |
| 3126 | 3309 | // Add a generic "Are you sure?" confirmation message. |
| 3127 | 3310 | addInlineJavaScript(' |
| 3128 | 3311 | var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
| 3129 | 3312 | |
| 3130 | 3313 | // Now add the capping code for avatars. |
| 3131 | - if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') |
|
| 3132 | - addInlineCss(' |
|
| 3314 | + if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') { |
|
| 3315 | + addInlineCss(' |
|
| 3133 | 3316 | img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }'); |
| 3317 | + } |
|
| 3134 | 3318 | |
| 3135 | 3319 | // This looks weird, but it's because BoardIndex.php references the variable. |
| 3136 | 3320 | $context['common_stats']['latest_member'] = array( |
@@ -3147,11 +3331,13 @@ discard block |
||
| 3147 | 3331 | ); |
| 3148 | 3332 | $context['common_stats']['boardindex_total_posts'] = sprintf($txt['boardindex_total_posts'], $context['common_stats']['total_posts'], $context['common_stats']['total_topics'], $context['common_stats']['total_members']); |
| 3149 | 3333 | |
| 3150 | - if (empty($settings['theme_version'])) |
|
| 3151 | - addJavaScriptVar('smf_scripturl', $scripturl); |
|
| 3334 | + if (empty($settings['theme_version'])) { |
|
| 3335 | + addJavaScriptVar('smf_scripturl', $scripturl); |
|
| 3336 | + } |
|
| 3152 | 3337 | |
| 3153 | - if (!isset($context['page_title'])) |
|
| 3154 | - $context['page_title'] = ''; |
|
| 3338 | + if (!isset($context['page_title'])) { |
|
| 3339 | + $context['page_title'] = ''; |
|
| 3340 | + } |
|
| 3155 | 3341 | |
| 3156 | 3342 | // Set some specific vars. |
| 3157 | 3343 | $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
@@ -3161,21 +3347,23 @@ discard block |
||
| 3161 | 3347 | $context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']); |
| 3162 | 3348 | $context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']); |
| 3163 | 3349 | |
| 3164 | - if (!empty($context['meta_keywords'])) |
|
| 3165 | - $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
| 3350 | + if (!empty($context['meta_keywords'])) { |
|
| 3351 | + $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
| 3352 | + } |
|
| 3166 | 3353 | |
| 3167 | - if (!empty($context['canonical_url'])) |
|
| 3168 | - $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
| 3354 | + if (!empty($context['canonical_url'])) { |
|
| 3355 | + $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
| 3356 | + } |
|
| 3169 | 3357 | |
| 3170 | - if (!empty($settings['og_image'])) |
|
| 3171 | - $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
| 3358 | + if (!empty($settings['og_image'])) { |
|
| 3359 | + $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
| 3360 | + } |
|
| 3172 | 3361 | |
| 3173 | 3362 | if (!empty($context['meta_description'])) |
| 3174 | 3363 | { |
| 3175 | 3364 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']); |
| 3176 | 3365 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']); |
| 3177 | - } |
|
| 3178 | - else |
|
| 3366 | + } else |
|
| 3179 | 3367 | { |
| 3180 | 3368 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']); |
| 3181 | 3369 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']); |
@@ -3200,8 +3388,9 @@ discard block |
||
| 3200 | 3388 | $memory_needed = memoryReturnBytes($needed); |
| 3201 | 3389 | |
| 3202 | 3390 | // should we account for how much is currently being used? |
| 3203 | - if ($in_use) |
|
| 3204 | - $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
| 3391 | + if ($in_use) { |
|
| 3392 | + $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
| 3393 | + } |
|
| 3205 | 3394 | |
| 3206 | 3395 | // if more is needed, request it |
| 3207 | 3396 | if ($memory_current < $memory_needed) |
@@ -3224,8 +3413,9 @@ discard block |
||
| 3224 | 3413 | */ |
| 3225 | 3414 | function memoryReturnBytes($val) |
| 3226 | 3415 | { |
| 3227 | - if (is_integer($val)) |
|
| 3228 | - return $val; |
|
| 3416 | + if (is_integer($val)) { |
|
| 3417 | + return $val; |
|
| 3418 | + } |
|
| 3229 | 3419 | |
| 3230 | 3420 | // Separate the number from the designator |
| 3231 | 3421 | $val = trim($val); |
@@ -3261,10 +3451,11 @@ discard block |
||
| 3261 | 3451 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
| 3262 | 3452 | |
| 3263 | 3453 | // Are we debugging the template/html content? |
| 3264 | - if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) |
|
| 3265 | - header('Content-Type: application/xhtml+xml'); |
|
| 3266 | - elseif (!isset($_REQUEST['xml'])) |
|
| 3267 | - header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3454 | + if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) { |
|
| 3455 | + header('Content-Type: application/xhtml+xml'); |
|
| 3456 | + } elseif (!isset($_REQUEST['xml'])) { |
|
| 3457 | + header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3458 | + } |
|
| 3268 | 3459 | } |
| 3269 | 3460 | |
| 3270 | 3461 | header('Content-Type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
@@ -3273,8 +3464,9 @@ discard block |
||
| 3273 | 3464 | if ($context['in_maintenance'] && $context['user']['is_admin']) |
| 3274 | 3465 | { |
| 3275 | 3466 | $position = array_search('body', $context['template_layers']); |
| 3276 | - if ($position === false) |
|
| 3277 | - $position = array_search('main', $context['template_layers']); |
|
| 3467 | + if ($position === false) { |
|
| 3468 | + $position = array_search('main', $context['template_layers']); |
|
| 3469 | + } |
|
| 3278 | 3470 | |
| 3279 | 3471 | if ($position !== false) |
| 3280 | 3472 | { |
@@ -3302,23 +3494,25 @@ discard block |
||
| 3302 | 3494 | |
| 3303 | 3495 | foreach ($securityFiles as $i => $securityFile) |
| 3304 | 3496 | { |
| 3305 | - if (!file_exists($boarddir . '/' . $securityFile)) |
|
| 3306 | - unset($securityFiles[$i]); |
|
| 3497 | + if (!file_exists($boarddir . '/' . $securityFile)) { |
|
| 3498 | + unset($securityFiles[$i]); |
|
| 3499 | + } |
|
| 3307 | 3500 | } |
| 3308 | 3501 | |
| 3309 | 3502 | // We are already checking so many files...just few more doesn't make any difference! :P |
| 3310 | - if (!empty($modSettings['currentAttachmentUploadDir'])) |
|
| 3311 | - $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
| 3312 | - |
|
| 3313 | - else |
|
| 3314 | - $path = $modSettings['attachmentUploadDir']; |
|
| 3503 | + if (!empty($modSettings['currentAttachmentUploadDir'])) { |
|
| 3504 | + $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
| 3505 | + } else { |
|
| 3506 | + $path = $modSettings['attachmentUploadDir']; |
|
| 3507 | + } |
|
| 3315 | 3508 | |
| 3316 | 3509 | secureDirectory($path, true); |
| 3317 | 3510 | secureDirectory($cachedir); |
| 3318 | 3511 | |
| 3319 | 3512 | // If agreement is enabled, at least the english version shall exists |
| 3320 | - if ($modSettings['requireAgreement']) |
|
| 3321 | - $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
| 3513 | + if ($modSettings['requireAgreement']) { |
|
| 3514 | + $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
| 3515 | + } |
|
| 3322 | 3516 | |
| 3323 | 3517 | if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement)) |
| 3324 | 3518 | { |
@@ -3333,18 +3527,21 @@ discard block |
||
| 3333 | 3527 | echo ' |
| 3334 | 3528 | ', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>'; |
| 3335 | 3529 | |
| 3336 | - if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') |
|
| 3337 | - echo ' |
|
| 3530 | + if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') { |
|
| 3531 | + echo ' |
|
| 3338 | 3532 | ', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>'; |
| 3533 | + } |
|
| 3339 | 3534 | } |
| 3340 | 3535 | |
| 3341 | - if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) |
|
| 3342 | - echo ' |
|
| 3536 | + if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) { |
|
| 3537 | + echo ' |
|
| 3343 | 3538 | <strong>', $txt['cache_writable'], '</strong><br>'; |
| 3539 | + } |
|
| 3344 | 3540 | |
| 3345 | - if (!empty($agreement)) |
|
| 3346 | - echo ' |
|
| 3541 | + if (!empty($agreement)) { |
|
| 3542 | + echo ' |
|
| 3347 | 3543 | <strong>', $txt['agreement_missing'], '</strong><br>'; |
| 3544 | + } |
|
| 3348 | 3545 | |
| 3349 | 3546 | echo ' |
| 3350 | 3547 | </p> |
@@ -3359,16 +3556,18 @@ discard block |
||
| 3359 | 3556 | <div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;"> |
| 3360 | 3557 | ', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']); |
| 3361 | 3558 | |
| 3362 | - if (!empty($_SESSION['ban']['cannot_post']['reason'])) |
|
| 3363 | - echo ' |
|
| 3559 | + if (!empty($_SESSION['ban']['cannot_post']['reason'])) { |
|
| 3560 | + echo ' |
|
| 3364 | 3561 | <div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>'; |
| 3562 | + } |
|
| 3365 | 3563 | |
| 3366 | - if (!empty($_SESSION['ban']['expire_time'])) |
|
| 3367 | - echo ' |
|
| 3564 | + if (!empty($_SESSION['ban']['expire_time'])) { |
|
| 3565 | + echo ' |
|
| 3368 | 3566 | <div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>'; |
| 3369 | - else |
|
| 3370 | - echo ' |
|
| 3567 | + } else { |
|
| 3568 | + echo ' |
|
| 3371 | 3569 | <div>', $txt['your_ban_expires_never'], '</div>'; |
| 3570 | + } |
|
| 3372 | 3571 | |
| 3373 | 3572 | echo ' |
| 3374 | 3573 | </div>'; |
@@ -3384,8 +3583,9 @@ discard block |
||
| 3384 | 3583 | global $forum_copyright, $software_year, $forum_version; |
| 3385 | 3584 | |
| 3386 | 3585 | // Don't display copyright for things like SSI. |
| 3387 | - if (!isset($forum_version) || !isset($software_year)) |
|
| 3388 | - return; |
|
| 3586 | + if (!isset($forum_version) || !isset($software_year)) { |
|
| 3587 | + return; |
|
| 3588 | + } |
|
| 3389 | 3589 | |
| 3390 | 3590 | // Put in the version... |
| 3391 | 3591 | printf($forum_copyright, $forum_version, $software_year); |
@@ -3403,9 +3603,10 @@ discard block |
||
| 3403 | 3603 | $context['load_time'] = comma_format(round(array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)), 3)); |
| 3404 | 3604 | $context['load_queries'] = $db_count; |
| 3405 | 3605 | |
| 3406 | - foreach (array_reverse($context['template_layers']) as $layer) |
|
| 3407 | - loadSubTemplate($layer . '_below', true); |
|
| 3408 | -} |
|
| 3606 | + foreach (array_reverse($context['template_layers']) as $layer) { |
|
| 3607 | + loadSubTemplate($layer . '_below', true); |
|
| 3608 | + } |
|
| 3609 | + } |
|
| 3409 | 3610 | |
| 3410 | 3611 | /** |
| 3411 | 3612 | * Output the Javascript files |
@@ -3436,8 +3637,7 @@ discard block |
||
| 3436 | 3637 | { |
| 3437 | 3638 | echo ' |
| 3438 | 3639 | var ', $key, ';'; |
| 3439 | - } |
|
| 3440 | - else |
|
| 3640 | + } else |
|
| 3441 | 3641 | { |
| 3442 | 3642 | echo ' |
| 3443 | 3643 | var ', $key, ' = ', $value, ';'; |
@@ -3452,26 +3652,27 @@ discard block |
||
| 3452 | 3652 | foreach ($context['javascript_files'] as $id => $js_file) |
| 3453 | 3653 | { |
| 3454 | 3654 | // Last minute call! allow theme authors to disable single files. |
| 3455 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
| 3456 | - continue; |
|
| 3655 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
| 3656 | + continue; |
|
| 3657 | + } |
|
| 3457 | 3658 | |
| 3458 | 3659 | // By default all files don't get minimized unless the file explicitly says so! |
| 3459 | 3660 | if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
| 3460 | 3661 | { |
| 3461 | - if ($do_deferred && !empty($js_file['options']['defer'])) |
|
| 3462 | - $toMinifyDefer[] = $js_file; |
|
| 3463 | - |
|
| 3464 | - elseif (!$do_deferred && empty($js_file['options']['defer'])) |
|
| 3465 | - $toMinify[] = $js_file; |
|
| 3662 | + if ($do_deferred && !empty($js_file['options']['defer'])) { |
|
| 3663 | + $toMinifyDefer[] = $js_file; |
|
| 3664 | + } elseif (!$do_deferred && empty($js_file['options']['defer'])) { |
|
| 3665 | + $toMinify[] = $js_file; |
|
| 3666 | + } |
|
| 3466 | 3667 | |
| 3467 | 3668 | // Grab a random seed. |
| 3468 | - if (!isset($minSeed)) |
|
| 3469 | - $minSeed = $js_file['options']['seed']; |
|
| 3470 | - } |
|
| 3471 | - |
|
| 3472 | - elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) |
|
| 3473 | - echo ' |
|
| 3669 | + if (!isset($minSeed)) { |
|
| 3670 | + $minSeed = $js_file['options']['seed']; |
|
| 3671 | + } |
|
| 3672 | + } elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) { |
|
| 3673 | + echo ' |
|
| 3474 | 3674 | <script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async="async"' : '', '></script>'; |
| 3675 | + } |
|
| 3475 | 3676 | } |
| 3476 | 3677 | |
| 3477 | 3678 | if ((!$do_deferred && !empty($toMinify)) || ($do_deferred && !empty($toMinifyDefer))) |
@@ -3479,14 +3680,14 @@ discard block |
||
| 3479 | 3680 | $result = custMinify(($do_deferred ? $toMinifyDefer : $toMinify), 'js', $do_deferred); |
| 3480 | 3681 | |
| 3481 | 3682 | // Minify process couldn't work, print each individual files. |
| 3482 | - if (!empty($result) && is_array($result)) |
|
| 3483 | - foreach ($result as $minFailedFile) |
|
| 3683 | + if (!empty($result) && is_array($result)) { |
|
| 3684 | + foreach ($result as $minFailedFile) |
|
| 3484 | 3685 | echo ' |
| 3485 | 3686 | <script src="', $minFailedFile['fileUrl'], '"', !empty($minFailedFile['options']['async']) ? ' async="async"' : '', '></script>'; |
| 3486 | - |
|
| 3487 | - else |
|
| 3488 | - echo ' |
|
| 3687 | + } else { |
|
| 3688 | + echo ' |
|
| 3489 | 3689 | <script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>'; |
| 3690 | + } |
|
| 3490 | 3691 | } |
| 3491 | 3692 | |
| 3492 | 3693 | // Inline JavaScript - Actually useful some times! |
@@ -3497,8 +3698,9 @@ discard block |
||
| 3497 | 3698 | echo ' |
| 3498 | 3699 | <script>'; |
| 3499 | 3700 | |
| 3500 | - foreach ($context['javascript_inline']['defer'] as $js_code) |
|
| 3501 | - echo $js_code; |
|
| 3701 | + foreach ($context['javascript_inline']['defer'] as $js_code) { |
|
| 3702 | + echo $js_code; |
|
| 3703 | + } |
|
| 3502 | 3704 | |
| 3503 | 3705 | echo ' |
| 3504 | 3706 | </script>'; |
@@ -3509,8 +3711,9 @@ discard block |
||
| 3509 | 3711 | echo ' |
| 3510 | 3712 | <script>'; |
| 3511 | 3713 | |
| 3512 | - foreach ($context['javascript_inline']['standard'] as $js_code) |
|
| 3513 | - echo $js_code; |
|
| 3714 | + foreach ($context['javascript_inline']['standard'] as $js_code) { |
|
| 3715 | + echo $js_code; |
|
| 3716 | + } |
|
| 3514 | 3717 | |
| 3515 | 3718 | echo ' |
| 3516 | 3719 | </script>'; |
@@ -3535,8 +3738,9 @@ discard block |
||
| 3535 | 3738 | foreach ($context['css_files'] as $id => $file) |
| 3536 | 3739 | { |
| 3537 | 3740 | // Last minute call! allow theme authors to disable single files. |
| 3538 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
| 3539 | - continue; |
|
| 3741 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
| 3742 | + continue; |
|
| 3743 | + } |
|
| 3540 | 3744 | |
| 3541 | 3745 | // By default all files don't get minimized unless the file explicitly says so! |
| 3542 | 3746 | if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
@@ -3544,12 +3748,12 @@ discard block |
||
| 3544 | 3748 | $toMinify[] = $file; |
| 3545 | 3749 | |
| 3546 | 3750 | // Grab a random seed. |
| 3547 | - if (!isset($minSeed)) |
|
| 3548 | - $minSeed = $file['options']['seed']; |
|
| 3751 | + if (!isset($minSeed)) { |
|
| 3752 | + $minSeed = $file['options']['seed']; |
|
| 3753 | + } |
|
| 3754 | + } else { |
|
| 3755 | + $normal[] = $file['fileUrl']; |
|
| 3549 | 3756 | } |
| 3550 | - |
|
| 3551 | - else |
|
| 3552 | - $normal[] = $file['fileUrl']; |
|
| 3553 | 3757 | } |
| 3554 | 3758 | |
| 3555 | 3759 | if (!empty($toMinify)) |
@@ -3557,28 +3761,30 @@ discard block |
||
| 3557 | 3761 | $result = custMinify($toMinify, 'css'); |
| 3558 | 3762 | |
| 3559 | 3763 | // Minify process couldn't work, print each individual files. |
| 3560 | - if (!empty($result) && is_array($result)) |
|
| 3561 | - foreach ($result as $minFailedFile) |
|
| 3764 | + if (!empty($result) && is_array($result)) { |
|
| 3765 | + foreach ($result as $minFailedFile) |
|
| 3562 | 3766 | echo ' |
| 3563 | 3767 | <link rel="stylesheet" href="', $minFailedFile['fileUrl'], '">'; |
| 3564 | - |
|
| 3565 | - else |
|
| 3566 | - echo ' |
|
| 3768 | + } else { |
|
| 3769 | + echo ' |
|
| 3567 | 3770 | <link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">'; |
| 3771 | + } |
|
| 3568 | 3772 | } |
| 3569 | 3773 | |
| 3570 | 3774 | // Print the rest after the minified files. |
| 3571 | - if (!empty($normal)) |
|
| 3572 | - foreach ($normal as $nf) |
|
| 3775 | + if (!empty($normal)) { |
|
| 3776 | + foreach ($normal as $nf) |
|
| 3573 | 3777 | echo ' |
| 3574 | 3778 | <link rel="stylesheet" href="', $nf ,'">'; |
| 3779 | + } |
|
| 3575 | 3780 | |
| 3576 | 3781 | if ($db_show_debug === true) |
| 3577 | 3782 | { |
| 3578 | 3783 | // Try to keep only what's useful. |
| 3579 | 3784 | $repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => ''); |
| 3580 | - foreach ($context['css_files'] as $file) |
|
| 3581 | - $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
| 3785 | + foreach ($context['css_files'] as $file) { |
|
| 3786 | + $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
| 3787 | + } |
|
| 3582 | 3788 | } |
| 3583 | 3789 | |
| 3584 | 3790 | if (!empty($context['css_header'])) |
@@ -3586,9 +3792,10 @@ discard block |
||
| 3586 | 3792 | echo ' |
| 3587 | 3793 | <style>'; |
| 3588 | 3794 | |
| 3589 | - foreach ($context['css_header'] as $css) |
|
| 3590 | - echo $css .' |
|
| 3795 | + foreach ($context['css_header'] as $css) { |
|
| 3796 | + echo $css .' |
|
| 3591 | 3797 | '; |
| 3798 | + } |
|
| 3592 | 3799 | |
| 3593 | 3800 | echo' |
| 3594 | 3801 | </style>'; |
@@ -3612,15 +3819,17 @@ discard block |
||
| 3612 | 3819 | $type = !empty($type) && in_array($type, $types) ? $type : false; |
| 3613 | 3820 | $data = !empty($data) ? $data : false; |
| 3614 | 3821 | |
| 3615 | - if (empty($type) || empty($data)) |
|
| 3616 | - return false; |
|
| 3822 | + if (empty($type) || empty($data)) { |
|
| 3823 | + return false; |
|
| 3824 | + } |
|
| 3617 | 3825 | |
| 3618 | 3826 | // Did we already did this? |
| 3619 | 3827 | $toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400); |
| 3620 | 3828 | |
| 3621 | 3829 | // Already done? |
| 3622 | - if (!empty($toCache)) |
|
| 3623 | - return true; |
|
| 3830 | + if (!empty($toCache)) { |
|
| 3831 | + return true; |
|
| 3832 | + } |
|
| 3624 | 3833 | |
| 3625 | 3834 | // No namespaces, sorry! |
| 3626 | 3835 | $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
@@ -3702,8 +3911,9 @@ discard block |
||
| 3702 | 3911 | global $modSettings, $smcFunc; |
| 3703 | 3912 | |
| 3704 | 3913 | // Just make up a nice hash... |
| 3705 | - if ($new) |
|
| 3706 | - return sha1(md5($filename . time()) . mt_rand()); |
|
| 3914 | + if ($new) { |
|
| 3915 | + return sha1(md5($filename . time()) . mt_rand()); |
|
| 3916 | + } |
|
| 3707 | 3917 | |
| 3708 | 3918 | // Just make sure that attachment id is only a int |
| 3709 | 3919 | $attachment_id = (int) $attachment_id; |
@@ -3720,23 +3930,25 @@ discard block |
||
| 3720 | 3930 | 'id_attach' => $attachment_id, |
| 3721 | 3931 | )); |
| 3722 | 3932 | |
| 3723 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 3724 | - return false; |
|
| 3933 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 3934 | + return false; |
|
| 3935 | + } |
|
| 3725 | 3936 | |
| 3726 | 3937 | list ($file_hash) = $smcFunc['db_fetch_row']($request); |
| 3727 | 3938 | $smcFunc['db_free_result']($request); |
| 3728 | 3939 | } |
| 3729 | 3940 | |
| 3730 | 3941 | // Still no hash? mmm... |
| 3731 | - if (empty($file_hash)) |
|
| 3732 | - $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
| 3942 | + if (empty($file_hash)) { |
|
| 3943 | + $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
| 3944 | + } |
|
| 3733 | 3945 | |
| 3734 | 3946 | // Are we using multiple directories? |
| 3735 | - if (is_array($modSettings['attachmentUploadDir'])) |
|
| 3736 | - $path = $modSettings['attachmentUploadDir'][$dir]; |
|
| 3737 | - |
|
| 3738 | - else |
|
| 3739 | - $path = $modSettings['attachmentUploadDir']; |
|
| 3947 | + if (is_array($modSettings['attachmentUploadDir'])) { |
|
| 3948 | + $path = $modSettings['attachmentUploadDir'][$dir]; |
|
| 3949 | + } else { |
|
| 3950 | + $path = $modSettings['attachmentUploadDir']; |
|
| 3951 | + } |
|
| 3740 | 3952 | |
| 3741 | 3953 | return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
| 3742 | 3954 | } |
@@ -3751,8 +3963,9 @@ discard block |
||
| 3751 | 3963 | function ip2range($fullip) |
| 3752 | 3964 | { |
| 3753 | 3965 | // Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.) |
| 3754 | - if ($fullip == 'unknown') |
|
| 3755 | - $fullip = '255.255.255.255'; |
|
| 3966 | + if ($fullip == 'unknown') { |
|
| 3967 | + $fullip = '255.255.255.255'; |
|
| 3968 | + } |
|
| 3756 | 3969 | |
| 3757 | 3970 | $ip_parts = explode('-', $fullip); |
| 3758 | 3971 | $ip_array = array(); |
@@ -3776,10 +3989,11 @@ discard block |
||
| 3776 | 3989 | $ip_array['low'] = $ip_parts[0]; |
| 3777 | 3990 | $ip_array['high'] = $ip_parts[1]; |
| 3778 | 3991 | return $ip_array; |
| 3779 | - } |
|
| 3780 | - elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.* |
|
| 3992 | + } elseif (count($ip_parts) == 2) { |
|
| 3993 | + // if ip 22.22.*-22.22.* |
|
| 3781 | 3994 | { |
| 3782 | 3995 | $valid_low = isValidIP($ip_parts[0]); |
| 3996 | + } |
|
| 3783 | 3997 | $valid_high = isValidIP($ip_parts[1]); |
| 3784 | 3998 | $count = 0; |
| 3785 | 3999 | $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
@@ -3794,7 +4008,9 @@ discard block |
||
| 3794 | 4008 | $ip_parts[0] .= $mode . $min; |
| 3795 | 4009 | $valid_low = isValidIP($ip_parts[0]); |
| 3796 | 4010 | $count++; |
| 3797 | - if ($count > 9) break; |
|
| 4011 | + if ($count > 9) { |
|
| 4012 | + break; |
|
| 4013 | + } |
|
| 3798 | 4014 | } |
| 3799 | 4015 | } |
| 3800 | 4016 | |
@@ -3808,7 +4024,9 @@ discard block |
||
| 3808 | 4024 | $ip_parts[1] .= $mode . $max; |
| 3809 | 4025 | $valid_high = isValidIP($ip_parts[1]); |
| 3810 | 4026 | $count++; |
| 3811 | - if ($count > 9) break; |
|
| 4027 | + if ($count > 9) { |
|
| 4028 | + break; |
|
| 4029 | + } |
|
| 3812 | 4030 | } |
| 3813 | 4031 | } |
| 3814 | 4032 | |
@@ -3833,46 +4051,54 @@ discard block |
||
| 3833 | 4051 | { |
| 3834 | 4052 | global $modSettings; |
| 3835 | 4053 | |
| 3836 | - if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) |
|
| 3837 | - return $host; |
|
| 4054 | + if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) { |
|
| 4055 | + return $host; |
|
| 4056 | + } |
|
| 3838 | 4057 | $t = microtime(); |
| 3839 | 4058 | |
| 3840 | 4059 | // Try the Linux host command, perhaps? |
| 3841 | 4060 | if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1) |
| 3842 | 4061 | { |
| 3843 | - if (!isset($modSettings['host_to_dis'])) |
|
| 3844 | - $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
| 3845 | - else |
|
| 3846 | - $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
| 4062 | + if (!isset($modSettings['host_to_dis'])) { |
|
| 4063 | + $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
| 4064 | + } else { |
|
| 4065 | + $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
| 4066 | + } |
|
| 3847 | 4067 | |
| 3848 | 4068 | // Did host say it didn't find anything? |
| 3849 | - if (strpos($test, 'not found') !== false) |
|
| 3850 | - $host = ''; |
|
| 4069 | + if (strpos($test, 'not found') !== false) { |
|
| 4070 | + $host = ''; |
|
| 4071 | + } |
|
| 3851 | 4072 | // Invalid server option? |
| 3852 | - elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) |
|
| 3853 | - updateSettings(array('host_to_dis' => 1)); |
|
| 4073 | + elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) { |
|
| 4074 | + updateSettings(array('host_to_dis' => 1)); |
|
| 4075 | + } |
|
| 3854 | 4076 | // Maybe it found something, after all? |
| 3855 | - elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) |
|
| 3856 | - $host = $match[1]; |
|
| 4077 | + elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) { |
|
| 4078 | + $host = $match[1]; |
|
| 4079 | + } |
|
| 3857 | 4080 | } |
| 3858 | 4081 | |
| 3859 | 4082 | // This is nslookup; usually only Windows, but possibly some Unix? |
| 3860 | 4083 | if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1) |
| 3861 | 4084 | { |
| 3862 | 4085 | $test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip)); |
| 3863 | - if (strpos($test, 'Non-existent domain') !== false) |
|
| 3864 | - $host = ''; |
|
| 3865 | - elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) |
|
| 3866 | - $host = $match[1]; |
|
| 4086 | + if (strpos($test, 'Non-existent domain') !== false) { |
|
| 4087 | + $host = ''; |
|
| 4088 | + } elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) { |
|
| 4089 | + $host = $match[1]; |
|
| 4090 | + } |
|
| 3867 | 4091 | } |
| 3868 | 4092 | |
| 3869 | 4093 | // This is the last try :/. |
| 3870 | - if (!isset($host) || $host === false) |
|
| 3871 | - $host = @gethostbyaddr($ip); |
|
| 4094 | + if (!isset($host) || $host === false) { |
|
| 4095 | + $host = @gethostbyaddr($ip); |
|
| 4096 | + } |
|
| 3872 | 4097 | |
| 3873 | 4098 | // It took a long time, so let's cache it! |
| 3874 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) |
|
| 3875 | - cache_put_data('hostlookup-' . $ip, $host, 600); |
|
| 4099 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) { |
|
| 4100 | + cache_put_data('hostlookup-' . $ip, $host, 600); |
|
| 4101 | + } |
|
| 3876 | 4102 | |
| 3877 | 4103 | return $host; |
| 3878 | 4104 | } |
@@ -3908,20 +4134,21 @@ discard block |
||
| 3908 | 4134 | { |
| 3909 | 4135 | $encrypted = substr(crypt($word, 'uk'), 2, $max_chars); |
| 3910 | 4136 | $total = 0; |
| 3911 | - for ($i = 0; $i < $max_chars; $i++) |
|
| 3912 | - $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
| 4137 | + for ($i = 0; $i < $max_chars; $i++) { |
|
| 4138 | + $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
| 4139 | + } |
|
| 3913 | 4140 | $returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total; |
| 3914 | 4141 | } |
| 3915 | 4142 | } |
| 3916 | 4143 | return array_unique($returned_ints); |
| 3917 | - } |
|
| 3918 | - else |
|
| 4144 | + } else |
|
| 3919 | 4145 | { |
| 3920 | 4146 | // Trim characters before and after and add slashes for database insertion. |
| 3921 | 4147 | $returned_words = array(); |
| 3922 | - foreach ($words as $word) |
|
| 3923 | - if (($word = trim($word, '-_\'')) !== '') |
|
| 4148 | + foreach ($words as $word) { |
|
| 4149 | + if (($word = trim($word, '-_\'')) !== '') |
|
| 3924 | 4150 | $returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars); |
| 4151 | + } |
|
| 3925 | 4152 | |
| 3926 | 4153 | // Filter out all words that occur more than once. |
| 3927 | 4154 | return array_unique($returned_words); |
@@ -3943,16 +4170,18 @@ discard block |
||
| 3943 | 4170 | global $settings, $txt; |
| 3944 | 4171 | |
| 3945 | 4172 | // Does the current loaded theme have this and we are not forcing the usage of this function? |
| 3946 | - if (function_exists('template_create_button') && !$force_use) |
|
| 3947 | - return template_create_button($name, $alt, $label = '', $custom = ''); |
|
| 4173 | + if (function_exists('template_create_button') && !$force_use) { |
|
| 4174 | + return template_create_button($name, $alt, $label = '', $custom = ''); |
|
| 4175 | + } |
|
| 3948 | 4176 | |
| 3949 | - if (!$settings['use_image_buttons']) |
|
| 3950 | - return $txt[$alt]; |
|
| 3951 | - elseif (!empty($settings['use_buttons'])) |
|
| 3952 | - return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
| 3953 | - else |
|
| 3954 | - return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
| 3955 | -} |
|
| 4177 | + if (!$settings['use_image_buttons']) { |
|
| 4178 | + return $txt[$alt]; |
|
| 4179 | + } elseif (!empty($settings['use_buttons'])) { |
|
| 4180 | + return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
| 4181 | + } else { |
|
| 4182 | + return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
| 4183 | + } |
|
| 4184 | + } |
|
| 3956 | 4185 | |
| 3957 | 4186 | /** |
| 3958 | 4187 | * Sets up all of the top menu buttons |
@@ -3995,9 +4224,10 @@ discard block |
||
| 3995 | 4224 | var user_menus = new smc_PopupMenu(); |
| 3996 | 4225 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
| 3997 | 4226 | user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
| 3998 | - if ($context['allow_pm']) |
|
| 3999 | - addInlineJavaScript(' |
|
| 4227 | + if ($context['allow_pm']) { |
|
| 4228 | + addInlineJavaScript(' |
|
| 4000 | 4229 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
| 4230 | + } |
|
| 4001 | 4231 | |
| 4002 | 4232 | if (!empty($modSettings['enable_ajax_alerts'])) |
| 4003 | 4233 | { |
@@ -4157,88 +4387,96 @@ discard block |
||
| 4157 | 4387 | |
| 4158 | 4388 | // Now we put the buttons in the context so the theme can use them. |
| 4159 | 4389 | $menu_buttons = array(); |
| 4160 | - foreach ($buttons as $act => $button) |
|
| 4161 | - if (!empty($button['show'])) |
|
| 4390 | + foreach ($buttons as $act => $button) { |
|
| 4391 | + if (!empty($button['show'])) |
|
| 4162 | 4392 | { |
| 4163 | 4393 | $button['active_button'] = false; |
| 4394 | + } |
|
| 4164 | 4395 | |
| 4165 | 4396 | // This button needs some action. |
| 4166 | - if (isset($button['action_hook'])) |
|
| 4167 | - $needs_action_hook = true; |
|
| 4397 | + if (isset($button['action_hook'])) { |
|
| 4398 | + $needs_action_hook = true; |
|
| 4399 | + } |
|
| 4168 | 4400 | |
| 4169 | 4401 | // Make sure the last button truly is the last button. |
| 4170 | 4402 | if (!empty($button['is_last'])) |
| 4171 | 4403 | { |
| 4172 | - if (isset($last_button)) |
|
| 4173 | - unset($menu_buttons[$last_button]['is_last']); |
|
| 4404 | + if (isset($last_button)) { |
|
| 4405 | + unset($menu_buttons[$last_button]['is_last']); |
|
| 4406 | + } |
|
| 4174 | 4407 | $last_button = $act; |
| 4175 | 4408 | } |
| 4176 | 4409 | |
| 4177 | 4410 | // Go through the sub buttons if there are any. |
| 4178 | - if (!empty($button['sub_buttons'])) |
|
| 4179 | - foreach ($button['sub_buttons'] as $key => $subbutton) |
|
| 4411 | + if (!empty($button['sub_buttons'])) { |
|
| 4412 | + foreach ($button['sub_buttons'] as $key => $subbutton) |
|
| 4180 | 4413 | { |
| 4181 | 4414 | if (empty($subbutton['show'])) |
| 4182 | 4415 | unset($button['sub_buttons'][$key]); |
| 4416 | + } |
|
| 4183 | 4417 | |
| 4184 | 4418 | // 2nd level sub buttons next... |
| 4185 | 4419 | if (!empty($subbutton['sub_buttons'])) |
| 4186 | 4420 | { |
| 4187 | 4421 | foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2) |
| 4188 | 4422 | { |
| 4189 | - if (empty($sub_button2['show'])) |
|
| 4190 | - unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
| 4423 | + if (empty($sub_button2['show'])) { |
|
| 4424 | + unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
| 4425 | + } |
|
| 4191 | 4426 | } |
| 4192 | 4427 | } |
| 4193 | 4428 | } |
| 4194 | 4429 | |
| 4195 | 4430 | // Does this button have its own icon? |
| 4196 | - if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) |
|
| 4197 | - $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4198 | - elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) |
|
| 4199 | - $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4200 | - elseif (isset($button['icon'])) |
|
| 4201 | - $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
| 4202 | - else |
|
| 4203 | - $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
| 4431 | + if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) { |
|
| 4432 | + $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4433 | + } elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) { |
|
| 4434 | + $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4435 | + } elseif (isset($button['icon'])) { |
|
| 4436 | + $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
| 4437 | + } else { |
|
| 4438 | + $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
| 4439 | + } |
|
| 4204 | 4440 | |
| 4205 | 4441 | $menu_buttons[$act] = $button; |
| 4206 | 4442 | } |
| 4207 | 4443 | |
| 4208 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 4209 | - cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
| 4444 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 4445 | + cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
| 4446 | + } |
|
| 4210 | 4447 | } |
| 4211 | 4448 | |
| 4212 | 4449 | $context['menu_buttons'] = $menu_buttons; |
| 4213 | 4450 | |
| 4214 | 4451 | // Logging out requires the session id in the url. |
| 4215 | - if (isset($context['menu_buttons']['logout'])) |
|
| 4216 | - $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
| 4452 | + if (isset($context['menu_buttons']['logout'])) { |
|
| 4453 | + $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
| 4454 | + } |
|
| 4217 | 4455 | |
| 4218 | 4456 | // Figure out which action we are doing so we can set the active tab. |
| 4219 | 4457 | // Default to home. |
| 4220 | 4458 | $current_action = 'home'; |
| 4221 | 4459 | |
| 4222 | - if (isset($context['menu_buttons'][$context['current_action']])) |
|
| 4223 | - $current_action = $context['current_action']; |
|
| 4224 | - elseif ($context['current_action'] == 'search2') |
|
| 4225 | - $current_action = 'search'; |
|
| 4226 | - elseif ($context['current_action'] == 'theme') |
|
| 4227 | - $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
| 4228 | - elseif ($context['current_action'] == 'register2') |
|
| 4229 | - $current_action = 'register'; |
|
| 4230 | - elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) |
|
| 4231 | - $current_action = 'login'; |
|
| 4232 | - elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) |
|
| 4233 | - $current_action = 'moderate'; |
|
| 4460 | + if (isset($context['menu_buttons'][$context['current_action']])) { |
|
| 4461 | + $current_action = $context['current_action']; |
|
| 4462 | + } elseif ($context['current_action'] == 'search2') { |
|
| 4463 | + $current_action = 'search'; |
|
| 4464 | + } elseif ($context['current_action'] == 'theme') { |
|
| 4465 | + $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
| 4466 | + } elseif ($context['current_action'] == 'register2') { |
|
| 4467 | + $current_action = 'register'; |
|
| 4468 | + } elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) { |
|
| 4469 | + $current_action = 'login'; |
|
| 4470 | + } elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) { |
|
| 4471 | + $current_action = 'moderate'; |
|
| 4472 | + } |
|
| 4234 | 4473 | |
| 4235 | 4474 | // There are certain exceptions to the above where we don't want anything on the menu highlighted. |
| 4236 | 4475 | if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner'])) |
| 4237 | 4476 | { |
| 4238 | 4477 | $current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile'; |
| 4239 | 4478 | $context[$current_action] = true; |
| 4240 | - } |
|
| 4241 | - elseif ($context['current_action'] == 'pm') |
|
| 4479 | + } elseif ($context['current_action'] == 'pm') |
|
| 4242 | 4480 | { |
| 4243 | 4481 | $current_action = 'self_pm'; |
| 4244 | 4482 | $context['self_pm'] = true; |
@@ -4281,12 +4519,14 @@ discard block |
||
| 4281 | 4519 | } |
| 4282 | 4520 | |
| 4283 | 4521 | // Not all actions are simple. |
| 4284 | - if (!empty($needs_action_hook)) |
|
| 4285 | - call_integration_hook('integrate_current_action', array(&$current_action)); |
|
| 4522 | + if (!empty($needs_action_hook)) { |
|
| 4523 | + call_integration_hook('integrate_current_action', array(&$current_action)); |
|
| 4524 | + } |
|
| 4286 | 4525 | |
| 4287 | - if (isset($context['menu_buttons'][$current_action])) |
|
| 4288 | - $context['menu_buttons'][$current_action]['active_button'] = true; |
|
| 4289 | -} |
|
| 4526 | + if (isset($context['menu_buttons'][$current_action])) { |
|
| 4527 | + $context['menu_buttons'][$current_action]['active_button'] = true; |
|
| 4528 | + } |
|
| 4529 | + } |
|
| 4290 | 4530 | |
| 4291 | 4531 | /** |
| 4292 | 4532 | * Generate a random seed and ensure it's stored in settings. |
@@ -4310,30 +4550,35 @@ discard block |
||
| 4310 | 4550 | global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug; |
| 4311 | 4551 | global $context, $txt; |
| 4312 | 4552 | |
| 4313 | - if ($db_show_debug === true) |
|
| 4314 | - $context['debug']['hooks'][] = $hook; |
|
| 4553 | + if ($db_show_debug === true) { |
|
| 4554 | + $context['debug']['hooks'][] = $hook; |
|
| 4555 | + } |
|
| 4315 | 4556 | |
| 4316 | 4557 | // Need to have some control. |
| 4317 | - if (!isset($context['instances'])) |
|
| 4318 | - $context['instances'] = array(); |
|
| 4558 | + if (!isset($context['instances'])) { |
|
| 4559 | + $context['instances'] = array(); |
|
| 4560 | + } |
|
| 4319 | 4561 | |
| 4320 | 4562 | $results = array(); |
| 4321 | - if (empty($modSettings[$hook])) |
|
| 4322 | - return $results; |
|
| 4563 | + if (empty($modSettings[$hook])) { |
|
| 4564 | + return $results; |
|
| 4565 | + } |
|
| 4323 | 4566 | |
| 4324 | 4567 | $functions = explode(',', $modSettings[$hook]); |
| 4325 | 4568 | // Loop through each function. |
| 4326 | 4569 | foreach ($functions as $function) |
| 4327 | 4570 | { |
| 4328 | 4571 | // Hook has been marked as "disabled". Skip it! |
| 4329 | - if (strpos($function, '!') !== false) |
|
| 4330 | - continue; |
|
| 4572 | + if (strpos($function, '!') !== false) { |
|
| 4573 | + continue; |
|
| 4574 | + } |
|
| 4331 | 4575 | |
| 4332 | 4576 | $call = call_helper($function, true); |
| 4333 | 4577 | |
| 4334 | 4578 | // Is it valid? |
| 4335 | - if (!empty($call)) |
|
| 4336 | - $results[$function] = call_user_func_array($call, $parameters); |
|
| 4579 | + if (!empty($call)) { |
|
| 4580 | + $results[$function] = call_user_func_array($call, $parameters); |
|
| 4581 | + } |
|
| 4337 | 4582 | |
| 4338 | 4583 | // Whatever it was suppose to call, it failed :( |
| 4339 | 4584 | elseif (!empty($function)) |
@@ -4349,8 +4594,9 @@ discard block |
||
| 4349 | 4594 | } |
| 4350 | 4595 | |
| 4351 | 4596 | // "Assume" the file resides on $boarddir somewhere... |
| 4352 | - else |
|
| 4353 | - log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
| 4597 | + else { |
|
| 4598 | + log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
| 4599 | + } |
|
| 4354 | 4600 | } |
| 4355 | 4601 | } |
| 4356 | 4602 | |
@@ -4372,12 +4618,14 @@ discard block |
||
| 4372 | 4618 | global $smcFunc, $modSettings; |
| 4373 | 4619 | |
| 4374 | 4620 | // Any objects? |
| 4375 | - if ($object) |
|
| 4376 | - $function = $function . '#'; |
|
| 4621 | + if ($object) { |
|
| 4622 | + $function = $function . '#'; |
|
| 4623 | + } |
|
| 4377 | 4624 | |
| 4378 | 4625 | // Any files to load? |
| 4379 | - if (!empty($file) && is_string($file)) |
|
| 4380 | - $function = $file . (!empty($function) ? '|' . $function : ''); |
|
| 4626 | + if (!empty($file) && is_string($file)) { |
|
| 4627 | + $function = $file . (!empty($function) ? '|' . $function : ''); |
|
| 4628 | + } |
|
| 4381 | 4629 | |
| 4382 | 4630 | // Get the correct string. |
| 4383 | 4631 | $integration_call = $function; |
@@ -4399,13 +4647,14 @@ discard block |
||
| 4399 | 4647 | if (!empty($current_functions)) |
| 4400 | 4648 | { |
| 4401 | 4649 | $current_functions = explode(',', $current_functions); |
| 4402 | - if (in_array($integration_call, $current_functions)) |
|
| 4403 | - return; |
|
| 4650 | + if (in_array($integration_call, $current_functions)) { |
|
| 4651 | + return; |
|
| 4652 | + } |
|
| 4404 | 4653 | |
| 4405 | 4654 | $permanent_functions = array_merge($current_functions, array($integration_call)); |
| 4655 | + } else { |
|
| 4656 | + $permanent_functions = array($integration_call); |
|
| 4406 | 4657 | } |
| 4407 | - else |
|
| 4408 | - $permanent_functions = array($integration_call); |
|
| 4409 | 4658 | |
| 4410 | 4659 | updateSettings(array($hook => implode(',', $permanent_functions))); |
| 4411 | 4660 | } |
@@ -4414,8 +4663,9 @@ discard block |
||
| 4414 | 4663 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
| 4415 | 4664 | |
| 4416 | 4665 | // Do nothing, if it's already there. |
| 4417 | - if (in_array($integration_call, $functions)) |
|
| 4418 | - return; |
|
| 4666 | + if (in_array($integration_call, $functions)) { |
|
| 4667 | + return; |
|
| 4668 | + } |
|
| 4419 | 4669 | |
| 4420 | 4670 | $functions[] = $integration_call; |
| 4421 | 4671 | $modSettings[$hook] = implode(',', $functions); |
@@ -4438,12 +4688,14 @@ discard block |
||
| 4438 | 4688 | global $smcFunc, $modSettings; |
| 4439 | 4689 | |
| 4440 | 4690 | // Any objects? |
| 4441 | - if ($object) |
|
| 4442 | - $function = $function . '#'; |
|
| 4691 | + if ($object) { |
|
| 4692 | + $function = $function . '#'; |
|
| 4693 | + } |
|
| 4443 | 4694 | |
| 4444 | 4695 | // Any files to load? |
| 4445 | - if (!empty($file) && is_string($file)) |
|
| 4446 | - $function = $file . '|' . $function; |
|
| 4696 | + if (!empty($file) && is_string($file)) { |
|
| 4697 | + $function = $file . '|' . $function; |
|
| 4698 | + } |
|
| 4447 | 4699 | |
| 4448 | 4700 | // Get the correct string. |
| 4449 | 4701 | $integration_call = $function; |
@@ -4464,16 +4716,18 @@ discard block |
||
| 4464 | 4716 | { |
| 4465 | 4717 | $current_functions = explode(',', $current_functions); |
| 4466 | 4718 | |
| 4467 | - if (in_array($integration_call, $current_functions)) |
|
| 4468 | - updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
| 4719 | + if (in_array($integration_call, $current_functions)) { |
|
| 4720 | + updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
| 4721 | + } |
|
| 4469 | 4722 | } |
| 4470 | 4723 | |
| 4471 | 4724 | // Turn the function list into something usable. |
| 4472 | 4725 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
| 4473 | 4726 | |
| 4474 | 4727 | // You can only remove it if it's available. |
| 4475 | - if (!in_array($integration_call, $functions)) |
|
| 4476 | - return; |
|
| 4728 | + if (!in_array($integration_call, $functions)) { |
|
| 4729 | + return; |
|
| 4730 | + } |
|
| 4477 | 4731 | |
| 4478 | 4732 | $functions = array_diff($functions, array($integration_call)); |
| 4479 | 4733 | $modSettings[$hook] = implode(',', $functions); |
@@ -4494,17 +4748,20 @@ discard block |
||
| 4494 | 4748 | global $context, $smcFunc, $txt, $db_show_debug; |
| 4495 | 4749 | |
| 4496 | 4750 | // Really? |
| 4497 | - if (empty($string)) |
|
| 4498 | - return false; |
|
| 4751 | + if (empty($string)) { |
|
| 4752 | + return false; |
|
| 4753 | + } |
|
| 4499 | 4754 | |
| 4500 | 4755 | // An array? should be a "callable" array IE array(object/class, valid_callable). |
| 4501 | 4756 | // A closure? should be a callable one. |
| 4502 | - if (is_array($string) || $string instanceof Closure) |
|
| 4503 | - return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
| 4757 | + if (is_array($string) || $string instanceof Closure) { |
|
| 4758 | + return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
| 4759 | + } |
|
| 4504 | 4760 | |
| 4505 | 4761 | // No full objects, sorry! pass a method or a property instead! |
| 4506 | - if (is_object($string)) |
|
| 4507 | - return false; |
|
| 4762 | + if (is_object($string)) { |
|
| 4763 | + return false; |
|
| 4764 | + } |
|
| 4508 | 4765 | |
| 4509 | 4766 | // Stay vitaminized my friends... |
| 4510 | 4767 | $string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string)); |
@@ -4513,8 +4770,9 @@ discard block |
||
| 4513 | 4770 | $string = load_file($string); |
| 4514 | 4771 | |
| 4515 | 4772 | // Loaded file failed |
| 4516 | - if (empty($string)) |
|
| 4517 | - return false; |
|
| 4773 | + if (empty($string)) { |
|
| 4774 | + return false; |
|
| 4775 | + } |
|
| 4518 | 4776 | |
| 4519 | 4777 | // Found a method. |
| 4520 | 4778 | if (strpos($string, '::') !== false) |
@@ -4535,8 +4793,9 @@ discard block |
||
| 4535 | 4793 | // Add another one to the list. |
| 4536 | 4794 | if ($db_show_debug === true) |
| 4537 | 4795 | { |
| 4538 | - if (!isset($context['debug']['instances'])) |
|
| 4539 | - $context['debug']['instances'] = array(); |
|
| 4796 | + if (!isset($context['debug']['instances'])) { |
|
| 4797 | + $context['debug']['instances'] = array(); |
|
| 4798 | + } |
|
| 4540 | 4799 | |
| 4541 | 4800 | $context['debug']['instances'][$class] = $class; |
| 4542 | 4801 | } |
@@ -4546,13 +4805,15 @@ discard block |
||
| 4546 | 4805 | } |
| 4547 | 4806 | |
| 4548 | 4807 | // Right then. This is a call to a static method. |
| 4549 | - else |
|
| 4550 | - $func = array($class, $method); |
|
| 4808 | + else { |
|
| 4809 | + $func = array($class, $method); |
|
| 4810 | + } |
|
| 4551 | 4811 | } |
| 4552 | 4812 | |
| 4553 | 4813 | // Nope! just a plain regular function. |
| 4554 | - else |
|
| 4555 | - $func = $string; |
|
| 4814 | + else { |
|
| 4815 | + $func = $string; |
|
| 4816 | + } |
|
| 4556 | 4817 | |
| 4557 | 4818 | // Right, we got what we need, time to do some checks. |
| 4558 | 4819 | if (!is_callable($func, false, $callable_name)) |
@@ -4568,17 +4829,18 @@ discard block |
||
| 4568 | 4829 | else |
| 4569 | 4830 | { |
| 4570 | 4831 | // What are we gonna do about it? |
| 4571 | - if ($return) |
|
| 4572 | - return $func; |
|
| 4832 | + if ($return) { |
|
| 4833 | + return $func; |
|
| 4834 | + } |
|
| 4573 | 4835 | |
| 4574 | 4836 | // If this is a plain function, avoid the heat of calling call_user_func(). |
| 4575 | 4837 | else |
| 4576 | 4838 | { |
| 4577 | - if (is_array($func)) |
|
| 4578 | - call_user_func($func); |
|
| 4579 | - |
|
| 4580 | - else |
|
| 4581 | - $func(); |
|
| 4839 | + if (is_array($func)) { |
|
| 4840 | + call_user_func($func); |
|
| 4841 | + } else { |
|
| 4842 | + $func(); |
|
| 4843 | + } |
|
| 4582 | 4844 | } |
| 4583 | 4845 | } |
| 4584 | 4846 | } |
@@ -4595,31 +4857,34 @@ discard block |
||
| 4595 | 4857 | { |
| 4596 | 4858 | global $sourcedir, $txt, $boarddir, $settings; |
| 4597 | 4859 | |
| 4598 | - if (empty($string)) |
|
| 4599 | - return false; |
|
| 4860 | + if (empty($string)) { |
|
| 4861 | + return false; |
|
| 4862 | + } |
|
| 4600 | 4863 | |
| 4601 | 4864 | if (strpos($string, '|') !== false) |
| 4602 | 4865 | { |
| 4603 | 4866 | list ($file, $string) = explode('|', $string); |
| 4604 | 4867 | |
| 4605 | 4868 | // Match the wildcards to their regular vars. |
| 4606 | - if (empty($settings['theme_dir'])) |
|
| 4607 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 4608 | - |
|
| 4609 | - else |
|
| 4610 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 4869 | + if (empty($settings['theme_dir'])) { |
|
| 4870 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 4871 | + } else { |
|
| 4872 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 4873 | + } |
|
| 4611 | 4874 | |
| 4612 | 4875 | // Load the file if it can be loaded. |
| 4613 | - if (file_exists($absPath)) |
|
| 4614 | - require_once($absPath); |
|
| 4876 | + if (file_exists($absPath)) { |
|
| 4877 | + require_once($absPath); |
|
| 4878 | + } |
|
| 4615 | 4879 | |
| 4616 | 4880 | // No? try a fallback to $sourcedir |
| 4617 | 4881 | else |
| 4618 | 4882 | { |
| 4619 | 4883 | $absPath = $sourcedir .'/'. $file; |
| 4620 | 4884 | |
| 4621 | - if (file_exists($absPath)) |
|
| 4622 | - require_once($absPath); |
|
| 4885 | + if (file_exists($absPath)) { |
|
| 4886 | + require_once($absPath); |
|
| 4887 | + } |
|
| 4623 | 4888 | |
| 4624 | 4889 | // Sorry, can't do much for you at this point. |
| 4625 | 4890 | else |
@@ -4646,8 +4911,9 @@ discard block |
||
| 4646 | 4911 | global $user_info, $smcFunc; |
| 4647 | 4912 | |
| 4648 | 4913 | // Make sure we have something to work with. |
| 4649 | - if (empty($topic)) |
|
| 4650 | - return array(); |
|
| 4914 | + if (empty($topic)) { |
|
| 4915 | + return array(); |
|
| 4916 | + } |
|
| 4651 | 4917 | |
| 4652 | 4918 | |
| 4653 | 4919 | // We already know the number of likes per message, we just want to know whether the current user liked it or not. |
@@ -4670,8 +4936,9 @@ discard block |
||
| 4670 | 4936 | 'topic' => $topic, |
| 4671 | 4937 | ) |
| 4672 | 4938 | ); |
| 4673 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4674 | - $temp[] = (int) $row['content_id']; |
|
| 4939 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 4940 | + $temp[] = (int) $row['content_id']; |
|
| 4941 | + } |
|
| 4675 | 4942 | |
| 4676 | 4943 | cache_put_data($cache_key, $temp, $ttl); |
| 4677 | 4944 | } |
@@ -4692,8 +4959,9 @@ discard block |
||
| 4692 | 4959 | { |
| 4693 | 4960 | global $context; |
| 4694 | 4961 | |
| 4695 | - if (empty($string)) |
|
| 4696 | - return $string; |
|
| 4962 | + if (empty($string)) { |
|
| 4963 | + return $string; |
|
| 4964 | + } |
|
| 4697 | 4965 | |
| 4698 | 4966 | // UTF-8 occurences of MS special characters |
| 4699 | 4967 | $findchars_utf8 = array( |
@@ -4734,10 +5002,11 @@ discard block |
||
| 4734 | 5002 | '--', // — |
| 4735 | 5003 | ); |
| 4736 | 5004 | |
| 4737 | - if ($context['utf8']) |
|
| 4738 | - $string = str_replace($findchars_utf8, $replacechars, $string); |
|
| 4739 | - else |
|
| 4740 | - $string = str_replace($findchars_iso, $replacechars, $string); |
|
| 5005 | + if ($context['utf8']) { |
|
| 5006 | + $string = str_replace($findchars_utf8, $replacechars, $string); |
|
| 5007 | + } else { |
|
| 5008 | + $string = str_replace($findchars_iso, $replacechars, $string); |
|
| 5009 | + } |
|
| 4741 | 5010 | |
| 4742 | 5011 | return $string; |
| 4743 | 5012 | } |
@@ -4756,49 +5025,59 @@ discard block |
||
| 4756 | 5025 | { |
| 4757 | 5026 | global $context; |
| 4758 | 5027 | |
| 4759 | - if (!isset($matches[2])) |
|
| 4760 | - return ''; |
|
| 5028 | + if (!isset($matches[2])) { |
|
| 5029 | + return ''; |
|
| 5030 | + } |
|
| 4761 | 5031 | |
| 4762 | 5032 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
| 4763 | 5033 | |
| 4764 | 5034 | // remove left to right / right to left overrides |
| 4765 | - if ($num === 0x202D || $num === 0x202E) |
|
| 4766 | - return ''; |
|
| 5035 | + if ($num === 0x202D || $num === 0x202E) { |
|
| 5036 | + return ''; |
|
| 5037 | + } |
|
| 4767 | 5038 | |
| 4768 | 5039 | // Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced |
| 4769 | - if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) |
|
| 4770 | - return '&#' . $num . ';'; |
|
| 5040 | + if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) { |
|
| 5041 | + return '&#' . $num . ';'; |
|
| 5042 | + } |
|
| 4771 | 5043 | |
| 4772 | 5044 | if (empty($context['utf8'])) |
| 4773 | 5045 | { |
| 4774 | 5046 | // no control characters |
| 4775 | - if ($num < 0x20) |
|
| 4776 | - return ''; |
|
| 5047 | + if ($num < 0x20) { |
|
| 5048 | + return ''; |
|
| 5049 | + } |
|
| 4777 | 5050 | // text is text |
| 4778 | - elseif ($num < 0x80) |
|
| 4779 | - return chr($num); |
|
| 5051 | + elseif ($num < 0x80) { |
|
| 5052 | + return chr($num); |
|
| 5053 | + } |
|
| 4780 | 5054 | // all others get html-ised |
| 4781 | - else |
|
| 4782 | - return '&#' . $matches[2] . ';'; |
|
| 4783 | - } |
|
| 4784 | - else |
|
| 5055 | + else { |
|
| 5056 | + return '&#' . $matches[2] . ';'; |
|
| 5057 | + } |
|
| 5058 | + } else |
|
| 4785 | 5059 | { |
| 4786 | 5060 | // <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set |
| 4787 | 5061 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text) |
| 4788 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) |
|
| 4789 | - return ''; |
|
| 5062 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) { |
|
| 5063 | + return ''; |
|
| 5064 | + } |
|
| 4790 | 5065 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
| 4791 | - elseif ($num < 0x80) |
|
| 4792 | - return chr($num); |
|
| 5066 | + elseif ($num < 0x80) { |
|
| 5067 | + return chr($num); |
|
| 5068 | + } |
|
| 4793 | 5069 | // <0x800 (2048) |
| 4794 | - elseif ($num < 0x800) |
|
| 4795 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5070 | + elseif ($num < 0x800) { |
|
| 5071 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5072 | + } |
|
| 4796 | 5073 | // < 0x10000 (65536) |
| 4797 | - elseif ($num < 0x10000) |
|
| 4798 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5074 | + elseif ($num < 0x10000) { |
|
| 5075 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5076 | + } |
|
| 4799 | 5077 | // <= 0x10FFFF (1114111) |
| 4800 | - else |
|
| 4801 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5078 | + else { |
|
| 5079 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5080 | + } |
|
| 4802 | 5081 | } |
| 4803 | 5082 | } |
| 4804 | 5083 | |
@@ -4814,28 +5093,34 @@ discard block |
||
| 4814 | 5093 | */ |
| 4815 | 5094 | function fixchar__callback($matches) |
| 4816 | 5095 | { |
| 4817 | - if (!isset($matches[1])) |
|
| 4818 | - return ''; |
|
| 5096 | + if (!isset($matches[1])) { |
|
| 5097 | + return ''; |
|
| 5098 | + } |
|
| 4819 | 5099 | |
| 4820 | 5100 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
| 4821 | 5101 | |
| 4822 | 5102 | // <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set |
| 4823 | 5103 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides |
| 4824 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) |
|
| 4825 | - return ''; |
|
| 5104 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) { |
|
| 5105 | + return ''; |
|
| 5106 | + } |
|
| 4826 | 5107 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
| 4827 | - elseif ($num < 0x80) |
|
| 4828 | - return chr($num); |
|
| 5108 | + elseif ($num < 0x80) { |
|
| 5109 | + return chr($num); |
|
| 5110 | + } |
|
| 4829 | 5111 | // <0x800 (2048) |
| 4830 | - elseif ($num < 0x800) |
|
| 4831 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5112 | + elseif ($num < 0x800) { |
|
| 5113 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5114 | + } |
|
| 4832 | 5115 | // < 0x10000 (65536) |
| 4833 | - elseif ($num < 0x10000) |
|
| 4834 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5116 | + elseif ($num < 0x10000) { |
|
| 5117 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5118 | + } |
|
| 4835 | 5119 | // <= 0x10FFFF (1114111) |
| 4836 | - else |
|
| 4837 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 4838 | -} |
|
| 5120 | + else { |
|
| 5121 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5122 | + } |
|
| 5123 | + } |
|
| 4839 | 5124 | |
| 4840 | 5125 | /** |
| 4841 | 5126 | * Strips out invalid html entities, replaces others with html style { codes |
@@ -4848,17 +5133,19 @@ discard block |
||
| 4848 | 5133 | */ |
| 4849 | 5134 | function entity_fix__callback($matches) |
| 4850 | 5135 | { |
| 4851 | - if (!isset($matches[2])) |
|
| 4852 | - return ''; |
|
| 5136 | + if (!isset($matches[2])) { |
|
| 5137 | + return ''; |
|
| 5138 | + } |
|
| 4853 | 5139 | |
| 4854 | 5140 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
| 4855 | 5141 | |
| 4856 | 5142 | // we don't allow control characters, characters out of range, byte markers, etc |
| 4857 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) |
|
| 4858 | - return ''; |
|
| 4859 | - else |
|
| 4860 | - return '&#' . $num . ';'; |
|
| 4861 | -} |
|
| 5143 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) { |
|
| 5144 | + return ''; |
|
| 5145 | + } else { |
|
| 5146 | + return '&#' . $num . ';'; |
|
| 5147 | + } |
|
| 5148 | + } |
|
| 4862 | 5149 | |
| 4863 | 5150 | /** |
| 4864 | 5151 | * Return a Gravatar URL based on |
@@ -4882,18 +5169,23 @@ discard block |
||
| 4882 | 5169 | $ratings = array('G', 'PG', 'R', 'X'); |
| 4883 | 5170 | $defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'); |
| 4884 | 5171 | $url_params = array(); |
| 4885 | - if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) |
|
| 4886 | - $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
| 4887 | - if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) |
|
| 4888 | - $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
| 4889 | - if (!empty($modSettings['avatar_max_width_external'])) |
|
| 4890 | - $size_string = (int) $modSettings['avatar_max_width_external']; |
|
| 4891 | - if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) |
|
| 4892 | - if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
| 5172 | + if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) { |
|
| 5173 | + $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
| 5174 | + } |
|
| 5175 | + if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) { |
|
| 5176 | + $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
| 5177 | + } |
|
| 5178 | + if (!empty($modSettings['avatar_max_width_external'])) { |
|
| 5179 | + $size_string = (int) $modSettings['avatar_max_width_external']; |
|
| 5180 | + } |
|
| 5181 | + if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) { |
|
| 5182 | + if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
| 4893 | 5183 | $size_string = $modSettings['avatar_max_height_external']; |
| 5184 | + } |
|
| 4894 | 5185 | |
| 4895 | - if (!empty($size_string)) |
|
| 4896 | - $url_params[] = 's=' . $size_string; |
|
| 5186 | + if (!empty($size_string)) { |
|
| 5187 | + $url_params[] = 's=' . $size_string; |
|
| 5188 | + } |
|
| 4897 | 5189 | } |
| 4898 | 5190 | $http_method = !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 ? 'https://secure' : 'http://www'; |
| 4899 | 5191 | |
@@ -4912,22 +5204,26 @@ discard block |
||
| 4912 | 5204 | static $timezones = null, $lastwhen = null; |
| 4913 | 5205 | |
| 4914 | 5206 | // No point doing this over if we already did it once |
| 4915 | - if (!empty($timezones) && $when == $lastwhen) |
|
| 4916 | - return $timezones; |
|
| 4917 | - else |
|
| 4918 | - $lastwhen = $when; |
|
| 5207 | + if (!empty($timezones) && $when == $lastwhen) { |
|
| 5208 | + return $timezones; |
|
| 5209 | + } else { |
|
| 5210 | + $lastwhen = $when; |
|
| 5211 | + } |
|
| 4919 | 5212 | |
| 4920 | 5213 | // Parseable datetime string? |
| 4921 | - if (is_int($timestamp = strtotime($when))) |
|
| 4922 | - $when = $timestamp; |
|
| 5214 | + if (is_int($timestamp = strtotime($when))) { |
|
| 5215 | + $when = $timestamp; |
|
| 5216 | + } |
|
| 4923 | 5217 | |
| 4924 | 5218 | // A Unix timestamp? |
| 4925 | - elseif (is_numeric($when)) |
|
| 4926 | - $when = intval($when); |
|
| 5219 | + elseif (is_numeric($when)) { |
|
| 5220 | + $when = intval($when); |
|
| 5221 | + } |
|
| 4927 | 5222 | |
| 4928 | 5223 | // Invalid value? Just get current Unix timestamp. |
| 4929 | - else |
|
| 4930 | - $when = time(); |
|
| 5224 | + else { |
|
| 5225 | + $when = time(); |
|
| 5226 | + } |
|
| 4931 | 5227 | |
| 4932 | 5228 | // We'll need these too |
| 4933 | 5229 | $date_when = date_create('@' . $when); |
@@ -4991,8 +5287,9 @@ discard block |
||
| 4991 | 5287 | foreach ($priority_countries as $country) |
| 4992 | 5288 | { |
| 4993 | 5289 | $country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country))); |
| 4994 | - if (!empty($country_tzids)) |
|
| 4995 | - $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
| 5290 | + if (!empty($country_tzids)) { |
|
| 5291 | + $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
| 5292 | + } |
|
| 4996 | 5293 | } |
| 4997 | 5294 | |
| 4998 | 5295 | // Process the preferred timezones first, then the rest. |
@@ -5002,8 +5299,9 @@ discard block |
||
| 5002 | 5299 | foreach ($tzids as $tzid) |
| 5003 | 5300 | { |
| 5004 | 5301 | // We don't want UTC right now |
| 5005 | - if ($tzid == 'UTC') |
|
| 5006 | - continue; |
|
| 5302 | + if ($tzid == 'UTC') { |
|
| 5303 | + continue; |
|
| 5304 | + } |
|
| 5007 | 5305 | |
| 5008 | 5306 | $tz = timezone_open($tzid); |
| 5009 | 5307 | |
@@ -5018,12 +5316,14 @@ discard block |
||
| 5018 | 5316 | $tzgeo = timezone_location_get($tz); |
| 5019 | 5317 | |
| 5020 | 5318 | // Don't overwrite our preferred tzids |
| 5021 | - if (empty($zones[$tzkey]['tzid'])) |
|
| 5022 | - $zones[$tzkey]['tzid'] = $tzid; |
|
| 5319 | + if (empty($zones[$tzkey]['tzid'])) { |
|
| 5320 | + $zones[$tzkey]['tzid'] = $tzid; |
|
| 5321 | + } |
|
| 5023 | 5322 | |
| 5024 | 5323 | // A time zone from a prioritized country? |
| 5025 | - if (in_array($tzid, $priority_tzids)) |
|
| 5026 | - $priority_zones[$tzkey] = true; |
|
| 5324 | + if (in_array($tzid, $priority_tzids)) { |
|
| 5325 | + $priority_zones[$tzkey] = true; |
|
| 5326 | + } |
|
| 5027 | 5327 | |
| 5028 | 5328 | // Keep track of the location and offset for this tzid |
| 5029 | 5329 | $tzid_parts = explode('/', $tzid); |
@@ -5044,15 +5344,17 @@ discard block |
||
| 5044 | 5344 | |
| 5045 | 5345 | date_timezone_set($date_when, timezone_open($tzvalue['tzid'])); |
| 5046 | 5346 | |
| 5047 | - if (!empty($timezone_descriptions[$tzvalue['tzid']])) |
|
| 5048 | - $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
| 5049 | - else |
|
| 5050 | - $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
| 5347 | + if (!empty($timezone_descriptions[$tzvalue['tzid']])) { |
|
| 5348 | + $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
| 5349 | + } else { |
|
| 5350 | + $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
| 5351 | + } |
|
| 5051 | 5352 | |
| 5052 | - if (isset($priority_zones[$tzkey])) |
|
| 5053 | - $priority_timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
| 5054 | - else |
|
| 5055 | - $timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
| 5353 | + if (isset($priority_zones[$tzkey])) { |
|
| 5354 | + $priority_timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
| 5355 | + } else { |
|
| 5356 | + $timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
| 5357 | + } |
|
| 5056 | 5358 | } |
| 5057 | 5359 | |
| 5058 | 5360 | $timezones = array_merge( |
@@ -5106,9 +5408,9 @@ discard block |
||
| 5106 | 5408 | 'Indian/Kerguelen' => 'TFT', |
| 5107 | 5409 | ); |
| 5108 | 5410 | |
| 5109 | - if (!empty($missing_tz_abbrs[$tzid])) |
|
| 5110 | - $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
| 5111 | - else |
|
| 5411 | + if (!empty($missing_tz_abbrs[$tzid])) { |
|
| 5412 | + $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
| 5413 | + } else |
|
| 5112 | 5414 | { |
| 5113 | 5415 | // Russia likes to experiment with time zones often, and names them as offsets from Moscow |
| 5114 | 5416 | $tz_location = timezone_location_get(timezone_open($tzid)); |
@@ -5136,8 +5438,9 @@ discard block |
||
| 5136 | 5438 | */ |
| 5137 | 5439 | function inet_ptod($ip_address) |
| 5138 | 5440 | { |
| 5139 | - if (!isValidIP($ip_address)) |
|
| 5140 | - return $ip_address; |
|
| 5441 | + if (!isValidIP($ip_address)) { |
|
| 5442 | + return $ip_address; |
|
| 5443 | + } |
|
| 5141 | 5444 | |
| 5142 | 5445 | $bin = inet_pton($ip_address); |
| 5143 | 5446 | return $bin; |
@@ -5149,13 +5452,15 @@ discard block |
||
| 5149 | 5452 | */ |
| 5150 | 5453 | function inet_dtop($bin) |
| 5151 | 5454 | { |
| 5152 | - if(empty($bin)) |
|
| 5153 | - return ''; |
|
| 5455 | + if(empty($bin)) { |
|
| 5456 | + return ''; |
|
| 5457 | + } |
|
| 5154 | 5458 | |
| 5155 | 5459 | global $db_type; |
| 5156 | 5460 | |
| 5157 | - if ($db_type == 'postgresql') |
|
| 5158 | - return $bin; |
|
| 5461 | + if ($db_type == 'postgresql') { |
|
| 5462 | + return $bin; |
|
| 5463 | + } |
|
| 5159 | 5464 | |
| 5160 | 5465 | $ip_address = inet_ntop($bin); |
| 5161 | 5466 | |
@@ -5180,26 +5485,32 @@ discard block |
||
| 5180 | 5485 | */ |
| 5181 | 5486 | function _safe_serialize($value) |
| 5182 | 5487 | { |
| 5183 | - if(is_null($value)) |
|
| 5184 | - return 'N;'; |
|
| 5488 | + if(is_null($value)) { |
|
| 5489 | + return 'N;'; |
|
| 5490 | + } |
|
| 5185 | 5491 | |
| 5186 | - if(is_bool($value)) |
|
| 5187 | - return 'b:'. (int) $value .';'; |
|
| 5492 | + if(is_bool($value)) { |
|
| 5493 | + return 'b:'. (int) $value .';'; |
|
| 5494 | + } |
|
| 5188 | 5495 | |
| 5189 | - if(is_int($value)) |
|
| 5190 | - return 'i:'. $value .';'; |
|
| 5496 | + if(is_int($value)) { |
|
| 5497 | + return 'i:'. $value .';'; |
|
| 5498 | + } |
|
| 5191 | 5499 | |
| 5192 | - if(is_float($value)) |
|
| 5193 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 5500 | + if(is_float($value)) { |
|
| 5501 | + return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 5502 | + } |
|
| 5194 | 5503 | |
| 5195 | - if(is_string($value)) |
|
| 5196 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 5504 | + if(is_string($value)) { |
|
| 5505 | + return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 5506 | + } |
|
| 5197 | 5507 | |
| 5198 | 5508 | if(is_array($value)) |
| 5199 | 5509 | { |
| 5200 | 5510 | $out = ''; |
| 5201 | - foreach($value as $k => $v) |
|
| 5202 | - $out .= _safe_serialize($k) . _safe_serialize($v); |
|
| 5511 | + foreach($value as $k => $v) { |
|
| 5512 | + $out .= _safe_serialize($k) . _safe_serialize($v); |
|
| 5513 | + } |
|
| 5203 | 5514 | |
| 5204 | 5515 | return 'a:'. count($value) .':{'. $out .'}'; |
| 5205 | 5516 | } |
@@ -5225,8 +5536,9 @@ discard block |
||
| 5225 | 5536 | |
| 5226 | 5537 | $out = _safe_serialize($value); |
| 5227 | 5538 | |
| 5228 | - if (isset($mbIntEnc)) |
|
| 5229 | - mb_internal_encoding($mbIntEnc); |
|
| 5539 | + if (isset($mbIntEnc)) { |
|
| 5540 | + mb_internal_encoding($mbIntEnc); |
|
| 5541 | + } |
|
| 5230 | 5542 | |
| 5231 | 5543 | return $out; |
| 5232 | 5544 | } |
@@ -5243,8 +5555,9 @@ discard block |
||
| 5243 | 5555 | function _safe_unserialize($str) |
| 5244 | 5556 | { |
| 5245 | 5557 | // Input is not a string. |
| 5246 | - if(empty($str) || !is_string($str)) |
|
| 5247 | - return false; |
|
| 5558 | + if(empty($str) || !is_string($str)) { |
|
| 5559 | + return false; |
|
| 5560 | + } |
|
| 5248 | 5561 | |
| 5249 | 5562 | $stack = array(); |
| 5250 | 5563 | $expected = array(); |
@@ -5260,43 +5573,38 @@ discard block |
||
| 5260 | 5573 | while($state != 1) |
| 5261 | 5574 | { |
| 5262 | 5575 | $type = isset($str[0]) ? $str[0] : ''; |
| 5263 | - if($type == '}') |
|
| 5264 | - $str = substr($str, 1); |
|
| 5265 | - |
|
| 5266 | - else if($type == 'N' && $str[1] == ';') |
|
| 5576 | + if($type == '}') { |
|
| 5577 | + $str = substr($str, 1); |
|
| 5578 | + } else if($type == 'N' && $str[1] == ';') |
|
| 5267 | 5579 | { |
| 5268 | 5580 | $value = null; |
| 5269 | 5581 | $str = substr($str, 2); |
| 5270 | - } |
|
| 5271 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5582 | + } else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5272 | 5583 | { |
| 5273 | 5584 | $value = $matches[1] == '1' ? true : false; |
| 5274 | 5585 | $str = substr($str, 4); |
| 5275 | - } |
|
| 5276 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5586 | + } else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5277 | 5587 | { |
| 5278 | 5588 | $value = (int)$matches[1]; |
| 5279 | 5589 | $str = $matches[2]; |
| 5280 | - } |
|
| 5281 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5590 | + } else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5282 | 5591 | { |
| 5283 | 5592 | $value = (float)$matches[1]; |
| 5284 | 5593 | $str = $matches[3]; |
| 5285 | - } |
|
| 5286 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5594 | + } else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5287 | 5595 | { |
| 5288 | 5596 | $value = substr($matches[2], 0, (int)$matches[1]); |
| 5289 | 5597 | $str = substr($matches[2], (int)$matches[1] + 2); |
| 5290 | - } |
|
| 5291 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5598 | + } else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5292 | 5599 | { |
| 5293 | 5600 | $expectedLength = (int)$matches[1]; |
| 5294 | 5601 | $str = $matches[2]; |
| 5295 | 5602 | } |
| 5296 | 5603 | |
| 5297 | 5604 | // Object or unknown/malformed type. |
| 5298 | - else |
|
| 5299 | - return false; |
|
| 5605 | + else { |
|
| 5606 | + return false; |
|
| 5607 | + } |
|
| 5300 | 5608 | |
| 5301 | 5609 | switch($state) |
| 5302 | 5610 | { |
@@ -5324,8 +5632,9 @@ discard block |
||
| 5324 | 5632 | if($type == '}') |
| 5325 | 5633 | { |
| 5326 | 5634 | // Array size is less than expected. |
| 5327 | - if(count($list) < end($expected)) |
|
| 5328 | - return false; |
|
| 5635 | + if(count($list) < end($expected)) { |
|
| 5636 | + return false; |
|
| 5637 | + } |
|
| 5329 | 5638 | |
| 5330 | 5639 | unset($list); |
| 5331 | 5640 | $list = &$stack[count($stack)-1]; |
@@ -5334,8 +5643,9 @@ discard block |
||
| 5334 | 5643 | // Go to terminal state if we're at the end of the root array. |
| 5335 | 5644 | array_pop($expected); |
| 5336 | 5645 | |
| 5337 | - if(count($expected) == 0) |
|
| 5338 | - $state = 1; |
|
| 5646 | + if(count($expected) == 0) { |
|
| 5647 | + $state = 1; |
|
| 5648 | + } |
|
| 5339 | 5649 | |
| 5340 | 5650 | break; |
| 5341 | 5651 | } |
@@ -5343,8 +5653,9 @@ discard block |
||
| 5343 | 5653 | if($type == 'i' || $type == 's') |
| 5344 | 5654 | { |
| 5345 | 5655 | // Array size exceeds expected length. |
| 5346 | - if(count($list) >= end($expected)) |
|
| 5347 | - return false; |
|
| 5656 | + if(count($list) >= end($expected)) { |
|
| 5657 | + return false; |
|
| 5658 | + } |
|
| 5348 | 5659 | |
| 5349 | 5660 | $key = $value; |
| 5350 | 5661 | $state = 3; |
@@ -5378,8 +5689,9 @@ discard block |
||
| 5378 | 5689 | } |
| 5379 | 5690 | |
| 5380 | 5691 | // Trailing data in input. |
| 5381 | - if(!empty($str)) |
|
| 5382 | - return false; |
|
| 5692 | + if(!empty($str)) { |
|
| 5693 | + return false; |
|
| 5694 | + } |
|
| 5383 | 5695 | |
| 5384 | 5696 | return $data; |
| 5385 | 5697 | } |
@@ -5402,8 +5714,9 @@ discard block |
||
| 5402 | 5714 | |
| 5403 | 5715 | $out = _safe_unserialize($str); |
| 5404 | 5716 | |
| 5405 | - if (isset($mbIntEnc)) |
|
| 5406 | - mb_internal_encoding($mbIntEnc); |
|
| 5717 | + if (isset($mbIntEnc)) { |
|
| 5718 | + mb_internal_encoding($mbIntEnc); |
|
| 5719 | + } |
|
| 5407 | 5720 | |
| 5408 | 5721 | return $out; |
| 5409 | 5722 | } |
@@ -5418,12 +5731,14 @@ discard block |
||
| 5418 | 5731 | function smf_chmod($file, $value = 0) |
| 5419 | 5732 | { |
| 5420 | 5733 | // No file? no checks! |
| 5421 | - if (empty($file)) |
|
| 5422 | - return false; |
|
| 5734 | + if (empty($file)) { |
|
| 5735 | + return false; |
|
| 5736 | + } |
|
| 5423 | 5737 | |
| 5424 | 5738 | // Already writable? |
| 5425 | - if (is_writable($file)) |
|
| 5426 | - return true; |
|
| 5739 | + if (is_writable($file)) { |
|
| 5740 | + return true; |
|
| 5741 | + } |
|
| 5427 | 5742 | |
| 5428 | 5743 | // Do we have a file or a dir? |
| 5429 | 5744 | $isDir = is_dir($file); |
@@ -5439,10 +5754,9 @@ discard block |
||
| 5439 | 5754 | { |
| 5440 | 5755 | $isWritable = true; |
| 5441 | 5756 | break; |
| 5757 | + } else { |
|
| 5758 | + @chmod($file, $val); |
|
| 5442 | 5759 | } |
| 5443 | - |
|
| 5444 | - else |
|
| 5445 | - @chmod($file, $val); |
|
| 5446 | 5760 | } |
| 5447 | 5761 | |
| 5448 | 5762 | return $isWritable; |
@@ -5461,8 +5775,9 @@ discard block |
||
| 5461 | 5775 | global $txt; |
| 5462 | 5776 | |
| 5463 | 5777 | // Come on... |
| 5464 | - if (empty($json) || !is_string($json)) |
|
| 5465 | - return array(); |
|
| 5778 | + if (empty($json) || !is_string($json)) { |
|
| 5779 | + return array(); |
|
| 5780 | + } |
|
| 5466 | 5781 | |
| 5467 | 5782 | $returnArray = @json_decode($json, $returnAsArray); |
| 5468 | 5783 | |
@@ -5500,11 +5815,11 @@ discard block |
||
| 5500 | 5815 | $jsonDebug = $jsonDebug[0]; |
| 5501 | 5816 | loadLanguage('Errors'); |
| 5502 | 5817 | |
| 5503 | - if (!empty($jsonDebug)) |
|
| 5504 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5505 | - |
|
| 5506 | - else |
|
| 5507 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
| 5818 | + if (!empty($jsonDebug)) { |
|
| 5819 | + log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5820 | + } else { |
|
| 5821 | + log_error($txt['json_'. $jsonError], 'critical'); |
|
| 5822 | + } |
|
| 5508 | 5823 | |
| 5509 | 5824 | // Everyone expects an array. |
| 5510 | 5825 | return array(); |
@@ -5534,8 +5849,9 @@ discard block |
||
| 5534 | 5849 | global $db_show_debug, $modSettings; |
| 5535 | 5850 | |
| 5536 | 5851 | // Defensive programming anyone? |
| 5537 | - if (empty($data)) |
|
| 5538 | - return false; |
|
| 5852 | + if (empty($data)) { |
|
| 5853 | + return false; |
|
| 5854 | + } |
|
| 5539 | 5855 | |
| 5540 | 5856 | // Don't need extra stuff... |
| 5541 | 5857 | $db_show_debug = false; |
@@ -5543,11 +5859,11 @@ discard block |
||
| 5543 | 5859 | // Kill anything else. |
| 5544 | 5860 | ob_end_clean(); |
| 5545 | 5861 | |
| 5546 | - if (!empty($modSettings['CompressedOutput'])) |
|
| 5547 | - @ob_start('ob_gzhandler'); |
|
| 5548 | - |
|
| 5549 | - else |
|
| 5550 | - ob_start(); |
|
| 5862 | + if (!empty($modSettings['CompressedOutput'])) { |
|
| 5863 | + @ob_start('ob_gzhandler'); |
|
| 5864 | + } else { |
|
| 5865 | + ob_start(); |
|
| 5866 | + } |
|
| 5551 | 5867 | |
| 5552 | 5868 | // Set the header. |
| 5553 | 5869 | header($type); |
@@ -5579,8 +5895,9 @@ discard block |
||
| 5579 | 5895 | static $done = false; |
| 5580 | 5896 | |
| 5581 | 5897 | // If we don't need to do anything, don't |
| 5582 | - if (!$update && $done) |
|
| 5583 | - return; |
|
| 5898 | + if (!$update && $done) { |
|
| 5899 | + return; |
|
| 5900 | + } |
|
| 5584 | 5901 | |
| 5585 | 5902 | // Should we get a new copy of the official list of TLDs? |
| 5586 | 5903 | if ($update) |
@@ -5601,10 +5918,11 @@ discard block |
||
| 5601 | 5918 | // Clean $tlds and convert it to an array |
| 5602 | 5919 | $tlds = array_filter(explode("\n", strtolower($tlds)), function($line) { |
| 5603 | 5920 | $line = trim($line); |
| 5604 | - if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) |
|
| 5605 | - return false; |
|
| 5606 | - else |
|
| 5607 | - return true; |
|
| 5921 | + if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) { |
|
| 5922 | + return false; |
|
| 5923 | + } else { |
|
| 5924 | + return true; |
|
| 5925 | + } |
|
| 5608 | 5926 | }); |
| 5609 | 5927 | |
| 5610 | 5928 | // Convert Punycode to Unicode |
@@ -5658,8 +5976,9 @@ discard block |
||
| 5658 | 5976 | $idx += $digit * $w; |
| 5659 | 5977 | $t = ($k <= $bias) ? $tmin : (($k >= $bias + $tmax) ? $tmax : ($k - $bias)); |
| 5660 | 5978 | |
| 5661 | - if ($digit < $t) |
|
| 5662 | - break; |
|
| 5979 | + if ($digit < $t) { |
|
| 5980 | + break; |
|
| 5981 | + } |
|
| 5663 | 5982 | |
| 5664 | 5983 | $w = (int) ($w * ($base - $t)); |
| 5665 | 5984 | } |
@@ -5668,8 +5987,9 @@ discard block |
||
| 5668 | 5987 | $delta = intval($is_first ? ($delta / $damp) : ($delta / 2)); |
| 5669 | 5988 | $delta += intval($delta / ($deco_len + 1)); |
| 5670 | 5989 | |
| 5671 | - for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) |
|
| 5672 | - $delta = intval($delta / ($base - $tmin)); |
|
| 5990 | + for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) { |
|
| 5991 | + $delta = intval($delta / ($base - $tmin)); |
|
| 5992 | + } |
|
| 5673 | 5993 | |
| 5674 | 5994 | $bias = intval($k + ($base - $tmin + 1) * $delta / ($delta + $skew)); |
| 5675 | 5995 | $is_first = false; |
@@ -5678,8 +5998,9 @@ discard block |
||
| 5678 | 5998 | |
| 5679 | 5999 | if ($deco_len > 0) |
| 5680 | 6000 | { |
| 5681 | - for ($i = $deco_len; $i > $idx; $i--) |
|
| 5682 | - $decoded[$i] = $decoded[($i - 1)]; |
|
| 6001 | + for ($i = $deco_len; $i > $idx; $i--) { |
|
| 6002 | + $decoded[$i] = $decoded[($i - 1)]; |
|
| 6003 | + } |
|
| 5683 | 6004 | } |
| 5684 | 6005 | $decoded[$idx++] = $char; |
| 5685 | 6006 | } |
@@ -5687,24 +6008,29 @@ discard block |
||
| 5687 | 6008 | foreach ($decoded as $k => $v) |
| 5688 | 6009 | { |
| 5689 | 6010 | // 7bit are transferred literally |
| 5690 | - if ($v < 128) |
|
| 5691 | - $output .= chr($v); |
|
| 6011 | + if ($v < 128) { |
|
| 6012 | + $output .= chr($v); |
|
| 6013 | + } |
|
| 5692 | 6014 | |
| 5693 | 6015 | // 2 bytes |
| 5694 | - elseif ($v < (1 << 11)) |
|
| 5695 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
| 6016 | + elseif ($v < (1 << 11)) { |
|
| 6017 | + $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
| 6018 | + } |
|
| 5696 | 6019 | |
| 5697 | 6020 | // 3 bytes |
| 5698 | - elseif ($v < (1 << 16)) |
|
| 5699 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 6021 | + elseif ($v < (1 << 16)) { |
|
| 6022 | + $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 6023 | + } |
|
| 5700 | 6024 | |
| 5701 | 6025 | // 4 bytes |
| 5702 | - elseif ($v < (1 << 21)) |
|
| 5703 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 6026 | + elseif ($v < (1 << 21)) { |
|
| 6027 | + $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 6028 | + } |
|
| 5704 | 6029 | |
| 5705 | 6030 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
| 5706 | - else |
|
| 5707 | - $output .= $safe_char; |
|
| 6031 | + else { |
|
| 6032 | + $output .= $safe_char; |
|
| 6033 | + } |
|
| 5708 | 6034 | } |
| 5709 | 6035 | |
| 5710 | 6036 | $output_parts[] = $output; |
@@ -5799,8 +6125,7 @@ discard block |
||
| 5799 | 6125 | |
| 5800 | 6126 | $strlen = 'mb_strlen'; |
| 5801 | 6127 | $substr = 'mb_substr'; |
| 5802 | - } |
|
| 5803 | - else |
|
| 6128 | + } else |
|
| 5804 | 6129 | { |
| 5805 | 6130 | $strlen = $smcFunc['strlen']; |
| 5806 | 6131 | $substr = $smcFunc['substr']; |
@@ -5814,20 +6139,21 @@ discard block |
||
| 5814 | 6139 | |
| 5815 | 6140 | $first = $substr($string, 0, 1); |
| 5816 | 6141 | |
| 5817 | - if (empty($index[$first])) |
|
| 5818 | - $index[$first] = array(); |
|
| 6142 | + if (empty($index[$first])) { |
|
| 6143 | + $index[$first] = array(); |
|
| 6144 | + } |
|
| 5819 | 6145 | |
| 5820 | 6146 | if ($strlen($string) > 1) |
| 5821 | 6147 | { |
| 5822 | 6148 | // Sanity check on recursion |
| 5823 | - if ($depth > 99) |
|
| 5824 | - $index[$first][$substr($string, 1)] = ''; |
|
| 5825 | - |
|
| 5826 | - else |
|
| 5827 | - $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
| 6149 | + if ($depth > 99) { |
|
| 6150 | + $index[$first][$substr($string, 1)] = ''; |
|
| 6151 | + } else { |
|
| 6152 | + $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
| 6153 | + } |
|
| 6154 | + } else { |
|
| 6155 | + $index[$first][''] = ''; |
|
| 5828 | 6156 | } |
| 5829 | - else |
|
| 5830 | - $index[$first][''] = ''; |
|
| 5831 | 6157 | |
| 5832 | 6158 | $depth--; |
| 5833 | 6159 | return $index; |
@@ -5850,9 +6176,9 @@ discard block |
||
| 5850 | 6176 | $key_regex = preg_quote($key, $delim); |
| 5851 | 6177 | $new_key = $key; |
| 5852 | 6178 | |
| 5853 | - if (empty($value)) |
|
| 5854 | - $sub_regex = ''; |
|
| 5855 | - else |
|
| 6179 | + if (empty($value)) { |
|
| 6180 | + $sub_regex = ''; |
|
| 6181 | + } else |
|
| 5856 | 6182 | { |
| 5857 | 6183 | $sub_regex = $index_to_regex($value, $delim); |
| 5858 | 6184 | |
@@ -5860,22 +6186,22 @@ discard block |
||
| 5860 | 6186 | { |
| 5861 | 6187 | $new_key_array = explode('(?'.'>', $sub_regex); |
| 5862 | 6188 | $new_key .= $new_key_array[0]; |
| 6189 | + } else { |
|
| 6190 | + $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 5863 | 6191 | } |
| 5864 | - else |
|
| 5865 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 5866 | 6192 | } |
| 5867 | 6193 | |
| 5868 | - if ($depth > 1) |
|
| 5869 | - $regex[$new_key] = $key_regex . $sub_regex; |
|
| 5870 | - else |
|
| 6194 | + if ($depth > 1) { |
|
| 6195 | + $regex[$new_key] = $key_regex . $sub_regex; |
|
| 6196 | + } else |
|
| 5871 | 6197 | { |
| 5872 | 6198 | if (($length += strlen($key_regex) + 1) < $max_length || empty($regex)) |
| 5873 | 6199 | { |
| 5874 | 6200 | $regex[$new_key] = $key_regex . $sub_regex; |
| 5875 | 6201 | unset($index[$key]); |
| 6202 | + } else { |
|
| 6203 | + break; |
|
| 5876 | 6204 | } |
| 5877 | - else |
|
| 5878 | - break; |
|
| 5879 | 6205 | } |
| 5880 | 6206 | } |
| 5881 | 6207 | |
@@ -5884,10 +6210,11 @@ discard block |
||
| 5884 | 6210 | $l1 = $strlen($k1); |
| 5885 | 6211 | $l2 = $strlen($k2); |
| 5886 | 6212 | |
| 5887 | - if ($l1 == $l2) |
|
| 5888 | - return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
| 5889 | - else |
|
| 5890 | - return $l1 > $l2 ? -1 : 1; |
|
| 6213 | + if ($l1 == $l2) { |
|
| 6214 | + return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
| 6215 | + } else { |
|
| 6216 | + return $l1 > $l2 ? -1 : 1; |
|
| 6217 | + } |
|
| 5891 | 6218 | }); |
| 5892 | 6219 | |
| 5893 | 6220 | $depth--; |
@@ -5898,15 +6225,18 @@ discard block |
||
| 5898 | 6225 | $index = array(); |
| 5899 | 6226 | $regexes = array(); |
| 5900 | 6227 | |
| 5901 | - foreach ($strings as $string) |
|
| 5902 | - $index = $add_string_to_index($string, $index); |
|
| 6228 | + foreach ($strings as $string) { |
|
| 6229 | + $index = $add_string_to_index($string, $index); |
|
| 6230 | + } |
|
| 5903 | 6231 | |
| 5904 | - while (!empty($index)) |
|
| 5905 | - $regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6232 | + while (!empty($index)) { |
|
| 6233 | + $regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6234 | + } |
|
| 5906 | 6235 | |
| 5907 | 6236 | // Restore PHP's internal character encoding to whatever it was originally |
| 5908 | - if (!empty($current_encoding)) |
|
| 5909 | - mb_internal_encoding($current_encoding); |
|
| 6237 | + if (!empty($current_encoding)) { |
|
| 6238 | + mb_internal_encoding($current_encoding); |
|
| 6239 | + } |
|
| 5910 | 6240 | |
| 5911 | 6241 | return $regexes; |
| 5912 | 6242 | } |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Our Cache API class |
@@ -44,8 +45,9 @@ discard block |
||
| 44 | 45 | { |
| 45 | 46 | $supported = function_exists('xcache_get') && function_exists('xcache_set') && ini_get('xcache.var_size') > 0; |
| 46 | 47 | |
| 47 | - if ($test) |
|
| 48 | - return $supported; |
|
| 48 | + if ($test) { |
|
| 49 | + return $supported; |
|
| 50 | + } |
|
| 49 | 51 | return parent::isSupported() && $supported; |
| 50 | 52 | } |
| 51 | 53 | |
@@ -66,10 +68,11 @@ discard block |
||
| 66 | 68 | { |
| 67 | 69 | $key = $this->prefix . strtr($key, ':/', '-_'); |
| 68 | 70 | |
| 69 | - if ($value === null) |
|
| 70 | - return xcache_unset($key); |
|
| 71 | - else |
|
| 72 | - return xcache_set($key, $value, $ttl); |
|
| 71 | + if ($value === null) { |
|
| 72 | + return xcache_unset($key); |
|
| 73 | + } else { |
|
| 74 | + return xcache_set($key, $value, $ttl); |
|
| 75 | + } |
|
| 73 | 76 | } |
| 74 | 77 | |
| 75 | 78 | /** |
@@ -88,10 +91,12 @@ discard block |
||
| 88 | 91 | } |
| 89 | 92 | |
| 90 | 93 | // if passed a type, clear that type out |
| 91 | - if ($type === '' || $type === 'user') |
|
| 92 | - xcache_clear_cache(XC_TYPE_VAR, 0); |
|
| 93 | - if ($type === '' || $type === 'data') |
|
| 94 | - xcache_clear_cache(XC_TYPE_PHP, 0); |
|
| 94 | + if ($type === '' || $type === 'user') { |
|
| 95 | + xcache_clear_cache(XC_TYPE_VAR, 0); |
|
| 96 | + } |
|
| 97 | + if ($type === '' || $type === 'data') { |
|
| 98 | + xcache_clear_cache(XC_TYPE_PHP, 0); |
|
| 99 | + } |
|
| 95 | 100 | |
| 96 | 101 | $this->invalidateCache(); |
| 97 | 102 | return true; |
@@ -110,8 +115,9 @@ discard block |
||
| 110 | 115 | // While we could md5 this when saving, this could be tricky to be sure it doesn't get corrupted on additional saves. |
| 111 | 116 | $config_vars[] = array('xcache_adminpass', $txt['cache_xcache_adminpass'], 'db', 'text', 0); |
| 112 | 117 | |
| 113 | - if (!isset($context['settings_post_javascript'])) |
|
| 114 | - $context['settings_post_javascript'] = ''; |
|
| 118 | + if (!isset($context['settings_post_javascript'])) { |
|
| 119 | + $context['settings_post_javascript'] = ''; |
|
| 120 | + } |
|
| 115 | 121 | |
| 116 | 122 | $context['settings_post_javascript'] .= ' |
| 117 | 123 | $("#cache_accelerator").change(function (e) { |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 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 | * Get all birthdays within the given time range. |
@@ -60,8 +61,7 @@ discard block |
||
| 60 | 61 | 'max_year' => $year_high, |
| 61 | 62 | ) |
| 62 | 63 | ); |
| 63 | - } |
|
| 64 | - else |
|
| 64 | + } else |
|
| 65 | 65 | { |
| 66 | 66 | $result = $smcFunc['db_query']('birthday_array', ' |
| 67 | 67 | SELECT id_member, real_name, YEAR(birthdate) AS birth_year, birthdate |
@@ -91,10 +91,11 @@ discard block |
||
| 91 | 91 | $bday = array(); |
| 92 | 92 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 93 | 93 | { |
| 94 | - if ($year_low != $year_high) |
|
| 95 | - $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
| 96 | - else |
|
| 97 | - $age_year = $year_low; |
|
| 94 | + if ($year_low != $year_high) { |
|
| 95 | + $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
| 96 | + } else { |
|
| 97 | + $age_year = $year_low; |
|
| 98 | + } |
|
| 98 | 99 | |
| 99 | 100 | $bday[$age_year . substr($row['birthdate'], 4)][] = array( |
| 100 | 101 | 'id' => $row['id_member'], |
@@ -108,8 +109,9 @@ discard block |
||
| 108 | 109 | ksort($bday); |
| 109 | 110 | |
| 110 | 111 | // Set is_last, so the themes know when to stop placing separators. |
| 111 | - foreach ($bday as $mday => $array) |
|
| 112 | - $bday[$mday][count($array) - 1]['is_last'] = true; |
|
| 112 | + foreach ($bday as $mday => $array) { |
|
| 113 | + $bday[$mday][count($array) - 1]['is_last'] = true; |
|
| 114 | + } |
|
| 113 | 115 | |
| 114 | 116 | return $bday; |
| 115 | 117 | } |
@@ -157,8 +159,9 @@ discard block |
||
| 157 | 159 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 158 | 160 | { |
| 159 | 161 | // If the attached topic is not approved then for the moment pretend it doesn't exist |
| 160 | - if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) |
|
| 161 | - continue; |
|
| 162 | + if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) { |
|
| 163 | + continue; |
|
| 164 | + } |
|
| 162 | 165 | |
| 163 | 166 | // Force a censor of the title - as often these are used by others. |
| 164 | 167 | censorText($row['title'], $use_permissions ? false : true); |
@@ -167,8 +170,9 @@ discard block |
||
| 167 | 170 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
| 168 | 171 | |
| 169 | 172 | // Sanity check |
| 170 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
| 171 | - continue; |
|
| 173 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
| 174 | + continue; |
|
| 175 | + } |
|
| 172 | 176 | |
| 173 | 177 | // Get set up for the loop |
| 174 | 178 | $start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), timezone_open($tz)); |
@@ -232,8 +236,8 @@ discard block |
||
| 232 | 236 | ); |
| 233 | 237 | |
| 234 | 238 | // If we're using permissions (calendar pages?) then just ouput normal contextual style information. |
| 235 | - if ($use_permissions) |
|
| 236 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 239 | + if ($use_permissions) { |
|
| 240 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 237 | 241 | 'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
| 238 | 242 | 'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
| 239 | 243 | 'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')), |
@@ -241,9 +245,10 @@ discard block |
||
| 241 | 245 | 'can_export' => !empty($modSettings['cal_export']) ? true : false, |
| 242 | 246 | 'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
| 243 | 247 | )); |
| 248 | + } |
|
| 244 | 249 | // Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info. |
| 245 | - else |
|
| 246 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 250 | + else { |
|
| 251 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 247 | 252 | 'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
| 248 | 253 | 'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
| 249 | 254 | 'can_edit' => false, |
@@ -253,6 +258,7 @@ discard block |
||
| 253 | 258 | 'poster' => $row['id_member'], |
| 254 | 259 | 'allowed_groups' => explode(',', $row['member_groups']), |
| 255 | 260 | )); |
| 261 | + } |
|
| 256 | 262 | |
| 257 | 263 | date_add($cal_date, date_interval_create_from_date_string('1 day')); |
| 258 | 264 | } |
@@ -262,8 +268,9 @@ discard block |
||
| 262 | 268 | // If we're doing normal contextual data, go through and make things clear to the templates ;). |
| 263 | 269 | if ($use_permissions) |
| 264 | 270 | { |
| 265 | - foreach ($events as $mday => $array) |
|
| 266 | - $events[$mday][count($array) - 1]['is_last'] = true; |
|
| 271 | + foreach ($events as $mday => $array) { |
|
| 272 | + $events[$mday][count($array) - 1]['is_last'] = true; |
|
| 273 | + } |
|
| 267 | 274 | } |
| 268 | 275 | |
| 269 | 276 | ksort($events); |
@@ -283,11 +290,12 @@ discard block |
||
| 283 | 290 | global $smcFunc; |
| 284 | 291 | |
| 285 | 292 | // Get the lowest and highest dates for "all years". |
| 286 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
| 287 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
| 293 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
| 294 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
| 288 | 295 | OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}'; |
| 289 | - else |
|
| 290 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
| 296 | + } else { |
|
| 297 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
| 298 | + } |
|
| 291 | 299 | |
| 292 | 300 | // Find some holidays... ;). |
| 293 | 301 | $result = $smcFunc['db_query']('', ' |
@@ -307,10 +315,11 @@ discard block |
||
| 307 | 315 | $holidays = array(); |
| 308 | 316 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 309 | 317 | { |
| 310 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
| 311 | - $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
| 312 | - else |
|
| 313 | - $event_year = substr($low_date, 0, 4); |
|
| 318 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
| 319 | + $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
| 320 | + } else { |
|
| 321 | + $event_year = substr($low_date, 0, 4); |
|
| 322 | + } |
|
| 314 | 323 | |
| 315 | 324 | $holidays[$event_year . substr($row['event_date'], 4)][] = $row['title']; |
| 316 | 325 | } |
@@ -336,10 +345,12 @@ discard block |
||
| 336 | 345 | isAllowedTo('calendar_post'); |
| 337 | 346 | |
| 338 | 347 | // No board? No topic?!? |
| 339 | - if (empty($board)) |
|
| 340 | - fatal_lang_error('missing_board_id', false); |
|
| 341 | - if (empty($topic)) |
|
| 342 | - fatal_lang_error('missing_topic_id', false); |
|
| 348 | + if (empty($board)) { |
|
| 349 | + fatal_lang_error('missing_board_id', false); |
|
| 350 | + } |
|
| 351 | + if (empty($topic)) { |
|
| 352 | + fatal_lang_error('missing_topic_id', false); |
|
| 353 | + } |
|
| 343 | 354 | |
| 344 | 355 | // Administrator, Moderator, or owner. Period. |
| 345 | 356 | if (!allowedTo('admin_forum') && !allowedTo('moderate_board')) |
@@ -357,12 +368,14 @@ discard block |
||
| 357 | 368 | if ($row = $smcFunc['db_fetch_assoc']($result)) |
| 358 | 369 | { |
| 359 | 370 | // Not the owner of the topic. |
| 360 | - if ($row['id_member_started'] != $user_info['id']) |
|
| 361 | - fatal_lang_error('not_your_topic', 'user'); |
|
| 371 | + if ($row['id_member_started'] != $user_info['id']) { |
|
| 372 | + fatal_lang_error('not_your_topic', 'user'); |
|
| 373 | + } |
|
| 362 | 374 | } |
| 363 | 375 | // Topic/Board doesn't exist..... |
| 364 | - else |
|
| 365 | - fatal_lang_error('calendar_no_topic', 'general'); |
|
| 376 | + else { |
|
| 377 | + fatal_lang_error('calendar_no_topic', 'general'); |
|
| 378 | + } |
|
| 366 | 379 | $smcFunc['db_free_result']($result); |
| 367 | 380 | } |
| 368 | 381 | } |
@@ -450,14 +463,16 @@ discard block |
||
| 450 | 463 | if (!empty($calendarOptions['start_day'])) |
| 451 | 464 | { |
| 452 | 465 | $nShift -= $calendarOptions['start_day']; |
| 453 | - if ($nShift < 0) |
|
| 454 | - $nShift = 7 + $nShift; |
|
| 466 | + if ($nShift < 0) { |
|
| 467 | + $nShift = 7 + $nShift; |
|
| 468 | + } |
|
| 455 | 469 | } |
| 456 | 470 | |
| 457 | 471 | // Number of rows required to fit the month. |
| 458 | 472 | $nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7); |
| 459 | - if (($month_info['last_day']['day_of_month'] + $nShift) % 7) |
|
| 460 | - $nRows++; |
|
| 473 | + if (($month_info['last_day']['day_of_month'] + $nShift) % 7) { |
|
| 474 | + $nRows++; |
|
| 475 | + } |
|
| 461 | 476 | |
| 462 | 477 | // Fetch the arrays for birthdays, posted events, and holidays. |
| 463 | 478 | $bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array(); |
@@ -470,8 +485,9 @@ discard block |
||
| 470 | 485 | { |
| 471 | 486 | $calendarGrid['week_days'][] = $count; |
| 472 | 487 | $count++; |
| 473 | - if ($count == 7) |
|
| 474 | - $count = 0; |
|
| 488 | + if ($count == 7) { |
|
| 489 | + $count = 0; |
|
| 490 | + } |
|
| 475 | 491 | } |
| 476 | 492 | |
| 477 | 493 | // Iterate through each week. |
@@ -488,8 +504,9 @@ discard block |
||
| 488 | 504 | { |
| 489 | 505 | $nDay = ($nRow * 7) + $nCol - $nShift + 1; |
| 490 | 506 | |
| 491 | - if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) |
|
| 492 | - $nDay = 0; |
|
| 507 | + if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) { |
|
| 508 | + $nDay = 0; |
|
| 509 | + } |
|
| 493 | 510 | |
| 494 | 511 | $date = sprintf('%04d-%02d-%02d', $year, $month, $nDay); |
| 495 | 512 | |
@@ -507,8 +524,9 @@ discard block |
||
| 507 | 524 | } |
| 508 | 525 | |
| 509 | 526 | // What is the last day of the month? |
| 510 | - if ($is_previous === true) |
|
| 511 | - $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
| 527 | + if ($is_previous === true) { |
|
| 528 | + $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
| 529 | + } |
|
| 512 | 530 | |
| 513 | 531 | // We'll use the shift in the template. |
| 514 | 532 | $calendarGrid['shift'] = $nShift; |
@@ -542,8 +560,9 @@ discard block |
||
| 542 | 560 | { |
| 543 | 561 | // Here we offset accordingly to get things to the real start of a week. |
| 544 | 562 | $date_diff = $day_of_week - $calendarOptions['start_day']; |
| 545 | - if ($date_diff < 0) |
|
| 546 | - $date_diff += 7; |
|
| 563 | + if ($date_diff < 0) { |
|
| 564 | + $date_diff += 7; |
|
| 565 | + } |
|
| 547 | 566 | $new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400; |
| 548 | 567 | $day = (int) strftime('%d', $new_timestamp); |
| 549 | 568 | $month = (int) strftime('%m', $new_timestamp); |
@@ -673,18 +692,20 @@ discard block |
||
| 673 | 692 | { |
| 674 | 693 | foreach ($date_events as $event_key => $event_val) |
| 675 | 694 | { |
| 676 | - if (in_array($event_val['id'], $temp)) |
|
| 677 | - unset($calendarGrid['events'][$date][$event_key]); |
|
| 678 | - else |
|
| 679 | - $temp[] = $event_val['id']; |
|
| 695 | + if (in_array($event_val['id'], $temp)) { |
|
| 696 | + unset($calendarGrid['events'][$date][$event_key]); |
|
| 697 | + } else { |
|
| 698 | + $temp[] = $event_val['id']; |
|
| 699 | + } |
|
| 680 | 700 | } |
| 681 | 701 | } |
| 682 | 702 | |
| 683 | 703 | // Give birthdays and holidays a friendly format, without the year |
| 684 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 685 | - $date_format = '%b %d'; |
|
| 686 | - else |
|
| 687 | - $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
| 704 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 705 | + $date_format = '%b %d'; |
|
| 706 | + } else { |
|
| 707 | + $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
| 708 | + } |
|
| 688 | 709 | |
| 689 | 710 | foreach (array('birthdays', 'holidays') as $type) |
| 690 | 711 | { |
@@ -779,8 +800,9 @@ discard block |
||
| 779 | 800 | // Holidays between now and now + days. |
| 780 | 801 | for ($i = $now; $i < $now + $days_for_index; $i += 86400) |
| 781 | 802 | { |
| 782 | - if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) |
|
| 783 | - $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
| 803 | + if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) { |
|
| 804 | + $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
| 805 | + } |
|
| 784 | 806 | } |
| 785 | 807 | |
| 786 | 808 | // Happy Birthday, guys and gals! |
@@ -789,8 +811,9 @@ discard block |
||
| 789 | 811 | $loop_date = strftime('%Y-%m-%d', $i); |
| 790 | 812 | if (isset($cached_data['birthdays'][$loop_date])) |
| 791 | 813 | { |
| 792 | - foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) |
|
| 793 | - $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
| 814 | + foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) { |
|
| 815 | + $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
| 816 | + } |
|
| 794 | 817 | $return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]); |
| 795 | 818 | } |
| 796 | 819 | } |
@@ -802,8 +825,9 @@ discard block |
||
| 802 | 825 | $loop_date = strftime('%Y-%m-%d', $i); |
| 803 | 826 | |
| 804 | 827 | // No events today? Check the next day. |
| 805 | - if (empty($cached_data['events'][$loop_date])) |
|
| 806 | - continue; |
|
| 828 | + if (empty($cached_data['events'][$loop_date])) { |
|
| 829 | + continue; |
|
| 830 | + } |
|
| 807 | 831 | |
| 808 | 832 | // Loop through all events to add a few last-minute values. |
| 809 | 833 | foreach ($cached_data['events'][$loop_date] as $ev => $event) |
@@ -816,9 +840,9 @@ discard block |
||
| 816 | 840 | { |
| 817 | 841 | unset($cached_data['events'][$loop_date][$ev]); |
| 818 | 842 | continue; |
| 843 | + } else { |
|
| 844 | + $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
| 819 | 845 | } |
| 820 | - else |
|
| 821 | - $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
| 822 | 846 | |
| 823 | 847 | // Might be set to true afterwards, depending on the permissions. |
| 824 | 848 | $this_event['can_edit'] = false; |
@@ -826,15 +850,18 @@ discard block |
||
| 826 | 850 | $this_event['date'] = $loop_date; |
| 827 | 851 | } |
| 828 | 852 | |
| 829 | - if (!empty($cached_data['events'][$loop_date])) |
|
| 830 | - $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
| 853 | + if (!empty($cached_data['events'][$loop_date])) { |
|
| 854 | + $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
| 855 | + } |
|
| 831 | 856 | } |
| 832 | 857 | |
| 833 | 858 | // Mark the last item so that a list separator can be used in the template. |
| 834 | - for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) |
|
| 835 | - $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
| 836 | - for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) |
|
| 837 | - $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
| 859 | + for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) { |
|
| 860 | + $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
| 861 | + } |
|
| 862 | + for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) { |
|
| 863 | + $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
| 864 | + } |
|
| 838 | 865 | |
| 839 | 866 | return array( |
| 840 | 867 | 'data' => $return_data, |
@@ -882,37 +909,46 @@ discard block |
||
| 882 | 909 | if (isset($_POST['start_date'])) |
| 883 | 910 | { |
| 884 | 911 | $d = date_parse($_POST['start_date']); |
| 885 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
| 886 | - fatal_lang_error('invalid_date', false); |
|
| 887 | - if (empty($d['year'])) |
|
| 888 | - fatal_lang_error('event_year_missing', false); |
|
| 889 | - if (empty($d['month'])) |
|
| 890 | - fatal_lang_error('event_month_missing', false); |
|
| 891 | - } |
|
| 892 | - elseif (isset($_POST['start_datetime'])) |
|
| 912 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
| 913 | + fatal_lang_error('invalid_date', false); |
|
| 914 | + } |
|
| 915 | + if (empty($d['year'])) { |
|
| 916 | + fatal_lang_error('event_year_missing', false); |
|
| 917 | + } |
|
| 918 | + if (empty($d['month'])) { |
|
| 919 | + fatal_lang_error('event_month_missing', false); |
|
| 920 | + } |
|
| 921 | + } elseif (isset($_POST['start_datetime'])) |
|
| 893 | 922 | { |
| 894 | 923 | $d = date_parse($_POST['start_datetime']); |
| 895 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
| 896 | - fatal_lang_error('invalid_date', false); |
|
| 897 | - if (empty($d['year'])) |
|
| 898 | - fatal_lang_error('event_year_missing', false); |
|
| 899 | - if (empty($d['month'])) |
|
| 900 | - fatal_lang_error('event_month_missing', false); |
|
| 924 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
| 925 | + fatal_lang_error('invalid_date', false); |
|
| 926 | + } |
|
| 927 | + if (empty($d['year'])) { |
|
| 928 | + fatal_lang_error('event_year_missing', false); |
|
| 929 | + } |
|
| 930 | + if (empty($d['month'])) { |
|
| 931 | + fatal_lang_error('event_month_missing', false); |
|
| 932 | + } |
|
| 901 | 933 | } |
| 902 | 934 | // The 2.0 way |
| 903 | 935 | else |
| 904 | 936 | { |
| 905 | 937 | // No month? No year? |
| 906 | - if (!isset($_POST['month'])) |
|
| 907 | - fatal_lang_error('event_month_missing', false); |
|
| 908 | - if (!isset($_POST['year'])) |
|
| 909 | - fatal_lang_error('event_year_missing', false); |
|
| 938 | + if (!isset($_POST['month'])) { |
|
| 939 | + fatal_lang_error('event_month_missing', false); |
|
| 940 | + } |
|
| 941 | + if (!isset($_POST['year'])) { |
|
| 942 | + fatal_lang_error('event_year_missing', false); |
|
| 943 | + } |
|
| 910 | 944 | |
| 911 | 945 | // Check the month and year... |
| 912 | - if ($_POST['month'] < 1 || $_POST['month'] > 12) |
|
| 913 | - fatal_lang_error('invalid_month', false); |
|
| 914 | - if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) |
|
| 915 | - fatal_lang_error('invalid_year', false); |
|
| 946 | + if ($_POST['month'] < 1 || $_POST['month'] > 12) { |
|
| 947 | + fatal_lang_error('invalid_month', false); |
|
| 948 | + } |
|
| 949 | + if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) { |
|
| 950 | + fatal_lang_error('invalid_year', false); |
|
| 951 | + } |
|
| 916 | 952 | } |
| 917 | 953 | } |
| 918 | 954 | |
@@ -922,8 +958,9 @@ discard block |
||
| 922 | 958 | // If they want to us to calculate an end date, make sure it will fit in an acceptable range. |
| 923 | 959 | if (isset($_POST['span'])) |
| 924 | 960 | { |
| 925 | - if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) |
|
| 926 | - fatal_lang_error('invalid_days_numb', false); |
|
| 961 | + if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) { |
|
| 962 | + fatal_lang_error('invalid_days_numb', false); |
|
| 963 | + } |
|
| 927 | 964 | } |
| 928 | 965 | |
| 929 | 966 | // There is no need to validate the following values if we are just deleting the event. |
@@ -933,24 +970,29 @@ discard block |
||
| 933 | 970 | if (empty($_POST['start_date']) && empty($_POST['start_datetime'])) |
| 934 | 971 | { |
| 935 | 972 | // No day? |
| 936 | - if (!isset($_POST['day'])) |
|
| 937 | - fatal_lang_error('event_day_missing', false); |
|
| 973 | + if (!isset($_POST['day'])) { |
|
| 974 | + fatal_lang_error('event_day_missing', false); |
|
| 975 | + } |
|
| 938 | 976 | |
| 939 | 977 | // Bad day? |
| 940 | - if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) |
|
| 941 | - fatal_lang_error('invalid_date', false); |
|
| 978 | + if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) { |
|
| 979 | + fatal_lang_error('invalid_date', false); |
|
| 980 | + } |
|
| 942 | 981 | } |
| 943 | 982 | |
| 944 | - if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) |
|
| 945 | - fatal_lang_error('event_title_missing', false); |
|
| 946 | - elseif (!isset($_POST['evtitle'])) |
|
| 947 | - $_POST['evtitle'] = $_POST['subject']; |
|
| 983 | + if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) { |
|
| 984 | + fatal_lang_error('event_title_missing', false); |
|
| 985 | + } elseif (!isset($_POST['evtitle'])) { |
|
| 986 | + $_POST['evtitle'] = $_POST['subject']; |
|
| 987 | + } |
|
| 948 | 988 | |
| 949 | 989 | // No title? |
| 950 | - if ($smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
| 951 | - fatal_lang_error('no_event_title', false); |
|
| 952 | - if ($smcFunc['strlen']($_POST['evtitle']) > 100) |
|
| 953 | - $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
| 990 | + if ($smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
| 991 | + fatal_lang_error('no_event_title', false); |
|
| 992 | + } |
|
| 993 | + if ($smcFunc['strlen']($_POST['evtitle']) > 100) { |
|
| 994 | + $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
| 995 | + } |
|
| 954 | 996 | $_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']); |
| 955 | 997 | } |
| 956 | 998 | } |
@@ -977,8 +1019,9 @@ discard block |
||
| 977 | 1019 | ); |
| 978 | 1020 | |
| 979 | 1021 | // No results, return false. |
| 980 | - if ($smcFunc['db_num_rows'] === 0) |
|
| 981 | - return false; |
|
| 1022 | + if ($smcFunc['db_num_rows'] === 0) { |
|
| 1023 | + return false; |
|
| 1024 | + } |
|
| 982 | 1025 | |
| 983 | 1026 | // Grab the results and return. |
| 984 | 1027 | list ($poster) = $smcFunc['db_fetch_row']($request); |
@@ -1112,8 +1155,9 @@ discard block |
||
| 1112 | 1155 | call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters)); |
| 1113 | 1156 | |
| 1114 | 1157 | $column_clauses = array(); |
| 1115 | - foreach ($event_columns as $col => $crit) |
|
| 1116 | - $column_clauses[] = $col . ' = ' . $crit; |
|
| 1158 | + foreach ($event_columns as $col => $crit) { |
|
| 1159 | + $column_clauses[] = $col . ' = ' . $crit; |
|
| 1160 | + } |
|
| 1117 | 1161 | |
| 1118 | 1162 | $smcFunc['db_query']('', ' |
| 1119 | 1163 | UPDATE {db_prefix}calendar |
@@ -1198,8 +1242,9 @@ discard block |
||
| 1198 | 1242 | ); |
| 1199 | 1243 | |
| 1200 | 1244 | // If nothing returned, we are in poo, poo. |
| 1201 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 1202 | - return false; |
|
| 1245 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 1246 | + return false; |
|
| 1247 | + } |
|
| 1203 | 1248 | |
| 1204 | 1249 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1205 | 1250 | $smcFunc['db_free_result']($request); |
@@ -1207,8 +1252,9 @@ discard block |
||
| 1207 | 1252 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
| 1208 | 1253 | |
| 1209 | 1254 | // Sanity check |
| 1210 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
| 1211 | - return false; |
|
| 1255 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
| 1256 | + return false; |
|
| 1257 | + } |
|
| 1212 | 1258 | |
| 1213 | 1259 | $return_value = array( |
| 1214 | 1260 | 'boards' => array(), |
@@ -1345,24 +1391,27 @@ discard block |
||
| 1345 | 1391 | |
| 1346 | 1392 | // Set $span, in case we need it |
| 1347 | 1393 | $span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0); |
| 1348 | - if ($span > 0) |
|
| 1349 | - $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
| 1394 | + if ($span > 0) { |
|
| 1395 | + $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
| 1396 | + } |
|
| 1350 | 1397 | |
| 1351 | 1398 | // Define the timezone for this event, falling back to the default if not provided |
| 1352 | - if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1353 | - $tz = $eventOptions['tz']; |
|
| 1354 | - elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1355 | - $tz = $_POST['tz']; |
|
| 1356 | - else |
|
| 1357 | - $tz = getUserTimezone(); |
|
| 1399 | + if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1400 | + $tz = $eventOptions['tz']; |
|
| 1401 | + } elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1402 | + $tz = $_POST['tz']; |
|
| 1403 | + } else { |
|
| 1404 | + $tz = getUserTimezone(); |
|
| 1405 | + } |
|
| 1358 | 1406 | |
| 1359 | 1407 | // Is this supposed to be an all day event, or should it have specific start and end times? |
| 1360 | - if (isset($eventOptions['allday'])) |
|
| 1361 | - $allday = $eventOptions['allday']; |
|
| 1362 | - elseif (empty($_POST['allday'])) |
|
| 1363 | - $allday = false; |
|
| 1364 | - else |
|
| 1365 | - $allday = true; |
|
| 1408 | + if (isset($eventOptions['allday'])) { |
|
| 1409 | + $allday = $eventOptions['allday']; |
|
| 1410 | + } elseif (empty($_POST['allday'])) { |
|
| 1411 | + $allday = false; |
|
| 1412 | + } else { |
|
| 1413 | + $allday = true; |
|
| 1414 | + } |
|
| 1366 | 1415 | |
| 1367 | 1416 | // Input might come as individual parameters... |
| 1368 | 1417 | $start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null); |
@@ -1389,10 +1438,12 @@ discard block |
||
| 1389 | 1438 | $end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null); |
| 1390 | 1439 | |
| 1391 | 1440 | // If the date and time were given in separate strings, combine them |
| 1392 | - if (empty($start_string) && isset($start_date_string)) |
|
| 1393 | - $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
| 1394 | - if (empty($end_string) && isset($end_date_string)) |
|
| 1395 | - $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
| 1441 | + if (empty($start_string) && isset($start_date_string)) { |
|
| 1442 | + $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
| 1443 | + } |
|
| 1444 | + if (empty($end_string) && isset($end_date_string)) { |
|
| 1445 | + $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
| 1446 | + } |
|
| 1396 | 1447 | |
| 1397 | 1448 | // If some form of string input was given, override individually defined options with it |
| 1398 | 1449 | if (isset($start_string)) |
@@ -1483,10 +1534,11 @@ discard block |
||
| 1483 | 1534 | if ($start_object >= $end_object) |
| 1484 | 1535 | { |
| 1485 | 1536 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
| 1486 | - if ($span > 0) |
|
| 1487 | - date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
| 1488 | - else |
|
| 1489 | - date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
| 1537 | + if ($span > 0) { |
|
| 1538 | + date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
| 1539 | + } else { |
|
| 1540 | + date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
| 1541 | + } |
|
| 1490 | 1542 | } |
| 1491 | 1543 | |
| 1492 | 1544 | // Is $end_object too late? |
@@ -1499,9 +1551,9 @@ discard block |
||
| 1499 | 1551 | { |
| 1500 | 1552 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
| 1501 | 1553 | date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days')); |
| 1554 | + } else { |
|
| 1555 | + $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
| 1502 | 1556 | } |
| 1503 | - else |
|
| 1504 | - $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
| 1505 | 1557 | } |
| 1506 | 1558 | } |
| 1507 | 1559 | |
@@ -1514,8 +1566,7 @@ discard block |
||
| 1514 | 1566 | $start_time = null; |
| 1515 | 1567 | $end_time = null; |
| 1516 | 1568 | $tz = null; |
| 1517 | - } |
|
| 1518 | - else |
|
| 1569 | + } else |
|
| 1519 | 1570 | { |
| 1520 | 1571 | $start_time = date_format($start_object, 'H:i:s'); |
| 1521 | 1572 | $end_time = date_format($end_object, 'H:i:s'); |
@@ -1536,16 +1587,18 @@ discard block |
||
| 1536 | 1587 | require_once($sourcedir . '/Subs.php'); |
| 1537 | 1588 | |
| 1538 | 1589 | // First, try to create a better date format, ignoring the "time" elements. |
| 1539 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 1540 | - $date_format = '%F'; |
|
| 1541 | - else |
|
| 1542 | - $date_format = $matches[0]; |
|
| 1590 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 1591 | + $date_format = '%F'; |
|
| 1592 | + } else { |
|
| 1593 | + $date_format = $matches[0]; |
|
| 1594 | + } |
|
| 1543 | 1595 | |
| 1544 | 1596 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 1545 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 1546 | - $time_format = '%k:%M'; |
|
| 1547 | - else |
|
| 1548 | - $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 1597 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 1598 | + $time_format = '%k:%M'; |
|
| 1599 | + } else { |
|
| 1600 | + $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 1601 | + } |
|
| 1549 | 1602 | |
| 1550 | 1603 | // Should this be an all day event? |
| 1551 | 1604 | $allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false; |
@@ -1554,8 +1607,9 @@ discard block |
||
| 1554 | 1607 | $span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d'); |
| 1555 | 1608 | |
| 1556 | 1609 | // We need to have a defined timezone in the steps below |
| 1557 | - if (empty($row['timezone'])) |
|
| 1558 | - $row['timezone'] = getUserTimezone(); |
|
| 1610 | + if (empty($row['timezone'])) { |
|
| 1611 | + $row['timezone'] = getUserTimezone(); |
|
| 1612 | + } |
|
| 1559 | 1613 | |
| 1560 | 1614 | // Get most of the standard date information for the start and end datetimes |
| 1561 | 1615 | $start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : '')); |
@@ -1607,8 +1661,9 @@ discard block |
||
| 1607 | 1661 | global $smcFunc, $context, $user_info, $modSettings; |
| 1608 | 1662 | static $member_cache = array(); |
| 1609 | 1663 | |
| 1610 | - if (is_null($id_member) && $user_info['is_guest'] == false) |
|
| 1611 | - $id_member = $context['user']['id']; |
|
| 1664 | + if (is_null($id_member) && $user_info['is_guest'] == false) { |
|
| 1665 | + $id_member = $context['user']['id']; |
|
| 1666 | + } |
|
| 1612 | 1667 | |
| 1613 | 1668 | //check if the cache got the data |
| 1614 | 1669 | if (isset($id_member) && isset($member_cache[$id_member])) |
@@ -1630,11 +1685,13 @@ discard block |
||
| 1630 | 1685 | $smcFunc['db_free_result']($request); |
| 1631 | 1686 | } |
| 1632 | 1687 | |
| 1633 | - if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1634 | - $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
| 1688 | + if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1689 | + $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
| 1690 | + } |
|
| 1635 | 1691 | |
| 1636 | - if (isset($id_member)) |
|
| 1637 | - $member_cache[$id_member] = $timezone; |
|
| 1692 | + if (isset($id_member)) { |
|
| 1693 | + $member_cache[$id_member] = $timezone; |
|
| 1694 | + } |
|
| 1638 | 1695 | |
| 1639 | 1696 | return $timezone; |
| 1640 | 1697 | } |
@@ -1663,8 +1720,9 @@ discard block |
||
| 1663 | 1720 | ) |
| 1664 | 1721 | ); |
| 1665 | 1722 | $holidays = array(); |
| 1666 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1667 | - $holidays[] = $row; |
|
| 1723 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1724 | + $holidays[] = $row; |
|
| 1725 | + } |
|
| 1668 | 1726 | $smcFunc['db_free_result']($request); |
| 1669 | 1727 | |
| 1670 | 1728 | return $holidays; |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 3 |
| 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 = '0001-01-01'; |
|
| 108 | - else |
|
| 109 | - $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 4 ? 4 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 4 ? 4 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '0001-01-01'; |
|
| 108 | + if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) { |
|
| 109 | + $value = '0001-01-01'; |
|
| 110 | + } else { |
|
| 111 | + $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 4 ? 4 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 4 ? 4 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '0001-01-01'; |
|
| 112 | + } |
|
| 113 | + } else { |
|
| 114 | + $value = '0001-01-01'; |
|
| 110 | 115 | } |
| 111 | - else |
|
| 112 | - $value = '0001-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]) : '0001-01-01'; |
| 129 | 132 | return true; |
| 130 | - } |
|
| 131 | - else |
|
| 133 | + } else |
|
| 132 | 134 | { |
| 133 | 135 | $value = empty($cur_profile['birthdate']) ? '0001-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,48 +1238,49 @@ 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 | - if ($row['field_length']) |
|
| 1197 | - $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
| 1260 | + if ($row['field_length']) { |
|
| 1261 | + $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
| 1262 | + } |
|
| 1198 | 1263 | |
| 1199 | 1264 | // Any masks? |
| 1200 | 1265 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
| 1201 | 1266 | { |
| 1202 | 1267 | if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
| 1203 | 1268 | { |
| 1204 | - if ($returnErrors) |
|
| 1205 | - $errors[] = 'custom_field_mail_fail'; |
|
| 1206 | - |
|
| 1207 | - else |
|
| 1208 | - $value = ''; |
|
| 1209 | - } |
|
| 1210 | - elseif ($row['mask'] == 'number') |
|
| 1269 | + if ($returnErrors) { |
|
| 1270 | + $errors[] = 'custom_field_mail_fail'; |
|
| 1271 | + } else { |
|
| 1272 | + $value = ''; |
|
| 1273 | + } |
|
| 1274 | + } elseif ($row['mask'] == 'number') |
|
| 1211 | 1275 | { |
| 1212 | 1276 | $value = (int) $value; |
| 1213 | - } |
|
| 1214 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 1277 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 1215 | 1278 | { |
| 1216 | - if ($returnErrors) |
|
| 1217 | - $errors[] = 'custom_field_regex_fail'; |
|
| 1218 | - |
|
| 1219 | - else |
|
| 1220 | - $value = ''; |
|
| 1279 | + if ($returnErrors) { |
|
| 1280 | + $errors[] = 'custom_field_regex_fail'; |
|
| 1281 | + } else { |
|
| 1282 | + $value = ''; |
|
| 1283 | + } |
|
| 1221 | 1284 | } |
| 1222 | 1285 | } |
| 1223 | 1286 | } |
@@ -1243,8 +1306,9 @@ discard block |
||
| 1243 | 1306 | |
| 1244 | 1307 | $hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize)); |
| 1245 | 1308 | |
| 1246 | - if (!empty($hook_errors) && is_array($hook_errors)) |
|
| 1247 | - $errors = array_merge($errors, $hook_errors); |
|
| 1309 | + if (!empty($hook_errors) && is_array($hook_errors)) { |
|
| 1310 | + $errors = array_merge($errors, $hook_errors); |
|
| 1311 | + } |
|
| 1248 | 1312 | |
| 1249 | 1313 | // Make those changes! |
| 1250 | 1314 | if (!empty($changes) && empty($context['password_auth_failed']) && empty($errors)) |
@@ -1262,9 +1326,10 @@ discard block |
||
| 1262 | 1326 | } |
| 1263 | 1327 | } |
| 1264 | 1328 | |
| 1265 | - if ($returnErrors) |
|
| 1266 | - return $errors; |
|
| 1267 | -} |
|
| 1329 | + if ($returnErrors) { |
|
| 1330 | + return $errors; |
|
| 1331 | + } |
|
| 1332 | + } |
|
| 1268 | 1333 | |
| 1269 | 1334 | /** |
| 1270 | 1335 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1276,8 +1341,9 @@ discard block |
||
| 1276 | 1341 | global $context, $txt, $modSettings; |
| 1277 | 1342 | |
| 1278 | 1343 | // Do a quick check to ensure people aren't getting here illegally! |
| 1279 | - if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) |
|
| 1280 | - fatal_lang_error('no_access', false); |
|
| 1344 | + if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) { |
|
| 1345 | + fatal_lang_error('no_access', false); |
|
| 1346 | + } |
|
| 1281 | 1347 | |
| 1282 | 1348 | // Can we email the user direct? |
| 1283 | 1349 | $context['can_moderate_forum'] = allowedTo('moderate_forum'); |
@@ -1307,9 +1373,10 @@ discard block |
||
| 1307 | 1373 | $context['sub_template'] = $subActions[$context['list_area']][0]; |
| 1308 | 1374 | $call = call_helper($subActions[$context['list_area']][0], true); |
| 1309 | 1375 | |
| 1310 | - if (!empty($call)) |
|
| 1311 | - call_user_func($call, $memID); |
|
| 1312 | -} |
|
| 1376 | + if (!empty($call)) { |
|
| 1377 | + call_user_func($call, $memID); |
|
| 1378 | + } |
|
| 1379 | + } |
|
| 1313 | 1380 | |
| 1314 | 1381 | /** |
| 1315 | 1382 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1323,9 +1390,10 @@ discard block |
||
| 1323 | 1390 | |
| 1324 | 1391 | // For making changes! |
| 1325 | 1392 | $buddiesArray = explode(',', $user_profile[$memID]['buddy_list']); |
| 1326 | - foreach ($buddiesArray as $k => $dummy) |
|
| 1327 | - if ($dummy == '') |
|
| 1393 | + foreach ($buddiesArray as $k => $dummy) { |
|
| 1394 | + if ($dummy == '') |
|
| 1328 | 1395 | unset($buddiesArray[$k]); |
| 1396 | + } |
|
| 1329 | 1397 | |
| 1330 | 1398 | // Removing a buddy? |
| 1331 | 1399 | if (isset($_GET['remove'])) |
@@ -1337,10 +1405,11 @@ discard block |
||
| 1337 | 1405 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
| 1338 | 1406 | |
| 1339 | 1407 | // Heh, I'm lazy, do it the easy way... |
| 1340 | - foreach ($buddiesArray as $key => $buddy) |
|
| 1341 | - if ($buddy == (int) $_GET['remove']) |
|
| 1408 | + foreach ($buddiesArray as $key => $buddy) { |
|
| 1409 | + if ($buddy == (int) $_GET['remove']) |
|
| 1342 | 1410 | { |
| 1343 | 1411 | unset($buddiesArray[$key]); |
| 1412 | + } |
|
| 1344 | 1413 | $_SESSION['prf-save'] = true; |
| 1345 | 1414 | } |
| 1346 | 1415 | |
@@ -1350,8 +1419,7 @@ discard block |
||
| 1350 | 1419 | |
| 1351 | 1420 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
| 1352 | 1421 | redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID); |
| 1353 | - } |
|
| 1354 | - elseif (isset($_POST['new_buddy'])) |
|
| 1422 | + } elseif (isset($_POST['new_buddy'])) |
|
| 1355 | 1423 | { |
| 1356 | 1424 | checkSession(); |
| 1357 | 1425 | |
@@ -1364,8 +1432,9 @@ discard block |
||
| 1364 | 1432 | { |
| 1365 | 1433 | $new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => ''')); |
| 1366 | 1434 | |
| 1367 | - if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
| 1368 | - unset($new_buddies[$k]); |
|
| 1435 | + if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
| 1436 | + unset($new_buddies[$k]); |
|
| 1437 | + } |
|
| 1369 | 1438 | } |
| 1370 | 1439 | |
| 1371 | 1440 | call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies)); |
@@ -1385,16 +1454,18 @@ discard block |
||
| 1385 | 1454 | ) |
| 1386 | 1455 | ); |
| 1387 | 1456 | |
| 1388 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1389 | - $_SESSION['prf-save'] = true; |
|
| 1457 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1458 | + $_SESSION['prf-save'] = true; |
|
| 1459 | + } |
|
| 1390 | 1460 | |
| 1391 | 1461 | // Add the new member to the buddies array. |
| 1392 | 1462 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1393 | 1463 | { |
| 1394 | - if (in_array($row['id_member'], $buddiesArray)) |
|
| 1395 | - continue; |
|
| 1396 | - else |
|
| 1397 | - $buddiesArray[] = (int) $row['id_member']; |
|
| 1464 | + if (in_array($row['id_member'], $buddiesArray)) { |
|
| 1465 | + continue; |
|
| 1466 | + } else { |
|
| 1467 | + $buddiesArray[] = (int) $row['id_member']; |
|
| 1468 | + } |
|
| 1398 | 1469 | } |
| 1399 | 1470 | $smcFunc['db_free_result']($request); |
| 1400 | 1471 | |
@@ -1424,18 +1495,20 @@ discard block |
||
| 1424 | 1495 | |
| 1425 | 1496 | $context['custom_pf'] = array(); |
| 1426 | 1497 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
| 1427 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1428 | - if (!isset($disabled_fields[$row['col_name']])) |
|
| 1498 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1499 | + if (!isset($disabled_fields[$row['col_name']])) |
|
| 1429 | 1500 | $context['custom_pf'][$row['col_name']] = array( |
| 1430 | 1501 | 'label' => $row['field_name'], |
| 1431 | 1502 | 'type' => $row['field_type'], |
| 1432 | 1503 | 'bbc' => !empty($row['bbc']), |
| 1433 | 1504 | 'enclose' => $row['enclose'], |
| 1434 | 1505 | ); |
| 1506 | + } |
|
| 1435 | 1507 | |
| 1436 | 1508 | // Gotta disable the gender option. |
| 1437 | - if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') |
|
| 1438 | - unset($context['custom_pf']['cust_gender']); |
|
| 1509 | + if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') { |
|
| 1510 | + unset($context['custom_pf']['cust_gender']); |
|
| 1511 | + } |
|
| 1439 | 1512 | |
| 1440 | 1513 | $smcFunc['db_free_result']($request); |
| 1441 | 1514 | |
@@ -1452,8 +1525,9 @@ discard block |
||
| 1452 | 1525 | 'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1, |
| 1453 | 1526 | ) |
| 1454 | 1527 | ); |
| 1455 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1456 | - $buddies[] = $row['id_member']; |
|
| 1528 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1529 | + $buddies[] = $row['id_member']; |
|
| 1530 | + } |
|
| 1457 | 1531 | $smcFunc['db_free_result']($result); |
| 1458 | 1532 | } |
| 1459 | 1533 | |
@@ -1481,30 +1555,32 @@ discard block |
||
| 1481 | 1555 | continue; |
| 1482 | 1556 | } |
| 1483 | 1557 | |
| 1484 | - if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) |
|
| 1485 | - $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
| 1486 | - |
|
| 1487 | - elseif ($column['type'] == 'check') |
|
| 1488 | - $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 1558 | + if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
| 1559 | + $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
| 1560 | + } elseif ($column['type'] == 'check') { |
|
| 1561 | + $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 1562 | + } |
|
| 1489 | 1563 | |
| 1490 | 1564 | // Enclosing the user input within some other text? |
| 1491 | - if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) |
|
| 1492 | - $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
| 1565 | + if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
| 1566 | + $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
| 1493 | 1567 | '{SCRIPTURL}' => $scripturl, |
| 1494 | 1568 | '{IMAGES_URL}' => $settings['images_url'], |
| 1495 | 1569 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1496 | 1570 | '{INPUT}' => $context['buddies'][$buddy]['options'][$key], |
| 1497 | 1571 | )); |
| 1572 | + } |
|
| 1498 | 1573 | } |
| 1499 | 1574 | } |
| 1500 | 1575 | } |
| 1501 | 1576 | |
| 1502 | 1577 | if (isset($_SESSION['prf-save'])) |
| 1503 | 1578 | { |
| 1504 | - if ($_SESSION['prf-save'] === true) |
|
| 1505 | - $context['saved_successful'] = true; |
|
| 1506 | - else |
|
| 1507 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1579 | + if ($_SESSION['prf-save'] === true) { |
|
| 1580 | + $context['saved_successful'] = true; |
|
| 1581 | + } else { |
|
| 1582 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1583 | + } |
|
| 1508 | 1584 | |
| 1509 | 1585 | unset($_SESSION['prf-save']); |
| 1510 | 1586 | } |
@@ -1524,9 +1600,10 @@ discard block |
||
| 1524 | 1600 | |
| 1525 | 1601 | // For making changes! |
| 1526 | 1602 | $ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']); |
| 1527 | - foreach ($ignoreArray as $k => $dummy) |
|
| 1528 | - if ($dummy == '') |
|
| 1603 | + foreach ($ignoreArray as $k => $dummy) { |
|
| 1604 | + if ($dummy == '') |
|
| 1529 | 1605 | unset($ignoreArray[$k]); |
| 1606 | + } |
|
| 1530 | 1607 | |
| 1531 | 1608 | // Removing a member from the ignore list? |
| 1532 | 1609 | if (isset($_GET['remove'])) |
@@ -1536,10 +1613,11 @@ discard block |
||
| 1536 | 1613 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
| 1537 | 1614 | |
| 1538 | 1615 | // Heh, I'm lazy, do it the easy way... |
| 1539 | - foreach ($ignoreArray as $key => $id_remove) |
|
| 1540 | - if ($id_remove == (int) $_GET['remove']) |
|
| 1616 | + foreach ($ignoreArray as $key => $id_remove) { |
|
| 1617 | + if ($id_remove == (int) $_GET['remove']) |
|
| 1541 | 1618 | { |
| 1542 | 1619 | unset($ignoreArray[$key]); |
| 1620 | + } |
|
| 1543 | 1621 | $_SESSION['prf-save'] = true; |
| 1544 | 1622 | } |
| 1545 | 1623 | |
@@ -1549,8 +1627,7 @@ discard block |
||
| 1549 | 1627 | |
| 1550 | 1628 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
| 1551 | 1629 | redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID); |
| 1552 | - } |
|
| 1553 | - elseif (isset($_POST['new_ignore'])) |
|
| 1630 | + } elseif (isset($_POST['new_ignore'])) |
|
| 1554 | 1631 | { |
| 1555 | 1632 | checkSession(); |
| 1556 | 1633 | // Prepare the string for extraction... |
@@ -1562,8 +1639,9 @@ discard block |
||
| 1562 | 1639 | { |
| 1563 | 1640 | $new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => ''')); |
| 1564 | 1641 | |
| 1565 | - if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
| 1566 | - unset($new_entries[$k]); |
|
| 1642 | + if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
| 1643 | + unset($new_entries[$k]); |
|
| 1644 | + } |
|
| 1567 | 1645 | } |
| 1568 | 1646 | |
| 1569 | 1647 | $_SESSION['prf-save'] = $txt['could_not_add_person']; |
@@ -1581,16 +1659,18 @@ discard block |
||
| 1581 | 1659 | ) |
| 1582 | 1660 | ); |
| 1583 | 1661 | |
| 1584 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1585 | - $_SESSION['prf-save'] = true; |
|
| 1662 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1663 | + $_SESSION['prf-save'] = true; |
|
| 1664 | + } |
|
| 1586 | 1665 | |
| 1587 | 1666 | // Add the new member to the buddies array. |
| 1588 | 1667 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1589 | 1668 | { |
| 1590 | - if (in_array($row['id_member'], $ignoreArray)) |
|
| 1591 | - continue; |
|
| 1592 | - else |
|
| 1593 | - $ignoreArray[] = (int) $row['id_member']; |
|
| 1669 | + if (in_array($row['id_member'], $ignoreArray)) { |
|
| 1670 | + continue; |
|
| 1671 | + } else { |
|
| 1672 | + $ignoreArray[] = (int) $row['id_member']; |
|
| 1673 | + } |
|
| 1594 | 1674 | } |
| 1595 | 1675 | $smcFunc['db_free_result']($request); |
| 1596 | 1676 | |
@@ -1619,8 +1699,9 @@ discard block |
||
| 1619 | 1699 | 'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1, |
| 1620 | 1700 | ) |
| 1621 | 1701 | ); |
| 1622 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1623 | - $ignored[] = $row['id_member']; |
|
| 1702 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1703 | + $ignored[] = $row['id_member']; |
|
| 1704 | + } |
|
| 1624 | 1705 | $smcFunc['db_free_result']($result); |
| 1625 | 1706 | } |
| 1626 | 1707 | |
@@ -1639,10 +1720,11 @@ discard block |
||
| 1639 | 1720 | |
| 1640 | 1721 | if (isset($_SESSION['prf-save'])) |
| 1641 | 1722 | { |
| 1642 | - if ($_SESSION['prf-save'] === true) |
|
| 1643 | - $context['saved_successful'] = true; |
|
| 1644 | - else |
|
| 1645 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1723 | + if ($_SESSION['prf-save'] === true) { |
|
| 1724 | + $context['saved_successful'] = true; |
|
| 1725 | + } else { |
|
| 1726 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1727 | + } |
|
| 1646 | 1728 | |
| 1647 | 1729 | unset($_SESSION['prf-save']); |
| 1648 | 1730 | } |
@@ -1658,8 +1740,9 @@ discard block |
||
| 1658 | 1740 | global $context, $txt; |
| 1659 | 1741 | |
| 1660 | 1742 | loadThemeOptions($memID); |
| 1661 | - if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) |
|
| 1662 | - loadCustomFields($memID, 'account'); |
|
| 1743 | + if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) { |
|
| 1744 | + loadCustomFields($memID, 'account'); |
|
| 1745 | + } |
|
| 1663 | 1746 | |
| 1664 | 1747 | $context['sub_template'] = 'edit_options'; |
| 1665 | 1748 | $context['page_desc'] = $txt['account_info']; |
@@ -1686,8 +1769,9 @@ discard block |
||
| 1686 | 1769 | global $context, $txt; |
| 1687 | 1770 | |
| 1688 | 1771 | loadThemeOptions($memID); |
| 1689 | - if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) |
|
| 1690 | - loadCustomFields($memID, 'forumprofile'); |
|
| 1772 | + if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) { |
|
| 1773 | + loadCustomFields($memID, 'forumprofile'); |
|
| 1774 | + } |
|
| 1691 | 1775 | |
| 1692 | 1776 | $context['sub_template'] = 'edit_options'; |
| 1693 | 1777 | $context['page_desc'] = $txt['forumProfile_info']; |
@@ -1720,18 +1804,21 @@ discard block |
||
| 1720 | 1804 | $dirs = array(); |
| 1721 | 1805 | $files = array(); |
| 1722 | 1806 | |
| 1723 | - if (!$dir) |
|
| 1724 | - return array(); |
|
| 1807 | + if (!$dir) { |
|
| 1808 | + return array(); |
|
| 1809 | + } |
|
| 1725 | 1810 | |
| 1726 | 1811 | while ($line = $dir->read()) |
| 1727 | 1812 | { |
| 1728 | - if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) |
|
| 1729 | - continue; |
|
| 1813 | + if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) { |
|
| 1814 | + continue; |
|
| 1815 | + } |
|
| 1730 | 1816 | |
| 1731 | - if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) |
|
| 1732 | - $dirs[] = $line; |
|
| 1733 | - else |
|
| 1734 | - $files[] = $line; |
|
| 1817 | + if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) { |
|
| 1818 | + $dirs[] = $line; |
|
| 1819 | + } else { |
|
| 1820 | + $files[] = $line; |
|
| 1821 | + } |
|
| 1735 | 1822 | } |
| 1736 | 1823 | $dir->close(); |
| 1737 | 1824 | |
@@ -1752,14 +1839,15 @@ discard block |
||
| 1752 | 1839 | foreach ($dirs as $line) |
| 1753 | 1840 | { |
| 1754 | 1841 | $tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1); |
| 1755 | - if (!empty($tmp)) |
|
| 1756 | - $result[] = array( |
|
| 1842 | + if (!empty($tmp)) { |
|
| 1843 | + $result[] = array( |
|
| 1757 | 1844 | 'filename' => $smcFunc['htmlspecialchars']($line), |
| 1758 | 1845 | 'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false, |
| 1759 | 1846 | 'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']', |
| 1760 | 1847 | 'is_dir' => true, |
| 1761 | 1848 | 'files' => $tmp |
| 1762 | 1849 | ); |
| 1850 | + } |
|
| 1763 | 1851 | unset($tmp); |
| 1764 | 1852 | } |
| 1765 | 1853 | |
@@ -1769,8 +1857,9 @@ discard block |
||
| 1769 | 1857 | $extension = substr(strrchr($line, '.'), 1); |
| 1770 | 1858 | |
| 1771 | 1859 | // Make sure it is an image. |
| 1772 | - if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) |
|
| 1773 | - continue; |
|
| 1860 | + if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) { |
|
| 1861 | + continue; |
|
| 1862 | + } |
|
| 1774 | 1863 | |
| 1775 | 1864 | $result[] = array( |
| 1776 | 1865 | 'filename' => $smcFunc['htmlspecialchars']($line), |
@@ -1778,8 +1867,9 @@ discard block |
||
| 1778 | 1867 | 'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)), |
| 1779 | 1868 | 'is_dir' => false |
| 1780 | 1869 | ); |
| 1781 | - if ($level == 1) |
|
| 1782 | - $context['avatar_list'][] = $directory . '/' . $line; |
|
| 1870 | + if ($level == 1) { |
|
| 1871 | + $context['avatar_list'][] = $directory . '/' . $line; |
|
| 1872 | + } |
|
| 1783 | 1873 | } |
| 1784 | 1874 | |
| 1785 | 1875 | return $result; |
@@ -1798,8 +1888,9 @@ discard block |
||
| 1798 | 1888 | loadSubTemplate('options'); |
| 1799 | 1889 | |
| 1800 | 1890 | loadThemeOptions($memID); |
| 1801 | - if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) |
|
| 1802 | - loadCustomFields($memID, 'theme'); |
|
| 1891 | + if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { |
|
| 1892 | + loadCustomFields($memID, 'theme'); |
|
| 1893 | + } |
|
| 1803 | 1894 | |
| 1804 | 1895 | $context['sub_template'] = 'edit_options'; |
| 1805 | 1896 | $context['page_desc'] = $txt['theme_info']; |
@@ -1853,16 +1944,19 @@ discard block |
||
| 1853 | 1944 | { |
| 1854 | 1945 | global $txt, $context, $modSettings, $smcFunc, $sourcedir; |
| 1855 | 1946 | |
| 1856 | - if (!isset($context['token_check'])) |
|
| 1857 | - $context['token_check'] = 'profile-nt' . $memID; |
|
| 1947 | + if (!isset($context['token_check'])) { |
|
| 1948 | + $context['token_check'] = 'profile-nt' . $memID; |
|
| 1949 | + } |
|
| 1858 | 1950 | |
| 1859 | 1951 | is_not_guest(); |
| 1860 | - if (!$context['user']['is_owner']) |
|
| 1861 | - isAllowedTo('profile_extra_any'); |
|
| 1952 | + if (!$context['user']['is_owner']) { |
|
| 1953 | + isAllowedTo('profile_extra_any'); |
|
| 1954 | + } |
|
| 1862 | 1955 | |
| 1863 | 1956 | // Set the post action if we're coming from the profile... |
| 1864 | - if (!isset($context['action'])) |
|
| 1865 | - $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
| 1957 | + if (!isset($context['action'])) { |
|
| 1958 | + $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
| 1959 | + } |
|
| 1866 | 1960 | |
| 1867 | 1961 | // What options are set |
| 1868 | 1962 | loadThemeOptions($memID); |
@@ -1949,28 +2043,34 @@ discard block |
||
| 1949 | 2043 | ); |
| 1950 | 2044 | |
| 1951 | 2045 | // There are certain things that are disabled at the group level. |
| 1952 | - if (empty($modSettings['cal_enabled'])) |
|
| 1953 | - unset($alert_types['calendar']); |
|
| 2046 | + if (empty($modSettings['cal_enabled'])) { |
|
| 2047 | + unset($alert_types['calendar']); |
|
| 2048 | + } |
|
| 1954 | 2049 | |
| 1955 | 2050 | // Disable paid subscriptions at group level if they're disabled |
| 1956 | - if (empty($modSettings['paid_enabled'])) |
|
| 1957 | - unset($alert_types['paidsubs']); |
|
| 2051 | + if (empty($modSettings['paid_enabled'])) { |
|
| 2052 | + unset($alert_types['paidsubs']); |
|
| 2053 | + } |
|
| 1958 | 2054 | |
| 1959 | 2055 | // Disable membergroup requests at group level if they're disabled |
| 1960 | - if (empty($modSettings['show_group_membership'])) |
|
| 1961 | - unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
| 2056 | + if (empty($modSettings['show_group_membership'])) { |
|
| 2057 | + unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
| 2058 | + } |
|
| 1962 | 2059 | |
| 1963 | 2060 | // Disable mentions if they're disabled |
| 1964 | - if (empty($modSettings['enable_mentions'])) |
|
| 1965 | - unset($alert_types['msg']['msg_mention']); |
|
| 2061 | + if (empty($modSettings['enable_mentions'])) { |
|
| 2062 | + unset($alert_types['msg']['msg_mention']); |
|
| 2063 | + } |
|
| 1966 | 2064 | |
| 1967 | 2065 | // Disable likes if they're disabled |
| 1968 | - if (empty($modSettings['enable_likes'])) |
|
| 1969 | - unset($alert_types['msg']['msg_like']); |
|
| 2066 | + if (empty($modSettings['enable_likes'])) { |
|
| 2067 | + unset($alert_types['msg']['msg_like']); |
|
| 2068 | + } |
|
| 1970 | 2069 | |
| 1971 | 2070 | // Disable buddy requests if they're disabled |
| 1972 | - if (empty($modSettings['enable_buddylist'])) |
|
| 1973 | - unset($alert_types['members']['buddy_request']); |
|
| 2071 | + if (empty($modSettings['enable_buddylist'])) { |
|
| 2072 | + unset($alert_types['members']['buddy_request']); |
|
| 2073 | + } |
|
| 1974 | 2074 | |
| 1975 | 2075 | // Now, now, we could pass this through global but we should really get into the habit of |
| 1976 | 2076 | // passing content to hooks, not expecting hooks to splatter everything everywhere. |
@@ -1998,15 +2098,17 @@ discard block |
||
| 1998 | 2098 | $perms_cache['manage_membergroups'] = in_array($memID, $members); |
| 1999 | 2099 | } |
| 2000 | 2100 | |
| 2001 | - if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) |
|
| 2002 | - unset($alert_types['members']['request_group']); |
|
| 2101 | + if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) { |
|
| 2102 | + unset($alert_types['members']['request_group']); |
|
| 2103 | + } |
|
| 2003 | 2104 | |
| 2004 | 2105 | foreach ($alert_types as $group => $items) |
| 2005 | 2106 | { |
| 2006 | 2107 | foreach ($items as $alert_key => $alert_value) |
| 2007 | 2108 | { |
| 2008 | - if (!isset($alert_value['permission'])) |
|
| 2009 | - continue; |
|
| 2109 | + if (!isset($alert_value['permission'])) { |
|
| 2110 | + continue; |
|
| 2111 | + } |
|
| 2010 | 2112 | if (!isset($perms_cache[$alert_value['permission']['name']])) |
| 2011 | 2113 | { |
| 2012 | 2114 | $in_board = !empty($alert_value['permission']['is_board']) ? 0 : null; |
@@ -2014,12 +2116,14 @@ discard block |
||
| 2014 | 2116 | $perms_cache[$alert_value['permission']['name']] = in_array($memID, $members); |
| 2015 | 2117 | } |
| 2016 | 2118 | |
| 2017 | - if (!$perms_cache[$alert_value['permission']['name']]) |
|
| 2018 | - unset ($alert_types[$group][$alert_key]); |
|
| 2119 | + if (!$perms_cache[$alert_value['permission']['name']]) { |
|
| 2120 | + unset ($alert_types[$group][$alert_key]); |
|
| 2121 | + } |
|
| 2019 | 2122 | } |
| 2020 | 2123 | |
| 2021 | - if (empty($alert_types[$group])) |
|
| 2022 | - unset ($alert_types[$group]); |
|
| 2124 | + if (empty($alert_types[$group])) { |
|
| 2125 | + unset ($alert_types[$group]); |
|
| 2126 | + } |
|
| 2023 | 2127 | } |
| 2024 | 2128 | } |
| 2025 | 2129 | |
@@ -2051,9 +2155,9 @@ discard block |
||
| 2051 | 2155 | $update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0; |
| 2052 | 2156 | break; |
| 2053 | 2157 | case 'select': |
| 2054 | - if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) |
|
| 2055 | - $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
| 2056 | - else |
|
| 2158 | + if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) { |
|
| 2159 | + $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
| 2160 | + } else |
|
| 2057 | 2161 | { |
| 2058 | 2162 | // We didn't have a sane value. Let's grab the first item from the possibles. |
| 2059 | 2163 | $keys = array_keys($this_option['opts']); |
@@ -2073,23 +2177,28 @@ discard block |
||
| 2073 | 2177 | $this_value = 0; |
| 2074 | 2178 | foreach ($context['alert_bits'] as $type => $bitvalue) |
| 2075 | 2179 | { |
| 2076 | - if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') |
|
| 2077 | - $this_value |= $bitvalue; |
|
| 2180 | + if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') { |
|
| 2181 | + $this_value |= $bitvalue; |
|
| 2182 | + } |
|
| 2183 | + } |
|
| 2184 | + if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) { |
|
| 2185 | + $update_prefs[$item_key] = $this_value; |
|
| 2078 | 2186 | } |
| 2079 | - if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) |
|
| 2080 | - $update_prefs[$item_key] = $this_value; |
|
| 2081 | 2187 | } |
| 2082 | 2188 | } |
| 2083 | 2189 | |
| 2084 | - if (!empty($_POST['opt_alert_timeout'])) |
|
| 2085 | - $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
| 2190 | + if (!empty($_POST['opt_alert_timeout'])) { |
|
| 2191 | + $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
| 2192 | + } |
|
| 2086 | 2193 | |
| 2087 | - if (!empty($_POST['notify_announcements'])) |
|
| 2088 | - $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
| 2194 | + if (!empty($_POST['notify_announcements'])) { |
|
| 2195 | + $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
| 2196 | + } |
|
| 2089 | 2197 | |
| 2090 | 2198 | setNotifyPrefs((int) $memID, $update_prefs); |
| 2091 | - foreach ($update_prefs as $pref => $value) |
|
| 2092 | - $context['alert_prefs'][$pref] = $value; |
|
| 2199 | + foreach ($update_prefs as $pref => $value) { |
|
| 2200 | + $context['alert_prefs'][$pref] = $value; |
|
| 2201 | + } |
|
| 2093 | 2202 | |
| 2094 | 2203 | makeNotificationChanges($memID); |
| 2095 | 2204 | |
@@ -2119,8 +2228,9 @@ discard block |
||
| 2119 | 2228 | |
| 2120 | 2229 | // Now we're all set up. |
| 2121 | 2230 | is_not_guest(); |
| 2122 | - if (!$context['user']['is_owner']) |
|
| 2123 | - fatal_error('no_access'); |
|
| 2231 | + if (!$context['user']['is_owner']) { |
|
| 2232 | + fatal_error('no_access'); |
|
| 2233 | + } |
|
| 2124 | 2234 | |
| 2125 | 2235 | checkSession('get'); |
| 2126 | 2236 | |
@@ -2152,8 +2262,9 @@ discard block |
||
| 2152 | 2262 | { |
| 2153 | 2263 | global $smcFunc; |
| 2154 | 2264 | |
| 2155 | - if (empty($toMark) || empty($memID)) |
|
| 2156 | - return false; |
|
| 2265 | + if (empty($toMark) || empty($memID)) { |
|
| 2266 | + return false; |
|
| 2267 | + } |
|
| 2157 | 2268 | |
| 2158 | 2269 | $toMark = (array) $toMark; |
| 2159 | 2270 | |
@@ -2187,8 +2298,9 @@ discard block |
||
| 2187 | 2298 | { |
| 2188 | 2299 | global $smcFunc; |
| 2189 | 2300 | |
| 2190 | - if (empty($toDelete)) |
|
| 2191 | - return false; |
|
| 2301 | + if (empty($toDelete)) { |
|
| 2302 | + return false; |
|
| 2303 | + } |
|
| 2192 | 2304 | |
| 2193 | 2305 | $toDelete = (array) $toDelete; |
| 2194 | 2306 | |
@@ -2223,8 +2335,9 @@ discard block |
||
| 2223 | 2335 | { |
| 2224 | 2336 | global $smcFunc; |
| 2225 | 2337 | |
| 2226 | - if (empty($memID)) |
|
| 2227 | - return false; |
|
| 2338 | + if (empty($memID)) { |
|
| 2339 | + return false; |
|
| 2340 | + } |
|
| 2228 | 2341 | |
| 2229 | 2342 | $request = $smcFunc['db_query']('', ' |
| 2230 | 2343 | SELECT id_alert |
@@ -2301,8 +2414,9 @@ discard block |
||
| 2301 | 2414 | { |
| 2302 | 2415 | $link = $topic['link']; |
| 2303 | 2416 | |
| 2304 | - if ($topic['new']) |
|
| 2305 | - $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2417 | + if ($topic['new']) { |
|
| 2418 | + $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2419 | + } |
|
| 2306 | 2420 | |
| 2307 | 2421 | $link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>'; |
| 2308 | 2422 | |
@@ -2453,8 +2567,9 @@ discard block |
||
| 2453 | 2567 | { |
| 2454 | 2568 | $link = $board['link']; |
| 2455 | 2569 | |
| 2456 | - if ($board['new']) |
|
| 2457 | - $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2570 | + if ($board['new']) { |
|
| 2571 | + $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2572 | + } |
|
| 2458 | 2573 | |
| 2459 | 2574 | return $link; |
| 2460 | 2575 | }, |
@@ -2654,8 +2769,8 @@ discard block |
||
| 2654 | 2769 | ) |
| 2655 | 2770 | ); |
| 2656 | 2771 | $notification_boards = array(); |
| 2657 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2658 | - $notification_boards[] = array( |
|
| 2772 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2773 | + $notification_boards[] = array( |
|
| 2659 | 2774 | 'id' => $row['id_board'], |
| 2660 | 2775 | 'name' => $row['name'], |
| 2661 | 2776 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
@@ -2663,6 +2778,7 @@ discard block |
||
| 2663 | 2778 | 'new' => $row['board_read'] < $row['id_msg_updated'], |
| 2664 | 2779 | 'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0), |
| 2665 | 2780 | ); |
| 2781 | + } |
|
| 2666 | 2782 | $smcFunc['db_free_result']($request); |
| 2667 | 2783 | |
| 2668 | 2784 | return $notification_boards; |
@@ -2677,17 +2793,18 @@ discard block |
||
| 2677 | 2793 | { |
| 2678 | 2794 | global $context, $options, $cur_profile, $smcFunc; |
| 2679 | 2795 | |
| 2680 | - if (isset($_POST['default_options'])) |
|
| 2681 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 2796 | + if (isset($_POST['default_options'])) { |
|
| 2797 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 2798 | + } |
|
| 2682 | 2799 | |
| 2683 | 2800 | if ($context['user']['is_owner']) |
| 2684 | 2801 | { |
| 2685 | 2802 | $context['member']['options'] = $options; |
| 2686 | - if (isset($_POST['options']) && is_array($_POST['options'])) |
|
| 2687 | - foreach ($_POST['options'] as $k => $v) |
|
| 2803 | + if (isset($_POST['options']) && is_array($_POST['options'])) { |
|
| 2804 | + foreach ($_POST['options'] as $k => $v) |
|
| 2688 | 2805 | $context['member']['options'][$k] = $v; |
| 2689 | - } |
|
| 2690 | - else |
|
| 2806 | + } |
|
| 2807 | + } else |
|
| 2691 | 2808 | { |
| 2692 | 2809 | $request = $smcFunc['db_query']('', ' |
| 2693 | 2810 | SELECT id_member, variable, value |
@@ -2708,8 +2825,9 @@ discard block |
||
| 2708 | 2825 | continue; |
| 2709 | 2826 | } |
| 2710 | 2827 | |
| 2711 | - if (isset($_POST['options'][$row['variable']])) |
|
| 2712 | - $row['value'] = $_POST['options'][$row['variable']]; |
|
| 2828 | + if (isset($_POST['options'][$row['variable']])) { |
|
| 2829 | + $row['value'] = $_POST['options'][$row['variable']]; |
|
| 2830 | + } |
|
| 2713 | 2831 | $context['member']['options'][$row['variable']] = $row['value']; |
| 2714 | 2832 | } |
| 2715 | 2833 | $smcFunc['db_free_result']($request); |
@@ -2717,8 +2835,9 @@ discard block |
||
| 2717 | 2835 | // Load up the default theme options for any missing. |
| 2718 | 2836 | foreach ($temp as $k => $v) |
| 2719 | 2837 | { |
| 2720 | - if (!isset($context['member']['options'][$k])) |
|
| 2721 | - $context['member']['options'][$k] = $v; |
|
| 2838 | + if (!isset($context['member']['options'][$k])) { |
|
| 2839 | + $context['member']['options'][$k] = $v; |
|
| 2840 | + } |
|
| 2722 | 2841 | } |
| 2723 | 2842 | } |
| 2724 | 2843 | } |
@@ -2733,8 +2852,9 @@ discard block |
||
| 2733 | 2852 | global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir; |
| 2734 | 2853 | |
| 2735 | 2854 | // Have the admins enabled this option? |
| 2736 | - if (empty($modSettings['allow_ignore_boards'])) |
|
| 2737 | - fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
| 2855 | + if (empty($modSettings['allow_ignore_boards'])) { |
|
| 2856 | + fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
| 2857 | + } |
|
| 2738 | 2858 | |
| 2739 | 2859 | // Find all the boards this user is allowed to see. |
| 2740 | 2860 | $request = $smcFunc['db_query']('order_by_board_order', ' |
@@ -2754,12 +2874,13 @@ discard block |
||
| 2754 | 2874 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2755 | 2875 | { |
| 2756 | 2876 | // This category hasn't been set up yet.. |
| 2757 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 2758 | - $context['categories'][$row['id_cat']] = array( |
|
| 2877 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 2878 | + $context['categories'][$row['id_cat']] = array( |
|
| 2759 | 2879 | 'id' => $row['id_cat'], |
| 2760 | 2880 | 'name' => $row['cat_name'], |
| 2761 | 2881 | 'boards' => array() |
| 2762 | 2882 | ); |
| 2883 | + } |
|
| 2763 | 2884 | |
| 2764 | 2885 | // Set this board up, and let the template know when it's a child. (indent them..) |
| 2765 | 2886 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -2789,18 +2910,20 @@ discard block |
||
| 2789 | 2910 | } |
| 2790 | 2911 | |
| 2791 | 2912 | $max_boards = ceil(count($temp_boards) / 2); |
| 2792 | - if ($max_boards == 1) |
|
| 2793 | - $max_boards = 2; |
|
| 2913 | + if ($max_boards == 1) { |
|
| 2914 | + $max_boards = 2; |
|
| 2915 | + } |
|
| 2794 | 2916 | |
| 2795 | 2917 | // Now, alternate them so they can be shown left and right ;). |
| 2796 | 2918 | $context['board_columns'] = array(); |
| 2797 | 2919 | for ($i = 0; $i < $max_boards; $i++) |
| 2798 | 2920 | { |
| 2799 | 2921 | $context['board_columns'][] = $temp_boards[$i]; |
| 2800 | - if (isset($temp_boards[$i + $max_boards])) |
|
| 2801 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 2802 | - else |
|
| 2803 | - $context['board_columns'][] = array(); |
|
| 2922 | + if (isset($temp_boards[$i + $max_boards])) { |
|
| 2923 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 2924 | + } else { |
|
| 2925 | + $context['board_columns'][] = array(); |
|
| 2926 | + } |
|
| 2804 | 2927 | } |
| 2805 | 2928 | |
| 2806 | 2929 | loadThemeOptions($memID); |
@@ -2869,8 +2992,9 @@ discard block |
||
| 2869 | 2992 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2870 | 2993 | { |
| 2871 | 2994 | // We should skip the administrator group if they don't have the admin_forum permission! |
| 2872 | - if ($row['id_group'] == 1 && !allowedTo('admin_forum')) |
|
| 2873 | - continue; |
|
| 2995 | + if ($row['id_group'] == 1 && !allowedTo('admin_forum')) { |
|
| 2996 | + continue; |
|
| 2997 | + } |
|
| 2874 | 2998 | |
| 2875 | 2999 | $context['member_groups'][$row['id_group']] = array( |
| 2876 | 3000 | 'id' => $row['id_group'], |
@@ -2916,16 +3040,17 @@ discard block |
||
| 2916 | 3040 | $context['max_signature_length'] = $context['signature_limits']['max_length']; |
| 2917 | 3041 | // Warning message for signature image limits? |
| 2918 | 3042 | $context['signature_warning'] = ''; |
| 2919 | - if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) |
|
| 2920 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
| 2921 | - elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) |
|
| 2922 | - $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']); |
|
| 3043 | + if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) { |
|
| 3044 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
| 3045 | + } elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) { |
|
| 3046 | + $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']); |
|
| 3047 | + } |
|
| 2923 | 3048 | |
| 2924 | 3049 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
| 2925 | 3050 | |
| 2926 | - if (empty($context['do_preview'])) |
|
| 2927 | - $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
| 2928 | - else |
|
| 3051 | + if (empty($context['do_preview'])) { |
|
| 3052 | + $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
| 3053 | + } else |
|
| 2929 | 3054 | { |
| 2930 | 3055 | $signature = !empty($_POST['signature']) ? $_POST['signature'] : ''; |
| 2931 | 3056 | $validation = profileValidateSignature($signature); |
@@ -2935,8 +3060,9 @@ discard block |
||
| 2935 | 3060 | $context['post_errors'] = array(); |
| 2936 | 3061 | } |
| 2937 | 3062 | $context['post_errors'][] = 'signature_not_yet_saved'; |
| 2938 | - if ($validation !== true && $validation !== false) |
|
| 2939 | - $context['post_errors'][] = $validation; |
|
| 3063 | + if ($validation !== true && $validation !== false) { |
|
| 3064 | + $context['post_errors'][] = $validation; |
|
| 3065 | + } |
|
| 2940 | 3066 | |
| 2941 | 3067 | censorText($context['member']['signature']); |
| 2942 | 3068 | $context['member']['current_signature'] = $context['member']['signature']; |
@@ -2946,8 +3072,9 @@ discard block |
||
| 2946 | 3072 | } |
| 2947 | 3073 | |
| 2948 | 3074 | // Load the spell checker? |
| 2949 | - if ($context['show_spellchecking']) |
|
| 2950 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 3075 | + if ($context['show_spellchecking']) { |
|
| 3076 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 3077 | + } |
|
| 2951 | 3078 | |
| 2952 | 3079 | return true; |
| 2953 | 3080 | } |
@@ -2981,8 +3108,7 @@ discard block |
||
| 2981 | 3108 | 'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11) |
| 2982 | 3109 | ); |
| 2983 | 3110 | $context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']); |
| 2984 | - } |
|
| 2985 | - elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
| 3111 | + } elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
| 2986 | 3112 | { |
| 2987 | 3113 | $context['member']['avatar'] += array( |
| 2988 | 3114 | 'choice' => 'upload', |
@@ -2992,33 +3118,34 @@ discard block |
||
| 2992 | 3118 | $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']; |
| 2993 | 3119 | } |
| 2994 | 3120 | // Use "avatar_original" here so we show what the user entered even if the image proxy is enabled |
| 2995 | - elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) |
|
| 2996 | - $context['member']['avatar'] += array( |
|
| 3121 | + elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) { |
|
| 3122 | + $context['member']['avatar'] += array( |
|
| 2997 | 3123 | 'choice' => 'external', |
| 2998 | 3124 | 'server_pic' => 'blank.png', |
| 2999 | 3125 | 'external' => $cur_profile['avatar_original'] |
| 3000 | 3126 | ); |
| 3001 | - elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) |
|
| 3002 | - $context['member']['avatar'] += array( |
|
| 3127 | + } elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) { |
|
| 3128 | + $context['member']['avatar'] += array( |
|
| 3003 | 3129 | 'choice' => 'server_stored', |
| 3004 | 3130 | 'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'], |
| 3005 | 3131 | 'external' => 'http://' |
| 3006 | 3132 | ); |
| 3007 | - else |
|
| 3008 | - $context['member']['avatar'] += array( |
|
| 3133 | + } else { |
|
| 3134 | + $context['member']['avatar'] += array( |
|
| 3009 | 3135 | 'choice' => 'none', |
| 3010 | 3136 | 'server_pic' => 'blank.png', |
| 3011 | 3137 | 'external' => 'http://' |
| 3012 | 3138 | ); |
| 3139 | + } |
|
| 3013 | 3140 | |
| 3014 | 3141 | // Get a list of all the avatars. |
| 3015 | 3142 | if ($context['member']['avatar']['allow_server_stored']) |
| 3016 | 3143 | { |
| 3017 | 3144 | $context['avatar_list'] = array(); |
| 3018 | 3145 | $context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array(); |
| 3146 | + } else { |
|
| 3147 | + $context['avatars'] = array(); |
|
| 3019 | 3148 | } |
| 3020 | - else |
|
| 3021 | - $context['avatars'] = array(); |
|
| 3022 | 3149 | |
| 3023 | 3150 | // Second level selected avatar... |
| 3024 | 3151 | $context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1); |
@@ -3047,19 +3174,22 @@ discard block |
||
| 3047 | 3174 | ) |
| 3048 | 3175 | ); |
| 3049 | 3176 | $protected_groups = array(1); |
| 3050 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3051 | - $protected_groups[] = $row['id_group']; |
|
| 3177 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3178 | + $protected_groups[] = $row['id_group']; |
|
| 3179 | + } |
|
| 3052 | 3180 | $smcFunc['db_free_result']($request); |
| 3053 | 3181 | |
| 3054 | 3182 | $protected_groups = array_unique($protected_groups); |
| 3055 | 3183 | } |
| 3056 | 3184 | |
| 3057 | 3185 | // The account page allows the change of your id_group - but not to a protected group! |
| 3058 | - if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) |
|
| 3059 | - $value = (int) $value; |
|
| 3186 | + if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) { |
|
| 3187 | + $value = (int) $value; |
|
| 3188 | + } |
|
| 3060 | 3189 | // ... otherwise it's the old group sir. |
| 3061 | - else |
|
| 3062 | - $value = $old_profile['id_group']; |
|
| 3190 | + else { |
|
| 3191 | + $value = $old_profile['id_group']; |
|
| 3192 | + } |
|
| 3063 | 3193 | |
| 3064 | 3194 | // Find the additional membergroups (if any) |
| 3065 | 3195 | if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups'])) |
@@ -3068,16 +3198,18 @@ discard block |
||
| 3068 | 3198 | foreach ($_POST['additional_groups'] as $group_id) |
| 3069 | 3199 | { |
| 3070 | 3200 | $group_id = (int) $group_id; |
| 3071 | - if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) |
|
| 3072 | - $additional_groups[] = $group_id; |
|
| 3201 | + if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) { |
|
| 3202 | + $additional_groups[] = $group_id; |
|
| 3203 | + } |
|
| 3073 | 3204 | } |
| 3074 | 3205 | |
| 3075 | 3206 | // Put the protected groups back in there if you don't have permission to take them away. |
| 3076 | 3207 | $old_additional_groups = explode(',', $old_profile['additional_groups']); |
| 3077 | 3208 | foreach ($old_additional_groups as $group_id) |
| 3078 | 3209 | { |
| 3079 | - if (!empty($protected_groups) && in_array($group_id, $protected_groups)) |
|
| 3080 | - $additional_groups[] = $group_id; |
|
| 3210 | + if (!empty($protected_groups) && in_array($group_id, $protected_groups)) { |
|
| 3211 | + $additional_groups[] = $group_id; |
|
| 3212 | + } |
|
| 3081 | 3213 | } |
| 3082 | 3214 | |
| 3083 | 3215 | if (implode(',', $additional_groups) !== $old_profile['additional_groups']) |
@@ -3109,18 +3241,20 @@ discard block |
||
| 3109 | 3241 | list ($another) = $smcFunc['db_fetch_row']($request); |
| 3110 | 3242 | $smcFunc['db_free_result']($request); |
| 3111 | 3243 | |
| 3112 | - if (empty($another)) |
|
| 3113 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 3244 | + if (empty($another)) { |
|
| 3245 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 3246 | + } |
|
| 3114 | 3247 | } |
| 3115 | 3248 | } |
| 3116 | 3249 | |
| 3117 | 3250 | // If we are changing group status, update permission cache as necessary. |
| 3118 | 3251 | if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups'])) |
| 3119 | 3252 | { |
| 3120 | - if ($context['user']['is_owner']) |
|
| 3121 | - $_SESSION['mc']['time'] = 0; |
|
| 3122 | - else |
|
| 3123 | - updateSettings(array('settings_updated' => time())); |
|
| 3253 | + if ($context['user']['is_owner']) { |
|
| 3254 | + $_SESSION['mc']['time'] = 0; |
|
| 3255 | + } else { |
|
| 3256 | + updateSettings(array('settings_updated' => time())); |
|
| 3257 | + } |
|
| 3124 | 3258 | } |
| 3125 | 3259 | |
| 3126 | 3260 | // Announce to any hooks that we have changed groups, but don't allow them to change it. |
@@ -3141,8 +3275,9 @@ discard block |
||
| 3141 | 3275 | global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context; |
| 3142 | 3276 | |
| 3143 | 3277 | $memID = $context['id_member']; |
| 3144 | - if (empty($memID) && !empty($context['password_auth_failed'])) |
|
| 3145 | - return false; |
|
| 3278 | + if (empty($memID) && !empty($context['password_auth_failed'])) { |
|
| 3279 | + return false; |
|
| 3280 | + } |
|
| 3146 | 3281 | |
| 3147 | 3282 | require_once($sourcedir . '/ManageAttachments.php'); |
| 3148 | 3283 | |
@@ -3153,8 +3288,9 @@ discard block |
||
| 3153 | 3288 | $downloadedExternalAvatar = false; |
| 3154 | 3289 | 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'])) |
| 3155 | 3290 | { |
| 3156 | - if (!is_writable($uploadDir)) |
|
| 3157 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3291 | + if (!is_writable($uploadDir)) { |
|
| 3292 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3293 | + } |
|
| 3158 | 3294 | |
| 3159 | 3295 | require_once($sourcedir . '/Subs-Package.php'); |
| 3160 | 3296 | |
@@ -3198,19 +3334,18 @@ discard block |
||
| 3198 | 3334 | |
| 3199 | 3335 | // Get rid of their old avatar. (if uploaded.) |
| 3200 | 3336 | removeAttachments(array('id_member' => $memID)); |
| 3201 | - } |
|
| 3202 | - elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
| 3337 | + } elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
| 3203 | 3338 | { |
| 3204 | 3339 | // 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. |
| 3205 | - if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) |
|
| 3206 | - $profile_vars['avatar'] = 'gravatar://'; |
|
| 3207 | - else |
|
| 3208 | - $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
| 3340 | + if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) { |
|
| 3341 | + $profile_vars['avatar'] = 'gravatar://'; |
|
| 3342 | + } else { |
|
| 3343 | + $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
| 3344 | + } |
|
| 3209 | 3345 | |
| 3210 | 3346 | // Get rid of their old avatar. (if uploaded.) |
| 3211 | 3347 | removeAttachments(array('id_member' => $memID)); |
| 3212 | - } |
|
| 3213 | - elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
| 3348 | + } elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
| 3214 | 3349 | { |
| 3215 | 3350 | // We need these clean... |
| 3216 | 3351 | $cur_profile['id_attach'] = 0; |
@@ -3222,11 +3357,13 @@ discard block |
||
| 3222 | 3357 | |
| 3223 | 3358 | $profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal'])); |
| 3224 | 3359 | |
| 3225 | - if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') |
|
| 3226 | - $profile_vars['avatar'] = ''; |
|
| 3360 | + if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') { |
|
| 3361 | + $profile_vars['avatar'] = ''; |
|
| 3362 | + } |
|
| 3227 | 3363 | // Trying to make us do something we'll regret? |
| 3228 | - elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') |
|
| 3229 | - return 'bad_avatar_invalid_url'; |
|
| 3364 | + elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') { |
|
| 3365 | + return 'bad_avatar_invalid_url'; |
|
| 3366 | + } |
|
| 3230 | 3367 | // Should we check dimensions? |
| 3231 | 3368 | elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external'])) |
| 3232 | 3369 | { |
@@ -3236,9 +3373,9 @@ discard block |
||
| 3236 | 3373 | 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'])))) |
| 3237 | 3374 | { |
| 3238 | 3375 | // Houston, we have a problem. The avatar is too large!! |
| 3239 | - if ($modSettings['avatar_action_too_large'] == 'option_refuse') |
|
| 3240 | - return 'bad_avatar_too_large'; |
|
| 3241 | - elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
| 3376 | + if ($modSettings['avatar_action_too_large'] == 'option_refuse') { |
|
| 3377 | + return 'bad_avatar_too_large'; |
|
| 3378 | + } elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
| 3242 | 3379 | { |
| 3243 | 3380 | // @todo remove this if appropriate |
| 3244 | 3381 | require_once($sourcedir . '/Subs-Graphics.php'); |
@@ -3248,26 +3385,27 @@ discard block |
||
| 3248 | 3385 | $cur_profile['id_attach'] = $modSettings['new_avatar_data']['id']; |
| 3249 | 3386 | $cur_profile['filename'] = $modSettings['new_avatar_data']['filename']; |
| 3250 | 3387 | $cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type']; |
| 3388 | + } else { |
|
| 3389 | + return 'bad_avatar'; |
|
| 3251 | 3390 | } |
| 3252 | - else |
|
| 3253 | - return 'bad_avatar'; |
|
| 3254 | 3391 | } |
| 3255 | 3392 | } |
| 3256 | 3393 | } |
| 3257 | - } |
|
| 3258 | - elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
| 3394 | + } elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
| 3259 | 3395 | { |
| 3260 | 3396 | if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar) |
| 3261 | 3397 | { |
| 3262 | 3398 | // Get the dimensions of the image. |
| 3263 | 3399 | if (!$downloadedExternalAvatar) |
| 3264 | 3400 | { |
| 3265 | - if (!is_writable($uploadDir)) |
|
| 3266 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3401 | + if (!is_writable($uploadDir)) { |
|
| 3402 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3403 | + } |
|
| 3267 | 3404 | |
| 3268 | 3405 | $new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true); |
| 3269 | - if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) |
|
| 3270 | - fatal_lang_error('attach_timeout', 'critical'); |
|
| 3406 | + if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) { |
|
| 3407 | + fatal_lang_error('attach_timeout', 'critical'); |
|
| 3408 | + } |
|
| 3271 | 3409 | |
| 3272 | 3410 | $_FILES['attachment']['tmp_name'] = $new_filename; |
| 3273 | 3411 | } |
@@ -3380,17 +3518,19 @@ discard block |
||
| 3380 | 3518 | $profile_vars['avatar'] = ''; |
| 3381 | 3519 | |
| 3382 | 3520 | // Delete any temporary file. |
| 3383 | - if (file_exists($_FILES['attachment']['tmp_name'])) |
|
| 3384 | - @unlink($_FILES['attachment']['tmp_name']); |
|
| 3521 | + if (file_exists($_FILES['attachment']['tmp_name'])) { |
|
| 3522 | + @unlink($_FILES['attachment']['tmp_name']); |
|
| 3523 | + } |
|
| 3385 | 3524 | } |
| 3386 | 3525 | // Selected the upload avatar option and had one already uploaded before or didn't upload one. |
| 3387 | - else |
|
| 3526 | + else { |
|
| 3527 | + $profile_vars['avatar'] = ''; |
|
| 3528 | + } |
|
| 3529 | + } elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) { |
|
| 3530 | + $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
| 3531 | + } else { |
|
| 3388 | 3532 | $profile_vars['avatar'] = ''; |
| 3389 | 3533 | } |
| 3390 | - elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) |
|
| 3391 | - $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
| 3392 | - else |
|
| 3393 | - $profile_vars['avatar'] = ''; |
|
| 3394 | 3534 | |
| 3395 | 3535 | // Setup the profile variables so it shows things right on display! |
| 3396 | 3536 | $cur_profile['avatar'] = $profile_vars['avatar']; |
@@ -3438,9 +3578,9 @@ discard block |
||
| 3438 | 3578 | $smiley_parsed = $unparsed_signature; |
| 3439 | 3579 | parsesmileys($smiley_parsed); |
| 3440 | 3580 | $smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img'); |
| 3441 | - if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) |
|
| 3442 | - return 'signature_allow_smileys'; |
|
| 3443 | - elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
| 3581 | + if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) { |
|
| 3582 | + return 'signature_allow_smileys'; |
|
| 3583 | + } elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
| 3444 | 3584 | { |
| 3445 | 3585 | $txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]); |
| 3446 | 3586 | return 'signature_max_smileys'; |
@@ -3453,14 +3593,15 @@ discard block |
||
| 3453 | 3593 | { |
| 3454 | 3594 | $limit_broke = 0; |
| 3455 | 3595 | // Attempt to allow all sizes of abuse, so to speak. |
| 3456 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
| 3457 | - $limit_broke = $sig_limits[7] . 'px'; |
|
| 3458 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
| 3459 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 3460 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
| 3461 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 3462 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
| 3463 | - $limit_broke = 'large'; |
|
| 3596 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
| 3597 | + $limit_broke = $sig_limits[7] . 'px'; |
|
| 3598 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
| 3599 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 3600 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
| 3601 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 3602 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
| 3603 | + $limit_broke = 'large'; |
|
| 3604 | + } |
|
| 3464 | 3605 | |
| 3465 | 3606 | if ($limit_broke) |
| 3466 | 3607 | { |
@@ -3502,24 +3643,26 @@ discard block |
||
| 3502 | 3643 | $width = -1; $height = -1; |
| 3503 | 3644 | |
| 3504 | 3645 | // Does it have predefined restraints? Width first. |
| 3505 | - if ($matches[6][$key]) |
|
| 3506 | - $matches[2][$key] = $matches[6][$key]; |
|
| 3646 | + if ($matches[6][$key]) { |
|
| 3647 | + $matches[2][$key] = $matches[6][$key]; |
|
| 3648 | + } |
|
| 3507 | 3649 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
| 3508 | 3650 | { |
| 3509 | 3651 | $width = $sig_limits[5]; |
| 3510 | 3652 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
| 3653 | + } elseif ($matches[2][$key]) { |
|
| 3654 | + $width = $matches[2][$key]; |
|
| 3511 | 3655 | } |
| 3512 | - elseif ($matches[2][$key]) |
|
| 3513 | - $width = $matches[2][$key]; |
|
| 3514 | 3656 | // ... and height. |
| 3515 | 3657 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
| 3516 | 3658 | { |
| 3517 | 3659 | $height = $sig_limits[6]; |
| 3518 | - if ($width != -1) |
|
| 3519 | - $width = $width * ($height / $matches[4][$key]); |
|
| 3660 | + if ($width != -1) { |
|
| 3661 | + $width = $width * ($height / $matches[4][$key]); |
|
| 3662 | + } |
|
| 3663 | + } elseif ($matches[4][$key]) { |
|
| 3664 | + $height = $matches[4][$key]; |
|
| 3520 | 3665 | } |
| 3521 | - elseif ($matches[4][$key]) |
|
| 3522 | - $height = $matches[4][$key]; |
|
| 3523 | 3666 | |
| 3524 | 3667 | // If the dimensions are still not fixed - we need to check the actual image. |
| 3525 | 3668 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -3537,21 +3680,24 @@ discard block |
||
| 3537 | 3680 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
| 3538 | 3681 | { |
| 3539 | 3682 | $height = $sig_limits[6]; |
| 3540 | - if ($width == -1) |
|
| 3541 | - $width = $sizes[0]; |
|
| 3683 | + if ($width == -1) { |
|
| 3684 | + $width = $sizes[0]; |
|
| 3685 | + } |
|
| 3542 | 3686 | $width = $width * ($height / $sizes[1]); |
| 3687 | + } elseif ($width != -1) { |
|
| 3688 | + $height = $sizes[1]; |
|
| 3543 | 3689 | } |
| 3544 | - elseif ($width != -1) |
|
| 3545 | - $height = $sizes[1]; |
|
| 3546 | 3690 | } |
| 3547 | 3691 | } |
| 3548 | 3692 | |
| 3549 | 3693 | // Did we come up with some changes? If so remake the string. |
| 3550 | - if ($width != -1 || $height != -1) |
|
| 3551 | - $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
| 3694 | + if ($width != -1 || $height != -1) { |
|
| 3695 | + $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
| 3696 | + } |
|
| 3697 | + } |
|
| 3698 | + if (!empty($replaces)) { |
|
| 3699 | + $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
| 3552 | 3700 | } |
| 3553 | - if (!empty($replaces)) |
|
| 3554 | - $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
| 3555 | 3701 | } |
| 3556 | 3702 | } |
| 3557 | 3703 | |
@@ -3595,10 +3741,12 @@ discard block |
||
| 3595 | 3741 | $email = strtr($email, array(''' => '\'')); |
| 3596 | 3742 | |
| 3597 | 3743 | // Check the name and email for validity. |
| 3598 | - if (trim($email) == '') |
|
| 3599 | - return 'no_email'; |
|
| 3600 | - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) |
|
| 3601 | - return 'bad_email'; |
|
| 3744 | + if (trim($email) == '') { |
|
| 3745 | + return 'no_email'; |
|
| 3746 | + } |
|
| 3747 | + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
| 3748 | + return 'bad_email'; |
|
| 3749 | + } |
|
| 3602 | 3750 | |
| 3603 | 3751 | // Email addresses should be and stay unique. |
| 3604 | 3752 | $request = $smcFunc['db_query']('', ' |
@@ -3613,8 +3761,9 @@ discard block |
||
| 3613 | 3761 | ) |
| 3614 | 3762 | ); |
| 3615 | 3763 | |
| 3616 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 3617 | - return 'email_taken'; |
|
| 3764 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 3765 | + return 'email_taken'; |
|
| 3766 | + } |
|
| 3618 | 3767 | $smcFunc['db_free_result']($request); |
| 3619 | 3768 | |
| 3620 | 3769 | return true; |
@@ -3627,8 +3776,9 @@ discard block |
||
| 3627 | 3776 | { |
| 3628 | 3777 | global $modSettings, $context, $cur_profile; |
| 3629 | 3778 | |
| 3630 | - if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') |
|
| 3631 | - setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
| 3779 | + if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') { |
|
| 3780 | + setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
| 3781 | + } |
|
| 3632 | 3782 | |
| 3633 | 3783 | loadUserSettings(); |
| 3634 | 3784 | writeLog(); |
@@ -3644,8 +3794,9 @@ discard block |
||
| 3644 | 3794 | require_once($sourcedir . '/Subs-Post.php'); |
| 3645 | 3795 | |
| 3646 | 3796 | // Shouldn't happen but just in case. |
| 3647 | - if (empty($profile_vars['email_address'])) |
|
| 3648 | - return; |
|
| 3797 | + if (empty($profile_vars['email_address'])) { |
|
| 3798 | + return; |
|
| 3799 | + } |
|
| 3649 | 3800 | |
| 3650 | 3801 | $replacements = array( |
| 3651 | 3802 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'], |
@@ -3668,8 +3819,9 @@ discard block |
||
| 3668 | 3819 | $_SESSION['log_time'] = 0; |
| 3669 | 3820 | $_SESSION['login_' . $cookiename] = json_encode(array(0, '', 0)); |
| 3670 | 3821 | |
| 3671 | - if (isset($_COOKIE[$cookiename])) |
|
| 3672 | - $_COOKIE[$cookiename] = ''; |
|
| 3822 | + if (isset($_COOKIE[$cookiename])) { |
|
| 3823 | + $_COOKIE[$cookiename] = ''; |
|
| 3824 | + } |
|
| 3673 | 3825 | |
| 3674 | 3826 | loadUserSettings(); |
| 3675 | 3827 | |
@@ -3702,11 +3854,13 @@ discard block |
||
| 3702 | 3854 | $groups[] = $curMember['id_group']; |
| 3703 | 3855 | |
| 3704 | 3856 | // Ensure the query doesn't croak! |
| 3705 | - if (empty($groups)) |
|
| 3706 | - $groups = array(0); |
|
| 3857 | + if (empty($groups)) { |
|
| 3858 | + $groups = array(0); |
|
| 3859 | + } |
|
| 3707 | 3860 | // Just to be sure... |
| 3708 | - foreach ($groups as $k => $v) |
|
| 3709 | - $groups[$k] = (int) $v; |
|
| 3861 | + foreach ($groups as $k => $v) { |
|
| 3862 | + $groups[$k] = (int) $v; |
|
| 3863 | + } |
|
| 3710 | 3864 | |
| 3711 | 3865 | // Get all the membergroups they can join. |
| 3712 | 3866 | $request = $smcFunc['db_query']('', ' |
@@ -3736,12 +3890,14 @@ discard block |
||
| 3736 | 3890 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3737 | 3891 | { |
| 3738 | 3892 | // Can they edit their primary group? |
| 3739 | - if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) |
|
| 3740 | - $context['can_edit_primary'] = true; |
|
| 3893 | + if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) { |
|
| 3894 | + $context['can_edit_primary'] = true; |
|
| 3895 | + } |
|
| 3741 | 3896 | |
| 3742 | 3897 | // If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it. |
| 3743 | - if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) |
|
| 3744 | - continue; |
|
| 3898 | + if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) { |
|
| 3899 | + continue; |
|
| 3900 | + } |
|
| 3745 | 3901 | |
| 3746 | 3902 | $context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array( |
| 3747 | 3903 | 'id' => $row['id_group'], |
@@ -3770,13 +3926,15 @@ discard block |
||
| 3770 | 3926 | ); |
| 3771 | 3927 | |
| 3772 | 3928 | // No changing primary one unless you have enough groups! |
| 3773 | - if (count($context['groups']['member']) < 2) |
|
| 3774 | - $context['can_edit_primary'] = false; |
|
| 3929 | + if (count($context['groups']['member']) < 2) { |
|
| 3930 | + $context['can_edit_primary'] = false; |
|
| 3931 | + } |
|
| 3775 | 3932 | |
| 3776 | 3933 | // In the special case that someone is requesting membership of a group, setup some special context vars. |
| 3777 | - if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) |
|
| 3778 | - $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
| 3779 | -} |
|
| 3934 | + if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) { |
|
| 3935 | + $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
| 3936 | + } |
|
| 3937 | + } |
|
| 3780 | 3938 | |
| 3781 | 3939 | /** |
| 3782 | 3940 | * This function actually makes all the group changes |
@@ -3791,10 +3949,12 @@ discard block |
||
| 3791 | 3949 | global $user_info, $context, $user_profile, $modSettings, $smcFunc; |
| 3792 | 3950 | |
| 3793 | 3951 | // Let's be extra cautious... |
| 3794 | - if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) |
|
| 3795 | - isAllowedTo('manage_membergroups'); |
|
| 3796 | - if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) |
|
| 3797 | - fatal_lang_error('no_access', false); |
|
| 3952 | + if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) { |
|
| 3953 | + isAllowedTo('manage_membergroups'); |
|
| 3954 | + } |
|
| 3955 | + if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) { |
|
| 3956 | + fatal_lang_error('no_access', false); |
|
| 3957 | + } |
|
| 3798 | 3958 | |
| 3799 | 3959 | checkSession(isset($_GET['gid']) ? 'get' : 'post'); |
| 3800 | 3960 | |
@@ -3813,8 +3973,9 @@ discard block |
||
| 3813 | 3973 | $foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false; |
| 3814 | 3974 | |
| 3815 | 3975 | // Sanity check!! |
| 3816 | - if ($group_id == 1) |
|
| 3817 | - isAllowedTo('admin_forum'); |
|
| 3976 | + if ($group_id == 1) { |
|
| 3977 | + isAllowedTo('admin_forum'); |
|
| 3978 | + } |
|
| 3818 | 3979 | // Protected groups too! |
| 3819 | 3980 | else |
| 3820 | 3981 | { |
@@ -3831,8 +3992,9 @@ discard block |
||
| 3831 | 3992 | list ($is_protected) = $smcFunc['db_fetch_row']($request); |
| 3832 | 3993 | $smcFunc['db_free_result']($request); |
| 3833 | 3994 | |
| 3834 | - if ($is_protected == 1) |
|
| 3835 | - isAllowedTo('admin_forum'); |
|
| 3995 | + if ($is_protected == 1) { |
|
| 3996 | + isAllowedTo('admin_forum'); |
|
| 3997 | + } |
|
| 3836 | 3998 | } |
| 3837 | 3999 | |
| 3838 | 4000 | // What ever we are doing, we need to determine if changing primary is possible! |
@@ -3854,36 +4016,43 @@ discard block |
||
| 3854 | 4016 | $group_name = $row['group_name']; |
| 3855 | 4017 | |
| 3856 | 4018 | // Does the group type match what we're doing - are we trying to request a non-requestable group? |
| 3857 | - if ($changeType == 'request' && $row['group_type'] != 2) |
|
| 3858 | - fatal_lang_error('no_access', false); |
|
| 4019 | + if ($changeType == 'request' && $row['group_type'] != 2) { |
|
| 4020 | + fatal_lang_error('no_access', false); |
|
| 4021 | + } |
|
| 3859 | 4022 | // What about leaving a requestable group we are not a member of? |
| 3860 | - elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) |
|
| 3861 | - fatal_lang_error('no_access', false); |
|
| 3862 | - elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) |
|
| 3863 | - fatal_lang_error('no_access', false); |
|
| 4023 | + elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) { |
|
| 4024 | + fatal_lang_error('no_access', false); |
|
| 4025 | + } elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) { |
|
| 4026 | + fatal_lang_error('no_access', false); |
|
| 4027 | + } |
|
| 3864 | 4028 | |
| 3865 | 4029 | // We can't change the primary group if this is hidden! |
| 3866 | - if ($row['hidden'] == 2) |
|
| 3867 | - $canChangePrimary = false; |
|
| 4030 | + if ($row['hidden'] == 2) { |
|
| 4031 | + $canChangePrimary = false; |
|
| 4032 | + } |
|
| 3868 | 4033 | } |
| 3869 | 4034 | |
| 3870 | 4035 | // If this is their old primary, can we change it? |
| 3871 | - if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) |
|
| 3872 | - $canChangePrimary = 1; |
|
| 4036 | + if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) { |
|
| 4037 | + $canChangePrimary = 1; |
|
| 4038 | + } |
|
| 3873 | 4039 | |
| 3874 | 4040 | // If we are not doing a force primary move, don't do it automatically if current primary is not 0. |
| 3875 | - if ($changeType != 'primary' && $old_profile['id_group'] != 0) |
|
| 3876 | - $canChangePrimary = false; |
|
| 4041 | + if ($changeType != 'primary' && $old_profile['id_group'] != 0) { |
|
| 4042 | + $canChangePrimary = false; |
|
| 4043 | + } |
|
| 3877 | 4044 | |
| 3878 | 4045 | // If this is the one we are acting on, can we even act? |
| 3879 | - if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) |
|
| 3880 | - $canChangePrimary = false; |
|
| 4046 | + if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) { |
|
| 4047 | + $canChangePrimary = false; |
|
| 4048 | + } |
|
| 3881 | 4049 | } |
| 3882 | 4050 | $smcFunc['db_free_result']($request); |
| 3883 | 4051 | |
| 3884 | 4052 | // Didn't find the target? |
| 3885 | - if (!$foundTarget) |
|
| 3886 | - fatal_lang_error('no_access', false); |
|
| 4053 | + if (!$foundTarget) { |
|
| 4054 | + fatal_lang_error('no_access', false); |
|
| 4055 | + } |
|
| 3887 | 4056 | |
| 3888 | 4057 | // Final security check, don't allow users to promote themselves to admin. |
| 3889 | 4058 | if ($context['can_manage_membergroups'] && !allowedTo('admin_forum')) |
@@ -3903,8 +4072,9 @@ discard block |
||
| 3903 | 4072 | list ($disallow) = $smcFunc['db_fetch_row']($request); |
| 3904 | 4073 | $smcFunc['db_free_result']($request); |
| 3905 | 4074 | |
| 3906 | - if ($disallow) |
|
| 3907 | - isAllowedTo('admin_forum'); |
|
| 4075 | + if ($disallow) { |
|
| 4076 | + isAllowedTo('admin_forum'); |
|
| 4077 | + } |
|
| 3908 | 4078 | } |
| 3909 | 4079 | |
| 3910 | 4080 | // If we're requesting, add the note then return. |
@@ -3922,8 +4092,9 @@ discard block |
||
| 3922 | 4092 | 'status_open' => 0, |
| 3923 | 4093 | ) |
| 3924 | 4094 | ); |
| 3925 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 3926 | - fatal_lang_error('profile_error_already_requested_group'); |
|
| 4095 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 4096 | + fatal_lang_error('profile_error_already_requested_group'); |
|
| 4097 | + } |
|
| 3927 | 4098 | $smcFunc['db_free_result']($request); |
| 3928 | 4099 | |
| 3929 | 4100 | // Log the request. |
@@ -3957,10 +4128,11 @@ discard block |
||
| 3957 | 4128 | // Are we leaving? |
| 3958 | 4129 | if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id])) |
| 3959 | 4130 | { |
| 3960 | - if ($old_profile['id_group'] == $group_id) |
|
| 3961 | - $newPrimary = 0; |
|
| 3962 | - else |
|
| 3963 | - unset($addGroups[$group_id]); |
|
| 4131 | + if ($old_profile['id_group'] == $group_id) { |
|
| 4132 | + $newPrimary = 0; |
|
| 4133 | + } else { |
|
| 4134 | + unset($addGroups[$group_id]); |
|
| 4135 | + } |
|
| 3964 | 4136 | } |
| 3965 | 4137 | // ... if not, must be joining. |
| 3966 | 4138 | else |
@@ -3968,36 +4140,42 @@ discard block |
||
| 3968 | 4140 | // Can we change the primary, and do we want to? |
| 3969 | 4141 | if ($canChangePrimary) |
| 3970 | 4142 | { |
| 3971 | - if ($old_profile['id_group'] != 0) |
|
| 3972 | - $addGroups[$old_profile['id_group']] = -1; |
|
| 4143 | + if ($old_profile['id_group'] != 0) { |
|
| 4144 | + $addGroups[$old_profile['id_group']] = -1; |
|
| 4145 | + } |
|
| 3973 | 4146 | $newPrimary = $group_id; |
| 3974 | 4147 | } |
| 3975 | 4148 | // Otherwise it's an additional group... |
| 3976 | - else |
|
| 3977 | - $addGroups[$group_id] = -1; |
|
| 4149 | + else { |
|
| 4150 | + $addGroups[$group_id] = -1; |
|
| 4151 | + } |
|
| 3978 | 4152 | } |
| 3979 | 4153 | } |
| 3980 | 4154 | // Finally, we must be setting the primary. |
| 3981 | 4155 | elseif ($canChangePrimary) |
| 3982 | 4156 | { |
| 3983 | - if ($old_profile['id_group'] != 0) |
|
| 3984 | - $addGroups[$old_profile['id_group']] = -1; |
|
| 3985 | - if (isset($addGroups[$group_id])) |
|
| 3986 | - unset($addGroups[$group_id]); |
|
| 4157 | + if ($old_profile['id_group'] != 0) { |
|
| 4158 | + $addGroups[$old_profile['id_group']] = -1; |
|
| 4159 | + } |
|
| 4160 | + if (isset($addGroups[$group_id])) { |
|
| 4161 | + unset($addGroups[$group_id]); |
|
| 4162 | + } |
|
| 3987 | 4163 | $newPrimary = $group_id; |
| 3988 | 4164 | } |
| 3989 | 4165 | |
| 3990 | 4166 | // Finally, we can make the changes! |
| 3991 | - foreach ($addGroups as $id => $dummy) |
|
| 3992 | - if (empty($id)) |
|
| 4167 | + foreach ($addGroups as $id => $dummy) { |
|
| 4168 | + if (empty($id)) |
|
| 3993 | 4169 | unset($addGroups[$id]); |
| 4170 | + } |
|
| 3994 | 4171 | $addGroups = implode(',', array_flip($addGroups)); |
| 3995 | 4172 | |
| 3996 | 4173 | // Ensure that we don't cache permissions if the group is changing. |
| 3997 | - if ($context['user']['is_owner']) |
|
| 3998 | - $_SESSION['mc']['time'] = 0; |
|
| 3999 | - else |
|
| 4000 | - updateSettings(array('settings_updated' => time())); |
|
| 4174 | + if ($context['user']['is_owner']) { |
|
| 4175 | + $_SESSION['mc']['time'] = 0; |
|
| 4176 | + } else { |
|
| 4177 | + updateSettings(array('settings_updated' => time())); |
|
| 4178 | + } |
|
| 4001 | 4179 | |
| 4002 | 4180 | updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups)); |
| 4003 | 4181 | |
@@ -4020,8 +4198,9 @@ discard block |
||
| 4020 | 4198 | if (empty($user_settings['tfa_secret']) && $context['user']['is_owner']) |
| 4021 | 4199 | { |
| 4022 | 4200 | // Check to ensure we're forcing SSL for authentication |
| 4023 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 4024 | - fatal_lang_error('login_ssl_required'); |
|
| 4201 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 4202 | + fatal_lang_error('login_ssl_required'); |
|
| 4203 | + } |
|
| 4025 | 4204 | |
| 4026 | 4205 | // In some cases (forced 2FA or backup code) they would be forced to be redirected here, |
| 4027 | 4206 | // we do not want too much AJAX to confuse them. |
@@ -4058,8 +4237,7 @@ discard block |
||
| 4058 | 4237 | $context['sub_template'] = 'tfasetup_backup'; |
| 4059 | 4238 | |
| 4060 | 4239 | return; |
| 4061 | - } |
|
| 4062 | - else |
|
| 4240 | + } else |
|
| 4063 | 4241 | { |
| 4064 | 4242 | $context['tfa_secret'] = $_SESSION['tfa_secret']; |
| 4065 | 4243 | $context['tfa_error'] = !$valid_code; |
@@ -4067,8 +4245,7 @@ discard block |
||
| 4067 | 4245 | $context['tfa_pass_value'] = $_POST['passwd']; |
| 4068 | 4246 | $context['tfa_value'] = $_POST['tfa_code']; |
| 4069 | 4247 | } |
| 4070 | - } |
|
| 4071 | - else |
|
| 4248 | + } else |
|
| 4072 | 4249 | { |
| 4073 | 4250 | $totp = new \TOTP\Auth(); |
| 4074 | 4251 | $secret = $totp->generateCode(); |
@@ -4078,17 +4255,16 @@ discard block |
||
| 4078 | 4255 | } |
| 4079 | 4256 | |
| 4080 | 4257 | $context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']); |
| 4081 | - } |
|
| 4082 | - elseif (isset($_REQUEST['disable'])) |
|
| 4258 | + } elseif (isset($_REQUEST['disable'])) |
|
| 4083 | 4259 | { |
| 4084 | 4260 | updateMemberData($memID, array( |
| 4085 | 4261 | 'tfa_secret' => '', |
| 4086 | 4262 | 'tfa_backup' => '', |
| 4087 | 4263 | )); |
| 4088 | 4264 | redirectexit('action=profile;area=account;u=' . $memID); |
| 4265 | + } else { |
|
| 4266 | + redirectexit('action=profile;area=account;u=' . $memID); |
|
| 4267 | + } |
|
| 4089 | 4268 | } |
| 4090 | - else |
|
| 4091 | - redirectexit('action=profile;area=account;u=' . $memID); |
|
| 4092 | -} |
|
| 4093 | 4269 | |
| 4094 | 4270 | ?> |
| 4095 | 4271 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 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 | * Finds or repairs errors in the database to fix possible problems. |
@@ -50,8 +51,9 @@ discard block |
||
| 50 | 51 | ); |
| 51 | 52 | |
| 52 | 53 | // Start displaying errors without fixing them. |
| 53 | - if (isset($_GET['fixErrors'])) |
|
| 54 | - checkSession('get'); |
|
| 54 | + if (isset($_GET['fixErrors'])) { |
|
| 55 | + checkSession('get'); |
|
| 56 | + } |
|
| 55 | 57 | |
| 56 | 58 | // Will want this. |
| 57 | 59 | loadForumTests(); |
@@ -69,11 +71,11 @@ discard block |
||
| 69 | 71 | $_SESSION['repairboards_to_fix'] = $context['to_fix']; |
| 70 | 72 | $_SESSION['repairboards_to_fix2'] = null; |
| 71 | 73 | |
| 72 | - if (empty($context['repair_errors'])) |
|
| 73 | - $context['repair_errors'][] = '???'; |
|
| 74 | + if (empty($context['repair_errors'])) { |
|
| 75 | + $context['repair_errors'][] = '???'; |
|
| 76 | + } |
|
| 74 | 77 | } |
| 75 | - } |
|
| 76 | - else |
|
| 78 | + } else |
|
| 77 | 79 | { |
| 78 | 80 | $context['error_search'] = false; |
| 79 | 81 | $context['to_fix'] = isset($_SESSION['repairboards_to_fix']) ? $_SESSION['repairboards_to_fix'] : array(); |
@@ -120,16 +122,19 @@ discard block |
||
| 120 | 122 | |
| 121 | 123 | // More time, I need more time! |
| 122 | 124 | @set_time_limit(600); |
| 123 | - if (function_exists('apache_reset_timeout')) |
|
| 124 | - @apache_reset_timeout(); |
|
| 125 | + if (function_exists('apache_reset_timeout')) { |
|
| 126 | + @apache_reset_timeout(); |
|
| 127 | + } |
|
| 125 | 128 | |
| 126 | 129 | // Errr, wait. How much time has this taken already? |
| 127 | - if (!$force && time() - array_sum(explode(' ', $time_start)) < 3) |
|
| 128 | - return; |
|
| 130 | + if (!$force && time() - array_sum(explode(' ', $time_start)) < 3) { |
|
| 131 | + return; |
|
| 132 | + } |
|
| 129 | 133 | |
| 130 | 134 | // Restore the query cache if interested. |
| 131 | - if (!empty($db_temp_cache)) |
|
| 132 | - $db_cache = $db_temp_cache; |
|
| 135 | + if (!empty($db_temp_cache)) { |
|
| 136 | + $db_cache = $db_temp_cache; |
|
| 137 | + } |
|
| 133 | 138 | |
| 134 | 139 | $context['continue_get_data'] = '?action=admin;area=repairboards' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 135 | 140 | $context['page_title'] = $txt['not_done_title']; |
@@ -138,10 +143,11 @@ discard block |
||
| 138 | 143 | $context['sub_template'] = 'not_done'; |
| 139 | 144 | |
| 140 | 145 | // Change these two if more steps are added! |
| 141 | - if (empty($max_substep)) |
|
| 142 | - $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
| 143 | - else |
|
| 144 | - $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
| 146 | + if (empty($max_substep)) { |
|
| 147 | + $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
| 148 | + } else { |
|
| 149 | + $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
| 150 | + } |
|
| 145 | 151 | |
| 146 | 152 | // Never more than 100%! |
| 147 | 153 | $context['continue_percent'] = min($context['continue_percent'], 100); |
@@ -612,8 +618,9 @@ discard block |
||
| 612 | 618 | $row['myid_last_msg'] = (int) $row['myid_last_msg']; |
| 613 | 619 | |
| 614 | 620 | // Not really a problem? |
| 615 | - if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
| 616 | - return false; |
|
| 621 | + if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
| 622 | + return false; |
|
| 623 | + } |
|
| 617 | 624 | |
| 618 | 625 | $memberStartedID = (int) getMsgMemberID($row['myid_first_msg']); |
| 619 | 626 | $memberUpdatedID = (int) getMsgMemberID($row['myid_last_msg']); |
@@ -637,15 +644,19 @@ discard block |
||
| 637 | 644 | 'message_function' => function ($row) use ($txt, &$context) |
| 638 | 645 | { |
| 639 | 646 | // A pretend error? |
| 640 | - if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
| 641 | - return false; |
|
| 647 | + if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
| 648 | + return false; |
|
| 649 | + } |
|
| 642 | 650 | |
| 643 | - if ($row['id_first_msg'] != $row['myid_first_msg']) |
|
| 644 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
| 645 | - if ($row['id_last_msg'] != $row['myid_last_msg']) |
|
| 646 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
| 647 | - if ($row['approved'] != $row['firstmsg_approved']) |
|
| 648 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
| 651 | + if ($row['id_first_msg'] != $row['myid_first_msg']) { |
|
| 652 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
| 653 | + } |
|
| 654 | + if ($row['id_last_msg'] != $row['myid_last_msg']) { |
|
| 655 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
| 656 | + } |
|
| 657 | + if ($row['approved'] != $row['firstmsg_approved']) { |
|
| 658 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
| 659 | + } |
|
| 649 | 660 | |
| 650 | 661 | return true; |
| 651 | 662 | }, |
@@ -675,8 +686,9 @@ discard block |
||
| 675 | 686 | $row['my_num_replies'] = (int) $row['my_num_replies']; |
| 676 | 687 | |
| 677 | 688 | // Not really a problem? |
| 678 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
| 679 | - return false; |
|
| 689 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
| 690 | + return false; |
|
| 691 | + } |
|
| 680 | 692 | |
| 681 | 693 | $smcFunc['db_query']('', ' |
| 682 | 694 | UPDATE {db_prefix}topics |
@@ -695,11 +707,13 @@ discard block |
||
| 695 | 707 | global $txt, $context; |
| 696 | 708 | |
| 697 | 709 | // Just joking? |
| 698 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
| 699 | - return false; |
|
| 710 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
| 711 | + return false; |
|
| 712 | + } |
|
| 700 | 713 | |
| 701 | - if ($row['num_replies'] != $row['my_num_replies']) |
|
| 702 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
| 714 | + if ($row['num_replies'] != $row['my_num_replies']) { |
|
| 715 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
| 716 | + } |
|
| 703 | 717 | |
| 704 | 718 | return true; |
| 705 | 719 | |
@@ -1290,8 +1304,9 @@ discard block |
||
| 1290 | 1304 | $inserts = array(); |
| 1291 | 1305 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1292 | 1306 | { |
| 1293 | - foreach (text2words($row['subject']) as $word) |
|
| 1294 | - $inserts[] = array($word, $row['id_topic']); |
|
| 1307 | + foreach (text2words($row['subject']) as $word) { |
|
| 1308 | + $inserts[] = array($word, $row['id_topic']); |
|
| 1309 | + } |
|
| 1295 | 1310 | if (count($inserts) > 500) |
| 1296 | 1311 | { |
| 1297 | 1312 | $smcFunc['db_insert']('ignore', |
@@ -1305,13 +1320,14 @@ discard block |
||
| 1305 | 1320 | |
| 1306 | 1321 | } |
| 1307 | 1322 | |
| 1308 | - if (!empty($inserts)) |
|
| 1309 | - $smcFunc['db_insert']('ignore', |
|
| 1323 | + if (!empty($inserts)) { |
|
| 1324 | + $smcFunc['db_insert']('ignore', |
|
| 1310 | 1325 | '{db_prefix}log_search_subjects', |
| 1311 | 1326 | array('word' => 'string', 'id_topic' => 'int'), |
| 1312 | 1327 | $inserts, |
| 1313 | 1328 | array('word', 'id_topic') |
| 1314 | 1329 | ); |
| 1330 | + } |
|
| 1315 | 1331 | |
| 1316 | 1332 | }, |
| 1317 | 1333 | 'message_function' => function ($row) |
@@ -1581,8 +1597,9 @@ discard block |
||
| 1581 | 1597 | $current_step++; |
| 1582 | 1598 | |
| 1583 | 1599 | // Already done this? |
| 1584 | - if ($_GET['step'] > $current_step) |
|
| 1585 | - continue; |
|
| 1600 | + if ($_GET['step'] > $current_step) { |
|
| 1601 | + continue; |
|
| 1602 | + } |
|
| 1586 | 1603 | |
| 1587 | 1604 | // If we're fixing it but it ain't broke why try? |
| 1588 | 1605 | if ($do_fix && !in_array($error_type, $to_fix)) |
@@ -1611,14 +1628,16 @@ discard block |
||
| 1611 | 1628 | while (!$done) |
| 1612 | 1629 | { |
| 1613 | 1630 | // Make sure there's at least one ID to test. |
| 1614 | - if (isset($test['substeps']) && empty($step_max)) |
|
| 1615 | - break; |
|
| 1631 | + if (isset($test['substeps']) && empty($step_max)) { |
|
| 1632 | + break; |
|
| 1633 | + } |
|
| 1616 | 1634 | |
| 1617 | 1635 | // What is the testing query (Changes if we are testing or fixing) |
| 1618 | - if (!$do_fix) |
|
| 1619 | - $test_query = 'check_query'; |
|
| 1620 | - else |
|
| 1621 | - $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
| 1636 | + if (!$do_fix) { |
|
| 1637 | + $test_query = 'check_query'; |
|
| 1638 | + } else { |
|
| 1639 | + $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
| 1640 | + } |
|
| 1622 | 1641 | |
| 1623 | 1642 | // Do the test... |
| 1624 | 1643 | $request = $smcFunc['db_query']('', |
@@ -1628,10 +1647,11 @@ discard block |
||
| 1628 | 1647 | ); |
| 1629 | 1648 | |
| 1630 | 1649 | // Does it need a fix? |
| 1631 | - if (!empty($test['check_type']) && $test['check_type'] == 'count') |
|
| 1632 | - list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
| 1633 | - else |
|
| 1634 | - $needs_fix = $smcFunc['db_num_rows']($request); |
|
| 1650 | + if (!empty($test['check_type']) && $test['check_type'] == 'count') { |
|
| 1651 | + list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
| 1652 | + } else { |
|
| 1653 | + $needs_fix = $smcFunc['db_num_rows']($request); |
|
| 1654 | + } |
|
| 1635 | 1655 | |
| 1636 | 1656 | $total_queries++; |
| 1637 | 1657 | |
@@ -1643,8 +1663,9 @@ discard block |
||
| 1643 | 1663 | // Assume need to fix. |
| 1644 | 1664 | $found_errors = true; |
| 1645 | 1665 | |
| 1646 | - if (isset($test['message'])) |
|
| 1647 | - $context['repair_errors'][] = $txt[$test['message']]; |
|
| 1666 | + if (isset($test['message'])) { |
|
| 1667 | + $context['repair_errors'][] = $txt[$test['message']]; |
|
| 1668 | + } |
|
| 1648 | 1669 | |
| 1649 | 1670 | // One per row! |
| 1650 | 1671 | elseif (isset($test['messages'])) |
@@ -1654,10 +1675,11 @@ discard block |
||
| 1654 | 1675 | $variables = $test['messages']; |
| 1655 | 1676 | foreach ($variables as $k => $v) |
| 1656 | 1677 | { |
| 1657 | - if ($k == 0 && isset($txt[$v])) |
|
| 1658 | - $variables[$k] = $txt[$v]; |
|
| 1659 | - elseif ($k > 0 && isset($row[$v])) |
|
| 1660 | - $variables[$k] = $row[$v]; |
|
| 1678 | + if ($k == 0 && isset($txt[$v])) { |
|
| 1679 | + $variables[$k] = $txt[$v]; |
|
| 1680 | + } elseif ($k > 0 && isset($row[$v])) { |
|
| 1681 | + $variables[$k] = $row[$v]; |
|
| 1682 | + } |
|
| 1661 | 1683 | } |
| 1662 | 1684 | $context['repair_errors'][] = call_user_func_array('sprintf', $variables); |
| 1663 | 1685 | } |
@@ -1668,13 +1690,15 @@ discard block |
||
| 1668 | 1690 | { |
| 1669 | 1691 | // Find out if there are actually errors. |
| 1670 | 1692 | $found_errors = false; |
| 1671 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1672 | - $found_errors |= $test['message_function']($row); |
|
| 1693 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1694 | + $found_errors |= $test['message_function']($row); |
|
| 1695 | + } |
|
| 1673 | 1696 | } |
| 1674 | 1697 | |
| 1675 | 1698 | // Actually have something to fix? |
| 1676 | - if ($found_errors) |
|
| 1677 | - $to_fix[] = $error_type; |
|
| 1699 | + if ($found_errors) { |
|
| 1700 | + $to_fix[] = $error_type; |
|
| 1701 | + } |
|
| 1678 | 1702 | } |
| 1679 | 1703 | |
| 1680 | 1704 | // We want to fix, we need to fix - so work out what exactly to do! |
@@ -1684,8 +1708,9 @@ discard block |
||
| 1684 | 1708 | if (isset($test['fix_collect'])) |
| 1685 | 1709 | { |
| 1686 | 1710 | $ids = array(); |
| 1687 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1688 | - $ids[] = $row[$test['fix_collect']['index']]; |
|
| 1711 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1712 | + $ids[] = $row[$test['fix_collect']['index']]; |
|
| 1713 | + } |
|
| 1689 | 1714 | if (!empty($ids)) |
| 1690 | 1715 | { |
| 1691 | 1716 | // Fix it! |
@@ -1694,30 +1719,34 @@ discard block |
||
| 1694 | 1719 | } |
| 1695 | 1720 | |
| 1696 | 1721 | // Simply executing a fix it query? |
| 1697 | - elseif (isset($test['fix_it_query'])) |
|
| 1698 | - $smcFunc['db_query']('', |
|
| 1722 | + elseif (isset($test['fix_it_query'])) { |
|
| 1723 | + $smcFunc['db_query']('', |
|
| 1699 | 1724 | $test['fix_it_query'], |
| 1700 | 1725 | array( |
| 1701 | 1726 | ) |
| 1702 | 1727 | ); |
| 1728 | + } |
|
| 1703 | 1729 | |
| 1704 | 1730 | // Do we have some processing to do? |
| 1705 | 1731 | elseif (isset($test['fix_processing'])) |
| 1706 | 1732 | { |
| 1707 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1708 | - $test['fix_processing']($row); |
|
| 1733 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1734 | + $test['fix_processing']($row); |
|
| 1735 | + } |
|
| 1709 | 1736 | } |
| 1710 | 1737 | |
| 1711 | 1738 | // What about the full set of processing? |
| 1712 | - elseif (isset($test['fix_full_processing'])) |
|
| 1713 | - $test['fix_full_processing']($request); |
|
| 1739 | + elseif (isset($test['fix_full_processing'])) { |
|
| 1740 | + $test['fix_full_processing']($request); |
|
| 1741 | + } |
|
| 1714 | 1742 | |
| 1715 | 1743 | // Do we have other things we need to fix as a result? |
| 1716 | 1744 | if (!empty($test['force_fix'])) |
| 1717 | 1745 | { |
| 1718 | - foreach ($test['force_fix'] as $item) |
|
| 1719 | - if (!in_array($item, $to_fix)) |
|
| 1746 | + foreach ($test['force_fix'] as $item) { |
|
| 1747 | + if (!in_array($item, $to_fix)) |
|
| 1720 | 1748 | $to_fix[] = $item; |
| 1749 | + } |
|
| 1721 | 1750 | } |
| 1722 | 1751 | } |
| 1723 | 1752 | } |
@@ -1735,16 +1764,17 @@ discard block |
||
| 1735 | 1764 | if ($_GET['substep'] <= $step_max) |
| 1736 | 1765 | { |
| 1737 | 1766 | pauseRepairProcess($to_fix, $error_type, $step_max); |
| 1767 | + } else { |
|
| 1768 | + $done = true; |
|
| 1738 | 1769 | } |
| 1739 | - else |
|
| 1740 | - $done = true; |
|
| 1770 | + } else { |
|
| 1771 | + $done = true; |
|
| 1741 | 1772 | } |
| 1742 | - else |
|
| 1743 | - $done = true; |
|
| 1744 | 1773 | |
| 1745 | 1774 | // Don't allow more than 1000 queries at a time. |
| 1746 | - if ($total_queries >= 1000) |
|
| 1747 | - pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
| 1775 | + if ($total_queries >= 1000) { |
|
| 1776 | + pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
| 1777 | + } |
|
| 1748 | 1778 | } |
| 1749 | 1779 | |
| 1750 | 1780 | // Keep going. |
@@ -1757,8 +1787,9 @@ discard block |
||
| 1757 | 1787 | if ($do_fix) |
| 1758 | 1788 | { |
| 1759 | 1789 | $key = array_search($error_type, $to_fix); |
| 1760 | - if ($key !== false && isset($to_fix[$key])) |
|
| 1761 | - unset($to_fix[$key]); |
|
| 1790 | + if ($key !== false && isset($to_fix[$key])) { |
|
| 1791 | + unset($to_fix[$key]); |
|
| 1792 | + } |
|
| 1762 | 1793 | } |
| 1763 | 1794 | |
| 1764 | 1795 | // Are we done? |
@@ -1781,10 +1812,11 @@ discard block |
||
| 1781 | 1812 | static $createOnce = false; |
| 1782 | 1813 | |
| 1783 | 1814 | // Have we already created it? |
| 1784 | - if ($createOnce) |
|
| 1785 | - return; |
|
| 1786 | - else |
|
| 1787 | - $createOnce = true; |
|
| 1815 | + if ($createOnce) { |
|
| 1816 | + return; |
|
| 1817 | + } else { |
|
| 1818 | + $createOnce = true; |
|
| 1819 | + } |
|
| 1788 | 1820 | |
| 1789 | 1821 | // Back to the forum's default language. |
| 1790 | 1822 | loadLanguage('Admin', $language); |
@@ -1799,8 +1831,9 @@ discard block |
||
| 1799 | 1831 | 'cat_name' => $txt['salvaged_category_name'], |
| 1800 | 1832 | ) |
| 1801 | 1833 | ); |
| 1802 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1803 | - list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
| 1834 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1835 | + list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
| 1836 | + } |
|
| 1804 | 1837 | $smcFunc['db_free_result']($result); |
| 1805 | 1838 | |
| 1806 | 1839 | if (empty($salvageCatID)) |
@@ -1832,8 +1865,9 @@ discard block |
||
| 1832 | 1865 | 'board_name' => $txt['salvaged_board_name'], |
| 1833 | 1866 | ) |
| 1834 | 1867 | ); |
| 1835 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1836 | - list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
| 1868 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1869 | + list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
| 1870 | + } |
|
| 1837 | 1871 | $smcFunc['db_free_result']($result); |
| 1838 | 1872 | |
| 1839 | 1873 | if (empty($salvageBoardID)) |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 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,27 +48,35 @@ 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 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
| 66 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 73 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
| 74 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 75 | + } |
|
| 67 | 76 | |
| 68 | - if (!empty($cache_enable)) |
|
| 69 | - cache_put_data('modSettings', $modSettings, 90); |
|
| 77 | + if (!empty($cache_enable)) { |
|
| 78 | + cache_put_data('modSettings', $modSettings, 90); |
|
| 79 | + } |
|
| 70 | 80 | } |
| 71 | 81 | |
| 72 | 82 | $modSettings['cache_enable'] = $cache_enable; |
@@ -86,8 +96,9 @@ discard block |
||
| 86 | 96 | }; |
| 87 | 97 | $fix_utf8mb4 = function($string) use ($utf8, $smcFunc) |
| 88 | 98 | { |
| 89 | - if (!$utf8 || $smcFunc['db_mb4']) |
|
| 90 | - return $string; |
|
| 99 | + if (!$utf8 || $smcFunc['db_mb4']) { |
|
| 100 | + return $string; |
|
| 101 | + } |
|
| 91 | 102 | |
| 92 | 103 | $i = 0; |
| 93 | 104 | $len = strlen($string); |
@@ -99,18 +110,15 @@ discard block |
||
| 99 | 110 | { |
| 100 | 111 | $new_string .= $string[$i]; |
| 101 | 112 | $i++; |
| 102 | - } |
|
| 103 | - elseif ($ord < 224) |
|
| 113 | + } elseif ($ord < 224) |
|
| 104 | 114 | { |
| 105 | 115 | $new_string .= $string[$i] . $string[$i + 1]; |
| 106 | 116 | $i += 2; |
| 107 | - } |
|
| 108 | - elseif ($ord < 240) |
|
| 117 | + } elseif ($ord < 240) |
|
| 109 | 118 | { |
| 110 | 119 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
| 111 | 120 | $i += 3; |
| 112 | - } |
|
| 113 | - elseif ($ord < 248) |
|
| 121 | + } elseif ($ord < 248) |
|
| 114 | 122 | { |
| 115 | 123 | // Magic happens. |
| 116 | 124 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -154,8 +162,7 @@ discard block |
||
| 154 | 162 | { |
| 155 | 163 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
| 156 | 164 | return is_int($result) ? $result + $offset : false; |
| 157 | - } |
|
| 158 | - else |
|
| 165 | + } else |
|
| 159 | 166 | { |
| 160 | 167 | $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); |
| 161 | 168 | $needle_size = count($needle_arr); |
@@ -164,8 +171,9 @@ discard block |
||
| 164 | 171 | while ((int) $result === $result) |
| 165 | 172 | { |
| 166 | 173 | $offset += $result; |
| 167 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
| 168 | - return $offset; |
|
| 174 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
| 175 | + return $offset; |
|
| 176 | + } |
|
| 169 | 177 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
| 170 | 178 | } |
| 171 | 179 | return false; |
@@ -203,8 +211,9 @@ discard block |
||
| 203 | 211 | $string = $ent_check($string); |
| 204 | 212 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
| 205 | 213 | $string = $matches[0]; |
| 206 | - while (strlen($string) > $length) |
|
| 207 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
| 214 | + while (strlen($string) > $length) { |
|
| 215 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
| 216 | + } |
|
| 208 | 217 | return $string; |
| 209 | 218 | }, |
| 210 | 219 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -214,23 +223,25 @@ discard block |
||
| 214 | 223 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
| 215 | 224 | { |
| 216 | 225 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
| 217 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
| 218 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
| 226 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
| 227 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
| 228 | + } |
|
| 219 | 229 | return implode('', $words); |
| 220 | 230 | } : 'ucwords', |
| 221 | 231 | ); |
| 222 | 232 | |
| 223 | 233 | // Setting the timezone is a requirement for some functions. |
| 224 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
| 225 | - date_default_timezone_set($modSettings['default_timezone']); |
|
| 226 | - else |
|
| 234 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
| 235 | + date_default_timezone_set($modSettings['default_timezone']); |
|
| 236 | + } else |
|
| 227 | 237 | { |
| 228 | 238 | // Get PHP's default timezone, if set |
| 229 | 239 | $ini_tz = ini_get('date.timezone'); |
| 230 | - if (!empty($ini_tz)) |
|
| 231 | - $modSettings['default_timezone'] = $ini_tz; |
|
| 232 | - else |
|
| 233 | - $modSettings['default_timezone'] = ''; |
|
| 240 | + if (!empty($ini_tz)) { |
|
| 241 | + $modSettings['default_timezone'] = $ini_tz; |
|
| 242 | + } else { |
|
| 243 | + $modSettings['default_timezone'] = ''; |
|
| 244 | + } |
|
| 234 | 245 | |
| 235 | 246 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 236 | 247 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -248,22 +259,26 @@ discard block |
||
| 248 | 259 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
| 249 | 260 | { |
| 250 | 261 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
| 251 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
| 252 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 253 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
| 254 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 255 | - else |
|
| 256 | - unset($modSettings['load_average']); |
|
| 262 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
| 263 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 264 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
| 265 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 266 | + } else { |
|
| 267 | + unset($modSettings['load_average']); |
|
| 268 | + } |
|
| 257 | 269 | |
| 258 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
| 259 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
| 270 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
| 271 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
| 272 | + } |
|
| 260 | 273 | } |
| 261 | 274 | |
| 262 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
| 263 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
| 275 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
| 276 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
| 277 | + } |
|
| 264 | 278 | |
| 265 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
| 266 | - display_loadavg_error(); |
|
| 279 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
| 280 | + display_loadavg_error(); |
|
| 281 | + } |
|
| 267 | 282 | } |
| 268 | 283 | |
| 269 | 284 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -284,8 +299,9 @@ discard block |
||
| 284 | 299 | if (defined('SMF_INTEGRATION_SETTINGS')) |
| 285 | 300 | { |
| 286 | 301 | $integration_settings = smf_json_decode(SMF_INTEGRATION_SETTINGS, true); |
| 287 | - foreach ($integration_settings as $hook => $function) |
|
| 288 | - add_integration_function($hook, $function, '', false); |
|
| 302 | + foreach ($integration_settings as $hook => $function) { |
|
| 303 | + add_integration_function($hook, $function, '', false); |
|
| 304 | + } |
|
| 289 | 305 | } |
| 290 | 306 | |
| 291 | 307 | // Any files to pre include? |
@@ -295,8 +311,9 @@ discard block |
||
| 295 | 311 | foreach ($pre_includes as $include) |
| 296 | 312 | { |
| 297 | 313 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
| 298 | - if (file_exists($include)) |
|
| 299 | - require_once($include); |
|
| 314 | + if (file_exists($include)) { |
|
| 315 | + require_once($include); |
|
| 316 | + } |
|
| 300 | 317 | } |
| 301 | 318 | } |
| 302 | 319 | |
@@ -400,27 +417,28 @@ discard block |
||
| 400 | 417 | break; |
| 401 | 418 | } |
| 402 | 419 | } |
| 420 | + } else { |
|
| 421 | + $id_member = 0; |
|
| 403 | 422 | } |
| 404 | - else |
|
| 405 | - $id_member = 0; |
|
| 406 | 423 | |
| 407 | 424 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
| 408 | 425 | { |
| 409 | 426 | $cookie_data = smf_json_decode($_COOKIE[$cookiename], true, false); |
| 410 | 427 | |
| 411 | - if (empty($cookie_data)) |
|
| 412 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
| 428 | + if (empty($cookie_data)) { |
|
| 429 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
| 430 | + } |
|
| 413 | 431 | |
| 414 | 432 | list ($id_member, $password) = $cookie_data; |
| 415 | 433 | $id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0; |
| 416 | - } |
|
| 417 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
| 434 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
| 418 | 435 | { |
| 419 | 436 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
| 420 | 437 | $cookie_data = smf_json_decode($_SESSION['login_' . $cookiename]); |
| 421 | 438 | |
| 422 | - if (empty($cookie_data)) |
|
| 423 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 439 | + if (empty($cookie_data)) { |
|
| 440 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 441 | + } |
|
| 424 | 442 | |
| 425 | 443 | list ($id_member, $password, $login_span) = $cookie_data; |
| 426 | 444 | $id_member = !empty($id_member) && strlen($password) == 128 && $login_span > time() ? (int) $id_member : 0; |
@@ -445,30 +463,34 @@ discard block |
||
| 445 | 463 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
| 446 | 464 | $smcFunc['db_free_result']($request); |
| 447 | 465 | |
| 448 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) |
|
| 449 | - $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
| 466 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) { |
|
| 467 | + $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
| 468 | + } |
|
| 450 | 469 | |
| 451 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 452 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 470 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 471 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 472 | + } |
|
| 453 | 473 | } |
| 454 | 474 | |
| 455 | 475 | // Did we find 'im? If not, junk it. |
| 456 | 476 | if (!empty($user_settings)) |
| 457 | 477 | { |
| 458 | 478 | // As much as the password should be right, we can assume the integration set things up. |
| 459 | - if (!empty($already_verified) && $already_verified === true) |
|
| 460 | - $check = true; |
|
| 479 | + if (!empty($already_verified) && $already_verified === true) { |
|
| 480 | + $check = true; |
|
| 481 | + } |
|
| 461 | 482 | // SHA-512 hash should be 128 characters long. |
| 462 | - elseif (strlen($password) == 128) |
|
| 463 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
| 464 | - else |
|
| 465 | - $check = false; |
|
| 483 | + elseif (strlen($password) == 128) { |
|
| 484 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
| 485 | + } else { |
|
| 486 | + $check = false; |
|
| 487 | + } |
|
| 466 | 488 | |
| 467 | 489 | // Wrong password or not activated - either way, you're going nowhere. |
| 468 | 490 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
| 491 | + } else { |
|
| 492 | + $id_member = 0; |
|
| 469 | 493 | } |
| 470 | - else |
|
| 471 | - $id_member = 0; |
|
| 472 | 494 | |
| 473 | 495 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
| 474 | 496 | if (!$id_member) |
@@ -490,13 +512,15 @@ discard block |
||
| 490 | 512 | { |
| 491 | 513 | $tfa_data = smf_json_decode($_COOKIE[$tfacookie]); |
| 492 | 514 | |
| 493 | - if (is_null($tfa_data)) |
|
| 494 | - $tfa_data = safe_unserialize($_COOKIE[$tfacookie]); |
|
| 515 | + if (is_null($tfa_data)) { |
|
| 516 | + $tfa_data = safe_unserialize($_COOKIE[$tfacookie]); |
|
| 517 | + } |
|
| 495 | 518 | |
| 496 | 519 | list ($tfamember, $tfasecret) = $tfa_data; |
| 497 | 520 | |
| 498 | - if ((int) $tfamember != $id_member) |
|
| 499 | - $tfasecret = null; |
|
| 521 | + if ((int) $tfamember != $id_member) { |
|
| 522 | + $tfasecret = null; |
|
| 523 | + } |
|
| 500 | 524 | } |
| 501 | 525 | |
| 502 | 526 | if (empty($tfasecret) || hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']) != $tfasecret) |
@@ -516,10 +540,12 @@ discard block |
||
| 516 | 540 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
| 517 | 541 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
| 518 | 542 | { |
| 519 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
| 543 | + if ($modSettings['tfa_mode'] == 2) { |
|
| 544 | + //only do this if we are just forcing SOME membergroups |
|
| 520 | 545 | { |
| 521 | 546 | //Build an array of ALL user membergroups. |
| 522 | 547 | $full_groups = array($user_settings['id_group']); |
| 548 | + } |
|
| 523 | 549 | if (!empty($user_settings['additional_groups'])) |
| 524 | 550 | { |
| 525 | 551 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -539,15 +565,17 @@ discard block |
||
| 539 | 565 | ); |
| 540 | 566 | $row = $smcFunc['db_fetch_assoc']($request); |
| 541 | 567 | $smcFunc['db_free_result']($request); |
| 568 | + } else { |
|
| 569 | + $row['total'] = 1; |
|
| 542 | 570 | } |
| 543 | - else |
|
| 544 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
| 571 | + //simplifies logics in the next "if" |
|
| 545 | 572 | |
| 546 | 573 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
| 547 | 574 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
| 548 | 575 | |
| 549 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
| 550 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
| 576 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
| 577 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
| 578 | + } |
|
| 551 | 579 | } |
| 552 | 580 | } |
| 553 | 581 | |
@@ -584,33 +612,37 @@ discard block |
||
| 584 | 612 | 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'])); |
| 585 | 613 | $user_settings['last_login'] = time(); |
| 586 | 614 | |
| 587 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 588 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 615 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 616 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 617 | + } |
|
| 589 | 618 | |
| 590 | - if (!empty($modSettings['cache_enable'])) |
|
| 591 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
| 619 | + if (!empty($modSettings['cache_enable'])) { |
|
| 620 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
| 621 | + } |
|
| 592 | 622 | } |
| 623 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
| 624 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
| 593 | 625 | } |
| 594 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
| 595 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
| 596 | 626 | |
| 597 | 627 | $username = $user_settings['member_name']; |
| 598 | 628 | |
| 599 | - if (empty($user_settings['additional_groups'])) |
|
| 600 | - $user_info = array( |
|
| 629 | + if (empty($user_settings['additional_groups'])) { |
|
| 630 | + $user_info = array( |
|
| 601 | 631 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
| 602 | 632 | ); |
| 603 | - else |
|
| 604 | - $user_info = array( |
|
| 633 | + } else { |
|
| 634 | + $user_info = array( |
|
| 605 | 635 | 'groups' => array_merge( |
| 606 | 636 | array($user_settings['id_group'], $user_settings['id_post_group']), |
| 607 | 637 | explode(',', $user_settings['additional_groups']) |
| 608 | 638 | ) |
| 609 | 639 | ); |
| 640 | + } |
|
| 610 | 641 | |
| 611 | 642 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
| 612 | - foreach ($user_info['groups'] as $k => $v) |
|
| 613 | - $user_info['groups'][$k] = (int) $v; |
|
| 643 | + foreach ($user_info['groups'] as $k => $v) { |
|
| 644 | + $user_info['groups'][$k] = (int) $v; |
|
| 645 | + } |
|
| 614 | 646 | |
| 615 | 647 | // This is a logged in user, so definitely not a spider. |
| 616 | 648 | $user_info['possibly_robot'] = false; |
@@ -624,8 +656,7 @@ discard block |
||
| 624 | 656 | $time_system = new DateTime('now', $tz_system); |
| 625 | 657 | $time_user = new DateTime('now', $tz_user); |
| 626 | 658 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
| 627 | - } |
|
| 628 | - else |
|
| 659 | + } else |
|
| 629 | 660 | { |
| 630 | 661 | // !!! Compatibility. |
| 631 | 662 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -639,16 +670,18 @@ discard block |
||
| 639 | 670 | $user_info = array('groups' => array(-1)); |
| 640 | 671 | $user_settings = array(); |
| 641 | 672 | |
| 642 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
| 643 | - $_COOKIE[$cookiename] = ''; |
|
| 673 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
| 674 | + $_COOKIE[$cookiename] = ''; |
|
| 675 | + } |
|
| 644 | 676 | |
| 645 | 677 | // Expire the 2FA cookie |
| 646 | 678 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
| 647 | 679 | { |
| 648 | 680 | $tfa_data = smf_json_decode($_COOKIE[$cookiename . '_tfa'], true); |
| 649 | 681 | |
| 650 | - if (is_null($tfa_data)) |
|
| 651 | - $tfa_data = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
| 682 | + if (is_null($tfa_data)) { |
|
| 683 | + $tfa_data = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
| 684 | + } |
|
| 652 | 685 | |
| 653 | 686 | list ($id, $user, $exp, $state, $preserve) = $tfa_data; |
| 654 | 687 | |
@@ -660,19 +693,20 @@ discard block |
||
| 660 | 693 | } |
| 661 | 694 | |
| 662 | 695 | // Create a login token if it doesn't exist yet. |
| 663 | - if (!isset($_SESSION['token']['post-login'])) |
|
| 664 | - createToken('login'); |
|
| 665 | - else |
|
| 666 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
| 696 | + if (!isset($_SESSION['token']['post-login'])) { |
|
| 697 | + createToken('login'); |
|
| 698 | + } else { |
|
| 699 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
| 700 | + } |
|
| 667 | 701 | |
| 668 | 702 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
| 669 | 703 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
| 670 | 704 | { |
| 671 | 705 | require_once($sourcedir . '/ManageSearchEngines.php'); |
| 672 | 706 | $user_info['possibly_robot'] = SpiderCheck(); |
| 707 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
| 708 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
| 673 | 709 | } |
| 674 | - elseif (!empty($modSettings['spider_mode'])) |
|
| 675 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
| 676 | 710 | // If we haven't turned on proper spider hunts then have a guess! |
| 677 | 711 | else |
| 678 | 712 | { |
@@ -720,8 +754,9 @@ discard block |
||
| 720 | 754 | $user_info['groups'] = array_unique($user_info['groups']); |
| 721 | 755 | |
| 722 | 756 | // 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. |
| 723 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
| 724 | - unset($user_info['ignoreboards'][$tmp]); |
|
| 757 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
| 758 | + unset($user_info['ignoreboards'][$tmp]); |
|
| 759 | + } |
|
| 725 | 760 | |
| 726 | 761 | // Allow the user to change their language. |
| 727 | 762 | if (!empty($modSettings['userLanguage'])) |
@@ -734,31 +769,36 @@ discard block |
||
| 734 | 769 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
| 735 | 770 | |
| 736 | 771 | // Make it permanent for members. |
| 737 | - if (!empty($user_info['id'])) |
|
| 738 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
| 739 | - else |
|
| 740 | - $_SESSION['language'] = $user_info['language']; |
|
| 772 | + if (!empty($user_info['id'])) { |
|
| 773 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
| 774 | + } else { |
|
| 775 | + $_SESSION['language'] = $user_info['language']; |
|
| 776 | + } |
|
| 777 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
| 778 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
| 741 | 779 | } |
| 742 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
| 743 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
| 744 | 780 | } |
| 745 | 781 | |
| 746 | 782 | // Just build this here, it makes it easier to change/use - administrators can see all boards. |
| 747 | - if ($user_info['is_admin']) |
|
| 748 | - $user_info['query_see_board'] = '1=1'; |
|
| 783 | + if ($user_info['is_admin']) { |
|
| 784 | + $user_info['query_see_board'] = '1=1'; |
|
| 785 | + } |
|
| 749 | 786 | // Otherwise just the groups in $user_info['groups']. |
| 750 | - else |
|
| 751 | - $user_info['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0)' . (!empty($modSettings['deny_boards_access']) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $user_info['groups']) . ', b.deny_member_groups) = 0)' : '') . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')'; |
|
| 787 | + else { |
|
| 788 | + $user_info['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0)' . (!empty($modSettings['deny_boards_access']) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $user_info['groups']) . ', b.deny_member_groups) = 0)' : '') . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')'; |
|
| 789 | + } |
|
| 752 | 790 | |
| 753 | 791 | // Build the list of boards they WANT to see. |
| 754 | 792 | // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also |
| 755 | 793 | |
| 756 | 794 | // If they aren't ignoring any boards then they want to see all the boards they can see |
| 757 | - if (empty($user_info['ignoreboards'])) |
|
| 758 | - $user_info['query_wanna_see_board'] = $user_info['query_see_board']; |
|
| 795 | + if (empty($user_info['ignoreboards'])) { |
|
| 796 | + $user_info['query_wanna_see_board'] = $user_info['query_see_board']; |
|
| 797 | + } |
|
| 759 | 798 | // Ok I guess they don't want to see all the boards |
| 760 | - else |
|
| 761 | - $user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))'; |
|
| 799 | + else { |
|
| 800 | + $user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))'; |
|
| 801 | + } |
|
| 762 | 802 | |
| 763 | 803 | call_integration_hook('integrate_user_info'); |
| 764 | 804 | } |
@@ -816,9 +856,9 @@ discard block |
||
| 816 | 856 | } |
| 817 | 857 | |
| 818 | 858 | // Remember redirection is the key to avoiding fallout from your bosses. |
| 819 | - if (!empty($topic)) |
|
| 820 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
| 821 | - else |
|
| 859 | + if (!empty($topic)) { |
|
| 860 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
| 861 | + } else |
|
| 822 | 862 | { |
| 823 | 863 | loadPermissions(); |
| 824 | 864 | loadTheme(); |
@@ -836,10 +876,11 @@ discard block |
||
| 836 | 876 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
| 837 | 877 | { |
| 838 | 878 | // @todo SLOW? |
| 839 | - if (!empty($topic)) |
|
| 840 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
| 841 | - else |
|
| 842 | - $temp = cache_get_data('board-' . $board, 120); |
|
| 879 | + if (!empty($topic)) { |
|
| 880 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
| 881 | + } else { |
|
| 882 | + $temp = cache_get_data('board-' . $board, 120); |
|
| 883 | + } |
|
| 843 | 884 | |
| 844 | 885 | if (!empty($temp)) |
| 845 | 886 | { |
@@ -877,8 +918,9 @@ discard block |
||
| 877 | 918 | $row = $smcFunc['db_fetch_assoc']($request); |
| 878 | 919 | |
| 879 | 920 | // Set the current board. |
| 880 | - if (!empty($row['id_board'])) |
|
| 881 | - $board = $row['id_board']; |
|
| 921 | + if (!empty($row['id_board'])) { |
|
| 922 | + $board = $row['id_board']; |
|
| 923 | + } |
|
| 882 | 924 | |
| 883 | 925 | // Basic operating information. (globals... :/) |
| 884 | 926 | $board_info = array( |
@@ -914,21 +956,23 @@ discard block |
||
| 914 | 956 | |
| 915 | 957 | do |
| 916 | 958 | { |
| 917 | - if (!empty($row['id_moderator'])) |
|
| 918 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
| 959 | + if (!empty($row['id_moderator'])) { |
|
| 960 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
| 919 | 961 | 'id' => $row['id_moderator'], |
| 920 | 962 | 'name' => $row['real_name'], |
| 921 | 963 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
| 922 | 964 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
| 923 | 965 | ); |
| 966 | + } |
|
| 924 | 967 | |
| 925 | - if (!empty($row['id_moderator_group'])) |
|
| 926 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
| 968 | + if (!empty($row['id_moderator_group'])) { |
|
| 969 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
| 927 | 970 | 'id' => $row['id_moderator_group'], |
| 928 | 971 | 'name' => $row['group_name'], |
| 929 | 972 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
| 930 | 973 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
| 931 | 974 | ); |
| 975 | + } |
|
| 932 | 976 | } |
| 933 | 977 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
| 934 | 978 | |
@@ -960,12 +1004,12 @@ discard block |
||
| 960 | 1004 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
| 961 | 1005 | { |
| 962 | 1006 | // @todo SLOW? |
| 963 | - if (!empty($topic)) |
|
| 964 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
| 1007 | + if (!empty($topic)) { |
|
| 1008 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
| 1009 | + } |
|
| 965 | 1010 | cache_put_data('board-' . $board, $board_info, 120); |
| 966 | 1011 | } |
| 967 | - } |
|
| 968 | - else |
|
| 1012 | + } else |
|
| 969 | 1013 | { |
| 970 | 1014 | // Otherwise the topic is invalid, there are no moderators, etc. |
| 971 | 1015 | $board_info = array( |
@@ -979,8 +1023,9 @@ discard block |
||
| 979 | 1023 | $smcFunc['db_free_result']($request); |
| 980 | 1024 | } |
| 981 | 1025 | |
| 982 | - if (!empty($topic)) |
|
| 983 | - $_GET['board'] = (int) $board; |
|
| 1026 | + if (!empty($topic)) { |
|
| 1027 | + $_GET['board'] = (int) $board; |
|
| 1028 | + } |
|
| 984 | 1029 | |
| 985 | 1030 | if (!empty($board)) |
| 986 | 1031 | { |
@@ -990,10 +1035,12 @@ discard block |
||
| 990 | 1035 | // Now check if the user is a moderator. |
| 991 | 1036 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
| 992 | 1037 | |
| 993 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
| 994 | - $board_info['error'] = 'access'; |
|
| 995 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
| 996 | - $board_info['error'] = 'access'; |
|
| 1038 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
| 1039 | + $board_info['error'] = 'access'; |
|
| 1040 | + } |
|
| 1041 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
| 1042 | + $board_info['error'] = 'access'; |
|
| 1043 | + } |
|
| 997 | 1044 | |
| 998 | 1045 | // Build up the linktree. |
| 999 | 1046 | $context['linktree'] = array_merge( |
@@ -1016,8 +1063,9 @@ discard block |
||
| 1016 | 1063 | $context['current_board'] = $board; |
| 1017 | 1064 | |
| 1018 | 1065 | // No posting in redirection boards! |
| 1019 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
| 1020 | - $board_info['error'] == 'post_in_redirect'; |
|
| 1066 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
| 1067 | + $board_info['error'] == 'post_in_redirect'; |
|
| 1068 | + } |
|
| 1021 | 1069 | |
| 1022 | 1070 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
| 1023 | 1071 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1043,24 +1091,23 @@ discard block |
||
| 1043 | 1091 | ob_end_clean(); |
| 1044 | 1092 | header('HTTP/1.1 403 Forbidden'); |
| 1045 | 1093 | die; |
| 1046 | - } |
|
| 1047 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
| 1094 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
| 1048 | 1095 | { |
| 1049 | 1096 | // Slightly different error message here... |
| 1050 | 1097 | fatal_lang_error('cannot_post_redirect', false); |
| 1051 | - } |
|
| 1052 | - elseif ($user_info['is_guest']) |
|
| 1098 | + } elseif ($user_info['is_guest']) |
|
| 1053 | 1099 | { |
| 1054 | 1100 | loadLanguage('Errors'); |
| 1055 | 1101 | is_not_guest($txt['topic_gone']); |
| 1102 | + } else { |
|
| 1103 | + fatal_lang_error('topic_gone', false); |
|
| 1056 | 1104 | } |
| 1057 | - else |
|
| 1058 | - fatal_lang_error('topic_gone', false); |
|
| 1059 | 1105 | } |
| 1060 | 1106 | |
| 1061 | - if ($user_info['is_mod']) |
|
| 1062 | - $user_info['groups'][] = 3; |
|
| 1063 | -} |
|
| 1107 | + if ($user_info['is_mod']) { |
|
| 1108 | + $user_info['groups'][] = 3; |
|
| 1109 | + } |
|
| 1110 | + } |
|
| 1064 | 1111 | |
| 1065 | 1112 | /** |
| 1066 | 1113 | * Load this user's permissions. |
@@ -1081,8 +1128,9 @@ discard block |
||
| 1081 | 1128 | asort($cache_groups); |
| 1082 | 1129 | $cache_groups = implode(',', $cache_groups); |
| 1083 | 1130 | // If it's a spider then cache it different. |
| 1084 | - if ($user_info['possibly_robot']) |
|
| 1085 | - $cache_groups .= '-spider'; |
|
| 1131 | + if ($user_info['possibly_robot']) { |
|
| 1132 | + $cache_groups .= '-spider'; |
|
| 1133 | + } |
|
| 1086 | 1134 | |
| 1087 | 1135 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
| 1088 | 1136 | { |
@@ -1090,9 +1138,9 @@ discard block |
||
| 1090 | 1138 | banPermissions(); |
| 1091 | 1139 | |
| 1092 | 1140 | return; |
| 1141 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
| 1142 | + list ($user_info['permissions'], $removals) = $temp; |
|
| 1093 | 1143 | } |
| 1094 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
| 1095 | - list ($user_info['permissions'], $removals) = $temp; |
|
| 1096 | 1144 | } |
| 1097 | 1145 | |
| 1098 | 1146 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1114,23 +1162,26 @@ discard block |
||
| 1114 | 1162 | $removals = array(); |
| 1115 | 1163 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1116 | 1164 | { |
| 1117 | - if (empty($row['add_deny'])) |
|
| 1118 | - $removals[] = $row['permission']; |
|
| 1119 | - else |
|
| 1120 | - $user_info['permissions'][] = $row['permission']; |
|
| 1165 | + if (empty($row['add_deny'])) { |
|
| 1166 | + $removals[] = $row['permission']; |
|
| 1167 | + } else { |
|
| 1168 | + $user_info['permissions'][] = $row['permission']; |
|
| 1169 | + } |
|
| 1121 | 1170 | } |
| 1122 | 1171 | $smcFunc['db_free_result']($request); |
| 1123 | 1172 | |
| 1124 | - if (isset($cache_groups)) |
|
| 1125 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
| 1173 | + if (isset($cache_groups)) { |
|
| 1174 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
| 1175 | + } |
|
| 1126 | 1176 | } |
| 1127 | 1177 | |
| 1128 | 1178 | // Get the board permissions. |
| 1129 | 1179 | if (!empty($board)) |
| 1130 | 1180 | { |
| 1131 | 1181 | // Make sure the board (if any) has been loaded by loadBoard(). |
| 1132 | - if (!isset($board_info['profile'])) |
|
| 1133 | - fatal_lang_error('no_board'); |
|
| 1182 | + if (!isset($board_info['profile'])) { |
|
| 1183 | + fatal_lang_error('no_board'); |
|
| 1184 | + } |
|
| 1134 | 1185 | |
| 1135 | 1186 | $request = $smcFunc['db_query']('', ' |
| 1136 | 1187 | SELECT permission, add_deny |
@@ -1146,20 +1197,23 @@ discard block |
||
| 1146 | 1197 | ); |
| 1147 | 1198 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1148 | 1199 | { |
| 1149 | - if (empty($row['add_deny'])) |
|
| 1150 | - $removals[] = $row['permission']; |
|
| 1151 | - else |
|
| 1152 | - $user_info['permissions'][] = $row['permission']; |
|
| 1200 | + if (empty($row['add_deny'])) { |
|
| 1201 | + $removals[] = $row['permission']; |
|
| 1202 | + } else { |
|
| 1203 | + $user_info['permissions'][] = $row['permission']; |
|
| 1204 | + } |
|
| 1153 | 1205 | } |
| 1154 | 1206 | $smcFunc['db_free_result']($request); |
| 1155 | 1207 | } |
| 1156 | 1208 | |
| 1157 | 1209 | // Remove all the permissions they shouldn't have ;). |
| 1158 | - if (!empty($modSettings['permission_enable_deny'])) |
|
| 1159 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
| 1210 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
| 1211 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
| 1212 | + } |
|
| 1160 | 1213 | |
| 1161 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
| 1162 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
| 1214 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
| 1215 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
| 1216 | + } |
|
| 1163 | 1217 | |
| 1164 | 1218 | // Banned? Watch, don't touch.. |
| 1165 | 1219 | banPermissions(); |
@@ -1171,17 +1225,18 @@ discard block |
||
| 1171 | 1225 | { |
| 1172 | 1226 | require_once($sourcedir . '/Subs-Auth.php'); |
| 1173 | 1227 | rebuildModCache(); |
| 1228 | + } else { |
|
| 1229 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 1174 | 1230 | } |
| 1175 | - else |
|
| 1176 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 1177 | 1231 | |
| 1178 | 1232 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
| 1179 | 1233 | // For example this drastically simplifies certain changes to the profile area. |
| 1180 | 1234 | $user_info['permissions'][] = 'is_not_guest'; |
| 1181 | 1235 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
| 1182 | 1236 | $user_info['permissions'][] = 'profile_view_own'; |
| 1183 | - if (in_array('profile_view', $user_info['permissions'])) |
|
| 1184 | - $user_info['permissions'][] = 'profile_view_any'; |
|
| 1237 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
| 1238 | + $user_info['permissions'][] = 'profile_view_any'; |
|
| 1239 | + } |
|
| 1185 | 1240 | } |
| 1186 | 1241 | } |
| 1187 | 1242 | |
@@ -1199,8 +1254,9 @@ discard block |
||
| 1199 | 1254 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
| 1200 | 1255 | |
| 1201 | 1256 | // Can't just look for no users :P. |
| 1202 | - if (empty($users)) |
|
| 1203 | - return array(); |
|
| 1257 | + if (empty($users)) { |
|
| 1258 | + return array(); |
|
| 1259 | + } |
|
| 1204 | 1260 | |
| 1205 | 1261 | // Pass the set value |
| 1206 | 1262 | $context['loadMemberContext_set'] = $set; |
@@ -1215,8 +1271,9 @@ discard block |
||
| 1215 | 1271 | for ($i = 0, $n = count($users); $i < $n; $i++) |
| 1216 | 1272 | { |
| 1217 | 1273 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
| 1218 | - if ($data == null) |
|
| 1219 | - continue; |
|
| 1274 | + if ($data == null) { |
|
| 1275 | + continue; |
|
| 1276 | + } |
|
| 1220 | 1277 | |
| 1221 | 1278 | $loaded_ids[] = $data['id_member']; |
| 1222 | 1279 | $user_profile[$data['id_member']] = $data; |
@@ -1283,13 +1340,16 @@ discard block |
||
| 1283 | 1340 | $row['avatar_original'] = $row['avatar']; |
| 1284 | 1341 | |
| 1285 | 1342 | // Take care of proxying avatar if required, do this here for maximum reach |
| 1286 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) |
|
| 1287 | - $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
| 1343 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) { |
|
| 1344 | + $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
| 1345 | + } |
|
| 1288 | 1346 | |
| 1289 | - if (isset($row['member_ip'])) |
|
| 1290 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
| 1291 | - if (isset($row['member_ip2'])) |
|
| 1292 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
| 1347 | + if (isset($row['member_ip'])) { |
|
| 1348 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
| 1349 | + } |
|
| 1350 | + if (isset($row['member_ip2'])) { |
|
| 1351 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
| 1352 | + } |
|
| 1293 | 1353 | $new_loaded_ids[] = $row['id_member']; |
| 1294 | 1354 | $loaded_ids[] = $row['id_member']; |
| 1295 | 1355 | $row['options'] = array(); |
@@ -1308,8 +1368,9 @@ discard block |
||
| 1308 | 1368 | 'loaded_ids' => $new_loaded_ids, |
| 1309 | 1369 | ) |
| 1310 | 1370 | ); |
| 1311 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1312 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
| 1371 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1372 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
| 1373 | + } |
|
| 1313 | 1374 | $smcFunc['db_free_result']($request); |
| 1314 | 1375 | } |
| 1315 | 1376 | |
@@ -1320,10 +1381,11 @@ discard block |
||
| 1320 | 1381 | { |
| 1321 | 1382 | foreach ($loaded_ids as $a_member) |
| 1322 | 1383 | { |
| 1323 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
| 1324 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
| 1325 | - else |
|
| 1326 | - $groups = array($user_profile[$a_member]['id_group']); |
|
| 1384 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
| 1385 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
| 1386 | + } else { |
|
| 1387 | + $groups = array($user_profile[$a_member]['id_group']); |
|
| 1388 | + } |
|
| 1327 | 1389 | |
| 1328 | 1390 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
| 1329 | 1391 | |
@@ -1336,8 +1398,9 @@ discard block |
||
| 1336 | 1398 | |
| 1337 | 1399 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
| 1338 | 1400 | { |
| 1339 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
| 1340 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
| 1401 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
| 1402 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
| 1403 | + } |
|
| 1341 | 1404 | } |
| 1342 | 1405 | |
| 1343 | 1406 | // Are we loading any moderators? If so, fix their group data... |
@@ -1363,14 +1426,17 @@ discard block |
||
| 1363 | 1426 | foreach ($temp_mods as $id) |
| 1364 | 1427 | { |
| 1365 | 1428 | // By popular demand, don't show admins or global moderators as moderators. |
| 1366 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
| 1367 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
| 1429 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
| 1430 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
| 1431 | + } |
|
| 1368 | 1432 | |
| 1369 | 1433 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
| 1370 | - if (!empty($row['icons'])) |
|
| 1371 | - $user_profile[$id]['icons'] = $row['icons']; |
|
| 1372 | - if (!empty($row['member_group_color'])) |
|
| 1373 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
| 1434 | + if (!empty($row['icons'])) { |
|
| 1435 | + $user_profile[$id]['icons'] = $row['icons']; |
|
| 1436 | + } |
|
| 1437 | + if (!empty($row['member_group_color'])) { |
|
| 1438 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
| 1439 | + } |
|
| 1374 | 1440 | } |
| 1375 | 1441 | } |
| 1376 | 1442 | |
@@ -1392,12 +1458,14 @@ discard block |
||
| 1392 | 1458 | static $loadedLanguages = array(); |
| 1393 | 1459 | |
| 1394 | 1460 | // If this person's data is already loaded, skip it. |
| 1395 | - if (isset($dataLoaded[$user])) |
|
| 1396 | - return true; |
|
| 1461 | + if (isset($dataLoaded[$user])) { |
|
| 1462 | + return true; |
|
| 1463 | + } |
|
| 1397 | 1464 | |
| 1398 | 1465 | // We can't load guests or members not loaded by loadMemberData()! |
| 1399 | - if ($user == 0) |
|
| 1400 | - return false; |
|
| 1466 | + if ($user == 0) { |
|
| 1467 | + return false; |
|
| 1468 | + } |
|
| 1401 | 1469 | if (!isset($user_profile[$user])) |
| 1402 | 1470 | { |
| 1403 | 1471 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1423,12 +1491,16 @@ discard block |
||
| 1423 | 1491 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
| 1424 | 1492 | |
| 1425 | 1493 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
| 1426 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
| 1494 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
| 1495 | + //icon is set and exists |
|
| 1427 | 1496 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
| 1428 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
| 1497 | + } elseif (isset($profile['icons'][1])) { |
|
| 1498 | + //icon is set and doesn't exist, fallback to default |
|
| 1429 | 1499 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
| 1430 | - else //not set, bye bye |
|
| 1500 | + } else { |
|
| 1501 | + //not set, bye bye |
|
| 1431 | 1502 | $group_icon_url = ''; |
| 1503 | + } |
|
| 1432 | 1504 | |
| 1433 | 1505 | // These minimal values are always loaded |
| 1434 | 1506 | $memberContext[$user] = array( |
@@ -1447,8 +1519,9 @@ discard block |
||
| 1447 | 1519 | if ($context['loadMemberContext_set'] != 'minimal') |
| 1448 | 1520 | { |
| 1449 | 1521 | // Go the extra mile and load the user's native language name. |
| 1450 | - if (empty($loadedLanguages)) |
|
| 1451 | - $loadedLanguages = getLanguages(); |
|
| 1522 | + if (empty($loadedLanguages)) { |
|
| 1523 | + $loadedLanguages = getLanguages(); |
|
| 1524 | + } |
|
| 1452 | 1525 | |
| 1453 | 1526 | $memberContext[$user] += array( |
| 1454 | 1527 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1502,31 +1575,33 @@ discard block |
||
| 1502 | 1575 | { |
| 1503 | 1576 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
| 1504 | 1577 | { |
| 1505 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
| 1506 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
| 1507 | - else |
|
| 1508 | - $image = get_gravatar_url($profile['email_address']); |
|
| 1509 | - } |
|
| 1510 | - else |
|
| 1578 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
| 1579 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
| 1580 | + } else { |
|
| 1581 | + $image = get_gravatar_url($profile['email_address']); |
|
| 1582 | + } |
|
| 1583 | + } else |
|
| 1511 | 1584 | { |
| 1512 | 1585 | // So it's stored in the member table? |
| 1513 | 1586 | if (!empty($profile['avatar'])) |
| 1514 | 1587 | { |
| 1515 | 1588 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
| 1589 | + } elseif (!empty($profile['filename'])) { |
|
| 1590 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
| 1516 | 1591 | } |
| 1517 | - elseif (!empty($profile['filename'])) |
|
| 1518 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
| 1519 | 1592 | // Right... no avatar...use the default one |
| 1520 | - else |
|
| 1521 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 1593 | + else { |
|
| 1594 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 1595 | + } |
|
| 1522 | 1596 | } |
| 1523 | - if (!empty($image)) |
|
| 1524 | - $memberContext[$user]['avatar'] = array( |
|
| 1597 | + if (!empty($image)) { |
|
| 1598 | + $memberContext[$user]['avatar'] = array( |
|
| 1525 | 1599 | 'name' => $profile['avatar'], |
| 1526 | 1600 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
| 1527 | 1601 | 'href' => $image, |
| 1528 | 1602 | 'url' => $image, |
| 1529 | 1603 | ); |
| 1604 | + } |
|
| 1530 | 1605 | } |
| 1531 | 1606 | |
| 1532 | 1607 | // Are we also loading the members custom fields into context? |
@@ -1534,35 +1609,41 @@ discard block |
||
| 1534 | 1609 | { |
| 1535 | 1610 | $memberContext[$user]['custom_fields'] = array(); |
| 1536 | 1611 | |
| 1537 | - if (!isset($context['display_fields'])) |
|
| 1538 | - $context['display_fields'] = smf_json_decode($modSettings['displayFields'], true); |
|
| 1612 | + if (!isset($context['display_fields'])) { |
|
| 1613 | + $context['display_fields'] = smf_json_decode($modSettings['displayFields'], true); |
|
| 1614 | + } |
|
| 1539 | 1615 | |
| 1540 | 1616 | foreach ($context['display_fields'] as $custom) |
| 1541 | 1617 | { |
| 1542 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
| 1543 | - continue; |
|
| 1618 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
| 1619 | + continue; |
|
| 1620 | + } |
|
| 1544 | 1621 | |
| 1545 | 1622 | $value = $profile['options'][$custom['col_name']]; |
| 1546 | 1623 | |
| 1547 | 1624 | // Don't show the "disabled" option for the "gender" field. |
| 1548 | - if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') |
|
| 1549 | - continue; |
|
| 1625 | + if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') { |
|
| 1626 | + continue; |
|
| 1627 | + } |
|
| 1550 | 1628 | |
| 1551 | 1629 | // BBC? |
| 1552 | - if ($custom['bbc']) |
|
| 1553 | - $value = parse_bbc($value); |
|
| 1630 | + if ($custom['bbc']) { |
|
| 1631 | + $value = parse_bbc($value); |
|
| 1632 | + } |
|
| 1554 | 1633 | // ... or checkbox? |
| 1555 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
| 1556 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
| 1634 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
| 1635 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
| 1636 | + } |
|
| 1557 | 1637 | |
| 1558 | 1638 | // Enclosing the user input within some other text? |
| 1559 | - if (!empty($custom['enclose'])) |
|
| 1560 | - $value = strtr($custom['enclose'], array( |
|
| 1639 | + if (!empty($custom['enclose'])) { |
|
| 1640 | + $value = strtr($custom['enclose'], array( |
|
| 1561 | 1641 | '{SCRIPTURL}' => $scripturl, |
| 1562 | 1642 | '{IMAGES_URL}' => $settings['images_url'], |
| 1563 | 1643 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1564 | 1644 | '{INPUT}' => $value, |
| 1565 | 1645 | )); |
| 1646 | + } |
|
| 1566 | 1647 | |
| 1567 | 1648 | $memberContext[$user]['custom_fields'][] = array( |
| 1568 | 1649 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1589,8 +1670,9 @@ discard block |
||
| 1589 | 1670 | global $smcFunc, $txt, $scripturl, $settings; |
| 1590 | 1671 | |
| 1591 | 1672 | // Do not waste my time... |
| 1592 | - if (empty($users) || empty($params)) |
|
| 1593 | - return false; |
|
| 1673 | + if (empty($users) || empty($params)) { |
|
| 1674 | + return false; |
|
| 1675 | + } |
|
| 1594 | 1676 | |
| 1595 | 1677 | // Make sure it's an array. |
| 1596 | 1678 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1614,31 +1696,36 @@ discard block |
||
| 1614 | 1696 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1615 | 1697 | { |
| 1616 | 1698 | // BBC? |
| 1617 | - if (!empty($row['bbc'])) |
|
| 1618 | - $row['value'] = parse_bbc($row['value']); |
|
| 1699 | + if (!empty($row['bbc'])) { |
|
| 1700 | + $row['value'] = parse_bbc($row['value']); |
|
| 1701 | + } |
|
| 1619 | 1702 | |
| 1620 | 1703 | // ... or checkbox? |
| 1621 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
| 1622 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
| 1704 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
| 1705 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
| 1706 | + } |
|
| 1623 | 1707 | |
| 1624 | 1708 | // Enclosing the user input within some other text? |
| 1625 | - if (!empty($row['enclose'])) |
|
| 1626 | - $row['value'] = strtr($row['enclose'], array( |
|
| 1709 | + if (!empty($row['enclose'])) { |
|
| 1710 | + $row['value'] = strtr($row['enclose'], array( |
|
| 1627 | 1711 | '{SCRIPTURL}' => $scripturl, |
| 1628 | 1712 | '{IMAGES_URL}' => $settings['images_url'], |
| 1629 | 1713 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1630 | 1714 | '{INPUT}' => un_htmlspecialchars($row['value']), |
| 1631 | 1715 | )); |
| 1716 | + } |
|
| 1632 | 1717 | |
| 1633 | 1718 | // Send a simple array if there is just 1 param |
| 1634 | - if (count($params) == 1) |
|
| 1635 | - $return[$row['id_member']] = $row; |
|
| 1719 | + if (count($params) == 1) { |
|
| 1720 | + $return[$row['id_member']] = $row; |
|
| 1721 | + } |
|
| 1636 | 1722 | |
| 1637 | 1723 | // More than 1? knock yourself out... |
| 1638 | 1724 | else |
| 1639 | 1725 | { |
| 1640 | - if (!isset($return[$row['id_member']])) |
|
| 1641 | - $return[$row['id_member']] = array(); |
|
| 1726 | + if (!isset($return[$row['id_member']])) { |
|
| 1727 | + $return[$row['id_member']] = array(); |
|
| 1728 | + } |
|
| 1642 | 1729 | |
| 1643 | 1730 | $return[$row['id_member']][$row['variable']] = $row; |
| 1644 | 1731 | } |
@@ -1672,8 +1759,9 @@ discard block |
||
| 1672 | 1759 | global $context; |
| 1673 | 1760 | |
| 1674 | 1761 | // Don't know any browser! |
| 1675 | - if (empty($context['browser'])) |
|
| 1676 | - detectBrowser(); |
|
| 1762 | + if (empty($context['browser'])) { |
|
| 1763 | + detectBrowser(); |
|
| 1764 | + } |
|
| 1677 | 1765 | |
| 1678 | 1766 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
| 1679 | 1767 | } |
@@ -1691,8 +1779,9 @@ discard block |
||
| 1691 | 1779 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
| 1692 | 1780 | |
| 1693 | 1781 | // The theme was specified by parameter. |
| 1694 | - if (!empty($id_theme)) |
|
| 1695 | - $id_theme = (int) $id_theme; |
|
| 1782 | + if (!empty($id_theme)) { |
|
| 1783 | + $id_theme = (int) $id_theme; |
|
| 1784 | + } |
|
| 1696 | 1785 | // The theme was specified by REQUEST. |
| 1697 | 1786 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
| 1698 | 1787 | { |
@@ -1700,51 +1789,58 @@ discard block |
||
| 1700 | 1789 | $_SESSION['id_theme'] = $id_theme; |
| 1701 | 1790 | } |
| 1702 | 1791 | // The theme was specified by REQUEST... previously. |
| 1703 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
| 1704 | - $id_theme = (int) $_SESSION['id_theme']; |
|
| 1792 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
| 1793 | + $id_theme = (int) $_SESSION['id_theme']; |
|
| 1794 | + } |
|
| 1705 | 1795 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
| 1706 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
| 1707 | - $id_theme = $user_info['theme']; |
|
| 1796 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
| 1797 | + $id_theme = $user_info['theme']; |
|
| 1798 | + } |
|
| 1708 | 1799 | // The theme was specified by the board. |
| 1709 | - elseif (!empty($board_info['theme'])) |
|
| 1710 | - $id_theme = $board_info['theme']; |
|
| 1800 | + elseif (!empty($board_info['theme'])) { |
|
| 1801 | + $id_theme = $board_info['theme']; |
|
| 1802 | + } |
|
| 1711 | 1803 | // The theme is the forum's default. |
| 1712 | - else |
|
| 1713 | - $id_theme = $modSettings['theme_guests']; |
|
| 1804 | + else { |
|
| 1805 | + $id_theme = $modSettings['theme_guests']; |
|
| 1806 | + } |
|
| 1714 | 1807 | |
| 1715 | 1808 | // Verify the id_theme... no foul play. |
| 1716 | 1809 | // Always allow the board specific theme, if they are overriding. |
| 1717 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
| 1718 | - $id_theme = $board_info['theme']; |
|
| 1810 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
| 1811 | + $id_theme = $board_info['theme']; |
|
| 1812 | + } |
|
| 1719 | 1813 | // If they have specified a particular theme to use with SSI allow it to be used. |
| 1720 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
| 1721 | - $id_theme = (int) $id_theme; |
|
| 1722 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
| 1814 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
| 1815 | + $id_theme = (int) $id_theme; |
|
| 1816 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
| 1723 | 1817 | { |
| 1724 | 1818 | $themes = explode(',', $modSettings['enableThemes']); |
| 1725 | - if (!in_array($id_theme, $themes)) |
|
| 1726 | - $id_theme = $modSettings['theme_guests']; |
|
| 1727 | - else |
|
| 1819 | + if (!in_array($id_theme, $themes)) { |
|
| 1820 | + $id_theme = $modSettings['theme_guests']; |
|
| 1821 | + } else { |
|
| 1822 | + $id_theme = (int) $id_theme; |
|
| 1823 | + } |
|
| 1824 | + } else { |
|
| 1728 | 1825 | $id_theme = (int) $id_theme; |
| 1729 | 1826 | } |
| 1730 | - else |
|
| 1731 | - $id_theme = (int) $id_theme; |
|
| 1732 | 1827 | |
| 1733 | 1828 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
| 1734 | 1829 | |
| 1735 | 1830 | // Disable image proxy if we don't have SSL enabled |
| 1736 | - if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) |
|
| 1737 | - $image_proxy_enabled = false; |
|
| 1831 | + if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) { |
|
| 1832 | + $image_proxy_enabled = false; |
|
| 1833 | + } |
|
| 1738 | 1834 | |
| 1739 | 1835 | 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']) |
| 1740 | 1836 | { |
| 1741 | 1837 | $themeData = $temp; |
| 1742 | 1838 | $flag = true; |
| 1839 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
| 1840 | + $themeData = $temp + array($member => array()); |
|
| 1841 | + } else { |
|
| 1842 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
| 1743 | 1843 | } |
| 1744 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
| 1745 | - $themeData = $temp + array($member => array()); |
|
| 1746 | - else |
|
| 1747 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
| 1748 | 1844 | |
| 1749 | 1845 | if (empty($flag)) |
| 1750 | 1846 | { |
@@ -1763,31 +1859,37 @@ discard block |
||
| 1763 | 1859 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1764 | 1860 | { |
| 1765 | 1861 | // There are just things we shouldn't be able to change as members. |
| 1766 | - 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'))) |
|
| 1767 | - continue; |
|
| 1862 | + 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'))) { |
|
| 1863 | + continue; |
|
| 1864 | + } |
|
| 1768 | 1865 | |
| 1769 | 1866 | // If this is the theme_dir of the default theme, store it. |
| 1770 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
| 1771 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
| 1867 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
| 1868 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
| 1869 | + } |
|
| 1772 | 1870 | |
| 1773 | 1871 | // If this isn't set yet, is a theme option, or is not the default theme.. |
| 1774 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
| 1775 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
| 1872 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
| 1873 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
| 1874 | + } |
|
| 1776 | 1875 | } |
| 1777 | 1876 | $smcFunc['db_free_result']($result); |
| 1778 | 1877 | |
| 1779 | - if (!empty($themeData[-1])) |
|
| 1780 | - foreach ($themeData[-1] as $k => $v) |
|
| 1878 | + if (!empty($themeData[-1])) { |
|
| 1879 | + foreach ($themeData[-1] as $k => $v) |
|
| 1781 | 1880 | { |
| 1782 | 1881 | if (!isset($themeData[$member][$k])) |
| 1783 | 1882 | $themeData[$member][$k] = $v; |
| 1883 | + } |
|
| 1784 | 1884 | } |
| 1785 | 1885 | |
| 1786 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 1787 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
| 1886 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 1887 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
| 1888 | + } |
|
| 1788 | 1889 | // Only if we didn't already load that part of the cache... |
| 1789 | - elseif (!isset($temp)) |
|
| 1790 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
| 1890 | + elseif (!isset($temp)) { |
|
| 1891 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
| 1892 | + } |
|
| 1791 | 1893 | } |
| 1792 | 1894 | |
| 1793 | 1895 | $settings = $themeData[0]; |
@@ -1804,20 +1906,24 @@ discard block |
||
| 1804 | 1906 | $settings['template_dirs'][] = $settings['theme_dir']; |
| 1805 | 1907 | |
| 1806 | 1908 | // Based on theme (if there is one). |
| 1807 | - if (!empty($settings['base_theme_dir'])) |
|
| 1808 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1909 | + if (!empty($settings['base_theme_dir'])) { |
|
| 1910 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1911 | + } |
|
| 1809 | 1912 | |
| 1810 | 1913 | // Lastly the default theme. |
| 1811 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
| 1812 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1914 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
| 1915 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1916 | + } |
|
| 1813 | 1917 | |
| 1814 | - if (!$initialize) |
|
| 1815 | - return; |
|
| 1918 | + if (!$initialize) { |
|
| 1919 | + return; |
|
| 1920 | + } |
|
| 1816 | 1921 | |
| 1817 | 1922 | // Check to see if we're forcing SSL |
| 1818 | 1923 | if (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 && empty($maintenance) && |
| 1819 | - (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') |
|
| 1820 | - redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
| 1924 | + (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') { |
|
| 1925 | + redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
| 1926 | + } |
|
| 1821 | 1927 | |
| 1822 | 1928 | // Check to see if they're accessing it from the wrong place. |
| 1823 | 1929 | if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME'])) |
@@ -1825,8 +1931,9 @@ discard block |
||
| 1825 | 1931 | $detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; |
| 1826 | 1932 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
| 1827 | 1933 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
| 1828 | - if ($temp != '/') |
|
| 1829 | - $detected_url .= $temp; |
|
| 1934 | + if ($temp != '/') { |
|
| 1935 | + $detected_url .= $temp; |
|
| 1936 | + } |
|
| 1830 | 1937 | } |
| 1831 | 1938 | if (isset($detected_url) && $detected_url != $boardurl) |
| 1832 | 1939 | { |
@@ -1838,8 +1945,9 @@ discard block |
||
| 1838 | 1945 | foreach ($aliases as $alias) |
| 1839 | 1946 | { |
| 1840 | 1947 | // Rip off all the boring parts, spaces, etc. |
| 1841 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
| 1842 | - $do_fix = true; |
|
| 1948 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
| 1949 | + $do_fix = true; |
|
| 1950 | + } |
|
| 1843 | 1951 | } |
| 1844 | 1952 | } |
| 1845 | 1953 | |
@@ -1847,20 +1955,22 @@ discard block |
||
| 1847 | 1955 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
| 1848 | 1956 | { |
| 1849 | 1957 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
| 1850 | - if (empty($_GET)) |
|
| 1851 | - redirectexit('wwwRedirect'); |
|
| 1852 | - else |
|
| 1958 | + if (empty($_GET)) { |
|
| 1959 | + redirectexit('wwwRedirect'); |
|
| 1960 | + } else |
|
| 1853 | 1961 | { |
| 1854 | 1962 | list ($k, $v) = each($_GET); |
| 1855 | 1963 | |
| 1856 | - if ($k != 'wwwRedirect') |
|
| 1857 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
| 1964 | + if ($k != 'wwwRedirect') { |
|
| 1965 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
| 1966 | + } |
|
| 1858 | 1967 | } |
| 1859 | 1968 | } |
| 1860 | 1969 | |
| 1861 | 1970 | // #3 is just a check for SSL... |
| 1862 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
| 1863 | - $do_fix = true; |
|
| 1971 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
| 1972 | + $do_fix = true; |
|
| 1973 | + } |
|
| 1864 | 1974 | |
| 1865 | 1975 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
| 1866 | 1976 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1894,8 +2004,9 @@ discard block |
||
| 1894 | 2004 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
| 1895 | 2005 | } |
| 1896 | 2006 | } |
| 1897 | - foreach ($context['linktree'] as $k => $dummy) |
|
| 1898 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
| 2007 | + foreach ($context['linktree'] as $k => $dummy) { |
|
| 2008 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
| 2009 | + } |
|
| 1899 | 2010 | } |
| 1900 | 2011 | } |
| 1901 | 2012 | // Set up the contextual user array. |
@@ -1914,16 +2025,16 @@ discard block |
||
| 1914 | 2025 | 'email' => $user_info['email'], |
| 1915 | 2026 | 'ignoreusers' => $user_info['ignoreusers'], |
| 1916 | 2027 | ); |
| 1917 | - if (!$context['user']['is_guest']) |
|
| 1918 | - $context['user']['name'] = $user_info['name']; |
|
| 1919 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
| 1920 | - $context['user']['name'] = $txt['guest_title']; |
|
| 2028 | + if (!$context['user']['is_guest']) { |
|
| 2029 | + $context['user']['name'] = $user_info['name']; |
|
| 2030 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
| 2031 | + $context['user']['name'] = $txt['guest_title']; |
|
| 2032 | + } |
|
| 1921 | 2033 | |
| 1922 | 2034 | // Determine the current smiley set. |
| 1923 | 2035 | $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']; |
| 1924 | 2036 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
| 1925 | - } |
|
| 1926 | - else |
|
| 2037 | + } else |
|
| 1927 | 2038 | { |
| 1928 | 2039 | $context['user'] = array( |
| 1929 | 2040 | 'id' => -1, |
@@ -1939,18 +2050,24 @@ discard block |
||
| 1939 | 2050 | } |
| 1940 | 2051 | |
| 1941 | 2052 | // Some basic information... |
| 1942 | - if (!isset($context['html_headers'])) |
|
| 1943 | - $context['html_headers'] = ''; |
|
| 1944 | - if (!isset($context['javascript_files'])) |
|
| 1945 | - $context['javascript_files'] = array(); |
|
| 1946 | - if (!isset($context['css_files'])) |
|
| 1947 | - $context['css_files'] = array(); |
|
| 1948 | - if (!isset($context['css_header'])) |
|
| 1949 | - $context['css_header'] = array(); |
|
| 1950 | - if (!isset($context['javascript_inline'])) |
|
| 1951 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
| 1952 | - if (!isset($context['javascript_vars'])) |
|
| 1953 | - $context['javascript_vars'] = array(); |
|
| 2053 | + if (!isset($context['html_headers'])) { |
|
| 2054 | + $context['html_headers'] = ''; |
|
| 2055 | + } |
|
| 2056 | + if (!isset($context['javascript_files'])) { |
|
| 2057 | + $context['javascript_files'] = array(); |
|
| 2058 | + } |
|
| 2059 | + if (!isset($context['css_files'])) { |
|
| 2060 | + $context['css_files'] = array(); |
|
| 2061 | + } |
|
| 2062 | + if (!isset($context['css_header'])) { |
|
| 2063 | + $context['css_header'] = array(); |
|
| 2064 | + } |
|
| 2065 | + if (!isset($context['javascript_inline'])) { |
|
| 2066 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
| 2067 | + } |
|
| 2068 | + if (!isset($context['javascript_vars'])) { |
|
| 2069 | + $context['javascript_vars'] = array(); |
|
| 2070 | + } |
|
| 1954 | 2071 | |
| 1955 | 2072 | $context['login_url'] = (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl) . '?action=login2'; |
| 1956 | 2073 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -1962,8 +2079,9 @@ discard block |
||
| 1962 | 2079 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
| 1963 | 2080 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
| 1964 | 2081 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
| 1965 | - if (isset($modSettings['load_average'])) |
|
| 1966 | - $context['load_average'] = $modSettings['load_average']; |
|
| 2082 | + if (isset($modSettings['load_average'])) { |
|
| 2083 | + $context['load_average'] = $modSettings['load_average']; |
|
| 2084 | + } |
|
| 1967 | 2085 | |
| 1968 | 2086 | // Detect the browser. This is separated out because it's also used in attachment downloads |
| 1969 | 2087 | detectBrowser(); |
@@ -1977,8 +2095,9 @@ discard block |
||
| 1977 | 2095 | // This allows sticking some HTML on the page output - useful for controls. |
| 1978 | 2096 | $context['insert_after_template'] = ''; |
| 1979 | 2097 | |
| 1980 | - if (!isset($txt)) |
|
| 1981 | - $txt = array(); |
|
| 2098 | + if (!isset($txt)) { |
|
| 2099 | + $txt = array(); |
|
| 2100 | + } |
|
| 1982 | 2101 | |
| 1983 | 2102 | $simpleActions = array( |
| 1984 | 2103 | 'findmember', |
@@ -2024,9 +2143,10 @@ discard block |
||
| 2024 | 2143 | |
| 2025 | 2144 | // See if theres any extra param to check. |
| 2026 | 2145 | $requiresXML = false; |
| 2027 | - foreach ($extraParams as $key => $extra) |
|
| 2028 | - if (isset($_REQUEST[$extra])) |
|
| 2146 | + foreach ($extraParams as $key => $extra) { |
|
| 2147 | + if (isset($_REQUEST[$extra])) |
|
| 2029 | 2148 | $requiresXML = true; |
| 2149 | + } |
|
| 2030 | 2150 | |
| 2031 | 2151 | // Output is fully XML, so no need for the index template. |
| 2032 | 2152 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2041,37 +2161,39 @@ discard block |
||
| 2041 | 2161 | { |
| 2042 | 2162 | loadLanguage('index+Modifications'); |
| 2043 | 2163 | $context['template_layers'] = array(); |
| 2044 | - } |
|
| 2045 | - |
|
| 2046 | - else |
|
| 2164 | + } else |
|
| 2047 | 2165 | { |
| 2048 | 2166 | // Custom templates to load, or just default? |
| 2049 | - if (isset($settings['theme_templates'])) |
|
| 2050 | - $templates = explode(',', $settings['theme_templates']); |
|
| 2051 | - else |
|
| 2052 | - $templates = array('index'); |
|
| 2167 | + if (isset($settings['theme_templates'])) { |
|
| 2168 | + $templates = explode(',', $settings['theme_templates']); |
|
| 2169 | + } else { |
|
| 2170 | + $templates = array('index'); |
|
| 2171 | + } |
|
| 2053 | 2172 | |
| 2054 | 2173 | // Load each template... |
| 2055 | - foreach ($templates as $template) |
|
| 2056 | - loadTemplate($template); |
|
| 2174 | + foreach ($templates as $template) { |
|
| 2175 | + loadTemplate($template); |
|
| 2176 | + } |
|
| 2057 | 2177 | |
| 2058 | 2178 | // ...and attempt to load their associated language files. |
| 2059 | 2179 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
| 2060 | 2180 | loadLanguage($required_files, '', false); |
| 2061 | 2181 | |
| 2062 | 2182 | // Custom template layers? |
| 2063 | - if (isset($settings['theme_layers'])) |
|
| 2064 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
| 2065 | - else |
|
| 2066 | - $context['template_layers'] = array('html', 'body'); |
|
| 2183 | + if (isset($settings['theme_layers'])) { |
|
| 2184 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
| 2185 | + } else { |
|
| 2186 | + $context['template_layers'] = array('html', 'body'); |
|
| 2187 | + } |
|
| 2067 | 2188 | } |
| 2068 | 2189 | |
| 2069 | 2190 | // Initialize the theme. |
| 2070 | 2191 | loadSubTemplate('init', 'ignore'); |
| 2071 | 2192 | |
| 2072 | 2193 | // Allow overriding the board wide time/number formats. |
| 2073 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
| 2074 | - $user_info['time_format'] = $txt['time_format']; |
|
| 2194 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
| 2195 | + $user_info['time_format'] = $txt['time_format']; |
|
| 2196 | + } |
|
| 2075 | 2197 | |
| 2076 | 2198 | // Set the character set from the template. |
| 2077 | 2199 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2079,12 +2201,14 @@ discard block |
||
| 2079 | 2201 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
| 2080 | 2202 | |
| 2081 | 2203 | // Guests may still need a name. |
| 2082 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
| 2083 | - $context['user']['name'] = $txt['guest_title']; |
|
| 2204 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
| 2205 | + $context['user']['name'] = $txt['guest_title']; |
|
| 2206 | + } |
|
| 2084 | 2207 | |
| 2085 | 2208 | // Any theme-related strings that need to be loaded? |
| 2086 | - if (!empty($settings['require_theme_strings'])) |
|
| 2087 | - loadLanguage('ThemeStrings', '', false); |
|
| 2209 | + if (!empty($settings['require_theme_strings'])) { |
|
| 2210 | + loadLanguage('ThemeStrings', '', false); |
|
| 2211 | + } |
|
| 2088 | 2212 | |
| 2089 | 2213 | // Make a special URL for the language. |
| 2090 | 2214 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2095,8 +2219,9 @@ discard block |
||
| 2095 | 2219 | // Here is my luvly Responsive CSS |
| 2096 | 2220 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true), 'smf_responsive'); |
| 2097 | 2221 | |
| 2098 | - if ($context['right_to_left']) |
|
| 2099 | - loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
| 2222 | + if ($context['right_to_left']) { |
|
| 2223 | + loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
| 2224 | + } |
|
| 2100 | 2225 | |
| 2101 | 2226 | // We allow theme variants, because we're cool. |
| 2102 | 2227 | $context['theme_variant'] = ''; |
@@ -2104,14 +2229,17 @@ discard block |
||
| 2104 | 2229 | if (!empty($settings['theme_variants'])) |
| 2105 | 2230 | { |
| 2106 | 2231 | // Overriding - for previews and that ilk. |
| 2107 | - if (!empty($_REQUEST['variant'])) |
|
| 2108 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
| 2232 | + if (!empty($_REQUEST['variant'])) { |
|
| 2233 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
| 2234 | + } |
|
| 2109 | 2235 | // User selection? |
| 2110 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
| 2111 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
| 2236 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
| 2237 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
| 2238 | + } |
|
| 2112 | 2239 | // If not a user variant, select the default. |
| 2113 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
| 2114 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
| 2240 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
| 2241 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
| 2242 | + } |
|
| 2115 | 2243 | |
| 2116 | 2244 | // Do this to keep things easier in the templates. |
| 2117 | 2245 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2120,20 +2248,23 @@ discard block |
||
| 2120 | 2248 | if (!empty($context['theme_variant'])) |
| 2121 | 2249 | { |
| 2122 | 2250 | loadCSSFile('index' . $context['theme_variant'] . '.css', array(), 'smf_index' . $context['theme_variant']); |
| 2123 | - if ($context['right_to_left']) |
|
| 2124 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
| 2251 | + if ($context['right_to_left']) { |
|
| 2252 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
| 2253 | + } |
|
| 2125 | 2254 | } |
| 2126 | 2255 | } |
| 2127 | 2256 | |
| 2128 | 2257 | // Let's be compatible with old themes! |
| 2129 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
| 2130 | - $context['template_layers'] = array('main'); |
|
| 2258 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
| 2259 | + $context['template_layers'] = array('main'); |
|
| 2260 | + } |
|
| 2131 | 2261 | |
| 2132 | 2262 | $context['tabindex'] = 1; |
| 2133 | 2263 | |
| 2134 | 2264 | // Compatibility. |
| 2135 | - if (!isset($settings['theme_version'])) |
|
| 2136 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
| 2265 | + if (!isset($settings['theme_version'])) { |
|
| 2266 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
| 2267 | + } |
|
| 2137 | 2268 | |
| 2138 | 2269 | // Default JS variables for use in every theme |
| 2139 | 2270 | $context['javascript_vars'] = array( |
@@ -2152,18 +2283,18 @@ discard block |
||
| 2152 | 2283 | ); |
| 2153 | 2284 | |
| 2154 | 2285 | // Add the JQuery library to the list of files to load. |
| 2155 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
| 2156 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2157 | - |
|
| 2158 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
| 2159 | - loadJavaScriptFile('jquery-3.1.1.min.js', array('seed' => false), 'smf_jquery'); |
|
| 2160 | - |
|
| 2161 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
| 2162 | - loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
| 2286 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
| 2287 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2288 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
| 2289 | + loadJavaScriptFile('jquery-3.1.1.min.js', array('seed' => false), 'smf_jquery'); |
|
| 2290 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
| 2291 | + loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
| 2292 | + } |
|
| 2163 | 2293 | |
| 2164 | 2294 | // Auto loading? template_javascript() will take care of the local half of this. |
| 2165 | - else |
|
| 2166 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2295 | + else { |
|
| 2296 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2297 | + } |
|
| 2167 | 2298 | |
| 2168 | 2299 | // Queue our JQuery plugins! |
| 2169 | 2300 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2186,12 +2317,12 @@ discard block |
||
| 2186 | 2317 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 2187 | 2318 | |
| 2188 | 2319 | // What to do, what to do?! |
| 2189 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
| 2190 | - AutoTask(); |
|
| 2191 | - else |
|
| 2192 | - ReduceMailQueue(); |
|
| 2193 | - } |
|
| 2194 | - else |
|
| 2320 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
| 2321 | + AutoTask(); |
|
| 2322 | + } else { |
|
| 2323 | + ReduceMailQueue(); |
|
| 2324 | + } |
|
| 2325 | + } else |
|
| 2195 | 2326 | { |
| 2196 | 2327 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
| 2197 | 2328 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2242,8 +2373,9 @@ discard block |
||
| 2242 | 2373 | foreach ($theme_includes as $include) |
| 2243 | 2374 | { |
| 2244 | 2375 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
| 2245 | - if (file_exists($include)) |
|
| 2246 | - require_once($include); |
|
| 2376 | + if (file_exists($include)) { |
|
| 2377 | + require_once($include); |
|
| 2378 | + } |
|
| 2247 | 2379 | } |
| 2248 | 2380 | } |
| 2249 | 2381 | |
@@ -2273,16 +2405,19 @@ discard block |
||
| 2273 | 2405 | // Do any style sheets first, cause we're easy with those. |
| 2274 | 2406 | if (!empty($style_sheets)) |
| 2275 | 2407 | { |
| 2276 | - if (!is_array($style_sheets)) |
|
| 2277 | - $style_sheets = array($style_sheets); |
|
| 2408 | + if (!is_array($style_sheets)) { |
|
| 2409 | + $style_sheets = array($style_sheets); |
|
| 2410 | + } |
|
| 2278 | 2411 | |
| 2279 | - foreach ($style_sheets as $sheet) |
|
| 2280 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
| 2412 | + foreach ($style_sheets as $sheet) { |
|
| 2413 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
| 2414 | + } |
|
| 2281 | 2415 | } |
| 2282 | 2416 | |
| 2283 | 2417 | // No template to load? |
| 2284 | - if ($template_name === false) |
|
| 2285 | - return true; |
|
| 2418 | + if ($template_name === false) { |
|
| 2419 | + return true; |
|
| 2420 | + } |
|
| 2286 | 2421 | |
| 2287 | 2422 | $loaded = false; |
| 2288 | 2423 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2297,12 +2432,14 @@ discard block |
||
| 2297 | 2432 | |
| 2298 | 2433 | if ($loaded) |
| 2299 | 2434 | { |
| 2300 | - if ($db_show_debug === true) |
|
| 2301 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
| 2435 | + if ($db_show_debug === true) { |
|
| 2436 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
| 2437 | + } |
|
| 2302 | 2438 | |
| 2303 | 2439 | // If they have specified an initialization function for this template, go ahead and call it now. |
| 2304 | - if (function_exists('template_' . $template_name . '_init')) |
|
| 2305 | - call_user_func('template_' . $template_name . '_init'); |
|
| 2440 | + if (function_exists('template_' . $template_name . '_init')) { |
|
| 2441 | + call_user_func('template_' . $template_name . '_init'); |
|
| 2442 | + } |
|
| 2306 | 2443 | } |
| 2307 | 2444 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
| 2308 | 2445 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2322,13 +2459,14 @@ discard block |
||
| 2322 | 2459 | loadTemplate($template_name); |
| 2323 | 2460 | } |
| 2324 | 2461 | // Cause an error otherwise. |
| 2325 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
| 2326 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
| 2327 | - elseif ($fatal) |
|
| 2328 | - 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')); |
|
| 2329 | - else |
|
| 2330 | - return false; |
|
| 2331 | -} |
|
| 2462 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
| 2463 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
| 2464 | + } elseif ($fatal) { |
|
| 2465 | + 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')); |
|
| 2466 | + } else { |
|
| 2467 | + return false; |
|
| 2468 | + } |
|
| 2469 | + } |
|
| 2332 | 2470 | |
| 2333 | 2471 | /** |
| 2334 | 2472 | * Load a sub-template. |
@@ -2346,17 +2484,19 @@ discard block |
||
| 2346 | 2484 | { |
| 2347 | 2485 | global $context, $txt, $db_show_debug; |
| 2348 | 2486 | |
| 2349 | - if ($db_show_debug === true) |
|
| 2350 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
| 2487 | + if ($db_show_debug === true) { |
|
| 2488 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
| 2489 | + } |
|
| 2351 | 2490 | |
| 2352 | 2491 | // Figure out what the template function is named. |
| 2353 | 2492 | $theme_function = 'template_' . $sub_template_name; |
| 2354 | - if (function_exists($theme_function)) |
|
| 2355 | - $theme_function(); |
|
| 2356 | - elseif ($fatal === false) |
|
| 2357 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
| 2358 | - elseif ($fatal !== 'ignore') |
|
| 2359 | - 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')); |
|
| 2493 | + if (function_exists($theme_function)) { |
|
| 2494 | + $theme_function(); |
|
| 2495 | + } elseif ($fatal === false) { |
|
| 2496 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
| 2497 | + } elseif ($fatal !== 'ignore') { |
|
| 2498 | + 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')); |
|
| 2499 | + } |
|
| 2360 | 2500 | |
| 2361 | 2501 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
| 2362 | 2502 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2393,8 +2533,9 @@ discard block |
||
| 2393 | 2533 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
| 2394 | 2534 | |
| 2395 | 2535 | // If this is an external file, automatically set this to false. |
| 2396 | - if (!empty($params['external'])) |
|
| 2397 | - $params['minimize'] = false; |
|
| 2536 | + if (!empty($params['external'])) { |
|
| 2537 | + $params['minimize'] = false; |
|
| 2538 | + } |
|
| 2398 | 2539 | |
| 2399 | 2540 | // Account for shorthand like admin.css?alp21 filenames |
| 2400 | 2541 | $has_seed = strpos($fileName, '.css?'); |
@@ -2411,13 +2552,10 @@ discard block |
||
| 2411 | 2552 | { |
| 2412 | 2553 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2413 | 2554 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2555 | + } else { |
|
| 2556 | + $fileUrl = false; |
|
| 2414 | 2557 | } |
| 2415 | - |
|
| 2416 | - else |
|
| 2417 | - $fileUrl = false; |
|
| 2418 | - } |
|
| 2419 | - |
|
| 2420 | - else |
|
| 2558 | + } else |
|
| 2421 | 2559 | { |
| 2422 | 2560 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2423 | 2561 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2432,12 +2570,14 @@ discard block |
||
| 2432 | 2570 | } |
| 2433 | 2571 | |
| 2434 | 2572 | // Add it to the array for use in the template |
| 2435 | - if (!empty($fileName)) |
|
| 2436 | - $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2573 | + if (!empty($fileName)) { |
|
| 2574 | + $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2575 | + } |
|
| 2437 | 2576 | |
| 2438 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
| 2439 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
| 2440 | -} |
|
| 2577 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
| 2578 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
| 2579 | + } |
|
| 2580 | + } |
|
| 2441 | 2581 | |
| 2442 | 2582 | /** |
| 2443 | 2583 | * Add a block of inline css code to be executed later |
@@ -2454,8 +2594,9 @@ discard block |
||
| 2454 | 2594 | global $context; |
| 2455 | 2595 | |
| 2456 | 2596 | // Gotta add something... |
| 2457 | - if (empty($css)) |
|
| 2458 | - return false; |
|
| 2597 | + if (empty($css)) { |
|
| 2598 | + return false; |
|
| 2599 | + } |
|
| 2459 | 2600 | |
| 2460 | 2601 | $context['css_header'][] = $css; |
| 2461 | 2602 | } |
@@ -2490,8 +2631,9 @@ discard block |
||
| 2490 | 2631 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
| 2491 | 2632 | |
| 2492 | 2633 | // If this is an external file, automatically set this to false. |
| 2493 | - if (!empty($params['external'])) |
|
| 2494 | - $params['minimize'] = false; |
|
| 2634 | + if (!empty($params['external'])) { |
|
| 2635 | + $params['minimize'] = false; |
|
| 2636 | + } |
|
| 2495 | 2637 | |
| 2496 | 2638 | // Account for shorthand like admin.js?alp21 filenames |
| 2497 | 2639 | $has_seed = strpos($fileName, '.js?'); |
@@ -2508,16 +2650,12 @@ discard block |
||
| 2508 | 2650 | { |
| 2509 | 2651 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2510 | 2652 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2511 | - } |
|
| 2512 | - |
|
| 2513 | - else |
|
| 2653 | + } else |
|
| 2514 | 2654 | { |
| 2515 | 2655 | $fileUrl = false; |
| 2516 | 2656 | $filePath = false; |
| 2517 | 2657 | } |
| 2518 | - } |
|
| 2519 | - |
|
| 2520 | - else |
|
| 2658 | + } else |
|
| 2521 | 2659 | { |
| 2522 | 2660 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2523 | 2661 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2532,9 +2670,10 @@ discard block |
||
| 2532 | 2670 | } |
| 2533 | 2671 | |
| 2534 | 2672 | // Add it to the array for use in the template |
| 2535 | - if (!empty($fileName)) |
|
| 2536 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2537 | -} |
|
| 2673 | + if (!empty($fileName)) { |
|
| 2674 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2675 | + } |
|
| 2676 | + } |
|
| 2538 | 2677 | |
| 2539 | 2678 | /** |
| 2540 | 2679 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2548,9 +2687,10 @@ discard block |
||
| 2548 | 2687 | { |
| 2549 | 2688 | global $context; |
| 2550 | 2689 | |
| 2551 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
| 2552 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 2553 | -} |
|
| 2690 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
| 2691 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 2692 | + } |
|
| 2693 | + } |
|
| 2554 | 2694 | |
| 2555 | 2695 | /** |
| 2556 | 2696 | * Add a block of inline Javascript code to be executed later |
@@ -2567,8 +2707,9 @@ discard block |
||
| 2567 | 2707 | { |
| 2568 | 2708 | global $context; |
| 2569 | 2709 | |
| 2570 | - if (empty($javascript)) |
|
| 2571 | - return false; |
|
| 2710 | + if (empty($javascript)) { |
|
| 2711 | + return false; |
|
| 2712 | + } |
|
| 2572 | 2713 | |
| 2573 | 2714 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
| 2574 | 2715 | } |
@@ -2589,15 +2730,18 @@ discard block |
||
| 2589 | 2730 | static $already_loaded = array(); |
| 2590 | 2731 | |
| 2591 | 2732 | // Default to the user's language. |
| 2592 | - if ($lang == '') |
|
| 2593 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
| 2733 | + if ($lang == '') { |
|
| 2734 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
| 2735 | + } |
|
| 2594 | 2736 | |
| 2595 | 2737 | // Do we want the English version of language file as fallback? |
| 2596 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
| 2597 | - loadLanguage($template_name, 'english', false); |
|
| 2738 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
| 2739 | + loadLanguage($template_name, 'english', false); |
|
| 2740 | + } |
|
| 2598 | 2741 | |
| 2599 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
| 2600 | - return $lang; |
|
| 2742 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
| 2743 | + return $lang; |
|
| 2744 | + } |
|
| 2601 | 2745 | |
| 2602 | 2746 | // Make sure we have $settings - if not we're in trouble and need to find it! |
| 2603 | 2747 | if (empty($settings['default_theme_dir'])) |
@@ -2608,8 +2752,9 @@ discard block |
||
| 2608 | 2752 | |
| 2609 | 2753 | // What theme are we in? |
| 2610 | 2754 | $theme_name = basename($settings['theme_url']); |
| 2611 | - if (empty($theme_name)) |
|
| 2612 | - $theme_name = 'unknown'; |
|
| 2755 | + if (empty($theme_name)) { |
|
| 2756 | + $theme_name = 'unknown'; |
|
| 2757 | + } |
|
| 2613 | 2758 | |
| 2614 | 2759 | // For each file open it up and write it out! |
| 2615 | 2760 | foreach (explode('+', $template_name) as $template) |
@@ -2651,8 +2796,9 @@ discard block |
||
| 2651 | 2796 | $found = true; |
| 2652 | 2797 | |
| 2653 | 2798 | // setlocale is required for basename() & pathinfo() to work properly on the selected language |
| 2654 | - if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) |
|
| 2655 | - setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
| 2799 | + if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) { |
|
| 2800 | + setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
| 2801 | + } |
|
| 2656 | 2802 | |
| 2657 | 2803 | break; |
| 2658 | 2804 | } |
@@ -2692,8 +2838,9 @@ discard block |
||
| 2692 | 2838 | } |
| 2693 | 2839 | |
| 2694 | 2840 | // Keep track of what we're up to soldier. |
| 2695 | - if ($db_show_debug === true) |
|
| 2696 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
| 2841 | + if ($db_show_debug === true) { |
|
| 2842 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
| 2843 | + } |
|
| 2697 | 2844 | |
| 2698 | 2845 | // Remember what we have loaded, and in which language. |
| 2699 | 2846 | $already_loaded[$template_name] = $lang; |
@@ -2739,8 +2886,9 @@ discard block |
||
| 2739 | 2886 | ) |
| 2740 | 2887 | ); |
| 2741 | 2888 | // In the EXTREMELY unlikely event this happens, give an error message. |
| 2742 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
| 2743 | - fatal_lang_error('parent_not_found', 'critical'); |
|
| 2889 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
| 2890 | + fatal_lang_error('parent_not_found', 'critical'); |
|
| 2891 | + } |
|
| 2744 | 2892 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 2745 | 2893 | { |
| 2746 | 2894 | if (!isset($boards[$row['id_board']])) |
@@ -2757,8 +2905,8 @@ discard block |
||
| 2757 | 2905 | ); |
| 2758 | 2906 | } |
| 2759 | 2907 | // If a moderator exists for this board, add that moderator for all children too. |
| 2760 | - if (!empty($row['id_moderator'])) |
|
| 2761 | - foreach ($boards as $id => $dummy) |
|
| 2908 | + if (!empty($row['id_moderator'])) { |
|
| 2909 | + foreach ($boards as $id => $dummy) |
|
| 2762 | 2910 | { |
| 2763 | 2911 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
| 2764 | 2912 | 'id' => $row['id_moderator'], |
@@ -2766,11 +2914,12 @@ discard block |
||
| 2766 | 2914 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
| 2767 | 2915 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
| 2768 | 2916 | ); |
| 2917 | + } |
|
| 2769 | 2918 | } |
| 2770 | 2919 | |
| 2771 | 2920 | // If a moderator group exists for this board, add that moderator group for all children too |
| 2772 | - if (!empty($row['id_moderator_group'])) |
|
| 2773 | - foreach ($boards as $id => $dummy) |
|
| 2921 | + if (!empty($row['id_moderator_group'])) { |
|
| 2922 | + foreach ($boards as $id => $dummy) |
|
| 2774 | 2923 | { |
| 2775 | 2924 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
| 2776 | 2925 | 'id' => $row['id_moderator_group'], |
@@ -2778,6 +2927,7 @@ discard block |
||
| 2778 | 2927 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
| 2779 | 2928 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
| 2780 | 2929 | ); |
| 2930 | + } |
|
| 2781 | 2931 | } |
| 2782 | 2932 | } |
| 2783 | 2933 | $smcFunc['db_free_result']($result); |
@@ -2804,23 +2954,27 @@ discard block |
||
| 2804 | 2954 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
| 2805 | 2955 | { |
| 2806 | 2956 | // If we don't have our ucwords function defined yet, let's load the settings data. |
| 2807 | - if (empty($smcFunc['ucwords'])) |
|
| 2808 | - reloadSettings(); |
|
| 2957 | + if (empty($smcFunc['ucwords'])) { |
|
| 2958 | + reloadSettings(); |
|
| 2959 | + } |
|
| 2809 | 2960 | |
| 2810 | 2961 | // If we don't have our theme information yet, let's get it. |
| 2811 | - if (empty($settings['default_theme_dir'])) |
|
| 2812 | - loadTheme(0, false); |
|
| 2962 | + if (empty($settings['default_theme_dir'])) { |
|
| 2963 | + loadTheme(0, false); |
|
| 2964 | + } |
|
| 2813 | 2965 | |
| 2814 | 2966 | // Default language directories to try. |
| 2815 | 2967 | $language_directories = array( |
| 2816 | 2968 | $settings['default_theme_dir'] . '/languages', |
| 2817 | 2969 | ); |
| 2818 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
| 2819 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
| 2970 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
| 2971 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
| 2972 | + } |
|
| 2820 | 2973 | |
| 2821 | 2974 | // We possibly have a base theme directory. |
| 2822 | - if (!empty($settings['base_theme_dir'])) |
|
| 2823 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
| 2975 | + if (!empty($settings['base_theme_dir'])) { |
|
| 2976 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
| 2977 | + } |
|
| 2824 | 2978 | |
| 2825 | 2979 | // Remove any duplicates. |
| 2826 | 2980 | $language_directories = array_unique($language_directories); |
@@ -2834,20 +2988,21 @@ discard block |
||
| 2834 | 2988 | foreach ($language_directories as $language_dir) |
| 2835 | 2989 | { |
| 2836 | 2990 | // Can't look in here... doesn't exist! |
| 2837 | - if (!file_exists($language_dir)) |
|
| 2838 | - continue; |
|
| 2991 | + if (!file_exists($language_dir)) { |
|
| 2992 | + continue; |
|
| 2993 | + } |
|
| 2839 | 2994 | |
| 2840 | 2995 | $dir = dir($language_dir); |
| 2841 | 2996 | while ($entry = $dir->read()) |
| 2842 | 2997 | { |
| 2843 | 2998 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
| 2844 | - if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) |
|
| 2845 | - continue; |
|
| 2846 | - |
|
| 2847 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
| 2848 | - $langName = $langList[$matches[1]]; |
|
| 2999 | + if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) { |
|
| 3000 | + continue; |
|
| 3001 | + } |
|
| 2849 | 3002 | |
| 2850 | - else |
|
| 3003 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
| 3004 | + $langName = $langList[$matches[1]]; |
|
| 3005 | + } else |
|
| 2851 | 3006 | { |
| 2852 | 3007 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
| 2853 | 3008 | |
@@ -2888,12 +3043,14 @@ discard block |
||
| 2888 | 3043 | } |
| 2889 | 3044 | |
| 2890 | 3045 | // Do we need to store the lang list? |
| 2891 | - if (empty($langList)) |
|
| 2892 | - updateSettings(array('langList' => json_encode($catchLang))); |
|
| 3046 | + if (empty($langList)) { |
|
| 3047 | + updateSettings(array('langList' => json_encode($catchLang))); |
|
| 3048 | + } |
|
| 2893 | 3049 | |
| 2894 | 3050 | // Let's cash in on this deal. |
| 2895 | - if (!empty($modSettings['cache_enable'])) |
|
| 2896 | - cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
| 3051 | + if (!empty($modSettings['cache_enable'])) { |
|
| 3052 | + cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
| 3053 | + } |
|
| 2897 | 3054 | } |
| 2898 | 3055 | |
| 2899 | 3056 | return $context['languages']; |
@@ -2916,8 +3073,9 @@ discard block |
||
| 2916 | 3073 | global $modSettings, $options, $txt; |
| 2917 | 3074 | static $censor_vulgar = null, $censor_proper; |
| 2918 | 3075 | |
| 2919 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
| 2920 | - return $text; |
|
| 3076 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
| 3077 | + return $text; |
|
| 3078 | + } |
|
| 2921 | 3079 | |
| 2922 | 3080 | // If they haven't yet been loaded, load them. |
| 2923 | 3081 | if ($censor_vulgar == null) |
@@ -2945,9 +3103,9 @@ discard block |
||
| 2945 | 3103 | { |
| 2946 | 3104 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
| 2947 | 3105 | $text = $func($censor_vulgar, $censor_proper, $text); |
| 3106 | + } else { |
|
| 3107 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
| 2948 | 3108 | } |
| 2949 | - else |
|
| 2950 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
| 2951 | 3109 | |
| 2952 | 3110 | return $text; |
| 2953 | 3111 | } |
@@ -2973,38 +3131,42 @@ discard block |
||
| 2973 | 3131 | @ini_set('track_errors', '1'); |
| 2974 | 3132 | |
| 2975 | 3133 | // Don't include the file more than once, if $once is true. |
| 2976 | - if ($once && in_array($filename, $templates)) |
|
| 2977 | - return; |
|
| 3134 | + if ($once && in_array($filename, $templates)) { |
|
| 3135 | + return; |
|
| 3136 | + } |
|
| 2978 | 3137 | // Add this file to the include list, whether $once is true or not. |
| 2979 | - else |
|
| 2980 | - $templates[] = $filename; |
|
| 3138 | + else { |
|
| 3139 | + $templates[] = $filename; |
|
| 3140 | + } |
|
| 2981 | 3141 | |
| 2982 | 3142 | // Are we going to use eval? |
| 2983 | 3143 | if (empty($modSettings['disableTemplateEval'])) |
| 2984 | 3144 | { |
| 2985 | 3145 | $file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false; |
| 2986 | 3146 | $settings['current_include_filename'] = $filename; |
| 2987 | - } |
|
| 2988 | - else |
|
| 3147 | + } else |
|
| 2989 | 3148 | { |
| 2990 | 3149 | $file_found = file_exists($filename); |
| 2991 | 3150 | |
| 2992 | - if ($once && $file_found) |
|
| 2993 | - require_once($filename); |
|
| 2994 | - elseif ($file_found) |
|
| 2995 | - require($filename); |
|
| 3151 | + if ($once && $file_found) { |
|
| 3152 | + require_once($filename); |
|
| 3153 | + } elseif ($file_found) { |
|
| 3154 | + require($filename); |
|
| 3155 | + } |
|
| 2996 | 3156 | } |
| 2997 | 3157 | |
| 2998 | 3158 | if ($file_found !== true) |
| 2999 | 3159 | { |
| 3000 | 3160 | ob_end_clean(); |
| 3001 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 3002 | - @ob_start('ob_gzhandler'); |
|
| 3003 | - else |
|
| 3004 | - ob_start(); |
|
| 3161 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 3162 | + @ob_start('ob_gzhandler'); |
|
| 3163 | + } else { |
|
| 3164 | + ob_start(); |
|
| 3165 | + } |
|
| 3005 | 3166 | |
| 3006 | - if (isset($_GET['debug'])) |
|
| 3007 | - header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3167 | + if (isset($_GET['debug'])) { |
|
| 3168 | + header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3169 | + } |
|
| 3008 | 3170 | |
| 3009 | 3171 | // Don't cache error pages!! |
| 3010 | 3172 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3023,12 +3185,13 @@ discard block |
||
| 3023 | 3185 | echo '<!DOCTYPE html> |
| 3024 | 3186 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
| 3025 | 3187 | <head>'; |
| 3026 | - if (isset($context['character_set'])) |
|
| 3027 | - echo ' |
|
| 3188 | + if (isset($context['character_set'])) { |
|
| 3189 | + echo ' |
|
| 3028 | 3190 | <meta charset="', $context['character_set'], '">'; |
| 3191 | + } |
|
| 3029 | 3192 | |
| 3030 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
| 3031 | - echo ' |
|
| 3193 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
| 3194 | + echo ' |
|
| 3032 | 3195 | <title>', $mtitle, '</title> |
| 3033 | 3196 | </head> |
| 3034 | 3197 | <body> |
@@ -3036,8 +3199,8 @@ discard block |
||
| 3036 | 3199 | ', $mmessage, ' |
| 3037 | 3200 | </body> |
| 3038 | 3201 | </html>'; |
| 3039 | - elseif (!allowedTo('admin_forum')) |
|
| 3040 | - echo ' |
|
| 3202 | + } elseif (!allowedTo('admin_forum')) { |
|
| 3203 | + echo ' |
|
| 3041 | 3204 | <title>', $txt['template_parse_error'], '</title> |
| 3042 | 3205 | </head> |
| 3043 | 3206 | <body> |
@@ -3045,15 +3208,17 @@ discard block |
||
| 3045 | 3208 | ', $txt['template_parse_error_message'], ' |
| 3046 | 3209 | </body> |
| 3047 | 3210 | </html>'; |
| 3048 | - else |
|
| 3211 | + } else |
|
| 3049 | 3212 | { |
| 3050 | 3213 | require_once($sourcedir . '/Subs-Package.php'); |
| 3051 | 3214 | |
| 3052 | 3215 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
| 3053 | - if (empty($error) && ini_get('track_errors') && !empty($php_errormsg)) |
|
| 3054 | - $error = $php_errormsg; |
|
| 3055 | - if (empty($error)) |
|
| 3056 | - $error = $txt['template_parse_errmsg']; |
|
| 3216 | + if (empty($error) && ini_get('track_errors') && !empty($php_errormsg)) { |
|
| 3217 | + $error = $php_errormsg; |
|
| 3218 | + } |
|
| 3219 | + if (empty($error)) { |
|
| 3220 | + $error = $txt['template_parse_errmsg']; |
|
| 3221 | + } |
|
| 3057 | 3222 | |
| 3058 | 3223 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
| 3059 | 3224 | |
@@ -3064,11 +3229,12 @@ discard block |
||
| 3064 | 3229 | <h3>', $txt['template_parse_error'], '</h3> |
| 3065 | 3230 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
| 3066 | 3231 | |
| 3067 | - if (!empty($error)) |
|
| 3068 | - echo ' |
|
| 3232 | + if (!empty($error)) { |
|
| 3233 | + echo ' |
|
| 3069 | 3234 | <hr> |
| 3070 | 3235 | |
| 3071 | 3236 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
| 3237 | + } |
|
| 3072 | 3238 | |
| 3073 | 3239 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
| 3074 | 3240 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3078,10 +3244,11 @@ discard block |
||
| 3078 | 3244 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
| 3079 | 3245 | |
| 3080 | 3246 | // Fix the PHP code stuff... |
| 3081 | - if (!isBrowser('gecko')) |
|
| 3082 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
| 3083 | - else |
|
| 3084 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
| 3247 | + if (!isBrowser('gecko')) { |
|
| 3248 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
| 3249 | + } else { |
|
| 3250 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
| 3251 | + } |
|
| 3085 | 3252 | |
| 3086 | 3253 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
| 3087 | 3254 | $j = -1; |
@@ -3089,8 +3256,9 @@ discard block |
||
| 3089 | 3256 | { |
| 3090 | 3257 | $j++; |
| 3091 | 3258 | |
| 3092 | - if (substr_count($line, '<br>') == 0) |
|
| 3093 | - continue; |
|
| 3259 | + if (substr_count($line, '<br>') == 0) { |
|
| 3260 | + continue; |
|
| 3261 | + } |
|
| 3094 | 3262 | |
| 3095 | 3263 | $n = substr_count($line, '<br>'); |
| 3096 | 3264 | for ($i = 0; $i < $n; $i++) |
@@ -3109,38 +3277,42 @@ discard block |
||
| 3109 | 3277 | // Figure out what the color coding was before... |
| 3110 | 3278 | $line = max($match[1] - 9, 1); |
| 3111 | 3279 | $last_line = ''; |
| 3112 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
| 3113 | - if (strpos($data2[$line2], '<') !== false) |
|
| 3280 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
| 3281 | + if (strpos($data2[$line2], '<') !== false) |
|
| 3114 | 3282 | { |
| 3115 | 3283 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
| 3116 | 3284 | $last_line = $color_match[1]; |
| 3285 | + } |
|
| 3117 | 3286 | break; |
| 3118 | 3287 | } |
| 3119 | 3288 | |
| 3120 | 3289 | // Show the relevant lines... |
| 3121 | 3290 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
| 3122 | 3291 | { |
| 3123 | - if ($line == $match[1]) |
|
| 3124 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
| 3292 | + if ($line == $match[1]) { |
|
| 3293 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
| 3294 | + } |
|
| 3125 | 3295 | |
| 3126 | 3296 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
| 3127 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
| 3128 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
| 3297 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
| 3298 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
| 3299 | + } |
|
| 3129 | 3300 | |
| 3130 | 3301 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
| 3131 | 3302 | { |
| 3132 | 3303 | $last_line = $color_match[1]; |
| 3133 | 3304 | echo '</', substr($last_line, 1, 4), '>'; |
| 3305 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
| 3306 | + $last_line = ''; |
|
| 3307 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
| 3308 | + echo '</', substr($last_line, 1, 4), '>'; |
|
| 3134 | 3309 | } |
| 3135 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
| 3136 | - $last_line = ''; |
|
| 3137 | - elseif ($last_line != '' && $data2[$line] != '') |
|
| 3138 | - echo '</', substr($last_line, 1, 4), '>'; |
|
| 3139 | 3310 | |
| 3140 | - if ($line == $match[1]) |
|
| 3141 | - echo '</pre></div><pre style="margin: 0;">'; |
|
| 3142 | - else |
|
| 3143 | - echo "\n"; |
|
| 3311 | + if ($line == $match[1]) { |
|
| 3312 | + echo '</pre></div><pre style="margin: 0;">'; |
|
| 3313 | + } else { |
|
| 3314 | + echo "\n"; |
|
| 3315 | + } |
|
| 3144 | 3316 | } |
| 3145 | 3317 | |
| 3146 | 3318 | echo '</pre></div>'; |
@@ -3164,8 +3336,9 @@ discard block |
||
| 3164 | 3336 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port; |
| 3165 | 3337 | |
| 3166 | 3338 | // Figure out what type of database we are using. |
| 3167 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
| 3168 | - $db_type = 'mysql'; |
|
| 3339 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
| 3340 | + $db_type = 'mysql'; |
|
| 3341 | + } |
|
| 3169 | 3342 | |
| 3170 | 3343 | // Load the file for the database. |
| 3171 | 3344 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3173,8 +3346,9 @@ discard block |
||
| 3173 | 3346 | $db_options = array(); |
| 3174 | 3347 | |
| 3175 | 3348 | // Add in the port if needed |
| 3176 | - if (!empty($db_port)) |
|
| 3177 | - $db_options['port'] = $db_port; |
|
| 3349 | + if (!empty($db_port)) { |
|
| 3350 | + $db_options['port'] = $db_port; |
|
| 3351 | + } |
|
| 3178 | 3352 | |
| 3179 | 3353 | // 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. |
| 3180 | 3354 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3193,13 +3367,15 @@ discard block |
||
| 3193 | 3367 | } |
| 3194 | 3368 | |
| 3195 | 3369 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
| 3196 | - if (!$db_connection) |
|
| 3197 | - display_db_error(); |
|
| 3370 | + if (!$db_connection) { |
|
| 3371 | + display_db_error(); |
|
| 3372 | + } |
|
| 3198 | 3373 | |
| 3199 | 3374 | // If in SSI mode fix up the prefix. |
| 3200 | - if (SMF == 'SSI') |
|
| 3201 | - db_fix_prefix($db_prefix, $db_name); |
|
| 3202 | -} |
|
| 3375 | + if (SMF == 'SSI') { |
|
| 3376 | + db_fix_prefix($db_prefix, $db_name); |
|
| 3377 | + } |
|
| 3378 | + } |
|
| 3203 | 3379 | |
| 3204 | 3380 | /** |
| 3205 | 3381 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3213,10 +3389,11 @@ discard block |
||
| 3213 | 3389 | global $sourcedir, $cacheAPI, $cache_accelerator; |
| 3214 | 3390 | |
| 3215 | 3391 | // Not overriding this and we have a cacheAPI, send it back. |
| 3216 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
| 3217 | - return $cacheAPI; |
|
| 3218 | - elseif (is_null($cacheAPI)) |
|
| 3219 | - $cacheAPI = false; |
|
| 3392 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
| 3393 | + return $cacheAPI; |
|
| 3394 | + } elseif (is_null($cacheAPI)) { |
|
| 3395 | + $cacheAPI = false; |
|
| 3396 | + } |
|
| 3220 | 3397 | |
| 3221 | 3398 | // Make sure our class is in session. |
| 3222 | 3399 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3237,8 +3414,9 @@ discard block |
||
| 3237 | 3414 | if (!$testAPI->isSupported()) |
| 3238 | 3415 | { |
| 3239 | 3416 | // Can we save ourselves? |
| 3240 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
| 3241 | - return loadCacheAccelerator(null, false); |
|
| 3417 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
| 3418 | + return loadCacheAccelerator(null, false); |
|
| 3419 | + } |
|
| 3242 | 3420 | return false; |
| 3243 | 3421 | } |
| 3244 | 3422 | |
@@ -3250,9 +3428,9 @@ discard block |
||
| 3250 | 3428 | { |
| 3251 | 3429 | $cacheAPI = $testAPI; |
| 3252 | 3430 | return $cacheAPI; |
| 3431 | + } else { |
|
| 3432 | + return $testAPI; |
|
| 3253 | 3433 | } |
| 3254 | - else |
|
| 3255 | - return $testAPI; |
|
| 3256 | 3434 | } |
| 3257 | 3435 | } |
| 3258 | 3436 | |
@@ -3272,8 +3450,9 @@ discard block |
||
| 3272 | 3450 | |
| 3273 | 3451 | // @todo Why are we doing this if caching is disabled? |
| 3274 | 3452 | |
| 3275 | - if (function_exists('call_integration_hook')) |
|
| 3276 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
| 3453 | + if (function_exists('call_integration_hook')) { |
|
| 3454 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
| 3455 | + } |
|
| 3277 | 3456 | |
| 3278 | 3457 | /* Refresh the cache if either: |
| 3279 | 3458 | 1. Caching is disabled. |
@@ -3287,16 +3466,19 @@ discard block |
||
| 3287 | 3466 | require_once($sourcedir . '/' . $file); |
| 3288 | 3467 | $cache_block = call_user_func_array($function, $params); |
| 3289 | 3468 | |
| 3290 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
| 3291 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
| 3469 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
| 3470 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
| 3471 | + } |
|
| 3292 | 3472 | } |
| 3293 | 3473 | |
| 3294 | 3474 | // Some cached data may need a freshening up after retrieval. |
| 3295 | - if (!empty($cache_block['post_retri_eval'])) |
|
| 3296 | - eval($cache_block['post_retri_eval']); |
|
| 3475 | + if (!empty($cache_block['post_retri_eval'])) { |
|
| 3476 | + eval($cache_block['post_retri_eval']); |
|
| 3477 | + } |
|
| 3297 | 3478 | |
| 3298 | - if (function_exists('call_integration_hook')) |
|
| 3299 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
| 3479 | + if (function_exists('call_integration_hook')) { |
|
| 3480 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
| 3481 | + } |
|
| 3300 | 3482 | |
| 3301 | 3483 | return $cache_block['data']; |
| 3302 | 3484 | } |
@@ -3323,8 +3505,9 @@ discard block |
||
| 3323 | 3505 | global $cache_enable, $cacheAPI; |
| 3324 | 3506 | global $cache_hits, $cache_count, $db_show_debug; |
| 3325 | 3507 | |
| 3326 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
| 3327 | - return; |
|
| 3508 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
| 3509 | + return; |
|
| 3510 | + } |
|
| 3328 | 3511 | |
| 3329 | 3512 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
| 3330 | 3513 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3337,12 +3520,14 @@ discard block |
||
| 3337 | 3520 | $value = $value === null ? null : json_encode($value); |
| 3338 | 3521 | $cacheAPI->putData($key, $value, $ttl); |
| 3339 | 3522 | |
| 3340 | - if (function_exists('call_integration_hook')) |
|
| 3341 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
| 3523 | + if (function_exists('call_integration_hook')) { |
|
| 3524 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
| 3525 | + } |
|
| 3342 | 3526 | |
| 3343 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 3344 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 3345 | -} |
|
| 3527 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 3528 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 3529 | + } |
|
| 3530 | + } |
|
| 3346 | 3531 | |
| 3347 | 3532 | /** |
| 3348 | 3533 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3358,8 +3543,9 @@ discard block |
||
| 3358 | 3543 | global $cache_enable, $cacheAPI; |
| 3359 | 3544 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
| 3360 | 3545 | |
| 3361 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
| 3362 | - return; |
|
| 3546 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
| 3547 | + return; |
|
| 3548 | + } |
|
| 3363 | 3549 | |
| 3364 | 3550 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
| 3365 | 3551 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3379,16 +3565,18 @@ discard block |
||
| 3379 | 3565 | |
| 3380 | 3566 | if (empty($value)) |
| 3381 | 3567 | { |
| 3382 | - if (!is_array($cache_misses)) |
|
| 3383 | - $cache_misses = array(); |
|
| 3568 | + if (!is_array($cache_misses)) { |
|
| 3569 | + $cache_misses = array(); |
|
| 3570 | + } |
|
| 3384 | 3571 | |
| 3385 | 3572 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
| 3386 | 3573 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
| 3387 | 3574 | } |
| 3388 | 3575 | } |
| 3389 | 3576 | |
| 3390 | - if (function_exists('call_integration_hook') && isset($value)) |
|
| 3391 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
| 3577 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
| 3578 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
| 3579 | + } |
|
| 3392 | 3580 | |
| 3393 | 3581 | return empty($value) ? null : smf_json_decode($value, true); |
| 3394 | 3582 | } |
@@ -3410,8 +3598,9 @@ discard block |
||
| 3410 | 3598 | global $cacheAPI; |
| 3411 | 3599 | |
| 3412 | 3600 | // If we can't get to the API, can't do this. |
| 3413 | - if (empty($cacheAPI)) |
|
| 3414 | - return; |
|
| 3601 | + if (empty($cacheAPI)) { |
|
| 3602 | + return; |
|
| 3603 | + } |
|
| 3415 | 3604 | |
| 3416 | 3605 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
| 3417 | 3606 | $cacheAPI->cleanCache($type); |
@@ -3436,8 +3625,9 @@ discard block |
||
| 3436 | 3625 | global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $image_proxy_secret; |
| 3437 | 3626 | |
| 3438 | 3627 | // Come on! |
| 3439 | - if (empty($data)) |
|
| 3440 | - return array(); |
|
| 3628 | + if (empty($data)) { |
|
| 3629 | + return array(); |
|
| 3630 | + } |
|
| 3441 | 3631 | |
| 3442 | 3632 | // Set a nice default var. |
| 3443 | 3633 | $image = ''; |
@@ -3445,11 +3635,11 @@ discard block |
||
| 3445 | 3635 | // Gravatar has been set as mandatory! |
| 3446 | 3636 | if (!empty($modSettings['gravatarOverride'])) |
| 3447 | 3637 | { |
| 3448 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
| 3449 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3450 | - |
|
| 3451 | - else if (!empty($data['email'])) |
|
| 3452 | - $image = get_gravatar_url($data['email']); |
|
| 3638 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
| 3639 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3640 | + } else if (!empty($data['email'])) { |
|
| 3641 | + $image = get_gravatar_url($data['email']); |
|
| 3642 | + } |
|
| 3453 | 3643 | } |
| 3454 | 3644 | |
| 3455 | 3645 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3461,54 +3651,60 @@ discard block |
||
| 3461 | 3651 | // Gravatar. |
| 3462 | 3652 | if (stristr($data['avatar'], 'gravatar://')) |
| 3463 | 3653 | { |
| 3464 | - if ($data['avatar'] == 'gravatar://') |
|
| 3465 | - $image = get_gravatar_url($data['email']); |
|
| 3466 | - |
|
| 3467 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
| 3468 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3654 | + if ($data['avatar'] == 'gravatar://') { |
|
| 3655 | + $image = get_gravatar_url($data['email']); |
|
| 3656 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
| 3657 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3658 | + } |
|
| 3469 | 3659 | } |
| 3470 | 3660 | |
| 3471 | 3661 | // External url. |
| 3472 | 3662 | else |
| 3473 | 3663 | { |
| 3474 | 3664 | // Using ssl? |
| 3475 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) |
|
| 3476 | - $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
| 3665 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) { |
|
| 3666 | + $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
| 3667 | + } |
|
| 3477 | 3668 | |
| 3478 | 3669 | // Just a plain external url. |
| 3479 | - else |
|
| 3480 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
| 3670 | + else { |
|
| 3671 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
| 3672 | + } |
|
| 3481 | 3673 | } |
| 3482 | 3674 | } |
| 3483 | 3675 | |
| 3484 | 3676 | // Perhaps this user has an attachment as avatar... |
| 3485 | - else if (!empty($data['filename'])) |
|
| 3486 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
| 3677 | + else if (!empty($data['filename'])) { |
|
| 3678 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
| 3679 | + } |
|
| 3487 | 3680 | |
| 3488 | 3681 | // Right... no avatar... use our default image. |
| 3489 | - else |
|
| 3490 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 3682 | + else { |
|
| 3683 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 3684 | + } |
|
| 3491 | 3685 | } |
| 3492 | 3686 | |
| 3493 | 3687 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
| 3494 | 3688 | |
| 3495 | 3689 | // 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. |
| 3496 | - if (!empty($image)) |
|
| 3497 | - return array( |
|
| 3690 | + if (!empty($image)) { |
|
| 3691 | + return array( |
|
| 3498 | 3692 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
| 3499 | 3693 | 'image' => '<img class="avatar" src="' . $image . '" />', |
| 3500 | 3694 | 'href' => $image, |
| 3501 | 3695 | 'url' => $image, |
| 3502 | 3696 | ); |
| 3697 | + } |
|
| 3503 | 3698 | |
| 3504 | 3699 | // Fallback to make life easier for everyone... |
| 3505 | - else |
|
| 3506 | - return array( |
|
| 3700 | + else { |
|
| 3701 | + return array( |
|
| 3507 | 3702 | 'name' => '', |
| 3508 | 3703 | 'image' => '', |
| 3509 | 3704 | 'href' => '', |
| 3510 | 3705 | 'url' => '', |
| 3511 | 3706 | ); |
| 3512 | -} |
|
| 3707 | + } |
|
| 3708 | + } |
|
| 3513 | 3709 | |
| 3514 | 3710 | ?> |
| 3515 | 3711 | \ No newline at end of file |