\n";
$inf_settings = get_settings('forum');
$sort_by = [
'datestamp' => "post_datestamp",
'subject' => "thread_subject",
'author' => "post_author",
];
$order_by = [
'0' => ' DESC',
'1' => ' ASC',
];
$sortby = !empty(Search_Engine::get_param('sort')) ? "ORDER BY ".$sort_by[Search_Engine::get_param('sort')].$order_by[Search_Engine::get_param('order')] : '';
$limit = (Search_Engine::get_param('stype') != "all" ? " LIMIT ".Search_Engine::get_param('rowstart').",10" : '');
$date_search = (Search_Engine::get_param('datelimit') != 0 ? ' AND post_datestamp >='.(TIME - Search_Engine::get_param('datelimit')) : '');
switch (Search_Engine::get_param('fields')) {
case 2:
Search_Engine::search_column('thread_subject', 'forum');
Search_Engine::search_column('post_message', 'forum');
Search_Engine::search_column('forum_name', 'forum');
break;
case 1:
Search_Engine::search_column('post_message', 'forum');
Search_Engine::search_column('forum_description', 'forum');
break;
default:
Search_Engine::search_column('thread_subject', 'forum');
}
if (!empty(Search_Engine::get_param('search_param'))) {
/*
* Group by the thread. We don't need about 100 results of the same thread.
*/
$query = "
SELECT tp.forum_id, tp.thread_id, tp.post_id, tp.post_message, tt.thread_subject, tf.forum_access, tf.forum_name, tf.forum_description
FROM ".DB_FORUM_POSTS." tp
LEFT JOIN ".DB_FORUMS." tf ON tf.forum_id = tp.forum_id
LEFT JOIN ".DB_FORUM_THREADS." tt ON tt.thread_id = tp.thread_id
".(multilang_table("FR") ? "WHERE ".in_group('tf.forum_language', LANGUAGE)." AND " : "WHERE ").groupaccess('forum_access')
.(Search_Engine::get_param('forum_id') != 0 ? " AND tf.forum_id=".Search_Engine::get_param('forum_id') : "")."
AND ".Search_Engine::search_conditions('forum')." GROUP BY tt.thread_id ".$date_search;
$result = dbquery($query, Search_Engine::get_param('search_param'));
$rows = dbrows($result);
} else {
$rows = 0;
}
if ($rows != 0) {
$item_count = "".$rows." ".($rows == 1 ? $locale['f402'] : $locale['f403'])." ".$locale['522']."
\n";
// Change from forum post to forum thread searching.
$query = "
SELECT tp.forum_id, tp.thread_id, tp.post_id, tp.post_message, tp.post_datestamp, tt.thread_subject, tt.thread_postcount,
tt.thread_sticky, tf.forum_access, tu.user_id, tu.user_name, tu.user_status, tu.user_avatar
FROM ".DB_FORUM_POSTS." tp
LEFT JOIN ".DB_FORUM_THREADS." tt ON tp.thread_id = tt.thread_id
LEFT JOIN ".DB_FORUMS." tf ON tp.forum_id = tf.forum_id
LEFT JOIN ".DB_USERS." tu ON tp.post_author=tu.user_id
".(multilang_table("FR") ? "WHERE ".in_group('tf.forum_language', LANGUAGE)." AND " : "WHERE ").groupaccess('forum_access').
(Search_Engine::get_param('forum_id') != 0 ? " AND tf.forum_id=".Search_Engine::get_param('forum_id') : '')."
AND ".Search_Engine::search_conditions('forum')." GROUP BY tt.thread_id ".$date_search.$sortby.$limit;
$result = dbquery($query, Search_Engine::get_param('search_param'));
$search_result = '';
while ($data = dbarray($result)) {
$text_all = Search_Engine::search_striphtmlbbcodes(iADMIN ? $data['post_message'] : preg_replace("#\[hide\](.*)\[/hide\]#si", '', $data['post_message']));
$text_frag = Search_Engine::search_textfrag($text_all);
$subj_c = Search_Engine::search_stringscount($data['thread_subject']);
$text_c = Search_Engine::search_stringscount($data['post_message']);;
$context = "