[ PHPXref.com ] [ Generated: Sun Jul 20 17:19:52 2008 ] [ DotClear 1.2.4 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> rss.php (source)

   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  
  23  # Chemin vers la racine de l'application (si vous changer le fichier de place)
  24  $app_path = '/';
  25  
  26  # Si par exemple vous mettez rss.php à la racine de votre site et que DotClear
  27  # se trouve dans /dotclear vous pouvez décommenter cette ligne :
  28  //$app_path = '/dotclear/';
  29  
  30  # NE RIEN CHANGER APRES CETTE LIGNE
  31  
  32  $blog_dc_path = dirname(__FILE__).$app_path;
  33  
  34  require $blog_dc_path.'/inc/prepend.php';
  35  require $blog_dc_path.'/layout/lib.cache.php';
  36  
  37  require $blog_dc_path.'/layout/class.xblog.php';
  38  require $blog_dc_path.'/layout/class.xblogpost.php';
  39  require $blog_dc_path.'/layout/class.xblogcomment.php';
  40  
  41  $type = (!empty($_GET['type']) && $_GET['type'] == 'co') ? 'co' : 'blog';
  42  $cat = (!empty($_GET['cat'])) ? $_GET['cat'] : '';
  43  $lang = (!empty($_GET['lang'])) ? $_GET['lang'] : '';
  44  
  45  # Cache HTTP
  46  if (dc_http_cache && defined('DC_UPDATE_FILE_W') && DC_UPDATE_FILE_W)
  47  {
  48      $mod_files = get_included_files();
  49      $mod_files[] = DC_UPDATE_FILE;
  50      $mod_files[] = $blog_dc_path.'/conf/dotclear.ini';
  51  
  52      cache::http($mod_files);
  53  }
  54  
  55  # Connexion MySQL
  56  $con = new Connection(DB_USER,DB_PASS,DB_HOST,DB_DBASE);
  57  
  58  if ($con->error()) { exit; }
  59  
  60  # Création de l'objet de type weblog avec uniquement les billets
  61  # publiés
  62  $blog = new xblog($con,DB_PREFIX,1,dc_encoding);
  63  $blog->rs_blogpost = 'xblogpost';
  64  $blog->rs_blogcomment = 'xblogcomment';
  65  
  66  $blog->setURL('post',util::getHost().dc_blog_url.dc_format_post_url);
  67  
  68  # Si type = co on fait un fil des commentaires
  69  if ($type == 'co')
  70  {
  71      if (!empty($_GET['post'])) {
  72          $comments = $blog->getComments($_GET['post'],'DESC');
  73      } else {
  74          $comments = $blog->getComments('','DESC',20);
  75      }
  76      
  77      $title = dc_blog_name.' - Commentaires';
  78      $ts = time();
  79      $items = $seq = '';
  80      
  81      if (!$comments->isEmpty())
  82      {
  83          $ts = $comments->getTS();
  84          
  85          while(!$comments->EOF())
  86          {
  87              $seq .= $comments->getRSSSeq();
  88              $items .= $comments->getRSSItem(dc_short_feeds);
  89              
  90              $comments->moveNext();
  91          }
  92      }
  93  }
  94  else
  95  {
  96      # Dernières nouvelles
  97      $news = $blog->getLastNews(10,$cat,'post_dt DESC',false,$lang);
  98      
  99      $ts = strtotime($blog->getEarlierDate());
 100      $title = dc_blog_name;
 101      
 102      $items = $seq = '';
 103      while(!$news->EOF())
 104      {
 105          $items .= $news->getRSSItem(dc_short_feeds);
 106          $seq .= $news->getRSSSeq();
 107          
 108          $news->moveNext();
 109      }
 110  }
 111  
 112  # Fermeture de connexion
 113  $con->close();
 114  
 115  header('Content-Type: application/rss+xml; charset='.dc_encoding);
 116  echo '<?xml version="1.0" encoding="'.dc_encoding.'" ?>'."\n";
 117  ?>
 118  <rdf:RDF
 119    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 120    xmlns:dc="http://purl.org/dc/elements/1.1/"
 121    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
 122    xmlns:admin="http://webns.net/mvcb/"
 123    xmlns:content="http://purl.org/rss/1.0/modules/content/"
 124    xmlns="http://purl.org/rss/1.0/">
 125  
 126  <channel rdf:about="<?php echo util::getHost().dc_blog_url; ?>">
 127    <title><?php echo $blog->toXML($title); ?></title>
 128    <description><![CDATA[<?php echo dc_blog_desc; ?>]]></description>
 129    <link><?php echo util::getHost().dc_blog_url; ?></link>
 130    <dc:language><?php echo DC_LANG; ?></dc:language>
 131    <dc:creator></dc:creator>
 132    <dc:rights></dc:rights>
 133    <dc:date><?php echo dt::iso8601($ts); ?></dc:date>
 134    <admin:generatorAgent rdf:resource="http://www.dotclear.net/" />
 135    
 136    <sy:updatePeriod>daily</sy:updatePeriod>
 137    <sy:updateFrequency>1</sy:updateFrequency>
 138    <sy:updateBase><?php echo dt::iso8601($ts); ?></sy:updateBase>
 139    
 140    <items>
 141    <rdf:Seq>
 142    <?php echo $seq; ?>
 143    </rdf:Seq>
 144    </items>
 145  </channel>
 146  
 147  <?php echo $items; ?>
 148  
 149  </rdf:RDF>


[ Powered by PHPXref - Served by Debian GNU/Linux ]