-
Notifications
You must be signed in to change notification settings - Fork 0
/
rss2c.php
89 lines (68 loc) · 2.61 KB
/
rss2c.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
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
<?php
header("Content-type: application/rss+xml");
$loguserid = 0;
//Edit the following lines to your preference.
$feedname = "AcmlmBoard XD (Cynthia IRC Style)";
$boardurl = "http://helmet.kafuka.org/nikoboard";
$description = "The latest replies on the board, mIRC style";
//</edit>
$maxPosts = 5;
$postCount = 0;
include("lib/mysql.php");
include("lib/snippets.php");
include("lib/post.php");
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title><?php print $feedname; ?></title>
<link><?php print $boardurl; ?></link>
<description><?php print $description; ?></description>
<atom:link href="<?php print $boardurl; ?>/rss2.php" rel="self" type="application/rss+xml" />
<?php
$qPosts = "select * from posts order by date desc limit 0, ".($maxPosts * 2);
$rPosts = Query($qPosts);
while($post = Fetch($rPosts))
{
$qThread = "select * from threads where id=".$post['thread'];
$rThread = Query($qThread);
$thread = Fetch($rThread);
$qForum = "select * from forums where id=".$thread['forum'];
$rForum = Query($qForum);
$forum = Fetch($rForum);
if($forum['minpower'] > 0)
continue;
$qPoster = "select * from users where id=".$post['user'];
$rPoster = Query($qPoster);
$poster = Fetch($rPoster);
$qText = "select text,revision from posts_text where pid=".$post['id']." order by revision desc limit 1";
$rText = Query($qText);
$text = Fetch($rText);
$post = array_merge($post, $text);
$fname = htmlentities($forum['title']);
$tname = htmlentities($thread['title']);
$uname = htmlentities($poster['name']);
$link = $boardurl."?pid=".$post['id'];
$guid = md5($post['id'].$post['date']);
$tname = str_replace("[", "{[<", $tname);
$tname = str_replace("]", ">]}", $tname);
$tname = str_replace("{[<", "[clr]14", $tname);
$tname = str_replace(">]}", "[clr]11", $tname);
print "\n<item>\n";
print "<title>irrelevant title</title>\n";
print "<link>".$link."</link>\n";
print "<pubDate>".gmdate(DATE_RFC1123, $post['date'])."</pubDate>\n";
$reply = ($post['revision'] > 0) ? "Post edited" : "New reply";
if($thread['replies'] < 1)
print "<description>[clr]12New thread by [clr]11".$uname."[clr]12: \"[clr]11".$tname."[clr]12\" (".$fname.") [clr]14-> ".$link."</description>\n";
else
print "<description>[clr]12".$reply." by [clr]11".$uname." [clr]12in \"[clr]11".$tname."[clr]12\" (".$fname.") [clr]14-> ".$link."</description>\n";
print "<guid isPermaLink=\"false\">".$guid."</guid>\n";
print "</item>\n";
$numPosts++;
//if($numPosts == $maxPosts)
break;
}
?>
</channel>
</rss>