From b063c13d7416e420136fcabd1d58af3cccfe872e Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Thu, 21 Aug 2025 11:08:11 +0300 Subject: [PATCH] Update functions.php --- library/includes/functions.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/library/includes/functions.php b/library/includes/functions.php index 7af41b25d..13860e681 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -1768,13 +1768,23 @@ function clean_text_match($text, $ltrim_star = true, $die_if_empty = false) $text = ' ' . str_compact(ltrim($text, $ltrim_chars)) . ' '; - if ($bb_cfg['search_engine_type'] == 'sphinx') { + if ($bb_cfg['search_engine_type'] == 'manticore') { $text = preg_replace('#(?<=\S)\-#u', ' ', $text); // "1-2-3" -> "1 2 3" - $text = preg_replace('#[^0-9a-zA-Zа-яА-ЯёЁ\-_*|]#u', ' ', $text); // valid characters (except '"' which are separate) - $text = str_replace(['-', '*'], [' -', '* '], $text); // only at the beginning/end of a word + $text = preg_replace('#[^0-9a-zA-Zа-яА-ЯёЁ\-_*|@]#u', ' ', $text); // валидные символы + @ для email поиска + $text = str_replace(['-', '*'], [' -', '* '], $text); $text = preg_replace('#\s*\|\s*#u', '|', $text); // "| " -> "|" $text = preg_replace('#\|+#u', ' | ', $text); // "||" -> "|" - $text = preg_replace('#(?<=\s)[\-*]+\s#u', ' ', $text); // single " - ", " * " + $text = preg_replace('#(?<=\s)[\-*]+\s#u', ' ', $text); // удаление одиночных " - ", " * " + $text = trim($text, ' -|'); + $text = str_compact($text); + $text_match_sql = ($wrap_with_quotes && $text != '') ? '"' . $text . '"' : $text; + } elseif ($bb_cfg['search_engine_type'] == 'sphinx') { + $text = preg_replace('#(?<=\S)\-#u', ' ', $text); + $text = preg_replace('#[^0-9a-zA-Zа-яА-ЯёЁ\-_*|]#u', ' ', $text); + $text = str_replace(['-', '*'], [' -', '* '], $text); + $text = preg_replace('#\s*\|\s*#u', '|', $text); + $text = preg_replace('#\|+#u', ' | ', $text); + $text = preg_replace('#(?<=\s)[\-*]+\s#u', ' ', $text); $text = trim($text, ' -|'); $text = str_compact($text); $text_match_sql = ($wrap_with_quotes && $text != '') ? '"' . $text . '"' : $text;