@@ -929,7 +929,7 @@ discard block |
||
929 | 929 | * Doesn't clean the inputs |
930 | 930 | * |
931 | 931 | * @param array $items_ids The items to remove |
932 | - * @param bool|int $group_id The ID of the group these triggers are associated with or false if deleting them from all groups |
|
932 | + * @param integer $group_id The ID of the group these triggers are associated with or false if deleting them from all groups |
|
933 | 933 | * @return bool Always returns true |
934 | 934 | */ |
935 | 935 | function removeBanTriggers($items_ids = array(), $group_id = false) |
@@ -1123,7 +1123,7 @@ discard block |
||
1123 | 1123 | * Errors in $context['ban_errors'] |
1124 | 1124 | * |
1125 | 1125 | * @param array $triggers The triggers to validate |
1126 | - * @return array An array of riggers and log info ready to be used |
|
1126 | + * @return integer An array of riggers and log info ready to be used |
|
1127 | 1127 | */ |
1128 | 1128 | function validateTriggers(&$triggers) |
1129 | 1129 | { |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | ) |
785 | 785 | ); |
786 | 786 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
787 | - $error_ips[] = inet_dtop($row['ip']); |
|
787 | + $error_ips[] = inet_dtop($row['ip']); |
|
788 | 788 | $smcFunc['db_free_result']($request); |
789 | 789 | |
790 | 790 | return $error_ips; |
@@ -2168,9 +2168,9 @@ discard block |
||
2168 | 2168 | |
2169 | 2169 | if ($low == '255.255.255.255') return 'unknown'; |
2170 | 2170 | if ($low == $high) |
2171 | - return $low; |
|
2171 | + return $low; |
|
2172 | 2172 | else |
2173 | - return $low . '-' . $high; |
|
2173 | + return $low . '-' . $high; |
|
2174 | 2174 | } |
2175 | 2175 | |
2176 | 2176 | /** |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Ban center. The main entrance point for all ban center functions. |
@@ -120,10 +121,11 @@ discard block |
||
120 | 121 | } |
121 | 122 | |
122 | 123 | // Create a date string so we don't overload them with date info. |
123 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
124 | - $context['ban_time_format'] = $user_info['time_format']; |
|
125 | - else |
|
126 | - $context['ban_time_format'] = $matches[0]; |
|
124 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
125 | + $context['ban_time_format'] = $user_info['time_format']; |
|
126 | + } else { |
|
127 | + $context['ban_time_format'] = $matches[0]; |
|
128 | + } |
|
127 | 129 | |
128 | 130 | $listOptions = array( |
129 | 131 | 'id' => 'ban_list', |
@@ -201,16 +203,19 @@ discard block |
||
201 | 203 | 'function' => function($rowData) use ($txt) |
202 | 204 | { |
203 | 205 | // This ban never expires...whahaha. |
204 | - if ($rowData['expire_time'] === null) |
|
205 | - return $txt['never']; |
|
206 | + if ($rowData['expire_time'] === null) { |
|
207 | + return $txt['never']; |
|
208 | + } |
|
206 | 209 | |
207 | 210 | // This ban has already expired. |
208 | - elseif ($rowData['expire_time'] < time()) |
|
209 | - return sprintf('<span class="red">%1$s</span>', $txt['ban_expired']); |
|
211 | + elseif ($rowData['expire_time'] < time()) { |
|
212 | + return sprintf('<span class="red">%1$s</span>', $txt['ban_expired']); |
|
213 | + } |
|
210 | 214 | |
211 | 215 | // Still need to wait a few days for this ban to expire. |
212 | - else |
|
213 | - return sprintf('%1$d %2$s', ceil(($rowData['expire_time'] - time()) / (60 * 60 * 24)), $txt['ban_days']); |
|
216 | + else { |
|
217 | + return sprintf('%1$d %2$s', ceil(($rowData['expire_time'] - time()) / (60 * 60 * 24)), $txt['ban_days']); |
|
218 | + } |
|
214 | 219 | }, |
215 | 220 | ), |
216 | 221 | 'sort' => array( |
@@ -309,8 +314,9 @@ discard block |
||
309 | 314 | ) |
310 | 315 | ); |
311 | 316 | $bans = array(); |
312 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
313 | - $bans[] = $row; |
|
317 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
318 | + $bans[] = $row; |
|
319 | + } |
|
314 | 320 | |
315 | 321 | $smcFunc['db_free_result']($request); |
316 | 322 | |
@@ -352,8 +358,9 @@ discard block |
||
352 | 358 | { |
353 | 359 | global $txt, $modSettings, $context, $scripturl, $smcFunc, $sourcedir; |
354 | 360 | |
355 | - if ((isset($_POST['add_ban']) || isset($_POST['modify_ban']) || isset($_POST['remove_selection'])) && empty($context['ban_errors'])) |
|
356 | - BanEdit2(); |
|
361 | + if ((isset($_POST['add_ban']) || isset($_POST['modify_ban']) || isset($_POST['remove_selection'])) && empty($context['ban_errors'])) { |
|
362 | + BanEdit2(); |
|
363 | + } |
|
357 | 364 | |
358 | 365 | $ban_group_id = isset($context['ban']['id']) ? $context['ban']['id'] : (isset($_REQUEST['bg']) ? (int) $_REQUEST['bg'] : 0); |
359 | 366 | |
@@ -364,10 +371,10 @@ discard block |
||
364 | 371 | |
365 | 372 | if (!empty($context['ban_errors'])) |
366 | 373 | { |
367 | - foreach ($context['ban_errors'] as $error) |
|
368 | - $context['error_messages'][$error] = $txt[$error]; |
|
369 | - } |
|
370 | - else |
|
374 | + foreach ($context['ban_errors'] as $error) { |
|
375 | + $context['error_messages'][$error] = $txt[$error]; |
|
376 | + } |
|
377 | + } else |
|
371 | 378 | { |
372 | 379 | // If we're editing an existing ban, get it from the database. |
373 | 380 | if (!empty($ban_group_id)) |
@@ -403,12 +410,13 @@ discard block |
||
403 | 410 | 'data' => array( |
404 | 411 | 'function' => function($ban_item) use ($txt) |
405 | 412 | { |
406 | - if (in_array($ban_item['type'], array('ip', 'hostname', 'email'))) |
|
407 | - return '<strong>' . $txt[$ban_item['type']] . ':</strong> ' . $ban_item[$ban_item['type']]; |
|
408 | - elseif ($ban_item['type'] == 'user') |
|
409 | - return '<strong>' . $txt['username'] . ':</strong> ' . $ban_item['user']['link']; |
|
410 | - else |
|
411 | - return '<strong>' . $txt['unknown'] . ':</strong> ' . $ban_item['no_bantype_selected']; |
|
413 | + if (in_array($ban_item['type'], array('ip', 'hostname', 'email'))) { |
|
414 | + return '<strong>' . $txt[$ban_item['type']] . ':</strong> ' . $ban_item[$ban_item['type']]; |
|
415 | + } elseif ($ban_item['type'] == 'user') { |
|
416 | + return '<strong>' . $txt['username'] . ':</strong> ' . $ban_item['user']['link']; |
|
417 | + } else { |
|
418 | + return '<strong>' . $txt['unknown'] . ':</strong> ' . $ban_item['no_bantype_selected']; |
|
419 | + } |
|
412 | 420 | }, |
413 | 421 | 'style' => 'text-align: left;', |
414 | 422 | ), |
@@ -546,8 +554,9 @@ discard block |
||
546 | 554 | $context['ban']['from_user'] = true; |
547 | 555 | |
548 | 556 | // Would be nice if we could also ban the hostname. |
549 | - if ((preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $context['ban_suggestions']['main_ip']) == 1 || isValidIPv6($context['ban_suggestions']['main_ip'])) && empty($modSettings['disableHostnameLookup'])) |
|
550 | - $context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']); |
|
557 | + if ((preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $context['ban_suggestions']['main_ip']) == 1 || isValidIPv6($context['ban_suggestions']['main_ip'])) && empty($modSettings['disableHostnameLookup'])) { |
|
558 | + $context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']); |
|
559 | + } |
|
551 | 560 | |
552 | 561 | $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
553 | 562 | } |
@@ -615,8 +624,9 @@ discard block |
||
615 | 624 | 'items_per_page' => $items_per_page, |
616 | 625 | ) |
617 | 626 | ); |
618 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
619 | - fatal_lang_error('ban_not_found', false); |
|
627 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
628 | + fatal_lang_error('ban_not_found', false); |
|
629 | + } |
|
620 | 630 | |
621 | 631 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
622 | 632 | { |
@@ -653,18 +663,15 @@ discard block |
||
653 | 663 | { |
654 | 664 | $ban_items[$row['id_ban']]['type'] = 'ip'; |
655 | 665 | $ban_items[$row['id_ban']]['ip'] = range2ip($row['ip_low'], $row['ip_high']); |
656 | - } |
|
657 | - elseif (!empty($row['hostname'])) |
|
666 | + } elseif (!empty($row['hostname'])) |
|
658 | 667 | { |
659 | 668 | $ban_items[$row['id_ban']]['type'] = 'hostname'; |
660 | 669 | $ban_items[$row['id_ban']]['hostname'] = str_replace('%', '*', $row['hostname']); |
661 | - } |
|
662 | - elseif (!empty($row['email_address'])) |
|
670 | + } elseif (!empty($row['email_address'])) |
|
663 | 671 | { |
664 | 672 | $ban_items[$row['id_ban']]['type'] = 'email'; |
665 | 673 | $ban_items[$row['id_ban']]['email'] = str_replace('%', '*', $row['email_address']); |
666 | - } |
|
667 | - elseif (!empty($row['id_member'])) |
|
674 | + } elseif (!empty($row['id_member'])) |
|
668 | 675 | { |
669 | 676 | $ban_items[$row['id_ban']]['type'] = 'user'; |
670 | 677 | $ban_items[$row['id_ban']]['user'] = array( |
@@ -730,9 +737,10 @@ discard block |
||
730 | 737 | $search_list += array('ips_in_messages' => 'banLoadAdditionalIPsMember', 'ips_in_errors' => 'banLoadAdditionalIPsError'); |
731 | 738 | |
732 | 739 | $return = array(); |
733 | - foreach ($search_list as $key => $callable) |
|
734 | - if (is_callable($callable)) |
|
740 | + foreach ($search_list as $key => $callable) { |
|
741 | + if (is_callable($callable)) |
|
735 | 742 | $return[$key] = call_user_func($callable, $member_id); |
743 | + } |
|
736 | 744 | |
737 | 745 | return $return; |
738 | 746 | } |
@@ -757,8 +765,9 @@ discard block |
||
757 | 765 | 'current_user' => $member_id, |
758 | 766 | ) |
759 | 767 | ); |
760 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
761 | - $message_ips[] = inet_dtop($row['poster_ip']); |
|
768 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
769 | + $message_ips[] = inet_dtop($row['poster_ip']); |
|
770 | + } |
|
762 | 771 | $smcFunc['db_free_result']($request); |
763 | 772 | |
764 | 773 | return $message_ips; |
@@ -783,8 +792,9 @@ discard block |
||
783 | 792 | 'current_user' => $member_id, |
784 | 793 | ) |
785 | 794 | ); |
786 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
787 | - $error_ips[] = inet_dtop($row['ip']); |
|
795 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
796 | + $error_ips[] = inet_dtop($row['ip']); |
|
797 | + } |
|
788 | 798 | $smcFunc['db_free_result']($request); |
789 | 799 | |
790 | 800 | return $error_ips; |
@@ -825,11 +835,13 @@ discard block |
||
825 | 835 | $ban_info['cannot']['login'] = !empty($ban_info['full_ban']) || empty($_POST['cannot_login']) ? 0 : 1; |
826 | 836 | |
827 | 837 | // Adding a new ban group |
828 | - if (empty($_REQUEST['bg'])) |
|
829 | - $ban_group_id = insertBanGroup($ban_info); |
|
838 | + if (empty($_REQUEST['bg'])) { |
|
839 | + $ban_group_id = insertBanGroup($ban_info); |
|
840 | + } |
|
830 | 841 | // Editing an existing ban group |
831 | - else |
|
832 | - $ban_group_id = updateBanGroup($ban_info); |
|
842 | + else { |
|
843 | + $ban_group_id = updateBanGroup($ban_info); |
|
844 | + } |
|
833 | 845 | |
834 | 846 | if (is_numeric($ban_group_id)) |
835 | 847 | { |
@@ -840,9 +852,10 @@ discard block |
||
840 | 852 | $context['ban'] = $ban_info; |
841 | 853 | } |
842 | 854 | |
843 | - if (isset($_POST['ban_suggestions'])) |
|
844 | - // @TODO: is $_REQUEST['bi'] ever set? |
|
855 | + if (isset($_POST['ban_suggestions'])) { |
|
856 | + // @TODO: is $_REQUEST['bi'] ever set? |
|
845 | 857 | $saved_triggers = saveTriggers($_POST['ban_suggestions'], $ban_info['id'], isset($_REQUEST['u']) ? (int) $_REQUEST['u'] : 0, isset($_REQUEST['bi']) ? (int) $_REQUEST['bi'] : 0); |
858 | + } |
|
846 | 859 | |
847 | 860 | // Something went wrong somewhere... Oh well, let's go back. |
848 | 861 | if (!empty($context['ban_errors'])) |
@@ -852,8 +865,9 @@ discard block |
||
852 | 865 | $context['ban_suggestions'] = array_merge($context['ban_suggestions'], getMemberData((int) $_REQUEST['u'])); |
853 | 866 | |
854 | 867 | // Not strictly necessary, but it's nice |
855 | - if (!empty($context['ban_suggestions']['member']['id'])) |
|
856 | - $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
|
868 | + if (!empty($context['ban_suggestions']['member']['id'])) { |
|
869 | + $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
|
870 | + } |
|
857 | 871 | return BanEdit(); |
858 | 872 | } |
859 | 873 | $context['ban_suggestions']['saved_triggers'] = !empty($saved_triggers) ? $saved_triggers : array(); |
@@ -902,10 +916,11 @@ discard block |
||
902 | 916 | |
903 | 917 | foreach ($suggestions as $key => $value) |
904 | 918 | { |
905 | - if (is_array($value)) |
|
906 | - $triggers[$key] = $value; |
|
907 | - else |
|
908 | - $triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : ''; |
|
919 | + if (is_array($value)) { |
|
920 | + $triggers[$key] = $value; |
|
921 | + } else { |
|
922 | + $triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : ''; |
|
923 | + } |
|
909 | 924 | } |
910 | 925 | |
911 | 926 | $ban_triggers = validateTriggers($triggers); |
@@ -913,16 +928,18 @@ discard block |
||
913 | 928 | // Time to save! |
914 | 929 | if (!empty($ban_triggers['ban_triggers']) && empty($context['ban_errors'])) |
915 | 930 | { |
916 | - if (empty($ban_id)) |
|
917 | - addTriggers($ban_group, $ban_triggers['ban_triggers'], $ban_triggers['log_info']); |
|
918 | - else |
|
919 | - updateTriggers($ban_id, $ban_group, array_shift($ban_triggers['ban_triggers']), $ban_triggers['log_info']); |
|
931 | + if (empty($ban_id)) { |
|
932 | + addTriggers($ban_group, $ban_triggers['ban_triggers'], $ban_triggers['log_info']); |
|
933 | + } else { |
|
934 | + updateTriggers($ban_id, $ban_group, array_shift($ban_triggers['ban_triggers']), $ban_triggers['log_info']); |
|
935 | + } |
|
936 | + } |
|
937 | + if (!empty($context['ban_errors'])) { |
|
938 | + return $triggers; |
|
939 | + } else { |
|
940 | + return false; |
|
941 | + } |
|
920 | 942 | } |
921 | - if (!empty($context['ban_errors'])) |
|
922 | - return $triggers; |
|
923 | - else |
|
924 | - return false; |
|
925 | -} |
|
926 | 943 | |
927 | 944 | /** |
928 | 945 | * This function removes a bunch of triggers based on ids |
@@ -936,14 +953,17 @@ discard block |
||
936 | 953 | { |
937 | 954 | global $smcFunc, $scripturl; |
938 | 955 | |
939 | - if ($group_id !== false) |
|
940 | - $group_id = (int) $group_id; |
|
956 | + if ($group_id !== false) { |
|
957 | + $group_id = (int) $group_id; |
|
958 | + } |
|
941 | 959 | |
942 | - if (empty($group_id) && empty($items_ids)) |
|
943 | - return false; |
|
960 | + if (empty($group_id) && empty($items_ids)) { |
|
961 | + return false; |
|
962 | + } |
|
944 | 963 | |
945 | - if (!is_array($items_ids)) |
|
946 | - $items_ids = array($items_ids); |
|
964 | + if (!is_array($items_ids)) { |
|
965 | + $items_ids = array($items_ids); |
|
966 | + } |
|
947 | 967 | |
948 | 968 | $log_info = array(); |
949 | 969 | $ban_items = array(); |
@@ -981,8 +1001,7 @@ discard block |
||
981 | 1001 | 'bantype' => ($is_range ? 'ip_range' : 'main_ip'), |
982 | 1002 | 'value' => $ban_items[$row['id_ban']]['ip'], |
983 | 1003 | ); |
984 | - } |
|
985 | - elseif (!empty($row['hostname'])) |
|
1004 | + } elseif (!empty($row['hostname'])) |
|
986 | 1005 | { |
987 | 1006 | $ban_items[$row['id_ban']]['type'] = 'hostname'; |
988 | 1007 | $ban_items[$row['id_ban']]['hostname'] = str_replace('%', '*', $row['hostname']); |
@@ -990,8 +1009,7 @@ discard block |
||
990 | 1009 | 'bantype' => 'hostname', |
991 | 1010 | 'value' => $row['hostname'], |
992 | 1011 | ); |
993 | - } |
|
994 | - elseif (!empty($row['email_address'])) |
|
1012 | + } elseif (!empty($row['email_address'])) |
|
995 | 1013 | { |
996 | 1014 | $ban_items[$row['id_ban']]['type'] = 'email'; |
997 | 1015 | $ban_items[$row['id_ban']]['email'] = str_replace('%', '*', $row['email_address']); |
@@ -999,8 +1017,7 @@ discard block |
||
999 | 1017 | 'bantype' => 'email', |
1000 | 1018 | 'value' => $ban_items[$row['id_ban']]['email'], |
1001 | 1019 | ); |
1002 | - } |
|
1003 | - elseif (!empty($row['id_member'])) |
|
1020 | + } elseif (!empty($row['id_member'])) |
|
1004 | 1021 | { |
1005 | 1022 | $ban_items[$row['id_ban']]['type'] = 'user'; |
1006 | 1023 | $ban_items[$row['id_ban']]['user'] = array( |
@@ -1033,8 +1050,7 @@ discard block |
||
1033 | 1050 | 'ban_group' => $group_id, |
1034 | 1051 | ) |
1035 | 1052 | ); |
1036 | - } |
|
1037 | - elseif (!empty($items_ids)) |
|
1053 | + } elseif (!empty($items_ids)) |
|
1038 | 1054 | { |
1039 | 1055 | $smcFunc['db_query']('', ' |
1040 | 1056 | DELETE FROM {db_prefix}ban_items |
@@ -1059,13 +1075,15 @@ discard block |
||
1059 | 1075 | { |
1060 | 1076 | global $smcFunc; |
1061 | 1077 | |
1062 | - if (!is_array($group_ids)) |
|
1063 | - $group_ids = array($group_ids); |
|
1078 | + if (!is_array($group_ids)) { |
|
1079 | + $group_ids = array($group_ids); |
|
1080 | + } |
|
1064 | 1081 | |
1065 | 1082 | $group_ids = array_unique($group_ids); |
1066 | 1083 | |
1067 | - if (empty($group_ids)) |
|
1068 | - return false; |
|
1084 | + if (empty($group_ids)) { |
|
1085 | + return false; |
|
1086 | + } |
|
1069 | 1087 | |
1070 | 1088 | $smcFunc['db_query']('', ' |
1071 | 1089 | DELETE FROM {db_prefix}ban_groups |
@@ -1089,21 +1107,23 @@ discard block |
||
1089 | 1107 | { |
1090 | 1108 | global $smcFunc; |
1091 | 1109 | |
1092 | - if (empty($ids)) |
|
1093 | - $smcFunc['db_query']('truncate_table', ' |
|
1110 | + if (empty($ids)) { |
|
1111 | + $smcFunc['db_query']('truncate_table', ' |
|
1094 | 1112 | TRUNCATE {db_prefix}log_banned', |
1095 | 1113 | array( |
1096 | 1114 | ) |
1097 | 1115 | ); |
1098 | - else |
|
1116 | + } else |
|
1099 | 1117 | { |
1100 | - if (!is_array($ids)) |
|
1101 | - $ids = array($ids); |
|
1118 | + if (!is_array($ids)) { |
|
1119 | + $ids = array($ids); |
|
1120 | + } |
|
1102 | 1121 | |
1103 | 1122 | $ids = array_unique($ids); |
1104 | 1123 | |
1105 | - if (empty($ids)) |
|
1106 | - return false; |
|
1124 | + if (empty($ids)) { |
|
1125 | + return false; |
|
1126 | + } |
|
1107 | 1127 | |
1108 | 1128 | $smcFunc['db_query']('', ' |
1109 | 1129 | DELETE FROM {db_prefix}log_banned |
@@ -1129,8 +1149,9 @@ discard block |
||
1129 | 1149 | { |
1130 | 1150 | global $context, $smcFunc; |
1131 | 1151 | |
1132 | - if (empty($triggers)) |
|
1133 | - $context['ban_erros'][] = 'ban_empty_triggers'; |
|
1152 | + if (empty($triggers)) { |
|
1153 | + $context['ban_erros'][] = 'ban_empty_triggers'; |
|
1154 | + } |
|
1134 | 1155 | |
1135 | 1156 | $ban_triggers = array(); |
1136 | 1157 | $log_info = array(); |
@@ -1139,39 +1160,39 @@ discard block |
||
1139 | 1160 | { |
1140 | 1161 | if (!empty($value)) |
1141 | 1162 | { |
1142 | - if ($key == 'member') |
|
1143 | - continue; |
|
1163 | + if ($key == 'member') { |
|
1164 | + continue; |
|
1165 | + } |
|
1144 | 1166 | |
1145 | 1167 | if ($key == 'main_ip') |
1146 | 1168 | { |
1147 | 1169 | $value = trim($value); |
1148 | 1170 | $ip_parts = ip2range($value); |
1149 | - if (!checkExistingTriggerIP($ip_parts, $value)) |
|
1150 | - $context['ban_erros'][] = 'invalid_ip'; |
|
1151 | - else |
|
1171 | + if (!checkExistingTriggerIP($ip_parts, $value)) { |
|
1172 | + $context['ban_erros'][] = 'invalid_ip'; |
|
1173 | + } else |
|
1152 | 1174 | { |
1153 | 1175 | $ban_triggers['main_ip'] = array( |
1154 | 1176 | 'ip_low' => $ip_parts['low'], |
1155 | 1177 | 'ip_high' => $ip_parts['high'] |
1156 | 1178 | ); |
1157 | 1179 | } |
1158 | - } |
|
1159 | - elseif ($key == 'hostname') |
|
1180 | + } elseif ($key == 'hostname') |
|
1160 | 1181 | { |
1161 | - if (preg_match('/[^\w.\-*]/', $value) == 1) |
|
1162 | - $context['ban_erros'][] = 'invalid_hostname'; |
|
1163 | - else |
|
1182 | + if (preg_match('/[^\w.\-*]/', $value) == 1) { |
|
1183 | + $context['ban_erros'][] = 'invalid_hostname'; |
|
1184 | + } else |
|
1164 | 1185 | { |
1165 | 1186 | // Replace the * wildcard by a MySQL wildcard %. |
1166 | 1187 | $value = substr(str_replace('*', '%', $value), 0, 255); |
1167 | 1188 | |
1168 | 1189 | $ban_triggers['hostname']['hostname'] = $value; |
1169 | 1190 | } |
1170 | - } |
|
1171 | - elseif ($key == 'email') |
|
1191 | + } elseif ($key == 'email') |
|
1172 | 1192 | { |
1173 | - if (preg_match('/[^\w.\-\+*@]/', $value) == 1) |
|
1174 | - $context['ban_erros'][] = 'invalid_email'; |
|
1193 | + if (preg_match('/[^\w.\-\+*@]/', $value) == 1) { |
|
1194 | + $context['ban_erros'][] = 'invalid_email'; |
|
1195 | + } |
|
1175 | 1196 | |
1176 | 1197 | // Check the user is not banning an admin. |
1177 | 1198 | $request = $smcFunc['db_query']('', ' |
@@ -1185,15 +1206,15 @@ discard block |
||
1185 | 1206 | 'email' => $value, |
1186 | 1207 | ) |
1187 | 1208 | ); |
1188 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1189 | - $context['ban_erros'][] = 'no_ban_admin'; |
|
1209 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1210 | + $context['ban_erros'][] = 'no_ban_admin'; |
|
1211 | + } |
|
1190 | 1212 | $smcFunc['db_free_result']($request); |
1191 | 1213 | |
1192 | 1214 | $value = substr(strtolower(str_replace('*', '%', $value)), 0, 255); |
1193 | 1215 | |
1194 | 1216 | $ban_triggers['email']['email_address'] = $value; |
1195 | - } |
|
1196 | - elseif ($key == 'user') |
|
1217 | + } elseif ($key == 'user') |
|
1197 | 1218 | { |
1198 | 1219 | $user = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $smcFunc['htmlspecialchars']($value, ENT_QUOTES)); |
1199 | 1220 | |
@@ -1207,8 +1228,9 @@ discard block |
||
1207 | 1228 | 'username' => $user, |
1208 | 1229 | ) |
1209 | 1230 | ); |
1210 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1211 | - $context['ban_erros'][] = 'invalid_username'; |
|
1231 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1232 | + $context['ban_erros'][] = 'invalid_username'; |
|
1233 | + } |
|
1212 | 1234 | list ($value, $isAdmin) = $smcFunc['db_fetch_row']($request); |
1213 | 1235 | $smcFunc['db_free_result']($request); |
1214 | 1236 | |
@@ -1216,25 +1238,25 @@ discard block |
||
1216 | 1238 | { |
1217 | 1239 | unset($value); |
1218 | 1240 | $context['ban_erros'][] = 'no_ban_admin'; |
1241 | + } else { |
|
1242 | + $ban_triggers['user']['id_member'] = $value; |
|
1219 | 1243 | } |
1220 | - else |
|
1221 | - $ban_triggers['user']['id_member'] = $value; |
|
1222 | - } |
|
1223 | - elseif (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
1244 | + } elseif (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
1224 | 1245 | { |
1225 | 1246 | // Special case, those two are arrays themselves |
1226 | 1247 | $values = array_unique($value); |
1227 | 1248 | // Don't add the main IP again. |
1228 | - if (isset($triggers['main_ip'])) |
|
1229 | - $values = array_diff($values, array($triggers['main_ip'])); |
|
1249 | + if (isset($triggers['main_ip'])) { |
|
1250 | + $values = array_diff($values, array($triggers['main_ip'])); |
|
1251 | + } |
|
1230 | 1252 | unset($value); |
1231 | 1253 | foreach ($values as $val) |
1232 | 1254 | { |
1233 | 1255 | $val = trim($val); |
1234 | 1256 | $ip_parts = ip2range($val); |
1235 | - if (!checkExistingTriggerIP($ip_parts, $val)) |
|
1236 | - $context['ban_erros'][] = 'invalid_ip'; |
|
1237 | - else |
|
1257 | + if (!checkExistingTriggerIP($ip_parts, $val)) { |
|
1258 | + $context['ban_erros'][] = 'invalid_ip'; |
|
1259 | + } else |
|
1238 | 1260 | { |
1239 | 1261 | $ban_triggers[$key][] = array( |
1240 | 1262 | 'ip_low' => $ip_parts['low'], |
@@ -1247,15 +1269,16 @@ discard block |
||
1247 | 1269 | ); |
1248 | 1270 | } |
1249 | 1271 | } |
1272 | + } else { |
|
1273 | + $context['ban_erros'][] = 'no_bantype_selected'; |
|
1250 | 1274 | } |
1251 | - else |
|
1252 | - $context['ban_erros'][] = 'no_bantype_selected'; |
|
1253 | 1275 | |
1254 | - if (isset($value) && !is_array($value)) |
|
1255 | - $log_info[] = array( |
|
1276 | + if (isset($value) && !is_array($value)) { |
|
1277 | + $log_info[] = array( |
|
1256 | 1278 | 'value' => $value, |
1257 | 1279 | 'bantype' => $key, |
1258 | 1280 | ); |
1281 | + } |
|
1259 | 1282 | } |
1260 | 1283 | } |
1261 | 1284 | return array('ban_triggers' => $ban_triggers, 'log_info' => $log_info); |
@@ -1275,8 +1298,9 @@ discard block |
||
1275 | 1298 | { |
1276 | 1299 | global $smcFunc, $context; |
1277 | 1300 | |
1278 | - if (empty($group_id)) |
|
1279 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
1301 | + if (empty($group_id)) { |
|
1302 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
1303 | + } |
|
1280 | 1304 | |
1281 | 1305 | // Preset all values that are required. |
1282 | 1306 | $values = array( |
@@ -1301,18 +1325,21 @@ discard block |
||
1301 | 1325 | foreach ($triggers as $key => $trigger) |
1302 | 1326 | { |
1303 | 1327 | // Exceptions, exceptions, exceptions...always exceptions... :P |
1304 | - if (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
1305 | - foreach ($trigger as $real_trigger) |
|
1328 | + if (in_array($key, array('ips_in_messages', 'ips_in_errors'))) { |
|
1329 | + foreach ($trigger as $real_trigger) |
|
1306 | 1330 | $insertTriggers[] = array_merge($values, $real_trigger); |
1307 | - else |
|
1308 | - $insertTriggers[] = array_merge($values, $trigger); |
|
1331 | + } else { |
|
1332 | + $insertTriggers[] = array_merge($values, $trigger); |
|
1333 | + } |
|
1309 | 1334 | } |
1310 | 1335 | |
1311 | - if (empty($insertTriggers)) |
|
1312 | - $context['ban_errors'][] = 'ban_no_triggers'; |
|
1336 | + if (empty($insertTriggers)) { |
|
1337 | + $context['ban_errors'][] = 'ban_no_triggers'; |
|
1338 | + } |
|
1313 | 1339 | |
1314 | - if (!empty($context['ban_errors'])) |
|
1315 | - return false; |
|
1340 | + if (!empty($context['ban_errors'])) { |
|
1341 | + return false; |
|
1342 | + } |
|
1316 | 1343 | |
1317 | 1344 | $smcFunc['db_insert']('', |
1318 | 1345 | '{db_prefix}ban_items', |
@@ -1340,15 +1367,19 @@ discard block |
||
1340 | 1367 | { |
1341 | 1368 | global $smcFunc, $context; |
1342 | 1369 | |
1343 | - if (empty($ban_item)) |
|
1344 | - $context['ban_errors'][] = 'ban_ban_item_empty'; |
|
1345 | - if (empty($group_id)) |
|
1346 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
1347 | - if (empty($trigger)) |
|
1348 | - $context['ban_errors'][] = 'ban_no_triggers'; |
|
1370 | + if (empty($ban_item)) { |
|
1371 | + $context['ban_errors'][] = 'ban_ban_item_empty'; |
|
1372 | + } |
|
1373 | + if (empty($group_id)) { |
|
1374 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
1375 | + } |
|
1376 | + if (empty($trigger)) { |
|
1377 | + $context['ban_errors'][] = 'ban_no_triggers'; |
|
1378 | + } |
|
1349 | 1379 | |
1350 | - if (!empty($context['ban_errors'])) |
|
1351 | - return; |
|
1380 | + if (!empty($context['ban_errors'])) { |
|
1381 | + return; |
|
1382 | + } |
|
1352 | 1383 | |
1353 | 1384 | // Preset all values that are required. |
1354 | 1385 | $values = array( |
@@ -1389,8 +1420,9 @@ discard block |
||
1389 | 1420 | */ |
1390 | 1421 | function logTriggersUpdates($logs, $new = true, $removal = false) |
1391 | 1422 | { |
1392 | - if (empty($logs)) |
|
1393 | - return; |
|
1423 | + if (empty($logs)) { |
|
1424 | + return; |
|
1425 | + } |
|
1394 | 1426 | |
1395 | 1427 | $log_name_map = array( |
1396 | 1428 | 'main_ip' => 'ip_range', |
@@ -1401,14 +1433,15 @@ discard block |
||
1401 | 1433 | ); |
1402 | 1434 | |
1403 | 1435 | // Log the addion of the ban entries into the moderation log. |
1404 | - foreach ($logs as $log) |
|
1405 | - logAction('ban' . ($removal == true ? 'remove' : ''), array( |
|
1436 | + foreach ($logs as $log) { |
|
1437 | + logAction('ban' . ($removal == true ? 'remove' : ''), array( |
|
1406 | 1438 | $log_name_map[$log['bantype']] => $log['value'], |
1407 | 1439 | 'new' => empty($new) ? 0 : 1, |
1408 | 1440 | 'remove' => empty($removal) ? 0 : 1, |
1409 | 1441 | 'type' => $log['bantype'], |
1410 | 1442 | )); |
1411 | -} |
|
1443 | + } |
|
1444 | + } |
|
1412 | 1445 | |
1413 | 1446 | /** |
1414 | 1447 | * Updates an existing ban group |
@@ -1422,12 +1455,15 @@ discard block |
||
1422 | 1455 | { |
1423 | 1456 | global $smcFunc, $context; |
1424 | 1457 | |
1425 | - if (empty($ban_info['name'])) |
|
1426 | - $context['ban_errors'][] = 'ban_name_empty'; |
|
1427 | - if (empty($ban_info['id'])) |
|
1428 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
1429 | - if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) |
|
1430 | - $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
1458 | + if (empty($ban_info['name'])) { |
|
1459 | + $context['ban_errors'][] = 'ban_name_empty'; |
|
1460 | + } |
|
1461 | + if (empty($ban_info['id'])) { |
|
1462 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
1463 | + } |
|
1464 | + if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) { |
|
1465 | + $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
1466 | + } |
|
1431 | 1467 | |
1432 | 1468 | if (!empty($ban_info['id'])) |
1433 | 1469 | { |
@@ -1442,8 +1478,9 @@ discard block |
||
1442 | 1478 | ) |
1443 | 1479 | ); |
1444 | 1480 | |
1445 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1446 | - $context['ban_errors'][] = 'ban_not_found'; |
|
1481 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1482 | + $context['ban_errors'][] = 'ban_not_found'; |
|
1483 | + } |
|
1447 | 1484 | $smcFunc['db_free_result']($request); |
1448 | 1485 | } |
1449 | 1486 | |
@@ -1461,13 +1498,15 @@ discard block |
||
1461 | 1498 | 'new_ban_name' => $ban_info['name'], |
1462 | 1499 | ) |
1463 | 1500 | ); |
1464 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1465 | - $context['ban_errors'][] = 'ban_name_exists'; |
|
1501 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1502 | + $context['ban_errors'][] = 'ban_name_exists'; |
|
1503 | + } |
|
1466 | 1504 | $smcFunc['db_free_result']($request); |
1467 | 1505 | } |
1468 | 1506 | |
1469 | - if (!empty($context['ban_errors'])) |
|
1470 | - return $ban_info['id']; |
|
1507 | + if (!empty($context['ban_errors'])) { |
|
1508 | + return $ban_info['id']; |
|
1509 | + } |
|
1471 | 1510 | |
1472 | 1511 | $smcFunc['db_query']('', ' |
1473 | 1512 | UPDATE {db_prefix}ban_groups |
@@ -1511,10 +1550,12 @@ discard block |
||
1511 | 1550 | { |
1512 | 1551 | global $smcFunc, $context; |
1513 | 1552 | |
1514 | - if (empty($ban_info['name'])) |
|
1515 | - $context['ban_errors'][] = 'ban_name_empty'; |
|
1516 | - if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) |
|
1517 | - $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
1553 | + if (empty($ban_info['name'])) { |
|
1554 | + $context['ban_errors'][] = 'ban_name_empty'; |
|
1555 | + } |
|
1556 | + if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) { |
|
1557 | + $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
1558 | + } |
|
1518 | 1559 | |
1519 | 1560 | if (!empty($ban_info['name'])) |
1520 | 1561 | { |
@@ -1529,13 +1570,15 @@ discard block |
||
1529 | 1570 | ) |
1530 | 1571 | ); |
1531 | 1572 | |
1532 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
1533 | - $context['ban_errors'][] = 'ban_name_exists'; |
|
1573 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
1574 | + $context['ban_errors'][] = 'ban_name_exists'; |
|
1575 | + } |
|
1534 | 1576 | $smcFunc['db_free_result']($request); |
1535 | 1577 | } |
1536 | 1578 | |
1537 | - if (!empty($context['ban_errors'])) |
|
1538 | - return; |
|
1579 | + if (!empty($context['ban_errors'])) { |
|
1580 | + return; |
|
1581 | + } |
|
1539 | 1582 | |
1540 | 1583 | // Yes yes, we're ready to add now. |
1541 | 1584 | $smcFunc['db_insert']('', |
@@ -1552,8 +1595,9 @@ discard block |
||
1552 | 1595 | ); |
1553 | 1596 | $ban_info['id'] = $smcFunc['db_insert_id']('{db_prefix}ban_groups', 'id_ban_group'); |
1554 | 1597 | |
1555 | - if (empty($ban_info['id'])) |
|
1556 | - $context['ban_errors'][] = 'impossible_insert_new_bangroup'; |
|
1598 | + if (empty($ban_info['id'])) { |
|
1599 | + $context['ban_errors'][] = 'impossible_insert_new_bangroup'; |
|
1600 | + } |
|
1557 | 1601 | |
1558 | 1602 | return $ban_info['id']; |
1559 | 1603 | } |
@@ -1578,24 +1622,24 @@ discard block |
||
1578 | 1622 | $ban_group = isset($_REQUEST['bg']) ? (int) $_REQUEST['bg'] : 0; |
1579 | 1623 | $ban_id = isset($_REQUEST['bi']) ? (int) $_REQUEST['bi'] : 0; |
1580 | 1624 | |
1581 | - if (empty($ban_group)) |
|
1582 | - fatal_lang_error('ban_not_found', false); |
|
1625 | + if (empty($ban_group)) { |
|
1626 | + fatal_lang_error('ban_not_found', false); |
|
1627 | + } |
|
1583 | 1628 | |
1584 | 1629 | if (isset($_POST['add_new_trigger']) && !empty($_POST['ban_suggestions'])) |
1585 | 1630 | { |
1586 | 1631 | saveTriggers($_POST['ban_suggestions'], $ban_group, 0, $ban_id); |
1587 | 1632 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
1588 | - } |
|
1589 | - elseif (isset($_POST['edit_trigger']) && !empty($_POST['ban_suggestions'])) |
|
1633 | + } elseif (isset($_POST['edit_trigger']) && !empty($_POST['ban_suggestions'])) |
|
1590 | 1634 | { |
1591 | 1635 | // The first replaces the old one, the others are added new (simplification, otherwise it would require another query and some work...) |
1592 | 1636 | saveTriggers(array_shift($_POST['ban_suggestions']), $ban_group, 0, $ban_id); |
1593 | - if (!empty($_POST['ban_suggestions'])) |
|
1594 | - saveTriggers($_POST['ban_suggestions'], $ban_group); |
|
1637 | + if (!empty($_POST['ban_suggestions'])) { |
|
1638 | + saveTriggers($_POST['ban_suggestions'], $ban_group); |
|
1639 | + } |
|
1595 | 1640 | |
1596 | 1641 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
1597 | - } |
|
1598 | - elseif (isset($_POST['edit_trigger'])) |
|
1642 | + } elseif (isset($_POST['edit_trigger'])) |
|
1599 | 1643 | { |
1600 | 1644 | removeBanTriggers($ban_id); |
1601 | 1645 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
@@ -1626,8 +1670,7 @@ discard block |
||
1626 | 1670 | ), |
1627 | 1671 | 'is_new' => true, |
1628 | 1672 | ); |
1629 | - } |
|
1630 | - else |
|
1673 | + } else |
|
1631 | 1674 | { |
1632 | 1675 | $request = $smcFunc['db_query']('', ' |
1633 | 1676 | SELECT |
@@ -1644,8 +1687,9 @@ discard block |
||
1644 | 1687 | 'ban_group' => $ban_group, |
1645 | 1688 | ) |
1646 | 1689 | ); |
1647 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1648 | - fatal_lang_error('ban_not_found', false); |
|
1690 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1691 | + fatal_lang_error('ban_not_found', false); |
|
1692 | + } |
|
1649 | 1693 | $row = $smcFunc['db_fetch_assoc']($request); |
1650 | 1694 | $smcFunc['db_free_result']($request); |
1651 | 1695 | |
@@ -1694,8 +1738,9 @@ discard block |
||
1694 | 1738 | removeBanTriggers($_POST['remove']); |
1695 | 1739 | |
1696 | 1740 | // Rehabilitate some members. |
1697 | - if ($_REQUEST['entity'] == 'member') |
|
1698 | - updateBanMembers(); |
|
1741 | + if ($_REQUEST['entity'] == 'member') { |
|
1742 | + updateBanMembers(); |
|
1743 | + } |
|
1699 | 1744 | |
1700 | 1745 | // Make sure the ban cache is refreshed. |
1701 | 1746 | updateSettings(array('banLastUpdated' => time())); |
@@ -1808,8 +1853,7 @@ discard block |
||
1808 | 1853 | 'default' => 'bi.ip_low, bi.ip_high, bi.ip_low', |
1809 | 1854 | 'reverse' => 'bi.ip_low DESC, bi.ip_high DESC', |
1810 | 1855 | ); |
1811 | - } |
|
1812 | - elseif ($context['selected_entity'] === 'hostname') |
|
1856 | + } elseif ($context['selected_entity'] === 'hostname') |
|
1813 | 1857 | { |
1814 | 1858 | $listOptions['columns']['banned_entity']['data'] = array( |
1815 | 1859 | 'function' => function($rowData) use ($smcFunc) |
@@ -1821,8 +1865,7 @@ discard block |
||
1821 | 1865 | 'default' => 'bi.hostname', |
1822 | 1866 | 'reverse' => 'bi.hostname DESC', |
1823 | 1867 | ); |
1824 | - } |
|
1825 | - elseif ($context['selected_entity'] === 'email') |
|
1868 | + } elseif ($context['selected_entity'] === 'email') |
|
1826 | 1869 | { |
1827 | 1870 | $listOptions['columns']['banned_entity']['data'] = array( |
1828 | 1871 | 'function' => function($rowData) use ($smcFunc) |
@@ -1834,8 +1877,7 @@ discard block |
||
1834 | 1877 | 'default' => 'bi.email_address', |
1835 | 1878 | 'reverse' => 'bi.email_address DESC', |
1836 | 1879 | ); |
1837 | - } |
|
1838 | - elseif ($context['selected_entity'] === 'member') |
|
1880 | + } elseif ($context['selected_entity'] === 'member') |
|
1839 | 1881 | { |
1840 | 1882 | $listOptions['columns']['banned_entity']['data'] = array( |
1841 | 1883 | 'sprintf' => array( |
@@ -1899,8 +1941,9 @@ discard block |
||
1899 | 1941 | ) |
1900 | 1942 | ); |
1901 | 1943 | $ban_triggers = array(); |
1902 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1903 | - $ban_triggers[] = $row; |
|
1944 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1945 | + $ban_triggers[] = $row; |
|
1946 | + } |
|
1904 | 1947 | $smcFunc['db_free_result']($request); |
1905 | 1948 | |
1906 | 1949 | return $ban_triggers; |
@@ -1956,8 +1999,9 @@ discard block |
||
1956 | 1999 | validateToken('admin-bl'); |
1957 | 2000 | |
1958 | 2001 | // 'Delete all entries' button was pressed. |
1959 | - if (!empty($_POST['removeAll'])) |
|
1960 | - removeBanLogs(); |
|
2002 | + if (!empty($_POST['removeAll'])) { |
|
2003 | + removeBanLogs(); |
|
2004 | + } |
|
1961 | 2005 | // 'Delete selection' button was pressed. |
1962 | 2006 | else |
1963 | 2007 | { |
@@ -2166,12 +2210,15 @@ discard block |
||
2166 | 2210 | $low = inet_dtop($low); |
2167 | 2211 | $high = inet_dtop($high); |
2168 | 2212 | |
2169 | - if ($low == '255.255.255.255') return 'unknown'; |
|
2170 | - if ($low == $high) |
|
2171 | - return $low; |
|
2172 | - else |
|
2173 | - return $low . '-' . $high; |
|
2174 | -} |
|
2213 | + if ($low == '255.255.255.255') { |
|
2214 | + return 'unknown'; |
|
2215 | + } |
|
2216 | + if ($low == $high) { |
|
2217 | + return $low; |
|
2218 | + } else { |
|
2219 | + return $low . '-' . $high; |
|
2220 | + } |
|
2221 | + } |
|
2175 | 2222 | |
2176 | 2223 | /** |
2177 | 2224 | * Checks whether a given IP range already exists in the trigger list. |
@@ -2247,15 +2294,17 @@ discard block |
||
2247 | 2294 | $memberEmailWild = array(); |
2248 | 2295 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2249 | 2296 | { |
2250 | - if ($row['id_member']) |
|
2251 | - $memberIDs[$row['id_member']] = $row['id_member']; |
|
2297 | + if ($row['id_member']) { |
|
2298 | + $memberIDs[$row['id_member']] = $row['id_member']; |
|
2299 | + } |
|
2252 | 2300 | if ($row['email_address']) |
2253 | 2301 | { |
2254 | 2302 | // Does it have a wildcard - if so we can't do a IN on it. |
2255 | - if (strpos($row['email_address'], '%') !== false) |
|
2256 | - $memberEmailWild[$row['email_address']] = $row['email_address']; |
|
2257 | - else |
|
2258 | - $memberEmails[$row['email_address']] = $row['email_address']; |
|
2303 | + if (strpos($row['email_address'], '%') !== false) { |
|
2304 | + $memberEmailWild[$row['email_address']] = $row['email_address']; |
|
2305 | + } else { |
|
2306 | + $memberEmails[$row['email_address']] = $row['email_address']; |
|
2307 | + } |
|
2259 | 2308 | } |
2260 | 2309 | } |
2261 | 2310 | $smcFunc['db_free_result']($request); |
@@ -2306,14 +2355,15 @@ discard block |
||
2306 | 2355 | } |
2307 | 2356 | |
2308 | 2357 | // We welcome our new members in the realm of the banned. |
2309 | - if (!empty($newMembers)) |
|
2310 | - $smcFunc['db_query']('', ' |
|
2358 | + if (!empty($newMembers)) { |
|
2359 | + $smcFunc['db_query']('', ' |
|
2311 | 2360 | DELETE FROM {db_prefix}log_online |
2312 | 2361 | WHERE id_member IN ({array_int:new_banned_members})', |
2313 | 2362 | array( |
2314 | 2363 | 'new_banned_members' => $newMembers, |
2315 | 2364 | ) |
2316 | 2365 | ); |
2366 | + } |
|
2317 | 2367 | |
2318 | 2368 | // Find members that are wrongfully marked as banned. |
2319 | 2369 | $request = $smcFunc['db_query']('', ' |
@@ -2340,9 +2390,10 @@ discard block |
||
2340 | 2390 | } |
2341 | 2391 | $smcFunc['db_free_result']($request); |
2342 | 2392 | |
2343 | - if (!empty($updates)) |
|
2344 | - foreach ($updates as $newStatus => $members) |
|
2393 | + if (!empty($updates)) { |
|
2394 | + foreach ($updates as $newStatus => $members) |
|
2345 | 2395 | updateMemberData($members, array('is_activated' => $newStatus)); |
2396 | + } |
|
2346 | 2397 | |
2347 | 2398 | // Update the latest member and our total members as banning may change them. |
2348 | 2399 | updateStats('member'); |
@@ -1452,7 +1452,7 @@ |
||
1452 | 1452 | * |
1453 | 1453 | * @param int $id_subscribe The subscription ID |
1454 | 1454 | * @param int $id_member The ID of the member |
1455 | - * @param int|string $renewal 0 if we're forcing start/end time, otherwise a string indicating how long to renew the subscription for ('D', 'W', 'M' or 'Y') |
|
1455 | + * @param integer $renewal 0 if we're forcing start/end time, otherwise a string indicating how long to renew the subscription for ('D', 'W', 'M' or 'Y') |
|
1456 | 1456 | * @param int $forceStartTime If set, forces the subscription to start at the specified time |
1457 | 1457 | * @param int $forceEndTime If set, forces the subscription to end at the specified time |
1458 | 1458 | */ |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * The main entrance point for the 'Paid Subscription' screen, calling |
@@ -32,18 +33,19 @@ discard block |
||
32 | 33 | loadLanguage('ManagePaid'); |
33 | 34 | loadTemplate('ManagePaid'); |
34 | 35 | |
35 | - if (!empty($modSettings['paid_enabled'])) |
|
36 | - $subActions = array( |
|
36 | + if (!empty($modSettings['paid_enabled'])) { |
|
37 | + $subActions = array( |
|
37 | 38 | 'modify' => array('ModifySubscription', 'admin_forum'), |
38 | 39 | 'modifyuser' => array('ModifyUserSubscription', 'admin_forum'), |
39 | 40 | 'settings' => array('ModifySubscriptionSettings', 'admin_forum'), |
40 | 41 | 'view' => array('ViewSubscriptions', 'admin_forum'), |
41 | 42 | 'viewsub' => array('ViewSubscribedUsers', 'admin_forum'), |
42 | 43 | ); |
43 | - else |
|
44 | - $subActions = array( |
|
44 | + } else { |
|
45 | + $subActions = array( |
|
45 | 46 | 'settings' => array('ModifySubscriptionSettings', 'admin_forum'), |
46 | 47 | ); |
48 | + } |
|
47 | 49 | |
48 | 50 | // Default the sub-action to 'view subscriptions', but only if they have already set things up.. |
49 | 51 | $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (!empty($modSettings['paid_currency_symbol']) && !empty($modSettings['paid_enabled']) ? 'view' : 'settings'); |
@@ -59,8 +61,8 @@ discard block |
||
59 | 61 | 'help' => '', |
60 | 62 | 'description' => $txt['paid_subscriptions_desc'], |
61 | 63 | ); |
62 | - if (!empty($modSettings['paid_enabled'])) |
|
63 | - $context[$context['admin_menu_name']]['tab_data']['tabs'] = array( |
|
64 | + if (!empty($modSettings['paid_enabled'])) { |
|
65 | + $context[$context['admin_menu_name']]['tab_data']['tabs'] = array( |
|
64 | 66 | 'view' => array( |
65 | 67 | 'description' => $txt['paid_subs_view_desc'], |
66 | 68 | ), |
@@ -68,6 +70,7 @@ discard block |
||
68 | 70 | 'description' => $txt['paid_subs_settings_desc'], |
69 | 71 | ), |
70 | 72 | ); |
73 | + } |
|
71 | 74 | |
72 | 75 | call_integration_hook('integrate_manage_subscriptions', array(&$subActions)); |
73 | 76 | |
@@ -92,8 +95,9 @@ discard block |
||
92 | 95 | { |
93 | 96 | // If the currency is set to something different then we need to set it to other for this to work and set it back shortly. |
94 | 97 | $modSettings['paid_currency'] = !empty($modSettings['paid_currency_code']) ? $modSettings['paid_currency_code'] : ''; |
95 | - if (!empty($modSettings['paid_currency_code']) && !in_array($modSettings['paid_currency_code'], array('usd', 'eur', 'gbp', 'cad', 'aud'))) |
|
96 | - $modSettings['paid_currency'] = 'other'; |
|
98 | + if (!empty($modSettings['paid_currency_code']) && !in_array($modSettings['paid_currency_code'], array('usd', 'eur', 'gbp', 'cad', 'aud'))) { |
|
99 | + $modSettings['paid_currency'] = 'other'; |
|
100 | + } |
|
97 | 101 | |
98 | 102 | // These are all the default settings. |
99 | 103 | $config_vars = array( |
@@ -156,8 +160,7 @@ discard block |
||
156 | 160 | } |
157 | 161 | } |
158 | 162 | toggleOther();', true); |
159 | - } |
|
160 | - else |
|
163 | + } else |
|
161 | 164 | { |
162 | 165 | $config_vars = array( |
163 | 166 | array('check', 'paid_enabled'), |
@@ -166,8 +169,9 @@ discard block |
||
166 | 169 | } |
167 | 170 | |
168 | 171 | // Just searching? |
169 | - if ($return_config) |
|
170 | - return $config_vars; |
|
172 | + if ($return_config) { |
|
173 | + return $config_vars; |
|
174 | + } |
|
171 | 175 | |
172 | 176 | // Get the settings template fired up. |
173 | 177 | require_once($sourcedir . '/ManageServer.php'); |
@@ -211,8 +215,9 @@ discard block |
||
211 | 215 | foreach (explode(',', $_POST['paid_email_to']) as $email) |
212 | 216 | { |
213 | 217 | $email = trim($email); |
214 | - if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) |
|
215 | - $email_addresses[] = $email; |
|
218 | + if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
219 | + $email_addresses[] = $email; |
|
220 | + } |
|
216 | 221 | $_POST['paid_email_to'] = implode(',', $email_addresses); |
217 | 222 | } |
218 | 223 | } |
@@ -249,8 +254,9 @@ discard block |
||
249 | 254 | global $context, $txt, $modSettings, $sourcedir, $scripturl; |
250 | 255 | |
251 | 256 | // Not made the settings yet? |
252 | - if (empty($modSettings['paid_currency_symbol'])) |
|
253 | - fatal_lang_error('paid_not_set_currency', false, $scripturl . '?action=admin;area=paidsubscribe;sa=settings'); |
|
257 | + if (empty($modSettings['paid_currency_symbol'])) { |
|
258 | + fatal_lang_error('paid_not_set_currency', false, $scripturl . '?action=admin;area=paidsubscribe;sa=settings'); |
|
259 | + } |
|
254 | 260 | |
255 | 261 | // Some basic stuff. |
256 | 262 | $context['page_title'] = $txt['paid_subs_view']; |
@@ -270,10 +276,11 @@ discard block |
||
270 | 276 | |
271 | 277 | foreach ($context['subscriptions'] as $data) |
272 | 278 | { |
273 | - if (++$counter < $start) |
|
274 | - continue; |
|
275 | - elseif ($counter == $start + $items_per_page) |
|
276 | - break; |
|
279 | + if (++$counter < $start) { |
|
280 | + continue; |
|
281 | + } elseif ($counter == $start + $items_per_page) { |
|
282 | + break; |
|
283 | + } |
|
277 | 284 | |
278 | 285 | $subscriptions[] = $data; |
279 | 286 | } |
@@ -450,8 +457,9 @@ discard block |
||
450 | 457 | ); |
451 | 458 | $id_group = 0; |
452 | 459 | $add_groups = ''; |
453 | - if ($smcFunc['db_num_rows']($request)) |
|
454 | - list ($id_group, $add_groups) = $smcFunc['db_fetch_row']($request); |
|
460 | + if ($smcFunc['db_num_rows']($request)) { |
|
461 | + list ($id_group, $add_groups) = $smcFunc['db_fetch_row']($request); |
|
462 | + } |
|
455 | 463 | $smcFunc['db_free_result']($request); |
456 | 464 | |
457 | 465 | $changes = array(); |
@@ -463,8 +471,9 @@ discard block |
||
463 | 471 | { |
464 | 472 | // If their current primary group isn't what they had before the subscription, and their current group was |
465 | 473 | // granted by the sub, remove it. |
466 | - if ($member_data['old_id_group'] != $member_data['id_group'] && $member_data['id_group'] == $id_group) |
|
467 | - $changes[$id_member]['id_group'] = $member_data['old_id_group']; |
|
474 | + if ($member_data['old_id_group'] != $member_data['id_group'] && $member_data['id_group'] == $id_group) { |
|
475 | + $changes[$id_member]['id_group'] = $member_data['old_id_group']; |
|
476 | + } |
|
468 | 477 | } |
469 | 478 | } |
470 | 479 | |
@@ -477,15 +486,17 @@ discard block |
||
477 | 486 | // First let's get their groups sorted. |
478 | 487 | $current_groups = explode(',', $member_data['additional_groups']); |
479 | 488 | $new_groups = implode(',', array_diff($current_groups, $add_groups)); |
480 | - if ($new_groups != $member_data['additional_groups']) |
|
481 | - $changes[$id_member]['additional_groups'] = $new_groups; |
|
489 | + if ($new_groups != $member_data['additional_groups']) { |
|
490 | + $changes[$id_member]['additional_groups'] = $new_groups; |
|
491 | + } |
|
482 | 492 | } |
483 | 493 | } |
484 | 494 | |
485 | 495 | // We're going through changes... |
486 | - if (!empty($changes)) |
|
487 | - foreach ($changes as $id_member => $new_values) |
|
496 | + if (!empty($changes)) { |
|
497 | + foreach ($changes as $id_member => $new_values) |
|
488 | 498 | updateMemberData($id_member, $new_values); |
499 | + } |
|
489 | 500 | } |
490 | 501 | |
491 | 502 | // Delete the subscription |
@@ -533,11 +544,13 @@ discard block |
||
533 | 544 | 'M' => 24, |
534 | 545 | 'Y' => 5, |
535 | 546 | ); |
536 | - if (empty($_POST['span_unit']) || empty($limits[$_POST['span_unit']]) || empty($_POST['span_value']) || $_POST['span_value'] < 1) |
|
537 | - fatal_lang_error('paid_invalid_duration', false); |
|
547 | + if (empty($_POST['span_unit']) || empty($limits[$_POST['span_unit']]) || empty($_POST['span_value']) || $_POST['span_value'] < 1) { |
|
548 | + fatal_lang_error('paid_invalid_duration', false); |
|
549 | + } |
|
538 | 550 | |
539 | - if ($_POST['span_value'] > $limits[$_POST['span_unit']]) |
|
540 | - fatal_lang_error('paid_invalid_duration_' . $_POST['span_unit'], false); |
|
551 | + if ($_POST['span_value'] > $limits[$_POST['span_unit']]) { |
|
552 | + fatal_lang_error('paid_invalid_duration_' . $_POST['span_unit'], false); |
|
553 | + } |
|
541 | 554 | |
542 | 555 | // Clean the span. |
543 | 556 | $span = $_POST['span_value'] . $_POST['span_unit']; |
@@ -546,8 +559,9 @@ discard block |
||
546 | 559 | $cost = array('fixed' => sprintf('%01.2f', strtr($_POST['cost'], ',', '.'))); |
547 | 560 | |
548 | 561 | // There needs to be something. |
549 | - if (empty($_POST['span_value']) || empty($_POST['cost'])) |
|
550 | - fatal_lang_error('paid_no_cost_value'); |
|
562 | + if (empty($_POST['span_value']) || empty($_POST['cost'])) { |
|
563 | + fatal_lang_error('paid_no_cost_value'); |
|
564 | + } |
|
551 | 565 | } |
552 | 566 | // Flexible is harder but more fun ;) |
553 | 567 | else |
@@ -561,8 +575,9 @@ discard block |
||
561 | 575 | 'year' => sprintf('%01.2f', strtr($_POST['cost_year'], ',', '.')), |
562 | 576 | ); |
563 | 577 | |
564 | - if (empty($_POST['cost_day']) && empty($_POST['cost_week']) && empty($_POST['cost_month']) && empty($_POST['cost_year'])) |
|
565 | - fatal_lang_error('paid_all_freq_blank'); |
|
578 | + if (empty($_POST['cost_day']) && empty($_POST['cost_week']) && empty($_POST['cost_month']) && empty($_POST['cost_year'])) { |
|
579 | + fatal_lang_error('paid_all_freq_blank'); |
|
580 | + } |
|
566 | 581 | } |
567 | 582 | $cost = json_encode($cost); |
568 | 583 | |
@@ -571,9 +586,10 @@ discard block |
||
571 | 586 | |
572 | 587 | // Yep, time to do additional groups. |
573 | 588 | $addgroups = array(); |
574 | - if (!empty($_POST['addgroup'])) |
|
575 | - foreach ($_POST['addgroup'] as $id => $dummy) |
|
589 | + if (!empty($_POST['addgroup'])) { |
|
590 | + foreach ($_POST['addgroup'] as $id => $dummy) |
|
576 | 591 | $addgroups[] = (int) $id; |
592 | + } |
|
577 | 593 | $addgroups = implode(',', $addgroups); |
578 | 594 | |
579 | 595 | // Is it new?! |
@@ -682,18 +698,18 @@ discard block |
||
682 | 698 | { |
683 | 699 | $span_value = $match[1]; |
684 | 700 | $span_unit = $match[2]; |
685 | - } |
|
686 | - else |
|
701 | + } else |
|
687 | 702 | { |
688 | 703 | $span_value = 0; |
689 | 704 | $span_unit = 'D'; |
690 | 705 | } |
691 | 706 | |
692 | 707 | // Is this a flexible one? |
693 | - if ($row['length'] == 'F') |
|
694 | - $isFlexible = true; |
|
695 | - else |
|
696 | - $isFlexible = false; |
|
708 | + if ($row['length'] == 'F') { |
|
709 | + $isFlexible = true; |
|
710 | + } else { |
|
711 | + $isFlexible = false; |
|
712 | + } |
|
697 | 713 | |
698 | 714 | $context['sub'] = array( |
699 | 715 | 'name' => $row['name'], |
@@ -742,8 +758,9 @@ discard block |
||
742 | 758 | ) |
743 | 759 | ); |
744 | 760 | $context['groups'] = array(); |
745 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
746 | - $context['groups'][$row['id_group']] = $row['group_name']; |
|
761 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
762 | + $context['groups'][$row['id_group']] = $row['group_name']; |
|
763 | + } |
|
747 | 764 | $smcFunc['db_free_result']($request); |
748 | 765 | |
749 | 766 | // This always happens. |
@@ -777,8 +794,9 @@ discard block |
||
777 | 794 | ) |
778 | 795 | ); |
779 | 796 | // Something wrong? |
780 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
781 | - fatal_lang_error('no_access', false); |
|
797 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
798 | + fatal_lang_error('no_access', false); |
|
799 | + } |
|
782 | 800 | // Do the subscription context. |
783 | 801 | $row = $smcFunc['db_fetch_assoc']($request); |
784 | 802 | $context['subscription'] = array( |
@@ -1013,8 +1031,8 @@ discard block |
||
1013 | 1031 | )) |
1014 | 1032 | ); |
1015 | 1033 | $subscribers = array(); |
1016 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1017 | - $subscribers[] = array( |
|
1034 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1035 | + $subscribers[] = array( |
|
1018 | 1036 | 'id' => $row['id_sublog'], |
1019 | 1037 | 'id_member' => $row['id_member'], |
1020 | 1038 | 'name' => $row['name'], |
@@ -1024,6 +1042,7 @@ discard block |
||
1024 | 1042 | 'status' => $row['status'], |
1025 | 1043 | 'status_text' => $row['status'] == 0 ? ($row['payments_pending'] == 0 ? $txt['paid_finished'] : $txt['paid_pending']) : $txt['paid_active'], |
1026 | 1044 | ); |
1045 | + } |
|
1027 | 1046 | $smcFunc['db_free_result']($request); |
1028 | 1047 | |
1029 | 1048 | return $subscribers; |
@@ -1058,14 +1077,16 @@ discard block |
||
1058 | 1077 | 'current_log_item' => $context['log_id'], |
1059 | 1078 | ) |
1060 | 1079 | ); |
1061 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1062 | - fatal_lang_error('no_access', false); |
|
1080 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1081 | + fatal_lang_error('no_access', false); |
|
1082 | + } |
|
1063 | 1083 | list ($context['sub_id']) = $smcFunc['db_fetch_row']($request); |
1064 | 1084 | $smcFunc['db_free_result']($request); |
1065 | 1085 | } |
1066 | 1086 | |
1067 | - if (!isset($context['subscriptions'][$context['sub_id']])) |
|
1068 | - fatal_lang_error('no_access', false); |
|
1087 | + if (!isset($context['subscriptions'][$context['sub_id']])) { |
|
1088 | + fatal_lang_error('no_access', false); |
|
1089 | + } |
|
1069 | 1090 | $context['current_subscription'] = $context['subscriptions'][$context['sub_id']]; |
1070 | 1091 | |
1071 | 1092 | // Searching? |
@@ -1098,8 +1119,9 @@ discard block |
||
1098 | 1119 | 'name' => $_POST['name'], |
1099 | 1120 | ) |
1100 | 1121 | ); |
1101 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1102 | - fatal_lang_error('error_member_not_found'); |
|
1122 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1123 | + fatal_lang_error('error_member_not_found'); |
|
1124 | + } |
|
1103 | 1125 | |
1104 | 1126 | list ($id_member, $id_group) = $smcFunc['db_fetch_row']($request); |
1105 | 1127 | $smcFunc['db_free_result']($request); |
@@ -1115,14 +1137,15 @@ discard block |
||
1115 | 1137 | 'current_member' => $id_member, |
1116 | 1138 | ) |
1117 | 1139 | ); |
1118 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1119 | - fatal_lang_error('member_already_subscribed'); |
|
1140 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1141 | + fatal_lang_error('member_already_subscribed'); |
|
1142 | + } |
|
1120 | 1143 | $smcFunc['db_free_result']($request); |
1121 | 1144 | |
1122 | 1145 | // Actually put the subscription in place. |
1123 | - if ($status == 1) |
|
1124 | - addSubscription($context['sub_id'], $id_member, 0, $starttime, $endtime); |
|
1125 | - else |
|
1146 | + if ($status == 1) { |
|
1147 | + addSubscription($context['sub_id'], $id_member, 0, $starttime, $endtime); |
|
1148 | + } else |
|
1126 | 1149 | { |
1127 | 1150 | $smcFunc['db_insert']('', |
1128 | 1151 | '{db_prefix}log_subscribed', |
@@ -1149,20 +1172,20 @@ discard block |
||
1149 | 1172 | 'current_log_item' => $context['log_id'], |
1150 | 1173 | ) |
1151 | 1174 | ); |
1152 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1153 | - fatal_lang_error('no_access', false); |
|
1175 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1176 | + fatal_lang_error('no_access', false); |
|
1177 | + } |
|
1154 | 1178 | |
1155 | 1179 | list ($id_member, $old_status) = $smcFunc['db_fetch_row']($request); |
1156 | 1180 | $smcFunc['db_free_result']($request); |
1157 | 1181 | |
1158 | 1182 | // Pick the right permission stuff depending on what the status is changing from/to. |
1159 | - if ($old_status == 1 && $status != 1) |
|
1160 | - removeSubscription($context['sub_id'], $id_member); |
|
1161 | - elseif ($status == 1 && $old_status != 1) |
|
1183 | + if ($old_status == 1 && $status != 1) { |
|
1184 | + removeSubscription($context['sub_id'], $id_member); |
|
1185 | + } elseif ($status == 1 && $old_status != 1) |
|
1162 | 1186 | { |
1163 | 1187 | addSubscription($context['sub_id'], $id_member, 0, $starttime, $endtime); |
1164 | - } |
|
1165 | - else |
|
1188 | + } else |
|
1166 | 1189 | { |
1167 | 1190 | $smcFunc['db_query']('', ' |
1168 | 1191 | UPDATE {db_prefix}log_subscribed |
@@ -1190,8 +1213,9 @@ discard block |
||
1190 | 1213 | if (!empty($_REQUEST['delsub'])) |
1191 | 1214 | { |
1192 | 1215 | $toDelete = array(); |
1193 | - foreach ($_REQUEST['delsub'] as $id => $dummy) |
|
1194 | - $toDelete[] = (int) $id; |
|
1216 | + foreach ($_REQUEST['delsub'] as $id => $dummy) { |
|
1217 | + $toDelete[] = (int) $id; |
|
1218 | + } |
|
1195 | 1219 | |
1196 | 1220 | $request = $smcFunc['db_query']('', ' |
1197 | 1221 | SELECT id_subscribe, id_member |
@@ -1201,8 +1225,9 @@ discard block |
||
1201 | 1225 | 'subscription_list' => $toDelete, |
1202 | 1226 | ) |
1203 | 1227 | ); |
1204 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1205 | - removeSubscription($row['id_subscribe'], $row['id_member'], isset($_REQUEST['delete'])); |
|
1228 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1229 | + removeSubscription($row['id_subscribe'], $row['id_member'], isset($_REQUEST['delete'])); |
|
1230 | + } |
|
1206 | 1231 | $smcFunc['db_free_result']($request); |
1207 | 1232 | } |
1208 | 1233 | redirectexit('action=admin;area=paidsubscribe;sa=viewsub;sid=' . $context['sub_id']); |
@@ -1246,9 +1271,9 @@ discard block |
||
1246 | 1271 | ); |
1247 | 1272 | list ($context['sub']['username']) = $smcFunc['db_fetch_row']($request); |
1248 | 1273 | $smcFunc['db_free_result']($request); |
1274 | + } else { |
|
1275 | + $context['sub']['username'] = ''; |
|
1249 | 1276 | } |
1250 | - else |
|
1251 | - $context['sub']['username'] = ''; |
|
1252 | 1277 | } |
1253 | 1278 | // Otherwise load the existing info. |
1254 | 1279 | else |
@@ -1265,8 +1290,9 @@ discard block |
||
1265 | 1290 | 'blank_string' => '', |
1266 | 1291 | ) |
1267 | 1292 | ); |
1268 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1269 | - fatal_lang_error('no_access', false); |
|
1293 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1294 | + fatal_lang_error('no_access', false); |
|
1295 | + } |
|
1270 | 1296 | $row = $smcFunc['db_fetch_assoc']($request); |
1271 | 1297 | $smcFunc['db_free_result']($request); |
1272 | 1298 | |
@@ -1287,13 +1313,13 @@ discard block |
||
1287 | 1313 | { |
1288 | 1314 | foreach ($costs as $duration => $cost) |
1289 | 1315 | { |
1290 | - if ($cost != 0 && $cost == $pending[1] && $duration == $pending[2]) |
|
1291 | - $context['pending_payments'][$id] = array( |
|
1316 | + if ($cost != 0 && $cost == $pending[1] && $duration == $pending[2]) { |
|
1317 | + $context['pending_payments'][$id] = array( |
|
1292 | 1318 | 'desc' => sprintf($modSettings['paid_currency_symbol'], $cost . '/' . $txt[$duration]), |
1293 | 1319 | ); |
1320 | + } |
|
1294 | 1321 | } |
1295 | - } |
|
1296 | - elseif ($costs['fixed'] == $pending[1]) |
|
1322 | + } elseif ($costs['fixed'] == $pending[1]) |
|
1297 | 1323 | { |
1298 | 1324 | $context['pending_payments'][$id] = array( |
1299 | 1325 | 'desc' => sprintf($modSettings['paid_currency_symbol'], $costs['fixed']), |
@@ -1311,8 +1337,9 @@ discard block |
||
1311 | 1337 | if ($_GET['pending'] == $id && $pending[3] == 'payback' && isset($context['pending_payments'][$id])) |
1312 | 1338 | { |
1313 | 1339 | // Flexible? |
1314 | - if (isset($_GET['accept'])) |
|
1315 | - addSubscription($context['current_subscription']['id'], $row['id_member'], $context['current_subscription']['real_length'] == 'F' ? strtoupper(substr($pending[2], 0, 1)) : 0); |
|
1340 | + if (isset($_GET['accept'])) { |
|
1341 | + addSubscription($context['current_subscription']['id'], $row['id_member'], $context['current_subscription']['real_length'] == 'F' ? strtoupper(substr($pending[2], 0, 1)) : 0); |
|
1342 | + } |
|
1316 | 1343 | unset($pending_details[$id]); |
1317 | 1344 | |
1318 | 1345 | $new_details = json_encode($pending_details); |
@@ -1374,8 +1401,9 @@ discard block |
||
1374 | 1401 | global $smcFunc; |
1375 | 1402 | |
1376 | 1403 | // Make it an array. |
1377 | - if (!is_array($users)) |
|
1378 | - $users = array($users); |
|
1404 | + if (!is_array($users)) { |
|
1405 | + $users = array($users); |
|
1406 | + } |
|
1379 | 1407 | |
1380 | 1408 | // Get all the members current groups. |
1381 | 1409 | $groups = array(); |
@@ -1413,14 +1441,16 @@ discard block |
||
1413 | 1441 | if ($row['id_group'] != 0) |
1414 | 1442 | { |
1415 | 1443 | // If this is changing - add the old one to the additional groups so it's not lost. |
1416 | - if ($row['id_group'] != $groups[$row['id_member']]['primary']) |
|
1417 | - $groups[$row['id_member']]['additional'][] = $groups[$row['id_member']]['primary']; |
|
1444 | + if ($row['id_group'] != $groups[$row['id_member']]['primary']) { |
|
1445 | + $groups[$row['id_member']]['additional'][] = $groups[$row['id_member']]['primary']; |
|
1446 | + } |
|
1418 | 1447 | $groups[$row['id_member']]['primary'] = $row['id_group']; |
1419 | 1448 | } |
1420 | 1449 | |
1421 | 1450 | // Additional groups. |
1422 | - if (!empty($row['add_groups'])) |
|
1423 | - $groups[$row['id_member']]['additional'] = array_merge($groups[$row['id_member']]['additional'], explode(',', $row['add_groups'])); |
|
1451 | + if (!empty($row['add_groups'])) { |
|
1452 | + $groups[$row['id_member']]['additional'] = array_merge($groups[$row['id_member']]['additional'], explode(',', $row['add_groups'])); |
|
1453 | + } |
|
1424 | 1454 | } |
1425 | 1455 | $smcFunc['db_free_result']($request); |
1426 | 1456 | |
@@ -1428,9 +1458,10 @@ discard block |
||
1428 | 1458 | foreach ($groups as $id => $group) |
1429 | 1459 | { |
1430 | 1460 | $group['additional'] = array_unique($group['additional']); |
1431 | - foreach ($group['additional'] as $key => $value) |
|
1432 | - if (empty($value)) |
|
1461 | + foreach ($group['additional'] as $key => $value) { |
|
1462 | + if (empty($value)) |
|
1433 | 1463 | unset($group['additional'][$key]); |
1464 | + } |
|
1434 | 1465 | $addgroups = implode(',', $group['additional']); |
1435 | 1466 | |
1436 | 1467 | $smcFunc['db_query']('', ' |
@@ -1464,8 +1495,9 @@ discard block |
||
1464 | 1495 | loadSubscriptions(); |
1465 | 1496 | |
1466 | 1497 | // Exists, yes? |
1467 | - if (!isset($context['subscriptions'][$id_subscribe])) |
|
1468 | - return; |
|
1498 | + if (!isset($context['subscriptions'][$id_subscribe])) { |
|
1499 | + return; |
|
1500 | + } |
|
1469 | 1501 | |
1470 | 1502 | $curSub = $context['subscriptions'][$id_subscribe]; |
1471 | 1503 | |
@@ -1513,16 +1545,19 @@ discard block |
||
1513 | 1545 | list ($id_sublog, $endtime, $starttime) = $smcFunc['db_fetch_row']($request); |
1514 | 1546 | |
1515 | 1547 | // If this has already expired but is active, extension means the period from now. |
1516 | - if ($endtime < time()) |
|
1517 | - $endtime = time(); |
|
1518 | - if ($starttime == 0) |
|
1519 | - $starttime = time(); |
|
1548 | + if ($endtime < time()) { |
|
1549 | + $endtime = time(); |
|
1550 | + } |
|
1551 | + if ($starttime == 0) { |
|
1552 | + $starttime = time(); |
|
1553 | + } |
|
1520 | 1554 | |
1521 | 1555 | // Work out the new expiry date. |
1522 | 1556 | $endtime += $duration; |
1523 | 1557 | |
1524 | - if ($forceEndTime != 0) |
|
1525 | - $endtime = $forceEndTime; |
|
1558 | + if ($forceEndTime != 0) { |
|
1559 | + $endtime = $forceEndTime; |
|
1560 | + } |
|
1526 | 1561 | |
1527 | 1562 | // As everything else should be good, just update! |
1528 | 1563 | $smcFunc['db_query']('', ' |
@@ -1552,8 +1587,9 @@ discard block |
||
1552 | 1587 | ); |
1553 | 1588 | |
1554 | 1589 | // Just in case the member doesn't exist. |
1555 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1556 | - return; |
|
1590 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1591 | + return; |
|
1592 | + } |
|
1557 | 1593 | |
1558 | 1594 | list ($old_id_group, $additional_groups) = $smcFunc['db_fetch_row']($request); |
1559 | 1595 | $smcFunc['db_free_result']($request); |
@@ -1570,16 +1606,18 @@ discard block |
||
1570 | 1606 | $id_group = $curSub['prim_group']; |
1571 | 1607 | |
1572 | 1608 | // Ensure their old privileges are maintained. |
1573 | - if ($old_id_group != 0) |
|
1574 | - $newAddGroups[] = $old_id_group; |
|
1609 | + if ($old_id_group != 0) { |
|
1610 | + $newAddGroups[] = $old_id_group; |
|
1611 | + } |
|
1612 | + } else { |
|
1613 | + $id_group = $old_id_group; |
|
1575 | 1614 | } |
1576 | - else |
|
1577 | - $id_group = $old_id_group; |
|
1578 | 1615 | |
1579 | 1616 | // Yep, make sure it's unique, and no empties. |
1580 | - foreach ($newAddGroups as $k => $v) |
|
1581 | - if (empty($v)) |
|
1617 | + foreach ($newAddGroups as $k => $v) { |
|
1618 | + if (empty($v)) |
|
1582 | 1619 | unset($newAddGroups[$k]); |
1620 | + } |
|
1583 | 1621 | $newAddGroups = array_unique($newAddGroups); |
1584 | 1622 | $newAddGroups = implode(',', $newAddGroups); |
1585 | 1623 | |
@@ -1615,16 +1653,19 @@ discard block |
||
1615 | 1653 | list ($id_sublog, $endtime, $starttime) = $smcFunc['db_fetch_row']($request); |
1616 | 1654 | |
1617 | 1655 | // If this has already expired but is active, extension means the period from now. |
1618 | - if ($endtime < time()) |
|
1619 | - $endtime = time(); |
|
1620 | - if ($starttime == 0) |
|
1621 | - $starttime = time(); |
|
1656 | + if ($endtime < time()) { |
|
1657 | + $endtime = time(); |
|
1658 | + } |
|
1659 | + if ($starttime == 0) { |
|
1660 | + $starttime = time(); |
|
1661 | + } |
|
1622 | 1662 | |
1623 | 1663 | // Work out the new expiry date. |
1624 | 1664 | $endtime += $duration; |
1625 | 1665 | |
1626 | - if ($forceEndTime != 0) |
|
1627 | - $endtime = $forceEndTime; |
|
1666 | + if ($forceEndTime != 0) { |
|
1667 | + $endtime = $forceEndTime; |
|
1668 | + } |
|
1628 | 1669 | |
1629 | 1670 | // As everything else should be good, just update! |
1630 | 1671 | $smcFunc['db_query']('', ' |
@@ -1647,13 +1688,15 @@ discard block |
||
1647 | 1688 | |
1648 | 1689 | // Otherwise a very simple insert. |
1649 | 1690 | $endtime = time() + $duration; |
1650 | - if ($forceEndTime != 0) |
|
1651 | - $endtime = $forceEndTime; |
|
1691 | + if ($forceEndTime != 0) { |
|
1692 | + $endtime = $forceEndTime; |
|
1693 | + } |
|
1652 | 1694 | |
1653 | - if ($forceStartTime == 0) |
|
1654 | - $starttime = time(); |
|
1655 | - else |
|
1656 | - $starttime = $forceStartTime; |
|
1695 | + if ($forceStartTime == 0) { |
|
1696 | + $starttime = time(); |
|
1697 | + } else { |
|
1698 | + $starttime = $forceStartTime; |
|
1699 | + } |
|
1657 | 1700 | |
1658 | 1701 | $smcFunc['db_insert']('', |
1659 | 1702 | '{db_prefix}log_subscribed', |
@@ -1726,15 +1769,17 @@ discard block |
||
1726 | 1769 | $new_id_group = -1; |
1727 | 1770 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1728 | 1771 | { |
1729 | - if (!isset($context['subscriptions'][$row['id_subscribe']])) |
|
1730 | - continue; |
|
1772 | + if (!isset($context['subscriptions'][$row['id_subscribe']])) { |
|
1773 | + continue; |
|
1774 | + } |
|
1731 | 1775 | |
1732 | 1776 | // The one we're removing? |
1733 | 1777 | if ($row['id_subscribe'] == $id_subscribe) |
1734 | 1778 | { |
1735 | 1779 | $removals = explode(',', $context['subscriptions'][$row['id_subscribe']]['add_groups']); |
1736 | - if ($context['subscriptions'][$row['id_subscribe']]['prim_group'] != 0) |
|
1737 | - $removals[] = $context['subscriptions'][$row['id_subscribe']]['prim_group']; |
|
1780 | + if ($context['subscriptions'][$row['id_subscribe']]['prim_group'] != 0) { |
|
1781 | + $removals[] = $context['subscriptions'][$row['id_subscribe']]['prim_group']; |
|
1782 | + } |
|
1738 | 1783 | $old_id_group = $row['old_id_group']; |
1739 | 1784 | } |
1740 | 1785 | // Otherwise things we allow. |
@@ -1752,30 +1797,33 @@ discard block |
||
1752 | 1797 | |
1753 | 1798 | // Now, for everything we are removing check they definitely are not allowed it. |
1754 | 1799 | $existingGroups = explode(',', $additional_groups); |
1755 | - foreach ($existingGroups as $key => $group) |
|
1756 | - if (empty($group) || (in_array($group, $removals) && !in_array($group, $allowed))) |
|
1800 | + foreach ($existingGroups as $key => $group) { |
|
1801 | + if (empty($group) || (in_array($group, $removals) && !in_array($group, $allowed))) |
|
1757 | 1802 | unset($existingGroups[$key]); |
1803 | + } |
|
1758 | 1804 | |
1759 | 1805 | // Finally, do something with the current primary group. |
1760 | 1806 | if (in_array($id_group, $removals)) |
1761 | 1807 | { |
1762 | 1808 | // If this primary group is actually allowed keep it. |
1763 | - if (in_array($id_group, $allowed)) |
|
1764 | - $existingGroups[] = $id_group; |
|
1809 | + if (in_array($id_group, $allowed)) { |
|
1810 | + $existingGroups[] = $id_group; |
|
1811 | + } |
|
1765 | 1812 | |
1766 | 1813 | // Either way, change the id_group back. |
1767 | 1814 | if ($new_id_group < 1) |
1768 | 1815 | { |
1769 | 1816 | // If we revert to the old id-group we need to ensure it wasn't from a subscription. |
1770 | - foreach ($context['subscriptions'] as $id => $group) |
|
1771 | - // It was? Make them a regular member then! |
|
1817 | + foreach ($context['subscriptions'] as $id => $group) { |
|
1818 | + // It was? Make them a regular member then! |
|
1772 | 1819 | if ($group['prim_group'] == $old_id_group) |
1773 | 1820 | $old_id_group = 0; |
1821 | + } |
|
1774 | 1822 | |
1775 | 1823 | $id_group = $old_id_group; |
1824 | + } else { |
|
1825 | + $id_group = $new_id_group; |
|
1776 | 1826 | } |
1777 | - else |
|
1778 | - $id_group = $new_id_group; |
|
1779 | 1827 | } |
1780 | 1828 | |
1781 | 1829 | // Crazy stuff, we seem to have our groups fixed, just make them unique |
@@ -1795,8 +1843,8 @@ discard block |
||
1795 | 1843 | ); |
1796 | 1844 | |
1797 | 1845 | // Disable the subscription. |
1798 | - if (!$delete) |
|
1799 | - $smcFunc['db_query']('', ' |
|
1846 | + if (!$delete) { |
|
1847 | + $smcFunc['db_query']('', ' |
|
1800 | 1848 | UPDATE {db_prefix}log_subscribed |
1801 | 1849 | SET status = {int:not_active} |
1802 | 1850 | WHERE id_member = {int:current_member} |
@@ -1807,9 +1855,10 @@ discard block |
||
1807 | 1855 | 'current_subscription' => $id_subscribe, |
1808 | 1856 | ) |
1809 | 1857 | ); |
1858 | + } |
|
1810 | 1859 | // Otherwise delete it! |
1811 | - else |
|
1812 | - $smcFunc['db_query']('', ' |
|
1860 | + else { |
|
1861 | + $smcFunc['db_query']('', ' |
|
1813 | 1862 | DELETE FROM {db_prefix}log_subscribed |
1814 | 1863 | WHERE id_member = {int:current_member} |
1815 | 1864 | AND id_subscribe = {int:current_subscription}', |
@@ -1818,7 +1867,8 @@ discard block |
||
1818 | 1867 | 'current_subscription' => $id_subscribe, |
1819 | 1868 | ) |
1820 | 1869 | ); |
1821 | -} |
|
1870 | + } |
|
1871 | + } |
|
1822 | 1872 | |
1823 | 1873 | /** |
1824 | 1874 | * This just kind of caches all the subscription data. |
@@ -1827,8 +1877,9 @@ discard block |
||
1827 | 1877 | { |
1828 | 1878 | global $context, $txt, $modSettings, $smcFunc; |
1829 | 1879 | |
1830 | - if (!empty($context['subscriptions'])) |
|
1831 | - return; |
|
1880 | + if (!empty($context['subscriptions'])) { |
|
1881 | + return; |
|
1882 | + } |
|
1832 | 1883 | |
1833 | 1884 | // Make sure this is loaded, just in case. |
1834 | 1885 | loadLanguage('ManagePaid'); |
@@ -1845,10 +1896,11 @@ discard block |
||
1845 | 1896 | // Pick a cost. |
1846 | 1897 | $costs = smf_json_decode($row['cost'], true); |
1847 | 1898 | |
1848 | - if ($row['length'] != 'F' && !empty($modSettings['paid_currency_symbol']) && !empty($costs['fixed'])) |
|
1849 | - $cost = sprintf($modSettings['paid_currency_symbol'], $costs['fixed']); |
|
1850 | - else |
|
1851 | - $cost = '???'; |
|
1899 | + if ($row['length'] != 'F' && !empty($modSettings['paid_currency_symbol']) && !empty($costs['fixed'])) { |
|
1900 | + $cost = sprintf($modSettings['paid_currency_symbol'], $costs['fixed']); |
|
1901 | + } else { |
|
1902 | + $cost = '???'; |
|
1903 | + } |
|
1852 | 1904 | |
1853 | 1905 | // Do the span. |
1854 | 1906 | preg_match('~(\d*)(\w)~', $row['length'], $match); |
@@ -1875,9 +1927,9 @@ discard block |
||
1875 | 1927 | $num_length *= 31556926; |
1876 | 1928 | break; |
1877 | 1929 | } |
1930 | + } else { |
|
1931 | + $length = '??'; |
|
1878 | 1932 | } |
1879 | - else |
|
1880 | - $length = '??'; |
|
1881 | 1933 | |
1882 | 1934 | $context['subscriptions'][$row['id_subscribe']] = array( |
1883 | 1935 | 'id' => $row['id_subscribe'], |
@@ -1912,8 +1964,9 @@ discard block |
||
1912 | 1964 | { |
1913 | 1965 | $ind = $row['status'] == 0 ? 'finished' : 'total'; |
1914 | 1966 | |
1915 | - if (isset($context['subscriptions'][$row['id_subscribe']])) |
|
1916 | - $context['subscriptions'][$row['id_subscribe']][$ind] = $row['member_count']; |
|
1967 | + if (isset($context['subscriptions'][$row['id_subscribe']])) { |
|
1968 | + $context['subscriptions'][$row['id_subscribe']][$ind] = $row['member_count']; |
|
1969 | + } |
|
1917 | 1970 | } |
1918 | 1971 | $smcFunc['db_free_result']($request); |
1919 | 1972 | |
@@ -1927,8 +1980,9 @@ discard block |
||
1927 | 1980 | ); |
1928 | 1981 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1929 | 1982 | { |
1930 | - if (isset($context['subscriptions'][$row['id_subscribe']])) |
|
1931 | - $context['subscriptions'][$row['id_subscribe']]['pending'] = $row['total_pending']; |
|
1983 | + if (isset($context['subscriptions'][$row['id_subscribe']])) { |
|
1984 | + $context['subscriptions'][$row['id_subscribe']]['pending'] = $row['total_pending']; |
|
1985 | + } |
|
1932 | 1986 | } |
1933 | 1987 | $smcFunc['db_free_result']($request); |
1934 | 1988 | } |
@@ -4070,7 +4070,7 @@ |
||
4070 | 4070 | * |
4071 | 4071 | * @param int $pmID The ID of the PM |
4072 | 4072 | * @param string $validFor Which folders this is valud for - can be 'inbox', 'outbox' or 'in_or_outbox' |
4073 | - * @return boolean Whether the PM is accessible in that folder for the current user |
|
4073 | + * @return boolean|null Whether the PM is accessible in that folder for the current user |
|
4074 | 4074 | */ |
4075 | 4075 | function isAccessiblePM($pmID, $validFor = 'in_or_outbox') |
4076 | 4076 | { |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 3 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * This helps organize things... |
@@ -37,13 +38,14 @@ discard block |
||
37 | 38 | |
38 | 39 | loadLanguage('PersonalMessage+Drafts'); |
39 | 40 | |
40 | - if (!isset($_REQUEST['xml'])) |
|
41 | - loadTemplate('PersonalMessage'); |
|
41 | + if (!isset($_REQUEST['xml'])) { |
|
42 | + loadTemplate('PersonalMessage'); |
|
43 | + } |
|
42 | 44 | |
43 | 45 | // Load up the members maximum message capacity. |
44 | - if ($user_info['is_admin']) |
|
45 | - $context['message_limit'] = 0; |
|
46 | - elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null) |
|
46 | + if ($user_info['is_admin']) { |
|
47 | + $context['message_limit'] = 0; |
|
48 | + } elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null) |
|
47 | 49 | { |
48 | 50 | // @todo Why do we do this? It seems like if they have any limit we should use it. |
49 | 51 | $request = $smcFunc['db_query']('', ' |
@@ -78,8 +80,9 @@ discard block |
||
78 | 80 | } |
79 | 81 | |
80 | 82 | // a previous message was sent successfully? show a small indication. |
81 | - if (isset($_GET['done']) && ($_GET['done'] == 'sent')) |
|
82 | - $context['pm_sent'] = true; |
|
83 | + if (isset($_GET['done']) && ($_GET['done'] == 'sent')) { |
|
84 | + $context['pm_sent'] = true; |
|
85 | + } |
|
83 | 86 | |
84 | 87 | $context['labels'] = array(); |
85 | 88 | |
@@ -210,11 +213,11 @@ discard block |
||
210 | 213 | { |
211 | 214 | $_REQUEST['sa'] = ''; |
212 | 215 | MessageFolder(); |
213 | - } |
|
214 | - else |
|
216 | + } else |
|
215 | 217 | { |
216 | - if (!isset($_REQUEST['xml']) && $_REQUEST['sa'] != 'popup') |
|
217 | - messageIndexBar($_REQUEST['sa']); |
|
218 | + if (!isset($_REQUEST['xml']) && $_REQUEST['sa'] != 'popup') { |
|
219 | + messageIndexBar($_REQUEST['sa']); |
|
220 | + } |
|
218 | 221 | |
219 | 222 | call_helper($subActions[$_REQUEST['sa']]); |
220 | 223 | } |
@@ -291,16 +294,17 @@ discard block |
||
291 | 294 | ); |
292 | 295 | |
293 | 296 | // Handle labels. |
294 | - if (empty($context['currently_using_labels'])) |
|
295 | - unset($pm_areas['labels']); |
|
296 | - else |
|
297 | + if (empty($context['currently_using_labels'])) { |
|
298 | + unset($pm_areas['labels']); |
|
299 | + } else |
|
297 | 300 | { |
298 | 301 | // Note we send labels by id as it will have less problems in the querystring. |
299 | 302 | $unread_in_labels = 0; |
300 | 303 | foreach ($context['labels'] as $label) |
301 | 304 | { |
302 | - if ($label['id'] == -1) |
|
303 | - continue; |
|
305 | + if ($label['id'] == -1) { |
|
306 | + continue; |
|
307 | + } |
|
304 | 308 | |
305 | 309 | // Count the amount of unread items in labels. |
306 | 310 | $unread_in_labels += $label['unread_messages']; |
@@ -314,8 +318,9 @@ discard block |
||
314 | 318 | ); |
315 | 319 | } |
316 | 320 | |
317 | - if (!empty($unread_in_labels)) |
|
318 | - $pm_areas['labels']['title'] .= ' <span class="amt">' . $unread_in_labels . '</span>'; |
|
321 | + if (!empty($unread_in_labels)) { |
|
322 | + $pm_areas['labels']['title'] .= ' <span class="amt">' . $unread_in_labels . '</span>'; |
|
323 | + } |
|
319 | 324 | } |
320 | 325 | |
321 | 326 | $pm_areas['folders']['areas']['inbox']['unread_messages'] = &$context['labels'][-1]['unread_messages']; |
@@ -356,8 +361,9 @@ discard block |
||
356 | 361 | unset($pm_areas); |
357 | 362 | |
358 | 363 | // No menu means no access. |
359 | - if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) |
|
360 | - fatal_lang_error('no_access', false); |
|
364 | + if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) { |
|
365 | + fatal_lang_error('no_access', false); |
|
366 | + } |
|
361 | 367 | |
362 | 368 | // Make a note of the Unique ID for this menu. |
363 | 369 | $context['pm_menu_id'] = $context['max_menu_id']; |
@@ -368,9 +374,10 @@ discard block |
||
368 | 374 | $context['menu_item_selected'] = $current_area; |
369 | 375 | |
370 | 376 | // Set the template for this area and add the profile layer. |
371 | - if (!isset($_REQUEST['xml'])) |
|
372 | - $context['template_layers'][] = 'pm'; |
|
373 | -} |
|
377 | + if (!isset($_REQUEST['xml'])) { |
|
378 | + $context['template_layers'][] = 'pm'; |
|
379 | + } |
|
380 | + } |
|
374 | 381 | |
375 | 382 | /** |
376 | 383 | * The popup for when we ask for the popup from the user. |
@@ -402,8 +409,9 @@ discard block |
||
402 | 409 | ) |
403 | 410 | ); |
404 | 411 | $pms = array(); |
405 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
406 | - $pms[] = $row[0]; |
|
412 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
413 | + $pms[] = $row[0]; |
|
414 | + } |
|
407 | 415 | $smcFunc['db_free_result']($request); |
408 | 416 | |
409 | 417 | if (!empty($pms)) |
@@ -431,8 +439,9 @@ discard block |
||
431 | 439 | ); |
432 | 440 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
433 | 441 | { |
434 | - if (!empty($row['id_member_from'])) |
|
435 | - $senders[] = $row['id_member_from']; |
|
442 | + if (!empty($row['id_member_from'])) { |
|
443 | + $senders[] = $row['id_member_from']; |
|
444 | + } |
|
436 | 445 | |
437 | 446 | $row['replied_to_you'] = $row['id_pm'] != $row['id_pm_head']; |
438 | 447 | $row['time'] = timeformat($row['timestamp']); |
@@ -442,13 +451,15 @@ discard block |
||
442 | 451 | $smcFunc['db_free_result']($request); |
443 | 452 | |
444 | 453 | $senders = loadMemberData($senders); |
445 | - foreach ($senders as $member) |
|
446 | - loadMemberContext($member); |
|
454 | + foreach ($senders as $member) { |
|
455 | + loadMemberContext($member); |
|
456 | + } |
|
447 | 457 | |
448 | 458 | // Having loaded everyone, attach them to the PMs. |
449 | - foreach ($context['unread_pms'] as $id_pm => $details) |
|
450 | - if (!empty($memberContext[$details['id_member_from']])) |
|
459 | + foreach ($context['unread_pms'] as $id_pm => $details) { |
|
460 | + if (!empty($memberContext[$details['id_member_from']])) |
|
451 | 461 | $context['unread_pms'][$id_pm]['member'] = &$memberContext[$details['id_member_from']]; |
462 | + } |
|
452 | 463 | } |
453 | 464 | } |
454 | 465 | |
@@ -468,12 +479,13 @@ discard block |
||
468 | 479 | } |
469 | 480 | |
470 | 481 | // Make sure the starting location is valid. |
471 | - if (isset($_GET['start']) && $_GET['start'] != 'new') |
|
472 | - $_GET['start'] = (int) $_GET['start']; |
|
473 | - elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) |
|
474 | - $_GET['start'] = 0; |
|
475 | - else |
|
476 | - $_GET['start'] = 'new'; |
|
482 | + if (isset($_GET['start']) && $_GET['start'] != 'new') { |
|
483 | + $_GET['start'] = (int) $_GET['start']; |
|
484 | + } elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) { |
|
485 | + $_GET['start'] = 0; |
|
486 | + } else { |
|
487 | + $_GET['start'] = 'new'; |
|
488 | + } |
|
477 | 489 | |
478 | 490 | // Set up some basic theme stuff. |
479 | 491 | $context['from_or_to'] = $context['folder'] != 'sent' ? 'from' : 'to'; |
@@ -490,8 +502,7 @@ discard block |
||
490 | 502 | { |
491 | 503 | $labelQuery = ' |
492 | 504 | AND pmr.in_inbox = 1'; |
493 | - } |
|
494 | - elseif ($context['folder'] != 'sent') |
|
505 | + } elseif ($context['folder'] != 'sent') |
|
495 | 506 | { |
496 | 507 | $labelJoin = ' |
497 | 508 | INNER JOIN {db_prefix}pm_labeled_messages AS pl ON (pl.id_pm = pmr.id_pm)'; |
@@ -533,22 +544,24 @@ discard block |
||
533 | 544 | $txt['delete_all'] = str_replace('PMBOX', $pmbox, $txt['delete_all']); |
534 | 545 | |
535 | 546 | // Now, build the link tree! |
536 | - if ($context['current_label_id'] == -1) |
|
537 | - $context['linktree'][] = array( |
|
547 | + if ($context['current_label_id'] == -1) { |
|
548 | + $context['linktree'][] = array( |
|
538 | 549 | 'url' => $scripturl . '?action=pm;f=' . $context['folder'], |
539 | 550 | 'name' => $pmbox |
540 | 551 | ); |
552 | + } |
|
541 | 553 | |
542 | 554 | // Build it further for a label. |
543 | - if ($context['current_label_id'] != -1) |
|
544 | - $context['linktree'][] = array( |
|
555 | + if ($context['current_label_id'] != -1) { |
|
556 | + $context['linktree'][] = array( |
|
545 | 557 | 'url' => $scripturl . '?action=pm;f=' . $context['folder'] . ';l=' . $context['current_label_id'], |
546 | 558 | 'name' => $txt['pm_current_label'] . ': ' . $context['current_label'] |
547 | 559 | ); |
560 | + } |
|
548 | 561 | |
549 | 562 | // Figure out how many messages there are. |
550 | - if ($context['folder'] == 'sent') |
|
551 | - $request = $smcFunc['db_query']('', ' |
|
563 | + if ($context['folder'] == 'sent') { |
|
564 | + $request = $smcFunc['db_query']('', ' |
|
552 | 565 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
553 | 566 | FROM {db_prefix}personal_messages AS pm |
554 | 567 | WHERE pm.id_member_from = {int:current_member} |
@@ -558,8 +571,8 @@ discard block |
||
558 | 571 | 'not_deleted' => 0, |
559 | 572 | ) |
560 | 573 | ); |
561 | - else |
|
562 | - $request = $smcFunc['db_query']('', ' |
|
574 | + } else { |
|
575 | + $request = $smcFunc['db_query']('', ' |
|
563 | 576 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
564 | 577 | FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? ' |
565 | 578 | INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . ' |
@@ -570,6 +583,7 @@ discard block |
||
570 | 583 | 'not_deleted' => 0, |
571 | 584 | ) |
572 | 585 | ); |
586 | + } |
|
573 | 587 | list ($max_messages) = $smcFunc['db_fetch_row']($request); |
574 | 588 | $smcFunc['db_free_result']($request); |
575 | 589 | |
@@ -578,10 +592,11 @@ discard block |
||
578 | 592 | $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
579 | 593 | |
580 | 594 | // Start on the last page. |
581 | - if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) |
|
582 | - $_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage); |
|
583 | - elseif ($_GET['start'] < 0) |
|
584 | - $_GET['start'] = 0; |
|
595 | + if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) { |
|
596 | + $_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage); |
|
597 | + } elseif ($_GET['start'] < 0) { |
|
598 | + $_GET['start'] = 0; |
|
599 | + } |
|
585 | 600 | |
586 | 601 | // ... but wait - what if we want to start from a specific message? |
587 | 602 | if (isset($_GET['pmid'])) |
@@ -589,19 +604,21 @@ discard block |
||
589 | 604 | $pmID = (int) $_GET['pmid']; |
590 | 605 | |
591 | 606 | // Make sure you have access to this PM. |
592 | - if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) |
|
593 | - fatal_lang_error('no_access', false); |
|
607 | + if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) { |
|
608 | + fatal_lang_error('no_access', false); |
|
609 | + } |
|
594 | 610 | |
595 | 611 | $context['current_pm'] = $pmID; |
596 | 612 | |
597 | 613 | // With only one page of PM's we're gonna want page 1. |
598 | - if ($max_messages <= $maxPerPage) |
|
599 | - $_GET['start'] = 0; |
|
614 | + if ($max_messages <= $maxPerPage) { |
|
615 | + $_GET['start'] = 0; |
|
616 | + } |
|
600 | 617 | // If we pass kstart we assume we're in the right place. |
601 | 618 | elseif (!isset($_GET['kstart'])) |
602 | 619 | { |
603 | - if ($context['folder'] == 'sent') |
|
604 | - $request = $smcFunc['db_query']('', ' |
|
620 | + if ($context['folder'] == 'sent') { |
|
621 | + $request = $smcFunc['db_query']('', ' |
|
605 | 622 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
606 | 623 | FROM {db_prefix}personal_messages |
607 | 624 | WHERE id_member_from = {int:current_member} |
@@ -613,8 +630,8 @@ discard block |
||
613 | 630 | 'id_pm' => $pmID, |
614 | 631 | ) |
615 | 632 | ); |
616 | - else |
|
617 | - $request = $smcFunc['db_query']('', ' |
|
633 | + } else { |
|
634 | + $request = $smcFunc['db_query']('', ' |
|
618 | 635 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
619 | 636 | FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? ' |
620 | 637 | INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . ' |
@@ -627,6 +644,7 @@ discard block |
||
627 | 644 | 'id_pm' => $pmID, |
628 | 645 | ) |
629 | 646 | ); |
647 | + } |
|
630 | 648 | |
631 | 649 | list ($_GET['start']) = $smcFunc['db_fetch_row']($request); |
632 | 650 | $smcFunc['db_free_result']($request); |
@@ -641,8 +659,9 @@ discard block |
||
641 | 659 | { |
642 | 660 | $pmsg = (int) $_GET['pmsg']; |
643 | 661 | |
644 | - if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) |
|
645 | - fatal_lang_error('no_access', false); |
|
662 | + if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) { |
|
663 | + fatal_lang_error('no_access', false); |
|
664 | + } |
|
646 | 665 | } |
647 | 666 | |
648 | 667 | // Set up the page index. |
@@ -737,8 +756,9 @@ discard block |
||
737 | 756 | { |
738 | 757 | if (!isset($recipients[$row['id_pm']])) |
739 | 758 | { |
740 | - if (isset($row['id_member_from'])) |
|
741 | - $posters[$row['id_pm']] = $row['id_member_from']; |
|
759 | + if (isset($row['id_member_from'])) { |
|
760 | + $posters[$row['id_pm']] = $row['id_member_from']; |
|
761 | + } |
|
742 | 762 | $pms[$row['id_pm']] = $row['id_pm']; |
743 | 763 | $recipients[$row['id_pm']] = array( |
744 | 764 | 'to' => array(), |
@@ -747,29 +767,33 @@ discard block |
||
747 | 767 | } |
748 | 768 | |
749 | 769 | // Keep track of the last message so we know what the head is without another query! |
750 | - if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) |
|
751 | - $lastData = array( |
|
770 | + if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) { |
|
771 | + $lastData = array( |
|
752 | 772 | 'id' => $row['id_pm'], |
753 | 773 | 'head' => $row['id_pm_head'], |
754 | 774 | ); |
775 | + } |
|
755 | 776 | } |
756 | 777 | $smcFunc['db_free_result']($request); |
757 | 778 | |
758 | 779 | // Make sure that we have been given a correct head pm id! |
759 | - if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) |
|
760 | - fatal_lang_error('no_access', false); |
|
780 | + if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) { |
|
781 | + fatal_lang_error('no_access', false); |
|
782 | + } |
|
761 | 783 | |
762 | 784 | if (!empty($pms)) |
763 | 785 | { |
764 | 786 | // Select the correct current message. |
765 | - if (empty($pmID)) |
|
766 | - $context['current_pm'] = $lastData['id']; |
|
787 | + if (empty($pmID)) { |
|
788 | + $context['current_pm'] = $lastData['id']; |
|
789 | + } |
|
767 | 790 | |
768 | 791 | // This is a list of the pm's that are used for "full" display. |
769 | - if ($context['display_mode'] == 0) |
|
770 | - $display_pms = $pms; |
|
771 | - else |
|
772 | - $display_pms = array($context['current_pm']); |
|
792 | + if ($context['display_mode'] == 0) { |
|
793 | + $display_pms = $pms; |
|
794 | + } else { |
|
795 | + $display_pms = array($context['current_pm']); |
|
796 | + } |
|
773 | 797 | |
774 | 798 | // At this point we know the main id_pm's. But - if we are looking at conversations we need the others! |
775 | 799 | if ($context['display_mode'] == 2) |
@@ -791,16 +815,18 @@ discard block |
||
791 | 815 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
792 | 816 | { |
793 | 817 | // This is, frankly, a joke. We will put in a workaround for people sending to themselves - yawn! |
794 | - if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) |
|
795 | - continue; |
|
796 | - elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) |
|
797 | - continue; |
|
818 | + if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) { |
|
819 | + continue; |
|
820 | + } elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) { |
|
821 | + continue; |
|
822 | + } |
|
798 | 823 | |
799 | - if (!isset($recipients[$row['id_pm']])) |
|
800 | - $recipients[$row['id_pm']] = array( |
|
824 | + if (!isset($recipients[$row['id_pm']])) { |
|
825 | + $recipients[$row['id_pm']] = array( |
|
801 | 826 | 'to' => array(), |
802 | 827 | 'bcc' => array() |
803 | 828 | ); |
829 | + } |
|
804 | 830 | $display_pms[] = $row['id_pm']; |
805 | 831 | $posters[$row['id_pm']] = $row['id_member_from']; |
806 | 832 | } |
@@ -851,8 +877,9 @@ discard block |
||
851 | 877 | while($row2 = $smcFunc['db_fetch_assoc']($request2)) |
852 | 878 | { |
853 | 879 | $l_id = $row2['id_label']; |
854 | - if (isset($context['labels'][$l_id])) |
|
855 | - $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
880 | + if (isset($context['labels'][$l_id])) { |
|
881 | + $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
882 | + } |
|
856 | 883 | } |
857 | 884 | |
858 | 885 | $smcFunc['db_free_result']($request2); |
@@ -869,9 +896,10 @@ discard block |
||
869 | 896 | // Make sure we don't load unnecessary data. |
870 | 897 | if ($context['display_mode'] == 1) |
871 | 898 | { |
872 | - foreach ($posters as $k => $v) |
|
873 | - if (!in_array($k, $display_pms)) |
|
899 | + foreach ($posters as $k => $v) { |
|
900 | + if (!in_array($k, $display_pms)) |
|
874 | 901 | unset($posters[$k]); |
902 | + } |
|
875 | 903 | } |
876 | 904 | |
877 | 905 | // Load any users.... |
@@ -882,8 +910,9 @@ discard block |
||
882 | 910 | { |
883 | 911 | // Get the order right. |
884 | 912 | $orderBy = array(); |
885 | - foreach (array_reverse($pms) as $pm) |
|
886 | - $orderBy[] = 'pm.id_pm = ' . $pm; |
|
913 | + foreach (array_reverse($pms) as $pm) { |
|
914 | + $orderBy[] = 'pm.id_pm = ' . $pm; |
|
915 | + } |
|
887 | 916 | |
888 | 917 | // Seperate query for these bits! |
889 | 918 | $subjects_request = $smcFunc['db_query']('', ' |
@@ -929,9 +958,9 @@ discard block |
||
929 | 958 | // Allow mods to add additional buttons here |
930 | 959 | call_integration_hook('integrate_conversation_buttons'); |
931 | 960 | } |
961 | + } else { |
|
962 | + $messages_request = false; |
|
932 | 963 | } |
933 | - else |
|
934 | - $messages_request = false; |
|
935 | 964 | |
936 | 965 | $context['can_send_pm'] = allowedTo('pm_send'); |
937 | 966 | $context['can_send_email'] = allowedTo('moderate_forum'); |
@@ -942,11 +971,13 @@ discard block |
||
942 | 971 | if ($context['folder'] != 'sent' && !empty($context['labels'][(int) $context['current_label_id']]['unread_messages'])) |
943 | 972 | { |
944 | 973 | // If the display mode is "old sk00l" do them all... |
945 | - if ($context['display_mode'] == 0) |
|
946 | - markMessages(null, $context['current_label_id']); |
|
974 | + if ($context['display_mode'] == 0) { |
|
975 | + markMessages(null, $context['current_label_id']); |
|
976 | + } |
|
947 | 977 | // Otherwise do just the current one! |
948 | - elseif (!empty($context['current_pm'])) |
|
949 | - markMessages($display_pms, $context['current_label_id']); |
|
978 | + elseif (!empty($context['current_pm'])) { |
|
979 | + markMessages($display_pms, $context['current_label_id']); |
|
980 | + } |
|
950 | 981 | } |
951 | 982 | } |
952 | 983 | |
@@ -964,8 +995,9 @@ discard block |
||
964 | 995 | |
965 | 996 | // Count the current message number.... |
966 | 997 | static $counter = null; |
967 | - if ($counter === null || $reset) |
|
968 | - $counter = $context['start']; |
|
998 | + if ($counter === null || $reset) { |
|
999 | + $counter = $context['start']; |
|
1000 | + } |
|
969 | 1001 | |
970 | 1002 | static $temp_pm_selected = null; |
971 | 1003 | if ($temp_pm_selected === null) |
@@ -1010,19 +1042,22 @@ discard block |
||
1010 | 1042 | } |
1011 | 1043 | |
1012 | 1044 | // Bail if it's false, ie. no messages. |
1013 | - if ($messages_request == false) |
|
1014 | - return false; |
|
1045 | + if ($messages_request == false) { |
|
1046 | + return false; |
|
1047 | + } |
|
1015 | 1048 | |
1016 | 1049 | // Reset the data? |
1017 | - if ($reset == true) |
|
1018 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1050 | + if ($reset == true) { |
|
1051 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1052 | + } |
|
1019 | 1053 | |
1020 | 1054 | // Get the next one... bail if anything goes wrong. |
1021 | 1055 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
1022 | 1056 | if (!$message) |
1023 | 1057 | { |
1024 | - if ($type != 'subject') |
|
1025 | - $smcFunc['db_free_result']($messages_request); |
|
1058 | + if ($type != 'subject') { |
|
1059 | + $smcFunc['db_free_result']($messages_request); |
|
1060 | + } |
|
1026 | 1061 | |
1027 | 1062 | return false; |
1028 | 1063 | } |
@@ -1042,8 +1077,7 @@ discard block |
||
1042 | 1077 | $memberContext[$message['id_member_from']]['email'] = ''; |
1043 | 1078 | $memberContext[$message['id_member_from']]['show_email'] = false; |
1044 | 1079 | $memberContext[$message['id_member_from']]['is_guest'] = true; |
1045 | - } |
|
1046 | - else |
|
1080 | + } else |
|
1047 | 1081 | { |
1048 | 1082 | $memberContext[$message['id_member_from']]['can_view_profile'] = allowedTo('profile_view') || ($message['id_member_from'] == $user_info['id'] && !$user_info['is_guest']); |
1049 | 1083 | $memberContext[$message['id_member_from']]['can_see_warning'] = !isset($context['disabled_fields']['warning_status']) && $memberContext[$message['id_member_from']]['warning_status'] && ($context['user']['can_mod'] || (!empty($modSettings['warning_show']) && ($modSettings['warning_show'] > 1 || $message['id_member_from'] == $user_info['id']))); |
@@ -1084,12 +1118,13 @@ discard block |
||
1084 | 1118 | $counter++; |
1085 | 1119 | |
1086 | 1120 | // Any custom profile fields? |
1087 | - if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) |
|
1088 | - foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom) |
|
1121 | + if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) { |
|
1122 | + foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom) |
|
1089 | 1123 | switch ($custom['placement']) |
1090 | 1124 | { |
1091 | 1125 | case 1: |
1092 | 1126 | $output['custom_fields']['icons'][] = $custom; |
1127 | + } |
|
1093 | 1128 | break; |
1094 | 1129 | case 2: |
1095 | 1130 | $output['custom_fields']['above_signature'][] = $custom; |
@@ -1132,22 +1167,28 @@ discard block |
||
1132 | 1167 | $context['search_params'][$k] = $v; |
1133 | 1168 | } |
1134 | 1169 | } |
1135 | - if (isset($_REQUEST['search'])) |
|
1136 | - $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
1170 | + if (isset($_REQUEST['search'])) { |
|
1171 | + $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
1172 | + } |
|
1137 | 1173 | |
1138 | - if (isset($context['search_params']['search'])) |
|
1139 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
1140 | - if (isset($context['search_params']['userspec'])) |
|
1141 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
1174 | + if (isset($context['search_params']['search'])) { |
|
1175 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
1176 | + } |
|
1177 | + if (isset($context['search_params']['userspec'])) { |
|
1178 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
1179 | + } |
|
1142 | 1180 | |
1143 | - if (!empty($context['search_params']['searchtype'])) |
|
1144 | - $context['search_params']['searchtype'] = 2; |
|
1181 | + if (!empty($context['search_params']['searchtype'])) { |
|
1182 | + $context['search_params']['searchtype'] = 2; |
|
1183 | + } |
|
1145 | 1184 | |
1146 | - if (!empty($context['search_params']['minage'])) |
|
1147 | - $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
1185 | + if (!empty($context['search_params']['minage'])) { |
|
1186 | + $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
1187 | + } |
|
1148 | 1188 | |
1149 | - if (!empty($context['search_params']['maxage'])) |
|
1150 | - $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
1189 | + if (!empty($context['search_params']['maxage'])) { |
|
1190 | + $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
1191 | + } |
|
1151 | 1192 | |
1152 | 1193 | $context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']); |
1153 | 1194 | $context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']); |
@@ -1174,8 +1215,9 @@ discard block |
||
1174 | 1215 | $context['search_errors']['messages'] = array(); |
1175 | 1216 | foreach ($context['search_errors'] as $search_error => $dummy) |
1176 | 1217 | { |
1177 | - if ($search_error == 'messages') |
|
1178 | - continue; |
|
1218 | + if ($search_error == 'messages') { |
|
1219 | + continue; |
|
1220 | + } |
|
1179 | 1221 | |
1180 | 1222 | $context['search_errors']['messages'][] = $txt['error_' . $search_error]; |
1181 | 1223 | } |
@@ -1197,8 +1239,9 @@ discard block |
||
1197 | 1239 | global $scripturl, $modSettings, $user_info, $context, $txt; |
1198 | 1240 | global $memberContext, $smcFunc; |
1199 | 1241 | |
1200 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
1201 | - fatal_lang_error('loadavg_search_disabled', false); |
|
1242 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
1243 | + fatal_lang_error('loadavg_search_disabled', false); |
|
1244 | + } |
|
1202 | 1245 | |
1203 | 1246 | /** |
1204 | 1247 | * @todo For the moment force the folder to the inbox. |
@@ -1227,35 +1270,40 @@ discard block |
||
1227 | 1270 | $context['start'] = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
1228 | 1271 | |
1229 | 1272 | // Store whether simple search was used (needed if the user wants to do another query). |
1230 | - if (!isset($search_params['advanced'])) |
|
1231 | - $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
1273 | + if (!isset($search_params['advanced'])) { |
|
1274 | + $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
1275 | + } |
|
1232 | 1276 | |
1233 | 1277 | // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'. |
1234 | - if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) |
|
1235 | - $search_params['searchtype'] = 2; |
|
1278 | + if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) { |
|
1279 | + $search_params['searchtype'] = 2; |
|
1280 | + } |
|
1236 | 1281 | |
1237 | 1282 | // Minimum age of messages. Default to zero (don't set param in that case). |
1238 | - if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) |
|
1239 | - $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
1283 | + if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) { |
|
1284 | + $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
1285 | + } |
|
1240 | 1286 | |
1241 | 1287 | // Maximum age of messages. Default to infinite (9999 days: param not set). |
1242 | - if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) |
|
1243 | - $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
1288 | + if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) { |
|
1289 | + $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
1290 | + } |
|
1244 | 1291 | |
1245 | 1292 | $search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']); |
1246 | 1293 | $search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']); |
1247 | 1294 | |
1248 | 1295 | // Default the user name to a wildcard matching every user (*). |
1249 | - if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) |
|
1250 | - $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
1296 | + if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) { |
|
1297 | + $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
1298 | + } |
|
1251 | 1299 | |
1252 | 1300 | // This will be full of all kinds of parameters! |
1253 | 1301 | $searchq_parameters = array(); |
1254 | 1302 | |
1255 | 1303 | // If there's no specific user, then don't mention it in the main query. |
1256 | - if (empty($search_params['userspec'])) |
|
1257 | - $userQuery = ''; |
|
1258 | - else |
|
1304 | + if (empty($search_params['userspec'])) { |
|
1305 | + $userQuery = ''; |
|
1306 | + } else |
|
1259 | 1307 | { |
1260 | 1308 | $userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('"' => '"')); |
1261 | 1309 | $userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')); |
@@ -1267,8 +1315,9 @@ discard block |
||
1267 | 1315 | { |
1268 | 1316 | $possible_users[$k] = trim($possible_users[$k]); |
1269 | 1317 | |
1270 | - if (strlen($possible_users[$k]) == 0) |
|
1271 | - unset($possible_users[$k]); |
|
1318 | + if (strlen($possible_users[$k]) == 0) { |
|
1319 | + unset($possible_users[$k]); |
|
1320 | + } |
|
1272 | 1321 | } |
1273 | 1322 | |
1274 | 1323 | if (!empty($possible_users)) |
@@ -1280,8 +1329,9 @@ discard block |
||
1280 | 1329 | { |
1281 | 1330 | $where_params['name_' . $k] = $v; |
1282 | 1331 | $where_clause[] = '{raw:real_name} LIKE {string:name_' . $k . '}'; |
1283 | - if (!isset($where_params['real_name'])) |
|
1284 | - $where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
|
1332 | + if (!isset($where_params['real_name'])) { |
|
1333 | + $where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
|
1334 | + } |
|
1285 | 1335 | } |
1286 | 1336 | |
1287 | 1337 | // Who matches those criteria? |
@@ -1294,28 +1344,28 @@ discard block |
||
1294 | 1344 | ); |
1295 | 1345 | |
1296 | 1346 | // Simply do nothing if there're too many members matching the criteria. |
1297 | - if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) |
|
1298 | - $userQuery = ''; |
|
1299 | - elseif ($smcFunc['db_num_rows']($request) == 0) |
|
1347 | + if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) { |
|
1348 | + $userQuery = ''; |
|
1349 | + } elseif ($smcFunc['db_num_rows']($request) == 0) |
|
1300 | 1350 | { |
1301 | 1351 | $userQuery = 'AND pm.id_member_from = 0 AND ({raw:pm_from_name} LIKE {raw:guest_user_name_implode})'; |
1302 | 1352 | $searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\''; |
1303 | 1353 | $searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name'; |
1304 | - } |
|
1305 | - else |
|
1354 | + } else |
|
1306 | 1355 | { |
1307 | 1356 | $memberlist = array(); |
1308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1309 | - $memberlist[] = $row['id_member']; |
|
1357 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1358 | + $memberlist[] = $row['id_member']; |
|
1359 | + } |
|
1310 | 1360 | $userQuery = 'AND (pm.id_member_from IN ({array_int:member_list}) OR (pm.id_member_from = 0 AND ({raw:pm_from_name} LIKE {raw:guest_user_name_implode})))'; |
1311 | 1361 | $searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\''; |
1312 | 1362 | $searchq_parameters['member_list'] = $memberlist; |
1313 | 1363 | $searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name'; |
1314 | 1364 | } |
1315 | 1365 | $smcFunc['db_free_result']($request); |
1366 | + } else { |
|
1367 | + $userQuery = ''; |
|
1316 | 1368 | } |
1317 | - else |
|
1318 | - $userQuery = ''; |
|
1319 | 1369 | } |
1320 | 1370 | |
1321 | 1371 | // Setup the sorting variables... |
@@ -1323,8 +1373,9 @@ discard block |
||
1323 | 1373 | $sort_columns = array( |
1324 | 1374 | 'pm.id_pm', |
1325 | 1375 | ); |
1326 | - if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) |
|
1327 | - list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
1376 | + if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) { |
|
1377 | + list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
1378 | + } |
|
1328 | 1379 | $search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'pm.id_pm'; |
1329 | 1380 | $search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc'; |
1330 | 1381 | |
@@ -1334,24 +1385,27 @@ discard block |
||
1334 | 1385 | if ($context['folder'] == 'inbox' && !empty($search_params['advanced']) && $context['currently_using_labels']) |
1335 | 1386 | { |
1336 | 1387 | // Came here from pagination? Put them back into $_REQUEST for sanitization. |
1337 | - if (isset($search_params['labels'])) |
|
1338 | - $_REQUEST['searchlabel'] = explode(',', $search_params['labels']); |
|
1388 | + if (isset($search_params['labels'])) { |
|
1389 | + $_REQUEST['searchlabel'] = explode(',', $search_params['labels']); |
|
1390 | + } |
|
1339 | 1391 | |
1340 | 1392 | // Assuming we have some labels - make them all integers. |
1341 | 1393 | if (!empty($_REQUEST['searchlabel']) && is_array($_REQUEST['searchlabel'])) |
1342 | 1394 | { |
1343 | - foreach ($_REQUEST['searchlabel'] as $key => $id) |
|
1344 | - $_REQUEST['searchlabel'][$key] = (int) $id; |
|
1395 | + foreach ($_REQUEST['searchlabel'] as $key => $id) { |
|
1396 | + $_REQUEST['searchlabel'][$key] = (int) $id; |
|
1397 | + } |
|
1398 | + } else { |
|
1399 | + $_REQUEST['searchlabel'] = array(); |
|
1345 | 1400 | } |
1346 | - else |
|
1347 | - $_REQUEST['searchlabel'] = array(); |
|
1348 | 1401 | |
1349 | 1402 | // Now that everything is cleaned up a bit, make the labels a param. |
1350 | 1403 | $search_params['labels'] = implode(',', $_REQUEST['searchlabel']); |
1351 | 1404 | |
1352 | 1405 | // No labels selected? That must be an error! |
1353 | - if (empty($_REQUEST['searchlabel'])) |
|
1354 | - $context['search_errors']['no_labels_selected'] = true; |
|
1406 | + if (empty($_REQUEST['searchlabel'])) { |
|
1407 | + $context['search_errors']['no_labels_selected'] = true; |
|
1408 | + } |
|
1355 | 1409 | // Otherwise prepare the query! |
1356 | 1410 | elseif (count($_REQUEST['searchlabel']) != count($context['labels'])) |
1357 | 1411 | { |
@@ -1374,8 +1428,7 @@ discard block |
||
1374 | 1428 | // Not searching the inbox - PM must be labeled |
1375 | 1429 | $labelQuery = ' AND pml.id_label IN ({array_int:labels})'; |
1376 | 1430 | $labelJoin = ' INNER JOIN {db_prefix}pm_labeled_messages AS pml ON (pml.id_pm = pmr.id_pm)'; |
1377 | - } |
|
1378 | - else |
|
1431 | + } else |
|
1379 | 1432 | { |
1380 | 1433 | // Searching the inbox - PM doesn't have to be labeled |
1381 | 1434 | $labelQuery = ' AND (' . substr($labelQuery, 5) . ' OR pml.id_label IN ({array_int:labels}))'; |
@@ -1390,8 +1443,9 @@ discard block |
||
1390 | 1443 | // What are we actually searching for? |
1391 | 1444 | $search_params['search'] = !empty($search_params['search']) ? $search_params['search'] : (isset($_REQUEST['search']) ? $_REQUEST['search'] : ''); |
1392 | 1445 | // If we ain't got nothing - we should error! |
1393 | - if (!isset($search_params['search']) || $search_params['search'] == '') |
|
1394 | - $context['search_errors']['invalid_search_string'] = true; |
|
1446 | + if (!isset($search_params['search']) || $search_params['search'] == '') { |
|
1447 | + $context['search_errors']['invalid_search_string'] = true; |
|
1448 | + } |
|
1395 | 1449 | |
1396 | 1450 | // Extract phrase parts first (e.g. some words "this is a phrase" some more words.) |
1397 | 1451 | preg_match_all('~(?:^|\s)([-]?)"([^"]+)"(?:$|\s)~' . ($context['utf8'] ? 'u' : ''), $search_params['search'], $matches, PREG_PATTERN_ORDER); |
@@ -1404,12 +1458,14 @@ discard block |
||
1404 | 1458 | $excludedWords = array(); |
1405 | 1459 | |
1406 | 1460 | // .. first, we check for things like -"some words", but not "-some words". |
1407 | - foreach ($matches[1] as $index => $word) |
|
1408 | - if ($word == '-') |
|
1461 | + foreach ($matches[1] as $index => $word) { |
|
1462 | + if ($word == '-') |
|
1409 | 1463 | { |
1410 | 1464 | $word = $smcFunc['strtolower'](trim($searchArray[$index])); |
1411 | - if (strlen($word) > 0) |
|
1412 | - $excludedWords[] = $word; |
|
1465 | + } |
|
1466 | + if (strlen($word) > 0) { |
|
1467 | + $excludedWords[] = $word; |
|
1468 | + } |
|
1413 | 1469 | unset($searchArray[$index]); |
1414 | 1470 | } |
1415 | 1471 | |
@@ -1419,8 +1475,9 @@ discard block |
||
1419 | 1475 | if (strpos(trim($word), '-') === 0) |
1420 | 1476 | { |
1421 | 1477 | $word = substr($smcFunc['strtolower']($word), 1); |
1422 | - if (strlen($word) > 0) |
|
1423 | - $excludedWords[] = $word; |
|
1478 | + if (strlen($word) > 0) { |
|
1479 | + $excludedWords[] = $word; |
|
1480 | + } |
|
1424 | 1481 | unset($tempSearch[$index]); |
1425 | 1482 | } |
1426 | 1483 | } |
@@ -1431,9 +1488,9 @@ discard block |
||
1431 | 1488 | foreach ($searchArray as $index => $value) |
1432 | 1489 | { |
1433 | 1490 | $searchArray[$index] = $smcFunc['strtolower'](trim($value)); |
1434 | - if ($searchArray[$index] == '') |
|
1435 | - unset($searchArray[$index]); |
|
1436 | - else |
|
1491 | + if ($searchArray[$index] == '') { |
|
1492 | + unset($searchArray[$index]); |
|
1493 | + } else |
|
1437 | 1494 | { |
1438 | 1495 | // Sort out entities first. |
1439 | 1496 | $searchArray[$index] = $smcFunc['htmlspecialchars']($searchArray[$index]); |
@@ -1443,27 +1500,32 @@ discard block |
||
1443 | 1500 | |
1444 | 1501 | // Create an array of replacements for highlighting. |
1445 | 1502 | $context['mark'] = array(); |
1446 | - foreach ($searchArray as $word) |
|
1447 | - $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
1503 | + foreach ($searchArray as $word) { |
|
1504 | + $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
1505 | + } |
|
1448 | 1506 | |
1449 | 1507 | // This contains *everything* |
1450 | 1508 | $searchWords = array_merge($searchArray, $excludedWords); |
1451 | 1509 | |
1452 | 1510 | // Make sure at least one word is being searched for. |
1453 | - if (empty($searchArray)) |
|
1454 | - $context['search_errors']['invalid_search_string'] = true; |
|
1511 | + if (empty($searchArray)) { |
|
1512 | + $context['search_errors']['invalid_search_string'] = true; |
|
1513 | + } |
|
1455 | 1514 | |
1456 | 1515 | // Sort out the search query so the user can edit it - if they want. |
1457 | 1516 | $context['search_params'] = $search_params; |
1458 | - if (isset($context['search_params']['search'])) |
|
1459 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
1460 | - if (isset($context['search_params']['userspec'])) |
|
1461 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
1517 | + if (isset($context['search_params']['search'])) { |
|
1518 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
1519 | + } |
|
1520 | + if (isset($context['search_params']['userspec'])) { |
|
1521 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
1522 | + } |
|
1462 | 1523 | |
1463 | 1524 | // Now we have all the parameters, combine them together for pagination and the like... |
1464 | 1525 | $context['params'] = array(); |
1465 | - foreach ($search_params as $k => $v) |
|
1466 | - $context['params'][] = $k . '|\'|' . $v; |
|
1526 | + foreach ($search_params as $k => $v) { |
|
1527 | + $context['params'][] = $k . '|\'|' . $v; |
|
1528 | + } |
|
1467 | 1529 | $context['params'] = base64_encode(implode('|"|', $context['params'])); |
1468 | 1530 | |
1469 | 1531 | // Compile the subject query part. |
@@ -1471,26 +1533,31 @@ discard block |
||
1471 | 1533 | |
1472 | 1534 | foreach ($searchWords as $index => $word) |
1473 | 1535 | { |
1474 | - if ($word == '') |
|
1475 | - continue; |
|
1536 | + if ($word == '') { |
|
1537 | + continue; |
|
1538 | + } |
|
1476 | 1539 | |
1477 | - if ($search_params['subject_only']) |
|
1478 | - $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}'; |
|
1479 | - else |
|
1480 | - $andQueryParts[] = '(pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '} ' . (in_array($word, $excludedWords) ? 'AND pm.body NOT' : 'OR pm.body') . ' LIKE {string:search_' . $index . '})'; |
|
1540 | + if ($search_params['subject_only']) { |
|
1541 | + $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}'; |
|
1542 | + } else { |
|
1543 | + $andQueryParts[] = '(pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '} ' . (in_array($word, $excludedWords) ? 'AND pm.body NOT' : 'OR pm.body') . ' LIKE {string:search_' . $index . '})'; |
|
1544 | + } |
|
1481 | 1545 | $searchq_parameters['search_' . $index] = '%' . strtr($word, array('_' => '\\_', '%' => '\\%')) . '%'; |
1482 | 1546 | } |
1483 | 1547 | |
1484 | 1548 | $searchQuery = ' 1=1'; |
1485 | - if (!empty($andQueryParts)) |
|
1486 | - $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); |
|
1549 | + if (!empty($andQueryParts)) { |
|
1550 | + $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); |
|
1551 | + } |
|
1487 | 1552 | |
1488 | 1553 | // Age limits? |
1489 | 1554 | $timeQuery = ''; |
1490 | - if (!empty($search_params['minage'])) |
|
1491 | - $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400); |
|
1492 | - if (!empty($search_params['maxage'])) |
|
1493 | - $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400); |
|
1555 | + if (!empty($search_params['minage'])) { |
|
1556 | + $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400); |
|
1557 | + } |
|
1558 | + if (!empty($search_params['maxage'])) { |
|
1559 | + $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400); |
|
1560 | + } |
|
1494 | 1561 | |
1495 | 1562 | // If we have errors - return back to the first screen... |
1496 | 1563 | if (!empty($context['search_errors'])) |
@@ -1576,8 +1643,9 @@ discard block |
||
1576 | 1643 | ) |
1577 | 1644 | ); |
1578 | 1645 | $real_pm_ids = array(); |
1579 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1580 | - $real_pm_ids[$row['id_pm_head']] = $row['id_pm']; |
|
1646 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1647 | + $real_pm_ids[$row['id_pm_head']] = $row['id_pm']; |
|
1648 | + } |
|
1581 | 1649 | $smcFunc['db_free_result']($request); |
1582 | 1650 | } |
1583 | 1651 | |
@@ -1607,8 +1675,9 @@ discard block |
||
1607 | 1675 | ); |
1608 | 1676 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1609 | 1677 | { |
1610 | - if ($context['folder'] == 'sent' || empty($row['bcc'])) |
|
1611 | - $recipients[$row['id_pm']][empty($row['bcc']) ? 'to' : 'bcc'][] = empty($row['id_member_to']) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . '">' . $row['to_name'] . '</a>'; |
|
1678 | + if ($context['folder'] == 'sent' || empty($row['bcc'])) { |
|
1679 | + $recipients[$row['id_pm']][empty($row['bcc']) ? 'to' : 'bcc'][] = empty($row['id_member_to']) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . '">' . $row['to_name'] . '</a>'; |
|
1680 | + } |
|
1612 | 1681 | |
1613 | 1682 | if ($row['id_member_to'] == $user_info['id'] && $context['folder'] != 'sent') |
1614 | 1683 | { |
@@ -1629,12 +1698,14 @@ discard block |
||
1629 | 1698 | while($row2 = $smcFunc['db_fetch_assoc']($request2)) |
1630 | 1699 | { |
1631 | 1700 | $l_id = $row2['id_label']; |
1632 | - if (isset($context['labels'][$l_id])) |
|
1633 | - $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
1701 | + if (isset($context['labels'][$l_id])) { |
|
1702 | + $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
1703 | + } |
|
1634 | 1704 | |
1635 | 1705 | // Here we find the first label on a message - for linking to posts in results |
1636 | - if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) |
|
1637 | - $context['first_label'][$row['id_pm']] = $l_id; |
|
1706 | + if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) { |
|
1707 | + $context['first_label'][$row['id_pm']] = $l_id; |
|
1708 | + } |
|
1638 | 1709 | } |
1639 | 1710 | |
1640 | 1711 | $smcFunc['db_free_result']($request2); |
@@ -1761,8 +1832,9 @@ discard block |
||
1761 | 1832 | list ($postCount) = $smcFunc['db_fetch_row']($request); |
1762 | 1833 | $smcFunc['db_free_result']($request); |
1763 | 1834 | |
1764 | - if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) |
|
1765 | - fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
1835 | + if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) { |
|
1836 | + fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
1837 | + } |
|
1766 | 1838 | } |
1767 | 1839 | |
1768 | 1840 | // Quoting/Replying to a message? |
@@ -1771,8 +1843,9 @@ discard block |
||
1771 | 1843 | $pmsg = (int) $_REQUEST['pmsg']; |
1772 | 1844 | |
1773 | 1845 | // Make sure this is yours. |
1774 | - if (!isAccessiblePM($pmsg)) |
|
1775 | - fatal_lang_error('no_access', false); |
|
1846 | + if (!isAccessiblePM($pmsg)) { |
|
1847 | + fatal_lang_error('no_access', false); |
|
1848 | + } |
|
1776 | 1849 | |
1777 | 1850 | // Work out whether this is one you've received? |
1778 | 1851 | $request = $smcFunc['db_query']('', ' |
@@ -1809,8 +1882,9 @@ discard block |
||
1809 | 1882 | 'id_pm' => $pmsg, |
1810 | 1883 | ) |
1811 | 1884 | ); |
1812 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1813 | - fatal_lang_error('pm_not_yours', false); |
|
1885 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1886 | + fatal_lang_error('pm_not_yours', false); |
|
1887 | + } |
|
1814 | 1888 | $row_quoted = $smcFunc['db_fetch_assoc']($request); |
1815 | 1889 | $smcFunc['db_free_result']($request); |
1816 | 1890 | |
@@ -1821,9 +1895,9 @@ discard block |
||
1821 | 1895 | // Add 'Re: ' to it.... |
1822 | 1896 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
1823 | 1897 | { |
1824 | - if ($language === $user_info['language']) |
|
1825 | - $context['response_prefix'] = $txt['response_prefix']; |
|
1826 | - else |
|
1898 | + if ($language === $user_info['language']) { |
|
1899 | + $context['response_prefix'] = $txt['response_prefix']; |
|
1900 | + } else |
|
1827 | 1901 | { |
1828 | 1902 | loadLanguage('index', $language, false); |
1829 | 1903 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -1832,22 +1906,25 @@ discard block |
||
1832 | 1906 | cache_put_data('response_prefix', $context['response_prefix'], 600); |
1833 | 1907 | } |
1834 | 1908 | $form_subject = $row_quoted['subject']; |
1835 | - if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
1836 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
1909 | + if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
1910 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
1911 | + } |
|
1837 | 1912 | |
1838 | 1913 | if (isset($_REQUEST['quote'])) |
1839 | 1914 | { |
1840 | 1915 | // Remove any nested quotes and <br>... |
1841 | 1916 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $row_quoted['body']); |
1842 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
1843 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
1844 | - if (empty($row_quoted['id_member'])) |
|
1845 | - $form_message = '[quote author="' . $row_quoted['real_name'] . '"]' . "\n" . $form_message . "\n" . '[/quote]'; |
|
1846 | - else |
|
1847 | - $form_message = '[quote author=' . $row_quoted['real_name'] . ' link=action=profile;u=' . $row_quoted['id_member'] . ' date=' . $row_quoted['msgtime'] . ']' . "\n" . $form_message . "\n" . '[/quote]'; |
|
1917 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
1918 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
1919 | + } |
|
1920 | + if (empty($row_quoted['id_member'])) { |
|
1921 | + $form_message = '[quote author="' . $row_quoted['real_name'] . '"]' . "\n" . $form_message . "\n" . '[/quote]'; |
|
1922 | + } else { |
|
1923 | + $form_message = '[quote author=' . $row_quoted['real_name'] . ' link=action=profile;u=' . $row_quoted['id_member'] . ' date=' . $row_quoted['msgtime'] . ']' . "\n" . $form_message . "\n" . '[/quote]'; |
|
1924 | + } |
|
1925 | + } else { |
|
1926 | + $form_message = ''; |
|
1848 | 1927 | } |
1849 | - else |
|
1850 | - $form_message = ''; |
|
1851 | 1928 | |
1852 | 1929 | // Do the BBC thang on the message. |
1853 | 1930 | $row_quoted['body'] = parse_bbc($row_quoted['body'], true, 'pm' . $row_quoted['id_pm']); |
@@ -1868,8 +1945,7 @@ discard block |
||
1868 | 1945 | 'timestamp' => forum_time(true, $row_quoted['msgtime']), |
1869 | 1946 | 'body' => $row_quoted['body'] |
1870 | 1947 | ); |
1871 | - } |
|
1872 | - else |
|
1948 | + } else |
|
1873 | 1949 | { |
1874 | 1950 | $context['quoted_message'] = false; |
1875 | 1951 | $form_subject = ''; |
@@ -1888,11 +1964,12 @@ discard block |
||
1888 | 1964 | if ($_REQUEST['u'] == 'all' && isset($row_quoted)) |
1889 | 1965 | { |
1890 | 1966 | // Firstly, to reply to all we clearly already have $row_quoted - so have the original member from. |
1891 | - if ($row_quoted['id_member'] != $user_info['id']) |
|
1892 | - $context['recipients']['to'][] = array( |
|
1967 | + if ($row_quoted['id_member'] != $user_info['id']) { |
|
1968 | + $context['recipients']['to'][] = array( |
|
1893 | 1969 | 'id' => $row_quoted['id_member'], |
1894 | 1970 | 'name' => $smcFunc['htmlspecialchars']($row_quoted['real_name']), |
1895 | 1971 | ); |
1972 | + } |
|
1896 | 1973 | |
1897 | 1974 | // Now to get the others. |
1898 | 1975 | $request = $smcFunc['db_query']('', ' |
@@ -1908,18 +1985,19 @@ discard block |
||
1908 | 1985 | 'not_bcc' => 0, |
1909 | 1986 | ) |
1910 | 1987 | ); |
1911 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1912 | - $context['recipients']['to'][] = array( |
|
1988 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1989 | + $context['recipients']['to'][] = array( |
|
1913 | 1990 | 'id' => $row['id_member'], |
1914 | 1991 | 'name' => $row['real_name'], |
1915 | 1992 | ); |
1993 | + } |
|
1916 | 1994 | $smcFunc['db_free_result']($request); |
1917 | - } |
|
1918 | - else |
|
1995 | + } else |
|
1919 | 1996 | { |
1920 | 1997 | $_REQUEST['u'] = explode(',', $_REQUEST['u']); |
1921 | - foreach ($_REQUEST['u'] as $key => $uID) |
|
1922 | - $_REQUEST['u'][$key] = (int) $uID; |
|
1998 | + foreach ($_REQUEST['u'] as $key => $uID) { |
|
1999 | + $_REQUEST['u'][$key] = (int) $uID; |
|
2000 | + } |
|
1923 | 2001 | |
1924 | 2002 | $_REQUEST['u'] = array_unique($_REQUEST['u']); |
1925 | 2003 | |
@@ -1933,22 +2011,24 @@ discard block |
||
1933 | 2011 | 'limit' => count($_REQUEST['u']), |
1934 | 2012 | ) |
1935 | 2013 | ); |
1936 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1937 | - $context['recipients']['to'][] = array( |
|
2014 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2015 | + $context['recipients']['to'][] = array( |
|
1938 | 2016 | 'id' => $row['id_member'], |
1939 | 2017 | 'name' => $row['real_name'], |
1940 | 2018 | ); |
2019 | + } |
|
1941 | 2020 | $smcFunc['db_free_result']($request); |
1942 | 2021 | } |
1943 | 2022 | |
1944 | 2023 | // Get a literal name list in case the user has JavaScript disabled. |
1945 | 2024 | $names = array(); |
1946 | - foreach ($context['recipients']['to'] as $to) |
|
1947 | - $names[] = $to['name']; |
|
2025 | + foreach ($context['recipients']['to'] as $to) { |
|
2026 | + $names[] = $to['name']; |
|
2027 | + } |
|
1948 | 2028 | $context['to_value'] = empty($names) ? '' : '"' . implode('", "', $names) . '"'; |
2029 | + } else { |
|
2030 | + $context['to_value'] = ''; |
|
1949 | 2031 | } |
1950 | - else |
|
1951 | - $context['to_value'] = ''; |
|
1952 | 2032 | |
1953 | 2033 | // Set the defaults... |
1954 | 2034 | $context['subject'] = $form_subject; |
@@ -2018,8 +2098,9 @@ discard block |
||
2018 | 2098 | |
2019 | 2099 | // validate with loadMemberData() |
2020 | 2100 | $memberResult = loadMemberData($user_info['id'], false); |
2021 | - if (!$memberResult) |
|
2022 | - fatal_lang_error('not_a_user', false); |
|
2101 | + if (!$memberResult) { |
|
2102 | + fatal_lang_error('not_a_user', false); |
|
2103 | + } |
|
2023 | 2104 | list ($memID) = $memberResult; |
2024 | 2105 | |
2025 | 2106 | // drafts is where the functions reside |
@@ -2045,9 +2126,9 @@ discard block |
||
2045 | 2126 | $context['sub_template'] = 'send'; |
2046 | 2127 | loadJavaScriptFile('PersonalMessage.js', array('defer' => false), 'smf_pms'); |
2047 | 2128 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
2129 | + } else { |
|
2130 | + $context['sub_template'] = 'pm'; |
|
2048 | 2131 | } |
2049 | - else |
|
2050 | - $context['sub_template'] = 'pm'; |
|
2051 | 2132 | |
2052 | 2133 | $context['page_title'] = $txt['send_message']; |
2053 | 2134 | |
@@ -2108,10 +2189,11 @@ discard block |
||
2108 | 2189 | ); |
2109 | 2190 | if ($smcFunc['db_num_rows']($request) == 0) |
2110 | 2191 | { |
2111 | - if (!isset($_REQUEST['xml'])) |
|
2112 | - fatal_lang_error('pm_not_yours', false); |
|
2113 | - else |
|
2114 | - $error_types[] = 'pm_not_yours'; |
|
2192 | + if (!isset($_REQUEST['xml'])) { |
|
2193 | + fatal_lang_error('pm_not_yours', false); |
|
2194 | + } else { |
|
2195 | + $error_types[] = 'pm_not_yours'; |
|
2196 | + } |
|
2115 | 2197 | } |
2116 | 2198 | $row_quoted = $smcFunc['db_fetch_assoc']($request); |
2117 | 2199 | $smcFunc['db_free_result']($request); |
@@ -2158,14 +2240,16 @@ discard block |
||
2158 | 2240 | $context['post_error'][$error_type] = true; |
2159 | 2241 | if (isset($txt['error_' . $error_type])) |
2160 | 2242 | { |
2161 | - if ($error_type == 'long_message') |
|
2162 | - $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); |
|
2243 | + if ($error_type == 'long_message') { |
|
2244 | + $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); |
|
2245 | + } |
|
2163 | 2246 | $context['post_error']['messages'][] = $txt['error_' . $error_type]; |
2164 | 2247 | } |
2165 | 2248 | |
2166 | 2249 | // If it's not a minor error flag it as such. |
2167 | - if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) |
|
2168 | - $context['error_type'] = 'serious'; |
|
2250 | + if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) { |
|
2251 | + $context['error_type'] = 'serious'; |
|
2252 | + } |
|
2169 | 2253 | } |
2170 | 2254 | |
2171 | 2255 | // We need to load the editor once more. |
@@ -2223,8 +2307,9 @@ discard block |
||
2223 | 2307 | require_once($sourcedir . '/Subs-Auth.php'); |
2224 | 2308 | |
2225 | 2309 | // PM Drafts enabled and needed? |
2226 | - if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) |
|
2227 | - require_once($sourcedir . '/Drafts.php'); |
|
2310 | + if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) { |
|
2311 | + require_once($sourcedir . '/Drafts.php'); |
|
2312 | + } |
|
2228 | 2313 | |
2229 | 2314 | loadLanguage('PersonalMessage', '', false); |
2230 | 2315 | |
@@ -2254,24 +2339,27 @@ discard block |
||
2254 | 2339 | |
2255 | 2340 | if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) |
2256 | 2341 | { |
2257 | - if (!isset($_REQUEST['xml'])) |
|
2258 | - fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
2259 | - else |
|
2260 | - $post_errors[] = 'pm_too_many_per_hour'; |
|
2342 | + if (!isset($_REQUEST['xml'])) { |
|
2343 | + fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
2344 | + } else { |
|
2345 | + $post_errors[] = 'pm_too_many_per_hour'; |
|
2346 | + } |
|
2261 | 2347 | } |
2262 | 2348 | } |
2263 | 2349 | |
2264 | 2350 | // If your session timed out, show an error, but do allow to re-submit. |
2265 | - if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') |
|
2266 | - $post_errors[] = 'session_timeout'; |
|
2351 | + if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') { |
|
2352 | + $post_errors[] = 'session_timeout'; |
|
2353 | + } |
|
2267 | 2354 | |
2268 | 2355 | $_REQUEST['subject'] = isset($_REQUEST['subject']) ? trim($_REQUEST['subject']) : ''; |
2269 | 2356 | $_REQUEST['to'] = empty($_POST['to']) ? (empty($_GET['to']) ? '' : $_GET['to']) : $_POST['to']; |
2270 | 2357 | $_REQUEST['bcc'] = empty($_POST['bcc']) ? (empty($_GET['bcc']) ? '' : $_GET['bcc']) : $_POST['bcc']; |
2271 | 2358 | |
2272 | 2359 | // Route the input from the 'u' parameter to the 'to'-list. |
2273 | - if (!empty($_POST['u'])) |
|
2274 | - $_POST['recipient_to'] = explode(',', $_POST['u']); |
|
2360 | + if (!empty($_POST['u'])) { |
|
2361 | + $_POST['recipient_to'] = explode(',', $_POST['u']); |
|
2362 | + } |
|
2275 | 2363 | |
2276 | 2364 | // Construct the list of recipients. |
2277 | 2365 | $recipientList = array(); |
@@ -2283,8 +2371,9 @@ discard block |
||
2283 | 2371 | $recipientList[$recipientType] = array(); |
2284 | 2372 | if (!empty($_POST['recipient_' . $recipientType]) && is_array($_POST['recipient_' . $recipientType])) |
2285 | 2373 | { |
2286 | - foreach ($_POST['recipient_' . $recipientType] as $recipient) |
|
2287 | - $recipientList[$recipientType][] = (int) $recipient; |
|
2374 | + foreach ($_POST['recipient_' . $recipientType] as $recipient) { |
|
2375 | + $recipientList[$recipientType][] = (int) $recipient; |
|
2376 | + } |
|
2288 | 2377 | } |
2289 | 2378 | |
2290 | 2379 | // Are there also literal names set? |
@@ -2298,10 +2387,11 @@ discard block |
||
2298 | 2387 | |
2299 | 2388 | foreach ($namedRecipientList[$recipientType] as $index => $recipient) |
2300 | 2389 | { |
2301 | - if (strlen(trim($recipient)) > 0) |
|
2302 | - $namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient))); |
|
2303 | - else |
|
2304 | - unset($namedRecipientList[$recipientType][$index]); |
|
2390 | + if (strlen(trim($recipient)) > 0) { |
|
2391 | + $namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient))); |
|
2392 | + } else { |
|
2393 | + unset($namedRecipientList[$recipientType][$index]); |
|
2394 | + } |
|
2305 | 2395 | } |
2306 | 2396 | |
2307 | 2397 | if (!empty($namedRecipientList[$recipientType])) |
@@ -2331,8 +2421,9 @@ discard block |
||
2331 | 2421 | } |
2332 | 2422 | |
2333 | 2423 | // Selected a recipient to be deleted? Remove them now. |
2334 | - if (!empty($_POST['delete_recipient'])) |
|
2335 | - $recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient'])); |
|
2424 | + if (!empty($_POST['delete_recipient'])) { |
|
2425 | + $recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient'])); |
|
2426 | + } |
|
2336 | 2427 | |
2337 | 2428 | // Make sure we don't include the same name twice |
2338 | 2429 | $recipientList[$recipientType] = array_unique($recipientList[$recipientType]); |
@@ -2342,8 +2433,9 @@ discard block |
||
2342 | 2433 | $is_recipient_change = !empty($_POST['delete_recipient']) || !empty($_POST['to_submit']) || !empty($_POST['bcc_submit']); |
2343 | 2434 | |
2344 | 2435 | // Check if there's at least one recipient. |
2345 | - if (empty($recipientList['to']) && empty($recipientList['bcc'])) |
|
2346 | - $post_errors[] = 'no_to'; |
|
2436 | + if (empty($recipientList['to']) && empty($recipientList['bcc'])) { |
|
2437 | + $post_errors[] = 'no_to'; |
|
2438 | + } |
|
2347 | 2439 | |
2348 | 2440 | // Make sure that we remove the members who did get it from the screen. |
2349 | 2441 | if (!$is_recipient_change) |
@@ -2357,28 +2449,31 @@ discard block |
||
2357 | 2449 | // Since we already have a post error, remove the previous one. |
2358 | 2450 | $post_errors = array_diff($post_errors, array('no_to')); |
2359 | 2451 | |
2360 | - foreach ($namesNotFound[$recipientType] as $name) |
|
2361 | - $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
2452 | + foreach ($namesNotFound[$recipientType] as $name) { |
|
2453 | + $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
2454 | + } |
|
2362 | 2455 | } |
2363 | 2456 | } |
2364 | 2457 | } |
2365 | 2458 | |
2366 | 2459 | // Did they make any mistakes? |
2367 | - if ($_REQUEST['subject'] == '') |
|
2368 | - $post_errors[] = 'no_subject'; |
|
2369 | - if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') |
|
2370 | - $post_errors[] = 'no_message'; |
|
2371 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) |
|
2372 | - $post_errors[] = 'long_message'; |
|
2373 | - else |
|
2460 | + if ($_REQUEST['subject'] == '') { |
|
2461 | + $post_errors[] = 'no_subject'; |
|
2462 | + } |
|
2463 | + if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') { |
|
2464 | + $post_errors[] = 'no_message'; |
|
2465 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) { |
|
2466 | + $post_errors[] = 'long_message'; |
|
2467 | + } else |
|
2374 | 2468 | { |
2375 | 2469 | // Preparse the message. |
2376 | 2470 | $message = $_REQUEST['message']; |
2377 | 2471 | preparsecode($message); |
2378 | 2472 | |
2379 | 2473 | // Make sure there's still some content left without the tags. |
2380 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) |
|
2381 | - $post_errors[] = 'no_message'; |
|
2474 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) { |
|
2475 | + $post_errors[] = 'no_message'; |
|
2476 | + } |
|
2382 | 2477 | } |
2383 | 2478 | |
2384 | 2479 | // Wrong verification code? |
@@ -2390,13 +2485,15 @@ discard block |
||
2390 | 2485 | ); |
2391 | 2486 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
2392 | 2487 | |
2393 | - if (is_array($context['require_verification'])) |
|
2394 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
2488 | + if (is_array($context['require_verification'])) { |
|
2489 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
2490 | + } |
|
2395 | 2491 | } |
2396 | 2492 | |
2397 | 2493 | // If they did, give a chance to make ammends. |
2398 | - if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) |
|
2399 | - return messagePostError($post_errors, $namedRecipientList, $recipientList); |
|
2494 | + if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) { |
|
2495 | + return messagePostError($post_errors, $namedRecipientList, $recipientList); |
|
2496 | + } |
|
2400 | 2497 | |
2401 | 2498 | // Want to take a second glance before you send? |
2402 | 2499 | if (isset($_REQUEST['preview'])) |
@@ -2427,8 +2524,9 @@ discard block |
||
2427 | 2524 | foreach ($namesNotFound as $recipientType => $names) |
2428 | 2525 | { |
2429 | 2526 | $post_errors[] = 'bad_' . $recipientType; |
2430 | - foreach ($names as $name) |
|
2431 | - $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
2527 | + foreach ($names as $name) { |
|
2528 | + $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
2529 | + } |
|
2432 | 2530 | } |
2433 | 2531 | |
2434 | 2532 | return messagePostError(array(), $namedRecipientList, $recipientList); |
@@ -2458,13 +2556,14 @@ discard block |
||
2458 | 2556 | checkSubmitOnce('check'); |
2459 | 2557 | |
2460 | 2558 | // Do the actual sending of the PM. |
2461 | - if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) |
|
2462 | - $context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0); |
|
2463 | - else |
|
2464 | - $context['send_log'] = array( |
|
2559 | + if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) { |
|
2560 | + $context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0); |
|
2561 | + } else { |
|
2562 | + $context['send_log'] = array( |
|
2465 | 2563 | 'sent' => array(), |
2466 | 2564 | 'failed' => array() |
2467 | 2565 | ); |
2566 | + } |
|
2468 | 2567 | |
2469 | 2568 | // Mark the message as "replied to". |
2470 | 2569 | if (!empty($context['send_log']['sent']) && !empty($_REQUEST['replied_to']) && isset($_REQUEST['f']) && $_REQUEST['f'] == 'inbox') |
@@ -2482,11 +2581,12 @@ discard block |
||
2482 | 2581 | } |
2483 | 2582 | |
2484 | 2583 | // If one or more of the recipient were invalid, go back to the post screen with the failed usernames. |
2485 | - if (!empty($context['send_log']['failed'])) |
|
2486 | - return messagePostError($post_errors, $namesNotFound, array( |
|
2584 | + if (!empty($context['send_log']['failed'])) { |
|
2585 | + return messagePostError($post_errors, $namesNotFound, array( |
|
2487 | 2586 | 'to' => array_intersect($recipientList['to'], $context['send_log']['failed']), |
2488 | 2587 | 'bcc' => array_intersect($recipientList['bcc'], $context['send_log']['failed']) |
2489 | 2588 | )); |
2589 | + } |
|
2490 | 2590 | |
2491 | 2591 | // Message sent successfully? |
2492 | 2592 | if (!empty($context['send_log']) && empty($context['send_log']['failed'])) |
@@ -2494,8 +2594,9 @@ discard block |
||
2494 | 2594 | $context['current_label_redirect'] = $context['current_label_redirect'] . ';done=sent'; |
2495 | 2595 | |
2496 | 2596 | // If we had a PM draft for this one, then its time to remove it since it was just sent |
2497 | - if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) |
|
2498 | - DeleteDraft($_POST['id_pm_draft']); |
|
2597 | + if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) { |
|
2598 | + DeleteDraft($_POST['id_pm_draft']); |
|
2599 | + } |
|
2499 | 2600 | } |
2500 | 2601 | |
2501 | 2602 | // Go back to the where they sent from, if possible... |
@@ -2510,24 +2611,28 @@ discard block |
||
2510 | 2611 | |
2511 | 2612 | checkSession('request'); |
2512 | 2613 | |
2513 | - if (isset($_REQUEST['del_selected'])) |
|
2514 | - $_REQUEST['pm_action'] = 'delete'; |
|
2614 | + if (isset($_REQUEST['del_selected'])) { |
|
2615 | + $_REQUEST['pm_action'] = 'delete'; |
|
2616 | + } |
|
2515 | 2617 | |
2516 | 2618 | if (isset($_REQUEST['pm_action']) && $_REQUEST['pm_action'] != '' && !empty($_REQUEST['pms']) && is_array($_REQUEST['pms'])) |
2517 | 2619 | { |
2518 | - foreach ($_REQUEST['pms'] as $pm) |
|
2519 | - $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action']; |
|
2620 | + foreach ($_REQUEST['pms'] as $pm) { |
|
2621 | + $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action']; |
|
2622 | + } |
|
2520 | 2623 | } |
2521 | 2624 | |
2522 | - if (empty($_REQUEST['pm_actions'])) |
|
2523 | - redirectexit($context['current_label_redirect']); |
|
2625 | + if (empty($_REQUEST['pm_actions'])) { |
|
2626 | + redirectexit($context['current_label_redirect']); |
|
2627 | + } |
|
2524 | 2628 | |
2525 | 2629 | // If we are in conversation, we may need to apply this to every message in the conversation. |
2526 | 2630 | if ($context['display_mode'] == 2 && isset($_REQUEST['conversation'])) |
2527 | 2631 | { |
2528 | 2632 | $id_pms = array(); |
2529 | - foreach ($_REQUEST['pm_actions'] as $pm => $dummy) |
|
2530 | - $id_pms[] = (int) $pm; |
|
2633 | + foreach ($_REQUEST['pm_actions'] as $pm => $dummy) { |
|
2634 | + $id_pms[] = (int) $pm; |
|
2635 | + } |
|
2531 | 2636 | |
2532 | 2637 | $request = $smcFunc['db_query']('', ' |
2533 | 2638 | SELECT id_pm_head, id_pm |
@@ -2538,8 +2643,9 @@ discard block |
||
2538 | 2643 | ) |
2539 | 2644 | ); |
2540 | 2645 | $pm_heads = array(); |
2541 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2542 | - $pm_heads[$row['id_pm_head']] = $row['id_pm']; |
|
2646 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2647 | + $pm_heads[$row['id_pm_head']] = $row['id_pm']; |
|
2648 | + } |
|
2543 | 2649 | $smcFunc['db_free_result']($request); |
2544 | 2650 | |
2545 | 2651 | $request = $smcFunc['db_query']('', ' |
@@ -2553,8 +2659,9 @@ discard block |
||
2553 | 2659 | // Copy the action from the single to PM to the others. |
2554 | 2660 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2555 | 2661 | { |
2556 | - if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) |
|
2557 | - $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]; |
|
2662 | + if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) { |
|
2663 | + $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]; |
|
2664 | + } |
|
2558 | 2665 | } |
2559 | 2666 | $smcFunc['db_free_result']($request); |
2560 | 2667 | } |
@@ -2566,22 +2673,21 @@ discard block |
||
2566 | 2673 | $labels = array(); |
2567 | 2674 | foreach ($_REQUEST['pm_actions'] as $pm => $action) |
2568 | 2675 | { |
2569 | - if ($action === 'delete') |
|
2570 | - $to_delete[] = (int) $pm; |
|
2571 | - else |
|
2676 | + if ($action === 'delete') { |
|
2677 | + $to_delete[] = (int) $pm; |
|
2678 | + } else |
|
2572 | 2679 | { |
2573 | 2680 | if (substr($action, 0, 4) == 'add_') |
2574 | 2681 | { |
2575 | 2682 | $type = 'add'; |
2576 | 2683 | $action = substr($action, 4); |
2577 | - } |
|
2578 | - elseif (substr($action, 0, 4) == 'rem_') |
|
2684 | + } elseif (substr($action, 0, 4) == 'rem_') |
|
2579 | 2685 | { |
2580 | 2686 | $type = 'rem'; |
2581 | 2687 | $action = substr($action, 4); |
2688 | + } else { |
|
2689 | + $type = 'unk'; |
|
2582 | 2690 | } |
2583 | - else |
|
2584 | - $type = 'unk'; |
|
2585 | 2691 | |
2586 | 2692 | if ($action == '-1' || (int) $action > 0) |
2587 | 2693 | { |
@@ -2592,8 +2698,9 @@ discard block |
||
2592 | 2698 | } |
2593 | 2699 | |
2594 | 2700 | // Deleting, it looks like? |
2595 | - if (!empty($to_delete)) |
|
2596 | - deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']); |
|
2701 | + if (!empty($to_delete)) { |
|
2702 | + deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']); |
|
2703 | + } |
|
2597 | 2704 | |
2598 | 2705 | // Are we labeling anything? |
2599 | 2706 | if (!empty($to_label) && $context['folder'] == 'inbox') |
@@ -2661,8 +2768,7 @@ discard block |
||
2661 | 2768 | } |
2662 | 2769 | |
2663 | 2770 | $smcFunc['db_free_result']($request2); |
2664 | - } |
|
2665 | - elseif ($type == 'rem') |
|
2771 | + } elseif ($type == 'rem') |
|
2666 | 2772 | { |
2667 | 2773 | // If we're removing from the inbox, see if we have at least one other label. |
2668 | 2774 | // This query is faster than the one above |
@@ -2694,21 +2800,25 @@ discard block |
||
2694 | 2800 | if ($to_label[$row['id_pm']] != '-1') |
2695 | 2801 | { |
2696 | 2802 | // If this label is in the list and we're not adding it, remove it |
2697 | - if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') |
|
2698 | - unset($labels[$to_label[$row['id_pm']]]); |
|
2699 | - else if ($type !== 'rem') |
|
2700 | - $labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']]; |
|
2803 | + if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') { |
|
2804 | + unset($labels[$to_label[$row['id_pm']]]); |
|
2805 | + } else if ($type !== 'rem') { |
|
2806 | + $labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']]; |
|
2807 | + } |
|
2701 | 2808 | } |
2702 | 2809 | |
2703 | 2810 | // Removing all labels or just removing the inbox label |
2704 | - if ($type == 'rem' && empty($labels)) |
|
2705 | - $in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0); |
|
2811 | + if ($type == 'rem' && empty($labels)) { |
|
2812 | + $in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0); |
|
2813 | + } |
|
2706 | 2814 | // Adding new labels, but removing inbox and applying new ones |
2707 | - elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) |
|
2708 | - $in_inbox = 0; |
|
2815 | + elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) { |
|
2816 | + $in_inbox = 0; |
|
2817 | + } |
|
2709 | 2818 | // Just adding it to the inbox |
2710 | - else |
|
2711 | - $in_inbox = 1; |
|
2819 | + else { |
|
2820 | + $in_inbox = 1; |
|
2821 | + } |
|
2712 | 2822 | |
2713 | 2823 | // Are we adding it to or removing it from the inbox? |
2714 | 2824 | if ($in_inbox != $row['in_inbox']) |
@@ -2750,8 +2860,9 @@ discard block |
||
2750 | 2860 | if (!empty($labels_to_apply)) |
2751 | 2861 | { |
2752 | 2862 | $inserts = array(); |
2753 | - foreach ($labels_to_apply as $label) |
|
2754 | - $inserts[] = array($row['id_pm'], $label); |
|
2863 | + foreach ($labels_to_apply as $label) { |
|
2864 | + $inserts[] = array($row['id_pm'], $label); |
|
2865 | + } |
|
2755 | 2866 | |
2756 | 2867 | $smcFunc['db_insert']('', |
2757 | 2868 | '{db_prefix}pm_labeled_messages', |
@@ -2795,11 +2906,13 @@ discard block |
||
2795 | 2906 | checkSession('get'); |
2796 | 2907 | |
2797 | 2908 | // If all then delete all messages the user has. |
2798 | - if ($_REQUEST['f'] == 'all') |
|
2799 | - deleteMessages(null, null); |
|
2909 | + if ($_REQUEST['f'] == 'all') { |
|
2910 | + deleteMessages(null, null); |
|
2911 | + } |
|
2800 | 2912 | // Otherwise just the selected folder. |
2801 | - else |
|
2802 | - deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent'); |
|
2913 | + else { |
|
2914 | + deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent'); |
|
2915 | + } |
|
2803 | 2916 | |
2804 | 2917 | // Done... all gone. |
2805 | 2918 | redirectexit($context['current_label_redirect']); |
@@ -2836,8 +2949,9 @@ discard block |
||
2836 | 2949 | 'msgtime' => $deleteTime, |
2837 | 2950 | ) |
2838 | 2951 | ); |
2839 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
2840 | - $toDelete[] = $row[0]; |
|
2952 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
2953 | + $toDelete[] = $row[0]; |
|
2954 | + } |
|
2841 | 2955 | $smcFunc['db_free_result']($request); |
2842 | 2956 | |
2843 | 2957 | // Select all messages in their inbox older than $deleteTime. |
@@ -2854,8 +2968,9 @@ discard block |
||
2854 | 2968 | 'msgtime' => $deleteTime, |
2855 | 2969 | ) |
2856 | 2970 | ); |
2857 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2858 | - $toDelete[] = $row['id_pm']; |
|
2971 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2972 | + $toDelete[] = $row['id_pm']; |
|
2973 | + } |
|
2859 | 2974 | $smcFunc['db_free_result']($request); |
2860 | 2975 | |
2861 | 2976 | // Delete the actual messages. |
@@ -2886,26 +3001,29 @@ discard block |
||
2886 | 3001 | { |
2887 | 3002 | global $user_info, $smcFunc; |
2888 | 3003 | |
2889 | - if ($owner === null) |
|
2890 | - $owner = array($user_info['id']); |
|
2891 | - elseif (empty($owner)) |
|
2892 | - return; |
|
2893 | - elseif (!is_array($owner)) |
|
2894 | - $owner = array($owner); |
|
3004 | + if ($owner === null) { |
|
3005 | + $owner = array($user_info['id']); |
|
3006 | + } elseif (empty($owner)) { |
|
3007 | + return; |
|
3008 | + } elseif (!is_array($owner)) { |
|
3009 | + $owner = array($owner); |
|
3010 | + } |
|
2895 | 3011 | |
2896 | 3012 | if ($personal_messages !== null) |
2897 | 3013 | { |
2898 | - if (empty($personal_messages) || !is_array($personal_messages)) |
|
2899 | - return; |
|
3014 | + if (empty($personal_messages) || !is_array($personal_messages)) { |
|
3015 | + return; |
|
3016 | + } |
|
2900 | 3017 | |
2901 | - foreach ($personal_messages as $index => $delete_id) |
|
2902 | - $personal_messages[$index] = (int) $delete_id; |
|
3018 | + foreach ($personal_messages as $index => $delete_id) { |
|
3019 | + $personal_messages[$index] = (int) $delete_id; |
|
3020 | + } |
|
2903 | 3021 | |
2904 | 3022 | $where = ' |
2905 | 3023 | AND id_pm IN ({array_int:pm_list})'; |
3024 | + } else { |
|
3025 | + $where = ''; |
|
2906 | 3026 | } |
2907 | - else |
|
2908 | - $where = ''; |
|
2909 | 3027 | |
2910 | 3028 | if ($folder == 'sent' || $folder === null) |
2911 | 3029 | { |
@@ -2940,17 +3058,19 @@ discard block |
||
2940 | 3058 | // ...And update the statistics accordingly - now including unread messages!. |
2941 | 3059 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2942 | 3060 | { |
2943 | - if ($row['is_read']) |
|
2944 | - updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'])); |
|
2945 | - else |
|
2946 | - updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'], 'unread_messages' => $where == '' ? 0 : 'unread_messages - ' . $row['num_deleted_messages'])); |
|
3061 | + if ($row['is_read']) { |
|
3062 | + updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'])); |
|
3063 | + } else { |
|
3064 | + updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'], 'unread_messages' => $where == '' ? 0 : 'unread_messages - ' . $row['num_deleted_messages'])); |
|
3065 | + } |
|
2947 | 3066 | |
2948 | 3067 | // If this is the current member we need to make their message count correct. |
2949 | 3068 | if ($user_info['id'] == $row['id_member']) |
2950 | 3069 | { |
2951 | 3070 | $user_info['messages'] -= $row['num_deleted_messages']; |
2952 | - if (!($row['is_read'])) |
|
2953 | - $user_info['unread_messages'] -= $row['num_deleted_messages']; |
|
3071 | + if (!($row['is_read'])) { |
|
3072 | + $user_info['unread_messages'] -= $row['num_deleted_messages']; |
|
3073 | + } |
|
2954 | 3074 | } |
2955 | 3075 | } |
2956 | 3076 | $smcFunc['db_free_result']($request); |
@@ -3018,8 +3138,9 @@ discard block |
||
3018 | 3138 | ) |
3019 | 3139 | ); |
3020 | 3140 | $remove_pms = array(); |
3021 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3022 | - $remove_pms[] = $row['sender']; |
|
3141 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3142 | + $remove_pms[] = $row['sender']; |
|
3143 | + } |
|
3023 | 3144 | $smcFunc['db_free_result']($request); |
3024 | 3145 | |
3025 | 3146 | if (!empty($remove_pms)) |
@@ -3064,8 +3185,9 @@ discard block |
||
3064 | 3185 | { |
3065 | 3186 | global $user_info, $context, $smcFunc; |
3066 | 3187 | |
3067 | - if ($owner === null) |
|
3068 | - $owner = $user_info['id']; |
|
3188 | + if ($owner === null) { |
|
3189 | + $owner = $user_info['id']; |
|
3190 | + } |
|
3069 | 3191 | |
3070 | 3192 | $in_inbox = ''; |
3071 | 3193 | |
@@ -3089,8 +3211,7 @@ discard block |
||
3089 | 3211 | } |
3090 | 3212 | |
3091 | 3213 | $smcFunc['db_free_result']($get_messages); |
3092 | - } |
|
3093 | - elseif ($label = '-1') |
|
3214 | + } elseif ($label = '-1') |
|
3094 | 3215 | { |
3095 | 3216 | // Marking all PMs in your inbox read |
3096 | 3217 | $in_inbox = ' |
@@ -3115,8 +3236,9 @@ discard block |
||
3115 | 3236 | { |
3116 | 3237 | if ($owner == $user_info['id']) |
3117 | 3238 | { |
3118 | - foreach ($context['labels'] as $label) |
|
3119 | - $context['labels'][(int) $label['id']]['unread_messages'] = 0; |
|
3239 | + foreach ($context['labels'] as $label) { |
|
3240 | + $context['labels'][(int) $label['id']]['unread_messages'] = 0; |
|
3241 | + } |
|
3120 | 3242 | } |
3121 | 3243 | |
3122 | 3244 | $result = $smcFunc['db_query']('', ' |
@@ -3136,8 +3258,9 @@ discard block |
||
3136 | 3258 | { |
3137 | 3259 | $total_unread += $row['num']; |
3138 | 3260 | |
3139 | - if ($owner != $user_info['id'] || empty($row['id_pm'])) |
|
3140 | - continue; |
|
3261 | + if ($owner != $user_info['id'] || empty($row['id_pm'])) { |
|
3262 | + continue; |
|
3263 | + } |
|
3141 | 3264 | |
3142 | 3265 | $this_labels = array(); |
3143 | 3266 | |
@@ -3161,11 +3284,13 @@ discard block |
||
3161 | 3284 | |
3162 | 3285 | $smcFunc['db_free_result']($result2); |
3163 | 3286 | |
3164 | - foreach ($this_labels as $this_label) |
|
3165 | - $context['labels'][$this_label]['unread_messages'] += $row['num']; |
|
3287 | + foreach ($this_labels as $this_label) { |
|
3288 | + $context['labels'][$this_label]['unread_messages'] += $row['num']; |
|
3289 | + } |
|
3166 | 3290 | |
3167 | - if ($row['in_inbox'] == 1) |
|
3168 | - $context['labels'][-1]['unread_messages'] += $row['num']; |
|
3291 | + if ($row['in_inbox'] == 1) { |
|
3292 | + $context['labels'][-1]['unread_messages'] += $row['num']; |
|
3293 | + } |
|
3169 | 3294 | } |
3170 | 3295 | $smcFunc['db_free_result']($result); |
3171 | 3296 | |
@@ -3174,8 +3299,9 @@ discard block |
||
3174 | 3299 | updateMemberData($owner, array('unread_messages' => $total_unread)); |
3175 | 3300 | |
3176 | 3301 | // If it was for the current member, reflect this in the $user_info array too. |
3177 | - if ($owner == $user_info['id']) |
|
3178 | - $user_info['unread_messages'] = $total_unread; |
|
3302 | + if ($owner == $user_info['id']) { |
|
3303 | + $user_info['unread_messages'] = $total_unread; |
|
3304 | + } |
|
3179 | 3305 | } |
3180 | 3306 | } |
3181 | 3307 | |
@@ -3203,8 +3329,9 @@ discard block |
||
3203 | 3329 | // Add all existing labels to the array to save, slashing them as necessary... |
3204 | 3330 | foreach ($context['labels'] as $label) |
3205 | 3331 | { |
3206 | - if ($label['id'] != -1) |
|
3207 | - $the_labels[$label['id']] = $label['name']; |
|
3332 | + if ($label['id'] != -1) { |
|
3333 | + $the_labels[$label['id']] = $label['name']; |
|
3334 | + } |
|
3208 | 3335 | } |
3209 | 3336 | |
3210 | 3337 | if (isset($_POST[$context['session_var']])) |
@@ -3223,8 +3350,9 @@ discard block |
||
3223 | 3350 | { |
3224 | 3351 | $_POST['label'] = strtr($smcFunc['htmlspecialchars'](trim($_POST['label'])), array(',' => ',')); |
3225 | 3352 | |
3226 | - if ($smcFunc['strlen']($_POST['label']) > 30) |
|
3227 | - $_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30); |
|
3353 | + if ($smcFunc['strlen']($_POST['label']) > 30) { |
|
3354 | + $_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30); |
|
3355 | + } |
|
3228 | 3356 | if ($_POST['label'] != '') |
3229 | 3357 | { |
3230 | 3358 | $the_labels[] = $_POST['label']; |
@@ -3245,24 +3373,25 @@ discard block |
||
3245 | 3373 | { |
3246 | 3374 | foreach ($the_labels as $id => $name) |
3247 | 3375 | { |
3248 | - if ($id == -1) |
|
3249 | - continue; |
|
3250 | - elseif (isset($_POST['label_name'][$id])) |
|
3376 | + if ($id == -1) { |
|
3377 | + continue; |
|
3378 | + } elseif (isset($_POST['label_name'][$id])) |
|
3251 | 3379 | { |
3252 | 3380 | $_POST['label_name'][$id] = trim(strtr($smcFunc['htmlspecialchars']($_POST['label_name'][$id]), array(',' => ','))); |
3253 | 3381 | |
3254 | - if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) |
|
3255 | - $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30); |
|
3382 | + if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) { |
|
3383 | + $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30); |
|
3384 | + } |
|
3256 | 3385 | if ($_POST['label_name'][$id] != '') |
3257 | 3386 | { |
3258 | 3387 | // Changing the name of this label? |
3259 | - if ($the_labels[$id] != $_POST['label_name'][$id]) |
|
3260 | - $label_updates[$id] = $_POST['label_name'][$id]; |
|
3388 | + if ($the_labels[$id] != $_POST['label_name'][$id]) { |
|
3389 | + $label_updates[$id] = $_POST['label_name'][$id]; |
|
3390 | + } |
|
3261 | 3391 | |
3262 | 3392 | $the_labels[(int) $id] = $_POST['label_name'][$id]; |
3263 | 3393 | |
3264 | - } |
|
3265 | - else |
|
3394 | + } else |
|
3266 | 3395 | { |
3267 | 3396 | unset($the_labels[(int) $id]); |
3268 | 3397 | $labels_to_remove[] = $id; |
@@ -3276,8 +3405,9 @@ discard block |
||
3276 | 3405 | if (!empty($labels_to_add)) |
3277 | 3406 | { |
3278 | 3407 | $inserts = array(); |
3279 | - foreach ($labels_to_add AS $label) |
|
3280 | - $inserts[] = array($user_info['id'], $label); |
|
3408 | + foreach ($labels_to_add AS $label) { |
|
3409 | + $inserts[] = array($user_info['id'], $label); |
|
3410 | + } |
|
3281 | 3411 | |
3282 | 3412 | $smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member' => 'int', 'name' => 'string-30'), $inserts, array()); |
3283 | 3413 | } |
@@ -3367,8 +3497,9 @@ discard block |
||
3367 | 3497 | // Each action... |
3368 | 3498 | foreach ($rule['actions'] as $k2 => $action) |
3369 | 3499 | { |
3370 | - if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) |
|
3371 | - continue; |
|
3500 | + if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) { |
|
3501 | + continue; |
|
3502 | + } |
|
3372 | 3503 | |
3373 | 3504 | $rule_changes[] = $rule['id']; |
3374 | 3505 | |
@@ -3383,8 +3514,8 @@ discard block |
||
3383 | 3514 | { |
3384 | 3515 | $rule_changes = array_unique($rule_changes); |
3385 | 3516 | // Update/delete as appropriate. |
3386 | - foreach ($rule_changes as $k => $id) |
|
3387 | - if (!empty($context['rules'][$id]['actions'])) |
|
3517 | + foreach ($rule_changes as $k => $id) { |
|
3518 | + if (!empty($context['rules'][$id]['actions'])) |
|
3388 | 3519 | { |
3389 | 3520 | $smcFunc['db_query']('', ' |
3390 | 3521 | UPDATE {db_prefix}pm_rules |
@@ -3397,12 +3528,13 @@ discard block |
||
3397 | 3528 | 'actions' => json_encode($context['rules'][$id]['actions']), |
3398 | 3529 | ) |
3399 | 3530 | ); |
3531 | + } |
|
3400 | 3532 | unset($rule_changes[$k]); |
3401 | 3533 | } |
3402 | 3534 | |
3403 | 3535 | // Anything left here means it's lost all actions... |
3404 | - if (!empty($rule_changes)) |
|
3405 | - $smcFunc['db_query']('', ' |
|
3536 | + if (!empty($rule_changes)) { |
|
3537 | + $smcFunc['db_query']('', ' |
|
3406 | 3538 | DELETE FROM {db_prefix}pm_rules |
3407 | 3539 | WHERE id_rule IN ({array_int:rule_list}) |
3408 | 3540 | AND id_member = {int:current_member}', |
@@ -3411,6 +3543,7 @@ discard block |
||
3411 | 3543 | 'rule_list' => $rule_changes, |
3412 | 3544 | ) |
3413 | 3545 | ); |
3546 | + } |
|
3414 | 3547 | } |
3415 | 3548 | |
3416 | 3549 | // Make sure we're not caching this! |
@@ -3480,8 +3613,9 @@ discard block |
||
3480 | 3613 | // Save the fields. |
3481 | 3614 | saveProfileFields(); |
3482 | 3615 | |
3483 | - if (!empty($profile_vars)) |
|
3484 | - updateMemberData($user_info['id'], $profile_vars); |
|
3616 | + if (!empty($profile_vars)) { |
|
3617 | + updateMemberData($user_info['id'], $profile_vars); |
|
3618 | + } |
|
3485 | 3619 | } |
3486 | 3620 | |
3487 | 3621 | setupProfileContext( |
@@ -3506,13 +3640,15 @@ discard block |
||
3506 | 3640 | global $user_info, $language, $modSettings, $smcFunc; |
3507 | 3641 | |
3508 | 3642 | // Check that this feature is even enabled! |
3509 | - if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) |
|
3510 | - fatal_lang_error('no_access', false); |
|
3643 | + if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) { |
|
3644 | + fatal_lang_error('no_access', false); |
|
3645 | + } |
|
3511 | 3646 | |
3512 | 3647 | $pmsg = (int) $_REQUEST['pmsg']; |
3513 | 3648 | |
3514 | - if (!isAccessiblePM($pmsg, 'inbox')) |
|
3515 | - fatal_lang_error('no_access', false); |
|
3649 | + if (!isAccessiblePM($pmsg, 'inbox')) { |
|
3650 | + fatal_lang_error('no_access', false); |
|
3651 | + } |
|
3516 | 3652 | |
3517 | 3653 | $context['pm_id'] = $pmsg; |
3518 | 3654 | $context['page_title'] = $txt['pm_report_title']; |
@@ -3534,8 +3670,9 @@ discard block |
||
3534 | 3670 | ) |
3535 | 3671 | ); |
3536 | 3672 | $context['admins'] = array(); |
3537 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3538 | - $context['admins'][$row['id_member']] = $row['real_name']; |
|
3673 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3674 | + $context['admins'][$row['id_member']] = $row['real_name']; |
|
3675 | + } |
|
3539 | 3676 | $smcFunc['db_free_result']($request); |
3540 | 3677 | |
3541 | 3678 | // How many admins in total? |
@@ -3564,8 +3701,9 @@ discard block |
||
3564 | 3701 | ) |
3565 | 3702 | ); |
3566 | 3703 | // Can only be a hacker here! |
3567 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
3568 | - fatal_lang_error('no_access', false); |
|
3704 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
3705 | + fatal_lang_error('no_access', false); |
|
3706 | + } |
|
3569 | 3707 | list ($subject, $body, $time, $memberFromID, $memberFromName) = $smcFunc['db_fetch_row']($request); |
3570 | 3708 | $smcFunc['db_free_result']($request); |
3571 | 3709 | |
@@ -3589,15 +3727,17 @@ discard block |
||
3589 | 3727 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
3590 | 3728 | { |
3591 | 3729 | // If it's hidden still don't reveal their names - privacy after all ;) |
3592 | - if ($row['bcc']) |
|
3593 | - $hidden_recipients++; |
|
3594 | - else |
|
3595 | - $recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]'; |
|
3730 | + if ($row['bcc']) { |
|
3731 | + $hidden_recipients++; |
|
3732 | + } else { |
|
3733 | + $recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]'; |
|
3734 | + } |
|
3596 | 3735 | } |
3597 | 3736 | $smcFunc['db_free_result']($request); |
3598 | 3737 | |
3599 | - if ($hidden_recipients) |
|
3600 | - $recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients); |
|
3738 | + if ($hidden_recipients) { |
|
3739 | + $recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients); |
|
3740 | + } |
|
3601 | 3741 | |
3602 | 3742 | // Now let's get out and loop through the admins. |
3603 | 3743 | $request = $smcFunc['db_query']('', ' |
@@ -3613,8 +3753,9 @@ discard block |
||
3613 | 3753 | ); |
3614 | 3754 | |
3615 | 3755 | // Maybe we shouldn't advertise this? |
3616 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
3617 | - fatal_lang_error('no_access', false); |
|
3756 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
3757 | + fatal_lang_error('no_access', false); |
|
3758 | + } |
|
3618 | 3759 | |
3619 | 3760 | $memberFromName = un_htmlspecialchars($memberFromName); |
3620 | 3761 | |
@@ -3633,8 +3774,9 @@ discard block |
||
3633 | 3774 | // Make the body. |
3634 | 3775 | $report_body = str_replace(array('{REPORTER}', '{SENDER}'), array(un_htmlspecialchars($user_info['name']), $memberFromName), $txt['pm_report_pm_user_sent']); |
3635 | 3776 | $report_body .= "\n" . '[b]' . $_POST['reason'] . '[/b]' . "\n\n"; |
3636 | - if (!empty($recipients)) |
|
3637 | - $report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n"; |
|
3777 | + if (!empty($recipients)) { |
|
3778 | + $report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n"; |
|
3779 | + } |
|
3638 | 3780 | $report_body .= $txt['pm_report_pm_unedited_below'] . "\n" . '[quote author=' . (empty($memberFromID) ? '"' . $memberFromName . '"' : $memberFromName . ' link=action=profile;u=' . $memberFromID . ' date=' . $time) . ']' . "\n" . un_htmlspecialchars($body) . '[/quote]'; |
3639 | 3781 | |
3640 | 3782 | // Plonk it in the array ;) |
@@ -3654,12 +3796,14 @@ discard block |
||
3654 | 3796 | $smcFunc['db_free_result']($request); |
3655 | 3797 | |
3656 | 3798 | // Send a different email for each language. |
3657 | - foreach ($messagesToSend as $lang => $message) |
|
3658 | - sendpm($message['recipients'], $message['subject'], $message['body']); |
|
3799 | + foreach ($messagesToSend as $lang => $message) { |
|
3800 | + sendpm($message['recipients'], $message['subject'], $message['body']); |
|
3801 | + } |
|
3659 | 3802 | |
3660 | 3803 | // Give the user their own language back! |
3661 | - if (!empty($modSettings['userLanguage'])) |
|
3662 | - loadLanguage('PersonalMessage', '', false); |
|
3804 | + if (!empty($modSettings['userLanguage'])) { |
|
3805 | + loadLanguage('PersonalMessage', '', false); |
|
3806 | + } |
|
3663 | 3807 | |
3664 | 3808 | // Leave them with a template. |
3665 | 3809 | $context['sub_template'] = 'report_message_complete'; |
@@ -3705,8 +3849,9 @@ discard block |
||
3705 | 3849 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
3706 | 3850 | { |
3707 | 3851 | // Hide hidden groups! |
3708 | - if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) |
|
3709 | - continue; |
|
3852 | + if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) { |
|
3853 | + continue; |
|
3854 | + } |
|
3710 | 3855 | |
3711 | 3856 | $context['groups'][$row['id_group']] = $row['group_name']; |
3712 | 3857 | } |
@@ -3732,9 +3877,10 @@ discard block |
||
3732 | 3877 | $context['rule'] = $context['rules'][$context['rid']]; |
3733 | 3878 | $members = array(); |
3734 | 3879 | // Need to get member names! |
3735 | - foreach ($context['rule']['criteria'] as $k => $criteria) |
|
3736 | - if ($criteria['t'] == 'mid' && !empty($criteria['v'])) |
|
3880 | + foreach ($context['rule']['criteria'] as $k => $criteria) { |
|
3881 | + if ($criteria['t'] == 'mid' && !empty($criteria['v'])) |
|
3737 | 3882 | $members[(int) $criteria['v']] = $k; |
3883 | + } |
|
3738 | 3884 | |
3739 | 3885 | if (!empty($members)) |
3740 | 3886 | { |
@@ -3746,19 +3892,20 @@ discard block |
||
3746 | 3892 | 'member_list' => array_keys($members), |
3747 | 3893 | ) |
3748 | 3894 | ); |
3749 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3750 | - $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; |
|
3895 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3896 | + $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; |
|
3897 | + } |
|
3751 | 3898 | $smcFunc['db_free_result']($request); |
3752 | 3899 | } |
3753 | - } |
|
3754 | - else |
|
3755 | - $context['rule'] = array( |
|
3900 | + } else { |
|
3901 | + $context['rule'] = array( |
|
3756 | 3902 | 'id' => '', |
3757 | 3903 | 'name' => '', |
3758 | 3904 | 'criteria' => array(), |
3759 | 3905 | 'actions' => array(), |
3760 | 3906 | 'logic' => 'and', |
3761 | 3907 | ); |
3908 | + } |
|
3762 | 3909 | } |
3763 | 3910 | // Saving? |
3764 | 3911 | elseif (isset($_GET['save'])) |
@@ -3768,22 +3915,25 @@ discard block |
||
3768 | 3915 | |
3769 | 3916 | // Name is easy! |
3770 | 3917 | $ruleName = $smcFunc['htmlspecialchars'](trim($_POST['rule_name'])); |
3771 | - if (empty($ruleName)) |
|
3772 | - fatal_lang_error('pm_rule_no_name', false); |
|
3918 | + if (empty($ruleName)) { |
|
3919 | + fatal_lang_error('pm_rule_no_name', false); |
|
3920 | + } |
|
3773 | 3921 | |
3774 | 3922 | // Sanity check... |
3775 | - if (empty($_POST['ruletype']) || empty($_POST['acttype'])) |
|
3776 | - fatal_lang_error('pm_rule_no_criteria', false); |
|
3923 | + if (empty($_POST['ruletype']) || empty($_POST['acttype'])) { |
|
3924 | + fatal_lang_error('pm_rule_no_criteria', false); |
|
3925 | + } |
|
3777 | 3926 | |
3778 | 3927 | // Let's do the criteria first - it's also hardest! |
3779 | 3928 | $criteria = array(); |
3780 | 3929 | foreach ($_POST['ruletype'] as $ind => $type) |
3781 | 3930 | { |
3782 | 3931 | // Check everything is here... |
3783 | - if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) |
|
3784 | - continue; |
|
3785 | - elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) |
|
3786 | - continue; |
|
3932 | + if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) { |
|
3933 | + continue; |
|
3934 | + } elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) { |
|
3935 | + continue; |
|
3936 | + } |
|
3787 | 3937 | |
3788 | 3938 | // Members need to be found. |
3789 | 3939 | if ($type == 'mid') |
@@ -3807,13 +3957,13 @@ discard block |
||
3807 | 3957 | $smcFunc['db_free_result']($request); |
3808 | 3958 | |
3809 | 3959 | $criteria[] = array('t' => 'mid', 'v' => $memID); |
3960 | + } elseif ($type == 'bud') { |
|
3961 | + $criteria[] = array('t' => 'bud', 'v' => 1); |
|
3962 | + } elseif ($type == 'gid') { |
|
3963 | + $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); |
|
3964 | + } elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') { |
|
3965 | + $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); |
|
3810 | 3966 | } |
3811 | - elseif ($type == 'bud') |
|
3812 | - $criteria[] = array('t' => 'bud', 'v' => 1); |
|
3813 | - elseif ($type == 'gid') |
|
3814 | - $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); |
|
3815 | - elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') |
|
3816 | - $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); |
|
3817 | 3967 | } |
3818 | 3968 | |
3819 | 3969 | // Also do the actions! |
@@ -3823,26 +3973,29 @@ discard block |
||
3823 | 3973 | foreach ($_POST['acttype'] as $ind => $type) |
3824 | 3974 | { |
3825 | 3975 | // Picking a valid label? |
3826 | - if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) |
|
3827 | - continue; |
|
3976 | + if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) { |
|
3977 | + continue; |
|
3978 | + } |
|
3828 | 3979 | |
3829 | 3980 | // Record what we're doing. |
3830 | - if ($type == 'del') |
|
3831 | - $doDelete = 1; |
|
3832 | - elseif ($type == 'lab') |
|
3833 | - $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]); |
|
3981 | + if ($type == 'del') { |
|
3982 | + $doDelete = 1; |
|
3983 | + } elseif ($type == 'lab') { |
|
3984 | + $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]); |
|
3985 | + } |
|
3834 | 3986 | } |
3835 | 3987 | |
3836 | - if (empty($criteria) || (empty($actions) && !$doDelete)) |
|
3837 | - fatal_lang_error('pm_rule_no_criteria', false); |
|
3988 | + if (empty($criteria) || (empty($actions) && !$doDelete)) { |
|
3989 | + fatal_lang_error('pm_rule_no_criteria', false); |
|
3990 | + } |
|
3838 | 3991 | |
3839 | 3992 | // What are we storing? |
3840 | 3993 | $criteria = json_encode($criteria); |
3841 | 3994 | $actions = json_encode($actions); |
3842 | 3995 | |
3843 | 3996 | // Create the rule? |
3844 | - if (empty($context['rid'])) |
|
3845 | - $smcFunc['db_insert']('', |
|
3997 | + if (empty($context['rid'])) { |
|
3998 | + $smcFunc['db_insert']('', |
|
3846 | 3999 | '{db_prefix}pm_rules', |
3847 | 4000 | array( |
3848 | 4001 | 'id_member' => 'int', 'rule_name' => 'string', 'criteria' => 'string', 'actions' => 'string', |
@@ -3853,8 +4006,8 @@ discard block |
||
3853 | 4006 | ), |
3854 | 4007 | array('id_rule') |
3855 | 4008 | ); |
3856 | - else |
|
3857 | - $smcFunc['db_query']('', ' |
|
4009 | + } else { |
|
4010 | + $smcFunc['db_query']('', ' |
|
3858 | 4011 | UPDATE {db_prefix}pm_rules |
3859 | 4012 | SET rule_name = {string:rule_name}, criteria = {string:criteria}, actions = {string:actions}, |
3860 | 4013 | delete_pm = {int:delete_pm}, is_or = {int:is_or} |
@@ -3870,6 +4023,7 @@ discard block |
||
3870 | 4023 | 'actions' => $actions, |
3871 | 4024 | ) |
3872 | 4025 | ); |
4026 | + } |
|
3873 | 4027 | |
3874 | 4028 | redirectexit('action=pm;sa=manrules'); |
3875 | 4029 | } |
@@ -3878,11 +4032,12 @@ discard block |
||
3878 | 4032 | { |
3879 | 4033 | checkSession(); |
3880 | 4034 | $toDelete = array(); |
3881 | - foreach ($_POST['delrule'] as $k => $v) |
|
3882 | - $toDelete[] = (int) $k; |
|
4035 | + foreach ($_POST['delrule'] as $k => $v) { |
|
4036 | + $toDelete[] = (int) $k; |
|
4037 | + } |
|
3883 | 4038 | |
3884 | - if (!empty($toDelete)) |
|
3885 | - $smcFunc['db_query']('', ' |
|
4039 | + if (!empty($toDelete)) { |
|
4040 | + $smcFunc['db_query']('', ' |
|
3886 | 4041 | DELETE FROM {db_prefix}pm_rules |
3887 | 4042 | WHERE id_rule IN ({array_int:delete_list}) |
3888 | 4043 | AND id_member = {int:current_member}', |
@@ -3891,6 +4046,7 @@ discard block |
||
3891 | 4046 | 'delete_list' => $toDelete, |
3892 | 4047 | ) |
3893 | 4048 | ); |
4049 | + } |
|
3894 | 4050 | |
3895 | 4051 | redirectexit('action=pm;sa=manrules'); |
3896 | 4052 | } |
@@ -3909,8 +4065,9 @@ discard block |
||
3909 | 4065 | loadRules(); |
3910 | 4066 | |
3911 | 4067 | // No rules? |
3912 | - if (empty($context['rules'])) |
|
3913 | - return; |
|
4068 | + if (empty($context['rules'])) { |
|
4069 | + return; |
|
4070 | + } |
|
3914 | 4071 | |
3915 | 4072 | // Just unread ones? |
3916 | 4073 | $ruleQuery = $all_messages ? '' : ' AND pmr.is_new = 1'; |
@@ -3940,8 +4097,9 @@ discard block |
||
3940 | 4097 | // Loop through all the criteria hoping to make a match. |
3941 | 4098 | foreach ($rule['criteria'] as $criterium) |
3942 | 4099 | { |
3943 | - if (($criterium['t'] == 'mid' && $criterium['v'] == $row['id_member_from']) || ($criterium['t'] == 'gid' && $criterium['v'] == $row['id_group']) || ($criterium['t'] == 'sub' && strpos($row['subject'], $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($row['body'], $criterium['v']) !== false)) |
|
3944 | - $match = true; |
|
4100 | + if (($criterium['t'] == 'mid' && $criterium['v'] == $row['id_member_from']) || ($criterium['t'] == 'gid' && $criterium['v'] == $row['id_group']) || ($criterium['t'] == 'sub' && strpos($row['subject'], $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($row['body'], $criterium['v']) !== false)) { |
|
4101 | + $match = true; |
|
4102 | + } |
|
3945 | 4103 | // If we're adding and one criteria don't match then we stop! |
3946 | 4104 | elseif ($rule['logic'] == 'and') |
3947 | 4105 | { |
@@ -3953,17 +4111,18 @@ discard block |
||
3953 | 4111 | // If we have a match the rule must be true - act! |
3954 | 4112 | if ($match) |
3955 | 4113 | { |
3956 | - if ($rule['delete']) |
|
3957 | - $actions['deletes'][] = $row['id_pm']; |
|
3958 | - else |
|
4114 | + if ($rule['delete']) { |
|
4115 | + $actions['deletes'][] = $row['id_pm']; |
|
4116 | + } else |
|
3959 | 4117 | { |
3960 | 4118 | foreach ($rule['actions'] as $ruleAction) |
3961 | 4119 | { |
3962 | 4120 | if ($ruleAction['t'] == 'lab') |
3963 | 4121 | { |
3964 | 4122 | // Get a basic pot started! |
3965 | - if (!isset($actions['labels'][$row['id_pm']])) |
|
3966 | - $actions['labels'][$row['id_pm']] = array(); |
|
4123 | + if (!isset($actions['labels'][$row['id_pm']])) { |
|
4124 | + $actions['labels'][$row['id_pm']] = array(); |
|
4125 | + } |
|
3967 | 4126 | $actions['labels'][$row['id_pm']][] = $ruleAction['v']; |
3968 | 4127 | } |
3969 | 4128 | } |
@@ -3974,8 +4133,9 @@ discard block |
||
3974 | 4133 | $smcFunc['db_free_result']($request); |
3975 | 4134 | |
3976 | 4135 | // Deletes are easy! |
3977 | - if (!empty($actions['deletes'])) |
|
3978 | - deleteMessages($actions['deletes']); |
|
4136 | + if (!empty($actions['deletes'])) { |
|
4137 | + deleteMessages($actions['deletes']); |
|
4138 | + } |
|
3979 | 4139 | |
3980 | 4140 | // Relabel? |
3981 | 4141 | if (!empty($actions['labels'])) |
@@ -4002,8 +4162,7 @@ discard block |
||
4002 | 4162 | 'current_member' => $user_info['id'], |
4003 | 4163 | ) |
4004 | 4164 | ); |
4005 | - } |
|
4006 | - else |
|
4165 | + } else |
|
4007 | 4166 | { |
4008 | 4167 | $realLabels[] = $label['id']; |
4009 | 4168 | } |
@@ -4012,8 +4171,9 @@ discard block |
||
4012 | 4171 | |
4013 | 4172 | $inserts = array(); |
4014 | 4173 | // Now we insert the label info |
4015 | - foreach ($realLabels as $a_label) |
|
4016 | - $inserts[] = array($pm, $a_label); |
|
4174 | + foreach ($realLabels as $a_label) { |
|
4175 | + $inserts[] = array($pm, $a_label); |
|
4176 | + } |
|
4017 | 4177 | |
4018 | 4178 | $smcFunc['db_insert']('ignore', |
4019 | 4179 | '{db_prefix}pm_labeled_messages', |
@@ -4034,8 +4194,9 @@ discard block |
||
4034 | 4194 | { |
4035 | 4195 | global $user_info, $context, $smcFunc; |
4036 | 4196 | |
4037 | - if (isset($context['rules']) && !$reload) |
|
4038 | - return; |
|
4197 | + if (isset($context['rules']) && !$reload) { |
|
4198 | + return; |
|
4199 | + } |
|
4039 | 4200 | |
4040 | 4201 | $request = $smcFunc['db_query']('', ' |
4041 | 4202 | SELECT |
@@ -4059,8 +4220,9 @@ discard block |
||
4059 | 4220 | 'logic' => $row['is_or'] ? 'or' : 'and', |
4060 | 4221 | ); |
4061 | 4222 | |
4062 | - if ($row['delete_pm']) |
|
4063 | - $context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1); |
|
4223 | + if ($row['delete_pm']) { |
|
4224 | + $context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1); |
|
4225 | + } |
|
4064 | 4226 | } |
4065 | 4227 | $smcFunc['db_free_result']($request); |
4066 | 4228 | } |
@@ -2183,7 +2183,7 @@ discard block |
||
2183 | 2183 | * Deletes a single or a group of alerts by ID |
2184 | 2184 | * |
2185 | 2185 | * @param int|array The ID of a single alert to delete or an array containing the IDs of multiple alerts. The function will convert integers into an array for better handling. |
2186 | - * @param bool|int $memID The user ID. Used to update the user unread alerts count. |
|
2186 | + * @param integer $memID The user ID. Used to update the user unread alerts count. |
|
2187 | 2187 | * @return void|int If the $memID param is set, returns the new amount of unread alerts. |
2188 | 2188 | */ |
2189 | 2189 | function alert_delete($toDelete, $memID = false) |
@@ -2839,7 +2839,7 @@ discard block |
||
2839 | 2839 | /** |
2840 | 2840 | * Handles the "manage groups" section of the profile |
2841 | 2841 | * |
2842 | - * @return true Always returns true |
|
2842 | + * @return boolean Always returns true |
|
2843 | 2843 | */ |
2844 | 2844 | function profileLoadGroups() |
2845 | 2845 | { |
@@ -2896,7 +2896,7 @@ discard block |
||
2896 | 2896 | /** |
2897 | 2897 | * Load key signature context data. |
2898 | 2898 | * |
2899 | - * @return true Always returns true |
|
2899 | + * @return boolean Always returns true |
|
2900 | 2900 | */ |
2901 | 2901 | function profileLoadSignatureData() |
2902 | 2902 | { |
@@ -2960,7 +2960,7 @@ discard block |
||
2960 | 2960 | /** |
2961 | 2961 | * Load avatar context data. |
2962 | 2962 | * |
2963 | - * @return true Always returns true |
|
2963 | + * @return boolean Always returns true |
|
2964 | 2964 | */ |
2965 | 2965 | function profileLoadAvatarData() |
2966 | 2966 | { |
@@ -3033,7 +3033,7 @@ discard block |
||
3033 | 3033 | * Save a members group. |
3034 | 3034 | * |
3035 | 3035 | * @param int &$value The ID of the (new) primary group |
3036 | - * @return true Always returns true |
|
3036 | + * @return boolean Always returns true |
|
3037 | 3037 | */ |
3038 | 3038 | function profileSaveGroups(&$value) |
3039 | 3039 | { |
@@ -3138,7 +3138,7 @@ discard block |
||
3138 | 3138 | * @todo argh, the avatar here. Take this out of here! |
3139 | 3139 | * |
3140 | 3140 | * @param string &$value What kind of avatar we're expecting. Can be 'none', 'server_stored', 'gravatar', 'external' or 'upload' |
3141 | - * @return bool|string False if success (or if memID is empty and password authentication failed), otherwise a string indicating what error occurred |
|
3141 | + * @return false|string False if success (or if memID is empty and password authentication failed), otherwise a string indicating what error occurred |
|
3142 | 3142 | */ |
3143 | 3143 | function profileSaveAvatarData(&$value) |
3144 | 3144 | { |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 3 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * This defines every profile field known to man. |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | global $sourcedir, $profile_vars; |
30 | 31 | |
31 | 32 | // Don't load this twice! |
32 | - if (!empty($profile_fields) && !$force_reload) |
|
33 | - return; |
|
33 | + if (!empty($profile_fields) && !$force_reload) { |
|
34 | + return; |
|
35 | + } |
|
34 | 36 | |
35 | 37 | /* This horrific array defines all the profile fields in the whole world! |
36 | 38 | In general each "field" has one array - the key of which is the database column name associated with said field. Each item |
@@ -103,13 +105,14 @@ discard block |
||
103 | 105 | if (isset($_POST['bday2'], $_POST['bday3']) && $value > 0 && $_POST['bday2'] > 0) |
104 | 106 | { |
105 | 107 | // Set to blank? |
106 | - if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) |
|
107 | - $value = '0001-01-01'; |
|
108 | - else |
|
109 | - $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 4 ? 4 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 4 ? 4 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '0001-01-01'; |
|
108 | + if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) { |
|
109 | + $value = '0001-01-01'; |
|
110 | + } else { |
|
111 | + $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 4 ? 4 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 4 ? 4 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '0001-01-01'; |
|
112 | + } |
|
113 | + } else { |
|
114 | + $value = '0001-01-01'; |
|
110 | 115 | } |
111 | - else |
|
112 | - $value = '0001-01-01'; |
|
113 | 116 | |
114 | 117 | $profile_vars['birthdate'] = $value; |
115 | 118 | $cur_profile['birthdate'] = $value; |
@@ -127,8 +130,7 @@ discard block |
||
127 | 130 | { |
128 | 131 | $value = checkdate($dates[2], $dates[3], $dates[1] < 4 ? 4 : $dates[1]) ? sprintf('%04d-%02d-%02d', $dates[1] < 4 ? 4 : $dates[1], $dates[2], $dates[3]) : '0001-01-01'; |
129 | 132 | return true; |
130 | - } |
|
131 | - else |
|
133 | + } else |
|
132 | 134 | { |
133 | 135 | $value = empty($cur_profile['birthdate']) ? '0001-01-01' : $cur_profile['birthdate']; |
134 | 136 | return false; |
@@ -150,10 +152,11 @@ discard block |
||
150 | 152 | return $txt['invalid_registration'] . ' ' . strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%H:%M:%S'), forum_time(false)); |
151 | 153 | } |
152 | 154 | // As long as it doesn't equal "N/A"... |
153 | - elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) |
|
154 | - $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
155 | - else |
|
156 | - $value = $cur_profile['date_registered']; |
|
155 | + elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) { |
|
156 | + $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
157 | + } else { |
|
158 | + $value = $cur_profile['date_registered']; |
|
159 | + } |
|
157 | 160 | |
158 | 161 | return true; |
159 | 162 | }, |
@@ -177,8 +180,9 @@ discard block |
||
177 | 180 | { |
178 | 181 | global $context, $old_profile, $profile_vars, $sourcedir, $modSettings; |
179 | 182 | |
180 | - if (strtolower($value) == strtolower($old_profile['email_address'])) |
|
181 | - return false; |
|
183 | + if (strtolower($value) == strtolower($old_profile['email_address'])) { |
|
184 | + return false; |
|
185 | + } |
|
182 | 186 | |
183 | 187 | $isValid = profileValidateEmail($value, $context['id_member']); |
184 | 188 | |
@@ -254,11 +258,11 @@ discard block |
||
254 | 258 | |
255 | 259 | if (isset($context['profile_languages'][$value])) |
256 | 260 | { |
257 | - if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) |
|
258 | - $_SESSION['language'] = $value; |
|
261 | + if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) { |
|
262 | + $_SESSION['language'] = $value; |
|
263 | + } |
|
259 | 264 | return true; |
260 | - } |
|
261 | - else |
|
265 | + } else |
|
262 | 266 | { |
263 | 267 | $value = $cur_profile['lngfile']; |
264 | 268 | return false; |
@@ -282,13 +286,14 @@ discard block |
||
282 | 286 | |
283 | 287 | // Maybe they are trying to change their password as well? |
284 | 288 | $resetPassword = true; |
285 | - if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) |
|
286 | - $resetPassword = false; |
|
289 | + if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) { |
|
290 | + $resetPassword = false; |
|
291 | + } |
|
287 | 292 | |
288 | 293 | // Do the reset... this will send them an email too. |
289 | - if ($resetPassword) |
|
290 | - resetPassword($context['id_member'], $value); |
|
291 | - elseif ($value !== null) |
|
294 | + if ($resetPassword) { |
|
295 | + resetPassword($context['id_member'], $value); |
|
296 | + } elseif ($value !== null) |
|
292 | 297 | { |
293 | 298 | validateUsername($context['id_member'], trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value))); |
294 | 299 | updateMemberData($context['id_member'], array('member_name' => $value)); |
@@ -312,20 +317,23 @@ discard block |
||
312 | 317 | 'input_validate' => function(&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile) |
313 | 318 | { |
314 | 319 | // If we didn't try it then ignore it! |
315 | - if ($value == '') |
|
316 | - return false; |
|
320 | + if ($value == '') { |
|
321 | + return false; |
|
322 | + } |
|
317 | 323 | |
318 | 324 | // Do the two entries for the password even match? |
319 | - if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) |
|
320 | - return 'bad_new_password'; |
|
325 | + if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) { |
|
326 | + return 'bad_new_password'; |
|
327 | + } |
|
321 | 328 | |
322 | 329 | // Let's get the validation function into play... |
323 | 330 | require_once($sourcedir . '/Subs-Auth.php'); |
324 | 331 | $passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])); |
325 | 332 | |
326 | 333 | // Were there errors? |
327 | - if ($passwordErrors != null) |
|
328 | - return 'password_' . $passwordErrors; |
|
334 | + if ($passwordErrors != null) { |
|
335 | + return 'password_' . $passwordErrors; |
|
336 | + } |
|
329 | 337 | |
330 | 338 | // Set up the new password variable... ready for storage. |
331 | 339 | $value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value)); |
@@ -350,8 +358,9 @@ discard block |
||
350 | 358 | 'permission' => 'profile_blurb', |
351 | 359 | 'input_validate' => function(&$value) use ($smcFunc) |
352 | 360 | { |
353 | - if ($smcFunc['strlen']($value) > 50) |
|
354 | - return 'personal_text_too_long'; |
|
361 | + if ($smcFunc['strlen']($value) > 50) { |
|
362 | + return 'personal_text_too_long'; |
|
363 | + } |
|
355 | 364 | |
356 | 365 | return true; |
357 | 366 | }, |
@@ -386,10 +395,11 @@ discard block |
||
386 | 395 | 'permission' => 'moderate_forum', |
387 | 396 | 'input_validate' => function(&$value) |
388 | 397 | { |
389 | - if (!is_numeric($value)) |
|
390 | - return 'digits_only'; |
|
391 | - else |
|
392 | - $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
398 | + if (!is_numeric($value)) { |
|
399 | + return 'digits_only'; |
|
400 | + } else { |
|
401 | + $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
402 | + } |
|
393 | 403 | return true; |
394 | 404 | }, |
395 | 405 | ), |
@@ -405,15 +415,16 @@ discard block |
||
405 | 415 | { |
406 | 416 | $value = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value)); |
407 | 417 | |
408 | - if (trim($value) == '') |
|
409 | - return 'no_name'; |
|
410 | - elseif ($smcFunc['strlen']($value) > 60) |
|
411 | - return 'name_too_long'; |
|
412 | - elseif ($cur_profile['real_name'] != $value) |
|
418 | + if (trim($value) == '') { |
|
419 | + return 'no_name'; |
|
420 | + } elseif ($smcFunc['strlen']($value) > 60) { |
|
421 | + return 'name_too_long'; |
|
422 | + } elseif ($cur_profile['real_name'] != $value) |
|
413 | 423 | { |
414 | 424 | require_once($sourcedir . '/Subs-Members.php'); |
415 | - if (isReservedName($value, $context['id_member'])) |
|
416 | - return 'name_taken'; |
|
425 | + if (isReservedName($value, $context['id_member'])) { |
|
426 | + return 'name_taken'; |
|
427 | + } |
|
417 | 428 | } |
418 | 429 | return true; |
419 | 430 | }, |
@@ -471,8 +482,9 @@ discard block |
||
471 | 482 | 'selected' => $set == $context['member']['smiley_set']['id'] |
472 | 483 | ); |
473 | 484 | |
474 | - if ($context['smiley_sets'][$i]['selected']) |
|
475 | - $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
485 | + if ($context['smiley_sets'][$i]['selected']) { |
|
486 | + $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
487 | + } |
|
476 | 488 | } |
477 | 489 | return true; |
478 | 490 | }, |
@@ -481,8 +493,9 @@ discard block |
||
481 | 493 | global $modSettings; |
482 | 494 | |
483 | 495 | $smiley_sets = explode(',', $modSettings['smiley_sets_known']); |
484 | - if (!in_array($value, $smiley_sets) && $value != 'none') |
|
485 | - $value = ''; |
|
496 | + if (!in_array($value, $smiley_sets) && $value != 'none') { |
|
497 | + $value = ''; |
|
498 | + } |
|
486 | 499 | return true; |
487 | 500 | }, |
488 | 501 | ), |
@@ -497,8 +510,9 @@ discard block |
||
497 | 510 | loadLanguage('Settings'); |
498 | 511 | |
499 | 512 | $context['allow_no_censored'] = false; |
500 | - if ($user_info['is_admin'] || $context['user']['is_owner']) |
|
501 | - $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
513 | + if ($user_info['is_admin'] || $context['user']['is_owner']) { |
|
514 | + $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
515 | + } |
|
502 | 516 | |
503 | 517 | return true; |
504 | 518 | }, |
@@ -545,8 +559,9 @@ discard block |
||
545 | 559 | 'input_validate' => function($value) |
546 | 560 | { |
547 | 561 | $tz = smf_list_timezones(); |
548 | - if (!isset($tz[$value])) |
|
549 | - return 'bad_timezone'; |
|
562 | + if (!isset($tz[$value])) { |
|
563 | + return 'bad_timezone'; |
|
564 | + } |
|
550 | 565 | |
551 | 566 | return true; |
552 | 567 | }, |
@@ -561,8 +576,9 @@ discard block |
||
561 | 576 | 'enabled' => !empty($modSettings['titlesEnable']), |
562 | 577 | 'input_validate' => function(&$value) use ($smcFunc) |
563 | 578 | { |
564 | - if ($smcFunc['strlen']($value) > 50) |
|
565 | - return 'user_title_too_long'; |
|
579 | + if ($smcFunc['strlen']($value) > 50) { |
|
580 | + return 'user_title_too_long'; |
|
581 | + } |
|
566 | 582 | |
567 | 583 | return true; |
568 | 584 | }, |
@@ -584,10 +600,12 @@ discard block |
||
584 | 600 | // Fix the URL... |
585 | 601 | 'input_validate' => function(&$value) |
586 | 602 | { |
587 | - if (strlen(trim($value)) > 0 && strpos($value, '://') === false) |
|
588 | - $value = 'http://' . $value; |
|
589 | - if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) |
|
590 | - $value = ''; |
|
603 | + if (strlen(trim($value)) > 0 && strpos($value, '://') === false) { |
|
604 | + $value = 'http://' . $value; |
|
605 | + } |
|
606 | + if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) { |
|
607 | + $value = ''; |
|
608 | + } |
|
591 | 609 | return true; |
592 | 610 | }, |
593 | 611 | 'link_with' => 'website', |
@@ -601,16 +619,19 @@ discard block |
||
601 | 619 | foreach ($profile_fields as $key => $field) |
602 | 620 | { |
603 | 621 | // Do we have permission to do this? |
604 | - if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) |
|
605 | - unset($profile_fields[$key]); |
|
622 | + if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) { |
|
623 | + unset($profile_fields[$key]); |
|
624 | + } |
|
606 | 625 | |
607 | 626 | // Is it enabled? |
608 | - if (isset($field['enabled']) && !$field['enabled']) |
|
609 | - unset($profile_fields[$key]); |
|
627 | + if (isset($field['enabled']) && !$field['enabled']) { |
|
628 | + unset($profile_fields[$key]); |
|
629 | + } |
|
610 | 630 | |
611 | 631 | // Is it specifically disabled? |
612 | - if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) |
|
613 | - unset($profile_fields[$key]); |
|
632 | + if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) { |
|
633 | + unset($profile_fields[$key]); |
|
634 | + } |
|
614 | 635 | } |
615 | 636 | } |
616 | 637 | |
@@ -635,9 +656,10 @@ discard block |
||
635 | 656 | loadProfileFields(true); |
636 | 657 | |
637 | 658 | // First check for any linked sets. |
638 | - foreach ($profile_fields as $key => $field) |
|
639 | - if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
659 | + foreach ($profile_fields as $key => $field) { |
|
660 | + if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
640 | 661 | $fields[] = $key; |
662 | + } |
|
641 | 663 | |
642 | 664 | $i = 0; |
643 | 665 | $last_type = ''; |
@@ -649,38 +671,46 @@ discard block |
||
649 | 671 | $cur_field = &$profile_fields[$field]; |
650 | 672 | |
651 | 673 | // Does it have a preload and does that preload succeed? |
652 | - if (isset($cur_field['preload']) && !$cur_field['preload']()) |
|
653 | - continue; |
|
674 | + if (isset($cur_field['preload']) && !$cur_field['preload']()) { |
|
675 | + continue; |
|
676 | + } |
|
654 | 677 | |
655 | 678 | // If this is anything but complex we need to do more cleaning! |
656 | 679 | if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden') |
657 | 680 | { |
658 | - if (!isset($cur_field['label'])) |
|
659 | - $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
681 | + if (!isset($cur_field['label'])) { |
|
682 | + $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
683 | + } |
|
660 | 684 | |
661 | 685 | // Everything has a value! |
662 | - if (!isset($cur_field['value'])) |
|
663 | - $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
686 | + if (!isset($cur_field['value'])) { |
|
687 | + $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
688 | + } |
|
664 | 689 | |
665 | 690 | // Any input attributes? |
666 | 691 | $cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : ''; |
667 | 692 | } |
668 | 693 | |
669 | 694 | // Was there an error with this field on posting? |
670 | - if (isset($context['profile_errors'][$field])) |
|
671 | - $cur_field['is_error'] = true; |
|
695 | + if (isset($context['profile_errors'][$field])) { |
|
696 | + $cur_field['is_error'] = true; |
|
697 | + } |
|
672 | 698 | |
673 | 699 | // Any javascript stuff? |
674 | - if (!empty($cur_field['js_submit'])) |
|
675 | - $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
676 | - if (!empty($cur_field['js'])) |
|
677 | - $context['profile_javascript'] .= $cur_field['js']; |
|
700 | + if (!empty($cur_field['js_submit'])) { |
|
701 | + $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
702 | + } |
|
703 | + if (!empty($cur_field['js'])) { |
|
704 | + $context['profile_javascript'] .= $cur_field['js']; |
|
705 | + } |
|
678 | 706 | |
679 | 707 | // Any template stuff? |
680 | - if (!empty($cur_field['prehtml'])) |
|
681 | - $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
682 | - if (!empty($cur_field['posthtml'])) |
|
683 | - $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
708 | + if (!empty($cur_field['prehtml'])) { |
|
709 | + $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
710 | + } |
|
711 | + if (!empty($cur_field['posthtml'])) { |
|
712 | + $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
713 | + } |
|
684 | 714 | |
685 | 715 | // Finally put it into context? |
686 | 716 | if ($cur_field['type'] != 'hidden') |
@@ -713,12 +743,14 @@ discard block |
||
713 | 743 | }, false);' : ''), true); |
714 | 744 | |
715 | 745 | // Any onsubmit javascript? |
716 | - if (!empty($context['profile_onsubmit_javascript'])) |
|
717 | - addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
746 | + if (!empty($context['profile_onsubmit_javascript'])) { |
|
747 | + addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
748 | + } |
|
718 | 749 | |
719 | 750 | // Any totally custom stuff? |
720 | - if (!empty($context['profile_javascript'])) |
|
721 | - addInlineJavaScript($context['profile_javascript'], true); |
|
751 | + if (!empty($context['profile_javascript'])) { |
|
752 | + addInlineJavaScript($context['profile_javascript'], true); |
|
753 | + } |
|
722 | 754 | |
723 | 755 | // Free up some memory. |
724 | 756 | unset($profile_fields); |
@@ -739,8 +771,9 @@ discard block |
||
739 | 771 | |
740 | 772 | // This allows variables to call activities when they save - by default just to reload their settings |
741 | 773 | $context['profile_execute_on_save'] = array(); |
742 | - if ($context['user']['is_owner']) |
|
743 | - $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
774 | + if ($context['user']['is_owner']) { |
|
775 | + $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
776 | + } |
|
744 | 777 | |
745 | 778 | // Assume we log nothing. |
746 | 779 | $context['log_changes'] = array(); |
@@ -748,8 +781,9 @@ discard block |
||
748 | 781 | // Cycle through the profile fields working out what to do! |
749 | 782 | foreach ($profile_fields as $key => $field) |
750 | 783 | { |
751 | - if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) |
|
752 | - continue; |
|
784 | + if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) { |
|
785 | + continue; |
|
786 | + } |
|
753 | 787 | |
754 | 788 | // What gets updated? |
755 | 789 | $db_key = isset($field['save_key']) ? $field['save_key'] : $key; |
@@ -777,12 +811,13 @@ discard block |
||
777 | 811 | $field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type']; |
778 | 812 | |
779 | 813 | // Finally, clean up certain types. |
780 | - if ($field['cast_type'] == 'int') |
|
781 | - $_POST[$key] = (int) $_POST[$key]; |
|
782 | - elseif ($field['cast_type'] == 'float') |
|
783 | - $_POST[$key] = (float) $_POST[$key]; |
|
784 | - elseif ($field['cast_type'] == 'check') |
|
785 | - $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
814 | + if ($field['cast_type'] == 'int') { |
|
815 | + $_POST[$key] = (int) $_POST[$key]; |
|
816 | + } elseif ($field['cast_type'] == 'float') { |
|
817 | + $_POST[$key] = (float) $_POST[$key]; |
|
818 | + } elseif ($field['cast_type'] == 'check') { |
|
819 | + $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
820 | + } |
|
786 | 821 | |
787 | 822 | // If we got here we're doing OK. |
788 | 823 | if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key])) |
@@ -793,11 +828,12 @@ discard block |
||
793 | 828 | $cur_profile[$key] = $_POST[$key]; |
794 | 829 | |
795 | 830 | // Are we logging it? |
796 | - if (!empty($field['log_change']) && isset($old_profile[$key])) |
|
797 | - $context['log_changes'][$key] = array( |
|
831 | + if (!empty($field['log_change']) && isset($old_profile[$key])) { |
|
832 | + $context['log_changes'][$key] = array( |
|
798 | 833 | 'previous' => $old_profile[$key], |
799 | 834 | 'new' => $_POST[$key], |
800 | 835 | ); |
836 | + } |
|
801 | 837 | } |
802 | 838 | |
803 | 839 | // Logging group changes are a bit different... |
@@ -830,10 +866,11 @@ discard block |
||
830 | 866 | { |
831 | 867 | foreach ($groups as $id => $group) |
832 | 868 | { |
833 | - if (isset($context['member_groups'][$group])) |
|
834 | - $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
835 | - else |
|
836 | - unset($additional_groups[$type][$id]); |
|
869 | + if (isset($context['member_groups'][$group])) { |
|
870 | + $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
871 | + } else { |
|
872 | + unset($additional_groups[$type][$id]); |
|
873 | + } |
|
837 | 874 | } |
838 | 875 | $additional_groups[$type] = implode(', ', $additional_groups[$type]); |
839 | 876 | } |
@@ -844,10 +881,11 @@ discard block |
||
844 | 881 | } |
845 | 882 | |
846 | 883 | // @todo Temporary |
847 | - if ($context['user']['is_owner']) |
|
848 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
849 | - else |
|
850 | - $changeOther = allowedTo('profile_extra_any'); |
|
884 | + if ($context['user']['is_owner']) { |
|
885 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
886 | + } else { |
|
887 | + $changeOther = allowedTo('profile_extra_any'); |
|
888 | + } |
|
851 | 889 | if ($changeOther && empty($post_errors)) |
852 | 890 | { |
853 | 891 | makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
@@ -855,8 +893,9 @@ discard block |
||
855 | 893 | { |
856 | 894 | $custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true); |
857 | 895 | |
858 | - if (!empty($custom_fields_errors)) |
|
859 | - $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
896 | + if (!empty($custom_fields_errors)) { |
|
897 | + $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
898 | + } |
|
860 | 899 | } |
861 | 900 | } |
862 | 901 | |
@@ -882,9 +921,9 @@ discard block |
||
882 | 921 | if ($context['user']['is_owner']) |
883 | 922 | { |
884 | 923 | $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own')); |
924 | + } else { |
|
925 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
885 | 926 | } |
886 | - else |
|
887 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
888 | 927 | |
889 | 928 | // Arrays of all the changes - makes things easier. |
890 | 929 | $profile_bools = array(); |
@@ -895,22 +934,25 @@ discard block |
||
895 | 934 | 'ignore_boards', |
896 | 935 | ); |
897 | 936 | |
898 | - if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) |
|
899 | - $_POST['ignore_brd'] = array(); |
|
937 | + if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) { |
|
938 | + $_POST['ignore_brd'] = array(); |
|
939 | + } |
|
900 | 940 | |
901 | 941 | unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing. Kinda like our minds. |
902 | 942 | if (isset($_POST['ignore_brd'])) |
903 | 943 | { |
904 | - if (!is_array($_POST['ignore_brd'])) |
|
905 | - $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
944 | + if (!is_array($_POST['ignore_brd'])) { |
|
945 | + $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
946 | + } |
|
906 | 947 | |
907 | 948 | foreach ($_POST['ignore_brd'] as $k => $d) |
908 | 949 | { |
909 | 950 | $d = (int) $d; |
910 | - if ($d != 0) |
|
911 | - $_POST['ignore_brd'][$k] = $d; |
|
912 | - else |
|
913 | - unset($_POST['ignore_brd'][$k]); |
|
951 | + if ($d != 0) { |
|
952 | + $_POST['ignore_brd'][$k] = $d; |
|
953 | + } else { |
|
954 | + unset($_POST['ignore_brd'][$k]); |
|
955 | + } |
|
914 | 956 | } |
915 | 957 | $_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']); |
916 | 958 | unset($_POST['ignore_brd']); |
@@ -923,21 +965,26 @@ discard block |
||
923 | 965 | makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
924 | 966 | //makeAvatarChanges($memID, $post_errors); |
925 | 967 | |
926 | - if (!empty($_REQUEST['sa'])) |
|
927 | - makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
968 | + if (!empty($_REQUEST['sa'])) { |
|
969 | + makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
970 | + } |
|
928 | 971 | |
929 | - foreach ($profile_bools as $var) |
|
930 | - if (isset($_POST[$var])) |
|
972 | + foreach ($profile_bools as $var) { |
|
973 | + if (isset($_POST[$var])) |
|
931 | 974 | $profile_vars[$var] = empty($_POST[$var]) ? '0' : '1'; |
932 | - foreach ($profile_ints as $var) |
|
933 | - if (isset($_POST[$var])) |
|
975 | + } |
|
976 | + foreach ($profile_ints as $var) { |
|
977 | + if (isset($_POST[$var])) |
|
934 | 978 | $profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : ''; |
935 | - foreach ($profile_floats as $var) |
|
936 | - if (isset($_POST[$var])) |
|
979 | + } |
|
980 | + foreach ($profile_floats as $var) { |
|
981 | + if (isset($_POST[$var])) |
|
937 | 982 | $profile_vars[$var] = (float) $_POST[$var]; |
938 | - foreach ($profile_strings as $var) |
|
939 | - if (isset($_POST[$var])) |
|
983 | + } |
|
984 | + foreach ($profile_strings as $var) { |
|
985 | + if (isset($_POST[$var])) |
|
940 | 986 | $profile_vars[$var] = $_POST[$var]; |
987 | + } |
|
941 | 988 | } |
942 | 989 | } |
943 | 990 | |
@@ -971,8 +1018,9 @@ discard block |
||
971 | 1018 | ); |
972 | 1019 | |
973 | 1020 | // Can't change reserved vars. |
974 | - if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) |
|
975 | - fatal_lang_error('no_access', false); |
|
1021 | + if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) { |
|
1022 | + fatal_lang_error('no_access', false); |
|
1023 | + } |
|
976 | 1024 | |
977 | 1025 | // Don't allow any overriding of custom fields with default or non-default options. |
978 | 1026 | $request = $smcFunc['db_query']('', ' |
@@ -984,8 +1032,9 @@ discard block |
||
984 | 1032 | ) |
985 | 1033 | ); |
986 | 1034 | $custom_fields = array(); |
987 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
988 | - $custom_fields[] = $row['col_name']; |
|
1035 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1036 | + $custom_fields[] = $row['col_name']; |
|
1037 | + } |
|
989 | 1038 | $smcFunc['db_free_result']($request); |
990 | 1039 | |
991 | 1040 | // These are the theme changes... |
@@ -994,33 +1043,39 @@ discard block |
||
994 | 1043 | { |
995 | 1044 | foreach ($_POST['options'] as $opt => $val) |
996 | 1045 | { |
997 | - if (in_array($opt, $custom_fields)) |
|
998 | - continue; |
|
1046 | + if (in_array($opt, $custom_fields)) { |
|
1047 | + continue; |
|
1048 | + } |
|
999 | 1049 | |
1000 | 1050 | // These need to be controlled. |
1001 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
1002 | - $val = max(0, min($val, 50)); |
|
1051 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
1052 | + $val = max(0, min($val, 50)); |
|
1053 | + } |
|
1003 | 1054 | // We don't set this per theme anymore. |
1004 | - elseif ($opt == 'allow_no_censored') |
|
1005 | - continue; |
|
1055 | + elseif ($opt == 'allow_no_censored') { |
|
1056 | + continue; |
|
1057 | + } |
|
1006 | 1058 | |
1007 | 1059 | $themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val); |
1008 | 1060 | } |
1009 | 1061 | } |
1010 | 1062 | |
1011 | 1063 | $erase_options = array(); |
1012 | - if (isset($_POST['default_options']) && is_array($_POST['default_options'])) |
|
1013 | - foreach ($_POST['default_options'] as $opt => $val) |
|
1064 | + if (isset($_POST['default_options']) && is_array($_POST['default_options'])) { |
|
1065 | + foreach ($_POST['default_options'] as $opt => $val) |
|
1014 | 1066 | { |
1015 | 1067 | if (in_array($opt, $custom_fields)) |
1016 | 1068 | continue; |
1069 | + } |
|
1017 | 1070 | |
1018 | 1071 | // These need to be controlled. |
1019 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
1020 | - $val = max(0, min($val, 50)); |
|
1072 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
1073 | + $val = max(0, min($val, 50)); |
|
1074 | + } |
|
1021 | 1075 | // Only let admins and owners change the censor. |
1022 | - elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) |
|
1023 | - continue; |
|
1076 | + elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) { |
|
1077 | + continue; |
|
1078 | + } |
|
1024 | 1079 | |
1025 | 1080 | $themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
1026 | 1081 | $erase_options[] = $opt; |
@@ -1056,8 +1111,9 @@ discard block |
||
1056 | 1111 | |
1057 | 1112 | // Admins can choose any theme, even if it's not enabled... |
1058 | 1113 | $themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']); |
1059 | - foreach ($themes as $t) |
|
1060 | - cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
1114 | + foreach ($themes as $t) { |
|
1115 | + cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
1116 | + } |
|
1061 | 1117 | } |
1062 | 1118 | } |
1063 | 1119 | |
@@ -1076,8 +1132,9 @@ discard block |
||
1076 | 1132 | if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards'])) |
1077 | 1133 | { |
1078 | 1134 | // Make sure only integers are deleted. |
1079 | - foreach ($_POST['notify_boards'] as $index => $id) |
|
1080 | - $_POST['notify_boards'][$index] = (int) $id; |
|
1135 | + foreach ($_POST['notify_boards'] as $index => $id) { |
|
1136 | + $_POST['notify_boards'][$index] = (int) $id; |
|
1137 | + } |
|
1081 | 1138 | |
1082 | 1139 | // id_board = 0 is reserved for topic notifications. |
1083 | 1140 | $_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0)); |
@@ -1096,8 +1153,9 @@ discard block |
||
1096 | 1153 | // We are editing topic notifications...... |
1097 | 1154 | elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics'])) |
1098 | 1155 | { |
1099 | - foreach ($_POST['notify_topics'] as $index => $id) |
|
1100 | - $_POST['notify_topics'][$index] = (int) $id; |
|
1156 | + foreach ($_POST['notify_topics'] as $index => $id) { |
|
1157 | + $_POST['notify_topics'][$index] = (int) $id; |
|
1158 | + } |
|
1101 | 1159 | |
1102 | 1160 | // Make sure there are no zeros left. |
1103 | 1161 | $_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0)); |
@@ -1111,16 +1169,18 @@ discard block |
||
1111 | 1169 | 'selected_member' => $memID, |
1112 | 1170 | ) |
1113 | 1171 | ); |
1114 | - foreach ($_POST['notify_topics'] as $topic) |
|
1115 | - setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
1172 | + foreach ($_POST['notify_topics'] as $topic) { |
|
1173 | + setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
1174 | + } |
|
1116 | 1175 | } |
1117 | 1176 | |
1118 | 1177 | // We are removing topic preferences |
1119 | 1178 | elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics'])) |
1120 | 1179 | { |
1121 | 1180 | $prefs = array(); |
1122 | - foreach ($_POST['notify_topics'] as $topic) |
|
1123 | - $prefs[] = 'topic_notify_' . $topic; |
|
1181 | + foreach ($_POST['notify_topics'] as $topic) { |
|
1182 | + $prefs[] = 'topic_notify_' . $topic; |
|
1183 | + } |
|
1124 | 1184 | deleteNotifyPrefs($memID, $prefs); |
1125 | 1185 | } |
1126 | 1186 | |
@@ -1128,8 +1188,9 @@ discard block |
||
1128 | 1188 | elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards'])) |
1129 | 1189 | { |
1130 | 1190 | $prefs = array(); |
1131 | - foreach ($_POST['notify_boards'] as $board) |
|
1132 | - $prefs[] = 'board_notify_' . $board; |
|
1191 | + foreach ($_POST['notify_boards'] as $board) { |
|
1192 | + $prefs[] = 'board_notify_' . $board; |
|
1193 | + } |
|
1133 | 1194 | deleteNotifyPrefs($memID, $prefs); |
1134 | 1195 | } |
1135 | 1196 | } |
@@ -1150,8 +1211,9 @@ discard block |
||
1150 | 1211 | |
1151 | 1212 | $errors = array(); |
1152 | 1213 | |
1153 | - if ($sanitize && isset($_POST['customfield'])) |
|
1154 | - $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
1214 | + if ($sanitize && isset($_POST['customfield'])) { |
|
1215 | + $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
1216 | + } |
|
1155 | 1217 | |
1156 | 1218 | $where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}'; |
1157 | 1219 | |
@@ -1176,48 +1238,49 @@ discard block |
||
1176 | 1238 | - The data is not invisible to users but editable by the owner (or if it is the user is not the owner) |
1177 | 1239 | - The area isn't registration, and if it is that the field is not supposed to be shown there. |
1178 | 1240 | */ |
1179 | - if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) |
|
1180 | - continue; |
|
1241 | + if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) { |
|
1242 | + continue; |
|
1243 | + } |
|
1181 | 1244 | |
1182 | 1245 | // Validate the user data. |
1183 | - if ($row['field_type'] == 'check') |
|
1184 | - $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
1185 | - elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
1246 | + if ($row['field_type'] == 'check') { |
|
1247 | + $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
1248 | + } elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
1186 | 1249 | { |
1187 | 1250 | $value = $row['default_value']; |
1188 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
1189 | - if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
1251 | + foreach (explode(',', $row['field_options']) as $k => $v) { |
|
1252 | + if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
1190 | 1253 | $value = $v; |
1254 | + } |
|
1191 | 1255 | } |
1192 | 1256 | // Otherwise some form of text! |
1193 | 1257 | else |
1194 | 1258 | { |
1195 | 1259 | $value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : ''; |
1196 | - if ($row['field_length']) |
|
1197 | - $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
1260 | + if ($row['field_length']) { |
|
1261 | + $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
1262 | + } |
|
1198 | 1263 | |
1199 | 1264 | // Any masks? |
1200 | 1265 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
1201 | 1266 | { |
1202 | 1267 | if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
1203 | 1268 | { |
1204 | - if ($returnErrors) |
|
1205 | - $errors[] = 'custom_field_mail_fail'; |
|
1206 | - |
|
1207 | - else |
|
1208 | - $value = ''; |
|
1209 | - } |
|
1210 | - elseif ($row['mask'] == 'number') |
|
1269 | + if ($returnErrors) { |
|
1270 | + $errors[] = 'custom_field_mail_fail'; |
|
1271 | + } else { |
|
1272 | + $value = ''; |
|
1273 | + } |
|
1274 | + } elseif ($row['mask'] == 'number') |
|
1211 | 1275 | { |
1212 | 1276 | $value = (int) $value; |
1213 | - } |
|
1214 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
1277 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
1215 | 1278 | { |
1216 | - if ($returnErrors) |
|
1217 | - $errors[] = 'custom_field_regex_fail'; |
|
1218 | - |
|
1219 | - else |
|
1220 | - $value = ''; |
|
1279 | + if ($returnErrors) { |
|
1280 | + $errors[] = 'custom_field_regex_fail'; |
|
1281 | + } else { |
|
1282 | + $value = ''; |
|
1283 | + } |
|
1221 | 1284 | } |
1222 | 1285 | } |
1223 | 1286 | } |
@@ -1243,8 +1306,9 @@ discard block |
||
1243 | 1306 | |
1244 | 1307 | $hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize)); |
1245 | 1308 | |
1246 | - if (!empty($hook_errors) && is_array($hook_errors)) |
|
1247 | - $errors = array_merge($errors, $hook_errors); |
|
1309 | + if (!empty($hook_errors) && is_array($hook_errors)) { |
|
1310 | + $errors = array_merge($errors, $hook_errors); |
|
1311 | + } |
|
1248 | 1312 | |
1249 | 1313 | // Make those changes! |
1250 | 1314 | if (!empty($changes) && empty($context['password_auth_failed']) && empty($errors)) |
@@ -1262,9 +1326,10 @@ discard block |
||
1262 | 1326 | } |
1263 | 1327 | } |
1264 | 1328 | |
1265 | - if ($returnErrors) |
|
1266 | - return $errors; |
|
1267 | -} |
|
1329 | + if ($returnErrors) { |
|
1330 | + return $errors; |
|
1331 | + } |
|
1332 | + } |
|
1268 | 1333 | |
1269 | 1334 | /** |
1270 | 1335 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1276,8 +1341,9 @@ discard block |
||
1276 | 1341 | global $context, $txt, $modSettings; |
1277 | 1342 | |
1278 | 1343 | // Do a quick check to ensure people aren't getting here illegally! |
1279 | - if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) |
|
1280 | - fatal_lang_error('no_access', false); |
|
1344 | + if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) { |
|
1345 | + fatal_lang_error('no_access', false); |
|
1346 | + } |
|
1281 | 1347 | |
1282 | 1348 | // Can we email the user direct? |
1283 | 1349 | $context['can_moderate_forum'] = allowedTo('moderate_forum'); |
@@ -1307,9 +1373,10 @@ discard block |
||
1307 | 1373 | $context['sub_template'] = $subActions[$context['list_area']][0]; |
1308 | 1374 | $call = call_helper($subActions[$context['list_area']][0], true); |
1309 | 1375 | |
1310 | - if (!empty($call)) |
|
1311 | - call_user_func($call, $memID); |
|
1312 | -} |
|
1376 | + if (!empty($call)) { |
|
1377 | + call_user_func($call, $memID); |
|
1378 | + } |
|
1379 | + } |
|
1313 | 1380 | |
1314 | 1381 | /** |
1315 | 1382 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1323,9 +1390,10 @@ discard block |
||
1323 | 1390 | |
1324 | 1391 | // For making changes! |
1325 | 1392 | $buddiesArray = explode(',', $user_profile[$memID]['buddy_list']); |
1326 | - foreach ($buddiesArray as $k => $dummy) |
|
1327 | - if ($dummy == '') |
|
1393 | + foreach ($buddiesArray as $k => $dummy) { |
|
1394 | + if ($dummy == '') |
|
1328 | 1395 | unset($buddiesArray[$k]); |
1396 | + } |
|
1329 | 1397 | |
1330 | 1398 | // Removing a buddy? |
1331 | 1399 | if (isset($_GET['remove'])) |
@@ -1337,10 +1405,11 @@ discard block |
||
1337 | 1405 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
1338 | 1406 | |
1339 | 1407 | // Heh, I'm lazy, do it the easy way... |
1340 | - foreach ($buddiesArray as $key => $buddy) |
|
1341 | - if ($buddy == (int) $_GET['remove']) |
|
1408 | + foreach ($buddiesArray as $key => $buddy) { |
|
1409 | + if ($buddy == (int) $_GET['remove']) |
|
1342 | 1410 | { |
1343 | 1411 | unset($buddiesArray[$key]); |
1412 | + } |
|
1344 | 1413 | $_SESSION['prf-save'] = true; |
1345 | 1414 | } |
1346 | 1415 | |
@@ -1350,8 +1419,7 @@ discard block |
||
1350 | 1419 | |
1351 | 1420 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
1352 | 1421 | redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID); |
1353 | - } |
|
1354 | - elseif (isset($_POST['new_buddy'])) |
|
1422 | + } elseif (isset($_POST['new_buddy'])) |
|
1355 | 1423 | { |
1356 | 1424 | checkSession(); |
1357 | 1425 | |
@@ -1364,8 +1432,9 @@ discard block |
||
1364 | 1432 | { |
1365 | 1433 | $new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => ''')); |
1366 | 1434 | |
1367 | - if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
1368 | - unset($new_buddies[$k]); |
|
1435 | + if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
1436 | + unset($new_buddies[$k]); |
|
1437 | + } |
|
1369 | 1438 | } |
1370 | 1439 | |
1371 | 1440 | call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies)); |
@@ -1385,16 +1454,18 @@ discard block |
||
1385 | 1454 | ) |
1386 | 1455 | ); |
1387 | 1456 | |
1388 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1389 | - $_SESSION['prf-save'] = true; |
|
1457 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1458 | + $_SESSION['prf-save'] = true; |
|
1459 | + } |
|
1390 | 1460 | |
1391 | 1461 | // Add the new member to the buddies array. |
1392 | 1462 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1393 | 1463 | { |
1394 | - if (in_array($row['id_member'], $buddiesArray)) |
|
1395 | - continue; |
|
1396 | - else |
|
1397 | - $buddiesArray[] = (int) $row['id_member']; |
|
1464 | + if (in_array($row['id_member'], $buddiesArray)) { |
|
1465 | + continue; |
|
1466 | + } else { |
|
1467 | + $buddiesArray[] = (int) $row['id_member']; |
|
1468 | + } |
|
1398 | 1469 | } |
1399 | 1470 | $smcFunc['db_free_result']($request); |
1400 | 1471 | |
@@ -1424,18 +1495,20 @@ discard block |
||
1424 | 1495 | |
1425 | 1496 | $context['custom_pf'] = array(); |
1426 | 1497 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
1427 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1428 | - if (!isset($disabled_fields[$row['col_name']])) |
|
1498 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1499 | + if (!isset($disabled_fields[$row['col_name']])) |
|
1429 | 1500 | $context['custom_pf'][$row['col_name']] = array( |
1430 | 1501 | 'label' => $row['field_name'], |
1431 | 1502 | 'type' => $row['field_type'], |
1432 | 1503 | 'bbc' => !empty($row['bbc']), |
1433 | 1504 | 'enclose' => $row['enclose'], |
1434 | 1505 | ); |
1506 | + } |
|
1435 | 1507 | |
1436 | 1508 | // Gotta disable the gender option. |
1437 | - if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') |
|
1438 | - unset($context['custom_pf']['cust_gender']); |
|
1509 | + if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') { |
|
1510 | + unset($context['custom_pf']['cust_gender']); |
|
1511 | + } |
|
1439 | 1512 | |
1440 | 1513 | $smcFunc['db_free_result']($request); |
1441 | 1514 | |
@@ -1452,8 +1525,9 @@ discard block |
||
1452 | 1525 | 'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1, |
1453 | 1526 | ) |
1454 | 1527 | ); |
1455 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1456 | - $buddies[] = $row['id_member']; |
|
1528 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1529 | + $buddies[] = $row['id_member']; |
|
1530 | + } |
|
1457 | 1531 | $smcFunc['db_free_result']($result); |
1458 | 1532 | } |
1459 | 1533 | |
@@ -1481,30 +1555,32 @@ discard block |
||
1481 | 1555 | continue; |
1482 | 1556 | } |
1483 | 1557 | |
1484 | - if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) |
|
1485 | - $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
1486 | - |
|
1487 | - elseif ($column['type'] == 'check') |
|
1488 | - $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
1558 | + if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
1559 | + $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
1560 | + } elseif ($column['type'] == 'check') { |
|
1561 | + $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
1562 | + } |
|
1489 | 1563 | |
1490 | 1564 | // Enclosing the user input within some other text? |
1491 | - if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) |
|
1492 | - $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
1565 | + if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
1566 | + $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
1493 | 1567 | '{SCRIPTURL}' => $scripturl, |
1494 | 1568 | '{IMAGES_URL}' => $settings['images_url'], |
1495 | 1569 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1496 | 1570 | '{INPUT}' => $context['buddies'][$buddy]['options'][$key], |
1497 | 1571 | )); |
1572 | + } |
|
1498 | 1573 | } |
1499 | 1574 | } |
1500 | 1575 | } |
1501 | 1576 | |
1502 | 1577 | if (isset($_SESSION['prf-save'])) |
1503 | 1578 | { |
1504 | - if ($_SESSION['prf-save'] === true) |
|
1505 | - $context['saved_successful'] = true; |
|
1506 | - else |
|
1507 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
1579 | + if ($_SESSION['prf-save'] === true) { |
|
1580 | + $context['saved_successful'] = true; |
|
1581 | + } else { |
|
1582 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
1583 | + } |
|
1508 | 1584 | |
1509 | 1585 | unset($_SESSION['prf-save']); |
1510 | 1586 | } |
@@ -1524,9 +1600,10 @@ discard block |
||
1524 | 1600 | |
1525 | 1601 | // For making changes! |
1526 | 1602 | $ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']); |
1527 | - foreach ($ignoreArray as $k => $dummy) |
|
1528 | - if ($dummy == '') |
|
1603 | + foreach ($ignoreArray as $k => $dummy) { |
|
1604 | + if ($dummy == '') |
|
1529 | 1605 | unset($ignoreArray[$k]); |
1606 | + } |
|
1530 | 1607 | |
1531 | 1608 | // Removing a member from the ignore list? |
1532 | 1609 | if (isset($_GET['remove'])) |
@@ -1536,10 +1613,11 @@ discard block |
||
1536 | 1613 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
1537 | 1614 | |
1538 | 1615 | // Heh, I'm lazy, do it the easy way... |
1539 | - foreach ($ignoreArray as $key => $id_remove) |
|
1540 | - if ($id_remove == (int) $_GET['remove']) |
|
1616 | + foreach ($ignoreArray as $key => $id_remove) { |
|
1617 | + if ($id_remove == (int) $_GET['remove']) |
|
1541 | 1618 | { |
1542 | 1619 | unset($ignoreArray[$key]); |
1620 | + } |
|
1543 | 1621 | $_SESSION['prf-save'] = true; |
1544 | 1622 | } |
1545 | 1623 | |
@@ -1549,8 +1627,7 @@ discard block |
||
1549 | 1627 | |
1550 | 1628 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
1551 | 1629 | redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID); |
1552 | - } |
|
1553 | - elseif (isset($_POST['new_ignore'])) |
|
1630 | + } elseif (isset($_POST['new_ignore'])) |
|
1554 | 1631 | { |
1555 | 1632 | checkSession(); |
1556 | 1633 | // Prepare the string for extraction... |
@@ -1562,8 +1639,9 @@ discard block |
||
1562 | 1639 | { |
1563 | 1640 | $new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => ''')); |
1564 | 1641 | |
1565 | - if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
1566 | - unset($new_entries[$k]); |
|
1642 | + if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
1643 | + unset($new_entries[$k]); |
|
1644 | + } |
|
1567 | 1645 | } |
1568 | 1646 | |
1569 | 1647 | $_SESSION['prf-save'] = $txt['could_not_add_person']; |
@@ -1581,16 +1659,18 @@ discard block |
||
1581 | 1659 | ) |
1582 | 1660 | ); |
1583 | 1661 | |
1584 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1585 | - $_SESSION['prf-save'] = true; |
|
1662 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1663 | + $_SESSION['prf-save'] = true; |
|
1664 | + } |
|
1586 | 1665 | |
1587 | 1666 | // Add the new member to the buddies array. |
1588 | 1667 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1589 | 1668 | { |
1590 | - if (in_array($row['id_member'], $ignoreArray)) |
|
1591 | - continue; |
|
1592 | - else |
|
1593 | - $ignoreArray[] = (int) $row['id_member']; |
|
1669 | + if (in_array($row['id_member'], $ignoreArray)) { |
|
1670 | + continue; |
|
1671 | + } else { |
|
1672 | + $ignoreArray[] = (int) $row['id_member']; |
|
1673 | + } |
|
1594 | 1674 | } |
1595 | 1675 | $smcFunc['db_free_result']($request); |
1596 | 1676 | |
@@ -1619,8 +1699,9 @@ discard block |
||
1619 | 1699 | 'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1, |
1620 | 1700 | ) |
1621 | 1701 | ); |
1622 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1623 | - $ignored[] = $row['id_member']; |
|
1702 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1703 | + $ignored[] = $row['id_member']; |
|
1704 | + } |
|
1624 | 1705 | $smcFunc['db_free_result']($result); |
1625 | 1706 | } |
1626 | 1707 | |
@@ -1639,10 +1720,11 @@ discard block |
||
1639 | 1720 | |
1640 | 1721 | if (isset($_SESSION['prf-save'])) |
1641 | 1722 | { |
1642 | - if ($_SESSION['prf-save'] === true) |
|
1643 | - $context['saved_successful'] = true; |
|
1644 | - else |
|
1645 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
1723 | + if ($_SESSION['prf-save'] === true) { |
|
1724 | + $context['saved_successful'] = true; |
|
1725 | + } else { |
|
1726 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
1727 | + } |
|
1646 | 1728 | |
1647 | 1729 | unset($_SESSION['prf-save']); |
1648 | 1730 | } |
@@ -1658,8 +1740,9 @@ discard block |
||
1658 | 1740 | global $context, $txt; |
1659 | 1741 | |
1660 | 1742 | loadThemeOptions($memID); |
1661 | - if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) |
|
1662 | - loadCustomFields($memID, 'account'); |
|
1743 | + if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) { |
|
1744 | + loadCustomFields($memID, 'account'); |
|
1745 | + } |
|
1663 | 1746 | |
1664 | 1747 | $context['sub_template'] = 'edit_options'; |
1665 | 1748 | $context['page_desc'] = $txt['account_info']; |
@@ -1686,8 +1769,9 @@ discard block |
||
1686 | 1769 | global $context, $txt; |
1687 | 1770 | |
1688 | 1771 | loadThemeOptions($memID); |
1689 | - if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) |
|
1690 | - loadCustomFields($memID, 'forumprofile'); |
|
1772 | + if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) { |
|
1773 | + loadCustomFields($memID, 'forumprofile'); |
|
1774 | + } |
|
1691 | 1775 | |
1692 | 1776 | $context['sub_template'] = 'edit_options'; |
1693 | 1777 | $context['page_desc'] = $txt['forumProfile_info']; |
@@ -1720,18 +1804,21 @@ discard block |
||
1720 | 1804 | $dirs = array(); |
1721 | 1805 | $files = array(); |
1722 | 1806 | |
1723 | - if (!$dir) |
|
1724 | - return array(); |
|
1807 | + if (!$dir) { |
|
1808 | + return array(); |
|
1809 | + } |
|
1725 | 1810 | |
1726 | 1811 | while ($line = $dir->read()) |
1727 | 1812 | { |
1728 | - if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) |
|
1729 | - continue; |
|
1813 | + if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) { |
|
1814 | + continue; |
|
1815 | + } |
|
1730 | 1816 | |
1731 | - if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) |
|
1732 | - $dirs[] = $line; |
|
1733 | - else |
|
1734 | - $files[] = $line; |
|
1817 | + if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) { |
|
1818 | + $dirs[] = $line; |
|
1819 | + } else { |
|
1820 | + $files[] = $line; |
|
1821 | + } |
|
1735 | 1822 | } |
1736 | 1823 | $dir->close(); |
1737 | 1824 | |
@@ -1752,14 +1839,15 @@ discard block |
||
1752 | 1839 | foreach ($dirs as $line) |
1753 | 1840 | { |
1754 | 1841 | $tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1); |
1755 | - if (!empty($tmp)) |
|
1756 | - $result[] = array( |
|
1842 | + if (!empty($tmp)) { |
|
1843 | + $result[] = array( |
|
1757 | 1844 | 'filename' => $smcFunc['htmlspecialchars']($line), |
1758 | 1845 | 'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false, |
1759 | 1846 | 'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']', |
1760 | 1847 | 'is_dir' => true, |
1761 | 1848 | 'files' => $tmp |
1762 | 1849 | ); |
1850 | + } |
|
1763 | 1851 | unset($tmp); |
1764 | 1852 | } |
1765 | 1853 | |
@@ -1769,8 +1857,9 @@ discard block |
||
1769 | 1857 | $extension = substr(strrchr($line, '.'), 1); |
1770 | 1858 | |
1771 | 1859 | // Make sure it is an image. |
1772 | - if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) |
|
1773 | - continue; |
|
1860 | + if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) { |
|
1861 | + continue; |
|
1862 | + } |
|
1774 | 1863 | |
1775 | 1864 | $result[] = array( |
1776 | 1865 | 'filename' => $smcFunc['htmlspecialchars']($line), |
@@ -1778,8 +1867,9 @@ discard block |
||
1778 | 1867 | 'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)), |
1779 | 1868 | 'is_dir' => false |
1780 | 1869 | ); |
1781 | - if ($level == 1) |
|
1782 | - $context['avatar_list'][] = $directory . '/' . $line; |
|
1870 | + if ($level == 1) { |
|
1871 | + $context['avatar_list'][] = $directory . '/' . $line; |
|
1872 | + } |
|
1783 | 1873 | } |
1784 | 1874 | |
1785 | 1875 | return $result; |
@@ -1795,8 +1885,9 @@ discard block |
||
1795 | 1885 | global $txt, $context; |
1796 | 1886 | |
1797 | 1887 | loadThemeOptions($memID); |
1798 | - if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) |
|
1799 | - loadCustomFields($memID, 'theme'); |
|
1888 | + if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { |
|
1889 | + loadCustomFields($memID, 'theme'); |
|
1890 | + } |
|
1800 | 1891 | |
1801 | 1892 | $context['sub_template'] = 'edit_options'; |
1802 | 1893 | $context['page_desc'] = $txt['theme_info']; |
@@ -1850,16 +1941,19 @@ discard block |
||
1850 | 1941 | { |
1851 | 1942 | global $txt, $user_profile, $context, $modSettings, $smcFunc, $sourcedir; |
1852 | 1943 | |
1853 | - if (!isset($context['token_check'])) |
|
1854 | - $context['token_check'] = 'profile-nt' . $memID; |
|
1944 | + if (!isset($context['token_check'])) { |
|
1945 | + $context['token_check'] = 'profile-nt' . $memID; |
|
1946 | + } |
|
1855 | 1947 | |
1856 | 1948 | is_not_guest(); |
1857 | - if (!$context['user']['is_owner']) |
|
1858 | - isAllowedTo('profile_extra_any'); |
|
1949 | + if (!$context['user']['is_owner']) { |
|
1950 | + isAllowedTo('profile_extra_any'); |
|
1951 | + } |
|
1859 | 1952 | |
1860 | 1953 | // Set the post action if we're coming from the profile... |
1861 | - if (!isset($context['action'])) |
|
1862 | - $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
1954 | + if (!isset($context['action'])) { |
|
1955 | + $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
1956 | + } |
|
1863 | 1957 | |
1864 | 1958 | // What options are set |
1865 | 1959 | loadThemeOptions($memID); |
@@ -1946,28 +2040,34 @@ discard block |
||
1946 | 2040 | ); |
1947 | 2041 | |
1948 | 2042 | // There are certain things that are disabled at the group level. |
1949 | - if (empty($modSettings['cal_enabled'])) |
|
1950 | - unset($alert_types['calendar']); |
|
2043 | + if (empty($modSettings['cal_enabled'])) { |
|
2044 | + unset($alert_types['calendar']); |
|
2045 | + } |
|
1951 | 2046 | |
1952 | 2047 | // Disable paid subscriptions at group level if they're disabled |
1953 | - if (empty($modSettings['paid_enabled'])) |
|
1954 | - unset($alert_types['paidsubs']); |
|
2048 | + if (empty($modSettings['paid_enabled'])) { |
|
2049 | + unset($alert_types['paidsubs']); |
|
2050 | + } |
|
1955 | 2051 | |
1956 | 2052 | // Disable membergroup requests at group level if they're disabled |
1957 | - if (empty($modSettings['show_group_membership'])) |
|
1958 | - unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
2053 | + if (empty($modSettings['show_group_membership'])) { |
|
2054 | + unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
2055 | + } |
|
1959 | 2056 | |
1960 | 2057 | // Disable mentions if they're disabled |
1961 | - if (empty($modSettings['enable_mentions'])) |
|
1962 | - unset($alert_types['msg']['msg_mention']); |
|
2058 | + if (empty($modSettings['enable_mentions'])) { |
|
2059 | + unset($alert_types['msg']['msg_mention']); |
|
2060 | + } |
|
1963 | 2061 | |
1964 | 2062 | // Disable likes if they're disabled |
1965 | - if (empty($modSettings['enable_likes'])) |
|
1966 | - unset($alert_types['msg']['msg_like']); |
|
2063 | + if (empty($modSettings['enable_likes'])) { |
|
2064 | + unset($alert_types['msg']['msg_like']); |
|
2065 | + } |
|
1967 | 2066 | |
1968 | 2067 | // Disable buddy requests if they're disabled |
1969 | - if (empty($modSettings['enable_buddylist'])) |
|
1970 | - unset($alert_types['members']['buddy_request']); |
|
2068 | + if (empty($modSettings['enable_buddylist'])) { |
|
2069 | + unset($alert_types['members']['buddy_request']); |
|
2070 | + } |
|
1971 | 2071 | |
1972 | 2072 | // Now, now, we could pass this through global but we should really get into the habit of |
1973 | 2073 | // passing content to hooks, not expecting hooks to splatter everything everywhere. |
@@ -1995,15 +2095,17 @@ discard block |
||
1995 | 2095 | $perms_cache['manage_membergroups'] = in_array($memID, $members); |
1996 | 2096 | } |
1997 | 2097 | |
1998 | - if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) |
|
1999 | - unset($alert_types['members']['request_group']); |
|
2098 | + if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) { |
|
2099 | + unset($alert_types['members']['request_group']); |
|
2100 | + } |
|
2000 | 2101 | |
2001 | 2102 | foreach ($alert_types as $group => $items) |
2002 | 2103 | { |
2003 | 2104 | foreach ($items as $alert_key => $alert_value) |
2004 | 2105 | { |
2005 | - if (!isset($alert_value['permission'])) |
|
2006 | - continue; |
|
2106 | + if (!isset($alert_value['permission'])) { |
|
2107 | + continue; |
|
2108 | + } |
|
2007 | 2109 | if (!isset($perms_cache[$alert_value['permission']['name']])) |
2008 | 2110 | { |
2009 | 2111 | $in_board = !empty($alert_value['permission']['is_board']) ? 0 : null; |
@@ -2011,12 +2113,14 @@ discard block |
||
2011 | 2113 | $perms_cache[$alert_value['permission']['name']] = in_array($memID, $members); |
2012 | 2114 | } |
2013 | 2115 | |
2014 | - if (!$perms_cache[$alert_value['permission']['name']]) |
|
2015 | - unset ($alert_types[$group][$alert_key]); |
|
2116 | + if (!$perms_cache[$alert_value['permission']['name']]) { |
|
2117 | + unset ($alert_types[$group][$alert_key]); |
|
2118 | + } |
|
2016 | 2119 | } |
2017 | 2120 | |
2018 | - if (empty($alert_types[$group])) |
|
2019 | - unset ($alert_types[$group]); |
|
2121 | + if (empty($alert_types[$group])) { |
|
2122 | + unset ($alert_types[$group]); |
|
2123 | + } |
|
2020 | 2124 | } |
2021 | 2125 | } |
2022 | 2126 | |
@@ -2048,9 +2152,9 @@ discard block |
||
2048 | 2152 | $update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0; |
2049 | 2153 | break; |
2050 | 2154 | case 'select': |
2051 | - if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) |
|
2052 | - $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
2053 | - else |
|
2155 | + if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) { |
|
2156 | + $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
2157 | + } else |
|
2054 | 2158 | { |
2055 | 2159 | // We didn't have a sane value. Let's grab the first item from the possibles. |
2056 | 2160 | $keys = array_keys($this_option['opts']); |
@@ -2070,23 +2174,28 @@ discard block |
||
2070 | 2174 | $this_value = 0; |
2071 | 2175 | foreach ($context['alert_bits'] as $type => $bitvalue) |
2072 | 2176 | { |
2073 | - if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') |
|
2074 | - $this_value |= $bitvalue; |
|
2177 | + if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') { |
|
2178 | + $this_value |= $bitvalue; |
|
2179 | + } |
|
2180 | + } |
|
2181 | + if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) { |
|
2182 | + $update_prefs[$item_key] = $this_value; |
|
2075 | 2183 | } |
2076 | - if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) |
|
2077 | - $update_prefs[$item_key] = $this_value; |
|
2078 | 2184 | } |
2079 | 2185 | } |
2080 | 2186 | |
2081 | - if (!empty($_POST['opt_alert_timeout'])) |
|
2082 | - $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
2187 | + if (!empty($_POST['opt_alert_timeout'])) { |
|
2188 | + $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
2189 | + } |
|
2083 | 2190 | |
2084 | - if (!empty($_POST['notify_announcements'])) |
|
2085 | - $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
2191 | + if (!empty($_POST['notify_announcements'])) { |
|
2192 | + $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
2193 | + } |
|
2086 | 2194 | |
2087 | 2195 | setNotifyPrefs((int) $memID, $update_prefs); |
2088 | - foreach ($update_prefs as $pref => $value) |
|
2089 | - $context['alert_prefs'][$pref] = $value; |
|
2196 | + foreach ($update_prefs as $pref => $value) { |
|
2197 | + $context['alert_prefs'][$pref] = $value; |
|
2198 | + } |
|
2090 | 2199 | |
2091 | 2200 | makeNotificationChanges($memID); |
2092 | 2201 | |
@@ -2116,8 +2225,9 @@ discard block |
||
2116 | 2225 | |
2117 | 2226 | // Now we're all set up. |
2118 | 2227 | is_not_guest(); |
2119 | - if (!$context['user']['is_owner']) |
|
2120 | - fatal_error('no_access'); |
|
2228 | + if (!$context['user']['is_owner']) { |
|
2229 | + fatal_error('no_access'); |
|
2230 | + } |
|
2121 | 2231 | |
2122 | 2232 | checkSession('get'); |
2123 | 2233 | |
@@ -2149,8 +2259,9 @@ discard block |
||
2149 | 2259 | { |
2150 | 2260 | global $smcFunc; |
2151 | 2261 | |
2152 | - if (empty($toMark) || empty($memID)) |
|
2153 | - return false; |
|
2262 | + if (empty($toMark) || empty($memID)) { |
|
2263 | + return false; |
|
2264 | + } |
|
2154 | 2265 | |
2155 | 2266 | $toMark = (array) $toMark; |
2156 | 2267 | |
@@ -2184,8 +2295,9 @@ discard block |
||
2184 | 2295 | { |
2185 | 2296 | global $smcFunc; |
2186 | 2297 | |
2187 | - if (empty($toDelete)) |
|
2188 | - return false; |
|
2298 | + if (empty($toDelete)) { |
|
2299 | + return false; |
|
2300 | + } |
|
2189 | 2301 | |
2190 | 2302 | $toDelete = (array) $toDelete; |
2191 | 2303 | |
@@ -2220,8 +2332,9 @@ discard block |
||
2220 | 2332 | { |
2221 | 2333 | global $smcFunc; |
2222 | 2334 | |
2223 | - if (empty($memID)) |
|
2224 | - return false; |
|
2335 | + if (empty($memID)) { |
|
2336 | + return false; |
|
2337 | + } |
|
2225 | 2338 | |
2226 | 2339 | $request = $smcFunc['db_query']('', ' |
2227 | 2340 | SELECT id_alert |
@@ -2298,8 +2411,9 @@ discard block |
||
2298 | 2411 | { |
2299 | 2412 | $link = $topic['link']; |
2300 | 2413 | |
2301 | - if ($topic['new']) |
|
2302 | - $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2414 | + if ($topic['new']) { |
|
2415 | + $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2416 | + } |
|
2303 | 2417 | |
2304 | 2418 | $link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>'; |
2305 | 2419 | |
@@ -2450,8 +2564,9 @@ discard block |
||
2450 | 2564 | { |
2451 | 2565 | $link = $board['link']; |
2452 | 2566 | |
2453 | - if ($board['new']) |
|
2454 | - $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2567 | + if ($board['new']) { |
|
2568 | + $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2569 | + } |
|
2455 | 2570 | |
2456 | 2571 | return $link; |
2457 | 2572 | }, |
@@ -2651,8 +2766,8 @@ discard block |
||
2651 | 2766 | ) |
2652 | 2767 | ); |
2653 | 2768 | $notification_boards = array(); |
2654 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2655 | - $notification_boards[] = array( |
|
2769 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2770 | + $notification_boards[] = array( |
|
2656 | 2771 | 'id' => $row['id_board'], |
2657 | 2772 | 'name' => $row['name'], |
2658 | 2773 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
@@ -2660,6 +2775,7 @@ discard block |
||
2660 | 2775 | 'new' => $row['board_read'] < $row['id_msg_updated'], |
2661 | 2776 | 'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0), |
2662 | 2777 | ); |
2778 | + } |
|
2663 | 2779 | $smcFunc['db_free_result']($request); |
2664 | 2780 | |
2665 | 2781 | return $notification_boards; |
@@ -2674,17 +2790,18 @@ discard block |
||
2674 | 2790 | { |
2675 | 2791 | global $context, $options, $cur_profile, $smcFunc; |
2676 | 2792 | |
2677 | - if (isset($_POST['default_options'])) |
|
2678 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
2793 | + if (isset($_POST['default_options'])) { |
|
2794 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
2795 | + } |
|
2679 | 2796 | |
2680 | 2797 | if ($context['user']['is_owner']) |
2681 | 2798 | { |
2682 | 2799 | $context['member']['options'] = $options; |
2683 | - if (isset($_POST['options']) && is_array($_POST['options'])) |
|
2684 | - foreach ($_POST['options'] as $k => $v) |
|
2800 | + if (isset($_POST['options']) && is_array($_POST['options'])) { |
|
2801 | + foreach ($_POST['options'] as $k => $v) |
|
2685 | 2802 | $context['member']['options'][$k] = $v; |
2686 | - } |
|
2687 | - else |
|
2803 | + } |
|
2804 | + } else |
|
2688 | 2805 | { |
2689 | 2806 | $request = $smcFunc['db_query']('', ' |
2690 | 2807 | SELECT id_member, variable, value |
@@ -2705,8 +2822,9 @@ discard block |
||
2705 | 2822 | continue; |
2706 | 2823 | } |
2707 | 2824 | |
2708 | - if (isset($_POST['options'][$row['variable']])) |
|
2709 | - $row['value'] = $_POST['options'][$row['variable']]; |
|
2825 | + if (isset($_POST['options'][$row['variable']])) { |
|
2826 | + $row['value'] = $_POST['options'][$row['variable']]; |
|
2827 | + } |
|
2710 | 2828 | $context['member']['options'][$row['variable']] = $row['value']; |
2711 | 2829 | } |
2712 | 2830 | $smcFunc['db_free_result']($request); |
@@ -2714,8 +2832,9 @@ discard block |
||
2714 | 2832 | // Load up the default theme options for any missing. |
2715 | 2833 | foreach ($temp as $k => $v) |
2716 | 2834 | { |
2717 | - if (!isset($context['member']['options'][$k])) |
|
2718 | - $context['member']['options'][$k] = $v; |
|
2835 | + if (!isset($context['member']['options'][$k])) { |
|
2836 | + $context['member']['options'][$k] = $v; |
|
2837 | + } |
|
2719 | 2838 | } |
2720 | 2839 | } |
2721 | 2840 | } |
@@ -2730,8 +2849,9 @@ discard block |
||
2730 | 2849 | global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir; |
2731 | 2850 | |
2732 | 2851 | // Have the admins enabled this option? |
2733 | - if (empty($modSettings['allow_ignore_boards'])) |
|
2734 | - fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
2852 | + if (empty($modSettings['allow_ignore_boards'])) { |
|
2853 | + fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
2854 | + } |
|
2735 | 2855 | |
2736 | 2856 | // Find all the boards this user is allowed to see. |
2737 | 2857 | $request = $smcFunc['db_query']('order_by_board_order', ' |
@@ -2751,12 +2871,13 @@ discard block |
||
2751 | 2871 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2752 | 2872 | { |
2753 | 2873 | // This category hasn't been set up yet.. |
2754 | - if (!isset($context['categories'][$row['id_cat']])) |
|
2755 | - $context['categories'][$row['id_cat']] = array( |
|
2874 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
2875 | + $context['categories'][$row['id_cat']] = array( |
|
2756 | 2876 | 'id' => $row['id_cat'], |
2757 | 2877 | 'name' => $row['cat_name'], |
2758 | 2878 | 'boards' => array() |
2759 | 2879 | ); |
2880 | + } |
|
2760 | 2881 | |
2761 | 2882 | // Set this board up, and let the template know when it's a child. (indent them..) |
2762 | 2883 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -2786,18 +2907,20 @@ discard block |
||
2786 | 2907 | } |
2787 | 2908 | |
2788 | 2909 | $max_boards = ceil(count($temp_boards) / 2); |
2789 | - if ($max_boards == 1) |
|
2790 | - $max_boards = 2; |
|
2910 | + if ($max_boards == 1) { |
|
2911 | + $max_boards = 2; |
|
2912 | + } |
|
2791 | 2913 | |
2792 | 2914 | // Now, alternate them so they can be shown left and right ;). |
2793 | 2915 | $context['board_columns'] = array(); |
2794 | 2916 | for ($i = 0; $i < $max_boards; $i++) |
2795 | 2917 | { |
2796 | 2918 | $context['board_columns'][] = $temp_boards[$i]; |
2797 | - if (isset($temp_boards[$i + $max_boards])) |
|
2798 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
2799 | - else |
|
2800 | - $context['board_columns'][] = array(); |
|
2919 | + if (isset($temp_boards[$i + $max_boards])) { |
|
2920 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
2921 | + } else { |
|
2922 | + $context['board_columns'][] = array(); |
|
2923 | + } |
|
2801 | 2924 | } |
2802 | 2925 | |
2803 | 2926 | loadThemeOptions($memID); |
@@ -2866,8 +2989,9 @@ discard block |
||
2866 | 2989 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2867 | 2990 | { |
2868 | 2991 | // We should skip the administrator group if they don't have the admin_forum permission! |
2869 | - if ($row['id_group'] == 1 && !allowedTo('admin_forum')) |
|
2870 | - continue; |
|
2992 | + if ($row['id_group'] == 1 && !allowedTo('admin_forum')) { |
|
2993 | + continue; |
|
2994 | + } |
|
2871 | 2995 | |
2872 | 2996 | $context['member_groups'][$row['id_group']] = array( |
2873 | 2997 | 'id' => $row['id_group'], |
@@ -2913,16 +3037,17 @@ discard block |
||
2913 | 3037 | $context['max_signature_length'] = $context['signature_limits']['max_length']; |
2914 | 3038 | // Warning message for signature image limits? |
2915 | 3039 | $context['signature_warning'] = ''; |
2916 | - if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) |
|
2917 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
2918 | - elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) |
|
2919 | - $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']); |
|
3040 | + if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) { |
|
3041 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
3042 | + } elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) { |
|
3043 | + $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']); |
|
3044 | + } |
|
2920 | 3045 | |
2921 | 3046 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
2922 | 3047 | |
2923 | - if (empty($context['do_preview'])) |
|
2924 | - $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
2925 | - else |
|
3048 | + if (empty($context['do_preview'])) { |
|
3049 | + $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
3050 | + } else |
|
2926 | 3051 | { |
2927 | 3052 | $signature = !empty($_POST['signature']) ? $_POST['signature'] : ''; |
2928 | 3053 | $validation = profileValidateSignature($signature); |
@@ -2932,8 +3057,9 @@ discard block |
||
2932 | 3057 | $context['post_errors'] = array(); |
2933 | 3058 | } |
2934 | 3059 | $context['post_errors'][] = 'signature_not_yet_saved'; |
2935 | - if ($validation !== true && $validation !== false) |
|
2936 | - $context['post_errors'][] = $validation; |
|
3060 | + if ($validation !== true && $validation !== false) { |
|
3061 | + $context['post_errors'][] = $validation; |
|
3062 | + } |
|
2937 | 3063 | |
2938 | 3064 | censorText($context['member']['signature']); |
2939 | 3065 | $context['member']['current_signature'] = $context['member']['signature']; |
@@ -2943,8 +3069,9 @@ discard block |
||
2943 | 3069 | } |
2944 | 3070 | |
2945 | 3071 | // Load the spell checker? |
2946 | - if ($context['show_spellchecking']) |
|
2947 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
3072 | + if ($context['show_spellchecking']) { |
|
3073 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
3074 | + } |
|
2948 | 3075 | |
2949 | 3076 | return true; |
2950 | 3077 | } |
@@ -2978,8 +3105,7 @@ discard block |
||
2978 | 3105 | 'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11) |
2979 | 3106 | ); |
2980 | 3107 | $context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']); |
2981 | - } |
|
2982 | - elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
3108 | + } elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
2983 | 3109 | { |
2984 | 3110 | $context['member']['avatar'] += array( |
2985 | 3111 | 'choice' => 'upload', |
@@ -2987,34 +3113,34 @@ discard block |
||
2987 | 3113 | 'external' => 'http://' |
2988 | 3114 | ); |
2989 | 3115 | $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']; |
2990 | - } |
|
2991 | - elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) |
|
2992 | - $context['member']['avatar'] += array( |
|
3116 | + } elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) { |
|
3117 | + $context['member']['avatar'] += array( |
|
2993 | 3118 | 'choice' => 'external', |
2994 | 3119 | 'server_pic' => 'blank.png', |
2995 | 3120 | 'external' => $cur_profile['avatar'] |
2996 | 3121 | ); |
2997 | - elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) |
|
2998 | - $context['member']['avatar'] += array( |
|
3122 | + } elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) { |
|
3123 | + $context['member']['avatar'] += array( |
|
2999 | 3124 | 'choice' => 'server_stored', |
3000 | 3125 | 'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'], |
3001 | 3126 | 'external' => 'http://' |
3002 | 3127 | ); |
3003 | - else |
|
3004 | - $context['member']['avatar'] += array( |
|
3128 | + } else { |
|
3129 | + $context['member']['avatar'] += array( |
|
3005 | 3130 | 'choice' => 'none', |
3006 | 3131 | 'server_pic' => 'blank.png', |
3007 | 3132 | 'external' => 'http://' |
3008 | 3133 | ); |
3134 | + } |
|
3009 | 3135 | |
3010 | 3136 | // Get a list of all the avatars. |
3011 | 3137 | if ($context['member']['avatar']['allow_server_stored']) |
3012 | 3138 | { |
3013 | 3139 | $context['avatar_list'] = array(); |
3014 | 3140 | $context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array(); |
3141 | + } else { |
|
3142 | + $context['avatars'] = array(); |
|
3015 | 3143 | } |
3016 | - else |
|
3017 | - $context['avatars'] = array(); |
|
3018 | 3144 | |
3019 | 3145 | // Second level selected avatar... |
3020 | 3146 | $context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1); |
@@ -3043,19 +3169,22 @@ discard block |
||
3043 | 3169 | ) |
3044 | 3170 | ); |
3045 | 3171 | $protected_groups = array(1); |
3046 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3047 | - $protected_groups[] = $row['id_group']; |
|
3172 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3173 | + $protected_groups[] = $row['id_group']; |
|
3174 | + } |
|
3048 | 3175 | $smcFunc['db_free_result']($request); |
3049 | 3176 | |
3050 | 3177 | $protected_groups = array_unique($protected_groups); |
3051 | 3178 | } |
3052 | 3179 | |
3053 | 3180 | // The account page allows the change of your id_group - but not to a protected group! |
3054 | - if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) |
|
3055 | - $value = (int) $value; |
|
3181 | + if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) { |
|
3182 | + $value = (int) $value; |
|
3183 | + } |
|
3056 | 3184 | // ... otherwise it's the old group sir. |
3057 | - else |
|
3058 | - $value = $old_profile['id_group']; |
|
3185 | + else { |
|
3186 | + $value = $old_profile['id_group']; |
|
3187 | + } |
|
3059 | 3188 | |
3060 | 3189 | // Find the additional membergroups (if any) |
3061 | 3190 | if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups'])) |
@@ -3064,16 +3193,18 @@ discard block |
||
3064 | 3193 | foreach ($_POST['additional_groups'] as $group_id) |
3065 | 3194 | { |
3066 | 3195 | $group_id = (int) $group_id; |
3067 | - if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) |
|
3068 | - $additional_groups[] = $group_id; |
|
3196 | + if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) { |
|
3197 | + $additional_groups[] = $group_id; |
|
3198 | + } |
|
3069 | 3199 | } |
3070 | 3200 | |
3071 | 3201 | // Put the protected groups back in there if you don't have permission to take them away. |
3072 | 3202 | $old_additional_groups = explode(',', $old_profile['additional_groups']); |
3073 | 3203 | foreach ($old_additional_groups as $group_id) |
3074 | 3204 | { |
3075 | - if (!empty($protected_groups) && in_array($group_id, $protected_groups)) |
|
3076 | - $additional_groups[] = $group_id; |
|
3205 | + if (!empty($protected_groups) && in_array($group_id, $protected_groups)) { |
|
3206 | + $additional_groups[] = $group_id; |
|
3207 | + } |
|
3077 | 3208 | } |
3078 | 3209 | |
3079 | 3210 | if (implode(',', $additional_groups) !== $old_profile['additional_groups']) |
@@ -3105,18 +3236,20 @@ discard block |
||
3105 | 3236 | list ($another) = $smcFunc['db_fetch_row']($request); |
3106 | 3237 | $smcFunc['db_free_result']($request); |
3107 | 3238 | |
3108 | - if (empty($another)) |
|
3109 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
3239 | + if (empty($another)) { |
|
3240 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
3241 | + } |
|
3110 | 3242 | } |
3111 | 3243 | } |
3112 | 3244 | |
3113 | 3245 | // If we are changing group status, update permission cache as necessary. |
3114 | 3246 | if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups'])) |
3115 | 3247 | { |
3116 | - if ($context['user']['is_owner']) |
|
3117 | - $_SESSION['mc']['time'] = 0; |
|
3118 | - else |
|
3119 | - updateSettings(array('settings_updated' => time())); |
|
3248 | + if ($context['user']['is_owner']) { |
|
3249 | + $_SESSION['mc']['time'] = 0; |
|
3250 | + } else { |
|
3251 | + updateSettings(array('settings_updated' => time())); |
|
3252 | + } |
|
3120 | 3253 | } |
3121 | 3254 | |
3122 | 3255 | // Announce to any hooks that we have changed groups, but don't allow them to change it. |
@@ -3137,8 +3270,9 @@ discard block |
||
3137 | 3270 | global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context; |
3138 | 3271 | |
3139 | 3272 | $memID = $context['id_member']; |
3140 | - if (empty($memID) && !empty($context['password_auth_failed'])) |
|
3141 | - return false; |
|
3273 | + if (empty($memID) && !empty($context['password_auth_failed'])) { |
|
3274 | + return false; |
|
3275 | + } |
|
3142 | 3276 | |
3143 | 3277 | require_once($sourcedir . '/ManageAttachments.php'); |
3144 | 3278 | |
@@ -3149,8 +3283,9 @@ discard block |
||
3149 | 3283 | $downloadedExternalAvatar = false; |
3150 | 3284 | if ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external'])) |
3151 | 3285 | { |
3152 | - if (!is_writable($uploadDir)) |
|
3153 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
3286 | + if (!is_writable($uploadDir)) { |
|
3287 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
3288 | + } |
|
3154 | 3289 | |
3155 | 3290 | require_once($sourcedir . '/Subs-Package.php'); |
3156 | 3291 | |
@@ -3194,19 +3329,18 @@ discard block |
||
3194 | 3329 | |
3195 | 3330 | // Get rid of their old avatar. (if uploaded.) |
3196 | 3331 | removeAttachments(array('id_member' => $memID)); |
3197 | - } |
|
3198 | - elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
3332 | + } elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
3199 | 3333 | { |
3200 | 3334 | // One wasn't specified, or it's not allowed to use extra email addresses, or it's not a valid one, reset to default Gravatar. |
3201 | - if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) |
|
3202 | - $profile_vars['avatar'] = 'gravatar://'; |
|
3203 | - else |
|
3204 | - $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
3335 | + if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) { |
|
3336 | + $profile_vars['avatar'] = 'gravatar://'; |
|
3337 | + } else { |
|
3338 | + $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
3339 | + } |
|
3205 | 3340 | |
3206 | 3341 | // Get rid of their old avatar. (if uploaded.) |
3207 | 3342 | removeAttachments(array('id_member' => $memID)); |
3208 | - } |
|
3209 | - elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
3343 | + } elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
3210 | 3344 | { |
3211 | 3345 | // We need these clean... |
3212 | 3346 | $cur_profile['id_attach'] = 0; |
@@ -3218,11 +3352,13 @@ discard block |
||
3218 | 3352 | |
3219 | 3353 | $profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal'])); |
3220 | 3354 | |
3221 | - if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') |
|
3222 | - $profile_vars['avatar'] = ''; |
|
3355 | + if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') { |
|
3356 | + $profile_vars['avatar'] = ''; |
|
3357 | + } |
|
3223 | 3358 | // Trying to make us do something we'll regret? |
3224 | - elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') |
|
3225 | - return 'bad_avatar_invalid_url'; |
|
3359 | + elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') { |
|
3360 | + return 'bad_avatar_invalid_url'; |
|
3361 | + } |
|
3226 | 3362 | // Should we check dimensions? |
3227 | 3363 | elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external'])) |
3228 | 3364 | { |
@@ -3232,9 +3368,9 @@ discard block |
||
3232 | 3368 | if (is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external'])))) |
3233 | 3369 | { |
3234 | 3370 | // Houston, we have a problem. The avatar is too large!! |
3235 | - if ($modSettings['avatar_action_too_large'] == 'option_refuse') |
|
3236 | - return 'bad_avatar_too_large'; |
|
3237 | - elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
3371 | + if ($modSettings['avatar_action_too_large'] == 'option_refuse') { |
|
3372 | + return 'bad_avatar_too_large'; |
|
3373 | + } elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
3238 | 3374 | { |
3239 | 3375 | // @todo remove this if appropriate |
3240 | 3376 | require_once($sourcedir . '/Subs-Graphics.php'); |
@@ -3244,26 +3380,27 @@ discard block |
||
3244 | 3380 | $cur_profile['id_attach'] = $modSettings['new_avatar_data']['id']; |
3245 | 3381 | $cur_profile['filename'] = $modSettings['new_avatar_data']['filename']; |
3246 | 3382 | $cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type']; |
3383 | + } else { |
|
3384 | + return 'bad_avatar'; |
|
3247 | 3385 | } |
3248 | - else |
|
3249 | - return 'bad_avatar'; |
|
3250 | 3386 | } |
3251 | 3387 | } |
3252 | 3388 | } |
3253 | - } |
|
3254 | - elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
3389 | + } elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
3255 | 3390 | { |
3256 | 3391 | if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar) |
3257 | 3392 | { |
3258 | 3393 | // Get the dimensions of the image. |
3259 | 3394 | if (!$downloadedExternalAvatar) |
3260 | 3395 | { |
3261 | - if (!is_writable($uploadDir)) |
|
3262 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
3396 | + if (!is_writable($uploadDir)) { |
|
3397 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
3398 | + } |
|
3263 | 3399 | |
3264 | 3400 | $new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true); |
3265 | - if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) |
|
3266 | - fatal_lang_error('attach_timeout', 'critical'); |
|
3401 | + if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) { |
|
3402 | + fatal_lang_error('attach_timeout', 'critical'); |
|
3403 | + } |
|
3267 | 3404 | |
3268 | 3405 | $_FILES['attachment']['tmp_name'] = $new_filename; |
3269 | 3406 | } |
@@ -3376,17 +3513,19 @@ discard block |
||
3376 | 3513 | $profile_vars['avatar'] = ''; |
3377 | 3514 | |
3378 | 3515 | // Delete any temporary file. |
3379 | - if (file_exists($_FILES['attachment']['tmp_name'])) |
|
3380 | - @unlink($_FILES['attachment']['tmp_name']); |
|
3516 | + if (file_exists($_FILES['attachment']['tmp_name'])) { |
|
3517 | + @unlink($_FILES['attachment']['tmp_name']); |
|
3518 | + } |
|
3381 | 3519 | } |
3382 | 3520 | // Selected the upload avatar option and had one already uploaded before or didn't upload one. |
3383 | - else |
|
3521 | + else { |
|
3522 | + $profile_vars['avatar'] = ''; |
|
3523 | + } |
|
3524 | + } elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) { |
|
3525 | + $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
3526 | + } else { |
|
3384 | 3527 | $profile_vars['avatar'] = ''; |
3385 | 3528 | } |
3386 | - elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) |
|
3387 | - $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
3388 | - else |
|
3389 | - $profile_vars['avatar'] = ''; |
|
3390 | 3529 | |
3391 | 3530 | // Setup the profile variables so it shows things right on display! |
3392 | 3531 | $cur_profile['avatar'] = $profile_vars['avatar']; |
@@ -3434,9 +3573,9 @@ discard block |
||
3434 | 3573 | $smiley_parsed = $unparsed_signature; |
3435 | 3574 | parsesmileys($smiley_parsed); |
3436 | 3575 | $smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img'); |
3437 | - if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) |
|
3438 | - return 'signature_allow_smileys'; |
|
3439 | - elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
3576 | + if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) { |
|
3577 | + return 'signature_allow_smileys'; |
|
3578 | + } elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
3440 | 3579 | { |
3441 | 3580 | $txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]); |
3442 | 3581 | return 'signature_max_smileys'; |
@@ -3449,14 +3588,15 @@ discard block |
||
3449 | 3588 | { |
3450 | 3589 | $limit_broke = 0; |
3451 | 3590 | // Attempt to allow all sizes of abuse, so to speak. |
3452 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
3453 | - $limit_broke = $sig_limits[7] . 'px'; |
|
3454 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
3455 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
3456 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
3457 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
3458 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
3459 | - $limit_broke = 'large'; |
|
3591 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
3592 | + $limit_broke = $sig_limits[7] . 'px'; |
|
3593 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
3594 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
3595 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
3596 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
3597 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
3598 | + $limit_broke = 'large'; |
|
3599 | + } |
|
3460 | 3600 | |
3461 | 3601 | if ($limit_broke) |
3462 | 3602 | { |
@@ -3498,24 +3638,26 @@ discard block |
||
3498 | 3638 | $width = -1; $height = -1; |
3499 | 3639 | |
3500 | 3640 | // Does it have predefined restraints? Width first. |
3501 | - if ($matches[6][$key]) |
|
3502 | - $matches[2][$key] = $matches[6][$key]; |
|
3641 | + if ($matches[6][$key]) { |
|
3642 | + $matches[2][$key] = $matches[6][$key]; |
|
3643 | + } |
|
3503 | 3644 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
3504 | 3645 | { |
3505 | 3646 | $width = $sig_limits[5]; |
3506 | 3647 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
3648 | + } elseif ($matches[2][$key]) { |
|
3649 | + $width = $matches[2][$key]; |
|
3507 | 3650 | } |
3508 | - elseif ($matches[2][$key]) |
|
3509 | - $width = $matches[2][$key]; |
|
3510 | 3651 | // ... and height. |
3511 | 3652 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
3512 | 3653 | { |
3513 | 3654 | $height = $sig_limits[6]; |
3514 | - if ($width != -1) |
|
3515 | - $width = $width * ($height / $matches[4][$key]); |
|
3655 | + if ($width != -1) { |
|
3656 | + $width = $width * ($height / $matches[4][$key]); |
|
3657 | + } |
|
3658 | + } elseif ($matches[4][$key]) { |
|
3659 | + $height = $matches[4][$key]; |
|
3516 | 3660 | } |
3517 | - elseif ($matches[4][$key]) |
|
3518 | - $height = $matches[4][$key]; |
|
3519 | 3661 | |
3520 | 3662 | // If the dimensions are still not fixed - we need to check the actual image. |
3521 | 3663 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -3533,21 +3675,24 @@ discard block |
||
3533 | 3675 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
3534 | 3676 | { |
3535 | 3677 | $height = $sig_limits[6]; |
3536 | - if ($width == -1) |
|
3537 | - $width = $sizes[0]; |
|
3678 | + if ($width == -1) { |
|
3679 | + $width = $sizes[0]; |
|
3680 | + } |
|
3538 | 3681 | $width = $width * ($height / $sizes[1]); |
3682 | + } elseif ($width != -1) { |
|
3683 | + $height = $sizes[1]; |
|
3539 | 3684 | } |
3540 | - elseif ($width != -1) |
|
3541 | - $height = $sizes[1]; |
|
3542 | 3685 | } |
3543 | 3686 | } |
3544 | 3687 | |
3545 | 3688 | // Did we come up with some changes? If so remake the string. |
3546 | - if ($width != -1 || $height != -1) |
|
3547 | - $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
3689 | + if ($width != -1 || $height != -1) { |
|
3690 | + $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
3691 | + } |
|
3692 | + } |
|
3693 | + if (!empty($replaces)) { |
|
3694 | + $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
3548 | 3695 | } |
3549 | - if (!empty($replaces)) |
|
3550 | - $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
3551 | 3696 | } |
3552 | 3697 | } |
3553 | 3698 | |
@@ -3591,10 +3736,12 @@ discard block |
||
3591 | 3736 | $email = strtr($email, array(''' => '\'')); |
3592 | 3737 | |
3593 | 3738 | // Check the name and email for validity. |
3594 | - if (trim($email) == '') |
|
3595 | - return 'no_email'; |
|
3596 | - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) |
|
3597 | - return 'bad_email'; |
|
3739 | + if (trim($email) == '') { |
|
3740 | + return 'no_email'; |
|
3741 | + } |
|
3742 | + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
3743 | + return 'bad_email'; |
|
3744 | + } |
|
3598 | 3745 | |
3599 | 3746 | // Email addresses should be and stay unique. |
3600 | 3747 | $request = $smcFunc['db_query']('', ' |
@@ -3609,8 +3756,9 @@ discard block |
||
3609 | 3756 | ) |
3610 | 3757 | ); |
3611 | 3758 | |
3612 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
3613 | - return 'email_taken'; |
|
3759 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
3760 | + return 'email_taken'; |
|
3761 | + } |
|
3614 | 3762 | $smcFunc['db_free_result']($request); |
3615 | 3763 | |
3616 | 3764 | return true; |
@@ -3623,8 +3771,9 @@ discard block |
||
3623 | 3771 | { |
3624 | 3772 | global $modSettings, $context, $cur_profile; |
3625 | 3773 | |
3626 | - if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') |
|
3627 | - setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
3774 | + if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') { |
|
3775 | + setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
3776 | + } |
|
3628 | 3777 | |
3629 | 3778 | loadUserSettings(); |
3630 | 3779 | writeLog(); |
@@ -3640,8 +3789,9 @@ discard block |
||
3640 | 3789 | require_once($sourcedir . '/Subs-Post.php'); |
3641 | 3790 | |
3642 | 3791 | // Shouldn't happen but just in case. |
3643 | - if (empty($profile_vars['email_address'])) |
|
3644 | - return; |
|
3792 | + if (empty($profile_vars['email_address'])) { |
|
3793 | + return; |
|
3794 | + } |
|
3645 | 3795 | |
3646 | 3796 | $replacements = array( |
3647 | 3797 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'], |
@@ -3664,8 +3814,9 @@ discard block |
||
3664 | 3814 | $_SESSION['log_time'] = 0; |
3665 | 3815 | $_SESSION['login_' . $cookiename] = json_encode(array(0, '', 0)); |
3666 | 3816 | |
3667 | - if (isset($_COOKIE[$cookiename])) |
|
3668 | - $_COOKIE[$cookiename] = ''; |
|
3817 | + if (isset($_COOKIE[$cookiename])) { |
|
3818 | + $_COOKIE[$cookiename] = ''; |
|
3819 | + } |
|
3669 | 3820 | |
3670 | 3821 | loadUserSettings(); |
3671 | 3822 | |
@@ -3698,11 +3849,13 @@ discard block |
||
3698 | 3849 | $groups[] = $curMember['id_group']; |
3699 | 3850 | |
3700 | 3851 | // Ensure the query doesn't croak! |
3701 | - if (empty($groups)) |
|
3702 | - $groups = array(0); |
|
3852 | + if (empty($groups)) { |
|
3853 | + $groups = array(0); |
|
3854 | + } |
|
3703 | 3855 | // Just to be sure... |
3704 | - foreach ($groups as $k => $v) |
|
3705 | - $groups[$k] = (int) $v; |
|
3856 | + foreach ($groups as $k => $v) { |
|
3857 | + $groups[$k] = (int) $v; |
|
3858 | + } |
|
3706 | 3859 | |
3707 | 3860 | // Get all the membergroups they can join. |
3708 | 3861 | $request = $smcFunc['db_query']('', ' |
@@ -3732,12 +3885,14 @@ discard block |
||
3732 | 3885 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
3733 | 3886 | { |
3734 | 3887 | // Can they edit their primary group? |
3735 | - if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) |
|
3736 | - $context['can_edit_primary'] = true; |
|
3888 | + if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) { |
|
3889 | + $context['can_edit_primary'] = true; |
|
3890 | + } |
|
3737 | 3891 | |
3738 | 3892 | // If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it. |
3739 | - if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) |
|
3740 | - continue; |
|
3893 | + if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) { |
|
3894 | + continue; |
|
3895 | + } |
|
3741 | 3896 | |
3742 | 3897 | $context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array( |
3743 | 3898 | 'id' => $row['id_group'], |
@@ -3766,13 +3921,15 @@ discard block |
||
3766 | 3921 | ); |
3767 | 3922 | |
3768 | 3923 | // No changing primary one unless you have enough groups! |
3769 | - if (count($context['groups']['member']) < 2) |
|
3770 | - $context['can_edit_primary'] = false; |
|
3924 | + if (count($context['groups']['member']) < 2) { |
|
3925 | + $context['can_edit_primary'] = false; |
|
3926 | + } |
|
3771 | 3927 | |
3772 | 3928 | // In the special case that someone is requesting membership of a group, setup some special context vars. |
3773 | - if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) |
|
3774 | - $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
3775 | -} |
|
3929 | + if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) { |
|
3930 | + $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
3931 | + } |
|
3932 | + } |
|
3776 | 3933 | |
3777 | 3934 | /** |
3778 | 3935 | * This function actually makes all the group changes |
@@ -3787,10 +3944,12 @@ discard block |
||
3787 | 3944 | global $user_info, $context, $user_profile, $modSettings, $smcFunc; |
3788 | 3945 | |
3789 | 3946 | // Let's be extra cautious... |
3790 | - if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) |
|
3791 | - isAllowedTo('manage_membergroups'); |
|
3792 | - if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) |
|
3793 | - fatal_lang_error('no_access', false); |
|
3947 | + if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) { |
|
3948 | + isAllowedTo('manage_membergroups'); |
|
3949 | + } |
|
3950 | + if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) { |
|
3951 | + fatal_lang_error('no_access', false); |
|
3952 | + } |
|
3794 | 3953 | |
3795 | 3954 | checkSession(isset($_GET['gid']) ? 'get' : 'post'); |
3796 | 3955 | |
@@ -3809,8 +3968,9 @@ discard block |
||
3809 | 3968 | $foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false; |
3810 | 3969 | |
3811 | 3970 | // Sanity check!! |
3812 | - if ($group_id == 1) |
|
3813 | - isAllowedTo('admin_forum'); |
|
3971 | + if ($group_id == 1) { |
|
3972 | + isAllowedTo('admin_forum'); |
|
3973 | + } |
|
3814 | 3974 | // Protected groups too! |
3815 | 3975 | else |
3816 | 3976 | { |
@@ -3827,8 +3987,9 @@ discard block |
||
3827 | 3987 | list ($is_protected) = $smcFunc['db_fetch_row']($request); |
3828 | 3988 | $smcFunc['db_free_result']($request); |
3829 | 3989 | |
3830 | - if ($is_protected == 1) |
|
3831 | - isAllowedTo('admin_forum'); |
|
3990 | + if ($is_protected == 1) { |
|
3991 | + isAllowedTo('admin_forum'); |
|
3992 | + } |
|
3832 | 3993 | } |
3833 | 3994 | |
3834 | 3995 | // What ever we are doing, we need to determine if changing primary is possible! |
@@ -3850,36 +4011,43 @@ discard block |
||
3850 | 4011 | $group_name = $row['group_name']; |
3851 | 4012 | |
3852 | 4013 | // Does the group type match what we're doing - are we trying to request a non-requestable group? |
3853 | - if ($changeType == 'request' && $row['group_type'] != 2) |
|
3854 | - fatal_lang_error('no_access', false); |
|
4014 | + if ($changeType == 'request' && $row['group_type'] != 2) { |
|
4015 | + fatal_lang_error('no_access', false); |
|
4016 | + } |
|
3855 | 4017 | // What about leaving a requestable group we are not a member of? |
3856 | - elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) |
|
3857 | - fatal_lang_error('no_access', false); |
|
3858 | - elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) |
|
3859 | - fatal_lang_error('no_access', false); |
|
4018 | + elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) { |
|
4019 | + fatal_lang_error('no_access', false); |
|
4020 | + } elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) { |
|
4021 | + fatal_lang_error('no_access', false); |
|
4022 | + } |
|
3860 | 4023 | |
3861 | 4024 | // We can't change the primary group if this is hidden! |
3862 | - if ($row['hidden'] == 2) |
|
3863 | - $canChangePrimary = false; |
|
4025 | + if ($row['hidden'] == 2) { |
|
4026 | + $canChangePrimary = false; |
|
4027 | + } |
|
3864 | 4028 | } |
3865 | 4029 | |
3866 | 4030 | // If this is their old primary, can we change it? |
3867 | - if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) |
|
3868 | - $canChangePrimary = 1; |
|
4031 | + if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) { |
|
4032 | + $canChangePrimary = 1; |
|
4033 | + } |
|
3869 | 4034 | |
3870 | 4035 | // If we are not doing a force primary move, don't do it automatically if current primary is not 0. |
3871 | - if ($changeType != 'primary' && $old_profile['id_group'] != 0) |
|
3872 | - $canChangePrimary = false; |
|
4036 | + if ($changeType != 'primary' && $old_profile['id_group'] != 0) { |
|
4037 | + $canChangePrimary = false; |
|
4038 | + } |
|
3873 | 4039 | |
3874 | 4040 | // If this is the one we are acting on, can we even act? |
3875 | - if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) |
|
3876 | - $canChangePrimary = false; |
|
4041 | + if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) { |
|
4042 | + $canChangePrimary = false; |
|
4043 | + } |
|
3877 | 4044 | } |
3878 | 4045 | $smcFunc['db_free_result']($request); |
3879 | 4046 | |
3880 | 4047 | // Didn't find the target? |
3881 | - if (!$foundTarget) |
|
3882 | - fatal_lang_error('no_access', false); |
|
4048 | + if (!$foundTarget) { |
|
4049 | + fatal_lang_error('no_access', false); |
|
4050 | + } |
|
3883 | 4051 | |
3884 | 4052 | // Final security check, don't allow users to promote themselves to admin. |
3885 | 4053 | if ($context['can_manage_membergroups'] && !allowedTo('admin_forum')) |
@@ -3899,8 +4067,9 @@ discard block |
||
3899 | 4067 | list ($disallow) = $smcFunc['db_fetch_row']($request); |
3900 | 4068 | $smcFunc['db_free_result']($request); |
3901 | 4069 | |
3902 | - if ($disallow) |
|
3903 | - isAllowedTo('admin_forum'); |
|
4070 | + if ($disallow) { |
|
4071 | + isAllowedTo('admin_forum'); |
|
4072 | + } |
|
3904 | 4073 | } |
3905 | 4074 | |
3906 | 4075 | // If we're requesting, add the note then return. |
@@ -3918,8 +4087,9 @@ discard block |
||
3918 | 4087 | 'status_open' => 0, |
3919 | 4088 | ) |
3920 | 4089 | ); |
3921 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
3922 | - fatal_lang_error('profile_error_already_requested_group'); |
|
4090 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
4091 | + fatal_lang_error('profile_error_already_requested_group'); |
|
4092 | + } |
|
3923 | 4093 | $smcFunc['db_free_result']($request); |
3924 | 4094 | |
3925 | 4095 | // Log the request. |
@@ -3953,10 +4123,11 @@ discard block |
||
3953 | 4123 | // Are we leaving? |
3954 | 4124 | if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id])) |
3955 | 4125 | { |
3956 | - if ($old_profile['id_group'] == $group_id) |
|
3957 | - $newPrimary = 0; |
|
3958 | - else |
|
3959 | - unset($addGroups[$group_id]); |
|
4126 | + if ($old_profile['id_group'] == $group_id) { |
|
4127 | + $newPrimary = 0; |
|
4128 | + } else { |
|
4129 | + unset($addGroups[$group_id]); |
|
4130 | + } |
|
3960 | 4131 | } |
3961 | 4132 | // ... if not, must be joining. |
3962 | 4133 | else |
@@ -3964,36 +4135,42 @@ discard block |
||
3964 | 4135 | // Can we change the primary, and do we want to? |
3965 | 4136 | if ($canChangePrimary) |
3966 | 4137 | { |
3967 | - if ($old_profile['id_group'] != 0) |
|
3968 | - $addGroups[$old_profile['id_group']] = -1; |
|
4138 | + if ($old_profile['id_group'] != 0) { |
|
4139 | + $addGroups[$old_profile['id_group']] = -1; |
|
4140 | + } |
|
3969 | 4141 | $newPrimary = $group_id; |
3970 | 4142 | } |
3971 | 4143 | // Otherwise it's an additional group... |
3972 | - else |
|
3973 | - $addGroups[$group_id] = -1; |
|
4144 | + else { |
|
4145 | + $addGroups[$group_id] = -1; |
|
4146 | + } |
|
3974 | 4147 | } |
3975 | 4148 | } |
3976 | 4149 | // Finally, we must be setting the primary. |
3977 | 4150 | elseif ($canChangePrimary) |
3978 | 4151 | { |
3979 | - if ($old_profile['id_group'] != 0) |
|
3980 | - $addGroups[$old_profile['id_group']] = -1; |
|
3981 | - if (isset($addGroups[$group_id])) |
|
3982 | - unset($addGroups[$group_id]); |
|
4152 | + if ($old_profile['id_group'] != 0) { |
|
4153 | + $addGroups[$old_profile['id_group']] = -1; |
|
4154 | + } |
|
4155 | + if (isset($addGroups[$group_id])) { |
|
4156 | + unset($addGroups[$group_id]); |
|
4157 | + } |
|
3983 | 4158 | $newPrimary = $group_id; |
3984 | 4159 | } |
3985 | 4160 | |
3986 | 4161 | // Finally, we can make the changes! |
3987 | - foreach ($addGroups as $id => $dummy) |
|
3988 | - if (empty($id)) |
|
4162 | + foreach ($addGroups as $id => $dummy) { |
|
4163 | + if (empty($id)) |
|
3989 | 4164 | unset($addGroups[$id]); |
4165 | + } |
|
3990 | 4166 | $addGroups = implode(',', array_flip($addGroups)); |
3991 | 4167 | |
3992 | 4168 | // Ensure that we don't cache permissions if the group is changing. |
3993 | - if ($context['user']['is_owner']) |
|
3994 | - $_SESSION['mc']['time'] = 0; |
|
3995 | - else |
|
3996 | - updateSettings(array('settings_updated' => time())); |
|
4169 | + if ($context['user']['is_owner']) { |
|
4170 | + $_SESSION['mc']['time'] = 0; |
|
4171 | + } else { |
|
4172 | + updateSettings(array('settings_updated' => time())); |
|
4173 | + } |
|
3997 | 4174 | |
3998 | 4175 | updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups)); |
3999 | 4176 | |
@@ -4016,8 +4193,9 @@ discard block |
||
4016 | 4193 | if (empty($user_settings['tfa_secret']) && $context['user']['is_owner']) |
4017 | 4194 | { |
4018 | 4195 | // Check to ensure we're forcing SSL for authentication |
4019 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
4020 | - fatal_lang_error('login_ssl_required'); |
|
4196 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
4197 | + fatal_lang_error('login_ssl_required'); |
|
4198 | + } |
|
4021 | 4199 | |
4022 | 4200 | // In some cases (forced 2FA or backup code) they would be forced to be redirected here, |
4023 | 4201 | // we do not want too much AJAX to confuse them. |
@@ -4054,8 +4232,7 @@ discard block |
||
4054 | 4232 | $context['sub_template'] = 'tfasetup_backup'; |
4055 | 4233 | |
4056 | 4234 | return; |
4057 | - } |
|
4058 | - else |
|
4235 | + } else |
|
4059 | 4236 | { |
4060 | 4237 | $context['tfa_secret'] = $_SESSION['tfa_secret']; |
4061 | 4238 | $context['tfa_error'] = !$valid_code; |
@@ -4063,8 +4240,7 @@ discard block |
||
4063 | 4240 | $context['tfa_pass_value'] = $_POST['passwd']; |
4064 | 4241 | $context['tfa_value'] = $_POST['tfa_code']; |
4065 | 4242 | } |
4066 | - } |
|
4067 | - else |
|
4243 | + } else |
|
4068 | 4244 | { |
4069 | 4245 | $totp = new \TOTP\Auth(); |
4070 | 4246 | $secret = $totp->generateCode(); |
@@ -4074,17 +4250,16 @@ discard block |
||
4074 | 4250 | } |
4075 | 4251 | |
4076 | 4252 | $context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']); |
4077 | - } |
|
4078 | - elseif (isset($_REQUEST['disable'])) |
|
4253 | + } elseif (isset($_REQUEST['disable'])) |
|
4079 | 4254 | { |
4080 | 4255 | updateMemberData($memID, array( |
4081 | 4256 | 'tfa_secret' => '', |
4082 | 4257 | 'tfa_backup' => '', |
4083 | 4258 | )); |
4084 | 4259 | redirectexit('action=profile;area=account;u=' . $memID); |
4260 | + } else { |
|
4261 | + redirectexit('action=profile;area=account;u=' . $memID); |
|
4262 | + } |
|
4085 | 4263 | } |
4086 | - else |
|
4087 | - redirectexit('action=profile;area=account;u=' . $memID); |
|
4088 | -} |
|
4089 | 4264 | |
4090 | 4265 | ?> |
4091 | 4266 | \ No newline at end of file |
@@ -2605,7 +2605,7 @@ |
||
2605 | 2605 | * @param int $start Which item to start with (for pagination purposes) |
2606 | 2606 | * @param int $items_per_page How many items to show on each page |
2607 | 2607 | * @param string $sort A string indicating how to sort the results |
2608 | - * @param int $memID The ID of the member |
|
2608 | + * @param string $memID The ID of the member |
|
2609 | 2609 | * @return array An array of information about the user's group requests |
2610 | 2610 | */ |
2611 | 2611 | function list_getGroupRequests($start, $items_per_page, $sort, $memID) |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * View a summary. |
@@ -23,8 +24,9 @@ discard block |
||
23 | 24 | global $context, $memberContext, $txt, $modSettings, $user_profile, $sourcedir, $scripturl, $smcFunc; |
24 | 25 | |
25 | 26 | // Attempt to load the member's profile data. |
26 | - if (!loadMemberContext($memID) || !isset($memberContext[$memID])) |
|
27 | - fatal_lang_error('not_a_user', false, 404); |
|
27 | + if (!loadMemberContext($memID) || !isset($memberContext[$memID])) { |
|
28 | + fatal_lang_error('not_a_user', false, 404); |
|
29 | + } |
|
28 | 30 | |
29 | 31 | // Set up the stuff and load the user. |
30 | 32 | $context += array( |
@@ -49,19 +51,21 @@ discard block |
||
49 | 51 | |
50 | 52 | // See if they have broken any warning levels... |
51 | 53 | list ($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']); |
52 | - if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) |
|
53 | - $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
54 | - elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) |
|
55 | - $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
56 | - elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) |
|
57 | - $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
54 | + if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) { |
|
55 | + $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
56 | + } elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) { |
|
57 | + $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
58 | + } elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) { |
|
59 | + $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
60 | + } |
|
58 | 61 | |
59 | 62 | // They haven't even been registered for a full day!? |
60 | 63 | $days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24)); |
61 | - if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) |
|
62 | - $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
63 | - else |
|
64 | - $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
64 | + if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) { |
|
65 | + $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
66 | + } else { |
|
67 | + $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
68 | + } |
|
65 | 69 | |
66 | 70 | // Set the age... |
67 | 71 | if (empty($context['member']['birth_date'])) |
@@ -70,8 +74,7 @@ discard block |
||
70 | 74 | 'age' => $txt['not_applicable'], |
71 | 75 | 'today_is_birthday' => false |
72 | 76 | ); |
73 | - } |
|
74 | - else |
|
77 | + } else |
|
75 | 78 | { |
76 | 79 | list ($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d'); |
77 | 80 | $datearray = getdate(forum_time()); |
@@ -84,15 +87,16 @@ discard block |
||
84 | 87 | if (allowedTo('moderate_forum')) |
85 | 88 | { |
86 | 89 | // Make sure it's a valid ip address; otherwise, don't bother... |
87 | - if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) |
|
88 | - $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
89 | - else |
|
90 | - $context['member']['hostname'] = ''; |
|
90 | + if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) { |
|
91 | + $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
92 | + } else { |
|
93 | + $context['member']['hostname'] = ''; |
|
94 | + } |
|
91 | 95 | |
92 | 96 | $context['can_see_ip'] = true; |
97 | + } else { |
|
98 | + $context['can_see_ip'] = false; |
|
93 | 99 | } |
94 | - else |
|
95 | - $context['can_see_ip'] = false; |
|
96 | 100 | |
97 | 101 | // Are they hidden? |
98 | 102 | $context['member']['is_hidden'] = empty($user_profile[$memID]['show_online']); |
@@ -103,8 +107,9 @@ discard block |
||
103 | 107 | include_once($sourcedir . '/Who.php'); |
104 | 108 | $action = determineActions($user_profile[$memID]['url']); |
105 | 109 | |
106 | - if ($action !== false) |
|
107 | - $context['member']['action'] = $action; |
|
110 | + if ($action !== false) { |
|
111 | + $context['member']['action'] = $action; |
|
112 | + } |
|
108 | 113 | } |
109 | 114 | |
110 | 115 | // If the user is awaiting activation, and the viewer has permission - setup some activation context messages. |
@@ -167,13 +172,15 @@ discard block |
||
167 | 172 | { |
168 | 173 | // Work out what restrictions we actually have. |
169 | 174 | $ban_restrictions = array(); |
170 | - foreach (array('access', 'register', 'login', 'post') as $type) |
|
171 | - if ($row['cannot_' . $type]) |
|
175 | + foreach (array('access', 'register', 'login', 'post') as $type) { |
|
176 | + if ($row['cannot_' . $type]) |
|
172 | 177 | $ban_restrictions[] = $txt['ban_type_' . $type]; |
178 | + } |
|
173 | 179 | |
174 | 180 | // No actual ban in place? |
175 | - if (empty($ban_restrictions)) |
|
176 | - continue; |
|
181 | + if (empty($ban_restrictions)) { |
|
182 | + continue; |
|
183 | + } |
|
177 | 184 | |
178 | 185 | // Prepare the link for context. |
179 | 186 | $ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=admin;area=ban;sa=edit;bg=' . $row['id_ban_group'] . '">' . $row['name'] . '</a>'); |
@@ -196,9 +203,10 @@ discard block |
||
196 | 203 | $context['print_custom_fields'] = array(); |
197 | 204 | |
198 | 205 | // Any custom profile fields? |
199 | - if (!empty($context['custom_fields'])) |
|
200 | - foreach ($context['custom_fields'] as $custom) |
|
206 | + if (!empty($context['custom_fields'])) { |
|
207 | + foreach ($context['custom_fields'] as $custom) |
|
201 | 208 | $context['print_custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
209 | + } |
|
202 | 210 | |
203 | 211 | } |
204 | 212 | |
@@ -242,14 +250,16 @@ discard block |
||
242 | 250 | $row['extra'] = !empty($row['extra']) ? smf_json_decode($row['extra'], true) : array(); |
243 | 251 | $alerts[$id_alert] = $row; |
244 | 252 | |
245 | - if (!empty($row['sender_id'])) |
|
246 | - $senders[] = $row['sender_id']; |
|
253 | + if (!empty($row['sender_id'])) { |
|
254 | + $senders[] = $row['sender_id']; |
|
255 | + } |
|
247 | 256 | } |
248 | 257 | $smcFunc['db_free_result']($request); |
249 | 258 | |
250 | 259 | $senders = loadMemberData($senders); |
251 | - foreach ($senders as $member) |
|
252 | - loadMemberContext($member); |
|
260 | + foreach ($senders as $member) { |
|
261 | + loadMemberContext($member); |
|
262 | + } |
|
253 | 263 | |
254 | 264 | // Now go through and actually make with the text. |
255 | 265 | loadLanguage('Alerts'); |
@@ -263,12 +273,15 @@ discard block |
||
263 | 273 | $msgs = array(); |
264 | 274 | foreach ($alerts as $id_alert => $alert) |
265 | 275 | { |
266 | - if (isset($alert['extra']['board'])) |
|
267 | - $boards[$alert['extra']['board']] = $txt['board_na']; |
|
268 | - if (isset($alert['extra']['topic'])) |
|
269 | - $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
270 | - if ($alert['content_type'] == 'msg') |
|
271 | - $msgs[$alert['content_id']] = $txt['topic_na']; |
|
276 | + if (isset($alert['extra']['board'])) { |
|
277 | + $boards[$alert['extra']['board']] = $txt['board_na']; |
|
278 | + } |
|
279 | + if (isset($alert['extra']['topic'])) { |
|
280 | + $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
281 | + } |
|
282 | + if ($alert['content_type'] == 'msg') { |
|
283 | + $msgs[$alert['content_id']] = $txt['topic_na']; |
|
284 | + } |
|
272 | 285 | } |
273 | 286 | |
274 | 287 | // Having figured out what boards etc. there are, let's now get the names of them if we can see them. If not, there's already a fallback set up. |
@@ -283,8 +296,9 @@ discard block |
||
283 | 296 | 'boards' => array_keys($boards), |
284 | 297 | ) |
285 | 298 | ); |
286 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
287 | - $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
299 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
300 | + $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
301 | + } |
|
288 | 302 | } |
289 | 303 | if (!empty($topics)) |
290 | 304 | { |
@@ -299,8 +313,9 @@ discard block |
||
299 | 313 | 'topics' => array_keys($topics), |
300 | 314 | ) |
301 | 315 | ); |
302 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
303 | - $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
316 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
317 | + $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
318 | + } |
|
304 | 319 | } |
305 | 320 | if (!empty($msgs)) |
306 | 321 | { |
@@ -315,26 +330,33 @@ discard block |
||
315 | 330 | 'msgs' => array_keys($msgs), |
316 | 331 | ) |
317 | 332 | ); |
318 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
319 | - $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
333 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
334 | + $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
335 | + } |
|
320 | 336 | } |
321 | 337 | |
322 | 338 | // Now to go back through the alerts, reattach this extra information and then try to build the string out of it (if a hook didn't already) |
323 | 339 | foreach ($alerts as $id_alert => $alert) |
324 | 340 | { |
325 | - if (!empty($alert['text'])) |
|
326 | - continue; |
|
327 | - if (isset($alert['extra']['board'])) |
|
328 | - $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
329 | - if (isset($alert['extra']['topic'])) |
|
330 | - $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
331 | - if ($alert['content_type'] == 'msg') |
|
332 | - $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
333 | - if ($alert['content_type'] == 'profile') |
|
334 | - $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
335 | - |
|
336 | - if (!empty($memberContext[$alert['sender_id']])) |
|
337 | - $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
341 | + if (!empty($alert['text'])) { |
|
342 | + continue; |
|
343 | + } |
|
344 | + if (isset($alert['extra']['board'])) { |
|
345 | + $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
346 | + } |
|
347 | + if (isset($alert['extra']['topic'])) { |
|
348 | + $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
349 | + } |
|
350 | + if ($alert['content_type'] == 'msg') { |
|
351 | + $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
352 | + } |
|
353 | + if ($alert['content_type'] == 'profile') { |
|
354 | + $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
355 | + } |
|
356 | + |
|
357 | + if (!empty($memberContext[$alert['sender_id']])) { |
|
358 | + $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
359 | + } |
|
338 | 360 | |
339 | 361 | $string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action']; |
340 | 362 | if (isset($txt[$string])) |
@@ -422,11 +444,11 @@ discard block |
||
422 | 444 | checkSession('request'); |
423 | 445 | |
424 | 446 | // Call it! |
425 | - if ($action == 'remove') |
|
426 | - alert_delete($toMark, $memID); |
|
427 | - |
|
428 | - else |
|
429 | - alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
447 | + if ($action == 'remove') { |
|
448 | + alert_delete($toMark, $memID); |
|
449 | + } else { |
|
450 | + alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
451 | + } |
|
430 | 452 | |
431 | 453 | // Set a nice update message. |
432 | 454 | $_SESSION['update_message'] = true; |
@@ -476,23 +498,27 @@ discard block |
||
476 | 498 | ); |
477 | 499 | |
478 | 500 | // Set the page title |
479 | - if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) |
|
480 | - $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
481 | - else |
|
482 | - $context['page_title'] = $txt['showPosts']; |
|
501 | + if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) { |
|
502 | + $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
503 | + } else { |
|
504 | + $context['page_title'] = $txt['showPosts']; |
|
505 | + } |
|
483 | 506 | |
484 | 507 | $context['page_title'] .= ' - ' . $user_profile[$memID]['real_name']; |
485 | 508 | |
486 | 509 | // Is the load average too high to allow searching just now? |
487 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) |
|
488 | - fatal_lang_error('loadavg_show_posts_disabled', false); |
|
510 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) { |
|
511 | + fatal_lang_error('loadavg_show_posts_disabled', false); |
|
512 | + } |
|
489 | 513 | |
490 | 514 | // If we're specifically dealing with attachments use that function! |
491 | - if (isset($_GET['sa']) && $_GET['sa'] == 'attach') |
|
492 | - return showAttachments($memID); |
|
515 | + if (isset($_GET['sa']) && $_GET['sa'] == 'attach') { |
|
516 | + return showAttachments($memID); |
|
517 | + } |
|
493 | 518 | // Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function. |
494 | - elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') |
|
495 | - return showUnwatched($memID); |
|
519 | + elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') { |
|
520 | + return showUnwatched($memID); |
|
521 | + } |
|
496 | 522 | |
497 | 523 | // Are we just viewing topics? |
498 | 524 | $context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false; |
@@ -515,27 +541,30 @@ discard block |
||
515 | 541 | $smcFunc['db_free_result']($request); |
516 | 542 | |
517 | 543 | // Trying to remove a message that doesn't exist. |
518 | - if (empty($info)) |
|
519 | - redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
544 | + if (empty($info)) { |
|
545 | + redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
546 | + } |
|
520 | 547 | |
521 | 548 | // We can be lazy, since removeMessage() will check the permissions for us. |
522 | 549 | require_once($sourcedir . '/RemoveTopic.php'); |
523 | 550 | removeMessage((int) $_GET['delete']); |
524 | 551 | |
525 | 552 | // Add it to the mod log. |
526 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
527 | - logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
553 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
554 | + logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
555 | + } |
|
528 | 556 | |
529 | 557 | // Back to... where we are now ;). |
530 | 558 | redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
531 | 559 | } |
532 | 560 | |
533 | 561 | // Default to 10. |
534 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
535 | - $_REQUEST['viewscount'] = '10'; |
|
562 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
563 | + $_REQUEST['viewscount'] = '10'; |
|
564 | + } |
|
536 | 565 | |
537 | - if ($context['is_topics']) |
|
538 | - $request = $smcFunc['db_query']('', ' |
|
566 | + if ($context['is_topics']) { |
|
567 | + $request = $smcFunc['db_query']('', ' |
|
539 | 568 | SELECT COUNT(*) |
540 | 569 | FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
541 | 570 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . ' |
@@ -548,8 +577,8 @@ discard block |
||
548 | 577 | 'board' => $board, |
549 | 578 | ) |
550 | 579 | ); |
551 | - else |
|
552 | - $request = $smcFunc['db_query']('', ' |
|
580 | + } else { |
|
581 | + $request = $smcFunc['db_query']('', ' |
|
553 | 582 | SELECT COUNT(*) |
554 | 583 | FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
555 | 584 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . ' |
@@ -562,6 +591,7 @@ discard block |
||
562 | 591 | 'board' => $board, |
563 | 592 | ) |
564 | 593 | ); |
594 | + } |
|
565 | 595 | list ($msgCount) = $smcFunc['db_fetch_row']($request); |
566 | 596 | $smcFunc['db_free_result']($request); |
567 | 597 | |
@@ -583,10 +613,11 @@ discard block |
||
583 | 613 | $reverse = false; |
584 | 614 | $range_limit = ''; |
585 | 615 | |
586 | - if ($context['is_topics']) |
|
587 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
588 | - else |
|
589 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
616 | + if ($context['is_topics']) { |
|
617 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
618 | + } else { |
|
619 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
620 | + } |
|
590 | 621 | |
591 | 622 | $maxIndex = $maxPerPage; |
592 | 623 | |
@@ -612,9 +643,9 @@ discard block |
||
612 | 643 | { |
613 | 644 | $margin *= 5; |
614 | 645 | $range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin); |
646 | + } else { |
|
647 | + $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
615 | 648 | } |
616 | - else |
|
617 | - $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
618 | 649 | } |
619 | 650 | |
620 | 651 | // Find this user's posts. The left join on categories somehow makes this faster, weird as it looks. |
@@ -646,8 +677,7 @@ discard block |
||
646 | 677 | 'max' => $maxIndex, |
647 | 678 | ) |
648 | 679 | ); |
649 | - } |
|
650 | - else |
|
680 | + } else |
|
651 | 681 | { |
652 | 682 | $request = $smcFunc['db_query']('', ' |
653 | 683 | SELECT |
@@ -676,8 +706,9 @@ discard block |
||
676 | 706 | } |
677 | 707 | |
678 | 708 | // Make sure we quit this loop. |
679 | - if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) |
|
680 | - break; |
|
709 | + if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) { |
|
710 | + break; |
|
711 | + } |
|
681 | 712 | $looped = true; |
682 | 713 | $range_limit = ''; |
683 | 714 | } |
@@ -721,19 +752,21 @@ discard block |
||
721 | 752 | 'css_class' => $row['approved'] ? 'windowbg' : 'approvebg', |
722 | 753 | ); |
723 | 754 | |
724 | - if ($user_info['id'] == $row['id_member_started']) |
|
725 | - $board_ids['own'][$row['id_board']][] = $counter; |
|
755 | + if ($user_info['id'] == $row['id_member_started']) { |
|
756 | + $board_ids['own'][$row['id_board']][] = $counter; |
|
757 | + } |
|
726 | 758 | $board_ids['any'][$row['id_board']][] = $counter; |
727 | 759 | } |
728 | 760 | $smcFunc['db_free_result']($request); |
729 | 761 | |
730 | 762 | // All posts were retrieved in reverse order, get them right again. |
731 | - if ($reverse) |
|
732 | - $context['posts'] = array_reverse($context['posts'], true); |
|
763 | + if ($reverse) { |
|
764 | + $context['posts'] = array_reverse($context['posts'], true); |
|
765 | + } |
|
733 | 766 | |
734 | 767 | // These are all the permissions that are different from board to board.. |
735 | - if ($context['is_topics']) |
|
736 | - $permissions = array( |
|
768 | + if ($context['is_topics']) { |
|
769 | + $permissions = array( |
|
737 | 770 | 'own' => array( |
738 | 771 | 'post_reply_own' => 'can_reply', |
739 | 772 | ), |
@@ -741,8 +774,8 @@ discard block |
||
741 | 774 | 'post_reply_any' => 'can_reply', |
742 | 775 | ) |
743 | 776 | ); |
744 | - else |
|
745 | - $permissions = array( |
|
777 | + } else { |
|
778 | + $permissions = array( |
|
746 | 779 | 'own' => array( |
747 | 780 | 'post_reply_own' => 'can_reply', |
748 | 781 | 'delete_own' => 'can_delete', |
@@ -752,6 +785,7 @@ discard block |
||
752 | 785 | 'delete_any' => 'can_delete', |
753 | 786 | ) |
754 | 787 | ); |
788 | + } |
|
755 | 789 | |
756 | 790 | // For every permission in the own/any lists... |
757 | 791 | foreach ($permissions as $type => $list) |
@@ -762,19 +796,22 @@ discard block |
||
762 | 796 | $boards = boardsAllowedTo($permission); |
763 | 797 | |
764 | 798 | // Hmm, they can do it on all boards, can they? |
765 | - if (!empty($boards) && $boards[0] == 0) |
|
766 | - $boards = array_keys($board_ids[$type]); |
|
799 | + if (!empty($boards) && $boards[0] == 0) { |
|
800 | + $boards = array_keys($board_ids[$type]); |
|
801 | + } |
|
767 | 802 | |
768 | 803 | // Now go through each board they can do the permission on. |
769 | 804 | foreach ($boards as $board_id) |
770 | 805 | { |
771 | 806 | // There aren't any posts displayed from this board. |
772 | - if (!isset($board_ids[$type][$board_id])) |
|
773 | - continue; |
|
807 | + if (!isset($board_ids[$type][$board_id])) { |
|
808 | + continue; |
|
809 | + } |
|
774 | 810 | |
775 | 811 | // Set the permission to true ;). |
776 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
777 | - $context['posts'][$counter][$allowed] = true; |
|
812 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
813 | + $context['posts'][$counter][$allowed] = true; |
|
814 | + } |
|
778 | 815 | } |
779 | 816 | } |
780 | 817 | } |
@@ -805,8 +842,9 @@ discard block |
||
805 | 842 | $boardsAllowed = boardsAllowedTo('view_attachments'); |
806 | 843 | |
807 | 844 | // Make sure we can't actually see anything... |
808 | - if (empty($boardsAllowed)) |
|
809 | - $boardsAllowed = array(-1); |
|
845 | + if (empty($boardsAllowed)) { |
|
846 | + $boardsAllowed = array(-1); |
|
847 | + } |
|
810 | 848 | |
811 | 849 | require_once($sourcedir . '/Subs-List.php'); |
812 | 850 | |
@@ -957,8 +995,8 @@ discard block |
||
957 | 995 | ) |
958 | 996 | ); |
959 | 997 | $attachments = array(); |
960 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
961 | - $attachments[] = array( |
|
998 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
999 | + $attachments[] = array( |
|
962 | 1000 | 'id' => $row['id_attach'], |
963 | 1001 | 'filename' => $row['filename'], |
964 | 1002 | 'downloads' => $row['downloads'], |
@@ -970,6 +1008,7 @@ discard block |
||
970 | 1008 | 'board_name' => $row['name'], |
971 | 1009 | 'approved' => $row['approved'], |
972 | 1010 | ); |
1011 | + } |
|
973 | 1012 | |
974 | 1013 | $smcFunc['db_free_result']($request); |
975 | 1014 | |
@@ -1024,8 +1063,9 @@ discard block |
||
1024 | 1063 | global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir; |
1025 | 1064 | |
1026 | 1065 | // Only the owner can see the list (if the function is enabled of course) |
1027 | - if ($user_info['id'] != $memID) |
|
1028 | - return; |
|
1066 | + if ($user_info['id'] != $memID) { |
|
1067 | + return; |
|
1068 | + } |
|
1029 | 1069 | |
1030 | 1070 | require_once($sourcedir . '/Subs-List.php'); |
1031 | 1071 | |
@@ -1171,8 +1211,9 @@ discard block |
||
1171 | 1211 | ); |
1172 | 1212 | |
1173 | 1213 | $topics = array(); |
1174 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1175 | - $topics[] = $row['id_topic']; |
|
1214 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1215 | + $topics[] = $row['id_topic']; |
|
1216 | + } |
|
1176 | 1217 | |
1177 | 1218 | $smcFunc['db_free_result']($request); |
1178 | 1219 | |
@@ -1192,8 +1233,9 @@ discard block |
||
1192 | 1233 | 'topics' => $topics, |
1193 | 1234 | ) |
1194 | 1235 | ); |
1195 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1196 | - $topicsInfo[] = $row; |
|
1236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1237 | + $topicsInfo[] = $row; |
|
1238 | + } |
|
1197 | 1239 | $smcFunc['db_free_result']($request); |
1198 | 1240 | } |
1199 | 1241 | |
@@ -1241,8 +1283,9 @@ discard block |
||
1241 | 1283 | $context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name']; |
1242 | 1284 | |
1243 | 1285 | // Is the load average too high to allow searching just now? |
1244 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) |
|
1245 | - fatal_lang_error('loadavg_userstats_disabled', false); |
|
1286 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) { |
|
1287 | + fatal_lang_error('loadavg_userstats_disabled', false); |
|
1288 | + } |
|
1246 | 1289 | |
1247 | 1290 | // General user statistics. |
1248 | 1291 | $timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400); |
@@ -1400,11 +1443,13 @@ discard block |
||
1400 | 1443 | } |
1401 | 1444 | $smcFunc['db_free_result']($result); |
1402 | 1445 | |
1403 | - if ($maxPosts > 0) |
|
1404 | - for ($hour = 0; $hour < 24; $hour++) |
|
1446 | + if ($maxPosts > 0) { |
|
1447 | + for ($hour = 0; |
|
1448 | + } |
|
1449 | + $hour < 24; $hour++) |
|
1405 | 1450 | { |
1406 | - if (!isset($context['posts_by_time'][$hour])) |
|
1407 | - $context['posts_by_time'][$hour] = array( |
|
1451 | + if (!isset($context['posts_by_time'][$hour])) { |
|
1452 | + $context['posts_by_time'][$hour] = array( |
|
1408 | 1453 | 'hour' => $hour, |
1409 | 1454 | 'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)), |
1410 | 1455 | 'posts' => 0, |
@@ -1412,7 +1457,7 @@ discard block |
||
1412 | 1457 | 'relative_percent' => 0, |
1413 | 1458 | 'is_last' => $hour == 23, |
1414 | 1459 | ); |
1415 | - else |
|
1460 | + } else |
|
1416 | 1461 | { |
1417 | 1462 | $context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts); |
1418 | 1463 | $context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts); |
@@ -1445,8 +1490,9 @@ discard block |
||
1445 | 1490 | |
1446 | 1491 | foreach ($subActions as $sa => $action) |
1447 | 1492 | { |
1448 | - if (!allowedTo($action[2])) |
|
1449 | - unset($subActions[$sa]); |
|
1493 | + if (!allowedTo($action[2])) { |
|
1494 | + unset($subActions[$sa]); |
|
1495 | + } |
|
1450 | 1496 | } |
1451 | 1497 | |
1452 | 1498 | // Create the tabs for the template. |
@@ -1464,15 +1510,18 @@ discard block |
||
1464 | 1510 | ); |
1465 | 1511 | |
1466 | 1512 | // Moderation must be on to track edits. |
1467 | - if (empty($modSettings['userlog_enabled'])) |
|
1468 | - unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
1513 | + if (empty($modSettings['userlog_enabled'])) { |
|
1514 | + unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
1515 | + } |
|
1469 | 1516 | |
1470 | 1517 | // Group requests must be active to show it... |
1471 | - if (empty($modSettings['show_group_membership'])) |
|
1472 | - unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
1518 | + if (empty($modSettings['show_group_membership'])) { |
|
1519 | + unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
1520 | + } |
|
1473 | 1521 | |
1474 | - if (empty($subActions)) |
|
1475 | - fatal_lang_error('no_access', false); |
|
1522 | + if (empty($subActions)) { |
|
1523 | + fatal_lang_error('no_access', false); |
|
1524 | + } |
|
1476 | 1525 | |
1477 | 1526 | $keys = array_keys($subActions); |
1478 | 1527 | $default = array_shift($keys); |
@@ -1485,9 +1534,10 @@ discard block |
||
1485 | 1534 | $context['sub_template'] = $subActions[$context['tracking_area']][0]; |
1486 | 1535 | $call = call_helper($subActions[$context['tracking_area']][0], true); |
1487 | 1536 | |
1488 | - if (!empty($call)) |
|
1489 | - call_user_func($call, $memID); |
|
1490 | -} |
|
1537 | + if (!empty($call)) { |
|
1538 | + call_user_func($call, $memID); |
|
1539 | + } |
|
1540 | + } |
|
1491 | 1541 | |
1492 | 1542 | /** |
1493 | 1543 | * Handles tracking a user's activity |
@@ -1503,8 +1553,9 @@ discard block |
||
1503 | 1553 | isAllowedTo('moderate_forum'); |
1504 | 1554 | |
1505 | 1555 | $context['last_ip'] = $user_profile[$memID]['member_ip']; |
1506 | - if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) |
|
1507 | - $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
1556 | + if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) { |
|
1557 | + $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
1558 | + } |
|
1508 | 1559 | $context['member']['name'] = $user_profile[$memID]['real_name']; |
1509 | 1560 | |
1510 | 1561 | // Set the options for the list component. |
@@ -1670,8 +1721,9 @@ discard block |
||
1670 | 1721 | ) |
1671 | 1722 | ); |
1672 | 1723 | $message_members = array(); |
1673 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1674 | - $message_members[] = $row['id_member']; |
|
1724 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1725 | + $message_members[] = $row['id_member']; |
|
1726 | + } |
|
1675 | 1727 | $smcFunc['db_free_result']($request); |
1676 | 1728 | |
1677 | 1729 | // Fetch their names, cause of the GROUP BY doesn't like giving us that normally. |
@@ -1686,8 +1738,9 @@ discard block |
||
1686 | 1738 | 'ip_list' => $ips, |
1687 | 1739 | ) |
1688 | 1740 | ); |
1689 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1690 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1741 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1742 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1743 | + } |
|
1691 | 1744 | $smcFunc['db_free_result']($request); |
1692 | 1745 | } |
1693 | 1746 | |
@@ -1701,8 +1754,9 @@ discard block |
||
1701 | 1754 | 'ip_list' => $ips, |
1702 | 1755 | ) |
1703 | 1756 | ); |
1704 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1705 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1757 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1758 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1759 | + } |
|
1706 | 1760 | $smcFunc['db_free_result']($request); |
1707 | 1761 | } |
1708 | 1762 | } |
@@ -1762,8 +1816,8 @@ discard block |
||
1762 | 1816 | )) |
1763 | 1817 | ); |
1764 | 1818 | $error_messages = array(); |
1765 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1766 | - $error_messages[] = array( |
|
1819 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1820 | + $error_messages[] = array( |
|
1767 | 1821 | 'ip' => inet_dtop($row['ip']), |
1768 | 1822 | 'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'], |
1769 | 1823 | 'message' => strtr($row['message'], array('<span class="remove">' => '', '</span>' => '')), |
@@ -1771,6 +1825,7 @@ discard block |
||
1771 | 1825 | 'time' => timeformat($row['log_time']), |
1772 | 1826 | 'timestamp' => forum_time(true, $row['log_time']), |
1773 | 1827 | ); |
1828 | + } |
|
1774 | 1829 | $smcFunc['db_free_result']($request); |
1775 | 1830 | |
1776 | 1831 | return $error_messages; |
@@ -1833,8 +1888,8 @@ discard block |
||
1833 | 1888 | )) |
1834 | 1889 | ); |
1835 | 1890 | $messages = array(); |
1836 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1837 | - $messages[] = array( |
|
1891 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1892 | + $messages[] = array( |
|
1838 | 1893 | 'ip' => inet_dtop($row['poster_ip']), |
1839 | 1894 | 'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>', |
1840 | 1895 | 'board' => array( |
@@ -1847,6 +1902,7 @@ discard block |
||
1847 | 1902 | 'time' => timeformat($row['poster_time']), |
1848 | 1903 | 'timestamp' => forum_time(true, $row['poster_time']) |
1849 | 1904 | ); |
1905 | + } |
|
1850 | 1906 | $smcFunc['db_free_result']($request); |
1851 | 1907 | |
1852 | 1908 | return $messages; |
@@ -1873,19 +1929,20 @@ discard block |
||
1873 | 1929 | $context['sub_template'] = 'trackIP'; |
1874 | 1930 | $context['page_title'] = $txt['profile']; |
1875 | 1931 | $context['base_url'] = $scripturl . '?action=trackip'; |
1876 | - } |
|
1877 | - else |
|
1932 | + } else |
|
1878 | 1933 | { |
1879 | 1934 | $context['ip'] = $user_profile[$memID]['member_ip']; |
1880 | 1935 | $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
1881 | 1936 | } |
1882 | 1937 | |
1883 | 1938 | // Searching? |
1884 | - if (isset($_REQUEST['searchip'])) |
|
1885 | - $context['ip'] = trim($_REQUEST['searchip']); |
|
1939 | + if (isset($_REQUEST['searchip'])) { |
|
1940 | + $context['ip'] = trim($_REQUEST['searchip']); |
|
1941 | + } |
|
1886 | 1942 | |
1887 | - if (isValidIP($context['ip']) === false) |
|
1888 | - fatal_lang_error('invalid_tracking_ip', false); |
|
1943 | + if (isValidIP($context['ip']) === false) { |
|
1944 | + fatal_lang_error('invalid_tracking_ip', false); |
|
1945 | + } |
|
1889 | 1946 | |
1890 | 1947 | //mysql didn't support like search with varbinary |
1891 | 1948 | //$ip_var = str_replace('*', '%', $context['ip']); |
@@ -1893,8 +1950,9 @@ discard block |
||
1893 | 1950 | $ip_var = $context['ip']; |
1894 | 1951 | $ip_string = '= {inet:ip_address}'; |
1895 | 1952 | |
1896 | - if (empty($context['tracking_area'])) |
|
1897 | - $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
1953 | + if (empty($context['tracking_area'])) { |
|
1954 | + $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
1955 | + } |
|
1898 | 1956 | |
1899 | 1957 | $request = $smcFunc['db_query']('', ' |
1900 | 1958 | SELECT id_member, real_name AS display_name, member_ip |
@@ -1905,8 +1963,9 @@ discard block |
||
1905 | 1963 | ) |
1906 | 1964 | ); |
1907 | 1965 | $context['ips'] = array(); |
1908 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1909 | - $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
1966 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1967 | + $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
1968 | + } |
|
1910 | 1969 | $smcFunc['db_free_result']($request); |
1911 | 1970 | |
1912 | 1971 | ksort($context['ips']); |
@@ -2135,8 +2194,9 @@ discard block |
||
2135 | 2194 | foreach ($context['whois_servers'] as $whois) |
2136 | 2195 | { |
2137 | 2196 | // Strip off the "decimal point" and anything following... |
2138 | - if (in_array((int) $context['ip'], $whois['range'])) |
|
2139 | - $context['auto_whois_server'] = $whois; |
|
2197 | + if (in_array((int) $context['ip'], $whois['range'])) { |
|
2198 | + $context['auto_whois_server'] = $whois; |
|
2199 | + } |
|
2140 | 2200 | } |
2141 | 2201 | } |
2142 | 2202 | } |
@@ -2153,10 +2213,11 @@ discard block |
||
2153 | 2213 | // Gonna want this for the list. |
2154 | 2214 | require_once($sourcedir . '/Subs-List.php'); |
2155 | 2215 | |
2156 | - if ($memID == 0) |
|
2157 | - $context['base_url'] = $scripturl . '?action=trackip'; |
|
2158 | - else |
|
2159 | - $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
2216 | + if ($memID == 0) { |
|
2217 | + $context['base_url'] = $scripturl . '?action=trackip'; |
|
2218 | + } else { |
|
2219 | + $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
2220 | + } |
|
2160 | 2221 | |
2161 | 2222 | // Start with the user messages. |
2162 | 2223 | $listOptions = array( |
@@ -2266,12 +2327,13 @@ discard block |
||
2266 | 2327 | ) |
2267 | 2328 | ); |
2268 | 2329 | $logins = array(); |
2269 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2270 | - $logins[] = array( |
|
2330 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2331 | + $logins[] = array( |
|
2271 | 2332 | 'time' => timeformat($row['time']), |
2272 | 2333 | 'ip' => inet_dtop($row['ip']), |
2273 | 2334 | 'ip2' => inet_dtop($row['ip2']), |
2274 | 2335 | ); |
2336 | + } |
|
2275 | 2337 | $smcFunc['db_free_result']($request); |
2276 | 2338 | |
2277 | 2339 | return $logins; |
@@ -2296,11 +2358,12 @@ discard block |
||
2296 | 2358 | ) |
2297 | 2359 | ); |
2298 | 2360 | $context['custom_field_titles'] = array(); |
2299 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2300 | - $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
2361 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2362 | + $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
2301 | 2363 | 'title' => $row['field_name'], |
2302 | 2364 | 'parse_bbc' => $row['bbc'], |
2303 | 2365 | ); |
2366 | + } |
|
2304 | 2367 | $smcFunc['db_free_result']($request); |
2305 | 2368 | |
2306 | 2369 | // Set the options for the error lists. |
@@ -2439,19 +2502,22 @@ discard block |
||
2439 | 2502 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2440 | 2503 | { |
2441 | 2504 | $extra = smf_json_decode($row['extra'], true); |
2442 | - if (!empty($extra['applicator'])) |
|
2443 | - $members[] = $extra['applicator']; |
|
2505 | + if (!empty($extra['applicator'])) { |
|
2506 | + $members[] = $extra['applicator']; |
|
2507 | + } |
|
2444 | 2508 | |
2445 | 2509 | // Work out what the name of the action is. |
2446 | - if (isset($txt['trackEdit_action_' . $row['action']])) |
|
2447 | - $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
2448 | - elseif (isset($txt[$row['action']])) |
|
2449 | - $action_text = $txt[$row['action']]; |
|
2510 | + if (isset($txt['trackEdit_action_' . $row['action']])) { |
|
2511 | + $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
2512 | + } elseif (isset($txt[$row['action']])) { |
|
2513 | + $action_text = $txt[$row['action']]; |
|
2514 | + } |
|
2450 | 2515 | // Custom field? |
2451 | - elseif (isset($context['custom_field_titles'][$row['action']])) |
|
2452 | - $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
2453 | - else |
|
2454 | - $action_text = $row['action']; |
|
2516 | + elseif (isset($context['custom_field_titles'][$row['action']])) { |
|
2517 | + $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
2518 | + } else { |
|
2519 | + $action_text = $row['action']; |
|
2520 | + } |
|
2455 | 2521 | |
2456 | 2522 | // Parse BBC? |
2457 | 2523 | $parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false; |
@@ -2483,13 +2549,15 @@ discard block |
||
2483 | 2549 | ) |
2484 | 2550 | ); |
2485 | 2551 | $members = array(); |
2486 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2487 | - $members[$row['id_member']] = $row['real_name']; |
|
2552 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2553 | + $members[$row['id_member']] = $row['real_name']; |
|
2554 | + } |
|
2488 | 2555 | $smcFunc['db_free_result']($request); |
2489 | 2556 | |
2490 | - foreach ($edits as $key => $value) |
|
2491 | - if (isset($members[$value['id_member']])) |
|
2557 | + foreach ($edits as $key => $value) { |
|
2558 | + if (isset($members[$value['id_member']])) |
|
2492 | 2559 | $edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>'; |
2560 | + } |
|
2493 | 2561 | } |
2494 | 2562 | |
2495 | 2563 | return $edits; |
@@ -2690,10 +2758,11 @@ discard block |
||
2690 | 2758 | $context['board'] = $board; |
2691 | 2759 | |
2692 | 2760 | // Determine which groups this user is in. |
2693 | - if (empty($user_profile[$memID]['additional_groups'])) |
|
2694 | - $curGroups = array(); |
|
2695 | - else |
|
2696 | - $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
2761 | + if (empty($user_profile[$memID]['additional_groups'])) { |
|
2762 | + $curGroups = array(); |
|
2763 | + } else { |
|
2764 | + $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
2765 | + } |
|
2697 | 2766 | $curGroups[] = $user_profile[$memID]['id_group']; |
2698 | 2767 | $curGroups[] = $user_profile[$memID]['id_post_group']; |
2699 | 2768 | |
@@ -2713,28 +2782,30 @@ discard block |
||
2713 | 2782 | $context['no_access_boards'] = array(); |
2714 | 2783 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2715 | 2784 | { |
2716 | - if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) |
|
2717 | - $context['no_access_boards'][] = array( |
|
2785 | + if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) { |
|
2786 | + $context['no_access_boards'][] = array( |
|
2718 | 2787 | 'id' => $row['id_board'], |
2719 | 2788 | 'name' => $row['name'], |
2720 | 2789 | 'is_last' => false, |
2721 | 2790 | ); |
2722 | - elseif ($row['id_profile'] != 1 || $row['is_mod']) |
|
2723 | - $context['boards'][$row['id_board']] = array( |
|
2791 | + } elseif ($row['id_profile'] != 1 || $row['is_mod']) { |
|
2792 | + $context['boards'][$row['id_board']] = array( |
|
2724 | 2793 | 'id' => $row['id_board'], |
2725 | 2794 | 'name' => $row['name'], |
2726 | 2795 | 'selected' => $board == $row['id_board'], |
2727 | 2796 | 'profile' => $row['id_profile'], |
2728 | 2797 | 'profile_name' => $context['profiles'][$row['id_profile']]['name'], |
2729 | 2798 | ); |
2799 | + } |
|
2730 | 2800 | } |
2731 | 2801 | $smcFunc['db_free_result']($request); |
2732 | 2802 | |
2733 | 2803 | require_once($sourcedir . '/Subs-Boards.php'); |
2734 | 2804 | sortBoards($context['boards']); |
2735 | 2805 | |
2736 | - if (!empty($context['no_access_boards'])) |
|
2737 | - $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
2806 | + if (!empty($context['no_access_boards'])) { |
|
2807 | + $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
2808 | + } |
|
2738 | 2809 | |
2739 | 2810 | $context['member']['permissions'] = array( |
2740 | 2811 | 'general' => array(), |
@@ -2743,8 +2814,9 @@ discard block |
||
2743 | 2814 | |
2744 | 2815 | // If you're an admin we know you can do everything, we might as well leave. |
2745 | 2816 | $context['member']['has_all_permissions'] = in_array(1, $curGroups); |
2746 | - if ($context['member']['has_all_permissions']) |
|
2747 | - return; |
|
2817 | + if ($context['member']['has_all_permissions']) { |
|
2818 | + return; |
|
2819 | + } |
|
2748 | 2820 | |
2749 | 2821 | $denied = array(); |
2750 | 2822 | |
@@ -2763,21 +2835,24 @@ discard block |
||
2763 | 2835 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2764 | 2836 | { |
2765 | 2837 | // We don't know about this permission, it doesn't exist :P. |
2766 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
2767 | - continue; |
|
2838 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
2839 | + continue; |
|
2840 | + } |
|
2768 | 2841 | |
2769 | - if (empty($row['add_deny'])) |
|
2770 | - $denied[] = $row['permission']; |
|
2842 | + if (empty($row['add_deny'])) { |
|
2843 | + $denied[] = $row['permission']; |
|
2844 | + } |
|
2771 | 2845 | |
2772 | 2846 | // Permissions that end with _own or _any consist of two parts. |
2773 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
2774 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2775 | - else |
|
2776 | - $name = $txt['permissionname_' . $row['permission']]; |
|
2847 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
2848 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2849 | + } else { |
|
2850 | + $name = $txt['permissionname_' . $row['permission']]; |
|
2851 | + } |
|
2777 | 2852 | |
2778 | 2853 | // Add this permission if it doesn't exist yet. |
2779 | - if (!isset($context['member']['permissions']['general'][$row['permission']])) |
|
2780 | - $context['member']['permissions']['general'][$row['permission']] = array( |
|
2854 | + if (!isset($context['member']['permissions']['general'][$row['permission']])) { |
|
2855 | + $context['member']['permissions']['general'][$row['permission']] = array( |
|
2781 | 2856 | 'id' => $row['permission'], |
2782 | 2857 | 'groups' => array( |
2783 | 2858 | 'allowed' => array(), |
@@ -2787,6 +2862,7 @@ discard block |
||
2787 | 2862 | 'is_denied' => false, |
2788 | 2863 | 'is_global' => true, |
2789 | 2864 | ); |
2865 | + } |
|
2790 | 2866 | |
2791 | 2867 | // Add the membergroup to either the denied or the allowed groups. |
2792 | 2868 | $context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
@@ -2820,18 +2896,20 @@ discard block |
||
2820 | 2896 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2821 | 2897 | { |
2822 | 2898 | // We don't know about this permission, it doesn't exist :P. |
2823 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
2824 | - continue; |
|
2899 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
2900 | + continue; |
|
2901 | + } |
|
2825 | 2902 | |
2826 | 2903 | // The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'. |
2827 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
2828 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2829 | - else |
|
2830 | - $name = $txt['permissionname_' . $row['permission']]; |
|
2904 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
2905 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2906 | + } else { |
|
2907 | + $name = $txt['permissionname_' . $row['permission']]; |
|
2908 | + } |
|
2831 | 2909 | |
2832 | 2910 | // Create the structure for this permission. |
2833 | - if (!isset($context['member']['permissions']['board'][$row['permission']])) |
|
2834 | - $context['member']['permissions']['board'][$row['permission']] = array( |
|
2911 | + if (!isset($context['member']['permissions']['board'][$row['permission']])) { |
|
2912 | + $context['member']['permissions']['board'][$row['permission']] = array( |
|
2835 | 2913 | 'id' => $row['permission'], |
2836 | 2914 | 'groups' => array( |
2837 | 2915 | 'allowed' => array(), |
@@ -2841,6 +2919,7 @@ discard block |
||
2841 | 2919 | 'is_denied' => false, |
2842 | 2920 | 'is_global' => empty($board), |
2843 | 2921 | ); |
2922 | + } |
|
2844 | 2923 | |
2845 | 2924 | $context['member']['permissions']['board'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][$row['id_group']] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
2846 | 2925 | |
@@ -2859,8 +2938,9 @@ discard block |
||
2859 | 2938 | global $modSettings, $context, $sourcedir, $txt, $scripturl; |
2860 | 2939 | |
2861 | 2940 | // Firstly, can we actually even be here? |
2862 | - if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) |
|
2863 | - fatal_lang_error('no_access', false); |
|
2941 | + if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) { |
|
2942 | + fatal_lang_error('no_access', false); |
|
2943 | + } |
|
2864 | 2944 | |
2865 | 2945 | // Make sure things which are disabled stay disabled. |
2866 | 2946 | $modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110; |
@@ -2947,9 +3027,10 @@ discard block |
||
2947 | 3027 | $modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'], |
2948 | 3028 | ); |
2949 | 3029 | $context['current_level'] = 0; |
2950 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
2951 | - if ($context['member']['warning'] >= $limit) |
|
3030 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
3031 | + if ($context['member']['warning'] >= $limit) |
|
2952 | 3032 | $context['current_level'] = $limit; |
2953 | -} |
|
3033 | + } |
|
3034 | + } |
|
2954 | 3035 | |
2955 | 3036 | ?> |
2956 | 3037 | \ No newline at end of file |
@@ -325,7 +325,7 @@ |
||
325 | 325 | * Validates a IPv6 address. returns true if it is ipv6. |
326 | 326 | * |
327 | 327 | * @param string $ip The ip address to be validated |
328 | - * @return boolean Whether the specified IP is a valid IPv6 address |
|
328 | + * @return false|string Whether the specified IP is a valid IPv6 address |
|
329 | 329 | */ |
330 | 330 | function isValidIPv6($ip) |
331 | 331 | { |
@@ -426,8 +426,8 @@ |
||
426 | 426 | */ |
427 | 427 | function matchIPtoCIDR($ip_address, $cidr_address) |
428 | 428 | { |
429 | - list ($cidr_network, $cidr_subnetmask) = preg_split('/', $cidr_address); |
|
430 | - return (ip2long($ip_address) & (~((1 << (32 - $cidr_subnetmask)) - 1))) == ip2long($cidr_network); |
|
429 | + list ($cidr_network, $cidr_subnetmask) = preg_split('/', $cidr_address); |
|
430 | + return (ip2long($ip_address) & (~((1 << (32 - $cidr_subnetmask)) - 1))) == ip2long($cidr_network); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | /** |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Clean the request variables - add html entities to GET and slashes if magic_quotes_gpc is Off. |
@@ -44,22 +45,26 @@ discard block |
||
44 | 45 | unset($GLOBALS['HTTP_POST_FILES'], $GLOBALS['HTTP_POST_FILES']); |
45 | 46 | |
46 | 47 | // These keys shouldn't be set...ever. |
47 | - if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
48 | - die('Invalid request variable.'); |
|
48 | + if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
49 | + die('Invalid request variable.'); |
|
50 | + } |
|
49 | 51 | |
50 | 52 | // Same goes for numeric keys. |
51 | - foreach (array_merge(array_keys($_POST), array_keys($_GET), array_keys($_FILES)) as $key) |
|
52 | - if (is_numeric($key)) |
|
53 | + foreach (array_merge(array_keys($_POST), array_keys($_GET), array_keys($_FILES)) as $key) { |
|
54 | + if (is_numeric($key)) |
|
53 | 55 | die('Numeric request keys are invalid.'); |
56 | + } |
|
54 | 57 | |
55 | 58 | // Numeric keys in cookies are less of a problem. Just unset those. |
56 | - foreach ($_COOKIE as $key => $value) |
|
57 | - if (is_numeric($key)) |
|
59 | + foreach ($_COOKIE as $key => $value) { |
|
60 | + if (is_numeric($key)) |
|
58 | 61 | unset($_COOKIE[$key]); |
62 | + } |
|
59 | 63 | |
60 | 64 | // Get the correct query string. It may be in an environment variable... |
61 | - if (!isset($_SERVER['QUERY_STRING'])) |
|
62 | - $_SERVER['QUERY_STRING'] = getenv('QUERY_STRING'); |
|
65 | + if (!isset($_SERVER['QUERY_STRING'])) { |
|
66 | + $_SERVER['QUERY_STRING'] = getenv('QUERY_STRING'); |
|
67 | + } |
|
63 | 68 | |
64 | 69 | // It seems that sticking a URL after the query string is mighty common, well, it's evil - don't. |
65 | 70 | if (strpos($_SERVER['QUERY_STRING'], 'http') === 0) |
@@ -83,13 +88,14 @@ discard block |
||
83 | 88 | parse_str(preg_replace('/&(\w+)(?=&|$)/', '&$1=', strtr($_SERVER['QUERY_STRING'], array(';?' => '&', ';' => '&', '%00' => '', "\0" => ''))), $_GET); |
84 | 89 | |
85 | 90 | // Magic quotes still applies with parse_str - so clean it up. |
86 | - if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc() != 0 && empty($modSettings['integrate_magic_quotes'])) |
|
87 | - $_GET = $removeMagicQuoteFunction($_GET); |
|
88 | - } |
|
89 | - elseif (strpos(ini_get('arg_separator.input'), ';') !== false) |
|
91 | + if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc() != 0 && empty($modSettings['integrate_magic_quotes'])) { |
|
92 | + $_GET = $removeMagicQuoteFunction($_GET); |
|
93 | + } |
|
94 | + } elseif (strpos(ini_get('arg_separator.input'), ';') !== false) |
|
90 | 95 | { |
91 | - if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc() != 0 && empty($modSettings['integrate_magic_quotes'])) |
|
92 | - $_GET = $removeMagicQuoteFunction($_GET); |
|
96 | + if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc() != 0 && empty($modSettings['integrate_magic_quotes'])) { |
|
97 | + $_GET = $removeMagicQuoteFunction($_GET); |
|
98 | + } |
|
93 | 99 | |
94 | 100 | // Search engines will send action=profile%3Bu=1, which confuses PHP. |
95 | 101 | foreach ($_GET as $k => $v) |
@@ -102,8 +108,9 @@ discard block |
||
102 | 108 | for ($i = 1, $n = count($temp); $i < $n; $i++) |
103 | 109 | { |
104 | 110 | @list ($key, $val) = @explode('=', $temp[$i], 2); |
105 | - if (!isset($_GET[$key])) |
|
106 | - $_GET[$key] = $val; |
|
111 | + if (!isset($_GET[$key])) { |
|
112 | + $_GET[$key] = $val; |
|
113 | + } |
|
107 | 114 | } |
108 | 115 | } |
109 | 116 | |
@@ -120,18 +127,20 @@ discard block |
||
120 | 127 | if (!empty($_SERVER['REQUEST_URI'])) |
121 | 128 | { |
122 | 129 | // Remove the .html, assuming there is one. |
123 | - if (substr($_SERVER['REQUEST_URI'], strrpos($_SERVER['REQUEST_URI'], '.'), 4) == '.htm') |
|
124 | - $request = substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '.')); |
|
125 | - else |
|
126 | - $request = $_SERVER['REQUEST_URI']; |
|
130 | + if (substr($_SERVER['REQUEST_URI'], strrpos($_SERVER['REQUEST_URI'], '.'), 4) == '.htm') { |
|
131 | + $request = substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '.')); |
|
132 | + } else { |
|
133 | + $request = $_SERVER['REQUEST_URI']; |
|
134 | + } |
|
127 | 135 | |
128 | 136 | // @todo smflib. |
129 | 137 | // Replace 'index.php/a,b,c/d/e,f' with 'a=b,c&d=&e=f' and parse it into $_GET. |
130 | 138 | if (strpos($request, basename($scripturl) . '/') !== false) |
131 | 139 | { |
132 | 140 | parse_str(substr(preg_replace('/&(\w+)(?=&|$)/', '&$1=', strtr(preg_replace('~/([^,/]+),~', '/$1=', substr($request, strpos($request, basename($scripturl)) + strlen(basename($scripturl)))), '/', '&')), 1), $temp); |
133 | - if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc() != 0 && empty($modSettings['integrate_magic_quotes'])) |
|
134 | - $temp = $removeMagicQuoteFunction($temp); |
|
141 | + if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc() != 0 && empty($modSettings['integrate_magic_quotes'])) { |
|
142 | + $temp = $removeMagicQuoteFunction($temp); |
|
143 | + } |
|
135 | 144 | $_GET += $temp; |
136 | 145 | } |
137 | 146 | } |
@@ -142,9 +151,10 @@ discard block |
||
142 | 151 | $_ENV = $removeMagicQuoteFunction($_ENV); |
143 | 152 | $_POST = $removeMagicQuoteFunction($_POST); |
144 | 153 | $_COOKIE = $removeMagicQuoteFunction($_COOKIE); |
145 | - foreach ($_FILES as $k => $dummy) |
|
146 | - if (isset($_FILES[$k]['name'])) |
|
154 | + foreach ($_FILES as $k => $dummy) { |
|
155 | + if (isset($_FILES[$k]['name'])) |
|
147 | 156 | $_FILES[$k]['name'] = $removeMagicQuoteFunction($_FILES[$k]['name']); |
157 | + } |
|
148 | 158 | } |
149 | 159 | |
150 | 160 | // Add entities to GET. This is kinda like the slashes on everything else. |
@@ -160,11 +170,13 @@ discard block |
||
160 | 170 | $_REQUEST['board'] = (string) $_REQUEST['board']; |
161 | 171 | |
162 | 172 | // If there's a slash in it, we've got a start value! (old, compatible links.) |
163 | - if (strpos($_REQUEST['board'], '/') !== false) |
|
164 | - list ($_REQUEST['board'], $_REQUEST['start']) = explode('/', $_REQUEST['board']); |
|
173 | + if (strpos($_REQUEST['board'], '/') !== false) { |
|
174 | + list ($_REQUEST['board'], $_REQUEST['start']) = explode('/', $_REQUEST['board']); |
|
175 | + } |
|
165 | 176 | // Same idea, but dots. This is the currently used format - ?board=1.0... |
166 | - elseif (strpos($_REQUEST['board'], '.') !== false) |
|
167 | - list ($_REQUEST['board'], $_REQUEST['start']) = explode('.', $_REQUEST['board']); |
|
177 | + elseif (strpos($_REQUEST['board'], '.') !== false) { |
|
178 | + list ($_REQUEST['board'], $_REQUEST['start']) = explode('.', $_REQUEST['board']); |
|
179 | + } |
|
168 | 180 | // Now make absolutely sure it's a number. |
169 | 181 | $board = (int) $_REQUEST['board']; |
170 | 182 | $_REQUEST['start'] = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0; |
@@ -173,12 +185,14 @@ discard block |
||
173 | 185 | $_GET['board'] = $board; |
174 | 186 | } |
175 | 187 | // Well, $board is going to be a number no matter what. |
176 | - else |
|
177 | - $board = 0; |
|
188 | + else { |
|
189 | + $board = 0; |
|
190 | + } |
|
178 | 191 | |
179 | 192 | // If there's a threadid, it's probably an old YaBB SE link. Flow with it. |
180 | - if (isset($_REQUEST['threadid']) && !isset($_REQUEST['topic'])) |
|
181 | - $_REQUEST['topic'] = $_REQUEST['threadid']; |
|
193 | + if (isset($_REQUEST['threadid']) && !isset($_REQUEST['topic'])) { |
|
194 | + $_REQUEST['topic'] = $_REQUEST['threadid']; |
|
195 | + } |
|
182 | 196 | |
183 | 197 | // We've got topic! |
184 | 198 | if (isset($_REQUEST['topic'])) |
@@ -187,29 +201,34 @@ discard block |
||
187 | 201 | $_REQUEST['topic'] = (string) $_REQUEST['topic']; |
188 | 202 | |
189 | 203 | // Slash means old, beta style, formatting. That's okay though, the link should still work. |
190 | - if (strpos($_REQUEST['topic'], '/') !== false) |
|
191 | - list ($_REQUEST['topic'], $_REQUEST['start']) = explode('/', $_REQUEST['topic']); |
|
204 | + if (strpos($_REQUEST['topic'], '/') !== false) { |
|
205 | + list ($_REQUEST['topic'], $_REQUEST['start']) = explode('/', $_REQUEST['topic']); |
|
206 | + } |
|
192 | 207 | // Dots are useful and fun ;). This is ?topic=1.15. |
193 | - elseif (strpos($_REQUEST['topic'], '.') !== false) |
|
194 | - list ($_REQUEST['topic'], $_REQUEST['start']) = explode('.', $_REQUEST['topic']); |
|
208 | + elseif (strpos($_REQUEST['topic'], '.') !== false) { |
|
209 | + list ($_REQUEST['topic'], $_REQUEST['start']) = explode('.', $_REQUEST['topic']); |
|
210 | + } |
|
195 | 211 | |
196 | 212 | $topic = (int) $_REQUEST['topic']; |
197 | 213 | |
198 | 214 | // Now make sure the online log gets the right number. |
199 | 215 | $_GET['topic'] = $topic; |
216 | + } else { |
|
217 | + $topic = 0; |
|
200 | 218 | } |
201 | - else |
|
202 | - $topic = 0; |
|
203 | 219 | |
204 | 220 | // There should be a $_REQUEST['start'], some at least. If you need to default to other than 0, use $_GET['start']. |
205 | - if (empty($_REQUEST['start']) || $_REQUEST['start'] < 0 || (int) $_REQUEST['start'] > 2147473647) |
|
206 | - $_REQUEST['start'] = 0; |
|
221 | + if (empty($_REQUEST['start']) || $_REQUEST['start'] < 0 || (int) $_REQUEST['start'] > 2147473647) { |
|
222 | + $_REQUEST['start'] = 0; |
|
223 | + } |
|
207 | 224 | |
208 | 225 | // The action needs to be a string and not an array or anything else |
209 | - if (isset($_REQUEST['action'])) |
|
210 | - $_REQUEST['action'] = (string) $_REQUEST['action']; |
|
211 | - if (isset($_GET['action'])) |
|
212 | - $_GET['action'] = (string) $_GET['action']; |
|
226 | + if (isset($_REQUEST['action'])) { |
|
227 | + $_REQUEST['action'] = (string) $_REQUEST['action']; |
|
228 | + } |
|
229 | + if (isset($_GET['action'])) { |
|
230 | + $_GET['action'] = (string) $_GET['action']; |
|
231 | + } |
|
213 | 232 | |
214 | 233 | // Some mail providers like to encode semicolons in activation URLs... |
215 | 234 | if (!empty($_REQUEST['action']) && substr($_SERVER['QUERY_STRING'], 0, 18) == 'action=activate%3b') |
@@ -235,29 +254,33 @@ discard block |
||
235 | 254 | $_SERVER['BAN_CHECK_IP'] = $_SERVER['REMOTE_ADDR']; |
236 | 255 | |
237 | 256 | // If we haven't specified how to handle Reverse Proxy IP headers, lets do what we always used to do. |
238 | - if (!isset($modSettings['proxy_ip_header'])) |
|
239 | - $modSettings['proxy_ip_header'] = 'autodetect'; |
|
257 | + if (!isset($modSettings['proxy_ip_header'])) { |
|
258 | + $modSettings['proxy_ip_header'] = 'autodetect'; |
|
259 | + } |
|
240 | 260 | |
241 | 261 | // Which headers are we going to check for Reverse Proxy IP headers? |
242 | - if ($modSettings['proxy_ip_header'] == 'disabled') |
|
243 | - $reverseIPheaders = array(); |
|
244 | - elseif ($modSettings['proxy_ip_header'] == 'autodetect') |
|
245 | - $reverseIPheaders = array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP'); |
|
246 | - else |
|
247 | - $reverseIPheaders = array($modSettings['proxy_ip_header']); |
|
262 | + if ($modSettings['proxy_ip_header'] == 'disabled') { |
|
263 | + $reverseIPheaders = array(); |
|
264 | + } elseif ($modSettings['proxy_ip_header'] == 'autodetect') { |
|
265 | + $reverseIPheaders = array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP'); |
|
266 | + } else { |
|
267 | + $reverseIPheaders = array($modSettings['proxy_ip_header']); |
|
268 | + } |
|
248 | 269 | |
249 | 270 | // Find the user's IP address. (but don't let it give you 'unknown'!) |
250 | 271 | foreach ($reverseIPheaders as $proxyIPheader) |
251 | 272 | { |
252 | 273 | // Ignore if this is not set. |
253 | - if (!isset($_SERVER[$proxyIPheader])) |
|
254 | - continue; |
|
274 | + if (!isset($_SERVER[$proxyIPheader])) { |
|
275 | + continue; |
|
276 | + } |
|
255 | 277 | |
256 | 278 | if (!empty($modSettings['proxy_ip_servers'])) |
257 | 279 | { |
258 | - foreach (explode(',', $modSettings['proxy_ip_servers']) as $proxy) |
|
259 | - if ($proxy == $_SERVER['REMOTE_ADDR'] || matchIPtoCIDR($_SERVER['REMOTE_ADDR'], $proxy)) |
|
280 | + foreach (explode(',', $modSettings['proxy_ip_servers']) as $proxy) { |
|
281 | + if ($proxy == $_SERVER['REMOTE_ADDR'] || matchIPtoCIDR($_SERVER['REMOTE_ADDR'], $proxy)) |
|
260 | 282 | continue; |
283 | + } |
|
261 | 284 | } |
262 | 285 | |
263 | 286 | // If there are commas, get the last one.. probably. |
@@ -277,8 +300,9 @@ discard block |
||
277 | 300 | |
278 | 301 | // Just incase we have a legacy IPv4 address. |
279 | 302 | // @ TODO: Convert to IPv6. |
280 | - if (preg_match('~^((([1]?\d)?\d|2[0-4]\d|25[0-5])\.){3}(([1]?\d)?\d|2[0-4]\d|25[0-5])$~', $_SERVER[$proxyIPheader]) === 0) |
|
281 | - continue; |
|
303 | + if (preg_match('~^((([1]?\d)?\d|2[0-4]\d|25[0-5])\.){3}(([1]?\d)?\d|2[0-4]\d|25[0-5])$~', $_SERVER[$proxyIPheader]) === 0) { |
|
304 | + continue; |
|
305 | + } |
|
282 | 306 | } |
283 | 307 | |
284 | 308 | continue; |
@@ -290,36 +314,40 @@ discard block |
||
290 | 314 | } |
291 | 315 | } |
292 | 316 | // Otherwise just use the only one. |
293 | - elseif (preg_match('~^((0|10|172\.(1[6-9]|2[0-9]|3[01])|192\.168|255|127)\.|unknown|::1|fe80::|fc00::)~', $_SERVER[$proxyIPheader]) == 0 || preg_match('~^((0|10|172\.(1[6-9]|2[0-9]|3[01])|192\.168|255|127)\.|unknown|::1|fe80::|fc00::)~', $_SERVER['REMOTE_ADDR']) != 0) |
|
294 | - $_SERVER['BAN_CHECK_IP'] = $_SERVER[$proxyIPheader]; |
|
295 | - elseif (!isValidIPv6($_SERVER[$proxyIPheader]) || preg_match('~::ffff:\d+\.\d+\.\d+\.\d+~', $_SERVER[$proxyIPheader]) !== 0) |
|
317 | + elseif (preg_match('~^((0|10|172\.(1[6-9]|2[0-9]|3[01])|192\.168|255|127)\.|unknown|::1|fe80::|fc00::)~', $_SERVER[$proxyIPheader]) == 0 || preg_match('~^((0|10|172\.(1[6-9]|2[0-9]|3[01])|192\.168|255|127)\.|unknown|::1|fe80::|fc00::)~', $_SERVER['REMOTE_ADDR']) != 0) { |
|
318 | + $_SERVER['BAN_CHECK_IP'] = $_SERVER[$proxyIPheader]; |
|
319 | + } elseif (!isValidIPv6($_SERVER[$proxyIPheader]) || preg_match('~::ffff:\d+\.\d+\.\d+\.\d+~', $_SERVER[$proxyIPheader]) !== 0) |
|
296 | 320 | { |
297 | 321 | $_SERVER[$proxyIPheader] = preg_replace('~^::ffff:(\d+\.\d+\.\d+\.\d+)~', '\1', $_SERVER[$proxyIPheader]); |
298 | 322 | |
299 | 323 | // Just incase we have a legacy IPv4 address. |
300 | 324 | // @ TODO: Convert to IPv6. |
301 | - if (preg_match('~^((([1]?\d)?\d|2[0-4]\d|25[0-5])\.){3}(([1]?\d)?\d|2[0-4]\d|25[0-5])$~', $_SERVER[$proxyIPheader]) === 0) |
|
302 | - continue; |
|
325 | + if (preg_match('~^((([1]?\d)?\d|2[0-4]\d|25[0-5])\.){3}(([1]?\d)?\d|2[0-4]\d|25[0-5])$~', $_SERVER[$proxyIPheader]) === 0) { |
|
326 | + continue; |
|
327 | + } |
|
303 | 328 | } |
304 | 329 | } |
305 | 330 | |
306 | 331 | // Make sure we know the URL of the current request. |
307 | - if (empty($_SERVER['REQUEST_URI'])) |
|
308 | - $_SERVER['REQUEST_URL'] = $scripturl . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''); |
|
309 | - elseif (preg_match('~^([^/]+//[^/]+)~', $scripturl, $match) == 1) |
|
310 | - $_SERVER['REQUEST_URL'] = $match[1] . $_SERVER['REQUEST_URI']; |
|
311 | - else |
|
312 | - $_SERVER['REQUEST_URL'] = $_SERVER['REQUEST_URI']; |
|
332 | + if (empty($_SERVER['REQUEST_URI'])) { |
|
333 | + $_SERVER['REQUEST_URL'] = $scripturl . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''); |
|
334 | + } elseif (preg_match('~^([^/]+//[^/]+)~', $scripturl, $match) == 1) { |
|
335 | + $_SERVER['REQUEST_URL'] = $match[1] . $_SERVER['REQUEST_URI']; |
|
336 | + } else { |
|
337 | + $_SERVER['REQUEST_URL'] = $_SERVER['REQUEST_URI']; |
|
338 | + } |
|
313 | 339 | |
314 | 340 | // And make sure HTTP_USER_AGENT is set. |
315 | 341 | $_SERVER['HTTP_USER_AGENT'] = isset($_SERVER['HTTP_USER_AGENT']) ? (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($smcFunc['db_unescape_string']($_SERVER['HTTP_USER_AGENT']), ENT_QUOTES) : htmlspecialchars($smcFunc['db_unescape_string']($_SERVER['HTTP_USER_AGENT']), ENT_QUOTES)) : ''; |
316 | 342 | |
317 | 343 | // Some final checking. |
318 | - if (!isValidIP($_SERVER['BAN_CHECK_IP'])) |
|
319 | - $_SERVER['BAN_CHECK_IP'] = ''; |
|
320 | - if ($_SERVER['REMOTE_ADDR'] == 'unknown') |
|
321 | - $_SERVER['REMOTE_ADDR'] = ''; |
|
322 | -} |
|
344 | + if (!isValidIP($_SERVER['BAN_CHECK_IP'])) { |
|
345 | + $_SERVER['BAN_CHECK_IP'] = ''; |
|
346 | + } |
|
347 | + if ($_SERVER['REMOTE_ADDR'] == 'unknown') { |
|
348 | + $_SERVER['REMOTE_ADDR'] = ''; |
|
349 | + } |
|
350 | + } |
|
323 | 351 | |
324 | 352 | /** |
325 | 353 | * Validates a IPv6 address. returns true if it is ipv6. |
@@ -330,8 +358,9 @@ discard block |
||
330 | 358 | function isValidIPv6($ip) |
331 | 359 | { |
332 | 360 | //looking for : |
333 | - if (strpos($ip, ':') === false) |
|
334 | - return false; |
|
361 | + if (strpos($ip, ':') === false) { |
|
362 | + return false; |
|
363 | + } |
|
335 | 364 | |
336 | 365 | //check valid address |
337 | 366 | return inet_pton($ip); |
@@ -348,15 +377,17 @@ discard block |
||
348 | 377 | static $expanded = array(); |
349 | 378 | |
350 | 379 | // Check if we have done this already. |
351 | - if (isset($expanded[$ip])) |
|
352 | - return $expanded[$ip]; |
|
380 | + if (isset($expanded[$ip])) { |
|
381 | + return $expanded[$ip]; |
|
382 | + } |
|
353 | 383 | |
354 | 384 | // Expand the IP out. |
355 | 385 | $expanded_ip = explode(':', expandIPv6($ip)); |
356 | 386 | |
357 | 387 | $new_ip = array(); |
358 | - foreach ($expanded_ip as $int) |
|
359 | - $new_ip[] = hexdec($int); |
|
388 | + foreach ($expanded_ip as $int) { |
|
389 | + $new_ip[] = hexdec($int); |
|
390 | + } |
|
360 | 391 | |
361 | 392 | // Save this incase of repeated use. |
362 | 393 | $expanded[$ip] = $new_ip; |
@@ -376,8 +407,9 @@ discard block |
||
376 | 407 | static $converted = array(); |
377 | 408 | |
378 | 409 | // Check if we have done this already. |
379 | - if (isset($converted[$addr])) |
|
380 | - return $converted[$addr]; |
|
410 | + if (isset($converted[$addr])) { |
|
411 | + return $converted[$addr]; |
|
412 | + } |
|
381 | 413 | |
382 | 414 | // Check if there are segments missing, insert if necessary. |
383 | 415 | if (strpos($addr, '::') !== false) |
@@ -387,18 +419,20 @@ discard block |
||
387 | 419 | $part[1] = explode(':', $part[1]); |
388 | 420 | $missing = array(); |
389 | 421 | |
390 | - for ($i = 0; $i < (8 - (count($part[0]) + count($part[1]))); $i++) |
|
391 | - array_push($missing, '0000'); |
|
422 | + for ($i = 0; $i < (8 - (count($part[0]) + count($part[1]))); $i++) { |
|
423 | + array_push($missing, '0000'); |
|
424 | + } |
|
392 | 425 | |
393 | 426 | $part = array_merge($part[0], $missing, $part[1]); |
427 | + } else { |
|
428 | + $part = explode(':', $addr); |
|
394 | 429 | } |
395 | - else |
|
396 | - $part = explode(':', $addr); |
|
397 | 430 | |
398 | 431 | // Pad each segment until it has 4 digits. |
399 | - foreach ($part as &$p) |
|
400 | - while (strlen($p) < 4) |
|
432 | + foreach ($part as &$p) { |
|
433 | + while (strlen($p) < 4) |
|
401 | 434 | $p = '0' . $p; |
435 | + } |
|
402 | 436 | |
403 | 437 | unset($p); |
404 | 438 | |
@@ -409,11 +443,12 @@ discard block |
||
409 | 443 | $converted[$addr] = $result; |
410 | 444 | |
411 | 445 | // Quick check to make sure the length is as expected. |
412 | - if (!$strict_check || strlen($result) == 39) |
|
413 | - return $result; |
|
414 | - else |
|
415 | - return false; |
|
416 | -} |
|
446 | + if (!$strict_check || strlen($result) == 39) { |
|
447 | + return $result; |
|
448 | + } else { |
|
449 | + return false; |
|
450 | + } |
|
451 | + } |
|
417 | 452 | |
418 | 453 | |
419 | 454 | /** |
@@ -444,15 +479,17 @@ discard block |
||
444 | 479 | { |
445 | 480 | global $smcFunc; |
446 | 481 | |
447 | - if (!is_array($var)) |
|
448 | - return $smcFunc['db_escape_string']($var); |
|
482 | + if (!is_array($var)) { |
|
483 | + return $smcFunc['db_escape_string']($var); |
|
484 | + } |
|
449 | 485 | |
450 | 486 | // Reindex the array with slashes. |
451 | 487 | $new_var = array(); |
452 | 488 | |
453 | 489 | // Add slashes to every element, even the indexes! |
454 | - foreach ($var as $k => $v) |
|
455 | - $new_var[$smcFunc['db_escape_string']($k)] = escapestring__recursive($v); |
|
490 | + foreach ($var as $k => $v) { |
|
491 | + $new_var[$smcFunc['db_escape_string']($k)] = escapestring__recursive($v); |
|
492 | + } |
|
456 | 493 | |
457 | 494 | return $new_var; |
458 | 495 | } |
@@ -472,12 +509,14 @@ discard block |
||
472 | 509 | { |
473 | 510 | global $smcFunc; |
474 | 511 | |
475 | - if (!is_array($var)) |
|
476 | - return isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($var, ENT_QUOTES) : htmlspecialchars($var, ENT_QUOTES); |
|
512 | + if (!is_array($var)) { |
|
513 | + return isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($var, ENT_QUOTES) : htmlspecialchars($var, ENT_QUOTES); |
|
514 | + } |
|
477 | 515 | |
478 | 516 | // Add the htmlspecialchars to every element. |
479 | - foreach ($var as $k => $v) |
|
480 | - $var[$k] = $level > 25 ? null : htmlspecialchars__recursive($v, $level + 1); |
|
517 | + foreach ($var as $k => $v) { |
|
518 | + $var[$k] = $level > 25 ? null : htmlspecialchars__recursive($v, $level + 1); |
|
519 | + } |
|
481 | 520 | |
482 | 521 | return $var; |
483 | 522 | } |
@@ -495,15 +534,17 @@ discard block |
||
495 | 534 | */ |
496 | 535 | function urldecode__recursive($var, $level = 0) |
497 | 536 | { |
498 | - if (!is_array($var)) |
|
499 | - return urldecode($var); |
|
537 | + if (!is_array($var)) { |
|
538 | + return urldecode($var); |
|
539 | + } |
|
500 | 540 | |
501 | 541 | // Reindex the array... |
502 | 542 | $new_var = array(); |
503 | 543 | |
504 | 544 | // Add the htmlspecialchars to every element. |
505 | - foreach ($var as $k => $v) |
|
506 | - $new_var[urldecode($k)] = $level > 25 ? null : urldecode__recursive($v, $level + 1); |
|
545 | + foreach ($var as $k => $v) { |
|
546 | + $new_var[urldecode($k)] = $level > 25 ? null : urldecode__recursive($v, $level + 1); |
|
547 | + } |
|
507 | 548 | |
508 | 549 | return $new_var; |
509 | 550 | } |
@@ -521,15 +562,17 @@ discard block |
||
521 | 562 | { |
522 | 563 | global $smcFunc; |
523 | 564 | |
524 | - if (!is_array($var)) |
|
525 | - return $smcFunc['db_unescape_string']($var); |
|
565 | + if (!is_array($var)) { |
|
566 | + return $smcFunc['db_unescape_string']($var); |
|
567 | + } |
|
526 | 568 | |
527 | 569 | // Reindex the array without slashes, this time. |
528 | 570 | $new_var = array(); |
529 | 571 | |
530 | 572 | // Strip the slashes from every element. |
531 | - foreach ($var as $k => $v) |
|
532 | - $new_var[$smcFunc['db_unescape_string']($k)] = unescapestring__recursive($v); |
|
573 | + foreach ($var as $k => $v) { |
|
574 | + $new_var[$smcFunc['db_unescape_string']($k)] = unescapestring__recursive($v); |
|
575 | + } |
|
533 | 576 | |
534 | 577 | return $new_var; |
535 | 578 | } |
@@ -547,15 +590,17 @@ discard block |
||
547 | 590 | */ |
548 | 591 | function stripslashes__recursive($var, $level = 0) |
549 | 592 | { |
550 | - if (!is_array($var)) |
|
551 | - return stripslashes($var); |
|
593 | + if (!is_array($var)) { |
|
594 | + return stripslashes($var); |
|
595 | + } |
|
552 | 596 | |
553 | 597 | // Reindex the array without slashes, this time. |
554 | 598 | $new_var = array(); |
555 | 599 | |
556 | 600 | // Strip the slashes from every element. |
557 | - foreach ($var as $k => $v) |
|
558 | - $new_var[stripslashes($k)] = $level > 25 ? null : stripslashes__recursive($v, $level + 1); |
|
601 | + foreach ($var as $k => $v) { |
|
602 | + $new_var[stripslashes($k)] = $level > 25 ? null : stripslashes__recursive($v, $level + 1); |
|
603 | + } |
|
559 | 604 | |
560 | 605 | return $new_var; |
561 | 606 | } |
@@ -576,12 +621,14 @@ discard block |
||
576 | 621 | global $smcFunc; |
577 | 622 | |
578 | 623 | // Remove spaces (32), tabs (9), returns (13, 10, and 11), nulls (0), and hard spaces. (160) |
579 | - if (!is_array($var)) |
|
580 | - return isset($smcFunc) ? $smcFunc['htmltrim']($var) : trim($var, ' ' . "\t\n\r\x0B" . '\0' . "\xA0"); |
|
624 | + if (!is_array($var)) { |
|
625 | + return isset($smcFunc) ? $smcFunc['htmltrim']($var) : trim($var, ' ' . "\t\n\r\x0B" . '\0' . "\xA0"); |
|
626 | + } |
|
581 | 627 | |
582 | 628 | // Go through all the elements and remove the whitespace. |
583 | - foreach ($var as $k => $v) |
|
584 | - $var[$k] = $level > 25 ? null : htmltrim__recursive($v, $level + 1); |
|
629 | + foreach ($var as $k => $v) { |
|
630 | + $var[$k] = $level > 25 ? null : htmltrim__recursive($v, $level + 1); |
|
631 | + } |
|
585 | 632 | |
586 | 633 | return $var; |
587 | 634 | } |
@@ -646,30 +693,37 @@ discard block |
||
646 | 693 | global $scripturl, $modSettings, $context; |
647 | 694 | |
648 | 695 | // If $scripturl is set to nothing, or the SID is not defined (SSI?) just quit. |
649 | - if ($scripturl == '' || !defined('SID')) |
|
650 | - return $buffer; |
|
696 | + if ($scripturl == '' || !defined('SID')) { |
|
697 | + return $buffer; |
|
698 | + } |
|
651 | 699 | |
652 | 700 | // Do nothing if the session is cookied, or they are a crawler - guests are caught by redirectexit(). This doesn't work below PHP 4.3.0, because it makes the output buffer bigger. |
653 | 701 | // @todo smflib |
654 | - if (empty($_COOKIE) && SID != '' && !isBrowser('possibly_robot')) |
|
655 | - $buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', '"' . $scripturl . '?' . SID . '&', $buffer); |
|
702 | + if (empty($_COOKIE) && SID != '' && !isBrowser('possibly_robot')) { |
|
703 | + $buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', '"' . $scripturl . '?' . SID . '&', $buffer); |
|
704 | + } |
|
656 | 705 | // Debugging templates, are we? |
657 | - elseif (isset($_GET['debug'])) |
|
658 | - $buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '\\??/', '"' . $scripturl . '?debug;', $buffer); |
|
706 | + elseif (isset($_GET['debug'])) { |
|
707 | + $buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '\\??/', '"' . $scripturl . '?debug;', $buffer); |
|
708 | + } |
|
659 | 709 | |
660 | 710 | // This should work even in 4.2.x, just not CGI without cgi.fix_pathinfo. |
661 | 711 | if (!empty($modSettings['queryless_urls']) && (!$context['server']['is_cgi'] || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && ($context['server']['is_apache'] || $context['server']['is_lighttpd'] || $context['server']['is_litespeed'])) |
662 | 712 | { |
663 | 713 | // Let's do something special for session ids! |
664 | - if (defined('SID') && SID != '') |
|
665 | - $buffer = preg_replace_callback('~"' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#"]+?)(#[^"]*?)?"~', function($m) |
|
714 | + if (defined('SID') && SID != '') { |
|
715 | + $buffer = preg_replace_callback('~"' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#"]+?)(#[^"]*?)?"~', function($m) |
|
666 | 716 | { |
667 | - global $scripturl; return '"' . $scripturl . "/" . strtr("$m[1]", '&;=', '//,') . ".html?" . SID . (isset($m[2]) ? $m[2] : "") . '"'; |
|
717 | + global $scripturl; |
|
718 | + } |
|
719 | + return '"' . $scripturl . "/" . strtr("$m[1]", '&;=', '//,') . ".html?" . SID . (isset($m[2]) ? $m[2] : "") . '"'; |
|
668 | 720 | }, $buffer); |
669 | - else |
|
670 | - $buffer = preg_replace_callback('~"' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?"~', function($m) |
|
721 | + else { |
|
722 | + $buffer = preg_replace_callback('~"' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?"~', function($m) |
|
671 | 723 | { |
672 | - global $scripturl; return '"' . $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? $m[2] : "") . '"'; |
|
724 | + global $scripturl; |
|
725 | + } |
|
726 | + return '"' . $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? $m[2] : "") . '"'; |
|
673 | 727 | }, $buffer); |
674 | 728 | } |
675 | 729 |
@@ -1491,7 +1491,7 @@ |
||
1491 | 1491 | |
1492 | 1492 | /** |
1493 | 1493 | * Try to determine if the topic has already been deleted by another user. |
1494 | - * @return bool False if it can't be deleted (recycling not enabled or no recycling board set), true if we've confirmed it can be deleted. Dies with an error if it's already been deleted. |
|
1494 | + * @return boolean|null False if it can't be deleted (recycling not enabled or no recycling board set), true if we've confirmed it can be deleted. Dies with an error if it's already been deleted. |
|
1495 | 1495 | */ |
1496 | 1496 | function removeDeleteConcurrence() |
1497 | 1497 | { |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /* The contents of this file handle the deletion of topics, posts, and related |
21 | 22 | paraphernalia. It has the following functions: |
@@ -37,8 +38,9 @@ discard block |
||
37 | 38 | require_once($sourcedir . '/Subs-Post.php'); |
38 | 39 | |
39 | 40 | // Trying to fool us around, are we? |
40 | - if (empty($topic)) |
|
41 | - redirectexit(); |
|
41 | + if (empty($topic)) { |
|
42 | + redirectexit(); |
|
43 | + } |
|
42 | 44 | |
43 | 45 | removeDeleteConcurrence(); |
44 | 46 | |
@@ -55,20 +57,23 @@ discard block |
||
55 | 57 | list ($starter, $subject, $approved, $locked) = $smcFunc['db_fetch_row']($request); |
56 | 58 | $smcFunc['db_free_result']($request); |
57 | 59 | |
58 | - if ($starter == $user_info['id'] && !allowedTo('remove_any')) |
|
59 | - isAllowedTo('remove_own'); |
|
60 | - else |
|
61 | - isAllowedTo('remove_any'); |
|
60 | + if ($starter == $user_info['id'] && !allowedTo('remove_any')) { |
|
61 | + isAllowedTo('remove_own'); |
|
62 | + } else { |
|
63 | + isAllowedTo('remove_any'); |
|
64 | + } |
|
62 | 65 | |
63 | 66 | // Can they see the topic? |
64 | - if ($modSettings['postmod_active'] && !$approved && $starter != $user_info['id']) |
|
65 | - isAllowedTo('approve_posts'); |
|
67 | + if ($modSettings['postmod_active'] && !$approved && $starter != $user_info['id']) { |
|
68 | + isAllowedTo('approve_posts'); |
|
69 | + } |
|
66 | 70 | |
67 | 71 | // Ok, we got that far, but is it locked? |
68 | 72 | if ($locked) |
69 | 73 | { |
70 | - if (!($locked == 1 && $starter == $user_info['id'] || allowedTo('lock_any'))) |
|
71 | - fatal_lang_error('cannot_remove_locked', 'user'); |
|
74 | + if (!($locked == 1 && $starter == $user_info['id'] || allowedTo('lock_any'))) { |
|
75 | + fatal_lang_error('cannot_remove_locked', 'user'); |
|
76 | + } |
|
72 | 77 | } |
73 | 78 | |
74 | 79 | // Notify people that this topic has been removed. |
@@ -77,8 +82,9 @@ discard block |
||
77 | 82 | removeTopics($topic); |
78 | 83 | |
79 | 84 | // Note, only log topic ID in native form if it's not gone forever. |
80 | - if (allowedTo('remove_any') || (allowedTo('remove_own') && $starter == $user_info['id'])) |
|
81 | - logAction('remove', array((empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $board ? 'topic' : 'old_topic_id') => $topic, 'subject' => $subject, 'member' => $starter, 'board' => $board)); |
|
85 | + if (allowedTo('remove_any') || (allowedTo('remove_own') && $starter == $user_info['id'])) { |
|
86 | + logAction('remove', array((empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $board ? 'topic' : 'old_topic_id') => $topic, 'subject' => $subject, 'member' => $starter, 'board' => $board)); |
|
87 | + } |
|
82 | 88 | |
83 | 89 | redirectexit('board=' . $board . '.0'); |
84 | 90 | } |
@@ -96,8 +102,9 @@ discard block |
||
96 | 102 | $_REQUEST['msg'] = (int) $_REQUEST['msg']; |
97 | 103 | |
98 | 104 | // Is $topic set? |
99 | - if (empty($topic) && isset($_REQUEST['topic'])) |
|
100 | - $topic = (int) $_REQUEST['topic']; |
|
105 | + if (empty($topic) && isset($_REQUEST['topic'])) { |
|
106 | + $topic = (int) $_REQUEST['topic']; |
|
107 | + } |
|
101 | 108 | |
102 | 109 | removeDeleteConcurrence(); |
103 | 110 | |
@@ -116,44 +123,48 @@ discard block |
||
116 | 123 | $smcFunc['db_free_result']($request); |
117 | 124 | |
118 | 125 | // Verify they can see this! |
119 | - if ($modSettings['postmod_active'] && !$approved && !empty($poster) && $poster != $user_info['id']) |
|
120 | - isAllowedTo('approve_posts'); |
|
126 | + if ($modSettings['postmod_active'] && !$approved && !empty($poster) && $poster != $user_info['id']) { |
|
127 | + isAllowedTo('approve_posts'); |
|
128 | + } |
|
121 | 129 | |
122 | 130 | if ($poster == $user_info['id']) |
123 | 131 | { |
124 | 132 | if (!allowedTo('delete_own')) |
125 | 133 | { |
126 | - if ($starter == $user_info['id'] && !allowedTo('delete_any')) |
|
127 | - isAllowedTo('delete_replies'); |
|
128 | - elseif (!allowedTo('delete_any')) |
|
129 | - isAllowedTo('delete_own'); |
|
134 | + if ($starter == $user_info['id'] && !allowedTo('delete_any')) { |
|
135 | + isAllowedTo('delete_replies'); |
|
136 | + } elseif (!allowedTo('delete_any')) { |
|
137 | + isAllowedTo('delete_own'); |
|
138 | + } |
|
139 | + } elseif (!allowedTo('delete_any') && ($starter != $user_info['id'] || !allowedTo('delete_replies')) && !empty($modSettings['edit_disable_time']) && $post_time + $modSettings['edit_disable_time'] * 60 < time()) { |
|
140 | + fatal_lang_error('modify_post_time_passed', false); |
|
130 | 141 | } |
131 | - elseif (!allowedTo('delete_any') && ($starter != $user_info['id'] || !allowedTo('delete_replies')) && !empty($modSettings['edit_disable_time']) && $post_time + $modSettings['edit_disable_time'] * 60 < time()) |
|
132 | - fatal_lang_error('modify_post_time_passed', false); |
|
142 | + } elseif ($starter == $user_info['id'] && !allowedTo('delete_any')) { |
|
143 | + isAllowedTo('delete_replies'); |
|
144 | + } else { |
|
145 | + isAllowedTo('delete_any'); |
|
133 | 146 | } |
134 | - elseif ($starter == $user_info['id'] && !allowedTo('delete_any')) |
|
135 | - isAllowedTo('delete_replies'); |
|
136 | - else |
|
137 | - isAllowedTo('delete_any'); |
|
138 | 147 | |
139 | 148 | // If the full topic was removed go back to the board. |
140 | 149 | $full_topic = removeMessage($_REQUEST['msg']); |
141 | 150 | |
142 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $poster != $user_info['id'])) |
|
143 | - logAction('delete', array('topic' => $topic, 'subject' => $subject, 'member' => $poster, 'board' => $board)); |
|
151 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $poster != $user_info['id'])) { |
|
152 | + logAction('delete', array('topic' => $topic, 'subject' => $subject, 'member' => $poster, 'board' => $board)); |
|
153 | + } |
|
144 | 154 | |
145 | 155 | // We want to redirect back to recent action. |
146 | - if (isset($_REQUEST['modcenter'])) |
|
147 | - redirectexit('action=moderate;area=reportedposts;done'); |
|
148 | - elseif (isset($_REQUEST['recent'])) |
|
149 | - redirectexit('action=recent'); |
|
150 | - elseif (isset($_REQUEST['profile'], $_REQUEST['start'], $_REQUEST['u'])) |
|
151 | - redirectexit('action=profile;u=' . $_REQUEST['u'] . ';area=showposts;start=' . $_REQUEST['start']); |
|
152 | - elseif ($full_topic) |
|
153 | - redirectexit('board=' . $board . '.0'); |
|
154 | - else |
|
155 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
156 | -} |
|
156 | + if (isset($_REQUEST['modcenter'])) { |
|
157 | + redirectexit('action=moderate;area=reportedposts;done'); |
|
158 | + } elseif (isset($_REQUEST['recent'])) { |
|
159 | + redirectexit('action=recent'); |
|
160 | + } elseif (isset($_REQUEST['profile'], $_REQUEST['start'], $_REQUEST['u'])) { |
|
161 | + redirectexit('action=profile;u=' . $_REQUEST['u'] . ';area=showposts;start=' . $_REQUEST['start']); |
|
162 | + } elseif ($full_topic) { |
|
163 | + redirectexit('board=' . $board . '.0'); |
|
164 | + } else { |
|
165 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
166 | + } |
|
167 | + } |
|
157 | 168 | |
158 | 169 | /** |
159 | 170 | * So long as you are sure... all old posts will be gone. |
@@ -167,8 +178,9 @@ discard block |
||
167 | 178 | checkSession('post', 'admin'); |
168 | 179 | |
169 | 180 | // No boards at all? Forget it then :/. |
170 | - if (empty($_POST['boards'])) |
|
171 | - redirectexit('action=admin;area=maintain;sa=topics'); |
|
181 | + if (empty($_POST['boards'])) { |
|
182 | + redirectexit('action=admin;area=maintain;sa=topics'); |
|
183 | + } |
|
172 | 184 | |
173 | 185 | // This should exist, but we can make sure. |
174 | 186 | $_POST['delete_type'] = isset($_POST['delete_type']) ? $_POST['delete_type'] : 'nothing'; |
@@ -222,8 +234,9 @@ discard block |
||
222 | 234 | $condition_params |
223 | 235 | ); |
224 | 236 | $topics = array(); |
225 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
226 | - $topics[] = $row['id_topic']; |
|
237 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
238 | + $topics[] = $row['id_topic']; |
|
239 | + } |
|
227 | 240 | $smcFunc['db_free_result']($request); |
228 | 241 | |
229 | 242 | removeTopics($topics, false, true); |
@@ -247,11 +260,13 @@ discard block |
||
247 | 260 | global $sourcedir, $modSettings, $smcFunc; |
248 | 261 | |
249 | 262 | // Nothing to do? |
250 | - if (empty($topics)) |
|
251 | - return; |
|
263 | + if (empty($topics)) { |
|
264 | + return; |
|
265 | + } |
|
252 | 266 | // Only a single topic. |
253 | - if (is_numeric($topics)) |
|
254 | - $topics = array($topics); |
|
267 | + if (is_numeric($topics)) { |
|
268 | + $topics = array($topics); |
|
269 | + } |
|
255 | 270 | |
256 | 271 | $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
257 | 272 | |
@@ -276,8 +291,9 @@ discard block |
||
276 | 291 | ); |
277 | 292 | if ($smcFunc['db_num_rows']($requestMembers) > 0) |
278 | 293 | { |
279 | - while ($rowMembers = $smcFunc['db_fetch_assoc']($requestMembers)) |
|
280 | - updateMemberData($rowMembers['id_member'], array('posts' => 'posts - ' . $rowMembers['posts'])); |
|
294 | + while ($rowMembers = $smcFunc['db_fetch_assoc']($requestMembers)) { |
|
295 | + updateMemberData($rowMembers['id_member'], array('posts' => 'posts - ' . $rowMembers['posts'])); |
|
296 | + } |
|
281 | 297 | } |
282 | 298 | $smcFunc['db_free_result']($requestMembers); |
283 | 299 | } |
@@ -303,8 +319,9 @@ discard block |
||
303 | 319 | $recycleTopics = array(); |
304 | 320 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
305 | 321 | { |
306 | - if (function_exists('apache_reset_timeout')) |
|
307 | - @apache_reset_timeout(); |
|
322 | + if (function_exists('apache_reset_timeout')) { |
|
323 | + @apache_reset_timeout(); |
|
324 | + } |
|
308 | 325 | |
309 | 326 | $recycleTopics[] = $row['id_topic']; |
310 | 327 | |
@@ -346,20 +363,22 @@ discard block |
||
346 | 363 | |
347 | 364 | // Topics that were recycled don't need to be deleted, so subtract them. |
348 | 365 | $topics = array_diff($topics, $recycleTopics); |
366 | + } else { |
|
367 | + $smcFunc['db_free_result']($request); |
|
349 | 368 | } |
350 | - else |
|
351 | - $smcFunc['db_free_result']($request); |
|
352 | 369 | } |
353 | 370 | |
354 | 371 | // Still topics left to delete? |
355 | - if (empty($topics)) |
|
356 | - return; |
|
372 | + if (empty($topics)) { |
|
373 | + return; |
|
374 | + } |
|
357 | 375 | |
358 | 376 | // Callback for search APIs to do their thing |
359 | 377 | require_once($sourcedir . '/Search.php'); |
360 | 378 | $searchAPI = findSearchAPI(); |
361 | - if ($searchAPI->supportsMethod('topicsRemoved')) |
|
362 | - $searchAPI->topicsRemoved($topics); |
|
379 | + if ($searchAPI->supportsMethod('topicsRemoved')) { |
|
380 | + $searchAPI->topicsRemoved($topics); |
|
381 | + } |
|
363 | 382 | |
364 | 383 | $adjustBoards = array(); |
365 | 384 | |
@@ -391,10 +410,11 @@ discard block |
||
391 | 410 | $adjustBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts']; |
392 | 411 | |
393 | 412 | // Add the topics to the right type. |
394 | - if ($row['approved']) |
|
395 | - $adjustBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
396 | - else |
|
397 | - $adjustBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
413 | + if ($row['approved']) { |
|
414 | + $adjustBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
415 | + } else { |
|
416 | + $adjustBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
417 | + } |
|
398 | 418 | } |
399 | 419 | $smcFunc['db_free_result']($request); |
400 | 420 | |
@@ -403,8 +423,9 @@ discard block |
||
403 | 423 | // Decrease the posts/topics... |
404 | 424 | foreach ($adjustBoards as $stats) |
405 | 425 | { |
406 | - if (function_exists('apache_reset_timeout')) |
|
407 | - @apache_reset_timeout(); |
|
426 | + if (function_exists('apache_reset_timeout')) { |
|
427 | + @apache_reset_timeout(); |
|
428 | + } |
|
408 | 429 | |
409 | 430 | $smcFunc['db_query']('', ' |
410 | 431 | UPDATE {db_prefix}boards |
@@ -438,8 +459,9 @@ discard block |
||
438 | 459 | ) |
439 | 460 | ); |
440 | 461 | $polls = array(); |
441 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
442 | - $polls[] = $row['id_poll']; |
|
462 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
463 | + $polls[] = $row['id_poll']; |
|
464 | + } |
|
443 | 465 | $smcFunc['db_free_result']($request); |
444 | 466 | |
445 | 467 | if (!empty($polls)) |
@@ -492,8 +514,9 @@ discard block |
||
492 | 514 | ); |
493 | 515 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
494 | 516 | { |
495 | - if (function_exists('apache_reset_timeout')) |
|
496 | - @apache_reset_timeout(); |
|
517 | + if (function_exists('apache_reset_timeout')) { |
|
518 | + @apache_reset_timeout(); |
|
519 | + } |
|
497 | 520 | |
498 | 521 | $words = array_merge($words, text2words($row['body'], $customIndexSettings['bytes_per_word'], true)); |
499 | 522 | $messages[] = $row['id_msg']; |
@@ -501,8 +524,8 @@ discard block |
||
501 | 524 | $smcFunc['db_free_result']($request); |
502 | 525 | $words = array_unique($words); |
503 | 526 | |
504 | - if (!empty($words) && !empty($messages)) |
|
505 | - $smcFunc['db_query']('', ' |
|
527 | + if (!empty($words) && !empty($messages)) { |
|
528 | + $smcFunc['db_query']('', ' |
|
506 | 529 | DELETE FROM {db_prefix}log_search_words |
507 | 530 | WHERE id_word IN ({array_int:word_list}) |
508 | 531 | AND id_msg IN ({array_int:message_list})', |
@@ -511,6 +534,7 @@ discard block |
||
511 | 534 | 'message_list' => $messages, |
512 | 535 | ) |
513 | 536 | ); |
537 | + } |
|
514 | 538 | } |
515 | 539 | |
516 | 540 | // Delete anything related to the topic. |
@@ -569,8 +593,9 @@ discard block |
||
569 | 593 | |
570 | 594 | require_once($sourcedir . '/Subs-Post.php'); |
571 | 595 | $updates = array(); |
572 | - foreach ($adjustBoards as $stats) |
|
573 | - $updates[] = $stats['id_board']; |
|
596 | + foreach ($adjustBoards as $stats) { |
|
597 | + $updates[] = $stats['id_board']; |
|
598 | + } |
|
574 | 599 | updateLastMessages($updates); |
575 | 600 | } |
576 | 601 | |
@@ -587,8 +612,9 @@ discard block |
||
587 | 612 | { |
588 | 613 | global $board, $sourcedir, $modSettings, $user_info, $smcFunc; |
589 | 614 | |
590 | - if (empty($message) || !is_numeric($message)) |
|
591 | - return false; |
|
615 | + if (empty($message) || !is_numeric($message)) { |
|
616 | + return false; |
|
617 | + } |
|
592 | 618 | |
593 | 619 | $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
594 | 620 | |
@@ -607,8 +633,9 @@ discard block |
||
607 | 633 | 'id_msg' => $message, |
608 | 634 | ) |
609 | 635 | ); |
610 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
611 | - return false; |
|
636 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
637 | + return false; |
|
638 | + } |
|
612 | 639 | $row = $smcFunc['db_fetch_assoc']($request); |
613 | 640 | $smcFunc['db_free_result']($request); |
614 | 641 | |
@@ -629,54 +656,57 @@ discard block |
||
629 | 656 | { |
630 | 657 | if ($row['id_member_poster'] == $user_info['id']) |
631 | 658 | { |
632 | - if (!$delete_replies) |
|
633 | - fatal_lang_error('cannot_delete_replies', 'permission'); |
|
659 | + if (!$delete_replies) { |
|
660 | + fatal_lang_error('cannot_delete_replies', 'permission'); |
|
661 | + } |
|
662 | + } else { |
|
663 | + fatal_lang_error('cannot_delete_own', 'permission'); |
|
634 | 664 | } |
635 | - else |
|
636 | - fatal_lang_error('cannot_delete_own', 'permission'); |
|
665 | + } elseif (($row['id_member_poster'] != $user_info['id'] || !$delete_replies) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) { |
|
666 | + fatal_lang_error('modify_post_time_passed', false); |
|
637 | 667 | } |
638 | - elseif (($row['id_member_poster'] != $user_info['id'] || !$delete_replies) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) |
|
639 | - fatal_lang_error('modify_post_time_passed', false); |
|
640 | - } |
|
641 | - elseif ($row['id_member_poster'] == $user_info['id']) |
|
668 | + } elseif ($row['id_member_poster'] == $user_info['id']) |
|
642 | 669 | { |
643 | - if (!$delete_replies) |
|
644 | - fatal_lang_error('cannot_delete_replies', 'permission'); |
|
670 | + if (!$delete_replies) { |
|
671 | + fatal_lang_error('cannot_delete_replies', 'permission'); |
|
672 | + } |
|
673 | + } else { |
|
674 | + fatal_lang_error('cannot_delete_any', 'permission'); |
|
645 | 675 | } |
646 | - else |
|
647 | - fatal_lang_error('cannot_delete_any', 'permission'); |
|
648 | 676 | } |
649 | 677 | |
650 | 678 | // Can't delete an unapproved message, if you can't see it! |
651 | 679 | if ($modSettings['postmod_active'] && !$row['approved'] && $row['id_member'] != $user_info['id'] && !(in_array(0, $delete_any) || in_array($row['id_board'], $delete_any))) |
652 | 680 | { |
653 | 681 | $approve_posts = boardsAllowedTo('approve_posts'); |
654 | - if (!in_array(0, $approve_posts) && !in_array($row['id_board'], $approve_posts)) |
|
655 | - return false; |
|
682 | + if (!in_array(0, $approve_posts) && !in_array($row['id_board'], $approve_posts)) { |
|
683 | + return false; |
|
684 | + } |
|
656 | 685 | } |
657 | - } |
|
658 | - else |
|
686 | + } else |
|
659 | 687 | { |
660 | 688 | // Check permissions to delete this message. |
661 | 689 | if ($row['id_member'] == $user_info['id']) |
662 | 690 | { |
663 | 691 | if (!allowedTo('delete_own')) |
664 | 692 | { |
665 | - if ($row['id_member_poster'] == $user_info['id'] && !allowedTo('delete_any')) |
|
666 | - isAllowedTo('delete_replies'); |
|
667 | - elseif (!allowedTo('delete_any')) |
|
668 | - isAllowedTo('delete_own'); |
|
693 | + if ($row['id_member_poster'] == $user_info['id'] && !allowedTo('delete_any')) { |
|
694 | + isAllowedTo('delete_replies'); |
|
695 | + } elseif (!allowedTo('delete_any')) { |
|
696 | + isAllowedTo('delete_own'); |
|
697 | + } |
|
698 | + } elseif (!allowedTo('delete_any') && ($row['id_member_poster'] != $user_info['id'] || !allowedTo('delete_replies')) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) { |
|
699 | + fatal_lang_error('modify_post_time_passed', false); |
|
669 | 700 | } |
670 | - elseif (!allowedTo('delete_any') && ($row['id_member_poster'] != $user_info['id'] || !allowedTo('delete_replies')) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) |
|
671 | - fatal_lang_error('modify_post_time_passed', false); |
|
701 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('delete_any')) { |
|
702 | + isAllowedTo('delete_replies'); |
|
703 | + } else { |
|
704 | + isAllowedTo('delete_any'); |
|
672 | 705 | } |
673 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('delete_any')) |
|
674 | - isAllowedTo('delete_replies'); |
|
675 | - else |
|
676 | - isAllowedTo('delete_any'); |
|
677 | 706 | |
678 | - if ($modSettings['postmod_active'] && !$row['approved'] && $row['id_member'] != $user_info['id'] && !allowedTo('delete_own')) |
|
679 | - isAllowedTo('approve_posts'); |
|
707 | + if ($modSettings['postmod_active'] && !$row['approved'] && $row['id_member'] != $user_info['id'] && !allowedTo('delete_own')) { |
|
708 | + isAllowedTo('approve_posts'); |
|
709 | + } |
|
680 | 710 | } |
681 | 711 | |
682 | 712 | // Delete the *whole* topic, but only if the topic consists of one message. |
@@ -692,31 +722,34 @@ discard block |
||
692 | 722 | $remove_own = in_array(0, $remove_own) || in_array($row['id_board'], $remove_own); |
693 | 723 | } |
694 | 724 | |
695 | - if ($row['id_member'] != $user_info['id'] && !$remove_any) |
|
696 | - fatal_lang_error('cannot_remove_any', 'permission'); |
|
697 | - elseif (!$remove_any && !$remove_own) |
|
698 | - fatal_lang_error('cannot_remove_own', 'permission'); |
|
699 | - } |
|
700 | - else |
|
725 | + if ($row['id_member'] != $user_info['id'] && !$remove_any) { |
|
726 | + fatal_lang_error('cannot_remove_any', 'permission'); |
|
727 | + } elseif (!$remove_any && !$remove_own) { |
|
728 | + fatal_lang_error('cannot_remove_own', 'permission'); |
|
729 | + } |
|
730 | + } else |
|
701 | 731 | { |
702 | 732 | // Check permissions to delete a whole topic. |
703 | - if ($row['id_member'] != $user_info['id']) |
|
704 | - isAllowedTo('remove_any'); |
|
705 | - elseif (!allowedTo('remove_any')) |
|
706 | - isAllowedTo('remove_own'); |
|
733 | + if ($row['id_member'] != $user_info['id']) { |
|
734 | + isAllowedTo('remove_any'); |
|
735 | + } elseif (!allowedTo('remove_any')) { |
|
736 | + isAllowedTo('remove_own'); |
|
737 | + } |
|
707 | 738 | } |
708 | 739 | |
709 | 740 | // ...if there is only one post. |
710 | - if (!empty($row['num_replies'])) |
|
711 | - fatal_lang_error('delFirstPost', false); |
|
741 | + if (!empty($row['num_replies'])) { |
|
742 | + fatal_lang_error('delFirstPost', false); |
|
743 | + } |
|
712 | 744 | |
713 | 745 | removeTopics($row['id_topic']); |
714 | 746 | return true; |
715 | 747 | } |
716 | 748 | |
717 | 749 | // Deleting a recycled message can not lower anyone's post count. |
718 | - if (!empty($recycle_board) && $row['id_board'] == $recycle_board) |
|
719 | - $decreasePostCount = false; |
|
750 | + if (!empty($recycle_board) && $row['id_board'] == $recycle_board) { |
|
751 | + $decreasePostCount = false; |
|
752 | + } |
|
720 | 753 | |
721 | 754 | // This is the last post, update the last post on the board. |
722 | 755 | if ($row['id_last_msg'] == $message) |
@@ -755,8 +788,8 @@ discard block |
||
755 | 788 | ); |
756 | 789 | } |
757 | 790 | // Only decrease post counts. |
758 | - else |
|
759 | - $smcFunc['db_query']('', ' |
|
791 | + else { |
|
792 | + $smcFunc['db_query']('', ' |
|
760 | 793 | UPDATE {db_prefix}topics |
761 | 794 | SET ' . ($row['approved'] ? ' |
762 | 795 | num_replies = CASE WHEN num_replies = {int:no_replies} THEN 0 ELSE num_replies - 1 END' : ' |
@@ -768,6 +801,7 @@ discard block |
||
768 | 801 | 'id_topic' => $row['id_topic'], |
769 | 802 | ) |
770 | 803 | ); |
804 | + } |
|
771 | 805 | |
772 | 806 | // Default recycle to false. |
773 | 807 | $recycle = false; |
@@ -787,8 +821,9 @@ discard block |
||
787 | 821 | 'recycle_board' => $modSettings['recycle_board'], |
788 | 822 | ) |
789 | 823 | ); |
790 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
791 | - fatal_lang_error('recycle_no_valid_board'); |
|
824 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
825 | + fatal_lang_error('recycle_no_valid_board'); |
|
826 | + } |
|
792 | 827 | list ($isRead, $last_board_msg) = $smcFunc['db_fetch_row']($request); |
793 | 828 | $smcFunc['db_free_result']($request); |
794 | 829 | |
@@ -807,8 +842,8 @@ discard block |
||
807 | 842 | $smcFunc['db_free_result']($request); |
808 | 843 | |
809 | 844 | // Insert a new topic in the recycle board if $id_recycle_topic is empty. |
810 | - if (empty($id_recycle_topic)) |
|
811 | - $id_topic = $smcFunc['db_insert']('', |
|
845 | + if (empty($id_recycle_topic)) { |
|
846 | + $id_topic = $smcFunc['db_insert']('', |
|
812 | 847 | '{db_prefix}topics', |
813 | 848 | array( |
814 | 849 | 'id_board' => 'int', 'id_member_started' => 'int', 'id_member_updated' => 'int', 'id_first_msg' => 'int', |
@@ -821,6 +856,7 @@ discard block |
||
821 | 856 | array('id_topic'), |
822 | 857 | 1 |
823 | 858 | ); |
859 | + } |
|
824 | 860 | |
825 | 861 | // Capture the ID of the new topic... |
826 | 862 | $topicID = empty($id_recycle_topic) ? $id_topic : $id_recycle_topic; |
@@ -858,22 +894,24 @@ discard block |
||
858 | 894 | ); |
859 | 895 | |
860 | 896 | // Mark recycled topic as read. |
861 | - if (!$user_info['is_guest']) |
|
862 | - $smcFunc['db_insert']('replace', |
|
897 | + if (!$user_info['is_guest']) { |
|
898 | + $smcFunc['db_insert']('replace', |
|
863 | 899 | '{db_prefix}log_topics', |
864 | 900 | array('id_topic' => 'int', 'id_member' => 'int', 'id_msg' => 'int', 'unwatched' => 'int'), |
865 | 901 | array($topicID, $user_info['id'], $modSettings['maxMsgID'], 0), |
866 | 902 | array('id_topic', 'id_member') |
867 | 903 | ); |
904 | + } |
|
868 | 905 | |
869 | 906 | // Mark recycle board as seen, if it was marked as seen before. |
870 | - if (!empty($isRead) && !$user_info['is_guest']) |
|
871 | - $smcFunc['db_insert']('replace', |
|
907 | + if (!empty($isRead) && !$user_info['is_guest']) { |
|
908 | + $smcFunc['db_insert']('replace', |
|
872 | 909 | '{db_prefix}log_boards', |
873 | 910 | array('id_board' => 'int', 'id_member' => 'int', 'id_msg' => 'int'), |
874 | 911 | array($modSettings['recycle_board'], $user_info['id'], $modSettings['maxMsgID']), |
875 | 912 | array('id_board', 'id_member') |
876 | 913 | ); |
914 | + } |
|
877 | 915 | |
878 | 916 | // Add one topic and post to the recycle bin board. |
879 | 917 | $smcFunc['db_query']('', ' |
@@ -891,8 +929,8 @@ discard block |
||
891 | 929 | ); |
892 | 930 | |
893 | 931 | // Lets increase the num_replies, and the first/last message ID as appropriate. |
894 | - if (!empty($id_recycle_topic)) |
|
895 | - $smcFunc['db_query']('', ' |
|
932 | + if (!empty($id_recycle_topic)) { |
|
933 | + $smcFunc['db_query']('', ' |
|
896 | 934 | UPDATE {db_prefix}topics |
897 | 935 | SET num_replies = num_replies + 1' . |
898 | 936 | ($message > $last_topic_msg ? ', id_last_msg = {int:id_merged_msg}' : '') . |
@@ -903,6 +941,7 @@ discard block |
||
903 | 941 | 'id_merged_msg' => $message, |
904 | 942 | ) |
905 | 943 | ); |
944 | + } |
|
906 | 945 | |
907 | 946 | // Make sure this message isn't getting deleted later on. |
908 | 947 | $recycle = true; |
@@ -912,8 +951,8 @@ discard block |
||
912 | 951 | } |
913 | 952 | |
914 | 953 | // If it wasn't approved don't keep it in the queue. |
915 | - if (!$row['approved']) |
|
916 | - $smcFunc['db_query']('', ' |
|
954 | + if (!$row['approved']) { |
|
955 | + $smcFunc['db_query']('', ' |
|
917 | 956 | DELETE FROM {db_prefix}approval_queue |
918 | 957 | WHERE id_msg = {int:id_msg} |
919 | 958 | AND id_attach = {int:id_attach}', |
@@ -922,6 +961,7 @@ discard block |
||
922 | 961 | 'id_attach' => 0, |
923 | 962 | ) |
924 | 963 | ); |
964 | + } |
|
925 | 965 | } |
926 | 966 | |
927 | 967 | $smcFunc['db_query']('', ' |
@@ -939,8 +979,9 @@ discard block |
||
939 | 979 | |
940 | 980 | // If the poster was registered and the board this message was on incremented |
941 | 981 | // the member's posts when it was posted, decrease his or her post count. |
942 | - if (!empty($row['id_member']) && $decreasePostCount && empty($row['count_posts']) && $row['approved']) |
|
943 | - updateMemberData($row['id_member'], array('posts' => '-')); |
|
982 | + if (!empty($row['id_member']) && $decreasePostCount && empty($row['count_posts']) && $row['approved']) { |
|
983 | + updateMemberData($row['id_member'], array('posts' => '-')); |
|
984 | + } |
|
944 | 985 | |
945 | 986 | // Only remove posts if they're not recycled. |
946 | 987 | if (!$recycle) |
@@ -948,8 +989,9 @@ discard block |
||
948 | 989 | // Callback for search APIs to do their thing |
949 | 990 | require_once($sourcedir . '/Search.php'); |
950 | 991 | $searchAPI = findSearchAPI(); |
951 | - if ($searchAPI->supportsMethod('postRemoved')) |
|
952 | - $searchAPI->postRemoved($message); |
|
992 | + if ($searchAPI->supportsMethod('postRemoved')) { |
|
993 | + $searchAPI->postRemoved($message); |
|
994 | + } |
|
953 | 995 | |
954 | 996 | // Remove the message! |
955 | 997 | $smcFunc['db_query']('', ' |
@@ -964,8 +1006,8 @@ discard block |
||
964 | 1006 | { |
965 | 1007 | $customIndexSettings = smf_json_decode($modSettings['search_custom_index_config'], true); |
966 | 1008 | $words = text2words($row['body'], $customIndexSettings['bytes_per_word'], true); |
967 | - if (!empty($words)) |
|
968 | - $smcFunc['db_query']('', ' |
|
1009 | + if (!empty($words)) { |
|
1010 | + $smcFunc['db_query']('', ' |
|
969 | 1011 | DELETE FROM {db_prefix}log_search_words |
970 | 1012 | WHERE id_word IN ({array_int:word_list}) |
971 | 1013 | AND id_msg = {int:id_msg}', |
@@ -974,6 +1016,7 @@ discard block |
||
974 | 1016 | 'id_msg' => $message, |
975 | 1017 | ) |
976 | 1018 | ); |
1019 | + } |
|
977 | 1020 | } |
978 | 1021 | |
979 | 1022 | // Delete attachment(s) if they exist. |
@@ -997,10 +1040,11 @@ discard block |
||
997 | 1040 | |
998 | 1041 | // And now to update the last message of each board we messed with. |
999 | 1042 | require_once($sourcedir . '/Subs-Post.php'); |
1000 | - if ($recycle) |
|
1001 | - updateLastMessages(array($row['id_board'], $modSettings['recycle_board'])); |
|
1002 | - else |
|
1003 | - updateLastMessages($row['id_board']); |
|
1043 | + if ($recycle) { |
|
1044 | + updateLastMessages(array($row['id_board'], $modSettings['recycle_board'])); |
|
1045 | + } else { |
|
1046 | + updateLastMessages($row['id_board']); |
|
1047 | + } |
|
1004 | 1048 | |
1005 | 1049 | // Close any moderation reports for this message. |
1006 | 1050 | $smcFunc['db_query']('', ' |
@@ -1033,8 +1077,9 @@ discard block |
||
1033 | 1077 | checkSession('get'); |
1034 | 1078 | |
1035 | 1079 | // Is recycled board enabled? |
1036 | - if (empty($modSettings['recycle_enable'])) |
|
1037 | - fatal_lang_error('restored_disabled', 'critical'); |
|
1080 | + if (empty($modSettings['recycle_enable'])) { |
|
1081 | + fatal_lang_error('restored_disabled', 'critical'); |
|
1082 | + } |
|
1038 | 1083 | |
1039 | 1084 | // Can we be in here? |
1040 | 1085 | isAllowedTo('move_any', $modSettings['recycle_board']); |
@@ -1049,8 +1094,9 @@ discard block |
||
1049 | 1094 | if (!empty($_REQUEST['msgs'])) |
1050 | 1095 | { |
1051 | 1096 | $msgs = explode(',', $_REQUEST['msgs']); |
1052 | - foreach ($msgs as $k => $msg) |
|
1053 | - $msgs[$k] = (int) $msg; |
|
1097 | + foreach ($msgs as $k => $msg) { |
|
1098 | + $msgs[$k] = (int) $msg; |
|
1099 | + } |
|
1054 | 1100 | |
1055 | 1101 | // Get the id_previous_board and id_previous_topic. |
1056 | 1102 | $request = $smcFunc['db_query']('', ' |
@@ -1084,8 +1130,8 @@ discard block |
||
1084 | 1130 | } |
1085 | 1131 | |
1086 | 1132 | $previous_topics[] = $row['id_previous_topic']; |
1087 | - if (empty($actioned_messages[$row['id_previous_topic']])) |
|
1088 | - $actioned_messages[$row['id_previous_topic']] = array( |
|
1133 | + if (empty($actioned_messages[$row['id_previous_topic']])) { |
|
1134 | + $actioned_messages[$row['id_previous_topic']] = array( |
|
1089 | 1135 | 'msgs' => array(), |
1090 | 1136 | 'count_posts' => $row['count_posts'], |
1091 | 1137 | 'subject' => $row['subject'], |
@@ -1095,17 +1141,20 @@ discard block |
||
1095 | 1141 | 'current_board' => $row['id_board'], |
1096 | 1142 | 'members' => array(), |
1097 | 1143 | ); |
1144 | + } |
|
1098 | 1145 | |
1099 | 1146 | $actioned_messages[$row['id_previous_topic']]['msgs'][$row['id_msg']] = $row['subject']; |
1100 | - if ($row['id_member']) |
|
1101 | - $actioned_messages[$row['id_previous_topic']]['members'][] = $row['id_member']; |
|
1147 | + if ($row['id_member']) { |
|
1148 | + $actioned_messages[$row['id_previous_topic']]['members'][] = $row['id_member']; |
|
1149 | + } |
|
1102 | 1150 | } |
1103 | 1151 | $smcFunc['db_free_result']($request); |
1104 | 1152 | |
1105 | 1153 | // Check for topics we are going to fully restore. |
1106 | - foreach ($actioned_messages as $topic => $data) |
|
1107 | - if (in_array($topic, $topics_to_restore)) |
|
1154 | + foreach ($actioned_messages as $topic => $data) { |
|
1155 | + if (in_array($topic, $topics_to_restore)) |
|
1108 | 1156 | unset($actioned_messages[$topic]); |
1157 | + } |
|
1109 | 1158 | |
1110 | 1159 | // Load any previous topics to check they exist. |
1111 | 1160 | if (!empty($previous_topics)) |
@@ -1120,11 +1169,12 @@ discard block |
||
1120 | 1169 | ) |
1121 | 1170 | ); |
1122 | 1171 | $previous_topics = array(); |
1123 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1124 | - $previous_topics[$row['id_topic']] = array( |
|
1172 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1173 | + $previous_topics[$row['id_topic']] = array( |
|
1125 | 1174 | 'board' => $row['id_board'], |
1126 | 1175 | 'subject' => $row['subject'], |
1127 | 1176 | ); |
1177 | + } |
|
1128 | 1178 | $smcFunc['db_free_result']($request); |
1129 | 1179 | } |
1130 | 1180 | |
@@ -1146,11 +1196,11 @@ discard block |
||
1146 | 1196 | // Log em. |
1147 | 1197 | logAction('restore_posts', array('topic' => $topic, 'subject' => $previous_topics[$topic]['subject'], 'board' => empty($data['previous_board']) ? $data['possible_prev_board'] : $data['previous_board'])); |
1148 | 1198 | $messages = array_merge(array_keys($data['msgs']), $messages); |
1149 | - } |
|
1150 | - else |
|
1199 | + } else |
|
1151 | 1200 | { |
1152 | - foreach ($data['msgs'] as $msg) |
|
1153 | - $unfound_messages[$msg['id']] = $msg['subject']; |
|
1201 | + foreach ($data['msgs'] as $msg) { |
|
1202 | + $unfound_messages[$msg['id']] = $msg['subject']; |
|
1203 | + } |
|
1154 | 1204 | } |
1155 | 1205 | } |
1156 | 1206 | } |
@@ -1159,8 +1209,9 @@ discard block |
||
1159 | 1209 | if (!empty($_REQUEST['topics'])) |
1160 | 1210 | { |
1161 | 1211 | $topics = explode(',', $_REQUEST['topics']); |
1162 | - foreach ($topics as $id) |
|
1163 | - $topics_to_restore[] = (int) $id; |
|
1212 | + foreach ($topics as $id) { |
|
1213 | + $topics_to_restore[] = (int) $id; |
|
1214 | + } |
|
1164 | 1215 | } |
1165 | 1216 | |
1166 | 1217 | if (!empty($topics_to_restore)) |
@@ -1214,8 +1265,9 @@ discard block |
||
1214 | 1265 | ) |
1215 | 1266 | ); |
1216 | 1267 | |
1217 | - while ($member = $smcFunc['db_fetch_assoc']($request2)) |
|
1218 | - updateMemberData($member['id_member'], array('posts' => 'posts + ' . $member['post_count'])); |
|
1268 | + while ($member = $smcFunc['db_fetch_assoc']($request2)) { |
|
1269 | + updateMemberData($member['id_member'], array('posts' => 'posts + ' . $member['post_count'])); |
|
1270 | + } |
|
1219 | 1271 | $smcFunc['db_free_result']($request2); |
1220 | 1272 | } |
1221 | 1273 | |
@@ -1226,8 +1278,9 @@ discard block |
||
1226 | 1278 | } |
1227 | 1279 | |
1228 | 1280 | // Didn't find some things? |
1229 | - if (!empty($unfound_messages)) |
|
1230 | - fatal_lang_error('restore_not_found', false, array(implode('<br>', $unfound_messages))); |
|
1281 | + if (!empty($unfound_messages)) { |
|
1282 | + fatal_lang_error('restore_not_found', false, array(implode('<br>', $unfound_messages))); |
|
1283 | + } |
|
1231 | 1284 | |
1232 | 1285 | // Just send them to the index if they get here. |
1233 | 1286 | redirectexit(); |
@@ -1247,12 +1300,14 @@ discard block |
||
1247 | 1300 | //!!! This really needs to be rewritten to take a load of messages from ANY topic, it's also inefficient. |
1248 | 1301 | |
1249 | 1302 | // Is it an array? |
1250 | - if (!is_array($msgs)) |
|
1251 | - $msgs = array($msgs); |
|
1303 | + if (!is_array($msgs)) { |
|
1304 | + $msgs = array($msgs); |
|
1305 | + } |
|
1252 | 1306 | |
1253 | 1307 | // Lets make sure they are int. |
1254 | - foreach ($msgs as $key => $msg) |
|
1255 | - $msgs[$key] = (int) $msg; |
|
1308 | + foreach ($msgs as $key => $msg) { |
|
1309 | + $msgs[$key] = (int) $msg; |
|
1310 | + } |
|
1256 | 1311 | |
1257 | 1312 | // Get the source information. |
1258 | 1313 | $request = $smcFunc['db_query']('', ' |
@@ -1295,8 +1350,9 @@ discard block |
||
1295 | 1350 | ) |
1296 | 1351 | ); |
1297 | 1352 | |
1298 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1299 | - updateMemberData($row['id_member'], array('posts' => '+')); |
|
1353 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1354 | + updateMemberData($row['id_member'], array('posts' => '+')); |
|
1355 | + } |
|
1300 | 1356 | } |
1301 | 1357 | |
1302 | 1358 | // Time to move the messages. |
@@ -1332,13 +1388,15 @@ discard block |
||
1332 | 1388 | ); |
1333 | 1389 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1334 | 1390 | { |
1335 | - if ($row['id_first_msg'] < $target_topic_data['id_first_msg']) |
|
1336 | - $target_topic_data['id_first_msg'] = $row['id_first_msg']; |
|
1391 | + if ($row['id_first_msg'] < $target_topic_data['id_first_msg']) { |
|
1392 | + $target_topic_data['id_first_msg'] = $row['id_first_msg']; |
|
1393 | + } |
|
1337 | 1394 | $target_topic_data['id_last_msg'] = $row['id_last_msg']; |
1338 | - if (!$row['approved']) |
|
1339 | - $target_topic_data['unapproved_posts'] = $row['message_count']; |
|
1340 | - else |
|
1341 | - $target_topic_data['num_replies'] = max(0, $row['message_count'] - 1); |
|
1395 | + if (!$row['approved']) { |
|
1396 | + $target_topic_data['unapproved_posts'] = $row['message_count']; |
|
1397 | + } else { |
|
1398 | + $target_topic_data['num_replies'] = max(0, $row['message_count'] - 1); |
|
1399 | + } |
|
1342 | 1400 | } |
1343 | 1401 | $smcFunc['db_free_result']($request); |
1344 | 1402 | |
@@ -1397,13 +1455,15 @@ discard block |
||
1397 | 1455 | ); |
1398 | 1456 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1399 | 1457 | { |
1400 | - if ($row['id_first_msg'] < $source_topic_data['id_first_msg']) |
|
1401 | - $source_topic_data['id_first_msg'] = $row['id_first_msg']; |
|
1458 | + if ($row['id_first_msg'] < $source_topic_data['id_first_msg']) { |
|
1459 | + $source_topic_data['id_first_msg'] = $row['id_first_msg']; |
|
1460 | + } |
|
1402 | 1461 | $source_topic_data['id_last_msg'] = $row['id_last_msg']; |
1403 | - if (!$row['approved']) |
|
1404 | - $source_topic_data['unapproved_posts'] = $row['message_count']; |
|
1405 | - else |
|
1406 | - $source_topic_data['num_replies'] = max(0, $row['message_count'] - 1); |
|
1462 | + if (!$row['approved']) { |
|
1463 | + $source_topic_data['unapproved_posts'] = $row['message_count']; |
|
1464 | + } else { |
|
1465 | + $source_topic_data['num_replies'] = max(0, $row['message_count'] - 1); |
|
1466 | + } |
|
1407 | 1467 | } |
1408 | 1468 | $smcFunc['db_free_result']($request); |
1409 | 1469 | |
@@ -1467,10 +1527,12 @@ discard block |
||
1467 | 1527 | |
1468 | 1528 | // Subject cache? |
1469 | 1529 | $cache_updates = array(); |
1470 | - if ($target_first_msg != $target_topic_data['id_first_msg']) |
|
1471 | - $cache_updates[] = $target_topic_data['id_first_msg']; |
|
1472 | - if (!empty($source_topic_data['id_first_msg']) && $from_first_msg != $source_topic_data['id_first_msg']) |
|
1473 | - $cache_updates[] = $source_topic_data['id_first_msg']; |
|
1530 | + if ($target_first_msg != $target_topic_data['id_first_msg']) { |
|
1531 | + $cache_updates[] = $target_topic_data['id_first_msg']; |
|
1532 | + } |
|
1533 | + if (!empty($source_topic_data['id_first_msg']) && $from_first_msg != $source_topic_data['id_first_msg']) { |
|
1534 | + $cache_updates[] = $source_topic_data['id_first_msg']; |
|
1535 | + } |
|
1474 | 1536 | |
1475 | 1537 | if (!empty($cache_updates)) |
1476 | 1538 | { |
@@ -1482,8 +1544,9 @@ discard block |
||
1482 | 1544 | 'first_messages' => $cache_updates, |
1483 | 1545 | ) |
1484 | 1546 | ); |
1485 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1486 | - updateStats('subject', $row['id_topic'], $row['subject']); |
|
1547 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1548 | + updateStats('subject', $row['id_topic'], $row['subject']); |
|
1549 | + } |
|
1487 | 1550 | $smcFunc['db_free_result']($request); |
1488 | 1551 | } |
1489 | 1552 | |
@@ -1499,22 +1562,26 @@ discard block |
||
1499 | 1562 | global $modSettings, $board, $scripturl, $context; |
1500 | 1563 | |
1501 | 1564 | // No recycle no need to go further |
1502 | - if (empty($modSettings['recycle_enable']) || empty($modSettings['recycle_board'])) |
|
1503 | - return false; |
|
1565 | + if (empty($modSettings['recycle_enable']) || empty($modSettings['recycle_board'])) { |
|
1566 | + return false; |
|
1567 | + } |
|
1504 | 1568 | |
1505 | 1569 | // If it's confirmed go on and delete (from recycle) |
1506 | - if (isset($_GET['confirm_delete'])) |
|
1507 | - return true; |
|
1570 | + if (isset($_GET['confirm_delete'])) { |
|
1571 | + return true; |
|
1572 | + } |
|
1508 | 1573 | |
1509 | - if (empty($board)) |
|
1510 | - return false; |
|
1574 | + if (empty($board)) { |
|
1575 | + return false; |
|
1576 | + } |
|
1511 | 1577 | |
1512 | - if ($modSettings['recycle_board'] != $board) |
|
1513 | - return true; |
|
1514 | - elseif (isset($_REQUEST['msg'])) |
|
1515 | - $confirm_url = $scripturl . '?action=deletemsg;confirm_delete;topic=' . $context['current_topic'] . '.0;msg=' . $_REQUEST['msg'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
|
1516 | - else |
|
1517 | - $confirm_url = $scripturl . '?action=removetopic2;confirm_delete;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']; |
|
1578 | + if ($modSettings['recycle_board'] != $board) { |
|
1579 | + return true; |
|
1580 | + } elseif (isset($_REQUEST['msg'])) { |
|
1581 | + $confirm_url = $scripturl . '?action=deletemsg;confirm_delete;topic=' . $context['current_topic'] . '.0;msg=' . $_REQUEST['msg'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
|
1582 | + } else { |
|
1583 | + $confirm_url = $scripturl . '?action=removetopic2;confirm_delete;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']; |
|
1584 | + } |
|
1518 | 1585 | |
1519 | 1586 | fatal_lang_error('post_already_deleted', false, array($confirm_url)); |
1520 | 1587 | } |
@@ -1013,7 +1013,7 @@ |
||
1013 | 1013 | * @param string $title The title of the separator |
1014 | 1014 | * @param null|string $custom_table The ID of the custom table |
1015 | 1015 | * |
1016 | - * @return void|bool Returns false if there are no tables |
|
1016 | + * @return null|false Returns false if there are no tables |
|
1017 | 1017 | */ |
1018 | 1018 | function addSeparator($title = '', $custom_table = null) |
1019 | 1019 | { |
@@ -21,8 +21,9 @@ discard block |
||
21 | 21 | * @version 2.1 Beta 3 |
22 | 22 | */ |
23 | 23 | |
24 | -if (!defined('SMF')) |
|
24 | +if (!defined('SMF')) { |
|
25 | 25 | die('No direct access...'); |
26 | +} |
|
26 | 27 | |
27 | 28 | /** |
28 | 29 | * Handling function for generating reports. |
@@ -69,14 +70,15 @@ discard block |
||
69 | 70 | ); |
70 | 71 | |
71 | 72 | $is_first = 0; |
72 | - foreach ($context['report_types'] as $k => $temp) |
|
73 | - $context['report_types'][$k] = array( |
|
73 | + foreach ($context['report_types'] as $k => $temp) { |
|
74 | + $context['report_types'][$k] = array( |
|
74 | 75 | 'id' => $k, |
75 | 76 | 'title' => isset($txt['gr_type_' . $k]) ? $txt['gr_type_' . $k] : $k, |
76 | 77 | 'description' => isset($txt['gr_type_desc_' . $k]) ? $txt['gr_type_desc_' . $k] : null, |
77 | 78 | 'function' => $temp, |
78 | 79 | 'is_first' => $is_first++ == 0, |
79 | 80 | ); |
81 | + } |
|
80 | 82 | |
81 | 83 | // If they haven't chosen a report type which is valid, send them off to the report type chooser! |
82 | 84 | if (empty($_REQUEST['rt']) || !isset($context['report_types'][$_REQUEST['rt']])) |
@@ -102,8 +104,9 @@ discard block |
||
102 | 104 | $context['sub_template'] = $_REQUEST['st']; |
103 | 105 | |
104 | 106 | // Are we disabling the other layers - print friendly for example? |
105 | - if ($reportTemplates[$_REQUEST['st']]['layers'] !== null) |
|
106 | - $context['template_layers'] = $reportTemplates[$_REQUEST['st']]['layers']; |
|
107 | + if ($reportTemplates[$_REQUEST['st']]['layers'] !== null) { |
|
108 | + $context['template_layers'] = $reportTemplates[$_REQUEST['st']]['layers']; |
|
109 | + } |
|
107 | 110 | } |
108 | 111 | |
109 | 112 | // Make the page title more descriptive. |
@@ -151,8 +154,9 @@ discard block |
||
151 | 154 | ) |
152 | 155 | ); |
153 | 156 | $moderators = array(); |
154 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
155 | - $moderators[$row['id_board']][] = $row['real_name']; |
|
157 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
158 | + $moderators[$row['id_board']][] = $row['real_name']; |
|
159 | + } |
|
156 | 160 | $smcFunc['db_free_result']($request); |
157 | 161 | |
158 | 162 | // Get every moderator gruop. |
@@ -164,8 +168,9 @@ discard block |
||
164 | 168 | ) |
165 | 169 | ); |
166 | 170 | $moderator_groups = array(); |
167 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
168 | - $moderator_groups[$row['id_board']][] = $row['group_name']; |
|
171 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
172 | + $moderator_groups[$row['id_board']][] = $row['group_name']; |
|
173 | + } |
|
169 | 174 | $smcFunc['db_free_result']($request); |
170 | 175 | |
171 | 176 | // Get all the possible membergroups! |
@@ -176,8 +181,9 @@ discard block |
||
176 | 181 | ) |
177 | 182 | ); |
178 | 183 | $groups = array(-1 => $txt['guest_title'], 0 => $txt['full_member']); |
179 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
180 | - $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
184 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
185 | + $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
186 | + } |
|
181 | 187 | $smcFunc['db_free_result']($request); |
182 | 188 | |
183 | 189 | // All the fields we'll show. |
@@ -195,8 +201,9 @@ discard block |
||
195 | 201 | 'moderator_groups' => $txt['board_moderator_groups'], |
196 | 202 | 'groups' => $txt['board_groups'], |
197 | 203 | ); |
198 | - if (!empty($modSettings['deny_boards_access'])) |
|
199 | - $boardSettings['disallowed_groups'] = $txt['board_disallowed_groups']; |
|
204 | + if (!empty($modSettings['deny_boards_access'])) { |
|
205 | + $boardSettings['disallowed_groups'] = $txt['board_disallowed_groups']; |
|
206 | + } |
|
200 | 207 | |
201 | 208 | // Do it in columns, it's just easier. |
202 | 209 | setKeys('cols'); |
@@ -222,8 +229,9 @@ discard block |
||
222 | 229 | newTable($row['name'], '', 'left', 'auto', 'left', 200, 'left'); |
223 | 230 | |
224 | 231 | $this_boardSettings = $boardSettings; |
225 | - if (empty($row['redirect'])) |
|
226 | - unset($this_boardSettings['redirect']); |
|
232 | + if (empty($row['redirect'])) { |
|
233 | + unset($this_boardSettings['redirect']); |
|
234 | + } |
|
227 | 235 | |
228 | 236 | // First off, add in the side key. |
229 | 237 | addData($this_boardSettings); |
@@ -250,10 +258,11 @@ discard block |
||
250 | 258 | $allowedGroups = explode(',', $row['member_groups']); |
251 | 259 | foreach ($allowedGroups as $key => $group) |
252 | 260 | { |
253 | - if (isset($groups[$group])) |
|
254 | - $allowedGroups[$key] = $groups[$group]; |
|
255 | - else |
|
256 | - unset($allowedGroups[$key]); |
|
261 | + if (isset($groups[$group])) { |
|
262 | + $allowedGroups[$key] = $groups[$group]; |
|
263 | + } else { |
|
264 | + unset($allowedGroups[$key]); |
|
265 | + } |
|
257 | 266 | } |
258 | 267 | $boardData['groups'] = implode(', ', $allowedGroups); |
259 | 268 | if (!empty($modSettings['deny_boards_access'])) |
@@ -261,16 +270,18 @@ discard block |
||
261 | 270 | $disallowedGroups = explode(',', $row['deny_member_groups']); |
262 | 271 | foreach ($disallowedGroups as $key => $group) |
263 | 272 | { |
264 | - if (isset($groups[$group])) |
|
265 | - $disallowedGroups[$key] = $groups[$group]; |
|
266 | - else |
|
267 | - unset($disallowedGroups[$key]); |
|
273 | + if (isset($groups[$group])) { |
|
274 | + $disallowedGroups[$key] = $groups[$group]; |
|
275 | + } else { |
|
276 | + unset($disallowedGroups[$key]); |
|
277 | + } |
|
268 | 278 | } |
269 | 279 | $boardData['disallowed_groups'] = implode(', ', $disallowedGroups); |
270 | 280 | } |
271 | 281 | |
272 | - if (empty($row['redirect'])) |
|
273 | - unset ($boardData['redirect']); |
|
282 | + if (empty($row['redirect'])) { |
|
283 | + unset ($boardData['redirect']); |
|
284 | + } |
|
274 | 285 | |
275 | 286 | // Next add the main data. |
276 | 287 | addData($boardData); |
@@ -295,27 +306,31 @@ discard block |
||
295 | 306 | |
296 | 307 | if (isset($_REQUEST['boards'])) |
297 | 308 | { |
298 | - if (!is_array($_REQUEST['boards'])) |
|
299 | - $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
|
300 | - foreach ($_REQUEST['boards'] as $k => $dummy) |
|
301 | - $_REQUEST['boards'][$k] = (int) $dummy; |
|
309 | + if (!is_array($_REQUEST['boards'])) { |
|
310 | + $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
|
311 | + } |
|
312 | + foreach ($_REQUEST['boards'] as $k => $dummy) { |
|
313 | + $_REQUEST['boards'][$k] = (int) $dummy; |
|
314 | + } |
|
302 | 315 | |
303 | 316 | $board_clause = 'id_board IN ({array_int:boards})'; |
317 | + } else { |
|
318 | + $board_clause = '1=1'; |
|
304 | 319 | } |
305 | - else |
|
306 | - $board_clause = '1=1'; |
|
307 | 320 | |
308 | 321 | if (isset($_REQUEST['groups'])) |
309 | 322 | { |
310 | - if (!is_array($_REQUEST['groups'])) |
|
311 | - $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
312 | - foreach ($_REQUEST['groups'] as $k => $dummy) |
|
313 | - $_REQUEST['groups'][$k] = (int) $dummy; |
|
323 | + if (!is_array($_REQUEST['groups'])) { |
|
324 | + $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
325 | + } |
|
326 | + foreach ($_REQUEST['groups'] as $k => $dummy) { |
|
327 | + $_REQUEST['groups'][$k] = (int) $dummy; |
|
328 | + } |
|
314 | 329 | |
315 | 330 | $group_clause = 'id_group IN ({array_int:groups})'; |
331 | + } else { |
|
332 | + $group_clause = '1=1'; |
|
316 | 333 | } |
317 | - else |
|
318 | - $group_clause = '1=1'; |
|
319 | 334 | |
320 | 335 | // Fetch all the board names. |
321 | 336 | $request = $smcFunc['db_query']('', ' |
@@ -369,12 +384,14 @@ discard block |
||
369 | 384 | 'groups' => isset($_REQUEST['groups']) ? $_REQUEST['groups'] : array(), |
370 | 385 | ) |
371 | 386 | ); |
372 | - if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) |
|
373 | - $member_groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
374 | - else |
|
375 | - $member_groups = array('col' => ''); |
|
376 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
377 | - $member_groups[$row['id_group']] = $row['group_name']; |
|
387 | + if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) { |
|
388 | + $member_groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
389 | + } else { |
|
390 | + $member_groups = array('col' => ''); |
|
391 | + } |
|
392 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
393 | + $member_groups[$row['id_group']] = $row['group_name']; |
|
394 | + } |
|
378 | 395 | $smcFunc['db_free_result']($request); |
379 | 396 | |
380 | 397 | // Make sure that every group is represented - plus in rows! |
@@ -411,12 +428,14 @@ discard block |
||
411 | 428 | ); |
412 | 429 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
413 | 430 | { |
414 | - if (in_array($row['permission'], $disabled_permissions)) |
|
415 | - continue; |
|
431 | + if (in_array($row['permission'], $disabled_permissions)) { |
|
432 | + continue; |
|
433 | + } |
|
416 | 434 | |
417 | - foreach ($boards as $id => $board) |
|
418 | - if ($board['profile'] == $row['id_profile']) |
|
435 | + foreach ($boards as $id => $board) { |
|
436 | + if ($board['profile'] == $row['id_profile']) |
|
419 | 437 | $board_permissions[$id][$row['id_group']][$row['permission']] = $row['add_deny']; |
438 | + } |
|
420 | 439 | |
421 | 440 | // Make sure we get every permission. |
422 | 441 | if (!isset($permissions[$row['permission']])) |
@@ -454,8 +473,9 @@ discard block |
||
454 | 473 | foreach ($member_groups as $id_group => $name) |
455 | 474 | { |
456 | 475 | // Don't overwrite the key column! |
457 | - if ($id_group === 'col') |
|
458 | - continue; |
|
476 | + if ($id_group === 'col') { |
|
477 | + continue; |
|
478 | + } |
|
459 | 479 | |
460 | 480 | $group_permissions = isset($groups[$id_group]) ? $groups[$id_group] : array(); |
461 | 481 | |
@@ -477,16 +497,18 @@ discard block |
||
477 | 497 | } |
478 | 498 | |
479 | 499 | // Now actually make the data for the group look right. |
480 | - if (empty($curData[$id_group])) |
|
481 | - $curData[$id_group] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
482 | - elseif ($curData[$id_group] == 1) |
|
483 | - $curData[$id_group] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
484 | - else |
|
485 | - $curData[$id_group] = 'x'; |
|
500 | + if (empty($curData[$id_group])) { |
|
501 | + $curData[$id_group] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
502 | + } elseif ($curData[$id_group] == 1) { |
|
503 | + $curData[$id_group] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
504 | + } else { |
|
505 | + $curData[$id_group] = 'x'; |
|
506 | + } |
|
486 | 507 | |
487 | 508 | // Embolden those permissions different from global (makes it a lot easier!) |
488 | - if (@$board_permissions[0][$id_group][$ID_PERM] != @$group_permissions[$ID_PERM]) |
|
489 | - $curData[$id_group] = '<strong>' . $curData[$id_group] . '</strong>'; |
|
509 | + if (@$board_permissions[0][$id_group][$ID_PERM] != @$group_permissions[$ID_PERM]) { |
|
510 | + $curData[$id_group] = '<strong>' . $curData[$id_group] . '</strong>'; |
|
511 | + } |
|
490 | 512 | } |
491 | 513 | |
492 | 514 | // Now add the data for this permission. |
@@ -516,15 +538,17 @@ discard block |
||
516 | 538 | ); |
517 | 539 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
518 | 540 | { |
519 | - if (trim($row['member_groups']) == '') |
|
520 | - $groups = array(1); |
|
521 | - else |
|
522 | - $groups = array_merge(array(1), explode(',', $row['member_groups'])); |
|
541 | + if (trim($row['member_groups']) == '') { |
|
542 | + $groups = array(1); |
|
543 | + } else { |
|
544 | + $groups = array_merge(array(1), explode(',', $row['member_groups'])); |
|
545 | + } |
|
523 | 546 | |
524 | - if (trim($row['deny_member_groups']) == '') |
|
525 | - $denyGroups = array(); |
|
526 | - else |
|
527 | - $denyGroups = explode(',', $row['deny_member_groups']); |
|
547 | + if (trim($row['deny_member_groups']) == '') { |
|
548 | + $denyGroups = array(); |
|
549 | + } else { |
|
550 | + $denyGroups = explode(',', $row['deny_member_groups']); |
|
551 | + } |
|
528 | 552 | |
529 | 553 | $boards[$row['id_board']] = array( |
530 | 554 | 'id' => $row['id_board'], |
@@ -548,8 +572,9 @@ discard block |
||
548 | 572 | ); |
549 | 573 | |
550 | 574 | // Add on the boards! |
551 | - foreach ($boards as $board) |
|
552 | - $mgSettings['board_' . $board['id']] = $board['name']; |
|
575 | + foreach ($boards as $board) { |
|
576 | + $mgSettings['board_' . $board['id']] = $board['name']; |
|
577 | + } |
|
553 | 578 | |
554 | 579 | // Add all the membergroup settings, plus we'll be adding in columns! |
555 | 580 | setKeys('cols', $mgSettings); |
@@ -594,8 +619,9 @@ discard block |
||
594 | 619 | 'icons' => '' |
595 | 620 | ), |
596 | 621 | ); |
597 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
598 | - $rows[] = $row; |
|
622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
623 | + $rows[] = $row; |
|
624 | + } |
|
599 | 625 | $smcFunc['db_free_result']($request); |
600 | 626 | |
601 | 627 | foreach ($rows as $row) |
@@ -611,8 +637,9 @@ discard block |
||
611 | 637 | ); |
612 | 638 | |
613 | 639 | // Board permissions. |
614 | - foreach ($boards as $board) |
|
615 | - $group['board_' . $board['id']] = in_array($row['id_group'], $board['groups']) ? '<span class="success">' . $txt['board_perms_allow'] . '</span>' : (!empty($modSettings['deny_boards_access']) && in_array($row['id_group'], $board['deny_groups']) ? '<span class="alert">' . $txt['board_perms_deny'] . '</span>' : 'x'); |
|
640 | + foreach ($boards as $board) { |
|
641 | + $group['board_' . $board['id']] = in_array($row['id_group'], $board['groups']) ? '<span class="success">' . $txt['board_perms_allow'] . '</span>' : (!empty($modSettings['deny_boards_access']) && in_array($row['id_group'], $board['deny_groups']) ? '<span class="alert">' . $txt['board_perms_deny'] . '</span>' : 'x'); |
|
642 | + } |
|
616 | 643 | |
617 | 644 | addData($group); |
618 | 645 | } |
@@ -632,16 +659,18 @@ discard block |
||
632 | 659 | |
633 | 660 | if (isset($_REQUEST['groups'])) |
634 | 661 | { |
635 | - if (!is_array($_REQUEST['groups'])) |
|
636 | - $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
637 | - foreach ($_REQUEST['groups'] as $k => $dummy) |
|
638 | - $_REQUEST['groups'][$k] = (int) $dummy; |
|
662 | + if (!is_array($_REQUEST['groups'])) { |
|
663 | + $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
664 | + } |
|
665 | + foreach ($_REQUEST['groups'] as $k => $dummy) { |
|
666 | + $_REQUEST['groups'][$k] = (int) $dummy; |
|
667 | + } |
|
639 | 668 | $_REQUEST['groups'] = array_diff($_REQUEST['groups'], array(3)); |
640 | 669 | |
641 | 670 | $clause = 'id_group IN ({array_int:groups})'; |
671 | + } else { |
|
672 | + $clause = 'id_group != {int:moderator_group}'; |
|
642 | 673 | } |
643 | - else |
|
644 | - $clause = 'id_group != {int:moderator_group}'; |
|
645 | 674 | |
646 | 675 | // Get all the possible membergroups, except admin! |
647 | 676 | $request = $smcFunc['db_query']('', ' |
@@ -659,12 +688,14 @@ discard block |
||
659 | 688 | 'groups' => isset($_REQUEST['groups']) ? $_REQUEST['groups'] : array(), |
660 | 689 | ) |
661 | 690 | ); |
662 | - if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) |
|
663 | - $groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
664 | - else |
|
665 | - $groups = array('col' => ''); |
|
666 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
667 | - $groups[$row['id_group']] = $row['group_name']; |
|
691 | + if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) { |
|
692 | + $groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
693 | + } else { |
|
694 | + $groups = array('col' => ''); |
|
695 | + } |
|
696 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
697 | + $groups[$row['id_group']] = $row['group_name']; |
|
698 | + } |
|
668 | 699 | $smcFunc['db_free_result']($request); |
669 | 700 | |
670 | 701 | // Make sure that every group is represented! |
@@ -688,8 +719,9 @@ discard block |
||
688 | 719 | $disabled_permissions[] = 'calendar_edit_own'; |
689 | 720 | $disabled_permissions[] = 'calendar_edit_any'; |
690 | 721 | } |
691 | - if (empty($modSettings['warning_settings']) || $modSettings['warning_settings'][0] == 0) |
|
692 | - $disabled_permissions[] = 'issue_warning'; |
|
722 | + if (empty($modSettings['warning_settings']) || $modSettings['warning_settings'][0] == 0) { |
|
723 | + $disabled_permissions[] = 'issue_warning'; |
|
724 | + } |
|
693 | 725 | |
694 | 726 | call_integration_hook('integrate_reports_groupperm', array(&$disabled_permissions)); |
695 | 727 | |
@@ -710,15 +742,17 @@ discard block |
||
710 | 742 | $curData = array(); |
711 | 743 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
712 | 744 | { |
713 | - if (in_array($row['permission'], $disabled_permissions)) |
|
714 | - continue; |
|
745 | + if (in_array($row['permission'], $disabled_permissions)) { |
|
746 | + continue; |
|
747 | + } |
|
715 | 748 | |
716 | 749 | // If this is a new permission flush the last row. |
717 | 750 | if ($row['permission'] != $lastPermission) |
718 | 751 | { |
719 | 752 | // Send the data! |
720 | - if ($lastPermission !== null) |
|
721 | - addData($curData); |
|
753 | + if ($lastPermission !== null) { |
|
754 | + addData($curData); |
|
755 | + } |
|
722 | 756 | |
723 | 757 | // Add the permission name in the left column. |
724 | 758 | $curData = array('col' => isset($txt['group_perms_name_' . $row['permission']]) ? $txt['group_perms_name_' . $row['permission']] : $row['permission']); |
@@ -727,10 +761,11 @@ discard block |
||
727 | 761 | } |
728 | 762 | |
729 | 763 | // Good stuff - add the permission to the list! |
730 | - if ($row['add_deny']) |
|
731 | - $curData[$row['id_group']] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
732 | - else |
|
733 | - $curData[$row['id_group']] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
764 | + if ($row['add_deny']) { |
|
765 | + $curData[$row['id_group']] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
766 | + } else { |
|
767 | + $curData[$row['id_group']] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
768 | + } |
|
734 | 769 | } |
735 | 770 | $smcFunc['db_free_result']($request); |
736 | 771 | |
@@ -760,8 +795,9 @@ discard block |
||
760 | 795 | ) |
761 | 796 | ); |
762 | 797 | $boards = array(); |
763 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
764 | - $boards[$row['id_board']] = $row['name']; |
|
798 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
799 | + $boards[$row['id_board']] = $row['name']; |
|
800 | + } |
|
765 | 801 | $smcFunc['db_free_result']($request); |
766 | 802 | |
767 | 803 | // Get every moderator. |
@@ -793,12 +829,14 @@ discard block |
||
793 | 829 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
794 | 830 | { |
795 | 831 | // Either we don't have them as a moderator at all or at least not as a moderator of this board |
796 | - if (!array_key_exists($row['id_member'], $moderators) || !in_array($row['id_board'], $moderators[$row['id_member']])) |
|
797 | - $moderators[$row['id_member']][] = $row['id_board']; |
|
832 | + if (!array_key_exists($row['id_member'], $moderators) || !in_array($row['id_board'], $moderators[$row['id_member']])) { |
|
833 | + $moderators[$row['id_member']][] = $row['id_board']; |
|
834 | + } |
|
798 | 835 | |
799 | 836 | // We don't have them listed as a moderator yet |
800 | - if (!array_key_exists($row['id_member'], $local_mods)) |
|
801 | - $local_mods[$row['id_member']] = $row['id_member']; |
|
837 | + if (!array_key_exists($row['id_member'], $local_mods)) { |
|
838 | + $local_mods[$row['id_member']] = $row['id_member']; |
|
839 | + } |
|
802 | 840 | } |
803 | 841 | |
804 | 842 | // Get a list of global moderators (i.e. members with moderation powers). |
@@ -811,8 +849,9 @@ discard block |
||
811 | 849 | $allStaff = array_unique($allStaff); |
812 | 850 | |
813 | 851 | // This is a bit of a cop out - but we're protecting their forum, really! |
814 | - if (count($allStaff) > 300) |
|
815 | - fatal_lang_error('report_error_too_many_staff'); |
|
852 | + if (count($allStaff) > 300) { |
|
853 | + fatal_lang_error('report_error_too_many_staff'); |
|
854 | + } |
|
816 | 855 | |
817 | 856 | // Get all the possible membergroups! |
818 | 857 | $request = $smcFunc['db_query']('', ' |
@@ -822,8 +861,9 @@ discard block |
||
822 | 861 | ) |
823 | 862 | ); |
824 | 863 | $groups = array(0 => $txt['full_member']); |
825 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
826 | - $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
864 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
865 | + $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
866 | + } |
|
827 | 867 | $smcFunc['db_free_result']($request); |
828 | 868 | |
829 | 869 | // All the fields we'll show. |
@@ -864,19 +904,20 @@ discard block |
||
864 | 904 | ); |
865 | 905 | |
866 | 906 | // What do they moderate? |
867 | - if (in_array($row['id_member'], $global_mods)) |
|
868 | - $staffData['moderates'] = '<em>' . $txt['report_staff_all_boards'] . '</em>'; |
|
869 | - elseif (isset($moderators[$row['id_member']])) |
|
907 | + if (in_array($row['id_member'], $global_mods)) { |
|
908 | + $staffData['moderates'] = '<em>' . $txt['report_staff_all_boards'] . '</em>'; |
|
909 | + } elseif (isset($moderators[$row['id_member']])) |
|
870 | 910 | { |
871 | 911 | // Get the names |
872 | - foreach ($moderators[$row['id_member']] as $board) |
|
873 | - if (isset($boards[$board])) |
|
912 | + foreach ($moderators[$row['id_member']] as $board) { |
|
913 | + if (isset($boards[$board])) |
|
874 | 914 | $staffData['moderates'][] = $boards[$board]; |
915 | + } |
|
875 | 916 | |
876 | 917 | $staffData['moderates'] = implode(', ', $staffData['moderates']); |
918 | + } else { |
|
919 | + $staffData['moderates'] = '<em>' . $txt['report_staff_no_boards'] . '</em>'; |
|
877 | 920 | } |
878 | - else |
|
879 | - $staffData['moderates'] = '<em>' . $txt['report_staff_no_boards'] . '</em>'; |
|
880 | 921 | |
881 | 922 | // Next add the main data. |
882 | 923 | addData($staffData); |
@@ -904,8 +945,9 @@ discard block |
||
904 | 945 | global $context; |
905 | 946 | |
906 | 947 | // Set the table count if needed. |
907 | - if (empty($context['table_count'])) |
|
908 | - $context['table_count'] = 0; |
|
948 | + if (empty($context['table_count'])) { |
|
949 | + $context['table_count'] = 0; |
|
950 | + } |
|
909 | 951 | |
910 | 952 | // Create the table! |
911 | 953 | $context['tables'][$context['table_count']] = array( |
@@ -955,16 +997,18 @@ discard block |
||
955 | 997 | global $context; |
956 | 998 | |
957 | 999 | // No tables? Create one even though we are probably already in a bad state! |
958 | - if (empty($context['table_count'])) |
|
959 | - newTable(); |
|
1000 | + if (empty($context['table_count'])) { |
|
1001 | + newTable(); |
|
1002 | + } |
|
960 | 1003 | |
961 | 1004 | // Specific table? |
962 | - if ($custom_table !== null && !isset($context['tables'][$custom_table])) |
|
963 | - return false; |
|
964 | - elseif ($custom_table !== null) |
|
965 | - $table = $custom_table; |
|
966 | - else |
|
967 | - $table = $context['current_table']; |
|
1005 | + if ($custom_table !== null && !isset($context['tables'][$custom_table])) { |
|
1006 | + return false; |
|
1007 | + } elseif ($custom_table !== null) { |
|
1008 | + $table = $custom_table; |
|
1009 | + } else { |
|
1010 | + $table = $context['current_table']; |
|
1011 | + } |
|
968 | 1012 | |
969 | 1013 | // If we have keys, sanitise the data... |
970 | 1014 | if (!empty($context['keys'])) |
@@ -976,11 +1020,11 @@ discard block |
||
976 | 1020 | 'v' => empty($inc_data[$key]) ? $context['tables'][$table]['default_value'] : $inc_data[$key], |
977 | 1021 | ); |
978 | 1022 | // Special "hack" the adding separators when doing data by column. |
979 | - if (substr($key, 0, 5) == '#sep#') |
|
980 | - $data[$key]['separator'] = true; |
|
1023 | + if (substr($key, 0, 5) == '#sep#') { |
|
1024 | + $data[$key]['separator'] = true; |
|
1025 | + } |
|
981 | 1026 | } |
982 | - } |
|
983 | - else |
|
1027 | + } else |
|
984 | 1028 | { |
985 | 1029 | $data = $inc_data; |
986 | 1030 | foreach ($data as $key => $value) |
@@ -988,8 +1032,9 @@ discard block |
||
988 | 1032 | $data[$key] = array( |
989 | 1033 | 'v' => $value, |
990 | 1034 | ); |
991 | - if (substr($key, 0, 5) == '#sep#') |
|
992 | - $data[$key]['separator'] = true; |
|
1035 | + if (substr($key, 0, 5) == '#sep#') { |
|
1036 | + $data[$key]['separator'] = true; |
|
1037 | + } |
|
993 | 1038 | } |
994 | 1039 | } |
995 | 1040 | |
@@ -1002,8 +1047,9 @@ discard block |
||
1002 | 1047 | // Otherwise, tricky! |
1003 | 1048 | else |
1004 | 1049 | { |
1005 | - foreach ($data as $key => $item) |
|
1006 | - $context['tables'][$table]['data'][$key][] = $item; |
|
1050 | + foreach ($data as $key => $item) { |
|
1051 | + $context['tables'][$table]['data'][$key][] = $item; |
|
1052 | + } |
|
1007 | 1053 | } |
1008 | 1054 | } |
1009 | 1055 | |
@@ -1020,16 +1066,18 @@ discard block |
||
1020 | 1066 | global $context; |
1021 | 1067 | |
1022 | 1068 | // No tables - return? |
1023 | - if (empty($context['table_count'])) |
|
1024 | - return; |
|
1069 | + if (empty($context['table_count'])) { |
|
1070 | + return; |
|
1071 | + } |
|
1025 | 1072 | |
1026 | 1073 | // Specific table? |
1027 | - if ($custom_table !== null && !isset($context['tables'][$table])) |
|
1028 | - return false; |
|
1029 | - elseif ($custom_table !== null) |
|
1030 | - $table = $custom_table; |
|
1031 | - else |
|
1032 | - $table = $context['current_table']; |
|
1074 | + if ($custom_table !== null && !isset($context['tables'][$table])) { |
|
1075 | + return false; |
|
1076 | + } elseif ($custom_table !== null) { |
|
1077 | + $table = $custom_table; |
|
1078 | + } else { |
|
1079 | + $table = $context['current_table']; |
|
1080 | + } |
|
1033 | 1081 | |
1034 | 1082 | // Plumb in the separator |
1035 | 1083 | $context['tables'][$table]['data'][] = array(0 => array( |
@@ -1050,8 +1098,9 @@ discard block |
||
1050 | 1098 | { |
1051 | 1099 | global $context; |
1052 | 1100 | |
1053 | - if (empty($context['tables'])) |
|
1054 | - return; |
|
1101 | + if (empty($context['tables'])) { |
|
1102 | + return; |
|
1103 | + } |
|
1055 | 1104 | |
1056 | 1105 | // Loop through each table counting up some basic values, to help with the templating. |
1057 | 1106 | foreach ($context['tables'] as $id => $table) |
@@ -1062,12 +1111,13 @@ discard block |
||
1062 | 1111 | $context['tables'][$id]['column_count'] = count($curElement); |
1063 | 1112 | |
1064 | 1113 | // Work out the rough width - for templates like the print template. Without this we might get funny tables. |
1065 | - if ($table['shading']['left'] && $table['width']['shaded'] != 'auto' && $table['width']['normal'] != 'auto') |
|
1066 | - $context['tables'][$id]['max_width'] = $table['width']['shaded'] + ($context['tables'][$id]['column_count'] - 1) * $table['width']['normal']; |
|
1067 | - elseif ($table['width']['normal'] != 'auto') |
|
1068 | - $context['tables'][$id]['max_width'] = $context['tables'][$id]['column_count'] * $table['width']['normal']; |
|
1069 | - else |
|
1070 | - $context['tables'][$id]['max_width'] = 'auto'; |
|
1114 | + if ($table['shading']['left'] && $table['width']['shaded'] != 'auto' && $table['width']['normal'] != 'auto') { |
|
1115 | + $context['tables'][$id]['max_width'] = $table['width']['shaded'] + ($context['tables'][$id]['column_count'] - 1) * $table['width']['normal']; |
|
1116 | + } elseif ($table['width']['normal'] != 'auto') { |
|
1117 | + $context['tables'][$id]['max_width'] = $context['tables'][$id]['column_count'] * $table['width']['normal']; |
|
1118 | + } else { |
|
1119 | + $context['tables'][$id]['max_width'] = 'auto'; |
|
1120 | + } |
|
1071 | 1121 | } |
1072 | 1122 | } |
1073 | 1123 | |
@@ -1092,10 +1142,11 @@ discard block |
||
1092 | 1142 | global $context; |
1093 | 1143 | |
1094 | 1144 | // Do we want to use the keys of the keys as the keys? :P |
1095 | - if ($reverse) |
|
1096 | - $context['keys'] = array_flip($keys); |
|
1097 | - else |
|
1098 | - $context['keys'] = $keys; |
|
1145 | + if ($reverse) { |
|
1146 | + $context['keys'] = array_flip($keys); |
|
1147 | + } else { |
|
1148 | + $context['keys'] = $keys; |
|
1149 | + } |
|
1099 | 1150 | |
1100 | 1151 | // Rows or columns? |
1101 | 1152 | $context['key_method'] = $method == 'rows' ? 'rows' : 'cols'; |
@@ -807,7 +807,7 @@ |
||
807 | 807 | /** |
808 | 808 | * Send a group of emails from the mail queue. |
809 | 809 | * |
810 | - * @param bool|int $number The number to send each loop through or false to use the standard limits |
|
810 | + * @param integer $number The number to send each loop through or false to use the standard limits |
|
811 | 811 | * @param bool $override_limit Whether to bypass the limit |
812 | 812 | * @param bool $force_send Whether to forcibly send the messages now (useful when using cron jobs) |
813 | 813 | * @return bool Whether things were sent |
@@ -384,7 +384,7 @@ |
||
384 | 384 | clean_cache(); |
385 | 385 | |
386 | 386 | // If warning decrement is enabled and we have people who have not had a new warning in 24 hours, lower their warning level. |
387 | - list (, , $modSettings['warning_decrement']) = explode(',', $modSettings['warning_settings']); |
|
387 | + list (,, $modSettings['warning_decrement']) = explode(',', $modSettings['warning_settings']); |
|
388 | 388 | if ($modSettings['warning_decrement']) |
389 | 389 | { |
390 | 390 | // Find every member who has a warning level... |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * This function works out what to do! |
@@ -24,9 +25,9 @@ discard block |
||
24 | 25 | global $time_start, $smcFunc, $modSettings; |
25 | 26 | |
26 | 27 | // Special case for doing the mail queue. |
27 | - if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') |
|
28 | - ReduceMailQueue(); |
|
29 | - else |
|
28 | + if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') { |
|
29 | + ReduceMailQueue(); |
|
30 | + } else |
|
30 | 31 | { |
31 | 32 | $task_string = ''; |
32 | 33 | |
@@ -53,18 +54,20 @@ discard block |
||
53 | 54 | |
54 | 55 | // How long in seconds it the gap? |
55 | 56 | $duration = $row['time_regularity']; |
56 | - if ($row['time_unit'] == 'm') |
|
57 | - $duration *= 60; |
|
58 | - elseif ($row['time_unit'] == 'h') |
|
59 | - $duration *= 3600; |
|
60 | - elseif ($row['time_unit'] == 'd') |
|
61 | - $duration *= 86400; |
|
62 | - elseif ($row['time_unit'] == 'w') |
|
63 | - $duration *= 604800; |
|
57 | + if ($row['time_unit'] == 'm') { |
|
58 | + $duration *= 60; |
|
59 | + } elseif ($row['time_unit'] == 'h') { |
|
60 | + $duration *= 3600; |
|
61 | + } elseif ($row['time_unit'] == 'd') { |
|
62 | + $duration *= 86400; |
|
63 | + } elseif ($row['time_unit'] == 'w') { |
|
64 | + $duration *= 604800; |
|
65 | + } |
|
64 | 66 | |
65 | 67 | // If we were really late running this task actually skip the next one. |
66 | - if (time() + ($duration / 2) > $next_time) |
|
67 | - $next_time += $duration; |
|
68 | + if (time() + ($duration / 2) > $next_time) { |
|
69 | + $next_time += $duration; |
|
70 | + } |
|
68 | 71 | |
69 | 72 | // Update it now, so no others run this! |
70 | 73 | $smcFunc['db_query']('', ' |
@@ -81,16 +84,19 @@ discard block |
||
81 | 84 | $affected_rows = $smcFunc['db_affected_rows'](); |
82 | 85 | |
83 | 86 | // What kind of task are we handling? |
84 | - if (!empty($row['callable'])) |
|
85 | - $task_string = $row['callable']; |
|
87 | + if (!empty($row['callable'])) { |
|
88 | + $task_string = $row['callable']; |
|
89 | + } |
|
86 | 90 | |
87 | 91 | // Default SMF task or old mods? |
88 | - elseif (function_exists('scheduled_' . $row['task'])) |
|
89 | - $task_string = 'scheduled_' . $row['task']; |
|
92 | + elseif (function_exists('scheduled_' . $row['task'])) { |
|
93 | + $task_string = 'scheduled_' . $row['task']; |
|
94 | + } |
|
90 | 95 | |
91 | 96 | // One last resource, the task name. |
92 | - elseif (!empty($row['task'])) |
|
93 | - $task_string = $row['task']; |
|
97 | + elseif (!empty($row['task'])) { |
|
98 | + $task_string = $row['task']; |
|
99 | + } |
|
94 | 100 | |
95 | 101 | // The function must exist or we are wasting our time, plus do some timestamp checking, and database check! |
96 | 102 | if (!empty($task_string) && (!isset($_GET['ts']) || $_GET['ts'] == $row['next_time']) && $affected_rows) |
@@ -101,11 +107,11 @@ discard block |
||
101 | 107 | $callable_task = call_helper($task_string, true); |
102 | 108 | |
103 | 109 | // Perform the task. |
104 | - if (!empty($callable_task)) |
|
105 | - $completed = call_user_func($callable_task); |
|
106 | - |
|
107 | - else |
|
108 | - $completed = false; |
|
110 | + if (!empty($callable_task)) { |
|
111 | + $completed = call_user_func($callable_task); |
|
112 | + } else { |
|
113 | + $completed = false; |
|
114 | + } |
|
109 | 115 | |
110 | 116 | // Log that we did it ;) |
111 | 117 | if ($completed) |
@@ -138,18 +144,20 @@ discard block |
||
138 | 144 | ) |
139 | 145 | ); |
140 | 146 | // No new task scheduled yet? |
141 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
142 | - $nextEvent = time() + 86400; |
|
143 | - else |
|
144 | - list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
147 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
148 | + $nextEvent = time() + 86400; |
|
149 | + } else { |
|
150 | + list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
151 | + } |
|
145 | 152 | $smcFunc['db_free_result']($request); |
146 | 153 | |
147 | 154 | updateSettings(array('next_task_time' => $nextEvent)); |
148 | 155 | } |
149 | 156 | |
150 | 157 | // Shall we return? |
151 | - if (!isset($_GET['scheduled'])) |
|
152 | - return true; |
|
158 | + if (!isset($_GET['scheduled'])) { |
|
159 | + return true; |
|
160 | + } |
|
153 | 161 | |
154 | 162 | // Finally, send some stuff... |
155 | 163 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -181,16 +189,18 @@ discard block |
||
181 | 189 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
182 | 190 | { |
183 | 191 | // If this is no longer around we'll ignore it. |
184 | - if (empty($row['id_topic'])) |
|
185 | - continue; |
|
192 | + if (empty($row['id_topic'])) { |
|
193 | + continue; |
|
194 | + } |
|
186 | 195 | |
187 | 196 | // What type is it? |
188 | - if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) |
|
189 | - $type = 'topic'; |
|
190 | - elseif ($row['id_attach']) |
|
191 | - $type = 'attach'; |
|
192 | - else |
|
193 | - $type = 'msg'; |
|
197 | + if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) { |
|
198 | + $type = 'topic'; |
|
199 | + } elseif ($row['id_attach']) { |
|
200 | + $type = 'attach'; |
|
201 | + } else { |
|
202 | + $type = 'msg'; |
|
203 | + } |
|
194 | 204 | |
195 | 205 | // Add it to the array otherwise. |
196 | 206 | $notices[$row['id_board']][$type][] = array( |
@@ -211,8 +221,9 @@ discard block |
||
211 | 221 | ); |
212 | 222 | |
213 | 223 | // If nothing quit now. |
214 | - if (empty($notices)) |
|
215 | - return true; |
|
224 | + if (empty($notices)) { |
|
225 | + return true; |
|
226 | + } |
|
216 | 227 | |
217 | 228 | // Now we need to think about finding out *who* can approve - this is hard! |
218 | 229 | |
@@ -231,14 +242,16 @@ discard block |
||
231 | 242 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
232 | 243 | { |
233 | 244 | // Sorry guys, but we have to ignore guests AND members - it would be too many otherwise. |
234 | - if ($row['id_group'] < 2) |
|
235 | - continue; |
|
245 | + if ($row['id_group'] < 2) { |
|
246 | + continue; |
|
247 | + } |
|
236 | 248 | |
237 | 249 | $perms[$row['id_profile']][$row['add_deny'] ? 'add' : 'deny'][] = $row['id_group']; |
238 | 250 | |
239 | 251 | // Anyone who can access has to be considered. |
240 | - if ($row['add_deny']) |
|
241 | - $addGroups[] = $row['id_group']; |
|
252 | + if ($row['add_deny']) { |
|
253 | + $addGroups[] = $row['id_group']; |
|
254 | + } |
|
242 | 255 | } |
243 | 256 | $smcFunc['db_free_result']($request); |
244 | 257 | |
@@ -283,8 +296,9 @@ discard block |
||
283 | 296 | if (!empty($row['mod_prefs'])) |
284 | 297 | { |
285 | 298 | list(,, $pref_binary) = explode('|', $row['mod_prefs']); |
286 | - if (!($pref_binary & 4)) |
|
287 | - continue; |
|
299 | + if (!($pref_binary & 4)) { |
|
300 | + continue; |
|
301 | + } |
|
288 | 302 | } |
289 | 303 | |
290 | 304 | $members[$row['id_member']] = array( |
@@ -309,8 +323,9 @@ discard block |
||
309 | 323 | $emailbody = ''; |
310 | 324 | |
311 | 325 | // Load the language file as required. |
312 | - if (empty($current_language) || $current_language != $member['language']) |
|
313 | - $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
326 | + if (empty($current_language) || $current_language != $member['language']) { |
|
327 | + $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
328 | + } |
|
314 | 329 | |
315 | 330 | // Loop through each notice... |
316 | 331 | foreach ($notices as $board => $notice) |
@@ -318,29 +333,34 @@ discard block |
||
318 | 333 | $access = false; |
319 | 334 | |
320 | 335 | // Can they mod in this board? |
321 | - if (isset($mods[$id][$board])) |
|
322 | - $access = true; |
|
336 | + if (isset($mods[$id][$board])) { |
|
337 | + $access = true; |
|
338 | + } |
|
323 | 339 | |
324 | 340 | // Do the group check... |
325 | 341 | if (!$access && isset($perms[$profiles[$board]]['add'])) |
326 | 342 | { |
327 | 343 | // They can access?! |
328 | - if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) |
|
329 | - $access = true; |
|
344 | + if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) { |
|
345 | + $access = true; |
|
346 | + } |
|
330 | 347 | |
331 | 348 | // If they have deny rights don't consider them! |
332 | - if (isset($perms[$profiles[$board]]['deny'])) |
|
333 | - if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
349 | + if (isset($perms[$profiles[$board]]['deny'])) { |
|
350 | + if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
334 | 351 | $access = false; |
352 | + } |
|
335 | 353 | } |
336 | 354 | |
337 | 355 | // Finally, fix it for admins! |
338 | - if (in_array(1, $member['groups'])) |
|
339 | - $access = true; |
|
356 | + if (in_array(1, $member['groups'])) { |
|
357 | + $access = true; |
|
358 | + } |
|
340 | 359 | |
341 | 360 | // If they can't access it then give it a break! |
342 | - if (!$access) |
|
343 | - continue; |
|
361 | + if (!$access) { |
|
362 | + continue; |
|
363 | + } |
|
344 | 364 | |
345 | 365 | foreach ($notice as $type => $items) |
346 | 366 | { |
@@ -348,15 +368,17 @@ discard block |
||
348 | 368 | $emailbody .= $txt['scheduled_approval_email_' . $type] . "\n" . |
349 | 369 | '------------------------------------------------------' . "\n"; |
350 | 370 | |
351 | - foreach ($items as $item) |
|
352 | - $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
371 | + foreach ($items as $item) { |
|
372 | + $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
373 | + } |
|
353 | 374 | |
354 | 375 | $emailbody .= "\n"; |
355 | 376 | } |
356 | 377 | } |
357 | 378 | |
358 | - if ($emailbody == '') |
|
359 | - continue; |
|
379 | + if ($emailbody == '') { |
|
380 | + continue; |
|
381 | + } |
|
360 | 382 | |
361 | 383 | $replacements = array( |
362 | 384 | 'REALNAME' => $member['name'], |
@@ -397,8 +419,9 @@ discard block |
||
397 | 419 | ) |
398 | 420 | ); |
399 | 421 | $members = array(); |
400 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
401 | - $members[$row['id_member']] = $row['warning']; |
|
422 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
423 | + $members[$row['id_member']] = $row['warning']; |
|
424 | + } |
|
402 | 425 | $smcFunc['db_free_result']($request); |
403 | 426 | |
404 | 427 | // Have some members to check? |
@@ -420,17 +443,18 @@ discard block |
||
420 | 443 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
421 | 444 | { |
422 | 445 | // More than 24 hours ago? |
423 | - if ($row['last_warning'] <= time() - 86400) |
|
424 | - $member_changes[] = array( |
|
446 | + if ($row['last_warning'] <= time() - 86400) { |
|
447 | + $member_changes[] = array( |
|
425 | 448 | 'id' => $row['id_recipient'], |
426 | 449 | 'warning' => $members[$row['id_recipient']] >= $modSettings['warning_decrement'] ? $members[$row['id_recipient']] - $modSettings['warning_decrement'] : 0, |
427 | 450 | ); |
451 | + } |
|
428 | 452 | } |
429 | 453 | $smcFunc['db_free_result']($request); |
430 | 454 | |
431 | 455 | // Have some members to change? |
432 | - if (!empty($member_changes)) |
|
433 | - foreach ($member_changes as $change) |
|
456 | + if (!empty($member_changes)) { |
|
457 | + foreach ($member_changes as $change) |
|
434 | 458 | $smcFunc['db_query']('', ' |
435 | 459 | UPDATE {db_prefix}members |
436 | 460 | SET warning = {int:warning} |
@@ -440,6 +464,7 @@ discard block |
||
440 | 464 | 'id_member' => $change['id'], |
441 | 465 | ) |
442 | 466 | ); |
467 | + } |
|
443 | 468 | } |
444 | 469 | } |
445 | 470 | |
@@ -452,16 +477,17 @@ discard block |
||
452 | 477 | |
453 | 478 | // Check the database version - for some buggy MySQL version. |
454 | 479 | $server_version = $smcFunc['db_server_info'](); |
455 | - if (($db_type == 'mysql') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
456 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
457 | - elseif (!empty($modSettings['db_mysql_group_by_fix'])) |
|
458 | - $smcFunc['db_query']('', ' |
|
480 | + if (($db_type == 'mysql') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
481 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
482 | + } elseif (!empty($modSettings['db_mysql_group_by_fix'])) { |
|
483 | + $smcFunc['db_query']('', ' |
|
459 | 484 | DELETE FROM {db_prefix}settings |
460 | 485 | WHERE variable = {string:mysql_fix}', |
461 | 486 | array( |
462 | 487 | 'mysql_fix' => 'db_mysql_group_by_fix', |
463 | 488 | ) |
464 | 489 | ); |
490 | + } |
|
465 | 491 | |
466 | 492 | // Clean up some old login history information. |
467 | 493 | $smcFunc['db_query']('', ' |
@@ -519,15 +545,17 @@ discard block |
||
519 | 545 | |
520 | 546 | // Store this useful data! |
521 | 547 | $boards[$row['id_board']] = $row['id_board']; |
522 | - if ($row['id_topic']) |
|
523 | - $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
524 | - else |
|
525 | - $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
548 | + if ($row['id_topic']) { |
|
549 | + $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
550 | + } else { |
|
551 | + $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
552 | + } |
|
526 | 553 | } |
527 | 554 | $smcFunc['db_free_result']($request); |
528 | 555 | |
529 | - if (empty($boards)) |
|
530 | - return true; |
|
556 | + if (empty($boards)) { |
|
557 | + return true; |
|
558 | + } |
|
531 | 559 | |
532 | 560 | // Just get the board names. |
533 | 561 | $request = $smcFunc['db_query']('', ' |
@@ -539,12 +567,14 @@ discard block |
||
539 | 567 | ) |
540 | 568 | ); |
541 | 569 | $boards = array(); |
542 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
543 | - $boards[$row['id_board']] = $row['name']; |
|
570 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
571 | + $boards[$row['id_board']] = $row['name']; |
|
572 | + } |
|
544 | 573 | $smcFunc['db_free_result']($request); |
545 | 574 | |
546 | - if (empty($boards)) |
|
547 | - return true; |
|
575 | + if (empty($boards)) { |
|
576 | + return true; |
|
577 | + } |
|
548 | 578 | |
549 | 579 | // Get the actual topics... |
550 | 580 | $request = $smcFunc['db_query']('', ' |
@@ -564,52 +594,57 @@ discard block |
||
564 | 594 | $types = array(); |
565 | 595 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
566 | 596 | { |
567 | - if (!isset($types[$row['note_type']][$row['id_board']])) |
|
568 | - $types[$row['note_type']][$row['id_board']] = array( |
|
597 | + if (!isset($types[$row['note_type']][$row['id_board']])) { |
|
598 | + $types[$row['note_type']][$row['id_board']] = array( |
|
569 | 599 | 'lines' => array(), |
570 | 600 | 'name' => $row['board_name'], |
571 | 601 | 'id' => $row['id_board'], |
572 | 602 | ); |
603 | + } |
|
573 | 604 | |
574 | 605 | if ($row['note_type'] == 'reply') |
575 | 606 | { |
576 | - if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
577 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
578 | - else |
|
579 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
607 | + if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
608 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
609 | + } else { |
|
610 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
580 | 611 | 'id' => $row['id_topic'], |
581 | 612 | 'subject' => un_htmlspecialchars($row['subject']), |
582 | 613 | 'count' => 1, |
583 | 614 | ); |
584 | - } |
|
585 | - elseif ($row['note_type'] == 'topic') |
|
615 | + } |
|
616 | + } elseif ($row['note_type'] == 'topic') |
|
586 | 617 | { |
587 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
588 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
618 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
619 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
589 | 620 | 'id' => $row['id_topic'], |
590 | 621 | 'subject' => un_htmlspecialchars($row['subject']), |
591 | 622 | ); |
592 | - } |
|
593 | - else |
|
623 | + } |
|
624 | + } else |
|
594 | 625 | { |
595 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
596 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
626 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
627 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
597 | 628 | 'id' => $row['id_topic'], |
598 | 629 | 'subject' => un_htmlspecialchars($row['subject']), |
599 | 630 | 'starter' => $row['id_member_started'], |
600 | 631 | ); |
632 | + } |
|
601 | 633 | } |
602 | 634 | |
603 | 635 | $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array(); |
604 | - if (!empty($notify['topics'][$row['id_topic']])) |
|
605 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
606 | - if (!empty($notify['boards'][$row['id_board']])) |
|
607 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
636 | + if (!empty($notify['topics'][$row['id_topic']])) { |
|
637 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
638 | + } |
|
639 | + if (!empty($notify['boards'][$row['id_board']])) { |
|
640 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
641 | + } |
|
608 | 642 | } |
609 | 643 | $smcFunc['db_free_result']($request); |
610 | 644 | |
611 | - if (empty($types)) |
|
612 | - return true; |
|
645 | + if (empty($types)) { |
|
646 | + return true; |
|
647 | + } |
|
613 | 648 | |
614 | 649 | // Let's load all the languages into a cache thingy. |
615 | 650 | $langtxt = array(); |
@@ -650,8 +685,9 @@ discard block |
||
650 | 685 | $notify_types = !empty($prefs[$mid]['msg_notify_type']) ? $prefs[$mid]['msg_notify_type'] : 1; |
651 | 686 | |
652 | 687 | // Did they not elect to choose this? |
653 | - if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) |
|
654 | - continue; |
|
688 | + if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) { |
|
689 | + continue; |
|
690 | + } |
|
655 | 691 | |
656 | 692 | // Right character set! |
657 | 693 | $context['character_set'] = empty($modSettings['global_character_set']) ? $langtxt[$lang]['char_set'] : $modSettings['global_character_set']; |
@@ -667,39 +703,43 @@ discard block |
||
667 | 703 | if (isset($types['topic'])) |
668 | 704 | { |
669 | 705 | $titled = false; |
670 | - foreach ($types['topic'] as $id => $board) |
|
671 | - foreach ($board['lines'] as $topic) |
|
706 | + foreach ($types['topic'] as $id => $board) { |
|
707 | + foreach ($board['lines'] as $topic) |
|
672 | 708 | if (in_array($mid, $topic['members'])) |
673 | 709 | { |
674 | 710 | if (!$titled) |
675 | 711 | { |
676 | 712 | $email['body'] .= "\n" . $langtxt[$lang]['new_topics'] . ':' . "\n" . '-----------------------------------------------'; |
713 | + } |
|
677 | 714 | $titled = true; |
678 | 715 | } |
679 | 716 | $email['body'] .= "\n" . sprintf($langtxt[$lang]['topic_lines'], $topic['subject'], $board['name']); |
680 | 717 | } |
681 | - if ($titled) |
|
682 | - $email['body'] .= "\n"; |
|
718 | + if ($titled) { |
|
719 | + $email['body'] .= "\n"; |
|
720 | + } |
|
683 | 721 | } |
684 | 722 | |
685 | 723 | // What about replies? |
686 | 724 | if (isset($types['reply'])) |
687 | 725 | { |
688 | 726 | $titled = false; |
689 | - foreach ($types['reply'] as $id => $board) |
|
690 | - foreach ($board['lines'] as $topic) |
|
727 | + foreach ($types['reply'] as $id => $board) { |
|
728 | + foreach ($board['lines'] as $topic) |
|
691 | 729 | if (in_array($mid, $topic['members'])) |
692 | 730 | { |
693 | 731 | if (!$titled) |
694 | 732 | { |
695 | 733 | $email['body'] .= "\n" . $langtxt[$lang]['new_replies'] . ':' . "\n" . '-----------------------------------------------'; |
734 | + } |
|
696 | 735 | $titled = true; |
697 | 736 | } |
698 | 737 | $email['body'] .= "\n" . ($topic['count'] == 1 ? sprintf($langtxt[$lang]['replies_one'], $topic['subject']) : sprintf($langtxt[$lang]['replies_many'], $topic['count'], $topic['subject'])); |
699 | 738 | } |
700 | 739 | |
701 | - if ($titled) |
|
702 | - $email['body'] .= "\n"; |
|
740 | + if ($titled) { |
|
741 | + $email['body'] .= "\n"; |
|
742 | + } |
|
703 | 743 | } |
704 | 744 | |
705 | 745 | // Finally, moderation actions! |
@@ -708,24 +748,27 @@ discard block |
||
708 | 748 | $titled = false; |
709 | 749 | foreach ($types as $note_type => $type) |
710 | 750 | { |
711 | - if ($note_type == 'topic' || $note_type == 'reply') |
|
712 | - continue; |
|
751 | + if ($note_type == 'topic' || $note_type == 'reply') { |
|
752 | + continue; |
|
753 | + } |
|
713 | 754 | |
714 | - foreach ($type as $id => $board) |
|
715 | - foreach ($board['lines'] as $topic) |
|
755 | + foreach ($type as $id => $board) { |
|
756 | + foreach ($board['lines'] as $topic) |
|
716 | 757 | if (in_array($mid, $topic['members'])) |
717 | 758 | { |
718 | 759 | if (!$titled) |
719 | 760 | { |
720 | 761 | $email['body'] .= "\n" . $langtxt[$lang]['mod_actions'] . ':' . "\n" . '-----------------------------------------------'; |
762 | + } |
|
721 | 763 | $titled = true; |
722 | 764 | } |
723 | 765 | $email['body'] .= "\n" . sprintf($langtxt[$lang][$note_type], $topic['subject']); |
724 | 766 | } |
725 | 767 | } |
726 | 768 | } |
727 | - if ($titled) |
|
728 | - $email['body'] .= "\n"; |
|
769 | + if ($titled) { |
|
770 | + $email['body'] .= "\n"; |
|
771 | + } |
|
729 | 772 | |
730 | 773 | // Then just say our goodbyes! |
731 | 774 | $email['body'] .= "\n\n" . $txt['regards_team']; |
@@ -753,8 +796,7 @@ discard block |
||
753 | 796 | 'not_daily' => 0, |
754 | 797 | ) |
755 | 798 | ); |
756 | - } |
|
757 | - else |
|
799 | + } else |
|
758 | 800 | { |
759 | 801 | // Clear any only weekly ones, and stop us from sending daily again. |
760 | 802 | $smcFunc['db_query']('', ' |
@@ -816,16 +858,19 @@ discard block |
||
816 | 858 | global $modSettings, $smcFunc, $sourcedir; |
817 | 859 | |
818 | 860 | // Are we intending another script to be sending out the queue? |
819 | - if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) |
|
820 | - return false; |
|
861 | + if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) { |
|
862 | + return false; |
|
863 | + } |
|
821 | 864 | |
822 | 865 | // By default send 5 at once. |
823 | - if (!$number) |
|
824 | - $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
866 | + if (!$number) { |
|
867 | + $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
868 | + } |
|
825 | 869 | |
826 | 870 | // If we came with a timestamp, and that doesn't match the next event, then someone else has beaten us. |
827 | - if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) |
|
828 | - return false; |
|
871 | + if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) { |
|
872 | + return false; |
|
873 | + } |
|
829 | 874 | |
830 | 875 | // By default move the next sending on by 10 seconds, and require an affected row. |
831 | 876 | if (!$override_limit) |
@@ -842,8 +887,9 @@ discard block |
||
842 | 887 | 'last_send' => $modSettings['mail_next_send'], |
843 | 888 | ) |
844 | 889 | ); |
845 | - if ($smcFunc['db_affected_rows']() == 0) |
|
846 | - return false; |
|
890 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
891 | + return false; |
|
892 | + } |
|
847 | 893 | $modSettings['mail_next_send'] = time() + $delay; |
848 | 894 | } |
849 | 895 | |
@@ -864,8 +910,9 @@ discard block |
||
864 | 910 | $mn += $number; |
865 | 911 | } |
866 | 912 | // No more I'm afraid, return! |
867 | - else |
|
868 | - return false; |
|
913 | + else { |
|
914 | + return false; |
|
915 | + } |
|
869 | 916 | |
870 | 917 | // Reflect that we're about to send some, do it now to be safe. |
871 | 918 | updateSettings(array('mail_recent' => $mt . '|' . $mn)); |
@@ -900,14 +947,15 @@ discard block |
||
900 | 947 | $smcFunc['db_free_result']($request); |
901 | 948 | |
902 | 949 | // Delete, delete, delete!!! |
903 | - if (!empty($ids)) |
|
904 | - $smcFunc['db_query']('', ' |
|
950 | + if (!empty($ids)) { |
|
951 | + $smcFunc['db_query']('', ' |
|
905 | 952 | DELETE FROM {db_prefix}mail_queue |
906 | 953 | WHERE id_mail IN ({array_int:mail_list})', |
907 | 954 | array( |
908 | 955 | 'mail_list' => $ids, |
909 | 956 | ) |
910 | 957 | ); |
958 | + } |
|
911 | 959 | |
912 | 960 | // Don't believe we have any left? |
913 | 961 | if (count($ids) < $number) |
@@ -925,11 +973,13 @@ discard block |
||
925 | 973 | ); |
926 | 974 | } |
927 | 975 | |
928 | - if (empty($ids)) |
|
929 | - return false; |
|
976 | + if (empty($ids)) { |
|
977 | + return false; |
|
978 | + } |
|
930 | 979 | |
931 | - if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') |
|
932 | - require_once($sourcedir . '/Subs-Post.php'); |
|
980 | + if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') { |
|
981 | + require_once($sourcedir . '/Subs-Post.php'); |
|
982 | + } |
|
933 | 983 | |
934 | 984 | // Send each email, yea! |
935 | 985 | $failed_emails = array(); |
@@ -949,15 +999,17 @@ discard block |
||
949 | 999 | |
950 | 1000 | // Try to stop a timeout, this would be bad... |
951 | 1001 | @set_time_limit(300); |
952 | - if (function_exists('apache_reset_timeout')) |
|
953 | - @apache_reset_timeout(); |
|
1002 | + if (function_exists('apache_reset_timeout')) { |
|
1003 | + @apache_reset_timeout(); |
|
1004 | + } |
|
1005 | + } else { |
|
1006 | + $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
954 | 1007 | } |
955 | - else |
|
956 | - $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
957 | 1008 | |
958 | 1009 | // Hopefully it sent? |
959 | - if (!$result) |
|
960 | - $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
1010 | + if (!$result) { |
|
1011 | + $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
1012 | + } |
|
961 | 1013 | } |
962 | 1014 | |
963 | 1015 | // Any emails that didn't send? |
@@ -972,8 +1024,8 @@ discard block |
||
972 | 1024 | ); |
973 | 1025 | |
974 | 1026 | // If we have failed to many times, tell mail to wait a bit and try again. |
975 | - if ($modSettings['mail_failed_attempts'] > 5) |
|
976 | - $smcFunc['db_query']('', ' |
|
1027 | + if ($modSettings['mail_failed_attempts'] > 5) { |
|
1028 | + $smcFunc['db_query']('', ' |
|
977 | 1029 | UPDATE {db_prefix}settings |
978 | 1030 | SET value = {string:next_mail_send} |
979 | 1031 | WHERE variable = {literal:mail_next_send} |
@@ -982,6 +1034,7 @@ discard block |
||
982 | 1034 | 'next_mail_send' => time() + 60, |
983 | 1035 | 'last_send' => $modSettings['mail_next_send'], |
984 | 1036 | )); |
1037 | + } |
|
985 | 1038 | |
986 | 1039 | // Add our email back to the queue, manually. |
987 | 1040 | $smcFunc['db_insert']('insert', |
@@ -994,8 +1047,8 @@ discard block |
||
994 | 1047 | return false; |
995 | 1048 | } |
996 | 1049 | // We where unable to send the email, clear our failed attempts. |
997 | - elseif (!empty($modSettings['mail_failed_attempts'])) |
|
998 | - $smcFunc['db_query']('', ' |
|
1050 | + elseif (!empty($modSettings['mail_failed_attempts'])) { |
|
1051 | + $smcFunc['db_query']('', ' |
|
999 | 1052 | UPDATE {db_prefix}settings |
1000 | 1053 | SET value = {string:zero} |
1001 | 1054 | WHERE variable = {string:mail_failed_attempts}', |
@@ -1003,6 +1056,7 @@ discard block |
||
1003 | 1056 | 'zero' => '0', |
1004 | 1057 | 'mail_failed_attempts' => 'mail_failed_attempts', |
1005 | 1058 | )); |
1059 | + } |
|
1006 | 1060 | |
1007 | 1061 | // Had something to send... |
1008 | 1062 | return true; |
@@ -1019,16 +1073,18 @@ discard block |
||
1019 | 1073 | global $modSettings, $smcFunc; |
1020 | 1074 | |
1021 | 1075 | $task_query = ''; |
1022 | - if (!is_array($tasks)) |
|
1023 | - $tasks = array($tasks); |
|
1076 | + if (!is_array($tasks)) { |
|
1077 | + $tasks = array($tasks); |
|
1078 | + } |
|
1024 | 1079 | |
1025 | 1080 | // Actually have something passed? |
1026 | 1081 | if (!empty($tasks)) |
1027 | 1082 | { |
1028 | - if (!isset($tasks[0]) || is_numeric($tasks[0])) |
|
1029 | - $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
1030 | - else |
|
1031 | - $task_query = ' AND task IN ({array_string:tasks})'; |
|
1083 | + if (!isset($tasks[0]) || is_numeric($tasks[0])) { |
|
1084 | + $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
1085 | + } else { |
|
1086 | + $task_query = ' AND task IN ({array_string:tasks})'; |
|
1087 | + } |
|
1032 | 1088 | } |
1033 | 1089 | $nextTaskTime = empty($tasks) ? time() + 86400 : $modSettings['next_task_time']; |
1034 | 1090 | |
@@ -1049,20 +1105,22 @@ discard block |
||
1049 | 1105 | $next_time = next_time($row['time_regularity'], $row['time_unit'], $row['time_offset']); |
1050 | 1106 | |
1051 | 1107 | // Only bother moving the task if it's out of place or we're forcing it! |
1052 | - if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) |
|
1053 | - $tasks[$row['id_task']] = $next_time; |
|
1054 | - else |
|
1055 | - $next_time = $row['next_time']; |
|
1108 | + if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) { |
|
1109 | + $tasks[$row['id_task']] = $next_time; |
|
1110 | + } else { |
|
1111 | + $next_time = $row['next_time']; |
|
1112 | + } |
|
1056 | 1113 | |
1057 | 1114 | // If this is sooner than the current next task, make this the next task. |
1058 | - if ($next_time < $nextTaskTime) |
|
1059 | - $nextTaskTime = $next_time; |
|
1115 | + if ($next_time < $nextTaskTime) { |
|
1116 | + $nextTaskTime = $next_time; |
|
1117 | + } |
|
1060 | 1118 | } |
1061 | 1119 | $smcFunc['db_free_result']($request); |
1062 | 1120 | |
1063 | 1121 | // Now make the changes! |
1064 | - foreach ($tasks as $id => $time) |
|
1065 | - $smcFunc['db_query']('', ' |
|
1122 | + foreach ($tasks as $id => $time) { |
|
1123 | + $smcFunc['db_query']('', ' |
|
1066 | 1124 | UPDATE {db_prefix}scheduled_tasks |
1067 | 1125 | SET next_time = {int:next_time} |
1068 | 1126 | WHERE id_task = {int:id_task}', |
@@ -1071,11 +1129,13 @@ discard block |
||
1071 | 1129 | 'id_task' => $id, |
1072 | 1130 | ) |
1073 | 1131 | ); |
1132 | + } |
|
1074 | 1133 | |
1075 | 1134 | // If the next task is now different update. |
1076 | - if ($modSettings['next_task_time'] != $nextTaskTime) |
|
1077 | - updateSettings(array('next_task_time' => $nextTaskTime)); |
|
1078 | -} |
|
1135 | + if ($modSettings['next_task_time'] != $nextTaskTime) { |
|
1136 | + updateSettings(array('next_task_time' => $nextTaskTime)); |
|
1137 | + } |
|
1138 | + } |
|
1079 | 1139 | |
1080 | 1140 | /** |
1081 | 1141 | * Simply returns a time stamp of the next instance of these time parameters. |
@@ -1088,8 +1148,9 @@ discard block |
||
1088 | 1148 | function next_time($regularity, $unit, $offset) |
1089 | 1149 | { |
1090 | 1150 | // Just in case! |
1091 | - if ($regularity == 0) |
|
1092 | - $regularity = 2; |
|
1151 | + if ($regularity == 0) { |
|
1152 | + $regularity = 2; |
|
1153 | + } |
|
1093 | 1154 | |
1094 | 1155 | $curMin = date('i', time()); |
1095 | 1156 | |
@@ -1099,15 +1160,16 @@ discard block |
||
1099 | 1160 | $off = date('i', $offset); |
1100 | 1161 | |
1101 | 1162 | // If it's now just pretend it ain't, |
1102 | - if ($off == $curMin) |
|
1103 | - $next_time = time() + $regularity; |
|
1104 | - else |
|
1163 | + if ($off == $curMin) { |
|
1164 | + $next_time = time() + $regularity; |
|
1165 | + } else |
|
1105 | 1166 | { |
1106 | 1167 | // Make sure that the offset is always in the past. |
1107 | 1168 | $off = $off > $curMin ? $off - 60 : $off; |
1108 | 1169 | |
1109 | - while ($off <= $curMin) |
|
1110 | - $off += $regularity; |
|
1170 | + while ($off <= $curMin) { |
|
1171 | + $off += $regularity; |
|
1172 | + } |
|
1111 | 1173 | |
1112 | 1174 | // Now we know when the time should be! |
1113 | 1175 | $next_time = time() + 60 * ($off - $curMin); |
@@ -1127,11 +1189,13 @@ discard block |
||
1127 | 1189 | // Default we'll jump in hours. |
1128 | 1190 | $applyOffset = 3600; |
1129 | 1191 | // 24 hours = 1 day. |
1130 | - if ($unit == 'd') |
|
1131 | - $applyOffset = 86400; |
|
1192 | + if ($unit == 'd') { |
|
1193 | + $applyOffset = 86400; |
|
1194 | + } |
|
1132 | 1195 | // Otherwise a week. |
1133 | - if ($unit == 'w') |
|
1134 | - $applyOffset = 604800; |
|
1196 | + if ($unit == 'w') { |
|
1197 | + $applyOffset = 604800; |
|
1198 | + } |
|
1135 | 1199 | |
1136 | 1200 | $applyOffset *= $regularity; |
1137 | 1201 | |
@@ -1168,8 +1232,9 @@ discard block |
||
1168 | 1232 | $settings[$row['variable']] = $row['value']; |
1169 | 1233 | |
1170 | 1234 | // Is this the default theme? |
1171 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') |
|
1172 | - $settings['default_' . $row['variable']] = $row['value']; |
|
1235 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') { |
|
1236 | + $settings['default_' . $row['variable']] = $row['value']; |
|
1237 | + } |
|
1173 | 1238 | } |
1174 | 1239 | $smcFunc['db_free_result']($result); |
1175 | 1240 | |
@@ -1179,12 +1244,14 @@ discard block |
||
1179 | 1244 | $settings['template_dirs'] = array($settings['theme_dir']); |
1180 | 1245 | |
1181 | 1246 | // Based on theme (if there is one). |
1182 | - if (!empty($settings['base_theme_dir'])) |
|
1183 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1247 | + if (!empty($settings['base_theme_dir'])) { |
|
1248 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1249 | + } |
|
1184 | 1250 | |
1185 | 1251 | // Lastly the default theme. |
1186 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
1187 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1252 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
1253 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1254 | + } |
|
1188 | 1255 | } |
1189 | 1256 | |
1190 | 1257 | // Assume we want this. |
@@ -1330,8 +1397,9 @@ discard block |
||
1330 | 1397 | // Ok should we prune the logs? |
1331 | 1398 | if (!empty($modSettings['pruningOptions'])) |
1332 | 1399 | { |
1333 | - if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) |
|
1334 | - list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
1400 | + if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) { |
|
1401 | + list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
1402 | + } |
|
1335 | 1403 | |
1336 | 1404 | if (!empty($modSettings['pruneErrorLog'])) |
1337 | 1405 | { |
@@ -1397,8 +1465,9 @@ discard block |
||
1397 | 1465 | ) |
1398 | 1466 | ); |
1399 | 1467 | |
1400 | - while ($row = $smcFunc['db_fetch_row']($result)) |
|
1401 | - $reports[] = $row[0]; |
|
1468 | + while ($row = $smcFunc['db_fetch_row']($result)) { |
|
1469 | + $reports[] = $row[0]; |
|
1470 | + } |
|
1402 | 1471 | |
1403 | 1472 | $smcFunc['db_free_result']($result); |
1404 | 1473 | |
@@ -1560,8 +1629,9 @@ discard block |
||
1560 | 1629 | $emaildata = loadEmailTemplate('paid_subscription_reminder', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']); |
1561 | 1630 | |
1562 | 1631 | // Send the actual email. |
1563 | - if ($notifyPrefs[$row['id_member']] & 0x02) |
|
1564 | - sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
1632 | + if ($notifyPrefs[$row['id_member']] & 0x02) { |
|
1633 | + sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
1634 | + } |
|
1565 | 1635 | |
1566 | 1636 | if ($notifyPrefs[$row['id_member']] & 0x01) |
1567 | 1637 | { |
@@ -1584,18 +1654,19 @@ discard block |
||
1584 | 1654 | } |
1585 | 1655 | |
1586 | 1656 | // Insert the alerts if any |
1587 | - if (!empty($alert_rows)) |
|
1588 | - $smcFunc['db_insert']('', |
|
1657 | + if (!empty($alert_rows)) { |
|
1658 | + $smcFunc['db_insert']('', |
|
1589 | 1659 | '{db_prefix}user_alerts', |
1590 | 1660 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
1591 | 1661 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
1592 | 1662 | $alert_rows, |
1593 | 1663 | array() |
1594 | 1664 | ); |
1665 | + } |
|
1595 | 1666 | |
1596 | 1667 | // Mark the reminder as sent. |
1597 | - if (!empty($subs_reminded)) |
|
1598 | - $smcFunc['db_query']('', ' |
|
1668 | + if (!empty($subs_reminded)) { |
|
1669 | + $smcFunc['db_query']('', ' |
|
1599 | 1670 | UPDATE {db_prefix}log_subscribed |
1600 | 1671 | SET reminder_sent = {int:reminder_sent} |
1601 | 1672 | WHERE id_sublog IN ({array_int:subscription_list})', |
@@ -1604,6 +1675,7 @@ discard block |
||
1604 | 1675 | 'reminder_sent' => 1, |
1605 | 1676 | ) |
1606 | 1677 | ); |
1678 | + } |
|
1607 | 1679 | |
1608 | 1680 | return true; |
1609 | 1681 | } |
@@ -1619,13 +1691,13 @@ discard block |
||
1619 | 1691 | // We need to know where this thing is going. |
1620 | 1692 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
1621 | 1693 | { |
1622 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
1623 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
1694 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
1695 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
1696 | + } |
|
1624 | 1697 | |
1625 | 1698 | // Just use the current path for temp files. |
1626 | 1699 | $attach_dirs = $modSettings['attachmentUploadDir']; |
1627 | - } |
|
1628 | - else |
|
1700 | + } else |
|
1629 | 1701 | { |
1630 | 1702 | $attach_dirs = array($modSettings['attachmentUploadDir']); |
1631 | 1703 | } |
@@ -1644,14 +1716,16 @@ discard block |
||
1644 | 1716 | |
1645 | 1717 | while ($file = readdir($dir)) |
1646 | 1718 | { |
1647 | - if ($file == '.' || $file == '..') |
|
1648 | - continue; |
|
1719 | + if ($file == '.' || $file == '..') { |
|
1720 | + continue; |
|
1721 | + } |
|
1649 | 1722 | |
1650 | 1723 | if (strpos($file, 'post_tmp_') !== false) |
1651 | 1724 | { |
1652 | 1725 | // Temp file is more than 5 hours old! |
1653 | - if (filemtime($attach_dir . '/' . $file) < time() - 18000) |
|
1654 | - @unlink($attach_dir . '/' . $file); |
|
1726 | + if (filemtime($attach_dir . '/' . $file) < time() - 18000) { |
|
1727 | + @unlink($attach_dir . '/' . $file); |
|
1728 | + } |
|
1655 | 1729 | } |
1656 | 1730 | } |
1657 | 1731 | closedir($dir); |
@@ -1684,8 +1758,9 @@ discard block |
||
1684 | 1758 | ) |
1685 | 1759 | ); |
1686 | 1760 | |
1687 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1688 | - $topics[] = $row[0]; |
|
1761 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1762 | + $topics[] = $row[0]; |
|
1763 | + } |
|
1689 | 1764 | $smcFunc['db_free_result']($request); |
1690 | 1765 | |
1691 | 1766 | // Zap, your gone |
@@ -1705,8 +1780,9 @@ discard block |
||
1705 | 1780 | { |
1706 | 1781 | global $smcFunc, $sourcedir, $modSettings; |
1707 | 1782 | |
1708 | - if (empty($modSettings['drafts_keep_days'])) |
|
1709 | - return true; |
|
1783 | + if (empty($modSettings['drafts_keep_days'])) { |
|
1784 | + return true; |
|
1785 | + } |
|
1710 | 1786 | |
1711 | 1787 | // init |
1712 | 1788 | $drafts = array(); |
@@ -1724,8 +1800,9 @@ discard block |
||
1724 | 1800 | ) |
1725 | 1801 | ); |
1726 | 1802 | |
1727 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1728 | - $drafts[] = (int) $row[0]; |
|
1803 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1804 | + $drafts[] = (int) $row[0]; |
|
1805 | + } |
|
1729 | 1806 | $smcFunc['db_free_result']($request); |
1730 | 1807 | |
1731 | 1808 | // If we have old one, remove them |