45 lines
2.1 KiB
PHP
Executable File
45 lines
2.1 KiB
PHP
Executable File
<?php
|
||
|
||
/* ----------------------------------------------------------------------
|
||
02.01.2023
|
||
Модуль динамической генерации RSS адаптированный для Яндекс-турбо страниц
|
||
Загружаем в лк веб-мастера в формате /rss/info-0-999.xml
|
||
где цифры определяют лимиты загрузки страниц
|
||
info - выбирает из таблицы pages
|
||
blog - из таблицы пользовательских блогов
|
||
---------------------------------------------------------------------- */
|
||
|
||
ini_set('display_errors', 0 );
|
||
header('Content-type: text/xml; charset=utf-8');
|
||
$smarty->caching = true;
|
||
$smarty->cache_lifetime = 172800;//Два дня
|
||
function delxml ($text) { // ФУНКЦИЯ очистки кода
|
||
$old1 = array(".xml", "info-");#Ищем вредное ">",, "<"
|
||
$new1 = array("", "");#Меняем на полезное">", , "<"
|
||
$text = str_replace($old1, $new1, $text);#Собсно сама замена =)
|
||
return $text;
|
||
}
|
||
|
||
function delbugs ($text) { // ФУНКЦИЯ очистки кода
|
||
$old1 = array(" ");#Ищем вредное ">",, "<"
|
||
$new1 = array("");#Меняем на полезное">", , "<"
|
||
$text = str_replace($old1, $new1, $text);#Собсно сама замена =)
|
||
return $text;
|
||
}
|
||
// /rss/info-0-999.xml
|
||
//берем из адресной строки гет с по урезаем xml
|
||
|
||
$description=\core::getSettings('about');
|
||
|
||
$period=delxml($_GET['id']);
|
||
$pieces = explode("-",$period);
|
||
$table=mb_substr($_GET['id'], 0, 5);
|
||
if ($table=='info-') $table='pages';
|
||
$rss=\DB::getAll("SELECT `id`,`title`, `time`, `json`, `txt` FROM `content` WHERE `status`=1 AND `site`=?",$_SERVER['SERVER_NAME']);// array( $_SERVER['SERVER_NAME'], $pieces[0] , $pieces[1] )
|
||
$count=count($rss);
|
||
for ($i=0; $i<$count; $i++){
|
||
$rss[$i]['alias']=\core::j($rss[$i]['json'])['alias'];
|
||
}
|
||
$smarty->assign('rss', @$rss);
|
||
$smarty->assign('description', strip_tags(delbugs(@$description)));
|
||
?>
|