aboutsummaryrefslogtreecommitdiff
blob: 94d96dc7dfb139be2f5d1de38f0a621f3ad4f3e3 (plain)
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
<?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,DBNAME);  // open persistent connection to 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>';