NoPaste

phpBB-Title-Search-Update UDiff

von Imhotep

SNIPPET_TEXT:
  1. --- search.php.old      2005-05-13 23:04:02.000000000 +0200
  2. +++ search.php  2005-06-21 00:31:51.000000000 +0200
  3. @@ -81,13 +81,10 @@
  4.         $search_terms = 0;
  5.  }
  6.  
  7. -if ( isset($HTTP_POST_VARS['search_fields']) )
  8. -{
  9. -       $search_fields = ( $HTTP_POST_VARS['search_fields'] == 'all' ) ? 1 : 0;
  10. -}
  11. -else
  12. -{
  13. -       $search_fields = 0;
  14. +switch($HTTP_POST_VARS['search_fields']){
  15. +       case 'all':             $search_fields = 'a'; break;
  16. +       case 'msgonly':         $search_fields = 'm'; break;
  17. +       case 'titleonly':       $search_fields = 't'; break;
  18.  }
  19.  
  20.  $return_chars = ( isset($HTTP_POST_VARS['return_chars']) ) ? intval($HTTP_POST_VARS['return_chars']) : 200;
  21. @@ -259,7 +256,11 @@
  22.                         $split_search = array();
  23.                         $split_search = ( !strstr($multibyte_charset, $lang['ENCODING']) ) ?  split_words(clean_words('search', stripslashes($search_keywords), $stopword_array, $synonym_array), 'search') : split(' ', $search_keywords);    
  24.  
  25. -                       $search_msg_only = ( !$search_fields ) ? "AND m.title_match = 0" : ( ( strstr($multibyte_charset, $lang['ENCODING']) ) ? '' : '' );
  26. +                       switch($search_fields){
  27. +                               case 'a': $search_msg_only = ''; break;
  28. +                               case 'm': $search_msg_only = 'AND m.title_match = 0'; break;
  29. +                               case 't': $search_msg_only = 'AND m.title_match = 1'; break;
  30. +                       }
  31.  
  32.                         $word_count = 0;
  33.                         $current_match_type = 'or';
  34. @@ -308,7 +309,7 @@
  35.                                                 else
  36.                                                 {
  37.                                                         $match_word =  addslashes('%' . str_replace('*', '', $split_search[$i]) . '%');
  38. -                                                       $search_msg_only = ( $search_fields ) ? "OR post_subject LIKE '$match_word'" : '';
  39. +                                                       $search_msg_only = ( $search_fields != 'm' ) ? "OR post_subject LIKE '$match_word'" : '';
  40.                                                         $sql = "SELECT post_id
  41.                                                                 FROM " . POSTS_TEXT_TABLE . "
  42.                                                                 WHERE post_text LIKE '$match_word'
  43. @@ -1398,6 +1399,7 @@
  44.         'L_SEARCH_ANY_TERMS' => $lang['Search_for_any'],
  45.         'L_SEARCH_ALL_TERMS' => $lang['Search_for_all'],
  46.         'L_SEARCH_MESSAGE_ONLY' => $lang['Search_msg_only'],
  47. +       'L_SEARCH_TITLE' => $lang['Search_title_only'],
  48.         'L_SEARCH_MESSAGE_TITLE' => $lang['Search_title_msg'],
  49.         'L_CATEGORY' => $lang['Category'],
  50.         'L_RETURN_FIRST' => $lang['Return_first'],

Quellcode

Hier kannst du den Code kopieren und ihn in deinen bevorzugten Editor einfügen. PASTEBIN_DOWNLOAD_SNIPPET_EXPLAIN