Source of trunk/rdf.php at revision HEAD (02/11/2009 11:02:36, 3659 bytes, 100 lines, language: php) [download]:
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | ** RDF Feed Generator |
| 5 | ** for CodewiseBlog Multi-User |
| 6 | ** |
| 7 | |
| 8 | ** Copyright (c) 2005-2008 Codewise.org |
| 9 | */ |
| 10 | |
| 11 | /* |
| 12 | ** This file is part of CodewiseBlog |
| 13 | ** |
| 14 | ** CodewiseBlog is free software; you can redistribute it and/or modify |
| 15 | ** it under the terms of the GNU General Public License as published by |
| 16 | ** the Free Software Foundation; either version 2 of the License, or |
| 17 | ** (at your option) any later version. |
| 18 | ** |
| 19 | ** CodewiseBlog is distributed in the hope that it will be useful, |
| 20 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | ** GNU General Public License for more details. |
| 23 | ** |
| 24 | ** You should have received a copy of the GNU General Public License |
| 25 | ** along with CodewiseBlog; if not, write to the Free Software |
| 26 | ** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 27 | */ |
| 28 | |
| 29 | header("Content-Type: text/xml"); |
| 30 | |
| 31 | echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; |
| 32 | |
| 33 | define("NO_ACTION", TRUE); |
| 34 | |
| 35 | require("cwbmulti.php"); |
| 36 | |
| 37 | // prevent a SQL error if there are no topics |
| 38 | if($db->num_rows[$db->issue_query("SELECT tid FROM topics WHERE blogid = '".BLOGID."'")] > 0) |
| 39 | { |
| 40 | $first_post = $db->fetch_var($db->issue_query("SELECT timestamp FROM topics WHERE blogid = '".BLOGID."' ORDER by TIMESTAMP ASC LIMIT 1")); |
| 41 | $latest_post = $db->fetch_var($db->issue_query("SELECT timestamp FROM topics WHERE blogid = '".BLOGID."' ORDER by TIMESTAMP DESC LIMIT 1")); |
| 42 | $copyright_years = date("Y", $first_post) . "-" . date("Y", $latest_post); |
| 43 | } else { |
| 44 | $copyright_years = date("Y"); |
| 45 | } |
| 46 | |
| 47 | ?> |
| 48 | |
| 49 | <rdf:RDF |
| 50 | xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
| 51 | xmlns="http://purl.org/rss/1.0/" |
| 52 | xmlns:dc="http://purl.org/dc/elements/1.1/" |
| 53 | xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" |
| 54 | xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" |
| 55 | > |
| 56 | |
| 57 | <channel rdf:about="<?php echo INDEX_URL; ?>"> |
| 58 | <title><?php echo htmlspecialchars($BLOGINFO['title']); ?></title> |
| 59 | <link><?php echo INDEX_URL; ?></link> |
| 60 | <description><?php echo htmlspecialchars($BLOGINFO['title']); ?> :: by <?php echo htmlspecialchars($BLOGINFO['realname'] == NULL ? BLOGNAME : $BLOGINFO['realname']); ?></description> |
| 61 | <dc:rights>Copyright (c) <?php echo $copyright_years; ?> <?php echo htmlspecialchars($BLOGINFO['realname'] == NULL ? BLOGNAME : $BLOGINFO['realname']); ?></dc:rights> |
| 62 | <dc:date><?php echo iso8601_date($latest_post); ?></dc:date> |
| 63 | <dc:creator><?php echo htmlspecialchars($BLOGINFO['realname'] == NULL ? BLOGNAME : $BLOGINFO['realname']); ?></dc:creator> |
| 64 | <items> |
| 65 | <rdf:Seq> |
| 66 | |
| 67 | <?php |
| 68 | |
| 69 | if(isset($_GET['all_one_page'])) |
| 70 | $limit = ""; |
| 71 | else |
| 72 | $limit = "LIMIT 10"; // rdf spec says it must be 10 |
| 73 | |
| 74 | $q = $db->issue_query("SELECT tid,title,text,timestamp FROM topics WHERE blogid = '" . BLOGID . "' ORDER BY timestamp DESC $limit"); |
| 75 | $data = $db->fetch_all($q); |
| 76 | |
| 77 | foreach($data as $row) |
| 78 | { |
| 79 | echo " <rdf:li rdf:resource=\"" . INDEX_URL . "article/" . string_to_url_goodness($row['title']) . "\" />\n"; |
| 80 | } |
| 81 | |
| 82 | ?> |
| 83 | </rdf:Seq> |
| 84 | </items> |
| 85 | </channel> |
| 86 | |
| 87 | <?php foreach($data as $row) |
| 88 | { |
| 89 | echo " <item rdf:about=\"" . INDEX_URL . "article/" . string_to_url_goodness($row['title']) . "\"> |
| 90 | <title>" . $row['title'] . "</title> |
| 91 | <link>" . INDEX_URL . "article/" . string_to_url_goodness($row['title']) . "</link> |
| 92 | <description>" . htmlspecialchars(output_topic_text($row['text'])) . "</description> |
| 93 | <dc:date>" . iso8601_date($row['timestamp']) . "</dc:date> |
| 94 | </item>"; |
| 95 | } |
| 96 | |
| 97 | ?> |
| 98 | |
| 99 | </rdf:RDF> |
| 100 |