.rss.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. // echo "<pre>cat = $cat, news = " ;
  65. $news = $blog->getLastNews(10,$cat,'post_dt DESC',false,$lang);
  66. // print_r ($news) ; echo "</pre>" ;
  67. $ts = strtotime($blog->getEarlierDate());
  68. $title = dc_blog_name;
  69. $items = $seq = '';
  70. while(!$news->EOF())
  71. {
  72. $items .= $news->getRSSItem(dc_short_feeds);
  73. $seq .= $news->getRSSSeq();
  74. $news->moveNext();
  75. }
  76. }
  77. # Fermeture de connexion
  78. $con->close();
  79. # Cache HTTP
  80. if (dc_http_cache && defined('DC_UPDATE_FILE_W') && DC_UPDATE_FILE_W)
  81. {
  82. $mod_files = get_included_files();
  83. $mod_files[] = DC_UPDATE_FILE;
  84. $mod_files[] = dirname(__FILE__).'/conf/dotclear.ini';
  85. cache::http($mod_files);
  86. }
  87. header('Content-Type: text/xml; charset='.dc_encoding);
  88. echo '<?xml version="1.0" encoding="'.dc_encoding.'" ?>'."\n";
  89. ?>
  90. <rdf:RDF
  91. xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  92. xmlns:dc="http://purl.org/dc/elements/1.1/"
  93. xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
  94. xmlns:admin="http://webns.net/mvcb/"
  95. xmlns:content="http://purl.org/rss/1.0/modules/content/"
  96. xmlns="http://purl.org/rss/1.0/">
  97. <channel rdf:about="<?php echo 'http://'.$_SERVER['HTTP_HOST'].dc_blog_url; ?>">
  98. <title><?php echo $blog->toXML($title); ?></title>
  99. <description><![CDATA[<?php echo dc_blog_desc; ?>]]></description>
  100. <link><?php echo 'http://'.$_SERVER['HTTP_HOST'].dc_blog_url; ?></link>
  101. <dc:language><?php echo DC_LANG; ?></dc:language>
  102. <dc:creator></dc:creator>
  103. <dc:rights></dc:rights>
  104. <dc:date><?php echo dt::iso8601($ts); ?></dc:date>
  105. <admin:generatorAgent rdf:resource="http://www.dotclear.net/" />
  106. <sy:updatePeriod>daily</sy:updatePeriod>
  107. <sy:updateFrequency>1</sy:updateFrequency>
  108. <sy:updateBase><?php echo dt::iso8601($ts); ?></sy:updateBase>
  109. <items>
  110. <rdf:Seq>
  111. <?php echo $seq; ?>
  112. </rdf:Seq>
  113. </items>
  114. </channel>
  115. <?php echo $items; ?>
  116. </rdf:RDF>