D
deadaphelia
Посетитель
- Регистрация
- 5 Апр 2022
- Сообщения
- 36
- Реакции
- 28
PHP:
<?PHP
defined('DATALIFEENGINE') || die('Hacking attempt!');
$news_id = is_null($news_id) && !is_numeric($news_id) ? false : intval($news_id);
if(!$news_id) return;
$allow_cache = ($config['version_id'] >= '10.2') ? $config['allow_cache'] == '1' : $config['allow_cache'] == "yes";
$is_change = false;
if (!$allow_cache)
{
if ($config['version_id'] >= '10.2') $config['allow_cache'] = '1';
else $config['allow_cache'] = "yes";
$is_change = true;
}
$rows = $db->super_query("SELECT * FROM " . PREFIX . "_post WHERE id='{$news_id}'");
$where = is_null($where) && !is_string($where) ? "short_story,full_story,title,xfields" : trim(strip_tags(stripslashes($where)));
$gtype = is_null($gtype) && !is_string($gtype) ? "against" : "like";
$from = is_null($from) && !is_string($from) ? "title" : trim(strip_tags(stripslashes($from)));
if($from != "title")
{
$xf = xfieldsdataload($rows["xfields"]);
$from = $xf[$from];
}
else
$from = $rows[$from];
$from = $db->safesql($from);
if($gtype == "against")
{$where = explode(",", $where); $where = "`" . implode("`,`", $where) . "`";}
elseif ($gtype == "like")
{ $where = explode(",", $where); $where = "(`" . implode("` LIKE '%{$from}%' OR `", $where) . "`)";}
$sort = is_null($sort) && !is_string($sort) ? "date" : trim(strip_tags(stripslashes($sort)));
if($sort != "date")
$sort = "SUBSTRING_INDEX( SUBSTRING_INDEX( \"xfields\", '{$sort}|', -1 ) , '||', 1 )";
$cache_linkseazon = dle_cache( "news_linkseazon_", $config['skin'] . $news_id . '_' . $gtype . '_' . $where . '_' . $from . '_' . $sort, false);
if($cache_linkseazon) {echo $cache_linkseazon; return;}
$tpl->load_template( 'seazon.tpl' );
if($gtype == "against")
$sql_result = $db->query("SELECT id, category, xfields, title, date, alt_name FROM " . PREFIX . "_post WHERE MATCH ({$where}) AGAINST ('+$from' IN BOOLEAN MODE) ORDER BY {$sort} DESC");
elseif($gtype == "like")
$sql_result = $db->query("SELECT id, category, xfields, title, date, alt_name FROM " . PREFIX . "_post WHERE {$where} ORDER BY {$sort} DESC");
$count_rows = $sql_result->num_rows;
$allow_alt_url = ($config['version_id'] >= '10.2') ? $config['allow_alt_url'] == '1' : $config['allow_alt_url'] == "yes";
$tpl_1 = new dle_template(); $tpl_1->dir = TEMPLATE_DIR; $tpl_1->load_template( 'seazon_content.tpl' );
if($count_rows > 0)
{
while ($rowsql = $db->get_row($sql_result))
{
if($rowsql["id"] == $news_id)
{
$tpl->set_block( "'\\[this\\](.*?)\\[/this\\]'si", "\\1" );
$tpl->set_block( "'\\[not_this\\](.*?)\\[/not_this\\]'si", "" );
}
else
{
$tpl->set_block( "'\\[this\\](.*?)\\[/this\\]'si", "" );
$tpl->set_block( "'\\[not_this\\](.*?)\\[/not_this\\]'si", "\\1" );
}
$rowsql['date'] = strtotime($rowsql['date']);
$rowsql['category'] = intval($rowsql['category']);
if ($allow_alt_url)
{
if ($condition = $config['seo_type'] == 1 OR $config['seo_type'] == 2)
{
if ($rowsql['category'] and $config['seo_type'] == 2)
$full_link = $config['http_home_url'] . get_url($rowsql['category']) . "/" . $rowsql['id'] . "-" . $rowsql['alt_name'] . ".html";
else
$full_link = $config['http_home_url'] . $rowsql['id'] . "-" . $rowsql['alt_name'] . ".html";
}
else
$full_link = $config['http_home_url'] . date('Y/m/d/', $rowsql['date']) . $rowsql['alt_name'] . ".html";
}
else
$full_link = $config['http_home_url'] . "index.php?newsid=" . $rowsql['id'];
$thisdate = date( "Y-m-d H:i:s", $_TIME );
if (date('Ymd', $rowsql['date']) == date('Ymd', $thisdate))
$date_news = $lang['time_heute'] . langdate(", H:i", $rowsql['date']);
elseif (date('Ymd', $rowsql['date']) == date('Ymd', ($thisdate - 86400)))
$date_news = $lang['time_gestern'] . langdate(", H:i", $rowsql['date']);
else
$date_news = langdate($config['timestamp_active'], $rowsql['date']);
$tpl->set('{date}', $date_news);
$tpl->set('{full_link}', $full_link);
$tpl->set('{title}', $rowsql["title"]);
if ( preg_match( "#\\{title limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) )
{
$count= intval($matches[1]);
if( $count AND dle_strlen( $rowsql['title'], $config['charset'] ) > $count )
{
$rowsql['title'] = dle_substr( $rowsql['title'], 0, $count, $config['charset'] );
if( ($temp_dmax = dle_strrpos( $rowsql['title'], ' ', $config['charset'] )) ) $rowsql['title'] = dle_substr( $rowsql['title'], 0, $temp_dmax, $config['charset'] );
}
$tpl->set( $matches[0], $rowsql['title'] );
}
$tpl->copy_template = preg_replace("#\{date=(.+?)\}#ie", "langdate('\\1', '{$rowsql['date']}')", $tpl->copy_template); // формирование даты
if( strpos( $tpl->copy_template, "[xfvalue_" ) !== false OR strpos( $tpl->copy_template, "[xfgiven_" ) !== false )
{
$xf_news = xfieldsdataload($rowsql["xfields"]);
foreach($xf_news AS $name => $val)
{
if(empty( $xf_news[$name] ))
{
$tpl->copy_template = preg_replace( "'\\[xfgiven_{$name}\\](.*?)\\[/xfgiven_{$name}\\]'is", "", $tpl->copy_template);
$tpl->copy_template = str_replace("[xfvalue_{$name}]", '', $tpl->copy_template);
$tpl->copy_template = preg_replace( "'\\[xfnotgiven_{$name}\\](.*?)\\[/xfnotgiven_{$name}\\]'si", "\\1", $tpl->copy_template);
}
else
{
$tpl->copy_template = preg_replace( "'\\[xfnotgiven_{$name}\\](.*?)\\[/xfnotgiven_{$name}\\]'is", "", $tpl->copy_template);
$tpl->copy_template = str_replace("[xfvalue_{$name}]", $val, $tpl->copy_template);
$tpl->copy_template = preg_replace( "'\\[xfgiven_{$name}\\](.*?)\\[/xfgiven_{$name}\\]'si", "\\1", $tpl->copy_template);
}
}
}
$tpl->copy_template = preg_replace( "'\\[xfgiven_(.*?)\\](.*?)\\[/xfgiven_(.*?)\\]'is", "", $tpl->copy_template);
$tpl->copy_template = str_replace("[xfvalue_(.*?)]", '', $tpl->copy_template);
$tpl->copy_template = preg_replace( "'\\[xfnotgiven_(.*?)\\](.*?)\\[/xfnotgiven_(.*?)\\]'is", "", $tpl->copy_template);
$tpl->compile("seazon");
}
$tpl->clear();
$tpl_1->set( '{content_block}', $tpl->result['seazon']);
$tpl_1->set( '{num}', $count_rows );
$tpl_1->compile( 'seazon_content' );
$tpl_1->clear();
create_cache( "news_linkseazon_", $tpl_1->result['seazon_content'], $config['skin'] . $news_id . '_' . $gtype . '_' . $where . '_' . $from . '_' . $sort, false );
echo $tpl_1->result['seazon_content'];
}
?>
PHP:
$tpl_1->set( '{num}', $count_rows );
PHP:
$tpl_1->set( '{content_block}', $tpl->result['seazon']);
PHP:
$tpl_1->set( '{content_block}', $tpl->result['seazon']);
$tpl_1->set( '{num}', $count_rows );
Последнее редактирование модератором: