@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * 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]); |
@@ -154,11 +157,12 @@ discard block |
||
154 | 157 | 'data' => array( |
155 | 158 | 'function' => function($news) |
156 | 159 | { |
157 | - if (is_numeric($news['id'])) |
|
158 | - return '<textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea> |
|
160 | + if (is_numeric($news['id'])) { |
|
161 | + return '<textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea> |
|
159 | 162 | <div class="floatleft" id="preview_' . $news['id'] . '"></div>'; |
160 | - else |
|
161 | - return $news['unparsed']; |
|
163 | + } else { |
|
164 | + return $news['unparsed']; |
|
165 | + } |
|
162 | 166 | }, |
163 | 167 | 'style' => 'width: 50%;', |
164 | 168 | ), |
@@ -183,10 +187,11 @@ discard block |
||
183 | 187 | 'data' => array( |
184 | 188 | 'function' => function($news) |
185 | 189 | { |
186 | - if (is_numeric($news['id'])) |
|
187 | - return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '" class="input_check">'; |
|
188 | - else |
|
189 | - return ''; |
|
190 | + if (is_numeric($news['id'])) { |
|
191 | + return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '" class="input_check">'; |
|
192 | + } else { |
|
193 | + return ''; |
|
194 | + } |
|
190 | 195 | }, |
191 | 196 | 'class' => 'centercol', |
192 | 197 | ), |
@@ -280,12 +285,13 @@ discard block |
||
280 | 285 | |
281 | 286 | $admin_current_news = array(); |
282 | 287 | // Ready the current news. |
283 | - foreach (explode("\n", $modSettings['news']) as $id => $line) |
|
284 | - $admin_current_news[$id] = array( |
|
288 | + foreach (explode("\n", $modSettings['news']) as $id => $line) { |
|
289 | + $admin_current_news[$id] = array( |
|
285 | 290 | 'id' => $id, |
286 | 291 | 'unparsed' => un_preparsecode($line), |
287 | 292 | 'parsed' => preg_replace('~<([/]?)form[^>]*?[>]*>~i', '<em class="smalltext"><$1form></em>', parse_bbc($line)), |
288 | 293 | ); |
294 | + } |
|
289 | 295 | |
290 | 296 | $admin_current_news['last'] = array( |
291 | 297 | 'id' => 'last', |
@@ -352,10 +358,11 @@ discard block |
||
352 | 358 | 'member_count' => 0, |
353 | 359 | ); |
354 | 360 | |
355 | - if ($row['min_posts'] == -1) |
|
356 | - $normalGroups[$row['id_group']] = $row['id_group']; |
|
357 | - else |
|
358 | - $postGroups[$row['id_group']] = $row['id_group']; |
|
361 | + if ($row['min_posts'] == -1) { |
|
362 | + $normalGroups[$row['id_group']] = $row['id_group']; |
|
363 | + } else { |
|
364 | + $postGroups[$row['id_group']] = $row['id_group']; |
|
365 | + } |
|
359 | 366 | } |
360 | 367 | $smcFunc['db_free_result']($request); |
361 | 368 | |
@@ -371,8 +378,9 @@ discard block |
||
371 | 378 | 'post_group_list' => $postGroups, |
372 | 379 | ) |
373 | 380 | ); |
374 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
375 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
381 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
382 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
383 | + } |
|
376 | 384 | $smcFunc['db_free_result']($query); |
377 | 385 | } |
378 | 386 | |
@@ -388,8 +396,9 @@ discard block |
||
388 | 396 | 'normal_group_list' => $normalGroups, |
389 | 397 | ) |
390 | 398 | ); |
391 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
392 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
399 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
400 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
401 | + } |
|
393 | 402 | $smcFunc['db_free_result']($query); |
394 | 403 | |
395 | 404 | // Also do those who have it as an additional membergroup - this ones more yucky... |
@@ -406,8 +415,9 @@ discard block |
||
406 | 415 | 'blank_string' => '', |
407 | 416 | ) |
408 | 417 | ); |
409 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
410 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
418 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
419 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
420 | + } |
|
411 | 421 | $smcFunc['db_free_result']($query); |
412 | 422 | } |
413 | 423 | |
@@ -458,10 +468,11 @@ discard block |
||
458 | 468 | { |
459 | 469 | $context[$key] = !empty($_REQUEST[$post]) ? $_REQUEST[$post] : ''; |
460 | 470 | |
461 | - if (empty($context[$key]) && empty($_REQUEST['xml'])) |
|
462 | - $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
463 | - elseif (!empty($_REQUEST['xml'])) |
|
464 | - continue; |
|
471 | + if (empty($context[$key]) && empty($_REQUEST['xml'])) { |
|
472 | + $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
473 | + } elseif (!empty($_REQUEST['xml'])) { |
|
474 | + continue; |
|
475 | + } |
|
465 | 476 | |
466 | 477 | preparsecode($context[$key]); |
467 | 478 | if ($html) |
@@ -540,10 +551,12 @@ discard block |
||
540 | 551 | |
541 | 552 | // Start by finding any members! |
542 | 553 | $toClean = array(); |
543 | - if (!empty($_POST['members'])) |
|
544 | - $toClean[] = 'members'; |
|
545 | - if (!empty($_POST['exclude_members'])) |
|
546 | - $toClean[] = 'exclude_members'; |
|
554 | + if (!empty($_POST['members'])) { |
|
555 | + $toClean[] = 'members'; |
|
556 | + } |
|
557 | + if (!empty($_POST['exclude_members'])) { |
|
558 | + $toClean[] = 'exclude_members'; |
|
559 | + } |
|
547 | 560 | if (!empty($toClean)) |
548 | 561 | { |
549 | 562 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -555,11 +568,13 @@ discard block |
||
555 | 568 | preg_match_all('~"([^"]+)"~', $_POST[$type], $matches); |
556 | 569 | $_POST[$type] = array_unique(array_merge($matches[1], explode(',', preg_replace('~"[^"]+"~', '', $_POST[$type])))); |
557 | 570 | |
558 | - foreach ($_POST[$type] as $index => $member) |
|
559 | - if (strlen(trim($member)) > 0) |
|
571 | + foreach ($_POST[$type] as $index => $member) { |
|
572 | + if (strlen(trim($member)) > 0) |
|
560 | 573 | $_POST[$type][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($member))); |
561 | - else |
|
562 | - unset($_POST[$type][$index]); |
|
574 | + } |
|
575 | + else { |
|
576 | + unset($_POST[$type][$index]); |
|
577 | + } |
|
563 | 578 | |
564 | 579 | // Find the members |
565 | 580 | $_POST[$type] = implode(',', array_keys(findMembers($_POST[$type]))); |
@@ -569,16 +584,18 @@ discard block |
||
569 | 584 | if (isset($_POST['member_list']) && is_array($_POST['member_list'])) |
570 | 585 | { |
571 | 586 | $members = array(); |
572 | - foreach ($_POST['member_list'] as $member_id) |
|
573 | - $members[] = (int) $member_id; |
|
587 | + foreach ($_POST['member_list'] as $member_id) { |
|
588 | + $members[] = (int) $member_id; |
|
589 | + } |
|
574 | 590 | $_POST['members'] = implode(',', $members); |
575 | 591 | } |
576 | 592 | |
577 | 593 | if (isset($_POST['exclude_member_list']) && is_array($_POST['exclude_member_list'])) |
578 | 594 | { |
579 | 595 | $members = array(); |
580 | - foreach ($_POST['exclude_member_list'] as $member_id) |
|
581 | - $members[] = (int) $member_id; |
|
596 | + foreach ($_POST['exclude_member_list'] as $member_id) { |
|
597 | + $members[] = (int) $member_id; |
|
598 | + } |
|
582 | 599 | $_POST['exclude_members'] = implode(',', $members); |
583 | 600 | } |
584 | 601 | |
@@ -602,8 +619,9 @@ discard block |
||
602 | 619 | 'current_time' => time(), |
603 | 620 | ) |
604 | 621 | ); |
605 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
606 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
623 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
624 | + } |
|
607 | 625 | $smcFunc['db_free_result']($request); |
608 | 626 | |
609 | 627 | $request = $smcFunc['db_query']('', ' |
@@ -638,8 +656,9 @@ discard block |
||
638 | 656 | WHERE email_address IN(' . implode(', ', $condition_array) . ')', |
639 | 657 | $condition_array_params |
640 | 658 | ); |
641 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
642 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
659 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
660 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
661 | + } |
|
643 | 662 | $smcFunc['db_free_result']($request); |
644 | 663 | } |
645 | 664 | |
@@ -657,10 +676,11 @@ discard block |
||
657 | 676 | ); |
658 | 677 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
659 | 678 | { |
660 | - if (in_array(3, $context['recipients'])) |
|
661 | - $context['recipients']['exclude_members'][] = $row['identifier']; |
|
662 | - else |
|
663 | - $context['recipients']['members'][] = $row['identifier']; |
|
679 | + if (in_array(3, $context['recipients'])) { |
|
680 | + $context['recipients']['exclude_members'][] = $row['identifier']; |
|
681 | + } else { |
|
682 | + $context['recipients']['members'][] = $row['identifier']; |
|
683 | + } |
|
664 | 684 | } |
665 | 685 | $smcFunc['db_free_result']($request); |
666 | 686 | } |
@@ -707,8 +727,9 @@ discard block |
||
707 | 727 | $num_at_once = 1000; |
708 | 728 | |
709 | 729 | // If by PM's I suggest we half the above number. |
710 | - if (!empty($_POST['send_pm'])) |
|
711 | - $num_at_once /= 2; |
|
730 | + if (!empty($_POST['send_pm'])) { |
|
731 | + $num_at_once /= 2; |
|
732 | + } |
|
712 | 733 | |
713 | 734 | checkSession(); |
714 | 735 | |
@@ -731,8 +752,7 @@ discard block |
||
731 | 752 | ); |
732 | 753 | list ($context['total_members']) = $smcFunc['db_fetch_row']($request); |
733 | 754 | $smcFunc['db_free_result']($request); |
734 | - } |
|
735 | - else |
|
755 | + } else |
|
736 | 756 | { |
737 | 757 | $context['total_members'] = (int) $_REQUEST['total_members']; |
738 | 758 | } |
@@ -750,32 +770,35 @@ discard block |
||
750 | 770 | if (!empty($_POST['exclude_members'])) |
751 | 771 | { |
752 | 772 | $members = explode(',', $_POST['exclude_members']); |
753 | - foreach ($members as $member) |
|
754 | - if ($member >= $context['start']) |
|
773 | + foreach ($members as $member) { |
|
774 | + if ($member >= $context['start']) |
|
755 | 775 | $context['recipients']['exclude_members'][] = (int) $member; |
776 | + } |
|
756 | 777 | } |
757 | 778 | |
758 | 779 | // What about members we *must* do? |
759 | 780 | if (!empty($_POST['members'])) |
760 | 781 | { |
761 | 782 | $members = explode(',', $_POST['members']); |
762 | - foreach ($members as $member) |
|
763 | - if ($member >= $context['start']) |
|
783 | + foreach ($members as $member) { |
|
784 | + if ($member >= $context['start']) |
|
764 | 785 | $context['recipients']['members'][] = (int) $member; |
786 | + } |
|
765 | 787 | } |
766 | 788 | // Cleaning groups is simple - although deal with both checkbox and commas. |
767 | 789 | if (isset($_POST['groups'])) |
768 | 790 | { |
769 | 791 | if (is_array($_POST['groups'])) |
770 | 792 | { |
771 | - foreach ($_POST['groups'] as $group => $dummy) |
|
772 | - $context['recipients']['groups'][] = (int) $group; |
|
773 | - } |
|
774 | - else |
|
793 | + foreach ($_POST['groups'] as $group => $dummy) { |
|
794 | + $context['recipients']['groups'][] = (int) $group; |
|
795 | + } |
|
796 | + } else |
|
775 | 797 | { |
776 | 798 | $groups = explode(',', $_POST['groups']); |
777 | - foreach ($groups as $group) |
|
778 | - $context['recipients']['groups'][] = (int) $group; |
|
799 | + foreach ($groups as $group) { |
|
800 | + $context['recipients']['groups'][] = (int) $group; |
|
801 | + } |
|
779 | 802 | } |
780 | 803 | } |
781 | 804 | // Same for excluded groups |
@@ -783,14 +806,15 @@ discard block |
||
783 | 806 | { |
784 | 807 | if (is_array($_POST['exclude_groups'])) |
785 | 808 | { |
786 | - foreach ($_POST['exclude_groups'] as $group => $dummy) |
|
787 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
788 | - } |
|
789 | - else |
|
809 | + foreach ($_POST['exclude_groups'] as $group => $dummy) { |
|
810 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
811 | + } |
|
812 | + } else |
|
790 | 813 | { |
791 | 814 | $groups = explode(',', $_POST['exclude_groups']); |
792 | - foreach ($groups as $group) |
|
793 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
815 | + foreach ($groups as $group) { |
|
816 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
817 | + } |
|
794 | 818 | } |
795 | 819 | } |
796 | 820 | // Finally - emails! |
@@ -800,14 +824,16 @@ discard block |
||
800 | 824 | foreach ($addressed as $curmem) |
801 | 825 | { |
802 | 826 | $curmem = trim($curmem); |
803 | - if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) |
|
804 | - $context['recipients']['emails'][$curmem] = $curmem; |
|
827 | + if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) { |
|
828 | + $context['recipients']['emails'][$curmem] = $curmem; |
|
829 | + } |
|
805 | 830 | } |
806 | 831 | } |
807 | 832 | |
808 | 833 | // If we're only cleaning drop out here. |
809 | - if ($clean_only) |
|
810 | - return; |
|
834 | + if ($clean_only) { |
|
835 | + return; |
|
836 | + } |
|
811 | 837 | |
812 | 838 | require_once($sourcedir . '/Subs-Post.php'); |
813 | 839 | |
@@ -823,16 +849,18 @@ discard block |
||
823 | 849 | if (!$context['send_pm'] && !empty($_POST['send_html'])) |
824 | 850 | { |
825 | 851 | // Prepare the message for HTML. |
826 | - if (!empty($_POST['parse_html'])) |
|
827 | - $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
852 | + if (!empty($_POST['parse_html'])) { |
|
853 | + $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
854 | + } |
|
828 | 855 | |
829 | 856 | // This is here to prevent spam filters from tagging this as spam. |
830 | 857 | if (preg_match('~\<html~i', $_POST['message']) == 0) |
831 | 858 | { |
832 | - if (preg_match('~\<body~i', $_POST['message']) == 0) |
|
833 | - $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
834 | - else |
|
835 | - $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
859 | + if (preg_match('~\<body~i', $_POST['message']) == 0) { |
|
860 | + $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
861 | + } else { |
|
862 | + $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
863 | + } |
|
836 | 864 | } |
837 | 865 | } |
838 | 866 | |
@@ -886,15 +914,17 @@ discard block |
||
886 | 914 | foreach ($context['recipients']['emails'] as $k => $email) |
887 | 915 | { |
888 | 916 | // Done as many as we can? |
889 | - if ($i >= $num_at_once) |
|
890 | - break; |
|
917 | + if ($i >= $num_at_once) { |
|
918 | + break; |
|
919 | + } |
|
891 | 920 | |
892 | 921 | // Don't sent it twice! |
893 | 922 | unset($context['recipients']['emails'][$k]); |
894 | 923 | |
895 | 924 | // Dammit - can't PM emails! |
896 | - if ($context['send_pm']) |
|
897 | - continue; |
|
925 | + if ($context['send_pm']) { |
|
926 | + continue; |
|
927 | + } |
|
898 | 928 | |
899 | 929 | $to_member = array( |
900 | 930 | $email, |
@@ -928,8 +958,9 @@ discard block |
||
928 | 958 | $queryBuild[] = 'mem.id_post_group = {int:group_' . $group . '}'; |
929 | 959 | } |
930 | 960 | } |
931 | - if (!empty($queryBuild)) |
|
932 | - $sendQuery .= implode(' OR ', $queryBuild); |
|
961 | + if (!empty($queryBuild)) { |
|
962 | + $sendQuery .= implode(' OR ', $queryBuild); |
|
963 | + } |
|
933 | 964 | } |
934 | 965 | if (!empty($context['recipients']['members'])) |
935 | 966 | { |
@@ -948,8 +979,9 @@ discard block |
||
948 | 979 | } |
949 | 980 | |
950 | 981 | // Anything to exclude? |
951 | - if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) |
|
952 | - $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
982 | + if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) { |
|
983 | + $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
984 | + } |
|
953 | 985 | if (!empty($context['recipients']['exclude_members'])) |
954 | 986 | { |
955 | 987 | $sendQuery .= ' AND mem.id_member NOT IN ({array_int:exclude_members})'; |
@@ -985,21 +1017,24 @@ discard block |
||
985 | 1017 | foreach ($rows as $row) |
986 | 1018 | { |
987 | 1019 | // Force them to have it? |
988 | - if (empty($context['email_force']) || empty($prefs[$row['id_member']]['announcements'])) |
|
989 | - continue; |
|
1020 | + if (empty($context['email_force']) || empty($prefs[$row['id_member']]['announcements'])) { |
|
1021 | + continue; |
|
1022 | + } |
|
990 | 1023 | |
991 | 1024 | // What groups are we looking at here? |
992 | - if (empty($row['additional_groups'])) |
|
993 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
994 | - else |
|
995 | - $groups = array_merge( |
|
1025 | + if (empty($row['additional_groups'])) { |
|
1026 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
1027 | + } else { |
|
1028 | + $groups = array_merge( |
|
996 | 1029 | array($row['id_group'], $row['id_post_group']), |
997 | 1030 | explode(',', $row['additional_groups']) |
998 | 1031 | ); |
1032 | + } |
|
999 | 1033 | |
1000 | 1034 | // Excluded groups? |
1001 | - if (array_intersect($groups, $context['recipients']['exclude_groups'])) |
|
1002 | - continue; |
|
1035 | + if (array_intersect($groups, $context['recipients']['exclude_groups'])) { |
|
1036 | + continue; |
|
1037 | + } |
|
1003 | 1038 | |
1004 | 1039 | // We might need this |
1005 | 1040 | $cleanMemberName = empty($_POST['send_html']) || $context['send_pm'] ? un_htmlspecialchars($row['real_name']) : $row['real_name']; |
@@ -1022,10 +1057,11 @@ discard block |
||
1022 | 1057 | ), $_POST['subject']); |
1023 | 1058 | |
1024 | 1059 | // Send the actual email - or a PM! |
1025 | - if (!$context['send_pm']) |
|
1026 | - sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
1027 | - else |
|
1028 | - sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
1060 | + if (!$context['send_pm']) { |
|
1061 | + sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
1062 | + } else { |
|
1063 | + sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
1064 | + } |
|
1029 | 1065 | } |
1030 | 1066 | } |
1031 | 1067 | |
@@ -1075,8 +1111,9 @@ discard block |
||
1075 | 1111 | |
1076 | 1112 | call_integration_hook('integrate_modify_news_settings', array(&$config_vars)); |
1077 | 1113 | |
1078 | - if ($return_config) |
|
1079 | - return $config_vars; |
|
1114 | + if ($return_config) { |
|
1115 | + return $config_vars; |
|
1116 | + } |
|
1080 | 1117 | |
1081 | 1118 | $context['page_title'] = $txt['admin_edit_news'] . ' - ' . $txt['settings']; |
1082 | 1119 | $context['sub_template'] = 'show_settings'; |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * View the forum's error log. |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | global $scripturl, $txt, $context, $modSettings, $user_profile, $filter, $smcFunc; |
31 | 32 | |
32 | 33 | // Viewing contents of a file? |
33 | - if (isset($_GET['file'])) |
|
34 | - return ViewFile(); |
|
34 | + if (isset($_GET['file'])) { |
|
35 | + return ViewFile(); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // Check for the administrative permission to do this. |
37 | 39 | isAllowedTo('admin_forum'); |
@@ -85,8 +87,8 @@ discard block |
||
85 | 87 | ); |
86 | 88 | |
87 | 89 | // Set up the filtering... |
88 | - if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) |
|
89 | - $filter = array( |
|
90 | + if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) { |
|
91 | + $filter = array( |
|
90 | 92 | 'variable' => $_GET['filter'], |
91 | 93 | 'value' => array( |
92 | 94 | 'sql' => in_array($_GET['filter'], array('message', 'url', 'file')) ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : $smcFunc['db_escape_wildcard_string']($_GET['value']), |
@@ -94,10 +96,12 @@ discard block |
||
94 | 96 | 'href' => ';filter=' . $_GET['filter'] . ';value=' . $_GET['value'], |
95 | 97 | 'entity' => $filters[$_GET['filter']]['txt'] |
96 | 98 | ); |
99 | + } |
|
97 | 100 | |
98 | 101 | // Deleting, are we? |
99 | - if (isset($_POST['delall']) || isset($_POST['delete'])) |
|
100 | - deleteErrors(); |
|
102 | + if (isset($_POST['delall']) || isset($_POST['delete'])) { |
|
103 | + deleteErrors(); |
|
104 | + } |
|
101 | 105 | |
102 | 106 | // Just how many errors are there? |
103 | 107 | $result = $smcFunc['db_query']('', ' |
@@ -112,12 +116,14 @@ discard block |
||
112 | 116 | $smcFunc['db_free_result']($result); |
113 | 117 | |
114 | 118 | // If this filter is empty... |
115 | - if ($num_errors == 0 && isset($filter)) |
|
116 | - redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
119 | + if ($num_errors == 0 && isset($filter)) { |
|
120 | + redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
121 | + } |
|
117 | 122 | |
118 | 123 | // Clean up start. |
119 | - if (!isset($_GET['start']) || $_GET['start'] < 0) |
|
120 | - $_GET['start'] = 0; |
|
124 | + if (!isset($_GET['start']) || $_GET['start'] < 0) { |
|
125 | + $_GET['start'] = 0; |
|
126 | + } |
|
121 | 127 | |
122 | 128 | // Do we want to reverse error listing? |
123 | 129 | $context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up'; |
@@ -127,9 +133,9 @@ discard block |
||
127 | 133 | $context['start'] = $_GET['start']; |
128 | 134 | |
129 | 135 | // Update the error count |
130 | - if (!isset($filter)) |
|
131 | - $context['num_errors'] = $num_errors; |
|
132 | - else |
|
136 | + if (!isset($filter)) { |
|
137 | + $context['num_errors'] = $num_errors; |
|
138 | + } else |
|
133 | 139 | { |
134 | 140 | // We want all errors, not just the number of filtered messages... |
135 | 141 | $query = $smcFunc['db_query']('', ' |
@@ -161,8 +167,9 @@ discard block |
||
161 | 167 | for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i++) |
162 | 168 | { |
163 | 169 | $search_message = preg_replace('~<span class="remove">(.+?)</span>~', '%', $smcFunc['db_escape_wildcard_string']($row['message'])); |
164 | - if ($search_message == $filter['value']['sql']) |
|
165 | - $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
170 | + if ($search_message == $filter['value']['sql']) { |
|
171 | + $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
172 | + } |
|
166 | 173 | $show_message = strtr(strtr(preg_replace('~<span class="remove">(.+?)</span>~', '$1', $row['message']), array("\r" => '', '<br>' => "\n", '<' => '<', '>' => '>', '"' => '"')), array("\n" => '<br>')); |
167 | 174 | |
168 | 175 | $context['errors'][$row['id_error']] = array( |
@@ -221,8 +228,9 @@ discard block |
||
221 | 228 | 'members' => count($members), |
222 | 229 | ) |
223 | 230 | ); |
224 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
225 | - $members[$row['id_member']] = $row; |
|
231 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
232 | + $members[$row['id_member']] = $row; |
|
233 | + } |
|
226 | 234 | $smcFunc['db_free_result']($request); |
227 | 235 | |
228 | 236 | // This is a guest... |
@@ -254,20 +262,18 @@ discard block |
||
254 | 262 | $id = $filter['value']['sql']; |
255 | 263 | loadMemberData($id, false, 'minimal'); |
256 | 264 | $context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>'; |
257 | - } |
|
258 | - elseif ($filter['variable'] == 'url') |
|
259 | - $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
260 | - elseif ($filter['variable'] == 'message') |
|
265 | + } elseif ($filter['variable'] == 'url') { |
|
266 | + $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
267 | + } elseif ($filter['variable'] == 'message') |
|
261 | 268 | { |
262 | 269 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
263 | 270 | $context['filter']['value']['html'] = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $context['filter']['value']['html']); |
264 | - } |
|
265 | - elseif ($filter['variable'] == 'error_type') |
|
271 | + } elseif ($filter['variable'] == 'error_type') |
|
266 | 272 | { |
267 | 273 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
274 | + } else { |
|
275 | + $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
268 | 276 | } |
269 | - else |
|
270 | - $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
271 | 277 | } |
272 | 278 | |
273 | 279 | $context['error_types'] = array(); |
@@ -308,10 +314,11 @@ discard block |
||
308 | 314 | $context['error_types']['all']['label'] .= ' (' . $sum . ')'; |
309 | 315 | |
310 | 316 | // Finally, work out what is the last tab! |
311 | - if (isset($context['error_types'][$sum])) |
|
312 | - $context['error_types'][$sum]['is_last'] = true; |
|
313 | - else |
|
314 | - $context['error_types']['all']['is_last'] = true; |
|
317 | + if (isset($context['error_types'][$sum])) { |
|
318 | + $context['error_types'][$sum]['is_last'] = true; |
|
319 | + } else { |
|
320 | + $context['error_types']['all']['is_last'] = true; |
|
321 | + } |
|
315 | 322 | |
316 | 323 | // And this is pretty basic ;). |
317 | 324 | $context['page_title'] = $txt['errlog']; |
@@ -337,21 +344,23 @@ discard block |
||
337 | 344 | validateToken('admin-el'); |
338 | 345 | |
339 | 346 | // Delete all or just some? |
340 | - if (isset($_POST['delall']) && !isset($filter)) |
|
341 | - $smcFunc['db_query']('truncate_table', ' |
|
347 | + if (isset($_POST['delall']) && !isset($filter)) { |
|
348 | + $smcFunc['db_query']('truncate_table', ' |
|
342 | 349 | TRUNCATE {db_prefix}log_errors', |
343 | 350 | array( |
344 | 351 | ) |
345 | 352 | ); |
353 | + } |
|
346 | 354 | // Deleting all with a filter? |
347 | - elseif (isset($_POST['delall']) && isset($filter)) |
|
348 | - $smcFunc['db_query']('', ' |
|
355 | + elseif (isset($_POST['delall']) && isset($filter)) { |
|
356 | + $smcFunc['db_query']('', ' |
|
349 | 357 | DELETE FROM {db_prefix}log_errors |
350 | 358 | WHERE ' . $filter['variable'] . ' LIKE {string:filter}', |
351 | 359 | array( |
352 | 360 | 'filter' => $filter['value']['sql'], |
353 | 361 | ) |
354 | 362 | ); |
363 | + } |
|
355 | 364 | // Just specific errors? |
356 | 365 | elseif (!empty($_POST['delete'])) |
357 | 366 | { |
@@ -397,15 +406,17 @@ discard block |
||
397 | 406 | $line = isset($_REQUEST['line']) ? (int) $_REQUEST['line'] : 0; |
398 | 407 | |
399 | 408 | // Make sure the file we are looking for is one they are allowed to look at |
400 | - if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) |
|
401 | - fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
409 | + if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) { |
|
410 | + fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
411 | + } |
|
402 | 412 | |
403 | 413 | // get the min and max lines |
404 | 414 | $min = $line - 20 <= 0 ? 1 : $line - 20; |
405 | 415 | $max = $line + 21; // One additional line to make everything work out correctly |
406 | 416 | |
407 | - if ($max <= 0 || $min >= $max) |
|
408 | - fatal_lang_error('error_bad_line'); |
|
417 | + if ($max <= 0 || $min >= $max) { |
|
418 | + fatal_lang_error('error_bad_line'); |
|
419 | + } |
|
409 | 420 | |
410 | 421 | $file_data = explode('<br />', highlight_php_code($smcFunc['htmlspecialchars'](implode('', file($file))))); |
411 | 422 |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Mark a board or multiple boards read. |
@@ -28,14 +29,16 @@ discard block |
||
28 | 29 | global $user_info, $modSettings, $smcFunc; |
29 | 30 | |
30 | 31 | // Force $boards to be an array. |
31 | - if (!is_array($boards)) |
|
32 | - $boards = array($boards); |
|
33 | - else |
|
34 | - $boards = array_unique($boards); |
|
32 | + if (!is_array($boards)) { |
|
33 | + $boards = array($boards); |
|
34 | + } else { |
|
35 | + $boards = array_unique($boards); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // No boards, nothing to mark as read. |
37 | - if (empty($boards)) |
|
38 | - return; |
|
39 | + if (empty($boards)) { |
|
40 | + return; |
|
41 | + } |
|
39 | 42 | |
40 | 43 | // Allow the user to mark a board as unread. |
41 | 44 | if ($unread) |
@@ -65,8 +68,9 @@ discard block |
||
65 | 68 | else |
66 | 69 | { |
67 | 70 | $markRead = array(); |
68 | - foreach ($boards as $board) |
|
69 | - $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board); |
|
71 | + foreach ($boards as $board) { |
|
72 | + $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board); |
|
73 | + } |
|
70 | 74 | |
71 | 75 | // Update log_mark_read and log_boards. |
72 | 76 | $smcFunc['db_insert']('replace', |
@@ -99,8 +103,9 @@ discard block |
||
99 | 103 | list ($lowest_topic) = $smcFunc['db_fetch_row']($result); |
100 | 104 | $smcFunc['db_free_result']($result); |
101 | 105 | |
102 | - if (empty($lowest_topic)) |
|
103 | - return; |
|
106 | + if (empty($lowest_topic)) { |
|
107 | + return; |
|
108 | + } |
|
104 | 109 | |
105 | 110 | // @todo SLOW This query seems to eat it sometimes. |
106 | 111 | $result = $smcFunc['db_query']('', ' |
@@ -118,12 +123,13 @@ discard block |
||
118 | 123 | ) |
119 | 124 | ); |
120 | 125 | $topics = array(); |
121 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
122 | - $topics[] = $row['id_topic']; |
|
126 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
127 | + $topics[] = $row['id_topic']; |
|
128 | + } |
|
123 | 129 | $smcFunc['db_free_result']($result); |
124 | 130 | |
125 | - if (!empty($topics)) |
|
126 | - $smcFunc['db_query']('', ' |
|
131 | + if (!empty($topics)) { |
|
132 | + $smcFunc['db_query']('', ' |
|
127 | 133 | DELETE FROM {db_prefix}log_topics |
128 | 134 | WHERE id_member = {int:current_member} |
129 | 135 | AND id_topic IN ({array_int:topic_list})', |
@@ -132,7 +138,8 @@ discard block |
||
132 | 138 | 'topic_list' => $topics, |
133 | 139 | ) |
134 | 140 | ); |
135 | -} |
|
141 | + } |
|
142 | + } |
|
136 | 143 | |
137 | 144 | /** |
138 | 145 | * Mark one or more boards as read. |
@@ -157,23 +164,26 @@ discard block |
||
157 | 164 | ) |
158 | 165 | ); |
159 | 166 | $boards = array(); |
160 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
161 | - $boards[] = $row['id_board']; |
|
167 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
168 | + $boards[] = $row['id_board']; |
|
169 | + } |
|
162 | 170 | $smcFunc['db_free_result']($result); |
163 | 171 | |
164 | - if (!empty($boards)) |
|
165 | - markBoardsRead($boards, isset($_REQUEST['unread'])); |
|
172 | + if (!empty($boards)) { |
|
173 | + markBoardsRead($boards, isset($_REQUEST['unread'])); |
|
174 | + } |
|
166 | 175 | |
167 | 176 | $_SESSION['id_msg_last_visit'] = $modSettings['maxMsgID']; |
168 | - if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) |
|
169 | - redirectexit('action=unread'); |
|
177 | + if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) { |
|
178 | + redirectexit('action=unread'); |
|
179 | + } |
|
170 | 180 | |
171 | - if (isset($_SESSION['topicseen_cache'])) |
|
172 | - $_SESSION['topicseen_cache'] = array(); |
|
181 | + if (isset($_SESSION['topicseen_cache'])) { |
|
182 | + $_SESSION['topicseen_cache'] = array(); |
|
183 | + } |
|
173 | 184 | |
174 | 185 | redirectexit(); |
175 | - } |
|
176 | - elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies') |
|
186 | + } elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies') |
|
177 | 187 | { |
178 | 188 | // Make sure all the topics are integers! |
179 | 189 | $topics = array_map('intval', explode('-', $_REQUEST['topics'])); |
@@ -189,13 +199,15 @@ discard block |
||
189 | 199 | ) |
190 | 200 | ); |
191 | 201 | $logged_topics = array(); |
192 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
193 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
202 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
203 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
204 | + } |
|
194 | 205 | $smcFunc['db_free_result']($request); |
195 | 206 | |
196 | 207 | $markRead = array(); |
197 | - foreach ($topics as $id_topic) |
|
198 | - $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
208 | + foreach ($topics as $id_topic) { |
|
209 | + $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
210 | + } |
|
199 | 211 | |
200 | 212 | $smcFunc['db_insert']('replace', |
201 | 213 | '{db_prefix}log_topics', |
@@ -204,8 +216,9 @@ discard block |
||
204 | 216 | array('id_member', 'id_topic') |
205 | 217 | ); |
206 | 218 | |
207 | - if (isset($_SESSION['topicseen_cache'])) |
|
208 | - $_SESSION['topicseen_cache'] = array(); |
|
219 | + if (isset($_SESSION['topicseen_cache'])) { |
|
220 | + $_SESSION['topicseen_cache'] = array(); |
|
221 | + } |
|
209 | 222 | |
210 | 223 | redirectexit('action=unreadreplies'); |
211 | 224 | } |
@@ -230,11 +243,13 @@ discard block |
||
230 | 243 | if (!empty($_GET['t'])) |
231 | 244 | { |
232 | 245 | // If they read the whole topic, go back to the beginning. |
233 | - if ($_GET['t'] >= $topicinfo['id_last_msg']) |
|
234 | - $earlyMsg = 0; |
|
246 | + if ($_GET['t'] >= $topicinfo['id_last_msg']) { |
|
247 | + $earlyMsg = 0; |
|
248 | + } |
|
235 | 249 | // If they want to mark the whole thing read, same. |
236 | - elseif ($_GET['t'] <= $topicinfo['id_first_msg']) |
|
237 | - $earlyMsg = 0; |
|
250 | + elseif ($_GET['t'] <= $topicinfo['id_first_msg']) { |
|
251 | + $earlyMsg = 0; |
|
252 | + } |
|
238 | 253 | // Otherwise, get the latest message before the named one. |
239 | 254 | else |
240 | 255 | { |
@@ -255,9 +270,9 @@ discard block |
||
255 | 270 | } |
256 | 271 | } |
257 | 272 | // Marking read from first page? That's the whole topic. |
258 | - elseif ($_REQUEST['start'] == 0) |
|
259 | - $earlyMsg = 0; |
|
260 | - else |
|
273 | + elseif ($_REQUEST['start'] == 0) { |
|
274 | + $earlyMsg = 0; |
|
275 | + } else |
|
261 | 276 | { |
262 | 277 | $result = $smcFunc['db_query']('', ' |
263 | 278 | SELECT id_msg |
@@ -285,8 +300,7 @@ discard block |
||
285 | 300 | ); |
286 | 301 | |
287 | 302 | redirectexit('board=' . $board . '.0'); |
288 | - } |
|
289 | - else |
|
303 | + } else |
|
290 | 304 | { |
291 | 305 | $categories = array(); |
292 | 306 | $boards = array(); |
@@ -294,17 +308,20 @@ discard block |
||
294 | 308 | if (isset($_REQUEST['c'])) |
295 | 309 | { |
296 | 310 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
297 | - foreach ($_REQUEST['c'] as $c) |
|
298 | - $categories[] = (int) $c; |
|
311 | + foreach ($_REQUEST['c'] as $c) { |
|
312 | + $categories[] = (int) $c; |
|
313 | + } |
|
299 | 314 | } |
300 | 315 | if (isset($_REQUEST['boards'])) |
301 | 316 | { |
302 | 317 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
303 | - foreach ($_REQUEST['boards'] as $b) |
|
304 | - $boards[] = (int) $b; |
|
318 | + foreach ($_REQUEST['boards'] as $b) { |
|
319 | + $boards[] = (int) $b; |
|
320 | + } |
|
321 | + } |
|
322 | + if (!empty($board)) { |
|
323 | + $boards[] = (int) $board; |
|
305 | 324 | } |
306 | - if (!empty($board)) |
|
307 | - $boards[] = (int) $board; |
|
308 | 325 | |
309 | 326 | if (isset($_REQUEST['children']) && !empty($boards)) |
310 | 327 | { |
@@ -324,9 +341,10 @@ discard block |
||
324 | 341 | 'board_list' => $boards, |
325 | 342 | ) |
326 | 343 | ); |
327 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
328 | - if (in_array($row['id_parent'], $boards)) |
|
344 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
345 | + if (in_array($row['id_parent'], $boards)) |
|
329 | 346 | $boards[] = $row['id_board']; |
347 | + } |
|
330 | 348 | $smcFunc['db_free_result']($request); |
331 | 349 | } |
332 | 350 | |
@@ -343,8 +361,9 @@ discard block |
||
343 | 361 | $clauseParameters['board_list'] = $boards; |
344 | 362 | } |
345 | 363 | |
346 | - if (empty($clauses)) |
|
347 | - redirectexit(); |
|
364 | + if (empty($clauses)) { |
|
365 | + redirectexit(); |
|
366 | + } |
|
348 | 367 | |
349 | 368 | $request = $smcFunc['db_query']('', ' |
350 | 369 | SELECT b.id_board |
@@ -355,19 +374,22 @@ discard block |
||
355 | 374 | )) |
356 | 375 | ); |
357 | 376 | $boards = array(); |
358 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
359 | - $boards[] = $row['id_board']; |
|
377 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
378 | + $boards[] = $row['id_board']; |
|
379 | + } |
|
360 | 380 | $smcFunc['db_free_result']($request); |
361 | 381 | |
362 | - if (empty($boards)) |
|
363 | - redirectexit(); |
|
382 | + if (empty($boards)) { |
|
383 | + redirectexit(); |
|
384 | + } |
|
364 | 385 | |
365 | 386 | markBoardsRead($boards, isset($_REQUEST['unread'])); |
366 | 387 | |
367 | 388 | foreach ($boards as $b) |
368 | 389 | { |
369 | - if (isset($_SESSION['topicseen_cache'][$b])) |
|
370 | - $_SESSION['topicseen_cache'][$b] = array(); |
|
390 | + if (isset($_SESSION['topicseen_cache'][$b])) { |
|
391 | + $_SESSION['topicseen_cache'][$b] = array(); |
|
392 | + } |
|
371 | 393 | } |
372 | 394 | |
373 | 395 | if (!isset($_REQUEST['unread'])) |
@@ -385,8 +407,9 @@ discard block |
||
385 | 407 | if ($smcFunc['db_num_rows']($result) > 0) |
386 | 408 | { |
387 | 409 | $logBoardInserts = ''; |
388 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
389 | - $logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']); |
|
410 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
411 | + $logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']); |
|
412 | + } |
|
390 | 413 | |
391 | 414 | $smcFunc['db_insert']('replace', |
392 | 415 | '{db_prefix}log_boards', |
@@ -397,17 +420,18 @@ discard block |
||
397 | 420 | } |
398 | 421 | $smcFunc['db_free_result']($result); |
399 | 422 | |
400 | - if (empty($board)) |
|
401 | - redirectexit(); |
|
402 | - else |
|
403 | - redirectexit('board=' . $board . '.0'); |
|
404 | - } |
|
405 | - else |
|
423 | + if (empty($board)) { |
|
424 | + redirectexit(); |
|
425 | + } else { |
|
426 | + redirectexit('board=' . $board . '.0'); |
|
427 | + } |
|
428 | + } else |
|
406 | 429 | { |
407 | - if (empty($board_info['parent'])) |
|
408 | - redirectexit(); |
|
409 | - else |
|
410 | - redirectexit('board=' . $board_info['parent'] . '.0'); |
|
430 | + if (empty($board_info['parent'])) { |
|
431 | + redirectexit(); |
|
432 | + } else { |
|
433 | + redirectexit('board=' . $board_info['parent'] . '.0'); |
|
434 | + } |
|
411 | 435 | } |
412 | 436 | } |
413 | 437 | } |
@@ -432,11 +456,13 @@ discard block |
||
432 | 456 | 'selected_message' => (int) $messageID, |
433 | 457 | ) |
434 | 458 | ); |
435 | - if ($smcFunc['db_num_rows']($result) > 0) |
|
436 | - list ($memberID) = $smcFunc['db_fetch_row']($result); |
|
459 | + if ($smcFunc['db_num_rows']($result) > 0) { |
|
460 | + list ($memberID) = $smcFunc['db_fetch_row']($result); |
|
461 | + } |
|
437 | 462 | // The message doesn't even exist. |
438 | - else |
|
439 | - $memberID = 0; |
|
463 | + else { |
|
464 | + $memberID = 0; |
|
465 | + } |
|
440 | 466 | $smcFunc['db_free_result']($result); |
441 | 467 | |
442 | 468 | return (int) $memberID; |
@@ -457,8 +483,9 @@ discard block |
||
457 | 483 | getBoardTree(); |
458 | 484 | |
459 | 485 | // Make sure given boards and categories exist. |
460 | - if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) |
|
461 | - fatal_lang_error('no_board'); |
|
486 | + if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) { |
|
487 | + fatal_lang_error('no_board'); |
|
488 | + } |
|
462 | 489 | |
463 | 490 | $id = $board_id; |
464 | 491 | call_integration_hook('integrate_pre_modify_board', array($id, &$boardOptions)); |
@@ -486,8 +513,9 @@ discard block |
||
486 | 513 | $child_level = 0; |
487 | 514 | $id_parent = 0; |
488 | 515 | $after = 0; |
489 | - foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) |
|
490 | - $after = max($after, $boards[$id_board]['order']); |
|
516 | + foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) { |
|
517 | + $after = max($after, $boards[$id_board]['order']); |
|
518 | + } |
|
491 | 519 | } |
492 | 520 | |
493 | 521 | // Make the board a child of a given board. |
@@ -498,17 +526,19 @@ discard block |
||
498 | 526 | $id_parent = $boardOptions['target_board']; |
499 | 527 | |
500 | 528 | // People can be creative, in many ways... |
501 | - if (isChildOf($id_parent, $board_id)) |
|
502 | - fatal_lang_error('mboards_parent_own_child_error', false); |
|
503 | - elseif ($id_parent == $board_id) |
|
504 | - fatal_lang_error('mboards_board_own_child_error', false); |
|
529 | + if (isChildOf($id_parent, $board_id)) { |
|
530 | + fatal_lang_error('mboards_parent_own_child_error', false); |
|
531 | + } elseif ($id_parent == $board_id) { |
|
532 | + fatal_lang_error('mboards_board_own_child_error', false); |
|
533 | + } |
|
505 | 534 | |
506 | 535 | $after = $boards[$boardOptions['target_board']]['order']; |
507 | 536 | |
508 | 537 | // Check if there are already children and (if so) get the max board order. |
509 | - if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) |
|
510 | - foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy) |
|
538 | + if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) { |
|
539 | + foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy) |
|
511 | 540 | $after = max($after, $boards[$childBoard_id]['order']); |
541 | + } |
|
512 | 542 | } |
513 | 543 | |
514 | 544 | // Place a board before or after another board, on the same child level. |
@@ -521,8 +551,9 @@ discard block |
||
521 | 551 | } |
522 | 552 | |
523 | 553 | // Oops...? |
524 | - else |
|
525 | - trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR); |
|
554 | + else { |
|
555 | + trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR); |
|
556 | + } |
|
526 | 557 | |
527 | 558 | // Get a list of children of this board. |
528 | 559 | $childList = array(); |
@@ -531,14 +562,16 @@ discard block |
||
531 | 562 | // See if there are changes that affect children. |
532 | 563 | $childUpdates = array(); |
533 | 564 | $levelDiff = $child_level - $boards[$board_id]['level']; |
534 | - if ($levelDiff != 0) |
|
535 | - $childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}'; |
|
536 | - if ($id_cat != $boards[$board_id]['category']) |
|
537 | - $childUpdates[] = 'id_cat = {int:category}'; |
|
565 | + if ($levelDiff != 0) { |
|
566 | + $childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}'; |
|
567 | + } |
|
568 | + if ($id_cat != $boards[$board_id]['category']) { |
|
569 | + $childUpdates[] = 'id_cat = {int:category}'; |
|
570 | + } |
|
538 | 571 | |
539 | 572 | // Fix the children of this board. |
540 | - if (!empty($childList) && !empty($childUpdates)) |
|
541 | - $smcFunc['db_query']('', ' |
|
573 | + if (!empty($childList) && !empty($childUpdates)) { |
|
574 | + $smcFunc['db_query']('', ' |
|
542 | 575 | UPDATE {db_prefix}boards |
543 | 576 | SET ' . implode(', |
544 | 577 | ', $childUpdates) . ' |
@@ -549,6 +582,7 @@ discard block |
||
549 | 582 | 'level_diff' => $levelDiff, |
550 | 583 | ) |
551 | 584 | ); |
585 | + } |
|
552 | 586 | |
553 | 587 | // Make some room for this spot. |
554 | 588 | $smcFunc['db_query']('', ' |
@@ -644,8 +678,8 @@ discard block |
||
644 | 678 | call_integration_hook('integrate_modify_board', array($id, &$boardUpdates, &$boardUpdateParameters)); |
645 | 679 | |
646 | 680 | // Do the updates (if any). |
647 | - if (!empty($boardUpdates)) |
|
648 | - $smcFunc['db_query']('', ' |
|
681 | + if (!empty($boardUpdates)) { |
|
682 | + $smcFunc['db_query']('', ' |
|
649 | 683 | UPDATE {db_prefix}boards |
650 | 684 | SET |
651 | 685 | ' . implode(', |
@@ -655,6 +689,7 @@ discard block |
||
655 | 689 | 'selected_board' => $board_id, |
656 | 690 | )) |
657 | 691 | ); |
692 | + } |
|
658 | 693 | |
659 | 694 | // Set moderators of this board. |
660 | 695 | if (isset($boardOptions['moderators']) || isset($boardOptions['moderator_string']) || isset($boardOptions['moderator_groups']) || isset($boardOptions['moderator_group_string'])) |
@@ -679,13 +714,15 @@ discard block |
||
679 | 714 | { |
680 | 715 | $moderators[$k] = trim($moderators[$k]); |
681 | 716 | |
682 | - if (strlen($moderators[$k]) == 0) |
|
683 | - unset($moderators[$k]); |
|
717 | + if (strlen($moderators[$k]) == 0) { |
|
718 | + unset($moderators[$k]); |
|
719 | + } |
|
684 | 720 | } |
685 | 721 | |
686 | 722 | // Find all the id_member's for the member_name's in the list. |
687 | - if (empty($boardOptions['moderators'])) |
|
688 | - $boardOptions['moderators'] = array(); |
|
723 | + if (empty($boardOptions['moderators'])) { |
|
724 | + $boardOptions['moderators'] = array(); |
|
725 | + } |
|
689 | 726 | if (!empty($moderators)) |
690 | 727 | { |
691 | 728 | $request = $smcFunc['db_query']('', ' |
@@ -698,8 +735,9 @@ discard block |
||
698 | 735 | 'limit' => count($moderators), |
699 | 736 | ) |
700 | 737 | ); |
701 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
702 | - $boardOptions['moderators'][] = $row['id_member']; |
|
738 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
739 | + $boardOptions['moderators'][] = $row['id_member']; |
|
740 | + } |
|
703 | 741 | $smcFunc['db_free_result']($request); |
704 | 742 | } |
705 | 743 | } |
@@ -708,8 +746,9 @@ discard block |
||
708 | 746 | if (!empty($boardOptions['moderators'])) |
709 | 747 | { |
710 | 748 | $inserts = array(); |
711 | - foreach ($boardOptions['moderators'] as $moderator) |
|
712 | - $inserts[] = array($board_id, $moderator); |
|
749 | + foreach ($boardOptions['moderators'] as $moderator) { |
|
750 | + $inserts[] = array($board_id, $moderator); |
|
751 | + } |
|
713 | 752 | |
714 | 753 | $smcFunc['db_insert']('insert', |
715 | 754 | '{db_prefix}moderators', |
@@ -739,14 +778,16 @@ discard block |
||
739 | 778 | { |
740 | 779 | $moderator_groups[$k] = trim($moderator_groups[$k]); |
741 | 780 | |
742 | - if (strlen($moderator_groups[$k]) == 0) |
|
743 | - unset($moderator_groups[$k]); |
|
781 | + if (strlen($moderator_groups[$k]) == 0) { |
|
782 | + unset($moderator_groups[$k]); |
|
783 | + } |
|
744 | 784 | } |
745 | 785 | |
746 | 786 | /* Find all the id_group's for all the group names in the list |
747 | 787 | But skip any invalid ones (invisible/post groups/Administrator/Moderator) */ |
748 | - if (empty($boardOptions['moderator_groups'])) |
|
749 | - $boardOptions['moderator_groups'] = array(); |
|
788 | + if (empty($boardOptions['moderator_groups'])) { |
|
789 | + $boardOptions['moderator_groups'] = array(); |
|
790 | + } |
|
750 | 791 | if (!empty($moderator_groups)) |
751 | 792 | { |
752 | 793 | $request = $smcFunc['db_query']('', ' |
@@ -777,8 +818,9 @@ discard block |
||
777 | 818 | if (!empty($boardOptions['moderator_groups'])) |
778 | 819 | { |
779 | 820 | $inserts = array(); |
780 | - foreach ($boardOptions['moderator_groups'] as $moderator_group) |
|
781 | - $inserts[] = array($board_id, $moderator_group); |
|
821 | + foreach ($boardOptions['moderator_groups'] as $moderator_group) { |
|
822 | + $inserts[] = array($board_id, $moderator_group); |
|
823 | + } |
|
782 | 824 | |
783 | 825 | $smcFunc['db_insert']('insert', |
784 | 826 | '{db_prefix}moderator_groups', |
@@ -792,14 +834,16 @@ discard block |
||
792 | 834 | updateSettings(array('settings_updated' => time())); |
793 | 835 | } |
794 | 836 | |
795 | - if (isset($boardOptions['move_to'])) |
|
796 | - reorderBoards(); |
|
837 | + if (isset($boardOptions['move_to'])) { |
|
838 | + reorderBoards(); |
|
839 | + } |
|
797 | 840 | |
798 | 841 | clean_cache('data'); |
799 | 842 | |
800 | - if (empty($boardOptions['dont_log'])) |
|
801 | - logAction('edit_board', array('board' => $board_id), 'admin'); |
|
802 | -} |
|
843 | + if (empty($boardOptions['dont_log'])) { |
|
844 | + logAction('edit_board', array('board' => $board_id), 'admin'); |
|
845 | + } |
|
846 | + } |
|
803 | 847 | |
804 | 848 | /** |
805 | 849 | * Create a new board and set its properties and position. |
@@ -815,11 +859,13 @@ discard block |
||
815 | 859 | global $boards, $smcFunc; |
816 | 860 | |
817 | 861 | // Trigger an error if one of the required values is not set. |
818 | - if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) |
|
819 | - trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
862 | + if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) { |
|
863 | + trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
864 | + } |
|
820 | 865 | |
821 | - if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) |
|
822 | - trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
866 | + if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) { |
|
867 | + trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
868 | + } |
|
823 | 869 | |
824 | 870 | // Set every optional value to its default value. |
825 | 871 | $boardOptions += array( |
@@ -853,8 +899,9 @@ discard block |
||
853 | 899 | 1 |
854 | 900 | ); |
855 | 901 | |
856 | - if (empty($board_id)) |
|
857 | - return 0; |
|
902 | + if (empty($board_id)) { |
|
903 | + return 0; |
|
904 | + } |
|
858 | 905 | |
859 | 906 | // Change the board according to the given specifications. |
860 | 907 | modifyBoard($board_id, $boardOptions); |
@@ -917,8 +964,9 @@ discard block |
||
917 | 964 | global $sourcedir, $boards, $smcFunc; |
918 | 965 | |
919 | 966 | // No boards to delete? Return! |
920 | - if (empty($boards_to_remove)) |
|
921 | - return; |
|
967 | + if (empty($boards_to_remove)) { |
|
968 | + return; |
|
969 | + } |
|
922 | 970 | |
923 | 971 | getBoardTree(); |
924 | 972 | |
@@ -929,12 +977,14 @@ discard block |
||
929 | 977 | { |
930 | 978 | // Get a list of the child boards that will also be removed. |
931 | 979 | $child_boards_to_remove = array(); |
932 | - foreach ($boards_to_remove as $board_to_remove) |
|
933 | - recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
980 | + foreach ($boards_to_remove as $board_to_remove) { |
|
981 | + recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
982 | + } |
|
934 | 983 | |
935 | 984 | // Merge the children with their parents. |
936 | - if (!empty($child_boards_to_remove)) |
|
937 | - $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
985 | + if (!empty($child_boards_to_remove)) { |
|
986 | + $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
987 | + } |
|
938 | 988 | } |
939 | 989 | // Move the children to a safe home. |
940 | 990 | else |
@@ -942,10 +992,11 @@ discard block |
||
942 | 992 | foreach ($boards_to_remove as $id_board) |
943 | 993 | { |
944 | 994 | // @todo Separate category? |
945 | - if ($moveChildrenTo === 0) |
|
946 | - fixChildren($id_board, 0, 0); |
|
947 | - else |
|
948 | - fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
995 | + if ($moveChildrenTo === 0) { |
|
996 | + fixChildren($id_board, 0, 0); |
|
997 | + } else { |
|
998 | + fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
999 | + } |
|
949 | 1000 | } |
950 | 1001 | } |
951 | 1002 | |
@@ -959,8 +1010,9 @@ discard block |
||
959 | 1010 | ) |
960 | 1011 | ); |
961 | 1012 | $topics = array(); |
962 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
963 | - $topics[] = $row['id_topic']; |
|
1013 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1014 | + $topics[] = $row['id_topic']; |
|
1015 | + } |
|
964 | 1016 | $smcFunc['db_free_result']($request); |
965 | 1017 | |
966 | 1018 | require_once($sourcedir . '/RemoveTopic.php'); |
@@ -1048,8 +1100,9 @@ discard block |
||
1048 | 1100 | clean_cache('data'); |
1049 | 1101 | |
1050 | 1102 | // Let's do some serious logging. |
1051 | - foreach ($boards_to_remove as $id_board) |
|
1052 | - logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
1103 | + foreach ($boards_to_remove as $id_board) { |
|
1104 | + logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
1105 | + } |
|
1053 | 1106 | |
1054 | 1107 | reorderBoards(); |
1055 | 1108 | } |
@@ -1068,8 +1121,8 @@ discard block |
||
1068 | 1121 | $board_order = 0; |
1069 | 1122 | foreach ($cat_tree as $catID => $dummy) |
1070 | 1123 | { |
1071 | - foreach ($boardList[$catID] as $boardID) |
|
1072 | - if ($boards[$boardID]['order'] != ++$board_order) |
|
1124 | + foreach ($boardList[$catID] as $boardID) { |
|
1125 | + if ($boards[$boardID]['order'] != ++$board_order) |
|
1073 | 1126 | $smcFunc['db_query']('', ' |
1074 | 1127 | UPDATE {db_prefix}boards |
1075 | 1128 | SET board_order = {int:new_order} |
@@ -1079,6 +1132,7 @@ discard block |
||
1079 | 1132 | 'selected_board' => $boardID, |
1080 | 1133 | ) |
1081 | 1134 | ); |
1135 | + } |
|
1082 | 1136 | } |
1083 | 1137 | |
1084 | 1138 | // Empty the board order cache |
@@ -1107,8 +1161,9 @@ discard block |
||
1107 | 1161 | ) |
1108 | 1162 | ); |
1109 | 1163 | $children = array(); |
1110 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1111 | - $children[] = $row['id_board']; |
|
1164 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1165 | + $children[] = $row['id_board']; |
|
1166 | + } |
|
1112 | 1167 | $smcFunc['db_free_result']($result); |
1113 | 1168 | |
1114 | 1169 | // ...and set it to a new parent and child_level. |
@@ -1124,9 +1179,10 @@ discard block |
||
1124 | 1179 | ); |
1125 | 1180 | |
1126 | 1181 | // Recursively fix the children of the children. |
1127 | - foreach ($children as $child) |
|
1128 | - fixChildren($child, $newLevel + 1, $child); |
|
1129 | -} |
|
1182 | + foreach ($children as $child) { |
|
1183 | + fixChildren($child, $newLevel + 1, $child); |
|
1184 | + } |
|
1185 | + } |
|
1130 | 1186 | |
1131 | 1187 | /** |
1132 | 1188 | * Tries to load up the entire board order and category very very quickly |
@@ -1143,8 +1199,9 @@ discard block |
||
1143 | 1199 | 'boards' => array(), |
1144 | 1200 | ); |
1145 | 1201 | |
1146 | - if (!empty($tree_order['boards'])) |
|
1147 | - return $tree_order; |
|
1202 | + if (!empty($tree_order['boards'])) { |
|
1203 | + return $tree_order; |
|
1204 | + } |
|
1148 | 1205 | |
1149 | 1206 | if (($cached = cache_get_data('board_order', 86400)) !== null) |
1150 | 1207 | { |
@@ -1160,8 +1217,9 @@ discard block |
||
1160 | 1217 | ); |
1161 | 1218 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1162 | 1219 | { |
1163 | - if (!in_array($row['id_cat'], $tree_order['cats'])) |
|
1164 | - $tree_order['cats'][] = $row['id_cat']; |
|
1220 | + if (!in_array($row['id_cat'], $tree_order['cats'])) { |
|
1221 | + $tree_order['cats'][] = $row['id_cat']; |
|
1222 | + } |
|
1165 | 1223 | $tree_order['boards'][] = $row['id_board']; |
1166 | 1224 | } |
1167 | 1225 | $smcFunc['db_free_result']($request); |
@@ -1181,16 +1239,19 @@ discard block |
||
1181 | 1239 | $tree = getTreeOrder(); |
1182 | 1240 | |
1183 | 1241 | $ordered = array(); |
1184 | - foreach ($tree['boards'] as $board) |
|
1185 | - if (!empty($boards[$board])) |
|
1242 | + foreach ($tree['boards'] as $board) { |
|
1243 | + if (!empty($boards[$board])) |
|
1186 | 1244 | { |
1187 | 1245 | $ordered[$board] = $boards[$board]; |
1246 | + } |
|
1188 | 1247 | |
1189 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) |
|
1190 | - sortBoards($ordered[$board]['boards']); |
|
1248 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) { |
|
1249 | + sortBoards($ordered[$board]['boards']); |
|
1250 | + } |
|
1191 | 1251 | |
1192 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) |
|
1193 | - sortBoards($ordered[$board]['children']); |
|
1252 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) { |
|
1253 | + sortBoards($ordered[$board]['children']); |
|
1254 | + } |
|
1194 | 1255 | } |
1195 | 1256 | |
1196 | 1257 | $boards = $ordered; |
@@ -1206,12 +1267,14 @@ discard block |
||
1206 | 1267 | $tree = getTreeOrder(); |
1207 | 1268 | |
1208 | 1269 | $ordered = array(); |
1209 | - foreach ($tree['cats'] as $cat) |
|
1210 | - if (!empty($categories[$cat])) |
|
1270 | + foreach ($tree['cats'] as $cat) { |
|
1271 | + if (!empty($categories[$cat])) |
|
1211 | 1272 | { |
1212 | 1273 | $ordered[$cat] = $categories[$cat]; |
1213 | - if (!empty($ordered[$cat]['boards'])) |
|
1214 | - sortBoards($ordered[$cat]['boards']); |
|
1274 | + } |
|
1275 | + if (!empty($ordered[$cat]['boards'])) { |
|
1276 | + sortBoards($ordered[$cat]['boards']); |
|
1277 | + } |
|
1215 | 1278 | } |
1216 | 1279 | |
1217 | 1280 | $categories = $ordered; |
@@ -1227,8 +1290,9 @@ discard block |
||
1227 | 1290 | { |
1228 | 1291 | global $smcFunc, $scripturl, $txt; |
1229 | 1292 | |
1230 | - if (empty($boards)) |
|
1231 | - return array(); |
|
1293 | + if (empty($boards)) { |
|
1294 | + return array(); |
|
1295 | + } |
|
1232 | 1296 | |
1233 | 1297 | $request = $smcFunc['db_query']('', ' |
1234 | 1298 | SELECT mem.id_member, mem.real_name, mo.id_board |
@@ -1242,8 +1306,9 @@ discard block |
||
1242 | 1306 | $moderators = array(); |
1243 | 1307 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1244 | 1308 | { |
1245 | - if (empty($moderators[$row['id_board']])) |
|
1246 | - $moderators[$row['id_board']] = array(); |
|
1309 | + if (empty($moderators[$row['id_board']])) { |
|
1310 | + $moderators[$row['id_board']] = array(); |
|
1311 | + } |
|
1247 | 1312 | |
1248 | 1313 | $moderators[$row['id_board']][] = array( |
1249 | 1314 | 'id' => $row['id_member'], |
@@ -1267,8 +1332,9 @@ discard block |
||
1267 | 1332 | { |
1268 | 1333 | global $smcFunc, $scripturl, $txt; |
1269 | 1334 | |
1270 | - if (empty($boards)) |
|
1271 | - return array(); |
|
1335 | + if (empty($boards)) { |
|
1336 | + return array(); |
|
1337 | + } |
|
1272 | 1338 | |
1273 | 1339 | $request = $smcFunc['db_query']('', ' |
1274 | 1340 | SELECT mg.id_group, mg.group_name, bg.id_board |
@@ -1282,8 +1348,9 @@ discard block |
||
1282 | 1348 | $groups = array(); |
1283 | 1349 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1284 | 1350 | { |
1285 | - if (empty($groups[$row['id_board']])) |
|
1286 | - $groups[$row['id_board']] = array(); |
|
1351 | + if (empty($groups[$row['id_board']])) { |
|
1352 | + $groups[$row['id_board']] = array(); |
|
1353 | + } |
|
1287 | 1354 | |
1288 | 1355 | $groups[$row['id_board']][] = array( |
1289 | 1356 | 'id' => $row['id_group'], |
@@ -1345,8 +1412,9 @@ discard block |
||
1345 | 1412 | |
1346 | 1413 | if (!empty($row['id_board'])) |
1347 | 1414 | { |
1348 | - if ($row['child_level'] != $curLevel) |
|
1349 | - $prevBoard = 0; |
|
1415 | + if ($row['child_level'] != $curLevel) { |
|
1416 | + $prevBoard = 0; |
|
1417 | + } |
|
1350 | 1418 | |
1351 | 1419 | $boards[$row['id_board']] = array( |
1352 | 1420 | 'id' => $row['id_board'], |
@@ -1378,16 +1446,16 @@ discard block |
||
1378 | 1446 | 'children' => array() |
1379 | 1447 | ); |
1380 | 1448 | $boards[$row['id_board']]['tree'] = &$cat_tree[$row['id_cat']]['children'][$row['id_board']]; |
1381 | - } |
|
1382 | - else |
|
1449 | + } else |
|
1383 | 1450 | { |
1384 | 1451 | // Parent doesn't exist! |
1385 | - if (!isset($boards[$row['id_parent']]['tree'])) |
|
1386 | - fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
1452 | + if (!isset($boards[$row['id_parent']]['tree'])) { |
|
1453 | + fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
1454 | + } |
|
1387 | 1455 | |
1388 | 1456 | // Wrong childlevel...we can silently fix this... |
1389 | - if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) |
|
1390 | - $smcFunc['db_query']('', ' |
|
1457 | + if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) { |
|
1458 | + $smcFunc['db_query']('', ' |
|
1391 | 1459 | UPDATE {db_prefix}boards |
1392 | 1460 | SET child_level = {int:new_child_level} |
1393 | 1461 | WHERE id_board = {int:selected_board}', |
@@ -1396,6 +1464,7 @@ discard block |
||
1396 | 1464 | 'selected_board' => $row['id_board'], |
1397 | 1465 | ) |
1398 | 1466 | ); |
1467 | + } |
|
1399 | 1468 | |
1400 | 1469 | $boards[$row['id_parent']]['tree']['children'][$row['id_board']] = array( |
1401 | 1470 | 'node' => &$boards[$row['id_board']], |
@@ -1426,8 +1495,9 @@ discard block |
||
1426 | 1495 | */ |
1427 | 1496 | function recursiveBoards(&$_boardList, &$_tree) |
1428 | 1497 | { |
1429 | - if (empty($_tree['children'])) |
|
1430 | - return; |
|
1498 | + if (empty($_tree['children'])) { |
|
1499 | + return; |
|
1500 | + } |
|
1431 | 1501 | |
1432 | 1502 | foreach ($_tree['children'] as $id => $node) |
1433 | 1503 | { |
@@ -1446,11 +1516,13 @@ discard block |
||
1446 | 1516 | { |
1447 | 1517 | global $boards; |
1448 | 1518 | |
1449 | - if (empty($boards[$child]['parent'])) |
|
1450 | - return false; |
|
1519 | + if (empty($boards[$child]['parent'])) { |
|
1520 | + return false; |
|
1521 | + } |
|
1451 | 1522 | |
1452 | - if ($boards[$child]['parent'] == $parent) |
|
1453 | - return true; |
|
1523 | + if ($boards[$child]['parent'] == $parent) { |
|
1524 | + return true; |
|
1525 | + } |
|
1454 | 1526 | |
1455 | 1527 | return isChildOf($boards[$child]['parent'], $parent); |
1456 | 1528 | } |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 3 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * The main designating function for modifying profiles. Loads up info, determins what to do, etc. |
@@ -30,18 +31,21 @@ discard block |
||
30 | 31 | global $db_show_debug, $smcFunc; |
31 | 32 | |
32 | 33 | // Don't reload this as we may have processed error strings. |
33 | - if (empty($post_errors)) |
|
34 | - loadLanguage('Profile+Drafts'); |
|
34 | + if (empty($post_errors)) { |
|
35 | + loadLanguage('Profile+Drafts'); |
|
36 | + } |
|
35 | 37 | loadTemplate('Profile'); |
36 | 38 | |
37 | 39 | require_once($sourcedir . '/Subs-Menu.php'); |
38 | 40 | |
39 | 41 | // Did we get the user by name... |
40 | - if (isset($_REQUEST['user'])) |
|
41 | - $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
42 | + if (isset($_REQUEST['user'])) { |
|
43 | + $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
44 | + } |
|
42 | 45 | // ... or by id_member? |
43 | - elseif (!empty($_REQUEST['u'])) |
|
44 | - $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
46 | + elseif (!empty($_REQUEST['u'])) { |
|
47 | + $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
48 | + } |
|
45 | 49 | // If it was just ?action=profile, edit your own profile, but only if you're not a guest. |
46 | 50 | else |
47 | 51 | { |
@@ -51,8 +55,9 @@ discard block |
||
51 | 55 | } |
52 | 56 | |
53 | 57 | // Check if loadMemberData() has returned a valid result. |
54 | - if (!$memberResult) |
|
55 | - fatal_lang_error('not_a_user', false, 404); |
|
58 | + if (!$memberResult) { |
|
59 | + fatal_lang_error('not_a_user', false, 404); |
|
60 | + } |
|
56 | 61 | |
57 | 62 | // If all went well, we have a valid member ID! |
58 | 63 | list ($memID) = $memberResult; |
@@ -68,8 +73,9 @@ discard block |
||
68 | 73 | |
69 | 74 | // Group management isn't actually a permission. But we need it to be for this, so we need a phantom permission. |
70 | 75 | // And we care about what the current user can do, not what the user whose profile it is. |
71 | - if ($user_info['mod_cache']['gq'] != '0=1') |
|
72 | - $user_info['permissions'][] = 'approve_group_requests'; |
|
76 | + if ($user_info['mod_cache']['gq'] != '0=1') { |
|
77 | + $user_info['permissions'][] = 'approve_group_requests'; |
|
78 | + } |
|
73 | 79 | |
74 | 80 | // If paid subscriptions are enabled, make sure we actually have at least one subscription available... |
75 | 81 | $context['subs_available'] = false; |
@@ -437,21 +443,25 @@ discard block |
||
437 | 443 | foreach ($section['areas'] as $area_id => $area) |
438 | 444 | { |
439 | 445 | // If it said no permissions that meant it wasn't valid! |
440 | - if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) |
|
441 | - $profile_areas[$section_id]['areas'][$area_id]['enabled'] = false; |
|
446 | + if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) { |
|
447 | + $profile_areas[$section_id]['areas'][$area_id]['enabled'] = false; |
|
448 | + } |
|
442 | 449 | // Otherwise pick the right set. |
443 | - else |
|
444 | - $profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any']; |
|
450 | + else { |
|
451 | + $profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any']; |
|
452 | + } |
|
445 | 453 | |
446 | 454 | // Password required in most cases |
447 | - if (!empty($area['password'])) |
|
448 | - $context['password_areas'][] = $area_id; |
|
455 | + if (!empty($area['password'])) { |
|
456 | + $context['password_areas'][] = $area_id; |
|
457 | + } |
|
449 | 458 | } |
450 | 459 | } |
451 | 460 | |
452 | 461 | // Is there an updated message to show? |
453 | - if (isset($_GET['updated'])) |
|
454 | - $context['profile_updated'] = $txt['profile_updated_own']; |
|
462 | + if (isset($_GET['updated'])) { |
|
463 | + $context['profile_updated'] = $txt['profile_updated_own']; |
|
464 | + } |
|
455 | 465 | |
456 | 466 | // Set a few options for the menu. |
457 | 467 | $menuOptions = array( |
@@ -466,8 +476,9 @@ discard block |
||
466 | 476 | $profile_include_data = createMenu($profile_areas, $menuOptions); |
467 | 477 | |
468 | 478 | // No menu means no access. |
469 | - if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) |
|
470 | - fatal_lang_error('no_access', false); |
|
479 | + if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) { |
|
480 | + fatal_lang_error('no_access', false); |
|
481 | + } |
|
471 | 482 | |
472 | 483 | // Make a note of the Unique ID for this menu. |
473 | 484 | $context['profile_menu_id'] = $context['max_menu_id']; |
@@ -493,8 +504,9 @@ discard block |
||
493 | 504 | if ($current_area == $area_id) |
494 | 505 | { |
495 | 506 | // This can't happen - but is a security check. |
496 | - if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) |
|
497 | - fatal_lang_error('no_access', false); |
|
507 | + if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) { |
|
508 | + fatal_lang_error('no_access', false); |
|
509 | + } |
|
498 | 510 | |
499 | 511 | // Are we saving data in a valid area? |
500 | 512 | if (isset($area['sc']) && (isset($_REQUEST['save']) || $context['do_preview'])) |
@@ -513,12 +525,14 @@ discard block |
||
513 | 525 | } |
514 | 526 | |
515 | 527 | // Does this require session validating? |
516 | - if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) |
|
517 | - $security_checks['validate'] = true; |
|
528 | + if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) { |
|
529 | + $security_checks['validate'] = true; |
|
530 | + } |
|
518 | 531 | |
519 | 532 | // Permissions for good measure. |
520 | - if (!empty($profile_include_data['permission'])) |
|
521 | - $security_checks['permission'] = $profile_include_data['permission']; |
|
533 | + if (!empty($profile_include_data['permission'])) { |
|
534 | + $security_checks['permission'] = $profile_include_data['permission']; |
|
535 | + } |
|
522 | 536 | |
523 | 537 | // Either way got something. |
524 | 538 | $found_area = true; |
@@ -527,21 +541,26 @@ discard block |
||
527 | 541 | } |
528 | 542 | |
529 | 543 | // Oh dear, some serious security lapse is going on here... we'll put a stop to that! |
530 | - if (!$found_area) |
|
531 | - fatal_lang_error('no_access', false); |
|
544 | + if (!$found_area) { |
|
545 | + fatal_lang_error('no_access', false); |
|
546 | + } |
|
532 | 547 | |
533 | 548 | // Release this now. |
534 | 549 | unset($profile_areas); |
535 | 550 | |
536 | 551 | // Now the context is setup have we got any security checks to carry out additional to that above? |
537 | - if (isset($security_checks['session'])) |
|
538 | - checkSession($security_checks['session']); |
|
539 | - if (isset($security_checks['validate'])) |
|
540 | - validateSession(); |
|
541 | - if (isset($security_checks['validateToken'])) |
|
542 | - validateToken($token_name, $token_type); |
|
543 | - if (isset($security_checks['permission'])) |
|
544 | - isAllowedTo($security_checks['permission']); |
|
552 | + if (isset($security_checks['session'])) { |
|
553 | + checkSession($security_checks['session']); |
|
554 | + } |
|
555 | + if (isset($security_checks['validate'])) { |
|
556 | + validateSession(); |
|
557 | + } |
|
558 | + if (isset($security_checks['validateToken'])) { |
|
559 | + validateToken($token_name, $token_type); |
|
560 | + } |
|
561 | + if (isset($security_checks['permission'])) { |
|
562 | + isAllowedTo($security_checks['permission']); |
|
563 | + } |
|
545 | 564 | |
546 | 565 | // Create a token if needed. |
547 | 566 | if (isset($security_checks['needsToken']) || isset($security_checks['validateToken'])) |
@@ -551,8 +570,9 @@ discard block |
||
551 | 570 | } |
552 | 571 | |
553 | 572 | // File to include? |
554 | - if (isset($profile_include_data['file'])) |
|
555 | - require_once($sourcedir . '/' . $profile_include_data['file']); |
|
573 | + if (isset($profile_include_data['file'])) { |
|
574 | + require_once($sourcedir . '/' . $profile_include_data['file']); |
|
575 | + } |
|
556 | 576 | |
557 | 577 | // Build the link tree. |
558 | 578 | $context['linktree'][] = array( |
@@ -560,17 +580,19 @@ discard block |
||
560 | 580 | 'name' => sprintf($txt['profile_of_username'], $context['member']['name']), |
561 | 581 | ); |
562 | 582 | |
563 | - if (!empty($profile_include_data['label'])) |
|
564 | - $context['linktree'][] = array( |
|
583 | + if (!empty($profile_include_data['label'])) { |
|
584 | + $context['linktree'][] = array( |
|
565 | 585 | 'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'], |
566 | 586 | 'name' => $profile_include_data['label'], |
567 | 587 | ); |
588 | + } |
|
568 | 589 | |
569 | - if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) |
|
570 | - $context['linktree'][] = array( |
|
590 | + if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) { |
|
591 | + $context['linktree'][] = array( |
|
571 | 592 | 'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'] . ';sa=' . $profile_include_data['current_subsection'], |
572 | 593 | 'name' => $profile_include_data['subsections'][$profile_include_data['current_subsection']][0], |
573 | 594 | ); |
595 | + } |
|
574 | 596 | |
575 | 597 | // Set the template for this area and add the profile layer. |
576 | 598 | $context['sub_template'] = $profile_include_data['function']; |
@@ -596,12 +618,14 @@ discard block |
||
596 | 618 | if ($check_password) |
597 | 619 | { |
598 | 620 | // Check to ensure we're forcing SSL for authentication |
599 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
600 | - fatal_lang_error('login_ssl_required'); |
|
621 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
622 | + fatal_lang_error('login_ssl_required'); |
|
623 | + } |
|
601 | 624 | |
602 | 625 | // You didn't even enter a password! |
603 | - if (trim($_POST['oldpasswrd']) == '') |
|
604 | - $post_errors[] = 'no_password'; |
|
626 | + if (trim($_POST['oldpasswrd']) == '') { |
|
627 | + $post_errors[] = 'no_password'; |
|
628 | + } |
|
605 | 629 | |
606 | 630 | // Since the password got modified due to all the $_POST cleaning, lets undo it so we can get the correct password |
607 | 631 | $_POST['oldpasswrd'] = un_htmlspecialchars($_POST['oldpasswrd']); |
@@ -610,33 +634,35 @@ discard block |
||
610 | 634 | $good_password = in_array(true, call_integration_hook('integrate_verify_password', array($cur_profile['member_name'], $_POST['oldpasswrd'], false)), true); |
611 | 635 | |
612 | 636 | // Bad password!!! |
613 | - if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) |
|
614 | - $post_errors[] = 'bad_password'; |
|
637 | + if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) { |
|
638 | + $post_errors[] = 'bad_password'; |
|
639 | + } |
|
615 | 640 | |
616 | 641 | // Warn other elements not to jump the gun and do custom changes! |
617 | - if (in_array('bad_password', $post_errors)) |
|
618 | - $context['password_auth_failed'] = true; |
|
642 | + if (in_array('bad_password', $post_errors)) { |
|
643 | + $context['password_auth_failed'] = true; |
|
644 | + } |
|
619 | 645 | } |
620 | 646 | |
621 | 647 | // Change the IP address in the database. |
622 | - if ($context['user']['is_owner']) |
|
623 | - $profile_vars['member_ip'] = $user_info['ip']; |
|
648 | + if ($context['user']['is_owner']) { |
|
649 | + $profile_vars['member_ip'] = $user_info['ip']; |
|
650 | + } |
|
624 | 651 | |
625 | 652 | // Now call the sub-action function... |
626 | 653 | if ($current_area == 'activateaccount') |
627 | 654 | { |
628 | - if (empty($post_errors)) |
|
629 | - activateAccount($memID); |
|
630 | - } |
|
631 | - elseif ($current_area == 'deleteaccount') |
|
655 | + if (empty($post_errors)) { |
|
656 | + activateAccount($memID); |
|
657 | + } |
|
658 | + } elseif ($current_area == 'deleteaccount') |
|
632 | 659 | { |
633 | 660 | if (empty($post_errors)) |
634 | 661 | { |
635 | 662 | deleteAccount2($memID); |
636 | 663 | redirectexit(); |
637 | 664 | } |
638 | - } |
|
639 | - elseif ($current_area == 'groupmembership' && empty($post_errors)) |
|
665 | + } elseif ($current_area == 'groupmembership' && empty($post_errors)) |
|
640 | 666 | { |
641 | 667 | $msg = groupMembership2($profile_vars, $post_errors, $memID); |
642 | 668 | |
@@ -647,10 +673,9 @@ discard block |
||
647 | 673 | elseif ($current_area == 'authentication') |
648 | 674 | { |
649 | 675 | authentication($memID, true); |
650 | - } |
|
651 | - elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) |
|
652 | - saveProfileFields(); |
|
653 | - else |
|
676 | + } elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) { |
|
677 | + saveProfileFields(); |
|
678 | + } else |
|
654 | 679 | { |
655 | 680 | $force_redirect = true; |
656 | 681 | // Ensure we include this. |
@@ -666,34 +691,36 @@ discard block |
||
666 | 691 | // Load the language file so we can give a nice explanation of the errors. |
667 | 692 | loadLanguage('Errors'); |
668 | 693 | $context['post_errors'] = $post_errors; |
669 | - } |
|
670 | - elseif (!empty($profile_vars)) |
|
694 | + } elseif (!empty($profile_vars)) |
|
671 | 695 | { |
672 | 696 | // If we've changed the password, notify any integration that may be listening in. |
673 | - if (isset($profile_vars['passwd'])) |
|
674 | - call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2'])); |
|
697 | + if (isset($profile_vars['passwd'])) { |
|
698 | + call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2'])); |
|
699 | + } |
|
675 | 700 | |
676 | 701 | updateMemberData($memID, $profile_vars); |
677 | 702 | |
678 | 703 | // What if this is the newest member? |
679 | - if ($modSettings['latestMember'] == $memID) |
|
680 | - updateStats('member'); |
|
681 | - elseif (isset($profile_vars['real_name'])) |
|
682 | - updateSettings(array('memberlist_updated' => time())); |
|
704 | + if ($modSettings['latestMember'] == $memID) { |
|
705 | + updateStats('member'); |
|
706 | + } elseif (isset($profile_vars['real_name'])) { |
|
707 | + updateSettings(array('memberlist_updated' => time())); |
|
708 | + } |
|
683 | 709 | |
684 | 710 | // If the member changed his/her birthdate, update calendar statistics. |
685 | - if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) |
|
686 | - updateSettings(array( |
|
711 | + if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) { |
|
712 | + updateSettings(array( |
|
687 | 713 | 'calendar_updated' => time(), |
688 | 714 | )); |
715 | + } |
|
689 | 716 | |
690 | 717 | // Anything worth logging? |
691 | 718 | if (!empty($context['log_changes']) && !empty($modSettings['modlog_enabled'])) |
692 | 719 | { |
693 | 720 | $log_changes = array(); |
694 | 721 | require_once($sourcedir . '/Logging.php'); |
695 | - foreach ($context['log_changes'] as $k => $v) |
|
696 | - $log_changes[] = array( |
|
722 | + foreach ($context['log_changes'] as $k => $v) { |
|
723 | + $log_changes[] = array( |
|
697 | 724 | 'action' => $k, |
698 | 725 | 'log_type' => 'user', |
699 | 726 | 'extra' => array_merge($v, array( |
@@ -701,14 +728,16 @@ discard block |
||
701 | 728 | 'member_affected' => $memID, |
702 | 729 | )), |
703 | 730 | ); |
731 | + } |
|
704 | 732 | |
705 | 733 | logActions($log_changes); |
706 | 734 | } |
707 | 735 | |
708 | 736 | // Have we got any post save functions to execute? |
709 | - if (!empty($context['profile_execute_on_save'])) |
|
710 | - foreach ($context['profile_execute_on_save'] as $saveFunc) |
|
737 | + if (!empty($context['profile_execute_on_save'])) { |
|
738 | + foreach ($context['profile_execute_on_save'] as $saveFunc) |
|
711 | 739 | $saveFunc(); |
740 | + } |
|
712 | 741 | |
713 | 742 | // Let them know it worked! |
714 | 743 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $cur_profile['member_name']); |
@@ -722,27 +751,31 @@ discard block |
||
722 | 751 | if (!empty($post_errors)) |
723 | 752 | { |
724 | 753 | // Set all the errors so the template knows what went wrong. |
725 | - foreach ($post_errors as $error_type) |
|
726 | - $context['modify_error'][$error_type] = true; |
|
754 | + foreach ($post_errors as $error_type) { |
|
755 | + $context['modify_error'][$error_type] = true; |
|
756 | + } |
|
727 | 757 | } |
728 | 758 | // If it's you then we should redirect upon save. |
729 | - elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) |
|
730 | - redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated'); |
|
731 | - elseif (!empty($force_redirect)) |
|
732 | - redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area); |
|
759 | + elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) { |
|
760 | + redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated'); |
|
761 | + } elseif (!empty($force_redirect)) { |
|
762 | + redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area); |
|
763 | + } |
|
733 | 764 | |
734 | 765 | |
735 | 766 | // Get the right callable. |
736 | 767 | $call = call_helper($profile_include_data['function'], true); |
737 | 768 | |
738 | 769 | // Is it valid? |
739 | - if (!empty($call)) |
|
740 | - call_user_func($call, $memID); |
|
770 | + if (!empty($call)) { |
|
771 | + call_user_func($call, $memID); |
|
772 | + } |
|
741 | 773 | |
742 | 774 | // Set the page title if it's not already set... |
743 | - if (!isset($context['page_title'])) |
|
744 | - $context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : ''); |
|
745 | -} |
|
775 | + if (!isset($context['page_title'])) { |
|
776 | + $context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : ''); |
|
777 | + } |
|
778 | + } |
|
746 | 779 | |
747 | 780 | /** |
748 | 781 | * Set up the requirements for the profile popup - the area that is shown as the popup menu for the current user. |
@@ -865,16 +898,18 @@ discard block |
||
865 | 898 | if (!allowedTo('admin_forum') && $area != 'register') |
866 | 899 | { |
867 | 900 | // If it's the owner they can see two types of private fields, regardless. |
868 | - if ($memID == $user_info['id']) |
|
869 | - $where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
870 | - else |
|
871 | - $where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
901 | + if ($memID == $user_info['id']) { |
|
902 | + $where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
903 | + } else { |
|
904 | + $where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
905 | + } |
|
872 | 906 | } |
873 | 907 | |
874 | - if ($area == 'register') |
|
875 | - $where .= ' AND show_reg != 0'; |
|
876 | - elseif ($area != 'summary') |
|
877 | - $where .= ' AND show_profile = {string:area}'; |
|
908 | + if ($area == 'register') { |
|
909 | + $where .= ' AND show_reg != 0'; |
|
910 | + } elseif ($area != 'summary') { |
|
911 | + $where .= ' AND show_profile = {string:area}'; |
|
912 | + } |
|
878 | 913 | |
879 | 914 | // Load all the relevant fields - and data. |
880 | 915 | $request = $smcFunc['db_query']('', ' |
@@ -900,13 +935,15 @@ discard block |
||
900 | 935 | if (isset($_POST['customfield']) && isset($_POST['customfield'][$row['col_name']])) |
901 | 936 | { |
902 | 937 | $value = $smcFunc['htmlspecialchars']($_POST['customfield'][$row['col_name']]); |
903 | - if (in_array($row['field_type'], array('select', 'radio'))) |
|
904 | - $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
938 | + if (in_array($row['field_type'], array('select', 'radio'))) { |
|
939 | + $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
940 | + } |
|
905 | 941 | } |
906 | 942 | |
907 | 943 | // Don't show the "disabled" option for the "gender" field if we are on the "summary" area. |
908 | - if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'Disabled') |
|
909 | - continue; |
|
944 | + if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'Disabled') { |
|
945 | + continue; |
|
946 | + } |
|
910 | 947 | |
911 | 948 | // HTML for the input form. |
912 | 949 | $output_html = $value; |
@@ -915,8 +952,7 @@ discard block |
||
915 | 952 | $true = (!$exists && $row['default_value']) || $value; |
916 | 953 | $input_html = '<input type="checkbox" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($true ? ' checked' : '') . ' class="input_check">'; |
917 | 954 | $output_html = $true ? $txt['yes'] : $txt['no']; |
918 | - } |
|
919 | - elseif ($row['field_type'] == 'select') |
|
955 | + } elseif ($row['field_type'] == 'select') |
|
920 | 956 | { |
921 | 957 | $input_html = '<select name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"><option value="-1"></option>'; |
922 | 958 | $options = explode(',', $row['field_options']); |
@@ -924,13 +960,13 @@ discard block |
||
924 | 960 | { |
925 | 961 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
926 | 962 | $input_html .= '<option value="' . $k . '"' . ($true ? ' selected' : '') . '>' . $v . '</option>'; |
927 | - if ($true) |
|
928 | - $output_html = $v; |
|
963 | + if ($true) { |
|
964 | + $output_html = $v; |
|
965 | + } |
|
929 | 966 | } |
930 | 967 | |
931 | 968 | $input_html .= '</select>'; |
932 | - } |
|
933 | - elseif ($row['field_type'] == 'radio') |
|
969 | + } elseif ($row['field_type'] == 'radio') |
|
934 | 970 | { |
935 | 971 | $input_html = '<fieldset>'; |
936 | 972 | $options = explode(',', $row['field_options']); |
@@ -938,36 +974,37 @@ discard block |
||
938 | 974 | { |
939 | 975 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
940 | 976 | $input_html .= '<label for="customfield_' . $row['col_name'] . '_' . $k . '"><input type="radio" name="customfield[' . $row['col_name'] . ']" class="input_radio" id="customfield_' . $row['col_name'] . '_' . $k . '" value="' . $k . '"' . ($true ? ' checked' : '') . '>' . $v . '</label><br>'; |
941 | - if ($true) |
|
942 | - $output_html = $v; |
|
977 | + if ($true) { |
|
978 | + $output_html = $v; |
|
979 | + } |
|
943 | 980 | } |
944 | 981 | $input_html .= '</fieldset>'; |
945 | - } |
|
946 | - elseif ($row['field_type'] == 'text') |
|
982 | + } elseif ($row['field_type'] == 'text') |
|
947 | 983 | { |
948 | 984 | $input_html = '<input type="text" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($row['field_length'] != 0 ? ' maxlength="' . $row['field_length'] . '"' : '') . ' size="' . ($row['field_length'] == 0 || $row['field_length'] >= 50 ? 50 : ($row['field_length'] > 30 ? 30 : ($row['field_length'] > 10 ? 20 : 10))) . '" value="' . un_htmlspecialchars($value) . '" class="input_text"' . ($row['show_reg'] == 2 ? ' required' : '') . '>'; |
949 | - } |
|
950 | - else |
|
985 | + } else |
|
951 | 986 | { |
952 | 987 | @list ($rows, $cols) = @explode(',', $row['default_value']); |
953 | 988 | $input_html = '<textarea name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . (!empty($rows) ? ' rows="' . $rows . '"' : '') . (!empty($cols) ? ' cols="' . $cols . '"' : '') . ($row['show_reg'] == 2 ? ' required' : '') . '>' . un_htmlspecialchars($value) . '</textarea>'; |
954 | 989 | } |
955 | 990 | |
956 | 991 | // Parse BBCode |
957 | - if ($row['bbc']) |
|
958 | - $output_html = parse_bbc($output_html); |
|
959 | - elseif ($row['field_type'] == 'textarea') |
|
960 | - // Allow for newlines at least |
|
992 | + if ($row['bbc']) { |
|
993 | + $output_html = parse_bbc($output_html); |
|
994 | + } elseif ($row['field_type'] == 'textarea') { |
|
995 | + // Allow for newlines at least |
|
961 | 996 | $output_html = strtr($output_html, array("\n" => '<br>')); |
997 | + } |
|
962 | 998 | |
963 | 999 | // Enclosing the user input within some other text? |
964 | - if (!empty($row['enclose']) && !empty($output_html)) |
|
965 | - $output_html = strtr($row['enclose'], array( |
|
1000 | + if (!empty($row['enclose']) && !empty($output_html)) { |
|
1001 | + $output_html = strtr($row['enclose'], array( |
|
966 | 1002 | '{SCRIPTURL}' => $scripturl, |
967 | 1003 | '{IMAGES_URL}' => $settings['images_url'], |
968 | 1004 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
969 | 1005 | '{INPUT}' => un_htmlspecialchars($output_html), |
970 | 1006 | )); |
1007 | + } |
|
971 | 1008 | |
972 | 1009 | $context['custom_fields'][] = array( |
973 | 1010 | 'name' => $row['field_name'], |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Main entry point for the admin search settings screen. |
@@ -107,11 +108,13 @@ discard block |
||
107 | 108 | // Perhaps the search method wants to add some settings? |
108 | 109 | require_once($sourcedir . '/Search.php'); |
109 | 110 | $searchAPI = findSearchAPI(); |
110 | - if (is_callable(array($searchAPI, 'searchSettings'))) |
|
111 | - call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars)); |
|
111 | + if (is_callable(array($searchAPI, 'searchSettings'))) { |
|
112 | + call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars)); |
|
113 | + } |
|
112 | 114 | |
113 | - if ($return_config) |
|
114 | - return $config_vars; |
|
115 | + if ($return_config) { |
|
116 | + return $config_vars; |
|
117 | + } |
|
115 | 118 | |
116 | 119 | $context['page_title'] = $txt['search_settings_title']; |
117 | 120 | $context['sub_template'] = 'show_settings'; |
@@ -126,8 +129,9 @@ discard block |
||
126 | 129 | |
127 | 130 | call_integration_hook('integrate_save_search_settings'); |
128 | 131 | |
129 | - if (empty($_POST['search_results_per_page'])) |
|
130 | - $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages']; |
|
132 | + if (empty($_POST['search_results_per_page'])) { |
|
133 | + $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages']; |
|
134 | + } |
|
131 | 135 | saveDBSettings($config_vars); |
132 | 136 | $_SESSION['adm-save'] = true; |
133 | 137 | redirectexit('action=admin;area=managesearch;sa=settings;' . $context['session_var'] . '=' . $context['session_id']); |
@@ -177,17 +181,20 @@ discard block |
||
177 | 181 | call_integration_hook('integrate_save_search_weights'); |
178 | 182 | |
179 | 183 | $changes = array(); |
180 | - foreach ($factors as $factor) |
|
181 | - $changes[$factor] = (int) $_POST[$factor]; |
|
184 | + foreach ($factors as $factor) { |
|
185 | + $changes[$factor] = (int) $_POST[$factor]; |
|
186 | + } |
|
182 | 187 | updateSettings($changes); |
183 | 188 | } |
184 | 189 | |
185 | 190 | $context['relative_weights'] = array('total' => 0); |
186 | - foreach ($factors as $factor) |
|
187 | - $context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0; |
|
191 | + foreach ($factors as $factor) { |
|
192 | + $context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0; |
|
193 | + } |
|
188 | 194 | |
189 | - foreach ($factors as $factor) |
|
190 | - $context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1); |
|
195 | + foreach ($factors as $factor) { |
|
196 | + $context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1); |
|
197 | + } |
|
191 | 198 | |
192 | 199 | createToken('admin-msw'); |
193 | 200 | } |
@@ -215,8 +222,9 @@ discard block |
||
215 | 222 | $context['search_apis'] = loadSearchAPIs(); |
216 | 223 | |
217 | 224 | // Detect whether a fulltext index is set. |
218 | - if ($context['supports_fulltext']) |
|
219 | - detectFulltextIndex(); |
|
225 | + if ($context['supports_fulltext']) { |
|
226 | + detectFulltextIndex(); |
|
227 | + } |
|
220 | 228 | |
221 | 229 | if (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'createfulltext') |
222 | 230 | { |
@@ -252,8 +260,7 @@ discard block |
||
252 | 260 | 'language' => $language_ftx |
253 | 261 | ) |
254 | 262 | ); |
255 | - } |
|
256 | - else |
|
263 | + } else |
|
257 | 264 | { |
258 | 265 | // Make sure it's gone before creating it. |
259 | 266 | $smcFunc['db_query']('', ' |
@@ -273,8 +280,7 @@ discard block |
||
273 | 280 | } |
274 | 281 | |
275 | 282 | $context['fulltext_index'] = 'body'; |
276 | - } |
|
277 | - elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index'])) |
|
283 | + } elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index'])) |
|
278 | 284 | { |
279 | 285 | checkSession('get'); |
280 | 286 | validateToken('admin-msm', 'get'); |
@@ -291,12 +297,12 @@ discard block |
||
291 | 297 | $context['fulltext_index'] = ''; |
292 | 298 | |
293 | 299 | // Go back to the default search method. |
294 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') |
|
295 | - updateSettings(array( |
|
300 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') { |
|
301 | + updateSettings(array( |
|
296 | 302 | 'search_index' => '', |
297 | 303 | )); |
298 | - } |
|
299 | - elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom') |
|
304 | + } |
|
305 | + } elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom') |
|
300 | 306 | { |
301 | 307 | checkSession('get'); |
302 | 308 | validateToken('admin-msm', 'get'); |
@@ -318,12 +324,12 @@ discard block |
||
318 | 324 | )); |
319 | 325 | |
320 | 326 | // Go back to the default search method. |
321 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') |
|
322 | - updateSettings(array( |
|
327 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') { |
|
328 | + updateSettings(array( |
|
323 | 329 | 'search_index' => '', |
324 | 330 | )); |
325 | - } |
|
326 | - elseif (isset($_POST['save'])) |
|
331 | + } |
|
332 | + } elseif (isset($_POST['save'])) |
|
327 | 333 | { |
328 | 334 | checkSession(); |
329 | 335 | validateToken('admin-msmpost'); |
@@ -345,8 +351,8 @@ discard block |
||
345 | 351 | // Get some info about the messages table, to show its size and index size. |
346 | 352 | if ($db_type == 'mysql') |
347 | 353 | { |
348 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
349 | - $request = $smcFunc['db_query']('', ' |
|
354 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
355 | + $request = $smcFunc['db_query']('', ' |
|
350 | 356 | SHOW TABLE STATUS |
351 | 357 | FROM {string:database_name} |
352 | 358 | LIKE {string:table_name}', |
@@ -355,14 +361,15 @@ discard block |
||
355 | 361 | 'table_name' => str_replace('_', '\_', $match[2]) . 'messages', |
356 | 362 | ) |
357 | 363 | ); |
358 | - else |
|
359 | - $request = $smcFunc['db_query']('', ' |
|
364 | + } else { |
|
365 | + $request = $smcFunc['db_query']('', ' |
|
360 | 366 | SHOW TABLE STATUS |
361 | 367 | LIKE {string:table_name}', |
362 | 368 | array( |
363 | 369 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'messages', |
364 | 370 | ) |
365 | 371 | ); |
372 | + } |
|
366 | 373 | if ($request !== false && $smcFunc['db_num_rows']($request) == 1) |
367 | 374 | { |
368 | 375 | // Only do this if the user has permission to execute this query. |
@@ -374,8 +381,8 @@ discard block |
||
374 | 381 | } |
375 | 382 | |
376 | 383 | // Now check the custom index table, if it exists at all. |
377 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
378 | - $request = $smcFunc['db_query']('', ' |
|
384 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
385 | + $request = $smcFunc['db_query']('', ' |
|
379 | 386 | SHOW TABLE STATUS |
380 | 387 | FROM {string:database_name} |
381 | 388 | LIKE {string:table_name}', |
@@ -384,14 +391,15 @@ discard block |
||
384 | 391 | 'table_name' => str_replace('_', '\_', $match[2]) . 'log_search_words', |
385 | 392 | ) |
386 | 393 | ); |
387 | - else |
|
388 | - $request = $smcFunc['db_query']('', ' |
|
394 | + } else { |
|
395 | + $request = $smcFunc['db_query']('', ' |
|
389 | 396 | SHOW TABLE STATUS |
390 | 397 | LIKE {string:table_name}', |
391 | 398 | array( |
392 | 399 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'log_search_words', |
393 | 400 | ) |
394 | 401 | ); |
402 | + } |
|
395 | 403 | if ($request !== false && $smcFunc['db_num_rows']($request) == 1) |
396 | 404 | { |
397 | 405 | // Only do this if the user has permission to execute this query. |
@@ -400,8 +408,7 @@ discard block |
||
400 | 408 | $context['table_info']['custom_index_length'] = $row['Data_length'] + $row['Index_length']; |
401 | 409 | $smcFunc['db_free_result']($request); |
402 | 410 | } |
403 | - } |
|
404 | - elseif ($db_type == 'postgresql') |
|
411 | + } elseif ($db_type == 'postgresql') |
|
405 | 412 | { |
406 | 413 | // In order to report the sizes correctly we need to perform vacuum (optimize) on the tables we will be using. |
407 | 414 | //db_extend(); |
@@ -443,38 +450,38 @@ discard block |
||
443 | 450 | $context['table_info']['data_length'] = (int) $row['table_size']; |
444 | 451 | $context['table_info']['index_length'] = (int) $row['index_size']; |
445 | 452 | $context['table_info']['fulltext_length'] = (int) $row['index_size']; |
446 | - } |
|
447 | - elseif ($row['indexname'] == $db_prefix . 'log_search_words') |
|
453 | + } elseif ($row['indexname'] == $db_prefix . 'log_search_words') |
|
448 | 454 | { |
449 | 455 | $context['table_info']['index_length'] = (int) $row['index_size']; |
450 | 456 | $context['table_info']['custom_index_length'] = (int) $row['index_size']; |
451 | 457 | } |
452 | 458 | } |
453 | 459 | $smcFunc['db_free_result']($request); |
454 | - } |
|
455 | - else |
|
456 | - // Didn't work for some reason... |
|
460 | + } else { |
|
461 | + // Didn't work for some reason... |
|
457 | 462 | $context['table_info'] = array( |
458 | 463 | 'data_length' => $txt['not_applicable'], |
459 | 464 | 'index_length' => $txt['not_applicable'], |
460 | 465 | 'fulltext_length' => $txt['not_applicable'], |
461 | 466 | 'custom_index_length' => $txt['not_applicable'], |
462 | 467 | ); |
463 | - } |
|
464 | - else |
|
465 | - $context['table_info'] = array( |
|
468 | + } |
|
469 | + } else { |
|
470 | + $context['table_info'] = array( |
|
466 | 471 | 'data_length' => $txt['not_applicable'], |
467 | 472 | 'index_length' => $txt['not_applicable'], |
468 | 473 | 'fulltext_length' => $txt['not_applicable'], |
469 | 474 | 'custom_index_length' => $txt['not_applicable'], |
470 | 475 | ); |
476 | + } |
|
471 | 477 | |
472 | 478 | // Format the data and index length in kilobytes. |
473 | 479 | foreach ($context['table_info'] as $type => $size) |
474 | 480 | { |
475 | 481 | // If it's not numeric then just break. This database engine doesn't support size. |
476 | - if (!is_numeric($size)) |
|
477 | - break; |
|
482 | + if (!is_numeric($size)) { |
|
483 | + break; |
|
484 | + } |
|
478 | 485 | |
479 | 486 | $context['table_info'][$type] = comma_format($context['table_info'][$type] / 1024) . ' ' . $txt['search_method_kilobytes']; |
480 | 487 | } |
@@ -503,8 +510,9 @@ discard block |
||
503 | 510 | |
504 | 511 | // Scotty, we need more time... |
505 | 512 | @set_time_limit(600); |
506 | - if (function_exists('apache_reset_timeout')) |
|
507 | - @apache_reset_timeout(); |
|
513 | + if (function_exists('apache_reset_timeout')) { |
|
514 | + @apache_reset_timeout(); |
|
515 | + } |
|
508 | 516 | |
509 | 517 | $context[$context['admin_menu_name']]['current_subsection'] = 'method'; |
510 | 518 | $context['page_title'] = $txt['search_index_custom']; |
@@ -534,8 +542,7 @@ discard block |
||
534 | 542 | $context['start'] = (int) $context['index_settings']['resume_at']; |
535 | 543 | unset($context['index_settings']['resume_at']); |
536 | 544 | $context['step'] = 1; |
537 | - } |
|
538 | - else |
|
545 | + } else |
|
539 | 546 | { |
540 | 547 | $context['index_settings'] = array( |
541 | 548 | 'bytes_per_word' => isset($_REQUEST['bytes_per_word']) && isset($index_properties[$_REQUEST['bytes_per_word']]) ? (int) $_REQUEST['bytes_per_word'] : 2, |
@@ -544,12 +551,14 @@ discard block |
||
544 | 551 | $context['step'] = isset($_REQUEST['step']) ? (int) $_REQUEST['step'] : 0; |
545 | 552 | |
546 | 553 | // admin timeouts are painful when building these long indexes - but only if we actually have such things enabled |
547 | - if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) |
|
548 | - $_SESSION['admin_time'] = time(); |
|
554 | + if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) { |
|
555 | + $_SESSION['admin_time'] = time(); |
|
556 | + } |
|
549 | 557 | } |
550 | 558 | |
551 | - if ($context['step'] !== 0) |
|
552 | - checkSession('request'); |
|
559 | + if ($context['step'] !== 0) { |
|
560 | + checkSession('request'); |
|
561 | + } |
|
553 | 562 | |
554 | 563 | // Step 0: let the user determine how they like their index. |
555 | 564 | if ($context['step'] === 0) |
@@ -578,12 +587,14 @@ discard block |
||
578 | 587 | $smcFunc['db_create_word_search']($index_properties[$context['index_settings']['bytes_per_word']]['column_definition']); |
579 | 588 | |
580 | 589 | // Temporarily switch back to not using a search index. |
581 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') |
|
582 | - updateSettings(array('search_index' => '')); |
|
590 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') { |
|
591 | + updateSettings(array('search_index' => '')); |
|
592 | + } |
|
583 | 593 | |
584 | 594 | // Don't let simultanious processes be updating the search index. |
585 | - if (!empty($modSettings['search_custom_index_config'])) |
|
586 | - updateSettings(array('search_custom_index_config' => '')); |
|
595 | + if (!empty($modSettings['search_custom_index_config'])) { |
|
596 | + updateSettings(array('search_custom_index_config' => '')); |
|
597 | + } |
|
587 | 598 | } |
588 | 599 | |
589 | 600 | $num_messages = array( |
@@ -599,16 +610,16 @@ discard block |
||
599 | 610 | 'starting_id' => $context['start'], |
600 | 611 | ) |
601 | 612 | ); |
602 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
603 | - $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
613 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
614 | + $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
615 | + } |
|
604 | 616 | |
605 | 617 | if (empty($num_messages['todo'])) |
606 | 618 | { |
607 | 619 | $context['step'] = 2; |
608 | 620 | $context['percentage'] = 80; |
609 | 621 | $context['start'] = 0; |
610 | - } |
|
611 | - else |
|
622 | + } else |
|
612 | 623 | { |
613 | 624 | // Number of seconds before the next step. |
614 | 625 | $stop = time() + 3; |
@@ -649,21 +660,22 @@ discard block |
||
649 | 660 | |
650 | 661 | $context['start'] += $forced_break ? $number_processed : $messages_per_batch; |
651 | 662 | |
652 | - if (!empty($inserts)) |
|
653 | - $smcFunc['db_insert']('ignore', |
|
663 | + if (!empty($inserts)) { |
|
664 | + $smcFunc['db_insert']('ignore', |
|
654 | 665 | '{db_prefix}log_search_words', |
655 | 666 | array('id_word' => 'int', 'id_msg' => 'int'), |
656 | 667 | $inserts, |
657 | 668 | array('id_word', 'id_msg') |
658 | 669 | ); |
670 | + } |
|
659 | 671 | if ($num_messages['todo'] === 0) |
660 | 672 | { |
661 | 673 | $context['step'] = 2; |
662 | 674 | $context['start'] = 0; |
663 | 675 | break; |
676 | + } else { |
|
677 | + updateSettings(array('search_custom_index_resume' => json_encode(array_merge($context['index_settings'], array('resume_at' => $context['start']))))); |
|
664 | 678 | } |
665 | - else |
|
666 | - updateSettings(array('search_custom_index_resume' => json_encode(array_merge($context['index_settings'], array('resume_at' => $context['start']))))); |
|
667 | 679 | } |
668 | 680 | |
669 | 681 | // Since there are still two steps to go, 80% is the maximum here. |
@@ -674,9 +686,9 @@ discard block |
||
674 | 686 | // Step 2: removing the words that occur too often and are of no use. |
675 | 687 | elseif ($context['step'] === 2) |
676 | 688 | { |
677 | - if ($context['index_settings']['bytes_per_word'] < 4) |
|
678 | - $context['step'] = 3; |
|
679 | - else |
|
689 | + if ($context['index_settings']['bytes_per_word'] < 4) { |
|
690 | + $context['step'] = 3; |
|
691 | + } else |
|
680 | 692 | { |
681 | 693 | $stop_words = $context['start'] === 0 || empty($modSettings['search_stopwords']) ? array() : explode(',', $modSettings['search_stopwords']); |
682 | 694 | $stop = time() + 3; |
@@ -697,20 +709,22 @@ discard block |
||
697 | 709 | 'minimum_messages' => $max_messages, |
698 | 710 | ) |
699 | 711 | ); |
700 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
701 | - $stop_words[] = $row['id_word']; |
|
712 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
713 | + $stop_words[] = $row['id_word']; |
|
714 | + } |
|
702 | 715 | $smcFunc['db_free_result']($request); |
703 | 716 | |
704 | 717 | updateSettings(array('search_stopwords' => implode(',', $stop_words))); |
705 | 718 | |
706 | - if (!empty($stop_words)) |
|
707 | - $smcFunc['db_query']('', ' |
|
719 | + if (!empty($stop_words)) { |
|
720 | + $smcFunc['db_query']('', ' |
|
708 | 721 | DELETE FROM {db_prefix}log_search_words |
709 | 722 | WHERE id_word in ({array_int:stop_words})', |
710 | 723 | array( |
711 | 724 | 'stop_words' => $stop_words, |
712 | 725 | ) |
713 | 726 | ); |
727 | + } |
|
714 | 728 | |
715 | 729 | $context['start'] += $index_properties[$context['index_settings']['bytes_per_word']]['step_size']; |
716 | 730 | if ($context['start'] > $index_properties[$context['index_settings']['bytes_per_word']]['max_size']) |
@@ -771,8 +785,9 @@ discard block |
||
771 | 785 | $searchAPI = new $search_class_name(); |
772 | 786 | |
773 | 787 | // No Support? NEXT! |
774 | - if (!$searchAPI->is_supported) |
|
775 | - continue; |
|
788 | + if (!$searchAPI->is_supported) { |
|
789 | + continue; |
|
790 | + } |
|
776 | 791 | |
777 | 792 | $apis[$index_name] = array( |
778 | 793 | 'filename' => $file, |
@@ -819,10 +834,10 @@ discard block |
||
819 | 834 | 'messages_ftx' => $db_prefix . 'messages_ftx', |
820 | 835 | ) |
821 | 836 | ); |
822 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
823 | - $context['fulltext_index'][] = $row['indexname']; |
|
824 | - } |
|
825 | - else |
|
837 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
838 | + $context['fulltext_index'][] = $row['indexname']; |
|
839 | + } |
|
840 | + } else |
|
826 | 841 | { |
827 | 842 | $request = $smcFunc['db_query']('', ' |
828 | 843 | SHOW INDEX |
@@ -833,17 +848,19 @@ discard block |
||
833 | 848 | $context['fulltext_index'] = ''; |
834 | 849 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
835 | 850 | { |
836 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
837 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
851 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
852 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
838 | 853 | $context['fulltext_index'][] = $row['Key_name']; |
854 | + } |
|
839 | 855 | $smcFunc['db_free_result']($request); |
840 | 856 | |
841 | - if (is_array($context['fulltext_index'])) |
|
842 | - $context['fulltext_index'] = array_unique($context['fulltext_index']); |
|
857 | + if (is_array($context['fulltext_index'])) { |
|
858 | + $context['fulltext_index'] = array_unique($context['fulltext_index']); |
|
859 | + } |
|
843 | 860 | } |
844 | 861 | |
845 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
846 | - $request = $smcFunc['db_query']('', ' |
|
862 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
863 | + $request = $smcFunc['db_query']('', ' |
|
847 | 864 | SHOW TABLE STATUS |
848 | 865 | FROM {string:database_name} |
849 | 866 | LIKE {string:table_name}', |
@@ -852,20 +869,22 @@ discard block |
||
852 | 869 | 'table_name' => str_replace('_', '\_', $match[2]) . 'messages', |
853 | 870 | ) |
854 | 871 | ); |
855 | - else |
|
856 | - $request = $smcFunc['db_query']('', ' |
|
872 | + } else { |
|
873 | + $request = $smcFunc['db_query']('', ' |
|
857 | 874 | SHOW TABLE STATUS |
858 | 875 | LIKE {string:table_name}', |
859 | 876 | array( |
860 | 877 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'messages', |
861 | 878 | ) |
862 | 879 | ); |
880 | + } |
|
863 | 881 | |
864 | 882 | if ($request !== false) |
865 | 883 | { |
866 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
867 | - if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'], '5.6.4', '>='))) |
|
884 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
885 | + if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'], '5.6.4', '>='))) |
|
868 | 886 | $context['cannot_create_fulltext'] = true; |
887 | + } |
|
869 | 888 | $smcFunc['db_free_result']($request); |
870 | 889 | } |
871 | 890 | } |