// Похожие темы НАЧАЛО
if ($t_data['allow_reg_tracker'])
{
$title = (strlen($topic_title) > 10) ? (substr($topic_title, 0, 10) . '') : $topic_title;
$sgl_search = "t.topic_title LIKE '%" . addslashes($title) . "%'";
//$porno_forums = $bb_cfg['porno_forums'] ? $bb_cfg['porno_forums'] : '0';
$trash_forums = $bb_cfg['trash_forum_id'] ? $bb_cfg['trash_forum_id'] : '0';
$sql = "SELECT t.*, u.user_id, u.username, f.forum_id, f.forum_name, tor.size
FROM ". BB_TOPICS ." t, ". BB_USERS ." u, ". BB_FORUMS ." f, ". BB_BT_TORRENTS ." tor
WHERE t.topic_id != $topic_id
AND tor.topic_id = t.topic_id
AND $sgl_search
AND f.allow_reg_tracker = 1
AND t.forum_id = f.forum_id
AND t.topic_poster = u.user_id
AND f.forum_id NOT IN ($trash_forums)
GROUP BY t.topic_title LIMIT 0,8";
if ( !($result = DB()->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not get main information for similar topics", '', __LINE__, __FILE__, $sql);
}
$similar = array();
while ( $row = DB()->sql_fetchrow($result) )
{
$similar[] = $row;
}
$count_similar = count($similar);
if ( $count_similar > 0)
{
$template->assign_block_vars('similar', array());
if ($count_similar > 2)
{
$page_cfg['use_tablesorter'] = true;
}
for($i = 0; $i < $count_similar; $i++)
{
$title = wbr(str_short($similar[$i]['topic_title'], 200));
$topic_url = '<a title="'.$similar[$i]['topic_title'].'" href="'. "viewtopic.php?". POST_TOPIC_URL .'='. $similar[$i]['topic_id'] .'">'. $title . '</a>';
$poster_url = "profile.php?mode=viewprofile&". POST_USERS_URL .'='. $similar[$i]['user_id'];
$similar[$i]['username'] = wbr($similar[$i]['username']);
$poster_username = '<a class="genmed" href="'. $poster_url .'">'. $similar[$i]['username'] .'</a>';
$forum_url = "viewforum.php?f=". $similar[$i]['forum_id'];
$forum = '<a class="genmed" href="'. $forum_url .'">'. $similar[$i]['forum_name'] .'</a>';
$tor_size = humn_size($similar[$i]['size']);
$template->assign_block_vars('similar.topics', array(
'TOPICS' => $topic_url,
'AUTHOR' => $poster_username,
'FORUM' => $forum,
'TOR_SIZE' => $tor_size,
));
}
}
}
// Похожие темы КОНЕЦ