|
indvdum@0
|
1 |
<?php
|
|
indvdum@0
|
2 |
/**
|
|
indvdum@0
|
3 |
*
|
|
indvdum@0
|
4 |
* @package phpBB3
|
|
indvdum@0
|
5 |
* @version $Id$
|
|
indvdum@0
|
6 |
* @copyright (c) 2005 phpBB Group
|
|
indvdum@0
|
7 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
indvdum@0
|
8 |
*
|
|
indvdum@0
|
9 |
*/
|
|
indvdum@0
|
10 |
|
|
indvdum@0
|
11 |
/**
|
|
indvdum@0
|
12 |
* @ignore
|
|
indvdum@0
|
13 |
*/
|
|
indvdum@0
|
14 |
define('IN_PHPBB', true);
|
|
indvdum@0
|
15 |
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
|
|
indvdum@0
|
16 |
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
|
indvdum@0
|
17 |
include($phpbb_root_path . 'common.' . $phpEx);
|
|
indvdum@0
|
18 |
|
|
indvdum@0
|
19 |
// Start session management
|
|
indvdum@0
|
20 |
$user->session_begin();
|
|
indvdum@0
|
21 |
$auth->acl($user->data);
|
|
indvdum@0
|
22 |
$user->setup('search');
|
|
indvdum@0
|
23 |
|
|
indvdum@0
|
24 |
// Define initial vars
|
|
indvdum@0
|
25 |
$mode = request_var('mode', '');
|
|
indvdum@0
|
26 |
$search_id = request_var('search_id', '');
|
|
indvdum@0
|
27 |
$start = max(request_var('start', 0), 0);
|
|
indvdum@0
|
28 |
$post_id = request_var('p', 0);
|
|
indvdum@0
|
29 |
$topic_id = request_var('t', 0);
|
|
indvdum@0
|
30 |
$view = request_var('view', '');
|
|
indvdum@0
|
31 |
|
|
indvdum@0
|
32 |
$submit = request_var('submit', false);
|
|
indvdum@0
|
33 |
$keywords = utf8_normalize_nfc(request_var('keywords', '', true));
|
|
indvdum@0
|
34 |
$add_keywords = utf8_normalize_nfc(request_var('add_keywords', '', true));
|
|
indvdum@0
|
35 |
$author = request_var('author', '', true);
|
|
indvdum@0
|
36 |
$author_id = request_var('author_id', 0);
|
|
indvdum@0
|
37 |
$show_results = ($topic_id) ? 'posts' : request_var('sr', 'posts');
|
|
indvdum@0
|
38 |
$show_results = ($show_results == 'posts') ? 'posts' : 'topics';
|
|
indvdum@0
|
39 |
$search_terms = request_var('terms', 'all');
|
|
indvdum@0
|
40 |
$search_fields = request_var('sf', 'all');
|
|
indvdum@0
|
41 |
$search_child = request_var('sc', true);
|
|
indvdum@0
|
42 |
|
|
indvdum@0
|
43 |
$sort_days = request_var('st', 0);
|
|
indvdum@0
|
44 |
$sort_key = request_var('sk', 't');
|
|
indvdum@0
|
45 |
$sort_dir = request_var('sd', 'd');
|
|
indvdum@0
|
46 |
|
|
indvdum@0
|
47 |
$return_chars = request_var('ch', ($topic_id) ? -1 : 300);
|
|
indvdum@0
|
48 |
$search_forum = request_var('fid', array(0));
|
|
indvdum@0
|
49 |
|
|
indvdum@0
|
50 |
// We put login boxes for the case if search_id is newposts, egosearch or unreadposts
|
|
indvdum@0
|
51 |
// because a guest should be able to log in even if guests search is not permitted
|
|
indvdum@0
|
52 |
|
|
indvdum@0
|
53 |
switch ($search_id)
|
|
indvdum@0
|
54 |
{
|
|
indvdum@0
|
55 |
// Egosearch is an author search
|
|
indvdum@0
|
56 |
case 'egosearch':
|
|
indvdum@0
|
57 |
$author_id = $user->data['user_id'];
|
|
indvdum@0
|
58 |
if ($user->data['user_id'] == ANONYMOUS)
|
|
indvdum@0
|
59 |
{
|
|
indvdum@0
|
60 |
login_box('', $user->lang['LOGIN_EXPLAIN_EGOSEARCH']);
|
|
indvdum@0
|
61 |
}
|
|
indvdum@0
|
62 |
break;
|
|
indvdum@0
|
63 |
|
|
indvdum@0
|
64 |
// Search for unread posts needs to be allowed and user to be logged in if topics tracking for guests is disabled
|
|
indvdum@0
|
65 |
case 'unreadposts':
|
|
indvdum@0
|
66 |
if (!$config['load_unreads_search'])
|
|
indvdum@0
|
67 |
{
|
|
indvdum@0
|
68 |
$template->assign_var('S_NO_SEARCH', true);
|
|
indvdum@0
|
69 |
trigger_error('NO_SEARCH_UNREADS');
|
|
indvdum@0
|
70 |
}
|
|
indvdum@0
|
71 |
else if (!$config['load_anon_lastread'] && !$user->data['is_registered'])
|
|
indvdum@0
|
72 |
{
|
|
indvdum@0
|
73 |
login_box('', $user->lang['LOGIN_EXPLAIN_UNREADSEARCH']);
|
|
indvdum@0
|
74 |
}
|
|
indvdum@0
|
75 |
break;
|
|
indvdum@0
|
76 |
|
|
indvdum@0
|
77 |
// The "new posts" search uses user_lastvisit which is user based, so it should require user to log in.
|
|
indvdum@0
|
78 |
case 'newposts':
|
|
indvdum@0
|
79 |
if ($user->data['user_id'] == ANONYMOUS)
|
|
indvdum@0
|
80 |
{
|
|
indvdum@0
|
81 |
login_box('', $user->lang['LOGIN_EXPLAIN_NEWPOSTS']);
|
|
indvdum@0
|
82 |
}
|
|
indvdum@0
|
83 |
break;
|
|
indvdum@0
|
84 |
|
|
indvdum@0
|
85 |
default:
|
|
indvdum@0
|
86 |
// There's nothing to do here for now ;)
|
|
indvdum@0
|
87 |
break;
|
|
indvdum@0
|
88 |
}
|
|
indvdum@0
|
89 |
|
|
indvdum@0
|
90 |
// Is user able to search? Has search been disabled?
|
|
indvdum@0
|
91 |
if (!$auth->acl_get('u_search') || !$auth->acl_getf_global('f_search') || !$config['load_search'])
|
|
indvdum@0
|
92 |
{
|
|
indvdum@0
|
93 |
$template->assign_var('S_NO_SEARCH', true);
|
|
indvdum@0
|
94 |
trigger_error('NO_SEARCH');
|
|
indvdum@0
|
95 |
}
|
|
indvdum@0
|
96 |
|
|
indvdum@0
|
97 |
// Check search load limit
|
|
indvdum@0
|
98 |
if ($user->load && $config['limit_search_load'] && ($user->load > doubleval($config['limit_search_load'])))
|
|
indvdum@0
|
99 |
{
|
|
indvdum@0
|
100 |
$template->assign_var('S_NO_SEARCH', true);
|
|
indvdum@0
|
101 |
trigger_error('NO_SEARCH_TIME');
|
|
indvdum@0
|
102 |
}
|
|
indvdum@0
|
103 |
|
|
indvdum@0
|
104 |
// It is applicable if the configuration setting is non-zero, and the user cannot
|
|
indvdum@0
|
105 |
// ignore the flood setting, and the search is a keyword search.
|
|
indvdum@0
|
106 |
$interval = ($user->data['user_id'] == ANONYMOUS) ? $config['search_anonymous_interval'] : $config['search_interval'];
|
|
indvdum@0
|
107 |
if ($interval && !in_array($search_id, array('unreadposts', 'unanswered', 'active_topics', 'egosearch')) && !$auth->acl_get('u_ignoreflood'))
|
|
indvdum@0
|
108 |
{
|
|
indvdum@0
|
109 |
if ($user->data['user_last_search'] > time() - $interval)
|
|
indvdum@0
|
110 |
{
|
|
indvdum@0
|
111 |
$template->assign_var('S_NO_SEARCH', true);
|
|
indvdum@0
|
112 |
trigger_error('NO_SEARCH_TIME');
|
|
indvdum@0
|
113 |
}
|
|
indvdum@0
|
114 |
}
|
|
indvdum@0
|
115 |
|
|
indvdum@0
|
116 |
// Define some vars
|
|
indvdum@0
|
117 |
$limit_days = array(0 => $user->lang['ALL_RESULTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
|
|
indvdum@0
|
118 |
$sort_by_text = array('a' => $user->lang['SORT_AUTHOR'], 't' => $user->lang['SORT_TIME'], 'f' => $user->lang['SORT_FORUM'], 'i' => $user->lang['SORT_TOPIC_TITLE'], 's' => $user->lang['SORT_POST_SUBJECT']);
|
|
indvdum@0
|
119 |
|
|
indvdum@0
|
120 |
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
|
|
indvdum@0
|
121 |
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);
|
|
indvdum@0
|
122 |
|
|
indvdum@0
|
123 |
if ($keywords || $author || $author_id || $search_id || $submit)
|
|
indvdum@0
|
124 |
{
|
|
indvdum@0
|
125 |
// clear arrays
|
|
indvdum@0
|
126 |
$id_ary = array();
|
|
indvdum@0
|
127 |
|
|
indvdum@0
|
128 |
// If we are looking for authors get their ids
|
|
indvdum@0
|
129 |
$author_id_ary = array();
|
|
indvdum@0
|
130 |
$sql_author_match = '';
|
|
indvdum@0
|
131 |
if ($author_id)
|
|
indvdum@0
|
132 |
{
|
|
indvdum@0
|
133 |
$author_id_ary[] = $author_id;
|
|
indvdum@0
|
134 |
}
|
|
indvdum@0
|
135 |
else if ($author)
|
|
indvdum@0
|
136 |
{
|
|
indvdum@0
|
137 |
if ((strpos($author, '*') !== false) && (utf8_strlen(str_replace(array('*', '%'), '', $author)) < $config['min_search_author_chars']))
|
|
indvdum@0
|
138 |
{
|
|
indvdum@0
|
139 |
trigger_error(sprintf($user->lang['TOO_FEW_AUTHOR_CHARS'], $config['min_search_author_chars']));
|
|
indvdum@0
|
140 |
}
|
|
indvdum@0
|
141 |
|
|
indvdum@0
|
142 |
$sql_where = (strpos($author, '*') !== false) ? ' username_clean ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($author))) : " username_clean = '" . $db->sql_escape(utf8_clean_string($author)) . "'";
|
|
indvdum@0
|
143 |
|
|
indvdum@0
|
144 |
$sql = 'SELECT user_id
|
|
indvdum@0
|
145 |
FROM ' . USERS_TABLE . "
|
|
indvdum@0
|
146 |
WHERE $sql_where
|
|
indvdum@0
|
147 |
AND user_type <> " . USER_IGNORE;
|
|
indvdum@0
|
148 |
$result = $db->sql_query_limit($sql, 100);
|
|
indvdum@0
|
149 |
|
|
indvdum@0
|
150 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
151 |
{
|
|
indvdum@0
|
152 |
$author_id_ary[] = (int) $row['user_id'];
|
|
indvdum@0
|
153 |
}
|
|
indvdum@0
|
154 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
155 |
|
|
indvdum@0
|
156 |
$sql_where = (strpos($author, '*') !== false) ? ' post_username ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($author))) : " post_username = '" . $db->sql_escape(utf8_clean_string($author)) . "'";
|
|
indvdum@0
|
157 |
|
|
indvdum@0
|
158 |
$sql = 'SELECT 1 as guest_post
|
|
indvdum@0
|
159 |
FROM ' . POSTS_TABLE . "
|
|
indvdum@0
|
160 |
WHERE $sql_where
|
|
indvdum@0
|
161 |
AND poster_id = " . ANONYMOUS;
|
|
indvdum@0
|
162 |
$result = $db->sql_query_limit($sql, 1);
|
|
indvdum@0
|
163 |
$found_guest_post = $db->sql_fetchfield('guest_post');
|
|
indvdum@0
|
164 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
165 |
|
|
indvdum@0
|
166 |
if ($found_guest_post)
|
|
indvdum@0
|
167 |
{
|
|
indvdum@0
|
168 |
$author_id_ary[] = ANONYMOUS;
|
|
indvdum@0
|
169 |
$sql_author_match = (strpos($author, '*') !== false) ? ' ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($author))) : " = '" . $db->sql_escape(utf8_clean_string($author)) . "'";
|
|
indvdum@0
|
170 |
}
|
|
indvdum@0
|
171 |
|
|
indvdum@0
|
172 |
if (!sizeof($author_id_ary))
|
|
indvdum@0
|
173 |
{
|
|
indvdum@0
|
174 |
trigger_error('NO_SEARCH_RESULTS');
|
|
indvdum@0
|
175 |
}
|
|
indvdum@0
|
176 |
}
|
|
indvdum@0
|
177 |
|
|
indvdum@0
|
178 |
// if we search in an existing search result just add the additional keywords. But we need to use "all search terms"-mode
|
|
indvdum@0
|
179 |
// so we can keep the old keywords in their old mode, but add the new ones as required words
|
|
indvdum@0
|
180 |
if ($add_keywords)
|
|
indvdum@0
|
181 |
{
|
|
indvdum@0
|
182 |
if ($search_terms == 'all')
|
|
indvdum@0
|
183 |
{
|
|
indvdum@0
|
184 |
$keywords .= ' ' . $add_keywords;
|
|
indvdum@0
|
185 |
}
|
|
indvdum@0
|
186 |
else
|
|
indvdum@0
|
187 |
{
|
|
indvdum@0
|
188 |
$search_terms = 'all';
|
|
indvdum@0
|
189 |
$keywords = implode(' |', explode(' ', preg_replace('#\s+#u', ' ', $keywords))) . ' ' .$add_keywords;
|
|
indvdum@0
|
190 |
}
|
|
indvdum@0
|
191 |
}
|
|
indvdum@0
|
192 |
|
|
indvdum@0
|
193 |
// Which forums should not be searched? Author searches are also carried out in unindexed forums
|
|
indvdum@0
|
194 |
if (empty($keywords) && sizeof($author_id_ary))
|
|
indvdum@0
|
195 |
{
|
|
indvdum@0
|
196 |
$ex_fid_ary = array_keys($auth->acl_getf('!f_read', true));
|
|
indvdum@0
|
197 |
}
|
|
indvdum@0
|
198 |
else
|
|
indvdum@0
|
199 |
{
|
|
indvdum@0
|
200 |
$ex_fid_ary = array_unique(array_merge(array_keys($auth->acl_getf('!f_read', true)), array_keys($auth->acl_getf('!f_search', true))));
|
|
indvdum@0
|
201 |
}
|
|
indvdum@0
|
202 |
|
|
indvdum@0
|
203 |
$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'] . ')' : "";
|
|
indvdum@0
|
204 |
|
|
indvdum@0
|
205 |
$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
|
|
indvdum@0
|
206 |
FROM ' . FORUMS_TABLE . ' f
|
|
indvdum@0
|
207 |
LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa ON (fa.forum_id = f.forum_id
|
|
indvdum@0
|
208 |
AND fa.session_id = '" . $db->sql_escape($user->session_id) . "')
|
|
indvdum@0
|
209 |
$not_in_fid
|
|
indvdum@0
|
210 |
ORDER BY f.left_id";
|
|
indvdum@0
|
211 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
212 |
|
|
indvdum@0
|
213 |
$right_id = 0;
|
|
indvdum@0
|
214 |
$reset_search_forum = true;
|
|
indvdum@0
|
215 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
216 |
{
|
|
indvdum@0
|
217 |
if ($row['forum_password'] && $row['user_id'] != $user->data['user_id'])
|
|
indvdum@0
|
218 |
{
|
|
indvdum@0
|
219 |
$ex_fid_ary[] = (int) $row['forum_id'];
|
|
indvdum@0
|
220 |
continue;
|
|
indvdum@0
|
221 |
}
|
|
indvdum@0
|
222 |
|
|
indvdum@0
|
223 |
// Exclude forums from active topics
|
|
indvdum@0
|
224 |
if (!($row['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) && ($search_id == 'active_topics'))
|
|
indvdum@0
|
225 |
{
|
|
indvdum@0
|
226 |
$ex_fid_ary[] = (int) $row['forum_id'];
|
|
indvdum@0
|
227 |
continue;
|
|
indvdum@0
|
228 |
}
|
|
indvdum@0
|
229 |
|
|
indvdum@0
|
230 |
if (sizeof($search_forum))
|
|
indvdum@0
|
231 |
{
|
|
indvdum@0
|
232 |
if ($search_child)
|
|
indvdum@0
|
233 |
{
|
|
indvdum@0
|
234 |
if (in_array($row['forum_id'], $search_forum) && $row['right_id'] > $right_id)
|
|
indvdum@0
|
235 |
{
|
|
indvdum@0
|
236 |
$right_id = (int) $row['right_id'];
|
|
indvdum@0
|
237 |
}
|
|
indvdum@0
|
238 |
else if ($row['right_id'] < $right_id)
|
|
indvdum@0
|
239 |
{
|
|
indvdum@0
|
240 |
continue;
|
|
indvdum@0
|
241 |
}
|
|
indvdum@0
|
242 |
}
|
|
indvdum@0
|
243 |
|
|
indvdum@0
|
244 |
if (!in_array($row['forum_id'], $search_forum))
|
|
indvdum@0
|
245 |
{
|
|
indvdum@0
|
246 |
$ex_fid_ary[] = (int) $row['forum_id'];
|
|
indvdum@0
|
247 |
$reset_search_forum = false;
|
|
indvdum@0
|
248 |
}
|
|
indvdum@0
|
249 |
}
|
|
indvdum@0
|
250 |
}
|
|
indvdum@0
|
251 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
252 |
|
|
indvdum@0
|
253 |
// find out in which forums the user is allowed to view approved posts
|
|
indvdum@0
|
254 |
if ($auth->acl_get('m_approve'))
|
|
indvdum@0
|
255 |
{
|
|
indvdum@0
|
256 |
$m_approve_fid_ary = array(-1);
|
|
indvdum@0
|
257 |
$m_approve_fid_sql = '';
|
|
indvdum@0
|
258 |
}
|
|
indvdum@0
|
259 |
else if ($auth->acl_getf_global('m_approve'))
|
|
indvdum@0
|
260 |
{
|
|
indvdum@0
|
261 |
$m_approve_fid_ary = array_diff(array_keys($auth->acl_getf('!m_approve', true)), $ex_fid_ary);
|
|
indvdum@0
|
262 |
$m_approve_fid_sql = ' AND (p.post_approved = 1' . ((sizeof($m_approve_fid_ary)) ? ' OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) : '') . ')';
|
|
indvdum@0
|
263 |
}
|
|
indvdum@0
|
264 |
else
|
|
indvdum@0
|
265 |
{
|
|
indvdum@0
|
266 |
$m_approve_fid_ary = array();
|
|
indvdum@0
|
267 |
$m_approve_fid_sql = ' AND p.post_approved = 1';
|
|
indvdum@0
|
268 |
}
|
|
indvdum@0
|
269 |
|
|
indvdum@0
|
270 |
if ($reset_search_forum)
|
|
indvdum@0
|
271 |
{
|
|
indvdum@0
|
272 |
$search_forum = array();
|
|
indvdum@0
|
273 |
}
|
|
indvdum@0
|
274 |
|
|
indvdum@0
|
275 |
// Select which method we'll use to obtain the post_id or topic_id information
|
|
indvdum@0
|
276 |
$search_type = basename($config['search_type']);
|
|
indvdum@0
|
277 |
|
|
indvdum@0
|
278 |
if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx))
|
|
indvdum@0
|
279 |
{
|
|
indvdum@0
|
280 |
trigger_error('NO_SUCH_SEARCH_MODULE');
|
|
indvdum@0
|
281 |
}
|
|
indvdum@0
|
282 |
|
|
indvdum@0
|
283 |
require("{$phpbb_root_path}includes/search/$search_type.$phpEx");
|
|
indvdum@0
|
284 |
|
|
indvdum@0
|
285 |
// We do some additional checks in the module to ensure it can actually be utilised
|
|
indvdum@0
|
286 |
$error = false;
|
|
indvdum@0
|
287 |
$search = new $search_type($error);
|
|
indvdum@0
|
288 |
|
|
indvdum@0
|
289 |
if ($error)
|
|
indvdum@0
|
290 |
{
|
|
indvdum@0
|
291 |
trigger_error($error);
|
|
indvdum@0
|
292 |
}
|
|
indvdum@0
|
293 |
|
|
indvdum@0
|
294 |
// let the search module split up the keywords
|
|
indvdum@0
|
295 |
if ($keywords)
|
|
indvdum@0
|
296 |
{
|
|
indvdum@0
|
297 |
$correct_query = $search->split_keywords($keywords, $search_terms);
|
|
indvdum@0
|
298 |
if (!$correct_query || (empty($search->search_query) && !sizeof($author_id_ary) && !$search_id))
|
|
indvdum@0
|
299 |
{
|
|
indvdum@0
|
300 |
$ignored = (sizeof($search->common_words)) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $search->common_words)) . '<br />' : '';
|
|
indvdum@0
|
301 |
trigger_error($ignored . sprintf($user->lang['NO_KEYWORDS'], $search->word_length['min'], $search->word_length['max']));
|
|
indvdum@0
|
302 |
}
|
|
indvdum@0
|
303 |
}
|
|
indvdum@0
|
304 |
|
|
indvdum@0
|
305 |
if (!$keywords && sizeof($author_id_ary))
|
|
indvdum@0
|
306 |
{
|
|
indvdum@0
|
307 |
// if it is an author search we want to show topics by default
|
|
indvdum@0
|
308 |
$show_results = ($topic_id) ? 'posts' : request_var('sr', ($search_id == 'egosearch') ? 'topics' : 'posts');
|
|
indvdum@0
|
309 |
$show_results = ($show_results == 'posts') ? 'posts' : 'topics';
|
|
indvdum@0
|
310 |
}
|
|
indvdum@0
|
311 |
|
|
indvdum@0
|
312 |
// define some variables needed for retrieving post_id/topic_id information
|
|
indvdum@0
|
313 |
$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'));
|
|
indvdum@0
|
314 |
|
|
indvdum@0
|
315 |
// pre-made searches
|
|
indvdum@0
|
316 |
$sql = $field = $l_search_title = '';
|
|
indvdum@0
|
317 |
if ($search_id)
|
|
indvdum@0
|
318 |
{
|
|
indvdum@0
|
319 |
switch ($search_id)
|
|
indvdum@0
|
320 |
{
|
|
indvdum@0
|
321 |
// Oh holy Bob, bring us some activity...
|
|
indvdum@0
|
322 |
case 'active_topics':
|
|
indvdum@0
|
323 |
$l_search_title = $user->lang['SEARCH_ACTIVE_TOPICS'];
|
|
indvdum@0
|
324 |
$show_results = 'topics';
|
|
indvdum@0
|
325 |
$sort_key = 't';
|
|
indvdum@0
|
326 |
$sort_dir = 'd';
|
|
indvdum@0
|
327 |
$sort_days = request_var('st', 7);
|
|
indvdum@0
|
328 |
$sort_by_sql['t'] = 't.topic_last_post_time';
|
|
indvdum@0
|
329 |
|
|
indvdum@0
|
330 |
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);
|
|
indvdum@0
|
331 |
$s_sort_key = $s_sort_dir = '';
|
|
indvdum@0
|
332 |
|
|
indvdum@0
|
333 |
$last_post_time_sql = ($sort_days) ? ' AND t.topic_last_post_time > ' . (time() - ($sort_days * 24 * 3600)) : '';
|
|
indvdum@0
|
334 |
|
|
indvdum@0
|
335 |
$sql = 'SELECT t.topic_last_post_time, t.topic_id
|
|
indvdum@0
|
336 |
FROM ' . TOPICS_TABLE . " t
|
|
indvdum@0
|
337 |
WHERE t.topic_moved_id = 0
|
|
indvdum@0
|
338 |
$last_post_time_sql
|
|
indvdum@0
|
339 |
" . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
|
|
indvdum@0
|
340 |
' . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . '
|
|
indvdum@0
|
341 |
ORDER BY t.topic_last_post_time DESC';
|
|
indvdum@0
|
342 |
$field = 'topic_id';
|
|
indvdum@0
|
343 |
break;
|
|
indvdum@0
|
344 |
|
|
indvdum@0
|
345 |
case 'unanswered':
|
|
indvdum@0
|
346 |
$l_search_title = $user->lang['SEARCH_UNANSWERED'];
|
|
indvdum@0
|
347 |
$show_results = request_var('sr', 'topics');
|
|
indvdum@0
|
348 |
$show_results = ($show_results == 'posts') ? 'posts' : 'topics';
|
|
indvdum@0
|
349 |
$sort_by_sql['t'] = ($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time';
|
|
indvdum@0
|
350 |
$sort_by_sql['s'] = ($show_results == 'posts') ? 'p.post_subject' : 't.topic_title';
|
|
indvdum@0
|
351 |
$sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
|
|
indvdum@0
|
352 |
|
|
indvdum@0
|
353 |
$sort_join = ($sort_key == 'f') ? FORUMS_TABLE . ' f, ' : '';
|
|
indvdum@0
|
354 |
$sql_sort = ($sort_key == 'f') ? ' AND f.forum_id = p.forum_id ' . $sql_sort : $sql_sort;
|
|
indvdum@0
|
355 |
|
|
indvdum@0
|
356 |
if ($sort_days)
|
|
indvdum@0
|
357 |
{
|
|
indvdum@0
|
358 |
$last_post_time = 'AND p.post_time > ' . (time() - ($sort_days * 24 * 3600));
|
|
indvdum@0
|
359 |
}
|
|
indvdum@0
|
360 |
else
|
|
indvdum@0
|
361 |
{
|
|
indvdum@0
|
362 |
$last_post_time = '';
|
|
indvdum@0
|
363 |
}
|
|
indvdum@0
|
364 |
|
|
indvdum@0
|
365 |
if ($sort_key == 'a')
|
|
indvdum@0
|
366 |
{
|
|
indvdum@0
|
367 |
$sort_join = USERS_TABLE . ' u, ';
|
|
indvdum@0
|
368 |
$sql_sort = ' AND u.user_id = p.poster_id ' . $sql_sort;
|
|
indvdum@0
|
369 |
}
|
|
indvdum@0
|
370 |
if ($show_results == 'posts')
|
|
indvdum@0
|
371 |
{
|
|
indvdum@0
|
372 |
$sql = "SELECT p.post_id
|
|
indvdum@0
|
373 |
FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
|
|
indvdum@0
|
374 |
WHERE t.topic_replies = 0
|
|
indvdum@0
|
375 |
AND p.topic_id = t.topic_id
|
|
indvdum@0
|
376 |
$last_post_time
|
|
indvdum@0
|
377 |
$m_approve_fid_sql
|
|
indvdum@0
|
378 |
" . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
|
|
indvdum@0
|
379 |
$sql_sort";
|
|
indvdum@0
|
380 |
$field = 'post_id';
|
|
indvdum@0
|
381 |
}
|
|
indvdum@0
|
382 |
else
|
|
indvdum@0
|
383 |
{
|
|
indvdum@0
|
384 |
$sql = 'SELECT DISTINCT ' . $sort_by_sql[$sort_key] . ", p.topic_id
|
|
indvdum@0
|
385 |
FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
|
|
indvdum@0
|
386 |
WHERE t.topic_replies = 0
|
|
indvdum@0
|
387 |
AND t.topic_moved_id = 0
|
|
indvdum@0
|
388 |
AND p.topic_id = t.topic_id
|
|
indvdum@0
|
389 |
$last_post_time
|
|
indvdum@0
|
390 |
$m_approve_fid_sql
|
|
indvdum@0
|
391 |
" . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
|
|
indvdum@0
|
392 |
$sql_sort";
|
|
indvdum@0
|
393 |
$field = 'topic_id';
|
|
indvdum@0
|
394 |
}
|
|
indvdum@0
|
395 |
break;
|
|
indvdum@0
|
396 |
|
|
indvdum@0
|
397 |
case 'unreadposts':
|
|
indvdum@0
|
398 |
$l_search_title = $user->lang['SEARCH_UNREAD'];
|
|
indvdum@0
|
399 |
// force sorting
|
|
indvdum@0
|
400 |
$show_results = 'topics';
|
|
indvdum@0
|
401 |
$sort_key = 't';
|
|
indvdum@0
|
402 |
$sort_by_sql['t'] = 't.topic_last_post_time';
|
|
indvdum@0
|
403 |
$sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
|
|
indvdum@0
|
404 |
|
|
indvdum@0
|
405 |
$sql_where = 'AND t.topic_moved_id = 0
|
|
indvdum@0
|
406 |
' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
|
|
indvdum@0
|
407 |
' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
|
|
indvdum@0
|
408 |
|
|
indvdum@0
|
409 |
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);
|
|
indvdum@0
|
410 |
$s_sort_key = $s_sort_dir = $u_sort_param = $s_limit_days = '';
|
|
indvdum@0
|
411 |
break;
|
|
indvdum@0
|
412 |
|
|
indvdum@0
|
413 |
case 'newposts':
|
|
indvdum@0
|
414 |
$l_search_title = $user->lang['SEARCH_NEW'];
|
|
indvdum@0
|
415 |
// force sorting
|
|
indvdum@0
|
416 |
$show_results = (request_var('sr', 'topics') == 'posts') ? 'posts' : 'topics';
|
|
indvdum@0
|
417 |
$sort_key = 't';
|
|
indvdum@0
|
418 |
$sort_dir = 'd';
|
|
indvdum@0
|
419 |
$sort_by_sql['t'] = ($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time';
|
|
indvdum@0
|
420 |
$sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
|
|
indvdum@0
|
421 |
|
|
indvdum@0
|
422 |
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);
|
|
indvdum@0
|
423 |
$s_sort_key = $s_sort_dir = $u_sort_param = $s_limit_days = '';
|
|
indvdum@0
|
424 |
|
|
indvdum@0
|
425 |
if ($show_results == 'posts')
|
|
indvdum@0
|
426 |
{
|
|
indvdum@0
|
427 |
$sql = 'SELECT p.post_id
|
|
indvdum@0
|
428 |
FROM ' . POSTS_TABLE . ' p
|
|
indvdum@0
|
429 |
WHERE p.post_time > ' . $user->data['user_lastvisit'] . "
|
|
indvdum@0
|
430 |
$m_approve_fid_sql
|
|
indvdum@0
|
431 |
" . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
|
|
indvdum@0
|
432 |
$sql_sort";
|
|
indvdum@0
|
433 |
$field = 'post_id';
|
|
indvdum@0
|
434 |
}
|
|
indvdum@0
|
435 |
else
|
|
indvdum@0
|
436 |
{
|
|
indvdum@0
|
437 |
$sql = 'SELECT t.topic_id
|
|
indvdum@0
|
438 |
FROM ' . TOPICS_TABLE . ' t
|
|
indvdum@0
|
439 |
WHERE t.topic_last_post_time > ' . $user->data['user_lastvisit'] . '
|
|
indvdum@0
|
440 |
AND t.topic_moved_id = 0
|
|
indvdum@0
|
441 |
' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
|
|
indvdum@0
|
442 |
' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . "
|
|
indvdum@0
|
443 |
$sql_sort";
|
|
indvdum@0
|
444 |
/*
|
|
indvdum@0
|
445 |
[Fix] queued replies missing from "view new posts" (Bug #42705 - Patch by Paul)
|
|
indvdum@0
|
446 |
- Creates temporary table, query is far from optimized
|
|
indvdum@0
|
447 |
|
|
indvdum@0
|
448 |
$sql = 'SELECT t.topic_id
|
|
indvdum@0
|
449 |
FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
|
|
indvdum@0
|
450 |
WHERE p.post_time > ' . $user->data['user_lastvisit'] . '
|
|
indvdum@0
|
451 |
AND t.topic_id = p.topic_id
|
|
indvdum@0
|
452 |
AND t.topic_moved_id = 0
|
|
indvdum@0
|
453 |
' . $m_approve_fid_sql . '
|
|
indvdum@0
|
454 |
' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . "
|
|
indvdum@0
|
455 |
GROUP BY t.topic_id
|
|
indvdum@0
|
456 |
$sql_sort";
|
|
indvdum@0
|
457 |
*/
|
|
indvdum@0
|
458 |
$field = 'topic_id';
|
|
indvdum@0
|
459 |
}
|
|
indvdum@0
|
460 |
break;
|
|
indvdum@0
|
461 |
|
|
indvdum@0
|
462 |
case 'egosearch':
|
|
indvdum@0
|
463 |
$l_search_title = $user->lang['SEARCH_SELF'];
|
|
indvdum@0
|
464 |
break;
|
|
indvdum@0
|
465 |
}
|
|
indvdum@0
|
466 |
}
|
|
indvdum@0
|
467 |
|
|
indvdum@0
|
468 |
// show_results should not change after this
|
|
indvdum@0
|
469 |
$per_page = ($show_results == 'posts') ? $config['posts_per_page'] : $config['topics_per_page'];
|
|
indvdum@0
|
470 |
$total_match_count = 0;
|
|
indvdum@0
|
471 |
|
|
indvdum@0
|
472 |
if ($search_id)
|
|
indvdum@0
|
473 |
{
|
|
indvdum@0
|
474 |
if ($sql)
|
|
indvdum@0
|
475 |
{
|
|
indvdum@0
|
476 |
// only return up to 1000 ids (the last one will be removed later)
|
|
indvdum@0
|
477 |
$result = $db->sql_query_limit($sql, 1001 - $start, $start);
|
|
indvdum@0
|
478 |
|
|
indvdum@0
|
479 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
480 |
{
|
|
indvdum@0
|
481 |
$id_ary[] = (int) $row[$field];
|
|
indvdum@0
|
482 |
}
|
|
indvdum@0
|
483 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
484 |
|
|
indvdum@0
|
485 |
$total_match_count = sizeof($id_ary) + $start;
|
|
indvdum@0
|
486 |
$id_ary = array_slice($id_ary, 0, $per_page);
|
|
indvdum@0
|
487 |
}
|
|
indvdum@0
|
488 |
else if ($search_id == 'unreadposts')
|
|
indvdum@0
|
489 |
{
|
|
indvdum@0
|
490 |
$id_ary = array_keys(get_unread_topics($user->data['user_id'], $sql_where, $sql_sort, 1001 - $start, $start));
|
|
indvdum@0
|
491 |
|
|
indvdum@0
|
492 |
$total_match_count = sizeof($id_ary) + $start;
|
|
indvdum@0
|
493 |
$id_ary = array_slice($id_ary, 0, $per_page);
|
|
indvdum@0
|
494 |
}
|
|
indvdum@0
|
495 |
else
|
|
indvdum@0
|
496 |
{
|
|
indvdum@0
|
497 |
$search_id = '';
|
|
indvdum@0
|
498 |
}
|
|
indvdum@0
|
499 |
}
|
|
indvdum@0
|
500 |
|
|
indvdum@0
|
501 |
// make sure that some arrays are always in the same order
|
|
indvdum@0
|
502 |
sort($ex_fid_ary);
|
|
indvdum@0
|
503 |
sort($m_approve_fid_ary);
|
|
indvdum@0
|
504 |
sort($author_id_ary);
|
|
indvdum@0
|
505 |
|
|
indvdum@0
|
506 |
if (!empty($search->search_query))
|
|
indvdum@0
|
507 |
{
|
|
indvdum@0
|
508 |
$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_fid_ary, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page);
|
|
indvdum@0
|
509 |
}
|
|
indvdum@0
|
510 |
else if (sizeof($author_id_ary))
|
|
indvdum@0
|
511 |
{
|
|
indvdum@0
|
512 |
$firstpost_only = ($search_fields === 'firstpost' || $search_fields == 'titleonly') ? true : false;
|
|
indvdum@0
|
513 |
$total_match_count = $search->author_search($show_results, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page);
|
|
indvdum@0
|
514 |
}
|
|
indvdum@0
|
515 |
|
|
indvdum@0
|
516 |
// For some searches we need to print out the "no results" page directly to allow re-sorting/refining the search options.
|
|
indvdum@0
|
517 |
if (!sizeof($id_ary) && !$search_id)
|
|
indvdum@0
|
518 |
{
|
|
indvdum@0
|
519 |
trigger_error('NO_SEARCH_RESULTS');
|
|
indvdum@0
|
520 |
}
|
|
indvdum@0
|
521 |
|
|
indvdum@0
|
522 |
$sql_where = '';
|
|
indvdum@0
|
523 |
|
|
indvdum@0
|
524 |
if (sizeof($id_ary))
|
|
indvdum@0
|
525 |
{
|
|
indvdum@0
|
526 |
$sql_where .= $db->sql_in_set(($show_results == 'posts') ? 'p.post_id' : 't.topic_id', $id_ary);
|
|
indvdum@0
|
527 |
$sql_where .= (sizeof($ex_fid_ary)) ? ' AND (' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . ' OR f.forum_id IS NULL)' : '';
|
|
indvdum@0
|
528 |
$sql_where .= ($show_results == 'posts') ? $m_approve_fid_sql : str_replace(array('p.post_approved', 'p.forum_id'), array('t.topic_approved', 't.forum_id'), $m_approve_fid_sql);
|
|
indvdum@0
|
529 |
}
|
|
indvdum@0
|
530 |
|
|
indvdum@0
|
531 |
if ($show_results == 'posts')
|
|
indvdum@0
|
532 |
{
|
|
indvdum@0
|
533 |
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
|
|
indvdum@0
|
534 |
}
|
|
indvdum@0
|
535 |
else
|
|
indvdum@0
|
536 |
{
|
|
indvdum@0
|
537 |
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
|
indvdum@0
|
538 |
}
|
|
indvdum@0
|
539 |
|
|
indvdum@0
|
540 |
$user->add_lang('viewtopic');
|
|
indvdum@0
|
541 |
|
|
indvdum@0
|
542 |
// Grab icons
|
|
indvdum@0
|
543 |
$icons = $cache->obtain_icons();
|
|
indvdum@0
|
544 |
|
|
indvdum@0
|
545 |
// Output header
|
|
indvdum@0
|
546 |
if ($search_id && ($total_match_count > 1000))
|
|
indvdum@0
|
547 |
{
|
|
indvdum@0
|
548 |
// limit the number to 1000 for pre-made searches
|
|
indvdum@0
|
549 |
$total_match_count--;
|
|
indvdum@0
|
550 |
$l_search_matches = sprintf($user->lang['FOUND_MORE_SEARCH_MATCHES'], $total_match_count);
|
|
indvdum@0
|
551 |
}
|
|
indvdum@0
|
552 |
else
|
|
indvdum@0
|
553 |
{
|
|
indvdum@0
|
554 |
$l_search_matches = ($total_match_count == 1) ? sprintf($user->lang['FOUND_SEARCH_MATCH'], $total_match_count) : sprintf($user->lang['FOUND_SEARCH_MATCHES'], $total_match_count);
|
|
indvdum@0
|
555 |
}
|
|
indvdum@0
|
556 |
|
|
indvdum@0
|
557 |
// define some vars for urls
|
|
indvdum@0
|
558 |
$hilit = implode('|', explode(' ', preg_replace('#\s+#u', ' ', str_replace(array('+', '-', '|', '(', ')', '"'), ' ', $keywords))));
|
|
indvdum@0
|
559 |
// Do not allow *only* wildcard being used for hilight
|
|
indvdum@0
|
560 |
$hilit = (strspn($hilit, '*') === strlen($hilit)) ? '' : $hilit;
|
|
indvdum@0
|
561 |
|
|
indvdum@0
|
562 |
$u_hilit = urlencode(htmlspecialchars_decode(str_replace('|', ' ', $hilit)));
|
|
indvdum@0
|
563 |
$u_show_results = '&sr=' . $show_results;
|
|
indvdum@0
|
564 |
$u_search_forum = implode('&fid%5B%5D=', $search_forum);
|
|
indvdum@0
|
565 |
|
|
indvdum@0
|
566 |
$u_search = append_sid("{$phpbb_root_path}search.$phpEx", $u_sort_param . $u_show_results);
|
|
indvdum@0
|
567 |
$u_search .= ($search_id) ? '&search_id=' . $search_id : '';
|
|
indvdum@0
|
568 |
$u_search .= ($u_hilit) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : '';
|
|
indvdum@0
|
569 |
$u_search .= ($search_terms != 'all') ? '&terms=' . $search_terms : '';
|
|
indvdum@0
|
570 |
$u_search .= ($topic_id) ? '&t=' . $topic_id : '';
|
|
indvdum@0
|
571 |
$u_search .= ($author) ? '&author=' . urlencode(htmlspecialchars_decode($author)) : '';
|
|
indvdum@0
|
572 |
$u_search .= ($author_id) ? '&author_id=' . $author_id : '';
|
|
indvdum@0
|
573 |
$u_search .= ($u_search_forum) ? '&fid%5B%5D=' . $u_search_forum : '';
|
|
indvdum@0
|
574 |
$u_search .= (!$search_child) ? '&sc=0' : '';
|
|
indvdum@0
|
575 |
$u_search .= ($search_fields != 'all') ? '&sf=' . $search_fields : '';
|
|
indvdum@0
|
576 |
$u_search .= ($return_chars != 300) ? '&ch=' . $return_chars : '';
|
|
indvdum@0
|
577 |
|
|
indvdum@0
|
578 |
$template->assign_vars(array(
|
|
indvdum@0
|
579 |
'SEARCH_TITLE' => $l_search_title,
|
|
indvdum@0
|
580 |
'SEARCH_MATCHES' => $l_search_matches,
|
|
indvdum@0
|
581 |
'SEARCH_WORDS' => $search->search_query,
|
|
indvdum@0
|
582 |
'IGNORED_WORDS' => (sizeof($search->common_words)) ? implode(' ', $search->common_words) : '',
|
|
indvdum@0
|
583 |
'PAGINATION' => generate_pagination($u_search, $total_match_count, $per_page, $start),
|
|
indvdum@0
|
584 |
'PAGE_NUMBER' => on_page($total_match_count, $per_page, $start),
|
|
indvdum@0
|
585 |
'TOTAL_MATCHES' => $total_match_count,
|
|
indvdum@0
|
586 |
'SEARCH_IN_RESULTS' => ($search_id) ? false : true,
|
|
indvdum@0
|
587 |
|
|
indvdum@0
|
588 |
'S_SELECT_SORT_DIR' => $s_sort_dir,
|
|
indvdum@0
|
589 |
'S_SELECT_SORT_KEY' => $s_sort_key,
|
|
indvdum@0
|
590 |
'S_SELECT_SORT_DAYS' => $s_limit_days,
|
|
indvdum@0
|
591 |
'S_SEARCH_ACTION' => $u_search,
|
|
indvdum@0
|
592 |
'S_SHOW_TOPICS' => ($show_results == 'posts') ? false : true,
|
|
indvdum@0
|
593 |
|
|
indvdum@0
|
594 |
'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'),
|
|
indvdum@0
|
595 |
'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
|
|
indvdum@0
|
596 |
'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'),
|
|
indvdum@0
|
597 |
'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'),
|
|
indvdum@0
|
598 |
'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
|
|
indvdum@0
|
599 |
|
|
indvdum@0
|
600 |
'U_SEARCH_WORDS' => $u_search,
|
|
indvdum@0
|
601 |
));
|
|
indvdum@0
|
602 |
|
|
indvdum@0
|
603 |
if ($sql_where)
|
|
indvdum@0
|
604 |
{
|
|
indvdum@0
|
605 |
if ($show_results == 'posts')
|
|
indvdum@0
|
606 |
{
|
|
indvdum@0
|
607 |
// @todo Joining this query to the one below?
|
|
indvdum@0
|
608 |
$sql = 'SELECT zebra_id, friend, foe
|
|
indvdum@0
|
609 |
FROM ' . ZEBRA_TABLE . '
|
|
indvdum@0
|
610 |
WHERE user_id = ' . $user->data['user_id'];
|
|
indvdum@0
|
611 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
612 |
|
|
indvdum@0
|
613 |
$zebra = array();
|
|
indvdum@0
|
614 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
615 |
{
|
|
indvdum@0
|
616 |
$zebra[($row['friend']) ? 'friend' : 'foe'][] = $row['zebra_id'];
|
|
indvdum@0
|
617 |
}
|
|
indvdum@0
|
618 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
619 |
|
|
indvdum@0
|
620 |
$sql = 'SELECT p.*, f.forum_id, f.forum_name, t.*, u.username, u.username_clean, u.user_sig, u.user_sig_bbcode_uid, u.user_colour
|
|
indvdum@0
|
621 |
FROM ' . POSTS_TABLE . ' p
|
|
indvdum@0
|
622 |
LEFT JOIN ' . TOPICS_TABLE . ' t ON (p.topic_id = t.topic_id)
|
|
indvdum@0
|
623 |
LEFT JOIN ' . FORUMS_TABLE . ' f ON (p.forum_id = f.forum_id)
|
|
indvdum@0
|
624 |
LEFT JOIN ' . USERS_TABLE . " u ON (p.poster_id = u.user_id)
|
|
indvdum@0
|
625 |
WHERE $sql_where";
|
|
indvdum@0
|
626 |
}
|
|
indvdum@0
|
627 |
else
|
|
indvdum@0
|
628 |
{
|
|
indvdum@0
|
629 |
$sql_from = TOPICS_TABLE . ' t
|
|
indvdum@0
|
630 |
LEFT JOIN ' . FORUMS_TABLE . ' f ON (f.forum_id = t.forum_id)
|
|
indvdum@0
|
631 |
' . (($sort_key == 'a') ? ' LEFT JOIN ' . USERS_TABLE . ' u ON (u.user_id = t.topic_poster) ' : '');
|
|
indvdum@0
|
632 |
$sql_select = 't.*, f.forum_id, f.forum_name';
|
|
indvdum@0
|
633 |
|
|
indvdum@0
|
634 |
if ($user->data['is_registered'])
|
|
indvdum@0
|
635 |
{
|
|
indvdum@0
|
636 |
if ($config['load_db_track'] && $author_id !== $user->data['user_id'])
|
|
indvdum@0
|
637 |
{
|
|
indvdum@0
|
638 |
$sql_from .= ' LEFT JOIN ' . TOPICS_POSTED_TABLE . ' tp ON (tp.user_id = ' . $user->data['user_id'] . '
|
|
indvdum@0
|
639 |
AND t.topic_id = tp.topic_id)';
|
|
indvdum@0
|
640 |
$sql_select .= ', tp.topic_posted';
|
|
indvdum@0
|
641 |
}
|
|
indvdum@0
|
642 |
|
|
indvdum@0
|
643 |
if ($config['load_db_lastread'])
|
|
indvdum@0
|
644 |
{
|
|
indvdum@0
|
645 |
$sql_from .= ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.user_id = ' . $user->data['user_id'] . '
|
|
indvdum@0
|
646 |
AND t.topic_id = tt.topic_id)
|
|
indvdum@0
|
647 |
LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . '
|
|
indvdum@0
|
648 |
AND ft.forum_id = f.forum_id)';
|
|
indvdum@0
|
649 |
$sql_select .= ', tt.mark_time, ft.mark_time as f_mark_time';
|
|
indvdum@0
|
650 |
}
|
|
indvdum@0
|
651 |
}
|
|
indvdum@0
|
652 |
|
|
indvdum@0
|
653 |
if ($config['load_anon_lastread'] || ($user->data['is_registered'] && !$config['load_db_lastread']))
|
|
indvdum@0
|
654 |
{
|
|
indvdum@0
|
655 |
$tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : '';
|
|
indvdum@0
|
656 |
$tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array();
|
|
indvdum@0
|
657 |
}
|
|
indvdum@0
|
658 |
|
|
indvdum@0
|
659 |
$sql = "SELECT $sql_select
|
|
indvdum@0
|
660 |
FROM $sql_from
|
|
indvdum@0
|
661 |
WHERE $sql_where";
|
|
indvdum@0
|
662 |
}
|
|
indvdum@0
|
663 |
$sql .= ' ORDER BY ' . $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
|
|
indvdum@0
|
664 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
665 |
$result_topic_id = 0;
|
|
indvdum@0
|
666 |
|
|
indvdum@0
|
667 |
$rowset = array();
|
|
indvdum@0
|
668 |
|
|
indvdum@0
|
669 |
if ($show_results == 'topics')
|
|
indvdum@0
|
670 |
{
|
|
indvdum@0
|
671 |
$forums = $rowset = $shadow_topic_list = array();
|
|
indvdum@0
|
672 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
673 |
{
|
|
indvdum@0
|
674 |
$row['forum_id'] = (int) $row['forum_id'];
|
|
indvdum@0
|
675 |
$row['topic_id'] = (int) $row['topic_id'];
|
|
indvdum@0
|
676 |
|
|
indvdum@0
|
677 |
if ($row['topic_status'] == ITEM_MOVED)
|
|
indvdum@0
|
678 |
{
|
|
indvdum@0
|
679 |
$shadow_topic_list[$row['topic_moved_id']] = $row['topic_id'];
|
|
indvdum@0
|
680 |
}
|
|
indvdum@0
|
681 |
|
|
indvdum@0
|
682 |
$rowset[$row['topic_id']] = $row;
|
|
indvdum@0
|
683 |
|
|
indvdum@0
|
684 |
if (!isset($forums[$row['forum_id']]) && $user->data['is_registered'] && $config['load_db_lastread'])
|
|
indvdum@0
|
685 |
{
|
|
indvdum@0
|
686 |
$forums[$row['forum_id']]['mark_time'] = $row['f_mark_time'];
|
|
indvdum@0
|
687 |
}
|
|
indvdum@0
|
688 |
$forums[$row['forum_id']]['topic_list'][] = $row['topic_id'];
|
|
indvdum@0
|
689 |
$forums[$row['forum_id']]['rowset'][$row['topic_id']] = &$rowset[$row['topic_id']];
|
|
indvdum@0
|
690 |
}
|
|
indvdum@0
|
691 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
692 |
|
|
indvdum@0
|
693 |
// If we have some shadow topics, update the rowset to reflect their topic information
|
|
indvdum@0
|
694 |
if (sizeof($shadow_topic_list))
|
|
indvdum@0
|
695 |
{
|
|
indvdum@0
|
696 |
$sql = 'SELECT *
|
|
indvdum@0
|
697 |
FROM ' . TOPICS_TABLE . '
|
|
indvdum@0
|
698 |
WHERE ' . $db->sql_in_set('topic_id', array_keys($shadow_topic_list));
|
|
indvdum@0
|
699 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
700 |
|
|
indvdum@0
|
701 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
702 |
{
|
|
indvdum@0
|
703 |
$orig_topic_id = $shadow_topic_list[$row['topic_id']];
|
|
indvdum@0
|
704 |
|
|
indvdum@0
|
705 |
// We want to retain some values
|
|
indvdum@0
|
706 |
$row = array_merge($row, array(
|
|
indvdum@0
|
707 |
'topic_moved_id' => $rowset[$orig_topic_id]['topic_moved_id'],
|
|
indvdum@0
|
708 |
'topic_status' => $rowset[$orig_topic_id]['topic_status'],
|
|
indvdum@0
|
709 |
'forum_name' => $rowset[$orig_topic_id]['forum_name'])
|
|
indvdum@0
|
710 |
);
|
|
indvdum@0
|
711 |
|
|
indvdum@0
|
712 |
$rowset[$orig_topic_id] = $row;
|
|
indvdum@0
|
713 |
}
|
|
indvdum@0
|
714 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
715 |
}
|
|
indvdum@0
|
716 |
unset($shadow_topic_list);
|
|
indvdum@0
|
717 |
|
|
indvdum@0
|
718 |
foreach ($forums as $forum_id => $forum)
|
|
indvdum@0
|
719 |
{
|
|
indvdum@0
|
720 |
if ($user->data['is_registered'] && $config['load_db_lastread'])
|
|
indvdum@0
|
721 |
{
|
|
indvdum@0
|
722 |
$topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time']), ($forum_id) ? false : $forum['topic_list']);
|
|
indvdum@0
|
723 |
}
|
|
indvdum@0
|
724 |
else if ($config['load_anon_lastread'] || $user->data['is_registered'])
|
|
indvdum@0
|
725 |
{
|
|
indvdum@0
|
726 |
$topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list'], ($forum_id) ? false : $forum['topic_list']);
|
|
indvdum@0
|
727 |
|
|
indvdum@0
|
728 |
if (!$user->data['is_registered'])
|
|
indvdum@0
|
729 |
{
|
|
indvdum@0
|
730 |
$user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
|
|
indvdum@0
|
731 |
}
|
|
indvdum@0
|
732 |
}
|
|
indvdum@0
|
733 |
}
|
|
indvdum@0
|
734 |
unset($forums);
|
|
indvdum@0
|
735 |
}
|
|
indvdum@0
|
736 |
else
|
|
indvdum@0
|
737 |
{
|
|
indvdum@0
|
738 |
$bbcode_bitfield = $text_only_message = '';
|
|
indvdum@0
|
739 |
$attach_list = array();
|
|
indvdum@0
|
740 |
|
|
indvdum@0
|
741 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
742 |
{
|
|
indvdum@0
|
743 |
// We pre-process some variables here for later usage
|
|
indvdum@0
|
744 |
$row['post_text'] = censor_text($row['post_text']);
|
|
indvdum@0
|
745 |
|
|
indvdum@0
|
746 |
$text_only_message = $row['post_text'];
|
|
indvdum@0
|
747 |
// make list items visible as such
|
|
indvdum@0
|
748 |
if ($row['bbcode_uid'])
|
|
indvdum@0
|
749 |
{
|
|
indvdum@0
|
750 |
$text_only_message = str_replace('[*:' . $row['bbcode_uid'] . ']', '⋅ ', $text_only_message);
|
|
indvdum@0
|
751 |
// no BBCode in text only message
|
|
indvdum@0
|
752 |
strip_bbcode($text_only_message, $row['bbcode_uid']);
|
|
indvdum@0
|
753 |
}
|
|
indvdum@0
|
754 |
|
|
indvdum@0
|
755 |
if ($return_chars == -1 || utf8_strlen($text_only_message) < ($return_chars + 3))
|
|
indvdum@0
|
756 |
{
|
|
indvdum@0
|
757 |
$row['display_text_only'] = false;
|
|
indvdum@0
|
758 |
$bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
|
|
indvdum@0
|
759 |
|
|
indvdum@0
|
760 |
// Does this post have an attachment? If so, add it to the list
|
|
indvdum@0
|
761 |
if ($row['post_attachment'] && $config['allow_attachments'])
|
|
indvdum@0
|
762 |
{
|
|
indvdum@0
|
763 |
$attach_list[$row['forum_id']][] = $row['post_id'];
|
|
indvdum@0
|
764 |
}
|
|
indvdum@0
|
765 |
}
|
|
indvdum@0
|
766 |
else
|
|
indvdum@0
|
767 |
{
|
|
indvdum@0
|
768 |
$row['post_text'] = $text_only_message;
|
|
indvdum@0
|
769 |
$row['display_text_only'] = true;
|
|
indvdum@0
|
770 |
}
|
|
indvdum@0
|
771 |
|
|
indvdum@0
|
772 |
$rowset[] = $row;
|
|
indvdum@0
|
773 |
}
|
|
indvdum@0
|
774 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
775 |
|
|
indvdum@0
|
776 |
unset($text_only_message);
|
|
indvdum@0
|
777 |
|
|
indvdum@0
|
778 |
// Instantiate BBCode if needed
|
|
indvdum@0
|
779 |
if ($bbcode_bitfield !== '')
|
|
indvdum@0
|
780 |
{
|
|
indvdum@0
|
781 |
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
|
|
indvdum@0
|
782 |
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
|
|
indvdum@0
|
783 |
}
|
|
indvdum@0
|
784 |
|
|
indvdum@0
|
785 |
// Pull attachment data
|
|
indvdum@0
|
786 |
if (sizeof($attach_list))
|
|
indvdum@0
|
787 |
{
|
|
indvdum@0
|
788 |
$use_attach_list = $attach_list;
|
|
indvdum@0
|
789 |
$attach_list = array();
|
|
indvdum@0
|
790 |
|
|
indvdum@0
|
791 |
foreach ($use_attach_list as $forum_id => $_list)
|
|
indvdum@0
|
792 |
{
|
|
indvdum@0
|
793 |
if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id))
|
|
indvdum@0
|
794 |
{
|
|
indvdum@0
|
795 |
$attach_list = array_merge($attach_list, $_list);
|
|
indvdum@0
|
796 |
}
|
|
indvdum@0
|
797 |
}
|
|
indvdum@0
|
798 |
}
|
|
indvdum@0
|
799 |
|
|
indvdum@0
|
800 |
if (sizeof($attach_list))
|
|
indvdum@0
|
801 |
{
|
|
indvdum@0
|
802 |
$sql = 'SELECT *
|
|
indvdum@0
|
803 |
FROM ' . ATTACHMENTS_TABLE . '
|
|
indvdum@0
|
804 |
WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . '
|
|
indvdum@0
|
805 |
AND in_message = 0
|
|
indvdum@0
|
806 |
ORDER BY filetime DESC, post_msg_id ASC';
|
|
indvdum@0
|
807 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
808 |
|
|
indvdum@0
|
809 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
810 |
{
|
|
indvdum@0
|
811 |
$attachments[$row['post_msg_id']][] = $row;
|
|
indvdum@0
|
812 |
}
|
|
indvdum@0
|
813 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
814 |
}
|
|
indvdum@0
|
815 |
}
|
|
indvdum@0
|
816 |
|
|
indvdum@0
|
817 |
if ($hilit)
|
|
indvdum@0
|
818 |
{
|
|
indvdum@0
|
819 |
// Remove bad highlights
|
|
indvdum@0
|
820 |
$hilit_array = array_filter(explode('|', $hilit), 'strlen');
|
|
indvdum@0
|
821 |
foreach ($hilit_array as $key => $value)
|
|
indvdum@0
|
822 |
{
|
|
indvdum@0
|
823 |
$hilit_array[$key] = str_replace('\*', '\w*?', preg_quote($value, '#'));
|
|
indvdum@0
|
824 |
$hilit_array[$key] = preg_replace('#(^|\s)\\\\w\*\?(\s|$)#', '$1\w+?$2', $hilit_array[$key]);
|
|
indvdum@0
|
825 |
}
|
|
indvdum@0
|
826 |
$hilit = implode('|', $hilit_array);
|
|
indvdum@0
|
827 |
}
|
|
indvdum@0
|
828 |
|
|
indvdum@0
|
829 |
foreach ($rowset as $row)
|
|
indvdum@0
|
830 |
{
|
|
indvdum@0
|
831 |
$forum_id = $row['forum_id'];
|
|
indvdum@0
|
832 |
$result_topic_id = $row['topic_id'];
|
|
indvdum@0
|
833 |
$topic_title = censor_text($row['topic_title']);
|
|
indvdum@0
|
834 |
|
|
indvdum@0
|
835 |
// we need to select a forum id for this global topic
|
|
indvdum@0
|
836 |
if (!$forum_id)
|
|
indvdum@0
|
837 |
{
|
|
indvdum@0
|
838 |
if (!isset($g_forum_id))
|
|
indvdum@0
|
839 |
{
|
|
indvdum@0
|
840 |
// Get a list of forums the user cannot read
|
|
indvdum@0
|
841 |
$forum_ary = array_unique(array_keys($auth->acl_getf('!f_read', true)));
|
|
indvdum@0
|
842 |
|
|
indvdum@0
|
843 |
// Determine first forum the user is able to read (must not be a category)
|
|
indvdum@0
|
844 |
$sql = 'SELECT forum_id
|
|
indvdum@0
|
845 |
FROM ' . FORUMS_TABLE . '
|
|
indvdum@0
|
846 |
WHERE forum_type = ' . FORUM_POST;
|
|
indvdum@0
|
847 |
|
|
indvdum@0
|
848 |
if (sizeof($forum_ary))
|
|
indvdum@0
|
849 |
{
|
|
indvdum@0
|
850 |
$sql .= ' AND ' . $db->sql_in_set('forum_id', $forum_ary, true);
|
|
indvdum@0
|
851 |
}
|
|
indvdum@0
|
852 |
|
|
indvdum@0
|
853 |
$result = $db->sql_query_limit($sql, 1);
|
|
indvdum@0
|
854 |
$g_forum_id = (int) $db->sql_fetchfield('forum_id');
|
|
indvdum@0
|
855 |
}
|
|
indvdum@0
|
856 |
$u_forum_id = $g_forum_id;
|
|
indvdum@0
|
857 |
}
|
|
indvdum@0
|
858 |
else
|
|
indvdum@0
|
859 |
{
|
|
indvdum@0
|
860 |
$u_forum_id = $forum_id;
|
|
indvdum@0
|
861 |
}
|
|
indvdum@0
|
862 |
|
|
indvdum@0
|
863 |
$view_topic_url_params = "f=$u_forum_id&t=$result_topic_id" . (($u_hilit) ? "&hilit=$u_hilit" : '');
|
|
indvdum@0
|
864 |
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params);
|
|
indvdum@0
|
865 |
|
|
indvdum@0
|
866 |
$replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies'];
|
|
indvdum@0
|
867 |
|
|
indvdum@0
|
868 |
if ($show_results == 'topics')
|
|
indvdum@0
|
869 |
{
|
|
indvdum@0
|
870 |
if ($config['load_db_track'] && $author_id === $user->data['user_id'])
|
|
indvdum@0
|
871 |
{
|
|
indvdum@0
|
872 |
$row['topic_posted'] = 1;
|
|
indvdum@0
|
873 |
}
|
|
indvdum@0
|
874 |
|
|
indvdum@0
|
875 |
$folder_img = $folder_alt = $topic_type = '';
|
|
indvdum@0
|
876 |
topic_status($row, $replies, (isset($topic_tracking_info[$forum_id][$row['topic_id']]) && $row['topic_last_post_time'] > $topic_tracking_info[$forum_id][$row['topic_id']]) ? true : false, $folder_img, $folder_alt, $topic_type);
|
|
indvdum@0
|
877 |
|
|
indvdum@0
|
878 |
$unread_topic = (isset($topic_tracking_info[$forum_id][$row['topic_id']]) && $row['topic_last_post_time'] > $topic_tracking_info[$forum_id][$row['topic_id']]) ? true : false;
|
|
indvdum@0
|
879 |
|
|
indvdum@0
|
880 |
$topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $forum_id)) ? true : false;
|
|
indvdum@0
|
881 |
$posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $forum_id)) ? true : false;
|
|
indvdum@0
|
882 |
$u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$result_topic_id", true, $user->session_id) : '';
|
|
indvdum@0
|
883 |
|
|
indvdum@0
|
884 |
$row['topic_title'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">$1</span>', $row['topic_title']);
|
|
indvdum@0
|
885 |
|
|
indvdum@0
|
886 |
$tpl_ary = array(
|
|
indvdum@0
|
887 |
'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
indvdum@0
|
888 |
'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
indvdum@0
|
889 |
'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
indvdum@0
|
890 |
'FIRST_POST_TIME' => $user->format_date($row['topic_time']),
|
|
indvdum@0
|
891 |
'LAST_POST_SUBJECT' => $row['topic_last_post_subject'],
|
|
indvdum@0
|
892 |
'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
|
|
indvdum@0
|
893 |
'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']),
|
|
indvdum@0
|
894 |
'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
indvdum@0
|
895 |
'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
indvdum@0
|
896 |
'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
indvdum@0
|
897 |
|
|
indvdum@0
|
898 |
'PAGINATION' => topic_generate_pagination($replies, $view_topic_url),
|
|
indvdum@0
|
899 |
'TOPIC_TYPE' => $topic_type,
|
|
indvdum@0
|
900 |
|
|
indvdum@0
|
901 |
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
|
|
indvdum@0
|
902 |
'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'),
|
|
indvdum@0
|
903 |
'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt],
|
|
indvdum@0
|
904 |
'TOPIC_FOLDER_IMG_WIDTH'=> $user->img($folder_img, '', false, '', 'width'),
|
|
indvdum@0
|
905 |
'TOPIC_FOLDER_IMG_HEIGHT' => $user->img($folder_img, '', false, '', 'height'),
|
|
indvdum@0
|
906 |
|
|
indvdum@0
|
907 |
'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
|
|
indvdum@0
|
908 |
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
|
|
indvdum@0
|
909 |
'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '',
|
|
indvdum@0
|
910 |
'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
|
indvdum@0
|
911 |
'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '',
|
|
indvdum@0
|
912 |
|
|
indvdum@0
|
913 |
'S_TOPIC_GLOBAL' => (!$forum_id) ? true : false,
|
|
indvdum@0
|
914 |
'S_TOPIC_TYPE' => $row['topic_type'],
|
|
indvdum@0
|
915 |
'S_USER_POSTED' => (!empty($row['topic_posted'])) ? true : false,
|
|
indvdum@0
|
916 |
'S_UNREAD_TOPIC' => $unread_topic,
|
|
indvdum@0
|
917 |
|
|
indvdum@0
|
918 |
'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $forum_id)) ? true : false,
|
|
indvdum@0
|
919 |
'S_TOPIC_UNAPPROVED' => $topic_unapproved,
|
|
indvdum@0
|
920 |
'S_POSTS_UNAPPROVED' => $posts_unapproved,
|
|
indvdum@0
|
921 |
|
|
indvdum@0
|
922 |
'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'],
|
|
indvdum@0
|
923 |
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
indvdum@0
|
924 |
'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
indvdum@0
|
925 |
'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&view=unread') . '#unread',
|
|
indvdum@0
|
926 |
'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=reports&t=' . $result_topic_id, true, $user->session_id),
|
|
indvdum@0
|
927 |
'U_MCP_QUEUE' => $u_mcp_queue,
|
|
indvdum@0
|
928 |
);
|
|
indvdum@0
|
929 |
}
|
|
indvdum@0
|
930 |
else
|
|
indvdum@0
|
931 |
{
|
|
indvdum@0
|
932 |
if ((isset($zebra['foe']) && in_array($row['poster_id'], $zebra['foe'])) && (!$view || $view != 'show' || $post_id != $row['post_id']))
|
|
indvdum@0
|
933 |
{
|
|
indvdum@0
|
934 |
$template->assign_block_vars('searchresults', array(
|
|
indvdum@0
|
935 |
'S_IGNORE_POST' => true,
|
|
indvdum@0
|
936 |
|
|
indvdum@0
|
937 |
'L_IGNORE_POST' => sprintf($user->lang['POST_BY_FOE'], $row['username'], "<a href=\"$u_search&start=$start&p=" . $row['post_id'] . '&view=show#p' . $row['post_id'] . '">', '</a>'))
|
|
indvdum@0
|
938 |
);
|
|
indvdum@0
|
939 |
|
|
indvdum@0
|
940 |
continue;
|
|
indvdum@0
|
941 |
}
|
|
indvdum@0
|
942 |
|
|
indvdum@0
|
943 |
// Replace naughty words such as farty pants
|
|
indvdum@0
|
944 |
$row['post_subject'] = censor_text($row['post_subject']);
|
|
indvdum@0
|
945 |
|
|
indvdum@0
|
946 |
if ($row['display_text_only'])
|
|
indvdum@0
|
947 |
{
|
|
indvdum@0
|
948 |
// now find context for the searched words
|
|
indvdum@0
|
949 |
$row['post_text'] = get_context($row['post_text'], array_filter(explode('|', $hilit), 'strlen'), $return_chars);
|
|
indvdum@0
|
950 |
$row['post_text'] = bbcode_nl2br($row['post_text']);
|
|
indvdum@0
|
951 |
}
|
|
indvdum@0
|
952 |
else
|
|
indvdum@0
|
953 |
{
|
|
indvdum@0
|
954 |
// Second parse bbcode here
|
|
indvdum@0
|
955 |
if ($row['bbcode_bitfield'])
|
|
indvdum@0
|
956 |
{
|
|
indvdum@0
|
957 |
$bbcode->bbcode_second_pass($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield']);
|
|
indvdum@0
|
958 |
}
|
|
indvdum@0
|
959 |
|
|
indvdum@0
|
960 |
$row['post_text'] = bbcode_nl2br($row['post_text']);
|
|
indvdum@0
|
961 |
$row['post_text'] = smiley_text($row['post_text']);
|
|
indvdum@0
|
962 |
|
|
indvdum@0
|
963 |
if (!empty($attachments[$row['post_id']]))
|
|
indvdum@0
|
964 |
{
|
|
indvdum@0
|
965 |
parse_attachments($forum_id, $row['post_text'], $attachments[$row['post_id']], $update_count);
|
|
indvdum@0
|
966 |
|
|
indvdum@0
|
967 |
// we only display inline attachments
|
|
indvdum@0
|
968 |
unset($attachments[$row['post_id']]);
|
|
indvdum@0
|
969 |
}
|
|
indvdum@0
|
970 |
}
|
|
indvdum@0
|
971 |
|
|
indvdum@0
|
972 |
if ($hilit)
|
|
indvdum@0
|
973 |
{
|
|
indvdum@0
|
974 |
// post highlighting
|
|
indvdum@0
|
975 |
$row['post_text'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">$1</span>', $row['post_text']);
|
|
indvdum@0
|
976 |
$row['post_subject'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">$1</span>', $row['post_subject']);
|
|
indvdum@0
|
977 |
}
|
|
indvdum@0
|
978 |
|
|
indvdum@0
|
979 |
$tpl_ary = array(
|
|
indvdum@0
|
980 |
'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
|
indvdum@0
|
981 |
'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
|
indvdum@0
|
982 |
'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
|
indvdum@0
|
983 |
'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
|
indvdum@0
|
984 |
|
|
indvdum@0
|
985 |
'POST_SUBJECT' => $row['post_subject'],
|
|
indvdum@0
|
986 |
'POST_DATE' => (!empty($row['post_time'])) ? $user->format_date($row['post_time']) : '',
|
|
indvdum@0
|
987 |
'MESSAGE' => $row['post_text']
|
|
indvdum@0
|
988 |
);
|
|
indvdum@0
|
989 |
}
|
|
indvdum@0
|
990 |
|
|
indvdum@0
|
991 |
$template->assign_block_vars('searchresults', array_merge($tpl_ary, array(
|
|
indvdum@0
|
992 |
'FORUM_ID' => $forum_id,
|
|
indvdum@0
|
993 |
'TOPIC_ID' => $result_topic_id,
|
|
indvdum@0
|
994 |
'POST_ID' => ($show_results == 'posts') ? $row['post_id'] : false,
|
|
indvdum@0
|
995 |
|
|
indvdum@0
|
996 |
'FORUM_TITLE' => $row['forum_name'],
|
|
indvdum@0
|
997 |
'TOPIC_TITLE' => $topic_title,
|
|
indvdum@0
|
998 |
'TOPIC_REPLIES' => $replies,
|
|
indvdum@0
|
999 |
'TOPIC_VIEWS' => $row['topic_views'],
|
|
indvdum@0
|
1000 |
|
|
indvdum@0
|
1001 |
'U_VIEW_TOPIC' => $view_topic_url,
|
|
indvdum@0
|
1002 |
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
|
|
indvdum@0
|
1003 |
'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'] : '')
|
|
indvdum@0
|
1004 |
));
|
|
indvdum@0
|
1005 |
}
|
|
indvdum@0
|
1006 |
|
|
indvdum@0
|
1007 |
if ($topic_id && ($topic_id == $result_topic_id))
|
|
indvdum@0
|
1008 |
{
|
|
indvdum@0
|
1009 |
$template->assign_vars(array(
|
|
indvdum@0
|
1010 |
'SEARCH_TOPIC' => $topic_title,
|
|
indvdum@0
|
1011 |
'U_SEARCH_TOPIC' => $view_topic_url
|
|
indvdum@0
|
1012 |
));
|
|
indvdum@0
|
1013 |
}
|
|
indvdum@0
|
1014 |
}
|
|
indvdum@0
|
1015 |
unset($rowset);
|
|
indvdum@0
|
1016 |
|
|
indvdum@0
|
1017 |
page_header(($l_search_title) ? $l_search_title : $user->lang['SEARCH']);
|
|
indvdum@0
|
1018 |
|
|
indvdum@0
|
1019 |
$template->set_filenames(array(
|
|
indvdum@0
|
1020 |
'body' => 'search_results.html')
|
|
indvdum@0
|
1021 |
);
|
|
indvdum@0
|
1022 |
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
|
|
indvdum@0
|
1023 |
|
|
indvdum@0
|
1024 |
page_footer();
|
|
indvdum@0
|
1025 |
}
|
|
indvdum@0
|
1026 |
|
|
indvdum@0
|
1027 |
// Search forum
|
|
indvdum@0
|
1028 |
$s_forums = '';
|
|
indvdum@0
|
1029 |
$sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.left_id, f.right_id, f.forum_password, f.enable_indexing, fa.user_id
|
|
indvdum@0
|
1030 |
FROM ' . FORUMS_TABLE . ' f
|
|
indvdum@0
|
1031 |
LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa ON (fa.forum_id = f.forum_id
|
|
indvdum@0
|
1032 |
AND fa.session_id = '" . $db->sql_escape($user->session_id) . "')
|
|
indvdum@0
|
1033 |
ORDER BY f.left_id ASC";
|
|
indvdum@0
|
1034 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1035 |
|
|
indvdum@0
|
1036 |
$right = $cat_right = $padding_inc = 0;
|
|
indvdum@0
|
1037 |
$padding = $forum_list = $holding = '';
|
|
indvdum@0
|
1038 |
$pad_store = array('0' => '');
|
|
indvdum@0
|
1039 |
|
|
indvdum@0
|
1040 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
1041 |
{
|
|
indvdum@0
|
1042 |
if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id']))
|
|
indvdum@0
|
1043 |
{
|
|
indvdum@0
|
1044 |
// Non-postable forum with no subforums, don't display
|
|
indvdum@0
|
1045 |
continue;
|
|
indvdum@0
|
1046 |
}
|
|
indvdum@0
|
1047 |
|
|
indvdum@0
|
1048 |
if ($row['forum_type'] == FORUM_POST && ($row['left_id'] + 1 == $row['right_id']) && !$row['enable_indexing'])
|
|
indvdum@0
|
1049 |
{
|
|
indvdum@0
|
1050 |
// Postable forum with no subforums and indexing disabled, don't display
|
|
indvdum@0
|
1051 |
continue;
|
|
indvdum@0
|
1052 |
}
|
|
indvdum@0
|
1053 |
|
|
indvdum@0
|
1054 |
if ($row['forum_type'] == FORUM_LINK || ($row['forum_password'] && !$row['user_id']))
|
|
indvdum@0
|
1055 |
{
|
|
indvdum@0
|
1056 |
// if this forum is a link or password protected (user has not entered the password yet) then skip to the next branch
|
|
indvdum@0
|
1057 |
continue;
|
|
indvdum@0
|
1058 |
}
|
|
indvdum@0
|
1059 |
|
|
indvdum@0
|
1060 |
if ($row['left_id'] < $right)
|
|
indvdum@0
|
1061 |
{
|
|
indvdum@0
|
1062 |
$padding .= ' ';
|
|
indvdum@0
|
1063 |
$pad_store[$row['parent_id']] = $padding;
|
|
indvdum@0
|
1064 |
}
|
|
indvdum@0
|
1065 |
else if ($row['left_id'] > $right + 1)
|
|
indvdum@0
|
1066 |
{
|
|
indvdum@0
|
1067 |
if (isset($pad_store[$row['parent_id']]))
|
|
indvdum@0
|
1068 |
{
|
|
indvdum@0
|
1069 |
$padding = $pad_store[$row['parent_id']];
|
|
indvdum@0
|
1070 |
}
|
|
indvdum@0
|
1071 |
else
|
|
indvdum@0
|
1072 |
{
|
|
indvdum@0
|
1073 |
continue;
|
|
indvdum@0
|
1074 |
}
|
|
indvdum@0
|
1075 |
}
|
|
indvdum@0
|
1076 |
|
|
indvdum@0
|
1077 |
$right = $row['right_id'];
|
|
indvdum@0
|
1078 |
|
|
indvdum@0
|
1079 |
if ($auth->acl_gets('!f_search', '!f_list', $row['forum_id']))
|
|
indvdum@0
|
1080 |
{
|
|
indvdum@0
|
1081 |
// if the user does not have permissions to search or see this forum skip only this forum/category
|
|
indvdum@0
|
1082 |
continue;
|
|
indvdum@0
|
1083 |
}
|
|
indvdum@0
|
1084 |
|
|
indvdum@0
|
1085 |
$selected = (in_array($row['forum_id'], $search_forum)) ? ' selected="selected"' : '';
|
|
indvdum@0
|
1086 |
|
|
indvdum@0
|
1087 |
if ($row['left_id'] > $cat_right)
|
|
indvdum@0
|
1088 |
{
|
|
indvdum@0
|
1089 |
// make sure we don't forget anything
|
|
indvdum@0
|
1090 |
$s_forums .= $holding;
|
|
indvdum@0
|
1091 |
$holding = '';
|
|
indvdum@0
|
1092 |
}
|
|
indvdum@0
|
1093 |
|
|
indvdum@0
|
1094 |
if ($row['right_id'] - $row['left_id'] > 1)
|
|
indvdum@0
|
1095 |
{
|
|
indvdum@0
|
1096 |
$cat_right = max($cat_right, $row['right_id']);
|
|
indvdum@0
|
1097 |
|
|
indvdum@0
|
1098 |
$holding .= '<option value="' . $row['forum_id'] . '"' . $selected . '>' . $padding . $row['forum_name'] . '</option>';
|
|
indvdum@0
|
1099 |
}
|
|
indvdum@0
|
1100 |
else
|
|
indvdum@0
|
1101 |
{
|
|
indvdum@0
|
1102 |
$s_forums .= $holding . '<option value="' . $row['forum_id'] . '"' . $selected . '>' . $padding . $row['forum_name'] . '</option>';
|
|
indvdum@0
|
1103 |
$holding = '';
|
|
indvdum@0
|
1104 |
}
|
|
indvdum@0
|
1105 |
}
|
|
indvdum@0
|
1106 |
|
|
indvdum@0
|
1107 |
if ($holding)
|
|
indvdum@0
|
1108 |
{
|
|
indvdum@0
|
1109 |
$s_forums .= $holding;
|
|
indvdum@0
|
1110 |
}
|
|
indvdum@0
|
1111 |
|
|
indvdum@0
|
1112 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1113 |
unset($pad_store);
|
|
indvdum@0
|
1114 |
|
|
indvdum@0
|
1115 |
if (!$s_forums)
|
|
indvdum@0
|
1116 |
{
|
|
indvdum@0
|
1117 |
trigger_error('NO_SEARCH');
|
|
indvdum@0
|
1118 |
}
|
|
indvdum@0
|
1119 |
|
|
indvdum@0
|
1120 |
// Number of chars returned
|
|
indvdum@0
|
1121 |
$s_characters = '<option value="-1">' . $user->lang['ALL_AVAILABLE'] . '</option>';
|
|
indvdum@0
|
1122 |
$s_characters .= '<option value="0">0</option>';
|
|
indvdum@0
|
1123 |
$s_characters .= '<option value="25">25</option>';
|
|
indvdum@0
|
1124 |
$s_characters .= '<option value="50">50</option>';
|
|
indvdum@0
|
1125 |
|
|
indvdum@0
|
1126 |
for ($i = 100; $i <= 1000 ; $i += 100)
|
|
indvdum@0
|
1127 |
{
|
|
indvdum@0
|
1128 |
$selected = ($i == 300) ? ' selected="selected"' : '';
|
|
indvdum@0
|
1129 |
$s_characters .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
|
|
indvdum@0
|
1130 |
}
|
|
indvdum@0
|
1131 |
|
|
indvdum@0
|
1132 |
$s_hidden_fields = array('t' => $topic_id);
|
|
indvdum@0
|
1133 |
|
|
indvdum@0
|
1134 |
if ($_SID)
|
|
indvdum@0
|
1135 |
{
|
|
indvdum@0
|
1136 |
$s_hidden_fields['sid'] = $_SID;
|
|
indvdum@0
|
1137 |
}
|
|
indvdum@0
|
1138 |
|
|
indvdum@0
|
1139 |
if (!empty($_EXTRA_URL))
|
|
indvdum@0
|
1140 |
{
|
|
indvdum@0
|
1141 |
foreach ($_EXTRA_URL as $url_param)
|
|
indvdum@0
|
1142 |
{
|
|
indvdum@0
|
1143 |
$url_param = explode('=', $url_param, 2);
|
|
indvdum@0
|
1144 |
$s_hidden_fields[$url_param[0]] = $url_param[1];
|
|
indvdum@0
|
1145 |
}
|
|
indvdum@0
|
1146 |
}
|
|
indvdum@0
|
1147 |
|
|
indvdum@0
|
1148 |
$template->assign_vars(array(
|
|
indvdum@0
|
1149 |
'S_SEARCH_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx", false, true, 0), // We force no ?sid= appending by using 0
|
|
indvdum@0
|
1150 |
'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields),
|
|
indvdum@0
|
1151 |
'S_CHARACTER_OPTIONS' => $s_characters,
|
|
indvdum@0
|
1152 |
'S_FORUM_OPTIONS' => $s_forums,
|
|
indvdum@0
|
1153 |
'S_SELECT_SORT_DIR' => $s_sort_dir,
|
|
indvdum@0
|
1154 |
'S_SELECT_SORT_KEY' => $s_sort_key,
|
|
indvdum@0
|
1155 |
'S_SELECT_SORT_DAYS' => $s_limit_days,
|
|
indvdum@0
|
1156 |
'S_IN_SEARCH' => true,
|
|
indvdum@0
|
1157 |
));
|
|
indvdum@0
|
1158 |
|
|
indvdum@0
|
1159 |
// only show recent searches to search administrators
|
|
indvdum@0
|
1160 |
if ($auth->acl_get('a_search'))
|
|
indvdum@0
|
1161 |
{
|
|
indvdum@0
|
1162 |
// Handle large objects differently for Oracle and MSSQL
|
|
indvdum@0
|
1163 |
switch ($db->sql_layer)
|
|
indvdum@0
|
1164 |
{
|
|
indvdum@0
|
1165 |
case 'oracle':
|
|
indvdum@0
|
1166 |
$sql = 'SELECT search_time, search_keywords
|
|
indvdum@0
|
1167 |
FROM ' . SEARCH_RESULTS_TABLE . '
|
|
indvdum@0
|
1168 |
WHERE dbms_lob.getlength(search_keywords) > 0
|
|
indvdum@0
|
1169 |
ORDER BY search_time DESC';
|
|
indvdum@0
|
1170 |
break;
|
|
indvdum@0
|
1171 |
|
|
indvdum@0
|
1172 |
case 'mssql':
|
|
indvdum@0
|
1173 |
case 'mssql_odbc':
|
|
indvdum@0
|
1174 |
case 'mssqlnative':
|
|
indvdum@0
|
1175 |
$sql = 'SELECT search_time, search_keywords
|
|
indvdum@0
|
1176 |
FROM ' . SEARCH_RESULTS_TABLE . '
|
|
indvdum@0
|
1177 |
WHERE DATALENGTH(search_keywords) > 0
|
|
indvdum@0
|
1178 |
ORDER BY search_time DESC';
|
|
indvdum@0
|
1179 |
break;
|
|
indvdum@0
|
1180 |
|
|
indvdum@0
|
1181 |
default:
|
|
indvdum@0
|
1182 |
$sql = 'SELECT search_time, search_keywords
|
|
indvdum@0
|
1183 |
FROM ' . SEARCH_RESULTS_TABLE . '
|
|
indvdum@0
|
1184 |
WHERE search_keywords <> \'\'
|
|
indvdum@0
|
1185 |
ORDER BY search_time DESC';
|
|
indvdum@0
|
1186 |
break;
|
|
indvdum@0
|
1187 |
}
|
|
indvdum@0
|
1188 |
$result = $db->sql_query_limit($sql, 5);
|
|
indvdum@0
|
1189 |
|
|
indvdum@0
|
1190 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
1191 |
{
|
|
indvdum@0
|
1192 |
$keywords = $row['search_keywords'];
|
|
indvdum@0
|
1193 |
|
|
indvdum@0
|
1194 |
$template->assign_block_vars('recentsearch', array(
|
|
indvdum@0
|
1195 |
'KEYWORDS' => $keywords,
|
|
indvdum@0
|
1196 |
'TIME' => $user->format_date($row['search_time']),
|
|
indvdum@0
|
1197 |
|
|
indvdum@0
|
1198 |
'U_KEYWORDS' => append_sid("{$phpbb_root_path}search.$phpEx", 'keywords=' . urlencode(htmlspecialchars_decode($keywords)))
|
|
indvdum@0
|
1199 |
));
|
|
indvdum@0
|
1200 |
}
|
|
indvdum@0
|
1201 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1202 |
}
|
|
indvdum@0
|
1203 |
|
|
indvdum@0
|
1204 |
// Output the basic page
|
|
indvdum@0
|
1205 |
page_header($user->lang['SEARCH']);
|
|
indvdum@0
|
1206 |
|
|
indvdum@0
|
1207 |
$template->set_filenames(array(
|
|
indvdum@0
|
1208 |
'body' => 'search_body.html')
|
|
indvdum@0
|
1209 |
);
|
|
indvdum@0
|
1210 |
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
|
|
indvdum@0
|
1211 |
|
|
indvdum@0
|
1212 |
page_footer();
|
|
indvdum@0
|
1213 |
|
|
indvdum@0
|
1214 |
?> |