@@ -53,29 +53,39 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | // If it's not an array, make it so! |
| 55 | 55 | if (!is_array($users)) |
| 56 | - $users = array($users); |
|
| 57 | - else |
|
| 58 | - $users = array_unique($users); |
|
| 56 | + { |
|
| 57 | + $users = array($users); |
|
| 58 | + } |
|
| 59 | + else { |
|
| 60 | + $users = array_unique($users); |
|
| 61 | + } |
|
| 59 | 62 | |
| 60 | 63 | // Make sure there's no void user in here. |
| 61 | 64 | $users = array_diff($users, array(0)); |
| 62 | 65 | |
| 63 | 66 | // How many are they deleting? |
| 64 | 67 | if (empty($users)) |
| 65 | - return; |
|
| 68 | + { |
|
| 69 | + return; |
|
| 70 | + } |
|
| 66 | 71 | elseif (count($users) == 1) |
| 67 | 72 | { |
| 68 | 73 | list ($user) = $users; |
| 69 | 74 | |
| 70 | 75 | if ($user == $user_info['id']) |
| 71 | - isAllowedTo('profile_remove_own'); |
|
| 72 | - else |
|
| 73 | - isAllowedTo('profile_remove_any'); |
|
| 76 | + { |
|
| 77 | + isAllowedTo('profile_remove_own'); |
|
| 78 | + } |
|
| 79 | + else { |
|
| 80 | + isAllowedTo('profile_remove_any'); |
|
| 81 | + } |
|
| 74 | 82 | } |
| 75 | 83 | else |
| 76 | 84 | { |
| 77 | 85 | foreach ($users as $k => $v) |
| 78 | - $users[$k] = (int) $v; |
|
| 86 | + { |
|
| 87 | + $users[$k] = (int) $v; |
|
| 88 | + } |
|
| 79 | 89 | |
| 80 | 90 | // Deleting more than one? You can't have more than one account... |
| 81 | 91 | isAllowedTo('profile_remove_any'); |
@@ -98,26 +108,34 @@ discard block |
||
| 98 | 108 | while ($row = $db->fetch_assoc($request)) |
| 99 | 109 | { |
| 100 | 110 | if ($row['is_admin']) |
| 101 | - $admins[] = $row['id_member']; |
|
| 111 | + { |
|
| 112 | + $admins[] = $row['id_member']; |
|
| 113 | + } |
|
| 102 | 114 | $user_log_details[$row['id_member']] = array($row['id_member'], $row['member_name']); |
| 103 | 115 | $emails[] = $row['email_address']; |
| 104 | 116 | } |
| 105 | 117 | $db->free_result($request); |
| 106 | 118 | |
| 107 | 119 | if (empty($user_log_details)) |
| 108 | - return; |
|
| 120 | + { |
|
| 121 | + return; |
|
| 122 | + } |
|
| 109 | 123 | |
| 110 | 124 | // Make sure they aren't trying to delete administrators if they aren't one. But don't bother checking if it's just themselves. |
| 111 | 125 | if (!empty($admins) && ($check_not_admin || (!allowedTo('admin_forum') && (count($users) != 1 || $users[0] != $user_info['id'])))) |
| 112 | 126 | { |
| 113 | 127 | $users = array_diff($users, $admins); |
| 114 | 128 | foreach ($admins as $id) |
| 115 | - unset($user_log_details[$id]); |
|
| 129 | + { |
|
| 130 | + unset($user_log_details[$id]); |
|
| 131 | + } |
|
| 116 | 132 | } |
| 117 | 133 | |
| 118 | 134 | // No one left? |
| 119 | 135 | if (empty($users)) |
| 120 | - return; |
|
| 136 | + { |
|
| 137 | + return; |
|
| 138 | + } |
|
| 121 | 139 | |
| 122 | 140 | // Log the action - regardless of who is deleting it. |
| 123 | 141 | $log_changes = array(); |
@@ -493,9 +511,12 @@ discard block |
||
| 493 | 511 | if (empty($regOptions['auth_method']) || !in_array($regOptions['auth_method'], array('password', 'openid'))) |
| 494 | 512 | { |
| 495 | 513 | if (!empty($regOptions['openid'])) |
| 496 | - $regOptions['auth_method'] = 'openid'; |
|
| 497 | - else |
|
| 498 | - $regOptions['auth_method'] = 'password'; |
|
| 514 | + { |
|
| 515 | + $regOptions['auth_method'] = 'openid'; |
|
| 516 | + } |
|
| 517 | + else { |
|
| 518 | + $regOptions['auth_method'] = 'password'; |
|
| 519 | + } |
|
| 499 | 520 | } |
| 500 | 521 | |
| 501 | 522 | // Spaces and other odd characters are evil... |
@@ -503,7 +524,9 @@ discard block |
||
| 503 | 524 | |
| 504 | 525 | // Valid emails only |
| 505 | 526 | if (!Data_Validator::is_valid($regOptions, array('email' => 'valid_email|required|max_length[255]'), array('email' => 'trim'))) |
| 506 | - $reg_errors->addError('bad_email'); |
|
| 527 | + { |
|
| 528 | + $reg_errors->addError('bad_email'); |
|
| 529 | + } |
|
| 507 | 530 | |
| 508 | 531 | validateUsername(0, $regOptions['username'], $ErrorContext, !empty($regOptions['check_reserved_name'])); |
| 509 | 532 | |
@@ -512,15 +535,20 @@ discard block |
||
| 512 | 535 | |
| 513 | 536 | // Does the first password match the second? |
| 514 | 537 | if ($regOptions['password'] != $regOptions['password_check'] && $regOptions['auth_method'] == 'password') |
| 515 | - $reg_errors->addError('passwords_dont_match'); |
|
| 538 | + { |
|
| 539 | + $reg_errors->addError('passwords_dont_match'); |
|
| 540 | + } |
|
| 516 | 541 | |
| 517 | 542 | // That's kind of easy to guess... |
| 518 | 543 | if ($regOptions['password'] == '') |
| 519 | 544 | { |
| 520 | 545 | if ($regOptions['auth_method'] == 'password') |
| 521 | - $reg_errors->addError('no_password'); |
|
| 522 | - else |
|
| 523 | - $regOptions['password'] = sha1(mt_rand()); |
|
| 546 | + { |
|
| 547 | + $reg_errors->addError('no_password'); |
|
| 548 | + } |
|
| 549 | + else { |
|
| 550 | + $regOptions['password'] = sha1(mt_rand()); |
|
| 551 | + } |
|
| 524 | 552 | } |
| 525 | 553 | |
| 526 | 554 | // Now perform hard password validation as required. |
@@ -530,13 +558,17 @@ discard block |
||
| 530 | 558 | |
| 531 | 559 | // Password isn't legal? |
| 532 | 560 | if ($passwordError !== null) |
| 533 | - $reg_errors->addError('profile_error_password_' . $passwordError); |
|
| 561 | + { |
|
| 562 | + $reg_errors->addError('profile_error_password_' . $passwordError); |
|
| 563 | + } |
|
| 534 | 564 | } |
| 535 | 565 | |
| 536 | 566 | // @todo move to controller |
| 537 | 567 | // You may not be allowed to register this email. |
| 538 | 568 | if (!empty($regOptions['check_email_ban'])) |
| 539 | - isBannedEmail($regOptions['email'], 'cannot_register', $txt['ban_register_prohibited']); |
|
| 569 | + { |
|
| 570 | + isBannedEmail($regOptions['email'], 'cannot_register', $txt['ban_register_prohibited']); |
|
| 571 | + } |
|
| 540 | 572 | |
| 541 | 573 | // Check if the email address is in use. |
| 542 | 574 | if (userByEmail($regOptions['email'], $regOptions['username'])) |
@@ -549,7 +581,9 @@ discard block |
||
| 549 | 581 | |
| 550 | 582 | // If there's any errors left return them at once! |
| 551 | 583 | if ($reg_errors->hasErrors()) |
| 552 | - return false; |
|
| 584 | + { |
|
| 585 | + return false; |
|
| 586 | + } |
|
| 553 | 587 | |
| 554 | 588 | $reservedVars = array( |
| 555 | 589 | 'actual_theme_url', |
@@ -572,7 +606,9 @@ discard block |
||
| 572 | 606 | |
| 573 | 607 | // Can't change reserved vars. |
| 574 | 608 | if (isset($regOptions['theme_vars']) && count(array_intersect(array_keys($regOptions['theme_vars']), $reservedVars)) != 0) |
| 575 | - throw new Elk_Exception('no_theme'); |
|
| 609 | + { |
|
| 610 | + throw new Elk_Exception('no_theme'); |
|
| 611 | + } |
|
| 576 | 612 | |
| 577 | 613 | $tokenizer = new Token_Hash(); |
| 578 | 614 | |
@@ -625,13 +661,18 @@ discard block |
||
| 625 | 661 | } |
| 626 | 662 | // Maybe it can be activated right away? |
| 627 | 663 | elseif ($regOptions['require'] == 'nothing') |
| 628 | - $regOptions['register_vars']['is_activated'] = 1; |
|
| 664 | + { |
|
| 665 | + $regOptions['register_vars']['is_activated'] = 1; |
|
| 666 | + } |
|
| 629 | 667 | // Maybe it must be activated by email? |
| 630 | 668 | elseif ($regOptions['require'] == 'activation') |
| 631 | - $regOptions['register_vars']['is_activated'] = 0; |
|
| 669 | + { |
|
| 670 | + $regOptions['register_vars']['is_activated'] = 0; |
|
| 671 | + } |
|
| 632 | 672 | // Otherwise it must be awaiting approval! |
| 633 | - else |
|
| 634 | - $regOptions['register_vars']['is_activated'] = 3; |
|
| 673 | + else { |
|
| 674 | + $regOptions['register_vars']['is_activated'] = 3; |
|
| 675 | + } |
|
| 635 | 676 | |
| 636 | 677 | if (isset($regOptions['memberGroup'])) |
| 637 | 678 | { |
@@ -644,19 +685,25 @@ discard block |
||
| 644 | 685 | $unassignableGroups = getUnassignableGroups(allowedTo('admin_forum')); |
| 645 | 686 | |
| 646 | 687 | if (in_array($regOptions['register_vars']['id_group'], $unassignableGroups)) |
| 647 | - $regOptions['register_vars']['id_group'] = 0; |
|
| 688 | + { |
|
| 689 | + $regOptions['register_vars']['id_group'] = 0; |
|
| 690 | + } |
|
| 648 | 691 | } |
| 649 | 692 | |
| 650 | 693 | // Integrate optional member settings to be set. |
| 651 | 694 | if (!empty($regOptions['extra_register_vars'])) |
| 652 | - foreach ($regOptions['extra_register_vars'] as $var => $value) |
|
| 695 | + { |
|
| 696 | + foreach ($regOptions['extra_register_vars'] as $var => $value) |
|
| 653 | 697 | $regOptions['register_vars'][$var] = $value; |
| 698 | + } |
|
| 654 | 699 | |
| 655 | 700 | // Integrate optional user theme options to be set. |
| 656 | 701 | $theme_vars = array(); |
| 657 | 702 | if (!empty($regOptions['theme_vars'])) |
| 658 | - foreach ($regOptions['theme_vars'] as $var => $value) |
|
| 703 | + { |
|
| 704 | + foreach ($regOptions['theme_vars'] as $var => $value) |
|
| 659 | 705 | $theme_vars[$var] = $value; |
| 706 | + } |
|
| 660 | 707 | |
| 661 | 708 | // Right, now let's prepare for insertion. |
| 662 | 709 | $knownInts = array( |
@@ -678,11 +725,17 @@ discard block |
||
| 678 | 725 | { |
| 679 | 726 | $type = 'string'; |
| 680 | 727 | if (in_array($var, $knownInts)) |
| 681 | - $type = 'int'; |
|
| 728 | + { |
|
| 729 | + $type = 'int'; |
|
| 730 | + } |
|
| 682 | 731 | elseif (in_array($var, $knownFloats)) |
| 683 | - $type = 'float'; |
|
| 732 | + { |
|
| 733 | + $type = 'float'; |
|
| 734 | + } |
|
| 684 | 735 | elseif ($var == 'birthdate') |
| 685 | - $type = 'date'; |
|
| 736 | + { |
|
| 737 | + $type = 'date'; |
|
| 738 | + } |
|
| 686 | 739 | |
| 687 | 740 | $column_names[$var] = $type; |
| 688 | 741 | $values[$var] = $val; |
@@ -699,9 +752,12 @@ discard block |
||
| 699 | 752 | |
| 700 | 753 | // Update the number of members and latest member's info - and pass the name, but remove the 's. |
| 701 | 754 | if ($regOptions['register_vars']['is_activated'] == 1) |
| 702 | - updateMemberStats($memberID, $regOptions['register_vars']['real_name']); |
|
| 703 | - else |
|
| 704 | - updateMemberStats(); |
|
| 755 | + { |
|
| 756 | + updateMemberStats($memberID, $regOptions['register_vars']['real_name']); |
|
| 757 | + } |
|
| 758 | + else { |
|
| 759 | + updateMemberStats(); |
|
| 760 | + } |
|
| 705 | 761 | |
| 706 | 762 | // @todo there's got to be a method that does this |
| 707 | 763 | // Theme variables too? |
@@ -709,7 +765,9 @@ discard block |
||
| 709 | 765 | { |
| 710 | 766 | $inserts = array(); |
| 711 | 767 | foreach ($theme_vars as $var => $val) |
| 712 | - $inserts[] = array($memberID, $var, $val); |
|
| 768 | + { |
|
| 769 | + $inserts[] = array($memberID, $var, $val); |
|
| 770 | + } |
|
| 713 | 771 | $db->insert('insert', |
| 714 | 772 | '{db_prefix}themes', |
| 715 | 773 | array('id_member' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'), |
@@ -740,9 +798,13 @@ discard block |
||
| 740 | 798 | if ($regOptions['interface'] == 'admin') |
| 741 | 799 | { |
| 742 | 800 | if ($regOptions['require'] == 'activation') |
| 743 | - $email_message = 'admin_register_activate'; |
|
| 801 | + { |
|
| 802 | + $email_message = 'admin_register_activate'; |
|
| 803 | + } |
|
| 744 | 804 | elseif (!empty($regOptions['send_welcome_email'])) |
| 745 | - $email_message = 'admin_register_immediate'; |
|
| 805 | + { |
|
| 806 | + $email_message = 'admin_register_immediate'; |
|
| 807 | + } |
|
| 746 | 808 | |
| 747 | 809 | if (isset($email_message)) |
| 748 | 810 | { |
@@ -855,38 +917,51 @@ discard block |
||
| 855 | 917 | foreach ($reservedNames as $reserved) |
| 856 | 918 | { |
| 857 | 919 | if ($reserved == '') |
| 858 | - continue; |
|
| 920 | + { |
|
| 921 | + continue; |
|
| 922 | + } |
|
| 859 | 923 | |
| 860 | 924 | // The admin might've used entities too, level the playing field. |
| 861 | 925 | $reservedCheck = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'replaceEntities__callback', $reserved); |
| 862 | 926 | |
| 863 | 927 | // Case sensitive name? |
| 864 | 928 | if (empty($modSettings['reserveCase'])) |
| 865 | - $reservedCheck = Util::strtolower($reservedCheck); |
|
| 929 | + { |
|
| 930 | + $reservedCheck = Util::strtolower($reservedCheck); |
|
| 931 | + } |
|
| 866 | 932 | |
| 867 | 933 | // If it's not just entire word, check for it in there somewhere... |
| 868 | 934 | if ($checkMe == $reservedCheck || (Util::strpos($checkMe, $reservedCheck) !== false && empty($modSettings['reserveWord']))) |
| 869 | - if ($fatal) |
|
| 935 | + { |
|
| 936 | + if ($fatal) |
|
| 870 | 937 | throw new Elk_Exception('username_reserved', 'password', array($reserved)); |
| 871 | - else |
|
| 872 | - return true; |
|
| 938 | + } |
|
| 939 | + else { |
|
| 940 | + return true; |
|
| 941 | + } |
|
| 873 | 942 | } |
| 874 | 943 | |
| 875 | 944 | $censor_name = $name; |
| 876 | 945 | if (censor($censor_name) != $name) |
| 877 | - if ($fatal) |
|
| 946 | + { |
|
| 947 | + if ($fatal) |
|
| 878 | 948 | throw new Elk_Exception('name_censored', 'password', array($name)); |
| 879 | - else |
|
| 880 | - return true; |
|
| 949 | + } |
|
| 950 | + else { |
|
| 951 | + return true; |
|
| 952 | + } |
|
| 881 | 953 | } |
| 882 | 954 | |
| 883 | 955 | // Characters we just shouldn't allow, regardless. |
| 884 | 956 | foreach (array('*') as $char) |
| 885 | - if (strpos($checkName, $char) !== false) |
|
| 957 | + { |
|
| 958 | + if (strpos($checkName, $char) !== false) |
|
| 886 | 959 | if ($fatal) |
| 887 | 960 | throw new Elk_Exception('username_reserved', 'password', array($char)); |
| 888 | - else |
|
| 889 | - return true; |
|
| 961 | + } |
|
| 962 | + else { |
|
| 963 | + return true; |
|
| 964 | + } |
|
| 890 | 965 | |
| 891 | 966 | // Get rid of any SQL parts of the reserved name... |
| 892 | 967 | $checkName = strtr($name, array('_' => '\\_', '%' => '\\%')); |
@@ -972,7 +1047,9 @@ discard block |
||
| 972 | 1047 | ) |
| 973 | 1048 | ); |
| 974 | 1049 | while ($row = $db->fetch_assoc($request)) |
| 975 | - $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
| 1050 | + { |
|
| 1051 | + $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
| 1052 | + } |
|
| 976 | 1053 | $db->free_result($request); |
| 977 | 1054 | } |
| 978 | 1055 | |
@@ -981,18 +1058,23 @@ discard block |
||
| 981 | 1058 | { |
| 982 | 1059 | // First get the profile of the given board. |
| 983 | 1060 | if (isset($board_info['id']) && $board_info['id'] == $board_id) |
| 984 | - $profile_id = $board_info['profile']; |
|
| 1061 | + { |
|
| 1062 | + $profile_id = $board_info['profile']; |
|
| 1063 | + } |
|
| 985 | 1064 | elseif ($board_id !== 0) |
| 986 | 1065 | { |
| 987 | 1066 | require_once(SUBSDIR . '/Boards.subs.php'); |
| 988 | 1067 | $board_data = fetchBoardsInfo(array('boards' => $board_id), array('selects' => 'permissions')); |
| 989 | 1068 | |
| 990 | 1069 | if (empty($board_data)) |
| 991 | - throw new Elk_Exception('no_board'); |
|
| 1070 | + { |
|
| 1071 | + throw new Elk_Exception('no_board'); |
|
| 1072 | + } |
|
| 992 | 1073 | $profile_id = $board_data[$board_id]['id_profile']; |
| 993 | 1074 | } |
| 994 | - else |
|
| 995 | - $profile_id = 1; |
|
| 1075 | + else { |
|
| 1076 | + $profile_id = 1; |
|
| 1077 | + } |
|
| 996 | 1078 | |
| 997 | 1079 | $request = $db->query('', ' |
| 998 | 1080 | SELECT bp.id_group, bp.add_deny |
@@ -1005,7 +1087,9 @@ discard block |
||
| 1005 | 1087 | ) |
| 1006 | 1088 | ); |
| 1007 | 1089 | while ($row = $db->fetch_assoc($request)) |
| 1008 | - $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
| 1090 | + { |
|
| 1091 | + $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
| 1092 | + } |
|
| 1009 | 1093 | $db->free_result($request); |
| 1010 | 1094 | } |
| 1011 | 1095 | |
@@ -1117,9 +1201,13 @@ discard block |
||
| 1117 | 1201 | |
| 1118 | 1202 | $query_parts = array(); |
| 1119 | 1203 | if (!empty($email)) |
| 1120 | - $query_parts[] = 'poster_email = {string:email_address}'; |
|
| 1204 | + { |
|
| 1205 | + $query_parts[] = 'poster_email = {string:email_address}'; |
|
| 1206 | + } |
|
| 1121 | 1207 | if (!empty($membername)) |
| 1122 | - $query_parts[] = 'poster_name = {string:member_name}'; |
|
| 1208 | + { |
|
| 1209 | + $query_parts[] = 'poster_name = {string:member_name}'; |
|
| 1210 | + } |
|
| 1123 | 1211 | $query = implode(' AND ', $query_parts); |
| 1124 | 1212 | |
| 1125 | 1213 | // Finally, update the posts themselves! |
@@ -1182,7 +1270,9 @@ discard block |
||
| 1182 | 1270 | |
| 1183 | 1271 | // If we want duplicates pass the members array off. |
| 1184 | 1272 | if ($get_duplicates) |
| 1185 | - populateDuplicateMembers($members); |
|
| 1273 | + { |
|
| 1274 | + populateDuplicateMembers($members); |
|
| 1275 | + } |
|
| 1186 | 1276 | |
| 1187 | 1277 | return $members; |
| 1188 | 1278 | } |
@@ -1202,7 +1292,9 @@ discard block |
||
| 1202 | 1292 | |
| 1203 | 1293 | // We know how many members there are in total. |
| 1204 | 1294 | if (empty($where) || $where == '1=1') |
| 1205 | - $num_members = $modSettings['totalMembers']; |
|
| 1295 | + { |
|
| 1296 | + $num_members = $modSettings['totalMembers']; |
|
| 1297 | + } |
|
| 1206 | 1298 | |
| 1207 | 1299 | // The database knows the amount when there are extra conditions. |
| 1208 | 1300 | else |
@@ -1240,15 +1332,21 @@ discard block |
||
| 1240 | 1332 | |
| 1241 | 1333 | // Store the IPs. |
| 1242 | 1334 | if (!empty($member['member_ip'])) |
| 1243 | - $ips[] = $member['member_ip']; |
|
| 1335 | + { |
|
| 1336 | + $ips[] = $member['member_ip']; |
|
| 1337 | + } |
|
| 1244 | 1338 | if (!empty($member['member_ip2'])) |
| 1245 | - $ips[] = $member['member_ip2']; |
|
| 1339 | + { |
|
| 1340 | + $ips[] = $member['member_ip2']; |
|
| 1341 | + } |
|
| 1246 | 1342 | } |
| 1247 | 1343 | |
| 1248 | 1344 | $ips = array_unique($ips); |
| 1249 | 1345 | |
| 1250 | 1346 | if (empty($ips)) |
| 1251 | - return false; |
|
| 1347 | + { |
|
| 1348 | + return false; |
|
| 1349 | + } |
|
| 1252 | 1350 | |
| 1253 | 1351 | // Fetch all members with this IP address, we'll filter out the current ones in a sec. |
| 1254 | 1352 | $potential_dupes = membersByIP($ips, 'exact', true); |
@@ -1269,9 +1367,13 @@ discard block |
||
| 1269 | 1367 | ); |
| 1270 | 1368 | |
| 1271 | 1369 | if (in_array($row['member_ip'], $ips)) |
| 1272 | - $duplicate_members[$row['member_ip']][] = $member_context; |
|
| 1370 | + { |
|
| 1371 | + $duplicate_members[$row['member_ip']][] = $member_context; |
|
| 1372 | + } |
|
| 1273 | 1373 | if ($row['member_ip'] != $row['member_ip2'] && in_array($row['member_ip2'], $ips)) |
| 1274 | - $duplicate_members[$row['member_ip2']][] = $member_context; |
|
| 1374 | + { |
|
| 1375 | + $duplicate_members[$row['member_ip2']][] = $member_context; |
|
| 1376 | + } |
|
| 1275 | 1377 | } |
| 1276 | 1378 | |
| 1277 | 1379 | // Also try to get a list of messages using these ips. |
@@ -1294,7 +1396,9 @@ discard block |
||
| 1294 | 1396 | { |
| 1295 | 1397 | // Don't collect lots of the same. |
| 1296 | 1398 | if (isset($had_ips[$row['poster_ip']]) && in_array($row['id_member'], $had_ips[$row['poster_ip']])) |
| 1297 | - continue; |
|
| 1399 | + { |
|
| 1400 | + continue; |
|
| 1401 | + } |
|
| 1298 | 1402 | $had_ips[$row['poster_ip']][] = $row['id_member']; |
| 1299 | 1403 | |
| 1300 | 1404 | $duplicate_members[$row['poster_ip']][] = array( |
@@ -1314,9 +1418,13 @@ discard block |
||
| 1314 | 1418 | foreach ($members as $key => $member) |
| 1315 | 1419 | { |
| 1316 | 1420 | if (isset($duplicate_members[$member['member_ip']])) |
| 1317 | - $members[$key]['duplicate_members'] = $duplicate_members[$member['member_ip']]; |
|
| 1421 | + { |
|
| 1422 | + $members[$key]['duplicate_members'] = $duplicate_members[$member['member_ip']]; |
|
| 1423 | + } |
|
| 1318 | 1424 | if ($member['member_ip'] != $member['member_ip2'] && isset($duplicate_members[$member['member_ip2']])) |
| 1319 | - $members[$key]['duplicate_members'] = array_merge($member['duplicate_members'], $duplicate_members[$member['member_ip2']]); |
|
| 1425 | + { |
|
| 1426 | + $members[$key]['duplicate_members'] = array_merge($member['duplicate_members'], $duplicate_members[$member['member_ip2']]); |
|
| 1427 | + } |
|
| 1320 | 1428 | |
| 1321 | 1429 | // Check we don't have lots of the same member. |
| 1322 | 1430 | $member_track = array($member['id_member']); |
@@ -1352,10 +1460,14 @@ discard block |
||
| 1352 | 1460 | foreach (array($ip1, $ip2) as $id => $ip) |
| 1353 | 1461 | { |
| 1354 | 1462 | if ($ip === false) |
| 1355 | - continue; |
|
| 1463 | + { |
|
| 1464 | + continue; |
|
| 1465 | + } |
|
| 1356 | 1466 | |
| 1357 | 1467 | if ($match === 'exact') |
| 1358 | - $ip_params['ips'] = array_merge($ip_params['ips'], (array) $ip); |
|
| 1468 | + { |
|
| 1469 | + $ip_params['ips'] = array_merge($ip_params['ips'], (array) $ip); |
|
| 1470 | + } |
|
| 1359 | 1471 | else |
| 1360 | 1472 | { |
| 1361 | 1473 | $ip = (array) $ip; |
@@ -1372,15 +1484,19 @@ discard block |
||
| 1372 | 1484 | { |
| 1373 | 1485 | $where = 'member_ip IN ({array_string:ips})'; |
| 1374 | 1486 | if ($ip2 !== false) |
| 1375 | - $where .= ' |
|
| 1487 | + { |
|
| 1488 | + $where .= ' |
|
| 1376 | 1489 | OR member_ip2 IN ({array_string:ips})'; |
| 1490 | + } |
|
| 1377 | 1491 | } |
| 1378 | 1492 | else |
| 1379 | 1493 | { |
| 1380 | 1494 | $where = 'member_ip ' . implode(' OR member_ip', $ip_query); |
| 1381 | 1495 | if ($ip2 !== false) |
| 1382 | - $where .= ' |
|
| 1496 | + { |
|
| 1497 | + $where .= ' |
|
| 1383 | 1498 | OR member_ip2 ' . implode(' OR member_ip', $ip_query); |
| 1499 | + } |
|
| 1384 | 1500 | } |
| 1385 | 1501 | |
| 1386 | 1502 | return $db->fetchQuery(' |
@@ -1451,13 +1567,17 @@ discard block |
||
| 1451 | 1567 | if ($details) |
| 1452 | 1568 | { |
| 1453 | 1569 | while ($row = $db->fetch_assoc($request)) |
| 1454 | - $members[$row['id_member']] = $row; |
|
| 1570 | + { |
|
| 1571 | + $members[$row['id_member']] = $row; |
|
| 1572 | + } |
|
| 1455 | 1573 | } |
| 1456 | 1574 | // Or just a int[] of found member id's |
| 1457 | 1575 | else |
| 1458 | 1576 | { |
| 1459 | 1577 | while ($row = $db->fetch_assoc($request)) |
| 1460 | - $members[] = $row['id_member']; |
|
| 1578 | + { |
|
| 1579 | + $members[] = $row['id_member']; |
|
| 1580 | + } |
|
| 1461 | 1581 | } |
| 1462 | 1582 | $db->free_result($request); |
| 1463 | 1583 | |
@@ -1538,9 +1658,12 @@ discard block |
||
| 1538 | 1658 | foreach ($query_conditions as $condition => $query_condition) |
| 1539 | 1659 | { |
| 1540 | 1660 | if ($query_condition == 'member_names') |
| 1541 | - $query_parts[$condition === 'or' ? 'or' : 'and'][] = $allowed_conditions[$query_condition]($query_params); |
|
| 1542 | - else |
|
| 1543 | - $query_parts[$condition === 'or' ? 'or' : 'and'][] = isset($allowed_conditions[$query_condition]) ? $allowed_conditions[$query_condition] : $query_condition; |
|
| 1661 | + { |
|
| 1662 | + $query_parts[$condition === 'or' ? 'or' : 'and'][] = $allowed_conditions[$query_condition]($query_params); |
|
| 1663 | + } |
|
| 1664 | + else { |
|
| 1665 | + $query_parts[$condition === 'or' ? 'or' : 'and'][] = isset($allowed_conditions[$query_condition]) ? $allowed_conditions[$query_condition] : $query_condition; |
|
| 1666 | + } |
|
| 1544 | 1667 | } |
| 1545 | 1668 | } |
| 1546 | 1669 | elseif ($query_conditions == 'member_names') |
@@ -1554,7 +1677,9 @@ discard block |
||
| 1554 | 1677 | } |
| 1555 | 1678 | |
| 1556 | 1679 | if (!empty($query_parts['or'])) |
| 1557 | - $query_parts['and'][] = implode("\n\t\t\tOR ", $query_parts['or']); |
|
| 1680 | + { |
|
| 1681 | + $query_parts['and'][] = implode("\n\t\t\tOR ", $query_parts['or']); |
|
| 1682 | + } |
|
| 1558 | 1683 | |
| 1559 | 1684 | $query_where = implode("\n\t\t\tAND ", $query_parts['and']); |
| 1560 | 1685 | } |
@@ -1562,17 +1687,23 @@ discard block |
||
| 1562 | 1687 | elseif (isset($allowed_conditions[$query])) |
| 1563 | 1688 | { |
| 1564 | 1689 | if ($query == 'member_names') |
| 1565 | - $query_where = $allowed_conditions[$query]($query_params); |
|
| 1566 | - else |
|
| 1567 | - $query_where = $allowed_conditions[$query]; |
|
| 1690 | + { |
|
| 1691 | + $query_where = $allowed_conditions[$query]($query_params); |
|
| 1692 | + } |
|
| 1693 | + else { |
|
| 1694 | + $query_where = $allowed_conditions[$query]; |
|
| 1695 | + } |
|
| 1568 | 1696 | } |
| 1569 | 1697 | // Something else, be careful ;) |
| 1570 | - else |
|
| 1571 | - $query_where = $query; |
|
| 1698 | + else { |
|
| 1699 | + $query_where = $query; |
|
| 1700 | + } |
|
| 1572 | 1701 | |
| 1573 | 1702 | // Lazy loading, our favorite |
| 1574 | 1703 | if (empty($query_where)) |
| 1575 | - return false; |
|
| 1704 | + { |
|
| 1705 | + return false; |
|
| 1706 | + } |
|
| 1576 | 1707 | |
| 1577 | 1708 | // Only want active members |
| 1578 | 1709 | if ($only_active) |
@@ -1613,7 +1744,9 @@ discard block |
||
| 1613 | 1744 | |
| 1614 | 1745 | $admins = array(); |
| 1615 | 1746 | while ($row = $db->fetch_assoc($request)) |
| 1616 | - $admins[$row['id_member']] = array($row['real_name'], $row['lngfile']); |
|
| 1747 | + { |
|
| 1748 | + $admins[$row['id_member']] = array($row['real_name'], $row['lngfile']); |
|
| 1749 | + } |
|
| 1617 | 1750 | $db->free_result($request); |
| 1618 | 1751 | |
| 1619 | 1752 | return $admins; |
@@ -1663,7 +1796,9 @@ discard block |
||
| 1663 | 1796 | $members = array(); |
| 1664 | 1797 | |
| 1665 | 1798 | if (empty($member_ids)) |
| 1666 | - return false; |
|
| 1799 | + { |
|
| 1800 | + return false; |
|
| 1801 | + } |
|
| 1667 | 1802 | |
| 1668 | 1803 | if (!is_array($member_ids)) |
| 1669 | 1804 | { |
@@ -1703,12 +1838,17 @@ discard block |
||
| 1703 | 1838 | while ($row = $db->fetch_assoc($request)) |
| 1704 | 1839 | { |
| 1705 | 1840 | if (empty($row['lngfile'])) |
| 1706 | - $row['lngfile'] = $language; |
|
| 1841 | + { |
|
| 1842 | + $row['lngfile'] = $language; |
|
| 1843 | + } |
|
| 1707 | 1844 | |
| 1708 | 1845 | if (!empty($single)) |
| 1709 | - $members = $row; |
|
| 1710 | - else |
|
| 1711 | - $members[$row['id_member']] = $row; |
|
| 1846 | + { |
|
| 1847 | + $members = $row; |
|
| 1848 | + } |
|
| 1849 | + else { |
|
| 1850 | + $members[$row['id_member']] = $row; |
|
| 1851 | + } |
|
| 1712 | 1852 | } |
| 1713 | 1853 | $db->free_result($request); |
| 1714 | 1854 | |
@@ -1738,7 +1878,9 @@ discard block |
||
| 1738 | 1878 | ); |
| 1739 | 1879 | |
| 1740 | 1880 | while ($row = $db->fetch_assoc($request)) |
| 1741 | - $inactive_members[$row['is_activated']] = $row['total_members']; |
|
| 1881 | + { |
|
| 1882 | + $inactive_members[$row['is_activated']] = $row['total_members']; |
|
| 1883 | + } |
|
| 1742 | 1884 | $db->free_result($request); |
| 1743 | 1885 | |
| 1744 | 1886 | return $inactive_members; |
@@ -1769,7 +1911,9 @@ discard block |
||
| 1769 | 1911 | ) |
| 1770 | 1912 | ); |
| 1771 | 1913 | if ($db->num_rows($request) == 0) |
| 1772 | - return false; |
|
| 1914 | + { |
|
| 1915 | + return false; |
|
| 1916 | + } |
|
| 1773 | 1917 | $member = $db->fetch_assoc($request); |
| 1774 | 1918 | $db->free_result($request); |
| 1775 | 1919 | |
@@ -1873,16 +2017,22 @@ discard block |
||
| 1873 | 2017 | |
| 1874 | 2018 | $query_cond = array(); |
| 1875 | 2019 | foreach ($conditions as $key => $dummy) |
| 1876 | - if (isset($available_conditions[$key])) |
|
| 2020 | + { |
|
| 2021 | + if (isset($available_conditions[$key])) |
|
| 1877 | 2022 | $query_cond[] = $available_conditions[$key]; |
| 2023 | + } |
|
| 1878 | 2024 | |
| 1879 | 2025 | if (isset($conditions['group_list'])) |
| 1880 | - $conditions['additional_group_list'] = implode(', additional_groups) != 0 OR FIND_IN_SET(', $conditions['group_list']); |
|
| 2026 | + { |
|
| 2027 | + $conditions['additional_group_list'] = implode(', additional_groups) != 0 OR FIND_IN_SET(', $conditions['group_list']); |
|
| 2028 | + } |
|
| 1881 | 2029 | |
| 1882 | 2030 | $data = array(); |
| 1883 | 2031 | |
| 1884 | 2032 | if (!isset($conditions['order_by'])) |
| 1885 | - $conditions['order_by'] = 'lngfile'; |
|
| 2033 | + { |
|
| 2034 | + $conditions['order_by'] = 'lngfile'; |
|
| 2035 | + } |
|
| 1886 | 2036 | |
| 1887 | 2037 | $limit = (isset($conditions['limit'])) ? ' |
| 1888 | 2038 | LIMIT {int:limit}' : ''; |
@@ -1899,7 +2049,9 @@ discard block |
||
| 1899 | 2049 | $data['member_count'] = $db->num_rows($request); |
| 1900 | 2050 | |
| 1901 | 2051 | if ($data['member_count'] == 0) |
| 1902 | - return $data; |
|
| 2052 | + { |
|
| 2053 | + return $data; |
|
| 2054 | + } |
|
| 1903 | 2055 | |
| 1904 | 2056 | // Fill the info array. |
| 1905 | 2057 | while ($row = $db->fetch_assoc($request)) |
@@ -1951,7 +2103,9 @@ discard block |
||
| 1951 | 2103 | if (isset($available_conditions[$key])) |
| 1952 | 2104 | { |
| 1953 | 2105 | if ($key === 'time_before') |
| 1954 | - $query = true; |
|
| 2106 | + { |
|
| 2107 | + $query = true; |
|
| 2108 | + } |
|
| 1955 | 2109 | $query_cond[] = $available_conditions[$key]; |
| 1956 | 2110 | } |
| 1957 | 2111 | } |
@@ -1961,7 +2115,9 @@ discard block |
||
| 1961 | 2115 | $data = retrieveMemberData($conditions); |
| 1962 | 2116 | $members_id = array(); |
| 1963 | 2117 | foreach ($data['member_info'] as $member) |
| 1964 | - $members_id[] = $member['username']; |
|
| 2118 | + { |
|
| 2119 | + $members_id[] = $member['username']; |
|
| 2120 | + } |
|
| 1965 | 2121 | } |
| 1966 | 2122 | else |
| 1967 | 2123 | { |
@@ -1981,7 +2137,9 @@ discard block |
||
| 1981 | 2137 | |
| 1982 | 2138 | // Let the integration know that they've been activated! |
| 1983 | 2139 | foreach ($members_id as $member_id) |
| 1984 | - call_integration_hook('integrate_activate', array($member_id, $conditions['activated_status'], $conditions['is_activated'])); |
|
| 2140 | + { |
|
| 2141 | + call_integration_hook('integrate_activate', array($member_id, $conditions['activated_status'], $conditions['is_activated'])); |
|
| 2142 | + } |
|
| 1985 | 2143 | |
| 1986 | 2144 | return $conditions['is_activated']; |
| 1987 | 2145 | } |
@@ -2232,16 +2390,22 @@ discard block |
||
| 2232 | 2390 | $row['additional_groups'] = $group_changes[$row['id_member']]['add']; |
| 2233 | 2391 | $row['primary_group'] = $group_changes[$row['id_member']]['primary']; |
| 2234 | 2392 | } |
| 2235 | - else |
|
| 2236 | - $row['additional_groups'] = explode(',', $row['additional_groups']); |
|
| 2393 | + else { |
|
| 2394 | + $row['additional_groups'] = explode(',', $row['additional_groups']); |
|
| 2395 | + } |
|
| 2237 | 2396 | // Don't have it already? |
| 2238 | 2397 | if ($row['primary_group'] == $row['id_group'] || in_array($row['id_group'], $row['additional_groups'])) |
| 2239 | - continue; |
|
| 2398 | + { |
|
| 2399 | + continue; |
|
| 2400 | + } |
|
| 2240 | 2401 | // Should it become their primary? |
| 2241 | 2402 | if ($row['primary_group'] == 0 && $row['hidden'] == 0) |
| 2242 | - $row['primary_group'] = $row['id_group']; |
|
| 2243 | - else |
|
| 2244 | - $row['additional_groups'][] = $row['id_group']; |
|
| 2403 | + { |
|
| 2404 | + $row['primary_group'] = $row['id_group']; |
|
| 2405 | + } |
|
| 2406 | + else { |
|
| 2407 | + $row['additional_groups'][] = $row['id_group']; |
|
| 2408 | + } |
|
| 2245 | 2409 | |
| 2246 | 2410 | // Add them to the group master list. |
| 2247 | 2411 | $group_changes[$row['id_member']] = array( |
@@ -2252,7 +2416,8 @@ discard block |
||
| 2252 | 2416 | |
| 2253 | 2417 | // Add required information to email them. |
| 2254 | 2418 | if ($row['notify_types'] != 4) |
| 2255 | - $email_details[] = array( |
|
| 2419 | + { |
|
| 2420 | + $email_details[] = array( |
|
| 2256 | 2421 | 'rid' => $row['id_request'], |
| 2257 | 2422 | 'member_id' => $row['id_member'], |
| 2258 | 2423 | 'member_name' => $row['member_name'], |
@@ -2261,6 +2426,7 @@ discard block |
||
| 2261 | 2426 | 'email' => $row['email_address'], |
| 2262 | 2427 | 'language' => $row['lngfile'], |
| 2263 | 2428 | ); |
| 2429 | + } |
|
| 2264 | 2430 | } |
| 2265 | 2431 | $db->free_result($request); |
| 2266 | 2432 | |
@@ -2300,17 +2466,24 @@ discard block |
||
| 2300 | 2466 | |
| 2301 | 2467 | // 0 = all members |
| 2302 | 2468 | if ($receive_from == 0) |
| 2303 | - return true; |
|
| 2469 | + { |
|
| 2470 | + return true; |
|
| 2471 | + } |
|
| 2304 | 2472 | // 1 = all except ignore |
| 2305 | 2473 | elseif ($receive_from == 1) |
| 2306 | - return !(!empty($ignore_list) && in_array($user_info['id'], $ignore_list)); |
|
| 2474 | + { |
|
| 2475 | + return !(!empty($ignore_list) && in_array($user_info['id'], $ignore_list)); |
|
| 2476 | + } |
|
| 2307 | 2477 | // 2 = buddies and admin |
| 2308 | 2478 | elseif ($receive_from == 2) |
| 2309 | - return ($user_info['is_admin'] || (!empty($buddy_list) && in_array($user_info['id'], $buddy_list))); |
|
| 2479 | + { |
|
| 2480 | + return ($user_info['is_admin'] || (!empty($buddy_list) && in_array($user_info['id'], $buddy_list))); |
|
| 2481 | + } |
|
| 2310 | 2482 | // 3 = admin only |
| 2311 | - else |
|
| 2312 | - return (bool) $user_info['is_admin']; |
|
| 2313 | -} |
|
| 2483 | + else { |
|
| 2484 | + return (bool) $user_info['is_admin']; |
|
| 2485 | + } |
|
| 2486 | + } |
|
| 2314 | 2487 | |
| 2315 | 2488 | /** |
| 2316 | 2489 | * This function updates the latest member, the total membercount, and the |
@@ -2458,7 +2631,9 @@ discard block |
||
| 2458 | 2631 | $parameters['members'] = $members; |
| 2459 | 2632 | } |
| 2460 | 2633 | elseif ($members === null) |
| 2461 | - $condition = '1=1'; |
|
| 2634 | + { |
|
| 2635 | + $condition = '1=1'; |
|
| 2636 | + } |
|
| 2462 | 2637 | else |
| 2463 | 2638 | { |
| 2464 | 2639 | $condition = 'id_member = {int:member}'; |
@@ -2501,7 +2676,9 @@ discard block |
||
| 2501 | 2676 | { |
| 2502 | 2677 | // Fetch a list of member_names if necessary |
| 2503 | 2678 | if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) |
| 2504 | - $member_names = array($user_info['username']); |
|
| 2679 | + { |
|
| 2680 | + $member_names = array($user_info['username']); |
|
| 2681 | + } |
|
| 2505 | 2682 | else |
| 2506 | 2683 | { |
| 2507 | 2684 | $member_names = $db->fetchQueryCallback(' |
@@ -2517,8 +2694,10 @@ discard block |
||
| 2517 | 2694 | } |
| 2518 | 2695 | |
| 2519 | 2696 | if (!empty($member_names)) |
| 2520 | - foreach ($vars_to_integrate as $var) |
|
| 2697 | + { |
|
| 2698 | + foreach ($vars_to_integrate as $var) |
|
| 2521 | 2699 | call_integration_hook('integrate_change_member_data', array($member_names, &$var, &$data[$var], &$knownInts, &$knownFloats)); |
| 2700 | + } |
|
| 2522 | 2701 | } |
| 2523 | 2702 | } |
| 2524 | 2703 | |
@@ -2528,11 +2707,17 @@ discard block |
||
| 2528 | 2707 | $type = 'string'; |
| 2529 | 2708 | |
| 2530 | 2709 | if (in_array($var, $knownInts)) |
| 2531 | - $type = 'int'; |
|
| 2710 | + { |
|
| 2711 | + $type = 'int'; |
|
| 2712 | + } |
|
| 2532 | 2713 | elseif (in_array($var, $knownFloats)) |
| 2533 | - $type = 'float'; |
|
| 2714 | + { |
|
| 2715 | + $type = 'float'; |
|
| 2716 | + } |
|
| 2534 | 2717 | elseif ($var == 'birthdate') |
| 2535 | - $type = 'date'; |
|
| 2718 | + { |
|
| 2719 | + $type = 'date'; |
|
| 2720 | + } |
|
| 2536 | 2721 | |
| 2537 | 2722 | // Doing an increment? |
| 2538 | 2723 | if ($type == 'int' && ($val === '+' || $val === '-')) |
@@ -2547,7 +2732,9 @@ discard block |
||
| 2547 | 2732 | if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match)) |
| 2548 | 2733 | { |
| 2549 | 2734 | if ($match[1] != '+ ') |
| 2550 | - $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
| 2735 | + { |
|
| 2736 | + $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
| 2737 | + } |
|
| 2551 | 2738 | $type = 'raw'; |
| 2552 | 2739 | } |
| 2553 | 2740 | } |
@@ -2572,7 +2759,9 @@ discard block |
||
| 2572 | 2759 | if ($cache->levelHigherThan(1) && !empty($members)) |
| 2573 | 2760 | { |
| 2574 | 2761 | if (!is_array($members)) |
| 2575 | - $members = array($members); |
|
| 2762 | + { |
|
| 2763 | + $members = array($members); |
|
| 2764 | + } |
|
| 2576 | 2765 | |
| 2577 | 2766 | foreach ($members as $member) |
| 2578 | 2767 | { |
@@ -2611,7 +2800,9 @@ discard block |
||
| 2611 | 2800 | ); |
| 2612 | 2801 | $ips = array(); |
| 2613 | 2802 | while ($row = $db->fetch_assoc($request)) |
| 2614 | - $ips[$row['member_ip']][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
| 2803 | + { |
|
| 2804 | + $ips[$row['member_ip']][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
| 2805 | + } |
|
| 2615 | 2806 | $db->free_result($request); |
| 2616 | 2807 | |
| 2617 | 2808 | ksort($ips); |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | 'pm_ignore_list' => implode(', pm_ignore_list) != 0 OR FIND_IN_SET(', $users), |
| 431 | 431 | 'buddy_list' => implode(', buddy_list) != 0 OR FIND_IN_SET(', $users), |
| 432 | 432 | ), |
| 433 | - function ($row) use ($users) |
|
| 433 | + function($row) use ($users) |
|
| 434 | 434 | { |
| 435 | 435 | updateMemberData($row['id_member'], array( |
| 436 | 436 | 'pm_ignore_list' => implode(',', array_diff(explode(',', $row['pm_ignore_list']), $users)), |
@@ -1054,7 +1054,7 @@ discard block |
||
| 1054 | 1054 | 'member_group_allowed_implode' => implode(', mem.additional_groups) != 0 OR FIND_IN_SET(', $member_groups['allowed']), |
| 1055 | 1055 | 'member_group_denied_implode' => implode(', mem.additional_groups) != 0 OR FIND_IN_SET(', $member_groups['denied']), |
| 1056 | 1056 | ), |
| 1057 | - function ($row) |
|
| 1057 | + function($row) |
|
| 1058 | 1058 | { |
| 1059 | 1059 | return $row['id_member']; |
| 1060 | 1060 | } |
@@ -1509,7 +1509,7 @@ discard block |
||
| 1509 | 1509 | { |
| 1510 | 1510 | $allowed_conditions = array( |
| 1511 | 1511 | 'member_ids' => 'id_member IN ({array_int:member_ids})', |
| 1512 | - 'member_names' => function (&$members) |
|
| 1512 | + 'member_names' => function(&$members) |
|
| 1513 | 1513 | { |
| 1514 | 1514 | $mem_query = array(); |
| 1515 | 1515 | |
@@ -1811,7 +1811,7 @@ discard block |
||
| 1811 | 1811 | 'activation_status' => array(1, 12), |
| 1812 | 1812 | 'limit' => Util::strlen($search) <= 2 ? 100 : 200, |
| 1813 | 1813 | ), |
| 1814 | - function ($row) |
|
| 1814 | + function($row) |
|
| 1815 | 1815 | { |
| 1816 | 1816 | $row['real_name'] = strtr($row['real_name'], array('&' => '&', '<' => '<', '>' => '>', '"' => '"')); |
| 1817 | 1817 | |
@@ -2509,7 +2509,7 @@ discard block |
||
| 2509 | 2509 | FROM {db_prefix}members |
| 2510 | 2510 | WHERE ' . $condition, |
| 2511 | 2511 | $parameters, |
| 2512 | - function ($row) |
|
| 2512 | + function($row) |
|
| 2513 | 2513 | { |
| 2514 | 2514 | return $row['member_name']; |
| 2515 | 2515 | } |
@@ -30,11 +30,17 @@ discard block |
||
| 30 | 30 | // Not pretty, but since we don't want folders created for every post. |
| 31 | 31 | // It'll do unless a better solution can be found. |
| 32 | 32 | if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin') |
| 33 | - $doit = true; |
|
| 33 | + { |
|
| 34 | + $doit = true; |
|
| 35 | + } |
|
| 34 | 36 | elseif (empty($modSettings['automanage_attachments'])) |
| 35 | - return; |
|
| 37 | + { |
|
| 38 | + return; |
|
| 39 | + } |
|
| 36 | 40 | elseif (!isset($_FILES)) |
| 37 | - return; |
|
| 41 | + { |
|
| 42 | + return; |
|
| 43 | + } |
|
| 38 | 44 | elseif (isset($_FILES['attachment'])) |
| 39 | 45 | { |
| 40 | 46 | foreach ($_FILES['attachment']['tmp_name'] as $dummy) |
@@ -48,7 +54,9 @@ discard block |
||
| 48 | 54 | } |
| 49 | 55 | |
| 50 | 56 | if (!isset($doit)) |
| 51 | - return; |
|
| 57 | + { |
|
| 58 | + return; |
|
| 59 | + } |
|
| 52 | 60 | |
| 53 | 61 | // Get our date and random numbers for the directory choices |
| 54 | 62 | $year = date('Y'); |
@@ -61,21 +69,30 @@ discard block |
||
| 61 | 69 | if (!empty($modSettings['attachment_basedirectories']) && !empty($modSettings['use_subdirectories_for_attachments'])) |
| 62 | 70 | { |
| 63 | 71 | if (!is_array($modSettings['attachment_basedirectories'])) |
| 64 | - $modSettings['attachment_basedirectories'] = Util::unserialize($modSettings['attachment_basedirectories']); |
|
| 72 | + { |
|
| 73 | + $modSettings['attachment_basedirectories'] = Util::unserialize($modSettings['attachment_basedirectories']); |
|
| 74 | + } |
|
| 65 | 75 | |
| 66 | 76 | $base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']); |
| 67 | 77 | } |
| 68 | - else |
|
| 69 | - $base_dir = 0; |
|
| 78 | + else { |
|
| 79 | + $base_dir = 0; |
|
| 80 | + } |
|
| 70 | 81 | |
| 71 | 82 | if ($modSettings['automanage_attachments'] == 1) |
| 72 | 83 | { |
| 73 | 84 | if (!isset($modSettings['last_attachments_directory'])) |
| 74 | - $modSettings['last_attachments_directory'] = array(); |
|
| 85 | + { |
|
| 86 | + $modSettings['last_attachments_directory'] = array(); |
|
| 87 | + } |
|
| 75 | 88 | if (!is_array($modSettings['last_attachments_directory'])) |
| 76 | - $modSettings['last_attachments_directory'] = Util::unserialize($modSettings['last_attachments_directory']); |
|
| 89 | + { |
|
| 90 | + $modSettings['last_attachments_directory'] = Util::unserialize($modSettings['last_attachments_directory']); |
|
| 91 | + } |
|
| 77 | 92 | if (!isset($modSettings['last_attachments_directory'][$base_dir])) |
| 78 | - $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
| 93 | + { |
|
| 94 | + $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
| 95 | + } |
|
| 79 | 96 | } |
| 80 | 97 | |
| 81 | 98 | $basedirectory = (!empty($modSettings['use_subdirectories_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : BOARDDIR); |
@@ -106,12 +123,18 @@ discard block |
||
| 106 | 123 | } |
| 107 | 124 | |
| 108 | 125 | if (!is_array($modSettings['attachmentUploadDir'])) |
| 109 | - $modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']); |
|
| 126 | + { |
|
| 127 | + $modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']); |
|
| 128 | + } |
|
| 110 | 129 | |
| 111 | 130 | if (!in_array($updir, $modSettings['attachmentUploadDir']) && !empty($updir)) |
| 112 | - $outputCreation = automanage_attachments_create_directory($updir); |
|
| 131 | + { |
|
| 132 | + $outputCreation = automanage_attachments_create_directory($updir); |
|
| 133 | + } |
|
| 113 | 134 | elseif (in_array($updir, $modSettings['attachmentUploadDir'])) |
| 114 | - $outputCreation = true; |
|
| 135 | + { |
|
| 136 | + $outputCreation = true; |
|
| 137 | + } |
|
| 115 | 138 | |
| 116 | 139 | if ($outputCreation) |
| 117 | 140 | { |
@@ -153,7 +176,9 @@ discard block |
||
| 153 | 176 | |
| 154 | 177 | $directory = !empty($tree) ? attachments_init_dir($tree, $count) : false; |
| 155 | 178 | if ($directory === false) |
| 156 | - return false; |
|
| 179 | + { |
|
| 180 | + return false; |
|
| 181 | + } |
|
| 157 | 182 | } |
| 158 | 183 | |
| 159 | 184 | $directory .= DIRECTORY_SEPARATOR . array_shift($tree); |
@@ -194,7 +219,9 @@ discard block |
||
| 194 | 219 | |
| 195 | 220 | // Everything seems fine...let's create the .htaccess |
| 196 | 221 | if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess')) |
| 197 | - secureDirectory($updir, true); |
|
| 222 | + { |
|
| 223 | + secureDirectory($updir, true); |
|
| 224 | + } |
|
| 198 | 225 | |
| 199 | 226 | $sep = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? '\/' : DIRECTORY_SEPARATOR; |
| 200 | 227 | $updir = rtrim($updir, $sep); |
@@ -231,7 +258,9 @@ discard block |
||
| 231 | 258 | global $modSettings; |
| 232 | 259 | |
| 233 | 260 | if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1)) |
| 234 | - return; |
|
| 261 | + { |
|
| 262 | + return; |
|
| 263 | + } |
|
| 235 | 264 | |
| 236 | 265 | $basedirectory = (!empty($modSettings['use_subdirectories_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : BOARDDIR); |
| 237 | 266 | |
@@ -245,12 +274,15 @@ discard block |
||
| 245 | 274 | $base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']); |
| 246 | 275 | $base_dir = !empty($modSettings['automanage_attachments']) ? $base_dir : 0; |
| 247 | 276 | } |
| 248 | - else |
|
| 249 | - $base_dir = 0; |
|
| 277 | + else { |
|
| 278 | + $base_dir = 0; |
|
| 279 | + } |
|
| 250 | 280 | |
| 251 | 281 | // Get the last attachment directory for that base directory |
| 252 | 282 | if (empty($modSettings['last_attachments_directory'][$base_dir])) |
| 253 | - $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
| 283 | + { |
|
| 284 | + $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
| 285 | + } |
|
| 254 | 286 | |
| 255 | 287 | // And increment it. |
| 256 | 288 | $modSettings['last_attachments_directory'][$base_dir]++; |
@@ -269,9 +301,10 @@ discard block |
||
| 269 | 301 | |
| 270 | 302 | return true; |
| 271 | 303 | } |
| 272 | - else |
|
| 273 | - return false; |
|
| 274 | -} |
|
| 304 | + else { |
|
| 305 | + return false; |
|
| 306 | + } |
|
| 307 | + } |
|
| 275 | 308 | |
| 276 | 309 | /** |
| 277 | 310 | * Finds the current directory tree for the supplied base directory |
@@ -290,11 +323,15 @@ discard block |
||
| 290 | 323 | * while in linux should be safe to explode only for / (aka DIRECTORY_SEPARATOR) |
| 291 | 324 | */ |
| 292 | 325 | if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') |
| 293 | - $tree = preg_split('#[\\\/]#', $directory); |
|
| 326 | + { |
|
| 327 | + $tree = preg_split('#[\\\/]#', $directory); |
|
| 328 | + } |
|
| 294 | 329 | else |
| 295 | 330 | { |
| 296 | 331 | if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR) |
| 297 | - return false; |
|
| 332 | + { |
|
| 333 | + return false; |
|
| 334 | + } |
|
| 298 | 335 | |
| 299 | 336 | $tree = explode(DIRECTORY_SEPARATOR, trim($directory, DIRECTORY_SEPARATOR)); |
| 300 | 337 | } |
@@ -324,9 +361,12 @@ discard block |
||
| 324 | 361 | // ...even if, I should check this in the admin page...isn't it? |
| 325 | 362 | // ...NHAAA Let's leave space for users' complains! :P |
| 326 | 363 | if (preg_match('/^[a-z]:$/i', $tree[0])) |
| 327 | - $directory = array_shift($tree); |
|
| 328 | - else |
|
| 329 | - return false; |
|
| 364 | + { |
|
| 365 | + $directory = array_shift($tree); |
|
| 366 | + } |
|
| 367 | + else { |
|
| 368 | + return false; |
|
| 369 | + } |
|
| 330 | 370 | |
| 331 | 371 | $count--; |
| 332 | 372 | } |
@@ -356,7 +396,9 @@ discard block |
||
| 356 | 396 | |
| 357 | 397 | // Make sure we're uploading to the right place. |
| 358 | 398 | if (!empty($modSettings['automanage_attachments'])) |
| 359 | - automanage_attachments_check_directory(); |
|
| 399 | + { |
|
| 400 | + automanage_attachments_check_directory(); |
|
| 401 | + } |
|
| 360 | 402 | |
| 361 | 403 | if (!is_array($modSettings['attachmentUploadDir'])) |
| 362 | 404 | { |
@@ -371,7 +413,9 @@ discard block |
||
| 371 | 413 | |
| 372 | 414 | // Is the attachments folder actually there? |
| 373 | 415 | if (!empty($context['dir_creation_error'])) |
| 374 | - $initial_error = $context['dir_creation_error']; |
|
| 416 | + { |
|
| 417 | + $initial_error = $context['dir_creation_error']; |
|
| 418 | + } |
|
| 375 | 419 | elseif (!is_dir($context['attach_dir'])) |
| 376 | 420 | { |
| 377 | 421 | $initial_error = 'attach_folder_warning'; |
@@ -382,7 +426,9 @@ discard block |
||
| 382 | 426 | { |
| 383 | 427 | // If this isn't a new post, check the current attachments. |
| 384 | 428 | if (!empty($id_msg)) |
| 385 | - list ($context['attachments']['quantity'], $context['attachments']['total_size']) = attachmentsSizeForMessage($id_msg); |
|
| 429 | + { |
|
| 430 | + list ($context['attachments']['quantity'], $context['attachments']['total_size']) = attachmentsSizeForMessage($id_msg); |
|
| 431 | + } |
|
| 386 | 432 | else |
| 387 | 433 | { |
| 388 | 434 | $context['attachments']['quantity'] = 0; |
@@ -416,7 +462,9 @@ discard block |
||
| 416 | 462 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 417 | 463 | { |
| 418 | 464 | if (strpos($attachID, 'post_tmp_' . $user_info['id'] . '_') !== false) |
| 419 | - @unlink($attachment['tmp_name']); |
|
| 465 | + { |
|
| 466 | + @unlink($attachment['tmp_name']); |
|
| 467 | + } |
|
| 420 | 468 | } |
| 421 | 469 | |
| 422 | 470 | $attach_errors->activate()->addError('temp_attachments_flushed'); |
@@ -425,25 +473,33 @@ discard block |
||
| 425 | 473 | } |
| 426 | 474 | |
| 427 | 475 | if (!isset($_FILES['attachment']['name'])) |
| 428 | - $_FILES['attachment']['tmp_name'] = array(); |
|
| 476 | + { |
|
| 477 | + $_FILES['attachment']['tmp_name'] = array(); |
|
| 478 | + } |
|
| 429 | 479 | |
| 430 | 480 | if (!isset($_SESSION['temp_attachments'])) |
| 431 | - $_SESSION['temp_attachments'] = array(); |
|
| 481 | + { |
|
| 482 | + $_SESSION['temp_attachments'] = array(); |
|
| 483 | + } |
|
| 432 | 484 | |
| 433 | 485 | // Remember where we are at. If it's anywhere at all. |
| 434 | 486 | if (!$ignore_temp) |
| 435 | - $_SESSION['temp_attachments']['post'] = array( |
|
| 487 | + { |
|
| 488 | + $_SESSION['temp_attachments']['post'] = array( |
|
| 436 | 489 | 'msg' => !empty($id_msg) ? $id_msg : 0, |
| 437 | 490 | 'last_msg' => !empty($_REQUEST['last_msg']) ? $_REQUEST['last_msg'] : 0, |
| 438 | 491 | 'topic' => !empty($topic) ? $topic : 0, |
| 439 | 492 | 'board' => !empty($board) ? $board : 0, |
| 440 | 493 | ); |
| 494 | + } |
|
| 441 | 495 | |
| 442 | 496 | // Loop through $_FILES['attachment'] array and move each file to the current attachments folder. |
| 443 | 497 | foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
| 444 | 498 | { |
| 445 | 499 | if ($_FILES['attachment']['name'][$n] == '') |
| 446 | - continue; |
|
| 500 | + { |
|
| 501 | + continue; |
|
| 502 | + } |
|
| 447 | 503 | |
| 448 | 504 | // If we have an initial error, lets just display it. |
| 449 | 505 | if (!empty($initial_error) && $added_initial_error === false) |
@@ -464,7 +520,9 @@ discard block |
||
| 464 | 520 | foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
| 465 | 521 | { |
| 466 | 522 | if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
| 467 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 523 | + { |
|
| 524 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 525 | + } |
|
| 468 | 526 | } |
| 469 | 527 | |
| 470 | 528 | $_FILES['attachment']['tmp_name'] = array(); |
@@ -493,12 +551,16 @@ discard block |
||
| 493 | 551 | |
| 494 | 552 | // Move the file to the attachments folder with a temp name for now. |
| 495 | 553 | if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) |
| 496 | - @chmod($destName, 0644); |
|
| 554 | + { |
|
| 555 | + @chmod($destName, 0644); |
|
| 556 | + } |
|
| 497 | 557 | else |
| 498 | 558 | { |
| 499 | 559 | $_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout'; |
| 500 | 560 | if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
| 501 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 561 | + { |
|
| 562 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 563 | + } |
|
| 502 | 564 | } |
| 503 | 565 | } |
| 504 | 566 | // Upload error(s) were detected, flag the error, remove the file |
@@ -511,12 +573,16 @@ discard block |
||
| 511 | 573 | ); |
| 512 | 574 | |
| 513 | 575 | if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
| 514 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 576 | + { |
|
| 577 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 578 | + } |
|
| 515 | 579 | } |
| 516 | 580 | |
| 517 | 581 | // If there were no errors to this point, we apply some additional checks |
| 518 | 582 | if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
| 519 | - attachmentChecks($attachID); |
|
| 583 | + { |
|
| 584 | + attachmentChecks($attachID); |
|
| 585 | + } |
|
| 520 | 586 | |
| 521 | 587 | // Want to correct for phonetographer photos? |
| 522 | 588 | if (!empty($modSettings['attachment_autorotate']) && empty($_SESSION['temp_attachments'][$attachID]['errors']) && substr($_SESSION['temp_attachments'][$attachID]['type'], 0, 5) === 'image') |
@@ -548,8 +614,9 @@ discard block |
||
| 548 | 614 | unset($_SESSION['temp_attachments'][$attachID]); |
| 549 | 615 | } |
| 550 | 616 | } |
| 551 | - else |
|
| 552 | - $attach_errors->addError(array($error[0], $error[1])); |
|
| 617 | + else { |
|
| 618 | + $attach_errors->addError(array($error[0], $error[1])); |
|
| 619 | + } |
|
| 553 | 620 | } |
| 554 | 621 | } |
| 555 | 622 | } |
@@ -589,8 +656,9 @@ discard block |
||
| 589 | 656 | return true; |
| 590 | 657 | } |
| 591 | 658 | // Nope can't delete it if we can't find it |
| 592 | - else |
|
| 593 | - return 'attachment_not_found'; |
|
| 659 | + else { |
|
| 660 | + return 'attachment_not_found'; |
|
| 661 | + } |
|
| 594 | 662 | } |
| 595 | 663 | } |
| 596 | 664 | |
@@ -642,18 +710,25 @@ discard block |
||
| 642 | 710 | |
| 643 | 711 | // Permissions: only temporary attachments |
| 644 | 712 | if (substr($id_attach, 0, 8) !== 'post_tmp') |
| 645 | - throw new \Exception('no_access'); |
|
| 713 | + { |
|
| 714 | + throw new \Exception('no_access'); |
|
| 715 | + } |
|
| 646 | 716 | |
| 647 | 717 | // Permissions: only author is allowed. |
| 648 | 718 | $pieces = explode('_', substr($id_attach, 9)); |
| 649 | 719 | |
| 650 | 720 | if (!isset($pieces[0]) || $pieces[0] != $user_info['id']) |
| 651 | - throw new \Exception('no_access'); |
|
| 721 | + { |
|
| 722 | + throw new \Exception('no_access'); |
|
| 723 | + } |
|
| 652 | 724 | |
| 653 | 725 | if (is_array($modSettings['attachmentUploadDir'])) |
| 654 | - $dirs = $modSettings['attachmentUploadDir']; |
|
| 655 | - else |
|
| 656 | - $dirs = unserialize($modSettings['attachmentUploadDir']); |
|
| 726 | + { |
|
| 727 | + $dirs = $modSettings['attachmentUploadDir']; |
|
| 728 | + } |
|
| 729 | + else { |
|
| 730 | + $dirs = unserialize($modSettings['attachmentUploadDir']); |
|
| 731 | + } |
|
| 657 | 732 | |
| 658 | 733 | $attach_dir = $dirs[$modSettings['currentAttachmentUploadDir']]; |
| 659 | 734 | |
@@ -687,21 +762,30 @@ discard block |
||
| 687 | 762 | { |
| 688 | 763 | // The file exceeds the max_filesize directive in php.ini |
| 689 | 764 | if ($_FILES['attachment']['error'][$attachID] == 1) |
| 690 | - $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
| 765 | + { |
|
| 766 | + $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
| 767 | + } |
|
| 691 | 768 | // The uploaded file exceeds the MAX_FILE_SIZE directive in the HTML form. |
| 692 | 769 | elseif ($_FILES['attachment']['error'][$attachID] == 2) |
| 693 | - $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
| 770 | + { |
|
| 771 | + $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
| 772 | + } |
|
| 694 | 773 | // Missing or a full a temp directory on the server |
| 695 | 774 | elseif ($_FILES['attachment']['error'][$attachID] == 6) |
| 696 | - Errors::instance()->log_error($_FILES['attachment']['name'][$attachID] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
| 775 | + { |
|
| 776 | + Errors::instance()->log_error($_FILES['attachment']['name'][$attachID] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
| 777 | + } |
|
| 697 | 778 | // One of many errors such as (3)partially uploaded, (4)empty file, |
| 698 | - else |
|
| 699 | - Errors::instance()->log_error($_FILES['attachment']['name'][$attachID] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$attachID]]); |
|
| 779 | + else { |
|
| 780 | + Errors::instance()->log_error($_FILES['attachment']['name'][$attachID] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$attachID]]); |
|
| 781 | + } |
|
| 700 | 782 | |
| 701 | 783 | // If we did not set an user error (3,4,6,7,8) to show then give them a generic one as there is |
| 702 | 784 | // no need to provide back specifics of a server error, those are logged |
| 703 | 785 | if (empty($errors)) |
| 704 | - $errors[] = 'attach_php_error'; |
|
| 786 | + { |
|
| 787 | + $errors[] = 'attach_php_error'; |
|
| 788 | + } |
|
| 705 | 789 | } |
| 706 | 790 | |
| 707 | 791 | return $errors; |
@@ -731,17 +815,27 @@ discard block |
||
| 731 | 815 | |
| 732 | 816 | // No data or missing data .... Not necessarily needed, but in case a mod author missed something. |
| 733 | 817 | if (empty($_SESSION['temp_attachments'][$attachID])) |
| 734 | - $error = '$_SESSION[\'temp_attachments\'][$attachID]'; |
|
| 818 | + { |
|
| 819 | + $error = '$_SESSION[\'temp_attachments\'][$attachID]'; |
|
| 820 | + } |
|
| 735 | 821 | elseif (empty($attachID)) |
| 736 | - $error = '$attachID'; |
|
| 822 | + { |
|
| 823 | + $error = '$attachID'; |
|
| 824 | + } |
|
| 737 | 825 | elseif (empty($context['attachments'])) |
| 738 | - $error = '$context[\'attachments\']'; |
|
| 826 | + { |
|
| 827 | + $error = '$context[\'attachments\']'; |
|
| 828 | + } |
|
| 739 | 829 | elseif (empty($context['attach_dir'])) |
| 740 | - $error = '$context[\'attach_dir\']'; |
|
| 830 | + { |
|
| 831 | + $error = '$context[\'attach_dir\']'; |
|
| 832 | + } |
|
| 741 | 833 | |
| 742 | 834 | // Let's get their attention. |
| 743 | 835 | if (!empty($error)) |
| 744 | - throw new Elk_Exception('attach_check_nag', 'debug', array($error)); |
|
| 836 | + { |
|
| 837 | + throw new Elk_Exception('attach_check_nag', 'debug', array($error)); |
|
| 838 | + } |
|
| 745 | 839 | |
| 746 | 840 | // Just in case this slipped by the first checks, we stop it here and now |
| 747 | 841 | if ($_SESSION['temp_attachments'][$attachID]['size'] == 0) |
@@ -859,41 +953,55 @@ discard block |
||
| 859 | 953 | else |
| 860 | 954 | { |
| 861 | 955 | if (isset($context['dir_creation_error'])) |
| 862 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error']; |
|
| 863 | - else |
|
| 864 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
| 956 | + { |
|
| 957 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error']; |
|
| 958 | + } |
|
| 959 | + else { |
|
| 960 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
| 961 | + } |
|
| 865 | 962 | } |
| 866 | 963 | } |
| 867 | - else |
|
| 868 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
| 964 | + else { |
|
| 965 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
| 966 | + } |
|
| 869 | 967 | } |
| 870 | 968 | } |
| 871 | 969 | |
| 872 | 970 | // Is the file too big? |
| 873 | 971 | if (!empty($modSettings['attachmentSizeLimit']) && $_SESSION['temp_attachments'][$attachID]['size'] > $modSettings['attachmentSizeLimit'] * 1024) |
| 874 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0))); |
|
| 972 | + { |
|
| 973 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0))); |
|
| 974 | + } |
|
| 875 | 975 | |
| 876 | 976 | // Check the total upload size for this post... |
| 877 | 977 | $context['attachments']['total_size'] += $_SESSION['temp_attachments'][$attachID]['size']; |
| 878 | 978 | if (!empty($modSettings['attachmentPostLimit']) && $context['attachments']['total_size'] > $modSettings['attachmentPostLimit'] * 1024) |
| 879 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0))); |
|
| 979 | + { |
|
| 980 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0))); |
|
| 981 | + } |
|
| 880 | 982 | |
| 881 | 983 | // Have we reached the maximum number of files we are allowed? |
| 882 | 984 | $context['attachments']['quantity']++; |
| 883 | 985 | |
| 884 | 986 | // Set a max limit if none exists |
| 885 | 987 | if (empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] >= 50) |
| 886 | - $modSettings['attachmentNumPerPostLimit'] = 50; |
|
| 988 | + { |
|
| 989 | + $modSettings['attachmentNumPerPostLimit'] = 50; |
|
| 990 | + } |
|
| 887 | 991 | |
| 888 | 992 | if (!empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] > $modSettings['attachmentNumPerPostLimit']) |
| 889 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit'])); |
|
| 993 | + { |
|
| 994 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit'])); |
|
| 995 | + } |
|
| 890 | 996 | |
| 891 | 997 | // File extension check |
| 892 | 998 | if (!empty($modSettings['attachmentCheckExtensions'])) |
| 893 | 999 | { |
| 894 | 1000 | $allowed = explode(',', strtolower($modSettings['attachmentExtensions'])); |
| 895 | 1001 | foreach ($allowed as $k => $dummy) |
| 896 | - $allowed[$k] = trim($dummy); |
|
| 1002 | + { |
|
| 1003 | + $allowed[$k] = trim($dummy); |
|
| 1004 | + } |
|
| 897 | 1005 | |
| 898 | 1006 | if (!in_array(strtolower(substr(strrchr($_SESSION['temp_attachments'][$attachID]['name'], '.'), 1)), $allowed)) |
| 899 | 1007 | { |
@@ -906,9 +1014,13 @@ discard block |
||
| 906 | 1014 | if (!empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
| 907 | 1015 | { |
| 908 | 1016 | if (isset($context['dir_size'])) |
| 909 | - $context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size']; |
|
| 1017 | + { |
|
| 1018 | + $context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size']; |
|
| 1019 | + } |
|
| 910 | 1020 | if (isset($context['dir_files'])) |
| 911 | - $context['dir_files']--; |
|
| 1021 | + { |
|
| 1022 | + $context['dir_files']--; |
|
| 1023 | + } |
|
| 912 | 1024 | |
| 913 | 1025 | $context['attachments']['total_size'] -= $_SESSION['temp_attachments'][$attachID]['size']; |
| 914 | 1026 | $context['attachments']['quantity']--; |
@@ -970,14 +1082,18 @@ discard block |
||
| 970 | 1082 | |
| 971 | 1083 | // Get the hash if no hash has been given yet. |
| 972 | 1084 | if (empty($attachmentOptions['file_hash'])) |
| 973 | - $attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], 0, null, true); |
|
| 1085 | + { |
|
| 1086 | + $attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], 0, null, true); |
|
| 1087 | + } |
|
| 974 | 1088 | |
| 975 | 1089 | // Assuming no-one set the extension let's take a look at it. |
| 976 | 1090 | if (empty($attachmentOptions['fileext'])) |
| 977 | 1091 | { |
| 978 | 1092 | $attachmentOptions['fileext'] = strtolower(strrpos($attachmentOptions['name'], '.') !== false ? substr($attachmentOptions['name'], strrpos($attachmentOptions['name'], '.') + 1) : ''); |
| 979 | 1093 | if (strlen($attachmentOptions['fileext']) > 8 || '.' . $attachmentOptions['fileext'] == $attachmentOptions['name']) |
| 980 | - $attachmentOptions['fileext'] = ''; |
|
| 1094 | + { |
|
| 1095 | + $attachmentOptions['fileext'] = ''; |
|
| 1096 | + } |
|
| 981 | 1097 | } |
| 982 | 1098 | |
| 983 | 1099 | $db->insert('', |
@@ -998,7 +1114,9 @@ discard block |
||
| 998 | 1114 | |
| 999 | 1115 | // @todo Add an error here maybe? |
| 1000 | 1116 | if (empty($attachmentOptions['id'])) |
| 1001 | - return false; |
|
| 1117 | + { |
|
| 1118 | + return false; |
|
| 1119 | + } |
|
| 1002 | 1120 | |
| 1003 | 1121 | // Now that we have the attach id, let's rename this and finish up. |
| 1004 | 1122 | $attachmentOptions['destination'] = getAttachmentFilename(basename($attachmentOptions['name']), $attachmentOptions['id'], $attachmentOptions['id_folder'], false, $attachmentOptions['file_hash']); |
@@ -1006,7 +1124,8 @@ discard block |
||
| 1006 | 1124 | |
| 1007 | 1125 | // If it's not approved then add to the approval queue. |
| 1008 | 1126 | if (!$attachmentOptions['approved']) |
| 1009 | - $db->insert('', |
|
| 1127 | + { |
|
| 1128 | + $db->insert('', |
|
| 1010 | 1129 | '{db_prefix}approval_queue', |
| 1011 | 1130 | array( |
| 1012 | 1131 | 'id_attach' => 'int', 'id_msg' => 'int', |
@@ -1016,9 +1135,12 @@ discard block |
||
| 1016 | 1135 | ), |
| 1017 | 1136 | array() |
| 1018 | 1137 | ); |
| 1138 | + } |
|
| 1019 | 1139 | |
| 1020 | 1140 | if (empty($modSettings['attachmentThumbnails']) || (empty($attachmentOptions['width']) && empty($attachmentOptions['height']))) |
| 1021 | - return true; |
|
| 1141 | + { |
|
| 1142 | + return true; |
|
| 1143 | + } |
|
| 1022 | 1144 | |
| 1023 | 1145 | // Like thumbnails, do we? |
| 1024 | 1146 | if (!empty($modSettings['attachmentThumbWidth']) && !empty($modSettings['attachmentThumbHeight']) && ($attachmentOptions['width'] > $modSettings['attachmentThumbWidth'] || $attachmentOptions['height'] > $modSettings['attachmentThumbHeight'])) |
@@ -1123,7 +1245,9 @@ discard block |
||
| 1123 | 1245 | // Use our cache when possible |
| 1124 | 1246 | $cache = array(); |
| 1125 | 1247 | if (Cache::instance()->getVar($cache, 'getAvatar_id-' . $id_attach)) |
| 1126 | - $avatarData = $cache; |
|
| 1248 | + { |
|
| 1249 | + $avatarData = $cache; |
|
| 1250 | + } |
|
| 1127 | 1251 | else |
| 1128 | 1252 | { |
| 1129 | 1253 | $request = $db->query('', ' |
@@ -1139,7 +1263,9 @@ discard block |
||
| 1139 | 1263 | ); |
| 1140 | 1264 | $avatarData = array(); |
| 1141 | 1265 | if ($db->num_rows($request) != 0) |
| 1142 | - $avatarData = $db->fetch_row($request); |
|
| 1266 | + { |
|
| 1267 | + $avatarData = $db->fetch_row($request); |
|
| 1268 | + } |
|
| 1143 | 1269 | $db->free_result($request); |
| 1144 | 1270 | |
| 1145 | 1271 | Cache::instance()->put('getAvatar_id-' . $id_attach, $avatarData, 900); |
@@ -1365,7 +1491,9 @@ discard block |
||
| 1365 | 1491 | |
| 1366 | 1492 | // Just making sure there is a non-zero member. |
| 1367 | 1493 | if (empty($memID)) |
| 1368 | - return false; |
|
| 1494 | + { |
|
| 1495 | + return false; |
|
| 1496 | + } |
|
| 1369 | 1497 | |
| 1370 | 1498 | require_once(SUBSDIR . '/Graphics.subs.php'); |
| 1371 | 1499 | require_once(SUBSDIR . '/ManageAttachments.subs.php'); |
@@ -1441,8 +1569,9 @@ discard block |
||
| 1441 | 1569 | ); |
| 1442 | 1570 | return true; |
| 1443 | 1571 | } |
| 1444 | - else |
|
| 1445 | - return false; |
|
| 1572 | + else { |
|
| 1573 | + return false; |
|
| 1574 | + } |
|
| 1446 | 1575 | } |
| 1447 | 1576 | else |
| 1448 | 1577 | { |
@@ -1481,7 +1610,9 @@ discard block |
||
| 1481 | 1610 | // Can we pull this from the cache... please please? |
| 1482 | 1611 | $temp = array(); |
| 1483 | 1612 | if (Cache::instance()->getVar($temp, 'url_image_size-' . md5($url), 240)) |
| 1484 | - return $temp; |
|
| 1613 | + { |
|
| 1614 | + return $temp; |
|
| 1615 | + } |
|
| 1485 | 1616 | |
| 1486 | 1617 | $t = microtime(true); |
| 1487 | 1618 | |
@@ -1490,9 +1621,13 @@ discard block |
||
| 1490 | 1621 | |
| 1491 | 1622 | // Can't figure it out, just try the image size. |
| 1492 | 1623 | if ($url == '' || $url == 'http://' || $url == 'https://') |
| 1493 | - return false; |
|
| 1624 | + { |
|
| 1625 | + return false; |
|
| 1626 | + } |
|
| 1494 | 1627 | elseif (!isset($match[1])) |
| 1495 | - $size = elk_getimagesize($url, false); |
|
| 1628 | + { |
|
| 1629 | + $size = elk_getimagesize($url, false); |
|
| 1630 | + } |
|
| 1496 | 1631 | else |
| 1497 | 1632 | { |
| 1498 | 1633 | // Try to connect to the server... give it half a second. |
@@ -1533,11 +1668,15 @@ discard block |
||
| 1533 | 1668 | |
| 1534 | 1669 | // If we didn't get it, we failed. |
| 1535 | 1670 | if (!isset($size)) |
| 1536 | - $size = false; |
|
| 1671 | + { |
|
| 1672 | + $size = false; |
|
| 1673 | + } |
|
| 1537 | 1674 | |
| 1538 | 1675 | // If this took a long time, we may never have to do it again, but then again we might... |
| 1539 | 1676 | if (microtime(true) - $t > 0.8) |
| 1540 | - Cache::instance()->put('url_image_size-' . md5($url), $size, 240); |
|
| 1677 | + { |
|
| 1678 | + Cache::instance()->put('url_image_size-' . md5($url), $size, 240); |
|
| 1679 | + } |
|
| 1541 | 1680 | |
| 1542 | 1681 | // Didn't work. |
| 1543 | 1682 | return $size; |
@@ -1561,7 +1700,9 @@ discard block |
||
| 1561 | 1700 | |
| 1562 | 1701 | // Make sure this thing exists and it is unserialized |
| 1563 | 1702 | if (empty($modSettings['attachmentUploadDir'])) |
| 1564 | - $attachmentDir = BOARDDIR . '/attachments'; |
|
| 1703 | + { |
|
| 1704 | + $attachmentDir = BOARDDIR . '/attachments'; |
|
| 1705 | + } |
|
| 1565 | 1706 | elseif (!empty($modSettings['currentAttachmentUploadDir']) && !is_array($modSettings['attachmentUploadDir']) && (@unserialize($modSettings['attachmentUploadDir']) !== false)) |
| 1566 | 1707 | { |
| 1567 | 1708 | // @todo this is here to prevent the package manager to die when complete the installation of the patch (the new Util class has not yet been loaded so we need the normal one) |
@@ -1574,8 +1715,9 @@ discard block |
||
| 1574 | 1715 | $attachmentDir = unserialize($modSettings['attachmentUploadDir']); |
| 1575 | 1716 | } |
| 1576 | 1717 | } |
| 1577 | - else |
|
| 1578 | - $attachmentDir = $modSettings['attachmentUploadDir']; |
|
| 1718 | + else { |
|
| 1719 | + $attachmentDir = $modSettings['attachmentUploadDir']; |
|
| 1720 | + } |
|
| 1579 | 1721 | |
| 1580 | 1722 | return is_array($attachmentDir) ? $attachmentDir[$modSettings['currentAttachmentUploadDir']] : $attachmentDir; |
| 1581 | 1723 | } |
@@ -1628,10 +1770,13 @@ discard block |
||
| 1628 | 1770 | |
| 1629 | 1771 | // Little utility function for the endless $id_folder computation for avatars. |
| 1630 | 1772 | if (!empty($modSettings['custom_avatar_enabled'])) |
| 1631 | - return 1; |
|
| 1632 | - else |
|
| 1633 | - return getAttachmentPathID(); |
|
| 1634 | -} |
|
| 1773 | + { |
|
| 1774 | + return 1; |
|
| 1775 | + } |
|
| 1776 | + else { |
|
| 1777 | + return getAttachmentPathID(); |
|
| 1778 | + } |
|
| 1779 | + } |
|
| 1635 | 1780 | |
| 1636 | 1781 | /** |
| 1637 | 1782 | * Get all attachments associated with a set of posts. |
@@ -1670,12 +1815,16 @@ discard block |
||
| 1670 | 1815 | while ($row = $db->fetch_assoc($request)) |
| 1671 | 1816 | { |
| 1672 | 1817 | if (!$row['approved'] && !$includeUnapproved && (empty($filter) || !call_user_func($filter, $row, $all_posters))) |
| 1673 | - continue; |
|
| 1818 | + { |
|
| 1819 | + continue; |
|
| 1820 | + } |
|
| 1674 | 1821 | |
| 1675 | 1822 | $temp[$row['id_attach']] = $row; |
| 1676 | 1823 | |
| 1677 | 1824 | if (!isset($attachments[$row['id_msg']])) |
| 1678 | - $attachments[$row['id_msg']] = array(); |
|
| 1825 | + { |
|
| 1826 | + $attachments[$row['id_msg']] = array(); |
|
| 1827 | + } |
|
| 1679 | 1828 | } |
| 1680 | 1829 | $db->free_result($request); |
| 1681 | 1830 | |
@@ -1683,7 +1832,9 @@ discard block |
||
| 1683 | 1832 | ksort($temp); |
| 1684 | 1833 | |
| 1685 | 1834 | foreach ($temp as $row) |
| 1686 | - $attachments[$row['id_msg']][] = $row; |
|
| 1835 | + { |
|
| 1836 | + $attachments[$row['id_msg']][] = $row; |
|
| 1837 | + } |
|
| 1687 | 1838 | |
| 1688 | 1839 | return $attachments; |
| 1689 | 1840 | } |
@@ -1732,17 +1883,24 @@ discard block |
||
| 1732 | 1883 | $files = array(); |
| 1733 | 1884 | |
| 1734 | 1885 | if (!$dir) |
| 1735 | - return array(); |
|
| 1886 | + { |
|
| 1887 | + return array(); |
|
| 1888 | + } |
|
| 1736 | 1889 | |
| 1737 | 1890 | while ($line = $dir->read()) |
| 1738 | 1891 | { |
| 1739 | 1892 | if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) |
| 1740 | - continue; |
|
| 1893 | + { |
|
| 1894 | + continue; |
|
| 1895 | + } |
|
| 1741 | 1896 | |
| 1742 | 1897 | if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) |
| 1743 | - $dirs[] = $line; |
|
| 1744 | - else |
|
| 1745 | - $files[] = $line; |
|
| 1898 | + { |
|
| 1899 | + $dirs[] = $line; |
|
| 1900 | + } |
|
| 1901 | + else { |
|
| 1902 | + $files[] = $line; |
|
| 1903 | + } |
|
| 1746 | 1904 | } |
| 1747 | 1905 | $dir->close(); |
| 1748 | 1906 | |
@@ -1764,13 +1922,15 @@ discard block |
||
| 1764 | 1922 | { |
| 1765 | 1923 | $tmp = getServerStoredAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1); |
| 1766 | 1924 | if (!empty($tmp)) |
| 1767 | - $result[] = array( |
|
| 1925 | + { |
|
| 1926 | + $result[] = array( |
|
| 1768 | 1927 | 'filename' => htmlspecialchars($line, ENT_COMPAT, 'UTF-8'), |
| 1769 | 1928 | 'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false, |
| 1770 | 1929 | 'name' => '[' . htmlspecialchars(str_replace('_', ' ', $line), ENT_COMPAT, 'UTF-8') . ']', |
| 1771 | 1930 | 'is_dir' => true, |
| 1772 | 1931 | 'files' => $tmp |
| 1773 | 1932 | ); |
| 1933 | + } |
|
| 1774 | 1934 | unset($tmp); |
| 1775 | 1935 | } |
| 1776 | 1936 | |
@@ -1781,7 +1941,9 @@ discard block |
||
| 1781 | 1941 | |
| 1782 | 1942 | // Make sure it is an image. |
| 1783 | 1943 | if (getValidMimeImageType($extension) === '') |
| 1784 | - continue; |
|
| 1944 | + { |
|
| 1945 | + continue; |
|
| 1946 | + } |
|
| 1785 | 1947 | |
| 1786 | 1948 | $result[] = array( |
| 1787 | 1949 | 'filename' => htmlspecialchars($line, ENT_COMPAT, 'UTF-8'), |
@@ -1790,7 +1952,9 @@ discard block |
||
| 1790 | 1952 | 'is_dir' => false |
| 1791 | 1953 | ); |
| 1792 | 1954 | if ($level == 1) |
| 1793 | - $context['avatar_list'][] = $directory . '/' . $line; |
|
| 1955 | + { |
|
| 1956 | + $context['avatar_list'][] = $directory . '/' . $line; |
|
| 1957 | + } |
|
| 1794 | 1958 | } |
| 1795 | 1959 | |
| 1796 | 1960 | return $result; |
@@ -1960,10 +2124,14 @@ discard block |
||
| 1960 | 2124 | |
| 1961 | 2125 | // If something is unapproved we'll note it so we can sort them. |
| 1962 | 2126 | if (!$attachment['approved']) |
| 1963 | - $have_unapproved = true; |
|
| 2127 | + { |
|
| 2128 | + $have_unapproved = true; |
|
| 2129 | + } |
|
| 1964 | 2130 | |
| 1965 | 2131 | if (!$attachmentData[$i]['is_image']) |
| 1966 | - continue; |
|
| 2132 | + { |
|
| 2133 | + continue; |
|
| 2134 | + } |
|
| 1967 | 2135 | |
| 1968 | 2136 | $attachmentData[$i]['real_width'] = $attachment['width']; |
| 1969 | 2137 | $attachmentData[$i]['width'] = $attachment['width']; |
@@ -1977,9 +2145,11 @@ discard block |
||
| 1977 | 2145 | if (empty($attachment['id_thumb']) |
| 1978 | 2146 | || $attachment['thumb_width'] > $modSettings['attachmentThumbWidth'] |
| 1979 | 2147 | || $attachment['thumb_height'] > $modSettings['attachmentThumbHeight']) |
| 1980 | - //|| ($attachment['thumb_width'] < $modSettings['attachmentThumbWidth'] && $attachment['thumb_height'] < $modSettings['attachmentThumbHeight'])) |
|
| 2148 | + { |
|
| 2149 | + //|| ($attachment['thumb_width'] < $modSettings['attachmentThumbWidth'] && $attachment['thumb_height'] < $modSettings['attachmentThumbHeight'])) |
|
| 1981 | 2150 | { |
| 1982 | 2151 | $filename = getAttachmentFilename($attachment['filename'], $attachment['id_attach'], $attachment['id_folder'], false, $attachment['file_hash']); |
| 2152 | + } |
|
| 1983 | 2153 | $attachment = array_merge($attachment, updateAttachmentThumbnail($filename, $attachment['id_attach'], $id_msg, $attachment['id_thumb'], $attachment['filename'])); |
| 1984 | 2154 | } |
| 1985 | 2155 | |
@@ -2022,19 +2192,26 @@ discard block |
||
| 2022 | 2192 | // If the image is too large to show inline, make it a popup. |
| 2023 | 2193 | // @todo this needs to be removed or depreciated |
| 2024 | 2194 | if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height']))) |
| 2025 | - $attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);'; |
|
| 2026 | - else |
|
| 2027 | - $attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');'; |
|
| 2195 | + { |
|
| 2196 | + $attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);'; |
|
| 2197 | + } |
|
| 2198 | + else { |
|
| 2199 | + $attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');'; |
|
| 2200 | + } |
|
| 2028 | 2201 | } |
| 2029 | 2202 | |
| 2030 | 2203 | if (!$attachmentData[$i]['thumbnail']['has_thumb']) |
| 2031 | - $attachmentData[$i]['downloads']++; |
|
| 2204 | + { |
|
| 2205 | + $attachmentData[$i]['downloads']++; |
|
| 2206 | + } |
|
| 2032 | 2207 | } |
| 2033 | 2208 | } |
| 2034 | 2209 | |
| 2035 | 2210 | // Do we need to instigate a sort? |
| 2036 | 2211 | if ($have_unapproved) |
| 2037 | - usort($attachmentData, 'approved_attach_sort'); |
|
| 2212 | + { |
|
| 2213 | + usort($attachmentData, 'approved_attach_sort'); |
|
| 2214 | + } |
|
| 2038 | 2215 | |
| 2039 | 2216 | return $attachmentData; |
| 2040 | 2217 | } |
@@ -2050,7 +2227,9 @@ discard block |
||
| 2050 | 2227 | function approved_attach_sort($a, $b) |
| 2051 | 2228 | { |
| 2052 | 2229 | if ($a['is_approved'] == $b['is_approved']) |
| 2053 | - return 0; |
|
| 2230 | + { |
|
| 2231 | + return 0; |
|
| 2232 | + } |
|
| 2054 | 2233 | |
| 2055 | 2234 | return $a['is_approved'] > $b['is_approved'] ? -1 : 1; |
| 2056 | 2235 | } |
@@ -2096,24 +2275,34 @@ discard block |
||
| 2096 | 2275 | $clean_name = preg_replace('~\.[\.]+~', '.', $clean_name); |
| 2097 | 2276 | |
| 2098 | 2277 | if (empty($attachment_id) || ($new && empty($modSettings['attachmentEncryptFilenames']))) |
| 2099 | - return $clean_name; |
|
| 2278 | + { |
|
| 2279 | + return $clean_name; |
|
| 2280 | + } |
|
| 2100 | 2281 | elseif ($new) |
| 2101 | - return $enc_name; |
|
| 2282 | + { |
|
| 2283 | + return $enc_name; |
|
| 2284 | + } |
|
| 2102 | 2285 | |
| 2103 | 2286 | // Are we using multiple directories? |
| 2104 | 2287 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
| 2105 | 2288 | { |
| 2106 | 2289 | if (!is_array($modSettings['attachmentUploadDir'])) |
| 2107 | - $modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']); |
|
| 2290 | + { |
|
| 2291 | + $modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']); |
|
| 2292 | + } |
|
| 2108 | 2293 | $path = $modSettings['attachmentUploadDir'][$dir]; |
| 2109 | 2294 | } |
| 2110 | - else |
|
| 2111 | - $path = $modSettings['attachmentUploadDir']; |
|
| 2295 | + else { |
|
| 2296 | + $path = $modSettings['attachmentUploadDir']; |
|
| 2297 | + } |
|
| 2112 | 2298 | |
| 2113 | 2299 | if (file_exists($path . '/' . $enc_name)) |
| 2114 | - $filename = $path . '/' . $enc_name; |
|
| 2115 | - else |
|
| 2116 | - $filename = $path . '/' . $clean_name; |
|
| 2300 | + { |
|
| 2301 | + $filename = $path . '/' . $enc_name; |
|
| 2302 | + } |
|
| 2303 | + else { |
|
| 2304 | + $filename = $path . '/' . $clean_name; |
|
| 2305 | + } |
|
| 2117 | 2306 | |
| 2118 | 2307 | return $filename; |
| 2119 | 2308 | } |
@@ -2164,7 +2353,9 @@ discard block |
||
| 2164 | 2353 | |
| 2165 | 2354 | // Just make up a nice hash... |
| 2166 | 2355 | if ($new) |
| 2167 | - return hash('sha1', hash('md5', $filename . time()) . mt_rand()); |
|
| 2356 | + { |
|
| 2357 | + return hash('sha1', hash('md5', $filename . time()) . mt_rand()); |
|
| 2358 | + } |
|
| 2168 | 2359 | |
| 2169 | 2360 | // In case of files from the old system, do a legacy call. |
| 2170 | 2361 | if (empty($file_hash)) |
@@ -2176,11 +2367,14 @@ discard block |
||
| 2176 | 2367 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
| 2177 | 2368 | { |
| 2178 | 2369 | if (!is_array($modSettings['attachmentUploadDir'])) |
| 2179 | - $modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']); |
|
| 2370 | + { |
|
| 2371 | + $modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']); |
|
| 2372 | + } |
|
| 2180 | 2373 | $path = isset($modSettings['attachmentUploadDir'][$dir]) ? $modSettings['attachmentUploadDir'][$dir] : $modSettings['basedirectory_for_attachments']; |
| 2181 | 2374 | } |
| 2182 | - else |
|
| 2183 | - $path = $modSettings['attachmentUploadDir']; |
|
| 2375 | + else { |
|
| 2376 | + $path = $modSettings['attachmentUploadDir']; |
|
| 2377 | + } |
|
| 2184 | 2378 | |
| 2185 | 2379 | return $path . '/' . $attachment_id . '_' . $file_hash . '.elk'; |
| 2186 | 2380 | } |
@@ -82,7 +82,9 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | // We need to know if the topic is approved. If we're told that's great - if not find out. |
| 84 | 84 | if (!$modSettings['postmod_active']) |
| 85 | - $topicOptions['is_approved'] = true; |
|
| 85 | + { |
|
| 86 | + $topicOptions['is_approved'] = true; |
|
| 87 | + } |
|
| 86 | 88 | elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved'])) |
| 87 | 89 | { |
| 88 | 90 | require_once(SUBSDIR . '/Topic.subs.php'); |
@@ -175,7 +177,9 @@ discard block |
||
| 175 | 177 | |
| 176 | 178 | // Something went wrong creating the message... |
| 177 | 179 | if (empty($msgOptions['id'])) |
| 178 | - return false; |
|
| 180 | + { |
|
| 181 | + return false; |
|
| 182 | + } |
|
| 179 | 183 | |
| 180 | 184 | // What if we want to export new posts out to a CMS? |
| 181 | 185 | call_integration_hook('integrate_create_post', array($msgOptions, $topicOptions, $posterOptions, $message_columns, $message_parameters)); |
@@ -269,21 +273,28 @@ discard block |
||
| 269 | 273 | ); |
| 270 | 274 | |
| 271 | 275 | if ($msgOptions['approved']) |
| 272 | - $topics_columns = array( |
|
| 276 | + { |
|
| 277 | + $topics_columns = array( |
|
| 273 | 278 | 'id_member_updated = {int:poster_id}', |
| 274 | 279 | 'id_last_msg = {int:id_msg}', |
| 275 | 280 | 'num_replies = num_replies + {int:counter_increment}', |
| 276 | 281 | ); |
| 277 | - else |
|
| 278 | - $topics_columns = array( |
|
| 282 | + } |
|
| 283 | + else { |
|
| 284 | + $topics_columns = array( |
|
| 279 | 285 | 'unapproved_posts = unapproved_posts + {int:counter_increment}', |
| 280 | 286 | ); |
| 287 | + } |
|
| 281 | 288 | |
| 282 | 289 | if ($topicOptions['lock_mode'] !== null) |
| 283 | - $topics_columns[] = 'locked = {int:locked}'; |
|
| 290 | + { |
|
| 291 | + $topics_columns[] = 'locked = {int:locked}'; |
|
| 292 | + } |
|
| 284 | 293 | |
| 285 | 294 | if ($topicOptions['sticky_mode'] !== null) |
| 286 | - $topics_columns[] = 'is_sticky = {int:is_sticky}'; |
|
| 295 | + { |
|
| 296 | + $topics_columns[] = 'is_sticky = {int:is_sticky}'; |
|
| 297 | + } |
|
| 287 | 298 | |
| 288 | 299 | call_integration_hook('integrate_before_modify_topic', array(&$topics_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions)); |
| 289 | 300 | |
@@ -314,7 +325,8 @@ discard block |
||
| 314 | 325 | |
| 315 | 326 | // Increase the number of posts and topics on the board. |
| 316 | 327 | if ($msgOptions['approved']) |
| 317 | - $db->query('', ' |
|
| 328 | + { |
|
| 329 | + $db->query('', ' |
|
| 318 | 330 | UPDATE {db_prefix}boards |
| 319 | 331 | SET num_posts = num_posts + 1' . ($new_topic ? ', num_topics = num_topics + 1' : '') . ' |
| 320 | 332 | WHERE id_board = {int:id_board}', |
@@ -322,6 +334,7 @@ discard block |
||
| 322 | 334 | 'id_board' => $topicOptions['board'], |
| 323 | 335 | ) |
| 324 | 336 | ); |
| 337 | + } |
|
| 325 | 338 | else |
| 326 | 339 | { |
| 327 | 340 | $db->query('', ' |
@@ -378,14 +391,18 @@ discard block |
||
| 378 | 391 | $search = new \ElkArte\Search\Search; |
| 379 | 392 | $searchAPI = $search->findSearchAPI(); |
| 380 | 393 | if (is_callable(array($searchAPI, 'postCreated'))) |
| 381 | - $searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions); |
|
| 394 | + { |
|
| 395 | + $searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions); |
|
| 396 | + } |
|
| 382 | 397 | |
| 383 | 398 | // Increase the post counter for the user that created the post. |
| 384 | 399 | if (!empty($posterOptions['update_post_count']) && !empty($posterOptions['id']) && $msgOptions['approved']) |
| 385 | 400 | { |
| 386 | 401 | // Are you the one that happened to create this post? |
| 387 | 402 | if ($user_info['id'] == $posterOptions['id']) |
| 388 | - $user_info['posts']++; |
|
| 403 | + { |
|
| 404 | + $user_info['posts']++; |
|
| 405 | + } |
|
| 389 | 406 | |
| 390 | 407 | require_once(SUBSDIR . '/Members.subs.php'); |
| 391 | 408 | updateMemberData($posterOptions['id'], array('posts' => '+')); |
@@ -396,7 +413,9 @@ discard block |
||
| 396 | 413 | |
| 397 | 414 | // Better safe than sorry. |
| 398 | 415 | if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) |
| 399 | - $_SESSION['topicseen_cache'][$topicOptions['board']]--; |
|
| 416 | + { |
|
| 417 | + $_SESSION['topicseen_cache'][$topicOptions['board']]--; |
|
| 418 | + } |
|
| 400 | 419 | |
| 401 | 420 | // Update all the stats so everyone knows about this new topic and message. |
| 402 | 421 | require_once(SUBSDIR . '/Messages.subs.php'); |
@@ -404,7 +423,9 @@ discard block |
||
| 404 | 423 | |
| 405 | 424 | // Update the last message on the board assuming it's approved AND the topic is. |
| 406 | 425 | if ($msgOptions['approved']) |
| 407 | - updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0); |
|
| 426 | + { |
|
| 427 | + updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0); |
|
| 428 | + } |
|
| 408 | 429 | |
| 409 | 430 | // Alright, done now... we can abort now, I guess... at least this much is done. |
| 410 | 431 | ignore_user_abort($previous_ignore_user_abort); |
@@ -435,13 +456,21 @@ discard block |
||
| 435 | 456 | // This is longer than it has to be, but makes it so we only set/change what we have to. |
| 436 | 457 | $messages_columns = array(); |
| 437 | 458 | if (isset($posterOptions['name'])) |
| 438 | - $messages_columns['poster_name'] = $posterOptions['name']; |
|
| 459 | + { |
|
| 460 | + $messages_columns['poster_name'] = $posterOptions['name']; |
|
| 461 | + } |
|
| 439 | 462 | if (isset($posterOptions['email'])) |
| 440 | - $messages_columns['poster_email'] = $posterOptions['email']; |
|
| 463 | + { |
|
| 464 | + $messages_columns['poster_email'] = $posterOptions['email']; |
|
| 465 | + } |
|
| 441 | 466 | if (isset($msgOptions['icon'])) |
| 442 | - $messages_columns['icon'] = $msgOptions['icon']; |
|
| 467 | + { |
|
| 468 | + $messages_columns['icon'] = $msgOptions['icon']; |
|
| 469 | + } |
|
| 443 | 470 | if (isset($msgOptions['subject'])) |
| 444 | - $messages_columns['subject'] = $msgOptions['subject']; |
|
| 471 | + { |
|
| 472 | + $messages_columns['subject'] = $msgOptions['subject']; |
|
| 473 | + } |
|
| 445 | 474 | if (isset($msgOptions['body'])) |
| 446 | 475 | { |
| 447 | 476 | $messages_columns['body'] = $msgOptions['body']; |
@@ -461,7 +490,9 @@ discard block |
||
| 461 | 490 | $messages_columns['id_msg_modified'] = $modSettings['maxMsgID']; |
| 462 | 491 | } |
| 463 | 492 | if (isset($msgOptions['smileys_enabled'])) |
| 464 | - $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1; |
|
| 493 | + { |
|
| 494 | + $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1; |
|
| 495 | + } |
|
| 465 | 496 | |
| 466 | 497 | // Which columns need to be ints? |
| 467 | 498 | $messageInts = array('modified_time', 'id_msg_modified', 'smileys_enabled'); |
@@ -479,7 +510,9 @@ discard block |
||
| 479 | 510 | |
| 480 | 511 | // Nothing to do? |
| 481 | 512 | if (empty($messages_columns)) |
| 482 | - return true; |
|
| 513 | + { |
|
| 514 | + return true; |
|
| 515 | + } |
|
| 483 | 516 | |
| 484 | 517 | // Change the post. |
| 485 | 518 | $db->query('', ' |
@@ -492,15 +525,23 @@ discard block |
||
| 492 | 525 | $attributes = array(); |
| 493 | 526 | // Lock and or sticky the post. |
| 494 | 527 | if ($topicOptions['sticky_mode'] !== null) |
| 495 | - $attributes['is_sticky'] = $topicOptions['sticky_mode']; |
|
| 528 | + { |
|
| 529 | + $attributes['is_sticky'] = $topicOptions['sticky_mode']; |
|
| 530 | + } |
|
| 496 | 531 | if ($topicOptions['lock_mode'] !== null) |
| 497 | - $attributes['locked'] = $topicOptions['lock_mode']; |
|
| 532 | + { |
|
| 533 | + $attributes['locked'] = $topicOptions['lock_mode']; |
|
| 534 | + } |
|
| 498 | 535 | if ($topicOptions['poll'] !== null) |
| 499 | - $attributes['id_poll'] = $topicOptions['poll']; |
|
| 536 | + { |
|
| 537 | + $attributes['id_poll'] = $topicOptions['poll']; |
|
| 538 | + } |
|
| 500 | 539 | |
| 501 | 540 | // If anything to do, do it. |
| 502 | 541 | if (!empty($attributes)) |
| 503 | - setTopicAttribute($topicOptions['id'], $attributes); |
|
| 542 | + { |
|
| 543 | + setTopicAttribute($topicOptions['id'], $attributes); |
|
| 544 | + } |
|
| 504 | 545 | |
| 505 | 546 | // Mark the edited post as read. |
| 506 | 547 | if (!empty($topicOptions['mark_as_read']) && !$user_info['is_guest']) |
@@ -531,7 +572,9 @@ discard block |
||
| 531 | 572 | $search = new \ElkArte\Search\Search; |
| 532 | 573 | $searchAPI = $search->findSearchAPI(); |
| 533 | 574 | if (is_callable(array($searchAPI, 'postModified'))) |
| 534 | - $searchAPI->postModified($msgOptions, $topicOptions, $posterOptions); |
|
| 575 | + { |
|
| 576 | + $searchAPI->postModified($msgOptions, $topicOptions, $posterOptions); |
|
| 577 | + } |
|
| 535 | 578 | |
| 536 | 579 | if (isset($msgOptions['subject'])) |
| 537 | 580 | { |
@@ -555,7 +598,9 @@ discard block |
||
| 555 | 598 | |
| 556 | 599 | // Finally, if we are setting the approved state we need to do much more work :( |
| 557 | 600 | if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) |
| 558 | - approvePosts($msgOptions['id'], $msgOptions['approved']); |
|
| 601 | + { |
|
| 602 | + approvePosts($msgOptions['id'], $msgOptions['approved']); |
|
| 603 | + } |
|
| 559 | 604 | |
| 560 | 605 | return true; |
| 561 | 606 | } |
@@ -575,10 +620,14 @@ discard block |
||
| 575 | 620 | $db = database(); |
| 576 | 621 | |
| 577 | 622 | if (!is_array($msgs)) |
| 578 | - $msgs = array($msgs); |
|
| 623 | + { |
|
| 624 | + $msgs = array($msgs); |
|
| 625 | + } |
|
| 579 | 626 | |
| 580 | 627 | if (empty($msgs)) |
| 581 | - return false; |
|
| 628 | + { |
|
| 629 | + return false; |
|
| 630 | + } |
|
| 582 | 631 | |
| 583 | 632 | // May as well start at the beginning, working out *what* we need to change. |
| 584 | 633 | $request = $db->query('', ' |
@@ -611,19 +660,23 @@ discard block |
||
| 611 | 660 | |
| 612 | 661 | // Ensure our change array exists already. |
| 613 | 662 | if (!isset($topic_changes[$row['id_topic']])) |
| 614 | - $topic_changes[$row['id_topic']] = array( |
|
| 663 | + { |
|
| 664 | + $topic_changes[$row['id_topic']] = array( |
|
| 615 | 665 | 'id_last_msg' => $row['id_last_msg'], |
| 616 | 666 | 'approved' => $row['topic_approved'], |
| 617 | 667 | 'replies' => 0, |
| 618 | 668 | 'unapproved_posts' => 0, |
| 619 | 669 | ); |
| 670 | + } |
|
| 620 | 671 | if (!isset($board_changes[$row['id_board']])) |
| 621 | - $board_changes[$row['id_board']] = array( |
|
| 672 | + { |
|
| 673 | + $board_changes[$row['id_board']] = array( |
|
| 622 | 674 | 'posts' => 0, |
| 623 | 675 | 'topics' => 0, |
| 624 | 676 | 'unapproved_posts' => 0, |
| 625 | 677 | 'unapproved_topics' => 0, |
| 626 | 678 | ); |
| 679 | + } |
|
| 627 | 680 | |
| 628 | 681 | // If it's the first message then the topic state changes! |
| 629 | 682 | if ($row['id_msg'] == $row['id_first_msg']) |
@@ -651,7 +704,8 @@ discard block |
||
| 651 | 704 | |
| 652 | 705 | // This will be a post... but don't notify unless it's not followed by approved ones. |
| 653 | 706 | if ($row['id_msg'] > $row['id_last_msg']) |
| 654 | - $notification_posts[$row['id_topic']][] = array( |
|
| 707 | + { |
|
| 708 | + $notification_posts[$row['id_topic']][] = array( |
|
| 655 | 709 | 'id' => $row['id_msg'], |
| 656 | 710 | 'body' => $row['body'], |
| 657 | 711 | 'subject' => $row['subject'], |
@@ -659,15 +713,20 @@ discard block |
||
| 659 | 713 | 'topic' => $row['id_topic'], |
| 660 | 714 | 'signature' => $row['signature'], |
| 661 | 715 | ); |
| 716 | + } |
|
| 662 | 717 | } |
| 663 | 718 | |
| 664 | 719 | // If this is being approved and id_msg is higher than the current id_last_msg then it changes. |
| 665 | 720 | if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) |
| 666 | - $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg']; |
|
| 721 | + { |
|
| 722 | + $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg']; |
|
| 723 | + } |
|
| 667 | 724 | // If this is being unapproved, and it's equal to the id_last_msg we need to find a new one! |
| 668 | 725 | elseif (!$approve) |
| 669 | - // Default to the first message and then we'll override in a bit ;) |
|
| 726 | + { |
|
| 727 | + // Default to the first message and then we'll override in a bit ;) |
|
| 670 | 728 | $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_first_msg']; |
| 729 | + } |
|
| 671 | 730 | |
| 672 | 731 | $topic_changes[$row['id_topic']]['unapproved_posts'] += $approve ? -1 : 1; |
| 673 | 732 | $board_changes[$row['id_board']]['unapproved_posts'] += $approve ? -1 : 1; |
@@ -675,12 +734,16 @@ discard block |
||
| 675 | 734 | |
| 676 | 735 | // Post count for the user? |
| 677 | 736 | if ($row['id_member'] && empty($row['count_posts'])) |
| 678 | - $member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1; |
|
| 737 | + { |
|
| 738 | + $member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1; |
|
| 739 | + } |
|
| 679 | 740 | } |
| 680 | 741 | $db->free_result($request); |
| 681 | 742 | |
| 682 | 743 | if (empty($msgs)) |
| 683 | - return; |
|
| 744 | + { |
|
| 745 | + return; |
|
| 746 | + } |
|
| 684 | 747 | |
| 685 | 748 | // Now we have the differences make the changes, first the easy one. |
| 686 | 749 | $db->query('', ' |
@@ -708,13 +771,16 @@ discard block |
||
| 708 | 771 | ) |
| 709 | 772 | ); |
| 710 | 773 | while ($row = $db->fetch_assoc($request)) |
| 711 | - $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
|
| 774 | + { |
|
| 775 | + $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
|
| 776 | + } |
|
| 712 | 777 | $db->free_result($request); |
| 713 | 778 | } |
| 714 | 779 | |
| 715 | 780 | // ... next the topics... |
| 716 | 781 | foreach ($topic_changes as $id => $changes) |
| 717 | - $db->query('', ' |
|
| 782 | + { |
|
| 783 | + $db->query('', ' |
|
| 718 | 784 | UPDATE {db_prefix}topics |
| 719 | 785 | SET |
| 720 | 786 | approved = {int:approved}, |
@@ -730,10 +796,12 @@ discard block |
||
| 730 | 796 | 'id_topic' => $id, |
| 731 | 797 | ) |
| 732 | 798 | ); |
| 799 | + } |
|
| 733 | 800 | |
| 734 | 801 | // ... finally the boards... |
| 735 | 802 | foreach ($board_changes as $id => $changes) |
| 736 | - $db->query('', ' |
|
| 803 | + { |
|
| 804 | + $db->query('', ' |
|
| 737 | 805 | UPDATE {db_prefix}boards |
| 738 | 806 | SET |
| 739 | 807 | num_posts = num_posts + {int:num_posts}, |
@@ -749,6 +817,7 @@ discard block |
||
| 749 | 817 | 'id_board' => $id, |
| 750 | 818 | ) |
| 751 | 819 | ); |
| 820 | + } |
|
| 752 | 821 | |
| 753 | 822 | // Finally, least importantly, notifications! |
| 754 | 823 | if ($approve) |
@@ -756,10 +825,14 @@ discard block |
||
| 756 | 825 | require_once(SUBSDIR . '/Notification.subs.php'); |
| 757 | 826 | |
| 758 | 827 | if (!empty($notification_topics)) |
| 759 | - sendBoardNotifications($notification_topics); |
|
| 828 | + { |
|
| 829 | + sendBoardNotifications($notification_topics); |
|
| 830 | + } |
|
| 760 | 831 | |
| 761 | 832 | if (!empty($notification_posts)) |
| 762 | - sendApprovalNotifications($notification_posts); |
|
| 833 | + { |
|
| 834 | + sendApprovalNotifications($notification_posts); |
|
| 835 | + } |
|
| 763 | 836 | |
| 764 | 837 | $db->query('', ' |
| 765 | 838 | DELETE FROM {db_prefix}approval_queue |
@@ -776,7 +849,9 @@ discard block |
||
| 776 | 849 | { |
| 777 | 850 | $msgInserts = array(); |
| 778 | 851 | foreach ($msgs as $msg) |
| 779 | - $msgInserts[] = array($msg); |
|
| 852 | + { |
|
| 853 | + $msgInserts[] = array($msg); |
|
| 854 | + } |
|
| 780 | 855 | |
| 781 | 856 | $db->insert('ignore', |
| 782 | 857 | '{db_prefix}approval_queue', |
@@ -800,7 +875,9 @@ discard block |
||
| 800 | 875 | { |
| 801 | 876 | require_once(SUBSDIR . '/Members.subs.php'); |
| 802 | 877 | foreach ($member_post_changes as $id_member => $count_change) |
| 803 | - updateMemberData($id_member, array('posts' => 'posts ' . ($approve ? '+' : '-') . ' ' . $count_change)); |
|
| 878 | + { |
|
| 879 | + updateMemberData($id_member, array('posts' => 'posts ' . ($approve ? '+' : '-') . ' ' . $count_change)); |
|
| 880 | + } |
|
| 804 | 881 | } |
| 805 | 882 | |
| 806 | 883 | return true; |
@@ -827,10 +904,14 @@ discard block |
||
| 827 | 904 | |
| 828 | 905 | // Please - let's be sane. |
| 829 | 906 | if (empty($setboards)) |
| 830 | - return false; |
|
| 907 | + { |
|
| 908 | + return false; |
|
| 909 | + } |
|
| 831 | 910 | |
| 832 | 911 | if (!is_array($setboards)) |
| 833 | - $setboards = array($setboards); |
|
| 912 | + { |
|
| 913 | + $setboards = array($setboards); |
|
| 914 | + } |
|
| 834 | 915 | |
| 835 | 916 | $lastMsg = array(); |
| 836 | 917 | |
@@ -850,14 +931,18 @@ discard block |
||
| 850 | 931 | ) |
| 851 | 932 | ); |
| 852 | 933 | while ($row = $db->fetch_assoc($request)) |
| 853 | - $lastMsg[$row['id_board']] = $row['id_msg']; |
|
| 934 | + { |
|
| 935 | + $lastMsg[$row['id_board']] = $row['id_msg']; |
|
| 936 | + } |
|
| 854 | 937 | $db->free_result($request); |
| 855 | 938 | } |
| 856 | 939 | else |
| 857 | 940 | { |
| 858 | 941 | // Just to note - there should only be one board passed if we are doing this. |
| 859 | 942 | foreach ($setboards as $id_board) |
| 860 | - $lastMsg[$id_board] = $id_msg; |
|
| 943 | + { |
|
| 944 | + $lastMsg[$id_board] = $id_msg; |
|
| 945 | + } |
|
| 861 | 946 | } |
| 862 | 947 | |
| 863 | 948 | $parent_boards = array(); |
@@ -875,9 +960,12 @@ discard block |
||
| 875 | 960 | } |
| 876 | 961 | |
| 877 | 962 | if (!empty($board) && $id_board == $board) |
| 878 | - $parents = $board_info['parent_boards']; |
|
| 879 | - else |
|
| 880 | - $parents = getBoardParents($id_board); |
|
| 963 | + { |
|
| 964 | + $parents = $board_info['parent_boards']; |
|
| 965 | + } |
|
| 966 | + else { |
|
| 967 | + $parents = getBoardParents($id_board); |
|
| 968 | + } |
|
| 881 | 969 | |
| 882 | 970 | // Ignore any parents on the top child level. |
| 883 | 971 | foreach ($parents as $id => $parent) |
@@ -886,9 +974,13 @@ discard block |
||
| 886 | 974 | { |
| 887 | 975 | // If we're already doing this one as a board, is this a higher last modified? |
| 888 | 976 | if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) |
| 889 | - $lastModified[$id] = $lastModified[$id_board]; |
|
| 977 | + { |
|
| 978 | + $lastModified[$id] = $lastModified[$id_board]; |
|
| 979 | + } |
|
| 890 | 980 | elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) |
| 891 | - $parent_boards[$id] = $lastModified[$id_board]; |
|
| 981 | + { |
|
| 982 | + $parent_boards[$id] = $lastModified[$id_board]; |
|
| 983 | + } |
|
| 892 | 984 | } |
| 893 | 985 | } |
| 894 | 986 | } |
@@ -902,22 +994,28 @@ discard block |
||
| 902 | 994 | foreach ($parent_boards as $id => $msg) |
| 903 | 995 | { |
| 904 | 996 | if (!isset($parent_updates[$msg])) |
| 905 | - $parent_updates[$msg] = array($id); |
|
| 906 | - else |
|
| 907 | - $parent_updates[$msg][] = $id; |
|
| 997 | + { |
|
| 998 | + $parent_updates[$msg] = array($id); |
|
| 999 | + } |
|
| 1000 | + else { |
|
| 1001 | + $parent_updates[$msg][] = $id; |
|
| 1002 | + } |
|
| 908 | 1003 | } |
| 909 | 1004 | |
| 910 | 1005 | foreach ($lastMsg as $id => $msg) |
| 911 | 1006 | { |
| 912 | 1007 | if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) |
| 913 | - $board_updates[$msg . '-' . $lastModified[$id]] = array( |
|
| 1008 | + { |
|
| 1009 | + $board_updates[$msg . '-' . $lastModified[$id]] = array( |
|
| 914 | 1010 | 'id' => $msg, |
| 915 | 1011 | 'updated' => $lastModified[$id], |
| 916 | 1012 | 'boards' => array($id) |
| 917 | 1013 | ); |
| 1014 | + } |
|
| 918 | 1015 | |
| 919 | - else |
|
| 920 | - $board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id; |
|
| 1016 | + else { |
|
| 1017 | + $board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id; |
|
| 1018 | + } |
|
| 921 | 1019 | } |
| 922 | 1020 | |
| 923 | 1021 | // Now commit the changes! |
@@ -980,7 +1078,9 @@ discard block |
||
| 980 | 1078 | ) |
| 981 | 1079 | ); |
| 982 | 1080 | if ($db->num_rows($request) == 0) |
| 983 | - return array(); |
|
| 1081 | + { |
|
| 1082 | + return array(); |
|
| 1083 | + } |
|
| 984 | 1084 | $row = $db->fetch_assoc($request); |
| 985 | 1085 | $db->free_result($request); |
| 986 | 1086 | |
@@ -1044,14 +1144,18 @@ discard block |
||
| 1044 | 1144 | |
| 1045 | 1145 | // The message they were trying to edit was most likely deleted. |
| 1046 | 1146 | if ($message === false) |
| 1047 | - return false; |
|
| 1147 | + { |
|
| 1148 | + return false; |
|
| 1149 | + } |
|
| 1048 | 1150 | |
| 1049 | 1151 | $errors = checkMessagePermissions($message['message']); |
| 1050 | 1152 | |
| 1051 | 1153 | prepareMessageContext($message); |
| 1052 | 1154 | |
| 1053 | 1155 | if (!empty($errors)) |
| 1054 | - $message['errors'] = $errors; |
|
| 1156 | + { |
|
| 1157 | + $message['errors'] = $errors; |
|
| 1158 | + } |
|
| 1055 | 1159 | |
| 1056 | 1160 | return $message; |
| 1057 | 1161 | // Posting a quoted reply? |
@@ -1074,14 +1178,18 @@ discard block |
||
| 1074 | 1178 | ) |
| 1075 | 1179 | ); |
| 1076 | 1180 | if ($db->num_rows($request) == 0) |
| 1077 | - throw new Elk_Exception('quoted_post_deleted', false); |
|
| 1181 | + { |
|
| 1182 | + throw new Elk_Exception('quoted_post_deleted', false); |
|
| 1183 | + } |
|
| 1078 | 1184 | list ($form_subject, $mname, $mdate, $form_message) = $db->fetch_row($request); |
| 1079 | 1185 | $db->free_result($request); |
| 1080 | 1186 | |
| 1081 | 1187 | // Add 'Re: ' to the front of the quoted subject. |
| 1082 | 1188 | $response_prefix = response_prefix(); |
| 1083 | 1189 | if (trim($response_prefix) != '' && Util::strpos($form_subject, trim($response_prefix)) !== 0) |
| 1084 | - $form_subject = $response_prefix . $form_subject; |
|
| 1190 | + { |
|
| 1191 | + $form_subject = $response_prefix . $form_subject; |
|
| 1192 | + } |
|
| 1085 | 1193 | |
| 1086 | 1194 | // Censor the message and subject. |
| 1087 | 1195 | $form_message = censor($form_message); |
@@ -1102,7 +1210,9 @@ discard block |
||
| 1102 | 1210 | // Add 'Re: ' to the front of the subject. |
| 1103 | 1211 | $response_prefix = response_prefix(); |
| 1104 | 1212 | if (trim($response_prefix) != '' && $form_subject != '' && Util::strpos($form_subject, trim($response_prefix)) !== 0) |
| 1105 | - $form_subject = $response_prefix . $form_subject; |
|
| 1213 | + { |
|
| 1214 | + $form_subject = $response_prefix . $form_subject; |
|
| 1215 | + } |
|
| 1106 | 1216 | |
| 1107 | 1217 | // Censor the subject. |
| 1108 | 1218 | $form_subject = censor($form_subject); |
@@ -140,7 +140,9 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | // This function sorta needs gzinflate! |
| 142 | 142 | if (!function_exists('gzinflate')) |
| 143 | - throw new Elk_Exception('package_no_zlib', 'critical'); |
|
| 143 | + { |
|
| 144 | + throw new Elk_Exception('package_no_zlib', 'critical'); |
|
| 145 | + } |
|
| 144 | 146 | |
| 145 | 147 | // Make sure we have this loaded. |
| 146 | 148 | loadLanguage('Packages'); |
@@ -151,7 +153,9 @@ discard block |
||
| 151 | 153 | // The destination needs exist and be writable or we are doomed |
| 152 | 154 | umask(0); |
| 153 | 155 | if ($this->destination !== null && !file_exists($this->destination) && !$this->single_file) |
| 154 | - mktree($this->destination, 0777); |
|
| 156 | + { |
|
| 157 | + mktree($this->destination, 0777); |
|
| 158 | + } |
|
| 155 | 159 | } |
| 156 | 160 | |
| 157 | 161 | /** |
@@ -163,7 +167,9 @@ discard block |
||
| 163 | 167 | { |
| 164 | 168 | // Make sure we have a zip file |
| 165 | 169 | if ($this->check_valid_zip() === false) |
| 166 | - return false; |
|
| 170 | + { |
|
| 171 | + return false; |
|
| 172 | + } |
|
| 167 | 173 | |
| 168 | 174 | // The overall zip information for this archive |
| 169 | 175 | $this->_read_endof_cdr(); |
@@ -173,23 +179,32 @@ discard block |
||
| 173 | 179 | |
| 174 | 180 | // Load the file list from the central directory record |
| 175 | 181 | if ($this->_load_file_headers() === false) |
| 176 | - return false; |
|
| 182 | + { |
|
| 183 | + return false; |
|
| 184 | + } |
|
| 177 | 185 | |
| 178 | 186 | // The file records in the CDR point to the files location in the archive |
| 179 | 187 | $this->_process_files(); |
| 180 | 188 | |
| 181 | 189 | // Looking for a single file and this is it |
| 182 | 190 | if ($this->_found && $this->single_file) |
| 183 | - return $this->_crc_check ? $this->_found : false; |
|
| 191 | + { |
|
| 192 | + return $this->_crc_check ? $this->_found : false; |
|
| 193 | + } |
|
| 184 | 194 | |
| 185 | 195 | // Wanted many files then we need to clean up |
| 186 | 196 | if ($this->destination !== null && !$this->single_file) |
| 187 | - package_flush_cache(); |
|
| 197 | + { |
|
| 198 | + package_flush_cache(); |
|
| 199 | + } |
|
| 188 | 200 | |
| 189 | 201 | if ($this->single_file) |
| 190 | - return false; |
|
| 191 | - else |
|
| 192 | - return $this->return; |
|
| 202 | + { |
|
| 203 | + return false; |
|
| 204 | + } |
|
| 205 | + else { |
|
| 206 | + return $this->return; |
|
| 207 | + } |
|
| 193 | 208 | } |
| 194 | 209 | |
| 195 | 210 | /** |
@@ -201,7 +216,9 @@ discard block |
||
| 201 | 216 | { |
| 202 | 217 | // No signature? |
| 203 | 218 | if (strlen($this->data) < 10) |
| 204 | - return false; |
|
| 219 | + { |
|
| 220 | + return false; |
|
| 221 | + } |
|
| 205 | 222 | |
| 206 | 223 | // Look for an end of central directory signature 0x06054b50 |
| 207 | 224 | $check = explode("\x50\x4b\x05\x06", $this->data); |
@@ -280,7 +297,9 @@ discard block |
||
| 280 | 297 | // Extract all file standard length information for this record, its the 42 bytes following the signature |
| 281 | 298 | $temp = unpack('vversion/vversion_needed/vgeneral_purpose/vcompress_method/vfile_time/vfile_date/Vcrc/Vcompressed_size/Vsize/vfilename_length/vextra_field_length/vcomment_length/vdisk_number_start/vinternal_attributes/vexternal_attributes1/vexternal_attributes2/Vrelative_offset', substr($this->_data_cdr, $pointer + 4, 42)); |
| 282 | 299 | if ($temp === false) |
| 283 | - return false; |
|
| 300 | + { |
|
| 301 | + return false; |
|
| 302 | + } |
|
| 284 | 303 | |
| 285 | 304 | // Extract the variable length data, filename, etc |
| 286 | 305 | $pointer = $pointer + 46; |
@@ -298,7 +317,9 @@ discard block |
||
| 298 | 317 | |
| 299 | 318 | // Sections and count from the signature must match or the zip file is bad |
| 300 | 319 | if ($i !== $this->_zip_info['files']) |
| 301 | - return false; |
|
| 320 | + { |
|
| 321 | + return false; |
|
| 322 | + } |
|
| 302 | 323 | } |
| 303 | 324 | |
| 304 | 325 | /** |
@@ -323,10 +344,13 @@ discard block |
||
| 323 | 344 | |
| 324 | 345 | // Validate we are at a local file header '\x50\x4b\x03\x04' |
| 325 | 346 | if (substr($this->_file_info['data'], 0, 4) === "\x50\x4b\x03\x04") |
| 326 | - $this->_read_local_header(); |
|
| 347 | + { |
|
| 348 | + $this->_read_local_header(); |
|
| 349 | + } |
|
| 327 | 350 | // Something is probably wrong with the archive, like the 70's |
| 328 | - else |
|
| 329 | - continue; |
|
| 351 | + else { |
|
| 352 | + continue; |
|
| 353 | + } |
|
| 330 | 354 | |
| 331 | 355 | // Check if the gp flag requires us to make any adjustments |
| 332 | 356 | $this->_check_general_purpose_flag(); |
@@ -335,12 +359,17 @@ discard block |
||
| 335 | 359 | if (!empty($this->_file_info['compress_method']) || ($this->_file_info['compressed_size'] != $this->_file_info['size'])) |
| 336 | 360 | { |
| 337 | 361 | if ($this->_file_info['compress_method'] == 8) |
| 338 | - $this->_file_info['data'] = @gzinflate($this->_file_info['compress_data'], $this->_file_info['size']); |
|
| 362 | + { |
|
| 363 | + $this->_file_info['data'] = @gzinflate($this->_file_info['compress_data'], $this->_file_info['size']); |
|
| 364 | + } |
|
| 339 | 365 | elseif ($this->_file_info['compress_method'] == 12 && function_exists('bzdecompress')) |
| 340 | - $this->_file_info['data'] = bzdecompress($this->_file_info['compress_data']); |
|
| 366 | + { |
|
| 367 | + $this->_file_info['data'] = bzdecompress($this->_file_info['compress_data']); |
|
| 368 | + } |
|
| 369 | + } |
|
| 370 | + else { |
|
| 371 | + $this->_file_info['data'] = $this->_file_info['compress_data']; |
|
| 341 | 372 | } |
| 342 | - else |
|
| 343 | - $this->_file_info['data'] = $this->_file_info['compress_data']; |
|
| 344 | 373 | |
| 345 | 374 | // Okay! We can write this file, looks good from here... |
| 346 | 375 | if ($this->_write_this && $this->destination !== null) |
@@ -348,10 +377,14 @@ discard block |
||
| 348 | 377 | $this->_write_this_file(); |
| 349 | 378 | |
| 350 | 379 | if ($this->_skip) |
| 351 | - continue; |
|
| 380 | + { |
|
| 381 | + continue; |
|
| 382 | + } |
|
| 352 | 383 | |
| 353 | 384 | if ($this->_found) |
| 354 | - return; |
|
| 385 | + { |
|
| 386 | + return; |
|
| 387 | + } |
|
| 355 | 388 | } |
| 356 | 389 | |
| 357 | 390 | // Not a directory, add it to our results |
@@ -411,10 +444,14 @@ discard block |
||
| 411 | 444 | { |
| 412 | 445 | // If this is a file, and it doesn't exist.... happy days! |
| 413 | 446 | if (substr($this->_filename, -1) !== '/' && !file_exists($this->destination . '/' . $this->_filename)) |
| 414 | - $this->_write_this = true; |
|
| 447 | + { |
|
| 448 | + $this->_write_this = true; |
|
| 449 | + } |
|
| 415 | 450 | // If the file exists, we may not want to overwrite it. |
| 416 | 451 | elseif (substr($this->_filename, -1) !== '/') |
| 417 | - $this->_write_this = $this->overwrite; |
|
| 452 | + { |
|
| 453 | + $this->_write_this = $this->overwrite; |
|
| 454 | + } |
|
| 418 | 455 | // This is a directory, so we're gonna want to create it. (probably...) |
| 419 | 456 | elseif ($this->destination !== null && !$this->single_file) |
| 420 | 457 | { |
@@ -422,11 +459,14 @@ discard block |
||
| 422 | 459 | $this->_filename = strtr($this->_filename, array('../' => '', '/..' => '')); |
| 423 | 460 | |
| 424 | 461 | if (!file_exists($this->destination . '/' . $this->_filename)) |
| 425 | - mktree($this->destination . '/' . $this->_filename, 0777); |
|
| 462 | + { |
|
| 463 | + mktree($this->destination . '/' . $this->_filename, 0777); |
|
| 464 | + } |
|
| 426 | 465 | $this->_write_this = false; |
| 427 | 466 | } |
| 428 | - else |
|
| 429 | - $this->_write_this = false; |
|
| 467 | + else { |
|
| 468 | + $this->_write_this = false; |
|
| 469 | + } |
|
| 430 | 470 | } |
| 431 | 471 | |
| 432 | 472 | /** |
@@ -442,26 +482,40 @@ discard block |
||
| 442 | 482 | |
| 443 | 483 | // A directory may need to be created |
| 444 | 484 | if ((strpos($this->_filename, '/') !== false && !$this->single_file) || (!$this->single_file && !is_dir($this->_file_info['dir']))) |
| 445 | - mktree($this->_file_info['dir'], 0777); |
|
| 485 | + { |
|
| 486 | + mktree($this->_file_info['dir'], 0777); |
|
| 487 | + } |
|
| 446 | 488 | |
| 447 | 489 | // If we're looking for a **specific file**, and this is it... ka-bam, baby. |
| 448 | 490 | if ($this->single_file && ($this->destination === $this->_filename || $this->destination === '*/' . basename($this->_filename))) |
| 449 | - $this->_found = $this->_file_info['data']; |
|
| 491 | + { |
|
| 492 | + $this->_found = $this->_file_info['data']; |
|
| 493 | + } |
|
| 450 | 494 | // Oh? Another file. Fine. You don't like this file, do you? I know how it is. |
| 451 | 495 | // Yeah... just go away. No, don't apologize. I know this file's just not *good enough* for you. |
| 452 | 496 | elseif ($this->single_file) |
| 453 | - $this->_skip = true; |
|
| 497 | + { |
|
| 498 | + $this->_skip = true; |
|
| 499 | + } |
|
| 454 | 500 | // Don't really want this file? |
| 455 | 501 | elseif ($this->files_to_extract !== null && !in_array($this->_filename, $this->files_to_extract)) |
| 456 | - $this->_skip = true; |
|
| 502 | + { |
|
| 503 | + $this->_skip = true; |
|
| 504 | + } |
|
| 457 | 505 | |
| 458 | 506 | // Write it out then |
| 459 | 507 | if ($this->_skip === true) |
| 460 | - return; |
|
| 508 | + { |
|
| 509 | + return; |
|
| 510 | + } |
|
| 461 | 511 | elseif (!empty($this->_found)) |
| 462 | - $this->_check_crc(); |
|
| 512 | + { |
|
| 513 | + $this->_check_crc(); |
|
| 514 | + } |
|
| 463 | 515 | elseif ($this->_skip === false && $this->_found === false && $this->_check_crc()) |
| 464 | - package_put_contents($this->destination . '/' . $this->_filename, $this->_file_info['data']); |
|
| 516 | + { |
|
| 517 | + package_put_contents($this->destination . '/' . $this->_filename, $this->_file_info['data']); |
|
| 518 | + } |
|
| 465 | 519 | } |
| 466 | 520 | |
| 467 | 521 | /** |
@@ -487,7 +541,9 @@ discard block |
||
| 487 | 541 | { |
| 488 | 542 | // If bit 1 is set the file is encrypted so empty it instead of writing out gibberish |
| 489 | 543 | if ($this->_file_info['general_purpose'] & 0x0001) |
| 490 | - $this->_file_info['data'] = ''; |
|
| 544 | + { |
|
| 545 | + $this->_file_info['data'] = ''; |
|
| 546 | + } |
|
| 491 | 547 | |
| 492 | 548 | // See if bit 3 is set |
| 493 | 549 | if ($this->_file_info['general_purpose'] & 0x0008) |
@@ -497,7 +553,9 @@ discard block |
||
| 497 | 553 | |
| 498 | 554 | // The spec allows for an optional header in the general purpose record |
| 499 | 555 | if (substr($general_purpose, 0, 4) === "\x50\x4b\x07\x08") |
| 500 | - $general_purpose = substr($general_purpose, 4); |
|
| 556 | + { |
|
| 557 | + $general_purpose = substr($general_purpose, 4); |
|
| 558 | + } |
|
| 501 | 559 | |
| 502 | 560 | // These values should be what's in the CDR record per spec |
| 503 | 561 | $general_purpose_data = unpack('Vcrc/Vcompressed_size/Vsize', $general_purpose); |
@@ -131,7 +131,9 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | // Set up to output a file to the users browser |
| 133 | 133 | while (ob_get_level() > 0) |
| 134 | - @ob_end_clean(); |
|
| 134 | + { |
|
| 135 | + @ob_end_clean(); |
|
| 136 | + } |
|
| 135 | 137 | |
| 136 | 138 | header('Content-Encoding: none'); |
| 137 | 139 | header('Pragma: no-cache'); |
@@ -349,11 +351,15 @@ discard block |
||
| 349 | 351 | |
| 350 | 352 | // Temporarily switch back to not using a search index. |
| 351 | 353 | if (!empty($modSettings['search_index']) && $modSettings['search_index'] === 'custom') |
| 352 | - updateSettings(array('search_index' => '')); |
|
| 354 | + { |
|
| 355 | + updateSettings(array('search_index' => '')); |
|
| 356 | + } |
|
| 353 | 357 | |
| 354 | 358 | // Don't let simultaneous processes be updating the search index. |
| 355 | 359 | if (!empty($modSettings['search_custom_index_config'])) |
| 356 | - updateSettings(array('search_custom_index_config' => '')); |
|
| 360 | + { |
|
| 361 | + updateSettings(array('search_custom_index_config' => '')); |
|
| 362 | + } |
|
| 357 | 363 | } |
| 358 | 364 | |
| 359 | 365 | $num_messages = array( |
@@ -370,7 +376,9 @@ discard block |
||
| 370 | 376 | ) |
| 371 | 377 | ); |
| 372 | 378 | while ($row = $db->fetch_assoc($request)) |
| 373 | - $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
| 379 | + { |
|
| 380 | + $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
| 381 | + } |
|
| 374 | 382 | |
| 375 | 383 | // Done with indexing the messages, on to the next step |
| 376 | 384 | if (empty($num_messages['todo'])) |
@@ -411,7 +419,9 @@ discard block |
||
| 411 | 419 | |
| 412 | 420 | $number_processed++; |
| 413 | 421 | foreach (text2words($row['body'], $index_settings['bytes_per_word'], true) as $id_word) |
| 414 | - $inserts[] = array($id_word, $row['id_msg']); |
|
| 422 | + { |
|
| 423 | + $inserts[] = array($id_word, $row['id_msg']); |
|
| 424 | + } |
|
| 415 | 425 | } |
| 416 | 426 | $num_messages['done'] += $number_processed; |
| 417 | 427 | $num_messages['todo'] -= $number_processed; |
@@ -420,12 +430,14 @@ discard block |
||
| 420 | 430 | $start += $forced_break ? $number_processed : $messages_per_batch; |
| 421 | 431 | |
| 422 | 432 | if (!empty($inserts)) |
| 423 | - $db->insert('ignore', |
|
| 433 | + { |
|
| 434 | + $db->insert('ignore', |
|
| 424 | 435 | '{db_prefix}log_search_words', |
| 425 | 436 | array('id_word' => 'int', 'id_msg' => 'int'), |
| 426 | 437 | $inserts, |
| 427 | 438 | array('id_word', 'id_msg') |
| 428 | 439 | ); |
| 440 | + } |
|
| 429 | 441 | |
| 430 | 442 | // Done then set up for the next step, set up for the next loop. |
| 431 | 443 | if ($num_messages['todo'] === 0) |
@@ -434,8 +446,9 @@ discard block |
||
| 434 | 446 | $start = 0; |
| 435 | 447 | break; |
| 436 | 448 | } |
| 437 | - else |
|
| 438 | - updateSettings(array('search_custom_index_resume' => serialize(array_merge($index_settings, array('resume_at' => $start))))); |
|
| 449 | + else { |
|
| 450 | + updateSettings(array('search_custom_index_resume' => serialize(array_merge($index_settings, array('resume_at' => $start))))); |
|
| 451 | + } |
|
| 439 | 452 | } |
| 440 | 453 | |
| 441 | 454 | // Since there are still steps to go, 80% is the maximum here. |
@@ -478,19 +491,23 @@ discard block |
||
| 478 | 491 | ) |
| 479 | 492 | ); |
| 480 | 493 | while ($row = $db->fetch_assoc($request)) |
| 481 | - $stop_words[] = $row['id_word']; |
|
| 494 | + { |
|
| 495 | + $stop_words[] = $row['id_word']; |
|
| 496 | + } |
|
| 482 | 497 | $db->free_result($request); |
| 483 | 498 | |
| 484 | 499 | updateSettings(array('search_stopwords' => implode(',', $stop_words))); |
| 485 | 500 | |
| 486 | 501 | if (!empty($stop_words)) |
| 487 | - $db->query('', ' |
|
| 502 | + { |
|
| 503 | + $db->query('', ' |
|
| 488 | 504 | DELETE FROM {db_prefix}log_search_words |
| 489 | 505 | WHERE id_word in ({array_int:stop_words})', |
| 490 | 506 | array( |
| 491 | 507 | 'stop_words' => $stop_words, |
| 492 | 508 | ) |
| 493 | 509 | ); |
| 510 | + } |
|
| 494 | 511 | |
| 495 | 512 | $start += $column_definition['step_size']; |
| 496 | 513 | if ($start > $column_definition['max_size']) |
@@ -65,9 +65,12 @@ discard block |
||
| 65 | 65 | while ($row = $db->fetch_assoc($result)) |
| 66 | 66 | { |
| 67 | 67 | if ($year_low != $year_high) |
| 68 | - $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
| 69 | - else |
|
| 70 | - $age_year = $year_low; |
|
| 68 | + { |
|
| 69 | + $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
| 70 | + } |
|
| 71 | + else { |
|
| 72 | + $age_year = $year_low; |
|
| 73 | + } |
|
| 71 | 74 | |
| 72 | 75 | $bday[$age_year . substr($row['birthdate'], 4)][] = array( |
| 73 | 76 | 'id' => $row['id_member'], |
@@ -80,7 +83,9 @@ discard block |
||
| 80 | 83 | |
| 81 | 84 | // Set is_last, so the themes know when to stop placing separators. |
| 82 | 85 | foreach ($bday as $mday => $array) |
| 83 | - $bday[$mday][count($array) - 1]['is_last'] = true; |
|
| 86 | + { |
|
| 87 | + $bday[$mday][count($array) - 1]['is_last'] = true; |
|
| 88 | + } |
|
| 84 | 89 | |
| 85 | 90 | return $bday; |
| 86 | 91 | } |
@@ -137,7 +142,9 @@ discard block |
||
| 137 | 142 | { |
| 138 | 143 | // If the attached topic is not approved then for the moment pretend it doesn't exist |
| 139 | 144 | if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) |
| 140 | - continue; |
|
| 145 | + { |
|
| 146 | + continue; |
|
| 147 | + } |
|
| 141 | 148 | |
| 142 | 149 | // Force a censor of the title - as often these are used by others. |
| 143 | 150 | $row['title'] = censor($row['title'], $use_permissions ? false : true); |
@@ -153,12 +160,15 @@ discard block |
||
| 153 | 160 | // Attempt to avoid DST problems. |
| 154 | 161 | // @todo Resolve this properly at some point. |
| 155 | 162 | if (Util::strftime('%Y-%m-%d', $date) == $lastDate) |
| 156 | - $date += 3601; |
|
| 163 | + { |
|
| 164 | + $date += 3601; |
|
| 165 | + } |
|
| 157 | 166 | $lastDate = Util::strftime('%Y-%m-%d', $date); |
| 158 | 167 | |
| 159 | 168 | // If we're using permissions (calendar pages?) then just ouput normal contextual style information. |
| 160 | 169 | if ($use_permissions) |
| 161 | - $events[Util::strftime('%Y-%m-%d', $date)][] = array( |
|
| 170 | + { |
|
| 171 | + $events[Util::strftime('%Y-%m-%d', $date)][] = array( |
|
| 162 | 172 | 'id' => $row['id_event'], |
| 163 | 173 | 'title' => $row['title'], |
| 164 | 174 | 'start_date' => $row['start_date'], |
@@ -173,9 +183,10 @@ discard block |
||
| 173 | 183 | 'can_export' => !empty($modSettings['cal_export']) ? true : false, |
| 174 | 184 | 'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
| 175 | 185 | ); |
| 186 | + } |
|
| 176 | 187 | // Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info. |
| 177 | - else |
|
| 178 | - $events[Util::strftime('%Y-%m-%d', $date)][] = array( |
|
| 188 | + else { |
|
| 189 | + $events[Util::strftime('%Y-%m-%d', $date)][] = array( |
|
| 179 | 190 | 'id' => $row['id_event'], |
| 180 | 191 | 'title' => $row['title'], |
| 181 | 192 | 'start_date' => $row['start_date'], |
@@ -192,6 +203,7 @@ discard block |
||
| 192 | 203 | 'poster' => $row['id_member'], |
| 193 | 204 | 'allowed_groups' => explode(',', $row['member_groups']), |
| 194 | 205 | ); |
| 206 | + } |
|
| 195 | 207 | } |
| 196 | 208 | } |
| 197 | 209 | $db->free_result($result); |
@@ -200,7 +212,9 @@ discard block |
||
| 200 | 212 | if ($use_permissions) |
| 201 | 213 | { |
| 202 | 214 | foreach ($events as $mday => $array) |
| 203 | - $events[$mday][count($array) - 1]['is_last'] = true; |
|
| 215 | + { |
|
| 216 | + $events[$mday][count($array) - 1]['is_last'] = true; |
|
| 217 | + } |
|
| 204 | 218 | } |
| 205 | 219 | |
| 206 | 220 | return $events; |
@@ -220,10 +234,13 @@ discard block |
||
| 220 | 234 | |
| 221 | 235 | // Get the lowest and highest dates for "all years". |
| 222 | 236 | if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
| 223 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
| 237 | + { |
|
| 238 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
| 224 | 239 | OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}'; |
| 225 | - else |
|
| 226 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
| 240 | + } |
|
| 241 | + else { |
|
| 242 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
| 243 | + } |
|
| 227 | 244 | |
| 228 | 245 | // Find some holidays... ;). |
| 229 | 246 | $result = $db->query('', ' |
@@ -244,9 +261,12 @@ discard block |
||
| 244 | 261 | while ($row = $db->fetch_assoc($result)) |
| 245 | 262 | { |
| 246 | 263 | if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
| 247 | - $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
| 248 | - else |
|
| 249 | - $event_year = substr($low_date, 0, 4); |
|
| 264 | + { |
|
| 265 | + $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
| 266 | + } |
|
| 267 | + else { |
|
| 268 | + $event_year = substr($low_date, 0, 4); |
|
| 269 | + } |
|
| 250 | 270 | |
| 251 | 271 | $holidays[$event_year . substr($row['event_date'], 4)][] = $row['title']; |
| 252 | 272 | } |
@@ -277,9 +297,13 @@ discard block |
||
| 277 | 297 | |
| 278 | 298 | // No board? No topic?!? |
| 279 | 299 | if (empty($board)) |
| 280 | - throw new Elk_Exception('missing_board_id', false); |
|
| 300 | + { |
|
| 301 | + throw new Elk_Exception('missing_board_id', false); |
|
| 302 | + } |
|
| 281 | 303 | if (empty($topic)) |
| 282 | - throw new Elk_Exception('missing_topic_id', false); |
|
| 304 | + { |
|
| 305 | + throw new Elk_Exception('missing_topic_id', false); |
|
| 306 | + } |
|
| 283 | 307 | |
| 284 | 308 | // Administrator, Moderator, or owner. Period. |
| 285 | 309 | if (!allowedTo('admin_forum') && !allowedTo('moderate_board')) |
@@ -290,11 +314,14 @@ discard block |
||
| 290 | 314 | { |
| 291 | 315 | // Not the owner of the topic. |
| 292 | 316 | if ($row['id_member_started'] != $user_info['id']) |
| 293 | - throw new Elk_Exception('not_your_topic', 'user'); |
|
| 317 | + { |
|
| 318 | + throw new Elk_Exception('not_your_topic', 'user'); |
|
| 319 | + } |
|
| 294 | 320 | } |
| 295 | 321 | // Topic/Board doesn't exist..... |
| 296 | - else |
|
| 297 | - throw new Elk_Exception('calendar_no_topic', 'general'); |
|
| 322 | + else { |
|
| 323 | + throw new Elk_Exception('calendar_no_topic', 'general'); |
|
| 324 | + } |
|
| 298 | 325 | } |
| 299 | 326 | } |
| 300 | 327 | |
@@ -379,13 +406,17 @@ discard block |
||
| 379 | 406 | { |
| 380 | 407 | $nShift -= $calendarOptions['start_day']; |
| 381 | 408 | if ($nShift < 0) |
| 382 | - $nShift = 7 + $nShift; |
|
| 409 | + { |
|
| 410 | + $nShift = 7 + $nShift; |
|
| 411 | + } |
|
| 383 | 412 | } |
| 384 | 413 | |
| 385 | 414 | // Number of rows required to fit the month. |
| 386 | 415 | $nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7); |
| 387 | 416 | if (($month_info['last_day']['day_of_month'] + $nShift) % 7) |
| 388 | - $nRows++; |
|
| 417 | + { |
|
| 418 | + $nRows++; |
|
| 419 | + } |
|
| 389 | 420 | |
| 390 | 421 | // Fetch the arrays for birthdays, posted events, and holidays. |
| 391 | 422 | $bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array(); |
@@ -399,7 +430,9 @@ discard block |
||
| 399 | 430 | $calendarGrid['week_days'][] = $count; |
| 400 | 431 | $count++; |
| 401 | 432 | if ($count == 7) |
| 402 | - $count = 0; |
|
| 433 | + { |
|
| 434 | + $count = 0; |
|
| 435 | + } |
|
| 403 | 436 | } |
| 404 | 437 | |
| 405 | 438 | // An adjustment value to apply to all calculated week numbers. |
@@ -410,7 +443,9 @@ discard block |
||
| 410 | 443 | // a Sunday, then there is a partial week at the start of the year |
| 411 | 444 | // that needs to be accounted for. |
| 412 | 445 | if ($calendarOptions['start_day'] === 0) |
| 413 | - $nWeekAdjust = $month_info['first_day_of_year'] === 0 ? 0 : 1; |
|
| 446 | + { |
|
| 447 | + $nWeekAdjust = $month_info['first_day_of_year'] === 0 ? 0 : 1; |
|
| 448 | + } |
|
| 414 | 449 | // If we are viewing the weeks, with a starting date other than Sunday, |
| 415 | 450 | // then things get complicated! Basically, as PHP is calculating the |
| 416 | 451 | // weeks with a Sunday starting date, we need to take this into account |
@@ -418,18 +453,22 @@ discard block |
||
| 418 | 453 | // year is above or below our starting date. Note that we offset by |
| 419 | 454 | // two, as some of this will get undone quite quickly by the statement |
| 420 | 455 | // below. |
| 421 | - else |
|
| 422 | - $nWeekAdjust = $calendarOptions['start_day'] > $month_info['first_day_of_year'] && $month_info['first_day_of_year'] !== 0 ? 2 : 1; |
|
| 456 | + else { |
|
| 457 | + $nWeekAdjust = $calendarOptions['start_day'] > $month_info['first_day_of_year'] && $month_info['first_day_of_year'] !== 0 ? 2 : 1; |
|
| 458 | + } |
|
| 423 | 459 | |
| 424 | 460 | // If our week starts on a day greater than the day the month starts |
| 425 | 461 | // on, then our week numbers will be one too high. So we need to |
| 426 | 462 | // reduce it by one - all these thoughts of offsets makes my head |
| 427 | 463 | // hurt... |
| 428 | 464 | if ($month_info['first_day']['day_of_week'] < $calendarOptions['start_day'] || $month_info['first_day_of_year'] > 4) |
| 429 | - $nWeekAdjust--; |
|
| 465 | + { |
|
| 466 | + $nWeekAdjust--; |
|
| 467 | + } |
|
| 468 | + } |
|
| 469 | + else { |
|
| 470 | + $nWeekAdjust = 0; |
|
| 430 | 471 | } |
| 431 | - else |
|
| 432 | - $nWeekAdjust = 0; |
|
| 433 | 472 | |
| 434 | 473 | // Iterate through each week. |
| 435 | 474 | $calendarGrid['weeks'] = array(); |
@@ -443,7 +482,9 @@ discard block |
||
| 443 | 482 | |
| 444 | 483 | // Handle the dreaded "week 53", it can happen, but only once in a blue moon ;) |
| 445 | 484 | if ($calendarGrid['weeks'][$nRow]['number'] == 53 && $nShift != 4 && $month_info['first_day_of_next_year'] < 4) |
| 446 | - $calendarGrid['weeks'][$nRow]['number'] = 1; |
|
| 485 | + { |
|
| 486 | + $calendarGrid['weeks'][$nRow]['number'] = 1; |
|
| 487 | + } |
|
| 447 | 488 | |
| 448 | 489 | // And figure out all the days. |
| 449 | 490 | for ($nCol = 0; $nCol < 7; $nCol++) |
@@ -451,7 +492,9 @@ discard block |
||
| 451 | 492 | $nDay = ($nRow * 7) + $nCol - $nShift + 1; |
| 452 | 493 | |
| 453 | 494 | if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) |
| 454 | - $nDay = 0; |
|
| 495 | + { |
|
| 496 | + $nDay = 0; |
|
| 497 | + } |
|
| 455 | 498 | |
| 456 | 499 | $date = sprintf('%04d-%02d-%02d', $year, $month, $nDay); |
| 457 | 500 | |
@@ -499,7 +542,9 @@ discard block |
||
| 499 | 542 | // Here we offset accordingly to get things to the real start of a week. |
| 500 | 543 | $date_diff = $day_of_week - $calendarOptions['start_day']; |
| 501 | 544 | if ($date_diff < 0) |
| 502 | - $date_diff += 7; |
|
| 545 | + { |
|
| 546 | + $date_diff += 7; |
|
| 547 | + } |
|
| 503 | 548 | $new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400; |
| 504 | 549 | $day = (int) Util::strftime('%d', $new_timestamp); |
| 505 | 550 | $month = (int) Util::strftime('%m', $new_timestamp); |
@@ -545,15 +590,20 @@ discard block |
||
| 545 | 590 | |
| 546 | 591 | // All this is as getCalendarGrid. |
| 547 | 592 | if ($calendarOptions['start_day'] === 0) |
| 548 | - $nWeekAdjust = $first_day_of_year === 0 && $first_day_of_year > 3 ? 0 : 1; |
|
| 549 | - else |
|
| 550 | - $nWeekAdjust = $calendarOptions['start_day'] > $first_day_of_year && $first_day_of_year !== 0 ? 2 : 1; |
|
| 593 | + { |
|
| 594 | + $nWeekAdjust = $first_day_of_year === 0 && $first_day_of_year > 3 ? 0 : 1; |
|
| 595 | + } |
|
| 596 | + else { |
|
| 597 | + $nWeekAdjust = $calendarOptions['start_day'] > $first_day_of_year && $first_day_of_year !== 0 ? 2 : 1; |
|
| 598 | + } |
|
| 551 | 599 | |
| 552 | 600 | $calendarGrid['week_number'] = (int) Util::strftime('%U', mktime(0, 0, 0, $month, $day, $year)) + $nWeekAdjust; |
| 553 | 601 | |
| 554 | 602 | // If this crosses a year boundary and includes january it should be week one. |
| 555 | 603 | if ((int) Util::strftime('%Y', $curTimestamp + 518400) != $year && $calendarGrid['week_number'] > 53 && $first_day_of_next_year < 5) |
| 556 | - $calendarGrid['week_number'] = 1; |
|
| 604 | + { |
|
| 605 | + $calendarGrid['week_number'] = 1; |
|
| 606 | + } |
|
| 557 | 607 | } |
| 558 | 608 | |
| 559 | 609 | // This holds all the main data - there is at least one month! |
@@ -668,7 +718,9 @@ discard block |
||
| 668 | 718 | for ($i = $now; $i < $now + $days_for_index; $i += 86400) |
| 669 | 719 | { |
| 670 | 720 | if (isset($cached_data['holidays'][Util::strftime('%Y-%m-%d', $i)])) |
| 671 | - $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][Util::strftime('%Y-%m-%d', $i)]); |
|
| 721 | + { |
|
| 722 | + $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][Util::strftime('%Y-%m-%d', $i)]); |
|
| 723 | + } |
|
| 672 | 724 | } |
| 673 | 725 | |
| 674 | 726 | // Happy Birthday, guys and gals! |
@@ -678,7 +730,9 @@ discard block |
||
| 678 | 730 | if (isset($cached_data['birthdays'][$loop_date])) |
| 679 | 731 | { |
| 680 | 732 | foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) |
| 681 | - $cached_data['birthdays'][Util::strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
| 733 | + { |
|
| 734 | + $cached_data['birthdays'][Util::strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
| 735 | + } |
|
| 682 | 736 | $return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]); |
| 683 | 737 | } |
| 684 | 738 | } |
@@ -691,7 +745,9 @@ discard block |
||
| 691 | 745 | |
| 692 | 746 | // No events today? Check the next day. |
| 693 | 747 | if (empty($cached_data['events'][$loop_date])) |
| 694 | - continue; |
|
| 748 | + { |
|
| 749 | + continue; |
|
| 750 | + } |
|
| 695 | 751 | |
| 696 | 752 | // Loop through all events to add a few last-minute values. |
| 697 | 753 | foreach ($cached_data['events'][$loop_date] as $ev => $event) |
@@ -705,8 +761,9 @@ discard block |
||
| 705 | 761 | unset($cached_data['events'][$loop_date][$ev]); |
| 706 | 762 | continue; |
| 707 | 763 | } |
| 708 | - else |
|
| 709 | - $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
| 764 | + else { |
|
| 765 | + $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
| 766 | + } |
|
| 710 | 767 | |
| 711 | 768 | // Might be set to true afterwards, depending on the permissions. |
| 712 | 769 | $this_event['can_edit'] = false; |
@@ -715,14 +772,20 @@ discard block |
||
| 715 | 772 | } |
| 716 | 773 | |
| 717 | 774 | if (!empty($cached_data['events'][$loop_date])) |
| 718 | - $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
| 775 | + { |
|
| 776 | + $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
| 777 | + } |
|
| 719 | 778 | } |
| 720 | 779 | |
| 721 | 780 | // Mark the last item so that a list separator can be used in the template. |
| 722 | 781 | for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) |
| 723 | - $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
| 782 | + { |
|
| 783 | + $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
| 784 | + } |
|
| 724 | 785 | for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) |
| 725 | - $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
| 786 | + { |
|
| 787 | + $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
| 788 | + } |
|
| 726 | 789 | |
| 727 | 790 | return array( |
| 728 | 791 | 'data' => $return_data, |
@@ -781,7 +844,9 @@ discard block |
||
| 781 | 844 | |
| 782 | 845 | // No results, return false. |
| 783 | 846 | if ($db->num_rows($request) === 0) |
| 784 | - return false; |
|
| 847 | + { |
|
| 848 | + return false; |
|
| 849 | + } |
|
| 785 | 850 | |
| 786 | 851 | // Grab the results and return. |
| 787 | 852 | list ($poster) = $db->fetch_row($request); |
@@ -818,11 +883,15 @@ discard block |
||
| 818 | 883 | $month = ''; |
| 819 | 884 | $day = ''; |
| 820 | 885 | if (($num_results = sscanf($eventOptions['start_date'], '%d-%d-%d', $year, $month, $day)) !== 3) |
| 821 | - trigger_error('insertEvent(): invalid start date format given', E_USER_ERROR); |
|
| 886 | + { |
|
| 887 | + trigger_error('insertEvent(): invalid start date format given', E_USER_ERROR); |
|
| 888 | + } |
|
| 822 | 889 | |
| 823 | 890 | // Set the end date (if not yet given) |
| 824 | 891 | if (!isset($eventOptions['end_date'])) |
| 825 | - $eventOptions['end_date'] = Util::strftime('%Y-%m-%d', mktime(0, 0, 0, $month, $day, $year) + $eventOptions['span'] * 86400); |
|
| 892 | + { |
|
| 893 | + $eventOptions['end_date'] = Util::strftime('%Y-%m-%d', mktime(0, 0, 0, $month, $day, $year) + $eventOptions['span'] * 86400); |
|
| 894 | + } |
|
| 826 | 895 | |
| 827 | 896 | // If no topic and board are given, they are not linked to a topic. |
| 828 | 897 | $eventOptions['id_board'] = isset($eventOptions['id_board']) ? (int) $eventOptions['id_board'] : 0; |
@@ -878,14 +947,18 @@ discard block |
||
| 878 | 947 | $month = ''; |
| 879 | 948 | $day = ''; |
| 880 | 949 | if (($num_results = sscanf($eventOptions['start_date'], '%d-%d-%d', $year, $month, $day)) !== 3) |
| 881 | - trigger_error('modifyEvent(): invalid start date format given', E_USER_ERROR); |
|
| 950 | + { |
|
| 951 | + trigger_error('modifyEvent(): invalid start date format given', E_USER_ERROR); |
|
| 952 | + } |
|
| 882 | 953 | |
| 883 | 954 | // Default span to 0 days. |
| 884 | 955 | $eventOptions['span'] = isset($eventOptions['span']) ? (int) $eventOptions['span'] : 0; |
| 885 | 956 | |
| 886 | 957 | // Set the end date to the start date + span (if the end date wasn't already given). |
| 887 | 958 | if (!isset($eventOptions['end_date'])) |
| 888 | - $eventOptions['end_date'] = Util::strftime('%Y-%m-%d', mktime(0, 0, 0, $month, $day, $year) + $eventOptions['span'] * 86400); |
|
| 959 | + { |
|
| 960 | + $eventOptions['end_date'] = Util::strftime('%Y-%m-%d', mktime(0, 0, 0, $month, $day, $year) + $eventOptions['span'] * 86400); |
|
| 961 | + } |
|
| 889 | 962 | |
| 890 | 963 | $event_columns = array( |
| 891 | 964 | 'start_date' => 'start_date = {date:start_date}', |
@@ -901,11 +974,15 @@ discard block |
||
| 901 | 974 | |
| 902 | 975 | $to_update = array(); |
| 903 | 976 | foreach ($event_columns as $key => $value) |
| 904 | - if (isset($eventOptions[$key])) |
|
| 977 | + { |
|
| 978 | + if (isset($eventOptions[$key])) |
|
| 905 | 979 | $to_update[] = $value; |
| 980 | + } |
|
| 906 | 981 | |
| 907 | 982 | if (empty($to_update)) |
| 908 | - return; |
|
| 983 | + { |
|
| 984 | + return; |
|
| 985 | + } |
|
| 909 | 986 | |
| 910 | 987 | $db->query('', ' |
| 911 | 988 | UPDATE {db_prefix}calendar |
@@ -979,13 +1056,17 @@ discard block |
||
| 979 | 1056 | |
| 980 | 1057 | // If nothing returned, we are in poo, poo. |
| 981 | 1058 | if ($db->num_rows($request) === 0) |
| 982 | - return false; |
|
| 1059 | + { |
|
| 1060 | + return false; |
|
| 1061 | + } |
|
| 983 | 1062 | |
| 984 | 1063 | $row = $db->fetch_assoc($request); |
| 985 | 1064 | $db->free_result($request); |
| 986 | 1065 | |
| 987 | 1066 | if ($calendar_only) |
| 988 | - $return_value = $row; |
|
| 1067 | + { |
|
| 1068 | + $return_value = $row; |
|
| 1069 | + } |
|
| 989 | 1070 | else |
| 990 | 1071 | { |
| 991 | 1072 | $return_value = array( |
@@ -1094,7 +1175,9 @@ discard block |
||
| 1094 | 1175 | $db = database(); |
| 1095 | 1176 | |
| 1096 | 1177 | if (!is_array($holiday_ids)) |
| 1097 | - $holiday_ids = array($holiday_ids); |
|
| 1178 | + { |
|
| 1179 | + $holiday_ids = array($holiday_ids); |
|
| 1180 | + } |
|
| 1098 | 1181 | |
| 1099 | 1182 | $db->query('', ' |
| 1100 | 1183 | DELETE FROM {db_prefix}calendar_holidays |
@@ -1185,13 +1268,15 @@ discard block |
||
| 1185 | 1268 | ) |
| 1186 | 1269 | ); |
| 1187 | 1270 | while ($row = $db->fetch_assoc($request)) |
| 1188 | - $holiday = array( |
|
| 1271 | + { |
|
| 1272 | + $holiday = array( |
|
| 1189 | 1273 | 'id' => $row['id_holiday'], |
| 1190 | 1274 | 'day' => $row['day'], |
| 1191 | 1275 | 'month' => $row['month'], |
| 1192 | 1276 | 'year' => $row['year'] <= 4 ? 0 : $row['year'], |
| 1193 | 1277 | 'title' => $row['title'] |
| 1194 | 1278 | ); |
| 1279 | + } |
|
| 1195 | 1280 | $db->free_result($request); |
| 1196 | 1281 | |
| 1197 | 1282 | return $holiday; |
@@ -1219,7 +1304,9 @@ discard block |
||
| 1219 | 1304 | foreach ($title as $id => $line) |
| 1220 | 1305 | { |
| 1221 | 1306 | if ($id != 0) |
| 1222 | - $title[$id] = ' ' . $title[$id]; |
|
| 1307 | + { |
|
| 1308 | + $title[$id] = ' ' . $title[$id]; |
|
| 1309 | + } |
|
| 1223 | 1310 | $title[$id] .= "\n"; |
| 1224 | 1311 | } |
| 1225 | 1312 | |
@@ -1248,11 +1335,15 @@ discard block |
||
| 1248 | 1335 | |
| 1249 | 1336 | // more than one day |
| 1250 | 1337 | if ($event['span'] > 1) |
| 1251 | - $filecontents .= 'DTEND;VALUE=DATE:' . $dateend . "\n"; |
|
| 1338 | + { |
|
| 1339 | + $filecontents .= 'DTEND;VALUE=DATE:' . $dateend . "\n"; |
|
| 1340 | + } |
|
| 1252 | 1341 | |
| 1253 | 1342 | // event has changed? advance the sequence for this UID |
| 1254 | 1343 | if ($event['sequence'] > 0) |
| 1255 | - $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
| 1344 | + { |
|
| 1345 | + $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
| 1346 | + } |
|
| 1256 | 1347 | |
| 1257 | 1348 | $filecontents .= 'SUMMARY:' . implode('', $title); |
| 1258 | 1349 | $filecontents .= 'UID:' . $event['eventid'] . '@' . str_replace(' ', '-', $mbname) . "\n"; |
@@ -28,7 +28,9 @@ discard block |
||
| 28 | 28 | $db = database(); |
| 29 | 29 | |
| 30 | 30 | if (isset($_SESSION['id_robot'])) |
| 31 | - unset($_SESSION['id_robot']); |
|
| 31 | + { |
|
| 32 | + unset($_SESSION['id_robot']); |
|
| 33 | + } |
|
| 32 | 34 | |
| 33 | 35 | $_SESSION['robot_check'] = time(); |
| 34 | 36 | |
@@ -45,7 +47,9 @@ discard block |
||
| 45 | 47 | ) |
| 46 | 48 | ); |
| 47 | 49 | while ($row = $db->fetch_assoc($request)) |
| 48 | - $spider_data[] = $row; |
|
| 50 | + { |
|
| 51 | + $spider_data[] = $row; |
|
| 52 | + } |
|
| 49 | 53 | $db->free_result($request); |
| 50 | 54 | |
| 51 | 55 | // Save it in the cache |
@@ -53,23 +57,30 @@ discard block |
||
| 53 | 57 | } |
| 54 | 58 | |
| 55 | 59 | if (empty($spider_data)) |
| 56 | - return false; |
|
| 60 | + { |
|
| 61 | + return false; |
|
| 62 | + } |
|
| 57 | 63 | |
| 58 | 64 | // We need the user agent |
| 59 | 65 | $req = request(); |
| 60 | 66 | |
| 61 | 67 | // Always attempt IPv6 first. |
| 62 | 68 | if (strpos($_SERVER['REMOTE_ADDR'], ':') !== false) |
| 63 | - $ip_parts = convertIPv6toInts($_SERVER['REMOTE_ADDR']); |
|
| 69 | + { |
|
| 70 | + $ip_parts = convertIPv6toInts($_SERVER['REMOTE_ADDR']); |
|
| 71 | + } |
|
| 64 | 72 | // Then xxx.xxx.xxx.xxx next |
| 65 | - else |
|
| 66 | - preg_match('/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $_SERVER['REMOTE_ADDR'], $ip_parts); |
|
| 73 | + else { |
|
| 74 | + preg_match('/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $_SERVER['REMOTE_ADDR'], $ip_parts); |
|
| 75 | + } |
|
| 67 | 76 | |
| 68 | 77 | foreach ($spider_data as $spider) |
| 69 | 78 | { |
| 70 | 79 | // User agent is easy. |
| 71 | 80 | if (!empty($spider['user_agent']) && strpos(strtolower($req->user_agent()), strtolower($spider['user_agent'])) !== false) |
| 72 | - $_SESSION['id_robot'] = $spider['id_spider']; |
|
| 81 | + { |
|
| 82 | + $_SESSION['id_robot'] = $spider['id_spider']; |
|
| 83 | + } |
|
| 73 | 84 | // IP stuff is harder. |
| 74 | 85 | elseif (!empty($ip_parts)) |
| 75 | 86 | { |
@@ -82,21 +93,29 @@ discard block |
||
| 82 | 93 | foreach ($ip as $key => $value) |
| 83 | 94 | { |
| 84 | 95 | if ($value['low'] > $ip_parts[$key + 1] || $value['high'] < $ip_parts[$key + 1]) |
| 85 | - break; |
|
| 96 | + { |
|
| 97 | + break; |
|
| 98 | + } |
|
| 86 | 99 | elseif (($key == 7 && strpos($_SERVER['REMOTE_ADDR'], ':') !== false) || ($key == 3 && strpos($_SERVER['REMOTE_ADDR'], ':') === false)) |
| 87 | - $_SESSION['id_robot'] = $spider['id_spider']; |
|
| 100 | + { |
|
| 101 | + $_SESSION['id_robot'] = $spider['id_spider']; |
|
| 102 | + } |
|
| 88 | 103 | } |
| 89 | 104 | } |
| 90 | 105 | } |
| 91 | 106 | } |
| 92 | 107 | |
| 93 | 108 | if (isset($_SESSION['id_robot'])) |
| 94 | - break; |
|
| 109 | + { |
|
| 110 | + break; |
|
| 111 | + } |
|
| 95 | 112 | } |
| 96 | 113 | |
| 97 | 114 | // If this is low server tracking then log the spider here as opposed to the main logging function. |
| 98 | 115 | if (!empty($modSettings['spider_mode']) && $modSettings['spider_mode'] == 1 && !empty($_SESSION['id_robot'])) |
| 99 | - logSpider(); |
|
| 116 | + { |
|
| 117 | + logSpider(); |
|
| 118 | + } |
|
| 100 | 119 | |
| 101 | 120 | return !empty($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
| 102 | 121 | } |
@@ -113,7 +132,9 @@ discard block |
||
| 113 | 132 | $db = database(); |
| 114 | 133 | |
| 115 | 134 | if (empty($modSettings['spider_mode']) || empty($_SESSION['id_robot'])) |
| 116 | - return; |
|
| 135 | + { |
|
| 136 | + return; |
|
| 137 | + } |
|
| 117 | 138 | |
| 118 | 139 | // Attempt to update today's entry. |
| 119 | 140 | if ($modSettings['spider_mode'] == 1) |
@@ -152,13 +173,17 @@ discard block |
||
| 152 | 173 | { |
| 153 | 174 | $url = $_GET; |
| 154 | 175 | if (isset($context['session_var'])) |
| 155 | - unset($url['sesc'], $url[$context['session_var']]); |
|
| 156 | - else |
|
| 157 | - unset($url['sesc']); |
|
| 176 | + { |
|
| 177 | + unset($url['sesc'], $url[$context['session_var']]); |
|
| 178 | + } |
|
| 179 | + else { |
|
| 180 | + unset($url['sesc']); |
|
| 181 | + } |
|
| 158 | 182 | $url = serialize($url); |
| 159 | 183 | } |
| 160 | - else |
|
| 161 | - $url = ''; |
|
| 184 | + else { |
|
| 185 | + $url = ''; |
|
| 186 | + } |
|
| 162 | 187 | |
| 163 | 188 | $db->insert('insert', |
| 164 | 189 | '{db_prefix}log_spider_hits', |
@@ -189,11 +214,15 @@ discard block |
||
| 189 | 214 | ); |
| 190 | 215 | $spider_hits = array(); |
| 191 | 216 | while ($row = $db->fetch_assoc($request)) |
| 192 | - $spider_hits[] = $row; |
|
| 217 | + { |
|
| 218 | + $spider_hits[] = $row; |
|
| 219 | + } |
|
| 193 | 220 | $db->free_result($request); |
| 194 | 221 | |
| 195 | 222 | if (empty($spider_hits)) |
| 196 | - return; |
|
| 223 | + { |
|
| 224 | + return; |
|
| 225 | + } |
|
| 197 | 226 | |
| 198 | 227 | // Attempt to update the master data. |
| 199 | 228 | $stat_inserts = array(); |
@@ -214,17 +243,21 @@ discard block |
||
| 214 | 243 | ) |
| 215 | 244 | ); |
| 216 | 245 | if ($db->affected_rows() == 0) |
| 217 | - $stat_inserts[] = array($date, $stat['id_spider'], $stat['num_hits'], $stat['last_seen']); |
|
| 246 | + { |
|
| 247 | + $stat_inserts[] = array($date, $stat['id_spider'], $stat['num_hits'], $stat['last_seen']); |
|
| 248 | + } |
|
| 218 | 249 | } |
| 219 | 250 | |
| 220 | 251 | // New stats? |
| 221 | 252 | if (!empty($stat_inserts)) |
| 222 | - $db->insert('ignore', |
|
| 253 | + { |
|
| 254 | + $db->insert('ignore', |
|
| 223 | 255 | '{db_prefix}log_spider_stats', |
| 224 | 256 | array('stat_date' => 'date', 'id_spider' => 'int', 'page_hits' => 'int', 'last_seen' => 'int'), |
| 225 | 257 | $stat_inserts, |
| 226 | 258 | array('stat_date', 'id_spider') |
| 227 | 259 | ); |
| 260 | + } |
|
| 228 | 261 | |
| 229 | 262 | // All processed. |
| 230 | 263 | $db->query('', ' |
@@ -255,7 +288,9 @@ discard block |
||
| 255 | 288 | ); |
| 256 | 289 | $spiders = array(); |
| 257 | 290 | while ($row = $db->fetch_assoc($request)) |
| 258 | - $spiders[$row['id_spider']] = $row['spider_name']; |
|
| 291 | + { |
|
| 292 | + $spiders[$row['id_spider']] = $row['spider_name']; |
|
| 293 | + } |
|
| 259 | 294 | $db->free_result($request); |
| 260 | 295 | |
| 261 | 296 | updateSettings(array('spider_name_cache' => serialize($spiders))); |
@@ -306,7 +341,9 @@ discard block |
||
| 306 | 341 | ); |
| 307 | 342 | $spiders = array(); |
| 308 | 343 | while ($row = $db->fetch_assoc($request)) |
| 309 | - $spiders[$row['id_spider']] = $row; |
|
| 344 | + { |
|
| 345 | + $spiders[$row['id_spider']] = $row; |
|
| 346 | + } |
|
| 310 | 347 | $db->free_result($request); |
| 311 | 348 | |
| 312 | 349 | return $spiders; |
@@ -386,7 +423,9 @@ discard block |
||
| 386 | 423 | ); |
| 387 | 424 | $spider_logs = array(); |
| 388 | 425 | while ($row = $db->fetch_assoc($request)) |
| 389 | - $spider_logs[] = $row; |
|
| 426 | + { |
|
| 427 | + $spider_logs[] = $row; |
|
| 428 | + } |
|
| 390 | 429 | $db->free_result($request); |
| 391 | 430 | |
| 392 | 431 | return $spider_logs; |
@@ -440,7 +479,9 @@ discard block |
||
| 440 | 479 | ); |
| 441 | 480 | $spider_stats = array(); |
| 442 | 481 | while ($row = $db->fetch_assoc($request)) |
| 443 | - $spider_stats[] = $row; |
|
| 482 | + { |
|
| 483 | + $spider_stats[] = $row; |
|
| 484 | + } |
|
| 444 | 485 | $db->free_result($request); |
| 445 | 486 | |
| 446 | 487 | return $spider_stats; |
@@ -564,7 +605,9 @@ discard block |
||
| 564 | 605 | |
| 565 | 606 | $spider_last_seen = array(); |
| 566 | 607 | while ($row = $db->fetch_assoc($request)) |
| 567 | - $spider_last_seen[$row['id_spider']] = $row['last_seen_time']; |
|
| 608 | + { |
|
| 609 | + $spider_last_seen[$row['id_spider']] = $row['last_seen_time']; |
|
| 610 | + } |
|
| 568 | 611 | $db->free_result($request); |
| 569 | 612 | |
| 570 | 613 | return $spider_last_seen; |
@@ -600,13 +643,20 @@ discard block |
||
| 600 | 643 | // Prepare the dates for the drop down. |
| 601 | 644 | $date_choices = array(); |
| 602 | 645 | for ($y = $min_year; $y <= $max_year; $y++) |
| 603 | - for ($m = 1; $m <= 12; $m++) |
|
| 646 | + { |
|
| 647 | + for ($m = 1; |
|
| 648 | + } |
|
| 649 | + $m <= 12; $m++) |
|
| 604 | 650 | { |
| 605 | 651 | // This doesn't count? |
| 606 | 652 | if ($y == $min_year && $m < $min_month) |
| 607 | - continue; |
|
| 653 | + { |
|
| 654 | + continue; |
|
| 655 | + } |
|
| 608 | 656 | if ($y == $max_year && $m > $max_month) |
| 609 | - break; |
|
| 657 | + { |
|
| 658 | + break; |
|
| 659 | + } |
|
| 610 | 660 | |
| 611 | 661 | $date_choices[$y . $m] = $txt['months_short'][$m] . ' ' . $y; |
| 612 | 662 | } |
@@ -629,7 +679,8 @@ discard block |
||
| 629 | 679 | |
| 630 | 680 | // New spider, insert |
| 631 | 681 | if (empty($id)) |
| 632 | - $db->insert('insert', |
|
| 682 | + { |
|
| 683 | + $db->insert('insert', |
|
| 633 | 684 | '{db_prefix}spiders', |
| 634 | 685 | array( |
| 635 | 686 | 'spider_name' => 'string', 'user_agent' => 'string', 'ip_info' => 'string', |
@@ -639,9 +690,10 @@ discard block |
||
| 639 | 690 | ), |
| 640 | 691 | array('id_spider') |
| 641 | 692 | ); |
| 693 | + } |
|
| 642 | 694 | // Existing spider update |
| 643 | - else |
|
| 644 | - $db->query('', ' |
|
| 695 | + else { |
|
| 696 | + $db->query('', ' |
|
| 645 | 697 | UPDATE {db_prefix}spiders |
| 646 | 698 | SET spider_name = {string:spider_name}, user_agent = {string:spider_agent}, |
| 647 | 699 | ip_info = {string:ip_info} |
@@ -653,4 +705,5 @@ discard block |
||
| 653 | 705 | 'ip_info' => $info_ip, |
| 654 | 706 | ) |
| 655 | 707 | ); |
| 656 | -} |
|
| 657 | 708 | \ No newline at end of file |
| 709 | + } |
|
| 710 | + } |
|
| 658 | 711 | \ No newline at end of file |
@@ -31,17 +31,24 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | // If we already know who we're dealing with |
| 33 | 33 | if (isset($memID) && !$reload_id) |
| 34 | - return $memID; |
|
| 34 | + { |
|
| 35 | + return $memID; |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // Did we get the user by name... |
| 37 | 39 | if (isset($_REQUEST['user'])) |
| 38 | - $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
| 40 | + { |
|
| 41 | + $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
| 42 | + } |
|
| 39 | 43 | // ... or by id_member? |
| 40 | 44 | elseif (!empty($_REQUEST['u'])) |
| 41 | - $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
| 45 | + { |
|
| 46 | + $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
| 47 | + } |
|
| 42 | 48 | // If it was just ?action=profile, edit your own profile. |
| 43 | - else |
|
| 44 | - $memberResult = loadMemberData($user_info['id'], false, 'profile'); |
|
| 49 | + else { |
|
| 50 | + $memberResult = loadMemberData($user_info['id'], false, 'profile'); |
|
| 51 | + } |
|
| 45 | 52 | |
| 46 | 53 | // Check if loadMemberData() has returned a valid result. |
| 47 | 54 | if (!is_array($memberResult)) |
@@ -50,9 +57,12 @@ discard block |
||
| 50 | 57 | is_not_guest('', $fatal); |
| 51 | 58 | |
| 52 | 59 | if ($fatal) |
| 53 | - throw new Elk_Exception('not_a_user', false); |
|
| 54 | - else |
|
| 55 | - return false; |
|
| 60 | + { |
|
| 61 | + throw new Elk_Exception('not_a_user', false); |
|
| 62 | + } |
|
| 63 | + else { |
|
| 64 | + return false; |
|
| 65 | + } |
|
| 56 | 66 | } |
| 57 | 67 | |
| 58 | 68 | // If all went well, we have a valid member ID! |
@@ -72,15 +82,19 @@ discard block |
||
| 72 | 82 | global $profile_fields, $context, $cur_profile, $txt; |
| 73 | 83 | |
| 74 | 84 | if (!empty($hook)) |
| 75 | - call_integration_hook('integrate_' . $hook . '_profile_fields', array(&$fields)); |
|
| 85 | + { |
|
| 86 | + call_integration_hook('integrate_' . $hook . '_profile_fields', array(&$fields)); |
|
| 87 | + } |
|
| 76 | 88 | |
| 77 | 89 | // Make sure we have this! |
| 78 | 90 | loadProfileFields(true); |
| 79 | 91 | |
| 80 | 92 | // First check for any linked sets. |
| 81 | 93 | foreach ($profile_fields as $key => $field) |
| 82 | - if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
| 94 | + { |
|
| 95 | + if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
| 83 | 96 | $fields[] = $key; |
| 97 | + } |
|
| 84 | 98 | |
| 85 | 99 | // Some default bits. |
| 86 | 100 | $context['profile_prehtml'] = ''; |
@@ -98,17 +112,23 @@ discard block |
||
| 98 | 112 | |
| 99 | 113 | // Does it have a preload and does that preload succeed? |
| 100 | 114 | if (isset($cur_field['preload']) && !$cur_field['preload']()) |
| 101 | - continue; |
|
| 115 | + { |
|
| 116 | + continue; |
|
| 117 | + } |
|
| 102 | 118 | |
| 103 | 119 | // If this is anything but complex we need to do more cleaning! |
| 104 | 120 | if ($cur_field['type'] !== 'callback' && $cur_field['type'] !== 'hidden') |
| 105 | 121 | { |
| 106 | 122 | if (!isset($cur_field['label'])) |
| 107 | - $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
| 123 | + { |
|
| 124 | + $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
| 125 | + } |
|
| 108 | 126 | |
| 109 | 127 | // Everything has a value! |
| 110 | 128 | if (!isset($cur_field['value'])) |
| 111 | - $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
| 129 | + { |
|
| 130 | + $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
| 131 | + } |
|
| 112 | 132 | |
| 113 | 133 | // Any input attributes? |
| 114 | 134 | $cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : ''; |
@@ -116,21 +136,33 @@ discard block |
||
| 116 | 136 | |
| 117 | 137 | // Was there an error with this field on posting? |
| 118 | 138 | if (isset($context['post_errors'][$field])) |
| 119 | - $cur_field['is_error'] = true; |
|
| 139 | + { |
|
| 140 | + $cur_field['is_error'] = true; |
|
| 141 | + } |
|
| 120 | 142 | |
| 121 | 143 | // Any javascript stuff? |
| 122 | 144 | if (!empty($cur_field['js_submit'])) |
| 123 | - $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
| 145 | + { |
|
| 146 | + $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
| 147 | + } |
|
| 124 | 148 | if (!empty($cur_field['js'])) |
| 125 | - addInlineJavascript($cur_field['js']); |
|
| 149 | + { |
|
| 150 | + addInlineJavascript($cur_field['js']); |
|
| 151 | + } |
|
| 126 | 152 | if (!empty($cur_field['js_load'])) |
| 127 | - loadJavascriptFile($cur_field['js_load']); |
|
| 153 | + { |
|
| 154 | + loadJavascriptFile($cur_field['js_load']); |
|
| 155 | + } |
|
| 128 | 156 | |
| 129 | 157 | // Any template stuff? |
| 130 | 158 | if (!empty($cur_field['prehtml'])) |
| 131 | - $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
| 159 | + { |
|
| 160 | + $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
| 161 | + } |
|
| 132 | 162 | if (!empty($cur_field['posthtml'])) |
| 133 | - $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
| 163 | + { |
|
| 164 | + $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
| 165 | + } |
|
| 134 | 166 | |
| 135 | 167 | // Finally put it into context? |
| 136 | 168 | if ($cur_field['type'] !== 'hidden') |
@@ -171,15 +203,22 @@ discard block |
||
| 171 | 203 | { |
| 172 | 204 | // If it's the owner they can see two types of private fields, regardless. |
| 173 | 205 | if ($memID == $user_info['id']) |
| 174 | - $where .= $area === 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
| 175 | - else |
|
| 176 | - $where .= $area === 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
| 206 | + { |
|
| 207 | + $where .= $area === 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
| 208 | + } |
|
| 209 | + else { |
|
| 210 | + $where .= $area === 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
| 211 | + } |
|
| 177 | 212 | } |
| 178 | 213 | |
| 179 | 214 | if ($area === 'register') |
| 180 | - $where .= ' AND show_reg != 0'; |
|
| 215 | + { |
|
| 216 | + $where .= ' AND show_reg != 0'; |
|
| 217 | + } |
|
| 181 | 218 | elseif ($area !== 'summary') |
| 182 | - $where .= ' AND show_profile = {string:area}'; |
|
| 219 | + { |
|
| 220 | + $where .= ' AND show_profile = {string:area}'; |
|
| 221 | + } |
|
| 183 | 222 | |
| 184 | 223 | // Load all the relevant fields - and data. |
| 185 | 224 | // The fully-qualified name for rows is here because it's a reserved word in Mariadb 10.2.4+ and quoting would be different for MySQL/Mariadb and PSQL |
@@ -274,10 +313,14 @@ discard block |
||
| 274 | 313 | |
| 275 | 314 | // Parse BBCode |
| 276 | 315 | if ($row['bbc']) |
| 277 | - $output_html = $bbc_parser->parseCustomFields($output_html); |
|
| 316 | + { |
|
| 317 | + $output_html = $bbc_parser->parseCustomFields($output_html); |
|
| 318 | + } |
|
| 278 | 319 | // Allow for newlines at least |
| 279 | 320 | elseif ($row['field_type'] === 'textarea') |
| 280 | - $output_html = strtr($output_html, array("\n" => '<br />')); |
|
| 321 | + { |
|
| 322 | + $output_html = strtr($output_html, array("\n" => '<br />')); |
|
| 323 | + } |
|
| 281 | 324 | |
| 282 | 325 | // Enclosing the user input within some other text? |
| 283 | 326 | if (!empty($row['enclose']) && !empty($output_html)) |
@@ -333,7 +376,9 @@ discard block |
||
| 333 | 376 | |
| 334 | 377 | // Don't load this twice! |
| 335 | 378 | if (!empty($profile_fields) && !$force_reload) |
| 336 | - return; |
|
| 379 | + { |
|
| 380 | + return; |
|
| 381 | + } |
|
| 337 | 382 | |
| 338 | 383 | /** |
| 339 | 384 | * This horrific array defines all the profile fields in the whole world! |
@@ -414,12 +459,16 @@ discard block |
||
| 414 | 459 | { |
| 415 | 460 | // Set to blank? |
| 416 | 461 | if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) |
| 417 | - $value = '0001-01-01'; |
|
| 418 | - else |
|
| 419 | - $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 4 ? 4 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 4 ? 4 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '0001-01-01'; |
|
| 462 | + { |
|
| 463 | + $value = '0001-01-01'; |
|
| 464 | + } |
|
| 465 | + else { |
|
| 466 | + $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 4 ? 4 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 4 ? 4 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '0001-01-01'; |
|
| 467 | + } |
|
| 468 | + } |
|
| 469 | + else { |
|
| 470 | + $value = '0001-01-01'; |
|
| 420 | 471 | } |
| 421 | - else |
|
| 422 | - $value = '0001-01-01'; |
|
| 423 | 472 | |
| 424 | 473 | $profile_vars['birthdate'] = $value; |
| 425 | 474 | $cur_profile['birthdate'] = $value; |
@@ -463,9 +512,12 @@ discard block |
||
| 463 | 512 | } |
| 464 | 513 | // As long as it doesn't equal "N/A"... |
| 465 | 514 | elseif ($value != $txt['not_applicable'] && $value != strtotime(Util::strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) |
| 466 | - $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 467 | - else |
|
| 468 | - $value = $cur_profile['date_registered']; |
|
| 515 | + { |
|
| 516 | + $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 517 | + } |
|
| 518 | + else { |
|
| 519 | + $value = $cur_profile['date_registered']; |
|
| 520 | + } |
|
| 469 | 521 | |
| 470 | 522 | return true; |
| 471 | 523 | }, |
@@ -480,7 +532,9 @@ discard block |
||
| 480 | 532 | global $context, $old_profile, $profile_vars, $modSettings; |
| 481 | 533 | |
| 482 | 534 | if (strtolower($value) == strtolower($old_profile['email_address'])) |
| 483 | - return false; |
|
| 535 | + { |
|
| 536 | + return false; |
|
| 537 | + } |
|
| 484 | 538 | |
| 485 | 539 | $isValid = profileValidateEmail($value, $context['id_member']); |
| 486 | 540 | |
@@ -595,7 +649,9 @@ discard block |
||
| 595 | 649 | if (isset($context['profile_languages'][$value])) |
| 596 | 650 | { |
| 597 | 651 | if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) |
| 598 | - $_SESSION['language'] = $value; |
|
| 652 | + { |
|
| 653 | + $_SESSION['language'] = $value; |
|
| 654 | + } |
|
| 599 | 655 | return true; |
| 600 | 656 | } |
| 601 | 657 | else |
@@ -641,14 +697,18 @@ discard block |
||
| 641 | 697 | |
| 642 | 698 | // No errors we can proceed normally |
| 643 | 699 | if (!$errors->hasErrors()) |
| 644 | - updateMemberData($context['id_member'], array('member_name' => $value)); |
|
| 700 | + { |
|
| 701 | + updateMemberData($context['id_member'], array('member_name' => $value)); |
|
| 702 | + } |
|
| 645 | 703 | else |
| 646 | 704 | { |
| 647 | 705 | // If there are "important" errors and you are not an admin: log the first error |
| 648 | 706 | // Otherwise grab all of them and do not log anything |
| 649 | 707 | $error_severity = $errors->hasErrors(1) && !$user_info['is_admin'] ? 1 : null; |
| 650 | 708 | foreach ($errors->prepareErrors($error_severity) as $error) |
| 651 | - throw new Elk_Exception($error, $error_severity === null ? false : 'general'); |
|
| 709 | + { |
|
| 710 | + throw new Elk_Exception($error, $error_severity === null ? false : 'general'); |
|
| 711 | + } |
|
| 652 | 712 | } |
| 653 | 713 | } |
| 654 | 714 | } |
@@ -670,11 +730,15 @@ discard block |
||
| 670 | 730 | |
| 671 | 731 | // If we didn't try it then ignore it! |
| 672 | 732 | if ($value == '') |
| 673 | - return false; |
|
| 733 | + { |
|
| 734 | + return false; |
|
| 735 | + } |
|
| 674 | 736 | |
| 675 | 737 | // Do the two entries for the password even match? |
| 676 | 738 | if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) |
| 677 | - return 'bad_new_password'; |
|
| 739 | + { |
|
| 740 | + return 'bad_new_password'; |
|
| 741 | + } |
|
| 678 | 742 | |
| 679 | 743 | // Let's get the validation function into play... |
| 680 | 744 | require_once(SUBSDIR . '/Auth.subs.php'); |
@@ -682,7 +746,9 @@ discard block |
||
| 682 | 746 | |
| 683 | 747 | // Were there errors? |
| 684 | 748 | if ($passwordErrors !== null) |
| 685 | - return 'password_' . $passwordErrors; |
|
| 749 | + { |
|
| 750 | + return 'password_' . $passwordErrors; |
|
| 751 | + } |
|
| 686 | 752 | |
| 687 | 753 | // Set up the new password variable... ready for storage. |
| 688 | 754 | require_once(SUBSDIR . '/Auth.subs.php'); |
@@ -771,9 +837,12 @@ discard block |
||
| 771 | 837 | 'permission' => 'moderate_forum', |
| 772 | 838 | 'input_validate' => function (&$value) { |
| 773 | 839 | if (!is_numeric($value)) |
| 774 | - return 'digits_only'; |
|
| 775 | - else |
|
| 776 | - $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
| 840 | + { |
|
| 841 | + return 'digits_only'; |
|
| 842 | + } |
|
| 843 | + else { |
|
| 844 | + $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
| 845 | + } |
|
| 777 | 846 | return true; |
| 778 | 847 | }, |
| 779 | 848 | ), |
@@ -791,14 +860,20 @@ discard block |
||
| 791 | 860 | $value = trim(preg_replace('~[\s]~u', ' ', $value)); |
| 792 | 861 | |
| 793 | 862 | if (trim($value) == '') |
| 794 | - return 'no_name'; |
|
| 863 | + { |
|
| 864 | + return 'no_name'; |
|
| 865 | + } |
|
| 795 | 866 | elseif (Util::strlen($value) > 60) |
| 796 | - return 'name_too_long'; |
|
| 867 | + { |
|
| 868 | + return 'name_too_long'; |
|
| 869 | + } |
|
| 797 | 870 | elseif ($cur_profile['real_name'] != $value) |
| 798 | 871 | { |
| 799 | 872 | require_once(SUBSDIR . '/Members.subs.php'); |
| 800 | 873 | if (isReservedName($value, $context['id_member'])) |
| 801 | - return 'name_taken'; |
|
| 874 | + { |
|
| 875 | + return 'name_taken'; |
|
| 876 | + } |
|
| 802 | 877 | } |
| 803 | 878 | return true; |
| 804 | 879 | }, |
@@ -877,7 +952,9 @@ discard block |
||
| 877 | 952 | ); |
| 878 | 953 | |
| 879 | 954 | if ($context['smiley_sets'][$i]['selected']) |
| 880 | - $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
| 955 | + { |
|
| 956 | + $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
| 957 | + } |
|
| 881 | 958 | } |
| 882 | 959 | return true; |
| 883 | 960 | }, |
@@ -886,7 +963,9 @@ discard block |
||
| 886 | 963 | |
| 887 | 964 | $smiley_sets = explode(',', $modSettings['smiley_sets_known']); |
| 888 | 965 | if (!in_array($value, $smiley_sets) && $value !== 'none') |
| 889 | - $value = ''; |
|
| 966 | + { |
|
| 967 | + $value = ''; |
|
| 968 | + } |
|
| 890 | 969 | return true; |
| 891 | 970 | }, |
| 892 | 971 | ), |
@@ -904,7 +983,9 @@ discard block |
||
| 904 | 983 | // Can they disable censoring? |
| 905 | 984 | $context['allow_no_censored'] = false; |
| 906 | 985 | if ($user_info['is_admin'] || $context['user']['is_owner']) |
| 907 | - $context['allow_no_censored'] = allowedTo('disable_censor'); |
|
| 986 | + { |
|
| 987 | + $context['allow_no_censored'] = allowedTo('disable_censor'); |
|
| 988 | + } |
|
| 908 | 989 | |
| 909 | 990 | return true; |
| 910 | 991 | }, |
@@ -947,7 +1028,9 @@ discard block |
||
| 947 | 1028 | $value = (float) strtr($value, ',', '.'); |
| 948 | 1029 | |
| 949 | 1030 | if ($value < -23.5 || $value > 23.5) |
| 950 | - return 'bad_offset'; |
|
| 1031 | + { |
|
| 1032 | + return 'bad_offset'; |
|
| 1033 | + } |
|
| 951 | 1034 | |
| 952 | 1035 | return true; |
| 953 | 1036 | }, |
@@ -962,7 +1045,9 @@ discard block |
||
| 962 | 1045 | 'enabled' => !empty($modSettings['titlesEnable']), |
| 963 | 1046 | 'input_validate' => function (&$value) { |
| 964 | 1047 | if (Util::strlen($value) > 50) |
| 965 | - return 'user_title_too_long'; |
|
| 1048 | + { |
|
| 1049 | + return 'user_title_too_long'; |
|
| 1050 | + } |
|
| 966 | 1051 | |
| 967 | 1052 | return true; |
| 968 | 1053 | }, |
@@ -986,7 +1071,9 @@ discard block |
||
| 986 | 1071 | |
| 987 | 1072 | $value = addProtocol($value, array('http://', 'https://', 'ftp://', 'ftps://')); |
| 988 | 1073 | if (strlen($value) < 8) |
| 989 | - $value = ''; |
|
| 1074 | + { |
|
| 1075 | + $value = ''; |
|
| 1076 | + } |
|
| 990 | 1077 | return true; |
| 991 | 1078 | }, |
| 992 | 1079 | 'link_with' => 'website', |
@@ -1005,15 +1092,21 @@ discard block |
||
| 1005 | 1092 | { |
| 1006 | 1093 | // Do we have permission to do this? |
| 1007 | 1094 | if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) |
| 1008 | - unset($profile_fields[$key]); |
|
| 1095 | + { |
|
| 1096 | + unset($profile_fields[$key]); |
|
| 1097 | + } |
|
| 1009 | 1098 | |
| 1010 | 1099 | // Is it enabled? |
| 1011 | 1100 | if (isset($field['enabled']) && !$field['enabled']) |
| 1012 | - unset($profile_fields[$key]); |
|
| 1101 | + { |
|
| 1102 | + unset($profile_fields[$key]); |
|
| 1103 | + } |
|
| 1013 | 1104 | |
| 1014 | 1105 | // Is it specifically disabled? |
| 1015 | 1106 | if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) |
| 1016 | - unset($profile_fields[$key]); |
|
| 1107 | + { |
|
| 1108 | + unset($profile_fields[$key]); |
|
| 1109 | + } |
|
| 1017 | 1110 | } |
| 1018 | 1111 | } |
| 1019 | 1112 | |
@@ -1029,7 +1122,9 @@ discard block |
||
| 1029 | 1122 | global $profile_fields, $profile_vars, $context, $old_profile, $post_errors, $cur_profile; |
| 1030 | 1123 | |
| 1031 | 1124 | if (!empty($hook)) |
| 1032 | - call_integration_hook('integrate_' . $hook . '_profile_fields', array(&$fields)); |
|
| 1125 | + { |
|
| 1126 | + call_integration_hook('integrate_' . $hook . '_profile_fields', array(&$fields)); |
|
| 1127 | + } |
|
| 1033 | 1128 | |
| 1034 | 1129 | // Load them up. |
| 1035 | 1130 | loadProfileFields(); |
@@ -1041,7 +1136,9 @@ discard block |
||
| 1041 | 1136 | // - by default just to reload their settings |
| 1042 | 1137 | $context['profile_execute_on_save'] = array(); |
| 1043 | 1138 | if ($context['user']['is_owner']) |
| 1044 | - $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
| 1139 | + { |
|
| 1140 | + $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
| 1141 | + } |
|
| 1045 | 1142 | |
| 1046 | 1143 | // Assume we log nothing. |
| 1047 | 1144 | $context['log_changes'] = array(); |
@@ -1057,7 +1154,9 @@ discard block |
||
| 1057 | 1154 | $field = $profile_fields[$key]; |
| 1058 | 1155 | |
| 1059 | 1156 | if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key === 'signature')) |
| 1060 | - continue; |
|
| 1157 | + { |
|
| 1158 | + continue; |
|
| 1159 | + } |
|
| 1061 | 1160 | |
| 1062 | 1161 | // What gets updated? |
| 1063 | 1162 | $db_key = isset($field['save_key']) ? $field['save_key'] : $key; |
@@ -1088,11 +1187,17 @@ discard block |
||
| 1088 | 1187 | |
| 1089 | 1188 | // Finally, clean up certain types. |
| 1090 | 1189 | if ($field['cast_type'] === 'int') |
| 1091 | - $_POST[$key] = (int) $_POST[$key]; |
|
| 1190 | + { |
|
| 1191 | + $_POST[$key] = (int) $_POST[$key]; |
|
| 1192 | + } |
|
| 1092 | 1193 | elseif ($field['cast_type'] === 'float') |
| 1093 | - $_POST[$key] = (float) $_POST[$key]; |
|
| 1194 | + { |
|
| 1195 | + $_POST[$key] = (float) $_POST[$key]; |
|
| 1196 | + } |
|
| 1094 | 1197 | elseif ($field['cast_type'] === 'check') |
| 1095 | - $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
| 1198 | + { |
|
| 1199 | + $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
| 1200 | + } |
|
| 1096 | 1201 | |
| 1097 | 1202 | // If we got here we're doing OK. |
| 1098 | 1203 | if ($field['type'] !== 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key])) |
@@ -1105,10 +1210,12 @@ discard block |
||
| 1105 | 1210 | |
| 1106 | 1211 | // Are we logging it? |
| 1107 | 1212 | if (!empty($field['log_change']) && isset($old_profile[$key])) |
| 1108 | - $context['log_changes'][$key] = array( |
|
| 1213 | + { |
|
| 1214 | + $context['log_changes'][$key] = array( |
|
| 1109 | 1215 | 'previous' => $old_profile[$key], |
| 1110 | 1216 | 'new' => $_POST[$key], |
| 1111 | 1217 | ); |
| 1218 | + } |
|
| 1112 | 1219 | } |
| 1113 | 1220 | |
| 1114 | 1221 | // Logging group changes are a bit different... |
@@ -1142,9 +1249,12 @@ discard block |
||
| 1142 | 1249 | foreach ($groups as $id => $group) |
| 1143 | 1250 | { |
| 1144 | 1251 | if (isset($context['member_groups'][$group])) |
| 1145 | - $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
| 1146 | - else |
|
| 1147 | - unset($additional_groups[$type][$id]); |
|
| 1252 | + { |
|
| 1253 | + $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
| 1254 | + } |
|
| 1255 | + else { |
|
| 1256 | + unset($additional_groups[$type][$id]); |
|
| 1257 | + } |
|
| 1148 | 1258 | } |
| 1149 | 1259 | $additional_groups[$type] = implode(', ', $additional_groups[$type]); |
| 1150 | 1260 | } |
@@ -1156,15 +1266,20 @@ discard block |
||
| 1156 | 1266 | |
| 1157 | 1267 | // @todo Temporary |
| 1158 | 1268 | if ($context['user']['is_owner']) |
| 1159 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 1160 | - else |
|
| 1161 | - $changeOther = allowedTo('profile_extra_any'); |
|
| 1269 | + { |
|
| 1270 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 1271 | + } |
|
| 1272 | + else { |
|
| 1273 | + $changeOther = allowedTo('profile_extra_any'); |
|
| 1274 | + } |
|
| 1162 | 1275 | |
| 1163 | 1276 | if ($changeOther && empty($post_errors)) |
| 1164 | 1277 | { |
| 1165 | 1278 | makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
| 1166 | 1279 | if (!empty($_REQUEST['sa'])) |
| 1167 | - makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false); |
|
| 1280 | + { |
|
| 1281 | + makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false); |
|
| 1282 | + } |
|
| 1168 | 1283 | } |
| 1169 | 1284 | |
| 1170 | 1285 | // Free memory! |
@@ -1185,9 +1300,12 @@ discard block |
||
| 1185 | 1300 | $check = array(); |
| 1186 | 1301 | $check['email'] = strtr($email, array(''' => '\'')); |
| 1187 | 1302 | if (Data_Validator::is_valid($check, array('email' => 'valid_email|required'), array('email' => 'trim'))) |
| 1188 | - $email = $check['email']; |
|
| 1189 | - else |
|
| 1190 | - return empty($check['email']) ? 'no_email' : 'bad_email'; |
|
| 1303 | + { |
|
| 1304 | + $email = $check['email']; |
|
| 1305 | + } |
|
| 1306 | + else { |
|
| 1307 | + return empty($check['email']) ? 'no_email' : 'bad_email'; |
|
| 1308 | + } |
|
| 1191 | 1309 | |
| 1192 | 1310 | // Email addresses should be and stay unique. |
| 1193 | 1311 | $request = $db->query('', ' |
@@ -1223,9 +1341,12 @@ discard block |
||
| 1223 | 1341 | |
| 1224 | 1342 | // Permissions... |
| 1225 | 1343 | if ($context['user']['is_owner']) |
| 1226 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 1227 | - else |
|
| 1228 | - $changeOther = allowedTo('profile_extra_any'); |
|
| 1344 | + { |
|
| 1345 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 1346 | + } |
|
| 1347 | + else { |
|
| 1348 | + $changeOther = allowedTo('profile_extra_any'); |
|
| 1349 | + } |
|
| 1229 | 1350 | |
| 1230 | 1351 | // Arrays of all the changes - makes things easier. |
| 1231 | 1352 | $profile_bools = array( |
@@ -1249,7 +1370,9 @@ discard block |
||
| 1249 | 1370 | call_integration_hook('integrate_save_profile_changes', array(&$profile_bools, &$profile_ints, &$profile_floats, &$profile_strings)); |
| 1250 | 1371 | |
| 1251 | 1372 | if (isset($_POST['sa']) && $_POST['sa'] === 'ignoreboards' && empty($_POST['ignore_brd'])) |
| 1252 | - $_POST['ignore_brd'] = array(); |
|
| 1373 | + { |
|
| 1374 | + $_POST['ignore_brd'] = array(); |
|
| 1375 | + } |
|
| 1253 | 1376 | |
| 1254 | 1377 | // Whatever it is set to is a dirty filthy thing. Kinda like our minds. |
| 1255 | 1378 | unset($_POST['ignore_boards']); |
@@ -1257,15 +1380,20 @@ discard block |
||
| 1257 | 1380 | if (isset($_POST['ignore_brd'])) |
| 1258 | 1381 | { |
| 1259 | 1382 | if (!is_array($_POST['ignore_brd'])) |
| 1260 | - $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
| 1383 | + { |
|
| 1384 | + $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
| 1385 | + } |
|
| 1261 | 1386 | |
| 1262 | 1387 | foreach ($_POST['ignore_brd'] as $k => $d) |
| 1263 | 1388 | { |
| 1264 | 1389 | $d = (int) $d; |
| 1265 | 1390 | if ($d != 0) |
| 1266 | - $_POST['ignore_brd'][$k] = $d; |
|
| 1267 | - else |
|
| 1268 | - unset($_POST['ignore_brd'][$k]); |
|
| 1391 | + { |
|
| 1392 | + $_POST['ignore_brd'][$k] = $d; |
|
| 1393 | + } |
|
| 1394 | + else { |
|
| 1395 | + unset($_POST['ignore_brd'][$k]); |
|
| 1396 | + } |
|
| 1269 | 1397 | } |
| 1270 | 1398 | $_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']); |
| 1271 | 1399 | unset($_POST['ignore_brd']); |
@@ -1277,20 +1405,30 @@ discard block |
||
| 1277 | 1405 | makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
| 1278 | 1406 | makeNotificationChanges($memID); |
| 1279 | 1407 | if (!empty($_REQUEST['sa'])) |
| 1280 | - makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
| 1408 | + { |
|
| 1409 | + makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
| 1410 | + } |
|
| 1281 | 1411 | |
| 1282 | 1412 | foreach ($profile_bools as $var) |
| 1283 | - if (isset($_POST[$var])) |
|
| 1413 | + { |
|
| 1414 | + if (isset($_POST[$var])) |
|
| 1284 | 1415 | $profile_vars[$var] = empty($_POST[$var]) ? '0' : '1'; |
| 1416 | + } |
|
| 1285 | 1417 | foreach ($profile_ints as $var) |
| 1286 | - if (isset($_POST[$var])) |
|
| 1418 | + { |
|
| 1419 | + if (isset($_POST[$var])) |
|
| 1287 | 1420 | $profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : ''; |
| 1421 | + } |
|
| 1288 | 1422 | foreach ($profile_floats as $var) |
| 1289 | - if (isset($_POST[$var])) |
|
| 1423 | + { |
|
| 1424 | + if (isset($_POST[$var])) |
|
| 1290 | 1425 | $profile_vars[$var] = (float) $_POST[$var]; |
| 1426 | + } |
|
| 1291 | 1427 | foreach ($profile_strings as $var) |
| 1292 | - if (isset($_POST[$var])) |
|
| 1428 | + { |
|
| 1429 | + if (isset($_POST[$var])) |
|
| 1293 | 1430 | $profile_vars[$var] = $_POST[$var]; |
| 1431 | + } |
|
| 1294 | 1432 | } |
| 1295 | 1433 | } |
| 1296 | 1434 | |
@@ -1329,7 +1467,9 @@ discard block |
||
| 1329 | 1467 | |
| 1330 | 1468 | // Can't change reserved vars. |
| 1331 | 1469 | if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) |
| 1332 | - throw new Elk_Exception('no_access', false); |
|
| 1470 | + { |
|
| 1471 | + throw new Elk_Exception('no_access', false); |
|
| 1472 | + } |
|
| 1333 | 1473 | |
| 1334 | 1474 | // Don't allow any overriding of custom fields with default or non-default options. |
| 1335 | 1475 | $request = $db->query('', ' |
@@ -1342,7 +1482,9 @@ discard block |
||
| 1342 | 1482 | ); |
| 1343 | 1483 | $custom_fields = array(); |
| 1344 | 1484 | while ($row = $db->fetch_assoc($request)) |
| 1345 | - $custom_fields[] = $row['col_name']; |
|
| 1485 | + { |
|
| 1486 | + $custom_fields[] = $row['col_name']; |
|
| 1487 | + } |
|
| 1346 | 1488 | $db->free_result($request); |
| 1347 | 1489 | |
| 1348 | 1490 | // These are the theme changes... |
@@ -1352,14 +1494,20 @@ discard block |
||
| 1352 | 1494 | foreach ($_POST['options'] as $opt => $val) |
| 1353 | 1495 | { |
| 1354 | 1496 | if (in_array($opt, $custom_fields)) |
| 1355 | - continue; |
|
| 1497 | + { |
|
| 1498 | + continue; |
|
| 1499 | + } |
|
| 1356 | 1500 | |
| 1357 | 1501 | // These need to be controlled. |
| 1358 | 1502 | if ($opt === 'topics_per_page' || $opt === 'messages_per_page') |
| 1359 | - $val = max(0, min($val, 50)); |
|
| 1503 | + { |
|
| 1504 | + $val = max(0, min($val, 50)); |
|
| 1505 | + } |
|
| 1360 | 1506 | // We don't set this per theme anymore. |
| 1361 | 1507 | elseif ($opt === 'allow_no_censored') |
| 1362 | - continue; |
|
| 1508 | + { |
|
| 1509 | + continue; |
|
| 1510 | + } |
|
| 1363 | 1511 | |
| 1364 | 1512 | $themeSetArray[] = array($id_theme, $memID, $opt, is_array($val) ? implode(',', $val) : $val); |
| 1365 | 1513 | } |
@@ -1371,14 +1519,20 @@ discard block |
||
| 1371 | 1519 | foreach ($_POST['default_options'] as $opt => $val) |
| 1372 | 1520 | { |
| 1373 | 1521 | if (in_array($opt, $custom_fields)) |
| 1374 | - continue; |
|
| 1522 | + { |
|
| 1523 | + continue; |
|
| 1524 | + } |
|
| 1375 | 1525 | |
| 1376 | 1526 | // These need to be controlled. |
| 1377 | 1527 | if ($opt === 'topics_per_page' || $opt === 'messages_per_page') |
| 1378 | - $val = max(0, min($val, 50)); |
|
| 1528 | + { |
|
| 1529 | + $val = max(0, min($val, 50)); |
|
| 1530 | + } |
|
| 1379 | 1531 | // Only let admins and owners change the censor. |
| 1380 | 1532 | elseif ($opt === 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) |
| 1381 | - continue; |
|
| 1533 | + { |
|
| 1534 | + continue; |
|
| 1535 | + } |
|
| 1382 | 1536 | |
| 1383 | 1537 | $themeSetArray[] = array(1, $memID, $opt, is_array($val) ? implode(',', $val) : $val); |
| 1384 | 1538 | $erase_options[] = $opt; |
@@ -1390,14 +1544,20 @@ discard block |
||
| 1390 | 1544 | { |
| 1391 | 1545 | require_once(SUBSDIR . '/Themes.subs.php'); |
| 1392 | 1546 | if (!empty($themeSetArray)) |
| 1393 | - updateThemeOptions($themeSetArray); |
|
| 1547 | + { |
|
| 1548 | + updateThemeOptions($themeSetArray); |
|
| 1549 | + } |
|
| 1394 | 1550 | |
| 1395 | 1551 | if (!empty($erase_options)) |
| 1396 | - removeThemeOptions('custom', $memID, $erase_options); |
|
| 1552 | + { |
|
| 1553 | + removeThemeOptions('custom', $memID, $erase_options); |
|
| 1554 | + } |
|
| 1397 | 1555 | |
| 1398 | 1556 | $themes = explode(',', $modSettings['knownThemes']); |
| 1399 | 1557 | foreach ($themes as $t) |
| 1400 | - Cache::instance()->remove('theme_settings-' . $t . ':' . $memID); |
|
| 1558 | + { |
|
| 1559 | + Cache::instance()->remove('theme_settings-' . $t . ':' . $memID); |
|
| 1560 | + } |
|
| 1401 | 1561 | } |
| 1402 | 1562 | } |
| 1403 | 1563 | |
@@ -1419,8 +1579,9 @@ discard block |
||
| 1419 | 1579 | { |
| 1420 | 1580 | $to_save[$mention] = (int) $_POST['notify'][$mention]['method']; |
| 1421 | 1581 | } |
| 1422 | - else |
|
| 1423 | - $to_save[$mention] = 0; |
|
| 1582 | + else { |
|
| 1583 | + $to_save[$mention] = 0; |
|
| 1584 | + } |
|
| 1424 | 1585 | } |
| 1425 | 1586 | saveUserNotificationsPreferences($memID, $to_save); |
| 1426 | 1587 | } |
@@ -1429,11 +1590,15 @@ discard block |
||
| 1429 | 1590 | if (isset($_POST['edit_notify_boards'])) |
| 1430 | 1591 | { |
| 1431 | 1592 | if (!isset($_POST['notify_boards'])) |
| 1432 | - $_POST['notify_boards'] = array(); |
|
| 1593 | + { |
|
| 1594 | + $_POST['notify_boards'] = array(); |
|
| 1595 | + } |
|
| 1433 | 1596 | |
| 1434 | 1597 | // Make sure only integers are added/deleted. |
| 1435 | 1598 | foreach ($_POST['notify_boards'] as $index => $id) |
| 1436 | - $_POST['notify_boards'][$index] = (int) $id; |
|
| 1599 | + { |
|
| 1600 | + $_POST['notify_boards'][$index] = (int) $id; |
|
| 1601 | + } |
|
| 1437 | 1602 | |
| 1438 | 1603 | // id_board = 0 is reserved for topic notifications only |
| 1439 | 1604 | $notification_wanted = array_diff($_POST['notify_boards'], array(0)); |
@@ -1451,13 +1616,16 @@ discard block |
||
| 1451 | 1616 | ); |
| 1452 | 1617 | $notification_current = array(); |
| 1453 | 1618 | while ($row = $db->fetch_assoc($request)) |
| 1454 | - $notification_current[] = $row['id_board']; |
|
| 1619 | + { |
|
| 1620 | + $notification_current[] = $row['id_board']; |
|
| 1621 | + } |
|
| 1455 | 1622 | $db->free_result($request); |
| 1456 | 1623 | |
| 1457 | 1624 | // And remove what they no longer want |
| 1458 | 1625 | $notification_deletes = array_diff($notification_current, $notification_wanted); |
| 1459 | 1626 | if (!empty($notification_deletes)) |
| 1460 | - $db->query('', ' |
|
| 1627 | + { |
|
| 1628 | + $db->query('', ' |
|
| 1461 | 1629 | DELETE FROM {db_prefix}log_notify |
| 1462 | 1630 | WHERE id_board IN ({array_int:board_list}) |
| 1463 | 1631 | AND id_member = {int:selected_member}', |
@@ -1466,19 +1634,24 @@ discard block |
||
| 1466 | 1634 | 'selected_member' => $memID, |
| 1467 | 1635 | ) |
| 1468 | 1636 | ); |
| 1637 | + } |
|
| 1469 | 1638 | |
| 1470 | 1639 | // Now add in what they do want |
| 1471 | 1640 | $notification_inserts = array(); |
| 1472 | 1641 | foreach ($notification_wanted as $id) |
| 1473 | - $notification_inserts[] = array($memID, $id); |
|
| 1642 | + { |
|
| 1643 | + $notification_inserts[] = array($memID, $id); |
|
| 1644 | + } |
|
| 1474 | 1645 | |
| 1475 | 1646 | if (!empty($notification_inserts)) |
| 1476 | - $db->insert('ignore', |
|
| 1647 | + { |
|
| 1648 | + $db->insert('ignore', |
|
| 1477 | 1649 | '{db_prefix}log_notify', |
| 1478 | 1650 | array('id_member' => 'int', 'id_board' => 'int'), |
| 1479 | 1651 | $notification_inserts, |
| 1480 | 1652 | array('id_member', 'id_board') |
| 1481 | 1653 | ); |
| 1654 | + } |
|
| 1482 | 1655 | } |
| 1483 | 1656 | |
| 1484 | 1657 | // We are editing topic notifications...... |
@@ -1486,7 +1659,9 @@ discard block |
||
| 1486 | 1659 | { |
| 1487 | 1660 | $edit_notify_topics = array(); |
| 1488 | 1661 | foreach ($_POST['notify_topics'] as $index => $id) |
| 1489 | - $edit_notify_topics[$index] = (int) $id; |
|
| 1662 | + { |
|
| 1663 | + $edit_notify_topics[$index] = (int) $id; |
|
| 1664 | + } |
|
| 1490 | 1665 | |
| 1491 | 1666 | // Make sure there are no zeros left. |
| 1492 | 1667 | $edit_notify_topics = array_diff($edit_notify_topics, array(0)); |
@@ -1517,7 +1692,9 @@ discard block |
||
| 1517 | 1692 | $db = database(); |
| 1518 | 1693 | |
| 1519 | 1694 | if ($sanitize && isset($_POST['customfield'])) |
| 1520 | - $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
| 1695 | + { |
|
| 1696 | + $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
| 1697 | + } |
|
| 1521 | 1698 | |
| 1522 | 1699 | $where = $area === 'register' ? 'show_reg != 0' : 'show_profile = {string:area}'; |
| 1523 | 1700 | |
@@ -1543,11 +1720,15 @@ discard block |
||
| 1543 | 1720 | - The area isn't registration, and if it is that the field is not supposed to be shown there. |
| 1544 | 1721 | */ |
| 1545 | 1722 | if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area !== 'register' || $row['show_reg'] == 0)) |
| 1546 | - continue; |
|
| 1723 | + { |
|
| 1724 | + continue; |
|
| 1725 | + } |
|
| 1547 | 1726 | |
| 1548 | 1727 | // Validate the user data. |
| 1549 | 1728 | if ($row['field_type'] === 'check') |
| 1550 | - $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
| 1729 | + { |
|
| 1730 | + $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
| 1731 | + } |
|
| 1551 | 1732 | elseif (in_array($row['field_type'], array('radio', 'select'))) |
| 1552 | 1733 | { |
| 1553 | 1734 | $value = $row['default_value']; |
@@ -1584,7 +1765,9 @@ discard block |
||
| 1584 | 1765 | } |
| 1585 | 1766 | |
| 1586 | 1767 | if ($row['mask'] === 'number') |
| 1587 | - $value = (int) $value; |
|
| 1768 | + { |
|
| 1769 | + $value = (int) $value; |
|
| 1770 | + } |
|
| 1588 | 1771 | } |
| 1589 | 1772 | |
| 1590 | 1773 | // Did it change or has it been set? |
@@ -1628,7 +1811,9 @@ discard block |
||
| 1628 | 1811 | ); |
| 1629 | 1812 | |
| 1630 | 1813 | if (!empty($log_changes) && !empty($modSettings['modlog_enabled'])) |
| 1631 | - logActions($log_changes); |
|
| 1814 | + { |
|
| 1815 | + logActions($log_changes); |
|
| 1816 | + } |
|
| 1632 | 1817 | } |
| 1633 | 1818 | } |
| 1634 | 1819 | |
@@ -1648,18 +1833,26 @@ discard block |
||
| 1648 | 1833 | { |
| 1649 | 1834 | // Is it too long? |
| 1650 | 1835 | if ($field['field_length'] && $field['field_length'] < Util::strlen($value)) |
| 1651 | - return 'custom_field_too_long'; |
|
| 1836 | + { |
|
| 1837 | + return 'custom_field_too_long'; |
|
| 1838 | + } |
|
| 1652 | 1839 | |
| 1653 | 1840 | // Any masks to apply? |
| 1654 | 1841 | if ($field['field_type'] === 'text' && !empty($field['mask']) && $field['mask'] !== 'none') |
| 1655 | 1842 | { |
| 1656 | 1843 | // @todo We never error on this - just ignore it at the moment... |
| 1657 | 1844 | if ($field['mask'] === 'email' && !isValidEmail($value)) |
| 1658 | - return 'custom_field_invalid_email'; |
|
| 1845 | + { |
|
| 1846 | + return 'custom_field_invalid_email'; |
|
| 1847 | + } |
|
| 1659 | 1848 | elseif ($field['mask'] === 'number' && preg_match('~[^\d]~', $value)) |
| 1660 | - return 'custom_field_not_number'; |
|
| 1849 | + { |
|
| 1850 | + return 'custom_field_not_number'; |
|
| 1851 | + } |
|
| 1661 | 1852 | elseif (substr($field['mask'], 0, 5) === 'regex' && trim($value) !== '' && preg_match(substr($field['mask'], 5), $value) === 0) |
| 1662 | - return 'custom_field_inproper_format'; |
|
| 1853 | + { |
|
| 1854 | + return 'custom_field_inproper_format'; |
|
| 1855 | + } |
|
| 1663 | 1856 | } |
| 1664 | 1857 | |
| 1665 | 1858 | return true; |
@@ -1676,7 +1869,9 @@ discard block |
||
| 1676 | 1869 | |
| 1677 | 1870 | // Shouldn't happen but just in case. |
| 1678 | 1871 | if (empty($profile_vars['email_address'])) |
| 1679 | - return; |
|
| 1872 | + { |
|
| 1873 | + return; |
|
| 1874 | + } |
|
| 1680 | 1875 | |
| 1681 | 1876 | $replacements = array( |
| 1682 | 1877 | 'ACTIVATIONLINK' => $scripturl . '?action=register;sa=activate;u=' . $context['id_member'] . ';code=' . $old_profile['validation_code'], |
@@ -1695,7 +1890,9 @@ discard block |
||
| 1695 | 1890 | $_SESSION['login_' . $cookiename] = serialize(array(0, '', 0)); |
| 1696 | 1891 | |
| 1697 | 1892 | if (isset($_COOKIE[$cookiename])) |
| 1698 | - $_COOKIE[$cookiename] = ''; |
|
| 1893 | + { |
|
| 1894 | + $_COOKIE[$cookiename] = ''; |
|
| 1895 | + } |
|
| 1699 | 1896 | |
| 1700 | 1897 | loadUserSettings(); |
| 1701 | 1898 | |
@@ -1743,16 +1940,24 @@ discard block |
||
| 1743 | 1940 | // Warning message for signature image limits? |
| 1744 | 1941 | $context['signature_warning'] = ''; |
| 1745 | 1942 | if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) |
| 1746 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
| 1943 | + { |
|
| 1944 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
| 1945 | + } |
|
| 1747 | 1946 | elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) |
| 1748 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
| 1947 | + { |
|
| 1948 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
| 1949 | + } |
|
| 1749 | 1950 | |
| 1750 | 1951 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && function_exists('pspell_new'); |
| 1751 | 1952 | if ($context['show_spellchecking']) |
| 1752 | - loadJavascriptFile('spellcheck.js', array('defer' => true)); |
|
| 1953 | + { |
|
| 1954 | + loadJavascriptFile('spellcheck.js', array('defer' => true)); |
|
| 1955 | + } |
|
| 1753 | 1956 | |
| 1754 | 1957 | if (empty($context['do_preview'])) |
| 1755 | - $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br />', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
| 1958 | + { |
|
| 1959 | + $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br />', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
| 1960 | + } |
|
| 1756 | 1961 | else |
| 1757 | 1962 | { |
| 1758 | 1963 | $signature = !empty($_POST['signature']) ? $_POST['signature'] : ''; |
@@ -1765,7 +1970,9 @@ discard block |
||
| 1765 | 1970 | |
| 1766 | 1971 | $context['post_errors'][] = 'signature_not_yet_saved'; |
| 1767 | 1972 | if ($validation !== true && $validation !== false) |
| 1768 | - $context['post_errors'][] = $validation; |
|
| 1973 | + { |
|
| 1974 | + $context['post_errors'][] = $validation; |
|
| 1975 | + } |
|
| 1769 | 1976 | |
| 1770 | 1977 | $context['member']['signature'] = censor($context['member']['signature']); |
| 1771 | 1978 | $context['member']['current_signature'] = $context['member']['signature']; |
@@ -1794,9 +2001,12 @@ discard block |
||
| 1794 | 2001 | |
| 1795 | 2002 | // @todo Temporary |
| 1796 | 2003 | if ($context['user']['is_owner']) |
| 1797 | - $allowedChange = allowedTo('profile_set_avatar') && allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 1798 | - else |
|
| 1799 | - $allowedChange = allowedTo('profile_set_avatar') && allowedTo('profile_extra_any'); |
|
| 2004 | + { |
|
| 2005 | + $allowedChange = allowedTo('profile_set_avatar') && allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 2006 | + } |
|
| 2007 | + else { |
|
| 2008 | + $allowedChange = allowedTo('profile_set_avatar') && allowedTo('profile_extra_any'); |
|
| 2009 | + } |
|
| 1800 | 2010 | |
| 1801 | 2011 | // Default context. |
| 1802 | 2012 | $context['member']['avatar'] += array( |
@@ -1820,29 +2030,36 @@ discard block |
||
| 1820 | 2030 | $context['member']['avatar']['href'] = empty($cur_profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $cur_profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $cur_profile['filename']; |
| 1821 | 2031 | } |
| 1822 | 2032 | elseif ($valid_protocol && $context['member']['avatar']['allow_external']) |
| 1823 | - $context['member']['avatar'] += array( |
|
| 2033 | + { |
|
| 2034 | + $context['member']['avatar'] += array( |
|
| 1824 | 2035 | 'choice' => 'external', |
| 1825 | 2036 | 'server_pic' => 'blank.png', |
| 1826 | 2037 | 'external' => $cur_profile['avatar'] |
| 1827 | 2038 | ); |
| 2039 | + } |
|
| 1828 | 2040 | elseif ($cur_profile['avatar'] === 'gravatar' && $context['member']['avatar']['allow_gravatar']) |
| 1829 | - $context['member']['avatar'] += array( |
|
| 2041 | + { |
|
| 2042 | + $context['member']['avatar'] += array( |
|
| 1830 | 2043 | 'choice' => 'gravatar', |
| 1831 | 2044 | 'server_pic' => 'blank.png', |
| 1832 | 2045 | 'external' => 'https://' |
| 1833 | 2046 | ); |
| 2047 | + } |
|
| 1834 | 2048 | elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) |
| 1835 | - $context['member']['avatar'] += array( |
|
| 2049 | + { |
|
| 2050 | + $context['member']['avatar'] += array( |
|
| 1836 | 2051 | 'choice' => 'server_stored', |
| 1837 | 2052 | 'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'], |
| 1838 | 2053 | 'external' => $schema |
| 1839 | 2054 | ); |
| 1840 | - else |
|
| 1841 | - $context['member']['avatar'] += array( |
|
| 2055 | + } |
|
| 2056 | + else { |
|
| 2057 | + $context['member']['avatar'] += array( |
|
| 1842 | 2058 | 'choice' => 'none', |
| 1843 | 2059 | 'server_pic' => 'blank.png', |
| 1844 | 2060 | 'external' => $schema |
| 1845 | 2061 | ); |
| 2062 | + } |
|
| 1846 | 2063 | |
| 1847 | 2064 | // Get a list of all the avatars. |
| 1848 | 2065 | if ($context['member']['avatar']['allow_server_stored']) |
@@ -1881,7 +2098,9 @@ discard block |
||
| 1881 | 2098 | { |
| 1882 | 2099 | // Registered member was already taken care before |
| 1883 | 2100 | if ($id_group == 0) |
| 1884 | - continue; |
|
| 2101 | + { |
|
| 2102 | + continue; |
|
| 2103 | + } |
|
| 1885 | 2104 | |
| 1886 | 2105 | $context['member_groups'][$id_group]['is_primary'] = $cur_profile['id_group'] == $id_group; |
| 1887 | 2106 | $context['member_groups'][$id_group]['is_additional'] = in_array($id_group, $curGroups); |
@@ -1908,7 +2127,9 @@ discard block |
||
| 1908 | 2127 | |
| 1909 | 2128 | // Setup our languages. |
| 1910 | 2129 | foreach ($languages as $lang) |
| 1911 | - $context['profile_languages'][$lang['filename']] = $lang['name']; |
|
| 2130 | + { |
|
| 2131 | + $context['profile_languages'][$lang['filename']] = $lang['name']; |
|
| 2132 | + } |
|
| 1912 | 2133 | |
| 1913 | 2134 | ksort($context['profile_languages']); |
| 1914 | 2135 | |
@@ -1982,7 +2203,9 @@ discard block |
||
| 1982 | 2203 | |
| 1983 | 2204 | $smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img'); |
| 1984 | 2205 | if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) |
| 1985 | - return 'signature_allow_smileys'; |
|
| 2206 | + { |
|
| 2207 | + return 'signature_allow_smileys'; |
|
| 2208 | + } |
|
| 1986 | 2209 | elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
| 1987 | 2210 | { |
| 1988 | 2211 | $txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]); |
@@ -2008,13 +2231,21 @@ discard block |
||
| 2008 | 2231 | |
| 2009 | 2232 | // Attempt to allow all sizes of abuse, so to speak. |
| 2010 | 2233 | if ($matches[2][$ind] === 'px' && $size > $sig_limits[7]) |
| 2011 | - $limit_broke = $sig_limits[7] . 'px'; |
|
| 2234 | + { |
|
| 2235 | + $limit_broke = $sig_limits[7] . 'px'; |
|
| 2236 | + } |
|
| 2012 | 2237 | elseif ($matches[2][$ind] === 'pt' && $size > ($sig_limits[7] * 0.75)) |
| 2013 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 2238 | + { |
|
| 2239 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 2240 | + } |
|
| 2014 | 2241 | elseif ($matches[2][$ind] === 'em' && $size > ((float) $sig_limits[7] / 14)) |
| 2015 | - $limit_broke = ((float) $sig_limits[7] / 14) . 'em'; |
|
| 2242 | + { |
|
| 2243 | + $limit_broke = ((float) $sig_limits[7] / 14) . 'em'; |
|
| 2244 | + } |
|
| 2016 | 2245 | elseif ($matches[2][$ind] !== 'px' && $matches[2][$ind] !== 'pt' && $matches[2][$ind] !== 'em' && $sig_limits[7] < 18) |
| 2017 | - $limit_broke = 'large'; |
|
| 2246 | + { |
|
| 2247 | + $limit_broke = 'large'; |
|
| 2248 | + } |
|
| 2018 | 2249 | |
| 2019 | 2250 | if ($limit_broke) |
| 2020 | 2251 | { |
@@ -2061,7 +2292,9 @@ discard block |
||
| 2061 | 2292 | |
| 2062 | 2293 | // Does it have predefined restraints? Width first. |
| 2063 | 2294 | if ($matches[6][$key]) |
| 2064 | - $matches[2][$key] = $matches[6][$key]; |
|
| 2295 | + { |
|
| 2296 | + $matches[2][$key] = $matches[6][$key]; |
|
| 2297 | + } |
|
| 2065 | 2298 | |
| 2066 | 2299 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
| 2067 | 2300 | { |
@@ -2069,17 +2302,23 @@ discard block |
||
| 2069 | 2302 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
| 2070 | 2303 | } |
| 2071 | 2304 | elseif ($matches[2][$key]) |
| 2072 | - $width = $matches[2][$key]; |
|
| 2305 | + { |
|
| 2306 | + $width = $matches[2][$key]; |
|
| 2307 | + } |
|
| 2073 | 2308 | |
| 2074 | 2309 | // ... and height. |
| 2075 | 2310 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
| 2076 | 2311 | { |
| 2077 | 2312 | $height = $sig_limits[6]; |
| 2078 | 2313 | if ($width != -1) |
| 2079 | - $width = $width * ($height / $matches[4][$key]); |
|
| 2314 | + { |
|
| 2315 | + $width = $width * ($height / $matches[4][$key]); |
|
| 2316 | + } |
|
| 2080 | 2317 | } |
| 2081 | 2318 | elseif ($matches[4][$key]) |
| 2082 | - $height = $matches[4][$key]; |
|
| 2319 | + { |
|
| 2320 | + $height = $matches[4][$key]; |
|
| 2321 | + } |
|
| 2083 | 2322 | |
| 2084 | 2323 | // If the dimensions are still not fixed - we need to check the actual image. |
| 2085 | 2324 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -2100,21 +2339,29 @@ discard block |
||
| 2100 | 2339 | { |
| 2101 | 2340 | $height = $sig_limits[6]; |
| 2102 | 2341 | if ($width == -1) |
| 2103 | - $width = $sizes[0]; |
|
| 2342 | + { |
|
| 2343 | + $width = $sizes[0]; |
|
| 2344 | + } |
|
| 2104 | 2345 | $width = $width * ($height / $sizes[1]); |
| 2105 | 2346 | } |
| 2106 | 2347 | elseif ($width != -1) |
| 2107 | - $height = $sizes[1]; |
|
| 2348 | + { |
|
| 2349 | + $height = $sizes[1]; |
|
| 2350 | + } |
|
| 2108 | 2351 | } |
| 2109 | 2352 | } |
| 2110 | 2353 | |
| 2111 | 2354 | // Did we come up with some changes? If so remake the string. |
| 2112 | 2355 | if ($width != -1 || $height != -1) |
| 2113 | - $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
| 2356 | + { |
|
| 2357 | + $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
| 2358 | + } |
|
| 2114 | 2359 | } |
| 2115 | 2360 | |
| 2116 | 2361 | if (!empty($replaces)) |
| 2117 | - $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
| 2362 | + { |
|
| 2363 | + $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
| 2364 | + } |
|
| 2118 | 2365 | } |
| 2119 | 2366 | } |
| 2120 | 2367 | |
@@ -2166,7 +2413,9 @@ discard block |
||
| 2166 | 2413 | |
| 2167 | 2414 | $memID = $context['id_member']; |
| 2168 | 2415 | if (empty($memID) && !empty($context['password_auth_failed'])) |
| 2169 | - return false; |
|
| 2416 | + { |
|
| 2417 | + return false; |
|
| 2418 | + } |
|
| 2170 | 2419 | |
| 2171 | 2420 | // We need to know where we're going to be putting it.. |
| 2172 | 2421 | require_once(SUBSDIR . '/Attachments.subs.php'); |
@@ -2181,7 +2430,9 @@ discard block |
||
| 2181 | 2430 | { |
| 2182 | 2431 | loadLanguage('Post'); |
| 2183 | 2432 | if (!is_writable($uploadDir)) |
| 2184 | - throw new Elk_Exception('attachments_no_write', 'critical'); |
|
| 2433 | + { |
|
| 2434 | + throw new Elk_Exception('attachments_no_write', 'critical'); |
|
| 2435 | + } |
|
| 2185 | 2436 | |
| 2186 | 2437 | require_once(SUBSDIR . '/Package.subs.php'); |
| 2187 | 2438 | |
@@ -2248,10 +2499,14 @@ discard block |
||
| 2248 | 2499 | $profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal'])); |
| 2249 | 2500 | |
| 2250 | 2501 | if (preg_match('~^https?:///?$~i', $profile_vars['avatar']) === 1) |
| 2251 | - $profile_vars['avatar'] = ''; |
|
| 2502 | + { |
|
| 2503 | + $profile_vars['avatar'] = ''; |
|
| 2504 | + } |
|
| 2252 | 2505 | // Trying to make us do something we'll regret? |
| 2253 | 2506 | elseif ((!$valid_http && !$valid_https) || ($valid_http && detectServer()->supportsSSL())) |
| 2254 | - return 'bad_avatar'; |
|
| 2507 | + { |
|
| 2508 | + return 'bad_avatar'; |
|
| 2509 | + } |
|
| 2255 | 2510 | // Should we check dimensions? |
| 2256 | 2511 | elseif (!empty($modSettings['avatar_max_height']) || !empty($modSettings['avatar_max_width'])) |
| 2257 | 2512 | { |
@@ -2262,7 +2517,9 @@ discard block |
||
| 2262 | 2517 | { |
| 2263 | 2518 | // Houston, we have a problem. The avatar is too large!! |
| 2264 | 2519 | if ($modSettings['avatar_action_too_large'] === 'option_refuse') |
| 2265 | - return 'bad_avatar'; |
|
| 2520 | + { |
|
| 2521 | + return 'bad_avatar'; |
|
| 2522 | + } |
|
| 2266 | 2523 | elseif ($modSettings['avatar_action_too_large'] === 'option_download_and_resize') |
| 2267 | 2524 | { |
| 2268 | 2525 | // @todo remove this if appropriate |
@@ -2274,8 +2531,9 @@ discard block |
||
| 2274 | 2531 | $cur_profile['filename'] = $modSettings['new_avatar_data']['filename']; |
| 2275 | 2532 | $cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type']; |
| 2276 | 2533 | } |
| 2277 | - else |
|
| 2278 | - return 'bad_avatar'; |
|
| 2534 | + else { |
|
| 2535 | + return 'bad_avatar'; |
|
| 2536 | + } |
|
| 2279 | 2537 | } |
| 2280 | 2538 | } |
| 2281 | 2539 | } |
@@ -2406,7 +2664,9 @@ discard block |
||
| 2406 | 2664 | ); |
| 2407 | 2665 | |
| 2408 | 2666 | if (!empty($modSettings['attachment_webp_enable'])) |
| 2409 | - $extensions['18'] = 'webp'; |
|
| 2667 | + { |
|
| 2668 | + $extensions['18'] = 'webp'; |
|
| 2669 | + } |
|
| 2410 | 2670 | |
| 2411 | 2671 | $extension = isset($extensions[$sizes[2]]) ? $extensions[$sizes[2]] : 'jpg'; |
| 2412 | 2672 | $mime_type = 'image/' . ($extension === 'jpg' ? 'jpeg' : $extension); |
@@ -2450,14 +2710,18 @@ discard block |
||
| 2450 | 2710 | |
| 2451 | 2711 | // Delete any temporary file. |
| 2452 | 2712 | if (file_exists($_FILES['attachment']['tmp_name'])) |
| 2453 | - @unlink($_FILES['attachment']['tmp_name']); |
|
| 2713 | + { |
|
| 2714 | + @unlink($_FILES['attachment']['tmp_name']); |
|
| 2715 | + } |
|
| 2454 | 2716 | } |
| 2455 | 2717 | // Selected the upload avatar option and had one already uploaded before or didn't upload one. |
| 2456 | - else |
|
| 2718 | + else { |
|
| 2719 | + $profile_vars['avatar'] = ''; |
|
| 2720 | + } |
|
| 2721 | + } |
|
| 2722 | + else { |
|
| 2457 | 2723 | $profile_vars['avatar'] = ''; |
| 2458 | 2724 | } |
| 2459 | - else |
|
| 2460 | - $profile_vars['avatar'] = ''; |
|
| 2461 | 2725 | |
| 2462 | 2726 | // Setup the profile variables so it shows things right on display! |
| 2463 | 2727 | $cur_profile['avatar'] = $profile_vars['avatar']; |
@@ -2492,7 +2756,9 @@ discard block |
||
| 2492 | 2756 | ); |
| 2493 | 2757 | $protected_groups = array(1); |
| 2494 | 2758 | while ($row = $db->fetch_assoc($request)) |
| 2495 | - $protected_groups[] = $row['id_group']; |
|
| 2759 | + { |
|
| 2760 | + $protected_groups[] = $row['id_group']; |
|
| 2761 | + } |
|
| 2496 | 2762 | $db->free_result($request); |
| 2497 | 2763 | |
| 2498 | 2764 | $protected_groups = array_unique($protected_groups); |
@@ -2500,10 +2766,13 @@ discard block |
||
| 2500 | 2766 | |
| 2501 | 2767 | // The account page allows the change of your id_group - but not to a protected group! |
| 2502 | 2768 | if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) |
| 2503 | - $value = (int) $value; |
|
| 2769 | + { |
|
| 2770 | + $value = (int) $value; |
|
| 2771 | + } |
|
| 2504 | 2772 | // ... otherwise it's the old group sir. |
| 2505 | - else |
|
| 2506 | - $value = $old_profile['id_group']; |
|
| 2773 | + else { |
|
| 2774 | + $value = $old_profile['id_group']; |
|
| 2775 | + } |
|
| 2507 | 2776 | |
| 2508 | 2777 | // Find the additional membergroups (if any) |
| 2509 | 2778 | if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups'])) |
@@ -2513,7 +2782,9 @@ discard block |
||
| 2513 | 2782 | { |
| 2514 | 2783 | $group_id = (int) $group_id; |
| 2515 | 2784 | if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) |
| 2516 | - $additional_groups[] = $group_id; |
|
| 2785 | + { |
|
| 2786 | + $additional_groups[] = $group_id; |
|
| 2787 | + } |
|
| 2517 | 2788 | } |
| 2518 | 2789 | |
| 2519 | 2790 | // Put the protected groups back in there if you don't have permission to take them away. |
@@ -2521,7 +2792,9 @@ discard block |
||
| 2521 | 2792 | foreach ($old_additional_groups as $group_id) |
| 2522 | 2793 | { |
| 2523 | 2794 | if (!empty($protected_groups) && in_array($group_id, $protected_groups)) |
| 2524 | - $additional_groups[] = $group_id; |
|
| 2795 | + { |
|
| 2796 | + $additional_groups[] = $group_id; |
|
| 2797 | + } |
|
| 2525 | 2798 | } |
| 2526 | 2799 | |
| 2527 | 2800 | if (implode(',', $additional_groups) !== $old_profile['additional_groups']) |
@@ -2554,7 +2827,9 @@ discard block |
||
| 2554 | 2827 | $db->free_result($request); |
| 2555 | 2828 | |
| 2556 | 2829 | if (empty($another)) |
| 2557 | - throw new Elk_Exception('at_least_one_admin', 'critical'); |
|
| 2830 | + { |
|
| 2831 | + throw new Elk_Exception('at_least_one_admin', 'critical'); |
|
| 2832 | + } |
|
| 2558 | 2833 | } |
| 2559 | 2834 | } |
| 2560 | 2835 | |
@@ -2562,9 +2837,12 @@ discard block |
||
| 2562 | 2837 | if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups'])) |
| 2563 | 2838 | { |
| 2564 | 2839 | if ($context['user']['is_owner']) |
| 2565 | - $_SESSION['mc']['time'] = 0; |
|
| 2566 | - else |
|
| 2567 | - updateSettings(array('settings_updated' => time())); |
|
| 2840 | + { |
|
| 2841 | + $_SESSION['mc']['time'] = 0; |
|
| 2842 | + } |
|
| 2843 | + else { |
|
| 2844 | + updateSettings(array('settings_updated' => time())); |
|
| 2845 | + } |
|
| 2568 | 2846 | } |
| 2569 | 2847 | |
| 2570 | 2848 | return true; |
@@ -2665,7 +2943,9 @@ discard block |
||
| 2665 | 2943 | $db = database(); |
| 2666 | 2944 | |
| 2667 | 2945 | if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
| 2668 | - $exclude_boards = array($modSettings['recycle_board']); |
|
| 2946 | + { |
|
| 2947 | + $exclude_boards = array($modSettings['recycle_board']); |
|
| 2948 | + } |
|
| 2669 | 2949 | |
| 2670 | 2950 | // Retrieve some attachments. |
| 2671 | 2951 | $request = $db->query('', ' |
@@ -2702,9 +2982,12 @@ discard block |
||
| 2702 | 2982 | while ($row = $db->fetch_assoc($request)) |
| 2703 | 2983 | { |
| 2704 | 2984 | if (!$row['approved']) |
| 2705 | - $row['filename'] = str_replace(array('{attachment_link}', '{txt_awaiting}'), array('<a href="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'] . '">' . $row['filename'] . '</a>', $txt['awaiting_approval']), $settings['attachments_awaiting_approval']); |
|
| 2706 | - else |
|
| 2707 | - $row['filename'] = '<a href="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'] . '">' . $row['filename'] . '</a>'; |
|
| 2985 | + { |
|
| 2986 | + $row['filename'] = str_replace(array('{attachment_link}', '{txt_awaiting}'), array('<a href="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'] . '">' . $row['filename'] . '</a>', $txt['awaiting_approval']), $settings['attachments_awaiting_approval']); |
|
| 2987 | + } |
|
| 2988 | + else { |
|
| 2989 | + $row['filename'] = '<a href="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'] . '">' . $row['filename'] . '</a>'; |
|
| 2990 | + } |
|
| 2708 | 2991 | |
| 2709 | 2992 | $attachments[] = array( |
| 2710 | 2993 | 'id' => $row['id_attach'], |
@@ -2806,7 +3089,9 @@ discard block |
||
| 2806 | 3089 | ); |
| 2807 | 3090 | $topics = array(); |
| 2808 | 3091 | while ($row = $db->fetch_assoc($request)) |
| 2809 | - $topics[] = $row['id_topic']; |
|
| 3092 | + { |
|
| 3093 | + $topics[] = $row['id_topic']; |
|
| 3094 | + } |
|
| 2810 | 3095 | $db->free_result($request); |
| 2811 | 3096 | |
| 2812 | 3097 | // Any topics found? |
@@ -2826,7 +3111,9 @@ discard block |
||
| 2826 | 3111 | ) |
| 2827 | 3112 | ); |
| 2828 | 3113 | while ($row = $db->fetch_assoc($request)) |
| 2829 | - $topicsInfo[] = $row; |
|
| 3114 | + { |
|
| 3115 | + $topicsInfo[] = $row; |
|
| 3116 | + } |
|
| 2830 | 3117 | $db->free_result($request); |
| 2831 | 3118 | } |
| 2832 | 3119 | |
@@ -3058,14 +3345,19 @@ discard block |
||
| 3058 | 3345 | |
| 3059 | 3346 | // Did we get what we wanted, if so stop looking |
| 3060 | 3347 | if ($db->num_rows($request) === $count || empty($range_limit)) |
| 3061 | - break; |
|
| 3062 | - else |
|
| 3063 | - $range_limit = ''; |
|
| 3348 | + { |
|
| 3349 | + break; |
|
| 3350 | + } |
|
| 3351 | + else { |
|
| 3352 | + $range_limit = ''; |
|
| 3353 | + } |
|
| 3064 | 3354 | } |
| 3065 | 3355 | |
| 3066 | 3356 | // Place them in the post array |
| 3067 | 3357 | while ($row = $db->fetch_assoc($request)) |
| 3068 | - $user_posts[] = $row; |
|
| 3358 | + { |
|
| 3359 | + $user_posts[] = $row; |
|
| 3360 | + } |
|
| 3069 | 3361 | $db->free_result($request); |
| 3070 | 3362 | |
| 3071 | 3363 | return $user_posts; |
@@ -3123,14 +3415,19 @@ discard block |
||
| 3123 | 3415 | |
| 3124 | 3416 | // Did we get what we wanted, if so stop looking |
| 3125 | 3417 | if ($db->num_rows($request) === $count || empty($range_limit)) |
| 3126 | - break; |
|
| 3127 | - else |
|
| 3128 | - $range_limit = ''; |
|
| 3418 | + { |
|
| 3419 | + break; |
|
| 3420 | + } |
|
| 3421 | + else { |
|
| 3422 | + $range_limit = ''; |
|
| 3423 | + } |
|
| 3129 | 3424 | } |
| 3130 | 3425 | |
| 3131 | 3426 | // Place them in the topic array |
| 3132 | 3427 | while ($row = $db->fetch_assoc($request)) |
| 3133 | - $user_topics[] = $row; |
|
| 3428 | + { |
|
| 3429 | + $user_topics[] = $row; |
|
| 3430 | + } |
|
| 3134 | 3431 | $db->free_result($request); |
| 3135 | 3432 | |
| 3136 | 3433 | return $user_topics; |
@@ -3165,13 +3462,18 @@ discard block |
||
| 3165 | 3462 | { |
| 3166 | 3463 | // We don't know about this permission, it doesn't exist :P. |
| 3167 | 3464 | if (!isset($txt['permissionname_' . $row['permission']])) |
| 3168 | - continue; |
|
| 3465 | + { |
|
| 3466 | + continue; |
|
| 3467 | + } |
|
| 3169 | 3468 | |
| 3170 | 3469 | // Permissions that end with _own or _any consist of two parts. |
| 3171 | 3470 | if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
| 3172 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 3173 | - else |
|
| 3174 | - $name = $txt['permissionname_' . $row['permission']]; |
|
| 3471 | + { |
|
| 3472 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 3473 | + } |
|
| 3474 | + else { |
|
| 3475 | + $name = $txt['permissionname_' . $row['permission']]; |
|
| 3476 | + } |
|
| 3175 | 3477 | |
| 3176 | 3478 | // Add this permission if it doesn't exist yet. |
| 3177 | 3479 | if (!isset($general_permission[$row['permission']])) |
@@ -3238,17 +3540,23 @@ discard block |
||
| 3238 | 3540 | { |
| 3239 | 3541 | // We don't know about this permission, it doesn't exist :P. |
| 3240 | 3542 | if (!isset($txt['permissionname_' . $row['permission']])) |
| 3241 | - continue; |
|
| 3543 | + { |
|
| 3544 | + continue; |
|
| 3545 | + } |
|
| 3242 | 3546 | |
| 3243 | 3547 | // The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'. |
| 3244 | 3548 | if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
| 3245 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 3246 | - else |
|
| 3247 | - $name = $txt['permissionname_' . $row['permission']]; |
|
| 3549 | + { |
|
| 3550 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 3551 | + } |
|
| 3552 | + else { |
|
| 3553 | + $name = $txt['permissionname_' . $row['permission']]; |
|
| 3554 | + } |
|
| 3248 | 3555 | |
| 3249 | 3556 | // Create the structure for this permission. |
| 3250 | 3557 | if (!isset($board_permission[$row['permission']])) |
| 3251 | - $board_permission[$row['permission']] = array( |
|
| 3558 | + { |
|
| 3559 | + $board_permission[$row['permission']] = array( |
|
| 3252 | 3560 | 'id' => $row['permission'], |
| 3253 | 3561 | 'groups' => array( |
| 3254 | 3562 | 'allowed' => array(), |
@@ -3258,6 +3566,7 @@ discard block |
||
| 3258 | 3566 | 'is_denied' => false, |
| 3259 | 3567 | 'is_global' => empty($board), |
| 3260 | 3568 | ); |
| 3569 | + } |
|
| 3261 | 3570 | |
| 3262 | 3571 | $board_permission[$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][$row['id_group']] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
| 3263 | 3572 | $board_permission[$row['permission']]['is_denied'] |= empty($row['add_deny']); |
@@ -3319,7 +3628,9 @@ discard block |
||
| 3319 | 3628 | ); |
| 3320 | 3629 | |
| 3321 | 3630 | while ($row = $db->fetch_assoc($request)) |
| 3322 | - $ips[] = $row['poster_ip']; |
|
| 3631 | + { |
|
| 3632 | + $ips[] = $row['poster_ip']; |
|
| 3633 | + } |
|
| 3323 | 3634 | |
| 3324 | 3635 | $db->free_result($request); |
| 3325 | 3636 | |
@@ -3337,7 +3648,9 @@ discard block |
||
| 3337 | 3648 | $error_ips = array(); |
| 3338 | 3649 | |
| 3339 | 3650 | while ($row = $db->fetch_assoc($request)) |
| 3340 | - $error_ips[] = $row['ip']; |
|
| 3651 | + { |
|
| 3652 | + $error_ips[] = $row['ip']; |
|
| 3653 | + } |
|
| 3341 | 3654 | |
| 3342 | 3655 | $db->free_result($request); |
| 3343 | 3656 | |
@@ -3373,7 +3686,9 @@ discard block |
||
| 3373 | 3686 | ); |
| 3374 | 3687 | |
| 3375 | 3688 | while ($row = $db->fetch_assoc($request)) |
| 3376 | - $message_members[] = $row['id_member']; |
|
| 3689 | + { |
|
| 3690 | + $message_members[] = $row['id_member']; |
|
| 3691 | + } |
|
| 3377 | 3692 | $db->free_result($request); |
| 3378 | 3693 | |
| 3379 | 3694 | // And then get the member ID's belong to other users |
@@ -3388,7 +3703,9 @@ discard block |
||
| 3388 | 3703 | ) |
| 3389 | 3704 | ); |
| 3390 | 3705 | while ($row = $db->fetch_assoc($request)) |
| 3391 | - $message_members[] = $row['id_member']; |
|
| 3706 | + { |
|
| 3707 | + $message_members[] = $row['id_member']; |
|
| 3708 | + } |
|
| 3392 | 3709 | $db->free_result($request); |
| 3393 | 3710 | |
| 3394 | 3711 | // Once the IDs are all combined, let's clean them up |
@@ -3418,7 +3735,9 @@ discard block |
||
| 3418 | 3735 | global $modSettings, $context; |
| 3419 | 3736 | |
| 3420 | 3737 | if (empty($modSettings['enabled_mentions'])) |
| 3421 | - return array(); |
|
| 3738 | + { |
|
| 3739 | + return array(); |
|
| 3740 | + } |
|
| 3422 | 3741 | |
| 3423 | 3742 | require_once(SUBSDIR . '/Notification.subs.php'); |
| 3424 | 3743 | Elk_Autoloader::instance()->register(SUBSDIR . '/MentionType', '\\ElkArte\\sources\\subs\\MentionType'); |
@@ -3438,14 +3757,20 @@ discard block |
||
| 3438 | 3757 | { |
| 3439 | 3758 | $notif[$key] = array('id' => $val, 'enabled' => $user_preferences[$member_id][$type] === $key); |
| 3440 | 3759 | if ($user_preferences[$member_id][$type] > 0) |
| 3441 | - $type_on = true; |
|
| 3760 | + { |
|
| 3761 | + $type_on = true; |
|
| 3762 | + } |
|
| 3442 | 3763 | |
| 3443 | 3764 | if (!$push_enabled && $val === 'notification' && $user_preferences[$member_id][$type] === $key) |
| 3444 | - $push_enabled = true; |
|
| 3765 | + { |
|
| 3766 | + $push_enabled = true; |
|
| 3767 | + } |
|
| 3445 | 3768 | } |
| 3446 | 3769 | |
| 3447 | 3770 | if (!empty($notif)) |
| 3448 | - $mention_types[$type] = array('data' => $notif, 'enabled' => $type_on); |
|
| 3771 | + { |
|
| 3772 | + $mention_types[$type] = array('data' => $notif, 'enabled' => $type_on); |
|
| 3773 | + } |
|
| 3449 | 3774 | } |
| 3450 | 3775 | |
| 3451 | 3776 | // If they enabled notifications alert, then lets ask for browser permission to show them |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | 'type' => 'callback', |
| 395 | 395 | 'callback_func' => 'birthdate', |
| 396 | 396 | 'permission' => 'profile_extra', |
| 397 | - 'preload' => function () { |
|
| 397 | + 'preload' => function() { |
|
| 398 | 398 | global $cur_profile, $context; |
| 399 | 399 | |
| 400 | 400 | // Split up the birth date.... |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | |
| 408 | 408 | return true; |
| 409 | 409 | }, |
| 410 | - 'input_validate' => function (&$value) { |
|
| 410 | + 'input_validate' => function(&$value) { |
|
| 411 | 411 | global $profile_vars, $cur_profile; |
| 412 | 412 | |
| 413 | 413 | if (isset($_POST['bday2'], $_POST['bday3']) && $value > 0 && $_POST['bday2'] > 0) |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | 'birthdate' => array( |
| 431 | 431 | 'type' => 'hidden', |
| 432 | 432 | 'permission' => 'profile_extra', |
| 433 | - 'input_validate' => function (&$value) { |
|
| 433 | + 'input_validate' => function(&$value) { |
|
| 434 | 434 | global $cur_profile; |
| 435 | 435 | |
| 436 | 436 | // @todo Should we check for this year and tell them they made a mistake :P? (based on coppa at least?) |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | 'label' => $txt['date_registered'], |
| 453 | 453 | 'log_change' => true, |
| 454 | 454 | 'permission' => 'moderate_forum', |
| 455 | - 'input_validate' => function (&$value) { |
|
| 455 | + 'input_validate' => function(&$value) { |
|
| 456 | 456 | global $txt, $user_info, $modSettings, $cur_profile; |
| 457 | 457 | |
| 458 | 458 | // Bad date! Go try again - please? |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | 'subtext' => $txt['valid_email'], |
| 477 | 477 | 'log_change' => true, |
| 478 | 478 | 'permission' => 'profile_identity', |
| 479 | - 'input_validate' => function (&$value) { |
|
| 479 | + 'input_validate' => function(&$value) { |
|
| 480 | 480 | global $context, $old_profile, $profile_vars, $modSettings; |
| 481 | 481 | |
| 482 | 482 | if (strtolower($value) == strtolower($old_profile['email_address'])) |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | 'value' => empty($cur_profile['hide_email']) ? true : false, |
| 504 | 504 | 'label' => $txt['allow_user_email'], |
| 505 | 505 | 'permission' => 'profile_identity', |
| 506 | - 'input_validate' => function (&$value) { |
|
| 506 | + 'input_validate' => function(&$value) { |
|
| 507 | 507 | $value = $value == 0 ? 1 : 0; |
| 508 | 508 | |
| 509 | 509 | return true; |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | 'callback_func' => 'theme_pick', |
| 524 | 524 | 'permission' => 'profile_extra', |
| 525 | 525 | 'enabled' => empty($settings['disable_user_variant']) || !empty($modSettings['theme_allow']) || allowedTo('admin_forum'), |
| 526 | - 'preload' => function () { |
|
| 526 | + 'preload' => function() { |
|
| 527 | 527 | global $context, $cur_profile, $txt; |
| 528 | 528 | |
| 529 | 529 | $db = database(); |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | ); |
| 548 | 548 | return true; |
| 549 | 549 | }, |
| 550 | - 'input_validate' => function (&$value) { |
|
| 550 | + 'input_validate' => function(&$value) { |
|
| 551 | 551 | $value = (int) $value; |
| 552 | 552 | return true; |
| 553 | 553 | }, |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | 'callback_func' => 'karma_modify', |
| 558 | 558 | 'permission' => 'admin_forum', |
| 559 | 559 | // Set karma_bad too! |
| 560 | - 'input_validate' => function (&$value) { |
|
| 560 | + 'input_validate' => function(&$value) { |
|
| 561 | 561 | global $profile_vars, $cur_profile; |
| 562 | 562 | |
| 563 | 563 | $value = (int) $value; |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | } |
| 569 | 569 | return true; |
| 570 | 570 | }, |
| 571 | - 'preload' => function () { |
|
| 571 | + 'preload' => function() { |
|
| 572 | 572 | global $context, $cur_profile; |
| 573 | 573 | |
| 574 | 574 | $context['member']['karma']['good'] = $cur_profile['karma_good']; |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | 'preload' => 'profileLoadLanguages', |
| 587 | 587 | 'enabled' => !empty($modSettings['userLanguage']), |
| 588 | 588 | 'value' => empty($cur_profile['lngfile']) ? $language : $cur_profile['lngfile'], |
| 589 | - 'input_validate' => function (&$value) { |
|
| 589 | + 'input_validate' => function(&$value) { |
|
| 590 | 590 | global $context, $cur_profile; |
| 591 | 591 | |
| 592 | 592 | // Load the languages. |
@@ -613,7 +613,7 @@ discard block |
||
| 613 | 613 | 'log_change' => true, |
| 614 | 614 | 'permission' => 'profile_identity', |
| 615 | 615 | 'prehtml' => allowedTo('admin_forum') && isset($_GET['changeusername']) ? '<div class="warningbox">' . $txt['username_warning'] . '</div>' : '', |
| 616 | - 'input_validate' => function (&$value) { |
|
| 616 | + 'input_validate' => function(&$value) { |
|
| 617 | 617 | global $context, $user_info, $cur_profile; |
| 618 | 618 | |
| 619 | 619 | if (allowedTo('admin_forum')) |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | 'permission' => 'profile_identity', |
| 666 | 666 | 'save_key' => 'passwd', |
| 667 | 667 | // Note this will only work if passwrd2 also exists! |
| 668 | - 'input_validate' => function (&$value) { |
|
| 668 | + 'input_validate' => function(&$value) { |
|
| 669 | 669 | global $user_info, $cur_profile; |
| 670 | 670 | |
| 671 | 671 | // If we didn't try it then ignore it! |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | ), |
| 728 | 728 | 'subtext' => $txt['receive_from_description'], |
| 729 | 729 | 'value' => empty($cur_profile['receive_from']) ? 0 : $cur_profile['receive_from'], |
| 730 | - 'input_validate' => function (&$value) { |
|
| 730 | + 'input_validate' => function(&$value) { |
|
| 731 | 731 | global $cur_profile, $profile_vars; |
| 732 | 732 | |
| 733 | 733 | // Simple validate and apply the two "sub settings" |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | 'callback_func' => 'pm_settings', |
| 745 | 745 | 'permission' => 'pm_read', |
| 746 | 746 | 'save_key' => 'pm_prefs', |
| 747 | - 'preload' => function () { |
|
| 747 | + 'preload' => function() { |
|
| 748 | 748 | global $context, $cur_profile; |
| 749 | 749 | |
| 750 | 750 | $context['display_mode'] = $cur_profile['pm_prefs'] & 3; |
@@ -752,7 +752,7 @@ discard block |
||
| 752 | 752 | |
| 753 | 753 | return true; |
| 754 | 754 | }, |
| 755 | - 'input_validate' => function (&$value) { |
|
| 755 | + 'input_validate' => function(&$value) { |
|
| 756 | 756 | global $cur_profile, $profile_vars; |
| 757 | 757 | |
| 758 | 758 | // Simple validate and apply the two "sub settings" |
@@ -769,7 +769,7 @@ discard block |
||
| 769 | 769 | 'log_change' => true, |
| 770 | 770 | 'size' => 7, |
| 771 | 771 | 'permission' => 'moderate_forum', |
| 772 | - 'input_validate' => function (&$value) { |
|
| 772 | + 'input_validate' => function(&$value) { |
|
| 773 | 773 | if (!is_numeric($value)) |
| 774 | 774 | return 'digits_only'; |
| 775 | 775 | else |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | 'input_attr' => array('maxlength="60"'), |
| 786 | 786 | 'permission' => 'profile_identity', |
| 787 | 787 | 'enabled' => !empty($modSettings['allow_editDisplayName']) || allowedTo('moderate_forum'), |
| 788 | - 'input_validate' => function (&$value) { |
|
| 788 | + 'input_validate' => function(&$value) { |
|
| 789 | 789 | global $context, $cur_profile; |
| 790 | 790 | |
| 791 | 791 | $value = trim(preg_replace('~[\s]~u', ' ', $value)); |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | 'postinput' => '<span class="smalltext" style="margin-left: 4ex;">[<a href="' . $scripturl . '?action=quickhelp;help=secret_why_blank" onclick="return reqOverlayDiv(this.href);">' . $txt['secret_why_blank'] . '</a>]</span>', |
| 819 | 819 | 'value' => '', |
| 820 | 820 | 'permission' => 'profile_identity', |
| 821 | - 'input_validate' => function (&$value) { |
|
| 821 | + 'input_validate' => function(&$value) { |
|
| 822 | 822 | global $cur_profile; |
| 823 | 823 | |
| 824 | 824 | if (empty($value)) |
@@ -862,7 +862,7 @@ discard block |
||
| 862 | 862 | 'callback_func' => 'smiley_pick', |
| 863 | 863 | 'enabled' => !empty($modSettings['smiley_sets_enable']), |
| 864 | 864 | 'permission' => 'profile_extra', |
| 865 | - 'preload' => function () { |
|
| 865 | + 'preload' => function() { |
|
| 866 | 866 | global $modSettings, $context, $txt, $cur_profile; |
| 867 | 867 | |
| 868 | 868 | $context['member']['smiley_set']['id'] = empty($cur_profile['smiley_set']) ? '' : $cur_profile['smiley_set']; |
@@ -881,7 +881,7 @@ discard block |
||
| 881 | 881 | } |
| 882 | 882 | return true; |
| 883 | 883 | }, |
| 884 | - 'input_validate' => function (&$value) { |
|
| 884 | + 'input_validate' => function(&$value) { |
|
| 885 | 885 | global $modSettings; |
| 886 | 886 | |
| 887 | 887 | $smiley_sets = explode(',', $modSettings['smiley_sets_known']); |
@@ -896,7 +896,7 @@ discard block |
||
| 896 | 896 | 'callback_func' => 'theme_settings', |
| 897 | 897 | 'permission' => 'profile_extra', |
| 898 | 898 | 'is_dummy' => true, |
| 899 | - 'preload' => function () { |
|
| 899 | + 'preload' => function() { |
|
| 900 | 900 | global $context, $user_info; |
| 901 | 901 | |
| 902 | 902 | loadLanguage('Settings'); |
@@ -913,7 +913,7 @@ discard block |
||
| 913 | 913 | 'type' => 'callback', |
| 914 | 914 | 'callback_func' => 'timeformat_modify', |
| 915 | 915 | 'permission' => 'profile_extra', |
| 916 | - 'preload' => function () { |
|
| 916 | + 'preload' => function() { |
|
| 917 | 917 | global $context, $user_info, $txt, $cur_profile, $modSettings; |
| 918 | 918 | |
| 919 | 919 | $context['easy_timeformats'] = array( |
@@ -936,13 +936,13 @@ discard block |
||
| 936 | 936 | 'type' => 'callback', |
| 937 | 937 | 'callback_func' => 'timeoffset_modify', |
| 938 | 938 | 'permission' => 'profile_extra', |
| 939 | - 'preload' => function () { |
|
| 939 | + 'preload' => function() { |
|
| 940 | 940 | global $context, $cur_profile; |
| 941 | 941 | |
| 942 | 942 | $context['member']['time_offset'] = $cur_profile['time_offset']; |
| 943 | 943 | return true; |
| 944 | 944 | }, |
| 945 | - 'input_validate' => function (&$value) { |
|
| 945 | + 'input_validate' => function(&$value) { |
|
| 946 | 946 | // Validate the time_offset... |
| 947 | 947 | $value = (float) strtr($value, ',', '.'); |
| 948 | 948 | |
@@ -960,7 +960,7 @@ discard block |
||
| 960 | 960 | 'size' => 50, |
| 961 | 961 | 'permission' => 'profile_title', |
| 962 | 962 | 'enabled' => !empty($modSettings['titlesEnable']), |
| 963 | - 'input_validate' => function (&$value) { |
|
| 963 | + 'input_validate' => function(&$value) { |
|
| 964 | 964 | if (Util::strlen($value) > 50) |
| 965 | 965 | return 'user_title_too_long'; |
| 966 | 966 | |
@@ -982,7 +982,7 @@ discard block |
||
| 982 | 982 | 'size' => 50, |
| 983 | 983 | 'permission' => 'profile_extra', |
| 984 | 984 | // Fix the URL... |
| 985 | - 'input_validate' => function (&$value) { |
|
| 985 | + 'input_validate' => function(&$value) { |
|
| 986 | 986 | |
| 987 | 987 | $value = addProtocol($value, array('http://', 'https://', 'ftp://', 'ftps://')); |
| 988 | 988 | if (strlen($value) < 8) |
@@ -69,9 +69,13 @@ discard block |
||
| 69 | 69 | { |
| 70 | 70 | // Make sure it's turned on and not some fool trying to trick it. |
| 71 | 71 | if (empty($this->_settings['cal_allowspan'])) |
| 72 | - throw new Elk_Exception('no_span', false); |
|
| 72 | + { |
|
| 73 | + throw new Elk_Exception('no_span', false); |
|
| 74 | + } |
|
| 73 | 75 | if ($event['span'] < 1 || $event['span'] > $this->_settings['cal_maxspan']) |
| 74 | - throw new Elk_Exception('invalid_days_numb', false); |
|
| 76 | + { |
|
| 77 | + throw new Elk_Exception('invalid_days_numb', false); |
|
| 78 | + } |
|
| 75 | 79 | } |
| 76 | 80 | |
| 77 | 81 | |
@@ -80,34 +84,54 @@ discard block |
||
| 80 | 84 | { |
| 81 | 85 | // No month? No year? |
| 82 | 86 | if (!isset($event['month'])) |
| 83 | - throw new Elk_Exception('event_month_missing', false); |
|
| 87 | + { |
|
| 88 | + throw new Elk_Exception('event_month_missing', false); |
|
| 89 | + } |
|
| 84 | 90 | if (!isset($event['year'])) |
| 85 | - throw new Elk_Exception('event_year_missing', false); |
|
| 91 | + { |
|
| 92 | + throw new Elk_Exception('event_year_missing', false); |
|
| 93 | + } |
|
| 86 | 94 | |
| 87 | 95 | // Check the month and year... |
| 88 | 96 | if ($event['month'] < 1 || $event['month'] > 12) |
| 89 | - throw new Elk_Exception('invalid_month', false); |
|
| 97 | + { |
|
| 98 | + throw new Elk_Exception('invalid_month', false); |
|
| 99 | + } |
|
| 90 | 100 | if ($event['year'] < $this->_settings['cal_minyear'] || $event['year'] > (int) date('Y') + $this->_settings['cal_limityear']) |
| 91 | - throw new Elk_Exception('invalid_year', false); |
|
| 101 | + { |
|
| 102 | + throw new Elk_Exception('invalid_year', false); |
|
| 103 | + } |
|
| 92 | 104 | |
| 93 | 105 | // No day? |
| 94 | 106 | if (!isset($event['day'])) |
| 95 | - throw new Elk_Exception('event_day_missing', false); |
|
| 107 | + { |
|
| 108 | + throw new Elk_Exception('event_day_missing', false); |
|
| 109 | + } |
|
| 96 | 110 | |
| 97 | 111 | if (!isset($event['evtitle']) && !isset($event['subject'])) |
| 98 | - throw new Elk_Exception('event_title_missing', false); |
|
| 112 | + { |
|
| 113 | + throw new Elk_Exception('event_title_missing', false); |
|
| 114 | + } |
|
| 99 | 115 | elseif (!isset($event['evtitle'])) |
| 100 | - $event['evtitle'] = $event['subject']; |
|
| 116 | + { |
|
| 117 | + $event['evtitle'] = $event['subject']; |
|
| 118 | + } |
|
| 101 | 119 | |
| 102 | 120 | // Bad day? |
| 103 | 121 | if (!checkdate($event['month'], $event['day'], $event['year'])) |
| 104 | - throw new Elk_Exception('invalid_date', false); |
|
| 122 | + { |
|
| 123 | + throw new Elk_Exception('invalid_date', false); |
|
| 124 | + } |
|
| 105 | 125 | |
| 106 | 126 | // No title? |
| 107 | 127 | if (Util::htmltrim($event['evtitle']) === '') |
| 108 | - throw new Elk_Exception('no_event_title', false); |
|
| 128 | + { |
|
| 129 | + throw new Elk_Exception('no_event_title', false); |
|
| 130 | + } |
|
| 109 | 131 | if (Util::strlen($event['evtitle']) > 100) |
| 110 | - $event['evtitle'] = Util::substr($event['evtitle'], 0, 100); |
|
| 132 | + { |
|
| 133 | + $event['evtitle'] = Util::substr($event['evtitle'], 0, 100); |
|
| 134 | + } |
|
| 111 | 135 | $event['evtitle'] = str_replace(';', '', $event['evtitle']); |
| 112 | 136 | } |
| 113 | 137 | |
@@ -153,19 +177,28 @@ discard block |
||
| 153 | 177 | { |
| 154 | 178 | // There could be already a topic you are not allowed to modify |
| 155 | 179 | if (!allowedTo('post_new') && empty($this->_settings['disableNoPostingCalendarEdits'])) |
| 156 | - $eventProperties = getEventProperties($this->_event_id, true); |
|
| 180 | + { |
|
| 181 | + $eventProperties = getEventProperties($this->_event_id, true); |
|
| 182 | + } |
|
| 157 | 183 | |
| 158 | 184 | $id_board = isset($eventProperties['id_board']) ? $eventProperties['id_board'] : (isset($options['id_board']) ? $options['board'] : 0); |
| 159 | 185 | $id_topic = isset($eventProperties['id_topic']) ? $eventProperties['id_topic'] : (isset($options['id_topic']) ? $options['topic'] : 0); |
| 160 | 186 | |
| 161 | 187 | if (empty($this->_settings['cal_allowspan'])) |
| 162 | - $span = 0; |
|
| 188 | + { |
|
| 189 | + $span = 0; |
|
| 190 | + } |
|
| 163 | 191 | elseif (empty($options['span']) || $options['span'] == 1) |
| 164 | - $span = 0; |
|
| 192 | + { |
|
| 193 | + $span = 0; |
|
| 194 | + } |
|
| 165 | 195 | elseif (empty($this->_settings['cal_maxspan']) || $options['span'] > $this->_settings['cal_maxspan']) |
| 166 | - $span = 0; |
|
| 167 | - else |
|
| 168 | - $span = min((int) $this->_settings['cal_maxspan'], (int) $options['span'] - 1); |
|
| 196 | + { |
|
| 197 | + $span = 0; |
|
| 198 | + } |
|
| 199 | + else { |
|
| 200 | + $span = min((int) $this->_settings['cal_maxspan'], (int) $options['span'] - 1); |
|
| 201 | + } |
|
| 169 | 202 | |
| 170 | 203 | $eventOptions = array( |
| 171 | 204 | 'title' => Util::substr($options['evtitle'], 0, 100), |
@@ -217,7 +250,9 @@ discard block |
||
| 217 | 250 | $event = getEventProperties($this->_event_id); |
| 218 | 251 | |
| 219 | 252 | if ($event === false) |
| 220 | - throw new Elk_Exception('no_access', false); |
|
| 253 | + { |
|
| 254 | + throw new Elk_Exception('no_access', false); |
|
| 255 | + } |
|
| 221 | 256 | |
| 222 | 257 | // If it has a board, then they should be editing it within the topic. |
| 223 | 258 | if (!empty($event['topic']['id']) && !empty($event['topic']['first_msg'])) |
@@ -229,9 +264,13 @@ discard block |
||
| 229 | 264 | |
| 230 | 265 | // Make sure the user is allowed to edit this event. |
| 231 | 266 | if ($event['member'] != $member_id) |
| 232 | - isAllowedTo('calendar_edit_any'); |
|
| 267 | + { |
|
| 268 | + isAllowedTo('calendar_edit_any'); |
|
| 269 | + } |
|
| 233 | 270 | elseif (!allowedTo('calendar_edit_any')) |
| 234 | - isAllowedTo('calendar_edit_own'); |
|
| 271 | + { |
|
| 272 | + isAllowedTo('calendar_edit_own'); |
|
| 273 | + } |
|
| 235 | 274 | } |
| 236 | 275 | |
| 237 | 276 | return $event; |