From c45feb1347067e5796b0d46b5dce5f407cac5445 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Thu, 29 Nov 2001 13:05:03 +0000 Subject: [PATCH] Fix for 'bug' #484650 git-svn-id: file:///svn/phpbb/trunk@1479 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/language/lang_english/lang_main.php | 3 +- phpBB/search.php | 44 +++++++++++++++-------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/phpBB/language/lang_english/lang_main.php b/phpBB/language/lang_english/lang_main.php index a0faa176bb..ace3926159 100644 --- a/phpBB/language/lang_english/lang_main.php +++ b/phpBB/language/lang_english/lang_main.php @@ -671,7 +671,8 @@ $lang['Sort_Author'] = "Author"; $lang['Sort_Forum'] = "Forum"; $lang['Display_results'] = "Display results as"; -$lang['All'] = "All"; +$lang['All_available'] = "All available"; +$lang['No_searchable_forums'] = "You do not have permissions to search any forum on this site"; $lang['No_search_match'] = "No topics or posts met your search criteria"; $lang['Found_search_match'] = "Search found %d match"; // eg. Search found 1 match diff --git a/phpBB/search.php b/phpBB/search.php index 0c50dfda9d..cba7b0eef8 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -34,10 +34,19 @@ 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("ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ"); + $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); @@ -315,8 +324,7 @@ else if( $query_keywords != "" || $query_author != "" || $search_id ) $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 - ORDER BY m.post_id"; + AND m.word_id = w.word_id"; $result = $db->sql_query($sql); if( !$result ) { @@ -530,8 +538,6 @@ else if( $query_keywords != "" || $query_author != "" || $search_id ) $searchset = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - // // Clean up search results table // @@ -1079,33 +1085,41 @@ if(!$result) $is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata); -$s_forums = ""; - +$s_forums = ""; while($row = $db->sql_fetchrow($result)) { - if($is_auth_ary[$row['forum_id']]['auth_read']) + if( $is_auth_ary[$row['forum_id']]['auth_read'] ) { $s_forums .= ""; - if(empty($list_cat[$row['cat_id']])) + if( empty($list_cat[$row['cat_id']]) ) { $list_cat[$row['cat_id']] = $row['cat_title']; } } } -// -// Category to search -// -$s_categories = ""; -while( list($cat_id, $cat_title) = each($list_cat)) +if( $s_forums != "" ) { - $s_categories .= ""; + $s_forums = "" . $s_forums; + + // + // Category to search + // + $s_categories = ""; + while( list($cat_id, $cat_title) = @each($list_cat)) + { + $s_categories .= ""; + } +} +else +{ + message_die(GENERAL_MESSAGE, $lang['No_searchable_forums']); } // // Number of chars returned // -$s_characters = ""; +$s_characters = ""; $s_characters .= ""; $s_characters .= ""; $s_characters .= "";