130 |
kaklik |
1 |
<?php |
|
|
2 |
/*************************************************************************** |
|
|
3 |
* search.php |
|
|
4 |
* ------------------- |
|
|
5 |
* begin : Saturday, Feb 13, 2001 |
|
|
6 |
* copyright : (C) 2001 The phpBB Group |
|
|
7 |
* email : support@phpbb.com |
|
|
8 |
* |
|
|
9 |
* $Id: search.php,v 1.72.2.20 2006/05/20 14:01:48 grahamje Exp $ |
|
|
10 |
* |
|
|
11 |
* |
|
|
12 |
***************************************************************************/ |
|
|
13 |
|
|
|
14 |
/*************************************************************************** |
|
|
15 |
* |
|
|
16 |
* This program is free software; you can redistribute it and/or modify |
|
|
17 |
* it under the terms of the GNU General Public License as published by |
|
|
18 |
* the Free Software Foundation; either version 2 of the License, or |
|
|
19 |
* (at your option) any later version. |
|
|
20 |
* |
|
|
21 |
***************************************************************************/ |
|
|
22 |
|
|
|
23 |
define('IN_PHPBB', true); |
|
|
24 |
$phpbb_root_path = './'; |
|
|
25 |
include($phpbb_root_path . 'extension.inc'); |
|
|
26 |
include($phpbb_root_path . 'common.'.$phpEx); |
|
|
27 |
include($phpbb_root_path . 'includes/bbcode.'.$phpEx); |
|
|
28 |
include($phpbb_root_path . 'includes/functions_search.'.$phpEx); |
|
|
29 |
|
|
|
30 |
// |
|
|
31 |
// Start session management |
|
|
32 |
// |
|
|
33 |
$userdata = session_pagestart($user_ip, PAGE_SEARCH); |
|
|
34 |
init_userprefs($userdata); |
|
|
35 |
// |
|
|
36 |
// End session management |
|
|
37 |
// |
|
|
38 |
|
|
|
39 |
// |
|
|
40 |
// Define initial vars |
|
|
41 |
// |
|
|
42 |
if ( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) ) |
|
|
43 |
{ |
|
|
44 |
$mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode']; |
|
|
45 |
} |
|
|
46 |
else |
|
|
47 |
{ |
|
|
48 |
$mode = ''; |
|
|
49 |
} |
|
|
50 |
|
|
|
51 |
if ( isset($HTTP_POST_VARS['search_keywords']) || isset($HTTP_GET_VARS['search_keywords']) ) |
|
|
52 |
{ |
|
|
53 |
$search_keywords = ( isset($HTTP_POST_VARS['search_keywords']) ) ? $HTTP_POST_VARS['search_keywords'] : $HTTP_GET_VARS['search_keywords']; |
|
|
54 |
} |
|
|
55 |
else |
|
|
56 |
{ |
|
|
57 |
$search_keywords = ''; |
|
|
58 |
} |
|
|
59 |
|
|
|
60 |
if ( isset($HTTP_POST_VARS['search_author']) || isset($HTTP_GET_VARS['search_author'])) |
|
|
61 |
{ |
|
|
62 |
$search_author = ( isset($HTTP_POST_VARS['search_author']) ) ? $HTTP_POST_VARS['search_author'] : $HTTP_GET_VARS['search_author']; |
|
|
63 |
$search_author = phpbb_clean_username($search_author); |
|
|
64 |
} |
|
|
65 |
else |
|
|
66 |
{ |
|
|
67 |
$search_author = ''; |
|
|
68 |
} |
|
|
69 |
|
|
|
70 |
$search_id = ( isset($HTTP_GET_VARS['search_id']) ) ? $HTTP_GET_VARS['search_id'] : ''; |
|
|
71 |
|
|
|
72 |
$show_results = ( isset($HTTP_POST_VARS['show_results']) ) ? $HTTP_POST_VARS['show_results'] : 'posts'; |
|
|
73 |
$show_results = ($show_results == 'topics') ? 'topics' : 'posts'; |
|
|
74 |
|
|
|
75 |
if ( isset($HTTP_POST_VARS['search_terms']) ) |
|
|
76 |
{ |
|
|
77 |
$search_terms = ( $HTTP_POST_VARS['search_terms'] == 'all' ) ? 1 : 0; |
|
|
78 |
} |
|
|
79 |
else |
|
|
80 |
{ |
|
|
81 |
$search_terms = 0; |
|
|
82 |
} |
|
|
83 |
|
|
|
84 |
if ( isset($HTTP_POST_VARS['search_fields']) ) |
|
|
85 |
{ |
|
|
86 |
$search_fields = ( $HTTP_POST_VARS['search_fields'] == 'all' ) ? 1 : 0; |
|
|
87 |
} |
|
|
88 |
else |
|
|
89 |
{ |
|
|
90 |
$search_fields = 0; |
|
|
91 |
} |
|
|
92 |
|
|
|
93 |
$return_chars = ( isset($HTTP_POST_VARS['return_chars']) ) ? intval($HTTP_POST_VARS['return_chars']) : 200; |
|
|
94 |
|
|
|
95 |
$search_cat = ( isset($HTTP_POST_VARS['search_cat']) ) ? intval($HTTP_POST_VARS['search_cat']) : -1; |
|
|
96 |
$search_forum = ( isset($HTTP_POST_VARS['search_forum']) ) ? intval($HTTP_POST_VARS['search_forum']) : -1; |
|
|
97 |
|
|
|
98 |
$sort_by = ( isset($HTTP_POST_VARS['sort_by']) ) ? intval($HTTP_POST_VARS['sort_by']) : 0; |
|
|
99 |
|
|
|
100 |
if ( isset($HTTP_POST_VARS['sort_dir']) ) |
|
|
101 |
{ |
|
|
102 |
$sort_dir = ( $HTTP_POST_VARS['sort_dir'] == 'DESC' ) ? 'DESC' : 'ASC'; |
|
|
103 |
} |
|
|
104 |
else |
|
|
105 |
{ |
|
|
106 |
$sort_dir = 'DESC'; |
|
|
107 |
} |
|
|
108 |
|
|
|
109 |
if ( !empty($HTTP_POST_VARS['search_time']) || !empty($HTTP_GET_VARS['search_time'])) |
|
|
110 |
{ |
|
|
111 |
$search_time = time() - ( ( ( !empty($HTTP_POST_VARS['search_time']) ) ? intval($HTTP_POST_VARS['search_time']) : intval($HTTP_GET_VARS['search_time']) ) * 86400 ); |
|
|
112 |
$topic_days = (!empty($HTTP_POST_VARS['search_time'])) ? intval($HTTP_POST_VARS['search_time']) : intval($HTTP_GET_VARS['search_time']); |
|
|
113 |
} |
|
|
114 |
else |
|
|
115 |
{ |
|
|
116 |
$search_time = 0; |
|
|
117 |
$topic_days = 0; |
|
|
118 |
} |
|
|
119 |
|
|
|
120 |
$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0; |
|
|
121 |
|
|
|
122 |
$sort_by_types = array($lang['Sort_Time'], $lang['Sort_Post_Subject'], $lang['Sort_Topic_Title'], $lang['Sort_Author'], $lang['Sort_Forum']); |
|
|
123 |
|
|
|
124 |
// |
|
|
125 |
// encoding match for workaround |
|
|
126 |
// |
|
|
127 |
$multibyte_charset = 'utf-8, big5, shift_jis, euc-kr, gb2312'; |
|
|
128 |
|
|
|
129 |
// |
|
|
130 |
// Begin core code |
|
|
131 |
// |
|
|
132 |
if ( $mode == 'searchuser' ) |
|
|
133 |
{ |
|
|
134 |
// |
|
|
135 |
// This handles the simple windowed user search functions called from various other scripts |
|
|
136 |
// |
|
|
137 |
if ( isset($HTTP_POST_VARS['search_username']) ) |
|
|
138 |
{ |
|
|
139 |
username_search($HTTP_POST_VARS['search_username']); |
|
|
140 |
} |
|
|
141 |
else |
|
|
142 |
{ |
|
|
143 |
username_search(''); |
|
|
144 |
} |
|
|
145 |
|
|
|
146 |
exit; |
|
|
147 |
} |
|
|
148 |
else if ( $search_keywords != '' || $search_author != '' || $search_id ) |
|
|
149 |
{ |
|
|
150 |
$store_vars = array('search_results', 'total_match_count', 'split_search', 'sort_by', 'sort_dir', 'show_results', 'return_chars'); |
|
|
151 |
$search_results = ''; |
|
|
152 |
|
|
|
153 |
// |
|
|
154 |
// Search ID Limiter, decrease this value if you experience further timeout problems with searching forums |
|
|
155 |
$limiter = 5000; |
|
|
156 |
$current_time = time(); |
|
|
157 |
|
|
|
158 |
// |
|
|
159 |
// Cycle through options ... |
|
|
160 |
// |
|
|
161 |
if ( $search_id == 'newposts' || $search_id == 'egosearch' || $search_id == 'unanswered' || $search_keywords != '' || $search_author != '' ) |
|
|
162 |
{ |
|
|
163 |
// |
|
|
164 |
// Flood control |
|
|
165 |
// |
|
|
166 |
$where_sql = ($userdata['user_id'] == ANONYMOUS) ? "se.session_ip = '$user_ip'" : 'se.session_user_id = ' . $userdata['user_id']; |
|
|
167 |
$sql = 'SELECT MAX(sr.search_time) AS last_search_time |
|
|
168 |
FROM ' . SEARCH_TABLE . ' sr, ' . SESSIONS_TABLE . " se |
|
|
169 |
WHERE sr.session_id = se.session_id |
|
|
170 |
AND $where_sql"; |
|
|
171 |
if ($result = $db->sql_query($sql)) |
|
|
172 |
{ |
|
|
173 |
if ($row = $db->sql_fetchrow($result)) |
|
|
174 |
{ |
|
|
175 |
if (intval($row['last_search_time']) > 0 && ($current_time - intval($row['last_search_time'])) < intval($board_config['search_flood_interval'])) |
|
|
176 |
{ |
|
|
177 |
message_die(GENERAL_MESSAGE, $lang['Search_Flood_Error']); |
|
|
178 |
} |
|
|
179 |
} |
|
|
180 |
} |
|
|
181 |
if ( $search_id == 'newposts' || $search_id == 'egosearch' || ( $search_author != '' && $search_keywords == '' ) ) |
|
|
182 |
{ |
|
|
183 |
if ( $search_id == 'newposts' ) |
|
|
184 |
{ |
|
|
185 |
if ( $userdata['session_logged_in'] ) |
|
|
186 |
{ |
|
|
187 |
$sql = "SELECT post_id |
|
|
188 |
FROM " . POSTS_TABLE . " |
|
|
189 |
WHERE post_time >= " . $userdata['user_lastvisit']; |
|
|
190 |
} |
|
|
191 |
else |
|
|
192 |
{ |
|
|
193 |
redirect(append_sid("login.$phpEx?redirect=search.$phpEx&search_id=newposts", true)); |
|
|
194 |
} |
|
|
195 |
|
|
|
196 |
$show_results = 'topics'; |
|
|
197 |
$sort_by = 0; |
|
|
198 |
$sort_dir = 'DESC'; |
|
|
199 |
} |
|
|
200 |
else if ( $search_id == 'egosearch' ) |
|
|
201 |
{ |
|
|
202 |
if ( $userdata['session_logged_in'] ) |
|
|
203 |
{ |
|
|
204 |
$sql = "SELECT post_id |
|
|
205 |
FROM " . POSTS_TABLE . " |
|
|
206 |
WHERE poster_id = " . $userdata['user_id']; |
|
|
207 |
} |
|
|
208 |
else |
|
|
209 |
{ |
|
|
210 |
redirect(append_sid("login.$phpEx?redirect=search.$phpEx&search_id=egosearch", true)); |
|
|
211 |
} |
|
|
212 |
|
|
|
213 |
$show_results = 'topics'; |
|
|
214 |
$sort_by = 0; |
|
|
215 |
$sort_dir = 'DESC'; |
|
|
216 |
} |
|
|
217 |
else |
|
|
218 |
{ |
|
|
219 |
$search_author = str_replace('*', '%', trim($search_author)); |
|
|
220 |
|
|
|
221 |
if( ( strpos($search_author, '%') !== false ) && ( strlen(str_replace('%', '', $search_author)) < $board_config['search_min_chars'] ) ) |
|
|
222 |
{ |
|
|
223 |
$search_author = ''; |
|
|
224 |
} |
|
|
225 |
|
|
|
226 |
$sql = "SELECT user_id |
|
|
227 |
FROM " . USERS_TABLE . " |
|
|
228 |
WHERE username LIKE '" . str_replace("\'", "''", $search_author) . "'"; |
|
|
229 |
if ( !($result = $db->sql_query($sql)) ) |
|
|
230 |
{ |
|
|
231 |
message_die(GENERAL_ERROR, "Couldn't obtain list of matching users (searching for: $search_author)", "", __LINE__, __FILE__, $sql); |
|
|
232 |
} |
|
|
233 |
|
|
|
234 |
$matching_userids = ''; |
|
|
235 |
if ( $row = $db->sql_fetchrow($result) ) |
|
|
236 |
{ |
|
|
237 |
do |
|
|
238 |
{ |
|
|
239 |
$matching_userids .= ( ( $matching_userids != '' ) ? ', ' : '' ) . $row['user_id']; |
|
|
240 |
} |
|
|
241 |
while( $row = $db->sql_fetchrow($result) ); |
|
|
242 |
} |
|
|
243 |
else |
|
|
244 |
{ |
|
|
245 |
message_die(GENERAL_MESSAGE, $lang['No_search_match']); |
|
|
246 |
} |
|
|
247 |
|
|
|
248 |
$sql = "SELECT post_id |
|
|
249 |
FROM " . POSTS_TABLE . " |
|
|
250 |
WHERE poster_id IN ($matching_userids)"; |
|
|
251 |
|
|
|
252 |
if ($search_time) |
|
|
253 |
{ |
|
|
254 |
$sql .= " AND post_time >= " . $search_time; |
|
|
255 |
} |
|
|
256 |
} |
|
|
257 |
|
|
|
258 |
if ( !($result = $db->sql_query($sql)) ) |
|
|
259 |
{ |
|
|
260 |
message_die(GENERAL_ERROR, 'Could not obtain matched posts list', '', __LINE__, __FILE__, $sql); |
|
|
261 |
} |
|
|
262 |
|
|
|
263 |
$search_ids = array(); |
|
|
264 |
while( $row = $db->sql_fetchrow($result) ) |
|
|
265 |
{ |
|
|
266 |
$search_ids[] = $row['post_id']; |
|
|
267 |
} |
|
|
268 |
$db->sql_freeresult($result); |
|
|
269 |
|
|
|
270 |
$total_match_count = count($search_ids); |
|
|
271 |
|
|
|
272 |
} |
|
|
273 |
else if ( $search_keywords != '' ) |
|
|
274 |
{ |
|
|
275 |
$stopword_array = @file($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/search_stopwords.txt'); |
|
|
276 |
$synonym_array = @file($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/search_synonyms.txt'); |
|
|
277 |
|
|
|
278 |
$split_search = array(); |
|
|
279 |
$stripped_keywords = stripslashes($search_keywords); |
|
|
280 |
$split_search = ( !strstr($multibyte_charset, $lang['ENCODING']) ) ? split_words(clean_words('search', $stripped_keywords, $stopword_array, $synonym_array), 'search') : split(' ', $search_keywords); |
|
|
281 |
unset($stripped_keywords); |
|
|
282 |
|
|
|
283 |
$search_msg_only = ( !$search_fields ) ? "AND m.title_match = 0" : ( ( strstr($multibyte_charset, $lang['ENCODING']) ) ? '' : '' ); |
|
|
284 |
|
|
|
285 |
$word_count = 0; |
|
|
286 |
$current_match_type = 'or'; |
|
|
287 |
|
|
|
288 |
$word_match = array(); |
|
|
289 |
$result_list = array(); |
|
|
290 |
|
|
|
291 |
for($i = 0; $i < count($split_search); $i++) |
|
|
292 |
{ |
|
|
293 |
if ( strlen(str_replace(array('*', '%'), '', trim($split_search[$i]))) < $board_config['search_min_chars'] ) |
|
|
294 |
{ |
|
|
295 |
$split_search[$i] = ''; |
|
|
296 |
continue; |
|
|
297 |
} |
|
|
298 |
|
|
|
299 |
switch ( $split_search[$i] ) |
|
|
300 |
{ |
|
|
301 |
case 'and': |
|
|
302 |
$current_match_type = 'and'; |
|
|
303 |
break; |
|
|
304 |
|
|
|
305 |
case 'or': |
|
|
306 |
$current_match_type = 'or'; |
|
|
307 |
break; |
|
|
308 |
|
|
|
309 |
case 'not': |
|
|
310 |
$current_match_type = 'not'; |
|
|
311 |
break; |
|
|
312 |
|
|
|
313 |
default: |
|
|
314 |
if ( !empty($search_terms) ) |
|
|
315 |
{ |
|
|
316 |
$current_match_type = 'and'; |
|
|
317 |
} |
|
|
318 |
|
|
|
319 |
if ( !strstr($multibyte_charset, $lang['ENCODING']) ) |
|
|
320 |
{ |
|
|
321 |
$match_word = str_replace('*', '%', $split_search[$i]); |
|
|
322 |
$sql = "SELECT m.post_id |
|
|
323 |
FROM " . SEARCH_WORD_TABLE . " w, " . SEARCH_MATCH_TABLE . " m |
|
|
324 |
WHERE w.word_text LIKE '$match_word' |
|
|
325 |
AND m.word_id = w.word_id |
|
|
326 |
AND w.word_common <> 1 |
|
|
327 |
$search_msg_only"; |
|
|
328 |
} |
|
|
329 |
else |
|
|
330 |
{ |
|
|
331 |
$match_word = addslashes('%' . str_replace('*', '', $split_search[$i]) . '%'); |
|
|
332 |
$search_msg_only = ( $search_fields ) ? "OR post_subject LIKE '$match_word'" : ''; |
|
|
333 |
$sql = "SELECT post_id |
|
|
334 |
FROM " . POSTS_TEXT_TABLE . " |
|
|
335 |
WHERE post_text LIKE '$match_word' |
|
|
336 |
$search_msg_only"; |
|
|
337 |
} |
|
|
338 |
if ( !($result = $db->sql_query($sql)) ) |
|
|
339 |
{ |
|
|
340 |
message_die(GENERAL_ERROR, 'Could not obtain matched posts list', '', __LINE__, __FILE__, $sql); |
|
|
341 |
} |
|
|
342 |
|
|
|
343 |
$row = array(); |
|
|
344 |
while( $temp_row = $db->sql_fetchrow($result) ) |
|
|
345 |
{ |
|
|
346 |
$row[$temp_row['post_id']] = 1; |
|
|
347 |
|
|
|
348 |
if ( !$word_count ) |
|
|
349 |
{ |
|
|
350 |
$result_list[$temp_row['post_id']] = 1; |
|
|
351 |
} |
|
|
352 |
else if ( $current_match_type == 'or' ) |
|
|
353 |
{ |
|
|
354 |
$result_list[$temp_row['post_id']] = 1; |
|
|
355 |
} |
|
|
356 |
else if ( $current_match_type == 'not' ) |
|
|
357 |
{ |
|
|
358 |
$result_list[$temp_row['post_id']] = 0; |
|
|
359 |
} |
|
|
360 |
} |
|
|
361 |
|
|
|
362 |
if ( $current_match_type == 'and' && $word_count ) |
|
|
363 |
{ |
|
|
364 |
@reset($result_list); |
|
|
365 |
while( list($post_id, $match_count) = @each($result_list) ) |
|
|
366 |
{ |
|
|
367 |
if ( !$row[$post_id] ) |
|
|
368 |
{ |
|
|
369 |
$result_list[$post_id] = 0; |
|
|
370 |
} |
|
|
371 |
} |
|
|
372 |
} |
|
|
373 |
|
|
|
374 |
$word_count++; |
|
|
375 |
|
|
|
376 |
$db->sql_freeresult($result); |
|
|
377 |
} |
|
|
378 |
} |
|
|
379 |
|
|
|
380 |
@reset($result_list); |
|
|
381 |
|
|
|
382 |
$search_ids = array(); |
|
|
383 |
while( list($post_id, $matches) = each($result_list) ) |
|
|
384 |
{ |
|
|
385 |
if ( $matches ) |
|
|
386 |
{ |
|
|
387 |
$search_ids[] = $post_id; |
|
|
388 |
} |
|
|
389 |
} |
|
|
390 |
|
|
|
391 |
unset($result_list); |
|
|
392 |
$total_match_count = count($search_ids); |
|
|
393 |
} |
|
|
394 |
|
|
|
395 |
// |
|
|
396 |
// If user is logged in then we'll check to see which (if any) private |
|
|
397 |
// forums they are allowed to view and include them in the search. |
|
|
398 |
// |
|
|
399 |
// If not logged in we explicitly prevent searching of private forums |
|
|
400 |
// |
|
|
401 |
$auth_sql = ''; |
|
|
402 |
if ( $search_forum != -1 ) |
|
|
403 |
{ |
|
|
404 |
$is_auth = auth(AUTH_READ, $search_forum, $userdata); |
|
|
405 |
|
|
|
406 |
if ( !$is_auth['auth_read'] ) |
|
|
407 |
{ |
|
|
408 |
message_die(GENERAL_MESSAGE, $lang['No_searchable_forums']); |
|
|
409 |
} |
|
|
410 |
|
|
|
411 |
$auth_sql = "f.forum_id = $search_forum"; |
|
|
412 |
} |
|
|
413 |
else |
|
|
414 |
{ |
|
|
415 |
$is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata); |
|
|
416 |
|
|
|
417 |
if ( $search_cat != -1 ) |
|
|
418 |
{ |
|
|
419 |
$auth_sql = "f.cat_id = $search_cat"; |
|
|
420 |
} |
|
|
421 |
|
|
|
422 |
$ignore_forum_sql = ''; |
|
|
423 |
while( list($key, $value) = each($is_auth_ary) ) |
|
|
424 |
{ |
|
|
425 |
if ( !$value['auth_read'] ) |
|
|
426 |
{ |
|
|
427 |
$ignore_forum_sql .= ( ( $ignore_forum_sql != '' ) ? ', ' : '' ) . $key; |
|
|
428 |
} |
|
|
429 |
} |
|
|
430 |
|
|
|
431 |
if ( $ignore_forum_sql != '' ) |
|
|
432 |
{ |
|
|
433 |
$auth_sql .= ( $auth_sql != '' ) ? " AND f.forum_id NOT IN ($ignore_forum_sql) " : "f.forum_id NOT IN ($ignore_forum_sql) "; |
|
|
434 |
} |
|
|
435 |
} |
|
|
436 |
|
|
|
437 |
// |
|
|
438 |
// Author name search |
|
|
439 |
// |
|
|
440 |
if ( $search_author != '' ) |
|
|
441 |
{ |
|
|
442 |
$search_author = str_replace('*', '%', trim($search_author)); |
|
|
443 |
|
|
|
444 |
if( ( strpos($search_author, '%') !== false ) && ( strlen(str_replace('%', '', $search_author)) < $board_config['search_min_chars'] ) ) |
|
|
445 |
{ |
|
|
446 |
$search_author = ''; |
|
|
447 |
} |
|
|
448 |
} |
|
|
449 |
|
|
|
450 |
if ( $total_match_count ) |
|
|
451 |
{ |
|
|
452 |
if ( $show_results == 'topics' ) |
|
|
453 |
{ |
|
|
454 |
// |
|
|
455 |
// This one is a beast, try to seperate it a bit (workaround for connection timeouts) |
|
|
456 |
// |
|
|
457 |
$search_id_chunks = array(); |
|
|
458 |
$count = 0; |
|
|
459 |
$chunk = 0; |
|
|
460 |
|
|
|
461 |
if (count($search_ids) > $limiter) |
|
|
462 |
{ |
|
|
463 |
for ($i = 0; $i < count($search_ids); $i++) |
|
|
464 |
{ |
|
|
465 |
if ($count == $limiter) |
|
|
466 |
{ |
|
|
467 |
$chunk++; |
|
|
468 |
$count = 0; |
|
|
469 |
} |
|
|
470 |
|
|
|
471 |
$search_id_chunks[$chunk][$count] = $search_ids[$i]; |
|
|
472 |
$count++; |
|
|
473 |
} |
|
|
474 |
} |
|
|
475 |
else |
|
|
476 |
{ |
|
|
477 |
$search_id_chunks[0] = $search_ids; |
|
|
478 |
} |
|
|
479 |
|
|
|
480 |
$search_ids = array(); |
|
|
481 |
|
|
|
482 |
for ($i = 0; $i < count($search_id_chunks); $i++) |
|
|
483 |
{ |
|
|
484 |
$where_sql = ''; |
|
|
485 |
|
|
|
486 |
if ( $search_time ) |
|
|
487 |
{ |
|
|
488 |
$where_sql .= ( $search_author == '' && $auth_sql == '' ) ? " AND post_time >= $search_time " : " AND p.post_time >= $search_time "; |
|
|
489 |
} |
|
|
490 |
|
|
|
491 |
if ( $search_author == '' && $auth_sql == '' ) |
|
|
492 |
{ |
|
|
493 |
$sql = "SELECT topic_id |
|
|
494 |
FROM " . POSTS_TABLE . " |
|
|
495 |
WHERE post_id IN (" . implode(", ", $search_id_chunks[$i]) . ") |
|
|
496 |
$where_sql |
|
|
497 |
GROUP BY topic_id"; |
|
|
498 |
} |
|
|
499 |
else |
|
|
500 |
{ |
|
|
501 |
$from_sql = POSTS_TABLE . " p"; |
|
|
502 |
|
|
|
503 |
if ( $search_author != '' ) |
|
|
504 |
{ |
|
|
505 |
$from_sql .= ", " . USERS_TABLE . " u"; |
|
|
506 |
$where_sql .= " AND u.user_id = p.poster_id AND u.username LIKE '$search_author' "; |
|
|
507 |
} |
|
|
508 |
|
|
|
509 |
if ( $auth_sql != '' ) |
|
|
510 |
{ |
|
|
511 |
$from_sql .= ", " . FORUMS_TABLE . " f"; |
|
|
512 |
$where_sql .= " AND f.forum_id = p.forum_id AND $auth_sql"; |
|
|
513 |
} |
|
|
514 |
|
|
|
515 |
$sql = "SELECT p.topic_id |
|
|
516 |
FROM $from_sql |
|
|
517 |
WHERE p.post_id IN (" . implode(", ", $search_id_chunks[$i]) . ") |
|
|
518 |
$where_sql |
|
|
519 |
GROUP BY p.topic_id"; |
|
|
520 |
} |
|
|
521 |
|
|
|
522 |
if ( !($result = $db->sql_query($sql)) ) |
|
|
523 |
{ |
|
|
524 |
message_die(GENERAL_ERROR, 'Could not obtain topic ids', '', __LINE__, __FILE__, $sql); |
|
|
525 |
} |
|
|
526 |
|
|
|
527 |
while ($row = $db->sql_fetchrow($result)) |
|
|
528 |
{ |
|
|
529 |
$search_ids[] = $row['topic_id']; |
|
|
530 |
} |
|
|
531 |
$db->sql_freeresult($result); |
|
|
532 |
} |
|
|
533 |
|
|
|
534 |
$total_match_count = sizeof($search_ids); |
|
|
535 |
|
|
|
536 |
} |
|
|
537 |
else if ( $search_author != '' || $search_time || $auth_sql != '' ) |
|
|
538 |
{ |
|
|
539 |
$search_id_chunks = array(); |
|
|
540 |
$count = 0; |
|
|
541 |
$chunk = 0; |
|
|
542 |
|
|
|
543 |
if (count($search_ids) > $limiter) |
|
|
544 |
{ |
|
|
545 |
for ($i = 0; $i < count($search_ids); $i++) |
|
|
546 |
{ |
|
|
547 |
if ($count == $limiter) |
|
|
548 |
{ |
|
|
549 |
$chunk++; |
|
|
550 |
$count = 0; |
|
|
551 |
} |
|
|
552 |
|
|
|
553 |
$search_id_chunks[$chunk][$count] = $search_ids[$i]; |
|
|
554 |
$count++; |
|
|
555 |
} |
|
|
556 |
} |
|
|
557 |
else |
|
|
558 |
{ |
|
|
559 |
$search_id_chunks[0] = $search_ids; |
|
|
560 |
} |
|
|
561 |
|
|
|
562 |
$search_ids = array(); |
|
|
563 |
|
|
|
564 |
for ($i = 0; $i < count($search_id_chunks); $i++) |
|
|
565 |
{ |
|
|
566 |
$where_sql = ( $search_author == '' && $auth_sql == '' ) ? 'post_id IN (' . implode(', ', $search_id_chunks[$i]) . ')' : 'p.post_id IN (' . implode(', ', $search_id_chunks[$i]) . ')'; |
|
|
567 |
$select_sql = ( $search_author == '' && $auth_sql == '' ) ? 'post_id' : 'p.post_id'; |
|
|
568 |
$from_sql = ( $search_author == '' && $auth_sql == '' ) ? POSTS_TABLE : POSTS_TABLE . ' p'; |
|
|
569 |
|
|
|
570 |
if ( $search_time ) |
|
|
571 |
{ |
|
|
572 |
$where_sql .= ( $search_author == '' && $auth_sql == '' ) ? " AND post_time >= $search_time " : " AND p.post_time >= $search_time"; |
|
|
573 |
} |
|
|
574 |
|
|
|
575 |
if ( $auth_sql != '' ) |
|
|
576 |
{ |
|
|
577 |
$from_sql .= ", " . FORUMS_TABLE . " f"; |
|
|
578 |
$where_sql .= " AND f.forum_id = p.forum_id AND $auth_sql"; |
|
|
579 |
} |
|
|
580 |
|
|
|
581 |
if ( $search_author != '' ) |
|
|
582 |
{ |
|
|
583 |
$from_sql .= ", " . USERS_TABLE . " u"; |
|
|
584 |
$where_sql .= " AND u.user_id = p.poster_id AND u.username LIKE '$search_author'"; |
|
|
585 |
} |
|
|
586 |
|
|
|
587 |
$sql = "SELECT " . $select_sql . " |
|
|
588 |
FROM $from_sql |
|
|
589 |
WHERE $where_sql"; |
|
|
590 |
if ( !($result = $db->sql_query($sql)) ) |
|
|
591 |
{ |
|
|
592 |
message_die(GENERAL_ERROR, 'Could not obtain post ids', '', __LINE__, __FILE__, $sql); |
|
|
593 |
} |
|
|
594 |
|
|
|
595 |
while( $row = $db->sql_fetchrow($result) ) |
|
|
596 |
{ |
|
|
597 |
$search_ids[] = $row['post_id']; |
|
|
598 |
} |
|
|
599 |
$db->sql_freeresult($result); |
|
|
600 |
} |
|
|
601 |
|
|
|
602 |
$total_match_count = count($search_ids); |
|
|
603 |
} |
|
|
604 |
} |
|
|
605 |
else if ( $search_id == 'unanswered' ) |
|
|
606 |
{ |
|
|
607 |
if ( $auth_sql != '' ) |
|
|
608 |
{ |
|
|
609 |
$sql = "SELECT t.topic_id, f.forum_id |
|
|
610 |
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f |
|
|
611 |
WHERE t.topic_replies = 0 |
|
|
612 |
AND t.forum_id = f.forum_id |
|
|
613 |
AND t.topic_moved_id = 0 |
|
|
614 |
AND $auth_sql"; |
|
|
615 |
} |
|
|
616 |
else |
|
|
617 |
{ |
|
|
618 |
$sql = "SELECT topic_id |
|
|
619 |
FROM " . TOPICS_TABLE . " |
|
|
620 |
WHERE topic_replies = 0 |
|
|
621 |
AND topic_moved_id = 0"; |
|
|
622 |
} |
|
|
623 |
|
|
|
624 |
if ( !($result = $db->sql_query($sql)) ) |
|
|
625 |
{ |
|
|
626 |
message_die(GENERAL_ERROR, 'Could not obtain post ids', '', __LINE__, __FILE__, $sql); |
|
|
627 |
} |
|
|
628 |
|
|
|
629 |
$search_ids = array(); |
|
|
630 |
while( $row = $db->sql_fetchrow($result) ) |
|
|
631 |
{ |
|
|
632 |
$search_ids[] = $row['topic_id']; |
|
|
633 |
} |
|
|
634 |
$db->sql_freeresult($result); |
|
|
635 |
|
|
|
636 |
$total_match_count = count($search_ids); |
|
|
637 |
|
|
|
638 |
// |
|
|
639 |
// Basic requirements |
|
|
640 |
// |
|
|
641 |
$show_results = 'topics'; |
|
|
642 |
$sort_by = 0; |
|
|
643 |
$sort_dir = 'DESC'; |
|
|
644 |
} |
|
|
645 |
else |
|
|
646 |
{ |
|
|
647 |
message_die(GENERAL_MESSAGE, $lang['No_search_match']); |
|
|
648 |
} |
|
|
649 |
|
|
|
650 |
// |
|
|
651 |
// Delete old data from the search result table |
|
|
652 |
// |
|
|
653 |
$sql = 'DELETE FROM ' . SEARCH_TABLE . ' |
|
|
654 |
WHERE search_time < ' . ($current_time - (int) $board_config['session_length']); |
|
|
655 |
if ( !$result = $db->sql_query($sql) ) |
|
|
656 |
{ |
|
|
657 |
message_die(GENERAL_ERROR, 'Could not delete old search id sessions', '', __LINE__, __FILE__, $sql); |
|
|
658 |
} |
|
|
659 |
|
|
|
660 |
// |
|
|
661 |
// Store new result data |
|
|
662 |
// |
|
|
663 |
$search_results = implode(', ', $search_ids); |
|
|
664 |
$per_page = ( $show_results == 'posts' ) ? $board_config['posts_per_page'] : $board_config['topics_per_page']; |
|
|
665 |
|
|
|
666 |
// |
|
|
667 |
// Combine both results and search data (apart from original query) |
|
|
668 |
// so we can serialize it and place it in the DB |
|
|
669 |
// |
|
|
670 |
$store_search_data = array(); |
|
|
671 |
|
|
|
672 |
// |
|
|
673 |
// Limit the character length (and with this the results displayed at all following pages) to prevent |
|
|
674 |
// truncated result arrays. Normally, search results above 12000 are affected. |
|
|
675 |
// - to include or not to include |
|
|
676 |
/* |
|
|
677 |
$max_result_length = 60000; |
|
|
678 |
if (strlen($search_results) > $max_result_length) |
|
|
679 |
{ |
|
|
680 |
$search_results = substr($search_results, 0, $max_result_length); |
|
|
681 |
$search_results = substr($search_results, 0, strrpos($search_results, ',')); |
|
|
682 |
$total_match_count = count(explode(', ', $search_results)); |
|
|
683 |
} |
|
|
684 |
*/ |
|
|
685 |
|
|
|
686 |
for($i = 0; $i < count($store_vars); $i++) |
|
|
687 |
{ |
|
|
688 |
$store_search_data[$store_vars[$i]] = $$store_vars[$i]; |
|
|
689 |
} |
|
|
690 |
|
|
|
691 |
$result_array = serialize($store_search_data); |
|
|
692 |
unset($store_search_data); |
|
|
693 |
|
|
|
694 |
mt_srand ((double) microtime() * 1000000); |
|
|
695 |
$search_id = mt_rand(); |
|
|
696 |
|
|
|
697 |
$sql = "UPDATE " . SEARCH_TABLE . " |
|
|
698 |
SET search_id = $search_id, search_time = $current_time, search_array = '" . str_replace("\'", "''", $result_array) . "' |
|
|
699 |
WHERE session_id = '" . $userdata['session_id'] . "'"; |
|
|
700 |
if ( !($result = $db->sql_query($sql)) || !$db->sql_affectedrows() ) |
|
|
701 |
{ |
|
|
702 |
$sql = "INSERT INTO " . SEARCH_TABLE . " (search_id, session_id, search_time, search_array) |
|
|
703 |
VALUES($search_id, '" . $userdata['session_id'] . "', $current_time, '" . str_replace("\'", "''", $result_array) . "')"; |
|
|
704 |
if ( !($result = $db->sql_query($sql)) ) |
|
|
705 |
{ |
|
|
706 |
message_die(GENERAL_ERROR, 'Could not insert search results', '', __LINE__, __FILE__, $sql); |
|
|
707 |
} |
|
|
708 |
} |
|
|
709 |
} |
|
|
710 |
else |
|
|
711 |
{ |
|
|
712 |
$search_id = intval($search_id); |
|
|
713 |
if ( $search_id ) |
|
|
714 |
{ |
|
|
715 |
$sql = "SELECT search_array |
|
|
716 |
FROM " . SEARCH_TABLE . " |
|
|
717 |
WHERE search_id = $search_id |
|
|
718 |
AND session_id = '". $userdata['session_id'] . "'"; |
|
|
719 |
if ( !($result = $db->sql_query($sql)) ) |
|
|
720 |
{ |
|
|
721 |
message_die(GENERAL_ERROR, 'Could not obtain search results', '', __LINE__, __FILE__, $sql); |
|
|
722 |
} |
|
|
723 |
|
|
|
724 |
if ( $row = $db->sql_fetchrow($result) ) |
|
|
725 |
{ |
|
|
726 |
$search_data = unserialize($row['search_array']); |
|
|
727 |
for($i = 0; $i < count($store_vars); $i++) |
|
|
728 |
{ |
|
|
729 |
$$store_vars[$i] = $search_data[$store_vars[$i]]; |
|
|
730 |
} |
|
|
731 |
} |
|
|
732 |
} |
|
|
733 |
} |
|
|
734 |
|
|
|
735 |
// |
|
|
736 |
// Look up data ... |
|
|
737 |
// |
|
|
738 |
if ( $search_results != '' ) |
|
|
739 |
{ |
|
|
740 |
if ( $show_results == 'posts' ) |
|
|
741 |
{ |
|
|
742 |
$sql = "SELECT pt.post_text, pt.bbcode_uid, pt.post_subject, p.*, f.forum_id, f.forum_name, t.*, u.username, u.user_id, u.user_sig, u.user_sig_bbcode_uid |
|
|
743 |
FROM " . FORUMS_TABLE . " f, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TEXT_TABLE . " pt |
|
|
744 |
WHERE p.post_id IN ($search_results) |
|
|
745 |
AND pt.post_id = p.post_id |
|
|
746 |
AND f.forum_id = p.forum_id |
|
|
747 |
AND p.topic_id = t.topic_id |
|
|
748 |
AND p.poster_id = u.user_id"; |
|
|
749 |
} |
|
|
750 |
else |
|
|
751 |
{ |
|
|
752 |
$sql = "SELECT t.*, f.forum_id, f.forum_name, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time |
|
|
753 |
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2 |
|
|
754 |
WHERE t.topic_id IN ($search_results) |
|
|
755 |
AND t.topic_poster = u.user_id |
|
|
756 |
AND f.forum_id = t.forum_id |
|
|
757 |
AND p.post_id = t.topic_first_post_id |
|
|
758 |
AND p2.post_id = t.topic_last_post_id |
|
|
759 |
AND u2.user_id = p2.poster_id"; |
|
|
760 |
} |
|
|
761 |
|
|
|
762 |
$per_page = ( $show_results == 'posts' ) ? $board_config['posts_per_page'] : $board_config['topics_per_page']; |
|
|
763 |
|
|
|
764 |
$sql .= " ORDER BY "; |
|
|
765 |
switch ( $sort_by ) |
|
|
766 |
{ |
|
|
767 |
case 1: |
|
|
768 |
$sql .= ( $show_results == 'posts' ) ? 'pt.post_subject' : 't.topic_title'; |
|
|
769 |
break; |
|
|
770 |
case 2: |
|
|
771 |
$sql .= 't.topic_title'; |
|
|
772 |
break; |
|
|
773 |
case 3: |
|
|
774 |
$sql .= 'u.username'; |
|
|
775 |
break; |
|
|
776 |
case 4: |
|
|
777 |
$sql .= 'f.forum_id'; |
|
|
778 |
break; |
|
|
779 |
default: |
|
|
780 |
$sql .= ( $show_results == 'posts' ) ? 'p.post_time' : 'p2.post_time'; |
|
|
781 |
break; |
|
|
782 |
} |
|
|
783 |
$sql .= " $sort_dir LIMIT $start, " . $per_page; |
|
|
784 |
|
|
|
785 |
if ( !$result = $db->sql_query($sql) ) |
|
|
786 |
{ |
|
|
787 |
message_die(GENERAL_ERROR, 'Could not obtain search results', '', __LINE__, __FILE__, $sql); |
|
|
788 |
} |
|
|
789 |
|
|
|
790 |
$searchset = array(); |
|
|
791 |
while( $row = $db->sql_fetchrow($result) ) |
|
|
792 |
{ |
|
|
793 |
$searchset[] = $row; |
|
|
794 |
} |
|
|
795 |
|
|
|
796 |
$db->sql_freeresult($result); |
|
|
797 |
|
|
|
798 |
// |
|
|
799 |
// Define censored word matches |
|
|
800 |
// |
|
|
801 |
$orig_word = array(); |
|
|
802 |
$replacement_word = array(); |
|
|
803 |
obtain_word_list($orig_word, $replacement_word); |
|
|
804 |
|
|
|
805 |
// |
|
|
806 |
// Output header |
|
|
807 |
// |
|
|
808 |
$page_title = $lang['Search']; |
|
|
809 |
include($phpbb_root_path . 'includes/page_header.'.$phpEx); |
|
|
810 |
|
|
|
811 |
if ( $show_results == 'posts' ) |
|
|
812 |
{ |
|
|
813 |
$template->set_filenames(array( |
|
|
814 |
'body' => 'search_results_posts.tpl') |
|
|
815 |
); |
|
|
816 |
} |
|
|
817 |
else |
|
|
818 |
{ |
|
|
819 |
$template->set_filenames(array( |
|
|
820 |
'body' => 'search_results_topics.tpl') |
|
|
821 |
); |
|
|
822 |
} |
|
|
823 |
make_jumpbox('viewforum.'.$phpEx); |
|
|
824 |
|
|
|
825 |
$l_search_matches = ( $total_match_count == 1 ) ? sprintf($lang['Found_search_match'], $total_match_count) : sprintf($lang['Found_search_matches'], $total_match_count); |
|
|
826 |
|
|
|
827 |
$template->assign_vars(array( |
|
|
828 |
'L_SEARCH_MATCHES' => $l_search_matches, |
|
|
829 |
'L_TOPIC' => $lang['Topic']) |
|
|
830 |
); |
|
|
831 |
|
|
|
832 |
$highlight_active = ''; |
|
|
833 |
$highlight_match = array(); |
|
|
834 |
for($j = 0; $j < count($split_search); $j++ ) |
|
|
835 |
{ |
|
|
836 |
$split_word = $split_search[$j]; |
|
|
837 |
|
|
|
838 |
if ( $split_word != 'and' && $split_word != 'or' && $split_word != 'not' ) |
|
|
839 |
{ |
|
|
840 |
$highlight_match[] = '#\b(' . str_replace("*", "([\w]+)?", $split_word) . ')\b#is'; |
|
|
841 |
$highlight_active .= " " . $split_word; |
|
|
842 |
|
|
|
843 |
for ($k = 0; $k < count($synonym_array); $k++) |
|
|
844 |
{ |
|
|
845 |
list($replace_synonym, $match_synonym) = split(' ', trim(strtolower($synonym_array[$k]))); |
|
|
846 |
|
|
|
847 |
if ( $replace_synonym == $split_word ) |
|
|
848 |
{ |
|
|
849 |
$highlight_match[] = '#\b(' . str_replace("*", "([\w]+)?", $replace_synonym) . ')\b#is'; |
|
|
850 |
$highlight_active .= ' ' . $match_synonym; |
|
|
851 |
} |
|
|
852 |
} |
|
|
853 |
} |
|
|
854 |
} |
|
|
855 |
|
|
|
856 |
$highlight_active = urlencode(trim($highlight_active)); |
|
|
857 |
|
|
|
858 |
$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array(); |
|
|
859 |
$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array(); |
|
|
860 |
|
|
|
861 |
for($i = 0; $i < count($searchset); $i++) |
|
|
862 |
{ |
|
|
863 |
$forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . '=' . $searchset[$i]['forum_id']); |
|
|
864 |
$topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $searchset[$i]['topic_id'] . "&highlight=$highlight_active"); |
|
|
865 |
$post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $searchset[$i]['post_id'] . "&highlight=$highlight_active") . '#' . $searchset[$i]['post_id']; |
|
|
866 |
|
|
|
867 |
$post_date = create_date($board_config['default_dateformat'], $searchset[$i]['post_time'], $board_config['board_timezone']); |
|
|
868 |
|
|
|
869 |
$message = $searchset[$i]['post_text']; |
|
|
870 |
$topic_title = $searchset[$i]['topic_title']; |
|
|
871 |
|
|
|
872 |
$forum_id = $searchset[$i]['forum_id']; |
|
|
873 |
$topic_id = $searchset[$i]['topic_id']; |
|
|
874 |
|
|
|
875 |
if ( $show_results == 'posts' ) |
|
|
876 |
{ |
|
|
877 |
if ( isset($return_chars) ) |
|
|
878 |
{ |
|
|
879 |
$bbcode_uid = $searchset[$i]['bbcode_uid']; |
|
|
880 |
|
|
|
881 |
// |
|
|
882 |
// If the board has HTML off but the post has HTML |
|
|
883 |
// on then we process it, else leave it alone |
|
|
884 |
// |
|
|
885 |
if ( $return_chars != -1 ) |
|
|
886 |
{ |
|
|
887 |
$message = strip_tags($message); |
|
|
888 |
$message = preg_replace("/\[.*?:$bbcode_uid:?.*?\]/si", '', $message); |
|
|
889 |
$message = preg_replace('/\[url\]|\[\/url\]/si', '', $message); |
|
|
890 |
$message = ( strlen($message) > $return_chars ) ? substr($message, 0, $return_chars) . ' ...' : $message; |
|
|
891 |
} |
|
|
892 |
else |
|
|
893 |
{ |
|
|
894 |
if ( !$board_config['allow_html'] ) |
|
|
895 |
{ |
|
|
896 |
if ( $postrow[$i]['enable_html'] ) |
|
|
897 |
{ |
|
|
898 |
$message = preg_replace('#(<)([\/]?.*?)(>)#is', '<\\2>', $message); |
|
|
899 |
} |
|
|
900 |
} |
|
|
901 |
|
|
|
902 |
if ( $bbcode_uid != '' ) |
|
|
903 |
{ |
|
|
904 |
$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message); |
|
|
905 |
} |
|
|
906 |
|
|
|
907 |
$message = make_clickable($message); |
|
|
908 |
|
|
|
909 |
if ( $highlight_active ) |
|
|
910 |
{ |
|
|
911 |
if ( preg_match('/<.*>/', $message) ) |
|
|
912 |
{ |
|
|
913 |
$message = preg_replace($highlight_match, '<!-- #sh -->\1<!-- #eh -->', $message); |
|
|
914 |
|
|
|
915 |
$end_html = 0; |
|
|
916 |
$start_html = 1; |
|
|
917 |
$temp_message = ''; |
|
|
918 |
$message = ' ' . $message . ' '; |
|
|
919 |
|
|
|
920 |
while( $start_html = strpos($message, '<', $start_html) ) |
|
|
921 |
{ |
|
|
922 |
$grab_length = $start_html - $end_html - 1; |
|
|
923 |
$temp_message .= substr($message, $end_html + 1, $grab_length); |
|
|
924 |
|
|
|
925 |
if ( $end_html = strpos($message, '>', $start_html) ) |
|
|
926 |
{ |
|
|
927 |
$length = $end_html - $start_html + 1; |
|
|
928 |
$hold_string = substr($message, $start_html, $length); |
|
|
929 |
|
|
|
930 |
if ( strrpos(' ' . $hold_string, '<') != 1 ) |
|
|
931 |
{ |
|
|
932 |
$end_html = $start_html + 1; |
|
|
933 |
$end_counter = 1; |
|
|
934 |
|
|
|
935 |
while ( $end_counter && $end_html < strlen($message) ) |
|
|
936 |
{ |
|
|
937 |
if ( substr($message, $end_html, 1) == '>' ) |
|
|
938 |
{ |
|
|
939 |
$end_counter--; |
|
|
940 |
} |
|
|
941 |
else if ( substr($message, $end_html, 1) == '<' ) |
|
|
942 |
{ |
|
|
943 |
$end_counter++; |
|
|
944 |
} |
|
|
945 |
|
|
|
946 |
$end_html++; |
|
|
947 |
} |
|
|
948 |
|
|
|
949 |
$length = $end_html - $start_html + 1; |
|
|
950 |
$hold_string = substr($message, $start_html, $length); |
|
|
951 |
$hold_string = str_replace('<!-- #sh -->', '', $hold_string); |
|
|
952 |
$hold_string = str_replace('<!-- #eh -->', '', $hold_string); |
|
|
953 |
} |
|
|
954 |
else if ( $hold_string == '<!-- #sh -->' ) |
|
|
955 |
{ |
|
|
956 |
$hold_string = str_replace('<!-- #sh -->', '<span style="color:#' . $theme['fontcolor3'] . '"><b>', $hold_string); |
|
|
957 |
} |
|
|
958 |
else if ( $hold_string == '<!-- #eh -->' ) |
|
|
959 |
{ |
|
|
960 |
$hold_string = str_replace('<!-- #eh -->', '</b></span>', $hold_string); |
|
|
961 |
} |
|
|
962 |
|
|
|
963 |
$temp_message .= $hold_string; |
|
|
964 |
|
|
|
965 |
$start_html += $length; |
|
|
966 |
} |
|
|
967 |
else |
|
|
968 |
{ |
|
|
969 |
$start_html = strlen($message); |
|
|
970 |
} |
|
|
971 |
} |
|
|
972 |
|
|
|
973 |
$grab_length = strlen($message) - $end_html - 1; |
|
|
974 |
$temp_message .= substr($message, $end_html + 1, $grab_length); |
|
|
975 |
|
|
|
976 |
$message = trim($temp_message); |
|
|
977 |
} |
|
|
978 |
else |
|
|
979 |
{ |
|
|
980 |
$message = preg_replace($highlight_match, '<span style="color:#' . $theme['fontcolor3'] . '"><b>\1</b></span>', $message); |
|
|
981 |
} |
|
|
982 |
} |
|
|
983 |
} |
|
|
984 |
|
|
|
985 |
if ( count($orig_word) ) |
|
|
986 |
{ |
|
|
987 |
$topic_title = preg_replace($orig_word, $replacement_word, $topic_title); |
|
|
988 |
$post_subject = ( $searchset[$i]['post_subject'] != "" ) ? preg_replace($orig_word, $replacement_word, $searchset[$i]['post_subject']) : $topic_title; |
|
|
989 |
|
|
|
990 |
$message = preg_replace($orig_word, $replacement_word, $message); |
|
|
991 |
} |
|
|
992 |
else |
|
|
993 |
{ |
|
|
994 |
$post_subject = ( $searchset[$i]['post_subject'] != '' ) ? $searchset[$i]['post_subject'] : $topic_title; |
|
|
995 |
} |
|
|
996 |
|
|
|
997 |
if ($board_config['allow_smilies'] && $searchset[$i]['enable_smilies']) |
|
|
998 |
{ |
|
|
999 |
$message = smilies_pass($message); |
|
|
1000 |
} |
|
|
1001 |
|
|
|
1002 |
$message = str_replace("\n", '<br />', $message); |
|
|
1003 |
|
|
|
1004 |
} |
|
|
1005 |
|
|
|
1006 |
$poster = ( $searchset[$i]['user_id'] != ANONYMOUS ) ? '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $searchset[$i]['user_id']) . '">' : ''; |
|
|
1007 |
$poster .= ( $searchset[$i]['user_id'] != ANONYMOUS ) ? $searchset[$i]['username'] : ( ( $searchset[$i]['post_username'] != "" ) ? $searchset[$i]['post_username'] : $lang['Guest'] ); |
|
|
1008 |
$poster .= ( $searchset[$i]['user_id'] != ANONYMOUS ) ? '</a>' : ''; |
|
|
1009 |
|
|
|
1010 |
if ( $userdata['session_logged_in'] && $searchset[$i]['post_time'] > $userdata['user_lastvisit'] ) |
|
|
1011 |
{ |
|
|
1012 |
if ( !empty($tracking_topics[$topic_id]) && !empty($tracking_forums[$forum_id]) ) |
|
|
1013 |
{ |
|
|
1014 |
$topic_last_read = ( $tracking_topics[$topic_id] > $tracking_forums[$forum_id] ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id]; |
|
|
1015 |
} |
|
|
1016 |
else if ( !empty($tracking_topics[$topic_id]) || !empty($tracking_forums[$forum_id]) ) |
|
|
1017 |
{ |
|
|
1018 |
$topic_last_read = ( !empty($tracking_topics[$topic_id]) ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id]; |
|
|
1019 |
} |
|
|
1020 |
|
|
|
1021 |
if ( $searchset[$i]['post_time'] > $topic_last_read ) |
|
|
1022 |
{ |
|
|
1023 |
$mini_post_img = $images['icon_minipost_new']; |
|
|
1024 |
$mini_post_alt = $lang['New_post']; |
|
|
1025 |
} |
|
|
1026 |
else |
|
|
1027 |
{ |
|
|
1028 |
$mini_post_img = $images['icon_minipost']; |
|
|
1029 |
$mini_post_alt = $lang['Post']; |
|
|
1030 |
} |
|
|
1031 |
} |
|
|
1032 |
else |
|
|
1033 |
{ |
|
|
1034 |
$mini_post_img = $images['icon_minipost']; |
|
|
1035 |
$mini_post_alt = $lang['Post']; |
|
|
1036 |
} |
|
|
1037 |
|
|
|
1038 |
$template->assign_block_vars("searchresults", array( |
|
|
1039 |
'TOPIC_TITLE' => $topic_title, |
|
|
1040 |
'FORUM_NAME' => $searchset[$i]['forum_name'], |
|
|
1041 |
'POST_SUBJECT' => $post_subject, |
|
|
1042 |
'POST_DATE' => $post_date, |
|
|
1043 |
'POSTER_NAME' => $poster, |
|
|
1044 |
'TOPIC_REPLIES' => $searchset[$i]['topic_replies'], |
|
|
1045 |
'TOPIC_VIEWS' => $searchset[$i]['topic_views'], |
|
|
1046 |
'MESSAGE' => $message, |
|
|
1047 |
'MINI_POST_IMG' => $mini_post_img, |
|
|
1048 |
|
|
|
1049 |
'L_MINI_POST_ALT' => $mini_post_alt, |
|
|
1050 |
|
|
|
1051 |
'U_POST' => $post_url, |
|
|
1052 |
'U_TOPIC' => $topic_url, |
|
|
1053 |
'U_FORUM' => $forum_url) |
|
|
1054 |
); |
|
|
1055 |
} |
|
|
1056 |
else |
|
|
1057 |
{ |
|
|
1058 |
$message = ''; |
|
|
1059 |
|
|
|
1060 |
if ( count($orig_word) ) |
|
|
1061 |
{ |
|
|
1062 |
$topic_title = preg_replace($orig_word, $replacement_word, $searchset[$i]['topic_title']); |
|
|
1063 |
} |
|
|
1064 |
|
|
|
1065 |
$topic_type = $searchset[$i]['topic_type']; |
|
|
1066 |
|
|
|
1067 |
if ($topic_type == POST_ANNOUNCE) |
|
|
1068 |
{ |
|
|
1069 |
$topic_type = $lang['Topic_Announcement'] . ' '; |
|
|
1070 |
} |
|
|
1071 |
else if ($topic_type == POST_STICKY) |
|
|
1072 |
{ |
|
|
1073 |
$topic_type = $lang['Topic_Sticky'] . ' '; |
|
|
1074 |
} |
|
|
1075 |
else |
|
|
1076 |
{ |
|
|
1077 |
$topic_type = ''; |
|
|
1078 |
} |
|
|
1079 |
|
|
|
1080 |
if ( $searchset[$i]['topic_vote'] ) |
|
|
1081 |
{ |
|
|
1082 |
$topic_type .= $lang['Topic_Poll'] . ' '; |
|
|
1083 |
} |
|
|
1084 |
|
|
|
1085 |
$views = $searchset[$i]['topic_views']; |
|
|
1086 |
$replies = $searchset[$i]['topic_replies']; |
|
|
1087 |
|
|
|
1088 |
if ( ( $replies + 1 ) > $board_config['posts_per_page'] ) |
|
|
1089 |
{ |
|
|
1090 |
$total_pages = ceil( ( $replies + 1 ) / $board_config['posts_per_page'] ); |
|
|
1091 |
$goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['Goto_page'] . '" title="' . $lang['Goto_page'] . '" />' . $lang['Goto_page'] . ': '; |
|
|
1092 |
|
|
|
1093 |
$times = 1; |
|
|
1094 |
for($j = 0; $j < $replies + 1; $j += $board_config['posts_per_page']) |
|
|
1095 |
{ |
|
|
1096 |
$goto_page .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_id . "&start=$j") . '">' . $times . '</a>'; |
|
|
1097 |
if ( $times == 1 && $total_pages > 4 ) |
|
|
1098 |
{ |
|
|
1099 |
$goto_page .= ' ... '; |
|
|
1100 |
$times = $total_pages - 3; |
|
|
1101 |
$j += ( $total_pages - 4 ) * $board_config['posts_per_page']; |
|
|
1102 |
} |
|
|
1103 |
else if ( $times < $total_pages ) |
|
|
1104 |
{ |
|
|
1105 |
$goto_page .= ', '; |
|
|
1106 |
} |
|
|
1107 |
$times++; |
|
|
1108 |
} |
|
|
1109 |
$goto_page .= ' ] '; |
|
|
1110 |
} |
|
|
1111 |
else |
|
|
1112 |
{ |
|
|
1113 |
$goto_page = ''; |
|
|
1114 |
} |
|
|
1115 |
|
|
|
1116 |
if ( $searchset[$i]['topic_status'] == TOPIC_MOVED ) |
|
|
1117 |
{ |
|
|
1118 |
$topic_type = $lang['Topic_Moved'] . ' '; |
|
|
1119 |
$topic_id = $searchset[$i]['topic_moved_id']; |
|
|
1120 |
|
|
|
1121 |
$folder_image = '<img src="' . $images['folder'] . '" alt="' . $lang['No_new_posts'] . '" />'; |
|
|
1122 |
$newest_post_img = ''; |
|
|
1123 |
} |
|
|
1124 |
else |
|
|
1125 |
{ |
|
|
1126 |
if ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) |
|
|
1127 |
{ |
|
|
1128 |
$folder = $images['folder_locked']; |
|
|
1129 |
$folder_new = $images['folder_locked_new']; |
|
|
1130 |
} |
|
|
1131 |
else if ( $searchset[$i]['topic_type'] == POST_ANNOUNCE ) |
|
|
1132 |
{ |
|
|
1133 |
$folder = $images['folder_announce']; |
|
|
1134 |
$folder_new = $images['folder_announce_new']; |
|
|
1135 |
} |
|
|
1136 |
else if ( $searchset[$i]['topic_type'] == POST_STICKY ) |
|
|
1137 |
{ |
|
|
1138 |
$folder = $images['folder_sticky']; |
|
|
1139 |
$folder_new = $images['folder_sticky_new']; |
|
|
1140 |
} |
|
|
1141 |
else |
|
|
1142 |
{ |
|
|
1143 |
if ( $replies >= $board_config['hot_threshold'] ) |
|
|
1144 |
{ |
|
|
1145 |
$folder = $images['folder_hot']; |
|
|
1146 |
$folder_new = $images['folder_hot_new']; |
|
|
1147 |
} |
|
|
1148 |
else |
|
|
1149 |
{ |
|
|
1150 |
$folder = $images['folder']; |
|
|
1151 |
$folder_new = $images['folder_new']; |
|
|
1152 |
} |
|
|
1153 |
} |
|
|
1154 |
|
|
|
1155 |
if ( $userdata['session_logged_in'] ) |
|
|
1156 |
{ |
|
|
1157 |
if ( $searchset[$i]['post_time'] > $userdata['user_lastvisit'] ) |
|
|
1158 |
{ |
|
|
1159 |
if ( !empty($tracking_topics) || !empty($tracking_forums) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) ) |
|
|
1160 |
{ |
|
|
1161 |
|
|
|
1162 |
$unread_topics = true; |
|
|
1163 |
|
|
|
1164 |
if ( !empty($tracking_topics[$topic_id]) ) |
|
|
1165 |
{ |
|
|
1166 |
if ( $tracking_topics[$topic_id] > $searchset[$i]['post_time'] ) |
|
|
1167 |
{ |
|
|
1168 |
$unread_topics = false; |
|
|
1169 |
} |
|
|
1170 |
} |
|
|
1171 |
|
|
|
1172 |
if ( !empty($tracking_forums[$forum_id]) ) |
|
|
1173 |
{ |
|
|
1174 |
if ( $tracking_forums[$forum_id] > $searchset[$i]['post_time'] ) |
|
|
1175 |
{ |
|
|
1176 |
$unread_topics = false; |
|
|
1177 |
} |
|
|
1178 |
} |
|
|
1179 |
|
|
|
1180 |
if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) ) |
|
|
1181 |
{ |
|
|
1182 |
if ( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] > $searchset[$i]['post_time'] ) |
|
|
1183 |
{ |
|
|
1184 |
$unread_topics = false; |
|
|
1185 |
} |
|
|
1186 |
} |
|
|
1187 |
|
|
|
1188 |
if ( $unread_topics ) |
|
|
1189 |
{ |
|
|
1190 |
$folder_image = $folder_new; |
|
|
1191 |
$folder_alt = $lang['New_posts']; |
|
|
1192 |
|
|
|
1193 |
$newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> '; |
|
|
1194 |
} |
|
|
1195 |
else |
|
|
1196 |
{ |
|
|
1197 |
$folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts']; |
|
|
1198 |
|
|
|
1199 |
$folder_image = $folder; |
|
|
1200 |
$folder_alt = $folder_alt; |
|
|
1201 |
$newest_post_img = ''; |
|
|
1202 |
} |
|
|
1203 |
|
|
|
1204 |
} |
|
|
1205 |
else if ( $searchset[$i]['post_time'] > $userdata['user_lastvisit'] ) |
|
|
1206 |
{ |
|
|
1207 |
$folder_image = $folder_new; |
|
|
1208 |
$folder_alt = $lang['New_posts']; |
|
|
1209 |
|
|
|
1210 |
$newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> '; |
|
|
1211 |
} |
|
|
1212 |
else |
|
|
1213 |
{ |
|
|
1214 |
$folder_image = $folder; |
|
|
1215 |
$folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts']; |
|
|
1216 |
$newest_post_img = ''; |
|
|
1217 |
} |
|
|
1218 |
} |
|
|
1219 |
else |
|
|
1220 |
{ |
|
|
1221 |
$folder_image = $folder; |
|
|
1222 |
$folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts']; |
|
|
1223 |
$newest_post_img = ''; |
|
|
1224 |
} |
|
|
1225 |
} |
|
|
1226 |
else |
|
|
1227 |
{ |
|
|
1228 |
$folder_image = $folder; |
|
|
1229 |
$folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts']; |
|
|
1230 |
$newest_post_img = ''; |
|
|
1231 |
} |
|
|
1232 |
} |
|
|
1233 |
|
|
|
1234 |
|
|
|
1235 |
$topic_author = ( $searchset[$i]['user_id'] != ANONYMOUS ) ? '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '=' . $searchset[$i]['user_id']) . '">' : ''; |
|
|
1236 |
$topic_author .= ( $searchset[$i]['user_id'] != ANONYMOUS ) ? $searchset[$i]['username'] : ( ( $searchset[$i]['post_username'] != '' ) ? $searchset[$i]['post_username'] : $lang['Guest'] ); |
|
|
1237 |
|
|
|
1238 |
$topic_author .= ( $searchset[$i]['user_id'] != ANONYMOUS ) ? '</a>' : ''; |
|
|
1239 |
|
|
|
1240 |
$first_post_time = create_date($board_config['default_dateformat'], $searchset[$i]['topic_time'], $board_config['board_timezone']); |
|
|
1241 |
|
|
|
1242 |
$last_post_time = create_date($board_config['default_dateformat'], $searchset[$i]['post_time'], $board_config['board_timezone']); |
|
|
1243 |
|
|
|
1244 |
$last_post_author = ( $searchset[$i]['id2'] == ANONYMOUS ) ? ( ($searchset[$i]['post_username2'] != '' ) ? $searchset[$i]['post_username2'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '=' . $searchset[$i]['id2']) . '">' . $searchset[$i]['user2'] . '</a>'; |
|
|
1245 |
|
|
|
1246 |
$last_post_url = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $searchset[$i]['topic_last_post_id']) . '#' . $searchset[$i]['topic_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" border="0" /></a>'; |
|
|
1247 |
|
|
|
1248 |
$template->assign_block_vars('searchresults', array( |
|
|
1249 |
'FORUM_NAME' => $searchset[$i]['forum_name'], |
|
|
1250 |
'FORUM_ID' => $forum_id, |
|
|
1251 |
'TOPIC_ID' => $topic_id, |
|
|
1252 |
'FOLDER' => $folder_image, |
|
|
1253 |
'NEWEST_POST_IMG' => $newest_post_img, |
|
|
1254 |
'TOPIC_FOLDER_IMG' => $folder_image, |
|
|
1255 |
'GOTO_PAGE' => $goto_page, |
|
|
1256 |
'REPLIES' => $replies, |
|
|
1257 |
'TOPIC_TITLE' => $topic_title, |
|
|
1258 |
'TOPIC_TYPE' => $topic_type, |
|
|
1259 |
'VIEWS' => $views, |
|
|
1260 |
'TOPIC_AUTHOR' => $topic_author, |
|
|
1261 |
'FIRST_POST_TIME' => $first_post_time, |
|
|
1262 |
'LAST_POST_TIME' => $last_post_time, |
|
|
1263 |
'LAST_POST_AUTHOR' => $last_post_author, |
|
|
1264 |
'LAST_POST_IMG' => $last_post_url, |
|
|
1265 |
|
|
|
1266 |
'L_TOPIC_FOLDER_ALT' => $folder_alt, |
|
|
1267 |
|
|
|
1268 |
'U_VIEW_FORUM' => $forum_url, |
|
|
1269 |
'U_VIEW_TOPIC' => $topic_url) |
|
|
1270 |
); |
|
|
1271 |
} |
|
|
1272 |
} |
|
|
1273 |
|
|
|
1274 |
$base_url = "search.$phpEx?search_id=$search_id"; |
|
|
1275 |
|
|
|
1276 |
$template->assign_vars(array( |
|
|
1277 |
'PAGINATION' => generate_pagination($base_url, $total_match_count, $per_page, $start), |
|
|
1278 |
'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $per_page ) + 1 ), ceil( $total_match_count / $per_page )), |
|
|
1279 |
|
|
|
1280 |
'L_AUTHOR' => $lang['Author'], |
|
|
1281 |
'L_MESSAGE' => $lang['Message'], |
|
|
1282 |
'L_FORUM' => $lang['Forum'], |
|
|
1283 |
'L_TOPICS' => $lang['Topics'], |
|
|
1284 |
'L_REPLIES' => $lang['Replies'], |
|
|
1285 |
'L_VIEWS' => $lang['Views'], |
|
|
1286 |
'L_POSTS' => $lang['Posts'], |
|
|
1287 |
'L_LASTPOST' => $lang['Last_Post'], |
|
|
1288 |
'L_POSTED' => $lang['Posted'], |
|
|
1289 |
'L_SUBJECT' => $lang['Subject'], |
|
|
1290 |
|
|
|
1291 |
'L_GOTO_PAGE' => $lang['Goto_page']) |
|
|
1292 |
); |
|
|
1293 |
|
|
|
1294 |
$template->pparse('body'); |
|
|
1295 |
|
|
|
1296 |
include($phpbb_root_path . 'includes/page_tail.'.$phpEx); |
|
|
1297 |
} |
|
|
1298 |
else |
|
|
1299 |
{ |
|
|
1300 |
message_die(GENERAL_MESSAGE, $lang['No_search_match']); |
|
|
1301 |
} |
|
|
1302 |
} |
|
|
1303 |
|
|
|
1304 |
// |
|
|
1305 |
// Search forum |
|
|
1306 |
// |
|
|
1307 |
$sql = "SELECT c.cat_title, c.cat_id, f.forum_name, f.forum_id |
|
|
1308 |
FROM " . CATEGORIES_TABLE . " c, " . FORUMS_TABLE . " f |
|
|
1309 |
WHERE f.cat_id = c.cat_id |
|
|
1310 |
ORDER BY c.cat_order, f.forum_order"; |
|
|
1311 |
$result = $db->sql_query($sql); |
|
|
1312 |
if ( !$result ) |
|
|
1313 |
{ |
|
|
1314 |
message_die(GENERAL_ERROR, 'Could not obtain forum_name/forum_id', '', __LINE__, __FILE__, $sql); |
|
|
1315 |
} |
|
|
1316 |
|
|
|
1317 |
$is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata); |
|
|
1318 |
|
|
|
1319 |
$s_forums = ''; |
|
|
1320 |
while( $row = $db->sql_fetchrow($result) ) |
|
|
1321 |
{ |
|
|
1322 |
if ( $is_auth_ary[$row['forum_id']]['auth_read'] ) |
|
|
1323 |
{ |
|
|
1324 |
$s_forums .= '<option value="' . $row['forum_id'] . '">' . $row['forum_name'] . '</option>'; |
|
|
1325 |
if ( empty($list_cat[$row['cat_id']]) ) |
|
|
1326 |
{ |
|
|
1327 |
$list_cat[$row['cat_id']] = $row['cat_title']; |
|
|
1328 |
} |
|
|
1329 |
} |
|
|
1330 |
} |
|
|
1331 |
|
|
|
1332 |
if ( $s_forums != '' ) |
|
|
1333 |
{ |
|
|
1334 |
$s_forums = '<option value="-1">' . $lang['All_available'] . '</option>' . $s_forums; |
|
|
1335 |
|
|
|
1336 |
// |
|
|
1337 |
// Category to search |
|
|
1338 |
// |
|
|
1339 |
$s_categories = '<option value="-1">' . $lang['All_available'] . '</option>'; |
|
|
1340 |
while( list($cat_id, $cat_title) = @each($list_cat)) |
|
|
1341 |
{ |
|
|
1342 |
$s_categories .= '<option value="' . $cat_id . '">' . $cat_title . '</option>'; |
|
|
1343 |
} |
|
|
1344 |
} |
|
|
1345 |
else |
|
|
1346 |
{ |
|
|
1347 |
message_die(GENERAL_MESSAGE, $lang['No_searchable_forums']); |
|
|
1348 |
} |
|
|
1349 |
|
|
|
1350 |
// |
|
|
1351 |
// Number of chars returned |
|
|
1352 |
// |
|
|
1353 |
$s_characters = '<option value="-1">' . $lang['All_available'] . '</option>'; |
|
|
1354 |
$s_characters .= '<option value="0">0</option>'; |
|
|
1355 |
$s_characters .= '<option value="25">25</option>'; |
|
|
1356 |
$s_characters .= '<option value="50">50</option>'; |
|
|
1357 |
|
|
|
1358 |
for($i = 100; $i < 1100 ; $i += 100) |
|
|
1359 |
{ |
|
|
1360 |
$selected = ( $i == 200 ) ? ' selected="selected"' : ''; |
|
|
1361 |
$s_characters .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>'; |
|
|
1362 |
} |
|
|
1363 |
|
|
|
1364 |
// |
|
|
1365 |
// Sorting |
|
|
1366 |
// |
|
|
1367 |
$s_sort_by = ""; |
|
|
1368 |
for($i = 0; $i < count($sort_by_types); $i++) |
|
|
1369 |
{ |
|
|
1370 |
$s_sort_by .= '<option value="' . $i . '">' . $sort_by_types[$i] . '</option>'; |
|
|
1371 |
} |
|
|
1372 |
|
|
|
1373 |
// |
|
|
1374 |
// Search time |
|
|
1375 |
// |
|
|
1376 |
$previous_days = array(0, 1, 7, 14, 30, 90, 180, 364); |
|
|
1377 |
$previous_days_text = array($lang['All_Posts'], $lang['1_Day'], $lang['7_Days'], $lang['2_Weeks'], $lang['1_Month'], $lang['3_Months'], $lang['6_Months'], $lang['1_Year']); |
|
|
1378 |
|
|
|
1379 |
$s_time = ''; |
|
|
1380 |
for($i = 0; $i < count($previous_days); $i++) |
|
|
1381 |
{ |
|
|
1382 |
$selected = ( $topic_days == $previous_days[$i] ) ? ' selected="selected"' : ''; |
|
|
1383 |
$s_time .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>'; |
|
|
1384 |
} |
|
|
1385 |
|
|
|
1386 |
// |
|
|
1387 |
// Output the basic page |
|
|
1388 |
// |
|
|
1389 |
$page_title = $lang['Search']; |
|
|
1390 |
include($phpbb_root_path . 'includes/page_header.'.$phpEx); |
|
|
1391 |
|
|
|
1392 |
$template->set_filenames(array( |
|
|
1393 |
'body' => 'search_body.tpl') |
|
|
1394 |
); |
|
|
1395 |
make_jumpbox('viewforum.'.$phpEx); |
|
|
1396 |
|
|
|
1397 |
$template->assign_vars(array( |
|
|
1398 |
'L_SEARCH_QUERY' => $lang['Search_query'], |
|
|
1399 |
'L_SEARCH_OPTIONS' => $lang['Search_options'], |
|
|
1400 |
'L_SEARCH_KEYWORDS' => $lang['Search_keywords'], |
|
|
1401 |
'L_SEARCH_KEYWORDS_EXPLAIN' => $lang['Search_keywords_explain'], |
|
|
1402 |
'L_SEARCH_AUTHOR' => $lang['Search_author'], |
|
|
1403 |
'L_SEARCH_AUTHOR_EXPLAIN' => $lang['Search_author_explain'], |
|
|
1404 |
'L_SEARCH_ANY_TERMS' => $lang['Search_for_any'], |
|
|
1405 |
'L_SEARCH_ALL_TERMS' => $lang['Search_for_all'], |
|
|
1406 |
'L_SEARCH_MESSAGE_ONLY' => $lang['Search_msg_only'], |
|
|
1407 |
'L_SEARCH_MESSAGE_TITLE' => $lang['Search_title_msg'], |
|
|
1408 |
'L_CATEGORY' => $lang['Category'], |
|
|
1409 |
'L_RETURN_FIRST' => $lang['Return_first'], |
|
|
1410 |
'L_CHARACTERS' => $lang['characters_posts'], |
|
|
1411 |
'L_SORT_BY' => $lang['Sort_by'], |
|
|
1412 |
'L_SORT_ASCENDING' => $lang['Sort_Ascending'], |
|
|
1413 |
'L_SORT_DESCENDING' => $lang['Sort_Descending'], |
|
|
1414 |
'L_SEARCH_PREVIOUS' => $lang['Search_previous'], |
|
|
1415 |
'L_DISPLAY_RESULTS' => $lang['Display_results'], |
|
|
1416 |
'L_FORUM' => $lang['Forum'], |
|
|
1417 |
'L_TOPICS' => $lang['Topics'], |
|
|
1418 |
'L_POSTS' => $lang['Posts'], |
|
|
1419 |
|
|
|
1420 |
'S_SEARCH_ACTION' => append_sid("search.$phpEx?mode=results"), |
|
|
1421 |
'S_CHARACTER_OPTIONS' => $s_characters, |
|
|
1422 |
'S_FORUM_OPTIONS' => $s_forums, |
|
|
1423 |
'S_CATEGORY_OPTIONS' => $s_categories, |
|
|
1424 |
'S_TIME_OPTIONS' => $s_time, |
|
|
1425 |
'S_SORT_OPTIONS' => $s_sort_by, |
|
|
1426 |
'S_HIDDEN_FIELDS' => '') |
|
|
1427 |
); |
|
|
1428 |
|
|
|
1429 |
$template->pparse('body'); |
|
|
1430 |
|
|
|
1431 |
include($phpbb_root_path . 'includes/page_tail.'.$phpEx); |
|
|
1432 |
|
|
|
1433 |
?> |