@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * The central part of the board - topic display. |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | global $attachments, $messages_request, $language, $smcFunc; |
35 | 36 | |
36 | 37 | // What are you gonna display if these are empty?! |
37 | - if (empty($topic)) |
|
38 | - fatal_lang_error('no_board', false); |
|
38 | + if (empty($topic)) { |
|
39 | + fatal_lang_error('no_board', false); |
|
40 | + } |
|
39 | 41 | |
40 | 42 | // Load the proper template. |
41 | 43 | loadTemplate('Display'); |
@@ -52,15 +54,17 @@ discard block |
||
52 | 54 | $context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
53 | 55 | |
54 | 56 | // Let's do some work on what to search index. |
55 | - if (count($_GET) > 2) |
|
56 | - foreach ($_GET as $k => $v) |
|
57 | + if (count($_GET) > 2) { |
|
58 | + foreach ($_GET as $k => $v) |
|
57 | 59 | { |
58 | 60 | if (!in_array($k, array('topic', 'board', 'start', session_name()))) |
59 | 61 | $context['robot_no_index'] = true; |
62 | + } |
|
60 | 63 | } |
61 | 64 | |
62 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
63 | - $context['robot_no_index'] = true; |
|
65 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
66 | + $context['robot_no_index'] = true; |
|
67 | + } |
|
64 | 68 | |
65 | 69 | // Find the previous or next topic. Make a fuss if there are no more. |
66 | 70 | if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next')) |
@@ -172,8 +176,9 @@ discard block |
||
172 | 176 | $topic_parameters |
173 | 177 | ); |
174 | 178 | |
175 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
176 | - fatal_lang_error('not_a_topic', false, 404); |
|
179 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
180 | + fatal_lang_error('not_a_topic', false, 404); |
|
181 | + } |
|
177 | 182 | $context['topicinfo'] = $smcFunc['db_fetch_assoc']($request); |
178 | 183 | $smcFunc['db_free_result']($request); |
179 | 184 | |
@@ -210,8 +215,9 @@ discard block |
||
210 | 215 | $context['topic_unwatched'] = isset($context['topicinfo']['unwatched']) ? $context['topicinfo']['unwatched'] : 0; |
211 | 216 | |
212 | 217 | // Add up unapproved replies to get real number of replies... |
213 | - if ($modSettings['postmod_active'] && $approve_posts) |
|
214 | - $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
218 | + if ($modSettings['postmod_active'] && $approve_posts) { |
|
219 | + $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
220 | + } |
|
215 | 221 | |
216 | 222 | // If this topic has unapproved posts, we need to work out how many posts the user can see, for page indexing. |
217 | 223 | if ($modSettings['postmod_active'] && $context['topicinfo']['unapproved_posts'] && !$user_info['is_guest'] && !$approve_posts) |
@@ -231,11 +237,11 @@ discard block |
||
231 | 237 | $smcFunc['db_free_result']($request); |
232 | 238 | |
233 | 239 | $context['total_visible_posts'] = $context['num_replies'] + $myUnapprovedPosts + ($context['topicinfo']['approved'] ? 1 : 0); |
240 | + } elseif ($user_info['is_guest']) { |
|
241 | + $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
242 | + } else { |
|
243 | + $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
234 | 244 | } |
235 | - elseif ($user_info['is_guest']) |
|
236 | - $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
237 | - else |
|
238 | - $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
239 | 245 | |
240 | 246 | // The start isn't a number; it's information about what to do, where to go. |
241 | 247 | if (!is_numeric($_REQUEST['start'])) |
@@ -248,8 +254,7 @@ discard block |
||
248 | 254 | { |
249 | 255 | $context['start_from'] = $context['total_visible_posts'] - 1; |
250 | 256 | $_REQUEST['start'] = empty($options['view_newest_first']) ? $context['start_from'] : 0; |
251 | - } |
|
252 | - else |
|
257 | + } else |
|
253 | 258 | { |
254 | 259 | // Find the earliest unread message in the topic. (the use of topics here is just for both tables.) |
255 | 260 | $request = $smcFunc['db_query']('', ' |
@@ -277,9 +282,9 @@ discard block |
||
277 | 282 | if (substr($_REQUEST['start'], 0, 4) == 'from') |
278 | 283 | { |
279 | 284 | $timestamp = (int) substr($_REQUEST['start'], 4); |
280 | - if ($timestamp === 0) |
|
281 | - $_REQUEST['start'] = 0; |
|
282 | - else |
|
285 | + if ($timestamp === 0) { |
|
286 | + $_REQUEST['start'] = 0; |
|
287 | + } else |
|
283 | 288 | { |
284 | 289 | // Find the number of messages posted before said time... |
285 | 290 | $request = $smcFunc['db_query']('', ' |
@@ -307,11 +312,11 @@ discard block |
||
307 | 312 | elseif (substr($_REQUEST['start'], 0, 3) == 'msg') |
308 | 313 | { |
309 | 314 | $virtual_msg = (int) substr($_REQUEST['start'], 3); |
310 | - if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) |
|
311 | - $context['start_from'] = $context['total_visible_posts'] - 1; |
|
312 | - elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) |
|
313 | - $context['start_from'] = 0; |
|
314 | - else |
|
315 | + if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) { |
|
316 | + $context['start_from'] = $context['total_visible_posts'] - 1; |
|
317 | + } elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) { |
|
318 | + $context['start_from'] = 0; |
|
319 | + } else |
|
315 | 320 | { |
316 | 321 | // Find the start value for that message...... |
317 | 322 | $request = $smcFunc['db_query']('', ' |
@@ -394,21 +399,25 @@ discard block |
||
394 | 399 | ); |
395 | 400 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
396 | 401 | { |
397 | - if (empty($row['id_member'])) |
|
398 | - continue; |
|
402 | + if (empty($row['id_member'])) { |
|
403 | + continue; |
|
404 | + } |
|
399 | 405 | |
400 | - if (!empty($row['online_color'])) |
|
401 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
402 | - else |
|
403 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
406 | + if (!empty($row['online_color'])) { |
|
407 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
408 | + } else { |
|
409 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
410 | + } |
|
404 | 411 | |
405 | 412 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
406 | - if ($is_buddy) |
|
407 | - $link = '<strong>' . $link . '</strong>'; |
|
413 | + if ($is_buddy) { |
|
414 | + $link = '<strong>' . $link . '</strong>'; |
|
415 | + } |
|
408 | 416 | |
409 | 417 | // Add them both to the list and to the more detailed list. |
410 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
411 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
418 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
419 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
420 | + } |
|
412 | 421 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
413 | 422 | 'id' => $row['id_member'], |
414 | 423 | 'username' => $row['member_name'], |
@@ -420,8 +429,9 @@ discard block |
||
420 | 429 | 'hidden' => empty($row['show_online']), |
421 | 430 | ); |
422 | 431 | |
423 | - if (empty($row['show_online'])) |
|
424 | - $context['view_num_hidden']++; |
|
432 | + if (empty($row['show_online'])) { |
|
433 | + $context['view_num_hidden']++; |
|
434 | + } |
|
425 | 435 | } |
426 | 436 | |
427 | 437 | // The number of guests is equal to the rows minus the ones we actually used ;). |
@@ -435,11 +445,13 @@ discard block |
||
435 | 445 | |
436 | 446 | // If all is set, but not allowed... just unset it. |
437 | 447 | $can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages']; |
438 | - if (isset($_REQUEST['all']) && !$can_show_all) |
|
439 | - unset($_REQUEST['all']); |
|
448 | + if (isset($_REQUEST['all']) && !$can_show_all) { |
|
449 | + unset($_REQUEST['all']); |
|
450 | + } |
|
440 | 451 | // Otherwise, it must be allowed... so pretend start was -1. |
441 | - elseif (isset($_REQUEST['all'])) |
|
442 | - $_REQUEST['start'] = -1; |
|
452 | + elseif (isset($_REQUEST['all'])) { |
|
453 | + $_REQUEST['start'] = -1; |
|
454 | + } |
|
443 | 455 | |
444 | 456 | // Construct the page index, allowing for the .START method... |
445 | 457 | $context['page_index'] = constructPageIndex($scripturl . '?topic=' . $topic . '.%1$d', $_REQUEST['start'], $context['total_visible_posts'], $context['messages_per_page'], true); |
@@ -476,8 +488,9 @@ discard block |
||
476 | 488 | $_REQUEST['start'] = 0; |
477 | 489 | } |
478 | 490 | // They aren't using it, but the *option* is there, at least. |
479 | - else |
|
480 | - $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
491 | + else { |
|
492 | + $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
493 | + } |
|
481 | 494 | } |
482 | 495 | |
483 | 496 | // Build the link tree. |
@@ -493,14 +506,16 @@ discard block |
||
493 | 506 | if (!empty($board_info['moderators'])) |
494 | 507 | { |
495 | 508 | // Add a link for each moderator... |
496 | - foreach ($board_info['moderators'] as $mod) |
|
497 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
509 | + foreach ($board_info['moderators'] as $mod) { |
|
510 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
511 | + } |
|
498 | 512 | } |
499 | 513 | if (!empty($board_info['moderator_groups'])) |
500 | 514 | { |
501 | 515 | // Add a link for each moderator group as well... |
502 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
503 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
516 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
517 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
518 | + } |
|
504 | 519 | } |
505 | 520 | |
506 | 521 | if (!empty($context['link_moderators'])) |
@@ -531,9 +546,9 @@ discard block |
||
531 | 546 | // For quick reply we need a response prefix in the default forum language. |
532 | 547 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix', 600))) |
533 | 548 | { |
534 | - if ($language === $user_info['language']) |
|
535 | - $context['response_prefix'] = $txt['response_prefix']; |
|
536 | - else |
|
549 | + if ($language === $user_info['language']) { |
|
550 | + $context['response_prefix'] = $txt['response_prefix']; |
|
551 | + } else |
|
537 | 552 | { |
538 | 553 | loadLanguage('index', $language, false); |
539 | 554 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -565,8 +580,9 @@ discard block |
||
565 | 580 | list($start, $end, $allday, $span, $tz_abbrev) = buildEventDatetimes($row); |
566 | 581 | |
567 | 582 | // Sanity check |
568 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
569 | - continue; |
|
583 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
584 | + continue; |
|
585 | + } |
|
570 | 586 | |
571 | 587 | $linked_calendar_event = array( |
572 | 588 | 'id' => $row['id_event'], |
@@ -615,8 +631,9 @@ discard block |
||
615 | 631 | } |
616 | 632 | $smcFunc['db_free_result']($request); |
617 | 633 | |
618 | - if (!empty($context['linked_calendar_events'])) |
|
619 | - $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
634 | + if (!empty($context['linked_calendar_events'])) { |
|
635 | + $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
636 | + } |
|
620 | 637 | } |
621 | 638 | |
622 | 639 | // Create the poll info if it exists. |
@@ -689,20 +706,21 @@ discard block |
||
689 | 706 | foreach ($guestinfo as $i => $guestvoted) |
690 | 707 | { |
691 | 708 | $guestvoted = explode(',', $guestvoted); |
692 | - if ($guestvoted[0] == $context['topicinfo']['id_poll']) |
|
693 | - break; |
|
709 | + if ($guestvoted[0] == $context['topicinfo']['id_poll']) { |
|
710 | + break; |
|
711 | + } |
|
694 | 712 | } |
695 | 713 | // Has the poll been reset since guest voted? |
696 | 714 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
697 | 715 | { |
698 | 716 | // Remove the poll info from the cookie to allow guest to vote again |
699 | 717 | unset($guestinfo[$i]); |
700 | - if (!empty($guestinfo)) |
|
701 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
702 | - else |
|
703 | - unset($_COOKIE['guest_poll_vote']); |
|
704 | - } |
|
705 | - else |
|
718 | + if (!empty($guestinfo)) { |
|
719 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
720 | + } else { |
|
721 | + unset($_COOKIE['guest_poll_vote']); |
|
722 | + } |
|
723 | + } else |
|
706 | 724 | { |
707 | 725 | // What did they vote for? |
708 | 726 | unset($guestvoted[0], $guestvoted[1]); |
@@ -816,23 +834,29 @@ discard block |
||
816 | 834 | // Build the poll moderation button array. |
817 | 835 | $context['poll_buttons'] = array(); |
818 | 836 | |
819 | - if ($context['allow_return_vote']) |
|
820 | - $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
837 | + if ($context['allow_return_vote']) { |
|
838 | + $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
839 | + } |
|
821 | 840 | |
822 | - if ($context['show_view_results_button']) |
|
823 | - $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
841 | + if ($context['show_view_results_button']) { |
|
842 | + $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
843 | + } |
|
824 | 844 | |
825 | - if ($context['allow_change_vote']) |
|
826 | - $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
845 | + if ($context['allow_change_vote']) { |
|
846 | + $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
847 | + } |
|
827 | 848 | |
828 | - if ($context['allow_lock_poll']) |
|
829 | - $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
849 | + if ($context['allow_lock_poll']) { |
|
850 | + $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
851 | + } |
|
830 | 852 | |
831 | - if ($context['allow_edit_poll']) |
|
832 | - $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
853 | + if ($context['allow_edit_poll']) { |
|
854 | + $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
855 | + } |
|
833 | 856 | |
834 | - if ($context['can_remove_poll']) |
|
835 | - $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
857 | + if ($context['can_remove_poll']) { |
|
858 | + $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
859 | + } |
|
836 | 860 | |
837 | 861 | // Allow mods to add additional buttons here |
838 | 862 | call_integration_hook('integrate_poll_buttons'); |
@@ -873,8 +897,9 @@ discard block |
||
873 | 897 | $all_posters = array(); |
874 | 898 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
875 | 899 | { |
876 | - if (!empty($row['id_member'])) |
|
877 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
900 | + if (!empty($row['id_member'])) { |
|
901 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
902 | + } |
|
878 | 903 | $messages[] = $row['id_msg']; |
879 | 904 | } |
880 | 905 | $smcFunc['db_free_result']($request); |
@@ -886,8 +911,9 @@ discard block |
||
886 | 911 | if (!$user_info['is_guest'] && !empty($messages)) |
887 | 912 | { |
888 | 913 | $mark_at_msg = max($messages); |
889 | - if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) |
|
890 | - $mark_at_msg = $modSettings['maxMsgID']; |
|
914 | + if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) { |
|
915 | + $mark_at_msg = $modSettings['maxMsgID']; |
|
916 | + } |
|
891 | 917 | if ($mark_at_msg >= $context['topicinfo']['new_from']) |
892 | 918 | { |
893 | 919 | $smcFunc['db_insert']($context['topicinfo']['new_from'] == 0 ? 'ignore' : 'replace', |
@@ -919,8 +945,9 @@ discard block |
||
919 | 945 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
920 | 946 | { |
921 | 947 | // Find if this topic is marked for notification... |
922 | - if (!empty($row['id_topic'])) |
|
923 | - $context['is_marked_notify'] = true; |
|
948 | + if (!empty($row['id_topic'])) { |
|
949 | + $context['is_marked_notify'] = true; |
|
950 | + } |
|
924 | 951 | |
925 | 952 | // Only do this once, but mark the notifications as "not sent yet" for next time. |
926 | 953 | if (!empty($row['sent']) && $do_once) |
@@ -942,8 +969,9 @@ discard block |
||
942 | 969 | } |
943 | 970 | |
944 | 971 | // Have we recently cached the number of new topics in this board, and it's still a lot? |
945 | - if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) |
|
946 | - $_SESSION['topicseen_cache'][$board]--; |
|
972 | + if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) { |
|
973 | + $_SESSION['topicseen_cache'][$board]--; |
|
974 | + } |
|
947 | 975 | // Mark board as seen if this is the only new topic. |
948 | 976 | elseif (isset($_REQUEST['topicseen'])) |
949 | 977 | { |
@@ -967,14 +995,16 @@ discard block |
||
967 | 995 | $smcFunc['db_free_result']($request); |
968 | 996 | |
969 | 997 | // If there're no real new topics in this board, mark the board as seen. |
970 | - if (empty($numNewTopics)) |
|
971 | - $_REQUEST['boardseen'] = true; |
|
972 | - else |
|
973 | - $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
998 | + if (empty($numNewTopics)) { |
|
999 | + $_REQUEST['boardseen'] = true; |
|
1000 | + } else { |
|
1001 | + $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
1002 | + } |
|
974 | 1003 | } |
975 | 1004 | // Probably one less topic - maybe not, but even if we decrease this too fast it will only make us look more often. |
976 | - elseif (isset($_SESSION['topicseen_cache'][$board])) |
|
977 | - $_SESSION['topicseen_cache'][$board]--; |
|
1005 | + elseif (isset($_SESSION['topicseen_cache'][$board])) { |
|
1006 | + $_SESSION['topicseen_cache'][$board]--; |
|
1007 | + } |
|
978 | 1008 | |
979 | 1009 | // Mark board as seen if we came using last post link from BoardIndex. (or other places...) |
980 | 1010 | if (isset($_REQUEST['boardseen'])) |
@@ -1031,23 +1061,26 @@ discard block |
||
1031 | 1061 | $temp = array(); |
1032 | 1062 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1033 | 1063 | { |
1034 | - if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) |
|
1035 | - continue; |
|
1064 | + if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) { |
|
1065 | + continue; |
|
1066 | + } |
|
1036 | 1067 | |
1037 | 1068 | $temp[$row['id_attach']] = $row; |
1038 | 1069 | $temp[$row['id_attach']]['topic'] = $topic; |
1039 | 1070 | $temp[$row['id_attach']]['board'] = $board; |
1040 | 1071 | |
1041 | - if (!isset($context['loaded_attachments'][$row['id_msg']])) |
|
1042 | - $context['loaded_attachments'][$row['id_msg']] = array(); |
|
1072 | + if (!isset($context['loaded_attachments'][$row['id_msg']])) { |
|
1073 | + $context['loaded_attachments'][$row['id_msg']] = array(); |
|
1074 | + } |
|
1043 | 1075 | } |
1044 | 1076 | $smcFunc['db_free_result']($request); |
1045 | 1077 | |
1046 | 1078 | // This is better than sorting it with the query... |
1047 | 1079 | ksort($temp); |
1048 | 1080 | |
1049 | - foreach ($temp as $row) |
|
1050 | - $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
1081 | + foreach ($temp as $row) { |
|
1082 | + $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
1083 | + } |
|
1051 | 1084 | } |
1052 | 1085 | |
1053 | 1086 | $msg_parameters = array( |
@@ -1074,21 +1107,23 @@ discard block |
||
1074 | 1107 | ); |
1075 | 1108 | |
1076 | 1109 | // And the likes |
1077 | - if (!empty($modSettings['enable_likes'])) |
|
1078 | - $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
1110 | + if (!empty($modSettings['enable_likes'])) { |
|
1111 | + $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
1112 | + } |
|
1079 | 1113 | |
1080 | 1114 | // Go to the last message if the given time is beyond the time of the last message. |
1081 | - if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) |
|
1082 | - $context['start_from'] = $context['topicinfo']['num_replies']; |
|
1115 | + if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) { |
|
1116 | + $context['start_from'] = $context['topicinfo']['num_replies']; |
|
1117 | + } |
|
1083 | 1118 | |
1084 | 1119 | // Since the anchor information is needed on the top of the page we load these variables beforehand. |
1085 | 1120 | $context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0]; |
1086 | - if (empty($options['view_newest_first'])) |
|
1087 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
1088 | - else |
|
1089 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
1090 | - } |
|
1091 | - else |
|
1121 | + if (empty($options['view_newest_first'])) { |
|
1122 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
1123 | + } else { |
|
1124 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
1125 | + } |
|
1126 | + } else |
|
1092 | 1127 | { |
1093 | 1128 | $messages_request = false; |
1094 | 1129 | $context['first_message'] = 0; |
@@ -1124,8 +1159,9 @@ discard block |
||
1124 | 1159 | 'can_see_likes' => 'likes_view', |
1125 | 1160 | 'can_like' => 'likes_like', |
1126 | 1161 | ); |
1127 | - foreach ($common_permissions as $contextual => $perm) |
|
1128 | - $context[$contextual] = allowedTo($perm); |
|
1162 | + foreach ($common_permissions as $contextual => $perm) { |
|
1163 | + $context[$contextual] = allowedTo($perm); |
|
1164 | + } |
|
1129 | 1165 | |
1130 | 1166 | // Permissions with _any/_own versions. $context[YYY] => ZZZ_any/_own. |
1131 | 1167 | $anyown_permissions = array( |
@@ -1138,8 +1174,9 @@ discard block |
||
1138 | 1174 | 'can_reply_unapproved' => 'post_unapproved_replies', |
1139 | 1175 | 'can_view_warning' => 'profile_warning', |
1140 | 1176 | ); |
1141 | - foreach ($anyown_permissions as $contextual => $perm) |
|
1142 | - $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
1177 | + foreach ($anyown_permissions as $contextual => $perm) { |
|
1178 | + $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
1179 | + } |
|
1143 | 1180 | |
1144 | 1181 | if (!$user_info['is_admin'] && !$modSettings['topic_move_any']) |
1145 | 1182 | { |
@@ -1185,8 +1222,9 @@ discard block |
||
1185 | 1222 | // Check if the draft functions are enabled and that they have permission to use them (for quick reply.) |
1186 | 1223 | $context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply']; |
1187 | 1224 | $context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']); |
1188 | - if (!empty($context['drafts_save'])) |
|
1189 | - loadLanguage('Drafts'); |
|
1225 | + if (!empty($context['drafts_save'])) { |
|
1226 | + loadLanguage('Drafts'); |
|
1227 | + } |
|
1190 | 1228 | |
1191 | 1229 | // When was the last time this topic was replied to? Should we warn them about it? |
1192 | 1230 | if (!empty($modSettings['oldTopicDays']) && ($context['can_reply'] || $context['can_reply_unapproved']) && empty($context['topicinfo']['is_sticky'])) |
@@ -1247,26 +1285,31 @@ discard block |
||
1247 | 1285 | // Message icons - customized icons are off? |
1248 | 1286 | $context['icons'] = getMessageIcons($board); |
1249 | 1287 | |
1250 | - if (!empty($context['icons'])) |
|
1251 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1288 | + if (!empty($context['icons'])) { |
|
1289 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1290 | + } |
|
1252 | 1291 | |
1253 | 1292 | // Build the normal button array. |
1254 | 1293 | $context['normal_buttons'] = array(); |
1255 | 1294 | |
1256 | - if ($context['can_reply']) |
|
1257 | - $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
1295 | + if ($context['can_reply']) { |
|
1296 | + $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
1297 | + } |
|
1258 | 1298 | |
1259 | - if ($context['can_add_poll']) |
|
1260 | - $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
1299 | + if ($context['can_add_poll']) { |
|
1300 | + $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
1301 | + } |
|
1261 | 1302 | |
1262 | - if ($context['can_mark_unread']) |
|
1263 | - $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1303 | + if ($context['can_mark_unread']) { |
|
1304 | + $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1305 | + } |
|
1264 | 1306 | |
1265 | - if ($context['can_print']) |
|
1266 | - $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
1307 | + if ($context['can_print']) { |
|
1308 | + $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
1309 | + } |
|
1267 | 1310 | |
1268 | - if ($context['can_set_notify']) |
|
1269 | - $context['normal_buttons']['notify'] = array( |
|
1311 | + if ($context['can_set_notify']) { |
|
1312 | + $context['normal_buttons']['notify'] = array( |
|
1270 | 1313 | 'text' => 'notify_topic_' . $context['topic_notification_mode'], |
1271 | 1314 | 'sub_buttons' => array( |
1272 | 1315 | array( |
@@ -1288,38 +1331,47 @@ discard block |
||
1288 | 1331 | ), |
1289 | 1332 | ), |
1290 | 1333 | ); |
1334 | + } |
|
1291 | 1335 | |
1292 | 1336 | // Build the mod button array |
1293 | 1337 | $context['mod_buttons'] = array(); |
1294 | 1338 | |
1295 | - if ($context['can_move']) |
|
1296 | - $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1339 | + if ($context['can_move']) { |
|
1340 | + $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1341 | + } |
|
1297 | 1342 | |
1298 | - if ($context['can_delete']) |
|
1299 | - $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
1343 | + if ($context['can_delete']) { |
|
1344 | + $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
1345 | + } |
|
1300 | 1346 | |
1301 | - if ($context['can_lock']) |
|
1302 | - $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1347 | + if ($context['can_lock']) { |
|
1348 | + $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1349 | + } |
|
1303 | 1350 | |
1304 | - if ($context['can_sticky']) |
|
1305 | - $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1351 | + if ($context['can_sticky']) { |
|
1352 | + $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1353 | + } |
|
1306 | 1354 | |
1307 | - if ($context['can_merge']) |
|
1308 | - $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
1355 | + if ($context['can_merge']) { |
|
1356 | + $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
1357 | + } |
|
1309 | 1358 | |
1310 | - if ($context['calendar_post']) |
|
1311 | - $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1359 | + if ($context['calendar_post']) { |
|
1360 | + $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1361 | + } |
|
1312 | 1362 | |
1313 | 1363 | // Restore topic. eh? No monkey business. |
1314 | - if ($context['can_restore_topic']) |
|
1315 | - $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1364 | + if ($context['can_restore_topic']) { |
|
1365 | + $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1366 | + } |
|
1316 | 1367 | |
1317 | 1368 | // Show a message in case a recently posted message became unapproved. |
1318 | 1369 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
1319 | 1370 | |
1320 | 1371 | // Don't want to show this forever... |
1321 | - if ($context['becomesUnapproved']) |
|
1322 | - unset($_SESSION['becomesUnapproved']); |
|
1372 | + if ($context['becomesUnapproved']) { |
|
1373 | + unset($_SESSION['becomesUnapproved']); |
|
1374 | + } |
|
1323 | 1375 | |
1324 | 1376 | // Allow adding new mod buttons easily. |
1325 | 1377 | // Note: $context['normal_buttons'] and $context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used |
@@ -1328,12 +1380,14 @@ discard block |
||
1328 | 1380 | call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons'])); |
1329 | 1381 | |
1330 | 1382 | // Load the drafts js file |
1331 | - if ($context['drafts_autosave']) |
|
1332 | - loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
1383 | + if ($context['drafts_autosave']) { |
|
1384 | + loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
1385 | + } |
|
1333 | 1386 | |
1334 | 1387 | // Spellcheck |
1335 | - if ($context['show_spellchecking']) |
|
1336 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
1388 | + if ($context['show_spellchecking']) { |
|
1389 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
1390 | + } |
|
1337 | 1391 | |
1338 | 1392 | // topic.js |
1339 | 1393 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -1367,16 +1421,19 @@ discard block |
||
1367 | 1421 | static $counter = null; |
1368 | 1422 | |
1369 | 1423 | // If the query returned false, bail. |
1370 | - if ($messages_request == false) |
|
1371 | - return false; |
|
1424 | + if ($messages_request == false) { |
|
1425 | + return false; |
|
1426 | + } |
|
1372 | 1427 | |
1373 | 1428 | // Remember which message this is. (ie. reply #83) |
1374 | - if ($counter === null || $reset) |
|
1375 | - $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
1429 | + if ($counter === null || $reset) { |
|
1430 | + $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
1431 | + } |
|
1376 | 1432 | |
1377 | 1433 | // Start from the beginning... |
1378 | - if ($reset) |
|
1379 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1434 | + if ($reset) { |
|
1435 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1436 | + } |
|
1380 | 1437 | |
1381 | 1438 | // Attempt to get the next message. |
1382 | 1439 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
@@ -1390,19 +1447,21 @@ discard block |
||
1390 | 1447 | if (empty($context['icon_sources'])) |
1391 | 1448 | { |
1392 | 1449 | $context['icon_sources'] = array(); |
1393 | - foreach ($context['stable_icons'] as $icon) |
|
1394 | - $context['icon_sources'][$icon] = 'images_url'; |
|
1450 | + foreach ($context['stable_icons'] as $icon) { |
|
1451 | + $context['icon_sources'][$icon] = 'images_url'; |
|
1452 | + } |
|
1395 | 1453 | } |
1396 | 1454 | |
1397 | 1455 | // Message Icon Management... check the images exist. |
1398 | 1456 | if (empty($modSettings['messageIconChecks_disable'])) |
1399 | 1457 | { |
1400 | 1458 | // If the current icon isn't known, then we need to do something... |
1401 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
1402 | - $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1459 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
1460 | + $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1461 | + } |
|
1462 | + } elseif (!isset($context['icon_sources'][$message['icon']])) { |
|
1463 | + $context['icon_sources'][$message['icon']] = 'images_url'; |
|
1403 | 1464 | } |
1404 | - elseif (!isset($context['icon_sources'][$message['icon']])) |
|
1405 | - $context['icon_sources'][$message['icon']] = 'images_url'; |
|
1406 | 1465 | |
1407 | 1466 | // If you're a lazy bum, you probably didn't give a subject... |
1408 | 1467 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -1427,8 +1486,7 @@ discard block |
||
1427 | 1486 | $memberContext[$message['id_member']]['email'] = $message['poster_email']; |
1428 | 1487 | $memberContext[$message['id_member']]['show_email'] = allowedTo('moderate_forum'); |
1429 | 1488 | $memberContext[$message['id_member']]['is_guest'] = true; |
1430 | - } |
|
1431 | - else |
|
1489 | + } else |
|
1432 | 1490 | { |
1433 | 1491 | // Define this here to make things a bit more readable |
1434 | 1492 | $can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own')); |
@@ -1451,8 +1509,9 @@ discard block |
||
1451 | 1509 | $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
1452 | 1510 | |
1453 | 1511 | // If it's in the recycle bin we need to override whatever icon we did have. |
1454 | - if (!empty($board_info['recycle'])) |
|
1455 | - $message['icon'] = 'recycled'; |
|
1512 | + if (!empty($board_info['recycle'])) { |
|
1513 | + $message['icon'] = 'recycled'; |
|
1514 | + } |
|
1456 | 1515 | |
1457 | 1516 | require_once($sourcedir . '/Subs-Attachments.php'); |
1458 | 1517 | |
@@ -1496,32 +1555,36 @@ discard block |
||
1496 | 1555 | } |
1497 | 1556 | |
1498 | 1557 | // Are likes enable? |
1499 | - if (!empty($modSettings['enable_likes'])) |
|
1500 | - $output['likes'] = array( |
|
1558 | + if (!empty($modSettings['enable_likes'])) { |
|
1559 | + $output['likes'] = array( |
|
1501 | 1560 | 'count' => $message['likes'], |
1502 | 1561 | 'you' => in_array($message['id_msg'], $context['my_likes']), |
1503 | 1562 | 'can_like' => !$context['user']['is_guest'] && $message['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
1504 | 1563 | ); |
1564 | + } |
|
1505 | 1565 | |
1506 | 1566 | // Is this user the message author? |
1507 | 1567 | $output['is_message_author'] = $message['id_member'] == $user_info['id']; |
1508 | - if (!empty($output['modified']['name'])) |
|
1509 | - $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
1568 | + if (!empty($output['modified']['name'])) { |
|
1569 | + $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
1570 | + } |
|
1510 | 1571 | |
1511 | 1572 | // Did they give a reason for editing? |
1512 | - if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) |
|
1513 | - $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
1573 | + if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) { |
|
1574 | + $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
1575 | + } |
|
1514 | 1576 | |
1515 | 1577 | // Any custom profile fields? |
1516 | - if (!empty($memberContext[$message['id_member']]['custom_fields'])) |
|
1517 | - foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
1578 | + if (!empty($memberContext[$message['id_member']]['custom_fields'])) { |
|
1579 | + foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
1518 | 1580 | $output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
1581 | + } |
|
1519 | 1582 | |
1520 | - if (empty($options['view_newest_first'])) |
|
1521 | - $counter++; |
|
1522 | - |
|
1523 | - else |
|
1524 | - $counter--; |
|
1583 | + if (empty($options['view_newest_first'])) { |
|
1584 | + $counter++; |
|
1585 | + } else { |
|
1586 | + $counter--; |
|
1587 | + } |
|
1525 | 1588 | |
1526 | 1589 | call_integration_hook('integrate_prepare_display_context', array(&$output, &$message, $counter)); |
1527 | 1590 | |
@@ -1547,21 +1610,23 @@ discard block |
||
1547 | 1610 | $context['no_last_modified'] = true; |
1548 | 1611 | |
1549 | 1612 | // Prevent a preview image from being displayed twice. |
1550 | - if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) |
|
1551 | - return; |
|
1613 | + if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) { |
|
1614 | + return; |
|
1615 | + } |
|
1552 | 1616 | |
1553 | 1617 | // Make sure some attachment was requested! |
1554 | - if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) |
|
1555 | - fatal_lang_error('no_access', false); |
|
1618 | + if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) { |
|
1619 | + fatal_lang_error('no_access', false); |
|
1620 | + } |
|
1556 | 1621 | |
1557 | 1622 | $_REQUEST['attach'] = isset($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : (int) $_REQUEST['id']; |
1558 | 1623 | |
1559 | 1624 | // Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request. |
1560 | 1625 | $attachRequest = null; |
1561 | 1626 | call_integration_hook('integrate_download_request', array(&$attachRequest)); |
1562 | - if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) |
|
1563 | - $request = $attachRequest; |
|
1564 | - else |
|
1627 | + if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) { |
|
1628 | + $request = $attachRequest; |
|
1629 | + } else |
|
1565 | 1630 | { |
1566 | 1631 | // This checks only the current board for $board/$topic's permissions. |
1567 | 1632 | isAllowedTo('view_attachments'); |
@@ -1582,19 +1647,21 @@ discard block |
||
1582 | 1647 | ); |
1583 | 1648 | } |
1584 | 1649 | |
1585 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1586 | - fatal_lang_error('no_access', false); |
|
1650 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1651 | + fatal_lang_error('no_access', false); |
|
1652 | + } |
|
1587 | 1653 | |
1588 | 1654 | list ($id_folder, $real_filename, $file_hash, $file_ext, $id_attach, $attachment_type, $mime_type, $is_approved, $id_member) = $smcFunc['db_fetch_row']($request); |
1589 | 1655 | $smcFunc['db_free_result']($request); |
1590 | 1656 | |
1591 | 1657 | // If it isn't yet approved, do they have permission to view it? |
1592 | - if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) |
|
1593 | - isAllowedTo('approve_posts'); |
|
1658 | + if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) { |
|
1659 | + isAllowedTo('approve_posts'); |
|
1660 | + } |
|
1594 | 1661 | |
1595 | 1662 | // Update the download counter (unless it's a thumbnail). |
1596 | - if ($attachment_type != 3) |
|
1597 | - $smcFunc['db_query']('attach_download_increase', ' |
|
1663 | + if ($attachment_type != 3) { |
|
1664 | + $smcFunc['db_query']('attach_download_increase', ' |
|
1598 | 1665 | UPDATE LOW_PRIORITY {db_prefix}attachments |
1599 | 1666 | SET downloads = downloads + 1 |
1600 | 1667 | WHERE id_attach = {int:id_attach}', |
@@ -1602,15 +1669,15 @@ discard block |
||
1602 | 1669 | 'id_attach' => $id_attach, |
1603 | 1670 | ) |
1604 | 1671 | ); |
1672 | + } |
|
1605 | 1673 | |
1606 | 1674 | $filename = getAttachmentFilename($real_filename, $_REQUEST['attach'], $id_folder, false, $file_hash); |
1607 | 1675 | |
1608 | 1676 | // This is done to clear any output that was made before now. |
1609 | 1677 | ob_end_clean(); |
1610 | - if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) |
|
1611 | - @ob_start('ob_gzhandler'); |
|
1612 | - |
|
1613 | - else |
|
1678 | + if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) { |
|
1679 | + @ob_start('ob_gzhandler'); |
|
1680 | + } else |
|
1614 | 1681 | { |
1615 | 1682 | ob_start(); |
1616 | 1683 | header('Content-Encoding: none'); |
@@ -1653,8 +1720,9 @@ discard block |
||
1653 | 1720 | // Send the attachment headers. |
1654 | 1721 | header('Pragma: '); |
1655 | 1722 | |
1656 | - if (!isBrowser('gecko')) |
|
1657 | - header('Content-Transfer-Encoding: binary'); |
|
1723 | + if (!isBrowser('gecko')) { |
|
1724 | + header('Content-Transfer-Encoding: binary'); |
|
1725 | + } |
|
1658 | 1726 | |
1659 | 1727 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
1660 | 1728 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($filename)) . ' GMT'); |
@@ -1663,18 +1731,19 @@ discard block |
||
1663 | 1731 | header('ETag: ' . $eTag); |
1664 | 1732 | |
1665 | 1733 | // Make sure the mime type warrants an inline display. |
1666 | - if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) |
|
1667 | - unset($_REQUEST['image']); |
|
1734 | + if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) { |
|
1735 | + unset($_REQUEST['image']); |
|
1736 | + } |
|
1668 | 1737 | |
1669 | 1738 | // Does this have a mime type? |
1670 | - elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) |
|
1671 | - header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp'))); |
|
1672 | - |
|
1673 | - else |
|
1739 | + elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) { |
|
1740 | + header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp'))); |
|
1741 | + } else |
|
1674 | 1742 | { |
1675 | 1743 | header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream')); |
1676 | - if (isset($_REQUEST['image'])) |
|
1677 | - unset($_REQUEST['image']); |
|
1744 | + if (isset($_REQUEST['image'])) { |
|
1745 | + unset($_REQUEST['image']); |
|
1746 | + } |
|
1678 | 1747 | } |
1679 | 1748 | |
1680 | 1749 | // Convert the file to UTF-8, cuz most browsers dig that. |
@@ -1682,23 +1751,22 @@ discard block |
||
1682 | 1751 | $disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline'; |
1683 | 1752 | |
1684 | 1753 | // Different browsers like different standards... |
1685 | - if (isBrowser('firefox')) |
|
1686 | - header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
1687 | - |
|
1688 | - elseif (isBrowser('opera')) |
|
1689 | - header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
1690 | - |
|
1691 | - elseif (isBrowser('ie')) |
|
1692 | - header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
1693 | - |
|
1694 | - else |
|
1695 | - header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
1754 | + if (isBrowser('firefox')) { |
|
1755 | + header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
1756 | + } elseif (isBrowser('opera')) { |
|
1757 | + header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
1758 | + } elseif (isBrowser('ie')) { |
|
1759 | + header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
1760 | + } else { |
|
1761 | + header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
1762 | + } |
|
1696 | 1763 | |
1697 | 1764 | // If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE. |
1698 | - if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) |
|
1699 | - header('Cache-Control: no-cache'); |
|
1700 | - else |
|
1701 | - header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
1765 | + if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) { |
|
1766 | + header('Cache-Control: no-cache'); |
|
1767 | + } else { |
|
1768 | + header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
1769 | + } |
|
1702 | 1770 | |
1703 | 1771 | header('Content-Length: ' . filesize($filename)); |
1704 | 1772 | |
@@ -1708,20 +1776,23 @@ discard block |
||
1708 | 1776 | // Recode line endings for text files, if enabled. |
1709 | 1777 | if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file_ext, array('txt', 'css', 'htm', 'html', 'php', 'xml'))) |
1710 | 1778 | { |
1711 | - if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) |
|
1712 | - $callback = function($buffer) |
|
1779 | + if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) { |
|
1780 | + $callback = function($buffer) |
|
1713 | 1781 | { |
1714 | 1782 | return preg_replace('~[\r]?\n~', "\r\n", $buffer); |
1783 | + } |
|
1715 | 1784 | }; |
1716 | - elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) |
|
1717 | - $callback = function($buffer) |
|
1785 | + elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) { |
|
1786 | + $callback = function($buffer) |
|
1718 | 1787 | { |
1719 | 1788 | return preg_replace('~[\r]?\n~', "\r", $buffer); |
1789 | + } |
|
1720 | 1790 | }; |
1721 | - else |
|
1722 | - $callback = function($buffer) |
|
1791 | + else { |
|
1792 | + $callback = function($buffer) |
|
1723 | 1793 | { |
1724 | 1794 | return preg_replace('~[\r]?\n~', "\n", $buffer); |
1795 | + } |
|
1725 | 1796 | }; |
1726 | 1797 | } |
1727 | 1798 | |
@@ -1729,23 +1800,26 @@ discard block |
||
1729 | 1800 | if (filesize($filename) > 4194304) |
1730 | 1801 | { |
1731 | 1802 | // Forcibly end any output buffering going on. |
1732 | - while (@ob_get_level() > 0) |
|
1733 | - @ob_end_clean(); |
|
1803 | + while (@ob_get_level() > 0) { |
|
1804 | + @ob_end_clean(); |
|
1805 | + } |
|
1734 | 1806 | |
1735 | 1807 | $fp = fopen($filename, 'rb'); |
1736 | 1808 | while (!feof($fp)) |
1737 | 1809 | { |
1738 | - if (isset($callback)) |
|
1739 | - echo $callback(fread($fp, 8192)); |
|
1740 | - else |
|
1741 | - echo fread($fp, 8192); |
|
1810 | + if (isset($callback)) { |
|
1811 | + echo $callback(fread($fp, 8192)); |
|
1812 | + } else { |
|
1813 | + echo fread($fp, 8192); |
|
1814 | + } |
|
1742 | 1815 | flush(); |
1743 | 1816 | } |
1744 | 1817 | fclose($fp); |
1745 | 1818 | } |
1746 | 1819 | // On some of the less-bright hosts, readfile() is disabled. It's just a faster, more byte safe, version of what's in the if. |
1747 | - elseif (isset($callback) || @readfile($filename) === null) |
|
1748 | - echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename); |
|
1820 | + elseif (isset($callback) || @readfile($filename) === null) { |
|
1821 | + echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename); |
|
1822 | + } |
|
1749 | 1823 | |
1750 | 1824 | obExit(false); |
1751 | 1825 | } |
@@ -1758,8 +1832,9 @@ discard block |
||
1758 | 1832 | */ |
1759 | 1833 | function approved_attach_sort($a, $b) |
1760 | 1834 | { |
1761 | - if ($a['is_approved'] == $b['is_approved']) |
|
1762 | - return 0; |
|
1835 | + if ($a['is_approved'] == $b['is_approved']) { |
|
1836 | + return 0; |
|
1837 | + } |
|
1763 | 1838 | |
1764 | 1839 | return $a['is_approved'] > $b['is_approved'] ? -1 : 1; |
1765 | 1840 | } |
@@ -1776,16 +1851,19 @@ discard block |
||
1776 | 1851 | |
1777 | 1852 | require_once($sourcedir . '/RemoveTopic.php'); |
1778 | 1853 | |
1779 | - if (empty($_REQUEST['msgs'])) |
|
1780 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
1854 | + if (empty($_REQUEST['msgs'])) { |
|
1855 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
1856 | + } |
|
1781 | 1857 | |
1782 | 1858 | $messages = array(); |
1783 | - foreach ($_REQUEST['msgs'] as $dummy) |
|
1784 | - $messages[] = (int) $dummy; |
|
1859 | + foreach ($_REQUEST['msgs'] as $dummy) { |
|
1860 | + $messages[] = (int) $dummy; |
|
1861 | + } |
|
1785 | 1862 | |
1786 | 1863 | // We are restoring messages. We handle this in another place. |
1787 | - if (isset($_REQUEST['restore_selected'])) |
|
1788 | - redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1864 | + if (isset($_REQUEST['restore_selected'])) { |
|
1865 | + redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1866 | + } |
|
1789 | 1867 | if (isset($_REQUEST['split_selection'])) |
1790 | 1868 | { |
1791 | 1869 | $request = $smcFunc['db_query']('', ' |
@@ -1804,8 +1882,9 @@ discard block |
||
1804 | 1882 | } |
1805 | 1883 | |
1806 | 1884 | // Allowed to delete any message? |
1807 | - if (allowedTo('delete_any')) |
|
1808 | - $allowed_all = true; |
|
1885 | + if (allowedTo('delete_any')) { |
|
1886 | + $allowed_all = true; |
|
1887 | + } |
|
1809 | 1888 | // Allowed to delete replies to their messages? |
1810 | 1889 | elseif (allowedTo('delete_replies')) |
1811 | 1890 | { |
@@ -1822,13 +1901,14 @@ discard block |
||
1822 | 1901 | $smcFunc['db_free_result']($request); |
1823 | 1902 | |
1824 | 1903 | $allowed_all = $starter == $user_info['id']; |
1904 | + } else { |
|
1905 | + $allowed_all = false; |
|
1825 | 1906 | } |
1826 | - else |
|
1827 | - $allowed_all = false; |
|
1828 | 1907 | |
1829 | 1908 | // Make sure they're allowed to delete their own messages, if not any. |
1830 | - if (!$allowed_all) |
|
1831 | - isAllowedTo('delete_own'); |
|
1909 | + if (!$allowed_all) { |
|
1910 | + isAllowedTo('delete_own'); |
|
1911 | + } |
|
1832 | 1912 | |
1833 | 1913 | // Allowed to remove which messages? |
1834 | 1914 | $request = $smcFunc['db_query']('', ' |
@@ -1848,8 +1928,9 @@ discard block |
||
1848 | 1928 | $messages = array(); |
1849 | 1929 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1850 | 1930 | { |
1851 | - if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) |
|
1852 | - continue; |
|
1931 | + if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) { |
|
1932 | + continue; |
|
1933 | + } |
|
1853 | 1934 | |
1854 | 1935 | $messages[$row['id_msg']] = array($row['subject'], $row['id_member']); |
1855 | 1936 | } |
@@ -1872,17 +1953,20 @@ discard block |
||
1872 | 1953 | foreach ($messages as $message => $info) |
1873 | 1954 | { |
1874 | 1955 | // Just skip the first message - if it's not the last. |
1875 | - if ($message == $first_message && $message != $last_message) |
|
1876 | - continue; |
|
1956 | + if ($message == $first_message && $message != $last_message) { |
|
1957 | + continue; |
|
1958 | + } |
|
1877 | 1959 | // If the first message is going then don't bother going back to the topic as we're effectively deleting it. |
1878 | - elseif ($message == $first_message) |
|
1879 | - $topicGone = true; |
|
1960 | + elseif ($message == $first_message) { |
|
1961 | + $topicGone = true; |
|
1962 | + } |
|
1880 | 1963 | |
1881 | 1964 | removeMessage($message); |
1882 | 1965 | |
1883 | 1966 | // Log this moderation action ;). |
1884 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
1885 | - logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
1967 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
1968 | + logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
1969 | + } |
|
1886 | 1970 | } |
1887 | 1971 | |
1888 | 1972 | redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The main entrance point for the Manage Members screen. |
@@ -62,16 +63,18 @@ discard block |
||
62 | 63 | $context['activation_numbers'] = array(); |
63 | 64 | $context['awaiting_activation'] = 0; |
64 | 65 | $context['awaiting_approval'] = 0; |
65 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
66 | - $context['activation_numbers'][$row['is_activated']] = $row['total_members']; |
|
66 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
67 | + $context['activation_numbers'][$row['is_activated']] = $row['total_members']; |
|
68 | + } |
|
67 | 69 | $smcFunc['db_free_result']($request); |
68 | 70 | |
69 | 71 | foreach ($context['activation_numbers'] as $activation_type => $total_members) |
70 | 72 | { |
71 | - if (in_array($activation_type, array(0, 2))) |
|
72 | - $context['awaiting_activation'] += $total_members; |
|
73 | - elseif (in_array($activation_type, array(3, 4, 5))) |
|
74 | - $context['awaiting_approval'] += $total_members; |
|
73 | + if (in_array($activation_type, array(0, 2))) { |
|
74 | + $context['awaiting_activation'] += $total_members; |
|
75 | + } elseif (in_array($activation_type, array(3, 4, 5))) { |
|
76 | + $context['awaiting_approval'] += $total_members; |
|
77 | + } |
|
75 | 78 | } |
76 | 79 | |
77 | 80 | // For the page header... do we show activation? |
@@ -124,8 +127,9 @@ discard block |
||
124 | 127 | } |
125 | 128 | if (!$context['show_approve'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'approve')) |
126 | 129 | { |
127 | - if (!$context['show_activate'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'activate')) |
|
128 | - $context['tabs']['search']['is_last'] = true; |
|
130 | + if (!$context['show_activate'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'activate')) { |
|
131 | + $context['tabs']['search']['is_last'] = true; |
|
132 | + } |
|
129 | 133 | unset($context['tabs']['approve']); |
130 | 134 | } |
131 | 135 | |
@@ -157,8 +161,9 @@ discard block |
||
157 | 161 | foreach ($_POST['delete'] as $key => $value) |
158 | 162 | { |
159 | 163 | // Don't delete yourself, idiot. |
160 | - if ($value != $user_info['id']) |
|
161 | - $delete[$key] = (int) $value; |
|
164 | + if ($value != $user_info['id']) { |
|
165 | + $delete[$key] = (int) $value; |
|
166 | + } |
|
162 | 167 | } |
163 | 168 | |
164 | 169 | if (!empty($delete)) |
@@ -194,17 +199,18 @@ discard block |
||
194 | 199 | ); |
195 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
196 | 201 | { |
197 | - if ($row['min_posts'] == -1) |
|
198 | - $context['membergroups'][] = array( |
|
202 | + if ($row['min_posts'] == -1) { |
|
203 | + $context['membergroups'][] = array( |
|
199 | 204 | 'id' => $row['id_group'], |
200 | 205 | 'name' => $row['group_name'], |
201 | 206 | 'can_be_additional' => true |
202 | 207 | ); |
203 | - else |
|
204 | - $context['postgroups'][] = array( |
|
208 | + } else { |
|
209 | + $context['postgroups'][] = array( |
|
205 | 210 | 'id' => $row['id_group'], |
206 | 211 | 'name' => $row['group_name'] |
207 | 212 | ); |
213 | + } |
|
208 | 214 | } |
209 | 215 | $smcFunc['db_free_result']($request); |
210 | 216 | |
@@ -268,14 +274,15 @@ discard block |
||
268 | 274 | call_integration_hook('integrate_view_members_params', array(&$params)); |
269 | 275 | |
270 | 276 | $search_params = array(); |
271 | - if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) |
|
272 | - $search_params = smf_json_decode(base64_decode($_REQUEST['params']), true); |
|
273 | - elseif (!empty($_POST)) |
|
277 | + if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) { |
|
278 | + $search_params = smf_json_decode(base64_decode($_REQUEST['params']), true); |
|
279 | + } elseif (!empty($_POST)) |
|
274 | 280 | { |
275 | 281 | $search_params['types'] = $_POST['types']; |
276 | - foreach ($params as $param_name => $param_info) |
|
277 | - if (isset($_POST[$param_name])) |
|
282 | + foreach ($params as $param_name => $param_info) { |
|
283 | + if (isset($_POST[$param_name])) |
|
278 | 284 | $search_params[$param_name] = $_POST[$param_name]; |
285 | + } |
|
279 | 286 | } |
280 | 287 | |
281 | 288 | $search_url_params = isset($search_params) ? base64_encode(json_encode($search_params)) : null; |
@@ -288,18 +295,21 @@ discard block |
||
288 | 295 | foreach ($params as $param_name => $param_info) |
289 | 296 | { |
290 | 297 | // Not filled in? |
291 | - if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') |
|
292 | - continue; |
|
298 | + if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') { |
|
299 | + continue; |
|
300 | + } |
|
293 | 301 | |
294 | 302 | // Make sure numeric values are really numeric. |
295 | - if (in_array($param_info['type'], array('int', 'age'))) |
|
296 | - $search_params[$param_name] = (int) $search_params[$param_name]; |
|
303 | + if (in_array($param_info['type'], array('int', 'age'))) { |
|
304 | + $search_params[$param_name] = (int) $search_params[$param_name]; |
|
305 | + } |
|
297 | 306 | // Date values have to match the specified format. |
298 | 307 | elseif ($param_info['type'] == 'date') |
299 | 308 | { |
300 | 309 | // Check if this date format is valid. |
301 | - if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) |
|
302 | - continue; |
|
310 | + if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) { |
|
311 | + continue; |
|
312 | + } |
|
303 | 313 | |
304 | 314 | $search_params[$param_name] = strtotime($search_params[$param_name]); |
305 | 315 | } |
@@ -308,8 +318,9 @@ discard block |
||
308 | 318 | if (!empty($param_info['range'])) |
309 | 319 | { |
310 | 320 | // Default to '=', just in case... |
311 | - if (empty($range_trans[$search_params['types'][$param_name]])) |
|
312 | - $search_params['types'][$param_name] = '='; |
|
321 | + if (empty($range_trans[$search_params['types'][$param_name]])) { |
|
322 | + $search_params['types'][$param_name] = '='; |
|
323 | + } |
|
313 | 324 | |
314 | 325 | // Handle special case 'age'. |
315 | 326 | if ($param_info['type'] == 'age') |
@@ -337,29 +348,30 @@ discard block |
||
337 | 348 | elseif ($param_info['type'] == 'date' && $search_params['types'][$param_name] == '=') |
338 | 349 | { |
339 | 350 | $query_parts[] = $param_info['db_fields'][0] . ' > ' . $search_params[$param_name] . ' AND ' . $param_info['db_fields'][0] . ' < ' . ($search_params[$param_name] + 86400); |
351 | + } else { |
|
352 | + $query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name]; |
|
340 | 353 | } |
341 | - else |
|
342 | - $query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name]; |
|
343 | 354 | } |
344 | 355 | // Checkboxes. |
345 | 356 | elseif ($param_info['type'] == 'checkbox') |
346 | 357 | { |
347 | 358 | // Each checkbox or no checkbox at all is checked -> ignore. |
348 | - if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) |
|
349 | - continue; |
|
359 | + if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) { |
|
360 | + continue; |
|
361 | + } |
|
350 | 362 | |
351 | 363 | $query_parts[] = ($param_info['db_fields'][0]) . ' IN ({array_string:' . $param_name . '_check})'; |
352 | 364 | $where_params[$param_name . '_check'] = $search_params[$param_name]; |
353 | - } |
|
354 | - else |
|
365 | + } else |
|
355 | 366 | { |
356 | 367 | // Replace the wildcard characters ('*' and '?') into MySQL ones. |
357 | 368 | $parameter = strtolower(strtr($smcFunc['htmlspecialchars']($search_params[$param_name], ENT_QUOTES), array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_'))); |
358 | 369 | |
359 | - if ($smcFunc['db_case_sensitive']) |
|
360 | - $query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})'; |
|
361 | - else |
|
362 | - $query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})'; |
|
370 | + if ($smcFunc['db_case_sensitive']) { |
|
371 | + $query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})'; |
|
372 | + } else { |
|
373 | + $query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})'; |
|
374 | + } |
|
363 | 375 | $where_params[$param_name . '_normal'] = '%' . $parameter . '%'; |
364 | 376 | } |
365 | 377 | } |
@@ -375,16 +387,18 @@ discard block |
||
375 | 387 | } |
376 | 388 | |
377 | 389 | // Additional membergroups (these are only relevant if not all primary groups where selected!). |
378 | - if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) |
|
379 | - foreach ($search_params['membergroups'][2] as $mg) |
|
390 | + if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) { |
|
391 | + foreach ($search_params['membergroups'][2] as $mg) |
|
380 | 392 | { |
381 | 393 | $mg_query_parts[] = 'FIND_IN_SET({int:add_group_' . $mg . '}, mem.additional_groups) != 0'; |
394 | + } |
|
382 | 395 | $where_params['add_group_' . $mg] = $mg; |
383 | 396 | } |
384 | 397 | |
385 | 398 | // Combine the one or two membergroup parts into one query part linked with an OR. |
386 | - if (!empty($mg_query_parts)) |
|
387 | - $query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')'; |
|
399 | + if (!empty($mg_query_parts)) { |
|
400 | + $query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')'; |
|
401 | + } |
|
388 | 402 | |
389 | 403 | // Get all selected post count related membergroups. |
390 | 404 | if (!empty($search_params['postgroups']) && count($search_params['postgroups']) != count($context['postgroups'])) |
@@ -396,9 +410,9 @@ discard block |
||
396 | 410 | // Construct the where part of the query. |
397 | 411 | $where = empty($query_parts) ? '1=1' : implode(' |
398 | 412 | AND ', $query_parts); |
413 | + } else { |
|
414 | + $search_url_params = null; |
|
399 | 415 | } |
400 | - else |
|
401 | - $search_url_params = null; |
|
402 | 416 | |
403 | 417 | // Construct the additional URL part with the query info in it. |
404 | 418 | $context['params_url'] = $context['sub_action'] == 'query' ? ';sa=query;params=' . $search_url_params : ''; |
@@ -521,28 +535,32 @@ discard block |
||
521 | 535 | 'function' => function($rowData) use ($txt) |
522 | 536 | { |
523 | 537 | // Calculate number of days since last online. |
524 | - if (empty($rowData['last_login'])) |
|
525 | - $difference = $txt['never']; |
|
526 | - else |
|
538 | + if (empty($rowData['last_login'])) { |
|
539 | + $difference = $txt['never']; |
|
540 | + } else |
|
527 | 541 | { |
528 | 542 | $num_days_difference = jeffsdatediff($rowData['last_login']); |
529 | 543 | |
530 | 544 | // Today. |
531 | - if (empty($num_days_difference)) |
|
532 | - $difference = $txt['viewmembers_today']; |
|
545 | + if (empty($num_days_difference)) { |
|
546 | + $difference = $txt['viewmembers_today']; |
|
547 | + } |
|
533 | 548 | |
534 | 549 | // Yesterday. |
535 | - elseif ($num_days_difference == 1) |
|
536 | - $difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']); |
|
550 | + elseif ($num_days_difference == 1) { |
|
551 | + $difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']); |
|
552 | + } |
|
537 | 553 | |
538 | 554 | // X days ago. |
539 | - else |
|
540 | - $difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']); |
|
555 | + else { |
|
556 | + $difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']); |
|
557 | + } |
|
541 | 558 | } |
542 | 559 | |
543 | 560 | // Show it in italics if they're not activated... |
544 | - if ($rowData['is_activated'] % 10 != 1) |
|
545 | - $difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference); |
|
561 | + if ($rowData['is_activated'] % 10 != 1) { |
|
562 | + $difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference); |
|
563 | + } |
|
546 | 564 | |
547 | 565 | return $difference; |
548 | 566 | }, |
@@ -594,8 +612,9 @@ discard block |
||
594 | 612 | ); |
595 | 613 | |
596 | 614 | // Without enough permissions, don't show 'delete members' checkboxes. |
597 | - if (!allowedTo('profile_remove_any')) |
|
598 | - unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']); |
|
615 | + if (!allowedTo('profile_remove_any')) { |
|
616 | + unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']); |
|
617 | + } |
|
599 | 618 | |
600 | 619 | require_once($sourcedir . '/Subs-List.php'); |
601 | 620 | createList($listOptions); |
@@ -638,17 +657,18 @@ discard block |
||
638 | 657 | ); |
639 | 658 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
640 | 659 | { |
641 | - if ($row['min_posts'] == -1) |
|
642 | - $context['membergroups'][] = array( |
|
660 | + if ($row['min_posts'] == -1) { |
|
661 | + $context['membergroups'][] = array( |
|
643 | 662 | 'id' => $row['id_group'], |
644 | 663 | 'name' => $row['group_name'], |
645 | 664 | 'can_be_additional' => true |
646 | 665 | ); |
647 | - else |
|
648 | - $context['postgroups'][] = array( |
|
666 | + } else { |
|
667 | + $context['postgroups'][] = array( |
|
649 | 668 | 'id' => $row['id_group'], |
650 | 669 | 'name' => $row['group_name'] |
651 | 670 | ); |
671 | + } |
|
652 | 672 | } |
653 | 673 | $smcFunc['db_free_result']($request); |
654 | 674 | |
@@ -675,8 +695,9 @@ discard block |
||
675 | 695 | $context['page_title'] = $txt['admin_members']; |
676 | 696 | $context['sub_template'] = 'admin_browse'; |
677 | 697 | $context['browse_type'] = isset($_REQUEST['type']) ? $_REQUEST['type'] : (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1 ? 'activate' : 'approve'); |
678 | - if (isset($context['tabs'][$context['browse_type']])) |
|
679 | - $context['tabs'][$context['browse_type']]['is_selected'] = true; |
|
698 | + if (isset($context['tabs'][$context['browse_type']])) { |
|
699 | + $context['tabs'][$context['browse_type']]['is_selected'] = true; |
|
700 | + } |
|
680 | 701 | |
681 | 702 | // Allowed filters are those we can have, in theory. |
682 | 703 | $context['allowed_filters'] = $context['browse_type'] == 'approve' ? array(3, 4, 5) : array(0, 2); |
@@ -687,18 +708,20 @@ discard block |
||
687 | 708 | foreach ($context['activation_numbers'] as $type => $amount) |
688 | 709 | { |
689 | 710 | // We have some of these... |
690 | - if (in_array($type, $context['allowed_filters']) && $amount > 0) |
|
691 | - $context['available_filters'][] = array( |
|
711 | + if (in_array($type, $context['allowed_filters']) && $amount > 0) { |
|
712 | + $context['available_filters'][] = array( |
|
692 | 713 | 'type' => $type, |
693 | 714 | 'amount' => $amount, |
694 | 715 | 'desc' => isset($txt['admin_browse_filter_type_' . $type]) ? $txt['admin_browse_filter_type_' . $type] : '?', |
695 | 716 | 'selected' => $type == $context['current_filter'] |
696 | 717 | ); |
718 | + } |
|
697 | 719 | } |
698 | 720 | |
699 | 721 | // If the filter was not sent, set it to whatever has people in it! |
700 | - if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) |
|
701 | - $context['current_filter'] = $context['available_filters'][0]['type']; |
|
722 | + if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) { |
|
723 | + $context['current_filter'] = $context['available_filters'][0]['type']; |
|
724 | + } |
|
702 | 725 | |
703 | 726 | // This little variable is used to determine if we should flag where we are looking. |
704 | 727 | $context['show_filter'] = ($context['current_filter'] != 0 && $context['current_filter'] != 3) || count($context['available_filters']) > 1; |
@@ -713,44 +736,47 @@ discard block |
||
713 | 736 | ); |
714 | 737 | |
715 | 738 | // Are we showing duplicate information? |
716 | - if (isset($_GET['showdupes'])) |
|
717 | - $_SESSION['showdupes'] = (int) $_GET['showdupes']; |
|
739 | + if (isset($_GET['showdupes'])) { |
|
740 | + $_SESSION['showdupes'] = (int) $_GET['showdupes']; |
|
741 | + } |
|
718 | 742 | $context['show_duplicates'] = !empty($_SESSION['showdupes']); |
719 | 743 | |
720 | 744 | // Determine which actions we should allow on this page. |
721 | 745 | if ($context['browse_type'] == 'approve') |
722 | 746 | { |
723 | 747 | // If we are approving deleted accounts we have a slightly different list... actually a mirror ;) |
724 | - if ($context['current_filter'] == 4) |
|
725 | - $context['allowed_actions'] = array( |
|
748 | + if ($context['current_filter'] == 4) { |
|
749 | + $context['allowed_actions'] = array( |
|
726 | 750 | 'reject' => $txt['admin_browse_w_approve_deletion'], |
727 | 751 | 'ok' => $txt['admin_browse_w_reject'], |
728 | 752 | ); |
729 | - else |
|
730 | - $context['allowed_actions'] = array( |
|
753 | + } else { |
|
754 | + $context['allowed_actions'] = array( |
|
731 | 755 | 'ok' => $txt['admin_browse_w_approve'], |
732 | 756 | 'okemail' => $txt['admin_browse_w_approve'] . ' ' . $txt['admin_browse_w_email'], |
733 | 757 | 'require_activation' => $txt['admin_browse_w_approve_require_activate'], |
734 | 758 | 'reject' => $txt['admin_browse_w_reject'], |
735 | 759 | 'rejectemail' => $txt['admin_browse_w_reject'] . ' ' . $txt['admin_browse_w_email'], |
736 | 760 | ); |
737 | - } |
|
738 | - elseif ($context['browse_type'] == 'activate') |
|
739 | - $context['allowed_actions'] = array( |
|
761 | + } |
|
762 | + } elseif ($context['browse_type'] == 'activate') { |
|
763 | + $context['allowed_actions'] = array( |
|
740 | 764 | 'ok' => $txt['admin_browse_w_activate'], |
741 | 765 | 'okemail' => $txt['admin_browse_w_activate'] . ' ' . $txt['admin_browse_w_email'], |
742 | 766 | 'delete' => $txt['admin_browse_w_delete'], |
743 | 767 | 'deleteemail' => $txt['admin_browse_w_delete'] . ' ' . $txt['admin_browse_w_email'], |
744 | 768 | 'remind' => $txt['admin_browse_w_remind'] . ' ' . $txt['admin_browse_w_email'], |
745 | 769 | ); |
770 | + } |
|
746 | 771 | |
747 | 772 | // Create an option list for actions allowed to be done with selected members. |
748 | 773 | $allowed_actions = ' |
749 | 774 | <option selected value="">' . $txt['admin_browse_with_selected'] . ':</option> |
750 | 775 | <option value="" disabled>-----------------------------</option>'; |
751 | - foreach ($context['allowed_actions'] as $key => $desc) |
|
752 | - $allowed_actions .= ' |
|
776 | + foreach ($context['allowed_actions'] as $key => $desc) { |
|
777 | + $allowed_actions .= ' |
|
753 | 778 | <option value="' . $key . '">' . $desc . '</option>'; |
779 | + } |
|
754 | 780 | |
755 | 781 | // Setup the Javascript function for selecting an action for the list. |
756 | 782 | $javascript = ' |
@@ -762,15 +788,16 @@ discard block |
||
762 | 788 | var message = "";'; |
763 | 789 | |
764 | 790 | // We have special messages for approving deletion of accounts - it's surprisingly logical - honest. |
765 | - if ($context['current_filter'] == 4) |
|
766 | - $javascript .= ' |
|
791 | + if ($context['current_filter'] == 4) { |
|
792 | + $javascript .= ' |
|
767 | 793 | if (document.forms.postForm.todo.value.indexOf("reject") != -1) |
768 | 794 | message = "' . $txt['admin_browse_w_delete'] . '"; |
769 | 795 | else |
770 | 796 | message = "' . $txt['admin_browse_w_reject'] . '";'; |
797 | + } |
|
771 | 798 | // Otherwise a nice standard message. |
772 | - else |
|
773 | - $javascript .= ' |
|
799 | + else { |
|
800 | + $javascript .= ' |
|
774 | 801 | if (document.forms.postForm.todo.value.indexOf("delete") != -1) |
775 | 802 | message = "' . $txt['admin_browse_w_delete'] . '"; |
776 | 803 | else if (document.forms.postForm.todo.value.indexOf("reject") != -1) |
@@ -779,6 +806,7 @@ discard block |
||
779 | 806 | message = "' . $txt['admin_browse_w_remind'] . '"; |
780 | 807 | else |
781 | 808 | message = "' . ($context['browse_type'] == 'approve' ? $txt['admin_browse_w_approve'] : $txt['admin_browse_w_activate']) . '";'; |
809 | + } |
|
782 | 810 | $javascript .= ' |
783 | 811 | if (confirm(message + " ' . $txt['admin_browse_warn'] . '")) |
784 | 812 | document.forms.postForm.submit(); |
@@ -911,10 +939,11 @@ discard block |
||
911 | 939 | $member_links = array(); |
912 | 940 | foreach ($rowData['duplicate_members'] as $member) |
913 | 941 | { |
914 | - if ($member['id']) |
|
915 | - $member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>'; |
|
916 | - else |
|
917 | - $member_links[] = $member['name'] . ' (' . $txt['guest'] . ')'; |
|
942 | + if ($member['id']) { |
|
943 | + $member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>'; |
|
944 | + } else { |
|
945 | + $member_links[] = $member['name'] . ' (' . $txt['guest'] . ')'; |
|
946 | + } |
|
918 | 947 | } |
919 | 948 | return implode(', ', $member_links); |
920 | 949 | }, |
@@ -963,14 +992,16 @@ discard block |
||
963 | 992 | ); |
964 | 993 | |
965 | 994 | // Pick what column to actually include if we're showing duplicates. |
966 | - if ($context['show_duplicates']) |
|
967 | - unset($listOptions['columns']['email']); |
|
968 | - else |
|
969 | - unset($listOptions['columns']['duplicates']); |
|
995 | + if ($context['show_duplicates']) { |
|
996 | + unset($listOptions['columns']['email']); |
|
997 | + } else { |
|
998 | + unset($listOptions['columns']['duplicates']); |
|
999 | + } |
|
970 | 1000 | |
971 | 1001 | // Only show hostname on duplicates as it takes a lot of time. |
972 | - if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) |
|
973 | - unset($listOptions['columns']['hostname']); |
|
1002 | + if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) { |
|
1003 | + unset($listOptions['columns']['hostname']); |
|
1004 | + } |
|
974 | 1005 | |
975 | 1006 | // Is there any need to show filters? |
976 | 1007 | if (isset($context['available_filters']) && count($context['available_filters']) > 1) |
@@ -978,9 +1009,10 @@ discard block |
||
978 | 1009 | $filterOptions = ' |
979 | 1010 | <strong>' . $txt['admin_browse_filter_by'] . ':</strong> |
980 | 1011 | <select name="filter" onchange="this.form.submit();">'; |
981 | - foreach ($context['available_filters'] as $filter) |
|
982 | - $filterOptions .= ' |
|
1012 | + foreach ($context['available_filters'] as $filter) { |
|
1013 | + $filterOptions .= ' |
|
983 | 1014 | <option value="' . $filter['type'] . '"' . ($filter['selected'] ? ' selected' : '') . '>' . $filter['desc'] . ' - ' . $filter['amount'] . ' ' . ($filter['amount'] == 1 ? $txt['user'] : $txt['users']) . '</option>'; |
1015 | + } |
|
984 | 1016 | $filterOptions .= ' |
985 | 1017 | </select> |
986 | 1018 | <noscript><input type="submit" value="' . $txt['go'] . '" name="filter" class="button_submit"></noscript>'; |
@@ -992,12 +1024,13 @@ discard block |
||
992 | 1024 | } |
993 | 1025 | |
994 | 1026 | // What about if we only have one filter, but it's not the "standard" filter - show them what they are looking at. |
995 | - if (!empty($context['show_filter']) && !empty($context['available_filters'])) |
|
996 | - $listOptions['additional_rows'][] = array( |
|
1027 | + if (!empty($context['show_filter']) && !empty($context['available_filters'])) { |
|
1028 | + $listOptions['additional_rows'][] = array( |
|
997 | 1029 | 'position' => 'above_column_headers', |
998 | 1030 | 'value' => '<strong>' . $txt['admin_browse_filter_show'] . ':</strong> ' . $context['available_filters'][0]['desc'], |
999 | 1031 | 'class' => 'smalltext floatright', |
1000 | 1032 | ); |
1033 | + } |
|
1001 | 1034 | |
1002 | 1035 | // Now that we have all the options, create the list. |
1003 | 1036 | require_once($sourcedir . '/Subs-List.php'); |
@@ -1028,12 +1061,14 @@ discard block |
||
1028 | 1061 | $current_filter = (int) $_REQUEST['orig_filter']; |
1029 | 1062 | |
1030 | 1063 | // If we are applying a filter do just that - then redirect. |
1031 | - if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) |
|
1032 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']); |
|
1064 | + if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) { |
|
1065 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']); |
|
1066 | + } |
|
1033 | 1067 | |
1034 | 1068 | // Nothing to do? |
1035 | - if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) |
|
1036 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1069 | + if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) { |
|
1070 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1071 | + } |
|
1037 | 1072 | |
1038 | 1073 | // Are we dealing with members who have been waiting for > set amount of time? |
1039 | 1074 | if (isset($_POST['time_passed'])) |
@@ -1046,8 +1081,9 @@ discard block |
||
1046 | 1081 | else |
1047 | 1082 | { |
1048 | 1083 | $members = array(); |
1049 | - foreach ($_POST['todoAction'] as $id) |
|
1050 | - $members[] = (int) $id; |
|
1084 | + foreach ($_POST['todoAction'] as $id) { |
|
1085 | + $members[] = (int) $id; |
|
1086 | + } |
|
1051 | 1087 | $condition = ' |
1052 | 1088 | AND id_member IN ({array_int:members})'; |
1053 | 1089 | } |
@@ -1068,8 +1104,9 @@ discard block |
||
1068 | 1104 | $member_count = $smcFunc['db_num_rows']($request); |
1069 | 1105 | |
1070 | 1106 | // If no results then just return! |
1071 | - if ($member_count == 0) |
|
1072 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1107 | + if ($member_count == 0) { |
|
1108 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1109 | + } |
|
1073 | 1110 | |
1074 | 1111 | $member_info = array(); |
1075 | 1112 | $members = array(); |
@@ -1108,8 +1145,9 @@ discard block |
||
1108 | 1145 | // Do we have to let the integration code know about the activations? |
1109 | 1146 | if (!empty($modSettings['integrate_activate'])) |
1110 | 1147 | { |
1111 | - foreach ($member_info as $member) |
|
1112 | - call_integration_hook('integrate_activate', array($member['username'])); |
|
1148 | + foreach ($member_info as $member) { |
|
1149 | + call_integration_hook('integrate_activate', array($member['username'])); |
|
1150 | + } |
|
1113 | 1151 | } |
1114 | 1152 | |
1115 | 1153 | // Check for email. |
@@ -1240,20 +1278,23 @@ discard block |
||
1240 | 1278 | $log_inserts = array(); |
1241 | 1279 | |
1242 | 1280 | require_once($sourcedir . '/Logging.php'); |
1243 | - foreach ($member_info as $member) |
|
1244 | - logAction($log_action, array('member' => $member['id']), 'admin'); |
|
1281 | + foreach ($member_info as $member) { |
|
1282 | + logAction($log_action, array('member' => $member['id']), 'admin'); |
|
1283 | + } |
|
1245 | 1284 | } |
1246 | 1285 | |
1247 | 1286 | // Although updateStats *may* catch this, best to do it manually just in case (Doesn't always sort out unapprovedMembers). |
1248 | - if (in_array($current_filter, array(3, 4, 5))) |
|
1249 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0))); |
|
1287 | + if (in_array($current_filter, array(3, 4, 5))) { |
|
1288 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0))); |
|
1289 | + } |
|
1250 | 1290 | |
1251 | 1291 | // Update the member's stats. (but, we know the member didn't change their name.) |
1252 | 1292 | updateStats('member', false); |
1253 | 1293 | |
1254 | 1294 | // If they haven't been deleted, update the post group statistics on them... |
1255 | - if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) |
|
1256 | - updateStats('postgroups', $members); |
|
1295 | + if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) { |
|
1296 | + updateStats('postgroups', $members); |
|
1297 | + } |
|
1257 | 1298 | |
1258 | 1299 | redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
1259 | 1300 | } |
@@ -1278,10 +1319,11 @@ discard block |
||
1278 | 1319 | $dis = time() - $old; |
1279 | 1320 | |
1280 | 1321 | // Before midnight? |
1281 | - if ($dis < $sinceMidnight) |
|
1282 | - return 0; |
|
1283 | - else |
|
1284 | - $dis -= $sinceMidnight; |
|
1322 | + if ($dis < $sinceMidnight) { |
|
1323 | + return 0; |
|
1324 | + } else { |
|
1325 | + $dis -= $sinceMidnight; |
|
1326 | + } |
|
1285 | 1327 | |
1286 | 1328 | // Divide out the seconds in a day to get the number of days. |
1287 | 1329 | return ceil($dis / (24 * 60 * 60)); |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 3 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * This defines every profile field known to man. |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | global $sourcedir, $profile_vars; |
30 | 31 | |
31 | 32 | // Don't load this twice! |
32 | - if (!empty($profile_fields) && !$force_reload) |
|
33 | - return; |
|
33 | + if (!empty($profile_fields) && !$force_reload) { |
|
34 | + return; |
|
35 | + } |
|
34 | 36 | |
35 | 37 | /* This horrific array defines all the profile fields in the whole world! |
36 | 38 | In general each "field" has one array - the key of which is the database column name associated with said field. Each item |
@@ -103,13 +105,14 @@ discard block |
||
103 | 105 | if (isset($_POST['bday2'], $_POST['bday3']) && $value > 0 && $_POST['bday2'] > 0) |
104 | 106 | { |
105 | 107 | // Set to blank? |
106 | - if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) |
|
107 | - $value = '0001-01-01'; |
|
108 | - else |
|
109 | - $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 4 ? 4 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 4 ? 4 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '0001-01-01'; |
|
108 | + if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) { |
|
109 | + $value = '0001-01-01'; |
|
110 | + } else { |
|
111 | + $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 4 ? 4 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 4 ? 4 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '0001-01-01'; |
|
112 | + } |
|
113 | + } else { |
|
114 | + $value = '0001-01-01'; |
|
110 | 115 | } |
111 | - else |
|
112 | - $value = '0001-01-01'; |
|
113 | 116 | |
114 | 117 | $profile_vars['birthdate'] = $value; |
115 | 118 | $cur_profile['birthdate'] = $value; |
@@ -127,8 +130,7 @@ discard block |
||
127 | 130 | { |
128 | 131 | $value = checkdate($dates[2], $dates[3], $dates[1] < 4 ? 4 : $dates[1]) ? sprintf('%04d-%02d-%02d', $dates[1] < 4 ? 4 : $dates[1], $dates[2], $dates[3]) : '0001-01-01'; |
129 | 132 | return true; |
130 | - } |
|
131 | - else |
|
133 | + } else |
|
132 | 134 | { |
133 | 135 | $value = empty($cur_profile['birthdate']) ? '0001-01-01' : $cur_profile['birthdate']; |
134 | 136 | return false; |
@@ -150,10 +152,11 @@ discard block |
||
150 | 152 | return $txt['invalid_registration'] . ' ' . strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%H:%M:%S'), forum_time(false)); |
151 | 153 | } |
152 | 154 | // As long as it doesn't equal "N/A"... |
153 | - elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) |
|
154 | - $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
155 | - else |
|
156 | - $value = $cur_profile['date_registered']; |
|
155 | + elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) { |
|
156 | + $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
157 | + } else { |
|
158 | + $value = $cur_profile['date_registered']; |
|
159 | + } |
|
157 | 160 | |
158 | 161 | return true; |
159 | 162 | }, |
@@ -177,8 +180,9 @@ discard block |
||
177 | 180 | { |
178 | 181 | global $context, $old_profile, $profile_vars, $sourcedir, $modSettings; |
179 | 182 | |
180 | - if (strtolower($value) == strtolower($old_profile['email_address'])) |
|
181 | - return false; |
|
183 | + if (strtolower($value) == strtolower($old_profile['email_address'])) { |
|
184 | + return false; |
|
185 | + } |
|
182 | 186 | |
183 | 187 | $isValid = profileValidateEmail($value, $context['id_member']); |
184 | 188 | |
@@ -254,11 +258,11 @@ discard block |
||
254 | 258 | |
255 | 259 | if (isset($context['profile_languages'][$value])) |
256 | 260 | { |
257 | - if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) |
|
258 | - $_SESSION['language'] = $value; |
|
261 | + if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) { |
|
262 | + $_SESSION['language'] = $value; |
|
263 | + } |
|
259 | 264 | return true; |
260 | - } |
|
261 | - else |
|
265 | + } else |
|
262 | 266 | { |
263 | 267 | $value = $cur_profile['lngfile']; |
264 | 268 | return false; |
@@ -282,13 +286,14 @@ discard block |
||
282 | 286 | |
283 | 287 | // Maybe they are trying to change their password as well? |
284 | 288 | $resetPassword = true; |
285 | - if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) |
|
286 | - $resetPassword = false; |
|
289 | + if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) { |
|
290 | + $resetPassword = false; |
|
291 | + } |
|
287 | 292 | |
288 | 293 | // Do the reset... this will send them an email too. |
289 | - if ($resetPassword) |
|
290 | - resetPassword($context['id_member'], $value); |
|
291 | - elseif ($value !== null) |
|
294 | + if ($resetPassword) { |
|
295 | + resetPassword($context['id_member'], $value); |
|
296 | + } elseif ($value !== null) |
|
292 | 297 | { |
293 | 298 | validateUsername($context['id_member'], trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value))); |
294 | 299 | updateMemberData($context['id_member'], array('member_name' => $value)); |
@@ -312,20 +317,23 @@ discard block |
||
312 | 317 | 'input_validate' => function(&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile) |
313 | 318 | { |
314 | 319 | // If we didn't try it then ignore it! |
315 | - if ($value == '') |
|
316 | - return false; |
|
320 | + if ($value == '') { |
|
321 | + return false; |
|
322 | + } |
|
317 | 323 | |
318 | 324 | // Do the two entries for the password even match? |
319 | - if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) |
|
320 | - return 'bad_new_password'; |
|
325 | + if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) { |
|
326 | + return 'bad_new_password'; |
|
327 | + } |
|
321 | 328 | |
322 | 329 | // Let's get the validation function into play... |
323 | 330 | require_once($sourcedir . '/Subs-Auth.php'); |
324 | 331 | $passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])); |
325 | 332 | |
326 | 333 | // Were there errors? |
327 | - if ($passwordErrors != null) |
|
328 | - return 'password_' . $passwordErrors; |
|
334 | + if ($passwordErrors != null) { |
|
335 | + return 'password_' . $passwordErrors; |
|
336 | + } |
|
329 | 337 | |
330 | 338 | // Set up the new password variable... ready for storage. |
331 | 339 | $value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value)); |
@@ -350,8 +358,9 @@ discard block |
||
350 | 358 | 'permission' => 'profile_blurb', |
351 | 359 | 'input_validate' => function(&$value) use ($smcFunc) |
352 | 360 | { |
353 | - if ($smcFunc['strlen']($value) > 50) |
|
354 | - return 'personal_text_too_long'; |
|
361 | + if ($smcFunc['strlen']($value) > 50) { |
|
362 | + return 'personal_text_too_long'; |
|
363 | + } |
|
355 | 364 | |
356 | 365 | return true; |
357 | 366 | }, |
@@ -386,10 +395,11 @@ discard block |
||
386 | 395 | 'permission' => 'moderate_forum', |
387 | 396 | 'input_validate' => function(&$value) |
388 | 397 | { |
389 | - if (!is_numeric($value)) |
|
390 | - return 'digits_only'; |
|
391 | - else |
|
392 | - $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
398 | + if (!is_numeric($value)) { |
|
399 | + return 'digits_only'; |
|
400 | + } else { |
|
401 | + $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
402 | + } |
|
393 | 403 | return true; |
394 | 404 | }, |
395 | 405 | ), |
@@ -405,15 +415,16 @@ discard block |
||
405 | 415 | { |
406 | 416 | $value = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value)); |
407 | 417 | |
408 | - if (trim($value) == '') |
|
409 | - return 'no_name'; |
|
410 | - elseif ($smcFunc['strlen']($value) > 60) |
|
411 | - return 'name_too_long'; |
|
412 | - elseif ($cur_profile['real_name'] != $value) |
|
418 | + if (trim($value) == '') { |
|
419 | + return 'no_name'; |
|
420 | + } elseif ($smcFunc['strlen']($value) > 60) { |
|
421 | + return 'name_too_long'; |
|
422 | + } elseif ($cur_profile['real_name'] != $value) |
|
413 | 423 | { |
414 | 424 | require_once($sourcedir . '/Subs-Members.php'); |
415 | - if (isReservedName($value, $context['id_member'])) |
|
416 | - return 'name_taken'; |
|
425 | + if (isReservedName($value, $context['id_member'])) { |
|
426 | + return 'name_taken'; |
|
427 | + } |
|
417 | 428 | } |
418 | 429 | return true; |
419 | 430 | }, |
@@ -471,8 +482,9 @@ discard block |
||
471 | 482 | 'selected' => $set == $context['member']['smiley_set']['id'] |
472 | 483 | ); |
473 | 484 | |
474 | - if ($context['smiley_sets'][$i]['selected']) |
|
475 | - $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
485 | + if ($context['smiley_sets'][$i]['selected']) { |
|
486 | + $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
487 | + } |
|
476 | 488 | } |
477 | 489 | return true; |
478 | 490 | }, |
@@ -481,8 +493,9 @@ discard block |
||
481 | 493 | global $modSettings; |
482 | 494 | |
483 | 495 | $smiley_sets = explode(',', $modSettings['smiley_sets_known']); |
484 | - if (!in_array($value, $smiley_sets) && $value != 'none') |
|
485 | - $value = ''; |
|
496 | + if (!in_array($value, $smiley_sets) && $value != 'none') { |
|
497 | + $value = ''; |
|
498 | + } |
|
486 | 499 | return true; |
487 | 500 | }, |
488 | 501 | ), |
@@ -497,8 +510,9 @@ discard block |
||
497 | 510 | loadLanguage('Settings'); |
498 | 511 | |
499 | 512 | $context['allow_no_censored'] = false; |
500 | - if ($user_info['is_admin'] || $context['user']['is_owner']) |
|
501 | - $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
513 | + if ($user_info['is_admin'] || $context['user']['is_owner']) { |
|
514 | + $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
515 | + } |
|
502 | 516 | |
503 | 517 | return true; |
504 | 518 | }, |
@@ -545,8 +559,9 @@ discard block |
||
545 | 559 | 'input_validate' => function($value) |
546 | 560 | { |
547 | 561 | $tz = smf_list_timezones(); |
548 | - if (!isset($tz[$value])) |
|
549 | - return 'bad_timezone'; |
|
562 | + if (!isset($tz[$value])) { |
|
563 | + return 'bad_timezone'; |
|
564 | + } |
|
550 | 565 | |
551 | 566 | return true; |
552 | 567 | }, |
@@ -561,8 +576,9 @@ discard block |
||
561 | 576 | 'enabled' => !empty($modSettings['titlesEnable']), |
562 | 577 | 'input_validate' => function(&$value) use ($smcFunc) |
563 | 578 | { |
564 | - if ($smcFunc['strlen']($value) > 50) |
|
565 | - return 'user_title_too_long'; |
|
579 | + if ($smcFunc['strlen']($value) > 50) { |
|
580 | + return 'user_title_too_long'; |
|
581 | + } |
|
566 | 582 | |
567 | 583 | return true; |
568 | 584 | }, |
@@ -584,10 +600,12 @@ discard block |
||
584 | 600 | // Fix the URL... |
585 | 601 | 'input_validate' => function(&$value) |
586 | 602 | { |
587 | - if (strlen(trim($value)) > 0 && strpos($value, '://') === false) |
|
588 | - $value = 'http://' . $value; |
|
589 | - if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) |
|
590 | - $value = ''; |
|
603 | + if (strlen(trim($value)) > 0 && strpos($value, '://') === false) { |
|
604 | + $value = 'http://' . $value; |
|
605 | + } |
|
606 | + if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) { |
|
607 | + $value = ''; |
|
608 | + } |
|
591 | 609 | return true; |
592 | 610 | }, |
593 | 611 | 'link_with' => 'website', |
@@ -601,16 +619,19 @@ discard block |
||
601 | 619 | foreach ($profile_fields as $key => $field) |
602 | 620 | { |
603 | 621 | // Do we have permission to do this? |
604 | - if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) |
|
605 | - unset($profile_fields[$key]); |
|
622 | + if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) { |
|
623 | + unset($profile_fields[$key]); |
|
624 | + } |
|
606 | 625 | |
607 | 626 | // Is it enabled? |
608 | - if (isset($field['enabled']) && !$field['enabled']) |
|
609 | - unset($profile_fields[$key]); |
|
627 | + if (isset($field['enabled']) && !$field['enabled']) { |
|
628 | + unset($profile_fields[$key]); |
|
629 | + } |
|
610 | 630 | |
611 | 631 | // Is it specifically disabled? |
612 | - if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) |
|
613 | - unset($profile_fields[$key]); |
|
632 | + if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) { |
|
633 | + unset($profile_fields[$key]); |
|
634 | + } |
|
614 | 635 | } |
615 | 636 | } |
616 | 637 | |
@@ -635,9 +656,10 @@ discard block |
||
635 | 656 | loadProfileFields(true); |
636 | 657 | |
637 | 658 | // First check for any linked sets. |
638 | - foreach ($profile_fields as $key => $field) |
|
639 | - if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
659 | + foreach ($profile_fields as $key => $field) { |
|
660 | + if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
640 | 661 | $fields[] = $key; |
662 | + } |
|
641 | 663 | |
642 | 664 | $i = 0; |
643 | 665 | $last_type = ''; |
@@ -649,38 +671,46 @@ discard block |
||
649 | 671 | $cur_field = &$profile_fields[$field]; |
650 | 672 | |
651 | 673 | // Does it have a preload and does that preload succeed? |
652 | - if (isset($cur_field['preload']) && !$cur_field['preload']()) |
|
653 | - continue; |
|
674 | + if (isset($cur_field['preload']) && !$cur_field['preload']()) { |
|
675 | + continue; |
|
676 | + } |
|
654 | 677 | |
655 | 678 | // If this is anything but complex we need to do more cleaning! |
656 | 679 | if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden') |
657 | 680 | { |
658 | - if (!isset($cur_field['label'])) |
|
659 | - $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
681 | + if (!isset($cur_field['label'])) { |
|
682 | + $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
683 | + } |
|
660 | 684 | |
661 | 685 | // Everything has a value! |
662 | - if (!isset($cur_field['value'])) |
|
663 | - $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
686 | + if (!isset($cur_field['value'])) { |
|
687 | + $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
688 | + } |
|
664 | 689 | |
665 | 690 | // Any input attributes? |
666 | 691 | $cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : ''; |
667 | 692 | } |
668 | 693 | |
669 | 694 | // Was there an error with this field on posting? |
670 | - if (isset($context['profile_errors'][$field])) |
|
671 | - $cur_field['is_error'] = true; |
|
695 | + if (isset($context['profile_errors'][$field])) { |
|
696 | + $cur_field['is_error'] = true; |
|
697 | + } |
|
672 | 698 | |
673 | 699 | // Any javascript stuff? |
674 | - if (!empty($cur_field['js_submit'])) |
|
675 | - $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
676 | - if (!empty($cur_field['js'])) |
|
677 | - $context['profile_javascript'] .= $cur_field['js']; |
|
700 | + if (!empty($cur_field['js_submit'])) { |
|
701 | + $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
702 | + } |
|
703 | + if (!empty($cur_field['js'])) { |
|
704 | + $context['profile_javascript'] .= $cur_field['js']; |
|
705 | + } |
|
678 | 706 | |
679 | 707 | // Any template stuff? |
680 | - if (!empty($cur_field['prehtml'])) |
|
681 | - $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
682 | - if (!empty($cur_field['posthtml'])) |
|
683 | - $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
708 | + if (!empty($cur_field['prehtml'])) { |
|
709 | + $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
710 | + } |
|
711 | + if (!empty($cur_field['posthtml'])) { |
|
712 | + $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
713 | + } |
|
684 | 714 | |
685 | 715 | // Finally put it into context? |
686 | 716 | if ($cur_field['type'] != 'hidden') |
@@ -713,12 +743,14 @@ discard block |
||
713 | 743 | }, false);' : ''), true); |
714 | 744 | |
715 | 745 | // Any onsubmit javascript? |
716 | - if (!empty($context['profile_onsubmit_javascript'])) |
|
717 | - addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
746 | + if (!empty($context['profile_onsubmit_javascript'])) { |
|
747 | + addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
748 | + } |
|
718 | 749 | |
719 | 750 | // Any totally custom stuff? |
720 | - if (!empty($context['profile_javascript'])) |
|
721 | - addInlineJavaScript($context['profile_javascript'], true); |
|
751 | + if (!empty($context['profile_javascript'])) { |
|
752 | + addInlineJavaScript($context['profile_javascript'], true); |
|
753 | + } |
|
722 | 754 | |
723 | 755 | // Free up some memory. |
724 | 756 | unset($profile_fields); |
@@ -739,8 +771,9 @@ discard block |
||
739 | 771 | |
740 | 772 | // This allows variables to call activities when they save - by default just to reload their settings |
741 | 773 | $context['profile_execute_on_save'] = array(); |
742 | - if ($context['user']['is_owner']) |
|
743 | - $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
774 | + if ($context['user']['is_owner']) { |
|
775 | + $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
776 | + } |
|
744 | 777 | |
745 | 778 | // Assume we log nothing. |
746 | 779 | $context['log_changes'] = array(); |
@@ -748,8 +781,9 @@ discard block |
||
748 | 781 | // Cycle through the profile fields working out what to do! |
749 | 782 | foreach ($profile_fields as $key => $field) |
750 | 783 | { |
751 | - if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) |
|
752 | - continue; |
|
784 | + if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) { |
|
785 | + continue; |
|
786 | + } |
|
753 | 787 | |
754 | 788 | // What gets updated? |
755 | 789 | $db_key = isset($field['save_key']) ? $field['save_key'] : $key; |
@@ -777,12 +811,13 @@ discard block |
||
777 | 811 | $field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type']; |
778 | 812 | |
779 | 813 | // Finally, clean up certain types. |
780 | - if ($field['cast_type'] == 'int') |
|
781 | - $_POST[$key] = (int) $_POST[$key]; |
|
782 | - elseif ($field['cast_type'] == 'float') |
|
783 | - $_POST[$key] = (float) $_POST[$key]; |
|
784 | - elseif ($field['cast_type'] == 'check') |
|
785 | - $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
814 | + if ($field['cast_type'] == 'int') { |
|
815 | + $_POST[$key] = (int) $_POST[$key]; |
|
816 | + } elseif ($field['cast_type'] == 'float') { |
|
817 | + $_POST[$key] = (float) $_POST[$key]; |
|
818 | + } elseif ($field['cast_type'] == 'check') { |
|
819 | + $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
820 | + } |
|
786 | 821 | |
787 | 822 | // If we got here we're doing OK. |
788 | 823 | if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key])) |
@@ -793,11 +828,12 @@ discard block |
||
793 | 828 | $cur_profile[$key] = $_POST[$key]; |
794 | 829 | |
795 | 830 | // Are we logging it? |
796 | - if (!empty($field['log_change']) && isset($old_profile[$key])) |
|
797 | - $context['log_changes'][$key] = array( |
|
831 | + if (!empty($field['log_change']) && isset($old_profile[$key])) { |
|
832 | + $context['log_changes'][$key] = array( |
|
798 | 833 | 'previous' => $old_profile[$key], |
799 | 834 | 'new' => $_POST[$key], |
800 | 835 | ); |
836 | + } |
|
801 | 837 | } |
802 | 838 | |
803 | 839 | // Logging group changes are a bit different... |
@@ -830,10 +866,11 @@ discard block |
||
830 | 866 | { |
831 | 867 | foreach ($groups as $id => $group) |
832 | 868 | { |
833 | - if (isset($context['member_groups'][$group])) |
|
834 | - $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
835 | - else |
|
836 | - unset($additional_groups[$type][$id]); |
|
869 | + if (isset($context['member_groups'][$group])) { |
|
870 | + $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
871 | + } else { |
|
872 | + unset($additional_groups[$type][$id]); |
|
873 | + } |
|
837 | 874 | } |
838 | 875 | $additional_groups[$type] = implode(', ', $additional_groups[$type]); |
839 | 876 | } |
@@ -844,10 +881,11 @@ discard block |
||
844 | 881 | } |
845 | 882 | |
846 | 883 | // @todo Temporary |
847 | - if ($context['user']['is_owner']) |
|
848 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
849 | - else |
|
850 | - $changeOther = allowedTo('profile_extra_any'); |
|
884 | + if ($context['user']['is_owner']) { |
|
885 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
886 | + } else { |
|
887 | + $changeOther = allowedTo('profile_extra_any'); |
|
888 | + } |
|
851 | 889 | if ($changeOther && empty($post_errors)) |
852 | 890 | { |
853 | 891 | makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
@@ -855,8 +893,9 @@ discard block |
||
855 | 893 | { |
856 | 894 | $custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true); |
857 | 895 | |
858 | - if (!empty($custom_fields_errors)) |
|
859 | - $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
896 | + if (!empty($custom_fields_errors)) { |
|
897 | + $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
898 | + } |
|
860 | 899 | } |
861 | 900 | } |
862 | 901 | |
@@ -883,8 +922,7 @@ discard block |
||
883 | 922 | { |
884 | 923 | $changeIdentity = allowedTo(array('profile_identity_any', 'profile_identity_own', 'profile_password_any', 'profile_password_own')); |
885 | 924 | $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own')); |
886 | - } |
|
887 | - else |
|
925 | + } else |
|
888 | 926 | { |
889 | 927 | $changeIdentity = allowedTo('profile_identity_any', 'profile_signature_any'); |
890 | 928 | $changeOther = allowedTo('profile_extra_any', 'profile_website_any', 'profile_signature_any'); |
@@ -899,22 +937,25 @@ discard block |
||
899 | 937 | 'ignore_boards', |
900 | 938 | ); |
901 | 939 | |
902 | - if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) |
|
903 | - $_POST['ignore_brd'] = array(); |
|
940 | + if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) { |
|
941 | + $_POST['ignore_brd'] = array(); |
|
942 | + } |
|
904 | 943 | |
905 | 944 | unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing. Kinda like our minds. |
906 | 945 | if (isset($_POST['ignore_brd'])) |
907 | 946 | { |
908 | - if (!is_array($_POST['ignore_brd'])) |
|
909 | - $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
947 | + if (!is_array($_POST['ignore_brd'])) { |
|
948 | + $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
949 | + } |
|
910 | 950 | |
911 | 951 | foreach ($_POST['ignore_brd'] as $k => $d) |
912 | 952 | { |
913 | 953 | $d = (int) $d; |
914 | - if ($d != 0) |
|
915 | - $_POST['ignore_brd'][$k] = $d; |
|
916 | - else |
|
917 | - unset($_POST['ignore_brd'][$k]); |
|
954 | + if ($d != 0) { |
|
955 | + $_POST['ignore_brd'][$k] = $d; |
|
956 | + } else { |
|
957 | + unset($_POST['ignore_brd'][$k]); |
|
958 | + } |
|
918 | 959 | } |
919 | 960 | $_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']); |
920 | 961 | unset($_POST['ignore_brd']); |
@@ -927,21 +968,26 @@ discard block |
||
927 | 968 | makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
928 | 969 | //makeAvatarChanges($memID, $post_errors); |
929 | 970 | |
930 | - if (!empty($_REQUEST['sa'])) |
|
931 | - makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
971 | + if (!empty($_REQUEST['sa'])) { |
|
972 | + makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
973 | + } |
|
932 | 974 | |
933 | - foreach ($profile_bools as $var) |
|
934 | - if (isset($_POST[$var])) |
|
975 | + foreach ($profile_bools as $var) { |
|
976 | + if (isset($_POST[$var])) |
|
935 | 977 | $profile_vars[$var] = empty($_POST[$var]) ? '0' : '1'; |
936 | - foreach ($profile_ints as $var) |
|
937 | - if (isset($_POST[$var])) |
|
978 | + } |
|
979 | + foreach ($profile_ints as $var) { |
|
980 | + if (isset($_POST[$var])) |
|
938 | 981 | $profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : ''; |
939 | - foreach ($profile_floats as $var) |
|
940 | - if (isset($_POST[$var])) |
|
982 | + } |
|
983 | + foreach ($profile_floats as $var) { |
|
984 | + if (isset($_POST[$var])) |
|
941 | 985 | $profile_vars[$var] = (float) $_POST[$var]; |
942 | - foreach ($profile_strings as $var) |
|
943 | - if (isset($_POST[$var])) |
|
986 | + } |
|
987 | + foreach ($profile_strings as $var) { |
|
988 | + if (isset($_POST[$var])) |
|
944 | 989 | $profile_vars[$var] = $_POST[$var]; |
990 | + } |
|
945 | 991 | } |
946 | 992 | } |
947 | 993 | |
@@ -975,8 +1021,9 @@ discard block |
||
975 | 1021 | ); |
976 | 1022 | |
977 | 1023 | // Can't change reserved vars. |
978 | - if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) |
|
979 | - fatal_lang_error('no_access', false); |
|
1024 | + if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) { |
|
1025 | + fatal_lang_error('no_access', false); |
|
1026 | + } |
|
980 | 1027 | |
981 | 1028 | // Don't allow any overriding of custom fields with default or non-default options. |
982 | 1029 | $request = $smcFunc['db_query']('', ' |
@@ -988,8 +1035,9 @@ discard block |
||
988 | 1035 | ) |
989 | 1036 | ); |
990 | 1037 | $custom_fields = array(); |
991 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
992 | - $custom_fields[] = $row['col_name']; |
|
1038 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1039 | + $custom_fields[] = $row['col_name']; |
|
1040 | + } |
|
993 | 1041 | $smcFunc['db_free_result']($request); |
994 | 1042 | |
995 | 1043 | // These are the theme changes... |
@@ -998,33 +1046,39 @@ discard block |
||
998 | 1046 | { |
999 | 1047 | foreach ($_POST['options'] as $opt => $val) |
1000 | 1048 | { |
1001 | - if (in_array($opt, $custom_fields)) |
|
1002 | - continue; |
|
1049 | + if (in_array($opt, $custom_fields)) { |
|
1050 | + continue; |
|
1051 | + } |
|
1003 | 1052 | |
1004 | 1053 | // These need to be controlled. |
1005 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
1006 | - $val = max(0, min($val, 50)); |
|
1054 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
1055 | + $val = max(0, min($val, 50)); |
|
1056 | + } |
|
1007 | 1057 | // We don't set this per theme anymore. |
1008 | - elseif ($opt == 'allow_no_censored') |
|
1009 | - continue; |
|
1058 | + elseif ($opt == 'allow_no_censored') { |
|
1059 | + continue; |
|
1060 | + } |
|
1010 | 1061 | |
1011 | 1062 | $themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val); |
1012 | 1063 | } |
1013 | 1064 | } |
1014 | 1065 | |
1015 | 1066 | $erase_options = array(); |
1016 | - if (isset($_POST['default_options']) && is_array($_POST['default_options'])) |
|
1017 | - foreach ($_POST['default_options'] as $opt => $val) |
|
1067 | + if (isset($_POST['default_options']) && is_array($_POST['default_options'])) { |
|
1068 | + foreach ($_POST['default_options'] as $opt => $val) |
|
1018 | 1069 | { |
1019 | 1070 | if (in_array($opt, $custom_fields)) |
1020 | 1071 | continue; |
1072 | + } |
|
1021 | 1073 | |
1022 | 1074 | // These need to be controlled. |
1023 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
1024 | - $val = max(0, min($val, 50)); |
|
1075 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
1076 | + $val = max(0, min($val, 50)); |
|
1077 | + } |
|
1025 | 1078 | // Only let admins and owners change the censor. |
1026 | - elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) |
|
1027 | - continue; |
|
1079 | + elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) { |
|
1080 | + continue; |
|
1081 | + } |
|
1028 | 1082 | |
1029 | 1083 | $themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
1030 | 1084 | $erase_options[] = $opt; |
@@ -1060,8 +1114,9 @@ discard block |
||
1060 | 1114 | |
1061 | 1115 | // Admins can choose any theme, even if it's not enabled... |
1062 | 1116 | $themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']); |
1063 | - foreach ($themes as $t) |
|
1064 | - cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
1117 | + foreach ($themes as $t) { |
|
1118 | + cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
1119 | + } |
|
1065 | 1120 | } |
1066 | 1121 | } |
1067 | 1122 | |
@@ -1080,8 +1135,9 @@ discard block |
||
1080 | 1135 | if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards'])) |
1081 | 1136 | { |
1082 | 1137 | // Make sure only integers are deleted. |
1083 | - foreach ($_POST['notify_boards'] as $index => $id) |
|
1084 | - $_POST['notify_boards'][$index] = (int) $id; |
|
1138 | + foreach ($_POST['notify_boards'] as $index => $id) { |
|
1139 | + $_POST['notify_boards'][$index] = (int) $id; |
|
1140 | + } |
|
1085 | 1141 | |
1086 | 1142 | // id_board = 0 is reserved for topic notifications. |
1087 | 1143 | $_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0)); |
@@ -1100,8 +1156,9 @@ discard block |
||
1100 | 1156 | // We are editing topic notifications...... |
1101 | 1157 | elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics'])) |
1102 | 1158 | { |
1103 | - foreach ($_POST['notify_topics'] as $index => $id) |
|
1104 | - $_POST['notify_topics'][$index] = (int) $id; |
|
1159 | + foreach ($_POST['notify_topics'] as $index => $id) { |
|
1160 | + $_POST['notify_topics'][$index] = (int) $id; |
|
1161 | + } |
|
1105 | 1162 | |
1106 | 1163 | // Make sure there are no zeros left. |
1107 | 1164 | $_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0)); |
@@ -1115,16 +1172,18 @@ discard block |
||
1115 | 1172 | 'selected_member' => $memID, |
1116 | 1173 | ) |
1117 | 1174 | ); |
1118 | - foreach ($_POST['notify_topics'] as $topic) |
|
1119 | - setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
1175 | + foreach ($_POST['notify_topics'] as $topic) { |
|
1176 | + setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
1177 | + } |
|
1120 | 1178 | } |
1121 | 1179 | |
1122 | 1180 | // We are removing topic preferences |
1123 | 1181 | elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics'])) |
1124 | 1182 | { |
1125 | 1183 | $prefs = array(); |
1126 | - foreach ($_POST['notify_topics'] as $topic) |
|
1127 | - $prefs[] = 'topic_notify_' . $topic; |
|
1184 | + foreach ($_POST['notify_topics'] as $topic) { |
|
1185 | + $prefs[] = 'topic_notify_' . $topic; |
|
1186 | + } |
|
1128 | 1187 | deleteNotifyPrefs($memID, $prefs); |
1129 | 1188 | } |
1130 | 1189 | |
@@ -1132,8 +1191,9 @@ discard block |
||
1132 | 1191 | elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards'])) |
1133 | 1192 | { |
1134 | 1193 | $prefs = array(); |
1135 | - foreach ($_POST['notify_boards'] as $board) |
|
1136 | - $prefs[] = 'board_notify_' . $board; |
|
1194 | + foreach ($_POST['notify_boards'] as $board) { |
|
1195 | + $prefs[] = 'board_notify_' . $board; |
|
1196 | + } |
|
1137 | 1197 | deleteNotifyPrefs($memID, $prefs); |
1138 | 1198 | } |
1139 | 1199 | } |
@@ -1154,8 +1214,9 @@ discard block |
||
1154 | 1214 | |
1155 | 1215 | $errors = array(); |
1156 | 1216 | |
1157 | - if ($sanitize && isset($_POST['customfield'])) |
|
1158 | - $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
1217 | + if ($sanitize && isset($_POST['customfield'])) { |
|
1218 | + $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
1219 | + } |
|
1159 | 1220 | |
1160 | 1221 | $where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}'; |
1161 | 1222 | |
@@ -1180,48 +1241,49 @@ discard block |
||
1180 | 1241 | - The data is not invisible to users but editable by the owner (or if it is the user is not the owner) |
1181 | 1242 | - The area isn't registration, and if it is that the field is not supposed to be shown there. |
1182 | 1243 | */ |
1183 | - if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) |
|
1184 | - continue; |
|
1244 | + if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) { |
|
1245 | + continue; |
|
1246 | + } |
|
1185 | 1247 | |
1186 | 1248 | // Validate the user data. |
1187 | - if ($row['field_type'] == 'check') |
|
1188 | - $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
1189 | - elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
1249 | + if ($row['field_type'] == 'check') { |
|
1250 | + $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
1251 | + } elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
1190 | 1252 | { |
1191 | 1253 | $value = $row['default_value']; |
1192 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
1193 | - if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
1254 | + foreach (explode(',', $row['field_options']) as $k => $v) { |
|
1255 | + if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
1194 | 1256 | $value = $v; |
1257 | + } |
|
1195 | 1258 | } |
1196 | 1259 | // Otherwise some form of text! |
1197 | 1260 | else |
1198 | 1261 | { |
1199 | 1262 | $value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : ''; |
1200 | - if ($row['field_length']) |
|
1201 | - $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
1263 | + if ($row['field_length']) { |
|
1264 | + $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
1265 | + } |
|
1202 | 1266 | |
1203 | 1267 | // Any masks? |
1204 | 1268 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
1205 | 1269 | { |
1206 | 1270 | if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
1207 | 1271 | { |
1208 | - if ($returnErrors) |
|
1209 | - $errors[] = 'custom_field_mail_fail'; |
|
1210 | - |
|
1211 | - else |
|
1212 | - $value = ''; |
|
1213 | - } |
|
1214 | - elseif ($row['mask'] == 'number') |
|
1272 | + if ($returnErrors) { |
|
1273 | + $errors[] = 'custom_field_mail_fail'; |
|
1274 | + } else { |
|
1275 | + $value = ''; |
|
1276 | + } |
|
1277 | + } elseif ($row['mask'] == 'number') |
|
1215 | 1278 | { |
1216 | 1279 | $value = (int) $value; |
1217 | - } |
|
1218 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
1280 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
1219 | 1281 | { |
1220 | - if ($returnErrors) |
|
1221 | - $errors[] = 'custom_field_regex_fail'; |
|
1222 | - |
|
1223 | - else |
|
1224 | - $value = ''; |
|
1282 | + if ($returnErrors) { |
|
1283 | + $errors[] = 'custom_field_regex_fail'; |
|
1284 | + } else { |
|
1285 | + $value = ''; |
|
1286 | + } |
|
1225 | 1287 | } |
1226 | 1288 | } |
1227 | 1289 | } |
@@ -1248,8 +1310,9 @@ discard block |
||
1248 | 1310 | $hook_errors = array(); |
1249 | 1311 | $hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize)); |
1250 | 1312 | |
1251 | - if (!empty($hook_errors) && is_array($hook_errors)) |
|
1252 | - $errors = array_merge($errors, $hook_errors); |
|
1313 | + if (!empty($hook_errors) && is_array($hook_errors)) { |
|
1314 | + $errors = array_merge($errors, $hook_errors); |
|
1315 | + } |
|
1253 | 1316 | |
1254 | 1317 | // Make those changes! |
1255 | 1318 | if (!empty($changes) && empty($context['password_auth_failed']) && empty($errors)) |
@@ -1267,9 +1330,10 @@ discard block |
||
1267 | 1330 | } |
1268 | 1331 | } |
1269 | 1332 | |
1270 | - if ($returnErrors) |
|
1271 | - return $errors; |
|
1272 | -} |
|
1333 | + if ($returnErrors) { |
|
1334 | + return $errors; |
|
1335 | + } |
|
1336 | + } |
|
1273 | 1337 | |
1274 | 1338 | /** |
1275 | 1339 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1281,8 +1345,9 @@ discard block |
||
1281 | 1345 | global $context, $txt, $modSettings; |
1282 | 1346 | |
1283 | 1347 | // Do a quick check to ensure people aren't getting here illegally! |
1284 | - if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) |
|
1285 | - fatal_lang_error('no_access', false); |
|
1348 | + if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) { |
|
1349 | + fatal_lang_error('no_access', false); |
|
1350 | + } |
|
1286 | 1351 | |
1287 | 1352 | // Can we email the user direct? |
1288 | 1353 | $context['can_moderate_forum'] = allowedTo('moderate_forum'); |
@@ -1312,9 +1377,10 @@ discard block |
||
1312 | 1377 | $context['sub_template'] = $subActions[$context['list_area']][0]; |
1313 | 1378 | $call = call_helper($subActions[$context['list_area']][0], true); |
1314 | 1379 | |
1315 | - if (!empty($call)) |
|
1316 | - call_user_func($call, $memID); |
|
1317 | -} |
|
1380 | + if (!empty($call)) { |
|
1381 | + call_user_func($call, $memID); |
|
1382 | + } |
|
1383 | + } |
|
1318 | 1384 | |
1319 | 1385 | /** |
1320 | 1386 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1328,9 +1394,10 @@ discard block |
||
1328 | 1394 | |
1329 | 1395 | // For making changes! |
1330 | 1396 | $buddiesArray = explode(',', $user_profile[$memID]['buddy_list']); |
1331 | - foreach ($buddiesArray as $k => $dummy) |
|
1332 | - if ($dummy == '') |
|
1397 | + foreach ($buddiesArray as $k => $dummy) { |
|
1398 | + if ($dummy == '') |
|
1333 | 1399 | unset($buddiesArray[$k]); |
1400 | + } |
|
1334 | 1401 | |
1335 | 1402 | // Removing a buddy? |
1336 | 1403 | if (isset($_GET['remove'])) |
@@ -1342,10 +1409,11 @@ discard block |
||
1342 | 1409 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
1343 | 1410 | |
1344 | 1411 | // Heh, I'm lazy, do it the easy way... |
1345 | - foreach ($buddiesArray as $key => $buddy) |
|
1346 | - if ($buddy == (int) $_GET['remove']) |
|
1412 | + foreach ($buddiesArray as $key => $buddy) { |
|
1413 | + if ($buddy == (int) $_GET['remove']) |
|
1347 | 1414 | { |
1348 | 1415 | unset($buddiesArray[$key]); |
1416 | + } |
|
1349 | 1417 | $_SESSION['prf-save'] = true; |
1350 | 1418 | } |
1351 | 1419 | |
@@ -1355,8 +1423,7 @@ discard block |
||
1355 | 1423 | |
1356 | 1424 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
1357 | 1425 | redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID); |
1358 | - } |
|
1359 | - elseif (isset($_POST['new_buddy'])) |
|
1426 | + } elseif (isset($_POST['new_buddy'])) |
|
1360 | 1427 | { |
1361 | 1428 | checkSession(); |
1362 | 1429 | |
@@ -1369,8 +1436,9 @@ discard block |
||
1369 | 1436 | { |
1370 | 1437 | $new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => ''')); |
1371 | 1438 | |
1372 | - if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
1373 | - unset($new_buddies[$k]); |
|
1439 | + if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
1440 | + unset($new_buddies[$k]); |
|
1441 | + } |
|
1374 | 1442 | } |
1375 | 1443 | |
1376 | 1444 | call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies)); |
@@ -1390,16 +1458,18 @@ discard block |
||
1390 | 1458 | ) |
1391 | 1459 | ); |
1392 | 1460 | |
1393 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1394 | - $_SESSION['prf-save'] = true; |
|
1461 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1462 | + $_SESSION['prf-save'] = true; |
|
1463 | + } |
|
1395 | 1464 | |
1396 | 1465 | // Add the new member to the buddies array. |
1397 | 1466 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1398 | 1467 | { |
1399 | - if (in_array($row['id_member'], $buddiesArray)) |
|
1400 | - continue; |
|
1401 | - else |
|
1402 | - $buddiesArray[] = (int) $row['id_member']; |
|
1468 | + if (in_array($row['id_member'], $buddiesArray)) { |
|
1469 | + continue; |
|
1470 | + } else { |
|
1471 | + $buddiesArray[] = (int) $row['id_member']; |
|
1472 | + } |
|
1403 | 1473 | } |
1404 | 1474 | $smcFunc['db_free_result']($request); |
1405 | 1475 | |
@@ -1429,18 +1499,20 @@ discard block |
||
1429 | 1499 | |
1430 | 1500 | $context['custom_pf'] = array(); |
1431 | 1501 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
1432 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1433 | - if (!isset($disabled_fields[$row['col_name']])) |
|
1502 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1503 | + if (!isset($disabled_fields[$row['col_name']])) |
|
1434 | 1504 | $context['custom_pf'][$row['col_name']] = array( |
1435 | 1505 | 'label' => $row['field_name'], |
1436 | 1506 | 'type' => $row['field_type'], |
1437 | 1507 | 'bbc' => !empty($row['bbc']), |
1438 | 1508 | 'enclose' => $row['enclose'], |
1439 | 1509 | ); |
1510 | + } |
|
1440 | 1511 | |
1441 | 1512 | // Gotta disable the gender option. |
1442 | - if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') |
|
1443 | - unset($context['custom_pf']['cust_gender']); |
|
1513 | + if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') { |
|
1514 | + unset($context['custom_pf']['cust_gender']); |
|
1515 | + } |
|
1444 | 1516 | |
1445 | 1517 | $smcFunc['db_free_result']($request); |
1446 | 1518 | |
@@ -1457,8 +1529,9 @@ discard block |
||
1457 | 1529 | 'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1, |
1458 | 1530 | ) |
1459 | 1531 | ); |
1460 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1461 | - $buddies[] = $row['id_member']; |
|
1532 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1533 | + $buddies[] = $row['id_member']; |
|
1534 | + } |
|
1462 | 1535 | $smcFunc['db_free_result']($result); |
1463 | 1536 | } |
1464 | 1537 | |
@@ -1486,30 +1559,32 @@ discard block |
||
1486 | 1559 | continue; |
1487 | 1560 | } |
1488 | 1561 | |
1489 | - if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) |
|
1490 | - $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
1491 | - |
|
1492 | - elseif ($column['type'] == 'check') |
|
1493 | - $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
1562 | + if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
1563 | + $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
1564 | + } elseif ($column['type'] == 'check') { |
|
1565 | + $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
1566 | + } |
|
1494 | 1567 | |
1495 | 1568 | // Enclosing the user input within some other text? |
1496 | - if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) |
|
1497 | - $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
1569 | + if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
1570 | + $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
1498 | 1571 | '{SCRIPTURL}' => $scripturl, |
1499 | 1572 | '{IMAGES_URL}' => $settings['images_url'], |
1500 | 1573 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1501 | 1574 | '{INPUT}' => $context['buddies'][$buddy]['options'][$key], |
1502 | 1575 | )); |
1576 | + } |
|
1503 | 1577 | } |
1504 | 1578 | } |
1505 | 1579 | } |
1506 | 1580 | |
1507 | 1581 | if (isset($_SESSION['prf-save'])) |
1508 | 1582 | { |
1509 | - if ($_SESSION['prf-save'] === true) |
|
1510 | - $context['saved_successful'] = true; |
|
1511 | - else |
|
1512 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
1583 | + if ($_SESSION['prf-save'] === true) { |
|
1584 | + $context['saved_successful'] = true; |
|
1585 | + } else { |
|
1586 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
1587 | + } |
|
1513 | 1588 | |
1514 | 1589 | unset($_SESSION['prf-save']); |
1515 | 1590 | } |
@@ -1529,9 +1604,10 @@ discard block |
||
1529 | 1604 | |
1530 | 1605 | // For making changes! |
1531 | 1606 | $ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']); |
1532 | - foreach ($ignoreArray as $k => $dummy) |
|
1533 | - if ($dummy == '') |
|
1607 | + foreach ($ignoreArray as $k => $dummy) { |
|
1608 | + if ($dummy == '') |
|
1534 | 1609 | unset($ignoreArray[$k]); |
1610 | + } |
|
1535 | 1611 | |
1536 | 1612 | // Removing a member from the ignore list? |
1537 | 1613 | if (isset($_GET['remove'])) |
@@ -1541,10 +1617,11 @@ discard block |
||
1541 | 1617 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
1542 | 1618 | |
1543 | 1619 | // Heh, I'm lazy, do it the easy way... |
1544 | - foreach ($ignoreArray as $key => $id_remove) |
|
1545 | - if ($id_remove == (int) $_GET['remove']) |
|
1620 | + foreach ($ignoreArray as $key => $id_remove) { |
|
1621 | + if ($id_remove == (int) $_GET['remove']) |
|
1546 | 1622 | { |
1547 | 1623 | unset($ignoreArray[$key]); |
1624 | + } |
|
1548 | 1625 | $_SESSION['prf-save'] = true; |
1549 | 1626 | } |
1550 | 1627 | |
@@ -1554,8 +1631,7 @@ discard block |
||
1554 | 1631 | |
1555 | 1632 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
1556 | 1633 | redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID); |
1557 | - } |
|
1558 | - elseif (isset($_POST['new_ignore'])) |
|
1634 | + } elseif (isset($_POST['new_ignore'])) |
|
1559 | 1635 | { |
1560 | 1636 | checkSession(); |
1561 | 1637 | // Prepare the string for extraction... |
@@ -1567,8 +1643,9 @@ discard block |
||
1567 | 1643 | { |
1568 | 1644 | $new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => ''')); |
1569 | 1645 | |
1570 | - if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
1571 | - unset($new_entries[$k]); |
|
1646 | + if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
1647 | + unset($new_entries[$k]); |
|
1648 | + } |
|
1572 | 1649 | } |
1573 | 1650 | |
1574 | 1651 | $_SESSION['prf-save'] = $txt['could_not_add_person']; |
@@ -1586,16 +1663,18 @@ discard block |
||
1586 | 1663 | ) |
1587 | 1664 | ); |
1588 | 1665 | |
1589 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1590 | - $_SESSION['prf-save'] = true; |
|
1666 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1667 | + $_SESSION['prf-save'] = true; |
|
1668 | + } |
|
1591 | 1669 | |
1592 | 1670 | // Add the new member to the buddies array. |
1593 | 1671 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1594 | 1672 | { |
1595 | - if (in_array($row['id_member'], $ignoreArray)) |
|
1596 | - continue; |
|
1597 | - else |
|
1598 | - $ignoreArray[] = (int) $row['id_member']; |
|
1673 | + if (in_array($row['id_member'], $ignoreArray)) { |
|
1674 | + continue; |
|
1675 | + } else { |
|
1676 | + $ignoreArray[] = (int) $row['id_member']; |
|
1677 | + } |
|
1599 | 1678 | } |
1600 | 1679 | $smcFunc['db_free_result']($request); |
1601 | 1680 | |
@@ -1624,8 +1703,9 @@ discard block |
||
1624 | 1703 | 'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1, |
1625 | 1704 | ) |
1626 | 1705 | ); |
1627 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1628 | - $ignored[] = $row['id_member']; |
|
1706 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1707 | + $ignored[] = $row['id_member']; |
|
1708 | + } |
|
1629 | 1709 | $smcFunc['db_free_result']($result); |
1630 | 1710 | } |
1631 | 1711 | |
@@ -1644,10 +1724,11 @@ discard block |
||
1644 | 1724 | |
1645 | 1725 | if (isset($_SESSION['prf-save'])) |
1646 | 1726 | { |
1647 | - if ($_SESSION['prf-save'] === true) |
|
1648 | - $context['saved_successful'] = true; |
|
1649 | - else |
|
1650 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
1727 | + if ($_SESSION['prf-save'] === true) { |
|
1728 | + $context['saved_successful'] = true; |
|
1729 | + } else { |
|
1730 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
1731 | + } |
|
1651 | 1732 | |
1652 | 1733 | unset($_SESSION['prf-save']); |
1653 | 1734 | } |
@@ -1663,8 +1744,9 @@ discard block |
||
1663 | 1744 | global $context, $txt; |
1664 | 1745 | |
1665 | 1746 | loadThemeOptions($memID); |
1666 | - if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) |
|
1667 | - loadCustomFields($memID, 'account'); |
|
1747 | + if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) { |
|
1748 | + loadCustomFields($memID, 'account'); |
|
1749 | + } |
|
1668 | 1750 | |
1669 | 1751 | $context['sub_template'] = 'edit_options'; |
1670 | 1752 | $context['page_desc'] = $txt['account_info']; |
@@ -1691,8 +1773,9 @@ discard block |
||
1691 | 1773 | global $context, $txt; |
1692 | 1774 | |
1693 | 1775 | loadThemeOptions($memID); |
1694 | - if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) |
|
1695 | - loadCustomFields($memID, 'forumprofile'); |
|
1776 | + if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) { |
|
1777 | + loadCustomFields($memID, 'forumprofile'); |
|
1778 | + } |
|
1696 | 1779 | |
1697 | 1780 | $context['sub_template'] = 'edit_options'; |
1698 | 1781 | $context['page_desc'] = $txt['forumProfile_info']; |
@@ -1725,18 +1808,21 @@ discard block |
||
1725 | 1808 | $dirs = array(); |
1726 | 1809 | $files = array(); |
1727 | 1810 | |
1728 | - if (!$dir) |
|
1729 | - return array(); |
|
1811 | + if (!$dir) { |
|
1812 | + return array(); |
|
1813 | + } |
|
1730 | 1814 | |
1731 | 1815 | while ($line = $dir->read()) |
1732 | 1816 | { |
1733 | - if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) |
|
1734 | - continue; |
|
1817 | + if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) { |
|
1818 | + continue; |
|
1819 | + } |
|
1735 | 1820 | |
1736 | - if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) |
|
1737 | - $dirs[] = $line; |
|
1738 | - else |
|
1739 | - $files[] = $line; |
|
1821 | + if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) { |
|
1822 | + $dirs[] = $line; |
|
1823 | + } else { |
|
1824 | + $files[] = $line; |
|
1825 | + } |
|
1740 | 1826 | } |
1741 | 1827 | $dir->close(); |
1742 | 1828 | |
@@ -1757,14 +1843,15 @@ discard block |
||
1757 | 1843 | foreach ($dirs as $line) |
1758 | 1844 | { |
1759 | 1845 | $tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1); |
1760 | - if (!empty($tmp)) |
|
1761 | - $result[] = array( |
|
1846 | + if (!empty($tmp)) { |
|
1847 | + $result[] = array( |
|
1762 | 1848 | 'filename' => $smcFunc['htmlspecialchars']($line), |
1763 | 1849 | 'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false, |
1764 | 1850 | 'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']', |
1765 | 1851 | 'is_dir' => true, |
1766 | 1852 | 'files' => $tmp |
1767 | 1853 | ); |
1854 | + } |
|
1768 | 1855 | unset($tmp); |
1769 | 1856 | } |
1770 | 1857 | |
@@ -1774,8 +1861,9 @@ discard block |
||
1774 | 1861 | $extension = substr(strrchr($line, '.'), 1); |
1775 | 1862 | |
1776 | 1863 | // Make sure it is an image. |
1777 | - if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) |
|
1778 | - continue; |
|
1864 | + if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) { |
|
1865 | + continue; |
|
1866 | + } |
|
1779 | 1867 | |
1780 | 1868 | $result[] = array( |
1781 | 1869 | 'filename' => $smcFunc['htmlspecialchars']($line), |
@@ -1783,8 +1871,9 @@ discard block |
||
1783 | 1871 | 'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)), |
1784 | 1872 | 'is_dir' => false |
1785 | 1873 | ); |
1786 | - if ($level == 1) |
|
1787 | - $context['avatar_list'][] = $directory . '/' . $line; |
|
1874 | + if ($level == 1) { |
|
1875 | + $context['avatar_list'][] = $directory . '/' . $line; |
|
1876 | + } |
|
1788 | 1877 | } |
1789 | 1878 | |
1790 | 1879 | return $result; |
@@ -1800,8 +1889,9 @@ discard block |
||
1800 | 1889 | global $txt, $context; |
1801 | 1890 | |
1802 | 1891 | loadThemeOptions($memID); |
1803 | - if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) |
|
1804 | - loadCustomFields($memID, 'theme'); |
|
1892 | + if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { |
|
1893 | + loadCustomFields($memID, 'theme'); |
|
1894 | + } |
|
1805 | 1895 | |
1806 | 1896 | $context['sub_template'] = 'edit_options'; |
1807 | 1897 | $context['page_desc'] = $txt['theme_info']; |
@@ -1855,16 +1945,19 @@ discard block |
||
1855 | 1945 | { |
1856 | 1946 | global $txt, $user_profile, $context, $modSettings, $smcFunc, $sourcedir; |
1857 | 1947 | |
1858 | - if (!isset($context['token_check'])) |
|
1859 | - $context['token_check'] = 'profile-nt' . $memID; |
|
1948 | + if (!isset($context['token_check'])) { |
|
1949 | + $context['token_check'] = 'profile-nt' . $memID; |
|
1950 | + } |
|
1860 | 1951 | |
1861 | 1952 | is_not_guest(); |
1862 | - if (!$context['user']['is_owner']) |
|
1863 | - isAllowedTo('profile_extra_any'); |
|
1953 | + if (!$context['user']['is_owner']) { |
|
1954 | + isAllowedTo('profile_extra_any'); |
|
1955 | + } |
|
1864 | 1956 | |
1865 | 1957 | // Set the post action if we're coming from the profile... |
1866 | - if (!isset($context['action'])) |
|
1867 | - $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
1958 | + if (!isset($context['action'])) { |
|
1959 | + $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
1960 | + } |
|
1868 | 1961 | |
1869 | 1962 | // What options are set |
1870 | 1963 | loadThemeOptions($memID); |
@@ -1951,28 +2044,34 @@ discard block |
||
1951 | 2044 | ); |
1952 | 2045 | |
1953 | 2046 | // There are certain things that are disabled at the group level. |
1954 | - if (empty($modSettings['cal_enabled'])) |
|
1955 | - unset($alert_types['calendar']); |
|
2047 | + if (empty($modSettings['cal_enabled'])) { |
|
2048 | + unset($alert_types['calendar']); |
|
2049 | + } |
|
1956 | 2050 | |
1957 | 2051 | // Disable paid subscriptions at group level if they're disabled |
1958 | - if (empty($modSettings['paid_enabled'])) |
|
1959 | - unset($alert_types['paidsubs']); |
|
2052 | + if (empty($modSettings['paid_enabled'])) { |
|
2053 | + unset($alert_types['paidsubs']); |
|
2054 | + } |
|
1960 | 2055 | |
1961 | 2056 | // Disable membergroup requests at group level if they're disabled |
1962 | - if (empty($modSettings['show_group_membership'])) |
|
1963 | - unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
2057 | + if (empty($modSettings['show_group_membership'])) { |
|
2058 | + unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
2059 | + } |
|
1964 | 2060 | |
1965 | 2061 | // Disable mentions if they're disabled |
1966 | - if (empty($modSettings['enable_mentions'])) |
|
1967 | - unset($alert_types['msg']['msg_mention']); |
|
2062 | + if (empty($modSettings['enable_mentions'])) { |
|
2063 | + unset($alert_types['msg']['msg_mention']); |
|
2064 | + } |
|
1968 | 2065 | |
1969 | 2066 | // Disable likes if they're disabled |
1970 | - if (empty($modSettings['enable_likes'])) |
|
1971 | - unset($alert_types['msg']['msg_like']); |
|
2067 | + if (empty($modSettings['enable_likes'])) { |
|
2068 | + unset($alert_types['msg']['msg_like']); |
|
2069 | + } |
|
1972 | 2070 | |
1973 | 2071 | // Disable buddy requests if they're disabled |
1974 | - if (empty($modSettings['enable_buddylist'])) |
|
1975 | - unset($alert_types['members']['buddy_request']); |
|
2072 | + if (empty($modSettings['enable_buddylist'])) { |
|
2073 | + unset($alert_types['members']['buddy_request']); |
|
2074 | + } |
|
1976 | 2075 | |
1977 | 2076 | // Now, now, we could pass this through global but we should really get into the habit of |
1978 | 2077 | // passing content to hooks, not expecting hooks to splatter everything everywhere. |
@@ -2000,15 +2099,17 @@ discard block |
||
2000 | 2099 | $perms_cache['manage_membergroups'] = in_array($memID, $members); |
2001 | 2100 | } |
2002 | 2101 | |
2003 | - if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) |
|
2004 | - unset($alert_types['members']['request_group']); |
|
2102 | + if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) { |
|
2103 | + unset($alert_types['members']['request_group']); |
|
2104 | + } |
|
2005 | 2105 | |
2006 | 2106 | foreach ($alert_types as $group => $items) |
2007 | 2107 | { |
2008 | 2108 | foreach ($items as $alert_key => $alert_value) |
2009 | 2109 | { |
2010 | - if (!isset($alert_value['permission'])) |
|
2011 | - continue; |
|
2110 | + if (!isset($alert_value['permission'])) { |
|
2111 | + continue; |
|
2112 | + } |
|
2012 | 2113 | if (!isset($perms_cache[$alert_value['permission']['name']])) |
2013 | 2114 | { |
2014 | 2115 | $in_board = !empty($alert_value['permission']['is_board']) ? 0 : null; |
@@ -2016,12 +2117,14 @@ discard block |
||
2016 | 2117 | $perms_cache[$alert_value['permission']['name']] = in_array($memID, $members); |
2017 | 2118 | } |
2018 | 2119 | |
2019 | - if (!$perms_cache[$alert_value['permission']['name']]) |
|
2020 | - unset ($alert_types[$group][$alert_key]); |
|
2120 | + if (!$perms_cache[$alert_value['permission']['name']]) { |
|
2121 | + unset ($alert_types[$group][$alert_key]); |
|
2122 | + } |
|
2021 | 2123 | } |
2022 | 2124 | |
2023 | - if (empty($alert_types[$group])) |
|
2024 | - unset ($alert_types[$group]); |
|
2125 | + if (empty($alert_types[$group])) { |
|
2126 | + unset ($alert_types[$group]); |
|
2127 | + } |
|
2025 | 2128 | } |
2026 | 2129 | } |
2027 | 2130 | |
@@ -2053,9 +2156,9 @@ discard block |
||
2053 | 2156 | $update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0; |
2054 | 2157 | break; |
2055 | 2158 | case 'select': |
2056 | - if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) |
|
2057 | - $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
2058 | - else |
|
2159 | + if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) { |
|
2160 | + $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
2161 | + } else |
|
2059 | 2162 | { |
2060 | 2163 | // We didn't have a sane value. Let's grab the first item from the possibles. |
2061 | 2164 | $keys = array_keys($this_option['opts']); |
@@ -2075,23 +2178,28 @@ discard block |
||
2075 | 2178 | $this_value = 0; |
2076 | 2179 | foreach ($context['alert_bits'] as $type => $bitvalue) |
2077 | 2180 | { |
2078 | - if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') |
|
2079 | - $this_value |= $bitvalue; |
|
2181 | + if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') { |
|
2182 | + $this_value |= $bitvalue; |
|
2183 | + } |
|
2184 | + } |
|
2185 | + if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) { |
|
2186 | + $update_prefs[$item_key] = $this_value; |
|
2080 | 2187 | } |
2081 | - if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) |
|
2082 | - $update_prefs[$item_key] = $this_value; |
|
2083 | 2188 | } |
2084 | 2189 | } |
2085 | 2190 | |
2086 | - if (!empty($_POST['opt_alert_timeout'])) |
|
2087 | - $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
2191 | + if (!empty($_POST['opt_alert_timeout'])) { |
|
2192 | + $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
2193 | + } |
|
2088 | 2194 | |
2089 | - if (!empty($_POST['notify_announcements'])) |
|
2090 | - $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
2195 | + if (!empty($_POST['notify_announcements'])) { |
|
2196 | + $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
2197 | + } |
|
2091 | 2198 | |
2092 | 2199 | setNotifyPrefs((int) $memID, $update_prefs); |
2093 | - foreach ($update_prefs as $pref => $value) |
|
2094 | - $context['alert_prefs'][$pref] = $value; |
|
2200 | + foreach ($update_prefs as $pref => $value) { |
|
2201 | + $context['alert_prefs'][$pref] = $value; |
|
2202 | + } |
|
2095 | 2203 | |
2096 | 2204 | makeNotificationChanges($memID); |
2097 | 2205 | |
@@ -2121,8 +2229,9 @@ discard block |
||
2121 | 2229 | |
2122 | 2230 | // Now we're all set up. |
2123 | 2231 | is_not_guest(); |
2124 | - if (!$context['user']['is_owner']) |
|
2125 | - fatal_error('no_access'); |
|
2232 | + if (!$context['user']['is_owner']) { |
|
2233 | + fatal_error('no_access'); |
|
2234 | + } |
|
2126 | 2235 | |
2127 | 2236 | checkSession('get'); |
2128 | 2237 | |
@@ -2154,8 +2263,9 @@ discard block |
||
2154 | 2263 | { |
2155 | 2264 | global $smcFunc; |
2156 | 2265 | |
2157 | - if (empty($toMark) || empty($memID)) |
|
2158 | - return false; |
|
2266 | + if (empty($toMark) || empty($memID)) { |
|
2267 | + return false; |
|
2268 | + } |
|
2159 | 2269 | |
2160 | 2270 | $toMark = (array) $toMark; |
2161 | 2271 | $count = 0; |
@@ -2190,8 +2300,9 @@ discard block |
||
2190 | 2300 | { |
2191 | 2301 | global $smcFunc; |
2192 | 2302 | |
2193 | - if (empty($toDelete)) |
|
2194 | - return false; |
|
2303 | + if (empty($toDelete)) { |
|
2304 | + return false; |
|
2305 | + } |
|
2195 | 2306 | |
2196 | 2307 | $toDelete = (array) $toDelete; |
2197 | 2308 | |
@@ -2226,8 +2337,9 @@ discard block |
||
2226 | 2337 | { |
2227 | 2338 | global $smcFunc; |
2228 | 2339 | |
2229 | - if (empty($memID)) |
|
2230 | - return false; |
|
2340 | + if (empty($memID)) { |
|
2341 | + return false; |
|
2342 | + } |
|
2231 | 2343 | |
2232 | 2344 | $count = 0; |
2233 | 2345 | |
@@ -2306,8 +2418,9 @@ discard block |
||
2306 | 2418 | { |
2307 | 2419 | $link = $topic['link']; |
2308 | 2420 | |
2309 | - if ($topic['new']) |
|
2310 | - $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2421 | + if ($topic['new']) { |
|
2422 | + $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2423 | + } |
|
2311 | 2424 | |
2312 | 2425 | $link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>'; |
2313 | 2426 | |
@@ -2458,8 +2571,9 @@ discard block |
||
2458 | 2571 | { |
2459 | 2572 | $link = $board['link']; |
2460 | 2573 | |
2461 | - if ($board['new']) |
|
2462 | - $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2574 | + if ($board['new']) { |
|
2575 | + $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2576 | + } |
|
2463 | 2577 | |
2464 | 2578 | return $link; |
2465 | 2579 | }, |
@@ -2659,8 +2773,8 @@ discard block |
||
2659 | 2773 | ) |
2660 | 2774 | ); |
2661 | 2775 | $notification_boards = array(); |
2662 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2663 | - $notification_boards[] = array( |
|
2776 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2777 | + $notification_boards[] = array( |
|
2664 | 2778 | 'id' => $row['id_board'], |
2665 | 2779 | 'name' => $row['name'], |
2666 | 2780 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
@@ -2668,6 +2782,7 @@ discard block |
||
2668 | 2782 | 'new' => $row['board_read'] < $row['id_msg_updated'], |
2669 | 2783 | 'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0), |
2670 | 2784 | ); |
2785 | + } |
|
2671 | 2786 | $smcFunc['db_free_result']($request); |
2672 | 2787 | |
2673 | 2788 | return $notification_boards; |
@@ -2682,17 +2797,18 @@ discard block |
||
2682 | 2797 | { |
2683 | 2798 | global $context, $options, $cur_profile, $smcFunc; |
2684 | 2799 | |
2685 | - if (isset($_POST['default_options'])) |
|
2686 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
2800 | + if (isset($_POST['default_options'])) { |
|
2801 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
2802 | + } |
|
2687 | 2803 | |
2688 | 2804 | if ($context['user']['is_owner']) |
2689 | 2805 | { |
2690 | 2806 | $context['member']['options'] = $options; |
2691 | - if (isset($_POST['options']) && is_array($_POST['options'])) |
|
2692 | - foreach ($_POST['options'] as $k => $v) |
|
2807 | + if (isset($_POST['options']) && is_array($_POST['options'])) { |
|
2808 | + foreach ($_POST['options'] as $k => $v) |
|
2693 | 2809 | $context['member']['options'][$k] = $v; |
2694 | - } |
|
2695 | - else |
|
2810 | + } |
|
2811 | + } else |
|
2696 | 2812 | { |
2697 | 2813 | $request = $smcFunc['db_query']('', ' |
2698 | 2814 | SELECT id_member, variable, value |
@@ -2713,8 +2829,9 @@ discard block |
||
2713 | 2829 | continue; |
2714 | 2830 | } |
2715 | 2831 | |
2716 | - if (isset($_POST['options'][$row['variable']])) |
|
2717 | - $row['value'] = $_POST['options'][$row['variable']]; |
|
2832 | + if (isset($_POST['options'][$row['variable']])) { |
|
2833 | + $row['value'] = $_POST['options'][$row['variable']]; |
|
2834 | + } |
|
2718 | 2835 | $context['member']['options'][$row['variable']] = $row['value']; |
2719 | 2836 | } |
2720 | 2837 | $smcFunc['db_free_result']($request); |
@@ -2722,8 +2839,9 @@ discard block |
||
2722 | 2839 | // Load up the default theme options for any missing. |
2723 | 2840 | foreach ($temp as $k => $v) |
2724 | 2841 | { |
2725 | - if (!isset($context['member']['options'][$k])) |
|
2726 | - $context['member']['options'][$k] = $v; |
|
2842 | + if (!isset($context['member']['options'][$k])) { |
|
2843 | + $context['member']['options'][$k] = $v; |
|
2844 | + } |
|
2727 | 2845 | } |
2728 | 2846 | } |
2729 | 2847 | } |
@@ -2738,8 +2856,9 @@ discard block |
||
2738 | 2856 | global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir; |
2739 | 2857 | |
2740 | 2858 | // Have the admins enabled this option? |
2741 | - if (empty($modSettings['allow_ignore_boards'])) |
|
2742 | - fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
2859 | + if (empty($modSettings['allow_ignore_boards'])) { |
|
2860 | + fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
2861 | + } |
|
2743 | 2862 | |
2744 | 2863 | // Find all the boards this user is allowed to see. |
2745 | 2864 | $request = $smcFunc['db_query']('order_by_board_order', ' |
@@ -2759,12 +2878,13 @@ discard block |
||
2759 | 2878 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2760 | 2879 | { |
2761 | 2880 | // This category hasn't been set up yet.. |
2762 | - if (!isset($context['categories'][$row['id_cat']])) |
|
2763 | - $context['categories'][$row['id_cat']] = array( |
|
2881 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
2882 | + $context['categories'][$row['id_cat']] = array( |
|
2764 | 2883 | 'id' => $row['id_cat'], |
2765 | 2884 | 'name' => $row['cat_name'], |
2766 | 2885 | 'boards' => array() |
2767 | 2886 | ); |
2887 | + } |
|
2768 | 2888 | |
2769 | 2889 | // Set this board up, and let the template know when it's a child. (indent them..) |
2770 | 2890 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -2794,18 +2914,20 @@ discard block |
||
2794 | 2914 | } |
2795 | 2915 | |
2796 | 2916 | $max_boards = ceil(count($temp_boards) / 2); |
2797 | - if ($max_boards == 1) |
|
2798 | - $max_boards = 2; |
|
2917 | + if ($max_boards == 1) { |
|
2918 | + $max_boards = 2; |
|
2919 | + } |
|
2799 | 2920 | |
2800 | 2921 | // Now, alternate them so they can be shown left and right ;). |
2801 | 2922 | $context['board_columns'] = array(); |
2802 | 2923 | for ($i = 0; $i < $max_boards; $i++) |
2803 | 2924 | { |
2804 | 2925 | $context['board_columns'][] = $temp_boards[$i]; |
2805 | - if (isset($temp_boards[$i + $max_boards])) |
|
2806 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
2807 | - else |
|
2808 | - $context['board_columns'][] = array(); |
|
2926 | + if (isset($temp_boards[$i + $max_boards])) { |
|
2927 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
2928 | + } else { |
|
2929 | + $context['board_columns'][] = array(); |
|
2930 | + } |
|
2809 | 2931 | } |
2810 | 2932 | |
2811 | 2933 | loadThemeOptions($memID); |
@@ -2874,8 +2996,9 @@ discard block |
||
2874 | 2996 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2875 | 2997 | { |
2876 | 2998 | // We should skip the administrator group if they don't have the admin_forum permission! |
2877 | - if ($row['id_group'] == 1 && !allowedTo('admin_forum')) |
|
2878 | - continue; |
|
2999 | + if ($row['id_group'] == 1 && !allowedTo('admin_forum')) { |
|
3000 | + continue; |
|
3001 | + } |
|
2879 | 3002 | |
2880 | 3003 | $context['member_groups'][$row['id_group']] = array( |
2881 | 3004 | 'id' => $row['id_group'], |
@@ -2921,16 +3044,17 @@ discard block |
||
2921 | 3044 | $context['max_signature_length'] = $context['signature_limits']['max_length']; |
2922 | 3045 | // Warning message for signature image limits? |
2923 | 3046 | $context['signature_warning'] = ''; |
2924 | - if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) |
|
2925 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
2926 | - elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) |
|
2927 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
3047 | + if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) { |
|
3048 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
3049 | + } elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) { |
|
3050 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
3051 | + } |
|
2928 | 3052 | |
2929 | 3053 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
2930 | 3054 | |
2931 | - if (empty($context['do_preview'])) |
|
2932 | - $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
2933 | - else |
|
3055 | + if (empty($context['do_preview'])) { |
|
3056 | + $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
3057 | + } else |
|
2934 | 3058 | { |
2935 | 3059 | $signature = !empty($_POST['signature']) ? $_POST['signature'] : ''; |
2936 | 3060 | $validation = profileValidateSignature($signature); |
@@ -2940,8 +3064,9 @@ discard block |
||
2940 | 3064 | $context['post_errors'] = array(); |
2941 | 3065 | } |
2942 | 3066 | $context['post_errors'][] = 'signature_not_yet_saved'; |
2943 | - if ($validation !== true && $validation !== false) |
|
2944 | - $context['post_errors'][] = $validation; |
|
3067 | + if ($validation !== true && $validation !== false) { |
|
3068 | + $context['post_errors'][] = $validation; |
|
3069 | + } |
|
2945 | 3070 | |
2946 | 3071 | censorText($context['member']['signature']); |
2947 | 3072 | $context['member']['current_signature'] = $context['member']['signature']; |
@@ -2951,8 +3076,9 @@ discard block |
||
2951 | 3076 | } |
2952 | 3077 | |
2953 | 3078 | // Load the spell checker? |
2954 | - if ($context['show_spellchecking']) |
|
2955 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
3079 | + if ($context['show_spellchecking']) { |
|
3080 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
3081 | + } |
|
2956 | 3082 | |
2957 | 3083 | return true; |
2958 | 3084 | } |
@@ -2986,8 +3112,7 @@ discard block |
||
2986 | 3112 | 'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11) |
2987 | 3113 | ); |
2988 | 3114 | $context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']); |
2989 | - } |
|
2990 | - elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
3115 | + } elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
2991 | 3116 | { |
2992 | 3117 | $context['member']['avatar'] += array( |
2993 | 3118 | 'choice' => 'upload', |
@@ -2995,34 +3120,34 @@ discard block |
||
2995 | 3120 | 'external' => 'http://' |
2996 | 3121 | ); |
2997 | 3122 | $context['member']['avatar']['href'] = empty($cur_profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $cur_profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $cur_profile['filename']; |
2998 | - } |
|
2999 | - elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) |
|
3000 | - $context['member']['avatar'] += array( |
|
3123 | + } elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) { |
|
3124 | + $context['member']['avatar'] += array( |
|
3001 | 3125 | 'choice' => 'external', |
3002 | 3126 | 'server_pic' => 'blank.png', |
3003 | 3127 | 'external' => $cur_profile['avatar'] |
3004 | 3128 | ); |
3005 | - elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) |
|
3006 | - $context['member']['avatar'] += array( |
|
3129 | + } elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) { |
|
3130 | + $context['member']['avatar'] += array( |
|
3007 | 3131 | 'choice' => 'server_stored', |
3008 | 3132 | 'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'], |
3009 | 3133 | 'external' => 'http://' |
3010 | 3134 | ); |
3011 | - else |
|
3012 | - $context['member']['avatar'] += array( |
|
3135 | + } else { |
|
3136 | + $context['member']['avatar'] += array( |
|
3013 | 3137 | 'choice' => 'none', |
3014 | 3138 | 'server_pic' => 'blank.png', |
3015 | 3139 | 'external' => 'http://' |
3016 | 3140 | ); |
3141 | + } |
|
3017 | 3142 | |
3018 | 3143 | // Get a list of all the avatars. |
3019 | 3144 | if ($context['member']['avatar']['allow_server_stored']) |
3020 | 3145 | { |
3021 | 3146 | $context['avatar_list'] = array(); |
3022 | 3147 | $context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array(); |
3148 | + } else { |
|
3149 | + $context['avatars'] = array(); |
|
3023 | 3150 | } |
3024 | - else |
|
3025 | - $context['avatars'] = array(); |
|
3026 | 3151 | |
3027 | 3152 | // Second level selected avatar... |
3028 | 3153 | $context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1); |
@@ -3051,19 +3176,22 @@ discard block |
||
3051 | 3176 | ) |
3052 | 3177 | ); |
3053 | 3178 | $protected_groups = array(1); |
3054 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3055 | - $protected_groups[] = $row['id_group']; |
|
3179 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3180 | + $protected_groups[] = $row['id_group']; |
|
3181 | + } |
|
3056 | 3182 | $smcFunc['db_free_result']($request); |
3057 | 3183 | |
3058 | 3184 | $protected_groups = array_unique($protected_groups); |
3059 | 3185 | } |
3060 | 3186 | |
3061 | 3187 | // The account page allows the change of your id_group - but not to a protected group! |
3062 | - if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) |
|
3063 | - $value = (int) $value; |
|
3188 | + if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) { |
|
3189 | + $value = (int) $value; |
|
3190 | + } |
|
3064 | 3191 | // ... otherwise it's the old group sir. |
3065 | - else |
|
3066 | - $value = $old_profile['id_group']; |
|
3192 | + else { |
|
3193 | + $value = $old_profile['id_group']; |
|
3194 | + } |
|
3067 | 3195 | |
3068 | 3196 | // Find the additional membergroups (if any) |
3069 | 3197 | if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups'])) |
@@ -3072,16 +3200,18 @@ discard block |
||
3072 | 3200 | foreach ($_POST['additional_groups'] as $group_id) |
3073 | 3201 | { |
3074 | 3202 | $group_id = (int) $group_id; |
3075 | - if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) |
|
3076 | - $additional_groups[] = $group_id; |
|
3203 | + if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) { |
|
3204 | + $additional_groups[] = $group_id; |
|
3205 | + } |
|
3077 | 3206 | } |
3078 | 3207 | |
3079 | 3208 | // Put the protected groups back in there if you don't have permission to take them away. |
3080 | 3209 | $old_additional_groups = explode(',', $old_profile['additional_groups']); |
3081 | 3210 | foreach ($old_additional_groups as $group_id) |
3082 | 3211 | { |
3083 | - if (!empty($protected_groups) && in_array($group_id, $protected_groups)) |
|
3084 | - $additional_groups[] = $group_id; |
|
3212 | + if (!empty($protected_groups) && in_array($group_id, $protected_groups)) { |
|
3213 | + $additional_groups[] = $group_id; |
|
3214 | + } |
|
3085 | 3215 | } |
3086 | 3216 | |
3087 | 3217 | if (implode(',', $additional_groups) !== $old_profile['additional_groups']) |
@@ -3113,18 +3243,20 @@ discard block |
||
3113 | 3243 | list ($another) = $smcFunc['db_fetch_row']($request); |
3114 | 3244 | $smcFunc['db_free_result']($request); |
3115 | 3245 | |
3116 | - if (empty($another)) |
|
3117 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
3246 | + if (empty($another)) { |
|
3247 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
3248 | + } |
|
3118 | 3249 | } |
3119 | 3250 | } |
3120 | 3251 | |
3121 | 3252 | // If we are changing group status, update permission cache as necessary. |
3122 | 3253 | if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups'])) |
3123 | 3254 | { |
3124 | - if ($context['user']['is_owner']) |
|
3125 | - $_SESSION['mc']['time'] = 0; |
|
3126 | - else |
|
3127 | - updateSettings(array('settings_updated' => time())); |
|
3255 | + if ($context['user']['is_owner']) { |
|
3256 | + $_SESSION['mc']['time'] = 0; |
|
3257 | + } else { |
|
3258 | + updateSettings(array('settings_updated' => time())); |
|
3259 | + } |
|
3128 | 3260 | } |
3129 | 3261 | |
3130 | 3262 | // Announce to any hooks that we have changed groups, but don't allow them to change it. |
@@ -3145,8 +3277,9 @@ discard block |
||
3145 | 3277 | global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context; |
3146 | 3278 | |
3147 | 3279 | $memID = $context['id_member']; |
3148 | - if (empty($memID) && !empty($context['password_auth_failed'])) |
|
3149 | - return false; |
|
3280 | + if (empty($memID) && !empty($context['password_auth_failed'])) { |
|
3281 | + return false; |
|
3282 | + } |
|
3150 | 3283 | |
3151 | 3284 | require_once($sourcedir . '/ManageAttachments.php'); |
3152 | 3285 | |
@@ -3157,8 +3290,9 @@ discard block |
||
3157 | 3290 | $downloadedExternalAvatar = false; |
3158 | 3291 | if ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external'])) |
3159 | 3292 | { |
3160 | - if (!is_writable($uploadDir)) |
|
3161 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
3293 | + if (!is_writable($uploadDir)) { |
|
3294 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
3295 | + } |
|
3162 | 3296 | |
3163 | 3297 | require_once($sourcedir . '/Subs-Package.php'); |
3164 | 3298 | |
@@ -3202,19 +3336,18 @@ discard block |
||
3202 | 3336 | |
3203 | 3337 | // Get rid of their old avatar. (if uploaded.) |
3204 | 3338 | removeAttachments(array('id_member' => $memID)); |
3205 | - } |
|
3206 | - elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
3339 | + } elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
3207 | 3340 | { |
3208 | 3341 | // One wasn't specified, or it's not allowed to use extra email addresses, or it's not a valid one, reset to default Gravatar. |
3209 | - if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) |
|
3210 | - $profile_vars['avatar'] = 'gravatar://'; |
|
3211 | - else |
|
3212 | - $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
3342 | + if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) { |
|
3343 | + $profile_vars['avatar'] = 'gravatar://'; |
|
3344 | + } else { |
|
3345 | + $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
3346 | + } |
|
3213 | 3347 | |
3214 | 3348 | // Get rid of their old avatar. (if uploaded.) |
3215 | 3349 | removeAttachments(array('id_member' => $memID)); |
3216 | - } |
|
3217 | - elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
3350 | + } elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
3218 | 3351 | { |
3219 | 3352 | // We need these clean... |
3220 | 3353 | $cur_profile['id_attach'] = 0; |
@@ -3226,11 +3359,13 @@ discard block |
||
3226 | 3359 | |
3227 | 3360 | $profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal'])); |
3228 | 3361 | |
3229 | - if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') |
|
3230 | - $profile_vars['avatar'] = ''; |
|
3362 | + if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') { |
|
3363 | + $profile_vars['avatar'] = ''; |
|
3364 | + } |
|
3231 | 3365 | // Trying to make us do something we'll regret? |
3232 | - elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') |
|
3233 | - return 'bad_avatar_invalid_url'; |
|
3366 | + elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') { |
|
3367 | + return 'bad_avatar_invalid_url'; |
|
3368 | + } |
|
3234 | 3369 | // Should we check dimensions? |
3235 | 3370 | elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external'])) |
3236 | 3371 | { |
@@ -3240,9 +3375,9 @@ discard block |
||
3240 | 3375 | if (is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external'])))) |
3241 | 3376 | { |
3242 | 3377 | // Houston, we have a problem. The avatar is too large!! |
3243 | - if ($modSettings['avatar_action_too_large'] == 'option_refuse') |
|
3244 | - return 'bad_avatar_too_large'; |
|
3245 | - elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
3378 | + if ($modSettings['avatar_action_too_large'] == 'option_refuse') { |
|
3379 | + return 'bad_avatar_too_large'; |
|
3380 | + } elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
3246 | 3381 | { |
3247 | 3382 | // @todo remove this if appropriate |
3248 | 3383 | require_once($sourcedir . '/Subs-Graphics.php'); |
@@ -3252,26 +3387,27 @@ discard block |
||
3252 | 3387 | $cur_profile['id_attach'] = $modSettings['new_avatar_data']['id']; |
3253 | 3388 | $cur_profile['filename'] = $modSettings['new_avatar_data']['filename']; |
3254 | 3389 | $cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type']; |
3390 | + } else { |
|
3391 | + return 'bad_avatar'; |
|
3255 | 3392 | } |
3256 | - else |
|
3257 | - return 'bad_avatar'; |
|
3258 | 3393 | } |
3259 | 3394 | } |
3260 | 3395 | } |
3261 | - } |
|
3262 | - elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
3396 | + } elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
3263 | 3397 | { |
3264 | 3398 | if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar) |
3265 | 3399 | { |
3266 | 3400 | // Get the dimensions of the image. |
3267 | 3401 | if (!$downloadedExternalAvatar) |
3268 | 3402 | { |
3269 | - if (!is_writable($uploadDir)) |
|
3270 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
3403 | + if (!is_writable($uploadDir)) { |
|
3404 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
3405 | + } |
|
3271 | 3406 | |
3272 | 3407 | $new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true); |
3273 | - if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) |
|
3274 | - fatal_lang_error('attach_timeout', 'critical'); |
|
3408 | + if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) { |
|
3409 | + fatal_lang_error('attach_timeout', 'critical'); |
|
3410 | + } |
|
3275 | 3411 | |
3276 | 3412 | $_FILES['attachment']['tmp_name'] = $new_filename; |
3277 | 3413 | } |
@@ -3384,17 +3520,19 @@ discard block |
||
3384 | 3520 | $profile_vars['avatar'] = ''; |
3385 | 3521 | |
3386 | 3522 | // Delete any temporary file. |
3387 | - if (file_exists($_FILES['attachment']['tmp_name'])) |
|
3388 | - @unlink($_FILES['attachment']['tmp_name']); |
|
3523 | + if (file_exists($_FILES['attachment']['tmp_name'])) { |
|
3524 | + @unlink($_FILES['attachment']['tmp_name']); |
|
3525 | + } |
|
3389 | 3526 | } |
3390 | 3527 | // Selected the upload avatar option and had one already uploaded before or didn't upload one. |
3391 | - else |
|
3528 | + else { |
|
3529 | + $profile_vars['avatar'] = ''; |
|
3530 | + } |
|
3531 | + } elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) { |
|
3532 | + $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
3533 | + } else { |
|
3392 | 3534 | $profile_vars['avatar'] = ''; |
3393 | 3535 | } |
3394 | - elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) |
|
3395 | - $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
3396 | - else |
|
3397 | - $profile_vars['avatar'] = ''; |
|
3398 | 3536 | |
3399 | 3537 | // Setup the profile variables so it shows things right on display! |
3400 | 3538 | $cur_profile['avatar'] = $profile_vars['avatar']; |
@@ -3442,9 +3580,9 @@ discard block |
||
3442 | 3580 | $smiley_parsed = $unparsed_signature; |
3443 | 3581 | parsesmileys($smiley_parsed); |
3444 | 3582 | $smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img'); |
3445 | - if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) |
|
3446 | - return 'signature_allow_smileys'; |
|
3447 | - elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
3583 | + if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) { |
|
3584 | + return 'signature_allow_smileys'; |
|
3585 | + } elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
3448 | 3586 | { |
3449 | 3587 | $txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]); |
3450 | 3588 | return 'signature_max_smileys'; |
@@ -3457,14 +3595,15 @@ discard block |
||
3457 | 3595 | { |
3458 | 3596 | $limit_broke = 0; |
3459 | 3597 | // Attempt to allow all sizes of abuse, so to speak. |
3460 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
3461 | - $limit_broke = $sig_limits[7] . 'px'; |
|
3462 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
3463 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
3464 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
3465 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
3466 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
3467 | - $limit_broke = 'large'; |
|
3598 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
3599 | + $limit_broke = $sig_limits[7] . 'px'; |
|
3600 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
3601 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
3602 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
3603 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
3604 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
3605 | + $limit_broke = 'large'; |
|
3606 | + } |
|
3468 | 3607 | |
3469 | 3608 | if ($limit_broke) |
3470 | 3609 | { |
@@ -3506,24 +3645,26 @@ discard block |
||
3506 | 3645 | $width = -1; $height = -1; |
3507 | 3646 | |
3508 | 3647 | // Does it have predefined restraints? Width first. |
3509 | - if ($matches[6][$key]) |
|
3510 | - $matches[2][$key] = $matches[6][$key]; |
|
3648 | + if ($matches[6][$key]) { |
|
3649 | + $matches[2][$key] = $matches[6][$key]; |
|
3650 | + } |
|
3511 | 3651 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
3512 | 3652 | { |
3513 | 3653 | $width = $sig_limits[5]; |
3514 | 3654 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
3655 | + } elseif ($matches[2][$key]) { |
|
3656 | + $width = $matches[2][$key]; |
|
3515 | 3657 | } |
3516 | - elseif ($matches[2][$key]) |
|
3517 | - $width = $matches[2][$key]; |
|
3518 | 3658 | // ... and height. |
3519 | 3659 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
3520 | 3660 | { |
3521 | 3661 | $height = $sig_limits[6]; |
3522 | - if ($width != -1) |
|
3523 | - $width = $width * ($height / $matches[4][$key]); |
|
3662 | + if ($width != -1) { |
|
3663 | + $width = $width * ($height / $matches[4][$key]); |
|
3664 | + } |
|
3665 | + } elseif ($matches[4][$key]) { |
|
3666 | + $height = $matches[4][$key]; |
|
3524 | 3667 | } |
3525 | - elseif ($matches[4][$key]) |
|
3526 | - $height = $matches[4][$key]; |
|
3527 | 3668 | |
3528 | 3669 | // If the dimensions are still not fixed - we need to check the actual image. |
3529 | 3670 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -3541,21 +3682,24 @@ discard block |
||
3541 | 3682 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
3542 | 3683 | { |
3543 | 3684 | $height = $sig_limits[6]; |
3544 | - if ($width == -1) |
|
3545 | - $width = $sizes[0]; |
|
3685 | + if ($width == -1) { |
|
3686 | + $width = $sizes[0]; |
|
3687 | + } |
|
3546 | 3688 | $width = $width * ($height / $sizes[1]); |
3689 | + } elseif ($width != -1) { |
|
3690 | + $height = $sizes[1]; |
|
3547 | 3691 | } |
3548 | - elseif ($width != -1) |
|
3549 | - $height = $sizes[1]; |
|
3550 | 3692 | } |
3551 | 3693 | } |
3552 | 3694 | |
3553 | 3695 | // Did we come up with some changes? If so remake the string. |
3554 | - if ($width != -1 || $height != -1) |
|
3555 | - $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
3696 | + if ($width != -1 || $height != -1) { |
|
3697 | + $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
3698 | + } |
|
3699 | + } |
|
3700 | + if (!empty($replaces)) { |
|
3701 | + $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
3556 | 3702 | } |
3557 | - if (!empty($replaces)) |
|
3558 | - $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
3559 | 3703 | } |
3560 | 3704 | } |
3561 | 3705 | |
@@ -3599,10 +3743,12 @@ discard block |
||
3599 | 3743 | $email = strtr($email, array(''' => '\'')); |
3600 | 3744 | |
3601 | 3745 | // Check the name and email for validity. |
3602 | - if (trim($email) == '') |
|
3603 | - return 'no_email'; |
|
3604 | - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) |
|
3605 | - return 'bad_email'; |
|
3746 | + if (trim($email) == '') { |
|
3747 | + return 'no_email'; |
|
3748 | + } |
|
3749 | + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
3750 | + return 'bad_email'; |
|
3751 | + } |
|
3606 | 3752 | |
3607 | 3753 | // Email addresses should be and stay unique. |
3608 | 3754 | $request = $smcFunc['db_query']('', ' |
@@ -3617,8 +3763,9 @@ discard block |
||
3617 | 3763 | ) |
3618 | 3764 | ); |
3619 | 3765 | |
3620 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
3621 | - return 'email_taken'; |
|
3766 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
3767 | + return 'email_taken'; |
|
3768 | + } |
|
3622 | 3769 | $smcFunc['db_free_result']($request); |
3623 | 3770 | |
3624 | 3771 | return true; |
@@ -3631,8 +3778,9 @@ discard block |
||
3631 | 3778 | { |
3632 | 3779 | global $modSettings, $context, $cur_profile; |
3633 | 3780 | |
3634 | - if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') |
|
3635 | - setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
3781 | + if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') { |
|
3782 | + setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
3783 | + } |
|
3636 | 3784 | |
3637 | 3785 | loadUserSettings(); |
3638 | 3786 | writeLog(); |
@@ -3648,8 +3796,9 @@ discard block |
||
3648 | 3796 | require_once($sourcedir . '/Subs-Post.php'); |
3649 | 3797 | |
3650 | 3798 | // Shouldn't happen but just in case. |
3651 | - if (empty($profile_vars['email_address'])) |
|
3652 | - return; |
|
3799 | + if (empty($profile_vars['email_address'])) { |
|
3800 | + return; |
|
3801 | + } |
|
3653 | 3802 | |
3654 | 3803 | $replacements = array( |
3655 | 3804 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'], |
@@ -3672,8 +3821,9 @@ discard block |
||
3672 | 3821 | $_SESSION['log_time'] = 0; |
3673 | 3822 | $_SESSION['login_' . $cookiename] = json_encode(array(0, '', 0)); |
3674 | 3823 | |
3675 | - if (isset($_COOKIE[$cookiename])) |
|
3676 | - $_COOKIE[$cookiename] = ''; |
|
3824 | + if (isset($_COOKIE[$cookiename])) { |
|
3825 | + $_COOKIE[$cookiename] = ''; |
|
3826 | + } |
|
3677 | 3827 | |
3678 | 3828 | loadUserSettings(); |
3679 | 3829 | |
@@ -3706,11 +3856,13 @@ discard block |
||
3706 | 3856 | $groups[] = $curMember['id_group']; |
3707 | 3857 | |
3708 | 3858 | // Ensure the query doesn't croak! |
3709 | - if (empty($groups)) |
|
3710 | - $groups = array(0); |
|
3859 | + if (empty($groups)) { |
|
3860 | + $groups = array(0); |
|
3861 | + } |
|
3711 | 3862 | // Just to be sure... |
3712 | - foreach ($groups as $k => $v) |
|
3713 | - $groups[$k] = (int) $v; |
|
3863 | + foreach ($groups as $k => $v) { |
|
3864 | + $groups[$k] = (int) $v; |
|
3865 | + } |
|
3714 | 3866 | |
3715 | 3867 | // Get all the membergroups they can join. |
3716 | 3868 | $request = $smcFunc['db_query']('', ' |
@@ -3740,12 +3892,14 @@ discard block |
||
3740 | 3892 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
3741 | 3893 | { |
3742 | 3894 | // Can they edit their primary group? |
3743 | - if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) |
|
3744 | - $context['can_edit_primary'] = true; |
|
3895 | + if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) { |
|
3896 | + $context['can_edit_primary'] = true; |
|
3897 | + } |
|
3745 | 3898 | |
3746 | 3899 | // If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it. |
3747 | - if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) |
|
3748 | - continue; |
|
3900 | + if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) { |
|
3901 | + continue; |
|
3902 | + } |
|
3749 | 3903 | |
3750 | 3904 | $context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array( |
3751 | 3905 | 'id' => $row['id_group'], |
@@ -3774,13 +3928,15 @@ discard block |
||
3774 | 3928 | ); |
3775 | 3929 | |
3776 | 3930 | // No changing primary one unless you have enough groups! |
3777 | - if (count($context['groups']['member']) < 2) |
|
3778 | - $context['can_edit_primary'] = false; |
|
3931 | + if (count($context['groups']['member']) < 2) { |
|
3932 | + $context['can_edit_primary'] = false; |
|
3933 | + } |
|
3779 | 3934 | |
3780 | 3935 | // In the special case that someone is requesting membership of a group, setup some special context vars. |
3781 | - if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) |
|
3782 | - $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
3783 | -} |
|
3936 | + if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) { |
|
3937 | + $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
3938 | + } |
|
3939 | + } |
|
3784 | 3940 | |
3785 | 3941 | /** |
3786 | 3942 | * This function actually makes all the group changes |
@@ -3795,10 +3951,12 @@ discard block |
||
3795 | 3951 | global $user_info, $context, $user_profile, $modSettings, $smcFunc; |
3796 | 3952 | |
3797 | 3953 | // Let's be extra cautious... |
3798 | - if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) |
|
3799 | - isAllowedTo('manage_membergroups'); |
|
3800 | - if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) |
|
3801 | - fatal_lang_error('no_access', false); |
|
3954 | + if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) { |
|
3955 | + isAllowedTo('manage_membergroups'); |
|
3956 | + } |
|
3957 | + if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) { |
|
3958 | + fatal_lang_error('no_access', false); |
|
3959 | + } |
|
3802 | 3960 | |
3803 | 3961 | checkSession(isset($_GET['gid']) ? 'get' : 'post'); |
3804 | 3962 | |
@@ -3817,8 +3975,9 @@ discard block |
||
3817 | 3975 | $foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false; |
3818 | 3976 | |
3819 | 3977 | // Sanity check!! |
3820 | - if ($group_id == 1) |
|
3821 | - isAllowedTo('admin_forum'); |
|
3978 | + if ($group_id == 1) { |
|
3979 | + isAllowedTo('admin_forum'); |
|
3980 | + } |
|
3822 | 3981 | // Protected groups too! |
3823 | 3982 | else |
3824 | 3983 | { |
@@ -3835,8 +3994,9 @@ discard block |
||
3835 | 3994 | list ($is_protected) = $smcFunc['db_fetch_row']($request); |
3836 | 3995 | $smcFunc['db_free_result']($request); |
3837 | 3996 | |
3838 | - if ($is_protected == 1) |
|
3839 | - isAllowedTo('admin_forum'); |
|
3997 | + if ($is_protected == 1) { |
|
3998 | + isAllowedTo('admin_forum'); |
|
3999 | + } |
|
3840 | 4000 | } |
3841 | 4001 | |
3842 | 4002 | // What ever we are doing, we need to determine if changing primary is possible! |
@@ -3858,36 +4018,43 @@ discard block |
||
3858 | 4018 | $group_name = $row['group_name']; |
3859 | 4019 | |
3860 | 4020 | // Does the group type match what we're doing - are we trying to request a non-requestable group? |
3861 | - if ($changeType == 'request' && $row['group_type'] != 2) |
|
3862 | - fatal_lang_error('no_access', false); |
|
4021 | + if ($changeType == 'request' && $row['group_type'] != 2) { |
|
4022 | + fatal_lang_error('no_access', false); |
|
4023 | + } |
|
3863 | 4024 | // What about leaving a requestable group we are not a member of? |
3864 | - elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) |
|
3865 | - fatal_lang_error('no_access', false); |
|
3866 | - elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) |
|
3867 | - fatal_lang_error('no_access', false); |
|
4025 | + elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) { |
|
4026 | + fatal_lang_error('no_access', false); |
|
4027 | + } elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) { |
|
4028 | + fatal_lang_error('no_access', false); |
|
4029 | + } |
|
3868 | 4030 | |
3869 | 4031 | // We can't change the primary group if this is hidden! |
3870 | - if ($row['hidden'] == 2) |
|
3871 | - $canChangePrimary = false; |
|
4032 | + if ($row['hidden'] == 2) { |
|
4033 | + $canChangePrimary = false; |
|
4034 | + } |
|
3872 | 4035 | } |
3873 | 4036 | |
3874 | 4037 | // If this is their old primary, can we change it? |
3875 | - if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) |
|
3876 | - $canChangePrimary = 1; |
|
4038 | + if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) { |
|
4039 | + $canChangePrimary = 1; |
|
4040 | + } |
|
3877 | 4041 | |
3878 | 4042 | // If we are not doing a force primary move, don't do it automatically if current primary is not 0. |
3879 | - if ($changeType != 'primary' && $old_profile['id_group'] != 0) |
|
3880 | - $canChangePrimary = false; |
|
4043 | + if ($changeType != 'primary' && $old_profile['id_group'] != 0) { |
|
4044 | + $canChangePrimary = false; |
|
4045 | + } |
|
3881 | 4046 | |
3882 | 4047 | // If this is the one we are acting on, can we even act? |
3883 | - if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) |
|
3884 | - $canChangePrimary = false; |
|
4048 | + if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) { |
|
4049 | + $canChangePrimary = false; |
|
4050 | + } |
|
3885 | 4051 | } |
3886 | 4052 | $smcFunc['db_free_result']($request); |
3887 | 4053 | |
3888 | 4054 | // Didn't find the target? |
3889 | - if (!$foundTarget) |
|
3890 | - fatal_lang_error('no_access', false); |
|
4055 | + if (!$foundTarget) { |
|
4056 | + fatal_lang_error('no_access', false); |
|
4057 | + } |
|
3891 | 4058 | |
3892 | 4059 | // Final security check, don't allow users to promote themselves to admin. |
3893 | 4060 | if ($context['can_manage_membergroups'] && !allowedTo('admin_forum')) |
@@ -3907,8 +4074,9 @@ discard block |
||
3907 | 4074 | list ($disallow) = $smcFunc['db_fetch_row']($request); |
3908 | 4075 | $smcFunc['db_free_result']($request); |
3909 | 4076 | |
3910 | - if ($disallow) |
|
3911 | - isAllowedTo('admin_forum'); |
|
4077 | + if ($disallow) { |
|
4078 | + isAllowedTo('admin_forum'); |
|
4079 | + } |
|
3912 | 4080 | } |
3913 | 4081 | |
3914 | 4082 | // If we're requesting, add the note then return. |
@@ -3926,8 +4094,9 @@ discard block |
||
3926 | 4094 | 'status_open' => 0, |
3927 | 4095 | ) |
3928 | 4096 | ); |
3929 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
3930 | - fatal_lang_error('profile_error_already_requested_group'); |
|
4097 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
4098 | + fatal_lang_error('profile_error_already_requested_group'); |
|
4099 | + } |
|
3931 | 4100 | $smcFunc['db_free_result']($request); |
3932 | 4101 | |
3933 | 4102 | // Log the request. |
@@ -3961,10 +4130,11 @@ discard block |
||
3961 | 4130 | // Are we leaving? |
3962 | 4131 | if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id])) |
3963 | 4132 | { |
3964 | - if ($old_profile['id_group'] == $group_id) |
|
3965 | - $newPrimary = 0; |
|
3966 | - else |
|
3967 | - unset($addGroups[$group_id]); |
|
4133 | + if ($old_profile['id_group'] == $group_id) { |
|
4134 | + $newPrimary = 0; |
|
4135 | + } else { |
|
4136 | + unset($addGroups[$group_id]); |
|
4137 | + } |
|
3968 | 4138 | } |
3969 | 4139 | // ... if not, must be joining. |
3970 | 4140 | else |
@@ -3972,36 +4142,42 @@ discard block |
||
3972 | 4142 | // Can we change the primary, and do we want to? |
3973 | 4143 | if ($canChangePrimary) |
3974 | 4144 | { |
3975 | - if ($old_profile['id_group'] != 0) |
|
3976 | - $addGroups[$old_profile['id_group']] = -1; |
|
4145 | + if ($old_profile['id_group'] != 0) { |
|
4146 | + $addGroups[$old_profile['id_group']] = -1; |
|
4147 | + } |
|
3977 | 4148 | $newPrimary = $group_id; |
3978 | 4149 | } |
3979 | 4150 | // Otherwise it's an additional group... |
3980 | - else |
|
3981 | - $addGroups[$group_id] = -1; |
|
4151 | + else { |
|
4152 | + $addGroups[$group_id] = -1; |
|
4153 | + } |
|
3982 | 4154 | } |
3983 | 4155 | } |
3984 | 4156 | // Finally, we must be setting the primary. |
3985 | 4157 | elseif ($canChangePrimary) |
3986 | 4158 | { |
3987 | - if ($old_profile['id_group'] != 0) |
|
3988 | - $addGroups[$old_profile['id_group']] = -1; |
|
3989 | - if (isset($addGroups[$group_id])) |
|
3990 | - unset($addGroups[$group_id]); |
|
4159 | + if ($old_profile['id_group'] != 0) { |
|
4160 | + $addGroups[$old_profile['id_group']] = -1; |
|
4161 | + } |
|
4162 | + if (isset($addGroups[$group_id])) { |
|
4163 | + unset($addGroups[$group_id]); |
|
4164 | + } |
|
3991 | 4165 | $newPrimary = $group_id; |
3992 | 4166 | } |
3993 | 4167 | |
3994 | 4168 | // Finally, we can make the changes! |
3995 | - foreach ($addGroups as $id => $dummy) |
|
3996 | - if (empty($id)) |
|
4169 | + foreach ($addGroups as $id => $dummy) { |
|
4170 | + if (empty($id)) |
|
3997 | 4171 | unset($addGroups[$id]); |
4172 | + } |
|
3998 | 4173 | $addGroups = implode(',', array_flip($addGroups)); |
3999 | 4174 | |
4000 | 4175 | // Ensure that we don't cache permissions if the group is changing. |
4001 | - if ($context['user']['is_owner']) |
|
4002 | - $_SESSION['mc']['time'] = 0; |
|
4003 | - else |
|
4004 | - updateSettings(array('settings_updated' => time())); |
|
4176 | + if ($context['user']['is_owner']) { |
|
4177 | + $_SESSION['mc']['time'] = 0; |
|
4178 | + } else { |
|
4179 | + updateSettings(array('settings_updated' => time())); |
|
4180 | + } |
|
4005 | 4181 | |
4006 | 4182 | updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups)); |
4007 | 4183 | |
@@ -4024,8 +4200,9 @@ discard block |
||
4024 | 4200 | if (empty($user_settings['tfa_secret']) && $context['user']['is_owner']) |
4025 | 4201 | { |
4026 | 4202 | // Check to ensure we're forcing SSL for authentication |
4027 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
4028 | - fatal_lang_error('login_ssl_required'); |
|
4203 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
4204 | + fatal_lang_error('login_ssl_required'); |
|
4205 | + } |
|
4029 | 4206 | |
4030 | 4207 | // In some cases (forced 2FA or backup code) they would be forced to be redirected here, |
4031 | 4208 | // we do not want too much AJAX to confuse them. |
@@ -4062,8 +4239,7 @@ discard block |
||
4062 | 4239 | $context['sub_template'] = 'tfasetup_backup'; |
4063 | 4240 | |
4064 | 4241 | return; |
4065 | - } |
|
4066 | - else |
|
4242 | + } else |
|
4067 | 4243 | { |
4068 | 4244 | $context['tfa_secret'] = $_SESSION['tfa_secret']; |
4069 | 4245 | $context['tfa_error'] = !$valid_code; |
@@ -4071,8 +4247,7 @@ discard block |
||
4071 | 4247 | $context['tfa_pass_value'] = $_POST['passwd']; |
4072 | 4248 | $context['tfa_value'] = $_POST['tfa_code']; |
4073 | 4249 | } |
4074 | - } |
|
4075 | - else |
|
4250 | + } else |
|
4076 | 4251 | { |
4077 | 4252 | $totp = new \TOTP\Auth(); |
4078 | 4253 | $secret = $totp->generateCode(); |
@@ -4082,17 +4257,16 @@ discard block |
||
4082 | 4257 | } |
4083 | 4258 | |
4084 | 4259 | $context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']); |
4085 | - } |
|
4086 | - elseif (isset($_REQUEST['disable'])) |
|
4260 | + } elseif (isset($_REQUEST['disable'])) |
|
4087 | 4261 | { |
4088 | 4262 | updateMemberData($memID, array( |
4089 | 4263 | 'tfa_secret' => '', |
4090 | 4264 | 'tfa_backup' => '', |
4091 | 4265 | )); |
4092 | 4266 | redirectexit('action=profile;area=account;u=' . $memID); |
4267 | + } else { |
|
4268 | + redirectexit('action=profile;area=account;u=' . $memID); |
|
4269 | + } |
|
4093 | 4270 | } |
4094 | - else |
|
4095 | - redirectexit('action=profile;area=account;u=' . $memID); |
|
4096 | -} |
|
4097 | 4271 | |
4098 | 4272 | ?> |
4099 | 4273 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Maps the implementations in this file (smf_db_function_name) |
@@ -34,8 +35,8 @@ discard block |
||
34 | 35 | global $smcFunc; |
35 | 36 | |
36 | 37 | // Map some database specific functions, only do this once. |
37 | - if (!isset($smcFunc['db_fetch_assoc']) || $smcFunc['db_fetch_assoc'] != 'postg_fetch_assoc') |
|
38 | - $smcFunc += array( |
|
38 | + if (!isset($smcFunc['db_fetch_assoc']) || $smcFunc['db_fetch_assoc'] != 'postg_fetch_assoc') { |
|
39 | + $smcFunc += array( |
|
39 | 40 | 'db_query' => 'smf_db_query', |
40 | 41 | 'db_quote' => 'smf_db_quote', |
41 | 42 | 'db_insert' => 'smf_db_insert', |
@@ -59,11 +60,13 @@ discard block |
||
59 | 60 | 'db_escape_wildcard_string' => 'smf_db_escape_wildcard_string', |
60 | 61 | 'db_is_resource' => 'is_resource', |
61 | 62 | ); |
63 | + } |
|
62 | 64 | |
63 | - if (!empty($db_options['persist'])) |
|
64 | - $connection = @pg_pconnect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
65 | - else |
|
66 | - $connection = @pg_connect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
65 | + if (!empty($db_options['persist'])) { |
|
66 | + $connection = @pg_pconnect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
67 | + } else { |
|
68 | + $connection = @pg_connect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
69 | + } |
|
67 | 70 | |
68 | 71 | // Something's wrong, show an error if its fatal (which we assume it is) |
69 | 72 | if (!$connection) |
@@ -71,8 +74,7 @@ discard block |
||
71 | 74 | if (!empty($db_options['non_fatal'])) |
72 | 75 | { |
73 | 76 | return null; |
74 | - } |
|
75 | - else |
|
77 | + } else |
|
76 | 78 | { |
77 | 79 | display_db_error(); |
78 | 80 | } |
@@ -123,34 +125,42 @@ discard block |
||
123 | 125 | |
124 | 126 | list ($values, $connection) = $db_callback; |
125 | 127 | |
126 | - if ($matches[1] === 'db_prefix') |
|
127 | - return $db_prefix; |
|
128 | + if ($matches[1] === 'db_prefix') { |
|
129 | + return $db_prefix; |
|
130 | + } |
|
128 | 131 | |
129 | - if ($matches[1] === 'query_see_board') |
|
130 | - return $user_info['query_see_board']; |
|
132 | + if ($matches[1] === 'query_see_board') { |
|
133 | + return $user_info['query_see_board']; |
|
134 | + } |
|
131 | 135 | |
132 | - if ($matches[1] === 'query_wanna_see_board') |
|
133 | - return $user_info['query_wanna_see_board']; |
|
136 | + if ($matches[1] === 'query_wanna_see_board') { |
|
137 | + return $user_info['query_wanna_see_board']; |
|
138 | + } |
|
134 | 139 | |
135 | - if ($matches[1] === 'empty') |
|
136 | - return '\'\''; |
|
140 | + if ($matches[1] === 'empty') { |
|
141 | + return '\'\''; |
|
142 | + } |
|
137 | 143 | |
138 | - if (!isset($matches[2])) |
|
139 | - smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
144 | + if (!isset($matches[2])) { |
|
145 | + smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
146 | + } |
|
140 | 147 | |
141 | - if ($matches[1] === 'literal') |
|
142 | - return '\'' . pg_escape_string($matches[2]) . '\''; |
|
148 | + if ($matches[1] === 'literal') { |
|
149 | + return '\'' . pg_escape_string($matches[2]) . '\''; |
|
150 | + } |
|
143 | 151 | |
144 | - if (!isset($values[$matches[2]])) |
|
145 | - smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
152 | + if (!isset($values[$matches[2]])) { |
|
153 | + smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
154 | + } |
|
146 | 155 | |
147 | 156 | $replacement = $values[$matches[2]]; |
148 | 157 | |
149 | 158 | switch ($matches[1]) |
150 | 159 | { |
151 | 160 | case 'int': |
152 | - if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) |
|
153 | - smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
161 | + if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) { |
|
162 | + smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
163 | + } |
|
154 | 164 | return (string) (int) $replacement; |
155 | 165 | break; |
156 | 166 | |
@@ -162,56 +172,63 @@ discard block |
||
162 | 172 | case 'array_int': |
163 | 173 | if (is_array($replacement)) |
164 | 174 | { |
165 | - if (empty($replacement)) |
|
166 | - smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
175 | + if (empty($replacement)) { |
|
176 | + smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
177 | + } |
|
167 | 178 | |
168 | 179 | foreach ($replacement as $key => $value) |
169 | 180 | { |
170 | - if (!is_numeric($value) || (string) $value !== (string) (int) $value) |
|
171 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
181 | + if (!is_numeric($value) || (string) $value !== (string) (int) $value) { |
|
182 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
183 | + } |
|
172 | 184 | |
173 | 185 | $replacement[$key] = (string) (int) $value; |
174 | 186 | } |
175 | 187 | |
176 | 188 | return implode(', ', $replacement); |
189 | + } else { |
|
190 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
177 | 191 | } |
178 | - else |
|
179 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
180 | 192 | |
181 | 193 | break; |
182 | 194 | |
183 | 195 | case 'array_string': |
184 | 196 | if (is_array($replacement)) |
185 | 197 | { |
186 | - if (empty($replacement)) |
|
187 | - smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
198 | + if (empty($replacement)) { |
|
199 | + smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
200 | + } |
|
188 | 201 | |
189 | - foreach ($replacement as $key => $value) |
|
190 | - $replacement[$key] = sprintf('\'%1$s\'', pg_escape_string($value)); |
|
202 | + foreach ($replacement as $key => $value) { |
|
203 | + $replacement[$key] = sprintf('\'%1$s\'', pg_escape_string($value)); |
|
204 | + } |
|
191 | 205 | |
192 | 206 | return implode(', ', $replacement); |
207 | + } else { |
|
208 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
193 | 209 | } |
194 | - else |
|
195 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
196 | 210 | break; |
197 | 211 | |
198 | 212 | case 'date': |
199 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
|
200 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
201 | - else |
|
202 | - smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
213 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) { |
|
214 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
215 | + } else { |
|
216 | + smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
217 | + } |
|
203 | 218 | break; |
204 | 219 | |
205 | 220 | case 'time': |
206 | - if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
|
207 | - return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
208 | - else |
|
209 | - smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
221 | + if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) { |
|
222 | + return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
223 | + } else { |
|
224 | + smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
225 | + } |
|
210 | 226 | break; |
211 | 227 | |
212 | 228 | case 'float': |
213 | - if (!is_numeric($replacement)) |
|
214 | - smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
229 | + if (!is_numeric($replacement)) { |
|
230 | + smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
231 | + } |
|
215 | 232 | return (string) (float) $replacement; |
216 | 233 | break; |
217 | 234 | |
@@ -224,31 +241,36 @@ discard block |
||
224 | 241 | break; |
225 | 242 | |
226 | 243 | case 'inet': |
227 | - if ($replacement == 'null' || $replacement == '') |
|
228 | - return 'null'; |
|
229 | - if (inet_pton($replacement) === false) |
|
230 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
244 | + if ($replacement == 'null' || $replacement == '') { |
|
245 | + return 'null'; |
|
246 | + } |
|
247 | + if (inet_pton($replacement) === false) { |
|
248 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
249 | + } |
|
231 | 250 | return sprintf('\'%1$s\'::inet', pg_escape_string($replacement)); |
232 | 251 | |
233 | 252 | case 'array_inet': |
234 | 253 | if (is_array($replacement)) |
235 | 254 | { |
236 | - if (empty($replacement)) |
|
237 | - smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
255 | + if (empty($replacement)) { |
|
256 | + smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
257 | + } |
|
238 | 258 | |
239 | 259 | foreach ($replacement as $key => $value) |
240 | 260 | { |
241 | - if ($replacement == 'null' || $replacement == '') |
|
242 | - $replacement[$key] = 'null'; |
|
243 | - if (!isValidIP($value)) |
|
244 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
261 | + if ($replacement == 'null' || $replacement == '') { |
|
262 | + $replacement[$key] = 'null'; |
|
263 | + } |
|
264 | + if (!isValidIP($value)) { |
|
265 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
266 | + } |
|
245 | 267 | $replacement[$key] = sprintf('\'%1$s\'::inet', pg_escape_string($value)); |
246 | 268 | } |
247 | 269 | |
248 | 270 | return implode(', ', $replacement); |
271 | + } else { |
|
272 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
249 | 273 | } |
250 | - else |
|
251 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
252 | 274 | break; |
253 | 275 | |
254 | 276 | default: |
@@ -335,14 +357,16 @@ discard block |
||
335 | 357 | ), |
336 | 358 | ); |
337 | 359 | |
338 | - if (isset($replacements[$identifier])) |
|
339 | - $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
360 | + if (isset($replacements[$identifier])) { |
|
361 | + $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
362 | + } |
|
340 | 363 | |
341 | 364 | // Limits need to be a little different. |
342 | 365 | $db_string = preg_replace('~\sLIMIT\s(\d+|{int:.+}),\s*(\d+|{int:.+})\s*$~i', 'LIMIT $2 OFFSET $1', $db_string); |
343 | 366 | |
344 | - if (trim($db_string) == '') |
|
345 | - return false; |
|
367 | + if (trim($db_string) == '') { |
|
368 | + return false; |
|
369 | + } |
|
346 | 370 | |
347 | 371 | // Comments that are allowed in a query are preg_removed. |
348 | 372 | static $allowed_comments_from = array( |
@@ -362,8 +386,9 @@ discard block |
||
362 | 386 | $db_count = !isset($db_count) ? 1 : $db_count + 1; |
363 | 387 | $db_replace_result = 0; |
364 | 388 | |
365 | - if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) |
|
366 | - smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
389 | + if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) { |
|
390 | + smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
391 | + } |
|
367 | 392 | |
368 | 393 | if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false)) |
369 | 394 | { |
@@ -384,8 +409,9 @@ discard block |
||
384 | 409 | list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__); |
385 | 410 | |
386 | 411 | // Initialize $db_cache if not already initialized. |
387 | - if (!isset($db_cache)) |
|
388 | - $db_cache = array(); |
|
412 | + if (!isset($db_cache)) { |
|
413 | + $db_cache = array(); |
|
414 | + } |
|
389 | 415 | |
390 | 416 | if (!empty($_SESSION['debug_redirect'])) |
391 | 417 | { |
@@ -411,17 +437,18 @@ discard block |
||
411 | 437 | while (true) |
412 | 438 | { |
413 | 439 | $pos = strpos($db_string, '\'', $pos + 1); |
414 | - if ($pos === false) |
|
415 | - break; |
|
440 | + if ($pos === false) { |
|
441 | + break; |
|
442 | + } |
|
416 | 443 | $clean .= substr($db_string, $old_pos, $pos - $old_pos); |
417 | 444 | |
418 | 445 | while (true) |
419 | 446 | { |
420 | 447 | $pos1 = strpos($db_string, '\'', $pos + 1); |
421 | 448 | $pos2 = strpos($db_string, '\\', $pos + 1); |
422 | - if ($pos1 === false) |
|
423 | - break; |
|
424 | - elseif ($pos2 === false || $pos2 > $pos1) |
|
449 | + if ($pos1 === false) { |
|
450 | + break; |
|
451 | + } elseif ($pos2 === false || $pos2 > $pos1) |
|
425 | 452 | { |
426 | 453 | $pos = $pos1; |
427 | 454 | break; |
@@ -437,26 +464,31 @@ discard block |
||
437 | 464 | $clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean))); |
438 | 465 | |
439 | 466 | // Comments? We don't use comments in our queries, we leave 'em outside! |
440 | - if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) |
|
441 | - $fail = true; |
|
467 | + if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) { |
|
468 | + $fail = true; |
|
469 | + } |
|
442 | 470 | // Trying to change passwords, slow us down, or something? |
443 | - elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) |
|
444 | - $fail = true; |
|
445 | - elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) |
|
446 | - $fail = true; |
|
471 | + elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) { |
|
472 | + $fail = true; |
|
473 | + } elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) { |
|
474 | + $fail = true; |
|
475 | + } |
|
447 | 476 | |
448 | - if (!empty($fail) && function_exists('log_error')) |
|
449 | - smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
477 | + if (!empty($fail) && function_exists('log_error')) { |
|
478 | + smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
479 | + } |
|
450 | 480 | } |
451 | 481 | |
452 | 482 | $db_last_result = @pg_query($connection, $db_string); |
453 | 483 | |
454 | - if ($db_last_result === false && empty($db_values['db_error_skip'])) |
|
455 | - $db_last_result = smf_db_error($db_string, $connection); |
|
484 | + if ($db_last_result === false && empty($db_values['db_error_skip'])) { |
|
485 | + $db_last_result = smf_db_error($db_string, $connection); |
|
486 | + } |
|
456 | 487 | |
457 | 488 | // Debugging. |
458 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
459 | - $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
489 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
490 | + $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
491 | + } |
|
460 | 492 | |
461 | 493 | return $db_last_result; |
462 | 494 | } |
@@ -469,10 +501,11 @@ discard block |
||
469 | 501 | { |
470 | 502 | global $db_last_result, $db_replace_result; |
471 | 503 | |
472 | - if ($db_replace_result) |
|
473 | - return $db_replace_result; |
|
474 | - elseif ($result === null && !$db_last_result) |
|
475 | - return 0; |
|
504 | + if ($db_replace_result) { |
|
505 | + return $db_replace_result; |
|
506 | + } elseif ($result === null && !$db_last_result) { |
|
507 | + return 0; |
|
508 | + } |
|
476 | 509 | |
477 | 510 | return pg_affected_rows($result === null ? $db_last_result : $result); |
478 | 511 | } |
@@ -491,16 +524,18 @@ discard block |
||
491 | 524 | |
492 | 525 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
493 | 526 | |
494 | - if ($connection === false) |
|
495 | - $connection = $db_connection; |
|
527 | + if ($connection === false) { |
|
528 | + $connection = $db_connection; |
|
529 | + } |
|
496 | 530 | |
497 | 531 | // Try get the last ID for the auto increment field. |
498 | 532 | $request = $smcFunc['db_query']('', 'SELECT CURRVAL(\'' . $table . '_seq\') AS insertID', |
499 | 533 | array( |
500 | 534 | ) |
501 | 535 | ); |
502 | - if (!$request) |
|
503 | - return false; |
|
536 | + if (!$request) { |
|
537 | + return false; |
|
538 | + } |
|
504 | 539 | list ($lastID) = $smcFunc['db_fetch_row']($request); |
505 | 540 | $smcFunc['db_free_result']($request); |
506 | 541 | |
@@ -521,12 +556,13 @@ discard block |
||
521 | 556 | // Decide which connection to use |
522 | 557 | $connection = $connection === null ? $db_connection : $connection; |
523 | 558 | |
524 | - if ($type == 'begin') |
|
525 | - return @pg_query($connection, 'BEGIN'); |
|
526 | - elseif ($type == 'rollback') |
|
527 | - return @pg_query($connection, 'ROLLBACK'); |
|
528 | - elseif ($type == 'commit') |
|
529 | - return @pg_query($connection, 'COMMIT'); |
|
559 | + if ($type == 'begin') { |
|
560 | + return @pg_query($connection, 'BEGIN'); |
|
561 | + } elseif ($type == 'rollback') { |
|
562 | + return @pg_query($connection, 'ROLLBACK'); |
|
563 | + } elseif ($type == 'commit') { |
|
564 | + return @pg_query($connection, 'COMMIT'); |
|
565 | + } |
|
530 | 566 | |
531 | 567 | return false; |
532 | 568 | } |
@@ -554,19 +590,22 @@ discard block |
||
554 | 590 | $query_error = @pg_last_error($connection); |
555 | 591 | |
556 | 592 | // Log the error. |
557 | - if (function_exists('log_error')) |
|
558 | - log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n" . $db_string : ''), 'database', $file, $line); |
|
593 | + if (function_exists('log_error')) { |
|
594 | + log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n" . $db_string : ''), 'database', $file, $line); |
|
595 | + } |
|
559 | 596 | |
560 | 597 | // Nothing's defined yet... just die with it. |
561 | - if (empty($context) || empty($txt)) |
|
562 | - die($query_error); |
|
598 | + if (empty($context) || empty($txt)) { |
|
599 | + die($query_error); |
|
600 | + } |
|
563 | 601 | |
564 | 602 | // Show an error message, if possible. |
565 | 603 | $context['error_title'] = $txt['database_error']; |
566 | - if (allowedTo('admin_forum')) |
|
567 | - $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
568 | - else |
|
569 | - $context['error_message'] = $txt['try_again']; |
|
604 | + if (allowedTo('admin_forum')) { |
|
605 | + $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
606 | + } else { |
|
607 | + $context['error_message'] = $txt['try_again']; |
|
608 | + } |
|
570 | 609 | |
571 | 610 | if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true) |
572 | 611 | { |
@@ -588,12 +627,14 @@ discard block |
||
588 | 627 | { |
589 | 628 | global $db_row_count; |
590 | 629 | |
591 | - if ($counter !== false) |
|
592 | - return pg_fetch_row($request, $counter); |
|
630 | + if ($counter !== false) { |
|
631 | + return pg_fetch_row($request, $counter); |
|
632 | + } |
|
593 | 633 | |
594 | 634 | // Reset the row counter... |
595 | - if (!isset($db_row_count[(int) $request])) |
|
596 | - $db_row_count[(int) $request] = 0; |
|
635 | + if (!isset($db_row_count[(int) $request])) { |
|
636 | + $db_row_count[(int) $request] = 0; |
|
637 | + } |
|
597 | 638 | |
598 | 639 | // Return the right row. |
599 | 640 | return @pg_fetch_row($request, $db_row_count[(int) $request]++); |
@@ -610,12 +651,14 @@ discard block |
||
610 | 651 | { |
611 | 652 | global $db_row_count; |
612 | 653 | |
613 | - if ($counter !== false) |
|
614 | - return pg_fetch_assoc($request, $counter); |
|
654 | + if ($counter !== false) { |
|
655 | + return pg_fetch_assoc($request, $counter); |
|
656 | + } |
|
615 | 657 | |
616 | 658 | // Reset the row counter... |
617 | - if (!isset($db_row_count[(int) $request])) |
|
618 | - $db_row_count[(int) $request] = 0; |
|
659 | + if (!isset($db_row_count[(int) $request])) { |
|
660 | + $db_row_count[(int) $request] = 0; |
|
661 | + } |
|
619 | 662 | |
620 | 663 | // Return the right row. |
621 | 664 | return @pg_fetch_assoc($request, $db_row_count[(int) $request]++); |
@@ -667,11 +710,13 @@ discard block |
||
667 | 710 | |
668 | 711 | $replace = ''; |
669 | 712 | |
670 | - if (empty($data)) |
|
671 | - return; |
|
713 | + if (empty($data)) { |
|
714 | + return; |
|
715 | + } |
|
672 | 716 | |
673 | - if (!is_array($data[array_rand($data)])) |
|
674 | - $data = array($data); |
|
717 | + if (!is_array($data[array_rand($data)])) { |
|
718 | + $data = array($data); |
|
719 | + } |
|
675 | 720 | |
676 | 721 | // Replace the prefix holder with the actual prefix. |
677 | 722 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
@@ -697,11 +742,13 @@ discard block |
||
697 | 742 | //pg 9.5 got replace support |
698 | 743 | $pg_version = $smcFunc['db_get_version'](); |
699 | 744 | // if we got a Beta Version |
700 | - if (stripos($pg_version, 'beta') !== false) |
|
701 | - $pg_version = substr($pg_version, 0, stripos($pg_version, 'beta')) . '.0'; |
|
745 | + if (stripos($pg_version, 'beta') !== false) { |
|
746 | + $pg_version = substr($pg_version, 0, stripos($pg_version, 'beta')) . '.0'; |
|
747 | + } |
|
702 | 748 | // or RC |
703 | - if (stripos($pg_version, 'rc') !== false) |
|
704 | - $pg_version = substr($pg_version, 0, stripos($pg_version, 'rc')) . '.0'; |
|
749 | + if (stripos($pg_version, 'rc') !== false) { |
|
750 | + $pg_version = substr($pg_version, 0, stripos($pg_version, 'rc')) . '.0'; |
|
751 | + } |
|
705 | 752 | |
706 | 753 | $replace_support = (version_compare($pg_version, '9.5.0', '>=') ? true : false); |
707 | 754 | } |
@@ -720,8 +767,7 @@ discard block |
||
720 | 767 | $key_str .= ($count_pk > 0 ? ',' : ''); |
721 | 768 | $key_str .= $columnName; |
722 | 769 | $count_pk++; |
723 | - } |
|
724 | - else //normal field |
|
770 | + } else //normal field |
|
725 | 771 | { |
726 | 772 | $col_str .= ($count > 0 ? ',' : ''); |
727 | 773 | $col_str .= $columnName . ' = EXCLUDED.' . $columnName; |
@@ -729,20 +775,21 @@ discard block |
||
729 | 775 | } |
730 | 776 | } |
731 | 777 | $replace = ' ON CONFLICT (' . $key_str . ') DO UPDATE SET ' . $col_str; |
732 | - } |
|
733 | - else |
|
778 | + } else |
|
734 | 779 | { |
735 | 780 | foreach ($columns as $columnName => $type) |
736 | 781 | { |
737 | 782 | // Are we restricting the length? |
738 | - if (strpos($type, 'string-') !== false) |
|
739 | - $actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $count); |
|
740 | - else |
|
741 | - $actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $count); |
|
783 | + if (strpos($type, 'string-') !== false) { |
|
784 | + $actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $count); |
|
785 | + } else { |
|
786 | + $actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $count); |
|
787 | + } |
|
742 | 788 | |
743 | 789 | // A key? That's what we were looking for. |
744 | - if (in_array($columnName, $keys)) |
|
745 | - $where .= (empty($where) ? '' : ' AND ') . substr($actualType, 0, -2); |
|
790 | + if (in_array($columnName, $keys)) { |
|
791 | + $where .= (empty($where) ? '' : ' AND ') . substr($actualType, 0, -2); |
|
792 | + } |
|
746 | 793 | $count++; |
747 | 794 | } |
748 | 795 | |
@@ -768,10 +815,11 @@ discard block |
||
768 | 815 | foreach ($columns as $columnName => $type) |
769 | 816 | { |
770 | 817 | // Are we restricting the length? |
771 | - if (strpos($type, 'string-') !== false) |
|
772 | - $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
773 | - else |
|
774 | - $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
818 | + if (strpos($type, 'string-') !== false) { |
|
819 | + $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
820 | + } else { |
|
821 | + $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
822 | + } |
|
775 | 823 | } |
776 | 824 | $insertData = substr($insertData, 0, -2) . ')'; |
777 | 825 | |
@@ -780,11 +828,12 @@ discard block |
||
780 | 828 | |
781 | 829 | // Here's where the variables are injected to the query. |
782 | 830 | $insertRows = array(); |
783 | - foreach ($data as $dataRow) |
|
784 | - $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
831 | + foreach ($data as $dataRow) { |
|
832 | + $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
833 | + } |
|
785 | 834 | |
786 | - foreach ($insertRows as $entry) |
|
787 | - // Do the insert. |
|
835 | + foreach ($insertRows as $entry) { |
|
836 | + // Do the insert. |
|
788 | 837 | $smcFunc['db_query']('', ' |
789 | 838 | INSERT INTO ' . $table . '("' . implode('", "', $indexed_columns) . '") |
790 | 839 | VALUES |
@@ -795,11 +844,13 @@ discard block |
||
795 | 844 | ), |
796 | 845 | $connection |
797 | 846 | ); |
847 | + } |
|
798 | 848 | } |
799 | 849 | |
800 | - if ($priv_trans) |
|
801 | - $smcFunc['db_transaction']('commit', $connection); |
|
802 | -} |
|
850 | + if ($priv_trans) { |
|
851 | + $smcFunc['db_transaction']('commit', $connection); |
|
852 | + } |
|
853 | + } |
|
803 | 854 | |
804 | 855 | /** |
805 | 856 | * Dummy function really. Doesn't do anything on PostgreSQL. |
@@ -836,8 +887,9 @@ discard block |
||
836 | 887 | */ |
837 | 888 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
838 | 889 | { |
839 | - if (empty($log_message)) |
|
840 | - $log_message = $error_message; |
|
890 | + if (empty($log_message)) { |
|
891 | + $log_message = $error_message; |
|
892 | + } |
|
841 | 893 | |
842 | 894 | foreach (debug_backtrace() as $step) |
843 | 895 | { |
@@ -856,12 +908,14 @@ discard block |
||
856 | 908 | } |
857 | 909 | |
858 | 910 | // A special case - we want the file and line numbers for debugging. |
859 | - if ($error_type == 'return') |
|
860 | - return array($file, $line); |
|
911 | + if ($error_type == 'return') { |
|
912 | + return array($file, $line); |
|
913 | + } |
|
861 | 914 | |
862 | 915 | // Is always a critical error. |
863 | - if (function_exists('log_error')) |
|
864 | - log_error($log_message, 'critical', $file, $line); |
|
916 | + if (function_exists('log_error')) { |
|
917 | + log_error($log_message, 'critical', $file, $line); |
|
918 | + } |
|
865 | 919 | |
866 | 920 | if (function_exists('fatal_error')) |
867 | 921 | { |
@@ -869,12 +923,12 @@ discard block |
||
869 | 923 | |
870 | 924 | // Cannot continue... |
871 | 925 | exit; |
926 | + } elseif ($error_type) { |
|
927 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
928 | + } else { |
|
929 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
930 | + } |
|
872 | 931 | } |
873 | - elseif ($error_type) |
|
874 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
875 | - else |
|
876 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
877 | -} |
|
878 | 932 | |
879 | 933 | /** |
880 | 934 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
@@ -891,10 +945,11 @@ discard block |
||
891 | 945 | '\\' => '\\\\', |
892 | 946 | ); |
893 | 947 | |
894 | - if ($translate_human_wildcards) |
|
895 | - $replacements += array( |
|
948 | + if ($translate_human_wildcards) { |
|
949 | + $replacements += array( |
|
896 | 950 | '*' => '%', |
897 | 951 | ); |
952 | + } |
|
898 | 953 | |
899 | 954 | return strtr($string, $replacements); |
900 | 955 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Class Likes |
@@ -108,8 +109,9 @@ discard block |
||
108 | 109 | $this->_extra = isset($_GET['extra']) ? $_GET['extra'] : false; |
109 | 110 | |
110 | 111 | // We do not want to output debug information here. |
111 | - if ($this->_js) |
|
112 | - $db_show_debug = false; |
|
112 | + if ($this->_js) { |
|
113 | + $db_show_debug = false; |
|
114 | + } |
|
113 | 115 | } |
114 | 116 | |
115 | 117 | /** |
@@ -143,8 +145,9 @@ discard block |
||
143 | 145 | $call = $this->_sa; |
144 | 146 | |
145 | 147 | // Guest can only view likes. |
146 | - if ($call != 'view') |
|
147 | - is_not_guest(); |
|
148 | + if ($call != 'view') { |
|
149 | + is_not_guest(); |
|
150 | + } |
|
148 | 151 | |
149 | 152 | checkSession('get'); |
150 | 153 | |
@@ -182,15 +185,17 @@ discard block |
||
182 | 185 | global $smcFunc, $modSettings; |
183 | 186 | |
184 | 187 | // This feature is currently disable. |
185 | - if (empty($modSettings['enable_likes'])) |
|
186 | - return $this->_error = 'like_disable'; |
|
188 | + if (empty($modSettings['enable_likes'])) { |
|
189 | + return $this->_error = 'like_disable'; |
|
190 | + } |
|
187 | 191 | |
188 | 192 | // Zerothly, they did indicate some kind of content to like, right? |
189 | 193 | preg_match('~^([a-z0-9\-\_]{1,6})~i', $this->_type, $matches); |
190 | 194 | $this->_type = isset($matches[1]) ? $matches[1] : ''; |
191 | 195 | |
192 | - if ($this->_type == '' || $this->_content <= 0) |
|
193 | - return $this->_error = 'cannot_'; |
|
196 | + if ($this->_type == '' || $this->_content <= 0) { |
|
197 | + return $this->_error = 'cannot_'; |
|
198 | + } |
|
194 | 199 | |
195 | 200 | // First we need to verify if the user can see the type of content or not. This is set up to be extensible, |
196 | 201 | // so we'll check for the one type we do know about, and if it's not that, we'll defer to any hooks. |
@@ -209,12 +214,14 @@ discard block |
||
209 | 214 | 'msg' => $this->_content, |
210 | 215 | ) |
211 | 216 | ); |
212 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
213 | - list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
217 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
218 | + list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
219 | + } |
|
214 | 220 | |
215 | 221 | $smcFunc['db_free_result']($request); |
216 | - if (empty($this->_idTopic)) |
|
217 | - return $this->_error = 'cannot_'; |
|
222 | + if (empty($this->_idTopic)) { |
|
223 | + return $this->_error = 'cannot_'; |
|
224 | + } |
|
218 | 225 | |
219 | 226 | // So we know what topic it's in and more importantly we know the user can see it. |
220 | 227 | // If we're not viewing, we need some info set up. |
@@ -224,9 +231,7 @@ discard block |
||
224 | 231 | $this->_validLikes['can_see'] = allowedTo('likes_view') ? true : 'cannot_view_likes'; |
225 | 232 | |
226 | 233 | $this->_validLikes['can_like'] = ($this->_user['id'] == $topicOwner ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content')); |
227 | - } |
|
228 | - |
|
229 | - else |
|
234 | + } else |
|
230 | 235 | { |
231 | 236 | // Modders: This will give you whatever the user offers up in terms of liking, e.g. $this->_type=msg, $this->_content=1 |
232 | 237 | // When you hook this, check $this->_type first. If it is not something your mod worries about, return false. |
@@ -244,8 +249,9 @@ discard block |
||
244 | 249 | if ($result !== false) |
245 | 250 | { |
246 | 251 | // Match the type with what we already have. |
247 | - if (!isset($result['type']) || $result['type'] != $this->_type) |
|
248 | - return $this->_error = 'not_valid_like_type'; |
|
252 | + if (!isset($result['type']) || $result['type'] != $this->_type) { |
|
253 | + return $this->_error = 'not_valid_like_type'; |
|
254 | + } |
|
249 | 255 | |
250 | 256 | // Fill out the rest. |
251 | 257 | $this->_type = $result['type']; |
@@ -256,17 +262,20 @@ discard block |
||
256 | 262 | } |
257 | 263 | } |
258 | 264 | |
259 | - if (!$found) |
|
260 | - return $this->_error = 'cannot_'; |
|
265 | + if (!$found) { |
|
266 | + return $this->_error = 'cannot_'; |
|
267 | + } |
|
261 | 268 | } |
262 | 269 | |
263 | 270 | // Does the user can see this? |
264 | - if (isset($this->_validLikes['can_see']) && is_string($this->_validLikes['can_see'])) |
|
265 | - return $this->_error = $this->_validLikes['can_see']; |
|
271 | + if (isset($this->_validLikes['can_see']) && is_string($this->_validLikes['can_see'])) { |
|
272 | + return $this->_error = $this->_validLikes['can_see']; |
|
273 | + } |
|
266 | 274 | |
267 | 275 | // Does the user can like this? Viewing a list of likes doesn't require this permission. |
268 | - if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) |
|
269 | - return $this->_error = $this->_validLikes['can_like']; |
|
276 | + if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) { |
|
277 | + return $this->_error = $this->_validLikes['can_like']; |
|
278 | + } |
|
270 | 279 | } |
271 | 280 | |
272 | 281 | /** |
@@ -291,8 +300,9 @@ discard block |
||
291 | 300 | ); |
292 | 301 | |
293 | 302 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
294 | - if ($this->_sa == __FUNCTION__) |
|
295 | - $this->_data = __FUNCTION__; |
|
303 | + if ($this->_sa == __FUNCTION__) { |
|
304 | + $this->_data = __FUNCTION__; |
|
305 | + } |
|
296 | 306 | } |
297 | 307 | |
298 | 308 | /** |
@@ -322,8 +332,8 @@ discard block |
||
322 | 332 | |
323 | 333 | // Add a background task to process sending alerts. |
324 | 334 | // Mod author, you can add your own background task for your own custom like event using the "integrate_issue_like" hook or your callback, both are immediately called after this. |
325 | - if ($this->_type == 'msg') |
|
326 | - $smcFunc['db_insert']('insert', |
|
335 | + if ($this->_type == 'msg') { |
|
336 | + $smcFunc['db_insert']('insert', |
|
327 | 337 | '{db_prefix}background_tasks', |
328 | 338 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
329 | 339 | array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', json_encode(array( |
@@ -335,10 +345,12 @@ discard block |
||
335 | 345 | )), 0), |
336 | 346 | array('id_task') |
337 | 347 | ); |
348 | + } |
|
338 | 349 | |
339 | 350 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
340 | - if ($this->_sa == __FUNCTION__) |
|
341 | - $this->_data = __FUNCTION__; |
|
351 | + if ($this->_sa == __FUNCTION__) { |
|
352 | + $this->_data = __FUNCTION__; |
|
353 | + } |
|
342 | 354 | } |
343 | 355 | |
344 | 356 | /** |
@@ -364,8 +376,9 @@ discard block |
||
364 | 376 | $smcFunc['db_free_result']($request); |
365 | 377 | |
366 | 378 | // If you want to call this directly, fill out _data property too. |
367 | - if ($this->_sa == __FUNCTION__) |
|
368 | - $this->_data = $this->_numLikes; |
|
379 | + if ($this->_sa == __FUNCTION__) { |
|
380 | + $this->_data = $this->_numLikes; |
|
381 | + } |
|
369 | 382 | } |
370 | 383 | |
371 | 384 | /** |
@@ -378,8 +391,9 @@ discard block |
||
378 | 391 | global $smcFunc; |
379 | 392 | |
380 | 393 | // Safety first! |
381 | - if (empty($this->_type) || empty($this->_content)) |
|
382 | - return $this->_error = 'cannot_'; |
|
394 | + if (empty($this->_type) || empty($this->_content)) { |
|
395 | + return $this->_error = 'cannot_'; |
|
396 | + } |
|
383 | 397 | |
384 | 398 | // Do we already like this? |
385 | 399 | $request = $smcFunc['db_query']('', ' |
@@ -397,26 +411,28 @@ discard block |
||
397 | 411 | $this->_alreadyLiked = (bool) $smcFunc['db_num_rows']($request) != 0; |
398 | 412 | $smcFunc['db_free_result']($request); |
399 | 413 | |
400 | - if ($this->_alreadyLiked) |
|
401 | - $this->delete(); |
|
402 | - |
|
403 | - else |
|
404 | - $this->insert(); |
|
414 | + if ($this->_alreadyLiked) { |
|
415 | + $this->delete(); |
|
416 | + } else { |
|
417 | + $this->insert(); |
|
418 | + } |
|
405 | 419 | |
406 | 420 | // Now, how many people like this content now? We *could* just +1 / -1 the relevant container but that has proven to become unstable. |
407 | 421 | $this->_count(); |
408 | 422 | |
409 | 423 | // Update the likes count for messages. |
410 | - if ($this->_type == 'msg') |
|
411 | - $this->msgIssueLike(); |
|
424 | + if ($this->_type == 'msg') { |
|
425 | + $this->msgIssueLike(); |
|
426 | + } |
|
412 | 427 | |
413 | 428 | // Any callbacks? |
414 | 429 | elseif (!empty($this->_validLikes['callback'])) |
415 | 430 | { |
416 | 431 | $call = call_helper($this->_validLikes['callback'], true); |
417 | 432 | |
418 | - if (!empty($call)) |
|
419 | - call_user_func_array($call, array($this)); |
|
433 | + if (!empty($call)) { |
|
434 | + call_user_func_array($call, array($this)); |
|
435 | + } |
|
420 | 436 | } |
421 | 437 | |
422 | 438 | // Sometimes there might be other things that need updating after we do this like. |
@@ -425,8 +441,9 @@ discard block |
||
425 | 441 | // Now some clean up. This is provided here for any like handlers that want to do any cache flushing. |
426 | 442 | // This way a like handler doesn't need to explicitly declare anything in integrate_issue_like, but do so |
427 | 443 | // in integrate_valid_likes where it absolutely has to exist. |
428 | - if (!empty($this->_validLikes['flush_cache'])) |
|
429 | - cache_put_data($this->_validLikes['flush_cache'], null); |
|
444 | + if (!empty($this->_validLikes['flush_cache'])) { |
|
445 | + cache_put_data($this->_validLikes['flush_cache'], null); |
|
446 | + } |
|
430 | 447 | |
431 | 448 | // All done, start building the data to pass as response. |
432 | 449 | $this->_data = array( |
@@ -450,8 +467,9 @@ discard block |
||
450 | 467 | { |
451 | 468 | global $smcFunc; |
452 | 469 | |
453 | - if ($this->_type !== 'msg') |
|
454 | - return; |
|
470 | + if ($this->_type !== 'msg') { |
|
471 | + return; |
|
472 | + } |
|
455 | 473 | |
456 | 474 | $smcFunc['db_query']('', ' |
457 | 475 | UPDATE {db_prefix}messages |
@@ -492,8 +510,9 @@ discard block |
||
492 | 510 | 'like_type' => $this->_type, |
493 | 511 | ) |
494 | 512 | ); |
495 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
496 | - $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
513 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
514 | + $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
515 | + } |
|
497 | 516 | |
498 | 517 | // Now to get member data, including avatars and so on. |
499 | 518 | $members = array_keys($context['likers']); |
@@ -501,8 +520,9 @@ discard block |
||
501 | 520 | if (count($loaded) != count($members)) |
502 | 521 | { |
503 | 522 | $members = array_diff($members, $loaded); |
504 | - foreach ($members as $not_loaded) |
|
505 | - unset ($context['likers'][$not_loaded]); |
|
523 | + foreach ($members as $not_loaded) { |
|
524 | + unset ($context['likers'][$not_loaded]); |
|
525 | + } |
|
506 | 526 | } |
507 | 527 | |
508 | 528 | foreach ($context['likers'] as $liker => $dummy) |
@@ -544,12 +564,14 @@ discard block |
||
544 | 564 | global $context, $txt; |
545 | 565 | |
546 | 566 | // Don't do anything if someone else has already take care of the response. |
547 | - if (!$this->_setResponse) |
|
548 | - return; |
|
567 | + if (!$this->_setResponse) { |
|
568 | + return; |
|
569 | + } |
|
549 | 570 | |
550 | 571 | // Want a json response huh? |
551 | - if ($this->_validLikes['json']) |
|
552 | - return $this->jsonResponse(); |
|
572 | + if ($this->_validLikes['json']) { |
|
573 | + return $this->jsonResponse(); |
|
574 | + } |
|
553 | 575 | |
554 | 576 | // Set everything up for display. |
555 | 577 | loadTemplate('Likes'); |
@@ -559,8 +581,9 @@ discard block |
||
559 | 581 | if ($this->_error) |
560 | 582 | { |
561 | 583 | // If this is a generic error, set it up good. |
562 | - if ($this->_error == 'cannot_') |
|
563 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
584 | + if ($this->_error == 'cannot_') { |
|
585 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
586 | + } |
|
564 | 587 | |
565 | 588 | // Is this request coming from an ajax call? |
566 | 589 | if ($this->_js) |
@@ -570,8 +593,9 @@ discard block |
||
570 | 593 | } |
571 | 594 | |
572 | 595 | // Nope? then just do a redirect to whatever URL was provided. |
573 | - else |
|
574 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
596 | + else { |
|
597 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
598 | + } |
|
575 | 599 | |
576 | 600 | return; |
577 | 601 | } |
@@ -580,8 +604,9 @@ discard block |
||
580 | 604 | else |
581 | 605 | { |
582 | 606 | // Not an ajax request so send the user back to the previous location or the main page. |
583 | - if (!$this->_js) |
|
584 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
607 | + if (!$this->_js) { |
|
608 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
609 | + } |
|
585 | 610 | |
586 | 611 | // These fine gentlemen all share the same template. |
587 | 612 | $generic = array('delete', 'insert', '_count'); |
@@ -612,8 +637,9 @@ discard block |
||
612 | 637 | // If there is an error, send it. |
613 | 638 | if ($this->_error) |
614 | 639 | { |
615 | - if ($this->_error == 'cannot_') |
|
616 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
640 | + if ($this->_error == 'cannot_') { |
|
641 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
642 | + } |
|
617 | 643 | |
618 | 644 | $print['error'] = $this->_error; |
619 | 645 | } |
@@ -649,33 +675,36 @@ discard block |
||
649 | 675 | <body style="background-color: #444455; color: white; font-style: italic; font-family: serif;"> |
650 | 676 | <div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">'; |
651 | 677 | |
652 | - if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) |
|
653 | - $_GET['verse'] = '4:16'; |
|
678 | + if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) { |
|
679 | + $_GET['verse'] = '4:16'; |
|
680 | + } |
|
654 | 681 | |
655 | - if ($_GET['verse'] == '2:18') |
|
656 | - echo ' |
|
682 | + if ($_GET['verse'] == '2:18') { |
|
683 | + echo ' |
|
657 | 684 | Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none. And it became to be in those days <em>something</em>. Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind. And thus what was to be known the <em>secret project</em> began into its existence. Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.'; |
658 | - elseif ($_GET['verse'] == '4:16') |
|
659 | - echo ' |
|
685 | + } elseif ($_GET['verse'] == '4:16') { |
|
686 | + echo ' |
|
660 | 687 | And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together. Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.'; |
661 | - elseif ($_GET['verse'] == '22:1-2') |
|
662 | - echo ' |
|
688 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
689 | + echo ' |
|
663 | 690 | <p>Now <em>behold</em>, that which was once the secret project was <em id="unknown" name="[Unknown]">unknown</em> no longer. Alas, it needed more than <em>only one</em>, but yet even thought otherwise. It became that the opposition <em>rumored</em> and lied, but still to no avail. Their match, though not <em>perfect</em>, had them outdone.</p> |
664 | 691 | <p style="margin: 2ex 1ex 0 1ex; font-size: 1.05em; line-height: 1.5; text-align: center;">Let it continue. <em>The end</em>.</p>'; |
692 | + } |
|
665 | 693 | |
666 | 694 | echo ' |
667 | 695 | </div> |
668 | 696 | <div style="margin-top: 2ex; font-size: 2em; text-align: right;">'; |
669 | 697 | |
670 | - if ($_GET['verse'] == '2:18') |
|
671 | - echo ' |
|
698 | + if ($_GET['verse'] == '2:18') { |
|
699 | + echo ' |
|
672 | 700 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=4:16" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>'; |
673 | - elseif ($_GET['verse'] == '4:16') |
|
674 | - echo ' |
|
701 | + } elseif ($_GET['verse'] == '4:16') { |
|
702 | + echo ' |
|
675 | 703 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=22:1-2" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>'; |
676 | - elseif ($_GET['verse'] == '22:1-2') |
|
677 | - echo ' |
|
704 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
705 | + echo ' |
|
678 | 706 | from <span style="font-family: Georgia, serif;"><strong>The Book of Unknown</strong>, 22:1-2</span>'; |
707 | + } |
|
679 | 708 | |
680 | 709 | echo ' |
681 | 710 | </div> |
@@ -30,8 +30,9 @@ discard block |
||
30 | 30 | * @version 2.1 Beta 3 |
31 | 31 | */ |
32 | 32 | |
33 | -if (!defined('SMF')) |
|
33 | +if (!defined('SMF')) { |
|
34 | 34 | die('No direct access...'); |
35 | +} |
|
35 | 36 | |
36 | 37 | /** |
37 | 38 | * Subaction handler - manages the action and delegates control to the proper |
@@ -103,12 +104,12 @@ discard block |
||
103 | 104 | cache_put_data('minimized_css', null); |
104 | 105 | |
105 | 106 | // Follow the sa or just go to administration. |
106 | - if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) |
|
107 | - call_helper($subActions[$_GET['sa']]); |
|
108 | - |
|
109 | - else |
|
110 | - call_helper($subActions['admin']); |
|
111 | -} |
|
107 | + if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) { |
|
108 | + call_helper($subActions[$_GET['sa']]); |
|
109 | + } else { |
|
110 | + call_helper($subActions['admin']); |
|
111 | + } |
|
112 | + } |
|
112 | 113 | |
113 | 114 | /** |
114 | 115 | * This function allows administration of themes and their settings, |
@@ -130,15 +131,16 @@ discard block |
||
130 | 131 | checkSession(); |
131 | 132 | validateToken('admin-tm'); |
132 | 133 | |
133 | - if (isset($_POST['options']['known_themes'])) |
|
134 | - foreach ($_POST['options']['known_themes'] as $key => $id) |
|
134 | + if (isset($_POST['options']['known_themes'])) { |
|
135 | + foreach ($_POST['options']['known_themes'] as $key => $id) |
|
135 | 136 | $_POST['options']['known_themes'][$key] = (int) $id; |
137 | + } else { |
|
138 | + fatal_lang_error('themes_none_selectable', false); |
|
139 | + } |
|
136 | 140 | |
137 | - else |
|
138 | - fatal_lang_error('themes_none_selectable', false); |
|
139 | - |
|
140 | - if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) |
|
141 | - fatal_lang_error('themes_default_selectable', false); |
|
141 | + if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) { |
|
142 | + fatal_lang_error('themes_default_selectable', false); |
|
143 | + } |
|
142 | 144 | |
143 | 145 | // Commit the new settings. |
144 | 146 | updateSettings(array( |
@@ -146,8 +148,9 @@ discard block |
||
146 | 148 | 'theme_guests' => $_POST['options']['theme_guests'], |
147 | 149 | 'knownThemes' => implode(',', $_POST['options']['known_themes']), |
148 | 150 | )); |
149 | - if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) |
|
150 | - updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
151 | + if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) { |
|
152 | + updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
153 | + } |
|
151 | 154 | |
152 | 155 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=admin'); |
153 | 156 | } |
@@ -166,8 +169,9 @@ discard block |
||
166 | 169 | // Look for a non existent theme directory. (ie theme87.) |
167 | 170 | $theme_dir = $boarddir . '/Themes/theme'; |
168 | 171 | $i = 1; |
169 | - while (file_exists($theme_dir . $i)) |
|
170 | - $i++; |
|
172 | + while (file_exists($theme_dir . $i)) { |
|
173 | + $i++; |
|
174 | + } |
|
171 | 175 | |
172 | 176 | $context['new_theme_name'] = 'theme' . $i; |
173 | 177 | |
@@ -189,8 +193,9 @@ discard block |
||
189 | 193 | loadLanguage('Admin'); |
190 | 194 | isAllowedTo('admin_forum'); |
191 | 195 | |
192 | - if (isset($_REQUEST['th'])) |
|
193 | - return SetThemeSettings(); |
|
196 | + if (isset($_REQUEST['th'])) { |
|
197 | + return SetThemeSettings(); |
|
198 | + } |
|
194 | 199 | |
195 | 200 | if (isset($_POST['save'])) |
196 | 201 | { |
@@ -274,12 +279,13 @@ discard block |
||
274 | 279 | $context['themes'] = array(); |
275 | 280 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
276 | 281 | { |
277 | - if (!isset($context['themes'][$row['id_theme']])) |
|
278 | - $context['themes'][$row['id_theme']] = array( |
|
282 | + if (!isset($context['themes'][$row['id_theme']])) { |
|
283 | + $context['themes'][$row['id_theme']] = array( |
|
279 | 284 | 'id' => $row['id_theme'], |
280 | 285 | 'num_default_options' => 0, |
281 | 286 | 'num_members' => 0, |
282 | 287 | ); |
288 | + } |
|
283 | 289 | $context['themes'][$row['id_theme']][$row['variable']] = $row['value']; |
284 | 290 | } |
285 | 291 | $smcFunc['db_free_result']($request); |
@@ -293,8 +299,9 @@ discard block |
||
293 | 299 | 'guest_member' => -1, |
294 | 300 | ) |
295 | 301 | ); |
296 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
297 | - $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
302 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
303 | + $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
304 | + } |
|
298 | 305 | $smcFunc['db_free_result']($request); |
299 | 306 | |
300 | 307 | // Need to make sure we don't do custom fields. |
@@ -305,8 +312,9 @@ discard block |
||
305 | 312 | ) |
306 | 313 | ); |
307 | 314 | $customFields = array(); |
308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
309 | - $customFields[] = $row['col_name']; |
|
315 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
316 | + $customFields[] = $row['col_name']; |
|
317 | + } |
|
310 | 318 | $smcFunc['db_free_result']($request); |
311 | 319 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
312 | 320 | |
@@ -321,14 +329,16 @@ discard block |
||
321 | 329 | 'custom_fields' => empty($customFields) ? array() : $customFields, |
322 | 330 | ) |
323 | 331 | ); |
324 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
325 | - $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
332 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
333 | + $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
334 | + } |
|
326 | 335 | $smcFunc['db_free_result']($request); |
327 | 336 | |
328 | 337 | // There has to be a Settings template! |
329 | - foreach ($context['themes'] as $k => $v) |
|
330 | - if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
338 | + foreach ($context['themes'] as $k => $v) { |
|
339 | + if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
331 | 340 | unset($context['themes'][$k]); |
341 | + } |
|
332 | 342 | |
333 | 343 | loadTemplate('Themes'); |
334 | 344 | $context['sub_template'] = 'reset_list'; |
@@ -343,16 +353,19 @@ discard block |
||
343 | 353 | checkSession(); |
344 | 354 | validateToken('admin-sto'); |
345 | 355 | |
346 | - if (empty($_POST['options'])) |
|
347 | - $_POST['options'] = array(); |
|
348 | - if (empty($_POST['default_options'])) |
|
349 | - $_POST['default_options'] = array(); |
|
356 | + if (empty($_POST['options'])) { |
|
357 | + $_POST['options'] = array(); |
|
358 | + } |
|
359 | + if (empty($_POST['default_options'])) { |
|
360 | + $_POST['default_options'] = array(); |
|
361 | + } |
|
350 | 362 | |
351 | 363 | // Set up the sql query. |
352 | 364 | $setValues = array(); |
353 | 365 | |
354 | - foreach ($_POST['options'] as $opt => $val) |
|
355 | - $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
366 | + foreach ($_POST['options'] as $opt => $val) { |
|
367 | + $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
368 | + } |
|
356 | 369 | |
357 | 370 | $old_settings = array(); |
358 | 371 | foreach ($_POST['default_options'] as $opt => $val) |
@@ -366,8 +379,8 @@ discard block |
||
366 | 379 | if (!empty($setValues)) |
367 | 380 | { |
368 | 381 | // Are there options in non-default themes set that should be cleared? |
369 | - if (!empty($old_settings)) |
|
370 | - $smcFunc['db_query']('', ' |
|
382 | + if (!empty($old_settings)) { |
|
383 | + $smcFunc['db_query']('', ' |
|
371 | 384 | DELETE FROM {db_prefix}themes |
372 | 385 | WHERE id_theme != {int:default_theme} |
373 | 386 | AND id_member = {int:guest_member} |
@@ -378,6 +391,7 @@ discard block |
||
378 | 391 | 'old_settings' => $old_settings, |
379 | 392 | ) |
380 | 393 | ); |
394 | + } |
|
381 | 395 | |
382 | 396 | $smcFunc['db_insert']('replace', |
383 | 397 | '{db_prefix}themes', |
@@ -391,8 +405,7 @@ discard block |
||
391 | 405 | cache_put_data('theme_settings-1', null, 90); |
392 | 406 | |
393 | 407 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
394 | - } |
|
395 | - elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
408 | + } elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
396 | 409 | { |
397 | 410 | checkSession(); |
398 | 411 | validateToken('admin-sto'); |
@@ -405,9 +418,9 @@ discard block |
||
405 | 418 | $old_settings = array(); |
406 | 419 | foreach ($_POST['default_options'] as $opt => $val) |
407 | 420 | { |
408 | - if ($_POST['default_options_master'][$opt] == 0) |
|
409 | - continue; |
|
410 | - elseif ($_POST['default_options_master'][$opt] == 1) |
|
421 | + if ($_POST['default_options_master'][$opt] == 0) { |
|
422 | + continue; |
|
423 | + } elseif ($_POST['default_options_master'][$opt] == 1) |
|
411 | 424 | { |
412 | 425 | // Delete then insert for ease of database compatibility! |
413 | 426 | $smcFunc['db_query']('substring', ' |
@@ -433,8 +446,7 @@ discard block |
||
433 | 446 | ); |
434 | 447 | |
435 | 448 | $old_settings[] = $opt; |
436 | - } |
|
437 | - elseif ($_POST['default_options_master'][$opt] == 2) |
|
449 | + } elseif ($_POST['default_options_master'][$opt] == 2) |
|
438 | 450 | { |
439 | 451 | $smcFunc['db_query']('', ' |
440 | 452 | DELETE FROM {db_prefix}themes |
@@ -449,8 +461,8 @@ discard block |
||
449 | 461 | } |
450 | 462 | |
451 | 463 | // Delete options from other themes. |
452 | - if (!empty($old_settings)) |
|
453 | - $smcFunc['db_query']('', ' |
|
464 | + if (!empty($old_settings)) { |
|
465 | + $smcFunc['db_query']('', ' |
|
454 | 466 | DELETE FROM {db_prefix}themes |
455 | 467 | WHERE id_theme != {int:default_theme} |
456 | 468 | AND id_member > {int:no_member} |
@@ -461,12 +473,13 @@ discard block |
||
461 | 473 | 'old_settings' => $old_settings, |
462 | 474 | ) |
463 | 475 | ); |
476 | + } |
|
464 | 477 | |
465 | 478 | foreach ($_POST['options'] as $opt => $val) |
466 | 479 | { |
467 | - if ($_POST['options_master'][$opt] == 0) |
|
468 | - continue; |
|
469 | - elseif ($_POST['options_master'][$opt] == 1) |
|
480 | + if ($_POST['options_master'][$opt] == 0) { |
|
481 | + continue; |
|
482 | + } elseif ($_POST['options_master'][$opt] == 1) |
|
470 | 483 | { |
471 | 484 | // Delete then insert for ease of database compatibility - again! |
472 | 485 | $smcFunc['db_query']('substring', ' |
@@ -491,8 +504,7 @@ discard block |
||
491 | 504 | 'value' => (is_array($val) ? implode(',', $val) : $val), |
492 | 505 | ) |
493 | 506 | ); |
494 | - } |
|
495 | - elseif ($_POST['options_master'][$opt] == 2) |
|
507 | + } elseif ($_POST['options_master'][$opt] == 2) |
|
496 | 508 | { |
497 | 509 | $smcFunc['db_query']('', ' |
498 | 510 | DELETE FROM {db_prefix}themes |
@@ -509,8 +521,7 @@ discard block |
||
509 | 521 | } |
510 | 522 | |
511 | 523 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
512 | - } |
|
513 | - elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
524 | + } elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
514 | 525 | { |
515 | 526 | checkSession('get'); |
516 | 527 | validateToken('admin-stor', 'request'); |
@@ -525,8 +536,9 @@ discard block |
||
525 | 536 | ) |
526 | 537 | ); |
527 | 538 | $customFields = array(); |
528 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
529 | - $customFields[] = $row['col_name']; |
|
539 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
540 | + $customFields[] = $row['col_name']; |
|
541 | + } |
|
530 | 542 | $smcFunc['db_free_result']($request); |
531 | 543 | } |
532 | 544 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
@@ -578,13 +590,13 @@ discard block |
||
578 | 590 | ) |
579 | 591 | ); |
580 | 592 | $context['theme_options'] = array(); |
581 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
582 | - $context['theme_options'][$row['variable']] = $row['value']; |
|
593 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
594 | + $context['theme_options'][$row['variable']] = $row['value']; |
|
595 | + } |
|
583 | 596 | $smcFunc['db_free_result']($request); |
584 | 597 | |
585 | 598 | $context['theme_options_reset'] = false; |
586 | - } |
|
587 | - else |
|
599 | + } else |
|
588 | 600 | { |
589 | 601 | $context['theme_options'] = array(); |
590 | 602 | $context['theme_options_reset'] = true; |
@@ -597,22 +609,23 @@ discard block |
||
597 | 609 | { |
598 | 610 | unset($context['options'][$i]); |
599 | 611 | continue; |
600 | - } |
|
601 | - elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
612 | + } elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
602 | 613 | { |
603 | 614 | unset($context['options'][$i]); |
604 | 615 | continue; |
605 | 616 | } |
606 | 617 | |
607 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
608 | - $context['options'][$i]['type'] = 'checkbox'; |
|
609 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
610 | - $context['options'][$i]['type'] = 'number'; |
|
611 | - elseif ($setting['type'] == 'string') |
|
612 | - $context['options'][$i]['type'] = 'text'; |
|
618 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
619 | + $context['options'][$i]['type'] = 'checkbox'; |
|
620 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
621 | + $context['options'][$i]['type'] = 'number'; |
|
622 | + } elseif ($setting['type'] == 'string') { |
|
623 | + $context['options'][$i]['type'] = 'text'; |
|
624 | + } |
|
613 | 625 | |
614 | - if (isset($setting['options'])) |
|
615 | - $context['options'][$i]['type'] = 'list'; |
|
626 | + if (isset($setting['options'])) { |
|
627 | + $context['options'][$i]['type'] = 'list'; |
|
628 | + } |
|
616 | 629 | |
617 | 630 | $context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']]; |
618 | 631 | } |
@@ -637,8 +650,9 @@ discard block |
||
637 | 650 | { |
638 | 651 | global $txt, $context, $settings, $modSettings, $smcFunc; |
639 | 652 | |
640 | - if (empty($_GET['th']) && empty($_GET['id'])) |
|
641 | - return ThemeAdmin(); |
|
653 | + if (empty($_GET['th']) && empty($_GET['id'])) { |
|
654 | + return ThemeAdmin(); |
|
655 | + } |
|
642 | 656 | |
643 | 657 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
644 | 658 | |
@@ -649,8 +663,9 @@ discard block |
||
649 | 663 | isAllowedTo('admin_forum'); |
650 | 664 | |
651 | 665 | // Validate inputs/user. |
652 | - if (empty($_GET['th'])) |
|
653 | - fatal_lang_error('no_theme', false); |
|
666 | + if (empty($_GET['th'])) { |
|
667 | + fatal_lang_error('no_theme', false); |
|
668 | + } |
|
654 | 669 | |
655 | 670 | // Fetch the smiley sets... |
656 | 671 | $sets = explode(',', 'none,' . $modSettings['smiley_sets_known']); |
@@ -658,8 +673,9 @@ discard block |
||
658 | 673 | $context['smiley_sets'] = array( |
659 | 674 | '' => $txt['smileys_no_default'] |
660 | 675 | ); |
661 | - foreach ($sets as $i => $set) |
|
662 | - $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
676 | + foreach ($sets as $i => $set) { |
|
677 | + $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
678 | + } |
|
663 | 679 | |
664 | 680 | $old_id = $settings['theme_id']; |
665 | 681 | $old_settings = $settings; |
@@ -684,8 +700,9 @@ discard block |
||
684 | 700 | if (file_exists($settings['theme_dir'] . '/index.template.php')) |
685 | 701 | { |
686 | 702 | $file_contents = implode('', file($settings['theme_dir'] . '/index.template.php')); |
687 | - if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) |
|
688 | - eval('global $settings;' . $matches[0]); |
|
703 | + if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) { |
|
704 | + eval('global $settings;' . $matches[0]); |
|
705 | + } |
|
689 | 706 | } |
690 | 707 | |
691 | 708 | // Submitting! |
@@ -694,37 +711,45 @@ discard block |
||
694 | 711 | checkSession(); |
695 | 712 | validateToken('admin-sts'); |
696 | 713 | |
697 | - if (empty($_POST['options'])) |
|
698 | - $_POST['options'] = array(); |
|
699 | - if (empty($_POST['default_options'])) |
|
700 | - $_POST['default_options'] = array(); |
|
714 | + if (empty($_POST['options'])) { |
|
715 | + $_POST['options'] = array(); |
|
716 | + } |
|
717 | + if (empty($_POST['default_options'])) { |
|
718 | + $_POST['default_options'] = array(); |
|
719 | + } |
|
701 | 720 | |
702 | 721 | // Make sure items are cast correctly. |
703 | 722 | foreach ($context['theme_settings'] as $item) |
704 | 723 | { |
705 | 724 | // Disregard this item if this is just a separator. |
706 | - if (!is_array($item)) |
|
707 | - continue; |
|
725 | + if (!is_array($item)) { |
|
726 | + continue; |
|
727 | + } |
|
708 | 728 | |
709 | 729 | foreach (array('options', 'default_options') as $option) |
710 | 730 | { |
711 | - if (!isset($_POST[$option][$item['id']])) |
|
712 | - continue; |
|
731 | + if (!isset($_POST[$option][$item['id']])) { |
|
732 | + continue; |
|
733 | + } |
|
713 | 734 | // Checkbox. |
714 | - elseif (empty($item['type'])) |
|
715 | - $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
735 | + elseif (empty($item['type'])) { |
|
736 | + $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
737 | + } |
|
716 | 738 | // Number |
717 | - elseif ($item['type'] == 'number') |
|
718 | - $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
739 | + elseif ($item['type'] == 'number') { |
|
740 | + $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
741 | + } |
|
719 | 742 | } |
720 | 743 | } |
721 | 744 | |
722 | 745 | // Set up the sql query. |
723 | 746 | $inserts = array(); |
724 | - foreach ($_POST['options'] as $opt => $val) |
|
725 | - $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
726 | - foreach ($_POST['default_options'] as $opt => $val) |
|
727 | - $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
747 | + foreach ($_POST['options'] as $opt => $val) { |
|
748 | + $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
749 | + } |
|
750 | + foreach ($_POST['default_options'] as $opt => $val) { |
|
751 | + $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
752 | + } |
|
728 | 753 | // If we're actually inserting something.. |
729 | 754 | if (!empty($inserts)) |
730 | 755 | { |
@@ -750,8 +775,9 @@ discard block |
||
750 | 775 | |
751 | 776 | foreach ($settings as $setting => $dummy) |
752 | 777 | { |
753 | - if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) |
|
754 | - $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
778 | + if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) { |
|
779 | + $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
780 | + } |
|
755 | 781 | } |
756 | 782 | |
757 | 783 | $context['settings'] = $context['theme_settings']; |
@@ -760,18 +786,21 @@ discard block |
||
760 | 786 | foreach ($context['settings'] as $i => $setting) |
761 | 787 | { |
762 | 788 | // Separators are dummies, so leave them alone. |
763 | - if (!is_array($setting)) |
|
764 | - continue; |
|
789 | + if (!is_array($setting)) { |
|
790 | + continue; |
|
791 | + } |
|
765 | 792 | |
766 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
767 | - $context['settings'][$i]['type'] = 'checkbox'; |
|
768 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
769 | - $context['settings'][$i]['type'] = 'number'; |
|
770 | - elseif ($setting['type'] == 'string') |
|
771 | - $context['settings'][$i]['type'] = 'text'; |
|
793 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
794 | + $context['settings'][$i]['type'] = 'checkbox'; |
|
795 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
796 | + $context['settings'][$i]['type'] = 'number'; |
|
797 | + } elseif ($setting['type'] == 'string') { |
|
798 | + $context['settings'][$i]['type'] = 'text'; |
|
799 | + } |
|
772 | 800 | |
773 | - if (isset($setting['options'])) |
|
774 | - $context['settings'][$i]['type'] = 'list'; |
|
801 | + if (isset($setting['options'])) { |
|
802 | + $context['settings'][$i]['type'] = 'list'; |
|
803 | + } |
|
775 | 804 | |
776 | 805 | $context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']]; |
777 | 806 | } |
@@ -824,8 +853,9 @@ discard block |
||
824 | 853 | $themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
825 | 854 | |
826 | 855 | // You can't delete the default theme! |
827 | - if ($themeID == 1) |
|
828 | - fatal_lang_error('no_access', false); |
|
856 | + if ($themeID == 1) { |
|
857 | + fatal_lang_error('no_access', false); |
|
858 | + } |
|
829 | 859 | |
830 | 860 | $theme_info = get_single_theme($themeID); |
831 | 861 | |
@@ -833,8 +863,9 @@ discard block |
||
833 | 863 | remove_theme($themeID); |
834 | 864 | |
835 | 865 | // And remove all its files and folders too. |
836 | - if (!empty($theme_info) && !empty($theme_info['theme_dir'])) |
|
837 | - remove_dir($theme_info['theme_dir']); |
|
866 | + if (!empty($theme_info) && !empty($theme_info['theme_dir'])) { |
|
867 | + remove_dir($theme_info['theme_dir']); |
|
868 | + } |
|
838 | 869 | |
839 | 870 | // Go back to the list page. |
840 | 871 | redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=removing'); |
@@ -859,12 +890,14 @@ discard block |
||
859 | 890 | $enableThemes = explode(',', $modSettings['enableThemes']); |
860 | 891 | |
861 | 892 | // Are we disabling it? |
862 | - if (isset($_GET['disabled'])) |
|
863 | - $enableThemes = array_diff($enableThemes, array($themeID)); |
|
893 | + if (isset($_GET['disabled'])) { |
|
894 | + $enableThemes = array_diff($enableThemes, array($themeID)); |
|
895 | + } |
|
864 | 896 | |
865 | 897 | // Nope? then enable it! |
866 | - else |
|
867 | - $enableThemes[] = (string) $themeID; |
|
898 | + else { |
|
899 | + $enableThemes[] = (string) $themeID; |
|
900 | + } |
|
868 | 901 | |
869 | 902 | // Update the setting. |
870 | 903 | $enableThemes = strtr(implode(',', $enableThemes), array(',,' => ',')); |
@@ -899,18 +932,21 @@ discard block |
||
899 | 932 | |
900 | 933 | $_SESSION['id_theme'] = 0; |
901 | 934 | |
902 | - if (isset($_GET['id'])) |
|
903 | - $_GET['th'] = $_GET['id']; |
|
935 | + if (isset($_GET['id'])) { |
|
936 | + $_GET['th'] = $_GET['id']; |
|
937 | + } |
|
904 | 938 | |
905 | 939 | // Saving a variant cause JS doesn't work - pretend it did ;) |
906 | 940 | if (isset($_POST['save'])) |
907 | 941 | { |
908 | 942 | // Which theme? |
909 | - foreach ($_POST['save'] as $k => $v) |
|
910 | - $_GET['th'] = (int) $k; |
|
943 | + foreach ($_POST['save'] as $k => $v) { |
|
944 | + $_GET['th'] = (int) $k; |
|
945 | + } |
|
911 | 946 | |
912 | - if (isset($_POST['vrt'][$k])) |
|
913 | - $_GET['vrt'] = $_POST['vrt'][$k]; |
|
947 | + if (isset($_POST['vrt'][$k])) { |
|
948 | + $_GET['vrt'] = $_POST['vrt'][$k]; |
|
949 | + } |
|
914 | 950 | } |
915 | 951 | |
916 | 952 | // Have we made a decision, or are we just browsing? |
@@ -988,8 +1024,9 @@ discard block |
||
988 | 1024 | else |
989 | 1025 | { |
990 | 1026 | // The forum's default theme is always 0 and we |
991 | - if (isset($_GET['th']) && $_GET['th'] == 0) |
|
992 | - $_GET['th'] = $modSettings['theme_guests']; |
|
1027 | + if (isset($_GET['th']) && $_GET['th'] == 0) { |
|
1028 | + $_GET['th'] = $modSettings['theme_guests']; |
|
1029 | + } |
|
993 | 1030 | |
994 | 1031 | updateMemberData((int) $_REQUEST['u'], array('id_theme' => (int) $_GET['th'])); |
995 | 1032 | |
@@ -1003,8 +1040,9 @@ discard block |
||
1003 | 1040 | ); |
1004 | 1041 | cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90); |
1005 | 1042 | |
1006 | - if ($user_info['id'] == $_REQUEST['u']) |
|
1007 | - $_SESSION['id_variant'] = 0; |
|
1043 | + if ($user_info['id'] == $_REQUEST['u']) { |
|
1044 | + $_SESSION['id_variant'] = 0; |
|
1045 | + } |
|
1008 | 1046 | } |
1009 | 1047 | |
1010 | 1048 | redirectexit('action=profile;u=' . (int) $_REQUEST['u'] . ';area=theme'); |
@@ -1073,12 +1111,13 @@ discard block |
||
1073 | 1111 | ); |
1074 | 1112 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1075 | 1113 | { |
1076 | - if (!isset($context['available_themes'][$row['id_theme']])) |
|
1077 | - $context['available_themes'][$row['id_theme']] = array( |
|
1114 | + if (!isset($context['available_themes'][$row['id_theme']])) { |
|
1115 | + $context['available_themes'][$row['id_theme']] = array( |
|
1078 | 1116 | 'id' => $row['id_theme'], |
1079 | 1117 | 'selected' => $context['current_theme'] == $row['id_theme'], |
1080 | 1118 | 'num_users' => 0 |
1081 | 1119 | ); |
1120 | + } |
|
1082 | 1121 | $context['available_themes'][$row['id_theme']][$row['variable']] = $row['value']; |
1083 | 1122 | } |
1084 | 1123 | $smcFunc['db_free_result']($request); |
@@ -1091,9 +1130,9 @@ discard block |
||
1091 | 1130 | 'num_users' => 0 |
1092 | 1131 | ); |
1093 | 1132 | $guest_theme = 0; |
1133 | + } else { |
|
1134 | + $guest_theme = $modSettings['theme_guests']; |
|
1094 | 1135 | } |
1095 | - else |
|
1096 | - $guest_theme = $modSettings['theme_guests']; |
|
1097 | 1136 | |
1098 | 1137 | $request = $smcFunc['db_query']('', ' |
1099 | 1138 | SELECT id_theme, COUNT(*) AS the_count |
@@ -1106,15 +1145,17 @@ discard block |
||
1106 | 1145 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1107 | 1146 | { |
1108 | 1147 | // Figure out which theme it is they are REALLY using. |
1109 | - if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) |
|
1110 | - $row['id_theme'] = $guest_theme; |
|
1111 | - elseif (empty($modSettings['theme_allow'])) |
|
1112 | - $row['id_theme'] = $guest_theme; |
|
1148 | + if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) { |
|
1149 | + $row['id_theme'] = $guest_theme; |
|
1150 | + } elseif (empty($modSettings['theme_allow'])) { |
|
1151 | + $row['id_theme'] = $guest_theme; |
|
1152 | + } |
|
1113 | 1153 | |
1114 | - if (isset($context['available_themes'][$row['id_theme']])) |
|
1115 | - $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
1116 | - else |
|
1117 | - $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
1154 | + if (isset($context['available_themes'][$row['id_theme']])) { |
|
1155 | + $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
1156 | + } else { |
|
1157 | + $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
1158 | + } |
|
1118 | 1159 | } |
1119 | 1160 | $smcFunc['db_free_result']($request); |
1120 | 1161 | |
@@ -1133,8 +1174,9 @@ discard block |
||
1133 | 1174 | 'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1), |
1134 | 1175 | ) |
1135 | 1176 | ); |
1136 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1137 | - $variant_preferences[$row['id_theme']] = $row['value']; |
|
1177 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1178 | + $variant_preferences[$row['id_theme']] = $row['value']; |
|
1179 | + } |
|
1138 | 1180 | $smcFunc['db_free_result']($request); |
1139 | 1181 | } |
1140 | 1182 | |
@@ -1145,17 +1187,18 @@ discard block |
||
1145 | 1187 | foreach ($context['available_themes'] as $id_theme => $theme_data) |
1146 | 1188 | { |
1147 | 1189 | // Don't try to load the forum or board default theme's data... it doesn't have any! |
1148 | - if ($id_theme == 0) |
|
1149 | - continue; |
|
1190 | + if ($id_theme == 0) { |
|
1191 | + continue; |
|
1192 | + } |
|
1150 | 1193 | |
1151 | 1194 | // The thumbnail needs the correct path. |
1152 | 1195 | $settings['images_url'] = &$theme_data['images_url']; |
1153 | 1196 | |
1154 | - if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) |
|
1155 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
1156 | - elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) |
|
1157 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
1158 | - else |
|
1197 | + if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) { |
|
1198 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
1199 | + } elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) { |
|
1200 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
1201 | + } else |
|
1159 | 1202 | { |
1160 | 1203 | $txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png'; |
1161 | 1204 | $txt['theme_description'] = ''; |
@@ -1180,15 +1223,17 @@ discard block |
||
1180 | 1223 | loadLanguage('Settings'); |
1181 | 1224 | |
1182 | 1225 | $context['available_themes'][$id_theme]['variants'] = array(); |
1183 | - foreach ($settings['theme_variants'] as $variant) |
|
1184 | - $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
1226 | + foreach ($settings['theme_variants'] as $variant) { |
|
1227 | + $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
1185 | 1228 | 'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant, |
1186 | 1229 | 'thumbnail' => !file_exists($theme_data['theme_dir'] . '/images/thumbnail.png') || file_exists($theme_data['theme_dir'] . '/images/thumbnail_' . $variant . '.png') ? $theme_data['images_url'] . '/thumbnail_' . $variant . '.png' : ($theme_data['images_url'] . '/thumbnail.png'), |
1187 | 1230 | ); |
1231 | + } |
|
1188 | 1232 | |
1189 | 1233 | $context['available_themes'][$id_theme]['selected_variant'] = isset($_GET['vrt']) ? $_GET['vrt'] : (!empty($variant_preferences[$id_theme]) ? $variant_preferences[$id_theme] : (!empty($settings['default_variant']) ? $settings['default_variant'] : $settings['theme_variants'][0])); |
1190 | - if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) |
|
1191 | - $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
1234 | + if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) { |
|
1235 | + $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
1236 | + } |
|
1192 | 1237 | |
1193 | 1238 | $context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']; |
1194 | 1239 | // Allow themes to override the text. |
@@ -1204,8 +1249,9 @@ discard block |
||
1204 | 1249 | // As long as we're not doing the default theme... |
1205 | 1250 | if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0) |
1206 | 1251 | { |
1207 | - if ($guest_theme != 0) |
|
1208 | - $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
1252 | + if ($guest_theme != 0) { |
|
1253 | + $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
1254 | + } |
|
1209 | 1255 | |
1210 | 1256 | $context['available_themes'][0]['id'] = 0; |
1211 | 1257 | $context['available_themes'][0]['name'] = $txt['theme_forum_default']; |
@@ -1254,14 +1300,16 @@ discard block |
||
1254 | 1300 | $action = $smcFunc['htmlspecialchars'](trim($_GET['do'])); |
1255 | 1301 | |
1256 | 1302 | // Got any info from the specific form? |
1257 | - if (!isset($_POST['save_' . $action])) |
|
1258 | - fatal_lang_error('theme_install_no_action', false); |
|
1303 | + if (!isset($_POST['save_' . $action])) { |
|
1304 | + fatal_lang_error('theme_install_no_action', false); |
|
1305 | + } |
|
1259 | 1306 | |
1260 | 1307 | validateToken('admin-t-' . $action); |
1261 | 1308 | |
1262 | 1309 | // Hopefully the themes directory is writable, or we might have a problem. |
1263 | - if (!is_writable($themedir)) |
|
1264 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
1310 | + if (!is_writable($themedir)) { |
|
1311 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
1312 | + } |
|
1265 | 1313 | |
1266 | 1314 | // Call the function and handle the result. |
1267 | 1315 | $result = $subActions[$action](); |
@@ -1276,9 +1324,10 @@ discard block |
||
1276 | 1324 | } |
1277 | 1325 | |
1278 | 1326 | // Nope, show a nice error. |
1279 | - else |
|
1280 | - fatal_lang_error('theme_install_no_action', false); |
|
1281 | -} |
|
1327 | + else { |
|
1328 | + fatal_lang_error('theme_install_no_action', false); |
|
1329 | + } |
|
1330 | + } |
|
1282 | 1331 | |
1283 | 1332 | /** |
1284 | 1333 | * Installs a theme from a theme package. |
@@ -1294,8 +1343,9 @@ discard block |
||
1294 | 1343 | $dirtemp = $themedir . '/temp'; |
1295 | 1344 | |
1296 | 1345 | // Make sure the temp dir doesn't already exist |
1297 | - if (file_exists($dirtemp)) |
|
1298 | - remove_dir($dirtemp); |
|
1346 | + if (file_exists($dirtemp)) { |
|
1347 | + remove_dir($dirtemp); |
|
1348 | + } |
|
1299 | 1349 | |
1300 | 1350 | // Create the temp dir. |
1301 | 1351 | mkdir($dirtemp, 0777); |
@@ -1307,17 +1357,20 @@ discard block |
||
1307 | 1357 | smf_chmod($dirtemp, '0755'); |
1308 | 1358 | |
1309 | 1359 | // How about now? |
1310 | - if (!is_writable($dirtemp)) |
|
1311 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
1360 | + if (!is_writable($dirtemp)) { |
|
1361 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
1362 | + } |
|
1312 | 1363 | } |
1313 | 1364 | |
1314 | 1365 | // This happens when the admin session is gone and the user has to login again. |
1315 | - if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) |
|
1316 | - redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
1366 | + if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) { |
|
1367 | + redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
1368 | + } |
|
1317 | 1369 | |
1318 | 1370 | // Another error check layer, something went wrong with the upload. |
1319 | - if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) |
|
1320 | - fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
1371 | + if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) { |
|
1372 | + fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
1373 | + } |
|
1321 | 1374 | |
1322 | 1375 | // Get the theme's name. |
1323 | 1376 | $name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME); |
@@ -1348,11 +1401,10 @@ discard block |
||
1348 | 1401 | |
1349 | 1402 | // return all the info. |
1350 | 1403 | return $context['to_install']; |
1404 | + } else { |
|
1405 | + fatal_lang_error('theme_install_error_title', false); |
|
1406 | + } |
|
1351 | 1407 | } |
1352 | - |
|
1353 | - else |
|
1354 | - fatal_lang_error('theme_install_error_title', false); |
|
1355 | -} |
|
1356 | 1408 | |
1357 | 1409 | /** |
1358 | 1410 | * Makes a copy from the default theme, assigns a name for it and installs it. |
@@ -1366,15 +1418,17 @@ discard block |
||
1366 | 1418 | global $forum_version; |
1367 | 1419 | |
1368 | 1420 | // There's gotta be something to work with. |
1369 | - if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) |
|
1370 | - fatal_lang_error('theme_install_error_title', false); |
|
1421 | + if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) { |
|
1422 | + fatal_lang_error('theme_install_error_title', false); |
|
1423 | + } |
|
1371 | 1424 | |
1372 | 1425 | // Get a cleaner version. |
1373 | 1426 | $name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']); |
1374 | 1427 | |
1375 | 1428 | // Is there a theme already named like this? |
1376 | - if (file_exists($themedir . '/' . $name)) |
|
1377 | - fatal_lang_error('theme_install_already_dir', false); |
|
1429 | + if (file_exists($themedir . '/' . $name)) { |
|
1430 | + fatal_lang_error('theme_install_already_dir', false); |
|
1431 | + } |
|
1378 | 1432 | |
1379 | 1433 | // This is a brand new theme so set all possible values. |
1380 | 1434 | $context['to_install'] = array( |
@@ -1394,8 +1448,9 @@ discard block |
||
1394 | 1448 | |
1395 | 1449 | // Buy some time. |
1396 | 1450 | @set_time_limit(600); |
1397 | - if (function_exists('apache_reset_timeout')) |
|
1398 | - @apache_reset_timeout(); |
|
1451 | + if (function_exists('apache_reset_timeout')) { |
|
1452 | + @apache_reset_timeout(); |
|
1453 | + } |
|
1399 | 1454 | |
1400 | 1455 | // Create subdirectories for css and javascript files. |
1401 | 1456 | mkdir($context['to_install']['theme_dir'] . '/css', 0777); |
@@ -1431,12 +1486,13 @@ discard block |
||
1431 | 1486 | |
1432 | 1487 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1433 | 1488 | { |
1434 | - if ($row['variable'] == 'theme_templates') |
|
1435 | - $theme_templates = $row['value']; |
|
1436 | - elseif ($row['variable'] == 'theme_layers') |
|
1437 | - $theme_layers = $row['value']; |
|
1438 | - else |
|
1439 | - continue; |
|
1489 | + if ($row['variable'] == 'theme_templates') { |
|
1490 | + $theme_templates = $row['value']; |
|
1491 | + } elseif ($row['variable'] == 'theme_layers') { |
|
1492 | + $theme_layers = $row['value']; |
|
1493 | + } else { |
|
1494 | + continue; |
|
1495 | + } |
|
1440 | 1496 | } |
1441 | 1497 | |
1442 | 1498 | $smcFunc['db_free_result']($request); |
@@ -1495,12 +1551,14 @@ discard block |
||
1495 | 1551 | global $themedir, $themeurl, $context; |
1496 | 1552 | |
1497 | 1553 | // Cannot use the theme dir as a theme dir. |
1498 | - if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) |
|
1499 | - fatal_lang_error('theme_install_invalid_dir', false); |
|
1554 | + if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) { |
|
1555 | + fatal_lang_error('theme_install_invalid_dir', false); |
|
1556 | + } |
|
1500 | 1557 | |
1501 | 1558 | // Check is there is "something" on the dir. |
1502 | - elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) |
|
1503 | - fatal_lang_error('theme_install_error', false); |
|
1559 | + elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) { |
|
1560 | + fatal_lang_error('theme_install_error', false); |
|
1561 | + } |
|
1504 | 1562 | |
1505 | 1563 | $name = basename($_REQUEST['theme_dir']); |
1506 | 1564 | $name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name); |
@@ -1544,24 +1602,27 @@ discard block |
||
1544 | 1602 | } |
1545 | 1603 | |
1546 | 1604 | // Any special layers? |
1547 | - if (isset($settings['catch_action']['layers'])) |
|
1548 | - $context['template_layers'] = $settings['catch_action']['layers']; |
|
1605 | + if (isset($settings['catch_action']['layers'])) { |
|
1606 | + $context['template_layers'] = $settings['catch_action']['layers']; |
|
1607 | + } |
|
1549 | 1608 | |
1550 | 1609 | // Any function to call? |
1551 | 1610 | if (isset($settings['catch_action']['function'])) |
1552 | 1611 | { |
1553 | 1612 | $hook = $settings['catch_action']['function']; |
1554 | 1613 | |
1555 | - if (!isset($settings['catch_action']['filename'])) |
|
1556 | - $settings['catch_action']['filename'] = ''; |
|
1614 | + if (!isset($settings['catch_action']['filename'])) { |
|
1615 | + $settings['catch_action']['filename'] = ''; |
|
1616 | + } |
|
1557 | 1617 | |
1558 | 1618 | add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false); |
1559 | 1619 | call_integration_hook('integrate_wrap_action'); |
1560 | 1620 | } |
1561 | 1621 | // And finally, the main sub template ;). |
1562 | - if (isset($settings['catch_action']['sub_template'])) |
|
1563 | - $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
1564 | -} |
|
1622 | + if (isset($settings['catch_action']['sub_template'])) { |
|
1623 | + $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
1624 | + } |
|
1625 | + } |
|
1565 | 1626 | |
1566 | 1627 | /** |
1567 | 1628 | * Set an option via javascript. |
@@ -1580,12 +1641,14 @@ discard block |
||
1580 | 1641 | checkSession('get'); |
1581 | 1642 | |
1582 | 1643 | // This good-for-nothing pixel is being used to keep the session alive. |
1583 | - if (empty($_GET['var']) || !isset($_GET['val'])) |
|
1584 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
1644 | + if (empty($_GET['var']) || !isset($_GET['val'])) { |
|
1645 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
1646 | + } |
|
1585 | 1647 | |
1586 | 1648 | // Sorry, guests can't go any further than this. |
1587 | - if ($user_info['is_guest'] || $user_info['id'] == 0) |
|
1588 | - obExit(false); |
|
1649 | + if ($user_info['is_guest'] || $user_info['id'] == 0) { |
|
1650 | + obExit(false); |
|
1651 | + } |
|
1589 | 1652 | |
1590 | 1653 | $reservedVars = array( |
1591 | 1654 | 'actual_theme_url', |
@@ -1608,8 +1671,9 @@ discard block |
||
1608 | 1671 | ); |
1609 | 1672 | |
1610 | 1673 | // Can't change reserved vars. |
1611 | - if (in_array(strtolower($_GET['var']), $reservedVars)) |
|
1612 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
1674 | + if (in_array(strtolower($_GET['var']), $reservedVars)) { |
|
1675 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
1676 | + } |
|
1613 | 1677 | |
1614 | 1678 | // Use a specific theme? |
1615 | 1679 | if (isset($_GET['th']) || isset($_GET['id'])) |
@@ -1625,8 +1689,9 @@ discard block |
||
1625 | 1689 | { |
1626 | 1690 | $options['admin_preferences'] = !empty($options['admin_preferences']) ? smf_json_decode($options['admin_preferences'], true) : array(); |
1627 | 1691 | // New thingy... |
1628 | - if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) |
|
1629 | - $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
1692 | + if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) { |
|
1693 | + $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
1694 | + } |
|
1630 | 1695 | |
1631 | 1696 | // Change the value to be something nice, |
1632 | 1697 | $_GET['val'] = json_encode($options['admin_preferences']); |
@@ -1656,8 +1721,9 @@ discard block |
||
1656 | 1721 | global $context, $scripturl, $boarddir, $smcFunc, $txt; |
1657 | 1722 | |
1658 | 1723 | // @todo Should this be removed? |
1659 | - if (isset($_REQUEST['preview'])) |
|
1660 | - die('die() with fire'); |
|
1724 | + if (isset($_REQUEST['preview'])) { |
|
1725 | + die('die() with fire'); |
|
1726 | + } |
|
1661 | 1727 | |
1662 | 1728 | isAllowedTo('admin_forum'); |
1663 | 1729 | loadTemplate('Themes'); |
@@ -1671,11 +1737,11 @@ discard block |
||
1671 | 1737 | foreach ($context['themes'] as $key => $theme) |
1672 | 1738 | { |
1673 | 1739 | // There has to be a Settings template! |
1674 | - if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) |
|
1675 | - unset($context['themes'][$key]); |
|
1676 | - |
|
1677 | - else |
|
1678 | - $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
1740 | + if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) { |
|
1741 | + unset($context['themes'][$key]); |
|
1742 | + } else { |
|
1743 | + $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
1744 | + } |
|
1679 | 1745 | } |
1680 | 1746 | |
1681 | 1747 | $context['sub_template'] = 'edit_list'; |
@@ -1690,22 +1756,24 @@ discard block |
||
1690 | 1756 | $context['theme_id'] = $currentTheme['id']; |
1691 | 1757 | $context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']); |
1692 | 1758 | |
1693 | - if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) |
|
1694 | - fatal_lang_error('theme_edit_missing', false); |
|
1759 | + if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) { |
|
1760 | + fatal_lang_error('theme_edit_missing', false); |
|
1761 | + } |
|
1695 | 1762 | |
1696 | 1763 | if (!isset($_REQUEST['filename'])) |
1697 | 1764 | { |
1698 | 1765 | if (isset($_GET['directory'])) |
1699 | 1766 | { |
1700 | - if (substr($_GET['directory'], 0, 1) == '.') |
|
1701 | - $_GET['directory'] = ''; |
|
1702 | - else |
|
1767 | + if (substr($_GET['directory'], 0, 1) == '.') { |
|
1768 | + $_GET['directory'] = ''; |
|
1769 | + } else |
|
1703 | 1770 | { |
1704 | 1771 | $_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']); |
1705 | 1772 | |
1706 | 1773 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']); |
1707 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
1708 | - $_GET['directory'] = ''; |
|
1774 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
1775 | + $_GET['directory'] = ''; |
|
1776 | + } |
|
1709 | 1777 | } |
1710 | 1778 | } |
1711 | 1779 | |
@@ -1724,37 +1792,39 @@ discard block |
||
1724 | 1792 | 'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp, |
1725 | 1793 | 'size' => '', |
1726 | 1794 | )); |
1795 | + } else { |
|
1796 | + $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
1727 | 1797 | } |
1728 | - else |
|
1729 | - $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
1730 | 1798 | |
1731 | 1799 | $context['sub_template'] = 'edit_browse'; |
1732 | 1800 | |
1733 | 1801 | return; |
1734 | - } |
|
1735 | - else |
|
1802 | + } else |
|
1736 | 1803 | { |
1737 | - if (substr($_REQUEST['filename'], 0, 1) == '.') |
|
1738 | - $_REQUEST['filename'] = ''; |
|
1739 | - else |
|
1804 | + if (substr($_REQUEST['filename'], 0, 1) == '.') { |
|
1805 | + $_REQUEST['filename'] = ''; |
|
1806 | + } else |
|
1740 | 1807 | { |
1741 | 1808 | $_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']); |
1742 | 1809 | |
1743 | 1810 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
1744 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
1745 | - $_REQUEST['filename'] = ''; |
|
1811 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
1812 | + $_REQUEST['filename'] = ''; |
|
1813 | + } |
|
1746 | 1814 | } |
1747 | 1815 | |
1748 | - if (empty($_REQUEST['filename'])) |
|
1749 | - fatal_lang_error('theme_edit_missing', false); |
|
1816 | + if (empty($_REQUEST['filename'])) { |
|
1817 | + fatal_lang_error('theme_edit_missing', false); |
|
1818 | + } |
|
1750 | 1819 | } |
1751 | 1820 | |
1752 | 1821 | if (isset($_POST['save'])) |
1753 | 1822 | { |
1754 | 1823 | if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true) |
1755 | 1824 | { |
1756 | - if (is_array($_POST['entire_file'])) |
|
1757 | - $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
1825 | + if (is_array($_POST['entire_file'])) { |
|
1826 | + $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
1827 | + } |
|
1758 | 1828 | |
1759 | 1829 | $_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', ' ' => "\t"))); |
1760 | 1830 | |
@@ -1766,10 +1836,11 @@ discard block |
||
1766 | 1836 | fclose($fp); |
1767 | 1837 | |
1768 | 1838 | $error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php'); |
1769 | - if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) |
|
1770 | - $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
1771 | - else |
|
1772 | - unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
1839 | + if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) { |
|
1840 | + $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
1841 | + } else { |
|
1842 | + unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
1843 | + } |
|
1773 | 1844 | } |
1774 | 1845 | |
1775 | 1846 | if (!isset($error_file)) |
@@ -1790,10 +1861,11 @@ discard block |
||
1790 | 1861 | $context['sub_template'] = 'edit_file'; |
1791 | 1862 | |
1792 | 1863 | // Recycle the submitted data. |
1793 | - if (is_array($_POST['entire_file'])) |
|
1794 | - $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
1795 | - else |
|
1796 | - $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
1864 | + if (is_array($_POST['entire_file'])) { |
|
1865 | + $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
1866 | + } else { |
|
1867 | + $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
1868 | + } |
|
1797 | 1869 | |
1798 | 1870 | $context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']); |
1799 | 1871 | |
@@ -1816,17 +1888,17 @@ discard block |
||
1816 | 1888 | $context['sub_template'] = 'edit_style'; |
1817 | 1889 | |
1818 | 1890 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => ' '))); |
1819 | - } |
|
1820 | - elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
1891 | + } elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
1821 | 1892 | { |
1822 | 1893 | $context['sub_template'] = 'edit_template'; |
1823 | 1894 | |
1824 | - if (!isset($error_file)) |
|
1825 | - $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
1826 | - else |
|
1895 | + if (!isset($error_file)) { |
|
1896 | + $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
1897 | + } else |
|
1827 | 1898 | { |
1828 | - if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) |
|
1829 | - $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
1899 | + if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) { |
|
1900 | + $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
1901 | + } |
|
1830 | 1902 | $file_data = file($error_file); |
1831 | 1903 | unlink($error_file); |
1832 | 1904 | } |
@@ -1840,8 +1912,9 @@ discard block |
||
1840 | 1912 | // Try to format the functions a little nicer... |
1841 | 1913 | $context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n"; |
1842 | 1914 | |
1843 | - if (empty($context['file_parts'][$j]['lines'])) |
|
1844 | - unset($context['file_parts'][$j]); |
|
1915 | + if (empty($context['file_parts'][$j]['lines'])) { |
|
1916 | + unset($context['file_parts'][$j]); |
|
1917 | + } |
|
1845 | 1918 | $context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => ''); |
1846 | 1919 | } |
1847 | 1920 | |
@@ -1850,8 +1923,7 @@ discard block |
||
1850 | 1923 | } |
1851 | 1924 | |
1852 | 1925 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => ' '))); |
1853 | - } |
|
1854 | - else |
|
1926 | + } else |
|
1855 | 1927 | { |
1856 | 1928 | $context['sub_template'] = 'edit_file'; |
1857 | 1929 | |
@@ -1877,8 +1949,9 @@ discard block |
||
1877 | 1949 | |
1878 | 1950 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
1879 | 1951 | |
1880 | - if (empty($_GET['th'])) |
|
1881 | - fatal_lang_error('theme_install_invalid_id'); |
|
1952 | + if (empty($_GET['th'])) { |
|
1953 | + fatal_lang_error('theme_install_invalid_id'); |
|
1954 | + } |
|
1882 | 1955 | |
1883 | 1956 | // Get the theme info. |
1884 | 1957 | $theme = get_single_theme($_GET['th']); |
@@ -1886,25 +1959,24 @@ discard block |
||
1886 | 1959 | |
1887 | 1960 | if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0) |
1888 | 1961 | { |
1889 | - if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) |
|
1890 | - $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
1891 | - |
|
1892 | - else |
|
1893 | - fatal_lang_error('no_access', false); |
|
1962 | + if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) { |
|
1963 | + $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
1964 | + } else { |
|
1965 | + fatal_lang_error('no_access', false); |
|
1966 | + } |
|
1894 | 1967 | |
1895 | 1968 | $fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w'); |
1896 | 1969 | fwrite($fp, file_get_contents($filename)); |
1897 | 1970 | fclose($fp); |
1898 | 1971 | |
1899 | 1972 | redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy'); |
1900 | - } |
|
1901 | - elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
1973 | + } elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
1902 | 1974 | { |
1903 | - if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) |
|
1904 | - $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
1905 | - |
|
1906 | - else |
|
1907 | - fatal_lang_error('no_access', false); |
|
1975 | + if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) { |
|
1976 | + $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
1977 | + } else { |
|
1978 | + fatal_lang_error('no_access', false); |
|
1979 | + } |
|
1908 | 1980 | |
1909 | 1981 | $fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w'); |
1910 | 1982 | fwrite($fp, file_get_contents($filename)); |
@@ -1919,16 +1991,18 @@ discard block |
||
1919 | 1991 | $dir = dir($settings['default_theme_dir']); |
1920 | 1992 | while ($entry = $dir->read()) |
1921 | 1993 | { |
1922 | - if (substr($entry, -13) == '.template.php') |
|
1923 | - $templates[] = substr($entry, 0, -13); |
|
1994 | + if (substr($entry, -13) == '.template.php') { |
|
1995 | + $templates[] = substr($entry, 0, -13); |
|
1996 | + } |
|
1924 | 1997 | } |
1925 | 1998 | $dir->close(); |
1926 | 1999 | |
1927 | 2000 | $dir = dir($settings['default_theme_dir'] . '/languages'); |
1928 | 2001 | while ($entry = $dir->read()) |
1929 | 2002 | { |
1930 | - if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) |
|
1931 | - $lang_files[] = $matches[1]; |
|
2003 | + if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) { |
|
2004 | + $lang_files[] = $matches[1]; |
|
2005 | + } |
|
1932 | 2006 | } |
1933 | 2007 | $dir->close(); |
1934 | 2008 | |
@@ -1936,21 +2010,23 @@ discard block |
||
1936 | 2010 | natcasesort($lang_files); |
1937 | 2011 | |
1938 | 2012 | $context['available_templates'] = array(); |
1939 | - foreach ($templates as $template) |
|
1940 | - $context['available_templates'][$template] = array( |
|
2013 | + foreach ($templates as $template) { |
|
2014 | + $context['available_templates'][$template] = array( |
|
1941 | 2015 | 'filename' => $template . '.template.php', |
1942 | 2016 | 'value' => $template, |
1943 | 2017 | 'already_exists' => false, |
1944 | 2018 | 'can_copy' => is_writable($theme['theme_dir']), |
1945 | 2019 | ); |
2020 | + } |
|
1946 | 2021 | $context['available_language_files'] = array(); |
1947 | - foreach ($lang_files as $file) |
|
1948 | - $context['available_language_files'][$file] = array( |
|
2022 | + foreach ($lang_files as $file) { |
|
2023 | + $context['available_language_files'][$file] = array( |
|
1949 | 2024 | 'filename' => $file . '.php', |
1950 | 2025 | 'value' => $file, |
1951 | 2026 | 'already_exists' => false, |
1952 | 2027 | 'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']), |
1953 | 2028 | ); |
2029 | + } |
|
1954 | 2030 | |
1955 | 2031 | $dir = dir($theme['theme_dir']); |
1956 | 2032 | while ($entry = $dir->read()) |
@@ -19,8 +19,9 @@ discard block |
||
19 | 19 | * @version 2.1 Beta 3 |
20 | 20 | */ |
21 | 21 | |
22 | -if (!defined('SMF')) |
|
22 | +if (!defined('SMF')) { |
|
23 | 23 | die('No direct access...'); |
24 | +} |
|
24 | 25 | |
25 | 26 | /** |
26 | 27 | * Class gif_lzw_compression |
@@ -52,13 +53,15 @@ discard block |
||
52 | 53 | |
53 | 54 | $this->LZWCommand($data, true); |
54 | 55 | |
55 | - while (($iIndex = $this->LZWCommand($data, false)) >= 0) |
|
56 | - $ret .= chr($iIndex); |
|
56 | + while (($iIndex = $this->LZWCommand($data, false)) >= 0) { |
|
57 | + $ret .= chr($iIndex); |
|
58 | + } |
|
57 | 59 | |
58 | 60 | $datLen = $stLen - strlen($data); |
59 | 61 | |
60 | - if ($iIndex != -2) |
|
61 | - return false; |
|
62 | + if ($iIndex != -2) { |
|
63 | + return false; |
|
64 | + } |
|
62 | 65 | |
63 | 66 | return $ret; |
64 | 67 | } |
@@ -140,8 +143,9 @@ discard block |
||
140 | 143 | return $this->FirstCode; |
141 | 144 | } |
142 | 145 | |
143 | - if ($Code == $this->EndCode) |
|
144 | - return -2; |
|
146 | + if ($Code == $this->EndCode) { |
|
147 | + return -2; |
|
148 | + } |
|
145 | 149 | |
146 | 150 | $InCode = $Code; |
147 | 151 | if ($Code >= $this->MaxCode) |
@@ -156,8 +160,10 @@ discard block |
||
156 | 160 | $this->Stack[$this->sp] = $this->Vals[$Code]; |
157 | 161 | $this->sp++; |
158 | 162 | |
159 | - if ($Code == $this->Next[$Code]) // Circular table entry, big GIF Error! |
|
163 | + if ($Code == $this->Next[$Code]) { |
|
164 | + // Circular table entry, big GIF Error! |
|
160 | 165 | return -1; |
166 | + } |
|
161 | 167 | |
162 | 168 | $Code = $this->Next[$Code]; |
163 | 169 | } |
@@ -207,8 +213,9 @@ discard block |
||
207 | 213 | if ($this->Done) |
208 | 214 | { |
209 | 215 | // Ran off the end of my bits... |
210 | - if ($this->CurBit >= $this->LastBit) |
|
211 | - return 0; |
|
216 | + if ($this->CurBit >= $this->LastBit) { |
|
217 | + return 0; |
|
218 | + } |
|
212 | 219 | |
213 | 220 | return -1; |
214 | 221 | } |
@@ -221,13 +228,14 @@ discard block |
||
221 | 228 | |
222 | 229 | if ($count) |
223 | 230 | { |
224 | - for ($i = 0; $i < $count; $i++) |
|
225 | - $this->Buf[2 + $i] = ord($data{$i}); |
|
231 | + for ($i = 0; $i < $count; $i++) { |
|
232 | + $this->Buf[2 + $i] = ord($data{$i}); |
|
233 | + } |
|
226 | 234 | |
227 | 235 | $data = substr($data, $count); |
236 | + } else { |
|
237 | + $this->Done = 1; |
|
228 | 238 | } |
229 | - else |
|
230 | - $this->Done = 1; |
|
231 | 239 | |
232 | 240 | $this->LastByte = 2 + $count; |
233 | 241 | $this->CurBit = ($this->CurBit - $this->LastBit) + 16; |
@@ -235,8 +243,9 @@ discard block |
||
235 | 243 | } |
236 | 244 | |
237 | 245 | $iRet = 0; |
238 | - for ($i = $this->CurBit, $j = 0; $j < $this->CodeSize; $i++, $j++) |
|
239 | - $iRet |= (($this->Buf[intval($i / 8)] & (1 << ($i % 8))) != 0) << $j; |
|
246 | + for ($i = $this->CurBit, $j = 0; $j < $this->CodeSize; $i++, $j++) { |
|
247 | + $iRet |= (($this->Buf[intval($i / 8)] & (1 << ($i % 8))) != 0) << $j; |
|
248 | + } |
|
240 | 249 | |
241 | 250 | $this->CurBit += $this->CodeSize; |
242 | 251 | return $iRet; |
@@ -261,8 +270,9 @@ discard block |
||
261 | 270 | for ($i = 0; $i < $num; $i++) |
262 | 271 | { |
263 | 272 | $rgb = substr($lpData, $i * 3, 3); |
264 | - if (strlen($rgb) < 3) |
|
265 | - return false; |
|
273 | + if (strlen($rgb) < 3) { |
|
274 | + return false; |
|
275 | + } |
|
266 | 276 | |
267 | 277 | $this->m_arColors[] = (ord($rgb[2]) << 16) + (ord($rgb[1]) << 8) + ord($rgb[0]); |
268 | 278 | $this->m_nColors++; |
@@ -329,13 +339,15 @@ discard block |
||
329 | 339 | $hdrLen = 0; |
330 | 340 | |
331 | 341 | $this->m_lpVer = substr($lpData, 0, 6); |
332 | - if (($this->m_lpVer != 'GIF87a') && ($this->m_lpVer != 'GIF89a')) |
|
333 | - return false; |
|
342 | + if (($this->m_lpVer != 'GIF87a') && ($this->m_lpVer != 'GIF89a')) { |
|
343 | + return false; |
|
344 | + } |
|
334 | 345 | |
335 | 346 | list ($this->m_nWidth, $this->m_nHeight) = array_values(unpack('v2', substr($lpData, 6, 4))); |
336 | 347 | |
337 | - if (!$this->m_nWidth || !$this->m_nHeight) |
|
338 | - return false; |
|
348 | + if (!$this->m_nWidth || !$this->m_nHeight) { |
|
349 | + return false; |
|
350 | + } |
|
339 | 351 | |
340 | 352 | $b = ord(substr($lpData, 10, 1)); |
341 | 353 | $this->m_bGlobalClr = ($b & 0x80) ? true : false; |
@@ -349,8 +361,9 @@ discard block |
||
349 | 361 | if ($this->m_bGlobalClr) |
350 | 362 | { |
351 | 363 | $this->m_colorTable = new gif_color_table(); |
352 | - if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) |
|
353 | - return false; |
|
364 | + if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) { |
|
365 | + return false; |
|
366 | + } |
|
354 | 367 | |
355 | 368 | $hdrLen += 3 * $this->m_nTableSize; |
356 | 369 | } |
@@ -377,8 +390,9 @@ discard block |
||
377 | 390 | // Get the width/height/etc. from the header. |
378 | 391 | list ($this->m_nLeft, $this->m_nTop, $this->m_nWidth, $this->m_nHeight) = array_values(unpack('v4', substr($lpData, 0, 8))); |
379 | 392 | |
380 | - if (!$this->m_nWidth || !$this->m_nHeight) |
|
381 | - return false; |
|
393 | + if (!$this->m_nWidth || !$this->m_nHeight) { |
|
394 | + return false; |
|
395 | + } |
|
382 | 396 | |
383 | 397 | $b = ord($lpData[8]); |
384 | 398 | $this->m_bLocalClr = ($b & 0x80) ? true : false; |
@@ -390,8 +404,9 @@ discard block |
||
390 | 404 | if ($this->m_bLocalClr) |
391 | 405 | { |
392 | 406 | $this->m_colorTable = new gif_color_table(); |
393 | - if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) |
|
394 | - return false; |
|
407 | + if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) { |
|
408 | + return false; |
|
409 | + } |
|
395 | 410 | |
396 | 411 | $hdrLen += 3 * $this->m_nTableSize; |
397 | 412 | } |
@@ -427,8 +442,9 @@ discard block |
||
427 | 442 | // Extension... |
428 | 443 | case 0x21: |
429 | 444 | $len = 0; |
430 | - if (!$this->skipExt($data, $len)) |
|
431 | - return false; |
|
445 | + if (!$this->skipExt($data, $len)) { |
|
446 | + return false; |
|
447 | + } |
|
432 | 448 | |
433 | 449 | $datLen += $len; |
434 | 450 | break; |
@@ -437,22 +453,25 @@ discard block |
||
437 | 453 | case 0x2C: |
438 | 454 | // Load the header and color table. |
439 | 455 | $len = 0; |
440 | - if (!$this->m_gih->load($data, $len)) |
|
441 | - return false; |
|
456 | + if (!$this->m_gih->load($data, $len)) { |
|
457 | + return false; |
|
458 | + } |
|
442 | 459 | |
443 | 460 | $data = substr($data, $len); |
444 | 461 | $datLen += $len; |
445 | 462 | |
446 | 463 | // Decompress the data, and ride on home ;). |
447 | 464 | $len = 0; |
448 | - if (!($this->m_data = $this->m_lzw->decompress($data, $len))) |
|
449 | - return false; |
|
465 | + if (!($this->m_data = $this->m_lzw->decompress($data, $len))) { |
|
466 | + return false; |
|
467 | + } |
|
450 | 468 | |
451 | 469 | $data = substr($data, $len); |
452 | 470 | $datLen += $len; |
453 | 471 | |
454 | - if ($this->m_gih->m_bInterlace) |
|
455 | - $this->deInterlace(); |
|
472 | + if ($this->m_gih->m_bInterlace) { |
|
473 | + $this->deInterlace(); |
|
474 | + } |
|
456 | 475 | |
457 | 476 | return true; |
458 | 477 | |
@@ -572,17 +591,20 @@ discard block |
||
572 | 591 | |
573 | 592 | public function loadFile($filename, $iIndex) |
574 | 593 | { |
575 | - if ($iIndex < 0) |
|
576 | - return false; |
|
594 | + if ($iIndex < 0) { |
|
595 | + return false; |
|
596 | + } |
|
577 | 597 | |
578 | 598 | $this->data = @file_get_contents($filename); |
579 | - if ($this->data === false) |
|
580 | - return false; |
|
599 | + if ($this->data === false) { |
|
600 | + return false; |
|
601 | + } |
|
581 | 602 | |
582 | 603 | // Tell the header to load up.... |
583 | 604 | $len = 0; |
584 | - if (!$this->header->load($this->data, $len)) |
|
585 | - return false; |
|
605 | + if (!$this->header->load($this->data, $len)) { |
|
606 | + return false; |
|
607 | + } |
|
586 | 608 | |
587 | 609 | $this->data = substr($this->data, $len); |
588 | 610 | |
@@ -590,8 +612,9 @@ discard block |
||
590 | 612 | for ($j = 0; $j <= $iIndex; $j++) |
591 | 613 | { |
592 | 614 | $imgLen = 0; |
593 | - if (!$this->image->load($this->data, $imgLen)) |
|
594 | - return false; |
|
615 | + if (!$this->image->load($this->data, $imgLen)) { |
|
616 | + return false; |
|
617 | + } |
|
595 | 618 | |
596 | 619 | $this->data = substr($this->data, $imgLen); |
597 | 620 | } |
@@ -602,8 +625,9 @@ discard block |
||
602 | 625 | |
603 | 626 | public function get_png_data($background_color) |
604 | 627 | { |
605 | - if (!$this->loaded) |
|
606 | - return false; |
|
628 | + if (!$this->loaded) { |
|
629 | + return false; |
|
630 | + } |
|
607 | 631 | |
608 | 632 | // Prepare the color table. |
609 | 633 | if ($this->image->m_gih->m_bLocalClr) |
@@ -611,25 +635,26 @@ discard block |
||
611 | 635 | $colors = $this->image->m_gih->m_nTableSize; |
612 | 636 | $pal = $this->image->m_gih->m_colorTable->toString(); |
613 | 637 | |
614 | - if ($background_color != -1) |
|
615 | - $background_color = $this->image->m_gih->m_colorTable->colorIndex($background_color); |
|
616 | - } |
|
617 | - elseif ($this->header->m_bGlobalClr) |
|
638 | + if ($background_color != -1) { |
|
639 | + $background_color = $this->image->m_gih->m_colorTable->colorIndex($background_color); |
|
640 | + } |
|
641 | + } elseif ($this->header->m_bGlobalClr) |
|
618 | 642 | { |
619 | 643 | $colors = $this->header->m_nTableSize; |
620 | 644 | $pal = $this->header->m_colorTable->toString(); |
621 | 645 | |
622 | - if ($background_color != -1) |
|
623 | - $background_color = $this->header->m_colorTable->colorIndex($background_color); |
|
624 | - } |
|
625 | - else |
|
646 | + if ($background_color != -1) { |
|
647 | + $background_color = $this->header->m_colorTable->colorIndex($background_color); |
|
648 | + } |
|
649 | + } else |
|
626 | 650 | { |
627 | 651 | $colors = 0; |
628 | 652 | $background_color = -1; |
629 | 653 | } |
630 | 654 | |
631 | - if ($background_color == -1) |
|
632 | - $background_color = $this->header->m_nBgColor; |
|
655 | + if ($background_color == -1) { |
|
656 | + $background_color = $this->header->m_nBgColor; |
|
657 | + } |
|
633 | 658 | |
634 | 659 | $data = &$this->image->m_data; |
635 | 660 | $header = &$this->image->m_gih; |
@@ -645,11 +670,13 @@ discard block |
||
645 | 670 | for ($x = 0; $x < $this->header->m_nWidth; $x++, $i++) |
646 | 671 | { |
647 | 672 | // Is this in the proper range? If so, get the specific pixel data... |
648 | - if ($x >= $header->m_nLeft && $y >= $header->m_nTop && $x < ($header->m_nLeft + $header->m_nWidth) && $y < ($header->m_nTop + $header->m_nHeight)) |
|
649 | - $bmp .= $data{$i}; |
|
673 | + if ($x >= $header->m_nLeft && $y >= $header->m_nTop && $x < ($header->m_nLeft + $header->m_nWidth) && $y < ($header->m_nTop + $header->m_nHeight)) { |
|
674 | + $bmp .= $data{$i}; |
|
675 | + } |
|
650 | 676 | // Otherwise, this is background... |
651 | - else |
|
652 | - $bmp .= chr($background_color); |
|
677 | + else { |
|
678 | + $bmp .= chr($background_color); |
|
679 | + } |
|
653 | 680 | } |
654 | 681 | } |
655 | 682 | |
@@ -678,8 +705,9 @@ discard block |
||
678 | 705 | $tmp = 'tRNS'; |
679 | 706 | |
680 | 707 | // Stick each color on - full transparency or none. |
681 | - for ($i = 0; $i < $colors; $i++) |
|
682 | - $tmp .= $i == $this->image->m_nTrans ? "\x00" : "\xFF"; |
|
708 | + for ($i = 0; $i < $colors; $i++) { |
|
709 | + $tmp .= $i == $this->image->m_nTrans ? "\x00" : "\xFF"; |
|
710 | + } |
|
683 | 711 | |
684 | 712 | $out .= $tmp . pack('N', smf_crc32($tmp)); |
685 | 713 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Entry point for the moderation center. |
@@ -26,8 +27,9 @@ discard block |
||
26 | 27 | global $txt, $context, $scripturl, $modSettings, $user_info, $sourcedir, $options; |
27 | 28 | |
28 | 29 | // Don't run this twice... and don't conflict with the admin bar. |
29 | - if (isset($context['admin_area'])) |
|
30 | - return; |
|
30 | + if (isset($context['admin_area'])) { |
|
31 | + return; |
|
32 | + } |
|
31 | 33 | |
32 | 34 | $context['can_moderate_boards'] = $user_info['mod_cache']['bq'] != '0=1'; |
33 | 35 | $context['can_moderate_groups'] = $user_info['mod_cache']['gq'] != '0=1'; |
@@ -35,8 +37,9 @@ discard block |
||
35 | 37 | $context['can_moderate_users'] = allowedTo('moderate_forum'); |
36 | 38 | |
37 | 39 | // Everyone using this area must be allowed here! |
38 | - if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) |
|
39 | - isAllowedTo('access_mod_center'); |
|
40 | + if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) { |
|
41 | + isAllowedTo('access_mod_center'); |
|
42 | + } |
|
40 | 43 | |
41 | 44 | // We're gonna want a menu of some kind. |
42 | 45 | require_once($sourcedir . '/Subs-Menu.php'); |
@@ -195,8 +198,9 @@ discard block |
||
195 | 198 | unset($moderation_areas); |
196 | 199 | |
197 | 200 | // We got something - didn't we? DIDN'T WE! |
198 | - if ($mod_include_data == false) |
|
199 | - fatal_lang_error('no_access', false); |
|
201 | + if ($mod_include_data == false) { |
|
202 | + fatal_lang_error('no_access', false); |
|
203 | + } |
|
200 | 204 | |
201 | 205 | // Retain the ID information in case required by a subaction. |
202 | 206 | $context['moderation_menu_id'] = $context['max_menu_id']; |
@@ -219,22 +223,25 @@ discard block |
||
219 | 223 | 'url' => $scripturl . '?action=moderate', |
220 | 224 | 'name' => $txt['moderation_center'], |
221 | 225 | ); |
222 | - if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') |
|
223 | - $context['linktree'][] = array( |
|
226 | + if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') { |
|
227 | + $context['linktree'][] = array( |
|
224 | 228 | 'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'], |
225 | 229 | 'name' => $mod_include_data['label'], |
226 | 230 | ); |
227 | - if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) |
|
228 | - $context['linktree'][] = array( |
|
231 | + } |
|
232 | + if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) { |
|
233 | + $context['linktree'][] = array( |
|
229 | 234 | 'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'] . ';sa=' . $mod_include_data['current_subsection'], |
230 | 235 | 'name' => $mod_include_data['subsections'][$mod_include_data['current_subsection']][0], |
231 | 236 | ); |
237 | + } |
|
232 | 238 | |
233 | 239 | // Now - finally - the bit before the encore - the main performance of course! |
234 | 240 | if (!$dont_call) |
235 | 241 | { |
236 | - if (isset($mod_include_data['file'])) |
|
237 | - require_once($sourcedir . '/' . $mod_include_data['file']); |
|
242 | + if (isset($mod_include_data['file'])) { |
|
243 | + require_once($sourcedir . '/' . $mod_include_data['file']); |
|
244 | + } |
|
238 | 245 | |
239 | 246 | call_helper($mod_include_data['function']); |
240 | 247 | } |
@@ -259,8 +266,9 @@ discard block |
||
259 | 266 | // Load what blocks the user actually can see... |
260 | 267 | $valid_blocks = array(); |
261 | 268 | |
262 | - if ($context['can_moderate_groups']) |
|
263 | - $valid_blocks['g'] = 'GroupRequests'; |
|
269 | + if ($context['can_moderate_groups']) { |
|
270 | + $valid_blocks['g'] = 'GroupRequests'; |
|
271 | + } |
|
264 | 272 | if ($context['can_moderate_boards']) |
265 | 273 | { |
266 | 274 | $valid_blocks['r'] = 'ReportedPosts'; |
@@ -269,8 +277,9 @@ discard block |
||
269 | 277 | if ($context['can_moderate_users']) |
270 | 278 | { |
271 | 279 | // This falls under the category of moderating users as well... |
272 | - if (!$context['can_moderate_boards']) |
|
273 | - $valid_blocks['w'] = 'WatchedUsers'; |
|
280 | + if (!$context['can_moderate_boards']) { |
|
281 | + $valid_blocks['w'] = 'WatchedUsers'; |
|
282 | + } |
|
274 | 283 | |
275 | 284 | $valid_blocks['rm'] = 'ReportedMembers'; |
276 | 285 | } |
@@ -281,8 +290,9 @@ discard block |
||
281 | 290 | foreach ($valid_blocks as $k => $block) |
282 | 291 | { |
283 | 292 | $block = 'ModBlock' . $block; |
284 | - if (function_exists($block)) |
|
285 | - $context['mod_blocks'][] = $block(); |
|
293 | + if (function_exists($block)) { |
|
294 | + $context['mod_blocks'][] = $block(); |
|
295 | + } |
|
286 | 296 | } |
287 | 297 | |
288 | 298 | $context['admin_prefs'] = !empty($options['admin_preferences']) ? smf_json_decode($options['admin_preferences'], true) : array(); |
@@ -309,8 +319,9 @@ discard block |
||
309 | 319 | ) |
310 | 320 | ); |
311 | 321 | $watched_users = array(); |
312 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
313 | - $watched_users[] = $row; |
|
322 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
323 | + $watched_users[] = $row; |
|
324 | + } |
|
314 | 325 | $smcFunc['db_free_result']($request); |
315 | 326 | |
316 | 327 | cache_put_data('recent_user_watches', $watched_users, 240); |
@@ -402,8 +413,9 @@ discard block |
||
402 | 413 | $note_owner = $smcFunc['db_num_rows']($get_owner); |
403 | 414 | $smcFunc['db_free_result']($get_owner); |
404 | 415 | |
405 | - if (empty($note_owner)) |
|
406 | - fatal_lang_error('mc_notes_delete_own', false); |
|
416 | + if (empty($note_owner)) { |
|
417 | + fatal_lang_error('mc_notes_delete_own', false); |
|
418 | + } |
|
407 | 419 | } |
408 | 420 | |
409 | 421 | // Lets delete it. |
@@ -460,12 +472,14 @@ discard block |
||
460 | 472 | ) |
461 | 473 | ); |
462 | 474 | $moderator_notes = array(); |
463 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
464 | - $moderator_notes[] = $row; |
|
475 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
476 | + $moderator_notes[] = $row; |
|
477 | + } |
|
465 | 478 | $smcFunc['db_free_result']($request); |
466 | 479 | |
467 | - if ($offset == 0) |
|
468 | - cache_put_data('moderator_notes', $moderator_notes, 240); |
|
480 | + if ($offset == 0) { |
|
481 | + cache_put_data('moderator_notes', $moderator_notes, 240); |
|
482 | + } |
|
469 | 483 | } |
470 | 484 | |
471 | 485 | // Lets construct a page index. |
@@ -504,8 +518,9 @@ discard block |
||
504 | 518 | // Got the info already? |
505 | 519 | $cachekey = md5(json_encode($user_info['mod_cache']['bq'])); |
506 | 520 | $context['reported_posts'] = array(); |
507 | - if ($user_info['mod_cache']['bq'] == '0=1') |
|
508 | - return 'reported_posts_block'; |
|
521 | + if ($user_info['mod_cache']['bq'] == '0=1') { |
|
522 | + return 'reported_posts_block'; |
|
523 | + } |
|
509 | 524 | |
510 | 525 | if (($reported_posts = cache_get_data('reported_posts_' . $cachekey, 90)) === null) |
511 | 526 | { |
@@ -529,8 +544,9 @@ discard block |
||
529 | 544 | ) |
530 | 545 | ); |
531 | 546 | $reported_posts = array(); |
532 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
533 | - $reported_posts[] = $row; |
|
547 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
548 | + $reported_posts[] = $row; |
|
549 | + } |
|
534 | 550 | $smcFunc['db_free_result']($request); |
535 | 551 | |
536 | 552 | // Cache it. |
@@ -568,8 +584,9 @@ discard block |
||
568 | 584 | |
569 | 585 | $context['group_requests'] = array(); |
570 | 586 | // Make sure they can even moderate someone! |
571 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
572 | - return 'group_requests_block'; |
|
587 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
588 | + return 'group_requests_block'; |
|
589 | + } |
|
573 | 590 | |
574 | 591 | // What requests are outstanding? |
575 | 592 | $request = $smcFunc['db_query']('', ' |
@@ -618,8 +635,9 @@ discard block |
||
618 | 635 | // Got the info already? |
619 | 636 | $cachekey = md5(json_encode((int) allowedTo('moderate_forum'))); |
620 | 637 | $context['reported_users'] = array(); |
621 | - if (!allowedTo('moderate_forum')) |
|
622 | - return 'reported_users_block'; |
|
638 | + if (!allowedTo('moderate_forum')) { |
|
639 | + return 'reported_users_block'; |
|
640 | + } |
|
623 | 641 | |
624 | 642 | if (($reported_users = cache_get_data('reported_users_' . $cachekey, 90)) === null) |
625 | 643 | { |
@@ -642,8 +660,9 @@ discard block |
||
642 | 660 | ) |
643 | 661 | ); |
644 | 662 | $reported_users = array(); |
645 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
646 | - $reported_users[] = $row; |
|
663 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
664 | + $reported_users[] = $row; |
|
665 | + } |
|
647 | 666 | $smcFunc['db_free_result']($request); |
648 | 667 | |
649 | 668 | // Cache it. |
@@ -691,8 +710,9 @@ discard block |
||
691 | 710 | isAllowedTo('moderate_forum'); |
692 | 711 | |
693 | 712 | // Are they wanting to view a particular report? |
694 | - if (!empty($_REQUEST['report'])) |
|
695 | - return MemberReport(); |
|
713 | + if (!empty($_REQUEST['report'])) { |
|
714 | + return MemberReport(); |
|
715 | + } |
|
696 | 716 | |
697 | 717 | // Set up the comforting bits... |
698 | 718 | $context['page_title'] = $txt['mc_reported_members']; |
@@ -746,15 +766,15 @@ discard block |
||
746 | 766 | // Time to update. |
747 | 767 | updateSettings(array('last_mod_report_action' => time())); |
748 | 768 | recountOpenReports('members'); |
749 | - } |
|
750 | - elseif (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
769 | + } elseif (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
751 | 770 | { |
752 | 771 | checkSession(); |
753 | 772 | |
754 | 773 | // All the ones to update... |
755 | 774 | $toClose = array(); |
756 | - foreach ($_POST['close'] as $rid) |
|
757 | - $toClose[] = (int) $rid; |
|
775 | + foreach ($_POST['close'] as $rid) { |
|
776 | + $toClose[] = (int) $rid; |
|
777 | + } |
|
758 | 778 | |
759 | 779 | if (!empty($toClose)) |
760 | 780 | { |
@@ -907,8 +927,9 @@ discard block |
||
907 | 927 | global $context, $user_info; |
908 | 928 | |
909 | 929 | // You need to be allowed to moderate groups... |
910 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
911 | - isAllowedTo('manage_membergroups'); |
|
930 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
931 | + isAllowedTo('manage_membergroups'); |
|
932 | + } |
|
912 | 933 | |
913 | 934 | // Load the group templates. |
914 | 935 | loadTemplate('ModerationCenter'); |
@@ -919,8 +940,9 @@ discard block |
||
919 | 940 | 'view' => 'ViewGroups', |
920 | 941 | ); |
921 | 942 | |
922 | - if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) |
|
923 | - $_GET['sa'] = 'view'; |
|
943 | + if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) { |
|
944 | + $_GET['sa'] = 'view'; |
|
945 | + } |
|
924 | 946 | $context['sub_action'] = $_GET['sa']; |
925 | 947 | |
926 | 948 | // Call the relevant function. |
@@ -950,8 +972,9 @@ discard block |
||
950 | 972 | 'id_notice' => $id_notice, |
951 | 973 | ) |
952 | 974 | ); |
953 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
954 | - fatal_lang_error('no_access', false); |
|
975 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
976 | + fatal_lang_error('no_access', false); |
|
977 | + } |
|
955 | 978 | list ($context['notice_body'], $context['notice_subject']) = $smcFunc['db_fetch_row']($request); |
956 | 979 | $smcFunc['db_free_result']($request); |
957 | 980 | |
@@ -988,18 +1011,20 @@ discard block |
||
988 | 1011 | checkSession(!is_array($_REQUEST['delete']) ? 'get' : 'post'); |
989 | 1012 | |
990 | 1013 | $toDelete = array(); |
991 | - if (!is_array($_REQUEST['delete'])) |
|
992 | - $toDelete[] = (int) $_REQUEST['delete']; |
|
993 | - else |
|
994 | - foreach ($_REQUEST['delete'] as $did) |
|
1014 | + if (!is_array($_REQUEST['delete'])) { |
|
1015 | + $toDelete[] = (int) $_REQUEST['delete']; |
|
1016 | + } else { |
|
1017 | + foreach ($_REQUEST['delete'] as $did) |
|
995 | 1018 | $toDelete[] = (int) $did; |
1019 | + } |
|
996 | 1020 | |
997 | 1021 | if (!empty($toDelete)) |
998 | 1022 | { |
999 | 1023 | require_once($sourcedir . '/RemoveTopic.php'); |
1000 | 1024 | // If they don't have permission we'll let it error - either way no chance of a security slip here! |
1001 | - foreach ($toDelete as $did) |
|
1002 | - removeMessage($did); |
|
1025 | + foreach ($toDelete as $did) { |
|
1026 | + removeMessage($did); |
|
1027 | + } |
|
1003 | 1028 | } |
1004 | 1029 | } |
1005 | 1030 | |
@@ -1008,20 +1033,21 @@ discard block |
||
1008 | 1033 | { |
1009 | 1034 | $approve_query = ''; |
1010 | 1035 | $delete_boards = array(); |
1011 | - } |
|
1012 | - else |
|
1036 | + } else |
|
1013 | 1037 | { |
1014 | 1038 | // Still obey permissions! |
1015 | 1039 | $approve_boards = boardsAllowedTo('approve_posts'); |
1016 | 1040 | $delete_boards = boardsAllowedTo('delete_any'); |
1017 | 1041 | |
1018 | - if ($approve_boards == array(0)) |
|
1019 | - $approve_query = ''; |
|
1020 | - elseif (!empty($approve_boards)) |
|
1021 | - $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
1042 | + if ($approve_boards == array(0)) { |
|
1043 | + $approve_query = ''; |
|
1044 | + } elseif (!empty($approve_boards)) { |
|
1045 | + $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
1046 | + } |
|
1022 | 1047 | // Nada, zip, etc... |
1023 | - else |
|
1024 | - $approve_query = ' AND 1=0'; |
|
1048 | + else { |
|
1049 | + $approve_query = ' AND 1=0'; |
|
1050 | + } |
|
1025 | 1051 | } |
1026 | 1052 | |
1027 | 1053 | require_once($sourcedir . '/Subs-List.php'); |
@@ -1120,10 +1146,11 @@ discard block |
||
1120 | 1146 | 'data' => array( |
1121 | 1147 | 'function' => function($member) use ($scripturl) |
1122 | 1148 | { |
1123 | - if ($member['last_post_id']) |
|
1124 | - return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
|
1125 | - else |
|
1126 | - return $member['last_post']; |
|
1149 | + if ($member['last_post_id']) { |
|
1150 | + return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
|
1151 | + } else { |
|
1152 | + return $member['last_post']; |
|
1153 | + } |
|
1127 | 1154 | }, |
1128 | 1155 | ), |
1129 | 1156 | ), |
@@ -1251,8 +1278,9 @@ discard block |
||
1251 | 1278 | ) |
1252 | 1279 | ); |
1253 | 1280 | $latest_posts = array(); |
1254 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1255 | - $latest_posts[$row['id_member']] = $row['last_post_id']; |
|
1281 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1282 | + $latest_posts[$row['id_member']] = $row['last_post_id']; |
|
1283 | + } |
|
1256 | 1284 | |
1257 | 1285 | if (!empty($latest_posts)) |
1258 | 1286 | { |
@@ -1443,15 +1471,17 @@ discard block |
||
1443 | 1471 | // Setup the direction stuff... |
1444 | 1472 | $context['order'] = isset($_REQUEST['sort']) && isset($sort_types[$_REQUEST['sort']]) ? $_REQUEST['sort'] : 'member'; |
1445 | 1473 | |
1446 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
1447 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
1448 | - else |
|
1449 | - $search_params_string = $search_params['string']; |
|
1474 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
1475 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
1476 | + } else { |
|
1477 | + $search_params_string = $search_params['string']; |
|
1478 | + } |
|
1450 | 1479 | |
1451 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
1452 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
1453 | - else |
|
1454 | - $search_params_type = $search_params['type']; |
|
1480 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
1481 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
1482 | + } else { |
|
1483 | + $search_params_type = $search_params['type']; |
|
1484 | + } |
|
1455 | 1485 | |
1456 | 1486 | $search_params_column = $searchTypes[$search_params_type]['sql']; |
1457 | 1487 | $search_params = array( |
@@ -1535,9 +1565,10 @@ discard block |
||
1535 | 1565 | ' . $rowData['reason'] . ' |
1536 | 1566 | </div>'; |
1537 | 1567 | |
1538 | - if (!empty($rowData['id_notice'])) |
|
1539 | - $output .= ' |
|
1568 | + if (!empty($rowData['id_notice'])) { |
|
1569 | + $output .= ' |
|
1540 | 1570 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $rowData['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" class="new_win" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a>'; |
1571 | + } |
|
1541 | 1572 | return $output; |
1542 | 1573 | }, |
1543 | 1574 | ), |
@@ -1655,9 +1686,9 @@ discard block |
||
1655 | 1686 | global $smcFunc, $modSettings, $context, $txt, $scripturl, $sourcedir, $user_info; |
1656 | 1687 | |
1657 | 1688 | // Submitting a new one? |
1658 | - if (isset($_POST['add'])) |
|
1659 | - return ModifyWarningTemplate(); |
|
1660 | - elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) |
|
1689 | + if (isset($_POST['add'])) { |
|
1690 | + return ModifyWarningTemplate(); |
|
1691 | + } elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) |
|
1661 | 1692 | { |
1662 | 1693 | checkSession(); |
1663 | 1694 | validateToken('mod-wt'); |
@@ -1676,8 +1707,9 @@ discard block |
||
1676 | 1707 | 'current_member' => $user_info['id'], |
1677 | 1708 | ) |
1678 | 1709 | ); |
1679 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1680 | - logAction('delete_warn_template', array('template' => $row['recipient_name'])); |
|
1710 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1711 | + logAction('delete_warn_template', array('template' => $row['recipient_name'])); |
|
1712 | + } |
|
1681 | 1713 | $smcFunc['db_free_result']($request); |
1682 | 1714 | |
1683 | 1715 | // Do the deletes. |
@@ -1968,16 +2000,18 @@ discard block |
||
1968 | 2000 | ); |
1969 | 2001 | |
1970 | 2002 | // If it wasn't visible and now is they've effectively added it. |
1971 | - if ($context['template_data']['personal'] && !$recipient_id) |
|
1972 | - logAction('add_warn_template', array('template' => $_POST['template_title'])); |
|
2003 | + if ($context['template_data']['personal'] && !$recipient_id) { |
|
2004 | + logAction('add_warn_template', array('template' => $_POST['template_title'])); |
|
2005 | + } |
|
1973 | 2006 | // Conversely if they made it personal it's a delete. |
1974 | - elseif (!$context['template_data']['personal'] && $recipient_id) |
|
1975 | - logAction('delete_warn_template', array('template' => $_POST['template_title'])); |
|
2007 | + elseif (!$context['template_data']['personal'] && $recipient_id) { |
|
2008 | + logAction('delete_warn_template', array('template' => $_POST['template_title'])); |
|
2009 | + } |
|
1976 | 2010 | // Otherwise just an edit. |
1977 | - else |
|
1978 | - logAction('modify_warn_template', array('template' => $_POST['template_title'])); |
|
1979 | - } |
|
1980 | - else |
|
2011 | + else { |
|
2012 | + logAction('modify_warn_template', array('template' => $_POST['template_title'])); |
|
2013 | + } |
|
2014 | + } else |
|
1981 | 2015 | { |
1982 | 2016 | $smcFunc['db_insert']('', |
1983 | 2017 | '{db_prefix}log_comments', |
@@ -1997,17 +2031,18 @@ discard block |
||
1997 | 2031 | |
1998 | 2032 | // Get out of town... |
1999 | 2033 | redirectexit('action=moderate;area=warnings;sa=templates'); |
2000 | - } |
|
2001 | - else |
|
2034 | + } else |
|
2002 | 2035 | { |
2003 | 2036 | $context['warning_errors'] = array(); |
2004 | 2037 | $context['template_data']['title'] = !empty($_POST['template_title']) ? $_POST['template_title'] : ''; |
2005 | 2038 | $context['template_data']['body'] = !empty($_POST['template_body']) ? $_POST['template_body'] : $txt['mc_warning_template_body_default']; |
2006 | 2039 | $context['template_data']['personal'] = !empty($_POST['make_personal']); |
2007 | - if (empty($_POST['template_title'])) |
|
2008 | - $context['warning_errors'][] = $txt['mc_warning_template_error_no_title']; |
|
2009 | - if (empty($_POST['template_body'])) |
|
2010 | - $context['warning_errors'][] = $txt['mc_warning_template_error_no_body']; |
|
2040 | + if (empty($_POST['template_title'])) { |
|
2041 | + $context['warning_errors'][] = $txt['mc_warning_template_error_no_title']; |
|
2042 | + } |
|
2043 | + if (empty($_POST['template_body'])) { |
|
2044 | + $context['warning_errors'][] = $txt['mc_warning_template_error_no_body']; |
|
2045 | + } |
|
2011 | 2046 | } |
2012 | 2047 | } |
2013 | 2048 | |
@@ -2054,8 +2089,9 @@ discard block |
||
2054 | 2089 | // Now check other options! |
2055 | 2090 | $pref_binary = 0; |
2056 | 2091 | |
2057 | - if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) |
|
2058 | - $pref_binary |= 4; |
|
2092 | + if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) { |
|
2093 | + $pref_binary |= 4; |
|
2094 | + } |
|
2059 | 2095 | |
2060 | 2096 | // Put it all together. |
2061 | 2097 | $mod_prefs = '0||' . $pref_binary; |
@@ -2079,9 +2115,10 @@ discard block |
||
2079 | 2115 | unset($_SESSION['moderate_time']); |
2080 | 2116 | |
2081 | 2117 | // Clean any moderator tokens as well. |
2082 | - foreach ($_SESSION['token'] as $key => $token) |
|
2083 | - if (strpos($key, '-mod') !== false) |
|
2118 | + foreach ($_SESSION['token'] as $key => $token) { |
|
2119 | + if (strpos($key, '-mod') !== false) |
|
2084 | 2120 | unset($_SESSION['token'][$key]); |
2121 | + } |
|
2085 | 2122 | |
2086 | 2123 | redirectexit(); |
2087 | 2124 | } |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | ) |
785 | 785 | ); |
786 | 786 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
787 | - $error_ips[] = inet_dtop($row['ip']); |
|
787 | + $error_ips[] = inet_dtop($row['ip']); |
|
788 | 788 | $smcFunc['db_free_result']($request); |
789 | 789 | |
790 | 790 | return $error_ips; |
@@ -2168,9 +2168,9 @@ discard block |
||
2168 | 2168 | |
2169 | 2169 | if ($low == '255.255.255.255') return 'unknown'; |
2170 | 2170 | if ($low == $high) |
2171 | - return $low; |
|
2171 | + return $low; |
|
2172 | 2172 | else |
2173 | - return $low . '-' . $high; |
|
2173 | + return $low . '-' . $high; |
|
2174 | 2174 | } |
2175 | 2175 | |
2176 | 2176 | /** |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Ban center. The main entrance point for all ban center functions. |
@@ -120,10 +121,11 @@ discard block |
||
120 | 121 | } |
121 | 122 | |
122 | 123 | // Create a date string so we don't overload them with date info. |
123 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
124 | - $context['ban_time_format'] = $user_info['time_format']; |
|
125 | - else |
|
126 | - $context['ban_time_format'] = $matches[0]; |
|
124 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
125 | + $context['ban_time_format'] = $user_info['time_format']; |
|
126 | + } else { |
|
127 | + $context['ban_time_format'] = $matches[0]; |
|
128 | + } |
|
127 | 129 | |
128 | 130 | $listOptions = array( |
129 | 131 | 'id' => 'ban_list', |
@@ -201,16 +203,19 @@ discard block |
||
201 | 203 | 'function' => function($rowData) use ($txt) |
202 | 204 | { |
203 | 205 | // This ban never expires...whahaha. |
204 | - if ($rowData['expire_time'] === null) |
|
205 | - return $txt['never']; |
|
206 | + if ($rowData['expire_time'] === null) { |
|
207 | + return $txt['never']; |
|
208 | + } |
|
206 | 209 | |
207 | 210 | // This ban has already expired. |
208 | - elseif ($rowData['expire_time'] < time()) |
|
209 | - return sprintf('<span class="red">%1$s</span>', $txt['ban_expired']); |
|
211 | + elseif ($rowData['expire_time'] < time()) { |
|
212 | + return sprintf('<span class="red">%1$s</span>', $txt['ban_expired']); |
|
213 | + } |
|
210 | 214 | |
211 | 215 | // Still need to wait a few days for this ban to expire. |
212 | - else |
|
213 | - return sprintf('%1$d %2$s', ceil(($rowData['expire_time'] - time()) / (60 * 60 * 24)), $txt['ban_days']); |
|
216 | + else { |
|
217 | + return sprintf('%1$d %2$s', ceil(($rowData['expire_time'] - time()) / (60 * 60 * 24)), $txt['ban_days']); |
|
218 | + } |
|
214 | 219 | }, |
215 | 220 | ), |
216 | 221 | 'sort' => array( |
@@ -309,8 +314,9 @@ discard block |
||
309 | 314 | ) |
310 | 315 | ); |
311 | 316 | $bans = array(); |
312 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
313 | - $bans[] = $row; |
|
317 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
318 | + $bans[] = $row; |
|
319 | + } |
|
314 | 320 | |
315 | 321 | $smcFunc['db_free_result']($request); |
316 | 322 | |
@@ -352,8 +358,9 @@ discard block |
||
352 | 358 | { |
353 | 359 | global $txt, $modSettings, $context, $scripturl, $smcFunc, $sourcedir; |
354 | 360 | |
355 | - if ((isset($_POST['add_ban']) || isset($_POST['modify_ban']) || isset($_POST['remove_selection'])) && empty($context['ban_errors'])) |
|
356 | - BanEdit2(); |
|
361 | + if ((isset($_POST['add_ban']) || isset($_POST['modify_ban']) || isset($_POST['remove_selection'])) && empty($context['ban_errors'])) { |
|
362 | + BanEdit2(); |
|
363 | + } |
|
357 | 364 | |
358 | 365 | $ban_group_id = isset($context['ban']['id']) ? $context['ban']['id'] : (isset($_REQUEST['bg']) ? (int) $_REQUEST['bg'] : 0); |
359 | 366 | |
@@ -364,10 +371,10 @@ discard block |
||
364 | 371 | |
365 | 372 | if (!empty($context['ban_errors'])) |
366 | 373 | { |
367 | - foreach ($context['ban_errors'] as $error) |
|
368 | - $context['error_messages'][$error] = $txt[$error]; |
|
369 | - } |
|
370 | - else |
|
374 | + foreach ($context['ban_errors'] as $error) { |
|
375 | + $context['error_messages'][$error] = $txt[$error]; |
|
376 | + } |
|
377 | + } else |
|
371 | 378 | { |
372 | 379 | // If we're editing an existing ban, get it from the database. |
373 | 380 | if (!empty($ban_group_id)) |
@@ -403,12 +410,13 @@ discard block |
||
403 | 410 | 'data' => array( |
404 | 411 | 'function' => function($ban_item) use ($txt) |
405 | 412 | { |
406 | - if (in_array($ban_item['type'], array('ip', 'hostname', 'email'))) |
|
407 | - return '<strong>' . $txt[$ban_item['type']] . ':</strong> ' . $ban_item[$ban_item['type']]; |
|
408 | - elseif ($ban_item['type'] == 'user') |
|
409 | - return '<strong>' . $txt['username'] . ':</strong> ' . $ban_item['user']['link']; |
|
410 | - else |
|
411 | - return '<strong>' . $txt['unknown'] . ':</strong> ' . $ban_item['no_bantype_selected']; |
|
413 | + if (in_array($ban_item['type'], array('ip', 'hostname', 'email'))) { |
|
414 | + return '<strong>' . $txt[$ban_item['type']] . ':</strong> ' . $ban_item[$ban_item['type']]; |
|
415 | + } elseif ($ban_item['type'] == 'user') { |
|
416 | + return '<strong>' . $txt['username'] . ':</strong> ' . $ban_item['user']['link']; |
|
417 | + } else { |
|
418 | + return '<strong>' . $txt['unknown'] . ':</strong> ' . $ban_item['no_bantype_selected']; |
|
419 | + } |
|
412 | 420 | }, |
413 | 421 | 'style' => 'text-align: left;', |
414 | 422 | ), |
@@ -546,8 +554,9 @@ discard block |
||
546 | 554 | $context['ban']['from_user'] = true; |
547 | 555 | |
548 | 556 | // Would be nice if we could also ban the hostname. |
549 | - if ((preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $context['ban_suggestions']['main_ip']) == 1 || isValidIPv6($context['ban_suggestions']['main_ip'])) && empty($modSettings['disableHostnameLookup'])) |
|
550 | - $context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']); |
|
557 | + if ((preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $context['ban_suggestions']['main_ip']) == 1 || isValidIPv6($context['ban_suggestions']['main_ip'])) && empty($modSettings['disableHostnameLookup'])) { |
|
558 | + $context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']); |
|
559 | + } |
|
551 | 560 | |
552 | 561 | $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
553 | 562 | } |
@@ -615,8 +624,9 @@ discard block |
||
615 | 624 | 'items_per_page' => $items_per_page, |
616 | 625 | ) |
617 | 626 | ); |
618 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
619 | - fatal_lang_error('ban_not_found', false); |
|
627 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
628 | + fatal_lang_error('ban_not_found', false); |
|
629 | + } |
|
620 | 630 | |
621 | 631 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
622 | 632 | { |
@@ -653,18 +663,15 @@ discard block |
||
653 | 663 | { |
654 | 664 | $ban_items[$row['id_ban']]['type'] = 'ip'; |
655 | 665 | $ban_items[$row['id_ban']]['ip'] = range2ip($row['ip_low'], $row['ip_high']); |
656 | - } |
|
657 | - elseif (!empty($row['hostname'])) |
|
666 | + } elseif (!empty($row['hostname'])) |
|
658 | 667 | { |
659 | 668 | $ban_items[$row['id_ban']]['type'] = 'hostname'; |
660 | 669 | $ban_items[$row['id_ban']]['hostname'] = str_replace('%', '*', $row['hostname']); |
661 | - } |
|
662 | - elseif (!empty($row['email_address'])) |
|
670 | + } elseif (!empty($row['email_address'])) |
|
663 | 671 | { |
664 | 672 | $ban_items[$row['id_ban']]['type'] = 'email'; |
665 | 673 | $ban_items[$row['id_ban']]['email'] = str_replace('%', '*', $row['email_address']); |
666 | - } |
|
667 | - elseif (!empty($row['id_member'])) |
|
674 | + } elseif (!empty($row['id_member'])) |
|
668 | 675 | { |
669 | 676 | $ban_items[$row['id_ban']]['type'] = 'user'; |
670 | 677 | $ban_items[$row['id_ban']]['user'] = array( |
@@ -730,9 +737,10 @@ discard block |
||
730 | 737 | $search_list += array('ips_in_messages' => 'banLoadAdditionalIPsMember', 'ips_in_errors' => 'banLoadAdditionalIPsError'); |
731 | 738 | |
732 | 739 | $return = array(); |
733 | - foreach ($search_list as $key => $callable) |
|
734 | - if (is_callable($callable)) |
|
740 | + foreach ($search_list as $key => $callable) { |
|
741 | + if (is_callable($callable)) |
|
735 | 742 | $return[$key] = call_user_func($callable, $member_id); |
743 | + } |
|
736 | 744 | |
737 | 745 | return $return; |
738 | 746 | } |
@@ -757,8 +765,9 @@ discard block |
||
757 | 765 | 'current_user' => $member_id, |
758 | 766 | ) |
759 | 767 | ); |
760 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
761 | - $message_ips[] = inet_dtop($row['poster_ip']); |
|
768 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
769 | + $message_ips[] = inet_dtop($row['poster_ip']); |
|
770 | + } |
|
762 | 771 | $smcFunc['db_free_result']($request); |
763 | 772 | |
764 | 773 | return $message_ips; |
@@ -783,8 +792,9 @@ discard block |
||
783 | 792 | 'current_user' => $member_id, |
784 | 793 | ) |
785 | 794 | ); |
786 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
787 | - $error_ips[] = inet_dtop($row['ip']); |
|
795 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
796 | + $error_ips[] = inet_dtop($row['ip']); |
|
797 | + } |
|
788 | 798 | $smcFunc['db_free_result']($request); |
789 | 799 | |
790 | 800 | return $error_ips; |
@@ -825,11 +835,13 @@ discard block |
||
825 | 835 | $ban_info['cannot']['login'] = !empty($ban_info['full_ban']) || empty($_POST['cannot_login']) ? 0 : 1; |
826 | 836 | |
827 | 837 | // Adding a new ban group |
828 | - if (empty($_REQUEST['bg'])) |
|
829 | - $ban_group_id = insertBanGroup($ban_info); |
|
838 | + if (empty($_REQUEST['bg'])) { |
|
839 | + $ban_group_id = insertBanGroup($ban_info); |
|
840 | + } |
|
830 | 841 | // Editing an existing ban group |
831 | - else |
|
832 | - $ban_group_id = updateBanGroup($ban_info); |
|
842 | + else { |
|
843 | + $ban_group_id = updateBanGroup($ban_info); |
|
844 | + } |
|
833 | 845 | |
834 | 846 | if (is_numeric($ban_group_id)) |
835 | 847 | { |
@@ -840,9 +852,10 @@ discard block |
||
840 | 852 | $context['ban'] = $ban_info; |
841 | 853 | } |
842 | 854 | |
843 | - if (isset($_POST['ban_suggestions'])) |
|
844 | - // @TODO: is $_REQUEST['bi'] ever set? |
|
855 | + if (isset($_POST['ban_suggestions'])) { |
|
856 | + // @TODO: is $_REQUEST['bi'] ever set? |
|
845 | 857 | $saved_triggers = saveTriggers($_POST['ban_suggestions'], $ban_info['id'], isset($_REQUEST['u']) ? (int) $_REQUEST['u'] : 0, isset($_REQUEST['bi']) ? (int) $_REQUEST['bi'] : 0); |
858 | + } |
|
846 | 859 | |
847 | 860 | // Something went wrong somewhere... Oh well, let's go back. |
848 | 861 | if (!empty($context['ban_errors'])) |
@@ -852,8 +865,9 @@ discard block |
||
852 | 865 | $context['ban_suggestions'] = array_merge($context['ban_suggestions'], getMemberData((int) $_REQUEST['u'])); |
853 | 866 | |
854 | 867 | // Not strictly necessary, but it's nice |
855 | - if (!empty($context['ban_suggestions']['member']['id'])) |
|
856 | - $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
|
868 | + if (!empty($context['ban_suggestions']['member']['id'])) { |
|
869 | + $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
|
870 | + } |
|
857 | 871 | return BanEdit(); |
858 | 872 | } |
859 | 873 | $context['ban_suggestions']['saved_triggers'] = !empty($saved_triggers) ? $saved_triggers : array(); |
@@ -902,10 +916,11 @@ discard block |
||
902 | 916 | |
903 | 917 | foreach ($suggestions as $key => $value) |
904 | 918 | { |
905 | - if (is_array($value)) |
|
906 | - $triggers[$key] = $value; |
|
907 | - else |
|
908 | - $triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : ''; |
|
919 | + if (is_array($value)) { |
|
920 | + $triggers[$key] = $value; |
|
921 | + } else { |
|
922 | + $triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : ''; |
|
923 | + } |
|
909 | 924 | } |
910 | 925 | |
911 | 926 | $ban_triggers = validateTriggers($triggers); |
@@ -913,16 +928,18 @@ discard block |
||
913 | 928 | // Time to save! |
914 | 929 | if (!empty($ban_triggers['ban_triggers']) && empty($context['ban_errors'])) |
915 | 930 | { |
916 | - if (empty($ban_id)) |
|
917 | - addTriggers($ban_group, $ban_triggers['ban_triggers'], $ban_triggers['log_info']); |
|
918 | - else |
|
919 | - updateTriggers($ban_id, $ban_group, array_shift($ban_triggers['ban_triggers']), $ban_triggers['log_info']); |
|
931 | + if (empty($ban_id)) { |
|
932 | + addTriggers($ban_group, $ban_triggers['ban_triggers'], $ban_triggers['log_info']); |
|
933 | + } else { |
|
934 | + updateTriggers($ban_id, $ban_group, array_shift($ban_triggers['ban_triggers']), $ban_triggers['log_info']); |
|
935 | + } |
|
936 | + } |
|
937 | + if (!empty($context['ban_errors'])) { |
|
938 | + return $triggers; |
|
939 | + } else { |
|
940 | + return false; |
|
941 | + } |
|
920 | 942 | } |
921 | - if (!empty($context['ban_errors'])) |
|
922 | - return $triggers; |
|
923 | - else |
|
924 | - return false; |
|
925 | -} |
|
926 | 943 | |
927 | 944 | /** |
928 | 945 | * This function removes a bunch of triggers based on ids |
@@ -936,14 +953,17 @@ discard block |
||
936 | 953 | { |
937 | 954 | global $smcFunc, $scripturl; |
938 | 955 | |
939 | - if ($group_id !== false) |
|
940 | - $group_id = (int) $group_id; |
|
956 | + if ($group_id !== false) { |
|
957 | + $group_id = (int) $group_id; |
|
958 | + } |
|
941 | 959 | |
942 | - if (empty($group_id) && empty($items_ids)) |
|
943 | - return false; |
|
960 | + if (empty($group_id) && empty($items_ids)) { |
|
961 | + return false; |
|
962 | + } |
|
944 | 963 | |
945 | - if (!is_array($items_ids)) |
|
946 | - $items_ids = array($items_ids); |
|
964 | + if (!is_array($items_ids)) { |
|
965 | + $items_ids = array($items_ids); |
|
966 | + } |
|
947 | 967 | |
948 | 968 | $log_info = array(); |
949 | 969 | $ban_items = array(); |
@@ -981,8 +1001,7 @@ discard block |
||
981 | 1001 | 'bantype' => ($is_range ? 'ip_range' : 'main_ip'), |
982 | 1002 | 'value' => $ban_items[$row['id_ban']]['ip'], |
983 | 1003 | ); |
984 | - } |
|
985 | - elseif (!empty($row['hostname'])) |
|
1004 | + } elseif (!empty($row['hostname'])) |
|
986 | 1005 | { |
987 | 1006 | $ban_items[$row['id_ban']]['type'] = 'hostname'; |
988 | 1007 | $ban_items[$row['id_ban']]['hostname'] = str_replace('%', '*', $row['hostname']); |
@@ -990,8 +1009,7 @@ discard block |
||
990 | 1009 | 'bantype' => 'hostname', |
991 | 1010 | 'value' => $row['hostname'], |
992 | 1011 | ); |
993 | - } |
|
994 | - elseif (!empty($row['email_address'])) |
|
1012 | + } elseif (!empty($row['email_address'])) |
|
995 | 1013 | { |
996 | 1014 | $ban_items[$row['id_ban']]['type'] = 'email'; |
997 | 1015 | $ban_items[$row['id_ban']]['email'] = str_replace('%', '*', $row['email_address']); |
@@ -999,8 +1017,7 @@ discard block |
||
999 | 1017 | 'bantype' => 'email', |
1000 | 1018 | 'value' => $ban_items[$row['id_ban']]['email'], |
1001 | 1019 | ); |
1002 | - } |
|
1003 | - elseif (!empty($row['id_member'])) |
|
1020 | + } elseif (!empty($row['id_member'])) |
|
1004 | 1021 | { |
1005 | 1022 | $ban_items[$row['id_ban']]['type'] = 'user'; |
1006 | 1023 | $ban_items[$row['id_ban']]['user'] = array( |
@@ -1033,8 +1050,7 @@ discard block |
||
1033 | 1050 | 'ban_group' => $group_id, |
1034 | 1051 | ) |
1035 | 1052 | ); |
1036 | - } |
|
1037 | - elseif (!empty($items_ids)) |
|
1053 | + } elseif (!empty($items_ids)) |
|
1038 | 1054 | { |
1039 | 1055 | $smcFunc['db_query']('', ' |
1040 | 1056 | DELETE FROM {db_prefix}ban_items |
@@ -1059,13 +1075,15 @@ discard block |
||
1059 | 1075 | { |
1060 | 1076 | global $smcFunc; |
1061 | 1077 | |
1062 | - if (!is_array($group_ids)) |
|
1063 | - $group_ids = array($group_ids); |
|
1078 | + if (!is_array($group_ids)) { |
|
1079 | + $group_ids = array($group_ids); |
|
1080 | + } |
|
1064 | 1081 | |
1065 | 1082 | $group_ids = array_unique($group_ids); |
1066 | 1083 | |
1067 | - if (empty($group_ids)) |
|
1068 | - return false; |
|
1084 | + if (empty($group_ids)) { |
|
1085 | + return false; |
|
1086 | + } |
|
1069 | 1087 | |
1070 | 1088 | $smcFunc['db_query']('', ' |
1071 | 1089 | DELETE FROM {db_prefix}ban_groups |
@@ -1089,21 +1107,23 @@ discard block |
||
1089 | 1107 | { |
1090 | 1108 | global $smcFunc; |
1091 | 1109 | |
1092 | - if (empty($ids)) |
|
1093 | - $smcFunc['db_query']('truncate_table', ' |
|
1110 | + if (empty($ids)) { |
|
1111 | + $smcFunc['db_query']('truncate_table', ' |
|
1094 | 1112 | TRUNCATE {db_prefix}log_banned', |
1095 | 1113 | array( |
1096 | 1114 | ) |
1097 | 1115 | ); |
1098 | - else |
|
1116 | + } else |
|
1099 | 1117 | { |
1100 | - if (!is_array($ids)) |
|
1101 | - $ids = array($ids); |
|
1118 | + if (!is_array($ids)) { |
|
1119 | + $ids = array($ids); |
|
1120 | + } |
|
1102 | 1121 | |
1103 | 1122 | $ids = array_unique($ids); |
1104 | 1123 | |
1105 | - if (empty($ids)) |
|
1106 | - return false; |
|
1124 | + if (empty($ids)) { |
|
1125 | + return false; |
|
1126 | + } |
|
1107 | 1127 | |
1108 | 1128 | $smcFunc['db_query']('', ' |
1109 | 1129 | DELETE FROM {db_prefix}log_banned |
@@ -1129,8 +1149,9 @@ discard block |
||
1129 | 1149 | { |
1130 | 1150 | global $context, $smcFunc; |
1131 | 1151 | |
1132 | - if (empty($triggers)) |
|
1133 | - $context['ban_erros'][] = 'ban_empty_triggers'; |
|
1152 | + if (empty($triggers)) { |
|
1153 | + $context['ban_erros'][] = 'ban_empty_triggers'; |
|
1154 | + } |
|
1134 | 1155 | |
1135 | 1156 | $ban_triggers = array(); |
1136 | 1157 | $log_info = array(); |
@@ -1139,39 +1160,39 @@ discard block |
||
1139 | 1160 | { |
1140 | 1161 | if (!empty($value)) |
1141 | 1162 | { |
1142 | - if ($key == 'member') |
|
1143 | - continue; |
|
1163 | + if ($key == 'member') { |
|
1164 | + continue; |
|
1165 | + } |
|
1144 | 1166 | |
1145 | 1167 | if ($key == 'main_ip') |
1146 | 1168 | { |
1147 | 1169 | $value = trim($value); |
1148 | 1170 | $ip_parts = ip2range($value); |
1149 | - if (!checkExistingTriggerIP($ip_parts, $value)) |
|
1150 | - $context['ban_erros'][] = 'invalid_ip'; |
|
1151 | - else |
|
1171 | + if (!checkExistingTriggerIP($ip_parts, $value)) { |
|
1172 | + $context['ban_erros'][] = 'invalid_ip'; |
|
1173 | + } else |
|
1152 | 1174 | { |
1153 | 1175 | $ban_triggers['main_ip'] = array( |
1154 | 1176 | 'ip_low' => $ip_parts['low'], |
1155 | 1177 | 'ip_high' => $ip_parts['high'] |
1156 | 1178 | ); |
1157 | 1179 | } |
1158 | - } |
|
1159 | - elseif ($key == 'hostname') |
|
1180 | + } elseif ($key == 'hostname') |
|
1160 | 1181 | { |
1161 | - if (preg_match('/[^\w.\-*]/', $value) == 1) |
|
1162 | - $context['ban_erros'][] = 'invalid_hostname'; |
|
1163 | - else |
|
1182 | + if (preg_match('/[^\w.\-*]/', $value) == 1) { |
|
1183 | + $context['ban_erros'][] = 'invalid_hostname'; |
|
1184 | + } else |
|
1164 | 1185 | { |
1165 | 1186 | // Replace the * wildcard by a MySQL wildcard %. |
1166 | 1187 | $value = substr(str_replace('*', '%', $value), 0, 255); |
1167 | 1188 | |
1168 | 1189 | $ban_triggers['hostname']['hostname'] = $value; |
1169 | 1190 | } |
1170 | - } |
|
1171 | - elseif ($key == 'email') |
|
1191 | + } elseif ($key == 'email') |
|
1172 | 1192 | { |
1173 | - if (preg_match('/[^\w.\-\+*@]/', $value) == 1) |
|
1174 | - $context['ban_erros'][] = 'invalid_email'; |
|
1193 | + if (preg_match('/[^\w.\-\+*@]/', $value) == 1) { |
|
1194 | + $context['ban_erros'][] = 'invalid_email'; |
|
1195 | + } |
|
1175 | 1196 | |
1176 | 1197 | // Check the user is not banning an admin. |
1177 | 1198 | $request = $smcFunc['db_query']('', ' |
@@ -1185,15 +1206,15 @@ discard block |
||
1185 | 1206 | 'email' => $value, |
1186 | 1207 | ) |
1187 | 1208 | ); |
1188 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1189 | - $context['ban_erros'][] = 'no_ban_admin'; |
|
1209 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1210 | + $context['ban_erros'][] = 'no_ban_admin'; |
|
1211 | + } |
|
1190 | 1212 | $smcFunc['db_free_result']($request); |
1191 | 1213 | |
1192 | 1214 | $value = substr(strtolower(str_replace('*', '%', $value)), 0, 255); |
1193 | 1215 | |
1194 | 1216 | $ban_triggers['email']['email_address'] = $value; |
1195 | - } |
|
1196 | - elseif ($key == 'user') |
|
1217 | + } elseif ($key == 'user') |
|
1197 | 1218 | { |
1198 | 1219 | $user = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $smcFunc['htmlspecialchars']($value, ENT_QUOTES)); |
1199 | 1220 | |
@@ -1207,8 +1228,9 @@ discard block |
||
1207 | 1228 | 'username' => $user, |
1208 | 1229 | ) |
1209 | 1230 | ); |
1210 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1211 | - $context['ban_erros'][] = 'invalid_username'; |
|
1231 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1232 | + $context['ban_erros'][] = 'invalid_username'; |
|
1233 | + } |
|
1212 | 1234 | list ($value, $isAdmin) = $smcFunc['db_fetch_row']($request); |
1213 | 1235 | $smcFunc['db_free_result']($request); |
1214 | 1236 | |
@@ -1216,25 +1238,25 @@ discard block |
||
1216 | 1238 | { |
1217 | 1239 | unset($value); |
1218 | 1240 | $context['ban_erros'][] = 'no_ban_admin'; |
1241 | + } else { |
|
1242 | + $ban_triggers['user']['id_member'] = $value; |
|
1219 | 1243 | } |
1220 | - else |
|
1221 | - $ban_triggers['user']['id_member'] = $value; |
|
1222 | - } |
|
1223 | - elseif (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
1244 | + } elseif (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
1224 | 1245 | { |
1225 | 1246 | // Special case, those two are arrays themselves |
1226 | 1247 | $values = array_unique($value); |
1227 | 1248 | // Don't add the main IP again. |
1228 | - if (isset($triggers['main_ip'])) |
|
1229 | - $values = array_diff($values, array($triggers['main_ip'])); |
|
1249 | + if (isset($triggers['main_ip'])) { |
|
1250 | + $values = array_diff($values, array($triggers['main_ip'])); |
|
1251 | + } |
|
1230 | 1252 | unset($value); |
1231 | 1253 | foreach ($values as $val) |
1232 | 1254 | { |
1233 | 1255 | $val = trim($val); |
1234 | 1256 | $ip_parts = ip2range($val); |
1235 | - if (!checkExistingTriggerIP($ip_parts, $val)) |
|
1236 | - $context['ban_erros'][] = 'invalid_ip'; |
|
1237 | - else |
|
1257 | + if (!checkExistingTriggerIP($ip_parts, $val)) { |
|
1258 | + $context['ban_erros'][] = 'invalid_ip'; |
|
1259 | + } else |
|
1238 | 1260 | { |
1239 | 1261 | $ban_triggers[$key][] = array( |
1240 | 1262 | 'ip_low' => $ip_parts['low'], |
@@ -1247,15 +1269,16 @@ discard block |
||
1247 | 1269 | ); |
1248 | 1270 | } |
1249 | 1271 | } |
1272 | + } else { |
|
1273 | + $context['ban_erros'][] = 'no_bantype_selected'; |
|
1250 | 1274 | } |
1251 | - else |
|
1252 | - $context['ban_erros'][] = 'no_bantype_selected'; |
|
1253 | 1275 | |
1254 | - if (isset($value) && !is_array($value)) |
|
1255 | - $log_info[] = array( |
|
1276 | + if (isset($value) && !is_array($value)) { |
|
1277 | + $log_info[] = array( |
|
1256 | 1278 | 'value' => $value, |
1257 | 1279 | 'bantype' => $key, |
1258 | 1280 | ); |
1281 | + } |
|
1259 | 1282 | } |
1260 | 1283 | } |
1261 | 1284 | return array('ban_triggers' => $ban_triggers, 'log_info' => $log_info); |
@@ -1275,8 +1298,9 @@ discard block |
||
1275 | 1298 | { |
1276 | 1299 | global $smcFunc, $context; |
1277 | 1300 | |
1278 | - if (empty($group_id)) |
|
1279 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
1301 | + if (empty($group_id)) { |
|
1302 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
1303 | + } |
|
1280 | 1304 | |
1281 | 1305 | // Preset all values that are required. |
1282 | 1306 | $values = array( |
@@ -1301,18 +1325,21 @@ discard block |
||
1301 | 1325 | foreach ($triggers as $key => $trigger) |
1302 | 1326 | { |
1303 | 1327 | // Exceptions, exceptions, exceptions...always exceptions... :P |
1304 | - if (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
1305 | - foreach ($trigger as $real_trigger) |
|
1328 | + if (in_array($key, array('ips_in_messages', 'ips_in_errors'))) { |
|
1329 | + foreach ($trigger as $real_trigger) |
|
1306 | 1330 | $insertTriggers[] = array_merge($values, $real_trigger); |
1307 | - else |
|
1308 | - $insertTriggers[] = array_merge($values, $trigger); |
|
1331 | + } else { |
|
1332 | + $insertTriggers[] = array_merge($values, $trigger); |
|
1333 | + } |
|
1309 | 1334 | } |
1310 | 1335 | |
1311 | - if (empty($insertTriggers)) |
|
1312 | - $context['ban_errors'][] = 'ban_no_triggers'; |
|
1336 | + if (empty($insertTriggers)) { |
|
1337 | + $context['ban_errors'][] = 'ban_no_triggers'; |
|
1338 | + } |
|
1313 | 1339 | |
1314 | - if (!empty($context['ban_errors'])) |
|
1315 | - return false; |
|
1340 | + if (!empty($context['ban_errors'])) { |
|
1341 | + return false; |
|
1342 | + } |
|
1316 | 1343 | |
1317 | 1344 | $smcFunc['db_insert']('', |
1318 | 1345 | '{db_prefix}ban_items', |
@@ -1340,15 +1367,19 @@ discard block |
||
1340 | 1367 | { |
1341 | 1368 | global $smcFunc, $context; |
1342 | 1369 | |
1343 | - if (empty($ban_item)) |
|
1344 | - $context['ban_errors'][] = 'ban_ban_item_empty'; |
|
1345 | - if (empty($group_id)) |
|
1346 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
1347 | - if (empty($trigger)) |
|
1348 | - $context['ban_errors'][] = 'ban_no_triggers'; |
|
1370 | + if (empty($ban_item)) { |
|
1371 | + $context['ban_errors'][] = 'ban_ban_item_empty'; |
|
1372 | + } |
|
1373 | + if (empty($group_id)) { |
|
1374 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
1375 | + } |
|
1376 | + if (empty($trigger)) { |
|
1377 | + $context['ban_errors'][] = 'ban_no_triggers'; |
|
1378 | + } |
|
1349 | 1379 | |
1350 | - if (!empty($context['ban_errors'])) |
|
1351 | - return; |
|
1380 | + if (!empty($context['ban_errors'])) { |
|
1381 | + return; |
|
1382 | + } |
|
1352 | 1383 | |
1353 | 1384 | // Preset all values that are required. |
1354 | 1385 | $values = array( |
@@ -1389,8 +1420,9 @@ discard block |
||
1389 | 1420 | */ |
1390 | 1421 | function logTriggersUpdates($logs, $new = true, $removal = false) |
1391 | 1422 | { |
1392 | - if (empty($logs)) |
|
1393 | - return; |
|
1423 | + if (empty($logs)) { |
|
1424 | + return; |
|
1425 | + } |
|
1394 | 1426 | |
1395 | 1427 | $log_name_map = array( |
1396 | 1428 | 'main_ip' => 'ip_range', |
@@ -1401,14 +1433,15 @@ discard block |
||
1401 | 1433 | ); |
1402 | 1434 | |
1403 | 1435 | // Log the addion of the ban entries into the moderation log. |
1404 | - foreach ($logs as $log) |
|
1405 | - logAction('ban' . ($removal == true ? 'remove' : ''), array( |
|
1436 | + foreach ($logs as $log) { |
|
1437 | + logAction('ban' . ($removal == true ? 'remove' : ''), array( |
|
1406 | 1438 | $log_name_map[$log['bantype']] => $log['value'], |
1407 | 1439 | 'new' => empty($new) ? 0 : 1, |
1408 | 1440 | 'remove' => empty($removal) ? 0 : 1, |
1409 | 1441 | 'type' => $log['bantype'], |
1410 | 1442 | )); |
1411 | -} |
|
1443 | + } |
|
1444 | + } |
|
1412 | 1445 | |
1413 | 1446 | /** |
1414 | 1447 | * Updates an existing ban group |
@@ -1422,12 +1455,15 @@ discard block |
||
1422 | 1455 | { |
1423 | 1456 | global $smcFunc, $context; |
1424 | 1457 | |
1425 | - if (empty($ban_info['name'])) |
|
1426 | - $context['ban_errors'][] = 'ban_name_empty'; |
|
1427 | - if (empty($ban_info['id'])) |
|
1428 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
1429 | - if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) |
|
1430 | - $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
1458 | + if (empty($ban_info['name'])) { |
|
1459 | + $context['ban_errors'][] = 'ban_name_empty'; |
|
1460 | + } |
|
1461 | + if (empty($ban_info['id'])) { |
|
1462 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
1463 | + } |
|
1464 | + if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) { |
|
1465 | + $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
1466 | + } |
|
1431 | 1467 | |
1432 | 1468 | if (!empty($ban_info['id'])) |
1433 | 1469 | { |
@@ -1442,8 +1478,9 @@ discard block |
||
1442 | 1478 | ) |
1443 | 1479 | ); |
1444 | 1480 | |
1445 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1446 | - $context['ban_errors'][] = 'ban_not_found'; |
|
1481 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1482 | + $context['ban_errors'][] = 'ban_not_found'; |
|
1483 | + } |
|
1447 | 1484 | $smcFunc['db_free_result']($request); |
1448 | 1485 | } |
1449 | 1486 | |
@@ -1461,13 +1498,15 @@ discard block |
||
1461 | 1498 | 'new_ban_name' => $ban_info['name'], |
1462 | 1499 | ) |
1463 | 1500 | ); |
1464 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1465 | - $context['ban_errors'][] = 'ban_name_exists'; |
|
1501 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1502 | + $context['ban_errors'][] = 'ban_name_exists'; |
|
1503 | + } |
|
1466 | 1504 | $smcFunc['db_free_result']($request); |
1467 | 1505 | } |
1468 | 1506 | |
1469 | - if (!empty($context['ban_errors'])) |
|
1470 | - return $ban_info['id']; |
|
1507 | + if (!empty($context['ban_errors'])) { |
|
1508 | + return $ban_info['id']; |
|
1509 | + } |
|
1471 | 1510 | |
1472 | 1511 | $smcFunc['db_query']('', ' |
1473 | 1512 | UPDATE {db_prefix}ban_groups |
@@ -1511,10 +1550,12 @@ discard block |
||
1511 | 1550 | { |
1512 | 1551 | global $smcFunc, $context; |
1513 | 1552 | |
1514 | - if (empty($ban_info['name'])) |
|
1515 | - $context['ban_errors'][] = 'ban_name_empty'; |
|
1516 | - if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) |
|
1517 | - $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
1553 | + if (empty($ban_info['name'])) { |
|
1554 | + $context['ban_errors'][] = 'ban_name_empty'; |
|
1555 | + } |
|
1556 | + if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) { |
|
1557 | + $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
1558 | + } |
|
1518 | 1559 | |
1519 | 1560 | if (!empty($ban_info['name'])) |
1520 | 1561 | { |
@@ -1529,13 +1570,15 @@ discard block |
||
1529 | 1570 | ) |
1530 | 1571 | ); |
1531 | 1572 | |
1532 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
1533 | - $context['ban_errors'][] = 'ban_name_exists'; |
|
1573 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
1574 | + $context['ban_errors'][] = 'ban_name_exists'; |
|
1575 | + } |
|
1534 | 1576 | $smcFunc['db_free_result']($request); |
1535 | 1577 | } |
1536 | 1578 | |
1537 | - if (!empty($context['ban_errors'])) |
|
1538 | - return; |
|
1579 | + if (!empty($context['ban_errors'])) { |
|
1580 | + return; |
|
1581 | + } |
|
1539 | 1582 | |
1540 | 1583 | // Yes yes, we're ready to add now. |
1541 | 1584 | $smcFunc['db_insert']('', |
@@ -1552,8 +1595,9 @@ discard block |
||
1552 | 1595 | ); |
1553 | 1596 | $ban_info['id'] = $smcFunc['db_insert_id']('{db_prefix}ban_groups', 'id_ban_group'); |
1554 | 1597 | |
1555 | - if (empty($ban_info['id'])) |
|
1556 | - $context['ban_errors'][] = 'impossible_insert_new_bangroup'; |
|
1598 | + if (empty($ban_info['id'])) { |
|
1599 | + $context['ban_errors'][] = 'impossible_insert_new_bangroup'; |
|
1600 | + } |
|
1557 | 1601 | |
1558 | 1602 | return $ban_info['id']; |
1559 | 1603 | } |
@@ -1578,24 +1622,24 @@ discard block |
||
1578 | 1622 | $ban_group = isset($_REQUEST['bg']) ? (int) $_REQUEST['bg'] : 0; |
1579 | 1623 | $ban_id = isset($_REQUEST['bi']) ? (int) $_REQUEST['bi'] : 0; |
1580 | 1624 | |
1581 | - if (empty($ban_group)) |
|
1582 | - fatal_lang_error('ban_not_found', false); |
|
1625 | + if (empty($ban_group)) { |
|
1626 | + fatal_lang_error('ban_not_found', false); |
|
1627 | + } |
|
1583 | 1628 | |
1584 | 1629 | if (isset($_POST['add_new_trigger']) && !empty($_POST['ban_suggestions'])) |
1585 | 1630 | { |
1586 | 1631 | saveTriggers($_POST['ban_suggestions'], $ban_group, 0, $ban_id); |
1587 | 1632 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
1588 | - } |
|
1589 | - elseif (isset($_POST['edit_trigger']) && !empty($_POST['ban_suggestions'])) |
|
1633 | + } elseif (isset($_POST['edit_trigger']) && !empty($_POST['ban_suggestions'])) |
|
1590 | 1634 | { |
1591 | 1635 | // The first replaces the old one, the others are added new (simplification, otherwise it would require another query and some work...) |
1592 | 1636 | saveTriggers(array_shift($_POST['ban_suggestions']), $ban_group, 0, $ban_id); |
1593 | - if (!empty($_POST['ban_suggestions'])) |
|
1594 | - saveTriggers($_POST['ban_suggestions'], $ban_group); |
|
1637 | + if (!empty($_POST['ban_suggestions'])) { |
|
1638 | + saveTriggers($_POST['ban_suggestions'], $ban_group); |
|
1639 | + } |
|
1595 | 1640 | |
1596 | 1641 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
1597 | - } |
|
1598 | - elseif (isset($_POST['edit_trigger'])) |
|
1642 | + } elseif (isset($_POST['edit_trigger'])) |
|
1599 | 1643 | { |
1600 | 1644 | removeBanTriggers($ban_id); |
1601 | 1645 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
@@ -1626,8 +1670,7 @@ discard block |
||
1626 | 1670 | ), |
1627 | 1671 | 'is_new' => true, |
1628 | 1672 | ); |
1629 | - } |
|
1630 | - else |
|
1673 | + } else |
|
1631 | 1674 | { |
1632 | 1675 | $request = $smcFunc['db_query']('', ' |
1633 | 1676 | SELECT |
@@ -1644,8 +1687,9 @@ discard block |
||
1644 | 1687 | 'ban_group' => $ban_group, |
1645 | 1688 | ) |
1646 | 1689 | ); |
1647 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1648 | - fatal_lang_error('ban_not_found', false); |
|
1690 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1691 | + fatal_lang_error('ban_not_found', false); |
|
1692 | + } |
|
1649 | 1693 | $row = $smcFunc['db_fetch_assoc']($request); |
1650 | 1694 | $smcFunc['db_free_result']($request); |
1651 | 1695 | |
@@ -1694,8 +1738,9 @@ discard block |
||
1694 | 1738 | removeBanTriggers($_POST['remove']); |
1695 | 1739 | |
1696 | 1740 | // Rehabilitate some members. |
1697 | - if ($_REQUEST['entity'] == 'member') |
|
1698 | - updateBanMembers(); |
|
1741 | + if ($_REQUEST['entity'] == 'member') { |
|
1742 | + updateBanMembers(); |
|
1743 | + } |
|
1699 | 1744 | |
1700 | 1745 | // Make sure the ban cache is refreshed. |
1701 | 1746 | updateSettings(array('banLastUpdated' => time())); |
@@ -1808,8 +1853,7 @@ discard block |
||
1808 | 1853 | 'default' => 'bi.ip_low, bi.ip_high, bi.ip_low', |
1809 | 1854 | 'reverse' => 'bi.ip_low DESC, bi.ip_high DESC', |
1810 | 1855 | ); |
1811 | - } |
|
1812 | - elseif ($context['selected_entity'] === 'hostname') |
|
1856 | + } elseif ($context['selected_entity'] === 'hostname') |
|
1813 | 1857 | { |
1814 | 1858 | $listOptions['columns']['banned_entity']['data'] = array( |
1815 | 1859 | 'function' => function($rowData) use ($smcFunc) |
@@ -1821,8 +1865,7 @@ discard block |
||
1821 | 1865 | 'default' => 'bi.hostname', |
1822 | 1866 | 'reverse' => 'bi.hostname DESC', |
1823 | 1867 | ); |
1824 | - } |
|
1825 | - elseif ($context['selected_entity'] === 'email') |
|
1868 | + } elseif ($context['selected_entity'] === 'email') |
|
1826 | 1869 | { |
1827 | 1870 | $listOptions['columns']['banned_entity']['data'] = array( |
1828 | 1871 | 'function' => function($rowData) use ($smcFunc) |
@@ -1834,8 +1877,7 @@ discard block |
||
1834 | 1877 | 'default' => 'bi.email_address', |
1835 | 1878 | 'reverse' => 'bi.email_address DESC', |
1836 | 1879 | ); |
1837 | - } |
|
1838 | - elseif ($context['selected_entity'] === 'member') |
|
1880 | + } elseif ($context['selected_entity'] === 'member') |
|
1839 | 1881 | { |
1840 | 1882 | $listOptions['columns']['banned_entity']['data'] = array( |
1841 | 1883 | 'sprintf' => array( |
@@ -1899,8 +1941,9 @@ discard block |
||
1899 | 1941 | ) |
1900 | 1942 | ); |
1901 | 1943 | $ban_triggers = array(); |
1902 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1903 | - $ban_triggers[] = $row; |
|
1944 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1945 | + $ban_triggers[] = $row; |
|
1946 | + } |
|
1904 | 1947 | $smcFunc['db_free_result']($request); |
1905 | 1948 | |
1906 | 1949 | return $ban_triggers; |
@@ -1956,8 +1999,9 @@ discard block |
||
1956 | 1999 | validateToken('admin-bl'); |
1957 | 2000 | |
1958 | 2001 | // 'Delete all entries' button was pressed. |
1959 | - if (!empty($_POST['removeAll'])) |
|
1960 | - removeBanLogs(); |
|
2002 | + if (!empty($_POST['removeAll'])) { |
|
2003 | + removeBanLogs(); |
|
2004 | + } |
|
1961 | 2005 | // 'Delete selection' button was pressed. |
1962 | 2006 | else |
1963 | 2007 | { |
@@ -2166,12 +2210,15 @@ discard block |
||
2166 | 2210 | $low = inet_dtop($low); |
2167 | 2211 | $high = inet_dtop($high); |
2168 | 2212 | |
2169 | - if ($low == '255.255.255.255') return 'unknown'; |
|
2170 | - if ($low == $high) |
|
2171 | - return $low; |
|
2172 | - else |
|
2173 | - return $low . '-' . $high; |
|
2174 | -} |
|
2213 | + if ($low == '255.255.255.255') { |
|
2214 | + return 'unknown'; |
|
2215 | + } |
|
2216 | + if ($low == $high) { |
|
2217 | + return $low; |
|
2218 | + } else { |
|
2219 | + return $low . '-' . $high; |
|
2220 | + } |
|
2221 | + } |
|
2175 | 2222 | |
2176 | 2223 | /** |
2177 | 2224 | * Checks whether a given IP range already exists in the trigger list. |
@@ -2247,15 +2294,17 @@ discard block |
||
2247 | 2294 | $memberEmailWild = array(); |
2248 | 2295 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2249 | 2296 | { |
2250 | - if ($row['id_member']) |
|
2251 | - $memberIDs[$row['id_member']] = $row['id_member']; |
|
2297 | + if ($row['id_member']) { |
|
2298 | + $memberIDs[$row['id_member']] = $row['id_member']; |
|
2299 | + } |
|
2252 | 2300 | if ($row['email_address']) |
2253 | 2301 | { |
2254 | 2302 | // Does it have a wildcard - if so we can't do a IN on it. |
2255 | - if (strpos($row['email_address'], '%') !== false) |
|
2256 | - $memberEmailWild[$row['email_address']] = $row['email_address']; |
|
2257 | - else |
|
2258 | - $memberEmails[$row['email_address']] = $row['email_address']; |
|
2303 | + if (strpos($row['email_address'], '%') !== false) { |
|
2304 | + $memberEmailWild[$row['email_address']] = $row['email_address']; |
|
2305 | + } else { |
|
2306 | + $memberEmails[$row['email_address']] = $row['email_address']; |
|
2307 | + } |
|
2259 | 2308 | } |
2260 | 2309 | } |
2261 | 2310 | $smcFunc['db_free_result']($request); |
@@ -2306,14 +2355,15 @@ discard block |
||
2306 | 2355 | } |
2307 | 2356 | |
2308 | 2357 | // We welcome our new members in the realm of the banned. |
2309 | - if (!empty($newMembers)) |
|
2310 | - $smcFunc['db_query']('', ' |
|
2358 | + if (!empty($newMembers)) { |
|
2359 | + $smcFunc['db_query']('', ' |
|
2311 | 2360 | DELETE FROM {db_prefix}log_online |
2312 | 2361 | WHERE id_member IN ({array_int:new_banned_members})', |
2313 | 2362 | array( |
2314 | 2363 | 'new_banned_members' => $newMembers, |
2315 | 2364 | ) |
2316 | 2365 | ); |
2366 | + } |
|
2317 | 2367 | |
2318 | 2368 | // Find members that are wrongfully marked as banned. |
2319 | 2369 | $request = $smcFunc['db_query']('', ' |
@@ -2340,9 +2390,10 @@ discard block |
||
2340 | 2390 | } |
2341 | 2391 | $smcFunc['db_free_result']($request); |
2342 | 2392 | |
2343 | - if (!empty($updates)) |
|
2344 | - foreach ($updates as $newStatus => $members) |
|
2393 | + if (!empty($updates)) { |
|
2394 | + foreach ($updates as $newStatus => $members) |
|
2345 | 2395 | updateMemberData($members, array('is_activated' => $newStatus)); |
2396 | + } |
|
2346 | 2397 | |
2347 | 2398 | // Update the latest member and our total members as banning may change them. |
2348 | 2399 | updateStats('member'); |