$query = $db->query("SELECT t.*, f.name AS forumname, p.pid, p.message AS postmessage FROM ".TABLE_PREFIX."threads t LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=t.fid) LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=t.firstpost) WHERE 1=1 $forumlist $unviewable AND t.visible='1' ORDER BY t.dateline DESC LIMIT 0, ".$mybb->input['limit']);
while($thread = $db->fetch_array($query))
{
$thread['subject'] = htmlspecialchars_uni($thread['subject']);
$thread['forumname'] = htmlspecialchars_uni($thread['forumname']);
$postdate = mydate($mybb->settings['dateformat'], $thread['dateline'], "", 0);
$posttime = mydate($mybb->settings['timeformat'], $thread['dateline'], "", 0);
$thread['postmessage'] = nl2br(htmlspecialchars_uni($thread['postmessage']));
$pubdate = mydate("r", $thread['dateline'], "", 0);
$user_query = $db->query("SELECT uid,email FROM ".TABLE_PREFIX."users WHERE uid='".$thread['pid']."'");
while($user = $db->fetch_array($user_query))
{
switch($mybb->input['type'])
{
case "rss2.0";
echo "\t\t<item>\n";
echo "\t\t\t<guid>".$mybb->settings['bburl']."/showthread.php?tid=".$thread['tid']."&action=newpost</guid>\n";
echo "\t\t\t<title>".$thread['subject']."</title>\n";
echo "\t\t\t<author>".$thread['username']." ".$user['email']."</author>\n";
$description = htmlspecialchars($lang->forum." ".$thread['forumname']."\r\n<br />".$lang->posted_by." ".$thread['username']." ".$lang->on." ".$postdate." ".$posttime);
if($thread['postmessage'])
{
$description .= "\n<br />".$thread['postmessage'];
}
echo "\t\t\t<description><![CDATA[".$description."]]></description>";
echo "\t\t\t<link>".$mybb->settings['bburl']."/showthread.php?tid=".$thread['tid']."&action=newpost</link>\n";
echo "\t\t\t<category domain=\"".$mybb->settings['bburl']."/forumdisplay.php?fid=".$thread['fid']."\">".$thread['forumname']."</category>\n";
echo "\t\t\t<pubDate>".$pubdate."</pubDate>\n";
echo "\t\t</item>\n";
break;
default:
echo "\t\t<item>\n";
echo "\t\t\t<title>".$thread['subject']."</title>\n";
echo "\t\t\t<author>".$thread['username']."</author>\n";
$description = htmlspecialchars($lang->forum." ".$thread['forumname']."\r\n<br />".$lang->posted_by." ".$thread['username']." ".$lang->on." ".$postdate." ".$posttime);
if($thread['postmessage'])
{
$description .= "\n<br />".$thread['postmessage'];
}
echo "\t\t\t<description><![CDATA[".$description."]]></description>";
echo "\t\t\t<link>".$mybb->settings['bburl']."/showthread.php?tid=".$thread['tid']."&action=newpost</link>\n";
echo "\t\t</item>\n";
break;
}
}
}