public function index(){
$xml = '<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0"
xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/1.2/"
>
<channel>
<title>唯物鹰扬</title>
<link>http://wordpress.xupengfei.net</link>
<description>又一个WordPress站点</description>
<pubDate>Thu, 26 Jul 2018 02:16:53 +0000</pubDate>
<language>zh-CN</language>
<wp:wxr_version>1.2</wp:wxr_version>
<wp:base_site_url>http://wordpress.xupengfei.net</wp:base_site_url>
<wp:base_blog_url>http://wordpress.xupengfei.net</wp:base_blog_url>
<wp:author><wp:author_id>1</wp:author_id><wp:author_login><![CDATA[admin]]></wp:author_login><wp:author_email><![CDATA[1121252990@qq.com]]></wp:author_email><wp:author_display_name><![CDATA[admin]]></wp:author_display_name><wp:author_first_name><![CDATA[]]></wp:author_first_name><wp:author_last_name><![CDATA[]]></wp:author_last_name></wp:author>
<generator>https://wordpress.org/?v=4.9.7</generator>';
$db = Db::instance('blog');
$data = $db->select()->from('blog')->query();
foreach ($data as $k=>$v){
$xml .= '<item>';
$xml .= '<title>'.$v['title'].'</title>';
$xml .= '<link> </link>';
$xml .= '<pubDate></pubDate>';
$xml .= '<dc:creator><![CDATA[admin]]></dc:creator>';
$xml .= '<description></description>';
$xml .= '<content:encoded><![CDATA['.$v['content'].']]></content:encoded>';
$xml .= '<excerpt:encoded><![CDATA[]]></excerpt:encoded>';
$xml .= '<wp:post_id>'.($k+5).'</wp:post_id>';
$xml .= '<wp:post_date><![CDATA['.date('Y-m-d H:i:s',$v['create_time']).']]></wp:post_date>';
$xml .= '<wp:post_date_gmt><![CDATA['.date('Y-m-d H:i:s',$v['create_time']).']]></wp:post_date_gmt>';
$xml .= '<wp:comment_status><![CDATA[open]]></wp:comment_status>';
$xml .= '<wp:ping_status><![CDATA[open]]></wp:ping_status>';
$xml .= '<wp:post_name><![CDATA['.$v['title'].']]></wp:post_name>';
$xml .= '<wp:status><![CDATA[publish]]></wp:status>';
$xml .= '<wp:post_parent>0</wp:post_parent>';
$xml .= '<wp:menu_order>0</wp:menu_order>';
$xml .= '<wp:post_type><![CDATA[post]]></wp:post_type>';
$xml .= '<wp:post_password><![CDATA[]]></wp:post_password>';
$xml .= '<wp:is_sticky>0</wp:is_sticky>';
$xml .= '<category domain="category" nicename="uncategorized"><![CDATA[未分类]]></category>';
$xml .= '<wp:postmeta>';
$xml .= '<wp:meta_key><![CDATA[post_views_count]]></wp:meta_key>';
$xml .= '<wp:meta_value><![CDATA['.$v['onclicks'].']]></wp:meta_value>';
$xml .= '</wp:postmeta>';
$xml .= '</item>';
}
$xml .= '</channel>
</rss>';
Http::header('Content-type: text/xml');
return $this->send($xml);
}