вопрос
Всем привет.
Вот загорелся я сделать быстрый поиск с картинками. В общем пол дня ушло на пляски, но код заработал, как и хотелось.
Вопрос.
Как подправить этот код, что бы результат сразу подсвечивался в выдаче БЫСТРОГО поиска?
Вот загорелся я сделать быстрый поиск с картинками. В общем пол дня ушло на пляски, но код заработал, как и хотелось.
Вопрос.
Как подправить этот код, что бы результат сразу подсвечивался в выдаче БЫСТРОГО поиска?
<?php
/*
=====================================================
DataLife Engine - by SoftNews Media Group
-----------------------------------------------------
http://quantum-soft.net/
-----------------------------------------------------
Copyright (c) 2004,2017 SoftNews Media Group
=====================================================
Данный код защищен авторскими правами
=====================================================
Файл: search.php
-----------------------------------------------------
Назначение: Быстрый поиск
=====================================================
*/
@error_reporting ( E_ALL ^ E_WARNING ^ E_NOTICE );
@ini_set ( 'display_errors', true );
@ini_set ( 'html_errors', false );
@ini_set ( 'error_reporting', E_ALL ^ E_WARNING ^ E_NOTICE );
define( 'DATALIFEENGINE', true );
define( 'ROOT_DIR', substr( dirname( __FILE__ ), 0, -12 ) );
define( 'ENGINE_DIR', ROOT_DIR . '/engine' );
include ENGINE_DIR . '/data/config.php';
if( $config['http_home_url'] == "" ) {
$config['http_home_url'] = explode( "engine/ajax/search.php", $_SERVER['PHP_SELF'] );
$config['http_home_url'] = reset( $config['http_home_url'] );
$config['http_home_url'] = "http://" . $_SERVER['HTTP_HOST'] . $config['http_home_url'];
}
if( $config['version_id'] >= '10.4' ) {
date_default_timezone_set($config['date_adjust']);
}
require_once ENGINE_DIR . '/classes/mysql.php';
require_once ENGINE_DIR . '/data/dbconfig.php';
require_once ENGINE_DIR . '/modules/functions.php';
dle_session();
require_once ENGINE_DIR . '/modules/sitelogin.php';
require_once ROOT_DIR . '/language/' . $config['langs'] . '/website.lng';
if( !$is_logged ) $member_id['user_group'] = 5;
// Определение групп пользователей
$user_group = get_vars( "usergroup" );
if( !$user_group ) {
$user_group = array ();
$db->query( "SELECT * FROM " . USERPREFIX . "_usergroups ORDER BY id ASC" );
while ( $row = $db->get_row() ) {
$user_group[$row['id']] = array ();
foreach ( $row as $key => $value ) {
$user_group[$row['id']][$key] = stripslashes($value);
}
}
set_vars( "usergroup", $user_group );
$db->free();
}
if( !$config['fast_search'] OR !$user_group[$member_id['user_group']]['allow_search'] ) die( "error" );
// Определение категорий и их параметры
$cat_info = get_vars( "category" );
if( !is_array( $cat_info ) ) {
$cat_info = array ();
$db->query( "SELECT * FROM " . PREFIX . "_category ORDER BY posi ASC" );
while ( $row = $db->get_row() ) {
$cat_info[$row['id']] = array ();
foreach ( $row as $key => $value ) {
$cat_info[$row['id']][$key] = stripslashes( $value );
}
}
set_vars( "category", $cat_info );
$db->free();
}
require_once ENGINE_DIR . '/classes/templates.class.php';
$tpl = new dle_template();
$tpl->dir = ROOT_DIR . "/templates/" . $config['skin'];
define( 'TEMPLATE_DIR', $tpl->dir );
$query = $db->safesql(htmlspecialchars(trim(strip_tags(convert_unicode($_POST['query'], $config['charset']))), ENT_QUOTES, $config['charset']));
if( $query == "" ) die();
$buffer = "";
$_TIME = ($config['version_id'] < '10.4') ? time() + ($config['date_adjust'] * 60) : time();
$this_date = date("Y-m-d H:i:s", $_TIME);
$this_date = ($config['no_date'] AND !$config['news_future']) ? " AND " . PREFIX . "_post.date < '" . $this_date . "'" : "";
$db->query( "SELECT * FROM " . PREFIX . "_post WHERE " . PREFIX . "_post.approve=1" . $this_date . " AND (short_story LIKE '%{$query}%' OR full_story LIKE '%{$query}%' OR title LIKE '%{$query}%') ORDER by date DESC LIMIT 50" );
/*
расскоментируй если нужен поиск по доп.полям и удали верхние две строчки
$db->query( "SELECT * FROM " . PREFIX . "_post WHERE " . PREFIX . "_post.approve=1" . $this_date . " AND (short_story LIKE '%{$query}%' OR full_story LIKE '%{$query}%' OR xfields LIKE '%{$query}%' OR title LIKE '%{$query}%') ORDER by date DESC LIMIT 50" );
*/
$tpl->load_template("search_popup.tpl");
if( $db->num_rows() > 0 ) {
while($row = $db->get_row()) {
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 ) {
if( $allow_list[0] != "all" and !in_array( $cat_list[0], $allow_list ) ) $perm = 0;
$my_cat[] = $cat_info[$cat_list[0]]['name'];
$my_cat_link = get_categories( $cat_list[0] );
} else {
foreach ( $cat_list as $element ) {
if( $allow_list[0] != "all" and !in_array( $element, $allow_list ) ) $perm = 0;
if( $element ) {
$my_cat[] = $cat_info[$element]['name'];
if( $config['allow_alt_url'] ) $my_cat_link[] = "<a href=\"" . $config['http_home_url'] . get_url( $element ) . "/\">{$cat_info[$element]['name']}</a>";
else $my_cat_link[] = "<a href=\"$PHP_SELF?do=cat&category={$cat_info[$element]['alt_name']}\">{$cat_info[$element]['name']}</a>";
}
}
$my_cat_link = implode( ', ', $my_cat_link );
}
$my_cat = implode( ', ', $my_cat );
}
$category_list = explode( ',', $row['category'] );
$row['date'] = strtotime( $row['date'] );
$row['category'] = intval( $row['category'] );
if( $config['allow_alt_url'] ) {
if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
if( $row['category'] and $config['seo_type'] == 2 ) {
$full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
} else {
$full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
}
$tpl->set( '[full-link]', "<a href=\"" . $full_link . "\">" );
$tpl->set( '[/full-link]', "</a>" );
$tpl->set( '{full-link}', $full_link );
if( $row['fixed'] ) {
$tpl->set( '[fixed]', "" );
$tpl->set( '[/fixed]', "" );
$tpl->set_block( "'\\[not-fixed\\](.*?)\\[/not-fixed\\]'si", "" );
} else {
$tpl->set( '[not-fixed]', "" );
$tpl->set( '[/not-fixed]', "" );
$tpl->set_block( "'\\[fixed\\](.*?)\\[/fixed\\]'si", "" );
}
$comments_num = $row['comm_num'];
$news_find = array ('{comments-num}' => $comments_num, '{views}' => $row['news_read'], '{category}' => $my_cat, '{link-category}' => $my_cat_link, '{news-id}' => $row['id'] );
$tpl->set( '', $news_find );
if( $row['allow_comm'] ) {
$tpl->set( '[com-link]', "<a id=\"dle-comm-link\" href=\"" . $full_link . "#comment\">" );
$tpl->set( '[/com-link]', "</a>" );
} else {
$tpl->set_block( "'\\[com-link\\](.*?)\\[/com-link\\]'si", "" );
}
if( !$row['approve'] and ($member_id['name'] == $row['autor'] and !$user_group[$member_id['user_group']]['allow_all_edit']) ) {
$tpl->set( '[edit]', "<a href=\"" . $config['http_home_url'] . "index.php?do=addnews&id=" . $row['id'] . "\" >" );
$tpl->set( '[/edit]', "</a>" );
if( $config['allow_quick_wysiwyg'] ) $allow_comments_ajax = true;
} elseif( $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]', "<a onclick=\"return dropdownmenu(this, event, MenuNewsBuild('" . $row['id'] . "', 'full'), '170px')\" href=\"#\">" );
$tpl->set( '[/edit]', "</a>" );
if( $config['allow_quick_wysiwyg'] ) $allow_comments_ajax = true;
} else {
$tpl->set_block( "'\\[edit\\](.*?)\\[/edit\\]'si", "" );
}
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'] ) );
}
$news_date = $row['date'];
$tpl->copy_template = preg_replace_callback ( "#\{date=(.+?)\}#i", "formdate", $tpl->copy_template );
if( $row['editdate'] ) $_DOCUMENT_DATE = $row['editdate'];
else $_DOCUMENT_DATE = $row['date'];
if( $row['view_edit'] and $row['editdate'] ) {
if( date( Ymd, $row['editdate'] ) == date( Ymd, $_TIME ) ) {
$tpl->set( '{edit-date}', $lang['time_heute'] . langdate( ", H:i", $row['editdate'] ) );
} elseif( date( Ymd, $row['editdate'] ) == date( Ymd, ($_TIME - 86400) ) ) {
$tpl->set( '{edit-date}', $lang['time_gestern'] . langdate( ", H:i", $row['editdate'] ) );
} else {
$tpl->set( '{edit-date}', langdate( $config['timestamp_active'], $row['editdate'] ) );
}
$tpl->set( '{editor}', $row['editor'] );
$tpl->set( '{edit-reason}', $row['reason'] );
if( $row['reason'] ) {
$tpl->set( '[edit-reason]', "" );
$tpl->set( '[/edit-reason]', "" );
} else {
$tpl->set_block( "'\\[edit-reason\\](.*?)\\[/edit-reason\\]'si", "" );
}
$tpl->set( '[edit-date]', "" );
$tpl->set( '[/edit-date]', "" );
} else {
$tpl->set( '{edit-date}', "" );
$tpl->set( '{editor}', "" );
$tpl->set( '{edit-reason}', "" );
$tpl->set_block( "'\\[edit-date\\](.*?)\\[/edit-date\\]'si", "" );
$tpl->set_block( "'\\[edit-reason\\](.*?)\\[/edit-reason\\]'si", "" );
}
if( $is_logged ) {
$fav_arr = explode( ',', $member_id['favorites'] );
if( ! in_array( $row['id'], $fav_arr ) ) $tpl->set( '{favorites}', "<a id=\"fav-id-" . $row['id'] . "\" href=\"$PHP_SELF?do=favorites&doaction=add&id=" . $row['id'] . "\"><img src=\"" . $config['http_home_url'] . "templates/{$config['skin']}/dleimages/plus_fav.gif\" onclick=\"doFavorites('" . $row['id'] . "', 'plus'); return false;\" title=\"" . $lang['news_addfav'] . "\" style=\"vertical-align: middle;border: none;\" alt=\"\" /></a>" );
else $tpl->set( '{favorites}', "<a id=\"fav-id-" . $row['id'] . "\" href=\"$PHP_SELF?do=favorites&doaction=del&id=" . $row['id'] . "\"><img src=\"" . $config['http_home_url'] . "templates/{$config['skin']}/dleimages/minus_fav.gif\" onclick=\"doFavorites('" . $row['id'] . "', 'minus'); return false;\" title=\"" . $lang['news_minfav'] . "\" style=\"vertical-align: middle;border: none;\" alt=\"\" /></a>" );
$tpl->set( '[complaint]', "<a href=\"javascript:AddComplaint('" . $row['id'] . "', 'news')\">" );
$tpl->set( '[/complaint]', "</a>" );
} else {
$tpl->set( '{favorites}', "" );
$tpl->set_block( "'\\[complaint\\](.*?)\\[/complaint\\]'si", "" );
}
$url_cat = $category_id;
$category_id = $row['category'];
if( strpos( $tpl->copy_template, "[catlist=" ) !== false ) {
$tpl->copy_template = preg_replace_callback ( "#\\[(catlist)=(.+?)\\](.*?)\\[/catlist\\]#is", "check_category", $tpl->copy_template );
}
if( strpos( $tpl->copy_template, "[not-catlist=" ) !== false ) {
$tpl->copy_template = preg_replace_callback ( "#\\[(not-catlist)=(.+?)\\](.*?)\\[/not-catlist\\]#is", "check_category", $tpl->copy_template );
}
$category_id = $url_cat;
if( $cat_info[$category_id]['icon'] ) {
$tpl->set( '{category-icon}', $cat_info[$category_id]['icon'] );
} else {
$tpl->set( '{category-icon}', "{THEME}/dleimages/no_icon.gif" );
}
if( $category_id ) {
$tpl->set( '{category-url}', $config['http_home_url'] . get_url( $category_id ) . "/" );
} else {
$tpl->set( '{category-url}', "#" );
}
if( $row['allow_rate'] ) {
$tpl->set( '{rating}', ShowRating( $row['id'], $row['rating'], $row['vote_num'], $user_group[$member_id['user_group']]['allow_rating'] ) );
$tpl->set( '{vote-num}', "<span id=\"vote-num-id-" . $row['id'] . "\">" . $row['vote_num'] . "</span>" );
$tpl->set( '[rating]', "" );
$tpl->set( '[/rating]', "" );
} else {
$tpl->set( '{rating}', "" );
$tpl->set( '{vote-num}', "" );
$tpl->set_block( "'\\[rating\\](.*?)\\[/rating\\]'si", "" );
}
if( $config['allow_alt_url'] ) {
$go_page = $config['http_home_url'] . "user/" . urlencode( $row['autor'] ) . "/";
$tpl->set( '[day-news]', "<a href=\"" . $config['http_home_url'] . date( 'Y/m/d/', $row['date']) . "\" >" );
} else {
$go_page = "$PHP_SELF?subaction=userinfo&user=" . urlencode( $row['autor'] );
$tpl->set( '[day-news]', "<a href=\"$PHP_SELF?year=". date( 'Y', $row['date']) . "&month=" . date( 'm', $row['date']) . "&day=" . date( 'd', $row['date']) . "\" >" );
}
$tpl->set( '[/day-news]', "</a>" );
$tpl->set( '[profile]', "<a href=\"" . $go_page . "\">" );
$tpl->set( '[/profile]', "</a>" );
$tpl->set( '{login}', $row['autor'] );
$tpl->set( '{author}', "<a onclick=\"ShowProfile('" . urlencode( $row['autor'] ) . "', '" . $go_page . "', '" . $user_group[$member_id['user_group']]['admin_editusers'] . "'); return false;\" href=\"" . $go_page . "\">" . $row['autor'] . "</a>" );
$row['title'] = stripslashes($row['title']);
$tpl->set( '{title}', $row['title'] );
if( preg_match( "#\\{title limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) ) {
$count = intval($matches[1]);
$row['title'] = strip_tags( $row['title'] );
if( $count AND dle_strlen( $row['title'], $config['charset'] ) > $count ) {
$row['title'] = dle_substr( $row['title'], 0, $count, $config['charset'] );
if( ($temp_dmax = dle_strrpos( $row['title'], ' ', $config['charset'] )) ) $row['title'] = dle_substr( $row['title'], 0, $temp_dmax, $config['charset'] );
}
$tpl->set( $matches[0], $row['title'] );
}
$row['short_story'] = stripslashes($row['short_story']);
if( stripos ( $tpl->copy_template, "{image-" ) !== false ) {
$images = array();
preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $row['short_story'], $media);
$data = preg_replace('/(img|src)("|\'|="|=\')(.*)/i', "$3", $media[0]);
foreach($data as $url) {
$info = pathinfo($url);
if( isset($info['extension']) ) {
if( $info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
$info['extension'] = strtolower($info['extension']);
if( ($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png') ) array_push($images, $url);
}
}
if( count($images) ) {
$i=0;
foreach($images as $url) {
$i++;
$tpl->copy_template = str_replace( '{image-'.$i.'}', $url, $tpl->copy_template );
$tpl->copy_template = str_replace( '[image-'.$i.']', "", $tpl->copy_template );
$tpl->copy_template = str_replace( '[/image-'.$i.']', "", $tpl->copy_template );
}
}
$tpl->copy_template = preg_replace( "#\[image-(.+?)\](.+?)\[/image-(.+?)\]#is", "", $tpl->copy_template );
$tpl->copy_template = preg_replace( "#\\{image-(.+?)\\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );
}
// Обработка дополнительных полей
$xfields = xfieldsload();
$row['xfields'] = stripslashes( $row['xfields'] );
if( count($xfields) ) {
$xfieldsdata = xfieldsdataload( $row['xfields'] );
foreach ( $xfields as $value ) {
$preg_safe_name = preg_quote( $value[0], "'" );
if( $value[20] ) {
$value[20] = explode( ',', $value[20] );
if( $value[20][0] AND !in_array( $member_id['user_group'], $value[20] ) ) {
$xfieldsdata[$value[0]] = "";
}
}
if( $value[3] == "yesorno" ) {
if( intval($xfieldsdata[$value[0]]) ) {
$xfgiven = true;
$xfieldsdata[$value[0]] = $lang['xfield_xyes'];
} else {
$xfgiven = false;
$xfieldsdata[$value[0]] = $lang['xfield_xno'];
}
} else {
if( $xfieldsdata[$value[0]] == "" ) $xfgiven = false; else $xfgiven = true;
}
if( !$xfgiven ) {
$tpl->copy_template = preg_replace( "'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template );
$tpl->copy_template = str_replace ( "[xfnotgiven_{$value[0]}]", "", $tpl->copy_template );
$tpl->copy_template = str_replace ( "[/xfnotgiven_{$value[0]}]", "", $tpl->copy_template );
} else {
$tpl->copy_template = preg_replace( "'\\[xfnotgiven_{$preg_safe_name}\\](.*?)\\[/xfnotgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template );
$tpl->copy_template = str_replace ( "[xfgiven_{$value[0]}]", "", $tpl->copy_template );
$tpl->copy_template = str_replace ( "[/xfgiven_{$value[0]}]", "", $tpl->copy_template );
}
if( strpos( $tpl->copy_template, "[ifxfvalue" ) !== false ) {
$tpl->copy_template = preg_replace_callback ( "#\\[ifxfvalue(.+?)\\](.+?)\\[/ifxfvalue\\]#is", "check_xfvalue", $tpl->copy_template );
}
if( $value[6] AND !empty( $xfieldsdata[$value[0]] ) ) {
$temp_array = explode( ",", $xfieldsdata[$value[0]] );
$value3 = array();
foreach ($temp_array as $value2) {
$value2 = trim($value2);
$value2 = str_replace("'", "'", $value2);
if( $config['allow_alt_url'] ) $value3[] = "<a href=\"" . $config['http_home_url'] . "xfsearch/" .$value[0]."/". urlencode( $value2 ) . "/\">" . $value2 . "</a>";
else $value3[] = "<a href=\"$PHP_SELF?do=xfsearch&xfname=".$value[0]."&xf=" . urlencode( $value2 ) . "\">" . $value2 . "</a>";
}
$xfieldsdata[$value[0]] = implode(", ", $value3);
unset($temp_array);
unset($value2);
unset($value3);
}
if( $config['allow_links'] AND $value[3] == "textarea" AND function_exists('replace_links') ) $xfieldsdata[$value[0]] = replace_links( $xfieldsdata[$value[0]], $replace_links['news'] );
if( $value[3] == "image" AND $xfieldsdata[$value[0]] ) {
$path_parts = @pathinfo($xfieldsdata[$value[0]]);
if( $value[12] AND file_exists(ROOT_DIR . "/uploads/posts/" .$path_parts['dirname']."/thumbs/".$path_parts['basename']) ) {
$thumb_url = $config['http_home_url'] . "uploads/posts/" . $path_parts['dirname']."/thumbs/".$path_parts['basename'];
$img_url = $config['http_home_url'] . "uploads/posts/" . $path_parts['dirname']."/".$path_parts['basename'];
} else {
$img_url = $config['http_home_url'] . "uploads/posts/" . $path_parts['dirname']."/".$path_parts['basename'];
$thumb_url = "";
}
if( $thumb_url ) {
$xfieldsdata[$value[0]] = "<a href=\"$img_url\" class=\"highslide\" target=\"_blank\"><img class=\"xfieldimage {$value[0]}\" src=\"$thumb_url\" alt=\"\" /></a>";
} else $xfieldsdata[$value[0]] = "<img class=\"xfieldimage {$value[0]}\" src=\"{$img_url}\" alt=\"\" />";
}
if( $value[3] == "image" ) {
if( $xfieldsdata[$value[0]] ) {
$tpl->copy_template = str_replace( "[xfvalue_thumb_url_{$value[0]}]", $thumb_url, $tpl->copy_template );
$tpl->copy_template = str_replace( "[xfvalue_image_url_{$value[0]}]", $img_url, $tpl->copy_template );
} else {
$tpl->copy_template = str_replace( "[xfvalue_thumb_url_{$value[0]}]", "", $tpl->copy_template );
$tpl->copy_template = str_replace( "[xfvalue_image_url_{$value[0]}]", "", $tpl->copy_template );
}
}
if( $value[3] == "imagegalery" AND $xfieldsdata[$value[0]] AND stripos( $tpl->copy_template, "[xfvalue_{$value[0]}]" ) !== false ) {
$fieldvalue_arr = explode(',', $xfieldsdata[$value[0]]);
$gallery_image = array();
foreach ($fieldvalue_arr as $temp_value) {
$temp_value = trim($temp_value);
if( $temp_value == "" ) continue;
$path_parts = @pathinfo($temp_value);
if( $value[12] AND file_exists(ROOT_DIR . "/uploads/posts/" .$path_parts['dirname']."/thumbs/".$path_parts['basename']) ) {
$thumb_url = $config['http_home_url'] . "uploads/posts/" . $path_parts['dirname']."/thumbs/".$path_parts['basename'];
$img_url = $config['http_home_url'] . "uploads/posts/" . $path_parts['dirname']."/".$path_parts['basename'];
} else {
$img_url = $config['http_home_url'] . "uploads/posts/" . $path_parts['dirname']."/".$path_parts['basename'];
$thumb_url = "";
}
if( $thumb_url ) {
$gallery_image[] = "<li><a href=\"$img_url\" onclick=\"return hs.expand(this, { slideshowGroup: 'xf_{$row['id']}_{$value[0]}' })\" target=\"_blank\"><img src=\"{$thumb_url}\" alt=\"\" /></a></li>";
} else $gallery_image[] = "<li><img src=\"{$img_url}\" alt=\"\" /></li>";
}
$xfieldsdata[$value[0]] = "<ul class=\"xfieldimagegallery {$value[0]}\">".implode($gallery_image)."</ul>";
$uniq_id = "xf_{$row['id']}_{$value[0]}";
$onload_scripts[$uniq_id] = "hs.addSlideshow({slideshowGroup: '{$uniq_id}', interval: 4000, repeat: false, useControls: true, fixedControls: 'fit', overlayOptions: { opacity: .75, position: 'bottom center', hideOnMouseOut: true } });";
}
$tpl->set( "[xfvalue_{$value[0]}]", $xfieldsdata[$value[0]]);
if( preg_match( "#\\[xfvalue_{$preg_safe_name} limit=['\"](.+?)['\"]\\]#i", $tpl->copy_template, $matches ) ) {
$count = intval($matches[1]);
$xfieldsdata[$value[0]] = str_replace( "</p><p>", " ", $xfieldsdata[$value[0]] );
$xfieldsdata[$value[0]] = strip_tags( $xfieldsdata[$value[0]], "<br>" );
$xfieldsdata[$value[0]] = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $xfieldsdata[$value[0]] ) ) ) ));
if( $count AND dle_strlen( $xfieldsdata[$value[0]], $config['charset'] ) > $count ) {
$xfieldsdata[$value[0]] = dle_substr( $xfieldsdata[$value[0]], 0, $count, $config['charset'] );
if( ($temp_dmax = dle_strrpos( $xfieldsdata[$value[0]], ' ', $config['charset'] )) ) $xfieldsdata[$value[0]] = dle_substr( $xfieldsdata[$value[0]], 0, $temp_dmax, $config['charset'] );
}
$tpl->set( $matches[0], $xfieldsdata[$value[0]] );
}
}
}
// Обработка дополнительных полей
$row['short_story'] = preg_replace( "#<!--dle_spoiler-->(.+?)<!--/dle_spoiler-->#is", "", $row['short_story'] );
$tpl->set( '{short-story}', $row['short_story'] );
if( preg_match( "#\\{short-story limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) ) {
$count = intval($matches[1]);
$row['short_story'] = str_replace( "</p><p>", " ", $row['short_story'] );
$row['short_story'] = strip_tags( $row['short_story'], "<br>" );
$row['short_story'] = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $row['short_story'] ) ) ) ));
if( $count AND dle_strlen( $row['short_story'], $config['charset'] ) > $count ) {
$row['short_story'] = dle_substr( $row['short_story'], 0, $count, $config['charset'] );
if( ($temp_dmax = dle_strrpos( $row['short_story'], ' ', $config['charset'] )) ) $row['short_story'] = dle_substr( $row['short_story'], 0, $temp_dmax, $config['charset'] );
}
$tpl->set( $matches[0], $row['short_story'] );
}
$category_id = $row['category'];
$tpl->compile( 'content' );
$tpl->result['content'] = preg_replace_callback ( "#\\[declination=(\d+)\\](.+?)\\[/declination\\]#is", "declination", $tpl->result['content'] );
if( $user_group[$member_id['user_group']]['allow_hide'] ) $tpl->result['content'] = str_ireplace( "[hide]", "", str_ireplace( "[/hide]", "", $tpl->result['content']) );
else $tpl->result['content'] = preg_replace ( "#\[hide\](.+?)\[/hide\]#ims", "<div class=\"quote\">" . $lang['news_regus'] . "</div>", $tpl->result['content'] );
$tpl->result['content'] = str_replace ('&', '&', $tpl->result['content']);
$tpl->result['content'] = preg_replace( "'\[attachment=(.*?)\]'si", "", $tpl->result['content'] );
$tpl->result['content'] = str_replace ( '{THEME}', $config['http_home_url'] . 'templates/' . $config['skin'], $tpl->result['content'] );
}
$db->free();
$tpl->result['content'].= '<span class="seperator"><a href="' . $config['http_home_url'] . '?do=search&mode=advanced&subaction=search&story=' . $query . '">' . $lang['s_ffullstart'] . '</a></span><br class="break" />';
$tpl->clear();
$buffer = $tpl->result['content'];
} else {
$buffer = "<span class=\"notfound\">{$lang['related_not_found']}</span><span class=\"seperator\"><a href=\"" . $config['http_home_url'] . "?do=search&mode=advanced&subaction=search&story=" . $query . "\">" . $lang['s_ffullstart'] . "</a></span><br class=\"break\" />";
}
@header( "Content-type: text/html; charset=" . $config['charset'] );
echo $buffer;
?>