@@ -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 $db_show_debug, $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 | * View the forum's error log. |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | global $scripturl, $txt, $context, $modSettings, $user_profile, $filter, $smcFunc; |
31 | 32 | |
32 | 33 | // Viewing contents of a file? |
33 | - if (isset($_GET['file'])) |
|
34 | - return ViewFile(); |
|
34 | + if (isset($_GET['file'])) { |
|
35 | + return ViewFile(); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // Check for the administrative permission to do this. |
37 | 39 | isAllowedTo('admin_forum'); |
@@ -85,8 +87,8 @@ discard block |
||
85 | 87 | ); |
86 | 88 | |
87 | 89 | // Set up the filtering... |
88 | - if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) |
|
89 | - $filter = array( |
|
90 | + if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) { |
|
91 | + $filter = array( |
|
90 | 92 | 'variable' => $_GET['filter'], |
91 | 93 | 'value' => array( |
92 | 94 | 'sql' => in_array($_GET['filter'], array('message', 'url', 'file')) ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : $smcFunc['db_escape_wildcard_string']($_GET['value']), |
@@ -94,10 +96,12 @@ discard block |
||
94 | 96 | 'href' => ';filter=' . $_GET['filter'] . ';value=' . $_GET['value'], |
95 | 97 | 'entity' => $filters[$_GET['filter']]['txt'] |
96 | 98 | ); |
99 | + } |
|
97 | 100 | |
98 | 101 | // Deleting, are we? |
99 | - if (isset($_POST['delall']) || isset($_POST['delete'])) |
|
100 | - deleteErrors(); |
|
102 | + if (isset($_POST['delall']) || isset($_POST['delete'])) { |
|
103 | + deleteErrors(); |
|
104 | + } |
|
101 | 105 | |
102 | 106 | // Just how many errors are there? |
103 | 107 | $result = $smcFunc['db_query']('', ' |
@@ -112,12 +116,14 @@ discard block |
||
112 | 116 | $smcFunc['db_free_result']($result); |
113 | 117 | |
114 | 118 | // If this filter is empty... |
115 | - if ($num_errors == 0 && isset($filter)) |
|
116 | - redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
119 | + if ($num_errors == 0 && isset($filter)) { |
|
120 | + redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
121 | + } |
|
117 | 122 | |
118 | 123 | // Clean up start. |
119 | - if (!isset($_GET['start']) || $_GET['start'] < 0) |
|
120 | - $_GET['start'] = 0; |
|
124 | + if (!isset($_GET['start']) || $_GET['start'] < 0) { |
|
125 | + $_GET['start'] = 0; |
|
126 | + } |
|
121 | 127 | |
122 | 128 | // Do we want to reverse error listing? |
123 | 129 | $context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up'; |
@@ -127,9 +133,9 @@ discard block |
||
127 | 133 | $context['start'] = $_GET['start']; |
128 | 134 | |
129 | 135 | // Update the error count |
130 | - if (!isset($filter)) |
|
131 | - $context['num_errors'] = $num_errors; |
|
132 | - else |
|
136 | + if (!isset($filter)) { |
|
137 | + $context['num_errors'] = $num_errors; |
|
138 | + } else |
|
133 | 139 | { |
134 | 140 | // We want all errors, not just the number of filtered messages... |
135 | 141 | $query = $smcFunc['db_query']('', ' |
@@ -161,8 +167,9 @@ discard block |
||
161 | 167 | for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i++) |
162 | 168 | { |
163 | 169 | $search_message = preg_replace('~<span class="remove">(.+?)</span>~', '%', $smcFunc['db_escape_wildcard_string']($row['message'])); |
164 | - if ($search_message == $filter['value']['sql']) |
|
165 | - $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
170 | + if ($search_message == $filter['value']['sql']) { |
|
171 | + $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
172 | + } |
|
166 | 173 | $show_message = strtr(strtr(preg_replace('~<span class="remove">(.+?)</span>~', '$1', $row['message']), array("\r" => '', '<br>' => "\n", '<' => '<', '>' => '>', '"' => '"')), array("\n" => '<br>')); |
167 | 174 | |
168 | 175 | $context['errors'][$row['id_error']] = array( |
@@ -221,8 +228,9 @@ discard block |
||
221 | 228 | 'members' => count($members), |
222 | 229 | ) |
223 | 230 | ); |
224 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
225 | - $members[$row['id_member']] = $row; |
|
231 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
232 | + $members[$row['id_member']] = $row; |
|
233 | + } |
|
226 | 234 | $smcFunc['db_free_result']($request); |
227 | 235 | |
228 | 236 | // This is a guest... |
@@ -254,20 +262,18 @@ discard block |
||
254 | 262 | $id = $filter['value']['sql']; |
255 | 263 | loadMemberData($id, false, 'minimal'); |
256 | 264 | $context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>'; |
257 | - } |
|
258 | - elseif ($filter['variable'] == 'url') |
|
259 | - $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
260 | - elseif ($filter['variable'] == 'message') |
|
265 | + } elseif ($filter['variable'] == 'url') { |
|
266 | + $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
267 | + } elseif ($filter['variable'] == 'message') |
|
261 | 268 | { |
262 | 269 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
263 | 270 | $context['filter']['value']['html'] = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $context['filter']['value']['html']); |
264 | - } |
|
265 | - elseif ($filter['variable'] == 'error_type') |
|
271 | + } elseif ($filter['variable'] == 'error_type') |
|
266 | 272 | { |
267 | 273 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
274 | + } else { |
|
275 | + $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
268 | 276 | } |
269 | - else |
|
270 | - $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
271 | 277 | } |
272 | 278 | |
273 | 279 | $context['error_types'] = array(); |
@@ -308,10 +314,11 @@ discard block |
||
308 | 314 | $context['error_types']['all']['label'] .= ' (' . $sum . ')'; |
309 | 315 | |
310 | 316 | // Finally, work out what is the last tab! |
311 | - if (isset($context['error_types'][$sum])) |
|
312 | - $context['error_types'][$sum]['is_last'] = true; |
|
313 | - else |
|
314 | - $context['error_types']['all']['is_last'] = true; |
|
317 | + if (isset($context['error_types'][$sum])) { |
|
318 | + $context['error_types'][$sum]['is_last'] = true; |
|
319 | + } else { |
|
320 | + $context['error_types']['all']['is_last'] = true; |
|
321 | + } |
|
315 | 322 | |
316 | 323 | // And this is pretty basic ;). |
317 | 324 | $context['page_title'] = $txt['errlog']; |
@@ -337,21 +344,23 @@ discard block |
||
337 | 344 | validateToken('admin-el'); |
338 | 345 | |
339 | 346 | // Delete all or just some? |
340 | - if (isset($_POST['delall']) && !isset($filter)) |
|
341 | - $smcFunc['db_query']('truncate_table', ' |
|
347 | + if (isset($_POST['delall']) && !isset($filter)) { |
|
348 | + $smcFunc['db_query']('truncate_table', ' |
|
342 | 349 | TRUNCATE {db_prefix}log_errors', |
343 | 350 | array( |
344 | 351 | ) |
345 | 352 | ); |
353 | + } |
|
346 | 354 | // Deleting all with a filter? |
347 | - elseif (isset($_POST['delall']) && isset($filter)) |
|
348 | - $smcFunc['db_query']('', ' |
|
355 | + elseif (isset($_POST['delall']) && isset($filter)) { |
|
356 | + $smcFunc['db_query']('', ' |
|
349 | 357 | DELETE FROM {db_prefix}log_errors |
350 | 358 | WHERE ' . $filter['variable'] . ' LIKE {string:filter}', |
351 | 359 | array( |
352 | 360 | 'filter' => $filter['value']['sql'], |
353 | 361 | ) |
354 | 362 | ); |
363 | + } |
|
355 | 364 | // Just specific errors? |
356 | 365 | elseif (!empty($_POST['delete'])) |
357 | 366 | { |
@@ -397,15 +406,17 @@ discard block |
||
397 | 406 | $line = isset($_REQUEST['line']) ? (int) $_REQUEST['line'] : 0; |
398 | 407 | |
399 | 408 | // Make sure the file we are looking for is one they are allowed to look at |
400 | - if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) |
|
401 | - fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
409 | + if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) { |
|
410 | + fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
411 | + } |
|
402 | 412 | |
403 | 413 | // get the min and max lines |
404 | 414 | $min = $line - 20 <= 0 ? 1 : $line - 20; |
405 | 415 | $max = $line + 21; // One additional line to make everything work out correctly |
406 | 416 | |
407 | - if ($max <= 0 || $min >= $max) |
|
408 | - fatal_lang_error('error_bad_line'); |
|
417 | + if ($max <= 0 || $min >= $max) { |
|
418 | + fatal_lang_error('error_bad_line'); |
|
419 | + } |
|
409 | 420 | |
410 | 421 | $file_data = explode('<br />', highlight_php_code($smcFunc['htmlspecialchars'](implode('', file($file))))); |
411 | 422 |
@@ -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 | * Sets and call a function based on the given subaction. Acts as a dispatcher function. |
@@ -54,8 +55,9 @@ discard block |
||
54 | 55 | ); |
55 | 56 | |
56 | 57 | // This comes under the umbrella of moderating posts. |
57 | - if ($context['report_type'] == 'members' || $user_info['mod_cache']['bq'] == '0=1') |
|
58 | - isAllowedTo('moderate_forum'); |
|
58 | + if ($context['report_type'] == 'members' || $user_info['mod_cache']['bq'] == '0=1') { |
|
59 | + isAllowedTo('moderate_forum'); |
|
60 | + } |
|
59 | 61 | |
60 | 62 | $subActions = array( |
61 | 63 | 'show' => 'ShowReports', |
@@ -70,11 +72,11 @@ discard block |
||
70 | 72 | call_integration_hook('integrate_reported_' . $context['report_type'], array(&$subActions)); |
71 | 73 | |
72 | 74 | // By default we call the open sub-action. |
73 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
74 | - $context['sub_action'] = $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_REQUEST['sa']), ENT_QUOTES); |
|
75 | - |
|
76 | - else |
|
77 | - $context['sub_action'] = 'show'; |
|
75 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
76 | + $context['sub_action'] = $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_REQUEST['sa']), ENT_QUOTES); |
|
77 | + } else { |
|
78 | + $context['sub_action'] = 'show'; |
|
79 | + } |
|
78 | 80 | |
79 | 81 | // Hi Ho Silver Away! |
80 | 82 | call_helper($subActions[$context['sub_action']]); |
@@ -116,11 +118,13 @@ discard block |
||
116 | 118 | |
117 | 119 | // All the ones to update... |
118 | 120 | $toClose = array(); |
119 | - foreach ($_POST['close'] as $rid) |
|
120 | - $toClose[] = (int) $rid; |
|
121 | + foreach ($_POST['close'] as $rid) { |
|
122 | + $toClose[] = (int) $rid; |
|
123 | + } |
|
121 | 124 | |
122 | - if (!empty($toClose)) |
|
123 | - updateReport('closed', 1, $toClose); |
|
125 | + if (!empty($toClose)) { |
|
126 | + updateReport('closed', 1, $toClose); |
|
127 | + } |
|
124 | 128 | |
125 | 129 | // Set the confirmation message. |
126 | 130 | $_SESSION['rc_confirmation'] = 'close_all'; |
@@ -175,8 +179,9 @@ discard block |
||
175 | 179 | global $context, $sourcedir, $scripturl, $txt; |
176 | 180 | |
177 | 181 | // Have to at least give us something to work with. |
178 | - if (empty($_REQUEST['rid'])) |
|
179 | - fatal_lang_error('mc_reportedp_none_found'); |
|
182 | + if (empty($_REQUEST['rid'])) { |
|
183 | + fatal_lang_error('mc_reportedp_none_found'); |
|
184 | + } |
|
180 | 185 | |
181 | 186 | // Integers only please |
182 | 187 | $report_id = (int) $_REQUEST['rid']; |
@@ -184,8 +189,9 @@ discard block |
||
184 | 189 | // Get the report details. |
185 | 190 | $report = getReportDetails($report_id); |
186 | 191 | |
187 | - if (!$report) |
|
188 | - fatal_lang_error('mc_no_modreport_found'); |
|
192 | + if (!$report) { |
|
193 | + fatal_lang_error('mc_no_modreport_found'); |
|
194 | + } |
|
189 | 195 | |
190 | 196 | // Build the report data - basic details first, then extra stuff based on the type |
191 | 197 | $context['report'] = array( |
@@ -211,8 +217,7 @@ discard block |
||
211 | 217 | 'href' => $scripturl . '?action=profile;u=' . $report['id_user'], |
212 | 218 | ), |
213 | 219 | ); |
214 | - } |
|
215 | - else |
|
220 | + } else |
|
216 | 221 | { |
217 | 222 | $extraDetails = array( |
218 | 223 | 'topic_id' => $report['id_topic'], |
@@ -235,8 +240,9 @@ discard block |
||
235 | 240 | |
236 | 241 | $reportComments = getReportComments($report_id); |
237 | 242 | |
238 | - if (!empty($reportComments)) |
|
239 | - $context['report'] = array_merge($context['report'], $reportComments); |
|
243 | + if (!empty($reportComments)) { |
|
244 | + $context['report'] = array_merge($context['report'], $reportComments); |
|
245 | + } |
|
240 | 246 | |
241 | 247 | // What have the other moderators done to this message? |
242 | 248 | require_once($sourcedir . '/Modlog.php'); |
@@ -257,8 +263,7 @@ discard block |
||
257 | 263 | 1, |
258 | 264 | true, |
259 | 265 | ); |
260 | - } |
|
261 | - else |
|
266 | + } else |
|
262 | 267 | { |
263 | 268 | $params = array( |
264 | 269 | 'lm.id_topic = {int:id_topic} |
@@ -358,16 +363,16 @@ discard block |
||
358 | 363 | createList($listOptions); |
359 | 364 | |
360 | 365 | // Make sure to get the correct tab selected. |
361 | - if ($context['report']['closed']) |
|
362 | - $context[$context['moderation_menu_name']]['current_subsection'] = 'closed'; |
|
366 | + if ($context['report']['closed']) { |
|
367 | + $context[$context['moderation_menu_name']]['current_subsection'] = 'closed'; |
|
368 | + } |
|
363 | 369 | |
364 | 370 | // Finally we are done :P |
365 | 371 | if ($context['report_type'] == 'members') |
366 | 372 | { |
367 | 373 | $context['page_title'] = sprintf($txt['mc_viewmemberreport'], $context['report']['user']['name']); |
368 | 374 | $context['sub_template'] = 'viewmemberreport'; |
369 | - } |
|
370 | - else |
|
375 | + } else |
|
371 | 376 | { |
372 | 377 | $context['page_title'] = sprintf($txt['mc_viewmodreport'], $context['report']['subject'], $context['report']['author']['name']); |
373 | 378 | $context['sub_template'] = 'viewmodreport'; |
@@ -390,8 +395,9 @@ discard block |
||
390 | 395 | global $smcFunc, $scripturl, $user_info, $context; |
391 | 396 | |
392 | 397 | // The report ID is a must. |
393 | - if (empty($_REQUEST['rid'])) |
|
394 | - fatal_lang_error('mc_reportedp_none_found'); |
|
398 | + if (empty($_REQUEST['rid'])) { |
|
399 | + fatal_lang_error('mc_reportedp_none_found'); |
|
400 | + } |
|
395 | 401 | |
396 | 402 | // Integers only please. |
397 | 403 | $report_id = (int) $_REQUEST['rid']; |
@@ -416,8 +422,9 @@ discard block |
||
416 | 422 | checkSession('get'); |
417 | 423 | validateToken('mod-reportC-delete', 'get'); |
418 | 424 | |
419 | - if (empty($_REQUEST['mid'])) |
|
420 | - fatal_lang_error('mc_reportedp_comment_none_found'); |
|
425 | + if (empty($_REQUEST['mid'])) { |
|
426 | + fatal_lang_error('mc_reportedp_comment_none_found'); |
|
427 | + } |
|
421 | 428 | |
422 | 429 | $comment_id = (int) $_REQUEST['mid']; |
423 | 430 | |
@@ -425,15 +432,17 @@ discard block |
||
425 | 432 | $comment = getCommentModDetails($comment_id); |
426 | 433 | |
427 | 434 | // Perhaps somebody else already deleted this fine gem... |
428 | - if (empty($comment)) |
|
429 | - fatal_lang_error('report_action_message_delete_issue'); |
|
435 | + if (empty($comment)) { |
|
436 | + fatal_lang_error('report_action_message_delete_issue'); |
|
437 | + } |
|
430 | 438 | |
431 | 439 | // Can you actually do this? |
432 | 440 | $comment_owner = $user_info['id'] == $comment['id_member']; |
433 | 441 | |
434 | 442 | // Nope! sorry. |
435 | - if (!allowedTo('admin_forum') && !$comment_owner) |
|
436 | - fatal_lang_error('report_action_message_delete_cannot'); |
|
443 | + if (!allowedTo('admin_forum') && !$comment_owner) { |
|
444 | + fatal_lang_error('report_action_message_delete_cannot'); |
|
445 | + } |
|
437 | 446 | |
438 | 447 | // All good! |
439 | 448 | deleteModComment($comment_id); |
@@ -458,11 +467,13 @@ discard block |
||
458 | 467 | checkSession(isset($_REQUEST['save']) ? 'post' : 'get'); |
459 | 468 | |
460 | 469 | // The report ID is a must. |
461 | - if (empty($_REQUEST['rid'])) |
|
462 | - fatal_lang_error('mc_reportedp_none_found'); |
|
470 | + if (empty($_REQUEST['rid'])) { |
|
471 | + fatal_lang_error('mc_reportedp_none_found'); |
|
472 | + } |
|
463 | 473 | |
464 | - if (empty($_REQUEST['mid'])) |
|
465 | - fatal_lang_error('mc_reportedp_comment_none_found'); |
|
474 | + if (empty($_REQUEST['mid'])) { |
|
475 | + fatal_lang_error('mc_reportedp_comment_none_found'); |
|
476 | + } |
|
466 | 477 | |
467 | 478 | // Integers only please. |
468 | 479 | $context['report_id'] = (int) $_REQUEST['rid']; |
@@ -470,8 +481,9 @@ discard block |
||
470 | 481 | |
471 | 482 | $context['comment'] = getCommentModDetails($context['comment_id']); |
472 | 483 | |
473 | - if (empty($context['comment'])) |
|
474 | - fatal_lang_error('mc_reportedp_comment_none_found'); |
|
484 | + if (empty($context['comment'])) { |
|
485 | + fatal_lang_error('mc_reportedp_comment_none_found'); |
|
486 | + } |
|
475 | 487 | |
476 | 488 | // Set up the comforting bits... |
477 | 489 | $context['page_title'] = $txt['mc_reported_posts']; |
@@ -482,15 +494,17 @@ discard block |
||
482 | 494 | validateToken('mod-reportC-edit'); |
483 | 495 | |
484 | 496 | // Make sure there is some data to edit on the DB. |
485 | - if (empty($context['comment'])) |
|
486 | - fatal_lang_error('report_action_message_edit_issue'); |
|
497 | + if (empty($context['comment'])) { |
|
498 | + fatal_lang_error('report_action_message_edit_issue'); |
|
499 | + } |
|
487 | 500 | |
488 | 501 | // Still there, good, now lets see if you can actually edit it... |
489 | 502 | $comment_owner = $user_info['id'] == $context['comment']['id_member']; |
490 | 503 | |
491 | 504 | // So, you aren't neither an admin or the comment owner huh? that's too bad. |
492 | - if (!allowedTo('admin_forum') && !$comment_owner) |
|
493 | - fatal_lang_error('report_action_message_edit_cannot'); |
|
505 | + if (!allowedTo('admin_forum') && !$comment_owner) { |
|
506 | + fatal_lang_error('report_action_message_edit_cannot'); |
|
507 | + } |
|
494 | 508 | |
495 | 509 | // All good! |
496 | 510 | $edited_comment = trim($smcFunc['htmlspecialchars']($_POST['mod_comment'])); |
@@ -516,8 +530,9 @@ discard block |
||
516 | 530 | checkSession('get'); |
517 | 531 | |
518 | 532 | // We need to do something! |
519 | - if (empty($_GET['rid']) && (!isset($_GET['ignore']) || !isset($_GET['closed']))) |
|
520 | - fatal_lang_error('mc_reportedp_none_found'); |
|
533 | + if (empty($_GET['rid']) && (!isset($_GET['ignore']) || !isset($_GET['closed']))) { |
|
534 | + fatal_lang_error('mc_reportedp_none_found'); |
|
535 | + } |
|
521 | 536 | |
522 | 537 | // What are we gonna do? |
523 | 538 | $action = isset($_GET['ignore']) ? 'ignore' : 'closed'; |
@@ -16,8 +16,9 @@ discard block |
||
16 | 16 | * @version 2.1 Beta 3 |
17 | 17 | */ |
18 | 18 | |
19 | -if (!defined('SMF')) |
|
19 | +if (!defined('SMF')) { |
|
20 | 20 | die('No direct access...'); |
21 | +} |
|
21 | 22 | |
22 | 23 | /** |
23 | 24 | * Reads a .tar.gz file, filename, in and extracts file(s) from it. |
@@ -67,47 +68,53 @@ discard block |
||
67 | 68 | loadLanguage('Packages'); |
68 | 69 | |
69 | 70 | // This function sorta needs gzinflate! |
70 | - if (!function_exists('gzinflate')) |
|
71 | - fatal_lang_error('package_no_zlib', 'critical'); |
|
71 | + if (!function_exists('gzinflate')) { |
|
72 | + fatal_lang_error('package_no_zlib', 'critical'); |
|
73 | + } |
|
72 | 74 | |
73 | 75 | if (substr($gzfilename, 0, 7) == 'http://' || substr($gzfilename, 0, 8) == 'https://') |
74 | 76 | { |
75 | 77 | $data = fetch_web_data($gzfilename); |
76 | 78 | |
77 | - if ($data === false) |
|
78 | - return false; |
|
79 | - } |
|
80 | - else |
|
79 | + if ($data === false) { |
|
80 | + return false; |
|
81 | + } |
|
82 | + } else |
|
81 | 83 | { |
82 | 84 | $data = @file_get_contents($gzfilename); |
83 | 85 | |
84 | - if ($data === false) |
|
85 | - return false; |
|
86 | + if ($data === false) { |
|
87 | + return false; |
|
88 | + } |
|
86 | 89 | } |
87 | 90 | |
88 | 91 | umask(0); |
89 | - if (!$single_file && $destination !== null && !file_exists($destination)) |
|
90 | - mktree($destination, 0777); |
|
92 | + if (!$single_file && $destination !== null && !file_exists($destination)) { |
|
93 | + mktree($destination, 0777); |
|
94 | + } |
|
91 | 95 | |
92 | 96 | // No signature? |
93 | - if (strlen($data) < 2) |
|
94 | - return false; |
|
97 | + if (strlen($data) < 2) { |
|
98 | + return false; |
|
99 | + } |
|
95 | 100 | |
96 | 101 | $id = unpack('H2a/H2b', substr($data, 0, 2)); |
97 | 102 | if (strtolower($id['a'] . $id['b']) != '1f8b') |
98 | 103 | { |
99 | 104 | // Okay, this ain't no tar.gz, but maybe it's a zip file. |
100 | - if (substr($data, 0, 2) == 'PK') |
|
101 | - return read_zip_file($gzfilename, $destination, $single_file, $overwrite, $files_to_extract); |
|
102 | - else |
|
103 | - return false; |
|
105 | + if (substr($data, 0, 2) == 'PK') { |
|
106 | + return read_zip_file($gzfilename, $destination, $single_file, $overwrite, $files_to_extract); |
|
107 | + } else { |
|
108 | + return false; |
|
109 | + } |
|
104 | 110 | } |
105 | 111 | |
106 | 112 | $flags = unpack('Ct/Cf', substr($data, 2, 2)); |
107 | 113 | |
108 | 114 | // Not deflate! |
109 | - if ($flags['t'] != 8) |
|
110 | - return false; |
|
115 | + if ($flags['t'] != 8) { |
|
116 | + return false; |
|
117 | + } |
|
111 | 118 | $flags = $flags['f']; |
112 | 119 | |
113 | 120 | $offset = 10; |
@@ -117,18 +124,21 @@ discard block |
||
117 | 124 | // @todo Might be mussed. |
118 | 125 | if ($flags & 12) |
119 | 126 | { |
120 | - while ($flags & 8 && $data{$offset++} != "\0") |
|
121 | - continue; |
|
122 | - while ($flags & 4 && $data{$offset++} != "\0") |
|
123 | - continue; |
|
127 | + while ($flags & 8 && $data{$offset++} != "\0") { |
|
128 | + continue; |
|
129 | + } |
|
130 | + while ($flags & 4 && $data{$offset++} != "\0") { |
|
131 | + continue; |
|
132 | + } |
|
124 | 133 | } |
125 | 134 | |
126 | 135 | $crc = unpack('Vcrc32/Visize', substr($data, strlen($data) - 8, 8)); |
127 | 136 | $data = @gzinflate(substr($data, $offset, strlen($data) - 8 - $offset)); |
128 | 137 | |
129 | 138 | // smf_crc32 and crc32 may not return the same results, so we accept either. |
130 | - if ($crc['crc32'] != smf_crc32($data) && $crc['crc32'] != crc32($data)) |
|
131 | - return false; |
|
139 | + if ($crc['crc32'] != smf_crc32($data) && $crc['crc32'] != crc32($data)) { |
|
140 | + return false; |
|
141 | + } |
|
132 | 142 | |
133 | 143 | $blocks = strlen($data) / 512 - 1; |
134 | 144 | $offset = 0; |
@@ -149,83 +159,98 @@ discard block |
||
149 | 159 | |
150 | 160 | foreach ($current as $k => $v) |
151 | 161 | { |
152 | - if (in_array($k, $octdec)) |
|
153 | - $current[$k] = octdec(trim($v)); |
|
154 | - else |
|
155 | - $current[$k] = trim($v); |
|
162 | + if (in_array($k, $octdec)) { |
|
163 | + $current[$k] = octdec(trim($v)); |
|
164 | + } else { |
|
165 | + $current[$k] = trim($v); |
|
166 | + } |
|
156 | 167 | } |
157 | 168 | |
158 | - if ($current['type'] == 5 && substr($current['filename'], -1) != '/') |
|
159 | - $current['filename'] .= '/'; |
|
169 | + if ($current['type'] == 5 && substr($current['filename'], -1) != '/') { |
|
170 | + $current['filename'] .= '/'; |
|
171 | + } |
|
160 | 172 | |
161 | 173 | $checksum = 256; |
162 | - for ($i = 0; $i < 148; $i++) |
|
163 | - $checksum += ord($header{$i}); |
|
164 | - for ($i = 156; $i < 512; $i++) |
|
165 | - $checksum += ord($header{$i}); |
|
174 | + for ($i = 0; $i < 148; $i++) { |
|
175 | + $checksum += ord($header{$i}); |
|
176 | + } |
|
177 | + for ($i = 156; $i < 512; $i++) { |
|
178 | + $checksum += ord($header{$i}); |
|
179 | + } |
|
166 | 180 | |
167 | - if ($current['checksum'] != $checksum) |
|
168 | - break; |
|
181 | + if ($current['checksum'] != $checksum) { |
|
182 | + break; |
|
183 | + } |
|
169 | 184 | |
170 | 185 | $size = ceil($current['size'] / 512); |
171 | 186 | $current['data'] = substr($data, ++$offset << 9, $current['size']); |
172 | 187 | $offset += $size; |
173 | 188 | |
174 | 189 | // Not a directory and doesn't exist already... |
175 | - if (substr($current['filename'], -1, 1) != '/' && !file_exists($destination . '/' . $current['filename'])) |
|
176 | - $write_this = true; |
|
190 | + if (substr($current['filename'], -1, 1) != '/' && !file_exists($destination . '/' . $current['filename'])) { |
|
191 | + $write_this = true; |
|
192 | + } |
|
177 | 193 | // File exists... check if it is newer. |
178 | - elseif (substr($current['filename'], -1, 1) != '/') |
|
179 | - $write_this = $overwrite || filemtime($destination . '/' . $current['filename']) < $current['mtime']; |
|
194 | + elseif (substr($current['filename'], -1, 1) != '/') { |
|
195 | + $write_this = $overwrite || filemtime($destination . '/' . $current['filename']) < $current['mtime']; |
|
196 | + } |
|
180 | 197 | // Folder... create. |
181 | 198 | elseif ($destination !== null && !$single_file) |
182 | 199 | { |
183 | 200 | // Protect from accidental parent directory writing... |
184 | 201 | $current['filename'] = strtr($current['filename'], array('../' => '', '/..' => '')); |
185 | 202 | |
186 | - if (!file_exists($destination . '/' . $current['filename'])) |
|
187 | - mktree($destination . '/' . $current['filename'], 0777); |
|
203 | + if (!file_exists($destination . '/' . $current['filename'])) { |
|
204 | + mktree($destination . '/' . $current['filename'], 0777); |
|
205 | + } |
|
188 | 206 | $write_this = false; |
207 | + } else { |
|
208 | + $write_this = false; |
|
189 | 209 | } |
190 | - else |
|
191 | - $write_this = false; |
|
192 | 210 | |
193 | 211 | if ($write_this && $destination !== null) |
194 | 212 | { |
195 | - if (strpos($current['filename'], '/') !== false && !$single_file) |
|
196 | - mktree($destination . '/' . dirname($current['filename']), 0777); |
|
213 | + if (strpos($current['filename'], '/') !== false && !$single_file) { |
|
214 | + mktree($destination . '/' . dirname($current['filename']), 0777); |
|
215 | + } |
|
197 | 216 | |
198 | 217 | // Is this the file we're looking for? |
199 | - if ($single_file && ($destination == $current['filename'] || $destination == '*/' . basename($current['filename']))) |
|
200 | - return $current['data']; |
|
218 | + if ($single_file && ($destination == $current['filename'] || $destination == '*/' . basename($current['filename']))) { |
|
219 | + return $current['data']; |
|
220 | + } |
|
201 | 221 | // If we're looking for another file, keep going. |
202 | - elseif ($single_file) |
|
203 | - continue; |
|
222 | + elseif ($single_file) { |
|
223 | + continue; |
|
224 | + } |
|
204 | 225 | // Looking for restricted files? |
205 | - elseif ($files_to_extract !== null && !in_array($current['filename'], $files_to_extract)) |
|
206 | - continue; |
|
226 | + elseif ($files_to_extract !== null && !in_array($current['filename'], $files_to_extract)) { |
|
227 | + continue; |
|
228 | + } |
|
207 | 229 | |
208 | 230 | package_put_contents($destination . '/' . $current['filename'], $current['data']); |
209 | 231 | } |
210 | 232 | |
211 | - if (substr($current['filename'], -1, 1) != '/') |
|
212 | - $return[] = array( |
|
233 | + if (substr($current['filename'], -1, 1) != '/') { |
|
234 | + $return[] = array( |
|
213 | 235 | 'filename' => $current['filename'], |
214 | 236 | 'md5' => md5($current['data']), |
215 | 237 | 'preview' => substr($current['data'], 0, 100), |
216 | 238 | 'size' => $current['size'], |
217 | 239 | 'skipped' => false |
218 | 240 | ); |
241 | + } |
|
219 | 242 | } |
220 | 243 | |
221 | - if ($destination !== null && !$single_file) |
|
222 | - package_flush_cache(); |
|
244 | + if ($destination !== null && !$single_file) { |
|
245 | + package_flush_cache(); |
|
246 | + } |
|
223 | 247 | |
224 | - if ($single_file) |
|
225 | - return false; |
|
226 | - else |
|
227 | - return $return; |
|
228 | -} |
|
248 | + if ($single_file) { |
|
249 | + return false; |
|
250 | + } else { |
|
251 | + return $return; |
|
252 | + } |
|
253 | + } |
|
229 | 254 | |
230 | 255 | /** |
231 | 256 | * Extract zip data. A functional copy of {@list read_zip_data()}. |
@@ -254,65 +279,74 @@ discard block |
||
254 | 279 | { |
255 | 280 | $i = $iterator->getSubPathname(); |
256 | 281 | // If this is a file, and it doesn't exist.... happy days! |
257 | - if (substr($i, -1) != '/' && !file_exists($destination . '/' . $i)) |
|
258 | - $write_this = true; |
|
282 | + if (substr($i, -1) != '/' && !file_exists($destination . '/' . $i)) { |
|
283 | + $write_this = true; |
|
284 | + } |
|
259 | 285 | // If the file exists, we may not want to overwrite it. |
260 | - elseif (substr($i, -1) != '/') |
|
261 | - $write_this = $overwrite; |
|
262 | - else |
|
263 | - $write_this = false; |
|
286 | + elseif (substr($i, -1) != '/') { |
|
287 | + $write_this = $overwrite; |
|
288 | + } else { |
|
289 | + $write_this = false; |
|
290 | + } |
|
264 | 291 | |
265 | 292 | // Get the actual compressed data. |
266 | - if (!$file_info->isDir()) |
|
267 | - $file_data = file_get_contents($file_info); |
|
268 | - elseif ($destination !== null && !$single_file) |
|
293 | + if (!$file_info->isDir()) { |
|
294 | + $file_data = file_get_contents($file_info); |
|
295 | + } elseif ($destination !== null && !$single_file) |
|
269 | 296 | { |
270 | 297 | // Folder... create. |
271 | - if (!file_exists($destination . '/' . $i)) |
|
272 | - mktree($destination . '/' . $i, 0777); |
|
298 | + if (!file_exists($destination . '/' . $i)) { |
|
299 | + mktree($destination . '/' . $i, 0777); |
|
300 | + } |
|
273 | 301 | $file_data = null; |
302 | + } else { |
|
303 | + $file_data = null; |
|
274 | 304 | } |
275 | - else |
|
276 | - $file_data = null; |
|
277 | 305 | |
278 | 306 | // Okay! We can write this file, looks good from here... |
279 | 307 | if ($write_this && $destination !== null) |
280 | 308 | { |
281 | - if (!$single_file && !is_dir($destination . '/' . dirname($i))) |
|
282 | - mktree($destination . '/' . dirname($i), 0777); |
|
309 | + if (!$single_file && !is_dir($destination . '/' . dirname($i))) { |
|
310 | + mktree($destination . '/' . dirname($i), 0777); |
|
311 | + } |
|
283 | 312 | |
284 | 313 | // If we're looking for a specific file, and this is it... ka-bam, baby. |
285 | - if ($single_file && ($destination == $i || $destination == '*/' . basename($i))) |
|
286 | - return $file_data; |
|
314 | + if ($single_file && ($destination == $i || $destination == '*/' . basename($i))) { |
|
315 | + return $file_data; |
|
316 | + } |
|
287 | 317 | // Oh? Another file. Fine. You don't like this file, do you? I know how it is. Yeah... just go away. No, don't apologize. I know this file's just not *good enough* for you. |
288 | - elseif ($single_file) |
|
289 | - continue; |
|
318 | + elseif ($single_file) { |
|
319 | + continue; |
|
320 | + } |
|
290 | 321 | // Don't really want this? |
291 | - elseif ($files_to_extract !== null && !in_array($i, $files_to_extract)) |
|
292 | - continue; |
|
322 | + elseif ($files_to_extract !== null && !in_array($i, $files_to_extract)) { |
|
323 | + continue; |
|
324 | + } |
|
293 | 325 | |
294 | 326 | package_put_contents($destination . '/' . $i, $file_data); |
295 | 327 | } |
296 | 328 | |
297 | - if (substr($i, -1, 1) != '/') |
|
298 | - $return[] = array( |
|
329 | + if (substr($i, -1, 1) != '/') { |
|
330 | + $return[] = array( |
|
299 | 331 | 'filename' => $i, |
300 | 332 | 'md5' => md5($file_data), |
301 | 333 | 'preview' => substr($file_data, 0, 100), |
302 | 334 | 'size' => strlen($file_data), |
303 | 335 | 'skipped' => false |
304 | 336 | ); |
337 | + } |
|
305 | 338 | } |
306 | 339 | |
307 | - if ($destination !== null && !$single_file) |
|
308 | - package_flush_cache(); |
|
340 | + if ($destination !== null && !$single_file) { |
|
341 | + package_flush_cache(); |
|
342 | + } |
|
309 | 343 | |
310 | - if ($single_file) |
|
311 | - return false; |
|
312 | - else |
|
313 | - return $return; |
|
314 | - } |
|
315 | - catch (Exception $e) |
|
344 | + if ($single_file) { |
|
345 | + return false; |
|
346 | + } else { |
|
347 | + return $return; |
|
348 | + } |
|
349 | + } catch (Exception $e) |
|
316 | 350 | { |
317 | 351 | return false; |
318 | 352 | } |
@@ -334,13 +368,15 @@ discard block |
||
334 | 368 | function read_zip_data($data, $destination, $single_file = false, $overwrite = false, $files_to_extract = null) |
335 | 369 | { |
336 | 370 | umask(0); |
337 | - if ($destination !== null && !file_exists($destination) && !$single_file) |
|
338 | - mktree($destination, 0777); |
|
371 | + if ($destination !== null && !file_exists($destination) && !$single_file) { |
|
372 | + mktree($destination, 0777); |
|
373 | + } |
|
339 | 374 | |
340 | 375 | // Look for the end of directory signature 0x06054b50 |
341 | 376 | $data_ecr = explode("\x50\x4b\x05\x06", $data); |
342 | - if (!isset($data_ecr[1])) |
|
343 | - return false; |
|
377 | + if (!isset($data_ecr[1])) { |
|
378 | + return false; |
|
379 | + } |
|
344 | 380 | |
345 | 381 | $return = array(); |
346 | 382 | |
@@ -355,8 +391,9 @@ discard block |
||
355 | 391 | array_shift($file_sections); |
356 | 392 | |
357 | 393 | // sections and count from the signature must match or the zip file is bad |
358 | - if (count($file_sections) != $zip_info['files']) |
|
359 | - return false; |
|
394 | + if (count($file_sections) != $zip_info['files']) { |
|
395 | + return false; |
|
396 | + } |
|
360 | 397 | |
361 | 398 | // go though each file in the archive |
362 | 399 | foreach ($file_sections as $data) |
@@ -378,68 +415,79 @@ discard block |
||
378 | 415 | } |
379 | 416 | |
380 | 417 | // If this is a file, and it doesn't exist.... happy days! |
381 | - if (substr($file_info['filename'], -1) != '/' && !file_exists($destination . '/' . $file_info['filename'])) |
|
382 | - $write_this = true; |
|
418 | + if (substr($file_info['filename'], -1) != '/' && !file_exists($destination . '/' . $file_info['filename'])) { |
|
419 | + $write_this = true; |
|
420 | + } |
|
383 | 421 | // If the file exists, we may not want to overwrite it. |
384 | - elseif (substr($file_info['filename'], -1) != '/') |
|
385 | - $write_this = $overwrite; |
|
422 | + elseif (substr($file_info['filename'], -1) != '/') { |
|
423 | + $write_this = $overwrite; |
|
424 | + } |
|
386 | 425 | // This is a directory, so we're gonna want to create it. (probably...) |
387 | 426 | elseif ($destination !== null && !$single_file) |
388 | 427 | { |
389 | 428 | // Just a little accident prevention, don't mind me. |
390 | 429 | $file_info['filename'] = strtr($file_info['filename'], array('../' => '', '/..' => '')); |
391 | 430 | |
392 | - if (!file_exists($destination . '/' . $file_info['filename'])) |
|
393 | - mktree($destination . '/' . $file_info['filename'], 0777); |
|
431 | + if (!file_exists($destination . '/' . $file_info['filename'])) { |
|
432 | + mktree($destination . '/' . $file_info['filename'], 0777); |
|
433 | + } |
|
394 | 434 | $write_this = false; |
435 | + } else { |
|
436 | + $write_this = false; |
|
395 | 437 | } |
396 | - else |
|
397 | - $write_this = false; |
|
398 | 438 | |
399 | 439 | // Get the actual compressed data. |
400 | 440 | $file_info['data'] = substr($data, 26 + $file_info['filename_length'] + $file_info['extrafield_length']); |
401 | 441 | |
402 | 442 | // Only inflate it if we need to ;) |
403 | - if (!empty($file_info['compress_method']) || ($file_info['compressed_size'] != $file_info['size'])) |
|
404 | - $file_info['data'] = gzinflate($file_info['data']); |
|
443 | + if (!empty($file_info['compress_method']) || ($file_info['compressed_size'] != $file_info['size'])) { |
|
444 | + $file_info['data'] = gzinflate($file_info['data']); |
|
445 | + } |
|
405 | 446 | |
406 | 447 | // Okay! We can write this file, looks good from here... |
407 | 448 | if ($write_this && $destination !== null) |
408 | 449 | { |
409 | - if ((strpos($file_info['filename'], '/') !== false && !$single_file) || (!$single_file && !is_dir($file_info['dir']))) |
|
410 | - mktree($file_info['dir'], 0777); |
|
450 | + if ((strpos($file_info['filename'], '/') !== false && !$single_file) || (!$single_file && !is_dir($file_info['dir']))) { |
|
451 | + mktree($file_info['dir'], 0777); |
|
452 | + } |
|
411 | 453 | |
412 | 454 | // If we're looking for a specific file, and this is it... ka-bam, baby. |
413 | - if ($single_file && ($destination == $file_info['filename'] || $destination == '*/' . basename($file_info['filename']))) |
|
414 | - return $file_info['data']; |
|
455 | + if ($single_file && ($destination == $file_info['filename'] || $destination == '*/' . basename($file_info['filename']))) { |
|
456 | + return $file_info['data']; |
|
457 | + } |
|
415 | 458 | // Oh? Another file. Fine. You don't like this file, do you? I know how it is. Yeah... just go away. No, don't apologize. I know this file's just not *good enough* for you. |
416 | - elseif ($single_file) |
|
417 | - continue; |
|
459 | + elseif ($single_file) { |
|
460 | + continue; |
|
461 | + } |
|
418 | 462 | // Don't really want this? |
419 | - elseif ($files_to_extract !== null && !in_array($file_info['filename'], $files_to_extract)) |
|
420 | - continue; |
|
463 | + elseif ($files_to_extract !== null && !in_array($file_info['filename'], $files_to_extract)) { |
|
464 | + continue; |
|
465 | + } |
|
421 | 466 | |
422 | 467 | package_put_contents($destination . '/' . $file_info['filename'], $file_info['data']); |
423 | 468 | } |
424 | 469 | |
425 | - if (substr($file_info['filename'], -1, 1) != '/') |
|
426 | - $return[] = array( |
|
470 | + if (substr($file_info['filename'], -1, 1) != '/') { |
|
471 | + $return[] = array( |
|
427 | 472 | 'filename' => $file_info['filename'], |
428 | 473 | 'md5' => md5($file_info['data']), |
429 | 474 | 'preview' => substr($file_info['data'], 0, 100), |
430 | 475 | 'size' => $file_info['size'], |
431 | 476 | 'skipped' => false |
432 | 477 | ); |
478 | + } |
|
433 | 479 | } |
434 | 480 | |
435 | - if ($destination !== null && !$single_file) |
|
436 | - package_flush_cache(); |
|
481 | + if ($destination !== null && !$single_file) { |
|
482 | + package_flush_cache(); |
|
483 | + } |
|
437 | 484 | |
438 | - if ($single_file) |
|
439 | - return false; |
|
440 | - else |
|
441 | - return $return; |
|
442 | -} |
|
485 | + if ($single_file) { |
|
486 | + return false; |
|
487 | + } else { |
|
488 | + return $return; |
|
489 | + } |
|
490 | + } |
|
443 | 491 | |
444 | 492 | /** |
445 | 493 | * Checks the existence of a remote file since file_exists() does not do remote. |
@@ -451,14 +499,16 @@ discard block |
||
451 | 499 | { |
452 | 500 | $a_url = parse_url($url); |
453 | 501 | |
454 | - if (!isset($a_url['scheme'])) |
|
455 | - return false; |
|
502 | + if (!isset($a_url['scheme'])) { |
|
503 | + return false; |
|
504 | + } |
|
456 | 505 | |
457 | 506 | // Attempt to connect... |
458 | 507 | $temp = ''; |
459 | 508 | $fid = fsockopen($a_url['host'], !isset($a_url['port']) ? 80 : $a_url['port'], $temp, $temp, 8); |
460 | - if (!$fid) |
|
461 | - return false; |
|
509 | + if (!$fid) { |
|
510 | + return false; |
|
511 | + } |
|
462 | 512 | |
463 | 513 | fputs($fid, 'HEAD ' . $a_url['path'] . ' HTTP/1.0' . "\r\n" . 'Host: ' . $a_url['host'] . "\r\n\r\n"); |
464 | 514 | $head = fread($fid, 1024); |
@@ -493,8 +543,9 @@ discard block |
||
493 | 543 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
494 | 544 | { |
495 | 545 | // Already found this? If so don't add it twice! |
496 | - if (in_array($row['package_id'], $found)) |
|
497 | - continue; |
|
546 | + if (in_array($row['package_id'], $found)) { |
|
547 | + continue; |
|
548 | + } |
|
498 | 549 | |
499 | 550 | $found[] = $row['package_id']; |
500 | 551 | |
@@ -529,19 +580,21 @@ discard block |
||
529 | 580 | global $sourcedir, $packagesdir, $smcFunc; |
530 | 581 | |
531 | 582 | // Extract package-info.xml from downloaded file. (*/ is used because it could be in any directory.) |
532 | - if (strpos($gzfilename, 'http://') !== false || strpos($gzfilename, 'https://') !== false) |
|
533 | - $packageInfo = read_tgz_data($gzfilename, 'package-info.xml', true); |
|
534 | - else |
|
583 | + if (strpos($gzfilename, 'http://') !== false || strpos($gzfilename, 'https://') !== false) { |
|
584 | + $packageInfo = read_tgz_data($gzfilename, 'package-info.xml', true); |
|
585 | + } else |
|
535 | 586 | { |
536 | - if (!file_exists($packagesdir . '/' . $gzfilename)) |
|
537 | - return 'package_get_error_not_found'; |
|
587 | + if (!file_exists($packagesdir . '/' . $gzfilename)) { |
|
588 | + return 'package_get_error_not_found'; |
|
589 | + } |
|
538 | 590 | |
539 | - if (is_file($packagesdir . '/' . $gzfilename)) |
|
540 | - $packageInfo = read_tgz_file($packagesdir . '/' . $gzfilename, '*/package-info.xml', true); |
|
541 | - elseif (file_exists($packagesdir . '/' . $gzfilename . '/package-info.xml')) |
|
542 | - $packageInfo = file_get_contents($packagesdir . '/' . $gzfilename . '/package-info.xml'); |
|
543 | - else |
|
544 | - return 'package_get_error_missing_xml'; |
|
591 | + if (is_file($packagesdir . '/' . $gzfilename)) { |
|
592 | + $packageInfo = read_tgz_file($packagesdir . '/' . $gzfilename, '*/package-info.xml', true); |
|
593 | + } elseif (file_exists($packagesdir . '/' . $gzfilename . '/package-info.xml')) { |
|
594 | + $packageInfo = file_get_contents($packagesdir . '/' . $gzfilename . '/package-info.xml'); |
|
595 | + } else { |
|
596 | + return 'package_get_error_missing_xml'; |
|
597 | + } |
|
545 | 598 | } |
546 | 599 | |
547 | 600 | // Nothing? |
@@ -549,10 +602,11 @@ discard block |
||
549 | 602 | { |
550 | 603 | // Perhaps they are trying to install a theme, lets tell them nicely this is the wrong function |
551 | 604 | $packageInfo = read_tgz_file($packagesdir . '/' . $gzfilename, '*/theme_info.xml', true); |
552 | - if (!empty($packageInfo)) |
|
553 | - return 'package_get_error_is_theme'; |
|
554 | - else |
|
555 | - return 'package_get_error_is_zero'; |
|
605 | + if (!empty($packageInfo)) { |
|
606 | + return 'package_get_error_is_theme'; |
|
607 | + } else { |
|
608 | + return 'package_get_error_is_zero'; |
|
609 | + } |
|
556 | 610 | } |
557 | 611 | |
558 | 612 | // Parse package-info.xml into an xmlArray. |
@@ -560,8 +614,9 @@ discard block |
||
560 | 614 | $packageInfo = new xmlArray($packageInfo); |
561 | 615 | |
562 | 616 | // @todo Error message of some sort? |
563 | - if (!$packageInfo->exists('package-info[0]')) |
|
564 | - return 'package_get_error_packageinfo_corrupt'; |
|
617 | + if (!$packageInfo->exists('package-info[0]')) { |
|
618 | + return 'package_get_error_packageinfo_corrupt'; |
|
619 | + } |
|
565 | 620 | |
566 | 621 | $packageInfo = $packageInfo->path('package-info[0]'); |
567 | 622 | |
@@ -580,8 +635,9 @@ discard block |
||
580 | 635 | } |
581 | 636 | } |
582 | 637 | |
583 | - if (!isset($package['type'])) |
|
584 | - $package['type'] = 'modification'; |
|
638 | + if (!isset($package['type'])) { |
|
639 | + $package['type'] = 'modification'; |
|
640 | + } |
|
585 | 641 | |
586 | 642 | return $package; |
587 | 643 | } |
@@ -634,15 +690,14 @@ discard block |
||
634 | 690 | { |
635 | 691 | $ftp_file = strtr($file, array($_SESSION['pack_ftp']['root'] => '')); |
636 | 692 | $package_ftp->chmod($ftp_file, $perms); |
693 | + } else { |
|
694 | + smf_chmod($file, $perms); |
|
637 | 695 | } |
638 | - else |
|
639 | - smf_chmod($file, $perms); |
|
640 | 696 | |
641 | 697 | $new_permissions = @fileperms($file); |
642 | 698 | $result = $new_permissions == $perms ? 'success' : 'failure'; |
643 | 699 | unset($_SESSION['pack_ftp']['original_perms'][$file]); |
644 | - } |
|
645 | - elseif ($do_change) |
|
700 | + } elseif ($do_change) |
|
646 | 701 | { |
647 | 702 | $new_permissions = ''; |
648 | 703 | $result = 'skipped'; |
@@ -758,8 +813,7 @@ discard block |
||
758 | 813 | |
759 | 814 | $context['sub_template'] = 'show_list'; |
760 | 815 | $context['default_list'] = 'restore_file_permissions'; |
761 | - } |
|
762 | - else |
|
816 | + } else |
|
763 | 817 | { |
764 | 818 | unset($listOptions['columns']['result']); |
765 | 819 | } |
@@ -769,12 +823,14 @@ discard block |
||
769 | 823 | createList($listOptions); |
770 | 824 | |
771 | 825 | // If we just restored permissions then whereever we are, we are now done and dusted. |
772 | - if (!empty($_POST['restore_perms'])) |
|
773 | - obExit(); |
|
826 | + if (!empty($_POST['restore_perms'])) { |
|
827 | + obExit(); |
|
828 | + } |
|
774 | 829 | } |
775 | 830 | // Otherwise, it's entirely irrelevant? |
776 | - elseif ($restore_write_status) |
|
777 | - return true; |
|
831 | + elseif ($restore_write_status) { |
|
832 | + return true; |
|
833 | + } |
|
778 | 834 | |
779 | 835 | // This is where we report what we got up to. |
780 | 836 | $return_data = array( |
@@ -812,11 +868,12 @@ discard block |
||
812 | 868 | if (!in_array($_POST['ftp_path'], array('', '/'))) |
813 | 869 | { |
814 | 870 | $ftp_root = strtr($boarddir, array($_POST['ftp_path'] => '')); |
815 | - if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || substr($_POST['ftp_path'], 0, 1) == '/')) |
|
816 | - $ftp_root = substr($ftp_root, 0, -1); |
|
871 | + if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || substr($_POST['ftp_path'], 0, 1) == '/')) { |
|
872 | + $ftp_root = substr($ftp_root, 0, -1); |
|
873 | + } |
|
874 | + } else { |
|
875 | + $ftp_root = $boarddir; |
|
817 | 876 | } |
818 | - else |
|
819 | - $ftp_root = $boarddir; |
|
820 | 877 | |
821 | 878 | $_SESSION['pack_ftp'] = array( |
822 | 879 | 'server' => $_POST['ftp_server'], |
@@ -828,8 +885,9 @@ discard block |
||
828 | 885 | 'connected' => true, |
829 | 886 | ); |
830 | 887 | |
831 | - if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path']) |
|
832 | - updateSettings(array('package_path' => $_POST['ftp_path'])); |
|
888 | + if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path']) { |
|
889 | + updateSettings(array('package_path' => $_POST['ftp_path'])); |
|
890 | + } |
|
833 | 891 | |
834 | 892 | // This is now the primary connection. |
835 | 893 | $package_ftp = $ftp; |
@@ -842,12 +900,13 @@ discard block |
||
842 | 900 | foreach ($chmodFiles as $k => $file) |
843 | 901 | { |
844 | 902 | // Sometimes this can somehow happen maybe? |
845 | - if (empty($file)) |
|
846 | - unset($chmodFiles[$k]); |
|
903 | + if (empty($file)) { |
|
904 | + unset($chmodFiles[$k]); |
|
905 | + } |
|
847 | 906 | // Already writable? |
848 | - elseif (@is_writable($file)) |
|
849 | - $return_data['files']['writable'][] = $file; |
|
850 | - else |
|
907 | + elseif (@is_writable($file)) { |
|
908 | + $return_data['files']['writable'][] = $file; |
|
909 | + } else |
|
851 | 910 | { |
852 | 911 | // Now try to change that. |
853 | 912 | $return_data['files'][package_chmod($file, 'writable', true) ? 'writable' : 'notwritable'][] = $file; |
@@ -864,19 +923,21 @@ discard block |
||
864 | 923 | { |
865 | 924 | require_once($sourcedir . '/Class-Package.php'); |
866 | 925 | $ftp = new ftp_connection(null); |
926 | + } elseif ($ftp->error !== false && !isset($ftp_error)) { |
|
927 | + $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
867 | 928 | } |
868 | - elseif ($ftp->error !== false && !isset($ftp_error)) |
|
869 | - $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
870 | 929 | |
871 | 930 | list ($username, $detect_path, $found_path) = $ftp->detect_path($boarddir); |
872 | 931 | |
873 | - if ($found_path) |
|
874 | - $_POST['ftp_path'] = $detect_path; |
|
875 | - elseif (!isset($_POST['ftp_path'])) |
|
876 | - $_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path; |
|
932 | + if ($found_path) { |
|
933 | + $_POST['ftp_path'] = $detect_path; |
|
934 | + } elseif (!isset($_POST['ftp_path'])) { |
|
935 | + $_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path; |
|
936 | + } |
|
877 | 937 | |
878 | - if (!isset($_POST['ftp_username'])) |
|
879 | - $_POST['ftp_username'] = $username; |
|
938 | + if (!isset($_POST['ftp_username'])) { |
|
939 | + $_POST['ftp_username'] = $username; |
|
940 | + } |
|
880 | 941 | } |
881 | 942 | |
882 | 943 | $context['package_ftp'] = array( |
@@ -889,8 +950,9 @@ discard block |
||
889 | 950 | ); |
890 | 951 | |
891 | 952 | // Which files failed? |
892 | - if (!isset($context['notwritable_files'])) |
|
893 | - $context['notwritable_files'] = array(); |
|
953 | + if (!isset($context['notwritable_files'])) { |
|
954 | + $context['notwritable_files'] = array(); |
|
955 | + } |
|
894 | 956 | $context['notwritable_files'] = array_merge($context['notwritable_files'], $return_data['files']['notwritable']); |
895 | 957 | |
896 | 958 | // Sent here to die? |
@@ -923,40 +985,48 @@ discard block |
||
923 | 985 | foreach ($files as $k => $file) |
924 | 986 | { |
925 | 987 | // If this file doesn't exist, then we actually want to look at the directory, no? |
926 | - if (!file_exists($file)) |
|
927 | - $file = dirname($file); |
|
988 | + if (!file_exists($file)) { |
|
989 | + $file = dirname($file); |
|
990 | + } |
|
928 | 991 | |
929 | 992 | // This looks odd, but it's an attempt to work around PHP suExec. |
930 | - if (!@is_writable($file)) |
|
931 | - smf_chmod($file, 0755); |
|
932 | - if (!@is_writable($file)) |
|
933 | - smf_chmod($file, 0777); |
|
934 | - if (!@is_writable(dirname($file))) |
|
935 | - smf_chmod($file, 0755); |
|
936 | - if (!@is_writable(dirname($file))) |
|
937 | - smf_chmod($file, 0777); |
|
993 | + if (!@is_writable($file)) { |
|
994 | + smf_chmod($file, 0755); |
|
995 | + } |
|
996 | + if (!@is_writable($file)) { |
|
997 | + smf_chmod($file, 0777); |
|
998 | + } |
|
999 | + if (!@is_writable(dirname($file))) { |
|
1000 | + smf_chmod($file, 0755); |
|
1001 | + } |
|
1002 | + if (!@is_writable(dirname($file))) { |
|
1003 | + smf_chmod($file, 0777); |
|
1004 | + } |
|
938 | 1005 | |
939 | 1006 | $fp = is_dir($file) ? @opendir($file) : @fopen($file, 'rb'); |
940 | 1007 | if (@is_writable($file) && $fp) |
941 | 1008 | { |
942 | 1009 | unset($files[$k]); |
943 | - if (!is_dir($file)) |
|
944 | - fclose($fp); |
|
945 | - else |
|
946 | - closedir($fp); |
|
1010 | + if (!is_dir($file)) { |
|
1011 | + fclose($fp); |
|
1012 | + } else { |
|
1013 | + closedir($fp); |
|
1014 | + } |
|
947 | 1015 | } |
948 | 1016 | } |
949 | 1017 | |
950 | 1018 | // No FTP required! |
951 | - if (empty($files)) |
|
952 | - return array(); |
|
1019 | + if (empty($files)) { |
|
1020 | + return array(); |
|
1021 | + } |
|
953 | 1022 | } |
954 | 1023 | |
955 | 1024 | // They've opted to not use FTP, and try anyway. |
956 | 1025 | if (isset($_SESSION['pack_ftp']) && $_SESSION['pack_ftp'] == false) |
957 | 1026 | { |
958 | - if ($files === null) |
|
959 | - return array(); |
|
1027 | + if ($files === null) { |
|
1028 | + return array(); |
|
1029 | + } |
|
960 | 1030 | |
961 | 1031 | foreach ($files as $k => $file) |
962 | 1032 | { |
@@ -968,26 +1038,29 @@ discard block |
||
968 | 1038 | smf_chmod($file, 0755); |
969 | 1039 | } |
970 | 1040 | |
971 | - if (!@is_writable($file)) |
|
972 | - smf_chmod($file, 0777); |
|
973 | - if (!@is_writable(dirname($file))) |
|
974 | - smf_chmod(dirname($file), 0777); |
|
1041 | + if (!@is_writable($file)) { |
|
1042 | + smf_chmod($file, 0777); |
|
1043 | + } |
|
1044 | + if (!@is_writable(dirname($file))) { |
|
1045 | + smf_chmod(dirname($file), 0777); |
|
1046 | + } |
|
975 | 1047 | |
976 | - if (@is_writable($file)) |
|
977 | - unset($files[$k]); |
|
1048 | + if (@is_writable($file)) { |
|
1049 | + unset($files[$k]); |
|
1050 | + } |
|
978 | 1051 | } |
979 | 1052 | |
980 | 1053 | return $files; |
981 | - } |
|
982 | - elseif (isset($_SESSION['pack_ftp'])) |
|
1054 | + } elseif (isset($_SESSION['pack_ftp'])) |
|
983 | 1055 | { |
984 | 1056 | // Load the file containing the ftp_connection class. |
985 | 1057 | require_once($sourcedir . '/Class-Package.php'); |
986 | 1058 | |
987 | 1059 | $package_ftp = new ftp_connection($_SESSION['pack_ftp']['server'], $_SESSION['pack_ftp']['port'], $_SESSION['pack_ftp']['username'], package_crypt($_SESSION['pack_ftp']['password'])); |
988 | 1060 | |
989 | - if ($files === null) |
|
990 | - return array(); |
|
1061 | + if ($files === null) { |
|
1062 | + return array(); |
|
1063 | + } |
|
991 | 1064 | |
992 | 1065 | foreach ($files as $k => $file) |
993 | 1066 | { |
@@ -1001,13 +1074,16 @@ discard block |
||
1001 | 1074 | $package_ftp->chmod($ftp_file, 0755); |
1002 | 1075 | } |
1003 | 1076 | |
1004 | - if (!@is_writable($file)) |
|
1005 | - $package_ftp->chmod($ftp_file, 0777); |
|
1006 | - if (!@is_writable(dirname($file))) |
|
1007 | - $package_ftp->chmod(dirname($ftp_file), 0777); |
|
1077 | + if (!@is_writable($file)) { |
|
1078 | + $package_ftp->chmod($ftp_file, 0777); |
|
1079 | + } |
|
1080 | + if (!@is_writable(dirname($file))) { |
|
1081 | + $package_ftp->chmod(dirname($ftp_file), 0777); |
|
1082 | + } |
|
1008 | 1083 | |
1009 | - if (@is_writable($file)) |
|
1010 | - unset($files[$k]); |
|
1084 | + if (@is_writable($file)) { |
|
1085 | + unset($files[$k]); |
|
1086 | + } |
|
1011 | 1087 | } |
1012 | 1088 | |
1013 | 1089 | return $files; |
@@ -1019,8 +1095,7 @@ discard block |
||
1019 | 1095 | |
1020 | 1096 | $files = packageRequireFTP($destination_url, $files, $return); |
1021 | 1097 | return $files; |
1022 | - } |
|
1023 | - elseif (isset($_POST['ftp_username'])) |
|
1098 | + } elseif (isset($_POST['ftp_username'])) |
|
1024 | 1099 | { |
1025 | 1100 | require_once($sourcedir . '/Class-Package.php'); |
1026 | 1101 | $ftp = new ftp_connection($_POST['ftp_server'], $_POST['ftp_port'], $_POST['ftp_username'], $_POST['ftp_password']); |
@@ -1042,19 +1117,21 @@ discard block |
||
1042 | 1117 | { |
1043 | 1118 | require_once($sourcedir . '/Class-Package.php'); |
1044 | 1119 | $ftp = new ftp_connection(null); |
1120 | + } elseif ($ftp->error !== false && !isset($ftp_error)) { |
|
1121 | + $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
1045 | 1122 | } |
1046 | - elseif ($ftp->error !== false && !isset($ftp_error)) |
|
1047 | - $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
1048 | 1123 | |
1049 | 1124 | list ($username, $detect_path, $found_path) = $ftp->detect_path($boarddir); |
1050 | 1125 | |
1051 | - if ($found_path) |
|
1052 | - $_POST['ftp_path'] = $detect_path; |
|
1053 | - elseif (!isset($_POST['ftp_path'])) |
|
1054 | - $_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path; |
|
1126 | + if ($found_path) { |
|
1127 | + $_POST['ftp_path'] = $detect_path; |
|
1128 | + } elseif (!isset($_POST['ftp_path'])) { |
|
1129 | + $_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path; |
|
1130 | + } |
|
1055 | 1131 | |
1056 | - if (!isset($_POST['ftp_username'])) |
|
1057 | - $_POST['ftp_username'] = $username; |
|
1132 | + if (!isset($_POST['ftp_username'])) { |
|
1133 | + $_POST['ftp_username'] = $username; |
|
1134 | + } |
|
1058 | 1135 | |
1059 | 1136 | $context['package_ftp'] = array( |
1060 | 1137 | 'server' => isset($_POST['ftp_server']) ? $_POST['ftp_server'] : (isset($modSettings['package_server']) ? $modSettings['package_server'] : 'localhost'), |
@@ -1066,23 +1143,24 @@ discard block |
||
1066 | 1143 | ); |
1067 | 1144 | |
1068 | 1145 | // If we're returning dump out here. |
1069 | - if ($return) |
|
1070 | - return $files; |
|
1146 | + if ($return) { |
|
1147 | + return $files; |
|
1148 | + } |
|
1071 | 1149 | |
1072 | 1150 | $context['page_title'] = $txt['package_ftp_necessary']; |
1073 | 1151 | $context['sub_template'] = 'ftp_required'; |
1074 | 1152 | obExit(); |
1075 | - } |
|
1076 | - else |
|
1153 | + } else |
|
1077 | 1154 | { |
1078 | 1155 | if (!in_array($_POST['ftp_path'], array('', '/'))) |
1079 | 1156 | { |
1080 | 1157 | $ftp_root = strtr($boarddir, array($_POST['ftp_path'] => '')); |
1081 | - if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || $_POST['ftp_path'][0] == '/')) |
|
1082 | - $ftp_root = substr($ftp_root, 0, -1); |
|
1158 | + if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || $_POST['ftp_path'][0] == '/')) { |
|
1159 | + $ftp_root = substr($ftp_root, 0, -1); |
|
1160 | + } |
|
1161 | + } else { |
|
1162 | + $ftp_root = $boarddir; |
|
1083 | 1163 | } |
1084 | - else |
|
1085 | - $ftp_root = $boarddir; |
|
1086 | 1164 | |
1087 | 1165 | $_SESSION['pack_ftp'] = array( |
1088 | 1166 | 'server' => $_POST['ftp_server'], |
@@ -1093,8 +1171,9 @@ discard block |
||
1093 | 1171 | 'root' => $ftp_root, |
1094 | 1172 | ); |
1095 | 1173 | |
1096 | - if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path']) |
|
1097 | - updateSettings(array('package_path' => $_POST['ftp_path'])); |
|
1174 | + if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path']) { |
|
1175 | + updateSettings(array('package_path' => $_POST['ftp_path'])); |
|
1176 | + } |
|
1098 | 1177 | |
1099 | 1178 | $files = packageRequireFTP($destination_url, $files, $return); |
1100 | 1179 | } |
@@ -1122,16 +1201,18 @@ discard block |
||
1122 | 1201 | global $packagesdir, $forum_version, $context, $temp_path, $language, $smcFunc; |
1123 | 1202 | |
1124 | 1203 | // Mayday! That action doesn't exist!! |
1125 | - if (empty($packageXML) || !$packageXML->exists($method)) |
|
1126 | - return array(); |
|
1204 | + if (empty($packageXML) || !$packageXML->exists($method)) { |
|
1205 | + return array(); |
|
1206 | + } |
|
1127 | 1207 | |
1128 | 1208 | // We haven't found the package script yet... |
1129 | 1209 | $script = false; |
1130 | 1210 | $the_version = strtr($forum_version, array('SMF ' => '')); |
1131 | 1211 | |
1132 | 1212 | // Emulation support... |
1133 | - if (!empty($_SESSION['version_emulate'])) |
|
1134 | - $the_version = $_SESSION['version_emulate']; |
|
1213 | + if (!empty($_SESSION['version_emulate'])) { |
|
1214 | + $the_version = $_SESSION['version_emulate']; |
|
1215 | + } |
|
1135 | 1216 | |
1136 | 1217 | // Single package emulation |
1137 | 1218 | if (!empty($_REQUEST['ve']) && !empty($_REQUEST['package'])) |
@@ -1139,8 +1220,9 @@ discard block |
||
1139 | 1220 | $the_version = $_REQUEST['ve']; |
1140 | 1221 | $_SESSION['single_version_emulate'][$_REQUEST['package']] = $the_version; |
1141 | 1222 | } |
1142 | - if (!empty($_REQUEST['package']) && (!empty($_SESSION['single_version_emulate'][$_REQUEST['package']]))) |
|
1143 | - $the_version = $_SESSION['single_version_emulate'][$_REQUEST['package']]; |
|
1223 | + if (!empty($_REQUEST['package']) && (!empty($_SESSION['single_version_emulate'][$_REQUEST['package']]))) { |
|
1224 | + $the_version = $_SESSION['single_version_emulate'][$_REQUEST['package']]; |
|
1225 | + } |
|
1144 | 1226 | |
1145 | 1227 | // Get all the versions of this method and find the right one. |
1146 | 1228 | $these_methods = $packageXML->set($method); |
@@ -1150,16 +1232,18 @@ discard block |
||
1150 | 1232 | if ($this_method->exists('@for')) |
1151 | 1233 | { |
1152 | 1234 | // Don't keep going if this won't work for this version of SMF. |
1153 | - if (!matchPackageVersion($the_version, $this_method->fetch('@for'))) |
|
1154 | - continue; |
|
1235 | + if (!matchPackageVersion($the_version, $this_method->fetch('@for'))) { |
|
1236 | + continue; |
|
1237 | + } |
|
1155 | 1238 | } |
1156 | 1239 | |
1157 | 1240 | // Upgrades may go from a certain old version of the mod. |
1158 | 1241 | if ($method == 'upgrade' && $this_method->exists('@from')) |
1159 | 1242 | { |
1160 | 1243 | // Well, this is for the wrong old version... |
1161 | - if (!matchPackageVersion($previous_version, $this_method->fetch('@from'))) |
|
1162 | - continue; |
|
1244 | + if (!matchPackageVersion($previous_version, $this_method->fetch('@from'))) { |
|
1245 | + continue; |
|
1246 | + } |
|
1163 | 1247 | } |
1164 | 1248 | |
1165 | 1249 | // We've found it! |
@@ -1168,8 +1252,9 @@ discard block |
||
1168 | 1252 | } |
1169 | 1253 | |
1170 | 1254 | // Bad news, a matching script wasn't found! |
1171 | - if ($script === false) |
|
1172 | - return array(); |
|
1255 | + if ($script === false) { |
|
1256 | + return array(); |
|
1257 | + } |
|
1173 | 1258 | |
1174 | 1259 | // Find all the actions in this method - in theory, these should only be allowed actions. (* means all.) |
1175 | 1260 | $actions = $script->set('*'); |
@@ -1198,12 +1283,12 @@ discard block |
||
1198 | 1283 | if ((isset($_REQUEST['readme']) && $action->fetch('@lang') == $_REQUEST['readme']) || (isset($_REQUEST['license']) && $action->fetch('@lang') == $_REQUEST['license']) || (!isset($_REQUEST['readme']) && $action->fetch('@lang') == $language) || (!isset($_REQUEST['license']) && $action->fetch('@lang') == $language)) |
1199 | 1284 | { |
1200 | 1285 | // In case the user put the blocks in the wrong order. |
1201 | - if (isset($context[$type]['selected']) && $context[$type]['selected'] == 'default') |
|
1202 | - $context[$type][] = 'default'; |
|
1286 | + if (isset($context[$type]['selected']) && $context[$type]['selected'] == 'default') { |
|
1287 | + $context[$type][] = 'default'; |
|
1288 | + } |
|
1203 | 1289 | |
1204 | 1290 | $context[$type]['selected'] = $smcFunc['htmlspecialchars']($action->fetch('@lang')); |
1205 | - } |
|
1206 | - else |
|
1291 | + } else |
|
1207 | 1292 | { |
1208 | 1293 | // We don't want this now, but we'll allow the user to select to read it. |
1209 | 1294 | $context[$type][] = $smcFunc['htmlspecialchars']($action->fetch('@lang')); |
@@ -1218,9 +1303,9 @@ discard block |
||
1218 | 1303 | { |
1219 | 1304 | $context[$type][] = 'default'; |
1220 | 1305 | continue; |
1306 | + } else { |
|
1307 | + $context[$type]['selected'] = 'default'; |
|
1221 | 1308 | } |
1222 | - else |
|
1223 | - $context[$type]['selected'] = 'default'; |
|
1224 | 1309 | } |
1225 | 1310 | } |
1226 | 1311 | |
@@ -1230,9 +1315,9 @@ discard block |
||
1230 | 1315 | $filename = $temp_path . '$auto_' . $temp_auto++ . (in_array($actionType, array('readme', 'redirect', 'license')) ? '.txt' : ($actionType == 'code' || $actionType == 'database' ? '.php' : '.mod')); |
1231 | 1316 | package_put_contents($filename, $action->fetch('.')); |
1232 | 1317 | $filename = strtr($filename, array($temp_path => '')); |
1318 | + } else { |
|
1319 | + $filename = $action->fetch('.'); |
|
1233 | 1320 | } |
1234 | - else |
|
1235 | - $filename = $action->fetch('.'); |
|
1236 | 1321 | |
1237 | 1322 | $return[] = array( |
1238 | 1323 | 'type' => $actionType, |
@@ -1247,8 +1332,7 @@ discard block |
||
1247 | 1332 | ); |
1248 | 1333 | |
1249 | 1334 | continue; |
1250 | - } |
|
1251 | - elseif ($actionType == 'hook') |
|
1335 | + } elseif ($actionType == 'hook') |
|
1252 | 1336 | { |
1253 | 1337 | $return[] = array( |
1254 | 1338 | 'type' => $actionType, |
@@ -1260,16 +1344,16 @@ discard block |
||
1260 | 1344 | 'description' => '', |
1261 | 1345 | ); |
1262 | 1346 | continue; |
1263 | - } |
|
1264 | - elseif ($actionType == 'credits') |
|
1347 | + } elseif ($actionType == 'credits') |
|
1265 | 1348 | { |
1266 | 1349 | // quick check of any supplied url |
1267 | 1350 | $url = $action->exists('@url') ? $action->fetch('@url') : ''; |
1268 | 1351 | if (strlen(trim($url)) > 0 && substr($url, 0, 7) !== 'http://' && substr($url, 0, 8) !== 'https://') |
1269 | 1352 | { |
1270 | 1353 | $url = 'http://' . $url; |
1271 | - if (strlen($url) < 8 || (substr($url, 0, 7) !== 'http://' && substr($url, 0, 8) !== 'https://')) |
|
1272 | - $url = ''; |
|
1354 | + if (strlen($url) < 8 || (substr($url, 0, 7) !== 'http://' && substr($url, 0, 8) !== 'https://')) { |
|
1355 | + $url = ''; |
|
1356 | + } |
|
1273 | 1357 | } |
1274 | 1358 | |
1275 | 1359 | $return[] = array( |
@@ -1281,8 +1365,7 @@ discard block |
||
1281 | 1365 | 'title' => $action->fetch('.'), |
1282 | 1366 | ); |
1283 | 1367 | continue; |
1284 | - } |
|
1285 | - elseif ($actionType == 'requires') |
|
1368 | + } elseif ($actionType == 'requires') |
|
1286 | 1369 | { |
1287 | 1370 | $return[] = array( |
1288 | 1371 | 'type' => $actionType, |
@@ -1291,14 +1374,12 @@ discard block |
||
1291 | 1374 | 'description' => '', |
1292 | 1375 | ); |
1293 | 1376 | continue; |
1294 | - } |
|
1295 | - elseif ($actionType == 'error') |
|
1377 | + } elseif ($actionType == 'error') |
|
1296 | 1378 | { |
1297 | 1379 | $return[] = array( |
1298 | 1380 | 'type' => 'error', |
1299 | 1381 | ); |
1300 | - } |
|
1301 | - elseif (in_array($actionType, array('require-file', 'remove-file', 'require-dir', 'remove-dir', 'move-file', 'move-dir', 'create-file', 'create-dir'))) |
|
1382 | + } elseif (in_array($actionType, array('require-file', 'remove-file', 'require-dir', 'remove-dir', 'move-file', 'move-dir', 'create-file', 'create-dir'))) |
|
1302 | 1383 | { |
1303 | 1384 | $this_action = &$return[]; |
1304 | 1385 | $this_action = array( |
@@ -1312,8 +1393,7 @@ discard block |
||
1312 | 1393 | { |
1313 | 1394 | $this_action['unparsed_destination'] = $action->fetch('@destination'); |
1314 | 1395 | $this_action['destination'] = parse_path($action->fetch('@destination')) . '/' . basename($this_action['filename']); |
1315 | - } |
|
1316 | - else |
|
1396 | + } else |
|
1317 | 1397 | { |
1318 | 1398 | $this_action['unparsed_filename'] = $this_action['filename']; |
1319 | 1399 | $this_action['filename'] = parse_path($this_action['filename']); |
@@ -1322,10 +1402,11 @@ discard block |
||
1322 | 1402 | // If we're moving or requiring (copying) a file. |
1323 | 1403 | if (substr($actionType, 0, 4) == 'move' || substr($actionType, 0, 7) == 'require') |
1324 | 1404 | { |
1325 | - if ($action->exists('@from')) |
|
1326 | - $this_action['source'] = parse_path($action->fetch('@from')); |
|
1327 | - else |
|
1328 | - $this_action['source'] = $temp_path . $this_action['filename']; |
|
1405 | + if ($action->exists('@from')) { |
|
1406 | + $this_action['source'] = parse_path($action->fetch('@from')); |
|
1407 | + } else { |
|
1408 | + $this_action['source'] = $temp_path . $this_action['filename']; |
|
1409 | + } |
|
1329 | 1410 | } |
1330 | 1411 | |
1331 | 1412 | // Check if these things can be done. (chmod's etc.) |
@@ -1334,22 +1415,23 @@ discard block |
||
1334 | 1415 | if (!mktree($this_action['destination'], false)) |
1335 | 1416 | { |
1336 | 1417 | $temp = $this_action['destination']; |
1337 | - while (!file_exists($temp) && strlen($temp) > 1) |
|
1338 | - $temp = dirname($temp); |
|
1418 | + while (!file_exists($temp) && strlen($temp) > 1) { |
|
1419 | + $temp = dirname($temp); |
|
1420 | + } |
|
1339 | 1421 | |
1340 | 1422 | $return[] = array( |
1341 | 1423 | 'type' => 'chmod', |
1342 | 1424 | 'filename' => $temp |
1343 | 1425 | ); |
1344 | 1426 | } |
1345 | - } |
|
1346 | - elseif ($actionType == 'create-file') |
|
1427 | + } elseif ($actionType == 'create-file') |
|
1347 | 1428 | { |
1348 | 1429 | if (!mktree(dirname($this_action['destination']), false)) |
1349 | 1430 | { |
1350 | 1431 | $temp = dirname($this_action['destination']); |
1351 | - while (!file_exists($temp) && strlen($temp) > 1) |
|
1352 | - $temp = dirname($temp); |
|
1432 | + while (!file_exists($temp) && strlen($temp) > 1) { |
|
1433 | + $temp = dirname($temp); |
|
1434 | + } |
|
1353 | 1435 | |
1354 | 1436 | $return[] = array( |
1355 | 1437 | 'type' => 'chmod', |
@@ -1357,36 +1439,38 @@ discard block |
||
1357 | 1439 | ); |
1358 | 1440 | } |
1359 | 1441 | |
1360 | - if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) |
|
1361 | - $return[] = array( |
|
1442 | + if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) { |
|
1443 | + $return[] = array( |
|
1362 | 1444 | 'type' => 'chmod', |
1363 | 1445 | 'filename' => $this_action['destination'] |
1364 | 1446 | ); |
1365 | - } |
|
1366 | - elseif ($actionType == 'require-dir') |
|
1447 | + } |
|
1448 | + } elseif ($actionType == 'require-dir') |
|
1367 | 1449 | { |
1368 | 1450 | if (!mktree($this_action['destination'], false)) |
1369 | 1451 | { |
1370 | 1452 | $temp = $this_action['destination']; |
1371 | - while (!file_exists($temp) && strlen($temp) > 1) |
|
1372 | - $temp = dirname($temp); |
|
1453 | + while (!file_exists($temp) && strlen($temp) > 1) { |
|
1454 | + $temp = dirname($temp); |
|
1455 | + } |
|
1373 | 1456 | |
1374 | 1457 | $return[] = array( |
1375 | 1458 | 'type' => 'chmod', |
1376 | 1459 | 'filename' => $temp |
1377 | 1460 | ); |
1378 | 1461 | } |
1379 | - } |
|
1380 | - elseif ($actionType == 'require-file') |
|
1462 | + } elseif ($actionType == 'require-file') |
|
1381 | 1463 | { |
1382 | - if ($action->exists('@theme')) |
|
1383 | - $this_action['theme_action'] = $action->fetch('@theme'); |
|
1464 | + if ($action->exists('@theme')) { |
|
1465 | + $this_action['theme_action'] = $action->fetch('@theme'); |
|
1466 | + } |
|
1384 | 1467 | |
1385 | 1468 | if (!mktree(dirname($this_action['destination']), false)) |
1386 | 1469 | { |
1387 | 1470 | $temp = dirname($this_action['destination']); |
1388 | - while (!file_exists($temp) && strlen($temp) > 1) |
|
1389 | - $temp = dirname($temp); |
|
1471 | + while (!file_exists($temp) && strlen($temp) > 1) { |
|
1472 | + $temp = dirname($temp); |
|
1473 | + } |
|
1390 | 1474 | |
1391 | 1475 | $return[] = array( |
1392 | 1476 | 'type' => 'chmod', |
@@ -1394,19 +1478,20 @@ discard block |
||
1394 | 1478 | ); |
1395 | 1479 | } |
1396 | 1480 | |
1397 | - if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) |
|
1398 | - $return[] = array( |
|
1481 | + if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) { |
|
1482 | + $return[] = array( |
|
1399 | 1483 | 'type' => 'chmod', |
1400 | 1484 | 'filename' => $this_action['destination'] |
1401 | 1485 | ); |
1402 | - } |
|
1403 | - elseif ($actionType == 'move-dir' || $actionType == 'move-file') |
|
1486 | + } |
|
1487 | + } elseif ($actionType == 'move-dir' || $actionType == 'move-file') |
|
1404 | 1488 | { |
1405 | 1489 | if (!mktree(dirname($this_action['destination']), false)) |
1406 | 1490 | { |
1407 | 1491 | $temp = dirname($this_action['destination']); |
1408 | - while (!file_exists($temp) && strlen($temp) > 1) |
|
1409 | - $temp = dirname($temp); |
|
1492 | + while (!file_exists($temp) && strlen($temp) > 1) { |
|
1493 | + $temp = dirname($temp); |
|
1494 | + } |
|
1410 | 1495 | |
1411 | 1496 | $return[] = array( |
1412 | 1497 | 'type' => 'chmod', |
@@ -1414,30 +1499,30 @@ discard block |
||
1414 | 1499 | ); |
1415 | 1500 | } |
1416 | 1501 | |
1417 | - if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) |
|
1418 | - $return[] = array( |
|
1502 | + if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) { |
|
1503 | + $return[] = array( |
|
1419 | 1504 | 'type' => 'chmod', |
1420 | 1505 | 'filename' => $this_action['destination'] |
1421 | 1506 | ); |
1422 | - } |
|
1423 | - elseif ($actionType == 'remove-dir') |
|
1507 | + } |
|
1508 | + } elseif ($actionType == 'remove-dir') |
|
1424 | 1509 | { |
1425 | - if (!is_writable($this_action['filename']) && file_exists($this_action['filename'])) |
|
1426 | - $return[] = array( |
|
1510 | + if (!is_writable($this_action['filename']) && file_exists($this_action['filename'])) { |
|
1511 | + $return[] = array( |
|
1427 | 1512 | 'type' => 'chmod', |
1428 | 1513 | 'filename' => $this_action['filename'] |
1429 | 1514 | ); |
1430 | - } |
|
1431 | - elseif ($actionType == 'remove-file') |
|
1515 | + } |
|
1516 | + } elseif ($actionType == 'remove-file') |
|
1432 | 1517 | { |
1433 | - if (!is_writable($this_action['filename']) && file_exists($this_action['filename'])) |
|
1434 | - $return[] = array( |
|
1518 | + if (!is_writable($this_action['filename']) && file_exists($this_action['filename'])) { |
|
1519 | + $return[] = array( |
|
1435 | 1520 | 'type' => 'chmod', |
1436 | 1521 | 'filename' => $this_action['filename'] |
1437 | 1522 | ); |
1523 | + } |
|
1438 | 1524 | } |
1439 | - } |
|
1440 | - else |
|
1525 | + } else |
|
1441 | 1526 | { |
1442 | 1527 | $return[] = array( |
1443 | 1528 | 'type' => 'error', |
@@ -1448,8 +1533,9 @@ discard block |
||
1448 | 1533 | } |
1449 | 1534 | |
1450 | 1535 | // Only testing - just return a list of things to be done. |
1451 | - if ($testing_only) |
|
1452 | - return $return; |
|
1536 | + if ($testing_only) { |
|
1537 | + return $return; |
|
1538 | + } |
|
1453 | 1539 | |
1454 | 1540 | umask(0); |
1455 | 1541 | |
@@ -1457,78 +1543,81 @@ discard block |
||
1457 | 1543 | $not_done = array(array('type' => '!')); |
1458 | 1544 | foreach ($return as $action) |
1459 | 1545 | { |
1460 | - if (in_array($action['type'], array('modification', 'code', 'database', 'redirect', 'hook', 'credits'))) |
|
1461 | - $not_done[] = $action; |
|
1546 | + if (in_array($action['type'], array('modification', 'code', 'database', 'redirect', 'hook', 'credits'))) { |
|
1547 | + $not_done[] = $action; |
|
1548 | + } |
|
1462 | 1549 | |
1463 | 1550 | if ($action['type'] == 'create-dir') |
1464 | 1551 | { |
1465 | - if (!mktree($action['destination'], 0755) || !is_writable($action['destination'])) |
|
1466 | - $failure |= !mktree($action['destination'], 0777); |
|
1467 | - } |
|
1468 | - elseif ($action['type'] == 'create-file') |
|
1552 | + if (!mktree($action['destination'], 0755) || !is_writable($action['destination'])) { |
|
1553 | + $failure |= !mktree($action['destination'], 0777); |
|
1554 | + } |
|
1555 | + } elseif ($action['type'] == 'create-file') |
|
1469 | 1556 | { |
1470 | - if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) |
|
1471 | - $failure |= !mktree(dirname($action['destination']), 0777); |
|
1557 | + if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) { |
|
1558 | + $failure |= !mktree(dirname($action['destination']), 0777); |
|
1559 | + } |
|
1472 | 1560 | |
1473 | 1561 | // Create an empty file. |
1474 | 1562 | package_put_contents($action['destination'], package_get_contents($action['source']), $testing_only); |
1475 | 1563 | |
1476 | - if (!file_exists($action['destination'])) |
|
1477 | - $failure = true; |
|
1478 | - } |
|
1479 | - elseif ($action['type'] == 'require-dir') |
|
1564 | + if (!file_exists($action['destination'])) { |
|
1565 | + $failure = true; |
|
1566 | + } |
|
1567 | + } elseif ($action['type'] == 'require-dir') |
|
1480 | 1568 | { |
1481 | 1569 | copytree($action['source'], $action['destination']); |
1482 | 1570 | // Any other theme folders? |
1483 | - if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']])) |
|
1484 | - foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination) |
|
1571 | + if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']])) { |
|
1572 | + foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination) |
|
1485 | 1573 | copytree($action['source'], $theme_destination); |
1486 | - } |
|
1487 | - elseif ($action['type'] == 'require-file') |
|
1574 | + } |
|
1575 | + } elseif ($action['type'] == 'require-file') |
|
1488 | 1576 | { |
1489 | - if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) |
|
1490 | - $failure |= !mktree(dirname($action['destination']), 0777); |
|
1577 | + if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) { |
|
1578 | + $failure |= !mktree(dirname($action['destination']), 0777); |
|
1579 | + } |
|
1491 | 1580 | |
1492 | 1581 | package_put_contents($action['destination'], package_get_contents($action['source']), $testing_only); |
1493 | 1582 | |
1494 | 1583 | $failure |= !copy($action['source'], $action['destination']); |
1495 | 1584 | |
1496 | 1585 | // Any other theme files? |
1497 | - if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']])) |
|
1498 | - foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination) |
|
1586 | + if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']])) { |
|
1587 | + foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination) |
|
1499 | 1588 | { |
1500 | 1589 | if (!mktree(dirname($theme_destination), 0755) || !is_writable(dirname($theme_destination))) |
1501 | 1590 | $failure |= !mktree(dirname($theme_destination), 0777); |
1591 | + } |
|
1502 | 1592 | |
1503 | 1593 | package_put_contents($theme_destination, package_get_contents($action['source']), $testing_only); |
1504 | 1594 | |
1505 | 1595 | $failure |= !copy($action['source'], $theme_destination); |
1506 | 1596 | } |
1507 | - } |
|
1508 | - elseif ($action['type'] == 'move-file') |
|
1597 | + } elseif ($action['type'] == 'move-file') |
|
1509 | 1598 | { |
1510 | - if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) |
|
1511 | - $failure |= !mktree(dirname($action['destination']), 0777); |
|
1599 | + if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) { |
|
1600 | + $failure |= !mktree(dirname($action['destination']), 0777); |
|
1601 | + } |
|
1512 | 1602 | |
1513 | 1603 | $failure |= !rename($action['source'], $action['destination']); |
1514 | - } |
|
1515 | - elseif ($action['type'] == 'move-dir') |
|
1604 | + } elseif ($action['type'] == 'move-dir') |
|
1516 | 1605 | { |
1517 | - if (!mktree($action['destination'], 0755) || !is_writable($action['destination'])) |
|
1518 | - $failure |= !mktree($action['destination'], 0777); |
|
1606 | + if (!mktree($action['destination'], 0755) || !is_writable($action['destination'])) { |
|
1607 | + $failure |= !mktree($action['destination'], 0777); |
|
1608 | + } |
|
1519 | 1609 | |
1520 | 1610 | $failure |= !rename($action['source'], $action['destination']); |
1521 | - } |
|
1522 | - elseif ($action['type'] == 'remove-dir') |
|
1611 | + } elseif ($action['type'] == 'remove-dir') |
|
1523 | 1612 | { |
1524 | 1613 | deltree($action['filename']); |
1525 | 1614 | |
1526 | 1615 | // Any other theme folders? |
1527 | - if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']])) |
|
1528 | - foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination) |
|
1616 | + if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']])) { |
|
1617 | + foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination) |
|
1529 | 1618 | deltree($theme_destination); |
1530 | - } |
|
1531 | - elseif ($action['type'] == 'remove-file') |
|
1619 | + } |
|
1620 | + } elseif ($action['type'] == 'remove-file') |
|
1532 | 1621 | { |
1533 | 1622 | // Make sure the file exists before deleting it. |
1534 | 1623 | if (file_exists($action['filename'])) |
@@ -1537,16 +1626,18 @@ discard block |
||
1537 | 1626 | $failure |= !unlink($action['filename']); |
1538 | 1627 | } |
1539 | 1628 | // The file that was supposed to be deleted couldn't be found. |
1540 | - else |
|
1541 | - $failure = true; |
|
1629 | + else { |
|
1630 | + $failure = true; |
|
1631 | + } |
|
1542 | 1632 | |
1543 | 1633 | // Any other theme folders? |
1544 | - if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']])) |
|
1545 | - foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination) |
|
1634 | + if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']])) { |
|
1635 | + foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination) |
|
1546 | 1636 | if (file_exists($theme_destination)) |
1547 | 1637 | $failure |= !unlink($theme_destination); |
1548 | - else |
|
1549 | - $failure = true; |
|
1638 | + } else { |
|
1639 | + $failure = true; |
|
1640 | + } |
|
1550 | 1641 | } |
1551 | 1642 | } |
1552 | 1643 | |
@@ -1568,8 +1659,9 @@ discard block |
||
1568 | 1659 | { |
1569 | 1660 | static $near_version = 0; |
1570 | 1661 | |
1571 | - if ($reset) |
|
1572 | - $near_version = 0; |
|
1662 | + if ($reset) { |
|
1663 | + $near_version = 0; |
|
1664 | + } |
|
1573 | 1665 | |
1574 | 1666 | // Normalize the $versions while we remove our previous Doh! |
1575 | 1667 | $versions = explode(',', str_replace(array(' ', '2.0rc1-1'), array('', '2.0rc1.1'), strtolower($versions))); |
@@ -1578,16 +1670,19 @@ discard block |
||
1578 | 1670 | foreach ($versions as $for) |
1579 | 1671 | { |
1580 | 1672 | // Adjust for those wild cards |
1581 | - if (strpos($for, '*') !== false) |
|
1582 | - $for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for); |
|
1673 | + if (strpos($for, '*') !== false) { |
|
1674 | + $for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for); |
|
1675 | + } |
|
1583 | 1676 | |
1584 | 1677 | // If we have a range, grab the lower value, done this way so it looks normal-er to the user e.g. 2.0 vs 2.0.99 |
1585 | - if (strpos($for, '-') !== false) |
|
1586 | - list ($for, $higher) = explode('-', $for); |
|
1678 | + if (strpos($for, '-') !== false) { |
|
1679 | + list ($for, $higher) = explode('-', $for); |
|
1680 | + } |
|
1587 | 1681 | |
1588 | 1682 | // Do the compare, if the for is greater, than what we have but not greater than what we are running ..... |
1589 | - if (compareVersions($near_version, $for) === -1 && compareVersions($for, $the_version) !== 1) |
|
1590 | - $near_version = $for; |
|
1683 | + if (compareVersions($near_version, $for) === -1 && compareVersions($for, $the_version) !== 1) { |
|
1684 | + $near_version = $for; |
|
1685 | + } |
|
1591 | 1686 | } |
1592 | 1687 | |
1593 | 1688 | return !empty($near_version) ? $near_version : false; |
@@ -1610,15 +1705,17 @@ discard block |
||
1610 | 1705 | $versions = explode(',', str_replace(array(' ', '2.0rc1-1'), array('', '2.0rc1.1'), strtolower($versions))); |
1611 | 1706 | |
1612 | 1707 | // Perhaps we do accept anything? |
1613 | - if (in_array('all', $versions)) |
|
1614 | - return true; |
|
1708 | + if (in_array('all', $versions)) { |
|
1709 | + return true; |
|
1710 | + } |
|
1615 | 1711 | |
1616 | 1712 | // Loop through each version. |
1617 | 1713 | foreach ($versions as $for) |
1618 | 1714 | { |
1619 | 1715 | // Wild card spotted? |
1620 | - if (strpos($for, '*') !== false) |
|
1621 | - $for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for); |
|
1716 | + if (strpos($for, '*') !== false) { |
|
1717 | + $for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for); |
|
1718 | + } |
|
1622 | 1719 | |
1623 | 1720 | // Do we have a range? |
1624 | 1721 | if (strpos($for, '-') !== false) |
@@ -1626,12 +1723,14 @@ discard block |
||
1626 | 1723 | list ($lower, $upper) = explode('-', $for); |
1627 | 1724 | |
1628 | 1725 | // Compare the version against lower and upper bounds. |
1629 | - if (compareVersions($version, $lower) > -1 && compareVersions($version, $upper) < 1) |
|
1630 | - return true; |
|
1726 | + if (compareVersions($version, $lower) > -1 && compareVersions($version, $upper) < 1) { |
|
1727 | + return true; |
|
1728 | + } |
|
1631 | 1729 | } |
1632 | 1730 | // Otherwise check if they are equal... |
1633 | - elseif (compareVersions($version, $for) === 0) |
|
1634 | - return true; |
|
1731 | + elseif (compareVersions($version, $for) === 0) { |
|
1732 | + return true; |
|
1733 | + } |
|
1635 | 1734 | } |
1636 | 1735 | |
1637 | 1736 | return false; |
@@ -1671,12 +1770,14 @@ discard block |
||
1671 | 1770 | } |
1672 | 1771 | |
1673 | 1772 | // Are they the same, perhaps? |
1674 | - if ($versions[1] === $versions[2]) |
|
1675 | - return 0; |
|
1773 | + if ($versions[1] === $versions[2]) { |
|
1774 | + return 0; |
|
1775 | + } |
|
1676 | 1776 | |
1677 | 1777 | // Get version numbering categories... |
1678 | - if (!isset($categories)) |
|
1679 | - $categories = array_keys($versions[1]); |
|
1778 | + if (!isset($categories)) { |
|
1779 | + $categories = array_keys($versions[1]); |
|
1780 | + } |
|
1680 | 1781 | |
1681 | 1782 | // Loop through each category. |
1682 | 1783 | foreach ($categories as $category) |
@@ -1686,13 +1787,15 @@ discard block |
||
1686 | 1787 | { |
1687 | 1788 | // Dev builds are a problematic exception. |
1688 | 1789 | // (stable) dev < (stable) but (unstable) dev = (unstable) |
1689 | - if ($category == 'type') |
|
1690 | - return $versions[1][$category] > $versions[2][$category] ? ($versions[1]['dev'] ? -1 : 1) : ($versions[2]['dev'] ? 1 : -1); |
|
1691 | - elseif ($category == 'dev') |
|
1692 | - return $versions[1]['dev'] ? ($versions[2]['type'] == 'stable' ? -1 : 0) : ($versions[1]['type'] == 'stable' ? 1 : 0); |
|
1790 | + if ($category == 'type') { |
|
1791 | + return $versions[1][$category] > $versions[2][$category] ? ($versions[1]['dev'] ? -1 : 1) : ($versions[2]['dev'] ? 1 : -1); |
|
1792 | + } elseif ($category == 'dev') { |
|
1793 | + return $versions[1]['dev'] ? ($versions[2]['type'] == 'stable' ? -1 : 0) : ($versions[1]['type'] == 'stable' ? 1 : 0); |
|
1794 | + } |
|
1693 | 1795 | // Otherwise a simple comparison. |
1694 | - else |
|
1695 | - return $versions[1][$category] > $versions[2][$category] ? 1 : -1; |
|
1796 | + else { |
|
1797 | + return $versions[1][$category] > $versions[2][$category] ? 1 : -1; |
|
1798 | + } |
|
1696 | 1799 | } |
1697 | 1800 | } |
1698 | 1801 | |
@@ -1726,11 +1829,13 @@ discard block |
||
1726 | 1829 | ); |
1727 | 1830 | |
1728 | 1831 | // do we parse in a package directory? |
1729 | - if (!empty($temp_path)) |
|
1730 | - $dirs['$package'] = $temp_path; |
|
1832 | + if (!empty($temp_path)) { |
|
1833 | + $dirs['$package'] = $temp_path; |
|
1834 | + } |
|
1731 | 1835 | |
1732 | - if (strlen($path) == 0) |
|
1733 | - trigger_error('parse_path(): There should never be an empty filename', E_USER_ERROR); |
|
1836 | + if (strlen($path) == 0) { |
|
1837 | + trigger_error('parse_path(): There should never be an empty filename', E_USER_ERROR); |
|
1838 | + } |
|
1734 | 1839 | |
1735 | 1840 | return strtr($path, $dirs); |
1736 | 1841 | } |
@@ -1746,8 +1851,9 @@ discard block |
||
1746 | 1851 | { |
1747 | 1852 | global $package_ftp; |
1748 | 1853 | |
1749 | - if (!file_exists($dir)) |
|
1750 | - return; |
|
1854 | + if (!file_exists($dir)) { |
|
1855 | + return; |
|
1856 | + } |
|
1751 | 1857 | |
1752 | 1858 | $current_dir = @opendir($dir); |
1753 | 1859 | if ($current_dir == false) |
@@ -1755,8 +1861,9 @@ discard block |
||
1755 | 1861 | if ($delete_dir && isset($package_ftp)) |
1756 | 1862 | { |
1757 | 1863 | $ftp_file = strtr($dir, array($_SESSION['pack_ftp']['root'] => '')); |
1758 | - if (!is_dir($dir)) |
|
1759 | - $package_ftp->chmod($ftp_file, 0777); |
|
1864 | + if (!is_dir($dir)) { |
|
1865 | + $package_ftp->chmod($ftp_file, 0777); |
|
1866 | + } |
|
1760 | 1867 | $package_ftp->unlink($ftp_file); |
1761 | 1868 | } |
1762 | 1869 | |
@@ -1765,26 +1872,28 @@ discard block |
||
1765 | 1872 | |
1766 | 1873 | while ($entryname = readdir($current_dir)) |
1767 | 1874 | { |
1768 | - if (in_array($entryname, array('.', '..'))) |
|
1769 | - continue; |
|
1875 | + if (in_array($entryname, array('.', '..'))) { |
|
1876 | + continue; |
|
1877 | + } |
|
1770 | 1878 | |
1771 | - if (is_dir($dir . '/' . $entryname)) |
|
1772 | - deltree($dir . '/' . $entryname); |
|
1773 | - else |
|
1879 | + if (is_dir($dir . '/' . $entryname)) { |
|
1880 | + deltree($dir . '/' . $entryname); |
|
1881 | + } else |
|
1774 | 1882 | { |
1775 | 1883 | // Here, 755 doesn't really matter since we're deleting it anyway. |
1776 | 1884 | if (isset($package_ftp)) |
1777 | 1885 | { |
1778 | 1886 | $ftp_file = strtr($dir . '/' . $entryname, array($_SESSION['pack_ftp']['root'] => '')); |
1779 | 1887 | |
1780 | - if (!is_writable($dir . '/' . $entryname)) |
|
1781 | - $package_ftp->chmod($ftp_file, 0777); |
|
1888 | + if (!is_writable($dir . '/' . $entryname)) { |
|
1889 | + $package_ftp->chmod($ftp_file, 0777); |
|
1890 | + } |
|
1782 | 1891 | $package_ftp->unlink($ftp_file); |
1783 | - } |
|
1784 | - else |
|
1892 | + } else |
|
1785 | 1893 | { |
1786 | - if (!is_writable($dir . '/' . $entryname)) |
|
1787 | - smf_chmod($dir . '/' . $entryname, 0777); |
|
1894 | + if (!is_writable($dir . '/' . $entryname)) { |
|
1895 | + smf_chmod($dir . '/' . $entryname, 0777); |
|
1896 | + } |
|
1788 | 1897 | unlink($dir . '/' . $entryname); |
1789 | 1898 | } |
1790 | 1899 | } |
@@ -1797,14 +1906,15 @@ discard block |
||
1797 | 1906 | if (isset($package_ftp)) |
1798 | 1907 | { |
1799 | 1908 | $ftp_file = strtr($dir, array($_SESSION['pack_ftp']['root'] => '')); |
1800 | - if (!is_writable($dir . '/' . $entryname)) |
|
1801 | - $package_ftp->chmod($ftp_file, 0777); |
|
1909 | + if (!is_writable($dir . '/' . $entryname)) { |
|
1910 | + $package_ftp->chmod($ftp_file, 0777); |
|
1911 | + } |
|
1802 | 1912 | $package_ftp->unlink($ftp_file); |
1803 | - } |
|
1804 | - else |
|
1913 | + } else |
|
1805 | 1914 | { |
1806 | - if (!is_writable($dir)) |
|
1807 | - smf_chmod($dir, 0777); |
|
1915 | + if (!is_writable($dir)) { |
|
1916 | + smf_chmod($dir, 0777); |
|
1917 | + } |
|
1808 | 1918 | @rmdir($dir); |
1809 | 1919 | } |
1810 | 1920 | } |
@@ -1826,10 +1936,11 @@ discard block |
||
1826 | 1936 | { |
1827 | 1937 | if (!is_writable($strPath) && $mode !== false) |
1828 | 1938 | { |
1829 | - if (isset($package_ftp)) |
|
1830 | - $package_ftp->chmod(strtr($strPath, array($_SESSION['pack_ftp']['root'] => '')), $mode); |
|
1831 | - else |
|
1832 | - smf_chmod($strPath, $mode); |
|
1939 | + if (isset($package_ftp)) { |
|
1940 | + $package_ftp->chmod(strtr($strPath, array($_SESSION['pack_ftp']['root'] => '')), $mode); |
|
1941 | + } else { |
|
1942 | + smf_chmod($strPath, $mode); |
|
1943 | + } |
|
1833 | 1944 | } |
1834 | 1945 | |
1835 | 1946 | $test = @opendir($strPath); |
@@ -1837,36 +1948,37 @@ discard block |
||
1837 | 1948 | { |
1838 | 1949 | closedir($test); |
1839 | 1950 | return is_writable($strPath); |
1951 | + } else { |
|
1952 | + return false; |
|
1840 | 1953 | } |
1841 | - else |
|
1842 | - return false; |
|
1843 | 1954 | } |
1844 | 1955 | // Is this an invalid path and/or we can't make the directory? |
1845 | - if ($strPath == dirname($strPath) || !mktree(dirname($strPath), $mode)) |
|
1846 | - return false; |
|
1956 | + if ($strPath == dirname($strPath) || !mktree(dirname($strPath), $mode)) { |
|
1957 | + return false; |
|
1958 | + } |
|
1847 | 1959 | |
1848 | 1960 | if (!is_writable(dirname($strPath)) && $mode !== false) |
1849 | 1961 | { |
1850 | - if (isset($package_ftp)) |
|
1851 | - $package_ftp->chmod(dirname(strtr($strPath, array($_SESSION['pack_ftp']['root'] => ''))), $mode); |
|
1852 | - else |
|
1853 | - smf_chmod(dirname($strPath), $mode); |
|
1962 | + if (isset($package_ftp)) { |
|
1963 | + $package_ftp->chmod(dirname(strtr($strPath, array($_SESSION['pack_ftp']['root'] => ''))), $mode); |
|
1964 | + } else { |
|
1965 | + smf_chmod(dirname($strPath), $mode); |
|
1966 | + } |
|
1854 | 1967 | } |
1855 | 1968 | |
1856 | - if ($mode !== false && isset($package_ftp)) |
|
1857 | - return $package_ftp->create_dir(strtr($strPath, array($_SESSION['pack_ftp']['root'] => ''))); |
|
1858 | - elseif ($mode === false) |
|
1969 | + if ($mode !== false && isset($package_ftp)) { |
|
1970 | + return $package_ftp->create_dir(strtr($strPath, array($_SESSION['pack_ftp']['root'] => ''))); |
|
1971 | + } elseif ($mode === false) |
|
1859 | 1972 | { |
1860 | 1973 | $test = @opendir(dirname($strPath)); |
1861 | 1974 | if ($test) |
1862 | 1975 | { |
1863 | 1976 | closedir($test); |
1864 | 1977 | return true; |
1978 | + } else { |
|
1979 | + return false; |
|
1865 | 1980 | } |
1866 | - else |
|
1867 | - return false; |
|
1868 | - } |
|
1869 | - else |
|
1981 | + } else |
|
1870 | 1982 | { |
1871 | 1983 | @mkdir($strPath, $mode); |
1872 | 1984 | $test = @opendir($strPath); |
@@ -1874,9 +1986,9 @@ discard block |
||
1874 | 1986 | { |
1875 | 1987 | closedir($test); |
1876 | 1988 | return true; |
1989 | + } else { |
|
1990 | + return false; |
|
1877 | 1991 | } |
1878 | - else |
|
1879 | - return false; |
|
1880 | 1992 | } |
1881 | 1993 | } |
1882 | 1994 | |
@@ -1891,39 +2003,46 @@ discard block |
||
1891 | 2003 | { |
1892 | 2004 | global $package_ftp; |
1893 | 2005 | |
1894 | - if (!file_exists($destination) || !is_writable($destination)) |
|
1895 | - mktree($destination, 0755); |
|
1896 | - if (!is_writable($destination)) |
|
1897 | - mktree($destination, 0777); |
|
2006 | + if (!file_exists($destination) || !is_writable($destination)) { |
|
2007 | + mktree($destination, 0755); |
|
2008 | + } |
|
2009 | + if (!is_writable($destination)) { |
|
2010 | + mktree($destination, 0777); |
|
2011 | + } |
|
1898 | 2012 | |
1899 | 2013 | $current_dir = opendir($source); |
1900 | - if ($current_dir == false) |
|
1901 | - return; |
|
2014 | + if ($current_dir == false) { |
|
2015 | + return; |
|
2016 | + } |
|
1902 | 2017 | |
1903 | 2018 | while ($entryname = readdir($current_dir)) |
1904 | 2019 | { |
1905 | - if (in_array($entryname, array('.', '..'))) |
|
1906 | - continue; |
|
2020 | + if (in_array($entryname, array('.', '..'))) { |
|
2021 | + continue; |
|
2022 | + } |
|
1907 | 2023 | |
1908 | - if (isset($package_ftp)) |
|
1909 | - $ftp_file = strtr($destination . '/' . $entryname, array($_SESSION['pack_ftp']['root'] => '')); |
|
2024 | + if (isset($package_ftp)) { |
|
2025 | + $ftp_file = strtr($destination . '/' . $entryname, array($_SESSION['pack_ftp']['root'] => '')); |
|
2026 | + } |
|
1910 | 2027 | |
1911 | 2028 | if (is_file($source . '/' . $entryname)) |
1912 | 2029 | { |
1913 | - if (isset($package_ftp) && !file_exists($destination . '/' . $entryname)) |
|
1914 | - $package_ftp->create_file($ftp_file); |
|
1915 | - elseif (!file_exists($destination . '/' . $entryname)) |
|
1916 | - @touch($destination . '/' . $entryname); |
|
2030 | + if (isset($package_ftp) && !file_exists($destination . '/' . $entryname)) { |
|
2031 | + $package_ftp->create_file($ftp_file); |
|
2032 | + } elseif (!file_exists($destination . '/' . $entryname)) { |
|
2033 | + @touch($destination . '/' . $entryname); |
|
2034 | + } |
|
1917 | 2035 | } |
1918 | 2036 | |
1919 | 2037 | package_chmod($destination . '/' . $entryname); |
1920 | 2038 | |
1921 | - if (is_dir($source . '/' . $entryname)) |
|
1922 | - copytree($source . '/' . $entryname, $destination . '/' . $entryname); |
|
1923 | - elseif (file_exists($destination . '/' . $entryname)) |
|
1924 | - package_put_contents($destination . '/' . $entryname, package_get_contents($source . '/' . $entryname)); |
|
1925 | - else |
|
1926 | - copy($source . '/' . $entryname, $destination . '/' . $entryname); |
|
2039 | + if (is_dir($source . '/' . $entryname)) { |
|
2040 | + copytree($source . '/' . $entryname, $destination . '/' . $entryname); |
|
2041 | + } elseif (file_exists($destination . '/' . $entryname)) { |
|
2042 | + package_put_contents($destination . '/' . $entryname, package_get_contents($source . '/' . $entryname)); |
|
2043 | + } else { |
|
2044 | + copy($source . '/' . $entryname, $destination . '/' . $entryname); |
|
2045 | + } |
|
1927 | 2046 | } |
1928 | 2047 | |
1929 | 2048 | closedir($current_dir); |
@@ -1941,21 +2060,24 @@ discard block |
||
1941 | 2060 | $data = array(); |
1942 | 2061 | |
1943 | 2062 | $dir = @dir($path . $sub_path); |
1944 | - if (!$dir) |
|
1945 | - return array(); |
|
2063 | + if (!$dir) { |
|
2064 | + return array(); |
|
2065 | + } |
|
1946 | 2066 | while ($entry = $dir->read()) |
1947 | 2067 | { |
1948 | - if ($entry == '.' || $entry == '..') |
|
1949 | - continue; |
|
2068 | + if ($entry == '.' || $entry == '..') { |
|
2069 | + continue; |
|
2070 | + } |
|
1950 | 2071 | |
1951 | - if (is_dir($path . $sub_path . '/' . $entry)) |
|
1952 | - $data = array_merge($data, listtree($path, $sub_path . '/' . $entry)); |
|
1953 | - else |
|
1954 | - $data[] = array( |
|
2072 | + if (is_dir($path . $sub_path . '/' . $entry)) { |
|
2073 | + $data = array_merge($data, listtree($path, $sub_path . '/' . $entry)); |
|
2074 | + } else { |
|
2075 | + $data[] = array( |
|
1955 | 2076 | 'filename' => $sub_path == '' ? $entry : $sub_path . '/' . $entry, |
1956 | 2077 | 'size' => filesize($path . $sub_path . '/' . $entry), |
1957 | 2078 | 'skipped' => false, |
1958 | 2079 | ); |
2080 | + } |
|
1959 | 2081 | } |
1960 | 2082 | $dir->close(); |
1961 | 2083 | |
@@ -2010,8 +2132,9 @@ discard block |
||
2010 | 2132 | { |
2011 | 2133 | // If this filename is relative, if so take a guess at what it should be. |
2012 | 2134 | $real_filename = $filename; |
2013 | - if (strpos($filename, 'Themes') === 0) |
|
2014 | - $real_filename = $boarddir . '/' . $filename; |
|
2135 | + if (strpos($filename, 'Themes') === 0) { |
|
2136 | + $real_filename = $boarddir . '/' . $filename; |
|
2137 | + } |
|
2015 | 2138 | |
2016 | 2139 | if (strpos($real_filename, $theme['theme_dir']) === 0) |
2017 | 2140 | { |
@@ -2030,8 +2153,9 @@ discard block |
||
2030 | 2153 | foreach ($theme_paths as $id => $theme) |
2031 | 2154 | { |
2032 | 2155 | // Default is getting done anyway, so no need for involvement here. |
2033 | - if ($id == 1) |
|
2034 | - continue; |
|
2156 | + if ($id == 1) { |
|
2157 | + continue; |
|
2158 | + } |
|
2035 | 2159 | |
2036 | 2160 | // For every template, do we want it? Yea, no, maybe? |
2037 | 2161 | foreach ($template_changes[1] as $index => $template_file) |
@@ -2054,8 +2178,9 @@ discard block |
||
2054 | 2178 | ); |
2055 | 2179 | |
2056 | 2180 | // Sometimes though, we have some additional files for other themes, if we have add them to the mix. |
2057 | - if (isset($custom_themes_add[$files_to_change[1]])) |
|
2058 | - $files_to_change += $custom_themes_add[$files_to_change[1]]; |
|
2181 | + if (isset($custom_themes_add[$files_to_change[1]])) { |
|
2182 | + $files_to_change += $custom_themes_add[$files_to_change[1]]; |
|
2183 | + } |
|
2059 | 2184 | |
2060 | 2185 | // Now, loop through all the files we're changing, and, well, change them ;) |
2061 | 2186 | foreach ($files_to_change as $theme => $working_file) |
@@ -2089,11 +2214,13 @@ discard block |
||
2089 | 2214 | continue; |
2090 | 2215 | } |
2091 | 2216 | // Okay, we're creating this file then...? |
2092 | - elseif (!file_exists($working_file)) |
|
2093 | - $working_data = ''; |
|
2217 | + elseif (!file_exists($working_file)) { |
|
2218 | + $working_data = ''; |
|
2219 | + } |
|
2094 | 2220 | // Phew, it exists! Load 'er up! |
2095 | - else |
|
2096 | - $working_data = str_replace("\r", '', package_get_contents($working_file)); |
|
2221 | + else { |
|
2222 | + $working_data = str_replace("\r", '', package_get_contents($working_file)); |
|
2223 | + } |
|
2097 | 2224 | |
2098 | 2225 | $actions[] = array( |
2099 | 2226 | 'type' => 'opened', |
@@ -2114,8 +2241,8 @@ discard block |
||
2114 | 2241 | |
2115 | 2242 | // Grab all search items of this operation (in most cases just 1). |
2116 | 2243 | $searches = $operation->set('search'); |
2117 | - foreach ($searches as $i => $search) |
|
2118 | - $actual_operation['searches'][] = array( |
|
2244 | + foreach ($searches as $i => $search) { |
|
2245 | + $actual_operation['searches'][] = array( |
|
2119 | 2246 | 'position' => $search->exists('@position') && in_array(trim($search->fetch('@position')), array('before', 'after', 'replace', 'end')) ? trim($search->fetch('@position')) : 'replace', |
2120 | 2247 | 'is_reg_exp' => $search->exists('@regexp') && trim($search->fetch('@regexp')) === 'true', |
2121 | 2248 | 'loose_whitespace' => $search->exists('@whitespace') && trim($search->fetch('@whitespace')) === 'loose', |
@@ -2124,6 +2251,7 @@ discard block |
||
2124 | 2251 | 'preg_search' => '', |
2125 | 2252 | 'preg_replace' => '', |
2126 | 2253 | ); |
2254 | + } |
|
2127 | 2255 | |
2128 | 2256 | // At least one search should be defined. |
2129 | 2257 | if (empty($actual_operation['searches'])) |
@@ -2148,30 +2276,32 @@ discard block |
||
2148 | 2276 | // Reverse modification of regular expressions are not allowed. |
2149 | 2277 | if ($search['is_reg_exp']) |
2150 | 2278 | { |
2151 | - if ($actual_operation['error'] === 'fatal') |
|
2152 | - $actions[] = array( |
|
2279 | + if ($actual_operation['error'] === 'fatal') { |
|
2280 | + $actions[] = array( |
|
2153 | 2281 | 'type' => 'failure', |
2154 | 2282 | 'filename' => $working_file, |
2155 | 2283 | 'search' => $search['search'], |
2156 | 2284 | 'is_custom' => $theme > 1 ? $theme : 0, |
2157 | 2285 | ); |
2286 | + } |
|
2158 | 2287 | |
2159 | 2288 | // Continue to the next operation. |
2160 | 2289 | continue 2; |
2161 | 2290 | } |
2162 | 2291 | |
2163 | 2292 | // The replacement is now the search subject... |
2164 | - if ($search['position'] === 'replace' || $search['position'] === 'end') |
|
2165 | - $actual_operation['searches'][$i]['search'] = $search['add']; |
|
2166 | - else |
|
2293 | + if ($search['position'] === 'replace' || $search['position'] === 'end') { |
|
2294 | + $actual_operation['searches'][$i]['search'] = $search['add']; |
|
2295 | + } else |
|
2167 | 2296 | { |
2168 | 2297 | // Reversing a before/after modification becomes a replacement. |
2169 | 2298 | $actual_operation['searches'][$i]['position'] = 'replace'; |
2170 | 2299 | |
2171 | - if ($search['position'] === 'before') |
|
2172 | - $actual_operation['searches'][$i]['search'] .= $search['add']; |
|
2173 | - elseif ($search['position'] === 'after') |
|
2174 | - $actual_operation['searches'][$i]['search'] = $search['add'] . $search['search']; |
|
2300 | + if ($search['position'] === 'before') { |
|
2301 | + $actual_operation['searches'][$i]['search'] .= $search['add']; |
|
2302 | + } elseif ($search['position'] === 'after') { |
|
2303 | + $actual_operation['searches'][$i]['search'] = $search['add'] . $search['search']; |
|
2304 | + } |
|
2175 | 2305 | } |
2176 | 2306 | |
2177 | 2307 | // ...and the search subject is now the replacement. |
@@ -2199,16 +2329,17 @@ discard block |
||
2199 | 2329 | foreach ($actual_operation['searches'] as $i => $search) |
2200 | 2330 | { |
2201 | 2331 | // Not much needed if the search subject is already a regexp. |
2202 | - if ($search['is_reg_exp']) |
|
2203 | - $actual_operation['searches'][$i]['preg_search'] = $search['search']; |
|
2204 | - else |
|
2332 | + if ($search['is_reg_exp']) { |
|
2333 | + $actual_operation['searches'][$i]['preg_search'] = $search['search']; |
|
2334 | + } else |
|
2205 | 2335 | { |
2206 | 2336 | // Make the search subject fit into a regular expression. |
2207 | 2337 | $actual_operation['searches'][$i]['preg_search'] = preg_quote($search['search'], '~'); |
2208 | 2338 | |
2209 | 2339 | // Using 'loose', a random amount of tabs and spaces may be used. |
2210 | - if ($search['loose_whitespace']) |
|
2211 | - $actual_operation['searches'][$i]['preg_search'] = preg_replace('~[ \t]+~', '[ \t]+', $actual_operation['searches'][$i]['preg_search']); |
|
2340 | + if ($search['loose_whitespace']) { |
|
2341 | + $actual_operation['searches'][$i]['preg_search'] = preg_replace('~[ \t]+~', '[ \t]+', $actual_operation['searches'][$i]['preg_search']); |
|
2342 | + } |
|
2212 | 2343 | } |
2213 | 2344 | |
2214 | 2345 | // Shuzzup. This is done so we can safely use a regular expression. ($0 is bad!!) |
@@ -2234,8 +2365,7 @@ discard block |
||
2234 | 2365 | if ($undo) |
2235 | 2366 | { |
2236 | 2367 | $actual_operation['searches'][$i]['preg_replace'] = ''; |
2237 | - } |
|
2238 | - else |
|
2368 | + } else |
|
2239 | 2369 | { |
2240 | 2370 | $actual_operation['searches'][$i]['preg_search'] = '(\\n\\?\\>)?$'; |
2241 | 2371 | $actual_operation['searches'][$i]['preg_replace'] .= '$1'; |
@@ -2282,8 +2412,9 @@ discard block |
||
2282 | 2412 | } |
2283 | 2413 | |
2284 | 2414 | // Replace it into nothing? That's not an option...unless it's an undoing end. |
2285 | - if ($search['add'] === '' && ($search['position'] !== 'end' || !$undo)) |
|
2286 | - continue; |
|
2415 | + if ($search['add'] === '' && ($search['position'] !== 'end' || !$undo)) { |
|
2416 | + continue; |
|
2417 | + } |
|
2287 | 2418 | |
2288 | 2419 | // Finally, we're doing some replacements. |
2289 | 2420 | $working_data = preg_replace('~' . $actual_operation['searches'][$i]['preg_search'] . '~s', $actual_operation['searches'][$i]['preg_replace'], $working_data, 1); |
@@ -2308,22 +2439,25 @@ discard block |
||
2308 | 2439 | |
2309 | 2440 | package_chmod($working_file); |
2310 | 2441 | |
2311 | - if ((file_exists($working_file) && !is_writable($working_file)) || (!file_exists($working_file) && !is_writable(dirname($working_file)))) |
|
2312 | - $actions[] = array( |
|
2442 | + if ((file_exists($working_file) && !is_writable($working_file)) || (!file_exists($working_file) && !is_writable(dirname($working_file)))) { |
|
2443 | + $actions[] = array( |
|
2313 | 2444 | 'type' => 'chmod', |
2314 | 2445 | 'filename' => $working_file |
2315 | 2446 | ); |
2447 | + } |
|
2316 | 2448 | |
2317 | - if (basename($working_file) == 'Settings_bak.php') |
|
2318 | - continue; |
|
2449 | + if (basename($working_file) == 'Settings_bak.php') { |
|
2450 | + continue; |
|
2451 | + } |
|
2319 | 2452 | |
2320 | 2453 | if (!$testing && !empty($modSettings['package_make_backups']) && file_exists($working_file)) |
2321 | 2454 | { |
2322 | 2455 | // No, no, not Settings.php! |
2323 | - if (basename($working_file) == 'Settings.php') |
|
2324 | - @copy($working_file, dirname($working_file) . '/Settings_bak.php'); |
|
2325 | - else |
|
2326 | - @copy($working_file, $working_file . '~'); |
|
2456 | + if (basename($working_file) == 'Settings.php') { |
|
2457 | + @copy($working_file, dirname($working_file) . '/Settings_bak.php'); |
|
2458 | + } else { |
|
2459 | + @copy($working_file, $working_file . '~'); |
|
2460 | + } |
|
2327 | 2461 | } |
2328 | 2462 | |
2329 | 2463 | // Always call this, even if in testing, because it won't really be written in testing mode. |
@@ -2390,8 +2524,9 @@ discard block |
||
2390 | 2524 | if ($code_match[1] != 'edit file' && $code_match[1] != 'file') |
2391 | 2525 | { |
2392 | 2526 | // It's a step, let's add that to the current steps. |
2393 | - if (isset($temp_changes[$step_counter])) |
|
2394 | - $temp_changes[$step_counter]['changes'][] = $code_match[0]; |
|
2527 | + if (isset($temp_changes[$step_counter])) { |
|
2528 | + $temp_changes[$step_counter]['changes'][] = $code_match[0]; |
|
2529 | + } |
|
2395 | 2530 | continue; |
2396 | 2531 | } |
2397 | 2532 | |
@@ -2408,11 +2543,13 @@ discard block |
||
2408 | 2543 | foreach ($theme_paths as $id => $theme) |
2409 | 2544 | { |
2410 | 2545 | // If this filename is relative, if so take a guess at what it should be. |
2411 | - if (strpos($filename, 'Themes') === 0) |
|
2412 | - $filename = $boarddir . '/' . $filename; |
|
2546 | + if (strpos($filename, 'Themes') === 0) { |
|
2547 | + $filename = $boarddir . '/' . $filename; |
|
2548 | + } |
|
2413 | 2549 | |
2414 | - if (strpos($filename, $theme['theme_dir']) === 0) |
|
2415 | - $template_changes[$id][$counter] = substr($filename, strlen($theme['theme_dir']) + 1); |
|
2550 | + if (strpos($filename, $theme['theme_dir']) === 0) { |
|
2551 | + $template_changes[$id][$counter] = substr($filename, strlen($theme['theme_dir']) + 1); |
|
2552 | + } |
|
2416 | 2553 | } |
2417 | 2554 | } |
2418 | 2555 | |
@@ -2425,8 +2562,9 @@ discard block |
||
2425 | 2562 | foreach ($theme_paths as $id => $theme) |
2426 | 2563 | { |
2427 | 2564 | // Don't do default, it means nothing to me. |
2428 | - if ($id == 1) |
|
2429 | - continue; |
|
2565 | + if ($id == 1) { |
|
2566 | + continue; |
|
2567 | + } |
|
2430 | 2568 | |
2431 | 2569 | // Now, for each file do we need to edit it? |
2432 | 2570 | foreach ($template_changes[1] as $pos => $template_file) |
@@ -2462,32 +2600,36 @@ discard block |
||
2462 | 2600 | package_chmod($working_file); |
2463 | 2601 | |
2464 | 2602 | // Don't even dare. |
2465 | - if (basename($working_file) == 'Settings_bak.php') |
|
2466 | - continue; |
|
2603 | + if (basename($working_file) == 'Settings_bak.php') { |
|
2604 | + continue; |
|
2605 | + } |
|
2467 | 2606 | |
2468 | - if (!is_writable($working_file)) |
|
2469 | - $actions[] = array( |
|
2607 | + if (!is_writable($working_file)) { |
|
2608 | + $actions[] = array( |
|
2470 | 2609 | 'type' => 'chmod', |
2471 | 2610 | 'filename' => $working_file |
2472 | 2611 | ); |
2612 | + } |
|
2473 | 2613 | |
2474 | 2614 | if (!$testing && !empty($modSettings['package_make_backups']) && file_exists($working_file)) |
2475 | 2615 | { |
2476 | - if (basename($working_file) == 'Settings.php') |
|
2477 | - @copy($working_file, dirname($working_file) . '/Settings_bak.php'); |
|
2478 | - else |
|
2479 | - @copy($working_file, $working_file . '~'); |
|
2616 | + if (basename($working_file) == 'Settings.php') { |
|
2617 | + @copy($working_file, dirname($working_file) . '/Settings_bak.php'); |
|
2618 | + } else { |
|
2619 | + @copy($working_file, $working_file . '~'); |
|
2620 | + } |
|
2480 | 2621 | } |
2481 | 2622 | |
2482 | 2623 | package_put_contents($working_file, $working_data, $testing); |
2483 | 2624 | } |
2484 | 2625 | |
2485 | - if ($working_file !== null) |
|
2486 | - $actions[] = array( |
|
2626 | + if ($working_file !== null) { |
|
2627 | + $actions[] = array( |
|
2487 | 2628 | 'type' => 'saved', |
2488 | 2629 | 'filename' => $working_file, |
2489 | 2630 | 'is_custom' => $is_custom, |
2490 | 2631 | ); |
2632 | + } |
|
2491 | 2633 | |
2492 | 2634 | // Is this "now working on" file a theme specific one? |
2493 | 2635 | $is_custom = isset($theme_id_ref[$counter - 1]) ? $theme_id_ref[$counter - 1] : 0; |
@@ -2506,10 +2648,11 @@ discard block |
||
2506 | 2648 | { |
2507 | 2649 | $places_to_check = array($boarddir, $sourcedir, $settings['default_theme_dir'], $settings['default_theme_dir'] . '/languages'); |
2508 | 2650 | |
2509 | - foreach ($places_to_check as $place) |
|
2510 | - if (file_exists($place . '/' . $working_file)) |
|
2651 | + foreach ($places_to_check as $place) { |
|
2652 | + if (file_exists($place . '/' . $working_file)) |
|
2511 | 2653 | { |
2512 | 2654 | $working_file = $place . '/' . $working_file; |
2655 | + } |
|
2513 | 2656 | break; |
2514 | 2657 | } |
2515 | 2658 | } |
@@ -2523,8 +2666,7 @@ discard block |
||
2523 | 2666 | 'type' => 'opened', |
2524 | 2667 | 'filename' => $working_file |
2525 | 2668 | ); |
2526 | - } |
|
2527 | - else |
|
2669 | + } else |
|
2528 | 2670 | { |
2529 | 2671 | $actions[] = array( |
2530 | 2672 | 'type' => 'missing', |
@@ -2560,11 +2702,13 @@ discard block |
||
2560 | 2702 | $replace_with = $code_match[2]; |
2561 | 2703 | |
2562 | 2704 | // Add this afterward... |
2563 | - if ($code_match[1] == 'add' || $code_match[1] == 'add after') |
|
2564 | - $replace_with = $working_search . "\n" . $replace_with; |
|
2705 | + if ($code_match[1] == 'add' || $code_match[1] == 'add after') { |
|
2706 | + $replace_with = $working_search . "\n" . $replace_with; |
|
2707 | + } |
|
2565 | 2708 | // Add this beforehand. |
2566 | - elseif ($code_match[1] == 'before' || $code_match[1] == 'add before' || $code_match[1] == 'above' || $code_match[1] == 'add above') |
|
2567 | - $replace_with .= "\n" . $working_search; |
|
2709 | + elseif ($code_match[1] == 'before' || $code_match[1] == 'add before' || $code_match[1] == 'above' || $code_match[1] == 'add above') { |
|
2710 | + $replace_with .= "\n" . $working_search; |
|
2711 | + } |
|
2568 | 2712 | // Otherwise.. replace with $replace_with ;). |
2569 | 2713 | } |
2570 | 2714 | |
@@ -2627,29 +2771,32 @@ discard block |
||
2627 | 2771 | { |
2628 | 2772 | package_chmod($working_file); |
2629 | 2773 | |
2630 | - if (!is_writable($working_file)) |
|
2631 | - $actions[] = array( |
|
2774 | + if (!is_writable($working_file)) { |
|
2775 | + $actions[] = array( |
|
2632 | 2776 | 'type' => 'chmod', |
2633 | 2777 | 'filename' => $working_file |
2634 | 2778 | ); |
2779 | + } |
|
2635 | 2780 | |
2636 | 2781 | if (!$testing && !empty($modSettings['package_make_backups']) && file_exists($working_file)) |
2637 | 2782 | { |
2638 | - if (basename($working_file) == 'Settings.php') |
|
2639 | - @copy($working_file, dirname($working_file) . '/Settings_bak.php'); |
|
2640 | - else |
|
2641 | - @copy($working_file, $working_file . '~'); |
|
2783 | + if (basename($working_file) == 'Settings.php') { |
|
2784 | + @copy($working_file, dirname($working_file) . '/Settings_bak.php'); |
|
2785 | + } else { |
|
2786 | + @copy($working_file, $working_file . '~'); |
|
2787 | + } |
|
2642 | 2788 | } |
2643 | 2789 | |
2644 | 2790 | package_put_contents($working_file, $working_data, $testing); |
2645 | 2791 | } |
2646 | 2792 | |
2647 | - if ($working_file !== null) |
|
2648 | - $actions[] = array( |
|
2793 | + if ($working_file !== null) { |
|
2794 | + $actions[] = array( |
|
2649 | 2795 | 'type' => 'saved', |
2650 | 2796 | 'filename' => $working_file, |
2651 | 2797 | 'is_custom' => $is_custom, |
2652 | 2798 | ); |
2799 | + } |
|
2653 | 2800 | |
2654 | 2801 | $actions[] = array( |
2655 | 2802 | 'type' => 'result', |
@@ -2675,17 +2822,19 @@ discard block |
||
2675 | 2822 | $mem_check = setMemoryLimit('128M'); |
2676 | 2823 | |
2677 | 2824 | // Windows doesn't seem to care about the memory_limit. |
2678 | - if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false) |
|
2679 | - $package_cache = array(); |
|
2680 | - else |
|
2681 | - $package_cache = false; |
|
2825 | + if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false) { |
|
2826 | + $package_cache = array(); |
|
2827 | + } else { |
|
2828 | + $package_cache = false; |
|
2829 | + } |
|
2682 | 2830 | } |
2683 | 2831 | |
2684 | - if (strpos($filename, 'Packages/') !== false || $package_cache === false || !isset($package_cache[$filename])) |
|
2685 | - return file_get_contents($filename); |
|
2686 | - else |
|
2687 | - return $package_cache[$filename]; |
|
2688 | -} |
|
2832 | + if (strpos($filename, 'Packages/') !== false || $package_cache === false || !isset($package_cache[$filename])) { |
|
2833 | + return file_get_contents($filename); |
|
2834 | + } else { |
|
2835 | + return $package_cache[$filename]; |
|
2836 | + } |
|
2837 | + } |
|
2689 | 2838 | |
2690 | 2839 | /** |
2691 | 2840 | * Writes data to a file, almost exactly like the file_put_contents() function. |
@@ -2708,19 +2857,22 @@ discard block |
||
2708 | 2857 | // Try to increase the memory limit - we don't want to run out of ram! |
2709 | 2858 | $mem_check = setMemoryLimit('128M'); |
2710 | 2859 | |
2711 | - if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false) |
|
2712 | - $package_cache = array(); |
|
2713 | - else |
|
2714 | - $package_cache = false; |
|
2860 | + if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false) { |
|
2861 | + $package_cache = array(); |
|
2862 | + } else { |
|
2863 | + $package_cache = false; |
|
2864 | + } |
|
2715 | 2865 | } |
2716 | 2866 | |
2717 | - if (isset($package_ftp)) |
|
2718 | - $ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => '')); |
|
2867 | + if (isset($package_ftp)) { |
|
2868 | + $ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => '')); |
|
2869 | + } |
|
2719 | 2870 | |
2720 | - if (!file_exists($filename) && isset($package_ftp)) |
|
2721 | - $package_ftp->create_file($ftp_file); |
|
2722 | - elseif (!file_exists($filename)) |
|
2723 | - @touch($filename); |
|
2871 | + if (!file_exists($filename) && isset($package_ftp)) { |
|
2872 | + $package_ftp->create_file($ftp_file); |
|
2873 | + } elseif (!file_exists($filename)) { |
|
2874 | + @touch($filename); |
|
2875 | + } |
|
2724 | 2876 | |
2725 | 2877 | package_chmod($filename); |
2726 | 2878 | |
@@ -2729,22 +2881,23 @@ discard block |
||
2729 | 2881 | $fp = @fopen($filename, in_array(substr($filename, -3), $text_filetypes) ? 'w' : 'wb'); |
2730 | 2882 | |
2731 | 2883 | // We should show an error message or attempt a rollback, no? |
2732 | - if (!$fp) |
|
2733 | - return false; |
|
2884 | + if (!$fp) { |
|
2885 | + return false; |
|
2886 | + } |
|
2734 | 2887 | |
2735 | 2888 | fwrite($fp, $data); |
2736 | 2889 | fclose($fp); |
2737 | - } |
|
2738 | - elseif (strpos($filename, 'Packages/') !== false || $package_cache === false) |
|
2739 | - return strlen($data); |
|
2740 | - else |
|
2890 | + } elseif (strpos($filename, 'Packages/') !== false || $package_cache === false) { |
|
2891 | + return strlen($data); |
|
2892 | + } else |
|
2741 | 2893 | { |
2742 | 2894 | $package_cache[$filename] = $data; |
2743 | 2895 | |
2744 | 2896 | // Permission denied, eh? |
2745 | 2897 | $fp = @fopen($filename, 'r+'); |
2746 | - if (!$fp) |
|
2747 | - return false; |
|
2898 | + if (!$fp) { |
|
2899 | + return false; |
|
2900 | + } |
|
2748 | 2901 | fclose($fp); |
2749 | 2902 | } |
2750 | 2903 | |
@@ -2761,19 +2914,22 @@ discard block |
||
2761 | 2914 | global $package_ftp, $package_cache; |
2762 | 2915 | static $text_filetypes = array('php', 'txt', '.js', 'css', 'vbs', 'tml', 'htm'); |
2763 | 2916 | |
2764 | - if (empty($package_cache)) |
|
2765 | - return; |
|
2917 | + if (empty($package_cache)) { |
|
2918 | + return; |
|
2919 | + } |
|
2766 | 2920 | |
2767 | 2921 | // First, let's check permissions! |
2768 | 2922 | foreach ($package_cache as $filename => $data) |
2769 | 2923 | { |
2770 | - if (isset($package_ftp)) |
|
2771 | - $ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => '')); |
|
2924 | + if (isset($package_ftp)) { |
|
2925 | + $ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => '')); |
|
2926 | + } |
|
2772 | 2927 | |
2773 | - if (!file_exists($filename) && isset($package_ftp)) |
|
2774 | - $package_ftp->create_file($ftp_file); |
|
2775 | - elseif (!file_exists($filename)) |
|
2776 | - @touch($filename); |
|
2928 | + if (!file_exists($filename) && isset($package_ftp)) { |
|
2929 | + $package_ftp->create_file($ftp_file); |
|
2930 | + } elseif (!file_exists($filename)) { |
|
2931 | + @touch($filename); |
|
2932 | + } |
|
2777 | 2933 | |
2778 | 2934 | $result = package_chmod($filename); |
2779 | 2935 | |
@@ -2826,8 +2982,9 @@ discard block |
||
2826 | 2982 | { |
2827 | 2983 | global $package_ftp; |
2828 | 2984 | |
2829 | - if (file_exists($filename) && is_writable($filename) && $perm_state == 'writable') |
|
2830 | - return true; |
|
2985 | + if (file_exists($filename) && is_writable($filename) && $perm_state == 'writable') { |
|
2986 | + return true; |
|
2987 | + } |
|
2831 | 2988 | |
2832 | 2989 | // Start off checking without FTP. |
2833 | 2990 | if (!isset($package_ftp) || $package_ftp === false) |
@@ -2849,8 +3006,7 @@ discard block |
||
2849 | 3006 | |
2850 | 3007 | // Keep track of the writable status here. |
2851 | 3008 | $file_permissions = @fileperms($chmod_file); |
2852 | - } |
|
2853 | - else |
|
3009 | + } else |
|
2854 | 3010 | { |
2855 | 3011 | // This looks odd, but it's an attempt to work around PHP suExec. |
2856 | 3012 | if (!file_exists($chmod_file) && $perm_state == 'writable') |
@@ -2860,24 +3016,28 @@ discard block |
||
2860 | 3016 | mktree(dirname($chmod_file), 0755); |
2861 | 3017 | @touch($chmod_file); |
2862 | 3018 | smf_chmod($chmod_file, 0755); |
3019 | + } else { |
|
3020 | + $file_permissions = @fileperms($chmod_file); |
|
2863 | 3021 | } |
2864 | - else |
|
2865 | - $file_permissions = @fileperms($chmod_file); |
|
2866 | 3022 | } |
2867 | 3023 | |
2868 | 3024 | // This looks odd, but it's another attempt to work around PHP suExec. |
2869 | - if ($perm_state != 'writable') |
|
2870 | - smf_chmod($chmod_file, $perm_state == 'execute' ? 0755 : 0644); |
|
2871 | - else |
|
3025 | + if ($perm_state != 'writable') { |
|
3026 | + smf_chmod($chmod_file, $perm_state == 'execute' ? 0755 : 0644); |
|
3027 | + } else |
|
2872 | 3028 | { |
2873 | - if (!@is_writable($chmod_file)) |
|
2874 | - smf_chmod($chmod_file, 0755); |
|
2875 | - if (!@is_writable($chmod_file)) |
|
2876 | - smf_chmod($chmod_file, 0777); |
|
2877 | - if (!@is_writable(dirname($chmod_file))) |
|
2878 | - smf_chmod($chmod_file, 0755); |
|
2879 | - if (!@is_writable(dirname($chmod_file))) |
|
2880 | - smf_chmod($chmod_file, 0777); |
|
3029 | + if (!@is_writable($chmod_file)) { |
|
3030 | + smf_chmod($chmod_file, 0755); |
|
3031 | + } |
|
3032 | + if (!@is_writable($chmod_file)) { |
|
3033 | + smf_chmod($chmod_file, 0777); |
|
3034 | + } |
|
3035 | + if (!@is_writable(dirname($chmod_file))) { |
|
3036 | + smf_chmod($chmod_file, 0755); |
|
3037 | + } |
|
3038 | + if (!@is_writable(dirname($chmod_file))) { |
|
3039 | + smf_chmod($chmod_file, 0777); |
|
3040 | + } |
|
2881 | 3041 | } |
2882 | 3042 | |
2883 | 3043 | // The ultimate writable test. |
@@ -2886,20 +3046,22 @@ discard block |
||
2886 | 3046 | $fp = is_dir($chmod_file) ? @opendir($chmod_file) : @fopen($chmod_file, 'rb'); |
2887 | 3047 | if (@is_writable($chmod_file) && $fp) |
2888 | 3048 | { |
2889 | - if (!is_dir($chmod_file)) |
|
2890 | - fclose($fp); |
|
2891 | - else |
|
2892 | - closedir($fp); |
|
3049 | + if (!is_dir($chmod_file)) { |
|
3050 | + fclose($fp); |
|
3051 | + } else { |
|
3052 | + closedir($fp); |
|
3053 | + } |
|
2893 | 3054 | |
2894 | 3055 | // It worked! |
2895 | - if ($track_change) |
|
2896 | - $_SESSION['pack_ftp']['original_perms'][$chmod_file] = $file_permissions; |
|
3056 | + if ($track_change) { |
|
3057 | + $_SESSION['pack_ftp']['original_perms'][$chmod_file] = $file_permissions; |
|
3058 | + } |
|
2897 | 3059 | |
2898 | 3060 | return true; |
2899 | 3061 | } |
3062 | + } elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$chmod_file])) { |
|
3063 | + unset($_SESSION['pack_ftp']['original_perms'][$chmod_file]); |
|
2900 | 3064 | } |
2901 | - elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$chmod_file])) |
|
2902 | - unset($_SESSION['pack_ftp']['original_perms'][$chmod_file]); |
|
2903 | 3065 | } |
2904 | 3066 | |
2905 | 3067 | // If we're here we're a failure. |
@@ -2918,31 +3080,33 @@ discard block |
||
2918 | 3080 | mktree(dirname($filename), 0755); |
2919 | 3081 | $package_ftp->create_file($ftp_file); |
2920 | 3082 | $package_ftp->chmod($ftp_file, 0755); |
3083 | + } else { |
|
3084 | + $file_permissions = @fileperms($filename); |
|
2921 | 3085 | } |
2922 | - else |
|
2923 | - $file_permissions = @fileperms($filename); |
|
2924 | 3086 | |
2925 | 3087 | if ($perm_state != 'writable') |
2926 | 3088 | { |
2927 | 3089 | $package_ftp->chmod($ftp_file, $perm_state == 'execute' ? 0755 : 0644); |
2928 | - } |
|
2929 | - else |
|
3090 | + } else |
|
2930 | 3091 | { |
2931 | - if (!@is_writable($filename)) |
|
2932 | - $package_ftp->chmod($ftp_file, 0777); |
|
2933 | - if (!@is_writable(dirname($filename))) |
|
2934 | - $package_ftp->chmod(dirname($ftp_file), 0777); |
|
3092 | + if (!@is_writable($filename)) { |
|
3093 | + $package_ftp->chmod($ftp_file, 0777); |
|
3094 | + } |
|
3095 | + if (!@is_writable(dirname($filename))) { |
|
3096 | + $package_ftp->chmod(dirname($ftp_file), 0777); |
|
3097 | + } |
|
2935 | 3098 | } |
2936 | 3099 | |
2937 | 3100 | if (@is_writable($filename)) |
2938 | 3101 | { |
2939 | - if ($track_change) |
|
2940 | - $_SESSION['pack_ftp']['original_perms'][$filename] = $file_permissions; |
|
3102 | + if ($track_change) { |
|
3103 | + $_SESSION['pack_ftp']['original_perms'][$filename] = $file_permissions; |
|
3104 | + } |
|
2941 | 3105 | |
2942 | 3106 | return true; |
3107 | + } elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$filename])) { |
|
3108 | + unset($_SESSION['pack_ftp']['original_perms'][$filename]); |
|
2943 | 3109 | } |
2944 | - elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$filename])) |
|
2945 | - unset($_SESSION['pack_ftp']['original_perms'][$filename]); |
|
2946 | 3110 | } |
2947 | 3111 | |
2948 | 3112 | // Oh dear, we failed if we get here. |
@@ -2960,11 +3124,13 @@ discard block |
||
2960 | 3124 | $n = strlen($pass); |
2961 | 3125 | |
2962 | 3126 | $salt = session_id(); |
2963 | - while (strlen($salt) < $n) |
|
2964 | - $salt .= session_id(); |
|
3127 | + while (strlen($salt) < $n) { |
|
3128 | + $salt .= session_id(); |
|
3129 | + } |
|
2965 | 3130 | |
2966 | - for ($i = 0; $i < $n; $i++) |
|
2967 | - $pass{$i} = chr(ord($pass{$i}) ^ (ord($salt{$i}) - 32)); |
|
3131 | + for ($i = 0; $i < $n; $i++) { |
|
3132 | + $pass{$i} = chr(ord($pass{$i}) ^ (ord($salt{$i}) - 32)); |
|
3133 | + } |
|
2968 | 3134 | |
2969 | 3135 | return $pass; |
2970 | 3136 | } |
@@ -2983,8 +3149,9 @@ discard block |
||
2983 | 3149 | $base_files = array('index.php', 'SSI.php', 'agreement.txt', 'cron.php', 'ssi_examples.php', 'ssi_examples.shtml', 'subscriptions.php'); |
2984 | 3150 | foreach ($base_files as $file) |
2985 | 3151 | { |
2986 | - if (file_exists($boarddir . '/' . $file)) |
|
2987 | - $files[empty($_REQUEST['use_full_paths']) ? $file : $boarddir . '/' . $file] = $boarddir . '/' . $file; |
|
3152 | + if (file_exists($boarddir . '/' . $file)) { |
|
3153 | + $files[empty($_REQUEST['use_full_paths']) ? $file : $boarddir . '/' . $file] = $boarddir . '/' . $file; |
|
3154 | + } |
|
2988 | 3155 | } |
2989 | 3156 | |
2990 | 3157 | $dirs = array( |
@@ -3001,8 +3168,9 @@ discard block |
||
3001 | 3168 | 'theme_dir' => 'theme_dir', |
3002 | 3169 | ) |
3003 | 3170 | ); |
3004 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3005 | - $dirs[$row['value']] = empty($_REQUEST['use_full_paths']) ? 'Themes/' . basename($row['value']) . '/' : strtr($row['value'] . '/', '\\', '/'); |
|
3171 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3172 | + $dirs[$row['value']] = empty($_REQUEST['use_full_paths']) ? 'Themes/' . basename($row['value']) . '/' : strtr($row['value'] . '/', '\\', '/'); |
|
3173 | + } |
|
3006 | 3174 | $smcFunc['db_free_result']($request); |
3007 | 3175 | |
3008 | 3176 | try |
@@ -3017,11 +3185,13 @@ discard block |
||
3017 | 3185 | |
3018 | 3186 | foreach ($iter as $entry => $dir) |
3019 | 3187 | { |
3020 | - if ($dir->isDir()) |
|
3021 | - continue; |
|
3188 | + if ($dir->isDir()) { |
|
3189 | + continue; |
|
3190 | + } |
|
3022 | 3191 | |
3023 | - if (preg_match('~^(\.{1,2}|CVS|backup.*|help|images|.*\~)$~', $entry) != 0) |
|
3024 | - continue; |
|
3192 | + if (preg_match('~^(\.{1,2}|CVS|backup.*|help|images|.*\~)$~', $entry) != 0) { |
|
3193 | + continue; |
|
3194 | + } |
|
3025 | 3195 | |
3026 | 3196 | $files[empty($_REQUEST['use_full_paths']) ? str_replace(realpath($boarddir), '', $entry) : $entry] = $entry; |
3027 | 3197 | } |
@@ -3029,26 +3199,30 @@ discard block |
||
3029 | 3199 | $obj = new ArrayObject($files); |
3030 | 3200 | $iterator = $obj->getIterator(); |
3031 | 3201 | |
3032 | - if (!file_exists($packagesdir . '/backups')) |
|
3033 | - mktree($packagesdir . '/backups', 0777); |
|
3034 | - if (!is_writable($packagesdir . '/backups')) |
|
3035 | - package_chmod($packagesdir . '/backups'); |
|
3202 | + if (!file_exists($packagesdir . '/backups')) { |
|
3203 | + mktree($packagesdir . '/backups', 0777); |
|
3204 | + } |
|
3205 | + if (!is_writable($packagesdir . '/backups')) { |
|
3206 | + package_chmod($packagesdir . '/backups'); |
|
3207 | + } |
|
3036 | 3208 | $output_file = $packagesdir . '/backups/' . strftime('%Y-%m-%d_') . preg_replace('~[$\\\\/:<>|?*"\']~', '', $id); |
3037 | 3209 | $output_ext = '.tar'; |
3038 | 3210 | |
3039 | 3211 | if (file_exists($output_file . $output_ext)) |
3040 | 3212 | { |
3041 | 3213 | $i = 2; |
3042 | - while (file_exists($output_file . '_' . $i . $output_ext)) |
|
3043 | - $i++; |
|
3214 | + while (file_exists($output_file . '_' . $i . $output_ext)) { |
|
3215 | + $i++; |
|
3216 | + } |
|
3044 | 3217 | $output_file = $output_file . '_' . $i . $output_ext; |
3218 | + } else { |
|
3219 | + $output_file .= $output_ext; |
|
3045 | 3220 | } |
3046 | - else |
|
3047 | - $output_file .= $output_ext; |
|
3048 | 3221 | |
3049 | 3222 | @set_time_limit(300); |
3050 | - if (function_exists('apache_reset_timeout')) |
|
3051 | - @apache_reset_timeout(); |
|
3223 | + if (function_exists('apache_reset_timeout')) { |
|
3224 | + @apache_reset_timeout(); |
|
3225 | + } |
|
3052 | 3226 | |
3053 | 3227 | $a = new PharData($output_file); |
3054 | 3228 | $a->buildFromIterator($iterator); |
@@ -3060,8 +3234,7 @@ discard block |
||
3060 | 3234 | */ |
3061 | 3235 | unset($a); |
3062 | 3236 | unlink($output_file); |
3063 | - } |
|
3064 | - catch (Exception $e) |
|
3237 | + } catch (Exception $e) |
|
3065 | 3238 | { |
3066 | 3239 | log_error($e->getMessage(), 'backup'); |
3067 | 3240 | |
@@ -3093,32 +3266,35 @@ discard block |
||
3093 | 3266 | preg_match('~^(http|ftp)(s)?://([^/:]+)(:(\d+))?(.+)$~', $url, $match); |
3094 | 3267 | |
3095 | 3268 | // An FTP url. We should try connecting and RETRieving it... |
3096 | - if (empty($match[1])) |
|
3097 | - return false; |
|
3098 | - elseif ($match[1] == 'ftp') |
|
3269 | + if (empty($match[1])) { |
|
3270 | + return false; |
|
3271 | + } elseif ($match[1] == 'ftp') |
|
3099 | 3272 | { |
3100 | 3273 | // Include the file containing the ftp_connection class. |
3101 | 3274 | require_once($sourcedir . '/Class-Package.php'); |
3102 | 3275 | |
3103 | 3276 | // Establish a connection and attempt to enable passive mode. |
3104 | 3277 | $ftp = new ftp_connection(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? 21 : $match[5], 'anonymous', $webmaster_email); |
3105 | - if ($ftp->error !== false || !$ftp->passive()) |
|
3106 | - return false; |
|
3278 | + if ($ftp->error !== false || !$ftp->passive()) { |
|
3279 | + return false; |
|
3280 | + } |
|
3107 | 3281 | |
3108 | 3282 | // I want that one *points*! |
3109 | 3283 | fwrite($ftp->connection, 'RETR ' . $match[6] . "\r\n"); |
3110 | 3284 | |
3111 | 3285 | // Since passive mode worked (or we would have returned already!) open the connection. |
3112 | 3286 | $fp = @fsockopen($ftp->pasv['ip'], $ftp->pasv['port'], $err, $err, 5); |
3113 | - if (!$fp) |
|
3114 | - return false; |
|
3287 | + if (!$fp) { |
|
3288 | + return false; |
|
3289 | + } |
|
3115 | 3290 | |
3116 | 3291 | // The server should now say something in acknowledgement. |
3117 | 3292 | $ftp->check_response(150); |
3118 | 3293 | |
3119 | 3294 | $data = ''; |
3120 | - while (!feof($fp)) |
|
3121 | - $data .= fread($fp, 4096); |
|
3295 | + while (!feof($fp)) { |
|
3296 | + $data .= fread($fp, 4096); |
|
3297 | + } |
|
3122 | 3298 | fclose($fp); |
3123 | 3299 | |
3124 | 3300 | // All done, right? Good. |
@@ -3135,22 +3311,25 @@ discard block |
||
3135 | 3311 | $fetch_data->get_url_data($url, $post_data); |
3136 | 3312 | |
3137 | 3313 | // no errors and a 200 result, then we have a good dataset, well we at least have data ;) |
3138 | - if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) |
|
3139 | - $data = $fetch_data->result('body'); |
|
3140 | - else |
|
3141 | - return false; |
|
3314 | + if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) { |
|
3315 | + $data = $fetch_data->result('body'); |
|
3316 | + } else { |
|
3317 | + return false; |
|
3318 | + } |
|
3142 | 3319 | } |
3143 | 3320 | // This is more likely; a standard HTTP URL. |
3144 | 3321 | elseif (isset($match[1]) && $match[1] == 'http') |
3145 | 3322 | { |
3146 | - if ($keep_alive && $match[3] == $keep_alive_dom) |
|
3147 | - $fp = $keep_alive_fp; |
|
3323 | + if ($keep_alive && $match[3] == $keep_alive_dom) { |
|
3324 | + $fp = $keep_alive_fp; |
|
3325 | + } |
|
3148 | 3326 | if (empty($fp)) |
3149 | 3327 | { |
3150 | 3328 | // Open the socket on the port we want... |
3151 | 3329 | $fp = @fsockopen(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? ($match[2] ? 443 : 80) : $match[5], $err, $err, 5); |
3152 | - if (!$fp) |
|
3153 | - return false; |
|
3330 | + if (!$fp) { |
|
3331 | + return false; |
|
3332 | + } |
|
3154 | 3333 | } |
3155 | 3334 | |
3156 | 3335 | if ($keep_alive) |
@@ -3165,20 +3344,21 @@ discard block |
||
3165 | 3344 | fwrite($fp, 'GET ' . ($match[6] !== '/' ? str_replace(' ', '%20', $match[6]) : '') . ' HTTP/1.0' . "\r\n"); |
3166 | 3345 | fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n"); |
3167 | 3346 | fwrite($fp, 'User-Agent: PHP/SMF' . "\r\n"); |
3168 | - if ($keep_alive) |
|
3169 | - fwrite($fp, 'Connection: Keep-Alive' . "\r\n\r\n"); |
|
3170 | - else |
|
3171 | - fwrite($fp, 'Connection: close' . "\r\n\r\n"); |
|
3172 | - } |
|
3173 | - else |
|
3347 | + if ($keep_alive) { |
|
3348 | + fwrite($fp, 'Connection: Keep-Alive' . "\r\n\r\n"); |
|
3349 | + } else { |
|
3350 | + fwrite($fp, 'Connection: close' . "\r\n\r\n"); |
|
3351 | + } |
|
3352 | + } else |
|
3174 | 3353 | { |
3175 | 3354 | fwrite($fp, 'POST ' . ($match[6] !== '/' ? $match[6] : '') . ' HTTP/1.0' . "\r\n"); |
3176 | 3355 | fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n"); |
3177 | 3356 | fwrite($fp, 'User-Agent: PHP/SMF' . "\r\n"); |
3178 | - if ($keep_alive) |
|
3179 | - fwrite($fp, 'Connection: Keep-Alive' . "\r\n"); |
|
3180 | - else |
|
3181 | - fwrite($fp, 'Connection: close' . "\r\n"); |
|
3357 | + if ($keep_alive) { |
|
3358 | + fwrite($fp, 'Connection: Keep-Alive' . "\r\n"); |
|
3359 | + } else { |
|
3360 | + fwrite($fp, 'Connection: close' . "\r\n"); |
|
3361 | + } |
|
3182 | 3362 | fwrite($fp, 'Content-Type: application/x-www-form-urlencoded' . "\r\n"); |
3183 | 3363 | fwrite($fp, 'Content-Length: ' . strlen($post_data) . "\r\n\r\n"); |
3184 | 3364 | fwrite($fp, $post_data); |
@@ -3191,30 +3371,33 @@ discard block |
||
3191 | 3371 | { |
3192 | 3372 | $header = ''; |
3193 | 3373 | $location = ''; |
3194 | - while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') |
|
3195 | - if (strpos($header, 'Location:') !== false) |
|
3374 | + while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') { |
|
3375 | + if (strpos($header, 'Location:') !== false) |
|
3196 | 3376 | $location = trim(substr($header, strpos($header, ':') + 1)); |
3377 | + } |
|
3197 | 3378 | |
3198 | - if (empty($location)) |
|
3199 | - return false; |
|
3200 | - else |
|
3379 | + if (empty($location)) { |
|
3380 | + return false; |
|
3381 | + } else |
|
3201 | 3382 | { |
3202 | - if (!$keep_alive) |
|
3203 | - fclose($fp); |
|
3383 | + if (!$keep_alive) { |
|
3384 | + fclose($fp); |
|
3385 | + } |
|
3204 | 3386 | return fetch_web_data($location, $post_data, $keep_alive, $redirection_level + 1); |
3205 | 3387 | } |
3206 | 3388 | } |
3207 | 3389 | |
3208 | 3390 | // Make sure we get a 200 OK. |
3209 | - elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) |
|
3210 | - return false; |
|
3391 | + elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) { |
|
3392 | + return false; |
|
3393 | + } |
|
3211 | 3394 | |
3212 | 3395 | // Skip the headers... |
3213 | 3396 | while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') |
3214 | 3397 | { |
3215 | - if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) |
|
3216 | - $content_length = $match[1]; |
|
3217 | - elseif (preg_match('~connection:\s*close~i', $header) != 0) |
|
3398 | + if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) { |
|
3399 | + $content_length = $match[1]; |
|
3400 | + } elseif (preg_match('~connection:\s*close~i', $header) != 0) |
|
3218 | 3401 | { |
3219 | 3402 | $keep_alive_dom = null; |
3220 | 3403 | $keep_alive = false; |
@@ -3226,19 +3409,20 @@ discard block |
||
3226 | 3409 | $data = ''; |
3227 | 3410 | if (isset($content_length)) |
3228 | 3411 | { |
3229 | - while (!feof($fp) && strlen($data) < $content_length) |
|
3230 | - $data .= fread($fp, $content_length - strlen($data)); |
|
3231 | - } |
|
3232 | - else |
|
3412 | + while (!feof($fp) && strlen($data) < $content_length) { |
|
3413 | + $data .= fread($fp, $content_length - strlen($data)); |
|
3414 | + } |
|
3415 | + } else |
|
3233 | 3416 | { |
3234 | - while (!feof($fp)) |
|
3235 | - $data .= fread($fp, 4096); |
|
3417 | + while (!feof($fp)) { |
|
3418 | + $data .= fread($fp, 4096); |
|
3419 | + } |
|
3236 | 3420 | } |
3237 | 3421 | |
3238 | - if (!$keep_alive) |
|
3239 | - fclose($fp); |
|
3240 | - } |
|
3241 | - else |
|
3422 | + if (!$keep_alive) { |
|
3423 | + fclose($fp); |
|
3424 | + } |
|
3425 | + } else |
|
3242 | 3426 | { |
3243 | 3427 | // Umm, this shouldn't happen? |
3244 | 3428 | trigger_error('fetch_web_data(): Bad URL', E_USER_NOTICE); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @param bool $single_file If true returns the contents of the file specified by destination if it exists |
29 | 29 | * @param bool $overwrite Whether to overwrite existing files |
30 | 30 | * @param null|array $files_to_extract Specific files to extract |
31 | - * @return array|false An array of information about extracted files or false on failure |
|
31 | + * @return string An array of information about extracted files or false on failure |
|
32 | 32 | */ |
33 | 33 | function read_tgz_file($gzfilename, $destination, $single_file = false, $overwrite = false, $files_to_extract = null) |
34 | 34 | { |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param bool $single_file Whether to only extract a single file |
60 | 60 | * @param bool $overwrite Whether to overwrite existing data |
61 | 61 | * @param null|array $files_to_extract If set, only extracts the specified files |
62 | - * @return array|false An array of information about the extracted files or false on failure |
|
62 | + * @return string An array of information about the extracted files or false on failure |
|
63 | 63 | */ |
64 | 64 | function read_tgz_data($gzfilename, $destination, $single_file = false, $overwrite = false, $files_to_extract = null) |
65 | 65 | { |
@@ -3255,7 +3255,7 @@ discard block |
||
3255 | 3255 | * https://php.net/crc32#79567 |
3256 | 3256 | * |
3257 | 3257 | * @param string $number |
3258 | - * @return string The crc32 |
|
3258 | + * @return integer The crc32 |
|
3259 | 3259 | */ |
3260 | 3260 | function smf_crc32($number) |
3261 | 3261 | { |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('Location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
6 | -else |
|
6 | +} else { |
|
7 | 7 | exit; |
8 | +} |
|
8 | 9 | |
9 | 10 | ?> |
10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
6 | -else |
|
6 | +} else { |
|
7 | 7 | exit; |
8 | +} |
|
8 | 9 | |
9 | 10 | ?> |
10 | 11 | \ No newline at end of file |
@@ -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 | * Check if the user is who he/she says he is |
@@ -42,12 +43,14 @@ discard block |
||
42 | 43 | $refreshTime = isset($_GET['xml']) ? 4200 : 3600; |
43 | 44 | |
44 | 45 | // Is the security option off? |
45 | - if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) |
|
46 | - return; |
|
46 | + if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) { |
|
47 | + return; |
|
48 | + } |
|
47 | 49 | |
48 | 50 | // Or are they already logged in?, Moderator or admin session is need for this area |
49 | - if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) |
|
50 | - return; |
|
51 | + if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) { |
|
52 | + return; |
|
53 | + } |
|
51 | 54 | |
52 | 55 | require_once($sourcedir . '/Subs-Auth.php'); |
53 | 56 | |
@@ -55,8 +58,9 @@ discard block |
||
55 | 58 | if (isset($_POST[$type . '_pass'])) |
56 | 59 | { |
57 | 60 | // Check to ensure we're forcing SSL for authentication |
58 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
59 | - fatal_lang_error('login_ssl_required'); |
|
61 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
62 | + fatal_lang_error('login_ssl_required'); |
|
63 | + } |
|
60 | 64 | |
61 | 65 | checkSession(); |
62 | 66 | |
@@ -72,17 +76,19 @@ discard block |
||
72 | 76 | } |
73 | 77 | |
74 | 78 | // Better be sure to remember the real referer |
75 | - if (empty($_SESSION['request_referer'])) |
|
76 | - $_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
77 | - elseif (empty($_POST)) |
|
78 | - unset($_SESSION['request_referer']); |
|
79 | + if (empty($_SESSION['request_referer'])) { |
|
80 | + $_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
81 | + } elseif (empty($_POST)) { |
|
82 | + unset($_SESSION['request_referer']); |
|
83 | + } |
|
79 | 84 | |
80 | 85 | // Need to type in a password for that, man. |
81 | - if (!isset($_GET['xml'])) |
|
82 | - adminLogin($type); |
|
83 | - else |
|
84 | - return 'session_verify_fail'; |
|
85 | -} |
|
86 | + if (!isset($_GET['xml'])) { |
|
87 | + adminLogin($type); |
|
88 | + } else { |
|
89 | + return 'session_verify_fail'; |
|
90 | + } |
|
91 | + } |
|
86 | 92 | |
87 | 93 | /** |
88 | 94 | * Require a user who is logged in. (not a guest.) |
@@ -96,25 +102,30 @@ discard block |
||
96 | 102 | global $user_info, $txt, $context, $scripturl, $modSettings; |
97 | 103 | |
98 | 104 | // Luckily, this person isn't a guest. |
99 | - if (!$user_info['is_guest']) |
|
100 | - return; |
|
105 | + if (!$user_info['is_guest']) { |
|
106 | + return; |
|
107 | + } |
|
101 | 108 | |
102 | 109 | // Log what they were trying to do didn't work) |
103 | - if (!empty($modSettings['who_enabled'])) |
|
104 | - $_GET['error'] = 'guest_login'; |
|
110 | + if (!empty($modSettings['who_enabled'])) { |
|
111 | + $_GET['error'] = 'guest_login'; |
|
112 | + } |
|
105 | 113 | writeLog(true); |
106 | 114 | |
107 | 115 | // Just die. |
108 | - if (isset($_REQUEST['xml'])) |
|
109 | - obExit(false); |
|
116 | + if (isset($_REQUEST['xml'])) { |
|
117 | + obExit(false); |
|
118 | + } |
|
110 | 119 | |
111 | 120 | // Attempt to detect if they came from dlattach. |
112 | - if (SMF != 'SSI' && empty($context['theme_loaded'])) |
|
113 | - loadTheme(); |
|
121 | + if (SMF != 'SSI' && empty($context['theme_loaded'])) { |
|
122 | + loadTheme(); |
|
123 | + } |
|
114 | 124 | |
115 | 125 | // Never redirect to an attachment |
116 | - if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) |
|
117 | - $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
126 | + if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) { |
|
127 | + $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
128 | + } |
|
118 | 129 | |
119 | 130 | // Load the Login template and language file. |
120 | 131 | loadLanguage('Login'); |
@@ -124,8 +135,7 @@ discard block |
||
124 | 135 | { |
125 | 136 | $_SESSION['login_url'] = $scripturl . '?' . $_SERVER['QUERY_STRING']; |
126 | 137 | redirectexit('action=login'); |
127 | - } |
|
128 | - else |
|
138 | + } else |
|
129 | 139 | { |
130 | 140 | loadTemplate('Login'); |
131 | 141 | $context['sub_template'] = 'kick_guest'; |
@@ -155,8 +165,9 @@ discard block |
||
155 | 165 | global $sourcedir, $cookiename, $user_settings, $smcFunc; |
156 | 166 | |
157 | 167 | // You cannot be banned if you are an admin - doesn't help if you log out. |
158 | - if ($user_info['is_admin']) |
|
159 | - return; |
|
168 | + if ($user_info['is_admin']) { |
|
169 | + return; |
|
170 | + } |
|
160 | 171 | |
161 | 172 | // Only check the ban every so often. (to reduce load.) |
162 | 173 | if ($forceCheck || !isset($_SESSION['ban']) || empty($modSettings['banLastUpdated']) || ($_SESSION['ban']['last_checked'] < $modSettings['banLastUpdated']) || $_SESSION['ban']['id_member'] != $user_info['id'] || $_SESSION['ban']['ip'] != $user_info['ip'] || $_SESSION['ban']['ip2'] != $user_info['ip2'] || (isset($user_info['email'], $_SESSION['ban']['email']) && $_SESSION['ban']['email'] != $user_info['email'])) |
@@ -177,8 +188,9 @@ discard block |
||
177 | 188 | // Check both IP addresses. |
178 | 189 | foreach (array('ip', 'ip2') as $ip_number) |
179 | 190 | { |
180 | - if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) |
|
181 | - continue; |
|
191 | + if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) { |
|
192 | + continue; |
|
193 | + } |
|
182 | 194 | $ban_query[] = ' {inet:' . $ip_number . '} BETWEEN bi.ip_low and bi.ip_high'; |
183 | 195 | $ban_query_vars[$ip_number] = $user_info[$ip_number]; |
184 | 196 | // IP was valid, maybe there's also a hostname... |
@@ -228,24 +240,28 @@ discard block |
||
228 | 240 | // Store every type of ban that applies to you in your session. |
229 | 241 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
230 | 242 | { |
231 | - foreach ($restrictions as $restriction) |
|
232 | - if (!empty($row[$restriction])) |
|
243 | + foreach ($restrictions as $restriction) { |
|
244 | + if (!empty($row[$restriction])) |
|
233 | 245 | { |
234 | 246 | $_SESSION['ban'][$restriction]['reason'] = $row['reason']; |
247 | + } |
|
235 | 248 | $_SESSION['ban'][$restriction]['ids'][] = $row['id_ban']; |
236 | - if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) |
|
237 | - $_SESSION['ban']['expire_time'] = $row['expire_time']; |
|
249 | + if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) { |
|
250 | + $_SESSION['ban']['expire_time'] = $row['expire_time']; |
|
251 | + } |
|
238 | 252 | |
239 | - if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) |
|
240 | - $flag_is_activated = true; |
|
253 | + if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) { |
|
254 | + $flag_is_activated = true; |
|
255 | + } |
|
241 | 256 | } |
242 | 257 | } |
243 | 258 | $smcFunc['db_free_result']($request); |
244 | 259 | } |
245 | 260 | |
246 | 261 | // Mark the cannot_access and cannot_post bans as being 'hit'. |
247 | - if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) |
|
248 | - log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array())); |
|
262 | + if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) { |
|
263 | + log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array())); |
|
264 | + } |
|
249 | 265 | |
250 | 266 | // If for whatever reason the is_activated flag seems wrong, do a little work to clear it up. |
251 | 267 | if ($user_info['id'] && (($user_settings['is_activated'] >= 10 && !$flag_is_activated) |
@@ -260,8 +276,9 @@ discard block |
||
260 | 276 | if (!isset($_SESSION['ban']['cannot_access']) && !empty($_COOKIE[$cookiename . '_'])) |
261 | 277 | { |
262 | 278 | $bans = explode(',', $_COOKIE[$cookiename . '_']); |
263 | - foreach ($bans as $key => $value) |
|
264 | - $bans[$key] = (int) $value; |
|
279 | + foreach ($bans as $key => $value) { |
|
280 | + $bans[$key] = (int) $value; |
|
281 | + } |
|
265 | 282 | $request = $smcFunc['db_query']('', ' |
266 | 283 | SELECT bi.id_ban, bg.reason |
267 | 284 | FROM {db_prefix}ban_items AS bi |
@@ -297,14 +314,15 @@ discard block |
||
297 | 314 | if (isset($_SESSION['ban']['cannot_access'])) |
298 | 315 | { |
299 | 316 | // We don't wanna see you! |
300 | - if (!$user_info['is_guest']) |
|
301 | - $smcFunc['db_query']('', ' |
|
317 | + if (!$user_info['is_guest']) { |
|
318 | + $smcFunc['db_query']('', ' |
|
302 | 319 | DELETE FROM {db_prefix}log_online |
303 | 320 | WHERE id_member = {int:current_member}', |
304 | 321 | array( |
305 | 322 | 'current_member' => $user_info['id'], |
306 | 323 | ) |
307 | 324 | ); |
325 | + } |
|
308 | 326 | |
309 | 327 | // 'Log' the user out. Can't have any funny business... (save the name!) |
310 | 328 | $old_name = isset($user_info['name']) && $user_info['name'] != '' ? $user_info['name'] : $txt['guest_title']; |
@@ -390,9 +408,10 @@ discard block |
||
390 | 408 | } |
391 | 409 | |
392 | 410 | // Fix up the banning permissions. |
393 | - if (isset($user_info['permissions'])) |
|
394 | - banPermissions(); |
|
395 | -} |
|
411 | + if (isset($user_info['permissions'])) { |
|
412 | + banPermissions(); |
|
413 | + } |
|
414 | + } |
|
396 | 415 | |
397 | 416 | /** |
398 | 417 | * Fix permissions according to ban status. |
@@ -403,8 +422,9 @@ discard block |
||
403 | 422 | global $user_info, $sourcedir, $modSettings, $context; |
404 | 423 | |
405 | 424 | // Somehow they got here, at least take away all permissions... |
406 | - if (isset($_SESSION['ban']['cannot_access'])) |
|
407 | - $user_info['permissions'] = array(); |
|
425 | + if (isset($_SESSION['ban']['cannot_access'])) { |
|
426 | + $user_info['permissions'] = array(); |
|
427 | + } |
|
408 | 428 | // Okay, well, you can watch, but don't touch a thing. |
409 | 429 | elseif (isset($_SESSION['ban']['cannot_post']) || (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $user_info['warning'])) |
410 | 430 | { |
@@ -446,44 +466,45 @@ discard block |
||
446 | 466 | call_integration_hook('integrate_warn_permissions', array(&$permission_change)); |
447 | 467 | foreach ($permission_change as $old => $new) |
448 | 468 | { |
449 | - if (!in_array($old, $user_info['permissions'])) |
|
450 | - unset($permission_change[$old]); |
|
451 | - else |
|
452 | - $user_info['permissions'][] = $new; |
|
469 | + if (!in_array($old, $user_info['permissions'])) { |
|
470 | + unset($permission_change[$old]); |
|
471 | + } else { |
|
472 | + $user_info['permissions'][] = $new; |
|
473 | + } |
|
453 | 474 | } |
454 | 475 | $user_info['permissions'] = array_diff($user_info['permissions'], array_keys($permission_change)); |
455 | 476 | } |
456 | 477 | |
457 | 478 | // @todo Find a better place to call this? Needs to be after permissions loaded! |
458 | 479 | // Finally, some bits we cache in the session because it saves queries. |
459 | - if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) |
|
460 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
461 | - else |
|
480 | + if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) { |
|
481 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
482 | + } else |
|
462 | 483 | { |
463 | 484 | require_once($sourcedir . '/Subs-Auth.php'); |
464 | 485 | rebuildModCache(); |
465 | 486 | } |
466 | 487 | |
467 | 488 | // Now that we have the mod cache taken care of lets setup a cache for the number of mod reports still open |
468 | - if (!empty($_SESSION['rc']) && $_SESSION['rc']['time'] > $modSettings['last_mod_report_action'] && $_SESSION['rc']['id'] == $user_info['id']) |
|
469 | - $context['open_mod_reports'] = $_SESSION['rc']['reports']; |
|
470 | - elseif ($_SESSION['mc']['bq'] != '0=1') |
|
489 | + if (!empty($_SESSION['rc']) && $_SESSION['rc']['time'] > $modSettings['last_mod_report_action'] && $_SESSION['rc']['id'] == $user_info['id']) { |
|
490 | + $context['open_mod_reports'] = $_SESSION['rc']['reports']; |
|
491 | + } elseif ($_SESSION['mc']['bq'] != '0=1') |
|
471 | 492 | { |
472 | 493 | require_once($sourcedir . '/Subs-ReportedContent.php'); |
473 | 494 | recountOpenReports('posts'); |
495 | + } else { |
|
496 | + $context['open_mod_reports'] = 0; |
|
474 | 497 | } |
475 | - else |
|
476 | - $context['open_mod_reports'] = 0; |
|
477 | 498 | |
478 | - if (!empty($_SESSION['rc']) && $_SESSION['rc']['time'] > $modSettings['last_mod_report_action'] && $_SESSION['rc']['id'] == $user_info['id']) |
|
479 | - $context['open_member_reports'] = !empty($_SESSION['rc']['member_reports']) ? $_SESSION['rc']['member_reports'] : 0; |
|
480 | - elseif (allowedTo('moderate_forum')) |
|
499 | + if (!empty($_SESSION['rc']) && $_SESSION['rc']['time'] > $modSettings['last_mod_report_action'] && $_SESSION['rc']['id'] == $user_info['id']) { |
|
500 | + $context['open_member_reports'] = !empty($_SESSION['rc']['member_reports']) ? $_SESSION['rc']['member_reports'] : 0; |
|
501 | + } elseif (allowedTo('moderate_forum')) |
|
481 | 502 | { |
482 | 503 | require_once($sourcedir . '/Subs-ReportedContent.php'); |
483 | 504 | recountOpenReports('members'); |
505 | + } else { |
|
506 | + $context['open_member_reports'] = 0; |
|
484 | 507 | } |
485 | - else |
|
486 | - $context['open_member_reports'] = 0; |
|
487 | 508 | |
488 | 509 | } |
489 | 510 | |
@@ -500,8 +521,9 @@ discard block |
||
500 | 521 | global $user_info, $smcFunc; |
501 | 522 | |
502 | 523 | // Don't log web accelerators, it's very confusing... |
503 | - if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
|
504 | - return; |
|
524 | + if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') { |
|
525 | + return; |
|
526 | + } |
|
505 | 527 | |
506 | 528 | $smcFunc['db_insert']('', |
507 | 529 | '{db_prefix}log_banned', |
@@ -511,8 +533,8 @@ discard block |
||
511 | 533 | ); |
512 | 534 | |
513 | 535 | // One extra point for these bans. |
514 | - if (!empty($ban_ids)) |
|
515 | - $smcFunc['db_query']('', ' |
|
536 | + if (!empty($ban_ids)) { |
|
537 | + $smcFunc['db_query']('', ' |
|
516 | 538 | UPDATE {db_prefix}ban_items |
517 | 539 | SET hits = hits + 1 |
518 | 540 | WHERE id_ban IN ({array_int:ban_ids})', |
@@ -520,7 +542,8 @@ discard block |
||
520 | 542 | 'ban_ids' => $ban_ids, |
521 | 543 | ) |
522 | 544 | ); |
523 | -} |
|
545 | + } |
|
546 | + } |
|
524 | 547 | |
525 | 548 | /** |
526 | 549 | * Checks if a given email address might be banned. |
@@ -536,8 +559,9 @@ discard block |
||
536 | 559 | global $txt, $smcFunc; |
537 | 560 | |
538 | 561 | // Can't ban an empty email |
539 | - if (empty($email) || trim($email) == '') |
|
540 | - return; |
|
562 | + if (empty($email) || trim($email) == '') { |
|
563 | + return; |
|
564 | + } |
|
541 | 565 | |
542 | 566 | // Let's start with the bans based on your IP/hostname/memberID... |
543 | 567 | $ban_ids = isset($_SESSION['ban'][$restriction]) ? $_SESSION['ban'][$restriction]['ids'] : array(); |
@@ -610,16 +634,18 @@ discard block |
||
610 | 634 | if ($type == 'post') |
611 | 635 | { |
612 | 636 | $check = isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null); |
613 | - if ($check !== $sc) |
|
614 | - $error = 'session_timeout'; |
|
637 | + if ($check !== $sc) { |
|
638 | + $error = 'session_timeout'; |
|
639 | + } |
|
615 | 640 | } |
616 | 641 | |
617 | 642 | // How about $_GET['sesc']? |
618 | 643 | elseif ($type == 'get') |
619 | 644 | { |
620 | 645 | $check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : null); |
621 | - if ($check !== $sc) |
|
622 | - $error = 'session_verify_fail'; |
|
646 | + if ($check !== $sc) { |
|
647 | + $error = 'session_verify_fail'; |
|
648 | + } |
|
623 | 649 | } |
624 | 650 | |
625 | 651 | // Or can it be in either? |
@@ -627,13 +653,15 @@ discard block |
||
627 | 653 | { |
628 | 654 | $check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : (isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null))); |
629 | 655 | |
630 | - if ($check !== $sc) |
|
631 | - $error = 'session_verify_fail'; |
|
656 | + if ($check !== $sc) { |
|
657 | + $error = 'session_verify_fail'; |
|
658 | + } |
|
632 | 659 | } |
633 | 660 | |
634 | 661 | // Verify that they aren't changing user agents on us - that could be bad. |
635 | - if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) |
|
636 | - $error = 'session_verify_fail'; |
|
662 | + if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) { |
|
663 | + $error = 'session_verify_fail'; |
|
664 | + } |
|
637 | 665 | |
638 | 666 | // Make sure a page with session check requirement is not being prefetched. |
639 | 667 | if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
@@ -644,30 +672,35 @@ discard block |
||
644 | 672 | } |
645 | 673 | |
646 | 674 | // Check the referring site - it should be the same server at least! |
647 | - if (isset($_SESSION['request_referer'])) |
|
648 | - $referrer = $_SESSION['request_referer']; |
|
649 | - else |
|
650 | - $referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
675 | + if (isset($_SESSION['request_referer'])) { |
|
676 | + $referrer = $_SESSION['request_referer']; |
|
677 | + } else { |
|
678 | + $referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
679 | + } |
|
651 | 680 | if (!empty($referrer['host'])) |
652 | 681 | { |
653 | - if (strpos($_SERVER['HTTP_HOST'], ':') !== false) |
|
654 | - $real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':')); |
|
655 | - else |
|
656 | - $real_host = $_SERVER['HTTP_HOST']; |
|
682 | + if (strpos($_SERVER['HTTP_HOST'], ':') !== false) { |
|
683 | + $real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':')); |
|
684 | + } else { |
|
685 | + $real_host = $_SERVER['HTTP_HOST']; |
|
686 | + } |
|
657 | 687 | |
658 | 688 | $parsed_url = parse_url($boardurl); |
659 | 689 | |
660 | 690 | // Are global cookies on? If so, let's check them ;). |
661 | 691 | if (!empty($modSettings['globalCookies'])) |
662 | 692 | { |
663 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
664 | - $parsed_url['host'] = $parts[1]; |
|
693 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
694 | + $parsed_url['host'] = $parts[1]; |
|
695 | + } |
|
665 | 696 | |
666 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) |
|
667 | - $referrer['host'] = $parts[1]; |
|
697 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) { |
|
698 | + $referrer['host'] = $parts[1]; |
|
699 | + } |
|
668 | 700 | |
669 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) |
|
670 | - $real_host = $parts[1]; |
|
701 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) { |
|
702 | + $real_host = $parts[1]; |
|
703 | + } |
|
671 | 704 | } |
672 | 705 | |
673 | 706 | // Okay: referrer must either match parsed_url or real_host. |
@@ -685,12 +718,14 @@ discard block |
||
685 | 718 | $log_error = true; |
686 | 719 | } |
687 | 720 | |
688 | - if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') |
|
689 | - fatal_error('Sound the alarm! It\'s a hacker! Close the castle gates!!', false); |
|
721 | + if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') { |
|
722 | + fatal_error('Sound the alarm! It\'s a hacker! Close the castle gates!!', false); |
|
723 | + } |
|
690 | 724 | |
691 | 725 | // Everything is ok, return an empty string. |
692 | - if (!isset($error)) |
|
693 | - return ''; |
|
726 | + if (!isset($error)) { |
|
727 | + return ''; |
|
728 | + } |
|
694 | 729 | // A session error occurred, show the error. |
695 | 730 | elseif ($is_fatal) |
696 | 731 | { |
@@ -699,13 +734,14 @@ discard block |
||
699 | 734 | ob_end_clean(); |
700 | 735 | header('HTTP/1.1 403 Forbidden - Session timeout'); |
701 | 736 | die; |
737 | + } else { |
|
738 | + fatal_lang_error($error, isset($log_error) ? 'user' : false); |
|
702 | 739 | } |
703 | - else |
|
704 | - fatal_lang_error($error, isset($log_error) ? 'user' : false); |
|
705 | 740 | } |
706 | 741 | // A session error occurred, return the error to the calling function. |
707 | - else |
|
708 | - return $error; |
|
742 | + else { |
|
743 | + return $error; |
|
744 | + } |
|
709 | 745 | |
710 | 746 | // We really should never fall through here, for very important reasons. Let's make sure. |
711 | 747 | trigger_error('Hacking attempt...', E_USER_ERROR); |
@@ -721,10 +757,9 @@ discard block |
||
721 | 757 | { |
722 | 758 | global $modSettings; |
723 | 759 | |
724 | - if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) |
|
725 | - return true; |
|
726 | - |
|
727 | - else |
|
760 | + if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) { |
|
761 | + return true; |
|
762 | + } else |
|
728 | 763 | { |
729 | 764 | $token = md5(mt_rand() . session_id() . (string) microtime() . $modSettings['rand_seed']); |
730 | 765 | $_SESSION['confirm_' . $action] = md5($token . $_SERVER['HTTP_USER_AGENT']); |
@@ -775,9 +810,9 @@ discard block |
||
775 | 810 | $return = $_SESSION['token'][$type . '-' . $action][3]; |
776 | 811 | unset($_SESSION['token'][$type . '-' . $action]); |
777 | 812 | return $return; |
813 | + } else { |
|
814 | + return ''; |
|
778 | 815 | } |
779 | - else |
|
780 | - return ''; |
|
781 | 816 | } |
782 | 817 | |
783 | 818 | // This nasty piece of code validates a token. |
@@ -808,12 +843,14 @@ discard block |
||
808 | 843 | fatal_lang_error('token_verify_fail', false); |
809 | 844 | } |
810 | 845 | // Remove this token as its useless |
811 | - else |
|
812 | - unset($_SESSION['token'][$type . '-' . $action]); |
|
846 | + else { |
|
847 | + unset($_SESSION['token'][$type . '-' . $action]); |
|
848 | + } |
|
813 | 849 | |
814 | 850 | // Randomly check if we should remove some older tokens. |
815 | - if (mt_rand(0, 138) == 23) |
|
816 | - cleanTokens(); |
|
851 | + if (mt_rand(0, 138) == 23) { |
|
852 | + cleanTokens(); |
|
853 | + } |
|
817 | 854 | |
818 | 855 | return false; |
819 | 856 | } |
@@ -828,14 +865,16 @@ discard block |
||
828 | 865 | function cleanTokens($complete = false) |
829 | 866 | { |
830 | 867 | // We appreciate cleaning up after yourselves. |
831 | - if (!isset($_SESSION['token'])) |
|
832 | - return; |
|
868 | + if (!isset($_SESSION['token'])) { |
|
869 | + return; |
|
870 | + } |
|
833 | 871 | |
834 | 872 | // Clean up tokens, trying to give enough time still. |
835 | - foreach ($_SESSION['token'] as $key => $data) |
|
836 | - if ($data[2] + 10800 < time() || $complete) |
|
873 | + foreach ($_SESSION['token'] as $key => $data) { |
|
874 | + if ($data[2] + 10800 < time() || $complete) |
|
837 | 875 | unset($_SESSION['token'][$key]); |
838 | -} |
|
876 | + } |
|
877 | + } |
|
839 | 878 | |
840 | 879 | /** |
841 | 880 | * Check whether a form has been submitted twice. |
@@ -853,37 +892,40 @@ discard block |
||
853 | 892 | { |
854 | 893 | global $context; |
855 | 894 | |
856 | - if (!isset($_SESSION['forms'])) |
|
857 | - $_SESSION['forms'] = array(); |
|
895 | + if (!isset($_SESSION['forms'])) { |
|
896 | + $_SESSION['forms'] = array(); |
|
897 | + } |
|
858 | 898 | |
859 | 899 | // Register a form number and store it in the session stack. (use this on the page that has the form.) |
860 | 900 | if ($action == 'register') |
861 | 901 | { |
862 | 902 | $context['form_sequence_number'] = 0; |
863 | - while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) |
|
864 | - $context['form_sequence_number'] = mt_rand(1, 16000000); |
|
903 | + while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) { |
|
904 | + $context['form_sequence_number'] = mt_rand(1, 16000000); |
|
905 | + } |
|
865 | 906 | } |
866 | 907 | // Check whether the submitted number can be found in the session. |
867 | 908 | elseif ($action == 'check') |
868 | 909 | { |
869 | - if (!isset($_REQUEST['seqnum'])) |
|
870 | - return true; |
|
871 | - elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
910 | + if (!isset($_REQUEST['seqnum'])) { |
|
911 | + return true; |
|
912 | + } elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
872 | 913 | { |
873 | 914 | $_SESSION['forms'][] = (int) $_REQUEST['seqnum']; |
874 | 915 | return true; |
916 | + } elseif ($is_fatal) { |
|
917 | + fatal_lang_error('error_form_already_submitted', false); |
|
918 | + } else { |
|
919 | + return false; |
|
875 | 920 | } |
876 | - elseif ($is_fatal) |
|
877 | - fatal_lang_error('error_form_already_submitted', false); |
|
878 | - else |
|
879 | - return false; |
|
880 | 921 | } |
881 | 922 | // Don't check, just free the stack number. |
882 | - elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
883 | - $_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum'])); |
|
884 | - elseif ($action != 'free') |
|
885 | - trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING); |
|
886 | -} |
|
923 | + elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) { |
|
924 | + $_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum'])); |
|
925 | + } elseif ($action != 'free') { |
|
926 | + trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING); |
|
927 | + } |
|
928 | + } |
|
887 | 929 | |
888 | 930 | /** |
889 | 931 | * Check the user's permissions. |
@@ -900,16 +942,19 @@ discard block |
||
900 | 942 | global $user_info, $smcFunc; |
901 | 943 | |
902 | 944 | // You're always allowed to do nothing. (unless you're a working man, MR. LAZY :P!) |
903 | - if (empty($permission)) |
|
904 | - return true; |
|
945 | + if (empty($permission)) { |
|
946 | + return true; |
|
947 | + } |
|
905 | 948 | |
906 | 949 | // You're never allowed to do something if your data hasn't been loaded yet! |
907 | - if (empty($user_info)) |
|
908 | - return false; |
|
950 | + if (empty($user_info)) { |
|
951 | + return false; |
|
952 | + } |
|
909 | 953 | |
910 | 954 | // Administrators are supermen :P. |
911 | - if ($user_info['is_admin']) |
|
912 | - return true; |
|
955 | + if ($user_info['is_admin']) { |
|
956 | + return true; |
|
957 | + } |
|
913 | 958 | |
914 | 959 | // Let's ensure this is an array. |
915 | 960 | $permission = (array) $permission; |
@@ -917,14 +962,16 @@ discard block |
||
917 | 962 | // Are we checking the _current_ board, or some other boards? |
918 | 963 | if ($boards === null) |
919 | 964 | { |
920 | - if (count(array_intersect($permission, $user_info['permissions'])) != 0) |
|
921 | - return true; |
|
965 | + if (count(array_intersect($permission, $user_info['permissions'])) != 0) { |
|
966 | + return true; |
|
967 | + } |
|
922 | 968 | // You aren't allowed, by default. |
923 | - else |
|
924 | - return false; |
|
969 | + else { |
|
970 | + return false; |
|
971 | + } |
|
972 | + } elseif (!is_array($boards)) { |
|
973 | + $boards = array($boards); |
|
925 | 974 | } |
926 | - elseif (!is_array($boards)) |
|
927 | - $boards = array($boards); |
|
928 | 975 | |
929 | 976 | $request = $smcFunc['db_query']('', ' |
930 | 977 | SELECT MIN(bp.add_deny) AS add_deny |
@@ -947,12 +994,14 @@ discard block |
||
947 | 994 | ); |
948 | 995 | |
949 | 996 | // Make sure they can do it on all of the boards. |
950 | - if ($smcFunc['db_num_rows']($request) != count($boards)) |
|
951 | - return false; |
|
997 | + if ($smcFunc['db_num_rows']($request) != count($boards)) { |
|
998 | + return false; |
|
999 | + } |
|
952 | 1000 | |
953 | 1001 | $result = true; |
954 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
955 | - $result &= !empty($row['add_deny']); |
|
1002 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1003 | + $result &= !empty($row['add_deny']); |
|
1004 | + } |
|
956 | 1005 | $smcFunc['db_free_result']($request); |
957 | 1006 | |
958 | 1007 | // If the query returned 1, they can do it... otherwise, they can't. |
@@ -1017,9 +1066,10 @@ discard block |
||
1017 | 1066 | |
1018 | 1067 | // If you're doing something on behalf of some "heavy" permissions, validate your session. |
1019 | 1068 | // (take out the heavy permissions, and if you can't do anything but those, you need a validated session.) |
1020 | - if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) |
|
1021 | - validateSession(); |
|
1022 | -} |
|
1069 | + if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) { |
|
1070 | + validateSession(); |
|
1071 | + } |
|
1072 | + } |
|
1023 | 1073 | |
1024 | 1074 | /** |
1025 | 1075 | * Return the boards a user has a certain (board) permission on. (array(0) if all.) |
@@ -1038,8 +1088,9 @@ discard block |
||
1038 | 1088 | global $user_info, $smcFunc; |
1039 | 1089 | |
1040 | 1090 | // Arrays are nice, most of the time. |
1041 | - if (!is_array($permissions)) |
|
1042 | - $permissions = array($permissions); |
|
1091 | + if (!is_array($permissions)) { |
|
1092 | + $permissions = array($permissions); |
|
1093 | + } |
|
1043 | 1094 | |
1044 | 1095 | /* |
1045 | 1096 | * Set $simple to true to use this function as it were in SMF 2.0.x. |
@@ -1051,13 +1102,14 @@ discard block |
||
1051 | 1102 | // Administrators are all powerful, sorry. |
1052 | 1103 | if ($user_info['is_admin']) |
1053 | 1104 | { |
1054 | - if ($simple) |
|
1055 | - return array(0); |
|
1056 | - else |
|
1105 | + if ($simple) { |
|
1106 | + return array(0); |
|
1107 | + } else |
|
1057 | 1108 | { |
1058 | 1109 | $boards = array(); |
1059 | - foreach ($permissions as $permission) |
|
1060 | - $boards[$permission] = array(0); |
|
1110 | + foreach ($permissions as $permission) { |
|
1111 | + $boards[$permission] = array(0); |
|
1112 | + } |
|
1061 | 1113 | |
1062 | 1114 | return $boards; |
1063 | 1115 | } |
@@ -1089,31 +1141,32 @@ discard block |
||
1089 | 1141 | { |
1090 | 1142 | if ($simple) |
1091 | 1143 | { |
1092 | - if (empty($row['add_deny'])) |
|
1093 | - $deny_boards[] = $row['id_board']; |
|
1094 | - else |
|
1095 | - $boards[] = $row['id_board']; |
|
1096 | - } |
|
1097 | - else |
|
1144 | + if (empty($row['add_deny'])) { |
|
1145 | + $deny_boards[] = $row['id_board']; |
|
1146 | + } else { |
|
1147 | + $boards[] = $row['id_board']; |
|
1148 | + } |
|
1149 | + } else |
|
1098 | 1150 | { |
1099 | - if (empty($row['add_deny'])) |
|
1100 | - $deny_boards[$row['permission']][] = $row['id_board']; |
|
1101 | - else |
|
1102 | - $boards[$row['permission']][] = $row['id_board']; |
|
1151 | + if (empty($row['add_deny'])) { |
|
1152 | + $deny_boards[$row['permission']][] = $row['id_board']; |
|
1153 | + } else { |
|
1154 | + $boards[$row['permission']][] = $row['id_board']; |
|
1155 | + } |
|
1103 | 1156 | } |
1104 | 1157 | } |
1105 | 1158 | $smcFunc['db_free_result']($request); |
1106 | 1159 | |
1107 | - if ($simple) |
|
1108 | - $boards = array_unique(array_values(array_diff($boards, $deny_boards))); |
|
1109 | - else |
|
1160 | + if ($simple) { |
|
1161 | + $boards = array_unique(array_values(array_diff($boards, $deny_boards))); |
|
1162 | + } else |
|
1110 | 1163 | { |
1111 | 1164 | foreach ($permissions as $permission) |
1112 | 1165 | { |
1113 | 1166 | // never had it to start with |
1114 | - if (empty($boards[$permission])) |
|
1115 | - $boards[$permission] = array(); |
|
1116 | - else |
|
1167 | + if (empty($boards[$permission])) { |
|
1168 | + $boards[$permission] = array(); |
|
1169 | + } else |
|
1117 | 1170 | { |
1118 | 1171 | // Or it may have been removed |
1119 | 1172 | $deny_boards[$permission] = isset($deny_boards[$permission]) ? $deny_boards[$permission] : array(); |
@@ -1149,10 +1202,11 @@ discard block |
||
1149 | 1202 | |
1150 | 1203 | |
1151 | 1204 | // Moderators are free... |
1152 | - if (!allowedTo('moderate_board')) |
|
1153 | - $timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime']; |
|
1154 | - else |
|
1155 | - $timeLimit = 2; |
|
1205 | + if (!allowedTo('moderate_board')) { |
|
1206 | + $timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime']; |
|
1207 | + } else { |
|
1208 | + $timeLimit = 2; |
|
1209 | + } |
|
1156 | 1210 | |
1157 | 1211 | call_integration_hook('integrate_spam_protection', array(&$timeOverrides, &$timeLimit)); |
1158 | 1212 | |
@@ -1179,8 +1233,9 @@ discard block |
||
1179 | 1233 | if ($smcFunc['db_affected_rows']() != 1) |
1180 | 1234 | { |
1181 | 1235 | // Spammer! You only have to wait a *few* seconds! |
1182 | - if (!$only_return_result) |
|
1183 | - fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit)); |
|
1236 | + if (!$only_return_result) { |
|
1237 | + fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit)); |
|
1238 | + } |
|
1184 | 1239 | |
1185 | 1240 | return true; |
1186 | 1241 | } |
@@ -1198,11 +1253,13 @@ discard block |
||
1198 | 1253 | */ |
1199 | 1254 | function secureDirectory($path, $attachments = false) |
1200 | 1255 | { |
1201 | - if (empty($path)) |
|
1202 | - return 'empty_path'; |
|
1256 | + if (empty($path)) { |
|
1257 | + return 'empty_path'; |
|
1258 | + } |
|
1203 | 1259 | |
1204 | - if (!is_writable($path)) |
|
1205 | - return 'path_not_writable'; |
|
1260 | + if (!is_writable($path)) { |
|
1261 | + return 'path_not_writable'; |
|
1262 | + } |
|
1206 | 1263 | |
1207 | 1264 | $directoryname = basename($path); |
1208 | 1265 | |
@@ -1214,9 +1271,9 @@ discard block |
||
1214 | 1271 | |
1215 | 1272 | RemoveHandler .php .php3 .phtml .cgi .fcgi .pl .fpl .shtml'; |
1216 | 1273 | |
1217 | - if (file_exists($path . '/.htaccess')) |
|
1218 | - $errors[] = 'htaccess_exists'; |
|
1219 | - else |
|
1274 | + if (file_exists($path . '/.htaccess')) { |
|
1275 | + $errors[] = 'htaccess_exists'; |
|
1276 | + } else |
|
1220 | 1277 | { |
1221 | 1278 | $fh = @fopen($path . '/.htaccess', 'w'); |
1222 | 1279 | if ($fh) { |
@@ -1228,9 +1285,9 @@ discard block |
||
1228 | 1285 | $errors[] = 'htaccess_cannot_create_file'; |
1229 | 1286 | } |
1230 | 1287 | |
1231 | - if (file_exists($path . '/index.php')) |
|
1232 | - $errors[] = 'index-php_exists'; |
|
1233 | - else |
|
1288 | + if (file_exists($path . '/index.php')) { |
|
1289 | + $errors[] = 'index-php_exists'; |
|
1290 | + } else |
|
1234 | 1291 | { |
1235 | 1292 | $fh = @fopen($path . '/index.php', 'w'); |
1236 | 1293 | if ($fh) { |
@@ -1257,11 +1314,12 @@ discard block |
||
1257 | 1314 | $errors[] = 'index-php_cannot_create_file'; |
1258 | 1315 | } |
1259 | 1316 | |
1260 | - if (!empty($errors)) |
|
1261 | - return $errors; |
|
1262 | - else |
|
1263 | - return true; |
|
1264 | -} |
|
1317 | + if (!empty($errors)) { |
|
1318 | + return $errors; |
|
1319 | + } else { |
|
1320 | + return true; |
|
1321 | + } |
|
1322 | + } |
|
1265 | 1323 | |
1266 | 1324 | /** |
1267 | 1325 | * This sets the X-Frame-Options header. |
@@ -1274,14 +1332,16 @@ discard block |
||
1274 | 1332 | global $modSettings; |
1275 | 1333 | |
1276 | 1334 | $option = 'SAMEORIGIN'; |
1277 | - if (is_null($override) && !empty($modSettings['frame_security'])) |
|
1278 | - $option = $modSettings['frame_security']; |
|
1279 | - elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) |
|
1280 | - $option = $override; |
|
1335 | + if (is_null($override) && !empty($modSettings['frame_security'])) { |
|
1336 | + $option = $modSettings['frame_security']; |
|
1337 | + } elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) { |
|
1338 | + $option = $override; |
|
1339 | + } |
|
1281 | 1340 | |
1282 | 1341 | // Don't bother setting the header if we have disabled it. |
1283 | - if ($option == 'DISABLE') |
|
1284 | - return; |
|
1342 | + if ($option == 'DISABLE') { |
|
1343 | + return; |
|
1344 | + } |
|
1285 | 1345 | |
1286 | 1346 | // Finally set it. |
1287 | 1347 | header('X-Frame-Options: ' . $option); |
@@ -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 | * Mark a board or multiple boards read. |
@@ -28,14 +29,16 @@ discard block |
||
28 | 29 | global $user_info, $modSettings, $smcFunc; |
29 | 30 | |
30 | 31 | // Force $boards to be an array. |
31 | - if (!is_array($boards)) |
|
32 | - $boards = array($boards); |
|
33 | - else |
|
34 | - $boards = array_unique($boards); |
|
32 | + if (!is_array($boards)) { |
|
33 | + $boards = array($boards); |
|
34 | + } else { |
|
35 | + $boards = array_unique($boards); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // No boards, nothing to mark as read. |
37 | - if (empty($boards)) |
|
38 | - return; |
|
39 | + if (empty($boards)) { |
|
40 | + return; |
|
41 | + } |
|
39 | 42 | |
40 | 43 | // Allow the user to mark a board as unread. |
41 | 44 | if ($unread) |
@@ -65,8 +68,9 @@ discard block |
||
65 | 68 | else |
66 | 69 | { |
67 | 70 | $markRead = array(); |
68 | - foreach ($boards as $board) |
|
69 | - $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board); |
|
71 | + foreach ($boards as $board) { |
|
72 | + $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board); |
|
73 | + } |
|
70 | 74 | |
71 | 75 | // Update log_mark_read and log_boards. |
72 | 76 | $smcFunc['db_insert']('replace', |
@@ -99,8 +103,9 @@ discard block |
||
99 | 103 | list ($lowest_topic) = $smcFunc['db_fetch_row']($result); |
100 | 104 | $smcFunc['db_free_result']($result); |
101 | 105 | |
102 | - if (empty($lowest_topic)) |
|
103 | - return; |
|
106 | + if (empty($lowest_topic)) { |
|
107 | + return; |
|
108 | + } |
|
104 | 109 | |
105 | 110 | // @todo SLOW This query seems to eat it sometimes. |
106 | 111 | $result = $smcFunc['db_query']('', ' |
@@ -118,12 +123,13 @@ discard block |
||
118 | 123 | ) |
119 | 124 | ); |
120 | 125 | $topics = array(); |
121 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
122 | - $topics[] = $row['id_topic']; |
|
126 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
127 | + $topics[] = $row['id_topic']; |
|
128 | + } |
|
123 | 129 | $smcFunc['db_free_result']($result); |
124 | 130 | |
125 | - if (!empty($topics)) |
|
126 | - $smcFunc['db_query']('', ' |
|
131 | + if (!empty($topics)) { |
|
132 | + $smcFunc['db_query']('', ' |
|
127 | 133 | DELETE FROM {db_prefix}log_topics |
128 | 134 | WHERE id_member = {int:current_member} |
129 | 135 | AND id_topic IN ({array_int:topic_list})', |
@@ -132,7 +138,8 @@ discard block |
||
132 | 138 | 'topic_list' => $topics, |
133 | 139 | ) |
134 | 140 | ); |
135 | -} |
|
141 | + } |
|
142 | + } |
|
136 | 143 | |
137 | 144 | /** |
138 | 145 | * Mark one or more boards as read. |
@@ -157,23 +164,26 @@ discard block |
||
157 | 164 | ) |
158 | 165 | ); |
159 | 166 | $boards = array(); |
160 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
161 | - $boards[] = $row['id_board']; |
|
167 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
168 | + $boards[] = $row['id_board']; |
|
169 | + } |
|
162 | 170 | $smcFunc['db_free_result']($result); |
163 | 171 | |
164 | - if (!empty($boards)) |
|
165 | - markBoardsRead($boards, isset($_REQUEST['unread'])); |
|
172 | + if (!empty($boards)) { |
|
173 | + markBoardsRead($boards, isset($_REQUEST['unread'])); |
|
174 | + } |
|
166 | 175 | |
167 | 176 | $_SESSION['id_msg_last_visit'] = $modSettings['maxMsgID']; |
168 | - if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) |
|
169 | - redirectexit('action=unread'); |
|
177 | + if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) { |
|
178 | + redirectexit('action=unread'); |
|
179 | + } |
|
170 | 180 | |
171 | - if (isset($_SESSION['topicseen_cache'])) |
|
172 | - $_SESSION['topicseen_cache'] = array(); |
|
181 | + if (isset($_SESSION['topicseen_cache'])) { |
|
182 | + $_SESSION['topicseen_cache'] = array(); |
|
183 | + } |
|
173 | 184 | |
174 | 185 | redirectexit(); |
175 | - } |
|
176 | - elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies') |
|
186 | + } elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies') |
|
177 | 187 | { |
178 | 188 | // Make sure all the topics are integers! |
179 | 189 | $topics = array_map('intval', explode('-', $_REQUEST['topics'])); |
@@ -189,13 +199,15 @@ discard block |
||
189 | 199 | ) |
190 | 200 | ); |
191 | 201 | $logged_topics = array(); |
192 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
193 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
202 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
203 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
204 | + } |
|
194 | 205 | $smcFunc['db_free_result']($request); |
195 | 206 | |
196 | 207 | $markRead = array(); |
197 | - foreach ($topics as $id_topic) |
|
198 | - $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
208 | + foreach ($topics as $id_topic) { |
|
209 | + $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
210 | + } |
|
199 | 211 | |
200 | 212 | $smcFunc['db_insert']('replace', |
201 | 213 | '{db_prefix}log_topics', |
@@ -204,8 +216,9 @@ discard block |
||
204 | 216 | array('id_member', 'id_topic') |
205 | 217 | ); |
206 | 218 | |
207 | - if (isset($_SESSION['topicseen_cache'])) |
|
208 | - $_SESSION['topicseen_cache'] = array(); |
|
219 | + if (isset($_SESSION['topicseen_cache'])) { |
|
220 | + $_SESSION['topicseen_cache'] = array(); |
|
221 | + } |
|
209 | 222 | |
210 | 223 | redirectexit('action=unreadreplies'); |
211 | 224 | } |
@@ -230,11 +243,13 @@ discard block |
||
230 | 243 | if (!empty($_GET['t'])) |
231 | 244 | { |
232 | 245 | // If they read the whole topic, go back to the beginning. |
233 | - if ($_GET['t'] >= $topicinfo['id_last_msg']) |
|
234 | - $earlyMsg = 0; |
|
246 | + if ($_GET['t'] >= $topicinfo['id_last_msg']) { |
|
247 | + $earlyMsg = 0; |
|
248 | + } |
|
235 | 249 | // If they want to mark the whole thing read, same. |
236 | - elseif ($_GET['t'] <= $topicinfo['id_first_msg']) |
|
237 | - $earlyMsg = 0; |
|
250 | + elseif ($_GET['t'] <= $topicinfo['id_first_msg']) { |
|
251 | + $earlyMsg = 0; |
|
252 | + } |
|
238 | 253 | // Otherwise, get the latest message before the named one. |
239 | 254 | else |
240 | 255 | { |
@@ -255,9 +270,9 @@ discard block |
||
255 | 270 | } |
256 | 271 | } |
257 | 272 | // Marking read from first page? That's the whole topic. |
258 | - elseif ($_REQUEST['start'] == 0) |
|
259 | - $earlyMsg = 0; |
|
260 | - else |
|
273 | + elseif ($_REQUEST['start'] == 0) { |
|
274 | + $earlyMsg = 0; |
|
275 | + } else |
|
261 | 276 | { |
262 | 277 | $result = $smcFunc['db_query']('', ' |
263 | 278 | SELECT id_msg |
@@ -285,8 +300,7 @@ discard block |
||
285 | 300 | ); |
286 | 301 | |
287 | 302 | redirectexit('board=' . $board . '.0'); |
288 | - } |
|
289 | - else |
|
303 | + } else |
|
290 | 304 | { |
291 | 305 | $categories = array(); |
292 | 306 | $boards = array(); |
@@ -294,17 +308,20 @@ discard block |
||
294 | 308 | if (isset($_REQUEST['c'])) |
295 | 309 | { |
296 | 310 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
297 | - foreach ($_REQUEST['c'] as $c) |
|
298 | - $categories[] = (int) $c; |
|
311 | + foreach ($_REQUEST['c'] as $c) { |
|
312 | + $categories[] = (int) $c; |
|
313 | + } |
|
299 | 314 | } |
300 | 315 | if (isset($_REQUEST['boards'])) |
301 | 316 | { |
302 | 317 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
303 | - foreach ($_REQUEST['boards'] as $b) |
|
304 | - $boards[] = (int) $b; |
|
318 | + foreach ($_REQUEST['boards'] as $b) { |
|
319 | + $boards[] = (int) $b; |
|
320 | + } |
|
321 | + } |
|
322 | + if (!empty($board)) { |
|
323 | + $boards[] = (int) $board; |
|
305 | 324 | } |
306 | - if (!empty($board)) |
|
307 | - $boards[] = (int) $board; |
|
308 | 325 | |
309 | 326 | if (isset($_REQUEST['children']) && !empty($boards)) |
310 | 327 | { |
@@ -324,9 +341,10 @@ discard block |
||
324 | 341 | 'board_list' => $boards, |
325 | 342 | ) |
326 | 343 | ); |
327 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
328 | - if (in_array($row['id_parent'], $boards)) |
|
344 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
345 | + if (in_array($row['id_parent'], $boards)) |
|
329 | 346 | $boards[] = $row['id_board']; |
347 | + } |
|
330 | 348 | $smcFunc['db_free_result']($request); |
331 | 349 | } |
332 | 350 | |
@@ -343,8 +361,9 @@ discard block |
||
343 | 361 | $clauseParameters['board_list'] = $boards; |
344 | 362 | } |
345 | 363 | |
346 | - if (empty($clauses)) |
|
347 | - redirectexit(); |
|
364 | + if (empty($clauses)) { |
|
365 | + redirectexit(); |
|
366 | + } |
|
348 | 367 | |
349 | 368 | $request = $smcFunc['db_query']('', ' |
350 | 369 | SELECT b.id_board |
@@ -355,19 +374,22 @@ discard block |
||
355 | 374 | )) |
356 | 375 | ); |
357 | 376 | $boards = array(); |
358 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
359 | - $boards[] = $row['id_board']; |
|
377 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
378 | + $boards[] = $row['id_board']; |
|
379 | + } |
|
360 | 380 | $smcFunc['db_free_result']($request); |
361 | 381 | |
362 | - if (empty($boards)) |
|
363 | - redirectexit(); |
|
382 | + if (empty($boards)) { |
|
383 | + redirectexit(); |
|
384 | + } |
|
364 | 385 | |
365 | 386 | markBoardsRead($boards, isset($_REQUEST['unread'])); |
366 | 387 | |
367 | 388 | foreach ($boards as $b) |
368 | 389 | { |
369 | - if (isset($_SESSION['topicseen_cache'][$b])) |
|
370 | - $_SESSION['topicseen_cache'][$b] = array(); |
|
390 | + if (isset($_SESSION['topicseen_cache'][$b])) { |
|
391 | + $_SESSION['topicseen_cache'][$b] = array(); |
|
392 | + } |
|
371 | 393 | } |
372 | 394 | |
373 | 395 | if (!isset($_REQUEST['unread'])) |
@@ -385,8 +407,9 @@ discard block |
||
385 | 407 | if ($smcFunc['db_num_rows']($result) > 0) |
386 | 408 | { |
387 | 409 | $logBoardInserts = ''; |
388 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
389 | - $logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']); |
|
410 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
411 | + $logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']); |
|
412 | + } |
|
390 | 413 | |
391 | 414 | $smcFunc['db_insert']('replace', |
392 | 415 | '{db_prefix}log_boards', |
@@ -397,17 +420,18 @@ discard block |
||
397 | 420 | } |
398 | 421 | $smcFunc['db_free_result']($result); |
399 | 422 | |
400 | - if (empty($board)) |
|
401 | - redirectexit(); |
|
402 | - else |
|
403 | - redirectexit('board=' . $board . '.0'); |
|
404 | - } |
|
405 | - else |
|
423 | + if (empty($board)) { |
|
424 | + redirectexit(); |
|
425 | + } else { |
|
426 | + redirectexit('board=' . $board . '.0'); |
|
427 | + } |
|
428 | + } else |
|
406 | 429 | { |
407 | - if (empty($board_info['parent'])) |
|
408 | - redirectexit(); |
|
409 | - else |
|
410 | - redirectexit('board=' . $board_info['parent'] . '.0'); |
|
430 | + if (empty($board_info['parent'])) { |
|
431 | + redirectexit(); |
|
432 | + } else { |
|
433 | + redirectexit('board=' . $board_info['parent'] . '.0'); |
|
434 | + } |
|
411 | 435 | } |
412 | 436 | } |
413 | 437 | } |
@@ -432,11 +456,13 @@ discard block |
||
432 | 456 | 'selected_message' => (int) $messageID, |
433 | 457 | ) |
434 | 458 | ); |
435 | - if ($smcFunc['db_num_rows']($result) > 0) |
|
436 | - list ($memberID) = $smcFunc['db_fetch_row']($result); |
|
459 | + if ($smcFunc['db_num_rows']($result) > 0) { |
|
460 | + list ($memberID) = $smcFunc['db_fetch_row']($result); |
|
461 | + } |
|
437 | 462 | // The message doesn't even exist. |
438 | - else |
|
439 | - $memberID = 0; |
|
463 | + else { |
|
464 | + $memberID = 0; |
|
465 | + } |
|
440 | 466 | $smcFunc['db_free_result']($result); |
441 | 467 | |
442 | 468 | return (int) $memberID; |
@@ -457,8 +483,9 @@ discard block |
||
457 | 483 | getBoardTree(); |
458 | 484 | |
459 | 485 | // Make sure given boards and categories exist. |
460 | - if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) |
|
461 | - fatal_lang_error('no_board'); |
|
486 | + if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) { |
|
487 | + fatal_lang_error('no_board'); |
|
488 | + } |
|
462 | 489 | |
463 | 490 | $id = $board_id; |
464 | 491 | call_integration_hook('integrate_pre_modify_board', array($id, &$boardOptions)); |
@@ -486,8 +513,9 @@ discard block |
||
486 | 513 | $child_level = 0; |
487 | 514 | $id_parent = 0; |
488 | 515 | $after = 0; |
489 | - foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) |
|
490 | - $after = max($after, $boards[$id_board]['order']); |
|
516 | + foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) { |
|
517 | + $after = max($after, $boards[$id_board]['order']); |
|
518 | + } |
|
491 | 519 | } |
492 | 520 | |
493 | 521 | // Make the board a child of a given board. |
@@ -498,17 +526,19 @@ discard block |
||
498 | 526 | $id_parent = $boardOptions['target_board']; |
499 | 527 | |
500 | 528 | // People can be creative, in many ways... |
501 | - if (isChildOf($id_parent, $board_id)) |
|
502 | - fatal_lang_error('mboards_parent_own_child_error', false); |
|
503 | - elseif ($id_parent == $board_id) |
|
504 | - fatal_lang_error('mboards_board_own_child_error', false); |
|
529 | + if (isChildOf($id_parent, $board_id)) { |
|
530 | + fatal_lang_error('mboards_parent_own_child_error', false); |
|
531 | + } elseif ($id_parent == $board_id) { |
|
532 | + fatal_lang_error('mboards_board_own_child_error', false); |
|
533 | + } |
|
505 | 534 | |
506 | 535 | $after = $boards[$boardOptions['target_board']]['order']; |
507 | 536 | |
508 | 537 | // Check if there are already children and (if so) get the max board order. |
509 | - if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) |
|
510 | - foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy) |
|
538 | + if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) { |
|
539 | + foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy) |
|
511 | 540 | $after = max($after, $boards[$childBoard_id]['order']); |
541 | + } |
|
512 | 542 | } |
513 | 543 | |
514 | 544 | // Place a board before or after another board, on the same child level. |
@@ -521,8 +551,9 @@ discard block |
||
521 | 551 | } |
522 | 552 | |
523 | 553 | // Oops...? |
524 | - else |
|
525 | - trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR); |
|
554 | + else { |
|
555 | + trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR); |
|
556 | + } |
|
526 | 557 | |
527 | 558 | // Get a list of children of this board. |
528 | 559 | $childList = array(); |
@@ -531,14 +562,16 @@ discard block |
||
531 | 562 | // See if there are changes that affect children. |
532 | 563 | $childUpdates = array(); |
533 | 564 | $levelDiff = $child_level - $boards[$board_id]['level']; |
534 | - if ($levelDiff != 0) |
|
535 | - $childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}'; |
|
536 | - if ($id_cat != $boards[$board_id]['category']) |
|
537 | - $childUpdates[] = 'id_cat = {int:category}'; |
|
565 | + if ($levelDiff != 0) { |
|
566 | + $childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}'; |
|
567 | + } |
|
568 | + if ($id_cat != $boards[$board_id]['category']) { |
|
569 | + $childUpdates[] = 'id_cat = {int:category}'; |
|
570 | + } |
|
538 | 571 | |
539 | 572 | // Fix the children of this board. |
540 | - if (!empty($childList) && !empty($childUpdates)) |
|
541 | - $smcFunc['db_query']('', ' |
|
573 | + if (!empty($childList) && !empty($childUpdates)) { |
|
574 | + $smcFunc['db_query']('', ' |
|
542 | 575 | UPDATE {db_prefix}boards |
543 | 576 | SET ' . implode(', |
544 | 577 | ', $childUpdates) . ' |
@@ -549,6 +582,7 @@ discard block |
||
549 | 582 | 'level_diff' => $levelDiff, |
550 | 583 | ) |
551 | 584 | ); |
585 | + } |
|
552 | 586 | |
553 | 587 | // Make some room for this spot. |
554 | 588 | $smcFunc['db_query']('', ' |
@@ -644,8 +678,8 @@ discard block |
||
644 | 678 | call_integration_hook('integrate_modify_board', array($id, &$boardUpdates, &$boardUpdateParameters)); |
645 | 679 | |
646 | 680 | // Do the updates (if any). |
647 | - if (!empty($boardUpdates)) |
|
648 | - $smcFunc['db_query']('', ' |
|
681 | + if (!empty($boardUpdates)) { |
|
682 | + $smcFunc['db_query']('', ' |
|
649 | 683 | UPDATE {db_prefix}boards |
650 | 684 | SET |
651 | 685 | ' . implode(', |
@@ -655,6 +689,7 @@ discard block |
||
655 | 689 | 'selected_board' => $board_id, |
656 | 690 | )) |
657 | 691 | ); |
692 | + } |
|
658 | 693 | |
659 | 694 | // Set moderators of this board. |
660 | 695 | if (isset($boardOptions['moderators']) || isset($boardOptions['moderator_string']) || isset($boardOptions['moderator_groups']) || isset($boardOptions['moderator_group_string'])) |
@@ -679,13 +714,15 @@ discard block |
||
679 | 714 | { |
680 | 715 | $moderators[$k] = trim($moderators[$k]); |
681 | 716 | |
682 | - if (strlen($moderators[$k]) == 0) |
|
683 | - unset($moderators[$k]); |
|
717 | + if (strlen($moderators[$k]) == 0) { |
|
718 | + unset($moderators[$k]); |
|
719 | + } |
|
684 | 720 | } |
685 | 721 | |
686 | 722 | // Find all the id_member's for the member_name's in the list. |
687 | - if (empty($boardOptions['moderators'])) |
|
688 | - $boardOptions['moderators'] = array(); |
|
723 | + if (empty($boardOptions['moderators'])) { |
|
724 | + $boardOptions['moderators'] = array(); |
|
725 | + } |
|
689 | 726 | if (!empty($moderators)) |
690 | 727 | { |
691 | 728 | $request = $smcFunc['db_query']('', ' |
@@ -698,8 +735,9 @@ discard block |
||
698 | 735 | 'limit' => count($moderators), |
699 | 736 | ) |
700 | 737 | ); |
701 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
702 | - $boardOptions['moderators'][] = $row['id_member']; |
|
738 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
739 | + $boardOptions['moderators'][] = $row['id_member']; |
|
740 | + } |
|
703 | 741 | $smcFunc['db_free_result']($request); |
704 | 742 | } |
705 | 743 | } |
@@ -708,8 +746,9 @@ discard block |
||
708 | 746 | if (!empty($boardOptions['moderators'])) |
709 | 747 | { |
710 | 748 | $inserts = array(); |
711 | - foreach ($boardOptions['moderators'] as $moderator) |
|
712 | - $inserts[] = array($board_id, $moderator); |
|
749 | + foreach ($boardOptions['moderators'] as $moderator) { |
|
750 | + $inserts[] = array($board_id, $moderator); |
|
751 | + } |
|
713 | 752 | |
714 | 753 | $smcFunc['db_insert']('insert', |
715 | 754 | '{db_prefix}moderators', |
@@ -739,14 +778,16 @@ discard block |
||
739 | 778 | { |
740 | 779 | $moderator_groups[$k] = trim($moderator_groups[$k]); |
741 | 780 | |
742 | - if (strlen($moderator_groups[$k]) == 0) |
|
743 | - unset($moderator_groups[$k]); |
|
781 | + if (strlen($moderator_groups[$k]) == 0) { |
|
782 | + unset($moderator_groups[$k]); |
|
783 | + } |
|
744 | 784 | } |
745 | 785 | |
746 | 786 | /* Find all the id_group's for all the group names in the list |
747 | 787 | But skip any invalid ones (invisible/post groups/Administrator/Moderator) */ |
748 | - if (empty($boardOptions['moderator_groups'])) |
|
749 | - $boardOptions['moderator_groups'] = array(); |
|
788 | + if (empty($boardOptions['moderator_groups'])) { |
|
789 | + $boardOptions['moderator_groups'] = array(); |
|
790 | + } |
|
750 | 791 | if (!empty($moderator_groups)) |
751 | 792 | { |
752 | 793 | $request = $smcFunc['db_query']('', ' |
@@ -777,8 +818,9 @@ discard block |
||
777 | 818 | if (!empty($boardOptions['moderator_groups'])) |
778 | 819 | { |
779 | 820 | $inserts = array(); |
780 | - foreach ($boardOptions['moderator_groups'] as $moderator_group) |
|
781 | - $inserts[] = array($board_id, $moderator_group); |
|
821 | + foreach ($boardOptions['moderator_groups'] as $moderator_group) { |
|
822 | + $inserts[] = array($board_id, $moderator_group); |
|
823 | + } |
|
782 | 824 | |
783 | 825 | $smcFunc['db_insert']('insert', |
784 | 826 | '{db_prefix}moderator_groups', |
@@ -792,14 +834,16 @@ discard block |
||
792 | 834 | updateSettings(array('settings_updated' => time())); |
793 | 835 | } |
794 | 836 | |
795 | - if (isset($boardOptions['move_to'])) |
|
796 | - reorderBoards(); |
|
837 | + if (isset($boardOptions['move_to'])) { |
|
838 | + reorderBoards(); |
|
839 | + } |
|
797 | 840 | |
798 | 841 | clean_cache('data'); |
799 | 842 | |
800 | - if (empty($boardOptions['dont_log'])) |
|
801 | - logAction('edit_board', array('board' => $board_id), 'admin'); |
|
802 | -} |
|
843 | + if (empty($boardOptions['dont_log'])) { |
|
844 | + logAction('edit_board', array('board' => $board_id), 'admin'); |
|
845 | + } |
|
846 | + } |
|
803 | 847 | |
804 | 848 | /** |
805 | 849 | * Create a new board and set its properties and position. |
@@ -815,11 +859,13 @@ discard block |
||
815 | 859 | global $boards, $smcFunc; |
816 | 860 | |
817 | 861 | // Trigger an error if one of the required values is not set. |
818 | - if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) |
|
819 | - trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
862 | + if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) { |
|
863 | + trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
864 | + } |
|
820 | 865 | |
821 | - if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) |
|
822 | - trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
866 | + if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) { |
|
867 | + trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
868 | + } |
|
823 | 869 | |
824 | 870 | // Set every optional value to its default value. |
825 | 871 | $boardOptions += array( |
@@ -853,8 +899,9 @@ discard block |
||
853 | 899 | 1 |
854 | 900 | ); |
855 | 901 | |
856 | - if (empty($board_id)) |
|
857 | - return 0; |
|
902 | + if (empty($board_id)) { |
|
903 | + return 0; |
|
904 | + } |
|
858 | 905 | |
859 | 906 | // Change the board according to the given specifications. |
860 | 907 | modifyBoard($board_id, $boardOptions); |
@@ -917,8 +964,9 @@ discard block |
||
917 | 964 | global $sourcedir, $boards, $smcFunc; |
918 | 965 | |
919 | 966 | // No boards to delete? Return! |
920 | - if (empty($boards_to_remove)) |
|
921 | - return; |
|
967 | + if (empty($boards_to_remove)) { |
|
968 | + return; |
|
969 | + } |
|
922 | 970 | |
923 | 971 | getBoardTree(); |
924 | 972 | |
@@ -929,12 +977,14 @@ discard block |
||
929 | 977 | { |
930 | 978 | // Get a list of the child boards that will also be removed. |
931 | 979 | $child_boards_to_remove = array(); |
932 | - foreach ($boards_to_remove as $board_to_remove) |
|
933 | - recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
980 | + foreach ($boards_to_remove as $board_to_remove) { |
|
981 | + recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
982 | + } |
|
934 | 983 | |
935 | 984 | // Merge the children with their parents. |
936 | - if (!empty($child_boards_to_remove)) |
|
937 | - $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
985 | + if (!empty($child_boards_to_remove)) { |
|
986 | + $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
987 | + } |
|
938 | 988 | } |
939 | 989 | // Move the children to a safe home. |
940 | 990 | else |
@@ -942,10 +992,11 @@ discard block |
||
942 | 992 | foreach ($boards_to_remove as $id_board) |
943 | 993 | { |
944 | 994 | // @todo Separate category? |
945 | - if ($moveChildrenTo === 0) |
|
946 | - fixChildren($id_board, 0, 0); |
|
947 | - else |
|
948 | - fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
995 | + if ($moveChildrenTo === 0) { |
|
996 | + fixChildren($id_board, 0, 0); |
|
997 | + } else { |
|
998 | + fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
999 | + } |
|
949 | 1000 | } |
950 | 1001 | } |
951 | 1002 | |
@@ -959,8 +1010,9 @@ discard block |
||
959 | 1010 | ) |
960 | 1011 | ); |
961 | 1012 | $topics = array(); |
962 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
963 | - $topics[] = $row['id_topic']; |
|
1013 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1014 | + $topics[] = $row['id_topic']; |
|
1015 | + } |
|
964 | 1016 | $smcFunc['db_free_result']($request); |
965 | 1017 | |
966 | 1018 | require_once($sourcedir . '/RemoveTopic.php'); |
@@ -1048,8 +1100,9 @@ discard block |
||
1048 | 1100 | clean_cache('data'); |
1049 | 1101 | |
1050 | 1102 | // Let's do some serious logging. |
1051 | - foreach ($boards_to_remove as $id_board) |
|
1052 | - logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
1103 | + foreach ($boards_to_remove as $id_board) { |
|
1104 | + logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
1105 | + } |
|
1053 | 1106 | |
1054 | 1107 | reorderBoards(); |
1055 | 1108 | } |
@@ -1068,8 +1121,8 @@ discard block |
||
1068 | 1121 | $board_order = 0; |
1069 | 1122 | foreach ($cat_tree as $catID => $dummy) |
1070 | 1123 | { |
1071 | - foreach ($boardList[$catID] as $boardID) |
|
1072 | - if ($boards[$boardID]['order'] != ++$board_order) |
|
1124 | + foreach ($boardList[$catID] as $boardID) { |
|
1125 | + if ($boards[$boardID]['order'] != ++$board_order) |
|
1073 | 1126 | $smcFunc['db_query']('', ' |
1074 | 1127 | UPDATE {db_prefix}boards |
1075 | 1128 | SET board_order = {int:new_order} |
@@ -1079,6 +1132,7 @@ discard block |
||
1079 | 1132 | 'selected_board' => $boardID, |
1080 | 1133 | ) |
1081 | 1134 | ); |
1135 | + } |
|
1082 | 1136 | } |
1083 | 1137 | |
1084 | 1138 | // Empty the board order cache |
@@ -1107,8 +1161,9 @@ discard block |
||
1107 | 1161 | ) |
1108 | 1162 | ); |
1109 | 1163 | $children = array(); |
1110 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1111 | - $children[] = $row['id_board']; |
|
1164 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1165 | + $children[] = $row['id_board']; |
|
1166 | + } |
|
1112 | 1167 | $smcFunc['db_free_result']($result); |
1113 | 1168 | |
1114 | 1169 | // ...and set it to a new parent and child_level. |
@@ -1124,9 +1179,10 @@ discard block |
||
1124 | 1179 | ); |
1125 | 1180 | |
1126 | 1181 | // Recursively fix the children of the children. |
1127 | - foreach ($children as $child) |
|
1128 | - fixChildren($child, $newLevel + 1, $child); |
|
1129 | -} |
|
1182 | + foreach ($children as $child) { |
|
1183 | + fixChildren($child, $newLevel + 1, $child); |
|
1184 | + } |
|
1185 | + } |
|
1130 | 1186 | |
1131 | 1187 | /** |
1132 | 1188 | * Tries to load up the entire board order and category very very quickly |
@@ -1143,8 +1199,9 @@ discard block |
||
1143 | 1199 | 'boards' => array(), |
1144 | 1200 | ); |
1145 | 1201 | |
1146 | - if (!empty($tree_order['boards'])) |
|
1147 | - return $tree_order; |
|
1202 | + if (!empty($tree_order['boards'])) { |
|
1203 | + return $tree_order; |
|
1204 | + } |
|
1148 | 1205 | |
1149 | 1206 | if (($cached = cache_get_data('board_order', 86400)) !== null) |
1150 | 1207 | { |
@@ -1160,8 +1217,9 @@ discard block |
||
1160 | 1217 | ); |
1161 | 1218 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1162 | 1219 | { |
1163 | - if (!in_array($row['id_cat'], $tree_order['cats'])) |
|
1164 | - $tree_order['cats'][] = $row['id_cat']; |
|
1220 | + if (!in_array($row['id_cat'], $tree_order['cats'])) { |
|
1221 | + $tree_order['cats'][] = $row['id_cat']; |
|
1222 | + } |
|
1165 | 1223 | $tree_order['boards'][] = $row['id_board']; |
1166 | 1224 | } |
1167 | 1225 | $smcFunc['db_free_result']($request); |
@@ -1181,16 +1239,19 @@ discard block |
||
1181 | 1239 | $tree = getTreeOrder(); |
1182 | 1240 | |
1183 | 1241 | $ordered = array(); |
1184 | - foreach ($tree['boards'] as $board) |
|
1185 | - if (!empty($boards[$board])) |
|
1242 | + foreach ($tree['boards'] as $board) { |
|
1243 | + if (!empty($boards[$board])) |
|
1186 | 1244 | { |
1187 | 1245 | $ordered[$board] = $boards[$board]; |
1246 | + } |
|
1188 | 1247 | |
1189 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) |
|
1190 | - sortBoards($ordered[$board]['boards']); |
|
1248 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) { |
|
1249 | + sortBoards($ordered[$board]['boards']); |
|
1250 | + } |
|
1191 | 1251 | |
1192 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) |
|
1193 | - sortBoards($ordered[$board]['children']); |
|
1252 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) { |
|
1253 | + sortBoards($ordered[$board]['children']); |
|
1254 | + } |
|
1194 | 1255 | } |
1195 | 1256 | |
1196 | 1257 | $boards = $ordered; |
@@ -1206,12 +1267,14 @@ discard block |
||
1206 | 1267 | $tree = getTreeOrder(); |
1207 | 1268 | |
1208 | 1269 | $ordered = array(); |
1209 | - foreach ($tree['cats'] as $cat) |
|
1210 | - if (!empty($categories[$cat])) |
|
1270 | + foreach ($tree['cats'] as $cat) { |
|
1271 | + if (!empty($categories[$cat])) |
|
1211 | 1272 | { |
1212 | 1273 | $ordered[$cat] = $categories[$cat]; |
1213 | - if (!empty($ordered[$cat]['boards'])) |
|
1214 | - sortBoards($ordered[$cat]['boards']); |
|
1274 | + } |
|
1275 | + if (!empty($ordered[$cat]['boards'])) { |
|
1276 | + sortBoards($ordered[$cat]['boards']); |
|
1277 | + } |
|
1215 | 1278 | } |
1216 | 1279 | |
1217 | 1280 | $categories = $ordered; |
@@ -1227,8 +1290,9 @@ discard block |
||
1227 | 1290 | { |
1228 | 1291 | global $smcFunc, $scripturl, $txt; |
1229 | 1292 | |
1230 | - if (empty($boards)) |
|
1231 | - return array(); |
|
1293 | + if (empty($boards)) { |
|
1294 | + return array(); |
|
1295 | + } |
|
1232 | 1296 | |
1233 | 1297 | $request = $smcFunc['db_query']('', ' |
1234 | 1298 | SELECT mem.id_member, mem.real_name, mo.id_board |
@@ -1242,8 +1306,9 @@ discard block |
||
1242 | 1306 | $moderators = array(); |
1243 | 1307 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1244 | 1308 | { |
1245 | - if (empty($moderators[$row['id_board']])) |
|
1246 | - $moderators[$row['id_board']] = array(); |
|
1309 | + if (empty($moderators[$row['id_board']])) { |
|
1310 | + $moderators[$row['id_board']] = array(); |
|
1311 | + } |
|
1247 | 1312 | |
1248 | 1313 | $moderators[$row['id_board']][] = array( |
1249 | 1314 | 'id' => $row['id_member'], |
@@ -1267,8 +1332,9 @@ discard block |
||
1267 | 1332 | { |
1268 | 1333 | global $smcFunc, $scripturl, $txt; |
1269 | 1334 | |
1270 | - if (empty($boards)) |
|
1271 | - return array(); |
|
1335 | + if (empty($boards)) { |
|
1336 | + return array(); |
|
1337 | + } |
|
1272 | 1338 | |
1273 | 1339 | $request = $smcFunc['db_query']('', ' |
1274 | 1340 | SELECT mg.id_group, mg.group_name, bg.id_board |
@@ -1282,8 +1348,9 @@ discard block |
||
1282 | 1348 | $groups = array(); |
1283 | 1349 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1284 | 1350 | { |
1285 | - if (empty($groups[$row['id_board']])) |
|
1286 | - $groups[$row['id_board']] = array(); |
|
1351 | + if (empty($groups[$row['id_board']])) { |
|
1352 | + $groups[$row['id_board']] = array(); |
|
1353 | + } |
|
1287 | 1354 | |
1288 | 1355 | $groups[$row['id_board']][] = array( |
1289 | 1356 | 'id' => $row['id_group'], |
@@ -1345,8 +1412,9 @@ discard block |
||
1345 | 1412 | |
1346 | 1413 | if (!empty($row['id_board'])) |
1347 | 1414 | { |
1348 | - if ($row['child_level'] != $curLevel) |
|
1349 | - $prevBoard = 0; |
|
1415 | + if ($row['child_level'] != $curLevel) { |
|
1416 | + $prevBoard = 0; |
|
1417 | + } |
|
1350 | 1418 | |
1351 | 1419 | $boards[$row['id_board']] = array( |
1352 | 1420 | 'id' => $row['id_board'], |
@@ -1378,16 +1446,16 @@ discard block |
||
1378 | 1446 | 'children' => array() |
1379 | 1447 | ); |
1380 | 1448 | $boards[$row['id_board']]['tree'] = &$cat_tree[$row['id_cat']]['children'][$row['id_board']]; |
1381 | - } |
|
1382 | - else |
|
1449 | + } else |
|
1383 | 1450 | { |
1384 | 1451 | // Parent doesn't exist! |
1385 | - if (!isset($boards[$row['id_parent']]['tree'])) |
|
1386 | - fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
1452 | + if (!isset($boards[$row['id_parent']]['tree'])) { |
|
1453 | + fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
1454 | + } |
|
1387 | 1455 | |
1388 | 1456 | // Wrong childlevel...we can silently fix this... |
1389 | - if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) |
|
1390 | - $smcFunc['db_query']('', ' |
|
1457 | + if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) { |
|
1458 | + $smcFunc['db_query']('', ' |
|
1391 | 1459 | UPDATE {db_prefix}boards |
1392 | 1460 | SET child_level = {int:new_child_level} |
1393 | 1461 | WHERE id_board = {int:selected_board}', |
@@ -1396,6 +1464,7 @@ discard block |
||
1396 | 1464 | 'selected_board' => $row['id_board'], |
1397 | 1465 | ) |
1398 | 1466 | ); |
1467 | + } |
|
1399 | 1468 | |
1400 | 1469 | $boards[$row['id_parent']]['tree']['children'][$row['id_board']] = array( |
1401 | 1470 | 'node' => &$boards[$row['id_board']], |
@@ -1426,8 +1495,9 @@ discard block |
||
1426 | 1495 | */ |
1427 | 1496 | function recursiveBoards(&$_boardList, &$_tree) |
1428 | 1497 | { |
1429 | - if (empty($_tree['children'])) |
|
1430 | - return; |
|
1498 | + if (empty($_tree['children'])) { |
|
1499 | + return; |
|
1500 | + } |
|
1431 | 1501 | |
1432 | 1502 | foreach ($_tree['children'] as $id => $node) |
1433 | 1503 | { |
@@ -1446,11 +1516,13 @@ discard block |
||
1446 | 1516 | { |
1447 | 1517 | global $boards; |
1448 | 1518 | |
1449 | - if (empty($boards[$child]['parent'])) |
|
1450 | - return false; |
|
1519 | + if (empty($boards[$child]['parent'])) { |
|
1520 | + return false; |
|
1521 | + } |
|
1451 | 1522 | |
1452 | - if ($boards[$child]['parent'] == $parent) |
|
1453 | - return true; |
|
1523 | + if ($boards[$child]['parent'] == $parent) { |
|
1524 | + return true; |
|
1525 | + } |
|
1454 | 1526 | |
1455 | 1527 | return isChildOf($boards[$child]['parent'], $parent); |
1456 | 1528 | } |