@@ -12,7 +12,8 @@ |
||
12 | 12 | header('Location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -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 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Get the latest posts of a forum. |
@@ -59,8 +60,9 @@ discard block |
||
59 | 60 | censorText($row['body']); |
60 | 61 | |
61 | 62 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
62 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
63 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
63 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
64 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
65 | + } |
|
64 | 66 | |
65 | 67 | // Build the array. |
66 | 68 | $posts[] = array( |
@@ -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 | * Put this user in the online log. |
@@ -33,8 +34,9 @@ discard block |
||
33 | 34 | // Don't update for every page - this isn't wholly accurate but who cares. |
34 | 35 | if ($topic) |
35 | 36 | { |
36 | - if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) |
|
37 | - $force = false; |
|
37 | + if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) { |
|
38 | + $force = false; |
|
39 | + } |
|
38 | 40 | $_SESSION['last_topic_id'] = $topic; |
39 | 41 | } |
40 | 42 | } |
@@ -47,22 +49,24 @@ discard block |
||
47 | 49 | } |
48 | 50 | |
49 | 51 | // Don't mark them as online more than every so often. |
50 | - if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) |
|
51 | - return; |
|
52 | + if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) { |
|
53 | + return; |
|
54 | + } |
|
52 | 55 | |
53 | 56 | if (!empty($modSettings['who_enabled'])) |
54 | 57 | { |
55 | 58 | $serialized = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']); |
56 | 59 | |
57 | 60 | // In the case of a dlattach action, session_var may not be set. |
58 | - if (!isset($context['session_var'])) |
|
59 | - $context['session_var'] = $_SESSION['session_var']; |
|
61 | + if (!isset($context['session_var'])) { |
|
62 | + $context['session_var'] = $_SESSION['session_var']; |
|
63 | + } |
|
60 | 64 | |
61 | 65 | unset($serialized['sesc'], $serialized[$context['session_var']]); |
62 | 66 | $serialized = json_encode($serialized); |
67 | + } else { |
|
68 | + $serialized = ''; |
|
63 | 69 | } |
64 | - else |
|
65 | - $serialized = ''; |
|
66 | 70 | |
67 | 71 | // Guests use 0, members use their session ID. |
68 | 72 | $session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(); |
@@ -102,17 +106,18 @@ discard block |
||
102 | 106 | ); |
103 | 107 | |
104 | 108 | // Guess it got deleted. |
105 | - if ($smcFunc['db_affected_rows']() == 0) |
|
109 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
110 | + $_SESSION['log_time'] = 0; |
|
111 | + } |
|
112 | + } else { |
|
106 | 113 | $_SESSION['log_time'] = 0; |
107 | 114 | } |
108 | - else |
|
109 | - $_SESSION['log_time'] = 0; |
|
110 | 115 | |
111 | 116 | // Otherwise, we have to delete and insert. |
112 | 117 | if (empty($_SESSION['log_time'])) |
113 | 118 | { |
114 | - if ($do_delete || !empty($user_info['id'])) |
|
115 | - $smcFunc['db_query']('', ' |
|
119 | + if ($do_delete || !empty($user_info['id'])) { |
|
120 | + $smcFunc['db_query']('', ' |
|
116 | 121 | DELETE FROM {db_prefix}log_online |
117 | 122 | WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'), |
118 | 123 | array( |
@@ -120,6 +125,7 @@ discard block |
||
120 | 125 | 'log_time' => time() - $modSettings['lastActive'] * 60, |
121 | 126 | ) |
122 | 127 | ); |
128 | + } |
|
123 | 129 | |
124 | 130 | $smcFunc['db_insert']($do_delete ? 'ignore' : 'replace', |
125 | 131 | '{db_prefix}log_online', |
@@ -133,21 +139,24 @@ discard block |
||
133 | 139 | $_SESSION['log_time'] = time(); |
134 | 140 | |
135 | 141 | // Well, they are online now. |
136 | - if (empty($_SESSION['timeOnlineUpdated'])) |
|
137 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
142 | + if (empty($_SESSION['timeOnlineUpdated'])) { |
|
143 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
144 | + } |
|
138 | 145 | |
139 | 146 | // Set their login time, if not already done within the last minute. |
140 | 147 | if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa')))) |
141 | 148 | { |
142 | 149 | // Don't count longer than 15 minutes. |
143 | - if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) |
|
144 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
150 | + if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) { |
|
151 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
152 | + } |
|
145 | 153 | |
146 | 154 | $user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
147 | 155 | updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in'])); |
148 | 156 | |
149 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
150 | - cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
157 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
158 | + cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
159 | + } |
|
151 | 160 | |
152 | 161 | $user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
153 | 162 | $_SESSION['timeOnlineUpdated'] = time(); |
@@ -184,8 +193,7 @@ discard block |
||
184 | 193 | // Oops. maybe we have no more disk space left, or some other troubles, troubles... |
185 | 194 | // Copy the file back and run for your life! |
186 | 195 | @copy($boarddir . '/db_last_error_bak.php', $boarddir . '/db_last_error.php'); |
187 | - } |
|
188 | - else |
|
196 | + } else |
|
189 | 197 | { |
190 | 198 | @touch($boarddir . '/' . 'Settings.php'); |
191 | 199 | return true; |
@@ -205,22 +213,27 @@ discard block |
||
205 | 213 | global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt; |
206 | 214 | |
207 | 215 | // Add to Settings.php if you want to show the debugging information. |
208 | - if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) |
|
209 | - return; |
|
216 | + if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) { |
|
217 | + return; |
|
218 | + } |
|
210 | 219 | |
211 | - if (empty($_SESSION['view_queries'])) |
|
212 | - $_SESSION['view_queries'] = 0; |
|
213 | - if (empty($context['debug']['language_files'])) |
|
214 | - $context['debug']['language_files'] = array(); |
|
215 | - if (empty($context['debug']['sheets'])) |
|
216 | - $context['debug']['sheets'] = array(); |
|
220 | + if (empty($_SESSION['view_queries'])) { |
|
221 | + $_SESSION['view_queries'] = 0; |
|
222 | + } |
|
223 | + if (empty($context['debug']['language_files'])) { |
|
224 | + $context['debug']['language_files'] = array(); |
|
225 | + } |
|
226 | + if (empty($context['debug']['sheets'])) { |
|
227 | + $context['debug']['sheets'] = array(); |
|
228 | + } |
|
217 | 229 | |
218 | 230 | $files = get_included_files(); |
219 | 231 | $total_size = 0; |
220 | 232 | for ($i = 0, $n = count($files); $i < $n; $i++) |
221 | 233 | { |
222 | - if (file_exists($files[$i])) |
|
223 | - $total_size += filesize($files[$i]); |
|
234 | + if (file_exists($files[$i])) { |
|
235 | + $total_size += filesize($files[$i]); |
|
236 | + } |
|
224 | 237 | $files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)')); |
225 | 238 | } |
226 | 239 | |
@@ -229,8 +242,9 @@ discard block |
||
229 | 242 | { |
230 | 243 | foreach ($db_cache as $q => $qq) |
231 | 244 | { |
232 | - if (!empty($qq['w'])) |
|
233 | - $warnings += count($qq['w']); |
|
245 | + if (!empty($qq['w'])) { |
|
246 | + $warnings += count($qq['w']); |
|
247 | + } |
|
234 | 248 | } |
235 | 249 | |
236 | 250 | $_SESSION['debug'] = &$db_cache; |
@@ -251,12 +265,14 @@ discard block |
||
251 | 265 | ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
252 | 266 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
253 | 267 | |
254 | - if (function_exists('memory_get_peak_usage')) |
|
255 | - echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
268 | + if (function_exists('memory_get_peak_usage')) { |
|
269 | + echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
270 | + } |
|
256 | 271 | |
257 | 272 | // What tokens are active? |
258 | - if (isset($_SESSION['token'])) |
|
259 | - echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
273 | + if (isset($_SESSION['token'])) { |
|
274 | + echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
275 | + } |
|
260 | 276 | |
261 | 277 | if (!empty($modSettings['cache_enable']) && !empty($cache_hits)) |
262 | 278 | { |
@@ -269,10 +285,12 @@ discard block |
||
269 | 285 | $total_t += $cache_hit['t']; |
270 | 286 | $total_s += $cache_hit['s']; |
271 | 287 | } |
272 | - if (!isset($cache_misses)) |
|
273 | - $cache_misses = array(); |
|
274 | - foreach ($cache_misses as $missed) |
|
275 | - $missed_entires[] = $missed['d'] . ' ' . $missed['k']; |
|
288 | + if (!isset($cache_misses)) { |
|
289 | + $cache_misses = array(); |
|
290 | + } |
|
291 | + foreach ($cache_misses as $missed) { |
|
292 | + $missed_entires[] = $missed['d'] . ' ' . $missed['k']; |
|
293 | + } |
|
276 | 294 | |
277 | 295 | echo ' |
278 | 296 | ', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br> |
@@ -283,38 +301,44 @@ discard block |
||
283 | 301 | <a href="', $scripturl, '?action=viewquery" target="_blank" class="new_win">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br> |
284 | 302 | <br>'; |
285 | 303 | |
286 | - if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) |
|
287 | - foreach ($db_cache as $q => $qq) |
|
304 | + if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) { |
|
305 | + foreach ($db_cache as $q => $qq) |
|
288 | 306 | { |
289 | 307 | $is_select = strpos(trim($qq['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($qq['q'])) != 0; |
308 | + } |
|
290 | 309 | // Temporary tables created in earlier queries are not explainable. |
291 | 310 | if ($is_select) |
292 | 311 | { |
293 | - foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) |
|
294 | - if (strpos(trim($qq['q']), $tmp) !== false) |
|
312 | + foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) { |
|
313 | + if (strpos(trim($qq['q']), $tmp) !== false) |
|
295 | 314 | { |
296 | 315 | $is_select = false; |
316 | + } |
|
297 | 317 | break; |
298 | 318 | } |
299 | 319 | } |
300 | 320 | // But actual creation of the temporary tables are. |
301 | - elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) |
|
302 | - $is_select = true; |
|
321 | + elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) { |
|
322 | + $is_select = true; |
|
323 | + } |
|
303 | 324 | |
304 | 325 | // Make the filenames look a bit better. |
305 | - if (isset($qq['f'])) |
|
306 | - $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']); |
|
326 | + if (isset($qq['f'])) { |
|
327 | + $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']); |
|
328 | + } |
|
307 | 329 | |
308 | 330 | echo ' |
309 | 331 | <strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" class="new_win" style="text-decoration: none;">' : '', nl2br(str_replace("\t", ' ', $smcFunc['htmlspecialchars'](ltrim($qq['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br> |
310 | 332 | '; |
311 | - if (!empty($qq['f']) && !empty($qq['l'])) |
|
312 | - echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']); |
|
333 | + if (!empty($qq['f']) && !empty($qq['l'])) { |
|
334 | + echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']); |
|
335 | + } |
|
313 | 336 | |
314 | - if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) |
|
315 | - echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>'; |
|
316 | - elseif (isset($qq['t'])) |
|
317 | - echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>'; |
|
337 | + if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) { |
|
338 | + echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>'; |
|
339 | + } elseif (isset($qq['t'])) { |
|
340 | + echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>'; |
|
341 | + } |
|
318 | 342 | echo ' |
319 | 343 | <br>'; |
320 | 344 | } |
@@ -339,12 +363,14 @@ discard block |
||
339 | 363 | global $modSettings, $smcFunc; |
340 | 364 | static $cache_stats = array(); |
341 | 365 | |
342 | - if (empty($modSettings['trackStats'])) |
|
343 | - return false; |
|
344 | - if (!empty($stats)) |
|
345 | - return $cache_stats = array_merge($cache_stats, $stats); |
|
346 | - elseif (empty($cache_stats)) |
|
347 | - return false; |
|
366 | + if (empty($modSettings['trackStats'])) { |
|
367 | + return false; |
|
368 | + } |
|
369 | + if (!empty($stats)) { |
|
370 | + return $cache_stats = array_merge($cache_stats, $stats); |
|
371 | + } elseif (empty($cache_stats)) { |
|
372 | + return false; |
|
373 | + } |
|
348 | 374 | |
349 | 375 | $setStringUpdate = ''; |
350 | 376 | $insert_keys = array(); |
@@ -357,10 +383,11 @@ discard block |
||
357 | 383 | $setStringUpdate .= ' |
358 | 384 | ' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ','; |
359 | 385 | |
360 | - if ($change === '+') |
|
361 | - $cache_stats[$field] = 1; |
|
362 | - else |
|
363 | - $update_parameters[$field] = $change; |
|
386 | + if ($change === '+') { |
|
387 | + $cache_stats[$field] = 1; |
|
388 | + } else { |
|
389 | + $update_parameters[$field] = $change; |
|
390 | + } |
|
364 | 391 | $insert_keys[$field] = 'int'; |
365 | 392 | } |
366 | 393 | |
@@ -424,43 +451,50 @@ discard block |
||
424 | 451 | ); |
425 | 452 | |
426 | 453 | // Make sure this particular log is enabled first... |
427 | - if (empty($modSettings['modlog_enabled'])) |
|
428 | - unset ($log_types['moderate']); |
|
429 | - if (empty($modSettings['userlog_enabled'])) |
|
430 | - unset ($log_types['user']); |
|
431 | - if (empty($modSettings['adminlog_enabled'])) |
|
432 | - unset ($log_types['admin']); |
|
454 | + if (empty($modSettings['modlog_enabled'])) { |
|
455 | + unset ($log_types['moderate']); |
|
456 | + } |
|
457 | + if (empty($modSettings['userlog_enabled'])) { |
|
458 | + unset ($log_types['user']); |
|
459 | + } |
|
460 | + if (empty($modSettings['adminlog_enabled'])) { |
|
461 | + unset ($log_types['admin']); |
|
462 | + } |
|
433 | 463 | |
434 | 464 | call_integration_hook('integrate_log_types', array(&$log_types)); |
435 | 465 | |
436 | 466 | foreach ($logs as $log) |
437 | 467 | { |
438 | - if (!isset($log_types[$log['log_type']])) |
|
439 | - return false; |
|
468 | + if (!isset($log_types[$log['log_type']])) { |
|
469 | + return false; |
|
470 | + } |
|
440 | 471 | |
441 | - if (!is_array($log['extra'])) |
|
442 | - trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
472 | + if (!is_array($log['extra'])) { |
|
473 | + trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
474 | + } |
|
443 | 475 | |
444 | 476 | // Pull out the parts we want to store separately, but also make sure that the data is proper |
445 | 477 | if (isset($log['extra']['topic'])) |
446 | 478 | { |
447 | - if (!is_numeric($log['extra']['topic'])) |
|
448 | - trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
479 | + if (!is_numeric($log['extra']['topic'])) { |
|
480 | + trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
481 | + } |
|
449 | 482 | $topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic']; |
450 | 483 | unset($log['extra']['topic']); |
484 | + } else { |
|
485 | + $topic_id = 0; |
|
451 | 486 | } |
452 | - else |
|
453 | - $topic_id = 0; |
|
454 | 487 | |
455 | 488 | if (isset($log['extra']['message'])) |
456 | 489 | { |
457 | - if (!is_numeric($log['extra']['message'])) |
|
458 | - trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
490 | + if (!is_numeric($log['extra']['message'])) { |
|
491 | + trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
492 | + } |
|
459 | 493 | $msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message']; |
460 | 494 | unset($log['extra']['message']); |
495 | + } else { |
|
496 | + $msg_id = 0; |
|
461 | 497 | } |
462 | - else |
|
463 | - $msg_id = 0; |
|
464 | 498 | |
465 | 499 | // @todo cache this? |
466 | 500 | // Is there an associated report on this? |
@@ -487,23 +521,26 @@ discard block |
||
487 | 521 | $smcFunc['db_free_result']($request); |
488 | 522 | } |
489 | 523 | |
490 | - if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) |
|
491 | - trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
524 | + if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) { |
|
525 | + trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
526 | + } |
|
492 | 527 | |
493 | 528 | if (isset($log['extra']['board'])) |
494 | 529 | { |
495 | - if (!is_numeric($log['extra']['board'])) |
|
496 | - trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
530 | + if (!is_numeric($log['extra']['board'])) { |
|
531 | + trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
532 | + } |
|
497 | 533 | $board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board']; |
498 | 534 | unset($log['extra']['board']); |
535 | + } else { |
|
536 | + $board_id = 0; |
|
499 | 537 | } |
500 | - else |
|
501 | - $board_id = 0; |
|
502 | 538 | |
503 | 539 | if (isset($log['extra']['board_to'])) |
504 | 540 | { |
505 | - if (!is_numeric($log['extra']['board_to'])) |
|
506 | - trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
541 | + if (!is_numeric($log['extra']['board_to'])) { |
|
542 | + trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
543 | + } |
|
507 | 544 | if (empty($board_id)) |
508 | 545 | { |
509 | 546 | $board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to']; |
@@ -511,10 +548,11 @@ discard block |
||
511 | 548 | } |
512 | 549 | } |
513 | 550 | |
514 | - if (isset($log['extra']['member_affected'])) |
|
515 | - $memID = $log['extra']['member_affected']; |
|
516 | - else |
|
517 | - $memID = $user_info['id']; |
|
551 | + if (isset($log['extra']['member_affected'])) { |
|
552 | + $memID = $log['extra']['member_affected']; |
|
553 | + } else { |
|
554 | + $memID = $user_info['id']; |
|
555 | + } |
|
518 | 556 | |
519 | 557 | $inserts[] = array( |
520 | 558 | time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'], |
@@ -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 | * Used for the "custom search index" option |
@@ -54,8 +55,9 @@ discard block |
||
54 | 55 | return; |
55 | 56 | } |
56 | 57 | |
57 | - if (empty($modSettings['search_custom_index_config'])) |
|
58 | - return; |
|
58 | + if (empty($modSettings['search_custom_index_config'])) { |
|
59 | + return; |
|
60 | + } |
|
59 | 61 | |
60 | 62 | $this->indexSettings = smf_json_decode($modSettings['search_custom_index_config'], true); |
61 | 63 | |
@@ -118,21 +120,23 @@ discard block |
||
118 | 120 | |
119 | 121 | $subwords = text2words($word, $this->min_word_length, true); |
120 | 122 | |
121 | - if (empty($modSettings['search_force_index'])) |
|
122 | - $wordsSearch['words'][] = $word; |
|
123 | + if (empty($modSettings['search_force_index'])) { |
|
124 | + $wordsSearch['words'][] = $word; |
|
125 | + } |
|
123 | 126 | |
124 | 127 | // Excluded phrases don't benefit from being split into subwords. |
125 | - if (count($subwords) > 1 && $isExcluded) |
|
126 | - return; |
|
127 | - else |
|
128 | + if (count($subwords) > 1 && $isExcluded) { |
|
129 | + return; |
|
130 | + } else |
|
128 | 131 | { |
129 | 132 | foreach ($subwords as $subword) |
130 | 133 | { |
131 | 134 | if ($smcFunc['strlen']($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords)) |
132 | 135 | { |
133 | 136 | $wordsSearch['indexed_words'][] = $subword; |
134 | - if ($isExcluded) |
|
135 | - $wordsExclude[] = $subword; |
|
137 | + if ($isExcluded) { |
|
138 | + $wordsExclude[] = $subword; |
|
139 | + } |
|
136 | 140 | } |
137 | 141 | } |
138 | 142 | } |
@@ -153,8 +157,9 @@ discard block |
||
153 | 157 | $query_where = array(); |
154 | 158 | $query_params = $search_data['params']; |
155 | 159 | |
156 | - if ($query_params['id_search']) |
|
157 | - $query_select['id_search'] = '{int:id_search}'; |
|
160 | + if ($query_params['id_search']) { |
|
161 | + $query_select['id_search'] = '{int:id_search}'; |
|
162 | + } |
|
158 | 163 | |
159 | 164 | $count = 0; |
160 | 165 | foreach ($words['words'] as $regularWord) |
@@ -163,30 +168,37 @@ discard block |
||
163 | 168 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
164 | 169 | } |
165 | 170 | |
166 | - if ($query_params['user_query']) |
|
167 | - $query_where[] = '{raw:user_query}'; |
|
168 | - if ($query_params['board_query']) |
|
169 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
171 | + if ($query_params['user_query']) { |
|
172 | + $query_where[] = '{raw:user_query}'; |
|
173 | + } |
|
174 | + if ($query_params['board_query']) { |
|
175 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
176 | + } |
|
170 | 177 | |
171 | - if ($query_params['topic']) |
|
172 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
173 | - if ($query_params['min_msg_id']) |
|
174 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
175 | - if ($query_params['max_msg_id']) |
|
176 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
178 | + if ($query_params['topic']) { |
|
179 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
180 | + } |
|
181 | + if ($query_params['min_msg_id']) { |
|
182 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
183 | + } |
|
184 | + if ($query_params['max_msg_id']) { |
|
185 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
186 | + } |
|
177 | 187 | |
178 | 188 | $count = 0; |
179 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
180 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
189 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
190 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
181 | 191 | { |
182 | 192 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_phrase_' . $count . '}'; |
193 | + } |
|
183 | 194 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
184 | 195 | } |
185 | 196 | $count = 0; |
186 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
187 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
197 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
198 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
188 | 199 | { |
189 | 200 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_words_' . $count . '}'; |
201 | + } |
|
190 | 202 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
191 | 203 | } |
192 | 204 | |
@@ -199,8 +211,7 @@ discard block |
||
199 | 211 | { |
200 | 212 | $query_left_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_word = ' . $indexedWord . ' AND lsw' . $numTables . '.id_msg = m.id_msg)'; |
201 | 213 | $query_where[] = '(lsw' . $numTables . '.id_word IS NULL)'; |
202 | - } |
|
203 | - else |
|
214 | + } else |
|
204 | 215 | { |
205 | 216 | $query_inner_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_msg = ' . ($prev_join === 0 ? 'm' : 'lsw' . $prev_join) . '.id_msg)'; |
206 | 217 | $query_where[] = 'lsw' . $numTables . '.id_word = ' . $indexedWord; |
@@ -236,16 +247,18 @@ discard block |
||
236 | 247 | $customIndexSettings = smf_json_decode($modSettings['search_custom_index_config'], true); |
237 | 248 | |
238 | 249 | $inserts = array(); |
239 | - foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) |
|
240 | - $inserts[] = array($word, $msgOptions['id']); |
|
250 | + foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) { |
|
251 | + $inserts[] = array($word, $msgOptions['id']); |
|
252 | + } |
|
241 | 253 | |
242 | - if (!empty($inserts)) |
|
243 | - $smcFunc['db_insert']('ignore', |
|
254 | + if (!empty($inserts)) { |
|
255 | + $smcFunc['db_insert']('ignore', |
|
244 | 256 | '{db_prefix}log_search_words', |
245 | 257 | array('id_word' => 'int', 'id_msg' => 'int'), |
246 | 258 | $inserts, |
247 | 259 | array('id_word', 'id_msg') |
248 | 260 | ); |
261 | + } |
|
249 | 262 | } |
250 | 263 | |
251 | 264 | /** |
@@ -288,8 +301,9 @@ discard block |
||
288 | 301 | if (!empty($inserted_words)) |
289 | 302 | { |
290 | 303 | $inserts = array(); |
291 | - foreach ($inserted_words as $word) |
|
292 | - $inserts[] = array($word, $msgOptions['id']); |
|
304 | + foreach ($inserted_words as $word) { |
|
305 | + $inserts[] = array($word, $msgOptions['id']); |
|
306 | + } |
|
293 | 307 | $smcFunc['db_insert']('insert', |
294 | 308 | '{db_prefix}log_search_words', |
295 | 309 | array('id_word' => 'string', 'id_msg' => 'int'), |
@@ -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 | * Delete one of more membergroups. |
@@ -31,15 +32,16 @@ discard block |
||
31 | 32 | global $smcFunc, $modSettings, $txt; |
32 | 33 | |
33 | 34 | // Make sure it's an array. |
34 | - if (!is_array($groups)) |
|
35 | - $groups = array((int) $groups); |
|
36 | - else |
|
35 | + if (!is_array($groups)) { |
|
36 | + $groups = array((int) $groups); |
|
37 | + } else |
|
37 | 38 | { |
38 | 39 | $groups = array_unique($groups); |
39 | 40 | |
40 | 41 | // Make sure all groups are integer. |
41 | - foreach ($groups as $key => $value) |
|
42 | - $groups[$key] = (int) $value; |
|
42 | + foreach ($groups as $key => $value) { |
|
43 | + $groups[$key] = (int) $value; |
|
44 | + } |
|
43 | 45 | } |
44 | 46 | |
45 | 47 | // Some groups are protected (guests, administrators, moderators, newbies). |
@@ -56,15 +58,17 @@ discard block |
||
56 | 58 | 'is_protected' => 1, |
57 | 59 | ) |
58 | 60 | ); |
59 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
60 | - $protected_groups[] = $row['id_group']; |
|
61 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
62 | + $protected_groups[] = $row['id_group']; |
|
63 | + } |
|
61 | 64 | $smcFunc['db_free_result']($request); |
62 | 65 | } |
63 | 66 | |
64 | 67 | // Make sure they don't delete protected groups! |
65 | 68 | $groups = array_diff($groups, array_unique($protected_groups)); |
66 | - if (empty($groups)) |
|
67 | - return 'no_group_found'; |
|
69 | + if (empty($groups)) { |
|
70 | + return 'no_group_found'; |
|
71 | + } |
|
68 | 72 | |
69 | 73 | // Make sure they don't try to delete a group attached to a paid subscription. |
70 | 74 | $subscriptions = array(); |
@@ -74,13 +78,14 @@ discard block |
||
74 | 78 | ORDER BY name'); |
75 | 79 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
76 | 80 | { |
77 | - if (in_array($row['id_group'], $groups)) |
|
78 | - $subscriptions[] = $row['name']; |
|
79 | - else |
|
81 | + if (in_array($row['id_group'], $groups)) { |
|
82 | + $subscriptions[] = $row['name']; |
|
83 | + } else |
|
80 | 84 | { |
81 | 85 | $add_groups = explode(',', $row['add_groups']); |
82 | - if (count(array_intersect($add_groups, $groups)) != 0) |
|
83 | - $subscriptions[] = $row['name']; |
|
86 | + if (count(array_intersect($add_groups, $groups)) != 0) { |
|
87 | + $subscriptions[] = $row['name']; |
|
88 | + } |
|
84 | 89 | } |
85 | 90 | } |
86 | 91 | $smcFunc['db_free_result']($request); |
@@ -101,8 +106,9 @@ discard block |
||
101 | 106 | 'group_list' => $groups, |
102 | 107 | ) |
103 | 108 | ); |
104 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
105 | - logAction('delete_group', array('group' => $row['group_name']), 'admin'); |
|
109 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
110 | + logAction('delete_group', array('group' => $row['group_name']), 'admin'); |
|
111 | + } |
|
106 | 112 | $smcFunc['db_free_result']($request); |
107 | 113 | |
108 | 114 | call_integration_hook('integrate_delete_membergroups', array($groups)); |
@@ -187,12 +193,14 @@ discard block |
||
187 | 193 | ) |
188 | 194 | ); |
189 | 195 | $updates = array(); |
190 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
191 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
196 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
197 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
198 | + } |
|
192 | 199 | $smcFunc['db_free_result']($request); |
193 | 200 | |
194 | - foreach ($updates as $additional_groups => $memberArray) |
|
195 | - updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups)))); |
|
201 | + foreach ($updates as $additional_groups => $memberArray) { |
|
202 | + updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups)))); |
|
203 | + } |
|
196 | 204 | |
197 | 205 | // No boards can provide access to these membergroups anymore. |
198 | 206 | $request = $smcFunc['db_query']('', ' |
@@ -204,12 +212,13 @@ discard block |
||
204 | 212 | ) |
205 | 213 | ); |
206 | 214 | $updates = array(); |
207 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
208 | - $updates[$row['member_groups']][] = $row['id_board']; |
|
215 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
216 | + $updates[$row['member_groups']][] = $row['id_board']; |
|
217 | + } |
|
209 | 218 | $smcFunc['db_free_result']($request); |
210 | 219 | |
211 | - foreach ($updates as $member_groups => $boardArray) |
|
212 | - $smcFunc['db_query']('', ' |
|
220 | + foreach ($updates as $member_groups => $boardArray) { |
|
221 | + $smcFunc['db_query']('', ' |
|
213 | 222 | UPDATE {db_prefix}boards |
214 | 223 | SET member_groups = {string:member_groups} |
215 | 224 | WHERE id_board IN ({array_int:board_lists})', |
@@ -218,6 +227,7 @@ discard block |
||
218 | 227 | 'member_groups' => implode(',', array_diff(explode(',', $member_groups), $groups)), |
219 | 228 | ) |
220 | 229 | ); |
230 | + } |
|
221 | 231 | |
222 | 232 | // Recalculate the post groups, as they likely changed. |
223 | 233 | updateStats('postgroups'); |
@@ -225,8 +235,9 @@ discard block |
||
225 | 235 | // Make a note of the fact that the cache may be wrong. |
226 | 236 | $settings_update = array('settings_updated' => time()); |
227 | 237 | // Have we deleted the spider group? |
228 | - if (isset($modSettings['spider_group']) && in_array($modSettings['spider_group'], $groups)) |
|
229 | - $settings_update['spider_group'] = 0; |
|
238 | + if (isset($modSettings['spider_group']) && in_array($modSettings['spider_group'], $groups)) { |
|
239 | + $settings_update['spider_group'] = 0; |
|
240 | + } |
|
230 | 241 | |
231 | 242 | updateSettings($settings_update); |
232 | 243 | |
@@ -250,22 +261,24 @@ discard block |
||
250 | 261 | global $smcFunc, $modSettings, $sourcedir; |
251 | 262 | |
252 | 263 | // You're getting nowhere without this permission, unless of course you are the group's moderator. |
253 | - if (!$permissionCheckDone) |
|
254 | - isAllowedTo('manage_membergroups'); |
|
264 | + if (!$permissionCheckDone) { |
|
265 | + isAllowedTo('manage_membergroups'); |
|
266 | + } |
|
255 | 267 | |
256 | 268 | // Assume something will happen. |
257 | 269 | updateSettings(array('settings_updated' => time())); |
258 | 270 | |
259 | 271 | // Cleaning the input. |
260 | - if (!is_array($members)) |
|
261 | - $members = array((int) $members); |
|
262 | - else |
|
272 | + if (!is_array($members)) { |
|
273 | + $members = array((int) $members); |
|
274 | + } else |
|
263 | 275 | { |
264 | 276 | $members = array_unique($members); |
265 | 277 | |
266 | 278 | // Cast the members to integer. |
267 | - foreach ($members as $key => $value) |
|
268 | - $members[$key] = (int) $value; |
|
279 | + foreach ($members as $key => $value) { |
|
280 | + $members[$key] = (int) $value; |
|
281 | + } |
|
269 | 282 | } |
270 | 283 | |
271 | 284 | // Before we get started, let's check we won't leave the admin group empty! |
@@ -277,14 +290,15 @@ discard block |
||
277 | 290 | // Remove any admins if there are too many. |
278 | 291 | $non_changing_admins = array_diff(array_keys($admins), $members); |
279 | 292 | |
280 | - if (empty($non_changing_admins)) |
|
281 | - $members = array_diff($members, array_keys($admins)); |
|
293 | + if (empty($non_changing_admins)) { |
|
294 | + $members = array_diff($members, array_keys($admins)); |
|
295 | + } |
|
282 | 296 | } |
283 | 297 | |
284 | 298 | // Just in case. |
285 | - if (empty($members)) |
|
286 | - return false; |
|
287 | - elseif ($groups === null) |
|
299 | + if (empty($members)) { |
|
300 | + return false; |
|
301 | + } elseif ($groups === null) |
|
288 | 302 | { |
289 | 303 | // Wanna remove all groups from these members? That's easy. |
290 | 304 | $smcFunc['db_query']('', ' |
@@ -306,20 +320,21 @@ discard block |
||
306 | 320 | updateStats('postgroups', $members); |
307 | 321 | |
308 | 322 | // Log what just happened. |
309 | - foreach ($members as $member) |
|
310 | - logAction('removed_all_groups', array('member' => $member), 'admin'); |
|
323 | + foreach ($members as $member) { |
|
324 | + logAction('removed_all_groups', array('member' => $member), 'admin'); |
|
325 | + } |
|
311 | 326 | |
312 | 327 | return true; |
313 | - } |
|
314 | - elseif (!is_array($groups)) |
|
315 | - $groups = array((int) $groups); |
|
316 | - else |
|
328 | + } elseif (!is_array($groups)) { |
|
329 | + $groups = array((int) $groups); |
|
330 | + } else |
|
317 | 331 | { |
318 | 332 | $groups = array_unique($groups); |
319 | 333 | |
320 | 334 | // Make sure all groups are integer. |
321 | - foreach ($groups as $key => $value) |
|
322 | - $groups[$key] = (int) $value; |
|
335 | + foreach ($groups as $key => $value) { |
|
336 | + $groups[$key] = (int) $value; |
|
337 | + } |
|
323 | 338 | } |
324 | 339 | |
325 | 340 | // Fetch a list of groups members cannot be assigned to explicitly, and the group names of the ones we want. |
@@ -335,10 +350,11 @@ discard block |
||
335 | 350 | $group_names = array(); |
336 | 351 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
337 | 352 | { |
338 | - if ($row['min_posts'] != -1) |
|
339 | - $implicitGroups[] = $row['id_group']; |
|
340 | - else |
|
341 | - $group_names[$row['id_group']] = $row['group_name']; |
|
353 | + if ($row['min_posts'] != -1) { |
|
354 | + $implicitGroups[] = $row['id_group']; |
|
355 | + } else { |
|
356 | + $group_names[$row['id_group']] = $row['group_name']; |
|
357 | + } |
|
342 | 358 | } |
343 | 359 | $smcFunc['db_free_result']($request); |
344 | 360 | |
@@ -357,8 +373,9 @@ discard block |
||
357 | 373 | ) |
358 | 374 | ); |
359 | 375 | $protected_groups = array(1); |
360 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
361 | - $protected_groups[] = $row['id_group']; |
|
376 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
377 | + $protected_groups[] = $row['id_group']; |
|
378 | + } |
|
362 | 379 | $smcFunc['db_free_result']($request); |
363 | 380 | |
364 | 381 | // If you're not an admin yourself, you can't touch protected groups! |
@@ -366,8 +383,9 @@ discard block |
||
366 | 383 | } |
367 | 384 | |
368 | 385 | // Only continue if there are still groups and members left. |
369 | - if (empty($groups) || empty($members)) |
|
370 | - return false; |
|
386 | + if (empty($groups) || empty($members)) { |
|
387 | + return false; |
|
388 | + } |
|
371 | 389 | |
372 | 390 | // First, reset those who have this as their primary group - this is the easy one. |
373 | 391 | $log_inserts = array(); |
@@ -381,8 +399,9 @@ discard block |
||
381 | 399 | 'member_list' => $members, |
382 | 400 | ) |
383 | 401 | ); |
384 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
385 | - $log_inserts[] = array('group' => $group_names[$row['id_group']], 'member' => $row['id_member']); |
|
402 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
403 | + $log_inserts[] = array('group' => $group_names[$row['id_group']], 'member' => $row['id_member']); |
|
404 | + } |
|
386 | 405 | $smcFunc['db_free_result']($request); |
387 | 406 | |
388 | 407 | $smcFunc['db_query']('', ' |
@@ -414,16 +433,17 @@ discard block |
||
414 | 433 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
415 | 434 | { |
416 | 435 | // What log entries must we make for this one, eh? |
417 | - foreach (explode(',', $row['additional_groups']) as $group) |
|
418 | - if (in_array($group, $groups)) |
|
436 | + foreach (explode(',', $row['additional_groups']) as $group) { |
|
437 | + if (in_array($group, $groups)) |
|
419 | 438 | $log_inserts[] = array('group' => $group_names[$group], 'member' => $row['id_member']); |
439 | + } |
|
420 | 440 | |
421 | 441 | $updates[$row['additional_groups']][] = $row['id_member']; |
422 | 442 | } |
423 | 443 | $smcFunc['db_free_result']($request); |
424 | 444 | |
425 | - foreach ($updates as $additional_groups => $memberArray) |
|
426 | - $smcFunc['db_query']('', ' |
|
445 | + foreach ($updates as $additional_groups => $memberArray) { |
|
446 | + $smcFunc['db_query']('', ' |
|
427 | 447 | UPDATE {db_prefix}members |
428 | 448 | SET additional_groups = {string:additional_groups} |
429 | 449 | WHERE id_member IN ({array_int:member_list})', |
@@ -432,6 +452,7 @@ discard block |
||
432 | 452 | 'additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups)), |
433 | 453 | ) |
434 | 454 | ); |
455 | + } |
|
435 | 456 | |
436 | 457 | // Their post groups may have changed now... |
437 | 458 | updateStats('postgroups', $members); |
@@ -440,8 +461,9 @@ discard block |
||
440 | 461 | if (!empty($log_inserts) && !empty($modSettings['modlog_enabled'])) |
441 | 462 | { |
442 | 463 | require_once($sourcedir . '/Logging.php'); |
443 | - foreach ($log_inserts as $extra) |
|
444 | - logAction('removed_from_group', $extra, 'admin'); |
|
464 | + foreach ($log_inserts as $extra) { |
|
465 | + logAction('removed_from_group', $extra, 'admin'); |
|
466 | + } |
|
445 | 467 | } |
446 | 468 | |
447 | 469 | // Mission successful. |
@@ -477,21 +499,23 @@ discard block |
||
477 | 499 | global $smcFunc, $sourcedir; |
478 | 500 | |
479 | 501 | // Show your licence, but only if it hasn't been done yet. |
480 | - if (!$permissionCheckDone) |
|
481 | - isAllowedTo('manage_membergroups'); |
|
502 | + if (!$permissionCheckDone) { |
|
503 | + isAllowedTo('manage_membergroups'); |
|
504 | + } |
|
482 | 505 | |
483 | 506 | // Make sure we don't keep old stuff cached. |
484 | 507 | updateSettings(array('settings_updated' => time())); |
485 | 508 | |
486 | - if (!is_array($members)) |
|
487 | - $members = array((int) $members); |
|
488 | - else |
|
509 | + if (!is_array($members)) { |
|
510 | + $members = array((int) $members); |
|
511 | + } else |
|
489 | 512 | { |
490 | 513 | $members = array_unique($members); |
491 | 514 | |
492 | 515 | // Make sure all members are integer. |
493 | - foreach ($members as $key => $value) |
|
494 | - $members[$key] = (int) $value; |
|
516 | + foreach ($members as $key => $value) { |
|
517 | + $members[$key] = (int) $value; |
|
518 | + } |
|
495 | 519 | } |
496 | 520 | $group = (int) $group; |
497 | 521 | |
@@ -508,20 +532,23 @@ discard block |
||
508 | 532 | $group_names = array(); |
509 | 533 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
510 | 534 | { |
511 | - if ($row['min_posts'] != -1) |
|
512 | - $implicitGroups[] = $row['id_group']; |
|
513 | - else |
|
514 | - $group_names[$row['id_group']] = $row['group_name']; |
|
535 | + if ($row['min_posts'] != -1) { |
|
536 | + $implicitGroups[] = $row['id_group']; |
|
537 | + } else { |
|
538 | + $group_names[$row['id_group']] = $row['group_name']; |
|
539 | + } |
|
515 | 540 | } |
516 | 541 | $smcFunc['db_free_result']($request); |
517 | 542 | |
518 | 543 | // Sorry, you can't join an implicit group. |
519 | - if (in_array($group, $implicitGroups) || empty($members)) |
|
520 | - return false; |
|
544 | + if (in_array($group, $implicitGroups) || empty($members)) { |
|
545 | + return false; |
|
546 | + } |
|
521 | 547 | |
522 | 548 | // Only admins can add admins... |
523 | - if (!allowedTo('admin_forum') && $group == 1) |
|
524 | - return false; |
|
549 | + if (!allowedTo('admin_forum') && $group == 1) { |
|
550 | + return false; |
|
551 | + } |
|
525 | 552 | // ... and assign protected groups! |
526 | 553 | elseif (!allowedTo('admin_forum') && !$ignoreProtected) |
527 | 554 | { |
@@ -539,13 +566,14 @@ discard block |
||
539 | 566 | $smcFunc['db_free_result']($request); |
540 | 567 | |
541 | 568 | // Is it protected? |
542 | - if ($is_protected == 1) |
|
543 | - return false; |
|
569 | + if ($is_protected == 1) { |
|
570 | + return false; |
|
571 | + } |
|
544 | 572 | } |
545 | 573 | |
546 | 574 | // Do the actual updates. |
547 | - if ($type == 'only_additional') |
|
548 | - $smcFunc['db_query']('', ' |
|
575 | + if ($type == 'only_additional') { |
|
576 | + $smcFunc['db_query']('', ' |
|
549 | 577 | UPDATE {db_prefix}members |
550 | 578 | SET additional_groups = CASE WHEN additional_groups = {string:blank_string} THEN {string:id_group_string} ELSE CONCAT(additional_groups, {string:id_group_string_extend}) END |
551 | 579 | WHERE id_member IN ({array_int:member_list}) |
@@ -559,8 +587,8 @@ discard block |
||
559 | 587 | 'blank_string' => '', |
560 | 588 | ) |
561 | 589 | ); |
562 | - elseif ($type == 'only_primary' || $type == 'force_primary') |
|
563 | - $smcFunc['db_query']('', ' |
|
590 | + } elseif ($type == 'only_primary' || $type == 'force_primary') { |
|
591 | + $smcFunc['db_query']('', ' |
|
564 | 592 | UPDATE {db_prefix}members |
565 | 593 | SET id_group = {int:id_group} |
566 | 594 | WHERE id_member IN ({array_int:member_list})' . ($type == 'force_primary' ? '' : ' |
@@ -572,8 +600,8 @@ discard block |
||
572 | 600 | 'regular_group' => 0, |
573 | 601 | ) |
574 | 602 | ); |
575 | - elseif ($type == 'auto') |
|
576 | - $smcFunc['db_query']('', ' |
|
603 | + } elseif ($type == 'auto') { |
|
604 | + $smcFunc['db_query']('', ' |
|
577 | 605 | UPDATE {db_prefix}members |
578 | 606 | SET |
579 | 607 | id_group = CASE WHEN id_group = {int:regular_group} THEN {int:id_group} ELSE id_group END, |
@@ -592,9 +620,11 @@ discard block |
||
592 | 620 | 'id_group_string_extend' => ',' . $group, |
593 | 621 | ) |
594 | 622 | ); |
623 | + } |
|
595 | 624 | // Ack!!? What happened? |
596 | - else |
|
597 | - trigger_error('addMembersToGroup(): Unknown type \'' . $type . '\'', E_USER_WARNING); |
|
625 | + else { |
|
626 | + trigger_error('addMembersToGroup(): Unknown type \'' . $type . '\'', E_USER_WARNING); |
|
627 | + } |
|
598 | 628 | |
599 | 629 | call_integration_hook('integrate_add_members_to_group', array($members, $group, &$group_names)); |
600 | 630 | |
@@ -603,8 +633,9 @@ discard block |
||
603 | 633 | |
604 | 634 | // Log the data. |
605 | 635 | require_once($sourcedir . '/Logging.php'); |
606 | - foreach ($members as $member) |
|
607 | - logAction('added_to_group', array('group' => $group_names[$group], 'member' => $member), 'admin'); |
|
636 | + foreach ($members as $member) { |
|
637 | + logAction('added_to_group', array('group' => $group_names[$group], 'member' => $member), 'admin'); |
|
638 | + } |
|
608 | 639 | |
609 | 640 | return true; |
610 | 641 | } |
@@ -632,8 +663,9 @@ discard block |
||
632 | 663 | ) |
633 | 664 | ); |
634 | 665 | $members = array(); |
635 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
636 | - $members[$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
666 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
667 | + $members[$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
668 | + } |
|
637 | 669 | $smcFunc['db_free_result']($request); |
638 | 670 | |
639 | 671 | // If there are more than $limit members, add a 'more' link. |
@@ -641,10 +673,10 @@ discard block |
||
641 | 673 | { |
642 | 674 | array_pop($members); |
643 | 675 | return true; |
676 | + } else { |
|
677 | + return false; |
|
678 | + } |
|
644 | 679 | } |
645 | - else |
|
646 | - return false; |
|
647 | -} |
|
648 | 680 | |
649 | 681 | /** |
650 | 682 | * Retrieve a list of (visible) membergroups used by the cache. |
@@ -669,8 +701,9 @@ discard block |
||
669 | 701 | ) |
670 | 702 | ); |
671 | 703 | $groupCache = array(); |
672 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
673 | - $groupCache[] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_group'] . '" ' . ($row['online_color'] ? 'style="color: ' . $row['online_color'] . '"' : '') . '>' . $row['group_name'] . '</a>'; |
|
704 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
705 | + $groupCache[] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_group'] . '" ' . ($row['online_color'] ? 'style="color: ' . $row['online_color'] . '"' : '') . '>' . $row['group_name'] . '</a>'; |
|
706 | + } |
|
674 | 707 | $smcFunc['db_free_result']($request); |
675 | 708 | |
676 | 709 | return array( |
@@ -718,8 +751,9 @@ discard block |
||
718 | 751 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
719 | 752 | { |
720 | 753 | // We only list the groups they can see. |
721 | - if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) |
|
722 | - continue; |
|
754 | + if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) { |
|
755 | + continue; |
|
756 | + } |
|
723 | 757 | |
724 | 758 | $row['icons'] = explode('#', $row['icons']); |
725 | 759 | |
@@ -754,12 +788,11 @@ discard block |
||
754 | 788 | 'group_list' => $group_ids, |
755 | 789 | ) |
756 | 790 | ); |
757 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
758 | - $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
791 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
792 | + $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
793 | + } |
|
759 | 794 | $smcFunc['db_free_result']($query); |
760 | - } |
|
761 | - |
|
762 | - else |
|
795 | + } else |
|
763 | 796 | { |
764 | 797 | $query = $smcFunc['db_query']('', ' |
765 | 798 | SELECT id_group, COUNT(*) AS num_members |
@@ -770,8 +803,9 @@ discard block |
||
770 | 803 | 'group_list' => $group_ids, |
771 | 804 | ) |
772 | 805 | ); |
773 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
774 | - $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
806 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
807 | + $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
808 | + } |
|
775 | 809 | $smcFunc['db_free_result']($query); |
776 | 810 | |
777 | 811 | // Only do additional groups if we can moderate... |
@@ -790,8 +824,9 @@ discard block |
||
790 | 824 | 'blank_string' => '', |
791 | 825 | ) |
792 | 826 | ); |
793 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
794 | - $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
827 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
828 | + $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
829 | + } |
|
795 | 830 | $smcFunc['db_free_result']($query); |
796 | 831 | } |
797 | 832 | } |
@@ -805,8 +840,9 @@ discard block |
||
805 | 840 | 'group_list' => $group_ids, |
806 | 841 | ) |
807 | 842 | ); |
808 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
809 | - $groups[$row['id_group']]['moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
843 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
844 | + $groups[$row['id_group']]['moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
845 | + } |
|
810 | 846 | $smcFunc['db_free_result']($query); |
811 | 847 | } |
812 | 848 | |
@@ -815,8 +851,9 @@ discard block |
||
815 | 851 | { |
816 | 852 | $sort_ascending = strpos($sort, 'DESC') === false; |
817 | 853 | |
818 | - foreach ($groups as $group) |
|
819 | - $sort_array[] = $group['id_group'] != 3 ? (int) $group['num_members'] : -1; |
|
854 | + foreach ($groups as $group) { |
|
855 | + $sort_array[] = $group['id_group'] != 3 ? (int) $group['num_members'] : -1; |
|
856 | + } |
|
820 | 857 | |
821 | 858 | array_multisort($sort_array, $sort_ascending ? SORT_ASC : SORT_DESC, SORT_REGULAR, $groups); |
822 | 859 | } |
@@ -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 | * Redirect to the user help ;). |
@@ -95,12 +96,13 @@ discard block |
||
95 | 96 | ); |
96 | 97 | |
97 | 98 | // Have we got a localized one? |
98 | - if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) |
|
99 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
100 | - elseif (file_exists($boarddir . '/agreement.txt')) |
|
101 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
102 | - else |
|
103 | - $context['agreement'] = ''; |
|
99 | + if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) { |
|
100 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
101 | + } elseif (file_exists($boarddir . '/agreement.txt')) { |
|
102 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
103 | + } else { |
|
104 | + $context['agreement'] = ''; |
|
105 | + } |
|
104 | 106 | |
105 | 107 | // Nothing to show, so let's get out of here |
106 | 108 | if (empty($context['agreement'])) |
@@ -128,18 +130,21 @@ discard block |
||
128 | 130 | { |
129 | 131 | global $txt, $helptxt, $context, $scripturl; |
130 | 132 | |
131 | - if (!isset($_GET['help']) || !is_string($_GET['help'])) |
|
132 | - fatal_lang_error('no_access', false); |
|
133 | + if (!isset($_GET['help']) || !is_string($_GET['help'])) { |
|
134 | + fatal_lang_error('no_access', false); |
|
135 | + } |
|
133 | 136 | |
134 | - if (!isset($helptxt)) |
|
135 | - $helptxt = array(); |
|
137 | + if (!isset($helptxt)) { |
|
138 | + $helptxt = array(); |
|
139 | + } |
|
136 | 140 | |
137 | 141 | // Load the admin help language file and template. |
138 | 142 | loadLanguage('Help'); |
139 | 143 | |
140 | 144 | // Permission specific help? |
141 | - if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp') |
|
142 | - loadLanguage('ManagePermissions'); |
|
145 | + if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp') { |
|
146 | + loadLanguage('ManagePermissions'); |
|
147 | + } |
|
143 | 148 | |
144 | 149 | loadTemplate('Help'); |
145 | 150 | |
@@ -154,16 +159,18 @@ discard block |
||
154 | 159 | $context['sub_template'] = 'popup'; |
155 | 160 | |
156 | 161 | // What help string should be used? |
157 | - if (isset($helptxt[$_GET['help']])) |
|
158 | - $context['help_text'] = $helptxt[$_GET['help']]; |
|
159 | - elseif (isset($txt[$_GET['help']])) |
|
160 | - $context['help_text'] = $txt[$_GET['help']]; |
|
161 | - else |
|
162 | - $context['help_text'] = $_GET['help']; |
|
162 | + if (isset($helptxt[$_GET['help']])) { |
|
163 | + $context['help_text'] = $helptxt[$_GET['help']]; |
|
164 | + } elseif (isset($txt[$_GET['help']])) { |
|
165 | + $context['help_text'] = $txt[$_GET['help']]; |
|
166 | + } else { |
|
167 | + $context['help_text'] = $_GET['help']; |
|
168 | + } |
|
163 | 169 | |
164 | 170 | // Does this text contain a link that we should fill in? |
165 | - if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match)) |
|
166 | - $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']); |
|
167 | -} |
|
171 | + if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match)) { |
|
172 | + $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']); |
|
173 | + } |
|
174 | + } |
|
168 | 175 | |
169 | 176 | ?> |
170 | 177 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Create a menu. |
@@ -64,22 +65,26 @@ discard block |
||
64 | 65 | $menu_context['current_action'] = isset($menuOptions['action']) ? $menuOptions['action'] : $context['current_action']; |
65 | 66 | |
66 | 67 | // Allow extend *any* menu with a single hook |
67 | - if (!empty($menu_context['current_action'])) |
|
68 | - call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData)); |
|
68 | + if (!empty($menu_context['current_action'])) { |
|
69 | + call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData)); |
|
70 | + } |
|
69 | 71 | |
70 | 72 | // What is the current area selected? |
71 | - if (isset($menuOptions['current_area']) || isset($_GET['area'])) |
|
72 | - $menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area']; |
|
73 | + if (isset($menuOptions['current_area']) || isset($_GET['area'])) { |
|
74 | + $menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area']; |
|
75 | + } |
|
73 | 76 | |
74 | 77 | // Build a list of additional parameters that should go in the URL. |
75 | 78 | $menu_context['extra_parameters'] = ''; |
76 | - if (!empty($menuOptions['extra_url_parameters'])) |
|
77 | - foreach ($menuOptions['extra_url_parameters'] as $key => $value) |
|
79 | + if (!empty($menuOptions['extra_url_parameters'])) { |
|
80 | + foreach ($menuOptions['extra_url_parameters'] as $key => $value) |
|
78 | 81 | $menu_context['extra_parameters'] .= ';' . $key . '=' . $value; |
82 | + } |
|
79 | 83 | |
80 | 84 | // Only include the session ID in the URL if it's strictly necessary. |
81 | - if (empty($menuOptions['disable_url_session_check'])) |
|
82 | - $menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id']; |
|
85 | + if (empty($menuOptions['disable_url_session_check'])) { |
|
86 | + $menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id']; |
|
87 | + } |
|
83 | 88 | |
84 | 89 | $include_data = array(); |
85 | 90 | |
@@ -87,8 +92,9 @@ discard block |
||
87 | 92 | foreach ($menuData as $section_id => $section) |
88 | 93 | { |
89 | 94 | // Is this enabled - or has as permission check - which fails? |
90 | - if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) |
|
91 | - continue; |
|
95 | + if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) { |
|
96 | + continue; |
|
97 | + } |
|
92 | 98 | |
93 | 99 | // Now we cycle through the sections to pick the right area. |
94 | 100 | foreach ($section['areas'] as $area_id => $area) |
@@ -110,41 +116,45 @@ discard block |
||
110 | 116 | if (empty($area['hidden'])) |
111 | 117 | { |
112 | 118 | // First time this section? |
113 | - if (!isset($menu_context['sections'][$section_id])) |
|
114 | - $menu_context['sections'][$section_id]['title'] = $section['title']; |
|
119 | + if (!isset($menu_context['sections'][$section_id])) { |
|
120 | + $menu_context['sections'][$section_id]['title'] = $section['title']; |
|
121 | + } |
|
115 | 122 | |
116 | 123 | $menu_context['sections'][$section_id]['areas'][$area_id] = array('label' => isset($area['label']) ? $area['label'] : $txt[$area_id]); |
117 | 124 | // We'll need the ID as well... |
118 | 125 | $menu_context['sections'][$section_id]['id'] = $section_id; |
119 | 126 | // Does it have a custom URL? |
120 | - if (isset($area['custom_url'])) |
|
121 | - $menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url']; |
|
127 | + if (isset($area['custom_url'])) { |
|
128 | + $menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url']; |
|
129 | + } |
|
122 | 130 | |
123 | 131 | // Does this area have its own icon? |
124 | - if (!isset($area['force_menu_into_arms_of_another_menu']) && $user_info['name'] == 'iamanoompaloompa') |
|
125 | - $menu_context['sections'][$section_id]['areas'][$area_id] = safe_unserialize(base64_decode('YTozOntzOjU6ImxhYmVsIjtzOjEyOiJPb21wYSBMb29tcGEiO3M6MzoidXJsIjtzOjQzOiJodHRwOi8vZW4ud2lraXBlZGlhLm9yZy93aWtpL09vbXBhX0xvb21wYXM/IjtzOjQ6Imljb24iO3M6ODY6IjxpbWcgc3JjPSJodHRwOi8vd3d3LnNpbXBsZW1hY2hpbmVzLm9yZy9pbWFnZXMvb29tcGEuZ2lmIiBhbHQ9IkknbSBhbiBPb21wYSBMb29tcGEiIC8+Ijt9')); |
|
126 | - elseif (isset($area['icon']) && file_exists($settings['theme_dir'] . '/images/admin/' . $area['icon'])) |
|
127 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
|
128 | - elseif (isset($area['icon']) && file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon'])) |
|
129 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['default_images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
|
130 | - elseif (isset($area['icon'])) |
|
131 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>'; |
|
132 | - else |
|
133 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>'; |
|
134 | - |
|
135 | - if (isset($area['icon_class']) && empty($menu_context['sections'][$section_id]['areas'][$area_id]['icon'])) |
|
136 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . $area['icon_class']; |
|
137 | - elseif (isset($area['icon'])) |
|
132 | + if (!isset($area['force_menu_into_arms_of_another_menu']) && $user_info['name'] == 'iamanoompaloompa') { |
|
133 | + $menu_context['sections'][$section_id]['areas'][$area_id] = safe_unserialize(base64_decode('YTozOntzOjU6ImxhYmVsIjtzOjEyOiJPb21wYSBMb29tcGEiO3M6MzoidXJsIjtzOjQzOiJodHRwOi8vZW4ud2lraXBlZGlhLm9yZy93aWtpL09vbXBhX0xvb21wYXM/IjtzOjQ6Imljb24iO3M6ODY6IjxpbWcgc3JjPSJodHRwOi8vd3d3LnNpbXBsZW1hY2hpbmVzLm9yZy9pbWFnZXMvb29tcGEuZ2lmIiBhbHQ9IkknbSBhbiBPb21wYSBMb29tcGEiIC8+Ijt9')); |
|
134 | + } elseif (isset($area['icon']) && file_exists($settings['theme_dir'] . '/images/admin/' . $area['icon'])) { |
|
135 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
|
136 | + } elseif (isset($area['icon']) && file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon'])) { |
|
137 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['default_images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
|
138 | + } elseif (isset($area['icon'])) { |
|
139 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>'; |
|
140 | + } else { |
|
141 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>'; |
|
142 | + } |
|
143 | + |
|
144 | + if (isset($area['icon_class']) && empty($menu_context['sections'][$section_id]['areas'][$area_id]['icon'])) { |
|
145 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . $area['icon_class']; |
|
146 | + } elseif (isset($area['icon'])) |
|
138 | 147 | { |
139 | - if ((substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') && file_exists($settings['theme_dir'] . '/images/admin/big/' . $area['icon'])) |
|
140 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['theme_url'] . '/images/admin/big/' . $area['icon']; |
|
141 | - elseif ((substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') && file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon'])) |
|
142 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['default_theme_url'] . '/images/admin/big/' . $area['icon']; |
|
148 | + if ((substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') && file_exists($settings['theme_dir'] . '/images/admin/big/' . $area['icon'])) { |
|
149 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['theme_url'] . '/images/admin/big/' . $area['icon']; |
|
150 | + } elseif ((substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') && file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon'])) { |
|
151 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['default_theme_url'] . '/images/admin/big/' . $area['icon']; |
|
152 | + } |
|
143 | 153 | |
144 | 154 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area['icon']); |
155 | + } else { |
|
156 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id); |
|
145 | 157 | } |
146 | - else |
|
147 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id); |
|
148 | 158 | |
149 | 159 | // Some areas may be listed but not active, which we show as greyed out. |
150 | 160 | $menu_context['sections'][$section_id]['areas'][$area_id]['inactive'] = !empty($area['inactive']); |
@@ -158,35 +168,41 @@ discard block |
||
158 | 168 | { |
159 | 169 | if ((empty($sub[1]) || allowedTo($sub[1])) && (!isset($sub['enabled']) || !empty($sub['enabled']))) |
160 | 170 | { |
161 | - if ($first_sa == null) |
|
162 | - $first_sa = $sa; |
|
171 | + if ($first_sa == null) { |
|
172 | + $first_sa = $sa; |
|
173 | + } |
|
163 | 174 | |
164 | 175 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa] = array('label' => $sub[0]); |
165 | 176 | // Custom URL? |
166 | - if (isset($sub['url'])) |
|
167 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url']; |
|
177 | + if (isset($sub['url'])) { |
|
178 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url']; |
|
179 | + } |
|
168 | 180 | |
169 | 181 | // A bit complicated - but is this set? |
170 | 182 | if ($menu_context['current_area'] == $area_id) |
171 | 183 | { |
172 | 184 | // Save which is the first... |
173 | - if (empty($first_sa)) |
|
174 | - $first_sa = $sa; |
|
185 | + if (empty($first_sa)) { |
|
186 | + $first_sa = $sa; |
|
187 | + } |
|
175 | 188 | |
176 | 189 | // Is this the current subsection? |
177 | - if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) |
|
178 | - $menu_context['current_subsection'] = $sa; |
|
190 | + if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) { |
|
191 | + $menu_context['current_subsection'] = $sa; |
|
192 | + } |
|
179 | 193 | // Otherwise is it the default? |
180 | - elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) |
|
181 | - $menu_context['current_subsection'] = $sa; |
|
194 | + elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) { |
|
195 | + $menu_context['current_subsection'] = $sa; |
|
196 | + } |
|
182 | 197 | } |
183 | 198 | |
184 | 199 | // Let's assume this is the last, for now. |
185 | 200 | $last_sa = $sa; |
186 | 201 | } |
187 | 202 | // Mark it as disabled... |
188 | - else |
|
189 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true; |
|
203 | + else { |
|
204 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true; |
|
205 | + } |
|
190 | 206 | } |
191 | 207 | |
192 | 208 | // Set which one is first, last and selected in the group. |
@@ -195,8 +211,9 @@ discard block |
||
195 | 211 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $last_sa : $first_sa]['is_first'] = true; |
196 | 212 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $first_sa : $last_sa]['is_last'] = true; |
197 | 213 | |
198 | - if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) |
|
199 | - $menu_context['current_subsection'] = $first_sa; |
|
214 | + if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) { |
|
215 | + $menu_context['current_subsection'] = $first_sa; |
|
216 | + } |
|
200 | 217 | } |
201 | 218 | } |
202 | 219 | } |
@@ -230,23 +247,26 @@ discard block |
||
230 | 247 | $menu_context['base_url'] = isset($menuOptions['base_url']) ? $menuOptions['base_url'] : $scripturl . '?action=' . $menu_context['current_action']; |
231 | 248 | |
232 | 249 | // If we didn't find the area we were looking for go to a default one. |
233 | - if (isset($backup_area) && empty($found_section)) |
|
234 | - $menu_context['current_area'] = $backup_area; |
|
250 | + if (isset($backup_area) && empty($found_section)) { |
|
251 | + $menu_context['current_area'] = $backup_area; |
|
252 | + } |
|
235 | 253 | |
236 | 254 | // If there are sections quickly goes through all the sections to check if the base menu has an url |
237 | 255 | if (!empty($menu_context['current_section'])) |
238 | 256 | { |
239 | 257 | $menu_context['sections'][$menu_context['current_section']]['selected'] = true; |
240 | 258 | $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['selected'] = true; |
241 | - if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) |
|
242 | - $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true; |
|
259 | + if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) { |
|
260 | + $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true; |
|
261 | + } |
|
243 | 262 | |
244 | - foreach ($menu_context['sections'] as $section_id => $section) |
|
245 | - foreach ($section['areas'] as $area_id => $area) |
|
263 | + foreach ($menu_context['sections'] as $section_id => $section) { |
|
264 | + foreach ($section['areas'] as $area_id => $area) |
|
246 | 265 | { |
247 | 266 | if (!isset($menu_context['sections'][$section_id]['url'])) |
248 | 267 | { |
249 | 268 | $menu_context['sections'][$section_id]['url'] = isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $area_id; |
269 | + } |
|
250 | 270 | break; |
251 | 271 | } |
252 | 272 | } |
@@ -257,8 +277,9 @@ discard block |
||
257 | 277 | { |
258 | 278 | // Never happened! |
259 | 279 | $context['max_menu_id']--; |
260 | - if ($context['max_menu_id'] == 0) |
|
261 | - unset($context['max_menu_id']); |
|
280 | + if ($context['max_menu_id'] == 0) { |
|
281 | + unset($context['max_menu_id']); |
|
282 | + } |
|
262 | 283 | |
263 | 284 | return false; |
264 | 285 | } |
@@ -269,8 +290,9 @@ discard block |
||
269 | 290 | $context['template_layers'][] = $menu_context['layer_name']; |
270 | 291 | |
271 | 292 | // Check we had something - for sanity sake. |
272 | - if (empty($include_data)) |
|
273 | - return false; |
|
293 | + if (empty($include_data)) { |
|
294 | + return false; |
|
295 | + } |
|
274 | 296 | |
275 | 297 | // Finally - return information on the selected item. |
276 | 298 | $include_data += array( |
@@ -293,12 +315,14 @@ discard block |
||
293 | 315 | global $context; |
294 | 316 | |
295 | 317 | $menu_name = $menu_id == 'last' && isset($context['max_menu_id']) && isset($context['menu_data_' . $context['max_menu_id']]) ? 'menu_data_' . $context['max_menu_id'] : 'menu_data_' . $menu_id; |
296 | - if (!isset($context[$menu_name])) |
|
297 | - return false; |
|
318 | + if (!isset($context[$menu_name])) { |
|
319 | + return false; |
|
320 | + } |
|
298 | 321 | |
299 | 322 | $layer_index = array_search($context[$menu_name]['layer_name'], $context['template_layers']); |
300 | - if ($layer_index !== false) |
|
301 | - unset($context['template_layers'][$layer_index]); |
|
323 | + if ($layer_index !== false) { |
|
324 | + unset($context['template_layers'][$layer_index]); |
|
325 | + } |
|
302 | 326 | |
303 | 327 | unset($context[$menu_name]); |
304 | 328 | } |
@@ -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 | * This function shows the board index. |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | $context['canonical_url'] = $scripturl; |
35 | 36 | |
36 | 37 | // Do not let search engines index anything if there is a random thing in $_GET. |
37 | - if (!empty($_GET)) |
|
38 | - $context['robot_no_index'] = true; |
|
38 | + if (!empty($_GET)) { |
|
39 | + $context['robot_no_index'] = true; |
|
40 | + } |
|
39 | 41 | |
40 | 42 | // Retrieve the categories and boards. |
41 | 43 | require_once($sourcedir . '/Subs-BoardIndex.php'); |
@@ -62,11 +64,12 @@ discard block |
||
62 | 64 | $context['latest_posts'] = cache_quick_get('boardindex-latest_posts:' . md5($user_info['query_wanna_see_board'] . $user_info['language']), 'Subs-Recent.php', 'cache_getLastPosts', array($latestPostOptions)); |
63 | 65 | } |
64 | 66 | |
65 | - if (!empty($context['latest_posts']) || !empty($context['latest_post'])) |
|
66 | - $context['info_center'][] = array( |
|
67 | + if (!empty($context['latest_posts']) || !empty($context['latest_post'])) { |
|
68 | + $context['info_center'][] = array( |
|
67 | 69 | 'tpl' => 'recent', |
68 | 70 | 'txt' => 'recent_posts', |
69 | 71 | ); |
72 | + } |
|
70 | 73 | } |
71 | 74 | |
72 | 75 | // Load the calendar? |
@@ -87,20 +90,22 @@ discard block |
||
87 | 90 | // This is used to show the "how-do-I-edit" help. |
88 | 91 | $context['calendar_can_edit'] = allowedTo('calendar_edit_any'); |
89 | 92 | |
90 | - if ($context['show_calendar']) |
|
91 | - $context['info_center'][] = array( |
|
93 | + if ($context['show_calendar']) { |
|
94 | + $context['info_center'][] = array( |
|
92 | 95 | 'tpl' => 'calendar', |
93 | 96 | 'txt' => $context['calendar_only_today'] ? 'calendar_today' : 'calendar_upcoming', |
94 | 97 | ); |
98 | + } |
|
95 | 99 | } |
96 | 100 | |
97 | 101 | // And stats. |
98 | 102 | $context['show_stats'] = allowedTo('view_stats') && !empty($modSettings['trackStats']); |
99 | - if ($settings['show_stats_index']) |
|
100 | - $context['info_center'][] = array( |
|
103 | + if ($settings['show_stats_index']) { |
|
104 | + $context['info_center'][] = array( |
|
101 | 105 | 'tpl' => 'stats', |
102 | 106 | 'txt' => 'forum_stats', |
103 | 107 | ); |
108 | + } |
|
104 | 109 | |
105 | 110 | // Now the online stuff |
106 | 111 | require_once($sourcedir . '/Subs-MembersOnline.php'); |
@@ -118,12 +123,14 @@ discard block |
||
118 | 123 | ); |
119 | 124 | |
120 | 125 | // Track most online statistics? (Subs-MembersOnline.php) |
121 | - if (!empty($modSettings['trackStats'])) |
|
122 | - trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']); |
|
126 | + if (!empty($modSettings['trackStats'])) { |
|
127 | + trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']); |
|
128 | + } |
|
123 | 129 | |
124 | 130 | // Are we showing all membergroups on the board index? |
125 | - if (!empty($settings['show_group_key'])) |
|
126 | - $context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array()); |
|
131 | + if (!empty($settings['show_group_key'])) { |
|
132 | + $context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array()); |
|
133 | + } |
|
127 | 134 | |
128 | 135 | // And back to normality. |
129 | 136 | $context['page_title'] = sprintf($txt['forum_index'], $context['forum_name']); |