phpBB

Code Changes

File: search.php

  Unmodified   Added   Modified   Removed
Line 337Line 337
	}

// define some variables needed for retrieving post_id/topic_id information

	}

// define some variables needed for retrieving post_id/topic_id information

	$sort_by_sql = array('a' => 'u.username_clean', 't' => (($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time'), 'f' => 'f.forum_id', 'i' => 't.topic_title', 's' => (($show_results == 'posts') ? 'p.post_subject' : 't.topic_title'));







	$sort_by_sql = [
'a' => 'u.username_clean',
't' => (($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time'),
'f' => 'f.forum_id',
'i' => 't.topic_title',
's' => (($show_results == 'posts') ? 'p.post_subject' : 't.topic_title')
];


/**
* Event to modify the SQL parameters before pre-made searches


/**
* Event to modify the SQL parameters before pre-made searches

Line 403Line 409
				$sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');

$sort_join = ($sort_key == 'f') ? FORUMS_TABLE . ' f, ' : '';

				$sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');

$sort_join = ($sort_key == 'f') ? FORUMS_TABLE . ' f, ' : '';

				$sql_sort = ($sort_key == 'f') ? ' AND f.forum_id = p.forum_id ' . $sql_sort : $sql_sort;

				$sql_sort = ($sort_key == 'f') ? ' AND f.forum_id = t.forum_id ' . $sql_sort : $sql_sort;


if ($sort_days)
{


if ($sort_days)
{

					$last_post_time = 'AND p.post_time > ' . (time() - ($sort_days * 24 * 3600));

					$last_post_time = 'AND ' . ($show_results == 'posts' ? 'p.post_time' : 't.topic_last_post_time') . ' > ' . (time() - ($sort_days * 24 * 3600));

				}
else
{

				}
else
{

Line 417Line 423
				if ($sort_key == 'a')
{
$sort_join = USERS_TABLE . ' u, ';

				if ($sort_key == 'a')
{
$sort_join = USERS_TABLE . ' u, ';

					$sql_sort = ' AND u.user_id = p.poster_id ' . $sql_sort;

					$sql_sort = ' AND u.user_id = ' . ($show_results == 'posts' ? 'p.poster_id ' : 't.topic_last_poster_id ') . $sql_sort;

				}
if ($show_results == 'posts')
{

				}
if ($show_results == 'posts')
{

Line 433Line 439
				}
else
{

				}
else
{

					$sql = 'SELECT DISTINCT ' . $sort_by_sql[$sort_key] . ", p.topic_id
FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t

					$sql = 'SELECT DISTINCT ' . $sort_by_sql[$sort_key] . ", t.topic_id
FROM $sort_join" . TOPICS_TABLE . " t

						WHERE t.topic_posts_approved = 1
AND t.topic_moved_id = 0

						WHERE t.topic_posts_approved = 1
AND t.topic_moved_id = 0

							AND p.topic_id = t.topic_id

 
							$last_post_time
AND $m_approve_topics_fid_sql

							$last_post_time
AND $m_approve_topics_fid_sql

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

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

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

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

Line 678Line 683
	$hilit = phpbb_clean_search_string(str_replace(array('+', '-', '|', '(', ')', '"'), ' ', $keywords));
$hilit = str_replace(' ', '|', $hilit);


	$hilit = phpbb_clean_search_string(str_replace(array('+', '-', '|', '(', ')', '"'), ' ', $keywords));
$hilit = str_replace(' ', '|', $hilit);


	$u_hilit = urlencode(htmlspecialchars_decode(str_replace('|', ' ', $hilit)));

	$u_hilit = urlencode(html_entity_decode(str_replace('|', ' ', $hilit), ENT_COMPAT));

	$u_show_results = '&sr=' . $show_results;
$u_search_forum = implode('&fid%5B%5D=', $search_forum);

$u_search = append_sid("{$phpbb_root_path}search.$phpEx", $u_sort_param . $u_show_results);
$u_search .= ($search_id) ? '&search_id=' . $search_id : '';

	$u_show_results = '&sr=' . $show_results;
$u_search_forum = implode('&fid%5B%5D=', $search_forum);

$u_search = append_sid("{$phpbb_root_path}search.$phpEx", $u_sort_param . $u_show_results);
$u_search .= ($search_id) ? '&search_id=' . $search_id : '';

	$u_search .= ($u_hilit) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : '';

	$u_search .= ($u_hilit) ? '&keywords=' . urlencode(html_entity_decode($keywords, ENT_COMPAT)) : '';

	$u_search .= ($search_terms != 'all') ? '&terms=' . $search_terms : '';
$u_search .= ($topic_id) ? '&t=' . $topic_id : '';

	$u_search .= ($search_terms != 'all') ? '&terms=' . $search_terms : '';
$u_search .= ($topic_id) ? '&t=' . $topic_id : '';

	$u_search .= ($author) ? '&author=' . urlencode(htmlspecialchars_decode($author)) : '';

	$u_search .= ($author) ? '&author=' . urlencode(html_entity_decode($author, ENT_COMPAT)) : '';

	$u_search .= ($author_id) ? '&author_id=' . $author_id : '';
$u_search .= ($u_search_forum) ? '&fid%5B%5D=' . $u_search_forum : '';
$u_search .= (!$search_child) ? '&sc=0' : '';

	$u_search .= ($author_id) ? '&author_id=' . $author_id : '';
$u_search .= ($u_search_forum) ? '&fid%5B%5D=' . $u_search_forum : '';
$u_search .= (!$search_child) ? '&sc=0' : '';

Line 1076Line 1081
			$topic_title = censor_text($row['topic_title']);
$replies = $phpbb_content_visibility->get_count('topic_posts', $row, $forum_id) - 1;


			$topic_title = censor_text($row['topic_title']);
$replies = $phpbb_content_visibility->get_count('topic_posts', $row, $forum_id) - 1;


			$view_topic_url_params = "f=$forum_id&t=$result_topic_id" . (($u_hilit) ? "&hilit=$u_hilit" : '');

			$view_topic_url_params = "t=$result_topic_id" . (($u_hilit) ? "&hilit=$u_hilit" : '');

			$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params);

$folder_img = $folder_alt = $u_mcp_queue = '';

			$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params);

$folder_img = $folder_alt = $u_mcp_queue = '';

Line 1139Line 1144
					'S_TOPIC_DELETED'		=> $topic_deleted,
'S_HAS_POLL' => ($row['poll_start']) ? true : false,


					'S_TOPIC_DELETED'		=> $topic_deleted,
'S_HAS_POLL' => ($row['poll_start']) ? true : false,


					'U_LAST_POST'			=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'],

					'U_LAST_POST'			=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'],

					'U_LAST_POST_AUTHOR'	=> get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&view=unread') . '#unread',

					'U_LAST_POST_AUTHOR'	=> get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&view=unread') . '#unread',

Line 1214Line 1219

'U_VIEW_TOPIC' => $view_topic_url,
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),


'U_VIEW_TOPIC' => $view_topic_url,
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),

				'U_VIEW_POST'		=> (!empty($row['post_id'])) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=" . $row['topic_id'] . '&p=' . $row['post_id'] . (($u_hilit) ? '&hilit=' . $u_hilit : '')) . '#p' . $row['post_id'] : '',

				'U_VIEW_POST'		=> (!empty($row['post_id'])) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id'] . (($u_hilit) ? '&hilit=' . $u_hilit : '')) . '#p' . $row['post_id'] : '',

			));

/**

			));

/**

Line 1564Line 1569
			'KEYWORDS'	=> $keywords,
'TIME' => $user->format_date($row['search_time']),


			'KEYWORDS'	=> $keywords,
'TIME' => $user->format_date($row['search_time']),


			'U_KEYWORDS'	=> append_sid("{$phpbb_root_path}search.$phpEx", 'keywords=' . urlencode(htmlspecialchars_decode($keywords)))

			'U_KEYWORDS'	=> append_sid("{$phpbb_root_path}search.$phpEx", 'keywords=' . urlencode(html_entity_decode($keywords, ENT_COMPAT)))

		));
}
$db->sql_freeresult($result);

		));
}
$db->sql_freeresult($result);