From 17c95ac01c5e66a453b07dfd52500fb344354763 Mon Sep 17 00:00:00 2001 From: Exile Date: Wed, 27 Jan 2016 04:38:06 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B4=D0=BE=D0=BB=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D0=B8=D0=BD=D1=85=D1=80=D0=BE?= =?UTF-8?q?=D0=BD=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8,=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B2=D1=8B=D1=88=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=82=D1=80=D0=B5?= =?UTF-8?q?=D0=B1=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B9=20=D0=B4=D0=BE=20php?= =?UTF-8?q?=205.5=20=D0=95=D1=89=D0=B5=20=D0=BF=D0=B0=D1=87=D0=BA=D0=B0=20?= =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2=20=D0=B8=D0=B7=20=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D1=80=D0=BE=D0=B3=D0=BE=20=D1=80=D0=B5=D0=BF=D0=BE?= =?UTF-8?q?=D0=B7=D0=B8=D1=82=D0=BE=D1=80=D0=B8=D1=8F=20=D0=9F=D0=BE=D0=B2?= =?UTF-8?q?=D1=8B=D1=88=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=82=D1=80=D0=B5=D0=B1?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B9=20=D0=BA=20php=20(=D0=B8?= =?UTF-8?q?=D0=B7-=D0=B7=D0=B0=20ZF)=20=D0=9F=D1=80=D0=BE=D0=B4=D0=BE?= =?UTF-8?q?=D0=BB=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=87=D0=B8=D1=81=D1=82?= =?UTF-8?q?=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/config.php | 14 +- library/includes/functions.php | 30 +-- library/includes/functions_torrent.php | 72 ++----- library/includes/functions_upload.php | 5 +- library/includes/init_bb.php | 50 ++--- library/includes/old_attachment.php | 283 ------------------------- library/includes/sessions.php | 1 + library/includes/viewtopic_torrent.php | 134 +++--------- 8 files changed, 73 insertions(+), 516 deletions(-) delete mode 100644 library/includes/old_attachment.php diff --git a/library/config.php b/library/config.php index 2265c8d66..dd3c36579 100644 --- a/library/config.php +++ b/library/config.php @@ -200,8 +200,6 @@ $tr_cfg = array( $bb_cfg['show_dl_status_in_search'] = true; $bb_cfg['show_dl_status_in_forum'] = true; - -$bb_cfg['show_tor_info_in_dl_list'] = true; $bb_cfg['allow_dl_list_names_mode'] = true; $bb_cfg['torrent_name_style'] = true; // use torrent name style [yoursite.com].txxx.torrent @@ -542,14 +540,6 @@ $bb_cfg['allow_change'] = array( define('GZIP_OUTPUT_ALLOWED', (extension_loaded('zlib') && !ini_get('zlib.output_compression'))); -$banned_user_agents = array( -// Download Master -# 'download', -# 'master', -// Others -# 'wget', -); - $bb_cfg['trash_forum_id'] = 0; // (int) 7 $bb_cfg['first_logon_redirect_url'] = 'index.php'; @@ -578,8 +568,8 @@ $bb_cfg['attach'] = array( 'max_size' => 5*1024*1024, // максимальный размер файла в байтах ); -$bb_cfg['tor_forums_allowed_ext'] = array('torrent', 'zip', 'rar'); // для разделов с раздачами -$bb_cfg['gen_forums_allowed_ext'] = array('zip', 'rar'); // для обычных разделов +$bb_cfg['tor_forums_allowed_ext'] = ['torrent', 'zip', 'rar']; // для разделов с раздачами +$bb_cfg['gen_forums_allowed_ext'] = ['torrent', 'zip', 'rar']; // для обычных разделов // Avatars $bb_cfg['avatars'] = array( diff --git a/library/includes/functions.php b/library/includes/functions.php index 15737f7cc..4063aba03 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -1209,23 +1209,6 @@ function show_bt_userdata ($user_id) )); } -function get_attachments_dir ($cfg = null) -{ - if (!$cfg AND !$cfg = $GLOBALS['attach_config']) - { - $cfg = bb_get_config(BB_ATTACH_CONFIG, true, false); - } - - if ($cfg['upload_dir'][0] == '/' || ($cfg['upload_dir'][0] != '/' && $cfg['upload_dir'][1] == ':')) - { - return $cfg['upload_dir']; - } - else - { - return BB_ROOT . $cfg['upload_dir']; - } -} - function bb_get_config ($table, $from_db = false, $update_cache = true) { if ($from_db OR !$cfg = CACHE('bb_config')->get("config_{$table}")) @@ -1927,7 +1910,7 @@ function cat_exists ($cat_id) // class log_action { - var $log_type = array( + var $log_type = [ # LOG_TYPE_NAME LOG_TYPE_ID 'mod_topic_delete' => 1, 'mod_topic_move' => 2, @@ -1938,8 +1921,15 @@ class log_action 'adm_user_delete' => 7, 'adm_user_ban' => 8, 'adm_user_unban' => 9, - ); - var $log_type_select = array(); + 'tor_status_changed' => 10, + 'att_delete' => 11, + 'tor_unreg' => 12, + 'tor_cphold_close' => 13, + 'adm_ban_ip' => 14, + 'adm_ban_email' => 15, + 'adm_ban_name' => 16, + ]; + var $log_type_select = []; var $log_disabled = false; function init () diff --git a/library/includes/functions_torrent.php b/library/includes/functions_torrent.php index 0e4c09fd5..4817ec441 100644 --- a/library/includes/functions_torrent.php +++ b/library/includes/functions_torrent.php @@ -2,74 +2,32 @@ if (!defined('BB_ROOT')) die(basename(__FILE__)); -function get_torrent_info ($attach_id) -{ - global $lang; - - $attach_id = intval($attach_id); - - $sql = " - SELECT - a.post_id, d.physical_filename, d.extension, d.tracker_status, - t.topic_first_post_id, - p.poster_id, p.topic_id, p.forum_id, - f.allow_reg_tracker - FROM - ". BB_ATTACHMENTS ." a, - ". BB_ATTACHMENTS_DESC ." d, - ". BB_POSTS ." p, - ". BB_TOPICS ." t, - ". BB_FORUMS ." f - WHERE - a.attach_id = $attach_id - AND d.attach_id = $attach_id - AND p.post_id = a.post_id - AND t.topic_id = p.topic_id - AND f.forum_id = p.forum_id - LIMIT 1 - "; - - if (!$torrent = DB()->fetch_row($sql)) - { - bb_die($lang['INVALID_ATTACH_ID']); - } - - return $torrent; -} - function torrent_auth_check ($forum_id, $poster_id) { - global $userdata, $lang, $attach_config; + global $lang, $userdata; - if (IS_ADMIN) return true; - - $is_auth = auth(AUTH_ALL, $forum_id, $userdata); - - if ($poster_id != $userdata['user_id'] && !$is_auth['auth_mod']) + if (IS_ADMIN || IS_CP_HOLDER || $poster_id == $userdata['user_id']) { - bb_die($lang['NOT_MODERATOR']); + return true; } - else if (!$is_auth['auth_view'] || !$is_auth['auth_attachments'] || $attach_config['disable_mod']) + + if (IS_MOD) { - bb_die(sprintf($lang['SORRY_AUTH_READ'], $is_auth['auth_read_type'])); + $is_auth = auth(AUTH_MOD, $forum_id, $userdata); + if ($is_auth['auth_mod']) return true; } - return $is_auth; + + bb_die($lang['NOT_MODERATOR']); } -function tracker_unregister ($attach_id, $mode = '') +function tracker_unregister ($topic_id, $redirect_url = '') { - global $lang, $bb_cfg; + global $bb_cfg, $lang, $log_action; - $attach_id = (int) $attach_id; - $post_id = $topic_id = $forum_id = $info_hash = null; - - // Get torrent info - if ($torrent = get_torrent_info($attach_id)) - { - $post_id = $torrent['post_id']; - $topic_id = $torrent['topic_id']; - $forum_id = $torrent['forum_id']; - } + $tor = DB()->fetch_row(" + SELECT forum_id, tor_status FROM ". BB_BT_TORRENTS ." WHERE topic_id = ". intval($topic_id) ." LIMIT 1 + "); + $tor_status = isset($tor['tor_status']) ? $tor['tor_status'] : null; if ($mode == 'request') { diff --git a/library/includes/functions_upload.php b/library/includes/functions_upload.php index 7075ff1cc..9faa6eca2 100644 --- a/library/includes/functions_upload.php +++ b/library/includes/functions_upload.php @@ -120,13 +120,14 @@ class upload_common { if ($mode == 'avatar') { - delete_avatar($params['user_id'], $params['avatar_ext_id']); + delete_avatar($params['user_id'], $this->file_ext_id); $file_path = get_avatar_path($params['user_id'], $this->file_ext_id); return $this->_move($file_path); } else if ($mode == 'attach') { - $file_path = get_attach_path($params['topic_id'], $params['attach_ext_id']); + delete_attach($params['topic_id'], $this->file_ext_id); + $file_path = get_attach_path($params['topic_id'], $this->file_ext_id); return $this->_move($file_path); } else diff --git a/library/includes/init_bb.php b/library/includes/init_bb.php index 439211d07..edcac4220 100644 --- a/library/includes/init_bb.php +++ b/library/includes/init_bb.php @@ -1,13 +1,14 @@ 'genmed', + DL_STATUS_WILL => 'dlWill', + DL_STATUS_DOWN => 'leechmed', + DL_STATUS_COMPLETE => 'seedmed', + DL_STATUS_CANCEL => 'dlCancel', +]; + +$dl_status_css = [ + DL_STATUS_RELEASER => 'genmed', + DL_STATUS_WILL => 'dlWill', + DL_STATUS_DOWN => 'dlDown', + DL_STATUS_COMPLETE => 'dlComplete', + DL_STATUS_CANCEL => 'dlCancel', +]; // Functions function send_no_cache_headers () @@ -449,22 +451,6 @@ if ((empty($_POST) && !defined('IN_ADMIN') && !defined('IN_AJAX') && !file_exist } } -$dl_link_css = array( - DL_STATUS_RELEASER => 'genmed', - DL_STATUS_WILL => 'dlWill', - DL_STATUS_DOWN => 'leechmed', - DL_STATUS_COMPLETE => 'seedmed', - DL_STATUS_CANCEL => 'dlCancel', -); - -$dl_status_css = array( - DL_STATUS_RELEASER => 'genmed', - DL_STATUS_WILL => 'dlWill', - DL_STATUS_DOWN => 'dlDown', - DL_STATUS_COMPLETE => 'dlComplete', - DL_STATUS_CANCEL => 'dlCancel', -); - // Exit if board is disabled via ON/OFF trigger or by admin if (($bb_cfg['board_disable'] || file_exists(BB_DISABLED)) && !defined('IN_ADMIN') && !defined('IN_AJAX') && !defined('IN_LOGIN')) { diff --git a/library/includes/old_attachment.php b/library/includes/old_attachment.php deleted file mode 100644 index f039e9d28..000000000 --- a/library/includes/old_attachment.php +++ /dev/null @@ -1,283 +0,0 @@ -sql_query($sql))) - { - bb_die('Could not get attachment informations for post number ' . $post_id_array); - } - - $num_rows = DB()->num_rows($result); - $attachments = DB()->sql_fetchrowset($result); - DB()->sql_freeresult($result); - - if ($num_rows == 0) - { - return array(); - } - - return $attachments; -} - - -/** -* Get attachment mod configuration -*/ -function get_config() -{ - global $bb_cfg; - - $attach_config = array(); - - $sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG; - - if (!($result = DB()->sql_query($sql))) - { - bb_die('Could not query attachment information'); - } - - while ($row = DB()->sql_fetchrow($result)) - { - $attach_config[$row['config_name']] = trim($row['config_value']); - } - - // We assign the original default board language here, because it gets overwritten later with the users default language - $attach_config['board_lang'] = trim($bb_cfg['default_lang']); - - return $attach_config; -} - -// Get Attachment Config -$attach_config = array(); - -if (!$attach_config = CACHE('bb_cache')->get('attach_config')) -{ - $attach_config = get_config(); - CACHE('bb_cache')->set('attach_config', $attach_config, 86400); -} - -/** - * Writing Data into plain Template Vars - * - * @param $template_var - * @param $replacement - * @param string $filename - */ -function init_display_template($template_var, $replacement, $filename = 'viewtopic_attach.tpl') -{ - global $template; - - // This function is adapted from the old template class - // I wish i had the functions from the 3.x one. :D (This class rocks, can't await to use it in Mods) - - // Handle Attachment Informations - if (!isset($template->uncompiled_code[$template_var]) && empty($template->uncompiled_code[$template_var])) - { - // If we don't have a file assigned to this handle, die. - if (!isset($template->files[$template_var])) - { - die("Template->loadfile(): No file specified for handle $template_var"); - } - - $filename_2 = $template->files[$template_var]; - - $str = implode('', @file($filename_2)); - if (empty($str)) - { - die("Template->loadfile(): File $filename_2 for handle $template_var is empty"); - } - - $template->uncompiled_code[$template_var] = $str; - } - - $complete_filename = $filename; - if (substr($complete_filename, 0, 1) != '/') - { - $complete_filename = $template->root . '/' . $complete_filename; - } - - if (!file_exists($complete_filename)) - { - die("Template->make_filename(): Error - file $complete_filename does not exist"); - } - - $content = implode('', file($complete_filename)); - if (empty($content)) - { - die('Template->loadfile(): File ' . $complete_filename . ' is empty'); - } - - // replace $replacement with uncompiled code in $filename - $template->uncompiled_code[$template_var] = str_replace($replacement, $content, $template->uncompiled_code[$template_var]); -} - -/** - * Display Attachments in Posts - * - * @param $post_id - * @param $switch_attachment - */ -function display_post_attachments($post_id, $switch_attachment) -{ - global $attach_config, $is_auth; - - if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod'])) - { - return; - } - - if ($is_auth['auth_download'] && $is_auth['auth_view']) - { - display_attachments($post_id); - } -} - -/** - * Initializes some templating variables for displaying Attachments in Posts - * - * @param $switch_attachment - */ -function init_display_post_attachments($switch_attachment) -{ - global $attach_config, $is_auth, $template, $lang, $postrow, $total_posts, $attachments, $forum_row, $t_data; - - if (empty($t_data) && !empty($forum_row)) - { - $switch_attachment = $forum_row['topic_attachment']; - } - - if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']) || (!($is_auth['auth_download'] && $is_auth['auth_view']))) - { - init_display_template('body', '{postrow.ATTACHMENTS}', 'viewtopic_attach_guest.tpl'); - return; - } - - $post_id_array = array(); - - for ($i = 0; $i < $total_posts; $i++) - { - if ($postrow[$i]['post_attachment'] == 1) - { - $post_id_array[] = (int) $postrow[$i]['post_id']; - } - } - - if (sizeof($post_id_array) == 0) - { - return; - } - - $rows = get_attachments_from_post($post_id_array); - $num_rows = sizeof($rows); - - if ($num_rows == 0) - { - return; - } - - @reset($attachments); - - for ($i = 0; $i < $num_rows; $i++) - { - $attachments['_' . $rows[$i]['post_id']][] = $rows[$i]; - //bt - if ($rows[$i]['tracker_status']) - { - if (defined('TORRENT_POST')) - { - bb_die('Multiple registered torrents in one topic

first torrent found in post_id = '. TORRENT_POST .'
current post_id = '. $rows[$i]['post_id'] .'

attachments info:
'. print_r($rows, TRUE) .'
'); - } - define('TORRENT_POST', $rows[$i]['post_id']); - } - //bt end - } - - init_display_template('body', '{postrow.ATTACHMENTS}'); - -} - -function display_attachments($post_id) -{ - global $template, $upload_dir, $userdata, $allowed_extensions, $display_categories, $download_modes, $lang, $attachments, $upload_icons, $attach_config; - - $num_attachments = @sizeof($attachments['_' . $post_id]); - - if ($num_attachments == 0) - { - return; - } - - $template->assign_block_vars('postrow.attach', array()); - - for ($i = 0; $i < $num_attachments; $i++) - { - $upload_image = ''; - - if ($attach_config['upload_img'] && empty($upload_icons[$attachments['_' . $post_id][$i]['extension']])) - { - $upload_image = ''; - } - else if (trim($upload_icons[$attachments['_' . $post_id][$i]['extension']]) != '') - { - $upload_image = ''; - } - - $filesize = humn_size($attachments['_' . $post_id][$i]['filesize']); - - $display_name = htmlspecialchars($attachments['_' . $post_id][$i]['real_filename']); - $comment = htmlspecialchars($attachments['_' . $post_id][$i]['comment']); - $comment = str_replace("\n", '
', $comment); - - $denied = false; - - if (!$denied || IS_ADMIN) - { - $target_blank = ( (@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT) ) ? 'target="_blank"' : ''; - - // display attachment - $template->assign_block_vars('postrow.attach.attachrow', array( - 'U_DOWNLOAD_LINK' => BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'], - 'S_UPLOAD_IMAGE' => $upload_image, - 'DOWNLOAD_NAME' => $display_name, - 'FILESIZE' => $filesize, - 'COMMENT' => $comment, - 'TARGET_BLANK' => $target_blank, - 'DOWNLOAD_COUNT' => sprintf($lang['DOWNLOAD_NUMBER'], $attachments['_' . $post_id][$i]['download_count']), - )); - } - } -} - -$upload_dir = $attach_config['upload_dir']; \ No newline at end of file diff --git a/library/includes/sessions.php b/library/includes/sessions.php index 8bfb254cd..10fb5643b 100644 --- a/library/includes/sessions.php +++ b/library/includes/sessions.php @@ -192,6 +192,7 @@ class user_common define('IS_GUEST', (!$this->data['session_logged_in'])); define('IS_ADMIN', (!IS_GUEST && $this->data['user_level'] == ADMIN)); define('IS_MOD', (!IS_GUEST && $this->data['user_level'] == MOD)); + define('IS_CP_HOLDER', (!IS_GUEST && $this->data['user_level'] == CP_HOLDER)); define('IS_GROUP_MEMBER', (!IS_GUEST && $this->data['user_level'] == GROUP_MEMBER)); define('IS_USER', (!IS_GUEST && $this->data['user_level'] == USER)); define('IS_SUPER_ADMIN', (IS_ADMIN && isset($bb_cfg['super_admins'][$this->data['user_id']]))); diff --git a/library/includes/viewtopic_torrent.php b/library/includes/viewtopic_torrent.php index 061a474cb..4b4395a6b 100644 --- a/library/includes/viewtopic_torrent.php +++ b/library/includes/viewtopic_torrent.php @@ -2,142 +2,56 @@ if (!defined('BB_ROOT')) die(basename(__FILE__)); -global $bb_cfg, $t_data, $poster_id, $is_auth, $dl_link_css, $dl_status_css, $lang, $images; - -$change_peers_bgr_over = true; -$bgr_class_1 = 'row1'; -$bgr_class_2 = 'row2'; -$bgr_class_over = 'row3'; +global $bb_cfg, $t_data, $poster_id, $is_auth, $dl_link_css, $dl_status_css, $lang, $userdata; $show_peers_limit = 300; $max_peers_before_overflow = 20; -$peers_overflow_div_height = '400px'; $peers_div_style_normal = 'padding: 3px;'; -$peers_div_style_overflow = "padding: 6px; height: $peers_overflow_div_height; overflow: auto; border: 1px inset;"; -$s_last_seed_date_format = 'Y-m-d'; -$upload_image = ''. $lang['DL_TORRENT'] .''; +$peers_div_style_overflow = "padding: 6px; height: 400px; overflow: auto; border: 1px inset;"; -$peers_cnt = $seed_count = 0; +$peers_cnt = $seed_count = $leech_count = 0; $seeders = $leechers = ''; -$tor_info = array(); +$tor_info = []; -$template->assign_vars(array( - 'SEED_COUNT' => false, +$template->assign_vars([ + 'DL_BUTTONS' => true, 'LEECH_COUNT' => false, - 'TOR_SPEED_UP' => false, - 'TOR_SPEED_DOWN' => false, + 'SEED_COUNT' => false, + 'SHOW_CPHOLD_OPT' => (IS_ADMIN || IS_CP_HOLDER), 'SHOW_RATIO_WARN' => false, -)); + 'TOR_CONTROLS' => false, + 'TOR_SPEED_DOWN' => false, + 'TOR_SPEED_UP' => false, +]); +$page_cfg['show_tor_status_select'] = ($is_auth['auth_mod'] || IS_CP_HOLDER); -// Define show peers mode (count only || user names with complete % || full details) -$cfg_sp_mode = $bb_cfg['bt_show_peers_mode']; -$get_sp_mode = (isset($_GET['spmode'])) ? $_GET['spmode'] : ''; +// Define show peers mode (count only || full details) +$s_mode = (isset($_GET['spmode']) && $_GET['spmode'] == 'full') ? 'full' : 'count'; -$s_mode = 'count'; - -if ($cfg_sp_mode == SHOW_PEERS_NAMES) -{ - $s_mode = 'names'; -} -else if ($cfg_sp_mode == SHOW_PEERS_FULL) -{ - $s_mode = 'full'; -} - -if ($bb_cfg['bt_allow_spmode_change']) -{ - if ($get_sp_mode == 'names') - { - $s_mode = 'names'; - } - else if ($get_sp_mode == 'full') - { - $s_mode = 'full'; - } -} - -$bt_topic_id = $t_data['topic_id']; -$bt_user_id = $userdata['user_id']; -$attach_id = $attachments['_'. $post_id][$i]['attach_id']; -$tracker_status = $attachments['_'. $post_id][$i]['tracker_status']; -$download_count = $attachments['_'. $post_id][$i]['download_count']; -$tor_file_size = humn_size($attachments['_'. $post_id][$i]['filesize']); -$tor_file_time = bb_date($attachments['_'. $post_id][$i]['filetime']); - -$tor_reged = (bool) $tracker_status; -$show_peers = (bool) $bb_cfg['bt_show_peers']; +$tor_file_size = humn_size($t_data['filesize']); +$tor_reged = (bool) $t_data['tracker_status']; $locked = ($t_data['forum_status'] == FORUM_LOCKED || $t_data['topic_status'] == TOPIC_LOCKED); $tor_auth = ($bt_user_id != GUEST_UID && (($bt_user_id == $poster_id && !$locked) || $is_auth['auth_mod'])); -$tor_auth_reg = ($tor_auth && $t_data['allow_reg_tracker'] && $post_id == $t_data['topic_first_post_id']); -$tor_auth_del = ($tor_auth && $tor_reged); - -$tracker_link = ($tor_reged) ? $lang['BT_REG_YES'] : $lang['BT_REG_NO']; - -$download_link = DOWNLOAD_URL . $attach_id; -$description = ($comment) ? $comment : preg_replace("#.torrent$#i", '', $display_name); - -if ($tor_auth_reg || $tor_auth_del) +if ($tor_auth && $t_data['allow_reg_tracker'] && !$tor_reged && !IS_CP_HOLDER /* && $post_id == $t_data['topic_first_post_id']*/) { - $reg_tor_url = ''. $lang['BT_REG_ON_TRACKER'] .''; - $unreg_tor_url = ''. $lang['BT_UNREG_FROM_TRACKER'] .''; - - $tracker_link = ($tor_reged) ? $unreg_tor_url : $reg_tor_url; + $tr_reg_link = ''. $lang['BT_REG_ON_TRACKER'] .''; } - -if ($bb_cfg['torrent_name_style']) +else if ($is_auth['auth_mod'] && $tor_reged && !IS_CP_HOLDER) { - $display_name = '['.$bb_cfg['server_name'].'].t' . $bt_topic_id . '.torrent'; -} - -if (!$tor_reged) -{ - $template->assign_block_vars('postrow.attach.tor_not_reged', array( - 'DOWNLOAD_NAME' => $display_name, - 'TRACKER_LINK' => $tracker_link, - 'ATTACH_ID' => $attach_id, - - 'S_UPLOAD_IMAGE' => $upload_image, - 'U_DOWNLOAD_LINK' => $download_link, - 'FILESIZE' => $tor_file_size, - - 'DOWNLOAD_COUNT' => sprintf($lang['DOWNLOAD_NUMBER'], $download_count), - 'POSTED_TIME' => $tor_file_time, - )); - - if ($comment) - { - $template->assign_block_vars('postrow.attach.tor_not_reged.comment', array('COMMENT' => $comment)); - } + $tr_reg_link = ''. $lang['BT_UNREG_FROM_TRACKER'] .''; } else { - $sql = "SELECT bt.*, u.user_id, u.username, u.user_rank - FROM ". BB_BT_TORRENTS ." bt - LEFT JOIN ". BB_USERS ." u ON(bt.checked_user_id = u.user_id) - WHERE bt.attach_id = $attach_id"; - - if (!$result = DB()->sql_query($sql)) - { - bb_die('Could not obtain torrent information'); - } - $tor_info = DB()->sql_fetchrow($result); - DB()->sql_freeresult($result); -} - -if ($tor_reged && !$tor_info) -{ - DB()->query("UPDATE ". BB_ATTACHMENTS_DESC ." SET tracker_status = 0 WHERE attach_id = $attach_id"); - - bb_die('Torrent status fixed'); + $tr_reg_link = ($tor_reged) ? $lang['BT_REG_YES'] : $lang['BT_REG_NO']; } if ($tor_auth) { $template->assign_vars(array( - 'TOR_CONTROLS' => true, - 'TOR_ATTACH_ID' => $attach_id, + 'TOR_CONTROLS' => ($is_auth['auth_mod'] || IS_CP_HOLDER), + 'TOR_ACTION' => 'torrent.php', )); if ($t_data['self_moderated'] || $is_auth['auth_mod'])