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 = '