root / tags / milestone_3 / phpBB / search.php
History | View | Annotate | Download (22.6 kB)
| 1 | 1350 | psotfx | <?php
|
|---|---|---|---|
| 2 | 5114 | acydburn | /**
|
| 3 | 5114 | acydburn | * |
| 4 | 5114 | acydburn | * @package phpBB3 |
| 5 | 5114 | acydburn | * @version $Id$ |
| 6 | 5114 | acydburn | * @copyright (c) 2005 phpBB Group |
| 7 | 5114 | acydburn | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
| 8 | 5114 | acydburn | * |
| 9 | 5114 | acydburn | */ |
| 10 | 368 | psotfx | |
| 11 | 5114 | acydburn | /**
|
| 12 | 5114 | acydburn | */ |
| 13 | 2305 | psotfx | define('IN_PHPBB', true); |
| 14 | 2448 | psotfx | $phpbb_root_path = './'; |
| 15 | 4500 | psotfx | $phpEx = substr(strrchr(__FILE__, '.'), 1); |
| 16 | 646 | psotfx | include($phpbb_root_path . 'common.'.$phpEx); |
| 17 | 368 | psotfx | |
| 18 | 4970 | psotfx | // Start session management
|
| 19 | 5236 | acydburn | $user->session_begin();
|
| 20 | 4970 | psotfx | $auth->acl($user->data); |
| 21 | 4970 | psotfx | $user->setup('search'); |
| 22 | 4970 | psotfx | |
| 23 | 4500 | psotfx | // Define initial vars
|
| 24 | 4970 | psotfx | $mode = request_var('mode', ''); |
| 25 | 4970 | psotfx | $search_id = request_var('search_id', ''); |
| 26 | 5161 | acydburn | $search_session_id = request_var('search_session_id', 0); |
| 27 | 4970 | psotfx | $start = request_var('start', 0); |
| 28 | 4970 | psotfx | $post_id = request_var('p', 0); |
| 29 | 4970 | psotfx | $view = request_var('view', ''); |
| 30 | 4500 | psotfx | |
| 31 | 5236 | acydburn | $keywords = request_var('keywords', ''); |
| 32 | 5236 | acydburn | $author = request_var('author', ''); |
| 33 | 5236 | acydburn | $show_results = request_var('show_results', 'topics'); |
| 34 | 5236 | acydburn | $search_terms = request_var('search_terms', 'all'); |
| 35 | 5236 | acydburn | $search_fields = request_var('search_fields', 'all'); |
| 36 | 5236 | acydburn | $search_child = request_var('search_child', true); |
| 37 | 4500 | psotfx | |
| 38 | 4970 | psotfx | $return_chars = request_var('return_chars', 200); |
| 39 | 5003 | acydburn | $search_forum = request_var('search_forum', 0); |
| 40 | 4500 | psotfx | |
| 41 | 4970 | psotfx | $sort_days = request_var('st', 0); |
| 42 | 4970 | psotfx | $sort_key = request_var('sk', 't'); |
| 43 | 4970 | psotfx | $sort_dir = request_var('sd', 'd'); |
| 44 | 4500 | psotfx | |
| 45 | 3845 | psotfx | // Is user able to search? Has search been disabled?
|
| 46 | 4500 | psotfx | if (!$auth->acl_get('u_search') || !$config['load_search']) |
| 47 | 3845 | psotfx | {
|
| 48 | 4500 | psotfx | trigger_error($user->lang['NO_SEARCH']); |
| 49 | 3845 | psotfx | } |
| 50 | 3845 | psotfx | |
| 51 | 4530 | psotfx | // Define some vars
|
| 52 | 4500 | psotfx | $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'], 364 => $user->lang['1_YEAR']); |
| 53 | 4500 | psotfx | $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']); |
| 54 | 368 | psotfx | |
| 55 | 5003 | acydburn | $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; |
| 56 | 5003 | acydburn | 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); |
| 57 | 368 | psotfx | |
| 58 | 5003 | acydburn | $store_vars = array('sort_key', 'sort_dir', 'sort_days', 'show_results', 'return_chars', 'total_match_count'); |
| 59 | 4530 | psotfx | $current_time = time(); |
| 60 | 368 | psotfx | |
| 61 | 4530 | psotfx | // Check last search time ... if applicable
|
| 62 | 4530 | psotfx | if ($config['search_interval']) |
| 63 | 4530 | psotfx | {
|
| 64 | 4530 | psotfx | $sql = 'SELECT MAX(search_time) as last_time |
| 65 | 4530 | psotfx | FROM ' . SEARCH_TABLE; |
| 66 | 4530 | psotfx | $result = $db->sql_query($sql); |
| 67 | 4530 | psotfx | |
| 68 | 4530 | psotfx | if ($row = $db->sql_fetchrow($result)) |
| 69 | 4530 | psotfx | {
|
| 70 | 4530 | psotfx | if ($row['last_time'] > time() - $config['search_interval']) |
| 71 | 4530 | psotfx | {
|
| 72 | 4530 | psotfx | trigger_error($user->lang['NO_SEARCH_TIME']); |
| 73 | 4530 | psotfx | } |
| 74 | 4530 | psotfx | } |
| 75 | 4530 | psotfx | } |
| 76 | 4530 | psotfx | |
| 77 | 5236 | acydburn | if ($keywords || $author || $search_id || $search_session_id) |
| 78 | 368 | psotfx | {
|
| 79 | 5236 | acydburn | // clear arrays
|
| 80 | 5236 | acydburn | $pid_ary = $fid_ary = array(); |
| 81 | 2205 | psotfx | |
| 82 | 4500 | psotfx | // Which forums can we view?
|
| 83 | 4500 | psotfx | $sql_where = (sizeof($search_forum) && !$search_child) ? 'WHERE f.forum_id IN (' . implode(', ', $search_forum) . ')' : ''; |
| 84 | 4500 | psotfx | $sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.right_id, f.forum_password, fa.user_id |
| 85 | 5236 | acydburn | FROM (' . FORUMS_TABLE . ' f |
| 86 | 5236 | acydburn | LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa ON (fa.forum_id = f.forum_id |
| 87 | 5236 | acydburn | AND fa.session_id = '" . $db->sql_escape($user->data['session_id']) . "')) |
| 88 | 4500 | psotfx | $sql_where |
| 89 | 4500 | psotfx | ORDER BY f.left_id";
|
| 90 | 4500 | psotfx | $result = $db->sql_query($sql); |
| 91 | 4500 | psotfx | |
| 92 | 4500 | psotfx | $right_id = 0; |
| 93 | 4500 | psotfx | while ($row = $db->sql_fetchrow($result)) |
| 94 | 1051 | psotfx | {
|
| 95 | 4500 | psotfx | if ($search_child) |
| 96 | 1051 | psotfx | {
|
| 97 | 4970 | psotfx | if (!$search_forum || (in_array($row['forum_id'], $search_forum) && $row['right_id'] > $right_id)) |
| 98 | 1566 | psotfx | {
|
| 99 | 4500 | psotfx | $right_id = $row['right_id']; |
| 100 | 1566 | psotfx | } |
| 101 | 4500 | psotfx | else if ($row['right_id'] > $right_id) |
| 102 | 1566 | psotfx | {
|
| 103 | 4500 | psotfx | continue;
|
| 104 | 1566 | psotfx | } |
| 105 | 1511 | psotfx | } |
| 106 | 4500 | psotfx | |
| 107 | 4500 | psotfx | if ($auth->acl_get('f_read', $row['forum_id']) && (!$row['forum_password'] || $row['user_id'] == $user->data['user_id'])) |
| 108 | 1511 | psotfx | {
|
| 109 | 5236 | acydburn | $fid_ary[] = $row['forum_id']; |
| 110 | 4500 | psotfx | } |
| 111 | 4500 | psotfx | } |
| 112 | 4500 | psotfx | $db->sql_freeresult($result); |
| 113 | 5236 | acydburn | unset($search_forum); |
| 114 | 2849 | psotfx | |
| 115 | 5236 | acydburn | if (!sizeof($fid_ary)) |
| 116 | 4626 | psotfx | {
|
| 117 | 4626 | psotfx | trigger_error($user->lang['NO_SEARCH_RESULTS']); |
| 118 | 4626 | psotfx | } |
| 119 | 4626 | psotfx | |
| 120 | 4500 | psotfx | if ($search_id == 'egosearch') |
| 121 | 4500 | psotfx | {
|
| 122 | 5236 | acydburn | $author = $user->data['username']; |
| 123 | 4500 | psotfx | } |
| 124 | 1511 | psotfx | |
| 125 | 4500 | psotfx | // Are we looking for a user?
|
| 126 | 5236 | acydburn | $author_id = 0; |
| 127 | 5236 | acydburn | if ($author) |
| 128 | 4500 | psotfx | {
|
| 129 | 5236 | acydburn | $sql_where = (strstr($author, '*') !== false) ? ' LIKE ' : ' = '; |
| 130 | 5236 | acydburn | $sql = 'SELECT user_id |
| 131 | 4500 | psotfx | FROM ' . USERS_TABLE . " |
| 132 | 5236 | acydburn | WHERE username $sql_where '" . $db->sql_escape(preg_replace('#\*+#', '%', $author)) . "' |
| 133 | 5108 | acydburn | AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')'; |
| 134 | 4500 | psotfx | $result = $db->sql_query($sql); |
| 135 | 1293 | psotfx | |
| 136 | 4500 | psotfx | if (!$row = $db->sql_fetchrow($result)) |
| 137 | 2205 | psotfx | {
|
| 138 | 4500 | psotfx | trigger_error($user->lang['NO_SEARCH_RESULTS']); |
| 139 | 2205 | psotfx | } |
| 140 | 4500 | psotfx | $db->sql_freeresult($result); |
| 141 | 2673 | psotfx | |
| 142 | 5236 | acydburn | $author_id = (int) $row['user_id']; |
| 143 | 4500 | psotfx | } |
| 144 | 1511 | psotfx | |
| 145 | 5236 | acydburn | |
| 146 | 4500 | psotfx | if ($search_id) |
| 147 | 4500 | psotfx | {
|
| 148 | 5236 | acydburn | $sql_in = $sql_where = ''; |
| 149 | 5003 | acydburn | |
| 150 | 4500 | psotfx | switch ($search_id) |
| 151 | 1511 | psotfx | {
|
| 152 | 5161 | acydburn | // Oh holy Bob, bring us some activity...
|
| 153 | 5161 | acydburn | case 'active_topics': |
| 154 | 5161 | acydburn | $show_results = 'topics'; |
| 155 | 5161 | acydburn | |
| 156 | 5161 | acydburn | if (!$sort_days) |
| 157 | 5161 | acydburn | {
|
| 158 | 5161 | acydburn | $sort_days = 1; |
| 159 | 5161 | acydburn | 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); |
| 160 | 5161 | acydburn | } |
| 161 | 5161 | acydburn | |
| 162 | 5161 | acydburn | $last_post_time = (time() - ($sort_days * 24 * 3600)); |
| 163 | 5161 | acydburn | |
| 164 | 5161 | acydburn | $sql = 'SELECT DISTINCT t.topic_id |
| 165 | 5161 | acydburn | FROM ' . POSTS_TABLE . ' p |
| 166 | 5161 | acydburn | LEFT JOIN ' . TOPICS_TABLE . " t ON (t.topic_approved = 1 AND p.topic_id = t.topic_id) |
| 167 | 5161 | acydburn | WHERE p.post_time > $last_post_time |
| 168 | 5236 | acydburn | " . ((sizeof($fid_ary)) ? ' AND p.forum_id IN (' . implode(',', $fid_ary) . ')' : '') . ' |
| 169 | 5236 | acydburn | ORDER BY t.topic_last_post_time DESC';
|
| 170 | 5161 | acydburn | $result = $db->sql_query_limit($sql, 1000); |
| 171 | 5161 | acydburn | |
| 172 | 5161 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 173 | 5161 | acydburn | {
|
| 174 | 5236 | acydburn | $pid_ary[] = $row['topic_id']; |
| 175 | 5161 | acydburn | } |
| 176 | 5161 | acydburn | $db->sql_freeresult($result); |
| 177 | 5161 | acydburn | break;
|
| 178 | 5161 | acydburn | |
| 179 | 4500 | psotfx | case 'egosearch': |
| 180 | 4500 | psotfx | break;
|
| 181 | 1293 | psotfx | |
| 182 | 4500 | psotfx | case 'unanswered': |
| 183 | 4500 | psotfx | if ($show_results == 'posts') |
| 184 | 1089 | psotfx | {
|
| 185 | 5236 | acydburn | $sql = 'SELECT p.post_id |
| 186 | 5236 | acydburn | FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t |
| 187 | 4500 | psotfx | WHERE t.topic_replies = 0 |
| 188 | 4626 | psotfx | AND p.topic_id = t.topic_id |
| 189 | 5236 | acydburn | " . ((sizeof($fid_ary)) ? ' AND p.forum_id IN (' . implode(',', $fid_ary) . ')' : ''); |
| 190 | 4500 | psotfx | $field = 'post_id'; |
| 191 | 1089 | psotfx | } |
| 192 | 2205 | psotfx | else
|
| 193 | 2205 | psotfx | {
|
| 194 | 5236 | acydburn | $sql = 'SELECT t.topic_id |
| 195 | 5236 | acydburn | FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t |
| 196 | 5236 | acydburn | WHERE t.topic_replies = 0 |
| 197 | 4626 | psotfx | AND p.topic_id = t.topic_id |
| 198 | 5236 | acydburn | " . ((sizeof($fid_ary)) ? ' AND p.forum_id IN (' . implode(',', $fid_ary) . ')' : '') . ' |
| 199 | 5236 | acydburn | GROUP BY p.topic_id';
|
| 200 | 4500 | psotfx | $field = 'topic_id'; |
| 201 | 2205 | psotfx | } |
| 202 | 4500 | psotfx | $result = $db->sql_query($sql); |
| 203 | 1938 | psotfx | |
| 204 | 4500 | psotfx | while ($row = $db->sql_fetchrow($result)) |
| 205 | 2205 | psotfx | {
|
| 206 | 5236 | acydburn | $pid_ary[] = $row[$field]; |
| 207 | 2205 | psotfx | } |
| 208 | 4500 | psotfx | $db->sql_freeresult($result); |
| 209 | 2205 | psotfx | |
| 210 | 5236 | acydburn | if (!sizeof($pid_ary)) |
| 211 | 2205 | psotfx | {
|
| 212 | 4500 | psotfx | trigger_error($user->lang['NO_SEARCH_RESULTS']); |
| 213 | 2205 | psotfx | } |
| 214 | 4500 | psotfx | break;
|
| 215 | 2205 | psotfx | |
| 216 | 4500 | psotfx | case 'newposts': |
| 217 | 4500 | psotfx | if ($show_results == 'posts') |
| 218 | 1938 | psotfx | {
|
| 219 | 5236 | acydburn | $sql = 'SELECT p.post_id |
| 220 | 5236 | acydburn | FROM ' . POSTS_TABLE . ' p |
| 221 | 4626 | psotfx | WHERE p.post_time > ' . $user->data['user_lastvisit'] . " |
| 222 | 5236 | acydburn | " . ((sizeof($fid_ary)) ? ' AND p.forum_id IN (' . implode(',', $fid_ary) . ')' : ''); |
| 223 | 4500 | psotfx | $field = 'post_id'; |
| 224 | 1938 | psotfx | } |
| 225 | 4500 | psotfx | else
|
| 226 | 1938 | psotfx | {
|
| 227 | 4500 | psotfx | $sql = 'SELECT t.topic_id |
| 228 | 5236 | acydburn | FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p |
| 229 | 5236 | acydburn | WHERE p.post_time > ' . $user->data['user_lastvisit'] . " |
| 230 | 5236 | acydburn | AND t.topic_id = p.topic_id |
| 231 | 5236 | acydburn | " . ((sizeof($fid_ary)) ? ' AND p.forum_id IN (' . implode(',', $fid_ary) . ')' : '') . ' |
| 232 | 5236 | acydburn | GROUP by p.topic_id';
|
| 233 | 4500 | psotfx | $field = 'topic_id'; |
| 234 | 1938 | psotfx | } |
| 235 | 4500 | psotfx | $result = $db->sql_query($sql); |
| 236 | 1938 | psotfx | |
| 237 | 4500 | psotfx | while ($row = $db->sql_fetchrow($result)) |
| 238 | 2205 | psotfx | {
|
| 239 | 5236 | acydburn | $pid_ary[] = $row[$field]; |
| 240 | 2205 | psotfx | } |
| 241 | 4500 | psotfx | $db->sql_freeresult($result); |
| 242 | 2205 | psotfx | |
| 243 | 5236 | acydburn | if (!sizeof($pid_ary)) |
| 244 | 2205 | psotfx | {
|
| 245 | 4500 | psotfx | trigger_error($user->lang['NO_SEARCH_RESULTS']); |
| 246 | 2205 | psotfx | } |
| 247 | 4500 | psotfx | break;
|
| 248 | 5161 | acydburn | } |
| 249 | 5161 | acydburn | } |
| 250 | 5161 | acydburn | |
| 251 | 5236 | acydburn | /**
|
| 252 | 5236 | acydburn | * @todo add to config |
| 253 | 5236 | acydburn | */ |
| 254 | 5236 | acydburn | $config['search_type'] = 'mysql'; |
| 255 | 5236 | acydburn | |
| 256 | 5236 | acydburn | // Select which method we'll use to obtain the post_id information
|
| 257 | 5236 | acydburn | $smid = ''; |
| 258 | 5236 | acydburn | switch ($config['search_type']) |
| 259 | 5236 | acydburn | {
|
| 260 | 5236 | acydburn | case 'phpbb': |
| 261 | 5236 | acydburn | $smid = 'fulltext_phpbb'; |
| 262 | 5236 | acydburn | break;
|
| 263 | 5236 | acydburn | case 'mysql': |
| 264 | 5236 | acydburn | $smid = 'fulltext_mysql'; |
| 265 | 5236 | acydburn | break;
|
| 266 | 5236 | acydburn | /* case 'mssql':
|
| 267 | 5236 | acydburn | case 'pgsql': |
| 268 | 5236 | acydburn | $smid = 'fulltext_pgmssql'; |
| 269 | 5236 | acydburn | break; |
| 270 | 5236 | acydburn | case 'like': |
| 271 | 5236 | acydburn | $smid = 'like'; |
| 272 | 5236 | acydburn | break; |
| 273 | 5236 | acydburn | case 'preg': |
| 274 | 5236 | acydburn | $smid = 'preg_mysql'; |
| 275 | 5236 | acydburn | break;*/ |
| 276 | 5236 | acydburn | default:
|
| 277 | 5236 | acydburn | trigger_error('NO_SUCH_SEARCH_MODULE'); |
| 278 | 5236 | acydburn | } |
| 279 | 5236 | acydburn | |
| 280 | 5236 | acydburn | require($phpbb_root_path . 'includes/search/' . $smid . '.' . $phpEx); |
| 281 | 5236 | acydburn | |
| 282 | 5236 | acydburn | // We do some additional checks in each module to ensure it can actually be utilised
|
| 283 | 5236 | acydburn | $error = false; |
| 284 | 5236 | acydburn | $search = new $smid($error); |
| 285 | 5236 | acydburn | |
| 286 | 5236 | acydburn | if ($error) |
| 287 | 5236 | acydburn | {
|
| 288 | 5236 | acydburn | trigger_error($error); |
| 289 | 5236 | acydburn | } |
| 290 | 5236 | acydburn | |
| 291 | 5161 | acydburn | if ($search_session_id) |
| 292 | 5161 | acydburn | {
|
| 293 | 5161 | acydburn | $sql = 'SELECT search_array |
| 294 | 5161 | acydburn | FROM ' . SEARCH_TABLE . " |
| 295 | 5161 | acydburn | WHERE search_id = $search_session_id |
| 296 | 5161 | acydburn | AND session_id = '" . $db->sql_escape($user->data['session_id']) . "'"; |
| 297 | 5161 | acydburn | $result = $db->sql_query($sql); |
| 298 | 1938 | psotfx | |
| 299 | 5161 | acydburn | if ($row = $db->sql_fetchrow($result)) |
| 300 | 5161 | acydburn | {
|
| 301 | 5236 | acydburn | $pid_ary = explode('#', $row['search_array']); |
| 302 | 5003 | acydburn | |
| 303 | 5236 | acydburn | $search->split_words = unserialize(array_shift($pid_ary)); |
| 304 | 5236 | acydburn | if ($keywords) |
| 305 | 5161 | acydburn | {
|
| 306 | 5161 | acydburn | // If we're wanting to search on these results we store the existing split word array
|
| 307 | 5236 | acydburn | $search->old_split_words = $search->split_words; |
| 308 | 5161 | acydburn | } |
| 309 | 5236 | acydburn | $search->common_words = unserialize(array_shift($pid_ary)); |
| 310 | 5236 | acydburn | |
| 311 | 5161 | acydburn | foreach ($store_vars as $var) |
| 312 | 5161 | acydburn | {
|
| 313 | 5236 | acydburn | $$var = array_shift($pid_ary); |
| 314 | 5161 | acydburn | } |
| 315 | 1511 | psotfx | } |
| 316 | 5161 | acydburn | $db->sql_freeresult($result); |
| 317 | 4500 | psotfx | } |
| 318 | 2849 | psotfx | |
| 319 | 5236 | acydburn | $total_match_count = 0; |
| 320 | 5236 | acydburn | $search->search($show_results, $search_fields, $search_terms, $fid_ary, $keywords, $author_id, $pid_ary, $sort_days); |
| 321 | 1938 | psotfx | |
| 322 | 5236 | acydburn | if ($pid_ary) |
| 323 | 4500 | psotfx | {
|
| 324 | 5236 | acydburn | // Finish building query (for all combinations) and run it ...
|
| 325 | 5236 | acydburn | $sql = 'SELECT session_id |
| 326 | 5236 | acydburn | FROM ' . SESSIONS_TABLE; |
| 327 | 4500 | psotfx | $result = $db->sql_query($sql); |
| 328 | 2448 | psotfx | |
| 329 | 5236 | acydburn | $delete_search_ids = array(); |
| 330 | 4500 | psotfx | while ($row = $db->sql_fetchrow($result)) |
| 331 | 4500 | psotfx | {
|
| 332 | 5236 | acydburn | $delete_search_ids[] = "'" . $db->sql_escape($row['session_id']) . "'"; |
| 333 | 4500 | psotfx | } |
| 334 | 2448 | psotfx | |
| 335 | 5236 | acydburn | if (sizeof($delete_search_ids)) |
| 336 | 4500 | psotfx | {
|
| 337 | 5236 | acydburn | $sql = 'DELETE FROM ' . SEARCH_TABLE . ' |
| 338 | 5236 | acydburn | WHERE session_id NOT IN (' . implode(", ", $delete_search_ids) . ')'; |
| 339 | 5236 | acydburn | $db->sql_query($sql); |
| 340 | 4500 | psotfx | } |
| 341 | 2448 | psotfx | |
| 342 | 5236 | acydburn | $total_match_count = sizeof($pid_ary); |
| 343 | 5236 | acydburn | $sql_where = (($show_results == 'posts') ? 'p.post_id' : 't.topic_id') . ' IN (' . implode(', ', $pid_ary) . ')'; |
| 344 | 2448 | psotfx | |
| 345 | 5236 | acydburn | if (sizeof($search->old_split_words) && array_diff($search->split_words, $search->old_split_words)) |
| 346 | 4500 | psotfx | {
|
| 347 | 5236 | acydburn | $search->split_words = array_merge($search->split_words, $search->old_split_words); |
| 348 | 4500 | psotfx | } |
| 349 | 2448 | psotfx | |
| 350 | 5236 | acydburn | $data = serialize($search->split_words); |
| 351 | 5236 | acydburn | $data .= '#' . serialize($search->common_words); |
| 352 | 5236 | acydburn | |
| 353 | 4500 | psotfx | foreach ($store_vars as $var) |
| 354 | 4500 | psotfx | {
|
| 355 | 4500 | psotfx | $data .= '#' . $$var; |
| 356 | 4500 | psotfx | } |
| 357 | 5236 | acydburn | $data .= '#' . implode('#', $pid_ary); |
| 358 | 5236 | acydburn | |
| 359 | 5236 | acydburn | unset($pid_ary); |
| 360 | 2448 | psotfx | |
| 361 | 4500 | psotfx | srand ((double) microtime() * 1000000); |
| 362 | 5161 | acydburn | $search_session_id = rand(); |
| 363 | 1051 | psotfx | |
| 364 | 5003 | acydburn | $sql_ary = array( |
| 365 | 5161 | acydburn | 'search_id' => $search_session_id, |
| 366 | 5003 | acydburn | 'session_id' => $user->data['session_id'], |
| 367 | 5003 | acydburn | 'search_time' => $current_time, |
| 368 | 5003 | acydburn | 'search_array' => $data |
| 369 | 5003 | acydburn | ); |
| 370 | 5003 | acydburn | |
| 371 | 5003 | acydburn | $sql = 'INSERT INTO ' . SEARCH_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); |
| 372 | 4500 | psotfx | $db->sql_query($sql); |
| 373 | 4500 | psotfx | unset($data); |
| 374 | 4500 | psotfx | } |
| 375 | 1051 | psotfx | |
| 376 | 5003 | acydburn | if ($show_results == 'posts') |
| 377 | 5003 | acydburn | {
|
| 378 | 5236 | acydburn | include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); |
| 379 | 5003 | acydburn | } |
| 380 | 5003 | acydburn | else
|
| 381 | 5003 | acydburn | {
|
| 382 | 5236 | acydburn | include($phpbb_root_path . 'includes/functions_display.' . $phpEx); |
| 383 | 5003 | acydburn | } |
| 384 | 1051 | psotfx | |
| 385 | 4500 | psotfx | // Look up data ...
|
| 386 | 4500 | psotfx | $per_page = ($show_results == 'posts') ? $config['posts_per_page'] : $config['topics_per_page']; |
| 387 | 1051 | psotfx | |
| 388 | 4500 | psotfx | // Grab icons
|
| 389 | 4836 | acydburn | $icons = array(); |
| 390 | 5236 | acydburn | $cache->obtain_icons($icons); |
| 391 | 1051 | psotfx | |
| 392 | 4500 | psotfx | // Output header
|
| 393 | 4500 | psotfx | $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); |
| 394 | 1511 | psotfx | |
| 395 | 5236 | acydburn | $hilit = htmlspecialchars(implode('|', str_replace(array('+', '-', '|'), '', $search->split_words))); |
| 396 | 5236 | acydburn | $split_words = (sizeof($search->split_words)) ? htmlspecialchars(implode(' ', $search->split_words)) : ''; |
| 397 | 1947 | psotfx | |
| 398 | 4500 | psotfx | $template->assign_vars(array( |
| 399 | 4500 | psotfx | 'SEARCH_MATCHES' => $l_search_matches, |
| 400 | 4500 | psotfx | 'SEARCH_WORDS' => $split_words, |
| 401 | 5236 | acydburn | 'IGNORED_WORDS' => (sizeof($search->common_words)) ? htmlspecialchars(implode(' ', $search->common_words)) : '', |
| 402 | 5236 | acydburn | 'PAGINATION' => generate_pagination("{$phpbb_root_path}search.$phpEx$SID&search_session_id=$search_session_id&search_id=$search_id&hilit=$hilit&$u_sort_param", $total_match_count, $per_page, $start), |
| 403 | 5003 | acydburn | 'PAGE_NUMBER' => on_page($total_match_count, $per_page, $start), |
| 404 | 5003 | acydburn | 'TOTAL_MATCHES' => $total_match_count, |
| 405 | 1851 | psotfx | |
| 406 | 4500 | psotfx | 'S_SELECT_SORT_DIR' => $s_sort_dir, |
| 407 | 4500 | psotfx | 'S_SELECT_SORT_KEY' => $s_sort_key, |
| 408 | 5161 | acydburn | 'S_SELECT_SORT_DAYS' => $s_limit_days, |
| 409 | 5161 | acydburn | 'S_SEARCH_ACTION' => "{$phpbb_root_path}search.$phpEx$SID&search_session_id=$search_session_id&search_id=$search_id", |
| 410 | 5003 | acydburn | 'S_SHOW_TOPICS' => ($show_results == 'posts') ? false : true, |
| 411 | 1851 | psotfx | |
| 412 | 5003 | acydburn | 'REPORTED_IMG' => $user->img('icon_reported', 'TOPIC_REPORTED'), |
| 413 | 5003 | acydburn | 'UNAPPROVED_IMG' => $user->img('icon_unapproved', 'TOPIC_UNAPPROVED'), |
| 414 | 5003 | acydburn | 'GOTO_PAGE_IMG' => $user->img('icon_post', 'GOTO_PAGE'), |
| 415 | 5003 | acydburn | |
| 416 | 5236 | acydburn | 'U_SEARCH_WORDS' => "{$phpbb_root_path}search.$phpEx$SID&show_results=$show_results&keywords=" . urlencode($split_words)) |
| 417 | 4500 | psotfx | ); |
| 418 | 368 | psotfx | |
| 419 | 4500 | psotfx | $u_hilit = urlencode($split_words); |
| 420 | 368 | psotfx | |
| 421 | 4530 | psotfx | // Define ordering sql field, do it here because the order may be defined
|
| 422 | 4530 | psotfx | // within an existing search result set
|
| 423 | 4530 | psotfx | $sort_by_sql = array('a' => (($show_results == 'posts') ? 'u.username' : 't.topic_poster'), 't' => (($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time'), 'f' => 'f.forum_id', 'i' => 't.topic_title', 's' => (($show_results == 'posts') ? 'pt.post_subject' : 't.topic_title')); |
| 424 | 4530 | psotfx | |
| 425 | 5161 | acydburn | if ($sql_where) |
| 426 | 4500 | psotfx | {
|
| 427 | 5161 | acydburn | if ($show_results == 'posts') |
| 428 | 5161 | acydburn | {
|
| 429 | 5161 | acydburn | // Not joining this query to the one below at present ... may do in future
|
| 430 | 5161 | acydburn | $sql = 'SELECT zebra_id, friend, foe |
| 431 | 5161 | acydburn | FROM ' . ZEBRA_TABLE . ' |
| 432 | 5161 | acydburn | WHERE user_id = ' . $user->data['user_id']; |
| 433 | 5161 | acydburn | $result = $db->sql_query($sql); |
| 434 | 4530 | psotfx | |
| 435 | 5161 | acydburn | $zebra = array(); |
| 436 | 5161 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 437 | 4530 | psotfx | {
|
| 438 | 5161 | acydburn | $zebra[($row['friend']) ? 'friend' : 'foe'][] = $row['zebra_id']; |
| 439 | 4530 | psotfx | } |
| 440 | 5161 | acydburn | $db->sql_freeresult($result); |
| 441 | 5161 | acydburn | |
| 442 | 5161 | acydburn | $sql = 'SELECT p.*, f.forum_id, f.forum_name, t.*, u.username, u.user_sig, u.user_sig_bbcode_uid |
| 443 | 5161 | acydburn | FROM ' . FORUMS_TABLE . ' f, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u, ' . POSTS_TABLE . " p |
| 444 | 5161 | acydburn | WHERE $sql_where |
| 445 | 5161 | acydburn | AND f.forum_id = p.forum_id |
| 446 | 5161 | acydburn | AND p.topic_id = t.topic_id |
| 447 | 5161 | acydburn | AND p.poster_id = u.user_id";
|
| 448 | 4530 | psotfx | } |
| 449 | 5161 | acydburn | else
|
| 450 | 5161 | acydburn | {
|
| 451 | 5161 | acydburn | $sql = 'SELECT t.*, f.forum_id, f.forum_name |
| 452 | 5161 | acydburn | FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f |
| 453 | 5161 | acydburn | WHERE $sql_where |
| 454 | 5161 | acydburn | AND f.forum_id = t.forum_id";
|
| 455 | 5161 | acydburn | } |
| 456 | 5236 | acydburn | $sql .= ' ORDER BY ' . $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); |
| 457 | 5236 | acydburn | $result = $db->sql_query_limit($sql, $per_page, $start); |
| 458 | 4530 | psotfx | |
| 459 | 5161 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 460 | 5161 | acydburn | {
|
| 461 | 5161 | acydburn | $forum_id = $row['forum_id']; |
| 462 | 5161 | acydburn | $topic_id = $row['topic_id']; |
| 463 | 1051 | psotfx | |
| 464 | 5236 | acydburn | $view_topic_url = "{$phpbb_root_path}viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&hilit=$u_hilit"; |
| 465 | 368 | psotfx | |
| 466 | 5161 | acydburn | if ($show_results == 'topics') |
| 467 | 5161 | acydburn | {
|
| 468 | 5161 | acydburn | $replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies']; |
| 469 | 368 | psotfx | |
| 470 | 5161 | acydburn | $folder_img = $folder_alt = $topic_type = ''; |
| 471 | 5161 | acydburn | topic_status($row, $replies, time(), time(), $folder_img, $folder_alt, $topic_type); |
| 472 | 1051 | psotfx | |
| 473 | 5161 | acydburn | $tpl_ary = array( |
| 474 | 5161 | acydburn | 'TOPIC_AUTHOR' => topic_topic_author($row), |
| 475 | 5161 | acydburn | 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), |
| 476 | 5161 | acydburn | 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), |
| 477 | 5161 | acydburn | 'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']), |
| 478 | 5161 | acydburn | 'LAST_POST_AUTHOR' => ($row['topic_last_poster_name'] != '') ? $row['topic_last_poster_name'] : $user->lang['GUEST'], |
| 479 | 5161 | acydburn | 'PAGINATION' => topic_generate_pagination($replies, $view_topic_url), |
| 480 | 5161 | acydburn | 'REPLIES' => $replies, |
| 481 | 5161 | acydburn | 'VIEWS' => $row['topic_views'], |
| 482 | 5161 | acydburn | 'TOPIC_TYPE' => $topic_type, |
| 483 | 1051 | psotfx | |
| 484 | 5161 | acydburn | 'LAST_POST_IMG' => $user->img('icon_post_latest', 'VIEW_LATEST_POST'), |
| 485 | 5161 | acydburn | 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), |
| 486 | 5161 | acydburn | 'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '', |
| 487 | 5161 | acydburn | 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '', |
| 488 | 5161 | acydburn | 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '', |
| 489 | 5161 | acydburn | 'ATTACH_ICON_IMG' => ($auth->acl_gets('f_download', 'u_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', |
| 490 | 943 | thefinn | |
| 491 | 5161 | acydburn | 'S_TOPIC_TYPE' => $row['topic_type'], |
| 492 | 5161 | acydburn | 'S_USER_POSTED' => (!empty($row['mark_type'])) ? true : false, |
| 493 | 1368 | psotfx | |
| 494 | 5161 | acydburn | 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_gets('m_', $forum_id)) ? true : false, |
| 495 | 5161 | acydburn | 'S_TOPIC_UNAPPROVED' => (!$row['topic_approved'] && $auth->acl_gets('m_approve', $forum_id)) ? true : false, |
| 496 | 4500 | psotfx | |
| 497 | 5161 | acydburn | 'U_LAST_POST' => $view_topic_url . '&p=' . $row['topic_last_post_id'] . '#' . $row['topic_last_post_id'], |
| 498 | 5236 | acydburn | 'U_LAST_POST_AUTHOR'=> ($row['topic_last_poster_id'] != ANONYMOUS && $row['topic_last_poster_id']) ? "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&u={$row['topic_last_poster_id']}" : '', |
| 499 | 5236 | acydburn | 'U_MCP_REPORT' => "{$phpbb_root_path}mcp.$phpEx?sid={$user->session_id}&mode=reports&t=$topic_id", |
| 500 | 5236 | acydburn | 'U_MCP_QUEUE' => "{$phpbb_root_path}mcp.$phpEx?sid={$user->session_id}&i=queue&mode=approve_details&t=$topic_id" |
| 501 | 4530 | psotfx | ); |
| 502 | 4530 | psotfx | } |
| 503 | 5161 | acydburn | else
|
| 504 | 4500 | psotfx | {
|
| 505 | 5161 | acydburn | if ((isset($zebra['foe']) && in_array($row['poster_id'], $zebra['foe'])) && (!$view || $view != 'show' || $post_id != $row['post_id'])) |
| 506 | 5161 | acydburn | {
|
| 507 | 5161 | acydburn | $template->assign_block_vars('searchresults', array( |
| 508 | 5161 | acydburn | 'S_IGNORE_POST' => true, |
| 509 | 1511 | psotfx | |
| 510 | 5161 | acydburn | 'L_IGNORE_POST' => sprintf($user->lang['POST_BY_FOE'], $row['username'], "<a href=\"search.$phpEx$SID&search_session_id=$search_session_id&$u_sort_param&p=" . $row['post_id'] . '&view=show#' . $row['post_id'] . '">', '</a>')) |
| 511 | 5161 | acydburn | ); |
| 512 | 5161 | acydburn | |
| 513 | 5161 | acydburn | continue;
|
| 514 | 5161 | acydburn | } |
| 515 | 5003 | acydburn | |
| 516 | 5161 | acydburn | if ($row['enable_html']) |
| 517 | 5161 | acydburn | {
|
| 518 | 5161 | acydburn | $row['post_text'] = preg_replace('#(<!\-\- h \-\-><)([\/]?.*?)(><!\-\- h \-\->)#is', "<\\2>", $row['post_text']); |
| 519 | 5161 | acydburn | } |
| 520 | 5161 | acydburn | |
| 521 | 5161 | acydburn | $row['post_text'] = censor_text($row['post_text']); |
| 522 | 5161 | acydburn | decode_message($row['post_text'], $row['bbcode_uid']); |
| 523 | 5003 | acydburn | |
| 524 | 5161 | acydburn | if ($return_chars) |
| 525 | 5161 | acydburn | {
|
| 526 | 5161 | acydburn | $row['post_text'] = (strlen($row['post_text']) < $return_chars + 3) ? $row['post_text'] : substr($row['post_text'], 0, $return_chars) . '...'; |
| 527 | 5161 | acydburn | } |
| 528 | 1851 | psotfx | |
| 529 | 5161 | acydburn | if ($hilit) |
| 530 | 5161 | acydburn | {
|
| 531 | 5161 | acydburn | // This was shamelessly 'borrowed' from volker at multiartstudio dot de
|
| 532 | 5161 | acydburn | // via php.net's annotated manual
|
| 533 | 5161 | acydburn | $row['post_text'] = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#\b(" . str_replace('\\', '\\\\', $hilit) . ")\b#i', '<span class=\"posthilit\">\\\\1</span>', '\\0')", '>' . $row['post_text'] . '<'), 1, -1)); |
| 534 | 5161 | acydburn | } |
| 535 | 1851 | psotfx | |
| 536 | 5161 | acydburn | $row['post_text'] = smiley_text($row['post_text']); |
| 537 | 5003 | acydburn | |
| 538 | 5161 | acydburn | // Replace naughty words such as farty pants
|
| 539 | 5161 | acydburn | $row['post_subject'] = censor_text($row['post_subject']); |
| 540 | 5161 | acydburn | $row['post_text'] = str_replace("\n", '<br />', censor_text($row['post_text'])); |
| 541 | 1851 | psotfx | |
| 542 | 5161 | acydburn | $tpl_ary = array( |
| 543 | 5161 | acydburn | 'POSTER_NAME' => ($row['poster_id'] == ANONYMOUS) ? ((!empty($row['post_username'])) ? $row['post_username'] : $user->lang['GUEST']) : $row['username'], |
| 544 | 5161 | acydburn | 'POST_SUBJECT' => censor_text($row['post_subject']), |
| 545 | 5161 | acydburn | 'POST_DATE' => (!empty($row['post_time'])) ? $user->format_date($row['post_time']) : '', |
| 546 | 5161 | acydburn | 'MESSAGE' => $row['post_text'] |
| 547 | 5161 | acydburn | ); |
| 548 | 5161 | acydburn | } |
| 549 | 1851 | psotfx | |
| 550 | 5161 | acydburn | $template->assign_block_vars('searchresults', array_merge($tpl_ary, array( |
| 551 | 5161 | acydburn | 'FORUM_ID' => $forum_id, |
| 552 | 5161 | acydburn | 'TOPIC_ID' => $topic_id, |
| 553 | 5161 | acydburn | 'POST_ID' => ($show_results == 'posts') ? $row['post_id'] : false, |
| 554 | 1851 | psotfx | |
| 555 | 5161 | acydburn | 'FORUM_TITLE' => $row['forum_name'], |
| 556 | 5161 | acydburn | 'TOPIC_TITLE' => censor_text($row['topic_title']), |
| 557 | 5161 | acydburn | |
| 558 | 5161 | acydburn | 'U_VIEW_TOPIC' => $view_topic_url, |
| 559 | 5161 | acydburn | 'U_VIEW_FORUM' => "viewforum.$phpEx$SID&f=$forum_id", |
| 560 | 5161 | acydburn | 'U_VIEW_POST' => (!empty($row['post_id'])) ? "viewtopic.$phpEx$SID&f=$forum_id&t=" . $row['topic_id'] . '&p=' . $row['post_id'] . '&hilit=' . $u_hilit . '#' . $row['post_id'] : '') |
| 561 | 5161 | acydburn | )); |
| 562 | 5161 | acydburn | } |
| 563 | 5161 | acydburn | $db->sql_freeresult($result); |
| 564 | 4500 | psotfx | } |
| 565 | 5161 | acydburn | else
|
| 566 | 5161 | acydburn | {
|
| 567 | 5161 | acydburn | $template->assign_vars(array( |
| 568 | 5161 | acydburn | 'S_NO_SEARCH_RESULTS' => true) |
| 569 | 5161 | acydburn | ); |
| 570 | 5161 | acydburn | } |
| 571 | 368 | psotfx | |
| 572 | 4500 | psotfx | page_header($user->lang['SEARCH']); |
| 573 | 2448 | psotfx | |
| 574 | 4500 | psotfx | $template->set_filenames(array( |
| 575 | 5003 | acydburn | 'body' => 'search_results.html') |
| 576 | 4500 | psotfx | ); |
| 577 | 4500 | psotfx | make_jumpbox('viewforum.'.$phpEx); |
| 578 | 2448 | psotfx | |
| 579 | 4500 | psotfx | page_footer(); |
| 580 | 4500 | psotfx | } |
| 581 | 2448 | psotfx | |
| 582 | 368 | psotfx | |
| 583 | 4500 | psotfx | // Search forum
|
| 584 | 4500 | psotfx | $s_forums = ''; |
| 585 | 4500 | psotfx | $sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.left_id, f.right_id, f.forum_password, fa.user_id |
| 586 | 5236 | acydburn | FROM (' . FORUMS_TABLE . ' f |
| 587 | 5236 | acydburn | LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa ON (fa.forum_id = f.forum_id |
| 588 | 5236 | acydburn | AND fa.session_id = '" . $db->sql_escape($user->data['session_id']) . "')) |
| 589 | 4500 | psotfx | ORDER BY f.left_id ASC";
|
| 590 | 4500 | psotfx | $result = $db->sql_query($sql); |
| 591 | 368 | psotfx | |
| 592 | 4500 | psotfx | $right = $cat_right = $padding_inc = 0; |
| 593 | 4500 | psotfx | $padding = $forum_list = $holding = ''; |
| 594 | 4500 | psotfx | $pad_store = array('0' => ''); |
| 595 | 5003 | acydburn | $search_forums = array(); |
| 596 | 5236 | acydburn | |
| 597 | 4500 | psotfx | while ($row = $db->sql_fetchrow($result)) |
| 598 | 4500 | psotfx | {
|
| 599 | 4500 | psotfx | if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) |
| 600 | 4500 | psotfx | {
|
| 601 | 4500 | psotfx | // Non-postable forum with no subforums, don't display
|
| 602 | 4500 | psotfx | continue;
|
| 603 | 4500 | psotfx | } |
| 604 | 368 | psotfx | |
| 605 | 4500 | psotfx | if (!$auth->acl_get('f_list', $row['forum_id']) || $row['forum_type'] == FORUM_LINK || ($row['forum_password'] && !$row['user_id'])) |
| 606 | 4500 | psotfx | {
|
| 607 | 4500 | psotfx | // if the user does not have permissions to list this forum skip
|
| 608 | 4500 | psotfx | continue;
|
| 609 | 4500 | psotfx | } |
| 610 | 1051 | psotfx | |
| 611 | 4500 | psotfx | if ($row['left_id'] < $right) |
| 612 | 4500 | psotfx | {
|
| 613 | 4500 | psotfx | $padding .= ' '; |
| 614 | 4500 | psotfx | $pad_store[$row['parent_id']] = $padding; |
| 615 | 4500 | psotfx | } |
| 616 | 4500 | psotfx | else if ($row['left_id'] > $right + 1) |
| 617 | 4500 | psotfx | {
|
| 618 | 4500 | psotfx | $padding = $pad_store[$row['parent_id']]; |
| 619 | 4500 | psotfx | } |
| 620 | 2448 | psotfx | |
| 621 | 4500 | psotfx | $right = $row['right_id']; |
| 622 | 368 | psotfx | |
| 623 | 4500 | psotfx | $selected = (!sizeof($search_forums) || in_array($row['forum_id'], $search_forums)) ? ' selected="selected"' : ''; |
| 624 | 368 | psotfx | |
| 625 | 4500 | psotfx | if ($row['left_id'] > $cat_right) |
| 626 | 4500 | psotfx | {
|
| 627 | 4500 | psotfx | $holding = ''; |
| 628 | 4500 | psotfx | } |
| 629 | 1051 | psotfx | |
| 630 | 4500 | psotfx | if ($row['right_id'] - $row['left_id'] > 1) |
| 631 | 4500 | psotfx | {
|
| 632 | 4500 | psotfx | $cat_right = max($cat_right, $row['right_id']); |
| 633 | 2448 | psotfx | |
| 634 | 4500 | psotfx | $holding .= '<option value="' . $row['forum_id'] . '"' . $selected . '>' . $padding . $row['forum_name'] . '</option>'; |
| 635 | 368 | psotfx | } |
| 636 | 2455 | dougk_ff7 | else
|
| 637 | 2455 | dougk_ff7 | {
|
| 638 | 4500 | psotfx | $s_forums .= $holding . '<option value="' . $row['forum_id'] . '"' . $selected . '>' . $padding . $row['forum_name'] . '</option>'; |
| 639 | 4500 | psotfx | $holding = ''; |
| 640 | 2455 | dougk_ff7 | } |
| 641 | 368 | psotfx | } |
| 642 | 4500 | psotfx | $db->sql_freeresult($result); |
| 643 | 4500 | psotfx | unset($pad_store); |
| 644 | 368 | psotfx | |
| 645 | 1051 | psotfx | // Number of chars returned
|
| 646 | 4500 | psotfx | $s_characters = '<option value="-1">' . $user->lang['ALL_AVAILABLE'] . '</option>'; |
| 647 | 2205 | psotfx | $s_characters .= '<option value="0">0</option>'; |
| 648 | 2205 | psotfx | $s_characters .= '<option value="25">25</option>'; |
| 649 | 2205 | psotfx | $s_characters .= '<option value="50">50</option>'; |
| 650 | 1051 | psotfx | |
| 651 | 5236 | acydburn | for ($i = 100; $i <= 1000 ; $i += 100) |
| 652 | 368 | psotfx | {
|
| 653 | 4500 | psotfx | $selected = ($i == 200) ? ' selected="selected"' : ''; |
| 654 | 2205 | psotfx | $s_characters .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>'; |
| 655 | 368 | psotfx | } |
| 656 | 368 | psotfx | |
| 657 | 4500 | psotfx | $template->assign_vars(array( |
| 658 | 5236 | acydburn | 'S_SEARCH_ACTION' => "{$phpbb_root_path}search.$phpEx$SID&mode=results", |
| 659 | 4500 | psotfx | 'S_CHARACTER_OPTIONS' => $s_characters, |
| 660 | 4500 | psotfx | 'S_FORUM_OPTIONS' => $s_forums, |
| 661 | 4500 | psotfx | 'S_SELECT_SORT_DIR' => $s_sort_dir, |
| 662 | 4500 | psotfx | 'S_SELECT_SORT_KEY' => $s_sort_key, |
| 663 | 5003 | acydburn | 'S_SELECT_SORT_DAYS' => $s_limit_days) |
| 664 | 4500 | psotfx | ); |
| 665 | 1051 | psotfx | |
| 666 | 5236 | acydburn | $sql = 'SELECT search_id, search_time, search_array |
| 667 | 5003 | acydburn | FROM ' . SEARCH_TABLE . ' |
| 668 | 5003 | acydburn | ORDER BY search_time DESC';
|
| 669 | 4500 | psotfx | $result = $db->sql_query($sql); |
| 670 | 4500 | psotfx | |
| 671 | 4500 | psotfx | $i = 0; |
| 672 | 4500 | psotfx | while ($row = $db->sql_fetchrow($result)) |
| 673 | 1051 | psotfx | {
|
| 674 | 4500 | psotfx | if ($i == 5) |
| 675 | 4500 | psotfx | {
|
| 676 | 4500 | psotfx | break;
|
| 677 | 4500 | psotfx | } |
| 678 | 1051 | psotfx | |
| 679 | 4500 | psotfx | $data = explode('#', $row['search_array']); |
| 680 | 4500 | psotfx | $split_words = htmlspecialchars(implode(' ', unserialize(array_shift($data)))); |
| 681 | 368 | psotfx | |
| 682 | 4500 | psotfx | if (!$split_words) |
| 683 | 4500 | psotfx | {
|
| 684 | 4500 | psotfx | continue;
|
| 685 | 4500 | psotfx | } |
| 686 | 368 | psotfx | |
| 687 | 5236 | acydburn | $common_words = htmlspecialchars(implode(' ', unserialize(array_shift($data)))); |
| 688 | 4500 | psotfx | unset($data); |
| 689 | 4500 | psotfx | |
| 690 | 4500 | psotfx | $template->assign_block_vars('recentsearch', array( |
| 691 | 4500 | psotfx | 'KEYWORDS' => $split_words, |
| 692 | 5236 | acydburn | 'TIME' => $user->format_date($row['search_time']), |
| 693 | 4500 | psotfx | |
| 694 | 5236 | acydburn | 'U_KEYWORDS' => "{$phpbb_root_path}search.$phpEx$SID&keywords=" . urlencode($split_words)) |
| 695 | 4500 | psotfx | ); |
| 696 | 4920 | acydburn | |
| 697 | 4920 | acydburn | $i++;
|
| 698 | 4500 | psotfx | } |
| 699 | 4500 | psotfx | $db->sql_freeresult($result); |
| 700 | 4500 | psotfx | |
| 701 | 2760 | psotfx | // Output the basic page
|
| 702 | 3969 | psotfx | page_header($user->lang['SEARCH']); |
| 703 | 368 | psotfx | |
| 704 | 2760 | psotfx | $template->set_filenames(array( |
| 705 | 2760 | psotfx | 'body' => 'search_body.html') |
| 706 | 2760 | psotfx | ); |
| 707 | 2760 | psotfx | make_jumpbox('viewforum.'.$phpEx); |
| 708 | 2760 | psotfx | |
| 709 | 3969 | psotfx | page_footer(); |
| 710 | 368 | psotfx | |
| 711 | 2532 | psotfx | ?> |

