TorrentStream 1.1.0

Добавляет проигрывание торрентов без их скачивания через сервис TorrentStream.

  1. Exile
    Совместимость:
    проверялся на совместимость
    Изменения в БД:
    требуются
    Автор:
    IEx0
    Общественное достояние:
    да
    Описание: добавляет проигрывание торрентов без их скачивания через сервис TorrentStream.
    Инструкция по установке:
    PHP:
    /**
    *
    * Онлайн просмотр
    *
    **/
    #
    ##---[SQL]----------
    #

    ALTER TABLE `bb_bt_torrentsADD `ttube_hashVARCHAR255 NOT NULL;
    INSERT INTO `bb_config` (`config_name`, `config_value`) VALUES
    ('tt_api''81a81abced52283c830e7688f08c267e'),
    (
    'tt_height''350'),
    (
    'tt_type''1'),
    (
    'tt_width''640'),
    (
    'tt_zone''787');

    ALTER TABLE `bb_forumsADD `tt_viewTINYINTNOT NULL DEFAULT '0';

    #
    ##---[OPEN]----------
    #
    templates/admin/admin_board.tpl

    #
    ##---[FIND]----------
    #
        
    <td><h4>{L_BIRTHDAY_CHECK_DAY}</h4></td>
        <
    td><input class="post" type="text" size="25" maxlength="100" name="birthday_check_day" value="{BIRTHDAY_CHECK_DAY}" />&nbsp;{L_DAYS}</td>
    </
    tr>

    #
    ##---[AFTER ADD]----------
    #
    <tr class="row3 med">
        <
    td class="bold tCenter" colspan="2">{L_TTUBE_FUNCTION}</td>
    </
    tr>
    <
    tr>
        <
    td><h4>{L_TTUBE_ZONE}</h4></td>
        <
    td><input class="post" type="text" size="25" maxlength="100" name="tt_zone" value="{TT_ZONE}" /></td>
    </
    tr>
    <
    tr>
        <
    td><h4>{L_TTUBE_API}</h4></td>
        <
    td><input class="post" type="text" size="35" maxlength="100" name="tt_api" value="{TT_API}" /></td>
    </
    tr>
    <
    tr>
        <
    td><h4>{L_TTUBE_OPEN_TYPE}</h4></td>
        <
    td>
            <
    select name="tt_type">
                <
    option value="1" {TT_POPUP}>Pretty PhotoPopUp</option>
                <
    option value="2" {TT_BLANK}>BLANK PAGE</option>
                <
    option value="3" {TT_FRAME}>IFRAME</option>
            </
    select>
        </
    td>
    </
    tr>
    <
    tr>
        <
    td><h4>{L_TTUBE_WIDTH}</h4></td>
        <
    td><input class="post" type="text" size="25" maxlength="100" name="tt_width" value="{TT_WIDTH}" /></td>
    </
    tr>

    <
    tr>
        <
    td><h4>{L_TTUBE_HEIGHT}</h4></td>
        <
    td><input class="post" type="text" size="25" maxlength="100" name="tt_height" value="{TT_HEIGHT}" /></td>
    </
    tr>

    #
    ##---[OPEN]----------
    #
    admin_forums.tpl

    #
    ##---[FIND]----------
    #
                
    <select name="forum_display_sort">{S_FORUM_DISPLAY_SORT_LIST}</select>&nbsp;
                <
    select name="forum_display_order">{S_FORUM_DISPLAY_ORDER_LIST}</select>&nbsp;
            </
    td>
        </
    tr>
       
    #
    ##---[AFTER ADD]----------
    #
        
    <tr>
            <
    td class="row1">{L_TTUBE_FUNCTION}</td>
            <
    td class="row2">
                <
    select name="tt_view">
                    <
    option value="1"<!-- IF TT_VIEW --> selected="selected"<!-- ENDIF -->>{L_TTUBE_ENABLE}</option>
                    <
    option value="0"<!-- IF not TT_VIEW --> selected="selected"<!-- ENDIF -->>{L_TTUBE_DISABLE}</option>
                </
    select>
            </
    td>
        </
    tr>

    #
    ##---[OPEN]----------
    #

    templates/dafault/viewtopic_attach.tpl    Modified

    #
    ##---[FIND]----------
    #
                
    <a href="{postrow.attach.tor_reged.U_DOWNLOAD_LINK}" class="{postrow.attach.tor_reged.DL_LINK_CLASS}">
               
    #
    ##---[BEFORE ADD]----------
    #

                
    <!-- IF TS_POPUP --><a href="player.php?id={postrow.attach.tor_reged.ATTACH_ID}&amp;frame=1&amp;iframe=true&amp;width={TS_WIDTH_P}&amp;height={TS_HEIGHT_P}" rel="prettyPhoto[iframes]"  title="<b>{L_TT_ONLINE_VIEW}:</b> {TS_TOPIC_TITLE}"><img src="styles/images/ts_view.png" alt="{L_TT_ONLINE_VIEW}" width="48" title="{L_TT_ONLINE_VIEW}" /></a><br /><!-- ENDIF -->
                <!-- IF 
    TS_BLANK --><strong><a href="player.php?id={postrow.attach.tor_reged.ATTACH_ID}" title="{L_TT_ONLINE_VIEW}" target="_blank">{L_TT_ONLINE_VIEW}</a></strong><br /><!-- ENDIF -->
           
    #
    ##---[FIND]----------
    #
    <!-- ENDIF -->
    <!-- 
    END tor_reged -->

    #
    ##---[BEFORE ADD]----------
    #

    <!-- IF TS_FRAME --><center><iframe src="player.php?id={postrow.attach.tor_reged.ATTACH_ID}&amp;frame=1" width="{TS_WIDTH}" height="{TS_HEIGHT}" frameborder="1" marginwidth="0" marginheight="0" scrolling="no"></iframe></center><!-- ENDIF -->

    #
    ##---[OPEN]----------
    #

    templates/dafault/page_header.tpl    Modified

    #
    ##---[ADD]----------
    #

    <link rel="stylesheet" href="{SITE_URL}styles/js/prettyphoto/css/prettyPhoto.css" type="text/css" media="screen" title="prettyPhoto main stylesheet" charset="utf-8" />
    <
    script src="{SITE_URL}styles/js/prettyphoto/js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">
    $(document).ready(function(){
        $("a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'fast',slideshow:10000});
    });
    </script>

    #
    ##---[OPEN]----------
    #
    includes/functions_torrent.php

    #
    ##---[FIND]----------
    #
    function send_torrent_with_passkey ($filename)

    #
    ##---[BEFORE ADD]----------
    #
    /**
    * TorrentTUBE
    */
    function return_torrent_with_passkey ($filename)
    {
        global $attachment, $auth_pages, $userdata, $bb_cfg, $lang;

            if (!$bb_cfg['bt_add_auth_key'] || $attachment['extension'] !== TORRENT_EXT || !$size = @filesize($filename))
            {
                    return;
            }

            $post_id = $poster_id = $passkey_val = '';
            $user_id = $userdata['user_id'];
            $attach_id = $attachment['attach_id'];

            if (!$passkey_key = $bb_cfg['passkey_key'])
            {
                    bb_die('Could not add passkey (wrong config $bb_cfg[\'passkey_key\'])');
            }
           
            // Get $post_id & $poster_id
            foreach ($auth_pages as $rid => $row)
            {
                    if ($row['attach_id'] == $attach_id)
                    {
                            $post_id = $row['post_id'];
                            $poster_id = $row['user_id_1'];
                            break;
                    }
            }

             // Get $topic_id
            $topic_id_sql = 'SELECT topic_id FROM ' . BB_POSTS . ' WHERE post_id = ' . (int) $post_id;
            if (!($topic_id_result = DB()->sql_query($topic_id_sql)))
            {
                    bb_die('Could not query post information');
            }
            $topic_id_row = DB()->sql_fetchrow($topic_id_result);
            $topic_id = $topic_id_row['topic_id'];

            if (!$attachment['tracker_status'])
            {
                    bb_die($lang['PASSKEY_ERR_TOR_NOT_REG']);
            }

            if (bf($userdata['user_opt'], 'user_opt', 'dis_passkey') && !IS_GUEST)
            {
                    bb_die('Could not add passkey');
            }

            if ($bt_userdata = get_bt_userdata($user_id))
            {
                    $passkey_val = $bt_userdata['auth_key'];
            }

            if (!$passkey_val)
            {
                    if (!$passkey_val = generate_passkey($user_id))
                    {
                            bb_simple_die('Could not generate passkey');
                    }
            }
            // Ratio limits
            $min_ratio = $bb_cfg['bt_min_ratio_allow_dl_tor'];

            if ($min_ratio && $user_id != $poster_id && ($user_ratio = get_bt_ratio($bt_userdata)) !== null)
            {
                    if ($user_ratio < $min_ratio && $post_id)
                    {
                            $dl = DB()->fetch_row("
                                    SELECT dl.user_status
                                    FROM ". BB_POSTS ." p
                                    LEFT JOIN ". BB_BT_DLSTATUS ." dl ON dl.topic_id = p.topic_id AND dl.user_id = $user_id
                                    WHERE p.post_id = $post_id
                                    LIMIT 1
                            ");

                            if (!isset($dl['user_status']) || $dl['user_status'] != DL_STATUS_COMPLETE)
                            {
                                    $mess = sprintf($lang['BT_LOW_RATIO_FOR_DL'], round($user_ratio, 2), "search.php?dlu=$user_id&amp;dlc=1");
                                    bb_die($mess);
                            }
                    }
            }

            // Announce URL
            $ann_url = $bb_cfg['bt_announce_url'];

            if (!$tor = bdecode_file($filename))
            {
                    bb_die('This is not a bencoded file');
            }

            $announce = strval($ann_url . "?$passkey_key=$passkey_val");

            // Replace original announce url with tracker default
            if ($bb_cfg['bt_replace_ann_url'] || !@$tor['announce'])
            {
                    $tor['announce'] = $announce;
            }
           
            // Delete all additional urls
            if ($bb_cfg['bt_del_addit_ann_urls'] || $bb_cfg['bt_disable_dht'])
            {
                    unset($tor['announce-list']);
            }
            elseif (@$tor['announce-list'])
            {
                    $tor['announce-list'] = array_merge($tor['announce-list'], array(array($announce)));
            }

            // Add publisher & topic url
            $publisher_name = $bb_cfg['server_name'];
            $publisher_url  = make_url(TOPIC_URL . $topic_id);

            $tor['publisher'] = strval($publisher_name);
            unset($tor['publisher.utf-8']);

            $tor['publisher-url'] = strval($publisher_url);
            unset($tor['publisher-url.utf-8']);

            $tor['comment'] = strval($publisher_url);
            unset($tor['comment.utf-8']);

            // Send torrent
            $output   = bencode($tor);
            $filename = clean_filename(basename($attachment['real_filename']));
            $mimetype = 'application/x-bittorrent;';
            $charset  = (strpos(USER_AGENT, 'pera') && @$lang['CONTENT_ENCODING']) ? "charset={$lang['CONTENT_ENCODING']};" : '';

        return $output;
    }


    #
    ##---[OPEN]----------
    #
    library/language/en/main.php

    #
    ##---[В конец файла]----------
    #
    // TT
    $lang['TTUBE_FUNCTION'] = "Online viewing function";
    $lang['TTUBE_ENABLE'] = "Enabled";
    $lang['TTUBE_DISABLE'] = "Disabled";
    $lang['TTUBE_ZONE'] = "Number pad";
    $lang['TTUBE_API'] = "The key to the API TorrentStream";
    $lang['TTUBE_OPEN_TYPE'] = "Type of opening";
    $lang['TTUBE_WIDTH'] = 'The width of the Player';
    $lang['TTUBE_HEIGHT'] = 'The height of the Player'';
    $lang['TT_ONLINE_VIEW'] = 'Watch';
    #
    ##---[OPEN]----------
    #
    library/language/ru/main.php

    #
    ##---[В конец файла]----------
    #
    // TT
    $lang['TTUBE_FUNCTION'] = "Функция Онлайн просмотра";
    $lang['TTUBE_ENABLE'] = "Включено";
    $lang['TTUBE_DISABLE'] = "Отключено";
    $lang['TTUBE_ZONE'] = "Номер площадки";
    $lang['TTUBE_API'] = "Ключ к API TorrentStream";
    $lang['TTUBE_OPEN_TYPE'] = "Тип открывания";
    $lang['TTUBE_WIDTH'] = 'Ширина Плеера';
    $lang['TTUBE_HEIGHT'] = 'Высота Плеера';
    $lang['TT_ONLINE_VIEW'] = 'Смотреть онлайн';
    #
    ##---[OPEN]----------
    #
    library/language/uk/main.php

    #
    ##---[В конец файла]----------
    #
    // TT
    $lang['TTUBE_FUNCTION'] = "Функція Онлайн перегляду";
    $lang['TTUBE_ENABLE'] = "Включено";
    $lang['TTUBE_DISABLE'] = "Відключено";
    $lang['TTUBE_ZONE'] = "Номер майданчика";
    $lang['TTUBE_API'] = "Ключ к API TorrentStream";
    $lang['TTUBE_OPEN_TYPE'] = "Тип відкривання";
    $lang['TTUBE_WIDTH'] = 'Ширина Плеєра';
    $lang['TTUBE_HEIGHT'] = 'Висота Плеєра';
    $lang['TT_ONLINE_VIEW'] = 'Дивитися онлайн';
    #
    ##---[OPEN]----------
    #
    viewtopic.php    Modified

    #
    ##---[FIND]----------
    #
        'U_SEARCH_SELF'       => "search.php?uid={$userdata['user_id']}&t=$topic_id&dm=1",
       
    #
    ##---[AFTER ADD]----------
    #

        'FORUM_PLAY'          => (!$bb_cfg['tt_api'] || !$bb_cfg['tt_zone']) ? false : ($forum_topic_data['tt_view'] ? true : false),
        'TS_WIDTH'            => ($bb_cfg['tt_width'])?$bb_cfg['tt_width']:650,
        'TS_HEIGHT'           => ($bb_cfg['tt_height'])?$bb_cfg['tt_height']:352,
        'TS_WIDTH_P'          => ($bb_cfg['tt_width'])?$bb_cfg['tt_width']+20:670,
        'TS_HEIGHT_P'         => ($bb_cfg['tt_height'])?$bb_cfg['tt_height']+20:372,
        'TS_TOPIC_TITLE'      => str_replace("\"", "'", wbr($topic_title)),
        'TS_POPUP'              => ($bb_cfg['tt_type'] == 1)?true:false,
        'TS_BLANK'              => ($bb_cfg['tt_type'] == 2)?true:false,
        'TS_FRAME'              => ($bb_cfg['tt_type'] == 3)?true:false,

    #
    ##---[OPEN]----------
    #
    admin/admin_board.php    Modified


    #
    ##---[FIND]----------
    #
        'NEW_TPLS'     => $new['new_tpls'],
       
    #
    ##---[ADD]----------
    #
        'TT_ZONE' => $new['tt_zone'],
        'TT_API' => $new['tt_api'],
        'TT_POPUP' => ($new['tt_type'] == 1) ? 'selected="selected"' : '',
        'TT_BLANK' => ($new['tt_type'] == 2) ? 'selected="selected"' : '',
        'TT_FRAME' => ($new['tt_type'] == 3) ? 'selected="selected"' : '',
        'TT_WIDTH' => $new['tt_width'],
        'TT_HEIGHT' => $new['tt_height'],
       
    #
    ##---[OPEN]----------
    #
    admin/admin_forums.php

    #
    ##---[FIND]----------
    #
                    $prune_enabled = ($row['prune_days']) ? HTML_CHECKED : '';
                    $prune_days = $row['prune_days'];
                   
    #
    ##---[AFTER ADD]----------
    #
                   
                    $tt_view = $row['tt_view'];
                   
    #
    ##---[FIND]----------
    #
                    $prune_enabled = '';
                    $prune_days = 0;
                   
    #
    ##---[AFTER ADD]----------
    #
                   
                    $tt_view = 0;
                   
    #
    ##---[FIND]----------
    #
                    'DESCRIPTION' => htmlCHR($forumdesc),
                   
    #
    ##---[AFTER ADD]----------
    #
               
                    'TT_VIEW' => $tt_view,
                   
    #
    ##---[FIND]----------
    #
                $forum_display_order = intval($_POST['forum_display_order']);
               
    #
    ##---[AFTER ADD]----------
    #
                $tt_view = (int) $_POST['tt_view'];
               
    #
    ##---[FIND]----------
    #
                $columns = ' forum_name,   cat_id,   forum_desc,   forum_order,  forum_status,  prune_days,  forum_parent,  show_on_index,  forum_display_sort,  forum_display_order'. $field_sql;
                $values = "'$forum_name', $cat_id, '$forum_desc', $forum_order, $forum_status, $prune_days, $forum_parent, $show_on_index, $forum_display_sort, $forum_display_order". $value_sql;
               
    #
    ##---[REPLACE]----------
    #
                $columns = ' forum_name,   cat_id,   forum_desc,   forum_order,  forum_status,  prune_days,  forum_parent,  show_on_index,  forum_display_sort,  forum_display_order, tt_view'. $field_sql;
                $values = "'$forum_name', $cat_id, '$forum_desc', $forum_order, $forum_status, $prune_days, $forum_parent, $show_on_index, $forum_display_sort, $forum_display_order, $tt_view". $value_sql;
               
    #
    ##---[FIND]----------
    #
                $old_cat_id = $forum_data['cat_id'];
                $forum_order = $forum_data['forum_order'];

    #
    ##---[AFTER ADD]----------
    #
               
                $tt_view = (int) $_POST['tt_view'];
               
    #
    ##---[FIND]----------
    #
                        forum_display_sort  = $forum_display_sort
                       
    #
    ##---[REPLACE]----------
    #
                        forum_display_sort  = $forum_display_sort,
                        tt_view = $tt_view

    #
    ##---[OPEN]----------
    #

    admin/admin_bt_forum_cfg.php

    #
    ##---[FIND]----------
    #

    'allow_porno_topic'            => 0,  // Allowed forums for porno topics

    #
    ##---[AFTER ADD]----------
    #

    'tt_view'                      => 0,  // online video

    #
    ##---[OPEN]----------
    #

    admin_bt_forum_cfg.tpl

    #
    ##---[FIND]----------
    #

    <th colspan="3">{L_BT_SELECT_FORUMS}</th>

    #
    ##---[REPLACE]----------
    #

    <th colspan="4">{L_BT_SELECT_FORUMS}</th>

    #
    ##---[FIND]----------
    #

    <td>{L_ALLOW_PORNO_TOPIC}</td>

    #
    ##---[AFTER ADD]----------
    #

    <td>Online Video</td>

    #
    ##---[FIND]----------
    #

    <td>{S_ALLOW_PORNO_TOPIC}</td>

    #
    ##---[AFTER ADD]----------
    #

    <td>{S_TT_VIEW}</td>

    #
    ##---[FIND]----------
    #

    <td colspan="3" class="small">{L_BT_SELECT_FORUMS_EXPL}</td>

    #
    ##---[REPLACE]----------
    #

    <td colspan="4" class="small">{L_BT_SELECT_FORUMS_EXPL}</td>

    #
    ##---[EoM]----------
    #

Последние обнoвления

  1. Обновление 1.1.0