<?php
/**
* newest_posts - raw dump of newest posts from forum
*
* @copyright (c) 2008 ameeck / Vojtech Vondra - phpBB.cz
* @license
http://opensource.org/licenses/gpl-license.php GNU Public License
*/
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// Number of posts and grabbing permissions
$topic_limit = request_var('topic_limit', 30);
// forum_id to grab topics from (must be a valid forum_id integer)
$forums = array_unique(array_keys($auth->acl_getf('f_read', true)));
// Initial var setup
$forum_id = request_var('f', 0);
$topic_id = request_var('t', 0);
$forum_sql = empty($forum_id) ? '' : (" AND f.forum_id = '$forum_id'");
$topic_sql = empty($topic_id) ? '' : (" AND p.topic_id = t.topic_id AND t.topic_id = '$topic_id'");
// Select the last topics to which we have permissions
$sql = 'SELECT p.post_id, p.topic_id, p.forum_id, p.post_subject, p.post_text, p.post_time, u.username
FROM '. FORUMS_TABLE .' f,'.TOPICS_TABLE.' t, '.POSTS_TABLE.' p,'.USERS_TABLE.' u
WHERE t.forum_id = f.forum_id
AND t.topic_status != 1
AND u.user_id = p.poster_id' . $forum_sql . $topic_sql . (empty($topic_sql) ? ' AND p.post_id = t.topic_last_post_id ' : '') . '
ORDER BY ' . (empty($topic_sql) ? 't.topic_last_post_time DESC' : 'p.post_time DESC') . '
LIMIT 0,' . $topic_limit;
$result = $db->sql_query($sql);
// Proper header since output not buffered
header('Content-Type: text/html; charset=utf-8');
// Now let's output the content
echo '<div id="post_content"><ul style="list-style-type:none;">';
while ($row = $db->sql_fetchrow($result))
{
$url = generate_board_url() . "/viewtopic.{$phpEx}?f={$row['forum_id']}&t={$row['topic_id']}&p={$row['post_id']}#p{$row['post_id']}";
echo '<li><a target="_parent" href="' . $url . '">' . $row['post_subject'] . '</a></li><li>' . $row['post_text'] . '</li><br><br><li>from: ' . $row['username'] . ' on ' . $user->format_date($row['post_time']) . '</li><br>';
}
echo '</ul></div>';
?>