mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-06 07:35:29 +02:00
- view active topics
- seperated search id (int) from search id (string) for security reasons git-svn-id: file:///svn/phpbb/trunk@5161 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
2ca7293a68
commit
2e4ea58d28
@ -1956,9 +1956,11 @@ function page_header($page_title = '')
|
|||||||
'U_SEARCH_SELF' => "{$phpbb_root_path}search.$phpEx$SID&search_id=egosearch",
|
'U_SEARCH_SELF' => "{$phpbb_root_path}search.$phpEx$SID&search_id=egosearch",
|
||||||
'U_SEARCH_NEW' => "{$phpbb_root_path}search.$phpEx$SID&search_id=newposts",
|
'U_SEARCH_NEW' => "{$phpbb_root_path}search.$phpEx$SID&search_id=newposts",
|
||||||
'U_SEARCH_UNANSWERED' => "{$phpbb_root_path}search.$phpEx$SID&search_id=unanswered",
|
'U_SEARCH_UNANSWERED' => "{$phpbb_root_path}search.$phpEx$SID&search_id=unanswered",
|
||||||
|
'U_SEARCH_ACTIVE_TOPICS'=> "{$phpbb_root_path}search.$phpEx$SID&search_id=active_topics",
|
||||||
'U_DELETE_COOKIES' => "{$phpbb_root_path}ucp.$phpEx$SID&mode=delete_cookies",
|
'U_DELETE_COOKIES' => "{$phpbb_root_path}ucp.$phpEx$SID&mode=delete_cookies",
|
||||||
|
|
||||||
'S_USER_LOGGED_IN' => ($user->data['user_id'] != ANONYMOUS) ? true : false,
|
'S_USER_LOGGED_IN' => ($user->data['user_id'] != ANONYMOUS) ? true : false,
|
||||||
|
'S_REGISTERED_USER' => $user->data['is_registered'],
|
||||||
'S_USER_PM_POPUP' => $user->optionget('popuppm'),
|
'S_USER_PM_POPUP' => $user->optionget('popuppm'),
|
||||||
'S_USER_LANG' => $user->data['user_lang'],
|
'S_USER_LANG' => $user->data['user_lang'],
|
||||||
'S_USER_BROWSER' => (isset($user->data['session_browser'])) ? $user->data['session_browser'] : $user->lang['UNKNOWN_BROWSER'],
|
'S_USER_BROWSER' => (isset($user->data['session_browser'])) ? $user->data['session_browser'] : $user->lang['UNKNOWN_BROWSER'],
|
||||||
|
@ -333,6 +333,7 @@ $lang += array(
|
|||||||
'SEARCH' => 'Search',
|
'SEARCH' => 'Search',
|
||||||
'SEARCHING_FORUMS' => 'Searching forums',
|
'SEARCHING_FORUMS' => 'Searching forums',
|
||||||
'SELECT_DESTINATION_FORUM' => 'Please select a forum for destination',
|
'SELECT_DESTINATION_FORUM' => 'Please select a forum for destination',
|
||||||
|
'SEARCH_ACTIVE_TOPICS' => 'View active topics',
|
||||||
'SEARCH_FOR' => 'Search for',
|
'SEARCH_FOR' => 'Search for',
|
||||||
'SEARCH_NEW' => 'View new posts',
|
'SEARCH_NEW' => 'View new posts',
|
||||||
'SEARCH_SELF' => 'View your posts',
|
'SEARCH_SELF' => 'View your posts',
|
||||||
|
362
phpBB/search.php
362
phpBB/search.php
@ -27,6 +27,7 @@ $user->setup('search');
|
|||||||
// Define initial vars
|
// Define initial vars
|
||||||
$mode = request_var('mode', '');
|
$mode = request_var('mode', '');
|
||||||
$search_id = request_var('search_id', '');
|
$search_id = request_var('search_id', '');
|
||||||
|
$search_session_id = request_var('search_session_id', 0);
|
||||||
$start = request_var('start', 0);
|
$start = request_var('start', 0);
|
||||||
$post_id = request_var('p', 0);
|
$post_id = request_var('p', 0);
|
||||||
$view = request_var('view', '');
|
$view = request_var('view', '');
|
||||||
@ -77,7 +78,7 @@ if ($config['search_interval'])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($search_keywords || $search_author || $search_id)
|
if ($search_keywords || $search_author || $search_id || $search_session_id)
|
||||||
{
|
{
|
||||||
$post_id_ary = $split_words = $old_split_words = $common_words = array();
|
$post_id_ary = $split_words = $old_split_words = $common_words = array();
|
||||||
|
|
||||||
@ -156,6 +157,33 @@ if ($search_keywords || $search_author || $search_id)
|
|||||||
|
|
||||||
switch ($search_id)
|
switch ($search_id)
|
||||||
{
|
{
|
||||||
|
// Oh holy Bob, bring us some activity...
|
||||||
|
case 'active_topics':
|
||||||
|
$show_results = 'topics';
|
||||||
|
|
||||||
|
if (!$sort_days)
|
||||||
|
{
|
||||||
|
$sort_days = 1;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
$last_post_time = (time() - ($sort_days * 24 * 3600));
|
||||||
|
|
||||||
|
$sql = 'SELECT DISTINCT t.topic_id
|
||||||
|
FROM ' . POSTS_TABLE . ' p
|
||||||
|
LEFT JOIN ' . TOPICS_TABLE . " t ON (t.topic_approved = 1 AND p.topic_id = t.topic_id)
|
||||||
|
WHERE p.post_time > $last_post_time
|
||||||
|
$sql_forums
|
||||||
|
ORDER BY t.topic_last_post_time DESC";
|
||||||
|
$result = $db->sql_query_limit($sql, 1000);
|
||||||
|
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
$post_id_ary[] = $row['topic_id'];
|
||||||
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'egosearch':
|
case 'egosearch':
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -225,39 +253,40 @@ if ($search_keywords || $search_author || $search_id)
|
|||||||
trigger_error($user->lang['NO_SEARCH_RESULTS']);
|
trigger_error($user->lang['NO_SEARCH_RESULTS']);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
$search_id = (int) $search_id;
|
|
||||||
|
|
||||||
$sql = 'SELECT search_array
|
|
||||||
FROM ' . SEARCH_TABLE . "
|
|
||||||
WHERE search_id = $search_id
|
|
||||||
AND session_id = '" . $db->sql_escape($user->data['session_id']) . "'";
|
|
||||||
$result = $db->sql_query($sql);
|
|
||||||
|
|
||||||
if ($row = $db->sql_fetchrow($result))
|
|
||||||
{
|
|
||||||
$data = explode('#', $row['search_array']);
|
|
||||||
|
|
||||||
$split_words = unserialize(array_shift($data));
|
|
||||||
if ($search_keywords)
|
|
||||||
{
|
|
||||||
// If we're wanting to search on these results we store the existing split word array
|
|
||||||
$old_split_words = $split_words;
|
|
||||||
}
|
|
||||||
$stopped_words = unserialize(array_shift($data));
|
|
||||||
foreach ($store_vars as $var)
|
|
||||||
{
|
|
||||||
$$var = array_shift($data);
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql_where = (($show_results == 'posts') ? 'p.post_id' : 't.topic_id') . ' IN (' . implode(', ', $data) . ')';
|
|
||||||
unset($data);
|
|
||||||
}
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($search_session_id)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT search_array
|
||||||
|
FROM ' . SEARCH_TABLE . "
|
||||||
|
WHERE search_id = $search_session_id
|
||||||
|
AND session_id = '" . $db->sql_escape($user->data['session_id']) . "'";
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
if ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
$data = explode('#', $row['search_array']);
|
||||||
|
|
||||||
|
$split_words = unserialize(array_shift($data));
|
||||||
|
if ($search_keywords)
|
||||||
|
{
|
||||||
|
// If we're wanting to search on these results we store the existing split word array
|
||||||
|
$old_split_words = $split_words;
|
||||||
|
}
|
||||||
|
$stopped_words = unserialize(array_shift($data));
|
||||||
|
foreach ($store_vars as $var)
|
||||||
|
{
|
||||||
|
$$var = array_shift($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql_where = (($show_results == 'posts') ? 'p.post_id' : 't.topic_id') . ' IN (' . implode(', ', $data) . ')';
|
||||||
|
unset($data);
|
||||||
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: hook in fulltext_phpbb/mysql
|
||||||
|
|
||||||
// Are we looking for words
|
// Are we looking for words
|
||||||
if ($search_keywords)
|
if ($search_keywords)
|
||||||
@ -541,8 +570,9 @@ if ($search_keywords || $search_author || $search_id)
|
|||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$total_match_count = 0;
|
||||||
|
|
||||||
if ($post_id_ary)
|
if ($post_id_ary && sizeof($post_id_ary))
|
||||||
{
|
{
|
||||||
// Finish building query (for all combinations) and run it ...
|
// Finish building query (for all combinations) and run it ...
|
||||||
$sql = 'SELECT session_id
|
$sql = 'SELECT session_id
|
||||||
@ -580,10 +610,10 @@ if ($search_keywords || $search_author || $search_id)
|
|||||||
unset($post_id_ary);
|
unset($post_id_ary);
|
||||||
|
|
||||||
srand ((double) microtime() * 1000000);
|
srand ((double) microtime() * 1000000);
|
||||||
$search_id = rand();
|
$search_session_id = rand();
|
||||||
|
|
||||||
$sql_ary = array(
|
$sql_ary = array(
|
||||||
'search_id' => $search_id,
|
'search_id' => $search_session_id,
|
||||||
'session_id' => $user->data['session_id'],
|
'session_id' => $user->data['session_id'],
|
||||||
'search_time' => $current_time,
|
'search_time' => $current_time,
|
||||||
'search_array' => $data
|
'search_array' => $data
|
||||||
@ -622,13 +652,14 @@ if ($search_keywords || $search_author || $search_id)
|
|||||||
'SEARCH_MATCHES' => $l_search_matches,
|
'SEARCH_MATCHES' => $l_search_matches,
|
||||||
'SEARCH_WORDS' => $split_words,
|
'SEARCH_WORDS' => $split_words,
|
||||||
'IGNORED_WORDS' => ($ignored_words) ? $ignored_words : '',
|
'IGNORED_WORDS' => ($ignored_words) ? $ignored_words : '',
|
||||||
'PAGINATION' => generate_pagination("search.$phpEx$SID&search_id=$search_id&hilit=$hilit&$u_sort_param", $total_match_count, $per_page, $start),
|
'PAGINATION' => generate_pagination("search.$phpEx$SID&search_session_id=$search_session_id&search_id=$search_id&hilit=$hilit&$u_sort_param", $total_match_count, $per_page, $start),
|
||||||
'PAGE_NUMBER' => on_page($total_match_count, $per_page, $start),
|
'PAGE_NUMBER' => on_page($total_match_count, $per_page, $start),
|
||||||
'TOTAL_MATCHES' => $total_match_count,
|
'TOTAL_MATCHES' => $total_match_count,
|
||||||
|
|
||||||
'S_SELECT_SORT_DIR' => $s_sort_dir,
|
'S_SELECT_SORT_DIR' => $s_sort_dir,
|
||||||
'S_SELECT_SORT_KEY' => $s_sort_key,
|
'S_SELECT_SORT_KEY' => $s_sort_key,
|
||||||
'S_SEARCH_ACTION' => "search.$phpEx$SID&search_id=$search_id",
|
'S_SELECT_SORT_DAYS' => $s_limit_days,
|
||||||
|
'S_SEARCH_ACTION' => "{$phpbb_root_path}search.$phpEx$SID&search_session_id=$search_session_id&search_id=$search_id",
|
||||||
'S_SHOW_TOPICS' => ($show_results == 'posts') ? false : true,
|
'S_SHOW_TOPICS' => ($show_results == 'posts') ? false : true,
|
||||||
|
|
||||||
'REPORTED_IMG' => $user->img('icon_reported', 'TOPIC_REPORTED'),
|
'REPORTED_IMG' => $user->img('icon_reported', 'TOPIC_REPORTED'),
|
||||||
@ -644,145 +675,152 @@ if ($search_keywords || $search_author || $search_id)
|
|||||||
// within an existing search result set
|
// within an existing search result set
|
||||||
$sort_by_sql = array('a' => (($show_results == 'posts') ? 'u.username' : 't.topic_poster'), 't' => (($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time'), 'f' => 'f.forum_id', 'i' => 't.topic_title', 's' => (($show_results == 'posts') ? 'pt.post_subject' : 't.topic_title'));
|
$sort_by_sql = array('a' => (($show_results == 'posts') ? 'u.username' : 't.topic_poster'), 't' => (($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time'), 'f' => 'f.forum_id', 'i' => 't.topic_title', 's' => (($show_results == 'posts') ? 'pt.post_subject' : 't.topic_title'));
|
||||||
|
|
||||||
if ($show_results == 'posts')
|
if ($sql_where)
|
||||||
{
|
{
|
||||||
// Not joining this query to the one below at present ... may do in future
|
if ($show_results == 'posts')
|
||||||
$sql = 'SELECT zebra_id, friend, foe
|
|
||||||
FROM ' . ZEBRA_TABLE . '
|
|
||||||
WHERE user_id = ' . $user->data['user_id'];
|
|
||||||
$result = $db->sql_query($sql);
|
|
||||||
|
|
||||||
$zebra = array();
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
|
||||||
{
|
{
|
||||||
if ($row['friend'])
|
// Not joining this query to the one below at present ... may do in future
|
||||||
|
$sql = 'SELECT zebra_id, friend, foe
|
||||||
|
FROM ' . ZEBRA_TABLE . '
|
||||||
|
WHERE user_id = ' . $user->data['user_id'];
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
$zebra = array();
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$zebra['friend'][] = $row['zebra_id'];
|
$zebra[($row['friend']) ? 'friend' : 'foe'][] = $row['zebra_id'];
|
||||||
}
|
}
|
||||||
else
|
$db->sql_freeresult($result);
|
||||||
{
|
|
||||||
$zebra['foe'][] = $row['zebra_id'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
|
|
||||||
$sql = 'SELECT p.*, f.forum_id, f.forum_name, t.*, u.username, u.user_sig, u.user_sig_bbcode_uid
|
$sql = 'SELECT p.*, f.forum_id, f.forum_name, t.*, u.username, u.user_sig, u.user_sig_bbcode_uid
|
||||||
FROM ' . FORUMS_TABLE . ' f, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u, ' . POSTS_TABLE . " p
|
FROM ' . FORUMS_TABLE . ' f, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u, ' . POSTS_TABLE . " p
|
||||||
WHERE $sql_where
|
WHERE $sql_where
|
||||||
AND f.forum_id = p.forum_id
|
AND f.forum_id = p.forum_id
|
||||||
AND p.topic_id = t.topic_id
|
AND p.topic_id = t.topic_id
|
||||||
AND p.poster_id = u.user_id";
|
AND p.poster_id = u.user_id";
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$sql = 'SELECT t.*, f.forum_id, f.forum_name
|
|
||||||
FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
|
|
||||||
WHERE $sql_where
|
|
||||||
AND f.forum_id = t.forum_id";
|
|
||||||
}
|
|
||||||
$sql .= ' ORDER BY ' . $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC') . " LIMIT $start, $per_page";
|
|
||||||
$result = $db->sql_query($sql);
|
|
||||||
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
|
||||||
{
|
|
||||||
$forum_id = $row['forum_id'];
|
|
||||||
$topic_id = $row['topic_id'];
|
|
||||||
|
|
||||||
$view_topic_url = "viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&hilit=$u_hilit";
|
|
||||||
|
|
||||||
if ($show_results == 'topics')
|
|
||||||
{
|
|
||||||
$replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies'];
|
|
||||||
|
|
||||||
$folder_img = $folder_alt = $topic_type = '';
|
|
||||||
topic_status($row, $replies, time(), time(), $folder_img, $folder_alt, $topic_type);
|
|
||||||
|
|
||||||
$tpl_ary = array(
|
|
||||||
'TOPIC_AUTHOR' => topic_topic_author($row),
|
|
||||||
'FIRST_POST_TIME' => $user->format_date($row['topic_time']),
|
|
||||||
'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
|
|
||||||
'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']),
|
|
||||||
'LAST_POST_AUTHOR' => ($row['topic_last_poster_name'] != '') ? $row['topic_last_poster_name'] : $user->lang['GUEST'],
|
|
||||||
'PAGINATION' => topic_generate_pagination($replies, $view_topic_url),
|
|
||||||
'REPLIES' => $replies,
|
|
||||||
'VIEWS' => $row['topic_views'],
|
|
||||||
'TOPIC_TYPE' => $topic_type,
|
|
||||||
|
|
||||||
'LAST_POST_IMG' => $user->img('icon_post_latest', 'VIEW_LATEST_POST'),
|
|
||||||
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
|
|
||||||
'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
|
|
||||||
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
|
|
||||||
'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '',
|
|
||||||
'ATTACH_ICON_IMG' => ($auth->acl_gets('f_download', 'u_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
|
||||||
|
|
||||||
'S_TOPIC_TYPE' => $row['topic_type'],
|
|
||||||
'S_USER_POSTED' => (!empty($row['mark_type'])) ? true : false,
|
|
||||||
|
|
||||||
'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_gets('m_', $forum_id)) ? true : false,
|
|
||||||
'S_TOPIC_UNAPPROVED' => (!$row['topic_approved'] && $auth->acl_gets('m_approve', $forum_id)) ? true : false,
|
|
||||||
|
|
||||||
'U_LAST_POST' => $view_topic_url . '&p=' . $row['topic_last_post_id'] . '#' . $row['topic_last_post_id'],
|
|
||||||
'U_LAST_POST_AUTHOR'=> ($row['topic_last_poster_id'] != ANONYMOUS && $row['topic_last_poster_id']) ? "memberlist.$phpEx$SID&mode=viewprofile&u={$row['topic_last_poster_id']}" : '',
|
|
||||||
'U_MCP_REPORT' => "mcp.$phpEx?sid={$user->session_id}&mode=reports&t=$topic_id",
|
|
||||||
'U_MCP_QUEUE' => "mcp.$phpEx?sid={$user->session_id}&i=queue&mode=approve_details&t=$topic_id"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((isset($zebra['foe']) && in_array($row['poster_id'], $zebra['foe'])) && (!$view || $view != 'show' || $post_id != $row['post_id']))
|
$sql = 'SELECT t.*, f.forum_id, f.forum_name
|
||||||
{
|
FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
|
||||||
$template->assign_block_vars('searchresults', array(
|
WHERE $sql_where
|
||||||
'S_IGNORE_POST' => true,
|
AND f.forum_id = t.forum_id";
|
||||||
|
|
||||||
'L_IGNORE_POST' => sprintf($user->lang['POST_BY_FOE'], $row['username'], "<a href=\"search.$phpEx$SID&search_id=$search_id&$u_sort_param&p=" . $row['post_id'] . '&view=show#' . $row['post_id'] . '">', '</a>'))
|
|
||||||
);
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($row['enable_html'])
|
|
||||||
{
|
|
||||||
$row['post_text'] = preg_replace('#(<!\-\- h \-\-><)([\/]?.*?)(><!\-\- h \-\->)#is', "<\\2>", $row['post_text']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$row['post_text'] = censor_text($row['post_text']);
|
|
||||||
|
|
||||||
decode_message($row['post_text'], $row['bbcode_uid']);
|
|
||||||
|
|
||||||
if ($return_chars)
|
|
||||||
{
|
|
||||||
$row['post_text'] = (strlen($row['post_text']) < $return_chars + 3) ? $row['post_text'] : substr($row['post_text'], 0, $return_chars) . '...';
|
|
||||||
}
|
|
||||||
|
|
||||||
// This was shamelessly 'borrowed' from volker at multiartstudio dot de
|
|
||||||
// via php.net's annotated manual
|
|
||||||
$row['post_text'] = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#\b(" . $hilit . ")\b#i', '<span class=\"posthilit\">\\\\1</span>', '\\0')", '>' . $row['post_text'] . '<'), 1, -1));
|
|
||||||
|
|
||||||
$row['post_text'] = smiley_text($row['post_text']);
|
|
||||||
|
|
||||||
$tpl_ary = array(
|
|
||||||
'POSTER_NAME' => ($row['poster_id'] == ANONYMOUS) ? ((!empty($row['post_username'])) ? $row['post_username'] : $user->lang['GUEST']) : $row['username'],
|
|
||||||
'POST_SUBJECT' => censor_text($row['post_subject']),
|
|
||||||
'POST_DATE' => (!empty($row['post_time'])) ? $user->format_date($row['post_time']) : '',
|
|
||||||
'MESSAGE' => (!empty($row['post_text'])) ? str_replace("\n", '<br />', $row['post_text']) : ''
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
$sql .= ' ORDER BY ' . $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC') . " LIMIT $start, $per_page";
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
$template->assign_block_vars('searchresults', array_merge($tpl_ary, array(
|
while ($row = $db->sql_fetchrow($result))
|
||||||
'FORUM_ID' => $forum_id,
|
{
|
||||||
'TOPIC_ID' => $topic_id,
|
$forum_id = $row['forum_id'];
|
||||||
'POST_ID' => ($show_results == 'posts') ? $row['post_id'] : false,
|
$topic_id = $row['topic_id'];
|
||||||
|
|
||||||
'FORUM_TITLE' => $row['forum_name'],
|
$view_topic_url = "viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&hilit=$u_hilit";
|
||||||
'TOPIC_TITLE' => censor_text($row['topic_title']),
|
|
||||||
|
|
||||||
'U_VIEW_TOPIC' => $view_topic_url,
|
if ($show_results == 'topics')
|
||||||
'U_VIEW_FORUM' => "viewforum.$phpEx$SID&f=$forum_id",
|
{
|
||||||
'U_VIEW_POST' => (!empty($row['post_id'])) ? "viewtopic.$phpEx$SID&f=$forum_id&t=" . $row['topic_id'] . '&p=' . $row['post_id'] . '&hilit=' . $u_hilit . '#' . $row['post_id'] : '')
|
$replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies'];
|
||||||
));
|
|
||||||
|
$folder_img = $folder_alt = $topic_type = '';
|
||||||
|
topic_status($row, $replies, time(), time(), $folder_img, $folder_alt, $topic_type);
|
||||||
|
|
||||||
|
$tpl_ary = array(
|
||||||
|
'TOPIC_AUTHOR' => topic_topic_author($row),
|
||||||
|
'FIRST_POST_TIME' => $user->format_date($row['topic_time']),
|
||||||
|
'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
|
||||||
|
'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']),
|
||||||
|
'LAST_POST_AUTHOR' => ($row['topic_last_poster_name'] != '') ? $row['topic_last_poster_name'] : $user->lang['GUEST'],
|
||||||
|
'PAGINATION' => topic_generate_pagination($replies, $view_topic_url),
|
||||||
|
'REPLIES' => $replies,
|
||||||
|
'VIEWS' => $row['topic_views'],
|
||||||
|
'TOPIC_TYPE' => $topic_type,
|
||||||
|
|
||||||
|
'LAST_POST_IMG' => $user->img('icon_post_latest', 'VIEW_LATEST_POST'),
|
||||||
|
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
|
||||||
|
'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
|
||||||
|
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
|
||||||
|
'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '',
|
||||||
|
'ATTACH_ICON_IMG' => ($auth->acl_gets('f_download', 'u_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
||||||
|
|
||||||
|
'S_TOPIC_TYPE' => $row['topic_type'],
|
||||||
|
'S_USER_POSTED' => (!empty($row['mark_type'])) ? true : false,
|
||||||
|
|
||||||
|
'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_gets('m_', $forum_id)) ? true : false,
|
||||||
|
'S_TOPIC_UNAPPROVED' => (!$row['topic_approved'] && $auth->acl_gets('m_approve', $forum_id)) ? true : false,
|
||||||
|
|
||||||
|
'U_LAST_POST' => $view_topic_url . '&p=' . $row['topic_last_post_id'] . '#' . $row['topic_last_post_id'],
|
||||||
|
'U_LAST_POST_AUTHOR'=> ($row['topic_last_poster_id'] != ANONYMOUS && $row['topic_last_poster_id']) ? "memberlist.$phpEx$SID&mode=viewprofile&u={$row['topic_last_poster_id']}" : '',
|
||||||
|
'U_MCP_REPORT' => "mcp.$phpEx?sid={$user->session_id}&mode=reports&t=$topic_id",
|
||||||
|
'U_MCP_QUEUE' => "mcp.$phpEx?sid={$user->session_id}&i=queue&mode=approve_details&t=$topic_id"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((isset($zebra['foe']) && in_array($row['poster_id'], $zebra['foe'])) && (!$view || $view != 'show' || $post_id != $row['post_id']))
|
||||||
|
{
|
||||||
|
$template->assign_block_vars('searchresults', array(
|
||||||
|
'S_IGNORE_POST' => true,
|
||||||
|
|
||||||
|
'L_IGNORE_POST' => sprintf($user->lang['POST_BY_FOE'], $row['username'], "<a href=\"search.$phpEx$SID&search_session_id=$search_session_id&$u_sort_param&p=" . $row['post_id'] . '&view=show#' . $row['post_id'] . '">', '</a>'))
|
||||||
|
);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($row['enable_html'])
|
||||||
|
{
|
||||||
|
$row['post_text'] = preg_replace('#(<!\-\- h \-\-><)([\/]?.*?)(><!\-\- h \-\->)#is', "<\\2>", $row['post_text']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$row['post_text'] = censor_text($row['post_text']);
|
||||||
|
decode_message($row['post_text'], $row['bbcode_uid']);
|
||||||
|
|
||||||
|
if ($return_chars)
|
||||||
|
{
|
||||||
|
$row['post_text'] = (strlen($row['post_text']) < $return_chars + 3) ? $row['post_text'] : substr($row['post_text'], 0, $return_chars) . '...';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($hilit)
|
||||||
|
{
|
||||||
|
// This was shamelessly 'borrowed' from volker at multiartstudio dot de
|
||||||
|
// via php.net's annotated manual
|
||||||
|
$row['post_text'] = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#\b(" . str_replace('\\', '\\\\', $hilit) . ")\b#i', '<span class=\"posthilit\">\\\\1</span>', '\\0')", '>' . $row['post_text'] . '<'), 1, -1));
|
||||||
|
}
|
||||||
|
|
||||||
|
$row['post_text'] = smiley_text($row['post_text']);
|
||||||
|
|
||||||
|
// Replace naughty words such as farty pants
|
||||||
|
$row['post_subject'] = censor_text($row['post_subject']);
|
||||||
|
$row['post_text'] = str_replace("\n", '<br />', censor_text($row['post_text']));
|
||||||
|
|
||||||
|
$tpl_ary = array(
|
||||||
|
'POSTER_NAME' => ($row['poster_id'] == ANONYMOUS) ? ((!empty($row['post_username'])) ? $row['post_username'] : $user->lang['GUEST']) : $row['username'],
|
||||||
|
'POST_SUBJECT' => censor_text($row['post_subject']),
|
||||||
|
'POST_DATE' => (!empty($row['post_time'])) ? $user->format_date($row['post_time']) : '',
|
||||||
|
'MESSAGE' => $row['post_text']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign_block_vars('searchresults', array_merge($tpl_ary, array(
|
||||||
|
'FORUM_ID' => $forum_id,
|
||||||
|
'TOPIC_ID' => $topic_id,
|
||||||
|
'POST_ID' => ($show_results == 'posts') ? $row['post_id'] : false,
|
||||||
|
|
||||||
|
'FORUM_TITLE' => $row['forum_name'],
|
||||||
|
'TOPIC_TITLE' => censor_text($row['topic_title']),
|
||||||
|
|
||||||
|
'U_VIEW_TOPIC' => $view_topic_url,
|
||||||
|
'U_VIEW_FORUM' => "viewforum.$phpEx$SID&f=$forum_id",
|
||||||
|
'U_VIEW_POST' => (!empty($row['post_id'])) ? "viewtopic.$phpEx$SID&f=$forum_id&t=" . $row['topic_id'] . '&p=' . $row['post_id'] . '&hilit=' . $u_hilit . '#' . $row['post_id'] : '')
|
||||||
|
));
|
||||||
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$template->assign_vars(array(
|
||||||
|
'S_NO_SEARCH_RESULTS' => true)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
|
||||||
|
|
||||||
|
|
||||||
page_header($user->lang['SEARCH']);
|
page_header($user->lang['SEARCH']);
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ function jumpto()
|
|||||||
<div id="wrapcentre">
|
<div id="wrapcentre">
|
||||||
|
|
||||||
<p class="searchbar">
|
<p class="searchbar">
|
||||||
<a style="float: left;" href="{U_SEARCH_UNANSWERED}">{L_SEARCH_UNANSWERED}</a>
|
<span style="float: left;"><a href="{U_SEARCH_UNANSWERED}">{L_SEARCH_UNANSWERED}</a> | <a href="{U_SEARCH_ACTIVE_TOPICS}">{L_SEARCH_ACTIVE_TOPICS}</a></span>
|
||||||
<!-- IF S_USER_LOGGED_IN -->
|
<!-- IF S_USER_LOGGED_IN -->
|
||||||
<span style="float: right;"><a href="{U_SEARCH_NEW}">{L_SEARCH_NEW}</a> | <a href="{U_SEARCH_SELF}">{L_SEARCH_SELF}</a></span>
|
<span style="float: right;"><a href="{U_SEARCH_NEW}">{L_SEARCH_NEW}</a> | <a href="{U_SEARCH_SELF}">{L_SEARCH_SELF}</a></span>
|
||||||
<!-- ENDIF -->
|
<!-- ENDIF -->
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<td colspan="2"><span class="titles">{SEARCH_MATCHES}</span><br /></td>
|
<td colspan="2"><span class="titles">{SEARCH_MATCHES}</span><br /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="genmed">{L_SEARCHED_FOR}: <a href="{U_SEARCH_WORDS}"><b>{SEARCH_WORDS}</b></a><!-- IF IGNORED_WORDS --> {L_IGNORED_TERMS}: <b>{IGNORED_WORDS}</b><!-- ENDIF --></td>
|
<td class="genmed"><!-- IF SEARCH_WORDS -->{L_SEARCHED_FOR}: <a href="{U_SEARCH_WORDS}"><b>{SEARCH_WORDS}</b></a><!-- ENDIF --><!-- IF IGNORED_WORDS --> {L_IGNORED_TERMS}: <b>{IGNORED_WORDS}</b><!-- ENDIF --></td>
|
||||||
<td align="right"><span class="genmed">{L_SEARCH_IN_RESULTS}: </span><input type="text" name="search_keywords" value="" /> <input class="btnlite" type="submit" name="submit" value="{L_GO}" /></td>
|
<td align="right"><span class="genmed">{L_SEARCH_IN_RESULTS}: </span><input type="text" name="search_keywords" value="" /> <input class="btnlite" type="submit" name="submit" value="{L_GO}" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@ -58,9 +58,13 @@
|
|||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<!-- BEGINELSE -->
|
||||||
|
<tr valign="middle">
|
||||||
|
<td colspan="7" class="row3" align="center">{L_NO_SEARCH_RESULTS}</td>
|
||||||
|
</tr>
|
||||||
<!-- END searchresults -->
|
<!-- END searchresults -->
|
||||||
<tr>
|
<tr>
|
||||||
<td class="cat" colspan="7" valign="middle" align="center"><span class="gensmall">{L_SORT_BY}:</span> {S_SELECT_SORT_KEY} {S_SELECT_SORT_DIR} <input class="btnlite" type="submit" name="sort" value="{L_GO}" /></td>
|
<td class="cat" colspan="7" valign="middle" align="center"><span class="gensmall">{L_DISPLAY_POSTS}:</span> {S_SELECT_SORT_DAYS} <span class="gensmall">{L_SORT_BY}:</span> {S_SELECT_SORT_KEY} {S_SELECT_SORT_DIR} <input class="btnlite" type="submit" value="{L_GO}" name="sort" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
@ -98,6 +102,10 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="spacer" colspan="2"><img src="images/spacer.gif" height="1" alt="" /></td>
|
<td class="spacer" colspan="2"><img src="images/spacer.gif" height="1" alt="" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<!-- BEGINELSE -->
|
||||||
|
<tr valign="middle">
|
||||||
|
<td colspan="2" class="row3" align="center">{L_NO_SEARCH_RESULTS}</td>
|
||||||
|
</tr>
|
||||||
<!-- END searchresults -->
|
<!-- END searchresults -->
|
||||||
<tr>
|
<tr>
|
||||||
<td class="cat" colspan="2" align="center"><span class="gensmall">{L_SORT_BY}:</span> {S_SELECT_SORT_KEY} {S_SELECT_SORT_DIR} <input class="btnlite" type="submit" name="sort" value="{L_GO}" /></td>
|
<td class="cat" colspan="2" align="center"><span class="gensmall">{L_SORT_BY}:</span> {S_SELECT_SORT_KEY} {S_SELECT_SORT_DIR} <input class="btnlite" type="submit" name="sort" value="{L_GO}" /></td>
|
||||||
@ -107,7 +115,7 @@
|
|||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="nav" style="float:left">{PAGE_NUMBER} [ {TOTAL_MATCHES} ]</div><div class="nav" style="float:right"><!-- IF PAGINATION --><b><a href="javascript:jumpto();">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a> <!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE --> <a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --></b><!-- ENDIF --></div>
|
<div class="nav" style="float:left"><!-- IF PAGINATION -->{PAGE_NUMBER} [ {TOTAL_MATCHES} ]<!-- ENDIF --> </div><div class="nav" style="float:right"><!-- IF PAGINATION --><b><a href="javascript:jumpto();">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a> <!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE --> <a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --></b><!-- ENDIF --></div>
|
||||||
|
|
||||||
<br clear="all" /><br />
|
<br clear="all" /><br />
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user