mise en place de la release 0.7
passage pour le trunk a la version PHP 5 (voir le fichier RELEASE.fr pourplus de renseignement sur la nouvelle version de developpement)
This commit is contained in:
parent
0d66093946
commit
3145e721c3
286 changed files with 1971 additions and 78266 deletions
263
rss.php
263
rss.php
|
|
@ -1,220 +1,65 @@
|
|||
<?php
|
||||
/**
|
||||
* Strip-It RSS manager
|
||||
*
|
||||
* @author Johann "nojhan" Dréo <nojhan@gmail.com>
|
||||
* @license http://www.gnu.org/licenses/gpl.html GPL
|
||||
* @copyright 2007 Johann Dréo
|
||||
*
|
||||
* @package stripit
|
||||
*/
|
||||
* Strip-It Rss
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl.html GPL
|
||||
* @copyright 2009 Johann Dréo, Simon Leblanc
|
||||
* @author Johann "nojhan" Dréo <nojhan@gmail.com>
|
||||
* @author Simon Leblanc <contact@leblanc-simon.eu>
|
||||
* @package stripit
|
||||
*/
|
||||
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . getcwd());
|
||||
|
||||
require_once 'strip_manager.php';
|
||||
require_once 'conf/configuration.php';
|
||||
require_once 'inc/functions.php';
|
||||
|
||||
// hack for passing objects by values instead of reference under PHP5 (but not PHP4)
|
||||
// damn clone keyword !
|
||||
if (version_compare(phpversion(), '5.0') < 0) {
|
||||
eval('function clone($object) {return $object;}');
|
||||
//Launch Cron
|
||||
Cron::exec();
|
||||
|
||||
// Obtain the Config
|
||||
$config = new Config();
|
||||
|
||||
// Obtain the cache
|
||||
$cache = Cache::getCache();
|
||||
|
||||
// Obtain the id asked
|
||||
$last = Cache::getLastId();
|
||||
|
||||
// Obtain the limit
|
||||
if (isset($_GET['limit']) && is_numeric($_GET['limit'])) {
|
||||
$limit = $_GET['limit'];
|
||||
|
||||
if ($limit <= 0 || $limit > $last + 1) {
|
||||
$limit = $last + 1;
|
||||
}
|
||||
} else {
|
||||
$limit = $last + 1;
|
||||
}
|
||||
$end = $last - $limit;
|
||||
|
||||
// Obtain the strips
|
||||
$list = array();
|
||||
for ($i = $last; $i > $end; $i--) {
|
||||
$list[$i] = Cache::getStrip($i);
|
||||
}
|
||||
|
||||
/**
|
||||
* RSS manager
|
||||
*/
|
||||
class rss_manager
|
||||
{
|
||||
/**
|
||||
* Items list
|
||||
* @var array
|
||||
*/
|
||||
var $items_list = array();
|
||||
// Obtain the language
|
||||
if (isset($_GET['lang'])) {
|
||||
$lang = $_GET['lang'];
|
||||
} else {
|
||||
$lang = Config::getLanguage();
|
||||
}
|
||||
$lang = getLang($lang);
|
||||
|
||||
/**
|
||||
* Configuration
|
||||
* @var array
|
||||
*/
|
||||
var $general;
|
||||
|
||||
/**
|
||||
* Strip manager object
|
||||
* @var object
|
||||
*/
|
||||
var $strip_manager;
|
||||
// Navigation
|
||||
$nav_img = Config::getUrl().'/'.Config::getIndex().'?id=';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Use the {@link strip_manager} to do the stuff, and convert date from the iso8601 to RFC822 format.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function rss_manager() {
|
||||
|
||||
$this->strip_manager = new strip_manager();
|
||||
|
||||
$this->general = $this->strip_manager->general;
|
||||
$this->lang = $this->strip_manager->lang;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Init the strip manager
|
||||
*
|
||||
* Use the {@link strip_manager} to do the stuff, and convert date from the iso8601 to RFC822 format.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _init()
|
||||
{
|
||||
$this->strip_manager->strips_list_get();
|
||||
|
||||
// limit the number of strip in RSS
|
||||
$limit = 0;
|
||||
if (isset($_GET['limit']) && is_numeric($_GET['limit'])) {
|
||||
// check for have no infinite for
|
||||
if ($_GET['limit'] > 0 && $_GET['limit'] < $this->strip_manager->strips_count) {
|
||||
$limit = $this->strip_manager->strips_count - $_GET['limit'];
|
||||
}
|
||||
}
|
||||
|
||||
for( $i = $this->strip_manager->strips_count-1; $i >= $limit; $i-- ) { // reverser order
|
||||
$this->strip_manager->strip_info_get( $i );
|
||||
|
||||
// conversion iso8601 -> RFC822
|
||||
$this->strip_manager->date = date('r', strtotime($this->strip_manager->date));
|
||||
|
||||
$this->items_list[] = clone($this->strip_manager); // hack for php4/5 compat
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the RSS output with the template engine.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function generate() {
|
||||
if ($this->general->use_cache) {
|
||||
// use the cache system
|
||||
include_once 'cache.class.php';
|
||||
$cache = new STRIPIT_Cache();
|
||||
|
||||
$limit = 0;
|
||||
if (isset($_GET['limit']) && is_numeric($_GET['limit'])) {
|
||||
$limit = $_GET['limit'];
|
||||
}
|
||||
|
||||
$template_folder = $this->general->template_folder.'/'.$this->general->template_rss;
|
||||
$strip_folder = $this->strip_manager->strips_path;
|
||||
$cache_folder = $this->strip_manager->options['compileDir'];
|
||||
if ($cache->init($limit, $template_folder, $this->general->template_rss, $strip_folder, $cache_folder, '', true)) {
|
||||
if ($cache->isInCache()) {
|
||||
// the page is in cache, show cache
|
||||
$this->_sendHeader();
|
||||
$cache->getCache();
|
||||
} else {
|
||||
// the cache must be re-generate
|
||||
ob_start();
|
||||
|
||||
$this->_genRss();
|
||||
|
||||
$cache_data = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$cache->putInCache($cache_data);
|
||||
if ($this->general->use_punbb) {
|
||||
// if we generate the cache the first time with comments
|
||||
// redirect in the same page for use the cache (because the first
|
||||
// time we see the php code)
|
||||
header('Location: '.$_SERVER['REQUEST_URI']);
|
||||
exit();
|
||||
} else {
|
||||
$this->_sendHeader();
|
||||
$cache->getCache();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// error in the configuration cache, don't use the cache system
|
||||
$this->_sendHeader();
|
||||
$this->_genRss();
|
||||
}
|
||||
} else {
|
||||
// don't use the cache system
|
||||
$this->_sendHeader();
|
||||
$this->_genRss();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate the RSS page
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _genRss()
|
||||
{
|
||||
$this->_init();
|
||||
|
||||
$this->_genAnnonce();
|
||||
|
||||
$output = new HTML_Template_Flexy($this->strip_manager->options);
|
||||
$output->compile($this->general->template_folder.'/'.$this->general->template_rss.'/template.rss');
|
||||
$output->outputObject($this,$this->items_list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate the RSS item for announce of webmaster
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _genAnnonce()
|
||||
{
|
||||
// if one want to use punbb as forum
|
||||
if( $this->general->use_punbb ) {
|
||||
if ($this->general->use_cache) {
|
||||
// get the word of the day
|
||||
$this->general->wotd = '<?php
|
||||
$fh = fopen( \''.$this->general->forum.'/extern.php?action=new&show=1&type=last_rss&fid='.$this->general->punbb_wotd_id.'\', \'r\');
|
||||
|
||||
if (!$fh) {
|
||||
echo \''.str_replace("'", "\'", $this->lang->forum_error).'\';
|
||||
} else {
|
||||
echo utf8_encode(stream_get_contents($fh));
|
||||
fclose($fh);
|
||||
}
|
||||
?>';
|
||||
} else {
|
||||
// get the word of the day
|
||||
$fh = fopen( $this->general->forum.'/extern.php?action=new&show=1&type=last_rss&fid='.$this->general->punbb_wotd_id, 'r');
|
||||
|
||||
if (!$fh) {
|
||||
$this->general->wotd = $this->lang->forum_error;
|
||||
} else {
|
||||
$this->general->wotd = utf8_encode(stream_get_contents($fh));
|
||||
fclose($fh);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send the header XML
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _sendHeader()
|
||||
{
|
||||
header('Content-Type: application/rss+xml');
|
||||
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
|
||||
}
|
||||
// If necessary, obtain the forum data
|
||||
$wotd = '';
|
||||
if (Config::getUseFluxbb() === true) {
|
||||
$wotd = Forum::getWotdRss($lang);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instanciation and output.
|
||||
*/
|
||||
$rssm = new rss_manager();
|
||||
$rssm->generate();
|
||||
|
||||
?>
|
||||
// show the template
|
||||
header('Content-Type: application/rss+xml');
|
||||
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
|
||||
include_once Config::getTemplateFolder().'/'.Config::getTemplateRss().'/template.rss';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue