mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
Moved all search functions to includes/search.php Paul; please review
git-svn-id: file:///svn/phpbb/trunk@1781 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -24,82 +24,7 @@ $phpbb_root_path = "./";
|
||||
include($phpbb_root_path . 'extension.inc');
|
||||
include($phpbb_root_path . 'common.'.$phpEx);
|
||||
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
|
||||
|
||||
// -----------------------
|
||||
// Page specific functions
|
||||
//
|
||||
function clean_words_search($entry)
|
||||
{
|
||||
|
||||
$char_match = array("^", "$", "&", "(", ")", "<", ">", "`", "'", "|", ",", "@", "_", "?", "%", "~", ".", "[", "]", "{", "}", ":", "\\", "/", "=", "#", "\"", ";", "!");
|
||||
$char_replace = array(" ", " ", " ", " ", " ", " ", " ", " ", "", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ");
|
||||
|
||||
$sgml_match = array(" ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ");
|
||||
$sgml_replace = array(" ", "s", "a", "a", "a", "a", "a", "a", "a", "c", "e", "e", "e", "e", "i", "i", "i", "i", "o", "n", "o", "o", "o", "o", "o", "o", "u", "u", "u", "u", "y", "t", "y");
|
||||
|
||||
$accent_match = array("<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>", "<EFBFBD>");
|
||||
$accent_replace = array("s", "a", "a", "a", "a", "a", "a", "a", "c", "e", "e", "e", "e", "i", "i", "i", "i", "o", "n", "o", "o", "o", "o", "o", "o", "u", "u", "u", "u", "y", "t", "y");
|
||||
|
||||
$entry = " " . strip_tags(strtolower($entry)) . " ";
|
||||
|
||||
$entry = str_replace("+", " and ", $entry);
|
||||
$entry = str_replace("-", " not ", $entry);
|
||||
|
||||
$entry = str_replace($sgml_match, $sgml_match, $entry);
|
||||
$entry = str_replace($accent_match, $accent_replace, $entry);
|
||||
$entry = str_replace($char_match, $char_replace, $entry);
|
||||
|
||||
$entry = preg_replace("/\b[0-9]+\b/", " ", $entry);
|
||||
|
||||
return $entry;
|
||||
}
|
||||
|
||||
function remove_stop_words($entry, &$stopword_list)
|
||||
{
|
||||
|
||||
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" )
|
||||
{
|
||||
$entry = preg_replace("/\b" . phpbb_preg_quote($filter_word, "/") . "\b/is", " ", $entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $entry;
|
||||
}
|
||||
|
||||
function replace_synonyms($entry, &$synonym_list)
|
||||
{
|
||||
if( !empty($synonym_list) )
|
||||
{
|
||||
for ($j = 0; $j < count($synonym_list); $j++)
|
||||
{
|
||||
list($replace_synonym, $match_synonym) = split(" ", trim(strtolower($synonym_list[$j])));
|
||||
|
||||
if( $match_synonym != "and" && $match_synonym != "or" && $match_synonym != "not" &&
|
||||
$replace_synonym != "and" && $replace_synonym != "or" && $replace_synonym != "not" )
|
||||
{
|
||||
$entry = preg_replace("/\b" . phpbb_preg_quote(trim($match_synonym), "/") . "\b/is", " " . trim($replace_synonym) . " ", $entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $entry;
|
||||
}
|
||||
|
||||
function split_words(&$entry)
|
||||
{
|
||||
preg_match_all("/(\*?[a-z0-9]+\*?)|\b([a-z0-9]+)\b/is", $entry, $split_entries);
|
||||
|
||||
return $split_entries[1];
|
||||
}
|
||||
//
|
||||
// End of functions defns
|
||||
// ----------------------
|
||||
include($phpbb_root_path . 'includes/search.'.$phpEx);
|
||||
|
||||
//
|
||||
// Start session management
|
||||
|
Reference in New Issue
Block a user