@@ -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" class="new_win" 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 |
@@ -30,8 +30,9 @@ discard block |
||
30 | 30 | * @version 2.1 Beta 4 |
31 | 31 | */ |
32 | 32 | |
33 | -if (!defined('SMF')) |
|
33 | +if (!defined('SMF')) { |
|
34 | 34 | die('No direct access...'); |
35 | +} |
|
35 | 36 | |
36 | 37 | /** |
37 | 38 | * Subaction handler - manages the action and delegates control to the proper |
@@ -103,12 +104,12 @@ discard block |
||
103 | 104 | cache_put_data('minimized_css', null); |
104 | 105 | |
105 | 106 | // Follow the sa or just go to administration. |
106 | - if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) |
|
107 | - call_helper($subActions[$_GET['sa']]); |
|
108 | - |
|
109 | - else |
|
110 | - call_helper($subActions['admin']); |
|
111 | -} |
|
107 | + if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) { |
|
108 | + call_helper($subActions[$_GET['sa']]); |
|
109 | + } else { |
|
110 | + call_helper($subActions['admin']); |
|
111 | + } |
|
112 | + } |
|
112 | 113 | |
113 | 114 | /** |
114 | 115 | * This function allows administration of themes and their settings, |
@@ -130,15 +131,16 @@ discard block |
||
130 | 131 | checkSession(); |
131 | 132 | validateToken('admin-tm'); |
132 | 133 | |
133 | - if (isset($_POST['options']['known_themes'])) |
|
134 | - foreach ($_POST['options']['known_themes'] as $key => $id) |
|
134 | + if (isset($_POST['options']['known_themes'])) { |
|
135 | + foreach ($_POST['options']['known_themes'] as $key => $id) |
|
135 | 136 | $_POST['options']['known_themes'][$key] = (int) $id; |
137 | + } else { |
|
138 | + fatal_lang_error('themes_none_selectable', false); |
|
139 | + } |
|
136 | 140 | |
137 | - else |
|
138 | - fatal_lang_error('themes_none_selectable', false); |
|
139 | - |
|
140 | - if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) |
|
141 | - fatal_lang_error('themes_default_selectable', false); |
|
141 | + if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) { |
|
142 | + fatal_lang_error('themes_default_selectable', false); |
|
143 | + } |
|
142 | 144 | |
143 | 145 | // Commit the new settings. |
144 | 146 | updateSettings(array( |
@@ -146,8 +148,9 @@ discard block |
||
146 | 148 | 'theme_guests' => $_POST['options']['theme_guests'], |
147 | 149 | 'knownThemes' => implode(',', $_POST['options']['known_themes']), |
148 | 150 | )); |
149 | - if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) |
|
150 | - updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
151 | + if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) { |
|
152 | + updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
153 | + } |
|
151 | 154 | |
152 | 155 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=admin'); |
153 | 156 | } |
@@ -166,8 +169,9 @@ discard block |
||
166 | 169 | // Look for a non existent theme directory. (ie theme87.) |
167 | 170 | $theme_dir = $boarddir . '/Themes/theme'; |
168 | 171 | $i = 1; |
169 | - while (file_exists($theme_dir . $i)) |
|
170 | - $i++; |
|
172 | + while (file_exists($theme_dir . $i)) { |
|
173 | + $i++; |
|
174 | + } |
|
171 | 175 | |
172 | 176 | $context['new_theme_name'] = 'theme' . $i; |
173 | 177 | |
@@ -189,8 +193,9 @@ discard block |
||
189 | 193 | loadLanguage('Admin'); |
190 | 194 | isAllowedTo('admin_forum'); |
191 | 195 | |
192 | - if (isset($_REQUEST['th'])) |
|
193 | - return SetThemeSettings(); |
|
196 | + if (isset($_REQUEST['th'])) { |
|
197 | + return SetThemeSettings(); |
|
198 | + } |
|
194 | 199 | |
195 | 200 | if (isset($_POST['save'])) |
196 | 201 | { |
@@ -274,12 +279,13 @@ discard block |
||
274 | 279 | $context['themes'] = array(); |
275 | 280 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
276 | 281 | { |
277 | - if (!isset($context['themes'][$row['id_theme']])) |
|
278 | - $context['themes'][$row['id_theme']] = array( |
|
282 | + if (!isset($context['themes'][$row['id_theme']])) { |
|
283 | + $context['themes'][$row['id_theme']] = array( |
|
279 | 284 | 'id' => $row['id_theme'], |
280 | 285 | 'num_default_options' => 0, |
281 | 286 | 'num_members' => 0, |
282 | 287 | ); |
288 | + } |
|
283 | 289 | $context['themes'][$row['id_theme']][$row['variable']] = $row['value']; |
284 | 290 | } |
285 | 291 | $smcFunc['db_free_result']($request); |
@@ -293,8 +299,9 @@ discard block |
||
293 | 299 | 'guest_member' => -1, |
294 | 300 | ) |
295 | 301 | ); |
296 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
297 | - $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
302 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
303 | + $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
304 | + } |
|
298 | 305 | $smcFunc['db_free_result']($request); |
299 | 306 | |
300 | 307 | // Need to make sure we don't do custom fields. |
@@ -305,8 +312,9 @@ discard block |
||
305 | 312 | ) |
306 | 313 | ); |
307 | 314 | $customFields = array(); |
308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
309 | - $customFields[] = $row['col_name']; |
|
315 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
316 | + $customFields[] = $row['col_name']; |
|
317 | + } |
|
310 | 318 | $smcFunc['db_free_result']($request); |
311 | 319 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
312 | 320 | |
@@ -321,14 +329,16 @@ discard block |
||
321 | 329 | 'custom_fields' => empty($customFields) ? array() : $customFields, |
322 | 330 | ) |
323 | 331 | ); |
324 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
325 | - $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
332 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
333 | + $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
334 | + } |
|
326 | 335 | $smcFunc['db_free_result']($request); |
327 | 336 | |
328 | 337 | // There has to be a Settings template! |
329 | - foreach ($context['themes'] as $k => $v) |
|
330 | - if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
338 | + foreach ($context['themes'] as $k => $v) { |
|
339 | + if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
331 | 340 | unset($context['themes'][$k]); |
341 | + } |
|
332 | 342 | |
333 | 343 | loadTemplate('Themes'); |
334 | 344 | $context['sub_template'] = 'reset_list'; |
@@ -343,16 +353,19 @@ discard block |
||
343 | 353 | checkSession(); |
344 | 354 | validateToken('admin-sto'); |
345 | 355 | |
346 | - if (empty($_POST['options'])) |
|
347 | - $_POST['options'] = array(); |
|
348 | - if (empty($_POST['default_options'])) |
|
349 | - $_POST['default_options'] = array(); |
|
356 | + if (empty($_POST['options'])) { |
|
357 | + $_POST['options'] = array(); |
|
358 | + } |
|
359 | + if (empty($_POST['default_options'])) { |
|
360 | + $_POST['default_options'] = array(); |
|
361 | + } |
|
350 | 362 | |
351 | 363 | // Set up the sql query. |
352 | 364 | $setValues = array(); |
353 | 365 | |
354 | - foreach ($_POST['options'] as $opt => $val) |
|
355 | - $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
366 | + foreach ($_POST['options'] as $opt => $val) { |
|
367 | + $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
368 | + } |
|
356 | 369 | |
357 | 370 | $old_settings = array(); |
358 | 371 | foreach ($_POST['default_options'] as $opt => $val) |
@@ -366,8 +379,8 @@ discard block |
||
366 | 379 | if (!empty($setValues)) |
367 | 380 | { |
368 | 381 | // Are there options in non-default themes set that should be cleared? |
369 | - if (!empty($old_settings)) |
|
370 | - $smcFunc['db_query']('', ' |
|
382 | + if (!empty($old_settings)) { |
|
383 | + $smcFunc['db_query']('', ' |
|
371 | 384 | DELETE FROM {db_prefix}themes |
372 | 385 | WHERE id_theme != {int:default_theme} |
373 | 386 | AND id_member = {int:guest_member} |
@@ -378,6 +391,7 @@ discard block |
||
378 | 391 | 'old_settings' => $old_settings, |
379 | 392 | ) |
380 | 393 | ); |
394 | + } |
|
381 | 395 | |
382 | 396 | $smcFunc['db_insert']('replace', |
383 | 397 | '{db_prefix}themes', |
@@ -391,8 +405,7 @@ discard block |
||
391 | 405 | cache_put_data('theme_settings-1', null, 90); |
392 | 406 | |
393 | 407 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
394 | - } |
|
395 | - elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
408 | + } elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
396 | 409 | { |
397 | 410 | checkSession(); |
398 | 411 | validateToken('admin-sto'); |
@@ -405,9 +418,9 @@ discard block |
||
405 | 418 | $old_settings = array(); |
406 | 419 | foreach ($_POST['default_options'] as $opt => $val) |
407 | 420 | { |
408 | - if ($_POST['default_options_master'][$opt] == 0) |
|
409 | - continue; |
|
410 | - elseif ($_POST['default_options_master'][$opt] == 1) |
|
421 | + if ($_POST['default_options_master'][$opt] == 0) { |
|
422 | + continue; |
|
423 | + } elseif ($_POST['default_options_master'][$opt] == 1) |
|
411 | 424 | { |
412 | 425 | // Delete then insert for ease of database compatibility! |
413 | 426 | $smcFunc['db_query']('substring', ' |
@@ -433,8 +446,7 @@ discard block |
||
433 | 446 | ); |
434 | 447 | |
435 | 448 | $old_settings[] = $opt; |
436 | - } |
|
437 | - elseif ($_POST['default_options_master'][$opt] == 2) |
|
449 | + } elseif ($_POST['default_options_master'][$opt] == 2) |
|
438 | 450 | { |
439 | 451 | $smcFunc['db_query']('', ' |
440 | 452 | DELETE FROM {db_prefix}themes |
@@ -449,8 +461,8 @@ discard block |
||
449 | 461 | } |
450 | 462 | |
451 | 463 | // Delete options from other themes. |
452 | - if (!empty($old_settings)) |
|
453 | - $smcFunc['db_query']('', ' |
|
464 | + if (!empty($old_settings)) { |
|
465 | + $smcFunc['db_query']('', ' |
|
454 | 466 | DELETE FROM {db_prefix}themes |
455 | 467 | WHERE id_theme != {int:default_theme} |
456 | 468 | AND id_member > {int:no_member} |
@@ -461,12 +473,13 @@ discard block |
||
461 | 473 | 'old_settings' => $old_settings, |
462 | 474 | ) |
463 | 475 | ); |
476 | + } |
|
464 | 477 | |
465 | 478 | foreach ($_POST['options'] as $opt => $val) |
466 | 479 | { |
467 | - if ($_POST['options_master'][$opt] == 0) |
|
468 | - continue; |
|
469 | - elseif ($_POST['options_master'][$opt] == 1) |
|
480 | + if ($_POST['options_master'][$opt] == 0) { |
|
481 | + continue; |
|
482 | + } elseif ($_POST['options_master'][$opt] == 1) |
|
470 | 483 | { |
471 | 484 | // Delete then insert for ease of database compatibility - again! |
472 | 485 | $smcFunc['db_query']('substring', ' |
@@ -491,8 +504,7 @@ discard block |
||
491 | 504 | 'value' => (is_array($val) ? implode(',', $val) : $val), |
492 | 505 | ) |
493 | 506 | ); |
494 | - } |
|
495 | - elseif ($_POST['options_master'][$opt] == 2) |
|
507 | + } elseif ($_POST['options_master'][$opt] == 2) |
|
496 | 508 | { |
497 | 509 | $smcFunc['db_query']('', ' |
498 | 510 | DELETE FROM {db_prefix}themes |
@@ -509,8 +521,7 @@ discard block |
||
509 | 521 | } |
510 | 522 | |
511 | 523 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
512 | - } |
|
513 | - elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
524 | + } elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
514 | 525 | { |
515 | 526 | checkSession('get'); |
516 | 527 | validateToken('admin-stor', 'request'); |
@@ -525,8 +536,9 @@ discard block |
||
525 | 536 | ) |
526 | 537 | ); |
527 | 538 | $customFields = array(); |
528 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
529 | - $customFields[] = $row['col_name']; |
|
539 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
540 | + $customFields[] = $row['col_name']; |
|
541 | + } |
|
530 | 542 | $smcFunc['db_free_result']($request); |
531 | 543 | } |
532 | 544 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
@@ -578,13 +590,13 @@ discard block |
||
578 | 590 | ) |
579 | 591 | ); |
580 | 592 | $context['theme_options'] = array(); |
581 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
582 | - $context['theme_options'][$row['variable']] = $row['value']; |
|
593 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
594 | + $context['theme_options'][$row['variable']] = $row['value']; |
|
595 | + } |
|
583 | 596 | $smcFunc['db_free_result']($request); |
584 | 597 | |
585 | 598 | $context['theme_options_reset'] = false; |
586 | - } |
|
587 | - else |
|
599 | + } else |
|
588 | 600 | { |
589 | 601 | $context['theme_options'] = array(); |
590 | 602 | $context['theme_options_reset'] = true; |
@@ -593,30 +605,32 @@ discard block |
||
593 | 605 | foreach ($context['options'] as $i => $setting) |
594 | 606 | { |
595 | 607 | // Just skip separators |
596 | - if (!is_array($setting)) |
|
597 | - continue; |
|
608 | + if (!is_array($setting)) { |
|
609 | + continue; |
|
610 | + } |
|
598 | 611 | |
599 | 612 | // Is this disabled? |
600 | 613 | if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) |
601 | 614 | { |
602 | 615 | unset($context['options'][$i]); |
603 | 616 | continue; |
604 | - } |
|
605 | - elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
617 | + } elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
606 | 618 | { |
607 | 619 | unset($context['options'][$i]); |
608 | 620 | continue; |
609 | 621 | } |
610 | 622 | |
611 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
612 | - $context['options'][$i]['type'] = 'checkbox'; |
|
613 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
614 | - $context['options'][$i]['type'] = 'number'; |
|
615 | - elseif ($setting['type'] == 'string') |
|
616 | - $context['options'][$i]['type'] = 'text'; |
|
623 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
624 | + $context['options'][$i]['type'] = 'checkbox'; |
|
625 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
626 | + $context['options'][$i]['type'] = 'number'; |
|
627 | + } elseif ($setting['type'] == 'string') { |
|
628 | + $context['options'][$i]['type'] = 'text'; |
|
629 | + } |
|
617 | 630 | |
618 | - if (isset($setting['options'])) |
|
619 | - $context['options'][$i]['type'] = 'list'; |
|
631 | + if (isset($setting['options'])) { |
|
632 | + $context['options'][$i]['type'] = 'list'; |
|
633 | + } |
|
620 | 634 | |
621 | 635 | $context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']]; |
622 | 636 | } |
@@ -641,8 +655,9 @@ discard block |
||
641 | 655 | { |
642 | 656 | global $txt, $context, $settings, $modSettings, $smcFunc; |
643 | 657 | |
644 | - if (empty($_GET['th']) && empty($_GET['id'])) |
|
645 | - return ThemeAdmin(); |
|
658 | + if (empty($_GET['th']) && empty($_GET['id'])) { |
|
659 | + return ThemeAdmin(); |
|
660 | + } |
|
646 | 661 | |
647 | 662 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
648 | 663 | |
@@ -653,8 +668,9 @@ discard block |
||
653 | 668 | isAllowedTo('admin_forum'); |
654 | 669 | |
655 | 670 | // Validate inputs/user. |
656 | - if (empty($_GET['th'])) |
|
657 | - fatal_lang_error('no_theme', false); |
|
671 | + if (empty($_GET['th'])) { |
|
672 | + fatal_lang_error('no_theme', false); |
|
673 | + } |
|
658 | 674 | |
659 | 675 | // Fetch the smiley sets... |
660 | 676 | $sets = explode(',', 'none,' . $modSettings['smiley_sets_known']); |
@@ -662,8 +678,9 @@ discard block |
||
662 | 678 | $context['smiley_sets'] = array( |
663 | 679 | '' => $txt['smileys_no_default'] |
664 | 680 | ); |
665 | - foreach ($sets as $i => $set) |
|
666 | - $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
681 | + foreach ($sets as $i => $set) { |
|
682 | + $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
683 | + } |
|
667 | 684 | |
668 | 685 | $old_id = $settings['theme_id']; |
669 | 686 | $old_settings = $settings; |
@@ -688,8 +705,9 @@ discard block |
||
688 | 705 | if (file_exists($settings['theme_dir'] . '/index.template.php')) |
689 | 706 | { |
690 | 707 | $file_contents = implode('', file($settings['theme_dir'] . '/index.template.php')); |
691 | - if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) |
|
692 | - eval('global $settings;' . $matches[0]); |
|
708 | + if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) { |
|
709 | + eval('global $settings;' . $matches[0]); |
|
710 | + } |
|
693 | 711 | } |
694 | 712 | |
695 | 713 | // Submitting! |
@@ -698,37 +716,45 @@ discard block |
||
698 | 716 | checkSession(); |
699 | 717 | validateToken('admin-sts'); |
700 | 718 | |
701 | - if (empty($_POST['options'])) |
|
702 | - $_POST['options'] = array(); |
|
703 | - if (empty($_POST['default_options'])) |
|
704 | - $_POST['default_options'] = array(); |
|
719 | + if (empty($_POST['options'])) { |
|
720 | + $_POST['options'] = array(); |
|
721 | + } |
|
722 | + if (empty($_POST['default_options'])) { |
|
723 | + $_POST['default_options'] = array(); |
|
724 | + } |
|
705 | 725 | |
706 | 726 | // Make sure items are cast correctly. |
707 | 727 | foreach ($context['theme_settings'] as $item) |
708 | 728 | { |
709 | 729 | // Disregard this item if this is just a separator. |
710 | - if (!is_array($item)) |
|
711 | - continue; |
|
730 | + if (!is_array($item)) { |
|
731 | + continue; |
|
732 | + } |
|
712 | 733 | |
713 | 734 | foreach (array('options', 'default_options') as $option) |
714 | 735 | { |
715 | - if (!isset($_POST[$option][$item['id']])) |
|
716 | - continue; |
|
736 | + if (!isset($_POST[$option][$item['id']])) { |
|
737 | + continue; |
|
738 | + } |
|
717 | 739 | // Checkbox. |
718 | - elseif (empty($item['type'])) |
|
719 | - $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
740 | + elseif (empty($item['type'])) { |
|
741 | + $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
742 | + } |
|
720 | 743 | // Number |
721 | - elseif ($item['type'] == 'number') |
|
722 | - $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
744 | + elseif ($item['type'] == 'number') { |
|
745 | + $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
746 | + } |
|
723 | 747 | } |
724 | 748 | } |
725 | 749 | |
726 | 750 | // Set up the sql query. |
727 | 751 | $inserts = array(); |
728 | - foreach ($_POST['options'] as $opt => $val) |
|
729 | - $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
730 | - foreach ($_POST['default_options'] as $opt => $val) |
|
731 | - $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
752 | + foreach ($_POST['options'] as $opt => $val) { |
|
753 | + $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
754 | + } |
|
755 | + foreach ($_POST['default_options'] as $opt => $val) { |
|
756 | + $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
757 | + } |
|
732 | 758 | // If we're actually inserting something.. |
733 | 759 | if (!empty($inserts)) |
734 | 760 | { |
@@ -754,8 +780,9 @@ discard block |
||
754 | 780 | |
755 | 781 | foreach ($settings as $setting => $dummy) |
756 | 782 | { |
757 | - if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) |
|
758 | - $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
783 | + if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) { |
|
784 | + $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
785 | + } |
|
759 | 786 | } |
760 | 787 | |
761 | 788 | $context['settings'] = $context['theme_settings']; |
@@ -764,18 +791,21 @@ discard block |
||
764 | 791 | foreach ($context['settings'] as $i => $setting) |
765 | 792 | { |
766 | 793 | // Separators are dummies, so leave them alone. |
767 | - if (!is_array($setting)) |
|
768 | - continue; |
|
794 | + if (!is_array($setting)) { |
|
795 | + continue; |
|
796 | + } |
|
769 | 797 | |
770 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
771 | - $context['settings'][$i]['type'] = 'checkbox'; |
|
772 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
773 | - $context['settings'][$i]['type'] = 'number'; |
|
774 | - elseif ($setting['type'] == 'string') |
|
775 | - $context['settings'][$i]['type'] = 'text'; |
|
798 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
799 | + $context['settings'][$i]['type'] = 'checkbox'; |
|
800 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
801 | + $context['settings'][$i]['type'] = 'number'; |
|
802 | + } elseif ($setting['type'] == 'string') { |
|
803 | + $context['settings'][$i]['type'] = 'text'; |
|
804 | + } |
|
776 | 805 | |
777 | - if (isset($setting['options'])) |
|
778 | - $context['settings'][$i]['type'] = 'list'; |
|
806 | + if (isset($setting['options'])) { |
|
807 | + $context['settings'][$i]['type'] = 'list'; |
|
808 | + } |
|
779 | 809 | |
780 | 810 | $context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']]; |
781 | 811 | } |
@@ -828,8 +858,9 @@ discard block |
||
828 | 858 | $themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
829 | 859 | |
830 | 860 | // You can't delete the default theme! |
831 | - if ($themeID == 1) |
|
832 | - fatal_lang_error('no_access', false); |
|
861 | + if ($themeID == 1) { |
|
862 | + fatal_lang_error('no_access', false); |
|
863 | + } |
|
833 | 864 | |
834 | 865 | $theme_info = get_single_theme($themeID); |
835 | 866 | |
@@ -837,8 +868,9 @@ discard block |
||
837 | 868 | remove_theme($themeID); |
838 | 869 | |
839 | 870 | // And remove all its files and folders too. |
840 | - if (!empty($theme_info) && !empty($theme_info['theme_dir'])) |
|
841 | - remove_dir($theme_info['theme_dir']); |
|
871 | + if (!empty($theme_info) && !empty($theme_info['theme_dir'])) { |
|
872 | + remove_dir($theme_info['theme_dir']); |
|
873 | + } |
|
842 | 874 | |
843 | 875 | // Go back to the list page. |
844 | 876 | redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=removing'); |
@@ -863,12 +895,14 @@ discard block |
||
863 | 895 | $enableThemes = explode(',', $modSettings['enableThemes']); |
864 | 896 | |
865 | 897 | // Are we disabling it? |
866 | - if (isset($_GET['disabled'])) |
|
867 | - $enableThemes = array_diff($enableThemes, array($themeID)); |
|
898 | + if (isset($_GET['disabled'])) { |
|
899 | + $enableThemes = array_diff($enableThemes, array($themeID)); |
|
900 | + } |
|
868 | 901 | |
869 | 902 | // Nope? then enable it! |
870 | - else |
|
871 | - $enableThemes[] = (string) $themeID; |
|
903 | + else { |
|
904 | + $enableThemes[] = (string) $themeID; |
|
905 | + } |
|
872 | 906 | |
873 | 907 | // Update the setting. |
874 | 908 | $enableThemes = strtr(implode(',', $enableThemes), array(',,' => ',')); |
@@ -903,18 +937,21 @@ discard block |
||
903 | 937 | |
904 | 938 | $_SESSION['id_theme'] = 0; |
905 | 939 | |
906 | - if (isset($_GET['id'])) |
|
907 | - $_GET['th'] = $_GET['id']; |
|
940 | + if (isset($_GET['id'])) { |
|
941 | + $_GET['th'] = $_GET['id']; |
|
942 | + } |
|
908 | 943 | |
909 | 944 | // Saving a variant cause JS doesn't work - pretend it did ;) |
910 | 945 | if (isset($_POST['save'])) |
911 | 946 | { |
912 | 947 | // Which theme? |
913 | - foreach ($_POST['save'] as $k => $v) |
|
914 | - $_GET['th'] = (int) $k; |
|
948 | + foreach ($_POST['save'] as $k => $v) { |
|
949 | + $_GET['th'] = (int) $k; |
|
950 | + } |
|
915 | 951 | |
916 | - if (isset($_POST['vrt'][$k])) |
|
917 | - $_GET['vrt'] = $_POST['vrt'][$k]; |
|
952 | + if (isset($_POST['vrt'][$k])) { |
|
953 | + $_GET['vrt'] = $_POST['vrt'][$k]; |
|
954 | + } |
|
918 | 955 | } |
919 | 956 | |
920 | 957 | // Have we made a decision, or are we just browsing? |
@@ -992,8 +1029,9 @@ discard block |
||
992 | 1029 | else |
993 | 1030 | { |
994 | 1031 | // The forum's default theme is always 0 and we |
995 | - if (isset($_GET['th']) && $_GET['th'] == 0) |
|
996 | - $_GET['th'] = $modSettings['theme_guests']; |
|
1032 | + if (isset($_GET['th']) && $_GET['th'] == 0) { |
|
1033 | + $_GET['th'] = $modSettings['theme_guests']; |
|
1034 | + } |
|
997 | 1035 | |
998 | 1036 | updateMemberData((int) $_REQUEST['u'], array('id_theme' => (int) $_GET['th'])); |
999 | 1037 | |
@@ -1007,8 +1045,9 @@ discard block |
||
1007 | 1045 | ); |
1008 | 1046 | cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90); |
1009 | 1047 | |
1010 | - if ($user_info['id'] == $_REQUEST['u']) |
|
1011 | - $_SESSION['id_variant'] = 0; |
|
1048 | + if ($user_info['id'] == $_REQUEST['u']) { |
|
1049 | + $_SESSION['id_variant'] = 0; |
|
1050 | + } |
|
1012 | 1051 | } |
1013 | 1052 | |
1014 | 1053 | redirectexit('action=profile;u=' . (int) $_REQUEST['u'] . ';area=theme'); |
@@ -1077,12 +1116,13 @@ discard block |
||
1077 | 1116 | ); |
1078 | 1117 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1079 | 1118 | { |
1080 | - if (!isset($context['available_themes'][$row['id_theme']])) |
|
1081 | - $context['available_themes'][$row['id_theme']] = array( |
|
1119 | + if (!isset($context['available_themes'][$row['id_theme']])) { |
|
1120 | + $context['available_themes'][$row['id_theme']] = array( |
|
1082 | 1121 | 'id' => $row['id_theme'], |
1083 | 1122 | 'selected' => $context['current_theme'] == $row['id_theme'], |
1084 | 1123 | 'num_users' => 0 |
1085 | 1124 | ); |
1125 | + } |
|
1086 | 1126 | $context['available_themes'][$row['id_theme']][$row['variable']] = $row['value']; |
1087 | 1127 | } |
1088 | 1128 | $smcFunc['db_free_result']($request); |
@@ -1095,9 +1135,9 @@ discard block |
||
1095 | 1135 | 'num_users' => 0 |
1096 | 1136 | ); |
1097 | 1137 | $guest_theme = 0; |
1138 | + } else { |
|
1139 | + $guest_theme = $modSettings['theme_guests']; |
|
1098 | 1140 | } |
1099 | - else |
|
1100 | - $guest_theme = $modSettings['theme_guests']; |
|
1101 | 1141 | |
1102 | 1142 | $request = $smcFunc['db_query']('', ' |
1103 | 1143 | SELECT id_theme, COUNT(*) AS the_count |
@@ -1110,15 +1150,17 @@ discard block |
||
1110 | 1150 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1111 | 1151 | { |
1112 | 1152 | // Figure out which theme it is they are REALLY using. |
1113 | - if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) |
|
1114 | - $row['id_theme'] = $guest_theme; |
|
1115 | - elseif (empty($modSettings['theme_allow'])) |
|
1116 | - $row['id_theme'] = $guest_theme; |
|
1153 | + if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) { |
|
1154 | + $row['id_theme'] = $guest_theme; |
|
1155 | + } elseif (empty($modSettings['theme_allow'])) { |
|
1156 | + $row['id_theme'] = $guest_theme; |
|
1157 | + } |
|
1117 | 1158 | |
1118 | - if (isset($context['available_themes'][$row['id_theme']])) |
|
1119 | - $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
1120 | - else |
|
1121 | - $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
1159 | + if (isset($context['available_themes'][$row['id_theme']])) { |
|
1160 | + $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
1161 | + } else { |
|
1162 | + $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
1163 | + } |
|
1122 | 1164 | } |
1123 | 1165 | $smcFunc['db_free_result']($request); |
1124 | 1166 | |
@@ -1137,8 +1179,9 @@ discard block |
||
1137 | 1179 | 'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1), |
1138 | 1180 | ) |
1139 | 1181 | ); |
1140 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1141 | - $variant_preferences[$row['id_theme']] = $row['value']; |
|
1182 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1183 | + $variant_preferences[$row['id_theme']] = $row['value']; |
|
1184 | + } |
|
1142 | 1185 | $smcFunc['db_free_result']($request); |
1143 | 1186 | } |
1144 | 1187 | |
@@ -1149,17 +1192,18 @@ discard block |
||
1149 | 1192 | foreach ($context['available_themes'] as $id_theme => $theme_data) |
1150 | 1193 | { |
1151 | 1194 | // Don't try to load the forum or board default theme's data... it doesn't have any! |
1152 | - if ($id_theme == 0) |
|
1153 | - continue; |
|
1195 | + if ($id_theme == 0) { |
|
1196 | + continue; |
|
1197 | + } |
|
1154 | 1198 | |
1155 | 1199 | // The thumbnail needs the correct path. |
1156 | 1200 | $settings['images_url'] = &$theme_data['images_url']; |
1157 | 1201 | |
1158 | - if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) |
|
1159 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
1160 | - elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) |
|
1161 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
1162 | - else |
|
1202 | + if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) { |
|
1203 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
1204 | + } elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) { |
|
1205 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
1206 | + } else |
|
1163 | 1207 | { |
1164 | 1208 | $txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png'; |
1165 | 1209 | $txt['theme_description'] = ''; |
@@ -1184,15 +1228,17 @@ discard block |
||
1184 | 1228 | loadLanguage('Settings'); |
1185 | 1229 | |
1186 | 1230 | $context['available_themes'][$id_theme]['variants'] = array(); |
1187 | - foreach ($settings['theme_variants'] as $variant) |
|
1188 | - $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
1231 | + foreach ($settings['theme_variants'] as $variant) { |
|
1232 | + $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
1189 | 1233 | 'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant, |
1190 | 1234 | 'thumbnail' => !file_exists($theme_data['theme_dir'] . '/images/thumbnail.png') || file_exists($theme_data['theme_dir'] . '/images/thumbnail_' . $variant . '.png') ? $theme_data['images_url'] . '/thumbnail_' . $variant . '.png' : ($theme_data['images_url'] . '/thumbnail.png'), |
1191 | 1235 | ); |
1236 | + } |
|
1192 | 1237 | |
1193 | 1238 | $context['available_themes'][$id_theme]['selected_variant'] = isset($_GET['vrt']) ? $_GET['vrt'] : (!empty($variant_preferences[$id_theme]) ? $variant_preferences[$id_theme] : (!empty($settings['default_variant']) ? $settings['default_variant'] : $settings['theme_variants'][0])); |
1194 | - if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) |
|
1195 | - $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
1239 | + if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) { |
|
1240 | + $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
1241 | + } |
|
1196 | 1242 | |
1197 | 1243 | $context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']; |
1198 | 1244 | // Allow themes to override the text. |
@@ -1208,8 +1254,9 @@ discard block |
||
1208 | 1254 | // As long as we're not doing the default theme... |
1209 | 1255 | if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0) |
1210 | 1256 | { |
1211 | - if ($guest_theme != 0) |
|
1212 | - $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
1257 | + if ($guest_theme != 0) { |
|
1258 | + $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
1259 | + } |
|
1213 | 1260 | |
1214 | 1261 | $context['available_themes'][0]['id'] = 0; |
1215 | 1262 | $context['available_themes'][0]['name'] = $txt['theme_forum_default']; |
@@ -1258,14 +1305,16 @@ discard block |
||
1258 | 1305 | $action = $smcFunc['htmlspecialchars'](trim($_GET['do'])); |
1259 | 1306 | |
1260 | 1307 | // Got any info from the specific form? |
1261 | - if (!isset($_POST['save_' . $action])) |
|
1262 | - fatal_lang_error('theme_install_no_action', false); |
|
1308 | + if (!isset($_POST['save_' . $action])) { |
|
1309 | + fatal_lang_error('theme_install_no_action', false); |
|
1310 | + } |
|
1263 | 1311 | |
1264 | 1312 | validateToken('admin-t-' . $action); |
1265 | 1313 | |
1266 | 1314 | // Hopefully the themes directory is writable, or we might have a problem. |
1267 | - if (!is_writable($themedir)) |
|
1268 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
1315 | + if (!is_writable($themedir)) { |
|
1316 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
1317 | + } |
|
1269 | 1318 | |
1270 | 1319 | // Call the function and handle the result. |
1271 | 1320 | $result = $subActions[$action](); |
@@ -1280,9 +1329,10 @@ discard block |
||
1280 | 1329 | } |
1281 | 1330 | |
1282 | 1331 | // Nope, show a nice error. |
1283 | - else |
|
1284 | - fatal_lang_error('theme_install_no_action', false); |
|
1285 | -} |
|
1332 | + else { |
|
1333 | + fatal_lang_error('theme_install_no_action', false); |
|
1334 | + } |
|
1335 | + } |
|
1286 | 1336 | |
1287 | 1337 | /** |
1288 | 1338 | * Installs a theme from a theme package. |
@@ -1298,8 +1348,9 @@ discard block |
||
1298 | 1348 | $dirtemp = $themedir . '/temp'; |
1299 | 1349 | |
1300 | 1350 | // Make sure the temp dir doesn't already exist |
1301 | - if (file_exists($dirtemp)) |
|
1302 | - remove_dir($dirtemp); |
|
1351 | + if (file_exists($dirtemp)) { |
|
1352 | + remove_dir($dirtemp); |
|
1353 | + } |
|
1303 | 1354 | |
1304 | 1355 | // Create the temp dir. |
1305 | 1356 | mkdir($dirtemp, 0777); |
@@ -1311,17 +1362,20 @@ discard block |
||
1311 | 1362 | smf_chmod($dirtemp, '0755'); |
1312 | 1363 | |
1313 | 1364 | // How about now? |
1314 | - if (!is_writable($dirtemp)) |
|
1315 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
1365 | + if (!is_writable($dirtemp)) { |
|
1366 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
1367 | + } |
|
1316 | 1368 | } |
1317 | 1369 | |
1318 | 1370 | // This happens when the admin session is gone and the user has to login again. |
1319 | - if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) |
|
1320 | - redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
1371 | + if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) { |
|
1372 | + redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
1373 | + } |
|
1321 | 1374 | |
1322 | 1375 | // Another error check layer, something went wrong with the upload. |
1323 | - if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) |
|
1324 | - fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
1376 | + if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) { |
|
1377 | + fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
1378 | + } |
|
1325 | 1379 | |
1326 | 1380 | // Get the theme's name. |
1327 | 1381 | $name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME); |
@@ -1352,11 +1406,10 @@ discard block |
||
1352 | 1406 | |
1353 | 1407 | // return all the info. |
1354 | 1408 | return $context['to_install']; |
1409 | + } else { |
|
1410 | + fatal_lang_error('theme_install_error_title', false); |
|
1411 | + } |
|
1355 | 1412 | } |
1356 | - |
|
1357 | - else |
|
1358 | - fatal_lang_error('theme_install_error_title', false); |
|
1359 | -} |
|
1360 | 1413 | |
1361 | 1414 | /** |
1362 | 1415 | * Makes a copy from the default theme, assigns a name for it and installs it. |
@@ -1370,15 +1423,17 @@ discard block |
||
1370 | 1423 | global $forum_version; |
1371 | 1424 | |
1372 | 1425 | // There's gotta be something to work with. |
1373 | - if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) |
|
1374 | - fatal_lang_error('theme_install_error_title', false); |
|
1426 | + if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) { |
|
1427 | + fatal_lang_error('theme_install_error_title', false); |
|
1428 | + } |
|
1375 | 1429 | |
1376 | 1430 | // Get a cleaner version. |
1377 | 1431 | $name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']); |
1378 | 1432 | |
1379 | 1433 | // Is there a theme already named like this? |
1380 | - if (file_exists($themedir . '/' . $name)) |
|
1381 | - fatal_lang_error('theme_install_already_dir', false); |
|
1434 | + if (file_exists($themedir . '/' . $name)) { |
|
1435 | + fatal_lang_error('theme_install_already_dir', false); |
|
1436 | + } |
|
1382 | 1437 | |
1383 | 1438 | // This is a brand new theme so set all possible values. |
1384 | 1439 | $context['to_install'] = array( |
@@ -1398,8 +1453,9 @@ discard block |
||
1398 | 1453 | |
1399 | 1454 | // Buy some time. |
1400 | 1455 | @set_time_limit(600); |
1401 | - if (function_exists('apache_reset_timeout')) |
|
1402 | - @apache_reset_timeout(); |
|
1456 | + if (function_exists('apache_reset_timeout')) { |
|
1457 | + @apache_reset_timeout(); |
|
1458 | + } |
|
1403 | 1459 | |
1404 | 1460 | // Create subdirectories for css and javascript files. |
1405 | 1461 | mkdir($context['to_install']['theme_dir'] . '/css', 0777); |
@@ -1435,12 +1491,13 @@ discard block |
||
1435 | 1491 | |
1436 | 1492 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1437 | 1493 | { |
1438 | - if ($row['variable'] == 'theme_templates') |
|
1439 | - $theme_templates = $row['value']; |
|
1440 | - elseif ($row['variable'] == 'theme_layers') |
|
1441 | - $theme_layers = $row['value']; |
|
1442 | - else |
|
1443 | - continue; |
|
1494 | + if ($row['variable'] == 'theme_templates') { |
|
1495 | + $theme_templates = $row['value']; |
|
1496 | + } elseif ($row['variable'] == 'theme_layers') { |
|
1497 | + $theme_layers = $row['value']; |
|
1498 | + } else { |
|
1499 | + continue; |
|
1500 | + } |
|
1444 | 1501 | } |
1445 | 1502 | |
1446 | 1503 | $smcFunc['db_free_result']($request); |
@@ -1499,12 +1556,14 @@ discard block |
||
1499 | 1556 | global $themedir, $themeurl, $context; |
1500 | 1557 | |
1501 | 1558 | // Cannot use the theme dir as a theme dir. |
1502 | - if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) |
|
1503 | - fatal_lang_error('theme_install_invalid_dir', false); |
|
1559 | + if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) { |
|
1560 | + fatal_lang_error('theme_install_invalid_dir', false); |
|
1561 | + } |
|
1504 | 1562 | |
1505 | 1563 | // Check is there is "something" on the dir. |
1506 | - elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) |
|
1507 | - fatal_lang_error('theme_install_error', false); |
|
1564 | + elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) { |
|
1565 | + fatal_lang_error('theme_install_error', false); |
|
1566 | + } |
|
1508 | 1567 | |
1509 | 1568 | $name = basename($_REQUEST['theme_dir']); |
1510 | 1569 | $name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name); |
@@ -1548,24 +1607,27 @@ discard block |
||
1548 | 1607 | } |
1549 | 1608 | |
1550 | 1609 | // Any special layers? |
1551 | - if (isset($settings['catch_action']['layers'])) |
|
1552 | - $context['template_layers'] = $settings['catch_action']['layers']; |
|
1610 | + if (isset($settings['catch_action']['layers'])) { |
|
1611 | + $context['template_layers'] = $settings['catch_action']['layers']; |
|
1612 | + } |
|
1553 | 1613 | |
1554 | 1614 | // Any function to call? |
1555 | 1615 | if (isset($settings['catch_action']['function'])) |
1556 | 1616 | { |
1557 | 1617 | $hook = $settings['catch_action']['function']; |
1558 | 1618 | |
1559 | - if (!isset($settings['catch_action']['filename'])) |
|
1560 | - $settings['catch_action']['filename'] = ''; |
|
1619 | + if (!isset($settings['catch_action']['filename'])) { |
|
1620 | + $settings['catch_action']['filename'] = ''; |
|
1621 | + } |
|
1561 | 1622 | |
1562 | 1623 | add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false); |
1563 | 1624 | call_integration_hook('integrate_wrap_action'); |
1564 | 1625 | } |
1565 | 1626 | // And finally, the main sub template ;). |
1566 | - if (isset($settings['catch_action']['sub_template'])) |
|
1567 | - $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
1568 | -} |
|
1627 | + if (isset($settings['catch_action']['sub_template'])) { |
|
1628 | + $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
1629 | + } |
|
1630 | + } |
|
1569 | 1631 | |
1570 | 1632 | /** |
1571 | 1633 | * Set an option via javascript. |
@@ -1584,12 +1646,14 @@ discard block |
||
1584 | 1646 | checkSession('get'); |
1585 | 1647 | |
1586 | 1648 | // This good-for-nothing pixel is being used to keep the session alive. |
1587 | - if (empty($_GET['var']) || !isset($_GET['val'])) |
|
1588 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
1649 | + if (empty($_GET['var']) || !isset($_GET['val'])) { |
|
1650 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
1651 | + } |
|
1589 | 1652 | |
1590 | 1653 | // Sorry, guests can't go any further than this. |
1591 | - if ($user_info['is_guest'] || $user_info['id'] == 0) |
|
1592 | - obExit(false); |
|
1654 | + if ($user_info['is_guest'] || $user_info['id'] == 0) { |
|
1655 | + obExit(false); |
|
1656 | + } |
|
1593 | 1657 | |
1594 | 1658 | $reservedVars = array( |
1595 | 1659 | 'actual_theme_url', |
@@ -1612,8 +1676,9 @@ discard block |
||
1612 | 1676 | ); |
1613 | 1677 | |
1614 | 1678 | // Can't change reserved vars. |
1615 | - if (in_array(strtolower($_GET['var']), $reservedVars)) |
|
1616 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
1679 | + if (in_array(strtolower($_GET['var']), $reservedVars)) { |
|
1680 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
1681 | + } |
|
1617 | 1682 | |
1618 | 1683 | // Use a specific theme? |
1619 | 1684 | if (isset($_GET['th']) || isset($_GET['id'])) |
@@ -1629,8 +1694,9 @@ discard block |
||
1629 | 1694 | { |
1630 | 1695 | $options['admin_preferences'] = !empty($options['admin_preferences']) ? $smcFunc['json_decode']($options['admin_preferences'], true) : array(); |
1631 | 1696 | // New thingy... |
1632 | - if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) |
|
1633 | - $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
1697 | + if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) { |
|
1698 | + $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
1699 | + } |
|
1634 | 1700 | |
1635 | 1701 | // Change the value to be something nice, |
1636 | 1702 | $_GET['val'] = $smcFunc['json_encode']($options['admin_preferences']); |
@@ -1660,8 +1726,9 @@ discard block |
||
1660 | 1726 | global $context, $scripturl, $boarddir, $smcFunc, $txt; |
1661 | 1727 | |
1662 | 1728 | // @todo Should this be removed? |
1663 | - if (isset($_REQUEST['preview'])) |
|
1664 | - die('die() with fire'); |
|
1729 | + if (isset($_REQUEST['preview'])) { |
|
1730 | + die('die() with fire'); |
|
1731 | + } |
|
1665 | 1732 | |
1666 | 1733 | isAllowedTo('admin_forum'); |
1667 | 1734 | loadTemplate('Themes'); |
@@ -1675,11 +1742,11 @@ discard block |
||
1675 | 1742 | foreach ($context['themes'] as $key => $theme) |
1676 | 1743 | { |
1677 | 1744 | // There has to be a Settings template! |
1678 | - if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) |
|
1679 | - unset($context['themes'][$key]); |
|
1680 | - |
|
1681 | - else |
|
1682 | - $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
1745 | + if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) { |
|
1746 | + unset($context['themes'][$key]); |
|
1747 | + } else { |
|
1748 | + $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
1749 | + } |
|
1683 | 1750 | } |
1684 | 1751 | |
1685 | 1752 | $context['sub_template'] = 'edit_list'; |
@@ -1694,22 +1761,24 @@ discard block |
||
1694 | 1761 | $context['theme_id'] = $currentTheme['id']; |
1695 | 1762 | $context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']); |
1696 | 1763 | |
1697 | - if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) |
|
1698 | - fatal_lang_error('theme_edit_missing', false); |
|
1764 | + if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) { |
|
1765 | + fatal_lang_error('theme_edit_missing', false); |
|
1766 | + } |
|
1699 | 1767 | |
1700 | 1768 | if (!isset($_REQUEST['filename'])) |
1701 | 1769 | { |
1702 | 1770 | if (isset($_GET['directory'])) |
1703 | 1771 | { |
1704 | - if (substr($_GET['directory'], 0, 1) == '.') |
|
1705 | - $_GET['directory'] = ''; |
|
1706 | - else |
|
1772 | + if (substr($_GET['directory'], 0, 1) == '.') { |
|
1773 | + $_GET['directory'] = ''; |
|
1774 | + } else |
|
1707 | 1775 | { |
1708 | 1776 | $_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']); |
1709 | 1777 | |
1710 | 1778 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']); |
1711 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
1712 | - $_GET['directory'] = ''; |
|
1779 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
1780 | + $_GET['directory'] = ''; |
|
1781 | + } |
|
1713 | 1782 | } |
1714 | 1783 | } |
1715 | 1784 | |
@@ -1728,37 +1797,39 @@ discard block |
||
1728 | 1797 | 'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp, |
1729 | 1798 | 'size' => '', |
1730 | 1799 | )); |
1800 | + } else { |
|
1801 | + $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
1731 | 1802 | } |
1732 | - else |
|
1733 | - $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
1734 | 1803 | |
1735 | 1804 | $context['sub_template'] = 'edit_browse'; |
1736 | 1805 | |
1737 | 1806 | return; |
1738 | - } |
|
1739 | - else |
|
1807 | + } else |
|
1740 | 1808 | { |
1741 | - if (substr($_REQUEST['filename'], 0, 1) == '.') |
|
1742 | - $_REQUEST['filename'] = ''; |
|
1743 | - else |
|
1809 | + if (substr($_REQUEST['filename'], 0, 1) == '.') { |
|
1810 | + $_REQUEST['filename'] = ''; |
|
1811 | + } else |
|
1744 | 1812 | { |
1745 | 1813 | $_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']); |
1746 | 1814 | |
1747 | 1815 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
1748 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
1749 | - $_REQUEST['filename'] = ''; |
|
1816 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
1817 | + $_REQUEST['filename'] = ''; |
|
1818 | + } |
|
1750 | 1819 | } |
1751 | 1820 | |
1752 | - if (empty($_REQUEST['filename'])) |
|
1753 | - fatal_lang_error('theme_edit_missing', false); |
|
1821 | + if (empty($_REQUEST['filename'])) { |
|
1822 | + fatal_lang_error('theme_edit_missing', false); |
|
1823 | + } |
|
1754 | 1824 | } |
1755 | 1825 | |
1756 | 1826 | if (isset($_POST['save'])) |
1757 | 1827 | { |
1758 | 1828 | if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true) |
1759 | 1829 | { |
1760 | - if (is_array($_POST['entire_file'])) |
|
1761 | - $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
1830 | + if (is_array($_POST['entire_file'])) { |
|
1831 | + $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
1832 | + } |
|
1762 | 1833 | |
1763 | 1834 | $_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', ' ' => "\t"))); |
1764 | 1835 | |
@@ -1770,10 +1841,11 @@ discard block |
||
1770 | 1841 | fclose($fp); |
1771 | 1842 | |
1772 | 1843 | $error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php'); |
1773 | - if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) |
|
1774 | - $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
1775 | - else |
|
1776 | - unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
1844 | + if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) { |
|
1845 | + $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
1846 | + } else { |
|
1847 | + unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
1848 | + } |
|
1777 | 1849 | } |
1778 | 1850 | |
1779 | 1851 | if (!isset($error_file)) |
@@ -1794,10 +1866,11 @@ discard block |
||
1794 | 1866 | $context['sub_template'] = 'edit_file'; |
1795 | 1867 | |
1796 | 1868 | // Recycle the submitted data. |
1797 | - if (is_array($_POST['entire_file'])) |
|
1798 | - $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
1799 | - else |
|
1800 | - $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
1869 | + if (is_array($_POST['entire_file'])) { |
|
1870 | + $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
1871 | + } else { |
|
1872 | + $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
1873 | + } |
|
1801 | 1874 | |
1802 | 1875 | $context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']); |
1803 | 1876 | |
@@ -1820,17 +1893,17 @@ discard block |
||
1820 | 1893 | $context['sub_template'] = 'edit_style'; |
1821 | 1894 | |
1822 | 1895 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => ' '))); |
1823 | - } |
|
1824 | - elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
1896 | + } elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
1825 | 1897 | { |
1826 | 1898 | $context['sub_template'] = 'edit_template'; |
1827 | 1899 | |
1828 | - if (!isset($error_file)) |
|
1829 | - $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
1830 | - else |
|
1900 | + if (!isset($error_file)) { |
|
1901 | + $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
1902 | + } else |
|
1831 | 1903 | { |
1832 | - if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) |
|
1833 | - $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
1904 | + if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) { |
|
1905 | + $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
1906 | + } |
|
1834 | 1907 | $file_data = file($error_file); |
1835 | 1908 | unlink($error_file); |
1836 | 1909 | } |
@@ -1844,8 +1917,9 @@ discard block |
||
1844 | 1917 | // Try to format the functions a little nicer... |
1845 | 1918 | $context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n"; |
1846 | 1919 | |
1847 | - if (empty($context['file_parts'][$j]['lines'])) |
|
1848 | - unset($context['file_parts'][$j]); |
|
1920 | + if (empty($context['file_parts'][$j]['lines'])) { |
|
1921 | + unset($context['file_parts'][$j]); |
|
1922 | + } |
|
1849 | 1923 | $context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => ''); |
1850 | 1924 | } |
1851 | 1925 | |
@@ -1854,8 +1928,7 @@ discard block |
||
1854 | 1928 | } |
1855 | 1929 | |
1856 | 1930 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => ' '))); |
1857 | - } |
|
1858 | - else |
|
1931 | + } else |
|
1859 | 1932 | { |
1860 | 1933 | $context['sub_template'] = 'edit_file'; |
1861 | 1934 | |
@@ -1881,8 +1954,9 @@ discard block |
||
1881 | 1954 | |
1882 | 1955 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
1883 | 1956 | |
1884 | - if (empty($_GET['th'])) |
|
1885 | - fatal_lang_error('theme_install_invalid_id'); |
|
1957 | + if (empty($_GET['th'])) { |
|
1958 | + fatal_lang_error('theme_install_invalid_id'); |
|
1959 | + } |
|
1886 | 1960 | |
1887 | 1961 | // Get the theme info. |
1888 | 1962 | $theme = get_single_theme($_GET['th']); |
@@ -1890,25 +1964,24 @@ discard block |
||
1890 | 1964 | |
1891 | 1965 | if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0) |
1892 | 1966 | { |
1893 | - if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) |
|
1894 | - $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
1895 | - |
|
1896 | - else |
|
1897 | - fatal_lang_error('no_access', false); |
|
1967 | + if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) { |
|
1968 | + $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
1969 | + } else { |
|
1970 | + fatal_lang_error('no_access', false); |
|
1971 | + } |
|
1898 | 1972 | |
1899 | 1973 | $fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w'); |
1900 | 1974 | fwrite($fp, file_get_contents($filename)); |
1901 | 1975 | fclose($fp); |
1902 | 1976 | |
1903 | 1977 | redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy'); |
1904 | - } |
|
1905 | - elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
1978 | + } elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
1906 | 1979 | { |
1907 | - if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) |
|
1908 | - $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
1909 | - |
|
1910 | - else |
|
1911 | - fatal_lang_error('no_access', false); |
|
1980 | + if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) { |
|
1981 | + $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
1982 | + } else { |
|
1983 | + fatal_lang_error('no_access', false); |
|
1984 | + } |
|
1912 | 1985 | |
1913 | 1986 | $fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w'); |
1914 | 1987 | fwrite($fp, file_get_contents($filename)); |
@@ -1923,16 +1996,18 @@ discard block |
||
1923 | 1996 | $dir = dir($settings['default_theme_dir']); |
1924 | 1997 | while ($entry = $dir->read()) |
1925 | 1998 | { |
1926 | - if (substr($entry, -13) == '.template.php') |
|
1927 | - $templates[] = substr($entry, 0, -13); |
|
1999 | + if (substr($entry, -13) == '.template.php') { |
|
2000 | + $templates[] = substr($entry, 0, -13); |
|
2001 | + } |
|
1928 | 2002 | } |
1929 | 2003 | $dir->close(); |
1930 | 2004 | |
1931 | 2005 | $dir = dir($settings['default_theme_dir'] . '/languages'); |
1932 | 2006 | while ($entry = $dir->read()) |
1933 | 2007 | { |
1934 | - if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) |
|
1935 | - $lang_files[] = $matches[1]; |
|
2008 | + if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) { |
|
2009 | + $lang_files[] = $matches[1]; |
|
2010 | + } |
|
1936 | 2011 | } |
1937 | 2012 | $dir->close(); |
1938 | 2013 | |
@@ -1940,21 +2015,23 @@ discard block |
||
1940 | 2015 | natcasesort($lang_files); |
1941 | 2016 | |
1942 | 2017 | $context['available_templates'] = array(); |
1943 | - foreach ($templates as $template) |
|
1944 | - $context['available_templates'][$template] = array( |
|
2018 | + foreach ($templates as $template) { |
|
2019 | + $context['available_templates'][$template] = array( |
|
1945 | 2020 | 'filename' => $template . '.template.php', |
1946 | 2021 | 'value' => $template, |
1947 | 2022 | 'already_exists' => false, |
1948 | 2023 | 'can_copy' => is_writable($theme['theme_dir']), |
1949 | 2024 | ); |
2025 | + } |
|
1950 | 2026 | $context['available_language_files'] = array(); |
1951 | - foreach ($lang_files as $file) |
|
1952 | - $context['available_language_files'][$file] = array( |
|
2027 | + foreach ($lang_files as $file) { |
|
2028 | + $context['available_language_files'][$file] = array( |
|
1953 | 2029 | 'filename' => $file . '.php', |
1954 | 2030 | 'value' => $file, |
1955 | 2031 | 'already_exists' => false, |
1956 | 2032 | 'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']), |
1957 | 2033 | ); |
2034 | + } |
|
1958 | 2035 | |
1959 | 2036 | $dir = dir($theme['theme_dir']); |
1960 | 2037 | while ($entry = $dir->read()) |
@@ -16,8 +16,9 @@ discard block |
||
16 | 16 | |
17 | 17 | // Start things rolling by getting SMF alive... |
18 | 18 | $ssi_guest_access = true; |
19 | -if (!file_exists(dirname(__FILE__) . '/SSI.php')) |
|
19 | +if (!file_exists(dirname(__FILE__) . '/SSI.php')) { |
|
20 | 20 | die('Cannot find SSI.php'); |
21 | +} |
|
21 | 22 | |
22 | 23 | require_once(dirname(__FILE__) . '/SSI.php'); |
23 | 24 | require_once($sourcedir . '/ManagePaid.php'); |
@@ -35,20 +36,22 @@ discard block |
||
35 | 36 | } |
36 | 37 | |
37 | 38 | // I assume we're even active? |
38 | -if (empty($modSettings['paid_enabled'])) |
|
39 | +if (empty($modSettings['paid_enabled'])) { |
|
39 | 40 | exit; |
41 | +} |
|
40 | 42 | |
41 | 43 | // If we have some custom people who find out about problems load them here. |
42 | 44 | $notify_users = array(); |
43 | 45 | if (!empty($modSettings['paid_email_to'])) |
44 | 46 | { |
45 | - foreach (explode(',', $modSettings['paid_email_to']) as $email) |
|
46 | - $notify_users[] = array( |
|
47 | + foreach (explode(',', $modSettings['paid_email_to']) as $email) { |
|
48 | + $notify_users[] = array( |
|
47 | 49 | 'email' => $email, |
48 | 50 | 'name' => $txt['who_member'], |
49 | 51 | 'id' => 0, |
50 | 52 | ); |
51 | -} |
|
53 | + } |
|
54 | + } |
|
52 | 55 | |
53 | 56 | // We need to see whether we can find the correct payment gateway, |
54 | 57 | // we'll going to go through all our gateway scripts and find out |
@@ -65,8 +68,9 @@ discard block |
||
65 | 68 | } |
66 | 69 | } |
67 | 70 | |
68 | -if (empty($txnType)) |
|
71 | +if (empty($txnType)) { |
|
69 | 72 | generateSubscriptionError($txt['paid_unknown_transaction_type']); |
73 | +} |
|
70 | 74 | |
71 | 75 | // Get the subscription and member ID amoungst others... |
72 | 76 | @list($subscription_id, $member_id) = $gatewayClass->precheck(); |
@@ -76,8 +80,9 @@ discard block |
||
76 | 80 | $member_id = (int) $member_id; |
77 | 81 | |
78 | 82 | // This would be bad... |
79 | -if (empty($member_id)) |
|
83 | +if (empty($member_id)) { |
|
80 | 84 | generateSubscriptionError($txt['paid_empty_member']); |
85 | +} |
|
81 | 86 | |
82 | 87 | // Verify the member. |
83 | 88 | $request = $smcFunc['db_query']('', ' |
@@ -89,8 +94,9 @@ discard block |
||
89 | 94 | ) |
90 | 95 | ); |
91 | 96 | // Didn't find them? |
92 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
97 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
93 | 98 | generateSubscriptionError(sprintf($txt['paid_could_not_find_member'], $member_id)); |
99 | +} |
|
94 | 100 | $member_info = $smcFunc['db_fetch_assoc']($request); |
95 | 101 | $smcFunc['db_free_result']($request); |
96 | 102 | |
@@ -105,8 +111,9 @@ discard block |
||
105 | 111 | ); |
106 | 112 | |
107 | 113 | // Didn't find it? |
108 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
114 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
109 | 115 | generateSubscriptionError(sprintf($txt['paid_count_not_find_subscription'], $member_id, $subscription_id)); |
116 | +} |
|
110 | 117 | |
111 | 118 | $subscription_info = $smcFunc['db_fetch_assoc']($request); |
112 | 119 | $smcFunc['db_free_result']($request); |
@@ -123,8 +130,9 @@ discard block |
||
123 | 130 | 'current_member' => $member_id, |
124 | 131 | ) |
125 | 132 | ); |
126 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
133 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
127 | 134 | generateSubscriptionError(sprintf($txt['paid_count_not_find_subscription_log'], $member_id, $subscription_id)); |
135 | +} |
|
128 | 136 | $subscription_info += $smcFunc['db_fetch_assoc']($request); |
129 | 137 | $smcFunc['db_free_result']($request); |
130 | 138 | |
@@ -139,8 +147,7 @@ discard block |
||
139 | 147 | removeSubscription($subscription_id, $member_id); |
140 | 148 | $subscription_act = time(); |
141 | 149 | $status = 0; |
142 | - } |
|
143 | - else |
|
150 | + } else |
|
144 | 151 | { |
145 | 152 | loadSubscriptions(); |
146 | 153 | $subscription_act = $subscription_info['end_time'] - $context['subscriptions'][$subscription_id]['num_length']; |
@@ -188,16 +195,18 @@ discard block |
||
188 | 195 | if (!$gatewayClass->isSubscription()) |
189 | 196 | { |
190 | 197 | $real_details = $smcFunc['json_decode']($subscription_info['pending_details'], true); |
191 | - if (empty($real_details)) |
|
192 | - generateSubscriptionError(sprintf($txt['paid_count_not_find_outstanding_payment'], $member_id, $subscription_id)); |
|
198 | + if (empty($real_details)) { |
|
199 | + generateSubscriptionError(sprintf($txt['paid_count_not_find_outstanding_payment'], $member_id, $subscription_id)); |
|
200 | + } |
|
193 | 201 | |
194 | 202 | // Now we just try to find anything pending. |
195 | 203 | // We don't really care which it is as security happens later. |
196 | 204 | foreach ($real_details as $id => $detail) |
197 | 205 | { |
198 | 206 | unset($real_details[$id]); |
199 | - if ($detail[3] == 'payback' && $subscription_info['payments_pending']) |
|
200 | - $subscription_info['payments_pending']--; |
|
207 | + if ($detail[3] == 'payback' && $subscription_info['payments_pending']) { |
|
208 | + $subscription_info['payments_pending']--; |
|
209 | + } |
|
201 | 210 | break; |
202 | 211 | } |
203 | 212 | |
@@ -223,10 +232,11 @@ discard block |
||
223 | 232 | // This is a little harder, can we find the right duration? |
224 | 233 | foreach ($cost as $duration => $value) |
225 | 234 | { |
226 | - if ($duration == 'fixed') |
|
227 | - continue; |
|
228 | - elseif ((float) $value == (float) $total_cost) |
|
229 | - $found_duration = strtoupper(substr($duration, 0, 1)); |
|
235 | + if ($duration == 'fixed') { |
|
236 | + continue; |
|
237 | + } elseif ((float) $value == (float) $total_cost) { |
|
238 | + $found_duration = strtoupper(substr($duration, 0, 1)); |
|
239 | + } |
|
230 | 240 | } |
231 | 241 | |
232 | 242 | // If we have the duration then we're done. |
@@ -235,8 +245,7 @@ discard block |
||
235 | 245 | $notify = true; |
236 | 246 | addSubscription($subscription_id, $member_id, $found_duration); |
237 | 247 | } |
238 | - } |
|
239 | - else |
|
248 | + } else |
|
240 | 249 | { |
241 | 250 | $actual_cost = $cost['fixed']; |
242 | 251 | |
@@ -268,10 +277,10 @@ discard block |
||
268 | 277 | // Maybe they're cancelling. Some subscriptions may require actively doing something, but PayPal doesn't, for example. |
269 | 278 | elseif ($gatewayClass->isCancellation()) |
270 | 279 | { |
271 | - if (method_exists($gatewayClass, 'performCancel')) |
|
272 | - $gatewayClass->performCancel($subscription_id, $member_id, $subscription_info); |
|
273 | -} |
|
274 | -else |
|
280 | + if (method_exists($gatewayClass, 'performCancel')) { |
|
281 | + $gatewayClass->performCancel($subscription_id, $member_id, $subscription_info); |
|
282 | + } |
|
283 | + } else |
|
275 | 284 | { |
276 | 285 | // Some other "valid" transaction such as: |
277 | 286 | // |
@@ -308,8 +317,9 @@ discard block |
||
308 | 317 | // Maybe we can try to give them the post data? |
309 | 318 | if (!empty($_POST)) |
310 | 319 | { |
311 | - foreach ($_POST as $key => $val) |
|
312 | - $text .= '<br>' . $smcFunc['htmlspecialchars']($key) . ': ' . $smcFunc['htmlspecialchars']($val); |
|
320 | + foreach ($_POST as $key => $val) { |
|
321 | + $text .= '<br>' . $smcFunc['htmlspecialchars']($key) . ': ' . $smcFunc['htmlspecialchars']($val); |
|
322 | + } |
|
313 | 323 | } |
314 | 324 | |
315 | 325 | // Then just log and die. |
@@ -142,7 +142,7 @@ |
||
142 | 142 | foreach ($board['children'] as $child) |
143 | 143 | { |
144 | 144 | if (!$child['is_redirect']) |
145 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
145 | + $child['link'] = '' . ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
146 | 146 | else |
147 | 147 | $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
148 | 148 |
@@ -67,8 +67,9 @@ discard block |
||
67 | 67 | foreach ($context['categories'] as $category) |
68 | 68 | { |
69 | 69 | // If theres no parent boards we can see, avoid showing an empty category (unless its collapsed) |
70 | - if (empty($category['boards']) && !$category['is_collapsed']) |
|
71 | - continue; |
|
70 | + if (empty($category['boards']) && !$category['is_collapsed']) { |
|
71 | + continue; |
|
72 | + } |
|
72 | 73 | |
73 | 74 | echo ' |
74 | 75 | <div class="main_container"> |
@@ -76,9 +77,10 @@ discard block |
||
76 | 77 | <h3 class="catbg">'; |
77 | 78 | |
78 | 79 | // If this category even can collapse, show a link to collapse it. |
79 | - if ($category['can_collapse']) |
|
80 | - echo ' |
|
80 | + if ($category['can_collapse']) { |
|
81 | + echo ' |
|
81 | 82 | <span id="category_', $category['id'], '_upshrink" class="', $category['is_collapsed'] ? 'toggle_down' : 'toggle_up', ' floatright" data-collapsed="', (int) $category['is_collapsed'], '" title="', !$category['is_collapsed'] ? $txt['hide_category'] : $txt['show_category'], '" style="display: none;"></span>'; |
83 | + } |
|
82 | 84 | |
83 | 85 | echo ' |
84 | 86 | ', $category['link'], ' |
@@ -105,17 +107,19 @@ discard block |
||
105 | 107 | </a>'; |
106 | 108 | |
107 | 109 | // Has it outstanding posts for approval? |
108 | - if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) |
|
109 | - echo ' |
|
110 | + if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) { |
|
111 | + echo ' |
|
110 | 112 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>'; |
113 | + } |
|
111 | 114 | |
112 | 115 | echo ' |
113 | 116 | <p class="board_description">', $board['description'], '</p>'; |
114 | 117 | |
115 | 118 | // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.) |
116 | - if (!empty($board['link_moderators'])) |
|
117 | - echo ' |
|
119 | + if (!empty($board['link_moderators'])) { |
|
120 | + echo ' |
|
118 | 121 | <p class="moderators">', count($board['link_moderators']) == 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>'; |
122 | + } |
|
119 | 123 | |
120 | 124 | // Show some basic information about the number of posts, etc. |
121 | 125 | echo ' |
@@ -127,9 +131,10 @@ discard block |
||
127 | 131 | </div> |
128 | 132 | <div class="lastpost ',!empty($board['last_post']['id']) ? 'lpr_border' : 'hidden', '">'; |
129 | 133 | |
130 | - if (!empty($board['last_post']['id'])) |
|
131 | - echo ' |
|
134 | + if (!empty($board['last_post']['id'])) { |
|
135 | + echo ' |
|
132 | 136 | <p>', $board['last_post']['last_post_message'], '</p>'; |
137 | + } |
|
133 | 138 | echo ' |
134 | 139 | </div>'; |
135 | 140 | // Show the "Child Boards: ". (there's a link_children but we're going to bold the new ones...) |
@@ -141,14 +146,16 @@ discard block |
||
141 | 146 | id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */ |
142 | 147 | foreach ($board['children'] as $child) |
143 | 148 | { |
144 | - if (!$child['is_redirect']) |
|
145 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
146 | - else |
|
147 | - $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
|
149 | + if (!$child['is_redirect']) { |
|
150 | + $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
151 | + } else { |
|
152 | + $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
|
153 | + } |
|
148 | 154 | |
149 | 155 | // Has it posts awaiting approval? |
150 | - if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics'])) |
|
151 | - $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
156 | + if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics'])) { |
|
157 | + $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
158 | + } |
|
152 | 159 | |
153 | 160 | $children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>'; |
154 | 161 | } |
@@ -172,10 +179,11 @@ discard block |
||
172 | 179 | </div>'; |
173 | 180 | |
174 | 181 | // Show the mark all as read button? |
175 | - if ($context['user']['is_logged'] && !empty($context['categories'])) |
|
176 | - echo ' |
|
182 | + if ($context['user']['is_logged'] && !empty($context['categories'])) { |
|
183 | + echo ' |
|
177 | 184 | <div class="mark_read">', template_button_strip($context['mark_read_button'], 'right'), '</div>'; |
178 | -} |
|
185 | + } |
|
186 | + } |
|
179 | 187 | |
180 | 188 | /** |
181 | 189 | * The lower part of the outer layer of the board index |
@@ -192,8 +200,9 @@ discard block |
||
192 | 200 | { |
193 | 201 | global $context, $options, $txt; |
194 | 202 | |
195 | - if (empty($context['info_center'])) |
|
196 | - return; |
|
203 | + if (empty($context['info_center'])) { |
|
204 | + return; |
|
205 | + } |
|
197 | 206 | |
198 | 207 | // Here's where the "Info Center" starts... |
199 | 208 | echo ' |
@@ -293,14 +302,15 @@ discard block |
||
293 | 302 | /* Each post in latest_posts has: |
294 | 303 | board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.), |
295 | 304 | subject, short_subject (shortened with...), time, link, and href. */ |
296 | - foreach ($context['latest_posts'] as $post) |
|
297 | - echo ' |
|
305 | + foreach ($context['latest_posts'] as $post) { |
|
306 | + echo ' |
|
298 | 307 | <tr class="windowbg"> |
299 | 308 | <td class="recentpost"><strong>', $post['link'], '</strong></td> |
300 | 309 | <td class="recentposter">', $post['poster']['link'], '</td> |
301 | 310 | <td class="recentboard">', $post['board']['link'], '</td> |
302 | 311 | <td class="recenttime">', $post['time'], '</td> |
303 | 312 | </tr>'; |
313 | + } |
|
304 | 314 | echo ' |
305 | 315 | </table>'; |
306 | 316 | } |
@@ -324,9 +334,10 @@ discard block |
||
324 | 334 | </div>'; |
325 | 335 | |
326 | 336 | // Holidays like "Christmas", "Chanukah", and "We Love [Unknown] Day" :P. |
327 | - if (!empty($context['calendar_holidays'])) |
|
328 | - echo ' |
|
337 | + if (!empty($context['calendar_holidays'])) { |
|
338 | + echo ' |
|
329 | 339 | <p class="inline holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $context['calendar_holidays']), '</p>'; |
340 | + } |
|
330 | 341 | |
331 | 342 | // People's birthdays. Like mine. And yours, I guess. Kidding. |
332 | 343 | if (!empty($context['calendar_birthdays'])) |
@@ -335,9 +346,10 @@ discard block |
||
335 | 346 | <p class="inline"> |
336 | 347 | <span class="birthday">', $context['calendar_only_today'] ? $txt['birthdays'] : $txt['birthdays_upcoming'], '</span>'; |
337 | 348 | // Each member in calendar_birthdays has: id, name (person), age (if they have one set?), is_last. (last in list?), and is_today (birthday is today?) |
338 | - foreach ($context['calendar_birthdays'] as $member) |
|
339 | - echo ' |
|
349 | + foreach ($context['calendar_birthdays'] as $member) { |
|
350 | + echo ' |
|
340 | 351 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['is_today'] ? '<strong class="fix_rtl_names">' : '', $member['name'], $member['is_today'] ? '</strong>' : '', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] ? '' : ', '; |
352 | + } |
|
341 | 353 | echo ' |
342 | 354 | </p>'; |
343 | 355 | } |
@@ -351,9 +363,10 @@ discard block |
||
351 | 363 | |
352 | 364 | // Each event in calendar_events should have: |
353 | 365 | // title, href, is_last, can_edit (are they allowed?), modify_href, and is_today. |
354 | - foreach ($context['calendar_events'] as $event) |
|
355 | - echo ' |
|
366 | + foreach ($context['calendar_events'] as $event) { |
|
367 | + echo ' |
|
356 | 368 | ', $event['can_edit'] ? '<a href="' . $event['modify_href'] . '" title="' . $txt['calendar_edit'] . '"><span class="generic_icons calendar_modify"></span></a> ' : '', $event['href'] == '' ? '' : '<a href="' . $event['href'] . '">', $event['is_today'] ? '<strong>' . $event['title'] . '</strong>' : $event['title'], $event['href'] == '' ? '' : '</a>', $event['is_last'] ? '<br>' : ', '; |
369 | + } |
|
357 | 370 | echo ' |
358 | 371 | </p>'; |
359 | 372 | } |
@@ -398,15 +411,19 @@ discard block |
||
398 | 411 | |
399 | 412 | // Handle hidden users and buddies. |
400 | 413 | $bracketList = array(); |
401 | - if ($context['show_buddies']) |
|
402 | - $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
403 | - if (!empty($context['num_spiders'])) |
|
404 | - $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
405 | - if (!empty($context['num_users_hidden'])) |
|
406 | - $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']); |
|
414 | + if ($context['show_buddies']) { |
|
415 | + $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
416 | + } |
|
417 | + if (!empty($context['num_spiders'])) { |
|
418 | + $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
419 | + } |
|
420 | + if (!empty($context['num_users_hidden'])) { |
|
421 | + $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']); |
|
422 | + } |
|
407 | 423 | |
408 | - if (!empty($bracketList)) |
|
409 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
424 | + if (!empty($bracketList)) { |
|
425 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
426 | + } |
|
410 | 427 | |
411 | 428 | echo $context['show_who'] ? '</a>' : '', ' |
412 | 429 | |
@@ -420,9 +437,10 @@ discard block |
||
420 | 437 | ', sprintf($txt['users_active'], $modSettings['lastActive']), ': ', implode(', ', $context['list_users_online']); |
421 | 438 | |
422 | 439 | // Showing membergroups? |
423 | - if (!empty($settings['show_group_key']) && !empty($context['membergroups'])) |
|
424 | - echo ' |
|
440 | + if (!empty($settings['show_group_key']) && !empty($context['membergroups'])) { |
|
441 | + echo ' |
|
425 | 442 | <span class="membergroups">' . implode(', ', $context['membergroups']) . '</span>'; |
443 | + } |
|
426 | 444 | } |
427 | 445 | |
428 | 446 | echo ' |
@@ -86,7 +86,7 @@ |
||
86 | 86 | foreach ($board['children'] as $child) |
87 | 87 | { |
88 | 88 | if (!$child['is_redirect']) |
89 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
89 | + $child['link'] = '' . ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
90 | 90 | else |
91 | 91 | $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
92 | 92 |
@@ -48,17 +48,19 @@ discard block |
||
48 | 48 | </a>'; |
49 | 49 | |
50 | 50 | // Has it outstanding posts for approval? |
51 | - if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) |
|
52 | - echo ' |
|
51 | + if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) { |
|
52 | + echo ' |
|
53 | 53 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>'; |
54 | + } |
|
54 | 55 | |
55 | 56 | echo ' |
56 | 57 | <p class="board_description">', $board['description'], '</p>'; |
57 | 58 | |
58 | 59 | // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.) |
59 | - if (!empty($board['moderators']) || !empty($board['moderator_groups'])) |
|
60 | - echo ' |
|
60 | + if (!empty($board['moderators']) || !empty($board['moderator_groups'])) { |
|
61 | + echo ' |
|
61 | 62 | <p class="moderators">', count($board['link_moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>'; |
63 | + } |
|
62 | 64 | |
63 | 65 | // Show some basic information about the number of posts, etc. |
64 | 66 | echo ' |
@@ -70,9 +72,10 @@ discard block |
||
70 | 72 | </div> |
71 | 73 | <div class="lastpost lpr_border">'; |
72 | 74 | |
73 | - if (!empty($board['last_post']['id'])) |
|
74 | - echo ' |
|
75 | + if (!empty($board['last_post']['id'])) { |
|
76 | + echo ' |
|
75 | 77 | <p>', $board['last_post']['last_post_message'], '</p>'; |
78 | + } |
|
76 | 79 | echo ' |
77 | 80 | </div>'; |
78 | 81 | |
@@ -85,14 +88,16 @@ discard block |
||
85 | 88 | id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */ |
86 | 89 | foreach ($board['children'] as $child) |
87 | 90 | { |
88 | - if (!$child['is_redirect']) |
|
89 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
90 | - else |
|
91 | - $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
91 | + if (!$child['is_redirect']) { |
|
92 | + $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
93 | + } else { |
|
94 | + $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
95 | + } |
|
92 | 96 | |
93 | 97 | // Has it posts awaiting approval? |
94 | - if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) |
|
95 | - $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
98 | + if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) { |
|
99 | + $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
100 | + } |
|
96 | 101 | |
97 | 102 | $children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>'; |
98 | 103 | } |
@@ -111,8 +116,9 @@ discard block |
||
111 | 116 | } |
112 | 117 | |
113 | 118 | // They can only mark read if they are logged in and it's enabled! |
114 | - if (!$context['user']['is_logged']) |
|
115 | - unset($context['normal_buttons']['markread']); |
|
119 | + if (!$context['user']['is_logged']) { |
|
120 | + unset($context['normal_buttons']['markread']); |
|
121 | + } |
|
116 | 122 | |
117 | 123 | if (!$context['no_topic_listing']) |
118 | 124 | { |
@@ -135,13 +141,15 @@ discard block |
||
135 | 141 | <div id="description_board" class="generic_list_wrapper"> |
136 | 142 | <h3>', $context['name'], '</h3> |
137 | 143 | <p>'; |
138 | - if ($context['description'] != '') |
|
139 | - echo ' |
|
144 | + if ($context['description'] != '') { |
|
145 | + echo ' |
|
140 | 146 | ', $context['description'], ' '; |
147 | + } |
|
141 | 148 | |
142 | - if (!empty($context['moderators'])) |
|
143 | - echo ' |
|
149 | + if (!empty($context['moderators'])) { |
|
150 | + echo ' |
|
144 | 151 | ', count($context['moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $context['link_moderators']), '.'; |
152 | + } |
|
145 | 153 | |
146 | 154 | echo ' |
147 | 155 | </p> |
@@ -149,9 +157,10 @@ discard block |
||
149 | 157 | } |
150 | 158 | |
151 | 159 | // If Quick Moderation is enabled start the form. |
152 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
153 | - echo ' |
|
160 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
161 | + echo ' |
|
154 | 162 | <form action="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], '" method="post" accept-charset="', $context['character_set'], '" class="clear" name="quickModForm" id="quickModForm">'; |
163 | + } |
|
155 | 164 | |
156 | 165 | echo ' |
157 | 166 | <div id="messageindex">'; |
@@ -159,10 +168,11 @@ discard block |
||
159 | 168 | { |
160 | 169 | echo ' |
161 | 170 | <div class="information">'; |
162 | - if ($settings['display_who_viewing'] == 1) |
|
163 | - echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
164 | - else |
|
165 | - echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
171 | + if ($settings['display_who_viewing'] == 1) { |
|
172 | + echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
173 | + } else { |
|
174 | + echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
175 | + } |
|
166 | 176 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_board']; |
167 | 177 | |
168 | 178 | echo ' |
@@ -181,19 +191,22 @@ discard block |
||
181 | 191 | <div class="lastpost">', $context['topics_headers']['last_post'], '</div>'; |
182 | 192 | |
183 | 193 | // Show a "select all" box for quick moderation? |
184 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
|
185 | - echo ' |
|
194 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
195 | + echo ' |
|
186 | 196 | <div class="moderation"><input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="input_check"></div>'; |
197 | + } |
|
187 | 198 | |
188 | 199 | // If it's on in "image" mode, don't show anything but the column. |
189 | - elseif (!empty($context['can_quick_mod'])) |
|
190 | - echo ' |
|
200 | + elseif (!empty($context['can_quick_mod'])) { |
|
201 | + echo ' |
|
191 | 202 | <div class="moderation"> </div>'; |
203 | + } |
|
192 | 204 | } |
193 | 205 | // No topics.... just say, "sorry bub". |
194 | - else |
|
195 | - echo ' |
|
206 | + else { |
|
207 | + echo ' |
|
196 | 208 | <h3 class="titlebg">', $txt['topic_alert_none'], '</h3>'; |
209 | + } |
|
197 | 210 | |
198 | 211 | echo ' |
199 | 212 | </div>'; |
@@ -225,21 +238,26 @@ discard block |
||
225 | 238 | // Now we handle the icons |
226 | 239 | echo ' |
227 | 240 | <div class="icons floatright">'; |
228 | - if ($topic['is_watched']) |
|
229 | - echo ' |
|
241 | + if ($topic['is_watched']) { |
|
242 | + echo ' |
|
230 | 243 | <span class="generic_icons watch" title="', $txt['watching_this_topic'], '"></span>'; |
231 | - if ($topic['is_locked']) |
|
232 | - echo ' |
|
244 | + } |
|
245 | + if ($topic['is_locked']) { |
|
246 | + echo ' |
|
233 | 247 | <span class="generic_icons lock"></span>'; |
234 | - if ($topic['is_sticky']) |
|
235 | - echo ' |
|
248 | + } |
|
249 | + if ($topic['is_sticky']) { |
|
250 | + echo ' |
|
236 | 251 | <span class="generic_icons sticky"></span>'; |
237 | - if ($topic['is_redirect']) |
|
238 | - echo ' |
|
252 | + } |
|
253 | + if ($topic['is_redirect']) { |
|
254 | + echo ' |
|
239 | 255 | <span class="generic_icons move"></span>'; |
240 | - if ($topic['is_poll']) |
|
241 | - echo ' |
|
256 | + } |
|
257 | + if ($topic['is_poll']) { |
|
258 | + echo ' |
|
242 | 259 | <span class="generic_icons poll"></span>'; |
260 | + } |
|
243 | 261 | echo ' |
244 | 262 | </div>'; |
245 | 263 | |
@@ -265,26 +283,31 @@ discard block |
||
265 | 283 | { |
266 | 284 | echo ' |
267 | 285 | <div class="moderation">'; |
268 | - if ($options['display_quick_mod'] == 1) |
|
269 | - echo ' |
|
286 | + if ($options['display_quick_mod'] == 1) { |
|
287 | + echo ' |
|
270 | 288 | <input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check">'; |
271 | - else |
|
289 | + } else |
|
272 | 290 | { |
273 | 291 | // Check permissions on each and show only the ones they are allowed to use. |
274 | - if ($topic['quick_mod']['remove']) |
|
275 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
|
292 | + if ($topic['quick_mod']['remove']) { |
|
293 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
|
294 | + } |
|
276 | 295 | |
277 | - if ($topic['quick_mod']['lock']) |
|
278 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
|
296 | + if ($topic['quick_mod']['lock']) { |
|
297 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
|
298 | + } |
|
279 | 299 | |
280 | - if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) |
|
281 | - echo '<br>'; |
|
300 | + if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { |
|
301 | + echo '<br>'; |
|
302 | + } |
|
282 | 303 | |
283 | - if ($topic['quick_mod']['sticky']) |
|
284 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
|
304 | + if ($topic['quick_mod']['sticky']) { |
|
305 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
|
306 | + } |
|
285 | 307 | |
286 | - if ($topic['quick_mod']['move']) |
|
287 | - echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
|
308 | + if ($topic['quick_mod']['move']) { |
|
309 | + echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
|
310 | + } |
|
288 | 311 | } |
289 | 312 | echo ' |
290 | 313 | </div>'; |
@@ -302,18 +325,20 @@ discard block |
||
302 | 325 | <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> |
303 | 326 | <option value="">--------</option>'; |
304 | 327 | |
305 | - foreach ($context['qmod_actions'] as $qmod_action) |
|
306 | - if ($context['can_' . $qmod_action]) |
|
328 | + foreach ($context['qmod_actions'] as $qmod_action) { |
|
329 | + if ($context['can_' . $qmod_action]) |
|
307 | 330 | echo ' |
308 | 331 | <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>'; |
332 | + } |
|
309 | 333 | |
310 | 334 | echo ' |
311 | 335 | </select>'; |
312 | 336 | |
313 | 337 | // Show a list of boards they can move the topic to. |
314 | - if ($context['can_move']) |
|
315 | - echo ' |
|
338 | + if ($context['can_move']) { |
|
339 | + echo ' |
|
316 | 340 | <span id="quick_mod_jump_to"> </span>'; |
341 | + } |
|
317 | 342 | |
318 | 343 | echo ' |
319 | 344 | <input type="submit" value="', $txt['quick_mod_go'], '" onclick="return document.forms.quickModForm.qaction.value != \'\' && confirm(\'', $txt['quickmod_confirm'], '\');" class="button_submit qaction"> |
@@ -324,10 +349,11 @@ discard block |
||
324 | 349 | </div>'; |
325 | 350 | |
326 | 351 | // Finish off the form - again. |
327 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
328 | - echo ' |
|
352 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
353 | + echo ' |
|
329 | 354 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
330 | 355 | </form>'; |
356 | + } |
|
331 | 357 | |
332 | 358 | // Mobile action buttons (bottom) |
333 | 359 | echo ' |
@@ -346,8 +372,8 @@ discard block |
||
346 | 372 | // Show breadcrumbs at the bottom too. |
347 | 373 | theme_linktree(); |
348 | 374 | |
349 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) |
|
350 | - echo ' |
|
375 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { |
|
376 | + echo ' |
|
351 | 377 | <script> |
352 | 378 | if (typeof(window.XMLHttpRequest) != "undefined") |
353 | 379 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -366,6 +392,7 @@ discard block |
||
366 | 392 | sCustomName: "move_to" |
367 | 393 | }); |
368 | 394 | </script>'; |
395 | + } |
|
369 | 396 | |
370 | 397 | // Javascript for inline editing. |
371 | 398 | echo ' |
@@ -401,8 +428,8 @@ discard block |
||
401 | 428 | <div class="information"> |
402 | 429 | <p class="floatright" id="message_index_jump_to"> </p>'; |
403 | 430 | |
404 | - if (empty($context['no_topic_listing'])) |
|
405 | - echo ' |
|
431 | + if (empty($context['no_topic_listing'])) { |
|
432 | + echo ' |
|
406 | 433 | <p class="floatleft">', !empty($modSettings['enableParticipation']) && $context['user']['is_logged'] ? ' |
407 | 434 | <img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="" class="centericon"> ' . $txt['participation_caption'] . '<br>' : '', ' |
408 | 435 | '. ($modSettings['pollMode'] == '1' ? '<span class="generic_icons poll centericon"></span> ' . $txt['poll'] : '') . '<br> |
@@ -412,9 +439,10 @@ discard block |
||
412 | 439 | <span class="generic_icons lock centericon"></span> ' . $txt['locked_topic'] . '<br> |
413 | 440 | <span class="generic_icons sticky centericon"></span> ' . $txt['sticky_topic'] . '<br> |
414 | 441 | </p>'; |
442 | + } |
|
415 | 443 | |
416 | - if (!empty($context['jump_to'])) |
|
417 | - echo ' |
|
444 | + if (!empty($context['jump_to'])) { |
|
445 | + echo ' |
|
418 | 446 | <script> |
419 | 447 | if (typeof(window.XMLHttpRequest) != "undefined") |
420 | 448 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -430,6 +458,7 @@ discard block |
||
430 | 458 | sGoButtonLabel: "', $txt['quick_mod_go'], '" |
431 | 459 | }); |
432 | 460 | </script>'; |
461 | + } |
|
433 | 462 | |
434 | 463 | echo ' |
435 | 464 | <br class="clear"> |
@@ -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 | * The main dispatcher; doesn't do anything, just delegates. |
@@ -92,18 +93,19 @@ discard block |
||
92 | 93 | checkSession('get'); |
93 | 94 | validateToken('admin-bm-' . (int) $_REQUEST['src_board'], 'request'); |
94 | 95 | |
95 | - if ($_REQUEST['move_to'] === 'top') |
|
96 | - $boardOptions = array( |
|
96 | + if ($_REQUEST['move_to'] === 'top') { |
|
97 | + $boardOptions = array( |
|
97 | 98 | 'move_to' => $_REQUEST['move_to'], |
98 | 99 | 'target_category' => (int) $_REQUEST['target_cat'], |
99 | 100 | 'move_first_child' => true, |
100 | 101 | ); |
101 | - else |
|
102 | - $boardOptions = array( |
|
102 | + } else { |
|
103 | + $boardOptions = array( |
|
103 | 104 | 'move_to' => $_REQUEST['move_to'], |
104 | 105 | 'target_board' => (int) $_REQUEST['target_board'], |
105 | 106 | 'move_first_child' => true, |
106 | 107 | ); |
108 | + } |
|
107 | 109 | modifyBoard((int) $_REQUEST['src_board'], $boardOptions); |
108 | 110 | } |
109 | 111 | |
@@ -148,15 +150,16 @@ discard block |
||
148 | 150 | $security = $context['session_var'] . '=' . $context['session_id'] . ';' . $context['admin-bm-' . $context['move_board'] . '_token_var'] . '=' . $context['admin-bm-' . $context['move_board'] . '_token']; |
149 | 151 | foreach ($boardList[$catid] as $boardid) |
150 | 152 | { |
151 | - if (!isset($context['categories'][$catid]['move_link'])) |
|
152 | - $context['categories'][$catid]['move_link'] = array( |
|
153 | + if (!isset($context['categories'][$catid]['move_link'])) { |
|
154 | + $context['categories'][$catid]['move_link'] = array( |
|
153 | 155 | 'child_level' => 0, |
154 | 156 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'', |
155 | 157 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=before;' . $security, |
156 | 158 | ); |
159 | + } |
|
157 | 160 | |
158 | - if (!$context['categories'][$catid]['boards'][$boardid]['move']) |
|
159 | - $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
161 | + if (!$context['categories'][$catid]['boards'][$boardid]['move']) { |
|
162 | + $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
160 | 163 | array( |
161 | 164 | 'child_level' => $boards[$boardid]['level'], |
162 | 165 | 'label' => $txt['mboards_order_after'] . '\'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'', |
@@ -170,34 +173,39 @@ discard block |
||
170 | 173 | 'class' => 'here', |
171 | 174 | ), |
172 | 175 | ); |
176 | + } |
|
173 | 177 | |
174 | 178 | $difference = $boards[$boardid]['level'] - $prev_child_level; |
175 | - if ($difference == 1) |
|
176 | - array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
177 | - elseif ($difference < 0) |
|
179 | + if ($difference == 1) { |
|
180 | + array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
181 | + } elseif ($difference < 0) |
|
178 | 182 | { |
179 | - if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
180 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
181 | - for ($i = 0; $i < -$difference; $i++) |
|
182 | - if (($temp = array_pop($stack)) != null) |
|
183 | + if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
184 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
185 | + } |
|
186 | + for ($i = 0; $i < -$difference; $i++) { |
|
187 | + if (($temp = array_pop($stack)) != null) |
|
183 | 188 | array_unshift($context['categories'][$catid]['boards'][$prev_board]['move_links'], $temp); |
189 | + } |
|
184 | 190 | } |
185 | 191 | |
186 | 192 | $prev_board = $boardid; |
187 | 193 | $prev_child_level = $boards[$boardid]['level']; |
188 | 194 | |
189 | 195 | } |
190 | - if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
191 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
192 | - elseif (!empty($stack)) |
|
193 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
196 | + if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
197 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
198 | + } elseif (!empty($stack)) { |
|
199 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
200 | + } |
|
194 | 201 | |
195 | - if (empty($boardList[$catid])) |
|
196 | - $context['categories'][$catid]['move_link'] = array( |
|
202 | + if (empty($boardList[$catid])) { |
|
203 | + $context['categories'][$catid]['move_link'] = array( |
|
197 | 204 | 'child_level' => 0, |
198 | 205 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($tree['node']['name']) . '\'', |
199 | 206 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_cat=' . $catid . ';move_to=top;' . $security, |
200 | 207 | ); |
208 | + } |
|
201 | 209 | } |
202 | 210 | } |
203 | 211 | |
@@ -253,9 +261,9 @@ discard block |
||
253 | 261 | ); |
254 | 262 | } |
255 | 263 | // Category doesn't exist, man... sorry. |
256 | - elseif (!isset($cat_tree[$_REQUEST['cat']])) |
|
257 | - redirectexit('action=admin;area=manageboards'); |
|
258 | - else |
|
264 | + elseif (!isset($cat_tree[$_REQUEST['cat']])) { |
|
265 | + redirectexit('action=admin;area=manageboards'); |
|
266 | + } else |
|
259 | 267 | { |
260 | 268 | $context['category'] = array( |
261 | 269 | 'id' => $_REQUEST['cat'], |
@@ -267,30 +275,31 @@ discard block |
||
267 | 275 | 'is_empty' => empty($cat_tree[$_REQUEST['cat']]['children']) |
268 | 276 | ); |
269 | 277 | |
270 | - foreach ($boardList[$_REQUEST['cat']] as $child_board) |
|
271 | - $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
278 | + foreach ($boardList[$_REQUEST['cat']] as $child_board) { |
|
279 | + $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
280 | + } |
|
272 | 281 | } |
273 | 282 | |
274 | 283 | $prevCat = 0; |
275 | 284 | foreach ($cat_tree as $catid => $tree) |
276 | 285 | { |
277 | - if ($catid == $_REQUEST['cat'] && $prevCat > 0) |
|
278 | - $context['category_order'][$prevCat]['selected'] = true; |
|
279 | - elseif ($catid != $_REQUEST['cat']) |
|
280 | - $context['category_order'][$catid] = array( |
|
286 | + if ($catid == $_REQUEST['cat'] && $prevCat > 0) { |
|
287 | + $context['category_order'][$prevCat]['selected'] = true; |
|
288 | + } elseif ($catid != $_REQUEST['cat']) { |
|
289 | + $context['category_order'][$catid] = array( |
|
281 | 290 | 'id' => $catid, |
282 | 291 | 'name' => $txt['mboards_order_after'] . $tree['node']['name'], |
283 | 292 | 'selected' => false, |
284 | 293 | 'true_name' => $tree['node']['name'] |
285 | 294 | ); |
295 | + } |
|
286 | 296 | $prevCat = $catid; |
287 | 297 | } |
288 | 298 | if (!isset($_REQUEST['delete'])) |
289 | 299 | { |
290 | 300 | $context['sub_template'] = 'modify_category'; |
291 | 301 | $context['page_title'] = $_REQUEST['sa'] == 'newcat' ? $txt['mboards_new_cat_name'] : $txt['catEdit']; |
292 | - } |
|
293 | - else |
|
302 | + } else |
|
294 | 303 | { |
295 | 304 | $context['sub_template'] = 'confirm_category_delete'; |
296 | 305 | $context['page_title'] = $txt['mboards_delete_cat']; |
@@ -327,8 +336,9 @@ discard block |
||
327 | 336 | { |
328 | 337 | $catOptions = array(); |
329 | 338 | |
330 | - if (isset($_POST['cat_order'])) |
|
331 | - $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
339 | + if (isset($_POST['cat_order'])) { |
|
340 | + $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
341 | + } |
|
332 | 342 | |
333 | 343 | // Change "This & That" to "This & That" but don't change "¢" to "&cent;"... |
334 | 344 | $catOptions['cat_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['cat_name']), false, '', $context['description_allowed_tags']); |
@@ -336,10 +346,11 @@ discard block |
||
336 | 346 | |
337 | 347 | $catOptions['is_collapsible'] = isset($_POST['collapse']); |
338 | 348 | |
339 | - if (isset($_POST['add'])) |
|
340 | - createCategory($catOptions); |
|
341 | - else |
|
342 | - modifyCategory($_POST['cat'], $catOptions); |
|
349 | + if (isset($_POST['add'])) { |
|
350 | + createCategory($catOptions); |
|
351 | + } else { |
|
352 | + modifyCategory($_POST['cat'], $catOptions); |
|
353 | + } |
|
343 | 354 | } |
344 | 355 | // If they want to delete - first give them confirmation. |
345 | 356 | elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['empty'])) |
@@ -353,13 +364,14 @@ discard block |
||
353 | 364 | // First off - check if we are moving all the current boards first - before we start deleting! |
354 | 365 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
355 | 366 | { |
356 | - if (empty($_POST['cat_to'])) |
|
357 | - fatal_lang_error('mboards_delete_error'); |
|
367 | + if (empty($_POST['cat_to'])) { |
|
368 | + fatal_lang_error('mboards_delete_error'); |
|
369 | + } |
|
358 | 370 | |
359 | 371 | deleteCategories(array($_POST['cat']), (int) $_POST['cat_to']); |
372 | + } else { |
|
373 | + deleteCategories(array($_POST['cat'])); |
|
360 | 374 | } |
361 | - else |
|
362 | - deleteCategories(array($_POST['cat'])); |
|
363 | 375 | } |
364 | 376 | |
365 | 377 | redirectexit('action=admin;area=manageboards'); |
@@ -404,8 +416,9 @@ discard block |
||
404 | 416 | if ($_REQUEST['sa'] == 'newboard') |
405 | 417 | { |
406 | 418 | // Category doesn't exist, man... sorry. |
407 | - if (empty($_REQUEST['cat'])) |
|
408 | - redirectexit('action=admin;area=manageboards'); |
|
419 | + if (empty($_REQUEST['cat'])) { |
|
420 | + redirectexit('action=admin;area=manageboards'); |
|
421 | + } |
|
409 | 422 | |
410 | 423 | // Some things that need to be setup for a new board. |
411 | 424 | $curBoard = array( |
@@ -429,8 +442,7 @@ discard block |
||
429 | 442 | 'category' => (int) $_REQUEST['cat'], |
430 | 443 | 'no_children' => true, |
431 | 444 | ); |
432 | - } |
|
433 | - else |
|
445 | + } else |
|
434 | 446 | { |
435 | 447 | // Just some easy shortcuts. |
436 | 448 | $curBoard = &$boards[$_REQUEST['boardid']]; |
@@ -478,8 +490,9 @@ discard block |
||
478 | 490 | ); |
479 | 491 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
480 | 492 | { |
481 | - if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) |
|
482 | - $curBoard['member_groups'][] = $row['id_group']; |
|
493 | + if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) { |
|
494 | + $curBoard['member_groups'][] = $row['id_group']; |
|
495 | + } |
|
483 | 496 | |
484 | 497 | $context['groups'][(int) $row['id_group']] = array( |
485 | 498 | 'id' => $row['id_group'], |
@@ -492,8 +505,9 @@ discard block |
||
492 | 505 | $smcFunc['db_free_result']($request); |
493 | 506 | |
494 | 507 | // Category doesn't exist, man... sorry. |
495 | - if (!isset($boardList[$curBoard['category']])) |
|
496 | - redirectexit('action=admin;area=manageboards'); |
|
508 | + if (!isset($boardList[$curBoard['category']])) { |
|
509 | + redirectexit('action=admin;area=manageboards'); |
|
510 | + } |
|
497 | 511 | |
498 | 512 | foreach ($boardList[$curBoard['category']] as $boardid) |
499 | 513 | { |
@@ -507,8 +521,7 @@ discard block |
||
507 | 521 | 'is_child' => false, |
508 | 522 | 'selected' => true |
509 | 523 | ); |
510 | - } |
|
511 | - else |
|
524 | + } else |
|
512 | 525 | { |
513 | 526 | $context['board_order'][] = array( |
514 | 527 | 'id' => $boardid, |
@@ -525,19 +538,21 @@ discard block |
||
525 | 538 | $context['can_move_children'] = false; |
526 | 539 | $context['children'] = $boards[$_REQUEST['boardid']]['tree']['children']; |
527 | 540 | |
528 | - foreach ($context['board_order'] as $lBoard) |
|
529 | - if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
541 | + foreach ($context['board_order'] as $lBoard) { |
|
542 | + if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
530 | 543 | $context['can_move_children'] = true; |
544 | + } |
|
531 | 545 | } |
532 | 546 | |
533 | 547 | // Get other available categories. |
534 | 548 | $context['categories'] = array(); |
535 | - foreach ($cat_tree as $catID => $tree) |
|
536 | - $context['categories'][] = array( |
|
549 | + foreach ($cat_tree as $catID => $tree) { |
|
550 | + $context['categories'][] = array( |
|
537 | 551 | 'id' => $catID == $curBoard['category'] ? 0 : $catID, |
538 | 552 | 'name' => $tree['node']['name'], |
539 | 553 | 'selected' => $catID == $curBoard['category'] |
540 | 554 | ); |
555 | + } |
|
541 | 556 | |
542 | 557 | $request = $smcFunc['db_query']('', ' |
543 | 558 | SELECT mem.id_member, mem.real_name |
@@ -549,14 +564,16 @@ discard block |
||
549 | 564 | ) |
550 | 565 | ); |
551 | 566 | $context['board']['moderators'] = array(); |
552 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
553 | - $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
567 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
568 | + $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
569 | + } |
|
554 | 570 | $smcFunc['db_free_result']($request); |
555 | 571 | |
556 | 572 | $context['board']['moderator_list'] = empty($context['board']['moderators']) ? '' : '"' . implode('", "', $context['board']['moderators']) . '"'; |
557 | 573 | |
558 | - if (!empty($context['board']['moderators'])) |
|
559 | - list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
574 | + if (!empty($context['board']['moderators'])) { |
|
575 | + list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
576 | + } |
|
560 | 577 | |
561 | 578 | // Get all the groups assigned as moderators |
562 | 579 | $request = $smcFunc['db_query']('', ' |
@@ -568,14 +585,16 @@ discard block |
||
568 | 585 | ) |
569 | 586 | ); |
570 | 587 | $context['board']['moderator_groups'] = array(); |
571 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
572 | - $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
588 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
589 | + $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
590 | + } |
|
573 | 591 | $smcFunc['db_free_result']($request); |
574 | 592 | |
575 | 593 | $context['board']['moderator_groups_list'] = empty($context['board']['moderator_groups']) ? '' : '"' . implode('", &qout;', $context['board']['moderator_groups']) . '"'; |
576 | 594 | |
577 | - if (!empty($context['board']['moderator_groups'])) |
|
578 | - list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
595 | + if (!empty($context['board']['moderator_groups'])) { |
|
596 | + list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
597 | + } |
|
579 | 598 | |
580 | 599 | // Get all the themes... |
581 | 600 | $request = $smcFunc['db_query']('', ' |
@@ -587,8 +606,9 @@ discard block |
||
587 | 606 | ) |
588 | 607 | ); |
589 | 608 | $context['themes'] = array(); |
590 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
591 | - $context['themes'][] = $row; |
|
609 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
610 | + $context['themes'][] = $row; |
|
611 | + } |
|
592 | 612 | $smcFunc['db_free_result']($request); |
593 | 613 | |
594 | 614 | if (!isset($_REQUEST['delete'])) |
@@ -596,8 +616,7 @@ discard block |
||
596 | 616 | $context['sub_template'] = 'modify_board'; |
597 | 617 | $context['page_title'] = $txt['boardsEdit']; |
598 | 618 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
599 | - } |
|
600 | - else |
|
619 | + } else |
|
601 | 620 | { |
602 | 621 | $context['sub_template'] = 'confirm_board_delete'; |
603 | 622 | $context['page_title'] = $txt['mboards_delete_board']; |
@@ -641,8 +660,9 @@ discard block |
||
641 | 660 | // Change the boardorder of this board? |
642 | 661 | elseif (!empty($_POST['placement']) && !empty($_POST['board_order'])) |
643 | 662 | { |
644 | - if (!in_array($_POST['placement'], array('before', 'after', 'child'))) |
|
645 | - fatal_lang_error('mangled_post', false); |
|
663 | + if (!in_array($_POST['placement'], array('before', 'after', 'child'))) { |
|
664 | + fatal_lang_error('mangled_post', false); |
|
665 | + } |
|
646 | 666 | |
647 | 667 | $boardOptions['move_to'] = $_POST['placement']; |
648 | 668 | $boardOptions['target_board'] = (int) $_POST['board_order']; |
@@ -655,13 +675,14 @@ discard block |
||
655 | 675 | $boardOptions['access_groups'] = array(); |
656 | 676 | $boardOptions['deny_groups'] = array(); |
657 | 677 | |
658 | - if (!empty($_POST['groups'])) |
|
659 | - foreach ($_POST['groups'] as $group => $action) |
|
678 | + if (!empty($_POST['groups'])) { |
|
679 | + foreach ($_POST['groups'] as $group => $action) |
|
660 | 680 | { |
661 | 681 | if ($action == 'allow') |
662 | 682 | $boardOptions['access_groups'][] = (int) $group; |
663 | - elseif ($action == 'deny') |
|
664 | - $boardOptions['deny_groups'][] = (int) $group; |
|
683 | + } elseif ($action == 'deny') { |
|
684 | + $boardOptions['deny_groups'][] = (int) $group; |
|
685 | + } |
|
665 | 686 | } |
666 | 687 | |
667 | 688 | // People with manage-boards are special. |
@@ -673,8 +694,9 @@ discard block |
||
673 | 694 | // Secondly, make sure those with super cow powers (like apt-get, or in this case manage boards) are upgraded. |
674 | 695 | $boardOptions['access_groups'] = array_unique(array_merge($boardOptions['access_groups'], $board_managers)); |
675 | 696 | |
676 | - if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) |
|
677 | - fatal_lang_error('too_many_groups', false); |
|
697 | + if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) { |
|
698 | + fatal_lang_error('too_many_groups', false); |
|
699 | + } |
|
678 | 700 | |
679 | 701 | // Do not allow HTML tags. Parse the string. |
680 | 702 | $boardOptions['board_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['board_name']), false, '', $context['description_allowed_tags']); |
@@ -685,8 +707,9 @@ discard block |
||
685 | 707 | if (isset($_POST['moderator_list']) && is_array($_POST['moderator_list'])) |
686 | 708 | { |
687 | 709 | $moderators = array(); |
688 | - foreach ($_POST['moderator_list'] as $moderator) |
|
689 | - $moderators[(int) $moderator] = (int) $moderator; |
|
710 | + foreach ($_POST['moderator_list'] as $moderator) { |
|
711 | + $moderators[(int) $moderator] = (int) $moderator; |
|
712 | + } |
|
690 | 713 | $boardOptions['moderators'] = $moderators; |
691 | 714 | } |
692 | 715 | |
@@ -695,8 +718,9 @@ discard block |
||
695 | 718 | if (isset($_POST['moderator_group_list']) && is_array($_POST['moderator_group_list'])) |
696 | 719 | { |
697 | 720 | $moderator_groups = array(); |
698 | - foreach ($_POST['moderator_group_list'] as $moderator_group) |
|
699 | - $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
721 | + foreach ($_POST['moderator_group_list'] as $moderator_group) { |
|
722 | + $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
723 | + } |
|
700 | 724 | $boardOptions['moderator_groups'] = $moderator_groups; |
701 | 725 | } |
702 | 726 | |
@@ -722,56 +746,62 @@ discard block |
||
722 | 746 | $smcFunc['db_free_result']($request); |
723 | 747 | |
724 | 748 | // If we're turning redirection on check the board doesn't have posts in it - if it does don't make it a redirection board. |
725 | - if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) |
|
726 | - unset($boardOptions['redirect']); |
|
749 | + if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) { |
|
750 | + unset($boardOptions['redirect']); |
|
751 | + } |
|
727 | 752 | // Reset the redirection count when switching on/off. |
728 | - elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) |
|
729 | - $boardOptions['num_posts'] = 0; |
|
753 | + elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) { |
|
754 | + $boardOptions['num_posts'] = 0; |
|
755 | + } |
|
730 | 756 | // Resetting the count? |
731 | - elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) |
|
732 | - $boardOptions['num_posts'] = 0; |
|
757 | + elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) { |
|
758 | + $boardOptions['num_posts'] = 0; |
|
759 | + } |
|
733 | 760 | } |
734 | 761 | |
735 | 762 | // Create a new board... |
736 | 763 | if (isset($_POST['add'])) |
737 | 764 | { |
738 | 765 | // New boards by default go to the bottom of the category. |
739 | - if (empty($_POST['new_cat'])) |
|
740 | - $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
741 | - if (!isset($boardOptions['move_to'])) |
|
742 | - $boardOptions['move_to'] = 'bottom'; |
|
766 | + if (empty($_POST['new_cat'])) { |
|
767 | + $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
768 | + } |
|
769 | + if (!isset($boardOptions['move_to'])) { |
|
770 | + $boardOptions['move_to'] = 'bottom'; |
|
771 | + } |
|
743 | 772 | |
744 | 773 | createBoard($boardOptions); |
745 | 774 | } |
746 | 775 | |
747 | 776 | // ...or update an existing board. |
748 | - else |
|
749 | - modifyBoard($_POST['boardid'], $boardOptions); |
|
750 | - } |
|
751 | - elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
777 | + else { |
|
778 | + modifyBoard($_POST['boardid'], $boardOptions); |
|
779 | + } |
|
780 | + } elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
752 | 781 | { |
753 | 782 | EditBoard(); |
754 | 783 | return; |
755 | - } |
|
756 | - elseif (isset($_POST['delete'])) |
|
784 | + } elseif (isset($_POST['delete'])) |
|
757 | 785 | { |
758 | 786 | // First off - check if we are moving all the current child boards first - before we start deleting! |
759 | 787 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
760 | 788 | { |
761 | - if (empty($_POST['board_to'])) |
|
762 | - fatal_lang_error('mboards_delete_board_error'); |
|
789 | + if (empty($_POST['board_to'])) { |
|
790 | + fatal_lang_error('mboards_delete_board_error'); |
|
791 | + } |
|
763 | 792 | |
764 | 793 | deleteBoards(array($_POST['boardid']), (int) $_POST['board_to']); |
794 | + } else { |
|
795 | + deleteBoards(array($_POST['boardid']), 0); |
|
765 | 796 | } |
766 | - else |
|
767 | - deleteBoards(array($_POST['boardid']), 0); |
|
768 | 797 | } |
769 | 798 | |
770 | - if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') |
|
771 | - redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
772 | - else |
|
773 | - redirectexit('action=admin;area=manageboards'); |
|
774 | -} |
|
799 | + if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') { |
|
800 | + redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
801 | + } else { |
|
802 | + redirectexit('action=admin;area=manageboards'); |
|
803 | + } |
|
804 | + } |
|
775 | 805 | |
776 | 806 | /** |
777 | 807 | * Used to retrieve data for modifying a board category |
@@ -808,8 +838,9 @@ discard block |
||
808 | 838 | $smcFunc['db_free_result']($request); |
809 | 839 | |
810 | 840 | // This would probably never happen, but just to be sure. |
811 | - if ($cat .= $allowed_sa[1]) |
|
812 | - die(str_replace(',', ' to', $cat)); |
|
841 | + if ($cat .= $allowed_sa[1]) { |
|
842 | + die(str_replace(',', ' to', $cat)); |
|
843 | + } |
|
813 | 844 | |
814 | 845 | redirectexit(); |
815 | 846 | } |
@@ -835,8 +866,9 @@ discard block |
||
835 | 866 | 'empty_string' => '', |
836 | 867 | ) |
837 | 868 | ); |
838 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
839 | - $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
869 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
870 | + $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
871 | + } |
|
840 | 872 | $smcFunc['db_free_result']($request); |
841 | 873 | |
842 | 874 | if (!empty($recycle_boards)) |
@@ -844,9 +876,9 @@ discard block |
||
844 | 876 | require_once($sourcedir . '/Subs-Boards.php'); |
845 | 877 | sortBoards($recycle_boards); |
846 | 878 | $recycle_boards = array('') + $recycle_boards; |
879 | + } else { |
|
880 | + $recycle_boards = array(''); |
|
847 | 881 | } |
848 | - else |
|
849 | - $recycle_boards = array(''); |
|
850 | 882 | |
851 | 883 | // Here and the board settings... |
852 | 884 | $config_vars = array( |
@@ -864,8 +896,9 @@ discard block |
||
864 | 896 | |
865 | 897 | call_integration_hook('integrate_modify_board_settings', array(&$config_vars)); |
866 | 898 | |
867 | - if ($return_config) |
|
868 | - return $config_vars; |
|
899 | + if ($return_config) { |
|
900 | + return $config_vars; |
|
901 | + } |
|
869 | 902 | |
870 | 903 | // Needed for the settings template. |
871 | 904 | require_once($sourcedir . '/ManageServer.php'); |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * PostgreSQL Cache API class |
@@ -51,8 +52,9 @@ discard block |
||
51 | 52 | |
52 | 53 | $result = pg_execute($db_connection, '', array('public', $db_prefix . 'cache')); |
53 | 54 | |
54 | - if (pg_affected_rows($result) === 0) |
|
55 | - pg_query($db_connection, 'CREATE UNLOGGED TABLE {db_prefix}cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
55 | + if (pg_affected_rows($result) === 0) { |
|
56 | + pg_query($db_connection, 'CREATE UNLOGGED TABLE {db_prefix}cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
57 | + } |
|
56 | 58 | } |
57 | 59 | |
58 | 60 | /** |
@@ -63,14 +65,16 @@ discard block |
||
63 | 65 | global $smcFunc, $db_connection; |
64 | 66 | |
65 | 67 | |
66 | - if ($smcFunc['db_title'] !== 'PostgreSQL') |
|
67 | - return false; |
|
68 | + if ($smcFunc['db_title'] !== 'PostgreSQL') { |
|
69 | + return false; |
|
70 | + } |
|
68 | 71 | |
69 | 72 | $result = pg_query($db_connection, 'SHOW server_version_num'); |
70 | 73 | $res = pg_fetch_assoc($result); |
71 | 74 | |
72 | - if ($res['server_version_num'] < 90500) |
|
73 | - return false; |
|
75 | + if ($res['server_version_num'] < 90500) { |
|
76 | + return false; |
|
77 | + } |
|
74 | 78 | |
75 | 79 | return $test ? true : parent::isSupported(); |
76 | 80 | } |
@@ -84,13 +88,15 @@ discard block |
||
84 | 88 | |
85 | 89 | $ttl = time() - $ttl; |
86 | 90 | |
87 | - if (empty($this->pg_get_data_prep)) |
|
88 | - $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
91 | + if (empty($this->pg_get_data_prep)) { |
|
92 | + $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
93 | + } |
|
89 | 94 | |
90 | 95 | $result = pg_execute($db_connection, 'smf_cache_get_data', array($key, $ttl)); |
91 | 96 | |
92 | - if (pg_affected_rows($result) === 0) |
|
93 | - return null; |
|
97 | + if (pg_affected_rows($result) === 0) { |
|
98 | + return null; |
|
99 | + } |
|
94 | 100 | |
95 | 101 | $res = pg_fetch_assoc($result); |
96 | 102 | |
@@ -104,23 +110,26 @@ discard block |
||
104 | 110 | { |
105 | 111 | global $db_prefix, $db_connection; |
106 | 112 | |
107 | - if (!isset($value)) |
|
108 | - $value = ''; |
|
113 | + if (!isset($value)) { |
|
114 | + $value = ''; |
|
115 | + } |
|
109 | 116 | |
110 | 117 | $ttl = time() + $ttl; |
111 | 118 | |
112 | - if (empty($this->pg_put_data_prep)) |
|
113 | - $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
119 | + if (empty($this->pg_put_data_prep)) { |
|
120 | + $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
114 | 121 | 'INSERT INTO ' . $db_prefix . 'cache(key,value,ttl) VALUES($1,$2,$3) |
115 | 122 | ON CONFLICT(key) DO UPDATE SET value = excluded.value, ttl = excluded.ttl' |
116 | 123 | ); |
124 | + } |
|
117 | 125 | |
118 | 126 | $result = pg_execute($db_connection, 'smf_cache_put_data', array($key, $value, $ttl)); |
119 | 127 | |
120 | - if (pg_affected_rows($result) > 0) |
|
121 | - return true; |
|
122 | - else |
|
123 | - return false; |
|
128 | + if (pg_affected_rows($result) > 0) { |
|
129 | + return true; |
|
130 | + } else { |
|
131 | + return false; |
|
132 | + } |
|
124 | 133 | } |
125 | 134 | |
126 | 135 | /** |