<?php
defined('DCMS') or die;
$_path = array();
if($path_ = ini::read(H.'/sys/ini/menu.tsn.ini', true)) {
foreach($path_ as $option => $value) {
if($value['url']) {
$_path[preg_replace("/^.*=/si", '', $value['url'])] = $option;
}
}
}
if($path = ac_method::set('path', 'GP', join('|', array_keys($_path)).'|tags|search|foto')) {
$path = strtolower($path);
}
$_tags = '';
if($tags = ac_method::set('cat', 'GP')) {
$tags = htmlspecialchars(urldecode($tags));
$_tags = "&cat={$tags}";
}
$shift = array_keys(array_slice($_path, 0, 1));
$url = $site."{$path}";
if($path == $shift || $path == array_keys(array_slice($_path, 3, 1))) {
$url.= '/';
}
if($path == $shift) {
if($day = ac_method::set('day', 'GPS', false, 'I')) {
$day = (int)$day;
}
else {
$day = date('d');
}
$url.= "/{$day}";
if($month = ac_method::set('month', 'GPS', false, 'I')) {
$month = (int)$month;
}
else {
$month = date('m');
}
$url.= "-{$month}";
if($year = ac_method::set('year', 'GPS', false, 'I')) {
$year = (int)$year;
}
else {
$year = date('Y');
}
$url.= "-{$year}/";
$doc -> title = __('Новости дня %d. %d. %d г.', $year, $month, $day);
}
elseif($path == 'tags') {
$doc -> title = __('Тег: %s', $tags);
$url.= "/{$tags}";
}
elseif($path == 'search') {
$doc -> title = __('Запрос: %s', $tags);
$url.= "/{$tags}";
}
else {
$doc -> title = __($_path[$path]);
}
if($page > 1) {
if($path == $shift) {
$url.= "{$page}/";
}
else {
$url.= "?page={$page}";
}
}
include_once('inc/connect.php');
$str = preg_replace("/^.*?<div\s+class=[\"']?(content_photo|content|central_news_list|results|search\s+search_word)[\"']?.*?>|<div\s+class=[\"']?sep-0[\"']?>.*$/si", '', $str);
if(preg_match("/<table\s+class=[\"']?calendar[\"'].*?\/table>/si", $str)) {
$str = preg_replace("/<table\s+class=[\"']?calendar[\"'].*?\/table>/si", '', $str);
}
$_arr = array();
if(preg_match("/<ul\s?class=[\"']?list(_type_1)?[\"']?.*?\/ul>/si", $str)) {
preg_match_all("/<li.*?\/li>/si", preg_replace("/^.*?<ul\s+class=[\"']?list_type_1[\"']?>|<\/ul/si", '', $str), $_arr);
}
$pages = new pages(count($_arr) > 0?count($_arr[0]):0);
$pages -> items_per_page = $pages -> posts;
if(preg_match("/<div\s+class=[\"']c_pager[\"'].*?\/div>/si", $str)) {
$pages -> posts = preg_replace("/^.*?<div\s+class=[\"']c_pager[\"'].*<a.*?>(\d+)<\/a.*$/si", "\\1", $str) * $pages -> items_per_page;
}
$list = new listing;
if($pages -> posts > 0) {
print "<style>table tr td.image:nth-child(1) img:nth-child(1) {max-width: 50px!Important;max-height: 50px!Important;min-width: 50px!Important;min-height: 50px!Important;}</style>\r\n";
foreach($_arr[0] as $post) {
$elem = $list -> post();
if(preg_match("/<a.*?class=[\"']image[\"'].*?\/a>/si", $post)) {
/* Скрин */
$elem -> image = preg_replace("/^.*?<a.*?class=[\"']image[\"'].*?<img\s+src=[\"']|[\"'].*$/si", '', $post);
}
if(preg_match("/<h2\s+class=[\"'](title|photo_title)[\"'].*?\/h2>/si", $post)) {
/* Заголовок и ссылка поста */
$elem -> title = preg_replace("/^.*?<h2\s+class=[\"'](title|photo_title)[\"'].*?<a.*?>|<\/a.*$/si", '', $post);
$elem -> url = '?act=read&cat='.str_replace('/', '---', preg_replace("/^.*?<h2\s+class=[\"'](title|photo_title)[\"'].*?<a\s+href=[\"'](http:\/\/(\w+\.)?\w+\.\w+)?\/?|(\.html|[\"']).*$/si", '', $post));
}
if(preg_match("/<span\s+class=[\"']?date[\"'].*?\/span>/si", $post)) {
/* Дата публикации */
$elem -> time = preg_replace("/^.*?<span\s+class=[\"']date[\"']>|<\/span.*$/si", '', $post);
}
if(preg_match("/<span\s+class=[\"']descr[\"'].*?\/span>/si", $post)) {
/* Превью */
$elem -> post = preg_replace("/^.*?<span\s+class=[\"']descr[\"']>|<\/span.*$/si", '', $post);
}
$elem -> hightlight = true;
}
}
$list -> display(__('Категория пуста'));
if($pages -> pages > 1) {
$pages -> display("?act={$act}&path=".$path.$_tags."&");
}
if($path == $shift) {
if(isset($_GET['date'])) {
$doc -> act(__('Скрыть форму'), "?act={$act}");
$form = new form('?');
$form -> hidden('act', 'index');
$form -> text('year', __('Год'), $year, 1);
$form -> text('month', __('Месяц'), $month, 1);
$form -> text('day', __('День'), $day, 1);
$form -> button(__('Показать'));
$form -> display();
} else {
$doc -> act(__('За число...'), "?act={$act}&date");
}
}
if($dcms -> theme_version <> 3 && !isset($_GET['date'])) {
$list = new listing;
foreach($_path as $option => $value) {
$post = $list -> post();
$post -> title = __($value);
$post -> url = "?act=index&path={$option}";
}
$list -> display();
}
?>