Source for file rdf.php

Documentation is available at rdf.php

  1. <?php
  2. /**
  3.  * MvBlog -- An open source no-nosense blogtool
  4.  *
  5.  * Copyright (C) 2005-2007, 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-2007 Michiel van Baak
  19.  */
  20. require("mvblog.php");
  21. $mvblog new MvBlog();
  22.  
  23. //generate url to the root of our website
  24. if (array_key_exists("HTTPS"$_SERVER&& $_SERVER["HTTPS"== "on"$proto "https"else $proto "http"}
  25. $url $proto."://".$_SERVER["SERVER_NAME"].(substr($_SERVER["REQUEST_URI"]0strpos($_SERVER["REQUEST_URI"]"common/")));
  26.  
  27. $max_time mktime(000date("m")date("d")+1date("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.  
  34. if (PEAR::isError($res)) {
  35.     die($res->getMessage());
  36. }
  37.  
  38. /* fetch all items */
  39. $i 0;
  40. $items array();
  41. while ($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 */
  64. header("Content-Type: text/xml");
  65. echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
  66. echo "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" ";
  67. echo "xmlns=\"http://purl.org/rss/1.0/\" xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\" ";
  68. echo "xmlns:taxo=\"http://purl.org/rss/1.0/modules/taxonomy/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" ";
  69. echo "xmlns:syn=\"http://purl.org/rss/1.0/modules/syndication/\" ";
  70. echo "xmlns:admin=\"http://webns.net/mvcb/\" xmlns:feedburner=\"http://rssnamespace.org/feedburner/ext/1.0\">\n\n";
  71. echo "\t<channel rdf:about=\"".$url."\">\n";
  72. echo "\t\t<title>".$mvblog->settings["blogtitle"]."</title>\n";
  73. echo "\t\t<description>".$mvblog->settings["blogdescription"]."</description>\n";
  74. echo "\t\t<link>".$url."</link>\n";
  75. echo "\t\t<dc:date>".date("c")."</dc:date>\n";
  76. echo "\t\t<dc:subject>Blog</dc:subject>\n";
  77. echo "\t\t<syn:updatePeriod>daily</syn:updatePeriod>\n";
  78. echo "\t\t<syn:updateFrequency>1</syn:updateFrequency>\n";
  79. echo "\t\t<syn:updateBase>1970-01-01T00:00+00:00</syn:updateBase>\n";
  80. echo "\t\t<items>\n";
  81. echo "\t\t\t<rdf:Seq>\n";
  82. foreach ($items as $item{
  83.     echo "\t\t\t\t<rdf:li rdf:resource=\"".$item["link"]."\" />\n";
  84. }
  85. echo "\t\t\t</rdf:Seq>\n";
  86. echo "\t\t</items>\n";
  87. echo "\t</channel>\n";
  88.  
  89. foreach ($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. }
  100. echo "</rdf:RDF>\n";
  101. ?>

Documentation generated on Fri, 28 Dec 2007 13:17:42 +0100 by phpDocumentor 1.4.1