<?php
defined('DCMS') or die;
if(!$cat = ac_method::set('cat', 'GP')) {
refresh(false, 'Выберите категорию', '?act=index', 2);
}
if(preg_match("/^-{3}/", $cat)) {
$cat = preg_replace("/^-{3}/", '', $cat);
}
$url = $site.str_replace('---', '/', $cat).'.html';
$doc -> ret(__('Вернуться'), "?act=index&path=".preg_replace("/-{3}.*$/si", '', $cat));
$doc -> ret(__('Новости'), '?act=index');
include_once('inc/connect.php');
$str = preg_replace("/^.*?<body>|<\/body.*$/si", '', $str);
$title = 'Новость';
if(preg_match("/<h1.*?\/h1>/si", $str)) {
$title = strip_tags(preg_replace("/^.*?<h1.*?>|<\/h1.*$|&\w+;/si", '', $str));
}
$doc -> title = $title;
if(!preg_match("/<div\s+class=[\"']news_content[\"']>/si", $str)) {
refresh(false, 'Новость недоступна или была удалена');
}
$_tags = false;
if(preg_match("/<div\s+class=[\"']news_tags[\"'].*?\/div>/si", $str)) {
preg_match_all("/<a.*?\/a>/si", preg_replace("/^.*?<div\s+class=[\"']news_tags[\"']>|<\/div.*$/si", '', $str), $tags);
if(count($tags[0]) > 0) {
foreach($tags[0] as $post) {
$_tags.= "<a href=\"?act=index&path=tags&cat=".preg_replace("/^.*?<a\s+href=[\"']http:\/\/\w+\.\w+\/\w+\/|[\"'].*$/si", '', $post)."\"> ".preg_replace("/^.*?<a.*?>|<\/a.*$/si", '', $post)." </a>\r\n";
}
unset($tags);
}
}
$_date = false;
if(preg_match("/<span\s+class=[\"']date[\"']/si", $str)) {
$_date = preg_replace("/^.*?<span\s+class=[\"']date[\"']>|<\/span.*$/si", '', $str);
}
$_photo = false;
if(preg_match("/<ul\s+class=[\"']g_list\s+scrollzone[\"'].*?\/ul>/si", $str)) {
preg_match_all("/<li.*?\/li>/si", preg_replace("/^.*?<ul\s+class=[\"']g_list\s+scrollzone[\"']>|<\/ul>.*$/si", '', $str), $photo_);
if(count($photo_[0]) > 0) {
foreach($photo_[0] as $post) {
$_photo[] = str_replace('84x84', '608xX', preg_replace("/^.*?<img.*?src=[\"']|[\"'].*$/si", '', $post));
}
}
unset($photo_);
}
$str = preg_replace("/^.*?<div\s+class=[\"']news_content[\"']>|<div\s+class=[\"'](clear|inarticle_video|play_video|attached_news|v_player)[\"'].*$/si", '', $str);
if(preg_match("/<div\s+id=[\"']art_banner[\"']/si", $str)) {
$str = preg_replace("/<div\s+id=[\"']art_banner[\"'].*?\/div>/si", '', $str);
}
if($_photo) {
if($photo = ac_method::set('photo', 'GP', 1)) {
$photo = (int)$photo;
}
$photo_= count($_photo);
if($photo < 1) {
$photo = 1;
}
elseif($photo > $photo_) {
$photo = $photo_;
}
print "<img style=\"min-width: 128px;\" class=\"DCMS_photo\" src=\"".$_photo[$photo - 1]."\" />\r\n";
if($photo_> 1) {
$select = array();
for($i = 0, $l = $i + 1;$i < $photo_;$i++, $l++) {
$select[] = array("?act={$act}&cat={$cat}&photo={$l}", $l, $l == $photo);
}
$show = new design();
$show->assign('select', $select);
$show->display('design.select_bar.tpl');
}
}
elseif(preg_match("/<img\s+itemprop=[\"']image[\"']/si", $str)) {
print "<img class=\"DCMS_photo\" src=\"".preg_replace("/^.*?<img\s+itemprop=[\"']image[\"']\s+src=[\"']|[\"'].*$/si", '', $str)."\" />\r\n";
$str = preg_replace("/<div\s+class=[\"']picture\s+aleft[\"'].*?(<\/div>([\r\n\t\v\f\s]+)?){2,}/si", '', $str);
}
$list = new listing;
$elem = $list -> post();
$elem -> icon('info');
$elem -> title = __('Новость: %s', $title);
$str = strip_tags($str);
$elem -> content = $str;
if(mb_strlen($str) > 250) {
$str = mb_substr($str, 0, 250);
}
$doc -> description = $str;
$doc -> keywords = preg_split('/\s+/', $str);
if($_tags) {
$elem -> bottom = __('Теги: %s', $_tags);
}
if($_date) {
$elem -> time = $_date;
}
$list -> display();
if(preg_match("/<div\s+class=[\"']article_attached acenter[\"']/si", $str)) {
preg_match_all("/<div\s+class=[\"']article_attached acenter[\"'].*?\/div>/si", $str, $_links);
$links = count($_links[0]);
if($links > 0) {
$list = new listing;
$elem = $list -> post();
$elem -> icon('info');
$elem -> title = __('Актуально');
foreach($_links[0] as $post) {
$elem = $list -> post();
$elem -> title = preg_replace("/^.*?<a.*?>|<\/a.*$/si", '', $post);
$elem -> url = "?act=read&cat=".str_replace('/', '---', preg_replace("/^.*?<a.*?href=[\"']\/?|\.html[\"'].*$/si", '', $post));
}
$list -> display();
}
}
$smarty = new design();
$elements[] = array('type' => 'input_text', 'title' => __('Копировать ссылку'), 'br' => 0, 'info' => array('name' => '', 'value' => 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']));
$smarty->assign('el', $elements);
$smarty->display('input.form.tpl');
?>