@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
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 | * Activate an account. |
@@ -48,8 +49,9 @@ discard block |
||
48 | 49 | logAction('approve_member', array('member' => $memID), 'admin'); |
49 | 50 | |
50 | 51 | // If we are doing approval, update the stats for the member just in case. |
51 | - if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) |
|
52 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
52 | + if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) { |
|
53 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
54 | + } |
|
53 | 55 | |
54 | 56 | // Make sure we update the stats too. |
55 | 57 | updateStats('member', false); |
@@ -76,8 +78,9 @@ discard block |
||
76 | 78 | $issueErrors = array(); |
77 | 79 | |
78 | 80 | // Doesn't hurt to be overly cautious. |
79 | - if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) |
|
80 | - fatal_lang_error('no_access', false); |
|
81 | + if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) { |
|
82 | + fatal_lang_error('no_access', false); |
|
83 | + } |
|
81 | 84 | |
82 | 85 | // Get the base (errors related) stuff done. |
83 | 86 | loadLanguage('Errors'); |
@@ -135,16 +138,18 @@ discard block |
||
135 | 138 | |
136 | 139 | // This cannot be empty! |
137 | 140 | $_POST['warn_reason'] = isset($_POST['warn_reason']) ? trim($_POST['warn_reason']) : ''; |
138 | - if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) |
|
139 | - $issueErrors[] = 'warning_no_reason'; |
|
141 | + if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) { |
|
142 | + $issueErrors[] = 'warning_no_reason'; |
|
143 | + } |
|
140 | 144 | $_POST['warn_reason'] = $smcFunc['htmlspecialchars']($_POST['warn_reason']); |
141 | 145 | |
142 | 146 | $_POST['warning_level'] = (int) $_POST['warning_level']; |
143 | 147 | $_POST['warning_level'] = max(0, min(100, $_POST['warning_level'])); |
144 | - if ($_POST['warning_level'] < $context['min_allowed']) |
|
145 | - $_POST['warning_level'] = $context['min_allowed']; |
|
146 | - elseif ($_POST['warning_level'] > $context['max_allowed']) |
|
147 | - $_POST['warning_level'] = $context['max_allowed']; |
|
148 | + if ($_POST['warning_level'] < $context['min_allowed']) { |
|
149 | + $_POST['warning_level'] = $context['min_allowed']; |
|
150 | + } elseif ($_POST['warning_level'] > $context['max_allowed']) { |
|
151 | + $_POST['warning_level'] = $context['max_allowed']; |
|
152 | + } |
|
148 | 153 | |
149 | 154 | // Do we actually have to issue them with a PM? |
150 | 155 | $id_notice = 0; |
@@ -152,8 +157,9 @@ discard block |
||
152 | 157 | { |
153 | 158 | $_POST['warn_sub'] = trim($_POST['warn_sub']); |
154 | 159 | $_POST['warn_body'] = trim($_POST['warn_body']); |
155 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
156 | - $issueErrors[] = 'warning_notify_blank'; |
|
160 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
161 | + $issueErrors[] = 'warning_notify_blank'; |
|
162 | + } |
|
157 | 163 | // Send the PM? |
158 | 164 | else |
159 | 165 | { |
@@ -190,8 +196,8 @@ discard block |
||
190 | 196 | if (empty($issueErrors)) |
191 | 197 | { |
192 | 198 | // Log what we've done! |
193 | - if (!$context['user']['is_owner']) |
|
194 | - $smcFunc['db_insert']('', |
|
199 | + if (!$context['user']['is_owner']) { |
|
200 | + $smcFunc['db_insert']('', |
|
195 | 201 | '{db_prefix}log_comments', |
196 | 202 | array( |
197 | 203 | 'id_member' => 'int', 'member_name' => 'string', 'comment_type' => 'string', 'id_recipient' => 'int', 'recipient_name' => 'string-255', |
@@ -203,14 +209,14 @@ discard block |
||
203 | 209 | ), |
204 | 210 | array('id_comment') |
205 | 211 | ); |
212 | + } |
|
206 | 213 | |
207 | 214 | // Make the change. |
208 | 215 | updateMemberData($memID, array('warning' => $_POST['warning_level'])); |
209 | 216 | |
210 | 217 | // Leave a lovely message. |
211 | 218 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : $txt['profile_warning_success']; |
212 | - } |
|
213 | - else |
|
219 | + } else |
|
214 | 220 | { |
215 | 221 | // Try to remember some bits. |
216 | 222 | $context['warning_data'] = array( |
@@ -229,8 +235,9 @@ discard block |
||
229 | 235 | { |
230 | 236 | $warning_body = !empty($_POST['warn_body']) ? trim(censorText($_POST['warn_body'])) : ''; |
231 | 237 | $context['preview_subject'] = !empty($_POST['warn_sub']) ? trim($smcFunc['htmlspecialchars']($_POST['warn_sub'])) : ''; |
232 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
233 | - $issueErrors[] = 'warning_notify_blank'; |
|
238 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
239 | + $issueErrors[] = 'warning_notify_blank'; |
|
240 | + } |
|
234 | 241 | |
235 | 242 | if (!empty($_POST['warn_body'])) |
236 | 243 | { |
@@ -254,8 +261,9 @@ discard block |
||
254 | 261 | { |
255 | 262 | // Fill in the suite of errors. |
256 | 263 | $context['post_errors'] = array(); |
257 | - foreach ($issueErrors as $error) |
|
258 | - $context['post_errors'][] = $txt[$error]; |
|
264 | + foreach ($issueErrors as $error) { |
|
265 | + $context['post_errors'][] = $txt[$error]; |
|
266 | + } |
|
259 | 267 | } |
260 | 268 | |
261 | 269 | |
@@ -272,9 +280,10 @@ discard block |
||
272 | 280 | $modSettings['warning_mute'] => $txt['profile_warning_effect_mute'], |
273 | 281 | ); |
274 | 282 | $context['current_level'] = 0; |
275 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
276 | - if ($context['member']['warning'] >= $limit) |
|
283 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
284 | + if ($context['member']['warning'] >= $limit) |
|
277 | 285 | $context['current_level'] = $limit; |
286 | + } |
|
278 | 287 | |
279 | 288 | $listOptions = array( |
280 | 289 | 'id' => 'view_warnings', |
@@ -337,11 +346,12 @@ discard block |
||
337 | 346 | ' . $warning['reason'] . ' |
338 | 347 | </div>'; |
339 | 348 | |
340 | - if (!empty($warning['id_notice'])) |
|
341 | - $ret .= ' |
|
349 | + if (!empty($warning['id_notice'])) { |
|
350 | + $ret .= ' |
|
342 | 351 | <div class="floatright"> |
343 | 352 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $warning['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" rel="noopener" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a> |
344 | 353 | </div>'; |
354 | + } |
|
345 | 355 | |
346 | 356 | return $ret; |
347 | 357 | }, |
@@ -413,8 +423,9 @@ discard block |
||
413 | 423 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
414 | 424 | { |
415 | 425 | // If we're not warning for a message skip any that are. |
416 | - if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) |
|
417 | - continue; |
|
426 | + if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) { |
|
427 | + continue; |
|
428 | + } |
|
418 | 429 | |
419 | 430 | $context['notification_templates'][] = array( |
420 | 431 | 'title' => $row['template_title'], |
@@ -424,16 +435,18 @@ discard block |
||
424 | 435 | $smcFunc['db_free_result']($request); |
425 | 436 | |
426 | 437 | // Setup the "default" templates. |
427 | - foreach (array('spamming', 'offence', 'insulting') as $type) |
|
428 | - $context['notification_templates'][] = array( |
|
438 | + foreach (array('spamming', 'offence', 'insulting') as $type) { |
|
439 | + $context['notification_templates'][] = array( |
|
429 | 440 | 'title' => $txt['profile_warning_notify_title_' . $type], |
430 | 441 | 'body' => sprintf($txt['profile_warning_notify_template_outline' . (!empty($context['warning_for_message']) ? '_post' : '')], $txt['profile_warning_notify_for_' . $type]), |
431 | 442 | ); |
443 | + } |
|
432 | 444 | |
433 | 445 | // Replace all the common variables in the templates. |
434 | - foreach ($context['notification_templates'] as $k => $name) |
|
435 | - $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
436 | -} |
|
446 | + foreach ($context['notification_templates'] as $k => $name) { |
|
447 | + $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
448 | + } |
|
449 | + } |
|
437 | 450 | |
438 | 451 | /** |
439 | 452 | * Get the number of warnings a user has. Callback for $listOptions['get_count'] in issueWarning() |
@@ -517,10 +530,11 @@ discard block |
||
517 | 530 | { |
518 | 531 | global $txt, $context, $modSettings, $cur_profile; |
519 | 532 | |
520 | - if (!$context['user']['is_owner']) |
|
521 | - isAllowedTo('profile_remove_any'); |
|
522 | - elseif (!allowedTo('profile_remove_any')) |
|
523 | - isAllowedTo('profile_remove_own'); |
|
533 | + if (!$context['user']['is_owner']) { |
|
534 | + isAllowedTo('profile_remove_any'); |
|
535 | + } elseif (!allowedTo('profile_remove_any')) { |
|
536 | + isAllowedTo('profile_remove_own'); |
|
537 | + } |
|
524 | 538 | |
525 | 539 | // Permissions for removing stuff... |
526 | 540 | $context['can_delete_posts'] = !$context['user']['is_owner'] && allowedTo('moderate_forum'); |
@@ -547,10 +561,11 @@ discard block |
||
547 | 561 | |
548 | 562 | // @todo Add a way to delete pms as well? |
549 | 563 | |
550 | - if (!$context['user']['is_owner']) |
|
551 | - isAllowedTo('profile_remove_any'); |
|
552 | - elseif (!allowedTo('profile_remove_any')) |
|
553 | - isAllowedTo('profile_remove_own'); |
|
564 | + if (!$context['user']['is_owner']) { |
|
565 | + isAllowedTo('profile_remove_any'); |
|
566 | + } elseif (!allowedTo('profile_remove_any')) { |
|
567 | + isAllowedTo('profile_remove_own'); |
|
568 | + } |
|
554 | 569 | |
555 | 570 | checkSession(); |
556 | 571 | |
@@ -576,8 +591,9 @@ discard block |
||
576 | 591 | list ($another) = $smcFunc['db_fetch_row']($request); |
577 | 592 | $smcFunc['db_free_result']($request); |
578 | 593 | |
579 | - if (empty($another)) |
|
580 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
594 | + if (empty($another)) { |
|
595 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
596 | + } |
|
581 | 597 | } |
582 | 598 | |
583 | 599 | // This file is needed for the deleteMembers function. |
@@ -656,8 +672,9 @@ discard block |
||
656 | 672 | ) |
657 | 673 | ); |
658 | 674 | $topicIDs = array(); |
659 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
660 | - $topicIDs[] = $row['id_topic']; |
|
675 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
676 | + $topicIDs[] = $row['id_topic']; |
|
677 | + } |
|
661 | 678 | $smcFunc['db_free_result']($request); |
662 | 679 | |
663 | 680 | // Actually remove the topics. Ignore recycling if we want to perma-delete things... |
@@ -680,8 +697,9 @@ discard block |
||
680 | 697 | // This could take a while... but ya know it's gonna be worth it in the end. |
681 | 698 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
682 | 699 | { |
683 | - if (function_exists('apache_reset_timeout')) |
|
684 | - @apache_reset_timeout(); |
|
700 | + if (function_exists('apache_reset_timeout')) { |
|
701 | + @apache_reset_timeout(); |
|
702 | + } |
|
685 | 703 | |
686 | 704 | removeMessage($row['id_msg']); |
687 | 705 | } |
@@ -689,8 +707,9 @@ discard block |
||
689 | 707 | } |
690 | 708 | |
691 | 709 | // Only delete this poor members account if they are actually being booted out of camp. |
692 | - if (isset($_POST['deleteAccount'])) |
|
693 | - deleteMembers($memID); |
|
710 | + if (isset($_POST['deleteAccount'])) { |
|
711 | + deleteMembers($memID); |
|
712 | + } |
|
694 | 713 | } |
695 | 714 | // Do they need approval to delete? |
696 | 715 | elseif (!empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum')) |
@@ -741,18 +760,18 @@ discard block |
||
741 | 760 | { |
742 | 761 | foreach ($costs as $duration => $cost) |
743 | 762 | { |
744 | - if ($cost != 0) |
|
745 | - $cost_array[$duration] = $cost; |
|
763 | + if ($cost != 0) { |
|
764 | + $cost_array[$duration] = $cost; |
|
765 | + } |
|
746 | 766 | } |
747 | - } |
|
748 | - else |
|
767 | + } else |
|
749 | 768 | { |
750 | 769 | $cost_array['fixed'] = $costs['fixed']; |
751 | 770 | } |
752 | 771 | |
753 | - if (empty($cost_array)) |
|
754 | - unset($context['subscriptions'][$id]); |
|
755 | - else |
|
772 | + if (empty($cost_array)) { |
|
773 | + unset($context['subscriptions'][$id]); |
|
774 | + } else |
|
756 | 775 | { |
757 | 776 | $context['subscriptions'][$id]['member'] = 0; |
758 | 777 | $context['subscriptions'][$id]['subscribed'] = false; |
@@ -765,13 +784,15 @@ discard block |
||
765 | 784 | foreach ($gateways as $id => $gateway) |
766 | 785 | { |
767 | 786 | $gateways[$id] = new $gateway['display_class'](); |
768 | - if (!$gateways[$id]->gatewayEnabled()) |
|
769 | - unset($gateways[$id]); |
|
787 | + if (!$gateways[$id]->gatewayEnabled()) { |
|
788 | + unset($gateways[$id]); |
|
789 | + } |
|
770 | 790 | } |
771 | 791 | |
772 | 792 | // No gateways yet? |
773 | - if (empty($gateways)) |
|
774 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
793 | + if (empty($gateways)) { |
|
794 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
795 | + } |
|
775 | 796 | |
776 | 797 | // Get the current subscriptions. |
777 | 798 | $request = $smcFunc['db_query']('', ' |
@@ -786,8 +807,9 @@ discard block |
||
786 | 807 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
787 | 808 | { |
788 | 809 | // The subscription must exist! |
789 | - if (!isset($context['subscriptions'][$row['id_subscribe']])) |
|
790 | - continue; |
|
810 | + if (!isset($context['subscriptions'][$row['id_subscribe']])) { |
|
811 | + continue; |
|
812 | + } |
|
791 | 813 | |
792 | 814 | $context['current'][$row['id_subscribe']] = array( |
793 | 815 | 'id' => $row['id_sublog'], |
@@ -801,8 +823,9 @@ discard block |
||
801 | 823 | 'status_text' => $row['status'] == 0 ? ($row['payments_pending'] ? $txt['paid_pending'] : $txt['paid_finished']) : $txt['paid_active'], |
802 | 824 | ); |
803 | 825 | |
804 | - if ($row['status'] == 1) |
|
805 | - $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
826 | + if ($row['status'] == 1) { |
|
827 | + $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
828 | + } |
|
806 | 829 | } |
807 | 830 | $smcFunc['db_free_result']($request); |
808 | 831 | |
@@ -853,21 +876,25 @@ discard block |
||
853 | 876 | if (isset($_GET['confirm']) && isset($_POST['sub_id']) && is_array($_POST['sub_id'])) |
854 | 877 | { |
855 | 878 | // Hopefully just one. |
856 | - foreach ($_POST['sub_id'] as $k => $v) |
|
857 | - $ID_SUB = (int) $k; |
|
879 | + foreach ($_POST['sub_id'] as $k => $v) { |
|
880 | + $ID_SUB = (int) $k; |
|
881 | + } |
|
858 | 882 | |
859 | - if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) |
|
860 | - fatal_lang_error('paid_sub_not_active'); |
|
883 | + if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) { |
|
884 | + fatal_lang_error('paid_sub_not_active'); |
|
885 | + } |
|
861 | 886 | |
862 | 887 | // Simplify... |
863 | 888 | $context['sub'] = $context['subscriptions'][$ID_SUB]; |
864 | 889 | $period = 'xx'; |
865 | - if ($context['sub']['flexible']) |
|
866 | - $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
890 | + if ($context['sub']['flexible']) { |
|
891 | + $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
892 | + } |
|
867 | 893 | |
868 | 894 | // Check we have a valid cost. |
869 | - if ($context['sub']['flexible'] && $period == 'xx') |
|
870 | - fatal_lang_error('paid_sub_not_active'); |
|
895 | + if ($context['sub']['flexible'] && $period == 'xx') { |
|
896 | + fatal_lang_error('paid_sub_not_active'); |
|
897 | + } |
|
871 | 898 | |
872 | 899 | // Sort out the cost/currency. |
873 | 900 | $context['currency'] = $modSettings['paid_currency_code']; |
@@ -880,8 +907,7 @@ discard block |
||
880 | 907 | $context['cost'] = sprintf($modSettings['paid_currency_symbol'], $context['value']) . '/' . $txt[$_POST['cur'][$ID_SUB]]; |
881 | 908 | // The period value for paypal. |
882 | 909 | $context['paypal_period'] = strtoupper(substr($_POST['cur'][$ID_SUB], 0, 1)); |
883 | - } |
|
884 | - else |
|
910 | + } else |
|
885 | 911 | { |
886 | 912 | // Real cost... |
887 | 913 | $context['value'] = $context['sub']['costs']['fixed']; |
@@ -898,13 +924,15 @@ discard block |
||
898 | 924 | foreach ($gateways as $id => $gateway) |
899 | 925 | { |
900 | 926 | $fields = $gateways[$id]->fetchGatewayFields($context['sub']['id'] . '+' . $memID, $context['sub'], $context['value'], $period, $scripturl . '?action=profile;u=' . $memID . ';area=subscriptions;sub_id=' . $context['sub']['id'] . ';done'); |
901 | - if (!empty($fields['form'])) |
|
902 | - $context['gateways'][] = $fields; |
|
927 | + if (!empty($fields['form'])) { |
|
928 | + $context['gateways'][] = $fields; |
|
929 | + } |
|
903 | 930 | } |
904 | 931 | |
905 | 932 | // Bugger?! |
906 | - if (empty($context['gateways'])) |
|
907 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
933 | + if (empty($context['gateways'])) { |
|
934 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
935 | + } |
|
908 | 936 | |
909 | 937 | // Now we are going to assume they want to take this out ;) |
910 | 938 | $new_data = array($context['sub']['id'], $context['value'], $period, 'prepay'); |
@@ -912,16 +940,19 @@ discard block |
||
912 | 940 | { |
913 | 941 | // What are the details like? |
914 | 942 | $current_pending = array(); |
915 | - if ($context['current'][$context['sub']['id']]['pending_details'] != '') |
|
916 | - $current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true); |
|
943 | + if ($context['current'][$context['sub']['id']]['pending_details'] != '') { |
|
944 | + $current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true); |
|
945 | + } |
|
917 | 946 | // Don't get silly. |
918 | - if (count($current_pending) > 9) |
|
919 | - $current_pending = array(); |
|
947 | + if (count($current_pending) > 9) { |
|
948 | + $current_pending = array(); |
|
949 | + } |
|
920 | 950 | $pending_count = 0; |
921 | 951 | // Only record real pending payments as will otherwise confuse the admin! |
922 | - foreach ($current_pending as $pending) |
|
923 | - if ($pending[3] == 'payback') |
|
952 | + foreach ($current_pending as $pending) { |
|
953 | + if ($pending[3] == 'payback') |
|
924 | 954 | $pending_count++; |
955 | + } |
|
925 | 956 | |
926 | 957 | if (!in_array($new_data, $current_pending)) |
927 | 958 | { |
@@ -966,9 +997,9 @@ discard block |
||
966 | 997 | |
967 | 998 | // Quit. |
968 | 999 | return; |
1000 | + } else { |
|
1001 | + $context['sub_template'] = 'user_subscription'; |
|
1002 | + } |
|
969 | 1003 | } |
970 | - else |
|
971 | - $context['sub_template'] = 'user_subscription'; |
|
972 | -} |
|
973 | 1004 | |
974 | 1005 | ?> |
975 | 1006 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
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 | * Entry point for the moderation center. |
@@ -26,8 +27,9 @@ discard block |
||
26 | 27 | global $smcFunc, $txt, $context, $scripturl, $modSettings, $user_info, $sourcedir, $options; |
27 | 28 | |
28 | 29 | // Don't run this twice... and don't conflict with the admin bar. |
29 | - if (isset($context['admin_area'])) |
|
30 | - return; |
|
30 | + if (isset($context['admin_area'])) { |
|
31 | + return; |
|
32 | + } |
|
31 | 33 | |
32 | 34 | $context['can_moderate_boards'] = $user_info['mod_cache']['bq'] != '0=1'; |
33 | 35 | $context['can_moderate_groups'] = $user_info['mod_cache']['gq'] != '0=1'; |
@@ -35,8 +37,9 @@ discard block |
||
35 | 37 | $context['can_moderate_users'] = allowedTo('moderate_forum'); |
36 | 38 | |
37 | 39 | // Everyone using this area must be allowed here! |
38 | - if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) |
|
39 | - isAllowedTo('access_mod_center'); |
|
40 | + if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) { |
|
41 | + isAllowedTo('access_mod_center'); |
|
42 | + } |
|
40 | 43 | |
41 | 44 | // We're gonna want a menu of some kind. |
42 | 45 | require_once($sourcedir . '/Subs-Menu.php'); |
@@ -195,8 +198,9 @@ discard block |
||
195 | 198 | unset($moderation_areas); |
196 | 199 | |
197 | 200 | // We got something - didn't we? DIDN'T WE! |
198 | - if ($mod_include_data == false) |
|
199 | - fatal_lang_error('no_access', false); |
|
201 | + if ($mod_include_data == false) { |
|
202 | + fatal_lang_error('no_access', false); |
|
203 | + } |
|
200 | 204 | |
201 | 205 | // Retain the ID information in case required by a subaction. |
202 | 206 | $context['moderation_menu_id'] = $context['max_menu_id']; |
@@ -219,22 +223,25 @@ discard block |
||
219 | 223 | 'url' => $scripturl . '?action=moderate', |
220 | 224 | 'name' => $txt['moderation_center'], |
221 | 225 | ); |
222 | - if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') |
|
223 | - $context['linktree'][] = array( |
|
226 | + if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') { |
|
227 | + $context['linktree'][] = array( |
|
224 | 228 | 'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'], |
225 | 229 | 'name' => $mod_include_data['label'], |
226 | 230 | ); |
227 | - if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) |
|
228 | - $context['linktree'][] = array( |
|
231 | + } |
|
232 | + if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) { |
|
233 | + $context['linktree'][] = array( |
|
229 | 234 | 'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'] . ';sa=' . $mod_include_data['current_subsection'], |
230 | 235 | 'name' => $mod_include_data['subsections'][$mod_include_data['current_subsection']][0], |
231 | 236 | ); |
237 | + } |
|
232 | 238 | |
233 | 239 | // Now - finally - the bit before the encore - the main performance of course! |
234 | 240 | if (!$dont_call) |
235 | 241 | { |
236 | - if (isset($mod_include_data['file'])) |
|
237 | - require_once($sourcedir . '/' . $mod_include_data['file']); |
|
242 | + if (isset($mod_include_data['file'])) { |
|
243 | + require_once($sourcedir . '/' . $mod_include_data['file']); |
|
244 | + } |
|
238 | 245 | |
239 | 246 | call_helper($mod_include_data['function']); |
240 | 247 | } |
@@ -259,8 +266,9 @@ discard block |
||
259 | 266 | // Load what blocks the user actually can see... |
260 | 267 | $valid_blocks = array(); |
261 | 268 | |
262 | - if ($context['can_moderate_groups']) |
|
263 | - $valid_blocks['g'] = 'GroupRequests'; |
|
269 | + if ($context['can_moderate_groups']) { |
|
270 | + $valid_blocks['g'] = 'GroupRequests'; |
|
271 | + } |
|
264 | 272 | if ($context['can_moderate_boards']) |
265 | 273 | { |
266 | 274 | $valid_blocks['r'] = 'ReportedPosts'; |
@@ -269,8 +277,9 @@ discard block |
||
269 | 277 | if ($context['can_moderate_users']) |
270 | 278 | { |
271 | 279 | // This falls under the category of moderating users as well... |
272 | - if (!$context['can_moderate_boards']) |
|
273 | - $valid_blocks['w'] = 'WatchedUsers'; |
|
280 | + if (!$context['can_moderate_boards']) { |
|
281 | + $valid_blocks['w'] = 'WatchedUsers'; |
|
282 | + } |
|
274 | 283 | |
275 | 284 | $valid_blocks['rm'] = 'ReportedMembers'; |
276 | 285 | } |
@@ -281,8 +290,9 @@ discard block |
||
281 | 290 | foreach ($valid_blocks as $k => $block) |
282 | 291 | { |
283 | 292 | $block = 'ModBlock' . $block; |
284 | - if (function_exists($block)) |
|
285 | - $context['mod_blocks'][] = $block(); |
|
293 | + if (function_exists($block)) { |
|
294 | + $context['mod_blocks'][] = $block(); |
|
295 | + } |
|
286 | 296 | } |
287 | 297 | |
288 | 298 | $context['admin_prefs'] = !empty($options['admin_preferences']) ? $smcFunc['json_decode']($options['admin_preferences'], true) : array(); |
@@ -309,8 +319,9 @@ discard block |
||
309 | 319 | ) |
310 | 320 | ); |
311 | 321 | $watched_users = array(); |
312 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
313 | - $watched_users[] = $row; |
|
322 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
323 | + $watched_users[] = $row; |
|
324 | + } |
|
314 | 325 | $smcFunc['db_free_result']($request); |
315 | 326 | |
316 | 327 | cache_put_data('recent_user_watches', $watched_users, 240); |
@@ -402,8 +413,9 @@ discard block |
||
402 | 413 | $note_owner = $smcFunc['db_num_rows']($get_owner); |
403 | 414 | $smcFunc['db_free_result']($get_owner); |
404 | 415 | |
405 | - if (empty($note_owner)) |
|
406 | - fatal_lang_error('mc_notes_delete_own', false); |
|
416 | + if (empty($note_owner)) { |
|
417 | + fatal_lang_error('mc_notes_delete_own', false); |
|
418 | + } |
|
407 | 419 | } |
408 | 420 | |
409 | 421 | // Lets delete it. |
@@ -460,12 +472,14 @@ discard block |
||
460 | 472 | ) |
461 | 473 | ); |
462 | 474 | $moderator_notes = array(); |
463 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
464 | - $moderator_notes[] = $row; |
|
475 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
476 | + $moderator_notes[] = $row; |
|
477 | + } |
|
465 | 478 | $smcFunc['db_free_result']($request); |
466 | 479 | |
467 | - if ($offset == 0) |
|
468 | - cache_put_data('moderator_notes', $moderator_notes, 240); |
|
480 | + if ($offset == 0) { |
|
481 | + cache_put_data('moderator_notes', $moderator_notes, 240); |
|
482 | + } |
|
469 | 483 | } |
470 | 484 | |
471 | 485 | // Lets construct a page index. |
@@ -504,8 +518,9 @@ discard block |
||
504 | 518 | // Got the info already? |
505 | 519 | $cachekey = md5($smcFunc['json_encode']($user_info['mod_cache']['bq'])); |
506 | 520 | $context['reported_posts'] = array(); |
507 | - if ($user_info['mod_cache']['bq'] == '0=1') |
|
508 | - return 'reported_posts_block'; |
|
521 | + if ($user_info['mod_cache']['bq'] == '0=1') { |
|
522 | + return 'reported_posts_block'; |
|
523 | + } |
|
509 | 524 | |
510 | 525 | if (($reported_posts = cache_get_data('reported_posts_' . $cachekey, 90)) === null) |
511 | 526 | { |
@@ -529,8 +544,9 @@ discard block |
||
529 | 544 | ) |
530 | 545 | ); |
531 | 546 | $reported_posts = array(); |
532 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
533 | - $reported_posts[] = $row; |
|
547 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
548 | + $reported_posts[] = $row; |
|
549 | + } |
|
534 | 550 | $smcFunc['db_free_result']($request); |
535 | 551 | |
536 | 552 | // Cache it. |
@@ -568,8 +584,9 @@ discard block |
||
568 | 584 | |
569 | 585 | $context['group_requests'] = array(); |
570 | 586 | // Make sure they can even moderate someone! |
571 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
572 | - return 'group_requests_block'; |
|
587 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
588 | + return 'group_requests_block'; |
|
589 | + } |
|
573 | 590 | |
574 | 591 | // What requests are outstanding? |
575 | 592 | $request = $smcFunc['db_query']('', ' |
@@ -618,8 +635,9 @@ discard block |
||
618 | 635 | // Got the info already? |
619 | 636 | $cachekey = md5($smcFunc['json_encode']((int) allowedTo('moderate_forum'))); |
620 | 637 | $context['reported_users'] = array(); |
621 | - if (!allowedTo('moderate_forum')) |
|
622 | - return 'reported_users_block'; |
|
638 | + if (!allowedTo('moderate_forum')) { |
|
639 | + return 'reported_users_block'; |
|
640 | + } |
|
623 | 641 | |
624 | 642 | if (($reported_users = cache_get_data('reported_users_' . $cachekey, 90)) === null) |
625 | 643 | { |
@@ -642,8 +660,9 @@ discard block |
||
642 | 660 | ) |
643 | 661 | ); |
644 | 662 | $reported_users = array(); |
645 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
646 | - $reported_users[] = $row; |
|
663 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
664 | + $reported_users[] = $row; |
|
665 | + } |
|
647 | 666 | $smcFunc['db_free_result']($request); |
648 | 667 | |
649 | 668 | // Cache it. |
@@ -742,15 +761,15 @@ discard block |
||
742 | 761 | // Time to update. |
743 | 762 | updateSettings(array('last_mod_report_action' => time())); |
744 | 763 | recountOpenReports('members'); |
745 | - } |
|
746 | - elseif (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
764 | + } elseif (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
747 | 765 | { |
748 | 766 | checkSession(); |
749 | 767 | |
750 | 768 | // All the ones to update... |
751 | 769 | $toClose = array(); |
752 | - foreach ($_POST['close'] as $rid) |
|
753 | - $toClose[] = (int) $rid; |
|
770 | + foreach ($_POST['close'] as $rid) { |
|
771 | + $toClose[] = (int) $rid; |
|
772 | + } |
|
754 | 773 | |
755 | 774 | if (!empty($toClose)) |
756 | 775 | { |
@@ -903,8 +922,9 @@ discard block |
||
903 | 922 | global $context, $user_info; |
904 | 923 | |
905 | 924 | // You need to be allowed to moderate groups... |
906 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
907 | - isAllowedTo('manage_membergroups'); |
|
925 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
926 | + isAllowedTo('manage_membergroups'); |
|
927 | + } |
|
908 | 928 | |
909 | 929 | // Load the group templates. |
910 | 930 | loadTemplate('ModerationCenter'); |
@@ -915,8 +935,9 @@ discard block |
||
915 | 935 | 'view' => 'ViewGroups', |
916 | 936 | ); |
917 | 937 | |
918 | - if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) |
|
919 | - $_GET['sa'] = 'view'; |
|
938 | + if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) { |
|
939 | + $_GET['sa'] = 'view'; |
|
940 | + } |
|
920 | 941 | $context['sub_action'] = $_GET['sa']; |
921 | 942 | |
922 | 943 | // Call the relevant function. |
@@ -946,8 +967,9 @@ discard block |
||
946 | 967 | 'id_notice' => $id_notice, |
947 | 968 | ) |
948 | 969 | ); |
949 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
950 | - fatal_lang_error('no_access', false); |
|
970 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
971 | + fatal_lang_error('no_access', false); |
|
972 | + } |
|
951 | 973 | list ($context['notice_body'], $context['notice_subject']) = $smcFunc['db_fetch_row']($request); |
952 | 974 | $smcFunc['db_free_result']($request); |
953 | 975 | |
@@ -984,18 +1006,20 @@ discard block |
||
984 | 1006 | checkSession(!is_array($_REQUEST['delete']) ? 'get' : 'post'); |
985 | 1007 | |
986 | 1008 | $toDelete = array(); |
987 | - if (!is_array($_REQUEST['delete'])) |
|
988 | - $toDelete[] = (int) $_REQUEST['delete']; |
|
989 | - else |
|
990 | - foreach ($_REQUEST['delete'] as $did) |
|
1009 | + if (!is_array($_REQUEST['delete'])) { |
|
1010 | + $toDelete[] = (int) $_REQUEST['delete']; |
|
1011 | + } else { |
|
1012 | + foreach ($_REQUEST['delete'] as $did) |
|
991 | 1013 | $toDelete[] = (int) $did; |
1014 | + } |
|
992 | 1015 | |
993 | 1016 | if (!empty($toDelete)) |
994 | 1017 | { |
995 | 1018 | require_once($sourcedir . '/RemoveTopic.php'); |
996 | 1019 | // If they don't have permission we'll let it error - either way no chance of a security slip here! |
997 | - foreach ($toDelete as $did) |
|
998 | - removeMessage($did); |
|
1020 | + foreach ($toDelete as $did) { |
|
1021 | + removeMessage($did); |
|
1022 | + } |
|
999 | 1023 | } |
1000 | 1024 | } |
1001 | 1025 | |
@@ -1004,20 +1028,21 @@ discard block |
||
1004 | 1028 | { |
1005 | 1029 | $approve_query = ''; |
1006 | 1030 | $delete_boards = array(); |
1007 | - } |
|
1008 | - else |
|
1031 | + } else |
|
1009 | 1032 | { |
1010 | 1033 | // Still obey permissions! |
1011 | 1034 | $approve_boards = boardsAllowedTo('approve_posts'); |
1012 | 1035 | $delete_boards = boardsAllowedTo('delete_any'); |
1013 | 1036 | |
1014 | - if ($approve_boards == array(0)) |
|
1015 | - $approve_query = ''; |
|
1016 | - elseif (!empty($approve_boards)) |
|
1017 | - $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
1037 | + if ($approve_boards == array(0)) { |
|
1038 | + $approve_query = ''; |
|
1039 | + } elseif (!empty($approve_boards)) { |
|
1040 | + $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
1041 | + } |
|
1018 | 1042 | // Nada, zip, etc... |
1019 | - else |
|
1020 | - $approve_query = ' AND 1=0'; |
|
1043 | + else { |
|
1044 | + $approve_query = ' AND 1=0'; |
|
1045 | + } |
|
1021 | 1046 | } |
1022 | 1047 | |
1023 | 1048 | require_once($sourcedir . '/Subs-List.php'); |
@@ -1116,10 +1141,11 @@ discard block |
||
1116 | 1141 | 'data' => array( |
1117 | 1142 | 'function' => function($member) use ($scripturl) |
1118 | 1143 | { |
1119 | - if ($member['last_post_id']) |
|
1120 | - return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
|
1121 | - else |
|
1122 | - return $member['last_post']; |
|
1144 | + if ($member['last_post_id']) { |
|
1145 | + return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
|
1146 | + } else { |
|
1147 | + return $member['last_post']; |
|
1148 | + } |
|
1123 | 1149 | }, |
1124 | 1150 | ), |
1125 | 1151 | ), |
@@ -1247,8 +1273,9 @@ discard block |
||
1247 | 1273 | ) |
1248 | 1274 | ); |
1249 | 1275 | $latest_posts = array(); |
1250 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1251 | - $latest_posts[$row['id_member']] = $row['last_post_id']; |
|
1276 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1277 | + $latest_posts[$row['id_member']] = $row['last_post_id']; |
|
1278 | + } |
|
1252 | 1279 | |
1253 | 1280 | if (!empty($latest_posts)) |
1254 | 1281 | { |
@@ -1439,15 +1466,17 @@ discard block |
||
1439 | 1466 | // Setup the direction stuff... |
1440 | 1467 | $context['order'] = isset($_REQUEST['sort']) && isset($sort_types[$_REQUEST['sort']]) ? $_REQUEST['sort'] : 'member'; |
1441 | 1468 | |
1442 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
1443 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
1444 | - else |
|
1445 | - $search_params_string = $search_params['string']; |
|
1469 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
1470 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
1471 | + } else { |
|
1472 | + $search_params_string = $search_params['string']; |
|
1473 | + } |
|
1446 | 1474 | |
1447 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
1448 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
1449 | - else |
|
1450 | - $search_params_type = $search_params['type']; |
|
1475 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
1476 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
1477 | + } else { |
|
1478 | + $search_params_type = $search_params['type']; |
|
1479 | + } |
|
1451 | 1480 | |
1452 | 1481 | $search_params = array( |
1453 | 1482 | 'string' => $search_params_string, |
@@ -1530,9 +1559,10 @@ discard block |
||
1530 | 1559 | ' . $rowData['reason'] . ' |
1531 | 1560 | </div>'; |
1532 | 1561 | |
1533 | - if (!empty($rowData['id_notice'])) |
|
1534 | - $output .= ' |
|
1562 | + if (!empty($rowData['id_notice'])) { |
|
1563 | + $output .= ' |
|
1535 | 1564 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $rowData['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" rel="noopener" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a>'; |
1565 | + } |
|
1536 | 1566 | return $output; |
1537 | 1567 | }, |
1538 | 1568 | ), |
@@ -1650,9 +1680,9 @@ discard block |
||
1650 | 1680 | global $smcFunc, $modSettings, $context, $txt, $scripturl, $sourcedir, $user_info; |
1651 | 1681 | |
1652 | 1682 | // Submitting a new one? |
1653 | - if (isset($_POST['add'])) |
|
1654 | - return ModifyWarningTemplate(); |
|
1655 | - elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) |
|
1683 | + if (isset($_POST['add'])) { |
|
1684 | + return ModifyWarningTemplate(); |
|
1685 | + } elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) |
|
1656 | 1686 | { |
1657 | 1687 | checkSession(); |
1658 | 1688 | validateToken('mod-wt'); |
@@ -1671,8 +1701,9 @@ discard block |
||
1671 | 1701 | 'current_member' => $user_info['id'], |
1672 | 1702 | ) |
1673 | 1703 | ); |
1674 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1675 | - logAction('delete_warn_template', array('template' => $row['recipient_name'])); |
|
1704 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1705 | + logAction('delete_warn_template', array('template' => $row['recipient_name'])); |
|
1706 | + } |
|
1676 | 1707 | $smcFunc['db_free_result']($request); |
1677 | 1708 | |
1678 | 1709 | // Do the deletes. |
@@ -1963,16 +1994,18 @@ discard block |
||
1963 | 1994 | ); |
1964 | 1995 | |
1965 | 1996 | // If it wasn't visible and now is they've effectively added it. |
1966 | - if ($context['template_data']['personal'] && !$recipient_id) |
|
1967 | - logAction('add_warn_template', array('template' => $_POST['template_title'])); |
|
1997 | + if ($context['template_data']['personal'] && !$recipient_id) { |
|
1998 | + logAction('add_warn_template', array('template' => $_POST['template_title'])); |
|
1999 | + } |
|
1968 | 2000 | // Conversely if they made it personal it's a delete. |
1969 | - elseif (!$context['template_data']['personal'] && $recipient_id) |
|
1970 | - logAction('delete_warn_template', array('template' => $_POST['template_title'])); |
|
2001 | + elseif (!$context['template_data']['personal'] && $recipient_id) { |
|
2002 | + logAction('delete_warn_template', array('template' => $_POST['template_title'])); |
|
2003 | + } |
|
1971 | 2004 | // Otherwise just an edit. |
1972 | - else |
|
1973 | - logAction('modify_warn_template', array('template' => $_POST['template_title'])); |
|
1974 | - } |
|
1975 | - else |
|
2005 | + else { |
|
2006 | + logAction('modify_warn_template', array('template' => $_POST['template_title'])); |
|
2007 | + } |
|
2008 | + } else |
|
1976 | 2009 | { |
1977 | 2010 | $smcFunc['db_insert']('', |
1978 | 2011 | '{db_prefix}log_comments', |
@@ -1992,17 +2025,18 @@ discard block |
||
1992 | 2025 | |
1993 | 2026 | // Get out of town... |
1994 | 2027 | redirectexit('action=moderate;area=warnings;sa=templates'); |
1995 | - } |
|
1996 | - else |
|
2028 | + } else |
|
1997 | 2029 | { |
1998 | 2030 | $context['warning_errors'] = array(); |
1999 | 2031 | $context['template_data']['title'] = !empty($_POST['template_title']) ? $_POST['template_title'] : ''; |
2000 | 2032 | $context['template_data']['body'] = !empty($_POST['template_body']) ? $_POST['template_body'] : $txt['mc_warning_template_body_default']; |
2001 | 2033 | $context['template_data']['personal'] = !empty($_POST['make_personal']); |
2002 | - if (empty($_POST['template_title'])) |
|
2003 | - $context['warning_errors'][] = $txt['mc_warning_template_error_no_title']; |
|
2004 | - if (empty($_POST['template_body'])) |
|
2005 | - $context['warning_errors'][] = $txt['mc_warning_template_error_no_body']; |
|
2034 | + if (empty($_POST['template_title'])) { |
|
2035 | + $context['warning_errors'][] = $txt['mc_warning_template_error_no_title']; |
|
2036 | + } |
|
2037 | + if (empty($_POST['template_body'])) { |
|
2038 | + $context['warning_errors'][] = $txt['mc_warning_template_error_no_body']; |
|
2039 | + } |
|
2006 | 2040 | } |
2007 | 2041 | } |
2008 | 2042 | |
@@ -2047,8 +2081,9 @@ discard block |
||
2047 | 2081 | // Now check other options! |
2048 | 2082 | $pref_binary = 0; |
2049 | 2083 | |
2050 | - if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) |
|
2051 | - $pref_binary |= 4; |
|
2084 | + if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) { |
|
2085 | + $pref_binary |= 4; |
|
2086 | + } |
|
2052 | 2087 | |
2053 | 2088 | // Put it all together. |
2054 | 2089 | $mod_prefs = '0||' . $pref_binary; |
@@ -2072,9 +2107,10 @@ discard block |
||
2072 | 2107 | unset($_SESSION['moderate_time']); |
2073 | 2108 | |
2074 | 2109 | // Clean any moderator tokens as well. |
2075 | - foreach ($_SESSION['token'] as $key => $token) |
|
2076 | - if (strpos($key, '-mod') !== false) |
|
2110 | + foreach ($_SESSION['token'] as $key => $token) { |
|
2111 | + if (strpos($key, '-mod') !== false) |
|
2077 | 2112 | unset($_SESSION['token'][$key]); |
2113 | + } |
|
2078 | 2114 | |
2079 | 2115 | redirectexit(); |
2080 | 2116 | } |
@@ -86,11 +86,12 @@ discard block |
||
86 | 86 | <span class="smalltext"><em>', $txt['find_wildcards'], '</em></span><br>'; |
87 | 87 | |
88 | 88 | // Only offer to search for buddies if we have some! |
89 | - if (!empty($context['show_buddies'])) |
|
90 | - echo ' |
|
89 | + if (!empty($context['show_buddies'])) { |
|
90 | + echo ' |
|
91 | 91 | <span class="smalltext"> |
92 | 92 | <label for="buddies"><input type="checkbox" name="buddies" id="buddies"', !empty($context['buddy_search']) ? ' checked' : '', '> ', $txt['find_buddies'], '</label> |
93 | 93 | </span><br>'; |
94 | + } |
|
94 | 95 | |
95 | 96 | echo ' |
96 | 97 | <div class="padding righttext"> |
@@ -105,20 +106,21 @@ discard block |
||
105 | 106 | <h3 class="catbg">', $txt['find_results'], '</h3> |
106 | 107 | </div>'; |
107 | 108 | |
108 | - if (empty($context['results'])) |
|
109 | - echo ' |
|
109 | + if (empty($context['results'])) { |
|
110 | + echo ' |
|
110 | 111 | <p class="error">', $txt['find_no_results'], '</p>'; |
111 | - else |
|
112 | + } else |
|
112 | 113 | { |
113 | 114 | echo ' |
114 | 115 | <ul class="padding">'; |
115 | 116 | |
116 | - foreach ($context['results'] as $result) |
|
117 | - echo ' |
|
117 | + foreach ($context['results'] as $result) { |
|
118 | + echo ' |
|
118 | 119 | <li class="windowbg"> |
119 | 120 | <a href="', $result['href'], '" target="_blank" rel="noopener"> <span class="generic_icons profile_sm"></span> |
120 | 121 | <a href="javascript:void(0);" onclick="addMember(this.innerHTML); return false;">', $result['name'], '</a> |
121 | 122 | </li>'; |
123 | + } |
|
122 | 124 | |
123 | 125 | echo ' |
124 | 126 | </ul> |
@@ -134,11 +136,12 @@ discard block |
||
134 | 136 | <input type="hidden" name="quote" value="', $context['quote_results'] ? '1' : '0', '"> |
135 | 137 | </form>'; |
136 | 138 | |
137 | - if (empty($context['results'])) |
|
138 | - echo ' |
|
139 | + if (empty($context['results'])) { |
|
140 | + echo ' |
|
139 | 141 | <script> |
140 | 142 | document.getElementById("search").focus(); |
141 | 143 | </script>'; |
144 | + } |
|
142 | 145 | |
143 | 146 | echo ' |
144 | 147 | </body> |
@@ -162,9 +165,10 @@ discard block |
||
162 | 165 | <p>', $txt['manual_introduction'], '</p> |
163 | 166 | <ul>'; |
164 | 167 | |
165 | - foreach ($context['manual_sections'] as $section_id => $wiki_id) |
|
166 | - echo ' |
|
168 | + foreach ($context['manual_sections'] as $section_id => $wiki_id) { |
|
169 | + echo ' |
|
167 | 170 | <li><a href="', $context['wiki_url'], '/', $context['wiki_prefix'], $wiki_id, ($txt['lang_dictionary'] != 'en' ? '/' . $txt['lang_dictionary'] : ''), '" target="_blank" rel="noopener">', $txt['manual_section_' . $section_id . '_title'], '</a> - ', $txt['manual_section_' . $section_id . '_desc'], '</li>'; |
171 | + } |
|
168 | 172 | |
169 | 173 | echo ' |
170 | 174 | </ul> |
@@ -180,8 +184,8 @@ discard block |
||
180 | 184 | { |
181 | 185 | global $txt, $context, $modSettings; |
182 | 186 | |
183 | - if (!empty($modSettings['requireAgreement'])) |
|
184 | - echo ' |
|
187 | + if (!empty($modSettings['requireAgreement'])) { |
|
188 | + echo ' |
|
185 | 189 | <div class="cat_bar"> |
186 | 190 | <h3 class="catbg"> |
187 | 191 | ', $txt['terms_and_rules'], ' - ', $context['forum_name_html_safe'], ' |
@@ -190,11 +194,12 @@ discard block |
||
190 | 194 | <div class="roundframe"> |
191 | 195 | ', $context['agreement'], ' |
192 | 196 | </div>'; |
193 | - else |
|
194 | - echo ' |
|
197 | + } else { |
|
198 | + echo ' |
|
195 | 199 | <div class="noticebox"> |
196 | 200 | ', $txt['agreement_disabled'], ' |
197 | 201 | </div>'; |
198 | -} |
|
202 | + } |
|
203 | + } |
|
199 | 204 | |
200 | 205 | ?> |
201 | 206 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
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 | * Add the file functions to the $smcFunc array. |
@@ -53,8 +54,9 @@ discard block |
||
53 | 54 | 'messages', 'moderator_groups', 'moderators', 'package_servers', 'permission_profiles', 'permissions', 'personal_messages', |
54 | 55 | 'pm_labeled_messages', 'pm_labels', 'pm_recipients', 'pm_rules', 'poll_choices', 'polls', 'scheduled_tasks', 'sessions', 'settings', 'smileys', |
55 | 56 | 'spiders', 'subscriptions', 'themes', 'topics', 'user_alerts', 'user_alerts_prefs', 'user_drafts', 'user_likes'); |
56 | - foreach ($reservedTables as $k => $table_name) |
|
57 | - $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
57 | + foreach ($reservedTables as $k => $table_name) { |
|
58 | + $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
59 | + } |
|
58 | 60 | |
59 | 61 | // We in turn may need the extra stuff. |
60 | 62 | db_extend('extra'); |
@@ -107,8 +109,9 @@ discard block |
||
107 | 109 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
108 | 110 | |
109 | 111 | // First - no way do we touch SMF tables. |
110 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
111 | - return false; |
|
112 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
113 | + return false; |
|
114 | + } |
|
112 | 115 | |
113 | 116 | // Log that we'll want to remove this on uninstall. |
114 | 117 | $db_package_log[] = array('remove_table', $table_name); |
@@ -118,9 +121,9 @@ discard block |
||
118 | 121 | if (in_array($full_table_name, $tables)) |
119 | 122 | { |
120 | 123 | // This is a sad day... drop the table? If not, return false (error) by default. |
121 | - if ($if_exists == 'overwrite') |
|
122 | - $smcFunc['db_drop_table']($table_name); |
|
123 | - else if ($if_exists == 'update') |
|
124 | + if ($if_exists == 'overwrite') { |
|
125 | + $smcFunc['db_drop_table']($table_name); |
|
126 | + } else if ($if_exists == 'update') |
|
124 | 127 | { |
125 | 128 | $smcFunc['db_drop_table']($table_name.'_old'); |
126 | 129 | $smcFunc['db_transaction']('begin'); |
@@ -132,47 +135,51 @@ discard block |
||
132 | 135 | ) |
133 | 136 | ); |
134 | 137 | $old_table_exists = true; |
138 | + } else { |
|
139 | + return $if_exists == 'ignore'; |
|
135 | 140 | } |
136 | - else |
|
137 | - return $if_exists == 'ignore'; |
|
138 | 141 | } |
139 | 142 | |
140 | 143 | // If we've got this far - good news - no table exists. We can build our own! |
141 | - if (!$db_trans) |
|
142 | - $smcFunc['db_transaction']('begin'); |
|
144 | + if (!$db_trans) { |
|
145 | + $smcFunc['db_transaction']('begin'); |
|
146 | + } |
|
143 | 147 | $table_query = 'CREATE TABLE ' . $table_name . "\n" . '('; |
144 | 148 | foreach ($columns as $column) |
145 | 149 | { |
146 | 150 | // If we have an auto increment do it! |
147 | 151 | if (!empty($column['auto'])) |
148 | 152 | { |
149 | - if (!$old_table_exists) |
|
150 | - $smcFunc['db_query']('', ' |
|
153 | + if (!$old_table_exists) { |
|
154 | + $smcFunc['db_query']('', ' |
|
151 | 155 | DROP SEQUENCE IF EXISTS ' . $table_name . '_seq', |
152 | 156 | array( |
153 | 157 | 'security_override' => true, |
154 | 158 | ) |
155 | 159 | ); |
160 | + } |
|
156 | 161 | |
157 | - if (!$old_table_exists) |
|
158 | - $smcFunc['db_query']('', ' |
|
162 | + if (!$old_table_exists) { |
|
163 | + $smcFunc['db_query']('', ' |
|
159 | 164 | CREATE SEQUENCE ' . $table_name . '_seq', |
160 | 165 | array( |
161 | 166 | 'security_override' => true, |
162 | 167 | ) |
163 | 168 | ); |
169 | + } |
|
164 | 170 | $default = 'default nextval(\'' . $table_name . '_seq\')'; |
171 | + } elseif (isset($column['default']) && $column['default'] !== null) { |
|
172 | + $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
173 | + } else { |
|
174 | + $default = ''; |
|
165 | 175 | } |
166 | - elseif (isset($column['default']) && $column['default'] !== null) |
|
167 | - $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
168 | - else |
|
169 | - $default = ''; |
|
170 | 176 | |
171 | 177 | // Sort out the size... |
172 | 178 | $column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null; |
173 | 179 | list ($type, $size) = $smcFunc['db_calculate_type']($column['type'], $column['size']); |
174 | - if ($size !== null) |
|
175 | - $type = $type . '(' . $size . ')'; |
|
180 | + if ($size !== null) { |
|
181 | + $type = $type . '(' . $size . ')'; |
|
182 | + } |
|
176 | 183 | |
177 | 184 | // Now just put it together! |
178 | 185 | $table_query .= "\n\t\"" . $column['name'] . '" ' . $type . ' ' . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default . ','; |
@@ -185,19 +192,21 @@ discard block |
||
185 | 192 | $columns = implode(',', $index['columns']); |
186 | 193 | |
187 | 194 | // Primary goes in the table... |
188 | - if (isset($index['type']) && $index['type'] == 'primary') |
|
189 | - $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
190 | - else |
|
195 | + if (isset($index['type']) && $index['type'] == 'primary') { |
|
196 | + $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
197 | + } else |
|
191 | 198 | { |
192 | - if (empty($index['name'])) |
|
193 | - $index['name'] = implode('_', $index['columns']); |
|
199 | + if (empty($index['name'])) { |
|
200 | + $index['name'] = implode('_', $index['columns']); |
|
201 | + } |
|
194 | 202 | $index_queries[] = 'CREATE ' . (isset($index['type']) && $index['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $table_name . '_' . $index['name'] . ' ON ' . $table_name . ' (' . $columns . ')'; |
195 | 203 | } |
196 | 204 | } |
197 | 205 | |
198 | 206 | // No trailing commas! |
199 | - if (substr($table_query, -1) == ',') |
|
200 | - $table_query = substr($table_query, 0, -1); |
|
207 | + if (substr($table_query, -1) == ',') { |
|
208 | + $table_query = substr($table_query, 0, -1); |
|
209 | + } |
|
201 | 210 | |
202 | 211 | $table_query .= ')'; |
203 | 212 | |
@@ -242,18 +251,20 @@ discard block |
||
242 | 251 | } |
243 | 252 | |
244 | 253 | // And the indexes... |
245 | - foreach ($index_queries as $query) |
|
246 | - $smcFunc['db_query']('', $query, |
|
254 | + foreach ($index_queries as $query) { |
|
255 | + $smcFunc['db_query']('', $query, |
|
247 | 256 | array( |
248 | 257 | 'security_override' => true, |
249 | 258 | ) |
250 | 259 | ); |
260 | + } |
|
251 | 261 | |
252 | 262 | // Go, go power rangers! |
253 | 263 | $smcFunc['db_transaction']('commit'); |
254 | 264 | |
255 | - if ($old_table_exists) |
|
256 | - $smcFunc['db_drop_table']($table_name . '_old'); |
|
265 | + if ($old_table_exists) { |
|
266 | + $smcFunc['db_drop_table']($table_name . '_old'); |
|
267 | + } |
|
257 | 268 | |
258 | 269 | return true; |
259 | 270 | } |
@@ -278,8 +289,9 @@ discard block |
||
278 | 289 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
279 | 290 | |
280 | 291 | // God no - dropping one of these = bad. |
281 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
282 | - return false; |
|
292 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
293 | + return false; |
|
294 | + } |
|
283 | 295 | |
284 | 296 | // Does it exist? |
285 | 297 | if (in_array($full_table_name, $smcFunc['db_list_tables']())) |
@@ -337,21 +349,24 @@ discard block |
||
337 | 349 | |
338 | 350 | // Does it exist - if so don't add it again! |
339 | 351 | $columns = $smcFunc['db_list_columns']($table_name, false); |
340 | - foreach ($columns as $column) |
|
341 | - if ($column == $column_info['name']) |
|
352 | + foreach ($columns as $column) { |
|
353 | + if ($column == $column_info['name']) |
|
342 | 354 | { |
343 | 355 | // If we're going to overwrite then use change column. |
344 | 356 | if ($if_exists == 'update') |
345 | 357 | return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
346 | - else |
|
347 | - return false; |
|
358 | + } |
|
359 | + else { |
|
360 | + return false; |
|
361 | + } |
|
348 | 362 | } |
349 | 363 | |
350 | 364 | // Get the specifics... |
351 | 365 | $column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null; |
352 | 366 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); |
353 | - if ($size !== null) |
|
354 | - $type = $type . '(' . $size . ')'; |
|
367 | + if ($size !== null) { |
|
368 | + $type = $type . '(' . $size . ')'; |
|
369 | + } |
|
355 | 370 | |
356 | 371 | // Now add the thing! |
357 | 372 | $query = ' |
@@ -366,11 +381,12 @@ discard block |
||
366 | 381 | // If there's more attributes they need to be done via a change on PostgreSQL. |
367 | 382 | unset($column_info['type'], $column_info['size']); |
368 | 383 | |
369 | - if (count($column_info) != 1) |
|
370 | - return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
|
371 | - else |
|
372 | - return true; |
|
373 | -} |
|
384 | + if (count($column_info) != 1) { |
|
385 | + return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
|
386 | + } else { |
|
387 | + return true; |
|
388 | + } |
|
389 | + } |
|
374 | 390 | |
375 | 391 | /** |
376 | 392 | * Removes a column. |
@@ -389,8 +405,8 @@ discard block |
||
389 | 405 | |
390 | 406 | // Does it exist? |
391 | 407 | $columns = $smcFunc['db_list_columns']($table_name, true); |
392 | - foreach ($columns as $column) |
|
393 | - if ($column['name'] == $column_name) |
|
408 | + foreach ($columns as $column) { |
|
409 | + if ($column['name'] == $column_name) |
|
394 | 410 | { |
395 | 411 | // If there is an auto we need remove it! |
396 | 412 | if ($column['auto']) |
@@ -400,6 +416,7 @@ discard block |
||
400 | 416 | 'security_override' => true, |
401 | 417 | ) |
402 | 418 | ); |
419 | + } |
|
403 | 420 | |
404 | 421 | $smcFunc['db_query']('', ' |
405 | 422 | ALTER TABLE ' . $table_name . ' |
@@ -433,13 +450,15 @@ discard block |
||
433 | 450 | // Check it does exist! |
434 | 451 | $columns = $smcFunc['db_list_columns']($table_name, true); |
435 | 452 | $old_info = null; |
436 | - foreach ($columns as $column) |
|
437 | - if ($column['name'] == $old_column) |
|
453 | + foreach ($columns as $column) { |
|
454 | + if ($column['name'] == $old_column) |
|
438 | 455 | $old_info = $column; |
456 | + } |
|
439 | 457 | |
440 | 458 | // Nothing? |
441 | - if ($old_info == null) |
|
442 | - return false; |
|
459 | + if ($old_info == null) { |
|
460 | + return false; |
|
461 | + } |
|
443 | 462 | |
444 | 463 | // Now we check each bit individually and ALTER as required. |
445 | 464 | if (isset($column_info['name']) && $column_info['name'] != $old_column) |
@@ -496,8 +515,9 @@ discard block |
||
496 | 515 | { |
497 | 516 | $column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null; |
498 | 517 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); |
499 | - if ($size !== null) |
|
500 | - $type = $type . '(' . $size . ')'; |
|
518 | + if ($size !== null) { |
|
519 | + $type = $type . '(' . $size . ')'; |
|
520 | + } |
|
501 | 521 | |
502 | 522 | // The alter is a pain. |
503 | 523 | $smcFunc['db_transaction']('begin'); |
@@ -598,21 +618,23 @@ discard block |
||
598 | 618 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
599 | 619 | |
600 | 620 | // No columns = no index. |
601 | - if (empty($index_info['columns'])) |
|
602 | - return false; |
|
621 | + if (empty($index_info['columns'])) { |
|
622 | + return false; |
|
623 | + } |
|
603 | 624 | $columns = implode(',', $index_info['columns']); |
604 | 625 | |
605 | 626 | // No name - make it up! |
606 | 627 | if (empty($index_info['name'])) |
607 | 628 | { |
608 | 629 | // No need for primary. |
609 | - if (isset($index_info['type']) && $index_info['type'] == 'primary') |
|
610 | - $index_info['name'] = ''; |
|
611 | - else |
|
612 | - $index_info['name'] = $table_name . implode('_', $index_info['columns']); |
|
630 | + if (isset($index_info['type']) && $index_info['type'] == 'primary') { |
|
631 | + $index_info['name'] = ''; |
|
632 | + } else { |
|
633 | + $index_info['name'] = $table_name . implode('_', $index_info['columns']); |
|
634 | + } |
|
635 | + } else { |
|
636 | + $index_info['name'] = $table_name . $index_info['name']; |
|
613 | 637 | } |
614 | - else |
|
615 | - $index_info['name'] = $table_name . $index_info['name']; |
|
616 | 638 | |
617 | 639 | // Log that we are going to want to remove this! |
618 | 640 | $db_package_log[] = array('remove_index', $table_name, $index_info['name']); |
@@ -625,10 +647,11 @@ discard block |
||
625 | 647 | if ($index['name'] == $index_info['name'] || ($index['type'] == 'primary' && isset($index_info['type']) && $index_info['type'] == 'primary')) |
626 | 648 | { |
627 | 649 | // If we want to overwrite simply remove the current one then continue. |
628 | - if ($if_exists != 'update' || $index['type'] == 'primary') |
|
629 | - return false; |
|
630 | - else |
|
631 | - $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
650 | + if ($if_exists != 'update' || $index['type'] == 'primary') { |
|
651 | + return false; |
|
652 | + } else { |
|
653 | + $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
654 | + } |
|
632 | 655 | } |
633 | 656 | } |
634 | 657 | |
@@ -642,8 +665,7 @@ discard block |
||
642 | 665 | 'security_override' => true, |
643 | 666 | ) |
644 | 667 | ); |
645 | - } |
|
646 | - else |
|
668 | + } else |
|
647 | 669 | { |
648 | 670 | $smcFunc['db_query']('', ' |
649 | 671 | CREATE ' . (isset($index_info['type']) && $index_info['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $index_info['name'] . ' ON ' . $table_name . ' (' . $columns . ')', |
@@ -671,8 +693,9 @@ discard block |
||
671 | 693 | |
672 | 694 | // Better exist! |
673 | 695 | $indexes = $smcFunc['db_list_indexes']($table_name, true); |
674 | - if ($index_name != 'primary') |
|
675 | - $index_name = $table_name . '_' . $index_name; |
|
696 | + if ($index_name != 'primary') { |
|
697 | + $index_name = $table_name . '_' . $index_name; |
|
698 | + } |
|
676 | 699 | |
677 | 700 | foreach ($indexes as $index) |
678 | 701 | { |
@@ -736,8 +759,7 @@ discard block |
||
736 | 759 | 'datetime' => 'timestamp without time zone', |
737 | 760 | 'timestamp' => 'timestamp without time zone', |
738 | 761 | ); |
739 | - } |
|
740 | - else |
|
762 | + } else |
|
741 | 763 | { |
742 | 764 | $types = array( |
743 | 765 | 'character varying' => 'varchar', |
@@ -753,14 +775,16 @@ discard block |
||
753 | 775 | // Got it? Change it! |
754 | 776 | if (isset($types[$type_name])) |
755 | 777 | { |
756 | - if ($type_name == 'tinytext') |
|
757 | - $type_size = 255; |
|
778 | + if ($type_name == 'tinytext') { |
|
779 | + $type_size = 255; |
|
780 | + } |
|
758 | 781 | $type_name = $types[$type_name]; |
759 | 782 | } |
760 | 783 | |
761 | 784 | // Only char fields got size |
762 | - if (strpos($type_name, 'char') === false) |
|
763 | - $type_size = null; |
|
785 | + if (strpos($type_name, 'char') === false) { |
|
786 | + $type_size = null; |
|
787 | + } |
|
764 | 788 | |
765 | 789 | |
766 | 790 | return array($type_name, $type_size); |
@@ -816,8 +840,7 @@ discard block |
||
816 | 840 | if (!$detail) |
817 | 841 | { |
818 | 842 | $columns[] = $row['column_name']; |
819 | - } |
|
820 | - else |
|
843 | + } else |
|
821 | 844 | { |
822 | 845 | $auto = false; |
823 | 846 | // What is the default? |
@@ -825,11 +848,11 @@ discard block |
||
825 | 848 | { |
826 | 849 | $default = null; |
827 | 850 | $auto = true; |
851 | + } elseif (trim($row['column_default']) != '') { |
|
852 | + $default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::')); |
|
853 | + } else { |
|
854 | + $default = null; |
|
828 | 855 | } |
829 | - elseif (trim($row['column_default']) != '') |
|
830 | - $default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::')); |
|
831 | - else |
|
832 | - $default = null; |
|
833 | 856 | |
834 | 857 | // Make the type generic. |
835 | 858 | list ($type, $size) = $smcFunc['db_calculate_type']($row['data_type'], $row['character_maximum_length'], true); |
@@ -880,26 +903,30 @@ discard block |
||
880 | 903 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
881 | 904 | { |
882 | 905 | // Try get the columns that make it up. |
883 | - if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) |
|
884 | - continue; |
|
906 | + if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) { |
|
907 | + continue; |
|
908 | + } |
|
885 | 909 | |
886 | 910 | $columns = explode(',', $matches[1]); |
887 | 911 | |
888 | - if (empty($columns)) |
|
889 | - continue; |
|
912 | + if (empty($columns)) { |
|
913 | + continue; |
|
914 | + } |
|
890 | 915 | |
891 | - foreach ($columns as $k => $v) |
|
892 | - $columns[$k] = trim($v); |
|
916 | + foreach ($columns as $k => $v) { |
|
917 | + $columns[$k] = trim($v); |
|
918 | + } |
|
893 | 919 | |
894 | 920 | // Fix up the name to be consistent cross databases |
895 | - if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1) |
|
896 | - $row['name'] = 'PRIMARY'; |
|
897 | - else |
|
898 | - $row['name'] = str_replace($table_name . '_', '', $row['name']); |
|
921 | + if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1) { |
|
922 | + $row['name'] = 'PRIMARY'; |
|
923 | + } else { |
|
924 | + $row['name'] = str_replace($table_name . '_', '', $row['name']); |
|
925 | + } |
|
899 | 926 | |
900 | - if (!$detail) |
|
901 | - $indexes[] = $row['name']; |
|
902 | - else |
|
927 | + if (!$detail) { |
|
928 | + $indexes[] = $row['name']; |
|
929 | + } else |
|
903 | 930 | { |
904 | 931 | $indexes[$row['name']] = array( |
905 | 932 | 'name' => $row['name'], |
@@ -1,9 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
6 | -else |
|
6 | +} else { |
|
7 | 7 | exit; |
8 | +} |
|
8 | 9 | |
9 | 10 | ?> |
10 | 11 | \ No newline at end of file |
@@ -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 |
@@ -41,37 +41,43 @@ discard block |
||
41 | 41 | define('TIME_START', microtime(true)); |
42 | 42 | |
43 | 43 | // Just being safe... |
44 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
44 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
45 | 45 | if (isset($GLOBALS[$variable])) |
46 | 46 | unset($GLOBALS[$variable]); |
47 | +} |
|
47 | 48 | |
48 | 49 | // Get the forum's settings for database and file paths. |
49 | 50 | require_once(dirname(__FILE__) . '/Settings.php'); |
50 | 51 | |
51 | 52 | // Make absolutely sure the cache directory is defined. |
52 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
53 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
53 | 54 | $cachedir = $boarddir . '/cache'; |
55 | +} |
|
54 | 56 | |
55 | 57 | // Don't do john didley if the forum's been shut down competely. |
56 | -if ($maintenance == 2) |
|
58 | +if ($maintenance == 2) { |
|
57 | 59 | die($mmessage); |
60 | +} |
|
58 | 61 | |
59 | 62 | // Fix for using the current directory as a path. |
60 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
63 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
61 | 64 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
65 | +} |
|
62 | 66 | |
63 | 67 | // Have we already turned this off? If so, exist gracefully. |
64 | -if (file_exists($cachedir . '/cron.lock')) |
|
68 | +if (file_exists($cachedir . '/cron.lock')) { |
|
65 | 69 | obExit_cron(); |
70 | +} |
|
66 | 71 | |
67 | 72 | // Before we go any further, if this is not a CLI request, we need to do some checking. |
68 | 73 | if (!FROM_CLI) |
69 | 74 | { |
70 | 75 | // We will clean up $_GET shortly. But we want to this ASAP. |
71 | 76 | $ts = isset($_GET['ts']) ? (int) $_GET['ts'] : 0; |
72 | - if ($ts <= 0 || $ts % 15 != 0 || time() - $ts < 0 || time() - $ts > 20) |
|
73 | - obExit_cron(); |
|
74 | -} |
|
77 | + if ($ts <= 0 || $ts % 15 != 0 || time() - $ts < 0 || time() - $ts > 20) { |
|
78 | + obExit_cron(); |
|
79 | + } |
|
80 | + } |
|
75 | 81 | |
76 | 82 | // Load the most important includes. In general, a background should be loading its own dependencies. |
77 | 83 | require_once($sourcedir . '/Errors.php'); |
@@ -123,8 +129,9 @@ discard block |
||
123 | 129 | global $smcFunc; |
124 | 130 | |
125 | 131 | // Check we haven't run over our time limit. |
126 | - if (microtime(true) - TIME_START > MAX_CRON_TIME) |
|
127 | - return false; |
|
132 | + if (microtime(true) - TIME_START > MAX_CRON_TIME) { |
|
133 | + return false; |
|
134 | + } |
|
128 | 135 | |
129 | 136 | // Try to find a task. Specifically, try to find one that hasn't been claimed previously, or failing that, |
130 | 137 | // a task that was claimed but failed for whatever reason and failed long enough ago. We should not care |
@@ -159,14 +166,12 @@ discard block |
||
159 | 166 | // Update the time and go back. |
160 | 167 | $row['claimed_time'] = time(); |
161 | 168 | return $row; |
162 | - } |
|
163 | - else |
|
169 | + } else |
|
164 | 170 | { |
165 | 171 | // Uh oh, we just missed it. Try to claim another one, and let it fall through if there aren't any. |
166 | 172 | return fetch_task(); |
167 | 173 | } |
168 | - } |
|
169 | - else |
|
174 | + } else |
|
170 | 175 | { |
171 | 176 | // No dice. Clean up and go home. |
172 | 177 | $smcFunc['db_free_result']($request); |
@@ -187,8 +192,9 @@ discard block |
||
187 | 192 | if (!empty($task_details['task_file'])) |
188 | 193 | { |
189 | 194 | $include = strtr(trim($task_details['task_file']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
190 | - if (file_exists($include)) |
|
191 | - require_once($include); |
|
195 | + if (file_exists($include)) { |
|
196 | + require_once($include); |
|
197 | + } |
|
192 | 198 | } |
193 | 199 | |
194 | 200 | if (empty($task_details['task_class'])) |
@@ -204,8 +210,7 @@ discard block |
||
204 | 210 | $details = empty($task_details['task_data']) ? array() : $smcFunc['json_decode']($task_details['task_data'], true); |
205 | 211 | $bgtask = new $task_details['task_class']($details); |
206 | 212 | return $bgtask->execute(); |
207 | - } |
|
208 | - else |
|
213 | + } else |
|
209 | 214 | { |
210 | 215 | log_error('Invalid background task specified: (class: ' . $task_details['task_class'] . ', ' . (empty($task_details['task_file']) ? ' no file' : ' to load ' . $task_details['task_file']) . ')'); |
211 | 216 | return true; // So we clear it from the queue. |
@@ -224,8 +229,9 @@ discard block |
||
224 | 229 | $scripturl = $boardurl . '/index.php'; |
225 | 230 | |
226 | 231 | // These keys shouldn't be set...ever. |
227 | - if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
228 | - die('Invalid request variable.'); |
|
232 | + if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
233 | + die('Invalid request variable.'); |
|
234 | + } |
|
229 | 235 | |
230 | 236 | // Save some memory.. (since we don't use these anyway.) |
231 | 237 | unset($GLOBALS['HTTP_POST_VARS'], $GLOBALS['HTTP_POST_VARS']); |
@@ -246,26 +252,28 @@ discard block |
||
246 | 252 | global $modSettings; |
247 | 253 | |
248 | 254 | // Ignore errors if we're ignoring them or they are strict notices from PHP 5 |
249 | - if (error_reporting() == 0) |
|
250 | - return; |
|
255 | + if (error_reporting() == 0) { |
|
256 | + return; |
|
257 | + } |
|
251 | 258 | |
252 | 259 | $error_type = 'cron'; |
253 | 260 | |
254 | 261 | log_error($error_level . ': ' . $error_string, $error_type, $file, $line); |
255 | 262 | |
256 | 263 | // If this is an E_ERROR or E_USER_ERROR.... die. Violently so. |
257 | - if ($error_level % 255 == E_ERROR) |
|
258 | - die('No direct access...'); |
|
259 | -} |
|
264 | + if ($error_level % 255 == E_ERROR) { |
|
265 | + die('No direct access...'); |
|
266 | + } |
|
267 | + } |
|
260 | 268 | |
261 | 269 | /** |
262 | 270 | * The exit function |
263 | 271 | */ |
264 | 272 | function obExit_cron() |
265 | 273 | { |
266 | - if (FROM_CLI) |
|
267 | - die(0); |
|
268 | - else |
|
274 | + if (FROM_CLI) { |
|
275 | + die(0); |
|
276 | + } else |
|
269 | 277 | { |
270 | 278 | header('content-type: image/gif'); |
271 | 279 | die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B"); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | // This won't be dedicated without this - this must exist in each gateway! |
15 | 15 | // SMF Payment Gateway: paypal |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Class for returning available form data for this gateway |
@@ -118,8 +119,7 @@ discard block |
||
118 | 119 | { |
119 | 120 | $return_data['hidden']['p3'] = 1; |
120 | 121 | $return_data['hidden']['t3'] = strtoupper(substr($period, 0, 1)); |
121 | - } |
|
122 | - else |
|
122 | + } else |
|
123 | 123 | { |
124 | 124 | preg_match('~(\d*)(\w)~', $sub_data['real_length'], $match); |
125 | 125 | $unit = $match[1]; |
@@ -130,14 +130,15 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | // If it's repeatable do some javascript to respect this idea. |
133 | - if (!empty($sub_data['repeatable'])) |
|
134 | - $return_data['javascript'] = ' |
|
133 | + if (!empty($sub_data['repeatable'])) { |
|
134 | + $return_data['javascript'] = ' |
|
135 | 135 | document.write(\'<label for="do_paypal_recur"><input type="checkbox" name="do_paypal_recur" id="do_paypal_recur" checked onclick="switchPaypalRecur();">' . $txt['paid_make_recurring'] . '</label><br>\'); |
136 | 136 | |
137 | 137 | function switchPaypalRecur() |
138 | 138 | { |
139 | 139 | document.getElementById("paypal_cmd").value = document.getElementById("do_paypal_recur").checked ? "_xclick-subscriptions" : "_xclick"; |
140 | 140 | }'; |
141 | + } |
|
141 | 142 | |
142 | 143 | return $return_data; |
143 | 144 | } |
@@ -160,20 +161,24 @@ discard block |
||
160 | 161 | global $modSettings; |
161 | 162 | |
162 | 163 | // Has the user set up an email address? |
163 | - if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email']))) |
|
164 | - return false; |
|
164 | + if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email']))) { |
|
165 | + return false; |
|
166 | + } |
|
165 | 167 | // Check the correct transaction types are even here. |
166 | - if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email']))) |
|
167 | - return false; |
|
168 | + if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email']))) { |
|
169 | + return false; |
|
170 | + } |
|
168 | 171 | // Correct email address? |
169 | - if (!isset($_POST['business'])) |
|
170 | - $_POST['business'] = $_POST['receiver_email']; |
|
172 | + if (!isset($_POST['business'])) { |
|
173 | + $_POST['business'] = $_POST['receiver_email']; |
|
174 | + } |
|
171 | 175 | |
172 | 176 | // Are we testing? |
173 | - if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) |
|
174 | - return false; |
|
175 | - elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails'])))) |
|
176 | - return false; |
|
177 | + if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) { |
|
178 | + return false; |
|
179 | + } elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails'])))) { |
|
180 | + return false; |
|
181 | + } |
|
177 | 182 | return true; |
178 | 183 | } |
179 | 184 | |
@@ -192,15 +197,17 @@ discard block |
||
192 | 197 | global $modSettings, $txt; |
193 | 198 | |
194 | 199 | // Put this to some default value. |
195 | - if (!isset($_POST['txn_type'])) |
|
196 | - $_POST['txn_type'] = ''; |
|
200 | + if (!isset($_POST['txn_type'])) { |
|
201 | + $_POST['txn_type'] = ''; |
|
202 | + } |
|
197 | 203 | |
198 | 204 | // Build the request string - starting with the minimum requirement. |
199 | 205 | $requestString = 'cmd=_notify-validate'; |
200 | 206 | |
201 | 207 | // Now my dear, add all the posted bits in the order we got them |
202 | - foreach ($_POST as $k => $v) |
|
203 | - $requestString .= '&' . $k . '=' . urlencode($v); |
|
208 | + foreach ($_POST as $k => $v) { |
|
209 | + $requestString .= '&' . $k . '=' . urlencode($v); |
|
210 | + } |
|
204 | 211 | |
205 | 212 | // Can we use curl? |
206 | 213 | if (function_exists('curl_init') && $curl = curl_init((!empty($modSettings['paidsubs_test']) ? 'https://www.sandbox.' : 'https://www.') . 'paypal.com/cgi-bin/webscr')) |
@@ -240,14 +247,16 @@ discard block |
||
240 | 247 | $header .= 'connection: close' . "\r\n\r\n"; |
241 | 248 | |
242 | 249 | // Open the connection. |
243 | - if (!empty($modSettings['paidsubs_test'])) |
|
244 | - $fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); |
|
245 | - else |
|
246 | - $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30); |
|
250 | + if (!empty($modSettings['paidsubs_test'])) { |
|
251 | + $fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); |
|
252 | + } else { |
|
253 | + $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30); |
|
254 | + } |
|
247 | 255 | |
248 | 256 | // Did it work? |
249 | - if (!$fp) |
|
250 | - generateSubscriptionError($txt['paypal_could_not_connect']); |
|
257 | + if (!$fp) { |
|
258 | + generateSubscriptionError($txt['paypal_could_not_connect']); |
|
259 | + } |
|
251 | 260 | |
252 | 261 | // Put the data to the port. |
253 | 262 | fputs($fp, $header . $requestString); |
@@ -256,8 +265,9 @@ discard block |
||
256 | 265 | while (!feof($fp)) |
257 | 266 | { |
258 | 267 | $this->return_data = fgets($fp, 1024); |
259 | - if (strcmp(trim($this->return_data), 'VERIFIED') === 0) |
|
260 | - break; |
|
268 | + if (strcmp(trim($this->return_data), 'VERIFIED') === 0) { |
|
269 | + break; |
|
270 | + } |
|
261 | 271 | } |
262 | 272 | |
263 | 273 | // Clean up. |
@@ -265,28 +275,34 @@ discard block |
||
265 | 275 | } |
266 | 276 | |
267 | 277 | // If this isn't verified then give up... |
268 | - if (strcmp(trim($this->return_data), 'VERIFIED') !== 0) |
|
269 | - exit; |
|
278 | + if (strcmp(trim($this->return_data), 'VERIFIED') !== 0) { |
|
279 | + exit; |
|
280 | + } |
|
270 | 281 | |
271 | 282 | // Check that this is intended for us. |
272 | - if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) |
|
273 | - exit; |
|
283 | + if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) { |
|
284 | + exit; |
|
285 | + } |
|
274 | 286 | |
275 | 287 | // Is this a subscription - and if so is it a secondary payment that we need to process? |
276 | 288 | // If so, make sure we get it in the expected format. Seems PayPal sometimes sends it without urlencoding. |
277 | - if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false) |
|
278 | - $_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']); |
|
279 | - if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false)) |
|
280 | - // Calculate the subscription it relates to! |
|
289 | + if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false) { |
|
290 | + $_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']); |
|
291 | + } |
|
292 | + if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false)) { |
|
293 | + // Calculate the subscription it relates to! |
|
281 | 294 | $this->_findSubscription(); |
295 | + } |
|
282 | 296 | |
283 | 297 | // Verify the currency! |
284 | - if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code'])) |
|
285 | - exit; |
|
298 | + if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code'])) { |
|
299 | + exit; |
|
300 | + } |
|
286 | 301 | |
287 | 302 | // Can't exist if it doesn't contain anything. |
288 | - if (empty($_POST['item_number'])) |
|
289 | - exit; |
|
303 | + if (empty($_POST['item_number'])) { |
|
304 | + exit; |
|
305 | + } |
|
290 | 306 | |
291 | 307 | // Return the id_sub and id_member |
292 | 308 | return explode('+', $_POST['item_number']); |
@@ -299,10 +315,11 @@ discard block |
||
299 | 315 | */ |
300 | 316 | public function isRefund() |
301 | 317 | { |
302 | - if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')) |
|
303 | - return true; |
|
304 | - else |
|
305 | - return false; |
|
318 | + if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')) { |
|
319 | + return true; |
|
320 | + } else { |
|
321 | + return false; |
|
322 | + } |
|
306 | 323 | } |
307 | 324 | |
308 | 325 | /** |
@@ -312,10 +329,11 @@ discard block |
||
312 | 329 | */ |
313 | 330 | public function isSubscription() |
314 | 331 | { |
315 | - if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed') |
|
316 | - return true; |
|
317 | - else |
|
318 | - return false; |
|
332 | + if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed') { |
|
333 | + return true; |
|
334 | + } else { |
|
335 | + return false; |
|
336 | + } |
|
319 | 337 | } |
320 | 338 | |
321 | 339 | /** |
@@ -325,10 +343,11 @@ discard block |
||
325 | 343 | */ |
326 | 344 | public function isPayment() |
327 | 345 | { |
328 | - if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept') |
|
329 | - return true; |
|
330 | - else |
|
331 | - return false; |
|
346 | + if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept') { |
|
347 | + return true; |
|
348 | + } else { |
|
349 | + return false; |
|
350 | + } |
|
332 | 351 | } |
333 | 352 | |
334 | 353 | /** |
@@ -341,10 +360,11 @@ discard block |
||
341 | 360 | // subscr_cancel is sent when the user cancels, subscr_eot is sent when the subscription reaches final payment |
342 | 361 | // Neither require us to *do* anything as per performCancel(). |
343 | 362 | // subscr_eot, if sent, indicates an end of payments term. |
344 | - if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot') |
|
345 | - return true; |
|
346 | - else |
|
347 | - return false; |
|
363 | + if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot') { |
|
364 | + return true; |
|
365 | + } else { |
|
366 | + return false; |
|
367 | + } |
|
348 | 368 | } |
349 | 369 | |
350 | 370 | /** |
@@ -408,8 +428,9 @@ discard block |
||
408 | 428 | global $smcFunc; |
409 | 429 | |
410 | 430 | // Assume we have this? |
411 | - if (empty($_POST['subscr_id'])) |
|
412 | - return false; |
|
431 | + if (empty($_POST['subscr_id'])) { |
|
432 | + return false; |
|
433 | + } |
|
413 | 434 | |
414 | 435 | // Do we have this in the database? |
415 | 436 | $request = $smcFunc['db_query']('', ' |
@@ -438,11 +459,12 @@ discard block |
||
438 | 459 | 'payer_email' => $_POST['payer_email'], |
439 | 460 | ) |
440 | 461 | ); |
441 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
442 | - return false; |
|
462 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
463 | + return false; |
|
464 | + } |
|
465 | + } else { |
|
466 | + return false; |
|
443 | 467 | } |
444 | - else |
|
445 | - return false; |
|
446 | 468 | } |
447 | 469 | list ($member_id, $subscription_id) = $smcFunc['db_fetch_row']($request); |
448 | 470 | $_POST['item_number'] = $member_id . '+' . $subscription_id; |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
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 | * Outputs xml data representing recent information or a profile. |
@@ -37,8 +38,9 @@ discard block |
||
37 | 38 | global $query_this_board, $smcFunc, $forum_version, $settings; |
38 | 39 | |
39 | 40 | // If it's not enabled, die. |
40 | - if (empty($modSettings['xmlnews_enable'])) |
|
41 | - obExit(false); |
|
41 | + if (empty($modSettings['xmlnews_enable'])) { |
|
42 | + obExit(false); |
|
43 | + } |
|
42 | 44 | |
43 | 45 | loadLanguage('Stats'); |
44 | 46 | |
@@ -64,8 +66,9 @@ discard block |
||
64 | 66 | if (!empty($_REQUEST['c']) && empty($board)) |
65 | 67 | { |
66 | 68 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
67 | - foreach ($_REQUEST['c'] as $i => $c) |
|
68 | - $_REQUEST['c'][$i] = (int) $c; |
|
69 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
70 | + $_REQUEST['c'][$i] = (int) $c; |
|
71 | + } |
|
69 | 72 | |
70 | 73 | if (count($_REQUEST['c']) == 1) |
71 | 74 | { |
@@ -101,18 +104,20 @@ discard block |
||
101 | 104 | } |
102 | 105 | $smcFunc['db_free_result']($request); |
103 | 106 | |
104 | - if (!empty($boards)) |
|
105 | - $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
107 | + if (!empty($boards)) { |
|
108 | + $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
109 | + } |
|
106 | 110 | |
107 | 111 | // Try to limit the number of messages we look through. |
108 | - if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15) |
|
109 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $_GET['limit'] * 5); |
|
110 | - } |
|
111 | - elseif (!empty($_REQUEST['boards'])) |
|
112 | + if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15) { |
|
113 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $_GET['limit'] * 5); |
|
114 | + } |
|
115 | + } elseif (!empty($_REQUEST['boards'])) |
|
112 | 116 | { |
113 | 117 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
114 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
115 | - $_REQUEST['boards'][$i] = (int) $b; |
|
118 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
119 | + $_REQUEST['boards'][$i] = (int) $b; |
|
120 | + } |
|
116 | 121 | |
117 | 122 | $request = $smcFunc['db_query']('', ' |
118 | 123 | SELECT b.id_board, b.num_posts, b.name |
@@ -128,29 +133,32 @@ discard block |
||
128 | 133 | |
129 | 134 | // Either the board specified doesn't exist or you have no access. |
130 | 135 | $num_boards = $smcFunc['db_num_rows']($request); |
131 | - if ($num_boards == 0) |
|
132 | - fatal_lang_error('no_board'); |
|
136 | + if ($num_boards == 0) { |
|
137 | + fatal_lang_error('no_board'); |
|
138 | + } |
|
133 | 139 | |
134 | 140 | $total_posts = 0; |
135 | 141 | $boards = array(); |
136 | 142 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
137 | 143 | { |
138 | - if ($num_boards == 1) |
|
139 | - $feed_meta['title'] = ' - ' . strip_tags($row['name']); |
|
144 | + if ($num_boards == 1) { |
|
145 | + $feed_meta['title'] = ' - ' . strip_tags($row['name']); |
|
146 | + } |
|
140 | 147 | |
141 | 148 | $boards[] = $row['id_board']; |
142 | 149 | $total_posts += $row['num_posts']; |
143 | 150 | } |
144 | 151 | $smcFunc['db_free_result']($request); |
145 | 152 | |
146 | - if (!empty($boards)) |
|
147 | - $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
153 | + if (!empty($boards)) { |
|
154 | + $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
155 | + } |
|
148 | 156 | |
149 | 157 | // The more boards, the more we're going to look through... |
150 | - if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12) |
|
151 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $_GET['limit'] * 5); |
|
152 | - } |
|
153 | - elseif (!empty($board)) |
|
158 | + if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12) { |
|
159 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $_GET['limit'] * 5); |
|
160 | + } |
|
161 | + } elseif (!empty($board)) |
|
154 | 162 | { |
155 | 163 | $request = $smcFunc['db_query']('', ' |
156 | 164 | SELECT num_posts |
@@ -170,10 +178,10 @@ discard block |
||
170 | 178 | $query_this_board = 'b.id_board = ' . $board; |
171 | 179 | |
172 | 180 | // Try to look through just a few messages, if at all possible. |
173 | - if ($total_posts > 80 && $total_posts > $modSettings['totalMessages'] / 10) |
|
174 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $_GET['limit'] * 5); |
|
175 | - } |
|
176 | - else |
|
181 | + if ($total_posts > 80 && $total_posts > $modSettings['totalMessages'] / 10) { |
|
182 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $_GET['limit'] * 5); |
|
183 | + } |
|
184 | + } else |
|
177 | 185 | { |
178 | 186 | $query_this_board = '{query_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
179 | 187 | AND b.id_board != ' . $modSettings['recycle_board'] : ''); |
@@ -196,30 +204,35 @@ discard block |
||
196 | 204 | // Easy adding of sub actions |
197 | 205 | call_integration_hook('integrate_xmlfeeds', array(&$subActions)); |
198 | 206 | |
199 | - if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']])) |
|
200 | - $_GET['sa'] = 'recent'; |
|
207 | + if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']])) { |
|
208 | + $_GET['sa'] = 'recent'; |
|
209 | + } |
|
201 | 210 | |
202 | 211 | // We only want some information, not all of it. |
203 | 212 | $cachekey = array($xml_format, $_GET['action'], $_GET['limit'], $_GET['sa']); |
204 | - foreach (array('board', 'boards', 'c') as $var) |
|
205 | - if (isset($_REQUEST[$var])) |
|
213 | + foreach (array('board', 'boards', 'c') as $var) { |
|
214 | + if (isset($_REQUEST[$var])) |
|
206 | 215 | $cachekey[] = $_REQUEST[$var]; |
216 | + } |
|
207 | 217 | $cachekey = md5($smcFunc['json_encode']($cachekey) . (!empty($query_this_board) ? $query_this_board : '')); |
208 | 218 | $cache_t = microtime(); |
209 | 219 | |
210 | 220 | // Get the associative array representing the xml. |
211 | - if (!empty($modSettings['cache_enable']) && (!$user_info['is_guest'] || $modSettings['cache_enable'] >= 3)) |
|
212 | - $xml_data = cache_get_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240); |
|
221 | + if (!empty($modSettings['cache_enable']) && (!$user_info['is_guest'] || $modSettings['cache_enable'] >= 3)) { |
|
222 | + $xml_data = cache_get_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240); |
|
223 | + } |
|
213 | 224 | if (empty($xml_data)) |
214 | 225 | { |
215 | 226 | $call = call_helper($subActions[$_GET['sa']][0], true); |
216 | 227 | |
217 | - if (!empty($call)) |
|
218 | - $xml_data = call_user_func($call, $xml_format); |
|
228 | + if (!empty($call)) { |
|
229 | + $xml_data = call_user_func($call, $xml_format); |
|
230 | + } |
|
219 | 231 | |
220 | 232 | if (!empty($modSettings['cache_enable']) && (($user_info['is_guest'] && $modSettings['cache_enable'] >= 3) |
221 | - || (!$user_info['is_guest'] && (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.2)))) |
|
222 | - cache_put_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml_data, 240); |
|
233 | + || (!$user_info['is_guest'] && (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.2)))) { |
|
234 | + cache_put_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml_data, 240); |
|
235 | + } |
|
223 | 236 | } |
224 | 237 | |
225 | 238 | $feed_meta['title'] = $smcFunc['htmlspecialchars'](strip_tags($context['forum_name'])) . (isset($feed_meta['title']) ? $feed_meta['title'] : ''); |
@@ -259,43 +272,49 @@ discard block |
||
259 | 272 | call_integration_hook('integrate_xml_data', array(&$xml_data, &$feed_meta, &$namespaces, &$extraFeedTags, &$forceCdataKeys, &$nsKeys, $xml_format, $_GET['sa'])); |
260 | 273 | |
261 | 274 | // These can't be empty |
262 | - foreach (array('title', 'desc', 'source') as $mkey) |
|
263 | - $feed_meta[$mkey] = !empty($feed_meta[$mkey]) ? $feed_meta[$mkey] : $orig_feed_meta[$mkey]; |
|
275 | + foreach (array('title', 'desc', 'source') as $mkey) { |
|
276 | + $feed_meta[$mkey] = !empty($feed_meta[$mkey]) ? $feed_meta[$mkey] : $orig_feed_meta[$mkey]; |
|
277 | + } |
|
264 | 278 | |
265 | 279 | // Sanitize basic feed metadata values |
266 | - foreach ($feed_meta as $mkey => $mvalue) |
|
267 | - $feed_meta[$mkey] = cdata_parse(strip_tags(fix_possible_url($feed_meta[$mkey]))); |
|
280 | + foreach ($feed_meta as $mkey => $mvalue) { |
|
281 | + $feed_meta[$mkey] = cdata_parse(strip_tags(fix_possible_url($feed_meta[$mkey]))); |
|
282 | + } |
|
268 | 283 | |
269 | 284 | $ns_string = ''; |
270 | 285 | if (!empty($namespaces[$xml_format])) |
271 | 286 | { |
272 | - foreach ($namespaces[$xml_format] as $nsprefix => $nsurl) |
|
273 | - $ns_string .= ' xmlns' . ($nsprefix !== '' ? ':' : '') . $nsprefix . '="' . $nsurl . '"'; |
|
287 | + foreach ($namespaces[$xml_format] as $nsprefix => $nsurl) { |
|
288 | + $ns_string .= ' xmlns' . ($nsprefix !== '' ? ':' : '') . $nsprefix . '="' . $nsurl . '"'; |
|
289 | + } |
|
274 | 290 | } |
275 | 291 | |
276 | 292 | $extraFeedTags_string = ''; |
277 | 293 | if (!empty($extraFeedTags[$xml_format])) |
278 | 294 | { |
279 | 295 | $indent = "\t" . ($xml_format !== 'atom' ? "\t" : ''); |
280 | - foreach ($extraFeedTags[$xml_format] as $extraTag) |
|
281 | - $extraFeedTags_string .= "\n" . $indent . $extraTag; |
|
296 | + foreach ($extraFeedTags[$xml_format] as $extraTag) { |
|
297 | + $extraFeedTags_string .= "\n" . $indent . $extraTag; |
|
298 | + } |
|
282 | 299 | } |
283 | 300 | |
284 | 301 | // This is an xml file.... |
285 | 302 | ob_end_clean(); |
286 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
287 | - @ob_start('ob_gzhandler'); |
|
288 | - else |
|
289 | - ob_start(); |
|
303 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
304 | + @ob_start('ob_gzhandler'); |
|
305 | + } else { |
|
306 | + ob_start(); |
|
307 | + } |
|
290 | 308 | |
291 | - if ($xml_format == 'smf' || isset($_REQUEST['debug'])) |
|
292 | - header('content-type: text/xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
293 | - elseif ($xml_format == 'rss' || $xml_format == 'rss2') |
|
294 | - header('content-type: application/rss+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
295 | - elseif ($xml_format == 'atom') |
|
296 | - header('content-type: application/atom+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
297 | - elseif ($xml_format == 'rdf') |
|
298 | - header('content-type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
309 | + if ($xml_format == 'smf' || isset($_REQUEST['debug'])) { |
|
310 | + header('content-type: text/xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
311 | + } elseif ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
312 | + header('content-type: application/rss+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
313 | + } elseif ($xml_format == 'atom') { |
|
314 | + header('content-type: application/atom+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
315 | + } elseif ($xml_format == 'rdf') { |
|
316 | + header('content-type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
317 | + } |
|
299 | 318 | |
300 | 319 | // First, output the xml header. |
301 | 320 | echo '<?xml version="1.0" encoding="', $context['character_set'], '"?' . '>'; |
@@ -303,10 +322,11 @@ discard block |
||
303 | 322 | // Are we outputting an rss feed or one with more information? |
304 | 323 | if ($xml_format == 'rss' || $xml_format == 'rss2') |
305 | 324 | { |
306 | - if ($xml_format == 'rss2') |
|
307 | - foreach ($_REQUEST as $var => $val) |
|
325 | + if ($xml_format == 'rss2') { |
|
326 | + foreach ($_REQUEST as $var => $val) |
|
308 | 327 | if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit'))) |
309 | 328 | $url_parts[] = $var . '=' . (is_array($val) ? implode(',', $val) : $val); |
329 | + } |
|
310 | 330 | |
311 | 331 | // Start with an RSS 2.0 header. |
312 | 332 | echo ' |
@@ -327,9 +347,10 @@ discard block |
||
327 | 347 | <language>' . $feed_meta['language'] . '</language>' : ''; |
328 | 348 | |
329 | 349 | // RSS2 calls for this. |
330 | - if ($xml_format == 'rss2') |
|
331 | - echo ' |
|
350 | + if ($xml_format == 'rss2') { |
|
351 | + echo ' |
|
332 | 352 | <atom:link rel="self" type="application/rss+xml" href="', $scripturl, !empty($url_parts) ? '?' . implode(';', $url_parts) : '', '" />'; |
353 | + } |
|
333 | 354 | |
334 | 355 | echo $extraFeedTags_string; |
335 | 356 | |
@@ -340,12 +361,12 @@ discard block |
||
340 | 361 | echo ' |
341 | 362 | </channel> |
342 | 363 | </rss>'; |
343 | - } |
|
344 | - elseif ($xml_format == 'atom') |
|
364 | + } elseif ($xml_format == 'atom') |
|
345 | 365 | { |
346 | - foreach ($_REQUEST as $var => $val) |
|
347 | - if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit'))) |
|
366 | + foreach ($_REQUEST as $var => $val) { |
|
367 | + if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit'))) |
|
348 | 368 | $url_parts[] = $var . '=' . (is_array($val) ? implode(',', $val) : $val); |
369 | + } |
|
349 | 370 | |
350 | 371 | echo ' |
351 | 372 | <feed', $ns_string, !empty($feed_meta['language']) ? ' xml:lang="' . $feed_meta['language'] . '"' : '', '> |
@@ -371,8 +392,7 @@ discard block |
||
371 | 392 | |
372 | 393 | echo ' |
373 | 394 | </feed>'; |
374 | - } |
|
375 | - elseif ($xml_format == 'rdf') |
|
395 | + } elseif ($xml_format == 'rdf') |
|
376 | 396 | { |
377 | 397 | echo ' |
378 | 398 | <rdf:RDF', $ns_string, '> |
@@ -437,13 +457,15 @@ discard block |
||
437 | 457 | { |
438 | 458 | global $modSettings, $context, $scripturl; |
439 | 459 | |
440 | - if (substr($val, 0, strlen($scripturl)) != $scripturl) |
|
441 | - return $val; |
|
460 | + if (substr($val, 0, strlen($scripturl)) != $scripturl) { |
|
461 | + return $val; |
|
462 | + } |
|
442 | 463 | |
443 | 464 | call_integration_hook('integrate_fix_url', array(&$val)); |
444 | 465 | |
445 | - if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd'])) |
|
446 | - return $val; |
|
466 | + if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd'])) { |
|
467 | + return $val; |
|
468 | + } |
|
447 | 469 | |
448 | 470 | $val = preg_replace_callback('~\b' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$~', function($m) use ($scripturl) |
449 | 471 | { |
@@ -466,8 +488,9 @@ discard block |
||
466 | 488 | global $smcFunc; |
467 | 489 | |
468 | 490 | // Do we even need to do this? |
469 | - if (strpbrk($data, '<>&') == false && $force !== true) |
|
470 | - return $data; |
|
491 | + if (strpbrk($data, '<>&') == false && $force !== true) { |
|
492 | + return $data; |
|
493 | + } |
|
471 | 494 | |
472 | 495 | $cdata = '<, |
478 | 501 | $smcFunc['strpos']($data, ']', $pos), |
479 | 502 | ); |
480 | - if ($ns != '') |
|
481 | - $positions[] = $smcFunc['strpos']($data, '<', $pos); |
|
503 | + if ($ns != '') { |
|
504 | + $positions[] = $smcFunc['strpos']($data, '<', $pos); |
|
505 | + } |
|
482 | 506 | foreach ($positions as $k => $dummy) |
483 | 507 | { |
484 | - if ($dummy === false) |
|
485 | - unset($positions[$k]); |
|
508 | + if ($dummy === false) { |
|
509 | + unset($positions[$k]); |
|
510 | + } |
|
486 | 511 | } |
487 | 512 | |
488 | 513 | $old = $pos; |
489 | 514 | $pos = empty($positions) ? $n : min($positions); |
490 | 515 | |
491 | - if ($pos - $old > 0) |
|
492 | - $cdata .= $smcFunc['substr']($data, $old, $pos - $old); |
|
493 | - if ($pos >= $n) |
|
494 | - break; |
|
516 | + if ($pos - $old > 0) { |
|
517 | + $cdata .= $smcFunc['substr']($data, $old, $pos - $old); |
|
518 | + } |
|
519 | + if ($pos >= $n) { |
|
520 | + break; |
|
521 | + } |
|
495 | 522 | |
496 | 523 | if ($smcFunc['substr']($data, $pos, 1) == '<') |
497 | 524 | { |
498 | 525 | $pos2 = $smcFunc['strpos']($data, '>', $pos); |
499 | - if ($pos2 === false) |
|
500 | - $pos2 = $n; |
|
501 | - if ($smcFunc['substr']($data, $pos + 1, 1) == '/') |
|
502 | - $cdata .= ']]></' . $ns . ':' . $smcFunc['substr']($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA['; |
|
503 | - else |
|
504 | - $cdata .= ']]><' . $ns . ':' . $smcFunc['substr']($data, $pos + 1, $pos2 - $pos) . '< == '/') { |
|
530 | + $cdata .= ']]></' . $ns . ':' . $smcFunc['substr']($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA['; |
|
531 | + } else { |
|
532 | + $cdata .= ']]><' . $ns . ':' . $smcFunc['substr']($data, $pos + 1, $pos2 - $pos) . '< == ']') |
|
535 | + } elseif ($smcFunc['substr']($data, $pos, 1) == ']') |
|
508 | 536 | { |
509 | 537 | $cdata .= ']]>]< == '&') |
|
539 | + } elseif ($smcFunc['substr']($data, $pos, 1) == '&') |
|
513 | 540 | { |
514 | 541 | $pos2 = $smcFunc['strpos']($data, ';', $pos); |
515 | - if ($pos2 === false) |
|
516 | - $pos2 = $n; |
|
542 | + if ($pos2 === false) { |
|
543 | + $pos2 = $n; |
|
544 | + } |
|
517 | 545 | $ent = $smcFunc['substr']($data, $pos + 1, $pos2 - $pos - 1); |
518 | 546 | |
519 | - if ($smcFunc['substr']($data, $pos + 1, 1) == '#') |
|
520 | - $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
521 | - elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot'))) |
|
522 | - $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '< == '#') { |
|
548 | + $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
549 | + } elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot'))) { |
|
550 | + $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
551 | + } |
|
523 | 552 | |
524 | 553 | $pos = $pos2 + 1; |
525 | 554 | } |
@@ -559,8 +588,9 @@ discard block |
||
559 | 588 | 'gender', |
560 | 589 | 'blurb', |
561 | 590 | ); |
562 | - if ($xml_format != 'atom') |
|
563 | - $keysToCdata[] = 'category'; |
|
591 | + if ($xml_format != 'atom') { |
|
592 | + $keysToCdata[] = 'category'; |
|
593 | + } |
|
564 | 594 | |
565 | 595 | if (!empty($forceCdataKeys)) |
566 | 596 | { |
@@ -577,8 +607,9 @@ discard block |
||
577 | 607 | $attrs = isset($element['attributes']) ? $element['attributes'] : null; |
578 | 608 | |
579 | 609 | // Skip it, it's been set to null. |
580 | - if ($key === null || ($val === null && $attrs === null)) |
|
581 | - continue; |
|
610 | + if ($key === null || ($val === null && $attrs === null)) { |
|
611 | + continue; |
|
612 | + } |
|
582 | 613 | |
583 | 614 | $forceCdata = in_array($key, $forceCdataKeys); |
584 | 615 | $ns = !empty($nsKeys[$key]) ? $nsKeys[$key] : ''; |
@@ -591,16 +622,16 @@ discard block |
||
591 | 622 | |
592 | 623 | if (!empty($attrs)) |
593 | 624 | { |
594 | - foreach ($attrs as $attr_key => $attr_value) |
|
595 | - echo ' ', $attr_key, '="', fix_possible_url($attr_value), '"'; |
|
625 | + foreach ($attrs as $attr_key => $attr_value) { |
|
626 | + echo ' ', $attr_key, '="', fix_possible_url($attr_value), '"'; |
|
627 | + } |
|
596 | 628 | } |
597 | 629 | |
598 | 630 | // If it's empty, simply output an empty element. |
599 | 631 | if (empty($val)) |
600 | 632 | { |
601 | 633 | echo ' />'; |
602 | - } |
|
603 | - else |
|
634 | + } else |
|
604 | 635 | { |
605 | 636 | echo '>'; |
606 | 637 | |
@@ -612,11 +643,13 @@ discard block |
||
612 | 643 | echo "\n", str_repeat("\t", $i); |
613 | 644 | } |
614 | 645 | // A string with returns in it.... show this as a multiline element. |
615 | - elseif (strpos($val, "\n") !== false) |
|
616 | - echo "\n", in_array($key, $keysToCdata) ? cdata_parse(fix_possible_url($val), $ns, $forceCdata) : fix_possible_url($val), "\n", str_repeat("\t", $i); |
|
646 | + elseif (strpos($val, "\n") !== false) { |
|
647 | + echo "\n", in_array($key, $keysToCdata) ? cdata_parse(fix_possible_url($val), $ns, $forceCdata) : fix_possible_url($val), "\n", str_repeat("\t", $i); |
|
648 | + } |
|
617 | 649 | // A simple string. |
618 | - else |
|
619 | - echo in_array($key, $keysToCdata) ? cdata_parse(fix_possible_url($val), $ns, $forceCdata) : fix_possible_url($val); |
|
650 | + else { |
|
651 | + echo in_array($key, $keysToCdata) ? cdata_parse(fix_possible_url($val), $ns, $forceCdata) : fix_possible_url($val); |
|
652 | + } |
|
620 | 653 | |
621 | 654 | // Ending tag. |
622 | 655 | echo '</', $key, '>'; |
@@ -636,8 +669,9 @@ discard block |
||
636 | 669 | { |
637 | 670 | global $scripturl, $smcFunc; |
638 | 671 | |
639 | - if (!allowedTo('view_mlist')) |
|
640 | - return array(); |
|
672 | + if (!allowedTo('view_mlist')) { |
|
673 | + return array(); |
|
674 | + } |
|
641 | 675 | |
642 | 676 | // Find the most recent members. |
643 | 677 | $request = $smcFunc['db_query']('', ' |
@@ -656,8 +690,8 @@ discard block |
||
656 | 690 | $guid = 'tag:' . parse_url($scripturl, PHP_URL_HOST) . ',' . gmdate('Y-m-d', $row['date_registered']) . ':member=' . $row['id_member']; |
657 | 691 | |
658 | 692 | // Make the data look rss-ish. |
659 | - if ($xml_format == 'rss' || $xml_format == 'rss2') |
|
660 | - $data[] = array( |
|
693 | + if ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
694 | + $data[] = array( |
|
661 | 695 | 'tag' => 'item', |
662 | 696 | 'content' => array( |
663 | 697 | array( |
@@ -685,8 +719,8 @@ discard block |
||
685 | 719 | ), |
686 | 720 | ), |
687 | 721 | ); |
688 | - elseif ($xml_format == 'rdf') |
|
689 | - $data[] = array( |
|
722 | + } elseif ($xml_format == 'rdf') { |
|
723 | + $data[] = array( |
|
690 | 724 | 'tag' => 'item', |
691 | 725 | 'attributes' => array('rdf:about' => $scripturl . '?action=profile;u=' . $row['id_member']), |
692 | 726 | 'content' => array( |
@@ -704,8 +738,8 @@ discard block |
||
704 | 738 | ), |
705 | 739 | ), |
706 | 740 | ); |
707 | - elseif ($xml_format == 'atom') |
|
708 | - $data[] = array( |
|
741 | + } elseif ($xml_format == 'atom') { |
|
742 | + $data[] = array( |
|
709 | 743 | 'tag' => 'entry', |
710 | 744 | 'content' => array( |
711 | 745 | array( |
@@ -734,9 +768,10 @@ discard block |
||
734 | 768 | ), |
735 | 769 | ), |
736 | 770 | ); |
771 | + } |
|
737 | 772 | // More logical format for the data, but harder to apply. |
738 | - else |
|
739 | - $data[] = array( |
|
773 | + else { |
|
774 | + $data[] = array( |
|
740 | 775 | 'tag' => 'member', |
741 | 776 | 'content' => array( |
742 | 777 | array( |
@@ -757,6 +792,7 @@ discard block |
||
757 | 792 | ), |
758 | 793 | ), |
759 | 794 | ); |
795 | + } |
|
760 | 796 | } |
761 | 797 | $smcFunc['db_free_result']($request); |
762 | 798 | |
@@ -817,22 +853,24 @@ discard block |
||
817 | 853 | if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit']) |
818 | 854 | { |
819 | 855 | $smcFunc['db_free_result']($request); |
820 | - if (empty($_REQUEST['boards']) && empty($board)) |
|
821 | - unset($context['optimize_msg']['lowest']); |
|
822 | - else |
|
823 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= t.id_first_msg'; |
|
856 | + if (empty($_REQUEST['boards']) && empty($board)) { |
|
857 | + unset($context['optimize_msg']['lowest']); |
|
858 | + } else { |
|
859 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= t.id_first_msg'; |
|
860 | + } |
|
824 | 861 | $context['optimize_msg']['highest'] = 'm.id_msg <= t.id_last_msg'; |
825 | 862 | $loops++; |
863 | + } else { |
|
864 | + $done = true; |
|
826 | 865 | } |
827 | - else |
|
828 | - $done = true; |
|
829 | 866 | } |
830 | 867 | $data = array(); |
831 | 868 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
832 | 869 | { |
833 | 870 | // Limit the length of the message, if the option is set. |
834 | - if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) |
|
835 | - $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
871 | + if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) { |
|
872 | + $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
873 | + } |
|
836 | 874 | |
837 | 875 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
838 | 876 | |
@@ -859,8 +897,9 @@ discard block |
||
859 | 897 | while ($attach = $smcFunc['db_fetch_assoc']($attach_request)) |
860 | 898 | { |
861 | 899 | // Include approved attachments only |
862 | - if ($attach['approved']) |
|
863 | - $loaded_attachments['attachment_' . $attach['id_attach']] = $attach; |
|
900 | + if ($attach['approved']) { |
|
901 | + $loaded_attachments['attachment_' . $attach['id_attach']] = $attach; |
|
902 | + } |
|
864 | 903 | } |
865 | 904 | $smcFunc['db_free_result']($attach_request); |
866 | 905 | |
@@ -868,16 +907,17 @@ discard block |
||
868 | 907 | if (!empty($loaded_attachments)) |
869 | 908 | { |
870 | 909 | uasort($loaded_attachments, function($a, $b) { |
871 | - if ($a['filesize'] == $b['filesize']) |
|
872 | - return 0; |
|
910 | + if ($a['filesize'] == $b['filesize']) { |
|
911 | + return 0; |
|
912 | + } |
|
873 | 913 | return ($a['filesize'] < $b['filesize']) ? -1 : 1; |
874 | 914 | }); |
915 | + } else { |
|
916 | + $loaded_attachments = null; |
|
875 | 917 | } |
876 | - else |
|
877 | - $loaded_attachments = null; |
|
918 | + } else { |
|
919 | + $loaded_attachments = null; |
|
878 | 920 | } |
879 | - else |
|
880 | - $loaded_attachments = null; |
|
881 | 921 | |
882 | 922 | // Create a GUID for this topic using the tag URI scheme |
883 | 923 | $guid = 'tag:' . parse_url($scripturl, PHP_URL_HOST) . ',' . gmdate('Y-m-d', $row['poster_time']) . ':topic=' . $row['id_topic']; |
@@ -894,9 +934,9 @@ discard block |
||
894 | 934 | 'length' => $attachment['filesize'], |
895 | 935 | 'type' => $attachment['mime_type'], |
896 | 936 | ); |
937 | + } else { |
|
938 | + $enclosure = null; |
|
897 | 939 | } |
898 | - else |
|
899 | - $enclosure = null; |
|
900 | 940 | |
901 | 941 | $data[] = array( |
902 | 942 | 'tag' => 'item', |
@@ -942,8 +982,7 @@ discard block |
||
942 | 982 | ), |
943 | 983 | ), |
944 | 984 | ); |
945 | - } |
|
946 | - elseif ($xml_format == 'rdf') |
|
985 | + } elseif ($xml_format == 'rdf') |
|
947 | 986 | { |
948 | 987 | $data[] = array( |
949 | 988 | 'tag' => 'item', |
@@ -967,8 +1006,7 @@ discard block |
||
967 | 1006 | ), |
968 | 1007 | ), |
969 | 1008 | ); |
970 | - } |
|
971 | - elseif ($xml_format == 'atom') |
|
1009 | + } elseif ($xml_format == 'atom') |
|
972 | 1010 | { |
973 | 1011 | // Only one attachment allowed |
974 | 1012 | if (!empty($loaded_attachments)) |
@@ -980,9 +1018,9 @@ discard block |
||
980 | 1018 | 'length' => $attachment['filesize'], |
981 | 1019 | 'type' => $attachment['mime_type'], |
982 | 1020 | ); |
1021 | + } else { |
|
1022 | + $enclosure = null; |
|
983 | 1023 | } |
984 | - else |
|
985 | - $enclosure = null; |
|
986 | 1024 | |
987 | 1025 | $data[] = array( |
988 | 1026 | 'tag' => 'entry', |
@@ -1082,9 +1120,9 @@ discard block |
||
1082 | 1120 | ) |
1083 | 1121 | ); |
1084 | 1122 | } |
1123 | + } else { |
|
1124 | + $attachments = null; |
|
1085 | 1125 | } |
1086 | - else |
|
1087 | - $attachments = null; |
|
1088 | 1126 | |
1089 | 1127 | $data[] = array( |
1090 | 1128 | 'tag' => 'article', |
@@ -1202,22 +1240,25 @@ discard block |
||
1202 | 1240 | if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit']) |
1203 | 1241 | { |
1204 | 1242 | $smcFunc['db_free_result']($request); |
1205 | - if (empty($_REQUEST['boards']) && empty($board)) |
|
1206 | - unset($context['optimize_msg']['lowest']); |
|
1207 | - else |
|
1208 | - $context['optimize_msg']['lowest'] = $loops ? 'm.id_msg >= t.id_first_msg' : 'm.id_msg >= (t.id_last_msg - t.id_first_msg) / 2'; |
|
1243 | + if (empty($_REQUEST['boards']) && empty($board)) { |
|
1244 | + unset($context['optimize_msg']['lowest']); |
|
1245 | + } else { |
|
1246 | + $context['optimize_msg']['lowest'] = $loops ? 'm.id_msg >= t.id_first_msg' : 'm.id_msg >= (t.id_last_msg - t.id_first_msg) / 2'; |
|
1247 | + } |
|
1209 | 1248 | $loops++; |
1249 | + } else { |
|
1250 | + $done = true; |
|
1210 | 1251 | } |
1211 | - else |
|
1212 | - $done = true; |
|
1213 | 1252 | } |
1214 | 1253 | $messages = array(); |
1215 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1216 | - $messages[] = $row['id_msg']; |
|
1254 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1255 | + $messages[] = $row['id_msg']; |
|
1256 | + } |
|
1217 | 1257 | $smcFunc['db_free_result']($request); |
1218 | 1258 | |
1219 | - if (empty($messages)) |
|
1220 | - return array(); |
|
1259 | + if (empty($messages)) { |
|
1260 | + return array(); |
|
1261 | + } |
|
1221 | 1262 | |
1222 | 1263 | // Find the most recent posts this user can see. |
1223 | 1264 | $request = $smcFunc['db_query']('', ' |
@@ -1247,8 +1288,9 @@ discard block |
||
1247 | 1288 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1248 | 1289 | { |
1249 | 1290 | // Limit the length of the message, if the option is set. |
1250 | - if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) |
|
1251 | - $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
1291 | + if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) { |
|
1292 | + $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
1293 | + } |
|
1252 | 1294 | |
1253 | 1295 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
1254 | 1296 | |
@@ -1275,8 +1317,9 @@ discard block |
||
1275 | 1317 | while ($attach = $smcFunc['db_fetch_assoc']($attach_request)) |
1276 | 1318 | { |
1277 | 1319 | // Include approved attachments only |
1278 | - if ($attach['approved']) |
|
1279 | - $loaded_attachments['attachment_' . $attach['id_attach']] = $attach; |
|
1320 | + if ($attach['approved']) { |
|
1321 | + $loaded_attachments['attachment_' . $attach['id_attach']] = $attach; |
|
1322 | + } |
|
1280 | 1323 | } |
1281 | 1324 | $smcFunc['db_free_result']($attach_request); |
1282 | 1325 | |
@@ -1284,16 +1327,17 @@ discard block |
||
1284 | 1327 | if (!empty($loaded_attachments)) |
1285 | 1328 | { |
1286 | 1329 | uasort($loaded_attachments, function($a, $b) { |
1287 | - if ($a['filesize'] == $b['filesize']) |
|
1288 | - return 0; |
|
1330 | + if ($a['filesize'] == $b['filesize']) { |
|
1331 | + return 0; |
|
1332 | + } |
|
1289 | 1333 | return ($a['filesize'] < $b['filesize']) ? -1 : 1; |
1290 | 1334 | }); |
1335 | + } else { |
|
1336 | + $loaded_attachments = null; |
|
1291 | 1337 | } |
1292 | - else |
|
1293 | - $loaded_attachments = null; |
|
1338 | + } else { |
|
1339 | + $loaded_attachments = null; |
|
1294 | 1340 | } |
1295 | - else |
|
1296 | - $loaded_attachments = null; |
|
1297 | 1341 | |
1298 | 1342 | // Create a GUID for this post using the tag URI scheme |
1299 | 1343 | $guid = 'tag:' . parse_url($scripturl, PHP_URL_HOST) . ',' . gmdate('Y-m-d', $row['poster_time']) . ':msg=' . $row['id_msg']; |
@@ -1310,9 +1354,9 @@ discard block |
||
1310 | 1354 | 'length' => $attachment['filesize'], |
1311 | 1355 | 'type' => $attachment['mime_type'], |
1312 | 1356 | ); |
1357 | + } else { |
|
1358 | + $enclosure = null; |
|
1313 | 1359 | } |
1314 | - else |
|
1315 | - $enclosure = null; |
|
1316 | 1360 | |
1317 | 1361 | $data[] = array( |
1318 | 1362 | 'tag' => 'item', |
@@ -1358,8 +1402,7 @@ discard block |
||
1358 | 1402 | ), |
1359 | 1403 | ), |
1360 | 1404 | ); |
1361 | - } |
|
1362 | - elseif ($xml_format == 'rdf') |
|
1405 | + } elseif ($xml_format == 'rdf') |
|
1363 | 1406 | { |
1364 | 1407 | $data[] = array( |
1365 | 1408 | 'tag' => 'item', |
@@ -1383,8 +1426,7 @@ discard block |
||
1383 | 1426 | ), |
1384 | 1427 | ), |
1385 | 1428 | ); |
1386 | - } |
|
1387 | - elseif ($xml_format == 'atom') |
|
1429 | + } elseif ($xml_format == 'atom') |
|
1388 | 1430 | { |
1389 | 1431 | // Only one attachment allowed |
1390 | 1432 | if (!empty($loaded_attachments)) |
@@ -1396,9 +1438,9 @@ discard block |
||
1396 | 1438 | 'length' => $attachment['filesize'], |
1397 | 1439 | 'type' => $attachment['mime_type'], |
1398 | 1440 | ); |
1441 | + } else { |
|
1442 | + $enclosure = null; |
|
1399 | 1443 | } |
1400 | - else |
|
1401 | - $enclosure = null; |
|
1402 | 1444 | |
1403 | 1445 | $data[] = array( |
1404 | 1446 | 'tag' => 'entry', |
@@ -1498,9 +1540,9 @@ discard block |
||
1498 | 1540 | ) |
1499 | 1541 | ); |
1500 | 1542 | } |
1543 | + } else { |
|
1544 | + $attachments = null; |
|
1501 | 1545 | } |
1502 | - else |
|
1503 | - $attachments = null; |
|
1504 | 1546 | |
1505 | 1547 | $data[] = array( |
1506 | 1548 | 'tag' => 'recent-post', |
@@ -1619,14 +1661,16 @@ discard block |
||
1619 | 1661 | global $scripturl, $memberContext, $user_profile, $user_info; |
1620 | 1662 | |
1621 | 1663 | // You must input a valid user.... |
1622 | - if (empty($_GET['u']) || !loadMemberData((int) $_GET['u'])) |
|
1623 | - return array(); |
|
1664 | + if (empty($_GET['u']) || !loadMemberData((int) $_GET['u'])) { |
|
1665 | + return array(); |
|
1666 | + } |
|
1624 | 1667 | |
1625 | 1668 | // Make sure the id is a number and not "I like trying to hack the database". |
1626 | 1669 | $_GET['u'] = (int) $_GET['u']; |
1627 | 1670 | // Load the member's contextual information! |
1628 | - if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view')) |
|
1629 | - return array(); |
|
1671 | + if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view')) { |
|
1672 | + return array(); |
|
1673 | + } |
|
1630 | 1674 | |
1631 | 1675 | // Okay, I admit it, I'm lazy. Stupid $_GET['u'] is long and hard to type. |
1632 | 1676 | $profile = &$memberContext[$_GET['u']]; |
@@ -1668,8 +1712,7 @@ discard block |
||
1668 | 1712 | ), |
1669 | 1713 | ) |
1670 | 1714 | ); |
1671 | - } |
|
1672 | - elseif ($xml_format == 'rdf') |
|
1715 | + } elseif ($xml_format == 'rdf') |
|
1673 | 1716 | { |
1674 | 1717 | $data[] = array( |
1675 | 1718 | 'tag' => 'item', |
@@ -1693,8 +1736,7 @@ discard block |
||
1693 | 1736 | ), |
1694 | 1737 | ) |
1695 | 1738 | ); |
1696 | - } |
|
1697 | - elseif ($xml_format == 'atom') |
|
1739 | + } elseif ($xml_format == 'atom') |
|
1698 | 1740 | { |
1699 | 1741 | $data[] = array( |
1700 | 1742 | 'tag' => 'entry', |
@@ -1747,8 +1789,7 @@ discard block |
||
1747 | 1789 | ), |
1748 | 1790 | ) |
1749 | 1791 | ); |
1750 | - } |
|
1751 | - else |
|
1792 | + } else |
|
1752 | 1793 | { |
1753 | 1794 | $data = array( |
1754 | 1795 | array( |