summaryrefslogtreecommitdiffstats
path: root/web/html/rss2.php
diff options
context:
space:
mode:
authorelij <elij.mx@gmail.com>2009-09-27 16:43:34 -0700
committerLoui Chang <louipc.ist@gmail.com>2009-09-28 16:08:22 -0400
commita8bf1108b4443009088a4fa29a45b4b2994354a8 (patch)
treed8f8a9df34de02db0efe126b41e2dddd57eeef0f /web/html/rss2.php
parent907f27cb8277bf211dc5abd574ac3adde97f41cb (diff)
downloadaurweb-a8bf1108b4443009088a4fa29a45b4b2994354a8.tar.xz
cleanup rss2.php
- removed excessive string catenation, replaced with variable substitution - consolidated http/https protocol checks - simplified host header parse (centralized) - moved cache file to /tmp, to remove need to custom permission directory in webdir Signed-off-by: Loui Chang <louipc.ist@gmail.com>
Diffstat (limited to 'web/html/rss2.php')
-rw-r--r--web/html/rss2.php31
1 files changed, 12 insertions, 19 deletions
diff --git a/web/html/rss2.php b/web/html/rss2.php
index ef6b2e7..659ee15 100644
--- a/web/html/rss2.php
+++ b/web/html/rss2.php
@@ -1,24 +1,26 @@
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang');
-
include_once("aur.inc");
-
include_once("feedcreator.class.php");
+#detect prefix
+$protocol = $_SERVER["HTTPS"]=='on' ? "https" : "http";
+$host = $_SERVER['HTTP_HOST'];
+
#If there's a cached version <1hr old, won't regenerate now
$rss = new UniversalFeedCreator();
-$rss->useCached("RSS2.0", "xml/newestpkg.xml", 1800);
+$rss->useCached("RSS2.0", "/tmp/aur-newestpkg.xml", 1800);
#All the general RSS setup
$rss->title = "AUR Newest Packages";
$rss->description = "The latest and greatest packages in the AUR";
-$rss->link = "http" . ($_SERVER["HTTPS"]=='on'?"s":"") . "://".$_SERVER['HTTP_HOST'];
-$rss->syndicationURL = "http" . ($_SERVER["HTTPS"]=='on'?"s":"") . "://".$_SERVER['HTTP_HOST']."/rss2.php";
+$rss->link = "${protocol}://{$host}";
+$rss->syndicationURL = "{$protocol}://{$host}/rss2.php";
$image = new FeedImage();
$image->title = "AUR";
-$image->url = "http" . ($_SERVER["HTTPS"]=='on'?"s":"") . "://".$_SERVER['HTTP_HOST']."/images/AUR-logo-80.png";
-$image->link = "http" . ($_SERVER["HTTPS"]=='on'?"s":"") . "://".$_SERVER['HTTP_HOST'];
+$image->url = "{$protocol}://{$host}/images/AUR-logo-80.png";
+$image->link = $rss->link;
$image->description = "AUR Newest Packages Feed";
$rss->image = $image;
@@ -30,26 +32,17 @@ $q.= "ORDER BY SubmittedTS DESC ";
$q.= "LIMIT 0 , 20";
$result = db_query($q, $dbh);
-$protocol = 'http';
-
-if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
- $protocol = 'https';
-
-
while ($row = mysql_fetch_assoc($result)) {
$item = new FeedItem();
$item->title = $row["Name"];
-
- $item->link = $protocol . "://".$_SERVER['HTTP_HOST'] .
- '/packages.php?ID='.$row["ID"];
-
+ $item->link = "{$protocol}://{$host}/packages.php?ID={$row["ID"]}";
$item->description = $row["Description"];
$item->date = intval($row["SubmittedTS"]);
- $item->source = $protocol . "://".$_SERVER['HTTP_HOST'];
+ $item->source = "{$protocol}://{$host}";
$item->author = username_from_id($row["MaintainerUID"]);
$rss->addItem($item);
}
#save it so that useCached() can find it
-$rss->saveFeed("RSS2.0","xml/newestpkg.xml",true);
+$rss->saveFeed("RSS2.0","/tmp/aur-newestpkg.xml",true);