-
Notifications
You must be signed in to change notification settings - Fork 1
/
rss.php
executable file
·47 lines (37 loc) · 1.28 KB
/
rss.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
<?php
if(!isset($_GET['debug'])) {
header("Content-Type: application/rss+xml");
error_reporting(!E_ALL);
}
define("BASE_URL", "http://jont.se/~nyson/i/");
require_once("lib/rss/RSSBuilder.php");
require_once("lib/Search.php");
$rss = new RSSBuilder();
$s = new Search();
$maxTime = 0;
$result = $s->search();
while ($row = $result->fetch_object()) {
$link = BASE_URL . "#$row->id";
$item = new RSSBuilderItem();
$item->addTag("title", "Wohoo, someone uploaded $row->name!");
$item->addTag("guid", $link, array("isPermaLink" => "false"));
$item->addTag("link", $link);
$item->addTag('pubDate', RSSBuilder::formatTimestamp($row->time));
if($row->time > $maxTime) $maxTime = $row->time;
$item->addTag("description",
htmlentities("<div>"
. "<h2>$row->name</h2>"
. "<div style='float: left;'><a href='$link' title='$row->name'>"
. "<img src='".BASE_URL."thumbs/$row->file' alt='$row->name' />"
."</a></div>"
."</div>"));
$rss->addItem($item);
}
$rss->setInfo(array("lastBuildDate" => RSSBuilder::formatTimestamp($maxTime)));
if(!isset($_GET['debug']))
echo $rss->build();
else
echo str_replace(
array("\n", "\t"),
array("<br />", " "),htmlentities($rss->build()));
?>