@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -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 | * Shows a listing of registered members. |
@@ -110,8 +111,9 @@ discard block |
||
| 110 | 111 | |
| 111 | 112 | $context['custom_profile_fields'] = getCustFieldsMList(); |
| 112 | 113 | |
| 113 | - if (!empty($context['custom_profile_fields']['columns'])) |
|
| 114 | - $context['columns'] += $context['custom_profile_fields']['columns']; |
|
| 114 | + if (!empty($context['custom_profile_fields']['columns'])) { |
|
| 115 | + $context['columns'] += $context['custom_profile_fields']['columns']; |
|
| 116 | + } |
|
| 115 | 117 | |
| 116 | 118 | $context['colspan'] = 0; |
| 117 | 119 | $context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
@@ -147,12 +149,12 @@ discard block |
||
| 147 | 149 | call_integration_hook('integrate_memberlist_buttons'); |
| 148 | 150 | |
| 149 | 151 | // Jump to the sub action. |
| 150 | - if (isset($subActions[$context['listing_by']])) |
|
| 151 | - call_helper($subActions[$context['listing_by']][1]); |
|
| 152 | - |
|
| 153 | - else |
|
| 154 | - call_helper($subActions['all'][1]); |
|
| 155 | -} |
|
| 152 | + if (isset($subActions[$context['listing_by']])) { |
|
| 153 | + call_helper($subActions[$context['listing_by']][1]); |
|
| 154 | + } else { |
|
| 155 | + call_helper($subActions['all'][1]); |
|
| 156 | + } |
|
| 157 | + } |
|
| 156 | 158 | |
| 157 | 159 | /** |
| 158 | 160 | * List all members, page by page, with sorting. |
@@ -177,8 +179,9 @@ discard block |
||
| 177 | 179 | if ($use_cache) |
| 178 | 180 | { |
| 179 | 181 | // Maybe there's something cached already. |
| 180 | - if (!empty($modSettings['memberlist_cache'])) |
|
| 181 | - $memberlist_cache = smf_json_decode($modSettings['memberlist_cache'], true); |
|
| 182 | + if (!empty($modSettings['memberlist_cache'])) { |
|
| 183 | + $memberlist_cache = smf_json_decode($modSettings['memberlist_cache'], true); |
|
| 184 | + } |
|
| 182 | 185 | |
| 183 | 186 | // The chunk size for the cached index. |
| 184 | 187 | $cache_step_size = 500; |
@@ -234,13 +237,15 @@ discard block |
||
| 234 | 237 | } |
| 235 | 238 | |
| 236 | 239 | // Set defaults for sort (real_name) and start. (0) |
| 237 | - if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) |
|
| 238 | - $_REQUEST['sort'] = 'real_name'; |
|
| 240 | + if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) { |
|
| 241 | + $_REQUEST['sort'] = 'real_name'; |
|
| 242 | + } |
|
| 239 | 243 | |
| 240 | 244 | if (!is_numeric($_REQUEST['start'])) |
| 241 | 245 | { |
| 242 | - if (preg_match('~^[^\'\\\\/]~' . ($context['utf8'] ? 'u' : ''), $smcFunc['strtolower']($_REQUEST['start']), $match) === 0) |
|
| 243 | - fatal_error('Hacker?', false); |
|
| 246 | + if (preg_match('~^[^\'\\\\/]~' . ($context['utf8'] ? 'u' : ''), $smcFunc['strtolower']($_REQUEST['start']), $match) === 0) { |
|
| 247 | + fatal_error('Hacker?', false); |
|
| 248 | + } |
|
| 244 | 249 | |
| 245 | 250 | $_REQUEST['start'] = $match[0]; |
| 246 | 251 | |
@@ -259,16 +264,18 @@ discard block |
||
| 259 | 264 | } |
| 260 | 265 | |
| 261 | 266 | $context['letter_links'] = ''; |
| 262 | - for ($i = 97; $i < 123; $i++) |
|
| 263 | - $context['letter_links'] .= '<a href="' . $scripturl . '?action=mlist;sa=all;start=' . chr($i) . '#letter' . chr($i) . '">' . strtoupper(chr($i)) . '</a> '; |
|
| 267 | + for ($i = 97; $i < 123; $i++) { |
|
| 268 | + $context['letter_links'] .= '<a href="' . $scripturl . '?action=mlist;sa=all;start=' . chr($i) . '#letter' . chr($i) . '">' . strtoupper(chr($i)) . '</a> '; |
|
| 269 | + } |
|
| 264 | 270 | |
| 265 | 271 | // Sort out the column information. |
| 266 | 272 | foreach ($context['columns'] as $col => $column_details) |
| 267 | 273 | { |
| 268 | 274 | $context['columns'][$col]['href'] = $scripturl . '?action=mlist;sort=' . $col . ';start=0'; |
| 269 | 275 | |
| 270 | - if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) |
|
| 271 | - $context['columns'][$col]['href'] .= ';desc'; |
|
| 276 | + if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) { |
|
| 277 | + $context['columns'][$col]['href'] .= ';desc'; |
|
| 278 | + } |
|
| 272 | 279 | |
| 273 | 280 | $context['columns'][$col]['link'] = '<a href="' . $context['columns'][$col]['href'] . '" rel="nofollow">' . $context['columns'][$col]['label'] . '</a>'; |
| 274 | 281 | $context['columns'][$col]['selected'] = $_REQUEST['sort'] == $col; |
@@ -317,8 +324,9 @@ discard block |
||
| 317 | 324 | elseif ($use_cache && $_REQUEST['sort'] === 'real_name') |
| 318 | 325 | { |
| 319 | 326 | $first_offset = floor(($memberlist_cache['num_members'] - $modSettings['defaultMaxMembers'] - $_REQUEST['start']) / $cache_step_size) * $cache_step_size; |
| 320 | - if ($first_offset < 0) |
|
| 321 | - $first_offset = 0; |
|
| 327 | + if ($first_offset < 0) { |
|
| 328 | + $first_offset = 0; |
|
| 329 | + } |
|
| 322 | 330 | $second_offset = ceil(($memberlist_cache['num_members'] - $_REQUEST['start']) / $cache_step_size) * $cache_step_size; |
| 323 | 331 | |
| 324 | 332 | $where = 'mem.real_name BETWEEN {string:real_name_low} AND {string:real_name_high}'; |
@@ -395,12 +403,13 @@ discard block |
||
| 395 | 403 | ) |
| 396 | 404 | ); |
| 397 | 405 | $context['custom_search_fields'] = array(); |
| 398 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 399 | - $context['custom_search_fields'][$row['col_name']] = array( |
|
| 406 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 407 | + $context['custom_search_fields'][$row['col_name']] = array( |
|
| 400 | 408 | 'colname' => $row['col_name'], |
| 401 | 409 | 'name' => $row['field_name'], |
| 402 | 410 | 'desc' => $row['field_desc'], |
| 403 | 411 | ); |
| 412 | + } |
|
| 404 | 413 | $smcFunc['db_free_result']($request); |
| 405 | 414 | |
| 406 | 415 | // They're searching.. |
@@ -413,23 +422,27 @@ discard block |
||
| 413 | 422 | $context['old_search_value'] = urlencode($_REQUEST['search']); |
| 414 | 423 | |
| 415 | 424 | // No fields? Use default... |
| 416 | - if (empty($_POST['fields'])) |
|
| 417 | - $_POST['fields'] = array('name'); |
|
| 425 | + if (empty($_POST['fields'])) { |
|
| 426 | + $_POST['fields'] = array('name'); |
|
| 427 | + } |
|
| 418 | 428 | |
| 419 | 429 | // Set defaults for how the results are sorted |
| 420 | - if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) |
|
| 421 | - $_REQUEST['sort'] = 'real_name'; |
|
| 430 | + if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) { |
|
| 431 | + $_REQUEST['sort'] = 'real_name'; |
|
| 432 | + } |
|
| 422 | 433 | |
| 423 | 434 | // Build the column link / sort information. |
| 424 | 435 | foreach ($context['columns'] as $col => $column_details) |
| 425 | 436 | { |
| 426 | 437 | $context['columns'][$col]['href'] = $scripturl . '?action=mlist;sa=search;start=0;sort=' . $col; |
| 427 | 438 | |
| 428 | - if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) |
|
| 429 | - $context['columns'][$col]['href'] .= ';desc'; |
|
| 439 | + if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) { |
|
| 440 | + $context['columns'][$col]['href'] .= ';desc'; |
|
| 441 | + } |
|
| 430 | 442 | |
| 431 | - if (isset($_POST['search']) && isset($_POST['fields'])) |
|
| 432 | - $context['columns'][$col]['href'] .= ';search=' . $_POST['search'] . ';fields=' . implode(',', $_POST['fields']); |
|
| 443 | + if (isset($_POST['search']) && isset($_POST['fields'])) { |
|
| 444 | + $context['columns'][$col]['href'] .= ';search=' . $_POST['search'] . ';fields=' . implode(',', $_POST['fields']); |
|
| 445 | + } |
|
| 433 | 446 | |
| 434 | 447 | $context['columns'][$col]['link'] = '<a href="' . $context['columns'][$col]['href'] . '" rel="nofollow">' . $context['columns'][$col]['label'] . '</a>'; |
| 435 | 448 | $context['columns'][$col]['selected'] = $_REQUEST['sort'] == $col; |
@@ -452,8 +465,7 @@ discard block |
||
| 452 | 465 | { |
| 453 | 466 | $fields = allowedTo('moderate_forum') ? array('member_name', 'real_name') : array('real_name'); |
| 454 | 467 | $search_fields[] = 'name'; |
| 455 | - } |
|
| 456 | - else |
|
| 468 | + } else |
|
| 457 | 469 | { |
| 458 | 470 | $fields = array(); |
| 459 | 471 | $search_fields = array(); |
@@ -478,9 +490,10 @@ discard block |
||
| 478 | 490 | $search_fields[] = 'email'; |
| 479 | 491 | } |
| 480 | 492 | |
| 481 | - if ($smcFunc['db_case_sensitive']) |
|
| 482 | - foreach ($fields as $key => $field) |
|
| 493 | + if ($smcFunc['db_case_sensitive']) { |
|
| 494 | + foreach ($fields as $key => $field) |
|
| 483 | 495 | $fields[$key] = 'LOWER(' . $field . ')'; |
| 496 | + } |
|
| 484 | 497 | |
| 485 | 498 | $customJoin = array(); |
| 486 | 499 | $customCount = 10; |
@@ -499,8 +512,9 @@ discard block |
||
| 499 | 512 | } |
| 500 | 513 | |
| 501 | 514 | // No search fields? That means you're trying to hack things |
| 502 | - if (empty($search_fields)) |
|
| 503 | - fatal_lang_error('invalid_search_string', false); |
|
| 515 | + if (empty($search_fields)) { |
|
| 516 | + fatal_lang_error('invalid_search_string', false); |
|
| 517 | + } |
|
| 504 | 518 | |
| 505 | 519 | $query = $_POST['search'] == '' ? '= {string:blank_string}' : ($smcFunc['db_case_sensitive'] ? 'LIKE LOWER({string:search})' : 'LIKE {string:search}'); |
| 506 | 520 | |
@@ -538,8 +552,7 @@ discard block |
||
| 538 | 552 | ); |
| 539 | 553 | printMemberListRows($request); |
| 540 | 554 | $smcFunc['db_free_result']($request); |
| 541 | - } |
|
| 542 | - else |
|
| 555 | + } else |
|
| 543 | 556 | { |
| 544 | 557 | // These are all the possible fields. |
| 545 | 558 | $context['search_fields'] = array( |
@@ -554,14 +567,14 @@ discard block |
||
| 554 | 567 | { |
| 555 | 568 | unset($context['search_fields']['email']); |
| 556 | 569 | $context['search_defaults'] = array('name'); |
| 557 | - } |
|
| 558 | - else |
|
| 570 | + } else |
|
| 559 | 571 | { |
| 560 | 572 | $context['search_defaults'] = array('name', 'email'); |
| 561 | 573 | } |
| 562 | 574 | |
| 563 | - foreach ($context['custom_search_fields'] as $field) |
|
| 564 | - $context['search_fields']['cust_' . $field['colname']] = sprintf($txt['mlist_search_by'], $field['name']); |
|
| 575 | + foreach ($context['custom_search_fields'] as $field) { |
|
| 576 | + $context['search_fields']['cust_' . $field['colname']] = sprintf($txt['mlist_search_by'], $field['name']); |
|
| 577 | + } |
|
| 565 | 578 | |
| 566 | 579 | $context['sub_template'] = 'search'; |
| 567 | 580 | $context['old_search'] = isset($_GET['search']) ? $_GET['search'] : (isset($_POST['search']) ? $smcFunc['htmlspecialchars']($_POST['search']) : ''); |
@@ -603,12 +616,14 @@ discard block |
||
| 603 | 616 | $smcFunc['db_free_result']($result); |
| 604 | 617 | |
| 605 | 618 | // Avoid division by zero... |
| 606 | - if ($most_posts == 0) |
|
| 607 | - $most_posts = 1; |
|
| 619 | + if ($most_posts == 0) { |
|
| 620 | + $most_posts = 1; |
|
| 621 | + } |
|
| 608 | 622 | |
| 609 | 623 | $members = array(); |
| 610 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 611 | - $members[] = $row['id_member']; |
|
| 624 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 625 | + $members[] = $row['id_member']; |
|
| 626 | + } |
|
| 612 | 627 | |
| 613 | 628 | // Load all the members for display. |
| 614 | 629 | loadMemberData($members); |
@@ -616,8 +631,9 @@ discard block |
||
| 616 | 631 | $context['members'] = array(); |
| 617 | 632 | foreach ($members as $member) |
| 618 | 633 | { |
| 619 | - if (!loadMemberContext($member)) |
|
| 620 | - continue; |
|
| 634 | + if (!loadMemberContext($member)) { |
|
| 635 | + continue; |
|
| 636 | + } |
|
| 621 | 637 | |
| 622 | 638 | $context['members'][$member] = $memberContext[$member]; |
| 623 | 639 | $context['members'][$member]['post_percent'] = round(($context['members'][$member]['real_posts'] * 100) / $most_posts); |
@@ -634,20 +650,21 @@ discard block |
||
| 634 | 650 | continue; |
| 635 | 651 | } |
| 636 | 652 | |
| 637 | - if ($column['bbc'] && !empty($context['members'][$member]['options'][$key])) |
|
| 638 | - $context['members'][$member]['options'][$key] = strip_tags(parse_bbc($context['members'][$member]['options'][$key])); |
|
| 639 | - |
|
| 640 | - elseif ($column['type'] == 'check') |
|
| 641 | - $context['members'][$member]['options'][$key] = $context['members'][$member]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 653 | + if ($column['bbc'] && !empty($context['members'][$member]['options'][$key])) { |
|
| 654 | + $context['members'][$member]['options'][$key] = strip_tags(parse_bbc($context['members'][$member]['options'][$key])); |
|
| 655 | + } elseif ($column['type'] == 'check') { |
|
| 656 | + $context['members'][$member]['options'][$key] = $context['members'][$member]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 657 | + } |
|
| 642 | 658 | |
| 643 | 659 | // Enclosing the user input within some other text? |
| 644 | - if (!empty($column['enclose'])) |
|
| 645 | - $context['members'][$member]['options'][$key] = strtr($column['enclose'], array( |
|
| 660 | + if (!empty($column['enclose'])) { |
|
| 661 | + $context['members'][$member]['options'][$key] = strtr($column['enclose'], array( |
|
| 646 | 662 | '{SCRIPTURL}' => $scripturl, |
| 647 | 663 | '{IMAGES_URL}' => $settings['images_url'], |
| 648 | 664 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 649 | 665 | '{INPUT}' => $context['members'][$member]['options'][$key], |
| 650 | 666 | )); |
| 667 | + } |
|
| 651 | 668 | } |
| 652 | 669 | } |
| 653 | 670 | } |
@@ -688,17 +705,17 @@ discard block |
||
| 688 | 705 | ); |
| 689 | 706 | |
| 690 | 707 | // Get the right sort method depending on the cust field type. |
| 691 | - if ($row['field_type'] != 'check') |
|
| 692 | - $cpf['columns'][$row['col_name']]['sort'] = array( |
|
| 708 | + if ($row['field_type'] != 'check') { |
|
| 709 | + $cpf['columns'][$row['col_name']]['sort'] = array( |
|
| 693 | 710 | 'down' => 'LENGTH(t' . $row['col_name'] . '.value) > 0 ASC, COALESCE(t' . $row['col_name'] . '.value, "") DESC', |
| 694 | 711 | 'up' => 'LENGTH(t' . $row['col_name'] . '.value) > 0 DESC, COALESCE(t' . $row['col_name'] . '.value, "") ASC' |
| 695 | 712 | ); |
| 696 | - |
|
| 697 | - else |
|
| 698 | - $cpf['columns'][$row['col_name']]['sort'] = array( |
|
| 713 | + } else { |
|
| 714 | + $cpf['columns'][$row['col_name']]['sort'] = array( |
|
| 699 | 715 | 'down' => 't' . $row['col_name'] . '.value DESC', |
| 700 | 716 | 'up' => 't' . $row['col_name'] . '.value ASC' |
| 701 | 717 | ); |
| 718 | + } |
|
| 702 | 719 | |
| 703 | 720 | $cpf['join'][$row['col_name']] = 'LEFT JOIN {db_prefix}themes AS t' . $row['col_name'] . ' ON (t' . $row['col_name'] . '.variable = {literal:' . $row['col_name'] . '} AND t' . $row['col_name'] . '.id_theme = 1 AND t' . $row['col_name'] . '.id_member = mem.id_member)'; |
| 704 | 721 | } |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * View the forum's error log. |
@@ -30,8 +31,9 @@ discard block |
||
| 30 | 31 | global $scripturl, $txt, $context, $modSettings, $user_profile, $filter, $smcFunc; |
| 31 | 32 | |
| 32 | 33 | // Viewing contents of a file? |
| 33 | - if (isset($_GET['file'])) |
|
| 34 | - return ViewFile(); |
|
| 34 | + if (isset($_GET['file'])) { |
|
| 35 | + return ViewFile(); |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // Check for the administrative permission to do this. |
| 37 | 39 | isAllowedTo('admin_forum'); |
@@ -85,8 +87,8 @@ discard block |
||
| 85 | 87 | ); |
| 86 | 88 | |
| 87 | 89 | // Set up the filtering... |
| 88 | - if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) |
|
| 89 | - $filter = array( |
|
| 90 | + if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) { |
|
| 91 | + $filter = array( |
|
| 90 | 92 | 'variable' => $_GET['filter'], |
| 91 | 93 | 'value' => array( |
| 92 | 94 | 'sql' => in_array($_GET['filter'], array('message', 'url', 'file')) ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : $smcFunc['db_escape_wildcard_string']($_GET['value']), |
@@ -94,10 +96,12 @@ discard block |
||
| 94 | 96 | 'href' => ';filter=' . $_GET['filter'] . ';value=' . $_GET['value'], |
| 95 | 97 | 'entity' => $filters[$_GET['filter']]['txt'] |
| 96 | 98 | ); |
| 99 | + } |
|
| 97 | 100 | |
| 98 | 101 | // Deleting, are we? |
| 99 | - if (isset($_POST['delall']) || isset($_POST['delete'])) |
|
| 100 | - deleteErrors(); |
|
| 102 | + if (isset($_POST['delall']) || isset($_POST['delete'])) { |
|
| 103 | + deleteErrors(); |
|
| 104 | + } |
|
| 101 | 105 | |
| 102 | 106 | // Just how many errors are there? |
| 103 | 107 | $result = $smcFunc['db_query']('', ' |
@@ -112,12 +116,14 @@ discard block |
||
| 112 | 116 | $smcFunc['db_free_result']($result); |
| 113 | 117 | |
| 114 | 118 | // If this filter is empty... |
| 115 | - if ($num_errors == 0 && isset($filter)) |
|
| 116 | - redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
| 119 | + if ($num_errors == 0 && isset($filter)) { |
|
| 120 | + redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
| 121 | + } |
|
| 117 | 122 | |
| 118 | 123 | // Clean up start. |
| 119 | - if (!isset($_GET['start']) || $_GET['start'] < 0) |
|
| 120 | - $_GET['start'] = 0; |
|
| 124 | + if (!isset($_GET['start']) || $_GET['start'] < 0) { |
|
| 125 | + $_GET['start'] = 0; |
|
| 126 | + } |
|
| 121 | 127 | |
| 122 | 128 | // Do we want to reverse error listing? |
| 123 | 129 | $context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up'; |
@@ -127,9 +133,9 @@ discard block |
||
| 127 | 133 | $context['start'] = $_GET['start']; |
| 128 | 134 | |
| 129 | 135 | // Update the error count |
| 130 | - if (!isset($filter)) |
|
| 131 | - $context['num_errors'] = $num_errors; |
|
| 132 | - else |
|
| 136 | + if (!isset($filter)) { |
|
| 137 | + $context['num_errors'] = $num_errors; |
|
| 138 | + } else |
|
| 133 | 139 | { |
| 134 | 140 | // We want all errors, not just the number of filtered messages... |
| 135 | 141 | $query = $smcFunc['db_query']('', ' |
@@ -161,8 +167,9 @@ discard block |
||
| 161 | 167 | for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i++) |
| 162 | 168 | { |
| 163 | 169 | $search_message = preg_replace('~<span class="remove">(.+?)</span>~', '%', $smcFunc['db_escape_wildcard_string']($row['message'])); |
| 164 | - if ($search_message == $filter['value']['sql']) |
|
| 165 | - $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
| 170 | + if ($search_message == $filter['value']['sql']) { |
|
| 171 | + $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
| 172 | + } |
|
| 166 | 173 | $show_message = strtr(strtr(preg_replace('~<span class="remove">(.+?)</span>~', '$1', $row['message']), array("\r" => '', '<br>' => "\n", '<' => '<', '>' => '>', '"' => '"')), array("\n" => '<br>')); |
| 167 | 174 | |
| 168 | 175 | $context['errors'][$row['id_error']] = array( |
@@ -221,8 +228,9 @@ discard block |
||
| 221 | 228 | 'members' => count($members), |
| 222 | 229 | ) |
| 223 | 230 | ); |
| 224 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 225 | - $members[$row['id_member']] = $row; |
|
| 231 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 232 | + $members[$row['id_member']] = $row; |
|
| 233 | + } |
|
| 226 | 234 | $smcFunc['db_free_result']($request); |
| 227 | 235 | |
| 228 | 236 | // This is a guest... |
@@ -254,20 +262,18 @@ discard block |
||
| 254 | 262 | $id = $filter['value']['sql']; |
| 255 | 263 | loadMemberData($id, false, 'minimal'); |
| 256 | 264 | $context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>'; |
| 257 | - } |
|
| 258 | - elseif ($filter['variable'] == 'url') |
|
| 259 | - $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
| 260 | - elseif ($filter['variable'] == 'message') |
|
| 265 | + } elseif ($filter['variable'] == 'url') { |
|
| 266 | + $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
| 267 | + } elseif ($filter['variable'] == 'message') |
|
| 261 | 268 | { |
| 262 | 269 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
| 263 | 270 | $context['filter']['value']['html'] = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $context['filter']['value']['html']); |
| 264 | - } |
|
| 265 | - elseif ($filter['variable'] == 'error_type') |
|
| 271 | + } elseif ($filter['variable'] == 'error_type') |
|
| 266 | 272 | { |
| 267 | 273 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
| 274 | + } else { |
|
| 275 | + $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
| 268 | 276 | } |
| 269 | - else |
|
| 270 | - $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
| 271 | 277 | } |
| 272 | 278 | |
| 273 | 279 | $context['error_types'] = array(); |
@@ -308,10 +314,11 @@ discard block |
||
| 308 | 314 | $context['error_types']['all']['label'] .= ' (' . $sum . ')'; |
| 309 | 315 | |
| 310 | 316 | // Finally, work out what is the last tab! |
| 311 | - if (isset($context['error_types'][$sum])) |
|
| 312 | - $context['error_types'][$sum]['is_last'] = true; |
|
| 313 | - else |
|
| 314 | - $context['error_types']['all']['is_last'] = true; |
|
| 317 | + if (isset($context['error_types'][$sum])) { |
|
| 318 | + $context['error_types'][$sum]['is_last'] = true; |
|
| 319 | + } else { |
|
| 320 | + $context['error_types']['all']['is_last'] = true; |
|
| 321 | + } |
|
| 315 | 322 | |
| 316 | 323 | // And this is pretty basic ;). |
| 317 | 324 | $context['page_title'] = $txt['errlog']; |
@@ -337,21 +344,23 @@ discard block |
||
| 337 | 344 | validateToken('admin-el'); |
| 338 | 345 | |
| 339 | 346 | // Delete all or just some? |
| 340 | - if (isset($_POST['delall']) && !isset($filter)) |
|
| 341 | - $smcFunc['db_query']('truncate_table', ' |
|
| 347 | + if (isset($_POST['delall']) && !isset($filter)) { |
|
| 348 | + $smcFunc['db_query']('truncate_table', ' |
|
| 342 | 349 | TRUNCATE {db_prefix}log_errors', |
| 343 | 350 | array( |
| 344 | 351 | ) |
| 345 | 352 | ); |
| 353 | + } |
|
| 346 | 354 | // Deleting all with a filter? |
| 347 | - elseif (isset($_POST['delall']) && isset($filter)) |
|
| 348 | - $smcFunc['db_query']('', ' |
|
| 355 | + elseif (isset($_POST['delall']) && isset($filter)) { |
|
| 356 | + $smcFunc['db_query']('', ' |
|
| 349 | 357 | DELETE FROM {db_prefix}log_errors |
| 350 | 358 | WHERE ' . $filter['variable'] . ' LIKE {string:filter}', |
| 351 | 359 | array( |
| 352 | 360 | 'filter' => $filter['value']['sql'], |
| 353 | 361 | ) |
| 354 | 362 | ); |
| 363 | + } |
|
| 355 | 364 | // Just specific errors? |
| 356 | 365 | elseif (!empty($_POST['delete'])) |
| 357 | 366 | { |
@@ -397,15 +406,17 @@ discard block |
||
| 397 | 406 | $line = isset($_REQUEST['line']) ? (int) $_REQUEST['line'] : 0; |
| 398 | 407 | |
| 399 | 408 | // Make sure the file we are looking for is one they are allowed to look at |
| 400 | - if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) |
|
| 401 | - fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
| 409 | + if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) { |
|
| 410 | + fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
| 411 | + } |
|
| 402 | 412 | |
| 403 | 413 | // get the min and max lines |
| 404 | 414 | $min = $line - 20 <= 0 ? 1 : $line - 20; |
| 405 | 415 | $max = $line + 21; // One additional line to make everything work out correctly |
| 406 | 416 | |
| 407 | - if ($max <= 0 || $min >= $max) |
|
| 408 | - fatal_lang_error('error_bad_line'); |
|
| 417 | + if ($max <= 0 || $min >= $max) { |
|
| 418 | + fatal_lang_error('error_bad_line'); |
|
| 419 | + } |
|
| 409 | 420 | |
| 410 | 421 | $file_data = explode('<br />', highlight_php_code($smcFunc['htmlspecialchars'](implode('', file($file))))); |
| 411 | 422 | |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Ban center. The main entrance point for all ban center functions. |
@@ -120,10 +121,11 @@ discard block |
||
| 120 | 121 | } |
| 121 | 122 | |
| 122 | 123 | // Create a date string so we don't overload them with date info. |
| 123 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 124 | - $context['ban_time_format'] = $user_info['time_format']; |
|
| 125 | - else |
|
| 126 | - $context['ban_time_format'] = $matches[0]; |
|
| 124 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 125 | + $context['ban_time_format'] = $user_info['time_format']; |
|
| 126 | + } else { |
|
| 127 | + $context['ban_time_format'] = $matches[0]; |
|
| 128 | + } |
|
| 127 | 129 | |
| 128 | 130 | $listOptions = array( |
| 129 | 131 | 'id' => 'ban_list', |
@@ -201,16 +203,19 @@ discard block |
||
| 201 | 203 | 'function' => function($rowData) use ($txt) |
| 202 | 204 | { |
| 203 | 205 | // This ban never expires...whahaha. |
| 204 | - if ($rowData['expire_time'] === null) |
|
| 205 | - return $txt['never']; |
|
| 206 | + if ($rowData['expire_time'] === null) { |
|
| 207 | + return $txt['never']; |
|
| 208 | + } |
|
| 206 | 209 | |
| 207 | 210 | // This ban has already expired. |
| 208 | - elseif ($rowData['expire_time'] < time()) |
|
| 209 | - return sprintf('<span class="red">%1$s</span>', $txt['ban_expired']); |
|
| 211 | + elseif ($rowData['expire_time'] < time()) { |
|
| 212 | + return sprintf('<span class="red">%1$s</span>', $txt['ban_expired']); |
|
| 213 | + } |
|
| 210 | 214 | |
| 211 | 215 | // Still need to wait a few days for this ban to expire. |
| 212 | - else |
|
| 213 | - return sprintf('%1$d %2$s', ceil(($rowData['expire_time'] - time()) / (60 * 60 * 24)), $txt['ban_days']); |
|
| 216 | + else { |
|
| 217 | + return sprintf('%1$d %2$s', ceil(($rowData['expire_time'] - time()) / (60 * 60 * 24)), $txt['ban_days']); |
|
| 218 | + } |
|
| 214 | 219 | }, |
| 215 | 220 | ), |
| 216 | 221 | 'sort' => array( |
@@ -309,8 +314,9 @@ discard block |
||
| 309 | 314 | ) |
| 310 | 315 | ); |
| 311 | 316 | $bans = array(); |
| 312 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 313 | - $bans[] = $row; |
|
| 317 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 318 | + $bans[] = $row; |
|
| 319 | + } |
|
| 314 | 320 | |
| 315 | 321 | $smcFunc['db_free_result']($request); |
| 316 | 322 | |
@@ -352,8 +358,9 @@ discard block |
||
| 352 | 358 | { |
| 353 | 359 | global $txt, $modSettings, $context, $scripturl, $smcFunc, $sourcedir; |
| 354 | 360 | |
| 355 | - if ((isset($_POST['add_ban']) || isset($_POST['modify_ban']) || isset($_POST['remove_selection'])) && empty($context['ban_errors'])) |
|
| 356 | - BanEdit2(); |
|
| 361 | + if ((isset($_POST['add_ban']) || isset($_POST['modify_ban']) || isset($_POST['remove_selection'])) && empty($context['ban_errors'])) { |
|
| 362 | + BanEdit2(); |
|
| 363 | + } |
|
| 357 | 364 | |
| 358 | 365 | $ban_group_id = isset($context['ban']['id']) ? $context['ban']['id'] : (isset($_REQUEST['bg']) ? (int) $_REQUEST['bg'] : 0); |
| 359 | 366 | |
@@ -364,10 +371,10 @@ discard block |
||
| 364 | 371 | |
| 365 | 372 | if (!empty($context['ban_errors'])) |
| 366 | 373 | { |
| 367 | - foreach ($context['ban_errors'] as $error) |
|
| 368 | - $context['error_messages'][$error] = $txt[$error]; |
|
| 369 | - } |
|
| 370 | - else |
|
| 374 | + foreach ($context['ban_errors'] as $error) { |
|
| 375 | + $context['error_messages'][$error] = $txt[$error]; |
|
| 376 | + } |
|
| 377 | + } else |
|
| 371 | 378 | { |
| 372 | 379 | // If we're editing an existing ban, get it from the database. |
| 373 | 380 | if (!empty($ban_group_id)) |
@@ -403,12 +410,13 @@ discard block |
||
| 403 | 410 | 'data' => array( |
| 404 | 411 | 'function' => function($ban_item) use ($txt) |
| 405 | 412 | { |
| 406 | - if (in_array($ban_item['type'], array('ip', 'hostname', 'email'))) |
|
| 407 | - return '<strong>' . $txt[$ban_item['type']] . ':</strong> ' . $ban_item[$ban_item['type']]; |
|
| 408 | - elseif ($ban_item['type'] == 'user') |
|
| 409 | - return '<strong>' . $txt['username'] . ':</strong> ' . $ban_item['user']['link']; |
|
| 410 | - else |
|
| 411 | - return '<strong>' . $txt['unknown'] . ':</strong> ' . $ban_item['no_bantype_selected']; |
|
| 413 | + if (in_array($ban_item['type'], array('ip', 'hostname', 'email'))) { |
|
| 414 | + return '<strong>' . $txt[$ban_item['type']] . ':</strong> ' . $ban_item[$ban_item['type']]; |
|
| 415 | + } elseif ($ban_item['type'] == 'user') { |
|
| 416 | + return '<strong>' . $txt['username'] . ':</strong> ' . $ban_item['user']['link']; |
|
| 417 | + } else { |
|
| 418 | + return '<strong>' . $txt['unknown'] . ':</strong> ' . $ban_item['no_bantype_selected']; |
|
| 419 | + } |
|
| 412 | 420 | }, |
| 413 | 421 | 'style' => 'text-align: left;', |
| 414 | 422 | ), |
@@ -546,8 +554,9 @@ discard block |
||
| 546 | 554 | $context['ban']['from_user'] = true; |
| 547 | 555 | |
| 548 | 556 | // Would be nice if we could also ban the hostname. |
| 549 | - if ((preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $context['ban_suggestions']['main_ip']) == 1 || isValidIPv6($context['ban_suggestions']['main_ip'])) && empty($modSettings['disableHostnameLookup'])) |
|
| 550 | - $context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']); |
|
| 557 | + if ((preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $context['ban_suggestions']['main_ip']) == 1 || isValidIPv6($context['ban_suggestions']['main_ip'])) && empty($modSettings['disableHostnameLookup'])) { |
|
| 558 | + $context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']); |
|
| 559 | + } |
|
| 551 | 560 | |
| 552 | 561 | $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
| 553 | 562 | } |
@@ -615,8 +624,9 @@ discard block |
||
| 615 | 624 | 'items_per_page' => $items_per_page, |
| 616 | 625 | ) |
| 617 | 626 | ); |
| 618 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 619 | - fatal_lang_error('ban_not_found', false); |
|
| 627 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 628 | + fatal_lang_error('ban_not_found', false); |
|
| 629 | + } |
|
| 620 | 630 | |
| 621 | 631 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 622 | 632 | { |
@@ -653,18 +663,15 @@ discard block |
||
| 653 | 663 | { |
| 654 | 664 | $ban_items[$row['id_ban']]['type'] = 'ip'; |
| 655 | 665 | $ban_items[$row['id_ban']]['ip'] = range2ip($row['ip_low'], $row['ip_high']); |
| 656 | - } |
|
| 657 | - elseif (!empty($row['hostname'])) |
|
| 666 | + } elseif (!empty($row['hostname'])) |
|
| 658 | 667 | { |
| 659 | 668 | $ban_items[$row['id_ban']]['type'] = 'hostname'; |
| 660 | 669 | $ban_items[$row['id_ban']]['hostname'] = str_replace('%', '*', $row['hostname']); |
| 661 | - } |
|
| 662 | - elseif (!empty($row['email_address'])) |
|
| 670 | + } elseif (!empty($row['email_address'])) |
|
| 663 | 671 | { |
| 664 | 672 | $ban_items[$row['id_ban']]['type'] = 'email'; |
| 665 | 673 | $ban_items[$row['id_ban']]['email'] = str_replace('%', '*', $row['email_address']); |
| 666 | - } |
|
| 667 | - elseif (!empty($row['id_member'])) |
|
| 674 | + } elseif (!empty($row['id_member'])) |
|
| 668 | 675 | { |
| 669 | 676 | $ban_items[$row['id_ban']]['type'] = 'user'; |
| 670 | 677 | $ban_items[$row['id_ban']]['user'] = array( |
@@ -730,9 +737,10 @@ discard block |
||
| 730 | 737 | $search_list += array('ips_in_messages' => 'banLoadAdditionalIPsMember', 'ips_in_errors' => 'banLoadAdditionalIPsError'); |
| 731 | 738 | |
| 732 | 739 | $return = array(); |
| 733 | - foreach ($search_list as $key => $callable) |
|
| 734 | - if (is_callable($callable)) |
|
| 740 | + foreach ($search_list as $key => $callable) { |
|
| 741 | + if (is_callable($callable)) |
|
| 735 | 742 | $return[$key] = call_user_func($callable, $member_id); |
| 743 | + } |
|
| 736 | 744 | |
| 737 | 745 | return $return; |
| 738 | 746 | } |
@@ -757,8 +765,9 @@ discard block |
||
| 757 | 765 | 'current_user' => $member_id, |
| 758 | 766 | ) |
| 759 | 767 | ); |
| 760 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 761 | - $message_ips[] = inet_dtop($row['poster_ip']); |
|
| 768 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 769 | + $message_ips[] = inet_dtop($row['poster_ip']); |
|
| 770 | + } |
|
| 762 | 771 | $smcFunc['db_free_result']($request); |
| 763 | 772 | |
| 764 | 773 | return $message_ips; |
@@ -783,8 +792,9 @@ discard block |
||
| 783 | 792 | 'current_user' => $member_id, |
| 784 | 793 | ) |
| 785 | 794 | ); |
| 786 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 787 | - $error_ips[] = inet_dtop($row['ip']); |
|
| 795 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 796 | + $error_ips[] = inet_dtop($row['ip']); |
|
| 797 | + } |
|
| 788 | 798 | $smcFunc['db_free_result']($request); |
| 789 | 799 | |
| 790 | 800 | return $error_ips; |
@@ -825,11 +835,13 @@ discard block |
||
| 825 | 835 | $ban_info['cannot']['login'] = !empty($ban_info['full_ban']) || empty($_POST['cannot_login']) ? 0 : 1; |
| 826 | 836 | |
| 827 | 837 | // Adding a new ban group |
| 828 | - if (empty($_REQUEST['bg'])) |
|
| 829 | - $ban_group_id = insertBanGroup($ban_info); |
|
| 838 | + if (empty($_REQUEST['bg'])) { |
|
| 839 | + $ban_group_id = insertBanGroup($ban_info); |
|
| 840 | + } |
|
| 830 | 841 | // Editing an existing ban group |
| 831 | - else |
|
| 832 | - $ban_group_id = updateBanGroup($ban_info); |
|
| 842 | + else { |
|
| 843 | + $ban_group_id = updateBanGroup($ban_info); |
|
| 844 | + } |
|
| 833 | 845 | |
| 834 | 846 | if (is_numeric($ban_group_id)) |
| 835 | 847 | { |
@@ -840,9 +852,10 @@ discard block |
||
| 840 | 852 | $context['ban'] = $ban_info; |
| 841 | 853 | } |
| 842 | 854 | |
| 843 | - if (isset($_POST['ban_suggestions'])) |
|
| 844 | - // @TODO: is $_REQUEST['bi'] ever set? |
|
| 855 | + if (isset($_POST['ban_suggestions'])) { |
|
| 856 | + // @TODO: is $_REQUEST['bi'] ever set? |
|
| 845 | 857 | $saved_triggers = saveTriggers($_POST['ban_suggestions'], $ban_info['id'], isset($_REQUEST['u']) ? (int) $_REQUEST['u'] : 0, isset($_REQUEST['bi']) ? (int) $_REQUEST['bi'] : 0); |
| 858 | + } |
|
| 846 | 859 | |
| 847 | 860 | // Something went wrong somewhere... Oh well, let's go back. |
| 848 | 861 | if (!empty($context['ban_errors'])) |
@@ -852,8 +865,9 @@ discard block |
||
| 852 | 865 | $context['ban_suggestions'] = array_merge($context['ban_suggestions'], getMemberData((int) $_REQUEST['u'])); |
| 853 | 866 | |
| 854 | 867 | // Not strictly necessary, but it's nice |
| 855 | - if (!empty($context['ban_suggestions']['member']['id'])) |
|
| 856 | - $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
|
| 868 | + if (!empty($context['ban_suggestions']['member']['id'])) { |
|
| 869 | + $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
|
| 870 | + } |
|
| 857 | 871 | return BanEdit(); |
| 858 | 872 | } |
| 859 | 873 | $context['ban_suggestions']['saved_triggers'] = !empty($saved_triggers) ? $saved_triggers : array(); |
@@ -900,10 +914,11 @@ discard block |
||
| 900 | 914 | |
| 901 | 915 | foreach ($suggestions as $key => $value) |
| 902 | 916 | { |
| 903 | - if (is_array($value)) |
|
| 904 | - $triggers[$key] = $value; |
|
| 905 | - else |
|
| 906 | - $triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : ''; |
|
| 917 | + if (is_array($value)) { |
|
| 918 | + $triggers[$key] = $value; |
|
| 919 | + } else { |
|
| 920 | + $triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : ''; |
|
| 921 | + } |
|
| 907 | 922 | } |
| 908 | 923 | |
| 909 | 924 | $ban_triggers = validateTriggers($triggers); |
@@ -911,16 +926,18 @@ discard block |
||
| 911 | 926 | // Time to save! |
| 912 | 927 | if (!empty($ban_triggers['ban_triggers']) && empty($context['ban_errors'])) |
| 913 | 928 | { |
| 914 | - if (empty($ban_id)) |
|
| 915 | - addTriggers($ban_group, $ban_triggers['ban_triggers'], $ban_triggers['log_info']); |
|
| 916 | - else |
|
| 917 | - updateTriggers($ban_id, $ban_group, array_shift($ban_triggers['ban_triggers']), $ban_triggers['log_info']); |
|
| 929 | + if (empty($ban_id)) { |
|
| 930 | + addTriggers($ban_group, $ban_triggers['ban_triggers'], $ban_triggers['log_info']); |
|
| 931 | + } else { |
|
| 932 | + updateTriggers($ban_id, $ban_group, array_shift($ban_triggers['ban_triggers']), $ban_triggers['log_info']); |
|
| 933 | + } |
|
| 934 | + } |
|
| 935 | + if (!empty($context['ban_errors'])) { |
|
| 936 | + return $triggers; |
|
| 937 | + } else { |
|
| 938 | + return false; |
|
| 939 | + } |
|
| 918 | 940 | } |
| 919 | - if (!empty($context['ban_errors'])) |
|
| 920 | - return $triggers; |
|
| 921 | - else |
|
| 922 | - return false; |
|
| 923 | -} |
|
| 924 | 941 | |
| 925 | 942 | /** |
| 926 | 943 | * This function removes a bunch of triggers based on ids |
@@ -934,14 +951,17 @@ discard block |
||
| 934 | 951 | { |
| 935 | 952 | global $smcFunc, $scripturl; |
| 936 | 953 | |
| 937 | - if ($group_id !== false) |
|
| 938 | - $group_id = (int) $group_id; |
|
| 954 | + if ($group_id !== false) { |
|
| 955 | + $group_id = (int) $group_id; |
|
| 956 | + } |
|
| 939 | 957 | |
| 940 | - if (empty($group_id) && empty($items_ids)) |
|
| 941 | - return false; |
|
| 958 | + if (empty($group_id) && empty($items_ids)) { |
|
| 959 | + return false; |
|
| 960 | + } |
|
| 942 | 961 | |
| 943 | - if (!is_array($items_ids)) |
|
| 944 | - $items_ids = array($items_ids); |
|
| 962 | + if (!is_array($items_ids)) { |
|
| 963 | + $items_ids = array($items_ids); |
|
| 964 | + } |
|
| 945 | 965 | |
| 946 | 966 | $log_info = array(); |
| 947 | 967 | $ban_items = array(); |
@@ -979,8 +999,7 @@ discard block |
||
| 979 | 999 | 'bantype' => ($is_range ? 'ip_range' : 'main_ip'), |
| 980 | 1000 | 'value' => $ban_items[$row['id_ban']]['ip'], |
| 981 | 1001 | ); |
| 982 | - } |
|
| 983 | - elseif (!empty($row['hostname'])) |
|
| 1002 | + } elseif (!empty($row['hostname'])) |
|
| 984 | 1003 | { |
| 985 | 1004 | $ban_items[$row['id_ban']]['type'] = 'hostname'; |
| 986 | 1005 | $ban_items[$row['id_ban']]['hostname'] = str_replace('%', '*', $row['hostname']); |
@@ -988,8 +1007,7 @@ discard block |
||
| 988 | 1007 | 'bantype' => 'hostname', |
| 989 | 1008 | 'value' => $row['hostname'], |
| 990 | 1009 | ); |
| 991 | - } |
|
| 992 | - elseif (!empty($row['email_address'])) |
|
| 1010 | + } elseif (!empty($row['email_address'])) |
|
| 993 | 1011 | { |
| 994 | 1012 | $ban_items[$row['id_ban']]['type'] = 'email'; |
| 995 | 1013 | $ban_items[$row['id_ban']]['email'] = str_replace('%', '*', $row['email_address']); |
@@ -997,8 +1015,7 @@ discard block |
||
| 997 | 1015 | 'bantype' => 'email', |
| 998 | 1016 | 'value' => $ban_items[$row['id_ban']]['email'], |
| 999 | 1017 | ); |
| 1000 | - } |
|
| 1001 | - elseif (!empty($row['id_member'])) |
|
| 1018 | + } elseif (!empty($row['id_member'])) |
|
| 1002 | 1019 | { |
| 1003 | 1020 | $ban_items[$row['id_ban']]['type'] = 'user'; |
| 1004 | 1021 | $ban_items[$row['id_ban']]['user'] = array( |
@@ -1031,8 +1048,7 @@ discard block |
||
| 1031 | 1048 | 'ban_group' => $group_id, |
| 1032 | 1049 | ) |
| 1033 | 1050 | ); |
| 1034 | - } |
|
| 1035 | - elseif (!empty($items_ids)) |
|
| 1051 | + } elseif (!empty($items_ids)) |
|
| 1036 | 1052 | { |
| 1037 | 1053 | $smcFunc['db_query']('', ' |
| 1038 | 1054 | DELETE FROM {db_prefix}ban_items |
@@ -1057,13 +1073,15 @@ discard block |
||
| 1057 | 1073 | { |
| 1058 | 1074 | global $smcFunc; |
| 1059 | 1075 | |
| 1060 | - if (!is_array($group_ids)) |
|
| 1061 | - $group_ids = array($group_ids); |
|
| 1076 | + if (!is_array($group_ids)) { |
|
| 1077 | + $group_ids = array($group_ids); |
|
| 1078 | + } |
|
| 1062 | 1079 | |
| 1063 | 1080 | $group_ids = array_unique($group_ids); |
| 1064 | 1081 | |
| 1065 | - if (empty($group_ids)) |
|
| 1066 | - return false; |
|
| 1082 | + if (empty($group_ids)) { |
|
| 1083 | + return false; |
|
| 1084 | + } |
|
| 1067 | 1085 | |
| 1068 | 1086 | $smcFunc['db_query']('', ' |
| 1069 | 1087 | DELETE FROM {db_prefix}ban_groups |
@@ -1087,21 +1105,23 @@ discard block |
||
| 1087 | 1105 | { |
| 1088 | 1106 | global $smcFunc; |
| 1089 | 1107 | |
| 1090 | - if (empty($ids)) |
|
| 1091 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1108 | + if (empty($ids)) { |
|
| 1109 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1092 | 1110 | TRUNCATE {db_prefix}log_banned', |
| 1093 | 1111 | array( |
| 1094 | 1112 | ) |
| 1095 | 1113 | ); |
| 1096 | - else |
|
| 1114 | + } else |
|
| 1097 | 1115 | { |
| 1098 | - if (!is_array($ids)) |
|
| 1099 | - $ids = array($ids); |
|
| 1116 | + if (!is_array($ids)) { |
|
| 1117 | + $ids = array($ids); |
|
| 1118 | + } |
|
| 1100 | 1119 | |
| 1101 | 1120 | $ids = array_unique($ids); |
| 1102 | 1121 | |
| 1103 | - if (empty($ids)) |
|
| 1104 | - return false; |
|
| 1122 | + if (empty($ids)) { |
|
| 1123 | + return false; |
|
| 1124 | + } |
|
| 1105 | 1125 | |
| 1106 | 1126 | $smcFunc['db_query']('', ' |
| 1107 | 1127 | DELETE FROM {db_prefix}log_banned |
@@ -1127,8 +1147,9 @@ discard block |
||
| 1127 | 1147 | { |
| 1128 | 1148 | global $context, $smcFunc; |
| 1129 | 1149 | |
| 1130 | - if (empty($triggers)) |
|
| 1131 | - $context['ban_erros'][] = 'ban_empty_triggers'; |
|
| 1150 | + if (empty($triggers)) { |
|
| 1151 | + $context['ban_erros'][] = 'ban_empty_triggers'; |
|
| 1152 | + } |
|
| 1132 | 1153 | |
| 1133 | 1154 | $ban_triggers = array(); |
| 1134 | 1155 | $log_info = array(); |
@@ -1137,39 +1158,39 @@ discard block |
||
| 1137 | 1158 | { |
| 1138 | 1159 | if (!empty($value)) |
| 1139 | 1160 | { |
| 1140 | - if ($key == 'member') |
|
| 1141 | - continue; |
|
| 1161 | + if ($key == 'member') { |
|
| 1162 | + continue; |
|
| 1163 | + } |
|
| 1142 | 1164 | |
| 1143 | 1165 | if ($key == 'main_ip') |
| 1144 | 1166 | { |
| 1145 | 1167 | $value = trim($value); |
| 1146 | 1168 | $ip_parts = ip2range($value); |
| 1147 | - if (!checkExistingTriggerIP($ip_parts, $value)) |
|
| 1148 | - $context['ban_erros'][] = 'invalid_ip'; |
|
| 1149 | - else |
|
| 1169 | + if (!checkExistingTriggerIP($ip_parts, $value)) { |
|
| 1170 | + $context['ban_erros'][] = 'invalid_ip'; |
|
| 1171 | + } else |
|
| 1150 | 1172 | { |
| 1151 | 1173 | $ban_triggers['main_ip'] = array( |
| 1152 | 1174 | 'ip_low' => $ip_parts['low'], |
| 1153 | 1175 | 'ip_high' => $ip_parts['high'] |
| 1154 | 1176 | ); |
| 1155 | 1177 | } |
| 1156 | - } |
|
| 1157 | - elseif ($key == 'hostname') |
|
| 1178 | + } elseif ($key == 'hostname') |
|
| 1158 | 1179 | { |
| 1159 | - if (preg_match('/[^\w.\-*]/', $value) == 1) |
|
| 1160 | - $context['ban_erros'][] = 'invalid_hostname'; |
|
| 1161 | - else |
|
| 1180 | + if (preg_match('/[^\w.\-*]/', $value) == 1) { |
|
| 1181 | + $context['ban_erros'][] = 'invalid_hostname'; |
|
| 1182 | + } else |
|
| 1162 | 1183 | { |
| 1163 | 1184 | // Replace the * wildcard by a MySQL wildcard %. |
| 1164 | 1185 | $value = substr(str_replace('*', '%', $value), 0, 255); |
| 1165 | 1186 | |
| 1166 | 1187 | $ban_triggers['hostname']['hostname'] = $value; |
| 1167 | 1188 | } |
| 1168 | - } |
|
| 1169 | - elseif ($key == 'email') |
|
| 1189 | + } elseif ($key == 'email') |
|
| 1170 | 1190 | { |
| 1171 | - if (preg_match('/[^\w.\-\+*@]/', $value) == 1) |
|
| 1172 | - $context['ban_erros'][] = 'invalid_email'; |
|
| 1191 | + if (preg_match('/[^\w.\-\+*@]/', $value) == 1) { |
|
| 1192 | + $context['ban_erros'][] = 'invalid_email'; |
|
| 1193 | + } |
|
| 1173 | 1194 | |
| 1174 | 1195 | // Check the user is not banning an admin. |
| 1175 | 1196 | $request = $smcFunc['db_query']('', ' |
@@ -1183,15 +1204,15 @@ discard block |
||
| 1183 | 1204 | 'email' => $value, |
| 1184 | 1205 | ) |
| 1185 | 1206 | ); |
| 1186 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1187 | - $context['ban_erros'][] = 'no_ban_admin'; |
|
| 1207 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1208 | + $context['ban_erros'][] = 'no_ban_admin'; |
|
| 1209 | + } |
|
| 1188 | 1210 | $smcFunc['db_free_result']($request); |
| 1189 | 1211 | |
| 1190 | 1212 | $value = substr(strtolower(str_replace('*', '%', $value)), 0, 255); |
| 1191 | 1213 | |
| 1192 | 1214 | $ban_triggers['email']['email_address'] = $value; |
| 1193 | - } |
|
| 1194 | - elseif ($key == 'user') |
|
| 1215 | + } elseif ($key == 'user') |
|
| 1195 | 1216 | { |
| 1196 | 1217 | $user = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $smcFunc['htmlspecialchars']($value, ENT_QUOTES)); |
| 1197 | 1218 | |
@@ -1205,8 +1226,9 @@ discard block |
||
| 1205 | 1226 | 'username' => $user, |
| 1206 | 1227 | ) |
| 1207 | 1228 | ); |
| 1208 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1209 | - $context['ban_erros'][] = 'invalid_username'; |
|
| 1229 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1230 | + $context['ban_erros'][] = 'invalid_username'; |
|
| 1231 | + } |
|
| 1210 | 1232 | list ($value, $isAdmin) = $smcFunc['db_fetch_row']($request); |
| 1211 | 1233 | $smcFunc['db_free_result']($request); |
| 1212 | 1234 | |
@@ -1214,25 +1236,25 @@ discard block |
||
| 1214 | 1236 | { |
| 1215 | 1237 | unset($value); |
| 1216 | 1238 | $context['ban_erros'][] = 'no_ban_admin'; |
| 1239 | + } else { |
|
| 1240 | + $ban_triggers['user']['id_member'] = $value; |
|
| 1217 | 1241 | } |
| 1218 | - else |
|
| 1219 | - $ban_triggers['user']['id_member'] = $value; |
|
| 1220 | - } |
|
| 1221 | - elseif (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
| 1242 | + } elseif (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
| 1222 | 1243 | { |
| 1223 | 1244 | // Special case, those two are arrays themselves |
| 1224 | 1245 | $values = array_unique($value); |
| 1225 | 1246 | // Don't add the main IP again. |
| 1226 | - if (isset($triggers['main_ip'])) |
|
| 1227 | - $values = array_diff($values, array($triggers['main_ip'])); |
|
| 1247 | + if (isset($triggers['main_ip'])) { |
|
| 1248 | + $values = array_diff($values, array($triggers['main_ip'])); |
|
| 1249 | + } |
|
| 1228 | 1250 | unset($value); |
| 1229 | 1251 | foreach ($values as $val) |
| 1230 | 1252 | { |
| 1231 | 1253 | $val = trim($val); |
| 1232 | 1254 | $ip_parts = ip2range($val); |
| 1233 | - if (!checkExistingTriggerIP($ip_parts, $val)) |
|
| 1234 | - $context['ban_erros'][] = 'invalid_ip'; |
|
| 1235 | - else |
|
| 1255 | + if (!checkExistingTriggerIP($ip_parts, $val)) { |
|
| 1256 | + $context['ban_erros'][] = 'invalid_ip'; |
|
| 1257 | + } else |
|
| 1236 | 1258 | { |
| 1237 | 1259 | $ban_triggers[$key][] = array( |
| 1238 | 1260 | 'ip_low' => $ip_parts['low'], |
@@ -1245,15 +1267,16 @@ discard block |
||
| 1245 | 1267 | ); |
| 1246 | 1268 | } |
| 1247 | 1269 | } |
| 1270 | + } else { |
|
| 1271 | + $context['ban_erros'][] = 'no_bantype_selected'; |
|
| 1248 | 1272 | } |
| 1249 | - else |
|
| 1250 | - $context['ban_erros'][] = 'no_bantype_selected'; |
|
| 1251 | 1273 | |
| 1252 | - if (isset($value) && !is_array($value)) |
|
| 1253 | - $log_info[] = array( |
|
| 1274 | + if (isset($value) && !is_array($value)) { |
|
| 1275 | + $log_info[] = array( |
|
| 1254 | 1276 | 'value' => $value, |
| 1255 | 1277 | 'bantype' => $key, |
| 1256 | 1278 | ); |
| 1279 | + } |
|
| 1257 | 1280 | } |
| 1258 | 1281 | } |
| 1259 | 1282 | return array('ban_triggers' => $ban_triggers, 'log_info' => $log_info); |
@@ -1273,8 +1296,9 @@ discard block |
||
| 1273 | 1296 | { |
| 1274 | 1297 | global $smcFunc, $context; |
| 1275 | 1298 | |
| 1276 | - if (empty($group_id)) |
|
| 1277 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1299 | + if (empty($group_id)) { |
|
| 1300 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1301 | + } |
|
| 1278 | 1302 | |
| 1279 | 1303 | // Preset all values that are required. |
| 1280 | 1304 | $values = array( |
@@ -1299,18 +1323,21 @@ discard block |
||
| 1299 | 1323 | foreach ($triggers as $key => $trigger) |
| 1300 | 1324 | { |
| 1301 | 1325 | // Exceptions, exceptions, exceptions...always exceptions... :P |
| 1302 | - if (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
| 1303 | - foreach ($trigger as $real_trigger) |
|
| 1326 | + if (in_array($key, array('ips_in_messages', 'ips_in_errors'))) { |
|
| 1327 | + foreach ($trigger as $real_trigger) |
|
| 1304 | 1328 | $insertTriggers[] = array_merge($values, $real_trigger); |
| 1305 | - else |
|
| 1306 | - $insertTriggers[] = array_merge($values, $trigger); |
|
| 1329 | + } else { |
|
| 1330 | + $insertTriggers[] = array_merge($values, $trigger); |
|
| 1331 | + } |
|
| 1307 | 1332 | } |
| 1308 | 1333 | |
| 1309 | - if (empty($insertTriggers)) |
|
| 1310 | - $context['ban_errors'][] = 'ban_no_triggers'; |
|
| 1334 | + if (empty($insertTriggers)) { |
|
| 1335 | + $context['ban_errors'][] = 'ban_no_triggers'; |
|
| 1336 | + } |
|
| 1311 | 1337 | |
| 1312 | - if (!empty($context['ban_errors'])) |
|
| 1313 | - return false; |
|
| 1338 | + if (!empty($context['ban_errors'])) { |
|
| 1339 | + return false; |
|
| 1340 | + } |
|
| 1314 | 1341 | |
| 1315 | 1342 | $smcFunc['db_insert']('', |
| 1316 | 1343 | '{db_prefix}ban_items', |
@@ -1338,15 +1365,19 @@ discard block |
||
| 1338 | 1365 | { |
| 1339 | 1366 | global $smcFunc, $context; |
| 1340 | 1367 | |
| 1341 | - if (empty($ban_item)) |
|
| 1342 | - $context['ban_errors'][] = 'ban_ban_item_empty'; |
|
| 1343 | - if (empty($group_id)) |
|
| 1344 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1345 | - if (empty($trigger)) |
|
| 1346 | - $context['ban_errors'][] = 'ban_no_triggers'; |
|
| 1368 | + if (empty($ban_item)) { |
|
| 1369 | + $context['ban_errors'][] = 'ban_ban_item_empty'; |
|
| 1370 | + } |
|
| 1371 | + if (empty($group_id)) { |
|
| 1372 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1373 | + } |
|
| 1374 | + if (empty($trigger)) { |
|
| 1375 | + $context['ban_errors'][] = 'ban_no_triggers'; |
|
| 1376 | + } |
|
| 1347 | 1377 | |
| 1348 | - if (!empty($context['ban_errors'])) |
|
| 1349 | - return; |
|
| 1378 | + if (!empty($context['ban_errors'])) { |
|
| 1379 | + return; |
|
| 1380 | + } |
|
| 1350 | 1381 | |
| 1351 | 1382 | // Preset all values that are required. |
| 1352 | 1383 | $values = array( |
@@ -1387,8 +1418,9 @@ discard block |
||
| 1387 | 1418 | */ |
| 1388 | 1419 | function logTriggersUpdates($logs, $new = true, $removal = false) |
| 1389 | 1420 | { |
| 1390 | - if (empty($logs)) |
|
| 1391 | - return; |
|
| 1421 | + if (empty($logs)) { |
|
| 1422 | + return; |
|
| 1423 | + } |
|
| 1392 | 1424 | |
| 1393 | 1425 | $log_name_map = array( |
| 1394 | 1426 | 'main_ip' => 'ip_range', |
@@ -1399,14 +1431,15 @@ discard block |
||
| 1399 | 1431 | ); |
| 1400 | 1432 | |
| 1401 | 1433 | // Log the addion of the ban entries into the moderation log. |
| 1402 | - foreach ($logs as $log) |
|
| 1403 | - logAction('ban' . ($removal == true ? 'remove' : ''), array( |
|
| 1434 | + foreach ($logs as $log) { |
|
| 1435 | + logAction('ban' . ($removal == true ? 'remove' : ''), array( |
|
| 1404 | 1436 | $log_name_map[$log['bantype']] => $log['value'], |
| 1405 | 1437 | 'new' => empty($new) ? 0 : 1, |
| 1406 | 1438 | 'remove' => empty($removal) ? 0 : 1, |
| 1407 | 1439 | 'type' => $log['bantype'], |
| 1408 | 1440 | )); |
| 1409 | -} |
|
| 1441 | + } |
|
| 1442 | + } |
|
| 1410 | 1443 | |
| 1411 | 1444 | /** |
| 1412 | 1445 | * Updates an existing ban group |
@@ -1420,12 +1453,15 @@ discard block |
||
| 1420 | 1453 | { |
| 1421 | 1454 | global $smcFunc, $context; |
| 1422 | 1455 | |
| 1423 | - if (empty($ban_info['name'])) |
|
| 1424 | - $context['ban_errors'][] = 'ban_name_empty'; |
|
| 1425 | - if (empty($ban_info['id'])) |
|
| 1426 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1427 | - if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) |
|
| 1428 | - $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
| 1456 | + if (empty($ban_info['name'])) { |
|
| 1457 | + $context['ban_errors'][] = 'ban_name_empty'; |
|
| 1458 | + } |
|
| 1459 | + if (empty($ban_info['id'])) { |
|
| 1460 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1461 | + } |
|
| 1462 | + if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) { |
|
| 1463 | + $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
| 1464 | + } |
|
| 1429 | 1465 | |
| 1430 | 1466 | if (!empty($ban_info['id'])) |
| 1431 | 1467 | { |
@@ -1440,8 +1476,9 @@ discard block |
||
| 1440 | 1476 | ) |
| 1441 | 1477 | ); |
| 1442 | 1478 | |
| 1443 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1444 | - $context['ban_errors'][] = 'ban_not_found'; |
|
| 1479 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1480 | + $context['ban_errors'][] = 'ban_not_found'; |
|
| 1481 | + } |
|
| 1445 | 1482 | $smcFunc['db_free_result']($request); |
| 1446 | 1483 | } |
| 1447 | 1484 | |
@@ -1459,13 +1496,15 @@ discard block |
||
| 1459 | 1496 | 'new_ban_name' => $ban_info['name'], |
| 1460 | 1497 | ) |
| 1461 | 1498 | ); |
| 1462 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1463 | - $context['ban_errors'][] = 'ban_name_exists'; |
|
| 1499 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1500 | + $context['ban_errors'][] = 'ban_name_exists'; |
|
| 1501 | + } |
|
| 1464 | 1502 | $smcFunc['db_free_result']($request); |
| 1465 | 1503 | } |
| 1466 | 1504 | |
| 1467 | - if (!empty($context['ban_errors'])) |
|
| 1468 | - return $ban_info['id']; |
|
| 1505 | + if (!empty($context['ban_errors'])) { |
|
| 1506 | + return $ban_info['id']; |
|
| 1507 | + } |
|
| 1469 | 1508 | |
| 1470 | 1509 | $smcFunc['db_query']('', ' |
| 1471 | 1510 | UPDATE {db_prefix}ban_groups |
@@ -1509,10 +1548,12 @@ discard block |
||
| 1509 | 1548 | { |
| 1510 | 1549 | global $smcFunc, $context; |
| 1511 | 1550 | |
| 1512 | - if (empty($ban_info['name'])) |
|
| 1513 | - $context['ban_errors'][] = 'ban_name_empty'; |
|
| 1514 | - if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) |
|
| 1515 | - $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
| 1551 | + if (empty($ban_info['name'])) { |
|
| 1552 | + $context['ban_errors'][] = 'ban_name_empty'; |
|
| 1553 | + } |
|
| 1554 | + if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) { |
|
| 1555 | + $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
| 1556 | + } |
|
| 1516 | 1557 | |
| 1517 | 1558 | if (!empty($ban_info['name'])) |
| 1518 | 1559 | { |
@@ -1527,13 +1568,15 @@ discard block |
||
| 1527 | 1568 | ) |
| 1528 | 1569 | ); |
| 1529 | 1570 | |
| 1530 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
| 1531 | - $context['ban_errors'][] = 'ban_name_exists'; |
|
| 1571 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
| 1572 | + $context['ban_errors'][] = 'ban_name_exists'; |
|
| 1573 | + } |
|
| 1532 | 1574 | $smcFunc['db_free_result']($request); |
| 1533 | 1575 | } |
| 1534 | 1576 | |
| 1535 | - if (!empty($context['ban_errors'])) |
|
| 1536 | - return; |
|
| 1577 | + if (!empty($context['ban_errors'])) { |
|
| 1578 | + return; |
|
| 1579 | + } |
|
| 1537 | 1580 | |
| 1538 | 1581 | // Yes yes, we're ready to add now. |
| 1539 | 1582 | $ban_info['id'] = $smcFunc['db_insert']('', |
@@ -1550,8 +1593,9 @@ discard block |
||
| 1550 | 1593 | 1 |
| 1551 | 1594 | ); |
| 1552 | 1595 | |
| 1553 | - if (empty($ban_info['id'])) |
|
| 1554 | - $context['ban_errors'][] = 'impossible_insert_new_bangroup'; |
|
| 1596 | + if (empty($ban_info['id'])) { |
|
| 1597 | + $context['ban_errors'][] = 'impossible_insert_new_bangroup'; |
|
| 1598 | + } |
|
| 1555 | 1599 | |
| 1556 | 1600 | return $ban_info['id']; |
| 1557 | 1601 | } |
@@ -1576,24 +1620,24 @@ discard block |
||
| 1576 | 1620 | $ban_group = isset($_REQUEST['bg']) ? (int) $_REQUEST['bg'] : 0; |
| 1577 | 1621 | $ban_id = isset($_REQUEST['bi']) ? (int) $_REQUEST['bi'] : 0; |
| 1578 | 1622 | |
| 1579 | - if (empty($ban_group)) |
|
| 1580 | - fatal_lang_error('ban_not_found', false); |
|
| 1623 | + if (empty($ban_group)) { |
|
| 1624 | + fatal_lang_error('ban_not_found', false); |
|
| 1625 | + } |
|
| 1581 | 1626 | |
| 1582 | 1627 | if (isset($_POST['add_new_trigger']) && !empty($_POST['ban_suggestions'])) |
| 1583 | 1628 | { |
| 1584 | 1629 | saveTriggers($_POST['ban_suggestions'], $ban_group, 0, $ban_id); |
| 1585 | 1630 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
| 1586 | - } |
|
| 1587 | - elseif (isset($_POST['edit_trigger']) && !empty($_POST['ban_suggestions'])) |
|
| 1631 | + } elseif (isset($_POST['edit_trigger']) && !empty($_POST['ban_suggestions'])) |
|
| 1588 | 1632 | { |
| 1589 | 1633 | // The first replaces the old one, the others are added new (simplification, otherwise it would require another query and some work...) |
| 1590 | 1634 | saveTriggers(array_shift($_POST['ban_suggestions']), $ban_group, 0, $ban_id); |
| 1591 | - if (!empty($_POST['ban_suggestions'])) |
|
| 1592 | - saveTriggers($_POST['ban_suggestions'], $ban_group); |
|
| 1635 | + if (!empty($_POST['ban_suggestions'])) { |
|
| 1636 | + saveTriggers($_POST['ban_suggestions'], $ban_group); |
|
| 1637 | + } |
|
| 1593 | 1638 | |
| 1594 | 1639 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
| 1595 | - } |
|
| 1596 | - elseif (isset($_POST['edit_trigger'])) |
|
| 1640 | + } elseif (isset($_POST['edit_trigger'])) |
|
| 1597 | 1641 | { |
| 1598 | 1642 | removeBanTriggers($ban_id); |
| 1599 | 1643 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
@@ -1624,8 +1668,7 @@ discard block |
||
| 1624 | 1668 | ), |
| 1625 | 1669 | 'is_new' => true, |
| 1626 | 1670 | ); |
| 1627 | - } |
|
| 1628 | - else |
|
| 1671 | + } else |
|
| 1629 | 1672 | { |
| 1630 | 1673 | $request = $smcFunc['db_query']('', ' |
| 1631 | 1674 | SELECT |
@@ -1642,8 +1685,9 @@ discard block |
||
| 1642 | 1685 | 'ban_group' => $ban_group, |
| 1643 | 1686 | ) |
| 1644 | 1687 | ); |
| 1645 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1646 | - fatal_lang_error('ban_not_found', false); |
|
| 1688 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1689 | + fatal_lang_error('ban_not_found', false); |
|
| 1690 | + } |
|
| 1647 | 1691 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1648 | 1692 | $smcFunc['db_free_result']($request); |
| 1649 | 1693 | |
@@ -1692,8 +1736,9 @@ discard block |
||
| 1692 | 1736 | removeBanTriggers($_POST['remove']); |
| 1693 | 1737 | |
| 1694 | 1738 | // Rehabilitate some members. |
| 1695 | - if ($_REQUEST['entity'] == 'member') |
|
| 1696 | - updateBanMembers(); |
|
| 1739 | + if ($_REQUEST['entity'] == 'member') { |
|
| 1740 | + updateBanMembers(); |
|
| 1741 | + } |
|
| 1697 | 1742 | |
| 1698 | 1743 | // Make sure the ban cache is refreshed. |
| 1699 | 1744 | updateSettings(array('banLastUpdated' => time())); |
@@ -1806,8 +1851,7 @@ discard block |
||
| 1806 | 1851 | 'default' => 'bi.ip_low, bi.ip_high, bi.ip_low', |
| 1807 | 1852 | 'reverse' => 'bi.ip_low DESC, bi.ip_high DESC', |
| 1808 | 1853 | ); |
| 1809 | - } |
|
| 1810 | - elseif ($context['selected_entity'] === 'hostname') |
|
| 1854 | + } elseif ($context['selected_entity'] === 'hostname') |
|
| 1811 | 1855 | { |
| 1812 | 1856 | $listOptions['columns']['banned_entity']['data'] = array( |
| 1813 | 1857 | 'function' => function($rowData) use ($smcFunc) |
@@ -1819,8 +1863,7 @@ discard block |
||
| 1819 | 1863 | 'default' => 'bi.hostname', |
| 1820 | 1864 | 'reverse' => 'bi.hostname DESC', |
| 1821 | 1865 | ); |
| 1822 | - } |
|
| 1823 | - elseif ($context['selected_entity'] === 'email') |
|
| 1866 | + } elseif ($context['selected_entity'] === 'email') |
|
| 1824 | 1867 | { |
| 1825 | 1868 | $listOptions['columns']['banned_entity']['data'] = array( |
| 1826 | 1869 | 'function' => function($rowData) use ($smcFunc) |
@@ -1832,8 +1875,7 @@ discard block |
||
| 1832 | 1875 | 'default' => 'bi.email_address', |
| 1833 | 1876 | 'reverse' => 'bi.email_address DESC', |
| 1834 | 1877 | ); |
| 1835 | - } |
|
| 1836 | - elseif ($context['selected_entity'] === 'member') |
|
| 1878 | + } elseif ($context['selected_entity'] === 'member') |
|
| 1837 | 1879 | { |
| 1838 | 1880 | $listOptions['columns']['banned_entity']['data'] = array( |
| 1839 | 1881 | 'sprintf' => array( |
@@ -1897,8 +1939,9 @@ discard block |
||
| 1897 | 1939 | ) |
| 1898 | 1940 | ); |
| 1899 | 1941 | $ban_triggers = array(); |
| 1900 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1901 | - $ban_triggers[] = $row; |
|
| 1942 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1943 | + $ban_triggers[] = $row; |
|
| 1944 | + } |
|
| 1902 | 1945 | $smcFunc['db_free_result']($request); |
| 1903 | 1946 | |
| 1904 | 1947 | return $ban_triggers; |
@@ -1954,8 +1997,9 @@ discard block |
||
| 1954 | 1997 | validateToken('admin-bl'); |
| 1955 | 1998 | |
| 1956 | 1999 | // 'Delete all entries' button was pressed. |
| 1957 | - if (!empty($_POST['removeAll'])) |
|
| 1958 | - removeBanLogs(); |
|
| 2000 | + if (!empty($_POST['removeAll'])) { |
|
| 2001 | + removeBanLogs(); |
|
| 2002 | + } |
|
| 1959 | 2003 | // 'Delete selection' button was pressed. |
| 1960 | 2004 | else |
| 1961 | 2005 | { |
@@ -2164,12 +2208,15 @@ discard block |
||
| 2164 | 2208 | $low = inet_dtop($low); |
| 2165 | 2209 | $high = inet_dtop($high); |
| 2166 | 2210 | |
| 2167 | - if ($low == '255.255.255.255') return 'unknown'; |
|
| 2168 | - if ($low == $high) |
|
| 2169 | - return $low; |
|
| 2170 | - else |
|
| 2171 | - return $low . '-' . $high; |
|
| 2172 | -} |
|
| 2211 | + if ($low == '255.255.255.255') { |
|
| 2212 | + return 'unknown'; |
|
| 2213 | + } |
|
| 2214 | + if ($low == $high) { |
|
| 2215 | + return $low; |
|
| 2216 | + } else { |
|
| 2217 | + return $low . '-' . $high; |
|
| 2218 | + } |
|
| 2219 | + } |
|
| 2173 | 2220 | |
| 2174 | 2221 | /** |
| 2175 | 2222 | * Checks whether a given IP range already exists in the trigger list. |
@@ -2245,15 +2292,17 @@ discard block |
||
| 2245 | 2292 | $memberEmailWild = array(); |
| 2246 | 2293 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2247 | 2294 | { |
| 2248 | - if ($row['id_member']) |
|
| 2249 | - $memberIDs[$row['id_member']] = $row['id_member']; |
|
| 2295 | + if ($row['id_member']) { |
|
| 2296 | + $memberIDs[$row['id_member']] = $row['id_member']; |
|
| 2297 | + } |
|
| 2250 | 2298 | if ($row['email_address']) |
| 2251 | 2299 | { |
| 2252 | 2300 | // Does it have a wildcard - if so we can't do a IN on it. |
| 2253 | - if (strpos($row['email_address'], '%') !== false) |
|
| 2254 | - $memberEmailWild[$row['email_address']] = $row['email_address']; |
|
| 2255 | - else |
|
| 2256 | - $memberEmails[$row['email_address']] = $row['email_address']; |
|
| 2301 | + if (strpos($row['email_address'], '%') !== false) { |
|
| 2302 | + $memberEmailWild[$row['email_address']] = $row['email_address']; |
|
| 2303 | + } else { |
|
| 2304 | + $memberEmails[$row['email_address']] = $row['email_address']; |
|
| 2305 | + } |
|
| 2257 | 2306 | } |
| 2258 | 2307 | } |
| 2259 | 2308 | $smcFunc['db_free_result']($request); |
@@ -2304,14 +2353,15 @@ discard block |
||
| 2304 | 2353 | } |
| 2305 | 2354 | |
| 2306 | 2355 | // We welcome our new members in the realm of the banned. |
| 2307 | - if (!empty($newMembers)) |
|
| 2308 | - $smcFunc['db_query']('', ' |
|
| 2356 | + if (!empty($newMembers)) { |
|
| 2357 | + $smcFunc['db_query']('', ' |
|
| 2309 | 2358 | DELETE FROM {db_prefix}log_online |
| 2310 | 2359 | WHERE id_member IN ({array_int:new_banned_members})', |
| 2311 | 2360 | array( |
| 2312 | 2361 | 'new_banned_members' => $newMembers, |
| 2313 | 2362 | ) |
| 2314 | 2363 | ); |
| 2364 | + } |
|
| 2315 | 2365 | |
| 2316 | 2366 | // Find members that are wrongfully marked as banned. |
| 2317 | 2367 | $request = $smcFunc['db_query']('', ' |
@@ -2338,9 +2388,10 @@ discard block |
||
| 2338 | 2388 | } |
| 2339 | 2389 | $smcFunc['db_free_result']($request); |
| 2340 | 2390 | |
| 2341 | - if (!empty($updates)) |
|
| 2342 | - foreach ($updates as $newStatus => $members) |
|
| 2391 | + if (!empty($updates)) { |
|
| 2392 | + foreach ($updates as $newStatus => $members) |
|
| 2343 | 2393 | updateMemberData($members, array('is_activated' => $newStatus)); |
| 2394 | + } |
|
| 2344 | 2395 | |
| 2345 | 2396 | // Update the latest member and our total members as banning may change them. |
| 2346 | 2397 | updateStats('member'); |
@@ -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 | * Sets and call a function based on the given subaction. Acts as a dispatcher function. |
@@ -54,8 +55,9 @@ discard block |
||
| 54 | 55 | ); |
| 55 | 56 | |
| 56 | 57 | // This comes under the umbrella of moderating posts. |
| 57 | - if ($context['report_type'] == 'members' || $user_info['mod_cache']['bq'] == '0=1') |
|
| 58 | - isAllowedTo('moderate_forum'); |
|
| 58 | + if ($context['report_type'] == 'members' || $user_info['mod_cache']['bq'] == '0=1') { |
|
| 59 | + isAllowedTo('moderate_forum'); |
|
| 60 | + } |
|
| 59 | 61 | |
| 60 | 62 | $subActions = array( |
| 61 | 63 | 'show' => 'ShowReports', |
@@ -70,11 +72,11 @@ discard block |
||
| 70 | 72 | call_integration_hook('integrate_reported_' . $context['report_type'], array(&$subActions)); |
| 71 | 73 | |
| 72 | 74 | // By default we call the open sub-action. |
| 73 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 74 | - $context['sub_action'] = $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_REQUEST['sa']), ENT_QUOTES); |
|
| 75 | - |
|
| 76 | - else |
|
| 77 | - $context['sub_action'] = 'show'; |
|
| 75 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 76 | + $context['sub_action'] = $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_REQUEST['sa']), ENT_QUOTES); |
|
| 77 | + } else { |
|
| 78 | + $context['sub_action'] = 'show'; |
|
| 79 | + } |
|
| 78 | 80 | |
| 79 | 81 | // Hi Ho Silver Away! |
| 80 | 82 | call_helper($subActions[$context['sub_action']]); |
@@ -116,11 +118,13 @@ discard block |
||
| 116 | 118 | |
| 117 | 119 | // All the ones to update... |
| 118 | 120 | $toClose = array(); |
| 119 | - foreach ($_POST['close'] as $rid) |
|
| 120 | - $toClose[] = (int) $rid; |
|
| 121 | + foreach ($_POST['close'] as $rid) { |
|
| 122 | + $toClose[] = (int) $rid; |
|
| 123 | + } |
|
| 121 | 124 | |
| 122 | - if (!empty($toClose)) |
|
| 123 | - updateReport('closed', 1, $toClose); |
|
| 125 | + if (!empty($toClose)) { |
|
| 126 | + updateReport('closed', 1, $toClose); |
|
| 127 | + } |
|
| 124 | 128 | |
| 125 | 129 | // Set the confirmation message. |
| 126 | 130 | $_SESSION['rc_confirmation'] = 'close_all'; |
@@ -175,8 +179,9 @@ discard block |
||
| 175 | 179 | global $context, $sourcedir, $scripturl, $txt; |
| 176 | 180 | |
| 177 | 181 | // Have to at least give us something to work with. |
| 178 | - if (empty($_REQUEST['rid'])) |
|
| 179 | - fatal_lang_error('mc_reportedp_none_found'); |
|
| 182 | + if (empty($_REQUEST['rid'])) { |
|
| 183 | + fatal_lang_error('mc_reportedp_none_found'); |
|
| 184 | + } |
|
| 180 | 185 | |
| 181 | 186 | // Integers only please |
| 182 | 187 | $report_id = (int) $_REQUEST['rid']; |
@@ -184,8 +189,9 @@ discard block |
||
| 184 | 189 | // Get the report details. |
| 185 | 190 | $report = getReportDetails($report_id); |
| 186 | 191 | |
| 187 | - if (!$report) |
|
| 188 | - fatal_lang_error('mc_no_modreport_found'); |
|
| 192 | + if (!$report) { |
|
| 193 | + fatal_lang_error('mc_no_modreport_found'); |
|
| 194 | + } |
|
| 189 | 195 | |
| 190 | 196 | // Build the report data - basic details first, then extra stuff based on the type |
| 191 | 197 | $context['report'] = array( |
@@ -211,8 +217,7 @@ discard block |
||
| 211 | 217 | 'href' => $scripturl . '?action=profile;u=' . $report['id_user'], |
| 212 | 218 | ), |
| 213 | 219 | ); |
| 214 | - } |
|
| 215 | - else |
|
| 220 | + } else |
|
| 216 | 221 | { |
| 217 | 222 | $extraDetails = array( |
| 218 | 223 | 'topic_id' => $report['id_topic'], |
@@ -235,8 +240,9 @@ discard block |
||
| 235 | 240 | |
| 236 | 241 | $reportComments = getReportComments($report_id); |
| 237 | 242 | |
| 238 | - if (!empty($reportComments)) |
|
| 239 | - $context['report'] = array_merge($context['report'], $reportComments); |
|
| 243 | + if (!empty($reportComments)) { |
|
| 244 | + $context['report'] = array_merge($context['report'], $reportComments); |
|
| 245 | + } |
|
| 240 | 246 | |
| 241 | 247 | // What have the other moderators done to this message? |
| 242 | 248 | require_once($sourcedir . '/Modlog.php'); |
@@ -257,8 +263,7 @@ discard block |
||
| 257 | 263 | 1, |
| 258 | 264 | true, |
| 259 | 265 | ); |
| 260 | - } |
|
| 261 | - else |
|
| 266 | + } else |
|
| 262 | 267 | { |
| 263 | 268 | $params = array( |
| 264 | 269 | 'lm.id_topic = {int:id_topic} |
@@ -358,16 +363,16 @@ discard block |
||
| 358 | 363 | createList($listOptions); |
| 359 | 364 | |
| 360 | 365 | // Make sure to get the correct tab selected. |
| 361 | - if ($context['report']['closed']) |
|
| 362 | - $context[$context['moderation_menu_name']]['current_subsection'] = 'closed'; |
|
| 366 | + if ($context['report']['closed']) { |
|
| 367 | + $context[$context['moderation_menu_name']]['current_subsection'] = 'closed'; |
|
| 368 | + } |
|
| 363 | 369 | |
| 364 | 370 | // Finally we are done :P |
| 365 | 371 | if ($context['report_type'] == 'members') |
| 366 | 372 | { |
| 367 | 373 | $context['page_title'] = sprintf($txt['mc_viewmemberreport'], $context['report']['user']['name']); |
| 368 | 374 | $context['sub_template'] = 'viewmemberreport'; |
| 369 | - } |
|
| 370 | - else |
|
| 375 | + } else |
|
| 371 | 376 | { |
| 372 | 377 | $context['page_title'] = sprintf($txt['mc_viewmodreport'], $context['report']['subject'], $context['report']['author']['name']); |
| 373 | 378 | $context['sub_template'] = 'viewmodreport'; |
@@ -390,8 +395,9 @@ discard block |
||
| 390 | 395 | global $smcFunc, $scripturl, $user_info, $context; |
| 391 | 396 | |
| 392 | 397 | // The report ID is a must. |
| 393 | - if (empty($_REQUEST['rid'])) |
|
| 394 | - fatal_lang_error('mc_reportedp_none_found'); |
|
| 398 | + if (empty($_REQUEST['rid'])) { |
|
| 399 | + fatal_lang_error('mc_reportedp_none_found'); |
|
| 400 | + } |
|
| 395 | 401 | |
| 396 | 402 | // Integers only please. |
| 397 | 403 | $report_id = (int) $_REQUEST['rid']; |
@@ -416,8 +422,9 @@ discard block |
||
| 416 | 422 | checkSession('get'); |
| 417 | 423 | validateToken('mod-reportC-delete', 'get'); |
| 418 | 424 | |
| 419 | - if (empty($_REQUEST['mid'])) |
|
| 420 | - fatal_lang_error('mc_reportedp_comment_none_found'); |
|
| 425 | + if (empty($_REQUEST['mid'])) { |
|
| 426 | + fatal_lang_error('mc_reportedp_comment_none_found'); |
|
| 427 | + } |
|
| 421 | 428 | |
| 422 | 429 | $comment_id = (int) $_REQUEST['mid']; |
| 423 | 430 | |
@@ -425,15 +432,17 @@ discard block |
||
| 425 | 432 | $comment = getCommentModDetails($comment_id); |
| 426 | 433 | |
| 427 | 434 | // Perhaps somebody else already deleted this fine gem... |
| 428 | - if (empty($comment)) |
|
| 429 | - fatal_lang_error('report_action_message_delete_issue'); |
|
| 435 | + if (empty($comment)) { |
|
| 436 | + fatal_lang_error('report_action_message_delete_issue'); |
|
| 437 | + } |
|
| 430 | 438 | |
| 431 | 439 | // Can you actually do this? |
| 432 | 440 | $comment_owner = $user_info['id'] == $comment['id_member']; |
| 433 | 441 | |
| 434 | 442 | // Nope! sorry. |
| 435 | - if (!allowedTo('admin_forum') && !$comment_owner) |
|
| 436 | - fatal_lang_error('report_action_message_delete_cannot'); |
|
| 443 | + if (!allowedTo('admin_forum') && !$comment_owner) { |
|
| 444 | + fatal_lang_error('report_action_message_delete_cannot'); |
|
| 445 | + } |
|
| 437 | 446 | |
| 438 | 447 | // All good! |
| 439 | 448 | deleteModComment($comment_id); |
@@ -458,11 +467,13 @@ discard block |
||
| 458 | 467 | checkSession(isset($_REQUEST['save']) ? 'post' : 'get'); |
| 459 | 468 | |
| 460 | 469 | // The report ID is a must. |
| 461 | - if (empty($_REQUEST['rid'])) |
|
| 462 | - fatal_lang_error('mc_reportedp_none_found'); |
|
| 470 | + if (empty($_REQUEST['rid'])) { |
|
| 471 | + fatal_lang_error('mc_reportedp_none_found'); |
|
| 472 | + } |
|
| 463 | 473 | |
| 464 | - if (empty($_REQUEST['mid'])) |
|
| 465 | - fatal_lang_error('mc_reportedp_comment_none_found'); |
|
| 474 | + if (empty($_REQUEST['mid'])) { |
|
| 475 | + fatal_lang_error('mc_reportedp_comment_none_found'); |
|
| 476 | + } |
|
| 466 | 477 | |
| 467 | 478 | // Integers only please. |
| 468 | 479 | $context['report_id'] = (int) $_REQUEST['rid']; |
@@ -470,8 +481,9 @@ discard block |
||
| 470 | 481 | |
| 471 | 482 | $context['comment'] = getCommentModDetails($context['comment_id']); |
| 472 | 483 | |
| 473 | - if (empty($context['comment'])) |
|
| 474 | - fatal_lang_error('mc_reportedp_comment_none_found'); |
|
| 484 | + if (empty($context['comment'])) { |
|
| 485 | + fatal_lang_error('mc_reportedp_comment_none_found'); |
|
| 486 | + } |
|
| 475 | 487 | |
| 476 | 488 | // Set up the comforting bits... |
| 477 | 489 | $context['page_title'] = $txt['mc_reported_posts']; |
@@ -482,15 +494,17 @@ discard block |
||
| 482 | 494 | validateToken('mod-reportC-edit'); |
| 483 | 495 | |
| 484 | 496 | // Make sure there is some data to edit on the DB. |
| 485 | - if (empty($context['comment'])) |
|
| 486 | - fatal_lang_error('report_action_message_edit_issue'); |
|
| 497 | + if (empty($context['comment'])) { |
|
| 498 | + fatal_lang_error('report_action_message_edit_issue'); |
|
| 499 | + } |
|
| 487 | 500 | |
| 488 | 501 | // Still there, good, now lets see if you can actually edit it... |
| 489 | 502 | $comment_owner = $user_info['id'] == $context['comment']['id_member']; |
| 490 | 503 | |
| 491 | 504 | // So, you aren't neither an admin or the comment owner huh? that's too bad. |
| 492 | - if (!allowedTo('admin_forum') && !$comment_owner) |
|
| 493 | - fatal_lang_error('report_action_message_edit_cannot'); |
|
| 505 | + if (!allowedTo('admin_forum') && !$comment_owner) { |
|
| 506 | + fatal_lang_error('report_action_message_edit_cannot'); |
|
| 507 | + } |
|
| 494 | 508 | |
| 495 | 509 | // All good! |
| 496 | 510 | $edited_comment = trim($smcFunc['htmlspecialchars']($_POST['mod_comment'])); |
@@ -516,8 +530,9 @@ discard block |
||
| 516 | 530 | checkSession('get'); |
| 517 | 531 | |
| 518 | 532 | // We need to do something! |
| 519 | - if (empty($_GET['rid']) && (!isset($_GET['ignore']) || !isset($_GET['closed']))) |
|
| 520 | - fatal_lang_error('mc_reportedp_none_found'); |
|
| 533 | + if (empty($_GET['rid']) && (!isset($_GET['ignore']) || !isset($_GET['closed']))) { |
|
| 534 | + fatal_lang_error('mc_reportedp_none_found'); |
|
| 535 | + } |
|
| 521 | 536 | |
| 522 | 537 | // What are we gonna do? |
| 523 | 538 | $action = isset($_GET['ignore']) ? 'ignore' : 'closed'; |