diff --git a/fluxbb-1.2.21_extern.php b/fluxbb-1.2.21_extern.php index 1a76188..f6d5a2c 100644 --- a/fluxbb-1.2.21_extern.php +++ b/fluxbb-1.2.21_extern.php @@ -234,6 +234,36 @@ if ($_GET['action'] == 'active' || $_GET['action'] == 'new') echo ''."\r\n"; echo ''; } + + + // 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".''."\r\n"; + echo "\t\t".''.pun_htmlspecialchars($cur_topic['subject']).''."\r\n"; + echo "\t\t".''.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].$url_action.''."\r\n"; + echo "\t\t".''."\r\n"; + echo "\t".''."\r\n"; + } + } // Output regular HTML diff --git a/rss.php b/rss.php index 864f03e..80a517e 100644 --- a/rss.php +++ b/rss.php @@ -94,10 +94,7 @@ class rss_manager * * @access public */ - function generate() { - header('Content-Type: application/rss+xml'); - echo ""; - + function generate() { 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 = '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 ""; + } } /** diff --git a/template/rss/template.rss b/template/rss/template.rss index dcc94db..41f0f3a 100644 --- a/template/rss/template.rss +++ b/template/rss/template.rss @@ -22,7 +22,7 @@ {general.email} ({general.webmaster}) Copyright {general.webmaster} http://cyber.law.harvard.edu/rss/ - + {general.wotd:h} {foreach:items_list,id,strip} {strip.title}