diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index d9b328ba92..5d6426f230 100644 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -2645,11 +2645,25 @@ function store_move_thread($values) */ function prepare4display($input='') { + $highlightcolors = array('yellow', '#33CC33','#3399CC', '#9999FF', '#33CC33'); if (!is_array($input)) { - if (isset($_GET['search'])) + if (!empty($_GET['search'])) { - $input = str_replace($_GET['search'],''.$_GET['search'].'',$input); + if (strstr($_GET['search'],'+')) + { + $search_terms = explode('+',$_GET['search']); + } + else + { + $search_terms[] = trim($_GET['search']); + } + $counter = 0; + foreach ($search_terms as $key=>$search_term) + { + $input = str_replace(trim(html_entity_decode($search_term)),''.trim(html_entity_decode($search_term)).'',$input); + $counter++; + } } return stripslashes($input); } @@ -2678,6 +2692,7 @@ function forum_search() // settting the form elements $form->addElement('header', '', get_lang('ForumSearch')); $form->addElement('text', 'search_term', get_lang('SearchTerm'),'class="input_titles"'); + $form->addElement('static', 'search_information', '', get_lang('ForumSearchInformation'), $dissertation[$_GET['opleidingsonderdeelcode']]['code']); $form->addElement('submit', 'SubmitForumCategory', get_lang('Search')); // setting the rules @@ -2709,9 +2724,25 @@ function display_forum_search_results($search_term) { global $table_categories, $table_forums, $table_threads, $table_posts; + // defining the search strings as an array + if (strstr($search_term,'+')) + { + $search_terms = explode('+',$search_term); + } + else + { + $search_terms[] = $search_term; + } + + // search restriction + foreach ($search_terms as $key => $value) + { + $search_restriction[] = "(posts.post_title LIKE '%".Database::escape_string(trim($value))."%' + OR posts.post_text LIKE '%".Database::escape_string(trim($value))."%')"; + } + $sql = "SELECT * FROM $table_posts posts - WHERE posts.post_title LIKE '%".Database::escape_string($search_term)."%' - OR posts.post_text LIKE '%".Database::escape_string($search_term)."%' + WHERE ".implode(' AND ',$search_restriction)." /*AND posts.thread_id = threads.thread_id*/ GROUP BY posts.post_id"; @@ -2746,10 +2777,10 @@ function display_forum_search_results($search_term) if ($display_result == true) { - $search_results_item = '
  • '.$forum_categories_list[$row['forum_id']['forum_category']]['cat_title'].' > '; - $search_results_item .= ''.$forum_list[$row['forum_id']]['forum_title'].' > '; + $search_results_item = '
  • '.$forum_categories_list[$row['forum_id']['forum_category']]['cat_title'].' > '; + $search_results_item .= ''.$forum_list[$row['forum_id']]['forum_title'].' > '; //$search_results_item .= 'THREAD > '; - $search_results_item .= ''.$row['post_title'].''; + $search_results_item .= ''.$row['post_title'].''; $search_results_item .= '
    '; if (strlen($row['post_title']) > 200 ) { diff --git a/main/forum/viewforum.php b/main/forum/viewforum.php index 30a48ec021..081a3f95b8 100644 --- a/main/forum/viewforum.php +++ b/main/forum/viewforum.php @@ -103,8 +103,8 @@ $current_forum_category=get_forumcategory_information($current_forum['forum_cate ----------------------------------------------------------- */ $interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS($_GET['search']),"name" => $nameTools); -$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&search=".Security::remove_XSS($_GET['search']),"name" => prepare4display($current_forum_category['cat_title'])); -$interbreadcrumb[]=array("url" => "viewforum.php?forum=".Security::remove_XSS($_GET['forum'])."&search=".Security::remove_XSS($_GET['search']),"name" => prepare4display($current_forum['forum_title'])); +$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => prepare4display($current_forum_category['cat_title'])); +$interbreadcrumb[]=array("url" => "viewforum.php?forum=".Security::remove_XSS($_GET['forum'])."&search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => prepare4display($current_forum['forum_title'])); if($origin=='learnpath') { include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php'); @@ -268,7 +268,7 @@ if(is_array($threads)) echo icon('../img/exclamation.gif'); } echo "\n"; - echo "\t\t".prepare4display($row['thread_title'])."\n"; + echo "\t\t".prepare4display($row['thread_title'])."\n"; echo "\t\t".$row['thread_replies']."\n"; if ($row['user_id']=='0') { diff --git a/main/forum/viewforumcategory.php b/main/forum/viewforumcategory.php index 5c8e6852b5..516fa6ab09 100644 --- a/main/forum/viewforumcategory.php +++ b/main/forum/viewforumcategory.php @@ -90,8 +90,8 @@ if(!api_is_allowed_to_edit()) ----------------------------------------------------------- */ $current_forum_category=get_forum_categories($_GET['forumcategory']); -$interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS($_GET['search']),"name" => $nameTools); -$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&search=".Security::remove_XSS($_GET['search']),"name" => prepare4display($current_forum_category['cat_title'])); +$interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS(url_encode($_GET['search'])),"name" => $nameTools); +$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&search=".Security::remove_XSS(url_encode($_GET['search'])),"name" => prepare4display($current_forum_category['cat_title'])); if (!empty($_GET['action']) && !empty($_GET['content'])) @@ -303,7 +303,7 @@ foreach ($forum_list as $key=>$forum) } } echo "\n"; - echo "\t\t".prepare4display($forum['forum_title']).'
    '.prepare4display($forum['forum_comment'])."\n"; + echo "\t\t".prepare4display($forum['forum_title']).'
    '.prepare4display($forum['forum_comment'])."\n"; //$number_forum_topics_and_posts=get_post_topics_of_forum($forum['forum_id']); // deprecated // the number of topics and posts echo "\t\t".$forum['number_of_threads']."\n"; diff --git a/main/forum/viewthread.php b/main/forum/viewthread.php index 347aa595e2..a2adebcb2b 100644 --- a/main/forum/viewthread.php +++ b/main/forum/viewthread.php @@ -118,9 +118,9 @@ if($origin=='learnpath') } else { - $interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS($_GET['search']),"name" => $nameTools); - $interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&search=".Security::remove_XSS($_GET['search']),"name" => prepare4display($current_forum_category['cat_title'])); - $interbreadcrumb[]=array("url" => "viewforum.php?forum=".Security::remove_XSS($_GET['forum'])."&search=".Security::remove_XSS($_GET['search']),"name" => prepare4display($current_forum['forum_title'])); + $interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => $nameTools); + $interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => prepare4display($current_forum_category['cat_title'])); + $interbreadcrumb[]=array("url" => "viewforum.php?forum=".Security::remove_XSS($_GET['forum'])."&search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => prepare4display($current_forum['forum_title'])); if ($message<>'PostDeletedSpecial') { $interbreadcrumb[]=array("url" => "viewthread.php?forum=".Security::remove_XSS($_GET['forum'])."&thread=".Security::remove_XSS($_GET['thread']),"name" => prepare4display($current_thread['thread_title'])); @@ -187,7 +187,7 @@ if ($message<>'PostDeletedSpecial') // in this case the first and only post of t ----------------------------------------------------------- */ echo '
    '; - $my_url = ''.get_lang('FlatView').' | '; echo $my_url.'&view=threaded&origin='.$origin.'">'.get_lang('ThreadedView').' | '; echo $my_url.'&view=nested&origin='.$origin.'">'.get_lang('NestedView').'';