From 16de03b2141077e9b858a252aa6924d7c13dcc8b Mon Sep 17 00:00:00 2001 From: Exile Date: Sun, 31 Aug 2014 22:14:41 +0400 Subject: [PATCH] Autocorrect layout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Опциональная корректировка раскладки клаваатуры в поиске. По умолчанию включено. --- upload/config.php | 3 ++- upload/search.php | 17 ++++++++++++----- upload/tracker.php | 13 ++++++++++--- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/upload/config.php b/upload/config.php index 1c329fb8b..3353558ca 100644 --- a/upload/config.php +++ b/upload/config.php @@ -484,7 +484,8 @@ $bb_cfg['max_search_words_per_post'] = 200; $bb_cfg['search_min_word_len'] = 3; $bb_cfg['search_max_word_len'] = 35; $bb_cfg['limit_max_search_results'] = false; -$bb_cfg['spam_filter_file_path'] = ''; //BB_PATH .'/misc/spam_filter_words.txt'; +$bb_cfg['spam_filter_file_path'] = ''; // BB_PATH .'/misc/spam_filter_words.txt'; +$bb_cfg['autocorrect_wkl'] = true; // autocorrect wrong keyboard layout // Posting $bb_cfg['prevent_multiposting'] = true; // replace "reply" with "edit last msg" if user (not admin or mod) is last topic poster diff --git a/upload/search.php b/upload/search.php index 79e1c4d3f..5bf7ae786 100644 --- a/upload/search.php +++ b/upload/search.php @@ -430,11 +430,18 @@ if (!$items_found) // Search words if ($var =& $_REQUEST[$text_match_key]) { - if ($tmp = substr(trim($var), 0, $text_match_max_len)) + if ($tmp = mb_substr(trim($var), 0, $text_match_max_len)) { - // Autocorrect wrong keyboard layout - $tlc = new Text_LangCorrect(); - $title_match_val = $tlc->parse($tlc->parse($tmp, 1), 2); + if ($bb_cfg['autocorrect_wkl']) + { + // Autocorrect wrong keyboard layout + $tlc = new Text_LangCorrect(); + $title_match_val = $tlc->parse($tlc->parse($tmp, 1), 2); + } + else + { + $title_match_val = $tmp; + } $text_match_sql = clean_text_match($title_match_val, $all_words_val, false, true); } } @@ -571,7 +578,7 @@ if ($post_mode) { if (empty($tmp[$post_id])) { - continue; // if post was deleted but still remain in search results + continue; // if post was deleted but still remain in search results } $topic_id = $tmp[$post_id]['topic_id']; $sorted_rows[$topic_id][] = $tmp[$post_id]; diff --git a/upload/tracker.php b/upload/tracker.php index d5b9378b5..5b064a97a 100644 --- a/upload/tracker.php +++ b/upload/tracker.php @@ -461,9 +461,16 @@ if (!$set_default) { if ($tmp = mb_substr(trim($tm), 0, $title_match_max_len)) { - // Autocorrect wrong keyboard layout - $tlc = new Text_LangCorrect(); - $title_match_val = $tlc->parse($tlc->parse($tmp, 1), 2); + if ($bb_cfg['autocorrect_wkl']) + { + // Autocorrect wrong keyboard layout + $tlc = new Text_LangCorrect(); + $title_match_val = $tlc->parse($tlc->parse($tmp, 1), 2); + } + else + { + $title_match_val = $tmp; + } $title_match_sql = clean_text_match($title_match_val, true, false, false); } }