


СпасибоЕгор Наклоняев писал(а):HD_TT
http://phpbbguru.net/community/viewtopic.php?t=1839
http://phpbbguru.net/community/viewtopic.php?t=1591
Код: Выделить всё
<?php
define ('IN_PHPBB', true);
$phpbb_root_path = 'forum/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$count = 15;
// Create main board url (some code borrowed from functions_post.php)
$script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path']));
$viewtopic = ( $script_name != '' ) ? $script_name . '/viewtopic.' . $phpEx : 'viewtopic.'. $phpEx;
$server_name = trim($board_config['server_name']);
$server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://';
$server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/';
$viewtopic_url = $server_protocol . $server_name . $server_port . $viewtopic;
$out = "";
// SQL statement to fetch active topics of public forums
$sql = "SELECT DISTINCT t.topic_title, t.topic_last_post_id, p.post_time, f.forum_name
FROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . FORUMS_TABLE . " AS f
WHERE
t.forum_id = f.forum_id //НОМЕР РАЗДЕЛА пример: новости-1 раздел
AND f.auth_view = " . AUTH_ALL . "
AND p.topic_id = t.topic_id
AND p.post_id = t.topic_last_post_id
ORDER BY p.post_time DESC LIMIT ".$count;
$topics_query = $db->sql_query($sql);
if ( !$topics_query )
{
die("Failed obtaining list of active topics");
}
else
{
$topics = $db->sql_fetchrowset($topics_query);
}
if ( count($topics) == 0 )
{
die("No topics found");
}
else
{
$x=count($topics);
for ($i = 0; $i < $x ; $i++)
{
$title = $topics[$i]['topic_title'];
$url = $viewtopic_url . "?" . POST_POST_URL . "=" . $topics[$i]['topic_last_post_id'] . "#" . $topics[$i]['topic_last_post_id'];
$out .= '<a href="'.$url.'">'.$title.'</a><br>';
}
}
echo $out;
?>