Похожие темы (поиск Sphinx) 1.0.0

Добавляет вывод похожих тем при просмотре темы (поиск Sphinx).

  1. Exile
    Совместимость:
    не проверялся на совместимость
    Изменения в БД:
    не требуются
    Автор:
    Zenden
    Общественное достояние:
    да
    Описание: добавляет вывод похожих тем при просмотре темы (поиск Sphinx).
    Инструкция по установке:
    PHP:
    ОписаниеСвязанные раздачи.
    АвторZenden

    *****************************************
    Открыть config.php
    В самом низу добавить
    $bb_cfg
    ['similar_topics'] = array(
        
    'enabled'                => true,
        
    'title_match_max_len'    => 60,
        
    'count'                    => 5,
    );

    *****************************************
    октрыть viewtopic.php

    Найти
        
    if ($poster_id != BOT_UID)
        {
            
    $prev_post_time $postrow[$i]['post_time'];
        }

    после добавить
        
    if ($bb_cfg['similar_topics']['enabled'] && $t_data['allow_reg_tracker'] && (!$start && ($post_id == $t_data['topic_first_post_id'])))
        {
            if (!
    $forums $datastore->get('cat_forums'))
            {
                
    $datastore->update('cat_forums');
                
    $forums $datastore->get('cat_forums');
            }

            
    $btu get_bt_userdata($userdata['user_id']);
            
    $excluded_forums_csv $user->get_excluded_forums(AUTH_VIEW);
            
    $not_auth_forums_sql = ($excluded_forums_csv) ? "AND t.forum_id NOT IN($excluded_forums_csv)" '';
            
    $allowed_forums array_diff(explode(','$forums['tracker_forums']), explode(','$excluded_forums_csv));

            if (
    $title_match =& $topic_title AND is_string($title_match))
            {
                if (
    $tmp mb_substr(trim($title_match), 0$bb_cfg['similar_topics']['title_match_max_len'], 'UTF-8'))
                {
                    
    $title_match_val clean_text_match($tmptruefalsefalse);

                    if (!
    $data CACHE('portal')->get($t_data['topic_id']))
                    {
                        
    $mb_strrpos            mb_strrpos($title_match_val' ''UTF-8');
                        
    $title_match_val    mb_substr($title_match_val0$mb_strrpos'UTF-8');
                        
    $title_match_val    trim(str_replace(" 039 "''$title_match_val));
                        
    $title_match_topics get_title_match_topics($title_match_val$allowed_forums);

                        if (
    $search_match_topics_csv join(','$title_match_topics))
                        {
                            
    $data DB()->fetch_rowset("
                                SELECT
                                    t.topic_id, t.topic_title, t.topic_time, t.topic_replies, tor.info_hash, tor.attach_id, tor.size, tor.tor_type, sn.seeders, sn.leechers
                                FROM " 
    BB_TOPICS " AS t
                                LEFT JOIN " 
    BB_BT_TORRENTS " AS tor ON tor.topic_id = t.topic_id
                                LEFT JOIN " 
    BB_BT_TRACKER_SNAP " AS sn ON sn.topic_id = tor.topic_id
                                WHERE t.topic_dl_type = 1
                                
    $not_auth_forums_sql
                                AND t.topic_id IN(
    $search_match_topics_csv)
                                ORDER BY t.topic_time DESC
                                LIMIT 5
                            "
    );

                            foreach (
    $data as $k => $value)
                            {
                                if (
    $value['topic_id'] == $topic_id)
                                {
                                    unset(
    $data[$k]);
                                }
                            }
                            
    CACHE('portal')->set($t_data['topic_id'], $data3600);
                        }

                    }

                    unset(
    $forums);
                    
    $datastore->rm('cat_forums');
                   
                    if (!empty(
    $data))
                    {
                        
    $template->assign_vars(array('SIMILAR_TOPICS' => true));

                        foreach (
    $data as $row)
                        {
                            
    $template->assign_block_vars('postrow.similar', array(
                                
    'U_VIEW_TOPIC'    => TOPIC_URL $row['topic_id'],
                                
    'TOPIC_TITLE'    => $row['topic_title'],
                                
    'TOPIC_TIME'    => bb_date($row['topic_time'], $bb_cfg['last_post_date_format'], 'false'),
                                
    'TOPIC_REPLIES'    => $row['topic_replies'],
                                
    'U_DOWNLOAD_LINK' => BB_ROOT DOWNLOAD_URL $row['attach_id'],
                                
    'ICON_DN'        => '<img src="'$images['icon_dn'] .'" alt="'$lang['DL_TORRENT'] .'" border="0" />',
                                
    'SIZE'            => humn_size($row['size']),
                                
    'MAGNET'        => create_magnet($row['info_hash'], $btu['auth_key'], $userdata['session_logged_in']),
                                
    'TOR_TYPE'        => is_gold($row['tor_type']),
                                
    'SEEDERS'        => $row['seeders'],
                                
    'LEESHERS'        => $row['leechers']
                            ));
                        }
                    }
                    else
                    {
                        
    $template->assign_vars(array('SIMILAR_TOPICS' => false));
                    }
                }
            }
        }

    *****************************************
    октрыть viewtopic.tpl
    Найти
    {postrow.ATTACHMENTS}

    Ниже вставить
                            
    <!-- IF SIMILAR_TOPICS && postrow.IS_FIRST_POST -->
                            <
    table class="forumline tablesorter">
                                <
    caption>Связанные раздачи</caption>
                                <
    thead>
                                    <
    tr>
                                        <
    th class="{sorter: 'text'}"><class="tbs-text">{L_BT_ADDED}</b></th>
                                        <
    th class="{sorter: 'text'}"><class="tbs-text">{L_TITLE}</b></th>
                                        <
    th class="{sorter: 'text'}"><class="tbs-text">{L_SIZE}</b></th>
                                        <
    th class="{sorter: 'text'}"><class="tbs-text">L</b></th>
                                        <
    th class="{sorter: false}"><class="tbs-text">{L_URL}</b></th>
                                    </
    tr>
                                </
    thead>
                                <
    tbody>
                                    <!-- 
    BEGIN similar -->
                                    <
    tr>
                                        <
    td class="tCenter">{similar.TOPIC_TIME}</td>
                                        <
    td><a href="{similar.U_VIEW_TOPIC}" title="{similar.TOPIC_TITLE}">{similar.TOPIC_TITLE}</a>{similar.TOR_TYPE}<em class="floatR small" title="{L_REPLIES}">{L_REPLIES_SHORT} {similar.TOPIC_REPLIES}</em></td>
                                        <
    td class="tCenter">{similar.SIZE}</td>
                                        <
    td class="tCenter">{similar.SEEDERS} | {similar.LEESHERS}</td>
                                        <
    td class="tCenter">
                                            <
    a href="{similar.U_DOWNLOAD_LINK}" title="Скачать">{similar.ICON_DN}</a>
                                            {
    similar.MAGNET}
                                        </
    td>
                                    </
    tr>
                                    <!-- 
    END similar -->
                                </
    tbody>
                            </
    table>
                            <!-- ENDIF / 
    SIMILAR_TOPICS -->