====== Punbb new RSS script ====== ===== Idea ===== The goal of this rewrite was to get a RSS fedd with the 15 last posts, with the content of the message, to allow user to read the entire forum from a RSS Reader. This script use the image from the [[icones|icons hack]]. ===== License ===== According to the license of punbb the following idea and code are subject to the GPL. ===== See the result in live ===== http://forum.swisslinux.org/extern.php?action=new&type=rss ===== How to use this script ===== Edit extern.php, and write put between : // Should we output this as RSS? ... and // Output regular HTML those lines : // ***** BEGIN rewritten by fbianco for Swisslinux.org *****// if (isset($_GET['type']) && strtoupper($_GET['type']) == 'RSS') { $rss_description = ($_GET['action'] == 'active') ? $lang_common['RSS Desc Active'] : $lang_common['RSS Desc New']; $url_action = ($_GET['action'] == 'active') ? '&action=new' : ''; // Send header rss+xml, encoding and no cache header('Content-Type: application/rss+xml; charset=UTF-8'); header('Expires: '.gmdate('D, d M Y H:i:s').' GMT'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); // It's time for some syndication! rss 2.0 valid output ! echo ''."\r\n"; echo ''."\r\n"; echo ''."\r\n"; echo "\t".''.pun_htmlspecialchars($pun_config['o_board_title']).''."\r\n"; echo "\t".''.$pun_config['o_base_url'].'/'."\r\n"; echo "\t".''.pun_htmlspecialchars($rss_description.' '.$pun_config['o_board_title']).''."\r\n"; echo "\t".'en-us'."\r\n"; // *** Added for Swisslinux.org ***** // echo "\t".''."\r\n"; echo "\t\t".'http://static.swisslinux.org/images/logo.png'."\r\n"; echo "\t\t".'Swisslinux.org\'s Logo'."\r\n"; echo "\t\t".''.$pun_config['o_base_url'].'/'."\r\n"; echo "\t".''."\r\n"; // get the 15 newest post, and other usefull stuff $result = $db->query(' SELECT t.id, p.poster, t.subject, t.posted, t.last_post, f.id AS fid, f.forum_name, p.id AS pid, p.message, fi.icon FROM '.$db->prefix.'posts AS p LEFT JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id 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.'forum_icon AS fi ON fi.forum_id=f.id WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL'.$forum_sql.' ORDER BY p.posted DESC LIMIT 15 ') or error('Unable to fetch post list', __FILE__, __LINE__, $db->error()); // we want to be able to parse the message include('include/parser.php'); // let's write the items while ($cur_topic = $db->fetch_assoc($result)) { if ($pun_config['o_censoring'] == '1') { $cur_topic['subject'] = censor_words($cur_topic['subject']); $cur_topic['message'] = censor_words($cur_topic['message']); } echo "\t".''."\r\n"; echo "\t\t".''.pun_htmlspecialchars($cur_topic['subject']).''."\r\n"; echo "\t\t".''.$pun_config['o_base_url'].'/viewtopic.php?pid='.$cur_topic['pid'].'#p'.$cur_topic['pid'].''."\r\n"; echo "\t\t".''."\r\n"); echo "\t\t\t".escape_cdata(''.$cur_topic['forum_name'].'
'."\r\n".$lang_common['Author'].': '.$cur_topic['poster'].'
'."\r\n".$lang_common['Posted'].': '.date('r', $cur_topic['last_post'])."\r\n"); echo "\t\t\t".'
'."\r\n"; echo escape_cdata(parse_message($cur_topic['message'],FALSE)); echo ']]>'."\r\n"."\t\t".'
'."\r\n"; echo "\t\t".escape_cdata(''.$pun_config['o_base_url'].'/viewtopic.php?pid='.$cur_topic['pid'].'#p'.$cur_topic['pid'].''."\r\n"); echo "\t".'
'."\r\n"; } echo '
'."\r\n"; echo '
'; } // ***** END rewritten by fbianco for Swisslinux.org *****//
Do not forget to edit the part of the script after : // *** Added for Swisslinux.org ***** // else you will get the Swisslinux.org's logo on your rss feed.