From 87aeaf6feddca59ee20b6415fc1db08194761518 Mon Sep 17 00:00:00 2001 From: Vitalychez Date: Wed, 28 Jan 2015 15:34:31 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D0=BF=D0=BE=D0=B8?= =?UTF-8?q?=D1=81=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/config.php | 2 +- library/includes/functions.php | 20 +++++++++++--------- search.php | 4 ++-- tracker.php | 2 +- viewforum.php | 2 +- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/library/config.php b/library/config.php index 91000723f..303bb3e58 100644 --- a/library/config.php +++ b/library/config.php @@ -483,7 +483,7 @@ $bb_cfg['max_post_length'] = 120000; // bytes $bb_cfg['use_ajax_posts'] = true; // Search -$bb_cfg['search_engine_type'] = 'mysql'; // none, mysql, sphinx +$bb_cfg['search_engine_type'] = false; // true/false -> sphinx/mysql $bb_cfg['sphinx_topic_titles_host'] = '127.0.0.1'; $bb_cfg['sphinx_topic_titles_port'] = 3312; $bb_cfg['sphinx_config_path'] = realpath("../install/sphinx/sphinx.conf"); diff --git a/library/includes/functions.php b/library/includes/functions.php index c67542dfa..607837419 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -2233,19 +2233,21 @@ function log_sphinx_error ($err_type, $err_msg, $query = '') } } -function get_title_match_topics ($title_match_sql, $forum_ids = array()) +function get_title_match_topics ($search) { - global $bb_cfg, $sphinx, $userdata, $title_match, $lang; - + global $bb_cfg, $sphinx, $userdata, $lang; + $where_ids = array(); - if($forum_ids) $forum_ids = array_diff($forum_ids, array(0 => 0)); - $title_match_sql = encode_text_match($title_match_sql); + + $forum_ids = (isset($search['ids']) && is_array($search['ids'])) ? array_diff($search['ids'], array(0 => 0)) : ''; + + $title_match_sql = encode_text_match($search['query']); - if ($bb_cfg['search_engine_type'] == 'sphinx') + if ($bb_cfg['search_engine_type']) { init_sphinx(); - $where = ($title_match) ? 'topics' : 'posts'; + $where = (isset($search['topic_match'])) ? 'topics' : 'posts'; $sphinx->SetServer($bb_cfg['sphinx_topic_titles_host'], $bb_cfg['sphinx_topic_titles_port']); if ($forum_ids) @@ -2276,12 +2278,12 @@ function get_title_match_topics ($title_match_sql, $forum_ids = array()) log_sphinx_error('wrn', $warning, $title_match_sql); } } - else if ($bb_cfg['search_engine_type'] == 'mysql') + elseif(!$bb_cfg['search_engine_type']) { $where_forum = ($forum_ids) ? "AND forum_id IN(". join(',', $forum_ids) .")" : ''; $search_bool_mode = ($bb_cfg['allow_search_in_bool_mode']) ? ' IN BOOLEAN MODE' : ''; - if($title_match) + if(isset($search['topic_match'])) { $where_id = 'topic_id'; $sql = "SELECT topic_id FROM ". BB_TOPICS ." diff --git a/search.php b/search.php index d1e3f67d8..9e2e2fba1 100644 --- a/search.php +++ b/search.php @@ -516,7 +516,7 @@ if ($post_mode) if ($text_match_sql) { $search_match_topics_csv = ''; - $title_match_topics = get_title_match_topics($text_match_sql, $forum_selected); + $title_match_topics = get_title_match_topics(array('query' => $text_match_sql, 'ids' => $forum_selected)); if (!$search_match_topics_csv = join(',', $title_match_topics)) { @@ -714,7 +714,7 @@ else if ($text_match_sql) { $search_match_topics_csv = ''; - $title_match_topics = get_title_match_topics($text_match_sql, $forum_selected); + $title_match_topics = get_title_match_topics(array('query' => $text_match_sql, 'ids' => $forum_selected)); if (!$search_match_topics_csv = join(',', $title_match_topics)) { diff --git a/tracker.php b/tracker.php index 7af97ce54..61d592171 100644 --- a/tracker.php +++ b/tracker.php @@ -558,7 +558,7 @@ if ($allowed_forums) if ($title_match) { - $title_match_topics = get_title_match_topics($title_match_sql, $search_in_forums_ary); + $title_match_topics = get_title_match_topics(array('query' => $title_match_val, 'ids' => array(0 => $forum_id))); if (!$search_match_topics_csv = join(',', $title_match_topics)) { diff --git a/viewforum.php b/viewforum.php index 69595b0b7..35efc3bb1 100644 --- a/viewforum.php +++ b/viewforum.php @@ -331,7 +331,7 @@ if ($title_match =& $_REQUEST[$title_match_key]) if ($tmp = mb_substr(trim($title_match), 0, $title_match_max_len)) { $title_match_val = clean_text_match($tmp, true, false, false); - $title_match_topics = get_title_match_topics($title_match_val, array(0 => $forum_id)); + $title_match_topics = get_title_match_topics(array('query' => $title_match_val, 'ids' => array(0 => $forum_id), 'topic_match' => true)); if ($search_match_topics_csv = join(',', $title_match_topics)) {