forked from d3m3vilurr/soojung
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rss2.php
58 lines (50 loc) · 1.67 KB
/
rss2.php
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
<?php
include_once("settings.php");
$encoding = strtolower(trim($_GET["encoding"]));
if(!$encoding) $encoding = strtolower(trim($_GET["charset"]));
if($encoding == "cp949" || $encoding == "euc-kr" || $encoding == "euckr") {
$encoding = "euc-kr";
function convenc($str) { return iconv("UTF-8", "CP949", $str); }
} else {
$encoding = "utf-8";
function convenc($str) { return $str; }
}
header("Content-type: text/xml; charset=$encoding");
echo "<?xml version=\"1.0\" encoding=\"$encoding\"?>\n";
?>
<rss version="2.0">
<channel>
<title><?=htmlspecialchars(convenc($blog_name)) ?></title>
<link><?php echo $blog_baseurl ?></link>
<description><?php echo htmlspecialchars(convenc($blog_desc)) ?></description>
<copyright></copyright>
<pubDate><?php echo date('r') ?></pubDate>
<generator>soojung <?php echo $soojung_version ?></generator>
<?php
if (isset($_GET['category'])) {
$category = new Category($_GET['category']);
$entries = $category->getEntries(10, 1);
} else {
$entries = Entry::getEntries(10, 1);
}
foreach ($entries as $e) {
if ($e->isSetOption("NO_RSS") || $e->isSetOption("SECRET")) {
continue;
}
$post_text = $e->getRawBody();
$formatter = Soojung::getFormatter($e->format);
$post_text = $formatter->toRSS($post_text);
echo "<item>\n";
echo "<title>" . htmlspecialchars(convenc($e->title)) . "</title>\n";
echo "<link>" . $e->getHref() . "</link>\n";
echo "<pubDate>" . date('r', $e->date) . "</pubDate>\n";
echo "<category>" . htmlspecialchars(convenc($e->category->name)) . "</category>\n";
echo "<description>" . htmlspecialchars(convenc($post_text)) . "</description>\n";
echo "</item>\n";
}
?>
</channel>
</rss>
<?php
# vim: ts=8 sw=2 sts=2 noet
?>