@@ -899,13 +899,13 @@ |
||
| 899 | 899 | if ($start_char === 'C') |
| 900 | 900 | $limit_seek = $limit; |
| 901 | 901 | else |
| 902 | - $limit_seek = $limit + 1; |
|
| 902 | + $limit_seek = $limit + 1; |
|
| 903 | 903 | |
| 904 | 904 | $request = $smcFunc['db_query']('', ' |
| 905 | 905 | SELECT id_msg, id_member, approved |
| 906 | 906 | FROM {db_prefix}messages |
| 907 | 907 | WHERE id_topic = {int:current_topic} |
| 908 | - AND id_msg '. $page_operator . ' {int:page_id}'. (!$modSettings['postmod_active'] || $approve_posts ? '' : ' |
|
| 908 | + AND id_msg '. $page_operator . ' {int:page_id}' . (!$modSettings['postmod_active'] || $approve_posts ? '' : ' |
|
| 909 | 909 | AND (approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR id_member = {int:current_member}') . ')') . ' |
| 910 | 910 | ORDER BY id_msg ' . ($ascending_seek ? '' : 'DESC') . ($context['messages_per_page'] == -1 ? '' : ' |
| 911 | 911 | LIMIT {int:limit}'), |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * The central part of the board - topic display. |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | global $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']('', ' |
@@ -365,9 +370,10 @@ discard block |
||
| 365 | 370 | list ($sig_limits, $sig_bbc) = explode(':', $modSettings['signature_settings']); |
| 366 | 371 | $sig_limits = explode(',', $sig_limits); |
| 367 | 372 | |
| 368 | - if (!empty($sig_limits[5]) || !empty($sig_limits[6])) |
|
| 369 | - addInlineCss(' |
|
| 373 | + if (!empty($sig_limits[5]) || !empty($sig_limits[6])) { |
|
| 374 | + addInlineCss(' |
|
| 370 | 375 | .signature img { ' . (!empty($sig_limits[5]) ? 'max-width: ' . (int) $sig_limits[5] . 'px; ' : '') . (!empty($sig_limits[6]) ? 'max-height: ' . (int) $sig_limits[6] . 'px; ' : '') . '}'); |
| 376 | + } |
|
| 371 | 377 | } |
| 372 | 378 | |
| 373 | 379 | // Censor the title... |
@@ -405,21 +411,25 @@ discard block |
||
| 405 | 411 | ); |
| 406 | 412 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 407 | 413 | { |
| 408 | - if (empty($row['id_member'])) |
|
| 409 | - continue; |
|
| 414 | + if (empty($row['id_member'])) { |
|
| 415 | + continue; |
|
| 416 | + } |
|
| 410 | 417 | |
| 411 | - if (!empty($row['online_color'])) |
|
| 412 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 413 | - else |
|
| 414 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 418 | + if (!empty($row['online_color'])) { |
|
| 419 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 420 | + } else { |
|
| 421 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 422 | + } |
|
| 415 | 423 | |
| 416 | 424 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
| 417 | - if ($is_buddy) |
|
| 418 | - $link = '<strong>' . $link . '</strong>'; |
|
| 425 | + if ($is_buddy) { |
|
| 426 | + $link = '<strong>' . $link . '</strong>'; |
|
| 427 | + } |
|
| 419 | 428 | |
| 420 | 429 | // Add them both to the list and to the more detailed list. |
| 421 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
| 422 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 430 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
| 431 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 432 | + } |
|
| 423 | 433 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
| 424 | 434 | 'id' => $row['id_member'], |
| 425 | 435 | 'username' => $row['member_name'], |
@@ -431,8 +441,9 @@ discard block |
||
| 431 | 441 | 'hidden' => empty($row['show_online']), |
| 432 | 442 | ); |
| 433 | 443 | |
| 434 | - if (empty($row['show_online'])) |
|
| 435 | - $context['view_num_hidden']++; |
|
| 444 | + if (empty($row['show_online'])) { |
|
| 445 | + $context['view_num_hidden']++; |
|
| 446 | + } |
|
| 436 | 447 | } |
| 437 | 448 | |
| 438 | 449 | // The number of guests is equal to the rows minus the ones we actually used ;). |
@@ -446,11 +457,13 @@ discard block |
||
| 446 | 457 | |
| 447 | 458 | // If all is set, but not allowed... just unset it. |
| 448 | 459 | $can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages']; |
| 449 | - if (isset($_REQUEST['all']) && !$can_show_all) |
|
| 450 | - unset($_REQUEST['all']); |
|
| 460 | + if (isset($_REQUEST['all']) && !$can_show_all) { |
|
| 461 | + unset($_REQUEST['all']); |
|
| 462 | + } |
|
| 451 | 463 | // Otherwise, it must be allowed... so pretend start was -1. |
| 452 | - elseif (isset($_REQUEST['all'])) |
|
| 453 | - $_REQUEST['start'] = -1; |
|
| 464 | + elseif (isset($_REQUEST['all'])) { |
|
| 465 | + $_REQUEST['start'] = -1; |
|
| 466 | + } |
|
| 454 | 467 | |
| 455 | 468 | // Construct the page index, allowing for the .START method... |
| 456 | 469 | $context['page_index'] = constructPageIndex($scripturl . '?topic=' . $topic . '.%1$d', $_REQUEST['start'], $context['total_visible_posts'], $context['messages_per_page'], true); |
@@ -487,8 +500,9 @@ discard block |
||
| 487 | 500 | $_REQUEST['start'] = 0; |
| 488 | 501 | } |
| 489 | 502 | // They aren't using it, but the *option* is there, at least. |
| 490 | - else |
|
| 491 | - $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
| 503 | + else { |
|
| 504 | + $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
| 505 | + } |
|
| 492 | 506 | } |
| 493 | 507 | |
| 494 | 508 | // Build the link tree. |
@@ -504,14 +518,16 @@ discard block |
||
| 504 | 518 | if (!empty($board_info['moderators'])) |
| 505 | 519 | { |
| 506 | 520 | // Add a link for each moderator... |
| 507 | - foreach ($board_info['moderators'] as $mod) |
|
| 508 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 521 | + foreach ($board_info['moderators'] as $mod) { |
|
| 522 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 523 | + } |
|
| 509 | 524 | } |
| 510 | 525 | if (!empty($board_info['moderator_groups'])) |
| 511 | 526 | { |
| 512 | 527 | // Add a link for each moderator group as well... |
| 513 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
| 514 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 528 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
| 529 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 530 | + } |
|
| 515 | 531 | } |
| 516 | 532 | |
| 517 | 533 | if (!empty($context['link_moderators'])) |
@@ -542,9 +558,9 @@ discard block |
||
| 542 | 558 | // For quick reply we need a response prefix in the default forum language. |
| 543 | 559 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix', 600))) |
| 544 | 560 | { |
| 545 | - if ($language === $user_info['language']) |
|
| 546 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 547 | - else |
|
| 561 | + if ($language === $user_info['language']) { |
|
| 562 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 563 | + } else |
|
| 548 | 564 | { |
| 549 | 565 | loadLanguage('index', $language, false); |
| 550 | 566 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -576,8 +592,9 @@ discard block |
||
| 576 | 592 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
| 577 | 593 | |
| 578 | 594 | // Sanity check |
| 579 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
| 580 | - continue; |
|
| 595 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
| 596 | + continue; |
|
| 597 | + } |
|
| 581 | 598 | |
| 582 | 599 | $linked_calendar_event = array( |
| 583 | 600 | 'id' => $row['id_event'], |
@@ -626,8 +643,9 @@ discard block |
||
| 626 | 643 | } |
| 627 | 644 | $smcFunc['db_free_result']($request); |
| 628 | 645 | |
| 629 | - if (!empty($context['linked_calendar_events'])) |
|
| 630 | - $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
| 646 | + if (!empty($context['linked_calendar_events'])) { |
|
| 647 | + $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
| 648 | + } |
|
| 631 | 649 | } |
| 632 | 650 | |
| 633 | 651 | // Create the poll info if it exists. |
@@ -690,8 +708,9 @@ discard block |
||
| 690 | 708 | $smcFunc['db_free_result']($request); |
| 691 | 709 | |
| 692 | 710 | // Got we multi choice? |
| 693 | - if ($pollinfo['max_votes'] > 1) |
|
| 694 | - $realtotal = $pollinfo['total']; |
|
| 711 | + if ($pollinfo['max_votes'] > 1) { |
|
| 712 | + $realtotal = $pollinfo['total']; |
|
| 713 | + } |
|
| 695 | 714 | |
| 696 | 715 | // If this is a guest we need to do our best to work out if they have voted, and what they voted for. |
| 697 | 716 | if ($user_info['is_guest'] && $pollinfo['guest_vote'] && allowedTo('poll_vote')) |
@@ -704,20 +723,21 @@ discard block |
||
| 704 | 723 | foreach ($guestinfo as $i => $guestvoted) |
| 705 | 724 | { |
| 706 | 725 | $guestvoted = explode(',', $guestvoted); |
| 707 | - if ($guestvoted[0] == $context['topicinfo']['id_poll']) |
|
| 708 | - break; |
|
| 726 | + if ($guestvoted[0] == $context['topicinfo']['id_poll']) { |
|
| 727 | + break; |
|
| 728 | + } |
|
| 709 | 729 | } |
| 710 | 730 | // Has the poll been reset since guest voted? |
| 711 | 731 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
| 712 | 732 | { |
| 713 | 733 | // Remove the poll info from the cookie to allow guest to vote again |
| 714 | 734 | unset($guestinfo[$i]); |
| 715 | - if (!empty($guestinfo)) |
|
| 716 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 717 | - else |
|
| 718 | - unset($_COOKIE['guest_poll_vote']); |
|
| 719 | - } |
|
| 720 | - else |
|
| 735 | + if (!empty($guestinfo)) { |
|
| 736 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 737 | + } else { |
|
| 738 | + unset($_COOKIE['guest_poll_vote']); |
|
| 739 | + } |
|
| 740 | + } else |
|
| 721 | 741 | { |
| 722 | 742 | // What did they vote for? |
| 723 | 743 | unset($guestvoted[0], $guestvoted[1]); |
@@ -831,23 +851,29 @@ discard block |
||
| 831 | 851 | // Build the poll moderation button array. |
| 832 | 852 | $context['poll_buttons'] = array(); |
| 833 | 853 | |
| 834 | - if ($context['allow_return_vote']) |
|
| 835 | - $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 854 | + if ($context['allow_return_vote']) { |
|
| 855 | + $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 856 | + } |
|
| 836 | 857 | |
| 837 | - if ($context['show_view_results_button']) |
|
| 838 | - $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
| 858 | + if ($context['show_view_results_button']) { |
|
| 859 | + $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
| 860 | + } |
|
| 839 | 861 | |
| 840 | - if ($context['allow_change_vote']) |
|
| 841 | - $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']); |
|
| 862 | + if ($context['allow_change_vote']) { |
|
| 863 | + $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']); |
|
| 864 | + } |
|
| 842 | 865 | |
| 843 | - if ($context['allow_lock_poll']) |
|
| 844 | - $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']); |
|
| 866 | + if ($context['allow_lock_poll']) { |
|
| 867 | + $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']); |
|
| 868 | + } |
|
| 845 | 869 | |
| 846 | - if ($context['allow_edit_poll']) |
|
| 847 | - $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 870 | + if ($context['allow_edit_poll']) { |
|
| 871 | + $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 872 | + } |
|
| 848 | 873 | |
| 849 | - if ($context['can_remove_poll']) |
|
| 850 | - $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']); |
|
| 874 | + if ($context['can_remove_poll']) { |
|
| 875 | + $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']); |
|
| 876 | + } |
|
| 851 | 877 | |
| 852 | 878 | // Allow mods to add additional buttons here |
| 853 | 879 | call_integration_hook('integrate_poll_buttons'); |
@@ -883,9 +909,9 @@ discard block |
||
| 883 | 909 | { |
| 884 | 910 | $start_char = 'C'; |
| 885 | 911 | $page_id = $ascending ? $context['topicinfo']['id_first_msg'] : $context['topicinfo']['id_last_msg']; |
| 912 | + } else { |
|
| 913 | + $start_char = null; |
|
| 886 | 914 | } |
| 887 | - else |
|
| 888 | - $start_char = null; |
|
| 889 | 915 | |
| 890 | 916 | $limit = $context['messages_per_page']; |
| 891 | 917 | |
@@ -899,17 +925,17 @@ discard block |
||
| 899 | 925 | { |
| 900 | 926 | $ascending_seek = true; |
| 901 | 927 | $page_operator = $ascending ? '>=' : '<='; |
| 902 | - } |
|
| 903 | - else |
|
| 928 | + } else |
|
| 904 | 929 | { |
| 905 | 930 | $ascending_seek = false; |
| 906 | 931 | $page_operator = $ascending ? '<=' : '>='; |
| 907 | 932 | } |
| 908 | 933 | |
| 909 | - if ($start_char === 'C') |
|
| 910 | - $limit_seek = $limit; |
|
| 911 | - else |
|
| 912 | - $limit_seek = $limit + 1; |
|
| 934 | + if ($start_char === 'C') { |
|
| 935 | + $limit_seek = $limit; |
|
| 936 | + } else { |
|
| 937 | + $limit_seek = $limit + 1; |
|
| 938 | + } |
|
| 913 | 939 | |
| 914 | 940 | $request = $smcFunc['db_query']('', ' |
| 915 | 941 | SELECT id_msg, id_member, approved |
@@ -932,21 +958,23 @@ discard block |
||
| 932 | 958 | $found_msg = false; |
| 933 | 959 | |
| 934 | 960 | // Fallback |
| 935 | - if ($smcFunc['db_num_rows']($request) < 1) |
|
| 936 | - unset($start_char); |
|
| 937 | - else |
|
| 961 | + if ($smcFunc['db_num_rows']($request) < 1) { |
|
| 962 | + unset($start_char); |
|
| 963 | + } else |
|
| 938 | 964 | { |
| 939 | 965 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 940 | 966 | { |
| 941 | 967 | // Check if the start msg is in our result |
| 942 | - if ($row['id_msg'] == $page_id) |
|
| 943 | - $found_msg = true; |
|
| 968 | + if ($row['id_msg'] == $page_id) { |
|
| 969 | + $found_msg = true; |
|
| 970 | + } |
|
| 944 | 971 | |
| 945 | 972 | // Skip the the start msg if we not in mode C |
| 946 | 973 | if ($start_char === 'C' || $row['id_msg'] != $page_id) |
| 947 | 974 | { |
| 948 | - if (!empty($row['id_member'])) |
|
| 949 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
| 975 | + if (!empty($row['id_member'])) { |
|
| 976 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
| 977 | + } |
|
| 950 | 978 | |
| 951 | 979 | $messages[] = $row['id_msg']; |
| 952 | 980 | } |
@@ -962,8 +990,9 @@ discard block |
||
| 962 | 990 | } |
| 963 | 991 | |
| 964 | 992 | // Before Page bring in the right order |
| 965 | - if (!empty($start_char) && $start_char === 'L') |
|
| 966 | - krsort($messages); |
|
| 993 | + if (!empty($start_char) && $start_char === 'L') { |
|
| 994 | + krsort($messages); |
|
| 995 | + } |
|
| 967 | 996 | } |
| 968 | 997 | |
| 969 | 998 | // Jump to page |
@@ -998,14 +1027,16 @@ discard block |
||
| 998 | 1027 | |
| 999 | 1028 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1000 | 1029 | { |
| 1001 | - if (!empty($row['id_member'])) |
|
| 1002 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
| 1030 | + if (!empty($row['id_member'])) { |
|
| 1031 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
| 1032 | + } |
|
| 1003 | 1033 | $messages[] = $row['id_msg']; |
| 1004 | 1034 | } |
| 1005 | 1035 | |
| 1006 | 1036 | // Sort the messages into the correct display order |
| 1007 | - if (!$ascending) |
|
| 1008 | - sort($messages); |
|
| 1037 | + if (!$ascending) { |
|
| 1038 | + sort($messages); |
|
| 1039 | + } |
|
| 1009 | 1040 | } |
| 1010 | 1041 | |
| 1011 | 1042 | // Remember the paging data for next time |
@@ -1025,8 +1056,9 @@ discard block |
||
| 1025 | 1056 | if (!$user_info['is_guest'] && !empty($messages)) |
| 1026 | 1057 | { |
| 1027 | 1058 | $mark_at_msg = max($messages); |
| 1028 | - if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) |
|
| 1029 | - $mark_at_msg = $modSettings['maxMsgID']; |
|
| 1059 | + if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) { |
|
| 1060 | + $mark_at_msg = $modSettings['maxMsgID']; |
|
| 1061 | + } |
|
| 1030 | 1062 | if ($mark_at_msg >= $context['topicinfo']['new_from']) |
| 1031 | 1063 | { |
| 1032 | 1064 | $smcFunc['db_insert']($context['topicinfo']['new_from'] == 0 ? 'ignore' : 'replace', |
@@ -1058,8 +1090,9 @@ discard block |
||
| 1058 | 1090 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1059 | 1091 | { |
| 1060 | 1092 | // Find if this topic is marked for notification... |
| 1061 | - if (!empty($row['id_topic'])) |
|
| 1062 | - $context['is_marked_notify'] = true; |
|
| 1093 | + if (!empty($row['id_topic'])) { |
|
| 1094 | + $context['is_marked_notify'] = true; |
|
| 1095 | + } |
|
| 1063 | 1096 | |
| 1064 | 1097 | // Only do this once, but mark the notifications as "not sent yet" for next time. |
| 1065 | 1098 | if (!empty($row['sent']) && $do_once) |
@@ -1081,8 +1114,9 @@ discard block |
||
| 1081 | 1114 | } |
| 1082 | 1115 | |
| 1083 | 1116 | // Have we recently cached the number of new topics in this board, and it's still a lot? |
| 1084 | - if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) |
|
| 1085 | - $_SESSION['topicseen_cache'][$board]--; |
|
| 1117 | + if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) { |
|
| 1118 | + $_SESSION['topicseen_cache'][$board]--; |
|
| 1119 | + } |
|
| 1086 | 1120 | // Mark board as seen if this is the only new topic. |
| 1087 | 1121 | elseif (isset($_REQUEST['topicseen'])) |
| 1088 | 1122 | { |
@@ -1106,14 +1140,16 @@ discard block |
||
| 1106 | 1140 | $smcFunc['db_free_result']($request); |
| 1107 | 1141 | |
| 1108 | 1142 | // If there're no real new topics in this board, mark the board as seen. |
| 1109 | - if (empty($numNewTopics)) |
|
| 1110 | - $_REQUEST['boardseen'] = true; |
|
| 1111 | - else |
|
| 1112 | - $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
| 1143 | + if (empty($numNewTopics)) { |
|
| 1144 | + $_REQUEST['boardseen'] = true; |
|
| 1145 | + } else { |
|
| 1146 | + $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
| 1147 | + } |
|
| 1113 | 1148 | } |
| 1114 | 1149 | // Probably one less topic - maybe not, but even if we decrease this too fast it will only make us look more often. |
| 1115 | - elseif (isset($_SESSION['topicseen_cache'][$board])) |
|
| 1116 | - $_SESSION['topicseen_cache'][$board]--; |
|
| 1150 | + elseif (isset($_SESSION['topicseen_cache'][$board])) { |
|
| 1151 | + $_SESSION['topicseen_cache'][$board]--; |
|
| 1152 | + } |
|
| 1117 | 1153 | |
| 1118 | 1154 | // Mark board as seen if we came using last post link from BoardIndex. (or other places...) |
| 1119 | 1155 | if (isset($_REQUEST['boardseen'])) |
@@ -1170,23 +1206,26 @@ discard block |
||
| 1170 | 1206 | $temp = array(); |
| 1171 | 1207 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1172 | 1208 | { |
| 1173 | - if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) |
|
| 1174 | - continue; |
|
| 1209 | + if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) { |
|
| 1210 | + continue; |
|
| 1211 | + } |
|
| 1175 | 1212 | |
| 1176 | 1213 | $temp[$row['id_attach']] = $row; |
| 1177 | 1214 | $temp[$row['id_attach']]['topic'] = $topic; |
| 1178 | 1215 | $temp[$row['id_attach']]['board'] = $board; |
| 1179 | 1216 | |
| 1180 | - if (!isset($context['loaded_attachments'][$row['id_msg']])) |
|
| 1181 | - $context['loaded_attachments'][$row['id_msg']] = array(); |
|
| 1217 | + if (!isset($context['loaded_attachments'][$row['id_msg']])) { |
|
| 1218 | + $context['loaded_attachments'][$row['id_msg']] = array(); |
|
| 1219 | + } |
|
| 1182 | 1220 | } |
| 1183 | 1221 | $smcFunc['db_free_result']($request); |
| 1184 | 1222 | |
| 1185 | 1223 | // This is better than sorting it with the query... |
| 1186 | 1224 | ksort($temp); |
| 1187 | 1225 | |
| 1188 | - foreach ($temp as $row) |
|
| 1189 | - $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
| 1226 | + foreach ($temp as $row) { |
|
| 1227 | + $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
| 1228 | + } |
|
| 1190 | 1229 | } |
| 1191 | 1230 | |
| 1192 | 1231 | $msg_parameters = array( |
@@ -1213,21 +1252,23 @@ discard block |
||
| 1213 | 1252 | ); |
| 1214 | 1253 | |
| 1215 | 1254 | // And the likes |
| 1216 | - if (!empty($modSettings['enable_likes'])) |
|
| 1217 | - $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
| 1255 | + if (!empty($modSettings['enable_likes'])) { |
|
| 1256 | + $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
| 1257 | + } |
|
| 1218 | 1258 | |
| 1219 | 1259 | // Go to the last message if the given time is beyond the time of the last message. |
| 1220 | - if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) |
|
| 1221 | - $context['start_from'] = $context['topicinfo']['num_replies']; |
|
| 1260 | + if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) { |
|
| 1261 | + $context['start_from'] = $context['topicinfo']['num_replies']; |
|
| 1262 | + } |
|
| 1222 | 1263 | |
| 1223 | 1264 | // Since the anchor information is needed on the top of the page we load these variables beforehand. |
| 1224 | 1265 | $context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0]; |
| 1225 | - if (empty($options['view_newest_first'])) |
|
| 1226 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
| 1227 | - else |
|
| 1228 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
| 1229 | - } |
|
| 1230 | - else |
|
| 1266 | + if (empty($options['view_newest_first'])) { |
|
| 1267 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
| 1268 | + } else { |
|
| 1269 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
| 1270 | + } |
|
| 1271 | + } else |
|
| 1231 | 1272 | { |
| 1232 | 1273 | $messages_request = false; |
| 1233 | 1274 | $context['first_message'] = 0; |
@@ -1262,8 +1303,9 @@ discard block |
||
| 1262 | 1303 | 'can_restore_msg' => 'move_any', |
| 1263 | 1304 | 'can_like' => 'likes_like', |
| 1264 | 1305 | ); |
| 1265 | - foreach ($common_permissions as $contextual => $perm) |
|
| 1266 | - $context[$contextual] = allowedTo($perm); |
|
| 1306 | + foreach ($common_permissions as $contextual => $perm) { |
|
| 1307 | + $context[$contextual] = allowedTo($perm); |
|
| 1308 | + } |
|
| 1267 | 1309 | |
| 1268 | 1310 | // Permissions with _any/_own versions. $context[YYY] => ZZZ_any/_own. |
| 1269 | 1311 | $anyown_permissions = array( |
@@ -1276,8 +1318,9 @@ discard block |
||
| 1276 | 1318 | 'can_reply_unapproved' => 'post_unapproved_replies', |
| 1277 | 1319 | 'can_view_warning' => 'profile_warning', |
| 1278 | 1320 | ); |
| 1279 | - foreach ($anyown_permissions as $contextual => $perm) |
|
| 1280 | - $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
| 1321 | + foreach ($anyown_permissions as $contextual => $perm) { |
|
| 1322 | + $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
| 1323 | + } |
|
| 1281 | 1324 | |
| 1282 | 1325 | if (!$user_info['is_admin'] && $context['can_move'] && !$modSettings['topic_move_any']) |
| 1283 | 1326 | { |
@@ -1323,8 +1366,9 @@ discard block |
||
| 1323 | 1366 | // Check if the draft functions are enabled and that they have permission to use them (for quick reply.) |
| 1324 | 1367 | $context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply']; |
| 1325 | 1368 | $context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']); |
| 1326 | - if (!empty($context['drafts_save'])) |
|
| 1327 | - loadLanguage('Drafts'); |
|
| 1369 | + if (!empty($context['drafts_save'])) { |
|
| 1370 | + loadLanguage('Drafts'); |
|
| 1371 | + } |
|
| 1328 | 1372 | |
| 1329 | 1373 | // When was the last time this topic was replied to? Should we warn them about it? |
| 1330 | 1374 | if (!empty($modSettings['oldTopicDays']) && ($context['can_reply'] || $context['can_reply_unapproved']) && empty($context['topicinfo']['is_sticky'])) |
@@ -1385,26 +1429,31 @@ discard block |
||
| 1385 | 1429 | // Message icons - customized icons are off? |
| 1386 | 1430 | $context['icons'] = getMessageIcons($board); |
| 1387 | 1431 | |
| 1388 | - if (!empty($context['icons'])) |
|
| 1389 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1432 | + if (!empty($context['icons'])) { |
|
| 1433 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1434 | + } |
|
| 1390 | 1435 | |
| 1391 | 1436 | // Build the normal button array. |
| 1392 | 1437 | $context['normal_buttons'] = array(); |
| 1393 | 1438 | |
| 1394 | - if ($context['can_reply']) |
|
| 1395 | - $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); |
|
| 1439 | + if ($context['can_reply']) { |
|
| 1440 | + $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); |
|
| 1441 | + } |
|
| 1396 | 1442 | |
| 1397 | - if ($context['can_add_poll']) |
|
| 1398 | - $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 1443 | + if ($context['can_add_poll']) { |
|
| 1444 | + $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 1445 | + } |
|
| 1399 | 1446 | |
| 1400 | - if ($context['can_mark_unread']) |
|
| 1401 | - $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']); |
|
| 1447 | + if ($context['can_mark_unread']) { |
|
| 1448 | + $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']); |
|
| 1449 | + } |
|
| 1402 | 1450 | |
| 1403 | - if ($context['can_print']) |
|
| 1404 | - $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
| 1451 | + if ($context['can_print']) { |
|
| 1452 | + $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
| 1453 | + } |
|
| 1405 | 1454 | |
| 1406 | - if ($context['can_set_notify']) |
|
| 1407 | - $context['normal_buttons']['notify'] = array( |
|
| 1455 | + if ($context['can_set_notify']) { |
|
| 1456 | + $context['normal_buttons']['notify'] = array( |
|
| 1408 | 1457 | 'text' => 'notify_topic_' . $context['topic_notification_mode'], |
| 1409 | 1458 | 'sub_buttons' => array( |
| 1410 | 1459 | array( |
@@ -1426,38 +1475,47 @@ discard block |
||
| 1426 | 1475 | ), |
| 1427 | 1476 | ), |
| 1428 | 1477 | ); |
| 1478 | + } |
|
| 1429 | 1479 | |
| 1430 | 1480 | // Build the mod button array |
| 1431 | 1481 | $context['mod_buttons'] = array(); |
| 1432 | 1482 | |
| 1433 | - if ($context['can_move']) |
|
| 1434 | - $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'); |
|
| 1483 | + if ($context['can_move']) { |
|
| 1484 | + $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'); |
|
| 1485 | + } |
|
| 1435 | 1486 | |
| 1436 | - if ($context['can_delete']) |
|
| 1437 | - $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']); |
|
| 1487 | + if ($context['can_delete']) { |
|
| 1488 | + $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']); |
|
| 1489 | + } |
|
| 1438 | 1490 | |
| 1439 | - if ($context['can_lock']) |
|
| 1440 | - $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']); |
|
| 1491 | + if ($context['can_lock']) { |
|
| 1492 | + $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']); |
|
| 1493 | + } |
|
| 1441 | 1494 | |
| 1442 | - if ($context['can_sticky']) |
|
| 1443 | - $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']); |
|
| 1495 | + if ($context['can_sticky']) { |
|
| 1496 | + $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']); |
|
| 1497 | + } |
|
| 1444 | 1498 | |
| 1445 | - if ($context['can_merge']) |
|
| 1446 | - $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
| 1499 | + if ($context['can_merge']) { |
|
| 1500 | + $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
| 1501 | + } |
|
| 1447 | 1502 | |
| 1448 | - if ($context['calendar_post']) |
|
| 1449 | - $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'); |
|
| 1503 | + if ($context['calendar_post']) { |
|
| 1504 | + $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'); |
|
| 1505 | + } |
|
| 1450 | 1506 | |
| 1451 | 1507 | // Restore topic. eh? No monkey business. |
| 1452 | - if ($context['can_restore_topic']) |
|
| 1453 | - $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1508 | + if ($context['can_restore_topic']) { |
|
| 1509 | + $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1510 | + } |
|
| 1454 | 1511 | |
| 1455 | 1512 | // Show a message in case a recently posted message became unapproved. |
| 1456 | 1513 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
| 1457 | 1514 | |
| 1458 | 1515 | // Don't want to show this forever... |
| 1459 | - if ($context['becomesUnapproved']) |
|
| 1460 | - unset($_SESSION['becomesUnapproved']); |
|
| 1516 | + if ($context['becomesUnapproved']) { |
|
| 1517 | + unset($_SESSION['becomesUnapproved']); |
|
| 1518 | + } |
|
| 1461 | 1519 | |
| 1462 | 1520 | // Allow adding new mod buttons easily. |
| 1463 | 1521 | // Note: $context['normal_buttons'] and $context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used |
@@ -1466,12 +1524,14 @@ discard block |
||
| 1466 | 1524 | call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons'])); |
| 1467 | 1525 | |
| 1468 | 1526 | // Load the drafts js file |
| 1469 | - if ($context['drafts_autosave']) |
|
| 1470 | - loadJavaScriptFile('drafts.js', array('defer' => false, 'minimize' => true), 'smf_drafts'); |
|
| 1527 | + if ($context['drafts_autosave']) { |
|
| 1528 | + loadJavaScriptFile('drafts.js', array('defer' => false, 'minimize' => true), 'smf_drafts'); |
|
| 1529 | + } |
|
| 1471 | 1530 | |
| 1472 | 1531 | // Spellcheck |
| 1473 | - if ($context['show_spellchecking']) |
|
| 1474 | - loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck'); |
|
| 1532 | + if ($context['show_spellchecking']) { |
|
| 1533 | + loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck'); |
|
| 1534 | + } |
|
| 1475 | 1535 | |
| 1476 | 1536 | // topic.js |
| 1477 | 1537 | loadJavaScriptFile('topic.js', array('defer' => false, 'minimize' => true), 'smf_topic'); |
@@ -1505,16 +1565,19 @@ discard block |
||
| 1505 | 1565 | static $counter = null; |
| 1506 | 1566 | |
| 1507 | 1567 | // If the query returned false, bail. |
| 1508 | - if ($messages_request == false) |
|
| 1509 | - return false; |
|
| 1568 | + if ($messages_request == false) { |
|
| 1569 | + return false; |
|
| 1570 | + } |
|
| 1510 | 1571 | |
| 1511 | 1572 | // Remember which message this is. (ie. reply #83) |
| 1512 | - if ($counter === null || $reset) |
|
| 1513 | - $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
| 1573 | + if ($counter === null || $reset) { |
|
| 1574 | + $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
| 1575 | + } |
|
| 1514 | 1576 | |
| 1515 | 1577 | // Start from the beginning... |
| 1516 | - if ($reset) |
|
| 1517 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1578 | + if ($reset) { |
|
| 1579 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1580 | + } |
|
| 1518 | 1581 | |
| 1519 | 1582 | // Attempt to get the next message. |
| 1520 | 1583 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
@@ -1528,19 +1591,21 @@ discard block |
||
| 1528 | 1591 | if (empty($context['icon_sources'])) |
| 1529 | 1592 | { |
| 1530 | 1593 | $context['icon_sources'] = array(); |
| 1531 | - foreach ($context['stable_icons'] as $icon) |
|
| 1532 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 1594 | + foreach ($context['stable_icons'] as $icon) { |
|
| 1595 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 1596 | + } |
|
| 1533 | 1597 | } |
| 1534 | 1598 | |
| 1535 | 1599 | // Message Icon Management... check the images exist. |
| 1536 | 1600 | if (empty($modSettings['messageIconChecks_disable'])) |
| 1537 | 1601 | { |
| 1538 | 1602 | // If the current icon isn't known, then we need to do something... |
| 1539 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
| 1540 | - $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1603 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
| 1604 | + $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1605 | + } |
|
| 1606 | + } elseif (!isset($context['icon_sources'][$message['icon']])) { |
|
| 1607 | + $context['icon_sources'][$message['icon']] = 'images_url'; |
|
| 1541 | 1608 | } |
| 1542 | - elseif (!isset($context['icon_sources'][$message['icon']])) |
|
| 1543 | - $context['icon_sources'][$message['icon']] = 'images_url'; |
|
| 1544 | 1609 | |
| 1545 | 1610 | // If you're a lazy bum, you probably didn't give a subject... |
| 1546 | 1611 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -1565,8 +1630,7 @@ discard block |
||
| 1565 | 1630 | $memberContext[$message['id_member']]['email'] = $message['poster_email']; |
| 1566 | 1631 | $memberContext[$message['id_member']]['show_email'] = allowedTo('moderate_forum'); |
| 1567 | 1632 | $memberContext[$message['id_member']]['is_guest'] = true; |
| 1568 | - } |
|
| 1569 | - else |
|
| 1633 | + } else |
|
| 1570 | 1634 | { |
| 1571 | 1635 | // Define this here to make things a bit more readable |
| 1572 | 1636 | $can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own')); |
@@ -1589,8 +1653,9 @@ discard block |
||
| 1589 | 1653 | $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
| 1590 | 1654 | |
| 1591 | 1655 | // If it's in the recycle bin we need to override whatever icon we did have. |
| 1592 | - if (!empty($board_info['recycle'])) |
|
| 1593 | - $message['icon'] = 'recycled'; |
|
| 1656 | + if (!empty($board_info['recycle'])) { |
|
| 1657 | + $message['icon'] = 'recycled'; |
|
| 1658 | + } |
|
| 1594 | 1659 | |
| 1595 | 1660 | require_once($sourcedir . '/Subs-Attachments.php'); |
| 1596 | 1661 | |
@@ -1634,32 +1699,36 @@ discard block |
||
| 1634 | 1699 | } |
| 1635 | 1700 | |
| 1636 | 1701 | // Are likes enable? |
| 1637 | - if (!empty($modSettings['enable_likes'])) |
|
| 1638 | - $output['likes'] = array( |
|
| 1702 | + if (!empty($modSettings['enable_likes'])) { |
|
| 1703 | + $output['likes'] = array( |
|
| 1639 | 1704 | 'count' => $message['likes'], |
| 1640 | 1705 | 'you' => in_array($message['id_msg'], $context['my_likes']), |
| 1641 | 1706 | 'can_like' => !$context['user']['is_guest'] && $message['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
| 1642 | 1707 | ); |
| 1708 | + } |
|
| 1643 | 1709 | |
| 1644 | 1710 | // Is this user the message author? |
| 1645 | 1711 | $output['is_message_author'] = $message['id_member'] == $user_info['id']; |
| 1646 | - if (!empty($output['modified']['name'])) |
|
| 1647 | - $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
| 1712 | + if (!empty($output['modified']['name'])) { |
|
| 1713 | + $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
| 1714 | + } |
|
| 1648 | 1715 | |
| 1649 | 1716 | // Did they give a reason for editing? |
| 1650 | - if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) |
|
| 1651 | - $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
| 1717 | + if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) { |
|
| 1718 | + $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
| 1719 | + } |
|
| 1652 | 1720 | |
| 1653 | 1721 | // Any custom profile fields? |
| 1654 | - if (!empty($memberContext[$message['id_member']]['custom_fields'])) |
|
| 1655 | - foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
| 1722 | + if (!empty($memberContext[$message['id_member']]['custom_fields'])) { |
|
| 1723 | + foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
| 1656 | 1724 | $output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
| 1725 | + } |
|
| 1657 | 1726 | |
| 1658 | - if (empty($options['view_newest_first'])) |
|
| 1659 | - $counter++; |
|
| 1660 | - |
|
| 1661 | - else |
|
| 1662 | - $counter--; |
|
| 1727 | + if (empty($options['view_newest_first'])) { |
|
| 1728 | + $counter++; |
|
| 1729 | + } else { |
|
| 1730 | + $counter--; |
|
| 1731 | + } |
|
| 1663 | 1732 | |
| 1664 | 1733 | call_integration_hook('integrate_prepare_display_context', array(&$output, &$message, $counter)); |
| 1665 | 1734 | |
@@ -1685,8 +1754,9 @@ discard block |
||
| 1685 | 1754 | */ |
| 1686 | 1755 | function approved_attach_sort($a, $b) |
| 1687 | 1756 | { |
| 1688 | - if ($a['is_approved'] == $b['is_approved']) |
|
| 1689 | - return 0; |
|
| 1757 | + if ($a['is_approved'] == $b['is_approved']) { |
|
| 1758 | + return 0; |
|
| 1759 | + } |
|
| 1690 | 1760 | |
| 1691 | 1761 | return $a['is_approved'] > $b['is_approved'] ? -1 : 1; |
| 1692 | 1762 | } |
@@ -1703,16 +1773,19 @@ discard block |
||
| 1703 | 1773 | |
| 1704 | 1774 | require_once($sourcedir . '/RemoveTopic.php'); |
| 1705 | 1775 | |
| 1706 | - if (empty($_REQUEST['msgs'])) |
|
| 1707 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 1776 | + if (empty($_REQUEST['msgs'])) { |
|
| 1777 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 1778 | + } |
|
| 1708 | 1779 | |
| 1709 | 1780 | $messages = array(); |
| 1710 | - foreach ($_REQUEST['msgs'] as $dummy) |
|
| 1711 | - $messages[] = (int) $dummy; |
|
| 1781 | + foreach ($_REQUEST['msgs'] as $dummy) { |
|
| 1782 | + $messages[] = (int) $dummy; |
|
| 1783 | + } |
|
| 1712 | 1784 | |
| 1713 | 1785 | // We are restoring messages. We handle this in another place. |
| 1714 | - if (isset($_REQUEST['restore_selected'])) |
|
| 1715 | - redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1786 | + if (isset($_REQUEST['restore_selected'])) { |
|
| 1787 | + redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1788 | + } |
|
| 1716 | 1789 | if (isset($_REQUEST['split_selection'])) |
| 1717 | 1790 | { |
| 1718 | 1791 | $request = $smcFunc['db_query']('', ' |
@@ -1731,8 +1804,9 @@ discard block |
||
| 1731 | 1804 | } |
| 1732 | 1805 | |
| 1733 | 1806 | // Allowed to delete any message? |
| 1734 | - if (allowedTo('delete_any')) |
|
| 1735 | - $allowed_all = true; |
|
| 1807 | + if (allowedTo('delete_any')) { |
|
| 1808 | + $allowed_all = true; |
|
| 1809 | + } |
|
| 1736 | 1810 | // Allowed to delete replies to their messages? |
| 1737 | 1811 | elseif (allowedTo('delete_replies')) |
| 1738 | 1812 | { |
@@ -1749,13 +1823,14 @@ discard block |
||
| 1749 | 1823 | $smcFunc['db_free_result']($request); |
| 1750 | 1824 | |
| 1751 | 1825 | $allowed_all = $starter == $user_info['id']; |
| 1826 | + } else { |
|
| 1827 | + $allowed_all = false; |
|
| 1752 | 1828 | } |
| 1753 | - else |
|
| 1754 | - $allowed_all = false; |
|
| 1755 | 1829 | |
| 1756 | 1830 | // Make sure they're allowed to delete their own messages, if not any. |
| 1757 | - if (!$allowed_all) |
|
| 1758 | - isAllowedTo('delete_own'); |
|
| 1831 | + if (!$allowed_all) { |
|
| 1832 | + isAllowedTo('delete_own'); |
|
| 1833 | + } |
|
| 1759 | 1834 | |
| 1760 | 1835 | // Allowed to remove which messages? |
| 1761 | 1836 | $request = $smcFunc['db_query']('', ' |
@@ -1775,8 +1850,9 @@ discard block |
||
| 1775 | 1850 | $messages = array(); |
| 1776 | 1851 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1777 | 1852 | { |
| 1778 | - if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) |
|
| 1779 | - continue; |
|
| 1853 | + if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) { |
|
| 1854 | + continue; |
|
| 1855 | + } |
|
| 1780 | 1856 | |
| 1781 | 1857 | $messages[$row['id_msg']] = array($row['subject'], $row['id_member']); |
| 1782 | 1858 | } |
@@ -1799,17 +1875,20 @@ discard block |
||
| 1799 | 1875 | foreach ($messages as $message => $info) |
| 1800 | 1876 | { |
| 1801 | 1877 | // Just skip the first message - if it's not the last. |
| 1802 | - if ($message == $first_message && $message != $last_message) |
|
| 1803 | - continue; |
|
| 1878 | + if ($message == $first_message && $message != $last_message) { |
|
| 1879 | + continue; |
|
| 1880 | + } |
|
| 1804 | 1881 | // If the first message is going then don't bother going back to the topic as we're effectively deleting it. |
| 1805 | - elseif ($message == $first_message) |
|
| 1806 | - $topicGone = true; |
|
| 1882 | + elseif ($message == $first_message) { |
|
| 1883 | + $topicGone = true; |
|
| 1884 | + } |
|
| 1807 | 1885 | |
| 1808 | 1886 | removeMessage($message); |
| 1809 | 1887 | |
| 1810 | 1888 | // Log this moderation action ;). |
| 1811 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
| 1812 | - logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
| 1889 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
| 1890 | + logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
| 1891 | + } |
|
| 1813 | 1892 | } |
| 1814 | 1893 | |
| 1815 | 1894 | redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']); |
@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -23,21 +23,21 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return array The truncated array |
| 25 | 25 | */ |
| 26 | -function truncateArray($arr, $max_length=1900) |
|
| 26 | +function truncateArray($arr, $max_length = 1900) |
|
| 27 | 27 | { |
| 28 | 28 | $curr_length = 0; |
| 29 | 29 | foreach ($arr as $key => $value) |
| 30 | 30 | if (is_array($value)) |
| 31 | 31 | foreach ($value as $key2 => $value2) |
| 32 | - $curr_length += strlen ($value2); |
|
| 32 | + $curr_length += strlen($value2); |
|
| 33 | 33 | else |
| 34 | - $curr_length += strlen ($value); |
|
| 34 | + $curr_length += strlen($value); |
|
| 35 | 35 | if ($curr_length <= $max_length) |
| 36 | 36 | return $arr; |
| 37 | 37 | else |
| 38 | 38 | { |
| 39 | 39 | // Truncate each element's value to a reasonable length |
| 40 | - $param_max = floor($max_length/count($arr)); |
|
| 40 | + $param_max = floor($max_length / count($arr)); |
|
| 41 | 41 | foreach ($arr as $key => &$value) |
| 42 | 42 | if (is_array($value)) |
| 43 | 43 | foreach ($value as $key2 => &$value2) |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | if (filemtime($cachedir . '/db_last_error.php') === $last_db_error_change) |
| 208 | 208 | { |
| 209 | 209 | // Write the change |
| 210 | - $write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>'; |
|
| 210 | + $write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>'; |
|
| 211 | 211 | $written_bytes = file_put_contents($cachedir . '/db_last_error.php', $write_db_change, LOCK_EX); |
| 212 | 212 | |
| 213 | 213 | // survey says ... |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | ', $txt['debug_language_files'], count($context['debug']['language_files']), ': <em>', implode('</em>, <em>', $context['debug']['language_files']), '</em>.<br> |
| 281 | 281 | ', $txt['debug_stylesheets'], count($context['debug']['sheets']), ': <em>', implode('</em>, <em>', $context['debug']['sheets']), '</em>.<br> |
| 282 | 282 | ', $txt['debug_hooks'], empty($context['debug']['hooks']) ? 0 : count($context['debug']['hooks']) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_hooks\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_hooks" style="display: none;"><em>' . implode('</em>, <em>', $context['debug']['hooks']), '</em></span>)', '<br> |
| 283 | - ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
|
| 283 | + ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">' . $txt['debug_show'] . '</a><span id="debug_instances" style="display: none;"><em>' . implode('</em>, <em>', array_keys($context['debug']['instances'])) . '</em></span>)' . '<br>') : ''), ' |
|
| 284 | 284 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
| 285 | 285 | |
| 286 | 286 | if (function_exists('memory_get_peak_usage')) |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Truncate the GET array to a specified length |
@@ -26,24 +27,28 @@ discard block |
||
| 26 | 27 | function truncateArray($arr, $max_length=1900) |
| 27 | 28 | { |
| 28 | 29 | $curr_length = 0; |
| 29 | - foreach ($arr as $key => $value) |
|
| 30 | - if (is_array($value)) |
|
| 30 | + foreach ($arr as $key => $value) { |
|
| 31 | + if (is_array($value)) |
|
| 31 | 32 | foreach ($value as $key2 => $value2) |
| 32 | 33 | $curr_length += strlen ($value2); |
| 33 | - else |
|
| 34 | - $curr_length += strlen ($value); |
|
| 35 | - if ($curr_length <= $max_length) |
|
| 36 | - return $arr; |
|
| 37 | - else |
|
| 34 | + } |
|
| 35 | + else { |
|
| 36 | + $curr_length += strlen ($value); |
|
| 37 | + } |
|
| 38 | + if ($curr_length <= $max_length) { |
|
| 39 | + return $arr; |
|
| 40 | + } else |
|
| 38 | 41 | { |
| 39 | 42 | // Truncate each element's value to a reasonable length |
| 40 | 43 | $param_max = floor($max_length/count($arr)); |
| 41 | - foreach ($arr as $key => &$value) |
|
| 42 | - if (is_array($value)) |
|
| 44 | + foreach ($arr as $key => &$value) { |
|
| 45 | + if (is_array($value)) |
|
| 43 | 46 | foreach ($value as $key2 => &$value2) |
| 44 | 47 | $value2 = substr($value2, 0, $param_max - strlen($key) - 5); |
| 45 | - else |
|
| 46 | - $value = substr($value, 0, $param_max - strlen($key) - 5); |
|
| 48 | + } |
|
| 49 | + else { |
|
| 50 | + $value = substr($value, 0, $param_max - strlen($key) - 5); |
|
| 51 | + } |
|
| 47 | 52 | return $arr; |
| 48 | 53 | } |
| 49 | 54 | } |
@@ -65,8 +70,9 @@ discard block |
||
| 65 | 70 | // Don't update for every page - this isn't wholly accurate but who cares. |
| 66 | 71 | if ($topic) |
| 67 | 72 | { |
| 68 | - if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) |
|
| 69 | - $force = false; |
|
| 73 | + if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) { |
|
| 74 | + $force = false; |
|
| 75 | + } |
|
| 70 | 76 | $_SESSION['last_topic_id'] = $topic; |
| 71 | 77 | } |
| 72 | 78 | } |
@@ -79,22 +85,24 @@ discard block |
||
| 79 | 85 | } |
| 80 | 86 | |
| 81 | 87 | // Don't mark them as online more than every so often. |
| 82 | - if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) |
|
| 83 | - return; |
|
| 88 | + if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) { |
|
| 89 | + return; |
|
| 90 | + } |
|
| 84 | 91 | |
| 85 | 92 | if (!empty($modSettings['who_enabled'])) |
| 86 | 93 | { |
| 87 | 94 | $encoded_get = truncateArray($_GET) + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']); |
| 88 | 95 | |
| 89 | 96 | // In the case of a dlattach action, session_var may not be set. |
| 90 | - if (!isset($context['session_var'])) |
|
| 91 | - $context['session_var'] = $_SESSION['session_var']; |
|
| 97 | + if (!isset($context['session_var'])) { |
|
| 98 | + $context['session_var'] = $_SESSION['session_var']; |
|
| 99 | + } |
|
| 92 | 100 | |
| 93 | 101 | unset($encoded_get['sesc'], $encoded_get[$context['session_var']]); |
| 94 | 102 | $encoded_get = $smcFunc['json_encode']($encoded_get); |
| 103 | + } else { |
|
| 104 | + $encoded_get = ''; |
|
| 95 | 105 | } |
| 96 | - else |
|
| 97 | - $encoded_get = ''; |
|
| 98 | 106 | |
| 99 | 107 | // Guests use 0, members use their session ID. |
| 100 | 108 | $session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(); |
@@ -134,17 +142,18 @@ discard block |
||
| 134 | 142 | ); |
| 135 | 143 | |
| 136 | 144 | // Guess it got deleted. |
| 137 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 145 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 146 | + $_SESSION['log_time'] = 0; |
|
| 147 | + } |
|
| 148 | + } else { |
|
| 138 | 149 | $_SESSION['log_time'] = 0; |
| 139 | 150 | } |
| 140 | - else |
|
| 141 | - $_SESSION['log_time'] = 0; |
|
| 142 | 151 | |
| 143 | 152 | // Otherwise, we have to delete and insert. |
| 144 | 153 | if (empty($_SESSION['log_time'])) |
| 145 | 154 | { |
| 146 | - if ($do_delete || !empty($user_info['id'])) |
|
| 147 | - $smcFunc['db_query']('', ' |
|
| 155 | + if ($do_delete || !empty($user_info['id'])) { |
|
| 156 | + $smcFunc['db_query']('', ' |
|
| 148 | 157 | DELETE FROM {db_prefix}log_online |
| 149 | 158 | WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'), |
| 150 | 159 | array( |
@@ -152,6 +161,7 @@ discard block |
||
| 152 | 161 | 'log_time' => time() - $modSettings['lastActive'] * 60, |
| 153 | 162 | ) |
| 154 | 163 | ); |
| 164 | + } |
|
| 155 | 165 | |
| 156 | 166 | $smcFunc['db_insert']($do_delete ? 'ignore' : 'replace', |
| 157 | 167 | '{db_prefix}log_online', |
@@ -165,21 +175,24 @@ discard block |
||
| 165 | 175 | $_SESSION['log_time'] = time(); |
| 166 | 176 | |
| 167 | 177 | // Well, they are online now. |
| 168 | - if (empty($_SESSION['timeOnlineUpdated'])) |
|
| 169 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
| 178 | + if (empty($_SESSION['timeOnlineUpdated'])) { |
|
| 179 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
| 180 | + } |
|
| 170 | 181 | |
| 171 | 182 | // Set their login time, if not already done within the last minute. |
| 172 | 183 | if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa')))) |
| 173 | 184 | { |
| 174 | 185 | // Don't count longer than 15 minutes. |
| 175 | - if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) |
|
| 176 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
| 186 | + if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) { |
|
| 187 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
| 188 | + } |
|
| 177 | 189 | |
| 178 | 190 | $user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
| 179 | 191 | updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in'])); |
| 180 | 192 | |
| 181 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 182 | - cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
| 193 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 194 | + cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
| 195 | + } |
|
| 183 | 196 | |
| 184 | 197 | $user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
| 185 | 198 | $_SESSION['timeOnlineUpdated'] = time(); |
@@ -216,8 +229,7 @@ discard block |
||
| 216 | 229 | // Oops. maybe we have no more disk space left, or some other troubles, troubles... |
| 217 | 230 | // Copy the file back and run for your life! |
| 218 | 231 | @copy($cachedir . '/db_last_error_bak.php', $cachedir . '/db_last_error.php'); |
| 219 | - } |
|
| 220 | - else |
|
| 232 | + } else |
|
| 221 | 233 | { |
| 222 | 234 | @touch($boarddir . '/' . 'Settings.php'); |
| 223 | 235 | return true; |
@@ -237,22 +249,27 @@ discard block |
||
| 237 | 249 | global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt; |
| 238 | 250 | |
| 239 | 251 | // Add to Settings.php if you want to show the debugging information. |
| 240 | - if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) |
|
| 241 | - return; |
|
| 252 | + if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) { |
|
| 253 | + return; |
|
| 254 | + } |
|
| 242 | 255 | |
| 243 | - if (empty($_SESSION['view_queries'])) |
|
| 244 | - $_SESSION['view_queries'] = 0; |
|
| 245 | - if (empty($context['debug']['language_files'])) |
|
| 246 | - $context['debug']['language_files'] = array(); |
|
| 247 | - if (empty($context['debug']['sheets'])) |
|
| 248 | - $context['debug']['sheets'] = array(); |
|
| 256 | + if (empty($_SESSION['view_queries'])) { |
|
| 257 | + $_SESSION['view_queries'] = 0; |
|
| 258 | + } |
|
| 259 | + if (empty($context['debug']['language_files'])) { |
|
| 260 | + $context['debug']['language_files'] = array(); |
|
| 261 | + } |
|
| 262 | + if (empty($context['debug']['sheets'])) { |
|
| 263 | + $context['debug']['sheets'] = array(); |
|
| 264 | + } |
|
| 249 | 265 | |
| 250 | 266 | $files = get_included_files(); |
| 251 | 267 | $total_size = 0; |
| 252 | 268 | for ($i = 0, $n = count($files); $i < $n; $i++) |
| 253 | 269 | { |
| 254 | - if (file_exists($files[$i])) |
|
| 255 | - $total_size += filesize($files[$i]); |
|
| 270 | + if (file_exists($files[$i])) { |
|
| 271 | + $total_size += filesize($files[$i]); |
|
| 272 | + } |
|
| 256 | 273 | $files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)')); |
| 257 | 274 | } |
| 258 | 275 | |
@@ -261,8 +278,9 @@ discard block |
||
| 261 | 278 | { |
| 262 | 279 | foreach ($db_cache as $q => $query_data) |
| 263 | 280 | { |
| 264 | - if (!empty($query_data['w'])) |
|
| 265 | - $warnings += count($query_data['w']); |
|
| 281 | + if (!empty($query_data['w'])) { |
|
| 282 | + $warnings += count($query_data['w']); |
|
| 283 | + } |
|
| 266 | 284 | } |
| 267 | 285 | |
| 268 | 286 | $_SESSION['debug'] = &$db_cache; |
@@ -283,12 +301,14 @@ discard block |
||
| 283 | 301 | ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
| 284 | 302 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
| 285 | 303 | |
| 286 | - if (function_exists('memory_get_peak_usage')) |
|
| 287 | - echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
| 304 | + if (function_exists('memory_get_peak_usage')) { |
|
| 305 | + echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
| 306 | + } |
|
| 288 | 307 | |
| 289 | 308 | // What tokens are active? |
| 290 | - if (isset($_SESSION['token'])) |
|
| 291 | - echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
| 309 | + if (isset($_SESSION['token'])) { |
|
| 310 | + echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
| 311 | + } |
|
| 292 | 312 | |
| 293 | 313 | if (!empty($modSettings['cache_enable']) && !empty($cache_hits)) |
| 294 | 314 | { |
@@ -302,10 +322,12 @@ discard block |
||
| 302 | 322 | $total_t += $cache_hit['t']; |
| 303 | 323 | $total_s += $cache_hit['s']; |
| 304 | 324 | } |
| 305 | - if (!isset($cache_misses)) |
|
| 306 | - $cache_misses = array(); |
|
| 307 | - foreach ($cache_misses as $missed) |
|
| 308 | - $missed_entries[] = $missed['d'] . ' ' . $missed['k']; |
|
| 325 | + if (!isset($cache_misses)) { |
|
| 326 | + $cache_misses = array(); |
|
| 327 | + } |
|
| 328 | + foreach ($cache_misses as $missed) { |
|
| 329 | + $missed_entries[] = $missed['d'] . ' ' . $missed['k']; |
|
| 330 | + } |
|
| 309 | 331 | |
| 310 | 332 | echo ' |
| 311 | 333 | ', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br> |
@@ -316,38 +338,44 @@ discard block |
||
| 316 | 338 | <a href="', $scripturl, '?action=viewquery" target="_blank" rel="noopener">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br> |
| 317 | 339 | <br>'; |
| 318 | 340 | |
| 319 | - if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) |
|
| 320 | - foreach ($db_cache as $q => $query_data) |
|
| 341 | + if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) { |
|
| 342 | + foreach ($db_cache as $q => $query_data) |
|
| 321 | 343 | { |
| 322 | 344 | $is_select = strpos(trim($query_data['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($query_data['q'])) != 0; |
| 345 | + } |
|
| 323 | 346 | // Temporary tables created in earlier queries are not explainable. |
| 324 | 347 | if ($is_select) |
| 325 | 348 | { |
| 326 | - foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) |
|
| 327 | - if (strpos(trim($query_data['q']), $tmp) !== false) |
|
| 349 | + foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) { |
|
| 350 | + if (strpos(trim($query_data['q']), $tmp) !== false) |
|
| 328 | 351 | { |
| 329 | 352 | $is_select = false; |
| 353 | + } |
|
| 330 | 354 | break; |
| 331 | 355 | } |
| 332 | 356 | } |
| 333 | 357 | // But actual creation of the temporary tables are. |
| 334 | - elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($query_data['q'])) != 0) |
|
| 335 | - $is_select = true; |
|
| 358 | + elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($query_data['q'])) != 0) { |
|
| 359 | + $is_select = true; |
|
| 360 | + } |
|
| 336 | 361 | |
| 337 | 362 | // Make the filenames look a bit better. |
| 338 | - if (isset($query_data['f'])) |
|
| 339 | - $query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']); |
|
| 363 | + if (isset($query_data['f'])) { |
|
| 364 | + $query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']); |
|
| 365 | + } |
|
| 340 | 366 | |
| 341 | 367 | echo ' |
| 342 | 368 | <strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" rel="noopener" style="text-decoration: none;">' : '', nl2br(str_replace("\t", ' ', $smcFunc['htmlspecialchars'](ltrim($query_data['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br> |
| 343 | 369 | '; |
| 344 | - if (!empty($query_data['f']) && !empty($query_data['l'])) |
|
| 345 | - echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']); |
|
| 370 | + if (!empty($query_data['f']) && !empty($query_data['l'])) { |
|
| 371 | + echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']); |
|
| 372 | + } |
|
| 346 | 373 | |
| 347 | - if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) |
|
| 348 | - echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)) . '<br>'; |
|
| 349 | - elseif (isset($query_data['t'])) |
|
| 350 | - echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)) . '<br>'; |
|
| 374 | + if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) { |
|
| 375 | + echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)) . '<br>'; |
|
| 376 | + } elseif (isset($query_data['t'])) { |
|
| 377 | + echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)) . '<br>'; |
|
| 378 | + } |
|
| 351 | 379 | echo ' |
| 352 | 380 | <br>'; |
| 353 | 381 | } |
@@ -372,12 +400,14 @@ discard block |
||
| 372 | 400 | global $modSettings, $smcFunc; |
| 373 | 401 | static $cache_stats = array(); |
| 374 | 402 | |
| 375 | - if (empty($modSettings['trackStats'])) |
|
| 376 | - return false; |
|
| 377 | - if (!empty($stats)) |
|
| 378 | - return $cache_stats = array_merge($cache_stats, $stats); |
|
| 379 | - elseif (empty($cache_stats)) |
|
| 380 | - return false; |
|
| 403 | + if (empty($modSettings['trackStats'])) { |
|
| 404 | + return false; |
|
| 405 | + } |
|
| 406 | + if (!empty($stats)) { |
|
| 407 | + return $cache_stats = array_merge($cache_stats, $stats); |
|
| 408 | + } elseif (empty($cache_stats)) { |
|
| 409 | + return false; |
|
| 410 | + } |
|
| 381 | 411 | |
| 382 | 412 | $setStringUpdate = ''; |
| 383 | 413 | $insert_keys = array(); |
@@ -390,10 +420,11 @@ discard block |
||
| 390 | 420 | $setStringUpdate .= ' |
| 391 | 421 | ' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ','; |
| 392 | 422 | |
| 393 | - if ($change === '+') |
|
| 394 | - $cache_stats[$field] = 1; |
|
| 395 | - else |
|
| 396 | - $update_parameters[$field] = $change; |
|
| 423 | + if ($change === '+') { |
|
| 424 | + $cache_stats[$field] = 1; |
|
| 425 | + } else { |
|
| 426 | + $update_parameters[$field] = $change; |
|
| 427 | + } |
|
| 397 | 428 | $insert_keys[$field] = 'int'; |
| 398 | 429 | } |
| 399 | 430 | |
@@ -457,43 +488,50 @@ discard block |
||
| 457 | 488 | ); |
| 458 | 489 | |
| 459 | 490 | // Make sure this particular log is enabled first... |
| 460 | - if (empty($modSettings['modlog_enabled'])) |
|
| 461 | - unset ($log_types['moderate']); |
|
| 462 | - if (empty($modSettings['userlog_enabled'])) |
|
| 463 | - unset ($log_types['user']); |
|
| 464 | - if (empty($modSettings['adminlog_enabled'])) |
|
| 465 | - unset ($log_types['admin']); |
|
| 491 | + if (empty($modSettings['modlog_enabled'])) { |
|
| 492 | + unset ($log_types['moderate']); |
|
| 493 | + } |
|
| 494 | + if (empty($modSettings['userlog_enabled'])) { |
|
| 495 | + unset ($log_types['user']); |
|
| 496 | + } |
|
| 497 | + if (empty($modSettings['adminlog_enabled'])) { |
|
| 498 | + unset ($log_types['admin']); |
|
| 499 | + } |
|
| 466 | 500 | |
| 467 | 501 | call_integration_hook('integrate_log_types', array(&$log_types)); |
| 468 | 502 | |
| 469 | 503 | foreach ($logs as $log) |
| 470 | 504 | { |
| 471 | - if (!isset($log_types[$log['log_type']])) |
|
| 472 | - return false; |
|
| 505 | + if (!isset($log_types[$log['log_type']])) { |
|
| 506 | + return false; |
|
| 507 | + } |
|
| 473 | 508 | |
| 474 | - if (!is_array($log['extra'])) |
|
| 475 | - trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
| 509 | + if (!is_array($log['extra'])) { |
|
| 510 | + trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
| 511 | + } |
|
| 476 | 512 | |
| 477 | 513 | // Pull out the parts we want to store separately, but also make sure that the data is proper |
| 478 | 514 | if (isset($log['extra']['topic'])) |
| 479 | 515 | { |
| 480 | - if (!is_numeric($log['extra']['topic'])) |
|
| 481 | - trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
| 516 | + if (!is_numeric($log['extra']['topic'])) { |
|
| 517 | + trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
| 518 | + } |
|
| 482 | 519 | $topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic']; |
| 483 | 520 | unset($log['extra']['topic']); |
| 521 | + } else { |
|
| 522 | + $topic_id = 0; |
|
| 484 | 523 | } |
| 485 | - else |
|
| 486 | - $topic_id = 0; |
|
| 487 | 524 | |
| 488 | 525 | if (isset($log['extra']['message'])) |
| 489 | 526 | { |
| 490 | - if (!is_numeric($log['extra']['message'])) |
|
| 491 | - trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
| 527 | + if (!is_numeric($log['extra']['message'])) { |
|
| 528 | + trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
| 529 | + } |
|
| 492 | 530 | $msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message']; |
| 493 | 531 | unset($log['extra']['message']); |
| 532 | + } else { |
|
| 533 | + $msg_id = 0; |
|
| 494 | 534 | } |
| 495 | - else |
|
| 496 | - $msg_id = 0; |
|
| 497 | 535 | |
| 498 | 536 | // @todo cache this? |
| 499 | 537 | // Is there an associated report on this? |
@@ -520,23 +558,26 @@ discard block |
||
| 520 | 558 | $smcFunc['db_free_result']($request); |
| 521 | 559 | } |
| 522 | 560 | |
| 523 | - if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) |
|
| 524 | - trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
| 561 | + if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) { |
|
| 562 | + trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
| 563 | + } |
|
| 525 | 564 | |
| 526 | 565 | if (isset($log['extra']['board'])) |
| 527 | 566 | { |
| 528 | - if (!is_numeric($log['extra']['board'])) |
|
| 529 | - trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
| 567 | + if (!is_numeric($log['extra']['board'])) { |
|
| 568 | + trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
| 569 | + } |
|
| 530 | 570 | $board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board']; |
| 531 | 571 | unset($log['extra']['board']); |
| 572 | + } else { |
|
| 573 | + $board_id = 0; |
|
| 532 | 574 | } |
| 533 | - else |
|
| 534 | - $board_id = 0; |
|
| 535 | 575 | |
| 536 | 576 | if (isset($log['extra']['board_to'])) |
| 537 | 577 | { |
| 538 | - if (!is_numeric($log['extra']['board_to'])) |
|
| 539 | - trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
| 578 | + if (!is_numeric($log['extra']['board_to'])) { |
|
| 579 | + trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
| 580 | + } |
|
| 540 | 581 | if (empty($board_id)) |
| 541 | 582 | { |
| 542 | 583 | $board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to']; |
@@ -544,15 +585,17 @@ discard block |
||
| 544 | 585 | } |
| 545 | 586 | } |
| 546 | 587 | |
| 547 | - if (isset($log['extra']['member_affected'])) |
|
| 548 | - $memID = $log['extra']['member_affected']; |
|
| 549 | - else |
|
| 550 | - $memID = $user_info['id']; |
|
| 588 | + if (isset($log['extra']['member_affected'])) { |
|
| 589 | + $memID = $log['extra']['member_affected']; |
|
| 590 | + } else { |
|
| 591 | + $memID = $user_info['id']; |
|
| 592 | + } |
|
| 551 | 593 | |
| 552 | - if (isset($user_info['ip'])) |
|
| 553 | - $memIP = $user_info['ip']; |
|
| 554 | - else |
|
| 555 | - $memIP = 'null'; |
|
| 594 | + if (isset($user_info['ip'])) { |
|
| 595 | + $memIP = $user_info['ip']; |
|
| 596 | + } else { |
|
| 597 | + $memIP = 'null'; |
|
| 598 | + } |
|
| 556 | 599 | |
| 557 | 600 | $inserts[] = array( |
| 558 | 601 | time(), $log_types[$log['log_type']], $memID, $memIP, $log['action'], |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | // INET. |
| 361 | 361 | elseif ($param_info['type'] == 'inet') |
| 362 | 362 | { |
| 363 | - if(count($search_params[$param_name]) === 1) |
|
| 363 | + if (count($search_params[$param_name]) === 1) |
|
| 364 | 364 | { |
| 365 | 365 | $query_parts[] = '(' . $param_info['db_fields'][0] . ' = {inet:' . $param_name . '})'; |
| 366 | 366 | $where_params[$param_name] = $search_params[$param_name][0]; |
@@ -368,8 +368,8 @@ discard block |
||
| 368 | 368 | elseif (count($search_params[$param_name]) === 2) |
| 369 | 369 | { |
| 370 | 370 | $query_parts[] = '(' . $param_info['db_fields'][0] . ' <= {inet:' . $param_name . '_high} and ' . $param_info['db_fields'][0] . ' >= {inet:' . $param_name . '_low})'; |
| 371 | - $where_params[$param_name.'_low'] = $search_params[$param_name]['low']; |
|
| 372 | - $where_params[$param_name.'_high'] = $search_params[$param_name]['high']; |
|
| 371 | + $where_params[$param_name . '_low'] = $search_params[$param_name]['low']; |
|
| 372 | + $where_params[$param_name . '_high'] = $search_params[$param_name]['high']; |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | } |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * The main 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 | |
@@ -276,14 +282,15 @@ discard block |
||
| 276 | 282 | call_integration_hook('integrate_view_members_params', array(&$params)); |
| 277 | 283 | |
| 278 | 284 | $search_params = array(); |
| 279 | - if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) |
|
| 280 | - $search_params = $smcFunc['json_decode'](base64_decode($_REQUEST['params']), true); |
|
| 281 | - elseif (!empty($_POST)) |
|
| 285 | + if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) { |
|
| 286 | + $search_params = $smcFunc['json_decode'](base64_decode($_REQUEST['params']), true); |
|
| 287 | + } elseif (!empty($_POST)) |
|
| 282 | 288 | { |
| 283 | 289 | $search_params['types'] = $_POST['types']; |
| 284 | - foreach ($params as $param_name => $param_info) |
|
| 285 | - if (isset($_POST[$param_name])) |
|
| 290 | + foreach ($params as $param_name => $param_info) { |
|
| 291 | + if (isset($_POST[$param_name])) |
|
| 286 | 292 | $search_params[$param_name] = $_POST[$param_name]; |
| 293 | + } |
|
| 287 | 294 | } |
| 288 | 295 | |
| 289 | 296 | $search_url_params = isset($search_params) ? base64_encode($smcFunc['json_encode']($search_params)) : null; |
@@ -296,34 +303,38 @@ discard block |
||
| 296 | 303 | foreach ($params as $param_name => $param_info) |
| 297 | 304 | { |
| 298 | 305 | // Not filled in? |
| 299 | - if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') |
|
| 300 | - continue; |
|
| 306 | + if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') { |
|
| 307 | + continue; |
|
| 308 | + } |
|
| 301 | 309 | |
| 302 | 310 | // Make sure numeric values are really numeric. |
| 303 | - if (in_array($param_info['type'], array('int', 'age'))) |
|
| 304 | - $search_params[$param_name] = (int) $search_params[$param_name]; |
|
| 311 | + if (in_array($param_info['type'], array('int', 'age'))) { |
|
| 312 | + $search_params[$param_name] = (int) $search_params[$param_name]; |
|
| 313 | + } |
|
| 305 | 314 | // Date values have to match the specified format. |
| 306 | 315 | elseif ($param_info['type'] == 'date') |
| 307 | 316 | { |
| 308 | 317 | // Check if this date format is valid. |
| 309 | - if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) |
|
| 310 | - continue; |
|
| 318 | + if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) { |
|
| 319 | + continue; |
|
| 320 | + } |
|
| 311 | 321 | |
| 312 | 322 | $search_params[$param_name] = strtotime($search_params[$param_name]); |
| 313 | - } |
|
| 314 | - elseif ($param_info['type'] == 'inet') |
|
| 323 | + } elseif ($param_info['type'] == 'inet') |
|
| 315 | 324 | { |
| 316 | 325 | $search_params[$param_name] = ip2range($search_params[$param_name]); |
| 317 | - if (empty($search_params[$param_name])) |
|
| 318 | - continue; |
|
| 326 | + if (empty($search_params[$param_name])) { |
|
| 327 | + continue; |
|
| 328 | + } |
|
| 319 | 329 | } |
| 320 | 330 | |
| 321 | 331 | // Those values that are in some kind of range (<, <=, =, >=, >). |
| 322 | 332 | if (!empty($param_info['range'])) |
| 323 | 333 | { |
| 324 | 334 | // Default to '=', just in case... |
| 325 | - if (empty($range_trans[$search_params['types'][$param_name]])) |
|
| 326 | - $search_params['types'][$param_name] = '='; |
|
| 335 | + if (empty($range_trans[$search_params['types'][$param_name]])) { |
|
| 336 | + $search_params['types'][$param_name] = '='; |
|
| 337 | + } |
|
| 327 | 338 | |
| 328 | 339 | // Handle special case 'age'. |
| 329 | 340 | if ($param_info['type'] == 'age') |
@@ -351,16 +362,17 @@ discard block |
||
| 351 | 362 | elseif ($param_info['type'] == 'date' && $search_params['types'][$param_name] == '=') |
| 352 | 363 | { |
| 353 | 364 | $query_parts[] = $param_info['db_fields'][0] . ' > ' . $search_params[$param_name] . ' AND ' . $param_info['db_fields'][0] . ' < ' . ($search_params[$param_name] + 86400); |
| 365 | + } else { |
|
| 366 | + $query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name]; |
|
| 354 | 367 | } |
| 355 | - else |
|
| 356 | - $query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name]; |
|
| 357 | 368 | } |
| 358 | 369 | // Checkboxes. |
| 359 | 370 | elseif ($param_info['type'] == 'checkbox') |
| 360 | 371 | { |
| 361 | 372 | // Each checkbox or no checkbox at all is checked -> ignore. |
| 362 | - if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) |
|
| 363 | - continue; |
|
| 373 | + if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) { |
|
| 374 | + continue; |
|
| 375 | + } |
|
| 364 | 376 | |
| 365 | 377 | $query_parts[] = ($param_info['db_fields'][0]) . ' IN ({array_string:' . $param_name . '_check})'; |
| 366 | 378 | $where_params[$param_name . '_check'] = $search_params[$param_name]; |
@@ -372,24 +384,23 @@ discard block |
||
| 372 | 384 | { |
| 373 | 385 | $query_parts[] = '(' . $param_info['db_fields'][0] . ' = {inet:' . $param_name . '})'; |
| 374 | 386 | $where_params[$param_name] = $search_params[$param_name][0]; |
| 375 | - } |
|
| 376 | - elseif (count($search_params[$param_name]) === 2) |
|
| 387 | + } elseif (count($search_params[$param_name]) === 2) |
|
| 377 | 388 | { |
| 378 | 389 | $query_parts[] = '(' . $param_info['db_fields'][0] . ' <= {inet:' . $param_name . '_high} and ' . $param_info['db_fields'][0] . ' >= {inet:' . $param_name . '_low})'; |
| 379 | 390 | $where_params[$param_name.'_low'] = $search_params[$param_name]['low']; |
| 380 | 391 | $where_params[$param_name.'_high'] = $search_params[$param_name]['high']; |
| 381 | 392 | } |
| 382 | 393 | |
| 383 | - } |
|
| 384 | - elseif ($param_info['type'] != 'groups') |
|
| 394 | + } elseif ($param_info['type'] != 'groups') |
|
| 385 | 395 | { |
| 386 | 396 | // Replace the wildcard characters ('*' and '?') into MySQL ones. |
| 387 | 397 | $parameter = strtolower(strtr($smcFunc['htmlspecialchars']($search_params[$param_name], ENT_QUOTES), array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_'))); |
| 388 | 398 | |
| 389 | - if ($smcFunc['db_case_sensitive']) |
|
| 390 | - $query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})'; |
|
| 391 | - else |
|
| 392 | - $query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})'; |
|
| 399 | + if ($smcFunc['db_case_sensitive']) { |
|
| 400 | + $query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})'; |
|
| 401 | + } else { |
|
| 402 | + $query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})'; |
|
| 403 | + } |
|
| 393 | 404 | $where_params[$param_name . '_normal'] = '%' . $parameter . '%'; |
| 394 | 405 | } |
| 395 | 406 | } |
@@ -405,16 +416,18 @@ discard block |
||
| 405 | 416 | } |
| 406 | 417 | |
| 407 | 418 | // Additional membergroups (these are only relevant if not all primary groups where selected!). |
| 408 | - if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) |
|
| 409 | - foreach ($search_params['membergroups'][2] as $mg) |
|
| 419 | + if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) { |
|
| 420 | + foreach ($search_params['membergroups'][2] as $mg) |
|
| 410 | 421 | { |
| 411 | 422 | $mg_query_parts[] = 'FIND_IN_SET({int:add_group_' . $mg . '}, mem.additional_groups) != 0'; |
| 423 | + } |
|
| 412 | 424 | $where_params['add_group_' . $mg] = $mg; |
| 413 | 425 | } |
| 414 | 426 | |
| 415 | 427 | // Combine the one or two membergroup parts into one query part linked with an OR. |
| 416 | - if (!empty($mg_query_parts)) |
|
| 417 | - $query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')'; |
|
| 428 | + if (!empty($mg_query_parts)) { |
|
| 429 | + $query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')'; |
|
| 430 | + } |
|
| 418 | 431 | |
| 419 | 432 | // Get all selected post count related membergroups. |
| 420 | 433 | if (!empty($search_params['postgroups']) && count($search_params['postgroups']) != count($context['postgroups'])) |
@@ -426,9 +439,9 @@ discard block |
||
| 426 | 439 | // Construct the where part of the query. |
| 427 | 440 | $where = empty($query_parts) ? '1=1' : implode(' |
| 428 | 441 | AND ', $query_parts); |
| 442 | + } else { |
|
| 443 | + $search_url_params = null; |
|
| 429 | 444 | } |
| 430 | - else |
|
| 431 | - $search_url_params = null; |
|
| 432 | 445 | |
| 433 | 446 | // Construct the additional URL part with the query info in it. |
| 434 | 447 | $context['params_url'] = $context['sub_action'] == 'query' ? ';sa=query;params=' . $search_url_params : ''; |
@@ -551,28 +564,32 @@ discard block |
||
| 551 | 564 | 'function' => function($rowData) use ($txt) |
| 552 | 565 | { |
| 553 | 566 | // Calculate number of days since last online. |
| 554 | - if (empty($rowData['last_login'])) |
|
| 555 | - $difference = $txt['never']; |
|
| 556 | - else |
|
| 567 | + if (empty($rowData['last_login'])) { |
|
| 568 | + $difference = $txt['never']; |
|
| 569 | + } else |
|
| 557 | 570 | { |
| 558 | 571 | $num_days_difference = jeffsdatediff($rowData['last_login']); |
| 559 | 572 | |
| 560 | 573 | // Today. |
| 561 | - if (empty($num_days_difference)) |
|
| 562 | - $difference = $txt['viewmembers_today']; |
|
| 574 | + if (empty($num_days_difference)) { |
|
| 575 | + $difference = $txt['viewmembers_today']; |
|
| 576 | + } |
|
| 563 | 577 | |
| 564 | 578 | // Yesterday. |
| 565 | - elseif ($num_days_difference == 1) |
|
| 566 | - $difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']); |
|
| 579 | + elseif ($num_days_difference == 1) { |
|
| 580 | + $difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']); |
|
| 581 | + } |
|
| 567 | 582 | |
| 568 | 583 | // X days ago. |
| 569 | - else |
|
| 570 | - $difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']); |
|
| 584 | + else { |
|
| 585 | + $difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']); |
|
| 586 | + } |
|
| 571 | 587 | } |
| 572 | 588 | |
| 573 | 589 | // Show it in italics if they're not activated... |
| 574 | - if ($rowData['is_activated'] % 10 != 1) |
|
| 575 | - $difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference); |
|
| 590 | + if ($rowData['is_activated'] % 10 != 1) { |
|
| 591 | + $difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference); |
|
| 592 | + } |
|
| 576 | 593 | |
| 577 | 594 | return $difference; |
| 578 | 595 | }, |
@@ -624,8 +641,9 @@ discard block |
||
| 624 | 641 | ); |
| 625 | 642 | |
| 626 | 643 | // Without enough permissions, don't show 'delete members' checkboxes. |
| 627 | - if (!allowedTo('profile_remove_any')) |
|
| 628 | - unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']); |
|
| 644 | + if (!allowedTo('profile_remove_any')) { |
|
| 645 | + unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']); |
|
| 646 | + } |
|
| 629 | 647 | |
| 630 | 648 | require_once($sourcedir . '/Subs-List.php'); |
| 631 | 649 | createList($listOptions); |
@@ -668,17 +686,18 @@ discard block |
||
| 668 | 686 | ); |
| 669 | 687 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 670 | 688 | { |
| 671 | - if ($row['min_posts'] == -1) |
|
| 672 | - $context['membergroups'][] = array( |
|
| 689 | + if ($row['min_posts'] == -1) { |
|
| 690 | + $context['membergroups'][] = array( |
|
| 673 | 691 | 'id' => $row['id_group'], |
| 674 | 692 | 'name' => $row['group_name'], |
| 675 | 693 | 'can_be_additional' => true |
| 676 | 694 | ); |
| 677 | - else |
|
| 678 | - $context['postgroups'][] = array( |
|
| 695 | + } else { |
|
| 696 | + $context['postgroups'][] = array( |
|
| 679 | 697 | 'id' => $row['id_group'], |
| 680 | 698 | 'name' => $row['group_name'] |
| 681 | 699 | ); |
| 700 | + } |
|
| 682 | 701 | } |
| 683 | 702 | $smcFunc['db_free_result']($request); |
| 684 | 703 | |
@@ -705,8 +724,9 @@ discard block |
||
| 705 | 724 | $context['page_title'] = $txt['admin_members']; |
| 706 | 725 | $context['sub_template'] = 'admin_browse'; |
| 707 | 726 | $context['browse_type'] = isset($_REQUEST['type']) ? $_REQUEST['type'] : (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1 ? 'activate' : 'approve'); |
| 708 | - if (isset($context['tabs'][$context['browse_type']])) |
|
| 709 | - $context['tabs'][$context['browse_type']]['is_selected'] = true; |
|
| 727 | + if (isset($context['tabs'][$context['browse_type']])) { |
|
| 728 | + $context['tabs'][$context['browse_type']]['is_selected'] = true; |
|
| 729 | + } |
|
| 710 | 730 | |
| 711 | 731 | // Allowed filters are those we can have, in theory. |
| 712 | 732 | $context['allowed_filters'] = $context['browse_type'] == 'approve' ? array(3, 4, 5) : array(0, 2); |
@@ -717,18 +737,20 @@ discard block |
||
| 717 | 737 | foreach ($context['activation_numbers'] as $type => $amount) |
| 718 | 738 | { |
| 719 | 739 | // We have some of these... |
| 720 | - if (in_array($type, $context['allowed_filters']) && $amount > 0) |
|
| 721 | - $context['available_filters'][] = array( |
|
| 740 | + if (in_array($type, $context['allowed_filters']) && $amount > 0) { |
|
| 741 | + $context['available_filters'][] = array( |
|
| 722 | 742 | 'type' => $type, |
| 723 | 743 | 'amount' => $amount, |
| 724 | 744 | 'desc' => isset($txt['admin_browse_filter_type_' . $type]) ? $txt['admin_browse_filter_type_' . $type] : '?', |
| 725 | 745 | 'selected' => $type == $context['current_filter'] |
| 726 | 746 | ); |
| 747 | + } |
|
| 727 | 748 | } |
| 728 | 749 | |
| 729 | 750 | // If the filter was not sent, set it to whatever has people in it! |
| 730 | - if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) |
|
| 731 | - $context['current_filter'] = $context['available_filters'][0]['type']; |
|
| 751 | + if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) { |
|
| 752 | + $context['current_filter'] = $context['available_filters'][0]['type']; |
|
| 753 | + } |
|
| 732 | 754 | |
| 733 | 755 | // This little variable is used to determine if we should flag where we are looking. |
| 734 | 756 | $context['show_filter'] = ($context['current_filter'] != 0 && $context['current_filter'] != 3) || count($context['available_filters']) > 1; |
@@ -743,44 +765,47 @@ discard block |
||
| 743 | 765 | ); |
| 744 | 766 | |
| 745 | 767 | // Are we showing duplicate information? |
| 746 | - if (isset($_GET['showdupes'])) |
|
| 747 | - $_SESSION['showdupes'] = (int) $_GET['showdupes']; |
|
| 768 | + if (isset($_GET['showdupes'])) { |
|
| 769 | + $_SESSION['showdupes'] = (int) $_GET['showdupes']; |
|
| 770 | + } |
|
| 748 | 771 | $context['show_duplicates'] = !empty($_SESSION['showdupes']); |
| 749 | 772 | |
| 750 | 773 | // Determine which actions we should allow on this page. |
| 751 | 774 | if ($context['browse_type'] == 'approve') |
| 752 | 775 | { |
| 753 | 776 | // If we are approving deleted accounts we have a slightly different list... actually a mirror ;) |
| 754 | - if ($context['current_filter'] == 4) |
|
| 755 | - $context['allowed_actions'] = array( |
|
| 777 | + if ($context['current_filter'] == 4) { |
|
| 778 | + $context['allowed_actions'] = array( |
|
| 756 | 779 | 'reject' => $txt['admin_browse_w_approve_deletion'], |
| 757 | 780 | 'ok' => $txt['admin_browse_w_reject'], |
| 758 | 781 | ); |
| 759 | - else |
|
| 760 | - $context['allowed_actions'] = array( |
|
| 782 | + } else { |
|
| 783 | + $context['allowed_actions'] = array( |
|
| 761 | 784 | 'ok' => $txt['admin_browse_w_approve'], |
| 762 | 785 | 'okemail' => $txt['admin_browse_w_approve'] . ' ' . $txt['admin_browse_w_email'], |
| 763 | 786 | 'require_activation' => $txt['admin_browse_w_approve_require_activate'], |
| 764 | 787 | 'reject' => $txt['admin_browse_w_reject'], |
| 765 | 788 | 'rejectemail' => $txt['admin_browse_w_reject'] . ' ' . $txt['admin_browse_w_email'], |
| 766 | 789 | ); |
| 767 | - } |
|
| 768 | - elseif ($context['browse_type'] == 'activate') |
|
| 769 | - $context['allowed_actions'] = array( |
|
| 790 | + } |
|
| 791 | + } elseif ($context['browse_type'] == 'activate') { |
|
| 792 | + $context['allowed_actions'] = array( |
|
| 770 | 793 | 'ok' => $txt['admin_browse_w_activate'], |
| 771 | 794 | 'okemail' => $txt['admin_browse_w_activate'] . ' ' . $txt['admin_browse_w_email'], |
| 772 | 795 | 'delete' => $txt['admin_browse_w_delete'], |
| 773 | 796 | 'deleteemail' => $txt['admin_browse_w_delete'] . ' ' . $txt['admin_browse_w_email'], |
| 774 | 797 | 'remind' => $txt['admin_browse_w_remind'] . ' ' . $txt['admin_browse_w_email'], |
| 775 | 798 | ); |
| 799 | + } |
|
| 776 | 800 | |
| 777 | 801 | // Create an option list for actions allowed to be done with selected members. |
| 778 | 802 | $allowed_actions = ' |
| 779 | 803 | <option selected value="">' . $txt['admin_browse_with_selected'] . ':</option> |
| 780 | 804 | <option value="" disabled>-----------------------------</option>'; |
| 781 | - foreach ($context['allowed_actions'] as $key => $desc) |
|
| 782 | - $allowed_actions .= ' |
|
| 805 | + foreach ($context['allowed_actions'] as $key => $desc) { |
|
| 806 | + $allowed_actions .= ' |
|
| 783 | 807 | <option value="' . $key . '">' . $desc . '</option>'; |
| 808 | + } |
|
| 784 | 809 | |
| 785 | 810 | // Setup the Javascript function for selecting an action for the list. |
| 786 | 811 | $javascript = ' |
@@ -792,15 +817,16 @@ discard block |
||
| 792 | 817 | var message = "";'; |
| 793 | 818 | |
| 794 | 819 | // We have special messages for approving deletion of accounts - it's surprisingly logical - honest. |
| 795 | - if ($context['current_filter'] == 4) |
|
| 796 | - $javascript .= ' |
|
| 820 | + if ($context['current_filter'] == 4) { |
|
| 821 | + $javascript .= ' |
|
| 797 | 822 | if (document.forms.postForm.todo.value.indexOf("reject") != -1) |
| 798 | 823 | message = "' . $txt['admin_browse_w_delete'] . '"; |
| 799 | 824 | else |
| 800 | 825 | message = "' . $txt['admin_browse_w_reject'] . '";'; |
| 826 | + } |
|
| 801 | 827 | // Otherwise a nice standard message. |
| 802 | - else |
|
| 803 | - $javascript .= ' |
|
| 828 | + else { |
|
| 829 | + $javascript .= ' |
|
| 804 | 830 | if (document.forms.postForm.todo.value.indexOf("delete") != -1) |
| 805 | 831 | message = "' . $txt['admin_browse_w_delete'] . '"; |
| 806 | 832 | else if (document.forms.postForm.todo.value.indexOf("reject") != -1) |
@@ -809,6 +835,7 @@ discard block |
||
| 809 | 835 | message = "' . $txt['admin_browse_w_remind'] . '"; |
| 810 | 836 | else |
| 811 | 837 | message = "' . ($context['browse_type'] == 'approve' ? $txt['admin_browse_w_approve'] : $txt['admin_browse_w_activate']) . '";'; |
| 838 | + } |
|
| 812 | 839 | $javascript .= ' |
| 813 | 840 | if (confirm(message + " ' . $txt['admin_browse_warn'] . '")) |
| 814 | 841 | document.forms.postForm.submit(); |
@@ -941,10 +968,11 @@ discard block |
||
| 941 | 968 | $member_links = array(); |
| 942 | 969 | foreach ($rowData['duplicate_members'] as $member) |
| 943 | 970 | { |
| 944 | - if ($member['id']) |
|
| 945 | - $member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>'; |
|
| 946 | - else |
|
| 947 | - $member_links[] = $member['name'] . ' (' . $txt['guest'] . ')'; |
|
| 971 | + if ($member['id']) { |
|
| 972 | + $member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>'; |
|
| 973 | + } else { |
|
| 974 | + $member_links[] = $member['name'] . ' (' . $txt['guest'] . ')'; |
|
| 975 | + } |
|
| 948 | 976 | } |
| 949 | 977 | return implode(', ', $member_links); |
| 950 | 978 | }, |
@@ -993,14 +1021,16 @@ discard block |
||
| 993 | 1021 | ); |
| 994 | 1022 | |
| 995 | 1023 | // Pick what column to actually include if we're showing duplicates. |
| 996 | - if ($context['show_duplicates']) |
|
| 997 | - unset($listOptions['columns']['email']); |
|
| 998 | - else |
|
| 999 | - unset($listOptions['columns']['duplicates']); |
|
| 1024 | + if ($context['show_duplicates']) { |
|
| 1025 | + unset($listOptions['columns']['email']); |
|
| 1026 | + } else { |
|
| 1027 | + unset($listOptions['columns']['duplicates']); |
|
| 1028 | + } |
|
| 1000 | 1029 | |
| 1001 | 1030 | // Only show hostname on duplicates as it takes a lot of time. |
| 1002 | - if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) |
|
| 1003 | - unset($listOptions['columns']['hostname']); |
|
| 1031 | + if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) { |
|
| 1032 | + unset($listOptions['columns']['hostname']); |
|
| 1033 | + } |
|
| 1004 | 1034 | |
| 1005 | 1035 | // Is there any need to show filters? |
| 1006 | 1036 | if (isset($context['available_filters']) && count($context['available_filters']) > 1) |
@@ -1008,9 +1038,10 @@ discard block |
||
| 1008 | 1038 | $filterOptions = ' |
| 1009 | 1039 | <strong>' . $txt['admin_browse_filter_by'] . ':</strong> |
| 1010 | 1040 | <select name="filter" onchange="this.form.submit();">'; |
| 1011 | - foreach ($context['available_filters'] as $filter) |
|
| 1012 | - $filterOptions .= ' |
|
| 1041 | + foreach ($context['available_filters'] as $filter) { |
|
| 1042 | + $filterOptions .= ' |
|
| 1013 | 1043 | <option value="' . $filter['type'] . '"' . ($filter['selected'] ? ' selected' : '') . '>' . $filter['desc'] . ' - ' . $filter['amount'] . ' ' . ($filter['amount'] == 1 ? $txt['user'] : $txt['users']) . '</option>'; |
| 1044 | + } |
|
| 1014 | 1045 | $filterOptions .= ' |
| 1015 | 1046 | </select> |
| 1016 | 1047 | <noscript><input type="submit" value="' . $txt['go'] . '" name="filter" class="button"></noscript>'; |
@@ -1022,12 +1053,13 @@ discard block |
||
| 1022 | 1053 | } |
| 1023 | 1054 | |
| 1024 | 1055 | // What about if we only have one filter, but it's not the "standard" filter - show them what they are looking at. |
| 1025 | - if (!empty($context['show_filter']) && !empty($context['available_filters'])) |
|
| 1026 | - $listOptions['additional_rows'][] = array( |
|
| 1056 | + if (!empty($context['show_filter']) && !empty($context['available_filters'])) { |
|
| 1057 | + $listOptions['additional_rows'][] = array( |
|
| 1027 | 1058 | 'position' => 'above_column_headers', |
| 1028 | 1059 | 'value' => '<strong>' . $txt['admin_browse_filter_show'] . ':</strong> ' . $context['available_filters'][0]['desc'], |
| 1029 | 1060 | 'class' => 'smalltext floatright', |
| 1030 | 1061 | ); |
| 1062 | + } |
|
| 1031 | 1063 | |
| 1032 | 1064 | // Now that we have all the options, create the list. |
| 1033 | 1065 | require_once($sourcedir . '/Subs-List.php'); |
@@ -1057,12 +1089,14 @@ discard block |
||
| 1057 | 1089 | $current_filter = (int) $_REQUEST['orig_filter']; |
| 1058 | 1090 | |
| 1059 | 1091 | // If we are applying a filter do just that - then redirect. |
| 1060 | - if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) |
|
| 1061 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']); |
|
| 1092 | + if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) { |
|
| 1093 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']); |
|
| 1094 | + } |
|
| 1062 | 1095 | |
| 1063 | 1096 | // Nothing to do? |
| 1064 | - if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) |
|
| 1065 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
| 1097 | + if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) { |
|
| 1098 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
| 1099 | + } |
|
| 1066 | 1100 | |
| 1067 | 1101 | // Are we dealing with members who have been waiting for > set amount of time? |
| 1068 | 1102 | if (isset($_POST['time_passed'])) |
@@ -1075,8 +1109,9 @@ discard block |
||
| 1075 | 1109 | else |
| 1076 | 1110 | { |
| 1077 | 1111 | $members = array(); |
| 1078 | - foreach ($_POST['todoAction'] as $id) |
|
| 1079 | - $members[] = (int) $id; |
|
| 1112 | + foreach ($_POST['todoAction'] as $id) { |
|
| 1113 | + $members[] = (int) $id; |
|
| 1114 | + } |
|
| 1080 | 1115 | $condition = ' |
| 1081 | 1116 | AND id_member IN ({array_int:members})'; |
| 1082 | 1117 | } |
@@ -1097,8 +1132,9 @@ discard block |
||
| 1097 | 1132 | $member_count = $smcFunc['db_num_rows']($request); |
| 1098 | 1133 | |
| 1099 | 1134 | // If no results then just return! |
| 1100 | - if ($member_count == 0) |
|
| 1101 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
| 1135 | + if ($member_count == 0) { |
|
| 1136 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
| 1137 | + } |
|
| 1102 | 1138 | |
| 1103 | 1139 | $member_info = array(); |
| 1104 | 1140 | $members = array(); |
@@ -1137,8 +1173,9 @@ discard block |
||
| 1137 | 1173 | // Do we have to let the integration code know about the activations? |
| 1138 | 1174 | if (!empty($modSettings['integrate_activate'])) |
| 1139 | 1175 | { |
| 1140 | - foreach ($member_info as $member) |
|
| 1141 | - call_integration_hook('integrate_activate', array($member['username'])); |
|
| 1176 | + foreach ($member_info as $member) { |
|
| 1177 | + call_integration_hook('integrate_activate', array($member['username'])); |
|
| 1178 | + } |
|
| 1142 | 1179 | } |
| 1143 | 1180 | |
| 1144 | 1181 | // Check for email. |
@@ -1268,20 +1305,23 @@ discard block |
||
| 1268 | 1305 | $log_action = $_POST['todo'] == 'remind' ? 'remind_member' : 'approve_member'; |
| 1269 | 1306 | |
| 1270 | 1307 | require_once($sourcedir . '/Logging.php'); |
| 1271 | - foreach ($member_info as $member) |
|
| 1272 | - logAction($log_action, array('member' => $member['id']), 'admin'); |
|
| 1308 | + foreach ($member_info as $member) { |
|
| 1309 | + logAction($log_action, array('member' => $member['id']), 'admin'); |
|
| 1310 | + } |
|
| 1273 | 1311 | } |
| 1274 | 1312 | |
| 1275 | 1313 | // Although updateStats *may* catch this, best to do it manually just in case (Doesn't always sort out unapprovedMembers). |
| 1276 | - if (in_array($current_filter, array(3, 4, 5))) |
|
| 1277 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0))); |
|
| 1314 | + if (in_array($current_filter, array(3, 4, 5))) { |
|
| 1315 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0))); |
|
| 1316 | + } |
|
| 1278 | 1317 | |
| 1279 | 1318 | // Update the member's stats. (but, we know the member didn't change their name.) |
| 1280 | 1319 | updateStats('member', false); |
| 1281 | 1320 | |
| 1282 | 1321 | // If they haven't been deleted, update the post group statistics on them... |
| 1283 | - if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) |
|
| 1284 | - updateStats('postgroups', $members); |
|
| 1322 | + if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) { |
|
| 1323 | + updateStats('postgroups', $members); |
|
| 1324 | + } |
|
| 1285 | 1325 | |
| 1286 | 1326 | redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
| 1287 | 1327 | } |
@@ -1306,10 +1346,11 @@ discard block |
||
| 1306 | 1346 | $dis = time() - $old; |
| 1307 | 1347 | |
| 1308 | 1348 | // Before midnight? |
| 1309 | - if ($dis < $sinceMidnight) |
|
| 1310 | - return 0; |
|
| 1311 | - else |
|
| 1312 | - $dis -= $sinceMidnight; |
|
| 1349 | + if ($dis < $sinceMidnight) { |
|
| 1350 | + return 0; |
|
| 1351 | + } else { |
|
| 1352 | + $dis -= $sinceMidnight; |
|
| 1353 | + } |
|
| 1313 | 1354 | |
| 1314 | 1355 | // Divide out the seconds in a day to get the number of days. |
| 1315 | 1356 | return ceil($dis / (24 * 60 * 60)); |
@@ -12,7 +12,8 @@ |
||
| 12 | 12 | header('location: ' . $boardurl); |
| 13 | 13 | } |
| 14 | 14 | // Can't find it... just forget it. |
| 15 | -else |
|
| 15 | +else { |
|
| 16 | 16 | exit; |
| 17 | +} |
|
| 17 | 18 | |
| 18 | 19 | ?> |
| 19 | 20 | \ No newline at end of file |
@@ -41,37 +41,43 @@ discard block |
||
| 41 | 41 | define('TIME_START', microtime(true)); |
| 42 | 42 | |
| 43 | 43 | // Just being safe... |
| 44 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 44 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 45 | 45 | if (isset($GLOBALS[$variable])) |
| 46 | 46 | unset($GLOBALS[$variable]); |
| 47 | +} |
|
| 47 | 48 | |
| 48 | 49 | // Get the forum's settings for database and file paths. |
| 49 | 50 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 50 | 51 | |
| 51 | 52 | // Make absolutely sure the cache directory is defined. |
| 52 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 53 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 53 | 54 | $cachedir = $boarddir . '/cache'; |
| 55 | +} |
|
| 54 | 56 | |
| 55 | 57 | // Don't do john didley if the forum's been shut down competely. |
| 56 | -if ($maintenance == 2) |
|
| 58 | +if ($maintenance == 2) { |
|
| 57 | 59 | die($mmessage); |
| 60 | +} |
|
| 58 | 61 | |
| 59 | 62 | // Fix for using the current directory as a path. |
| 60 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
| 63 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
| 61 | 64 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
| 65 | +} |
|
| 62 | 66 | |
| 63 | 67 | // Have we already turned this off? If so, exist gracefully. |
| 64 | -if (file_exists($cachedir . '/cron.lock')) |
|
| 68 | +if (file_exists($cachedir . '/cron.lock')) { |
|
| 65 | 69 | obExit_cron(); |
| 70 | +} |
|
| 66 | 71 | |
| 67 | 72 | // Before we go any further, if this is not a CLI request, we need to do some checking. |
| 68 | 73 | if (!FROM_CLI) |
| 69 | 74 | { |
| 70 | 75 | // We will clean up $_GET shortly. But we want to this ASAP. |
| 71 | 76 | $ts = isset($_GET['ts']) ? (int) $_GET['ts'] : 0; |
| 72 | - if ($ts <= 0 || $ts % 15 != 0 || time() - $ts < 0 || time() - $ts > 20) |
|
| 73 | - obExit_cron(); |
|
| 74 | -} |
|
| 77 | + if ($ts <= 0 || $ts % 15 != 0 || time() - $ts < 0 || time() - $ts > 20) { |
|
| 78 | + obExit_cron(); |
|
| 79 | + } |
|
| 80 | + } |
|
| 75 | 81 | |
| 76 | 82 | // Load the most important includes. In general, a background should be loading its own dependencies. |
| 77 | 83 | require_once($sourcedir . '/Errors.php'); |
@@ -123,8 +129,9 @@ discard block |
||
| 123 | 129 | global $smcFunc; |
| 124 | 130 | |
| 125 | 131 | // Check we haven't run over our time limit. |
| 126 | - if (microtime(true) - TIME_START > MAX_CRON_TIME) |
|
| 127 | - return false; |
|
| 132 | + if (microtime(true) - TIME_START > MAX_CRON_TIME) { |
|
| 133 | + return false; |
|
| 134 | + } |
|
| 128 | 135 | |
| 129 | 136 | // Try to find a task. Specifically, try to find one that hasn't been claimed previously, or failing that, |
| 130 | 137 | // a task that was claimed but failed for whatever reason and failed long enough ago. We should not care |
@@ -159,14 +166,12 @@ discard block |
||
| 159 | 166 | // Update the time and go back. |
| 160 | 167 | $row['claimed_time'] = time(); |
| 161 | 168 | return $row; |
| 162 | - } |
|
| 163 | - else |
|
| 169 | + } else |
|
| 164 | 170 | { |
| 165 | 171 | // Uh oh, we just missed it. Try to claim another one, and let it fall through if there aren't any. |
| 166 | 172 | return fetch_task(); |
| 167 | 173 | } |
| 168 | - } |
|
| 169 | - else |
|
| 174 | + } else |
|
| 170 | 175 | { |
| 171 | 176 | // No dice. Clean up and go home. |
| 172 | 177 | $smcFunc['db_free_result']($request); |
@@ -187,8 +192,9 @@ discard block |
||
| 187 | 192 | if (!empty($task_details['task_file'])) |
| 188 | 193 | { |
| 189 | 194 | $include = strtr(trim($task_details['task_file']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
| 190 | - if (file_exists($include)) |
|
| 191 | - require_once($include); |
|
| 195 | + if (file_exists($include)) { |
|
| 196 | + require_once($include); |
|
| 197 | + } |
|
| 192 | 198 | } |
| 193 | 199 | |
| 194 | 200 | if (empty($task_details['task_class'])) |
@@ -204,8 +210,7 @@ discard block |
||
| 204 | 210 | $details = empty($task_details['task_data']) ? array() : $smcFunc['json_decode']($task_details['task_data'], true); |
| 205 | 211 | $bgtask = new $task_details['task_class']($details); |
| 206 | 212 | return $bgtask->execute(); |
| 207 | - } |
|
| 208 | - else |
|
| 213 | + } else |
|
| 209 | 214 | { |
| 210 | 215 | log_error('Invalid background task specified: (class: ' . $task_details['task_class'] . ', ' . (empty($task_details['task_file']) ? ' no file' : ' to load ' . $task_details['task_file']) . ')'); |
| 211 | 216 | return true; // So we clear it from the queue. |
@@ -224,8 +229,9 @@ discard block |
||
| 224 | 229 | $scripturl = $boardurl . '/index.php'; |
| 225 | 230 | |
| 226 | 231 | // These keys shouldn't be set...ever. |
| 227 | - if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
| 228 | - die('Invalid request variable.'); |
|
| 232 | + if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
| 233 | + die('Invalid request variable.'); |
|
| 234 | + } |
|
| 229 | 235 | |
| 230 | 236 | // Save some memory.. (since we don't use these anyway.) |
| 231 | 237 | unset($GLOBALS['HTTP_POST_VARS'], $GLOBALS['HTTP_POST_VARS']); |
@@ -246,26 +252,28 @@ discard block |
||
| 246 | 252 | global $modSettings; |
| 247 | 253 | |
| 248 | 254 | // Ignore errors if we're ignoring them or they are strict notices from PHP 5 |
| 249 | - if (error_reporting() == 0) |
|
| 250 | - return; |
|
| 255 | + if (error_reporting() == 0) { |
|
| 256 | + return; |
|
| 257 | + } |
|
| 251 | 258 | |
| 252 | 259 | $error_type = 'cron'; |
| 253 | 260 | |
| 254 | 261 | log_error($error_level . ': ' . $error_string, $error_type, $file, $line); |
| 255 | 262 | |
| 256 | 263 | // If this is an E_ERROR or E_USER_ERROR.... die. Violently so. |
| 257 | - if ($error_level % 255 == E_ERROR) |
|
| 258 | - die('No direct access...'); |
|
| 259 | -} |
|
| 264 | + if ($error_level % 255 == E_ERROR) { |
|
| 265 | + die('No direct access...'); |
|
| 266 | + } |
|
| 267 | + } |
|
| 260 | 268 | |
| 261 | 269 | /** |
| 262 | 270 | * The exit function |
| 263 | 271 | */ |
| 264 | 272 | function obExit_cron() |
| 265 | 273 | { |
| 266 | - if (FROM_CLI) |
|
| 267 | - die(0); |
|
| 268 | - else |
|
| 274 | + if (FROM_CLI) { |
|
| 275 | + die(0); |
|
| 276 | + } else |
|
| 269 | 277 | { |
| 270 | 278 | header('content-type: image/gif'); |
| 271 | 279 | die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B"); |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Downloads an avatar or attachment based on $_GET['attach'], and increments the download count. |
@@ -40,11 +41,11 @@ discard block |
||
| 40 | 41 | |
| 41 | 42 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent() && ob_get_length() == 0) |
| 42 | 43 | { |
| 43 | - if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') |
|
| 44 | - $modSettings['enableCompressedOutput'] = 0; |
|
| 45 | - |
|
| 46 | - else |
|
| 47 | - ob_start('ob_gzhandler'); |
|
| 44 | + if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') { |
|
| 45 | + $modSettings['enableCompressedOutput'] = 0; |
|
| 46 | + } else { |
|
| 47 | + ob_start('ob_gzhandler'); |
|
| 48 | + } |
|
| 48 | 49 | } |
| 49 | 50 | |
| 50 | 51 | if (empty($modSettings['enableCompressedOutput'])) |
@@ -76,8 +77,9 @@ discard block |
||
| 76 | 77 | } |
| 77 | 78 | |
| 78 | 79 | // Use cache when possible. |
| 79 | - if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) |
|
| 80 | - list($file, $thumbFile) = $cache; |
|
| 80 | + if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) { |
|
| 81 | + list($file, $thumbFile) = $cache; |
|
| 82 | + } |
|
| 81 | 83 | |
| 82 | 84 | // Get the info from the DB. |
| 83 | 85 | if (empty($file) || empty($thumbFile) && !empty($file['id_thumb'])) |
@@ -85,10 +87,9 @@ discard block |
||
| 85 | 87 | // Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request. |
| 86 | 88 | $attachRequest = null; |
| 87 | 89 | call_integration_hook('integrate_download_request', array(&$attachRequest)); |
| 88 | - if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) |
|
| 89 | - $request = $attachRequest; |
|
| 90 | - |
|
| 91 | - else |
|
| 90 | + if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) { |
|
| 91 | + $request = $attachRequest; |
|
| 92 | + } else |
|
| 92 | 93 | { |
| 93 | 94 | // Make sure this attachment is on this board and load its info while we are at it. |
| 94 | 95 | $request = $smcFunc['db_query']('', ' |
@@ -181,13 +182,15 @@ discard block |
||
| 181 | 182 | } |
| 182 | 183 | |
| 183 | 184 | // Cache it. |
| 184 | - if (!empty($file) || !empty($thumbFile)) |
|
| 185 | - cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
| 185 | + if (!empty($file) || !empty($thumbFile)) { |
|
| 186 | + cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
| 187 | + } |
|
| 186 | 188 | } |
| 187 | 189 | |
| 188 | 190 | // Replace the normal file with its thumbnail if it has one! |
| 189 | - if (!empty($showThumb) && !empty($thumbFile)) |
|
| 190 | - $file = $thumbFile; |
|
| 191 | + if (!empty($showThumb) && !empty($thumbFile)) { |
|
| 192 | + $file = $thumbFile; |
|
| 193 | + } |
|
| 191 | 194 | |
| 192 | 195 | // No point in a nicer message, because this is supposed to be an attachment anyway... |
| 193 | 196 | if (!file_exists($file['filePath'])) |
@@ -237,8 +240,8 @@ discard block |
||
| 237 | 240 | } |
| 238 | 241 | |
| 239 | 242 | // Update the download counter (unless it's a thumbnail or resuming an incomplete download). |
| 240 | - if ($file['attachment_type'] != 3 && empty($showThumb) && $range === 0) |
|
| 241 | - $smcFunc['db_query']('', ' |
|
| 243 | + if ($file['attachment_type'] != 3 && empty($showThumb) && $range === 0) { |
|
| 244 | + $smcFunc['db_query']('', ' |
|
| 242 | 245 | UPDATE {db_prefix}attachments |
| 243 | 246 | SET downloads = downloads + 1 |
| 244 | 247 | WHERE id_attach = {int:id_attach}', |
@@ -246,12 +249,14 @@ discard block |
||
| 246 | 249 | 'id_attach' => $attachId, |
| 247 | 250 | ) |
| 248 | 251 | ); |
| 252 | + } |
|
| 249 | 253 | |
| 250 | 254 | // Send the attachment headers. |
| 251 | 255 | header('pragma: '); |
| 252 | 256 | |
| 253 | - if (!isBrowser('gecko')) |
|
| 254 | - header('content-transfer-encoding: binary'); |
|
| 257 | + if (!isBrowser('gecko')) { |
|
| 258 | + header('content-transfer-encoding: binary'); |
|
| 259 | + } |
|
| 255 | 260 | |
| 256 | 261 | header('expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
| 257 | 262 | header('last-modified: ' . gmdate('D, d M Y H:i:s', filemtime($file['filePath'])) . ' GMT'); |
@@ -260,18 +265,19 @@ discard block |
||
| 260 | 265 | header('etag: ' . $eTag); |
| 261 | 266 | |
| 262 | 267 | // Make sure the mime type warrants an inline display. |
| 263 | - if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) |
|
| 264 | - unset($_REQUEST['image']); |
|
| 268 | + if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) { |
|
| 269 | + unset($_REQUEST['image']); |
|
| 270 | + } |
|
| 265 | 271 | |
| 266 | 272 | // Does this have a mime type? |
| 267 | - elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) |
|
| 268 | - header('content-type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
| 269 | - |
|
| 270 | - else |
|
| 273 | + elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) { |
|
| 274 | + header('content-type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
| 275 | + } else |
|
| 271 | 276 | { |
| 272 | 277 | header('content-type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream')); |
| 273 | - if (isset($_REQUEST['image'])) |
|
| 274 | - unset($_REQUEST['image']); |
|
| 278 | + if (isset($_REQUEST['image'])) { |
|
| 279 | + unset($_REQUEST['image']); |
|
| 280 | + } |
|
| 275 | 281 | } |
| 276 | 282 | |
| 277 | 283 | // Convert the file to UTF-8, cuz most browsers dig that. |
@@ -279,24 +285,22 @@ discard block |
||
| 279 | 285 | $disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline'; |
| 280 | 286 | |
| 281 | 287 | // Different browsers like different standards... |
| 282 | - if (isBrowser('firefox')) |
|
| 283 | - header('content-disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
| 284 | - |
|
| 285 | - elseif (isBrowser('opera')) |
|
| 286 | - header('content-disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
| 287 | - |
|
| 288 | - elseif (isBrowser('ie')) |
|
| 289 | - header('content-disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
| 290 | - |
|
| 291 | - else |
|
| 292 | - header('content-disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
| 288 | + if (isBrowser('firefox')) { |
|
| 289 | + header('content-disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
| 290 | + } elseif (isBrowser('opera')) { |
|
| 291 | + header('content-disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
| 292 | + } elseif (isBrowser('ie')) { |
|
| 293 | + header('content-disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
| 294 | + } else { |
|
| 295 | + header('content-disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
| 296 | + } |
|
| 293 | 297 | |
| 294 | 298 | // If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE. |
| 295 | - if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) |
|
| 296 | - header('cache-control: no-cache'); |
|
| 297 | - |
|
| 298 | - else |
|
| 299 | - header('cache-control: max-age=' . (525600 * 60) . ', private'); |
|
| 299 | + if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) { |
|
| 300 | + header('cache-control: no-cache'); |
|
| 301 | + } else { |
|
| 302 | + header('cache-control: max-age=' . (525600 * 60) . ', private'); |
|
| 303 | + } |
|
| 300 | 304 | |
| 301 | 305 | // Multipart and resuming support |
| 302 | 306 | if (isset($_SERVER['HTTP_RANGE'])) |
@@ -304,9 +308,9 @@ discard block |
||
| 304 | 308 | header("HTTP/1.1 206 Partial Content"); |
| 305 | 309 | header("content-length: $new_length"); |
| 306 | 310 | header("content-range: bytes $range-$range_end/$size"); |
| 311 | + } else { |
|
| 312 | + header("content-length: " . $size); |
|
| 307 | 313 | } |
| 308 | - else |
|
| 309 | - header("content-length: " . $size); |
|
| 310 | 314 | |
| 311 | 315 | |
| 312 | 316 | // Try to buy some time... |
@@ -315,8 +319,9 @@ discard block |
||
| 315 | 319 | // For multipart/resumable downloads, send the requested chunk(s) of the file |
| 316 | 320 | if (isset($_SERVER['HTTP_RANGE'])) |
| 317 | 321 | { |
| 318 | - while (@ob_get_level() > 0) |
|
| 319 | - @ob_end_clean(); |
|
| 322 | + while (@ob_get_level() > 0) { |
|
| 323 | + @ob_end_clean(); |
|
| 324 | + } |
|
| 320 | 325 | |
| 321 | 326 | // 40 kilobytes is a good-ish amount |
| 322 | 327 | $chunksize = 40 * 1024; |
@@ -340,8 +345,9 @@ discard block |
||
| 340 | 345 | elseif ($size > 4194304) |
| 341 | 346 | { |
| 342 | 347 | // Forcibly end any output buffering going on. |
| 343 | - while (@ob_get_level() > 0) |
|
| 344 | - @ob_end_clean(); |
|
| 348 | + while (@ob_get_level() > 0) { |
|
| 349 | + @ob_end_clean(); |
|
| 350 | + } |
|
| 345 | 351 | |
| 346 | 352 | $fp = fopen($file['filePath'], 'rb'); |
| 347 | 353 | while (!feof($fp)) |
@@ -353,8 +359,9 @@ discard block |
||
| 353 | 359 | } |
| 354 | 360 | |
| 355 | 361 | // 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. |
| 356 | - elseif (@readfile($file['filePath']) === null) |
|
| 357 | - echo file_get_contents($file['filePath']); |
|
| 362 | + elseif (@readfile($file['filePath']) === null) { |
|
| 363 | + echo file_get_contents($file['filePath']); |
|
| 364 | + } |
|
| 358 | 365 | |
| 359 | 366 | die(); |
| 360 | 367 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | // Just send a generic message. |
| 77 | 77 | else |
| 78 | 78 | $this->setResponse(array( |
| 79 | - 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
|
| 79 | + 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
|
| 80 | 80 | 'type' => 'error', |
| 81 | 81 | 'data' => false, |
| 82 | 82 | )); |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | // Gotta urlencode the filename. |
| 411 | 411 | if ($this->_attachResults) |
| 412 | 412 | foreach ($this->_attachResults as $k => $v) |
| 413 | - $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
|
| 413 | + $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
|
| 414 | 414 | |
| 415 | 415 | $this->_response = array( |
| 416 | 416 | 'files' => $this->_attachResults ? $this->_attachResults : false, |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | ob_start(); |
| 438 | 438 | |
| 439 | 439 | // Set the header. |
| 440 | - header('content-type: application/json; charset='. $context['character_set'] .''); |
|
| 440 | + header('content-type: application/json; charset=' . $context['character_set'] . ''); |
|
| 441 | 441 | |
| 442 | 442 | echo $smcFunc['json_encode']($this->_response ? $this->_response : array()); |
| 443 | 443 | |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | class Attachments |
| 20 | 21 | { |
@@ -70,16 +71,18 @@ discard block |
||
| 70 | 71 | |
| 71 | 72 | $this->_sa = !empty($_REQUEST['sa']) ? $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($_REQUEST['sa'])) : false; |
| 72 | 73 | |
| 73 | - if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) |
|
| 74 | - $this->{$this->_sa}(); |
|
| 74 | + if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) { |
|
| 75 | + $this->{$this->_sa}(); |
|
| 76 | + } |
|
| 75 | 77 | |
| 76 | 78 | // Just send a generic message. |
| 77 | - else |
|
| 78 | - $this->setResponse(array( |
|
| 79 | + else { |
|
| 80 | + $this->setResponse(array( |
|
| 79 | 81 | 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
| 80 | 82 | 'type' => 'error', |
| 81 | 83 | 'data' => false, |
| 82 | 84 | )); |
| 85 | + } |
|
| 83 | 86 | |
| 84 | 87 | // Back to the future, oh, to the browser! |
| 85 | 88 | $this->sendResponse(); |
@@ -95,12 +98,13 @@ discard block |
||
| 95 | 98 | $attachID = !empty($_REQUEST['attach']) && is_numeric($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : 0; |
| 96 | 99 | |
| 97 | 100 | // Need something to work with. |
| 98 | - if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) |
|
| 99 | - return $this->setResponse(array( |
|
| 101 | + if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) { |
|
| 102 | + return $this->setResponse(array( |
|
| 100 | 103 | 'text' => 'attached_file_deleted_error', |
| 101 | 104 | 'type' => 'error', |
| 102 | 105 | 'data' => false, |
| 103 | 106 | )); |
| 107 | + } |
|
| 104 | 108 | |
| 105 | 109 | // Lets pass some params and see what happens :P |
| 106 | 110 | $affectedMessage = removeAttachments(array('id_attach' => $attachID), '', true, true); |
@@ -119,19 +123,21 @@ discard block |
||
| 119 | 123 | public function add() |
| 120 | 124 | { |
| 121 | 125 | // You gotta be able to post attachments. |
| 122 | - if (!$this->_canPostAttachment) |
|
| 123 | - return $this->setResponse(array( |
|
| 126 | + if (!$this->_canPostAttachment) { |
|
| 127 | + return $this->setResponse(array( |
|
| 124 | 128 | 'text' => 'attached_file_cannot', |
| 125 | 129 | 'type' => 'error', |
| 126 | 130 | 'data' => false, |
| 127 | 131 | )); |
| 132 | + } |
|
| 128 | 133 | |
| 129 | 134 | // Process them at once! |
| 130 | 135 | $this->processAttachments(); |
| 131 | 136 | |
| 132 | 137 | // The attachments was created and moved the the right folder, time to update the DB. |
| 133 | - if (!empty($_SESSION['temp_attachments'])) |
|
| 134 | - $this->createAtttach(); |
|
| 138 | + if (!empty($_SESSION['temp_attachments'])) { |
|
| 139 | + $this->createAtttach(); |
|
| 140 | + } |
|
| 135 | 141 | |
| 136 | 142 | // Set the response. |
| 137 | 143 | $this->setResponse(); |
@@ -144,8 +150,9 @@ discard block |
||
| 144 | 150 | { |
| 145 | 151 | global $context, $modSettings, $smcFunc, $user_info, $txt; |
| 146 | 152 | |
| 147 | - if (!isset($_FILES['attachment']['name'])) |
|
| 148 | - $_FILES['attachment']['tmp_name'] = array(); |
|
| 153 | + if (!isset($_FILES['attachment']['name'])) { |
|
| 154 | + $_FILES['attachment']['tmp_name'] = array(); |
|
| 155 | + } |
|
| 149 | 156 | |
| 150 | 157 | // If there are attachments, calculate the total size and how many. |
| 151 | 158 | $context['attachments']['total_size'] = 0; |
@@ -155,25 +162,30 @@ discard block |
||
| 155 | 162 | if (isset($_REQUEST['msg'])) |
| 156 | 163 | { |
| 157 | 164 | $context['attachments']['quantity'] = count($context['current_attachments']); |
| 158 | - foreach ($context['current_attachments'] as $attachment) |
|
| 159 | - $context['attachments']['total_size'] += $attachment['size']; |
|
| 165 | + foreach ($context['current_attachments'] as $attachment) { |
|
| 166 | + $context['attachments']['total_size'] += $attachment['size']; |
|
| 167 | + } |
|
| 160 | 168 | } |
| 161 | 169 | |
| 162 | 170 | // A bit of house keeping first. |
| 163 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
| 164 | - unset($_SESSION['temp_attachments']); |
|
| 171 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
| 172 | + unset($_SESSION['temp_attachments']); |
|
| 173 | + } |
|
| 165 | 174 | |
| 166 | 175 | // Our infamous SESSION var, we are gonna have soo much fun with it! |
| 167 | - if (!isset($_SESSION['temp_attachments'])) |
|
| 168 | - $_SESSION['temp_attachments'] = array(); |
|
| 176 | + if (!isset($_SESSION['temp_attachments'])) { |
|
| 177 | + $_SESSION['temp_attachments'] = array(); |
|
| 178 | + } |
|
| 169 | 179 | |
| 170 | 180 | // Make sure we're uploading to the right place. |
| 171 | - if (!empty($modSettings['automanage_attachments'])) |
|
| 172 | - automanage_attachments_check_directory(); |
|
| 181 | + if (!empty($modSettings['automanage_attachments'])) { |
|
| 182 | + automanage_attachments_check_directory(); |
|
| 183 | + } |
|
| 173 | 184 | |
| 174 | 185 | // Is the attachments folder actually there? |
| 175 | - if (!empty($context['dir_creation_error'])) |
|
| 176 | - $this->_generalErrors[] = $context['dir_creation_error']; |
|
| 186 | + if (!empty($context['dir_creation_error'])) { |
|
| 187 | + $this->_generalErrors[] = $context['dir_creation_error']; |
|
| 188 | + } |
|
| 177 | 189 | |
| 178 | 190 | // The current attach folder ha some issues... |
| 179 | 191 | elseif (!is_dir($this->_attchDir)) |
@@ -198,13 +210,12 @@ discard block |
||
| 198 | 210 | ); |
| 199 | 211 | list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request); |
| 200 | 212 | $smcFunc['db_free_result']($request); |
| 201 | - } |
|
| 202 | - |
|
| 203 | - else |
|
| 204 | - $context['attachments'] = array( |
|
| 213 | + } else { |
|
| 214 | + $context['attachments'] = array( |
|
| 205 | 215 | 'quantity' => 0, |
| 206 | 216 | 'total_size' => 0, |
| 207 | 217 | ); |
| 218 | + } |
|
| 208 | 219 | |
| 209 | 220 | // Check for other general errors here. |
| 210 | 221 | |
@@ -212,9 +223,10 @@ discard block |
||
| 212 | 223 | if (!empty($this->_generalErrors)) |
| 213 | 224 | { |
| 214 | 225 | // And delete the files 'cos they ain't going nowhere. |
| 215 | - foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
|
| 216 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
| 226 | + foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) { |
|
| 227 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
| 217 | 228 | unlink($_FILES['attachment']['tmp_name'][$n]); |
| 229 | + } |
|
| 218 | 230 | |
| 219 | 231 | $_FILES['attachment']['tmp_name'] = array(); |
| 220 | 232 | |
@@ -225,26 +237,29 @@ discard block |
||
| 225 | 237 | // Loop through $_FILES['attachment'] array and move each file to the current attachments folder. |
| 226 | 238 | foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
| 227 | 239 | { |
| 228 | - if ($_FILES['attachment']['name'][$n] == '') |
|
| 229 | - continue; |
|
| 240 | + if ($_FILES['attachment']['name'][$n] == '') { |
|
| 241 | + continue; |
|
| 242 | + } |
|
| 230 | 243 | |
| 231 | 244 | // First, let's first check for PHP upload errors. |
| 232 | 245 | $errors = array(); |
| 233 | 246 | if (!empty($_FILES['attachment']['error'][$n])) |
| 234 | 247 | { |
| 235 | - if ($_FILES['attachment']['error'][$n] == 2) |
|
| 236 | - $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
| 237 | - |
|
| 238 | - else |
|
| 239 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
| 248 | + if ($_FILES['attachment']['error'][$n] == 2) { |
|
| 249 | + $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
| 250 | + } else { |
|
| 251 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
| 252 | + } |
|
| 240 | 253 | |
| 241 | 254 | // Log this one, because... |
| 242 | - if ($_FILES['attachment']['error'][$n] == 6) |
|
| 243 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
| 255 | + if ($_FILES['attachment']['error'][$n] == 6) { |
|
| 256 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
| 257 | + } |
|
| 244 | 258 | |
| 245 | 259 | // Weird, no errors were cached, still fill out a generic one. |
| 246 | - if (empty($errors)) |
|
| 247 | - $errors[] = 'attach_php_error'; |
|
| 260 | + if (empty($errors)) { |
|
| 261 | + $errors[] = 'attach_php_error'; |
|
| 262 | + } |
|
| 248 | 263 | } |
| 249 | 264 | |
| 250 | 265 | // Try to move and rename the file before doing any more checks on it. |
@@ -256,8 +271,9 @@ discard block |
||
| 256 | 271 | { |
| 257 | 272 | // The reported MIME type of the attachment might not be reliable. |
| 258 | 273 | // Fortunately, PHP 5.3+ lets us easily verify the real MIME type. |
| 259 | - if (function_exists('mime_content_type')) |
|
| 260 | - $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
| 274 | + if (function_exists('mime_content_type')) { |
|
| 275 | + $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
| 276 | + } |
|
| 261 | 277 | |
| 262 | 278 | $_SESSION['temp_attachments'][$attachID] = array( |
| 263 | 279 | 'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])), |
@@ -269,16 +285,18 @@ discard block |
||
| 269 | 285 | ); |
| 270 | 286 | |
| 271 | 287 | // Move the file to the attachments folder with a temp name for now. |
| 272 | - if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) |
|
| 273 | - smf_chmod($destName, 0644); |
|
| 288 | + if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) { |
|
| 289 | + smf_chmod($destName, 0644); |
|
| 290 | + } |
|
| 274 | 291 | |
| 275 | 292 | // This is madness!! |
| 276 | 293 | else |
| 277 | 294 | { |
| 278 | 295 | // File couldn't be moved. |
| 279 | 296 | $_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout'; |
| 280 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
| 281 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 297 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
| 298 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 299 | + } |
|
| 282 | 300 | } |
| 283 | 301 | } |
| 284 | 302 | |
@@ -291,13 +309,15 @@ discard block |
||
| 291 | 309 | 'errors' => $errors, |
| 292 | 310 | ); |
| 293 | 311 | |
| 294 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
| 295 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 312 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
| 313 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 314 | + } |
|
| 296 | 315 | } |
| 297 | 316 | |
| 298 | 317 | // If there's no errors to this point. We still do need to apply some additional checks before we are finished. |
| 299 | - if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
|
| 300 | - attachmentChecks($attachID); |
|
| 318 | + if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) { |
|
| 319 | + attachmentChecks($attachID); |
|
| 320 | + } |
|
| 301 | 321 | } |
| 302 | 322 | |
| 303 | 323 | // Mod authors, finally a hook to hang an alternate attachment upload system upon |
@@ -344,14 +364,15 @@ discard block |
||
| 344 | 364 | |
| 345 | 365 | $_SESSION['already_attached'][$attachmentOptions['attachID']] = $attachmentOptions['attachID']; |
| 346 | 366 | |
| 347 | - if (!empty($attachmentOptions['thumb'])) |
|
| 348 | - $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
| 367 | + if (!empty($attachmentOptions['thumb'])) { |
|
| 368 | + $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
| 369 | + } |
|
| 349 | 370 | |
| 350 | - if ($this->_msg) |
|
| 351 | - assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
| 371 | + if ($this->_msg) { |
|
| 372 | + assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
| 373 | + } |
|
| 352 | 374 | } |
| 353 | - } |
|
| 354 | - else |
|
| 375 | + } else |
|
| 355 | 376 | { |
| 356 | 377 | // Sort out the errors for display and delete any associated files. |
| 357 | 378 | $log_these = array('attachments_no_create', 'attachments_no_write', 'attach_timeout', 'ran_out_of_space', 'cant_access_upload_path', 'attach_0_byte_file'); |
@@ -363,14 +384,16 @@ discard block |
||
| 363 | 384 | if (!is_array($error)) |
| 364 | 385 | { |
| 365 | 386 | $attachmentOptions['errors'][] = $txt[$error]; |
| 366 | - if (in_array($error, $log_these)) |
|
| 367 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 387 | + if (in_array($error, $log_these)) { |
|
| 388 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 389 | + } |
|
| 390 | + } else { |
|
| 391 | + $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
| 368 | 392 | } |
| 369 | - else |
|
| 370 | - $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
| 371 | 393 | } |
| 372 | - if (file_exists($attachment['tmp_name'])) |
|
| 373 | - unlink($attachment['tmp_name']); |
|
| 394 | + if (file_exists($attachment['tmp_name'])) { |
|
| 395 | + unlink($attachment['tmp_name']); |
|
| 396 | + } |
|
| 374 | 397 | } |
| 375 | 398 | |
| 376 | 399 | // You don't need to know. |
@@ -382,8 +405,9 @@ discard block |
||
| 382 | 405 | } |
| 383 | 406 | |
| 384 | 407 | // Temp save this on the db. |
| 385 | - if (!empty($_SESSION['already_attached'])) |
|
| 386 | - $this->_attachSuccess = $_SESSION['already_attached']; |
|
| 408 | + if (!empty($_SESSION['already_attached'])) { |
|
| 409 | + $this->_attachSuccess = $_SESSION['already_attached']; |
|
| 410 | + } |
|
| 387 | 411 | |
| 388 | 412 | unset($_SESSION['temp_attachments']); |
| 389 | 413 | } |
@@ -403,14 +427,16 @@ discard block |
||
| 403 | 427 | if ($this->_sa == 'add') |
| 404 | 428 | { |
| 405 | 429 | // Is there any generic errors? made some sense out of them! |
| 406 | - if ($this->_generalErrors) |
|
| 407 | - foreach ($this->_generalErrors as $k => $v) |
|
| 430 | + if ($this->_generalErrors) { |
|
| 431 | + foreach ($this->_generalErrors as $k => $v) |
|
| 408 | 432 | $this->_generalErrors[$k] = (is_array($v) ? vsprintf($txt[$v[0]], $v[1]) : $txt[$v]); |
| 433 | + } |
|
| 409 | 434 | |
| 410 | 435 | // Gotta urlencode the filename. |
| 411 | - if ($this->_attachResults) |
|
| 412 | - foreach ($this->_attachResults as $k => $v) |
|
| 436 | + if ($this->_attachResults) { |
|
| 437 | + foreach ($this->_attachResults as $k => $v) |
|
| 413 | 438 | $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
| 439 | + } |
|
| 414 | 440 | |
| 415 | 441 | $this->_response = array( |
| 416 | 442 | 'files' => $this->_attachResults ? $this->_attachResults : false, |
@@ -419,9 +445,10 @@ discard block |
||
| 419 | 445 | } |
| 420 | 446 | |
| 421 | 447 | // Rest of us mere mortals gets no special treatment... |
| 422 | - elseif (!empty($data)) |
|
| 423 | - if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
| 448 | + elseif (!empty($data)) { |
|
| 449 | + if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
| 424 | 450 | $this->_response['text'] = $txt[$data['text']]; |
| 451 | + } |
|
| 425 | 452 | } |
| 426 | 453 | |
| 427 | 454 | protected function sendResponse() |
@@ -430,11 +457,11 @@ discard block |
||
| 430 | 457 | |
| 431 | 458 | ob_end_clean(); |
| 432 | 459 | |
| 433 | - if (!empty($modSettings['CompressedOutput'])) |
|
| 434 | - @ob_start('ob_gzhandler'); |
|
| 435 | - |
|
| 436 | - else |
|
| 437 | - ob_start(); |
|
| 460 | + if (!empty($modSettings['CompressedOutput'])) { |
|
| 461 | + @ob_start('ob_gzhandler'); |
|
| 462 | + } else { |
|
| 463 | + ob_start(); |
|
| 464 | + } |
|
| 438 | 465 | |
| 439 | 466 | // Set the header. |
| 440 | 467 | header('content-type: application/json; charset='. $context['character_set'] .''); |
@@ -185,17 +185,21 @@ discard block |
||
| 185 | 185 | $tasksdir = $sourcedir . '/tasks'; |
| 186 | 186 | |
| 187 | 187 | # Make sure the paths are correct... at least try to fix them. |
| 188 | -if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt')) |
|
| 188 | +if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt')) { |
|
| 189 | 189 | $boarddir = dirname(__FILE__); |
| 190 | -if (!file_exists($sourcedir) && file_exists($boarddir . '/Sources')) |
|
| 190 | +} |
|
| 191 | +if (!file_exists($sourcedir) && file_exists($boarddir . '/Sources')) { |
|
| 191 | 192 | $sourcedir = $boarddir . '/Sources'; |
| 192 | -if (!file_exists($cachedir) && file_exists($boarddir . '/cache')) |
|
| 193 | +} |
|
| 194 | +if (!file_exists($cachedir) && file_exists($boarddir . '/cache')) { |
|
| 193 | 195 | $cachedir = $boarddir . '/cache'; |
| 196 | +} |
|
| 194 | 197 | |
| 195 | 198 | ########## Error-Catching ########## |
| 196 | 199 | # Note: You shouldn't touch these settings. |
| 197 | -if (file_exists((isset($cachedir) ? $cachedir : dirname(__FILE__)) . '/db_last_error.php')) |
|
| 200 | +if (file_exists((isset($cachedir) ? $cachedir : dirname(__FILE__)) . '/db_last_error.php')) { |
|
| 198 | 201 | include((isset($cachedir) ? $cachedir : dirname(__FILE__)) . '/db_last_error.php'); |
| 202 | +} |
|
| 199 | 203 | |
| 200 | 204 | if (!isset($db_last_error)) |
| 201 | 205 | { |
@@ -207,10 +211,11 @@ discard block |
||
| 207 | 211 | if (file_exists(dirname(__FILE__) . '/install.php')) |
| 208 | 212 | { |
| 209 | 213 | $secure = false; |
| 210 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
| 211 | - $secure = true; |
|
| 212 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
| 213 | - $secure = true; |
|
| 214 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
| 215 | + $secure = true; |
|
| 216 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
| 217 | + $secure = true; |
|
| 218 | + } |
|
| 214 | 219 | |
| 215 | 220 | header('location: http' . ($secure ? 's' : '') . '://' . (empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']) . (strtr(dirname($_SERVER['PHP_SELF']), '\\', '/') == '/' ? '' : strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')) . '/install.php'); exit; |
| 216 | 221 | } |