@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Get the latest post made on the system |
@@ -44,8 +45,9 @@ discard block |
||
| 44 | 45 | 'is_approved' => 1, |
| 45 | 46 | ) |
| 46 | 47 | ); |
| 47 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 48 | - return array(); |
|
| 48 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 49 | + return array(); |
|
| 50 | + } |
|
| 49 | 51 | $row = $smcFunc['db_fetch_assoc']($request); |
| 50 | 52 | $smcFunc['db_free_result']($request); |
| 51 | 53 | |
@@ -54,8 +56,9 @@ discard block |
||
| 54 | 56 | censorText($row['body']); |
| 55 | 57 | |
| 56 | 58 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled']), array('<br>' => ' '))); |
| 57 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
| 58 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 59 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
| 60 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 61 | + } |
|
| 59 | 62 | |
| 60 | 63 | // Send the data. |
| 61 | 64 | return array( |
@@ -83,15 +86,17 @@ discard block |
||
| 83 | 86 | |
| 84 | 87 | $context['is_redirect'] = false; |
| 85 | 88 | |
| 86 | - if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) |
|
| 87 | - $_REQUEST['start'] = 95; |
|
| 89 | + if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) { |
|
| 90 | + $_REQUEST['start'] = 95; |
|
| 91 | + } |
|
| 88 | 92 | |
| 89 | 93 | $query_parameters = array(); |
| 90 | 94 | if (!empty($_REQUEST['c']) && empty($board)) |
| 91 | 95 | { |
| 92 | 96 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
| 93 | - foreach ($_REQUEST['c'] as $i => $c) |
|
| 94 | - $_REQUEST['c'][$i] = (int) $c; |
|
| 97 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
| 98 | + $_REQUEST['c'][$i] = (int) $c; |
|
| 99 | + } |
|
| 95 | 100 | |
| 96 | 101 | if (count($_REQUEST['c']) == 1) |
| 97 | 102 | { |
@@ -107,8 +112,9 @@ discard block |
||
| 107 | 112 | list ($name) = $smcFunc['db_fetch_row']($request); |
| 108 | 113 | $smcFunc['db_free_result']($request); |
| 109 | 114 | |
| 110 | - if (empty($name)) |
|
| 111 | - fatal_lang_error('no_access', false); |
|
| 115 | + if (empty($name)) { |
|
| 116 | + fatal_lang_error('no_access', false); |
|
| 117 | + } |
|
| 112 | 118 | |
| 113 | 119 | $context['linktree'][] = array( |
| 114 | 120 | 'url' => $scripturl . '#c' . (int) $_REQUEST['c'], |
@@ -140,8 +146,9 @@ discard block |
||
| 140 | 146 | } |
| 141 | 147 | $smcFunc['db_free_result']($request); |
| 142 | 148 | |
| 143 | - if (empty($boards)) |
|
| 144 | - fatal_lang_error('error_no_boards_selected'); |
|
| 149 | + if (empty($boards)) { |
|
| 150 | + fatal_lang_error('error_no_boards_selected'); |
|
| 151 | + } |
|
| 145 | 152 | |
| 146 | 153 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
| 147 | 154 | $query_parameters['boards'] = $boards; |
@@ -155,12 +162,12 @@ discard block |
||
| 155 | 162 | } |
| 156 | 163 | |
| 157 | 164 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;c=' . implode(',', $_REQUEST['c']), $_REQUEST['start'], min(100, $total_cat_posts), 10, false); |
| 158 | - } |
|
| 159 | - elseif (!empty($_REQUEST['boards'])) |
|
| 165 | + } elseif (!empty($_REQUEST['boards'])) |
|
| 160 | 166 | { |
| 161 | 167 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
| 162 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
| 163 | - $_REQUEST['boards'][$i] = (int) $b; |
|
| 168 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
| 169 | + $_REQUEST['boards'][$i] = (int) $b; |
|
| 170 | + } |
|
| 164 | 171 | |
| 165 | 172 | $request = $smcFunc['db_query']('', ' |
| 166 | 173 | SELECT b.id_board, b.num_posts |
@@ -184,8 +191,9 @@ discard block |
||
| 184 | 191 | } |
| 185 | 192 | $smcFunc['db_free_result']($request); |
| 186 | 193 | |
| 187 | - if (empty($boards)) |
|
| 188 | - fatal_lang_error('error_no_boards_selected'); |
|
| 194 | + if (empty($boards)) { |
|
| 195 | + fatal_lang_error('error_no_boards_selected'); |
|
| 196 | + } |
|
| 189 | 197 | |
| 190 | 198 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
| 191 | 199 | $query_parameters['boards'] = $boards; |
@@ -199,8 +207,7 @@ discard block |
||
| 199 | 207 | } |
| 200 | 208 | |
| 201 | 209 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;boards=' . implode(',', $_REQUEST['boards']), $_REQUEST['start'], min(100, $total_posts), 10, false); |
| 202 | - } |
|
| 203 | - elseif (!empty($board)) |
|
| 210 | + } elseif (!empty($board)) |
|
| 204 | 211 | { |
| 205 | 212 | $request = $smcFunc['db_query']('', ' |
| 206 | 213 | SELECT num_posts, redirect |
@@ -233,8 +240,7 @@ discard block |
||
| 233 | 240 | } |
| 234 | 241 | |
| 235 | 242 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;board=' . $board . '.%1$d', $_REQUEST['start'], min(100, $total_posts), 10, true); |
| 236 | - } |
|
| 237 | - else |
|
| 243 | + } else |
|
| 238 | 244 | { |
| 239 | 245 | $query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
| 240 | 246 | AND b.id_board != {int:recycle_board}' : ''). ' |
@@ -269,8 +275,9 @@ discard block |
||
| 269 | 275 | ); |
| 270 | 276 | |
| 271 | 277 | // If you selected a redirection board, don't try getting posts for it... |
| 272 | - if ($context['is_redirect']) |
|
| 273 | - $messages = 0; |
|
| 278 | + if ($context['is_redirect']) { |
|
| 279 | + $messages = 0; |
|
| 280 | + } |
|
| 274 | 281 | |
| 275 | 282 | $key = 'recent-' . $user_info['id'] . '-' . md5(json_encode(array_diff_key($query_parameters, array('max_id_msg' => 0)))) . '-' . (int) $_REQUEST['start']; |
| 276 | 283 | if (!$context['is_redirect'] && (empty($modSettings['cache_enable']) || ($messages = cache_get_data($key, 120)) == null)) |
@@ -301,16 +308,18 @@ discard block |
||
| 301 | 308 | $query_this_board = str_replace('AND m.id_msg >= {int:max_id_msg}', '', $query_this_board); |
| 302 | 309 | $cache_results = true; |
| 303 | 310 | unset($query_parameters['max_id_msg']); |
| 311 | + } else { |
|
| 312 | + $done = true; |
|
| 304 | 313 | } |
| 305 | - else |
|
| 306 | - $done = true; |
|
| 307 | 314 | } |
| 308 | 315 | $messages = array(); |
| 309 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 310 | - $messages[] = $row['id_msg']; |
|
| 316 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 317 | + $messages[] = $row['id_msg']; |
|
| 318 | + } |
|
| 311 | 319 | $smcFunc['db_free_result']($request); |
| 312 | - if (!empty($cache_results)) |
|
| 313 | - cache_put_data($key, $messages, 120); |
|
| 320 | + if (!empty($cache_results)) { |
|
| 321 | + cache_put_data($key, $messages, 120); |
|
| 322 | + } |
|
| 314 | 323 | } |
| 315 | 324 | |
| 316 | 325 | // Nothing here... Or at least, nothing you can see... |
@@ -397,8 +406,9 @@ discard block |
||
| 397 | 406 | 'css_class' => 'windowbg', |
| 398 | 407 | ); |
| 399 | 408 | |
| 400 | - if ($user_info['id'] == $row['id_first_member']) |
|
| 401 | - $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
| 409 | + if ($user_info['id'] == $row['id_first_member']) { |
|
| 410 | + $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
| 411 | + } |
|
| 402 | 412 | $board_ids['any'][$row['id_board']][] = $row['id_msg']; |
| 403 | 413 | } |
| 404 | 414 | $smcFunc['db_free_result']($request); |
@@ -424,20 +434,23 @@ discard block |
||
| 424 | 434 | $boards = boardsAllowedTo($permission); |
| 425 | 435 | |
| 426 | 436 | // If 0 is the only thing in the array, they can do it everywhere! |
| 427 | - if (!empty($boards) && $boards[0] == 0) |
|
| 428 | - $boards = array_keys($board_ids[$type]); |
|
| 437 | + if (!empty($boards) && $boards[0] == 0) { |
|
| 438 | + $boards = array_keys($board_ids[$type]); |
|
| 439 | + } |
|
| 429 | 440 | |
| 430 | 441 | // Go through the boards, and look for posts they can do this on. |
| 431 | 442 | foreach ($boards as $board_id) |
| 432 | 443 | { |
| 433 | 444 | // Hmm, they have permission, but there are no topics from that board on this page. |
| 434 | - if (!isset($board_ids[$type][$board_id])) |
|
| 435 | - continue; |
|
| 445 | + if (!isset($board_ids[$type][$board_id])) { |
|
| 446 | + continue; |
|
| 447 | + } |
|
| 436 | 448 | |
| 437 | 449 | // Okay, looks like they can do it for these posts. |
| 438 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
| 439 | - if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
| 450 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
| 451 | + if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
| 440 | 452 | $context['posts'][$counter][$allowed] = true; |
| 453 | + } |
|
| 441 | 454 | } |
| 442 | 455 | } |
| 443 | 456 | } |
@@ -480,17 +493,19 @@ discard block |
||
| 480 | 493 | $context['showing_all_topics'] = isset($_GET['all']); |
| 481 | 494 | $context['start'] = (int) $_REQUEST['start']; |
| 482 | 495 | $context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
| 483 | - if ($_REQUEST['action'] == 'unread') |
|
| 484 | - $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
| 485 | - else |
|
| 486 | - $context['page_title'] = $txt['unread_replies']; |
|
| 496 | + if ($_REQUEST['action'] == 'unread') { |
|
| 497 | + $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
| 498 | + } else { |
|
| 499 | + $context['page_title'] = $txt['unread_replies']; |
|
| 500 | + } |
|
| 487 | 501 | |
| 488 | - if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) |
|
| 489 | - fatal_lang_error('loadavg_allunread_disabled', false); |
|
| 490 | - elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) |
|
| 491 | - fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
| 492 | - elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) |
|
| 493 | - fatal_lang_error('loadavg_unread_disabled', false); |
|
| 502 | + if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) { |
|
| 503 | + fatal_lang_error('loadavg_allunread_disabled', false); |
|
| 504 | + } elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) { |
|
| 505 | + fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
| 506 | + } elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) { |
|
| 507 | + fatal_lang_error('loadavg_unread_disabled', false); |
|
| 508 | + } |
|
| 494 | 509 | |
| 495 | 510 | // Parameters for the main query. |
| 496 | 511 | $query_parameters = array(); |
@@ -503,12 +518,14 @@ discard block |
||
| 503 | 518 | if (!empty($_REQUEST['boards'])) |
| 504 | 519 | { |
| 505 | 520 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
| 506 | - foreach ($_REQUEST['boards'] as $b) |
|
| 507 | - $boards[] = (int) $b; |
|
| 521 | + foreach ($_REQUEST['boards'] as $b) { |
|
| 522 | + $boards[] = (int) $b; |
|
| 523 | + } |
|
| 508 | 524 | } |
| 509 | 525 | |
| 510 | - if (!empty($board)) |
|
| 511 | - $boards[] = (int) $board; |
|
| 526 | + if (!empty($board)) { |
|
| 527 | + $boards[] = (int) $board; |
|
| 528 | + } |
|
| 512 | 529 | |
| 513 | 530 | // The easiest thing is to just get all the boards they can see, but since we've specified the top of tree we ignore some of them |
| 514 | 531 | $request = $smcFunc['db_query']('', ' |
@@ -525,30 +542,31 @@ discard block |
||
| 525 | 542 | ) |
| 526 | 543 | ); |
| 527 | 544 | |
| 528 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 529 | - if (in_array($row['id_parent'], $boards)) |
|
| 545 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 546 | + if (in_array($row['id_parent'], $boards)) |
|
| 530 | 547 | $boards[] = $row['id_board']; |
| 548 | + } |
|
| 531 | 549 | |
| 532 | 550 | $smcFunc['db_free_result']($request); |
| 533 | 551 | |
| 534 | - if (empty($boards)) |
|
| 535 | - fatal_lang_error('error_no_boards_selected'); |
|
| 552 | + if (empty($boards)) { |
|
| 553 | + fatal_lang_error('error_no_boards_selected'); |
|
| 554 | + } |
|
| 536 | 555 | |
| 537 | 556 | $query_this_board = 'id_board IN ({array_int:boards})'; |
| 538 | 557 | $query_parameters['boards'] = $boards; |
| 539 | 558 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%d'; |
| 540 | - } |
|
| 541 | - elseif (!empty($board)) |
|
| 559 | + } elseif (!empty($board)) |
|
| 542 | 560 | { |
| 543 | 561 | $query_this_board = 'id_board = {int:board}'; |
| 544 | 562 | $query_parameters['board'] = $board; |
| 545 | 563 | $context['querystring_board_limits'] = ';board=' . $board . '.%1$d'; |
| 546 | - } |
|
| 547 | - elseif (!empty($_REQUEST['boards'])) |
|
| 564 | + } elseif (!empty($_REQUEST['boards'])) |
|
| 548 | 565 | { |
| 549 | 566 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
| 550 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
| 551 | - $_REQUEST['boards'][$i] = (int) $b; |
|
| 567 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
| 568 | + $_REQUEST['boards'][$i] = (int) $b; |
|
| 569 | + } |
|
| 552 | 570 | |
| 553 | 571 | $request = $smcFunc['db_query']('', ' |
| 554 | 572 | SELECT b.id_board |
@@ -560,22 +578,24 @@ discard block |
||
| 560 | 578 | ) |
| 561 | 579 | ); |
| 562 | 580 | $boards = array(); |
| 563 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 564 | - $boards[] = $row['id_board']; |
|
| 581 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 582 | + $boards[] = $row['id_board']; |
|
| 583 | + } |
|
| 565 | 584 | $smcFunc['db_free_result']($request); |
| 566 | 585 | |
| 567 | - if (empty($boards)) |
|
| 568 | - fatal_lang_error('error_no_boards_selected'); |
|
| 586 | + if (empty($boards)) { |
|
| 587 | + fatal_lang_error('error_no_boards_selected'); |
|
| 588 | + } |
|
| 569 | 589 | |
| 570 | 590 | $query_this_board = 'id_board IN ({array_int:boards})'; |
| 571 | 591 | $query_parameters['boards'] = $boards; |
| 572 | 592 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%1$d'; |
| 573 | - } |
|
| 574 | - elseif (!empty($_REQUEST['c'])) |
|
| 593 | + } elseif (!empty($_REQUEST['c'])) |
|
| 575 | 594 | { |
| 576 | 595 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
| 577 | - foreach ($_REQUEST['c'] as $i => $c) |
|
| 578 | - $_REQUEST['c'][$i] = (int) $c; |
|
| 596 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
| 597 | + $_REQUEST['c'][$i] = (int) $c; |
|
| 598 | + } |
|
| 579 | 599 | |
| 580 | 600 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
| 581 | 601 | $request = $smcFunc['db_query']('', ' |
@@ -588,18 +608,19 @@ discard block |
||
| 588 | 608 | ) |
| 589 | 609 | ); |
| 590 | 610 | $boards = array(); |
| 591 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 592 | - $boards[] = $row['id_board']; |
|
| 611 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 612 | + $boards[] = $row['id_board']; |
|
| 613 | + } |
|
| 593 | 614 | $smcFunc['db_free_result']($request); |
| 594 | 615 | |
| 595 | - if (empty($boards)) |
|
| 596 | - fatal_lang_error('error_no_boards_selected'); |
|
| 616 | + if (empty($boards)) { |
|
| 617 | + fatal_lang_error('error_no_boards_selected'); |
|
| 618 | + } |
|
| 597 | 619 | |
| 598 | 620 | $query_this_board = 'id_board IN ({array_int:boards})'; |
| 599 | 621 | $query_parameters['boards'] = $boards; |
| 600 | 622 | $context['querystring_board_limits'] = ';c=' . implode(',', $_REQUEST['c']) . ';start=%1$d'; |
| 601 | - } |
|
| 602 | - else |
|
| 623 | + } else |
|
| 603 | 624 | { |
| 604 | 625 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
| 605 | 626 | // Don't bother to show deleted posts! |
@@ -613,12 +634,14 @@ discard block |
||
| 613 | 634 | ) |
| 614 | 635 | ); |
| 615 | 636 | $boards = array(); |
| 616 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 617 | - $boards[] = $row['id_board']; |
|
| 637 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 638 | + $boards[] = $row['id_board']; |
|
| 639 | + } |
|
| 618 | 640 | $smcFunc['db_free_result']($request); |
| 619 | 641 | |
| 620 | - if (empty($boards)) |
|
| 621 | - fatal_lang_error('error_no_boards_available', false); |
|
| 642 | + if (empty($boards)) { |
|
| 643 | + fatal_lang_error('error_no_boards_available', false); |
|
| 644 | + } |
|
| 622 | 645 | |
| 623 | 646 | $query_this_board = 'id_board IN ({array_int:boards})'; |
| 624 | 647 | $query_parameters['boards'] = $boards; |
@@ -680,13 +703,14 @@ discard block |
||
| 680 | 703 | 'name' => $_REQUEST['action'] == 'unread' ? $txt['unread_topics_visit'] : $txt['unread_replies'] |
| 681 | 704 | ); |
| 682 | 705 | |
| 683 | - if ($context['showing_all_topics']) |
|
| 684 | - $context['linktree'][] = array( |
|
| 706 | + if ($context['showing_all_topics']) { |
|
| 707 | + $context['linktree'][] = array( |
|
| 685 | 708 | 'url' => $scripturl . '?action=' . $_REQUEST['action'] . ';all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'], |
| 686 | 709 | 'name' => $txt['unread_topics_all'] |
| 687 | 710 | ); |
| 688 | - else |
|
| 689 | - $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
| 711 | + } else { |
|
| 712 | + $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
| 713 | + } |
|
| 690 | 714 | |
| 691 | 715 | loadTemplate('Recent'); |
| 692 | 716 | loadTemplate('MessageIndex'); |
@@ -694,8 +718,9 @@ discard block |
||
| 694 | 718 | |
| 695 | 719 | // Setup the default topic icons... for checking they exist and the like ;) |
| 696 | 720 | $context['icon_sources'] = array(); |
| 697 | - foreach ($context['stable_icons'] as $icon) |
|
| 698 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 721 | + foreach ($context['stable_icons'] as $icon) { |
|
| 722 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 723 | + } |
|
| 699 | 724 | |
| 700 | 725 | $is_topics = $_REQUEST['action'] == 'unread'; |
| 701 | 726 | |
@@ -725,8 +750,7 @@ discard block |
||
| 725 | 750 | ); |
| 726 | 751 | list ($earliest_msg) = $smcFunc['db_fetch_row']($request); |
| 727 | 752 | $smcFunc['db_free_result']($request); |
| 728 | - } |
|
| 729 | - else |
|
| 753 | + } else |
|
| 730 | 754 | { |
| 731 | 755 | $request = $smcFunc['db_query']('', ' |
| 732 | 756 | SELECT MIN(lmr.id_msg) |
@@ -742,14 +766,14 @@ discard block |
||
| 742 | 766 | } |
| 743 | 767 | |
| 744 | 768 | // This is needed in case of topics marked unread. |
| 745 | - if (empty($earliest_msg)) |
|
| 746 | - $earliest_msg = 0; |
|
| 747 | - else |
|
| 769 | + if (empty($earliest_msg)) { |
|
| 770 | + $earliest_msg = 0; |
|
| 771 | + } else |
|
| 748 | 772 | { |
| 749 | 773 | // Using caching, when possible, to ignore the below slow query. |
| 750 | - if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) |
|
| 751 | - $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
| 752 | - else |
|
| 774 | + if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) { |
|
| 775 | + $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
| 776 | + } else |
|
| 753 | 777 | { |
| 754 | 778 | // This query is pretty slow, but it's needed to ensure nothing crucial is ignored. |
| 755 | 779 | $request = $smcFunc['db_query']('', ' |
@@ -764,8 +788,9 @@ discard block |
||
| 764 | 788 | $smcFunc['db_free_result']($request); |
| 765 | 789 | |
| 766 | 790 | // In theory this could be zero, if the first ever post is unread, so fudge it ;) |
| 767 | - if ($earliest_msg2 == 0) |
|
| 768 | - $earliest_msg2 = -1; |
|
| 791 | + if ($earliest_msg2 == 0) { |
|
| 792 | + $earliest_msg2 = -1; |
|
| 793 | + } |
|
| 769 | 794 | |
| 770 | 795 | $_SESSION['cached_log_time'] = array(time(), $earliest_msg2); |
| 771 | 796 | } |
@@ -803,9 +828,9 @@ discard block |
||
| 803 | 828 | 'db_error_skip' => true, |
| 804 | 829 | )) |
| 805 | 830 | ) !== false; |
| 831 | + } else { |
|
| 832 | + $have_temp_table = false; |
|
| 806 | 833 | } |
| 807 | - else |
|
| 808 | - $have_temp_table = false; |
|
| 809 | 834 | |
| 810 | 835 | if ($context['showing_all_topics'] && $have_temp_table) |
| 811 | 836 | { |
@@ -851,14 +876,15 @@ discard block |
||
| 851 | 876 | |
| 852 | 877 | $context['topics'] = array(); |
| 853 | 878 | $context['no_topic_listing'] = true; |
| 854 | - if ($context['querystring_board_limits'] == ';start=%1$d') |
|
| 855 | - $context['querystring_board_limits'] = ''; |
|
| 856 | - else |
|
| 857 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 879 | + if ($context['querystring_board_limits'] == ';start=%1$d') { |
|
| 880 | + $context['querystring_board_limits'] = ''; |
|
| 881 | + } else { |
|
| 882 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 883 | + } |
|
| 858 | 884 | return; |
| 885 | + } else { |
|
| 886 | + $min_message = (int) $min_message; |
|
| 859 | 887 | } |
| 860 | - else |
|
| 861 | - $min_message = (int) $min_message; |
|
| 862 | 888 | |
| 863 | 889 | $request = $smcFunc['db_query']('substring', ' |
| 864 | 890 | SELECT ' . $select_clause . ' |
@@ -887,8 +913,7 @@ discard block |
||
| 887 | 913 | 'limit' => $context['topics_per_page'], |
| 888 | 914 | )) |
| 889 | 915 | ); |
| 890 | - } |
|
| 891 | - elseif ($is_topics) |
|
| 916 | + } elseif ($is_topics) |
|
| 892 | 917 | { |
| 893 | 918 | $request = $smcFunc['db_query']('', ' |
| 894 | 919 | SELECT COUNT(*), MIN(t.id_last_msg) |
@@ -939,14 +964,15 @@ discard block |
||
| 939 | 964 | |
| 940 | 965 | $context['topics'] = array(); |
| 941 | 966 | $context['no_topic_listing'] = true; |
| 942 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
| 943 | - $context['querystring_board_limits'] = ''; |
|
| 944 | - else |
|
| 945 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 967 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
| 968 | + $context['querystring_board_limits'] = ''; |
|
| 969 | + } else { |
|
| 970 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 971 | + } |
|
| 946 | 972 | return; |
| 973 | + } else { |
|
| 974 | + $min_message = (int) $min_message; |
|
| 947 | 975 | } |
| 948 | - else |
|
| 949 | - $min_message = (int) $min_message; |
|
| 950 | 976 | |
| 951 | 977 | $request = $smcFunc['db_query']('substring', ' |
| 952 | 978 | SELECT ' . $select_clause . ' |
@@ -976,8 +1002,7 @@ discard block |
||
| 976 | 1002 | 'limit' => $context['topics_per_page'], |
| 977 | 1003 | )) |
| 978 | 1004 | ); |
| 979 | - } |
|
| 980 | - else |
|
| 1005 | + } else |
|
| 981 | 1006 | { |
| 982 | 1007 | if ($modSettings['totalMessages'] > 100000) |
| 983 | 1008 | { |
@@ -1029,8 +1054,8 @@ discard block |
||
| 1029 | 1054 | ) !== false; |
| 1030 | 1055 | |
| 1031 | 1056 | // If that worked, create a sample of the log_topics table too. |
| 1032 | - if ($have_temp_table) |
|
| 1033 | - $have_temp_table = $smcFunc['db_query']('', ' |
|
| 1057 | + if ($have_temp_table) { |
|
| 1058 | + $have_temp_table = $smcFunc['db_query']('', ' |
|
| 1034 | 1059 | CREATE TEMPORARY TABLE {db_prefix}log_topics_posted_in ( |
| 1035 | 1060 | PRIMARY KEY (id_topic) |
| 1036 | 1061 | ) |
@@ -1043,6 +1068,7 @@ discard block |
||
| 1043 | 1068 | 'db_error_skip' => true, |
| 1044 | 1069 | ) |
| 1045 | 1070 | ) !== false; |
| 1071 | + } |
|
| 1046 | 1072 | } |
| 1047 | 1073 | |
| 1048 | 1074 | if (!empty($have_temp_table)) |
@@ -1058,8 +1084,7 @@ discard block |
||
| 1058 | 1084 | ); |
| 1059 | 1085 | list ($num_topics) = $smcFunc['db_fetch_row']($request); |
| 1060 | 1086 | $smcFunc['db_free_result']($request); |
| 1061 | - } |
|
| 1062 | - else |
|
| 1087 | + } else |
|
| 1063 | 1088 | { |
| 1064 | 1089 | $request = $smcFunc['db_query']('unread_fetch_topic_count', ' |
| 1065 | 1090 | SELECT COUNT(DISTINCT t.id_topic), MIN(t.id_last_msg) |
@@ -1100,15 +1125,16 @@ discard block |
||
| 1100 | 1125 | { |
| 1101 | 1126 | $context['topics'] = array(); |
| 1102 | 1127 | $context['no_topic_listing'] = true; |
| 1103 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
| 1104 | - $context['querystring_board_limits'] = ''; |
|
| 1105 | - else |
|
| 1106 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 1128 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
| 1129 | + $context['querystring_board_limits'] = ''; |
|
| 1130 | + } else { |
|
| 1131 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 1132 | + } |
|
| 1107 | 1133 | return; |
| 1108 | 1134 | } |
| 1109 | 1135 | |
| 1110 | - if (!empty($have_temp_table)) |
|
| 1111 | - $request = $smcFunc['db_query']('', ' |
|
| 1136 | + if (!empty($have_temp_table)) { |
|
| 1137 | + $request = $smcFunc['db_query']('', ' |
|
| 1112 | 1138 | SELECT t.id_topic |
| 1113 | 1139 | FROM {db_prefix}topics_posted_in AS t |
| 1114 | 1140 | LEFT JOIN {db_prefix}log_topics_posted_in AS lt ON (lt.id_topic = t.id_topic) |
@@ -1122,8 +1148,8 @@ discard block |
||
| 1122 | 1148 | 'limit' => $context['topics_per_page'], |
| 1123 | 1149 | )) |
| 1124 | 1150 | ); |
| 1125 | - else |
|
| 1126 | - $request = $smcFunc['db_query']('', ' |
|
| 1151 | + } else { |
|
| 1152 | + $request = $smcFunc['db_query']('', ' |
|
| 1127 | 1153 | SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].' |
| 1128 | 1154 | FROM {db_prefix}topics AS t |
| 1129 | 1155 | INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : ' |
@@ -1147,10 +1173,12 @@ discard block |
||
| 1147 | 1173 | 'sort' => $_REQUEST['sort'], |
| 1148 | 1174 | )) |
| 1149 | 1175 | ); |
| 1176 | + } |
|
| 1150 | 1177 | |
| 1151 | 1178 | $topics = array(); |
| 1152 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1153 | - $topics[] = $row['id_topic']; |
|
| 1179 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1180 | + $topics[] = $row['id_topic']; |
|
| 1181 | + } |
|
| 1154 | 1182 | $smcFunc['db_free_result']($request); |
| 1155 | 1183 | |
| 1156 | 1184 | // Sanity... where have you gone? |
@@ -1158,10 +1186,11 @@ discard block |
||
| 1158 | 1186 | { |
| 1159 | 1187 | $context['topics'] = array(); |
| 1160 | 1188 | $context['no_topic_listing'] = true; |
| 1161 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
| 1162 | - $context['querystring_board_limits'] = ''; |
|
| 1163 | - else |
|
| 1164 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 1189 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
| 1190 | + $context['querystring_board_limits'] = ''; |
|
| 1191 | + } else { |
|
| 1192 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 1193 | + } |
|
| 1165 | 1194 | return; |
| 1166 | 1195 | } |
| 1167 | 1196 | |
@@ -1195,8 +1224,9 @@ discard block |
||
| 1195 | 1224 | |
| 1196 | 1225 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1197 | 1226 | { |
| 1198 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
| 1199 | - continue; |
|
| 1227 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
| 1228 | + continue; |
|
| 1229 | + } |
|
| 1200 | 1230 | |
| 1201 | 1231 | $topic_ids[] = $row['id_topic']; |
| 1202 | 1232 | |
@@ -1204,11 +1234,13 @@ discard block |
||
| 1204 | 1234 | { |
| 1205 | 1235 | // Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise. |
| 1206 | 1236 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
| 1207 | - if ($smcFunc['strlen']($row['first_body']) > 128) |
|
| 1208 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
| 1237 | + if ($smcFunc['strlen']($row['first_body']) > 128) { |
|
| 1238 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
| 1239 | + } |
|
| 1209 | 1240 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
| 1210 | - if ($smcFunc['strlen']($row['last_body']) > 128) |
|
| 1211 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
| 1241 | + if ($smcFunc['strlen']($row['last_body']) > 128) { |
|
| 1242 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
| 1243 | + } |
|
| 1212 | 1244 | |
| 1213 | 1245 | // Censor the subject and message preview. |
| 1214 | 1246 | censorText($row['first_subject']); |
@@ -1219,23 +1251,22 @@ discard block |
||
| 1219 | 1251 | { |
| 1220 | 1252 | $row['last_subject'] = $row['first_subject']; |
| 1221 | 1253 | $row['last_body'] = $row['first_body']; |
| 1222 | - } |
|
| 1223 | - else |
|
| 1254 | + } else |
|
| 1224 | 1255 | { |
| 1225 | 1256 | censorText($row['last_subject']); |
| 1226 | 1257 | censorText($row['last_body']); |
| 1227 | 1258 | } |
| 1228 | - } |
|
| 1229 | - else |
|
| 1259 | + } else |
|
| 1230 | 1260 | { |
| 1231 | 1261 | $row['first_body'] = ''; |
| 1232 | 1262 | $row['last_body'] = ''; |
| 1233 | 1263 | censorText($row['first_subject']); |
| 1234 | 1264 | |
| 1235 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
| 1236 | - $row['last_subject'] = $row['first_subject']; |
|
| 1237 | - else |
|
| 1238 | - censorText($row['last_subject']); |
|
| 1265 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
| 1266 | + $row['last_subject'] = $row['first_subject']; |
|
| 1267 | + } else { |
|
| 1268 | + censorText($row['last_subject']); |
|
| 1269 | + } |
|
| 1239 | 1270 | } |
| 1240 | 1271 | |
| 1241 | 1272 | // Decide how many pages the topic should have. |
@@ -1247,22 +1278,24 @@ discard block |
||
| 1247 | 1278 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $topic_length, $messages_per_page, true, false); |
| 1248 | 1279 | |
| 1249 | 1280 | // If we can use all, show all. |
| 1250 | - if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) |
|
| 1251 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 1281 | + if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) { |
|
| 1282 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 1283 | + } |
|
| 1284 | + } else { |
|
| 1285 | + $pages = ''; |
|
| 1252 | 1286 | } |
| 1253 | 1287 | |
| 1254 | - else |
|
| 1255 | - $pages = ''; |
|
| 1256 | - |
|
| 1257 | 1288 | // We need to check the topic icons exist... you can never be too sure! |
| 1258 | 1289 | if (!empty($modSettings['messageIconChecks_enable'])) |
| 1259 | 1290 | { |
| 1260 | 1291 | // First icon first... as you'd expect. |
| 1261 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 1262 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1292 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 1293 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1294 | + } |
|
| 1263 | 1295 | // Last icon... last... duh. |
| 1264 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 1265 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1296 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 1297 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1298 | + } |
|
| 1266 | 1299 | } |
| 1267 | 1300 | |
| 1268 | 1301 | // Force the recycling icon if appropriate |
@@ -1276,12 +1309,14 @@ discard block |
||
| 1276 | 1309 | $colorClass = 'windowbg'; |
| 1277 | 1310 | |
| 1278 | 1311 | // Sticky topics should get a different color, too. |
| 1279 | - if ($row['is_sticky']) |
|
| 1280 | - $colorClass .= ' sticky'; |
|
| 1312 | + if ($row['is_sticky']) { |
|
| 1313 | + $colorClass .= ' sticky'; |
|
| 1314 | + } |
|
| 1281 | 1315 | |
| 1282 | 1316 | // Locked topics get special treatment as well. |
| 1283 | - if ($row['locked']) |
|
| 1284 | - $colorClass .= ' locked'; |
|
| 1317 | + if ($row['locked']) { |
|
| 1318 | + $colorClass .= ' locked'; |
|
| 1319 | + } |
|
| 1285 | 1320 | |
| 1286 | 1321 | // And build the array. |
| 1287 | 1322 | $context['topics'][$row['id_topic']] = array( |
@@ -1378,8 +1413,9 @@ discard block |
||
| 1378 | 1413 | ); |
| 1379 | 1414 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1380 | 1415 | { |
| 1381 | - if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) |
|
| 1382 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 1416 | + if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) { |
|
| 1417 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 1418 | + } |
|
| 1383 | 1419 | } |
| 1384 | 1420 | $smcFunc['db_free_result']($result); |
| 1385 | 1421 | } |
@@ -1394,28 +1430,30 @@ discard block |
||
| 1394 | 1430 | 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']), |
| 1395 | 1431 | ); |
| 1396 | 1432 | |
| 1397 | - if ($context['showCheckboxes']) |
|
| 1398 | - $context['recent_buttons']['markselectread'] = array( |
|
| 1433 | + if ($context['showCheckboxes']) { |
|
| 1434 | + $context['recent_buttons']['markselectread'] = array( |
|
| 1399 | 1435 | 'text' => 'quick_mod_markread', |
| 1400 | 1436 | 'image' => 'markselectedread.png', |
| 1401 | 1437 | 'url' => 'javascript:document.quickModForm.submit();', |
| 1402 | 1438 | ); |
| 1439 | + } |
|
| 1403 | 1440 | |
| 1404 | - if (!empty($context['topics']) && !$context['showing_all_topics']) |
|
| 1405 | - $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
| 1406 | - } |
|
| 1407 | - elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
| 1441 | + if (!empty($context['topics']) && !$context['showing_all_topics']) { |
|
| 1442 | + $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
| 1443 | + } |
|
| 1444 | + } elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
| 1408 | 1445 | { |
| 1409 | 1446 | $context['recent_buttons'] = array( |
| 1410 | 1447 | 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']), |
| 1411 | 1448 | ); |
| 1412 | 1449 | |
| 1413 | - if ($context['showCheckboxes']) |
|
| 1414 | - $context['recent_buttons']['markselectread'] = array( |
|
| 1450 | + if ($context['showCheckboxes']) { |
|
| 1451 | + $context['recent_buttons']['markselectread'] = array( |
|
| 1415 | 1452 | 'text' => 'quick_mod_markread', |
| 1416 | 1453 | 'image' => 'markselectedread.png', |
| 1417 | 1454 | 'url' => 'javascript:document.quickModForm.submit();', |
| 1418 | 1455 | ); |
| 1456 | + } |
|
| 1419 | 1457 | } |
| 1420 | 1458 | |
| 1421 | 1459 | // Allow mods to add additional buttons here |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Prepares the information from the moderation log for viewing. |
@@ -32,14 +33,16 @@ discard block |
||
| 32 | 33 | |
| 33 | 34 | // Are we looking at the moderation log or the administration log. |
| 34 | 35 | $context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1; |
| 35 | - if ($context['log_type'] == 3) |
|
| 36 | - isAllowedTo('admin_forum'); |
|
| 36 | + if ($context['log_type'] == 3) { |
|
| 37 | + isAllowedTo('admin_forum'); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | // These change dependant on whether we are viewing the moderation or admin log. |
| 39 | - if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') |
|
| 40 | - $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
| 41 | - else |
|
| 42 | - $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
| 41 | + if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') { |
|
| 42 | + $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
| 43 | + } else { |
|
| 44 | + $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
| 45 | + } |
|
| 43 | 46 | |
| 44 | 47 | $context['can_delete'] = allowedTo('admin_forum'); |
| 45 | 48 | |
@@ -67,8 +70,7 @@ discard block |
||
| 67 | 70 | $log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate'; |
| 68 | 71 | logAction('clearlog_' . $log_type, array(), $log_type); |
| 69 | 72 | |
| 70 | - } |
|
| 71 | - elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
| 73 | + } elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
| 72 | 74 | { |
| 73 | 75 | checkSession(); |
| 74 | 76 | validateToken('mod-ml'); |
@@ -114,15 +116,17 @@ discard block |
||
| 114 | 116 | 'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip']) |
| 115 | 117 | ); |
| 116 | 118 | |
| 117 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
| 118 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
| 119 | - else |
|
| 120 | - $search_params_string = $search_params['string']; |
|
| 119 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
| 120 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
| 121 | + } else { |
|
| 122 | + $search_params_string = $search_params['string']; |
|
| 123 | + } |
|
| 121 | 124 | |
| 122 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
| 123 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
| 124 | - else |
|
| 125 | - $search_params_type = $search_params['type']; |
|
| 125 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
| 126 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
| 127 | + } else { |
|
| 128 | + $search_params_type = $search_params['type']; |
|
| 129 | + } |
|
| 126 | 130 | |
| 127 | 131 | $search_params_column = $searchTypes[$search_params_type]['sql']; |
| 128 | 132 | $search_params = array( |
@@ -297,13 +301,14 @@ discard block |
||
| 297 | 301 | $context['sub_template'] = 'show_list'; |
| 298 | 302 | $context['default_list'] = 'moderation_log_list'; |
| 299 | 303 | |
| 300 | - if (isset($context['moderation_menu_name'])) |
|
| 301 | - $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
| 304 | + if (isset($context['moderation_menu_name'])) { |
|
| 305 | + $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
| 302 | 306 | 'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'], |
| 303 | 307 | 'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog', |
| 304 | 308 | 'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc'] |
| 305 | 309 | ); |
| 306 | -} |
|
| 310 | + } |
|
| 311 | + } |
|
| 307 | 312 | |
| 308 | 313 | /** |
| 309 | 314 | * Get the number of mod log entries. |
@@ -407,30 +412,35 @@ discard block |
||
| 407 | 412 | // Add on some of the column stuff info |
| 408 | 413 | if (!empty($row['id_board'])) |
| 409 | 414 | { |
| 410 | - if ($row['action'] == 'move') |
|
| 411 | - $row['extra']['board_to'] = $row['id_board']; |
|
| 412 | - else |
|
| 413 | - $row['extra']['board'] = $row['id_board']; |
|
| 415 | + if ($row['action'] == 'move') { |
|
| 416 | + $row['extra']['board_to'] = $row['id_board']; |
|
| 417 | + } else { |
|
| 418 | + $row['extra']['board'] = $row['id_board']; |
|
| 419 | + } |
|
| 414 | 420 | } |
| 415 | 421 | |
| 416 | - if (!empty($row['id_topic'])) |
|
| 417 | - $row['extra']['topic'] = $row['id_topic']; |
|
| 418 | - if (!empty($row['id_msg'])) |
|
| 419 | - $row['extra']['message'] = $row['id_msg']; |
|
| 422 | + if (!empty($row['id_topic'])) { |
|
| 423 | + $row['extra']['topic'] = $row['id_topic']; |
|
| 424 | + } |
|
| 425 | + if (!empty($row['id_msg'])) { |
|
| 426 | + $row['extra']['message'] = $row['id_msg']; |
|
| 427 | + } |
|
| 420 | 428 | |
| 421 | 429 | // Is this associated with a topic? |
| 422 | - if (isset($row['extra']['topic'])) |
|
| 423 | - $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
| 424 | - if (isset($row['extra']['new_topic'])) |
|
| 425 | - $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
| 430 | + if (isset($row['extra']['topic'])) { |
|
| 431 | + $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
| 432 | + } |
|
| 433 | + if (isset($row['extra']['new_topic'])) { |
|
| 434 | + $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
| 435 | + } |
|
| 426 | 436 | |
| 427 | 437 | // How about a member? |
| 428 | 438 | if (isset($row['extra']['member'])) |
| 429 | 439 | { |
| 430 | 440 | // Guests don't have names! |
| 431 | - if (empty($row['extra']['member'])) |
|
| 432 | - $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
| 433 | - else |
|
| 441 | + if (empty($row['extra']['member'])) { |
|
| 442 | + $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
| 443 | + } else |
|
| 434 | 444 | { |
| 435 | 445 | // Try to find it... |
| 436 | 446 | $members[(int) $row['extra']['member']][] = $row['id_action']; |
@@ -438,35 +448,42 @@ discard block |
||
| 438 | 448 | } |
| 439 | 449 | |
| 440 | 450 | // Associated with a board? |
| 441 | - if (isset($row['extra']['board_to'])) |
|
| 442 | - $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
| 443 | - if (isset($row['extra']['board_from'])) |
|
| 444 | - $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
| 445 | - if (isset($row['extra']['board'])) |
|
| 446 | - $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
| 451 | + if (isset($row['extra']['board_to'])) { |
|
| 452 | + $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
| 453 | + } |
|
| 454 | + if (isset($row['extra']['board_from'])) { |
|
| 455 | + $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
| 456 | + } |
|
| 457 | + if (isset($row['extra']['board'])) { |
|
| 458 | + $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
| 459 | + } |
|
| 447 | 460 | |
| 448 | 461 | // A message? |
| 449 | - if (isset($row['extra']['message'])) |
|
| 450 | - $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
| 462 | + if (isset($row['extra']['message'])) { |
|
| 463 | + $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
| 464 | + } |
|
| 451 | 465 | |
| 452 | 466 | // IP Info? |
| 453 | - if (isset($row['extra']['ip_range'])) |
|
| 454 | - if ($seeIP) |
|
| 467 | + if (isset($row['extra']['ip_range'])) { |
|
| 468 | + if ($seeIP) |
|
| 455 | 469 | $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>'; |
| 456 | - else |
|
| 457 | - $row['extra']['ip_range'] = $txt['logged']; |
|
| 470 | + } else { |
|
| 471 | + $row['extra']['ip_range'] = $txt['logged']; |
|
| 472 | + } |
|
| 458 | 473 | |
| 459 | 474 | // Email? |
| 460 | - if (isset($row['extra']['email'])) |
|
| 461 | - $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
| 475 | + if (isset($row['extra']['email'])) { |
|
| 476 | + $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
| 477 | + } |
|
| 462 | 478 | |
| 463 | 479 | // Bans are complex. |
| 464 | 480 | if ($row['action'] == 'ban' || $row['action'] == 'banremove') |
| 465 | 481 | { |
| 466 | 482 | $row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')]; |
| 467 | - foreach (array('member', 'email', 'ip_range', 'hostname') as $type) |
|
| 468 | - if (isset($row['extra'][$type])) |
|
| 483 | + foreach (array('member', 'email', 'ip_range', 'hostname') as $type) { |
|
| 484 | + if (isset($row['extra'][$type])) |
|
| 469 | 485 | $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type]; |
| 486 | + } |
|
| 470 | 487 | } |
| 471 | 488 | |
| 472 | 489 | // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details. |
@@ -502,12 +519,13 @@ discard block |
||
| 502 | 519 | foreach ($boards[$row['id_board']] as $action) |
| 503 | 520 | { |
| 504 | 521 | // Make the board number into a link - dealing with moving too. |
| 505 | - if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) |
|
| 506 | - $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 507 | - elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) |
|
| 508 | - $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 509 | - elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) |
|
| 510 | - $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 522 | + if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) { |
|
| 523 | + $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 524 | + } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) { |
|
| 525 | + $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 526 | + } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) { |
|
| 527 | + $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 528 | + } |
|
| 511 | 529 | } |
| 512 | 530 | } |
| 513 | 531 | $smcFunc['db_free_result']($request); |
@@ -541,10 +559,11 @@ discard block |
||
| 541 | 559 | ); |
| 542 | 560 | |
| 543 | 561 | // Make the topic number into a link - dealing with splitting too. |
| 544 | - if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) |
|
| 545 | - $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 546 | - elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) |
|
| 547 | - $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 562 | + if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) { |
|
| 563 | + $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 564 | + } elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) { |
|
| 565 | + $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 566 | + } |
|
| 548 | 567 | } |
| 549 | 568 | } |
| 550 | 569 | $smcFunc['db_free_result']($request); |
@@ -577,8 +596,9 @@ discard block |
||
| 577 | 596 | ); |
| 578 | 597 | |
| 579 | 598 | // Make the message number into a link. |
| 580 | - if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) |
|
| 581 | - $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 599 | + if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) { |
|
| 600 | + $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 601 | + } |
|
| 582 | 602 | } |
| 583 | 603 | } |
| 584 | 604 | $smcFunc['db_free_result']($request); |
@@ -618,25 +638,29 @@ discard block |
||
| 618 | 638 | foreach ($entries as $k => $entry) |
| 619 | 639 | { |
| 620 | 640 | // Make any message info links so its easier to go find that message. |
| 621 | - if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) |
|
| 622 | - $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
| 641 | + if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) { |
|
| 642 | + $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
| 643 | + } |
|
| 623 | 644 | |
| 624 | 645 | // Mark up any deleted members, topics and boards. |
| 625 | - foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) |
|
| 626 | - if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
| 646 | + foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) { |
|
| 647 | + if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
| 627 | 648 | $entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]); |
| 649 | + } |
|
| 628 | 650 | |
| 629 | 651 | if (isset($entry['extra']['report'])) |
| 630 | 652 | { |
| 631 | 653 | // Member profile reports go in a different area |
| 632 | - if (stristr($entry['action'], 'user_report')) |
|
| 633 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 634 | - else |
|
| 635 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 654 | + if (stristr($entry['action'], 'user_report')) { |
|
| 655 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 656 | + } else { |
|
| 657 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 658 | + } |
|
| 636 | 659 | } |
| 637 | 660 | |
| 638 | - if (empty($entries[$k]['action_text'])) |
|
| 639 | - $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
| 661 | + if (empty($entries[$k]['action_text'])) { |
|
| 662 | + $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
| 663 | + } |
|
| 640 | 664 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
| 641 | 665 | function ($matches) use ($entries, $k) |
| 642 | 666 | { |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Class browser_detector |
@@ -55,20 +56,25 @@ discard block |
||
| 55 | 56 | $this->_browsers['needs_size_fix'] = false; |
| 56 | 57 | |
| 57 | 58 | // One at a time, one at a time, and in this order too |
| 58 | - if ($this->isOpera()) |
|
| 59 | - $this->setupOpera(); |
|
| 59 | + if ($this->isOpera()) { |
|
| 60 | + $this->setupOpera(); |
|
| 61 | + } |
|
| 60 | 62 | // Meh... |
| 61 | - elseif ($this->isEdge()) |
|
| 62 | - $this->setupEdge(); |
|
| 63 | + elseif ($this->isEdge()) { |
|
| 64 | + $this->setupEdge(); |
|
| 65 | + } |
|
| 63 | 66 | // Them webkits need to be set up too |
| 64 | - elseif ($this->isWebkit()) |
|
| 65 | - $this->setupWebkit(); |
|
| 67 | + elseif ($this->isWebkit()) { |
|
| 68 | + $this->setupWebkit(); |
|
| 69 | + } |
|
| 66 | 70 | // We may have work to do on Firefox... |
| 67 | - elseif ($this->isFirefox()) |
|
| 68 | - $this->setupFirefox(); |
|
| 71 | + elseif ($this->isFirefox()) { |
|
| 72 | + $this->setupFirefox(); |
|
| 73 | + } |
|
| 69 | 74 | // Old friend, old frenemy |
| 70 | - elseif ($this->isIe()) |
|
| 71 | - $this->setupIe(); |
|
| 75 | + elseif ($this->isIe()) { |
|
| 76 | + $this->setupIe(); |
|
| 77 | + } |
|
| 72 | 78 | |
| 73 | 79 | // Just a few mobile checks |
| 74 | 80 | $this->isOperaMini(); |
@@ -84,11 +90,12 @@ discard block |
||
| 84 | 90 | $this->_browsers['possibly_robot'] = !empty($user_info['possibly_robot']); |
| 85 | 91 | |
| 86 | 92 | // Robots shouldn't be logging in or registering. So, they aren't a bot. Better to be wrong than sorry (or people won't be able to log in!), anyway. |
| 87 | - if ((isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('login', 'login2', 'register', 'signup'))) || !$user_info['is_guest']) |
|
| 88 | - $this->_browsers['possibly_robot'] = false; |
|
| 93 | + if ((isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('login', 'login2', 'register', 'signup'))) || !$user_info['is_guest']) { |
|
| 94 | + $this->_browsers['possibly_robot'] = false; |
|
| 95 | + } |
|
| 96 | + } else { |
|
| 97 | + $this->_browsers['possibly_robot'] = false; |
|
| 89 | 98 | } |
| 90 | - else |
|
| 91 | - $this->_browsers['possibly_robot'] = false; |
|
| 92 | 99 | |
| 93 | 100 | // Fill out the historical array as needed to support old mods that don't use isBrowser |
| 94 | 101 | $this->fillInformation(); |
@@ -106,8 +113,9 @@ discard block |
||
| 106 | 113 | */ |
| 107 | 114 | function isOpera() |
| 108 | 115 | { |
| 109 | - if (!isset($this->_browsers['is_opera'])) |
|
| 110 | - $this->_browsers['is_opera'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false; |
|
| 116 | + if (!isset($this->_browsers['is_opera'])) { |
|
| 117 | + $this->_browsers['is_opera'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false; |
|
| 118 | + } |
|
| 111 | 119 | return $this->_browsers['is_opera']; |
| 112 | 120 | } |
| 113 | 121 | |
@@ -118,8 +126,9 @@ discard block |
||
| 118 | 126 | function isIe() |
| 119 | 127 | { |
| 120 | 128 | // I'm IE, Yes I'm the real IE; All you other IEs are just imitating. |
| 121 | - if (!isset($this->_browsers['is_ie'])) |
|
| 122 | - $this->_browsers['is_ie'] = !$this->isOpera() && !$this->isGecko() && !$this->isWebTv() && preg_match('~MSIE \d+~', $_SERVER['HTTP_USER_AGENT']) === 1; |
|
| 129 | + if (!isset($this->_browsers['is_ie'])) { |
|
| 130 | + $this->_browsers['is_ie'] = !$this->isOpera() && !$this->isGecko() && !$this->isWebTv() && preg_match('~MSIE \d+~', $_SERVER['HTTP_USER_AGENT']) === 1; |
|
| 131 | + } |
|
| 123 | 132 | return $this->_browsers['is_ie']; |
| 124 | 133 | } |
| 125 | 134 | |
@@ -131,8 +140,9 @@ discard block |
||
| 131 | 140 | { |
| 132 | 141 | // IE11 is a bit different than earlier versions |
| 133 | 142 | // The isGecko() part is to ensure we get this right... |
| 134 | - if (!isset($this->_browsers['is_ie11'])) |
|
| 135 | - $this->_browsers['is_ie11'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false && $this->isGecko(); |
|
| 143 | + if (!isset($this->_browsers['is_ie11'])) { |
|
| 144 | + $this->_browsers['is_ie11'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false && $this->isGecko(); |
|
| 145 | + } |
|
| 136 | 146 | return $this->_browsers['is_ie11']; |
| 137 | 147 | } |
| 138 | 148 | |
@@ -142,8 +152,9 @@ discard block |
||
| 142 | 152 | */ |
| 143 | 153 | function isEdge() |
| 144 | 154 | { |
| 145 | - if (!isset($this->_browsers['is_edge'])) |
|
| 146 | - $this->_browsers['is_edge'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Edge') !== false; |
|
| 155 | + if (!isset($this->_browsers['is_edge'])) { |
|
| 156 | + $this->_browsers['is_edge'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Edge') !== false; |
|
| 157 | + } |
|
| 147 | 158 | return $this->_browsers['is_edge']; |
| 148 | 159 | } |
| 149 | 160 | |
@@ -153,8 +164,9 @@ discard block |
||
| 153 | 164 | */ |
| 154 | 165 | function isWebkit() |
| 155 | 166 | { |
| 156 | - if (!isset($this->_browsers['is_webkit'])) |
|
| 157 | - $this->_browsers['is_webkit'] = strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false; |
|
| 167 | + if (!isset($this->_browsers['is_webkit'])) { |
|
| 168 | + $this->_browsers['is_webkit'] = strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false; |
|
| 169 | + } |
|
| 158 | 170 | return $this->_browsers['is_webkit']; |
| 159 | 171 | } |
| 160 | 172 | |
@@ -164,8 +176,9 @@ discard block |
||
| 164 | 176 | */ |
| 165 | 177 | function isFirefox() |
| 166 | 178 | { |
| 167 | - if (!isset($this->_browsers['is_firefox'])) |
|
| 168 | - $this->_browsers['is_firefox'] = preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/~', $_SERVER['HTTP_USER_AGENT']) === 1 && $this->isGecko(); |
|
| 179 | + if (!isset($this->_browsers['is_firefox'])) { |
|
| 180 | + $this->_browsers['is_firefox'] = preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/~', $_SERVER['HTTP_USER_AGENT']) === 1 && $this->isGecko(); |
|
| 181 | + } |
|
| 169 | 182 | return $this->_browsers['is_firefox']; |
| 170 | 183 | } |
| 171 | 184 | |
@@ -175,8 +188,9 @@ discard block |
||
| 175 | 188 | */ |
| 176 | 189 | function isWebTv() |
| 177 | 190 | { |
| 178 | - if (!isset($this->_browsers['is_web_tv'])) |
|
| 179 | - $this->_browsers['is_web_tv'] = strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false; |
|
| 191 | + if (!isset($this->_browsers['is_web_tv'])) { |
|
| 192 | + $this->_browsers['is_web_tv'] = strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false; |
|
| 193 | + } |
|
| 180 | 194 | return $this->_browsers['is_web_tv']; |
| 181 | 195 | } |
| 182 | 196 | |
@@ -186,8 +200,9 @@ discard block |
||
| 186 | 200 | */ |
| 187 | 201 | function isKonqueror() |
| 188 | 202 | { |
| 189 | - if (!isset($this->_browsers['is_konqueror'])) |
|
| 190 | - $this->_browsers['is_konqueror'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false; |
|
| 203 | + if (!isset($this->_browsers['is_konqueror'])) { |
|
| 204 | + $this->_browsers['is_konqueror'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false; |
|
| 205 | + } |
|
| 191 | 206 | return $this->_browsers['is_konqueror']; |
| 192 | 207 | } |
| 193 | 208 | |
@@ -197,8 +212,9 @@ discard block |
||
| 197 | 212 | */ |
| 198 | 213 | function isGecko() |
| 199 | 214 | { |
| 200 | - if (!isset($this->_browsers['is_gecko'])) |
|
| 201 | - $this->_browsers['is_gecko'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$this->isWebkit() && !$this->isKonqueror(); |
|
| 215 | + if (!isset($this->_browsers['is_gecko'])) { |
|
| 216 | + $this->_browsers['is_gecko'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$this->isWebkit() && !$this->isKonqueror(); |
|
| 217 | + } |
|
| 202 | 218 | return $this->_browsers['is_gecko']; |
| 203 | 219 | } |
| 204 | 220 | |
@@ -208,10 +224,12 @@ discard block |
||
| 208 | 224 | */ |
| 209 | 225 | function isOperaMini() |
| 210 | 226 | { |
| 211 | - if (!isset($this->_browsers['is_opera_mini'])) |
|
| 212 | - $this->_browsers['is_opera_mini'] = (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) || stripos($_SERVER['HTTP_USER_AGENT'], 'opera mini') !== false); |
|
| 213 | - if ($this->_browsers['is_opera_mini']) |
|
| 214 | - $this->_is_mobile = true; |
|
| 227 | + if (!isset($this->_browsers['is_opera_mini'])) { |
|
| 228 | + $this->_browsers['is_opera_mini'] = (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) || stripos($_SERVER['HTTP_USER_AGENT'], 'opera mini') !== false); |
|
| 229 | + } |
|
| 230 | + if ($this->_browsers['is_opera_mini']) { |
|
| 231 | + $this->_is_mobile = true; |
|
| 232 | + } |
|
| 215 | 233 | return $this->_browsers['is_opera_mini']; |
| 216 | 234 | } |
| 217 | 235 | |
@@ -221,10 +239,12 @@ discard block |
||
| 221 | 239 | */ |
| 222 | 240 | function isOperaMobi() |
| 223 | 241 | { |
| 224 | - if (!isset($this->_browsers['is_opera_mobi'])) |
|
| 225 | - $this->_browsers['is_opera_mobi'] = stripos($_SERVER['HTTP_USER_AGENT'], 'opera mobi') !== false; |
|
| 226 | - if ($this->_browsers['is_opera_mobi']) |
|
| 227 | - $this->_is_mobile = true; |
|
| 242 | + if (!isset($this->_browsers['is_opera_mobi'])) { |
|
| 243 | + $this->_browsers['is_opera_mobi'] = stripos($_SERVER['HTTP_USER_AGENT'], 'opera mobi') !== false; |
|
| 244 | + } |
|
| 245 | + if ($this->_browsers['is_opera_mobi']) { |
|
| 246 | + $this->_is_mobile = true; |
|
| 247 | + } |
|
| 228 | 248 | return $this->_browsers['is_opera_mini']; |
| 229 | 249 | } |
| 230 | 250 | |
@@ -244,8 +264,9 @@ discard block |
||
| 244 | 264 | ); |
| 245 | 265 | |
| 246 | 266 | // blackberry, playbook, iphone, nokia, android and ipods set a mobile flag |
| 247 | - if ($this->_browsers['is_iphone'] || $this->_browsers['is_blackberry'] || $this->_browsers['is_android'] || $this->_browsers['is_nokia']) |
|
| 248 | - $this->_is_mobile = true; |
|
| 267 | + if ($this->_browsers['is_iphone'] || $this->_browsers['is_blackberry'] || $this->_browsers['is_android'] || $this->_browsers['is_nokia']) { |
|
| 268 | + $this->_is_mobile = true; |
|
| 269 | + } |
|
| 249 | 270 | |
| 250 | 271 | // @todo what to do with the blaPad? ... for now leave it detected as Safari ... |
| 251 | 272 | $this->_browsers['is_safari'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false && !$this->_browsers['is_chrome'] && !$this->_browsers['is_iphone']; |
@@ -254,15 +275,17 @@ discard block |
||
| 254 | 275 | // if Chrome, get the major version |
| 255 | 276 | if ($this->_browsers['is_chrome']) |
| 256 | 277 | { |
| 257 | - if (preg_match('~chrome[/]([0-9][0-9]?[.])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
| 258 | - $this->_browsers['is_chrome' . (int) $match[1]] = true; |
|
| 278 | + if (preg_match('~chrome[/]([0-9][0-9]?[.])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
| 279 | + $this->_browsers['is_chrome' . (int) $match[1]] = true; |
|
| 280 | + } |
|
| 259 | 281 | } |
| 260 | 282 | |
| 261 | 283 | // or if Safari get its major version |
| 262 | 284 | if ($this->_browsers['is_safari']) |
| 263 | 285 | { |
| 264 | - if (preg_match('~version/?(.*)safari.*~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
| 265 | - $this->_browsers['is_safari' . (int) trim($match[1])] = true; |
|
| 286 | + if (preg_match('~version/?(.*)safari.*~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
| 287 | + $this->_browsers['is_safari' . (int) trim($match[1])] = true; |
|
| 288 | + } |
|
| 266 | 289 | } |
| 267 | 290 | } |
| 268 | 291 | |
@@ -291,8 +314,9 @@ discard block |
||
| 291 | 314 | $this->_browsers['is_ie' . ((int) $trident_match[1] + 4)] = true; |
| 292 | 315 | |
| 293 | 316 | // If trident is set, see the (if any) msie tag in the user agent matches ... if not its in some compatibility view |
| 294 | - if (isset($msie_match[1]) && ($msie_match[1] < $trident_match[1] + 4)) |
|
| 295 | - $this->_browsers['is_ie_compat_view'] = true; |
|
| 317 | + if (isset($msie_match[1]) && ($msie_match[1] < $trident_match[1] + 4)) { |
|
| 318 | + $this->_browsers['is_ie_compat_view'] = true; |
|
| 319 | + } |
|
| 296 | 320 | } |
| 297 | 321 | |
| 298 | 322 | // Detect true IE6 and IE7 and not IE in compat mode. |
@@ -326,8 +350,9 @@ discard block |
||
| 326 | 350 | */ |
| 327 | 351 | private function setupFirefox() |
| 328 | 352 | { |
| 329 | - if (preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)[\/ \(]([^ ;\)]+)~', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
| 330 | - $this->_browsers['is_firefox' . (int) $match[1]] = true; |
|
| 353 | + if (preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)[\/ \(]([^ ;\)]+)~', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
| 354 | + $this->_browsers['is_firefox' . (int) $match[1]] = true; |
|
| 355 | + } |
|
| 331 | 356 | } |
| 332 | 357 | |
| 333 | 358 | /** |
@@ -338,11 +363,13 @@ discard block |
||
| 338 | 363 | private function setupOpera() |
| 339 | 364 | { |
| 340 | 365 | // Opera 10+ uses the version tag at the end of the string |
| 341 | - if (preg_match('~\sVersion/([0-9]+)\.[0-9]+(?:\s*|$)~', $_SERVER['HTTP_USER_AGENT'], $match)) |
|
| 342 | - $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
| 366 | + if (preg_match('~\sVersion/([0-9]+)\.[0-9]+(?:\s*|$)~', $_SERVER['HTTP_USER_AGENT'], $match)) { |
|
| 367 | + $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
| 368 | + } |
|
| 343 | 369 | // Opera pre 10 is supposed to uses the Opera tag alone, as do some spoofers |
| 344 | - elseif (preg_match('~Opera[ /]([0-9]+)(?!\\.[89])~', $_SERVER['HTTP_USER_AGENT'], $match)) |
|
| 345 | - $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
| 370 | + elseif (preg_match('~Opera[ /]([0-9]+)(?!\\.[89])~', $_SERVER['HTTP_USER_AGENT'], $match)) { |
|
| 371 | + $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
| 372 | + } |
|
| 346 | 373 | |
| 347 | 374 | // Needs size fix? |
| 348 | 375 | $this->_browsers['needs_size_fix'] = !empty($this->_browsers['is_opera6']); |
@@ -353,8 +380,9 @@ discard block |
||
| 353 | 380 | */ |
| 354 | 381 | private function setupEdge() |
| 355 | 382 | { |
| 356 | - if (preg_match('~Edge[\/]([0-9][0-9]?[\.][0-9][0-9])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
| 357 | - $this->_browsers['is_edge' . (int) $match[1]] = true; |
|
| 383 | + if (preg_match('~Edge[\/]([0-9][0-9]?[\.][0-9][0-9])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
| 384 | + $this->_browsers['is_edge' . (int) $match[1]] = true; |
|
| 385 | + } |
|
| 358 | 386 | } |
| 359 | 387 | |
| 360 | 388 | /** |
@@ -367,9 +395,9 @@ discard block |
||
| 367 | 395 | { |
| 368 | 396 | global $context; |
| 369 | 397 | |
| 370 | - if ($this->_is_mobile) |
|
| 371 | - $context['browser_body_id'] = 'mobile'; |
|
| 372 | - else |
|
| 398 | + if ($this->_is_mobile) { |
|
| 399 | + $context['browser_body_id'] = 'mobile'; |
|
| 400 | + } else |
|
| 373 | 401 | { |
| 374 | 402 | // add in any specific detection conversions here if you want a special body id e.g. 'is_opera9' => 'opera9' |
| 375 | 403 | $browser_priority = array( |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Entrance point for the registration center, it checks permissions and forwards |
@@ -31,8 +32,9 @@ discard block |
||
| 31 | 32 | global $context, $txt; |
| 32 | 33 | |
| 33 | 34 | // Old templates might still request this. |
| 34 | - if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse') |
|
| 35 | - redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : '')); |
|
| 35 | + if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse') { |
|
| 36 | + redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : '')); |
|
| 37 | + } |
|
| 36 | 38 | |
| 37 | 39 | $subActions = array( |
| 38 | 40 | 'register' => array('AdminRegister', 'moderate_forum'), |
@@ -99,9 +101,10 @@ discard block |
||
| 99 | 101 | checkSession(); |
| 100 | 102 | validateToken('admin-regc'); |
| 101 | 103 | |
| 102 | - foreach ($_POST as $key => $value) |
|
| 103 | - if (!is_array($_POST[$key])) |
|
| 104 | + foreach ($_POST as $key => $value) { |
|
| 105 | + if (!is_array($_POST[$key])) |
|
| 104 | 106 | $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); |
| 107 | + } |
|
| 105 | 108 | |
| 106 | 109 | $regOptions = array( |
| 107 | 110 | 'interface' => 'admin', |
@@ -161,12 +164,13 @@ discard block |
||
| 161 | 164 | ) |
| 162 | 165 | ); |
| 163 | 166 | $context['member_groups'] = array(0 => $txt['admin_register_group_none']); |
| 164 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 165 | - $context['member_groups'][$row['id_group']] = $row['group_name']; |
|
| 167 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 168 | + $context['member_groups'][$row['id_group']] = $row['group_name']; |
|
| 169 | + } |
|
| 166 | 170 | $smcFunc['db_free_result']($request); |
| 171 | + } else { |
|
| 172 | + $context['member_groups'] = array(); |
|
| 167 | 173 | } |
| 168 | - else |
|
| 169 | - $context['member_groups'] = array(); |
|
| 170 | 174 | |
| 171 | 175 | // Basic stuff. |
| 172 | 176 | $context['sub_template'] = 'admin_register'; |
@@ -207,8 +211,9 @@ discard block |
||
| 207 | 211 | { |
| 208 | 212 | $context['editable_agreements']['.' . $lang['filename']] = $lang['name']; |
| 209 | 213 | // Are we editing this? |
| 210 | - if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename']) |
|
| 211 | - $context['current_agreement'] = '.' . $lang['filename']; |
|
| 214 | + if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename']) { |
|
| 215 | + $context['current_agreement'] = '.' . $lang['filename']; |
|
| 216 | + } |
|
| 212 | 217 | } |
| 213 | 218 | } |
| 214 | 219 | |
@@ -223,10 +228,11 @@ discard block |
||
| 223 | 228 | |
| 224 | 229 | updateSettings(array('requireAgreement' => !empty($_POST['requireAgreement']))); |
| 225 | 230 | |
| 226 | - if ($bytes == strlen($to_write)) |
|
| 227 | - $context['saved_successful'] = true; |
|
| 228 | - else |
|
| 229 | - $context['could_not_save'] = true; |
|
| 231 | + if ($bytes == strlen($to_write)) { |
|
| 232 | + $context['saved_successful'] = true; |
|
| 233 | + } else { |
|
| 234 | + $context['could_not_save'] = true; |
|
| 235 | + } |
|
| 230 | 236 | } |
| 231 | 237 | |
| 232 | 238 | $context['agreement'] = file_exists($boarddir . '/agreement' . $context['current_agreement'] . '.txt') ? $smcFunc['htmlspecialchars'](file_get_contents($boarddir . '/agreement' . $context['current_agreement'] . '.txt')) : ''; |
@@ -310,8 +316,9 @@ discard block |
||
| 310 | 316 | |
| 311 | 317 | call_integration_hook('integrate_modify_registration_settings', array(&$config_vars)); |
| 312 | 318 | |
| 313 | - if ($return_config) |
|
| 314 | - return $config_vars; |
|
| 319 | + if ($return_config) { |
|
| 320 | + return $config_vars; |
|
| 321 | + } |
|
| 315 | 322 | |
| 316 | 323 | // Setup the template |
| 317 | 324 | $context['sub_template'] = 'show_settings'; |
@@ -322,8 +329,9 @@ discard block |
||
| 322 | 329 | checkSession(); |
| 323 | 330 | |
| 324 | 331 | // Are there some contacts missing? |
| 325 | - if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax'])) |
|
| 326 | - fatal_lang_error('admin_setting_coppa_require_contact'); |
|
| 332 | + if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax'])) { |
|
| 333 | + fatal_lang_error('admin_setting_coppa_require_contact'); |
|
| 334 | + } |
|
| 327 | 335 | |
| 328 | 336 | // Post needs to take into account line breaks. |
| 329 | 337 | $_POST['coppaPost'] = str_replace("\n", '<br>', empty($_POST['coppaPost']) ? '' : $_POST['coppaPost']); |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * The main dispatcher; doesn't do anything, just delegates. |
@@ -92,18 +93,19 @@ discard block |
||
| 92 | 93 | checkSession('get'); |
| 93 | 94 | validateToken('admin-bm-' . (int) $_REQUEST['src_board'], 'request'); |
| 94 | 95 | |
| 95 | - if ($_REQUEST['move_to'] === 'top') |
|
| 96 | - $boardOptions = array( |
|
| 96 | + if ($_REQUEST['move_to'] === 'top') { |
|
| 97 | + $boardOptions = array( |
|
| 97 | 98 | 'move_to' => $_REQUEST['move_to'], |
| 98 | 99 | 'target_category' => (int) $_REQUEST['target_cat'], |
| 99 | 100 | 'move_first_child' => true, |
| 100 | 101 | ); |
| 101 | - else |
|
| 102 | - $boardOptions = array( |
|
| 102 | + } else { |
|
| 103 | + $boardOptions = array( |
|
| 103 | 104 | 'move_to' => $_REQUEST['move_to'], |
| 104 | 105 | 'target_board' => (int) $_REQUEST['target_board'], |
| 105 | 106 | 'move_first_child' => true, |
| 106 | 107 | ); |
| 108 | + } |
|
| 107 | 109 | modifyBoard((int) $_REQUEST['src_board'], $boardOptions); |
| 108 | 110 | } |
| 109 | 111 | |
@@ -148,15 +150,16 @@ discard block |
||
| 148 | 150 | $security = $context['session_var'] . '=' . $context['session_id'] . ';' . $context['admin-bm-' . $context['move_board'] . '_token_var'] . '=' . $context['admin-bm-' . $context['move_board'] . '_token']; |
| 149 | 151 | foreach ($boardList[$catid] as $boardid) |
| 150 | 152 | { |
| 151 | - if (!isset($context['categories'][$catid]['move_link'])) |
|
| 152 | - $context['categories'][$catid]['move_link'] = array( |
|
| 153 | + if (!isset($context['categories'][$catid]['move_link'])) { |
|
| 154 | + $context['categories'][$catid]['move_link'] = array( |
|
| 153 | 155 | 'child_level' => 0, |
| 154 | 156 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'', |
| 155 | 157 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=before;' . $security, |
| 156 | 158 | ); |
| 159 | + } |
|
| 157 | 160 | |
| 158 | - if (!$context['categories'][$catid]['boards'][$boardid]['move']) |
|
| 159 | - $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
| 161 | + if (!$context['categories'][$catid]['boards'][$boardid]['move']) { |
|
| 162 | + $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
| 160 | 163 | array( |
| 161 | 164 | 'child_level' => $boards[$boardid]['level'], |
| 162 | 165 | 'label' => $txt['mboards_order_after'] . '\'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'', |
@@ -170,34 +173,39 @@ discard block |
||
| 170 | 173 | 'class' => 'here', |
| 171 | 174 | ), |
| 172 | 175 | ); |
| 176 | + } |
|
| 173 | 177 | |
| 174 | 178 | $difference = $boards[$boardid]['level'] - $prev_child_level; |
| 175 | - if ($difference == 1) |
|
| 176 | - array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
| 177 | - elseif ($difference < 0) |
|
| 179 | + if ($difference == 1) { |
|
| 180 | + array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
| 181 | + } elseif ($difference < 0) |
|
| 178 | 182 | { |
| 179 | - if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
| 180 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
| 181 | - for ($i = 0; $i < -$difference; $i++) |
|
| 182 | - if (($temp = array_pop($stack)) != null) |
|
| 183 | + if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
| 184 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
| 185 | + } |
|
| 186 | + for ($i = 0; $i < -$difference; $i++) { |
|
| 187 | + if (($temp = array_pop($stack)) != null) |
|
| 183 | 188 | array_unshift($context['categories'][$catid]['boards'][$prev_board]['move_links'], $temp); |
| 189 | + } |
|
| 184 | 190 | } |
| 185 | 191 | |
| 186 | 192 | $prev_board = $boardid; |
| 187 | 193 | $prev_child_level = $boards[$boardid]['level']; |
| 188 | 194 | |
| 189 | 195 | } |
| 190 | - if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
| 191 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
| 192 | - elseif (!empty($stack)) |
|
| 193 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
| 196 | + if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
| 197 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
| 198 | + } elseif (!empty($stack)) { |
|
| 199 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
| 200 | + } |
|
| 194 | 201 | |
| 195 | - if (empty($boardList[$catid])) |
|
| 196 | - $context['categories'][$catid]['move_link'] = array( |
|
| 202 | + if (empty($boardList[$catid])) { |
|
| 203 | + $context['categories'][$catid]['move_link'] = array( |
|
| 197 | 204 | 'child_level' => 0, |
| 198 | 205 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($tree['node']['name']) . '\'', |
| 199 | 206 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_cat=' . $catid . ';move_to=top;' . $security, |
| 200 | 207 | ); |
| 208 | + } |
|
| 201 | 209 | } |
| 202 | 210 | } |
| 203 | 211 | |
@@ -253,9 +261,9 @@ discard block |
||
| 253 | 261 | ); |
| 254 | 262 | } |
| 255 | 263 | // Category doesn't exist, man... sorry. |
| 256 | - elseif (!isset($cat_tree[$_REQUEST['cat']])) |
|
| 257 | - redirectexit('action=admin;area=manageboards'); |
|
| 258 | - else |
|
| 264 | + elseif (!isset($cat_tree[$_REQUEST['cat']])) { |
|
| 265 | + redirectexit('action=admin;area=manageboards'); |
|
| 266 | + } else |
|
| 259 | 267 | { |
| 260 | 268 | $context['category'] = array( |
| 261 | 269 | 'id' => $_REQUEST['cat'], |
@@ -267,30 +275,31 @@ discard block |
||
| 267 | 275 | 'is_empty' => empty($cat_tree[$_REQUEST['cat']]['children']) |
| 268 | 276 | ); |
| 269 | 277 | |
| 270 | - foreach ($boardList[$_REQUEST['cat']] as $child_board) |
|
| 271 | - $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
| 278 | + foreach ($boardList[$_REQUEST['cat']] as $child_board) { |
|
| 279 | + $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
| 280 | + } |
|
| 272 | 281 | } |
| 273 | 282 | |
| 274 | 283 | $prevCat = 0; |
| 275 | 284 | foreach ($cat_tree as $catid => $tree) |
| 276 | 285 | { |
| 277 | - if ($catid == $_REQUEST['cat'] && $prevCat > 0) |
|
| 278 | - $context['category_order'][$prevCat]['selected'] = true; |
|
| 279 | - elseif ($catid != $_REQUEST['cat']) |
|
| 280 | - $context['category_order'][$catid] = array( |
|
| 286 | + if ($catid == $_REQUEST['cat'] && $prevCat > 0) { |
|
| 287 | + $context['category_order'][$prevCat]['selected'] = true; |
|
| 288 | + } elseif ($catid != $_REQUEST['cat']) { |
|
| 289 | + $context['category_order'][$catid] = array( |
|
| 281 | 290 | 'id' => $catid, |
| 282 | 291 | 'name' => $txt['mboards_order_after'] . $tree['node']['name'], |
| 283 | 292 | 'selected' => false, |
| 284 | 293 | 'true_name' => $tree['node']['name'] |
| 285 | 294 | ); |
| 295 | + } |
|
| 286 | 296 | $prevCat = $catid; |
| 287 | 297 | } |
| 288 | 298 | if (!isset($_REQUEST['delete'])) |
| 289 | 299 | { |
| 290 | 300 | $context['sub_template'] = 'modify_category'; |
| 291 | 301 | $context['page_title'] = $_REQUEST['sa'] == 'newcat' ? $txt['mboards_new_cat_name'] : $txt['catEdit']; |
| 292 | - } |
|
| 293 | - else |
|
| 302 | + } else |
|
| 294 | 303 | { |
| 295 | 304 | $context['sub_template'] = 'confirm_category_delete'; |
| 296 | 305 | $context['page_title'] = $txt['mboards_delete_cat']; |
@@ -327,8 +336,9 @@ discard block |
||
| 327 | 336 | { |
| 328 | 337 | $catOptions = array(); |
| 329 | 338 | |
| 330 | - if (isset($_POST['cat_order'])) |
|
| 331 | - $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
| 339 | + if (isset($_POST['cat_order'])) { |
|
| 340 | + $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
| 341 | + } |
|
| 332 | 342 | |
| 333 | 343 | // Change "This & That" to "This & That" but don't change "¢" to "&cent;"... |
| 334 | 344 | $catOptions['cat_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['cat_name']), false, '', $context['description_allowed_tags']); |
@@ -336,10 +346,11 @@ discard block |
||
| 336 | 346 | |
| 337 | 347 | $catOptions['is_collapsible'] = isset($_POST['collapse']); |
| 338 | 348 | |
| 339 | - if (isset($_POST['add'])) |
|
| 340 | - createCategory($catOptions); |
|
| 341 | - else |
|
| 342 | - modifyCategory($_POST['cat'], $catOptions); |
|
| 349 | + if (isset($_POST['add'])) { |
|
| 350 | + createCategory($catOptions); |
|
| 351 | + } else { |
|
| 352 | + modifyCategory($_POST['cat'], $catOptions); |
|
| 353 | + } |
|
| 343 | 354 | } |
| 344 | 355 | // If they want to delete - first give them confirmation. |
| 345 | 356 | elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['empty'])) |
@@ -353,13 +364,14 @@ discard block |
||
| 353 | 364 | // First off - check if we are moving all the current boards first - before we start deleting! |
| 354 | 365 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
| 355 | 366 | { |
| 356 | - if (empty($_POST['cat_to'])) |
|
| 357 | - fatal_lang_error('mboards_delete_error'); |
|
| 367 | + if (empty($_POST['cat_to'])) { |
|
| 368 | + fatal_lang_error('mboards_delete_error'); |
|
| 369 | + } |
|
| 358 | 370 | |
| 359 | 371 | deleteCategories(array($_POST['cat']), (int) $_POST['cat_to']); |
| 372 | + } else { |
|
| 373 | + deleteCategories(array($_POST['cat'])); |
|
| 360 | 374 | } |
| 361 | - else |
|
| 362 | - deleteCategories(array($_POST['cat'])); |
|
| 363 | 375 | } |
| 364 | 376 | |
| 365 | 377 | redirectexit('action=admin;area=manageboards'); |
@@ -404,8 +416,9 @@ discard block |
||
| 404 | 416 | if ($_REQUEST['sa'] == 'newboard') |
| 405 | 417 | { |
| 406 | 418 | // Category doesn't exist, man... sorry. |
| 407 | - if (empty($_REQUEST['cat'])) |
|
| 408 | - redirectexit('action=admin;area=manageboards'); |
|
| 419 | + if (empty($_REQUEST['cat'])) { |
|
| 420 | + redirectexit('action=admin;area=manageboards'); |
|
| 421 | + } |
|
| 409 | 422 | |
| 410 | 423 | // Some things that need to be setup for a new board. |
| 411 | 424 | $curBoard = array( |
@@ -429,8 +442,7 @@ discard block |
||
| 429 | 442 | 'category' => (int) $_REQUEST['cat'], |
| 430 | 443 | 'no_children' => true, |
| 431 | 444 | ); |
| 432 | - } |
|
| 433 | - else |
|
| 445 | + } else |
|
| 434 | 446 | { |
| 435 | 447 | // Just some easy shortcuts. |
| 436 | 448 | $curBoard = &$boards[$_REQUEST['boardid']]; |
@@ -478,8 +490,9 @@ discard block |
||
| 478 | 490 | ); |
| 479 | 491 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 480 | 492 | { |
| 481 | - if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) |
|
| 482 | - $curBoard['member_groups'][] = $row['id_group']; |
|
| 493 | + if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) { |
|
| 494 | + $curBoard['member_groups'][] = $row['id_group']; |
|
| 495 | + } |
|
| 483 | 496 | |
| 484 | 497 | $context['groups'][(int) $row['id_group']] = array( |
| 485 | 498 | 'id' => $row['id_group'], |
@@ -492,8 +505,9 @@ discard block |
||
| 492 | 505 | $smcFunc['db_free_result']($request); |
| 493 | 506 | |
| 494 | 507 | // Category doesn't exist, man... sorry. |
| 495 | - if (!isset($boardList[$curBoard['category']])) |
|
| 496 | - redirectexit('action=admin;area=manageboards'); |
|
| 508 | + if (!isset($boardList[$curBoard['category']])) { |
|
| 509 | + redirectexit('action=admin;area=manageboards'); |
|
| 510 | + } |
|
| 497 | 511 | |
| 498 | 512 | foreach ($boardList[$curBoard['category']] as $boardid) |
| 499 | 513 | { |
@@ -507,8 +521,7 @@ discard block |
||
| 507 | 521 | 'is_child' => false, |
| 508 | 522 | 'selected' => true |
| 509 | 523 | ); |
| 510 | - } |
|
| 511 | - else |
|
| 524 | + } else |
|
| 512 | 525 | { |
| 513 | 526 | $context['board_order'][] = array( |
| 514 | 527 | 'id' => $boardid, |
@@ -525,19 +538,21 @@ discard block |
||
| 525 | 538 | $context['can_move_children'] = false; |
| 526 | 539 | $context['children'] = $boards[$_REQUEST['boardid']]['tree']['children']; |
| 527 | 540 | |
| 528 | - foreach ($context['board_order'] as $lBoard) |
|
| 529 | - if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
| 541 | + foreach ($context['board_order'] as $lBoard) { |
|
| 542 | + if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
| 530 | 543 | $context['can_move_children'] = true; |
| 544 | + } |
|
| 531 | 545 | } |
| 532 | 546 | |
| 533 | 547 | // Get other available categories. |
| 534 | 548 | $context['categories'] = array(); |
| 535 | - foreach ($cat_tree as $catID => $tree) |
|
| 536 | - $context['categories'][] = array( |
|
| 549 | + foreach ($cat_tree as $catID => $tree) { |
|
| 550 | + $context['categories'][] = array( |
|
| 537 | 551 | 'id' => $catID == $curBoard['category'] ? 0 : $catID, |
| 538 | 552 | 'name' => $tree['node']['name'], |
| 539 | 553 | 'selected' => $catID == $curBoard['category'] |
| 540 | 554 | ); |
| 555 | + } |
|
| 541 | 556 | |
| 542 | 557 | $request = $smcFunc['db_query']('', ' |
| 543 | 558 | SELECT mem.id_member, mem.real_name |
@@ -549,14 +564,16 @@ discard block |
||
| 549 | 564 | ) |
| 550 | 565 | ); |
| 551 | 566 | $context['board']['moderators'] = array(); |
| 552 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 553 | - $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
| 567 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 568 | + $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
| 569 | + } |
|
| 554 | 570 | $smcFunc['db_free_result']($request); |
| 555 | 571 | |
| 556 | 572 | $context['board']['moderator_list'] = empty($context['board']['moderators']) ? '' : '"' . implode('", "', $context['board']['moderators']) . '"'; |
| 557 | 573 | |
| 558 | - if (!empty($context['board']['moderators'])) |
|
| 559 | - list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
| 574 | + if (!empty($context['board']['moderators'])) { |
|
| 575 | + list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
| 576 | + } |
|
| 560 | 577 | |
| 561 | 578 | // Get all the groups assigned as moderators |
| 562 | 579 | $request = $smcFunc['db_query']('', ' |
@@ -568,14 +585,16 @@ discard block |
||
| 568 | 585 | ) |
| 569 | 586 | ); |
| 570 | 587 | $context['board']['moderator_groups'] = array(); |
| 571 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 572 | - $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
| 588 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 589 | + $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
| 590 | + } |
|
| 573 | 591 | $smcFunc['db_free_result']($request); |
| 574 | 592 | |
| 575 | 593 | $context['board']['moderator_groups_list'] = empty($context['board']['moderator_groups']) ? '' : '"' . implode('", &qout;', $context['board']['moderator_groups']) . '"'; |
| 576 | 594 | |
| 577 | - if (!empty($context['board']['moderator_groups'])) |
|
| 578 | - list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
| 595 | + if (!empty($context['board']['moderator_groups'])) { |
|
| 596 | + list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
| 597 | + } |
|
| 579 | 598 | |
| 580 | 599 | // Get all the themes... |
| 581 | 600 | $request = $smcFunc['db_query']('', ' |
@@ -587,8 +606,9 @@ discard block |
||
| 587 | 606 | ) |
| 588 | 607 | ); |
| 589 | 608 | $context['themes'] = array(); |
| 590 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 591 | - $context['themes'][] = $row; |
|
| 609 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 610 | + $context['themes'][] = $row; |
|
| 611 | + } |
|
| 592 | 612 | $smcFunc['db_free_result']($request); |
| 593 | 613 | |
| 594 | 614 | if (!isset($_REQUEST['delete'])) |
@@ -596,8 +616,7 @@ discard block |
||
| 596 | 616 | $context['sub_template'] = 'modify_board'; |
| 597 | 617 | $context['page_title'] = $txt['boardsEdit']; |
| 598 | 618 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
| 599 | - } |
|
| 600 | - else |
|
| 619 | + } else |
|
| 601 | 620 | { |
| 602 | 621 | $context['sub_template'] = 'confirm_board_delete'; |
| 603 | 622 | $context['page_title'] = $txt['mboards_delete_board']; |
@@ -641,8 +660,9 @@ discard block |
||
| 641 | 660 | // Change the boardorder of this board? |
| 642 | 661 | elseif (!empty($_POST['placement']) && !empty($_POST['board_order'])) |
| 643 | 662 | { |
| 644 | - if (!in_array($_POST['placement'], array('before', 'after', 'child'))) |
|
| 645 | - fatal_lang_error('mangled_post', false); |
|
| 663 | + if (!in_array($_POST['placement'], array('before', 'after', 'child'))) { |
|
| 664 | + fatal_lang_error('mangled_post', false); |
|
| 665 | + } |
|
| 646 | 666 | |
| 647 | 667 | $boardOptions['move_to'] = $_POST['placement']; |
| 648 | 668 | $boardOptions['target_board'] = (int) $_POST['board_order']; |
@@ -655,13 +675,14 @@ discard block |
||
| 655 | 675 | $boardOptions['access_groups'] = array(); |
| 656 | 676 | $boardOptions['deny_groups'] = array(); |
| 657 | 677 | |
| 658 | - if (!empty($_POST['groups'])) |
|
| 659 | - foreach ($_POST['groups'] as $group => $action) |
|
| 678 | + if (!empty($_POST['groups'])) { |
|
| 679 | + foreach ($_POST['groups'] as $group => $action) |
|
| 660 | 680 | { |
| 661 | 681 | if ($action == 'allow') |
| 662 | 682 | $boardOptions['access_groups'][] = (int) $group; |
| 663 | - elseif ($action == 'deny') |
|
| 664 | - $boardOptions['deny_groups'][] = (int) $group; |
|
| 683 | + } elseif ($action == 'deny') { |
|
| 684 | + $boardOptions['deny_groups'][] = (int) $group; |
|
| 685 | + } |
|
| 665 | 686 | } |
| 666 | 687 | |
| 667 | 688 | // People with manage-boards are special. |
@@ -673,8 +694,9 @@ discard block |
||
| 673 | 694 | // Secondly, make sure those with super cow powers (like apt-get, or in this case manage boards) are upgraded. |
| 674 | 695 | $boardOptions['access_groups'] = array_unique(array_merge($boardOptions['access_groups'], $board_managers)); |
| 675 | 696 | |
| 676 | - if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) |
|
| 677 | - fatal_lang_error('too_many_groups', false); |
|
| 697 | + if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) { |
|
| 698 | + fatal_lang_error('too_many_groups', false); |
|
| 699 | + } |
|
| 678 | 700 | |
| 679 | 701 | // Do not allow HTML tags. Parse the string. |
| 680 | 702 | $boardOptions['board_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['board_name']), false, '', $context['description_allowed_tags']); |
@@ -685,8 +707,9 @@ discard block |
||
| 685 | 707 | if (isset($_POST['moderator_list']) && is_array($_POST['moderator_list'])) |
| 686 | 708 | { |
| 687 | 709 | $moderators = array(); |
| 688 | - foreach ($_POST['moderator_list'] as $moderator) |
|
| 689 | - $moderators[(int) $moderator] = (int) $moderator; |
|
| 710 | + foreach ($_POST['moderator_list'] as $moderator) { |
|
| 711 | + $moderators[(int) $moderator] = (int) $moderator; |
|
| 712 | + } |
|
| 690 | 713 | $boardOptions['moderators'] = $moderators; |
| 691 | 714 | } |
| 692 | 715 | |
@@ -695,8 +718,9 @@ discard block |
||
| 695 | 718 | if (isset($_POST['moderator_group_list']) && is_array($_POST['moderator_group_list'])) |
| 696 | 719 | { |
| 697 | 720 | $moderator_groups = array(); |
| 698 | - foreach ($_POST['moderator_group_list'] as $moderator_group) |
|
| 699 | - $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
| 721 | + foreach ($_POST['moderator_group_list'] as $moderator_group) { |
|
| 722 | + $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
| 723 | + } |
|
| 700 | 724 | $boardOptions['moderator_groups'] = $moderator_groups; |
| 701 | 725 | } |
| 702 | 726 | |
@@ -722,56 +746,62 @@ discard block |
||
| 722 | 746 | $smcFunc['db_free_result']($request); |
| 723 | 747 | |
| 724 | 748 | // If we're turning redirection on check the board doesn't have posts in it - if it does don't make it a redirection board. |
| 725 | - if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) |
|
| 726 | - unset($boardOptions['redirect']); |
|
| 749 | + if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) { |
|
| 750 | + unset($boardOptions['redirect']); |
|
| 751 | + } |
|
| 727 | 752 | // Reset the redirection count when switching on/off. |
| 728 | - elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) |
|
| 729 | - $boardOptions['num_posts'] = 0; |
|
| 753 | + elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) { |
|
| 754 | + $boardOptions['num_posts'] = 0; |
|
| 755 | + } |
|
| 730 | 756 | // Resetting the count? |
| 731 | - elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) |
|
| 732 | - $boardOptions['num_posts'] = 0; |
|
| 757 | + elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) { |
|
| 758 | + $boardOptions['num_posts'] = 0; |
|
| 759 | + } |
|
| 733 | 760 | } |
| 734 | 761 | |
| 735 | 762 | // Create a new board... |
| 736 | 763 | if (isset($_POST['add'])) |
| 737 | 764 | { |
| 738 | 765 | // New boards by default go to the bottom of the category. |
| 739 | - if (empty($_POST['new_cat'])) |
|
| 740 | - $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
| 741 | - if (!isset($boardOptions['move_to'])) |
|
| 742 | - $boardOptions['move_to'] = 'bottom'; |
|
| 766 | + if (empty($_POST['new_cat'])) { |
|
| 767 | + $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
| 768 | + } |
|
| 769 | + if (!isset($boardOptions['move_to'])) { |
|
| 770 | + $boardOptions['move_to'] = 'bottom'; |
|
| 771 | + } |
|
| 743 | 772 | |
| 744 | 773 | createBoard($boardOptions); |
| 745 | 774 | } |
| 746 | 775 | |
| 747 | 776 | // ...or update an existing board. |
| 748 | - else |
|
| 749 | - modifyBoard($_POST['boardid'], $boardOptions); |
|
| 750 | - } |
|
| 751 | - elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
| 777 | + else { |
|
| 778 | + modifyBoard($_POST['boardid'], $boardOptions); |
|
| 779 | + } |
|
| 780 | + } elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
| 752 | 781 | { |
| 753 | 782 | EditBoard(); |
| 754 | 783 | return; |
| 755 | - } |
|
| 756 | - elseif (isset($_POST['delete'])) |
|
| 784 | + } elseif (isset($_POST['delete'])) |
|
| 757 | 785 | { |
| 758 | 786 | // First off - check if we are moving all the current child boards first - before we start deleting! |
| 759 | 787 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
| 760 | 788 | { |
| 761 | - if (empty($_POST['board_to'])) |
|
| 762 | - fatal_lang_error('mboards_delete_board_error'); |
|
| 789 | + if (empty($_POST['board_to'])) { |
|
| 790 | + fatal_lang_error('mboards_delete_board_error'); |
|
| 791 | + } |
|
| 763 | 792 | |
| 764 | 793 | deleteBoards(array($_POST['boardid']), (int) $_POST['board_to']); |
| 794 | + } else { |
|
| 795 | + deleteBoards(array($_POST['boardid']), 0); |
|
| 765 | 796 | } |
| 766 | - else |
|
| 767 | - deleteBoards(array($_POST['boardid']), 0); |
|
| 768 | 797 | } |
| 769 | 798 | |
| 770 | - if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') |
|
| 771 | - redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 772 | - else |
|
| 773 | - redirectexit('action=admin;area=manageboards'); |
|
| 774 | -} |
|
| 799 | + if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') { |
|
| 800 | + redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 801 | + } else { |
|
| 802 | + redirectexit('action=admin;area=manageboards'); |
|
| 803 | + } |
|
| 804 | + } |
|
| 775 | 805 | |
| 776 | 806 | /** |
| 777 | 807 | * Used to retrieve data for modifying a board category |
@@ -808,8 +838,9 @@ discard block |
||
| 808 | 838 | $smcFunc['db_free_result']($request); |
| 809 | 839 | |
| 810 | 840 | // This would probably never happen, but just to be sure. |
| 811 | - if ($cat .= $allowed_sa[1]) |
|
| 812 | - die(str_replace(',', ' to', $cat)); |
|
| 841 | + if ($cat .= $allowed_sa[1]) { |
|
| 842 | + die(str_replace(',', ' to', $cat)); |
|
| 843 | + } |
|
| 813 | 844 | |
| 814 | 845 | redirectexit(); |
| 815 | 846 | } |
@@ -835,8 +866,9 @@ discard block |
||
| 835 | 866 | 'empty_string' => '', |
| 836 | 867 | ) |
| 837 | 868 | ); |
| 838 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 839 | - $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
| 869 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 870 | + $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
| 871 | + } |
|
| 840 | 872 | $smcFunc['db_free_result']($request); |
| 841 | 873 | |
| 842 | 874 | require_once($sourcedir . '/Subs-Boards.php'); |
@@ -860,8 +892,9 @@ discard block |
||
| 860 | 892 | |
| 861 | 893 | call_integration_hook('integrate_modify_board_settings', array(&$config_vars)); |
| 862 | 894 | |
| 863 | - if ($return_config) |
|
| 864 | - return $config_vars; |
|
| 895 | + if ($return_config) { |
|
| 896 | + return $config_vars; |
|
| 897 | + } |
|
| 865 | 898 | |
| 866 | 899 | // Needed for the settings template. |
| 867 | 900 | require_once($sourcedir . '/ManageServer.php'); |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Converts the given UTF-8 string into lowercase. |
@@ -569,8 +570,8 @@ discard block |
||
| 569 | 570 | ); |
| 570 | 571 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 571 | 572 | { |
| 572 | - if (safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) |
|
| 573 | - $smcFunc['db_query']('', ' |
|
| 573 | + if (safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) { |
|
| 574 | + $smcFunc['db_query']('', ' |
|
| 574 | 575 | UPDATE {db_prefix}log_actions |
| 575 | 576 | SET extra = {string:extra} |
| 576 | 577 | WHERE id_action = {int:current_action}', |
@@ -579,6 +580,7 @@ discard block |
||
| 579 | 580 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 580 | 581 | ) |
| 581 | 582 | ); |
| 583 | + } |
|
| 582 | 584 | } |
| 583 | 585 | $smcFunc['db_free_result']($request); |
| 584 | 586 | |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Our Cache API class |
@@ -29,8 +30,9 @@ discard block |
||
| 29 | 30 | |
| 30 | 31 | $supported = function_exists('apc_fetch') && function_exists('apc_store'); |
| 31 | 32 | |
| 32 | - if ($test) |
|
| 33 | - return $supported; |
|
| 33 | + if ($test) { |
|
| 34 | + return $supported; |
|
| 35 | + } |
|
| 34 | 36 | return parent::isSupported() && $supported; |
| 35 | 37 | } |
| 36 | 38 | |
@@ -52,10 +54,11 @@ discard block |
||
| 52 | 54 | $key = $this->prefix . strtr($key, ':/', '-_'); |
| 53 | 55 | |
| 54 | 56 | // An extended key is needed to counteract a bug in APC. |
| 55 | - if ($value === null) |
|
| 56 | - return apc_delete($key . 'smf'); |
|
| 57 | - else |
|
| 58 | - return apc_store($key . 'smf', $value, $ttl); |
|
| 57 | + if ($value === null) { |
|
| 58 | + return apc_delete($key . 'smf'); |
|
| 59 | + } else { |
|
| 60 | + return apc_store($key . 'smf', $value, $ttl); |
|
| 61 | + } |
|
| 59 | 62 | } |
| 60 | 63 | |
| 61 | 64 | /** |
@@ -69,9 +72,9 @@ discard block |
||
| 69 | 72 | // Always returns true. |
| 70 | 73 | apc_clear_cache('user'); |
| 71 | 74 | apc_clear_cache('system'); |
| 75 | + } elseif ($type === 'user') { |
|
| 76 | + apc_clear_cache('user'); |
|
| 72 | 77 | } |
| 73 | - elseif ($type === 'user') |
|
| 74 | - apc_clear_cache('user'); |
|
| 75 | 78 | |
| 76 | 79 | $this->invalidateCache(); |
| 77 | 80 | return true; |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Our Cache API class |
@@ -29,8 +30,9 @@ discard block |
||
| 29 | 30 | |
| 30 | 31 | $supported = function_exists('apcu_fetch') && function_exists('apcu_store'); |
| 31 | 32 | |
| 32 | - if ($test) |
|
| 33 | - return $supported; |
|
| 33 | + if ($test) { |
|
| 34 | + return $supported; |
|
| 35 | + } |
|
| 34 | 36 | return parent::isSupported() && $supported; |
| 35 | 37 | } |
| 36 | 38 | |
@@ -52,10 +54,11 @@ discard block |
||
| 52 | 54 | $key = $this->prefix . strtr($key, ':/', '-_'); |
| 53 | 55 | |
| 54 | 56 | // An extended key is needed to counteract a bug in APC. |
| 55 | - if ($value === null) |
|
| 56 | - return apcu_delete($key . 'smf'); |
|
| 57 | - else |
|
| 58 | - return apcu_store($key . 'smf', $value, $ttl); |
|
| 57 | + if ($value === null) { |
|
| 58 | + return apcu_delete($key . 'smf'); |
|
| 59 | + } else { |
|
| 60 | + return apcu_store($key . 'smf', $value, $ttl); |
|
| 61 | + } |
|
| 59 | 62 | } |
| 60 | 63 | |
| 61 | 64 | /** |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | |
| 35 | 36 | $supported = class_exists('memcached'); |
| 36 | 37 | |
| 37 | - if ($test) |
|
| 38 | - return $supported; |
|
| 38 | + if ($test) { |
|
| 39 | + return $supported; |
|
| 40 | + } |
|
| 39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
| 40 | 42 | } |
| 41 | 43 | |
@@ -54,9 +56,9 @@ discard block |
||
| 54 | 56 | $currentServers = $this->memcached->getServerList(); |
| 55 | 57 | foreach ($servers as $server) |
| 56 | 58 | { |
| 57 | - if (strpos($server,'/') !== false) |
|
| 58 | - $tempServer = array($server, 0); |
|
| 59 | - else |
|
| 59 | + if (strpos($server,'/') !== false) { |
|
| 60 | + $tempServer = array($server, 0); |
|
| 61 | + } else |
|
| 60 | 62 | { |
| 61 | 63 | $server = explode(':', $server); |
| 62 | 64 | $tempServer = array($server[0], isset($server[1]) ? $server[1] : 11211); |
@@ -74,8 +76,9 @@ discard block |
||
| 74 | 76 | } |
| 75 | 77 | |
| 76 | 78 | // Found it? |
| 77 | - if (empty($foundServer)) |
|
| 78 | - $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
| 79 | + if (empty($foundServer)) { |
|
| 80 | + $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
| 81 | + } |
|
| 79 | 82 | } |
| 80 | 83 | |
| 81 | 84 | // Best guess is this worked. |
@@ -92,8 +95,9 @@ discard block |
||
| 92 | 95 | $value = $this->memcached->get($key); |
| 93 | 96 | |
| 94 | 97 | // $value should return either data or false (from failure, key not found or empty array). |
| 95 | - if ($value === false) |
|
| 96 | - return null; |
|
| 98 | + if ($value === false) { |
|
| 99 | + return null; |
|
| 100 | + } |
|
| 97 | 101 | return $value; |
| 98 | 102 | } |
| 99 | 103 | |
@@ -136,8 +140,9 @@ discard block |
||
| 136 | 140 | $config_vars[] = $txt['cache_memcache_settings']; |
| 137 | 141 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br /><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
| 138 | 142 | |
| 139 | - if (!isset($context['settings_post_javascript'])) |
|
| 140 | - $context['settings_post_javascript'] = ''; |
|
| 143 | + if (!isset($context['settings_post_javascript'])) { |
|
| 144 | + $context['settings_post_javascript'] = ''; |
|
| 145 | + } |
|
| 141 | 146 | |
| 142 | 147 | $context['settings_post_javascript'] .= ' |
| 143 | 148 | $("#cache_accelerator").change(function (e) { |