root/trunk/common/rdf.php

Revision 776, 4.0 KB (checked in by michiel, 9 months ago)

update copyright year.

Closes #180

Line 
1<?php
2/**
3 * MvBlog -- An open source no-nosense blogtool
4 *
5 * Copyright (C) 2005-2008, Michiel van Baak
6 * Michiel van Baak <mvanbaak@users.sourceforge.net>
7 *
8 * See http://www.mvblog.org for more information on MvBlog.
9 * That page also provides Bugtrackers, Filereleases etc.
10 *
11 * This program is free software, distributed under the terms of
12 * the GNU General Public License Version 2. See the LICENSE file
13 * at the top of the source tree.
14 *
15 * @package MvBlog
16 * @author Michiel van Baak
17 * @version %%VERSION%%
18 * @copyright 2005-2008 Michiel van Baak
19 */
20require("mvblog.php");
21$mvblog = new MvBlog();
22
23//generate url to the root of our website
24if (array_key_exists("HTTPS", $_SERVER) && $_SERVER["HTTPS"] == "on") { $proto = "https"; } else { $proto = "http"; }
25$url = $proto."://".$_SERVER["SERVER_NAME"].(substr($_SERVER["REQUEST_URI"], 0, strpos($_SERVER["REQUEST_URI"], "common/")));
26
27$max_time = mktime(0, 0, 0, date("m"), date("d")+1, date("Y"));
28
29$sql = "SELECT * FROM articles WHERE date <= $max_time AND active=1 AND public=1 ORDER BY date DESC";
30$comments = false;
31$mvblog->db->setLimit(20);
32$res =& $mvblog->db->query($sql);
33
34if (PEAR::isError($res)) {
35    die($res->getMessage());
36}
37
38/* fetch all items */
39$i = 0;
40$items = array();
41while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
42    $items[$i]["title"] = htmlspecialchars($row["title"]);
43    if (array_key_exists("aside", $row) && $row["aside"] == 1) {
44        $items[$i]["link"] = $url."index.php?aside=".$row["id"];
45        $items[$i]["category"] = "asides";
46        $items[$i]["comments"] = "0";
47    } else {
48        $items[$i]["link"] = $url."index.php?action=view&amp;id=".$row["id"];
49        $categories = explode(",", $row["categories_ids"]);
50        $category_names = array();
51        foreach ($categories as $v) {
52            if (array_key_exists($v, $mvblog->categories))
53                $category_names[] = $mvblog->categories[$v]["name"];
54        }
55        $items[$i]["category"] = implode(", ", $category_names);
56    }
57    $items[$i]["creator"] = htmlspecialchars($mvblog->authors[$row["authors_id"]]["fullname"]);
58    $items[$i]["description"] = $mvblog->strip_bbcode(strip_tags(str_replace("##BREAKPOINT##", "", stripslashes($row["body"]))));
59    $items[$i]["date"] = date("r", $row["date"]);
60    $i++;
61}
62
63/* start outputting the xml/rdf */
64header("Content-Type: text/xml");
65echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
66echo "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" ";
67echo "xmlns=\"http://purl.org/rss/1.0/\" xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\" ";
68echo "xmlns:taxo=\"http://purl.org/rss/1.0/modules/taxonomy/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" ";
69echo "xmlns:syn=\"http://purl.org/rss/1.0/modules/syndication/\" ";
70echo "xmlns:admin=\"http://webns.net/mvcb/\" xmlns:feedburner=\"http://rssnamespace.org/feedburner/ext/1.0\">\n\n";
71echo "\t<channel rdf:about=\"".$url."\">\n";
72echo "\t\t<title>".$mvblog->settings["blogtitle"]."</title>\n";
73echo "\t\t<description>".$mvblog->settings["blogdescription"]."</description>\n";
74echo "\t\t<link>".$url."</link>\n";
75echo "\t\t<dc:date>".date("c")."</dc:date>\n";
76echo "\t\t<dc:subject>Blog</dc:subject>\n";
77echo "\t\t<syn:updatePeriod>daily</syn:updatePeriod>\n";
78echo "\t\t<syn:updateFrequency>1</syn:updateFrequency>\n";
79echo "\t\t<syn:updateBase>1970-01-01T00:00+00:00</syn:updateBase>\n";
80echo "\t\t<items>\n";
81echo "\t\t\t<rdf:Seq>\n";
82foreach ($items as $item) {
83    echo "\t\t\t\t<rdf:li rdf:resource=\"".$item["link"]."\" />\n";
84}
85echo "\t\t\t</rdf:Seq>\n";
86echo "\t\t</items>\n";
87echo "\t</channel>\n";
88
89foreach ($items as $item) {
90    echo "\t<item rdf:about=\"".$item["link"]."\">\n";
91    echo "\t\t<title>".$item["title"]."</title>\n";
92    echo "\t\t<link>".$item["link"]."</link>\n";
93    echo "\t\t<description>".htmlspecialchars($item["description"])."</description>\n";
94    echo "\t\t<dc:creator>".$item["creator"]."</dc:creator>\n";
95    echo "\t\t<dc:date>".$item["date"]."</dc:date>\n";
96    echo "\t\t<dc:subject>".$item["category"]."</dc:subject>\n";
97    echo "\t\t<feedburner:origLink>".$item["link"]."</feedburner:origLink>\n";
98    echo "\t</item>\n";
99}
100echo "</rdf:RDF>\n";
101?>
Note: See TracBrowser for help on using the browser.