Vadyus писал(а):Хммм. Это phpBB2 + TorrentPier, не могу сказать точно, что за мод подфорумов они в дистрибудтив положили...
// End session management
//function CalcTopicAndPostsCount($forum_id)
{
global $db;
global $msgCount;
global $topicCount;
global $last_post_time;
global $forum_data;
// $sql='select * from phpbb_forums where forum_id='.$forum_id;
$sql = 'SELECT f.*, p.post_time, p.post_username, u.username, u.user_id,
t.topic_id AS last_topic_id, t.topic_title AS last_topic_title
FROM '. FORUMS_TABLE .' f LEFT JOIN '. POSTS_TABLE .' p ON
p.post_id = f.forum_last_post_id
LEFT JOIN '. USERS_TABLE .' u ON u.user_id = p.poster_id
LEFT JOIN '. TOPICS_TABLE ." t ON t.topic_last_post_id = f.forum_last_post_id
WHERE f.forum_id = $forum_id ORDER BY f.cat_id, f.forum_order";
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not obtain segments information', '', __LINE__, __FILE__, $sql);
}
if($row = $db->sql_fetchrow($result))
{
$msgCount = $msgCount + $row['forum_posts'];
$topicCount = $topicCount + $row['forum_topics'];
if($row['forum_last_post_id'])
{
if ((!$last_post_time)||($last_post_time<$row['post_time']))
{
$last_post_time=$row['post_time'];
$forum_data['forum_last_post_id'] = $row['forum_last_post_id'];
$forum_data['last_topic_id']=$row['last_topic_id'];
$forum_data['last_topic_title']=$row['last_topic_title'];
$forum_data['post_time']=$row['post_time'];
$forum_data['user_id']=$row['user_id'];
$forum_data['username']=$row['username'];
}
}
}
$sql='select * from phpbb_forums where forum_parent='.$forum_id;
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not obtain segments information', '', __LINE__, __FILE__, $sql);
}
while($row = $db->sql_fetchrow($result))
{
CalcTopicAndPostsCount($row['forum_id']);
}
}$posts = $forum_data['forum_posts'];
$topics = $forum_data['forum_topics'];// $posts = $forum_data['forum_posts'];
// $topics = $forum_data['forum_topics'];
$msgCount=0;
$topicCount=0;
$last_post_time=0;
CalcTopicAndPostsCount($forum_data['forum_id']);
$posts = $msgCount;
$topics = $topicCount;'POSTS' => $forum_data['forum_posts'],
'TOPICS' => $forum_data['forum_topics'],// 'POSTS' => $forum_data['forum_posts'],
// 'TOPICS' => $forum_data['forum_topics'],
'POSTS' => $posts,
'TOPICS' => $topics,define('LAST_TOPIC_MAX_LEN', 40);function CalcTopicAndPostsCount($forum_id)
{
global $db;
global $msgCount;
global $topicCount;
global $last_post_time;
global $forum_data;
// $sql='select * from phpbb_forums where forum_id='.$forum_id;
$sql = 'SELECT f.*, p.post_time, p.post_username, u.username, u.user_id,
t.topic_id AS last_topic_id, t.topic_title AS last_topic_title
FROM '. FORUMS_TABLE .' f LEFT JOIN '. POSTS_TABLE .' p ON
p.post_id = f.forum_last_post_id
LEFT JOIN '. USERS_TABLE .' u ON u.user_id = p.poster_id
LEFT JOIN '. TOPICS_TABLE ." t ON t.topic_last_post_id = f.forum_last_post_id
WHERE f.forum_id = $forum_id ORDER BY f.cat_id, f.forum_order";
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not obtain segments information', '', __LINE__, __FILE__, $sql);
}
if($row = $db->sql_fetchrow($result))
{
$msgCount = $msgCount + $row['forum_posts'];
$topicCount = $topicCount + $row['forum_topics'];
if($row['forum_last_post_id'])
{
if ((!$last_post_time)||($last_post_time<$row['post_time']))
{
$last_post_time=$row['post_time'];
$forum_data['forum_last_post_id'] = $row['forum_last_post_id'];
$forum_data['last_topic_id']=$row['last_topic_id'];
$forum_data['last_topic_title']=$row['last_topic_title'];
$forum_data['post_time']=$row['post_time'];
$forum_data['user_id']=$row['user_id'];
$forum_data['username']=$row['username'];
}
}
}
$sql='select * from phpbb_forums where forum_parent='.$forum_id;
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not obtain segments information', '', __LINE__, __FILE__, $sql);
}
while($row = $db->sql_fetchrow($result))
{
CalcTopicAndPostsCount($row['forum_id']);
}
} if ($forum_data['forum_last_post_id'])
{
$last_post_time = create_date($board_config['default_dateformat'], $forum_data['post_time'], $board_config['board_timezone']);
$last_post = $last_post_time . '<br />';
$last_post .= ($forum_data['user_id'] == ANONYMOUS) ? (($forum_data['post_username']) ? $forum_data['post_username'] .' ' : $lang['Guest'] .' ' ) : '<a href="'. append_sid("profile.$phpEx?mode=viewprofile&". POST_USERS_URL .'='. $forum_data['user_id']) .'">'. $forum_data['username'] .'</a> ';
$last_post .= '<a href="'. append_sid("viewtopic.$phpEx?". POST_POST_URL .'='. $forum_data['forum_last_post_id']) .'#'. $forum_data['forum_last_post_id'] .'"><img src="'. $images['icon_latest_reply'] .'" border="0" width="18" height="9" alt="'. $lang['View_latest_post'] .'" title="'. $lang['View_latest_post'] .'" /></a>';
} $msgCount=0;
$topicCount=0;
$last_post_time=0;
CalcTopicAndPostsCount($forum_data['forum_id']);
$posts = $msgCount;
$topics = $topicCount;'POSTS' => $forum_data['forum_posts'],
'TOPICS' => $forum_data['forum_topics'],// 'POSTS' => $forum_data['forum_posts'],
// 'TOPICS' => $forum_data['forum_topics'],
'POSTS' => $posts,
'TOPICS' => $topics,#
#-----[ OPEN ] ----------
#
index.php
#
#-----[ FIND ] ----------
#
{catrow.forumrow.TOPICS}
#
#-----[ REPLACE WITH ] ----------
#
{catrow.forumrow.TOTAL_TOPICS}
#
#-----[ FIND ] ----------
#
{catrow.forumrow.POSTS}
#
#-----[ REPLACE WITH ] ----------
#
{catrow.forumrow.TOTAL_POSTS}Вернуться в Запросы модов для phpBB 2.0.x
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 0