代码拉取完成,页面将自动刷新
同步操作将从 emlog/emlog 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<?php
/**
* RSS
* @package EMLOG (www.emlog.net)
*/
require_once './init.php';
header('Content-type: application/xml');
$sort = isset($_GET['sort']) ? (int)$_GET['sort'] : '';
$URL = BLOG_URL;
$blog = getArticleList($sort);
echo '<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title><![CDATA[' . Option::get('blogname') . ']]></title>
<description><![CDATA[' . Option::get('bloginfo') . ']]></description>
<link>' . $URL . '</link>
<language>zh-cn</language>
<generator>www.emlog.net</generator>';
if (!empty($blog)) {
$user_cache = $CACHE->readCache('user');
foreach ($blog as $value) {
$link = Url::log($value['id']);
$abstract = str_replace('[break]', '', $value['content']);
$pubdate = date('r', $value['date']);
$author = $user_cache[$value['author']]['name'];
doAction('rss_display');
echo <<< END
<item>
<title>{$value['title']}</title>
<link>$link</link>
<description><![CDATA[{$abstract}]]></description>
<pubDate>$pubdate</pubDate>
<author>$author</author>
<guid>$link</guid>
</item>
END;
}
}
echo <<< END
</channel>
</rss>
END;
function getArticleList($sortid = null) {
$parsedown = new Parsedown();
$parsedown->setBreaksEnabled(true); //automatic line wrapping
$rss_output_num = Option::get('rss_output_num');
if ($rss_output_num <= 0) {
return [];
}
$DB = Database::getInstance();
$sorts = Cache::getInstance()->readCache('sort');
if (isset($sorts[$sortid])) {
$sort = $sorts[$sortid];
if ($sort['pid'] != 0 || empty($sort['children'])) {
$subsql = "and sortid=$sortid";
} else {
$sortids = array_merge(array($sortid), $sort['children']);
$subsql = "and sortid in (" . implode(',', $sortids) . ")";
}
} else {
$subsql = $sortid ? "and sortid=$sortid" : '';
}
$sql = "SELECT * FROM " . DB_PREFIX . "blog WHERE hide='n' and type='blog' $subsql ORDER BY date DESC limit 0," . $rss_output_num;
$result = $DB->query($sql);
$d = [];
while ($re = $DB->fetch_array($result)) {
$re['id'] = $re['gid'];
$re['title'] = htmlspecialchars($re['title']);
$re['content'] = $parsedown->text($re['content']);
if (!empty($re['password'])) {
$re['content'] = '<p>[该文章已设置加密]</p>';
} elseif (Option::get('rss_output_fulltext') == 'n') {
if (!empty($re['excerpt'])) {
$re['content'] = $re['excerpt'];
} else {
$re['content'] = extractHtmlData($re['content'], 330);
}
$re['content'] .= ' <a href="' . Url::log($re['id']) . '">阅读全文>></a>';
}
$d[] = $re;
}
return $d;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。