Tiny bug: the default name of the textarea is hardcoded, so the script doesn't work anymore when you change the textarea name.

Patch:

-    msgfield = (document.all) ? document.all.req_message : document.forms['<?php echo $bbcode_form ?>']['<?php echo $bbcode_field ?>'];
+    msgfield = (document.all) ? document.all.<?php echo $bbcode_field ?> : document.forms['<?php echo $bbcode_form ?>']['<?php echo $bbcode_field ?>'];

There are already several mods that do this, but none of them could entirely satisfy me, so I made this one.

I post it here, in case it could be useful to someone else...

based on http://punbb.org/forums/viewtopic.php?id=5100 and PunBB extern.php

<?php
/**
  * BLOG:CMS: PHP/MySQL Personal Content Management System 
  * http://blogcms.com/
  * http://forum.blogcms.com/
  *
  * 2003-2004, (c) Radek HULAN 
  * http://hulan.cz/
  *
  * Mod by Bert Garcia for PunBB 1.2.1
  * http://nupusi.com
  *
  * Modified by Thomas Guebels
  * http://exolandia.be
  * +minor changes for PunBB 1.2.10
  * +output an rss 0.91 feed
  * +put forum name and topic name in subject
  * +use standard PunBB functions when possible (date_format, escape_cdata ...)
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
**/

define('PUN_ROOT', './');
@include PUN_ROOT.'config.php';

// If PUN isn't defined, config.php is missing or corrupt
if (!defined('PUN'))
    exit('The file \'config.php\' doesn\'t exist or is corrupt. Please run install.php to install PunBB first.');

// Disable error reporting for uninitialized variables
error_reporting(E_ERROR | E_WARNING | E_PARSE);

// Turn off magic_quotes_runtime
set_magic_quotes_runtime(0);

// Load the functions script
require PUN_ROOT.'include/functions.php';
require PUN_ROOT.'include/parser.php';

// Load DB abstraction layer and try to connect
require PUN_ROOT.'include/dblayer/common_db.php';

// Get the forum config
$result = $db->query('SELECT * FROM '.$db->prefix.'config') 
    or error('Unable to fetch forum config', __FILE__, __LINE__, $db->error());
while ($cur_config_item = $db->fetch_row($result))
    $pun_config[$cur_config_item[0]] = $cur_config_item[1];

// Make sure we (guests) have permission to read the forums
$result = $db->query('SELECT g_read_board FROM '.$db->prefix.'groups WHERE g_id=3') or error('Unable to fetch group info', __FILE__, __LINE__, $db->error());
if ($db->result($result) == '0')
    exit('No permission');

// Attempt to load the common language file
@include PUN_ROOT.'lang/'.$pun_config['o_default_lang'].'/common.php';
if (!isset($lang_common)) exit('There is no valid language pack \''.$pun_config['o_default_lang'].'\' installed. Please reinstall a language of that name.');

ob_start();

// Make feed
putHeader();
$result = $db->query(
    "select p.id as id, p.poster as poster, p.message as message, p.posted as postposted, t.subject as subject, f.forum_name as forum_name ".
    "from ".$db->prefix."posts as p, ".$db->prefix."topics as t, ".$db->prefix."forums as f ".
    "where p.topic_id=t.id and t.forum_id=f.id ".
    "order by postposted desc ".
    "limit 0,20")
    or error('Unable to fetch forum posts', __FILE__, __LINE__, $db->error());;
while ($cur = $db->fetch_assoc($result)) putPost($cur);
putEnd();

// get feed into $feed
$feed = ob_get_contents();
ob_end_clean();

// create ETAG (hash of feed)
$eTag = '"'.md5($feed).'"';
header('Etag: '.$eTag);

// compare Etag to what we got
if ($eTag == $_SERVER['HTTP_IF_NONE_MATCH']) {    
    header("HTTP/1.0 304 Not Modified");
    header('Content-Length: 0');
} else {
    // dump feed
    header ("Content-type: text/xml");
    echo $feed;
}

// Converts the CDATA end sequence ]]> into ]]>
function escape_cdata($str)
{
    return str_replace(']]>', ']]>', $str);
}

function putHeader() {   
    global $lang_common,$pun_config;
    echo '<?xml version="1.0" encoding="'.$lang_common['lang_encoding'].'"?>'."\r\n";
    echo '<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd">'."\r\n";
    echo '<rss version="0.91">'."\r\n";
    echo '<channel>'."\r\n";
    echo "\t".'<title>'.pun_htmlspecialchars($pun_config['o_board_title']).' - Derniers posts</title>'."\r\n";
    echo "\t".'<link>'.$pun_config['o_base_url'].'/</link>'."\r\n";
    echo "\t".'<description>'.pun_htmlspecialchars($rss_description.' '.$pun_config['o_board_title']).'</description>'."\r\n";
    echo "\t".'<language>fr-be</language>'."\r\n";
} 

function putPost($cur) {
    global $lang_common,$pun_config;
    if ($pun_config['o_censoring'] == '1')
    $cur_topic['subject'] = censor_words($cur_topic['subject']);

    echo "\t".'<item>'."\r\n";
    echo "\t\t".'<title>'.pun_htmlspecialchars($cur['forum_name']." -  ".$cur['subject']).'</title>'."\r\n";
    echo "\t\t".'<link>'.$pun_config['o_base_url'].'/viewtopic.php?pid='.strval($cur['id']).'#p'.strval($cur['id']).'</link>'."\r\n";
    echo "\t\t".'<description><![CDATA['.escape_cdata($lang_common['Posted'].': '.format_time($cur['postposted']).$lang_common['Author'].': <strong>'.$cur['poster'].'</strong>'.parse_message($cur['message'],0)).']]></description>'."\r\n\t".'</item>'."\r\n";
}

function putEnd() {
    echo "</channel>\n";
    echo "</rss>\n";
} 

?>

or
http://forum.exolandia.com/share/rssposts.phps

example:
http://forum.exolandia.com/rssposts.php

3

(1 replies, posted in PunBB 1.2 show off)

Migrated our forums from phpBB. PunBB integrates nicely in our site.

It's a mostly french-speaking forum about an online game.

http://forum.exolandia.com