A tumblelog CMS built on AJAX, PHP and MySQL.

rss.php 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?
  2. /* ===========================
  3. gelato CMS development version
  4. http://www.gelatocms.com/
  5. gelato CMS is a free software licensed under GPL (General public license)
  6. =========================== */
  7. ?>
  8. <?
  9. header("Content-type: text/xml; charset=utf-8");
  10. require_once("classes/configuration.class.php");
  11. $conf = new configuration();
  12. echo "<?xml version=\"1.0\""." encoding=\"UTF-8\"?>\n";
  13. include("classes/gelato.class.php");
  14. $tumble = new gelato();
  15. $rs = $tumble->getPosts("20");
  16. if ($tumble->contarRegistros()>0) {
  17. ?>
  18. <rss version="2.0">
  19. <channel>
  20. <title><?=htmlspecialchars(replaceAccents($conf->title));?></title>
  21. <link><?=$conf->urlGelato;?></link>
  22. <description><?=htmlspecialchars(replaceAccents($conf->description));?></description>
  23. <generator>gelato CMS</generator>
  24. <image>
  25. <url><?=$conf->urlGelato;?>/images/information.png</url>
  26. <title><?=htmlspecialchars(replaceAccents($conf->description));?></title>
  27. <link><?=$conf->urlGelato;?></link>
  28. </image>
  29. <?
  30. while($register = mysql_fetch_array($rs)) {
  31. switch ($register["type"]) {
  32. case "1":
  33. $tit = ($register["title"]=="") ? htmlspecialchars(strip_tags($register["description"])) : htmlspecialchars($register["title"]);
  34. $desc = htmlspecialchars($register["description"]);
  35. break;
  36. case "2":
  37. $tit = ($register["description"]=="") ? "Photo" : htmlspecialchars(strip_tags($register["description"]));
  38. $desc = "<img src=\"".$register["url"]."\"/>";
  39. break;
  40. case "3":
  41. $tit = "\"".htmlspecialchars(strip_tags($register["description"]))."\"";
  42. $tmpStr = ($register["title"]!="") ? "<br /><br /> - <em>".htmlspecialchars($register["title"])."</em>" : "";
  43. $desc = "\"".htmlspecialchars($register["description"])."\"".$tmpStr;
  44. break;
  45. case "4":
  46. $tit = ($register["title"]=="") ? htmlspecialchars($register["url"]) : htmlspecialchars($register["title"]);
  47. $tmpStr = ($register["description"]!="") ? "<br /><br /> - <em>".htmlspecialchars($register["description"])."</em>" : "";
  48. $desc = "<a href=\"".htmlspecialchars($register["url"])."\">".$tit."</a>".$tmpStr;
  49. break;
  50. case "5":
  51. $lines = explode("\n", $register["description"]);
  52. $line = htmlspecialchars($lines[0]);
  53. $tit = ($register["title"]=="") ? $line : htmlspecialchars($register["title"]);
  54. $desc = $tumble->formatConversation(htmlspecialchars($register["description"]));
  55. break;
  56. case "6":
  57. $tit = ($register["description"]=="") ? "Video" : htmlspecialchars(strip_tags($register["description"]));
  58. $desc = $tumble->getVideoPlayer(htmlspecialchars($register["url"]));
  59. break;
  60. case "7":
  61. $tit = ($register["description"]=="") ? "MP3" : htmlspecialchars(strip_tags($register["description"]));
  62. $desc = $tumble->getMp3Player(htmlspecialchars($register["url"]));
  63. break;
  64. }
  65. $url = htmlspecialchars($conf->urlGelato."/index.php/post/".$register["id_post"]."/");
  66. $formatedDate = gmdate("D, d M Y H:i:s \G\M\T", strtotime($register["date"]));
  67. ?>
  68. <item>
  69. <title><?=replaceAccentsWithAmp($tit);?></title>
  70. <description><![CDATA[<?=replaceAccentsWithAmp($desc);?>]]></description>
  71. <link><?=$url;?></link>
  72. <guid isPermaLink="true"><?=$conf->urlGelato."/index.php/post/".$register["id_post"]."/";?></guid>
  73. <pubDate><?=$formatedDate;?></pubDate>
  74. </item>
  75. <?
  76. }
  77. }
  78. ?>
  79. </channel>
  80. </rss>
  81. <?
  82. function replaceAccents($texto="") {
  83. $texto = str_replace("&Aacute;","A", $texto);
  84. $texto = str_replace("&Eacute;","E", $texto);
  85. $texto = str_replace("&Iacute;","I", $texto);
  86. $texto = str_replace("&Oacute;","O", $texto);
  87. $texto = str_replace("&Uacute;","U", $texto);
  88. $texto = str_replace("&aacute;","a", $texto);
  89. $texto = str_replace("&eacute;","e", $texto);
  90. $texto = str_replace("&iacute;","i", $texto);
  91. $texto = str_replace("&oacute;","o", $texto);
  92. $texto = str_replace("&uacute;","u", $texto);
  93. return $texto;
  94. }
  95. function replaceAccentsWithAmp($texto="") {
  96. $texto = str_replace("&amp;Aacute;","A", $texto);
  97. $texto = str_replace("&amp;Eacute;","E", $texto);
  98. $texto = str_replace("&amp;Iacute;","I", $texto);
  99. $texto = str_replace("&amp;Oacute;","O", $texto);
  100. $texto = str_replace("&amp;Uacute;","U", $texto);
  101. $texto = str_replace("&amp;aacute;","a", $texto);
  102. $texto = str_replace("&amp;eacute;","e", $texto);
  103. $texto = str_replace("&amp;iacute;","i", $texto);
  104. $texto = str_replace("&amp;oacute;","o", $texto);
  105. $texto = str_replace("&amp;uacute;","u", $texto);
  106. $texto = str_replace("&amp;#39;"," ", $texto);
  107. return $texto;
  108. }
  109. ?>