rss.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. # ***** BEGIN LICENSE BLOCK *****
  3. # This file is part of DotClear.
  4. # Copyright (c) 2004 Olivier Meunier and contributors. All rights
  5. # reserved.
  6. #
  7. # DotClear is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # DotClear is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with DotClear; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. #
  21. # ***** END LICENSE BLOCK *****
  22. require dirname(__FILE__).'/inc/prepend.php';
  23. require dirname(__FILE__).'/layout/lib.cache.php';
  24. require dirname(__FILE__).'/layout/class.xblog.php';
  25. require dirname(__FILE__).'/layout/class.xblogpost.php';
  26. require dirname(__FILE__).'/layout/class.xblogcomment.php';
  27. $type = (!empty($_GET['type']) && $_GET['type'] == 'co') ? 'co' : 'blog';
  28. $cat = (!empty($_GET['cat'])) ? $_GET['cat'] : '';
  29. $lang = (!empty($_GET['lang'])) ? $_GET['lang'] : '';
  30. # Connexion MySQL
  31. $con = new Connection(DB_USER,DB_PASS,DB_HOST,DB_DBASE);
  32. if ($con->error()) { exit; }
  33. # Création de l'objet de type weblog avec uniquement les billets
  34. # publiés
  35. $blog = new xblog($con,DB_PREFIX,1,dc_encoding);
  36. $blog->rs_blogpost = 'xblogpost';
  37. $blog->rs_blogcomment = 'xblogcomment';
  38. $blog->setURL('post','http://'.$_SERVER['HTTP_HOST'].dc_blog_url.dc_format_post_url);
  39. # Si type = co on fait un fil des commentaires
  40. if ($type == 'co')
  41. {
  42. if (!empty($_GET['post'])) {
  43. $comments = $blog->getComments($_GET['post'],'DESC');
  44. } else {
  45. $comments = $blog->getComments('','DESC',20);
  46. }
  47. $title = dc_blog_name.' - Commentaires';
  48. $ts = time();
  49. $items = $seq = '';
  50. if (!$comments->isEmpty())
  51. {
  52. $ts = $comments->getTS();
  53. while(!$comments->EOF())
  54. {
  55. $seq .= $comments->getRSSSeq();
  56. $items .= $comments->getRSSItem(dc_short_feeds);
  57. $comments->moveNext();
  58. }
  59. }
  60. }
  61. else
  62. {
  63. # Dernières nouvelles
  64. $news = $blog->getLastNews(10,$cat,'post_dt DESC',false,$lang);
  65. $ts = strtotime($blog->getEarlierDate());
  66. $title = dc_blog_name;
  67. $items = $seq = '';
  68. while(!$news->EOF())
  69. {
  70. $items .= $news->getRSSItem(dc_short_feeds);
  71. $seq .= $news->getRSSSeq();
  72. $news->moveNext();
  73. }
  74. }
  75. require_once dirname(__FILE__).'/'.DC_ECRIRE.'/tools/spamplemousse/inc/rss.php';
  76. # Fermeture de connexion
  77. $con->close();
  78. # Cache HTTP
  79. if (dc_http_cache && defined('DC_UPDATE_FILE_W') && DC_UPDATE_FILE_W)
  80. {
  81. $mod_files = get_included_files();
  82. $mod_files[] = DC_UPDATE_FILE;
  83. $mod_files[] = dirname(__FILE__).'/conf/dotclear.ini';
  84. cache::http($mod_files);
  85. }
  86. header('Content-Type: text/xml; charset='.dc_encoding);
  87. echo '<?xml version="1.0" encoding="'.dc_encoding.'" ?>'."\n";
  88. ?>
  89. <rdf:RDF
  90. xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  91. xmlns:dc="http://purl.org/dc/elements/1.1/"
  92. xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
  93. xmlns:admin="http://webns.net/mvcb/"
  94. xmlns:content="http://purl.org/rss/1.0/modules/content/"
  95. xmlns="http://purl.org/rss/1.0/">
  96. <channel rdf:about="<?php echo 'http://'.$_SERVER['HTTP_HOST'].dc_blog_url; ?>">
  97. <title><?php echo $blog->toXML($title); ?></title>
  98. <description><![CDATA[<?php echo dc_blog_desc; ?>]]></description>
  99. <link><?php echo 'http://'.$_SERVER['HTTP_HOST'].dc_blog_url; ?></link>
  100. <dc:language><?php echo DC_LANG; ?></dc:language>
  101. <dc:creator></dc:creator>
  102. <dc:rights></dc:rights>
  103. <dc:date><?php echo dt::iso8601($ts); ?></dc:date>
  104. <admin:generatorAgent rdf:resource="http://www.dotclear.net/" />
  105. <sy:updatePeriod>daily</sy:updatePeriod>
  106. <sy:updateFrequency>1</sy:updateFrequency>
  107. <sy:updateBase><?php echo dt::iso8601($ts); ?></sy:updateBase>
  108. <items>
  109. <rdf:Seq>
  110. <?php echo $seq; ?>
  111. </rdf:Seq>
  112. </items>
  113. </channel>
  114. <?php echo $items; ?>
  115. </rdf:RDF>