aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Evans <grknight@gentoo.org>2018-01-29 16:04:13 -0500
committerBrian Evans <grknight@gentoo.org>2018-01-29 16:05:35 -0500
commit3c56284f7fe1926f6bf6ebd97ec72805d94df1e4 (patch)
tree805a3fb4cfb14519c0bebc3f1863f4759e916a82 /php/rss/download-counts.php
downloadbouncer-3c56284f7fe1926f6bf6ebd97ec72805d94df1e4.tar.gz
bouncer-3c56284f7fe1926f6bf6ebd97ec72805d94df1e4.tar.bz2
bouncer-3c56284f7fe1926f6bf6ebd97ec72805d94df1e4.zip
Import existing bouncer.g.o into gitv1.0-20181208-IMPORT
Diffstat (limited to 'php/rss/download-counts.php')
-rw-r--r--php/rss/download-counts.php55
1 files changed, 55 insertions, 0 deletions
diff --git a/php/rss/download-counts.php b/php/rss/download-counts.php
new file mode 100644
index 0000000..4559647
--- /dev/null
+++ b/php/rss/download-counts.php
@@ -0,0 +1,55 @@
+<?php
+/**
+ * RSS 2.0 feed for download counts.
+ * @package mirror
+ * @subpackage rss
+ */
+
+require_once('../cfg/config.php'); // config file
+require_once(LIB.'/db.php'); // core mysql wrappers
+
+db_connect(DBHOST,DBUSER,DBPASS); // open persistent connection to db
+db_select(DBNAME); // select db
+
+// get download counts per product
+$data = db_get("SELECT * FROM mirror_products ORDER BY product_name");
+
+// time to go at the end of each item
+$now = date('G',time());
+
+// content headers, replace Content-type if already set
+header('Content-type: text/xml', true);
+echo '<?xml version="1.0"?>'."\n\n";
+
+// doctype
+echo '<rdf:RDF'."\n";
+echo ' xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"'."\n";
+echo ' xmlns="http://purl.org/rss/1.0/">'."\n\n";
+
+// channel details
+echo '<channel rdf:about="http://bouncer.gentoo.org/rss/download-counts.php">'."\n";
+echo ' <title>Gentoo Download Counts</title>'."\n";
+echo ' <link>http://www.gentoo.org/</link>'."\n";
+echo ' <description>Gentoo product download counts pulled from Bouncer database.</description> '."\n";
+
+// item listing
+echo ' <items>'."\n";
+echo ' <rdf:Seq>'."\n";
+foreach ($data as $product) {
+ echo ' <rdf:li rdf:resource="http://bouncer.gentoo.org/?product='.$product['product_name'].'&amp;lastmod='.$now.'"/>'."\n";
+}
+echo ' </rdf:Seq>'."\n";
+echo ' </items>'."\n";
+echo '</channel>'."\n\n";
+
+// item details
+foreach ($data as $product) {
+ echo '<item rdf:about="http://bouncer.gentoo.org/?product='.$product['product_name'].'&amp;lastmod='.$now.'">'."\n";
+ echo ' <title>'.$product['product_name'].'</title>'."\n";
+ echo ' <description>'.$product['product_count'].'</description>'."\n";
+ echo ' <link>http://bouncer.gentoo.org/?product='.$product['product_name'].'&amp;lastmod='.$now.'</link>'."\n";
+ echo '</item>'."\n";
+}
+
+echo "\n".'</rdf:RDF>';
+?>