A tumblelog CMS built on AJAX, PHP and MySQL.

rss.php 4.6KB

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