My favorites | Sign in
Logo
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
/**
* RSS输出主程序
* @copyright (c) Emlog All Rights Reserved
* @version emlog-3.2.1
* $Id$
*/

require_once('common.php');

header('Content-type: application/xml');

$sort = isset($_GET['sort']) ? intval($_GET['sort']) : '';

$URL = GetURL();
$site = $options_cache;
$blog = GetBlog($sort);
$blognum = GetBlogNum();

echo <<< END
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title><![CDATA[{$site['blogname']}]]></title>
<description><![CDATA[{$site['bloginfo']}]]></description>
<link>http://$URL</link>
<language>zh-cn</language>
<generator>www.emlog.net</generator>

END;
foreach($blog as $value)
{
$link = "http://".$URL."/?post=".$value['id'];
$abstract = str_replace('[break]','',$value['content']);
$pubdate = date('r',$value['date']);
$author = $user_cache[$value['author']]['name'];
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;

/**
* 获取url地址
*
* @return unknown
*/
function GetURL()
{
$path = $_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
$path = str_replace("/rss.php","",$path);
Return $path;
}

/**
* 获取日志信息
*
* @return array
*/
function GetBlog($sort = null)
{
global $DB,$URL;
$subsql = $sort ? "and sortid=$sort" : '';
$sql = "SELECT * FROM ".DB_PREFIX."blog WHERE hide='n' and type='blog' $subsql ORDER BY gid DESC limit 0,10";
$result = $DB->query($sql);
$blog = array();
while ($re = $DB->fetch_array($result))
{
$re['id'] = $re['gid'];
$re['title'] = htmlspecialchars($re['title']);
$re['date'] = $re['date'];
$re['content'] = $re['content'];
if(!empty($re['password']))
{
$re['excerpt'] = '<p>[该日志已设置加密]</p>';
}else{
if(!empty($re['excerpt']))
{
$re['excerpt'] .= '<p><a href="http://'.$URL.'/?post='.$re['id'].'">阅读全文&gt;&gt;</a></p>';
}
}
$re['content'] = empty($re['excerpt']) ? $re['content'] : $re['excerpt'];

$blog[] = $re;
}
return $blog;
}

/**
* 获取日志数目
*
* @return unknown
*/
function GetBlogNum()
{
$blog_t = GetBlog();
return count($blog_t);
}

?>
Show details Hide details

Change log

r1338 by emloog on Jun 10, 2009   Diff
修改文件头注释版本号到3.2.1
Go to: 

Older revisions

r1326 by qiyuuu on Jun 06, 2009   Diff
修复RSS中博文地址错误
r1161 by emloog on May 10, 2009   Diff
[No log message]
r1153 by emloog on May 09, 2009   Diff
版本号升级为 3.2.0
All revisions of this file

File info

Size: 2266 bytes, 112 lines

File properties

svn:keywords
Id
Hosted by Google Code