mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 22:33:55 -07:00
Исправление поиска
Дополнительный коммит с исправлениями.
This commit is contained in:
parent
87aeaf6fed
commit
0c6debb626
7 changed files with 16 additions and 25 deletions
|
@ -483,7 +483,7 @@ $bb_cfg['max_post_length'] = 120000; // bytes
|
||||||
$bb_cfg['use_ajax_posts'] = true;
|
$bb_cfg['use_ajax_posts'] = true;
|
||||||
|
|
||||||
// Search
|
// Search
|
||||||
$bb_cfg['search_engine_type'] = false; // true/false -> sphinx/mysql
|
$bb_cfg['sphinx_enabled'] = false; // if false mysql by default
|
||||||
$bb_cfg['sphinx_topic_titles_host'] = '127.0.0.1';
|
$bb_cfg['sphinx_topic_titles_host'] = '127.0.0.1';
|
||||||
$bb_cfg['sphinx_topic_titles_port'] = 3312;
|
$bb_cfg['sphinx_topic_titles_port'] = 3312;
|
||||||
$bb_cfg['sphinx_config_path'] = realpath("../install/sphinx/sphinx.conf");
|
$bb_cfg['sphinx_config_path'] = realpath("../install/sphinx/sphinx.conf");
|
||||||
|
|
|
@ -424,7 +424,7 @@ function add_search_words ($post_id, $post_message, $topic_title = '', $only_ret
|
||||||
$text = $topic_title .' '. $post_message;
|
$text = $topic_title .' '. $post_message;
|
||||||
$words = ($text) ? extract_search_words($text) : array();
|
$words = ($text) ? extract_search_words($text) : array();
|
||||||
|
|
||||||
if ($only_return_words || $bb_cfg['search_engine_type'] == 'sphinx')
|
if ($only_return_words || $bb_cfg['sphinx_enabled'])
|
||||||
{
|
{
|
||||||
return join("\n", $words);
|
return join("\n", $words);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2179,7 +2179,7 @@ function clean_text_match ($text, $ltrim_star = true, $remove_stopwords = false,
|
||||||
$text = remove_stopwords($text);
|
$text = remove_stopwords($text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($bb_cfg['search_engine_type'] == 'sphinx')
|
if ($bb_cfg['sphinx_enabled'])
|
||||||
{
|
{
|
||||||
$text = preg_replace('#(?<=\S)\-#u', ' ', $text); // "1-2-3" -> "1 2 3"
|
$text = preg_replace('#(?<=\S)\-#u', ' ', $text); // "1-2-3" -> "1 2 3"
|
||||||
$text = preg_replace('#[^0-9a-zA-Zа-яА-ЯёЁ\-_*|]#u', ' ', $text); // допустимые символы (кроме " которые отдельно)
|
$text = preg_replace('#[^0-9a-zA-Zа-яА-ЯёЁ\-_*|]#u', ' ', $text); // допустимые символы (кроме " которые отдельно)
|
||||||
|
@ -2233,17 +2233,15 @@ function log_sphinx_error ($err_type, $err_msg, $query = '')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_title_match_topics ($search)
|
function get_title_match_topics($search)
|
||||||
{
|
{
|
||||||
global $bb_cfg, $sphinx, $userdata, $lang;
|
global $bb_cfg, $sphinx, $userdata, $lang;
|
||||||
|
|
||||||
$where_ids = array();
|
$where_ids = array();
|
||||||
|
$forum_ids = (isset($search['ids']) && is_array($search['ids'])) ? array_diff($search['ids'], array(0 => 0)) : '';
|
||||||
$forum_ids = (isset($search['ids']) && is_array($search['ids'])) ? array_diff($search['ids'], array(0 => 0)) : '';
|
|
||||||
|
|
||||||
$title_match_sql = encode_text_match($search['query']);
|
$title_match_sql = encode_text_match($search['query']);
|
||||||
|
|
||||||
if ($bb_cfg['search_engine_type'])
|
if ($bb_cfg['sphinx_enabled'])
|
||||||
{
|
{
|
||||||
init_sphinx();
|
init_sphinx();
|
||||||
|
|
||||||
|
@ -2258,7 +2256,7 @@ function get_title_match_topics ($search)
|
||||||
{
|
{
|
||||||
$sphinx->SetMatchMode(SPH_MATCH_PHRASE);
|
$sphinx->SetMatchMode(SPH_MATCH_PHRASE);
|
||||||
}
|
}
|
||||||
if ($result = $sphinx->Query($title_match_sql, $where, $userdata['username'] .' ('. CLIENT_IP .')'))
|
if ($result = $sphinx->Query($title_match_sql, $where, $userdata['username'] . ' (' . CLIENT_IP . ')'))
|
||||||
{
|
{
|
||||||
if (!empty($result['matches']))
|
if (!empty($result['matches']))
|
||||||
{
|
{
|
||||||
|
@ -2278,23 +2276,23 @@ function get_title_match_topics ($search)
|
||||||
log_sphinx_error('wrn', $warning, $title_match_sql);
|
log_sphinx_error('wrn', $warning, $title_match_sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif(!$bb_cfg['search_engine_type'])
|
else
|
||||||
{
|
{
|
||||||
$where_forum = ($forum_ids) ? "AND forum_id IN(". join(',', $forum_ids) .")" : '';
|
$where_forum = ($forum_ids) ? "AND forum_id IN(" . join(',', $forum_ids) . ")" : '';
|
||||||
$search_bool_mode = ($bb_cfg['allow_search_in_bool_mode']) ? ' IN BOOLEAN MODE' : '';
|
$search_bool_mode = ($bb_cfg['allow_search_in_bool_mode']) ? ' IN BOOLEAN MODE' : '';
|
||||||
|
|
||||||
if(isset($search['topic_match']))
|
if (isset($search['topic_match']))
|
||||||
{
|
{
|
||||||
$where_id = 'topic_id';
|
$where_id = 'topic_id';
|
||||||
$sql = "SELECT topic_id FROM ". BB_TOPICS ."
|
$sql = "SELECT topic_id FROM " . BB_TOPICS . "
|
||||||
WHERE MATCH (topic_title) AGAINST ('$title_match_sql'$search_bool_mode)
|
WHERE MATCH (topic_title) AGAINST ('$title_match_sql'$search_bool_mode)
|
||||||
$where_forum";
|
$where_forum";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$where_id = 'post_id';
|
$where_id = 'post_id';
|
||||||
$sql = "SELECT p.post_id FROM ". BB_POSTS ." p, ". BB_POSTS_SEARCH ." ps
|
$sql = "SELECT p.post_id FROM " . BB_POSTS . " p, " . BB_POSTS_SEARCH . " ps
|
||||||
WHERE ps.post_id = p.post_id
|
WHERE ps.post_id = p.post_id
|
||||||
AND MATCH (ps.search_words) AGAINST ('$title_match_sql'$search_bool_mode)
|
AND MATCH (ps.search_words) AGAINST ('$title_match_sql'$search_bool_mode)
|
||||||
$where_forum";
|
$where_forum";
|
||||||
}
|
}
|
||||||
|
@ -2304,10 +2302,6 @@ function get_title_match_topics ($search)
|
||||||
$where_ids[] = $row[$where_id];
|
$where_ids[] = $row[$where_id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
bb_die($lang['SEARCH_OFF']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $where_ids;
|
return $where_ids;
|
||||||
}
|
}
|
||||||
|
|
|
@ -742,7 +742,6 @@ $lang['MORE_RELEASES'] = 'Find all releases of the group';
|
||||||
$lang['NOT_A_RELEASE_GROUP'] = 'This group is not a release group';
|
$lang['NOT_A_RELEASE_GROUP'] = 'This group is not a release group';
|
||||||
|
|
||||||
// Search
|
// Search
|
||||||
$lang['SEARCH_OFF'] = 'Search is temporarily disabled';
|
|
||||||
$lang['SEARCH_ERROR'] = 'At the moment, the search engine is not available<br /><br />Try to repeat the request after several seconds';
|
$lang['SEARCH_ERROR'] = 'At the moment, the search engine is not available<br /><br />Try to repeat the request after several seconds';
|
||||||
$lang['SEARCH_HELP_URL'] = 'Search Help';
|
$lang['SEARCH_HELP_URL'] = 'Search Help';
|
||||||
$lang['SEARCH_QUERY'] = 'Search Query';
|
$lang['SEARCH_QUERY'] = 'Search Query';
|
||||||
|
|
|
@ -742,7 +742,6 @@ $lang['MORE_RELEASES'] = 'Найти все релизы группы';
|
||||||
$lang['NOT_A_RELEASE_GROUP'] = 'Эта группа не является релиз группой';
|
$lang['NOT_A_RELEASE_GROUP'] = 'Эта группа не является релиз группой';
|
||||||
|
|
||||||
// Search
|
// Search
|
||||||
$lang['SEARCH_OFF'] = 'Поиск временно отключен';
|
|
||||||
$lang['SEARCH_ERROR'] = 'В данный момент поисковик недоступен<br /><br />Попробуйте повторить запрос через несколько секунд';
|
$lang['SEARCH_ERROR'] = 'В данный момент поисковик недоступен<br /><br />Попробуйте повторить запрос через несколько секунд';
|
||||||
$lang['SEARCH_HELP_URL'] = 'Помощь по поиску';
|
$lang['SEARCH_HELP_URL'] = 'Помощь по поиску';
|
||||||
$lang['SEARCH_QUERY'] = 'Запрос';
|
$lang['SEARCH_QUERY'] = 'Запрос';
|
||||||
|
|
|
@ -742,7 +742,6 @@ $lang['MORE_RELEASES'] = 'Знайти усі релізи групи';
|
||||||
$lang['NOT_A_RELEASE_GROUP'] = 'Ця група не є реліз групою';
|
$lang['NOT_A_RELEASE_GROUP'] = 'Ця група не є реліз групою';
|
||||||
|
|
||||||
// Search
|
// Search
|
||||||
$lang['SEARCH_OFF'] = 'Пошук тимчасово відключений';
|
|
||||||
$lang['SEARCH_ERROR'] = 'У даний момент пошуковик недоступний<br /><br />Спробуйте повторити запит через кілька секунд';
|
$lang['SEARCH_ERROR'] = 'У даний момент пошуковик недоступний<br /><br />Спробуйте повторити запит через кілька секунд';
|
||||||
$lang['SEARCH_HELP_URL'] = 'Допомога по пошуку';
|
$lang['SEARCH_HELP_URL'] = 'Допомога по пошуку';
|
||||||
$lang['SEARCH_QUERY'] = 'Запит';
|
$lang['SEARCH_QUERY'] = 'Запит';
|
||||||
|
|
|
@ -104,7 +104,7 @@ ajax.callback.manage_admin = function(data) {
|
||||||
<td><b>{L_UPDATE}:</b></td>
|
<td><b>{L_UPDATE}:</b></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#" id="update_user_level" onclick="ajax.manage_admin('update_user_level'); return false;">{L_USER_LEVELS}</a>
|
<a href="#" id="update_user_level" onclick="ajax.manage_admin('update_user_level'); return false;">{L_USER_LEVELS}</a>
|
||||||
<!-- IF $bb_cfg['search_engine_type'] == "sphinx" -->, <a href="#" id="indexer" onclick="ajax.manage_admin('indexer'); return false;">{L_INDEXER}</a><!-- ENDIF -->
|
<!-- IF $bb_cfg['sphinx_enabled'] -->, <a href="#" id="indexer" onclick="ajax.manage_admin('indexer'); return false;">{L_INDEXER}</a><!-- ENDIF -->
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue