2001-11-17 17:44:31 +00:00
|
|
|
<?php
|
2001-05-29 14:25:09 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* search.php
|
|
|
|
* -------------------
|
|
|
|
* begin : Saturday, Feb 13, 2001
|
|
|
|
* copyright : (C) 2001 The phpBB Group
|
|
|
|
* email : support@phpbb.com
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2001-08-30 22:20:23 +00:00
|
|
|
/***************************************************************************
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2002-03-18 13:35:43 +00:00
|
|
|
define('IN_PHPBB', true);
|
2001-07-13 16:14:37 +00:00
|
|
|
$phpbb_root_path = "./";
|
|
|
|
include($phpbb_root_path . 'extension.inc');
|
|
|
|
include($phpbb_root_path . 'common.'.$phpEx);
|
2001-09-17 00:42:17 +00:00
|
|
|
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
|
2002-03-18 13:35:43 +00:00
|
|
|
include($phpbb_root_path . 'includes/functions_search.'.$phpEx);
|
2001-05-29 14:25:09 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Start session management
|
|
|
|
//
|
2002-02-25 01:00:48 +00:00
|
|
|
$userdata = session_pagestart($user_ip, PAGE_SEARCH);
|
2001-05-29 14:25:09 +00:00
|
|
|
init_userprefs($userdata);
|
|
|
|
//
|
|
|
|
// End session management
|
|
|
|
//
|
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
//
|
|
|
|
// Define initial vars
|
|
|
|
//
|
2001-10-14 18:22:32 +00:00
|
|
|
if( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) )
|
|
|
|
{
|
|
|
|
$mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$mode = '';
|
2001-10-14 18:22:32 +00:00
|
|
|
}
|
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
if( isset($HTTP_POST_VARS['search_keywords']) || isset($HTTP_GET_VARS['search_keywords']) )
|
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$search_keywords = ( isset($HTTP_POST_VARS['search_keywords']) ) ? $HTTP_POST_VARS['search_keywords'] : $HTTP_GET_VARS['search_keywords'];
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$search_keywords = '';
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
2001-05-29 14:25:09 +00:00
|
|
|
|
2001-11-14 06:39:17 +00:00
|
|
|
if( isset($HTTP_POST_VARS['search_author']) || isset($HTTP_GET_VARS['search_author']))
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$search_author = ( isset($HTTP_POST_VARS['search_author']) ) ? $HTTP_POST_VARS['search_author'] : $HTTP_GET_VARS['search_author'];
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$search_author = '';
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
2001-05-29 14:25:09 +00:00
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
$search_id = ( isset($HTTP_GET_VARS['search_id']) ) ? $HTTP_GET_VARS['search_id'] : "";
|
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$show_results = ( isset($HTTP_POST_VARS['show_results']) ) ? $HTTP_POST_VARS['show_results'] : "posts";
|
2002-01-25 00:48:46 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
if( isset($HTTP_POST_VARS['search_terms']) )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$search_terms = ( $HTTP_POST_VARS['search_terms'] == "all" ) ? 1 : 0;
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$search_terms = 0;
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
if( isset($HTTP_POST_VARS['search_fields']) )
|
2002-01-12 17:00:32 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$search_fields = ( $HTTP_POST_VARS['search_fields'] == "all" ) ? 1 : 0;
|
2002-01-12 17:00:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$search_fields = 0;
|
2002-01-12 17:00:32 +00:00
|
|
|
}
|
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$return_chars = ( isset($HTTP_POST_VARS['return_chars']) ) ? intval($HTTP_POST_VARS['return_chars']) : 200;
|
2001-09-17 00:42:17 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$search_cat = ( isset($HTTP_POST_VARS['search_cat']) ) ? intval($HTTP_POST_VARS['search_cat']) : -1;
|
|
|
|
$search_forum = ( isset($HTTP_POST_VARS['search_forum']) ) ? intval($HTTP_POST_VARS['search_forum']) : -1;
|
2001-09-26 01:36:52 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$sort_by = ( isset($HTTP_POST_VARS['sort_by']) ) ? intval($HTTP_POST_VARS['sort_by']) : 0;
|
2001-09-17 00:42:17 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
if( isset($HTTP_POST_VARS['sort_dir']) )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$sort_dir = ( $HTTP_POST_VARS['sort_dir'] == "DESC" ) ? "DESC" : "ASC";
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$sort_dir = "DESC";
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
if(!empty($HTTP_POST_VARS['search_time']) )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$search_time = time() - ( intval($HTTP_POST_VARS['search_time']) * 86400 );
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$search_time = 0;
|
|
|
|
}
|
|
|
|
|
2001-12-20 01:25:00 +00:00
|
|
|
$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
|
2001-05-29 14:25:09 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Define some globally used data
|
|
|
|
//
|
2002-02-25 01:00:48 +00:00
|
|
|
$sort_by_types = array($lang['Sort_Time'], $lang['Sort_Post_Subject'], $lang['Sort_Topic_Title'], $lang['Sort_Author'], $lang['Sort_Forum']);
|
|
|
|
$sort_by_sql = array("p.post_time", "pt.post_subject", "t.topic_title", "u.username", "f.forum_id");
|
2001-05-29 14:25:09 +00:00
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
//
|
|
|
|
// Begin core code
|
|
|
|
//
|
2002-02-25 01:00:48 +00:00
|
|
|
if( $mode == 'searchuser' )
|
2001-10-16 14:47:27 +00:00
|
|
|
{
|
|
|
|
//
|
|
|
|
// This handles the simple windowed user search
|
|
|
|
// functions called from various other scripts. If a
|
|
|
|
// script allows an 'inline' user search then this is
|
|
|
|
// handled by the script itself, this is only for the
|
|
|
|
// windowed version
|
|
|
|
//
|
|
|
|
if( isset($HTTP_POST_VARS['search']) )
|
|
|
|
{
|
|
|
|
username_search($HTTP_POST_VARS['search_author'], false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
username_search("", false);
|
|
|
|
}
|
|
|
|
|
|
|
|
exit;
|
|
|
|
}
|
2002-02-25 01:00:48 +00:00
|
|
|
else if( $search_keywords != '' || $search_author != '' || $search_id )
|
2001-05-29 14:25:09 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$store_vars = array('search_results', 'total_match_count', 'split_search', 'sort_by', 'sort_dir', 'show_results', 'return_chars');
|
|
|
|
|
2001-12-05 00:20:56 +00:00
|
|
|
//
|
|
|
|
// Cycle through options ...
|
|
|
|
//
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( $search_id == 'newposts' || $search_id == 'egosearch' || $search_id == 'unanswered' || $search_keywords != '' || $search_author != '' )
|
2001-12-05 00:20:56 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( $search_id == 'newposts' || $search_id == 'egosearch' || ( $search_author != '' && $search_keywords == '' ) )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( $search_id == 'newposts' )
|
2001-12-14 02:41:33 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( $userdata['session_logged_in'] )
|
|
|
|
{
|
|
|
|
$sql = "SELECT post_id
|
|
|
|
FROM " . POSTS_TABLE . "
|
|
|
|
WHERE post_time >= " . $userdata['user_lastvisit'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
header("Location: login.$phpEx?redirect=search&search_id=newposts");
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$show_results = "topics";
|
|
|
|
$sort_by = 0;
|
|
|
|
$sort_dir = "DESC";
|
2001-12-14 02:41:33 +00:00
|
|
|
}
|
2002-02-25 01:00:48 +00:00
|
|
|
else if ( $search_id == 'egosearch' )
|
2001-12-14 02:41:33 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( $userdata['session_logged_in'] )
|
|
|
|
{
|
|
|
|
$sql = "SELECT post_id
|
|
|
|
FROM " . POSTS_TABLE . "
|
|
|
|
WHERE poster_id = " . $userdata['user_id'];;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
header("Location: login.$phpEx?redirect=search&search_id=egosearch");
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$show_results = "topics";
|
|
|
|
$sort_by = 0;
|
|
|
|
$sort_dir = "DESC";
|
2001-12-14 02:41:33 +00:00
|
|
|
}
|
2002-02-25 01:00:48 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$search_author = str_replace("*", "%", trim($search_author));
|
|
|
|
|
|
|
|
$sql = "SELECT user_id
|
|
|
|
FROM " . USERS_TABLE . "
|
|
|
|
WHERE username LIKE '" . str_replace("\'", "''", $search_author) . "'";
|
|
|
|
if ( !($result = $db->sql_query($sql)) )
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain list of matching users (searching for: $search_author)", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
2001-12-20 01:25:00 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$matching_userids = '';
|
|
|
|
if ( $row = $db->sql_fetchrow($result) )
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
$matching_userids .= ( ( $matching_userids != '' ) ? ', ' : '' ) . $row['user_id'];
|
|
|
|
}
|
|
|
|
while( $row = $db->sql_fetchrow($result) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message_die(GENERAL_MESSAGE, $lang['No_search_match']);
|
|
|
|
}
|
2001-12-20 01:25:00 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$sql = "SELECT post_id
|
|
|
|
FROM " . POSTS_TABLE . "
|
|
|
|
WHERE poster_id IN ($matching_userids)";
|
2001-12-15 16:15:45 +00:00
|
|
|
}
|
2002-02-25 01:00:48 +00:00
|
|
|
|
|
|
|
if ( !($result = $db->sql_query($sql)) )
|
2001-12-15 16:15:45 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain matched posts list", "", __LINE__, __FILE__, $sql);
|
2001-12-15 16:15:45 +00:00
|
|
|
}
|
2002-02-25 01:00:48 +00:00
|
|
|
|
|
|
|
$search_ids = array();
|
2001-12-15 16:15:45 +00:00
|
|
|
while( $row = $db->sql_fetchrow($result) )
|
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$search_ids[] = $row['post_id'];
|
|
|
|
}
|
|
|
|
$db->sql_freeresult($result);
|
2001-12-05 00:20:56 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$total_match_count = count($search_ids);
|
2001-12-20 01:25:00 +00:00
|
|
|
|
2001-12-05 00:20:56 +00:00
|
|
|
}
|
2002-02-25 01:00:48 +00:00
|
|
|
else if ( $search_keywords != '' )
|
2001-12-05 00:20:56 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$stopword_array = @file($phpbb_root_path . "language/lang_" . $board_config['default_lang'] . "/search_stopwords.txt");
|
|
|
|
$synonym_array = @file($phpbb_root_path . "language/lang_" . $board_config['default_lang'] . "/search_synonyms.txt");
|
|
|
|
|
|
|
|
$split_search = array();
|
|
|
|
$cleaned_search = clean_words("search", stripslashes($search_keywords), $stopword_array, $synonym_array);
|
|
|
|
$split_search = split_words($cleaned_search, "search");
|
2001-09-17 00:42:17 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$search_msg_only = ( !$search_fields ) ? "AND m.title_match = 0" : "";
|
2002-01-12 17:00:32 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$word_count = 0;
|
|
|
|
$current_match_type = 'and';
|
2002-01-14 14:16:54 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$word_match = array();
|
|
|
|
$result_list = array();
|
2001-09-17 00:42:17 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
for($i = 0; $i < count($split_search); $i++)
|
2001-11-09 13:00:04 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
switch ( $split_search[$i] )
|
2001-09-26 01:36:52 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
case 'and':
|
|
|
|
$current_match_type = 'and';
|
|
|
|
break;
|
2001-11-09 13:00:04 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
case 'or':
|
|
|
|
$current_match_type = 'or';
|
|
|
|
break;
|
2001-11-22 01:00:14 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
case 'not':
|
|
|
|
$current_match_type = 'not';
|
|
|
|
break;
|
2001-11-22 01:00:14 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
default:
|
|
|
|
if( !empty($search_terms) )
|
|
|
|
{
|
|
|
|
$current_match_type = "and";
|
|
|
|
}
|
2001-11-20 23:45:27 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$match_word = str_replace("*", "%", $split_search[$i]);
|
2001-11-20 23:45:27 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$sql = "SELECT m.post_id
|
|
|
|
FROM " . SEARCH_WORD_TABLE . " w, " . SEARCH_MATCH_TABLE . " m
|
|
|
|
WHERE w.word_text LIKE '$match_word'
|
|
|
|
AND m.word_id = w.word_id
|
|
|
|
AND w.word_common <> 1
|
|
|
|
$search_msg_only";
|
|
|
|
if ( !($result = $db->sql_query($sql)) )
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain matched posts list", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
2001-11-20 23:45:27 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$row = array();
|
|
|
|
while( $temp_row = $db->sql_fetchrow($result) )
|
2001-11-22 01:00:14 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$row[$temp_row['post_id']] = 1;
|
|
|
|
|
|
|
|
if ( !$word_count )
|
|
|
|
{
|
|
|
|
$result_list[$temp_row['post_id']] = 1;
|
|
|
|
}
|
|
|
|
else if ( $current_match_type == "or" )
|
|
|
|
{
|
|
|
|
$result_list[$temp_row['post_id']] = 1;
|
|
|
|
}
|
|
|
|
else if ( $current_match_type == "not" )
|
|
|
|
{
|
|
|
|
$result_list[$temp_row['post_id']] = 0;
|
|
|
|
}
|
2001-11-22 01:00:14 +00:00
|
|
|
}
|
2002-01-14 14:16:54 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( $current_match_type == "and" && $word_count )
|
|
|
|
{
|
|
|
|
@reset($result_list);
|
|
|
|
while( list($post_id, $match_count) = @each($result_list) )
|
|
|
|
{
|
|
|
|
if ( !$row[$post_id] )
|
|
|
|
{
|
|
|
|
$result_list[$post_id] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-01-14 14:16:54 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$word_count++;
|
2002-01-14 14:16:54 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$db->sql_freeresult($result);
|
|
|
|
}
|
2001-11-09 13:00:04 +00:00
|
|
|
}
|
2002-02-25 01:00:48 +00:00
|
|
|
|
|
|
|
@reset($result_list);
|
|
|
|
|
|
|
|
$search_ids = array();
|
|
|
|
while( list($post_id, $matches) = each($result_list) )
|
|
|
|
{
|
|
|
|
if ( $matches )
|
|
|
|
{
|
|
|
|
$search_ids[] = $post_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unset($result_list);
|
|
|
|
$total_match_count = count($search_ids);
|
2001-11-09 13:00:04 +00:00
|
|
|
}
|
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
//
|
|
|
|
// If user is logged in then we'll check to see which (if any) private
|
|
|
|
// forums they are allowed to view and include them in the search.
|
|
|
|
//
|
|
|
|
// If not logged in we explicitly prevent searching of private forums
|
|
|
|
//
|
|
|
|
$auth_sql = "";
|
|
|
|
if ( $search_forum != -1 )
|
|
|
|
{
|
|
|
|
$is_auth = auth(AUTH_READ, $search_forum, $userdata);
|
2001-11-22 01:00:14 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( !$is_auth['auth_read'] )
|
|
|
|
{
|
|
|
|
message_die(GENERAL_MESSAGE, $lang['No_searchable_forums']);
|
|
|
|
}
|
|
|
|
|
|
|
|
$auth_sql = "f.forum_id = $search_forum";
|
|
|
|
}
|
|
|
|
else
|
2001-11-09 13:00:04 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);
|
|
|
|
|
|
|
|
if ( $search_cat != -1 )
|
2001-11-09 13:00:04 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$auth_sql = "f.cat_id = $search_cat";
|
2001-11-09 13:00:04 +00:00
|
|
|
}
|
2001-09-17 00:42:17 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$ignore_forum_sql = "";
|
|
|
|
while( list($key, $value) = each($is_auth_ary) )
|
|
|
|
{
|
|
|
|
if ( !$value['auth_read'] )
|
|
|
|
{
|
|
|
|
$ignore_forum_sql .= ( ( $ignore_forum_sql != "" ) ? ", " : "" ) . $key;
|
|
|
|
}
|
|
|
|
}
|
2001-12-05 00:20:56 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( $ignore_forum_sql != "" )
|
|
|
|
{
|
|
|
|
$auth_sql .= ( $auth_sql != "" ) ? " AND f.forum_id NOT IN ($ignore_forum_sql) " : "f.forum_id NOT IN ($ignore_forum_sql) ";
|
|
|
|
}
|
2001-11-14 06:39:17 +00:00
|
|
|
}
|
2002-01-25 00:48:46 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
//
|
|
|
|
// Author name search
|
|
|
|
//
|
|
|
|
if ( $search_author != "" )
|
2001-12-05 00:20:56 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$search_author = str_replace("*", "%", trim(str_replace("\'", "''", $search_author)));
|
2001-12-05 00:20:56 +00:00
|
|
|
}
|
2001-11-09 13:00:04 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( $total_match_count )
|
2001-12-05 00:20:56 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( $show_results == "topics" )
|
2001-11-09 13:00:04 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$where_sql = "";
|
|
|
|
|
|
|
|
if ( $search_time )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$where_sql .= ( $search_author == "" && $auth_sql == "" ) ? " AND post_time >= $search_time " : " AND p.post_time >= $search_time ";
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( $search_author == "" && $auth_sql == "" )
|
|
|
|
{
|
|
|
|
$sql = "SELECT topic_id
|
|
|
|
FROM " . POSTS_TABLE . "
|
|
|
|
WHERE post_id IN (" . implode(", ", $search_ids) . ")
|
|
|
|
$where_sql
|
|
|
|
GROUP BY topic_id";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$from_sql = POSTS_TABLE . " p";
|
2001-11-09 13:00:04 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( $search_author != '' )
|
|
|
|
{
|
|
|
|
$from_sql .= ", " . USERS_TABLE . " u";
|
|
|
|
$where_sql .= " AND u.user_id = p.poster_id AND u.username LIKE '$search_author' ";
|
|
|
|
}
|
2002-01-25 00:48:46 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( $auth_sql != '' )
|
|
|
|
{
|
|
|
|
$from_sql .= ", " . FORUMS_TABLE . " f";
|
|
|
|
$where_sql .= " AND f.forum_id = p.forum_id AND $auth_sql";
|
|
|
|
}
|
2002-01-25 00:48:46 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$sql = "SELECT p.topic_id
|
|
|
|
FROM $from_sql
|
|
|
|
WHERE p.post_id IN (" . implode(", ", $search_ids) . ")
|
|
|
|
$where_sql
|
|
|
|
GROUP BY p.topic_id";
|
|
|
|
}
|
2002-01-25 00:48:46 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( !($result = $db->sql_query($sql)) )
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain topic ids", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
|
|
|
|
$search_ids = array();
|
|
|
|
while( $row = $db->sql_fetchrow($result) )
|
|
|
|
{
|
|
|
|
$search_ids[] = $row['topic_id'];
|
|
|
|
}
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
|
|
|
$total_match_count = sizeof($search_ids);
|
|
|
|
|
2002-01-25 00:48:46 +00:00
|
|
|
}
|
2002-02-25 01:00:48 +00:00
|
|
|
else if ( $search_author != '' || $search_time || $auth_sql != '' )
|
2002-01-25 00:48:46 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$where_sql = ( $search_author == "" && $auth_sql == "" ) ? "post_id IN (" . implode(", ", $search_ids) . ")" : "p.post_id IN (" . implode(", ", $search_ids) . ")";
|
|
|
|
$from_sql = ( $search_author == "" && $auth_sql == "" ) ? POSTS_TABLE : POSTS_TABLE . " p";
|
2002-01-25 00:48:46 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( $search_time )
|
2002-01-25 00:48:46 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$where_sql .= ( $search_author == "" && $auth_sql == "" ) ? " AND post_time >= $search_time " : " AND p.post_time >= $search_time";
|
2002-01-25 00:48:46 +00:00
|
|
|
}
|
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( $auth_sql != '' )
|
2002-01-25 00:48:46 +00:00
|
|
|
{
|
|
|
|
$from_sql .= ", " . FORUMS_TABLE . " f";
|
|
|
|
$where_sql .= " AND f.forum_id = p.forum_id AND $auth_sql";
|
|
|
|
}
|
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( $search_author != '' )
|
|
|
|
{
|
|
|
|
$from_sql .= ", " . USERS_TABLE . " u";
|
|
|
|
$where_sql .= " AND u.user_id = p.poster_id AND u.username LIKE '$search_author'";
|
|
|
|
}
|
2002-01-25 00:48:46 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$sql = "SELECT p.post_id
|
|
|
|
FROM $from_sql
|
|
|
|
WHERE $where_sql";
|
|
|
|
if ( !($result = $db->sql_query($sql)) )
|
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain post ids", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
2002-01-25 00:48:46 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$search_ids = array();
|
|
|
|
while( $row = $db->sql_fetchrow($result) )
|
|
|
|
{
|
|
|
|
$search_ids[] = $row['post_id'];
|
|
|
|
}
|
2002-01-25 00:48:46 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$db->sql_freeresult($result);
|
2002-01-25 00:48:46 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$total_match_count = count($search_ids);
|
|
|
|
}
|
2001-12-05 00:20:56 +00:00
|
|
|
}
|
2002-02-25 01:00:48 +00:00
|
|
|
else if ( $search_id == 'unanswered' )
|
2002-01-25 00:48:46 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( $auth_sql != "" )
|
2002-01-25 00:48:46 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$sql = "SELECT t.topic_id, f.forum_id
|
|
|
|
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
|
|
|
|
WHERE t.topic_replies = 0
|
|
|
|
AND t.forum_id = f.forum_id
|
|
|
|
AND t.topic_moved_id = 0
|
|
|
|
AND $auth_sql";
|
2002-01-25 00:48:46 +00:00
|
|
|
}
|
2002-02-25 01:00:48 +00:00
|
|
|
else
|
2002-01-25 00:48:46 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$sql = "SELECT topic_id
|
|
|
|
FROM " . TOPICS_TABLE . "
|
|
|
|
WHERE topic_replies = 0
|
|
|
|
AND topic_moved_id = 0";
|
2002-01-25 00:48:46 +00:00
|
|
|
}
|
2002-02-25 01:00:48 +00:00
|
|
|
|
|
|
|
if ( !($result = $db->sql_query($sql)) )
|
2002-01-25 00:48:46 +00:00
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain post ids", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
|
|
|
|
$search_ids = array();
|
|
|
|
while( $row = $db->sql_fetchrow($result) )
|
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$search_ids[] = $row['topic_id'];
|
2002-01-25 00:48:46 +00:00
|
|
|
}
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
|
|
|
$total_match_count = count($search_ids);
|
2002-02-25 01:00:48 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Basic requirements
|
|
|
|
//
|
|
|
|
$show_results = "topics";
|
|
|
|
$sort_by = 0;
|
|
|
|
$sort_dir = "DESC";
|
2002-02-03 18:54:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
message_die(GENERAL_MESSAGE, $lang['No_search_match']);
|
2002-01-25 00:48:46 +00:00
|
|
|
}
|
|
|
|
|
2001-12-05 00:20:56 +00:00
|
|
|
//
|
2002-02-25 01:00:48 +00:00
|
|
|
// Finish building query (for all combinations)
|
|
|
|
// and run it ...
|
2001-12-05 00:20:56 +00:00
|
|
|
//
|
|
|
|
$sql = "SELECT session_id
|
|
|
|
FROM " . SESSIONS_TABLE;
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( $result = $db->sql_query($sql) )
|
2001-12-05 00:20:56 +00:00
|
|
|
{
|
2002-01-25 00:48:46 +00:00
|
|
|
$delete_search_ids = array();
|
2001-12-05 00:20:56 +00:00
|
|
|
while( $row = $db->sql_fetchrow($result) )
|
2001-11-09 13:00:04 +00:00
|
|
|
{
|
2002-01-25 00:48:46 +00:00
|
|
|
$delete_search_ids[] = "'" . $row['session_id'] . "'";
|
2001-12-05 00:20:56 +00:00
|
|
|
}
|
2001-09-17 00:42:17 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( count($delete_search_ids) )
|
2001-12-05 00:20:56 +00:00
|
|
|
{
|
|
|
|
$sql = "DELETE FROM " . SEARCH_TABLE . "
|
2002-01-25 00:48:46 +00:00
|
|
|
WHERE session_id NOT IN (" . implode(", ", $delete_search_ids) . ")";
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( !$result = $db->sql_query($sql) )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
2001-12-05 00:20:56 +00:00
|
|
|
message_die(GENERAL_ERROR, "Couldn't delete old search id sessions", "", __LINE__, __FILE__, $sql);
|
2001-11-09 13:00:04 +00:00
|
|
|
}
|
|
|
|
}
|
2001-12-05 00:20:56 +00:00
|
|
|
}
|
2001-09-17 00:42:17 +00:00
|
|
|
|
2001-12-05 00:20:56 +00:00
|
|
|
//
|
|
|
|
// Store new result data
|
|
|
|
//
|
2002-02-25 01:00:48 +00:00
|
|
|
$search_results = implode(", ", $search_ids);
|
|
|
|
$per_page = ( $show_results == "posts" ) ? $board_config['posts_per_page'] : $board_config['topics_per_page'];
|
2002-01-25 00:48:46 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
//
|
|
|
|
// Combine both results and search data (apart from original query)
|
|
|
|
// so we can serialize it and place it in the DB
|
|
|
|
//
|
|
|
|
$store_search_data = array();
|
|
|
|
for($i = 0; $i < count($store_vars); $i++)
|
|
|
|
{
|
|
|
|
$store_search_data[$store_vars[$i]] = $$store_vars[$i];
|
|
|
|
}
|
2002-01-25 00:48:46 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$result_array = serialize($store_search_data);
|
|
|
|
unset($store_search_data);
|
2001-12-05 00:20:56 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
mt_srand ((double) microtime() * 1000000);
|
|
|
|
$search_id = mt_rand();
|
2001-12-05 00:20:56 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$sql = "UPDATE " . SEARCH_TABLE . "
|
|
|
|
SET search_id = $search_id, search_array = '$result_array'
|
|
|
|
WHERE session_id = '" . $userdata['session_id'] . "'";
|
|
|
|
if ( !($result = $db->sql_query($sql)) || !$db->sql_affectedrows() )
|
|
|
|
{
|
|
|
|
$sql = "INSERT INTO " . SEARCH_TABLE . " (search_id, session_id, search_array)
|
|
|
|
VALUES($search_id, '" . $userdata['session_id'] . "', '" . str_replace("\'", "''", $result_array) . "')";
|
|
|
|
if ( !($result = $db->sql_query($sql)) )
|
2001-11-09 13:00:04 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
message_die(GENERAL_ERROR, "Couldn't insert search results", "", __LINE__, __FILE__, $sql);
|
2001-11-09 13:00:04 +00:00
|
|
|
}
|
|
|
|
}
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
2002-02-25 01:00:48 +00:00
|
|
|
else
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
|
|
|
$sql = "SELECT search_array
|
2001-09-26 01:36:52 +00:00
|
|
|
FROM " . SEARCH_TABLE . "
|
2002-01-25 00:48:46 +00:00
|
|
|
WHERE search_id = $search_id
|
2001-09-17 00:42:17 +00:00
|
|
|
AND session_id = '". $userdata['session_id'] . "'";
|
2002-02-25 01:00:48 +00:00
|
|
|
if( !($result = $db->sql_query($sql)) )
|
2001-05-31 11:47:43 +00:00
|
|
|
{
|
2001-09-17 00:42:17 +00:00
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain search results", "", __LINE__, __FILE__, $sql);
|
2001-05-31 11:47:43 +00:00
|
|
|
}
|
2001-05-29 14:25:09 +00:00
|
|
|
|
2002-01-25 00:48:46 +00:00
|
|
|
if( $row = $db->sql_fetchrow($result) )
|
2001-05-29 14:25:09 +00:00
|
|
|
{
|
2001-11-09 13:00:04 +00:00
|
|
|
$search_data = unserialize($row['search_array']);
|
2002-02-25 01:00:48 +00:00
|
|
|
for($i = 0; $i < count($store_vars); $i++)
|
|
|
|
{
|
|
|
|
$$store_vars[$i] = $search_data[$store_vars[$i]];
|
|
|
|
}
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
//
|
|
|
|
// Look up data ...
|
|
|
|
//
|
|
|
|
if ( $search_results != "" )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( $show_results == "posts" )
|
2002-01-25 00:48:46 +00:00
|
|
|
{
|
|
|
|
$sql = "SELECT pt.post_text, pt.bbcode_uid, pt.post_subject, p.*, f.forum_id, f.forum_name, t.*, u.username, u.user_id, u.user_sig, u.user_sig_bbcode_uid
|
|
|
|
FROM " . FORUMS_TABLE . " f, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TEXT_TABLE . " pt
|
|
|
|
WHERE p.post_id IN ($search_results)
|
|
|
|
AND pt.post_id = p.post_id
|
|
|
|
AND f.forum_id = p.forum_id
|
|
|
|
AND p.topic_id = t.topic_id
|
|
|
|
AND p.poster_id = u.user_id";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$sql = "SELECT t.*, f.forum_id, f.forum_name, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username
|
|
|
|
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f, " . USERS_TABLE . " u, " . USERS_TABLE . " u2, " . POSTS_TABLE . " p
|
|
|
|
WHERE t.topic_id IN ($search_results)
|
|
|
|
AND f.forum_id = t.forum_id
|
|
|
|
AND u.user_id = t.topic_poster
|
|
|
|
AND p.post_id = t.topic_last_post_id
|
|
|
|
AND p.poster_id = u2.user_id";
|
|
|
|
}
|
|
|
|
|
|
|
|
$per_page = ( $show_results == "posts" ) ? $board_config['posts_per_page'] : $board_config['topics_per_page'];
|
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$sql .= " ORDER BY " . $sort_by_sql[$sort_by] . " $sort_dir LIMIT $start, " . $per_page;
|
2001-09-17 00:42:17 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( !$result = $db->sql_query($sql) )
|
2002-01-25 00:48:46 +00:00
|
|
|
{
|
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain search results", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
|
|
|
|
$searchset = array();
|
|
|
|
while( $row = $db->sql_fetchrow($result) )
|
|
|
|
{
|
|
|
|
$searchset[] = $row;
|
|
|
|
}
|
|
|
|
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
//
|
|
|
|
// Define censored word matches
|
|
|
|
//
|
|
|
|
$orig_word = array();
|
|
|
|
$replacement_word = array();
|
|
|
|
obtain_word_list($orig_word, $replacement_word);
|
|
|
|
|
2002-01-25 00:48:46 +00:00
|
|
|
//
|
|
|
|
// Output header
|
|
|
|
//
|
|
|
|
$page_title = $lang['Search'];
|
|
|
|
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
|
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
if ( $show_results == "posts" )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
|
|
|
$template->set_filenames(array(
|
|
|
|
"body" => "search_results_posts.tpl",
|
|
|
|
"jumpbox" => "jumpbox.tpl")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$template->set_filenames(array(
|
|
|
|
"body" => "search_results_topics.tpl",
|
|
|
|
"jumpbox" => "jumpbox.tpl")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$jumpbox = make_jumpbox();
|
|
|
|
$template->assign_vars(array(
|
|
|
|
"L_GO" => $lang['Go'],
|
|
|
|
"L_JUMP_TO" => $lang['Jump_to'],
|
|
|
|
"L_SELECT_FORUM" => $lang['Select_forum'],
|
|
|
|
|
|
|
|
"S_JUMPBOX_LIST" => $jumpbox,
|
|
|
|
"S_JUMPBOX_ACTION" => append_sid("viewforum.$phpEx"))
|
|
|
|
);
|
|
|
|
$template->assign_var_from_handle("JUMPBOX", "jumpbox");
|
|
|
|
|
2001-11-19 14:12:09 +00:00
|
|
|
$l_search_matches = ( $total_match_count == 1 ) ? sprintf($lang['Found_search_match'], $total_match_count) : sprintf($lang['Found_search_matches'], $total_match_count);
|
2001-09-17 00:42:17 +00:00
|
|
|
|
2001-11-19 14:12:09 +00:00
|
|
|
$template->assign_vars(array(
|
|
|
|
"L_SEARCH_MATCHES" => $l_search_matches,
|
2001-09-17 00:42:17 +00:00
|
|
|
"L_TOPIC" => $lang['Topic'])
|
|
|
|
);
|
|
|
|
|
2001-11-19 17:54:27 +00:00
|
|
|
$highlight_active = "";
|
2001-12-05 00:20:56 +00:00
|
|
|
$search_string = array();
|
|
|
|
$replace_string = array();
|
2001-11-09 13:00:04 +00:00
|
|
|
for($j = 0; $j < count($split_search); $j++ )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
2001-11-09 13:00:04 +00:00
|
|
|
$split_word = $split_search[$j];
|
|
|
|
|
|
|
|
if( $split_word != "and" && $split_word != "or" && $split_word != "not" )
|
|
|
|
{
|
2001-11-19 17:54:27 +00:00
|
|
|
$highlight_active .= " " . $split_word;
|
2001-11-09 13:00:04 +00:00
|
|
|
|
2002-01-25 00:48:46 +00:00
|
|
|
$search_string[] = "#\b(" . str_replace("\*", ".*?", phpbb_preg_quote($split_word, "#")) . ")(?!.*?<\/a>)(?!.*?\[/url\])(?!.*?<\/span>)\b#i";
|
|
|
|
$replace_string[] = '<span style="color:#' . $theme['fontcolor3'] . '"><b>\\1</b></span>';
|
2001-11-09 13:00:04 +00:00
|
|
|
|
|
|
|
for ($k = 0; $k < count($synonym_array); $k++)
|
|
|
|
{
|
|
|
|
list($replace_synonym, $match_synonym) = split(" ", trim(strtolower($synonym_array[$k])));
|
|
|
|
|
|
|
|
if( $replace_synonym == $split_word )
|
|
|
|
{
|
2002-01-25 00:48:46 +00:00
|
|
|
$search_string[] = "#\b(" . str_replace("\*", ".*?", phpbb_preg_quote($replace_synonym, "#")) . ")(?!.*?<\/a>)(?!.*?\[/url\])(?!.*?<\/span>)\b#i";
|
|
|
|
$replace_string[] = '<span style="color:#' . $theme['fontcolor3'] . '"><b>\\1</b></span>';
|
2001-11-09 13:00:04 +00:00
|
|
|
|
2001-11-19 17:54:27 +00:00
|
|
|
$highlight_active .= " " . $match_synonym;
|
2001-11-09 13:00:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
|
|
|
|
2001-11-19 17:54:27 +00:00
|
|
|
$highlight_active = urlencode(trim($highlight_active));
|
2001-11-09 13:00:04 +00:00
|
|
|
|
2002-01-12 17:00:32 +00:00
|
|
|
$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array();
|
|
|
|
$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array();
|
|
|
|
|
2002-01-25 00:48:46 +00:00
|
|
|
for($i = 0; $i < count($searchset); $i++)
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
|
|
|
$forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $searchset[$i]['forum_id']);
|
2001-11-19 17:54:27 +00:00
|
|
|
$topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $searchset[$i]['topic_id'] . "&highlight=$highlight_active");
|
|
|
|
$post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $searchset[$i]['post_id'] . "&highlight=$highlight_active#" . $searchset[$i]['post_id']);
|
2001-05-29 14:25:09 +00:00
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
$post_date = create_date($board_config['default_dateformat'], $searchset[$i]['post_time'], $board_config['board_timezone']);
|
|
|
|
|
|
|
|
$message = $searchset[$i]['post_text'];
|
2001-11-17 17:40:19 +00:00
|
|
|
$topic_title = $searchset[$i]['topic_title'];
|
2001-09-17 00:42:17 +00:00
|
|
|
|
2002-01-12 17:00:32 +00:00
|
|
|
$forum_id = $searchset[$i]['forum_id'];
|
|
|
|
$topic_id = $searchset[$i]['topic_id'];
|
|
|
|
|
2002-01-25 00:48:46 +00:00
|
|
|
if( $show_results == "posts" )
|
2001-05-29 14:25:09 +00:00
|
|
|
{
|
2001-12-20 01:25:00 +00:00
|
|
|
if( isset($return_chars) )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
2001-11-23 01:04:31 +00:00
|
|
|
$bbcode_uid = $searchset[$i]['bbcode_uid'];
|
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
//
|
|
|
|
// If the board has HTML off but the post has HTML
|
|
|
|
// on then we process it, else leave it alone
|
|
|
|
//
|
|
|
|
if( $return_chars != -1 )
|
|
|
|
{
|
2001-11-23 01:04:31 +00:00
|
|
|
$message = (strlen($message) > $return_chars) ? substr($message, 0, $return_chars) . " ..." : $message;
|
|
|
|
$message = strip_tags($message);
|
|
|
|
$message = preg_replace("/\[.*?:$bbcode_uid:?.*?\]/si", "", $message);
|
2001-12-05 00:20:56 +00:00
|
|
|
|
|
|
|
if( count($search_string) )
|
|
|
|
{
|
|
|
|
$message = preg_replace($search_string, $replace_string, $message);
|
|
|
|
}
|
|
|
|
|
2001-11-23 01:04:31 +00:00
|
|
|
$message = preg_replace("/\[url\]|\[\/url\]/si", "", $message);
|
2001-12-05 00:20:56 +00:00
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !$board_config['allow_html'] )
|
|
|
|
{
|
2001-11-09 13:00:04 +00:00
|
|
|
if( $postrow[$i]['enable_html'] )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
|
|
|
$message = preg_replace("#(<)([\/]?.*?)(>)#is", "<\\2>", $message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-09 13:00:04 +00:00
|
|
|
if( $bbcode_uid != "" )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
2001-11-09 13:00:04 +00:00
|
|
|
$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace("/\:[0-9a-z\:]+\]/si", "]", $message);
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
|
|
|
|
2001-12-11 09:13:04 +00:00
|
|
|
$message = make_clickable($message);
|
2001-12-14 02:41:33 +00:00
|
|
|
|
|
|
|
if( count($search_string) )
|
|
|
|
{
|
|
|
|
$message = preg_replace($search_string, $replace_string, $message);
|
|
|
|
}
|
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( count($orig_word) )
|
|
|
|
{
|
2001-11-17 17:40:19 +00:00
|
|
|
$topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
|
2001-09-17 00:42:17 +00:00
|
|
|
$post_subject = ( $searchset[$i]['post_subject'] != "" ) ? preg_replace($orig_word, $replacement_word, $searchset[$i]['post_subject']) : $topic_title;
|
2001-05-30 12:33:03 +00:00
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
$message = preg_replace($orig_word, $replacement_word, $message);
|
|
|
|
}
|
2001-11-17 17:42:46 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$post_subject = ( $searchset[$i]['post_subject'] != "" ) ? $searchset[$i]['post_subject'] : $topic_title;
|
|
|
|
}
|
2001-09-17 00:42:17 +00:00
|
|
|
|
|
|
|
if($board_config['allow_smilies'] && $searchset[$i]['enable_smilies'])
|
|
|
|
{
|
|
|
|
$message = smilies_pass($message);
|
|
|
|
}
|
|
|
|
|
|
|
|
$message = str_replace("\n", "<br />", $message);
|
|
|
|
|
|
|
|
}
|
2001-12-05 00:20:56 +00:00
|
|
|
|
2002-01-25 02:34:49 +00:00
|
|
|
$poster = ( $searchset[$i]['user_id'] != ANONYMOUS ) ? "<a href=\"" . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $searchset[$i]['user_id']) . "\">" : "";
|
|
|
|
$poster .= ( $searchset[$i]['user_id'] != ANONYMOUS ) ? $searchset[$i]['username'] : ( ( $searchset[$i]['post_username'] != "" ) ? $searchset[$i]['post_username'] : $lang['Guest'] );
|
|
|
|
$poster .= ( $searchset[$i]['user_id'] != ANONYMOUS ) ? "</a>" : "";
|
|
|
|
|
2002-01-12 17:00:32 +00:00
|
|
|
if( $userdata['session_logged_in'] && $searchset[$i]['post_time'] > $userdata['user_lastvisit'] )
|
|
|
|
{
|
|
|
|
if( !empty($tracking_topics['' . $topic_id . '']) && !empty($tracking_forums['' . $forum_id . '']) )
|
|
|
|
{
|
|
|
|
$topic_last_read = ( $tracking_topics['' . $topic_id . ''] > $tracking_forums['' . $forum_id . ''] ) ? $tracking_topics['' . $topic_id . ''] : $tracking_forums['' . $forum_id . ''];
|
|
|
|
}
|
|
|
|
else if( !empty($tracking_topics['' . $topic_id . '']) || !empty($tracking_forums['' . $forum_id . '']) )
|
|
|
|
{
|
|
|
|
$topic_last_read = ( !empty($tracking_topics['' . $topic_id . '']) ) ? $tracking_topics['' . $topic_id . ''] : $tracking_forums['' . $forum_id . ''];
|
|
|
|
}
|
|
|
|
|
|
|
|
if( $searchset[$i]['post_time'] > $topic_last_read )
|
|
|
|
{
|
|
|
|
$mini_post_img = '<img src="' . $images['icon_minipost_new'] . '" alt="' . $lang['New_post'] . '" title="' . $lang['New_post'] . '" border="0" />';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$mini_post_img = '<img src="' . $images['icon_minipost'] . '" alt="' . $lang['Post'] . '" title="' . $lang['Post'] . '" border="0" />';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$mini_post_img = '<img src="' . $images['icon_minipost'] . '" alt="' . $lang['Post'] . '" title="' . $lang['Post'] . '" border="0" />';
|
|
|
|
}
|
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
$template->assign_block_vars("searchresults", array(
|
|
|
|
"TOPIC_TITLE" => $topic_title,
|
|
|
|
"FORUM_NAME" => $searchset[$i]['forum_name'],
|
|
|
|
"POST_SUBJECT" => $post_subject,
|
|
|
|
"POST_DATE" => $post_date,
|
2002-01-25 02:34:49 +00:00
|
|
|
"POSTER_NAME" => $poster,
|
2001-09-17 00:42:17 +00:00
|
|
|
"TOPIC_REPLIES" => $searchset[$i]['topic_replies'],
|
|
|
|
"TOPIC_VIEWS" => $searchset[$i]['topic_views'],
|
|
|
|
"MESSAGE" => $message,
|
|
|
|
|
2002-01-12 17:00:32 +00:00
|
|
|
"MINI_POST_IMG" => $mini_post_img,
|
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
"U_POST" => $post_url,
|
|
|
|
"U_TOPIC" => $topic_url,
|
2002-01-25 02:34:49 +00:00
|
|
|
"U_FORUM" => $forum_url)
|
2001-05-30 12:33:03 +00:00
|
|
|
);
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$message = "";
|
2001-05-29 14:25:09 +00:00
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
if( count($orig_word) )
|
2001-05-29 14:25:09 +00:00
|
|
|
{
|
2001-09-17 00:42:17 +00:00
|
|
|
$topic_title = preg_replace($orig_word, $replacement_word, $searchset[$i]['topic_title']);
|
2001-05-29 14:25:09 +00:00
|
|
|
}
|
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
$topic_type = $searchset[$i]['topic_type'];
|
|
|
|
|
|
|
|
if($topic_type == POST_ANNOUNCE)
|
2001-05-29 14:25:09 +00:00
|
|
|
{
|
2001-09-17 00:42:17 +00:00
|
|
|
$topic_type = $lang['Topic_Announcement'] . " ";
|
|
|
|
}
|
|
|
|
else if($topic_type == POST_STICKY)
|
|
|
|
{
|
|
|
|
$topic_type = $lang['Topic_Sticky'] . " ";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$topic_type = "";
|
|
|
|
}
|
2001-05-29 14:25:09 +00:00
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
if( $searchset[$i]['topic_vote'] )
|
|
|
|
{
|
|
|
|
$topic_type .= $lang['Topic_Poll'] . " ";
|
|
|
|
}
|
|
|
|
|
2002-01-12 17:00:32 +00:00
|
|
|
$views = $searchset[$i]['topic_views'];
|
2001-09-17 00:42:17 +00:00
|
|
|
$replies = $searchset[$i]['topic_replies'];
|
|
|
|
|
2001-11-09 13:00:04 +00:00
|
|
|
if( $replies > $board_config['topics_per_page'] )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$goto_page = '[ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['Goto_page'] . '" title="' . $lang['Goto_page'] . '" />' . $lang['Goto_page'] . ': ';
|
2001-05-29 14:25:09 +00:00
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
$times = 1;
|
2001-12-20 00:39:22 +00:00
|
|
|
for($j = 0; $j < $replies + 1; $j += $board_config['posts_per_page'])
|
2001-05-29 14:25:09 +00:00
|
|
|
{
|
2001-11-19 17:54:27 +00:00
|
|
|
$base_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_id . "&start=$j&highlight=$highlight_active");
|
2001-11-09 13:00:04 +00:00
|
|
|
|
|
|
|
if( $times > 4 )
|
2001-05-29 14:25:09 +00:00
|
|
|
{
|
2001-11-09 13:00:04 +00:00
|
|
|
if( $j + $board_config['topics_per_page'] >= $replies + 1 )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$goto_page .= ' ... <a href="' . $base_url . '">' . $times . '</a>';
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
2001-05-29 14:25:09 +00:00
|
|
|
}
|
2001-09-17 00:42:17 +00:00
|
|
|
else
|
|
|
|
{
|
2001-11-09 13:00:04 +00:00
|
|
|
if( $times != 1 )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
|
|
|
$goto_page .= ", ";
|
|
|
|
}
|
2001-11-09 13:00:04 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
$goto_page .= '<a href="' . $base_url . '">' . $times . '</a>';
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
2001-11-09 13:00:04 +00:00
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
$times++;
|
|
|
|
}
|
2002-02-25 01:00:48 +00:00
|
|
|
$goto_page .= ' ]';
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$goto_page = '';
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
2001-08-30 22:20:23 +00:00
|
|
|
|
2001-11-09 13:00:04 +00:00
|
|
|
if( $searchset[$i]['topic_status'] == TOPIC_MOVED )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
|
|
|
$topic_type = $lang['Topic_Moved'] . " ";
|
|
|
|
$topic_id = $searchset[$i]['topic_moved_id'];
|
2001-11-19 14:12:09 +00:00
|
|
|
|
|
|
|
$folder_image = "<img src=\"" . $images['folder'] . "\" alt=\"" . $lang['No_new_posts'] . "\" />";
|
|
|
|
$newest_post_img = "";
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-11-09 13:00:04 +00:00
|
|
|
if( $searchset[$i]['topic_status'] == TOPIC_LOCKED )
|
|
|
|
{
|
|
|
|
$folder = $images['folder_locked'];
|
|
|
|
$folder_new = $images['folder_locked_new'];
|
|
|
|
}
|
|
|
|
else if( $searchset[$i]['topic_type'] == POST_ANNOUNCE )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
|
|
|
$folder = $images['folder_announce'];
|
|
|
|
$folder_new = $images['folder_announce_new'];
|
|
|
|
}
|
2001-09-26 01:36:52 +00:00
|
|
|
else if( $searchset[$i]['topic_type'] == POST_STICKY )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
|
|
|
$folder = $images['folder_sticky'];
|
|
|
|
$folder_new = $images['folder_sticky_new'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-26 01:36:52 +00:00
|
|
|
if( $replies >= $board_config['hot_threshold'] )
|
2001-05-31 11:47:43 +00:00
|
|
|
{
|
2001-09-17 00:42:17 +00:00
|
|
|
$folder = $images['folder_hot'];
|
2001-11-09 13:00:04 +00:00
|
|
|
$folder_new = $images['folder_hot_new'];
|
2001-05-31 11:47:43 +00:00
|
|
|
}
|
2001-09-17 00:42:17 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$folder = $images['folder'];
|
|
|
|
$folder_new = $images['folder_new'];
|
|
|
|
}
|
|
|
|
}
|
2001-05-29 14:25:09 +00:00
|
|
|
|
2002-01-12 17:00:32 +00:00
|
|
|
if( $userdata['session_logged_in'] )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
2002-01-12 17:00:32 +00:00
|
|
|
if( $searchset[$i]['post_time'] > $userdata['user_lastvisit'] )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
2002-01-12 17:00:32 +00:00
|
|
|
if( !empty($tracking_topics) || !empty($tracking_forums) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_all"]) )
|
2001-11-19 14:12:09 +00:00
|
|
|
{
|
|
|
|
|
2002-01-12 17:00:32 +00:00
|
|
|
$unread_topics = true;
|
|
|
|
|
|
|
|
if( !empty($tracking_topics['' . $topic_id . '']) )
|
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
if( $tracking_topics[$topic_id] > $searchset[$i]['post_time'] )
|
2002-01-12 17:00:32 +00:00
|
|
|
{
|
|
|
|
$unread_topics = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
if( !empty($tracking_forums[$forum_id]) )
|
2002-01-12 17:00:32 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
if( $tracking_forums[$forum_id] > $searchset[$i]['post_time'] )
|
2002-01-12 17:00:32 +00:00
|
|
|
{
|
|
|
|
$unread_topics = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_all"]) )
|
|
|
|
{
|
|
|
|
if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_all"] > $searchset[$i]['post_time'] )
|
|
|
|
{
|
|
|
|
$unread_topics = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( $unread_topics )
|
|
|
|
{
|
|
|
|
$folder_image = "<img src=\"$folder_new\" alt=\"" . $lang['New_posts'] . "\" title=\"" . $lang['New_posts'] . "\" />";
|
|
|
|
|
|
|
|
$newest_post_img = "<a href=\"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> ";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
|
|
|
|
|
|
|
|
$folder_image = "<img src=\"$folder\" alt=\"$folder_alt\" title=\"$folder_alt\" border=\"0\" />";
|
|
|
|
$newest_post_img = "";
|
|
|
|
}
|
|
|
|
|
2001-11-19 14:12:09 +00:00
|
|
|
}
|
2002-01-12 17:00:32 +00:00
|
|
|
else if( $searchset[$i]['post_time'] > $userdata['user_lastvisit'] )
|
|
|
|
{
|
|
|
|
$folder_image = "<img src=\"$folder_new\" alt=\"" . $lang['New_posts'] . "\" title=\"" . $lang['New_posts'] . "\" />";
|
2001-12-05 00:20:56 +00:00
|
|
|
|
2002-01-12 17:00:32 +00:00
|
|
|
$newest_post_img = "<a href=\"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> ";
|
|
|
|
}
|
|
|
|
else
|
2001-11-19 14:12:09 +00:00
|
|
|
{
|
2002-01-12 17:00:32 +00:00
|
|
|
$folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
|
|
|
|
$folder_image = "<img src=\"$folder\" alt=\"$folder_alt\" title=\"$folder_alt\" border=\"0\" />";
|
|
|
|
$newest_post_img = "";
|
2001-11-19 14:12:09 +00:00
|
|
|
}
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-01-12 17:00:32 +00:00
|
|
|
$folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
|
2001-12-05 00:20:56 +00:00
|
|
|
$folder_image = "<img src=\"$folder\" alt=\"$folder_alt\" title=\"$folder_alt\" border=\"0\" />";
|
2001-11-19 14:12:09 +00:00
|
|
|
$newest_post_img = "";
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
2001-12-05 00:20:56 +00:00
|
|
|
}
|
2002-01-12 17:00:32 +00:00
|
|
|
else
|
2001-12-05 00:20:56 +00:00
|
|
|
{
|
2002-01-12 17:00:32 +00:00
|
|
|
$folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
|
2001-12-05 00:20:56 +00:00
|
|
|
$folder_image = "<img src=\"$folder\" alt=\"$folder_alt\" title=\"$folder_alt\" border=\"0\" />";
|
|
|
|
$newest_post_img = "";
|
2001-05-29 14:25:09 +00:00
|
|
|
}
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
|
|
|
|
2002-01-25 02:34:49 +00:00
|
|
|
$topic_poster = ( $searchset[$i]['user_id'] != ANONYMOUS ) ? "<a href=\"" . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $searchset[$i]['user_id']) . "\">" : "";
|
|
|
|
$topic_poster .= ( $searchset[$i]['user_id'] != ANONYMOUS ) ? $searchset[$i]['username'] : ( ( $searchset[$i]['post_username'] != "" ) ? $searchset[$i]['post_username'] : $lang['Guest'] );
|
|
|
|
$topic_poster .= ( $searchset[$i]['user_id'] != ANONYMOUS ) ? "</a>" : "";
|
2001-05-29 14:25:09 +00:00
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
$last_post_time = create_date($board_config['default_dateformat'], $searchset[$i]['post_time'], $board_config['board_timezone']);
|
2001-05-29 14:25:09 +00:00
|
|
|
|
2002-01-12 17:00:32 +00:00
|
|
|
$last_post_user = ( $searchset[$i]['id2'] == ANONYMOUS && $searchset[$i]['post_username'] != '' ) ? $searchset[$i]['post_username'] : $searchset[$i]['user2'];
|
2001-05-29 14:25:09 +00:00
|
|
|
|
2002-01-25 02:34:49 +00:00
|
|
|
$last_post = $last_post_time . "<br />";
|
|
|
|
$last_post .= ( $searchset[$i]['id2'] == ANONYMOUS ) ? ( ($searchset[$i]['post_username'] != "" ) ? $searchset[$i]['post_username'] . " " : $lang['Guest'] . " " ) : "<a href=\"" . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $searchset[$i]['id2']) . "\">" . $searchset[$i]['user2'] . "</a> ";
|
|
|
|
$last_post .= "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $searchset[$i]['topic_last_post_id']) . "#" . $searchset[$i]['topic_last_post_id'] . "\"><img src=\"" . $images['icon_latest_reply'] . "\" alt=\"" . $lang['View_latest_post'] . "\" title=\"" . $lang['View_latest_post'] . "\" border=\"0\" /></a>";
|
2001-09-17 00:42:17 +00:00
|
|
|
|
|
|
|
$template->assign_block_vars("searchresults", array(
|
|
|
|
"FORUM_NAME" => $searchset[$i]['forum_name'],
|
|
|
|
"FORUM_ID" => $forum_id,
|
|
|
|
"TOPIC_ID" => $topic_id,
|
|
|
|
"FOLDER" => $folder_image,
|
2001-09-26 22:35:08 +00:00
|
|
|
"NEWEST_POST_IMG" => $newest_post_img,
|
2001-09-17 00:42:17 +00:00
|
|
|
"TOPIC_POSTER" => $topic_poster,
|
|
|
|
"GOTO_PAGE" => $goto_page,
|
|
|
|
"REPLIES" => $replies,
|
|
|
|
"TOPIC_TITLE" => $topic_title,
|
|
|
|
"TOPIC_TYPE" => $topic_type,
|
|
|
|
"VIEWS" => $views,
|
|
|
|
"LAST_POST" => $last_post,
|
|
|
|
|
|
|
|
"U_VIEW_FORUM" => $forum_url,
|
|
|
|
"U_VIEW_TOPIC" => $topic_url,
|
2001-12-19 17:15:08 +00:00
|
|
|
"U_TOPIC_POSTER_PROFILE" => append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $searchset[$i]['user_id']))
|
2001-09-17 00:42:17 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2001-05-29 14:25:09 +00:00
|
|
|
|
2002-01-25 00:48:46 +00:00
|
|
|
$base_url = "search.$phpEx?search_id=$search_id";
|
2001-08-30 22:20:23 +00:00
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
$template->assign_vars(array(
|
2001-11-09 13:00:04 +00:00
|
|
|
"PAGINATION" => generate_pagination($base_url, $total_match_count, $per_page, $start),
|
2001-11-16 00:20:43 +00:00
|
|
|
"PAGE_NUMBER" => sprintf($lang['Page_of'], ( floor( $start / $per_page ) + 1 ), ceil( $total_match_count / $per_page )),
|
2001-05-29 14:25:09 +00:00
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
"L_GOTO_PAGE" => $lang['Goto_page'])
|
|
|
|
);
|
2001-05-29 14:25:09 +00:00
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
$template->pparse("body");
|
|
|
|
|
|
|
|
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
|
2001-05-29 14:25:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2001-09-17 00:42:17 +00:00
|
|
|
// Search forum
|
2001-05-29 14:25:09 +00:00
|
|
|
//
|
2001-09-17 00:42:17 +00:00
|
|
|
$sql = "SELECT c.cat_title, c.cat_id, f.forum_name, f.forum_id
|
|
|
|
FROM " . CATEGORIES_TABLE . " c, " . FORUMS_TABLE . " f
|
|
|
|
WHERE f.cat_id = c.cat_id
|
|
|
|
ORDER BY c.cat_id, f.forum_order";
|
2001-05-29 14:25:09 +00:00
|
|
|
$result = $db->sql_query($sql);
|
2001-12-20 01:25:00 +00:00
|
|
|
if( !$result )
|
2001-05-29 14:25:09 +00:00
|
|
|
{
|
2001-09-17 00:42:17 +00:00
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain forum_name/forum_id", "", __LINE__, __FILE__, $sql);
|
2001-05-29 14:25:09 +00:00
|
|
|
}
|
|
|
|
|
2001-06-17 23:53:04 +00:00
|
|
|
$is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);
|
2001-06-02 16:49:22 +00:00
|
|
|
|
2001-11-29 13:05:03 +00:00
|
|
|
$s_forums = "";
|
2001-12-20 01:25:00 +00:00
|
|
|
while( $row = $db->sql_fetchrow($result) )
|
2001-05-29 14:25:09 +00:00
|
|
|
{
|
2001-11-29 13:05:03 +00:00
|
|
|
if( $is_auth_ary[$row['forum_id']]['auth_read'] )
|
2001-06-02 16:49:22 +00:00
|
|
|
{
|
2001-09-17 00:42:17 +00:00
|
|
|
$s_forums .= "<option value=\"" . $row['forum_id'] . "\">" . $row['forum_name'] . "</option>";
|
2001-11-29 13:05:03 +00:00
|
|
|
if( empty($list_cat[$row['cat_id']]) )
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
|
|
|
$list_cat[$row['cat_id']] = $row['cat_title'];
|
|
|
|
}
|
2001-06-02 16:49:22 +00:00
|
|
|
}
|
2001-05-29 14:25:09 +00:00
|
|
|
}
|
|
|
|
|
2001-11-29 13:05:03 +00:00
|
|
|
if( $s_forums != "" )
|
|
|
|
{
|
2001-12-20 01:25:00 +00:00
|
|
|
$s_forums = "<option value=\"-1\">" . $lang['All_available'] . "</option>" . $s_forums;
|
2001-11-29 13:05:03 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Category to search
|
|
|
|
//
|
2001-12-20 01:25:00 +00:00
|
|
|
$s_categories = "<option value=\"-1\">" . $lang['All_available'] . "</option>";
|
2001-11-29 13:05:03 +00:00
|
|
|
while( list($cat_id, $cat_title) = @each($list_cat))
|
|
|
|
{
|
|
|
|
$s_categories .= "<option value=\"$cat_id\">$cat_title</option>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2001-09-17 00:42:17 +00:00
|
|
|
{
|
2001-11-29 13:05:03 +00:00
|
|
|
message_die(GENERAL_MESSAGE, $lang['No_searchable_forums']);
|
2001-09-17 00:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Number of chars returned
|
|
|
|
//
|
2002-02-25 01:00:48 +00:00
|
|
|
$s_characters = '<option value="-1">' . $lang['All_available'] . '</option>';
|
|
|
|
$s_characters .= '<option value="0">0</option>';
|
|
|
|
$s_characters .= '<option value="25">25</option>';
|
|
|
|
$s_characters .= '<option value="50">50</option>';
|
2001-09-17 00:42:17 +00:00
|
|
|
|
2001-05-29 14:25:09 +00:00
|
|
|
for($i = 100; $i < 1100 ; $i += 100)
|
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$selected = ( $i == 200 ) ? ' selected="selected"' : '';
|
|
|
|
$s_characters .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
|
2001-05-29 14:25:09 +00:00
|
|
|
}
|
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
//
|
|
|
|
// Sorting
|
|
|
|
//
|
2002-02-25 01:00:48 +00:00
|
|
|
$s_sort_by = "";
|
|
|
|
for($i = 0; $i < count($sort_by_types); $i++)
|
2001-05-29 14:25:09 +00:00
|
|
|
{
|
2002-02-25 01:00:48 +00:00
|
|
|
$s_sort_by .= '<option value="' . $i . '">' . $sort_by_types[$i] . '</option>';
|
2001-05-29 14:25:09 +00:00
|
|
|
}
|
|
|
|
|
2001-09-17 00:42:17 +00:00
|
|
|
//
|
|
|
|
// Search time
|
|
|
|
//
|
|
|
|
$previous_days = array(0, 1, 7, 14, 30, 90, 180, 364);
|
2001-11-09 13:00:04 +00:00
|
|
|
$previous_days_text = array($lang['All_Posts'], $lang['1_Day'], $lang['7_Days'], $lang['2_Weeks'], $lang['1_Month'], $lang['3_Months'], $lang['6_Months'], $lang['1_Year']);
|
2001-09-17 00:42:17 +00:00
|
|
|
|
2001-09-26 01:36:52 +00:00
|
|
|
$s_time = "";
|
2001-09-17 00:42:17 +00:00
|
|
|
for($i = 0; $i < count($previous_days); $i++)
|
|
|
|
{
|
2001-12-20 01:25:00 +00:00
|
|
|
$selected = ( $topic_days == $previous_days[$i] ) ? " selected=\"selected\"" : "";
|
2001-09-17 00:42:17 +00:00
|
|
|
$s_time .= "<option value=\"" . $previous_days[$i] . "\"$selected>" . $previous_days_text[$i] . "</option>";
|
|
|
|
}
|
|
|
|
|
2001-09-26 01:36:52 +00:00
|
|
|
//
|
|
|
|
// Output the basic page
|
|
|
|
//
|
2001-09-17 00:42:17 +00:00
|
|
|
$page_title = $lang['Search'];
|
2001-07-13 16:14:37 +00:00
|
|
|
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
|
2001-05-29 14:25:09 +00:00
|
|
|
|
|
|
|
$template->set_filenames(array(
|
|
|
|
"body" => "search_body.tpl",
|
|
|
|
"jumpbox" => "jumpbox.tpl")
|
|
|
|
);
|
2001-09-17 00:42:17 +00:00
|
|
|
|
2001-05-29 14:25:09 +00:00
|
|
|
$jumpbox = make_jumpbox();
|
|
|
|
$template->assign_vars(array(
|
2001-09-17 00:42:17 +00:00
|
|
|
"L_GO" => $lang['Go'],
|
|
|
|
"L_JUMP_TO" => $lang['Jump_to'],
|
|
|
|
"L_SELECT_FORUM" => $lang['Select_forum'],
|
|
|
|
|
|
|
|
"S_JUMPBOX_LIST" => $jumpbox,
|
|
|
|
"S_JUMPBOX_ACTION" => append_sid("viewforum.$phpEx"))
|
2001-05-29 14:25:09 +00:00
|
|
|
);
|
|
|
|
$template->assign_var_from_handle("JUMPBOX", "jumpbox");
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
2001-09-17 00:42:17 +00:00
|
|
|
"L_SEARCH_QUERY" => $lang['Search_query'],
|
|
|
|
"L_SEARCH_OPTIONS" => $lang['Search_options'],
|
|
|
|
"L_SEARCH_KEYWORDS" => $lang['Search_keywords'],
|
|
|
|
"L_SEARCH_KEYWORDS_EXPLAIN" => $lang['Search_keywords_explain'],
|
|
|
|
"L_SEARCH_AUTHOR" => $lang['Search_author'],
|
|
|
|
"L_SEARCH_AUTHOR_EXPLAIN" => $lang['Search_author_explain'],
|
2001-05-29 14:25:09 +00:00
|
|
|
"L_SEARCH_ANY_TERMS" => $lang['Search_for_any'],
|
2002-01-14 14:16:54 +00:00
|
|
|
"L_SEARCH_ALL_TERMS" => $lang['Search_for_all'],
|
|
|
|
"L_SEARCH_MESSAGE_ONLY" => $lang['Search_msg_only'],
|
|
|
|
"L_SEARCH_MESSAGE_TITLE" => $lang['Search_title_msg'],
|
2001-09-17 00:42:17 +00:00
|
|
|
"L_CATEGORY" => $lang['Category'],
|
|
|
|
"L_RETURN_FIRST" => $lang['Return_first'],
|
2001-09-26 01:36:52 +00:00
|
|
|
"L_CHARACTERS" => $lang['characters_posts'],
|
2001-05-29 14:25:09 +00:00
|
|
|
"L_SORT_BY" => $lang['Sort_by'],
|
2001-08-30 22:20:23 +00:00
|
|
|
"L_SORT_ASCENDING" => $lang['Sort_Ascending'],
|
2001-11-16 17:31:49 +00:00
|
|
|
"L_SORT_DESCENDING" => $lang['Sort_Descending'],
|
2001-09-17 00:42:17 +00:00
|
|
|
"L_SEARCH_PREVIOUS" => $lang['Search_previous'],
|
|
|
|
"L_DISPLAY_RESULTS" => $lang['Display_results'],
|
2001-05-29 14:25:09 +00:00
|
|
|
|
2001-11-14 23:08:56 +00:00
|
|
|
"S_SEARCH_ACTION" => append_sid("search.$phpEx?mode=results"),
|
2001-05-29 14:25:09 +00:00
|
|
|
"S_CHARACTER_OPTIONS" => $s_characters,
|
2001-09-17 00:42:17 +00:00
|
|
|
"S_FORUM_OPTIONS" => $s_forums,
|
|
|
|
"S_CATEGORY_OPTIONS" => $s_categories,
|
|
|
|
"S_TIME_OPTIONS" => $s_time,
|
2002-02-25 01:00:48 +00:00
|
|
|
"S_SORT_OPTIONS" => $s_sort_by,
|
2001-05-29 14:25:09 +00:00
|
|
|
"S_HIDDEN_FIELDS" => $s_hidden_fields)
|
|
|
|
);
|
|
|
|
|
|
|
|
$template->pparse("body");
|
|
|
|
|
2001-07-13 16:14:37 +00:00
|
|
|
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
|
2001-05-29 14:25:09 +00:00
|
|
|
|
2002-02-25 01:00:48 +00:00
|
|
|
?>
|