mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
- overhauled search system
- updated structure for search backend plugins - better result caching using ACM - search results no longer session restricted => link to them by copying the URL :) - in-topic search - indexing posts now uses search backend plugins - develop/search_fill.php working again - fulltext_mysql not working yet - tiny bugfixes to ACM git-svn-id: file:///svn/phpbb/trunk@5441 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
9ea5fa1768
commit
0e0b1120fb
22 changed files with 1522 additions and 1036 deletions
|
@ -13,22 +13,35 @@
|
|||
//
|
||||
set_time_limit(0);
|
||||
|
||||
$phpbb_root_path = "../";
|
||||
include($phpbb_root_path . 'extension.inc');
|
||||
define('IN_PHPBB', true);
|
||||
$phpbb_root_path = '../';
|
||||
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
||||
include($phpbb_root_path . 'common.'.$phpEx);
|
||||
include($phpbb_root_path . 'includes/search.'.$phpEx);
|
||||
|
||||
$common_percent = 0.4; // Percentage of posts in which a word has to appear to be marked as common
|
||||
// Start session management
|
||||
$user->session_begin();
|
||||
$auth->acl($user->data);
|
||||
$user->setup();
|
||||
|
||||
$search_type = $config['search_type'];
|
||||
|
||||
if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx))
|
||||
{
|
||||
trigger_error('NO_SUCH_SEARCH_MODULE');
|
||||
}
|
||||
|
||||
require($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx);
|
||||
|
||||
$error = false;
|
||||
$search = new $search_type($error);
|
||||
|
||||
if ($error)
|
||||
{
|
||||
trigger_error($error);
|
||||
}
|
||||
|
||||
print "<html>\n<body>\n";
|
||||
|
||||
//
|
||||
// Try and load stopword and synonym files
|
||||
//
|
||||
// This needs fixing! Shouldn't be hardcoded to English files!
|
||||
$stopword_array = file($phpbb_root_path . "language/lang_english/search_stopwords.txt");
|
||||
$synonym_array = file($phpbb_root_path . "language/lang_english/search_synonyms.txt");
|
||||
|
||||
//
|
||||
// Fetch a batch of posts_text entries
|
||||
//
|
||||
|
@ -76,7 +89,7 @@ for(;$postcounter <= $max_post_id; $postcounter += $batchsize)
|
|||
|
||||
// $sql = "LOCK TABLES ".POST_TEXT_TABLE." WRITE";
|
||||
// $result = $db->sql_query($sql);
|
||||
print "\n<p>\n<a href='$PHP_SELF?batchstart=$batchstart'>Restart from posting $batchstart</a><br>\n";
|
||||
print "\n<p>\n<a href='{$_SERVER['PHP_SELF']}?batchstart=$batchstart'>Restart from posting $batchstart</a><br>\n";
|
||||
|
||||
// For every post in the batch:
|
||||
for($post_nr = 0; $post_nr < $post_rows; $post_nr++ )
|
||||
|
@ -86,105 +99,19 @@ for(;$postcounter <= $max_post_id; $postcounter += $batchsize)
|
|||
|
||||
$post_id = $rowset[$post_nr]['post_id'];
|
||||
|
||||
$matches = array();
|
||||
$matches['text'] = split_words(clean_words("post", $rowset[$post_nr]['post_text'], $stopword_array, $synonym_array));
|
||||
$matches['title'] = split_words(clean_words("post", $rowset[$post_nr]['post_subject'], $stopword_array, $synonym_array));
|
||||
|
||||
while( list($match_type, $match_ary) = @each($matches) )
|
||||
{
|
||||
$title_match = ( $match_type == 'title' ) ? 1 : 0;
|
||||
|
||||
$num_matches = count($match_ary);
|
||||
|
||||
if ( $num_matches < 1 )
|
||||
{
|
||||
// Skip this post if no words where found
|
||||
continue;
|
||||
$search->index('post', $rowset[$post_nr]['post_id'], $rowset[$post_nr]['post_text'], $rowset[$post_nr]['post_subject']);
|
||||
}
|
||||
|
||||
// For all words in the posting
|
||||
$sql_in = "";
|
||||
|
||||
$sql_insert = '';
|
||||
$sql_select = '';
|
||||
|
||||
$word = array();
|
||||
$word_count = array();
|
||||
|
||||
for($j = 0; $j < $num_matches; $j++)
|
||||
{
|
||||
$this_word = strtolower(trim($match_ary[$j]));
|
||||
if ( $this_word != '' )
|
||||
{
|
||||
$word_count[$this_word] = ( isset($word_count[$this_word]) ) ? $word_count[$this_word] + 1 : 0;
|
||||
$comma = ($sql_insert != '')? ', ': '';
|
||||
|
||||
$sql_insert .= "$comma('" . $this_word . "')";
|
||||
$sql_select .= "$comma'" . $this_word . "'";
|
||||
}
|
||||
}
|
||||
|
||||
if ( $sql_insert == '' )
|
||||
{
|
||||
die("no words found");
|
||||
}
|
||||
|
||||
$sql = 'INSERT IGNORE INTO ' . SEARCH_WORD_TABLE . "
|
||||
(word_text)
|
||||
VALUES $sql_insert";
|
||||
if ( !$result = $db->sql_query($sql) )
|
||||
{
|
||||
$error = $db->sql_error();
|
||||
die("Couldn't INSERT words :: " . $sql . " :: " . $error['message']);
|
||||
}
|
||||
|
||||
// Get the word_id's out of the DB (to see if they are already there)
|
||||
$sql = "SELECT word_id, word_text
|
||||
FROM " . SEARCH_WORD_TABLE . "
|
||||
WHERE word_text IN ($sql_select)
|
||||
GROUP BY word_text";
|
||||
$result = $db->sql_query($sql);
|
||||
if ( !$result )
|
||||
{
|
||||
$error = $db->sql_error();
|
||||
die("Couldn't select words :: " . $sql . " :: " . $error['message']);
|
||||
}
|
||||
|
||||
$sql_insert = array();
|
||||
while( $row = $db->sql_fetchrow($result) )
|
||||
{
|
||||
$sql_insert[] = "($post_id, " . $row['word_id'] . ", $title_match)";
|
||||
}
|
||||
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = "INSERT INTO " . SEARCH_MATCH_TABLE . "
|
||||
(post_id, word_id, title_match)
|
||||
VALUES " . implode(", ", $sql_insert);
|
||||
$result = $db->sql_query($sql);
|
||||
if ( !$result )
|
||||
{
|
||||
$error = $db->sql_error();
|
||||
die("Couldn't insert new word match :: " . $sql . " :: " . $error['message']);
|
||||
}
|
||||
|
||||
} // All posts
|
||||
}
|
||||
|
||||
// $sql = "UNLOCK TABLES";
|
||||
// $result = $db->sql_query($sql);
|
||||
|
||||
}
|
||||
|
||||
// Remove common words after the first 2 batches and after every 4th batch after that.
|
||||
if( $batchcount % 4 == 3 )
|
||||
{
|
||||
print "<br>Removing common words (words that appear in more than $common_percent of the posts)<br>\n";
|
||||
flush();
|
||||
print "Removed ". remove_common("global", $common_percent) ." words that where too common.<br>";
|
||||
}
|
||||
}
|
||||
|
||||
print "<br>Removing common words (words that appear in more than 50% of the posts)<br>\n";
|
||||
flush();
|
||||
$search->tidy();
|
||||
print "Removed words that where too common.<br>";
|
||||
|
||||
echo "<br>Done";
|
||||
|
||||
?>
|
||||
|
|
|
@ -57,7 +57,7 @@ class acm
|
|||
|
||||
if (!$var_names)
|
||||
{
|
||||
$var_requested[] = $row['var_name'];
|
||||
$this->var_requested[] = $row['var_name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ class acm
|
|||
|
||||
if ($var_name{0} == '_')
|
||||
{
|
||||
if (!in_array($this->var_requested, $var_name))
|
||||
if (!in_array($var_name, $this->var_requested))
|
||||
{
|
||||
$this->var_requested[] = $var_name;
|
||||
|
||||
|
|
|
@ -154,6 +154,11 @@ class acm
|
|||
{
|
||||
global $phpEx;
|
||||
|
||||
if (!$this->_exists($var_name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ($var_name == 'sql' && !empty($table))
|
||||
{
|
||||
$regex = '(' . ((is_array($table)) ? implode('|', $table) : $table) . ')';
|
||||
|
|
|
@ -564,7 +564,7 @@ class acp_board
|
|||
$dp = opendir($phpbb_root_path . 'includes/search');
|
||||
while ($file = readdir($dp))
|
||||
{
|
||||
if (preg_match('#\.' . $phpEx . '$#', $file))
|
||||
if ((preg_match('#\.' . $phpEx . '$#', $file)) && ($file != "search.$phpEx"))
|
||||
{
|
||||
$search_plugins[] = preg_replace('#^(.*?)\.' . $phpEx . '$#', '\1', $file);
|
||||
}
|
||||
|
|
|
@ -2057,6 +2057,11 @@ function page_footer()
|
|||
// Tidy some table rows every week
|
||||
$cron_type = 'tidy_database';
|
||||
}
|
||||
else if (time() - $config['search_last_gc'] > $config['search_gc'])
|
||||
{
|
||||
// Tidy the cache
|
||||
$cron_type = 'tidy_search';
|
||||
}
|
||||
/**
|
||||
* @todo add session garbage collection
|
||||
|
||||
|
|
|
@ -509,7 +509,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true)
|
|||
*/
|
||||
function delete_posts($where_type, $where_ids, $auto_sync = true)
|
||||
{
|
||||
global $db;
|
||||
global $db, $config, $phpbb_root_path, $phpEx;
|
||||
|
||||
if (is_array($where_ids))
|
||||
{
|
||||
|
@ -542,7 +542,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true)
|
|||
|
||||
$db->sql_transaction('begin');
|
||||
|
||||
$table_ary = array(POSTS_TABLE, REPORTS_TABLE, SEARCH_MATCH_TABLE);
|
||||
$table_ary = array(POSTS_TABLE, REPORTS_TABLE);
|
||||
|
||||
foreach ($table_ary as $table)
|
||||
{
|
||||
|
@ -552,6 +552,26 @@ function delete_posts($where_type, $where_ids, $auto_sync = true)
|
|||
}
|
||||
unset($table_ary);
|
||||
|
||||
// Remove the message from the search index
|
||||
$search_type = $config['search_type'];
|
||||
|
||||
if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx))
|
||||
{
|
||||
trigger_error('NO_SUCH_SEARCH_MODULE');
|
||||
}
|
||||
|
||||
require("{$phpbb_root_path}includes/search/$search_type.$phpEx");
|
||||
|
||||
$error = false;
|
||||
$search = new $search_type($error);
|
||||
|
||||
if ($error)
|
||||
{
|
||||
trigger_error($error);
|
||||
}
|
||||
|
||||
$search->index_remove($where_ids);
|
||||
|
||||
delete_attachments('post', $post_ids, false);
|
||||
|
||||
$db->sql_transaction('commit');
|
||||
|
|
|
@ -1212,325 +1212,4 @@ class parse_message extends bbcode_firstpass
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @package phpBB3
|
||||
* Parses a given message and updates/maintains the fulltext tables
|
||||
* @todo replace fulltext_search in message_parser with search modules
|
||||
*/
|
||||
class fulltext_search
|
||||
{
|
||||
function split_words($mode, $text)
|
||||
{
|
||||
global $user, $config;
|
||||
|
||||
static $drop_char_match, $drop_char_replace, $stopwords, $replace_synonym, $match_synonym;
|
||||
|
||||
// Is the fulltext indexer disabled? If yes then we need not
|
||||
// carry on ... it's okay ... I know when I'm not wanted boo hoo
|
||||
if (!$config['load_search_upd'])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_array($drop_char_match))
|
||||
{
|
||||
$drop_char_match = array('-', '^', '$', ';', '#', '&', '(', ')', '<', '>', '`', '\'', '"', '|', ',', '@', '_', '?', '%', '~', '.', '[', ']', '{', '}', ':', '\\', '/', '=', '\'', '!', '*');
|
||||
$drop_char_replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '', '', ' ', ' ', ' ', ' ', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '' , ' ', ' ', ' ', ' ', ' ');
|
||||
|
||||
if ($fp = @fopen($user->lang_path . '/search_stopwords.txt', 'rb'))
|
||||
{
|
||||
$stopwords = explode("\n", str_replace("\r\n", "\n", fread($fp, filesize($user->lang_path . '/search_stopwords.txt'))));
|
||||
}
|
||||
fclose($fp);
|
||||
|
||||
if ($fp = @fopen($user->lang_path . '/search_synonyms.txt', 'rb'))
|
||||
{
|
||||
preg_match_all('#^(.*?) (.*?)$#ms', fread($fp, filesize($user->lang_path . '/search_synonyms.txt')), $match);
|
||||
$replace_synonym = &$match[1];
|
||||
$match_synonym = &$match[2];
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
$match = array();
|
||||
// Comments for hardcoded bbcode elements (urls, smilies, html)
|
||||
$match[] = '#<!\-\- .* \-\->(.*?)<!\-\- .* \-\->#is';
|
||||
// New lines, carriage returns
|
||||
$match[] = "#[\n\r]+#";
|
||||
// NCRs like etc.
|
||||
$match[] = '#(&|&)[\#a-z0-9]+?;#i';
|
||||
// Do not index code
|
||||
$match[] = '#\[code=?.*?(\:?[0-9a-z]{5,})\].*?\[\/code(\:?[0-9a-z]{5,})\]#is';
|
||||
// BBcode
|
||||
$match[] = '#\[\/?[a-z\*\+\-]+=?.*?(\:?[0-9a-z]{5,})\]#';
|
||||
// Sequences > min_search_chars & < max_search_chars
|
||||
// $match[] = '#\s([\b]{1,' . $config['min_search_chars'] . '}|[\b]{' . $config['max_search_chars'] . ',})\s#is';
|
||||
// $match[] = '#\s((&\#[0-9]+;){1,' . $config['min_search_chars'] . '}|(&\#[0-9]+;){' . $config['max_search_chars'] . ',})\s#is';
|
||||
// Filter out ; and # but not &#[0-9]+;
|
||||
// $match[] = '#(&\#[0-9]+;)|;|\#|&#';
|
||||
|
||||
$text = preg_replace($match, ' ', ' ' . strtolower(trim($text)) . ' ');
|
||||
$text = str_replace(array(' + ', ' - '), array(' and ', ' not '), $text);
|
||||
|
||||
// Filter out non-alphabetical chars
|
||||
$text = str_replace($drop_char_match, $drop_char_replace, $text);
|
||||
|
||||
// Split words
|
||||
$text = explode(' ', preg_replace('#\s+#', ' ', trim($text)));
|
||||
|
||||
if (sizeof($stopwords))
|
||||
{
|
||||
$stopped_words = array_intersect($text, $stopwords);
|
||||
$text = array_diff($text, $stopwords);
|
||||
}
|
||||
|
||||
if (sizeof($replace_synonym))
|
||||
{
|
||||
$text = str_replace($replace_synonym, $match_synonym, $text);
|
||||
}
|
||||
|
||||
foreach ($text as $index => $word)
|
||||
{
|
||||
if (strlen($word) < $config['min_search_chars'] || strlen($word) > $config['max_search_chars'])
|
||||
{
|
||||
unset($text[$index]);
|
||||
}
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
function add($mode, $post_id, &$message, &$subject)
|
||||
{
|
||||
global $config, $db;
|
||||
|
||||
// Is the fulltext indexer disabled? If yes then we need not
|
||||
// carry on ... it's okay ... I know when I'm not wanted boo hoo
|
||||
if (!$config['load_search_upd'])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Split old and new post/subject to obtain array of 'words'
|
||||
$split_text = $this->split_words('post', $message);
|
||||
$split_title = ($subject) ? $this->split_words('post', $subject) : array();
|
||||
|
||||
$words = array();
|
||||
if ($mode == 'edit')
|
||||
{
|
||||
$words['add']['post'] = array();
|
||||
$words['add']['title'] = array();
|
||||
$words['del']['post'] = array();
|
||||
$words['del']['title'] = array();
|
||||
|
||||
$sql = 'SELECT w.word_id, w.word_text, m.title_match
|
||||
FROM ' . SEARCH_WORD_TABLE . ' w, ' . SEARCH_MATCH_TABLE . " m
|
||||
WHERE m.post_id = $post_id
|
||||
AND w.word_id = m.word_id";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$cur_words = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$which = ($row['title_match']) ? 'title' : 'post';
|
||||
$cur_words[$which][$row['word_text']] = $row['word_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$words['add']['post'] = array_diff($split_text, array_keys($cur_words['post']));
|
||||
$words['add']['title'] = array_diff($split_title, array_keys($cur_words['title']));
|
||||
$words['del']['post'] = array_diff(array_keys($cur_words['post']), $split_text);
|
||||
$words['del']['title'] = array_diff(array_keys($cur_words['title']), $split_title);
|
||||
}
|
||||
else
|
||||
{
|
||||
$words['add']['post'] = $split_text;
|
||||
$words['add']['title'] = $split_title;
|
||||
$words['del']['post'] = array();
|
||||
$words['del']['title'] = array();
|
||||
}
|
||||
unset($split_text);
|
||||
unset($split_title);
|
||||
|
||||
// Get unique words from the above arrays
|
||||
$unique_add_words = array_unique(array_merge($words['add']['post'], $words['add']['title']));
|
||||
|
||||
// We now have unique arrays of all words to be added and removed and
|
||||
// individual arrays of added and removed words for text and title. What
|
||||
// we need to do now is add the new words (if they don't already exist)
|
||||
// and then add (or remove) matches between the words and this post
|
||||
if (sizeof($unique_add_words))
|
||||
{
|
||||
$sql = 'SELECT word_id, word_text
|
||||
FROM ' . SEARCH_WORD_TABLE . '
|
||||
WHERE word_text IN (' . implode(', ', preg_replace('#^(.*)$#', '\'$1\'', $unique_add_words)) . ")";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$word_ids = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$word_ids[$row['word_text']] = $row['word_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$new_words = array_diff($unique_add_words, array_keys($word_ids));
|
||||
unset($unique_add_words);
|
||||
|
||||
if (sizeof($new_words))
|
||||
{
|
||||
switch (SQL_LAYER)
|
||||
{
|
||||
case 'mysql':
|
||||
$sql = 'INSERT INTO ' . SEARCH_WORD_TABLE . ' (word_text)
|
||||
VALUES ' . implode(', ', preg_replace('#^(.*)$#', '(\'$1\')', $new_words));
|
||||
$db->sql_query($sql);
|
||||
break;
|
||||
|
||||
case 'mysql4':
|
||||
case 'mysqli':
|
||||
case 'mssql':
|
||||
case 'mssql_odbc':
|
||||
case 'sqlite':
|
||||
$sql = 'INSERT INTO ' . SEARCH_WORD_TABLE . ' (word_text) ' . implode(' UNION ALL ', preg_replace('#^(.*)$#', "SELECT '\$1'", $new_words));
|
||||
$db->sql_query($sql);
|
||||
break;
|
||||
|
||||
default:
|
||||
foreach ($new_words as $word)
|
||||
{
|
||||
$sql = 'INSERT INTO ' . SEARCH_WORD_TABLE . " (word_text)
|
||||
VALUES ('$word')";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
unset($new_words);
|
||||
}
|
||||
|
||||
foreach ($words['del'] as $word_in => $word_ary)
|
||||
{
|
||||
$title_match = ($word_in == 'title') ? 1 : 0;
|
||||
|
||||
if (sizeof($word_ary))
|
||||
{
|
||||
$sql_in = array();
|
||||
foreach ($word_ary as $word)
|
||||
{
|
||||
$sql_in[] = $cur_words[$word_in][$word];
|
||||
}
|
||||
|
||||
$sql = 'DELETE FROM ' . SEARCH_MATCH_TABLE . '
|
||||
WHERE word_id IN (' . implode(', ', $sql_in) . ')
|
||||
AND post_id = ' . intval($post_id) . "
|
||||
AND title_match = $title_match";
|
||||
$db->sql_query($sql);
|
||||
unset($sql_in);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($words['add'] as $word_in => $word_ary)
|
||||
{
|
||||
$title_match = ($word_in == 'title') ? 1 : 0;
|
||||
|
||||
if (sizeof($word_ary))
|
||||
{
|
||||
$sql = 'INSERT INTO ' . SEARCH_MATCH_TABLE . " (post_id, word_id, title_match)
|
||||
SELECT $post_id, word_id, $title_match
|
||||
FROM " . SEARCH_WORD_TABLE . '
|
||||
WHERE word_text IN (' . implode(', ', preg_replace('#^(.*)$#', '\'$1\'', $word_ary)) . ')';
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
unset($words);
|
||||
|
||||
// Run the cleanup infrequently, once per session cleanup
|
||||
if ($config['search_last_gc'] < time() - $config['search_gc'])
|
||||
{
|
||||
$this->search_tidy();
|
||||
}
|
||||
}
|
||||
|
||||
// Tidy up indexes, tag 'common words', remove
|
||||
// words no longer referenced in the match table, etc.
|
||||
function search_tidy()
|
||||
{
|
||||
global $db, $config;
|
||||
|
||||
// Is the fulltext indexer disabled? If yes then we need not
|
||||
// carry on ... it's okay ... I know when I'm not wanted boo hoo
|
||||
if (!$config['load_search_upd'])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove common (> 60% of posts ) words
|
||||
$sql = 'SELECT SUM(forum_posts) AS total_posts
|
||||
FROM ' . FORUMS_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($row['total_posts'] >= 100)
|
||||
{
|
||||
$sql = 'SELECT word_id
|
||||
FROM ' . SEARCH_MATCH_TABLE . '
|
||||
GROUP BY word_id
|
||||
HAVING COUNT(word_id) > ' . floor($row['total_posts'] * 0.6);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$sql_in = array();
|
||||
do
|
||||
{
|
||||
$sql_in[] = $row['word_id'];
|
||||
}
|
||||
while ($row = $db->sql_fetchrow($result));
|
||||
|
||||
$sql_in = implode(', ', $sql_in);
|
||||
|
||||
$sql = 'UPDATE ' . SEARCH_WORD_TABLE . "
|
||||
SET word_common = 1
|
||||
WHERE word_id IN ($sql_in)";
|
||||
$db->sql_query($sql);
|
||||
|
||||
$sql = 'DELETE FROM ' . SEARCH_MATCH_TABLE . "
|
||||
WHERE word_id IN ($sql_in)";
|
||||
$db->sql_query($sql);
|
||||
unset($sql_in);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
// Remove words with no matches ... this is a potentially nasty query
|
||||
$sql = 'SELECT w.word_id
|
||||
FROM ' . SEARCH_WORD_TABLE . ' w
|
||||
LEFT JOIN ' . SEARCH_MATCH_TABLE . ' m ON (w.word_id = m.word_id)
|
||||
WHERE w.word_common = 0 AND m.word_id IS NULL
|
||||
GROUP BY m.word_id';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$sql_in = array();
|
||||
do
|
||||
{
|
||||
$sql_in[] = $row['word_id'];
|
||||
}
|
||||
while ($row = $db->sql_fetchrow($result));
|
||||
|
||||
$sql = 'DELETE FROM ' . SEARCH_WORD_TABLE . '
|
||||
WHERE word_id IN (' . implode(', ', $sql_in) . ')';
|
||||
$db->sql_query($sql);
|
||||
unset($sql_in);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
set_config('search_last_gc', time());
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
File diff suppressed because it is too large
Load diff
264
phpBB/includes/search/search.php
Executable file
264
phpBB/includes/search/search.php
Executable file
|
@ -0,0 +1,264 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package search
|
||||
* @version $Id$
|
||||
* @copyright (c) 2005 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('SEARCH_RESULT_NOT_IN_CACHE', 2);
|
||||
define('SEARCH_RESULT_IN_CACHE', 1);
|
||||
define('SEARCH_RESULT_INCOMPLETE', 2);
|
||||
|
||||
/**
|
||||
* @package search
|
||||
* search_backend
|
||||
* optional base class for search plugins providing simple caching based on ACM
|
||||
* and functions to retrieve ignore_words and synonyms
|
||||
*/
|
||||
class search_backend
|
||||
{
|
||||
var $ignore_words = array();
|
||||
var $match_synonym = array();
|
||||
var $replace_synonym = array();
|
||||
var $split_words = array();
|
||||
var $common_words = array();
|
||||
|
||||
function search_backend(&$error)
|
||||
{
|
||||
// This class cannot be used as a search plugin
|
||||
$error = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a list of common words that should be ignored in $this->ignore_words and caches them
|
||||
*/
|
||||
function get_ignore_words()
|
||||
{
|
||||
if (!sizeof($this->ignore_words))
|
||||
{
|
||||
global $user, $cache;
|
||||
|
||||
$ignore_words = $cache->get('_ignore_words');
|
||||
|
||||
if (!$ignore_words)
|
||||
{
|
||||
$ignore_words = array();
|
||||
}
|
||||
|
||||
if (!isset($ignore_words[$user->lang_name]))
|
||||
{
|
||||
$ignore_words[$user->lang_name] = explode("\n", str_replace("\n\n", "\n", str_replace("\r", "\n", file_get_contents($user->lang_path . '/search_ignore_words.txt'))));
|
||||
|
||||
$cache->put('_ignore_words', $ignore_words, 7200);
|
||||
}
|
||||
|
||||
$this->ignore_words = $ignore_words[$user->lang_name];
|
||||
|
||||
unset($ignore_words);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a list of synonyms that should be replaced in $this->match_synonym and $this->replace_synonym and caches them
|
||||
*/
|
||||
function get_synonyms()
|
||||
{
|
||||
if (!sizeof($this->match_synonym))
|
||||
{
|
||||
global $user, $cache;
|
||||
|
||||
$match_synonym = $cache->get('_match_synonym');
|
||||
|
||||
if (!$match_synonym)
|
||||
{
|
||||
$match_synonym = array();
|
||||
}
|
||||
|
||||
if (!isset($match_synonym[$user->lang_name]))
|
||||
{
|
||||
preg_match_all('#^\s+(\S+)\s+(\S+)\s+$#m', file_get_contents($user->lang_path . '/search_synonyms.txt'), $match);
|
||||
$match_synonym[$user->lang_name]['replace']= &$match[1];
|
||||
$match_synonym[$user->lang_name]['match'] = &$match[2];
|
||||
|
||||
$cache->put('_match_synonym', $match_synonym, 7200);
|
||||
}
|
||||
|
||||
$this->replace_synonym = $match_synonym[$user->lang_name]['replace'];
|
||||
$this->match_synonym = $match_synonym[$user->lang_name]['match'];
|
||||
|
||||
unset($match_synonym);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves cached search results
|
||||
*
|
||||
* @param int result_count will contain the number of all results for the search (not only for the current page)
|
||||
* @param array id_ary is filled with the ids belonging to the requested page that are stored in the cache
|
||||
*
|
||||
* @return SEARCH_RESULT_NOT_IN_CACHE or SEARCH_RESULT_IN_CACHE or SEARCH_RESULT_INCOMPLETE
|
||||
*/
|
||||
function obtain_ids($search_key, &$result_count, &$id_ary, $start, $per_page, $sort_dir)
|
||||
{
|
||||
global $cache;
|
||||
|
||||
if (!($stored_ids = $cache->get('_search_results_' . $search_key)))
|
||||
{
|
||||
// no search results cached for this search_key
|
||||
return SEARCH_RESULT_NOT_IN_CACHE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result_count = $stored_ids[-1];
|
||||
$reverse_ids = ($stored_ids[-2] != $sort_dir) ? true : false;
|
||||
$complete = true;
|
||||
|
||||
// change the start to the actual end of the current request if the sort direction differs
|
||||
// from the dirction in the cache and reverse the ids later
|
||||
if ($reverse_ids)
|
||||
{
|
||||
$start = $result_count - $start - $per_page;
|
||||
|
||||
// the user requested a page past the last index
|
||||
if ($start < 0)
|
||||
{
|
||||
return SEARCH_RESULT_NOT_IN_CACHE;
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = $start, $n = $start + $per_page; ($i < $n) && ($i < $result_count); $i++)
|
||||
{
|
||||
if (!isset($stored_ids[$i]))
|
||||
{
|
||||
$complete = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$id_ary[] = $stored_ids[$i];
|
||||
}
|
||||
}
|
||||
unset($stored_ids);
|
||||
|
||||
if ($reverse_ids)
|
||||
{
|
||||
$id_ary = array_reverse($id_ary);
|
||||
}
|
||||
|
||||
if (!$complete)
|
||||
{
|
||||
return SEARCH_RESULT_INCOMPLETE;
|
||||
}
|
||||
return SEARCH_RESULT_IN_CACHE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Caches post/topic ids
|
||||
*
|
||||
* @param array id_ary contains a list of post or topic ids that shall be cached, the first element
|
||||
* must have the absolute index $start in the result set.
|
||||
*/
|
||||
function save_ids($search_key, $keywords, $author_ary, $result_count, &$id_ary, $start, $sort_dir)
|
||||
{
|
||||
global $cache, $config, $db;
|
||||
|
||||
$length = min(sizeof($id_ary), $config['search_block_size']);
|
||||
|
||||
$store_ids = array_slice($id_ary, 0, $length);
|
||||
|
||||
// create a new resultset if there is none for this search_key yet
|
||||
// or add the ids to the existing resultset
|
||||
if (!($store = $cache->get('_search_results_' . $search_key)))
|
||||
{
|
||||
// add the current keywords to the recent searches in the cache which are listed on the search page
|
||||
if (!empty($keywords) || sizeof($author_ary))
|
||||
{
|
||||
$sql = 'SELECT search_time
|
||||
FROM ' . SEARCH_TABLE . '
|
||||
WHERE search_key = \'' . $db->sql_escape($search_key) . '\'';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if (!$db->sql_fetchrow($result))
|
||||
{
|
||||
$sql_ary = array(
|
||||
'search_key' => $search_key,
|
||||
'search_time' => time(),
|
||||
'search_keywords' => $keywords,
|
||||
'search_authors' => implode(' ', $author_ary)
|
||||
);
|
||||
|
||||
$sql = 'INSERT INTO ' . SEARCH_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
set_config('last_search_time', time());
|
||||
|
||||
$store = array(-1 => $result_count, -2 => $sort_dir);
|
||||
$id_range = range($start, $start + $length - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// we use one set of resuts for both sort directions so we have to calculate the indizes
|
||||
// for the reversed array and we also have to reverse the ids themselves
|
||||
if ($store[-2] != $sort_dir)
|
||||
{
|
||||
$store_ids = array_reverse($store_ids);
|
||||
$id_range = range($store[-1] - $start - $length, $store[-1] - $start - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$id_range = range($start, $start + $length - 1);
|
||||
}
|
||||
}
|
||||
|
||||
// append the ids
|
||||
$store += array_combine($id_range, $store_ids);
|
||||
$cache->put('_search_results_' . $search_key, $store, $config['search_store_results']);
|
||||
|
||||
unset($store);
|
||||
unset($store_ids);
|
||||
unset($id_range);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes old entries from the search results table and removes searches with keywords that contain a word in $words.
|
||||
*/
|
||||
function destroy_cache($words)
|
||||
{
|
||||
global $db, $cache, $config;
|
||||
|
||||
if (sizeof($words))
|
||||
{
|
||||
$sql_where = '';
|
||||
foreach ($words as $word)
|
||||
{
|
||||
$sql_where .= ' OR search_keywords LIKE \'%' . $db->sql_escape($word) . '%\'';
|
||||
}
|
||||
|
||||
$sql = 'SELECT search_key
|
||||
FROM ' . SEARCH_TABLE . "
|
||||
WHERE search_keywords LIKE '%*%' $sql_where";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$cache->destroy('_search_results_' . $row['search_key']);
|
||||
}
|
||||
$db->sql_freeresult();
|
||||
}
|
||||
|
||||
$sql = 'DELETE
|
||||
FROM ' . SEARCH_TABLE . '
|
||||
WHERE search_time < ' . (time() - $config['search_store_results']);
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -481,10 +481,10 @@ CREATE TABLE phpbb_reports_reasons (
|
|||
|
||||
# phpbb_search_results
|
||||
CREATE TABLE phpbb_search_results (
|
||||
search_id INTEGER DEFAULT 0 NOT NULL,
|
||||
session_id VARCHAR(32) NOT NULL,
|
||||
search_key VARCHAR(32) NOT NULL,
|
||||
search_time INTEGER DEFAULT 0 NOT NULL,
|
||||
search_array BLOB SUB_TYPE TEXT NOT NULL
|
||||
search_keywords BLOB SUB_TYPE TEXT NOT NULL,
|
||||
search_authors BLOB SUB_TYPE TEXT NOT NULL
|
||||
);;
|
||||
|
||||
# phpbb_search_wordlist
|
||||
|
@ -1242,12 +1242,7 @@ ADD PRIMARY KEY (
|
|||
|
||||
ALTER TABLE phpbb_search_results
|
||||
ADD PRIMARY KEY (
|
||||
search_id
|
||||
);;
|
||||
|
||||
CREATE INDEX session_id54
|
||||
ON phpbb_search_results(
|
||||
session_id
|
||||
search_key
|
||||
);;
|
||||
|
||||
ALTER TABLE phpbb_search_wordlist
|
||||
|
|
|
@ -486,10 +486,10 @@ CREATE TABLE [phpbb_reports_reasons] (
|
|||
GO
|
||||
|
||||
CREATE TABLE [phpbb_search_results] (
|
||||
[search_id] [int] NOT NULL ,
|
||||
[session_id] [varchar] (32) NOT NULL ,
|
||||
[search_key] [varchar] (32) NOT NULL ,
|
||||
[search_time] [int] NOT NULL ,
|
||||
[search_array] [text] NOT NULL
|
||||
[search_keywords] [text] NOT NULL ,
|
||||
[search_authors] [text] NOT NULL
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||
GO
|
||||
|
||||
|
@ -1058,7 +1058,7 @@ GO
|
|||
ALTER TABLE [phpbb_search_results] WITH NOCHECK ADD
|
||||
CONSTRAINT [PK_phpbb_search_results] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[search_id]
|
||||
[search_key]
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
|
@ -1461,7 +1461,6 @@ ALTER TABLE [phpbb_reports_reasons] WITH NOCHECK ADD
|
|||
GO
|
||||
|
||||
ALTER TABLE [phpbb_search_results] WITH NOCHECK ADD
|
||||
CONSTRAINT [DF_search_search_id] DEFAULT (0) FOR [search_id],
|
||||
CONSTRAINT [DF_search_search_time] DEFAULT (0) FOR [search_time]
|
||||
GO
|
||||
|
||||
|
@ -1785,9 +1784,6 @@ GO
|
|||
CREATE INDEX [field_order] ON [phpbb_profile_fields]([field_order]) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE INDEX [session_id] ON [phpbb_search_results]([session_id]) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE INDEX [word_id] ON [phpbb_search_wordlist]([word_id]) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
|
|
|
@ -563,17 +563,16 @@ CREATE TABLE phpbb_reports (
|
|||
PRIMARY KEY (report_id)
|
||||
);
|
||||
|
||||
# Table: phpbb_search_results
|
||||
CREATE TABLE phpbb_search_results (
|
||||
search_id int(11) UNSIGNED DEFAULT '0' NOT NULL,
|
||||
session_id varchar(32) DEFAULT '' NOT NULL,
|
||||
# Table: 'phpbb_search_results'
|
||||
CREATE TABLE new_search_results (
|
||||
search_key varchar(32) DEFAULT '' NOT NULL,
|
||||
search_time int(11) DEFAULT '0' NOT NULL,
|
||||
search_array mediumtext NOT NULL,
|
||||
PRIMARY KEY (search_id),
|
||||
KEY session_id (session_id)
|
||||
search_keywords mediumtext NOT NULL,
|
||||
search_authors mediumtext NOT NULL,
|
||||
PRIMARY KEY (search_key)
|
||||
);
|
||||
|
||||
# Table: phpbb_search_wordlist
|
||||
# Table: 'phpbb_search_wordlist'
|
||||
CREATE TABLE phpbb_search_wordlist (
|
||||
word_text varchar(50) BINARY DEFAULT '' NOT NULL,
|
||||
word_id mediumint(8) UNSIGNED NOT NULL auto_increment,
|
||||
|
@ -582,7 +581,7 @@ CREATE TABLE phpbb_search_wordlist (
|
|||
KEY word_id (word_id)
|
||||
);
|
||||
|
||||
# Table: phpbb_search_wordmatch
|
||||
# Table: 'phpbb_search_wordmatch'
|
||||
CREATE TABLE phpbb_search_wordmatch (
|
||||
post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
||||
word_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
||||
|
|
|
@ -1141,17 +1141,14 @@ END;
|
|||
Table: phpbb_search_results
|
||||
*/
|
||||
CREATE TABLE phpbb_search_results (
|
||||
search_id number(11) DEFAULT '0' NOT NULL,
|
||||
session_id varchar2(32) DEFAULT '',
|
||||
session_key varchar2(32) DEFAULT '',
|
||||
search_time number(11) DEFAULT '0' NOT NULL,
|
||||
search_array clob,
|
||||
CONSTRAINT pk_phpbb_search_results PRIMARY KEY (search_id)
|
||||
search_keywords clob,
|
||||
search_authors clob,
|
||||
CONSTRAINT pk_phpbb_search_results PRIMARY KEY (search_key)
|
||||
)
|
||||
/
|
||||
|
||||
CREATE INDEX session_id on phpbb_search_results (session_id)
|
||||
/
|
||||
|
||||
/*
|
||||
Table: phpbb_search_wordlist
|
||||
*/
|
||||
|
|
|
@ -775,16 +775,13 @@ SELECT SETVAL('phpbb_reports_report_id_seq',(select case when max(report_id)>0 t
|
|||
|
||||
/* Table: phpbb_search_results */
|
||||
CREATE TABLE phpbb_search_results (
|
||||
search_id INT4 DEFAULT '0' NOT NULL,
|
||||
session_id varchar(32) DEFAULT '' NOT NULL,
|
||||
search_key varchar(32) DEFAULT '' NOT NULL,
|
||||
search_time INT4 DEFAULT '0' NOT NULL,
|
||||
search_array TEXT DEFAULT '' NOT NULL,
|
||||
PRIMARY KEY (search_id),
|
||||
CHECK (search_id>=0)
|
||||
search_keywords TEXT DEFAULT '' NOT NULL,
|
||||
search_authors TEXT DEFAULT '' NOT NULL,
|
||||
PRIMARY KEY (search_key)
|
||||
);
|
||||
|
||||
CREATE INDEX session_id_phpbb_search_results_index ON phpbb_search_results (session_id);
|
||||
|
||||
/* Table: phpbb_search_wordlist */
|
||||
CREATE SEQUENCE phpbb_search_wordlist_word_i;
|
||||
|
||||
|
|
|
@ -108,6 +108,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_base_dn', '')
|
|||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_server', '');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_uid', '');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('limit_load', '0');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('limit_search_load', '0');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_birthdays', '1');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_memberlist', '0');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_viewprofile', '1');
|
||||
|
@ -121,7 +122,6 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online', '1')
|
|||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online_guests', '1');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online_time', '5');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_search', '1');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_search_phr', '1');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_search_upd', '1');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_tplcompile', '0');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_attachments', '3');
|
||||
|
@ -138,12 +138,13 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_post_smilies',
|
|||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_post_urls', '0');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_quote_depth', '3');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_reg_attempts', '5');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_search_chars', '10');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_search_chars', '14');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_chars', '255');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_smilies', '0');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_urls', '5');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('min_name_chars', '3');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('min_pass_chars', '6');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('min_search_author_chars', '3');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('min_search_chars', '3');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('override_user_style', '0');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('pm_edit_time', '0');
|
||||
|
@ -156,9 +157,11 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('ranks_path', 'imag
|
|||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('require_activation', '0');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('save_passwd', '3');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('script_path', '');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_block_size', '250');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_gc', '7200');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_interval', '0');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_type', 'fulltext_phpbb');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_store_results', '1800');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('secure_allow_deny', '1');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('secure_allow_empty_referer', '1');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('secure_downloads', '0');
|
||||
|
@ -184,6 +187,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '2.1.2')
|
|||
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('cache_last_gc', '0', 1);
|
||||
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('database_last_gc', '0', 1);
|
||||
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('last_queue_run', '0', 1);
|
||||
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('last_search_time', '0', 1);
|
||||
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('newest_user_id', '2', 1);
|
||||
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('newest_username', '', 1);
|
||||
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_files', '0', 1);
|
||||
|
|
|
@ -36,6 +36,7 @@ $lang = array_merge($lang, array(
|
|||
|
||||
'FOUND_SEARCH_MATCH' => 'Search found %d match',
|
||||
'FOUND_SEARCH_MATCHES' => 'Search found %d matches',
|
||||
'FOUND_MORE_SEARCH_MATCHES' => 'Search found more than %d matches',
|
||||
|
||||
'IGNORED_TERMS' => 'ignored',
|
||||
|
||||
|
@ -43,6 +44,8 @@ $lang = array_merge($lang, array(
|
|||
'NO_SEARCH' => 'Sorry but you are not permitted to use the search system.',
|
||||
'NO_SEARCH_RESULTS' => 'No suitable matches were found.',
|
||||
'NO_SEARCH_TIME' => 'Sorry but you cannot use search at this time. Please try again in a few minutes.',
|
||||
'NO_KEYWORDS' => 'You must specify at least one word to search for. Each word must consist of at least %d characters and must not contain more than %d characters excluding wildcards.',
|
||||
'TOO_FEW_AUTHOR_CHARS' => 'You must specify at least %d characters of the authors name.',
|
||||
|
||||
'POST_CHARACTERS' => 'characters of posts',
|
||||
|
||||
|
@ -52,6 +55,7 @@ $lang = array_merge($lang, array(
|
|||
'RETURN_FIRST' => 'Return first',
|
||||
|
||||
'SEARCHED_FOR' => 'Search term used',
|
||||
'SEARCHED_TOPIC' => 'Searched topic',
|
||||
'SEARCH_ALL_TERMS' => 'Search for all terms or use query as entered',
|
||||
'SEARCH_ANY_TERMS' => 'Search for any terms',
|
||||
'SEARCH_AUTHOR' => 'Search for Author',
|
||||
|
|
0
phpBB/language/en/search_stopwords.txt → phpBB/language/en/search_ignore_words.txt
Normal file → Executable file
0
phpBB/language/en/search_stopwords.txt → phpBB/language/en/search_ignore_words.txt
Normal file → Executable file
|
@ -1235,7 +1235,7 @@ function show_profile($data)
|
|||
'ICQ_STATUS_IMG'=> (!empty($data['user_icq'])) ? '<img src="http://web.icq.com/whitepages/online?icq=' . $data['user_icq'] . '&img=5" width="18" height="18" border="0" />' : '',
|
||||
|
||||
'U_PROFILE' => "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&u=$user_id",
|
||||
'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? "{$phpbb_root_path}search.$phpEx$SID&search_author=" . urlencode($username) . "&show_results=posts" : '',
|
||||
'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? "{$phpbb_root_path}search.$phpEx$SID&author=" . urlencode($username) . "&sr=posts" : '',
|
||||
'U_NOTES' => $auth->acl_gets('m_', 'a_') ? "{$phpbb_root_path}mcp.$phpEx$SID&i=notes&mode=user_notes&u=$user_id" : '',
|
||||
'U_WARN' => $auth->acl_gets('m_', 'a_') ? "{$phpbb_root_path}mcp.$phpEx$SID&i=warn&mode=warn_user&u=$user_id" : '',
|
||||
'U_PM' => ($auth->acl_get('u_sendpm')) ? "{$phpbb_root_path}ucp.$phpEx$SID&i=pm&mode=compose&u=$user_id" : '',
|
||||
|
|
|
@ -1812,11 +1812,28 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
|||
WHERE topic_moved_id = ' . $data['topic_id']);
|
||||
}
|
||||
|
||||
// Fulltext parse
|
||||
// Index message contents
|
||||
if ($update_message && $data['enable_indexing'])
|
||||
{
|
||||
$search = new fulltext_search();
|
||||
$result = $search->add($mode, $data['post_id'], $data['message'], $subject);
|
||||
// Select the search method and do some additional checks to ensure it can actually be utilised
|
||||
$search_type = $config['search_type'];
|
||||
|
||||
if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx))
|
||||
{
|
||||
trigger_error('NO_SUCH_SEARCH_MODULE');
|
||||
}
|
||||
|
||||
require("{$phpbb_root_path}includes/search/$search_type.$phpEx");
|
||||
|
||||
$error = false;
|
||||
$search = new $search_type($error);
|
||||
|
||||
if ($error)
|
||||
{
|
||||
trigger_error($error);
|
||||
}
|
||||
|
||||
$search->index($mode, $data['post_id'], $data['message'], $subject);
|
||||
}
|
||||
|
||||
$db->sql_transaction('commit');
|
||||
|
|
536
phpBB/search.php
536
phpBB/search.php
|
@ -23,31 +23,52 @@ $user->setup('search');
|
|||
// Define initial vars
|
||||
$mode = request_var('mode', '');
|
||||
$search_id = request_var('search_id', '');
|
||||
$search_session_id = request_var('search_session_id', 0);
|
||||
$start = request_var('start', 0);
|
||||
$start = max(request_var('start', 0), 0);
|
||||
$post_id = request_var('p', 0);
|
||||
$topic_id = request_var('t', 0);
|
||||
$view = request_var('view', '');
|
||||
|
||||
$keywords = request_var('keywords', '');
|
||||
$add_keywords = request_var('add_keywords', '');
|
||||
$author = request_var('author', '');
|
||||
$show_results = request_var('show_results', 'topics');
|
||||
$search_terms = request_var('search_terms', 'all');
|
||||
$search_fields = request_var('search_fields', 'all');
|
||||
$search_child = request_var('search_child', true);
|
||||
|
||||
$return_chars = request_var('return_chars', 200);
|
||||
$search_forum = request_var('search_forum', array(0));
|
||||
$show_results = ($topic_id) ? 'posts' : request_var('sr', 'topics');
|
||||
$search_terms = request_var('terms', 'all');
|
||||
$search_fields = request_var('sf', 'all');
|
||||
$search_child = request_var('sc', true);
|
||||
|
||||
$sort_days = request_var('st', 0);
|
||||
$sort_key = request_var('sk', 't');
|
||||
$sort_dir = request_var('sd', 'd');
|
||||
|
||||
$return_chars = request_var('ch', ($topic_id) ? -1 : 200);
|
||||
$search_forum = request_var('fid', array(0));
|
||||
|
||||
if ($search_forum == array(0))
|
||||
{
|
||||
$search_forum = array();
|
||||
}
|
||||
|
||||
// Is user able to search? Has search been disabled?
|
||||
if (!$auth->acl_get('u_search') || !$config['load_search'])
|
||||
{
|
||||
trigger_error($user->lang['NO_SEARCH']);
|
||||
}
|
||||
|
||||
// Check search load limit
|
||||
if ($user->load && $config['limit_search_load'] && ($user->load > doubleval($config['limit_search_load'])))
|
||||
{
|
||||
trigger_error($user->lang['NO_SEARCH_TIME']);
|
||||
}
|
||||
|
||||
// Check last search time ... if applicable
|
||||
if ($config['search_interval'])
|
||||
{
|
||||
if ($config['last_search_time'] > time() - $config['search_interval'])
|
||||
{
|
||||
trigger_error($user->lang['NO_SEARCH_TIME']);
|
||||
}
|
||||
}
|
||||
|
||||
// Define some vars
|
||||
$limit_days = array(0 => $user->lang['ALL_RESULTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']);
|
||||
$sort_by_text = array('a' => $user->lang['SORT_AUTHOR'], 't' => $user->lang['SORT_TIME'], 'f' => $user->lang['SORT_FORUM'], 'i' => $user->lang['SORT_TOPIC_TITLE'], 's' => $user->lang['SORT_POST_SUBJECT']);
|
||||
|
@ -55,109 +76,166 @@ $sort_by_text = array('a' => $user->lang['SORT_AUTHOR'], 't' => $user->lang['SOR
|
|||
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
|
||||
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
|
||||
|
||||
$store_vars = array('sort_key', 'sort_dir', 'sort_days', 'show_results', 'return_chars', 'total_match_count');
|
||||
$current_time = time();
|
||||
|
||||
// Check last search time ... if applicable
|
||||
if ($config['search_interval'])
|
||||
{
|
||||
$sql = 'SELECT MAX(search_time) as last_time
|
||||
FROM ' . SEARCH_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($row['last_time'] > time() - $config['search_interval'])
|
||||
{
|
||||
trigger_error($user->lang['NO_SEARCH_TIME']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($keywords || $author || $search_id || $search_session_id)
|
||||
if ($keywords || $author || $search_id)
|
||||
{
|
||||
// clear arrays
|
||||
$pid_ary = $fid_ary = array();
|
||||
$id_ary = array();
|
||||
|
||||
// Which forums should not be searched?
|
||||
$ex_fid_ary = array_keys($auth->acl_getf('!f_read', true));
|
||||
|
||||
// Which forums can we view?
|
||||
$sql_where = (sizeof($search_forum) && !$search_child) ? 'WHERE f.forum_id IN (' . implode(', ', $search_forum) . ')' : '';
|
||||
$sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.right_id, f.forum_password, fa.user_id
|
||||
FROM ' . FORUMS_TABLE . ' f
|
||||
LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa ON (fa.forum_id = f.forum_id
|
||||
AND fa.session_id = '" . $db->sql_escape($user->data['session_id']) . "')
|
||||
$sql_where
|
||||
ORDER BY f.left_id";
|
||||
WHERE f.forum_id NOT IN (" . implode(', ', $ex_fid_ary) . ")
|
||||
OR (f.forum_password <> '' AND fa.user_id <> " . (int) $user->data['user_id'] . ')
|
||||
ORDER BY f.left_id';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$right_id = 0;
|
||||
$reset_search_forum = true;
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($row['forum_password'] && ($row['user_id'] != $user->data['user_id']))
|
||||
{
|
||||
$ex_fid_ary[] = $row['forum_id'];
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sizeof($search_forum))
|
||||
{
|
||||
if ($search_child)
|
||||
{
|
||||
if (!$search_forum || (in_array($row['forum_id'], $search_forum) && $row['right_id'] > $right_id))
|
||||
if (in_array($row['forum_id'], $search_forum) && $row['right_id'] > $right_id)
|
||||
{
|
||||
$right_id = $row['right_id'];
|
||||
}
|
||||
else if ($row['right_id'] > $right_id)
|
||||
else if ($row['right_id'] < $right_id)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($auth->acl_get('f_read', $row['forum_id']) && (!$row['forum_password'] || $row['user_id'] == $user->data['user_id']))
|
||||
if (!in_array($row['forum_id'], $search_forum))
|
||||
{
|
||||
$fid_ary[] = $row['forum_id'];
|
||||
$ex_fid_ary[] = $row['forum_id'];
|
||||
$reset_search_forum = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
unset($search_forum);
|
||||
|
||||
if (!sizeof($fid_ary))
|
||||
if ($reset_search_forum)
|
||||
{
|
||||
trigger_error($user->lang['NO_SEARCH_RESULTS']);
|
||||
$search_forum = array();
|
||||
}
|
||||
|
||||
// egosearch is an author search
|
||||
if ($search_id == 'egosearch')
|
||||
{
|
||||
$author = $user->data['username'];
|
||||
}
|
||||
|
||||
// Are we looking for a user?
|
||||
$author_id = 0;
|
||||
// If we are looking for authors get their ids
|
||||
$author_id_ary = array();
|
||||
if ($author)
|
||||
{
|
||||
if ((strstr($author, '*') !== false) && (str_replace(array('*', '%'), '', $author) < $config['min_search_author_chars']))
|
||||
{
|
||||
trigger_error(sprintf($user->lang['TOO_FEW_AUTHOR_CHARS'], $config['min_search_author_chars']));
|
||||
}
|
||||
|
||||
$sql_where = (strstr($author, '*') !== false) ? ' LIKE ' : ' = ';
|
||||
$sql = 'SELECT user_id
|
||||
FROM ' . USERS_TABLE . "
|
||||
WHERE username $sql_where '" . $db->sql_escape(preg_replace('#\*+#', '%', $author)) . "'
|
||||
AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
|
||||
$result = $db->sql_query($sql);
|
||||
$result = $db->sql_query_limit($sql, 100);
|
||||
|
||||
if (!$row = $db->sql_fetchrow($result))
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$author_id_ary[] = (int) $row['user_id'];
|
||||
}
|
||||
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!sizeof($author_id_ary))
|
||||
{
|
||||
trigger_error($user->lang['NO_SEARCH_RESULTS']);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$author_id = (int) $row['user_id'];
|
||||
}
|
||||
|
||||
// if we search in an existing search result just add the additional keywords. But we need to use "all search terms"-mode
|
||||
// so we can keep the old keywords in their old mode, but add the new ones as required words
|
||||
if ($add_keywords)
|
||||
{
|
||||
if ($search_terms == 'all')
|
||||
{
|
||||
$keywords .= ' ' . $add_keywords;
|
||||
}
|
||||
else
|
||||
{
|
||||
$search_terms = 'all';
|
||||
$keywords = implode(' |', explode(' ', preg_replace('#\s+#', ' ', $keywords))) . ' ' .$add_keywords;
|
||||
}
|
||||
}
|
||||
|
||||
// Select which method we'll use to obtain the post_id or topic_id information
|
||||
$search_type = $config['search_type'];
|
||||
|
||||
if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx))
|
||||
{
|
||||
trigger_error('NO_SUCH_SEARCH_MODULE');
|
||||
}
|
||||
|
||||
require("{$phpbb_root_path}includes/search/$search_type.$phpEx");
|
||||
|
||||
// We do some additional checks in the module to ensure it can actually be utilised
|
||||
$error = false;
|
||||
$search = new $search_type($error);
|
||||
|
||||
if ($error)
|
||||
{
|
||||
trigger_error($error);
|
||||
}
|
||||
|
||||
// let the search module split up the keywords
|
||||
if ($keywords)
|
||||
{
|
||||
$search->split_keywords($keywords, $search_terms);
|
||||
if (!sizeof($search->split_words) && !sizeof($author_id_ary) && !$search_id)
|
||||
{
|
||||
trigger_error(sprintf($user->lang['NO_KEYWORDS'], $config['min_search_chars'], $config['max_search_chars']));
|
||||
}
|
||||
}
|
||||
|
||||
// define some variables needed for retrieving post_id/topic_id information
|
||||
$per_page = ($show_results == 'posts') ? $config['posts_per_page'] : $config['topics_per_page'];
|
||||
$sort_by_sql = array('a' => (($show_results == 'posts') ? 'u.username' : 't.topic_poster'), 't' => (($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time'), 'f' => 'f.forum_id', 'i' => 't.topic_title', 's' => (($show_results == 'posts') ? 'p.post_subject' : 't.topic_title'));
|
||||
|
||||
// pre-made searches
|
||||
$sql = $field = '';
|
||||
if ($search_id)
|
||||
{
|
||||
$sql_in = $sql_where = '';
|
||||
// Build sql string for sorting
|
||||
$sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
|
||||
|
||||
switch ($search_id)
|
||||
{
|
||||
// Oh holy Bob, bring us some activity...
|
||||
case 'active_topics':
|
||||
$show_results = 'topics';
|
||||
$sort_key = 't';
|
||||
$sort_dir = 'd';
|
||||
$sort_by_sql['t'] = 't.topic_last_post_time';
|
||||
|
||||
if (!$sort_days)
|
||||
{
|
||||
$sort_days = 1;
|
||||
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
|
||||
}
|
||||
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
|
||||
$s_sort_key = $s_sort_dir = $u_sort_param = '';
|
||||
|
||||
$last_post_time = (time() - ($sort_days * 24 * 3600));
|
||||
|
||||
|
@ -165,213 +243,113 @@ if ($keywords || $author || $search_id || $search_session_id)
|
|||
FROM ' . POSTS_TABLE . ' p
|
||||
LEFT JOIN ' . TOPICS_TABLE . " t ON (t.topic_approved = 1 AND p.topic_id = t.topic_id)
|
||||
WHERE p.post_time > $last_post_time
|
||||
" . ((sizeof($fid_ary)) ? ' AND p.forum_id IN (' . implode(',', $fid_ary) . ')' : '') . '
|
||||
" . ((sizeof($ex_fid_ary)) ? ' AND p.forum_id NOT IN (' . implode(',', $ex_fid_ary) . ')' : '') . '
|
||||
ORDER BY t.topic_last_post_time DESC';
|
||||
$result = $db->sql_query_limit($sql, 1000);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$pid_ary[] = $row['topic_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
break;
|
||||
|
||||
case 'egosearch':
|
||||
$field = 'topic_id';
|
||||
break;
|
||||
|
||||
case 'unanswered':
|
||||
$sort_join = ($sort_key == 'f') ? FORUMS_TABLE . ' f, ' : '';
|
||||
$sql_sort = ($sort_key == 'f') ? ' AND f.forum_id = p.forum_id ' . $sql_sort : $sql_sort;
|
||||
if ($show_results == 'posts')
|
||||
{
|
||||
$sql = 'SELECT p.post_id
|
||||
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
|
||||
if ($sort_key == 'a')
|
||||
{
|
||||
$sort_join = USERS_TABLE . ' u, ';
|
||||
$sql_sort = ' AND u.user_id = p.poster_id ' . $sql_sort;
|
||||
}
|
||||
$sql = "SELECT p.post_id
|
||||
FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
|
||||
WHERE t.topic_replies = 0
|
||||
AND p.topic_id = t.topic_id
|
||||
" . ((sizeof($fid_ary)) ? ' AND p.forum_id IN (' . implode(',', $fid_ary) . ')' : '');
|
||||
" . ((sizeof($ex_fid_ary)) ? ' AND p.forum_id NOT IN (' . implode(',', $ex_fid_ary) . ')' : '') . "
|
||||
$sql_sort";
|
||||
$field = 'post_id';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'SELECT t.topic_id
|
||||
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
|
||||
$sql = "SELECT DISTINCT p.topic_id
|
||||
FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
|
||||
WHERE t.topic_replies = 0
|
||||
AND p.topic_id = t.topic_id
|
||||
" . ((sizeof($fid_ary)) ? ' AND p.forum_id IN (' . implode(',', $fid_ary) . ')' : '') . '
|
||||
GROUP BY p.topic_id';
|
||||
" . ((sizeof($ex_fid_ary)) ? ' AND p.forum_id NOT IN (' . implode(',', $ex_fid_ary) . ')' : '') . "
|
||||
$sql_sort";
|
||||
$field = 'topic_id';
|
||||
}
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$pid_ary[] = $row[$field];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!sizeof($pid_ary))
|
||||
{
|
||||
trigger_error($user->lang['NO_SEARCH_RESULTS']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'newposts':
|
||||
$sort_join = ($sort_key == 'f') ? FORUMS_TABLE . ' f, ' : '';
|
||||
$sql_sort = ($sort_key == 'f') ? ' AND f.forum_id = p.forum_id ' . $sql_sort : $sql_sort;
|
||||
if ($show_results == 'posts')
|
||||
{
|
||||
$sql = 'SELECT p.post_id
|
||||
FROM ' . POSTS_TABLE . ' p
|
||||
if ($sort_key == 'i')
|
||||
{
|
||||
$sort_join = TOPICS_TABLE . ' t, ';
|
||||
$sql_sort = ' AND t.topic_id = p.topic_id ' . $sql_sort;
|
||||
}
|
||||
elseif ($sort_key == 'a')
|
||||
{
|
||||
$sort_join = USERS_TABLE . ' u, ';
|
||||
$sql_sort = ' AND u.user_id = p.poster_id ' . $sql_sort;
|
||||
}
|
||||
|
||||
$sql = "SELECT p.post_id
|
||||
FROM $sort_join" . POSTS_TABLE . ' p
|
||||
WHERE p.post_time > ' . $user->data['user_lastvisit'] . "
|
||||
" . ((sizeof($fid_ary)) ? ' AND p.forum_id IN (' . implode(',', $fid_ary) . ')' : '');
|
||||
" . ((sizeof($ex_fid_ary)) ? ' AND p.forum_id NOT IN (' . implode(',', $ex_fid_ary) . ')' : '') . "
|
||||
$sql_sort";
|
||||
$field = 'post_id';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'SELECT t.topic_id
|
||||
FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
|
||||
$sql = "SELECT DISTINCT p.topic_id
|
||||
FROM $sort_join" . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
|
||||
WHERE p.post_time > ' . $user->data['user_lastvisit'] . "
|
||||
AND t.topic_id = p.topic_id
|
||||
" . ((sizeof($fid_ary)) ? ' AND p.forum_id IN (' . implode(',', $fid_ary) . ')' : '') . '
|
||||
GROUP by p.topic_id';
|
||||
" . ((sizeof($ex_fid_ary)) ? ' AND p.forum_id NOT IN (' . implode(',', $ex_fid_ary) . ')' : '') . "
|
||||
$sql_sort";
|
||||
$field = 'topic_id';
|
||||
}
|
||||
$result = $db->sql_query($sql);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($sql)
|
||||
{
|
||||
// only return up to 1000 ids (the last one will be removed later)
|
||||
$result = $db->sql_query_limit($sql, 1001 - $start, $start);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$pid_ary[] = $row[$field];
|
||||
$id_ary[] = $row[$field];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!sizeof($pid_ary))
|
||||
$total_match_count = sizeof($id_ary) + $start;
|
||||
$id_ary = array_slice($id_ary, 0, $per_page);
|
||||
}
|
||||
else
|
||||
{
|
||||
$search_id = '';
|
||||
}
|
||||
}
|
||||
|
||||
if (sizeof($search->split_words))
|
||||
{
|
||||
$total_match_count = $search->keyword_search($show_results, $search_fields, $search_terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $topic_id, $author_id_ary, $id_ary, $start, $per_page);
|
||||
}
|
||||
else if (sizeof($author_id_ary))
|
||||
{
|
||||
$total_match_count = $search->author_search($show_results, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $topic_id, $author_id_ary, $id_ary, $start, $per_page);
|
||||
}
|
||||
|
||||
if (!sizeof($id_ary))
|
||||
{
|
||||
trigger_error($user->lang['NO_SEARCH_RESULTS']);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo add to config
|
||||
*/
|
||||
$config['search_type'] = 'phpbb';
|
||||
|
||||
// Select which method we'll use to obtain the post_id information
|
||||
$smid = '';
|
||||
switch ($config['search_type'])
|
||||
{
|
||||
case 'phpbb':
|
||||
$smid = 'fulltext_phpbb';
|
||||
break;
|
||||
case 'mysql':
|
||||
$smid = 'fulltext_mysql';
|
||||
break;
|
||||
/* case 'mssql':
|
||||
case 'pgsql':
|
||||
$smid = 'fulltext_pgmssql';
|
||||
break;
|
||||
case 'like':
|
||||
$smid = 'like';
|
||||
break;
|
||||
case 'preg':
|
||||
$smid = 'preg_mysql';
|
||||
break;*/
|
||||
default:
|
||||
trigger_error('NO_SUCH_SEARCH_MODULE');
|
||||
}
|
||||
|
||||
require($phpbb_root_path . 'includes/search/' . $smid . '.' . $phpEx);
|
||||
|
||||
// We do some additional checks in each module to ensure it can actually be utilised
|
||||
$error = false;
|
||||
$search = new $smid($error);
|
||||
|
||||
if ($error)
|
||||
{
|
||||
trigger_error($error);
|
||||
}
|
||||
|
||||
if ($search_session_id)
|
||||
{
|
||||
$sql = 'SELECT search_array
|
||||
FROM ' . SEARCH_TABLE . "
|
||||
WHERE search_id = $search_session_id
|
||||
AND session_id = '" . $db->sql_escape($user->data['session_id']) . "'";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$pid_ary = explode('#', $row['search_array']);
|
||||
|
||||
$search->split_words = unserialize(array_shift($pid_ary));
|
||||
if ($keywords)
|
||||
{
|
||||
// If we're wanting to search on these results we store the existing split word array
|
||||
$search->old_split_words = $search->split_words;
|
||||
}
|
||||
$search->common_words = unserialize(array_shift($pid_ary));
|
||||
|
||||
foreach ($store_vars as $var)
|
||||
{
|
||||
$$var = array_shift($pid_ary);
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
$total_match_count = 0;
|
||||
$search->search($show_results, $search_fields, $search_terms, $fid_ary, $keywords, $author_id, $pid_ary, $sort_days);
|
||||
|
||||
if ($pid_ary)
|
||||
{
|
||||
// Finish building query (for all combinations) and run it ...
|
||||
$sql = 'SELECT session_id
|
||||
FROM ' . SESSIONS_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$delete_search_ids = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$delete_search_ids[] = "'" . $db->sql_escape($row['session_id']) . "'";
|
||||
}
|
||||
|
||||
if (sizeof($delete_search_ids))
|
||||
{
|
||||
$sql = 'DELETE FROM ' . SEARCH_TABLE . '
|
||||
WHERE session_id NOT IN (' . implode(", ", $delete_search_ids) . ')';
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
$total_match_count = sizeof($pid_ary);
|
||||
$sql_where = (($show_results == 'posts') ? 'p.post_id' : 't.topic_id') . ' IN (' . implode(', ', $pid_ary) . ')';
|
||||
|
||||
if (sizeof($search->old_split_words) && array_diff($search->split_words, $search->old_split_words))
|
||||
{
|
||||
$search->split_words = array_merge($search->split_words, $search->old_split_words);
|
||||
}
|
||||
|
||||
$data = serialize($search->split_words);
|
||||
$data .= '#' . serialize($search->common_words);
|
||||
|
||||
foreach ($store_vars as $var)
|
||||
{
|
||||
$data .= '#' . $$var;
|
||||
}
|
||||
$data .= '#' . implode('#', $pid_ary);
|
||||
|
||||
unset($pid_ary);
|
||||
|
||||
srand ((double) microtime() * 1000000);
|
||||
$search_session_id = rand();
|
||||
|
||||
$sql_ary = array(
|
||||
'search_id' => $search_session_id,
|
||||
'session_id' => $user->data['session_id'],
|
||||
'search_time' => $current_time,
|
||||
'search_array' => $data
|
||||
);
|
||||
|
||||
$sql = 'INSERT INTO ' . SEARCH_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
|
||||
$db->sql_query($sql);
|
||||
unset($data);
|
||||
}
|
||||
$sql_where = (($show_results == 'posts') ? 'p.post_id' : 't.topic_id') . ' IN (' . implode(', ', $id_ary) . ')';
|
||||
$sql_where .= (sizeof($ex_fid_ary)) ? ' AND f.forum_id NOT IN (' . implode(',', $ex_fid_ary) . ')' : '';
|
||||
|
||||
if ($show_results == 'posts')
|
||||
{
|
||||
|
@ -382,51 +360,70 @@ if ($keywords || $author || $search_id || $search_session_id)
|
|||
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
||||
}
|
||||
|
||||
// Look up data ...
|
||||
$per_page = ($show_results == 'posts') ? $config['posts_per_page'] : $config['topics_per_page'];
|
||||
|
||||
// Grab icons
|
||||
$icons = array();
|
||||
$cache->obtain_icons($icons);
|
||||
|
||||
// Output header
|
||||
if ($search_id && ($total_match_count > 1000))
|
||||
{
|
||||
// limit the number to 1000 for pre-made searches
|
||||
$total_match_count--;
|
||||
$l_search_matches = sprintf($user->lang['FOUND_MORE_SEARCH_MATCHES'], $total_match_count);
|
||||
}
|
||||
else
|
||||
{
|
||||
$l_search_matches = ($total_match_count == 1) ? sprintf($user->lang['FOUND_SEARCH_MATCH'], $total_match_count) : sprintf($user->lang['FOUND_SEARCH_MATCHES'], $total_match_count);
|
||||
}
|
||||
|
||||
// define some vars for urls
|
||||
$hilit = htmlspecialchars(implode('|', str_replace(array('+', '-', '|'), '', $search->split_words)));
|
||||
$split_words = (sizeof($search->split_words)) ? htmlspecialchars(implode(' ', $search->split_words)) : '';
|
||||
$u_hilit = urlencode($split_words);
|
||||
$u_show_results = ($show_results != 'topic') ? '&sr=' . $show_results : '';
|
||||
$u_search_forum = implode('&fid%5B%5D=', $search_forum);
|
||||
|
||||
$u_search = "{$phpbb_root_path}search.$phpEx$SID";
|
||||
$u_search .= ($search_id) ? '&search_id=' . $search_id : '';
|
||||
$u_search .= ($u_hilit) ? '&keywords=' . $u_hilit : '';
|
||||
$u_search .= ($topic_id) ? '&ch=' . $topic_id : '';
|
||||
$u_search .= ($author) ? '&author=' . urlencode($author) : '';
|
||||
$u_search .= ($u_search_forum) ? '&fid%5B%5D=' . $u_search_forum : '';
|
||||
$u_search .= (!$search_child) ? '&sc=0' : '';
|
||||
$u_search .= ($search_fields != 'all') ? '&sf=' . $search_fields : '';
|
||||
$u_search .= '&' . $u_sort_param . $u_show_results;
|
||||
$u_search .= ($return_chars != 200) ? '&ch=' . $return_chars : '';
|
||||
|
||||
|
||||
$template->assign_vars(array(
|
||||
'SEARCH_MATCHES' => $l_search_matches,
|
||||
'SEARCH_WORDS' => $split_words,
|
||||
'IGNORED_WORDS' => (sizeof($search->common_words)) ? htmlspecialchars(implode(' ', $search->common_words)) : '',
|
||||
'PAGINATION' => generate_pagination("{$phpbb_root_path}search.$phpEx$SID&search_session_id=$search_session_id&search_id=$search_id&hilit=$hilit&$u_sort_param", $total_match_count, $per_page, $start),
|
||||
'PAGINATION' => generate_pagination($u_search, $total_match_count, $per_page, $start),
|
||||
'PAGE_NUMBER' => on_page($total_match_count, $per_page, $start),
|
||||
'TOTAL_MATCHES' => $total_match_count,
|
||||
'SEARCH_IN_RESULTS' => ($search_id) ? false : true,
|
||||
|
||||
'S_SELECT_SORT_DIR' => $s_sort_dir,
|
||||
'S_SELECT_SORT_KEY' => $s_sort_key,
|
||||
'S_SELECT_SORT_DAYS' => $s_limit_days,
|
||||
'S_SEARCH_ACTION' => "{$phpbb_root_path}search.$phpEx$SID&search_session_id=$search_session_id&search_id=$search_id",
|
||||
'S_SEARCH_ACTION' => $u_search,
|
||||
'S_SHOW_TOPICS' => ($show_results == 'posts') ? false : true,
|
||||
|
||||
'REPORTED_IMG' => $user->img('icon_reported', 'TOPIC_REPORTED'),
|
||||
'UNAPPROVED_IMG' => $user->img('icon_unapproved', 'TOPIC_UNAPPROVED'),
|
||||
'GOTO_PAGE_IMG' => $user->img('icon_post', 'GOTO_PAGE'),
|
||||
|
||||
'U_SEARCH_WORDS' => "{$phpbb_root_path}search.$phpEx$SID&show_results=$show_results&keywords=" . urlencode($split_words))
|
||||
'U_SEARCH_WORDS' => "{$phpbb_root_path}search.$phpEx$SID$u_show_results&keywords=$u_hilit")
|
||||
);
|
||||
|
||||
$u_hilit = urlencode($split_words);
|
||||
|
||||
// Define ordering sql field, do it here because the order may be defined
|
||||
// within an existing search result set
|
||||
$sort_by_sql = array('a' => (($show_results == 'posts') ? 'u.username' : 't.topic_poster'), 't' => (($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time'), 'f' => 'f.forum_id', 'i' => 't.topic_title', 's' => (($show_results == 'posts') ? 'pt.post_subject' : 't.topic_title'));
|
||||
|
||||
if ($sql_where)
|
||||
{
|
||||
if ($show_results == 'posts')
|
||||
{
|
||||
// Not joining this query to the one below at present ... may do in future
|
||||
/**
|
||||
* @todo Joining this query to the one below?
|
||||
*/
|
||||
$sql = 'SELECT zebra_id, friend, foe
|
||||
FROM ' . ZEBRA_TABLE . '
|
||||
WHERE user_id = ' . $user->data['user_id'];
|
||||
|
@ -454,14 +451,16 @@ if ($keywords || $author || $search_id || $search_session_id)
|
|||
AND f.forum_id = t.forum_id";
|
||||
}
|
||||
$sql .= ' ORDER BY ' . $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
|
||||
$result = $db->sql_query_limit($sql, $per_page, $start);
|
||||
$result = $db->sql_query($sql);
|
||||
$result_topic_id = 0;
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$forum_id = $row['forum_id'];
|
||||
$topic_id = $row['topic_id'];
|
||||
$result_topic_id = $row['topic_id'];
|
||||
$topic_title = censor_text($row['topic_title']);
|
||||
|
||||
$view_topic_url = "{$phpbb_root_path}viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&hilit=$u_hilit";
|
||||
$view_topic_url = "{$phpbb_root_path}viewtopic.$phpEx$SID&f=$forum_id&t=$result_topic_id&hilit=$u_hilit";
|
||||
|
||||
if ($show_results == 'topics')
|
||||
{
|
||||
|
@ -497,8 +496,8 @@ if ($keywords || $author || $search_id || $search_session_id)
|
|||
|
||||
'U_LAST_POST' => $view_topic_url . '&p=' . $row['topic_last_post_id'] . '#' . $row['topic_last_post_id'],
|
||||
'U_LAST_POST_AUTHOR'=> ($row['topic_last_poster_id'] != ANONYMOUS && $row['topic_last_poster_id']) ? "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&u={$row['topic_last_poster_id']}" : '',
|
||||
'U_MCP_REPORT' => "{$phpbb_root_path}mcp.$phpEx?sid={$user->session_id}&mode=reports&t=$topic_id",
|
||||
'U_MCP_QUEUE' => "{$phpbb_root_path}mcp.$phpEx?sid={$user->session_id}&i=queue&mode=approve_details&t=$topic_id"
|
||||
'U_MCP_REPORT' => "{$phpbb_root_path}mcp.$phpEx?sid={$user->session_id}&mode=reports&t=$result_topic_id",
|
||||
'U_MCP_QUEUE' => "{$phpbb_root_path}mcp.$phpEx?sid={$user->session_id}&i=queue&mode=approve_details&t=$result_topic_id"
|
||||
);
|
||||
}
|
||||
else
|
||||
|
@ -508,7 +507,7 @@ if ($keywords || $author || $search_id || $search_session_id)
|
|||
$template->assign_block_vars('searchresults', array(
|
||||
'S_IGNORE_POST' => true,
|
||||
|
||||
'L_IGNORE_POST' => sprintf($user->lang['POST_BY_FOE'], $row['username'], "<a href=\"search.$phpEx$SID&search_session_id=$search_session_id&$u_sort_param&p=" . $row['post_id'] . '&view=show#' . $row['post_id'] . '">', '</a>'))
|
||||
'L_IGNORE_POST' => sprintf($user->lang['POST_BY_FOE'], $row['username'], "<a href=\"$u_search&p=" . $row['post_id'] . '&view=show#' . $row['post_id'] . '">', '</a>'))
|
||||
);
|
||||
|
||||
continue;
|
||||
|
@ -519,29 +518,28 @@ if ($keywords || $author || $search_id || $search_session_id)
|
|||
$row['post_text'] = preg_replace('#(<!\-\- h \-\-><)([\/]?.*?)(><!\-\- h \-\->)#is', "<\\2>", $row['post_text']);
|
||||
}
|
||||
|
||||
$row['post_text'] = censor_text($row['post_text']);
|
||||
decode_message($row['post_text'], $row['bbcode_uid']);
|
||||
|
||||
if ($return_chars)
|
||||
if ($return_chars != -1)
|
||||
{
|
||||
$row['post_text'] = (strlen($row['post_text']) < $return_chars + 3) ? $row['post_text'] : substr($row['post_text'], 0, $return_chars) . '...';
|
||||
}
|
||||
|
||||
if ($hilit)
|
||||
{
|
||||
$row['post_text'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*>)#i', '<span class="posthilit">\1</span>', $row['post_text']);
|
||||
}
|
||||
|
||||
$row['post_text'] = smiley_text($row['post_text']);
|
||||
|
||||
// Replace naughty words such as farty pants
|
||||
$row['post_subject'] = censor_text($row['post_subject']);
|
||||
$row['post_text'] = str_replace("\n", '<br />', censor_text($row['post_text']));
|
||||
|
||||
if ($hilit)
|
||||
{
|
||||
$row['post_text'] = preg_replace('#(?!<.*)(?<!\w)(' . preg_quote($hilit) . ')(?!\w|[^<>]*>)#i', '<span class="posthilit">$1</span>', $row['post_text']);
|
||||
}
|
||||
|
||||
$row['post_text'] = smiley_text($row['post_text']);
|
||||
|
||||
$tpl_ary = array(
|
||||
'POSTER_NAME' => ($row['poster_id'] == ANONYMOUS) ? ((!empty($row['post_username'])) ? $row['post_username'] : $user->lang['GUEST']) : $row['username'],
|
||||
'U_PROFILE' => ($row['poster_id'] != ANONYMOUS) ? "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&u={$row['poster_id']}" : '',
|
||||
'POST_SUBJECT' => censor_text($row['post_subject']),
|
||||
'POST_SUBJECT' => $row['post_subject'],
|
||||
'POST_DATE' => (!empty($row['post_time'])) ? $user->format_date($row['post_time']) : '',
|
||||
'MESSAGE' => $row['post_text']
|
||||
);
|
||||
|
@ -549,11 +547,11 @@ if ($keywords || $author || $search_id || $search_session_id)
|
|||
|
||||
$template->assign_block_vars('searchresults', array_merge($tpl_ary, array(
|
||||
'FORUM_ID' => $forum_id,
|
||||
'TOPIC_ID' => $topic_id,
|
||||
'TOPIC_ID' => $result_topic_id,
|
||||
'POST_ID' => ($show_results == 'posts') ? $row['post_id'] : false,
|
||||
|
||||
'FORUM_TITLE' => $row['forum_name'],
|
||||
'TOPIC_TITLE' => censor_text($row['topic_title']),
|
||||
'TOPIC_TITLE' => $topic_title,
|
||||
|
||||
'U_VIEW_TOPIC' => $view_topic_url,
|
||||
'U_VIEW_FORUM' => "viewforum.$phpEx$SID&f=$forum_id",
|
||||
|
@ -561,6 +559,14 @@ if ($keywords || $author || $search_id || $search_session_id)
|
|||
));
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($topic_id && ($topic_id == $result_topic_id))
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'SEARCH_TOPIC' => $topic_title,
|
||||
'U_SEARCH_TOPIC' => $view_topic_url
|
||||
));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -592,7 +598,6 @@ $result = $db->sql_query($sql);
|
|||
$right = $cat_right = $padding_inc = 0;
|
||||
$padding = $forum_list = $holding = '';
|
||||
$pad_store = array('0' => '');
|
||||
$search_forums = array();
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
|
@ -620,7 +625,7 @@ while ($row = $db->sql_fetchrow($result))
|
|||
|
||||
$right = $row['right_id'];
|
||||
|
||||
$selected = (!sizeof($search_forums) || in_array($row['forum_id'], $search_forums)) ? ' selected="selected"' : '';
|
||||
$selected = (!sizeof($search_forum) || in_array($row['forum_id'], $search_forum)) ? ' selected="selected"' : '';
|
||||
|
||||
if ($row['left_id'] > $cat_right)
|
||||
{
|
||||
|
@ -655,7 +660,8 @@ for ($i = 100; $i <= 1000 ; $i += 100)
|
|||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_SEARCH_ACTION' => "{$phpbb_root_path}search.$phpEx$SID&mode=results",
|
||||
'S_SEARCH_ACTION' => "{$phpbb_root_path}search.$phpEx",
|
||||
'S_HIDDEN_FIELDS' => build_hidden_fields(array('sid' => $user->session_id)),
|
||||
'S_CHARACTER_OPTIONS' => $s_characters,
|
||||
'S_FORUM_OPTIONS' => $s_forums,
|
||||
'S_SELECT_SORT_DIR' => $s_sort_dir,
|
||||
|
@ -663,38 +669,22 @@ $template->assign_vars(array(
|
|||
'S_SELECT_SORT_DAYS' => $s_limit_days)
|
||||
);
|
||||
|
||||
$sql = 'SELECT search_id, search_time, search_array
|
||||
$sql = 'SELECT search_time, search_keywords
|
||||
FROM ' . SEARCH_TABLE . '
|
||||
WHERE search_keywords <> \'\'
|
||||
ORDER BY search_time DESC';
|
||||
$result = $db->sql_query($sql);
|
||||
$result = $db->sql_query_limit($sql, 5);
|
||||
|
||||
$i = 0;
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($i == 5)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
$data = explode('#', $row['search_array']);
|
||||
$split_words = htmlspecialchars(implode(' ', unserialize(array_shift($data))));
|
||||
|
||||
if (!$split_words)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$common_words = htmlspecialchars(implode(' ', unserialize(array_shift($data))));
|
||||
unset($data);
|
||||
$keywords = htmlspecialchars($row['search_keywords']);
|
||||
|
||||
$template->assign_block_vars('recentsearch', array(
|
||||
'KEYWORDS' => $split_words,
|
||||
'KEYWORDS' => $keywords,
|
||||
'TIME' => $user->format_date($row['search_time']),
|
||||
|
||||
'U_KEYWORDS' => "{$phpbb_root_path}search.$phpEx$SID&keywords=" . urlencode($split_words))
|
||||
'U_KEYWORDS' => "{$phpbb_root_path}search.$phpEx$SID&keywords=" . urlencode($keywords))
|
||||
);
|
||||
|
||||
$i++;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
|
||||
<div id="pagecontent">
|
||||
|
||||
<form method="post" action="{S_SEARCH_ACTION}"><table class="tablebg" width="100%" cellspacing="1">
|
||||
<form method="get" action="{S_SEARCH_ACTION}"><table class="tablebg" width="100%" cellspacing="1">
|
||||
<tr>
|
||||
<th colspan="4">{L_SEARCH_QUERY}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1" colspan="2" width="50%"><b class="genmed">{L_SEARCH_KEYWORDS}: </b><br /><span class="gensmall">{L_SEARCH_KEYWORDS_EXPLAIN}</span></td>
|
||||
<td class="row2" colspan="2" valign="top"><input type="text" style="width: 300px" class="post" name="keywords" size="30" /><br /><input type="radio" name="search_terms" value="all" checked="checked" /> <span class="genmed">{L_SEARCH_ALL_TERMS}</span><br /><input type="radio" name="search_terms" value="any" /> <span class="genmed">{L_SEARCH_ANY_TERMS}</span></td>
|
||||
<td class="row2" colspan="2" valign="top"><input type="text" style="width: 300px" class="post" name="keywords" size="30" /><br /><input type="radio" name="terms" value="all" checked="checked" /> <span class="genmed">{L_SEARCH_ALL_TERMS}</span><br /><input type="radio" name="terms" value="any" /> <span class="genmed">{L_SEARCH_ANY_TERMS}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1" colspan="2"><b class="genmed">{L_SEARCH_AUTHOR}:</b><br /><span class="gensmall">{L_SEARCH_AUTHOR_EXPLAIN}</span></td>
|
||||
|
@ -18,28 +18,28 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td class="row1" colspan="2"><b class="genmed">{L_SEARCH_FORUMS}: </b><br /><span class="gensmall">{L_SEARCH_FORUMS_EXPLAIN}</span></td>
|
||||
<td class="row2" colspan="2"><select name="search_forum[]" multiple="multiple" size="5">{S_FORUM_OPTIONS}</select></td>
|
||||
<td class="row2" colspan="2"><select name="fid[]" multiple="multiple" size="5">{S_FORUM_OPTIONS}</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="4">{L_SEARCH_OPTIONS}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1" width="25%" nowrap="nowrap"><b class="genmed">{L_SEARCH_SUBFORUMS}: </b></td>
|
||||
<td class="row2" width="25%" nowrap="nowrap"><input type="radio" name="search_child" value="1" checked="checked" /> <span class="genmed">{L_YES}</span> <input type="radio" name="search_child" value="0" /> <span class="genmed">{L_NO}</span></td>
|
||||
<td class="row2" width="25%" nowrap="nowrap"><input type="radio" name="sc" value="1" checked="checked" /> <span class="genmed">{L_YES}</span> <input type="radio" name="sc" value="0" /> <span class="genmed">{L_NO}</span></td>
|
||||
<td class="row1" width="25%" nowrap="nowrap"><b class="genmed">{L_SEARCH_WITHIN}: </b></td>
|
||||
<td class="row2" width="25%" nowrap="nowrap"><input type="radio" name="search_fields" value="all" checked="checked" /> <span class="genmed">{L_SEARCH_TITLE_MSG}</span><br /><input type="radio" name="search_fields" value="msgonly" /> <span class="genmed">{L_SEARCH_MSG_ONLY}</span> <br /><input type="radio" name="search_fields" value="titleonly" /> <span class="genmed">{L_SEARCH_TITLE_ONLY}</span></td>
|
||||
<td class="row2" width="25%" nowrap="nowrap"><input type="radio" name="sf" value="all" checked="checked" /> <span class="genmed">{L_SEARCH_TITLE_MSG}</span><br /><input type="radio" name="sf" value="msgonly" /> <span class="genmed">{L_SEARCH_MSG_ONLY}</span> <br /><input type="radio" name="sf" value="titleonly" /> <span class="genmed">{L_SEARCH_TITLE_ONLY}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1"><b class="genmed">{L_RESULT_SORT}: </b></td>
|
||||
<td class="row2" nowrap="nowrap">{S_SELECT_SORT_KEY}<br /><input type="radio" name="sd" value="a" /> <span class="genmed">{L_SORT_ASCENDING}</span><br /><input type="radio" name="sd" value="d" checked="checked" /> <span class="genmed">{L_SORT_DESCENDING}</span></td>
|
||||
<td class="row1" nowrap="nowrap"><b class="genmed">{L_DISPLAY_RESULTS}: </b></td>
|
||||
<td class="row2" nowrap="nowrap"><input type="radio" name="show_results" value="posts" /> <span class="genmed">{L_POSTS}</span> <input type="radio" name="show_results" value="topics" checked="checked" /> <span class="genmed">{L_TOPICS}</td>
|
||||
<td class="row2" nowrap="nowrap"><input type="radio" name="sr" value="posts" /> <span class="genmed">{L_POSTS}</span> <input type="radio" name="sr" value="topics" checked="checked" /> <span class="genmed">{L_TOPICS}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1" width="25%"><b class="genmed">{L_RESULT_DAYS}: </b></td>
|
||||
<td class="row2" width="25%" nowrap="nowrap">{S_SELECT_SORT_DAYS}</td>
|
||||
<td class="row1" nowrap="nowrap"><b class="genmed">{L_RETURN_FIRST}: </b></td>
|
||||
<td class="row2" nowrap="nowrap"><select name="return_chars">{S_CHARACTER_OPTIONS}</select> <span class="genmed">{L_POST_CHARACTERS}</span></td>
|
||||
<td class="row2" nowrap="nowrap"><select name="ch">{S_CHARACTER_OPTIONS}</select> <span class="genmed">{L_POST_CHARACTERS}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cat" colspan="4" align="center">{S_HIDDEN_FIELDS}<input class="btnlite" type="submit" value="{L_SEARCH}" /> <input class="btnlite" type="reset" value="{L_RESET}" /></td>
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
<td colspan="2"><span class="titles">{SEARCH_MATCHES}</span><br /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="genmed"><!-- IF SEARCH_WORDS -->{L_SEARCHED_FOR}: <a href="{U_SEARCH_WORDS}"><b>{SEARCH_WORDS}</b></a><!-- ENDIF --><!-- IF IGNORED_WORDS --> {L_IGNORED_TERMS}: <b>{IGNORED_WORDS}</b><!-- ENDIF --></td>
|
||||
<td align="right"><span class="genmed">{L_SEARCH_IN_RESULTS}: </span><input type="text" name="keywords" value="" /> <input class="btnlite" type="submit" name="submit" value="{L_GO}" /></td>
|
||||
<td class="genmed"><!-- IF SEARCH_TOPIC -->{L_SEARCHED_TOPIC}: <a href="{U_SEARCH_TOPIC}"><b>{SEARCH_TOPIC}</b></a><br /><!-- ENDIF --><!-- IF SEARCH_WORDS -->{L_SEARCHED_FOR}: <a href="{U_SEARCH_WORDS}"><b>{SEARCH_WORDS}</b></a><!-- ENDIF --><!-- IF IGNORED_WORDS --> {L_IGNORED_TERMS}: <b>{IGNORED_WORDS}</b><!-- ENDIF --></td>
|
||||
<td align="right"><!-- IF SEARCH_IN_RESULTS --><span class="genmed">{L_SEARCH_IN_RESULTS}: </span><input type="text" name="add_keywords" value="" /> <input class="btnlite" type="submit" name="submit" value="{L_GO}" /><!-- ENDIF --></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
@ -64,7 +64,7 @@
|
|||
</tr>
|
||||
<!-- END searchresults -->
|
||||
<tr>
|
||||
<td class="cat" colspan="7" valign="middle" align="center"><span class="gensmall">{L_DISPLAY_POSTS}:</span> {S_SELECT_SORT_DAYS} <span class="gensmall">{L_SORT_BY}:</span> {S_SELECT_SORT_KEY} {S_SELECT_SORT_DIR} <input class="btnlite" type="submit" value="{L_GO}" name="sort" /></td>
|
||||
<td class="cat" colspan="7" valign="middle" align="center"><span class="gensmall">{L_DISPLAY_POSTS}:</span> {S_SELECT_SORT_DAYS}<!-- IF S_SELECT_SORT_KEY --> <span class="gensmall">{L_SORT_BY}:</span> {S_SELECT_SORT_KEY} {S_SELECT_SORT_DIR} <input class="btnlite" type="submit" value="{L_GO}" name="sort" /><!-- ENDIF --></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue