rendered paste body<?php
/** configuration **/
$phpbb_root_path = './';
$phpbb_news_forum = 1; // announcements in current setup.
$phpbb_root_url = 'http://localhost/phpBB2/'; // with trailing slash
// bootstrap phpBB
define('IN_PHPBB', true);
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
/**
* Code to retrieve and output news items.
*/
global $db;
// news fetching query
$news_sql = "
SELECT
t.topic_id,
t.topic_title,
t.topic_time,
t.topic_replies,
pt.post_text,
u.username
FROM
".TOPICS_TABLE." t,
".POSTS_TABLE." p,
".USERS_TABLE." u,
".POSTS_TEXT_TABLE." pt
WHERE
t.forum_id=".intval($phpbb_news_forum)." AND
pt.post_id=t.topic_first_post_id AND
u.user_id=t.topic_poster
GROUP BY t.topic_id
ORDER BY t.topic_time DESC
";
if (!($result = $db->sql_query($news_sql))) {
echo "<h3>No news posted yet</h3>";
echo mysql_error();
} else {
while ($news_row = $db->sql_fetchrow($result)) {
$topic_link = $phpbb_root_url.'viewtopic.php?t='.$news_row['topic_id'];
// post heading
echo "<h2><a href=\"$topic_link\">".$news_row['topic_title']."</a></h2>";
// post information
$post_date = create_date($board_config['default_dateformat'], $news_row['topic_time'], $board_config['board_timezone']);
echo "Posted by ".$news_row['username']." on ".$post_date."<br />";
// post text
echo "<p>".$news_row['post_text']."</p>";
// reply information with link
switch ($news_row['topic_replies']) {
case 0:
$reply_text = "No replies";
break;
case 1:
$reply_text = "One reply";
break;
default:
$reply_text = $news_row['topic_replies']." replies";
}
echo "<a href=\"$topic_link\">".$reply_text."</a>";
}
}
?>