ajout de la fonctionnalite #1951953
This commit is contained in:
parent
e2d7b9f9bd
commit
5b07fb8d21
3 changed files with 95 additions and 6 deletions
|
|
@ -234,6 +234,36 @@ if ($_GET['action'] == 'active' || $_GET['action'] == 'new')
|
||||||
echo '</channel>'."\r\n";
|
echo '</channel>'."\r\n";
|
||||||
echo '</rss>';
|
echo '</rss>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Patch RSS for Strip-It
|
||||||
|
elseif (isset($_GET['type']) && strtoupper($_GET['type']) == 'LAST_RSS') {
|
||||||
|
$show = isset($_GET['show']) ? intval($_GET['show']) : 15;
|
||||||
|
if ($show < 1 || $show > 50)
|
||||||
|
$show = 15;
|
||||||
|
|
||||||
|
// Fetch $show topics
|
||||||
|
$result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post, f.id AS fid, f.forum_name, p.message FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) LEFT JOIN '.$db->prefix.'posts AS p ON (p.topic_id = t.id) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL'.$forum_sql.' ORDER BY '.$order_by.' DESC LIMIT '.$show) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
|
||||||
|
|
||||||
|
|
||||||
|
while ($cur_topic = $db->fetch_assoc($result))
|
||||||
|
{
|
||||||
|
if ($pun_config['o_censoring'] == '1')
|
||||||
|
$cur_topic['subject'] = censor_words($cur_topic['subject']);
|
||||||
|
|
||||||
|
if (pun_strlen($cur_topic['subject']) > $max_subject_length)
|
||||||
|
$subject_truncated = pun_htmlspecialchars(trim(substr($cur_topic['subject'], 0, ($max_subject_length-5)))).' …';
|
||||||
|
else
|
||||||
|
$subject_truncated = pun_htmlspecialchars($cur_topic['subject']);
|
||||||
|
|
||||||
|
|
||||||
|
echo "\t".'<item>'."\r\n";
|
||||||
|
echo "\t\t".'<title>'.pun_htmlspecialchars($cur_topic['subject']).'</title>'."\r\n";
|
||||||
|
echo "\t\t".'<link>'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].$url_action.'</link>'."\r\n";
|
||||||
|
echo "\t\t".'<description><![CDATA['.escape_cdata($cur_topic['message']).']]></description>'."\r\n";
|
||||||
|
echo "\t".'</item>'."\r\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Output regular HTML
|
// Output regular HTML
|
||||||
|
|
|
||||||
69
rss.php
69
rss.php
|
|
@ -94,10 +94,7 @@ class rss_manager
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function generate() {
|
function generate() {
|
||||||
header('Content-Type: application/rss+xml');
|
|
||||||
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
|
|
||||||
|
|
||||||
if ($this->general->use_cache) {
|
if ($this->general->use_cache) {
|
||||||
// use the cache system
|
// use the cache system
|
||||||
include_once 'cache.class.php';
|
include_once 'cache.class.php';
|
||||||
|
|
@ -114,6 +111,7 @@ class rss_manager
|
||||||
if ($cache->init($limit, $template_folder, $this->general->template_rss, $strip_folder, $cache_folder, '', true)) {
|
if ($cache->init($limit, $template_folder, $this->general->template_rss, $strip_folder, $cache_folder, '', true)) {
|
||||||
if ($cache->isInCache()) {
|
if ($cache->isInCache()) {
|
||||||
// the page is in cache, show cache
|
// the page is in cache, show cache
|
||||||
|
$this->_sendHeader();
|
||||||
$cache->getCache();
|
$cache->getCache();
|
||||||
} else {
|
} else {
|
||||||
// the cache must be re-generate
|
// the cache must be re-generate
|
||||||
|
|
@ -124,14 +122,25 @@ class rss_manager
|
||||||
$cache_data = ob_get_contents();
|
$cache_data = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
$cache->putInCache($cache_data);
|
$cache->putInCache($cache_data);
|
||||||
$cache->getCache();
|
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 {
|
} else {
|
||||||
// error in the configuration cache, don't use the cache system
|
// error in the configuration cache, don't use the cache system
|
||||||
|
$this->_sendHeader();
|
||||||
$this->_genRss();
|
$this->_genRss();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// don't use the cache system
|
// don't use the cache system
|
||||||
|
$this->_sendHeader();
|
||||||
$this->_genRss();
|
$this->_genRss();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -146,10 +155,60 @@ class rss_manager
|
||||||
{
|
{
|
||||||
$this->_init();
|
$this->_init();
|
||||||
|
|
||||||
|
$this->_genAnnonce();
|
||||||
|
|
||||||
$output = new HTML_Template_Flexy($this->strip_manager->options);
|
$output = new HTML_Template_Flexy($this->strip_manager->options);
|
||||||
$output->compile($this->general->template_folder.'/'.$this->general->template_rss.'/template.rss');
|
$output->compile($this->general->template_folder.'/'.$this->general->template_rss.'/template.rss');
|
||||||
$output->outputObject($this,$this->items_list);
|
$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\"?>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
<webMaster>{general.email} ({general.webmaster})</webMaster>
|
<webMaster>{general.email} ({general.webmaster})</webMaster>
|
||||||
<copyright>Copyright {general.webmaster}</copyright>
|
<copyright>Copyright {general.webmaster}</copyright>
|
||||||
<docs>http://cyber.law.harvard.edu/rss/</docs>
|
<docs>http://cyber.law.harvard.edu/rss/</docs>
|
||||||
|
{general.wotd:h}
|
||||||
{foreach:items_list,id,strip}
|
{foreach:items_list,id,strip}
|
||||||
<item>
|
<item>
|
||||||
<title>{strip.title}</title>
|
<title>{strip.title}</title>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue