8 Star 30 Fork 7

emlog/emlog

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
rss.php 1.27 KB
一键复制 编辑 原始数据 按行查看 历史
kohunglee 提交于 2023-04-29 23:30 . fix:Modified some RSS validation errors
<?php
/**
* RSS
* @package EMLOG
* @link https://www.emlog.net
*/
require_once './init.php';
header('Content-type: application/xml');
$Log_Model = new Log_Model();
$articles = $Log_Model->getLogsForRss(Option::get('rss_output_num'));
echo '<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
>
<channel>
<title><![CDATA[' . Option::get('blogname') . ']]></title>
<atom:link href="'.Option::get('blogurl').'rss.php" rel="self" type="application/rss+xml" />
<description><![CDATA[' . Option::get('bloginfo') . ']]></description>
<link>' . BLOG_URL . '</link>
<language>zh-cn</language>
<generator>www.emlog.net</generator>';
if (!empty($articles)) {
foreach ($articles as $value) {
$link = Url::log($value['id']);
$abstract = str_replace('[break]', '', $value['content']);
$pubdate = date('r', $value['date']);
$author = $value['nickname'];
doAction('rss_display');
echo <<< END
<item>
<title>{$value['title']}</title>
<link>$link</link>
<description><![CDATA[{$abstract}]]></description>
<pubDate>$pubdate</pubDate>
<dc:creator>$author</dc:creator>
<guid>$link</guid>
</item>
END;
}
}
echo <<< END
</channel>
</rss>
END;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/snowsun/emlog.git
git@gitee.com:snowsun/emlog.git
snowsun
emlog
emlog
master

搜索帮助