mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 14:23:57 -07:00
r251
поиск по сообщениям git-svn-id: https://torrentpier2.googlecode.com/svn/trunk@251 a8ac35ab-4ca4-ca47-4c2d-a49a94f06293
This commit is contained in:
parent
9dfa42916a
commit
bd14b5b363
4 changed files with 109 additions and 60 deletions
|
@ -3,8 +3,8 @@ source torrentpier
|
||||||
type = mysql
|
type = mysql
|
||||||
sql_host = localhost
|
sql_host = localhost
|
||||||
sql_user = user
|
sql_user = user
|
||||||
sql_pass = user
|
sql_pass = pass
|
||||||
sql_db = forum
|
sql_db = dbase
|
||||||
sql_query_pre = SET NAMES utf8
|
sql_query_pre = SET NAMES utf8
|
||||||
sql_query_pre = SET CHARACTER_SET_RESULTS=utf8
|
sql_query_pre = SET CHARACTER_SET_RESULTS=utf8
|
||||||
sql_query_pre = SET CHARACTER_SET_CLIENT=utf8
|
sql_query_pre = SET CHARACTER_SET_CLIENT=utf8
|
||||||
|
@ -26,6 +26,35 @@ source topics: torrentpier
|
||||||
sql_query_info = SELECT * FROM bb_topics WHERE topic_id = $id
|
sql_query_info = SELECT * FROM bb_topics WHERE topic_id = $id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
source posts: torrentpier
|
||||||
|
{
|
||||||
|
sql_query = \
|
||||||
|
SELECT pt.post_id, pt.post_text, t.topic_title, t.topic_id, t.forum_id \
|
||||||
|
FROM bb_posts_text pt \
|
||||||
|
LEFT JOIN bb_topics t on pt.post_id = t.topic_first_post_id \
|
||||||
|
WHERE pt.post_id BETWEEN $start AND $end
|
||||||
|
|
||||||
|
sql_query_range = SELECT MIN(post_id), MAX(post_id) FROM bb_posts_text
|
||||||
|
sql_range_step = 100000
|
||||||
|
|
||||||
|
sql_attr_uint = topic_id
|
||||||
|
sql_attr_uint = forum_id
|
||||||
|
sql_ranged_throttle = 50
|
||||||
|
sql_query_info = SELECT * FROM bb_posts_text WHERE post_id = $id
|
||||||
|
}
|
||||||
|
|
||||||
|
source users: torrentpier
|
||||||
|
{
|
||||||
|
sql_query = \
|
||||||
|
SELECT user_id, username \
|
||||||
|
FROM bb_users \
|
||||||
|
WHERE user_id BETWEEN $start AND $end
|
||||||
|
|
||||||
|
sql_query_range = SELECT (SELECT user_id FROM bb_users WHERE user_id = 1), MAX(user_id) FROM bb_users
|
||||||
|
sql_range_step = 1000
|
||||||
|
sql_query_info = SELECT * FROM bb_users WHERE user_id = $id
|
||||||
|
}
|
||||||
|
|
||||||
index topics
|
index topics
|
||||||
{
|
{
|
||||||
docinfo = extern
|
docinfo = extern
|
||||||
|
@ -41,6 +70,18 @@ index topics
|
||||||
source = topics
|
source = topics
|
||||||
}
|
}
|
||||||
|
|
||||||
|
index posts: topics
|
||||||
|
{
|
||||||
|
path = ./sphinx/data/posts
|
||||||
|
source = posts
|
||||||
|
}
|
||||||
|
|
||||||
|
index users: topics
|
||||||
|
{
|
||||||
|
path = ./sphinx/data/users
|
||||||
|
source = users
|
||||||
|
}
|
||||||
|
|
||||||
indexer
|
indexer
|
||||||
{
|
{
|
||||||
mem_limit = 256M
|
mem_limit = 256M
|
||||||
|
|
|
@ -57,8 +57,8 @@ $bb_cfg['css_ver'] = 1;
|
||||||
|
|
||||||
// Increase number of revision after update
|
// Increase number of revision after update
|
||||||
$bb_cfg['tp_version'] = '2.1 Stable';
|
$bb_cfg['tp_version'] = '2.1 Stable';
|
||||||
$bb_cfg['tp_release_state'] = 'R250';
|
$bb_cfg['tp_release_state'] = 'R251';
|
||||||
$bb_cfg['tp_release_date'] = '23-08-2011';
|
$bb_cfg['tp_release_date'] = '24-08-2011';
|
||||||
|
|
||||||
$bb_cfg['board_disabled_msg'] = 'форум временно отключен'; // 'forums temporarily disabled'; // show this msg if board has been disabled via ON/OFF trigger
|
$bb_cfg['board_disabled_msg'] = 'форум временно отключен'; // 'forums temporarily disabled'; // show this msg if board has been disabled via ON/OFF trigger
|
||||||
$bb_cfg['srv_overloaded_msg'] = "Извините, в данный момент сервер перегружен\nПопробуйте повторить запрос через несколько минут";
|
$bb_cfg['srv_overloaded_msg'] = "Извините, в данный момент сервер перегружен\nПопробуйте повторить запрос через несколько минут";
|
||||||
|
|
|
@ -2608,19 +2608,19 @@ function log_sphinx_error ($err_type, $err_msg, $query = '')
|
||||||
|
|
||||||
function get_title_match_topics ($title_match_sql, $limit = 500, $forum_ids = array())
|
function get_title_match_topics ($title_match_sql, $limit = 500, $forum_ids = array())
|
||||||
{
|
{
|
||||||
global $bb_cfg, $sphinx, $userdata;
|
global $bb_cfg, $sphinx, $userdata, $title_match;
|
||||||
|
|
||||||
$topic_ids = array();
|
$where_ids = array();
|
||||||
$limit = (int) $limit;
|
$limit = (int) $limit;
|
||||||
$forum_ids = (array) $forum_ids;
|
if($forum_ids) $forum_ids = array_diff($forum_ids, array(0 => 0));
|
||||||
$title_match_sql = encode_text_match($title_match_sql);
|
$title_match_sql = encode_text_match($title_match_sql);
|
||||||
|
|
||||||
if ($bb_cfg['search_engine_type'] == 'sphinx')
|
if ($bb_cfg['search_engine_type'] == 'sphinx')
|
||||||
{
|
{
|
||||||
global $user, $title_match; //$title_match - для поиска по постам и топикам (ещё не реализовано)
|
|
||||||
|
|
||||||
init_sphinx();
|
init_sphinx();
|
||||||
|
|
||||||
|
$where = ($title_match) ? 'topics' : 'posts';
|
||||||
|
|
||||||
$sphinx->SetServer($bb_cfg['sphinx_topic_titles_host'], $bb_cfg['sphinx_topic_titles_port']);
|
$sphinx->SetServer($bb_cfg['sphinx_topic_titles_host'], $bb_cfg['sphinx_topic_titles_port']);
|
||||||
$sphinx->SetLimits(0, $limit, $limit, $limit);
|
$sphinx->SetLimits(0, $limit, $limit, $limit);
|
||||||
if ($forum_ids)
|
if ($forum_ids)
|
||||||
|
@ -2631,18 +2631,17 @@ function get_title_match_topics ($title_match_sql, $limit = 500, $forum_ids = ar
|
||||||
{
|
{
|
||||||
$sphinx->SetMatchMode(SPH_MATCH_PHRASE);
|
$sphinx->SetMatchMode(SPH_MATCH_PHRASE);
|
||||||
}
|
}
|
||||||
if ($result = $sphinx->Query($title_match_sql, 'topics', $userdata['username'] .' ('. CLIENT_IP .')'))
|
if ($result = $sphinx->Query($title_match_sql, $where, $userdata['username'] .' ('. CLIENT_IP .')'))
|
||||||
{
|
{
|
||||||
if (!empty($result['matches']))
|
if (!empty($result['matches']))
|
||||||
{
|
{
|
||||||
$topic_ids = array_keys($result['matches']);
|
$where_ids = array_keys($result['matches']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ($error = $sphinx->GetLastError())
|
else if ($error = $sphinx->GetLastError())
|
||||||
{
|
{
|
||||||
if (strpos($error, 'errno=110'))
|
if (strpos($error, 'errno=110'))
|
||||||
{
|
{
|
||||||
bb_log(' ', 'misc/sphinx_conn_err_110');
|
|
||||||
bb_die('В данный момент поисковик недоступен<br /><br />Попробуйте повторить запрос через несколько секунд');
|
bb_die('В данный момент поисковик недоступен<br /><br />Попробуйте повторить запрос через несколько секунд');
|
||||||
}
|
}
|
||||||
log_sphinx_error('ERR', $error, $title_match_sql);
|
log_sphinx_error('ERR', $error, $title_match_sql);
|
||||||
|
@ -2654,18 +2653,30 @@ function get_title_match_topics ($title_match_sql, $limit = 500, $forum_ids = ar
|
||||||
}
|
}
|
||||||
else if ($bb_cfg['search_engine_type'] == 'mysql')
|
else if ($bb_cfg['search_engine_type'] == 'mysql')
|
||||||
{
|
{
|
||||||
$in_forums = ($forum_ids) ? "AND forum_id IN(". join(',', $forum_ids) .")" : '';
|
$where_forum = ($forum_ids) ? "AND forum_id IN(". join(',', $forum_ids) .")" : '';
|
||||||
$sql = "
|
$search_bool_mode = ($bb_cfg['allow_search_in_bool_mode']) ? ' IN BOOLEAN MODE' : '';
|
||||||
SELECT topic_id
|
|
||||||
FROM ". BB_TOPICS ."
|
if($title_match)
|
||||||
WHERE topic_title LIKE '%$title_match_sql%'
|
{
|
||||||
$in_forums
|
$where_id = 'topic_id';
|
||||||
ORDER BY NULL
|
$sql = "SELECT topic_id FROM ". BB_TOPICS ."
|
||||||
LIMIT $limit
|
WHERE MATCH (topic_title) AGAINST ('$title_match_sql'$search_bool_mode)
|
||||||
";
|
$where_forum
|
||||||
|
LIMIT $limit";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$where_id = 'post_id';
|
||||||
|
$sql = "SELECT p.post_id FROM ". BB_POSTS ." p, ". BB_POSTS_SEARCH ." ps
|
||||||
|
WHERE ps.post_id = p.post_id
|
||||||
|
AND MATCH (ps.search_words) AGAINST ('$title_match_sql'$search_bool_mode)
|
||||||
|
$where_forum
|
||||||
|
LIMIT $limit";
|
||||||
|
}
|
||||||
|
|
||||||
foreach (DB()->fetch_rowset($sql) as $row)
|
foreach (DB()->fetch_rowset($sql) as $row)
|
||||||
{
|
{
|
||||||
$topic_ids[] = $row['topic_id'];
|
$where_ids[] = $row[$where_id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2673,7 +2684,7 @@ function get_title_match_topics ($title_match_sql, $limit = 500, $forum_ids = ar
|
||||||
bb_die('Поиск временно отключен');
|
bb_die('Поиск временно отключен');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $topic_ids;
|
return $where_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
// для более корректного поиска по словам содержащим одиночную кавычку
|
// для более корректного поиска по словам содержащим одиночную кавычку
|
||||||
|
|
|
@ -54,7 +54,6 @@ $forums_tbl = BB_FORUMS .' f';
|
||||||
$posts_tbl = BB_POSTS .' p';
|
$posts_tbl = BB_POSTS .' p';
|
||||||
$posts_text_tbl = BB_POSTS_TEXT .' pt';
|
$posts_text_tbl = BB_POSTS_TEXT .' pt';
|
||||||
$posts_html_tbl = BB_POSTS_HTML .' h';
|
$posts_html_tbl = BB_POSTS_HTML .' h';
|
||||||
$search_tbl = BB_POSTS_SEARCH .' ps';
|
|
||||||
$tr_snap_tbl = BB_BT_TRACKER_SNAP .' sn';
|
$tr_snap_tbl = BB_BT_TRACKER_SNAP .' sn';
|
||||||
$topics_tbl = BB_TOPICS .' t';
|
$topics_tbl = BB_TOPICS .' t';
|
||||||
$torrents_tbl = BB_BT_TORRENTS .' tor';
|
$torrents_tbl = BB_BT_TORRENTS .' tor';
|
||||||
|
@ -430,7 +429,6 @@ if ($post_mode)
|
||||||
// FROM
|
// FROM
|
||||||
if ($join_t) $SQL['FROM'][] = $topics_tbl;
|
if ($join_t) $SQL['FROM'][] = $topics_tbl;
|
||||||
if ($join_p) $SQL['FROM'][] = $posts_tbl;
|
if ($join_p) $SQL['FROM'][] = $posts_tbl;
|
||||||
if ($join_s) $SQL['FROM'][] = $search_tbl;
|
|
||||||
|
|
||||||
if (!$SQL['FROM'])
|
if (!$SQL['FROM'])
|
||||||
{
|
{
|
||||||
|
@ -440,7 +438,6 @@ if ($post_mode)
|
||||||
|
|
||||||
// WHERE
|
// WHERE
|
||||||
if ($join_p && $join_t) $SQL['WHERE'][] = "t.topic_id = p.topic_id";
|
if ($join_p && $join_t) $SQL['WHERE'][] = "t.topic_id = p.topic_id";
|
||||||
if ($join_s) $SQL['WHERE'][] = "ps.post_id = p.post_id";
|
|
||||||
|
|
||||||
if ($excluded_forums_csv) $SQL['WHERE'][] = "$tbl.forum_id NOT IN($excluded_forums_csv)";
|
if ($excluded_forums_csv) $SQL['WHERE'][] = "$tbl.forum_id NOT IN($excluded_forums_csv)";
|
||||||
|
|
||||||
|
@ -455,7 +452,6 @@ if ($post_mode)
|
||||||
if ($text_match_sql)
|
if ($text_match_sql)
|
||||||
{
|
{
|
||||||
$search_match_topics_csv = '';
|
$search_match_topics_csv = '';
|
||||||
if(!is_array($forum_selected)) $forum_selected = array();
|
|
||||||
$title_match_topics = get_title_match_topics($text_match_sql, 500, $forum_selected);
|
$title_match_topics = get_title_match_topics($text_match_sql, 500, $forum_selected);
|
||||||
|
|
||||||
if (!$search_match_topics_csv = join(',', $title_match_topics))
|
if (!$search_match_topics_csv = join(',', $title_match_topics))
|
||||||
|
@ -463,7 +459,9 @@ if ($post_mode)
|
||||||
bb_die($lang['NO_SEARCH_MATCH']);
|
bb_die($lang['NO_SEARCH_MATCH']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$SQL['WHERE'][] = "$tbl.topic_id IN($search_match_topics_csv)";
|
$where_id = ($title_match) ? 'topic_id' : 'post_id';
|
||||||
|
|
||||||
|
$SQL['WHERE'][] = "$tbl.$where_id IN($search_match_topics_csv)";
|
||||||
prevent_huge_searches($SQL);
|
prevent_huge_searches($SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -600,7 +598,6 @@ else
|
||||||
|
|
||||||
// FROM
|
// FROM
|
||||||
if ($join_t) $SQL['FROM'][] = $topics_tbl;
|
if ($join_t) $SQL['FROM'][] = $topics_tbl;
|
||||||
if ($join_s) $SQL['FROM'][] = $search_tbl;
|
|
||||||
if ($join_p) $SQL['FROM'][] = $posts_tbl;
|
if ($join_p) $SQL['FROM'][] = $posts_tbl;
|
||||||
|
|
||||||
if (!$SQL['FROM'])
|
if (!$SQL['FROM'])
|
||||||
|
@ -611,7 +608,6 @@ else
|
||||||
|
|
||||||
// WHERE
|
// WHERE
|
||||||
if ($join_p && $join_t) $SQL['WHERE'][] = "t.topic_id = p.topic_id";
|
if ($join_p && $join_t) $SQL['WHERE'][] = "t.topic_id = p.topic_id";
|
||||||
if ($join_s) $SQL['WHERE'][] = "ps.post_id = p.post_id";
|
|
||||||
|
|
||||||
if ($excluded_forums_csv) $SQL['WHERE'][] = "$tbl.forum_id NOT IN($excluded_forums_csv)";
|
if ($excluded_forums_csv) $SQL['WHERE'][] = "$tbl.forum_id NOT IN($excluded_forums_csv)";
|
||||||
|
|
||||||
|
@ -627,7 +623,6 @@ else
|
||||||
if ($text_match_sql)
|
if ($text_match_sql)
|
||||||
{
|
{
|
||||||
$search_match_topics_csv = '';
|
$search_match_topics_csv = '';
|
||||||
if(!is_array($forum_selected)) $forum_selected = array();
|
|
||||||
$title_match_topics = get_title_match_topics($text_match_sql, 500, $forum_selected);
|
$title_match_topics = get_title_match_topics($text_match_sql, 500, $forum_selected);
|
||||||
|
|
||||||
if (!$search_match_topics_csv = join(',', $title_match_topics))
|
if (!$search_match_topics_csv = join(',', $title_match_topics))
|
||||||
|
@ -635,7 +630,9 @@ else
|
||||||
bb_die($lang['NO_SEARCH_MATCH']);
|
bb_die($lang['NO_SEARCH_MATCH']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$SQL['WHERE'][] = "$tbl.topic_id IN($search_match_topics_csv)";
|
$where_id = ($title_match) ? 'topic_id' : 'post_id';
|
||||||
|
|
||||||
|
$SQL['WHERE'][] = "$tbl.$where_id IN($search_match_topics_csv)";
|
||||||
prevent_huge_searches($SQL);
|
prevent_huge_searches($SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue