[ Index ]
 

Code source de Dotclear 1.2.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/ -> atom.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  else
  82  {
  83      # Dernières nouvelles
  84      $news = $blog->getLastNews(10,$cat,'post_dt DESC',false,$lang);
  85      
  86      $ts = strtotime($blog->getEarlierDate());
  87      $title = dc_blog_name;
  88  }
  89  
  90  header('Content-Type: application/atom+xml; charset='.dc_encoding);
  91  echo '<?xml version="1.0" encoding="'.dc_encoding.'" ?>'."\n";
  92  /*
  93  echo '<?xml-stylesheet href="'.$rss_css.'" type="text/css"?>'."\n";
  94  //*/
  95  ?>
  96  <feed xmlns="http://www.w3.org/2005/Atom"
  97        xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
  98        xml:lang="<?php echo DC_LANG; ?>">
  99    <title><?php echo $blog->toXML($title); ?></title>
 100    <link rel="alternate" type="text/html" href="<?php echo util::getHost().dc_blog_url; ?>"/>
 101    <link rel="self" href="<?php echo util::getPageURL(); ?>"/>
 102  <?php if (dc_blog_desc != '') : ?>
 103    <subtitle type="text"><?php echo htmlspecialchars(dc_blog_desc); ?></subtitle>
 104  <?php endif; ?>
 105    <id><?php echo $blog->getAtomID(dc_blog_url); ?></id>
 106  
 107    <updated><?php echo dt::iso8601($ts); ?></updated>
 108    <generator version="<?php echo DC_VERSION; ?>" uri="http://www.dotclear.net/">DotClear</generator>
 109  
 110    <sy:updatePeriod>daily</sy:updatePeriod>
 111    <sy:updateFrequency>1</sy:updateFrequency>
 112    <sy:updateBase><?php echo dt::iso8601($ts); ?></sy:updateBase>
 113  
 114  <?php
 115  if ($type == 'co')
 116  {
 117      while(!$comments->EOF()) {
 118          echo $comments->getAtomEntry(dc_short_feeds);
 119          $comments->moveNext();
 120      }
 121  }
 122  else
 123  {
 124      while(!$news->EOF()) {
 125          echo $news->getAtomEntry(dc_short_feeds);
 126          $news->moveNext();
 127      }
 128  }
 129  
 130  $con->close();
 131  ?>
 132  </feed>


Généré le : Fri Feb 23 21:40:15 2007 par Balluche grâce à PHPXref 0.7