@@ -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 news dispatcher; doesn't do anything, just delegates. |
@@ -67,8 +68,9 @@ discard block |
||
67 | 68 | ); |
68 | 69 | |
69 | 70 | // Force the right area... |
70 | - if (substr($_REQUEST['sa'], 0, 7) == 'mailing') |
|
71 | - $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
71 | + if (substr($_REQUEST['sa'], 0, 7) == 'mailing') { |
|
72 | + $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
73 | + } |
|
72 | 74 | |
73 | 75 | call_helper($subActions[$_REQUEST['sa']][0]); |
74 | 76 | } |
@@ -99,9 +101,10 @@ discard block |
||
99 | 101 | $temp_news = explode("\n", $modSettings['news']); |
100 | 102 | |
101 | 103 | // Remove the items that were selected. |
102 | - foreach ($temp_news as $i => $news) |
|
103 | - if (in_array($i, $_POST['remove'])) |
|
104 | + foreach ($temp_news as $i => $news) { |
|
105 | + if (in_array($i, $_POST['remove'])) |
|
104 | 106 | unset($temp_news[$i]); |
107 | + } |
|
105 | 108 | |
106 | 109 | // Update the database. |
107 | 110 | updateSettings(array('news' => implode("\n", $temp_news))); |
@@ -117,9 +120,9 @@ discard block |
||
117 | 120 | |
118 | 121 | foreach ($_POST['news'] as $i => $news) |
119 | 122 | { |
120 | - if (trim($news) == '') |
|
121 | - unset($_POST['news'][$i]); |
|
122 | - else |
|
123 | + if (trim($news) == '') { |
|
124 | + unset($_POST['news'][$i]); |
|
125 | + } else |
|
123 | 126 | { |
124 | 127 | $_POST['news'][$i] = $smcFunc['htmlspecialchars']($_POST['news'][$i], ENT_QUOTES); |
125 | 128 | preparsecode($_POST['news'][$i]); |
@@ -155,12 +158,13 @@ discard block |
||
155 | 158 | 'data' => array( |
156 | 159 | 'function' => function($news) |
157 | 160 | { |
158 | - if (is_numeric($news['id'])) |
|
159 | - return ' |
|
161 | + if (is_numeric($news['id'])) { |
|
162 | + return ' |
|
160 | 163 | <textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea> |
161 | 164 | <div class="floatleft" id="preview_' . $news['id'] . '"></div>'; |
162 | - else |
|
163 | - return $news['unparsed']; |
|
165 | + } else { |
|
166 | + return $news['unparsed']; |
|
167 | + } |
|
164 | 168 | }, |
165 | 169 | 'class' => 'half_table', |
166 | 170 | ), |
@@ -186,10 +190,11 @@ discard block |
||
186 | 190 | 'data' => array( |
187 | 191 | 'function' => function($news) |
188 | 192 | { |
189 | - if (is_numeric($news['id'])) |
|
190 | - return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">'; |
|
191 | - else |
|
192 | - return ''; |
|
193 | + if (is_numeric($news['id'])) { |
|
194 | + return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">'; |
|
195 | + } else { |
|
196 | + return ''; |
|
197 | + } |
|
193 | 198 | }, |
194 | 199 | 'class' => 'centercol icon', |
195 | 200 | ), |
@@ -283,12 +288,13 @@ discard block |
||
283 | 288 | |
284 | 289 | $admin_current_news = array(); |
285 | 290 | // Ready the current news. |
286 | - foreach (explode("\n", $modSettings['news']) as $id => $line) |
|
287 | - $admin_current_news[$id] = array( |
|
291 | + foreach (explode("\n", $modSettings['news']) as $id => $line) { |
|
292 | + $admin_current_news[$id] = array( |
|
288 | 293 | 'id' => $id, |
289 | 294 | 'unparsed' => un_preparsecode($line), |
290 | 295 | 'parsed' => preg_replace('~<([/]?)form[^>]*?[>]*>~i', '<em class="smalltext"><$1form></em>', parse_bbc($line)), |
291 | 296 | ); |
297 | + } |
|
292 | 298 | |
293 | 299 | $admin_current_news['last'] = array( |
294 | 300 | 'id' => 'last', |
@@ -355,10 +361,11 @@ discard block |
||
355 | 361 | 'member_count' => 0, |
356 | 362 | ); |
357 | 363 | |
358 | - if ($row['min_posts'] == -1) |
|
359 | - $normalGroups[$row['id_group']] = $row['id_group']; |
|
360 | - else |
|
361 | - $postGroups[$row['id_group']] = $row['id_group']; |
|
364 | + if ($row['min_posts'] == -1) { |
|
365 | + $normalGroups[$row['id_group']] = $row['id_group']; |
|
366 | + } else { |
|
367 | + $postGroups[$row['id_group']] = $row['id_group']; |
|
368 | + } |
|
362 | 369 | } |
363 | 370 | $smcFunc['db_free_result']($request); |
364 | 371 | |
@@ -374,8 +381,9 @@ discard block |
||
374 | 381 | 'post_group_list' => $postGroups, |
375 | 382 | ) |
376 | 383 | ); |
377 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
378 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
384 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
385 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
386 | + } |
|
379 | 387 | $smcFunc['db_free_result']($query); |
380 | 388 | } |
381 | 389 | |
@@ -391,8 +399,9 @@ discard block |
||
391 | 399 | 'normal_group_list' => $normalGroups, |
392 | 400 | ) |
393 | 401 | ); |
394 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
395 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
402 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
403 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
404 | + } |
|
396 | 405 | $smcFunc['db_free_result']($query); |
397 | 406 | |
398 | 407 | // Also do those who have it as an additional membergroup - this ones more yucky... |
@@ -409,8 +418,9 @@ discard block |
||
409 | 418 | 'blank_string' => '', |
410 | 419 | ) |
411 | 420 | ); |
412 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
413 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
421 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
422 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
423 | + } |
|
414 | 424 | $smcFunc['db_free_result']($query); |
415 | 425 | } |
416 | 426 | |
@@ -461,10 +471,11 @@ discard block |
||
461 | 471 | { |
462 | 472 | $context[$key] = !empty($_REQUEST[$post]) ? $_REQUEST[$post] : ''; |
463 | 473 | |
464 | - if (empty($context[$key]) && empty($_REQUEST['xml'])) |
|
465 | - $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
466 | - elseif (!empty($_REQUEST['xml'])) |
|
467 | - continue; |
|
474 | + if (empty($context[$key]) && empty($_REQUEST['xml'])) { |
|
475 | + $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
476 | + } elseif (!empty($_REQUEST['xml'])) { |
|
477 | + continue; |
|
478 | + } |
|
468 | 479 | |
469 | 480 | preparsecode($context[$key]); |
470 | 481 | if ($html) |
@@ -543,10 +554,12 @@ discard block |
||
543 | 554 | |
544 | 555 | // Start by finding any members! |
545 | 556 | $toClean = array(); |
546 | - if (!empty($_POST['members'])) |
|
547 | - $toClean[] = 'members'; |
|
548 | - if (!empty($_POST['exclude_members'])) |
|
549 | - $toClean[] = 'exclude_members'; |
|
557 | + if (!empty($_POST['members'])) { |
|
558 | + $toClean[] = 'members'; |
|
559 | + } |
|
560 | + if (!empty($_POST['exclude_members'])) { |
|
561 | + $toClean[] = 'exclude_members'; |
|
562 | + } |
|
550 | 563 | if (!empty($toClean)) |
551 | 564 | { |
552 | 565 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -558,11 +571,13 @@ discard block |
||
558 | 571 | preg_match_all('~"([^"]+)"~', $_POST[$type], $matches); |
559 | 572 | $_POST[$type] = array_unique(array_merge($matches[1], explode(',', preg_replace('~"[^"]+"~', '', $_POST[$type])))); |
560 | 573 | |
561 | - foreach ($_POST[$type] as $index => $member) |
|
562 | - if (strlen(trim($member)) > 0) |
|
574 | + foreach ($_POST[$type] as $index => $member) { |
|
575 | + if (strlen(trim($member)) > 0) |
|
563 | 576 | $_POST[$type][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($member))); |
564 | - else |
|
565 | - unset($_POST[$type][$index]); |
|
577 | + } |
|
578 | + else { |
|
579 | + unset($_POST[$type][$index]); |
|
580 | + } |
|
566 | 581 | |
567 | 582 | // Find the members |
568 | 583 | $_POST[$type] = implode(',', array_keys(findMembers($_POST[$type]))); |
@@ -572,16 +587,18 @@ discard block |
||
572 | 587 | if (isset($_POST['member_list']) && is_array($_POST['member_list'])) |
573 | 588 | { |
574 | 589 | $members = array(); |
575 | - foreach ($_POST['member_list'] as $member_id) |
|
576 | - $members[] = (int) $member_id; |
|
590 | + foreach ($_POST['member_list'] as $member_id) { |
|
591 | + $members[] = (int) $member_id; |
|
592 | + } |
|
577 | 593 | $_POST['members'] = implode(',', $members); |
578 | 594 | } |
579 | 595 | |
580 | 596 | if (isset($_POST['exclude_member_list']) && is_array($_POST['exclude_member_list'])) |
581 | 597 | { |
582 | 598 | $members = array(); |
583 | - foreach ($_POST['exclude_member_list'] as $member_id) |
|
584 | - $members[] = (int) $member_id; |
|
599 | + foreach ($_POST['exclude_member_list'] as $member_id) { |
|
600 | + $members[] = (int) $member_id; |
|
601 | + } |
|
585 | 602 | $_POST['exclude_members'] = implode(',', $members); |
586 | 603 | } |
587 | 604 | |
@@ -605,8 +622,9 @@ discard block |
||
605 | 622 | 'current_time' => time(), |
606 | 623 | ) |
607 | 624 | ); |
608 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
609 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
625 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
626 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
627 | + } |
|
610 | 628 | $smcFunc['db_free_result']($request); |
611 | 629 | |
612 | 630 | $request = $smcFunc['db_query']('', ' |
@@ -641,8 +659,9 @@ discard block |
||
641 | 659 | WHERE email_address IN(' . implode(', ', $condition_array) . ')', |
642 | 660 | $condition_array_params |
643 | 661 | ); |
644 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
645 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
662 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
663 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
664 | + } |
|
646 | 665 | $smcFunc['db_free_result']($request); |
647 | 666 | } |
648 | 667 | |
@@ -660,10 +679,11 @@ discard block |
||
660 | 679 | ); |
661 | 680 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
662 | 681 | { |
663 | - if (in_array(3, $context['recipients'])) |
|
664 | - $context['recipients']['exclude_members'][] = $row['identifier']; |
|
665 | - else |
|
666 | - $context['recipients']['members'][] = $row['identifier']; |
|
682 | + if (in_array(3, $context['recipients'])) { |
|
683 | + $context['recipients']['exclude_members'][] = $row['identifier']; |
|
684 | + } else { |
|
685 | + $context['recipients']['members'][] = $row['identifier']; |
|
686 | + } |
|
667 | 687 | } |
668 | 688 | $smcFunc['db_free_result']($request); |
669 | 689 | } |
@@ -710,8 +730,9 @@ discard block |
||
710 | 730 | $num_at_once = 1000; |
711 | 731 | |
712 | 732 | // If by PM's I suggest we half the above number. |
713 | - if (!empty($_POST['send_pm'])) |
|
714 | - $num_at_once /= 2; |
|
733 | + if (!empty($_POST['send_pm'])) { |
|
734 | + $num_at_once /= 2; |
|
735 | + } |
|
715 | 736 | |
716 | 737 | checkSession(); |
717 | 738 | |
@@ -734,8 +755,7 @@ discard block |
||
734 | 755 | ); |
735 | 756 | list ($context['total_members']) = $smcFunc['db_fetch_row']($request); |
736 | 757 | $smcFunc['db_free_result']($request); |
737 | - } |
|
738 | - else |
|
758 | + } else |
|
739 | 759 | { |
740 | 760 | $context['total_members'] = (int) $_REQUEST['total_members']; |
741 | 761 | } |
@@ -753,32 +773,35 @@ discard block |
||
753 | 773 | if (!empty($_POST['exclude_members'])) |
754 | 774 | { |
755 | 775 | $members = explode(',', $_POST['exclude_members']); |
756 | - foreach ($members as $member) |
|
757 | - if ($member >= $context['start']) |
|
776 | + foreach ($members as $member) { |
|
777 | + if ($member >= $context['start']) |
|
758 | 778 | $context['recipients']['exclude_members'][] = (int) $member; |
779 | + } |
|
759 | 780 | } |
760 | 781 | |
761 | 782 | // What about members we *must* do? |
762 | 783 | if (!empty($_POST['members'])) |
763 | 784 | { |
764 | 785 | $members = explode(',', $_POST['members']); |
765 | - foreach ($members as $member) |
|
766 | - if ($member >= $context['start']) |
|
786 | + foreach ($members as $member) { |
|
787 | + if ($member >= $context['start']) |
|
767 | 788 | $context['recipients']['members'][] = (int) $member; |
789 | + } |
|
768 | 790 | } |
769 | 791 | // Cleaning groups is simple - although deal with both checkbox and commas. |
770 | 792 | if (isset($_POST['groups'])) |
771 | 793 | { |
772 | 794 | if (is_array($_POST['groups'])) |
773 | 795 | { |
774 | - foreach ($_POST['groups'] as $group => $dummy) |
|
775 | - $context['recipients']['groups'][] = (int) $group; |
|
776 | - } |
|
777 | - else |
|
796 | + foreach ($_POST['groups'] as $group => $dummy) { |
|
797 | + $context['recipients']['groups'][] = (int) $group; |
|
798 | + } |
|
799 | + } else |
|
778 | 800 | { |
779 | 801 | $groups = explode(',', $_POST['groups']); |
780 | - foreach ($groups as $group) |
|
781 | - $context['recipients']['groups'][] = (int) $group; |
|
802 | + foreach ($groups as $group) { |
|
803 | + $context['recipients']['groups'][] = (int) $group; |
|
804 | + } |
|
782 | 805 | } |
783 | 806 | } |
784 | 807 | // Same for excluded groups |
@@ -786,15 +809,17 @@ discard block |
||
786 | 809 | { |
787 | 810 | if (is_array($_POST['exclude_groups'])) |
788 | 811 | { |
789 | - foreach ($_POST['exclude_groups'] as $group => $dummy) |
|
790 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
812 | + foreach ($_POST['exclude_groups'] as $group => $dummy) { |
|
813 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
814 | + } |
|
791 | 815 | } |
792 | 816 | // Ignore an empty string - we don't want to exclude "Regular Members" unless it's specifically selected |
793 | 817 | elseif ($_POST['exclude_groups'] != '') |
794 | 818 | { |
795 | 819 | $groups = explode(',', $_POST['exclude_groups']); |
796 | - foreach ($groups as $group) |
|
797 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
820 | + foreach ($groups as $group) { |
|
821 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
822 | + } |
|
798 | 823 | } |
799 | 824 | } |
800 | 825 | // Finally - emails! |
@@ -804,14 +829,16 @@ discard block |
||
804 | 829 | foreach ($addressed as $curmem) |
805 | 830 | { |
806 | 831 | $curmem = trim($curmem); |
807 | - if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) |
|
808 | - $context['recipients']['emails'][$curmem] = $curmem; |
|
832 | + if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) { |
|
833 | + $context['recipients']['emails'][$curmem] = $curmem; |
|
834 | + } |
|
809 | 835 | } |
810 | 836 | } |
811 | 837 | |
812 | 838 | // If we're only cleaning drop out here. |
813 | - if ($clean_only) |
|
814 | - return; |
|
839 | + if ($clean_only) { |
|
840 | + return; |
|
841 | + } |
|
815 | 842 | |
816 | 843 | require_once($sourcedir . '/Subs-Post.php'); |
817 | 844 | |
@@ -827,16 +854,18 @@ discard block |
||
827 | 854 | if (!$context['send_pm'] && !empty($_POST['send_html'])) |
828 | 855 | { |
829 | 856 | // Prepare the message for HTML. |
830 | - if (!empty($_POST['parse_html'])) |
|
831 | - $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
857 | + if (!empty($_POST['parse_html'])) { |
|
858 | + $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
859 | + } |
|
832 | 860 | |
833 | 861 | // This is here to prevent spam filters from tagging this as spam. |
834 | 862 | if (preg_match('~\<html~i', $_POST['message']) == 0) |
835 | 863 | { |
836 | - if (preg_match('~\<body~i', $_POST['message']) == 0) |
|
837 | - $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
838 | - else |
|
839 | - $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
864 | + if (preg_match('~\<body~i', $_POST['message']) == 0) { |
|
865 | + $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
866 | + } else { |
|
867 | + $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
868 | + } |
|
840 | 869 | } |
841 | 870 | } |
842 | 871 | |
@@ -890,15 +919,17 @@ discard block |
||
890 | 919 | foreach ($context['recipients']['emails'] as $k => $email) |
891 | 920 | { |
892 | 921 | // Done as many as we can? |
893 | - if ($i >= $num_at_once) |
|
894 | - break; |
|
922 | + if ($i >= $num_at_once) { |
|
923 | + break; |
|
924 | + } |
|
895 | 925 | |
896 | 926 | // Don't sent it twice! |
897 | 927 | unset($context['recipients']['emails'][$k]); |
898 | 928 | |
899 | 929 | // Dammit - can't PM emails! |
900 | - if ($context['send_pm']) |
|
901 | - continue; |
|
930 | + if ($context['send_pm']) { |
|
931 | + continue; |
|
932 | + } |
|
902 | 933 | |
903 | 934 | $to_member = array( |
904 | 935 | $email, |
@@ -932,8 +963,9 @@ discard block |
||
932 | 963 | $queryBuild[] = 'mem.id_post_group = {int:group_' . $group . '}'; |
933 | 964 | } |
934 | 965 | } |
935 | - if (!empty($queryBuild)) |
|
936 | - $sendQuery .= implode(' OR ', $queryBuild); |
|
966 | + if (!empty($queryBuild)) { |
|
967 | + $sendQuery .= implode(' OR ', $queryBuild); |
|
968 | + } |
|
937 | 969 | } |
938 | 970 | if (!empty($context['recipients']['members'])) |
939 | 971 | { |
@@ -952,8 +984,9 @@ discard block |
||
952 | 984 | } |
953 | 985 | |
954 | 986 | // Anything to exclude? |
955 | - if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) |
|
956 | - $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
987 | + if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) { |
|
988 | + $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
989 | + } |
|
957 | 990 | if (!empty($context['recipients']['exclude_members'])) |
958 | 991 | { |
959 | 992 | $sendQuery .= ' AND mem.id_member NOT IN ({array_int:exclude_members})'; |
@@ -989,21 +1022,24 @@ discard block |
||
989 | 1022 | foreach ($rows as $row) |
990 | 1023 | { |
991 | 1024 | // Force them to have it? |
992 | - if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) |
|
993 | - continue; |
|
1025 | + if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) { |
|
1026 | + continue; |
|
1027 | + } |
|
994 | 1028 | |
995 | 1029 | // What groups are we looking at here? |
996 | - if (empty($row['additional_groups'])) |
|
997 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
998 | - else |
|
999 | - $groups = array_merge( |
|
1030 | + if (empty($row['additional_groups'])) { |
|
1031 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
1032 | + } else { |
|
1033 | + $groups = array_merge( |
|
1000 | 1034 | array($row['id_group'], $row['id_post_group']), |
1001 | 1035 | explode(',', $row['additional_groups']) |
1002 | 1036 | ); |
1037 | + } |
|
1003 | 1038 | |
1004 | 1039 | // Excluded groups? |
1005 | - if (array_intersect($groups, $context['recipients']['exclude_groups'])) |
|
1006 | - continue; |
|
1040 | + if (array_intersect($groups, $context['recipients']['exclude_groups'])) { |
|
1041 | + continue; |
|
1042 | + } |
|
1007 | 1043 | |
1008 | 1044 | // We might need this |
1009 | 1045 | $cleanMemberName = empty($_POST['send_html']) || $context['send_pm'] ? un_htmlspecialchars($row['real_name']) : $row['real_name']; |
@@ -1026,10 +1062,11 @@ discard block |
||
1026 | 1062 | ), $_POST['subject']); |
1027 | 1063 | |
1028 | 1064 | // Send the actual email - or a PM! |
1029 | - if (!$context['send_pm']) |
|
1030 | - sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
1031 | - else |
|
1032 | - sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
1065 | + if (!$context['send_pm']) { |
|
1066 | + sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
1067 | + } else { |
|
1068 | + sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
1069 | + } |
|
1033 | 1070 | } |
1034 | 1071 | } |
1035 | 1072 | |
@@ -1079,8 +1116,9 @@ discard block |
||
1079 | 1116 | |
1080 | 1117 | call_integration_hook('integrate_modify_news_settings', array(&$config_vars)); |
1081 | 1118 | |
1082 | - if ($return_config) |
|
1083 | - return $config_vars; |
|
1119 | + if ($return_config) { |
|
1120 | + return $config_vars; |
|
1121 | + } |
|
1084 | 1122 | |
1085 | 1123 | $context['page_title'] = $txt['admin_edit_news'] . ' - ' . $txt['settings']; |
1086 | 1124 | $context['sub_template'] = 'show_settings'; |
@@ -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 |
@@ -49,8 +50,9 @@ discard block |
||
49 | 50 | |
50 | 51 | $result = pg_execute($db_connection, '', array('public', $db_prefix . 'cache')); |
51 | 52 | |
52 | - if (pg_affected_rows($result) === 0) |
|
53 | - pg_query($db_connection, 'CREATE UNLOGGED TABLE ' . $db_prefix . 'cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
53 | + if (pg_affected_rows($result) === 0) { |
|
54 | + pg_query($db_connection, 'CREATE UNLOGGED TABLE ' . $db_prefix . 'cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
55 | + } |
|
54 | 56 | } |
55 | 57 | |
56 | 58 | /** |
@@ -60,14 +62,16 @@ discard block |
||
60 | 62 | { |
61 | 63 | global $smcFunc, $db_connection; |
62 | 64 | |
63 | - if ($smcFunc['db_title'] !== 'PostgreSQL') |
|
64 | - return false; |
|
65 | + if ($smcFunc['db_title'] !== 'PostgreSQL') { |
|
66 | + return false; |
|
67 | + } |
|
65 | 68 | |
66 | 69 | $result = pg_query($db_connection, 'SHOW server_version_num'); |
67 | 70 | $res = pg_fetch_assoc($result); |
68 | 71 | |
69 | - if ($res['server_version_num'] < 90500) |
|
70 | - return false; |
|
72 | + if ($res['server_version_num'] < 90500) { |
|
73 | + return false; |
|
74 | + } |
|
71 | 75 | |
72 | 76 | return $test ? true : parent::isSupported(); |
73 | 77 | } |
@@ -81,13 +85,15 @@ discard block |
||
81 | 85 | |
82 | 86 | $ttl = time() - $ttl; |
83 | 87 | |
84 | - if (empty($this->pg_get_data_prep)) |
|
85 | - $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'); |
|
88 | + if (empty($this->pg_get_data_prep)) { |
|
89 | + $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'); |
|
90 | + } |
|
86 | 91 | |
87 | 92 | $result = pg_execute($db_connection, 'smf_cache_get_data', array($key, $ttl)); |
88 | 93 | |
89 | - if (pg_affected_rows($result) === 0) |
|
90 | - return null; |
|
94 | + if (pg_affected_rows($result) === 0) { |
|
95 | + return null; |
|
96 | + } |
|
91 | 97 | |
92 | 98 | $res = pg_fetch_assoc($result); |
93 | 99 | |
@@ -101,23 +107,26 @@ discard block |
||
101 | 107 | { |
102 | 108 | global $db_prefix, $db_connection; |
103 | 109 | |
104 | - if (!isset($value)) |
|
105 | - $value = ''; |
|
110 | + if (!isset($value)) { |
|
111 | + $value = ''; |
|
112 | + } |
|
106 | 113 | |
107 | 114 | $ttl = time() + $ttl; |
108 | 115 | |
109 | - if (empty($this->pg_put_data_prep)) |
|
110 | - $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
116 | + if (empty($this->pg_put_data_prep)) { |
|
117 | + $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
111 | 118 | 'INSERT INTO ' . $db_prefix . 'cache(key,value,ttl) VALUES($1,$2,$3) |
112 | 119 | ON CONFLICT(key) DO UPDATE SET value = excluded.value, ttl = excluded.ttl' |
113 | 120 | ); |
121 | + } |
|
114 | 122 | |
115 | 123 | $result = pg_execute($db_connection, 'smf_cache_put_data', array($key, $value, $ttl)); |
116 | 124 | |
117 | - if (pg_affected_rows($result) > 0) |
|
118 | - return true; |
|
119 | - else |
|
120 | - return false; |
|
125 | + if (pg_affected_rows($result) > 0) { |
|
126 | + return true; |
|
127 | + } else { |
|
128 | + return false; |
|
129 | + } |
|
121 | 130 | } |
122 | 131 | |
123 | 132 | /** |
@@ -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 | * SQLite Cache API class |
@@ -68,8 +69,9 @@ discard block |
||
68 | 69 | { |
69 | 70 | $supported = class_exists("SQLite3") && is_writable($this->cachedir); |
70 | 71 | |
71 | - if ($test) |
|
72 | - return $supported; |
|
72 | + if ($test) { |
|
73 | + return $supported; |
|
74 | + } |
|
73 | 75 | |
74 | 76 | return parent::isSupported() && $supported; |
75 | 77 | } |
@@ -84,8 +86,9 @@ discard block |
||
84 | 86 | $result = $this->cacheDB->query($query); |
85 | 87 | |
86 | 88 | $value = null; |
87 | - while ($res = $result->fetchArray(SQLITE3_ASSOC)) |
|
88 | - $value = $res['value']; |
|
89 | + while ($res = $result->fetchArray(SQLITE3_ASSOC)) { |
|
90 | + $value = $res['value']; |
|
91 | + } |
|
89 | 92 | |
90 | 93 | return !empty($value) ? $value : null; |
91 | 94 | } |
@@ -108,10 +111,11 @@ discard block |
||
108 | 111 | */ |
109 | 112 | public function cleanCache($type = '') |
110 | 113 | { |
111 | - if($type == 'expired') |
|
112 | - $query = 'DELETE FROM cache WHERE ttl >= ' . time().';'; |
|
113 | - else |
|
114 | - $query = 'DELETE FROM cache;'; |
|
114 | + if($type == 'expired') { |
|
115 | + $query = 'DELETE FROM cache WHERE ttl >= ' . time().';'; |
|
116 | + } else { |
|
117 | + $query = 'DELETE FROM cache;'; |
|
118 | + } |
|
115 | 119 | |
116 | 120 | $result = $this->cacheDB->exec($query); |
117 | 121 | |
@@ -131,8 +135,9 @@ discard block |
||
131 | 135 | $config_vars[] = $txt['cache_sqlite_settings']; |
132 | 136 | $config_vars[] = array('cachedir_sqlite', $txt['cachedir_sqlite'], 'file', 'text', 36, 'cache_sqlite_cachedir'); |
133 | 137 | |
134 | - if (!isset($context['settings_post_javascript'])) |
|
135 | - $context['settings_post_javascript'] = ''; |
|
138 | + if (!isset($context['settings_post_javascript'])) { |
|
139 | + $context['settings_post_javascript'] = ''; |
|
140 | + } |
|
136 | 141 | |
137 | 142 | $context['settings_post_javascript'] .= ' |
138 | 143 | $("#cache_accelerator").change(function (e) { |
@@ -155,13 +160,15 @@ discard block |
||
155 | 160 | global $cachedir, $cachedir_sqlite; |
156 | 161 | |
157 | 162 | // If its invalid, use SMF's. |
158 | - if (is_null($dir) || !is_writable($dir)) |
|
159 | - if(is_null($cachedir_sqlite) || !is_writable($cachedir_sqlite)) |
|
163 | + if (is_null($dir) || !is_writable($dir)) { |
|
164 | + if(is_null($cachedir_sqlite) || !is_writable($cachedir_sqlite)) |
|
160 | 165 | $this->cachedir = $cachedir; |
161 | - else |
|
162 | - $this->cachedir = $cachedir_sqlite; |
|
163 | - else |
|
164 | - $this->cachedir = $dir; |
|
166 | + } else { |
|
167 | + $this->cachedir = $cachedir_sqlite; |
|
168 | + } |
|
169 | + else { |
|
170 | + $this->cachedir = $dir; |
|
171 | + } |
|
165 | 172 | } |
166 | 173 | |
167 | 174 | /** |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Activate an account. |
@@ -48,8 +49,9 @@ discard block |
||
48 | 49 | logAction('approve_member', array('member' => $memID), 'admin'); |
49 | 50 | |
50 | 51 | // If we are doing approval, update the stats for the member just in case. |
51 | - if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) |
|
52 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
52 | + if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) { |
|
53 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
54 | + } |
|
53 | 55 | |
54 | 56 | // Make sure we update the stats too. |
55 | 57 | updateStats('member', false); |
@@ -76,8 +78,9 @@ discard block |
||
76 | 78 | $issueErrors = array(); |
77 | 79 | |
78 | 80 | // Doesn't hurt to be overly cautious. |
79 | - if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) |
|
80 | - fatal_lang_error('no_access', false); |
|
81 | + if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) { |
|
82 | + fatal_lang_error('no_access', false); |
|
83 | + } |
|
81 | 84 | |
82 | 85 | // Get the base (errors related) stuff done. |
83 | 86 | loadLanguage('Errors'); |
@@ -135,16 +138,18 @@ discard block |
||
135 | 138 | |
136 | 139 | // This cannot be empty! |
137 | 140 | $_POST['warn_reason'] = isset($_POST['warn_reason']) ? trim($_POST['warn_reason']) : ''; |
138 | - if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) |
|
139 | - $issueErrors[] = 'warning_no_reason'; |
|
141 | + if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) { |
|
142 | + $issueErrors[] = 'warning_no_reason'; |
|
143 | + } |
|
140 | 144 | $_POST['warn_reason'] = $smcFunc['htmlspecialchars']($_POST['warn_reason']); |
141 | 145 | |
142 | 146 | $_POST['warning_level'] = (int) $_POST['warning_level']; |
143 | 147 | $_POST['warning_level'] = max(0, min(100, $_POST['warning_level'])); |
144 | - if ($_POST['warning_level'] < $context['min_allowed']) |
|
145 | - $_POST['warning_level'] = $context['min_allowed']; |
|
146 | - elseif ($_POST['warning_level'] > $context['max_allowed']) |
|
147 | - $_POST['warning_level'] = $context['max_allowed']; |
|
148 | + if ($_POST['warning_level'] < $context['min_allowed']) { |
|
149 | + $_POST['warning_level'] = $context['min_allowed']; |
|
150 | + } elseif ($_POST['warning_level'] > $context['max_allowed']) { |
|
151 | + $_POST['warning_level'] = $context['max_allowed']; |
|
152 | + } |
|
148 | 153 | |
149 | 154 | // Do we actually have to issue them with a PM? |
150 | 155 | $id_notice = 0; |
@@ -152,8 +157,9 @@ discard block |
||
152 | 157 | { |
153 | 158 | $_POST['warn_sub'] = trim($_POST['warn_sub']); |
154 | 159 | $_POST['warn_body'] = trim($_POST['warn_body']); |
155 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
156 | - $issueErrors[] = 'warning_notify_blank'; |
|
160 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
161 | + $issueErrors[] = 'warning_notify_blank'; |
|
162 | + } |
|
157 | 163 | // Send the PM? |
158 | 164 | else |
159 | 165 | { |
@@ -190,8 +196,8 @@ discard block |
||
190 | 196 | if (empty($issueErrors)) |
191 | 197 | { |
192 | 198 | // Log what we've done! |
193 | - if (!$context['user']['is_owner']) |
|
194 | - $smcFunc['db_insert']('', |
|
199 | + if (!$context['user']['is_owner']) { |
|
200 | + $smcFunc['db_insert']('', |
|
195 | 201 | '{db_prefix}log_comments', |
196 | 202 | array( |
197 | 203 | 'id_member' => 'int', 'member_name' => 'string', 'comment_type' => 'string', 'id_recipient' => 'int', 'recipient_name' => 'string-255', |
@@ -203,14 +209,14 @@ discard block |
||
203 | 209 | ), |
204 | 210 | array('id_comment') |
205 | 211 | ); |
212 | + } |
|
206 | 213 | |
207 | 214 | // Make the change. |
208 | 215 | updateMemberData($memID, array('warning' => $_POST['warning_level'])); |
209 | 216 | |
210 | 217 | // Leave a lovely message. |
211 | 218 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : $txt['profile_warning_success']; |
212 | - } |
|
213 | - else |
|
219 | + } else |
|
214 | 220 | { |
215 | 221 | // Try to remember some bits. |
216 | 222 | $context['warning_data'] = array( |
@@ -229,8 +235,9 @@ discard block |
||
229 | 235 | { |
230 | 236 | $warning_body = !empty($_POST['warn_body']) ? trim(censorText($_POST['warn_body'])) : ''; |
231 | 237 | $context['preview_subject'] = !empty($_POST['warn_sub']) ? trim($smcFunc['htmlspecialchars']($_POST['warn_sub'])) : ''; |
232 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
233 | - $issueErrors[] = 'warning_notify_blank'; |
|
238 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
239 | + $issueErrors[] = 'warning_notify_blank'; |
|
240 | + } |
|
234 | 241 | |
235 | 242 | if (!empty($_POST['warn_body'])) |
236 | 243 | { |
@@ -254,8 +261,9 @@ discard block |
||
254 | 261 | { |
255 | 262 | // Fill in the suite of errors. |
256 | 263 | $context['post_errors'] = array(); |
257 | - foreach ($issueErrors as $error) |
|
258 | - $context['post_errors'][] = $txt[$error]; |
|
264 | + foreach ($issueErrors as $error) { |
|
265 | + $context['post_errors'][] = $txt[$error]; |
|
266 | + } |
|
259 | 267 | } |
260 | 268 | |
261 | 269 | |
@@ -272,9 +280,10 @@ discard block |
||
272 | 280 | $modSettings['warning_mute'] => $txt['profile_warning_effect_mute'], |
273 | 281 | ); |
274 | 282 | $context['current_level'] = 0; |
275 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
276 | - if ($context['member']['warning'] >= $limit) |
|
283 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
284 | + if ($context['member']['warning'] >= $limit) |
|
277 | 285 | $context['current_level'] = $limit; |
286 | + } |
|
278 | 287 | |
279 | 288 | $listOptions = array( |
280 | 289 | 'id' => 'view_warnings', |
@@ -337,11 +346,12 @@ discard block |
||
337 | 346 | ' . $warning['reason'] . ' |
338 | 347 | </div>'; |
339 | 348 | |
340 | - if (!empty($warning['id_notice'])) |
|
341 | - $ret .= ' |
|
349 | + if (!empty($warning['id_notice'])) { |
|
350 | + $ret .= ' |
|
342 | 351 | <div class="floatright"> |
343 | 352 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $warning['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" rel="noopener" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a> |
344 | 353 | </div>'; |
354 | + } |
|
345 | 355 | |
346 | 356 | return $ret; |
347 | 357 | }, |
@@ -413,8 +423,9 @@ discard block |
||
413 | 423 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
414 | 424 | { |
415 | 425 | // If we're not warning for a message skip any that are. |
416 | - if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) |
|
417 | - continue; |
|
426 | + if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) { |
|
427 | + continue; |
|
428 | + } |
|
418 | 429 | |
419 | 430 | $context['notification_templates'][] = array( |
420 | 431 | 'title' => $row['template_title'], |
@@ -424,16 +435,18 @@ discard block |
||
424 | 435 | $smcFunc['db_free_result']($request); |
425 | 436 | |
426 | 437 | // Setup the "default" templates. |
427 | - foreach (array('spamming', 'offence', 'insulting') as $type) |
|
428 | - $context['notification_templates'][] = array( |
|
438 | + foreach (array('spamming', 'offence', 'insulting') as $type) { |
|
439 | + $context['notification_templates'][] = array( |
|
429 | 440 | 'title' => $txt['profile_warning_notify_title_' . $type], |
430 | 441 | 'body' => sprintf($txt['profile_warning_notify_template_outline' . (!empty($context['warning_for_message']) ? '_post' : '')], $txt['profile_warning_notify_for_' . $type]), |
431 | 442 | ); |
443 | + } |
|
432 | 444 | |
433 | 445 | // Replace all the common variables in the templates. |
434 | - foreach ($context['notification_templates'] as $k => $name) |
|
435 | - $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
436 | -} |
|
446 | + foreach ($context['notification_templates'] as $k => $name) { |
|
447 | + $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
448 | + } |
|
449 | + } |
|
437 | 450 | |
438 | 451 | /** |
439 | 452 | * Get the number of warnings a user has. Callback for $listOptions['get_count'] in issueWarning() |
@@ -517,10 +530,11 @@ discard block |
||
517 | 530 | { |
518 | 531 | global $txt, $context, $modSettings, $cur_profile; |
519 | 532 | |
520 | - if (!$context['user']['is_owner']) |
|
521 | - isAllowedTo('profile_remove_any'); |
|
522 | - elseif (!allowedTo('profile_remove_any')) |
|
523 | - isAllowedTo('profile_remove_own'); |
|
533 | + if (!$context['user']['is_owner']) { |
|
534 | + isAllowedTo('profile_remove_any'); |
|
535 | + } elseif (!allowedTo('profile_remove_any')) { |
|
536 | + isAllowedTo('profile_remove_own'); |
|
537 | + } |
|
524 | 538 | |
525 | 539 | // Permissions for removing stuff... |
526 | 540 | $context['can_delete_posts'] = !$context['user']['is_owner'] && allowedTo('moderate_forum'); |
@@ -547,10 +561,11 @@ discard block |
||
547 | 561 | |
548 | 562 | // @todo Add a way to delete pms as well? |
549 | 563 | |
550 | - if (!$context['user']['is_owner']) |
|
551 | - isAllowedTo('profile_remove_any'); |
|
552 | - elseif (!allowedTo('profile_remove_any')) |
|
553 | - isAllowedTo('profile_remove_own'); |
|
564 | + if (!$context['user']['is_owner']) { |
|
565 | + isAllowedTo('profile_remove_any'); |
|
566 | + } elseif (!allowedTo('profile_remove_any')) { |
|
567 | + isAllowedTo('profile_remove_own'); |
|
568 | + } |
|
554 | 569 | |
555 | 570 | checkSession(); |
556 | 571 | |
@@ -576,8 +591,9 @@ discard block |
||
576 | 591 | list ($another) = $smcFunc['db_fetch_row']($request); |
577 | 592 | $smcFunc['db_free_result']($request); |
578 | 593 | |
579 | - if (empty($another)) |
|
580 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
594 | + if (empty($another)) { |
|
595 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
596 | + } |
|
581 | 597 | } |
582 | 598 | |
583 | 599 | // This file is needed for the deleteMembers function. |
@@ -656,8 +672,9 @@ discard block |
||
656 | 672 | ) |
657 | 673 | ); |
658 | 674 | $topicIDs = array(); |
659 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
660 | - $topicIDs[] = $row['id_topic']; |
|
675 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
676 | + $topicIDs[] = $row['id_topic']; |
|
677 | + } |
|
661 | 678 | $smcFunc['db_free_result']($request); |
662 | 679 | |
663 | 680 | // Actually remove the topics. Ignore recycling if we want to perma-delete things... |
@@ -680,8 +697,9 @@ discard block |
||
680 | 697 | // This could take a while... but ya know it's gonna be worth it in the end. |
681 | 698 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
682 | 699 | { |
683 | - if (function_exists('apache_reset_timeout')) |
|
684 | - @apache_reset_timeout(); |
|
700 | + if (function_exists('apache_reset_timeout')) { |
|
701 | + @apache_reset_timeout(); |
|
702 | + } |
|
685 | 703 | |
686 | 704 | removeMessage($row['id_msg']); |
687 | 705 | } |
@@ -689,8 +707,9 @@ discard block |
||
689 | 707 | } |
690 | 708 | |
691 | 709 | // Only delete this poor members account if they are actually being booted out of camp. |
692 | - if (isset($_POST['deleteAccount'])) |
|
693 | - deleteMembers($memID); |
|
710 | + if (isset($_POST['deleteAccount'])) { |
|
711 | + deleteMembers($memID); |
|
712 | + } |
|
694 | 713 | } |
695 | 714 | // Do they need approval to delete? |
696 | 715 | elseif (!empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum')) |
@@ -741,18 +760,18 @@ discard block |
||
741 | 760 | { |
742 | 761 | foreach ($costs as $duration => $cost) |
743 | 762 | { |
744 | - if ($cost != 0) |
|
745 | - $cost_array[$duration] = $cost; |
|
763 | + if ($cost != 0) { |
|
764 | + $cost_array[$duration] = $cost; |
|
765 | + } |
|
746 | 766 | } |
747 | - } |
|
748 | - else |
|
767 | + } else |
|
749 | 768 | { |
750 | 769 | $cost_array['fixed'] = $costs['fixed']; |
751 | 770 | } |
752 | 771 | |
753 | - if (empty($cost_array)) |
|
754 | - unset($context['subscriptions'][$id]); |
|
755 | - else |
|
772 | + if (empty($cost_array)) { |
|
773 | + unset($context['subscriptions'][$id]); |
|
774 | + } else |
|
756 | 775 | { |
757 | 776 | $context['subscriptions'][$id]['member'] = 0; |
758 | 777 | $context['subscriptions'][$id]['subscribed'] = false; |
@@ -765,13 +784,15 @@ discard block |
||
765 | 784 | foreach ($gateways as $id => $gateway) |
766 | 785 | { |
767 | 786 | $gateways[$id] = new $gateway['display_class'](); |
768 | - if (!$gateways[$id]->gatewayEnabled()) |
|
769 | - unset($gateways[$id]); |
|
787 | + if (!$gateways[$id]->gatewayEnabled()) { |
|
788 | + unset($gateways[$id]); |
|
789 | + } |
|
770 | 790 | } |
771 | 791 | |
772 | 792 | // No gateways yet? |
773 | - if (empty($gateways)) |
|
774 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
793 | + if (empty($gateways)) { |
|
794 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
795 | + } |
|
775 | 796 | |
776 | 797 | // Get the current subscriptions. |
777 | 798 | $request = $smcFunc['db_query']('', ' |
@@ -786,8 +807,9 @@ discard block |
||
786 | 807 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
787 | 808 | { |
788 | 809 | // The subscription must exist! |
789 | - if (!isset($context['subscriptions'][$row['id_subscribe']])) |
|
790 | - continue; |
|
810 | + if (!isset($context['subscriptions'][$row['id_subscribe']])) { |
|
811 | + continue; |
|
812 | + } |
|
791 | 813 | |
792 | 814 | $context['current'][$row['id_subscribe']] = array( |
793 | 815 | 'id' => $row['id_sublog'], |
@@ -801,8 +823,9 @@ discard block |
||
801 | 823 | 'status_text' => $row['status'] == 0 ? ($row['payments_pending'] ? $txt['paid_pending'] : $txt['paid_finished']) : $txt['paid_active'], |
802 | 824 | ); |
803 | 825 | |
804 | - if ($row['status'] == 1) |
|
805 | - $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
826 | + if ($row['status'] == 1) { |
|
827 | + $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
828 | + } |
|
806 | 829 | } |
807 | 830 | $smcFunc['db_free_result']($request); |
808 | 831 | |
@@ -853,21 +876,25 @@ discard block |
||
853 | 876 | if (isset($_GET['confirm']) && isset($_POST['sub_id']) && is_array($_POST['sub_id'])) |
854 | 877 | { |
855 | 878 | // Hopefully just one. |
856 | - foreach ($_POST['sub_id'] as $k => $v) |
|
857 | - $ID_SUB = (int) $k; |
|
879 | + foreach ($_POST['sub_id'] as $k => $v) { |
|
880 | + $ID_SUB = (int) $k; |
|
881 | + } |
|
858 | 882 | |
859 | - if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) |
|
860 | - fatal_lang_error('paid_sub_not_active'); |
|
883 | + if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) { |
|
884 | + fatal_lang_error('paid_sub_not_active'); |
|
885 | + } |
|
861 | 886 | |
862 | 887 | // Simplify... |
863 | 888 | $context['sub'] = $context['subscriptions'][$ID_SUB]; |
864 | 889 | $period = 'xx'; |
865 | - if ($context['sub']['flexible']) |
|
866 | - $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
890 | + if ($context['sub']['flexible']) { |
|
891 | + $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
892 | + } |
|
867 | 893 | |
868 | 894 | // Check we have a valid cost. |
869 | - if ($context['sub']['flexible'] && $period == 'xx') |
|
870 | - fatal_lang_error('paid_sub_not_active'); |
|
895 | + if ($context['sub']['flexible'] && $period == 'xx') { |
|
896 | + fatal_lang_error('paid_sub_not_active'); |
|
897 | + } |
|
871 | 898 | |
872 | 899 | // Sort out the cost/currency. |
873 | 900 | $context['currency'] = $modSettings['paid_currency_code']; |
@@ -880,8 +907,7 @@ discard block |
||
880 | 907 | $context['cost'] = sprintf($modSettings['paid_currency_symbol'], $context['value']) . '/' . $txt[$_POST['cur'][$ID_SUB]]; |
881 | 908 | // The period value for paypal. |
882 | 909 | $context['paypal_period'] = strtoupper(substr($_POST['cur'][$ID_SUB], 0, 1)); |
883 | - } |
|
884 | - else |
|
910 | + } else |
|
885 | 911 | { |
886 | 912 | // Real cost... |
887 | 913 | $context['value'] = $context['sub']['costs']['fixed']; |
@@ -898,13 +924,15 @@ discard block |
||
898 | 924 | foreach ($gateways as $id => $gateway) |
899 | 925 | { |
900 | 926 | $fields = $gateways[$id]->fetchGatewayFields($context['sub']['id'] . '+' . $memID, $context['sub'], $context['value'], $period, $scripturl . '?action=profile;u=' . $memID . ';area=subscriptions;sub_id=' . $context['sub']['id'] . ';done'); |
901 | - if (!empty($fields['form'])) |
|
902 | - $context['gateways'][] = $fields; |
|
927 | + if (!empty($fields['form'])) { |
|
928 | + $context['gateways'][] = $fields; |
|
929 | + } |
|
903 | 930 | } |
904 | 931 | |
905 | 932 | // Bugger?! |
906 | - if (empty($context['gateways'])) |
|
907 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
933 | + if (empty($context['gateways'])) { |
|
934 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
935 | + } |
|
908 | 936 | |
909 | 937 | // Now we are going to assume they want to take this out ;) |
910 | 938 | $new_data = array($context['sub']['id'], $context['value'], $period, 'prepay'); |
@@ -912,16 +940,19 @@ discard block |
||
912 | 940 | { |
913 | 941 | // What are the details like? |
914 | 942 | $current_pending = array(); |
915 | - if ($context['current'][$context['sub']['id']]['pending_details'] != '') |
|
916 | - $current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true); |
|
943 | + if ($context['current'][$context['sub']['id']]['pending_details'] != '') { |
|
944 | + $current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true); |
|
945 | + } |
|
917 | 946 | // Don't get silly. |
918 | - if (count($current_pending) > 9) |
|
919 | - $current_pending = array(); |
|
947 | + if (count($current_pending) > 9) { |
|
948 | + $current_pending = array(); |
|
949 | + } |
|
920 | 950 | $pending_count = 0; |
921 | 951 | // Only record real pending payments as will otherwise confuse the admin! |
922 | - foreach ($current_pending as $pending) |
|
923 | - if ($pending[3] == 'payback') |
|
952 | + foreach ($current_pending as $pending) { |
|
953 | + if ($pending[3] == 'payback') |
|
924 | 954 | $pending_count++; |
955 | + } |
|
925 | 956 | |
926 | 957 | if (!in_array($new_data, $current_pending)) |
927 | 958 | { |
@@ -966,9 +997,9 @@ discard block |
||
966 | 997 | |
967 | 998 | // Quit. |
968 | 999 | return; |
1000 | + } else { |
|
1001 | + $context['sub_template'] = 'user_subscription'; |
|
1002 | + } |
|
969 | 1003 | } |
970 | - else |
|
971 | - $context['sub_template'] = 'user_subscription'; |
|
972 | -} |
|
973 | 1004 | |
974 | 1005 | ?> |
975 | 1006 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Entry point for the moderation center. |
@@ -26,8 +27,9 @@ discard block |
||
26 | 27 | global $smcFunc, $txt, $context, $scripturl, $modSettings, $user_info, $sourcedir, $options; |
27 | 28 | |
28 | 29 | // Don't run this twice... and don't conflict with the admin bar. |
29 | - if (isset($context['admin_area'])) |
|
30 | - return; |
|
30 | + if (isset($context['admin_area'])) { |
|
31 | + return; |
|
32 | + } |
|
31 | 33 | |
32 | 34 | $context['can_moderate_boards'] = $user_info['mod_cache']['bq'] != '0=1'; |
33 | 35 | $context['can_moderate_groups'] = $user_info['mod_cache']['gq'] != '0=1'; |
@@ -35,8 +37,9 @@ discard block |
||
35 | 37 | $context['can_moderate_users'] = allowedTo('moderate_forum'); |
36 | 38 | |
37 | 39 | // Everyone using this area must be allowed here! |
38 | - if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) |
|
39 | - isAllowedTo('access_mod_center'); |
|
40 | + if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) { |
|
41 | + isAllowedTo('access_mod_center'); |
|
42 | + } |
|
40 | 43 | |
41 | 44 | // We're gonna want a menu of some kind. |
42 | 45 | require_once($sourcedir . '/Subs-Menu.php'); |
@@ -195,8 +198,9 @@ discard block |
||
195 | 198 | unset($moderation_areas); |
196 | 199 | |
197 | 200 | // We got something - didn't we? DIDN'T WE! |
198 | - if ($mod_include_data == false) |
|
199 | - fatal_lang_error('no_access', false); |
|
201 | + if ($mod_include_data == false) { |
|
202 | + fatal_lang_error('no_access', false); |
|
203 | + } |
|
200 | 204 | |
201 | 205 | // Retain the ID information in case required by a subaction. |
202 | 206 | $context['moderation_menu_id'] = $context['max_menu_id']; |
@@ -219,22 +223,25 @@ discard block |
||
219 | 223 | 'url' => $scripturl . '?action=moderate', |
220 | 224 | 'name' => $txt['moderation_center'], |
221 | 225 | ); |
222 | - if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') |
|
223 | - $context['linktree'][] = array( |
|
226 | + if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') { |
|
227 | + $context['linktree'][] = array( |
|
224 | 228 | 'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'], |
225 | 229 | 'name' => $mod_include_data['label'], |
226 | 230 | ); |
227 | - if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) |
|
228 | - $context['linktree'][] = array( |
|
231 | + } |
|
232 | + if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) { |
|
233 | + $context['linktree'][] = array( |
|
229 | 234 | 'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'] . ';sa=' . $mod_include_data['current_subsection'], |
230 | 235 | 'name' => $mod_include_data['subsections'][$mod_include_data['current_subsection']][0], |
231 | 236 | ); |
237 | + } |
|
232 | 238 | |
233 | 239 | // Now - finally - the bit before the encore - the main performance of course! |
234 | 240 | if (!$dont_call) |
235 | 241 | { |
236 | - if (isset($mod_include_data['file'])) |
|
237 | - require_once($sourcedir . '/' . $mod_include_data['file']); |
|
242 | + if (isset($mod_include_data['file'])) { |
|
243 | + require_once($sourcedir . '/' . $mod_include_data['file']); |
|
244 | + } |
|
238 | 245 | |
239 | 246 | call_helper($mod_include_data['function']); |
240 | 247 | } |
@@ -259,8 +266,9 @@ discard block |
||
259 | 266 | // Load what blocks the user actually can see... |
260 | 267 | $valid_blocks = array(); |
261 | 268 | |
262 | - if ($context['can_moderate_groups']) |
|
263 | - $valid_blocks['g'] = 'GroupRequests'; |
|
269 | + if ($context['can_moderate_groups']) { |
|
270 | + $valid_blocks['g'] = 'GroupRequests'; |
|
271 | + } |
|
264 | 272 | if ($context['can_moderate_boards']) |
265 | 273 | { |
266 | 274 | $valid_blocks['r'] = 'ReportedPosts'; |
@@ -269,8 +277,9 @@ discard block |
||
269 | 277 | if ($context['can_moderate_users']) |
270 | 278 | { |
271 | 279 | // This falls under the category of moderating users as well... |
272 | - if (!$context['can_moderate_boards']) |
|
273 | - $valid_blocks['w'] = 'WatchedUsers'; |
|
280 | + if (!$context['can_moderate_boards']) { |
|
281 | + $valid_blocks['w'] = 'WatchedUsers'; |
|
282 | + } |
|
274 | 283 | |
275 | 284 | $valid_blocks['rm'] = 'ReportedMembers'; |
276 | 285 | } |
@@ -281,8 +290,9 @@ discard block |
||
281 | 290 | foreach ($valid_blocks as $k => $block) |
282 | 291 | { |
283 | 292 | $block = 'ModBlock' . $block; |
284 | - if (function_exists($block)) |
|
285 | - $context['mod_blocks'][] = $block(); |
|
293 | + if (function_exists($block)) { |
|
294 | + $context['mod_blocks'][] = $block(); |
|
295 | + } |
|
286 | 296 | } |
287 | 297 | |
288 | 298 | $context['admin_prefs'] = !empty($options['admin_preferences']) ? $smcFunc['json_decode']($options['admin_preferences'], true) : array(); |
@@ -309,8 +319,9 @@ discard block |
||
309 | 319 | ) |
310 | 320 | ); |
311 | 321 | $watched_users = array(); |
312 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
313 | - $watched_users[] = $row; |
|
322 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
323 | + $watched_users[] = $row; |
|
324 | + } |
|
314 | 325 | $smcFunc['db_free_result']($request); |
315 | 326 | |
316 | 327 | cache_put_data('recent_user_watches', $watched_users, 240); |
@@ -402,8 +413,9 @@ discard block |
||
402 | 413 | $note_owner = $smcFunc['db_num_rows']($get_owner); |
403 | 414 | $smcFunc['db_free_result']($get_owner); |
404 | 415 | |
405 | - if (empty($note_owner)) |
|
406 | - fatal_lang_error('mc_notes_delete_own', false); |
|
416 | + if (empty($note_owner)) { |
|
417 | + fatal_lang_error('mc_notes_delete_own', false); |
|
418 | + } |
|
407 | 419 | } |
408 | 420 | |
409 | 421 | // Lets delete it. |
@@ -460,12 +472,14 @@ discard block |
||
460 | 472 | ) |
461 | 473 | ); |
462 | 474 | $moderator_notes = array(); |
463 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
464 | - $moderator_notes[] = $row; |
|
475 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
476 | + $moderator_notes[] = $row; |
|
477 | + } |
|
465 | 478 | $smcFunc['db_free_result']($request); |
466 | 479 | |
467 | - if ($offset == 0) |
|
468 | - cache_put_data('moderator_notes', $moderator_notes, 240); |
|
480 | + if ($offset == 0) { |
|
481 | + cache_put_data('moderator_notes', $moderator_notes, 240); |
|
482 | + } |
|
469 | 483 | } |
470 | 484 | |
471 | 485 | // Lets construct a page index. |
@@ -504,8 +518,9 @@ discard block |
||
504 | 518 | // Got the info already? |
505 | 519 | $cachekey = md5($smcFunc['json_encode']($user_info['mod_cache']['bq'])); |
506 | 520 | $context['reported_posts'] = array(); |
507 | - if ($user_info['mod_cache']['bq'] == '0=1') |
|
508 | - return 'reported_posts_block'; |
|
521 | + if ($user_info['mod_cache']['bq'] == '0=1') { |
|
522 | + return 'reported_posts_block'; |
|
523 | + } |
|
509 | 524 | |
510 | 525 | if (($reported_posts = cache_get_data('reported_posts_' . $cachekey, 90)) === null) |
511 | 526 | { |
@@ -529,8 +544,9 @@ discard block |
||
529 | 544 | ) |
530 | 545 | ); |
531 | 546 | $reported_posts = array(); |
532 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
533 | - $reported_posts[] = $row; |
|
547 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
548 | + $reported_posts[] = $row; |
|
549 | + } |
|
534 | 550 | $smcFunc['db_free_result']($request); |
535 | 551 | |
536 | 552 | // Cache it. |
@@ -568,8 +584,9 @@ discard block |
||
568 | 584 | |
569 | 585 | $context['group_requests'] = array(); |
570 | 586 | // Make sure they can even moderate someone! |
571 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
572 | - return 'group_requests_block'; |
|
587 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
588 | + return 'group_requests_block'; |
|
589 | + } |
|
573 | 590 | |
574 | 591 | // What requests are outstanding? |
575 | 592 | $request = $smcFunc['db_query']('', ' |
@@ -618,8 +635,9 @@ discard block |
||
618 | 635 | // Got the info already? |
619 | 636 | $cachekey = md5($smcFunc['json_encode']((int) allowedTo('moderate_forum'))); |
620 | 637 | $context['reported_users'] = array(); |
621 | - if (!allowedTo('moderate_forum')) |
|
622 | - return 'reported_users_block'; |
|
638 | + if (!allowedTo('moderate_forum')) { |
|
639 | + return 'reported_users_block'; |
|
640 | + } |
|
623 | 641 | |
624 | 642 | if (($reported_users = cache_get_data('reported_users_' . $cachekey, 90)) === null) |
625 | 643 | { |
@@ -642,8 +660,9 @@ discard block |
||
642 | 660 | ) |
643 | 661 | ); |
644 | 662 | $reported_users = array(); |
645 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
646 | - $reported_users[] = $row; |
|
663 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
664 | + $reported_users[] = $row; |
|
665 | + } |
|
647 | 666 | $smcFunc['db_free_result']($request); |
648 | 667 | |
649 | 668 | // Cache it. |
@@ -742,15 +761,15 @@ discard block |
||
742 | 761 | // Time to update. |
743 | 762 | updateSettings(array('last_mod_report_action' => time())); |
744 | 763 | recountOpenReports('members'); |
745 | - } |
|
746 | - elseif (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
764 | + } elseif (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
747 | 765 | { |
748 | 766 | checkSession(); |
749 | 767 | |
750 | 768 | // All the ones to update... |
751 | 769 | $toClose = array(); |
752 | - foreach ($_POST['close'] as $rid) |
|
753 | - $toClose[] = (int) $rid; |
|
770 | + foreach ($_POST['close'] as $rid) { |
|
771 | + $toClose[] = (int) $rid; |
|
772 | + } |
|
754 | 773 | |
755 | 774 | if (!empty($toClose)) |
756 | 775 | { |
@@ -903,8 +922,9 @@ discard block |
||
903 | 922 | global $context, $user_info; |
904 | 923 | |
905 | 924 | // You need to be allowed to moderate groups... |
906 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
907 | - isAllowedTo('manage_membergroups'); |
|
925 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
926 | + isAllowedTo('manage_membergroups'); |
|
927 | + } |
|
908 | 928 | |
909 | 929 | // Load the group templates. |
910 | 930 | loadTemplate('ModerationCenter'); |
@@ -915,8 +935,9 @@ discard block |
||
915 | 935 | 'view' => 'ViewGroups', |
916 | 936 | ); |
917 | 937 | |
918 | - if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) |
|
919 | - $_GET['sa'] = 'view'; |
|
938 | + if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) { |
|
939 | + $_GET['sa'] = 'view'; |
|
940 | + } |
|
920 | 941 | $context['sub_action'] = $_GET['sa']; |
921 | 942 | |
922 | 943 | // Call the relevant function. |
@@ -946,8 +967,9 @@ discard block |
||
946 | 967 | 'id_notice' => $id_notice, |
947 | 968 | ) |
948 | 969 | ); |
949 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
950 | - fatal_lang_error('no_access', false); |
|
970 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
971 | + fatal_lang_error('no_access', false); |
|
972 | + } |
|
951 | 973 | list ($context['notice_body'], $context['notice_subject']) = $smcFunc['db_fetch_row']($request); |
952 | 974 | $smcFunc['db_free_result']($request); |
953 | 975 | |
@@ -984,18 +1006,20 @@ discard block |
||
984 | 1006 | checkSession(!is_array($_REQUEST['delete']) ? 'get' : 'post'); |
985 | 1007 | |
986 | 1008 | $toDelete = array(); |
987 | - if (!is_array($_REQUEST['delete'])) |
|
988 | - $toDelete[] = (int) $_REQUEST['delete']; |
|
989 | - else |
|
990 | - foreach ($_REQUEST['delete'] as $did) |
|
1009 | + if (!is_array($_REQUEST['delete'])) { |
|
1010 | + $toDelete[] = (int) $_REQUEST['delete']; |
|
1011 | + } else { |
|
1012 | + foreach ($_REQUEST['delete'] as $did) |
|
991 | 1013 | $toDelete[] = (int) $did; |
1014 | + } |
|
992 | 1015 | |
993 | 1016 | if (!empty($toDelete)) |
994 | 1017 | { |
995 | 1018 | require_once($sourcedir . '/RemoveTopic.php'); |
996 | 1019 | // If they don't have permission we'll let it error - either way no chance of a security slip here! |
997 | - foreach ($toDelete as $did) |
|
998 | - removeMessage($did); |
|
1020 | + foreach ($toDelete as $did) { |
|
1021 | + removeMessage($did); |
|
1022 | + } |
|
999 | 1023 | } |
1000 | 1024 | } |
1001 | 1025 | |
@@ -1004,20 +1028,21 @@ discard block |
||
1004 | 1028 | { |
1005 | 1029 | $approve_query = ''; |
1006 | 1030 | $delete_boards = array(); |
1007 | - } |
|
1008 | - else |
|
1031 | + } else |
|
1009 | 1032 | { |
1010 | 1033 | // Still obey permissions! |
1011 | 1034 | $approve_boards = boardsAllowedTo('approve_posts'); |
1012 | 1035 | $delete_boards = boardsAllowedTo('delete_any'); |
1013 | 1036 | |
1014 | - if ($approve_boards == array(0)) |
|
1015 | - $approve_query = ''; |
|
1016 | - elseif (!empty($approve_boards)) |
|
1017 | - $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
1037 | + if ($approve_boards == array(0)) { |
|
1038 | + $approve_query = ''; |
|
1039 | + } elseif (!empty($approve_boards)) { |
|
1040 | + $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
1041 | + } |
|
1018 | 1042 | // Nada, zip, etc... |
1019 | - else |
|
1020 | - $approve_query = ' AND 1=0'; |
|
1043 | + else { |
|
1044 | + $approve_query = ' AND 1=0'; |
|
1045 | + } |
|
1021 | 1046 | } |
1022 | 1047 | |
1023 | 1048 | require_once($sourcedir . '/Subs-List.php'); |
@@ -1116,10 +1141,11 @@ discard block |
||
1116 | 1141 | 'data' => array( |
1117 | 1142 | 'function' => function($member) use ($scripturl) |
1118 | 1143 | { |
1119 | - if ($member['last_post_id']) |
|
1120 | - return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
|
1121 | - else |
|
1122 | - return $member['last_post']; |
|
1144 | + if ($member['last_post_id']) { |
|
1145 | + return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
|
1146 | + } else { |
|
1147 | + return $member['last_post']; |
|
1148 | + } |
|
1123 | 1149 | }, |
1124 | 1150 | ), |
1125 | 1151 | ), |
@@ -1247,8 +1273,9 @@ discard block |
||
1247 | 1273 | ) |
1248 | 1274 | ); |
1249 | 1275 | $latest_posts = array(); |
1250 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1251 | - $latest_posts[$row['id_member']] = $row['last_post_id']; |
|
1276 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1277 | + $latest_posts[$row['id_member']] = $row['last_post_id']; |
|
1278 | + } |
|
1252 | 1279 | |
1253 | 1280 | if (!empty($latest_posts)) |
1254 | 1281 | { |
@@ -1439,15 +1466,17 @@ discard block |
||
1439 | 1466 | // Setup the direction stuff... |
1440 | 1467 | $context['order'] = isset($_REQUEST['sort']) && isset($sort_types[$_REQUEST['sort']]) ? $_REQUEST['sort'] : 'member'; |
1441 | 1468 | |
1442 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
1443 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
1444 | - else |
|
1445 | - $search_params_string = $search_params['string']; |
|
1469 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
1470 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
1471 | + } else { |
|
1472 | + $search_params_string = $search_params['string']; |
|
1473 | + } |
|
1446 | 1474 | |
1447 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
1448 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
1449 | - else |
|
1450 | - $search_params_type = $search_params['type']; |
|
1475 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
1476 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
1477 | + } else { |
|
1478 | + $search_params_type = $search_params['type']; |
|
1479 | + } |
|
1451 | 1480 | |
1452 | 1481 | $search_params = array( |
1453 | 1482 | 'string' => $search_params_string, |
@@ -1530,9 +1559,10 @@ discard block |
||
1530 | 1559 | ' . $rowData['reason'] . ' |
1531 | 1560 | </div>'; |
1532 | 1561 | |
1533 | - if (!empty($rowData['id_notice'])) |
|
1534 | - $output .= ' |
|
1562 | + if (!empty($rowData['id_notice'])) { |
|
1563 | + $output .= ' |
|
1535 | 1564 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $rowData['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" rel="noopener" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a>'; |
1565 | + } |
|
1536 | 1566 | return $output; |
1537 | 1567 | }, |
1538 | 1568 | ), |
@@ -1650,9 +1680,9 @@ discard block |
||
1650 | 1680 | global $smcFunc, $modSettings, $context, $txt, $scripturl, $sourcedir, $user_info; |
1651 | 1681 | |
1652 | 1682 | // Submitting a new one? |
1653 | - if (isset($_POST['add'])) |
|
1654 | - return ModifyWarningTemplate(); |
|
1655 | - elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) |
|
1683 | + if (isset($_POST['add'])) { |
|
1684 | + return ModifyWarningTemplate(); |
|
1685 | + } elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) |
|
1656 | 1686 | { |
1657 | 1687 | checkSession(); |
1658 | 1688 | validateToken('mod-wt'); |
@@ -1671,8 +1701,9 @@ discard block |
||
1671 | 1701 | 'current_member' => $user_info['id'], |
1672 | 1702 | ) |
1673 | 1703 | ); |
1674 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1675 | - logAction('delete_warn_template', array('template' => $row['recipient_name'])); |
|
1704 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1705 | + logAction('delete_warn_template', array('template' => $row['recipient_name'])); |
|
1706 | + } |
|
1676 | 1707 | $smcFunc['db_free_result']($request); |
1677 | 1708 | |
1678 | 1709 | // Do the deletes. |
@@ -1963,16 +1994,18 @@ discard block |
||
1963 | 1994 | ); |
1964 | 1995 | |
1965 | 1996 | // If it wasn't visible and now is they've effectively added it. |
1966 | - if ($context['template_data']['personal'] && !$recipient_id) |
|
1967 | - logAction('add_warn_template', array('template' => $_POST['template_title'])); |
|
1997 | + if ($context['template_data']['personal'] && !$recipient_id) { |
|
1998 | + logAction('add_warn_template', array('template' => $_POST['template_title'])); |
|
1999 | + } |
|
1968 | 2000 | // Conversely if they made it personal it's a delete. |
1969 | - elseif (!$context['template_data']['personal'] && $recipient_id) |
|
1970 | - logAction('delete_warn_template', array('template' => $_POST['template_title'])); |
|
2001 | + elseif (!$context['template_data']['personal'] && $recipient_id) { |
|
2002 | + logAction('delete_warn_template', array('template' => $_POST['template_title'])); |
|
2003 | + } |
|
1971 | 2004 | // Otherwise just an edit. |
1972 | - else |
|
1973 | - logAction('modify_warn_template', array('template' => $_POST['template_title'])); |
|
1974 | - } |
|
1975 | - else |
|
2005 | + else { |
|
2006 | + logAction('modify_warn_template', array('template' => $_POST['template_title'])); |
|
2007 | + } |
|
2008 | + } else |
|
1976 | 2009 | { |
1977 | 2010 | $smcFunc['db_insert']('', |
1978 | 2011 | '{db_prefix}log_comments', |
@@ -1992,17 +2025,18 @@ discard block |
||
1992 | 2025 | |
1993 | 2026 | // Get out of town... |
1994 | 2027 | redirectexit('action=moderate;area=warnings;sa=templates'); |
1995 | - } |
|
1996 | - else |
|
2028 | + } else |
|
1997 | 2029 | { |
1998 | 2030 | $context['warning_errors'] = array(); |
1999 | 2031 | $context['template_data']['title'] = !empty($_POST['template_title']) ? $_POST['template_title'] : ''; |
2000 | 2032 | $context['template_data']['body'] = !empty($_POST['template_body']) ? $_POST['template_body'] : $txt['mc_warning_template_body_default']; |
2001 | 2033 | $context['template_data']['personal'] = !empty($_POST['make_personal']); |
2002 | - if (empty($_POST['template_title'])) |
|
2003 | - $context['warning_errors'][] = $txt['mc_warning_template_error_no_title']; |
|
2004 | - if (empty($_POST['template_body'])) |
|
2005 | - $context['warning_errors'][] = $txt['mc_warning_template_error_no_body']; |
|
2034 | + if (empty($_POST['template_title'])) { |
|
2035 | + $context['warning_errors'][] = $txt['mc_warning_template_error_no_title']; |
|
2036 | + } |
|
2037 | + if (empty($_POST['template_body'])) { |
|
2038 | + $context['warning_errors'][] = $txt['mc_warning_template_error_no_body']; |
|
2039 | + } |
|
2006 | 2040 | } |
2007 | 2041 | } |
2008 | 2042 | |
@@ -2047,8 +2081,9 @@ discard block |
||
2047 | 2081 | // Now check other options! |
2048 | 2082 | $pref_binary = 0; |
2049 | 2083 | |
2050 | - if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) |
|
2051 | - $pref_binary |= 4; |
|
2084 | + if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) { |
|
2085 | + $pref_binary |= 4; |
|
2086 | + } |
|
2052 | 2087 | |
2053 | 2088 | // Put it all together. |
2054 | 2089 | $mod_prefs = '0||' . $pref_binary; |
@@ -2072,9 +2107,10 @@ discard block |
||
2072 | 2107 | unset($_SESSION['moderate_time']); |
2073 | 2108 | |
2074 | 2109 | // Clean any moderator tokens as well. |
2075 | - foreach ($_SESSION['token'] as $key => $token) |
|
2076 | - if (strpos($key, '-mod') !== false) |
|
2110 | + foreach ($_SESSION['token'] as $key => $token) { |
|
2111 | + if (strpos($key, '-mod') !== false) |
|
2077 | 2112 | unset($_SESSION['token'][$key]); |
2113 | + } |
|
2078 | 2114 | |
2079 | 2115 | redirectexit(); |
2080 | 2116 | } |
@@ -86,11 +86,12 @@ discard block |
||
86 | 86 | <span class="smalltext"><em>', $txt['find_wildcards'], '</em></span><br>'; |
87 | 87 | |
88 | 88 | // Only offer to search for buddies if we have some! |
89 | - if (!empty($context['show_buddies'])) |
|
90 | - echo ' |
|
89 | + if (!empty($context['show_buddies'])) { |
|
90 | + echo ' |
|
91 | 91 | <span class="smalltext"> |
92 | 92 | <label for="buddies"><input type="checkbox" name="buddies" id="buddies"', !empty($context['buddy_search']) ? ' checked' : '', '> ', $txt['find_buddies'], '</label> |
93 | 93 | </span><br>'; |
94 | + } |
|
94 | 95 | |
95 | 96 | echo ' |
96 | 97 | <div class="padding righttext"> |
@@ -105,20 +106,21 @@ discard block |
||
105 | 106 | <h3 class="catbg">', $txt['find_results'], '</h3> |
106 | 107 | </div>'; |
107 | 108 | |
108 | - if (empty($context['results'])) |
|
109 | - echo ' |
|
109 | + if (empty($context['results'])) { |
|
110 | + echo ' |
|
110 | 111 | <p class="error">', $txt['find_no_results'], '</p>'; |
111 | - else |
|
112 | + } else |
|
112 | 113 | { |
113 | 114 | echo ' |
114 | 115 | <ul class="padding">'; |
115 | 116 | |
116 | - foreach ($context['results'] as $result) |
|
117 | - echo ' |
|
117 | + foreach ($context['results'] as $result) { |
|
118 | + echo ' |
|
118 | 119 | <li class="windowbg"> |
119 | 120 | <a href="', $result['href'], '" target="_blank" rel="noopener"> <span class="generic_icons profile_sm"></span> |
120 | 121 | <a href="javascript:void(0);" onclick="addMember(this.innerHTML); return false;">', $result['name'], '</a> |
121 | 122 | </li>'; |
123 | + } |
|
122 | 124 | |
123 | 125 | echo ' |
124 | 126 | </ul> |
@@ -134,11 +136,12 @@ discard block |
||
134 | 136 | <input type="hidden" name="quote" value="', $context['quote_results'] ? '1' : '0', '"> |
135 | 137 | </form>'; |
136 | 138 | |
137 | - if (empty($context['results'])) |
|
138 | - echo ' |
|
139 | + if (empty($context['results'])) { |
|
140 | + echo ' |
|
139 | 141 | <script> |
140 | 142 | document.getElementById("search").focus(); |
141 | 143 | </script>'; |
144 | + } |
|
142 | 145 | |
143 | 146 | echo ' |
144 | 147 | </body> |
@@ -162,9 +165,10 @@ discard block |
||
162 | 165 | <p>', $txt['manual_introduction'], '</p> |
163 | 166 | <ul>'; |
164 | 167 | |
165 | - foreach ($context['manual_sections'] as $section_id => $wiki_id) |
|
166 | - echo ' |
|
168 | + foreach ($context['manual_sections'] as $section_id => $wiki_id) { |
|
169 | + echo ' |
|
167 | 170 | <li><a href="', $context['wiki_url'], '/', $context['wiki_prefix'], $wiki_id, ($txt['lang_dictionary'] != 'en' ? '/' . $txt['lang_dictionary'] : ''), '" target="_blank" rel="noopener">', $txt['manual_section_' . $section_id . '_title'], '</a> - ', $txt['manual_section_' . $section_id . '_desc'], '</li>'; |
171 | + } |
|
168 | 172 | |
169 | 173 | echo ' |
170 | 174 | </ul> |
@@ -180,8 +184,8 @@ discard block |
||
180 | 184 | { |
181 | 185 | global $txt, $context, $modSettings; |
182 | 186 | |
183 | - if (!empty($modSettings['requireAgreement'])) |
|
184 | - echo ' |
|
187 | + if (!empty($modSettings['requireAgreement'])) { |
|
188 | + echo ' |
|
185 | 189 | <div class="cat_bar"> |
186 | 190 | <h3 class="catbg"> |
187 | 191 | ', $txt['terms_and_rules'], ' - ', $context['forum_name_html_safe'], ' |
@@ -190,11 +194,12 @@ discard block |
||
190 | 194 | <div class="roundframe"> |
191 | 195 | ', $context['agreement'], ' |
192 | 196 | </div>'; |
193 | - else |
|
194 | - echo ' |
|
197 | + } else { |
|
198 | + echo ' |
|
195 | 199 | <div class="noticebox"> |
196 | 200 | ', $txt['agreement_disabled'], ' |
197 | 201 | </div>'; |
198 | -} |
|
202 | + } |
|
203 | + } |
|
199 | 204 | |
200 | 205 | ?> |
201 | 206 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Add the file functions to the $smcFunc array. |
@@ -53,8 +54,9 @@ discard block |
||
53 | 54 | 'messages', 'moderator_groups', 'moderators', 'package_servers', 'permission_profiles', 'permissions', 'personal_messages', |
54 | 55 | 'pm_labeled_messages', 'pm_labels', 'pm_recipients', 'pm_rules', 'poll_choices', 'polls', 'scheduled_tasks', 'sessions', 'settings', 'smileys', |
55 | 56 | 'spiders', 'subscriptions', 'themes', 'topics', 'user_alerts', 'user_alerts_prefs', 'user_drafts', 'user_likes'); |
56 | - foreach ($reservedTables as $k => $table_name) |
|
57 | - $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
57 | + foreach ($reservedTables as $k => $table_name) { |
|
58 | + $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
59 | + } |
|
58 | 60 | |
59 | 61 | // We in turn may need the extra stuff. |
60 | 62 | db_extend('extra'); |
@@ -107,8 +109,9 @@ discard block |
||
107 | 109 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
108 | 110 | |
109 | 111 | // First - no way do we touch SMF tables. |
110 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
111 | - return false; |
|
112 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
113 | + return false; |
|
114 | + } |
|
112 | 115 | |
113 | 116 | // Log that we'll want to remove this on uninstall. |
114 | 117 | $db_package_log[] = array('remove_table', $table_name); |
@@ -118,9 +121,9 @@ discard block |
||
118 | 121 | if (in_array($full_table_name, $tables)) |
119 | 122 | { |
120 | 123 | // This is a sad day... drop the table? If not, return false (error) by default. |
121 | - if ($if_exists == 'overwrite') |
|
122 | - $smcFunc['db_drop_table']($table_name); |
|
123 | - else if ($if_exists == 'update') |
|
124 | + if ($if_exists == 'overwrite') { |
|
125 | + $smcFunc['db_drop_table']($table_name); |
|
126 | + } else if ($if_exists == 'update') |
|
124 | 127 | { |
125 | 128 | $smcFunc['db_drop_table']($table_name.'_old'); |
126 | 129 | $smcFunc['db_transaction']('begin'); |
@@ -132,47 +135,51 @@ discard block |
||
132 | 135 | ) |
133 | 136 | ); |
134 | 137 | $old_table_exists = true; |
138 | + } else { |
|
139 | + return $if_exists == 'ignore'; |
|
135 | 140 | } |
136 | - else |
|
137 | - return $if_exists == 'ignore'; |
|
138 | 141 | } |
139 | 142 | |
140 | 143 | // If we've got this far - good news - no table exists. We can build our own! |
141 | - if (!$db_trans) |
|
142 | - $smcFunc['db_transaction']('begin'); |
|
144 | + if (!$db_trans) { |
|
145 | + $smcFunc['db_transaction']('begin'); |
|
146 | + } |
|
143 | 147 | $table_query = 'CREATE TABLE ' . $table_name . "\n" . '('; |
144 | 148 | foreach ($columns as $column) |
145 | 149 | { |
146 | 150 | // If we have an auto increment do it! |
147 | 151 | if (!empty($column['auto'])) |
148 | 152 | { |
149 | - if (!$old_table_exists) |
|
150 | - $smcFunc['db_query']('', ' |
|
153 | + if (!$old_table_exists) { |
|
154 | + $smcFunc['db_query']('', ' |
|
151 | 155 | DROP SEQUENCE IF EXISTS ' . $table_name . '_seq', |
152 | 156 | array( |
153 | 157 | 'security_override' => true, |
154 | 158 | ) |
155 | 159 | ); |
160 | + } |
|
156 | 161 | |
157 | - if (!$old_table_exists) |
|
158 | - $smcFunc['db_query']('', ' |
|
162 | + if (!$old_table_exists) { |
|
163 | + $smcFunc['db_query']('', ' |
|
159 | 164 | CREATE SEQUENCE ' . $table_name . '_seq', |
160 | 165 | array( |
161 | 166 | 'security_override' => true, |
162 | 167 | ) |
163 | 168 | ); |
169 | + } |
|
164 | 170 | $default = 'default nextval(\'' . $table_name . '_seq\')'; |
171 | + } elseif (isset($column['default']) && $column['default'] !== null) { |
|
172 | + $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
173 | + } else { |
|
174 | + $default = ''; |
|
165 | 175 | } |
166 | - elseif (isset($column['default']) && $column['default'] !== null) |
|
167 | - $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
168 | - else |
|
169 | - $default = ''; |
|
170 | 176 | |
171 | 177 | // Sort out the size... |
172 | 178 | $column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null; |
173 | 179 | list ($type, $size) = $smcFunc['db_calculate_type']($column['type'], $column['size']); |
174 | - if ($size !== null) |
|
175 | - $type = $type . '(' . $size . ')'; |
|
180 | + if ($size !== null) { |
|
181 | + $type = $type . '(' . $size . ')'; |
|
182 | + } |
|
176 | 183 | |
177 | 184 | // Now just put it together! |
178 | 185 | $table_query .= "\n\t\"" . $column['name'] . '" ' . $type . ' ' . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default . ','; |
@@ -185,19 +192,21 @@ discard block |
||
185 | 192 | $columns = implode(',', $index['columns']); |
186 | 193 | |
187 | 194 | // Primary goes in the table... |
188 | - if (isset($index['type']) && $index['type'] == 'primary') |
|
189 | - $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
190 | - else |
|
195 | + if (isset($index['type']) && $index['type'] == 'primary') { |
|
196 | + $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
197 | + } else |
|
191 | 198 | { |
192 | - if (empty($index['name'])) |
|
193 | - $index['name'] = implode('_', $index['columns']); |
|
199 | + if (empty($index['name'])) { |
|
200 | + $index['name'] = implode('_', $index['columns']); |
|
201 | + } |
|
194 | 202 | $index_queries[] = 'CREATE ' . (isset($index['type']) && $index['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $table_name . '_' . $index['name'] . ' ON ' . $table_name . ' (' . $columns . ')'; |
195 | 203 | } |
196 | 204 | } |
197 | 205 | |
198 | 206 | // No trailing commas! |
199 | - if (substr($table_query, -1) == ',') |
|
200 | - $table_query = substr($table_query, 0, -1); |
|
207 | + if (substr($table_query, -1) == ',') { |
|
208 | + $table_query = substr($table_query, 0, -1); |
|
209 | + } |
|
201 | 210 | |
202 | 211 | $table_query .= ')'; |
203 | 212 | |
@@ -242,18 +251,20 @@ discard block |
||
242 | 251 | } |
243 | 252 | |
244 | 253 | // And the indexes... |
245 | - foreach ($index_queries as $query) |
|
246 | - $smcFunc['db_query']('', $query, |
|
254 | + foreach ($index_queries as $query) { |
|
255 | + $smcFunc['db_query']('', $query, |
|
247 | 256 | array( |
248 | 257 | 'security_override' => true, |
249 | 258 | ) |
250 | 259 | ); |
260 | + } |
|
251 | 261 | |
252 | 262 | // Go, go power rangers! |
253 | 263 | $smcFunc['db_transaction']('commit'); |
254 | 264 | |
255 | - if ($old_table_exists) |
|
256 | - $smcFunc['db_drop_table']($table_name . '_old'); |
|
265 | + if ($old_table_exists) { |
|
266 | + $smcFunc['db_drop_table']($table_name . '_old'); |
|
267 | + } |
|
257 | 268 | |
258 | 269 | return true; |
259 | 270 | } |
@@ -278,8 +289,9 @@ discard block |
||
278 | 289 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
279 | 290 | |
280 | 291 | // God no - dropping one of these = bad. |
281 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
282 | - return false; |
|
292 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
293 | + return false; |
|
294 | + } |
|
283 | 295 | |
284 | 296 | // Does it exist? |
285 | 297 | if (in_array($full_table_name, $smcFunc['db_list_tables']())) |
@@ -337,21 +349,24 @@ discard block |
||
337 | 349 | |
338 | 350 | // Does it exist - if so don't add it again! |
339 | 351 | $columns = $smcFunc['db_list_columns']($table_name, false); |
340 | - foreach ($columns as $column) |
|
341 | - if ($column == $column_info['name']) |
|
352 | + foreach ($columns as $column) { |
|
353 | + if ($column == $column_info['name']) |
|
342 | 354 | { |
343 | 355 | // If we're going to overwrite then use change column. |
344 | 356 | if ($if_exists == 'update') |
345 | 357 | return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
346 | - else |
|
347 | - return false; |
|
358 | + } |
|
359 | + else { |
|
360 | + return false; |
|
361 | + } |
|
348 | 362 | } |
349 | 363 | |
350 | 364 | // Get the specifics... |
351 | 365 | $column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null; |
352 | 366 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); |
353 | - if ($size !== null) |
|
354 | - $type = $type . '(' . $size . ')'; |
|
367 | + if ($size !== null) { |
|
368 | + $type = $type . '(' . $size . ')'; |
|
369 | + } |
|
355 | 370 | |
356 | 371 | // Now add the thing! |
357 | 372 | $query = ' |
@@ -366,11 +381,12 @@ discard block |
||
366 | 381 | // If there's more attributes they need to be done via a change on PostgreSQL. |
367 | 382 | unset($column_info['type'], $column_info['size']); |
368 | 383 | |
369 | - if (count($column_info) != 1) |
|
370 | - return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
|
371 | - else |
|
372 | - return true; |
|
373 | -} |
|
384 | + if (count($column_info) != 1) { |
|
385 | + return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
|
386 | + } else { |
|
387 | + return true; |
|
388 | + } |
|
389 | + } |
|
374 | 390 | |
375 | 391 | /** |
376 | 392 | * Removes a column. |
@@ -389,8 +405,8 @@ discard block |
||
389 | 405 | |
390 | 406 | // Does it exist? |
391 | 407 | $columns = $smcFunc['db_list_columns']($table_name, true); |
392 | - foreach ($columns as $column) |
|
393 | - if ($column['name'] == $column_name) |
|
408 | + foreach ($columns as $column) { |
|
409 | + if ($column['name'] == $column_name) |
|
394 | 410 | { |
395 | 411 | // If there is an auto we need remove it! |
396 | 412 | if ($column['auto']) |
@@ -400,6 +416,7 @@ discard block |
||
400 | 416 | 'security_override' => true, |
401 | 417 | ) |
402 | 418 | ); |
419 | + } |
|
403 | 420 | |
404 | 421 | $smcFunc['db_query']('', ' |
405 | 422 | ALTER TABLE ' . $table_name . ' |
@@ -433,13 +450,15 @@ discard block |
||
433 | 450 | // Check it does exist! |
434 | 451 | $columns = $smcFunc['db_list_columns']($table_name, true); |
435 | 452 | $old_info = null; |
436 | - foreach ($columns as $column) |
|
437 | - if ($column['name'] == $old_column) |
|
453 | + foreach ($columns as $column) { |
|
454 | + if ($column['name'] == $old_column) |
|
438 | 455 | $old_info = $column; |
456 | + } |
|
439 | 457 | |
440 | 458 | // Nothing? |
441 | - if ($old_info == null) |
|
442 | - return false; |
|
459 | + if ($old_info == null) { |
|
460 | + return false; |
|
461 | + } |
|
443 | 462 | |
444 | 463 | // Now we check each bit individually and ALTER as required. |
445 | 464 | if (isset($column_info['name']) && $column_info['name'] != $old_column) |
@@ -496,8 +515,9 @@ discard block |
||
496 | 515 | { |
497 | 516 | $column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null; |
498 | 517 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); |
499 | - if ($size !== null) |
|
500 | - $type = $type . '(' . $size . ')'; |
|
518 | + if ($size !== null) { |
|
519 | + $type = $type . '(' . $size . ')'; |
|
520 | + } |
|
501 | 521 | |
502 | 522 | // The alter is a pain. |
503 | 523 | $smcFunc['db_transaction']('begin'); |
@@ -598,21 +618,23 @@ discard block |
||
598 | 618 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
599 | 619 | |
600 | 620 | // No columns = no index. |
601 | - if (empty($index_info['columns'])) |
|
602 | - return false; |
|
621 | + if (empty($index_info['columns'])) { |
|
622 | + return false; |
|
623 | + } |
|
603 | 624 | $columns = implode(',', $index_info['columns']); |
604 | 625 | |
605 | 626 | // No name - make it up! |
606 | 627 | if (empty($index_info['name'])) |
607 | 628 | { |
608 | 629 | // No need for primary. |
609 | - if (isset($index_info['type']) && $index_info['type'] == 'primary') |
|
610 | - $index_info['name'] = ''; |
|
611 | - else |
|
612 | - $index_info['name'] = $table_name . implode('_', $index_info['columns']); |
|
630 | + if (isset($index_info['type']) && $index_info['type'] == 'primary') { |
|
631 | + $index_info['name'] = ''; |
|
632 | + } else { |
|
633 | + $index_info['name'] = $table_name . implode('_', $index_info['columns']); |
|
634 | + } |
|
635 | + } else { |
|
636 | + $index_info['name'] = $table_name . $index_info['name']; |
|
613 | 637 | } |
614 | - else |
|
615 | - $index_info['name'] = $table_name . $index_info['name']; |
|
616 | 638 | |
617 | 639 | // Log that we are going to want to remove this! |
618 | 640 | $db_package_log[] = array('remove_index', $table_name, $index_info['name']); |
@@ -625,10 +647,11 @@ discard block |
||
625 | 647 | if ($index['name'] == $index_info['name'] || ($index['type'] == 'primary' && isset($index_info['type']) && $index_info['type'] == 'primary')) |
626 | 648 | { |
627 | 649 | // If we want to overwrite simply remove the current one then continue. |
628 | - if ($if_exists != 'update' || $index['type'] == 'primary') |
|
629 | - return false; |
|
630 | - else |
|
631 | - $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
650 | + if ($if_exists != 'update' || $index['type'] == 'primary') { |
|
651 | + return false; |
|
652 | + } else { |
|
653 | + $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
654 | + } |
|
632 | 655 | } |
633 | 656 | } |
634 | 657 | |
@@ -642,8 +665,7 @@ discard block |
||
642 | 665 | 'security_override' => true, |
643 | 666 | ) |
644 | 667 | ); |
645 | - } |
|
646 | - else |
|
668 | + } else |
|
647 | 669 | { |
648 | 670 | $smcFunc['db_query']('', ' |
649 | 671 | CREATE ' . (isset($index_info['type']) && $index_info['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $index_info['name'] . ' ON ' . $table_name . ' (' . $columns . ')', |
@@ -671,8 +693,9 @@ discard block |
||
671 | 693 | |
672 | 694 | // Better exist! |
673 | 695 | $indexes = $smcFunc['db_list_indexes']($table_name, true); |
674 | - if ($index_name != 'primary') |
|
675 | - $index_name = $table_name . '_' . $index_name; |
|
696 | + if ($index_name != 'primary') { |
|
697 | + $index_name = $table_name . '_' . $index_name; |
|
698 | + } |
|
676 | 699 | |
677 | 700 | foreach ($indexes as $index) |
678 | 701 | { |
@@ -736,8 +759,7 @@ discard block |
||
736 | 759 | 'datetime' => 'timestamp without time zone', |
737 | 760 | 'timestamp' => 'timestamp without time zone', |
738 | 761 | ); |
739 | - } |
|
740 | - else |
|
762 | + } else |
|
741 | 763 | { |
742 | 764 | $types = array( |
743 | 765 | 'character varying' => 'varchar', |
@@ -753,14 +775,16 @@ discard block |
||
753 | 775 | // Got it? Change it! |
754 | 776 | if (isset($types[$type_name])) |
755 | 777 | { |
756 | - if ($type_name == 'tinytext') |
|
757 | - $type_size = 255; |
|
778 | + if ($type_name == 'tinytext') { |
|
779 | + $type_size = 255; |
|
780 | + } |
|
758 | 781 | $type_name = $types[$type_name]; |
759 | 782 | } |
760 | 783 | |
761 | 784 | // Only char fields got size |
762 | - if (strpos($type_name, 'char') === false) |
|
763 | - $type_size = null; |
|
785 | + if (strpos($type_name, 'char') === false) { |
|
786 | + $type_size = null; |
|
787 | + } |
|
764 | 788 | |
765 | 789 | |
766 | 790 | return array($type_name, $type_size); |
@@ -816,8 +840,7 @@ discard block |
||
816 | 840 | if (!$detail) |
817 | 841 | { |
818 | 842 | $columns[] = $row['column_name']; |
819 | - } |
|
820 | - else |
|
843 | + } else |
|
821 | 844 | { |
822 | 845 | $auto = false; |
823 | 846 | // What is the default? |
@@ -825,11 +848,11 @@ discard block |
||
825 | 848 | { |
826 | 849 | $default = null; |
827 | 850 | $auto = true; |
851 | + } elseif (trim($row['column_default']) != '') { |
|
852 | + $default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::')); |
|
853 | + } else { |
|
854 | + $default = null; |
|
828 | 855 | } |
829 | - elseif (trim($row['column_default']) != '') |
|
830 | - $default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::')); |
|
831 | - else |
|
832 | - $default = null; |
|
833 | 856 | |
834 | 857 | // Make the type generic. |
835 | 858 | list ($type, $size) = $smcFunc['db_calculate_type']($row['data_type'], $row['character_maximum_length'], true); |
@@ -880,26 +903,30 @@ discard block |
||
880 | 903 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
881 | 904 | { |
882 | 905 | // Try get the columns that make it up. |
883 | - if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) |
|
884 | - continue; |
|
906 | + if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) { |
|
907 | + continue; |
|
908 | + } |
|
885 | 909 | |
886 | 910 | $columns = explode(',', $matches[1]); |
887 | 911 | |
888 | - if (empty($columns)) |
|
889 | - continue; |
|
912 | + if (empty($columns)) { |
|
913 | + continue; |
|
914 | + } |
|
890 | 915 | |
891 | - foreach ($columns as $k => $v) |
|
892 | - $columns[$k] = trim($v); |
|
916 | + foreach ($columns as $k => $v) { |
|
917 | + $columns[$k] = trim($v); |
|
918 | + } |
|
893 | 919 | |
894 | 920 | // Fix up the name to be consistent cross databases |
895 | - if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1) |
|
896 | - $row['name'] = 'PRIMARY'; |
|
897 | - else |
|
898 | - $row['name'] = str_replace($table_name . '_', '', $row['name']); |
|
921 | + if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1) { |
|
922 | + $row['name'] = 'PRIMARY'; |
|
923 | + } else { |
|
924 | + $row['name'] = str_replace($table_name . '_', '', $row['name']); |
|
925 | + } |
|
899 | 926 | |
900 | - if (!$detail) |
|
901 | - $indexes[] = $row['name']; |
|
902 | - else |
|
927 | + if (!$detail) { |
|
928 | + $indexes[] = $row['name']; |
|
929 | + } else |
|
903 | 930 | { |
904 | 931 | $indexes[$row['name']] = array( |
905 | 932 | 'name' => $row['name'], |
@@ -1,9 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
6 | -else |
|
6 | +} else { |
|
7 | 7 | exit; |
8 | +} |
|
8 | 9 | |
9 | 10 | ?> |
10 | 11 | \ No newline at end of file |
@@ -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})'); |
@@ -581,13 +593,13 @@ discard block |
||
581 | 593 | ) |
582 | 594 | ); |
583 | 595 | $context['theme_options'] = array(); |
584 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
585 | - $context['theme_options'][$row['variable']] = $row['value']; |
|
596 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
597 | + $context['theme_options'][$row['variable']] = $row['value']; |
|
598 | + } |
|
586 | 599 | $smcFunc['db_free_result']($request); |
587 | 600 | |
588 | 601 | $context['theme_options_reset'] = false; |
589 | - } |
|
590 | - else |
|
602 | + } else |
|
591 | 603 | { |
592 | 604 | $context['theme_options'] = array(); |
593 | 605 | $context['theme_options_reset'] = true; |
@@ -596,30 +608,32 @@ discard block |
||
596 | 608 | foreach ($context['options'] as $i => $setting) |
597 | 609 | { |
598 | 610 | // Just skip separators |
599 | - if (!is_array($setting)) |
|
600 | - continue; |
|
611 | + if (!is_array($setting)) { |
|
612 | + continue; |
|
613 | + } |
|
601 | 614 | |
602 | 615 | // Is this disabled? |
603 | 616 | if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) |
604 | 617 | { |
605 | 618 | unset($context['options'][$i]); |
606 | 619 | continue; |
607 | - } |
|
608 | - elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
620 | + } elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
609 | 621 | { |
610 | 622 | unset($context['options'][$i]); |
611 | 623 | continue; |
612 | 624 | } |
613 | 625 | |
614 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
615 | - $context['options'][$i]['type'] = 'checkbox'; |
|
616 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
617 | - $context['options'][$i]['type'] = 'number'; |
|
618 | - elseif ($setting['type'] == 'string') |
|
619 | - $context['options'][$i]['type'] = 'text'; |
|
626 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
627 | + $context['options'][$i]['type'] = 'checkbox'; |
|
628 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
629 | + $context['options'][$i]['type'] = 'number'; |
|
630 | + } elseif ($setting['type'] == 'string') { |
|
631 | + $context['options'][$i]['type'] = 'text'; |
|
632 | + } |
|
620 | 633 | |
621 | - if (isset($setting['options'])) |
|
622 | - $context['options'][$i]['type'] = 'list'; |
|
634 | + if (isset($setting['options'])) { |
|
635 | + $context['options'][$i]['type'] = 'list'; |
|
636 | + } |
|
623 | 637 | |
624 | 638 | $context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']]; |
625 | 639 | } |
@@ -644,8 +658,9 @@ discard block |
||
644 | 658 | { |
645 | 659 | global $txt, $context, $settings, $modSettings, $smcFunc; |
646 | 660 | |
647 | - if (empty($_GET['th']) && empty($_GET['id'])) |
|
648 | - return ThemeAdmin(); |
|
661 | + if (empty($_GET['th']) && empty($_GET['id'])) { |
|
662 | + return ThemeAdmin(); |
|
663 | + } |
|
649 | 664 | |
650 | 665 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
651 | 666 | |
@@ -656,8 +671,9 @@ discard block |
||
656 | 671 | isAllowedTo('admin_forum'); |
657 | 672 | |
658 | 673 | // Validate inputs/user. |
659 | - if (empty($_GET['th'])) |
|
660 | - fatal_lang_error('no_theme', false); |
|
674 | + if (empty($_GET['th'])) { |
|
675 | + fatal_lang_error('no_theme', false); |
|
676 | + } |
|
661 | 677 | |
662 | 678 | // Fetch the smiley sets... |
663 | 679 | $sets = explode(',', 'none,' . $modSettings['smiley_sets_known']); |
@@ -665,8 +681,9 @@ discard block |
||
665 | 681 | $context['smiley_sets'] = array( |
666 | 682 | '' => $txt['smileys_no_default'] |
667 | 683 | ); |
668 | - foreach ($sets as $i => $set) |
|
669 | - $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
684 | + foreach ($sets as $i => $set) { |
|
685 | + $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
686 | + } |
|
670 | 687 | |
671 | 688 | $old_id = $settings['theme_id']; |
672 | 689 | $old_settings = $settings; |
@@ -691,8 +708,9 @@ discard block |
||
691 | 708 | if (file_exists($settings['theme_dir'] . '/index.template.php')) |
692 | 709 | { |
693 | 710 | $file_contents = implode('', file($settings['theme_dir'] . '/index.template.php')); |
694 | - if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) |
|
695 | - eval('global $settings;' . $matches[0]); |
|
711 | + if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) { |
|
712 | + eval('global $settings;' . $matches[0]); |
|
713 | + } |
|
696 | 714 | } |
697 | 715 | |
698 | 716 | // Let mods hook into the theme settings. |
@@ -704,37 +722,45 @@ discard block |
||
704 | 722 | checkSession(); |
705 | 723 | validateToken('admin-sts'); |
706 | 724 | |
707 | - if (empty($_POST['options'])) |
|
708 | - $_POST['options'] = array(); |
|
709 | - if (empty($_POST['default_options'])) |
|
710 | - $_POST['default_options'] = array(); |
|
725 | + if (empty($_POST['options'])) { |
|
726 | + $_POST['options'] = array(); |
|
727 | + } |
|
728 | + if (empty($_POST['default_options'])) { |
|
729 | + $_POST['default_options'] = array(); |
|
730 | + } |
|
711 | 731 | |
712 | 732 | // Make sure items are cast correctly. |
713 | 733 | foreach ($context['theme_settings'] as $item) |
714 | 734 | { |
715 | 735 | // Disregard this item if this is just a separator. |
716 | - if (!is_array($item)) |
|
717 | - continue; |
|
736 | + if (!is_array($item)) { |
|
737 | + continue; |
|
738 | + } |
|
718 | 739 | |
719 | 740 | foreach (array('options', 'default_options') as $option) |
720 | 741 | { |
721 | - if (!isset($_POST[$option][$item['id']])) |
|
722 | - continue; |
|
742 | + if (!isset($_POST[$option][$item['id']])) { |
|
743 | + continue; |
|
744 | + } |
|
723 | 745 | // Checkbox. |
724 | - elseif (empty($item['type'])) |
|
725 | - $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
746 | + elseif (empty($item['type'])) { |
|
747 | + $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
748 | + } |
|
726 | 749 | // Number |
727 | - elseif ($item['type'] == 'number') |
|
728 | - $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
750 | + elseif ($item['type'] == 'number') { |
|
751 | + $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
752 | + } |
|
729 | 753 | } |
730 | 754 | } |
731 | 755 | |
732 | 756 | // Set up the sql query. |
733 | 757 | $inserts = array(); |
734 | - foreach ($_POST['options'] as $opt => $val) |
|
735 | - $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
736 | - foreach ($_POST['default_options'] as $opt => $val) |
|
737 | - $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
758 | + foreach ($_POST['options'] as $opt => $val) { |
|
759 | + $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
760 | + } |
|
761 | + foreach ($_POST['default_options'] as $opt => $val) { |
|
762 | + $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
763 | + } |
|
738 | 764 | // If we're actually inserting something.. |
739 | 765 | if (!empty($inserts)) |
740 | 766 | { |
@@ -760,8 +786,9 @@ discard block |
||
760 | 786 | |
761 | 787 | foreach ($settings as $setting => $dummy) |
762 | 788 | { |
763 | - if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) |
|
764 | - $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
789 | + if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) { |
|
790 | + $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
791 | + } |
|
765 | 792 | } |
766 | 793 | |
767 | 794 | $context['settings'] = $context['theme_settings']; |
@@ -770,18 +797,21 @@ discard block |
||
770 | 797 | foreach ($context['settings'] as $i => $setting) |
771 | 798 | { |
772 | 799 | // Separators are dummies, so leave them alone. |
773 | - if (!is_array($setting)) |
|
774 | - continue; |
|
800 | + if (!is_array($setting)) { |
|
801 | + continue; |
|
802 | + } |
|
775 | 803 | |
776 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
777 | - $context['settings'][$i]['type'] = 'checkbox'; |
|
778 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
779 | - $context['settings'][$i]['type'] = 'number'; |
|
780 | - elseif ($setting['type'] == 'string') |
|
781 | - $context['settings'][$i]['type'] = 'text'; |
|
804 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
805 | + $context['settings'][$i]['type'] = 'checkbox'; |
|
806 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
807 | + $context['settings'][$i]['type'] = 'number'; |
|
808 | + } elseif ($setting['type'] == 'string') { |
|
809 | + $context['settings'][$i]['type'] = 'text'; |
|
810 | + } |
|
782 | 811 | |
783 | - if (isset($setting['options'])) |
|
784 | - $context['settings'][$i]['type'] = 'list'; |
|
812 | + if (isset($setting['options'])) { |
|
813 | + $context['settings'][$i]['type'] = 'list'; |
|
814 | + } |
|
785 | 815 | |
786 | 816 | $context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']]; |
787 | 817 | } |
@@ -834,8 +864,9 @@ discard block |
||
834 | 864 | $themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
835 | 865 | |
836 | 866 | // You can't delete the default theme! |
837 | - if ($themeID == 1) |
|
838 | - fatal_lang_error('no_access', false); |
|
867 | + if ($themeID == 1) { |
|
868 | + fatal_lang_error('no_access', false); |
|
869 | + } |
|
839 | 870 | |
840 | 871 | $theme_info = get_single_theme($themeID); |
841 | 872 | |
@@ -843,8 +874,9 @@ discard block |
||
843 | 874 | remove_theme($themeID); |
844 | 875 | |
845 | 876 | // And remove all its files and folders too. |
846 | - if (!empty($theme_info) && !empty($theme_info['theme_dir'])) |
|
847 | - remove_dir($theme_info['theme_dir']); |
|
877 | + if (!empty($theme_info) && !empty($theme_info['theme_dir'])) { |
|
878 | + remove_dir($theme_info['theme_dir']); |
|
879 | + } |
|
848 | 880 | |
849 | 881 | // Go back to the list page. |
850 | 882 | redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=removing'); |
@@ -869,12 +901,14 @@ discard block |
||
869 | 901 | $enableThemes = explode(',', $modSettings['enableThemes']); |
870 | 902 | |
871 | 903 | // Are we disabling it? |
872 | - if (isset($_GET['disabled'])) |
|
873 | - $enableThemes = array_diff($enableThemes, array($themeID)); |
|
904 | + if (isset($_GET['disabled'])) { |
|
905 | + $enableThemes = array_diff($enableThemes, array($themeID)); |
|
906 | + } |
|
874 | 907 | |
875 | 908 | // Nope? then enable it! |
876 | - else |
|
877 | - $enableThemes[] = (string) $themeID; |
|
909 | + else { |
|
910 | + $enableThemes[] = (string) $themeID; |
|
911 | + } |
|
878 | 912 | |
879 | 913 | // Update the setting. |
880 | 914 | $enableThemes = strtr(implode(',', $enableThemes), array(',,' => ',')); |
@@ -909,18 +943,21 @@ discard block |
||
909 | 943 | |
910 | 944 | $_SESSION['id_theme'] = 0; |
911 | 945 | |
912 | - if (isset($_GET['id'])) |
|
913 | - $_GET['th'] = $_GET['id']; |
|
946 | + if (isset($_GET['id'])) { |
|
947 | + $_GET['th'] = $_GET['id']; |
|
948 | + } |
|
914 | 949 | |
915 | 950 | // Saving a variant cause JS doesn't work - pretend it did ;) |
916 | 951 | if (isset($_POST['save'])) |
917 | 952 | { |
918 | 953 | // Which theme? |
919 | - foreach ($_POST['save'] as $k => $v) |
|
920 | - $_GET['th'] = (int) $k; |
|
954 | + foreach ($_POST['save'] as $k => $v) { |
|
955 | + $_GET['th'] = (int) $k; |
|
956 | + } |
|
921 | 957 | |
922 | - if (isset($_POST['vrt'][$k])) |
|
923 | - $_GET['vrt'] = $_POST['vrt'][$k]; |
|
958 | + if (isset($_POST['vrt'][$k])) { |
|
959 | + $_GET['vrt'] = $_POST['vrt'][$k]; |
|
960 | + } |
|
924 | 961 | } |
925 | 962 | |
926 | 963 | // Have we made a decision, or are we just browsing? |
@@ -1009,10 +1046,10 @@ discard block |
||
1009 | 1046 | ); |
1010 | 1047 | cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90); |
1011 | 1048 | |
1012 | - if ($user_info['id'] == $_REQUEST['u']) |
|
1013 | - $_SESSION['id_variant'] = 0; |
|
1014 | - } |
|
1015 | - elseif ($_GET['th'] == 0) |
|
1049 | + if ($user_info['id'] == $_REQUEST['u']) { |
|
1050 | + $_SESSION['id_variant'] = 0; |
|
1051 | + } |
|
1052 | + } elseif ($_GET['th'] == 0) |
|
1016 | 1053 | { |
1017 | 1054 | // Remove any custom variants. |
1018 | 1055 | $smcFunc['db_query']('', ' |
@@ -1093,12 +1130,13 @@ discard block |
||
1093 | 1130 | ); |
1094 | 1131 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1095 | 1132 | { |
1096 | - if (!isset($context['available_themes'][$row['id_theme']])) |
|
1097 | - $context['available_themes'][$row['id_theme']] = array( |
|
1133 | + if (!isset($context['available_themes'][$row['id_theme']])) { |
|
1134 | + $context['available_themes'][$row['id_theme']] = array( |
|
1098 | 1135 | 'id' => $row['id_theme'], |
1099 | 1136 | 'selected' => $context['current_theme'] == $row['id_theme'], |
1100 | 1137 | 'num_users' => 0 |
1101 | 1138 | ); |
1139 | + } |
|
1102 | 1140 | $context['available_themes'][$row['id_theme']][$row['variable']] = $row['value']; |
1103 | 1141 | } |
1104 | 1142 | $smcFunc['db_free_result']($request); |
@@ -1111,9 +1149,9 @@ discard block |
||
1111 | 1149 | 'num_users' => 0 |
1112 | 1150 | ); |
1113 | 1151 | $guest_theme = 0; |
1152 | + } else { |
|
1153 | + $guest_theme = $modSettings['theme_guests']; |
|
1114 | 1154 | } |
1115 | - else |
|
1116 | - $guest_theme = $modSettings['theme_guests']; |
|
1117 | 1155 | |
1118 | 1156 | $request = $smcFunc['db_query']('', ' |
1119 | 1157 | SELECT id_theme, COUNT(*) AS the_count |
@@ -1126,15 +1164,17 @@ discard block |
||
1126 | 1164 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1127 | 1165 | { |
1128 | 1166 | // Figure out which theme it is they are REALLY using. |
1129 | - if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) |
|
1130 | - $row['id_theme'] = $guest_theme; |
|
1131 | - elseif (empty($modSettings['theme_allow'])) |
|
1132 | - $row['id_theme'] = $guest_theme; |
|
1167 | + if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) { |
|
1168 | + $row['id_theme'] = $guest_theme; |
|
1169 | + } elseif (empty($modSettings['theme_allow'])) { |
|
1170 | + $row['id_theme'] = $guest_theme; |
|
1171 | + } |
|
1133 | 1172 | |
1134 | - if (isset($context['available_themes'][$row['id_theme']])) |
|
1135 | - $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
1136 | - else |
|
1137 | - $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
1173 | + if (isset($context['available_themes'][$row['id_theme']])) { |
|
1174 | + $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
1175 | + } else { |
|
1176 | + $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
1177 | + } |
|
1138 | 1178 | } |
1139 | 1179 | $smcFunc['db_free_result']($request); |
1140 | 1180 | |
@@ -1153,8 +1193,9 @@ discard block |
||
1153 | 1193 | 'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1), |
1154 | 1194 | ) |
1155 | 1195 | ); |
1156 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1157 | - $variant_preferences[$row['id_theme']] = $row['value']; |
|
1196 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1197 | + $variant_preferences[$row['id_theme']] = $row['value']; |
|
1198 | + } |
|
1158 | 1199 | $smcFunc['db_free_result']($request); |
1159 | 1200 | } |
1160 | 1201 | |
@@ -1165,17 +1206,18 @@ discard block |
||
1165 | 1206 | foreach ($context['available_themes'] as $id_theme => $theme_data) |
1166 | 1207 | { |
1167 | 1208 | // Don't try to load the forum or board default theme's data... it doesn't have any! |
1168 | - if ($id_theme == 0) |
|
1169 | - continue; |
|
1209 | + if ($id_theme == 0) { |
|
1210 | + continue; |
|
1211 | + } |
|
1170 | 1212 | |
1171 | 1213 | // The thumbnail needs the correct path. |
1172 | 1214 | $settings['images_url'] = &$theme_data['images_url']; |
1173 | 1215 | |
1174 | - if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) |
|
1175 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
1176 | - elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) |
|
1177 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
1178 | - else |
|
1216 | + if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) { |
|
1217 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
1218 | + } elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) { |
|
1219 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
1220 | + } else |
|
1179 | 1221 | { |
1180 | 1222 | $txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png'; |
1181 | 1223 | $txt['theme_description'] = ''; |
@@ -1200,15 +1242,17 @@ discard block |
||
1200 | 1242 | loadLanguage('Settings'); |
1201 | 1243 | |
1202 | 1244 | $context['available_themes'][$id_theme]['variants'] = array(); |
1203 | - foreach ($settings['theme_variants'] as $variant) |
|
1204 | - $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
1245 | + foreach ($settings['theme_variants'] as $variant) { |
|
1246 | + $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
1205 | 1247 | 'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant, |
1206 | 1248 | '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'), |
1207 | 1249 | ); |
1250 | + } |
|
1208 | 1251 | |
1209 | 1252 | $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])); |
1210 | - if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) |
|
1211 | - $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
1253 | + if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) { |
|
1254 | + $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
1255 | + } |
|
1212 | 1256 | |
1213 | 1257 | $context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']; |
1214 | 1258 | // Allow themes to override the text. |
@@ -1224,8 +1268,9 @@ discard block |
||
1224 | 1268 | // As long as we're not doing the default theme... |
1225 | 1269 | if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0) |
1226 | 1270 | { |
1227 | - if ($guest_theme != 0) |
|
1228 | - $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
1271 | + if ($guest_theme != 0) { |
|
1272 | + $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
1273 | + } |
|
1229 | 1274 | |
1230 | 1275 | $context['available_themes'][0]['id'] = 0; |
1231 | 1276 | $context['available_themes'][0]['name'] = $txt['theme_forum_default']; |
@@ -1274,14 +1319,16 @@ discard block |
||
1274 | 1319 | $action = $smcFunc['htmlspecialchars'](trim($_GET['do'])); |
1275 | 1320 | |
1276 | 1321 | // Got any info from the specific form? |
1277 | - if (!isset($_POST['save_' . $action])) |
|
1278 | - fatal_lang_error('theme_install_no_action', false); |
|
1322 | + if (!isset($_POST['save_' . $action])) { |
|
1323 | + fatal_lang_error('theme_install_no_action', false); |
|
1324 | + } |
|
1279 | 1325 | |
1280 | 1326 | validateToken('admin-t-' . $action); |
1281 | 1327 | |
1282 | 1328 | // Hopefully the themes directory is writable, or we might have a problem. |
1283 | - if (!is_writable($themedir)) |
|
1284 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
1329 | + if (!is_writable($themedir)) { |
|
1330 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
1331 | + } |
|
1285 | 1332 | |
1286 | 1333 | // Call the function and handle the result. |
1287 | 1334 | $result = $subActions[$action](); |
@@ -1296,9 +1343,10 @@ discard block |
||
1296 | 1343 | } |
1297 | 1344 | |
1298 | 1345 | // Nope, show a nice error. |
1299 | - else |
|
1300 | - fatal_lang_error('theme_install_no_action', false); |
|
1301 | -} |
|
1346 | + else { |
|
1347 | + fatal_lang_error('theme_install_no_action', false); |
|
1348 | + } |
|
1349 | + } |
|
1302 | 1350 | |
1303 | 1351 | /** |
1304 | 1352 | * Installs a theme from a theme package. |
@@ -1314,8 +1362,9 @@ discard block |
||
1314 | 1362 | $dirtemp = $themedir . '/temp'; |
1315 | 1363 | |
1316 | 1364 | // Make sure the temp dir doesn't already exist |
1317 | - if (file_exists($dirtemp)) |
|
1318 | - remove_dir($dirtemp); |
|
1365 | + if (file_exists($dirtemp)) { |
|
1366 | + remove_dir($dirtemp); |
|
1367 | + } |
|
1319 | 1368 | |
1320 | 1369 | // Create the temp dir. |
1321 | 1370 | mkdir($dirtemp, 0777); |
@@ -1327,17 +1376,20 @@ discard block |
||
1327 | 1376 | smf_chmod($dirtemp, '0755'); |
1328 | 1377 | |
1329 | 1378 | // How about now? |
1330 | - if (!is_writable($dirtemp)) |
|
1331 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
1379 | + if (!is_writable($dirtemp)) { |
|
1380 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
1381 | + } |
|
1332 | 1382 | } |
1333 | 1383 | |
1334 | 1384 | // This happens when the admin session is gone and the user has to login again. |
1335 | - if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) |
|
1336 | - redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
1385 | + if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) { |
|
1386 | + redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
1387 | + } |
|
1337 | 1388 | |
1338 | 1389 | // Another error check layer, something went wrong with the upload. |
1339 | - if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) |
|
1340 | - fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
1390 | + if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) { |
|
1391 | + fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
1392 | + } |
|
1341 | 1393 | |
1342 | 1394 | // Get the theme's name. |
1343 | 1395 | $name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME); |
@@ -1368,11 +1420,10 @@ discard block |
||
1368 | 1420 | |
1369 | 1421 | // return all the info. |
1370 | 1422 | return $context['to_install']; |
1423 | + } else { |
|
1424 | + fatal_lang_error('theme_install_error_title', false); |
|
1425 | + } |
|
1371 | 1426 | } |
1372 | - |
|
1373 | - else |
|
1374 | - fatal_lang_error('theme_install_error_title', false); |
|
1375 | -} |
|
1376 | 1427 | |
1377 | 1428 | /** |
1378 | 1429 | * Makes a copy from the default theme, assigns a name for it and installs it. |
@@ -1386,15 +1437,17 @@ discard block |
||
1386 | 1437 | global $forum_version; |
1387 | 1438 | |
1388 | 1439 | // There's gotta be something to work with. |
1389 | - if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) |
|
1390 | - fatal_lang_error('theme_install_error_title', false); |
|
1440 | + if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) { |
|
1441 | + fatal_lang_error('theme_install_error_title', false); |
|
1442 | + } |
|
1391 | 1443 | |
1392 | 1444 | // Get a cleaner version. |
1393 | 1445 | $name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']); |
1394 | 1446 | |
1395 | 1447 | // Is there a theme already named like this? |
1396 | - if (file_exists($themedir . '/' . $name)) |
|
1397 | - fatal_lang_error('theme_install_already_dir', false); |
|
1448 | + if (file_exists($themedir . '/' . $name)) { |
|
1449 | + fatal_lang_error('theme_install_already_dir', false); |
|
1450 | + } |
|
1398 | 1451 | |
1399 | 1452 | // This is a brand new theme so set all possible values. |
1400 | 1453 | $context['to_install'] = array( |
@@ -1414,8 +1467,9 @@ discard block |
||
1414 | 1467 | |
1415 | 1468 | // Buy some time. |
1416 | 1469 | @set_time_limit(600); |
1417 | - if (function_exists('apache_reset_timeout')) |
|
1418 | - @apache_reset_timeout(); |
|
1470 | + if (function_exists('apache_reset_timeout')) { |
|
1471 | + @apache_reset_timeout(); |
|
1472 | + } |
|
1419 | 1473 | |
1420 | 1474 | // Create subdirectories for css and javascript files. |
1421 | 1475 | mkdir($context['to_install']['theme_dir'] . '/css', 0777); |
@@ -1451,12 +1505,13 @@ discard block |
||
1451 | 1505 | |
1452 | 1506 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1453 | 1507 | { |
1454 | - if ($row['variable'] == 'theme_templates') |
|
1455 | - $theme_templates = $row['value']; |
|
1456 | - elseif ($row['variable'] == 'theme_layers') |
|
1457 | - $theme_layers = $row['value']; |
|
1458 | - else |
|
1459 | - continue; |
|
1508 | + if ($row['variable'] == 'theme_templates') { |
|
1509 | + $theme_templates = $row['value']; |
|
1510 | + } elseif ($row['variable'] == 'theme_layers') { |
|
1511 | + $theme_layers = $row['value']; |
|
1512 | + } else { |
|
1513 | + continue; |
|
1514 | + } |
|
1460 | 1515 | } |
1461 | 1516 | |
1462 | 1517 | $smcFunc['db_free_result']($request); |
@@ -1515,12 +1570,14 @@ discard block |
||
1515 | 1570 | global $themedir, $themeurl, $context; |
1516 | 1571 | |
1517 | 1572 | // Cannot use the theme dir as a theme dir. |
1518 | - if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) |
|
1519 | - fatal_lang_error('theme_install_invalid_dir', false); |
|
1573 | + if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) { |
|
1574 | + fatal_lang_error('theme_install_invalid_dir', false); |
|
1575 | + } |
|
1520 | 1576 | |
1521 | 1577 | // Check is there is "something" on the dir. |
1522 | - elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) |
|
1523 | - fatal_lang_error('theme_install_error', false); |
|
1578 | + elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) { |
|
1579 | + fatal_lang_error('theme_install_error', false); |
|
1580 | + } |
|
1524 | 1581 | |
1525 | 1582 | $name = basename($_REQUEST['theme_dir']); |
1526 | 1583 | $name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name); |
@@ -1564,24 +1621,27 @@ discard block |
||
1564 | 1621 | } |
1565 | 1622 | |
1566 | 1623 | // Any special layers? |
1567 | - if (isset($settings['catch_action']['layers'])) |
|
1568 | - $context['template_layers'] = $settings['catch_action']['layers']; |
|
1624 | + if (isset($settings['catch_action']['layers'])) { |
|
1625 | + $context['template_layers'] = $settings['catch_action']['layers']; |
|
1626 | + } |
|
1569 | 1627 | |
1570 | 1628 | // Any function to call? |
1571 | 1629 | if (isset($settings['catch_action']['function'])) |
1572 | 1630 | { |
1573 | 1631 | $hook = $settings['catch_action']['function']; |
1574 | 1632 | |
1575 | - if (!isset($settings['catch_action']['filename'])) |
|
1576 | - $settings['catch_action']['filename'] = ''; |
|
1633 | + if (!isset($settings['catch_action']['filename'])) { |
|
1634 | + $settings['catch_action']['filename'] = ''; |
|
1635 | + } |
|
1577 | 1636 | |
1578 | 1637 | add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false); |
1579 | 1638 | call_integration_hook('integrate_wrap_action'); |
1580 | 1639 | } |
1581 | 1640 | // And finally, the main sub template ;). |
1582 | - if (isset($settings['catch_action']['sub_template'])) |
|
1583 | - $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
1584 | -} |
|
1641 | + if (isset($settings['catch_action']['sub_template'])) { |
|
1642 | + $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
1643 | + } |
|
1644 | + } |
|
1585 | 1645 | |
1586 | 1646 | /** |
1587 | 1647 | * Set an option via javascript. |
@@ -1600,12 +1660,14 @@ discard block |
||
1600 | 1660 | checkSession('get'); |
1601 | 1661 | |
1602 | 1662 | // This good-for-nothing pixel is being used to keep the session alive. |
1603 | - if (empty($_GET['var']) || !isset($_GET['val'])) |
|
1604 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
1663 | + if (empty($_GET['var']) || !isset($_GET['val'])) { |
|
1664 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
1665 | + } |
|
1605 | 1666 | |
1606 | 1667 | // Sorry, guests can't go any further than this. |
1607 | - if ($user_info['is_guest'] || $user_info['id'] == 0) |
|
1608 | - obExit(false); |
|
1668 | + if ($user_info['is_guest'] || $user_info['id'] == 0) { |
|
1669 | + obExit(false); |
|
1670 | + } |
|
1609 | 1671 | |
1610 | 1672 | $reservedVars = array( |
1611 | 1673 | 'actual_theme_url', |
@@ -1628,8 +1690,9 @@ discard block |
||
1628 | 1690 | ); |
1629 | 1691 | |
1630 | 1692 | // Can't change reserved vars. |
1631 | - if (in_array(strtolower($_GET['var']), $reservedVars)) |
|
1632 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
1693 | + if (in_array(strtolower($_GET['var']), $reservedVars)) { |
|
1694 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
1695 | + } |
|
1633 | 1696 | |
1634 | 1697 | // Use a specific theme? |
1635 | 1698 | if (isset($_GET['th']) || isset($_GET['id'])) |
@@ -1645,8 +1708,9 @@ discard block |
||
1645 | 1708 | { |
1646 | 1709 | $options['admin_preferences'] = !empty($options['admin_preferences']) ? $smcFunc['json_decode']($options['admin_preferences'], true) : array(); |
1647 | 1710 | // New thingy... |
1648 | - if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) |
|
1649 | - $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
1711 | + if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) { |
|
1712 | + $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
1713 | + } |
|
1650 | 1714 | |
1651 | 1715 | // Change the value to be something nice, |
1652 | 1716 | $_GET['val'] = $smcFunc['json_encode']($options['admin_preferences']); |
@@ -1676,8 +1740,9 @@ discard block |
||
1676 | 1740 | global $context, $scripturl, $boarddir, $smcFunc, $txt; |
1677 | 1741 | |
1678 | 1742 | // @todo Should this be removed? |
1679 | - if (isset($_REQUEST['preview'])) |
|
1680 | - die('die() with fire'); |
|
1743 | + if (isset($_REQUEST['preview'])) { |
|
1744 | + die('die() with fire'); |
|
1745 | + } |
|
1681 | 1746 | |
1682 | 1747 | isAllowedTo('admin_forum'); |
1683 | 1748 | loadTemplate('Themes'); |
@@ -1691,11 +1756,11 @@ discard block |
||
1691 | 1756 | foreach ($context['themes'] as $key => $theme) |
1692 | 1757 | { |
1693 | 1758 | // There has to be a Settings template! |
1694 | - if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) |
|
1695 | - unset($context['themes'][$key]); |
|
1696 | - |
|
1697 | - else |
|
1698 | - $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
1759 | + if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) { |
|
1760 | + unset($context['themes'][$key]); |
|
1761 | + } else { |
|
1762 | + $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
1763 | + } |
|
1699 | 1764 | } |
1700 | 1765 | |
1701 | 1766 | $context['sub_template'] = 'edit_list'; |
@@ -1710,22 +1775,24 @@ discard block |
||
1710 | 1775 | $context['theme_id'] = $currentTheme['id']; |
1711 | 1776 | $context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']); |
1712 | 1777 | |
1713 | - if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) |
|
1714 | - fatal_lang_error('theme_edit_missing', false); |
|
1778 | + if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) { |
|
1779 | + fatal_lang_error('theme_edit_missing', false); |
|
1780 | + } |
|
1715 | 1781 | |
1716 | 1782 | if (!isset($_REQUEST['filename'])) |
1717 | 1783 | { |
1718 | 1784 | if (isset($_GET['directory'])) |
1719 | 1785 | { |
1720 | - if (substr($_GET['directory'], 0, 1) == '.') |
|
1721 | - $_GET['directory'] = ''; |
|
1722 | - else |
|
1786 | + if (substr($_GET['directory'], 0, 1) == '.') { |
|
1787 | + $_GET['directory'] = ''; |
|
1788 | + } else |
|
1723 | 1789 | { |
1724 | 1790 | $_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']); |
1725 | 1791 | |
1726 | 1792 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']); |
1727 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
1728 | - $_GET['directory'] = ''; |
|
1793 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
1794 | + $_GET['directory'] = ''; |
|
1795 | + } |
|
1729 | 1796 | } |
1730 | 1797 | } |
1731 | 1798 | |
@@ -1744,37 +1811,39 @@ discard block |
||
1744 | 1811 | 'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp, |
1745 | 1812 | 'size' => '', |
1746 | 1813 | )); |
1814 | + } else { |
|
1815 | + $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
1747 | 1816 | } |
1748 | - else |
|
1749 | - $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
1750 | 1817 | |
1751 | 1818 | $context['sub_template'] = 'edit_browse'; |
1752 | 1819 | |
1753 | 1820 | return; |
1754 | - } |
|
1755 | - else |
|
1821 | + } else |
|
1756 | 1822 | { |
1757 | - if (substr($_REQUEST['filename'], 0, 1) == '.') |
|
1758 | - $_REQUEST['filename'] = ''; |
|
1759 | - else |
|
1823 | + if (substr($_REQUEST['filename'], 0, 1) == '.') { |
|
1824 | + $_REQUEST['filename'] = ''; |
|
1825 | + } else |
|
1760 | 1826 | { |
1761 | 1827 | $_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']); |
1762 | 1828 | |
1763 | 1829 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
1764 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
1765 | - $_REQUEST['filename'] = ''; |
|
1830 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
1831 | + $_REQUEST['filename'] = ''; |
|
1832 | + } |
|
1766 | 1833 | } |
1767 | 1834 | |
1768 | - if (empty($_REQUEST['filename'])) |
|
1769 | - fatal_lang_error('theme_edit_missing', false); |
|
1835 | + if (empty($_REQUEST['filename'])) { |
|
1836 | + fatal_lang_error('theme_edit_missing', false); |
|
1837 | + } |
|
1770 | 1838 | } |
1771 | 1839 | |
1772 | 1840 | if (isset($_POST['save'])) |
1773 | 1841 | { |
1774 | 1842 | if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true) |
1775 | 1843 | { |
1776 | - if (is_array($_POST['entire_file'])) |
|
1777 | - $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
1844 | + if (is_array($_POST['entire_file'])) { |
|
1845 | + $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
1846 | + } |
|
1778 | 1847 | |
1779 | 1848 | $_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', ' ' => "\t"))); |
1780 | 1849 | |
@@ -1786,10 +1855,11 @@ discard block |
||
1786 | 1855 | fclose($fp); |
1787 | 1856 | |
1788 | 1857 | $error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php'); |
1789 | - if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) |
|
1790 | - $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
1791 | - else |
|
1792 | - unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
1858 | + if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) { |
|
1859 | + $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
1860 | + } else { |
|
1861 | + unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
1862 | + } |
|
1793 | 1863 | } |
1794 | 1864 | |
1795 | 1865 | if (!isset($error_file)) |
@@ -1810,10 +1880,11 @@ discard block |
||
1810 | 1880 | $context['sub_template'] = 'edit_file'; |
1811 | 1881 | |
1812 | 1882 | // Recycle the submitted data. |
1813 | - if (is_array($_POST['entire_file'])) |
|
1814 | - $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
1815 | - else |
|
1816 | - $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
1883 | + if (is_array($_POST['entire_file'])) { |
|
1884 | + $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
1885 | + } else { |
|
1886 | + $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
1887 | + } |
|
1817 | 1888 | |
1818 | 1889 | $context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']); |
1819 | 1890 | |
@@ -1836,17 +1907,17 @@ discard block |
||
1836 | 1907 | $context['sub_template'] = 'edit_style'; |
1837 | 1908 | |
1838 | 1909 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => ' '))); |
1839 | - } |
|
1840 | - elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
1910 | + } elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
1841 | 1911 | { |
1842 | 1912 | $context['sub_template'] = 'edit_template'; |
1843 | 1913 | |
1844 | - if (!isset($error_file)) |
|
1845 | - $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
1846 | - else |
|
1914 | + if (!isset($error_file)) { |
|
1915 | + $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
1916 | + } else |
|
1847 | 1917 | { |
1848 | - if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) |
|
1849 | - $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
1918 | + if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) { |
|
1919 | + $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
1920 | + } |
|
1850 | 1921 | $file_data = file($error_file); |
1851 | 1922 | unlink($error_file); |
1852 | 1923 | } |
@@ -1860,8 +1931,9 @@ discard block |
||
1860 | 1931 | // Try to format the functions a little nicer... |
1861 | 1932 | $context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n"; |
1862 | 1933 | |
1863 | - if (empty($context['file_parts'][$j]['lines'])) |
|
1864 | - unset($context['file_parts'][$j]); |
|
1934 | + if (empty($context['file_parts'][$j]['lines'])) { |
|
1935 | + unset($context['file_parts'][$j]); |
|
1936 | + } |
|
1865 | 1937 | $context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => ''); |
1866 | 1938 | } |
1867 | 1939 | |
@@ -1870,8 +1942,7 @@ discard block |
||
1870 | 1942 | } |
1871 | 1943 | |
1872 | 1944 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => ' '))); |
1873 | - } |
|
1874 | - else |
|
1945 | + } else |
|
1875 | 1946 | { |
1876 | 1947 | $context['sub_template'] = 'edit_file'; |
1877 | 1948 | |
@@ -1897,8 +1968,9 @@ discard block |
||
1897 | 1968 | |
1898 | 1969 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
1899 | 1970 | |
1900 | - if (empty($_GET['th'])) |
|
1901 | - fatal_lang_error('theme_install_invalid_id'); |
|
1971 | + if (empty($_GET['th'])) { |
|
1972 | + fatal_lang_error('theme_install_invalid_id'); |
|
1973 | + } |
|
1902 | 1974 | |
1903 | 1975 | // Get the theme info. |
1904 | 1976 | $theme = get_single_theme($_GET['th']); |
@@ -1906,25 +1978,24 @@ discard block |
||
1906 | 1978 | |
1907 | 1979 | if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0) |
1908 | 1980 | { |
1909 | - if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) |
|
1910 | - $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
1911 | - |
|
1912 | - else |
|
1913 | - fatal_lang_error('no_access', false); |
|
1981 | + if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) { |
|
1982 | + $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
1983 | + } else { |
|
1984 | + fatal_lang_error('no_access', false); |
|
1985 | + } |
|
1914 | 1986 | |
1915 | 1987 | $fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w'); |
1916 | 1988 | fwrite($fp, file_get_contents($filename)); |
1917 | 1989 | fclose($fp); |
1918 | 1990 | |
1919 | 1991 | redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy'); |
1920 | - } |
|
1921 | - elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
1992 | + } elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
1922 | 1993 | { |
1923 | - if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) |
|
1924 | - $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
1925 | - |
|
1926 | - else |
|
1927 | - fatal_lang_error('no_access', false); |
|
1994 | + if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) { |
|
1995 | + $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
1996 | + } else { |
|
1997 | + fatal_lang_error('no_access', false); |
|
1998 | + } |
|
1928 | 1999 | |
1929 | 2000 | $fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w'); |
1930 | 2001 | fwrite($fp, file_get_contents($filename)); |
@@ -1939,16 +2010,18 @@ discard block |
||
1939 | 2010 | $dir = dir($settings['default_theme_dir']); |
1940 | 2011 | while ($entry = $dir->read()) |
1941 | 2012 | { |
1942 | - if (substr($entry, -13) == '.template.php') |
|
1943 | - $templates[] = substr($entry, 0, -13); |
|
2013 | + if (substr($entry, -13) == '.template.php') { |
|
2014 | + $templates[] = substr($entry, 0, -13); |
|
2015 | + } |
|
1944 | 2016 | } |
1945 | 2017 | $dir->close(); |
1946 | 2018 | |
1947 | 2019 | $dir = dir($settings['default_theme_dir'] . '/languages'); |
1948 | 2020 | while ($entry = $dir->read()) |
1949 | 2021 | { |
1950 | - if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) |
|
1951 | - $lang_files[] = $matches[1]; |
|
2022 | + if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) { |
|
2023 | + $lang_files[] = $matches[1]; |
|
2024 | + } |
|
1952 | 2025 | } |
1953 | 2026 | $dir->close(); |
1954 | 2027 | |
@@ -1956,21 +2029,23 @@ discard block |
||
1956 | 2029 | natcasesort($lang_files); |
1957 | 2030 | |
1958 | 2031 | $context['available_templates'] = array(); |
1959 | - foreach ($templates as $template) |
|
1960 | - $context['available_templates'][$template] = array( |
|
2032 | + foreach ($templates as $template) { |
|
2033 | + $context['available_templates'][$template] = array( |
|
1961 | 2034 | 'filename' => $template . '.template.php', |
1962 | 2035 | 'value' => $template, |
1963 | 2036 | 'already_exists' => false, |
1964 | 2037 | 'can_copy' => is_writable($theme['theme_dir']), |
1965 | 2038 | ); |
2039 | + } |
|
1966 | 2040 | $context['available_language_files'] = array(); |
1967 | - foreach ($lang_files as $file) |
|
1968 | - $context['available_language_files'][$file] = array( |
|
2041 | + foreach ($lang_files as $file) { |
|
2042 | + $context['available_language_files'][$file] = array( |
|
1969 | 2043 | 'filename' => $file . '.php', |
1970 | 2044 | 'value' => $file, |
1971 | 2045 | 'already_exists' => false, |
1972 | 2046 | 'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']), |
1973 | 2047 | ); |
2048 | + } |
|
1974 | 2049 | |
1975 | 2050 | $dir = dir($theme['theme_dir']); |
1976 | 2051 | while ($entry = $dir->read()) |