Dear Kowalski  Thanks a lot!

That solved the problem.

Slavok wrote:

As I can understand from your explanation, there are two possible reasons why the message could disappear: because of post's date or truncating message. Please, post more information about how your RSS is created.

The code of the file creating the RSS feed is the following:

<?php

define('PUN_ROOT', './');
define('PUN_QUIET_VISIT', 1);
require_once PUN_ROOT.'include/common.php';
require_once PUN_ROOT.'include/parser.php';
require_once PUN_ROOT.'include/user/feed_functions.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/feed.php';

//------------------------------------------------------------//

// Make sure 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');
}

//------------------------------------------------------------//

// Turn off magic_quotes_runtime
set_magic_quotes_runtime(0);

$show = 'topic';
$postslimit = '25';
$maxchars = '250';
$forumuri = $pun_config['o_base_url'].'/';
$modsdir = $pun_config['o_base_url'].'/';
$imagedir = $pun_config['o_base_url'].'/img/icons/';

//------------------------------------------------------------//

if (isset($_GET['cid']) && trim($_GET['cid']) != '')
{
    $feedreq = ' AND c.id='.intval($_GET['cid']);
    $add = '?cid='.intval($_GET['cid']);
}
else if (isset($_GET['fid']) && trim($_GET['fid']) != '')
{
    $feedreq = ' AND f.id='.intval($_GET['fid']);
    $add = '?fid='.intval($_GET['fid']);
}
else if (isset($_GET['pfid']) && trim($_GET['pfid']) != '')
{
    $feedreq = ' AND f.parent_forum_id='.intval($_GET['pfid']);
    $add = '?pfid='.intval($_GET['pfid']);
}
else if (isset($_GET['tid']) && trim($_GET['tid']) != '')
{
    $feedreq = ' AND t.id='.intval($_GET['tid']);
    $add = '?tid='.intval($_GET['tid']);
}
else
{
    $feedreq = '';
    $add = '';
}

if ($show != 'post')
{
    $result = $db->query('SELECT t.last_post, t.id, t.posted AS tposted, t.subject, t.poster, p.message, p.hide_smilies, p.posted AS pposted, f.forum_name AS forum, c.cat_name AS category FROM '.$db->prefix.'topics t LEFT JOIN '.$db->prefix.'posts p ON (p.topic_id=t.id AND t.posted=p.posted) INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'categories AS c ON f.cat_id=c.id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL'.$feedreq.' ORDER BY last_post DESC LIMIT '.$postslimit) or error('Unable to fetch forum topics', __FILE__, __LINE__, $db->error());
}
else
{
    $result = $db->query('SELECT t.last_post, p.id, p.message, p.poster, p.posted AS pposted, p.hide_smilies, t.posted AS tposted, t.subject, f.forum_name AS forum, c.cat_name AS category FROM '.$db->prefix.'posts p LEFT JOIN '.$db->prefix.'topics t ON p.topic_id=t.id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'categories AS c ON f.cat_id=c.id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL'.$feedreq.' ORDER BY last_post DESC LIMIT '.$postslimit) or error('Unable to fetch forum posts', __FILE__, __LINE__, $db->error());
}

//------------------------------------------------------------//

list($lastpost) = $db->fetch_row($result);
//pg_result_seek($result, 0);
mysql_data_seek($result, 0);

$x = '0';
$servertag = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? trim($_SERVER['HTTP_IF_NONE_MATCH']) : '';

ob_start();

if (!$lastpost)
{
    makeheader($none, $add);
    noposts($none);
}
else if ($servertag != $lastpost)
{
    while ($cur = $db->fetch_assoc($result))
    {
        if ($x == '0')
        {
            makeheader($cur, $add);
            $x++;
            $tag = $cur['last_post'];
        }
        makeposts($cur, $show, $maxchars);
    }
    echo '</channel>'."\n";
    echo '</rss>'."\n";
}

$feed = ob_get_contents();
ob_end_clean();

//------------------------------------------------------------//

if ($x == '0')
{
    header('HTTP/1.1 304 Not Modified');
    header('Last-Modified: '.gmdate('D, d M Y H:i:s', $lastpost).' GMT');
    header('Date: '.gmdate('D, d M Y H:i:s').' GMT');
    header('Content-Length: 0');
    header('Etag: '.$lastpost);
}
else
{
    header('Etag: '.$lastpost);

    if (stristr($_SERVER["HTTP_ACCEPT"], "application/xml"))
    {
        header ('Content-Type: application/rss+xml; charset='.$lang_common['lang_encoding']);
    }
    else
    {
        header ('Content-type: text/xml; charset='.$lang_common['lang_encoding']);
    }
    echo $feed;
}

//------------------------------------------------------------//

function makeheader($cur, $add)
{
    global $pun_config, $lang_common, $lang_feed, $modsdir, $imagedir, $forumuri;

    $language = strtolower(substr($pun_config['o_default_lang'], 0, 2));
    $script = basename($_SERVER['PHP_SELF']);
    $board_title = pun_htmlspecialchars($pun_config['o_board_title']);

    echo '<?xml version="1.0" encoding="'.$lang_common['lang_encoding'].'"?>'."\n";
    echo '<rss version="2.0" xmlns:atom="'.$lang_feed['Atom uri'].'">'."\n";
    echo '<channel>'."\n";
    echo '<title>'.$board_title.' '.$lang_feed['RSS feed'].'</title>'."\n";
    echo '<link>'.$forumuri.'</link>'."\n";
    echo '<generator>'.$lang_feed['RSS generator'].$lang_feed['Version'].'</generator>'."\n";
    echo '<description>'.$board_title.'</description>'."\n";
    echo '<language>'.$language.'</language>'."\n";
    echo '<docs>'.$lang_feed['RSS uri'].'</docs>'."\n";
    echo '<atom:link href="'.$modsdir.$script.$add.'" rel="self" type="application/rss+xml"/>'."\n";
    echo '<copyright>'."\n";
    echo "\t".$lang_feed['Copyright']."\n\t".$board_title."\n\t".$forumuri."\n";
    echo '</copyright>'."\n";
    echo '<ttl>60</ttl>'."\n";
}

function noposts($none)
{
    global $pun_config, $lang_common, $lang_feed, $modsdir, $imagedir, $forumuri;

    echo '<item>'."\n";
    echo "\t".'<title>'.$lang_feed['No posts'].'</title>'."\n";
    echo "\t".'<link>'.$forumuri.'</link>'."\n";
    echo "\t".'<guid isPermaLink="false">'.$forumuri.'</guid>'."\n";
    echo "\t".'<description>'."\n";
    echo "\t\t".$lang_feed['No posts info']."\n";
    echo "\t".'</description>'."\n";
    echo '</item>'."\n";
    echo '</channel>'."\n";
    echo '</rss>'."\n";
}

function makeposts($cur, $show, $maxchars)
{
    global $pun_config, $lang_common, $lang_feed, $modsdir, $imagedir, $forumuri;

    if ($show != 'post')
    {
        $link = $forumuri.'viewtopic.php?id='.strval($cur['id']);
    }
    else
    {
        $link = $forumuri.'viewtopic.php?pid='.strval($cur['id']).'#p'.strval($cur['id']);
    }

    $author = pun_htmlspecialchars($cur['poster']);

    if (strpos($cur['message'], '[video]') !== false || strpos($cur['message'], '[mp3]') !== false)
    {
        $message = str_replace(array('[video]', '[/video]', '[mp3]', '[/mp3]'), array('[url]', '[/url]', '[url]', '[/url]'), $cur['message']);
    }
    else
    {
        $message = $cur['message'];
    }

    $post = gmdate('d M Y H:i:s', $cur['last_post']);
    $topic = gmdate('d M Y H:i:s', $cur['tposted']);

    if (pun_strlen($message) > $maxchars)
    {
        $message = '<![CDATA[ '.$lang_feed['Author'].$author.'<br/>'."\n\t\t".parse_message(pun_htmlspecialchars($message), $cur['hide_smilies']).' ]]>';
    }
    else
    {
        $message = '<![CDATA[ '.$lang_feed['Author'].$author.'<br/>'."\n\t\t".parse_message(pun_htmlspecialchars($message), $cur['hide_smilies']).' ]]>';
    }

    echo '<item>'."\n";
    echo "\t".'<title>'.pun_htmlspecialchars($cur['subject']).'</title>'."\n";
    echo "\t".'<link>'.pun_htmlspecialchars($link).'</link>'."\n";
    echo "\t".'<guid isPermaLink="false">'.strval($cur['id']).'@'.$forumuri.'</guid>'."\n";
    echo "\t".'<pubDate>'.strval(date("r", $cur['tposted'])).'</pubDate>'."\n";
    echo "\t".'<category>'.pun_htmlspecialchars($cur['category'].' : '.$cur['forum']).'</category>'."\n";
    echo "\t".'<description>'."\n";
    echo "\t\t".$message."\n";
    echo "\t".'</description>'."\n";
    echo '</item>'."\n";
}

//------------------------------------------------------------//

?>

I am using punbb on my webpage merely as a Blog and create a RSS feed with RSS.php. After that I display the latest topics with a widget called FeedSweep on the entry page as a sort of "news" section. Most topics only have one post, (i.e like a Blog).

Sometimes I need to change the post date of the posts in order to insert a post respectively topic between two preexisitng posts, since in my widget they appear in chronological order. Because I did not find how to modify the post date directly within the punbb - interface, I do that directly in the SQL database of punbb (which forces me to translate the date into integer (10). In punbb that works nice and if I display the index of topics the result is as expected.

However the RSS feed I collect from RSS.php "looses" the message of the post and only displays the post date (as modified), the author, the subject. Again, this does not happen if I leave the post date as generated automically by punbb.

I may add that I slightly modified the RSS.php in order to avoid truncation of the message, because I want this to be done by my widget (Feedsweep). For this in line 200 I inserted the same as in line 204 so that the test regarding the length of the message is useless. I know this is not very elegant, but having no PHP programming knowledge I thought this to be the safest method.
So instead of:

if (pun_strlen($message) > $maxchars)
    {
        $message = '<![CDATA[ '.$lang_feed['Author'].$author.'<br/>'."\n\t\t".$lang_feed['Topic created'].$topic.'<br/>'."\n\t\t".$lang_feed['Topic updated'].$post.'<br/>'."\n\t\t".parse_message(pun_htmlspecialchars(truncate($message, $maxchars)), $cur['hide_smilies']).$lang_feed['Truncated'].' ]]>';
    }
    else
    {
        $message = '<![CDATA[ '.$lang_feed['Author'].$author.'<br/>'."\n\t\t".$lang_feed['Topic created'].$topic.'<br/>'."\n\t\t".$lang_feed['Topic updated'].$post.'<br/>'."\n\t\t".parse_message(pun_htmlspecialchars($message), $cur['hide_smilies']).' ]]>';
    }

I have:

if (pun_strlen($message) > $maxchars)
    {
        $message = '<![CDATA[ '.$lang_feed['Author'].$author.'<br/>'."\n\t\t".parse_message(pun_htmlspecialchars($message), $cur['hide_smilies']).' ]]>';
    }
    else
    {
        $message = '<![CDATA[ '.$lang_feed['Author'].$author.'<br/>'."\n\t\t".parse_message(pun_htmlspecialchars($message), $cur['hide_smilies']).' ]]>';
    }

Any idea why the message of the post disappears?
The forum is located at http://www.zoara.ch/forums/viewforum.php?id=2.

The widget showing the RSS feed at http://www.zoara.ch/