@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The news dispatcher; doesn't do anything, just delegates. |
@@ -67,8 +68,9 @@ discard block |
||
67 | 68 | ); |
68 | 69 | |
69 | 70 | // Force the right area... |
70 | - if (substr($_REQUEST['sa'], 0, 7) == 'mailing') |
|
71 | - $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
71 | + if (substr($_REQUEST['sa'], 0, 7) == 'mailing') { |
|
72 | + $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
73 | + } |
|
72 | 74 | |
73 | 75 | call_helper($subActions[$_REQUEST['sa']][0]); |
74 | 76 | } |
@@ -99,9 +101,10 @@ discard block |
||
99 | 101 | $temp_news = explode("\n", $modSettings['news']); |
100 | 102 | |
101 | 103 | // Remove the items that were selected. |
102 | - foreach ($temp_news as $i => $news) |
|
103 | - if (in_array($i, $_POST['remove'])) |
|
104 | + foreach ($temp_news as $i => $news) { |
|
105 | + if (in_array($i, $_POST['remove'])) |
|
104 | 106 | unset($temp_news[$i]); |
107 | + } |
|
105 | 108 | |
106 | 109 | // Update the database. |
107 | 110 | updateSettings(array('news' => implode("\n", $temp_news))); |
@@ -117,9 +120,9 @@ discard block |
||
117 | 120 | |
118 | 121 | foreach ($_POST['news'] as $i => $news) |
119 | 122 | { |
120 | - if (trim($news) == '') |
|
121 | - unset($_POST['news'][$i]); |
|
122 | - else |
|
123 | + if (trim($news) == '') { |
|
124 | + unset($_POST['news'][$i]); |
|
125 | + } else |
|
123 | 126 | { |
124 | 127 | $_POST['news'][$i] = $smcFunc['htmlspecialchars']($_POST['news'][$i], ENT_QUOTES); |
125 | 128 | preparsecode($_POST['news'][$i]); |
@@ -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'] . '">'; |
|
188 | - else |
|
189 | - return ''; |
|
190 | + if (is_numeric($news['id'])) { |
|
191 | + return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">'; |
|
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,15 +806,17 @@ 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; |
|
809 | + foreach ($_POST['exclude_groups'] as $group => $dummy) { |
|
810 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
811 | + } |
|
788 | 812 | } |
789 | 813 | // Ignore an empty string - we don't want to exclude "Regular Members" unless it's specifically selected |
790 | 814 | elseif ($_POST['exclude_groups'] != '') |
791 | 815 | { |
792 | 816 | $groups = explode(',', $_POST['exclude_groups']); |
793 | - foreach ($groups as $group) |
|
794 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
817 | + foreach ($groups as $group) { |
|
818 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
819 | + } |
|
795 | 820 | } |
796 | 821 | } |
797 | 822 | // Finally - emails! |
@@ -801,14 +826,16 @@ discard block |
||
801 | 826 | foreach ($addressed as $curmem) |
802 | 827 | { |
803 | 828 | $curmem = trim($curmem); |
804 | - if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) |
|
805 | - $context['recipients']['emails'][$curmem] = $curmem; |
|
829 | + if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) { |
|
830 | + $context['recipients']['emails'][$curmem] = $curmem; |
|
831 | + } |
|
806 | 832 | } |
807 | 833 | } |
808 | 834 | |
809 | 835 | // If we're only cleaning drop out here. |
810 | - if ($clean_only) |
|
811 | - return; |
|
836 | + if ($clean_only) { |
|
837 | + return; |
|
838 | + } |
|
812 | 839 | |
813 | 840 | require_once($sourcedir . '/Subs-Post.php'); |
814 | 841 | |
@@ -824,16 +851,18 @@ discard block |
||
824 | 851 | if (!$context['send_pm'] && !empty($_POST['send_html'])) |
825 | 852 | { |
826 | 853 | // Prepare the message for HTML. |
827 | - if (!empty($_POST['parse_html'])) |
|
828 | - $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
854 | + if (!empty($_POST['parse_html'])) { |
|
855 | + $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
856 | + } |
|
829 | 857 | |
830 | 858 | // This is here to prevent spam filters from tagging this as spam. |
831 | 859 | if (preg_match('~\<html~i', $_POST['message']) == 0) |
832 | 860 | { |
833 | - if (preg_match('~\<body~i', $_POST['message']) == 0) |
|
834 | - $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
835 | - else |
|
836 | - $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
861 | + if (preg_match('~\<body~i', $_POST['message']) == 0) { |
|
862 | + $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
863 | + } else { |
|
864 | + $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
865 | + } |
|
837 | 866 | } |
838 | 867 | } |
839 | 868 | |
@@ -887,15 +916,17 @@ discard block |
||
887 | 916 | foreach ($context['recipients']['emails'] as $k => $email) |
888 | 917 | { |
889 | 918 | // Done as many as we can? |
890 | - if ($i >= $num_at_once) |
|
891 | - break; |
|
919 | + if ($i >= $num_at_once) { |
|
920 | + break; |
|
921 | + } |
|
892 | 922 | |
893 | 923 | // Don't sent it twice! |
894 | 924 | unset($context['recipients']['emails'][$k]); |
895 | 925 | |
896 | 926 | // Dammit - can't PM emails! |
897 | - if ($context['send_pm']) |
|
898 | - continue; |
|
927 | + if ($context['send_pm']) { |
|
928 | + continue; |
|
929 | + } |
|
899 | 930 | |
900 | 931 | $to_member = array( |
901 | 932 | $email, |
@@ -929,8 +960,9 @@ discard block |
||
929 | 960 | $queryBuild[] = 'mem.id_post_group = {int:group_' . $group . '}'; |
930 | 961 | } |
931 | 962 | } |
932 | - if (!empty($queryBuild)) |
|
933 | - $sendQuery .= implode(' OR ', $queryBuild); |
|
963 | + if (!empty($queryBuild)) { |
|
964 | + $sendQuery .= implode(' OR ', $queryBuild); |
|
965 | + } |
|
934 | 966 | } |
935 | 967 | if (!empty($context['recipients']['members'])) |
936 | 968 | { |
@@ -949,8 +981,9 @@ discard block |
||
949 | 981 | } |
950 | 982 | |
951 | 983 | // Anything to exclude? |
952 | - if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) |
|
953 | - $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
984 | + if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) { |
|
985 | + $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
986 | + } |
|
954 | 987 | if (!empty($context['recipients']['exclude_members'])) |
955 | 988 | { |
956 | 989 | $sendQuery .= ' AND mem.id_member NOT IN ({array_int:exclude_members})'; |
@@ -986,21 +1019,24 @@ discard block |
||
986 | 1019 | foreach ($rows as $row) |
987 | 1020 | { |
988 | 1021 | // Force them to have it? |
989 | - if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) |
|
990 | - continue; |
|
1022 | + if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) { |
|
1023 | + continue; |
|
1024 | + } |
|
991 | 1025 | |
992 | 1026 | // What groups are we looking at here? |
993 | - if (empty($row['additional_groups'])) |
|
994 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
995 | - else |
|
996 | - $groups = array_merge( |
|
1027 | + if (empty($row['additional_groups'])) { |
|
1028 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
1029 | + } else { |
|
1030 | + $groups = array_merge( |
|
997 | 1031 | array($row['id_group'], $row['id_post_group']), |
998 | 1032 | explode(',', $row['additional_groups']) |
999 | 1033 | ); |
1034 | + } |
|
1000 | 1035 | |
1001 | 1036 | // Excluded groups? |
1002 | - if (array_intersect($groups, $context['recipients']['exclude_groups'])) |
|
1003 | - continue; |
|
1037 | + if (array_intersect($groups, $context['recipients']['exclude_groups'])) { |
|
1038 | + continue; |
|
1039 | + } |
|
1004 | 1040 | |
1005 | 1041 | // We might need this |
1006 | 1042 | $cleanMemberName = empty($_POST['send_html']) || $context['send_pm'] ? un_htmlspecialchars($row['real_name']) : $row['real_name']; |
@@ -1023,10 +1059,11 @@ discard block |
||
1023 | 1059 | ), $_POST['subject']); |
1024 | 1060 | |
1025 | 1061 | // Send the actual email - or a PM! |
1026 | - if (!$context['send_pm']) |
|
1027 | - sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
1028 | - else |
|
1029 | - sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
1062 | + if (!$context['send_pm']) { |
|
1063 | + sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
1064 | + } else { |
|
1065 | + sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
1066 | + } |
|
1030 | 1067 | } |
1031 | 1068 | } |
1032 | 1069 | |
@@ -1076,8 +1113,9 @@ discard block |
||
1076 | 1113 | |
1077 | 1114 | call_integration_hook('integrate_modify_news_settings', array(&$config_vars)); |
1078 | 1115 | |
1079 | - if ($return_config) |
|
1080 | - return $config_vars; |
|
1116 | + if ($return_config) { |
|
1117 | + return $config_vars; |
|
1118 | + } |
|
1081 | 1119 | |
1082 | 1120 | $context['page_title'] = $txt['admin_edit_news'] . ' - ' . $txt['settings']; |
1083 | 1121 | $context['sub_template'] = 'show_settings'; |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | // This won't be dedicated without this - this must exist in each gateway! |
15 | 15 | // SMF Payment Gateway: paypal |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Class for returning available form data for this gateway |
@@ -118,8 +119,7 @@ discard block |
||
118 | 119 | { |
119 | 120 | $return_data['hidden']['p3'] = 1; |
120 | 121 | $return_data['hidden']['t3'] = strtoupper(substr($period, 0, 1)); |
121 | - } |
|
122 | - else |
|
122 | + } else |
|
123 | 123 | { |
124 | 124 | preg_match('~(\d*)(\w)~', $sub_data['real_length'], $match); |
125 | 125 | $unit = $match[1]; |
@@ -130,14 +130,15 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | // If it's repeatable do some javascript to respect this idea. |
133 | - if (!empty($sub_data['repeatable'])) |
|
134 | - $return_data['javascript'] = ' |
|
133 | + if (!empty($sub_data['repeatable'])) { |
|
134 | + $return_data['javascript'] = ' |
|
135 | 135 | document.write(\'<label for="do_paypal_recur"><input type="checkbox" name="do_paypal_recur" id="do_paypal_recur" checked onclick="switchPaypalRecur();">' . $txt['paid_make_recurring'] . '</label><br>\'); |
136 | 136 | |
137 | 137 | function switchPaypalRecur() |
138 | 138 | { |
139 | 139 | document.getElementById("paypal_cmd").value = document.getElementById("do_paypal_recur").checked ? "_xclick-subscriptions" : "_xclick"; |
140 | 140 | }'; |
141 | + } |
|
141 | 142 | |
142 | 143 | return $return_data; |
143 | 144 | } |
@@ -160,20 +161,24 @@ discard block |
||
160 | 161 | global $modSettings; |
161 | 162 | |
162 | 163 | // Has the user set up an email address? |
163 | - if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email']))) |
|
164 | - return false; |
|
164 | + if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email']))) { |
|
165 | + return false; |
|
166 | + } |
|
165 | 167 | // Check the correct transaction types are even here. |
166 | - if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email']))) |
|
167 | - return false; |
|
168 | + if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email']))) { |
|
169 | + return false; |
|
170 | + } |
|
168 | 171 | // Correct email address? |
169 | - if (!isset($_POST['business'])) |
|
170 | - $_POST['business'] = $_POST['receiver_email']; |
|
172 | + if (!isset($_POST['business'])) { |
|
173 | + $_POST['business'] = $_POST['receiver_email']; |
|
174 | + } |
|
171 | 175 | |
172 | 176 | // Are we testing? |
173 | - if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) |
|
174 | - return false; |
|
175 | - elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails'])))) |
|
176 | - return false; |
|
177 | + if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) { |
|
178 | + return false; |
|
179 | + } elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails'])))) { |
|
180 | + return false; |
|
181 | + } |
|
177 | 182 | return true; |
178 | 183 | } |
179 | 184 | |
@@ -192,15 +197,17 @@ discard block |
||
192 | 197 | global $modSettings, $txt; |
193 | 198 | |
194 | 199 | // Put this to some default value. |
195 | - if (!isset($_POST['txn_type'])) |
|
196 | - $_POST['txn_type'] = ''; |
|
200 | + if (!isset($_POST['txn_type'])) { |
|
201 | + $_POST['txn_type'] = ''; |
|
202 | + } |
|
197 | 203 | |
198 | 204 | // Build the request string - starting with the minimum requirement. |
199 | 205 | $requestString = 'cmd=_notify-validate'; |
200 | 206 | |
201 | 207 | // Now my dear, add all the posted bits in the order we got them |
202 | - foreach ($_POST as $k => $v) |
|
203 | - $requestString .= '&' . $k . '=' . urlencode($v); |
|
208 | + foreach ($_POST as $k => $v) { |
|
209 | + $requestString .= '&' . $k . '=' . urlencode($v); |
|
210 | + } |
|
204 | 211 | |
205 | 212 | // Can we use curl? |
206 | 213 | if (function_exists('curl_init') && $curl = curl_init((!empty($modSettings['paidsubs_test']) ? 'https://www.sandbox.' : 'https://www.') . 'paypal.com/cgi-bin/webscr')) |
@@ -240,14 +247,16 @@ discard block |
||
240 | 247 | $header .= 'Connection: close' . "\r\n\r\n"; |
241 | 248 | |
242 | 249 | // Open the connection. |
243 | - if (!empty($modSettings['paidsubs_test'])) |
|
244 | - $fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); |
|
245 | - else |
|
246 | - $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30); |
|
250 | + if (!empty($modSettings['paidsubs_test'])) { |
|
251 | + $fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); |
|
252 | + } else { |
|
253 | + $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30); |
|
254 | + } |
|
247 | 255 | |
248 | 256 | // Did it work? |
249 | - if (!$fp) |
|
250 | - generateSubscriptionError($txt['paypal_could_not_connect']); |
|
257 | + if (!$fp) { |
|
258 | + generateSubscriptionError($txt['paypal_could_not_connect']); |
|
259 | + } |
|
251 | 260 | |
252 | 261 | // Put the data to the port. |
253 | 262 | fputs($fp, $header . $requestString); |
@@ -256,8 +265,9 @@ discard block |
||
256 | 265 | while (!feof($fp)) |
257 | 266 | { |
258 | 267 | $this->return_data = fgets($fp, 1024); |
259 | - if (strcmp(trim($this->return_data), 'VERIFIED') === 0) |
|
260 | - break; |
|
268 | + if (strcmp(trim($this->return_data), 'VERIFIED') === 0) { |
|
269 | + break; |
|
270 | + } |
|
261 | 271 | } |
262 | 272 | |
263 | 273 | // Clean up. |
@@ -265,28 +275,34 @@ discard block |
||
265 | 275 | } |
266 | 276 | |
267 | 277 | // If this isn't verified then give up... |
268 | - if (strcmp(trim($this->return_data), 'VERIFIED') !== 0) |
|
269 | - exit; |
|
278 | + if (strcmp(trim($this->return_data), 'VERIFIED') !== 0) { |
|
279 | + exit; |
|
280 | + } |
|
270 | 281 | |
271 | 282 | // Check that this is intended for us. |
272 | - if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) |
|
273 | - exit; |
|
283 | + if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) { |
|
284 | + exit; |
|
285 | + } |
|
274 | 286 | |
275 | 287 | // Is this a subscription - and if so is it a secondary payment that we need to process? |
276 | 288 | // If so, make sure we get it in the expected format. Seems PayPal sometimes sends it without urlencoding. |
277 | - if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false) |
|
278 | - $_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']); |
|
279 | - if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false)) |
|
280 | - // Calculate the subscription it relates to! |
|
289 | + if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false) { |
|
290 | + $_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']); |
|
291 | + } |
|
292 | + if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false)) { |
|
293 | + // Calculate the subscription it relates to! |
|
281 | 294 | $this->_findSubscription(); |
295 | + } |
|
282 | 296 | |
283 | 297 | // Verify the currency! |
284 | - if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code'])) |
|
285 | - exit; |
|
298 | + if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code'])) { |
|
299 | + exit; |
|
300 | + } |
|
286 | 301 | |
287 | 302 | // Can't exist if it doesn't contain anything. |
288 | - if (empty($_POST['item_number'])) |
|
289 | - exit; |
|
303 | + if (empty($_POST['item_number'])) { |
|
304 | + exit; |
|
305 | + } |
|
290 | 306 | |
291 | 307 | // Return the id_sub and id_member |
292 | 308 | return explode('+', $_POST['item_number']); |
@@ -299,10 +315,11 @@ discard block |
||
299 | 315 | */ |
300 | 316 | public function isRefund() |
301 | 317 | { |
302 | - if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')) |
|
303 | - return true; |
|
304 | - else |
|
305 | - return false; |
|
318 | + if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')) { |
|
319 | + return true; |
|
320 | + } else { |
|
321 | + return false; |
|
322 | + } |
|
306 | 323 | } |
307 | 324 | |
308 | 325 | /** |
@@ -312,10 +329,11 @@ discard block |
||
312 | 329 | */ |
313 | 330 | public function isSubscription() |
314 | 331 | { |
315 | - if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed') |
|
316 | - return true; |
|
317 | - else |
|
318 | - return false; |
|
332 | + if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed') { |
|
333 | + return true; |
|
334 | + } else { |
|
335 | + return false; |
|
336 | + } |
|
319 | 337 | } |
320 | 338 | |
321 | 339 | /** |
@@ -325,10 +343,11 @@ discard block |
||
325 | 343 | */ |
326 | 344 | public function isPayment() |
327 | 345 | { |
328 | - if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept') |
|
329 | - return true; |
|
330 | - else |
|
331 | - return false; |
|
346 | + if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept') { |
|
347 | + return true; |
|
348 | + } else { |
|
349 | + return false; |
|
350 | + } |
|
332 | 351 | } |
333 | 352 | |
334 | 353 | /** |
@@ -341,10 +360,11 @@ discard block |
||
341 | 360 | // subscr_cancel is sent when the user cancels, subscr_eot is sent when the subscription reaches final payment |
342 | 361 | // Neither require us to *do* anything as per performCancel(). |
343 | 362 | // subscr_eot, if sent, indicates an end of payments term. |
344 | - if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot') |
|
345 | - return true; |
|
346 | - else |
|
347 | - return false; |
|
363 | + if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot') { |
|
364 | + return true; |
|
365 | + } else { |
|
366 | + return false; |
|
367 | + } |
|
348 | 368 | } |
349 | 369 | |
350 | 370 | /** |
@@ -408,8 +428,9 @@ discard block |
||
408 | 428 | global $smcFunc; |
409 | 429 | |
410 | 430 | // Assume we have this? |
411 | - if (empty($_POST['subscr_id'])) |
|
412 | - return false; |
|
431 | + if (empty($_POST['subscr_id'])) { |
|
432 | + return false; |
|
433 | + } |
|
413 | 434 | |
414 | 435 | // Do we have this in the database? |
415 | 436 | $request = $smcFunc['db_query']('', ' |
@@ -438,11 +459,12 @@ discard block |
||
438 | 459 | 'payer_email' => $_POST['payer_email'], |
439 | 460 | ) |
440 | 461 | ); |
441 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
442 | - return false; |
|
462 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
463 | + return false; |
|
464 | + } |
|
465 | + } else { |
|
466 | + return false; |
|
443 | 467 | } |
444 | - else |
|
445 | - return false; |
|
446 | 468 | } |
447 | 469 | list ($member_id, $subscription_id) = $smcFunc['db_fetch_row']($request); |
448 | 470 | $_POST['item_number'] = $member_id . '+' . $subscription_id; |
@@ -43,28 +43,33 @@ discard block |
||
43 | 43 | </div> |
44 | 44 | <div class="list_posts">', $post['message'], '</div>'; |
45 | 45 | |
46 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
47 | - echo ' |
|
46 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
47 | + echo ' |
|
48 | 48 | <ul class="quickbuttons">'; |
49 | + } |
|
49 | 50 | |
50 | 51 | // If they *can* reply? |
51 | - if ($post['can_reply']) |
|
52 | - echo ' |
|
52 | + if ($post['can_reply']) { |
|
53 | + echo ' |
|
53 | 54 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
55 | + } |
|
54 | 56 | |
55 | 57 | // If they *can* quote? |
56 | - if ($post['can_quote']) |
|
57 | - echo ' |
|
58 | + if ($post['can_quote']) { |
|
59 | + echo ' |
|
58 | 60 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
61 | + } |
|
59 | 62 | |
60 | 63 | // How about... even... remove it entirely?! |
61 | - if ($post['can_delete']) |
|
62 | - echo ' |
|
64 | + if ($post['can_delete']) { |
|
65 | + echo ' |
|
63 | 66 | <li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';recent;', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
67 | + } |
|
64 | 68 | |
65 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
66 | - echo ' |
|
69 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
70 | + echo ' |
|
67 | 71 | </ul>'; |
72 | + } |
|
68 | 73 | |
69 | 74 | echo ' |
70 | 75 | </div>'; |
@@ -86,12 +91,13 @@ discard block |
||
86 | 91 | echo ' |
87 | 92 | <div id="recent" class="main_content">'; |
88 | 93 | |
89 | - if ($context['showCheckboxes']) |
|
90 | - echo ' |
|
94 | + if ($context['showCheckboxes']) { |
|
95 | + echo ' |
|
91 | 96 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;"> |
92 | 97 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
93 | 98 | <input type="hidden" name="qaction" value="markread"> |
94 | 99 | <input type="hidden" name="redirect_url" value="action=unread', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">'; |
100 | + } |
|
95 | 101 | |
96 | 102 | if (!empty($context['topics'])) |
97 | 103 | { |
@@ -120,11 +126,12 @@ discard block |
||
120 | 126 | </div>'; |
121 | 127 | |
122 | 128 | // Show a "select all" box for quick moderation? |
123 | - if ($context['showCheckboxes']) |
|
124 | - echo ' |
|
129 | + if ($context['showCheckboxes']) { |
|
130 | + echo ' |
|
125 | 131 | <div class="moderation"> |
126 | 132 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"> |
127 | 133 | </div>'; |
134 | + } |
|
128 | 135 | |
129 | 136 | echo ' |
130 | 137 | </div> |
@@ -143,15 +150,18 @@ discard block |
||
143 | 150 | // Now we handle the icons |
144 | 151 | echo ' |
145 | 152 | <div class="icons floatright">'; |
146 | - if ($topic['is_locked']) |
|
147 | - echo ' |
|
153 | + if ($topic['is_locked']) { |
|
154 | + echo ' |
|
148 | 155 | <span class="generic_icons lock"></span>'; |
149 | - if ($topic['is_sticky']) |
|
150 | - echo ' |
|
156 | + } |
|
157 | + if ($topic['is_sticky']) { |
|
158 | + echo ' |
|
151 | 159 | <span class="generic_icons sticky"></span>'; |
152 | - if ($topic['is_poll']) |
|
153 | - echo ' |
|
160 | + } |
|
161 | + if ($topic['is_poll']) { |
|
162 | + echo ' |
|
154 | 163 | <span class="generic_icons poll"></span>'; |
164 | + } |
|
155 | 165 | echo ' |
156 | 166 | </div>'; |
157 | 167 | |
@@ -176,19 +186,21 @@ discard block |
||
176 | 186 | ', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), ' |
177 | 187 | </div>'; |
178 | 188 | |
179 | - if ($context['showCheckboxes']) |
|
180 | - echo ' |
|
189 | + if ($context['showCheckboxes']) { |
|
190 | + echo ' |
|
181 | 191 | <div class="moderation"> |
182 | 192 | <input type="checkbox" name="topics[]" value="', $topic['id'], '"> |
183 | 193 | </div>'; |
194 | + } |
|
184 | 195 | |
185 | 196 | echo ' |
186 | 197 | </div>'; |
187 | 198 | } |
188 | 199 | |
189 | - if (empty($context['topics'])) |
|
190 | - echo ' |
|
200 | + if (empty($context['topics'])) { |
|
201 | + echo ' |
|
191 | 202 | <div style="display: none;"></div>'; |
203 | + } |
|
192 | 204 | |
193 | 205 | echo ' |
194 | 206 | </div> |
@@ -203,25 +215,27 @@ discard block |
||
203 | 215 | ', $context['page_index'], ' |
204 | 216 | </div> |
205 | 217 | </div>'; |
206 | - } |
|
207 | - else |
|
208 | - echo ' |
|
218 | + } else { |
|
219 | + echo ' |
|
209 | 220 | <div class="cat_bar"> |
210 | 221 | <h3 class="catbg centertext"> |
211 | 222 | ', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], ' |
212 | 223 | </h3> |
213 | 224 | </div>'; |
225 | + } |
|
214 | 226 | |
215 | - if ($context['showCheckboxes']) |
|
216 | - echo ' |
|
227 | + if ($context['showCheckboxes']) { |
|
228 | + echo ' |
|
217 | 229 | </form>'; |
230 | + } |
|
218 | 231 | |
219 | 232 | echo ' |
220 | 233 | </div>'; |
221 | 234 | |
222 | - if (empty($context['no_topic_listing'])) |
|
223 | - template_topic_legend(); |
|
224 | -} |
|
235 | + if (empty($context['no_topic_listing'])) { |
|
236 | + template_topic_legend(); |
|
237 | + } |
|
238 | + } |
|
225 | 239 | |
226 | 240 | /** |
227 | 241 | * Template for showing unread replies (eg new replies to topics you've posted in) |
@@ -233,12 +247,13 @@ discard block |
||
233 | 247 | echo ' |
234 | 248 | <div id="recent">'; |
235 | 249 | |
236 | - if ($context['showCheckboxes']) |
|
237 | - echo ' |
|
250 | + if ($context['showCheckboxes']) { |
|
251 | + echo ' |
|
238 | 252 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;"> |
239 | 253 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
240 | 254 | <input type="hidden" name="qaction" value="markread"> |
241 | 255 | <input type="hidden" name="redirect_url" value="action=unreadreplies', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">'; |
256 | + } |
|
242 | 257 | |
243 | 258 | if (!empty($context['topics'])) |
244 | 259 | { |
@@ -267,11 +282,12 @@ discard block |
||
267 | 282 | </div>'; |
268 | 283 | |
269 | 284 | // Show a "select all" box for quick moderation? |
270 | - if ($context['showCheckboxes']) |
|
271 | - echo ' |
|
285 | + if ($context['showCheckboxes']) { |
|
286 | + echo ' |
|
272 | 287 | <div class="moderation"> |
273 | 288 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"> |
274 | 289 | </div>'; |
290 | + } |
|
275 | 291 | |
276 | 292 | echo ' |
277 | 293 | </div> |
@@ -290,15 +306,18 @@ discard block |
||
290 | 306 | // Now we handle the icons |
291 | 307 | echo ' |
292 | 308 | <div class="icons floatright">'; |
293 | - if ($topic['is_locked']) |
|
294 | - echo ' |
|
309 | + if ($topic['is_locked']) { |
|
310 | + echo ' |
|
295 | 311 | <span class="generic_icons lock"></span>'; |
296 | - if ($topic['is_sticky']) |
|
297 | - echo ' |
|
312 | + } |
|
313 | + if ($topic['is_sticky']) { |
|
314 | + echo ' |
|
298 | 315 | <span class="generic_icons sticky"></span>'; |
299 | - if ($topic['is_poll']) |
|
300 | - echo ' |
|
316 | + } |
|
317 | + if ($topic['is_poll']) { |
|
318 | + echo ' |
|
301 | 319 | <span class="generic_icons poll"></span>'; |
320 | + } |
|
302 | 321 | echo ' |
303 | 322 | </div>'; |
304 | 323 | |
@@ -323,11 +342,12 @@ discard block |
||
323 | 342 | ', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), ' |
324 | 343 | </div>'; |
325 | 344 | |
326 | - if ($context['showCheckboxes']) |
|
327 | - echo ' |
|
345 | + if ($context['showCheckboxes']) { |
|
346 | + echo ' |
|
328 | 347 | <div class="moderation"> |
329 | 348 | <input type="checkbox" name="topics[]" value="', $topic['id'], '"> |
330 | 349 | </div>'; |
350 | + } |
|
331 | 351 | echo ' |
332 | 352 | </div>'; |
333 | 353 | } |
@@ -343,24 +363,26 @@ discard block |
||
343 | 363 | ', $context['page_index'], ' |
344 | 364 | </div> |
345 | 365 | </div>'; |
346 | - } |
|
347 | - else |
|
348 | - echo ' |
|
366 | + } else { |
|
367 | + echo ' |
|
349 | 368 | <div class="cat_bar"> |
350 | 369 | <h3 class="catbg centertext"> |
351 | 370 | ', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], ' |
352 | 371 | </h3> |
353 | 372 | </div>'; |
373 | + } |
|
354 | 374 | |
355 | - if ($context['showCheckboxes']) |
|
356 | - echo ' |
|
375 | + if ($context['showCheckboxes']) { |
|
376 | + echo ' |
|
357 | 377 | </form>'; |
378 | + } |
|
358 | 379 | |
359 | 380 | echo ' |
360 | 381 | </div>'; |
361 | 382 | |
362 | - if (empty($context['no_topic_listing'])) |
|
363 | - template_topic_legend(); |
|
364 | -} |
|
383 | + if (empty($context['no_topic_listing'])) { |
|
384 | + template_topic_legend(); |
|
385 | + } |
|
386 | + } |
|
365 | 387 | |
366 | 388 | ?> |
367 | 389 | \ No newline at end of file |
@@ -11,8 +11,9 @@ |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Converts the given UTF-8 string into lowercase. |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * View a summary. |
@@ -23,8 +24,9 @@ discard block |
||
23 | 24 | global $context, $memberContext, $txt, $modSettings, $user_profile, $sourcedir, $scripturl, $smcFunc; |
24 | 25 | |
25 | 26 | // Attempt to load the member's profile data. |
26 | - if (!loadMemberContext($memID) || !isset($memberContext[$memID])) |
|
27 | - fatal_lang_error('not_a_user', false, 404); |
|
27 | + if (!loadMemberContext($memID) || !isset($memberContext[$memID])) { |
|
28 | + fatal_lang_error('not_a_user', false, 404); |
|
29 | + } |
|
28 | 30 | |
29 | 31 | // Set up the stuff and load the user. |
30 | 32 | $context += array( |
@@ -49,19 +51,21 @@ discard block |
||
49 | 51 | |
50 | 52 | // See if they have broken any warning levels... |
51 | 53 | list ($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']); |
52 | - if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) |
|
53 | - $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
54 | - elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) |
|
55 | - $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
56 | - elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) |
|
57 | - $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
54 | + if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) { |
|
55 | + $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
56 | + } elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) { |
|
57 | + $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
58 | + } elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) { |
|
59 | + $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
60 | + } |
|
58 | 61 | |
59 | 62 | // They haven't even been registered for a full day!? |
60 | 63 | $days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24)); |
61 | - if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) |
|
62 | - $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
63 | - else |
|
64 | - $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
64 | + if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) { |
|
65 | + $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
66 | + } else { |
|
67 | + $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
68 | + } |
|
65 | 69 | |
66 | 70 | // Set the age... |
67 | 71 | if (empty($context['member']['birth_date']) || substr($context['member']['birth_date'], 0, 4) < 1002) |
@@ -70,8 +74,7 @@ discard block |
||
70 | 74 | 'age' => $txt['not_applicable'], |
71 | 75 | 'today_is_birthday' => false |
72 | 76 | ); |
73 | - } |
|
74 | - else |
|
77 | + } else |
|
75 | 78 | { |
76 | 79 | list ($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d'); |
77 | 80 | $datearray = getdate(forum_time()); |
@@ -84,15 +87,16 @@ discard block |
||
84 | 87 | if (allowedTo('moderate_forum')) |
85 | 88 | { |
86 | 89 | // Make sure it's a valid ip address; otherwise, don't bother... |
87 | - if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) |
|
88 | - $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
89 | - else |
|
90 | - $context['member']['hostname'] = ''; |
|
90 | + if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) { |
|
91 | + $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
92 | + } else { |
|
93 | + $context['member']['hostname'] = ''; |
|
94 | + } |
|
91 | 95 | |
92 | 96 | $context['can_see_ip'] = true; |
97 | + } else { |
|
98 | + $context['can_see_ip'] = false; |
|
93 | 99 | } |
94 | - else |
|
95 | - $context['can_see_ip'] = false; |
|
96 | 100 | |
97 | 101 | // Are they hidden? |
98 | 102 | $context['member']['is_hidden'] = empty($user_profile[$memID]['show_online']); |
@@ -103,8 +107,9 @@ discard block |
||
103 | 107 | include_once($sourcedir . '/Who.php'); |
104 | 108 | $action = determineActions($user_profile[$memID]['url']); |
105 | 109 | |
106 | - if ($action !== false) |
|
107 | - $context['member']['action'] = $action; |
|
110 | + if ($action !== false) { |
|
111 | + $context['member']['action'] = $action; |
|
112 | + } |
|
108 | 113 | } |
109 | 114 | |
110 | 115 | // If the user is awaiting activation, and the viewer has permission - setup some activation context messages. |
@@ -167,13 +172,15 @@ discard block |
||
167 | 172 | { |
168 | 173 | // Work out what restrictions we actually have. |
169 | 174 | $ban_restrictions = array(); |
170 | - foreach (array('access', 'login', 'post') as $type) |
|
171 | - if ($row['cannot_' . $type]) |
|
175 | + foreach (array('access', 'login', 'post') as $type) { |
|
176 | + if ($row['cannot_' . $type]) |
|
172 | 177 | $ban_restrictions[] = $txt['ban_type_' . $type]; |
178 | + } |
|
173 | 179 | |
174 | 180 | // No actual ban in place? |
175 | - if (empty($ban_restrictions)) |
|
176 | - continue; |
|
181 | + if (empty($ban_restrictions)) { |
|
182 | + continue; |
|
183 | + } |
|
177 | 184 | |
178 | 185 | // Prepare the link for context. |
179 | 186 | $ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=admin;area=ban;sa=edit;bg=' . $row['id_ban_group'] . '">' . $row['name'] . '</a>'); |
@@ -195,9 +202,10 @@ discard block |
||
195 | 202 | $context['print_custom_fields'] = array(); |
196 | 203 | |
197 | 204 | // Any custom profile fields? |
198 | - if (!empty($context['custom_fields'])) |
|
199 | - foreach ($context['custom_fields'] as $custom) |
|
205 | + if (!empty($context['custom_fields'])) { |
|
206 | + foreach ($context['custom_fields'] as $custom) |
|
200 | 207 | $context['print_custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
208 | + } |
|
201 | 209 | |
202 | 210 | } |
203 | 211 | |
@@ -241,14 +249,16 @@ discard block |
||
241 | 249 | $row['extra'] = !empty($row['extra']) ? $smcFunc['json_decode']($row['extra'], true) : array(); |
242 | 250 | $alerts[$id_alert] = $row; |
243 | 251 | |
244 | - if (!empty($row['sender_id'])) |
|
245 | - $senders[] = $row['sender_id']; |
|
252 | + if (!empty($row['sender_id'])) { |
|
253 | + $senders[] = $row['sender_id']; |
|
254 | + } |
|
246 | 255 | } |
247 | 256 | $smcFunc['db_free_result']($request); |
248 | 257 | |
249 | 258 | $senders = loadMemberData($senders); |
250 | - foreach ($senders as $member) |
|
251 | - loadMemberContext($member); |
|
259 | + foreach ($senders as $member) { |
|
260 | + loadMemberContext($member); |
|
261 | + } |
|
252 | 262 | |
253 | 263 | // Now go through and actually make with the text. |
254 | 264 | loadLanguage('Alerts'); |
@@ -262,12 +272,15 @@ discard block |
||
262 | 272 | $msgs = array(); |
263 | 273 | foreach ($alerts as $id_alert => $alert) |
264 | 274 | { |
265 | - if (isset($alert['extra']['board'])) |
|
266 | - $boards[$alert['extra']['board']] = $txt['board_na']; |
|
267 | - if (isset($alert['extra']['topic'])) |
|
268 | - $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
269 | - if ($alert['content_type'] == 'msg') |
|
270 | - $msgs[$alert['content_id']] = $txt['topic_na']; |
|
275 | + if (isset($alert['extra']['board'])) { |
|
276 | + $boards[$alert['extra']['board']] = $txt['board_na']; |
|
277 | + } |
|
278 | + if (isset($alert['extra']['topic'])) { |
|
279 | + $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
280 | + } |
|
281 | + if ($alert['content_type'] == 'msg') { |
|
282 | + $msgs[$alert['content_id']] = $txt['topic_na']; |
|
283 | + } |
|
271 | 284 | } |
272 | 285 | |
273 | 286 | // Having figured out what boards etc. there are, let's now get the names of them if we can see them. If not, there's already a fallback set up. |
@@ -282,8 +295,9 @@ discard block |
||
282 | 295 | 'boards' => array_keys($boards), |
283 | 296 | ) |
284 | 297 | ); |
285 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
286 | - $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
298 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
299 | + $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
300 | + } |
|
287 | 301 | } |
288 | 302 | if (!empty($topics)) |
289 | 303 | { |
@@ -298,8 +312,9 @@ discard block |
||
298 | 312 | 'topics' => array_keys($topics), |
299 | 313 | ) |
300 | 314 | ); |
301 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
302 | - $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
315 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
316 | + $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
317 | + } |
|
303 | 318 | } |
304 | 319 | if (!empty($msgs)) |
305 | 320 | { |
@@ -314,26 +329,33 @@ discard block |
||
314 | 329 | 'msgs' => array_keys($msgs), |
315 | 330 | ) |
316 | 331 | ); |
317 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
318 | - $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
332 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
333 | + $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
334 | + } |
|
319 | 335 | } |
320 | 336 | |
321 | 337 | // Now to go back through the alerts, reattach this extra information and then try to build the string out of it (if a hook didn't already) |
322 | 338 | foreach ($alerts as $id_alert => $alert) |
323 | 339 | { |
324 | - if (!empty($alert['text'])) |
|
325 | - continue; |
|
326 | - if (isset($alert['extra']['board'])) |
|
327 | - $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
328 | - if (isset($alert['extra']['topic'])) |
|
329 | - $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
330 | - if ($alert['content_type'] == 'msg') |
|
331 | - $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
332 | - if ($alert['content_type'] == 'profile') |
|
333 | - $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
334 | - |
|
335 | - if (!empty($memberContext[$alert['sender_id']])) |
|
336 | - $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
340 | + if (!empty($alert['text'])) { |
|
341 | + continue; |
|
342 | + } |
|
343 | + if (isset($alert['extra']['board'])) { |
|
344 | + $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
345 | + } |
|
346 | + if (isset($alert['extra']['topic'])) { |
|
347 | + $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
348 | + } |
|
349 | + if ($alert['content_type'] == 'msg') { |
|
350 | + $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
351 | + } |
|
352 | + if ($alert['content_type'] == 'profile') { |
|
353 | + $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
354 | + } |
|
355 | + |
|
356 | + if (!empty($memberContext[$alert['sender_id']])) { |
|
357 | + $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
358 | + } |
|
337 | 359 | |
338 | 360 | $string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action']; |
339 | 361 | if (isset($txt[$string])) |
@@ -421,11 +443,11 @@ discard block |
||
421 | 443 | checkSession('request'); |
422 | 444 | |
423 | 445 | // Call it! |
424 | - if ($action == 'remove') |
|
425 | - alert_delete($toMark, $memID); |
|
426 | - |
|
427 | - else |
|
428 | - alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
446 | + if ($action == 'remove') { |
|
447 | + alert_delete($toMark, $memID); |
|
448 | + } else { |
|
449 | + alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
450 | + } |
|
429 | 451 | |
430 | 452 | // Set a nice update message. |
431 | 453 | $_SESSION['update_message'] = true; |
@@ -475,23 +497,27 @@ discard block |
||
475 | 497 | ); |
476 | 498 | |
477 | 499 | // Set the page title |
478 | - if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) |
|
479 | - $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
480 | - else |
|
481 | - $context['page_title'] = $txt['showPosts']; |
|
500 | + if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) { |
|
501 | + $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
502 | + } else { |
|
503 | + $context['page_title'] = $txt['showPosts']; |
|
504 | + } |
|
482 | 505 | |
483 | 506 | $context['page_title'] .= ' - ' . $user_profile[$memID]['real_name']; |
484 | 507 | |
485 | 508 | // Is the load average too high to allow searching just now? |
486 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) |
|
487 | - fatal_lang_error('loadavg_show_posts_disabled', false); |
|
509 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) { |
|
510 | + fatal_lang_error('loadavg_show_posts_disabled', false); |
|
511 | + } |
|
488 | 512 | |
489 | 513 | // If we're specifically dealing with attachments use that function! |
490 | - if (isset($_GET['sa']) && $_GET['sa'] == 'attach') |
|
491 | - return showAttachments($memID); |
|
514 | + if (isset($_GET['sa']) && $_GET['sa'] == 'attach') { |
|
515 | + return showAttachments($memID); |
|
516 | + } |
|
492 | 517 | // Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function. |
493 | - elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') |
|
494 | - return showUnwatched($memID); |
|
518 | + elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') { |
|
519 | + return showUnwatched($memID); |
|
520 | + } |
|
495 | 521 | |
496 | 522 | // Are we just viewing topics? |
497 | 523 | $context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false; |
@@ -514,27 +540,30 @@ discard block |
||
514 | 540 | $smcFunc['db_free_result']($request); |
515 | 541 | |
516 | 542 | // Trying to remove a message that doesn't exist. |
517 | - if (empty($info)) |
|
518 | - redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
543 | + if (empty($info)) { |
|
544 | + redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
545 | + } |
|
519 | 546 | |
520 | 547 | // We can be lazy, since removeMessage() will check the permissions for us. |
521 | 548 | require_once($sourcedir . '/RemoveTopic.php'); |
522 | 549 | removeMessage((int) $_GET['delete']); |
523 | 550 | |
524 | 551 | // Add it to the mod log. |
525 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
526 | - logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
552 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
553 | + logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
554 | + } |
|
527 | 555 | |
528 | 556 | // Back to... where we are now ;). |
529 | 557 | redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
530 | 558 | } |
531 | 559 | |
532 | 560 | // Default to 10. |
533 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
534 | - $_REQUEST['viewscount'] = '10'; |
|
561 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
562 | + $_REQUEST['viewscount'] = '10'; |
|
563 | + } |
|
535 | 564 | |
536 | - if ($context['is_topics']) |
|
537 | - $request = $smcFunc['db_query']('', ' |
|
565 | + if ($context['is_topics']) { |
|
566 | + $request = $smcFunc['db_query']('', ' |
|
538 | 567 | SELECT COUNT(*) |
539 | 568 | FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
540 | 569 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . ' |
@@ -547,8 +576,8 @@ discard block |
||
547 | 576 | 'board' => $board, |
548 | 577 | ) |
549 | 578 | ); |
550 | - else |
|
551 | - $request = $smcFunc['db_query']('', ' |
|
579 | + } else { |
|
580 | + $request = $smcFunc['db_query']('', ' |
|
552 | 581 | SELECT COUNT(*) |
553 | 582 | FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
554 | 583 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . ' |
@@ -561,6 +590,7 @@ discard block |
||
561 | 590 | 'board' => $board, |
562 | 591 | ) |
563 | 592 | ); |
593 | + } |
|
564 | 594 | list ($msgCount) = $smcFunc['db_fetch_row']($request); |
565 | 595 | $smcFunc['db_free_result']($request); |
566 | 596 | |
@@ -581,10 +611,11 @@ discard block |
||
581 | 611 | |
582 | 612 | $range_limit = ''; |
583 | 613 | |
584 | - if ($context['is_topics']) |
|
585 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
586 | - else |
|
587 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
614 | + if ($context['is_topics']) { |
|
615 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
616 | + } else { |
|
617 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
618 | + } |
|
588 | 619 | |
589 | 620 | $maxIndex = $maxPerPage; |
590 | 621 | |
@@ -610,9 +641,9 @@ discard block |
||
610 | 641 | { |
611 | 642 | $margin *= 5; |
612 | 643 | $range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin); |
644 | + } else { |
|
645 | + $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
613 | 646 | } |
614 | - else |
|
615 | - $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
616 | 647 | } |
617 | 648 | |
618 | 649 | // Find this user's posts. The left join on categories somehow makes this faster, weird as it looks. |
@@ -644,8 +675,7 @@ discard block |
||
644 | 675 | 'max' => $maxIndex, |
645 | 676 | ) |
646 | 677 | ); |
647 | - } |
|
648 | - else |
|
678 | + } else |
|
649 | 679 | { |
650 | 680 | $request = $smcFunc['db_query']('', ' |
651 | 681 | SELECT |
@@ -674,8 +704,9 @@ discard block |
||
674 | 704 | } |
675 | 705 | |
676 | 706 | // Make sure we quit this loop. |
677 | - if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) |
|
678 | - break; |
|
707 | + if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) { |
|
708 | + break; |
|
709 | + } |
|
679 | 710 | $looped = true; |
680 | 711 | $range_limit = ''; |
681 | 712 | } |
@@ -719,19 +750,21 @@ discard block |
||
719 | 750 | 'css_class' => $row['approved'] ? 'windowbg' : 'approvebg', |
720 | 751 | ); |
721 | 752 | |
722 | - if ($user_info['id'] == $row['id_member_started']) |
|
723 | - $board_ids['own'][$row['id_board']][] = $counter; |
|
753 | + if ($user_info['id'] == $row['id_member_started']) { |
|
754 | + $board_ids['own'][$row['id_board']][] = $counter; |
|
755 | + } |
|
724 | 756 | $board_ids['any'][$row['id_board']][] = $counter; |
725 | 757 | } |
726 | 758 | $smcFunc['db_free_result']($request); |
727 | 759 | |
728 | 760 | // All posts were retrieved in reverse order, get them right again. |
729 | - if ($reverse) |
|
730 | - $context['posts'] = array_reverse($context['posts'], true); |
|
761 | + if ($reverse) { |
|
762 | + $context['posts'] = array_reverse($context['posts'], true); |
|
763 | + } |
|
731 | 764 | |
732 | 765 | // These are all the permissions that are different from board to board.. |
733 | - if ($context['is_topics']) |
|
734 | - $permissions = array( |
|
766 | + if ($context['is_topics']) { |
|
767 | + $permissions = array( |
|
735 | 768 | 'own' => array( |
736 | 769 | 'post_reply_own' => 'can_reply', |
737 | 770 | ), |
@@ -739,8 +772,8 @@ discard block |
||
739 | 772 | 'post_reply_any' => 'can_reply', |
740 | 773 | ) |
741 | 774 | ); |
742 | - else |
|
743 | - $permissions = array( |
|
775 | + } else { |
|
776 | + $permissions = array( |
|
744 | 777 | 'own' => array( |
745 | 778 | 'post_reply_own' => 'can_reply', |
746 | 779 | 'delete_own' => 'can_delete', |
@@ -750,6 +783,7 @@ discard block |
||
750 | 783 | 'delete_any' => 'can_delete', |
751 | 784 | ) |
752 | 785 | ); |
786 | + } |
|
753 | 787 | |
754 | 788 | // For every permission in the own/any lists... |
755 | 789 | foreach ($permissions as $type => $list) |
@@ -760,19 +794,22 @@ discard block |
||
760 | 794 | $boards = boardsAllowedTo($permission); |
761 | 795 | |
762 | 796 | // Hmm, they can do it on all boards, can they? |
763 | - if (!empty($boards) && $boards[0] == 0) |
|
764 | - $boards = array_keys($board_ids[$type]); |
|
797 | + if (!empty($boards) && $boards[0] == 0) { |
|
798 | + $boards = array_keys($board_ids[$type]); |
|
799 | + } |
|
765 | 800 | |
766 | 801 | // Now go through each board they can do the permission on. |
767 | 802 | foreach ($boards as $board_id) |
768 | 803 | { |
769 | 804 | // There aren't any posts displayed from this board. |
770 | - if (!isset($board_ids[$type][$board_id])) |
|
771 | - continue; |
|
805 | + if (!isset($board_ids[$type][$board_id])) { |
|
806 | + continue; |
|
807 | + } |
|
772 | 808 | |
773 | 809 | // Set the permission to true ;). |
774 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
775 | - $context['posts'][$counter][$allowed] = true; |
|
810 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
811 | + $context['posts'][$counter][$allowed] = true; |
|
812 | + } |
|
776 | 813 | } |
777 | 814 | } |
778 | 815 | } |
@@ -803,8 +840,9 @@ discard block |
||
803 | 840 | $boardsAllowed = boardsAllowedTo('view_attachments'); |
804 | 841 | |
805 | 842 | // Make sure we can't actually see anything... |
806 | - if (empty($boardsAllowed)) |
|
807 | - $boardsAllowed = array(-1); |
|
843 | + if (empty($boardsAllowed)) { |
|
844 | + $boardsAllowed = array(-1); |
|
845 | + } |
|
808 | 846 | |
809 | 847 | require_once($sourcedir . '/Subs-List.php'); |
810 | 848 | |
@@ -955,8 +993,8 @@ discard block |
||
955 | 993 | ) |
956 | 994 | ); |
957 | 995 | $attachments = array(); |
958 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
959 | - $attachments[] = array( |
|
996 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
997 | + $attachments[] = array( |
|
960 | 998 | 'id' => $row['id_attach'], |
961 | 999 | 'filename' => $row['filename'], |
962 | 1000 | 'downloads' => $row['downloads'], |
@@ -968,6 +1006,7 @@ discard block |
||
968 | 1006 | 'board_name' => $row['name'], |
969 | 1007 | 'approved' => $row['approved'], |
970 | 1008 | ); |
1009 | + } |
|
971 | 1010 | |
972 | 1011 | $smcFunc['db_free_result']($request); |
973 | 1012 | |
@@ -1022,8 +1061,9 @@ discard block |
||
1022 | 1061 | global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir; |
1023 | 1062 | |
1024 | 1063 | // Only the owner can see the list (if the function is enabled of course) |
1025 | - if ($user_info['id'] != $memID) |
|
1026 | - return; |
|
1064 | + if ($user_info['id'] != $memID) { |
|
1065 | + return; |
|
1066 | + } |
|
1027 | 1067 | |
1028 | 1068 | require_once($sourcedir . '/Subs-List.php'); |
1029 | 1069 | |
@@ -1169,8 +1209,9 @@ discard block |
||
1169 | 1209 | ); |
1170 | 1210 | |
1171 | 1211 | $topics = array(); |
1172 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1173 | - $topics[] = $row['id_topic']; |
|
1212 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1213 | + $topics[] = $row['id_topic']; |
|
1214 | + } |
|
1174 | 1215 | |
1175 | 1216 | $smcFunc['db_free_result']($request); |
1176 | 1217 | |
@@ -1190,8 +1231,9 @@ discard block |
||
1190 | 1231 | 'topics' => $topics, |
1191 | 1232 | ) |
1192 | 1233 | ); |
1193 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1194 | - $topicsInfo[] = $row; |
|
1234 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1235 | + $topicsInfo[] = $row; |
|
1236 | + } |
|
1195 | 1237 | $smcFunc['db_free_result']($request); |
1196 | 1238 | } |
1197 | 1239 | |
@@ -1239,8 +1281,9 @@ discard block |
||
1239 | 1281 | $context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name']; |
1240 | 1282 | |
1241 | 1283 | // Is the load average too high to allow searching just now? |
1242 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) |
|
1243 | - fatal_lang_error('loadavg_userstats_disabled', false); |
|
1284 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) { |
|
1285 | + fatal_lang_error('loadavg_userstats_disabled', false); |
|
1286 | + } |
|
1244 | 1287 | |
1245 | 1288 | // General user statistics. |
1246 | 1289 | $timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400); |
@@ -1398,11 +1441,13 @@ discard block |
||
1398 | 1441 | } |
1399 | 1442 | $smcFunc['db_free_result']($result); |
1400 | 1443 | |
1401 | - if ($maxPosts > 0) |
|
1402 | - for ($hour = 0; $hour < 24; $hour++) |
|
1444 | + if ($maxPosts > 0) { |
|
1445 | + for ($hour = 0; |
|
1446 | + } |
|
1447 | + $hour < 24; $hour++) |
|
1403 | 1448 | { |
1404 | - if (!isset($context['posts_by_time'][$hour])) |
|
1405 | - $context['posts_by_time'][$hour] = array( |
|
1449 | + if (!isset($context['posts_by_time'][$hour])) { |
|
1450 | + $context['posts_by_time'][$hour] = array( |
|
1406 | 1451 | 'hour' => $hour, |
1407 | 1452 | 'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)), |
1408 | 1453 | 'posts' => 0, |
@@ -1410,7 +1455,7 @@ discard block |
||
1410 | 1455 | 'relative_percent' => 0, |
1411 | 1456 | 'is_last' => $hour == 23, |
1412 | 1457 | ); |
1413 | - else |
|
1458 | + } else |
|
1414 | 1459 | { |
1415 | 1460 | $context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts); |
1416 | 1461 | $context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts); |
@@ -1443,8 +1488,9 @@ discard block |
||
1443 | 1488 | |
1444 | 1489 | foreach ($subActions as $sa => $action) |
1445 | 1490 | { |
1446 | - if (!allowedTo($action[2])) |
|
1447 | - unset($subActions[$sa]); |
|
1491 | + if (!allowedTo($action[2])) { |
|
1492 | + unset($subActions[$sa]); |
|
1493 | + } |
|
1448 | 1494 | } |
1449 | 1495 | |
1450 | 1496 | // Create the tabs for the template. |
@@ -1462,15 +1508,18 @@ discard block |
||
1462 | 1508 | ); |
1463 | 1509 | |
1464 | 1510 | // Moderation must be on to track edits. |
1465 | - if (empty($modSettings['userlog_enabled'])) |
|
1466 | - unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
1511 | + if (empty($modSettings['userlog_enabled'])) { |
|
1512 | + unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
1513 | + } |
|
1467 | 1514 | |
1468 | 1515 | // Group requests must be active to show it... |
1469 | - if (empty($modSettings['show_group_membership'])) |
|
1470 | - unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
1516 | + if (empty($modSettings['show_group_membership'])) { |
|
1517 | + unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
1518 | + } |
|
1471 | 1519 | |
1472 | - if (empty($subActions)) |
|
1473 | - fatal_lang_error('no_access', false); |
|
1520 | + if (empty($subActions)) { |
|
1521 | + fatal_lang_error('no_access', false); |
|
1522 | + } |
|
1474 | 1523 | |
1475 | 1524 | $keys = array_keys($subActions); |
1476 | 1525 | $default = array_shift($keys); |
@@ -1483,9 +1532,10 @@ discard block |
||
1483 | 1532 | $context['sub_template'] = $subActions[$context['tracking_area']][0]; |
1484 | 1533 | $call = call_helper($subActions[$context['tracking_area']][0], true); |
1485 | 1534 | |
1486 | - if (!empty($call)) |
|
1487 | - call_user_func($call, $memID); |
|
1488 | -} |
|
1535 | + if (!empty($call)) { |
|
1536 | + call_user_func($call, $memID); |
|
1537 | + } |
|
1538 | + } |
|
1489 | 1539 | |
1490 | 1540 | /** |
1491 | 1541 | * Handles tracking a user's activity |
@@ -1501,8 +1551,9 @@ discard block |
||
1501 | 1551 | isAllowedTo('moderate_forum'); |
1502 | 1552 | |
1503 | 1553 | $context['last_ip'] = $user_profile[$memID]['member_ip']; |
1504 | - if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) |
|
1505 | - $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
1554 | + if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) { |
|
1555 | + $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
1556 | + } |
|
1506 | 1557 | $context['member']['name'] = $user_profile[$memID]['real_name']; |
1507 | 1558 | |
1508 | 1559 | // Set the options for the list component. |
@@ -1668,8 +1719,9 @@ discard block |
||
1668 | 1719 | ) |
1669 | 1720 | ); |
1670 | 1721 | $message_members = array(); |
1671 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1672 | - $message_members[] = $row['id_member']; |
|
1722 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1723 | + $message_members[] = $row['id_member']; |
|
1724 | + } |
|
1673 | 1725 | $smcFunc['db_free_result']($request); |
1674 | 1726 | |
1675 | 1727 | // Fetch their names, cause of the GROUP BY doesn't like giving us that normally. |
@@ -1684,8 +1736,9 @@ discard block |
||
1684 | 1736 | 'ip_list' => $ips, |
1685 | 1737 | ) |
1686 | 1738 | ); |
1687 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1688 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1739 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1740 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1741 | + } |
|
1689 | 1742 | $smcFunc['db_free_result']($request); |
1690 | 1743 | } |
1691 | 1744 | |
@@ -1699,8 +1752,9 @@ discard block |
||
1699 | 1752 | 'ip_list' => $ips, |
1700 | 1753 | ) |
1701 | 1754 | ); |
1702 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1703 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1755 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1756 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1757 | + } |
|
1704 | 1758 | $smcFunc['db_free_result']($request); |
1705 | 1759 | } |
1706 | 1760 | } |
@@ -1760,8 +1814,8 @@ discard block |
||
1760 | 1814 | )) |
1761 | 1815 | ); |
1762 | 1816 | $error_messages = array(); |
1763 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1764 | - $error_messages[] = array( |
|
1817 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1818 | + $error_messages[] = array( |
|
1765 | 1819 | 'ip' => inet_dtop($row['ip']), |
1766 | 1820 | 'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'], |
1767 | 1821 | 'message' => strtr($row['message'], array('<span class="remove">' => '', '</span>' => '')), |
@@ -1769,6 +1823,7 @@ discard block |
||
1769 | 1823 | 'time' => timeformat($row['log_time']), |
1770 | 1824 | 'timestamp' => forum_time(true, $row['log_time']), |
1771 | 1825 | ); |
1826 | + } |
|
1772 | 1827 | $smcFunc['db_free_result']($request); |
1773 | 1828 | |
1774 | 1829 | return $error_messages; |
@@ -1831,8 +1886,8 @@ discard block |
||
1831 | 1886 | )) |
1832 | 1887 | ); |
1833 | 1888 | $messages = array(); |
1834 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1835 | - $messages[] = array( |
|
1889 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1890 | + $messages[] = array( |
|
1836 | 1891 | 'ip' => inet_dtop($row['poster_ip']), |
1837 | 1892 | 'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>', |
1838 | 1893 | 'board' => array( |
@@ -1845,6 +1900,7 @@ discard block |
||
1845 | 1900 | 'time' => timeformat($row['poster_time']), |
1846 | 1901 | 'timestamp' => forum_time(true, $row['poster_time']) |
1847 | 1902 | ); |
1903 | + } |
|
1848 | 1904 | $smcFunc['db_free_result']($request); |
1849 | 1905 | |
1850 | 1906 | return $messages; |
@@ -1871,19 +1927,20 @@ discard block |
||
1871 | 1927 | $context['sub_template'] = 'trackIP'; |
1872 | 1928 | $context['page_title'] = $txt['profile']; |
1873 | 1929 | $context['base_url'] = $scripturl . '?action=trackip'; |
1874 | - } |
|
1875 | - else |
|
1930 | + } else |
|
1876 | 1931 | { |
1877 | 1932 | $context['ip'] = $user_profile[$memID]['member_ip']; |
1878 | 1933 | $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
1879 | 1934 | } |
1880 | 1935 | |
1881 | 1936 | // Searching? |
1882 | - if (isset($_REQUEST['searchip'])) |
|
1883 | - $context['ip'] = trim($_REQUEST['searchip']); |
|
1937 | + if (isset($_REQUEST['searchip'])) { |
|
1938 | + $context['ip'] = trim($_REQUEST['searchip']); |
|
1939 | + } |
|
1884 | 1940 | |
1885 | - if (isValidIP($context['ip']) === false) |
|
1886 | - fatal_lang_error('invalid_tracking_ip', false); |
|
1941 | + if (isValidIP($context['ip']) === false) { |
|
1942 | + fatal_lang_error('invalid_tracking_ip', false); |
|
1943 | + } |
|
1887 | 1944 | |
1888 | 1945 | //mysql didn't support like search with varbinary |
1889 | 1946 | //$ip_var = str_replace('*', '%', $context['ip']); |
@@ -1891,8 +1948,9 @@ discard block |
||
1891 | 1948 | $ip_var = $context['ip']; |
1892 | 1949 | $ip_string = '= {inet:ip_address}'; |
1893 | 1950 | |
1894 | - if (empty($context['tracking_area'])) |
|
1895 | - $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
1951 | + if (empty($context['tracking_area'])) { |
|
1952 | + $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
1953 | + } |
|
1896 | 1954 | |
1897 | 1955 | $request = $smcFunc['db_query']('', ' |
1898 | 1956 | SELECT id_member, real_name AS display_name, member_ip |
@@ -1903,8 +1961,9 @@ discard block |
||
1903 | 1961 | ) |
1904 | 1962 | ); |
1905 | 1963 | $context['ips'] = array(); |
1906 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1907 | - $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
1964 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1965 | + $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
1966 | + } |
|
1908 | 1967 | $smcFunc['db_free_result']($request); |
1909 | 1968 | |
1910 | 1969 | ksort($context['ips']); |
@@ -2133,8 +2192,9 @@ discard block |
||
2133 | 2192 | foreach ($context['whois_servers'] as $whois) |
2134 | 2193 | { |
2135 | 2194 | // Strip off the "decimal point" and anything following... |
2136 | - if (in_array((int) $context['ip'], $whois['range'])) |
|
2137 | - $context['auto_whois_server'] = $whois; |
|
2195 | + if (in_array((int) $context['ip'], $whois['range'])) { |
|
2196 | + $context['auto_whois_server'] = $whois; |
|
2197 | + } |
|
2138 | 2198 | } |
2139 | 2199 | } |
2140 | 2200 | } |
@@ -2151,10 +2211,11 @@ discard block |
||
2151 | 2211 | // Gonna want this for the list. |
2152 | 2212 | require_once($sourcedir . '/Subs-List.php'); |
2153 | 2213 | |
2154 | - if ($memID == 0) |
|
2155 | - $context['base_url'] = $scripturl . '?action=trackip'; |
|
2156 | - else |
|
2157 | - $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
2214 | + if ($memID == 0) { |
|
2215 | + $context['base_url'] = $scripturl . '?action=trackip'; |
|
2216 | + } else { |
|
2217 | + $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
2218 | + } |
|
2158 | 2219 | |
2159 | 2220 | // Start with the user messages. |
2160 | 2221 | $listOptions = array( |
@@ -2264,12 +2325,13 @@ discard block |
||
2264 | 2325 | ) |
2265 | 2326 | ); |
2266 | 2327 | $logins = array(); |
2267 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2268 | - $logins[] = array( |
|
2328 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2329 | + $logins[] = array( |
|
2269 | 2330 | 'time' => timeformat($row['time']), |
2270 | 2331 | 'ip' => inet_dtop($row['ip']), |
2271 | 2332 | 'ip2' => inet_dtop($row['ip2']), |
2272 | 2333 | ); |
2334 | + } |
|
2273 | 2335 | $smcFunc['db_free_result']($request); |
2274 | 2336 | |
2275 | 2337 | return $logins; |
@@ -2294,11 +2356,12 @@ discard block |
||
2294 | 2356 | ) |
2295 | 2357 | ); |
2296 | 2358 | $context['custom_field_titles'] = array(); |
2297 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2298 | - $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
2359 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2360 | + $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
2299 | 2361 | 'title' => $row['field_name'], |
2300 | 2362 | 'parse_bbc' => $row['bbc'], |
2301 | 2363 | ); |
2364 | + } |
|
2302 | 2365 | $smcFunc['db_free_result']($request); |
2303 | 2366 | |
2304 | 2367 | // Set the options for the error lists. |
@@ -2437,19 +2500,22 @@ discard block |
||
2437 | 2500 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2438 | 2501 | { |
2439 | 2502 | $extra = $smcFunc['json_decode']($row['extra'], true); |
2440 | - if (!empty($extra['applicator'])) |
|
2441 | - $members[] = $extra['applicator']; |
|
2503 | + if (!empty($extra['applicator'])) { |
|
2504 | + $members[] = $extra['applicator']; |
|
2505 | + } |
|
2442 | 2506 | |
2443 | 2507 | // Work out what the name of the action is. |
2444 | - if (isset($txt['trackEdit_action_' . $row['action']])) |
|
2445 | - $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
2446 | - elseif (isset($txt[$row['action']])) |
|
2447 | - $action_text = $txt[$row['action']]; |
|
2508 | + if (isset($txt['trackEdit_action_' . $row['action']])) { |
|
2509 | + $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
2510 | + } elseif (isset($txt[$row['action']])) { |
|
2511 | + $action_text = $txt[$row['action']]; |
|
2512 | + } |
|
2448 | 2513 | // Custom field? |
2449 | - elseif (isset($context['custom_field_titles'][$row['action']])) |
|
2450 | - $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
2451 | - else |
|
2452 | - $action_text = $row['action']; |
|
2514 | + elseif (isset($context['custom_field_titles'][$row['action']])) { |
|
2515 | + $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
2516 | + } else { |
|
2517 | + $action_text = $row['action']; |
|
2518 | + } |
|
2453 | 2519 | |
2454 | 2520 | // Parse BBC? |
2455 | 2521 | $parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false; |
@@ -2481,13 +2547,15 @@ discard block |
||
2481 | 2547 | ) |
2482 | 2548 | ); |
2483 | 2549 | $members = array(); |
2484 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2485 | - $members[$row['id_member']] = $row['real_name']; |
|
2550 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2551 | + $members[$row['id_member']] = $row['real_name']; |
|
2552 | + } |
|
2486 | 2553 | $smcFunc['db_free_result']($request); |
2487 | 2554 | |
2488 | - foreach ($edits as $key => $value) |
|
2489 | - if (isset($members[$value['id_member']])) |
|
2555 | + foreach ($edits as $key => $value) { |
|
2556 | + if (isset($members[$value['id_member']])) |
|
2490 | 2557 | $edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>'; |
2558 | + } |
|
2491 | 2559 | } |
2492 | 2560 | |
2493 | 2561 | return $edits; |
@@ -2688,10 +2756,11 @@ discard block |
||
2688 | 2756 | $context['board'] = $board; |
2689 | 2757 | |
2690 | 2758 | // Determine which groups this user is in. |
2691 | - if (empty($user_profile[$memID]['additional_groups'])) |
|
2692 | - $curGroups = array(); |
|
2693 | - else |
|
2694 | - $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
2759 | + if (empty($user_profile[$memID]['additional_groups'])) { |
|
2760 | + $curGroups = array(); |
|
2761 | + } else { |
|
2762 | + $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
2763 | + } |
|
2695 | 2764 | $curGroups[] = $user_profile[$memID]['id_group']; |
2696 | 2765 | $curGroups[] = $user_profile[$memID]['id_post_group']; |
2697 | 2766 | |
@@ -2711,28 +2780,30 @@ discard block |
||
2711 | 2780 | $context['no_access_boards'] = array(); |
2712 | 2781 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2713 | 2782 | { |
2714 | - if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) |
|
2715 | - $context['no_access_boards'][] = array( |
|
2783 | + if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) { |
|
2784 | + $context['no_access_boards'][] = array( |
|
2716 | 2785 | 'id' => $row['id_board'], |
2717 | 2786 | 'name' => $row['name'], |
2718 | 2787 | 'is_last' => false, |
2719 | 2788 | ); |
2720 | - elseif ($row['id_profile'] != 1 || $row['is_mod']) |
|
2721 | - $context['boards'][$row['id_board']] = array( |
|
2789 | + } elseif ($row['id_profile'] != 1 || $row['is_mod']) { |
|
2790 | + $context['boards'][$row['id_board']] = array( |
|
2722 | 2791 | 'id' => $row['id_board'], |
2723 | 2792 | 'name' => $row['name'], |
2724 | 2793 | 'selected' => $board == $row['id_board'], |
2725 | 2794 | 'profile' => $row['id_profile'], |
2726 | 2795 | 'profile_name' => $context['profiles'][$row['id_profile']]['name'], |
2727 | 2796 | ); |
2797 | + } |
|
2728 | 2798 | } |
2729 | 2799 | $smcFunc['db_free_result']($request); |
2730 | 2800 | |
2731 | 2801 | require_once($sourcedir . '/Subs-Boards.php'); |
2732 | 2802 | sortBoards($context['boards']); |
2733 | 2803 | |
2734 | - if (!empty($context['no_access_boards'])) |
|
2735 | - $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
2804 | + if (!empty($context['no_access_boards'])) { |
|
2805 | + $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
2806 | + } |
|
2736 | 2807 | |
2737 | 2808 | $context['member']['permissions'] = array( |
2738 | 2809 | 'general' => array(), |
@@ -2741,8 +2812,9 @@ discard block |
||
2741 | 2812 | |
2742 | 2813 | // If you're an admin we know you can do everything, we might as well leave. |
2743 | 2814 | $context['member']['has_all_permissions'] = in_array(1, $curGroups); |
2744 | - if ($context['member']['has_all_permissions']) |
|
2745 | - return; |
|
2815 | + if ($context['member']['has_all_permissions']) { |
|
2816 | + return; |
|
2817 | + } |
|
2746 | 2818 | |
2747 | 2819 | $denied = array(); |
2748 | 2820 | |
@@ -2761,21 +2833,24 @@ discard block |
||
2761 | 2833 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2762 | 2834 | { |
2763 | 2835 | // We don't know about this permission, it doesn't exist :P. |
2764 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
2765 | - continue; |
|
2836 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
2837 | + continue; |
|
2838 | + } |
|
2766 | 2839 | |
2767 | - if (empty($row['add_deny'])) |
|
2768 | - $denied[] = $row['permission']; |
|
2840 | + if (empty($row['add_deny'])) { |
|
2841 | + $denied[] = $row['permission']; |
|
2842 | + } |
|
2769 | 2843 | |
2770 | 2844 | // Permissions that end with _own or _any consist of two parts. |
2771 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
2772 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2773 | - else |
|
2774 | - $name = $txt['permissionname_' . $row['permission']]; |
|
2845 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
2846 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2847 | + } else { |
|
2848 | + $name = $txt['permissionname_' . $row['permission']]; |
|
2849 | + } |
|
2775 | 2850 | |
2776 | 2851 | // Add this permission if it doesn't exist yet. |
2777 | - if (!isset($context['member']['permissions']['general'][$row['permission']])) |
|
2778 | - $context['member']['permissions']['general'][$row['permission']] = array( |
|
2852 | + if (!isset($context['member']['permissions']['general'][$row['permission']])) { |
|
2853 | + $context['member']['permissions']['general'][$row['permission']] = array( |
|
2779 | 2854 | 'id' => $row['permission'], |
2780 | 2855 | 'groups' => array( |
2781 | 2856 | 'allowed' => array(), |
@@ -2785,6 +2860,7 @@ discard block |
||
2785 | 2860 | 'is_denied' => false, |
2786 | 2861 | 'is_global' => true, |
2787 | 2862 | ); |
2863 | + } |
|
2788 | 2864 | |
2789 | 2865 | // Add the membergroup to either the denied or the allowed groups. |
2790 | 2866 | $context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
@@ -2818,18 +2894,20 @@ discard block |
||
2818 | 2894 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2819 | 2895 | { |
2820 | 2896 | // We don't know about this permission, it doesn't exist :P. |
2821 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
2822 | - continue; |
|
2897 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
2898 | + continue; |
|
2899 | + } |
|
2823 | 2900 | |
2824 | 2901 | // The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'. |
2825 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
2826 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2827 | - else |
|
2828 | - $name = $txt['permissionname_' . $row['permission']]; |
|
2902 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
2903 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2904 | + } else { |
|
2905 | + $name = $txt['permissionname_' . $row['permission']]; |
|
2906 | + } |
|
2829 | 2907 | |
2830 | 2908 | // Create the structure for this permission. |
2831 | - if (!isset($context['member']['permissions']['board'][$row['permission']])) |
|
2832 | - $context['member']['permissions']['board'][$row['permission']] = array( |
|
2909 | + if (!isset($context['member']['permissions']['board'][$row['permission']])) { |
|
2910 | + $context['member']['permissions']['board'][$row['permission']] = array( |
|
2833 | 2911 | 'id' => $row['permission'], |
2834 | 2912 | 'groups' => array( |
2835 | 2913 | 'allowed' => array(), |
@@ -2839,6 +2917,7 @@ discard block |
||
2839 | 2917 | 'is_denied' => false, |
2840 | 2918 | 'is_global' => empty($board), |
2841 | 2919 | ); |
2920 | + } |
|
2842 | 2921 | |
2843 | 2922 | $context['member']['permissions']['board'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][$row['id_group']] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
2844 | 2923 | |
@@ -2857,8 +2936,9 @@ discard block |
||
2857 | 2936 | global $modSettings, $context, $sourcedir, $txt, $scripturl; |
2858 | 2937 | |
2859 | 2938 | // Firstly, can we actually even be here? |
2860 | - if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) |
|
2861 | - fatal_lang_error('no_access', false); |
|
2939 | + if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) { |
|
2940 | + fatal_lang_error('no_access', false); |
|
2941 | + } |
|
2862 | 2942 | |
2863 | 2943 | // Make sure things which are disabled stay disabled. |
2864 | 2944 | $modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110; |
@@ -2945,9 +3025,10 @@ discard block |
||
2945 | 3025 | $modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'], |
2946 | 3026 | ); |
2947 | 3027 | $context['current_level'] = 0; |
2948 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
2949 | - if ($context['member']['warning'] >= $limit) |
|
3028 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
3029 | + if ($context['member']['warning'] >= $limit) |
|
2950 | 3030 | $context['current_level'] = $limit; |
2951 | -} |
|
3031 | + } |
|
3032 | + } |
|
2952 | 3033 | |
2953 | 3034 | ?> |
2954 | 3035 | \ No newline at end of file |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
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. |
@@ -29,18 +30,21 @@ discard block |
||
29 | 30 | global $modSettings, $memberContext, $profile_vars, $post_errors, $smcFunc; |
30 | 31 | |
31 | 32 | // Don't reload this as we may have processed error strings. |
32 | - if (empty($post_errors)) |
|
33 | - loadLanguage('Profile+Drafts'); |
|
33 | + if (empty($post_errors)) { |
|
34 | + loadLanguage('Profile+Drafts'); |
|
35 | + } |
|
34 | 36 | loadTemplate('Profile'); |
35 | 37 | |
36 | 38 | require_once($sourcedir . '/Subs-Menu.php'); |
37 | 39 | |
38 | 40 | // Did we get the user by name... |
39 | - if (isset($_REQUEST['user'])) |
|
40 | - $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
41 | + if (isset($_REQUEST['user'])) { |
|
42 | + $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
43 | + } |
|
41 | 44 | // ... or by id_member? |
42 | - elseif (!empty($_REQUEST['u'])) |
|
43 | - $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
45 | + elseif (!empty($_REQUEST['u'])) { |
|
46 | + $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
47 | + } |
|
44 | 48 | // If it was just ?action=profile, edit your own profile, but only if you're not a guest. |
45 | 49 | else |
46 | 50 | { |
@@ -50,8 +54,9 @@ discard block |
||
50 | 54 | } |
51 | 55 | |
52 | 56 | // Check if loadMemberData() has returned a valid result. |
53 | - if (!$memberResult) |
|
54 | - fatal_lang_error('not_a_user', false, 404); |
|
57 | + if (!$memberResult) { |
|
58 | + fatal_lang_error('not_a_user', false, 404); |
|
59 | + } |
|
55 | 60 | |
56 | 61 | // If all went well, we have a valid member ID! |
57 | 62 | list ($memID) = $memberResult; |
@@ -67,8 +72,9 @@ discard block |
||
67 | 72 | |
68 | 73 | // Group management isn't actually a permission. But we need it to be for this, so we need a phantom permission. |
69 | 74 | // And we care about what the current user can do, not what the user whose profile it is. |
70 | - if ($user_info['mod_cache']['gq'] != '0=1') |
|
71 | - $user_info['permissions'][] = 'approve_group_requests'; |
|
75 | + if ($user_info['mod_cache']['gq'] != '0=1') { |
|
76 | + $user_info['permissions'][] = 'approve_group_requests'; |
|
77 | + } |
|
72 | 78 | |
73 | 79 | // If paid subscriptions are enabled, make sure we actually have at least one subscription available... |
74 | 80 | $context['subs_available'] = false; |
@@ -436,21 +442,25 @@ discard block |
||
436 | 442 | foreach ($section['areas'] as $area_id => $area) |
437 | 443 | { |
438 | 444 | // If it said no permissions that meant it wasn't valid! |
439 | - if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) |
|
440 | - $profile_areas[$section_id]['areas'][$area_id]['enabled'] = false; |
|
445 | + if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) { |
|
446 | + $profile_areas[$section_id]['areas'][$area_id]['enabled'] = false; |
|
447 | + } |
|
441 | 448 | // Otherwise pick the right set. |
442 | - else |
|
443 | - $profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any']; |
|
449 | + else { |
|
450 | + $profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any']; |
|
451 | + } |
|
444 | 452 | |
445 | 453 | // Password required in most cases |
446 | - if (!empty($area['password'])) |
|
447 | - $context['password_areas'][] = $area_id; |
|
454 | + if (!empty($area['password'])) { |
|
455 | + $context['password_areas'][] = $area_id; |
|
456 | + } |
|
448 | 457 | } |
449 | 458 | } |
450 | 459 | |
451 | 460 | // Is there an updated message to show? |
452 | - if (isset($_GET['updated'])) |
|
453 | - $context['profile_updated'] = $txt['profile_updated_own']; |
|
461 | + if (isset($_GET['updated'])) { |
|
462 | + $context['profile_updated'] = $txt['profile_updated_own']; |
|
463 | + } |
|
454 | 464 | |
455 | 465 | // Set a few options for the menu. |
456 | 466 | $menuOptions = array( |
@@ -465,8 +475,9 @@ discard block |
||
465 | 475 | $profile_include_data = createMenu($profile_areas, $menuOptions); |
466 | 476 | |
467 | 477 | // No menu means no access. |
468 | - if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) |
|
469 | - fatal_lang_error('no_access', false); |
|
478 | + if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) { |
|
479 | + fatal_lang_error('no_access', false); |
|
480 | + } |
|
470 | 481 | |
471 | 482 | // Make a note of the Unique ID for this menu. |
472 | 483 | $context['profile_menu_id'] = $context['max_menu_id']; |
@@ -492,8 +503,9 @@ discard block |
||
492 | 503 | if ($current_area == $area_id) |
493 | 504 | { |
494 | 505 | // This can't happen - but is a security check. |
495 | - if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) |
|
496 | - fatal_lang_error('no_access', false); |
|
506 | + if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) { |
|
507 | + fatal_lang_error('no_access', false); |
|
508 | + } |
|
497 | 509 | |
498 | 510 | // Are we saving data in a valid area? |
499 | 511 | if (isset($area['sc']) && (isset($_REQUEST['save']) || $context['do_preview'])) |
@@ -512,12 +524,14 @@ discard block |
||
512 | 524 | } |
513 | 525 | |
514 | 526 | // Does this require session validating? |
515 | - if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) |
|
516 | - $security_checks['validate'] = true; |
|
527 | + if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) { |
|
528 | + $security_checks['validate'] = true; |
|
529 | + } |
|
517 | 530 | |
518 | 531 | // Permissions for good measure. |
519 | - if (!empty($profile_include_data['permission'])) |
|
520 | - $security_checks['permission'] = $profile_include_data['permission']; |
|
532 | + if (!empty($profile_include_data['permission'])) { |
|
533 | + $security_checks['permission'] = $profile_include_data['permission']; |
|
534 | + } |
|
521 | 535 | |
522 | 536 | // Either way got something. |
523 | 537 | $found_area = true; |
@@ -526,21 +540,26 @@ discard block |
||
526 | 540 | } |
527 | 541 | |
528 | 542 | // Oh dear, some serious security lapse is going on here... we'll put a stop to that! |
529 | - if (!$found_area) |
|
530 | - fatal_lang_error('no_access', false); |
|
543 | + if (!$found_area) { |
|
544 | + fatal_lang_error('no_access', false); |
|
545 | + } |
|
531 | 546 | |
532 | 547 | // Release this now. |
533 | 548 | unset($profile_areas); |
534 | 549 | |
535 | 550 | // Now the context is setup have we got any security checks to carry out additional to that above? |
536 | - if (isset($security_checks['session'])) |
|
537 | - checkSession($security_checks['session']); |
|
538 | - if (isset($security_checks['validate'])) |
|
539 | - validateSession(); |
|
540 | - if (isset($security_checks['validateToken'])) |
|
541 | - validateToken($token_name, $token_type); |
|
542 | - if (isset($security_checks['permission'])) |
|
543 | - isAllowedTo($security_checks['permission']); |
|
551 | + if (isset($security_checks['session'])) { |
|
552 | + checkSession($security_checks['session']); |
|
553 | + } |
|
554 | + if (isset($security_checks['validate'])) { |
|
555 | + validateSession(); |
|
556 | + } |
|
557 | + if (isset($security_checks['validateToken'])) { |
|
558 | + validateToken($token_name, $token_type); |
|
559 | + } |
|
560 | + if (isset($security_checks['permission'])) { |
|
561 | + isAllowedTo($security_checks['permission']); |
|
562 | + } |
|
544 | 563 | |
545 | 564 | // Create a token if needed. |
546 | 565 | if (isset($security_checks['needsToken']) || isset($security_checks['validateToken'])) |
@@ -550,8 +569,9 @@ discard block |
||
550 | 569 | } |
551 | 570 | |
552 | 571 | // File to include? |
553 | - if (isset($profile_include_data['file'])) |
|
554 | - require_once($sourcedir . '/' . $profile_include_data['file']); |
|
572 | + if (isset($profile_include_data['file'])) { |
|
573 | + require_once($sourcedir . '/' . $profile_include_data['file']); |
|
574 | + } |
|
555 | 575 | |
556 | 576 | // Build the link tree. |
557 | 577 | $context['linktree'][] = array( |
@@ -559,17 +579,19 @@ discard block |
||
559 | 579 | 'name' => sprintf($txt['profile_of_username'], $context['member']['name']), |
560 | 580 | ); |
561 | 581 | |
562 | - if (!empty($profile_include_data['label'])) |
|
563 | - $context['linktree'][] = array( |
|
582 | + if (!empty($profile_include_data['label'])) { |
|
583 | + $context['linktree'][] = array( |
|
564 | 584 | 'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'], |
565 | 585 | 'name' => $profile_include_data['label'], |
566 | 586 | ); |
587 | + } |
|
567 | 588 | |
568 | - if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) |
|
569 | - $context['linktree'][] = array( |
|
589 | + if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) { |
|
590 | + $context['linktree'][] = array( |
|
570 | 591 | 'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'] . ';sa=' . $profile_include_data['current_subsection'], |
571 | 592 | 'name' => $profile_include_data['subsections'][$profile_include_data['current_subsection']][0], |
572 | 593 | ); |
594 | + } |
|
573 | 595 | |
574 | 596 | // Set the template for this area and add the profile layer. |
575 | 597 | $context['sub_template'] = $profile_include_data['function']; |
@@ -595,12 +617,14 @@ discard block |
||
595 | 617 | if ($check_password) |
596 | 618 | { |
597 | 619 | // Check to ensure we're forcing SSL for authentication |
598 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
599 | - fatal_lang_error('login_ssl_required'); |
|
620 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
621 | + fatal_lang_error('login_ssl_required'); |
|
622 | + } |
|
600 | 623 | |
601 | 624 | // You didn't even enter a password! |
602 | - if (trim($_POST['oldpasswrd']) == '') |
|
603 | - $post_errors[] = 'no_password'; |
|
625 | + if (trim($_POST['oldpasswrd']) == '') { |
|
626 | + $post_errors[] = 'no_password'; |
|
627 | + } |
|
604 | 628 | |
605 | 629 | // Since the password got modified due to all the $_POST cleaning, lets undo it so we can get the correct password |
606 | 630 | $_POST['oldpasswrd'] = un_htmlspecialchars($_POST['oldpasswrd']); |
@@ -609,42 +633,43 @@ discard block |
||
609 | 633 | $good_password = in_array(true, call_integration_hook('integrate_verify_password', array($cur_profile['member_name'], $_POST['oldpasswrd'], false)), true); |
610 | 634 | |
611 | 635 | // Bad password!!! |
612 | - if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) |
|
613 | - $post_errors[] = 'bad_password'; |
|
636 | + if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) { |
|
637 | + $post_errors[] = 'bad_password'; |
|
638 | + } |
|
614 | 639 | |
615 | 640 | // Warn other elements not to jump the gun and do custom changes! |
616 | - if (in_array('bad_password', $post_errors)) |
|
617 | - $context['password_auth_failed'] = true; |
|
641 | + if (in_array('bad_password', $post_errors)) { |
|
642 | + $context['password_auth_failed'] = true; |
|
643 | + } |
|
618 | 644 | } |
619 | 645 | |
620 | 646 | // Change the IP address in the database. |
621 | - if ($context['user']['is_owner']) |
|
622 | - $profile_vars['member_ip'] = $user_info['ip']; |
|
647 | + if ($context['user']['is_owner']) { |
|
648 | + $profile_vars['member_ip'] = $user_info['ip']; |
|
649 | + } |
|
623 | 650 | |
624 | 651 | // Now call the sub-action function... |
625 | 652 | if ($current_area == 'activateaccount') |
626 | 653 | { |
627 | - if (empty($post_errors)) |
|
628 | - activateAccount($memID); |
|
629 | - } |
|
630 | - elseif ($current_area == 'deleteaccount') |
|
654 | + if (empty($post_errors)) { |
|
655 | + activateAccount($memID); |
|
656 | + } |
|
657 | + } elseif ($current_area == 'deleteaccount') |
|
631 | 658 | { |
632 | 659 | if (empty($post_errors)) |
633 | 660 | { |
634 | 661 | deleteAccount2($memID); |
635 | 662 | redirectexit(); |
636 | 663 | } |
637 | - } |
|
638 | - elseif ($current_area == 'groupmembership' && empty($post_errors)) |
|
664 | + } elseif ($current_area == 'groupmembership' && empty($post_errors)) |
|
639 | 665 | { |
640 | 666 | $msg = groupMembership2($profile_vars, $post_errors, $memID); |
641 | 667 | |
642 | 668 | // Whatever we've done, we have nothing else to do here... |
643 | 669 | redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=groupmembership' . (!empty($msg) ? ';msg=' . $msg : '')); |
644 | - } |
|
645 | - elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) |
|
646 | - saveProfileFields(); |
|
647 | - else |
|
670 | + } elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) { |
|
671 | + saveProfileFields(); |
|
672 | + } else |
|
648 | 673 | { |
649 | 674 | $force_redirect = true; |
650 | 675 | // Ensure we include this. |
@@ -660,34 +685,36 @@ discard block |
||
660 | 685 | // Load the language file so we can give a nice explanation of the errors. |
661 | 686 | loadLanguage('Errors'); |
662 | 687 | $context['post_errors'] = $post_errors; |
663 | - } |
|
664 | - elseif (!empty($profile_vars)) |
|
688 | + } elseif (!empty($profile_vars)) |
|
665 | 689 | { |
666 | 690 | // If we've changed the password, notify any integration that may be listening in. |
667 | - if (isset($profile_vars['passwd'])) |
|
668 | - call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2'])); |
|
691 | + if (isset($profile_vars['passwd'])) { |
|
692 | + call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2'])); |
|
693 | + } |
|
669 | 694 | |
670 | 695 | updateMemberData($memID, $profile_vars); |
671 | 696 | |
672 | 697 | // What if this is the newest member? |
673 | - if ($modSettings['latestMember'] == $memID) |
|
674 | - updateStats('member'); |
|
675 | - elseif (isset($profile_vars['real_name'])) |
|
676 | - updateSettings(array('memberlist_updated' => time())); |
|
698 | + if ($modSettings['latestMember'] == $memID) { |
|
699 | + updateStats('member'); |
|
700 | + } elseif (isset($profile_vars['real_name'])) { |
|
701 | + updateSettings(array('memberlist_updated' => time())); |
|
702 | + } |
|
677 | 703 | |
678 | 704 | // If the member changed his/her birthdate, update calendar statistics. |
679 | - if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) |
|
680 | - updateSettings(array( |
|
705 | + if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) { |
|
706 | + updateSettings(array( |
|
681 | 707 | 'calendar_updated' => time(), |
682 | 708 | )); |
709 | + } |
|
683 | 710 | |
684 | 711 | // Anything worth logging? |
685 | 712 | if (!empty($context['log_changes']) && !empty($modSettings['modlog_enabled'])) |
686 | 713 | { |
687 | 714 | $log_changes = array(); |
688 | 715 | require_once($sourcedir . '/Logging.php'); |
689 | - foreach ($context['log_changes'] as $k => $v) |
|
690 | - $log_changes[] = array( |
|
716 | + foreach ($context['log_changes'] as $k => $v) { |
|
717 | + $log_changes[] = array( |
|
691 | 718 | 'action' => $k, |
692 | 719 | 'log_type' => 'user', |
693 | 720 | 'extra' => array_merge($v, array( |
@@ -695,14 +722,16 @@ discard block |
||
695 | 722 | 'member_affected' => $memID, |
696 | 723 | )), |
697 | 724 | ); |
725 | + } |
|
698 | 726 | |
699 | 727 | logActions($log_changes); |
700 | 728 | } |
701 | 729 | |
702 | 730 | // Have we got any post save functions to execute? |
703 | - if (!empty($context['profile_execute_on_save'])) |
|
704 | - foreach ($context['profile_execute_on_save'] as $saveFunc) |
|
731 | + if (!empty($context['profile_execute_on_save'])) { |
|
732 | + foreach ($context['profile_execute_on_save'] as $saveFunc) |
|
705 | 733 | $saveFunc(); |
734 | + } |
|
706 | 735 | |
707 | 736 | // Let them know it worked! |
708 | 737 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $cur_profile['member_name']); |
@@ -716,27 +745,31 @@ discard block |
||
716 | 745 | if (!empty($post_errors)) |
717 | 746 | { |
718 | 747 | // Set all the errors so the template knows what went wrong. |
719 | - foreach ($post_errors as $error_type) |
|
720 | - $context['modify_error'][$error_type] = true; |
|
748 | + foreach ($post_errors as $error_type) { |
|
749 | + $context['modify_error'][$error_type] = true; |
|
750 | + } |
|
721 | 751 | } |
722 | 752 | // If it's you then we should redirect upon save. |
723 | - elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) |
|
724 | - redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated'); |
|
725 | - elseif (!empty($force_redirect)) |
|
726 | - redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area); |
|
753 | + elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) { |
|
754 | + redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated'); |
|
755 | + } elseif (!empty($force_redirect)) { |
|
756 | + redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area); |
|
757 | + } |
|
727 | 758 | |
728 | 759 | |
729 | 760 | // Get the right callable. |
730 | 761 | $call = call_helper($profile_include_data['function'], true); |
731 | 762 | |
732 | 763 | // Is it valid? |
733 | - if (!empty($call)) |
|
734 | - call_user_func($call, $memID); |
|
764 | + if (!empty($call)) { |
|
765 | + call_user_func($call, $memID); |
|
766 | + } |
|
735 | 767 | |
736 | 768 | // Set the page title if it's not already set... |
737 | - if (!isset($context['page_title'])) |
|
738 | - $context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : ''); |
|
739 | -} |
|
769 | + if (!isset($context['page_title'])) { |
|
770 | + $context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : ''); |
|
771 | + } |
|
772 | + } |
|
740 | 773 | |
741 | 774 | /** |
742 | 775 | * Set up the requirements for the profile popup - the area that is shown as the popup menu for the current user. |
@@ -859,16 +892,18 @@ discard block |
||
859 | 892 | if (!allowedTo('admin_forum') && $area != 'register') |
860 | 893 | { |
861 | 894 | // If it's the owner they can see two types of private fields, regardless. |
862 | - if ($memID == $user_info['id']) |
|
863 | - $where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
864 | - else |
|
865 | - $where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
895 | + if ($memID == $user_info['id']) { |
|
896 | + $where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
897 | + } else { |
|
898 | + $where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
899 | + } |
|
866 | 900 | } |
867 | 901 | |
868 | - if ($area == 'register') |
|
869 | - $where .= ' AND show_reg != 0'; |
|
870 | - elseif ($area != 'summary') |
|
871 | - $where .= ' AND show_profile = {string:area}'; |
|
902 | + if ($area == 'register') { |
|
903 | + $where .= ' AND show_reg != 0'; |
|
904 | + } elseif ($area != 'summary') { |
|
905 | + $where .= ' AND show_profile = {string:area}'; |
|
906 | + } |
|
872 | 907 | |
873 | 908 | // Load all the relevant fields - and data. |
874 | 909 | $request = $smcFunc['db_query']('', ' |
@@ -894,13 +929,15 @@ discard block |
||
894 | 929 | if (isset($_POST['customfield']) && isset($_POST['customfield'][$row['col_name']])) |
895 | 930 | { |
896 | 931 | $value = $smcFunc['htmlspecialchars']($_POST['customfield'][$row['col_name']]); |
897 | - if (in_array($row['field_type'], array('select', 'radio'))) |
|
898 | - $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
932 | + if (in_array($row['field_type'], array('select', 'radio'))) { |
|
933 | + $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
934 | + } |
|
899 | 935 | } |
900 | 936 | |
901 | 937 | // Don't show the "disabled" option for the "gender" field if we are on the "summary" area. |
902 | - if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'Disabled') |
|
903 | - continue; |
|
938 | + if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'Disabled') { |
|
939 | + continue; |
|
940 | + } |
|
904 | 941 | |
905 | 942 | // HTML for the input form. |
906 | 943 | $output_html = $value; |
@@ -909,8 +946,7 @@ discard block |
||
909 | 946 | $true = (!$exists && $row['default_value']) || $value; |
910 | 947 | $input_html = '<input type="checkbox" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($true ? ' checked' : '') . '>'; |
911 | 948 | $output_html = $true ? $txt['yes'] : $txt['no']; |
912 | - } |
|
913 | - elseif ($row['field_type'] == 'select') |
|
949 | + } elseif ($row['field_type'] == 'select') |
|
914 | 950 | { |
915 | 951 | $input_html = '<select name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"><option value="-1"></option>'; |
916 | 952 | $options = explode(',', $row['field_options']); |
@@ -918,13 +954,13 @@ discard block |
||
918 | 954 | { |
919 | 955 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
920 | 956 | $input_html .= '<option value="' . $k . '"' . ($true ? ' selected' : '') . '>' . $v . '</option>'; |
921 | - if ($true) |
|
922 | - $output_html = $v; |
|
957 | + if ($true) { |
|
958 | + $output_html = $v; |
|
959 | + } |
|
923 | 960 | } |
924 | 961 | |
925 | 962 | $input_html .= '</select>'; |
926 | - } |
|
927 | - elseif ($row['field_type'] == 'radio') |
|
963 | + } elseif ($row['field_type'] == 'radio') |
|
928 | 964 | { |
929 | 965 | $input_html = '<fieldset>'; |
930 | 966 | $options = explode(',', $row['field_options']); |
@@ -932,36 +968,37 @@ discard block |
||
932 | 968 | { |
933 | 969 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
934 | 970 | $input_html .= '<label for="customfield_' . $row['col_name'] . '_' . $k . '"><input type="radio" name="customfield[' . $row['col_name'] . ']" id="customfield_' . $row['col_name'] . '_' . $k . '" value="' . $k . '"' . ($true ? ' checked' : '') . '>' . $v . '</label><br>'; |
935 | - if ($true) |
|
936 | - $output_html = $v; |
|
971 | + if ($true) { |
|
972 | + $output_html = $v; |
|
973 | + } |
|
937 | 974 | } |
938 | 975 | $input_html .= '</fieldset>'; |
939 | - } |
|
940 | - elseif ($row['field_type'] == 'text') |
|
976 | + } elseif ($row['field_type'] == 'text') |
|
941 | 977 | { |
942 | 978 | $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) . '"' . ($row['show_reg'] == 2 ? ' required' : '') . '>'; |
943 | - } |
|
944 | - else |
|
979 | + } else |
|
945 | 980 | { |
946 | 981 | @list ($rows, $cols) = @explode(',', $row['default_value']); |
947 | 982 | $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>'; |
948 | 983 | } |
949 | 984 | |
950 | 985 | // Parse BBCode |
951 | - if ($row['bbc']) |
|
952 | - $output_html = parse_bbc($output_html); |
|
953 | - elseif ($row['field_type'] == 'textarea') |
|
954 | - // Allow for newlines at least |
|
986 | + if ($row['bbc']) { |
|
987 | + $output_html = parse_bbc($output_html); |
|
988 | + } elseif ($row['field_type'] == 'textarea') { |
|
989 | + // Allow for newlines at least |
|
955 | 990 | $output_html = strtr($output_html, array("\n" => '<br>')); |
991 | + } |
|
956 | 992 | |
957 | 993 | // Enclosing the user input within some other text? |
958 | - if (!empty($row['enclose']) && !empty($output_html)) |
|
959 | - $output_html = strtr($row['enclose'], array( |
|
994 | + if (!empty($row['enclose']) && !empty($output_html)) { |
|
995 | + $output_html = strtr($row['enclose'], array( |
|
960 | 996 | '{SCRIPTURL}' => $scripturl, |
961 | 997 | '{IMAGES_URL}' => $settings['images_url'], |
962 | 998 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
963 | 999 | '{INPUT}' => un_htmlspecialchars($output_html), |
964 | 1000 | )); |
1001 | + } |
|
965 | 1002 | |
966 | 1003 | $context['custom_fields'][] = array( |
967 | 1004 | 'name' => $row['field_name'], |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | { |
24 | 24 | global $context, $txt; |
25 | 25 | |
26 | - if (!empty($context['simple_action'])) |
|
27 | - echo ' |
|
26 | + if (!empty($context['simple_action'])) { |
|
27 | + echo ' |
|
28 | 28 | <strong> |
29 | 29 | ', $context['error_title'], ' |
30 | 30 | </strong><br> |
31 | 31 | <div ', $context['error_code'], 'class="padding">', $context['error_message'], '</div>'; |
32 | - else |
|
32 | + } else |
|
33 | 33 | { |
34 | 34 | echo ' |
35 | 35 | <div id="fatal_error"> |
@@ -82,21 +82,23 @@ discard block |
||
82 | 82 | ', $txt['apply_filter_of_type'], ':'; |
83 | 83 | |
84 | 84 | $error_types = array(); |
85 | - foreach ($context['error_types'] as $type => $details) |
|
86 | - $error_types[] = ($details['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.png" alt=""> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : '') . ' title="' . $details['description'] . '">' . $details['label'] . '</a>'; |
|
85 | + foreach ($context['error_types'] as $type => $details) { |
|
86 | + $error_types[] = ($details['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.png" alt=""> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : '') . ' title="' . $details['description'] . '">' . $details['label'] . '</a>'; |
|
87 | + } |
|
87 | 88 | |
88 | 89 | echo ' |
89 | 90 | ', implode(' | ', $error_types), ' |
90 | 91 | </td> |
91 | 92 | </tr>'; |
92 | 93 | |
93 | - if ($context['has_filter']) |
|
94 | - echo ' |
|
94 | + if ($context['has_filter']) { |
|
95 | + echo ' |
|
95 | 96 | <tr> |
96 | 97 | <td colspan="3" class="windowbg"> |
97 | 98 | <strong> ', $txt['applying_filter'], ':</strong> ', $context['filter']['entity'], ' ', $context['filter']['value']['html'], ' [<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', '">', $txt['clear_filter'], '</a>] |
98 | 99 | </td> |
99 | 100 | </tr>'; |
101 | + } |
|
100 | 102 | |
101 | 103 | echo ' |
102 | 104 | <tr> |
@@ -107,11 +109,12 @@ discard block |
||
107 | 109 | </tr>'; |
108 | 110 | |
109 | 111 | // No errors, then show a message |
110 | - if (count($context['errors']) == 0) |
|
111 | - echo ' |
|
112 | + if (count($context['errors']) == 0) { |
|
113 | + echo ' |
|
112 | 114 | <tr class="windowbg"> |
113 | 115 | <td class="centertext" colspan="2">', $txt['errlog_no_entries'], '</td> |
114 | 116 | </tr>'; |
117 | + } |
|
115 | 118 | |
116 | 119 | // we have some errors, must be some mods installed :P |
117 | 120 | foreach ($context['errors'] as $error) |
@@ -125,19 +128,21 @@ discard block |
||
125 | 128 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? '' : ';desc', $context['has_filter'] ? $context['filter']['href'] : '', '" title="', $txt['reverse_direction'], '"><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></a> |
126 | 129 | ', $error['time'], '<br>'; |
127 | 130 | |
128 | - if (!empty($error['member']['ip'])) |
|
129 | - echo ' |
|
131 | + if (!empty($error['member']['ip'])) { |
|
132 | + echo ' |
|
130 | 133 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=ip;value=', $error['member']['ip'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_ip'], '"><span class="generic_icons filter centericon"></span></a> |
131 | 134 | <strong><a href="', $scripturl, '?action=trackip;searchip=', $error['member']['ip'], '">', $error['member']['ip'], '</a></strong> <br>'; |
135 | + } |
|
132 | 136 | |
133 | 137 | echo ' |
134 | 138 | </div> |
135 | 139 | <div style="float: left; width: 50%; line-height: 1.8em; padding: 0 4px;">'; |
136 | 140 | |
137 | - if ($error['member']['session'] != '') |
|
138 | - echo ' |
|
141 | + if ($error['member']['session'] != '') { |
|
142 | + echo ' |
|
139 | 143 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=session;value=', $error['member']['session'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_session'], '"><span class="generic_icons filter centericon"></span></a> |
140 | 144 | ', $error['member']['session'], '<br>'; |
145 | + } |
|
141 | 146 | |
142 | 147 | echo ' |
143 | 148 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=error_type;value=', $error['error_type']['type'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_type'], '"><span class="generic_icons filter centericon"></span></a> |
@@ -151,8 +156,8 @@ discard block |
||
151 | 156 | <a style="display: table-cell;" href="', $error['url']['html'], '">', $error['url']['html'], '</a> |
152 | 157 | </div>'; |
153 | 158 | |
154 | - if (!empty($error['file'])) |
|
155 | - echo ' |
|
159 | + if (!empty($error['file'])) { |
|
160 | + echo ' |
|
156 | 161 | <div style="float: left; width: 100%; padding: 4px 0; line-height: 1.6em; border-top: 1px solid #e3e3e3;"> |
157 | 162 | <a style="display: table-cell; padding: 4px; width: 20px; vertical-align: top;" href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=file;value=', $error['file']['search'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_file'], '"><span class="generic_icons filter"></span></a> |
158 | 163 | <div> |
@@ -160,6 +165,7 @@ discard block |
||
160 | 165 | ', $txt['line'], ': ', $error['file']['line'], ' |
161 | 166 | </div> |
162 | 167 | </div>'; |
168 | + } |
|
163 | 169 | |
164 | 170 | echo ' |
165 | 171 | </td> |
@@ -187,9 +193,10 @@ discard block |
||
187 | 193 | </div> |
188 | 194 | </div>'; |
189 | 195 | |
190 | - if ($context['sort_direction'] == 'down') |
|
191 | - echo ' |
|
196 | + if ($context['sort_direction'] == 'down') { |
|
197 | + echo ' |
|
192 | 198 | <input type="hidden" name="desc" value="1">'; |
199 | + } |
|
193 | 200 | |
194 | 201 | echo ' |
195 | 202 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Create a menu. |
@@ -64,22 +65,26 @@ discard block |
||
64 | 65 | $menu_context['current_action'] = isset($menuOptions['action']) ? $menuOptions['action'] : $context['current_action']; |
65 | 66 | |
66 | 67 | // Allow extend *any* menu with a single hook |
67 | - if (!empty($menu_context['current_action'])) |
|
68 | - call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData)); |
|
68 | + if (!empty($menu_context['current_action'])) { |
|
69 | + call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData)); |
|
70 | + } |
|
69 | 71 | |
70 | 72 | // What is the current area selected? |
71 | - if (isset($menuOptions['current_area']) || isset($_GET['area'])) |
|
72 | - $menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area']; |
|
73 | + if (isset($menuOptions['current_area']) || isset($_GET['area'])) { |
|
74 | + $menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area']; |
|
75 | + } |
|
73 | 76 | |
74 | 77 | // Build a list of additional parameters that should go in the URL. |
75 | 78 | $menu_context['extra_parameters'] = ''; |
76 | - if (!empty($menuOptions['extra_url_parameters'])) |
|
77 | - foreach ($menuOptions['extra_url_parameters'] as $key => $value) |
|
79 | + if (!empty($menuOptions['extra_url_parameters'])) { |
|
80 | + foreach ($menuOptions['extra_url_parameters'] as $key => $value) |
|
78 | 81 | $menu_context['extra_parameters'] .= ';' . $key . '=' . $value; |
82 | + } |
|
79 | 83 | |
80 | 84 | // Only include the session ID in the URL if it's strictly necessary. |
81 | - if (empty($menuOptions['disable_url_session_check'])) |
|
82 | - $menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id']; |
|
85 | + if (empty($menuOptions['disable_url_session_check'])) { |
|
86 | + $menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id']; |
|
87 | + } |
|
83 | 88 | |
84 | 89 | $include_data = array(); |
85 | 90 | |
@@ -87,8 +92,9 @@ discard block |
||
87 | 92 | foreach ($menuData as $section_id => $section) |
88 | 93 | { |
89 | 94 | // Is this enabled - or has as permission check - which fails? |
90 | - if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) |
|
91 | - continue; |
|
95 | + if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) { |
|
96 | + continue; |
|
97 | + } |
|
92 | 98 | |
93 | 99 | // Now we cycle through the sections to pick the right area. |
94 | 100 | foreach ($section['areas'] as $area_id => $area) |
@@ -110,59 +116,57 @@ discard block |
||
110 | 116 | if (empty($area['hidden'])) |
111 | 117 | { |
112 | 118 | // First time this section? |
113 | - if (!isset($menu_context['sections'][$section_id])) |
|
114 | - $menu_context['sections'][$section_id]['title'] = $section['title']; |
|
119 | + if (!isset($menu_context['sections'][$section_id])) { |
|
120 | + $menu_context['sections'][$section_id]['title'] = $section['title']; |
|
121 | + } |
|
115 | 122 | |
116 | 123 | $menu_context['sections'][$section_id]['areas'][$area_id] = array('label' => isset($area['label']) ? $area['label'] : $txt[$area_id]); |
117 | 124 | // We'll need the ID as well... |
118 | 125 | $menu_context['sections'][$section_id]['id'] = $section_id; |
119 | 126 | // Does it have a custom URL? |
120 | - if (isset($area['custom_url'])) |
|
121 | - $menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url']; |
|
127 | + if (isset($area['custom_url'])) { |
|
128 | + $menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url']; |
|
129 | + } |
|
122 | 130 | |
123 | 131 | // Does this area have its own icon? |
124 | 132 | if (!isset($area['force_menu_into_arms_of_another_menu']) && $user_info['name'] == 'iamanoompaloompa') |
125 | 133 | { |
126 | 134 | $menu_context['sections'][$section_id]['areas'][$area_id] = $smcFunc['json_decode'](base64_decode('eyJsYWJlbCI6Ik9vbXBhIExvb21wYSIsInVybCI6Imh0dHBzOlwvXC9lbi53aWtpcGVkaWEub3JnXC93aWtpXC9Pb21wYV9Mb29tcGFzPyIsImljb24iOiI8aW1nIHNyYz1cImh0dHBzOlwvXC93d3cuc2ltcGxlbWFjaGluZXMub3JnXC9pbWFnZXNcL29vbXBhLmdpZlwiIGFsdD1cIkknbSBhbiBPb21wYSBMb29tcGFcIiBcLz4ifQ=='), true); |
127 | - } |
|
128 | - elseif (isset($area['icon'])) |
|
135 | + } elseif (isset($area['icon'])) |
|
129 | 136 | { |
130 | 137 | if (file_exists($settings['theme_dir'] . '/images/admin/' . $area['icon'])) |
131 | 138 | { |
132 | 139 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
133 | - } |
|
134 | - elseif (file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon'])) |
|
140 | + } elseif (file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon'])) |
|
135 | 141 | { |
136 | 142 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['default_images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
143 | + } else { |
|
144 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>'; |
|
137 | 145 | } |
138 | - else |
|
139 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>'; |
|
146 | + } else { |
|
147 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>'; |
|
140 | 148 | } |
141 | - else |
|
142 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>'; |
|
143 | 149 | |
144 | 150 | if (isset($area['icon_class']) && empty($menu_context['sections'][$section_id]['areas'][$area_id]['icon'])) |
145 | 151 | { |
146 | 152 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . $area['icon_class']; |
147 | - } |
|
148 | - elseif (isset($area['icon'])) |
|
153 | + } elseif (isset($area['icon'])) |
|
149 | 154 | { |
150 | 155 | if (substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') |
151 | 156 | { |
152 | 157 | if (file_exists($settings['theme_dir'] . '/images/admin/big/' . $area['icon'])) |
153 | 158 | { |
154 | 159 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['theme_url'] . '/images/admin/big/' . $area['icon']; |
155 | - } |
|
156 | - elseif (file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon'])) |
|
160 | + } elseif (file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon'])) |
|
157 | 161 | { |
158 | 162 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['default_theme_url'] . '/images/admin/big/' . $area['icon']; |
159 | 163 | } |
160 | 164 | } |
161 | 165 | |
162 | 166 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area['icon']); |
167 | + } else { |
|
168 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id); |
|
163 | 169 | } |
164 | - else |
|
165 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id); |
|
166 | 170 | |
167 | 171 | // This is a shortcut for Font-Icon users so they don't have to re-do whole CSS. |
168 | 172 | $menu_context['sections'][$section_id]['areas'][$area_id]['plain_class'] = !empty($area['icon']) ? $area['icon'] : ''; |
@@ -179,35 +183,41 @@ discard block |
||
179 | 183 | { |
180 | 184 | if ((empty($sub[1]) || allowedTo($sub[1])) && (!isset($sub['enabled']) || !empty($sub['enabled']))) |
181 | 185 | { |
182 | - if ($first_sa == null) |
|
183 | - $first_sa = $sa; |
|
186 | + if ($first_sa == null) { |
|
187 | + $first_sa = $sa; |
|
188 | + } |
|
184 | 189 | |
185 | 190 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa] = array('label' => $sub[0]); |
186 | 191 | // Custom URL? |
187 | - if (isset($sub['url'])) |
|
188 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url']; |
|
192 | + if (isset($sub['url'])) { |
|
193 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url']; |
|
194 | + } |
|
189 | 195 | |
190 | 196 | // A bit complicated - but is this set? |
191 | 197 | if ($menu_context['current_area'] == $area_id) |
192 | 198 | { |
193 | 199 | // Save which is the first... |
194 | - if (empty($first_sa)) |
|
195 | - $first_sa = $sa; |
|
200 | + if (empty($first_sa)) { |
|
201 | + $first_sa = $sa; |
|
202 | + } |
|
196 | 203 | |
197 | 204 | // Is this the current subsection? |
198 | - if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) |
|
199 | - $menu_context['current_subsection'] = $sa; |
|
205 | + if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) { |
|
206 | + $menu_context['current_subsection'] = $sa; |
|
207 | + } |
|
200 | 208 | // Otherwise is it the default? |
201 | - elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) |
|
202 | - $menu_context['current_subsection'] = $sa; |
|
209 | + elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) { |
|
210 | + $menu_context['current_subsection'] = $sa; |
|
211 | + } |
|
203 | 212 | } |
204 | 213 | |
205 | 214 | // Let's assume this is the last, for now. |
206 | 215 | $last_sa = $sa; |
207 | 216 | } |
208 | 217 | // Mark it as disabled... |
209 | - else |
|
210 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true; |
|
218 | + else { |
|
219 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true; |
|
220 | + } |
|
211 | 221 | } |
212 | 222 | |
213 | 223 | // Set which one is first, last and selected in the group. |
@@ -216,8 +226,9 @@ discard block |
||
216 | 226 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $last_sa : $first_sa]['is_first'] = true; |
217 | 227 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $first_sa : $last_sa]['is_last'] = true; |
218 | 228 | |
219 | - if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) |
|
220 | - $menu_context['current_subsection'] = $first_sa; |
|
229 | + if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) { |
|
230 | + $menu_context['current_subsection'] = $first_sa; |
|
231 | + } |
|
221 | 232 | } |
222 | 233 | } |
223 | 234 | } |
@@ -251,23 +262,26 @@ discard block |
||
251 | 262 | $menu_context['base_url'] = isset($menuOptions['base_url']) ? $menuOptions['base_url'] : $scripturl . '?action=' . $menu_context['current_action']; |
252 | 263 | |
253 | 264 | // If we didn't find the area we were looking for go to a default one. |
254 | - if (isset($backup_area) && empty($found_section)) |
|
255 | - $menu_context['current_area'] = $backup_area; |
|
265 | + if (isset($backup_area) && empty($found_section)) { |
|
266 | + $menu_context['current_area'] = $backup_area; |
|
267 | + } |
|
256 | 268 | |
257 | 269 | // If there are sections quickly goes through all the sections to check if the base menu has an url |
258 | 270 | if (!empty($menu_context['current_section'])) |
259 | 271 | { |
260 | 272 | $menu_context['sections'][$menu_context['current_section']]['selected'] = true; |
261 | 273 | $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['selected'] = true; |
262 | - if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) |
|
263 | - $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true; |
|
274 | + if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) { |
|
275 | + $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true; |
|
276 | + } |
|
264 | 277 | |
265 | - foreach ($menu_context['sections'] as $section_id => $section) |
|
266 | - foreach ($section['areas'] as $area_id => $area) |
|
278 | + foreach ($menu_context['sections'] as $section_id => $section) { |
|
279 | + foreach ($section['areas'] as $area_id => $area) |
|
267 | 280 | { |
268 | 281 | if (!isset($menu_context['sections'][$section_id]['url'])) |
269 | 282 | { |
270 | 283 | $menu_context['sections'][$section_id]['url'] = isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $area_id; |
284 | + } |
|
271 | 285 | break; |
272 | 286 | } |
273 | 287 | } |
@@ -278,8 +292,9 @@ discard block |
||
278 | 292 | { |
279 | 293 | // Never happened! |
280 | 294 | $context['max_menu_id']--; |
281 | - if ($context['max_menu_id'] == 0) |
|
282 | - unset($context['max_menu_id']); |
|
295 | + if ($context['max_menu_id'] == 0) { |
|
296 | + unset($context['max_menu_id']); |
|
297 | + } |
|
283 | 298 | |
284 | 299 | return false; |
285 | 300 | } |
@@ -290,8 +305,9 @@ discard block |
||
290 | 305 | $context['template_layers'][] = $menu_context['layer_name']; |
291 | 306 | |
292 | 307 | // Check we had something - for sanity sake. |
293 | - if (empty($include_data)) |
|
294 | - return false; |
|
308 | + if (empty($include_data)) { |
|
309 | + return false; |
|
310 | + } |
|
295 | 311 | |
296 | 312 | // Finally - return information on the selected item. |
297 | 313 | $include_data += array( |
@@ -314,12 +330,14 @@ discard block |
||
314 | 330 | global $context; |
315 | 331 | |
316 | 332 | $menu_name = $menu_id == 'last' && isset($context['max_menu_id']) && isset($context['menu_data_' . $context['max_menu_id']]) ? 'menu_data_' . $context['max_menu_id'] : 'menu_data_' . $menu_id; |
317 | - if (!isset($context[$menu_name])) |
|
318 | - return false; |
|
333 | + if (!isset($context[$menu_name])) { |
|
334 | + return false; |
|
335 | + } |
|
319 | 336 | |
320 | 337 | $layer_index = array_search($context[$menu_name]['layer_name'], $context['template_layers']); |
321 | - if ($layer_index !== false) |
|
322 | - unset($context['template_layers'][$layer_index]); |
|
338 | + if ($layer_index !== false) { |
|
339 | + unset($context['template_layers'][$layer_index]); |
|
340 | + } |
|
323 | 341 | |
324 | 342 | unset($context[$menu_name]); |
325 | 343 | } |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
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 | * Ask them for their login information. (shows a page for the user to type |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | global $txt, $context, $scripturl, $user_info; |
30 | 31 | |
31 | 32 | // You are already logged in, go take a tour of the boards |
32 | - if (!empty($user_info['id'])) |
|
33 | - redirectexit(); |
|
33 | + if (!empty($user_info['id'])) { |
|
34 | + redirectexit(); |
|
35 | + } |
|
34 | 36 | |
35 | 37 | // We need to load the Login template/language file. |
36 | 38 | loadLanguage('Login'); |
@@ -57,10 +59,11 @@ discard block |
||
57 | 59 | ); |
58 | 60 | |
59 | 61 | // Set the login URL - will be used when the login process is done (but careful not to send us to an attachment). |
60 | - if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) |
|
61 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
62 | - elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) |
|
63 | - unset($_SESSION['login_url']); |
|
62 | + if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) { |
|
63 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
64 | + } elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) { |
|
65 | + unset($_SESSION['login_url']); |
|
66 | + } |
|
64 | 67 | |
65 | 68 | // Create a one time token. |
66 | 69 | createToken('login'); |
@@ -83,8 +86,9 @@ discard block |
||
83 | 86 | global $cookiename, $modSettings, $context, $sourcedir, $maintenance; |
84 | 87 | |
85 | 88 | // Check to ensure we're forcing SSL for authentication |
86 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
87 | - fatal_lang_error('login_ssl_required'); |
|
89 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
90 | + fatal_lang_error('login_ssl_required'); |
|
91 | + } |
|
88 | 92 | |
89 | 93 | // Load cookie authentication stuff. |
90 | 94 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -102,19 +106,20 @@ discard block |
||
102 | 106 | list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
103 | 107 | |
104 | 108 | // That didn't work... Maybe it's using serialize? |
105 | - if (is_null($timeout)) |
|
106 | - list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
107 | - } |
|
108 | - elseif (isset($_SESSION['login_' . $cookiename])) |
|
109 | + if (is_null($timeout)) { |
|
110 | + list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
111 | + } |
|
112 | + } elseif (isset($_SESSION['login_' . $cookiename])) |
|
109 | 113 | { |
110 | 114 | list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
111 | 115 | |
112 | 116 | // Try for old format |
113 | - if (is_null($timeout)) |
|
114 | - list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
117 | + if (is_null($timeout)) { |
|
118 | + list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
119 | + } |
|
120 | + } else { |
|
121 | + trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
115 | 122 | } |
116 | - else |
|
117 | - trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
118 | 123 | |
119 | 124 | $user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4); |
120 | 125 | updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt'])); |
@@ -127,10 +132,11 @@ discard block |
||
127 | 132 | list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata; |
128 | 133 | |
129 | 134 | // If we're preserving the cookie, reset it with updated salt |
130 | - if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) |
|
131 | - setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
132 | - else |
|
133 | - setTFACookie(-3600, 0, ''); |
|
135 | + if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) { |
|
136 | + setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
137 | + } else { |
|
138 | + setTFACookie(-3600, 0, ''); |
|
139 | + } |
|
134 | 140 | } |
135 | 141 | |
136 | 142 | setLoginCookie($timeout - time(), $user_info['id'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
@@ -141,20 +147,20 @@ discard block |
||
141 | 147 | elseif (isset($_GET['sa']) && $_GET['sa'] == 'check') |
142 | 148 | { |
143 | 149 | // Strike! You're outta there! |
144 | - if ($_GET['member'] != $user_info['id']) |
|
145 | - fatal_lang_error('login_cookie_error', false); |
|
150 | + if ($_GET['member'] != $user_info['id']) { |
|
151 | + fatal_lang_error('login_cookie_error', false); |
|
152 | + } |
|
146 | 153 | |
147 | 154 | $user_info['can_mod'] = allowedTo('access_mod_center') || (!$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || ($modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])))); |
148 | 155 | |
149 | 156 | // Some whitelisting for login_url... |
150 | - if (empty($_SESSION['login_url'])) |
|
151 | - redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
152 | - elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
157 | + if (empty($_SESSION['login_url'])) { |
|
158 | + redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
159 | + } elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
153 | 160 | { |
154 | 161 | unset ($_SESSION['login_url']); |
155 | 162 | redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
156 | - } |
|
157 | - else |
|
163 | + } else |
|
158 | 164 | { |
159 | 165 | // Best not to clutter the session data too much... |
160 | 166 | $temp = $_SESSION['login_url']; |
@@ -165,8 +171,9 @@ discard block |
||
165 | 171 | } |
166 | 172 | |
167 | 173 | // Beyond this point you are assumed to be a guest trying to login. |
168 | - if (!$user_info['is_guest']) |
|
169 | - redirectexit(); |
|
174 | + if (!$user_info['is_guest']) { |
|
175 | + redirectexit(); |
|
176 | + } |
|
170 | 177 | |
171 | 178 | // Are you guessing with a script? |
172 | 179 | checkSession(); |
@@ -174,18 +181,21 @@ discard block |
||
174 | 181 | spamProtection('login'); |
175 | 182 | |
176 | 183 | // Set the login_url if it's not already set (but careful not to send us to an attachment). |
177 | - if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) |
|
178 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
184 | + if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) { |
|
185 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
186 | + } |
|
179 | 187 | |
180 | 188 | // Been guessing a lot, haven't we? |
181 | - if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) |
|
182 | - fatal_lang_error('login_threshold_fail', 'login'); |
|
189 | + if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) { |
|
190 | + fatal_lang_error('login_threshold_fail', 'login'); |
|
191 | + } |
|
183 | 192 | |
184 | 193 | // Set up the cookie length. (if it's invalid, just fall through and use the default.) |
185 | - if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) |
|
186 | - $modSettings['cookieTime'] = 3153600; |
|
187 | - elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) |
|
188 | - $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
194 | + if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) { |
|
195 | + $modSettings['cookieTime'] = 3153600; |
|
196 | + } elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) { |
|
197 | + $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
198 | + } |
|
189 | 199 | |
190 | 200 | loadLanguage('Login'); |
191 | 201 | // Load the template stuff. |
@@ -305,8 +315,9 @@ discard block |
||
305 | 315 | $other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd'])); |
306 | 316 | |
307 | 317 | // Snitz style - SHA-256. Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway. |
308 | - if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) |
|
309 | - $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
318 | + if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) { |
|
319 | + $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
320 | + } |
|
310 | 321 | |
311 | 322 | // phpBB3 users new hashing. We now support it as well ;). |
312 | 323 | $other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']); |
@@ -326,27 +337,29 @@ discard block |
||
326 | 337 | // Some common md5 ones. |
327 | 338 | $other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']); |
328 | 339 | $other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']); |
329 | - } |
|
330 | - elseif (strlen($user_settings['passwd']) == 40) |
|
340 | + } elseif (strlen($user_settings['passwd']) == 40) |
|
331 | 341 | { |
332 | 342 | // Maybe they are using a hash from before the password fix. |
333 | 343 | // This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1 |
334 | 344 | $other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd'])); |
335 | 345 | |
336 | 346 | // BurningBoard3 style of hashing. |
337 | - if (!empty($modSettings['enable_password_conversion'])) |
|
338 | - $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
347 | + if (!empty($modSettings['enable_password_conversion'])) { |
|
348 | + $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
349 | + } |
|
339 | 350 | |
340 | 351 | // Perhaps we converted to UTF-8 and have a valid password being hashed differently. |
341 | 352 | if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8') |
342 | 353 | { |
343 | 354 | // Try iconv first, for no particular reason. |
344 | - if (function_exists('iconv')) |
|
345 | - $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
355 | + if (function_exists('iconv')) { |
|
356 | + $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
357 | + } |
|
346 | 358 | |
347 | 359 | // Say it aint so, iconv failed! |
348 | - if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) |
|
349 | - $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
360 | + if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) { |
|
361 | + $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
362 | + } |
|
350 | 363 | } |
351 | 364 | } |
352 | 365 | |
@@ -376,8 +389,9 @@ discard block |
||
376 | 389 | $_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1; |
377 | 390 | |
378 | 391 | // Hmm... don't remember it, do you? Here, try the password reminder ;). |
379 | - if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) |
|
380 | - redirectexit('action=reminder'); |
|
392 | + if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) { |
|
393 | + redirectexit('action=reminder'); |
|
394 | + } |
|
381 | 395 | // We'll give you another chance... |
382 | 396 | else |
383 | 397 | { |
@@ -388,8 +402,7 @@ discard block |
||
388 | 402 | return; |
389 | 403 | } |
390 | 404 | } |
391 | - } |
|
392 | - elseif (!empty($user_settings['passwd_flood'])) |
|
405 | + } elseif (!empty($user_settings['passwd_flood'])) |
|
393 | 406 | { |
394 | 407 | // Let's be sure they weren't a little hacker. |
395 | 408 | validatePasswordFlood($user_settings['id_member'], $user_settings['member_name'], $user_settings['passwd_flood'], true); |
@@ -406,8 +419,9 @@ discard block |
||
406 | 419 | } |
407 | 420 | |
408 | 421 | // Check their activation status. |
409 | - if (!checkActivation()) |
|
410 | - return; |
|
422 | + if (!checkActivation()) { |
|
423 | + return; |
|
424 | + } |
|
411 | 425 | |
412 | 426 | DoLogin(); |
413 | 427 | } |
@@ -419,8 +433,9 @@ discard block |
||
419 | 433 | { |
420 | 434 | global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl; |
421 | 435 | |
422 | - if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) |
|
423 | - fatal_lang_error('no_access', false); |
|
436 | + if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) { |
|
437 | + fatal_lang_error('no_access', false); |
|
438 | + } |
|
424 | 439 | |
425 | 440 | loadLanguage('Profile'); |
426 | 441 | require_once($sourcedir . '/Class-TOTP.php'); |
@@ -428,8 +443,9 @@ discard block |
||
428 | 443 | $member = $context['tfa_member']; |
429 | 444 | |
430 | 445 | // Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA |
431 | - if (time() - $member['last_login'] < 120) |
|
432 | - fatal_lang_error('tfa_wait', false); |
|
446 | + if (time() - $member['last_login'] < 120) { |
|
447 | + fatal_lang_error('tfa_wait', false); |
|
448 | + } |
|
433 | 449 | |
434 | 450 | $totp = new \TOTP\Auth($member['tfa_secret']); |
435 | 451 | $totp->setRange(1); |
@@ -443,8 +459,9 @@ discard block |
||
443 | 459 | if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup'])) |
444 | 460 | { |
445 | 461 | // Check to ensure we're forcing SSL for authentication |
446 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
447 | - fatal_lang_error('login_ssl_required'); |
|
462 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
463 | + fatal_lang_error('login_ssl_required'); |
|
464 | + } |
|
448 | 465 | |
449 | 466 | $code = $_POST['tfa_code']; |
450 | 467 | |
@@ -454,20 +471,19 @@ discard block |
||
454 | 471 | |
455 | 472 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']), !empty($_POST['tfa_preserve'])); |
456 | 473 | redirectexit(); |
457 | - } |
|
458 | - else |
|
474 | + } else |
|
459 | 475 | { |
460 | 476 | validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true); |
461 | 477 | |
462 | 478 | $context['tfa_error'] = true; |
463 | 479 | $context['tfa_value'] = $_POST['tfa_code']; |
464 | 480 | } |
465 | - } |
|
466 | - elseif (!empty($_POST['tfa_backup'])) |
|
481 | + } elseif (!empty($_POST['tfa_backup'])) |
|
467 | 482 | { |
468 | 483 | // Check to ensure we're forcing SSL for authentication |
469 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
470 | - fatal_lang_error('login_ssl_required'); |
|
484 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
485 | + fatal_lang_error('login_ssl_required'); |
|
486 | + } |
|
471 | 487 | |
472 | 488 | $backup = $_POST['tfa_backup']; |
473 | 489 | |
@@ -481,8 +497,7 @@ discard block |
||
481 | 497 | )); |
482 | 498 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt'])); |
483 | 499 | redirectexit('action=profile;area=tfasetup;backup'); |
484 | - } |
|
485 | - else |
|
500 | + } else |
|
486 | 501 | { |
487 | 502 | validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true); |
488 | 503 | |
@@ -505,8 +520,9 @@ discard block |
||
505 | 520 | { |
506 | 521 | global $context, $txt, $scripturl, $user_settings, $modSettings; |
507 | 522 | |
508 | - if (!isset($context['login_errors'])) |
|
509 | - $context['login_errors'] = array(); |
|
523 | + if (!isset($context['login_errors'])) { |
|
524 | + $context['login_errors'] = array(); |
|
525 | + } |
|
510 | 526 | |
511 | 527 | // What is the true activation status of this account? |
512 | 528 | $activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated']; |
@@ -518,8 +534,9 @@ discard block |
||
518 | 534 | return false; |
519 | 535 | } |
520 | 536 | // Awaiting approval still? |
521 | - elseif ($activation_status == 3) |
|
522 | - fatal_lang_error('still_awaiting_approval', 'user'); |
|
537 | + elseif ($activation_status == 3) { |
|
538 | + fatal_lang_error('still_awaiting_approval', 'user'); |
|
539 | + } |
|
523 | 540 | // Awaiting deletion, changed their mind? |
524 | 541 | elseif ($activation_status == 4) |
525 | 542 | { |
@@ -527,8 +544,7 @@ discard block |
||
527 | 544 | { |
528 | 545 | updateMemberData($user_settings['id_member'], array('is_activated' => 1)); |
529 | 546 | updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
530 | - } |
|
531 | - else |
|
547 | + } else |
|
532 | 548 | { |
533 | 549 | $context['disable_login_hashing'] = true; |
534 | 550 | $context['login_errors'][] = $txt['awaiting_delete_account']; |
@@ -568,8 +584,9 @@ discard block |
||
568 | 584 | setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
569 | 585 | |
570 | 586 | // Reset the login threshold. |
571 | - if (isset($_SESSION['failed_login'])) |
|
572 | - unset($_SESSION['failed_login']); |
|
587 | + if (isset($_SESSION['failed_login'])) { |
|
588 | + unset($_SESSION['failed_login']); |
|
589 | + } |
|
573 | 590 | |
574 | 591 | $user_info['is_guest'] = false; |
575 | 592 | $user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']); |
@@ -591,16 +608,18 @@ discard block |
||
591 | 608 | 'id_member' => $user_info['id'], |
592 | 609 | ) |
593 | 610 | ); |
594 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
595 | - $_SESSION['first_login'] = true; |
|
596 | - else |
|
597 | - unset($_SESSION['first_login']); |
|
611 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
612 | + $_SESSION['first_login'] = true; |
|
613 | + } else { |
|
614 | + unset($_SESSION['first_login']); |
|
615 | + } |
|
598 | 616 | $smcFunc['db_free_result']($request); |
599 | 617 | |
600 | 618 | // You've logged in, haven't you? |
601 | 619 | $update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']); |
602 | - if (empty($user_settings['tfa_secret'])) |
|
603 | - $update['last_login'] = time(); |
|
620 | + if (empty($user_settings['tfa_secret'])) { |
|
621 | + $update['last_login'] = time(); |
|
622 | + } |
|
604 | 623 | updateMemberData($user_info['id'], $update); |
605 | 624 | |
606 | 625 | // Get rid of the online entry for that old guest.... |
@@ -614,8 +633,8 @@ discard block |
||
614 | 633 | $_SESSION['log_time'] = 0; |
615 | 634 | |
616 | 635 | // Log this entry, only if we have it enabled. |
617 | - if (!empty($modSettings['loginHistoryDays'])) |
|
618 | - $smcFunc['db_insert']('insert', |
|
636 | + if (!empty($modSettings['loginHistoryDays'])) { |
|
637 | + $smcFunc['db_insert']('insert', |
|
619 | 638 | '{db_prefix}member_logins', |
620 | 639 | array( |
621 | 640 | 'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet', |
@@ -627,13 +646,15 @@ discard block |
||
627 | 646 | 'id_member', 'time' |
628 | 647 | ) |
629 | 648 | ); |
649 | + } |
|
630 | 650 | |
631 | 651 | // Just log you back out if it's in maintenance mode and you AREN'T an admin. |
632 | - if (empty($maintenance) || allowedTo('admin_forum')) |
|
633 | - redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
634 | - else |
|
635 | - redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
636 | -} |
|
652 | + if (empty($maintenance) || allowedTo('admin_forum')) { |
|
653 | + redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
654 | + } else { |
|
655 | + redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
656 | + } |
|
657 | + } |
|
637 | 658 | |
638 | 659 | /** |
639 | 660 | * Logs the current user out of their account. |
@@ -649,13 +670,15 @@ discard block |
||
649 | 670 | global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings; |
650 | 671 | |
651 | 672 | // Make sure they aren't being auto-logged out. |
652 | - if (!$internal) |
|
653 | - checkSession('get'); |
|
673 | + if (!$internal) { |
|
674 | + checkSession('get'); |
|
675 | + } |
|
654 | 676 | |
655 | 677 | require_once($sourcedir . '/Subs-Auth.php'); |
656 | 678 | |
657 | - if (isset($_SESSION['pack_ftp'])) |
|
658 | - $_SESSION['pack_ftp'] = null; |
|
679 | + if (isset($_SESSION['pack_ftp'])) { |
|
680 | + $_SESSION['pack_ftp'] = null; |
|
681 | + } |
|
659 | 682 | |
660 | 683 | // It won't be first login anymore. |
661 | 684 | unset($_SESSION['first_login']); |
@@ -683,8 +706,9 @@ discard block |
||
683 | 706 | |
684 | 707 | // And some other housekeeping while we're at it. |
685 | 708 | $salt = substr(md5(mt_rand()), 0, 4); |
686 | - if (!empty($user_info['id'])) |
|
687 | - updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
709 | + if (!empty($user_info['id'])) { |
|
710 | + updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
711 | + } |
|
688 | 712 | |
689 | 713 | if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa'])) |
690 | 714 | { |
@@ -693,10 +717,11 @@ discard block |
||
693 | 717 | list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata; |
694 | 718 | |
695 | 719 | // If we're preserving the cookie, reset it with updated salt |
696 | - if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) |
|
697 | - setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
698 | - else |
|
699 | - setTFACookie(-3600, 0, ''); |
|
720 | + if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) { |
|
721 | + setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
722 | + } else { |
|
723 | + setTFACookie(-3600, 0, ''); |
|
724 | + } |
|
700 | 725 | } |
701 | 726 | |
702 | 727 | session_destroy(); |
@@ -704,14 +729,13 @@ discard block |
||
704 | 729 | // Off to the merry board index we go! |
705 | 730 | if ($redirect) |
706 | 731 | { |
707 | - if (empty($_SESSION['logout_url'])) |
|
708 | - redirectexit('', $context['server']['needs_login_fix']); |
|
709 | - elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
732 | + if (empty($_SESSION['logout_url'])) { |
|
733 | + redirectexit('', $context['server']['needs_login_fix']); |
|
734 | + } elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
710 | 735 | { |
711 | 736 | unset ($_SESSION['logout_url']); |
712 | 737 | redirectexit(); |
713 | - } |
|
714 | - else |
|
738 | + } else |
|
715 | 739 | { |
716 | 740 | $temp = $_SESSION['logout_url']; |
717 | 741 | unset($_SESSION['logout_url']); |
@@ -744,8 +768,9 @@ discard block |
||
744 | 768 | function phpBB3_password_check($passwd, $passwd_hash) |
745 | 769 | { |
746 | 770 | // Too long or too short? |
747 | - if (strlen($passwd_hash) != 34) |
|
748 | - return; |
|
771 | + if (strlen($passwd_hash) != 34) { |
|
772 | + return; |
|
773 | + } |
|
749 | 774 | |
750 | 775 | // Range of characters allowed. |
751 | 776 | $range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
@@ -756,8 +781,9 @@ discard block |
||
756 | 781 | $salt = substr($passwd_hash, 4, 8); |
757 | 782 | |
758 | 783 | $hash = md5($salt . $passwd, true); |
759 | - for (; $count != 0; --$count) |
|
760 | - $hash = md5($hash . $passwd, true); |
|
784 | + for (; $count != 0; --$count) { |
|
785 | + $hash = md5($hash . $passwd, true); |
|
786 | + } |
|
761 | 787 | |
762 | 788 | $output = substr($passwd_hash, 0, 12); |
763 | 789 | $i = 0; |
@@ -766,21 +792,25 @@ discard block |
||
766 | 792 | $value = ord($hash[$i++]); |
767 | 793 | $output .= $range[$value & 0x3f]; |
768 | 794 | |
769 | - if ($i < 16) |
|
770 | - $value |= ord($hash[$i]) << 8; |
|
795 | + if ($i < 16) { |
|
796 | + $value |= ord($hash[$i]) << 8; |
|
797 | + } |
|
771 | 798 | |
772 | 799 | $output .= $range[($value >> 6) & 0x3f]; |
773 | 800 | |
774 | - if ($i++ >= 16) |
|
775 | - break; |
|
801 | + if ($i++ >= 16) { |
|
802 | + break; |
|
803 | + } |
|
776 | 804 | |
777 | - if ($i < 16) |
|
778 | - $value |= ord($hash[$i]) << 16; |
|
805 | + if ($i < 16) { |
|
806 | + $value |= ord($hash[$i]) << 16; |
|
807 | + } |
|
779 | 808 | |
780 | 809 | $output .= $range[($value >> 12) & 0x3f]; |
781 | 810 | |
782 | - if ($i++ >= 16) |
|
783 | - break; |
|
811 | + if ($i++ >= 16) { |
|
812 | + break; |
|
813 | + } |
|
784 | 814 | |
785 | 815 | $output .= $range[($value >> 18) & 0x3f]; |
786 | 816 | } |
@@ -812,8 +842,9 @@ discard block |
||
812 | 842 | require_once($sourcedir . '/Subs-Auth.php'); |
813 | 843 | setLoginCookie(-3600, 0); |
814 | 844 | |
815 | - if (isset($_SESSION['login_' . $cookiename])) |
|
816 | - unset($_SESSION['login_' . $cookiename]); |
|
845 | + if (isset($_SESSION['login_' . $cookiename])) { |
|
846 | + unset($_SESSION['login_' . $cookiename]); |
|
847 | + } |
|
817 | 848 | } |
818 | 849 | |
819 | 850 | // We need a member! |
@@ -827,8 +858,9 @@ discard block |
||
827 | 858 | } |
828 | 859 | |
829 | 860 | // Right, have we got a flood value? |
830 | - if ($password_flood_value !== false) |
|
831 | - @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
861 | + if ($password_flood_value !== false) { |
|
862 | + @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
863 | + } |
|
832 | 864 | |
833 | 865 | // Timestamp or number of tries invalid? |
834 | 866 | if (empty($number_tries) || empty($time_stamp)) |
@@ -844,15 +876,17 @@ discard block |
||
844 | 876 | $number_tries = $time_stamp < time() - 20 ? 2 : $number_tries; |
845 | 877 | |
846 | 878 | // They are trying too fast, make them wait longer |
847 | - if ($time_stamp < time() - 10) |
|
848 | - $time_stamp = time(); |
|
879 | + if ($time_stamp < time() - 10) { |
|
880 | + $time_stamp = time(); |
|
881 | + } |
|
849 | 882 | } |
850 | 883 | |
851 | 884 | $number_tries++; |
852 | 885 | |
853 | 886 | // Broken the law? |
854 | - if ($number_tries > 5) |
|
855 | - fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]); |
|
887 | + if ($number_tries > 5) { |
|
888 | + fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]); |
|
889 | + } |
|
856 | 890 | |
857 | 891 | // Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it! |
858 | 892 | updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries)); |