rss.php 1.67 KB
Newer Older
1
<?php
pjmattal's avatar
pjmattal committed
2
3

set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang');
4
include_once("aur.inc.php");
5
include_once("pkgfuncs.inc.php");
Dan McGee's avatar
Dan McGee committed
6
include_once("feedcreator.class.php");
simo's avatar
simo committed
7

elij's avatar
elij committed
8
#detect prefix
9
$protocol = isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"]=='on' ? "https" : "http";
elij's avatar
elij committed
10
11
$host = $_SERVER['HTTP_HOST'];

12
13
$feed_key = 'pkg-feed-' . $protocol;

14
15
header("Content-Type: application/rss+xml");

16
17
18
19
20
21
22
$bool = false;
$ret = get_cache_value($feed_key, $bool);
if ($bool) {
	echo $ret;
	exit();
}

23
$rss = new RSSCreator20();
24
25
$rss->cssStyleSheet = false;
$rss->xslStyleSheet = false;
26
27
28
29

# Use UTF-8 (fixes FS#10706).
$rss->encoding = "UTF-8";

simo's avatar
simo committed
30
31
32
#All the general RSS setup
$rss->title = "AUR Newest Packages";
$rss->description = "The latest and greatest packages in the AUR";
elij's avatar
elij committed
33
$rss->link = "${protocol}://{$host}";
34
$rss->syndicationURL = "{$protocol}://{$host}" . get_uri('/rss/');
simo's avatar
simo committed
35
36
$image = new FeedImage();
$image->title = "AUR";
Lukas Fleischer's avatar
Lukas Fleischer committed
37
$image->url = "{$protocol}://{$host}/css/archnavbar/aurlogo.png";
elij's avatar
elij committed
38
$image->link = $rss->link;
simo's avatar
simo committed
39
40
41
42
$image->description = "AUR Newest Packages Feed";
$rss->image = $image;

#Get the latest packages and add items for them
canyonknight's avatar
canyonknight committed
43
$packages = latest_pkgs(20);
Loui Chang's avatar
Loui Chang committed
44

Lukas Fleischer's avatar
Lukas Fleischer committed
45
foreach ($packages as $indx => $row) {
simo's avatar
simo committed
46
47
	$item = new FeedItem();
	$item->title = $row["Name"];
48
	$item->link = "{$protocol}://{$host}" . get_pkg_uri($row["Name"]);
simo's avatar
simo committed
49
50
	$item->description = $row["Description"];
	$item->date = intval($row["SubmittedTS"]);
elij's avatar
elij committed
51
	$item->source = "{$protocol}://{$host}";
simo's avatar
simo committed
52
53
54
55
56
	$item->author = username_from_id($row["MaintainerUID"]);
	$rss->addItem($item);
}

#save it so that useCached() can find it
57
58
59
60
$feedContent = $rss->createFeed();
set_cache_value($feed_key, $feedContent, 1800);
echo $feedContent;
?>