", "?", "!", '"' ); $goodquotes = array ("-", "+", "#" ); $repquotes = array ("\-", "\+", "\#" ); $text = stripslashes( $text ); $text = trim( strip_tags( $text ) ); $text = str_replace( $quotes, '', $text ); $text = str_replace( $goodquotes, $repquotes, $text ); return $text; } $count_result = 0; $sql_count = ""; $sql_find = ""; $config['search_length_min'] = 3; // Минимальное количество символов в слове поиска $tpl->load_template( 'search.tpl' ); $config['search_number'] = intval($config['search_number']); if ( $config['search_number'] < 1) $config['search_number'] = 10; $this_date = date( "Y-m-d H:i:s", $_TIME ); if( intval( $config['no_date'] ) ) $this_date = " AND " . PREFIX . "_post.date < '" . $this_date . "'"; else $this_date = ""; if( isset( $_REQUEST['story'] ) ) $story = substr( strip_data( $_REQUEST['story'] ), 0, 90 ); else $story = ""; if( isset( $_REQUEST['search_start'] ) ) $search_start = intval( $_REQUEST['search_start'] ); else $search_start = 0; if( isset( $_REQUEST['titleonly'] ) ) $titleonly = intval( $_REQUEST['titleonly'] ); else $titleonly = 0; if( isset( $_REQUEST['searchuser'] ) ) $searchuser = substr( strip_data( $_REQUEST['searchuser'] ), 0, 40 ); else $searchuser = ""; if( isset( $_REQUEST['exactname'] ) ) $exactname = $_REQUEST['exactname']; else $exactname = ""; if( isset( $_REQUEST['all_word_seach'] ) ) $all_word_seach = intval($_REQUEST['all_word_seach']); else $all_word_seach = 0; if( isset( $_REQUEST['replyless'] ) ) $replyless = intval( $_REQUEST['replyless'] ); else $replyless = 0; if( isset( $_REQUEST['replylimit'] ) ) $replylimit = intval( $_REQUEST['replylimit'] ); else $replylimit = 0; if( isset( $_REQUEST['searchdate'] ) ) $searchdate = intval( $_REQUEST['searchdate'] ); else $searchdate = 0; if( isset( $_REQUEST['beforeafter'] ) ) $beforeafter = strip_data( $_REQUEST['beforeafter'] ); else $beforeafter = "after"; if ($config['full_search']) {if( isset( $_REQUEST['sortby'] ) ) $sortby = strip_data( $_REQUEST['sortby'] ); else $sortby = ""; } else {if( isset( $_REQUEST['sortby'] ) ) $sortby = strip_data( $_REQUEST['sortby'] ); else $sortby = "date";} if( isset( $_REQUEST['resorder'] ) ) $resorder = strip_data( $_REQUEST['resorder'] ); else $resorder = "desc"; if( isset( $_REQUEST['showposts'] ) ) $showposts = intval( $_REQUEST['showposts'] ); else $showposts = 0; if( isset( $_REQUEST['result_from'] ) ) $result_from = intval( $_REQUEST['result_from'] ); else $result_from = 1; // Показать страницу с результатом № ХХХ $full_search = intval( $_REQUEST['full_search'] ); if( !count( $_REQUEST['catlist'] ) ) { $catlist = array (); $catlist[] = '0'; } else $catlist = $_REQUEST['catlist']; $category_list = array(); foreach ( $catlist as $value ) {$category_list[] = intval($value);} $category_list = $db->safesql( implode( ',', $category_list ) ); $findstory = stripslashes( $story ); // Для вывода в поле поиска if ($titleonly == 2 AND !empty( $searchuser ) ) $searchuser = ""; if( empty( $story ) AND !empty( $searchuser ) AND $titleonly != 2) $story = "___SEARCH___ALL___"; if( $search_start < 0 ) $search_start = 0; // Начальная страница поиска if( $titleonly < 0 or $titleonly > 3 ) $titleonly = 0; // Искать в заголовках, статьях, дополнительных полях, комментариях или везде if( $replyless < 0 or $replyless > 1 ) $replyless = 0; // Искать больше или меньше ответов if( $replylimit < 0 ) $replylimit = 0; // Лимит ответов if( $showposts < 0 or $showposts > 1 ) $showposts = 0; // Искать в статьях или комментариях юзера $listdate = array (0, - 1, 1, 7, 14, 30, 90, 180, 365 ); // Искать за период ХХХ дней if( ! (in_array( $searchdate, $listdate )) ) $searchdate = 0; if( $beforeafter != "after" and $beforeafter != "before" ) $beforeafter = "after"; // Искать до или после периода дней $listsortby = array ("date", "title", "comm_num", "news_read", "autor", "category", "rating" ); if ($config['full_search']) {if( ! (in_array( $sortby, $listsortby )) ) $sortby = ""; // Сортировать по полям } else {if( ! (in_array( $sortby, $listsortby )) ) $sortby = "date";} // Сортировать по полям} $listresorder = array ("desc", "asc" ); if( ! (in_array( $resorder, $listresorder )) ) $resorder = "desc"; // Сортировать по возрастающей или убывающей // Определение выбранных ранее опций, переданных в форме $titleonly_sel = array ('0' => '', '1' => '', '2' => '', '3' => '' ); $titleonly_sel[$titleonly] = 'selected="selected"'; $replyless_sel = array ('0' => '', '1' => '' ); $replyless_sel[$replyless] = 'selected="selected"'; $searchdate_sel = array ('0' => '', '-1' => '', '1' => '', '7' => '', '14' => '', '30' => '', '90' => '', '180' => '', '365' => '' ); $searchdate_sel[$searchdate] = 'selected="selected"'; $beforeafter_sel = array ('after' => '', 'before' => '' ); $beforeafter_sel[$beforeafter] = 'selected="selected"'; $sortby_sel = array ('date' => '', 'title' => '', 'comm_num' => '', 'news_read' => '', 'autor' => '', 'category' => '', 'rating' => '' ); $sortby_sel[$sortby] = 'selected="selected"'; $resorder_sel = array ('desc' => '', 'asc' => '' ); $resorder_sel[$resorder] = 'selected="selected"'; $showposts_sel = array ('0' => '', '1' => '' ); $showposts_sel[$showposts] = 'checked="checked"'; if( $exactname == "yes" ) $exactname_sel = 'checked="checked"'; else $exactname_sel = ''; if( $all_word_seach == 1 ) $all_word_seach_sel = 'checked="checked"'; else $all_word_seach_sel = ''; // Вывод формы поиска if( $category_list == "" or $category_list == "0" ) {$catselall = "selected=\"selected\""; } else { $catselall = ""; $category_list = preg_replace( "/^0\,/", '', $category_list ); } // Определение и вывод доступных категорий $cats = ""; $tpl->copy_template .= << HTML; $searchtable = << HTML; if( $full_search ) { if ($config['full_search']) { $full_search_option = ""; $all_word_option = ""; } else { $full_search_option = ""; $all_word_option = "
"; } $searchtable .= <<
|