diff --git a/README.md b/README.md index f7cdb24..605f37a 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,12 @@ -# {AJAX FULL-STORY} DLE +# DLE-AjaxFullStory +![Release version](https://img.shields.io/github/v/release/dle-modules/DLE-AjaxFullStory?style=flat-square) +![DLE](https://img.shields.io/badge/DLE-14.x-green.svg?style=flat-square "DLE Version") +![License](https://img.shields.io/github/license/dle-modules/DLE-AjaxFullStory?style=flat-square) + Бесплатный модуль для загрузки полной новости в DLE средствами AJAX ## Требования -- Версия DLE: **10.2+** (на более старых не проверялся, но должен работать вплоть до 9.6) +- Версия DLE: **14.x** ## Особенности модуля - Не требует каких-либо правок движка @@ -13,8 +17,14 @@ - Кеширование на стороне клиента (модуль отдаёт правильные заголовки) ## Установка -- Если сайт работает в кодировке windows-1251, необходимо перекодировать файлы модуля в эту кодировку. -- Залить содержимое папки **upload** в корень сайта. +- Устанавливаем как обычный плагин, файл **[afs_plugin.zip](https://github.com/dle-modules/DLE-AjaxFullStory/releases/latest)** содержит всё необходимое для автоматической установки. +- В нужном месте прописать стили и скрипты модуля (если у вас уже есть magnificpopup - второй раз прописывать не нужно) +```html + + + + +``` - В нужном месте любого шаблона вставить минимальный код: ``` html Быстрый просмотр @@ -31,77 +41,4 @@ + `data-afs-template="mytemplate"` - Путь к шаблону модуля относительно текущей папки с шаблоном сайта. Если на сайте разрешена смена скина, то путь будет построен относительно активного в данный момент шаблона сайта. По умолчанию: **{THEME}/ajax/fullstory**. (Необязательный параметр). + `data-afs-preset="mypreset"` - Путь к файлу с настройками модуля. По умолчанию не используется. Подробнее о параметрах читайте в документации. - -- В js файл шаблона вставить: -``` javascript -$(document).on('click', '[data-afs-id]', function () { - var $this = $(this), - $data = $this.data(); - - $.ajax({ - url: dle_root + 'engine/ajax/full-story.php', - type: 'GET', - dataType: 'html', - data: { - newsId: $data.afsId, // Обязательная переменная - preset: ($data.afsPreset) ? $data.afsPreset : '', // название файла с настройками - template: ($data.afsTemplate) ? $data.afsTemplate : '', // Название файла с шаблоном - }, - }) - .done(function (data) { - var $html = $(data); - - // Данные получены, можно заняться разбором и показать их в диалоге - // Ниже простейший пример вывода контента в стандартном модальном окне DLE - - var modalId = 'afs-' + $data.afsId + '-' + $data.afsPreset + '-' + $data.afsTemplate; - modalId = modalId.replace(/\//g, "-"); - - var $modalBlock = $('
'); - - $modalBlock - .appendTo('body') - .find('#' + modalId) - .html($html) - .dialog({ - width: 800 - }); - - }) - .fail(function () { - console.log("full-story error"); - }); -}); -``` - -- В CSS-файл шаблона вставить код для стилизации выводимых ошибок: -``` CSS -.afs-error { - /*Общий стиль для всех ошибок*/ - padding: 20px; - background: #fff; - color: #424242; -} -.afs-news-error { - /*Стиль ошибки, если новость не найдена*/ - background: #eceff1; -} -.afs-tpl-error { - /*Стиль ошибки, если не найден шаблон*/ - color: #b71c1c; -} -.afs-perm-error { - /*Стиль ошибки, если не достаточно прав для просмотра полной новости*/ - background: #e65100; - color: #F5F5F5; -} -``` - -## Документация -- Документация по модулю находится на [этой странице](https://github.com/pafnuty/ajax-full-story-DLE/blob/master/DOCUMENTATION.md) - -## Контакты -- URL: http://pafnuty.name/ -- twitter: https://twitter.com/pafnuty_name -- google+: http://gplus.to/pafnuty -- email: pafnuty10@gmail.com + z diff --git a/ajaxfullstory.xml b/ajaxfullstory.xml new file mode 100644 index 0000000..9a77345 --- /dev/null +++ b/ajaxfullstory.xml @@ -0,0 +1,25 @@ + + + AjaxFullStory + DLE-AjaxFullStory - модуль для загрузки полной новости в DLE средствами AJAX + + 2.0.0 + 14 + greater + https://updates.pafnuty.name/check-afs.php + 0 + + 1 + + + + + + + + + + + Настройка +Release notes]]> + \ No newline at end of file diff --git a/engine/ajax/fullstory.php b/engine/ajax/fullstory.php new file mode 100644 index 0000000..49e92fb --- /dev/null +++ b/engine/ajax/fullstory.php @@ -0,0 +1,1555 @@ + + Ошибка. Отсутствует файл шаблона: /templates/'.$config['skin'].'/'.$presetFile.'.tpl + '; + die($afs); + } + + // Разбиваем полученные из файла настройки по строкам + $preset = explode("\n", $preset); + + // Пробегаем по массиву и формируем список настроек + foreach ($preset as $v) { + $_v = explode('=', $v); + if (isset($_v[1])) { + $arConf[trim($_v[0])] = trim($_v[1]); + } + } + + // Список разрешенных полей, отбираемых из БД. + $existFields = [ + 'short_story', + 'full_story', + 'xfields', + 'comm_num', + 'fixed', + 'tags', + ]; + + // Поля, которые отбираются из БД в любом случае + $_queryFields = [ + 'id', + 'title', + 'date', + 'category', + 'alt_name', + 'approve', + 'autor', + ]; + + // Убираем пробелы, на всякий случай + $arConf['fields'] = str_replace(' ', '', $arConf['fields']); +} else { + // Если ничего не передано - заберём все поля + $arConf['fields'] = 'all'; +} + + +if ($arConf['fields'] == 'all') { + // Если передано all - значит мы хотим получить все поля из таблицы + $queryFields = '*'; +} else { + // Разбиваем поля на массив + $_fields = explode(',', $arConf['fields']); + + // Сравниваем со списком разрешенных полей + foreach ($_fields as $key => $field) { + if (!in_array($field, $existFields)) { + // Удаляем лишние поля из массива + unset($_fields[$key]); + } + } + + // Объединяем массивы + $arQueryFields = array_merge($_queryFields, $_fields); + + // И опять разбиваем, для вставки в запрос. + $queryFields = implode(', ', $arQueryFields); +} + +$newsID = (int)$_GET['newsId']; + +// Конфиг модуля +$afsCfg = [ + 'template' => !empty($_GET['template']) ? $_GET['template'] : 'ajax/fullstory', + 'cachePrefix' => !empty($arConf['cachePrefix']) ? $arConf['cachePrefix'].'_'.$newsID : 'full_'.$newsID, + 'newsId' => ($newsID > 0) ? $newsID : '0', + 'fields' => $queryFields, +]; + +if (!file_exists($template_dir.'/'.$afsCfg['template'].'.tpl')) { + $afs = '
+ Ошибка. Отсутствует файл шаблона: /templates/'.$config['skin'].'/'.$afsCfg['template'].'.tpl +
'; + die($afs); +} + +if ($afsCfg['newsId'] < 1) { + $afs = '
Ошибка. Статья не существует или удалена.
'; + die($afs); +} + +// Получаем новость +$query = "SELECT ".$afsCfg['fields']." FROM ".PREFIX."_post LEFT JOIN ".PREFIX."_post_extras ON (".PREFIX."_post.id=" + .PREFIX."_post_extras.news_id) WHERE id = ".$afsCfg['newsId']; + + +$allow_list = explode(',', $user_group[$member_id['user_group']]['allow_cats']); +$not_allow_cats = explode(',', $user_group[$member_id['user_group']]['not_allow_cats']); + +$perm = 1; +$i = 0; +$news_found = false; +$allow_full_cache = false; + +$row = dle_cache($afsCfg['cachePrefix'], $query); + +if ($row) { + $row = json_decode($row, true); +} + +if (is_array($row)) { + $full_cache = true; +} else { + $row = $db->super_query($query); + $full_cache = false; +} + +$options = news_permission($row['access']); + +if ($options[$member_id['user_group']] AND $options[$member_id['user_group']] != 3) { + $perm = 1; +} +if ($options[$member_id['user_group']] == 3) { + $perm = 0; +} + +if ($row['id'] AND !$row['approve'] AND $member_id['name'] != $row['autor'] + AND !$user_group[$member_id['user_group']]['allow_all_edit'] +) { + $perm = 0; +} + +if ($row['id'] AND $config['no_date'] AND !$config['news_future'] + AND !$user_group[$member_id['user_group']]['allow_all_edit'] +) { + if (strtotime($row['date']) > $_TIME) { + $perm = 0; + } +} + +$need_pass = $row['need_pass']; + +if ($row['id'] AND $need_pass AND $member_id['user_group'] > 2) { + if (!$_SESSION['news_pass_'.$row['id'].'']) { + $perm = 0; + $afs = '
'.$user_group[$member_id['user_group']]['group_name'] + .' не имеют доступа для просмотра статей из данного раздела.
'; + die($afs); + } else { + $need_pass = false; + } +} + +if ($config['category_separator'] != ',') { + $config['category_separator'] = ' '.$config['category_separator']; +} + +// Когда статья не найдена, скажем об этом. +if (!$row['id'] AND $perm) { + $afs = '
Ошибка. Статья не существует или удалена.
'; + die($afs); +} + +if (!$perm) { + $afs = '
'.$user_group[$member_id['user_group']]['group_name'] + .' не имеют доступа для просмотра статей из данного раздела.
'; + die($afs); +} + +if (!$row['category']) { + $my_cat = "---"; + $my_cat_link = "---"; +} else { + + $my_cat = []; + $my_cat_link = []; + $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; + } + + if ($not_allow_cats[0] != "" AND in_array($cat_list[0], $not_allow_cats)) { + $perm = 0; + } + + if ($cat_info[$cat_list[0]]['id']) { + $my_cat[] = $cat_info[$cat_list[0]]['name']; + $my_cat_link = get_categories($cat_list[0], $config['category_separator']); + } else { + $my_cat_link = "---"; + } + + } else { + + foreach ($cat_list as $element) { + + if ($allow_list[0] != "all" AND !in_array($element, $allow_list)) { + $perm = 0; + } + + if ($not_allow_cats[0] != "" AND in_array($element, $not_allow_cats)) { + $perm = 0; + } + + if ($element AND $cat_info[$element]['id']) { + $my_cat[] = $cat_info[$element]['name']; + if ($config['allow_alt_url']) { + $my_cat_link[] = "{$cat_info[$element]['name']}"; + } else { + $my_cat_link[] + = "{$cat_info[$element]['name']}"; + } + } + } + + if (count($my_cat_link)) { + $my_cat_link = implode("{$config['category_separator']} ", $my_cat_link); + } else { + $my_cat_link = "---"; + } + } + + if (count($my_cat)) { + $my_cat = implode("{$config['category_separator']} ", $my_cat); + } else { + $my_cat = "---"; + } + +} + + +if ($row['id'] AND $perm) { + + $config['fullcache_days'] = intval($config['fullcache_days']); + + if ($config['fullcache_days'] < 1) { + $config['fullcache_days'] = 30; + } + + if (strtotime($row['date']) >= ($_TIME - ($config['fullcache_days'] * 86400))) { + + $allow_full_cache = true; + + } + + $xfields = xfieldsload(); + + $category_id = intval($row['category']); + + // Подцепляем шаблонизатор + $tpl = new dle_template(); + $tpl->dir = $template_dir; + define('TEMPLATE_DIR', $tpl->dir); + // Подгружаем шаблон + $tpl->load_template($afsCfg['template'].'.tpl'); + + if (stripos($tpl->copy_template, "{next-") !== false OR stripos($tpl->copy_template, "{prev-") !== false) { + $link = ""; + $prev_next = false; + + if ($allow_full_cache) { + $prev_next = dle_cache("news", "next_prev_l_".$row['id']); + if ($prev_next) { + $prev_next = json_decode($prev_next, true); + } + } + if (!is_array($prev_next)) { + + $row_link = $db->super_query("SELECT id, date, title, category, alt_name FROM ".PREFIX + ."_post WHERE category = '{$row['category']}' AND date >= '{$row['date']}'{$where_date} AND id != '{$row['id']}' AND approve = '1' ORDER BY date ASC LIMIT 1"); + + if ($row_link['id']) { + if ($config['allow_alt_url']) { + if ($config['seo_type'] == 1 OR $config['seo_type'] == 2) { + if (intval($row_link['category']) and $config['seo_type'] == 2) { + $link = $config['http_home_url'].get_url(intval($row_link['category']))."/".$row_link['id'] + ."-".$row_link['alt_name'].".html"; + } else { + $link = $config['http_home_url'].$row_link['id']."-".$row_link['alt_name'].".html"; + } + } else { + $link = $config['http_home_url'].date('Y/m/d/', strtotime($row_link['date'])) + .$row_link['alt_name'].".html"; + } + } else { + $link = $config['http_home_url']."index.php?newsid=".$row_link['id']; + } + + $prev_next['next_title'] = str_replace("&amp;", "&", + htmlspecialchars(strip_tags(stripslashes($row_link['title'])), ENT_QUOTES, $config['charset'])); + } else { + $prev_next['next_title'] = ""; + } + + $prev_next['next_link'] = $link; + $link = ""; + + $row_link = $db->super_query("SELECT id, date, title, category, alt_name FROM ".PREFIX + ."_post WHERE category = '{$row['category']}' AND date <= '{$row['date']}'{$where_date} AND id != '{$row['id']}' AND approve = '1' ORDER BY date DESC LIMIT 1"); + + if ($row_link['id']) { + if ($config['allow_alt_url']) { + if ($config['seo_type'] == 1 OR $config['seo_type'] == 2) { + if (intval($row_link['category']) and $config['seo_type'] == 2) { + $link = $config['http_home_url'].get_url(intval($row_link['category']))."/".$row_link['id'] + ."-".$row_link['alt_name'].".html"; + } else { + $link = $config['http_home_url'].$row_link['id']."-".$row_link['alt_name'].".html"; + } + } else { + $link = $config['http_home_url'].date('Y/m/d/', strtotime($row_link['date'])) + .$row_link['alt_name'].".html"; + } + } else { + $link = $config['http_home_url']."index.php?newsid=".$row_link['id']; + } + + $prev_next['prev_title'] = str_replace("&amp;", "&", + htmlspecialchars(strip_tags(stripslashes($row_link['title'])), ENT_QUOTES, $config['charset'])); + + } else { + $prev_next['prev_title'] = ""; + } + + $prev_next['prev_link'] = $link; + + if ($allow_full_cache) { + create_cache("news", json_encode($prev_next, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), + "next_prev_l_".$row['id']); + } + + } + + if ($prev_next['next_link']) { + $tpl->set('[next-url]', ""); + $tpl->set('[/next-url]', ""); + $tpl->set('{next-url}', $prev_next['next_link']); + $tpl->set('{next-title}', $prev_next['next_title']); + } else { + $tpl->set('{next-url}', ""); + $tpl->set('{next-title}', ""); + $tpl->set_block("'\\[next-url\\](.*?)\\[/next-url\\]'si", ""); + } + + if ($prev_next['prev_link']) { + $tpl->set('[prev-url]', ""); + $tpl->set('[/prev-url]', ""); + $tpl->set('{prev-url}', $prev_next['prev_link']); + $tpl->set('{prev-title}', $prev_next['prev_title']); + } else { + $tpl->set('{prev-url}', ""); + $tpl->set('{prev-title}', ""); + $tpl->set_block("'\\[prev-url\\](.*?)\\[/prev-url\\]'si", ""); + } + + } + + if ($config['allow_read_count']) { + if ($config['allow_read_count'] == 2) { + + $readcount = $db->super_query("SELECT count(*) as count FROM ".PREFIX + ."_read_log WHERE news_id='{$row['id']}' AND ip='{$_IP}'"); + + if (!$readcount['count']) { + + if ($config['cache_count']) { + $db->query("INSERT INTO ".PREFIX."_views (news_id) VALUES ('{$row['id']}')"); + } else { + $db->query("UPDATE ".PREFIX."_post_extras SET news_read=news_read+1 WHERE news_id='{$row['id']}'"); + } + + $db->query("INSERT INTO ".PREFIX."_read_log (news_id, ip) VALUES ('{$row['id']}', '{$_IP}')"); + } + + } else { + + if ($config['cache_count']) { + $db->query("INSERT INTO ".PREFIX."_views (news_id) VALUES ('{$row['id']}')"); + } else { + $db->query("UPDATE ".PREFIX."_post_extras SET news_read=news_read+1 WHERE news_id='{$row['id']}'"); + } + } + } + + if ($allow_full_cache AND !$full_cache) { + create_cache($afsCfg['cachePrefix'], json_encode($row, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), + $query); + } + + $news_found = true; + $empty_full = false; + $row['date'] = strtotime($row['date']); + + if ((strlen($row['full_story']) < 13) and (strpos($tpl->copy_template, "{short-story}") === false)) { + $row['full_story'] = $row['short_story']; + $empty_full = true; + } + + + $row['full_story'] = str_replace("{PAGEBREAK}", "", $row['full_story']); + $row['title'] = stripslashes($row['title']); + + $comments_num = $row['comm_num']; + + $news_find = [ + '{comments-num}' => number_format($comments_num, 0, ',', ' '), + '{views}' => number_format($row['news_read'], 0, ',', ' '), + '{category}' => $my_cat, + '{link-category}' => $my_cat_link, + '{news-id}' => $row['id'], + ]; + + 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['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", ""); + } + + $tpl->set_block("'\\[comments\\](.*?)\\[/comments\\]'si", ""); + $tpl->set_block("'\\[not-comments\\](.*?)\\[/not-comments\\]'si", ""); + + + if ($row['votes']) { + + $tpl->set('[poll]', ""); + $tpl->set('[/poll]', ""); + $tpl->set_block("'\\[not-poll\\](.*?)\\[/not-poll\\]'si", ""); + + } else { + + $tpl->set('[not-poll]', ""); + $tpl->set('[/not-poll]', ""); + $tpl->set_block("'\\[poll\\](.*?)\\[/poll\\]'si", ""); + } + + if ($vk_url) { + $tpl->set('[vk]', ""); + $tpl->set('[/vk]', ""); + $tpl->set('{vk_url}', $vk_url); + } else { + $tpl->set_block("'\\[vk\\](.*?)\\[/vk\\]'si", ""); + $tpl->set('{vk_url}', ''); + } + if ($odnoklassniki_url) { + $tpl->set('[odnoklassniki]', ""); + $tpl->set('[/odnoklassniki]', ""); + $tpl->set('{odnoklassniki_url}', $odnoklassniki_url); + } else { + $tpl->set_block("'\\[odnoklassniki\\](.*?)\\[/odnoklassniki\\]'si", ""); + $tpl->set('{odnoklassniki_url}', ''); + } + if ($facebook_url) { + $tpl->set('[facebook]', ""); + $tpl->set('[/facebook]', ""); + $tpl->set('{facebook_url}', $facebook_url); + } else { + $tpl->set_block("'\\[facebook\\](.*?)\\[/facebook\\]'si", ""); + $tpl->set('{facebook_url}', ''); + } + if ($google_url) { + $tpl->set('[google]', ""); + $tpl->set('[/google]', ""); + $tpl->set('{google_url}', $google_url); + } else { + $tpl->set_block("'\\[google\\](.*?)\\[/google\\]'si", ""); + $tpl->set('{google_url}', ''); + } + if ($mailru_url) { + $tpl->set('[mailru]', ""); + $tpl->set('[/mailru]', ""); + $tpl->set('{mailru_url}', $mailru_url); + } else { + $tpl->set_block("'\\[mailru\\](.*?)\\[/mailru\\]'si", ""); + $tpl->set('{mailru_url}', ''); + } + if ($yandex_url) { + $tpl->set('[yandex]', ""); + $tpl->set('[/yandex]', ""); + $tpl->set('{yandex_url}', $yandex_url); + } else { + $tpl->set_block("'\\[yandex\\](.*?)\\[/yandex\\]'si", ""); + $tpl->set('{yandex_url}', ''); + } + + 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 ($config['allow_tags'] and $row['tags']) { + + $tpl->set('[tags]', ""); + $tpl->set('[/tags]', ""); + + $social_tags['news_keywords'] = $row['tags']; + + $tags = []; + + $row['tags'] = explode(",", $row['tags']); + + foreach ($row['tags'] as $value) { + + $value = trim($value); + $url_tag = str_replace(["'", """, "&"], ["'", '"', "&"], $value); + + if ($config['allow_alt_url']) { + $tags[] = "".$value + .""; + } else { + $tags[] = "".$value + .""; + } + + } + + $tpl->set('{tags}', implode(" ", $tags)); + + } else { + + $tpl->set_block("'\\[tags\\](.*?)\\[/tags\\]'si", ""); + $tpl->set('{tags}', ""); + + } + + $tpl->set('', $news_find); + + $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 ($category_id AND $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) { + + if ($config['allow_alt_url']) { + $tpl->set('{category-url}', $config['http_home_url'].get_url($category_id)."/"); + } else { + $tpl->set('{category-url}', "$PHP_SELF?do=cat&category={$cat_info[$category_id]['alt_name']}"); + } + + } else { + $tpl->set('{category-url}', "#"); + } + + $tpl->set_block("'\\[print-link\\](.*?)\\[/print-link\\]'si", ""); + + + if ($config['rating_type'] == "1") { + $tpl->set('[rating-type-2]', ""); + $tpl->set('[/rating-type-2]', ""); + $tpl->set_block("'\\[rating-type-1\\](.*?)\\[/rating-type-1\\]'si", ""); + $tpl->set_block("'\\[rating-type-3\\](.*?)\\[/rating-type-3\\]'si", ""); + $tpl->set_block("'\\[rating-type-4\\](.*?)\\[/rating-type-4\\]'si", ""); + } elseif ($config['rating_type'] == "2") { + $tpl->set('[rating-type-3]', ""); + $tpl->set('[/rating-type-3]', ""); + $tpl->set_block("'\\[rating-type-1\\](.*?)\\[/rating-type-1\\]'si", ""); + $tpl->set_block("'\\[rating-type-2\\](.*?)\\[/rating-type-2\\]'si", ""); + $tpl->set_block("'\\[rating-type-4\\](.*?)\\[/rating-type-4\\]'si", ""); + } elseif ($config['rating_type'] == "3") { + $tpl->set('[rating-type-4]', ""); + $tpl->set('[/rating-type-4]', ""); + $tpl->set_block("'\\[rating-type-1\\](.*?)\\[/rating-type-1\\]'si", ""); + $tpl->set_block("'\\[rating-type-2\\](.*?)\\[/rating-type-2\\]'si", ""); + $tpl->set_block("'\\[rating-type-3\\](.*?)\\[/rating-type-3\\]'si", ""); + } else { + $tpl->set('[rating-type-1]', ""); + $tpl->set('[/rating-type-1]', ""); + $tpl->set_block("'\\[rating-type-4\\](.*?)\\[/rating-type-4\\]'si", ""); + $tpl->set_block("'\\[rating-type-3\\](.*?)\\[/rating-type-3\\]'si", ""); + $tpl->set_block("'\\[rating-type-2\\](.*?)\\[/rating-type-2\\]'si", ""); + } + + if ($row['allow_rate']) { + + $dislikes = ($row['vote_num'] - $row['rating']) / 2; + $likes = $row['vote_num'] - $dislikes; + + $tpl->set('{likes}', "".$likes.""); + $tpl->set('{dislikes}', "".$dislikes.""); + + $tpl->set('{rating}', ShowRating($row['id'], $row['rating'], $row['vote_num'], + $user_group[$member_id['user_group']]['allow_rating'])); + $tpl->set('{vote-num}', "".$row['vote_num'].""); + $tpl->set('[rating]', ""); + $tpl->set('[/rating]', ""); + + if ($row['vote_num']) { + $ratingscore = str_replace(',', '.', round(($row['rating'] / $row['vote_num']), 1)); + } else { + $ratingscore = 0; + } + + $tpl->set('{ratingscore}', $ratingscore); + + if ($user_group[$member_id['user_group']]['allow_rating']) { + + if ($config['rating_type']) { + + $tpl->set('[rating-plus]', ""); + $tpl->set('[/rating-plus]', ''); + + if ($config['rating_type'] == "2" OR $config['rating_type'] == "3") { + + $tpl->set('[rating-minus]', + ""); + $tpl->set('[/rating-minus]', ''); + + } else { + $tpl->set_block("'\\[rating-minus\\](.*?)\\[/rating-minus\\]'si", ""); + } + + } else { + $tpl->set_block("'\\[rating-plus\\](.*?)\\[/rating-plus\\]'si", ""); + $tpl->set_block("'\\[rating-minus\\](.*?)\\[/rating-minus\\]'si", ""); + } + + } else { + $tpl->set_block("'\\[rating-plus\\](.*?)\\[/rating-plus\\]'si", ""); + $tpl->set_block("'\\[rating-minus\\](.*?)\\[/rating-minus\\]'si", ""); + } + + } else { + + $tpl->set('{rating}', ""); + $tpl->set('{vote-num}', ""); + $tpl->set('{likes}', ""); + $tpl->set('{dislikes}', ""); + $tpl->set('{ratingscore}', ""); + $tpl->set_block("'\\[rating\\](.*?)\\[/rating\\]'si", ""); + $tpl->set_block("'\\[rating-plus\\](.*?)\\[/rating-plus\\]'si", ""); + $tpl->set_block("'\\[rating-minus\\](.*?)\\[/rating-minus\\]'si", ""); + } + $tpl->set_block("'\\[comments-subscribe\\](.*?)\\[/comments-subscribe\\]'si", ""); + + if ($config['allow_alt_url']) { + + $go_page = $config['http_home_url']."user/".urlencode($row['autor'])."/"; + $tpl->set('[day-news]', ""); + + } else { + + $go_page = "$PHP_SELF?subaction=userinfo&user=".urlencode($row['autor']); + $tpl->set('[day-news]', + ""); + + } + + $tpl->set('[/day-news]', ""); + $tpl->set('[profile]', ""); + $tpl->set('[/profile]', ""); + + $tpl->set('{login}', $row['autor']); + + $tpl->set('{author}', "" + .$row['autor'].""); + + $_SESSION['referrer'] = htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES, $config['charset']); + + $tpl->set('[full-link]', ""); + $tpl->set('[/full-link]', ""); + + $tpl->set('{full-link}', $full_link); + + if ($row['allow_comm']) { + + $tpl->set('[com-link]', ""); + $tpl->set('[/com-link]', ""); + + } 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]', ""); + $tpl->set('[/edit]', ""); + + 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]', ""); + $tpl->set('[/edit]', ""); + + if ($config['allow_quick_wysiwyg']) { + $allow_comments_ajax = true; + } + + } else { + $tpl->set_block("'\\[edit\\](.*?)\\[/edit\\]'si", ""); + } + + if ($is_logged) { + + $fav_arr = explode(',', $member_id['favorites']); + + if (!in_array($row['id'], $fav_arr)) { + + $tpl->set('{favorites}', + "\"\""); + $tpl->set('[add-favorites]', ""); + $tpl->set('[/add-favorites]', ""); + $tpl->set_block("'\\[del-favorites\\](.*?)\\[/del-favorites\\]'si", ""); + } else { + + $tpl->set('{favorites}', + "\"\""); + $tpl->set('[del-favorites]', ""); + $tpl->set('[/del-favorites]', ""); + $tpl->set_block("'\\[add-favorites\\](.*?)\\[/add-favorites\\]'si", ""); + } + + } else { + $tpl->set('{favorites}', ""); + $tpl->set_block("'\\[add-favorites\\](.*?)\\[/add-favorites\\]'si", ""); + $tpl->set_block("'\\[del-favorites\\](.*?)\\[/del-favorites\\]'si", ""); + } + + $tpl->set('[complaint]', ""); + $tpl->set('[/complaint]', ""); + + $tpl->set('{poll}', ''); + + if ($config['allow_banner']) { + include_once(DLEPlugins::Check(ENGINE_DIR.'/modules/banners.php')); + } + + if ($config['allow_banner'] AND count($banners)) { + + foreach ($banners as $name => $value) { + $tpl->copy_template = str_replace("{banner_".$name."}", $value, $tpl->copy_template); + + if ($value) { + $tpl->copy_template = str_replace("[banner_".$name."]", "", $tpl->copy_template); + $tpl->copy_template = str_replace("[/banner_".$name."]", "", $tpl->copy_template); + } + } + } + + $tpl->set_block("'{banner_(.*?)}'si", ""); + $tpl->set_block("'\\[banner_(.*?)\\](.*?)\\[/banner_(.*?)\\]'si", ""); + + $row['short_story'] = stripslashes($row['short_story']); + $row['full_story'] = stripslashes($row['full_story']); + $row['xfields'] = stripslashes($row['xfields']); + + if ($config['allow_links'] AND function_exists('replace_links') AND isset($replace_links['news'])) { + $row['short_story'] = replace_links($row['short_story'], $replace_links['news']); + $row['full_story'] = replace_links($row['full_story'], $replace_links['news']); + } + + if (stripos($tpl->copy_template, "{image-") !== false) { + + $images = []; + preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $row['short_story'].$row['xfields'], $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-minus" + OR strpos($info['dirname'], 'engine/data/emoticons') !== false + ) { + continue; + } + $info['extension'] = strtolower($info['extension']); + if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') + || ($info['extension'] == 'png') + || ($info['extension'] == 'webp') + ) { + 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("#\[not-image-{$i}\](.+?)\[/not-image-{$i}\]#is", "", + $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); + $tpl->copy_template = preg_replace("#\[not-image-(.+?)\]#i", "", $tpl->copy_template); + $tpl->copy_template = preg_replace("#\[/not-image-(.+?)\]#i", "", $tpl->copy_template); + + } + + if (stripos($tpl->copy_template, "{fullimage-") !== false) { + + $images = []; + preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $row['full_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-minus" + OR strpos($info['dirname'], 'engine/data/emoticons') !== false + ) { + continue; + } + $info['extension'] = strtolower($info['extension']); + if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') + || ($info['extension'] == 'png') + || ($info['extension'] == 'webp') + ) { + array_push($images, $url); + } + } + } + + if (count($images)) { + $i = 0; + foreach ($images as $url) { + $i++; + $tpl->copy_template = str_replace('{fullimage-'.$i.'}', $url, $tpl->copy_template); + $tpl->copy_template = str_replace('[fullimage-'.$i.']', "", $tpl->copy_template); + $tpl->copy_template = str_replace('[/fullimage-'.$i.']', "", $tpl->copy_template); + } + + } + + $tpl->copy_template = preg_replace("#\[fullimage-(.+?)\](.+?)\[/fullimage-(.+?)\]#is", "", $tpl->copy_template); + $tpl->copy_template = preg_replace("#\\{fullimage-(.+?)\\}#i", "{THEME}/dleimages/no_image.jpg", + $tpl->copy_template); + + } + + $images = []; + $allcontent = $row['full_story'].$row['short_story'].$row['xfields']; + preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $allcontent, $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-minus" OR strpos($info['dirname'], + 'engine/data/emoticons') !== false + ) { + continue; + } + $info['extension'] = strtolower($info['extension']); + if (($info['extension'] == 'jpg' || $info['extension'] == 'jpeg' || $info['extension'] == 'gif' + || $info['extension'] == 'png' + || $info['extension'] == 'webp') AND !in_array($url, $images) + ) { + array_push($images, $url); + } + } + } + + if (count($images)) { + $social_tags['image'] = str_replace("/thumbs/", "/", $images[0]); + $social_tags['image'] = str_replace("/medium/", "/", $social_tags['image']); + } + + if (preg_match("##is", $allcontent, $media)) { + $media[1] = str_replace("|", "|", $media[1]); + + $media[1] = explode(",", trim($media[1])); + + if (count($media[1]) > 1 AND stripos($media[1][0], "http") === false AND intval($media[1][0])) { + $media[1] = explode("|", $media[1][1]); + } else { + $media[1] = explode("|", $media[1][0]); + } + + $social_tags['video'] = $media[1][0]; + + } + + if (preg_match("##is", $allcontent, $media)) { + $media[1] = str_replace("|", "|", $media[1]); + + $media[1] = explode(",", trim($media[1])); + + if (count($media[1]) > 1 AND stripos($media[1][0], "http") === false AND intval($media[1][0])) { + $media[1] = explode("|", $media[1][1]); + } else { + $media[1] = explode("|", $media[1][0]); + } + + $social_tags['audio'] = $media[1][0]; + + } + + if ($smartphone_detected) { + + if (!$config['allow_smart_format']) { + + $row['short_story'] = strip_tags($row['short_story'], '


'); + $row['full_story'] = strip_tags($row['full_story'], '


'); + + } else { + + if (!$config['allow_smart_images']) { + + $row['short_story'] = preg_replace("##is", "", $row['short_story']); + $row['short_story'] = preg_replace("##is", "", $row['short_story']); + $row['short_story'] = preg_replace("##is", "", $row['short_story']); + $row['full_story'] = preg_replace("##is", "", $row['full_story']); + $row['full_story'] = preg_replace("##is", "", $row['full_story']); + $row['full_story'] = preg_replace("##is", "", $row['full_story']); + + } + + if (!$config['allow_smart_video']) { + + $row['short_story'] = preg_replace("##is", "", + $row['short_story']); + $row['short_story'] = preg_replace("##is", "", + $row['short_story']); + $row['short_story'] = preg_replace("##is", "", + $row['short_story']); + $row['full_story'] = preg_replace("##is", "", + $row['full_story']); + $row['full_story'] = preg_replace("##is", "", + $row['full_story']); + $row['full_story'] = preg_replace("##is", "", + $row['full_story']); + + } + + } + + } + $tpl->set('{comments}', ""); + $tpl->set('{addcomments}', ""); + $tpl->set('{navigation}', ""); + + if ($config['image_lazy'] AND $view_template != "print") { + $row['short_story'] = preg_replace_callback("##i", "enable_lazyload", $row['short_story']); + $row['full_story'] = preg_replace_callback("##i", "enable_lazyload", $row['full_story']); + } + + $row['full_story'] = str_replace("{PAGEBREAK}", "", $row['full_story']); + $row['full_story'] = preg_replace("'\[page=(.*?)\](.*?)\[/page\]'si", "\\2", $row['full_story']); + $tpl->set_block("'\\[pages\\](.*?)\\[/pages\\]'si", ""); + $tpl->set('{pages}', ""); + + $tpl->set('{short-story}', $row['short_story']); + + $tpl->set('{full-story}', $row['full_story']); + + if (preg_match("#\\{full-story limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches)) { + $count = intval($matches[1]); + + $row['full_story'] = preg_replace("##is", "", $row['full_story']); + $row['full_story'] = preg_replace("#(.+?)#is", "", + $row['full_story']); + $row['full_story'] = preg_replace("'\[attachment=(.*?)\]'si", "", $row['full_story']); + $row['full_story'] = preg_replace("#\[hide(.*?)\](.+?)\[/hide\]#is", "", $row['full_story']); + + $row['full_story'] = str_replace("><", "> <", $row['full_story']); + $row['full_story'] = strip_tags($row['full_story'], "
"); + $row['full_story'] = trim(str_replace("
", " ", + str_replace("
", " ", str_replace("\n", " ", str_replace("\r", "", $row['full_story']))))); + $row['full_story'] = preg_replace('/\s+/u', ' ', $row['full_story']); + + if ($count AND dle_strlen($row['full_story'], $config['charset']) > $count) { + + $row['full_story'] = dle_substr($row['full_story'], 0, $count, $config['charset']); + + if (($temp_dmax = dle_strrpos($row['full_story'], ' ', $config['charset']))) { + $row['full_story'] = dle_substr($row['full_story'], 0, $temp_dmax, $config['charset']); + } + + } + + $tpl->set($matches[0], $row['full_story']); + + } + + $tpl->set('{title}', + str_replace("&amp;", "&", htmlspecialchars($row['title'], ENT_QUOTES, $config['charset']))); + + 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], + str_replace("&amp;", "&", htmlspecialchars($row['title'], ENT_QUOTES, $config['charset']))); + + } + + $xfieldsdata = $row['xfields']; + $category_id = $row['category']; + + $all_xf_content = []; + + 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_ireplace("[xfnotgiven_{$value[0]}]", "", $tpl->copy_template); + $tpl->copy_template = str_ireplace("[/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_ireplace("[xfgiven_{$value[0]}]", "", $tpl->copy_template); + $tpl->copy_template = str_ireplace("[/xfgiven_{$value[0]}]", "", $tpl->copy_template); + } + + if (strpos($tpl->copy_template, "[ifxfvalue {$value[0]}") !== 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 = []; + + foreach ($temp_array as $value2) { + + $value2 = trim($value2); + + if ($value2) { + + $value4 = str_replace(["'", """, "&", "{", "[", ":"], + ["'", '"', "&", "{", "[", ":"], $value2); + + if ($value[3] == "datetime") { + + $value2 = strtotime($value4); + + if (!trim($value[24])) { + $value[24] = $config['timestamp_active']; + } + + if ($value[25]) { + + if ($value[26]) { + $value2 = langdate($value[24], $value2); + } else { + $value2 = langdate($value[24], $value2, false, $customlangdate); + } + + } else { + $value2 = date($value[24], $value2); + } + + } + + if ($config['allow_alt_url']) { + $value3[] = "
".$value2.""; + } else { + $value3[] = "".$value2.""; + } + } + + } + + if (empty($value[21])) { + $value[21] = ", "; + } + + $xfieldsdata[$value[0]] = implode($value[21], $value3); + + unset($temp_array); + unset($value2); + unset($value3); + unset($value3); + + } elseif ($value[3] == "datetime" AND !empty($xfieldsdata[$value[0]])) { + + $xfieldsdata[$value[0]] = strtotime(str_replace(":", ":", $xfieldsdata[$value[0]])); + + if (!trim($value[24])) { + $value[24] = $config['timestamp_active']; + } + + if ($value[25]) { + + if ($value[26]) { + $xfieldsdata[$value[0]] = langdate($value[24], $xfieldsdata[$value[0]]); + } else { + $xfieldsdata[$value[0]] = langdate($value[24], $xfieldsdata[$value[0]], false, $customlangdate); + } + + } else { + $xfieldsdata[$value[0]] = date($value[24], $xfieldsdata[$value[0]]); + } + + + } + + 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]]) { + + $temp_array = explode('|', $xfieldsdata[$value[0]]); + + if (count($temp_array) > 1) { + + $temp_alt = $temp_array[0]; + $temp_value = $temp_array[1]; + + } else { + + $temp_alt = ''; + $temp_value = $temp_array[0]; + + } + + $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) { + $tpl->set("[xfvalue_thumb_url_{$value[0]}]", $thumb_url); + $xfieldsdata[$value[0]] + = "\"{$temp_alt}\""; + } else { + $tpl->set("[xfvalue_thumb_url_{$value[0]}]", $img_url); + $xfieldsdata[$value[0]] + = "\"{$temp_alt}\""; + } + + $tpl->set("[xfvalue_image_url_{$value[0]}]", $img_url); + + } + + if ($value[3] == "image" AND !$xfieldsdata[$value[0]]) { + + $tpl->set("[xfvalue_thumb_url_{$value[0]}]", ""); + $tpl->set("[xfvalue_image_url_{$value[0]}]", ""); + + } + + 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 = []; + $gallery_single_image = []; + $xf_image_count = 0; + $single_need = false; + + if (stripos($tpl->copy_template, "[xfvalue_{$value[0]} image=") !== false) { + $single_need = true; + } + + foreach ($fieldvalue_arr as $temp_value) { + $xf_image_count++; + + $temp_value = trim($temp_value); + + if ($temp_value == "") { + continue; + } + + $temp_array = explode('|', $temp_value); + + if (count($temp_array) > 1) { + + $temp_alt = $temp_array[0]; + $temp_value = $temp_array[1]; + + } else { + + $temp_alt = ''; + $temp_value = $temp_array[0]; + + } + + $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[] + = "

  • \"{$temp_alt}\"
  • "; + $gallery_single_image['[xfvalue_'.$value[0].' image="'.$xf_image_count.'"]'] + = "\"{$temp_alt}\""; + + } else { + $gallery_image[] = "
  • \"{$temp_alt}\"
  • "; + $gallery_single_image['[xfvalue_'.$value[0].' image="'.$xf_image_count.'"]'] + = "\"{$temp_alt}\""; + } + + } + + if ($single_need AND count($gallery_single_image)) { + foreach ($gallery_single_image as $temp_key => $temp_value) { + $tpl->set($temp_key, $temp_value); + } + } + + $xfieldsdata[$value[0]] = ""; + + } + + if ($config['image_lazy'] AND $view_template != "print") { + $xfieldsdata[$value[0]] = preg_replace_callback("##i", "enable_lazyload", + $xfieldsdata[$value[0]]); + } + + $tpl->set("[xfvalue_{$value[0]}]", $xfieldsdata[$value[0]]); + + $all_xf_content[] = $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("><", "> <", $xfieldsdata[$value[0]]); + $xfieldsdata[$value[0]] = strip_tags($xfieldsdata[$value[0]], "
    "); + $xfieldsdata[$value[0]] = trim(str_replace("
    ", " ", str_replace("
    ", " ", + str_replace("\n", " ", str_replace("\r", "", $xfieldsdata[$value[0]]))))); + $xfieldsdata[$value[0]] = preg_replace('/\s+/u', ' ', $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]]); + + } + } + } + + $tpl->compile('afs'); + + if (stripos($tpl->result['afs'], "[hide") !== false) { + + $tpl->result['afs'] = preg_replace_callback("#\[hide(.*?)\](.+?)\[/hide\]#is", + function ($matches) use ($member_id, $user_group, $lang) { + + $matches[1] = str_replace(["=", " "], "", $matches[1]); + $matches[2] = $matches[2]; + + if ($matches[1]) { + + $groups = explode(',', $matches[1]); + + if (in_array($member_id['user_group'], $groups) OR $member_id['user_group'] == "1") { + return $matches[2]; + } else { + return "
    ".$lang['news_regus']."
    "; + } + + } else { + + if ($user_group[$member_id['user_group']]['allow_hide']) { + return $matches[2]; + } else { + return "
    ".$lang['news_regus']."
    "; + } + + } + + }, $tpl->result['afs']); + } + + if ($config['allow_banner'] AND count($banner_in_news)) { + + foreach ($banner_in_news as $name) { + $tpl->result['afs'] = str_replace("{banner_".$name."}", $banners[$name], $tpl->result['afs']); + + if ($banners[$name]) { + $tpl->result['afs'] = str_replace("[banner_".$name."]", "", $tpl->result['afs']); + $tpl->result['afs'] = str_replace("[/banner_".$name."]", "", $tpl->result['afs']); + } + } + + $tpl->result['afs'] = preg_replace("'\\[banner_(.*?)\\](.*?)\\[/banner_(.*?)\\]'si", '', $tpl->result['afs']); + + } + + $news_id = $row['id']; + + + if ($config['files_allow'] AND $news_found) { + if (strpos($tpl->result['afs'], "[attachment=") !== false) { + $tpl->result['afs'] = show_attach($tpl->result['afs'], $news_id); + } + } + + $tpl->clear(); + + $afs = $tpl->result['afs']; + +} + +unset($row); + +// Устанавливаем правильные заголовки +$seconds = 86400; // 1 день для кеша в браузере + +// Определяем дату создания кеша, при использовании файлового кеша +// @TODO: наладить Expires при работе с мемкешем. +$_end_file = ($is_logged) ? '_'.$member_id['user_group'] : '_0'; +$filedate = ENGINE_DIR.'/cache/'.$afsCfg['cachePrefix'].'_'.md5($cacheName).$_end_file.'.tmp'; + +header('Content-Type: text/html; charset='.$config['charset']); +header('Cache-Control: public, max-age='.$seconds); + +if (!file_exists($filedate)) { + $lastModified = $_TIME; +} else { + $etag = md5_file($filedate); + $lastModified = filemtime($filedate); + + header("Expires: ".gmdate("D, d M Y H:i:s", $lastModified + $seconds)." GMT"); + header("Last-Modified: ".gmdate("D, d M Y H:i:s", $lastModified)." GMT"); + + header("Etag: $etag"); + if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified + || @trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag + ) { + header("HTTP/1.1 304 Not Modified"); + exit; + } +} + +// Выводим результат +echo $afs; \ No newline at end of file diff --git a/templates/{THEME}/ajax/fullstory.css b/templates/{THEME}/ajax/fullstory.css new file mode 100644 index 0000000..280e710 --- /dev/null +++ b/templates/{THEME}/ajax/fullstory.css @@ -0,0 +1,28 @@ +/* Стиль модального окна */ +.afs-modal .mfp-content .fullstory { + margin: 20px auto; + max-width: 800px; +} + +.afs-error { + /* Общий стиль для всех ошибок */ + padding: 20px; + background: #fff; + color: #424242; +} + +.afs-news-error { + /* Стиль ошибки, если новость не найдена */ + background: #eceff1; +} + +.afs-tpl-error { + /* Стиль ошибки, если не найден шаблон */ + color: #b71c1c; +} + +.afs-perm-error { + /* Стиль ошибки, если не достаточно прав для просмотра полной новости */ + background: #e65100; + color: #f5f5f5; +} \ No newline at end of file diff --git a/templates/{THEME}/ajax/fullstory.js b/templates/{THEME}/ajax/fullstory.js new file mode 100644 index 0000000..41beeea --- /dev/null +++ b/templates/{THEME}/ajax/fullstory.js @@ -0,0 +1,26 @@ +$(document).on('click', '[data-afs-id]', function (event) { + event.preventDefault(); + var $this = $(event.currentTarget); + var $data = $this.data(); + + $.magnificPopup.open({ + type: 'ajax', + mainClass: 'afs-modal', + items: { + // eslint-disable-next-line camelcase + src: dle_root + 'engine/ajax/controller.php' + }, + ajax: { + settings: { + type: 'GET', + dataType: 'html', + data: { + mod: 'fullstory', + newsId: $data.afsId, + preset: $data.afsPreset ? $data.afsPreset : '', + template: $data.afsTemplate ? $data.afsTemplate : '' + } + } + } + }); +}); \ No newline at end of file diff --git a/templates/{THEME}/ajax/fullstory.tpl b/templates/{THEME}/ajax/fullstory.tpl new file mode 100644 index 0000000..47514b1 --- /dev/null +++ b/templates/{THEME}/ajax/fullstory.tpl @@ -0,0 +1,58 @@ +
    +
    + [not-group=5] +
      +
    • + [add-favorites][/add-favorites] + [del-favorites][/del-favorites] +
    • +
    • + [edit]Редактировать[/edit] +
    • +
    + [/not-group] +

    {title}

    +
    + {full-story} + [edit-date]

    Новость отредактировал: {editor} - {edit-date}
    + [edit-reason]Причина: {edit-reason}[/edit-reason]

    [/edit-date] +
    + {pages} +
    +
    + + {link-category} +
    + [rating] +
    + [rating-type-1]
    {rating}
    [/rating-type-1] + [rating-type-2] +
    + [rating-plus] + + {rating} + [/rating-plus] +
    + [/rating-type-2] + [rating-type-3] +
    + [rating-plus][/rating-plus] + {rating} + [rating-minus][/rating-minus] +
    + [/rating-type-3] +
    + [/rating] +
    + [fixed][/fixed] +
    +
    +
      +
    • {views}
    • +
    • [com-link] {comments-num}[/com-link]
    • +
    +
      + +
    +
    +
    \ No newline at end of file diff --git a/templates/{THEME}/ajax/magnificpopup.css b/templates/{THEME}/ajax/magnificpopup.css new file mode 100644 index 0000000..6280e82 --- /dev/null +++ b/templates/{THEME}/ajax/magnificpopup.css @@ -0,0 +1,351 @@ +/* Magnific Popup CSS */ +.mfp-bg { + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 1042; + overflow: hidden; + position: fixed; + background: #0b0b0b; + opacity: 0.8; } + +.mfp-wrap { + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 1043; + position: fixed; + outline: none !important; + -webkit-backface-visibility: hidden; } + +.mfp-container { + text-align: center; + position: absolute; + width: 100%; + height: 100%; + left: 0; + top: 0; + padding: 0 8px; + box-sizing: border-box; } + +.mfp-container:before { + content: ''; + display: inline-block; + height: 100%; + vertical-align: middle; } + +.mfp-align-top .mfp-container:before { + display: none; } + +.mfp-content { + position: relative; + display: inline-block; + vertical-align: middle; + margin: 0 auto; + text-align: left; + z-index: 1045; } + +.mfp-inline-holder .mfp-content, +.mfp-ajax-holder .mfp-content { + width: 100%; + cursor: auto; } + +.mfp-ajax-cur { + cursor: progress; } + +.mfp-zoom-out-cur, .mfp-zoom-out-cur .mfp-image-holder .mfp-close { + cursor: -moz-zoom-out; + cursor: -webkit-zoom-out; + cursor: zoom-out; } + +.mfp-zoom { + cursor: pointer; + cursor: -webkit-zoom-in; + cursor: -moz-zoom-in; + cursor: zoom-in; } + +.mfp-auto-cursor .mfp-content { + cursor: auto; } + +.mfp-close, +.mfp-arrow, +.mfp-preloader, +.mfp-counter { + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; } + +.mfp-loading.mfp-figure { + display: none; } + +.mfp-hide { + display: none !important; } + +.mfp-preloader { + color: #CCC; + position: absolute; + top: 50%; + width: auto; + text-align: center; + margin-top: -0.8em; + left: 8px; + right: 8px; + z-index: 1044; } +.mfp-preloader a { + color: #CCC; } +.mfp-preloader a:hover { + color: #FFF; } + +.mfp-s-ready .mfp-preloader { + display: none; } + +.mfp-s-error .mfp-content { + display: none; } + +button.mfp-close, +button.mfp-arrow { + overflow: visible; + cursor: pointer; + background: transparent; + border: 0; + -webkit-appearance: none; + display: block; + outline: none; + padding: 0; + z-index: 1046; + box-shadow: none; + touch-action: manipulation; } + +button::-moz-focus-inner { + padding: 0; + border: 0; } + +.mfp-close { + width: 44px; + height: 44px; + line-height: 44px; + position: absolute; + right: 0; + top: 0; + text-decoration: none; + text-align: center; + opacity: 0.65; + padding: 0 0 18px 10px; + color: #FFF; + font-style: normal; + font-size: 28px; + font-family: Arial, Baskerville, monospace; } +.mfp-close:hover, +.mfp-close:focus { + opacity: 1; } +.mfp-close:active { + top: 1px; } + +.mfp-close-btn-in .mfp-close { + color: #333; } + +.mfp-image-holder .mfp-close, +.mfp-iframe-holder .mfp-close { + color: #FFF; + right: -6px; + text-align: right; + padding-right: 6px; + width: 100%; } + +.mfp-counter { + position: absolute; + top: 0; + right: 0; + color: #CCC; + font-size: 12px; + line-height: 18px; + white-space: nowrap; } + +.mfp-arrow { + position: absolute; + opacity: 0.65; + margin: 0; + top: 50%; + margin-top: -55px; + padding: 0; + width: 90px; + height: 110px; + -webkit-tap-highlight-color: transparent; } +.mfp-arrow:active { + margin-top: -54px; } +.mfp-arrow:hover, +.mfp-arrow:focus { + opacity: 1; } +.mfp-arrow:before, +.mfp-arrow:after { + content: ''; + display: block; + width: 0; + height: 0; + position: absolute; + left: 0; + top: 0; + margin-top: 35px; + margin-left: 35px; + border: medium inset transparent; } +.mfp-arrow:after { + border-top-width: 13px; + border-bottom-width: 13px; + top: 8px; } +.mfp-arrow:before { + border-top-width: 21px; + border-bottom-width: 21px; + opacity: 0.7; } + +.mfp-arrow-left { + left: 0; } +.mfp-arrow-left:after { + border-right: 17px solid #FFF; + margin-left: 31px; } +.mfp-arrow-left:before { + margin-left: 25px; + border-right: 27px solid #3F3F3F; } + +.mfp-arrow-right { + right: 0; } +.mfp-arrow-right:after { + border-left: 17px solid #FFF; + margin-left: 39px; } +.mfp-arrow-right:before { + border-left: 27px solid #3F3F3F; } + +.mfp-iframe-holder { + padding-top: 40px; + padding-bottom: 40px; } +.mfp-iframe-holder .mfp-content { + line-height: 0; + width: 100%; + max-width: 900px; } +.mfp-iframe-holder .mfp-close { + top: -40px; } + +.mfp-iframe-scaler { + width: 100%; + height: 0; + overflow: hidden; + padding-top: 56.25%; } +.mfp-iframe-scaler iframe { + position: absolute; + display: block; + top: 0; + left: 0; + width: 100%; + height: 100%; + box-shadow: 0 0 8px rgba(0, 0, 0, 0.6); + background: #000; } + +/* Main image in popup */ +img.mfp-img { + width: auto; + max-width: 100%; + height: auto; + display: block; + line-height: 0; + box-sizing: border-box; + padding: 40px 0 40px; + margin: 0 auto; } + +/* The shadow behind the image */ +.mfp-figure { + line-height: 0; } +.mfp-figure:after { + content: ''; + position: absolute; + left: 0; + top: 40px; + bottom: 40px; + display: block; + right: 0; + width: auto; + height: auto; + z-index: -1; + box-shadow: 0 0 8px rgba(0, 0, 0, 0.6); + background: #444; } +.mfp-figure small { + color: #BDBDBD; + display: block; + font-size: 12px; + line-height: 14px; } +.mfp-figure figure { + margin: 0; } + +.mfp-bottom-bar { + margin-top: -36px; + position: absolute; + top: 100%; + left: 0; + width: 100%; + cursor: auto; } + +.mfp-title { + text-align: left; + line-height: 18px; + color: #F3F3F3; + word-wrap: break-word; + padding-right: 36px; } + +.mfp-image-holder .mfp-content { + max-width: 100%; } + +.mfp-gallery .mfp-image-holder .mfp-figure { + cursor: pointer; } + +@media screen and (max-width: 800px) and (orientation: landscape), screen and (max-height: 300px) { + /** + * Remove all paddings around the image on small screen + */ + .mfp-img-mobile .mfp-image-holder { + padding-left: 0; + padding-right: 0; } + .mfp-img-mobile img.mfp-img { + padding: 0; } + .mfp-img-mobile .mfp-figure:after { + top: 0; + bottom: 0; } + .mfp-img-mobile .mfp-figure small { + display: inline; + margin-left: 5px; } + .mfp-img-mobile .mfp-bottom-bar { + background: rgba(0, 0, 0, 0.6); + bottom: 0; + margin: 0; + top: auto; + padding: 3px 5px; + position: fixed; + box-sizing: border-box; } + .mfp-img-mobile .mfp-bottom-bar:empty { + padding: 0; } + .mfp-img-mobile .mfp-counter { + right: 5px; + top: 3px; } + .mfp-img-mobile .mfp-close { + top: 0; + right: 0; + width: 35px; + height: 35px; + line-height: 35px; + background: rgba(0, 0, 0, 0.6); + position: fixed; + text-align: center; + padding: 0; } } + +@media all and (max-width: 900px) { + .mfp-arrow { + -webkit-transform: scale(0.75); + transform: scale(0.75); } + .mfp-arrow-left { + -webkit-transform-origin: 0; + transform-origin: 0; } + .mfp-arrow-right { + -webkit-transform-origin: 100%; + transform-origin: 100%; } + .mfp-container { + padding-left: 6px; + padding-right: 6px; } } \ No newline at end of file diff --git a/templates/{THEME}/ajax/magnificpopup.js b/templates/{THEME}/ajax/magnificpopup.js new file mode 100644 index 0000000..048f24a --- /dev/null +++ b/templates/{THEME}/ajax/magnificpopup.js @@ -0,0 +1,3 @@ +// Magnific Popup v1.1.0 by Dmitry Semenov +// http://bit.ly/magnific-popup#build=ajax +(function(a){typeof define=="function"&&define.amd?define(["jquery"],a):typeof exports=="object"?a(require("jquery")):a(window.jQuery||window.Zepto)})(function(a){var b="Close",c="BeforeClose",d="AfterClose",e="BeforeAppend",f="MarkupParse",g="Open",h="Change",i="mfp",j="."+i,k="mfp-ready",l="mfp-removing",m="mfp-prevent-close",n,o=function(){},p=!!window.jQuery,q,r=a(window),s,t,u,v,w=function(a,b){n.ev.on(i+a+j,b)},x=function(b,c,d,e){var f=document.createElement("div");return f.className="mfp-"+b,d&&(f.innerHTML=d),e?c&&c.appendChild(f):(f=a(f),c&&f.appendTo(c)),f},y=function(b,c){n.ev.triggerHandler(i+b,c),n.st.callbacks&&(b=b.charAt(0).toLowerCase()+b.slice(1),n.st.callbacks[b]&&n.st.callbacks[b].apply(n,a.isArray(c)?c:[c]))},z=function(b){if(b!==v||!n.currTemplate.closeBtn)n.currTemplate.closeBtn=a(n.st.closeMarkup.replace("%title%",n.st.tClose)),v=b;return n.currTemplate.closeBtn},A=function(){a.magnificPopup.instance||(n=new o,n.init(),a.magnificPopup.instance=n)},B=function(){var a=document.createElement("p").style,b=["ms","O","Moz","Webkit"];if(a.transition!==undefined)return!0;while(b.length)if(b.pop()+"Transition"in a)return!0;return!1};o.prototype={constructor:o,init:function(){var b=navigator.appVersion;n.isLowIE=n.isIE8=document.all&&!document.addEventListener,n.isAndroid=/android/gi.test(b),n.isIOS=/iphone|ipad|ipod/gi.test(b),n.supportsTransition=B(),n.probablyMobile=n.isAndroid||n.isIOS||/(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent),s=a(document),n.popupsCache={}},open:function(b){var c;if(b.isObj===!1){n.items=b.items.toArray(),n.index=0;var d=b.items,e;for(c=0;c(a||r.height())},_setFocus:function(){(n.st.focus?n.content.find(n.st.focus).eq(0):n.wrap).focus()},_onFocusIn:function(b){if(b.target!==n.wrap[0]&&!a.contains(n.wrap[0],b.target))return n._setFocus(),!1},_parseMarkup:function(b,c,d){var e;d.data&&(c=a.extend(d.data,c)),y(f,[b,c,d]),a.each(c,function(c,d){if(d===undefined||d===!1)return!0;e=c.split("_");if(e.length>1){var f=b.find(j+"-"+e[0]);if(f.length>0){var g=e[1];g==="replaceWith"?f[0]!==d[0]&&f.replaceWith(d):g==="img"?f.is("img")?f.attr("src",d):f.replaceWith(a("").attr("src",d).attr("class",f.attr("class"))):f.attr(e[1],d)}}else b.find(j+"-"+c).html(d)})},_getScrollbarSize:function(){if(n.scrollbarSize===undefined){var a=document.createElement("div");a.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(a),n.scrollbarSize=a.offsetWidth-a.clientWidth,document.body.removeChild(a)}return n.scrollbarSize}},a.magnificPopup={instance:null,proto:o.prototype,modules:[],open:function(b,c){return A(),b?b=a.extend(!0,{},b):b={},b.isObj=!0,b.index=c||0,this.instance.open(b)},close:function(){return a.magnificPopup.instance&&a.magnificPopup.instance.close()},registerModule:function(b,c){c.options&&(a.magnificPopup.defaults[b]=c.options),a.extend(this.proto,c.proto),this.modules.push(b)},defaults:{disableOn:0,key:null,midClick:!1,mainClass:"",preloader:!0,focus:"",closeOnContentClick:!1,closeOnBgClick:!0,closeBtnInside:!0,showCloseBtn:!0,enableEscapeKey:!0,modal:!1,alignTop:!1,removalDelay:0,prependTo:null,fixedContentPos:"auto",fixedBgPos:"auto",overflowY:"auto",closeMarkup:'',tClose:"Close (Esc)",tLoading:"Loading...",autoFocusLast:!0}},a.fn.magnificPopup=function(b){A();var c=a(this);if(typeof b=="string")if(b==="open"){var d,e=p?c.data("magnificPopup"):c[0].magnificPopup,f=parseInt(arguments[1],10)||0;e.items?d=e.items[f]:(d=c,e.delegate&&(d=d.find(e.delegate)),d=d.eq(f)),n._openClick({mfpEl:d},c,e)}else n.isOpen&&n[b].apply(n,Array.prototype.slice.call(arguments,1));else b=a.extend(!0,{},b),p?c.data("magnificPopup",b):c[0].magnificPopup=b,n.addGroup(c,b);return c};var C="ajax",D,E=function(){D&&a(document.body).removeClass(D)},F=function(){E(),n.req&&n.req.abort()};a.magnificPopup.registerModule(C,{options:{settings:null,cursor:"mfp-ajax-cur",tError:'The content could not be loaded.'},proto:{initAjax:function(){n.types.push(C),D=n.st.ajax.cursor,w(b+"."+C,F),w("BeforeChange."+C,F)},getAjax:function(b){D&&a(document.body).addClass(D),n.updateStatus("loading");var c=a.extend({url:b.src,success:function(c,d,e){var f={data:c,xhr:e};y("ParseAjax",f),n.appendContent(a(f.data),C),b.finished=!0,E(),n._setFocus(),setTimeout(function(){n.wrap.addClass(k)},16),n.updateStatus("ready"),y("AjaxContentAdded")},error:function(){E(),b.finished=b.loadError=!0,n.updateStatus("error",n.st.ajax.tError.replace("%url%",b.src))}},n.st.ajax.settings);return n.req=a.ajax(c),""}}});var G,H=function(){return G===undefined&&(G=document.createElement("p").style.MozTransform!==undefined),G};a.magnificPopup.registerModule("zoom",{options:{enabled:!1,easing:"ease-in-out",duration:300,opener:function(a){return a.is("img")?a:a.find("img")}},proto:{initZoom:function(){var a=n.st.zoom,d=".zoom",e;if(!a.enabled||!n.supportsTransition)return;var f=a.duration,g=function(b){var c=b.clone().removeAttr("style").removeAttr("class").addClass("mfp-animated-image"),d="all "+a.duration/1e3+"s "+a.easing,e={position:"fixed",zIndex:9999,left:0,top:0,"-webkit-backface-visibility":"hidden"},f="transition";return e["-webkit-"+f]=e["-moz-"+f]=e["-o-"+f]=e[f]=d,c.css(e),c},h=function(){n.content.css("visibility","visible")},i,j;w("BuildControls"+d,function(){if(n._allowZoom()){clearTimeout(i),n.content.css("visibility","hidden"),e=n._getItemToZoom();if(!e){h();return}j=g(e),j.css(n._getOffset()),n.wrap.append(j),i=setTimeout(function(){j.css(n._getOffset(!0)),i=setTimeout(function(){h(),setTimeout(function(){j.remove(),e=j=null,y("ZoomAnimationEnded")},16)},f)},16)}}),w(c+d,function(){if(n._allowZoom()){clearTimeout(i),n.st.removalDelay=f;if(!e){e=n._getItemToZoom();if(!e)return;j=g(e)}j.css(n._getOffset(!0)),n.wrap.append(j),n.content.css("visibility","hidden"),setTimeout(function(){j.css(n._getOffset())},16)}}),w(b+d,function(){n._allowZoom()&&(h(),j&&j.remove(),e=null)})},_allowZoom:function(){return n.currItem.type==="image"},_getItemToZoom:function(){return n.currItem.hasSize?n.currItem.img:!1},_getOffset:function(b){var c;b?c=n.currItem.img:c=n.st.zoom.opener(n.currItem.el||n.currItem);var d=c.offset(),e=parseInt(c.css("padding-top"),10),f=parseInt(c.css("padding-bottom"),10);d.top-=a(window).scrollTop()-e;var g={width:c.width(),height:(p?c.innerHeight():c[0].offsetHeight)-f-e};return H()?g["-moz-transform"]=g.transform="translate("+d.left+"px,"+d.top+"px)":(g.left=d.left,g.top=d.top),g}}}),A()}) \ No newline at end of file diff --git a/upload/templates/Default/ajax/preset-default.tpl b/templates/{THEME}/ajax/preset-default.tpl similarity index 100% rename from upload/templates/Default/ajax/preset-default.tpl rename to templates/{THEME}/ajax/preset-default.tpl diff --git a/upload/engine/ajax/full-story.php b/upload/engine/ajax/full-story.php deleted file mode 100644 index 7c3736a..0000000 --- a/upload/engine/ajax/full-story.php +++ /dev/null @@ -1,908 +0,0 @@ - 10.2) { - date_default_timezone_set($config['date_adjust']); - $_TIME = time(); -} else { - $_TIME = time() + ($config['date_adjust'] * 60); -} - -$_COOKIE['dle_skin'] = trim(totranslit($_COOKIE['dle_skin'], false, false)); - -if ($_COOKIE['dle_skin']) { - if (@is_dir(ROOT_DIR . '/templates/' . $_COOKIE['dle_skin'])) { - $config['skin'] = $_COOKIE['dle_skin']; - } -} - -if ($config["lang_" . $config['skin']]) { - - if (file_exists(ROOT_DIR . '/language/' . $config["lang_" . $config['skin']] . '/website.lng')) { - @include_once ROOT_DIR . '/language/' . $config["lang_" . $config['skin']] . '/website.lng'; - } else { - die("Language file not found"); - - } -} else { - - include_once ROOT_DIR . '/language/' . $config['langs'] . '/website.lng'; - -} - -$config['charset'] = ($lang['charset'] != '') ? $lang['charset'] : $config['charset']; - -require_once ENGINE_DIR . '/classes/templates.class.php'; - -if ($config['version_id'] > 9.6) { - dle_session(); -} else { - @session_start(); -} - -$member_id = array(); - -require_once ENGINE_DIR . '/modules/sitelogin.php'; - -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(); -} - -$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(); -} -$template_dir = ROOT_DIR . '/templates/' . $config['skin']; - -// Пытаемся получить даные из шаблона с настройками -$presetFile = (!empty($_GET['preset'])) ? $_GET['preset'] : false; -if ($presetFile) { - // Если название шаблона передано, то получаем из него конфиг - if (file_exists($template_dir . '/' . $presetFile . '.tpl')) { - // Если файл существует - берём из него контент с настройками - $preset = file_get_contents($template_dir . '/' . $presetFile . '.tpl'); - $arConf = array(); - } else { - die('error'); - } - - // Разбиваем полученные из файла настройки по строкам - $preset = explode("\n", $preset); - - // Пробегаем по массиву и формируем список настроек - foreach ($preset as $v) { - $_v = explode('=', $v); - if (isset($_v[1])) { - $arConf[trim($_v[0])] = trim($_v[1]); - } - } - - // Список разрешенных полей, отбираемых из БД. - $existFields = array( - 'short_story', - 'full_story', - 'xfields', - 'comm_num', - 'fixed', - 'tags', - ); - - // Поля, которые отбираются из БД в любом случаи - $_queryFields = array( - 'id', - 'title', - 'date', - 'category', - 'alt_name', - 'approve', - 'autor', - ); - - // Убираем пробелы, на всякий случай - $arConf['fields'] = str_replace(' ', '', $arConf['fields']); -} else { - // Если ничего не передано - заберём все поля - $arConf['fields'] = 'all'; -} - -if ($arConf['fields'] == 'all') { - // Если передано all - значит мы хотим получить все поля из таблицы - $queryFields = '*'; -} else { - // Разбиваем поля на массив - $_fields = explode(',', $arConf['fields']); - - // Сравниваем со списком разрешенных полей - foreach ($_fields as $key => $field) { - if (!in_array($field, $existFields)) { - // Удаляем лишние поля из массива - unset($_fields[$key]); - } - } - - // Объединяем массивы - $arQueryFields = array_merge($_queryFields, $_fields); - - // И опять разбиваем, для вставки в запрос. - $queryFields = implode(', ', $arQueryFields); -} - -// Конфиг модуля -$afsCfg = array( - 'template' => !empty($_GET['template']) ? $_GET['template'] : 'ajax/fullstory', - 'cachePrefix' => !empty($arConf['cachePrefix']) ? $arConf['cachePrefix'] . '_' . (int) $_GET['newsId'] : 'full_' . (int) $_GET['newsId'], - 'newsId' => ((int) $_GET['newsId'] > 0) ? (int) $_GET['newsId'] : '0', - 'fields' => $queryFields, -); - -if ($afsCfg['newsId'] < 1) { - die('error'); -} - -// Формируем имя кеша -$cacheName = md5(implode('_', $afsCfg)) . $config['skin']; -$afs = false; -// Пытаемся получить даные из кеша -$afs = dle_cache($afsCfg['cachePrefix'], $cacheName, true); -if (!$afs) { - // Если ничего нет - работаем - if (file_exists($template_dir . '/' . $afsCfg['template'] . '.tpl')) { - // Если файл шаблона есть - работаем - - // По умолчанию доступ к новости разрешен - $perm = 1; - - // Определяем доступные категории - $allow_list = explode(',', $user_group[$member_id['user_group']]['allow_cats']); - - // Получаем новость - $query = "SELECT " . $afsCfg['fields'] . " FROM " . PREFIX . "_post LEFT JOIN " . PREFIX . "_post_extras ON (" . PREFIX . "_post.id=" . PREFIX . "_post_extras.news_id) WHERE id = " . $afsCfg['newsId']; - - $row = $db->super_query($query); - - // Опеределяем возможность доступа к новости (взято непосредственно из движка) - $options = news_permission($row['access']); - if ($options[$member_id['user_group']] AND $options[$member_id['user_group']] != 3) { - $perm = 1; - } - - if ($options[$member_id['user_group']] == 3) { - $perm = 0; - } - - if ($options[$member_id['user_group']] == 1) { - $user_group[$member_id['user_group']]['allow_addc'] = 0; - } - - if ($options[$member_id['user_group']] == 2) { - $user_group[$member_id['user_group']]['allow_addc'] = 1; - } - - if ($row['id'] AND !$row['approve'] AND $member_id['name'] != $row['autor'] AND !$user_group[$member_id['user_group']]['allow_all_edit']) { - $perm = 0; - } - - if ($row['id'] AND $config['no_date'] AND !$config['news_future'] AND !$user_group[$member_id['user_group']]['allow_all_edit']) { - - if (strtotime($row['date']) > $_TIME) { - $perm = 0; - } - - } - - // Разбираемся со ссылками на категорию - if ($config['category_separator'] != ',') { - $config['category_separator'] = ' ' . $config['category_separator']; - } - if ($config['version_id'] > 10.1) { - $config['category_separator'] = ','; - } - - 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 = ($config['version_id'] > 10.1) ? get_categories($cat_list[0], $config['category_separator']) : 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'] AND $config['allow_alt_url'] != 'no') { - $my_cat_link[] = "{$cat_info[$element]['name']}"; - } else { - $my_cat_link[] = "{$cat_info[$element]['name']}"; - } - } - } - - $my_cat_link = implode("{$config['category_separator']} ", $my_cat_link); - } - - $my_cat = implode("{$config['category_separator']} ", $my_cat); - } - // Если доступ к новости разрешен и новость есть - работаем - if ($row['id'] AND $perm) { - - // Подцепляем шаблонизатор - $tpl = new dle_template(); - $tpl->dir = $template_dir; - define('TEMPLATE_DIR', $tpl->dir); - - // Подгружаем шаблон - $tpl->load_template($afsCfg['template'] . '.tpl'); - - // Определяем IP - $_IP = get_ip(); - // Определяем категорию - $category_id = intval($row['category']); - // Работам с датой новости - $row['date'] = strtotime($row['date']); - // Если текста мало - if ((strlen($row['full_story']) < 13) and (strpos($tpl->copy_template, "{short-story}") === false)) { - $row['full_story'] = $row['short_story']; - } - - // Если разрешен счётчик просмотров - if ($config['allow_read_count'] AND $config['allow_read_count'] != 'no') { - if ($config['allow_read_count'] == 2) { - - $readcount = $db->super_query("SELECT count(*) as count FROM " . PREFIX . "_read_log WHERE news_id='{$row['id']}' AND ip='{$_IP}'"); - - if (!$readcount['count']) { - - if ($config['cache_count']) { - $db->query("INSERT INTO " . PREFIX . "_views (news_id) VALUES ('{$row['id']}')"); - } else { - $db->query("UPDATE " . PREFIX . "_post_extras SET news_read=news_read+1 WHERE news_id='{$row['id']}'"); - } - - $db->query("INSERT INTO " . PREFIX . "_read_log (news_id, ip) VALUES ('{$row['id']}', '{$_IP}')"); - } - - } else { - - if ($config['cache_count']) { - $db->query("INSERT INTO " . PREFIX . "_views (news_id) VALUES ('{$row['id']}')"); - } else { - $db->query("UPDATE " . PREFIX . "_post_extras SET news_read=news_read+1 WHERE news_id='{$row['id']}'"); - } - } - $db->free(); - - } - - // Получаем ссылку на новость - if ($config['allow_alt_url'] AND $config['allow_alt_url'] != 'no') { - if ( - ($config['version_id'] < 9.6 AND $config['seo_type']) - || - ($config['version_id'] >= 9.6 AND ($config['seo_type'] == 1 || $config['seo_type'] == 2)) - ) { - if (intval($row['category']) AND $config['seo_type'] == 2) { - $full_link = $config['http_home_url'] . get_url(intval($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']; - } - - $row['title'] = stripslashes($row['title']); - $comments_num = $row['comm_num']; - - // Разбираемся с тегами шаблона - - $arTags = array( - '{comments-num}' => $comments_num, - '{views}' => $row['news_read'], - '{category}' => $my_cat, - '{link-category}' => $my_cat_link, - '{news-id}' => $row['id'], - '{full-link}' => $full_link, - ); - - $tpl->set('', $arTags); - - $tpl->set('[full-link]', ""); - $tpl->set('[/full-link]', ""); - - 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_callback("#\{date=(.+?)\}#i", "formdate", $tpl->copy_template); - - 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", ""); - } - - if ($comments_num) { - - $tpl->set('[comments]', ""); - $tpl->set('[/comments]', ""); - $tpl->set_block("'\\[not-comments\\](.*?)\\[/not-comments\\]'si", ""); - - } else { - - $tpl->set('[not-comments]', ""); - $tpl->set('[/not-comments]', ""); - $tpl->set_block("'\\[comments\\](.*?)\\[/comments\\]'si", ""); - } - - if ($row['votes']) { - - $tpl->set('[poll]', ""); - $tpl->set('[/poll]', ""); - $tpl->set_block("'\\[not-poll\\](.*?)\\[/not-poll\\]'si", ""); - - } else { - - $tpl->set('[not-poll]', ""); - $tpl->set('[/not-poll]', ""); - $tpl->set_block("'\\[poll\\](.*?)\\[/poll\\]'si", ""); - } - - 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 ($config['allow_tags'] and $row['tags']) { - - $tpl->set('[tags]', ""); - $tpl->set('[/tags]', ""); - - $tags = array(); - - $row['tags'] = explode(",", $row['tags']); - - foreach ($row['tags'] as $value) { - - $value = trim($value); - - if ($config['allow_alt_url'] AND $config['allow_alt_url'] != 'no') { - $tags[] = "" . $value . ""; - } else { - $tags[] = "" . $value . ""; - - } - } - - $tpl->set('{tags}', implode(", ", $tags)); - - } else { - - $tpl->set_block("'\\[tags\\](.*?)\\[/tags\\]'si", ""); - $tpl->set('{tags}', ""); - - } - - $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 ($category_id AND $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}', "" . $row['vote_num'] . ""); - $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'] AND $config['allow_alt_url'] != 'no') { - - $go_page = $config['http_home_url'] . "user/" . urlencode($row['autor']) . "/"; - $tpl->set('[day-news]', ""); - - } else { - - $go_page = "$PHP_SELF?subaction=userinfo&user=" . urlencode($row['autor']); - $tpl->set('[day-news]', ""); - - } - - $tpl->set('[/day-news]', ""); - $tpl->set('[profile]', ""); - $tpl->set('[/profile]', ""); - - $tpl->set('{login}', $row['autor']); - - $tpl->set('{author}', "" . $row['autor'] . ""); - - if ($row['allow_comm']) { - - $tpl->set('[com-link]', ""); - $tpl->set('[/com-link]', ""); - - } 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]', ""); - $tpl->set('[/edit]', ""); - 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]', ""); - $tpl->set('[/edit]', ""); - if ($config['allow_quick_wysiwyg']) { - $allow_comments_ajax = true; - } - } else { - $tpl->set_block("'\\[edit\\](.*?)\\[/edit\\]'si", ""); - } - - $tpl->set('{favorites}', ""); - $tpl->set_block("'\\[complaint\\](.*?)\\[/complaint\\]'si", ""); - $tpl->set_block("'\\[add-favorites\\](.*?)\\[/add-favorites\\]'si", ""); - $tpl->set_block("'\\[del-favorites\\](.*?)\\[/del-favorites\\]'si", ""); - $tpl->set('{poll}', ''); - $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']); - $row['full_story'] = stripslashes($row['full_story']); - - if ($config['allow_links'] AND function_exists('replace_links') AND isset($replace_links['news'])) { - $row['short_story'] = replace_links($row['short_story'], $replace_links['news']); - $row['full_story'] = replace_links($row['full_story'], $replace_links['news']); - } - - 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); - - } - - if (stripos($tpl->copy_template, "{fullimage-") !== false) { - - $images = array(); - preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $row['full_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('{fullimage-' . $i . '}', $url, $tpl->copy_template); - $tpl->copy_template = str_replace('[fullimage-' . $i . ']', "", $tpl->copy_template); - $tpl->copy_template = str_replace('[/fullimage-' . $i . ']', "", $tpl->copy_template); - } - - } - - $tpl->copy_template = preg_replace("#\[fullimage-(.+?)\](.+?)\[/fullimage-(.+?)\]#is", "", $tpl->copy_template); - $tpl->copy_template = preg_replace("#\\{fullimage-(.+?)\\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template); - - } - - $tpl->set('{comments}', ''); - $tpl->set('{addcomments}', ''); - $tpl->set('{navigation}', ''); - $tpl->set('{related-news}', ''); - $tpl->set_block("'\\[related-news\\](.*?)\\[/related-news\\]'si", ""); - $tpl->set('{pages}', ''); - $row['full_story'] = preg_replace("'\[page=(.*?)\](.*?)\[/page\]'si", "", $row['full_story']); - $tpl->set_block("'\\[pages\\](.*?)\\[/pages\\]'si", ""); - - $tpl->set('{short-story}', $row['short_story']); - - $tpl->set('{full-story}', $row['full_story']); - - if (preg_match("#\\{full-story limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches)) { - $count = intval($matches[1]); - - $row['full_story'] = str_replace("

    ", " ", $row['full_story']); - $row['full_story'] = strip_tags($row['full_story'], "
    "); - $row['full_story'] = trim(str_replace("
    ", " ", str_replace("
    ", " ", str_replace("\n", " ", str_replace("\r", "", $row['full_story']))))); - - if ($count AND dle_strlen($row['full_story'], $config['charset']) > $count) { - - $row['full_story'] = dle_substr($row['full_story'], 0, $count, $config['charset']); - - if (($temp_dmax = dle_strrpos($row['full_story'], ' ', $config['charset']))) { - $row['full_story'] = dle_substr($row['full_story'], 0, $temp_dmax, $config['charset']); - - } - } - - $tpl->set($matches[0], $row['full_story']); - - } - $xfields = xfieldsload(); - if (strpos($tpl->copy_template, "[xfvalue_") !== false OR strpos($tpl->copy_template, "[xfgiven_") !== false) { - - $xfieldsdata = xfieldsdataload($row['xfields']); - - foreach ($xfields as $value) { - $preg_safe_name = preg_quote($value[0], "'"); - - 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'] AND $config['allow_alt_url'] != 'no') { - $value3[] = "" . $value2 . ""; - } else { - $value3[] = "" . $value2 . ""; - } - } - - $xfieldsdata[$value[0]] = implode(", ", $value3); - - unset($temp_array); - unset($value2); - unset($value3); - - } - - if (empty($xfieldsdata[$value[0]])) { - $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); - } - - $xfieldsdata[$value[0]] = stripslashes($xfieldsdata[$value[0]]); - - if ($config['allow_links'] AND $value[3] == "textarea" AND function_exists('replace_links')) { - $xfieldsdata[$value[0]] = replace_links($xfieldsdata[$value[0]], $replace_links['news']); - } - - $tpl->copy_template = str_replace("[xfvalue_{$value[0]}]", $xfieldsdata[$value[0]], $tpl->copy_template); - - if (preg_match("#\\[xfvalue_{$preg_safe_name} limit=['\"](.+?)['\"]\\]#i", $tpl->copy_template, $matches)) { - $count = intval($matches[1]); - - $xfieldsdata[$value[0]] = str_replace("

    ", " ", $xfieldsdata[$value[0]]); - $xfieldsdata[$value[0]] = strip_tags($xfieldsdata[$value[0]], "
    "); - $xfieldsdata[$value[0]] = trim(str_replace("
    ", " ", str_replace("
    ", " ", 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]]); - - } - } - } - - $category_id = $row['category']; - - $category_id = $row['category']; - - $tpl->compile('afs'); - - $tpl->result['afs'] = preg_replace_callback("#\\[declination=(\d+)\\](.+?)\\[/declination\\]#is", "declination", $tpl->result['afs']); - - if ($user_group[$member_id['user_group']]['allow_hide']) { - $tpl->result['afs'] = str_ireplace("[hide]", "", str_ireplace("[/hide]", "", $tpl->result['afs'])); - } else { - $tpl->result['afs'] = preg_replace("#\[hide\](.+?)\[/hide\]#ims", "

    " . $lang['news_regus'] . "
    ", $tpl->result['afs']); - } - - $tpl->result['afs'] = preg_replace("'\\[banner_(.*?)\\](.*?)\\[/banner_(.*?)\\]'si", '', $tpl->result['afs']); - - $tpl->result['afs'] = str_ireplace('{THEME}', $config['http_home_url'] . 'templates/' . $config['skin'], $tpl->result['afs']); - - $news_id = $row['id']; - - $tpl->clear(); - - if ($config['files_allow'] AND $config['files_allow'] != 'no') { - if (strpos($tpl->result['afs'], "[attachment=") !== false) { - $tpl->result['afs'] = show_attach($tpl->result['afs'], $news_id); - } - } - - $afs = $tpl->result['afs']; - - create_cache($afsCfg['cachePrefix'], $afs, $cacheName, true); - }// $row['id'] AND $perm - - // Если доступ есть, но id новости не существует - скажем об этом. - if (!$row['id'] AND $perm) { - $afs = '
    Ошибка. Статья не существует или удалена.
    '; - } - - unset($row); - - if (!$perm) { - $afs = '
    ' . $user_group[$member_id['user_group']]['group_name'] . ' не имеют доступа для просмотра статей из данного раздела.
    '; - } - - } else { - // Если файла шаблона нет - скажем об этом на понятном языке. - $afs = '
    - Ошибка. Отсутствует файл шаблона: /templates/' . $config['skin'] . '/' . $afsCfg['template'] . '.tpl -
    '; - } -} -// Устанавливаем правильные заголовки -$seconds = 86400; // 1 день для кеша в браузере - -// Определяем дату создания кеша, при использовании файлового кеша -// @TODO: наладить Expires при работе с мемкешем. -$_end_file = ($is_logged) ? '_' . $member_id['user_group'] : '_0'; -$filedate = ENGINE_DIR . '/cache/' . $afsCfg['cachePrefix'] . '_' . md5($cacheName) . $_end_file . '.tmp'; - -header('Content-Type: text/html; charset=' . $config['charset']); -header('Cache-Control: public, max-age=' . $seconds); - -if (!file_exists($filedate)) { - $lastModified = $_TIME; -} else { - $etag = md5_file($filedate); - $lastModified = filemtime($filedate); - - header("Expires: " . gmdate("D, d M Y H:i:s", $lastModified + $seconds) . " GMT"); - header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastModified) . " GMT"); - - header("Etag: $etag"); - if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified || - @trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) { - header("HTTP/1.1 304 Not Modified"); - exit; - } -} - -// Выводим результат -echo $afs; \ No newline at end of file diff --git a/upload/templates/Default/ajax/.htaccess b/upload/templates/Default/ajax/.htaccess deleted file mode 100644 index d1163bf..0000000 --- a/upload/templates/Default/ajax/.htaccess +++ /dev/null @@ -1,2 +0,0 @@ -Order Deny,Allow -Allow from all diff --git a/upload/templates/Default/ajax/fullstory.tpl b/upload/templates/Default/ajax/fullstory.tpl deleted file mode 100644 index 725112c..0000000 --- a/upload/templates/Default/ajax/fullstory.tpl +++ /dev/null @@ -1,48 +0,0 @@ -
    -
    -

    {title}

    -
    - [not-group=5] -
      -
    • [edit]Редактировать[/edit]
    • -
    • {favorites}
    • -
    • [complaint]Сообщить об ошибке[/complaint]
    • -
    - [/not-group] - - Автор: {author} от [day-news]{date}[/day-news] - - [rating]
    {rating}
    [/rating] -
    -
    - {full-story} -
    - - [edit-date]


    Новость отредактировал: {editor} - {edit-date} -
    [edit-reason]Причина: {edit-reason}[/edit-reason]

    [/edit-date] - [tags]

    Теги: {tags}

    [/tags] -
    - [pages]
    {pages}
    [/pages] -
    - [related-news][/related-news] - - [group=5] -
    - Уважаемый посетитель, Вы зашли на сайт как незарегистрированный пользователь.
    - Мы рекомендуем Вам зарегистрироваться либо войти на сайт под своим именем. -
    - [/group] -
    - diff --git a/upload/templates/Default/ajax/index.htm b/upload/templates/Default/ajax/index.htm deleted file mode 100644 index 7d13843..0000000 --- a/upload/templates/Default/ajax/index.htm +++ /dev/null @@ -1,8 +0,0 @@ - - - - -Error!!! - -Error!!! -