", "?", "!", '"' ); $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 .= <<
HTML; } else { if ( $smartphone_detected ) {$link_full_search = ""; } else {$link_full_search = "";} $searchtable .= <<
HTML; } $searchtable .= << HTML; $tpl->set( '{searchtable}', $searchtable ); // По умолчанию, выводится только форма поиска if( $subaction != "search" ) { $tpl->set_block( "'\[searchmsg\](.*?)\[/searchmsg\]'si", "" ); $tpl->compile( 'content' ); } // Конец вывода формы поиска if( $subaction == "search" ) { // Вывод результатов поиска if ($config['full_search']) { $arr = explode( ' ', $story ); $story_maxlen = 0; $story = array (); foreach ( $arr as $word ) { $wordlen = strlen( trim( $word ) ); if( $wordlen > $story_maxlen ) {$story_maxlen = $wordlen;} } $story = implode( " ", $story ); } else { if ( !$all_word_seach ) $story = preg_replace( "#(\s+|__OR__)#i", '%', $story ); $story_maxlen = strlen( trim( $story )); } if( (empty( $story ) or ($story_maxlen < $config['search_length_min'])) and (empty( $searchuser ) or (strlen( $searchuser ) < $config['search_length_min'])) ) { msgbox( $lang['all_info'], $lang['search_err_3'] ); $tpl->set( '{searchmsg}', '' ); $tpl->set( '[searchmsg]', "" ); $tpl->set( '[/searchmsg]', "" ); $tpl->compile( 'content' ); } else { // Начало подготовки поиска if( $search_start ) { $search_start = $search_start - 1; $search_start = $search_start * $config['search_number']; } // Проверка разрешенных категорий из списка выбранных категорий $allow_cats = $user_group[$member_id['user_group']]['allow_cats']; $allow_list = explode( ',', $allow_cats ); $stop_list = ""; if( $allow_list[0] == "all" ) { // Все категории доступны для группы if( $category_list == "" or $category_list == "0" ) { // Выбран поиск по всем категориям ; } else { // Выбран поиск по некоторым категориям $stop_list = str_replace( ',', '|', $category_list ); } } else { // Не все категории доступны для группы if( $category_list == "" or $category_list == "0" ) { // Выбран поиск по всем категориям $stop_list = str_replace( ',', '|', $allow_cats ); } else { // Выбран поиск по некоторым категориям $cats_list = explode( ',', $category_list ); foreach ( $cats_list as $id ) { if( in_array( $id, $allow_list ) ) $stop_list .= $id . '|'; } $stop_list = substr( $stop_list, 0, strlen( $stop_list ) - 1 ); } } // Ограничение по категориям $where_category = ""; if( ! empty( $stop_list ) ) { if( $config['allow_multi_category'] ) {$where_category = "category regexp '[[:<:]](" . $stop_list . ")[[:>:]]'"; } else { $stop_list = str_replace( "|", "','", $stop_list ); $where_category = "category IN ('" . $stop_list . "')"; } } if( $story == "___SEARCH___ALL___" ) $story = ''; $thistime = date( "Y-m-d H:i:s", (time() + $config['date_adjust'] * 60) ); if( $exactname == 'yes' ) $likename = ''; else $likename = '%'; if( $searchdate != '0' ) { if( $searchdate != '-1' ) { $qdate = date( "Y-m-d H:i:s", (time() + $config['date_adjust'] * 60 - $searchdate * 86400) ); } else { if( $is_logged and isset( $_SESSION['member_lasttime'] ) ) $qdate = date( "Y-m-d H:i:s", $_SESSION['member_lasttime'] ); else $qdate = $thistime; } } // Поиск по автору статьи или комментария $autor_posts = ''; $autor_comms = ''; $searchuser = $db->safesql($searchuser); if( ! empty( $searchuser ) ) { switch ($titleonly) { case 0 : // Искать только в статьях $autor_posts = PREFIX . "_post.autor like '$searchuser$likename'"; break; case 3 : // Искать только в статьях $autor_posts = PREFIX . "_post.autor like '$searchuser$likename'"; break; case 1 : // Искать только в комментариях $autor_comms = PREFIX . "_comments.autor like '$searchuser$likename'"; break; } } $where_reply = ""; if( ! empty( $replylimit ) ) { if( $replyless == 0 ) $where_reply = PREFIX . "_post.comm_num >= '" . $replylimit . "'"; else $where_reply = PREFIX . "_post.comm_num <= '" . $replylimit . "'"; } // Поиск по ключевым словам if ($config['full_search']) { $titleonly_where = array ('0' => "MATCH(title,short_story,full_story) AGAINST ('{story}')", // Искать только в статьях '1' => "MATCH(text) AGAINST ('{story}')", // Искать только в комментариях '2' => "MATCH(" . PREFIX . "_static.template) AGAINST ('{story}')", // Искать только в статических страницах '3' => "title LIKE '%{story}%'" ); // Искать только в заголовках статей } else { $titleonly_where = array ('0' => "short_story LIKE '%{story}%' OR full_story LIKE '%{story}%' OR title LIKE '%{story}%'", // Искать только в статьях '1' => "text LIKE '%{story}%'", // Искать только в комментариях '2' => PREFIX . "_static.template LIKE '%{story}%'", // Искать только в статических страницах '3' => "title LIKE '%{story}%'" ); // Искать только в заголовках статей } if( !empty( $story ) ) { foreach ( $titleonly_where as $name => $value ) { $value2 = str_replace( "{story}", $db->safesql($story), $value ); $titleonly_where[$name] = $value2; } } // Поиск по статьям if( in_array( $titleonly, array (0, 3 ) ) ) { $where_posts = "WHERE " . PREFIX . "_post.approve=1" . $this_date; if( ! empty( $where_category ) ) $where_posts .= " AND " . $where_category; if ($config['full_search']) {if( ! empty( $story ) ) $where_posts .= " AND " . $titleonly_where[$titleonly]; } else {if( ! empty( $story ) ) $where_posts .= " AND (" . $titleonly_where[$titleonly] . ")";} if( ! empty( $autor_posts ) ) $where_posts .= " AND " . $autor_posts; $sdate = PREFIX . "_post.date"; if( $searchdate != '0' ) { if( $beforeafter == 'before' ) $where_date = $sdate . " < '" . $qdate . "'"; else $where_date = $sdate . " between '" . $qdate . "' and '" . $thistime . "'"; $where_posts .= " AND " . $where_date; } if( ! empty( $where_reply ) ) $where_posts .= " AND " . $where_reply; $where = $where_posts; if ($config['full_search']) if( $titleonly_where[$titleonly] == "" ) $titleonly_where[$titleonly] = "''"; $posts_fields = "SELECT SQL_CALC_FOUND_ROWS id, autor, " . PREFIX . "_post.date AS newsdate, " . PREFIX . "_post.date AS date, short_story AS story, title, descr, keywords, category, alt_name, comm_num AS comm_in_news, allow_comm, rating, news_read, editdate, tags, '' AS output_comms"; $posts_from = "FROM " . PREFIX . "_post"; $sql_fields = $posts_fields; $sql_find = "$sql_fields $posts_from $where"; } // Поиск по комментариям if( $titleonly == 1) { $where_comms = "WHERE " . PREFIX . "_post.approve=1" . $this_date; if( ! empty( $where_category ) ) $where_comms .= " AND " . $where_category; if( ! empty( $story ) ) $where_comms .= " AND (" . $titleonly_where['1'] . ")"; if( ! empty( $autor_comms ) ) $where_comms .= " AND " . $autor_comms; $sdate = PREFIX . "_comments.date"; if( $searchdate != '0' ) { if( $beforeafter == 'before' ) $where_date = $sdate . " < '" . $qdate . "'"; else $where_date = $sdate . " between '" . $qdate . "' and '" . $thistime . "'"; $where_comms .= " AND " . $where_date; } if( ! empty( $where_reply ) ) $where_comms .= " AND " . $where_reply; $where = $where_comms; $comms_fields = "SELECT SQL_CALC_FOUND_ROWS " . PREFIX . "_comments.id AS coms_id, post_id AS id, " . PREFIX . "_comments.date, " . PREFIX . "_comments.autor AS autor, " . PREFIX . "_comments.email AS gast_email, " . PREFIX . "_comments.text AS story, ip, is_register, name, " . USERPREFIX . "_users.email, news_num, " . USERPREFIX . "_users.comm_num, reg_date, banned, signature, foto, fullname, land, icq, repa, repa_mod, repa_off, " . PREFIX . "_post.date AS newsdate, " . PREFIX . "_post.title, " . PREFIX . "_post.category, " . PREFIX . "_post.alt_name, " . PREFIX . "_post.comm_num AS comm_in_news, " . PREFIX . "_post.allow_comm, " . PREFIX . "_post.rating, " . PREFIX . "_post.news_read, '1' AS output_comms"; $comms_from = "FROM " . PREFIX . "_comments LEFT JOIN " . PREFIX . "_post ON " . PREFIX . "_comments.post_id=" . PREFIX . "_post.id LEFT JOIN " . USERPREFIX . "_users ON " . PREFIX . "_comments.user_id=" . USERPREFIX . "_users.user_id"; $sql_fields = $comms_fields; $sql_find = "$sql_fields $comms_from $where"; } $order_by = $sortby . " " . $resorder; // Поиск в статических страницах if( $titleonly == 6 ) { $sql_from = "FROM " . PREFIX . "_static"; $sql_fields = "SELECT SQL_NO_CACHE id, name AS static_name, descr AS title, template AS story, grouplevel, date, views"; if ( $titleonly_where[$titleonly] ) $where = "WHERE " . $titleonly_where[$titleonly]; else $where = ""; $sql_find = "$sql_fields $sql_from $where"; $order_by = "id"; } // ------ Запрос к базе $from_num = $search_start + 1; if ($config['full_search']) { if( $sortby != "" ) $order_by = "ORDER BY " . $order_by; else $order_by = ""; $sql_request = "$sql_find $order_by LIMIT $search_start,{$config['search_number']}"; } else { $sql_request = "$sql_find ORDER BY $order_by LIMIT $search_start,{$config['search_number']}"; } $sql_result = $db->query( $sql_request ); $found_result = $db->num_rows( $sql_result ); $result_count = $db->super_query( "SELECT FOUND_ROWS() as count" ); $count_result = $result_count['count']; if( $count_result > ($config['search_number'] * 5) ) $count_result = ($config['search_number'] * 5); // Не найдено if( ! $found_result ) { msgbox( $lang['all_info'], $lang[search_err_2] ); $tpl->set( '{searchmsg}', '' ); $tpl->set_block( "'\[searchmsg\](.*?)\[/searchmsg\]'si", "" ); $tpl->compile( 'content' ); } else { $to_num = $search_start + $found_result; // Вывод информации о количестве найденных результатов $searchmsg = "$lang[search_ok] " . $count_result . " $lang[search_ok_1] ($lang[search_ok_2] " . $from_num . " - " . $to_num . ") :"; $tpl->set( '{searchmsg}', $searchmsg ); $tpl->set( '[searchmsg]', "" ); $tpl->set( '[/searchmsg]', "" ); $tpl->compile( 'content' ); $tpl->load_template( 'searchresult.tpl' ); function hilites($search, $txt) { $r = preg_split( '((>)|(<))', $txt, - 1, PREG_SPLIT_DELIM_CAPTURE ); for($i = 0; $i < count( $r ); $i ++) { if( $r[$i] == "<" ) { $i ++; continue; } $r[$i] = preg_replace( "#($search)#i", "\\1", $r[$i] ); } return join( "", $r ); } // Вывод текста статьи или комментария во всплывающей подсказке при выводе только заголовков function create_description($txt) { $fastquotes = array ("\x27", "\x22", "\x60", "\t", "\n", "\r" ); $quotes = array ('"', "'" ); $maxchr = 80; $txt = preg_replace( "/\[hide\](.*?)\[\/hide\]/ims", "", $txt ); $txt = stripslashes( $txt ); $txt = trim( strip_tags( $txt ) ); $txt = str_replace( $fastquotes, ' ', $txt ); $txt = str_replace( $quotes, '', $txt ); $txt = preg_replace( "#\s+#i", ' ', $txt ); $txt = substr( $txt, 0, 300 ); $txt = wordwrap( $txt, $maxchr, " " ); return $txt; } // Вывод результатов поиска $search_id = $search_start; while ( $row = $db->get_row( $sql_result ) ) { // Порядковый номер результата поиска $search_id ++; $attachments[] = $row['id']; if( $titleonly != 2 ) { $row['newsdate'] = strtotime( $row['newsdate'] ); $row['date'] = strtotime( $row['date'] ); } $row['story'] = stripslashes( $row['story'] ); if( $user_group[$member_id['user_group']]['allow_hide'] ) $row['story'] = str_ireplace( "[hide]", "", str_ireplace( "[/hide]", "", $row['story']) ); else $row['story'] = preg_replace ( "#\[hide\](.+?)\[/hide\]#is", "
" . $lang['news_regus'] . "
", $row['story'] ); if ($config['full_search']) $arr = explode( " ", $story ); else $arr = explode( "%", $story ); foreach ( $arr as $word ) { if( strlen( trim( $word ) ) >= $config['search_length_min'] ) { $row['story'] = hilites( $word, $row['story'] ); } ; } if( $titleonly == 2 ) { // Результаты поиска в статических страницах $row['grouplevel'] = explode( ',', $row['grouplevel'] ); if( $row['grouplevel'][0] != "all" and ! in_array( $member_id['user_group'], $row['grouplevel'] ) ) { $tpl->result['content'] .= $lang['static_denied']; } else { $row['story'] = stripslashes( $row['story'] ); $title = stripslashes( strip_tags( $row['title'] ) ); $tpl->load_template( 'static.tpl' ); $static_descr = "" . $title . ""; $tpl->set( '{description}', $static_descr ); if (strlen( $row['story'] ) > 2000) { $row['story'] = substr( strip_tags ($row['story']), 0, 2000)." .... "; $row['story'] .= "( " . $lang['search_s_go'] . " )"; } $tpl->set( '{static}', $row['story'] ); $tpl->set( '{pages}', '' ); if( @date( "Ymd", $row['date'] ) == date( "Ymd", $_TIME ) ) { $tpl->set( '{date}', $lang['time_heute'] . langdate( ", H:i", $row['date'] ) ); } elseif( @date( "Ymd", $row['date'] ) == date( "Ymd", ($_TIME - 86400) ) ) { $tpl->set( '{date}', $lang['time_gestern'] . langdate( ", H:i", $row['date'] ) ); } else { $tpl->set( '{date}', langdate( $config['timestamp_active'], $row['date'] ) ); } $tpl->copy_template = preg_replace ( "#\{date=(.+?)\}#ie", "langdate('\\1', '{$row['date']}')", $tpl->copy_template ); $tpl->set( '{views}', $row['views'] ); $tpl->compile( 'content' ); $tpl->clear(); if( $config['files_allow'] == "yes" ) { if( strpos( $tpl->result['content'], "[file=" ) !== false ) {$tpl->result['content'] = show_file( $tpl->result['content'], $attachments, true );} if( strpos( $tpl->result['content'], "[torrent=" ) !== false ) {$tpl->result['content'] = show_torrent( $tpl->result['content'], $attachments, true );} } } } else { // Результаты поиска в статьях и комментариях $tpl->set( '{result-date}', langdate( $config['timestamp_active'], $row['date'] ) ); $tpl->copy_template = preg_replace ( "#\{date=(.+?)\}#ie", "langdate('\\1', '{$row['date']}')", $tpl->copy_template ); $row_title = stripslashes( $row['title'] ); $tpl->set( '{result-title}', $row_title ); $tpl->set( '{result-author}', "" . $row['autor'] . "" ); $tpl->set( '{result-comments}', $row['comm_in_news'] ); $my_news_id = "№ " . $row['id'] . ""; $tpl->set( '{news-id}', $my_news_id ); if( ! $row['category'] ) { $my_cat = "---"; $my_cat_link = "---"; } else { $my_cat = array (); $my_cat_link = array (); $cat_list = explode( ',', $row['category'] ); if( count( $cat_list ) == 1 ) { $my_cat[] = $cat_info[$cat_list[0]]['name']; $my_cat_link = get_categories( $cat_list[0] ); } else { foreach ( $cat_list as $element ) { if( $element ) { $my_cat[] = $cat_info[$element]['name']; $my_cat_link[] = "{$cat_info[$element]['name']}"; }}$my_cat_link = stripslashes( implode( ', ', $my_cat_link ) ); }$my_cat = stripslashes( implode( ', ', $my_cat ) ); } $row['category'] = intval( $row['category'] ); if( $row['tags'] ) { $tpl->set( '[tags]', "" ); $tpl->set( '[/tags]', "" ); $tags = array (); $row['tags'] = explode( ",", $row['tags'] ); foreach ( $row['tags'] as $value ) { $value = trim( $value ); $tags[] = "" . $value . ""; } $tpl->set( '{tags}', implode( ", ", $tags ) ); } else { $tpl->set_block( "'\\[tags\\](.*?)\\[/tags\\]'si", "" ); $tpl->set( '{tags}', "" ); } $tpl->set( '{link-category}', $my_cat_link ); $tpl->set( '{views}', $row['news_read'] ); if( $row['output_comms'] == '1' ) { // Обработка и вывод комментариев if( ! $row['is_register'] ) { if( $row['gast_email'] != "" ) {$tpl->set( '{result-author}', "" . stripslashes( $row['autor'] ) . "" ); } else {$tpl->set( '{result-author}', stripslashes( $row['autor'] ) );} } else {$tpl->set( '{result-author}', "" . stripslashes( $row['autor'] ) . "" ); } if( $is_logged and $member_id['user_group'] == '1' ) $tpl->set( '{ip}', "IP: {$row['ip']}" ); else $tpl->set( '{ip}', '' ); if( $is_logged and (($member_id['name'] == $row['name'] and $row['is_register'] and $user_group[$member_id['user_group']]['allow_editc']) or $user_group[$member_id['user_group']]['edit_allc']) ) { $tpl->set( '[com-edit]', "" ); $tpl->set( '[/com-edit]', "" ); } else $tpl->set_block( "'\\[com-edit\\](.*?)\\[/com-edit\\]'si", "" ); if( $is_logged and (($member_id['name'] == $row['name'] and $row['is_register'] and $user_group[$member_id['user_group']]['allow_delc']) or $member_id['user_group'] == '1' or $user_group[$member_id['user_group']]['del_allc']) ) { $tpl->set( '[com-del]', "" ); $tpl->set( '[/com-del]', "" ); } else $tpl->set_block( "'\\[com-del\\](.*?)\\[/com-del\\]'si", "" ); $tpl->set_block( "'\\[fast\\](.*?)\\[/fast\\]'si", "" ); $tpl->set( '{mail}', $row['email'] ); $tpl->set( '{comment-id}', '--' ); if( $row['banned'] == 'yes' or $row['name'] == '' or ! $row['is_register'] ) { $grav_url = 'http://gravatar.com/avatar/' . md5( stripslashes( $row['email'] ) ) . "?s=100&r=g&d=" . $config['http_home_url'] . 'templates/' . $config['skin'] . '/images/noavatar.png';$tpl->set('{foto}', "
"); } else { if( $row['foto'] ) $tpl->set( '{foto}', "" ); else $grav_url = 'http://gravatar.com/avatar/' . md5( stripslashes( $row['email'] ) ) . "?s=100&r=g&d=" . $config['http_home_url'] . 'templates/' . $config['skin'] . '/images/noavatar.png';$tpl->set('{foto}', "
"); } @include (SYSTEM_DIR.'/modules/reputation.php'); if( $row['is_register'] ) $tpl->set( '{registration}', langdate( "d.m.Y", $row['reg_date'] ) ); else $tpl->set( '{registration}', '--' ); if( $row['is_register'] and $row['news_num'] ) $tpl->set( '{news_num}', $row['news_num'] ); else $tpl->set( '{news_num}', '0' ); if( $row['is_register'] and $row['comm_num'] ) $tpl->set( '{comm_num}', $row['comm_num'] ); else $tpl->set( '{comm_num}', '0' ); $tpl->set_block( "'\\[signature\\](.*?)\\[/signature\\]'si", "" ); $tpl->set( '{result-text}', "
" . $row['story'] . "
" ); } else { if( $is_logged and (($member_id['name'] == $row['autor'] and $user_group[$member_id['user_group']]['allow_edit']) or $user_group[$member_id['user_group']]['allow_all_edit']) ) { $tpl->set( '[edit]', "" ); $tpl->set( '[/edit]', "" ); } else {$tpl->set_block( "'\\[edit\\](.*?)\\[/edit\\]'si", "" );} if ($smartphone_detected) { if (!$config['allow_smart_format']) {$row['story'] = strip_tags( $row['story'], '


' ); } else { if ( !$config['allow_smart_images'] ) { $row['story'] = preg_replace( "#(.+?)#is", "", $row['story'] ); $row['story'] = preg_replace( "##is", "", $row['story'] ); } if ( !$config['allow_smart_video'] ) { $row['story'] = preg_replace( "##is", "", $row['story'] ); $row['story'] = preg_replace( "##is", "", $row['story'] ); }}} if ($is_logged){ $fav_arr = explode (',', $member_id['favorites']); if (!in_array ($row['id'], $fav_arr)) $tpl->set('{favorites}',"\"".$lang['news_addfav']."\""); else $tpl->set('{favorites}',"\"".$lang['news_minfav']."\""); } else $tpl->set('{favorites}',""); $tpl->set( '{result-text}', "

" . $row['story'] . "
" ); } $tpl->set( '{search-id}', $search_id ); if( $showposts == 0 ) { // Показать короткую новость $tpl->set_block( "'\\[shortresult\\].*?\\[/shortresult\\]'si", "" ); $tpl->set( '[fullresult]', "" ); $tpl->set( '[/fullresult]', "" ); $alt_text = $row_title; } else { // Показать только заголовок $tpl->set_block( "'\\[fullresult\\].*?\\[/fullresult\\]'si", "" ); $tpl->set( '[shortresult]', "" ); $tpl->set( '[/shortresult]', "" ); $alt_text = create_description( $row['story'] ); } $full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html"; $tpl->set( '[result-link]', "" ); $tpl->set( '[/result-link]', "" ); if( $row['output_comms'] == '1' ) { // Для вывода комментариев $tpl->set_block( "'\\[searchposts\\].*?\\[/searchposts\\]'si", "" ); $tpl->set( '[searchcomments]', "
" ); $tpl->set( '[/searchcomments]', "
" ); } else { // Для вывода статей $tpl->set_block( "'\\[searchcomments\\].*?\\[/searchcomments\\]'si", "" ); $tpl->set( '[searchposts]', "" ); $tpl->set( '[/searchposts]', "" ); } $tpl->compile( 'content' ); if( $user_group[$member_id['user_group']]['allow_hide'] ) $tpl->result['content'] = preg_replace( "'\[hide\](.*?)\[/hide\]'si", "\\1", $tpl->result['content']); else $tpl->result['content'] = preg_replace ( "'\[hide\](.*?)\[/hide\]'si", "
" . $lang['news_regus'] . "
", $tpl->result['content'] ); if( $config['files_allow'] == "yes" ) { if( strpos( $tpl->result['content'], "[file=" ) !== false ) { $tpl->result['content'] = show_file( $tpl->result['content'], $attachments ); } if( strpos( $tpl->result['content'], "[torrent=" ) !== false ) { $tpl->result['content'] = show_torrent( $tpl->result['content'], $attachments ); } } } // Результаты поиска в статьях и комментариях } // while $tpl->clear(); $db->free( $sql_result ); } } } $tpl->clear(); //#################################################################################################################### // Навигация по новостям //#################################################################################################################### if( $found_result > 0 ) { $tpl->load_template( 'navigation.tpl' ); //---------------------------------- // Previous link //---------------------------------- if( isset( $search_start ) and $search_start != "" and $search_start > 0 ) { $prev = $search_start / $config['search_number']; $prev_page = ""; $tpl->set_block( "'\[prev-link\](.*?)\[/prev-link\]'si", $prev_page . "\\1" ); } else { $tpl->set_block( "'\[prev-link\](.*?)\[/prev-link\]'si", "\\1" ); $no_prev = TRUE; } //---------------------------------- // Pages //---------------------------------- if( $config['search_number'] ) { $pages_count = @ceil( $count_result / $config['search_number'] ); $pages_start_from = 0; $pages = ""; for($j = 1; $j <= $pages_count; $j ++) { if( $pages_start_from != $search_start ) { $pages .= "$j "; } else { $pages .= " $j "; } $pages_start_from += $config['search_number']; } $tpl->set( '{pages}', $pages ); } //---------------------------------- // Next link //---------------------------------- if( $config['search_number'] < $count_result and $to_num < $count_result ) { $next_page = $to_num / $config['search_number'] + 1; $next = ""; $tpl->set_block( "'\[next-link\](.*?)\[/next-link\]'si", $next . "\\1" ); } else { $tpl->set_block( "'\[next-link\](.*?)\[/next-link\]'si", "\\1" ); $no_next = TRUE; } if( ! $no_prev or ! $no_next ) { $tpl->compile( 'content' ); } $tpl->clear(); } } ?>