| 102 | | $store_vars = array('search_results', 'total_match_count', 'split_search', 'sort_by', 'sort_dir', 'show_results', 'return_chars'); |
|---|
| 103 | | $search_results = ''; |
|---|
| 104 | | // Topic search MOD |
|---|
| 105 | | $tid = request_var('topic_id', 0); |
|---|
| 106 | | // Topic search MOD |
|---|
| 107 | | |
|---|
| 108 | | // |
|---|
| 109 | | // Search ID Limiter, decrease this value if you experience further timeout problems with searching forums |
|---|
| 110 | | $limiter = 5000; |
|---|
| 111 | | $current_time = time(); |
|---|
| 112 | | $total_match_count = 0; |
|---|
| 113 | | |
|---|
| 114 | | // |
|---|
| 115 | | // Cycle through options ... |
|---|
| 116 | | // |
|---|
| 117 | | if ( $search_id == 'newposts' || $search_id == 'egosearch' || $search_id == 'unanswered' || $search_keywords != '' || $search_author != '' ) |
|---|
| 118 | | { |
|---|
| 119 | | // |
|---|
| 120 | | // Flood control |
|---|
| 121 | | // |
|---|
| 122 | | $where_sql = ($userdata['uid'] == ANONYMOUS) ? "se.session_ip = '$user_ip'" : 'se.session_user_id = ' . $userdata['uid']; |
|---|
| 123 | | $sql = 'SELECT MAX(sr.search_time) AS last_search_time |
|---|
| 124 | | FROM ' . SEARCH_TABLE . ' sr, ' . SESSIONS_TABLE . " se |
|---|
| 125 | | WHERE sr.session_id = se.session_id |
|---|
| 126 | | AND $where_sql"; |
|---|
| 127 | | if ($result = $db->sql_query($sql)) |
|---|
| 128 | | { |
|---|
| 129 | | if ($row = $db->sql_fetchrow($result)) |
|---|
| 130 | | { |
|---|
| 131 | | if (intval($row['last_search_time']) > 0 && ($current_time - intval($row['last_search_time'])) < intval($config['search_flood_interval'])) |
|---|
| 132 | | { |
|---|
| 133 | | $wait_time = intval($config['search_flood_interval']) - ($current_time - intval($row['last_search_time'])); |
|---|
| 134 | | trigger_error(sprintf($lang['search_flood_error'], $wait_time)); |
|---|
| 135 | | return; |
|---|
| 136 | | } |
|---|
| 137 | | } |
|---|
| 138 | | } |
|---|
| 139 | | if ( $search_id == 'newposts' || $search_id == 'egosearch' || ( $search_author != '' && $search_keywords == '' ) ) |
|---|
| 140 | | { |
|---|
| 141 | | if ( $search_id == 'newposts' ) |
|---|
| 142 | | { |
|---|
| 143 | | if ( $userdata['session_logged_in'] ) |
|---|
| 144 | | { |
|---|
| 145 | | $sql = "SELECT post_id |
|---|
| 146 | | FROM " . POSTS_TABLE . " |
|---|
| 147 | | WHERE post_time >= " . $userdata['user_lastvisit']; |
|---|
| 148 | | } |
|---|
| 149 | | else |
|---|
| 150 | | { |
|---|
| 151 | | loggedinorreturn(); |
|---|
| 152 | | //redirect(append_sid($root_path . "login.php?returnto=" . rawurlencode("phpbb2.$phpEx?page=search&search_id=newposts"))); |
|---|
| 153 | | } |
|---|
| 154 | | |
|---|
| 155 | | $show_results = 'topics'; |
|---|
| 156 | | $sort_by = 0; |
|---|
| 157 | | $sort_dir = 'DESC'; |
|---|
| 158 | | } |
|---|
| 159 | | else if ( $search_id == 'egosearch' ) |
|---|
| 160 | | { |
|---|
| 161 | | if ( $userdata['session_logged_in'] ) |
|---|
| 162 | | { |
|---|
| 163 | | $sql = "SELECT post_id |
|---|
| 164 | | FROM " . POSTS_TABLE . " |
|---|
| 165 | | WHERE poster_id = " . $userdata['uid']; |
|---|
| 166 | | } |
|---|
| 167 | | else |
|---|
| 168 | | { |
|---|
| 169 | | loggedinorreturn(); |
|---|
| 170 | | //redirect(append_sid($root_path . "login.php?returnto=" . rawurlencode("phpbb2.$phpEx?page=search&search_id=egosearch"))); |
|---|
| 171 | | } |
|---|
| 172 | | |
|---|
| 173 | | $show_results = 'topics'; |
|---|
| 174 | | $sort_by = 0; |
|---|
| 175 | | $sort_dir = 'DESC'; |
|---|
| 176 | | } |
|---|
| 177 | | else |
|---|
| 178 | | { |
|---|
| 179 | | $search_author = str_replace('*', '%', trim($search_author)); |
|---|
| 180 | | |
|---|
| 181 | | if( ( strpos($search_author, '%') !== false ) && ( utf_strlen(str_replace('%', '', $search_author)) < $config['search_min_chars'] ) ) |
|---|
| 182 | | { |
|---|
| 183 | | $search_author = ''; |
|---|
| 184 | | } |
|---|
| 185 | | |
|---|
| 186 | | $sql = "SELECT uid |
|---|
| 187 | | FROM " . USERS_TABLE . " |
|---|
| 188 | | WHERE name LIKE '" . str_replace("\'", "''", $search_author) . "'"; |
|---|
| 189 | | $result = $db->sql_query($sql); |
|---|
| 190 | | |
|---|
| 191 | | $matching_userids = ''; |
|---|
| 192 | | if ( $row = $db->sql_fetchrow($result) ) |
|---|
| 193 | | { |
|---|
| 194 | | do |
|---|
| 195 | | { |
|---|
| 196 | | $matching_userids .= ( ( $matching_userids != '' ) ? ', ' : '' ) . $row['uid']; |
|---|
| 197 | | } |
|---|
| 198 | | while( $row = $db->sql_fetchrow($result) ); |
|---|
| 199 | | } |
|---|
| 200 | | else |
|---|
| 201 | | { |
|---|
| 202 | | trigger_error($lang['no_search_match']); |
|---|
| 203 | | return; |
|---|
| 204 | | } |
|---|
| 205 | | |
|---|
| 206 | | $sql = "SELECT post_id |
|---|
| 207 | | FROM " . POSTS_TABLE . " |
|---|
| 208 | | WHERE poster_id IN ($matching_userids)"; |
|---|
| 209 | | |
|---|
| 210 | | if ($search_time) |
|---|
| 211 | | { |
|---|
| 212 | | $sql .= " AND post_time >= " . $search_time; |
|---|
| 213 | | } |
|---|
| 214 | | } |
|---|
| 215 | | |
|---|
| 216 | | $result = $db->sql_query($sql); |
|---|
| 217 | | |
|---|
| 218 | | $search_ids = array(); |
|---|
| 219 | | while( $row = $db->sql_fetchrow($result) ) |
|---|
| 220 | | { |
|---|
| 221 | | $search_ids[] = $row['post_id']; |
|---|
| 222 | | } |
|---|
| 223 | | $db->sql_freeresult($result); |
|---|
| 224 | | |
|---|
| 225 | | $total_match_count = sizeof($search_ids); |
|---|
| 226 | | |
|---|
| 227 | | } |
|---|
| 228 | | else if ( $search_keywords != '' ) |
|---|
| 229 | | { |
|---|
| 230 | | $stopword_array = @file($root_path . 'languages/lang_' . $config['default_lang'] . '/search_stopwords.txt'); |
|---|
| 231 | | $synonym_array = @file($root_path . 'languages/lang_' . $config['default_lang'] . '/search_synonyms.txt'); |
|---|
| 232 | | |
|---|
| 233 | | $stripped_keywords = ( STRIP ? stripslashes($search_keywords) : $search_keywords ); |
|---|
| 234 | | $split_search = split_words(clean_words('search', $stripped_keywords, $stopword_array, $synonym_array), 'search'); |
|---|
| 235 | | unset($stripped_keywords); |
|---|
| 236 | | |
|---|
| 237 | | $search_msg_only = ( !$search_fields ) ? "AND m.title_match = 0" : ''; |
|---|
| 238 | | |
|---|
| 239 | | $word_count = 0; |
|---|
| 240 | | $current_match_type = 'or'; |
|---|
| 241 | | |
|---|
| 242 | | $word_match = array(); |
|---|
| 243 | | $result_list = array(); |
|---|
| 244 | | |
|---|
| 245 | | for($i = 0; $i < sizeof($split_search); $i++) |
|---|
| 246 | | { |
|---|
| 247 | | if ( utf_strlen(str_replace(array('*', '%'), '', trim($split_search[$i]))) < $config['search_min_chars'] ) |
|---|
| 248 | | { |
|---|
| 249 | | $split_search[$i] = ''; |
|---|
| 250 | | continue; |
|---|
| 251 | | } |
|---|
| 252 | | |
|---|
| 253 | | switch ( $split_search[$i] ) |
|---|
| 254 | | { |
|---|
| 255 | | case 'and': |
|---|
| 256 | | $current_match_type = 'and'; |
|---|
| 257 | | break; |
|---|
| 258 | | |
|---|
| 259 | | case 'or': |
|---|
| 260 | | $current_match_type = 'or'; |
|---|
| 261 | | break; |
|---|
| 262 | | |
|---|
| 263 | | case 'not': |
|---|
| 264 | | $current_match_type = 'not'; |
|---|
| 265 | | break; |
|---|
| 266 | | |
|---|
| 267 | | default: |
|---|
| 268 | | if ( !empty($search_terms) ) |
|---|
| 269 | | { |
|---|
| 270 | | $current_match_type = 'and'; |
|---|
| 271 | | } |
|---|
| 272 | | |
|---|
| 273 | | $match_word = str_replace('*', '%', $split_search[$i]); |
|---|
| 274 | | $sql = "SELECT m.post_id |
|---|
| 275 | | FROM " . SEARCH_WORD_TABLE . " w, " . SEARCH_MATCH_TABLE . " m |
|---|
| 276 | | WHERE w.word_text LIKE '$match_word' |
|---|
| 277 | | AND m.word_id = w.word_id |
|---|
| 278 | | AND w.word_common <> 1 |
|---|
| 279 | | $search_msg_only"; |
|---|
| 280 | | $result = $db->sql_query($sql); |
|---|
| 281 | | |
|---|
| 282 | | $row = array(); |
|---|
| 283 | | while( $temp_row = $db->sql_fetchrow($result) ) |
|---|
| 284 | | { |
|---|
| 285 | | $row[$temp_row['post_id']] = 1; |
|---|
| 286 | | |
|---|
| 287 | | if ( !$word_count ) |
|---|
| 288 | | { |
|---|
| 289 | | $result_list[$temp_row['post_id']] = 1; |
|---|
| 290 | | } |
|---|
| 291 | | else if ( $current_match_type == 'or' ) |
|---|
| 292 | | { |
|---|
| 293 | | $result_list[$temp_row['post_id']] = 1; |
|---|
| 294 | | } |
|---|
| 295 | | else if ( $current_match_type == 'not' ) |
|---|
| 296 | | { |
|---|
| 297 | | $result_list[$temp_row['post_id']] = 0; |
|---|
| 298 | | } |
|---|
| 299 | | } |
|---|
| 300 | | |
|---|
| 301 | | if ( $current_match_type == 'and' && $word_count ) |
|---|
| 302 | | { |
|---|
| 303 | | @reset($result_list); |
|---|
| 304 | | while( list($post_id, $match_count) = @each($result_list) ) |
|---|
| 305 | | { |
|---|
| 306 | | if ( !$row[$post_id] ) |
|---|
| 307 | | { |
|---|
| 308 | | $result_list[$post_id] = 0; |
|---|
| 309 | | } |
|---|
| 310 | | } |
|---|
| 311 | | } |
|---|
| 312 | | |
|---|
| 313 | | $word_count++; |
|---|
| 314 | | |
|---|
| 315 | | $db->sql_freeresult($result); |
|---|
| 316 | | } |
|---|
| 317 | | } |
|---|
| 318 | | |
|---|
| 319 | | @reset($result_list); |
|---|
| 320 | | |
|---|
| 321 | | $search_ids = array(); |
|---|
| 322 | | while( list($post_id, $matches) = each($result_list) ) |
|---|
| 323 | | { |
|---|
| 324 | | if ( $matches ) |
|---|
| 325 | | { |
|---|
| 326 | | |
|---|
| 327 | | // Topic Search MOD |
|---|
| 328 | | if($tid) |
|---|
| 329 | | { |
|---|
| 330 | | $sql = "SELECT post_id |
|---|
| 331 | | FROM " . POSTS_TABLE . " |
|---|
| 332 | | WHERE topic_id = '$tid'"; |
|---|
| 333 | | $result = $db->sql_query($sql); |
|---|
| 334 | | while( $test = $db->sql_fetchrow($result) ) |
|---|
| 335 | | { |
|---|
| 336 | | if($test['post_id'] == $post_id) |
|---|
| 337 | | { |
|---|
| 338 | | $search_ids[] = $post_id; |
|---|
| 339 | | } |
|---|
| 340 | | } |
|---|
| 341 | | $show_results = 'posts'; |
|---|
| 342 | | } |
|---|
| 343 | | else |
|---|
| 344 | | { // End Topic Search MOD |
|---|
| 345 | | |
|---|
| 346 | | $search_ids[] = $post_id; |
|---|
| 347 | | // Topic Search MOD |
|---|
| 348 | | } |
|---|
| 349 | | // End Topic search MOD |
|---|
| 350 | | } |
|---|
| 351 | | } |
|---|
| 352 | | |
|---|
| 353 | | unset($result_list); |
|---|
| 354 | | $total_match_count = sizeof($search_ids); |
|---|
| 355 | | } |
|---|
| 356 | | |
|---|
| 357 | | // |
|---|
| 358 | | // If user is logged in then we'll check to see which (if any) private |
|---|
| 359 | | // forums they are allowed to view and include them in the search. |
|---|
| 360 | | // |
|---|
| 361 | | // If not logged in we explicitly prevent searching of private forums |
|---|
| 362 | | // |
|---|
| 363 | | $auth_sql = ''; |
|---|
| 364 | | if ( $search_forum != -1 ) |
|---|
| 365 | | { |
|---|
| 366 | | $is_auth = auth(AUTH_READ, $search_forum, $userdata); |
|---|
| 367 | | |
|---|
| 368 | | if ( !$is_auth['auth_read'] ) |
|---|
| 369 | | { |
|---|
| 370 | | trigger_error($lang['no_searchable_forums']); |
|---|
| 371 | | return; |
|---|
| 372 | | } |
|---|
| 373 | | |
|---|
| 374 | | $auth_sql = "f.forum_id = $search_forum"; |
|---|
| 375 | | } |
|---|
| 376 | | else |
|---|
| 377 | | { |
|---|
| 378 | | $is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata); |
|---|
| 379 | | |
|---|
| 380 | | if ( $search_cat != -1 ) |
|---|
| 381 | | { |
|---|
| 382 | | $auth_sql = "f.cat_id = $search_cat"; |
|---|
| 383 | | } |
|---|
| 384 | | |
|---|
| 385 | | $ignore_forum_sql = ''; |
|---|
| 386 | | while( list($key, $value) = each($is_auth_ary) ) |
|---|
| 387 | | { |
|---|
| 388 | | if ( !$value['auth_read'] ) |
|---|
| 389 | | { |
|---|
| 390 | | $ignore_forum_sql .= ( ( $ignore_forum_sql != '' ) ? ', ' : '' ) . $key; |
|---|
| 391 | | } |
|---|
| 392 | | } |
|---|
| 393 | | |
|---|
| 394 | | if ( $ignore_forum_sql != '' ) |
|---|
| 395 | | { |
|---|
| 396 | | $auth_sql .= ( $auth_sql != '' ) ? " AND f.forum_id NOT IN ($ignore_forum_sql) " : "f.forum_id NOT IN ($ignore_forum_sql) "; |
|---|
| 397 | | } |
|---|
| 398 | | } |
|---|
| 399 | | |
|---|
| 400 | | // |
|---|
| 401 | | // Author name search |
|---|
| 402 | | // |
|---|
| 403 | | if ( $search_author != '' ) |
|---|
| 404 | | { |
|---|
| 405 | | $search_author = str_replace('*', '%', trim($search_author)); |
|---|
| 406 | | |
|---|
| 407 | | if( ( strpos($search_author, '%') !== false ) && ( utf_strlen(str_replace('%', '', $search_author)) < $config['search_min_chars'] ) ) |
|---|
| 408 | | { |
|---|
| 409 | | $search_author = ''; |
|---|
| 410 | | } |
|---|
| 411 | | } |
|---|
| 412 | | |
|---|
| 413 | | if ( $total_match_count ) |
|---|
| 414 | | { |
|---|
| 415 | | if ( $show_results == 'topics' ) |
|---|
| 416 | | { |
|---|
| 417 | | // |
|---|
| 418 | | // This one is a beast, try to seperate it a bit (workaround for connection timeouts) |
|---|
| 419 | | // |
|---|
| 420 | | $search_id_chunks = array(); |
|---|
| 421 | | $count = 0; |
|---|
| 422 | | $chunk = 0; |
|---|
| 423 | | |
|---|
| 424 | | if (sizeof($search_ids) > $limiter) |
|---|
| 425 | | { |
|---|
| 426 | | for ($i = 0; $i < sizeof($search_ids); $i++) |
|---|
| 427 | | { |
|---|
| 428 | | if ($count == $limiter) |
|---|
| 429 | | { |
|---|
| 430 | | $chunk++; |
|---|
| 431 | | $count = 0; |
|---|
| 432 | | } |
|---|
| 433 | | |
|---|
| 434 | | $search_id_chunks[$chunk][$count] = $search_ids[$i]; |
|---|
| 435 | | $count++; |
|---|
| 436 | | } |
|---|
| 437 | | } |
|---|
| 438 | | else |
|---|
| 439 | | { |
|---|
| 440 | | $search_id_chunks[0] = $search_ids; |
|---|
| 441 | | } |
|---|
| 442 | | |
|---|
| 443 | | $search_ids = array(); |
|---|
| 444 | | |
|---|
| 445 | | for ($i = 0; $i < sizeof($search_id_chunks); $i++) |
|---|
| 446 | | { |
|---|
| 447 | | $where_sql = ''; |
|---|
| 448 | | |
|---|
| 449 | | if ( $search_time ) |
|---|
| 450 | | { |
|---|
| 451 | | $where_sql .= ( $search_author == '' && $auth_sql == '' ) ? " AND post_time >= $search_time " : " AND p.post_time >= $search_time "; |
|---|
| 452 | | } |
|---|
| 453 | | |
|---|
| 454 | | if ( $search_author == '' && $auth_sql == '' ) |
|---|
| 455 | | { |
|---|
| 456 | | $sql = "SELECT topic_id |
|---|
| 457 | | FROM " . POSTS_TABLE . " |
|---|
| 458 | | WHERE post_id IN (" . implode(", ", $search_id_chunks[$i]) . ") |
|---|
| 459 | | $where_sql |
|---|
| 460 | | GROUP BY topic_id"; |
|---|
| 461 | | } |
|---|
| 462 | | else |
|---|
| 463 | | { |
|---|
| 464 | | $from_sql = POSTS_TABLE . " p"; |
|---|
| 465 | | |
|---|
| 466 | | if ( $search_author != '' ) |
|---|
| 467 | | { |
|---|
| 468 | | $from_sql .= ", " . USERS_TABLE . " u"; |
|---|
| 469 | | $where_sql .= " AND u.uid = p.poster_id AND u.name LIKE '$search_author' "; |
|---|
| 470 | | } |
|---|
| 471 | | |
|---|
| 472 | | if ( $auth_sql != '' ) |
|---|
| 473 | | { |
|---|
| 474 | | $from_sql .= ", " . FORUMS_TABLE . " f"; |
|---|
| 475 | | $where_sql .= " AND f.forum_id = p.forum_id AND $auth_sql"; |
|---|
| 476 | | } |
|---|
| 477 | | |
|---|
| 478 | | $sql = "SELECT p.topic_id |
|---|
| 479 | | FROM $from_sql |
|---|
| 480 | | WHERE p.post_id IN (" . implode(", ", $search_id_chunks[$i]) . ") |
|---|
| 481 | | $where_sql |
|---|
| 482 | | GROUP BY p.topic_id"; |
|---|
| 483 | | } |
|---|
| 484 | | |
|---|
| 485 | | $result = $db->sql_query($sql); |
|---|
| 486 | | |
|---|
| 487 | | while ($row = $db->sql_fetchrow($result)) |
|---|
| 488 | | { |
|---|
| 489 | | $search_ids[] = $row['topic_id']; |
|---|
| 490 | | } |
|---|
| 491 | | $db->sql_freeresult($result); |
|---|
| 492 | | } |
|---|
| 493 | | |
|---|
| 494 | | $total_match_count = sizeof($search_ids); |
|---|
| 495 | | |
|---|
| 496 | | } |
|---|
| 497 | | else if ( $search_author != '' || $search_time || $auth_sql != '' ) |
|---|
| 498 | | { |
|---|
| 499 | | $search_id_chunks = array(); |
|---|
| 500 | | $count = 0; |
|---|
| 501 | | $chunk = 0; |
|---|
| 502 | | |
|---|
| 503 | | if (count($search_ids) > $limiter) |
|---|
| 504 | | { |
|---|
| 505 | | for ($i = 0; $i < count($search_ids); $i++) |
|---|
| 506 | | { |
|---|
| 507 | | if ($count == $limiter) |
|---|
| 508 | | { |
|---|
| 509 | | $chunk++; |
|---|
| 510 | | $count = 0; |
|---|
| 511 | | } |
|---|
| 512 | | |
|---|
| 513 | | $search_id_chunks[$chunk][$count] = $search_ids[$i]; |
|---|
| 514 | | $count++; |
|---|
| 515 | | } |
|---|
| 516 | | } |
|---|
| 517 | | else |
|---|
| 518 | | { |
|---|
| 519 | | $search_id_chunks[0] = $search_ids; |
|---|
| 520 | | } |
|---|
| 521 | | |
|---|
| 522 | | $search_ids = array(); |
|---|
| 523 | | |
|---|
| 524 | | for ($i = 0; $i < count($search_id_chunks); $i++) |
|---|
| 525 | | { |
|---|
| 526 | | $where_sql = ( $search_author == '' && $auth_sql == '' ) ? 'post_id IN (' . implode(', ', $search_id_chunks[$i]) . ')' : 'p.post_id IN (' . implode(', ', $search_id_chunks[$i]) . ')'; |
|---|
| 527 | | $select_sql = ( $search_author == '' && $auth_sql == '' ) ? 'post_id' : 'p.post_id'; |
|---|
| 528 | | $from_sql = ( $search_author == '' && $auth_sql == '' ) ? POSTS_TABLE : POSTS_TABLE . ' p'; |
|---|
| 529 | | |
|---|
| 530 | | if ( $search_time ) |
|---|
| 531 | | { |
|---|
| 532 | | $where_sql .= ( $search_author == '' && $auth_sql == '' ) ? " AND post_time >= $search_time " : " AND p.post_time >= $search_time"; |
|---|
| 533 | | } |
|---|
| 534 | | |
|---|
| 535 | | if ( $auth_sql != '' ) |
|---|
| 536 | | { |
|---|
| 537 | | $from_sql .= ", " . FORUMS_TABLE . " f"; |
|---|
| 538 | | $where_sql .= " AND f.forum_id = p.forum_id AND $auth_sql"; |
|---|
| 539 | | } |
|---|
| 540 | | |
|---|
| 541 | | if ( $search_author != '' ) |
|---|
| 542 | | { |
|---|
| 543 | | $from_sql .= ", " . USERS_TABLE . " u"; |
|---|
| 544 | | $where_sql .= " AND u.uid = p.poster_id AND u.name LIKE '$search_author'"; |
|---|
| 545 | | } |
|---|
| 546 | | |
|---|
| 547 | | $sql = "SELECT " . $select_sql . " |
|---|
| 548 | | FROM $from_sql |
|---|
| 549 | | WHERE $where_sql"; |
|---|
| 550 | | $result = $db->sql_query($sql); |
|---|
| 551 | | |
|---|
| 552 | | while( $row = $db->sql_fetchrow($result) ) |
|---|
| 553 | | { |
|---|
| 554 | | $search_ids[] = $row['post_id']; |
|---|
| 555 | | } |
|---|
| 556 | | $db->sql_freeresult($result); |
|---|
| 557 | | } |
|---|
| 558 | | |
|---|
| 559 | | $total_match_count = count($search_ids); |
|---|
| 560 | | } |
|---|
| 561 | | } |
|---|
| 562 | | else if ( $search_id == 'unanswered' ) |
|---|
| 563 | | { |
|---|
| 564 | | if ( $auth_sql != '' ) |
|---|
| 565 | | { |
|---|
| 566 | | $sql = "SELECT t.topic_id, f.forum_id |
|---|
| 567 | | FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f |
|---|
| 568 | | WHERE t.topic_replies = 0 |
|---|
| 569 | | AND t.forum_id = f.forum_id |
|---|
| 570 | | AND t.topic_moved_id = 0 |
|---|
| 571 | | AND $auth_sql"; |
|---|
| 572 | | } |
|---|
| 573 | | else |
|---|
| 574 | | { |
|---|
| 575 | | $sql = "SELECT topic_id |
|---|
| 576 | | FROM " . TOPICS_TABLE . " |
|---|
| 577 | | WHERE topic_replies = 0 |
|---|
| 578 | | AND topic_moved_id = 0"; |
|---|
| 579 | | } |
|---|
| 580 | | |
|---|
| 581 | | $result = $db->sql_query($sql); |
|---|
| 582 | | |
|---|
| 583 | | $search_ids = array(); |
|---|
| 584 | | while( $row = $db->sql_fetchrow($result) ) |
|---|
| 585 | | { |
|---|
| 586 | | $search_ids[] = $row['topic_id']; |
|---|
| 587 | | } |
|---|
| 588 | | $db->sql_freeresult($result); |
|---|
| 589 | | |
|---|
| 590 | | $total_match_count = count($search_ids); |
|---|
| 591 | | |
|---|
| 592 | | // |
|---|
| 593 | | // Basic requirements |
|---|
| 594 | | // |
|---|
| 595 | | $show_results = 'topics'; |
|---|
| 596 | | $sort_by = 0; |
|---|
| 597 | | $sort_dir = 'DESC'; |
|---|
| 598 | | } |
|---|
| 599 | | else |
|---|
| 600 | | { |
|---|
| 601 | | trigger_error($lang['no_search_match']); |
|---|
| 602 | | return; |
|---|
| 603 | | } |
|---|
| 604 | | |
|---|
| 605 | | // |
|---|
| 606 | | // Store new result data |
|---|
| 607 | | // |
|---|
| 608 | | $search_results = implode(', ', $search_ids); |
|---|
| 609 | | $per_page = ( $show_results == 'posts' ) ? $config['posts_per_page'] : $config['topics_per_page']; |
|---|
| 610 | | |
|---|
| 611 | | // |
|---|
| 612 | | // Combine both results and search data (apart from original query) |
|---|
| 613 | | // so we can serialize it and place it in the DB |
|---|
| 614 | | // |
|---|
| 615 | | $store_search_data = array(); |
|---|
| 616 | | |
|---|
| 617 | | // |
|---|
| 618 | | // Limit the character length (and with this the results displayed at all following pages) to prevent |
|---|
| 619 | | // truncated result arrays. Normally, search results above 12000 are affected. |
|---|
| 620 | | // - to include or not to include |
|---|
| 621 | | /* |
|---|
| 622 | | $max_result_length = 60000; |
|---|
| 623 | | if (utf_strlen($search_results) > $max_result_length) |
|---|
| 624 | | { |
|---|
| 625 | | $search_results = substr($search_results, 0, $max_result_length); |
|---|
| 626 | | $search_results = substr($search_results, 0, strrpos($search_results, ',')); |
|---|
| 627 | | $total_match_count = count(explode(', ', $search_results)); |
|---|
| 628 | | } |
|---|
| 629 | | */ |
|---|
| 630 | | |
|---|
| 631 | | for($i = 0; $i < sizeof($store_vars); $i++) |
|---|
| 632 | | { |
|---|
| 633 | | $store_search_data[$store_vars[$i]] = $$store_vars[$i]; |
|---|
| 634 | | } |
|---|
| 635 | | |
|---|
| 636 | | $result_array = serialize($store_search_data); |
|---|
| 637 | | unset($store_search_data); |
|---|
| 638 | | |
|---|
| 639 | | $search_id = md5(dss_rand()); |
|---|
| 640 | | |
|---|
| 641 | | $sql = "UPDATE " . SEARCH_TABLE . " |
|---|
| 642 | | SET search_id = '" . $db->sql_escape($search_id) . "', search_time = $current_time, search_array = '" . $db->sql_escape($result_array) . "' |
|---|
| 643 | | WHERE session_id = '" . $userdata['session_id'] . "'"; |
|---|
| 644 | | if ( !($result = $db->sql_query($sql)) || !$db->sql_affectedrows() ) |
|---|
| 645 | | { |
|---|
| 646 | | $sql = "INSERT INTO " . SEARCH_TABLE . " (search_id, session_id, search_time, search_array) |
|---|
| 647 | | VALUES('" . $db->sql_escape($search_id) . "', '" . $userdata['session_id'] . "', $current_time, '" . $db->sql_escape($result_array) . "')"; |
|---|
| 648 | | $result = $db->sql_query($sql); |
|---|
| 649 | | } |
|---|
| 650 | | } |
|---|
| 651 | | else |
|---|
| 652 | | { |
|---|
| 653 | | $search_id = intval($search_id); |
|---|
| 654 | | if ( $search_id ) |
|---|
| 655 | | { |
|---|
| 656 | | $sql = "SELECT search_array |
|---|
| 657 | | FROM " . SEARCH_TABLE . " |
|---|
| 658 | | WHERE search_id = '" . $db->sql_escape($search_id) . "' |
|---|
| 659 | | AND session_id = '". $userdata['session_id'] . "'"; |
|---|
| 660 | | $result = $db->sql_query($sql); |
|---|
| 661 | | |
|---|
| 662 | | if ( $row = $db->sql_fetchrow($result) ) |
|---|
| 663 | | { |
|---|
| 664 | | $search_data = unserialize($row['search_array']); |
|---|
| 665 | | for($i = 0; $i < sizeof($store_vars); $i++) |
|---|
| 666 | | { |
|---|
| 667 | | $$store_vars[$i] = $search_data[$store_vars[$i]]; |
|---|
| 668 | | } |
|---|
| 669 | | } |
|---|
| 670 | | } |
|---|
| 671 | | } |
|---|
| 672 | | // |
|---|
| 673 | | // Look up data ... |
|---|
| 674 | | // |
|---|
| 675 | | if ( $search_results != '' ) |
|---|
| 676 | | { |
|---|
| 677 | | if ( $show_results == 'posts' ) |
|---|
| 678 | | { |
|---|
| 679 | | $sql = "SELECT pt.post_text, pt.post_subject, p.*, f.forum_id, f.forum_name, t.*, u.name AS username, u.uid, c.cat_id, c.cat_title, f2.forum_id AS p_forum_id, f2.forum_name AS p_forum_name |
|---|
| 680 | | FROM " . FORUMS_TABLE . " f LEFT JOIN " . FORUMS_TABLE . " f2 ON ( f.forum_parent = f2.forum_id ), |
|---|
| 681 | | " . FORUM_CATEGORIES_TABLE . " c, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TEXT_TABLE . " pt |
|---|
| 682 | | WHERE p.post_id IN ($search_results) |
|---|
| 683 | | AND pt.post_id = p.post_id |
|---|
| 684 | | AND f.forum_id = p.forum_id |
|---|
| 685 | | AND p.topic_id = t.topic_id |
|---|
| 686 | | AND p.poster_id = u.uid |
|---|
| 687 | | AND f.cat_id = c.cat_id"; |
|---|
| 688 | | } |
|---|
| 689 | | else |
|---|
| 690 | | { |
|---|
| 691 | | $sql = "SELECT t.*, f.forum_id, f.forum_name, u.name AS username, u.uid, u2.name as user2, u2.uid as id2, p.post_username, p2.post_username AS post_username2, p2.post_time, c.cat_id, c.cat_title, f2.forum_id AS p_forum_id, f2.forum_name AS p_forum_name |
|---|
| 692 | | FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f LEFT JOIN " . FORUMS_TABLE . " f2 ON ( f.forum_parent = f2.forum_id )," . FORUM_CATEGORIES_TABLE . " c, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2 |
|---|
| 693 | | WHERE t.topic_id IN ($search_results) |
|---|
| 694 | | AND t.topic_poster = u.uid |
|---|
| 695 | | AND f.forum_id = t.forum_id |
|---|
| 696 | | AND p.post_id = t.topic_first_post_id |
|---|
| 697 | | AND p2.post_id = t.topic_last_post_id |
|---|
| 698 | | AND u2.uid = p2.poster_id |
|---|
| 699 | | AND f.cat_id = c.cat_id"; |
|---|
| 700 | | } |
|---|
| 701 | | |
|---|
| 702 | | $per_page = ( $show_results == 'posts' ) ? $config['posts_per_page'] : $config['topics_per_page']; |
|---|
| 703 | | |
|---|
| 704 | | /*if ($userdata['session_logged_in']) |
|---|
| 705 | | { |
|---|
| 706 | | if ($config['load_db_track'] && $author_id !== $userdata['uid']) |
|---|
| 707 | | { |
|---|
| 708 | | $sql_from .= ' LEFT JOIN ' . TOPICS_POSTED_TABLE . ' tp ON (tp.user_id = ' . $userdata['uid'] . ' |
|---|
| 709 | | AND t.topic_id = tp.topic_id)'; |
|---|
| 710 | | $sql_select .= ', tp.topic_posted'; |
|---|
| 711 | | } |
|---|
| 712 | | |
|---|
| 713 | | if ($config['load_db_lastread']) |
|---|
| 714 | | { |
|---|
| 715 | | $sql_from .= ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.user_id = ' . $userdata['uid'] . ' |
|---|
| 716 | | AND t.topic_id = tt.topic_id) |
|---|
| 717 | | LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $userdata['uid'] . ' |
|---|
| 718 | | AND ft.forum_id = f.forum_id)'; |
|---|
| 719 | | $sql_select .= ', tt.mark_time, ft.mark_time as f_mark_time'; |
|---|
| 720 | | } |
|---|
| 721 | | } |
|---|
| 722 | | |
|---|
| 723 | | if ($config['load_anon_lastread'] || ($userdata['session_logged_in'] && !$config['load_db_lastread'])) |
|---|
| 724 | | {*/ |
|---|
| 725 | | $tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : ''; |
|---|
| 726 | | $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); |
|---|
| 727 | | //} |
|---|
| 728 | | $topic_tracking_info = array(); |
|---|
| 729 | | |
|---|
| 730 | | $sql .= " ORDER BY "; |
|---|
| 731 | | switch ( $sort_by ) |
|---|
| 732 | | { |
|---|
| 733 | | case 1: |
|---|
| 734 | | $sql .= ( $show_results == 'posts' ) ? 'pt.post_subject' : 't.topic_title'; |
|---|
| 735 | | break; |
|---|
| 736 | | case 2: |
|---|
| 737 | | $sql .= 't.topic_title'; |
|---|
| 738 | | break; |
|---|
| 739 | | case 3: |
|---|
| 740 | | $sql .= 'u.name'; |
|---|
| 741 | | break; |
|---|
| 742 | | case 4: |
|---|
| 743 | | $sql .= 'f.forum_id'; |
|---|
| 744 | | break; |
|---|
| 745 | | default: |
|---|
| 746 | | $sql .= ( $show_results == 'posts' ) ? 'p.post_time' : 'p2.post_time'; |
|---|
| 747 | | break; |
|---|
| 748 | | } |
|---|
| 749 | | |
|---|
| 750 | | $sql .= ' ' . $sort_dir . ' LIMIT ' . $start . ', ' . $per_page; |
|---|
| 751 | | |
|---|
| 752 | | $result = $db->sql_query($sql); |
|---|
| 753 | | |
|---|
| 754 | | $searchset = array(); |
|---|
| 755 | | $forums = array(); |
|---|
| 756 | | while( $row = $db->sql_fetchrow($result) ) |
|---|
| 757 | | { |
|---|
| 758 | | $searchset[] = $row; |
|---|
| 759 | | |
|---|
| 760 | | $forums[$row['forum_id']]['topic_list'][] = $row['topic_id']; |
|---|
| 761 | | } |
|---|
| 762 | | |
|---|
| 763 | | foreach ($forums as $forum_id => $forum) |
|---|
| 764 | | { |
|---|
| 765 | | /*if ($userdata['session_logged_in'] && $config['load_db_lastread']) |
|---|
| 766 | | { |
|---|
| 767 | | $topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time']), ($forum_id) ? false : $forum['topic_list']); |
|---|
| 768 | | } |
|---|
| 769 | | else if ($config['load_anon_lastread'] || $userdata['session_logged_in']) |
|---|
| 770 | | {*/ |
|---|
| 771 | | $topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list'], ($forum_id) ? false : $forum['topic_list']); |
|---|
| 772 | | |
|---|
| 773 | | if (!$userdata['session_logged_in']) |
|---|
| 774 | | { |
|---|
| 775 | | $userdata['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['onlinesince']) : 0; |
|---|
| 776 | | } |
|---|
| 777 | | //} |
|---|
| 778 | | } |
|---|
| 779 | | unset($forums); |
|---|
| 780 | | |
|---|
| 781 | | $db->sql_freeresult($result); |
|---|
| 782 | | |
|---|
| 783 | | // |
|---|
| 784 | | // Define censored word matches |
|---|
| 785 | | // |
|---|
| 786 | | $orig_word = array(); |
|---|
| 787 | | $replacement_word = array(); |
|---|
| 788 | | $cache->obtain_word_list($orig_word, $replacement_word); |
|---|
| 789 | | |
|---|
| 790 | | // |
|---|
| 791 | | // Output header |
|---|
| 792 | | // |
|---|
| 793 | | stdhead($lang['forums'] . ' :: ' . $lang['search'], false); |
|---|
| 794 | | |
|---|
| 795 | | if ( $show_results == 'posts' ) |
|---|
| 796 | | { |
|---|
| 797 | | // Topic search MOD |
|---|
| 798 | | if( !$tid ) |
|---|
| 799 | | { |
|---|
| 800 | | // End Topic search MOD |
|---|
| 801 | | $template->set_filenames(array( |
|---|
| 802 | | 'body' => 'forum/search_results_posts.tpl') |
|---|
| 803 | | ); |
|---|
| 804 | | // Topic search MOD |
|---|
| 805 | | } |
|---|
| 806 | | else |
|---|
| 807 | | { |
|---|
| 808 | | $template->set_filenames(array( |
|---|
| 809 | | 'body' => 'forum/topic_search_results.tpl') |
|---|
| 810 | | ); |
|---|
| 811 | | } |
|---|
| 812 | | // End Topic search MOD |
|---|
| 813 | | } |
|---|
| 814 | | else |
|---|
| 815 | | { |
|---|
| 816 | | $template->set_filenames(array( |
|---|
| 817 | | 'body' => 'forum/search_results_topics.tpl') |
|---|
| 818 | | ); |
|---|
| 819 | | } |
|---|
| 820 | | //make_jumpbox('viewforum.'.$phpEx); |
|---|
| 821 | | make_jumpbox('phpbb2.php?page=viewforum'); |
|---|
| 822 | | |
|---|
| 823 | | $l_search_matches = ( $total_match_count == 1 ) ? sprintf($lang['found_search_match'], $total_match_count) : sprintf($lang['found_search_matches'], $total_match_count); |
|---|
| 824 | | |
|---|
| 825 | | $template->assign_vars(array( |
|---|
| 826 | | 'L_SEARCH_MATCHES' => $l_search_matches) |
|---|
| 827 | | ); |
|---|
| 828 | | |
|---|
| 829 | | $highlight_active = ''; |
|---|
| 830 | | $highlight_match = array(); |
|---|
| 831 | | for($j = 0; $j < sizeof($split_search); $j++ ) |
|---|
| 832 | | { |
|---|
| 833 | | $split_word = $split_search[$j]; |
|---|
| 834 | | |
|---|
| 835 | | if ( $split_word != 'and' && $split_word != 'or' && $split_word != 'not' ) |
|---|
| 836 | | { |
|---|
| 837 | | $highlight_match[] = '#\b(' . str_replace("*", "([\w]+)?", $split_word) . ')\b#is'; |
|---|
| 838 | | $highlight_active .= " " . $split_word; |
|---|
| 839 | | |
|---|
| 840 | | for ($k = 0; $k < sizeof($synonym_array); $k++) |
|---|
| 841 | | { |
|---|
| 842 | | list($replace_synonym, $match_synonym) = split(' ', trim(utf_strtolower($synonym_array[$k]))); |
|---|
| 843 | | |
|---|
| 844 | | if ( $replace_synonym == $split_word ) |
|---|
| 845 | | { |
|---|
| 846 | | $highlight_match[] = '#\b(' . str_replace("*", "([\w]+)?", $replace_synonym) . ')\b#is'; |
|---|
| 847 | | $highlight_active .= ' ' . $match_synonym; |
|---|
| 848 | | } |
|---|
| 849 | | } |
|---|
| 850 | | } |
|---|
| 851 | | } |
|---|
| 852 | | |
|---|
| 853 | | $highlight_active = urlencode(trim($highlight_active)); |
|---|
| 854 | | |
|---|
| 855 | | for($i = 0; $i < sizeof($searchset); $i++) |
|---|
| 856 | | { |
|---|
| 857 | | |
|---|
| 858 | | $topic_title = $searchset[$i]['topic_title']; |
|---|
| 859 | | |
|---|
| 860 | | $forum_id = $searchset[$i]['forum_id']; |
|---|
| 861 | | $topic_id = $searchset[$i]['topic_id']; |
|---|
| 862 | | |
|---|
| 863 | | // www.phpBB-SEO.com SEO TOOLKIT BEGIN |
|---|
| 864 | | $seo->set_url($searchset[$i]['cat_id'], $searchset[$i]['cat_title'], $seo->seo_static['forum_cat']); |
|---|
| 865 | | |
|---|
| 866 | | if ( !empty($searchset[$i]['p_forum_id']) ) { |
|---|
| 867 | | $seo->set_parent($searchset[$i]['p_forum_id'], $seo->seo_static['forum'], $searchset[$i]['cat_id'], $seo->seo_static['forum_cat']); |
|---|
| 868 | | $seo->set_url($searchset[$i]['p_forum_name'], $searchset[$i]['p_forum_id'], $seo->seo_static['forum']); |
|---|
| 869 | | $seo->set_parent($forum_id, $seo->seo_static['forum'], $searchset[$i]['p_forum_id'], $seo->seo_static['forum']); |
|---|
| 870 | | } |
|---|
| 871 | | else { |
|---|
| 872 | | $seo->set_parent($forum_id, $seo->seo_static['forum'], $searchset[$i]['cat_id'], $seo->seo_static['forum_cat']); |
|---|
| 873 | | } |
|---|
| 874 | | $seo->set_url($searchset[$i]['forum_name'], $forum_id, $seo->seo_static['forum']); |
|---|
| 875 | | |
|---|
| 876 | | $seo->set_parent($topic_id, $seo->seo_static['topic'], $forum_id, $seo->seo_static['forum']); |
|---|
| 877 | | $seo->set_url($topic_title, $topic_id, $seo->seo_static['topic']); |
|---|
| 878 | | |
|---|
| 879 | | if ( $show_results != 'posts' ) { |
|---|
| 880 | | |
|---|
| 881 | | $seo->set_user_url($searchset[$i]['username'], $searchset[$i]['uid']); |
|---|
| 882 | | $seo->set_user_url($searchset[$i]['user2'], $searchset[$i]['id2']); |
|---|
| 883 | | } |
|---|
| 884 | | // www.phpBB-SEO.com SEO TOOLKIT END |
|---|
| 885 | | |
|---|
| 886 | | //$forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . '=' . $searchset[$i]['forum_id']); |
|---|
| 887 | | $forum_url = append_sid($root_path . "phpbb2.php?page=viewforum&" . POST_FORUM_URL . '=' . $searchset[$i]['forum_id']); |
|---|
| 888 | | //$topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $searchset[$i]['topic_id'] . "&highlight=$highlight_active"); |
|---|
| 889 | | $topic_url = append_sid($root_path . "phpbb2.php?page=viewtopic&" . POST_TOPIC_URL . '=' . $searchset[$i]['topic_id'] . "&highlight=$highlight_active"); |
|---|
| 890 | | //$post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $searchset[$i]['post_id'] . "&highlight=$highlight_active") . '#' . $searchset[$i]['post_id']; |
|---|
| 891 | | |
|---|
| 892 | | $post_date = create_date($searchset[$i]['post_time']); |
|---|
| 893 | | |
|---|
| 894 | | if ( $show_results == 'posts' ) |
|---|
| 895 | | { |
|---|
| 896 | | $message = $searchset[$i]['post_text']; |
|---|
| 897 | | $post_url = append_sid($root_path . "phpbb2.php?page=viewtopic&" . POST_POST_URL . '=' . $searchset[$i]['post_id'] . "&highlight=$highlight_active") . '#' . $searchset[$i]['post_id']; |
|---|
| 898 | | |
|---|
| 899 | | if ( isset($return_chars) ) |
|---|
| 900 | | { |
|---|
| 901 | | |
|---|
| 902 | | // |
|---|
| 903 | | // If the board has HTML off but the post has HTML |
|---|
| 904 | | // on then we process it, else leave it alone |
|---|
| 905 | | // |
|---|
| 906 | | if ( $return_chars != -1 ) |
|---|
| 907 | | { |
|---|
| 908 | | $message = strip_tags($message); |
|---|
| 909 | | $message = preg_replace('/\[url\]|\[\/url\]/si', '', $message); |
|---|
| 910 | | $message = ( utf_strlen($message) > $return_chars ) ? substr($message, 0, $return_chars) . ' ...' : $message; |
|---|
| 911 | | } |
|---|
| 912 | | else |
|---|
| 913 | | { |
|---|
| 914 | | if ( !$config['allow_html'] ) |
|---|
| 915 | | { |
|---|
| 916 | | if ( $searchset[$i]['enable_html'] ) |
|---|
| 917 | | { |
|---|
| 918 | | $message = preg_replace('#(<)([\/]?.*?)(>)#is', '<\\2>', $message); |
|---|
| 919 | | } |
|---|
| 920 | | } |
|---|
| 921 | | |
|---|
| 922 | | $bb_code->parse($message); |
|---|
| 923 | | $message = $bb_code->get_html(); |
|---|
| 924 | | |
|---|
| 925 | | if ( $highlight_active ) |
|---|
| 926 | | { |
|---|
| 927 | | if ( preg_match('/<.*>/', $message) ) |
|---|
| 928 | | { |
|---|
| 929 | | $message = preg_replace($highlight_match, '<!-- #sh -->\1<!-- #eh -->', $message); |
|---|
| 930 | | |
|---|
| 931 | | $end_html = 0; |
|---|
| 932 | | $start_html = 1; |
|---|
| 933 | | $temp_message = ''; |
|---|
| 934 | | $message = ' ' . $message . ' '; |
|---|
| 935 | | |
|---|
| 936 | | while( $start_html = strpos($message, '<', $start_html) ) |
|---|
| 937 | | { |
|---|
| 938 | | $grab_length = $start_html - $end_html - 1; |
|---|
| 939 | | $temp_message .= substr($message, $end_html + 1, $grab_length); |
|---|
| 940 | | |
|---|
| 941 | | if ( $end_html = strpos($message, '>', $start_html) ) |
|---|
| 942 | | { |
|---|
| 943 | | $length = $end_html - $start_html + 1; |
|---|
| 944 | | $hold_string = substr($message, $start_html, $length); |
|---|
| 945 | | |
|---|
| 946 | | if ( strrpos(' ' . $hold_string, '<') != 1 ) |
|---|
| 947 | | { |
|---|
| 948 | | $end_html = $start_html + 1; |
|---|
| 949 | | $end_counter = 1; |
|---|
| 950 | | |
|---|
| 951 | | while ( $end_counter && $end_html < utf_strlen($message) ) |
|---|
| 952 | | { |
|---|
| 953 | | if ( substr($message, $end_html, 1) == '>' ) |
|---|
| 954 | | { |
|---|
| 955 | | $end_counter--; |
|---|
| 956 | | } |
|---|
| 957 | | else if ( substr($message, $end_html, 1) == '<' ) |
|---|
| 958 | | { |
|---|
| 959 | | $end_counter++; |
|---|
| 960 | | } |
|---|
| 961 | | |
|---|
| 962 | | $end_html++; |
|---|
| 963 | | } |
|---|
| 964 | | |
|---|
| 965 | | $length = $end_html - $start_html + 1; |
|---|
| 966 | | $hold_string = substr($message, $start_html, $length); |
|---|
| 967 | | $hold_string = str_replace('<!-- #sh -->', '', $hold_string); |
|---|
| 968 | | $hold_string = str_replace('<!-- #eh -->', '', $hold_string); |
|---|
| 969 | | } |
|---|
| 970 | | else if ( $hold_string == '<!-- #sh -->' ) |
|---|
| 971 | | { |
|---|
| 972 | | $hold_string = str_replace('<!-- #sh -->', '<span style="color:#' . $theme['fontcolor3'] . '"><b>', $hold_string); |
|---|
| 973 | | } |
|---|
| 974 | | else if ( $hold_string == '<!-- #eh -->' ) |
|---|
| 975 | | { |
|---|
| 976 | | $hold_string = str_replace('<!-- #eh -->', '</b></span>', $hold_string); |
|---|
| 977 | | } |
|---|
| 978 | | |
|---|
| 979 | | $temp_message .= $hold_string; |
|---|
| 980 | | |
|---|
| 981 | | $start_html += $length; |
|---|
| 982 | | } |
|---|
| 983 | | else |
|---|
| 984 | | { |
|---|
| 985 | | $start_html = utf_strlen($message); |
|---|
| 986 | | } |
|---|
| 987 | | } |
|---|
| 988 | | |
|---|
| 989 | | $grab_length = utf_strlen($message) - $end_html - 1; |
|---|
| 990 | | $temp_message .= substr($message, $end_html + 1, $grab_length); |
|---|
| 991 | | |
|---|
| 992 | | $message = trim($temp_message); |
|---|
| 993 | | } |
|---|
| 994 | | else |
|---|
| 995 | | { |
|---|
| 996 | | $message = preg_replace($highlight_match, '<span style="color:#' . $theme['fontcolor3'] . '"><b>\1</b></span>', $message); |
|---|
| 997 | | } |
|---|
| 998 | | } |
|---|
| 999 | | } |
|---|
| 1000 | | |
|---|
| 1001 | | $topic_title = censor_text($topic_title); |
|---|
| 1002 | | $post_subject = ( $searchset[$i]['post_subject'] != '' ) ? censor_text($searchset[$i]['post_subject']) : $topic_title; |
|---|
| 1003 | | $message = censor_text($message); |
|---|
| 1004 | | |
|---|
| 1005 | | $message = str_replace("\n", '<br />', $message); |
|---|
| 1006 | | |
|---|
| 1007 | | } |
|---|
| 1008 | | |
|---|
| 1009 | | $poster = ( $searchset[$i]['uid'] != ANONYMOUS ) ? '<a href="' . append_sid($root_path . "userdetails.php?id=" . $searchset[$i]['uid']) . '">' : ''; |
|---|
| 1010 | | $poster .= ( $searchset[$i]['uid'] != ANONYMOUS ) ? $searchset[$i]['username'] : ( ( $searchset[$i]['post_username'] != "" ) ? $searchset[$i]['post_username'] : $lang['guest'] ); |
|---|
| 1011 | | $poster .= ( $searchset[$i]['uid'] != ANONYMOUS ) ? '</a>' : ''; |
|---|
| 1012 | | |
|---|
| 1013 | | /*if ( $userdata['session_logged_in'] && $searchset[$i]['post_time'] > $userdata['user_lastvisit'] ) |
|---|
| 1014 | | { |
|---|
| 1015 | | $topic_last_read = 0; |
|---|
| 1016 | | if ( !empty($tracking_topics[$topic_id]) && !empty($tracking_forums[$forum_id]) ) |
|---|
| 1017 | | { |
|---|
| 1018 | | $topic_last_read = ( $tracking_topics[$topic_id] > $tracking_forums[$forum_id] ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id]; |
|---|
| 1019 | | } |
|---|
| 1020 | | else if ( !empty($tracking_topics[$topic_id]) || !empty($tracking_forums[$forum_id]) ) |
|---|
| 1021 | | { |
|---|
| 1022 | | $topic_last_read = ( !empty($tracking_topics[$topic_id]) ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id]; |
|---|
| 1023 | | } |
|---|
| 1024 | | |
|---|
| 1025 | | if ( $searchset[$i]['post_time'] > $topic_last_read ) |
|---|
| 1026 | | { |
|---|
| 1027 | | $mini_post_img = $images['icon_minipost_new']; |
|---|
| 1028 | | $mini_post_alt = $lang['new_post']; |
|---|
| 1029 | | } |
|---|
| 1030 | | else |
|---|
| 1031 | | { |
|---|
| 1032 | | $mini_post_img = $images['icon_minipost']; |
|---|
| 1033 | | $mini_post_alt = $lang['post']; |
|---|
| 1034 | | } |
|---|
| 1035 | | } |
|---|
| 1036 | | else |
|---|
| 1037 | | { |
|---|
| 1038 | | $mini_post_img = $images['icon_minipost']; |
|---|
| 1039 | | $mini_post_alt = $lang['post']; |
|---|
| 1040 | | }*/ |
|---|
| 1041 | | |
|---|
| 1042 | | $unread_topic = (isset($topic_tracking_info[$forum_id][$topic_id]) && $searchset[$i]['post_time'] > $topic_tracking_info[$forum_id][$topic_id]) ? true : false; |
|---|
| 1043 | | |
|---|
| 1044 | | if ( $unread_topic ) |
|---|
| 1045 | | { |
|---|
| 1046 | | $mini_post_img = $images['icon_minipost_new']; |
|---|
| 1047 | | $mini_post_alt = $lang['new_post']; |
|---|
| 1048 | | } |
|---|
| 1049 | | else |
|---|
| 1050 | | { |
|---|
| 1051 | | $mini_post_img = $images['icon_minipost']; |
|---|
| 1052 | | $mini_post_alt = $lang['post']; |
|---|
| 1053 | | } |
|---|
| 1054 | | |
|---|
| 1055 | | $template->assign_block_vars("searchresults", array( |
|---|
| 1056 | | 'TOPIC_TITLE' => $topic_title, |
|---|
| 1057 | | 'FORUM_NAME' => $searchset[$i]['forum_name'], |
|---|
| 1058 | | 'POST_SUBJECT' => $post_subject, |
|---|
| 1059 | | 'POST_DATE' => $post_date, |
|---|
| 1060 | | 'POSTER_NAME' => $poster, |
|---|
| 1061 | | 'TOPIC_REPLIES' => $searchset[$i]['topic_replies'], |
|---|
| 1062 | | 'TOPIC_VIEWS' => $searchset[$i]['topic_views'], |
|---|
| 1063 | | 'MESSAGE' => $message, |
|---|
| 1064 | | 'MINI_POST_IMG' => $mini_post_img, |
|---|
| 1065 | | |
|---|
| 1066 | | 'L_MINI_POST_ALT' => $mini_post_alt, |
|---|
| 1067 | | |
|---|
| 1068 | | 'U_POST' => $post_url, |
|---|
| 1069 | | 'U_TOPIC' => $topic_url, |
|---|
| 1070 | | 'U_FORUM' => $forum_url) |
|---|
| 1071 | | ); |
|---|
| 1072 | | } |
|---|
| 1073 | | else |
|---|
| 1074 | | { |
|---|
| 1075 | | $message = ''; |
|---|
| 1076 | | |
|---|
| 1077 | | if ( count($orig_word) ) |
|---|
| 1078 | | { |
|---|
| 1079 | | $topic_title = preg_replace($orig_word, $replacement_word, $searchset[$i]['topic_title']); |
|---|
| 1080 | | } |
|---|
| 1081 | | |
|---|
| 1082 | | $topic_type = $searchset[$i]['topic_type']; |
|---|
| 1083 | | |
|---|
| 1084 | | if ($topic_type == POST_ANNOUNCE) |
|---|
| 1085 | | { |
|---|
| 1086 | | $topic_type = $lang['topic_announcement'] . ' '; |
|---|
| 1087 | | } |
|---|
| 1088 | | else if ($topic_type == POST_STICKY) |
|---|
| 1089 | | { |
|---|
| 1090 | | $topic_type = $lang['topic_sticky'] . ' '; |
|---|
| 1091 | | } |
|---|
| 1092 | | else |
|---|
| 1093 | | { |
|---|
| 1094 | | $topic_type = ''; |
|---|
| 1095 | | } |
|---|
| 1096 | | |
|---|
| 1097 | | if ( $searchset[$i]['topic_vote'] ) |
|---|
| 1098 | | { |
|---|
| 1099 | | $topic_type .= $lang['topic_poll'] . ' '; |
|---|
| 1100 | | } |
|---|
| 1101 | | |
|---|
| 1102 | | $views = $searchset[$i]['topic_views']; |
|---|
| 1103 | | $replies = $searchset[$i]['topic_replies']; |
|---|
| 1104 | | |
|---|
| 1105 | | if ( ( $replies + 1 ) > $config['posts_per_page'] ) |
|---|
| 1106 | | { |
|---|
| 1107 | | $total_pages = ceil( ( $replies + 1 ) / $config['posts_per_page'] ); |
|---|
| 1108 | | //$goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['goto_page'] . '" title="' . $lang['goto_page'] . '" />' . $lang['goto_page'] . ': '; |
|---|
| 1109 | | $goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['goto_page'] . '" title="' . $lang['goto_page'] . '" />' . $lang['goto_page'] . ': '; |
|---|
| 1110 | | |
|---|
| 1111 | | $times = 1; |
|---|
| 1112 | | for($j = 0; $j < $replies + 1; $j += $config['posts_per_page']) |
|---|
| 1113 | | { |
|---|
| 1114 | | //$goto_page .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_id . "&start=$j") . '">' . $times . '</a>'; |
|---|
| 1115 | | $goto_page .= '<a href="' . append_sid($root_path . "phpbb2.php?page=viewtopic&" . POST_TOPIC_URL . "=" . $topic_id . "&start=$j") . '">' . $times . '</a>'; |
|---|
| 1116 | | if ( $times == 1 && $total_pages > 4 ) |
|---|
| 1117 | | { |
|---|
| 1118 | | $goto_page .= ' ... '; |
|---|
| 1119 | | $times = $total_pages - 3; |
|---|
| 1120 | | $j += ( $total_pages - 4 ) * $config['posts_per_page']; |
|---|
| 1121 | | } |
|---|
| 1122 | | else if ( $times < $total_pages ) |
|---|
| 1123 | | { |
|---|
| 1124 | | $goto_page .= ', '; |
|---|
| 1125 | | } |
|---|
| 1126 | | $times++; |
|---|
| 1127 | | } |
|---|
| 1128 | | $goto_page .= ' ] '; |
|---|
| 1129 | | } |
|---|
| 1130 | | else |
|---|
| 1131 | | { |
|---|
| 1132 | | $goto_page = ''; |
|---|
| 1133 | | } |
|---|
| 1134 | | |
|---|
| 1135 | | if ( $searchset[$i]['topic_status'] == TOPIC_MOVED ) |
|---|
| 1136 | | { |
|---|
| 1137 | | $topic_type = $lang['topic_moved'] . ' '; |
|---|
| 1138 | | $topic_id = $searchset[$i]['topic_moved_id']; |
|---|
| 1139 | | |
|---|
| 1140 | | //$folder_image = '<img src="' . $images['folder'] . '" alt="' . $lang['no_new_posts'] . '" />'; |
|---|
| 1141 | | $folder_image = '<img src="' . $images['folder'] . '" alt="' . $lang['no_new_posts'] . '" />'; |
|---|
| 1142 | | $newest_post_img = ''; |
|---|
| 1143 | | } |
|---|
| 1144 | | else |
|---|
| 1145 | | { |
|---|
| 1146 | | if ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) |
|---|
| 1147 | | { |
|---|
| 1148 | | $folder = $images['folder_locked']; |
|---|
| 1149 | | $folder_new = $images['folder_locked_new']; |
|---|
| 1150 | | } |
|---|
| 1151 | | else if ( $searchset[$i]['topic_type'] == POST_ANNOUNCE ) |
|---|
| 1152 | | { |
|---|
| 1153 | | $folder = $images['folder_announce']; |
|---|
| 1154 | | $folder_new = $images['folder_announce_new']; |
|---|
| 1155 | | } |
|---|
| 1156 | | else if ( $searchset[$i]['topic_type'] == POST_STICKY ) |
|---|
| 1157 | | { |
|---|
| 1158 | | $folder = $images['folder_sticky']; |
|---|
| 1159 | | $folder_new = $images['folder_sticky_new']; |
|---|
| 1160 | | } |
|---|
| 1161 | | else |
|---|
| 1162 | | { |
|---|
| 1163 | | if ( $replies >= $config['hot_threshold'] ) |
|---|
| 1164 | | { |
|---|
| 1165 | | $folder = $images['folder_hot']; |
|---|
| 1166 | | $folder_new = $images['folder_hot_new']; |
|---|
| 1167 | | } |
|---|
| 1168 | | else |
|---|
| 1169 | | { |
|---|
| 1170 | | $folder = $images['folder']; |
|---|
| 1171 | | $folder_new = $images['folder_new']; |
|---|
| 1172 | | } |
|---|
| 1173 | | } |
|---|
| 1174 | | |
|---|
| 1175 | | /*if ( $userdata['session_logged_in'] ) |
|---|
| 1176 | | { |
|---|
| 1177 | | if ( $searchset[$i]['post_time'] > $userdata['user_lastvisit'] ) |
|---|
| 1178 | | { |
|---|
| 1179 | | if ( !empty($tracking_topics) || !empty($tracking_forums) || isset($_COOKIE[$config['cookie_name'] . '_f_all']) ) |
|---|
| 1180 | | { |
|---|
| 1181 | | |
|---|
| 1182 | | $unread_topics = true; |
|---|
| 1183 | | |
|---|
| 1184 | | if ( !empty($tracking_topics[$topic_id]) ) |
|---|
| 1185 | | { |
|---|
| 1186 | | if ( $tracking_topics[$topic_id] > $searchset[$i]['post_time'] ) |
|---|
| 1187 | | { |
|---|
| 1188 | | $unread_topics = false; |
|---|
| 1189 | | } |
|---|
| 1190 | | } |
|---|
| 1191 | | |
|---|
| 1192 | | if ( !empty($tracking_forums[$forum_id]) ) |
|---|
| 1193 | | { |
|---|
| 1194 | | if ( $tracking_forums[$forum_id] > $searchset[$i]['post_time'] ) |
|---|
| 1195 | | { |
|---|
| 1196 | | $unread_topics = false; |
|---|
| 1197 | | } |
|---|
| 1198 | | } |
|---|
| 1199 | | |
|---|
| 1200 | | if ( isset($_COOKIE[$config['cookie_name'] . '_f_all']) ) |
|---|
| 1201 | | { |
|---|
| 1202 | | if ( $_COOKIE[$config['cookie_name'] . '_f_all'] > $searchset[$i]['post_time'] ) |
|---|
| 1203 | | { |
|---|
| 1204 | | $unread_topics = false; |
|---|
| 1205 | | } |
|---|
| 1206 | | }*/ |
|---|
| 1207 | | |
|---|
| 1208 | | $unread_topics = (isset($topic_tracking_info[$forum_id][$topic_id]) && $searchset[$i]['post_time'] > $topic_tracking_info[$forum_id][$topic_id]) ? true : false; |
|---|
| 1209 | | |
|---|
| 1210 | | if ( $unread_topics ) |
|---|
| 1211 | | { |
|---|
| 1212 | | $folder_image = $folder_new; |
|---|
| 1213 | | $folder_alt = $lang['new_posts']; |
|---|
| 1214 | | |
|---|
| 1215 | | //$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> '; |
|---|
| 1216 | | $newest_post_img = '<a href="' . append_sid($root_path . "phpbb2.php?page=viewtopic&" . 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> '; |
|---|
| 1217 | | } |
|---|
| 1218 | | else |
|---|
| 1219 | | { |
|---|
| 1220 | | $folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['topic_locked'] : $lang['no_new_posts']; |
|---|
| 1221 | | |
|---|
| 1222 | | $folder_image = $folder; |
|---|
| 1223 | | $folder_alt = $folder_alt; |
|---|
| 1224 | | $newest_post_img = ''; |
|---|
| 1225 | | } |
|---|
| 1226 | | |
|---|
| 1227 | | /*} |
|---|
| 1228 | | else if ( $searchset[$i]['post_time'] > $userdata['user_lastvisit'] ) |
|---|
| 1229 | | { |
|---|
| 1230 | | $folder_image = $folder_new; |
|---|
| 1231 | | $folder_alt = $lang['new_posts']; |
|---|
| 1232 | | |
|---|
| 1233 | | //$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> '; |
|---|
| 1234 | | $newest_post_img = '<a href="' . append_sid($root_path . "phpbb2.php?page=viewtopic&" . 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> '; |
|---|
| 1235 | | } |
|---|
| 1236 | | else |
|---|
| 1237 | | { |
|---|
| 1238 | | $folder_image = $folder; |
|---|
| 1239 | | $folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['topic_locked'] : $lang['no_new_posts']; |
|---|
| 1240 | | $newest_post_img = ''; |
|---|
| 1241 | | } |
|---|
| 1242 | | } |
|---|
| 1243 | | else |
|---|
| 1244 | | { |
|---|
| 1245 | | $folder_image = $folder; |
|---|
| 1246 | | $folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['topic_locked'] : $lang['no_new_posts']; |
|---|
| 1247 | | $newest_post_img = ''; |
|---|
| 1248 | | } |
|---|
| 1249 | | } |
|---|
| 1250 | | else |
|---|
| 1251 | | { |
|---|
| 1252 | | $folder_image = $folder; |
|---|
| 1253 | | $folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['topic_locked'] : $lang['no_new_posts']; |
|---|
| 1254 | | $newest_post_img = ''; |
|---|
| 1255 | | }*/ |
|---|
| 1256 | | } |
|---|
| 1257 | | |
|---|
| 1258 | | |
|---|
| 1259 | | $topic_author = ( $searchset[$i]['uid'] != ANONYMOUS ) ? '<a href="' . append_sid($root_path . "userdetails.php?id=" . $searchset[$i]['uid']) . '">' : ''; |
|---|
| 1260 | | $topic_author .= ( $searchset[$i]['uid'] != ANONYMOUS ) ? $searchset[$i]['username'] : ( ( $searchset[$i]['post_username'] != '' ) ? $searchset[$i]['post_username'] : $lang['guest'] ); |
|---|
| 1261 | | |
|---|
| 1262 | | $topic_author .= ( $searchset[$i]['uid'] != ANONYMOUS ) ? '</a>' : ''; |
|---|
| 1263 | | |
|---|
| 1264 | | $first_post_time = create_date($searchset[$i]['topic_time']); |
|---|
| 1265 | | |
|---|
| 1266 | | $last_post_time = create_date($searchset[$i]['post_time']); |
|---|
| 1267 | | |
|---|
| 1268 | | $last_post_author = ( $searchset[$i]['id2'] == ANONYMOUS ) ? ( ($searchset[$i]['post_username2'] != '' ) ? $searchset[$i]['post_username2'] . ' ' : $lang['guest'] . ' ' ) : '<a href="' . append_sid($root_path . "userdetails.php?id=" . $searchset[$i]['id2']) . '">' . $searchset[$i]['user2'] . '</a>'; |
|---|
| 1269 | | |
|---|
| 1270 | | $last_post_url = '<a href="' . append_sid($root_path . "phpbb2.php?page=viewtopic&" . 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>'; |
|---|
| 1271 | | |
|---|
| 1272 | | $template->assign_block_vars('searchresults', array( |
|---|
| 1273 | | 'FORUM_NAME' => $searchset[$i]['forum_name'], |
|---|
| 1274 | | 'FORUM_ID' => $forum_id, |
|---|
| 1275 | | 'TOPIC_ID' => $topic_id, |
|---|
| 1276 | | 'FOLDER' => $folder_image, |
|---|
| 1277 | | 'NEWEST_POST_IMG' => $newest_post_img, |
|---|
| 1278 | | 'TOPIC_FOLDER_IMG' => $folder_image, |
|---|
| 1279 | | 'GOTO_PAGE' => $goto_page, |
|---|
| 1280 | | 'REPLIES' => $replies, |
|---|
| 1281 | | 'TOPIC_TITLE' => $topic_title, |
|---|
| 1282 | | 'TOPIC_TYPE' => $topic_type, |
|---|
| 1283 | | 'VIEWS' => $views, |
|---|
| 1284 | | 'TOPIC_AUTHOR' => $topic_author, |
|---|
| 1285 | | 'FIRST_POST_TIME' => $first_post_time, |
|---|
| 1286 | | 'LAST_POST_TIME' => $last_post_time, |
|---|
| 1287 | | 'LAST_POST_AUTHOR' => $last_post_author, |
|---|
| 1288 | | 'LAST_POST_IMG' => $last_post_url, |
|---|
| 1289 | | |
|---|
| 1290 | | 'L_TOPIC_FOLDER_ALT' => $folder_alt, |
|---|
| 1291 | | |
|---|
| 1292 | | 'U_VIEW_FORUM' => $forum_url, |
|---|
| 1293 | | 'U_VIEW_TOPIC' => $topic_url) |
|---|
| 1294 | | ); |
|---|
| 1295 | | } |
|---|
| 1296 | | } |
|---|
| 1297 | | // Topic search MOD |
|---|
| 1298 | | if( !$tid ) |
|---|
| 1299 | | { |
|---|
| 1300 | | // End Topic search MOD |
|---|
| 1301 | | $base_url = "phpbb2.php?page=search&search_id=$search_id&search_author=$search_author"; |
|---|
| 1302 | | // Topic search MOD |
|---|
| 1303 | | } |
|---|
| 1304 | | else |
|---|
| 1305 | | { |
|---|
| 1306 | | $base_url = "phpbb2.php?page=search&search_id=$search_id&topic_id=$tid"; |
|---|
| 1307 | | } |
|---|
| 1308 | | // End Topic search MOD |
|---|
| 1309 | | |
|---|
| 1310 | | $template->assign_vars(array( |
|---|
| 1311 | | 'PAGINATION' => generate_pagination($root_path . $base_url, $total_match_count, $per_page, $start), |
|---|
| 1312 | | 'PAGE_NUMBER' => sprintf($lang['page_of'], ( floor( $start / $per_page ) + 1 ), ceil( $total_match_count / $per_page )), |
|---|
| 1313 | | )); |
|---|
| 1314 | | return; |
|---|
| 1315 | | } |
|---|
| 1316 | | else |
|---|
| 1317 | | { |
|---|
| 1318 | | trigger_error($lang['no_search_match']); |
|---|
| 1319 | | return; |
|---|
| 1320 | | } |
|---|
| | 92 | $store_vars = array('search_results', 'total_match_count', 'split_search', 'sort_by', 'sort_dir', 'show_results', 'return_chars'); |
|---|
| | 93 | $search_results = ''; |
|---|
| | 94 | // Topic search MOD |
|---|
| | 95 | $tid = request_var('topic_id', 0); |
|---|
| | 96 | // Topic search MOD |
|---|
| | 97 | |
|---|
| | 98 | // |
|---|
| | 99 | // Search ID Limiter, decrease this value if you experience further timeout problems with searching forums |
|---|
| | 100 | $limiter = 5000; |
|---|
| | 101 | $current_time = time(); |
|---|
| | 102 | $total_match_count = 0; |
|---|
| | 103 | |
|---|
| | 104 | // |
|---|
| | 105 | // Cycle through options ... |
|---|
| | 106 | // |
|---|
| | 107 | if ( $search_id == 'newposts' || $search_id == 'egosearch' || $search_id == 'unanswered' || $search_keywords != '' || $search_author != '' ) |
|---|
| | 108 | { |
|---|
| | 109 | // |
|---|
| | 110 | // Flood control |
|---|
| | 111 | // |
|---|
| | 112 | $where_sql = ($userdata['uid'] == ANONYMOUS) ? "se.session_ip = '$user_ip'" : 'se.session_user_id = ' . $userdata['uid']; |
|---|
| | 113 | $sql = 'SELECT MAX(sr.search_time) AS last_search_time |
|---|
| | 114 | FROM ' . SEARCH_TABLE . ' sr, ' . SESSIONS_TABLE . " se |
|---|
| | 115 | WHERE sr.session_id = se.session_id |
|---|
| | 116 | AND $where_sql"; |
|---|
| | 117 | $result = $db->sql_query($sql); |
|---|
| | 118 | if ( $row = $db->sql_fetchrow($result) ) { |
|---|
| | 119 | if ( $row['last_search_time'] > 0 && ($current_time - $row['last_search_time']) < $config['search_flood_interval'] ) { |
|---|
| | 120 | $wait_time = intval($config['search_flood_interval']) - ($current_time - intval($row['last_search_time'])); |
|---|
| | 121 | trigger_error(sprintf($lang['search_flood_error'], $wait_time)); |
|---|
| | 122 | } |
|---|
| | 123 | } |
|---|
| | 124 | |
|---|
| | 125 | if ( $search_id == 'newposts' || $search_id == 'egosearch' || ( $search_author != '' && $search_keywords == '' ) ) |
|---|
| | 126 | { |
|---|
| | 127 | if ( $search_id == 'newposts' ) |
|---|
| | 128 | { |
|---|
| | 129 | |
|---|
| | 130 | loggedinorreturn(); |
|---|
| | 131 | |
|---|
| | 132 | $topic_ids = get_unread_topics(); |
|---|
| | 133 | |
|---|
| | 134 | if ( sizeof($topic_ids) ) { |
|---|
| | 135 | $topic_ids = array_keys($topic_ids); |
|---|
| | 136 | $sql = 'SELECT post_id FROM ' . POSTS_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids); |
|---|
| | 137 | } |
|---|
| | 138 | else { |
|---|
| | 139 | $sql = false; |
|---|
| | 140 | } |
|---|
| | 141 | |
|---|
| | 142 | $show_results = 'topics'; |
|---|
| | 143 | $sort_by = 0; |
|---|
| | 144 | $sort_dir = 'DESC'; |
|---|
| | 145 | } |
|---|
| | 146 | else if ( $search_id == 'egosearch' ) |
|---|
| | 147 | { |
|---|
| | 148 | loggedinorreturn(); |
|---|
| | 149 | |
|---|
| | 150 | $sql = "SELECT post_id FROM " . POSTS_TABLE . " WHERE poster_id = " . $userdata['uid']; |
|---|
| | 151 | |
|---|
| | 152 | $show_results = 'topics'; |
|---|
| | 153 | $sort_by = 0; |
|---|
| | 154 | $sort_dir = 'DESC'; |
|---|
| | 155 | } |
|---|
| | 156 | else |
|---|
| | 157 | { |
|---|
| | 158 | $search_author = str_replace('*', '%', trim($search_author)); |
|---|
| | 159 | |
|---|
| | 160 | if( ( strpos($search_author, '%') !== false ) && ( utf_strlen(str_replace('%', '', $search_author)) < $config['search_min_chars'] ) ) |
|---|
| | 161 | { |
|---|
| | 162 | $search_author = ''; |
|---|
| | 163 | } |
|---|
| | 164 | |
|---|
| | 165 | $sql = "SELECT uid FROM " . USERS_TABLE . " WHERE name LIKE '" . $db->sql_escape($search_author) . "'"; |
|---|
| | 166 | $result = $db->sql_query($sql); |
|---|
| | 167 | |
|---|
| | 168 | $matching_userids = ''; |
|---|
| | 169 | if ( $row = $db->sql_fetchrow($result) ) |
|---|
| | 170 | { |
|---|
| | 171 | do |
|---|
| | 172 | { |
|---|
| | 173 | $matching_userids .= ( ( $matching_userids != '' ) ? ', ' : '' ) . $row['uid']; |
|---|
| | 174 | } |
|---|
| | 175 | while( $row = $db->sql_fetchrow($result) ); |
|---|
| | 176 | } |
|---|
| | 177 | else |
|---|
| | 178 | { |
|---|
| | 179 | trigger_error($lang['no_search_match']); |
|---|
| | 180 | } |
|---|
| | 181 | |
|---|
| | 182 | $sql = "SELECT post_id FROM " . POSTS_TABLE . " WHERE poster_id IN ($matching_userids)"; |
|---|
| | 183 | |
|---|
| | 184 | if ($search_time) |
|---|
| | 185 | { |
|---|
| | 186 | $sql .= " AND post_time >= " . $search_time; |
|---|
| | 187 | } |
|---|
| | 188 | } |
|---|
| | 189 | |
|---|
| | 190 | $result = $db->sql_query($sql); |
|---|
| | 191 | |
|---|
| | 192 | $search_ids = array(); |
|---|
| | 193 | while( $row = $db->sql_fetchrow($result) ) |
|---|
| | 194 | { |
|---|
| | 195 | $search_ids[] = $row['post_id']; |
|---|
| | 196 | } |
|---|
| | 197 | |
|---|
| | 198 | $db->sql_freeresult($result); |
|---|
| | 199 | |
|---|
| | 200 | $total_match_count = sizeof($search_ids); |
|---|
| | 201 | |
|---|
| | 202 | } |
|---|
| | 203 | else if ( $search_keywords != '' ) |
|---|
| | 204 | { |
|---|
| | 205 | $stopword_array = @file($root_path . 'languages/lang_' . $config['default_lang'] . '/search_stopwords.txt'); |
|---|
| | 206 | $synonym_array = @file($root_path . 'languages/lang_' . $config['default_lang'] . '/search_synonyms.txt'); |
|---|
| | 207 | |
|---|
| | 208 | $stripped_keywords = ( STRIP ? stripslashes($search_keywords) : $search_keywords ); |
|---|
| | 209 | $split_search = split_words(clean_words('search', $stripped_keywords, $stopword_array, $synonym_array), 'search'); |
|---|
| | 210 | unset($stripped_keywords); |
|---|
| | 211 | |
|---|
| | 212 | $search_msg_only = ( !$search_fields ) ? "AND m.title_match = 0" : ''; |
|---|
| | 213 | |
|---|
| | 214 | $word_count = 0; |
|---|
| | 215 | $current_match_type = 'or'; |
|---|
| | 216 | |
|---|
| | 217 | $word_match = array(); |
|---|
| | 218 | $result_list = array(); |
|---|
| | 219 | |
|---|
| | 220 | for($i = 0; $i < sizeof($split_search); $i++) |
|---|
| | 221 | { |
|---|
| | 222 | if ( utf_strlen(str_replace(array('*', '%'), '', trim($split_search[$i]))) < $config['search_min_chars'] ) |
|---|
| | 223 | { |
|---|
| | 224 | $split_search[$i] = ''; |
|---|
| | 225 | continue; |
|---|
| | 226 | } |
|---|
| | 227 | |
|---|
| | 228 | switch ( $split_search[$i] ) |
|---|
| | 229 | { |
|---|
| | 230 | case 'and': |
|---|
| | 231 | $current_match_type = 'and'; |
|---|
| | 232 | break; |
|---|
| | 233 | |
|---|
| | 234 | case 'or': |
|---|
| | 235 | $current_match_type = 'or'; |
|---|
| | 236 | break; |
|---|
| | 237 | |
|---|
| | 238 | case 'not': |
|---|
| | 239 | $current_match_type = 'not'; |
|---|
| | 240 | break; |
|---|
| | 241 | |
|---|
| | 242 | default: |
|---|
| | 243 | if ( !empty($search_terms) ) |
|---|
| | 244 | { |
|---|
| | 245 | $current_match_type = 'and'; |
|---|
| | 246 | } |
|---|
| | 247 | |
|---|
| | 248 | $match_word = str_replace('*', '%', $split_search[$i]); |
|---|
| | 249 | $sql = "SELECT m.post_id |
|---|
| | 250 | FROM " . SEARCH_WORD_TABLE . " w, " . SEARCH_MATCH_TABLE . " m |
|---|
| | 251 | WHERE w.word_text LIKE '$match_word' |
|---|
| | 252 | AND m.word_id = w.word_id |
|---|
| | 253 | AND w.word_common <> 1 |
|---|
| | 254 | $search_msg_only"; |
|---|
| | 255 | $result = $db->sql_query($sql); |
|---|
| | 256 | |
|---|
| | 257 | $row = array(); |
|---|
| | 258 | while( $temp_row = $db->sql_fetchrow($result) ) |
|---|
| | 259 | { |
|---|
| | 260 | $row[$temp_row['post_id']] = 1; |
|---|
| | 261 | |
|---|
| | 262 | if ( !$word_count ) |
|---|
| | 263 | { |
|---|
| | 264 | $result_list[$temp_row['post_id']] = 1; |
|---|
| | 265 | } |
|---|
| | 266 | else if ( $current_match_type == 'or' ) |
|---|
| | 267 | { |
|---|
| | 268 | $result_list[$temp_row['post_id']] = 1; |
|---|
| | 269 | } |
|---|
| | 270 | else if ( $current_match_type == 'not' ) |
|---|
| | 271 | { |
|---|
| | 272 | $result_list[$temp_row['post_id']] = 0; |
|---|
| | 273 | } |
|---|
| | 274 | } |
|---|
| | 275 | |
|---|
| | 276 | if ( $current_match_type == 'and' && $word_count ) |
|---|
| | 277 | { |
|---|
| | 278 | @reset($result_list); |
|---|
| | 279 | while( list($post_id, $match_count) = @each($result_list) ) |
|---|
| | 280 | { |
|---|
| | 281 | if ( !$row[$post_id] ) |
|---|
| | 282 | { |
|---|
| | 283 | $result_list[$post_id] = 0; |
|---|
| | 284 | } |
|---|
| | 285 | } |
|---|
| | 286 | } |
|---|
| | 287 | |
|---|
| | 288 | $word_count++; |
|---|
| | 289 | |
|---|
| | 290 | $db->sql_freeresult($result); |
|---|
| | 291 | } |
|---|
| | 292 | } |
|---|
| | 293 | |
|---|
| | 294 | @reset($result_list); |
|---|
| | 295 | |
|---|
| | 296 | $search_ids = array(); |
|---|
| | 297 | while( list($post_id, $matches) = each($result_list) ) |
|---|
| | 298 | { |
|---|
| | 299 | if ( $matches ) |
|---|
| | 300 | { |
|---|
| | 301 | |
|---|
| | 302 | // Topic Search MOD |
|---|
| | 303 | if($tid) |
|---|
| | 304 | { |
|---|
| | 305 | $sql = "SELECT post_id |
|---|
| | 306 | FROM " . POSTS_TABLE . " |
|---|
| | 307 | WHERE topic_id = '$tid'"; |
|---|
| | 308 | $result = $db->sql_query($sql); |
|---|
| | 309 | while( $test = $db->sql_fetchrow($result) ) |
|---|
| | 310 | { |
|---|
| | 311 | if($test['post_id'] == $post_id) |
|---|
| | 312 | { |
|---|
| | 313 | $search_ids[] = $post_id; |
|---|
| | 314 | } |
|---|
| | 315 | } |
|---|
| | 316 | $show_results = 'posts'; |
|---|
| | 317 | } |
|---|
| | 318 | else |
|---|
| | 319 | { // End Topic Search MOD |
|---|
| | 320 | |
|---|
| | 321 | $search_ids[] = $post_id; |
|---|
| | 322 | // Topic Search MOD |
|---|
| | 323 | } |
|---|
| | 324 | // End Topic search MOD |
|---|
| | 325 | } |
|---|
| | 326 | } |
|---|
| | 327 | |
|---|
| | 328 | unset($result_list); |
|---|
| | 329 | $total_match_count = sizeof($search_ids); |
|---|
| | 330 | } |
|---|
| | 331 | |
|---|
| | 332 | // |
|---|
| | 333 | // If user is logged in then we'll check to see which (if any) private |
|---|
| | 334 | // forums they are allowed to view and include them in the search. |
|---|
| | 335 | // |
|---|
| | 336 | // If not logged in we explicitly prevent searching of private forums |
|---|
| | 337 | // |
|---|
| | 338 | $auth_sql = ''; |
|---|
| | 339 | if ( $search_forum != -1 ) |
|---|
| | 340 | { |
|---|
| | 341 | $is_auth = auth(AUTH_READ, $search_forum, $userdata); |
|---|
| | 342 | |
|---|
| | 343 | if ( !$is_auth['auth_read'] ) |
|---|
| | 344 | { |
|---|
| | 345 | trigger_error($lang['no_searchable_forums']); |
|---|
| | 346 | return; |
|---|
| | 347 | } |
|---|
| | 348 | |
|---|
| | 349 | $auth_sql = "f.forum_id = $search_forum"; |
|---|
| | 350 | } |
|---|
| | 351 | else |
|---|
| | 352 | { |
|---|
| | 353 | $is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata); |
|---|
| | 354 | |
|---|
| | 355 | if ( $search_cat != -1 ) |
|---|
| | 356 | { |
|---|
| | 357 | $auth_sql = "f.cat_id = $search_cat"; |
|---|
| | 358 | } |
|---|
| | 359 | |
|---|
| | 360 | $ignore_forum_sql = ''; |
|---|
| | 361 | while( list($key, $value) = each($is_auth_ary) ) |
|---|
| | 362 | { |
|---|
| | 363 | if ( !$value['auth_read'] ) |
|---|
| | 364 | { |
|---|
| | 365 | $ignore_forum_sql .= ( ( $ignore_forum_sql != '' ) ? ', ' : '' ) . $key; |
|---|
| | 366 | } |
|---|
| | 367 | } |
|---|
| | 368 | |
|---|
| | 369 | if ( $ignore_forum_sql != '' ) |
|---|
| | 370 | { |
|---|
| | 371 | $auth_sql .= ( $auth_sql != '' ) ? " AND f.forum_id NOT IN ($ignore_forum_sql) " : "f.forum_id NOT IN ($ignore_forum_sql) "; |
|---|
| | 372 | } |
|---|
| | 373 | } |
|---|
| | 374 | |
|---|
| | 375 | // |
|---|
| | 376 | // Author name search |
|---|
| | 377 | // |
|---|
| | 378 | if ( $search_author != '' ) |
|---|
| | 379 | { |
|---|
| | 380 | $search_author = str_replace('*', '%', trim($search_author)); |
|---|
| | 381 | |
|---|
| | 382 | if( ( strpos($search_author, '%') !== false ) && ( utf_strlen(str_replace('%', '', $search_author)) < $config['search_min_chars'] ) ) |
|---|
| | 383 | { |
|---|
| | 384 | $search_author = ''; |
|---|
| | 385 | } |
|---|
| | 386 | } |
|---|
| | 387 | |
|---|
| | 388 | if ( $total_match_count ) |
|---|
| | 389 | { |
|---|
| | 390 | if ( $show_results == 'topics' ) |
|---|
| | 391 | { |
|---|
| | 392 | // |
|---|
| | 393 | // This one is a beast, try to seperate it a bit (workaround for connection timeouts) |
|---|
| | 394 | // |
|---|
| | 395 | $search_id_chunks = array(); |
|---|
| | 396 | $count = 0; |
|---|
| | 397 | $chunk = 0; |
|---|
| | 398 | |
|---|
| | 399 | if (sizeof($search_ids) > $limiter) |
|---|
| | 400 | { |
|---|
| | 401 | for ($i = 0; $i < sizeof($search_ids); $i++) |
|---|
| | 402 | { |
|---|
| | 403 | if ($count == $limiter) |
|---|
| | 404 | { |
|---|
| | 405 | $chunk++; |
|---|
| | 406 | $count = 0; |
|---|
| | 407 | } |
|---|
| | 408 | |
|---|
| | 409 | $search_id_chunks[$chunk][$count] = $search_ids[$i]; |
|---|
| | 410 | $count++; |
|---|
| | 411 | } |
|---|
| | 412 | } |
|---|
| | 413 | else |
|---|
| | 414 | { |
|---|
| | 415 | $search_id_chunks[0] = $search_ids; |
|---|
| | 416 | } |
|---|
| | 417 | |
|---|
| | 418 | $search_ids = array(); |
|---|
| | 419 | |
|---|
| | 420 | for ($i = 0; $i < sizeof($search_id_chunks); $i++) |
|---|
| | 421 | { |
|---|
| | 422 | $where_sql = ''; |
|---|
| | 423 | |
|---|
| | 424 | if ( $search_time ) |
|---|
| | 425 | { |
|---|
| | 426 | $where_sql .= ( $search_author == '' && $auth_sql == '' ) ? " AND post_time >= $search_time " : " AND p.post_time >= $search_time "; |
|---|
| | 427 | } |
|---|
| | 428 | |
|---|
| | 429 | if ( $search_author == '' && $auth_sql == '' ) |
|---|
| | 430 | { |
|---|
| | 431 | $sql = "SELECT topic_id |
|---|
| | 432 | FROM " . POSTS_TABLE . " |
|---|
| | 433 | WHERE post_id IN (" . implode(", ", $search_id_chunks[$i]) . ") |
|---|
| | 434 | $where_sql |
|---|
| | 435 | GROUP BY topic_id"; |
|---|
| | 436 | } |
|---|
| | 437 | else |
|---|
| | 438 | { |
|---|
| | 439 | $from_sql = POSTS_TABLE . " p"; |
|---|
| | 440 | |
|---|
| | 441 | if ( $search_author != '' ) |
|---|
| | 442 | { |
|---|
| | 443 | $from_sql .= ", " . USERS_TABLE . " u"; |
|---|
| | 444 | $where_sql .= " AND u.uid = p.poster_id AND u.name LIKE '$search_author' "; |
|---|
| | 445 | } |
|---|
| | 446 | |
|---|
| | 447 | if ( $auth_sql != '' ) |
|---|
| | 448 | { |
|---|
| | 449 | $from_sql .= ", " . FORUMS_TABLE . " f"; |
|---|
| | 450 | $where_sql .= " AND f.forum_id = p.forum_id AND $auth_sql"; |
|---|
| | 451 | } |
|---|
| | 452 | |
|---|
| | 453 | $sql = "SELECT p.topic_id |
|---|
| | 454 | FROM $from_sql |
|---|
| | 455 | WHERE p.post_id IN (" . implode(", ", $search_id_chunks[$i]) . ") |
|---|
| | 456 | $where_sql |
|---|
| | 457 | GROUP BY p.topic_id"; |
|---|
| | 458 | } |
|---|
| | 459 | |
|---|
| | 460 | $result = $db->sql_query($sql); |
|---|
| | 461 | |
|---|
| | 462 | while ($row = $db->sql_fetchrow($result)) |
|---|
| | 463 | { |
|---|
| | 464 | $search_ids[] = $row['topic_id']; |
|---|
| | 465 | } |
|---|
| | 466 | $db->sql_freeresult($result); |
|---|
| | 467 | } |
|---|
| | 468 | |
|---|
| | 469 | $total_match_count = sizeof($search_ids); |
|---|
| | 470 | |
|---|
| | 471 | } |
|---|
| | 472 | else if ( $search_author != '' || $search_time || $auth_sql != '' ) |
|---|
| | 473 | { |
|---|
| | 474 | $search_id_chunks = array(); |
|---|
| | 475 | $count = 0; |
|---|
| | 476 | $chunk = 0; |
|---|
| | 477 | |
|---|
| | 478 | if (count($search_ids) > $limiter) |
|---|
| | 479 | { |
|---|
| | 480 | for ($i = 0; $i < count($search_ids); $i++) |
|---|
| | 481 | { |
|---|
| | 482 | if ($count == $limiter) |
|---|
| | 483 | { |
|---|
| | 484 | $chunk++; |
|---|
| | 485 | $count = 0; |
|---|
| | 486 | } |
|---|
| | 487 | |
|---|
| | 488 | $search_id_chunks[$chunk][$count] = $search_ids[$i]; |
|---|
| | 489 | $count++; |
|---|
| | 490 | } |
|---|
| | 491 | } |
|---|
| | 492 | else |
|---|
| | 493 | { |
|---|
| | 494 | $search_id_chunks[0] = $search_ids; |
|---|
| | 495 | } |
|---|
| | 496 | |
|---|
| | 497 | $search_ids = array(); |
|---|
| | 498 | |
|---|
| | 499 | for ($i = 0; $i < count($search_id_chunks); $i++) |
|---|
| | 500 | { |
|---|
| | 501 | $where_sql = ( $search_author == '' && $auth_sql == '' ) ? 'post_id IN (' . implode(', ', $search_id_chunks[$i]) . ')' : 'p.post_id IN (' . implode(', ', $search_id_chunks[$i]) . ')'; |
|---|
| | 502 | $select_sql = ( $search_author == '' && $auth_sql == '' ) ? 'post_id' : 'p.post_id'; |
|---|
| | 503 | $from_sql = ( $search_author == '' && $auth_sql == '' ) ? POSTS_TABLE : POSTS_TABLE . ' p'; |
|---|
| | 504 | |
|---|
| | 505 | if ( $search_time ) |
|---|
| | 506 | { |
|---|
| | 507 | $where_sql .= ( $search_author == '' && $auth_sql == '' ) ? " AND post_time >= $search_time " : " AND p.post_time >= $search_time"; |
|---|
| | 508 | } |
|---|
| | 509 | |
|---|
| | 510 | if ( $auth_sql != '' ) |
|---|
| | 511 | { |
|---|
| | 512 | $from_sql .= ", " . FORUMS_TABLE . " f"; |
|---|
| | 513 | $where_sql .= " AND f.forum_id = p.forum_id AND $auth_sql"; |
|---|
| | 514 | } |
|---|
| | 515 | |
|---|
| | 516 | if ( $search_author != '' ) |
|---|
| | 517 | { |
|---|
| | 518 | $from_sql .= ", " . USERS_TABLE . " u"; |
|---|
| | 519 | $where_sql .= " AND u.uid = p.poster_id AND u.name LIKE '$search_author'"; |
|---|
| | 520 | } |
|---|
| | 521 | |
|---|
| | 522 | $sql = "SELECT " . $select_sql . " |
|---|
| | 523 | FROM $from_sql |
|---|
| | 524 | WHERE $where_sql"; |
|---|
| | 525 | $result = $db->sql_query($sql); |
|---|
| | 526 | |
|---|
| | 527 | while( $row = $db->sql_fetchrow($result) ) |
|---|
| | 528 | { |
|---|
| | 529 | $search_ids[] = $row['post_id']; |
|---|
| | 530 | } |
|---|
| | 531 | $db->sql_freeresult($result); |
|---|
| | 532 | } |
|---|
| | 533 | |
|---|
| | 534 | $total_match_count = count($search_ids); |
|---|
| | 535 | } |
|---|
| | 536 | } |
|---|
| | 537 | else if ( $search_id == 'unanswered' ) |
|---|
| | 538 | { |
|---|
| | 539 | if ( $auth_sql != '' ) |
|---|
| | 540 | { |
|---|
| | 541 | $sql = "SELECT t.topic_id, f.forum_id |
|---|
| | 542 | FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f |
|---|
| | 543 | WHERE t.topic_replies = 0 |
|---|
| | 544 | AND t.forum_id = f.forum_id |
|---|
| | 545 | AND t.topic_moved_id = 0 |
|---|
| | 546 | AND $auth_sql"; |
|---|
| | 547 | } |
|---|
| | 548 | else |
|---|
| | 549 | { |
|---|
| | 550 | $sql = "SELECT topic_id |
|---|
| | 551 | FROM " . TOPICS_TABLE . " |
|---|
| | 552 | WHERE topic_replies = 0 |
|---|
| | 553 | AND topic_moved_id = 0"; |
|---|
| | 554 | } |
|---|
| | 555 | |
|---|
| | 556 | $result = $db->sql_query($sql); |
|---|
| | 557 | |
|---|
| | 558 | $search_ids = array(); |
|---|
| | 559 | while( $row = $db->sql_fetchrow($result) ) |
|---|
| | 560 | { |
|---|
| | 561 | $search_ids[] = $row['topic_id']; |
|---|
| | 562 | } |
|---|
| | 563 | $db->sql_freeresult($result); |
|---|
| | 564 | |
|---|
| | 565 | $total_match_count = count($search_ids); |
|---|
| | 566 | |
|---|
| | 567 | // |
|---|
| | 568 | // Basic requirements |
|---|
| | 569 | // |
|---|
| | 570 | $show_results = 'topics'; |
|---|
| | 571 | $sort_by = 0; |
|---|
| | 572 | $sort_dir = 'DESC'; |
|---|
| | 573 | } |
|---|
| | 574 | else |
|---|
| | 575 | { |
|---|
| | 576 | trigger_error($lang['no_search_match']); |
|---|
| | 577 | return; |
|---|
| | 578 | } |
|---|
| | 579 | |
|---|
| | 580 | // |
|---|
| | 581 | // Store new result data |
|---|
| | 582 | // |
|---|
| | 583 | $search_results = implode(', ', $search_ids); |
|---|
| | 584 | $per_page = ( $show_results == 'posts' ) ? $config['posts_per_page'] : $config['topics_per_page']; |
|---|
| | 585 | |
|---|
| | 586 | // |
|---|
| | 587 | // Combine both results and search data (apart from original query) |
|---|
| | 588 | // so we can serialize it and place it in the DB |
|---|
| | 589 | // |
|---|
| | 590 | $store_search_data = array(); |
|---|
| | 591 | |
|---|
| | 592 | // |
|---|
| | 593 | // Limit the character length (and with this the results displayed at all following pages) to prevent |
|---|
| | 594 | // truncated result arrays. Normally, search results above 12000 are affected. |
|---|
| | 595 | // - to include or not to include |
|---|
| | 596 | /* |
|---|
| | 597 | $max_result_length = 60000; |
|---|
| | 598 | if (utf_strlen($search_results) > $max_result_length) |
|---|
| | 599 | { |
|---|
| | 600 | $search_results = substr($search_results, 0, $max_result_length); |
|---|
| | 601 | $search_results = substr($search_results, 0, strrpos($search_results, ',')); |
|---|
| | 602 | $total_match_count = count(explode(', ', $search_results)); |
|---|
| | 603 | } |
|---|
| | 604 | */ |
|---|
| | 605 | |
|---|
| | 606 | for($i = 0; $i < sizeof($store_vars); $i++) |
|---|
| | 607 | { |
|---|
| | 608 | $store_search_data[$store_vars[$i]] = $$store_vars[$i]; |
|---|
| | 609 | } |
|---|
| | 610 | |
|---|
| | 611 | $result_array = serialize($store_search_data); |
|---|
| | 612 | unset($store_search_data); |
|---|
| | 613 | |
|---|
| | 614 | $search_id = md5(dss_rand()); |
|---|
| | 615 | |
|---|
| | 616 | $sql = "UPDATE " . SEARCH_TABLE . " |
|---|
| | 617 | SET search_id = '" . $db->sql_escape($search_id) . "', search_time = $current_time, search_array = '" . $db->sql_escape($result_array) . "' |
|---|
| | 618 | WHERE session_id = '" . $userdata['session_id'] . "'"; |
|---|
| | 619 | if ( !($result = $db->sql_query($sql)) || !$db->sql_affectedrows() ) |
|---|
| | 620 | { |
|---|
| | 621 | $sql = "INSERT INTO " . SEARCH_TABLE . " (search_id, session_id, search_time, search_array) |
|---|
| | 622 | VALUES('" . $db->sql_escape($search_id) . "', '" . $userdata['session_id'] . "', $current_time, '" . $db->sql_escape($result_array) . "')"; |
|---|
| | 623 | $result = $db->sql_query($sql); |
|---|
| | 624 | } |
|---|
| | 625 | } |
|---|
| | 626 | else |
|---|
| | 627 | { |
|---|
| | 628 | $search_id = intval($search_id); |
|---|
| | 629 | if ( $search_id ) |
|---|
| | 630 | { |
|---|
| | 631 | $sql = "SELECT search_array |
|---|
| | 632 | FROM " . SEARCH_TABLE . " |
|---|
| | 633 | WHERE search_id = '" . $db->sql_escape($search_id) . "' |
|---|
| | 634 | AND session_id = '". $userdata['session_id'] . "'"; |
|---|
| | 635 | $result = $db->sql_query($sql); |
|---|
| | 636 | |
|---|
| | 637 | if ( $row = $db->sql_fetchrow($result) ) |
|---|
| | 638 | { |
|---|
| | 639 | $search_data = unserialize($row['search_array']); |
|---|
| | 640 | for($i = 0; $i < sizeof($store_vars); $i++) |
|---|
| | 641 | { |
|---|
| | 642 | $$store_vars[$i] = $search_data[$store_vars[$i]]; |
|---|
| | 643 | } |
|---|
| | 644 | } |
|---|
| | 645 | } |
|---|
| | 646 | } |
|---|
| | 647 | // |
|---|
| | 648 | // Look up data ... |
|---|
| | 649 | // |
|---|
| | 650 | if ( $search_results != '' ) |
|---|
| | 651 | { |
|---|
| | 652 | if ( $show_results == 'posts' ) |
|---|
| | 653 | { |
|---|
| | 654 | $sql = "SELECT pt.post_text, pt.post_subject, p.*, f.forum_id, f.forum_name, t.*, u.name AS username, u.uid, c.cat_id, c.cat_title, f2.forum_id AS p_forum_id, f2.forum_name AS p_forum_name |
|---|
| | 655 | FROM " . FORUMS_TABLE . " f LEFT JOIN " . FORUMS_TABLE . " f2 ON ( f.forum_parent = f2.forum_id ), |
|---|
| | 656 | " . FORUM_CATEGORIES_TABLE . " c, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TEXT_TABLE . " pt |
|---|
| | 657 | WHERE p.post_id IN ($search_results) |
|---|
| | 658 | AND pt.post_id = p.post_id |
|---|
| | 659 | AND f.forum_id = p.forum_id |
|---|
| | 660 | AND p.topic_id = t.topic_id |
|---|
| | 661 | AND p.poster_id = u.uid |
|---|
| | 662 | AND f.cat_id = c.cat_id"; |
|---|
| | 663 | } |
|---|
| | 664 | else |
|---|
| | 665 | { |
|---|
| | 666 | $sql = "SELECT t.*, f.forum_id, f.forum_name, u.name AS username, u.uid, u2.name as user2, u2.uid as id2, p.post_username, p2.post_username AS post_username2, p2.post_time, c.cat_id, c.cat_title, f2.forum_id AS p_forum_id, f2.forum_name AS p_forum_name |
|---|
| | 667 | FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f LEFT JOIN " . FORUMS_TABLE . " f2 ON ( f.forum_parent = f2.forum_id )," . FORUM_CATEGORIES_TABLE . " c, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2 |
|---|
| | 668 | WHERE t.topic_id IN ($search_results) |
|---|
| | 669 | AND t.topic_poster = u.uid |
|---|
| | 670 | AND f.forum_id = t.forum_id |
|---|
| | 671 | AND p.post_id = t.topic_first_post_id |
|---|
| | 672 | AND p2.post_id = t.topic_last_post_id |
|---|
| | 673 | AND u2.uid = p2.poster_id |
|---|
| | 674 | AND f.cat_id = c.cat_id"; |
|---|
| | 675 | } |
|---|
| | 676 | |
|---|
| | 677 | $per_page = ( $show_results == 'posts' ) ? $config['posts_per_page'] : $config['topics_per_page']; |
|---|
| | 678 | |
|---|
| | 679 | /*if ($userdata['session_logged_in']) |
|---|
| | 680 | { |
|---|
| | 681 | if ($config['load_db_track'] && $author_id !== $userdata['uid']) |
|---|
| | 682 | { |
|---|
| | 683 | $sql_from .= ' LEFT JOIN ' . TOPICS_POSTED_TABLE . ' tp ON (tp.user_id = ' . $userdata['uid'] . ' |
|---|
| | 684 | AND t.topic_id = tp.topic_id)'; |
|---|
| | 685 | $sql_select .= ', tp.topic_posted'; |
|---|
| | 686 | } |
|---|
| | 687 | |
|---|
| | 688 | if ($config['load_db_lastread']) |
|---|
| | 689 | { |
|---|
| | 690 | $sql_from .= ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.user_id = ' . $userdata['uid'] . ' |
|---|
| | 691 | AND t.topic_id = tt.topic_id) |
|---|
| | 692 | LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $userdata['uid'] . ' |
|---|
| | 693 | AND ft.forum_id = f.forum_id)'; |
|---|
| | 694 | $sql_select .= ', tt.mark_time, ft.mark_time as f_mark_time'; |
|---|
| | 695 | } |
|---|
| | 696 | } |
|---|
| | 697 | |
|---|
| | 698 | if ($config['load_anon_lastread'] || ($userdata['session_logged_in'] && !$config['load_db_lastread'])) |
|---|
| | 699 | {*/ |
|---|
| | 700 | $tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : ''; |
|---|
| | 701 | $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); |
|---|
| | 702 | //} |
|---|
| | 703 | $topic_tracking_info = array(); |
|---|
| | 704 | |
|---|
| | 705 | $sql .= " ORDER BY "; |
|---|
| | 706 | switch ( $sort_by ) |
|---|
| | 707 | { |
|---|
| | 708 | case 1: |
|---|
| | 709 | $sql .= ( $show_results == 'posts' ) ? 'pt.post_subject' : 't.topic_title'; |
|---|
| | 710 | break; |
|---|
| | 711 | case 2: |
|---|
| | 712 | $sql .= 't.topic_title'; |
|---|
| | 713 | break; |
|---|
| | 714 | case 3: |
|---|
| | 715 | $sql .= 'u.name'; |
|---|
| | 716 | break; |
|---|
| | 717 | case 4: |
|---|
| | 718 | $sql .= 'f.forum_id'; |
|---|
| | 719 | break; |
|---|
| | 720 | default: |
|---|
| | 721 | $sql .= ( $show_results == 'posts' ) ? 'p.post_time' : 'p2.post_time'; |
|---|
| | 722 | break; |
|---|
| | 723 | } |
|---|
| | 724 | |
|---|
| | 725 | $sql .= ' ' . $sort_dir . ' LIMIT ' . $start . ', ' . $per_page; |
|---|
| | 726 | |
|---|
| | 727 | $result = $db->sql_query($sql); |
|---|
| | 728 | |
|---|
| | 729 | $searchset = array(); |
|---|
| | 730 | $forums = array(); |
|---|
| | 731 | while( $row = $db->sql_fetchrow($result) ) |
|---|
| | 732 | { |
|---|
| | 733 | $searchset[] = $row; |
|---|
| | 734 | |
|---|
| | 735 | $forums[$row['forum_id']]['topic_list'][] = $row['topic_id']; |
|---|
| | 736 | } |
|---|
| | 737 | |
|---|
| | 738 | foreach ($forums as $forum_id => $forum) |
|---|
| | 739 | { |
|---|
| | 740 | /*if ($userdata['session_logged_in'] && $config['load_db_lastread']) |
|---|
| | 741 | { |
|---|
| | 742 | $topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time']), ($forum_id) ? false : $forum['topic_list']); |
|---|
| | 743 | } |
|---|
| | 744 | else if ($config['load_anon_lastread'] || $userdata['session_logged_in']) |
|---|
| | 745 | {*/ |
|---|
| | 746 | $topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list'], ($forum_id) ? false : $forum['topic_list']); |
|---|
| | 747 | |
|---|
| | 748 | if (!$userdata['session_logged_in']) |
|---|
| | 749 | { |
|---|
| | 750 | $userdata['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['onlinesince']) : 0; |
|---|
| | 751 | } |
|---|
| | 752 | //} |
|---|
| | 753 | } |
|---|
| | 754 | unset($forums); |
|---|
| | 755 | |
|---|
| | 756 | $db->sql_freeresult($result); |
|---|
| | 757 | |
|---|
| | 758 | // |
|---|
| | 759 | // Define censored word matches |
|---|
| | 760 | // |
|---|
| | 761 | $orig_word = array(); |
|---|
| | 762 | $replacement_word = array(); |
|---|
| | 763 | $cache->obtain_word_list($orig_word, $replacement_word); |
|---|
| | 764 | |
|---|
| | 765 | // |
|---|
| | 766 | // Output header |
|---|
| | 767 | // |
|---|
| | 768 | stdhead($lang['forums'] . ' :: ' . $lang['search'], false); |
|---|
| | 769 | |
|---|
| | 770 | if ( $show_results == 'posts' ) |
|---|
| | 771 | { |
|---|
| | 772 | // Topic search MOD |
|---|
| | 773 | if( !$tid ) |
|---|
| | 774 | { |
|---|
| | 775 | // End Topic search MOD |
|---|
| | 776 | $template->set_filenames(array( |
|---|
| | 777 | 'body' => 'forum/search_results_posts.tpl') |
|---|
| | 778 | ); |
|---|
| | 779 | // Topic search MOD |
|---|
| | 780 | } |
|---|
| | 781 | else |
|---|
| | 782 | { |
|---|
| | 783 | $template->set_filenames(array( |
|---|
| | 784 | 'body' => 'forum/topic_search_results.tpl') |
|---|
| | 785 | ); |
|---|
| | 786 | } |
|---|
| | 787 | // End Topic search MOD |
|---|
| | 788 | } |
|---|
| | 789 | else |
|---|
| | 790 | { |
|---|
| | 791 | $template->set_filenames(array( |
|---|
| | 792 | 'body' => 'forum/search_results_topics.tpl') |
|---|
| | 793 | ); |
|---|
| | 794 | } |
|---|
| | 795 | //make_jumpbox('viewforum.'.$phpEx); |
|---|
| | 796 | make_jumpbox('phpbb2.php?page=viewforum'); |
|---|
| | 797 | |
|---|
| | 798 | $l_search_matches = ( $total_match_count == 1 ) ? sprintf($lang['found_search_match'], $total_match_count) : sprintf($lang['found_search_matches'], $total_match_count); |
|---|
| | 799 | |
|---|
| | 800 | $template->assign_vars(array( |
|---|
| | 801 | 'L_SEARCH_MATCHES' => $l_search_matches) |
|---|
| | 802 | ); |
|---|
| | 803 | |
|---|
| | 804 | $highlight_active = ''; |
|---|
| | 805 | $highlight_match = array(); |
|---|
| | 806 | for($j = 0; $j < sizeof($split_search); $j++ ) |
|---|
| | 807 | { |
|---|
| | 808 | $split_word = $split_search[$j]; |
|---|
| | 809 | |
|---|
| | 810 | if ( $split_word != 'and' && $split_word != 'or' && $split_word != 'not' ) |
|---|
| | 811 | { |
|---|
| | 812 | $highlight_match[] = '#\b(' . str_replace("*", "([\w]+)?", $split_word) . ')\b#is'; |
|---|
| | 813 | $highlight_active .= " " . $split_word; |
|---|
| | 814 | |
|---|
| | 815 | for ($k = 0; $k < sizeof($synonym_array); $k++) |
|---|
| | 816 | { |
|---|
| | 817 | list($replace_synonym, $match_synonym) = split(' ', trim(utf_strtolower($synonym_array[$k]))); |
|---|
| | 818 | |
|---|
| | 819 | if ( $replace_synonym == $split_word ) |
|---|
| | 820 | { |
|---|
| | 821 | $highlight_match[] = '#\b(' . str_replace("*", "([\w]+)?", $replace_synonym) . ')\b#is'; |
|---|
| | 822 | $highlight_active .= ' ' . $match_synonym; |
|---|
| | 823 | } |
|---|
| | 824 | } |
|---|
| | 825 | } |
|---|
| | 826 | } |
|---|
| | 827 | |
|---|
| | 828 | $highlight_active = urlencode(trim($highlight_active)); |
|---|
| | 829 | |
|---|
| | 830 | for($i = 0; $i < sizeof($searchset); $i++) |
|---|
| | 831 | { |
|---|
| | 832 | |
|---|
| | 833 | $topic_title = $searchset[$i]['topic_title']; |
|---|
| | 834 | |
|---|
| | 835 | $forum_id = $searchset[$i]['forum_id']; |
|---|
| | 836 | $topic_id = $searchset[$i]['topic_id']; |
|---|
| | 837 | |
|---|
| | 838 | // www.phpBB-SEO.com SEO TOOLKIT BEGIN |
|---|
| | 839 | $seo->set_url($searchset[$i]['cat_id'], $searchset[$i]['cat_title'], $seo->seo_static['forum_cat']); |
|---|
| | 840 | |
|---|
| | 841 | if ( !empty($searchset[$i]['p_forum_id']) ) { |
|---|
| | 842 | $seo->set_parent($searchset[$i]['p_forum_id'], $seo->seo_static['forum'], $searchset[$i]['cat_id'], $seo->seo_static['forum_cat']); |
|---|
| | 843 | $seo->set_url($searchset[$i]['p_forum_name'], $searchset[$i]['p_forum_id'], $seo->seo_static['forum']); |
|---|
| | 844 | $seo->set_parent($forum_id, $seo->seo_static['forum'], $searchset[$i]['p_forum_id'], $seo->seo_static['forum']); |
|---|
| | 845 | } |
|---|
| | 846 | else { |
|---|
| | 847 | $seo->set_parent($forum_id, $seo->seo_static['forum'], $searchset[$i]['cat_id'], $seo->seo_static['forum_cat']); |
|---|
| | 848 | } |
|---|
| | 849 | $seo->set_url($searchset[$i]['forum_name'], $forum_id, $seo->seo_static['forum']); |
|---|
| | 850 | |
|---|
| | 851 | $seo->set_parent($topic_id, $seo->seo_static['topic'], $forum_id, $seo->seo_static['forum']); |
|---|
| | 852 | $seo->set_url($topic_title, $topic_id, $seo->seo_static['topic']); |
|---|
| | 853 | |
|---|
| | 854 | if ( $show_results != 'posts' ) { |
|---|
| | 855 | |
|---|
| | 856 | $seo->set_user_url($searchset[$i]['username'], $searchset[$i]['uid']); |
|---|
| | 857 | $seo->set_user_url($searchset[$i]['user2'], $searchset[$i]['id2']); |
|---|
| | 858 | } |
|---|
| | 859 | // www.phpBB-SEO.com SEO TOOLKIT END |
|---|
| | 860 | |
|---|
| | 861 | //$forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . '=' . $searchset[$i]['forum_id']); |
|---|
| | 862 | $forum_url = append_sid($root_path . "phpbb2.php?page=viewforum&" . POST_FORUM_URL . '=' . $searchset[$i]['forum_id']); |
|---|
| | 863 | //$topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $searchset[$i]['topic_id'] . "&highlight=$highlight_active"); |
|---|
| | 864 | $topic_url = append_sid($root_path . "phpbb2.php?page=viewtopic&" . 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($searchset[$i]['post_time']); |
|---|
| | 868 | |
|---|
| | 869 | if ( $show_results == 'posts' ) |
|---|
| | 870 | { |
|---|
| | 871 | $message = $searchset[$i]['post_text']; |
|---|
| | 872 | $post_url = append_sid($root_path . "phpbb2.php?page=viewtopic&" . POST_POST_URL . '=' . $searchset[$i]['post_id'] . "&highlight=$highlight_active") . '#' . $searchset[$i]['post_id']; |
|---|
| | 873 | |
|---|
| | 874 | if ( isset($return_chars) ) |
|---|
| | 875 | { |
|---|
| | 876 | |
|---|
| | 877 | // |
|---|
| | 878 | // If the board has HTML off but the post has HTML |
|---|
| | 879 | // on then we process it, else leave it alone |
|---|
| | 880 | // |
|---|
| | 881 | if ( $return_chars != -1 ) |
|---|
| | 882 | { |
|---|
| | 883 | $message = strip_tags($message); |
|---|
| | 884 | $message = preg_replace('/\[url\]|\[\/url\]/si', '', $message); |
|---|
| | 885 | $message = ( utf_strlen($message) > $return_chars ) ? substr($message, 0, $return_chars) . ' ...' : $message; |
|---|
| | 886 | } |
|---|
| | 887 | else |
|---|
| | 888 | { |
|---|
| | 889 | if ( !$config['allow_html'] ) |
|---|
| | 890 | { |
|---|
| | 891 | if ( $searchset[$i]['enable_html'] ) |
|---|
| | 892 | { |
|---|
| | 893 | $message = preg_replace('#(<)([\/]?.*?)(>)#is', '<\\2>', $message); |
|---|
| | 894 | } |
|---|
| | 895 | } |
|---|
| | 896 | |
|---|
| | 897 | $bb_code->parse($message); |
|---|
| | 898 | $message = $bb_code->get_html(); |
|---|
| | 899 | |
|---|
| | 900 | if ( $highlight_active ) |
|---|
| | 901 | { |
|---|
| | 902 | if ( preg_match('/<.*>/', $message) ) |
|---|
| | 903 | { |
|---|
| | 904 | $message = preg_replace($highlight_match, '<!-- #sh -->\1<!-- #eh -->', $message); |
|---|
| | 905 | |
|---|
| | 906 | $end_html = 0; |
|---|
| | 907 | $start_html = 1; |
|---|
| | 908 | $temp_message = ''; |
|---|
| | 909 | $message = ' ' . $message . ' '; |
|---|
| | 910 | |
|---|
| | 911 | while( $start_html = strpos($message, '<', $start_html) ) |
|---|
| | 912 | { |
|---|
| | 913 | $grab_length = $start_html - $end_html - 1; |
|---|
| | 914 | $temp_message .= substr($message, $end_html + 1, $grab_length); |
|---|
| | 915 | |
|---|
| | 916 | if ( $end_html = strpos($message, '>', $start_html) ) |
|---|
| | 917 | { |
|---|
| | 918 | $length = $end_html - $start_html + 1; |
|---|
| | 919 | $hold_string = substr($message, $start_html, $length); |
|---|
| | 920 | |
|---|
| | 921 | if ( strrpos(' ' . $hold_string, '<') != 1 ) |
|---|
| | 922 | { |
|---|
| | 923 | $end_html = $start_html + 1; |
|---|
| | 924 | $end_counter = 1; |
|---|
| | 925 | |
|---|
| | 926 | while ( $end_counter && $end_html < utf_strlen($message) ) |
|---|
| | 927 | { |
|---|
| | 928 | if ( substr($message, $end_html, 1) == '>' ) |
|---|
| | 929 | { |
|---|
| | 930 | $end_counter--; |
|---|
| | 931 | } |
|---|
| | 932 | else if ( substr($message, $end_html, 1) == '<' ) |
|---|
| | 933 | { |
|---|
| | 934 | $end_counter++; |
|---|
| | 935 | } |
|---|
| | 936 | |
|---|
| | 937 | $end_html++; |
|---|
| | 938 | } |
|---|
| | 939 | |
|---|
| | 940 | $length = $end_html - $start_html + 1; |
|---|
| | 941 | $hold_string = substr($message, $start_html, $length); |
|---|
| | 942 | $hold_string = str_replace('<!-- #sh -->', '', $hold_string); |
|---|
| | 943 | $hold_string = str_replace('<!-- #eh -->', '', $hold_string); |
|---|
| | 944 | } |
|---|
| | 945 | else if ( $hold_string == '<!-- #sh -->' ) |
|---|
| | 946 | { |
|---|
| | 947 | $hold_string = str_replace('<!-- #sh -->', '<span style="color:#' . $theme['fontcolor3'] . '"><b>', $hold_string); |
|---|
| | 948 | } |
|---|
| | 949 | else if ( $hold_string == '<!-- #eh -->' ) |
|---|
| | 950 | { |
|---|
| | 951 | $hold_string = str_replace('<!-- #eh -->', '</b></span>', $hold_string); |
|---|
| | 952 | } |
|---|
| | 953 | |
|---|
| | 954 | $temp_message .= $hold_string; |
|---|
| | 955 | |
|---|
| | 956 | $start_html += $length; |
|---|
| | 957 | } |
|---|
| | 958 | else |
|---|
| | 959 | { |
|---|
| | 960 | $start_html = utf_strlen($message); |
|---|
| | 961 | } |
|---|
| | 962 | } |
|---|
| | 963 | |
|---|
| | 964 | $grab_length = utf_strlen($message) - $end_html - 1; |
|---|
| | 965 | $temp_message .= substr($message, $end_html + 1, $grab_length); |
|---|
| | 966 | |
|---|
| | 967 | $message = trim($temp_message); |
|---|
| | 968 | } |
|---|
| | 969 | else |
|---|
| | 970 | { |
|---|
| | 971 | $message = preg_replace($highlight_match, '<span style="color:#' . $theme['fontcolor3'] . '"><b>\1</b></span>', $message); |
|---|
| | 972 | } |
|---|
| | 973 | } |
|---|
| | 974 | } |
|---|
| | 975 | |
|---|
| | 976 | $topic_title = censor_text($topic_title); |
|---|
| | 977 | $post_subject = ( $searchset[$i]['post_subject'] != '' ) ? censor_text($searchset[$i]['post_subject']) : $topic_title; |
|---|
| | 978 | $message = censor_text($message); |
|---|
| | 979 | |
|---|
| | 980 | $message = str_replace("\n", '<br />', $message); |
|---|
| | 981 | |
|---|
| | 982 | } |
|---|
| | 983 | |
|---|
| | 984 | $poster = ( $searchset[$i]['uid'] != ANONYMOUS ) ? '<a href="' . append_sid($root_path . "userdetails.php?id=" . $searchset[$i]['uid']) . '">' : ''; |
|---|
| | 985 | $poster .= ( $searchset[$i]['uid'] != ANONYMOUS ) ? $searchset[$i]['username'] : ( ( $searchset[$i]['post_username'] != "" ) ? $searchset[$i]['post_username'] : $lang['guest'] ); |
|---|
| | 986 | $poster .= ( $searchset[$i]['uid'] != ANONYMOUS ) ? '</a>' : ''; |
|---|
| | 987 | |
|---|
| | 988 | /*if ( $userdata['session_logged_in'] && $searchset[$i]['post_time'] > $userdata['user_lastvisit'] ) |
|---|
| | 989 | { |
|---|
| | 990 | $topic_last_read = 0; |
|---|
| | 991 | if ( !empty($tracking_topics[$topic_id]) && !empty($tracking_forums[$forum_id]) ) |
|---|
| | 992 | { |
|---|
| | 993 | $topic_last_read = ( $tracking_topics[$topic_id] > $tracking_forums[$forum_id] ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id]; |
|---|
| | 994 | } |
|---|
| | 995 | else if ( !empty($tracking_topics[$topic_id]) || !empty($tracking_forums[$forum_id]) ) |
|---|
| | 996 | { |
|---|
| | 997 | $topic_last_read = ( !empty($tracking_topics[$topic_id]) ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id]; |
|---|
| | 998 | } |
|---|
| | 999 | |
|---|
| | 1000 | if ( $searchset[$i]['post_time'] > $topic_last_read ) |
|---|
| | 1001 | { |
|---|
| | 1002 | $mini_post_img = $images['icon_minipost_new']; |
|---|
| | 1003 | $mini_post_alt = $lang['new_post']; |
|---|
| | 1004 | } |
|---|
| | 1005 | else |
|---|
| | 1006 | { |
|---|
| | 1007 | $mini_post_img = $images['icon_minipost']; |
|---|
| | 1008 | $mini_post_alt = $lang['post']; |
|---|
| | 1009 | } |
|---|
| | 1010 | } |
|---|
| | 1011 | else |
|---|
| | 1012 | { |
|---|
| | 1013 | $mini_post_img = $images['icon_minipost']; |
|---|
| | 1014 | $mini_post_alt = $lang['post']; |
|---|
| | 1015 | }*/ |
|---|
| | 1016 | |
|---|
| | 1017 | $unread_topic = (isset($topic_tracking_info[$forum_id][$topic_id]) && $searchset[$i]['post_time'] > $topic_tracking_info[$forum_id][$topic_id]) ? true : false; |
|---|
| | 1018 | |
|---|
| | 1019 | if ( $unread_topic ) |
|---|
| | 1020 | { |
|---|
| | 1021 | $mini_post_img = $images['icon_minipost_new']; |
|---|
| | 1022 | $mini_post_alt = $lang['new_post']; |
|---|
| | 1023 | } |
|---|
| | 1024 | else |
|---|
| | 1025 | { |
|---|
| | 1026 | $mini_post_img = $images['icon_minipost']; |
|---|
| | 1027 | $mini_post_alt = $lang['post']; |
|---|
| | 1028 | } |
|---|
| | 1029 | |
|---|
| | 1030 | $template->assign_block_vars("searchresults", array( |
|---|
| | 1031 | 'TOPIC_TITLE' => $topic_title, |
|---|
| | 1032 | 'FORUM_NAME' => $searchset[$i]['forum_name'], |
|---|
| | 1033 | 'POST_SUBJECT' => $post_subject, |
|---|
| | 1034 | 'POST_DATE' => $post_date, |
|---|
| | 1035 | 'POSTER_NAME' => $poster, |
|---|
| | 1036 | 'TOPIC_REPLIES' => $searchset[$i]['topic_replies'], |
|---|
| | 1037 | 'TOPIC_VIEWS' => $searchset[$i]['topic_views'], |
|---|
| | 1038 | 'MESSAGE' => $message, |
|---|
| | 1039 | 'MINI_POST_IMG' => $mini_post_img, |
|---|
| | 1040 | |
|---|
| | 1041 | 'L_MINI_POST_ALT' => $mini_post_alt, |
|---|
| | 1042 | |
|---|
| | 1043 | 'U_POST' => $post_url, |
|---|
| | 1044 | 'U_TOPIC' => $topic_url, |
|---|
| | 1045 | 'U_FORUM' => $forum_url) |
|---|
| | 1046 | ); |
|---|
| | 1047 | } |
|---|
| | 1048 | else |
|---|
| | 1049 | { |
|---|
| | 1050 | $message = ''; |
|---|
| | 1051 | |
|---|
| | 1052 | if ( count($orig_word) ) |
|---|
| | 1053 | { |
|---|
| | 1054 | $topic_title = preg_replace($orig_word, $replacement_word, $searchset[$i]['topic_title']); |
|---|
| | 1055 | } |
|---|
| | 1056 | |
|---|
| | 1057 | $topic_type = $searchset[$i]['topic_type']; |
|---|
| | 1058 | |
|---|
| | 1059 | if ($topic_type == POST_ANNOUNCE) |
|---|
| | 1060 | { |
|---|
| | 1061 | $topic_type = $lang['topic_announcement'] . ' '; |
|---|
| | 1062 | } |
|---|
| | 1063 | else if ($topic_type == POST_STICKY) |
|---|
| | 1064 | { |
|---|
| | 1065 | $topic_type = $lang['topic_sticky'] . ' '; |
|---|
| | 1066 | } |
|---|
| | 1067 | else |
|---|
| | 1068 | { |
|---|
| | 1069 | $topic_type = ''; |
|---|
| | 1070 | } |
|---|
| | 1071 | |
|---|
| | 1072 | if ( $searchset[$i]['topic_vote'] ) |
|---|
| | 1073 | { |
|---|
| | 1074 | $topic_type .= $lang['topic_poll'] . ' '; |
|---|
| | 1075 | } |
|---|
| | 1076 | |
|---|
| | 1077 | $views = $searchset[$i]['topic_views']; |
|---|
| | 1078 | $replies = $searchset[$i]['topic_replies']; |
|---|
| | 1079 | |
|---|
| | 1080 | if ( ( $replies + 1 ) > $config['posts_per_page'] ) |
|---|
| | 1081 | { |
|---|
| | 1082 | $total_pages = ceil( ( $replies + 1 ) / $config['posts_per_page'] ); |
|---|
| | 1083 | //$goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['goto_page'] . '" title="' . $lang['goto_page'] . '" />' . $lang['goto_page'] . ': '; |
|---|
| | 1084 | $goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['goto_page'] . '" title="' . $lang['goto_page'] . '" />' . $lang['goto_page'] . ': '; |
|---|
| | 1085 | |
|---|
| | 1086 | $times = 1; |
|---|
| | 1087 | for($j = 0; $j < $replies + 1; $j += $config['posts_per_page']) |
|---|
| | 1088 | { |
|---|
| | 1089 | //$goto_page .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_id . "&start=$j") . '">' . $times . '</a>'; |
|---|
| | 1090 | $goto_page .= '<a href="' . append_sid($root_path . "phpbb2.php?page=viewtopic&" . POST_TOPIC_URL . "=" . $topic_id . "&start=$j") . '">' . $times . '</a>'; |
|---|
| | 1091 | if ( $times == 1 && $total_pages > 4 ) |
|---|
| | 1092 | { |
|---|
| | 1093 | $goto_page .= ' ... '; |
|---|
| | 1094 | $times = $total_pages - 3; |
|---|
| | 1095 | $j += ( $total_pages - 4 ) * $config['posts_per_page']; |
|---|
| | 1096 | } |
|---|
| | 1097 | else if ( $times < $total_pages ) |
|---|
| | 1098 | { |
|---|
| | 1099 | $goto_page .= ', '; |
|---|
| | 1100 | } |
|---|
| | 1101 | $times++; |
|---|
| | 1102 | } |
|---|
| | 1103 | $goto_page .= ' ] '; |
|---|
| | 1104 | } |
|---|
| | 1105 | else |
|---|
| | 1106 | { |
|---|
| | 1107 | $goto_page = ''; |
|---|
| | 1108 | } |
|---|
| | 1109 | |
|---|
| | 1110 | if ( $searchset[$i]['topic_status'] == TOPIC_MOVED ) |
|---|
| | 1111 | { |
|---|
| | 1112 | $topic_type = $lang['topic_moved'] . ' '; |
|---|
| | 1113 | $topic_id = $searchset[$i]['topic_moved_id']; |
|---|
| | 1114 | |
|---|
| | 1115 | //$folder_image = '<img src="' . $images['folder'] . '" alt="' . $lang['no_new_posts'] . '" />'; |
|---|
| | 1116 | $folder_image = '<img src="' . $images['folder'] . '" alt="' . $lang['no_new_posts'] . '" />'; |
|---|
| | 1117 | $newest_post_img = ''; |
|---|
| | 1118 | } |
|---|
| | 1119 | else |
|---|
| | 1120 | { |
|---|
| | 1121 | if ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) |
|---|
| | 1122 | { |
|---|
| | 1123 | $folder = $images['folder_locked']; |
|---|
| | 1124 | $folder_new = $images['folder_locked_new']; |
|---|
| | 1125 | } |
|---|
| | 1126 | else if ( $searchset[$i]['topic_type'] == POST_ANNOUNCE ) |
|---|
| | 1127 | { |
|---|
| | 1128 | $folder = $images['folder_announce']; |
|---|
| | 1129 | $folder_new = $images['folder_announce_new']; |
|---|
| | 1130 | } |
|---|
| | 1131 | else if ( $searchset[$i]['topic_type'] == POST_STICKY ) |
|---|
| | 1132 | { |
|---|
| | 1133 | $folder = $images['folder_sticky']; |
|---|
| | 1134 | $folder_new = $images['folder_sticky_new']; |
|---|
| | 1135 | } |
|---|
| | 1136 | else |
|---|
| | 1137 | { |
|---|
| | 1138 | if ( $replies >= $config['hot_threshold'] ) |
|---|
| | 1139 | { |
|---|
| | 1140 | $folder = $images['folder_hot']; |
|---|
| | 1141 | $folder_new = $images['folder_hot_new']; |
|---|
| | 1142 | } |
|---|
| | 1143 | else |
|---|
| | 1144 | { |
|---|
| | 1145 | $folder = $images['folder']; |
|---|
| | 1146 | $folder_new = $images['folder_new']; |
|---|
| | 1147 | } |
|---|
| | 1148 | } |
|---|
| | 1149 | |
|---|
| | 1150 | /*if ( $userdata['session_logged_in'] ) |
|---|
| | 1151 | { |
|---|
| | 1152 | if ( $searchset[$i]['post_time'] > $userdata['user_lastvisit'] ) |
|---|
| | 1153 | { |
|---|
| | 1154 | if ( !empty($tracking_topics) || !empty($tracking_forums) || isset($_COOKIE[$config['cookie_name'] . '_f_all']) ) |
|---|
| | 1155 | { |
|---|
| | 1156 | |
|---|
| | 1157 | $unread_topics = true; |
|---|
| | 1158 | |
|---|
| | 1159 | if ( !empty($tracking_topics[$topic_id]) ) |
|---|
| | 1160 | { |
|---|
| | 1161 | if ( $tracking_topics[$topic_id] > $searchset[$i]['post_time'] ) |
|---|
| | 1162 | { |
|---|
| | 1163 | $unread_topics = false; |
|---|
| | 1164 | } |
|---|
| | 1165 | } |
|---|
| | 1166 | |
|---|
| | 1167 | if ( !empty($tracking_forums[$forum_id]) ) |
|---|
| | 1168 | { |
|---|
| | 1169 | if ( $tracking_forums[$forum_id] > $searchset[$i]['post_time'] ) |
|---|
| | 1170 | { |
|---|
| | 1171 | $unread_topics = false; |
|---|
| | 1172 | } |
|---|
| | 1173 | } |
|---|
| | 1174 | |
|---|
| | 1175 | if ( isset($_COOKIE[$config['cookie_name'] . '_f_all']) ) |
|---|
| | 1176 | { |
|---|
| | 1177 | if ( $_COOKIE[$config['cookie_name'] . '_f_all'] > $searchset[$i]['post_time'] ) |
|---|
| | 1178 | { |
|---|
| | 1179 | $unread_topics = false; |
|---|
| | 1180 | } |
|---|
| | 1181 | }*/ |
|---|
| | 1182 | |
|---|
| | 1183 | $unread_topics = (isset($topic_tracking_info[$forum_id][$topic_id]) && $searchset[$i]['post_time'] > $topic_tracking_info[$forum_id][$topic_id]) ? true : false; |
|---|
| | 1184 | |
|---|
| | 1185 | if ( $unread_topics ) |
|---|
| | 1186 | { |
|---|
| | 1187 | $folder_image = $folder_new; |
|---|
| | 1188 | $folder_alt = $lang['new_posts']; |
|---|
| | 1189 | |
|---|
| | 1190 | //$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> '; |
|---|
| | 1191 | $newest_post_img = '<a href="' . append_sid($root_path . "phpbb2.php?page=viewtopic&" . 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> '; |
|---|
| | 1192 | } |
|---|
| | 1193 | else |
|---|
| | 1194 | { |
|---|
| | 1195 | $folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['topic_locked'] : $lang['no_new_posts']; |
|---|
| | 1196 | |
|---|
| | 1197 | $folder_image = $folder; |
|---|
| | 1198 | $folder_alt = $folder_alt; |
|---|
| | 1199 | $newest_post_img = ''; |
|---|
| | 1200 | } |
|---|
| | 1201 | |
|---|
| | 1202 | /*} |
|---|
| | 1203 | else if ( $searchset[$i]['post_time'] > $userdata['user_lastvisit'] ) |
|---|
| | 1204 | { |
|---|
| | 1205 | $folder_image = $folder_new; |
|---|
| | 1206 | $folder_alt = $lang['new_posts']; |
|---|
| | 1207 | |
|---|
| | 1208 | //$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> '; |
|---|
| | 1209 | $newest_post_img = '<a href="' . append_sid($root_path . "phpbb2.php?page=viewtopic&" . 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> '; |
|---|
| | 1210 | } |
|---|
| | 1211 | else |
|---|
| | 1212 | { |
|---|
| | 1213 | $folder_image = $folder; |
|---|
| | 1214 | $folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['topic_locked'] : $lang['no_new_posts']; |
|---|
| | 1215 | $newest_post_img = ''; |
|---|
| | 1216 | } |
|---|
| | 1217 | } |
|---|
| | 1218 | else |
|---|
| | 1219 | { |
|---|
| | 1220 | $folder_image = $folder; |
|---|
| | 1221 | $folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['topic_locked'] : $lang['no_new_posts']; |
|---|
| | 1222 | $newest_post_img = ''; |
|---|
| | 1223 | } |
|---|
| | 1224 | } |
|---|
| | 1225 | else |
|---|
| | 1226 | { |
|---|
| | 1227 | $folder_image = $folder; |
|---|
| | 1228 | $folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['topic_locked'] : $lang['no_new_posts']; |
|---|
| | 1229 | $newest_post_img = ''; |
|---|
| | 1230 | }*/ |
|---|
| | 1231 | } |
|---|
| | 1232 | |
|---|
| | 1233 | |
|---|
| | 1234 | $topic_author = ( $searchset[$i]['uid'] != ANONYMOUS ) ? '<a href="' . append_sid($root_path . "userdetails.php?id=" . $searchset[$i]['uid']) . '">' : ''; |
|---|
| | 1235 | $topic_author .= ( $searchset[$i]['uid'] != ANONYMOUS ) ? $searchset[$i]['username'] : ( ( $searchset[$i]['post_username'] != '' ) ? $searchset[$i]['post_username'] : $lang['guest'] ); |
|---|
| | 1236 | |
|---|
| | 1237 | $topic_author .= ( $searchset[$i]['uid'] != ANONYMOUS ) ? '</a>' : ''; |
|---|
| | 1238 | |
|---|
| | 1239 | $first_post_time = create_date($searchset[$i]['topic_time']); |
|---|
| | 1240 | |
|---|
| | 1241 | $last_post_time = create_date($searchset[$i]['post_time']); |
|---|
| | 1242 | |
|---|
| | 1243 | $last_post_author = ( $searchset[$i]['id2'] == ANONYMOUS ) ? ( ($searchset[$i]['post_username2'] != '' ) ? $searchset[$i]['post_username2'] . ' ' : $lang['guest'] . ' ' ) : '<a href="' . append_sid($root_path . "userdetails.php?id=" . $searchset[$i]['id2']) . '">' . $searchset[$i]['user2'] . '</a>'; |
|---|
| | 1244 | |
|---|
| | 1245 | $last_post_url = '<a href="' . append_sid($root_path . "phpbb2.php?page=viewtopic&" . 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>'; |
|---|
| | 1246 | |
|---|
| | 1247 | $template->assign_block_vars('searchresults', array( |
|---|
| | 1248 | 'FORUM_NAME' => $searchset[$i]['forum_name'], |
|---|
| | 1249 | 'FORUM_ID' => $forum_id, |
|---|
| | 1250 | 'TOPIC_ID' => $topic_id, |
|---|
| | 1251 | 'FOLDER' => $folder_image, |
|---|
| | 1252 | 'NEWEST_POST_IMG' => $newest_post_img, |
|---|
| | 1253 | 'TOPIC_FOLDER_IMG' => $folder_image, |
|---|
| | 1254 | 'GOTO_PAGE' => $goto_page, |
|---|
| | 1255 | 'REPLIES' => $replies, |
|---|
| | 1256 | 'TOPIC_TITLE' => $topic_title, |
|---|
| | 1257 | 'TOPIC_TYPE' => $topic_type, |
|---|
| | 1258 | 'VIEWS' => $views, |
|---|
| | 1259 | 'TOPIC_AUTHOR' => $topic_author, |
|---|
| | 1260 | 'FIRST_POST_TIME' => $first_post_time, |
|---|
| | 1261 | 'LAST_POST_TIME' => $last_post_time, |
|---|
| | 1262 | 'LAST_POST_AUTHOR' => $last_post_author, |
|---|
| | 1263 | 'LAST_POST_IMG' => $last_post_url, |
|---|
| | 1264 | |
|---|
| | 1265 | 'L_TOPIC_FOLDER_ALT' => $folder_alt, |
|---|
| | 1266 | |
|---|
| | 1267 | 'U_VIEW_FORUM' => $forum_url, |
|---|
| | 1268 | 'U_VIEW_TOPIC' => $topic_url) |
|---|
| | 1269 | ); |
|---|
| | 1270 | } |
|---|
| | 1271 | } |
|---|
| | 1272 | // Topic search MOD |
|---|
| | 1273 | if( !$tid ) |
|---|
| | 1274 | { |
|---|
| | 1275 | // End Topic search MOD |
|---|
| | 1276 | $base_url = "phpbb2.php?page=search&search_id=$search_id&search_author=$search_author"; |
|---|
| | 1277 | // Topic search MOD |
|---|
| | 1278 | } |
|---|
| | 1279 | else |
|---|
| | 1280 | { |
|---|
| | 1281 | $base_url = "phpbb2.php?page=search&search_id=$search_id&topic_id=$tid"; |
|---|
| | 1282 | } |
|---|
| | 1283 | // End Topic search MOD |
|---|
| | 1284 | |
|---|
| | 1285 | $template->assign_vars(array( |
|---|
| | 1286 | 'PAGINATION' => generate_pagination($root_path . $base_url, $total_match_count, $per_page, $start), |
|---|
| | 1287 | 'PAGE_NUMBER' => sprintf($lang['page_of'], ( floor( $start / $per_page ) + 1 ), ceil( $total_match_count / $per_page )), |
|---|
| | 1288 | )); |
|---|
| | 1289 | return; |
|---|
| | 1290 | } |
|---|
| | 1291 | else |
|---|
| | 1292 | { |
|---|
| | 1293 | trigger_error($lang['no_search_match']); |
|---|
| | 1294 | return; |
|---|
| | 1295 | } |
|---|