@@ -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 | * Generates the query to determine the list of available boards for a user |
@@ -25,8 +26,9 @@ discard block |
||
| 25 | 26 | { |
| 26 | 27 | global $smcFunc, $sourcedir; |
| 27 | 28 | |
| 28 | - if (isset($boardListOptions['excluded_boards']) && isset($boardListOptions['included_boards'])) |
|
| 29 | - trigger_error('getBoardList(): Setting both excluded_boards and included_boards is not allowed.', E_USER_ERROR); |
|
| 29 | + if (isset($boardListOptions['excluded_boards']) && isset($boardListOptions['included_boards'])) { |
|
| 30 | + trigger_error('getBoardList(): Setting both excluded_boards and included_boards is not allowed.', E_USER_ERROR); |
|
| 31 | + } |
|
| 30 | 32 | |
| 31 | 33 | $where = array(); |
| 32 | 34 | $where_parameters = array(); |
@@ -42,11 +44,11 @@ discard block |
||
| 42 | 44 | $where_parameters['included_boards'] = $boardListOptions['included_boards']; |
| 43 | 45 | } |
| 44 | 46 | |
| 45 | - if (!empty($boardListOptions['ignore_boards'])) |
|
| 46 | - $where[] = '{query_wanna_see_board}'; |
|
| 47 | - |
|
| 48 | - elseif (!empty($boardListOptions['use_permissions'])) |
|
| 49 | - $where[] = '{query_see_board}'; |
|
| 47 | + if (!empty($boardListOptions['ignore_boards'])) { |
|
| 48 | + $where[] = '{query_wanna_see_board}'; |
|
| 49 | + } elseif (!empty($boardListOptions['use_permissions'])) { |
|
| 50 | + $where[] = '{query_see_board}'; |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | if (!empty($boardListOptions['not_redirection'])) |
| 52 | 54 | { |
@@ -68,12 +70,13 @@ discard block |
||
| 68 | 70 | { |
| 69 | 71 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 70 | 72 | { |
| 71 | - if (!isset($return_value[$row['id_cat']])) |
|
| 72 | - $return_value[$row['id_cat']] = array( |
|
| 73 | + if (!isset($return_value[$row['id_cat']])) { |
|
| 74 | + $return_value[$row['id_cat']] = array( |
|
| 73 | 75 | 'id' => $row['id_cat'], |
| 74 | 76 | 'name' => $row['cat_name'], |
| 75 | 77 | 'boards' => array(), |
| 76 | 78 | ); |
| 79 | + } |
|
| 77 | 80 | |
| 78 | 81 | $return_value[$row['id_cat']]['boards'][$row['id_board']] = array( |
| 79 | 82 | 'id' => $row['id_board'], |
@@ -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 | * Add the file functions to the $smcFunc array. |
@@ -23,28 +24,32 @@ discard block |
||
| 23 | 24 | { |
| 24 | 25 | global $smcFunc; |
| 25 | 26 | |
| 26 | - if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') |
|
| 27 | - $smcFunc += array( |
|
| 27 | + if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') { |
|
| 28 | + $smcFunc += array( |
|
| 28 | 29 | 'db_search_query' => 'smf_db_search_query', |
| 29 | 30 | 'db_search_support' => 'smf_db_search_support', |
| 30 | 31 | 'db_create_word_search' => 'smf_db_create_word_search', |
| 31 | 32 | 'db_support_ignore' => false, |
| 32 | 33 | ); |
| 34 | + } |
|
| 33 | 35 | |
| 34 | 36 | db_extend(); |
| 35 | 37 | |
| 36 | 38 | //pg 9.5 got ignore support |
| 37 | 39 | $version = $smcFunc['db_get_version'](); |
| 38 | 40 | // if we got a Beta Version |
| 39 | - if (stripos($version, 'beta') !== false) |
|
| 40 | - $version = substr($version, 0, stripos($version, 'beta')).'.0'; |
|
| 41 | + if (stripos($version, 'beta') !== false) { |
|
| 42 | + $version = substr($version, 0, stripos($version, 'beta')).'.0'; |
|
| 43 | + } |
|
| 41 | 44 | // or RC |
| 42 | - if (stripos($version, 'rc') !== false) |
|
| 43 | - $version = substr($version, 0, stripos($version, 'rc')).'.0'; |
|
| 45 | + if (stripos($version, 'rc') !== false) { |
|
| 46 | + $version = substr($version, 0, stripos($version, 'rc')).'.0'; |
|
| 47 | + } |
|
| 44 | 48 | |
| 45 | - if (version_compare($version,'9.5.0','>=')) |
|
| 46 | - $smcFunc['db_support_ignore'] = true; |
|
| 47 | -} |
|
| 49 | + if (version_compare($version,'9.5.0','>=')) { |
|
| 50 | + $smcFunc['db_support_ignore'] = true; |
|
| 51 | + } |
|
| 52 | + } |
|
| 48 | 53 | |
| 49 | 54 | /** |
| 50 | 55 | * This function will tell you whether this database type supports this search type. |
@@ -103,16 +108,16 @@ discard block |
||
| 103 | 108 | ), |
| 104 | 109 | ); |
| 105 | 110 | |
| 106 | - if (isset($replacements[$identifier])) |
|
| 107 | - $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
| 111 | + if (isset($replacements[$identifier])) { |
|
| 112 | + $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
| 113 | + } |
|
| 108 | 114 | if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0) |
| 109 | 115 | { |
| 110 | 116 | $db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string); |
| 111 | 117 | if ($smcFunc['db_support_ignore']){ |
| 112 | 118 | //pg style "INSERT INTO.... ON CONFLICT DO NOTHING" |
| 113 | 119 | $db_string = $db_string.' ON CONFLICT DO NOTHING'; |
| 114 | - } |
|
| 115 | - else |
|
| 120 | + } else |
|
| 116 | 121 | { |
| 117 | 122 | // Don't error on multi-insert. |
| 118 | 123 | $db_values['db_error_skip'] = true; |
@@ -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 | * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or. |
@@ -202,16 +203,18 @@ discard block |
||
| 202 | 203 | { |
| 203 | 204 | $all_zones = timezone_identifiers_list(); |
| 204 | 205 | // Make sure we set the value to the same as the printed value. |
| 205 | - foreach ($all_zones as $zone) |
|
| 206 | - $config_vars['default_timezone'][2][$zone] = $zone; |
|
| 206 | + foreach ($all_zones as $zone) { |
|
| 207 | + $config_vars['default_timezone'][2][$zone] = $zone; |
|
| 208 | + } |
|
| 209 | + } else { |
|
| 210 | + unset($config_vars['default_timezone']); |
|
| 207 | 211 | } |
| 208 | - else |
|
| 209 | - unset($config_vars['default_timezone']); |
|
| 210 | 212 | |
| 211 | 213 | call_integration_hook('integrate_modify_basic_settings', array(&$config_vars)); |
| 212 | 214 | |
| 213 | - if ($return_config) |
|
| 214 | - return $config_vars; |
|
| 215 | + if ($return_config) { |
|
| 216 | + return $config_vars; |
|
| 217 | + } |
|
| 215 | 218 | |
| 216 | 219 | // Saving? |
| 217 | 220 | if (isset($_GET['save'])) |
@@ -219,8 +222,9 @@ discard block |
||
| 219 | 222 | checkSession(); |
| 220 | 223 | |
| 221 | 224 | // Prevent absurd boundaries here - make it a day tops. |
| 222 | - if (isset($_POST['lastActive'])) |
|
| 223 | - $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
| 225 | + if (isset($_POST['lastActive'])) { |
|
| 226 | + $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
| 227 | + } |
|
| 224 | 228 | |
| 225 | 229 | call_integration_hook('integrate_save_basic_settings'); |
| 226 | 230 | |
@@ -265,8 +269,9 @@ discard block |
||
| 265 | 269 | |
| 266 | 270 | call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars)); |
| 267 | 271 | |
| 268 | - if ($return_config) |
|
| 269 | - return $config_vars; |
|
| 272 | + if ($return_config) { |
|
| 273 | + return $config_vars; |
|
| 274 | + } |
|
| 270 | 275 | |
| 271 | 276 | // Setup the template. |
| 272 | 277 | require_once($sourcedir . '/ManageServer.php'); |
@@ -283,13 +288,15 @@ discard block |
||
| 283 | 288 | |
| 284 | 289 | // Clean up the tags. |
| 285 | 290 | $bbcTags = array(); |
| 286 | - foreach (parse_bbc(false) as $tag) |
|
| 287 | - $bbcTags[] = $tag['tag']; |
|
| 291 | + foreach (parse_bbc(false) as $tag) { |
|
| 292 | + $bbcTags[] = $tag['tag']; |
|
| 293 | + } |
|
| 288 | 294 | |
| 289 | - if (!isset($_POST['disabledBBC_enabledTags'])) |
|
| 290 | - $_POST['disabledBBC_enabledTags'] = array(); |
|
| 291 | - elseif (!is_array($_POST['disabledBBC_enabledTags'])) |
|
| 292 | - $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
| 295 | + if (!isset($_POST['disabledBBC_enabledTags'])) { |
|
| 296 | + $_POST['disabledBBC_enabledTags'] = array(); |
|
| 297 | + } elseif (!is_array($_POST['disabledBBC_enabledTags'])) { |
|
| 298 | + $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
| 299 | + } |
|
| 293 | 300 | // Work out what is actually disabled! |
| 294 | 301 | $_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags'])); |
| 295 | 302 | |
@@ -333,8 +340,9 @@ discard block |
||
| 333 | 340 | |
| 334 | 341 | call_integration_hook('integrate_layout_settings', array(&$config_vars)); |
| 335 | 342 | |
| 336 | - if ($return_config) |
|
| 337 | - return $config_vars; |
|
| 343 | + if ($return_config) { |
|
| 344 | + return $config_vars; |
|
| 345 | + } |
|
| 338 | 346 | |
| 339 | 347 | // Saving? |
| 340 | 348 | if (isset($_GET['save'])) |
@@ -375,8 +383,9 @@ discard block |
||
| 375 | 383 | |
| 376 | 384 | call_integration_hook('integrate_likes_settings', array(&$config_vars)); |
| 377 | 385 | |
| 378 | - if ($return_config) |
|
| 379 | - return $config_vars; |
|
| 386 | + if ($return_config) { |
|
| 387 | + return $config_vars; |
|
| 388 | + } |
|
| 380 | 389 | |
| 381 | 390 | // Saving? |
| 382 | 391 | if (isset($_GET['save'])) |
@@ -414,8 +423,9 @@ discard block |
||
| 414 | 423 | |
| 415 | 424 | call_integration_hook('integrate_mentions_settings', array(&$config_vars)); |
| 416 | 425 | |
| 417 | - if ($return_config) |
|
| 418 | - return $config_vars; |
|
| 426 | + if ($return_config) { |
|
| 427 | + return $config_vars; |
|
| 428 | + } |
|
| 419 | 429 | |
| 420 | 430 | // Saving? |
| 421 | 431 | if (isset($_GET['save'])) |
@@ -459,8 +469,8 @@ discard block |
||
| 459 | 469 | 'enable' => array('check', 'warning_enable'), |
| 460 | 470 | ); |
| 461 | 471 | |
| 462 | - if (!empty($modSettings['warning_settings']) && $currently_enabled) |
|
| 463 | - $config_vars += array( |
|
| 472 | + if (!empty($modSettings['warning_settings']) && $currently_enabled) { |
|
| 473 | + $config_vars += array( |
|
| 464 | 474 | '', |
| 465 | 475 | array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']), |
| 466 | 476 | 'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']), |
@@ -469,15 +479,18 @@ discard block |
||
| 469 | 479 | 'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']), |
| 470 | 480 | array('permissions', 'view_warning'), |
| 471 | 481 | ); |
| 482 | + } |
|
| 472 | 483 | |
| 473 | 484 | call_integration_hook('integrate_warning_settings', array(&$config_vars)); |
| 474 | 485 | |
| 475 | - if ($return_config) |
|
| 476 | - return $config_vars; |
|
| 486 | + if ($return_config) { |
|
| 487 | + return $config_vars; |
|
| 488 | + } |
|
| 477 | 489 | |
| 478 | 490 | // Cannot use moderation if post moderation is not enabled. |
| 479 | - if (!$modSettings['postmod_active']) |
|
| 480 | - unset($config_vars['moderate']); |
|
| 491 | + if (!$modSettings['postmod_active']) { |
|
| 492 | + unset($config_vars['moderate']); |
|
| 493 | + } |
|
| 481 | 494 | |
| 482 | 495 | // Will need the utility functions from here. |
| 483 | 496 | require_once($sourcedir . '/ManageServer.php'); |
@@ -502,16 +515,16 @@ discard block |
||
| 502 | 515 | 'warning_watch' => 10, |
| 503 | 516 | 'warning_mute' => 60, |
| 504 | 517 | ); |
| 505 | - if ($modSettings['postmod_active']) |
|
| 506 | - $vars['warning_moderate'] = 35; |
|
| 518 | + if ($modSettings['postmod_active']) { |
|
| 519 | + $vars['warning_moderate'] = 35; |
|
| 520 | + } |
|
| 507 | 521 | |
| 508 | 522 | foreach ($vars as $var => $value) |
| 509 | 523 | { |
| 510 | 524 | $config_vars[] = array('int', $var); |
| 511 | 525 | $_POST[$var] = $value; |
| 512 | 526 | } |
| 513 | - } |
|
| 514 | - else |
|
| 527 | + } else |
|
| 515 | 528 | { |
| 516 | 529 | $_POST['warning_watch'] = min($_POST['warning_watch'], 100); |
| 517 | 530 | $_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0; |
@@ -592,8 +605,9 @@ discard block |
||
| 592 | 605 | |
| 593 | 606 | call_integration_hook('integrate_spam_settings', array(&$config_vars)); |
| 594 | 607 | |
| 595 | - if ($return_config) |
|
| 596 | - return $config_vars; |
|
| 608 | + if ($return_config) { |
|
| 609 | + return $config_vars; |
|
| 610 | + } |
|
| 597 | 611 | |
| 598 | 612 | // You need to be an admin to edit settings! |
| 599 | 613 | isAllowedTo('admin_forum'); |
@@ -627,8 +641,9 @@ discard block |
||
| 627 | 641 | |
| 628 | 642 | if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers'])) |
| 629 | 643 | { |
| 630 | - if (empty($context['settings_insert_above'])) |
|
| 631 | - $context['settings_insert_above'] = ''; |
|
| 644 | + if (empty($context['settings_insert_above'])) { |
|
| 645 | + $context['settings_insert_above'] = ''; |
|
| 646 | + } |
|
| 632 | 647 | |
| 633 | 648 | $context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>'; |
| 634 | 649 | } |
@@ -671,8 +686,9 @@ discard block |
||
| 671 | 686 | $_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour']; |
| 672 | 687 | |
| 673 | 688 | // Hack in guest requiring verification! |
| 674 | - if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) |
|
| 675 | - $_POST['posts_require_captcha'] = -1; |
|
| 689 | + if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) { |
|
| 690 | + $_POST['posts_require_captcha'] = -1; |
|
| 691 | + } |
|
| 676 | 692 | |
| 677 | 693 | $save_vars = $config_vars; |
| 678 | 694 | unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']); |
@@ -689,14 +705,16 @@ discard block |
||
| 689 | 705 | foreach ($context['qa_languages'] as $lang_id => $dummy) |
| 690 | 706 | { |
| 691 | 707 | // If we had some questions for this language before, but don't now, delete everything from that language. |
| 692 | - if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) |
|
| 693 | - $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
| 708 | + if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) { |
|
| 709 | + $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
| 710 | + } |
|
| 694 | 711 | |
| 695 | 712 | // Now step through and see if any existing questions no longer exist. |
| 696 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
| 697 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
| 713 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
| 714 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
| 698 | 715 | if (empty($_POST['question'][$lang_id][$q_id])) |
| 699 | 716 | $changes['delete'][] = $q_id; |
| 717 | + } |
|
| 700 | 718 | |
| 701 | 719 | // Now let's see if there are new questions or ones that need updating. |
| 702 | 720 | if (isset($_POST['question'][$lang_id])) |
@@ -705,14 +723,16 @@ discard block |
||
| 705 | 723 | { |
| 706 | 724 | // Ignore junky ids. |
| 707 | 725 | $q_id = (int) $q_id; |
| 708 | - if ($q_id <= 0) |
|
| 709 | - continue; |
|
| 726 | + if ($q_id <= 0) { |
|
| 727 | + continue; |
|
| 728 | + } |
|
| 710 | 729 | |
| 711 | 730 | // Check the question isn't empty (because they want to delete it?) |
| 712 | 731 | if (empty($question) || trim($question) == '') |
| 713 | 732 | { |
| 714 | - if (isset($context['question_answers'][$q_id])) |
|
| 715 | - $changes['delete'][] = $q_id; |
|
| 733 | + if (isset($context['question_answers'][$q_id])) { |
|
| 734 | + $changes['delete'][] = $q_id; |
|
| 735 | + } |
|
| 716 | 736 | continue; |
| 717 | 737 | } |
| 718 | 738 | $question = $smcFunc['htmlspecialchars'](trim($question)); |
@@ -720,19 +740,22 @@ discard block |
||
| 720 | 740 | // Get the answers. Firstly check there actually might be some. |
| 721 | 741 | if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id])) |
| 722 | 742 | { |
| 723 | - if (isset($context['question_answers'][$q_id])) |
|
| 724 | - $changes['delete'][] = $q_id; |
|
| 743 | + if (isset($context['question_answers'][$q_id])) { |
|
| 744 | + $changes['delete'][] = $q_id; |
|
| 745 | + } |
|
| 725 | 746 | continue; |
| 726 | 747 | } |
| 727 | 748 | // Now get them and check that they might be viable. |
| 728 | 749 | $answers = array(); |
| 729 | - foreach ($_POST['answer'][$lang_id][$q_id] as $answer) |
|
| 730 | - if (!empty($answer) && trim($answer) !== '') |
|
| 750 | + foreach ($_POST['answer'][$lang_id][$q_id] as $answer) { |
|
| 751 | + if (!empty($answer) && trim($answer) !== '') |
|
| 731 | 752 | $answers[] = $smcFunc['htmlspecialchars'](trim($answer)); |
| 753 | + } |
|
| 732 | 754 | if (empty($answers)) |
| 733 | 755 | { |
| 734 | - if (isset($context['question_answers'][$q_id])) |
|
| 735 | - $changes['delete'][] = $q_id; |
|
| 756 | + if (isset($context['question_answers'][$q_id])) { |
|
| 757 | + $changes['delete'][] = $q_id; |
|
| 758 | + } |
|
| 736 | 759 | continue; |
| 737 | 760 | } |
| 738 | 761 | $answers = json_encode($answers); |
@@ -742,16 +765,17 @@ discard block |
||
| 742 | 765 | { |
| 743 | 766 | // New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids. |
| 744 | 767 | $changes['insert'][] = array($lang_id, $question, $answers); |
| 745 | - } |
|
| 746 | - else |
|
| 768 | + } else |
|
| 747 | 769 | { |
| 748 | 770 | // It's an existing question. Let's see what's changed, if anything. |
| 749 | - if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) |
|
| 750 | - $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
| 771 | + if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) { |
|
| 772 | + $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
| 773 | + } |
|
| 751 | 774 | } |
| 752 | 775 | |
| 753 | - if (!isset($qs_per_lang[$lang_id])) |
|
| 754 | - $qs_per_lang[$lang_id] = 0; |
|
| 776 | + if (!isset($qs_per_lang[$lang_id])) { |
|
| 777 | + $qs_per_lang[$lang_id] = 0; |
|
| 778 | + } |
|
| 755 | 779 | $qs_per_lang[$lang_id]++; |
| 756 | 780 | } |
| 757 | 781 | } |
@@ -801,8 +825,9 @@ discard block |
||
| 801 | 825 | |
| 802 | 826 | // Lastly, the count of messages needs to be no more than the lowest number of questions for any one language. |
| 803 | 827 | $count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang); |
| 804 | - if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) |
|
| 805 | - $_POST['qa_verification_number'] = $count_questions; |
|
| 828 | + if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) { |
|
| 829 | + $_POST['qa_verification_number'] = $count_questions; |
|
| 830 | + } |
|
| 806 | 831 | |
| 807 | 832 | call_integration_hook('integrate_save_spam_settings', array(&$save_vars)); |
| 808 | 833 | |
@@ -817,24 +842,27 @@ discard block |
||
| 817 | 842 | |
| 818 | 843 | $character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y')); |
| 819 | 844 | $_SESSION['visual_verification_code'] = ''; |
| 820 | - for ($i = 0; $i < 6; $i++) |
|
| 821 | - $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
| 845 | + for ($i = 0; $i < 6; $i++) { |
|
| 846 | + $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
| 847 | + } |
|
| 822 | 848 | |
| 823 | 849 | // Some javascript for CAPTCHA. |
| 824 | 850 | $context['settings_post_javascript'] = ''; |
| 825 | - if ($context['use_graphic_library']) |
|
| 826 | - $context['settings_post_javascript'] .= ' |
|
| 851 | + if ($context['use_graphic_library']) { |
|
| 852 | + $context['settings_post_javascript'] .= ' |
|
| 827 | 853 | function refreshImages() |
| 828 | 854 | { |
| 829 | 855 | var imageType = document.getElementById(\'visual_verification_type\').value; |
| 830 | 856 | document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType; |
| 831 | 857 | }'; |
| 858 | + } |
|
| 832 | 859 | |
| 833 | 860 | // Show the image itself, or text saying we can't. |
| 834 | - if ($context['use_graphic_library']) |
|
| 835 | - $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
| 836 | - else |
|
| 837 | - $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
| 861 | + if ($context['use_graphic_library']) { |
|
| 862 | + $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
| 863 | + } else { |
|
| 864 | + $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
| 865 | + } |
|
| 838 | 866 | |
| 839 | 867 | // Hack for PM spam settings. |
| 840 | 868 | list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']); |
@@ -844,9 +872,10 @@ discard block |
||
| 844 | 872 | $modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha']; |
| 845 | 873 | |
| 846 | 874 | // Some minor javascript for the guest post setting. |
| 847 | - if ($modSettings['posts_require_captcha']) |
|
| 848 | - $context['settings_post_javascript'] .= ' |
|
| 875 | + if ($modSettings['posts_require_captcha']) { |
|
| 876 | + $context['settings_post_javascript'] .= ' |
|
| 849 | 877 | document.getElementById(\'guests_require_captcha\').disabled = true;'; |
| 878 | + } |
|
| 850 | 879 | |
| 851 | 880 | // And everything else. |
| 852 | 881 | $context['post_url'] = $scripturl . '?action=admin;area=antispam;save'; |
@@ -893,8 +922,9 @@ discard block |
||
| 893 | 922 | |
| 894 | 923 | call_integration_hook('integrate_signature_settings', array(&$config_vars)); |
| 895 | 924 | |
| 896 | - if ($return_config) |
|
| 897 | - return $config_vars; |
|
| 925 | + if ($return_config) { |
|
| 926 | + return $config_vars; |
|
| 927 | + } |
|
| 898 | 928 | |
| 899 | 929 | // Setup the template. |
| 900 | 930 | $context['page_title'] = $txt['signature_settings']; |
@@ -949,8 +979,9 @@ discard block |
||
| 949 | 979 | $sig = strtr($row['signature'], array('<br>' => "\n")); |
| 950 | 980 | |
| 951 | 981 | // Max characters... |
| 952 | - if (!empty($sig_limits[1])) |
|
| 953 | - $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
| 982 | + if (!empty($sig_limits[1])) { |
|
| 983 | + $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
| 984 | + } |
|
| 954 | 985 | // Max lines... |
| 955 | 986 | if (!empty($sig_limits[2])) |
| 956 | 987 | { |
@@ -960,8 +991,9 @@ discard block |
||
| 960 | 991 | if ($sig[$i] == "\n") |
| 961 | 992 | { |
| 962 | 993 | $count++; |
| 963 | - if ($count >= $sig_limits[2]) |
|
| 964 | - $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
| 994 | + if ($count >= $sig_limits[2]) { |
|
| 995 | + $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
| 996 | + } |
|
| 965 | 997 | } |
| 966 | 998 | } |
| 967 | 999 | } |
@@ -972,17 +1004,19 @@ discard block |
||
| 972 | 1004 | { |
| 973 | 1005 | $limit_broke = 0; |
| 974 | 1006 | // Attempt to allow all sizes of abuse, so to speak. |
| 975 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
| 976 | - $limit_broke = $sig_limits[7] . 'px'; |
|
| 977 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
| 978 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 979 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
| 980 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 981 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
| 982 | - $limit_broke = 'large'; |
|
| 983 | - |
|
| 984 | - if ($limit_broke) |
|
| 985 | - $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
| 1007 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
| 1008 | + $limit_broke = $sig_limits[7] . 'px'; |
|
| 1009 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
| 1010 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 1011 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
| 1012 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 1013 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
| 1014 | + $limit_broke = 'large'; |
|
| 1015 | + } |
|
| 1016 | + |
|
| 1017 | + if ($limit_broke) { |
|
| 1018 | + $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
| 1019 | + } |
|
| 986 | 1020 | } |
| 987 | 1021 | } |
| 988 | 1022 | |
@@ -1038,32 +1072,34 @@ discard block |
||
| 1038 | 1072 | $img_offset = false; |
| 1039 | 1073 | } |
| 1040 | 1074 | } |
| 1075 | + } else { |
|
| 1076 | + $replaces[$image] = ''; |
|
| 1041 | 1077 | } |
| 1042 | - else |
|
| 1043 | - $replaces[$image] = ''; |
|
| 1044 | 1078 | |
| 1045 | 1079 | continue; |
| 1046 | 1080 | } |
| 1047 | 1081 | |
| 1048 | 1082 | // Does it have predefined restraints? Width first. |
| 1049 | - if ($matches[6][$key]) |
|
| 1050 | - $matches[2][$key] = $matches[6][$key]; |
|
| 1083 | + if ($matches[6][$key]) { |
|
| 1084 | + $matches[2][$key] = $matches[6][$key]; |
|
| 1085 | + } |
|
| 1051 | 1086 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
| 1052 | 1087 | { |
| 1053 | 1088 | $width = $sig_limits[5]; |
| 1054 | 1089 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
| 1090 | + } elseif ($matches[2][$key]) { |
|
| 1091 | + $width = $matches[2][$key]; |
|
| 1055 | 1092 | } |
| 1056 | - elseif ($matches[2][$key]) |
|
| 1057 | - $width = $matches[2][$key]; |
|
| 1058 | 1093 | // ... and height. |
| 1059 | 1094 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
| 1060 | 1095 | { |
| 1061 | 1096 | $height = $sig_limits[6]; |
| 1062 | - if ($width != -1) |
|
| 1063 | - $width = $width * ($height / $matches[4][$key]); |
|
| 1097 | + if ($width != -1) { |
|
| 1098 | + $width = $width * ($height / $matches[4][$key]); |
|
| 1099 | + } |
|
| 1100 | + } elseif ($matches[4][$key]) { |
|
| 1101 | + $height = $matches[4][$key]; |
|
| 1064 | 1102 | } |
| 1065 | - elseif ($matches[4][$key]) |
|
| 1066 | - $height = $matches[4][$key]; |
|
| 1067 | 1103 | |
| 1068 | 1104 | // If the dimensions are still not fixed - we need to check the actual image. |
| 1069 | 1105 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -1081,12 +1117,13 @@ discard block |
||
| 1081 | 1117 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
| 1082 | 1118 | { |
| 1083 | 1119 | $height = $sig_limits[6]; |
| 1084 | - if ($width == -1) |
|
| 1085 | - $width = $sizes[0]; |
|
| 1120 | + if ($width == -1) { |
|
| 1121 | + $width = $sizes[0]; |
|
| 1122 | + } |
|
| 1086 | 1123 | $width = $width * ($height / $sizes[1]); |
| 1124 | + } elseif ($width != -1) { |
|
| 1125 | + $height = $sizes[1]; |
|
| 1087 | 1126 | } |
| 1088 | - elseif ($width != -1) |
|
| 1089 | - $height = $sizes[1]; |
|
| 1090 | 1127 | } |
| 1091 | 1128 | } |
| 1092 | 1129 | |
@@ -1099,8 +1136,9 @@ discard block |
||
| 1099 | 1136 | // Record that we got one. |
| 1100 | 1137 | $image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1; |
| 1101 | 1138 | } |
| 1102 | - if (!empty($replaces)) |
|
| 1103 | - $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
| 1139 | + if (!empty($replaces)) { |
|
| 1140 | + $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
| 1141 | + } |
|
| 1104 | 1142 | } |
| 1105 | 1143 | } |
| 1106 | 1144 | // Try to fix disabled tags. |
@@ -1112,18 +1150,20 @@ discard block |
||
| 1112 | 1150 | |
| 1113 | 1151 | $sig = strtr($sig, array("\n" => '<br>')); |
| 1114 | 1152 | call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags)); |
| 1115 | - if ($sig != $row['signature']) |
|
| 1116 | - $changes[$row['id_member']] = $sig; |
|
| 1153 | + if ($sig != $row['signature']) { |
|
| 1154 | + $changes[$row['id_member']] = $sig; |
|
| 1155 | + } |
|
| 1156 | + } |
|
| 1157 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1158 | + $done = true; |
|
| 1117 | 1159 | } |
| 1118 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1119 | - $done = true; |
|
| 1120 | 1160 | $smcFunc['db_free_result']($request); |
| 1121 | 1161 | |
| 1122 | 1162 | // Do we need to delete what we have? |
| 1123 | 1163 | if (!empty($changes)) |
| 1124 | 1164 | { |
| 1125 | - foreach ($changes as $id => $sig) |
|
| 1126 | - $smcFunc['db_query']('', ' |
|
| 1165 | + foreach ($changes as $id => $sig) { |
|
| 1166 | + $smcFunc['db_query']('', ' |
|
| 1127 | 1167 | UPDATE {db_prefix}members |
| 1128 | 1168 | SET signature = {string:signature} |
| 1129 | 1169 | WHERE id_member = {int:id_member}', |
@@ -1132,11 +1172,13 @@ discard block |
||
| 1132 | 1172 | 'signature' => $sig, |
| 1133 | 1173 | ) |
| 1134 | 1174 | ); |
| 1175 | + } |
|
| 1135 | 1176 | } |
| 1136 | 1177 | |
| 1137 | 1178 | $_GET['step'] += 50; |
| 1138 | - if (!$done) |
|
| 1139 | - pauseSignatureApplySettings(); |
|
| 1179 | + if (!$done) { |
|
| 1180 | + pauseSignatureApplySettings(); |
|
| 1181 | + } |
|
| 1140 | 1182 | } |
| 1141 | 1183 | $settings_applied = true; |
| 1142 | 1184 | } |
@@ -1154,8 +1196,9 @@ discard block |
||
| 1154 | 1196 | ); |
| 1155 | 1197 | |
| 1156 | 1198 | // Temporarily make each setting a modSetting! |
| 1157 | - foreach ($context['signature_settings'] as $key => $value) |
|
| 1158 | - $modSettings['signature_' . $key] = $value; |
|
| 1199 | + foreach ($context['signature_settings'] as $key => $value) { |
|
| 1200 | + $modSettings['signature_' . $key] = $value; |
|
| 1201 | + } |
|
| 1159 | 1202 | |
| 1160 | 1203 | // Make sure we check the right tags! |
| 1161 | 1204 | $modSettings['bbc_disabled_signature_bbc'] = $disabledTags; |
@@ -1167,23 +1210,26 @@ discard block |
||
| 1167 | 1210 | |
| 1168 | 1211 | // Clean up the tag stuff! |
| 1169 | 1212 | $bbcTags = array(); |
| 1170 | - foreach (parse_bbc(false) as $tag) |
|
| 1171 | - $bbcTags[] = $tag['tag']; |
|
| 1213 | + foreach (parse_bbc(false) as $tag) { |
|
| 1214 | + $bbcTags[] = $tag['tag']; |
|
| 1215 | + } |
|
| 1172 | 1216 | |
| 1173 | - if (!isset($_POST['signature_bbc_enabledTags'])) |
|
| 1174 | - $_POST['signature_bbc_enabledTags'] = array(); |
|
| 1175 | - elseif (!is_array($_POST['signature_bbc_enabledTags'])) |
|
| 1176 | - $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
| 1217 | + if (!isset($_POST['signature_bbc_enabledTags'])) { |
|
| 1218 | + $_POST['signature_bbc_enabledTags'] = array(); |
|
| 1219 | + } elseif (!is_array($_POST['signature_bbc_enabledTags'])) { |
|
| 1220 | + $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
| 1221 | + } |
|
| 1177 | 1222 | |
| 1178 | 1223 | $sig_limits = array(); |
| 1179 | 1224 | foreach ($context['signature_settings'] as $key => $value) |
| 1180 | 1225 | { |
| 1181 | - if ($key == 'allow_smileys') |
|
| 1182 | - continue; |
|
| 1183 | - elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) |
|
| 1184 | - $sig_limits[] = -1; |
|
| 1185 | - else |
|
| 1186 | - $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
| 1226 | + if ($key == 'allow_smileys') { |
|
| 1227 | + continue; |
|
| 1228 | + } elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) { |
|
| 1229 | + $sig_limits[] = -1; |
|
| 1230 | + } else { |
|
| 1231 | + $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
| 1232 | + } |
|
| 1187 | 1233 | } |
| 1188 | 1234 | |
| 1189 | 1235 | call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags)); |
@@ -1216,12 +1262,14 @@ discard block |
||
| 1216 | 1262 | |
| 1217 | 1263 | // Try get more time... |
| 1218 | 1264 | @set_time_limit(600); |
| 1219 | - if (function_exists('apache_reset_timeout')) |
|
| 1220 | - @apache_reset_timeout(); |
|
| 1265 | + if (function_exists('apache_reset_timeout')) { |
|
| 1266 | + @apache_reset_timeout(); |
|
| 1267 | + } |
|
| 1221 | 1268 | |
| 1222 | 1269 | // Have we exhausted all the time we allowed? |
| 1223 | - if (time() - array_sum(explode(' ', $sig_start)) < 3) |
|
| 1224 | - return; |
|
| 1270 | + if (time() - array_sum(explode(' ', $sig_start)) < 3) { |
|
| 1271 | + return; |
|
| 1272 | + } |
|
| 1225 | 1273 | |
| 1226 | 1274 | $context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 1227 | 1275 | $context['page_title'] = $txt['not_done_title']; |
@@ -1267,9 +1315,10 @@ discard block |
||
| 1267 | 1315 | $disable_fields = array_flip($standard_fields); |
| 1268 | 1316 | if (!empty($_POST['active'])) |
| 1269 | 1317 | { |
| 1270 | - foreach ($_POST['active'] as $value) |
|
| 1271 | - if (isset($disable_fields[$value])) |
|
| 1318 | + foreach ($_POST['active'] as $value) { |
|
| 1319 | + if (isset($disable_fields[$value])) |
|
| 1272 | 1320 | unset($disable_fields[$value]); |
| 1321 | + } |
|
| 1273 | 1322 | } |
| 1274 | 1323 | // What we have left! |
| 1275 | 1324 | $changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields)); |
@@ -1278,16 +1327,18 @@ discard block |
||
| 1278 | 1327 | $reg_fields = array(); |
| 1279 | 1328 | if (!empty($_POST['reg'])) |
| 1280 | 1329 | { |
| 1281 | - foreach ($_POST['reg'] as $value) |
|
| 1282 | - if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
| 1330 | + foreach ($_POST['reg'] as $value) { |
|
| 1331 | + if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
| 1283 | 1332 | $reg_fields[] = $value; |
| 1333 | + } |
|
| 1284 | 1334 | } |
| 1285 | 1335 | // What we have left! |
| 1286 | 1336 | $changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields); |
| 1287 | 1337 | |
| 1288 | 1338 | $_SESSION['adm-save'] = true; |
| 1289 | - if (!empty($changes)) |
|
| 1290 | - updateSettings($changes); |
|
| 1339 | + if (!empty($changes)) { |
|
| 1340 | + updateSettings($changes); |
|
| 1341 | + } |
|
| 1291 | 1342 | } |
| 1292 | 1343 | |
| 1293 | 1344 | createToken('admin-scp'); |
@@ -1390,11 +1441,13 @@ discard block |
||
| 1390 | 1441 | { |
| 1391 | 1442 | $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br />'; |
| 1392 | 1443 | |
| 1393 | - if ($rowData['field_order'] > 1) |
|
| 1394 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
| 1444 | + if ($rowData['field_order'] > 1) { |
|
| 1445 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
| 1446 | + } |
|
| 1395 | 1447 | |
| 1396 | - if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
|
| 1397 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
| 1448 | + if ($rowData['field_order'] < $context['custFieldsMaxOrder']) { |
|
| 1449 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
| 1450 | + } |
|
| 1398 | 1451 | |
| 1399 | 1452 | $return .= '</p>'; |
| 1400 | 1453 | |
@@ -1532,16 +1585,16 @@ discard block |
||
| 1532 | 1585 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array(); |
| 1533 | 1586 | $registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array(); |
| 1534 | 1587 | |
| 1535 | - foreach ($standard_fields as $field) |
|
| 1536 | - $list[] = array( |
|
| 1588 | + foreach ($standard_fields as $field) { |
|
| 1589 | + $list[] = array( |
|
| 1537 | 1590 | 'id' => $field, |
| 1538 | 1591 | 'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field), |
| 1539 | 1592 | 'disabled' => in_array($field, $disabled_fields), |
| 1540 | 1593 | 'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration), |
| 1541 | 1594 | 'can_show_register' => !in_array($field, $fields_no_registration), |
| 1542 | 1595 | ); |
| 1543 | - } |
|
| 1544 | - else |
|
| 1596 | + } |
|
| 1597 | + } else |
|
| 1545 | 1598 | { |
| 1546 | 1599 | // Load all the fields. |
| 1547 | 1600 | $request = $smcFunc['db_query']('', ' |
@@ -1555,8 +1608,9 @@ discard block |
||
| 1555 | 1608 | 'items_per_page' => $items_per_page, |
| 1556 | 1609 | ) |
| 1557 | 1610 | ); |
| 1558 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1559 | - $list[] = $row; |
|
| 1611 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1612 | + $list[] = $row; |
|
| 1613 | + } |
|
| 1560 | 1614 | $smcFunc['db_free_result']($request); |
| 1561 | 1615 | } |
| 1562 | 1616 | |
@@ -1622,9 +1676,9 @@ discard block |
||
| 1622 | 1676 | $context['field'] = array(); |
| 1623 | 1677 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1624 | 1678 | { |
| 1625 | - if ($row['field_type'] == 'textarea') |
|
| 1626 | - @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
| 1627 | - else |
|
| 1679 | + if ($row['field_type'] == 'textarea') { |
|
| 1680 | + @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
| 1681 | + } else |
|
| 1628 | 1682 | { |
| 1629 | 1683 | $rows = 3; |
| 1630 | 1684 | $cols = 30; |
@@ -1660,8 +1714,8 @@ discard block |
||
| 1660 | 1714 | } |
| 1661 | 1715 | |
| 1662 | 1716 | // Setup the default values as needed. |
| 1663 | - if (empty($context['field'])) |
|
| 1664 | - $context['field'] = array( |
|
| 1717 | + if (empty($context['field'])) { |
|
| 1718 | + $context['field'] = array( |
|
| 1665 | 1719 | 'name' => '', |
| 1666 | 1720 | 'col_name' => '???', |
| 1667 | 1721 | 'desc' => '', |
@@ -1686,6 +1740,7 @@ discard block |
||
| 1686 | 1740 | 'enclose' => '', |
| 1687 | 1741 | 'placement' => 0, |
| 1688 | 1742 | ); |
| 1743 | + } |
|
| 1689 | 1744 | |
| 1690 | 1745 | // Are we moving it? |
| 1691 | 1746 | if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to)) |
@@ -1694,8 +1749,10 @@ discard block |
||
| 1694 | 1749 | $new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1)); |
| 1695 | 1750 | |
| 1696 | 1751 | // Is this a valid position? |
| 1697 | - if ($new_order <= 0 || $new_order > $order_count) |
|
| 1698 | - redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
|
| 1752 | + if ($new_order <= 0 || $new_order > $order_count) { |
|
| 1753 | + redirectexit('action=admin;area=featuresettings;sa=profile'); |
|
| 1754 | + } |
|
| 1755 | + // @todo implement an error handler |
|
| 1699 | 1756 | |
| 1700 | 1757 | // All good, proceed. |
| 1701 | 1758 | $smcFunc['db_query']('',' |
@@ -1726,12 +1783,14 @@ discard block |
||
| 1726 | 1783 | validateToken('admin-ecp'); |
| 1727 | 1784 | |
| 1728 | 1785 | // Everyone needs a name - even the (bracket) unknown... |
| 1729 | - if (trim($_POST['field_name']) == '') |
|
| 1730 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
| 1786 | + if (trim($_POST['field_name']) == '') { |
|
| 1787 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
| 1788 | + } |
|
| 1731 | 1789 | |
| 1732 | 1790 | // Regex you say? Do a very basic test to see if the pattern is valid |
| 1733 | - if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) |
|
| 1734 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
| 1791 | + if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) { |
|
| 1792 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
| 1793 | + } |
|
| 1735 | 1794 | |
| 1736 | 1795 | $_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']); |
| 1737 | 1796 | $_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']); |
@@ -1748,8 +1807,9 @@ discard block |
||
| 1748 | 1807 | |
| 1749 | 1808 | // Some masking stuff... |
| 1750 | 1809 | $mask = isset($_POST['mask']) ? $_POST['mask'] : ''; |
| 1751 | - if ($mask == 'regex' && isset($_POST['regex'])) |
|
| 1752 | - $mask .= $_POST['regex']; |
|
| 1810 | + if ($mask == 'regex' && isset($_POST['regex'])) { |
|
| 1811 | + $mask .= $_POST['regex']; |
|
| 1812 | + } |
|
| 1753 | 1813 | |
| 1754 | 1814 | $field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255; |
| 1755 | 1815 | $enclose = isset($_POST['enclose']) ? $_POST['enclose'] : ''; |
@@ -1768,8 +1828,9 @@ discard block |
||
| 1768 | 1828 | $v = strtr($v, array(',' => '')); |
| 1769 | 1829 | |
| 1770 | 1830 | // Nada, zip, etc... |
| 1771 | - if (trim($v) == '') |
|
| 1772 | - continue; |
|
| 1831 | + if (trim($v) == '') { |
|
| 1832 | + continue; |
|
| 1833 | + } |
|
| 1773 | 1834 | |
| 1774 | 1835 | // Otherwise, save it boy. |
| 1775 | 1836 | $field_options .= $v . ','; |
@@ -1777,15 +1838,17 @@ discard block |
||
| 1777 | 1838 | $newOptions[$k] = $v; |
| 1778 | 1839 | |
| 1779 | 1840 | // Is it default? |
| 1780 | - if (isset($_POST['default_select']) && $_POST['default_select'] == $k) |
|
| 1781 | - $default = $v; |
|
| 1841 | + if (isset($_POST['default_select']) && $_POST['default_select'] == $k) { |
|
| 1842 | + $default = $v; |
|
| 1843 | + } |
|
| 1782 | 1844 | } |
| 1783 | 1845 | $field_options = substr($field_options, 0, -1); |
| 1784 | 1846 | } |
| 1785 | 1847 | |
| 1786 | 1848 | // Text area has default has dimensions |
| 1787 | - if ($_POST['field_type'] == 'textarea') |
|
| 1788 | - $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
| 1849 | + if ($_POST['field_type'] == 'textarea') { |
|
| 1850 | + $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
| 1851 | + } |
|
| 1789 | 1852 | |
| 1790 | 1853 | // Come up with the unique name? |
| 1791 | 1854 | if (empty($context['fid'])) |
@@ -1794,32 +1857,36 @@ discard block |
||
| 1794 | 1857 | preg_match('~([\w\d_-]+)~', $col_name, $matches); |
| 1795 | 1858 | |
| 1796 | 1859 | // If there is nothing to the name, then let's start out own - for foreign languages etc. |
| 1797 | - if (isset($matches[1])) |
|
| 1798 | - $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
| 1799 | - else |
|
| 1800 | - $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
| 1860 | + if (isset($matches[1])) { |
|
| 1861 | + $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
| 1862 | + } else { |
|
| 1863 | + $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
| 1864 | + } |
|
| 1801 | 1865 | |
| 1802 | 1866 | // Make sure this is unique. |
| 1803 | 1867 | $current_fields = array(); |
| 1804 | 1868 | $request = $smcFunc['db_query']('', ' |
| 1805 | 1869 | SELECT id_field, col_name |
| 1806 | 1870 | FROM {db_prefix}custom_fields'); |
| 1807 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1808 | - $current_fields[$row['id_field']] = $row['col_name']; |
|
| 1871 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1872 | + $current_fields[$row['id_field']] = $row['col_name']; |
|
| 1873 | + } |
|
| 1809 | 1874 | $smcFunc['db_free_result']($request); |
| 1810 | 1875 | |
| 1811 | 1876 | $unique = false; |
| 1812 | 1877 | for ($i = 0; !$unique && $i < 9; $i ++) |
| 1813 | 1878 | { |
| 1814 | - if (!in_array($col_name, $current_fields)) |
|
| 1815 | - $unique = true; |
|
| 1816 | - else |
|
| 1817 | - $col_name = $initial_col_name . $i; |
|
| 1879 | + if (!in_array($col_name, $current_fields)) { |
|
| 1880 | + $unique = true; |
|
| 1881 | + } else { |
|
| 1882 | + $col_name = $initial_col_name . $i; |
|
| 1883 | + } |
|
| 1818 | 1884 | } |
| 1819 | 1885 | |
| 1820 | 1886 | // Still not a unique column name? Leave it up to the user, then. |
| 1821 | - if (!$unique) |
|
| 1822 | - fatal_lang_error('custom_option_not_unique'); |
|
| 1887 | + if (!$unique) { |
|
| 1888 | + fatal_lang_error('custom_option_not_unique'); |
|
| 1889 | + } |
|
| 1823 | 1890 | } |
| 1824 | 1891 | // Work out what to do with the user data otherwise... |
| 1825 | 1892 | else |
@@ -1847,8 +1914,9 @@ discard block |
||
| 1847 | 1914 | // Work out what's changed! |
| 1848 | 1915 | foreach ($context['field']['options'] as $k => $option) |
| 1849 | 1916 | { |
| 1850 | - if (trim($option) == '') |
|
| 1851 | - continue; |
|
| 1917 | + if (trim($option) == '') { |
|
| 1918 | + continue; |
|
| 1919 | + } |
|
| 1852 | 1920 | |
| 1853 | 1921 | // Still exists? |
| 1854 | 1922 | if (in_array($option, $newOptions)) |
@@ -1862,8 +1930,8 @@ discard block |
||
| 1862 | 1930 | foreach ($optionChanges as $k => $option) |
| 1863 | 1931 | { |
| 1864 | 1932 | // Just been renamed? |
| 1865 | - if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) |
|
| 1866 | - $smcFunc['db_query']('', ' |
|
| 1933 | + if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) { |
|
| 1934 | + $smcFunc['db_query']('', ' |
|
| 1867 | 1935 | UPDATE {db_prefix}themes |
| 1868 | 1936 | SET value = {string:new_value} |
| 1869 | 1937 | WHERE variable = {string:current_column} |
@@ -1876,6 +1944,7 @@ discard block |
||
| 1876 | 1944 | 'old_value' => $option, |
| 1877 | 1945 | ) |
| 1878 | 1946 | ); |
| 1947 | + } |
|
| 1879 | 1948 | } |
| 1880 | 1949 | } |
| 1881 | 1950 | // @todo Maybe we should adjust based on new text length limits? |
@@ -1918,8 +1987,8 @@ discard block |
||
| 1918 | 1987 | ); |
| 1919 | 1988 | |
| 1920 | 1989 | // Just clean up any old selects - these are a pain! |
| 1921 | - if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) |
|
| 1922 | - $smcFunc['db_query']('', ' |
|
| 1990 | + if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) { |
|
| 1991 | + $smcFunc['db_query']('', ' |
|
| 1923 | 1992 | DELETE FROM {db_prefix}themes |
| 1924 | 1993 | WHERE variable = {string:current_column} |
| 1925 | 1994 | AND value NOT IN ({array_string:new_option_values}) |
@@ -1930,8 +1999,8 @@ discard block |
||
| 1930 | 1999 | 'current_column' => $context['field']['col_name'], |
| 1931 | 2000 | ) |
| 1932 | 2001 | ); |
| 1933 | - } |
|
| 1934 | - else |
|
| 2002 | + } |
|
| 2003 | + } else |
|
| 1935 | 2004 | { |
| 1936 | 2005 | // Gotta figure it out the order. |
| 1937 | 2006 | $new_order = $order_count > 1 ? ($order_count + 1) : 1; |
@@ -2105,11 +2174,13 @@ discard block |
||
| 2105 | 2174 | call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false)); |
| 2106 | 2175 | |
| 2107 | 2176 | $prune_toggle_dt = array(); |
| 2108 | - foreach ($prune_toggle as $item) |
|
| 2109 | - $prune_toggle_dt[] = 'setting_' . $item; |
|
| 2177 | + foreach ($prune_toggle as $item) { |
|
| 2178 | + $prune_toggle_dt[] = 'setting_' . $item; |
|
| 2179 | + } |
|
| 2110 | 2180 | |
| 2111 | - if ($return_config) |
|
| 2112 | - return $config_vars; |
|
| 2181 | + if ($return_config) { |
|
| 2182 | + return $config_vars; |
|
| 2183 | + } |
|
| 2113 | 2184 | |
| 2114 | 2185 | addInlineJavaScript(' |
| 2115 | 2186 | function togglePruned() |
@@ -2147,15 +2218,16 @@ discard block |
||
| 2147 | 2218 | $vals = array(); |
| 2148 | 2219 | foreach ($config_vars as $index => $dummy) |
| 2149 | 2220 | { |
| 2150 | - if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) |
|
| 2151 | - continue; |
|
| 2221 | + if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) { |
|
| 2222 | + continue; |
|
| 2223 | + } |
|
| 2152 | 2224 | |
| 2153 | 2225 | $vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]]; |
| 2154 | 2226 | } |
| 2155 | 2227 | $_POST['pruningOptions'] = implode(',', $vals); |
| 2228 | + } else { |
|
| 2229 | + $_POST['pruningOptions'] = ''; |
|
| 2156 | 2230 | } |
| 2157 | - else |
|
| 2158 | - $_POST['pruningOptions'] = ''; |
|
| 2159 | 2231 | |
| 2160 | 2232 | saveDBSettings($savevar); |
| 2161 | 2233 | $_SESSION['adm-save'] = true; |
@@ -2167,10 +2239,11 @@ discard block |
||
| 2167 | 2239 | $context['sub_template'] = 'show_settings'; |
| 2168 | 2240 | |
| 2169 | 2241 | // Get the actual values |
| 2170 | - if (!empty($modSettings['pruningOptions'])) |
|
| 2171 | - @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 2172 | - else |
|
| 2173 | - $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
| 2242 | + if (!empty($modSettings['pruningOptions'])) { |
|
| 2243 | + @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 2244 | + } else { |
|
| 2245 | + $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
| 2246 | + } |
|
| 2174 | 2247 | |
| 2175 | 2248 | prepareDBSettingContext($config_vars); |
| 2176 | 2249 | } |
@@ -2192,8 +2265,9 @@ discard block |
||
| 2192 | 2265 | // Make it even easier to add new settings. |
| 2193 | 2266 | call_integration_hook('integrate_general_mod_settings', array(&$config_vars)); |
| 2194 | 2267 | |
| 2195 | - if ($return_config) |
|
| 2196 | - return $config_vars; |
|
| 2268 | + if ($return_config) { |
|
| 2269 | + return $config_vars; |
|
| 2270 | + } |
|
| 2197 | 2271 | |
| 2198 | 2272 | $context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general'; |
| 2199 | 2273 | $context['settings_title'] = $txt['mods_cat_modifications_misc']; |
@@ -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 | // This defines two version types for checking the API's are compatible with this version of SMF. |
| 20 | 21 | $GLOBALS['search_versions'] = array( |
@@ -39,8 +40,9 @@ discard block |
||
| 39 | 40 | global $txt, $scripturl, $modSettings, $user_info, $context, $smcFunc, $sourcedir; |
| 40 | 41 | |
| 41 | 42 | // Is the load average too high to allow searching just now? |
| 42 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
| 43 | - fatal_lang_error('loadavg_search_disabled', false); |
|
| 43 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
| 44 | + fatal_lang_error('loadavg_search_disabled', false); |
|
| 45 | + } |
|
| 44 | 46 | |
| 45 | 47 | loadLanguage('Search'); |
| 46 | 48 | // Don't load this in XML mode. |
@@ -88,23 +90,30 @@ discard block |
||
| 88 | 90 | @list ($k, $v) = explode('|\'|', $data); |
| 89 | 91 | $context['search_params'][$k] = $v; |
| 90 | 92 | } |
| 91 | - if (isset($context['search_params']['brd'])) |
|
| 92 | - $context['search_params']['brd'] = $context['search_params']['brd'] == '' ? array() : explode(',', $context['search_params']['brd']); |
|
| 93 | + if (isset($context['search_params']['brd'])) { |
|
| 94 | + $context['search_params']['brd'] = $context['search_params']['brd'] == '' ? array() : explode(',', $context['search_params']['brd']); |
|
| 95 | + } |
|
| 93 | 96 | } |
| 94 | 97 | |
| 95 | - if (isset($_REQUEST['search'])) |
|
| 96 | - $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
| 98 | + if (isset($_REQUEST['search'])) { |
|
| 99 | + $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
| 100 | + } |
|
| 97 | 101 | |
| 98 | - if (isset($context['search_params']['search'])) |
|
| 99 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 100 | - if (isset($context['search_params']['userspec'])) |
|
| 101 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 102 | - if (!empty($context['search_params']['searchtype'])) |
|
| 103 | - $context['search_params']['searchtype'] = 2; |
|
| 104 | - if (!empty($context['search_params']['minage'])) |
|
| 105 | - $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
| 106 | - if (!empty($context['search_params']['maxage'])) |
|
| 107 | - $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
| 102 | + if (isset($context['search_params']['search'])) { |
|
| 103 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 104 | + } |
|
| 105 | + if (isset($context['search_params']['userspec'])) { |
|
| 106 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 107 | + } |
|
| 108 | + if (!empty($context['search_params']['searchtype'])) { |
|
| 109 | + $context['search_params']['searchtype'] = 2; |
|
| 110 | + } |
|
| 111 | + if (!empty($context['search_params']['minage'])) { |
|
| 112 | + $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
| 113 | + } |
|
| 114 | + if (!empty($context['search_params']['maxage'])) { |
|
| 115 | + $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
| 116 | + } |
|
| 108 | 117 | |
| 109 | 118 | $context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']); |
| 110 | 119 | $context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']); |
@@ -116,11 +125,13 @@ discard block |
||
| 116 | 125 | $context['search_errors']['messages'] = array(); |
| 117 | 126 | foreach ($context['search_errors'] as $search_error => $dummy) |
| 118 | 127 | { |
| 119 | - if ($search_error === 'messages') |
|
| 120 | - continue; |
|
| 128 | + if ($search_error === 'messages') { |
|
| 129 | + continue; |
|
| 130 | + } |
|
| 121 | 131 | |
| 122 | - if ($search_error == 'string_too_long') |
|
| 123 | - $txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']); |
|
| 132 | + if ($search_error == 'string_too_long') { |
|
| 133 | + $txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']); |
|
| 134 | + } |
|
| 124 | 135 | |
| 125 | 136 | $context['search_errors']['messages'][] = $txt['error_' . $search_error]; |
| 126 | 137 | } |
@@ -143,12 +154,13 @@ discard block |
||
| 143 | 154 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 144 | 155 | { |
| 145 | 156 | // This category hasn't been set up yet.. |
| 146 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 147 | - $context['categories'][$row['id_cat']] = array( |
|
| 157 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 158 | + $context['categories'][$row['id_cat']] = array( |
|
| 148 | 159 | 'id' => $row['id_cat'], |
| 149 | 160 | 'name' => $row['cat_name'], |
| 150 | 161 | 'boards' => array() |
| 151 | 162 | ); |
| 163 | + } |
|
| 152 | 164 | |
| 153 | 165 | // Set this board up, and let the template know when it's a child. (indent them..) |
| 154 | 166 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -159,8 +171,9 @@ discard block |
||
| 159 | 171 | ); |
| 160 | 172 | |
| 161 | 173 | // If a board wasn't checked that probably should have been ensure the board selection is selected, yo! |
| 162 | - if (!$context['categories'][$row['id_cat']]['boards'][$row['id_board']]['selected'] && (empty($modSettings['recycle_enable']) || $row['id_board'] != $modSettings['recycle_board'])) |
|
| 163 | - $context['boards_check_all'] = false; |
|
| 174 | + if (!$context['categories'][$row['id_cat']]['boards'][$row['id_board']]['selected'] && (empty($modSettings['recycle_enable']) || $row['id_board'] != $modSettings['recycle_board'])) { |
|
| 175 | + $context['boards_check_all'] = false; |
|
| 176 | + } |
|
| 164 | 177 | } |
| 165 | 178 | $smcFunc['db_free_result']($request); |
| 166 | 179 | |
@@ -182,18 +195,20 @@ discard block |
||
| 182 | 195 | } |
| 183 | 196 | |
| 184 | 197 | $max_boards = ceil(count($temp_boards) / 2); |
| 185 | - if ($max_boards == 1) |
|
| 186 | - $max_boards = 2; |
|
| 198 | + if ($max_boards == 1) { |
|
| 199 | + $max_boards = 2; |
|
| 200 | + } |
|
| 187 | 201 | |
| 188 | 202 | // Now, alternate them so they can be shown left and right ;). |
| 189 | 203 | $context['board_columns'] = array(); |
| 190 | 204 | for ($i = 0; $i < $max_boards; $i++) |
| 191 | 205 | { |
| 192 | 206 | $context['board_columns'][] = $temp_boards[$i]; |
| 193 | - if (isset($temp_boards[$i + $max_boards])) |
|
| 194 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 195 | - else |
|
| 196 | - $context['board_columns'][] = array(); |
|
| 207 | + if (isset($temp_boards[$i + $max_boards])) { |
|
| 208 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 209 | + } else { |
|
| 210 | + $context['board_columns'][] = array(); |
|
| 211 | + } |
|
| 197 | 212 | } |
| 198 | 213 | |
| 199 | 214 | if (!empty($_REQUEST['topic'])) |
@@ -225,8 +240,9 @@ discard block |
||
| 225 | 240 | ) |
| 226 | 241 | ); |
| 227 | 242 | |
| 228 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 229 | - fatal_lang_error('topic_gone', false); |
|
| 243 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 244 | + fatal_lang_error('topic_gone', false); |
|
| 245 | + } |
|
| 230 | 246 | |
| 231 | 247 | list ($context['search_topic']['subject']) = $smcFunc['db_fetch_row']($request); |
| 232 | 248 | $smcFunc['db_free_result']($request); |
@@ -256,11 +272,13 @@ discard block |
||
| 256 | 272 | global $excludedWords, $participants, $smcFunc; |
| 257 | 273 | |
| 258 | 274 | // if comming from the quick search box, and we want to search on members, well we need to do that ;) |
| 259 | - if (isset($_REQUEST['search_selection']) && $_REQUEST['search_selection'] === 'members') |
|
| 260 | - redirectexit($scripturl . '?action=mlist;sa=search;fields=name,email;search=' . urlencode($_REQUEST['search'])); |
|
| 275 | + if (isset($_REQUEST['search_selection']) && $_REQUEST['search_selection'] === 'members') { |
|
| 276 | + redirectexit($scripturl . '?action=mlist;sa=search;fields=name,email;search=' . urlencode($_REQUEST['search'])); |
|
| 277 | + } |
|
| 261 | 278 | |
| 262 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
| 263 | - fatal_lang_error('loadavg_search_disabled', false); |
|
| 279 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
| 280 | + fatal_lang_error('loadavg_search_disabled', false); |
|
| 281 | + } |
|
| 264 | 282 | |
| 265 | 283 | // No, no, no... this is a bit hard on the server, so don't you go prefetching it! |
| 266 | 284 | if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
@@ -307,8 +325,9 @@ discard block |
||
| 307 | 325 | } |
| 308 | 326 | |
| 309 | 327 | // Zero weight. Weightless :P. |
| 310 | - if (empty($weight_total)) |
|
| 311 | - fatal_lang_error('search_invalid_weights'); |
|
| 328 | + if (empty($weight_total)) { |
|
| 329 | + fatal_lang_error('search_invalid_weights'); |
|
| 330 | + } |
|
| 312 | 331 | |
| 313 | 332 | // These vars don't require an interface, they're just here for tweaking. |
| 314 | 333 | $recentPercentage = 0.30; |
@@ -326,11 +345,13 @@ discard block |
||
| 326 | 345 | $context['search_string_limit'] = 100; |
| 327 | 346 | |
| 328 | 347 | loadLanguage('Search'); |
| 329 | - if (!isset($_REQUEST['xml'])) |
|
| 330 | - loadTemplate('Search'); |
|
| 348 | + if (!isset($_REQUEST['xml'])) { |
|
| 349 | + loadTemplate('Search'); |
|
| 350 | + } |
|
| 331 | 351 | //If we're doing XML we need to use the results template regardless really. |
| 332 | - else |
|
| 333 | - $context['sub_template'] = 'results'; |
|
| 352 | + else { |
|
| 353 | + $context['sub_template'] = 'results'; |
|
| 354 | + } |
|
| 334 | 355 | |
| 335 | 356 | // Are you allowed? |
| 336 | 357 | isAllowedTo('search_posts'); |
@@ -363,34 +384,39 @@ discard block |
||
| 363 | 384 | $search_params[$k] = $v; |
| 364 | 385 | } |
| 365 | 386 | |
| 366 | - if (isset($search_params['brd'])) |
|
| 367 | - $search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']); |
|
| 387 | + if (isset($search_params['brd'])) { |
|
| 388 | + $search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']); |
|
| 389 | + } |
|
| 368 | 390 | } |
| 369 | 391 | |
| 370 | 392 | // Store whether simple search was used (needed if the user wants to do another query). |
| 371 | - if (!isset($search_params['advanced'])) |
|
| 372 | - $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
| 393 | + if (!isset($search_params['advanced'])) { |
|
| 394 | + $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
| 395 | + } |
|
| 373 | 396 | |
| 374 | 397 | // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'. |
| 375 | - if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) |
|
| 376 | - $search_params['searchtype'] = 2; |
|
| 398 | + if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) { |
|
| 399 | + $search_params['searchtype'] = 2; |
|
| 400 | + } |
|
| 377 | 401 | |
| 378 | 402 | // Minimum age of messages. Default to zero (don't set param in that case). |
| 379 | - if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) |
|
| 380 | - $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
| 403 | + if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) { |
|
| 404 | + $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
| 405 | + } |
|
| 381 | 406 | |
| 382 | 407 | // Maximum age of messages. Default to infinite (9999 days: param not set). |
| 383 | - if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999)) |
|
| 384 | - $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
| 408 | + if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999)) { |
|
| 409 | + $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
| 410 | + } |
|
| 385 | 411 | |
| 386 | 412 | // Searching a specific topic? |
| 387 | 413 | if (!empty($_REQUEST['topic']) || (!empty($_REQUEST['search_selection']) && $_REQUEST['search_selection'] == 'topic')) |
| 388 | 414 | { |
| 389 | 415 | $search_params['topic'] = empty($_REQUEST['search_selection']) ? (int) $_REQUEST['topic'] : (isset($_REQUEST['sd_topic']) ? (int) $_REQUEST['sd_topic'] : ''); |
| 390 | 416 | $search_params['show_complete'] = true; |
| 417 | + } elseif (!empty($search_params['topic'])) { |
|
| 418 | + $search_params['topic'] = (int) $search_params['topic']; |
|
| 391 | 419 | } |
| 392 | - elseif (!empty($search_params['topic'])) |
|
| 393 | - $search_params['topic'] = (int) $search_params['topic']; |
|
| 394 | 420 | |
| 395 | 421 | if (!empty($search_params['minage']) || !empty($search_params['maxage'])) |
| 396 | 422 | { |
@@ -408,19 +434,21 @@ discard block |
||
| 408 | 434 | ) |
| 409 | 435 | ); |
| 410 | 436 | list ($minMsgID, $maxMsgID) = $smcFunc['db_fetch_row']($request); |
| 411 | - if ($minMsgID < 0 || $maxMsgID < 0) |
|
| 412 | - $context['search_errors']['no_messages_in_time_frame'] = true; |
|
| 437 | + if ($minMsgID < 0 || $maxMsgID < 0) { |
|
| 438 | + $context['search_errors']['no_messages_in_time_frame'] = true; |
|
| 439 | + } |
|
| 413 | 440 | $smcFunc['db_free_result']($request); |
| 414 | 441 | } |
| 415 | 442 | |
| 416 | 443 | // Default the user name to a wildcard matching every user (*). |
| 417 | - if (!empty($search_params['userspec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) |
|
| 418 | - $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
| 444 | + if (!empty($search_params['userspec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) { |
|
| 445 | + $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
| 446 | + } |
|
| 419 | 447 | |
| 420 | 448 | // If there's no specific user, then don't mention it in the main query. |
| 421 | - if (empty($search_params['userspec'])) |
|
| 422 | - $userQuery = ''; |
|
| 423 | - else |
|
| 449 | + if (empty($search_params['userspec'])) { |
|
| 450 | + $userQuery = ''; |
|
| 451 | + } else |
|
| 424 | 452 | { |
| 425 | 453 | $userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('"' => '"')); |
| 426 | 454 | $userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')); |
@@ -432,19 +460,21 @@ discard block |
||
| 432 | 460 | { |
| 433 | 461 | $possible_users[$k] = trim($possible_users[$k]); |
| 434 | 462 | |
| 435 | - if (strlen($possible_users[$k]) == 0) |
|
| 436 | - unset($possible_users[$k]); |
|
| 463 | + if (strlen($possible_users[$k]) == 0) { |
|
| 464 | + unset($possible_users[$k]); |
|
| 465 | + } |
|
| 437 | 466 | } |
| 438 | 467 | |
| 439 | 468 | // Create a list of database-escaped search names. |
| 440 | 469 | $realNameMatches = array(); |
| 441 | - foreach ($possible_users as $possible_user) |
|
| 442 | - $realNameMatches[] = $smcFunc['db_quote']( |
|
| 470 | + foreach ($possible_users as $possible_user) { |
|
| 471 | + $realNameMatches[] = $smcFunc['db_quote']( |
|
| 443 | 472 | '{string:possible_user}', |
| 444 | 473 | array( |
| 445 | 474 | 'possible_user' => $possible_user |
| 446 | 475 | ) |
| 447 | 476 | ); |
| 477 | + } |
|
| 448 | 478 | |
| 449 | 479 | // Retrieve a list of possible members. |
| 450 | 480 | $request = $smcFunc['db_query']('', ' |
@@ -456,9 +486,9 @@ discard block |
||
| 456 | 486 | ) |
| 457 | 487 | ); |
| 458 | 488 | // Simply do nothing if there're too many members matching the criteria. |
| 459 | - if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) |
|
| 460 | - $userQuery = ''; |
|
| 461 | - elseif ($smcFunc['db_num_rows']($request) == 0) |
|
| 489 | + if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) { |
|
| 490 | + $userQuery = ''; |
|
| 491 | + } elseif ($smcFunc['db_num_rows']($request) == 0) |
|
| 462 | 492 | { |
| 463 | 493 | $userQuery = $smcFunc['db_quote']( |
| 464 | 494 | 'm.id_member = {int:id_member_guest} AND ({raw:match_possible_guest_names})', |
@@ -467,12 +497,12 @@ discard block |
||
| 467 | 497 | 'match_possible_guest_names' => 'm.poster_name LIKE ' . implode(' OR m.poster_name LIKE ', $realNameMatches), |
| 468 | 498 | ) |
| 469 | 499 | ); |
| 470 | - } |
|
| 471 | - else |
|
| 500 | + } else |
|
| 472 | 501 | { |
| 473 | 502 | $memberlist = array(); |
| 474 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 475 | - $memberlist[] = $row['id_member']; |
|
| 503 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 504 | + $memberlist[] = $row['id_member']; |
|
| 505 | + } |
|
| 476 | 506 | $userQuery = $smcFunc['db_quote']( |
| 477 | 507 | '(m.id_member IN ({array_int:matched_members}) OR (m.id_member = {int:id_member_guest} AND ({raw:match_possible_guest_names})))', |
| 478 | 508 | array( |
@@ -486,22 +516,25 @@ discard block |
||
| 486 | 516 | } |
| 487 | 517 | |
| 488 | 518 | // If the boards were passed by URL (params=), temporarily put them back in $_REQUEST. |
| 489 | - if (!empty($search_params['brd']) && is_array($search_params['brd'])) |
|
| 490 | - $_REQUEST['brd'] = $search_params['brd']; |
|
| 519 | + if (!empty($search_params['brd']) && is_array($search_params['brd'])) { |
|
| 520 | + $_REQUEST['brd'] = $search_params['brd']; |
|
| 521 | + } |
|
| 491 | 522 | |
| 492 | 523 | // Ensure that brd is an array. |
| 493 | 524 | if ((!empty($_REQUEST['brd']) && !is_array($_REQUEST['brd'])) || (!empty($_REQUEST['search_selection']) && $_REQUEST['search_selection'] == 'board')) |
| 494 | 525 | { |
| 495 | - if (!empty($_REQUEST['brd'])) |
|
| 496 | - $_REQUEST['brd'] = strpos($_REQUEST['brd'], ',') !== false ? explode(',', $_REQUEST['brd']) : array($_REQUEST['brd']); |
|
| 497 | - else |
|
| 498 | - $_REQUEST['brd'] = isset($_REQUEST['sd_brd']) ? array($_REQUEST['sd_brd']) : array(); |
|
| 526 | + if (!empty($_REQUEST['brd'])) { |
|
| 527 | + $_REQUEST['brd'] = strpos($_REQUEST['brd'], ',') !== false ? explode(',', $_REQUEST['brd']) : array($_REQUEST['brd']); |
|
| 528 | + } else { |
|
| 529 | + $_REQUEST['brd'] = isset($_REQUEST['sd_brd']) ? array($_REQUEST['sd_brd']) : array(); |
|
| 530 | + } |
|
| 499 | 531 | } |
| 500 | 532 | |
| 501 | 533 | // Make sure all boards are integers. |
| 502 | - if (!empty($_REQUEST['brd'])) |
|
| 503 | - foreach ($_REQUEST['brd'] as $id => $brd) |
|
| 534 | + if (!empty($_REQUEST['brd'])) { |
|
| 535 | + foreach ($_REQUEST['brd'] as $id => $brd) |
|
| 504 | 536 | $_REQUEST['brd'][$id] = (int) $brd; |
| 537 | + } |
|
| 505 | 538 | |
| 506 | 539 | // Special case for boards: searching just one topic? |
| 507 | 540 | if (!empty($search_params['topic'])) |
@@ -520,17 +553,18 @@ discard block |
||
| 520 | 553 | ) |
| 521 | 554 | ); |
| 522 | 555 | |
| 523 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 524 | - fatal_lang_error('topic_gone', false); |
|
| 556 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 557 | + fatal_lang_error('topic_gone', false); |
|
| 558 | + } |
|
| 525 | 559 | |
| 526 | 560 | $search_params['brd'] = array(); |
| 527 | 561 | list ($search_params['brd'][0]) = $smcFunc['db_fetch_row']($request); |
| 528 | 562 | $smcFunc['db_free_result']($request); |
| 529 | 563 | } |
| 530 | 564 | // Select all boards you've selected AND are allowed to see. |
| 531 | - elseif ($user_info['is_admin'] && (!empty($search_params['advanced']) || !empty($_REQUEST['brd']))) |
|
| 532 | - $search_params['brd'] = empty($_REQUEST['brd']) ? array() : $_REQUEST['brd']; |
|
| 533 | - else |
|
| 565 | + elseif ($user_info['is_admin'] && (!empty($search_params['advanced']) || !empty($_REQUEST['brd']))) { |
|
| 566 | + $search_params['brd'] = empty($_REQUEST['brd']) ? array() : $_REQUEST['brd']; |
|
| 567 | + } else |
|
| 534 | 568 | { |
| 535 | 569 | $see_board = empty($search_params['advanced']) ? 'query_wanna_see_board' : 'query_see_board'; |
| 536 | 570 | $request = $smcFunc['db_query']('', ' |
@@ -548,19 +582,22 @@ discard block |
||
| 548 | 582 | ) |
| 549 | 583 | ); |
| 550 | 584 | $search_params['brd'] = array(); |
| 551 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 552 | - $search_params['brd'][] = $row['id_board']; |
|
| 585 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 586 | + $search_params['brd'][] = $row['id_board']; |
|
| 587 | + } |
|
| 553 | 588 | $smcFunc['db_free_result']($request); |
| 554 | 589 | |
| 555 | 590 | // This error should pro'bly only happen for hackers. |
| 556 | - if (empty($search_params['brd'])) |
|
| 557 | - $context['search_errors']['no_boards_selected'] = true; |
|
| 591 | + if (empty($search_params['brd'])) { |
|
| 592 | + $context['search_errors']['no_boards_selected'] = true; |
|
| 593 | + } |
|
| 558 | 594 | } |
| 559 | 595 | |
| 560 | 596 | if (count($search_params['brd']) != 0) |
| 561 | 597 | { |
| 562 | - foreach ($search_params['brd'] as $k => $v) |
|
| 563 | - $search_params['brd'][$k] = (int) $v; |
|
| 598 | + foreach ($search_params['brd'] as $k => $v) { |
|
| 599 | + $search_params['brd'][$k] = (int) $v; |
|
| 600 | + } |
|
| 564 | 601 | |
| 565 | 602 | // If we've selected all boards, this parameter can be left empty. |
| 566 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -574,15 +611,16 @@ discard block |
||
| 574 | 611 | list ($num_boards) = $smcFunc['db_fetch_row']($request); |
| 575 | 612 | $smcFunc['db_free_result']($request); |
| 576 | 613 | |
| 577 | - if (count($search_params['brd']) == $num_boards) |
|
| 614 | + if (count($search_params['brd']) == $num_boards) { |
|
| 615 | + $boardQuery = ''; |
|
| 616 | + } elseif (count($search_params['brd']) == $num_boards - 1 && !empty($modSettings['recycle_board']) && !in_array($modSettings['recycle_board'], $search_params['brd'])) { |
|
| 617 | + $boardQuery = '!= ' . $modSettings['recycle_board']; |
|
| 618 | + } else { |
|
| 619 | + $boardQuery = 'IN (' . implode(', ', $search_params['brd']) . ')'; |
|
| 620 | + } |
|
| 621 | + } else { |
|
| 578 | 622 | $boardQuery = ''; |
| 579 | - elseif (count($search_params['brd']) == $num_boards - 1 && !empty($modSettings['recycle_board']) && !in_array($modSettings['recycle_board'], $search_params['brd'])) |
|
| 580 | - $boardQuery = '!= ' . $modSettings['recycle_board']; |
|
| 581 | - else |
|
| 582 | - $boardQuery = 'IN (' . implode(', ', $search_params['brd']) . ')'; |
|
| 583 | 623 | } |
| 584 | - else |
|
| 585 | - $boardQuery = ''; |
|
| 586 | 624 | |
| 587 | 625 | $search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']); |
| 588 | 626 | $search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']); |
@@ -596,11 +634,13 @@ discard block |
||
| 596 | 634 | 'id_msg', |
| 597 | 635 | ); |
| 598 | 636 | call_integration_hook('integrate_search_sort_columns', array(&$sort_columns)); |
| 599 | - if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) |
|
| 600 | - list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
| 637 | + if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) { |
|
| 638 | + list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
| 639 | + } |
|
| 601 | 640 | $search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'relevance'; |
| 602 | - if (!empty($search_params['topic']) && $search_params['sort'] === 'num_replies') |
|
| 603 | - $search_params['sort'] = 'id_msg'; |
|
| 641 | + if (!empty($search_params['topic']) && $search_params['sort'] === 'num_replies') { |
|
| 642 | + $search_params['sort'] = 'id_msg'; |
|
| 643 | + } |
|
| 604 | 644 | |
| 605 | 645 | // Sorting direction: descending unless stated otherwise. |
| 606 | 646 | $search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc'; |
@@ -624,17 +664,19 @@ discard block |
||
| 624 | 664 | // What are we searching for? |
| 625 | 665 | if (empty($search_params['search'])) |
| 626 | 666 | { |
| 627 | - if (isset($_GET['search'])) |
|
| 628 | - $search_params['search'] = un_htmlspecialchars($_GET['search']); |
|
| 629 | - elseif (isset($_POST['search'])) |
|
| 630 | - $search_params['search'] = $_POST['search']; |
|
| 631 | - else |
|
| 632 | - $search_params['search'] = ''; |
|
| 667 | + if (isset($_GET['search'])) { |
|
| 668 | + $search_params['search'] = un_htmlspecialchars($_GET['search']); |
|
| 669 | + } elseif (isset($_POST['search'])) { |
|
| 670 | + $search_params['search'] = $_POST['search']; |
|
| 671 | + } else { |
|
| 672 | + $search_params['search'] = ''; |
|
| 673 | + } |
|
| 633 | 674 | } |
| 634 | 675 | |
| 635 | 676 | // Nothing?? |
| 636 | - if (!isset($search_params['search']) || $search_params['search'] == '') |
|
| 637 | - $context['search_errors']['invalid_search_string'] = true; |
|
| 677 | + if (!isset($search_params['search']) || $search_params['search'] == '') { |
|
| 678 | + $context['search_errors']['invalid_search_string'] = true; |
|
| 679 | + } |
|
| 638 | 680 | // Too long? |
| 639 | 681 | elseif ($smcFunc['strlen']($search_params['search']) > $context['search_string_limit']) |
| 640 | 682 | { |
@@ -648,8 +690,9 @@ discard block |
||
| 648 | 690 | $stripped_query = un_htmlspecialchars($smcFunc['strtolower']($stripped_query)); |
| 649 | 691 | |
| 650 | 692 | // This (hidden) setting will do fulltext searching in the most basic way. |
| 651 | - if (!empty($modSettings['search_simple_fulltext'])) |
|
| 652 | - $stripped_query = strtr($stripped_query, array('"' => '')); |
|
| 693 | + if (!empty($modSettings['search_simple_fulltext'])) { |
|
| 694 | + $stripped_query = strtr($stripped_query, array('"' => '')); |
|
| 695 | + } |
|
| 653 | 696 | |
| 654 | 697 | $no_regexp = preg_match('~&#(?:\d{1,7}|x[0-9a-fA-F]{1,6});~', $stripped_query) === 1; |
| 655 | 698 | |
@@ -672,8 +715,9 @@ discard block |
||
| 672 | 715 | { |
| 673 | 716 | if ($word === '-') |
| 674 | 717 | { |
| 675 | - if (($word = trim($phraseArray[$index], '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) |
|
| 676 | - $excludedWords[] = $word; |
|
| 718 | + if (($word = trim($phraseArray[$index], '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) { |
|
| 719 | + $excludedWords[] = $word; |
|
| 720 | + } |
|
| 677 | 721 | unset($phraseArray[$index]); |
| 678 | 722 | } |
| 679 | 723 | } |
@@ -683,8 +727,9 @@ discard block |
||
| 683 | 727 | { |
| 684 | 728 | if (strpos(trim($word), '-') === 0) |
| 685 | 729 | { |
| 686 | - if (($word = trim($word, '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) |
|
| 687 | - $excludedWords[] = $word; |
|
| 730 | + if (($word = trim($word, '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) { |
|
| 731 | + $excludedWords[] = $word; |
|
| 732 | + } |
|
| 688 | 733 | unset($wordArray[$index]); |
| 689 | 734 | } |
| 690 | 735 | } |
@@ -697,8 +742,9 @@ discard block |
||
| 697 | 742 | foreach ($searchArray as $index => $value) |
| 698 | 743 | { |
| 699 | 744 | // Skip anything practically empty. |
| 700 | - if (($searchArray[$index] = trim($value, '-_\' ')) === '') |
|
| 701 | - unset($searchArray[$index]); |
|
| 745 | + if (($searchArray[$index] = trim($value, '-_\' ')) === '') { |
|
| 746 | + unset($searchArray[$index]); |
|
| 747 | + } |
|
| 702 | 748 | // Skip blacklisted words. Make sure to note we skipped them in case we end up with nothing. |
| 703 | 749 | elseif (in_array($searchArray[$index], $blacklisted_words)) |
| 704 | 750 | { |
@@ -710,39 +756,45 @@ discard block |
||
| 710 | 756 | { |
| 711 | 757 | $context['search_ignored'][] = $value; |
| 712 | 758 | unset($searchArray[$index]); |
| 759 | + } else { |
|
| 760 | + $searchArray[$index] = $searchArray[$index]; |
|
| 713 | 761 | } |
| 714 | - else |
|
| 715 | - $searchArray[$index] = $searchArray[$index]; |
|
| 716 | 762 | } |
| 717 | 763 | $searchArray = array_slice(array_unique($searchArray), 0, 10); |
| 718 | 764 | |
| 719 | 765 | // Create an array of replacements for highlighting. |
| 720 | 766 | $context['mark'] = array(); |
| 721 | - foreach ($searchArray as $word) |
|
| 722 | - $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
| 767 | + foreach ($searchArray as $word) { |
|
| 768 | + $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
| 769 | + } |
|
| 723 | 770 | |
| 724 | 771 | // Initialize two arrays storing the words that have to be searched for. |
| 725 | 772 | $orParts = array(); |
| 726 | 773 | $searchWords = array(); |
| 727 | 774 | |
| 728 | 775 | // Make sure at least one word is being searched for. |
| 729 | - if (empty($searchArray)) |
|
| 730 | - $context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true; |
|
| 776 | + if (empty($searchArray)) { |
|
| 777 | + $context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true; |
|
| 778 | + } |
|
| 731 | 779 | // All words/sentences must match. |
| 732 | - elseif (empty($search_params['searchtype'])) |
|
| 733 | - $orParts[0] = $searchArray; |
|
| 780 | + elseif (empty($search_params['searchtype'])) { |
|
| 781 | + $orParts[0] = $searchArray; |
|
| 782 | + } |
|
| 734 | 783 | // Any word/sentence must match. |
| 735 | - else |
|
| 736 | - foreach ($searchArray as $index => $value) |
|
| 784 | + else { |
|
| 785 | + foreach ($searchArray as $index => $value) |
|
| 737 | 786 | $orParts[$index] = array($value); |
| 787 | + } |
|
| 738 | 788 | |
| 739 | 789 | // Don't allow duplicate error messages if one string is too short. |
| 740 | - if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) |
|
| 741 | - unset($context['search_errors']['invalid_search_string']); |
|
| 790 | + if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) { |
|
| 791 | + unset($context['search_errors']['invalid_search_string']); |
|
| 792 | + } |
|
| 742 | 793 | // Make sure the excluded words are in all or-branches. |
| 743 | - foreach ($orParts as $orIndex => $andParts) |
|
| 744 | - foreach ($excludedWords as $word) |
|
| 794 | + foreach ($orParts as $orIndex => $andParts) { |
|
| 795 | + foreach ($excludedWords as $word) |
|
| 745 | 796 | $orParts[$orIndex][] = $word; |
| 797 | + } |
|
| 746 | 798 | |
| 747 | 799 | // Determine the or-branches and the fulltext search words. |
| 748 | 800 | foreach ($orParts as $orIndex => $andParts) |
@@ -756,8 +808,9 @@ discard block |
||
| 756 | 808 | ); |
| 757 | 809 | |
| 758 | 810 | // Sort the indexed words (large words -> small words -> excluded words). |
| 759 | - if ($searchAPI->supportsMethod('searchSort')) |
|
| 760 | - usort($orParts[$orIndex], 'searchSort'); |
|
| 811 | + if ($searchAPI->supportsMethod('searchSort')) { |
|
| 812 | + usort($orParts[$orIndex], 'searchSort'); |
|
| 813 | + } |
|
| 761 | 814 | |
| 762 | 815 | foreach ($orParts[$orIndex] as $word) |
| 763 | 816 | { |
@@ -769,15 +822,17 @@ discard block |
||
| 769 | 822 | if (!$is_excluded || count($subjectWords) === 1) |
| 770 | 823 | { |
| 771 | 824 | $searchWords[$orIndex]['subject_words'] = array_merge($searchWords[$orIndex]['subject_words'], $subjectWords); |
| 772 | - if ($is_excluded) |
|
| 773 | - $excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords); |
|
| 825 | + if ($is_excluded) { |
|
| 826 | + $excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords); |
|
| 827 | + } |
|
| 828 | + } else { |
|
| 829 | + $excludedPhrases[] = $word; |
|
| 774 | 830 | } |
| 775 | - else |
|
| 776 | - $excludedPhrases[] = $word; |
|
| 777 | 831 | |
| 778 | 832 | // Have we got indexes to prepare? |
| 779 | - if ($searchAPI->supportsMethod('prepareIndexes')) |
|
| 780 | - $searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded); |
|
| 833 | + if ($searchAPI->supportsMethod('prepareIndexes')) { |
|
| 834 | + $searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded); |
|
| 835 | + } |
|
| 781 | 836 | } |
| 782 | 837 | |
| 783 | 838 | // Search_force_index requires all AND parts to have at least one fulltext word. |
@@ -785,8 +840,7 @@ discard block |
||
| 785 | 840 | { |
| 786 | 841 | $context['search_errors']['query_not_specific_enough'] = true; |
| 787 | 842 | break; |
| 788 | - } |
|
| 789 | - elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords)) |
|
| 843 | + } elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords)) |
|
| 790 | 844 | { |
| 791 | 845 | $context['search_errors']['query_not_specific_enough'] = true; |
| 792 | 846 | break; |
@@ -814,8 +868,9 @@ discard block |
||
| 814 | 868 | $found_misspelling = false; |
| 815 | 869 | foreach ($searchArray as $word) |
| 816 | 870 | { |
| 817 | - if (empty($link)) |
|
| 818 | - continue; |
|
| 871 | + if (empty($link)) { |
|
| 872 | + continue; |
|
| 873 | + } |
|
| 819 | 874 | |
| 820 | 875 | // Don't check phrases. |
| 821 | 876 | if (preg_match('~^\w+$~', $word) === 0) |
@@ -830,8 +885,7 @@ discard block |
||
| 830 | 885 | $did_you_mean['search'][] = $word; |
| 831 | 886 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
| 832 | 887 | continue; |
| 833 | - } |
|
| 834 | - elseif (spell_check($link, $word)) |
|
| 888 | + } elseif (spell_check($link, $word)) |
|
| 835 | 889 | { |
| 836 | 890 | $did_you_mean['search'][] = $word; |
| 837 | 891 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
@@ -842,11 +896,13 @@ discard block |
||
| 842 | 896 | foreach ($suggestions as $i => $s) |
| 843 | 897 | { |
| 844 | 898 | // Search is case insensitive. |
| 845 | - if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word)) |
|
| 846 | - unset($suggestions[$i]); |
|
| 899 | + if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word)) { |
|
| 900 | + unset($suggestions[$i]); |
|
| 901 | + } |
|
| 847 | 902 | // Plus, don't suggest something the user thinks is rude! |
| 848 | - elseif ($suggestions[$i] != censorText($s)) |
|
| 849 | - unset($suggestions[$i]); |
|
| 903 | + elseif ($suggestions[$i] != censorText($s)) { |
|
| 904 | + unset($suggestions[$i]); |
|
| 905 | + } |
|
| 850 | 906 | } |
| 851 | 907 | |
| 852 | 908 | // Anything found? If so, correct it! |
@@ -856,8 +912,7 @@ discard block |
||
| 856 | 912 | $did_you_mean['search'][] = $suggestions[0]; |
| 857 | 913 | $did_you_mean['display'][] = '<em><strong>' . $smcFunc['htmlspecialchars']($suggestions[0]) . '</strong></em>'; |
| 858 | 914 | $found_misspelling = true; |
| 859 | - } |
|
| 860 | - else |
|
| 915 | + } else |
|
| 861 | 916 | { |
| 862 | 917 | $did_you_mean['search'][] = $word; |
| 863 | 918 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
@@ -874,8 +929,7 @@ discard block |
||
| 874 | 929 | { |
| 875 | 930 | $temp_excluded['search'][] = '-"' . $word . '"'; |
| 876 | 931 | $temp_excluded['display'][] = '-"' . $smcFunc['htmlspecialchars']($word) . '"'; |
| 877 | - } |
|
| 878 | - else |
|
| 932 | + } else |
|
| 879 | 933 | { |
| 880 | 934 | $temp_excluded['search'][] = '-' . $word; |
| 881 | 935 | $temp_excluded['display'][] = '-' . $smcFunc['htmlspecialchars']($word); |
@@ -887,11 +941,13 @@ discard block |
||
| 887 | 941 | |
| 888 | 942 | $temp_params = $search_params; |
| 889 | 943 | $temp_params['search'] = implode(' ', $did_you_mean['search']); |
| 890 | - if (isset($temp_params['brd'])) |
|
| 891 | - $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
| 944 | + if (isset($temp_params['brd'])) { |
|
| 945 | + $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
| 946 | + } |
|
| 892 | 947 | $context['params'] = array(); |
| 893 | - foreach ($temp_params as $k => $v) |
|
| 894 | - $context['did_you_mean_params'][] = $k . '|\'|' . $v; |
|
| 948 | + foreach ($temp_params as $k => $v) { |
|
| 949 | + $context['did_you_mean_params'][] = $k . '|\'|' . $v; |
|
| 950 | + } |
|
| 895 | 951 | $context['did_you_mean_params'] = base64_encode(implode('|"|', $context['did_you_mean_params'])); |
| 896 | 952 | $context['did_you_mean'] = implode(' ', $did_you_mean['display']); |
| 897 | 953 | } |
@@ -899,18 +955,20 @@ discard block |
||
| 899 | 955 | |
| 900 | 956 | // Let the user adjust the search query, should they wish? |
| 901 | 957 | $context['search_params'] = $search_params; |
| 902 | - if (isset($context['search_params']['search'])) |
|
| 903 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 904 | - if (isset($context['search_params']['userspec'])) |
|
| 905 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 958 | + if (isset($context['search_params']['search'])) { |
|
| 959 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 960 | + } |
|
| 961 | + if (isset($context['search_params']['userspec'])) { |
|
| 962 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 963 | + } |
|
| 906 | 964 | |
| 907 | 965 | // Do we have captcha enabled? |
| 908 | 966 | if ($user_info['is_guest'] && !empty($modSettings['search_enable_captcha']) && empty($_SESSION['ss_vv_passed']) && (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search'])) |
| 909 | 967 | { |
| 910 | 968 | // If we come from another search box tone down the error... |
| 911 | - if (!isset($_REQUEST['search_vv'])) |
|
| 912 | - $context['search_errors']['need_verification_code'] = true; |
|
| 913 | - else |
|
| 969 | + if (!isset($_REQUEST['search_vv'])) { |
|
| 970 | + $context['search_errors']['need_verification_code'] = true; |
|
| 971 | + } else |
|
| 914 | 972 | { |
| 915 | 973 | require_once($sourcedir . '/Subs-Editor.php'); |
| 916 | 974 | $verificationOptions = array( |
@@ -920,12 +978,14 @@ discard block |
||
| 920 | 978 | |
| 921 | 979 | if (is_array($context['require_verification'])) |
| 922 | 980 | { |
| 923 | - foreach ($context['require_verification'] as $error) |
|
| 924 | - $context['search_errors'][$error] = true; |
|
| 981 | + foreach ($context['require_verification'] as $error) { |
|
| 982 | + $context['search_errors'][$error] = true; |
|
| 983 | + } |
|
| 925 | 984 | } |
| 926 | 985 | // Don't keep asking for it - they've proven themselves worthy. |
| 927 | - else |
|
| 928 | - $_SESSION['ss_vv_passed'] = true; |
|
| 986 | + else { |
|
| 987 | + $_SESSION['ss_vv_passed'] = true; |
|
| 988 | + } |
|
| 929 | 989 | } |
| 930 | 990 | } |
| 931 | 991 | |
@@ -933,19 +993,22 @@ discard block |
||
| 933 | 993 | |
| 934 | 994 | // All search params have been checked, let's compile them to a single string... made less simple by PHP 4.3.9 and below. |
| 935 | 995 | $temp_params = $search_params; |
| 936 | - if (isset($temp_params['brd'])) |
|
| 937 | - $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
| 996 | + if (isset($temp_params['brd'])) { |
|
| 997 | + $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
| 998 | + } |
|
| 938 | 999 | $context['params'] = array(); |
| 939 | - foreach ($temp_params as $k => $v) |
|
| 940 | - $context['params'][] = $k . '|\'|' . $v; |
|
| 1000 | + foreach ($temp_params as $k => $v) { |
|
| 1001 | + $context['params'][] = $k . '|\'|' . $v; |
|
| 1002 | + } |
|
| 941 | 1003 | |
| 942 | 1004 | if (!empty($context['params'])) |
| 943 | 1005 | { |
| 944 | 1006 | // Due to old IE's 2083 character limit, we have to compress long search strings |
| 945 | 1007 | $params = @gzcompress(implode('|"|', $context['params'])); |
| 946 | 1008 | // Gzcompress failed, use try non-gz |
| 947 | - if (empty($params)) |
|
| 948 | - $params = implode('|"|', $context['params']); |
|
| 1009 | + if (empty($params)) { |
|
| 1010 | + $params = implode('|"|', $context['params']); |
|
| 1011 | + } |
|
| 949 | 1012 | // Base64 encode, then replace +/= with uri safe ones that can be reverted |
| 950 | 1013 | $context['params'] = str_replace(array('+', '/', '='), array('-', '_', '.'), base64_encode($params)); |
| 951 | 1014 | } |
@@ -971,8 +1034,9 @@ discard block |
||
| 971 | 1034 | } |
| 972 | 1035 | |
| 973 | 1036 | // Spam me not, Spam-a-lot? |
| 974 | - if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']) |
|
| 975 | - spamProtection('search'); |
|
| 1037 | + if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']) { |
|
| 1038 | + spamProtection('search'); |
|
| 1039 | + } |
|
| 976 | 1040 | // Store the last search string to allow pages of results to be browsed. |
| 977 | 1041 | $_SESSION['last_ss'] = $search_params['search']; |
| 978 | 1042 | |
@@ -1032,8 +1096,9 @@ discard block |
||
| 1032 | 1096 | 'where' => array(), |
| 1033 | 1097 | ); |
| 1034 | 1098 | |
| 1035 | - if ($modSettings['postmod_active']) |
|
| 1036 | - $subject_query['where'][] = 't.approved = {int:is_approved}'; |
|
| 1099 | + if ($modSettings['postmod_active']) { |
|
| 1100 | + $subject_query['where'][] = 't.approved = {int:is_approved}'; |
|
| 1101 | + } |
|
| 1037 | 1102 | |
| 1038 | 1103 | $numTables = 0; |
| 1039 | 1104 | $prev_join = 0; |
@@ -1045,8 +1110,7 @@ discard block |
||
| 1045 | 1110 | { |
| 1046 | 1111 | $subject_query['left_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}') . ' AND subj' . $numTables . '.id_topic = t.id_topic)'; |
| 1047 | 1112 | $subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)'; |
| 1048 | - } |
|
| 1049 | - else |
|
| 1113 | + } else |
|
| 1050 | 1114 | { |
| 1051 | 1115 | $subject_query['inner_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.id_topic = ' . ($prev_join === 0 ? 't' : 'subj' . $prev_join) . '.id_topic)'; |
| 1052 | 1116 | $subject_query['where'][] = 'subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}'); |
@@ -1064,14 +1128,18 @@ discard block |
||
| 1064 | 1128 | } |
| 1065 | 1129 | $subject_query['where'][] = $userQuery; |
| 1066 | 1130 | } |
| 1067 | - if (!empty($search_params['topic'])) |
|
| 1068 | - $subject_query['where'][] = 't.id_topic = ' . $search_params['topic']; |
|
| 1069 | - if (!empty($minMsgID)) |
|
| 1070 | - $subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID; |
|
| 1071 | - if (!empty($maxMsgID)) |
|
| 1072 | - $subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID; |
|
| 1073 | - if (!empty($boardQuery)) |
|
| 1074 | - $subject_query['where'][] = 't.id_board ' . $boardQuery; |
|
| 1131 | + if (!empty($search_params['topic'])) { |
|
| 1132 | + $subject_query['where'][] = 't.id_topic = ' . $search_params['topic']; |
|
| 1133 | + } |
|
| 1134 | + if (!empty($minMsgID)) { |
|
| 1135 | + $subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID; |
|
| 1136 | + } |
|
| 1137 | + if (!empty($maxMsgID)) { |
|
| 1138 | + $subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID; |
|
| 1139 | + } |
|
| 1140 | + if (!empty($boardQuery)) { |
|
| 1141 | + $subject_query['where'][] = 't.id_board ' . $boardQuery; |
|
| 1142 | + } |
|
| 1075 | 1143 | if (!empty($excludedPhrases)) |
| 1076 | 1144 | { |
| 1077 | 1145 | if ($subject_query['from'] != '{db_prefix}messages AS m') |
@@ -1091,8 +1159,9 @@ discard block |
||
| 1091 | 1159 | foreach ($weight_factors as $type => $value) |
| 1092 | 1160 | { |
| 1093 | 1161 | $relevance .= $weight[$type]; |
| 1094 | - if (!empty($value['results'])) |
|
| 1095 | - $relevance .= ' * ' . $value['results']; |
|
| 1162 | + if (!empty($value['results'])) { |
|
| 1163 | + $relevance .= ' * ' . $value['results']; |
|
| 1164 | + } |
|
| 1096 | 1165 | $relevance .= ' + '; |
| 1097 | 1166 | } |
| 1098 | 1167 | $relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance'; |
@@ -1130,20 +1199,23 @@ discard block |
||
| 1130 | 1199 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
| 1131 | 1200 | { |
| 1132 | 1201 | // No duplicates! |
| 1133 | - if (isset($inserts[$row[1]])) |
|
| 1134 | - continue; |
|
| 1202 | + if (isset($inserts[$row[1]])) { |
|
| 1203 | + continue; |
|
| 1204 | + } |
|
| 1135 | 1205 | |
| 1136 | - foreach ($row as $key => $value) |
|
| 1137 | - $inserts[$row[1]][] = (int) $row[$key]; |
|
| 1206 | + foreach ($row as $key => $value) { |
|
| 1207 | + $inserts[$row[1]][] = (int) $row[$key]; |
|
| 1208 | + } |
|
| 1138 | 1209 | } |
| 1139 | 1210 | $smcFunc['db_free_result']($ignoreRequest); |
| 1140 | 1211 | $numSubjectResults = count($inserts); |
| 1212 | + } else { |
|
| 1213 | + $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
| 1141 | 1214 | } |
| 1142 | - else |
|
| 1143 | - $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
| 1144 | 1215 | |
| 1145 | - if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) |
|
| 1146 | - break; |
|
| 1216 | + if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) { |
|
| 1217 | + break; |
|
| 1218 | + } |
|
| 1147 | 1219 | } |
| 1148 | 1220 | |
| 1149 | 1221 | // If there's data to be inserted for non-IGNORE databases do it here! |
@@ -1158,8 +1230,7 @@ discard block |
||
| 1158 | 1230 | } |
| 1159 | 1231 | |
| 1160 | 1232 | $_SESSION['search_cache']['num_results'] = $numSubjectResults; |
| 1161 | - } |
|
| 1162 | - else |
|
| 1233 | + } else |
|
| 1163 | 1234 | { |
| 1164 | 1235 | $main_query = array( |
| 1165 | 1236 | 'select' => array( |
@@ -1191,8 +1262,7 @@ discard block |
||
| 1191 | 1262 | $main_query['weights'] = $weight_factors; |
| 1192 | 1263 | |
| 1193 | 1264 | $main_query['group_by'][] = 't.id_topic'; |
| 1194 | - } |
|
| 1195 | - else |
|
| 1265 | + } else |
|
| 1196 | 1266 | { |
| 1197 | 1267 | // This is outrageous! |
| 1198 | 1268 | $main_query['select']['id_topic'] = 'm.id_msg AS id_topic'; |
@@ -1213,8 +1283,9 @@ discard block |
||
| 1213 | 1283 | $main_query['where'][] = 't.id_topic = {int:topic}'; |
| 1214 | 1284 | $main_query['parameters']['topic'] = $search_params['topic']; |
| 1215 | 1285 | } |
| 1216 | - if (!empty($search_params['show_complete'])) |
|
| 1217 | - $main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg'; |
|
| 1286 | + if (!empty($search_params['show_complete'])) { |
|
| 1287 | + $main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg'; |
|
| 1288 | + } |
|
| 1218 | 1289 | } |
| 1219 | 1290 | |
| 1220 | 1291 | // *** Get the subject results. |
@@ -1241,14 +1312,15 @@ discard block |
||
| 1241 | 1312 | ) !== false; |
| 1242 | 1313 | |
| 1243 | 1314 | // Clean up some previous cache. |
| 1244 | - if (!$createTemporary) |
|
| 1245 | - $smcFunc['db_search_query']('delete_log_search_topics', ' |
|
| 1315 | + if (!$createTemporary) { |
|
| 1316 | + $smcFunc['db_search_query']('delete_log_search_topics', ' |
|
| 1246 | 1317 | DELETE FROM {db_prefix}log_search_topics |
| 1247 | 1318 | WHERE id_search = {int:search_id}', |
| 1248 | 1319 | array( |
| 1249 | 1320 | 'search_id' => $_SESSION['search_cache']['id_search'], |
| 1250 | 1321 | ) |
| 1251 | 1322 | ); |
| 1323 | + } |
|
| 1252 | 1324 | |
| 1253 | 1325 | foreach ($searchWords as $orIndex => $words) |
| 1254 | 1326 | { |
@@ -1280,8 +1352,7 @@ discard block |
||
| 1280 | 1352 | $subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)'; |
| 1281 | 1353 | $subject_query['where'][] = 'm.body NOT ' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:body_not_' . $count . '}'; |
| 1282 | 1354 | $subject_query['params']['body_not_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($subjectWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $subjectWord), '\\\'') . '[[:>:]]'; |
| 1283 | - } |
|
| 1284 | - else |
|
| 1355 | + } else |
|
| 1285 | 1356 | { |
| 1286 | 1357 | $subject_query['inner_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.id_topic = ' . ($prev_join === 0 ? 't' : 'subj' . $prev_join) . '.id_topic)'; |
| 1287 | 1358 | $subject_query['where'][] = 'subj' . $numTables . '.word LIKE {string:subject_like_' . $count . '}'; |
@@ -1336,8 +1407,9 @@ discard block |
||
| 1336 | 1407 | call_integration_hook('integrate_subject_search_query', array(&$subject_query)); |
| 1337 | 1408 | |
| 1338 | 1409 | // Nothing to search for? |
| 1339 | - if (empty($subject_query['where'])) |
|
| 1340 | - continue; |
|
| 1410 | + if (empty($subject_query['where'])) { |
|
| 1411 | + continue; |
|
| 1412 | + } |
|
| 1341 | 1413 | |
| 1342 | 1414 | $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ( ' |
| 1343 | 1415 | INSERT IGNORE INTO {db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics |
@@ -1360,19 +1432,21 @@ discard block |
||
| 1360 | 1432 | { |
| 1361 | 1433 | $ind = $createTemporary ? 0 : 1; |
| 1362 | 1434 | // No duplicates! |
| 1363 | - if (isset($inserts[$row[$ind]])) |
|
| 1364 | - continue; |
|
| 1435 | + if (isset($inserts[$row[$ind]])) { |
|
| 1436 | + continue; |
|
| 1437 | + } |
|
| 1365 | 1438 | |
| 1366 | 1439 | $inserts[$row[$ind]] = $row; |
| 1367 | 1440 | } |
| 1368 | 1441 | $smcFunc['db_free_result']($ignoreRequest); |
| 1369 | 1442 | $numSubjectResults = count($inserts); |
| 1443 | + } else { |
|
| 1444 | + $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
| 1370 | 1445 | } |
| 1371 | - else |
|
| 1372 | - $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
| 1373 | 1446 | |
| 1374 | - if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) |
|
| 1375 | - break; |
|
| 1447 | + if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) { |
|
| 1448 | + break; |
|
| 1449 | + } |
|
| 1376 | 1450 | } |
| 1377 | 1451 | |
| 1378 | 1452 | // Got some non-MySQL data to plonk in? |
@@ -1390,8 +1464,9 @@ discard block |
||
| 1390 | 1464 | { |
| 1391 | 1465 | $main_query['weights']['subject']['search'] = 'CASE WHEN MAX(lst.id_topic) IS NULL THEN 0 ELSE 1 END'; |
| 1392 | 1466 | $main_query['left_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics AS lst ON (' . ($createTemporary ? '' : 'lst.id_search = {int:id_search} AND ') . 'lst.id_topic = t.id_topic)'; |
| 1393 | - if (!$createTemporary) |
|
| 1394 | - $main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search']; |
|
| 1467 | + if (!$createTemporary) { |
|
| 1468 | + $main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search']; |
|
| 1469 | + } |
|
| 1395 | 1470 | } |
| 1396 | 1471 | } |
| 1397 | 1472 | |
@@ -1419,14 +1494,15 @@ discard block |
||
| 1419 | 1494 | ) !== false; |
| 1420 | 1495 | |
| 1421 | 1496 | // Clear, all clear! |
| 1422 | - if (!$createTemporary) |
|
| 1423 | - $smcFunc['db_search_query']('delete_log_search_messages', ' |
|
| 1497 | + if (!$createTemporary) { |
|
| 1498 | + $smcFunc['db_search_query']('delete_log_search_messages', ' |
|
| 1424 | 1499 | DELETE FROM {db_prefix}log_search_messages |
| 1425 | 1500 | WHERE id_search = {int:id_search}', |
| 1426 | 1501 | array( |
| 1427 | 1502 | 'id_search' => $_SESSION['search_cache']['id_search'], |
| 1428 | 1503 | ) |
| 1429 | 1504 | ); |
| 1505 | + } |
|
| 1430 | 1506 | |
| 1431 | 1507 | foreach ($searchWords as $orIndex => $words) |
| 1432 | 1508 | { |
@@ -1460,19 +1536,21 @@ discard block |
||
| 1460 | 1536 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
| 1461 | 1537 | { |
| 1462 | 1538 | // No duplicates! |
| 1463 | - if (isset($inserts[$row[0]])) |
|
| 1464 | - continue; |
|
| 1539 | + if (isset($inserts[$row[0]])) { |
|
| 1540 | + continue; |
|
| 1541 | + } |
|
| 1465 | 1542 | |
| 1466 | 1543 | $inserts[$row[0]] = $row; |
| 1467 | 1544 | } |
| 1468 | 1545 | $smcFunc['db_free_result']($ignoreRequest); |
| 1469 | 1546 | $indexedResults = count($inserts); |
| 1547 | + } else { |
|
| 1548 | + $indexedResults += $smcFunc['db_affected_rows'](); |
|
| 1470 | 1549 | } |
| 1471 | - else |
|
| 1472 | - $indexedResults += $smcFunc['db_affected_rows'](); |
|
| 1473 | 1550 | |
| 1474 | - if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults) |
|
| 1475 | - break; |
|
| 1551 | + if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults) { |
|
| 1552 | + break; |
|
| 1553 | + } |
|
| 1476 | 1554 | } |
| 1477 | 1555 | } |
| 1478 | 1556 | |
@@ -1492,8 +1570,7 @@ discard block |
||
| 1492 | 1570 | $context['search_errors']['query_not_specific_enough'] = true; |
| 1493 | 1571 | $_REQUEST['params'] = $context['params']; |
| 1494 | 1572 | return PlushSearch1(); |
| 1495 | - } |
|
| 1496 | - elseif (!empty($indexedResults)) |
|
| 1573 | + } elseif (!empty($indexedResults)) |
|
| 1497 | 1574 | { |
| 1498 | 1575 | $main_query['inner_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_messages AS lsm ON (lsm.id_msg = m.id_msg)'; |
| 1499 | 1576 | if (!$createTemporary) |
@@ -1515,15 +1592,18 @@ discard block |
||
| 1515 | 1592 | foreach ($words['all_words'] as $regularWord) |
| 1516 | 1593 | { |
| 1517 | 1594 | $where[] = 'm.body' . (in_array($regularWord, $excludedWords) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
| 1518 | - if (in_array($regularWord, $excludedWords)) |
|
| 1519 | - $where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
|
| 1595 | + if (in_array($regularWord, $excludedWords)) { |
|
| 1596 | + $where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
|
| 1597 | + } |
|
| 1520 | 1598 | $main_query['parameters']['all_word_body_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
| 1521 | 1599 | } |
| 1522 | - if (!empty($where)) |
|
| 1523 | - $orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0]; |
|
| 1600 | + if (!empty($where)) { |
|
| 1601 | + $orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0]; |
|
| 1602 | + } |
|
| 1603 | + } |
|
| 1604 | + if (!empty($orWhere)) { |
|
| 1605 | + $main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0]; |
|
| 1524 | 1606 | } |
| 1525 | - if (!empty($orWhere)) |
|
| 1526 | - $main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0]; |
|
| 1527 | 1607 | |
| 1528 | 1608 | if (!empty($userQuery)) |
| 1529 | 1609 | { |
@@ -1561,8 +1641,9 @@ discard block |
||
| 1561 | 1641 | foreach ($main_query['weights'] as $type => $value) |
| 1562 | 1642 | { |
| 1563 | 1643 | $relevance .= $weight[$type]; |
| 1564 | - if (!empty($value['search'])) |
|
| 1565 | - $relevance .= ' * ' . $value['search']; |
|
| 1644 | + if (!empty($value['search'])) { |
|
| 1645 | + $relevance .= ' * ' . $value['search']; |
|
| 1646 | + } |
|
| 1566 | 1647 | $relevance .= ' + '; |
| 1567 | 1648 | $new_weight_total += $weight[$type]; |
| 1568 | 1649 | } |
@@ -1593,11 +1674,13 @@ discard block |
||
| 1593 | 1674 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
| 1594 | 1675 | { |
| 1595 | 1676 | // No duplicates! |
| 1596 | - if (isset($inserts[$row[2]])) |
|
| 1597 | - continue; |
|
| 1677 | + if (isset($inserts[$row[2]])) { |
|
| 1678 | + continue; |
|
| 1679 | + } |
|
| 1598 | 1680 | |
| 1599 | - foreach ($row as $key => $value) |
|
| 1600 | - $inserts[$row[2]][] = (int) $row[$key]; |
|
| 1681 | + foreach ($row as $key => $value) { |
|
| 1682 | + $inserts[$row[2]][] = (int) $row[$key]; |
|
| 1683 | + } |
|
| 1601 | 1684 | } |
| 1602 | 1685 | $smcFunc['db_free_result']($ignoreRequest); |
| 1603 | 1686 | |
@@ -1605,8 +1688,9 @@ discard block |
||
| 1605 | 1688 | if (!empty($inserts)) |
| 1606 | 1689 | { |
| 1607 | 1690 | $query_columns = array(); |
| 1608 | - foreach ($main_query['select'] as $k => $v) |
|
| 1609 | - $query_columns[$k] = 'int'; |
|
| 1691 | + foreach ($main_query['select'] as $k => $v) { |
|
| 1692 | + $query_columns[$k] = 'int'; |
|
| 1693 | + } |
|
| 1610 | 1694 | |
| 1611 | 1695 | $smcFunc['db_insert']('', |
| 1612 | 1696 | '{db_prefix}log_search_results', |
@@ -1616,21 +1700,23 @@ discard block |
||
| 1616 | 1700 | ); |
| 1617 | 1701 | } |
| 1618 | 1702 | $_SESSION['search_cache']['num_results'] += count($inserts); |
| 1703 | + } else { |
|
| 1704 | + $_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows'](); |
|
| 1619 | 1705 | } |
| 1620 | - else |
|
| 1621 | - $_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows'](); |
|
| 1622 | 1706 | } |
| 1623 | 1707 | |
| 1624 | 1708 | // Insert subject-only matches. |
| 1625 | 1709 | if ($_SESSION['search_cache']['num_results'] < $modSettings['search_max_results'] && $numSubjectResults !== 0) |
| 1626 | 1710 | { |
| 1627 | 1711 | $relevance = '1000 * ('; |
| 1628 | - foreach ($weight_factors as $type => $value) |
|
| 1629 | - if (isset($value['results'])) |
|
| 1712 | + foreach ($weight_factors as $type => $value) { |
|
| 1713 | + if (isset($value['results'])) |
|
| 1630 | 1714 | { |
| 1631 | 1715 | $relevance .= $weight[$type]; |
| 1632 | - if (!empty($value['results'])) |
|
| 1633 | - $relevance .= ' * ' . $value['results']; |
|
| 1716 | + } |
|
| 1717 | + if (!empty($value['results'])) { |
|
| 1718 | + $relevance .= ' * ' . $value['results']; |
|
| 1719 | + } |
|
| 1634 | 1720 | $relevance .= ' + '; |
| 1635 | 1721 | } |
| 1636 | 1722 | $relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance'; |
@@ -1664,8 +1750,9 @@ discard block |
||
| 1664 | 1750 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
| 1665 | 1751 | { |
| 1666 | 1752 | // No duplicates! |
| 1667 | - if (isset($usedIDs[$row[1]])) |
|
| 1668 | - continue; |
|
| 1753 | + if (isset($usedIDs[$row[1]])) { |
|
| 1754 | + continue; |
|
| 1755 | + } |
|
| 1669 | 1756 | |
| 1670 | 1757 | $usedIDs[$row[1]] = true; |
| 1671 | 1758 | $inserts[] = $row; |
@@ -1683,12 +1770,12 @@ discard block |
||
| 1683 | 1770 | ); |
| 1684 | 1771 | } |
| 1685 | 1772 | $_SESSION['search_cache']['num_results'] += count($inserts); |
| 1773 | + } else { |
|
| 1774 | + $_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows'](); |
|
| 1686 | 1775 | } |
| 1687 | - else |
|
| 1688 | - $_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows'](); |
|
| 1776 | + } elseif ($_SESSION['search_cache']['num_results'] == -1) { |
|
| 1777 | + $_SESSION['search_cache']['num_results'] = 0; |
|
| 1689 | 1778 | } |
| 1690 | - elseif ($_SESSION['search_cache']['num_results'] == -1) |
|
| 1691 | - $_SESSION['search_cache']['num_results'] = 0; |
|
| 1692 | 1779 | } |
| 1693 | 1780 | } |
| 1694 | 1781 | |
@@ -1758,14 +1845,16 @@ discard block |
||
| 1758 | 1845 | ) |
| 1759 | 1846 | ); |
| 1760 | 1847 | $posters = array(); |
| 1761 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1762 | - $posters[] = $row['id_member']; |
|
| 1848 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1849 | + $posters[] = $row['id_member']; |
|
| 1850 | + } |
|
| 1763 | 1851 | $smcFunc['db_free_result']($request); |
| 1764 | 1852 | |
| 1765 | 1853 | call_integration_hook('integrate_search_message_list', array(&$msg_list, &$posters)); |
| 1766 | 1854 | |
| 1767 | - if (!empty($posters)) |
|
| 1768 | - loadMemberData(array_unique($posters)); |
|
| 1855 | + if (!empty($posters)) { |
|
| 1856 | + loadMemberData(array_unique($posters)); |
|
| 1857 | + } |
|
| 1769 | 1858 | |
| 1770 | 1859 | // Get the messages out for the callback - select enough that it can be made to look just like Display. |
| 1771 | 1860 | $messages_request = $smcFunc['db_query']('', ' |
@@ -1799,8 +1888,9 @@ discard block |
||
| 1799 | 1888 | ); |
| 1800 | 1889 | |
| 1801 | 1890 | // If there are no results that means the things in the cache got deleted, so pretend we have no topics anymore. |
| 1802 | - if ($smcFunc['db_num_rows']($messages_request) == 0) |
|
| 1803 | - $context['topics'] = array(); |
|
| 1891 | + if ($smcFunc['db_num_rows']($messages_request) == 0) { |
|
| 1892 | + $context['topics'] = array(); |
|
| 1893 | + } |
|
| 1804 | 1894 | |
| 1805 | 1895 | // If we want to know who participated in what then load this now. |
| 1806 | 1896 | if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) |
@@ -1818,8 +1908,9 @@ discard block |
||
| 1818 | 1908 | 'limit' => count($participants), |
| 1819 | 1909 | ) |
| 1820 | 1910 | ); |
| 1821 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1822 | - $participants[$row['id_topic']] = true; |
|
| 1911 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1912 | + $participants[$row['id_topic']] = true; |
|
| 1913 | + } |
|
| 1823 | 1914 | $smcFunc['db_free_result']($result); |
| 1824 | 1915 | } |
| 1825 | 1916 | } |
@@ -1828,15 +1919,17 @@ discard block |
||
| 1828 | 1919 | $context['page_index'] = constructPageIndex($scripturl . '?action=search2;params=' . $context['params'], $_REQUEST['start'], $num_results, $modSettings['search_results_per_page'], false); |
| 1829 | 1920 | |
| 1830 | 1921 | // Consider the search complete! |
| 1831 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 1832 | - cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90); |
|
| 1922 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 1923 | + cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90); |
|
| 1924 | + } |
|
| 1833 | 1925 | |
| 1834 | 1926 | $context['key_words'] = &$searchArray; |
| 1835 | 1927 | |
| 1836 | 1928 | // Setup the default topic icons... for checking they exist and the like! |
| 1837 | 1929 | $context['icon_sources'] = array(); |
| 1838 | - foreach ($context['stable_icons'] as $icon) |
|
| 1839 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 1930 | + foreach ($context['stable_icons'] as $icon) { |
|
| 1931 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 1932 | + } |
|
| 1840 | 1933 | |
| 1841 | 1934 | $context['sub_template'] = 'results'; |
| 1842 | 1935 | $context['page_title'] = $txt['search_results']; |
@@ -1867,26 +1960,31 @@ discard block |
||
| 1867 | 1960 | global $boards_can, $participants, $smcFunc; |
| 1868 | 1961 | static $recycle_board = null; |
| 1869 | 1962 | |
| 1870 | - if ($recycle_board === null) |
|
| 1871 | - $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
|
| 1963 | + if ($recycle_board === null) { |
|
| 1964 | + $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
|
| 1965 | + } |
|
| 1872 | 1966 | |
| 1873 | 1967 | // Remember which message this is. (ie. reply #83) |
| 1874 | 1968 | static $counter = null; |
| 1875 | - if ($counter == null || $reset) |
|
| 1876 | - $counter = $_REQUEST['start'] + 1; |
|
| 1969 | + if ($counter == null || $reset) { |
|
| 1970 | + $counter = $_REQUEST['start'] + 1; |
|
| 1971 | + } |
|
| 1877 | 1972 | |
| 1878 | 1973 | // If the query returned false, bail. |
| 1879 | - if ($messages_request == false) |
|
| 1880 | - return false; |
|
| 1974 | + if ($messages_request == false) { |
|
| 1975 | + return false; |
|
| 1976 | + } |
|
| 1881 | 1977 | |
| 1882 | 1978 | // Start from the beginning... |
| 1883 | - if ($reset) |
|
| 1884 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1979 | + if ($reset) { |
|
| 1980 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1981 | + } |
|
| 1885 | 1982 | |
| 1886 | 1983 | // Attempt to get the next message. |
| 1887 | 1984 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
| 1888 | - if (!$message) |
|
| 1889 | - return false; |
|
| 1985 | + if (!$message) { |
|
| 1986 | + return false; |
|
| 1987 | + } |
|
| 1890 | 1988 | |
| 1891 | 1989 | // Can't have an empty subject can we? |
| 1892 | 1990 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -1925,9 +2023,9 @@ discard block |
||
| 1925 | 2023 | |
| 1926 | 2024 | if ($smcFunc['strlen']($message['body']) > $charLimit) |
| 1927 | 2025 | { |
| 1928 | - if (empty($context['key_words'])) |
|
| 1929 | - $message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>'; |
|
| 1930 | - else |
|
| 2026 | + if (empty($context['key_words'])) { |
|
| 2027 | + $message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>'; |
|
| 2028 | + } else |
|
| 1931 | 2029 | { |
| 1932 | 2030 | $matchString = ''; |
| 1933 | 2031 | $force_partial_word = false; |
@@ -1936,18 +2034,20 @@ discard block |
||
| 1936 | 2034 | $keyword = un_htmlspecialchars($keyword); |
| 1937 | 2035 | $keyword = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', strtr($keyword, array('\\\'' => '\'', '&' => '&'))); |
| 1938 | 2036 | |
| 1939 | - if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0) |
|
| 1940 | - $force_partial_word = true; |
|
| 2037 | + if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0) { |
|
| 2038 | + $force_partial_word = true; |
|
| 2039 | + } |
|
| 1941 | 2040 | $matchString .= strtr(preg_quote($keyword, '/'), array('\*' => '.+?')) . '|'; |
| 1942 | 2041 | } |
| 1943 | 2042 | $matchString = un_htmlspecialchars(substr($matchString, 0, -1)); |
| 1944 | 2043 | |
| 1945 | 2044 | $message['body'] = un_htmlspecialchars(strtr($message['body'], array(' ' => ' ', '<br>' => "\n", '[' => '[', ']' => ']', ':' => ':', '@' => '@'))); |
| 1946 | 2045 | |
| 1947 | - if (empty($modSettings['search_method']) || $force_partial_word) |
|
| 1948 | - preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
| 1949 | - else |
|
| 1950 | - preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
| 2046 | + if (empty($modSettings['search_method']) || $force_partial_word) { |
|
| 2047 | + preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
| 2048 | + } else { |
|
| 2049 | + preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
| 2050 | + } |
|
| 1951 | 2051 | |
| 1952 | 2052 | $message['body'] = ''; |
| 1953 | 2053 | foreach ($matches[0] as $index => $match) |
@@ -1960,8 +2060,7 @@ discard block |
||
| 1960 | 2060 | // Re-fix the international characters. |
| 1961 | 2061 | $message['body'] = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $message['body']); |
| 1962 | 2062 | } |
| 1963 | - } |
|
| 1964 | - else |
|
| 2063 | + } else |
|
| 1965 | 2064 | { |
| 1966 | 2065 | // Run BBC interpreter on the message. |
| 1967 | 2066 | $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
@@ -1980,21 +2079,26 @@ discard block |
||
| 1980 | 2079 | // Sadly, we need to check the icon ain't broke. |
| 1981 | 2080 | if (!empty($modSettings['messageIconChecks_enable'])) |
| 1982 | 2081 | { |
| 1983 | - if (!isset($context['icon_sources'][$message['first_icon']])) |
|
| 1984 | - $context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1985 | - if (!isset($context['icon_sources'][$message['last_icon']])) |
|
| 1986 | - $context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1987 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
| 1988 | - $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1989 | - } |
|
| 1990 | - else |
|
| 2082 | + if (!isset($context['icon_sources'][$message['first_icon']])) { |
|
| 2083 | + $context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 2084 | + } |
|
| 2085 | + if (!isset($context['icon_sources'][$message['last_icon']])) { |
|
| 2086 | + $context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 2087 | + } |
|
| 2088 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
| 2089 | + $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 2090 | + } |
|
| 2091 | + } else |
|
| 1991 | 2092 | { |
| 1992 | - if (!isset($context['icon_sources'][$message['first_icon']])) |
|
| 1993 | - $context['icon_sources'][$message['first_icon']] = 'images_url'; |
|
| 1994 | - if (!isset($context['icon_sources'][$message['last_icon']])) |
|
| 1995 | - $context['icon_sources'][$message['last_icon']] = 'images_url'; |
|
| 1996 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
| 1997 | - $context['icon_sources'][$message['icon']] = 'images_url'; |
|
| 2093 | + if (!isset($context['icon_sources'][$message['first_icon']])) { |
|
| 2094 | + $context['icon_sources'][$message['first_icon']] = 'images_url'; |
|
| 2095 | + } |
|
| 2096 | + if (!isset($context['icon_sources'][$message['last_icon']])) { |
|
| 2097 | + $context['icon_sources'][$message['last_icon']] = 'images_url'; |
|
| 2098 | + } |
|
| 2099 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
| 2100 | + $context['icon_sources'][$message['icon']] = 'images_url'; |
|
| 2101 | + } |
|
| 1998 | 2102 | } |
| 1999 | 2103 | |
| 2000 | 2104 | // Do we have quote tag enabled? |
@@ -2004,12 +2108,14 @@ discard block |
||
| 2004 | 2108 | $colorClass = 'windowbg'; |
| 2005 | 2109 | |
| 2006 | 2110 | // Sticky topics should get a different color, too. |
| 2007 | - if ($message['is_sticky']) |
|
| 2008 | - $colorClass .= ' sticky'; |
|
| 2111 | + if ($message['is_sticky']) { |
|
| 2112 | + $colorClass .= ' sticky'; |
|
| 2113 | + } |
|
| 2009 | 2114 | |
| 2010 | 2115 | // Locked topics get special treatment as well. |
| 2011 | - if ($message['locked']) |
|
| 2012 | - $colorClass .= ' locked'; |
|
| 2116 | + if ($message['locked']) { |
|
| 2117 | + $colorClass .= ' locked'; |
|
| 2118 | + } |
|
| 2013 | 2119 | |
| 2014 | 2120 | $output = array_merge($context['topics'][$message['id_msg']], array( |
| 2015 | 2121 | 'id' => $message['id_topic'], |
@@ -2153,8 +2259,9 @@ discard block |
||
| 2153 | 2259 | |
| 2154 | 2260 | // Load up the search API we are going to use. |
| 2155 | 2261 | $modSettings['search_index'] = empty($modSettings['search_index']) ? 'standard' : $modSettings['search_index']; |
| 2156 | - if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) |
|
| 2157 | - fatal_lang_error('search_api_missing'); |
|
| 2262 | + if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) { |
|
| 2263 | + fatal_lang_error('search_api_missing'); |
|
| 2264 | + } |
|
| 2158 | 2265 | require_once($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php'); |
| 2159 | 2266 | |
| 2160 | 2267 | // Create an instance of the search API and check it is valid for this version of SMF. |
@@ -18,11 +18,12 @@ discard block |
||
| 18 | 18 | global $context, $txt, $scripturl, $modSettings; |
| 19 | 19 | |
| 20 | 20 | // If maintenance has finished tell the user. |
| 21 | - if (!empty($context['maintenance_finished'])) |
|
| 22 | - echo ' |
|
| 21 | + if (!empty($context['maintenance_finished'])) { |
|
| 22 | + echo ' |
|
| 23 | 23 | <div class="infobox"> |
| 24 | 24 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
| 25 | 25 | </div>'; |
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | echo ' |
| 28 | 29 | <div id="manage_maintenance"> |
@@ -107,11 +108,12 @@ discard block |
||
| 107 | 108 | <div id="manage_maintenance">'; |
| 108 | 109 | |
| 109 | 110 | // If maintenance has finished tell the user. |
| 110 | - if (!empty($context['maintenance_finished'])) |
|
| 111 | - echo ' |
|
| 111 | + if (!empty($context['maintenance_finished'])) { |
|
| 112 | + echo ' |
|
| 112 | 113 | <div class="infobox"> |
| 113 | 114 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
| 114 | 115 | </div>'; |
| 116 | + } |
|
| 115 | 117 | |
| 116 | 118 | echo ' |
| 117 | 119 | <div class="cat_bar"> |
@@ -238,11 +240,12 @@ discard block |
||
| 238 | 240 | <div id="manage_maintenance">'; |
| 239 | 241 | |
| 240 | 242 | // If maintenance has finished tell the user. |
| 241 | - if (!empty($context['maintenance_finished'])) |
|
| 242 | - echo ' |
|
| 243 | + if (!empty($context['maintenance_finished'])) { |
|
| 244 | + echo ' |
|
| 243 | 245 | <div class="infobox"> |
| 244 | 246 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
| 245 | 247 | </div>'; |
| 248 | + } |
|
| 246 | 249 | |
| 247 | 250 | echo ' |
| 248 | 251 | <div class="cat_bar"> |
@@ -300,9 +303,10 @@ discard block |
||
| 300 | 303 | <p><a href="#membersLink" onclick="swapMembers();"><img src="', $settings['images_url'], '/selected.png" alt="+" id="membersIcon"></a> <a href="#membersLink" onclick="swapMembers();" id="membersText" style="font-weight: bold;">', $txt['maintain_members_all'], '</a></p> |
| 301 | 304 | <div style="display: none; padding: 3px" id="membersPanel">'; |
| 302 | 305 | |
| 303 | - foreach ($context['membergroups'] as $group) |
|
| 304 | - echo ' |
|
| 306 | + foreach ($context['membergroups'] as $group) { |
|
| 307 | + echo ' |
|
| 305 | 308 | <label for="groups', $group['id'], '"><input type="checkbox" name="groups[', $group['id'], ']" id="groups', $group['id'], '" checked class="input_check"> ', $group['name'], '</label><br>'; |
| 309 | + } |
|
| 306 | 310 | |
| 307 | 311 | echo ' |
| 308 | 312 | </div> |
@@ -346,11 +350,12 @@ discard block |
||
| 346 | 350 | global $scripturl, $txt, $context, $settings, $modSettings; |
| 347 | 351 | |
| 348 | 352 | // If maintenance has finished tell the user. |
| 349 | - if (!empty($context['maintenance_finished'])) |
|
| 350 | - echo ' |
|
| 353 | + if (!empty($context['maintenance_finished'])) { |
|
| 354 | + echo ' |
|
| 351 | 355 | <div class="infobox"> |
| 352 | 356 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
| 353 | 357 | </div>'; |
| 358 | + } |
|
| 354 | 359 | |
| 355 | 360 | // Bit of javascript for showing which boards to prune in an otherwise hidden list. |
| 356 | 361 | echo ' |
@@ -418,19 +423,21 @@ discard block |
||
| 418 | 423 | <ul>'; |
| 419 | 424 | |
| 420 | 425 | // Display a checkbox with every board. |
| 421 | - foreach ($category['boards'] as $board) |
|
| 422 | - echo ' |
|
| 426 | + foreach ($category['boards'] as $board) { |
|
| 427 | + echo ' |
|
| 423 | 428 | <li style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'] * 1.5, 'em;"><label for="boards_', $board['id'], '"><input type="checkbox" name="boards[', $board['id'], ']" id="boards_', $board['id'], '" checked class="input_check">', $board['name'], '</label></li>'; |
| 429 | + } |
|
| 424 | 430 | |
| 425 | 431 | echo ' |
| 426 | 432 | </ul> |
| 427 | 433 | </fieldset>'; |
| 428 | 434 | |
| 429 | 435 | // Increase $i, and check if we're at the middle yet. |
| 430 | - if (++$i == $middle) |
|
| 431 | - echo ' |
|
| 436 | + if (++$i == $middle) { |
|
| 437 | + echo ' |
|
| 432 | 438 | </div> |
| 433 | 439 | <div class="floatright" style="width: 49%;">'; |
| 440 | + } |
|
| 434 | 441 | } |
| 435 | 442 | |
| 436 | 443 | echo ' |
@@ -469,9 +476,10 @@ discard block |
||
| 469 | 476 | echo ' |
| 470 | 477 | <optgroup label="', $category['name'], '">'; |
| 471 | 478 | |
| 472 | - foreach ($category['boards'] as $board) |
|
| 473 | - echo ' |
|
| 479 | + foreach ($category['boards'] as $board) { |
|
| 480 | + echo ' |
|
| 474 | 481 | <option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=> ', $board['name'], '</option>'; |
| 482 | + } |
|
| 475 | 483 | |
| 476 | 484 | echo ' |
| 477 | 485 | </optgroup>'; |
@@ -489,9 +497,10 @@ discard block |
||
| 489 | 497 | echo ' |
| 490 | 498 | <optgroup label="', $category['name'], '">'; |
| 491 | 499 | |
| 492 | - foreach ($category['boards'] as $board) |
|
| 493 | - echo ' |
|
| 500 | + foreach ($category['boards'] as $board) { |
|
| 501 | + echo ' |
|
| 494 | 502 | <option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=> ', $board['name'], '</option>'; |
| 503 | + } |
|
| 495 | 504 | |
| 496 | 505 | echo ' |
| 497 | 506 | </optgroup>'; |
@@ -531,9 +540,10 @@ discard block |
||
| 531 | 540 | ', $txt['database_optimize_attempt'], '<br>'; |
| 532 | 541 | |
| 533 | 542 | // List each table being optimized... |
| 534 | - foreach ($context['optimized_tables'] as $table) |
|
| 535 | - echo ' |
|
| 543 | + foreach ($context['optimized_tables'] as $table) { |
|
| 544 | + echo ' |
|
| 536 | 545 | ', sprintf($txt['database_optimizing'], $table['name'], $table['data_freed']), '<br>'; |
| 546 | + } |
|
| 537 | 547 | |
| 538 | 548 | // How did we go? |
| 539 | 549 | echo ' |
@@ -590,13 +600,14 @@ discard block |
||
| 590 | 600 | ', implode('</li><li>', $context['exceeding_messages']), ' |
| 591 | 601 | </li> |
| 592 | 602 | </ul>'; |
| 593 | - if (!empty($context['exceeding_messages_morethan'])) |
|
| 594 | - echo ' |
|
| 603 | + if (!empty($context['exceeding_messages_morethan'])) { |
|
| 604 | + echo ' |
|
| 595 | 605 | <p>', $context['exceeding_messages_morethan'], '</p>'; |
| 596 | - } |
|
| 597 | - else |
|
| 598 | - echo ' |
|
| 606 | + } |
|
| 607 | + } else { |
|
| 608 | + echo ' |
|
| 599 | 609 | <p class="infobox">', $txt['convert_to_text'], '</p>'; |
| 610 | + } |
|
| 600 | 611 | |
| 601 | 612 | echo ' |
| 602 | 613 | <form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertmsgbody" method="post" accept-charset="', $context['character_set'], '"> |
@@ -29,9 +29,10 @@ discard block |
||
| 29 | 29 | // Go through each type of report they can run. |
| 30 | 30 | foreach ($context['report_types'] as $type) |
| 31 | 31 | { |
| 32 | - if (isset($type['description'])) |
|
| 33 | - echo ' |
|
| 32 | + if (isset($type['description'])) { |
|
| 33 | + echo ' |
|
| 34 | 34 | <dt>', $type['description'], '</dt>'; |
| 35 | + } |
|
| 35 | 36 | echo ' |
| 36 | 37 | <dd> |
| 37 | 38 | <input type="radio" id="rt_', $type['id'], '" name="rt" value="', $type['id'], '"', $type['is_first'] ? ' checked' : '', ' class="input_radio"> |
@@ -61,8 +62,9 @@ discard block |
||
| 61 | 62 | </div> |
| 62 | 63 | <div id="report_buttons">'; |
| 63 | 64 | |
| 64 | - if (!empty($context['report_buttons'])) |
|
| 65 | - template_button_strip($context['report_buttons'], 'right'); |
|
| 65 | + if (!empty($context['report_buttons'])) { |
|
| 66 | + template_button_strip($context['report_buttons'], 'right'); |
|
| 67 | + } |
|
| 66 | 68 | |
| 67 | 69 | echo ' |
| 68 | 70 | </div>'; |
@@ -73,25 +75,27 @@ discard block |
||
| 73 | 75 | echo ' |
| 74 | 76 | <table class="table_grid report_results">'; |
| 75 | 77 | |
| 76 | - if (!empty($table['title'])) |
|
| 77 | - echo ' |
|
| 78 | + if (!empty($table['title'])) { |
|
| 79 | + echo ' |
|
| 78 | 80 | <thead> |
| 79 | 81 | <tr class="title_bar"> |
| 80 | 82 | <th scope="col" colspan="', $table['column_count'], '">', $table['title'], '</th> |
| 81 | 83 | </tr> |
| 82 | 84 | </thead> |
| 83 | 85 | <tbody>'; |
| 86 | + } |
|
| 84 | 87 | |
| 85 | 88 | // Now do each row! |
| 86 | 89 | $row_number = 0; |
| 87 | 90 | foreach ($table['data'] as $row) |
| 88 | 91 | { |
| 89 | - if ($row_number == 0 && !empty($table['shading']['top'])) |
|
| 90 | - echo ' |
|
| 92 | + if ($row_number == 0 && !empty($table['shading']['top'])) { |
|
| 93 | + echo ' |
|
| 91 | 94 | <tr class="windowbg table_caption">'; |
| 92 | - else |
|
| 93 | - echo ' |
|
| 95 | + } else { |
|
| 96 | + echo ' |
|
| 94 | 97 | <tr class="', !empty($row[0]['separator']) ? 'title_bar' : 'windowbg', '">'; |
| 98 | + } |
|
| 95 | 99 | |
| 96 | 100 | // Now do each column. |
| 97 | 101 | $column_number = 0; |
@@ -109,16 +113,17 @@ discard block |
||
| 109 | 113 | } |
| 110 | 114 | |
| 111 | 115 | // Shaded? |
| 112 | - if ($column_number == 0 && !empty($table['shading']['left'])) |
|
| 113 | - echo ' |
|
| 116 | + if ($column_number == 0 && !empty($table['shading']['left'])) { |
|
| 117 | + echo ' |
|
| 114 | 118 | <td class="table_caption ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '> |
| 115 | 119 | ', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), ' |
| 116 | 120 | </td>'; |
| 117 | - else |
|
| 118 | - echo ' |
|
| 121 | + } else { |
|
| 122 | + echo ' |
|
| 119 | 123 | <td class="smalltext centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '> |
| 120 | 124 | ', $data['v'], ' |
| 121 | 125 | </td>'; |
| 126 | + } |
|
| 122 | 127 | |
| 123 | 128 | $column_number++; |
| 124 | 129 | } |
@@ -167,24 +172,26 @@ discard block |
||
| 167 | 172 | <div style="overflow: visible;', $table['max_width'] != 'auto' ? ' width: ' . $table['max_width'] . 'px;' : '', '"> |
| 168 | 173 | <table class="bordercolor">'; |
| 169 | 174 | |
| 170 | - if (!empty($table['title'])) |
|
| 171 | - echo ' |
|
| 175 | + if (!empty($table['title'])) { |
|
| 176 | + echo ' |
|
| 172 | 177 | <tr class="title_bar"> |
| 173 | 178 | <td colspan="', $table['column_count'], '"> |
| 174 | 179 | ', $table['title'], ' |
| 175 | 180 | </td> |
| 176 | 181 | </tr>'; |
| 182 | + } |
|
| 177 | 183 | |
| 178 | 184 | // Now do each row! |
| 179 | 185 | $row_number = 0; |
| 180 | 186 | foreach ($table['data'] as $row) |
| 181 | 187 | { |
| 182 | - if ($row_number == 0 && !empty($table['shading']['top'])) |
|
| 183 | - echo ' |
|
| 188 | + if ($row_number == 0 && !empty($table['shading']['top'])) { |
|
| 189 | + echo ' |
|
| 184 | 190 | <tr class="titlebg">'; |
| 185 | - else |
|
| 186 | - echo ' |
|
| 191 | + } else { |
|
| 192 | + echo ' |
|
| 187 | 193 | <tr class="windowbg">'; |
| 194 | + } |
|
| 188 | 195 | |
| 189 | 196 | // Now do each column!! |
| 190 | 197 | $column_number = 0; |
@@ -201,16 +208,17 @@ discard block |
||
| 201 | 208 | } |
| 202 | 209 | |
| 203 | 210 | // Shaded? |
| 204 | - if ($column_number == 0 && !empty($table['shading']['left'])) |
|
| 205 | - echo ' |
|
| 211 | + if ($column_number == 0 && !empty($table['shading']['left'])) { |
|
| 212 | + echo ' |
|
| 206 | 213 | <td class="titlebg ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '> |
| 207 | 214 | ', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), ' |
| 208 | 215 | </td>'; |
| 209 | - else |
|
| 210 | - echo ' |
|
| 216 | + } else { |
|
| 217 | + echo ' |
|
| 211 | 218 | <td class="centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '> |
| 212 | 219 | ', $data['v'], ' |
| 213 | 220 | </td>'; |
| 221 | + } |
|
| 214 | 222 | |
| 215 | 223 | $column_number++; |
| 216 | 224 | } |
@@ -26,9 +26,10 @@ discard block |
||
| 26 | 26 | <div class="cat_bar"> |
| 27 | 27 | <h3 class="catbg"> |
| 28 | 28 | <span class="floatleft">', $txt['members_list'], '</span>'; |
| 29 | - if (!isset($context['old_search'])) |
|
| 30 | - echo ' |
|
| 29 | + if (!isset($context['old_search'])) { |
|
| 30 | + echo ' |
|
| 31 | 31 | <span class="floatright">', $context['letter_links'], '</span>'; |
| 32 | + } |
|
| 32 | 33 | echo ' |
| 33 | 34 | </h3> |
| 34 | 35 | </div>'; |
@@ -43,19 +44,22 @@ discard block |
||
| 43 | 44 | foreach ($context['columns'] as $key => $column) |
| 44 | 45 | { |
| 45 | 46 | // @TODO maybe find something nicer? |
| 46 | - if ($key == 'email_address' && !$context['can_send_email']) |
|
| 47 | - continue; |
|
| 47 | + if ($key == 'email_address' && !$context['can_send_email']) { |
|
| 48 | + continue; |
|
| 49 | + } |
|
| 48 | 50 | |
| 49 | 51 | // This is a selected column, so underline it or some such. |
| 50 | - if ($column['selected']) |
|
| 51 | - echo ' |
|
| 52 | + if ($column['selected']) { |
|
| 53 | + echo ' |
|
| 52 | 54 | <th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', ' selected" style="width: auto;"' . (isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '') . '> |
| 53 | 55 | <a href="' . $column['href'] . '" rel="nofollow">' . $column['label'] . '</a><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></th>'; |
| 56 | + } |
|
| 54 | 57 | // This is just some column... show the link and be done with it. |
| 55 | - else |
|
| 56 | - echo ' |
|
| 58 | + else { |
|
| 59 | + echo ' |
|
| 57 | 60 | <th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', '"', isset($column['width']) ? ' style="width: ' . $column['width'] . '"' : '', isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '', '> |
| 58 | 61 | ', $column['link'], '</th>'; |
| 62 | + } |
|
| 59 | 63 | } |
| 60 | 64 | echo ' |
| 61 | 65 | </tr> |
@@ -74,9 +78,10 @@ discard block |
||
| 74 | 78 | </td> |
| 75 | 79 | <td class="lefttext">', $member['link'], '</td>'; |
| 76 | 80 | |
| 77 | - if (!isset($context['disabled_fields']['website'])) |
|
| 78 | - echo ' |
|
| 81 | + if (!isset($context['disabled_fields']['website'])) { |
|
| 82 | + echo ' |
|
| 79 | 83 | <td class="centertext website_url">', $member['website']['url'] != '' ? '<a href="' . $member['website']['url'] . '" target="_blank" class="new_win"><span class="generic_icons www" title="' . $member['website']['title'] . '"></span></a>' : '', '</td>'; |
| 84 | + } |
|
| 80 | 85 | |
| 81 | 86 | // Group and date. |
| 82 | 87 | echo ' |
@@ -89,11 +94,12 @@ discard block |
||
| 89 | 94 | <td class="centertext" style="white-space: nowrap; width: 15px">', $member['posts'], '</td> |
| 90 | 95 | <td class="centertext statsbar" style="width: 120px">'; |
| 91 | 96 | |
| 92 | - if (!empty($member['post_percent'])) |
|
| 93 | - echo ' |
|
| 97 | + if (!empty($member['post_percent'])) { |
|
| 98 | + echo ' |
|
| 94 | 99 | <div class="bar" style="width: ', $member['post_percent'] + 4, 'px;"> |
| 95 | 100 | <div style="width: ', $member['post_percent'], 'px;"></div> |
| 96 | 101 | </div>'; |
| 102 | + } |
|
| 97 | 103 | |
| 98 | 104 | echo ' |
| 99 | 105 | </td>'; |
@@ -102,9 +108,10 @@ discard block |
||
| 102 | 108 | // Show custom fields marked to be shown here |
| 103 | 109 | if (!empty($context['custom_profile_fields']['columns'])) |
| 104 | 110 | { |
| 105 | - foreach ($context['custom_profile_fields']['columns'] as $key => $column) |
|
| 106 | - echo ' |
|
| 111 | + foreach ($context['custom_profile_fields']['columns'] as $key => $column) { |
|
| 112 | + echo ' |
|
| 107 | 113 | <td class="righttext">', $member['options'][$key], '</td>'; |
| 114 | + } |
|
| 108 | 115 | } |
| 109 | 116 | |
| 110 | 117 | echo ' |
@@ -112,11 +119,12 @@ discard block |
||
| 112 | 119 | } |
| 113 | 120 | } |
| 114 | 121 | // No members? |
| 115 | - else |
|
| 116 | - echo ' |
|
| 122 | + else { |
|
| 123 | + echo ' |
|
| 117 | 124 | <tr> |
| 118 | 125 | <td colspan="', $context['colspan'], '" class="windowbg">', $txt['search_no_results'], '</td> |
| 119 | 126 | </tr>'; |
| 127 | + } |
|
| 120 | 128 | |
| 121 | 129 | echo ' |
| 122 | 130 | </tbody> |
@@ -129,9 +137,10 @@ discard block |
||
| 129 | 137 | <div class="pagelinks floatleft">', $context['page_index'], '</div>'; |
| 130 | 138 | |
| 131 | 139 | // If it is displaying the result of a search show a "search again" link to edit their criteria. |
| 132 | - if (isset($context['old_search'])) |
|
| 133 | - echo ' |
|
| 140 | + if (isset($context['old_search'])) { |
|
| 141 | + echo ' |
|
| 134 | 142 | <a class="button_link" href="', $scripturl, '?action=mlist;sa=search;search=', $context['old_search_value'], '">', $txt['mlist_search_again'], '</a>'; |
| 143 | + } |
|
| 135 | 144 | echo ' |
| 136 | 145 | </div> |
| 137 | 146 | </div>'; |
@@ -62,16 +62,17 @@ |
||
| 62 | 62 | <div id="error_box" class="errorbox"> |
| 63 | 63 | <ul id="error_list">'; |
| 64 | 64 | |
| 65 | - foreach ($context['post_errors'] as $key => $error) |
|
| 66 | - echo ' |
|
| 65 | + foreach ($context['post_errors'] as $key => $error) { |
|
| 66 | + echo ' |
|
| 67 | 67 | <li id="error_', $key, '" class="error">', $error, '</li>'; |
| 68 | + } |
|
| 68 | 69 | |
| 69 | 70 | echo ' |
| 70 | 71 | </ul>'; |
| 71 | - } |
|
| 72 | - else |
|
| 73 | - echo ' |
|
| 72 | + } else { |
|
| 73 | + echo ' |
|
| 74 | 74 | <div style="display:none" id="error_box" class="errorbox">'; |
| 75 | + } |
|
| 75 | 76 | |
| 76 | 77 | echo ' |
| 77 | 78 | </div>'; |
@@ -20,12 +20,12 @@ |
||
| 20 | 20 | // We completed some tasks? |
| 21 | 21 | if (!empty($context['tasks_were_run'])) |
| 22 | 22 | { |
| 23 | - if (empty($context['scheduled_errors'])) |
|
| 24 | - echo ' |
|
| 23 | + if (empty($context['scheduled_errors'])) { |
|
| 24 | + echo ' |
|
| 25 | 25 | <div class="infobox"> |
| 26 | 26 | ', $txt['scheduled_tasks_were_run'], ' |
| 27 | 27 | </div>'; |
| 28 | - else |
|
| 28 | + } else |
|
| 29 | 29 | { |
| 30 | 30 | echo ' |
| 31 | 31 | <div class="errorbox" id="errors"> |