|
From: Paul S. O. <ps...@us...> - 2002-01-25 00:48:49
|
Update of /cvsroot/phpbb/phpBB2/includes
In directory usw-pr-cvs1:/tmp/cvs-serv26164/includes
Modified Files:
search.php
Log Message:
Various updates to fix problems with large result sets ... code is quite messy, will clean up
Index: search.php
===================================================================
RCS file: /cvsroot/phpbb/phpBB2/includes/search.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** search.php 2002/01/14 14:17:18 1.2
--- search.php 2002/01/25 00:48:46 1.3
***************
*** 20,28 ****
***************************************************************************/
! function clean_words($mode, $entry, &$stopword_list, &$synonym_list)
{
// Weird, $init_match doesn't work with static when double quotes (") are used...
! static $drop_char_match = array('^', '$', '&', '(', ')', '<', '>', '`', "'", '|', ',', '@', '_', '?', '%', '-', '~', '+', '.', '[', ']', '{', '}', ':', '\\', '/', '=', '#', '\'', ';', '*', '!');
! static $drop_char_replace = array(" ", " ", " ", " ", " ", " ", " ", " ", "", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " , " ", " ", " ", " ", " ", " ", " ");
static $accent_match = array("ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ");
--- 20,28 ----
***************************************************************************/
! function clean_words($mode, &$entry, &$synonym_list)
{
// Weird, $init_match doesn't work with static when double quotes (") are used...
! static $drop_char_match = array('^', '$', '&', '(', ')', '<', '>', '`', "'", '|', ',', '@', '_', '?', '%', '-', '~', '+', '.', '[', ']', '{', '}', ':', '\\', '/', '=', '#', '\'', ';', '!');
! static $drop_char_replace = array(" ", " ", " ", " ", " ", " ", " ", " ", "", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " , " ", " ", " ", " ", " ", " ");
static $accent_match = array("ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ");
***************
*** 63,86 ****
for($i = 0; $i < count($drop_char_match); $i++)
{
! $entry = str_replace($drop_char_match[$i], $drop_char_replace[$i], $entry);
}
if( $mode == "post" )
{
! // 'words' that consist of <=2 or >=50 characters are removed.
! $entry = preg_replace("/\b([a-z0-9]{1,2}|[a-z0-9]{50,})\b/si", " ", $entry);
! }
!
! if( !empty($stopword_list) )
! {
! for ($j = 0; $j < count($stopword_list); $j++)
! {
! $filter_word = trim(strtolower($stopword_list[$j]));
! if( ( $filter_word != "and" && $filter_word != "or" && $filter_word != "not" ) || $mode == "post" )
! {
! $entry = preg_replace("/\b" . phpbb_preg_quote($filter_word, "/") . "\b/is", " ", $entry);
! }
! }
}
--- 63,75 ----
for($i = 0; $i < count($drop_char_match); $i++)
{
! $entry = str_replace($drop_char_match[$i], $drop_char_replace[$i], $entry);
}
if( $mode == "post" )
{
! $entry = str_replace("*", " ", $entry);
! // 'words' that consist of <=3 or >=50 characters are removed.
! $entry = preg_replace("/\b([a-z0-9]{1,3}|[a-z0-9]{50,})\b/si", " ", $entry);
}
***************
*** 102,108 ****
}
! function split_words(&$entry)
{
! preg_match_all("/\b(\w[\w']*\w+|\w+?)\b/", $entry, $split_entries);
return $split_entries[1];
--- 91,104 ----
}
! function split_words(&$entry, $mode = "post")
{
! if( $mode == "post" )
! {
! preg_match_all("/\b(\w[\w']*\w+|\w+?)\b/", $entry, $split_entries);
! }
! else
! {
! preg_match_all("/(\*?[a-z0-9]+\*?)|\b([a-z0-9]+)\b/is", $entry, $split_entries);
! }
return $split_entries[1];
***************
*** 113,122 ****
global $db, $phpbb_root_path, $board_config, $lang;
- $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");
$search_raw_words = array();
! $search_raw_words['text'] = split_words(clean_words("post", $post_text, $stopword_array, $synonym_array));
! $search_raw_words['title'] = split_words(clean_words("post", $post_title, $stopword_array, $synonym_array));
while( list($word_in, $search_matches) = @each($search_raw_words) )
--- 109,117 ----
global $db, $phpbb_root_path, $board_config, $lang;
$synonym_array = @file($phpbb_root_path . "language/lang_" . $board_config['default_lang'] . "/search_synonyms.txt");
$search_raw_words = array();
! $search_raw_words['text'] = split_words(clean_words("post", $post_text, $synonym_array));
! $search_raw_words['title'] = split_words(clean_words("post", $post_title, $synonym_array));
while( list($word_in, $search_matches) = @each($search_raw_words) )
|