phpBB

Code Changes

File: search.php

  Unmodified   Added   Modified   Removed
Line 198Line 198
			$sql_author_match = (strpos($author, '*') !== false) ? ' ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($author))) : " = '" . $db->sql_escape(utf8_clean_string($author)) . "'";
}


			$sql_author_match = (strpos($author, '*') !== false) ? ' ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($author))) : " = '" . $db->sql_escape(utf8_clean_string($author)) . "'";
}


		if (!sizeof($author_id_ary))

		if (!count($author_id_ary))

		{
trigger_error('NO_SEARCH_RESULTS');
}

		{
trigger_error('NO_SEARCH_RESULTS');
}

Line 220Line 220
	}

// Which forums should not be searched? Author searches are also carried out in unindexed forums

	}

// Which forums should not be searched? Author searches are also carried out in unindexed forums

	if (empty($keywords) && sizeof($author_id_ary))

	if (empty($keywords) && count($author_id_ary))

	{
$ex_fid_ary = array_keys($auth->acl_getf('!f_read', true));
}

	{
$ex_fid_ary = array_keys($auth->acl_getf('!f_read', true));
}

Line 229Line 229
		$ex_fid_ary = array_unique(array_merge(array_keys($auth->acl_getf('!f_read', true)), array_keys($auth->acl_getf('!f_search', true))));
}


		$ex_fid_ary = array_unique(array_merge(array_keys($auth->acl_getf('!f_read', true)), array_keys($auth->acl_getf('!f_search', true))));
}


	$not_in_fid = (sizeof($ex_fid_ary)) ? 'WHERE ' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . " OR (f.forum_password <> '' AND fa.user_id <> " . (int) $user->data['user_id'] . ')' : "";

	$not_in_fid = (count($ex_fid_ary)) ? 'WHERE ' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . " OR (f.forum_password <> '' AND fa.user_id <> " . (int) $user->data['user_id'] . ')' : "";


$sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.right_id, f.forum_password, f.forum_flags, fa.user_id
FROM ' . FORUMS_TABLE . ' f


$sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.right_id, f.forum_password, f.forum_flags, fa.user_id
FROM ' . FORUMS_TABLE . ' f

Line 256Line 256
			continue;
}


			continue;
}


		if (sizeof($search_forum))

		if (count($search_forum))

		{
if ($search_child)
{

		{
if ($search_child)
{

Line 309Line 309
	{
$correct_query = $search->split_keywords($keywords, $search_terms);
$common_words = $search->get_common_words();

	{
$correct_query = $search->split_keywords($keywords, $search_terms);
$common_words = $search->get_common_words();

		if (!$correct_query || (!$search->get_search_query() && !sizeof($author_id_ary) && !$search_id))

		if (!$correct_query || (!$search->get_search_query() && !count($author_id_ary) && !$search_id))

		{

		{

			$ignored = (sizeof($common_words)) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $common_words)) . '<br />' : '';

			$ignored = (count($common_words)) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $common_words)) . '<br />' : '';

			$word_length = $search->get_word_length();
if ($word_length)
{

			$word_length = $search->get_word_length();
if ($word_length)
{

Line 324Line 324
		}
}


		}
}


	if (!$keywords && sizeof($author_id_ary))

	if (!$keywords && count($author_id_ary))

	{
// if it is an author search we want to show topics by default
$show_results = ($topic_id) ? 'posts' : $request->variable('sr', ($search_id == 'egosearch') ? 'topics' : 'posts');

	{
// if it is an author search we want to show topics by default
$show_results = ($topic_id) ? 'posts' : $request->variable('sr', ($search_id == 'egosearch') ? 'topics' : 'posts');

Line 384Line 384
					WHERE t.topic_moved_id = 0
$last_post_time_sql
AND " . $m_approve_topics_fid_sql . '

					WHERE t.topic_moved_id = 0
$last_post_time_sql
AND " . $m_approve_topics_fid_sql . '

						' . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . '

						' . ((count($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . '

					ORDER BY t.topic_last_post_time DESC';
$field = 'topic_id';
break;

					ORDER BY t.topic_last_post_time DESC';
$field = 'topic_id';
break;

Line 422Line 422
							AND p.topic_id = t.topic_id
$last_post_time
AND $m_approve_posts_fid_sql

							AND p.topic_id = t.topic_id
$last_post_time
AND $m_approve_posts_fid_sql

							" . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "

							" . ((count($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "

							$sql_sort";
$field = 'post_id';
}

							$sql_sort";
$field = 'post_id';
}

Line 435Line 435
							AND p.topic_id = t.topic_id
$last_post_time
AND $m_approve_topics_fid_sql

							AND p.topic_id = t.topic_id
$last_post_time
AND $m_approve_topics_fid_sql

							" . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "

							" . ((count($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "

						$sql_sort";
$field = 'topic_id';
}

						$sql_sort";
$field = 'topic_id';
}

Line 451Line 451

$sql_where = 'AND t.topic_moved_id = 0
AND ' . $m_approve_topics_fid_sql . '


$sql_where = 'AND t.topic_moved_id = 0
AND ' . $m_approve_topics_fid_sql . '

					' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');

					' . ((count($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');


gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
$s_sort_key = $s_sort_dir = $u_sort_param = $s_limit_days = '';


gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
$s_sort_key = $s_sort_dir = $u_sort_param = $s_limit_days = '';

Line 477Line 477
						FROM ' . POSTS_TABLE . ' p
WHERE p.post_time > ' . $user->data['user_lastvisit'] . '
AND ' . $m_approve_posts_fid_sql . '

						FROM ' . POSTS_TABLE . ' p
WHERE p.post_time > ' . $user->data['user_lastvisit'] . '
AND ' . $m_approve_posts_fid_sql . '

							' . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "

							' . ((count($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "

						$sql_sort";
$field = 'post_id';
}

						$sql_sort";
$field = 'post_id';
}

Line 488Line 488
						WHERE t.topic_last_post_time > ' . $user->data['user_lastvisit'] . '
AND t.topic_moved_id = 0
AND ' . $m_approve_topics_fid_sql . '

						WHERE t.topic_last_post_time > ' . $user->data['user_lastvisit'] . '
AND t.topic_moved_id = 0
AND ' . $m_approve_topics_fid_sql . '

							' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . "

							' . ((count($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . "

						$sql_sort";
/*
[Fix] queued replies missing from "view new posts" (Bug #42705 - Patch by Paul)

						$sql_sort";
/*
[Fix] queued replies missing from "view new posts" (Bug #42705 - Patch by Paul)

Line 562Line 562
			$search_id = '';
}


			$search_id = '';
}


		$total_match_count = sizeof($id_ary);

		$total_match_count = count($id_ary);

		if ($total_match_count)
{
// Limit the number to $total_matches_limit for pre-made searches

		if ($total_match_count)
{
// Limit the number to $total_matches_limit for pre-made searches

Line 592Line 592
	{
$total_match_count = $search->keyword_search($show_results, $search_fields, $search_terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_posts_fid_sql, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page);
}

	{
$total_match_count = $search->keyword_search($show_results, $search_fields, $search_terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_posts_fid_sql, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page);
}

	else if (sizeof($author_id_ary))

	else if (count($author_id_ary))

	{
$firstpost_only = ($search_fields === 'firstpost' || $search_fields == 'titleonly') ? true : false;
$total_match_count = $search->author_search($show_results, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_posts_fid_sql, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page);

	{
$firstpost_only = ($search_fields === 'firstpost' || $search_fields == 'titleonly') ? true : false;
$total_match_count = $search->author_search($show_results, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_posts_fid_sql, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page);

Line 642Line 642

$sql_where = '';



$sql_where = '';


	if (sizeof($id_ary))

	if (count($id_ary))

	{
$sql_where .= $db->sql_in_set(($show_results == 'posts') ? 'p.post_id' : 't.topic_id', $id_ary);

	{
$sql_where .= $db->sql_in_set(($show_results == 'posts') ? 'p.post_id' : 't.topic_id', $id_ary);

		$sql_where .= (sizeof($ex_fid_ary)) ? ' AND (' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . ' OR f.forum_id IS NULL)' : '';

		$sql_where .= (count($ex_fid_ary)) ? ' AND (' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . ' OR f.forum_id IS NULL)' : '';

		$sql_where .= ' AND ' . (($show_results == 'posts') ? $m_approve_posts_fid_sql : $m_approve_topics_fid_sql);
}


		$sql_where .= ' AND ' . (($show_results == 'posts') ? $m_approve_posts_fid_sql : $m_approve_topics_fid_sql);
}


Line 883Line 883
			$db->sql_freeresult($result);

// If we have some shadow topics, update the rowset to reflect their topic information

			$db->sql_freeresult($result);

// If we have some shadow topics, update the rowset to reflect their topic information

			if (sizeof($shadow_topic_list))

			if (count($shadow_topic_list))

			{
$sql = 'SELECT *
FROM ' . TOPICS_TABLE . '

			{
$sql = 'SELECT *
FROM ' . TOPICS_TABLE . '

Line 932Line 932

while ($row = $db->sql_fetchrow($result))
{


while ($row = $db->sql_fetchrow($result))
{

 
				/**
* Modify the row of a post result before the post_text is trimmed
*
* @event core.search_modify_post_row
* @var string hilit String to highlight
* @var array row Array with the post data
* @var string u_hilit Highlight string to be injected into URL
* @var string view Search results view mode
* @var array zebra Array with zebra data for the current user
* @since 3.2.2-RC1
*/
$vars = array(
'hilit',
'row',
'u_hilit',
'view',
'zebra',
);
extract($phpbb_dispatcher->trigger_event('core.search_modify_post_row', compact($vars)));


				// We pre-process some variables here for later usage
$row['post_text'] = censor_text($row['post_text']);


				// We pre-process some variables here for later usage
$row['post_text'] = censor_text($row['post_text']);


Line 967Line 987
			unset($text_only_message);

// Pull attachment data

			unset($text_only_message);

// Pull attachment data

			if (sizeof($attach_list))

			if (count($attach_list))

			{
$use_attach_list = $attach_list;
$attach_list = array();

			{
$use_attach_list = $attach_list;
$attach_list = array();

Line 981Line 1001
				}
}


				}
}


			if (sizeof($attach_list))

			if (count($attach_list))

			{
$sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . '

			{
$sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . '