ajout de la fonctionnalite #1951953
This commit is contained in:
parent
e2d7b9f9bd
commit
5b07fb8d21
3 changed files with 95 additions and 6 deletions
|
|
@ -236,6 +236,36 @@ if ($_GET['action'] == 'active' || $_GET['action'] == 'new')
|
|||
}
|
||||
|
||||
|
||||
// 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
|
||||
else
|
||||
{
|
||||
|
|
|
|||
67
rss.php
67
rss.php
|
|
@ -95,9 +95,6 @@ class rss_manager
|
|||
* @access public
|
||||
*/
|
||||
function generate() {
|
||||
header('Content-Type: application/rss+xml');
|
||||
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
|
||||
|
||||
if ($this->general->use_cache) {
|
||||
// use the cache system
|
||||
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->isInCache()) {
|
||||
// the page is in cache, show cache
|
||||
$this->_sendHeader();
|
||||
$cache->getCache();
|
||||
} else {
|
||||
// the cache must be re-generate
|
||||
|
|
@ -124,14 +122,25 @@ class rss_manager
|
|||
$cache_data = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$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 {
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
|
@ -146,10 +155,60 @@ class rss_manager
|
|||
{
|
||||
$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\"?>";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
<webMaster>{general.email} ({general.webmaster})</webMaster>
|
||||
<copyright>Copyright {general.webmaster}</copyright>
|
||||
<docs>http://cyber.law.harvard.edu/rss/</docs>
|
||||
|
||||
{general.wotd:h}
|
||||
{foreach:items_list,id,strip}
|
||||
<item>
|
||||
<title>{strip.title}</title>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue