" . $lang['TOR_NOT_FOUND']);
} else {
$gotit = true;
@@ -146,7 +143,7 @@ $datastore->rm('cat_forums');
//
// Get Information on currently allowed Extensions
//
-$rows = get_extension_informations();
+$rows = get_extension_informations(); //todo
$num_rows = count($rows);
for ($i = 0; $i < $num_rows; $i++) {
diff --git a/install/sql/mysql.sql b/install/sql/mysql.sql
index 463d793a8..a7904652c 100644
--- a/install/sql/mysql.sql
+++ b/install/sql/mysql.sql
@@ -1,114 +1,5 @@
SET SQL_MODE = "";
--- ----------------------------
--- Table structure for `bb_attachments`
--- ----------------------------
-DROP TABLE IF EXISTS `bb_attachments`;
-CREATE TABLE IF NOT EXISTS `bb_attachments`
-(
- `attach_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
- `post_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
- `user_id_1` MEDIUMINT(8) NOT NULL DEFAULT '0',
- PRIMARY KEY (`attach_id`, `post_id`)
-)
- ENGINE = MyISAM
- DEFAULT CHARSET = utf8;
-
--- ----------------------------
--- Records of bb_attachments
--- ----------------------------
-
--- ----------------------------
--- Table structure for `bb_attachments_config`
--- ----------------------------
-DROP TABLE IF EXISTS `bb_attachments_config`;
-CREATE TABLE IF NOT EXISTS `bb_attachments_config`
-(
- `config_name` VARCHAR(255) NOT NULL DEFAULT '',
- `config_value` VARCHAR(255) NOT NULL DEFAULT '',
- PRIMARY KEY (`config_name`)
-)
- ENGINE = MyISAM
- DEFAULT CHARSET = utf8;
-
--- ----------------------------
--- Records of bb_attachments_config
--- ----------------------------
-INSERT INTO `bb_attachments_config`
-VALUES ('upload_dir', 'data/torrent_files'),
- ('upload_img', 'styles/images/icon_clip.gif'),
- ('topic_icon', 'styles/images/icon_clip.gif'),
- ('display_order', '0'),
- ('max_filesize', '262144'),
- ('attachment_quota', '52428800'),
- ('max_filesize_pm', '262144'),
- ('max_attachments', '1'),
- ('max_attachments_pm', '1'),
- ('disable_mod', '0'),
- ('allow_pm_attach', '1'),
- ('attach_version', '2.3.14'),
- ('default_upload_quota', '0'),
- ('default_pm_quota', '0'),
- ('img_display_inlined', '1'),
- ('img_max_width', '200'),
- ('img_max_height', '200'),
- ('img_link_width', '0'),
- ('img_link_height', '0'),
- ('img_create_thumbnail', '0'),
- ('img_min_thumb_filesize', '12000'),
- ('img_imagick', '/usr/bin/convert'),
- ('use_gd2', '1'),
- ('wma_autoplay', '0'),
- ('flash_autoplay', '0');
-
--- ----------------------------
--- Table structure for `bb_attachments_desc`
--- ----------------------------
-DROP TABLE IF EXISTS `bb_attachments_desc`;
-CREATE TABLE IF NOT EXISTS `bb_attachments_desc`
-(
- `attach_id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
- `physical_filename` VARCHAR(255) NOT NULL DEFAULT '',
- `real_filename` VARCHAR(255) NOT NULL DEFAULT '',
- `download_count` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
- `comment` VARCHAR(255) NOT NULL DEFAULT '',
- `extension` VARCHAR(100) NOT NULL DEFAULT '',
- `mimetype` VARCHAR(100) NOT NULL DEFAULT '',
- `filesize` INT(20) NOT NULL DEFAULT '0',
- `filetime` INT(11) NOT NULL DEFAULT '0',
- `thumbnail` TINYINT(1) NOT NULL DEFAULT '0',
- `tracker_status` TINYINT(1) NOT NULL DEFAULT '0',
- PRIMARY KEY (`attach_id`),
- KEY `filetime` (`filetime`),
- KEY `filesize` (`filesize`),
- KEY `physical_filename` (`physical_filename`(10))
-)
- ENGINE = MyISAM
- DEFAULT CHARSET = utf8;
-
--- ----------------------------
--- Records of bb_attachments_desc
--- ----------------------------
-
--- ----------------------------
--- Table structure for `bb_attach_quota`
--- ----------------------------
-DROP TABLE IF EXISTS `bb_attach_quota`;
-CREATE TABLE IF NOT EXISTS `bb_attach_quota`
-(
- `user_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
- `group_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
- `quota_type` SMALLINT(2) NOT NULL DEFAULT '0',
- `quota_limit_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
- KEY `quota_type` (`quota_type`)
-)
- ENGINE = MyISAM
- DEFAULT CHARSET = utf8;
-
--- ----------------------------
--- Records of bb_attach_quota
--- ----------------------------
-
-- ----------------------------
-- Table structure for `bb_auth_access`
-- ----------------------------
@@ -274,11 +165,9 @@ DROP TABLE IF EXISTS `bb_bt_torrents`;
CREATE TABLE IF NOT EXISTS `bb_bt_torrents`
(
`info_hash` VARBINARY(20) NOT NULL DEFAULT '',
- `post_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
`poster_id` MEDIUMINT(9) NOT NULL DEFAULT '0',
`topic_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
`forum_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0',
- `attach_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
`size` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
`reg_time` INT(11) NOT NULL DEFAULT '0',
`call_seed_time` INT(11) NOT NULL DEFAULT '0',
@@ -291,9 +180,7 @@ CREATE TABLE IF NOT EXISTS `bb_bt_torrents`
`speed_up` INT(11) NOT NULL DEFAULT '0',
`speed_down` INT(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`info_hash`),
- UNIQUE KEY `post_id` (`post_id`),
UNIQUE KEY `topic_id` (`topic_id`),
- UNIQUE KEY `attach_id` (`attach_id`),
KEY `reg_time` (`reg_time`),
KEY `forum_id` (`forum_id`),
KEY `poster_id` (`poster_id`)
@@ -332,7 +219,6 @@ CREATE TABLE IF NOT EXISTS `bb_bt_tor_dl_stat`
(
`topic_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
`user_id` MEDIUMINT(9) NOT NULL DEFAULT '0',
- `attach_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
`t_up_total` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
`t_down_total` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
`t_bonus_total` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
@@ -538,7 +424,6 @@ VALUES ('allow_autologin', '1'),
('default_dateformat', 'Y-m-d H:i'),
('default_lang', 'ru'),
('flood_interval', '15'),
- ('hot_threshold', '300'),
('login_reset_time', '30'),
('max_autologin_time', '10'),
('max_login_attempts', '5'),
@@ -614,9 +499,7 @@ CREATE TABLE IF NOT EXISTS `bb_cron`
INSERT INTO `bb_cron` (`cron_active`, `cron_title`, `cron_script`, `schedule`, `run_day`, `run_time`, `run_order`,
`last_run`, `next_run`, `run_interval`, `log_enabled`, `log_file`, `log_sql_queries`,
`disable_board`, `run_counter`)
-VALUES ('1', 'Attach maintenance', 'attach_maintenance.php', 'daily', '', '05:00:00', '40', '', '', '', '1', '', '0',
- '1', '0'),
- ('1', 'Board maintenance', 'board_maintenance.php', 'daily', '', '05:00:00', '40', '', '', '', '1', '', '0', '1',
+VALUES ('1', 'Board maintenance', 'board_maintenance.php', 'daily', '', '05:00:00', '40', '', '', '', '1', '', '0', '1',
'0'),
('1', 'Prune forums', 'prune_forums.php', 'daily', '', '05:00:00', '50', '', '', '', '1', '', '0', '1', '0'),
('1', 'Prune topic moved stubs', 'prune_topic_moved.php', 'daily', '', '05:00:00', '60', '', '', '', '1', '',
@@ -674,84 +557,6 @@ CREATE TABLE IF NOT EXISTS `bb_disallow`
-- Records of bb_disallow
-- ----------------------------
--- ----------------------------
--- Table structure for `bb_extensions`
--- ----------------------------
-DROP TABLE IF EXISTS `bb_extensions`;
-CREATE TABLE IF NOT EXISTS `bb_extensions`
-(
- `ext_id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
- `group_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
- `extension` VARCHAR(100) NOT NULL DEFAULT '',
- `comment` VARCHAR(100) NOT NULL DEFAULT '',
- PRIMARY KEY (`ext_id`)
-)
- ENGINE = MyISAM
- DEFAULT CHARSET = utf8;
-
--- ----------------------------
--- Records of bb_extensions
--- ----------------------------
-INSERT INTO `bb_extensions` (`group_id`, `extension`, `comment`)
-VALUES ('1', 'gif', ''),
- ('1', 'png', ''),
- ('1', 'jpeg', ''),
- ('1', 'jpg', ''),
- ('1', 'tif', ''),
- ('1', 'tga', ''),
- ('2', 'gtar', ''),
- ('2', 'gz', ''),
- ('2', 'tar', ''),
- ('2', 'zip', ''),
- ('2', 'rar', ''),
- ('2', 'ace', ''),
- ('3', 'txt', ''),
- ('3', 'c', ''),
- ('3', 'h', ''),
- ('3', 'cpp', ''),
- ('3', 'hpp', ''),
- ('3', 'diz', ''),
- ('4', 'xls', ''),
- ('4', 'doc', ''),
- ('4', 'dot', ''),
- ('4', 'pdf', ''),
- ('4', 'ai', ''),
- ('4', 'ps', ''),
- ('4', 'ppt', ''),
- ('5', 'rm', ''),
- ('6', 'torrent', '');
-
--- ----------------------------
--- Table structure for `bb_extension_groups`
--- ----------------------------
-DROP TABLE IF EXISTS `bb_extension_groups`;
-CREATE TABLE IF NOT EXISTS `bb_extension_groups`
-(
- `group_id` MEDIUMINT(8) NOT NULL AUTO_INCREMENT,
- `group_name` VARCHAR(20) NOT NULL DEFAULT '',
- `cat_id` TINYINT(2) NOT NULL DEFAULT '0',
- `allow_group` TINYINT(1) NOT NULL DEFAULT '0',
- `download_mode` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1',
- `upload_icon` VARCHAR(100) NOT NULL DEFAULT '',
- `max_filesize` INT(20) NOT NULL DEFAULT '0',
- `forum_permissions` TEXT NOT NULL,
- PRIMARY KEY (`group_id`)
-)
- ENGINE = MyISAM
- DEFAULT CHARSET = utf8;
-
--- ----------------------------
--- Records of bb_extension_groups
--- ----------------------------
-INSERT INTO `bb_extension_groups` (`group_name`, `cat_id`, `allow_group`, `download_mode`, `upload_icon`,
- `max_filesize`, `forum_permissions`)
-VALUES ('Images', '1', '1', '1', '', '262144', ''),
- ('Archives', '0', '1', '1', '', '262144', ''),
- ('Plain text', '0', '0', '1', '', '262144', ''),
- ('Documents', '0', '0', '1', '', '262144', ''),
- ('Real media', '0', '0', '2', '', '262144', ''),
- ('Torrent', '0', '1', '1', '', '122880', '');
-
-- ----------------------------
-- Table structure for `bb_forums`
-- ----------------------------
@@ -917,7 +722,6 @@ CREATE TABLE IF NOT EXISTS `bb_posts`
`post_username` VARCHAR(25) NOT NULL DEFAULT '',
`post_edit_time` INT(11) NOT NULL DEFAULT '0',
`post_edit_count` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0',
- `post_attachment` TINYINT(1) NOT NULL DEFAULT '0',
`user_post` TINYINT(1) NOT NULL DEFAULT '1',
`mc_comment` TEXT NOT NULL DEFAULT '',
`mc_type` TINYINT(1) NOT NULL DEFAULT '0',
@@ -935,7 +739,7 @@ CREATE TABLE IF NOT EXISTS `bb_posts`
-- Records of bb_posts
-- ----------------------------
INSERT INTO `bb_posts`
-VALUES ('1', '1', '1', '2', UNIX_TIMESTAMP(), '0', '0', '0', '', '0', '0', '0', '1', '', '0', '0');
+VALUES ('1', '1', '1', '2', UNIX_TIMESTAMP(), '0', '0', '0', '', '0', '0', '1', '', '0', '0');
-- ----------------------------
-- Table structure for `bb_posts_html`
@@ -1034,28 +838,6 @@ CREATE TABLE IF NOT EXISTS `bb_privmsgs_text`
-- Records of bb_privmsgs_text
-- ----------------------------
--- ----------------------------
--- Table structure for `bb_quota_limits`
--- ----------------------------
-DROP TABLE IF EXISTS `bb_quota_limits`;
-CREATE TABLE IF NOT EXISTS `bb_quota_limits`
-(
- `quota_limit_id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
- `quota_desc` VARCHAR(20) NOT NULL DEFAULT '',
- `quota_limit` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
- PRIMARY KEY (`quota_limit_id`)
-)
- ENGINE = MyISAM
- DEFAULT CHARSET = utf8;
-
--- ----------------------------
--- Records of bb_quota_limits
--- ----------------------------
-INSERT INTO `bb_quota_limits` (`quota_desc`, `quota_limit`)
-VALUES ('Low', '262144'),
- ('Medium', '10485760'),
- ('High', '15728640');
-
-- ----------------------------
-- Table structure for `bb_ranks`
-- ----------------------------
@@ -1246,8 +1028,10 @@ CREATE TABLE IF NOT EXISTS `bb_topics`
`topic_first_post_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
`topic_last_post_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
`topic_moved_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
- `topic_attachment` TINYINT(1) NOT NULL DEFAULT '0',
`topic_dl_type` TINYINT(1) NOT NULL DEFAULT '0',
+ `attach_ext_id` TINYINT(4) NOT NULL DEFAULT '0',
+ `attach_dl_cnt` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
+ `filesize` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
`topic_last_post_time` INT(11) NOT NULL DEFAULT '0',
`topic_show_first_post` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`topic_id`),
@@ -1265,27 +1049,7 @@ CREATE TABLE IF NOT EXISTS `bb_topics`
INSERT INTO `bb_topics`
VALUES ('1', '1', 'Добро пожаловать в TorrentPier Bison', '2', UNIX_TIMESTAMP(), '0', '0', '0', '0', '0', '1', '1', '0',
'0',
- '0', UNIX_TIMESTAMP(), '0');
-
--- ----------------------------
--- Table structure for `bb_topics_watch`
--- ----------------------------
-DROP TABLE IF EXISTS `bb_topics_watch`;
-CREATE TABLE IF NOT EXISTS `bb_topics_watch`
-(
- `topic_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
- `user_id` MEDIUMINT(8) NOT NULL DEFAULT '0',
- `notify_status` TINYINT(1) NOT NULL DEFAULT '0',
- KEY `topic_id` (`topic_id`),
- KEY `user_id` (`user_id`),
- KEY `notify_status` (`notify_status`)
-)
- ENGINE = MyISAM
- DEFAULT CHARSET = utf8;
-
--- ----------------------------
--- Records of bb_topics_watch
--- ----------------------------
+ '0', '0', '0', UNIX_TIMESTAMP(), '0');
-- ----------------------------
-- Table structure for `bb_topic_tpl`
diff --git a/install/upgrade/changes.txt b/install/upgrade/changes.txt
index a9c49b64a..56c4a0e0f 100644
--- a/install/upgrade/changes.txt
+++ b/install/upgrade/changes.txt
@@ -49,3 +49,25 @@ UPDATE `bb_smilies` SET `code` = ':cd:', `smile_url` = 'cd.gif', `emoticon` = 'c
ALTER TABLE `bb_search_results` CHANGE `search_id` `search_id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
ALTER TABLE `bb_users` CHANGE `autologin_id` `autologin_id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
DELETE FROM `bb_config` WHERE `config_name` = 'cron_enabled';
+
+// next
+DELETE FROM `bb_config` WHERE `config_name` = 'hot_threshold';
+DROP TABLE IF EXISTS `bb_attachments`;
+DROP TABLE IF EXISTS `bb_attachments_config`;
+DROP TABLE IF EXISTS `bb_attachments_desc`;
+DROP TABLE IF EXISTS `bb_attach_quota`;
+DROP TABLE IF EXISTS `bb_extensions`;
+DROP TABLE IF EXISTS `bb_extension_groups`;
+DROP TABLE IF EXISTS `bb_quota_limits`;
+DROP TABLE IF EXISTS `bb_topics_watch`;
+ALTER TABLE `bb_bt_torrents` DROP INDEX `post_id`;
+ALTER TABLE `bb_bt_torrents` DROP INDEX `attach_id`;
+ALTER TABLE `bb_bt_torrents` DROP COLUMN `post_id`;
+ALTER TABLE `bb_bt_torrents` DROP COLUMN `attach_id`;
+ALTER TABLE `bb_bt_tor_dl_stat` DROP COLUMN `attach_id`;
+DELETE FROM `bb_cron` WHERE `cron_script` = 'attach_maintenance.php';
+ALTER TABLE `bb_posts` DROP COLUMN `post_attachment`;
+ALTER TABLE `bb_topics` DROP COLUMN `topic_attachment`;
+ALTER TABLE `bb_topics` ADD COLUMN `attach_ext_id` TINYINT(4) NOT NULL DEFAULT '0' AFTER `topic_dl_type`;
+ALTER TABLE `bb_topics` ADD COLUMN `attach_dl_cnt` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0' AFTER `attach_ext_id`;
+ALTER TABLE `bb_topics` ADD COLUMN `filesize` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0' AFTER `attach_dl_cnt`;
diff --git a/library/ajax/change_tor_status.php b/library/ajax/change_tor_status.php
index 84aad69c5..d61cd5274 100644
--- a/library/ajax/change_tor_status.php
+++ b/library/ajax/change_tor_status.php
@@ -13,11 +13,11 @@ if (!defined('IN_AJAX')) {
global $userdata, $bb_cfg, $lang;
-if (!isset($this->request['attach_id'])) {
+if (!isset($this->request['topic_id'])) {
$this->ajax_die($lang['EMPTY_ATTACH_ID']);
}
-$attach_id = (int)$this->request['attach_id'];
+$topic_id = (int)$this->request['topic_id'];
$mode = (string)$this->request['mode'];
if ($bb_cfg['tor_comment']) {
@@ -26,11 +26,11 @@ if ($bb_cfg['tor_comment']) {
$tor = DB()->fetch_row("
SELECT
- tor.poster_id, tor.forum_id, tor.topic_id, tor.tor_status, tor.checked_time, tor.checked_user_id, f.cat_id, t.topic_title
+ tor.poster_id, tor.forum_id, tor.tor_status, tor.checked_time, tor.checked_user_id, f.cat_id, t.topic_title
FROM " . BB_BT_TORRENTS . " tor
INNER JOIN " . BB_FORUMS . " f ON(f.forum_id = tor.forum_id)
INNER JOIN " . BB_TOPICS . " t ON(t.topic_id = tor.topic_id)
- WHERE tor.attach_id = $attach_id
+ WHERE tor.topic_id = $topic_id
LIMIT 1
");
@@ -68,7 +68,7 @@ switch ($mode) {
if (!IS_ADMIN) {
$this->verify_mod_rights($tor['forum_id']);
}
- DB()->query("UPDATE " . BB_TOPICS . " SET topic_status = " . TOPIC_UNLOCKED . " WHERE topic_id = {$tor['topic_id']}");
+ DB()->query("UPDATE " . BB_TOPICS . " SET topic_status = " . TOPIC_UNLOCKED . " WHERE topic_id = {$topic_id} LIMIT 1");
} else {
$this->verify_mod_rights($tor['forum_id']);
}
@@ -83,7 +83,7 @@ switch ($mode) {
}
}
- \TorrentPier\Legacy\Torrent::change_tor_status($attach_id, $new_status);
+ \TorrentPier\Legacy\Torrent::change_tor_status($topic_id, $new_status);
$this->response['status'] = $bb_cfg['tor_icons'][$new_status] . ' ' . $lang['TOR_STATUS_NAME'][$new_status] . ' · ' . profile_url($userdata) . ' · ' . delta_time(TIMENOW) . $lang['TOR_BACK'] . '';
@@ -108,7 +108,7 @@ switch ($mode) {
}
$subject = sprintf($lang['TOR_AUTH_TITLE'], $tor['topic_title']);
- $message = sprintf($lang['TOR_AUTH_MSG'], get_username($tor['checked_user_id']), make_url(TOPIC_URL . $tor['topic_id']), $tor['topic_title']);
+ $message = sprintf($lang['TOR_AUTH_MSG'], get_username($tor['checked_user_id']), make_url(TOPIC_URL . $topic_id), $tor['topic_title']);
if ($comment && $comment != $lang['COMMENT']) {
$message .= "\n\n[b]" . $lang['COMMENT'] . '[/b]: ' . $comment;
@@ -119,4 +119,4 @@ switch ($mode) {
break;
}
-$this->response['attach_id'] = $attach_id;
+$this->response['topic_id'] = $topic_id;
diff --git a/library/ajax/change_torrent.php b/library/ajax/change_torrent.php
index a37ddd3e8..ecd9135bd 100644
--- a/library/ajax/change_torrent.php
+++ b/library/ajax/change_torrent.php
@@ -13,51 +13,22 @@ if (!defined('IN_AJAX')) {
global $userdata, $bb_cfg, $lang;
-if (!isset($this->request['attach_id'])) {
+if (!isset($this->request['t'])) {
$this->ajax_die($lang['EMPTY_ATTACH_ID']);
}
if (!isset($this->request['type'])) {
- $this->ajax_die('type');
+ $this->ajax_die('Invalid AJAX type');
}
-$attach_id = (int)$this->request['attach_id'];
+
+$topic_id = (int)$this->request['t'];
$type = (string)$this->request['type'];
-$torrent = DB()->fetch_row("
- 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) {
- $this->ajax_die($lang['INVALID_ATTACH_ID']);
-}
-
-if ($torrent['poster_id'] == $userdata['user_id'] && !IS_AM) {
- if ($type == 'del_torrent' || $type == 'reg' || $type == 'unreg') {
- true;
- } else {
- $this->ajax_die($lang['ONLY_FOR_MOD']);
- }
-} elseif (!IS_AM) {
+if (!IS_AM) {
$this->ajax_die($lang['ONLY_FOR_MOD']);
}
$title = $url = '';
+
switch ($type) {
case 'set_gold':
case 'set_silver':
@@ -69,35 +40,35 @@ switch ($type) {
} else {
$tor_type = 0;
}
- \TorrentPier\Legacy\Torrent::change_tor_type($attach_id, $tor_type);
+ \TorrentPier\Legacy\Torrent::change_tor_type($topic_id, $tor_type);
$title = $lang['CHANGE_TOR_TYPE'];
- $url = make_url(TOPIC_URL . $torrent['topic_id']);
+ $url = make_url(TOPIC_URL . $topic_id);
break;
case 'reg':
- \TorrentPier\Legacy\Torrent::tracker_register($attach_id);
- $url = (TOPIC_URL . $torrent['topic_id']);
+ \TorrentPier\Legacy\Torrent::tracker_register($topic_id);
+ $url = (TOPIC_URL . $topic_id);
break;
case 'unreg':
- \TorrentPier\Legacy\Torrent::tracker_unregister($attach_id);
- $url = (TOPIC_URL . $torrent['topic_id']);
+ \TorrentPier\Legacy\Torrent::tracker_unregister($topic_id);
+ $url = (TOPIC_URL . $topic_id);
break;
case 'del_torrent':
if (empty($this->request['confirmed'])) {
$this->prompt_for_confirm($lang['DEL_TORRENT']);
}
- \TorrentPier\Legacy\Torrent::delete_torrent($attach_id);
- $url = make_url(TOPIC_URL . $torrent['topic_id']);
+ \TorrentPier\Legacy\Torrent::delete_torrent($topic_id);
+ $url = make_url(TOPIC_URL . $topic_id);
break;
case 'del_torrent_move_topic':
if (empty($this->request['confirmed'])) {
$this->prompt_for_confirm($lang['DEL_MOVE_TORRENT']);
}
- \TorrentPier\Legacy\Torrent::delete_torrent($attach_id);
- $url = make_url("modcp.php?t={$torrent['topic_id']}&mode=move&sid={$userdata['session_id']}");
+ \TorrentPier\Legacy\Torrent::delete_torrent($topic_id);
+ $url = make_url("modcp.php?t=$topic_id&mode=move");
break;
}
diff --git a/library/ajax/mod_action.php b/library/ajax/mod_action.php
index 371b8c779..788aa2d6d 100644
--- a/library/ajax/mod_action.php
+++ b/library/ajax/mod_action.php
@@ -25,13 +25,13 @@ switch ($mode) {
$this->ajax_die($lang['STATUS_DOES_EXIST'] . $new_status);
}
- $topic_ids = DB()->fetch_rowset("SELECT attach_id FROM " . BB_BT_TORRENTS . " WHERE topic_id IN($topics)", 'attach_id');
+ $topic_ids = explode(',', $topics);
- foreach ($topic_ids as $attach_id) {
- \TorrentPier\Legacy\Torrent::change_tor_status($attach_id, $status);
+ foreach ($topic_ids as $topic_id) {
+ \TorrentPier\Legacy\Torrent::change_tor_status($topic_id, $status);
}
$this->response['status'] = $bb_cfg['tor_icons'][$status];
- $this->response['topics'] = explode(',', $topics);
+ $this->response['topics'] = $topic_ids;
break;
case 'edit_topic_title':
@@ -53,7 +53,7 @@ switch ($mode) {
$topic_title_sql = DB()->escape($new_title);
- DB()->query("UPDATE " . BB_TOPICS . " SET topic_title = '$topic_title_sql' WHERE topic_id = $topic_id");
+ DB()->query("UPDATE " . BB_TOPICS . " SET topic_title = '$topic_title_sql' WHERE topic_id = $topic_id LIMIT 1");
// Обновление кеша новостей на главной
$news_forums = array_flip(explode(',', $bb_cfg['latest_news_forum_id']));
diff --git a/library/ajax/posts.php b/library/ajax/posts.php
index 0a782852a..c67368b0c 100644
--- a/library/ajax/posts.php
+++ b/library/ajax/posts.php
@@ -110,7 +110,7 @@ switch ($this->request['type']) {
$message = htmlCHR($message, false, ENT_NOQUOTES);
$this->response['message_html'] = bbcode2html($message);
- $this->response['res_id'] = @$this->request['res_id'];
+ $this->response['res_id'] = $this->request['res_id'];
break;
case 'edit':
@@ -121,7 +121,7 @@ switch ($this->request['type']) {
if ($post['poster_id'] != $userdata['user_id'] && !$is_auth['auth_mod']) {
$this->ajax_die($lang['EDIT_OWN_POSTS']);
}
- if ((mb_strlen($post['post_text'], 'UTF-8') > 1000) || $post['post_attachment'] || ($post['topic_first_post_id'] == $post_id)) {
+ if ((mb_strlen($post['post_text'], 'UTF-8') > 1000) || $post['attach_ext_id'] || ($post['topic_first_post_id'] == $post_id)) {
$this->response['redirect'] = make_url(POSTING_URL . '?mode=editpost&p=' . $post_id);
} elseif ($this->request['type'] == 'editor') {
$text = (string)$this->request['text'];
@@ -135,9 +135,9 @@ switch ($this->request['type']) {
$this->ajax_die(sprintf($lang['MAX_SMILIES_PER_POST'], $bb_cfg['max_smilies']));
}
}
- DB()->query("UPDATE " . BB_POSTS_TEXT . " SET post_text = '" . DB()->escape($text) . "' WHERE post_id = $post_id");
+ DB()->query("UPDATE " . BB_POSTS_TEXT . " SET post_text = '" . DB()->escape($text) . "' WHERE post_id = $post_id LIMIT 1");
if ($post['topic_last_post_id'] != $post['post_id'] && $userdata['user_id'] == $post['poster_id']) {
- DB()->query("UPDATE " . BB_POSTS . " SET post_edit_time = '" . TIMENOW . "', post_edit_count = post_edit_count + 1 WHERE post_id = $post_id");
+ DB()->query("UPDATE " . BB_POSTS . " SET post_edit_time = '" . TIMENOW . "', post_edit_count = post_edit_count + 1 WHERE post_id = $post_id LIMIT 1");
}
$s_text = str_replace('\n', "\n", $text);
$s_topic_title = str_replace('\n', "\n", $post['topic_title']);
@@ -232,7 +232,7 @@ switch ($this->request['type']) {
$where_sql = (IS_GUEST) ? "p.poster_ip = '" . USER_IP . "'" : "p.poster_id = {$userdata['user_id']}";
$sql = "SELECT MAX(p.post_time) AS last_post_time FROM " . BB_POSTS . " p WHERE $where_sql";
- if ($row = DB()->fetch_row($sql) and $row['last_post_time']) {
+ if (($row = DB()->fetch_row($sql)) && $row['last_post_time']) {
if ($userdata['user_level'] == USER) {
if (TIMENOW - $row['last_post_time'] < $bb_cfg['flood_interval']) {
$this->ajax_die($lang['FLOOD_ERROR']);
@@ -281,11 +281,6 @@ switch ($this->request['type']) {
'post_text' => $message,
));
- if ($bb_cfg['topic_notify_enabled']) {
- $notify = !empty($this->request['notify']);
- \TorrentPier\Legacy\Post::user_notification('reply', $post, $post['topic_title'], $post['forum_id'], $topic_id, $notify);
- }
-
// Update atom feed
update_atom('topic', (int)$this->request['topic_id']);
diff --git a/library/ajax/view_torrent.php b/library/ajax/view_torrent.php
index eafa76146..52bc70dbf 100644
--- a/library/ajax/view_torrent.php
+++ b/library/ajax/view_torrent.php
@@ -13,20 +13,17 @@ if (!defined('IN_AJAX')) {
global $lang;
-if (!isset($this->request['attach_id'])) {
+if (!isset($this->request['t'])) {
$this->ajax_die($lang['EMPTY_ATTACH_ID']);
}
-$attach_id = (int)$this->request['attach_id'];
+$topic_id = (int)$this->request['t'];
-$torrent = DB()->fetch_row("SELECT attach_id, physical_filename FROM " . BB_ATTACHMENTS_DESC . " WHERE attach_id = $attach_id LIMIT 1");
-if (!$torrent) {
- $this->ajax_die($lang['ERROR_BUILD']);
-}
+// Получение торрент-файла
+$file_path = get_attach_path($topic_id, 8);
-$filename = get_attachments_dir() . '/' . $torrent['physical_filename'];
-if (file_exists($filename) && !$file_contents = file_get_contents($filename)) {
+if (file_exists($file_path) && !$file_contents = file_get_contents($file_path)) {
if (IS_AM) {
- $this->ajax_die($lang['ERROR_NO_ATTACHMENT'] . "\n\n" . htmlCHR($filename));
+ $this->ajax_die($lang['ERROR_NO_ATTACHMENT'] . "\n\n" . htmlCHR($file_path));
} else {
$this->ajax_die($lang['ERROR_NO_ATTACHMENT']);
}
diff --git a/posting.php b/posting.php
index d20c20ffe..9257f0c22 100644
--- a/posting.php
+++ b/posting.php
@@ -8,10 +8,8 @@
*/
define('BB_SCRIPT', 'posting');
-define('BB_ROOT', './');
require __DIR__ . '/common.php';
require INC_DIR . '/bbcode.php';
-require ATTACH_DIR . '/attachment_mod.php';
$page_cfg['load_tpl_vars'] = array('post_icons');
@@ -196,8 +194,9 @@ if ($post_info = DB()->fetch_row($sql)) {
bb_die($lang['NO_SUCH_POST']);
}
-// The user is not authed, if they're not logged in then redirect
-// them, else show them an error message
+$bb_cfg['attach']['allowed_ext'] = ($post_info['allow_reg_tracker']) ? $bb_cfg['tor_forums_allowed_ext'] : $bb_cfg['gen_forums_allowed_ext'];
+$attach_allowed_ext = $post_info['allow_reg_tracker'] ? $bb_cfg['tor_forums_allowed_ext'] : $bb_cfg['gen_forums_allowed_ext'];
+
if (!$is_auth[$is_auth_type]) {
if (!IS_GUEST) {
bb_die(sprintf($lang['SORRY_' . strtoupper($is_auth_type)], $is_auth[$is_auth_type . '_type']));
@@ -245,26 +244,13 @@ if ($mode == 'new_rel') {
exit;
}
-// Notify
-if ($submit || $refresh) {
- $notify_user = (int)!empty($_POST['notify']);
-} else {
- $notify_user = bf($userdata['user_opt'], 'user_opt', 'user_notify');
-
- if (!IS_GUEST && $mode != 'newtopic' && !$notify_user) {
- $notify_user = (int)DB()->fetch_row("SELECT topic_id FROM " . BB_TOPICS_WATCH . " WHERE topic_id = $topic_id AND user_id = " . $userdata['user_id']);
- }
-}
-
$update_post_time = !empty($_POST['update_post_time']);
-execute_posting_attachment_handling();
-
// если за время пока вы писали ответ, в топике появились новые сообщения, перед тем как ваше сообщение будет отправлено, выводится предупреждение с обзором этих сообщений
$topic_has_new_posts = false;
if (!IS_GUEST && $mode != 'newtopic' && ($submit || $preview || $mode == 'quote' || $mode == 'reply') && isset($_COOKIE[COOKIE_TOPIC])) {
- if ($topic_last_read = max((int)(@$tracking_topics[$topic_id]), (int)(@$tracking_forums[$forum_id]))) {
+ if ($topic_last_read = max((int)$tracking_topics[$topic_id], (int)$tracking_forums[$forum_id])) {
$sql = "SELECT p.*, pt.post_text, u.username, u.user_rank
FROM " . BB_POSTS . " p, " . BB_POSTS_TEXT . " pt, " . BB_USERS . " u
WHERE p.topic_id = " . (int)$topic_id . "
@@ -353,16 +339,14 @@ if (($delete || $mode == 'delete') && !$confirm) {
$user_id = ($mode == 'reply' || $mode == 'newtopic') ? $userdata['user_id'] : $post_data['poster_id'];
\TorrentPier\Legacy\Post::update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $user_id);
}
- $attachment_mod['posting']->insert_attachment($post_id);
-
- if (!$error_msg) {
- \TorrentPier\Legacy\Post::user_notification($mode, $post_data, $post_info['topic_title'], $forum_id, $topic_id, $notify_user);
- }
if ($mode == 'newtopic' || $mode == 'reply') {
set_tracks(COOKIE_TOPIC, $tracking_topics, $topic_id);
}
+ // новая тема или редактирование 1-го сообщения и нет уже прикрепленного файла
+ $can_attach_file = (($mode == 'newtopic' || ($post_data['first_post'] && $mode == 'editpost')) && empty($post_info['attach_ext_id']));
+
if (defined('TORRENT_ATTACH_ID') && $bb_cfg['bt_newtopic_auto_reg'] && !$error_msg) {
if (!DB()->fetch_row("SELECT attach_id FROM " . BB_BT_TORRENTS . " WHERE attach_id = " . TORRENT_ATTACH_ID)) {
if ($bb_cfg['premod']) {
@@ -529,7 +513,7 @@ if ($mode == 'newtopic' || ($mode == 'editpost' && $post_data['first_post'])) {
//bt
$topic_dl_type = $post_info['topic_dl_type'] ?? 0;
-if ($post_info['allow_reg_tracker'] && $post_data['first_post'] && ($topic_dl_type || $is_auth['auth_mod'])) {
+/**if ($post_info['allow_reg_tracker'] && $post_data['first_post'] && ($topic_dl_type || $is_auth['auth_mod'])) {
$sql = "
SELECT tor.attach_id
FROM " . BB_POSTS . " p
@@ -557,7 +541,7 @@ if ($post_info['allow_reg_tracker'] && $post_data['first_post'] && ($topic_dl_ty
$topic_type_toggle .= '';
$topic_type_toggle .= $dl_hid;
}
-}
+}**/
//bt end
// Get poster release group data
@@ -603,7 +587,6 @@ $template->set_filenames(array(
'body' => 'posting.tpl',
));
-// Output the data to the template
$template->assign_vars(array(
'FORUM_NAME' => htmlCHR($forum_name),
'PAGE_TITLE' => $page_title,
@@ -620,9 +603,8 @@ $template->assign_vars(array(
'POSTER_RGROUPS' => isset($poster_rgroups) && !empty($poster_rgroups) ? $poster_rgroups : '',
'ATTACH_RG_SIG' => ($switch_rg_sig) ?: false,
- 'U_VIEWTOPIC' => ($mode == 'reply') ? "viewtopic.php?" . POST_TOPIC_URL . "=$topic_id&postorder=desc" : '',
+ 'U_VIEWTOPIC' => ($mode == 'reply') ? "viewtopic.php?" . POST_TOPIC_URL . "=" . $topic_id : '',
- 'S_NOTIFY_CHECKED' => ($notify_user) ? 'checked="checked"' : '',
'S_TYPE_TOGGLE' => $topic_type_toggle,
'S_TOPIC_ID' => $topic_id,
'S_POST_ACTION' => POSTING_URL,
diff --git a/search.php b/search.php
index 21a30809f..13ed35b8e 100644
--- a/search.php
+++ b/search.php
@@ -8,7 +8,6 @@
*/
define('BB_SCRIPT', 'search');
-define('BB_ROOT', './');
require __DIR__ . '/common.php';
require INC_DIR . '/bbcode.php';
@@ -30,7 +29,7 @@ if (isset($_POST['del_my_post'])) {
' . $lang['INDEX_RETURN'] . '
');
- if (empty($_POST['topic_id_list']) or !$topic_csv = get_id_csv($_POST['topic_id_list'])) {
+ if (empty($_POST['topic_id_list']) || !($topic_csv = get_id_csv($_POST['topic_id_list']))) {
bb_die($lang['NONE_SELECTED']);
}
@@ -794,16 +793,16 @@ else {
'FORUM_ID' => $forum_id,
'FORUM_NAME' => $forum_name_html[$forum_id],
'TOPIC_ID' => $topic_id,
- 'HREF_TOPIC_ID' => ($moved) ? $topic['topic_moved_id'] : $topic['topic_id'],
+ 'HREF_TOPIC_ID' => $moved ? $topic['topic_moved_id'] : $topic['topic_id'],
'TOPIC_TITLE' => wbr($topic['topic_title']),
'IS_UNREAD' => $is_unread,
'TOPIC_ICON' => get_topic_icon($topic, $is_unread),
- 'PAGINATION' => ($moved) ? '' : build_topic_pagination(TOPIC_URL . $topic_id, $topic['topic_replies'], $bb_cfg['posts_per_page']),
+ 'PAGINATION' => $moved ? '' : build_topic_pagination(TOPIC_URL . $topic_id, $topic['topic_replies'], $bb_cfg['posts_per_page']),
'REPLIES' => $topic['topic_replies'],
- 'ATTACH' => $topic['topic_attachment'],
+ 'ATTACH' => $topic['attach_ext_id'],
'STATUS' => $topic['topic_status'],
'TYPE' => $topic['topic_type'],
- 'DL' => ($topic['topic_dl_type'] == TOPIC_DL_TYPE_DL),
+ 'DL' => $topic['tracker_status'] ?? null,
'POLL' => $topic['topic_vote'],
'DL_CLASS' => isset($topic['dl_status']) ? $dl_link_css[$topic['dl_status']] : '',
diff --git a/src/Legacy/Admin/Common.php b/src/Legacy/Admin/Common.php
index 5ea2fb202..dbd627335 100644
--- a/src/Legacy/Admin/Common.php
+++ b/src/Legacy/Admin/Common.php
@@ -107,7 +107,6 @@ class Common
topic_first_post_id INT UNSIGNED NOT NULL DEFAULT '0',
topic_last_post_id INT UNSIGNED NOT NULL DEFAULT '0',
topic_last_post_time INT UNSIGNED NOT NULL DEFAULT '0',
- topic_attachment INT UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (topic_id)
) ENGINE = MEMORY
");
@@ -122,11 +121,9 @@ class Common
COUNT(p.post_id) AS total_posts,
MIN(p.post_id) AS topic_first_post_id,
MAX(p.post_id) AS topic_last_post_id,
- MAX(p.post_time) AS topic_last_post_time,
- IF(MAX(a.attach_id), 1, 0) AS topic_attachment
+ MAX(p.post_time) AS topic_last_post_time
FROM " . BB_TOPICS . " t
LEFT JOIN " . BB_POSTS . " p ON(p.topic_id = t.topic_id)
- LEFT JOIN " . BB_ATTACHMENTS . " a ON(a.post_id = p.post_id)
WHERE t.topic_status != " . TOPIC_MOVED . "
$where_sql
GROUP BY t.topic_id
@@ -139,8 +136,7 @@ class Common
t.topic_replies = tmp.total_posts - 1,
t.topic_first_post_id = tmp.topic_first_post_id,
t.topic_last_post_id = tmp.topic_last_post_id,
- t.topic_last_post_time = tmp.topic_last_post_time,
- t.topic_attachment = tmp.topic_attachment
+ t.topic_last_post_time = tmp.topic_last_post_time
WHERE
t.topic_id = tmp.topic_id
");
@@ -157,7 +153,7 @@ class Common
$all_users = ($id === 'all');
- if (!$all_users and !$user_csv = get_id_csv($id)) {
+ if (!$all_users AND !$user_csv = get_id_csv($id)) {
break;
}
@@ -222,7 +218,7 @@ class Common
$topic_csv = [];
$prune = ($mode_or_topic_id === 'prune');
- if (!$prune and !$topic_csv = get_id_csv($mode_or_topic_id)) {
+ if (!$prune AND !$topic_csv = get_id_csv($mode_or_topic_id)) {
return false;
}
@@ -325,31 +321,6 @@ class Common
LEFT JOIN " . BB_POLL_USERS . " pu USING(topic_id)
");
- // Delete attachments (from disk)
- $attach_dir = get_attachments_dir();
-
- $result = DB()->query("
- SELECT
- d.physical_filename
- FROM
- " . $tmp_delete_topics . " del,
- " . BB_POSTS . " p,
- " . BB_ATTACHMENTS . " a,
- " . BB_ATTACHMENTS_DESC . " d
- WHERE
- p.topic_id = del.topic_id
- AND a.post_id = p.post_id
- AND d.attach_id = a.attach_id
- ");
-
- while ($row = DB()->fetch_next($result)) {
- if ($filename = basename($row['physical_filename'])) {
- @unlink("$attach_dir/" . $filename);
- @unlink("$attach_dir/" . THUMB_DIR . '/t_' . $filename);
- }
- }
- unset($row, $result);
-
// Delete posts, posts_text, attachments (from DB)
DB()->query("
DELETE p, pt, ps, a, d, ph
@@ -358,16 +329,13 @@ class Common
LEFT JOIN " . BB_POSTS_TEXT . " pt ON(pt.post_id = p.post_id)
LEFT JOIN " . BB_POSTS_HTML . " ph ON(ph.post_id = p.post_id)
LEFT JOIN " . BB_POSTS_SEARCH . " ps ON(ps.post_id = p.post_id)
- LEFT JOIN " . BB_ATTACHMENTS . " a ON(a.post_id = p.post_id)
- LEFT JOIN " . BB_ATTACHMENTS_DESC . " d ON(d.attach_id = a.attach_id)
");
- // Delete topics, topics watch
+ // Delete topics
DB()->query("
- DELETE t, tw
+ DELETE t
FROM " . $tmp_delete_topics . " del
LEFT JOIN " . BB_TOPICS . " t USING(topic_id)
- LEFT JOIN " . BB_TOPICS_WATCH . " tw USING(topic_id)
");
// Delete topic moved stubs
@@ -459,7 +427,7 @@ class Common
}
}
- if (!$topics or !$topic_csv = get_id_csv(array_keys($topics))) {
+ if (!$topics OR !$topic_csv = get_id_csv(array_keys($topics))) {
return false;
}
@@ -621,30 +589,7 @@ class Common
return 0;
}
- // Delete attachments (from disk)
- $attach_dir = get_attachments_dir();
-
- $result = DB()->query("
- SELECT
- d.physical_filename
- FROM
- " . $tmp_delete_posts . " del,
- " . BB_ATTACHMENTS . " a,
- " . BB_ATTACHMENTS_DESC . " d
- WHERE
- a.post_id = del.post_id
- AND d.attach_id = a.attach_id
- ");
-
- while ($row = DB()->fetch_next($result)) {
- if ($filename = basename($row['physical_filename'])) {
- @unlink("$attach_dir/" . $filename);
- @unlink("$attach_dir/" . THUMB_DIR . '/t_' . $filename);
- }
- }
- unset($row, $result);
-
- // Delete posts, posts_text, attachments (from DB)
+ // Delete posts, posts_text (from DB)
DB()->query("
DELETE p, pt, ps, tor, a, d, ph
FROM " . $tmp_delete_posts . " del
@@ -653,8 +598,6 @@ class Common
LEFT JOIN " . BB_POSTS_HTML . " ph ON(ph.post_id = del.post_id)
LEFT JOIN " . BB_POSTS_SEARCH . " ps ON(ps.post_id = del.post_id)
LEFT JOIN " . BB_BT_TORRENTS . " tor ON(tor.post_id = del.post_id)
- LEFT JOIN " . BB_ATTACHMENTS . " a ON(a.post_id = del.post_id)
- LEFT JOIN " . BB_ATTACHMENTS_DESC . " d ON(d.attach_id = a.attach_id)
");
// Log action
@@ -729,18 +672,15 @@ class Common
FROM " . BB_USER_GROUP . " ug
LEFT JOIN " . BB_GROUPS . " g ON(g.group_id = ug.group_id AND g.group_single_user = 1)
LEFT JOIN " . BB_AUTH_ACCESS . " a ON(a.group_id = g.group_id)
- LEFT JOIN " . BB_QUOTA . " qt1 ON(qt1.user_id = ug.user_id)
- LEFT JOIN " . BB_QUOTA . " qt2 ON(qt2.group_id = g.group_id)
WHERE ug.user_id IN($user_csv)
");
DB()->query("
- DELETE u, ban, pu, s, tw, asn
+ DELETE u, ban, pu, s, asn
FROM " . BB_USERS . " u
LEFT JOIN " . BB_BANLIST . " ban ON(ban.ban_userid = u.user_id)
LEFT JOIN " . BB_POLL_USERS . " pu ON(pu.user_id = u.user_id)
LEFT JOIN " . BB_SESSIONS . " s ON(s.session_user_id = u.user_id)
- LEFT JOIN " . BB_TOPICS_WATCH . " tw ON(tw.user_id = u.user_id)
LEFT JOIN " . BB_AUTH_ACCESS_SNAP . " asn ON(asn.user_id = u.user_id)
WHERE u.user_id IN($user_csv)
");
diff --git a/src/Legacy/Post.php b/src/Legacy/Post.php
index a7c78868f..220b32c0d 100644
--- a/src/Legacy/Post.php
+++ b/src/Legacy/Post.php
@@ -136,11 +136,11 @@ class Post
}
if ($mode == 'newtopic' || ($mode == 'editpost' && $post_data['first_post'])) {
- $topic_dl_type = (isset($_POST['topic_dl_type']) && ($post_info['allow_reg_tracker'] || $is_auth['auth_mod'])) ? TOPIC_DL_TYPE_DL : TOPIC_DL_TYPE_NORMAL;
+ $topic_dl_type = (isset($_POST['tracker_status']) && ($post_info['allow_reg_tracker'] || $is_auth['auth_mod'])) ? TOPIC_DL_TYPE_DL : TOPIC_DL_TYPE_NORMAL;
$sql_insert = "
INSERT INTO
- " . BB_TOPICS . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_dl_type)
+ " . BB_TOPICS . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, tracker_status)
VALUES
('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_dl_type)
";
@@ -151,7 +151,7 @@ class Post
SET
topic_title = '$post_subject',
topic_type = $topic_type,
- topic_dl_type = $topic_dl_type
+ tracker_status = $topic_dl_type
WHERE
topic_id = $topic_id
";
@@ -172,7 +172,7 @@ class Post
if ($update_post_time && $mode == 'editpost' && $post_data['last_post'] && !$post_data['first_post']) {
$edited_sql .= ", post_time = $current_time ";
//lpt
- DB()->sql_query("UPDATE " . BB_TOPICS . " SET topic_last_post_time = $current_time WHERE topic_id = $topic_id");
+ DB()->sql_query("UPDATE " . BB_TOPICS . " SET topic_last_post_time = $current_time WHERE topic_id = $topic_id LIMIT 1");
}
$sql = ($mode != "editpost") ? "INSERT INTO " . BB_POSTS . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, poster_rg_id, attach_rg_sig) VALUES ($topic_id, $forum_id, " . $userdata['user_id'] . ", '$post_username', $current_time, '" . USER_IP . "', $poster_rg_id, $attach_rg_sig)" : "UPDATE " . BB_POSTS . " SET post_username = '$post_username'" . $edited_sql . ", poster_rg_id = $poster_rg_id, attach_rg_sig = $attach_rg_sig WHERE post_id = $post_id";
@@ -323,101 +323,6 @@ class Post
set_die_append_msg($forum_id, $topic_id);
}
- /**
- * Handle user notification on new post
- *
- * @param string $mode
- * @param array $post_data
- * @param string $topic_title
- * @param int $forum_id
- * @param int $topic_id
- * @param bool $notify_user
- */
- public static function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topic_id, &$notify_user)
- {
- global $bb_cfg, $lang, $userdata;
-
- if (!$bb_cfg['topic_notify_enabled']) {
- return;
- }
-
- if ($mode != 'delete') {
- if ($mode == 'reply') {
- $update_watched_sql = $user_id_sql = [];
-
- $sql = DB()->fetch_rowset("SELECT ban_userid FROM " . BB_BANLIST . " WHERE ban_userid != 0");
-
- foreach ($sql as $row) {
- $user_id_sql[] = ',' . $row['ban_userid'];
- }
- $user_id_sql = implode('', $user_id_sql);
-
- $watch_list = DB()->fetch_rowset("SELECT u.username, u.user_id, u.user_email, u.user_lang
- FROM " . BB_TOPICS_WATCH . " tw, " . BB_USERS . " u
- WHERE tw.topic_id = $topic_id
- AND tw.user_id NOT IN (" . $userdata['user_id'] . ", " . EXCLUDED_USERS . $user_id_sql . ")
- AND tw.notify_status = " . TOPIC_WATCH_NOTIFIED . "
- AND u.user_id = tw.user_id
- AND u.user_active = 1
- ORDER BY u.user_id
- ");
-
- if ($watch_list) {
- $orig_word = $replacement_word = [];
- obtain_word_list($orig_word, $replacement_word);
-
- if (\count($orig_word)) {
- $topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
- }
-
- $u_topic = make_url(TOPIC_URL . $topic_id . '&view=newest#newest');
- $unwatch_topic = make_url(TOPIC_URL . "$topic_id&unwatch=topic");
-
- foreach ($watch_list as $row) {
- // Sending email
- $emailer = new Emailer();
-
- $emailer->set_to($row['user_email'], $row['username']);
- $emailer->set_subject(sprintf($lang['EMAILER_SUBJECT']['TOPIC_NOTIFY'], $topic_title));
-
- $emailer->set_template('topic_notify', $row['user_lang']);
- $emailer->assign_vars([
- 'TOPIC_TITLE' => html_entity_decode($topic_title),
- 'SITENAME' => $bb_cfg['sitename'],
- 'USERNAME' => $row['username'],
- 'U_TOPIC' => $u_topic,
- 'U_STOP_WATCHING_TOPIC' => $unwatch_topic,
- ]);
-
- $emailer->send();
-
- $update_watched_sql[] = $row['user_id'];
- }
- $update_watched_sql = implode(',', $update_watched_sql);
- }
-
- if ($update_watched_sql) {
- DB()->query("UPDATE " . BB_TOPICS_WATCH . "
- SET notify_status = " . TOPIC_WATCH_UNNOTIFIED . "
- WHERE topic_id = $topic_id
- AND user_id IN ($update_watched_sql)
- ");
- }
- }
-
- $topic_watch = DB()->fetch_row("SELECT topic_id FROM " . BB_TOPICS_WATCH . " WHERE topic_id = $topic_id AND user_id = {$userdata['user_id']}", 'topic_id');
-
- if (!$notify_user && !empty($topic_watch)) {
- DB()->query("DELETE FROM " . BB_TOPICS_WATCH . " WHERE topic_id = $topic_id AND user_id = {$userdata['user_id']}");
- } elseif ($notify_user && empty($topic_watch)) {
- DB()->query("
- INSERT INTO " . BB_TOPICS_WATCH . " (user_id, topic_id, notify_status)
- VALUES (" . $userdata['user_id'] . ", $topic_id, " . TOPIC_WATCH_NOTIFIED . ")
- ");
- }
- }
- }
-
/**
* Insert post to the existing thread
*
diff --git a/src/Legacy/Torrent.php b/src/Legacy/Torrent.php
index f6e47c77b..81a05943a 100644
--- a/src/Legacy/Torrent.php
+++ b/src/Legacy/Torrent.php
@@ -15,80 +15,40 @@ namespace TorrentPier\Legacy;
*/
class Torrent
{
- /**
- * Get torrent info by attach id
- *
- * @param int $attach_id
- *
- * @return array
- */
- private static function get_torrent_info($attach_id)
- {
- global $lang;
-
- $attach_id = (int)$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;
- }
-
/**
* Check that user has access to torrent download
*
* @param int $forum_id
* @param int $poster_id
*
- * @return bool|string
+ * @return void
*/
- private static function torrent_auth_check($forum_id, $poster_id)
+ private static function torrent_auth_check(int $forum_id, int $poster_id): void
{
- global $userdata, $lang, $attach_config;
+ global $userdata, $lang;
- if (IS_ADMIN) {
- return true;
+ if (IS_ADMIN || $userdata['user_id'] == $poster_id) {
+ return;
}
- $is_auth = auth(AUTH_ALL, $forum_id, $userdata);
-
- if ($poster_id != $userdata['user_id'] && !$is_auth['auth_mod']) {
- bb_die($lang['NOT_MODERATOR']);
- } elseif (!$is_auth['auth_view'] || !$is_auth['auth_attachments'] || $attach_config['disable_mod']) {
- bb_die(sprintf($lang['SORRY_AUTH_READ'], $is_auth['auth_read_type']));
+ if (IS_MOD)
+ {
+ $is_auth = auth(AUTH_MOD, $forum_id, $userdata);
+ if ($is_auth['auth_mod']) {
+ return;
+ }
}
- return $is_auth;
+
+ bb_die($lang['NOT_AUTHORISED']);
}
/**
* Unregister torrent from tracker
*
- * @param int $attach_id
+ * @param int $topic_id
* @param string $mode
*/
- public static function tracker_unregister($attach_id, $mode = '')
+ public static function tracker_unregister($topic_id, $mode = '')
{
global $lang, $bb_cfg;
@@ -148,18 +108,11 @@ class Torrent
}
// Delete torrent
- $sql = "DELETE FROM " . BB_BT_TORRENTS . " WHERE attach_id = $attach_id";
-
+ $sql = "DELETE FROM " . BB_BT_TORRENTS . " WHERE topic_id = $topic_id";
if (!DB()->sql_query($sql)) {
bb_die('Could not delete torrent from torrents table');
}
- // Update tracker_status
- $sql = "UPDATE " . BB_ATTACHMENTS_DESC . " SET tracker_status = 0 WHERE attach_id = $attach_id";
-
- if (!DB()->sql_query($sql)) {
- bb_die('Could not update torrent status #1');
- }
if ($mode == 'request') {
set_die_append_msg($forum_id, $topic_id);
@@ -264,22 +217,21 @@ class Torrent
/**
* Register torrent on tracker
*
- * @param int $attach_id
+ * @param int $topic_id
* @param string $mode
* @param int $tor_status
* @param int $reg_time
*
* @return bool
*/
- public static function tracker_register($attach_id, $mode = '', $tor_status = TOR_NOT_APPROVED, $reg_time = TIMENOW)
+ public static function tracker_register($topic_id, $mode = '', $tor_status = TOR_NOT_APPROVED, $reg_time = TIMENOW)
{
global $bb_cfg, $lang, $reg_mode;
$announce_urls = [];
- $attach_id = (int)$attach_id;
$reg_mode = $mode;
- if (!$torrent = self::get_torrent_info($attach_id)) {
+ if (!$torrent = self::get_torrent_info($topic_id)) {
bb_die($lang['TOR_NOT_FOUND']);
}
@@ -374,8 +326,8 @@ class Torrent
$size = sprintf('%.0f', (float)$totallen);
- $columns = ' info_hash, post_id, poster_id, topic_id, forum_id, attach_id, size, reg_time, tor_status';
- $values = "'$info_hash_sql', $post_id, $poster_id, $topic_id, $forum_id, $attach_id, '$size', $reg_time, $tor_status";
+ $columns = ' info_hash, post_id, poster_id, topic_id, forum_id, size, reg_time, tor_status';
+ $values = "'$info_hash_sql', $post_id, $poster_id, $topic_id, $forum_id, '$size', $reg_time, $tor_status";
$sql = "INSERT INTO " . BB_BT_TORRENTS . " ($columns) VALUES ($values)";
@@ -390,13 +342,6 @@ class Torrent
bb_die('Could not register torrent on tracker');
}
- // update tracker status for this attachment
- $sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . " SET tracker_status = 1 WHERE attach_id = $attach_id";
-
- if (!DB()->sql_query($sql)) {
- bb_die('Could not update torrent status #2');
- }
-
// set DL-Type for topic
if ($bb_cfg['bt_set_dltype_on_tor_reg']) {
$sql = 'UPDATE ' . BB_TOPICS . ' SET topic_dl_type = ' . TOPIC_DL_TYPE_DL . " WHERE topic_id = $topic_id";
@@ -412,8 +357,7 @@ class Torrent
if ($reg_mode == 'request' || $reg_mode == 'newtopic') {
set_die_append_msg($forum_id, $topic_id);
- $mess = sprintf($lang['BT_REGISTERED'], DL_URL . $attach_id);
- bb_die($mess);
+ bb_die(sprintf($lang['BT_REGISTERED'], DL_URL . $topic_id));
}
return true;
@@ -422,42 +366,21 @@ class Torrent
/**
* Set passkey and send torrent to the browser
*
- * @param string $filename
+ * @param array $t_data
*/
- public static function send_torrent_with_passkey($filename)
+ public static function send_torrent_with_passkey($t_data)
{
- global $attachment, $auth_pages, $userdata, $bb_cfg, $lang;
-
- if (!$bb_cfg['bt_add_auth_key'] || $attachment['extension'] !== TORRENT_EXT || !$size = @filesize($filename)) {
- return;
- }
+ global $userdata, $bb_cfg, $lang;
$post_id = $poster_id = $passkey_val = '';
+ $topic_id = $t_data['topic_id'];
+ $poster_id = $t_data['topic_poster'];
$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\'])');
- }
+ // Запрет на скачивание закрытого или незарегистрированного торрента
+ $row = DB()->fetch_row("SELECT tor_status FROM ". BB_BT_TORRENTS ." WHERE topic_id = $topic_id LIMIT 1");
- // 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']) {
+ if (!isset($row['tor_status'])) {
bb_die($lang['PASSKEY_ERR_TOR_NOT_REG']);
}
@@ -473,7 +396,7 @@ class Torrent
}
}
- // Ratio limits
+ // Ratio limit for torrents dl
$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) {
@@ -495,6 +418,10 @@ class Torrent
// Announce URL
$ann_url = $bb_cfg['bt_announce_url'];
+ $filename = get_attach_path($topic_id, 8);
+ if (!file_exists($filename)) {
+ bb_simple_die($lang['NOT_FOUND']);
+ }
$file_contents = file_get_contents($filename);
if (!$tor = \Rych\Bencode\Bencode::decode($file_contents)) {
bb_die('This is not a bencoded file');
@@ -598,7 +525,7 @@ class Torrent
}
// Update
- DB()->query("UPDATE IGNORE " . BB_BT_USERS . " SET auth_key = '$passkey_val' WHERE user_id = $user_id");
+ DB()->query("UPDATE IGNORE " . BB_BT_USERS . " SET auth_key = '$passkey_val' WHERE user_id = $user_id LIMIT 1");
if (DB()->affected_rows() == 1) {
// Ocelot
if ($bb_cfg['ocelot']['enabled']) {
diff --git a/styles/templates/admin/admin_bt_forum_cfg.tpl b/styles/templates/admin/admin_bt_forum_cfg.tpl
index 62f7478ad..a1c0861fb 100644
--- a/styles/templates/admin/admin_bt_forum_cfg.tpl
+++ b/styles/templates/admin/admin_bt_forum_cfg.tpl
@@ -174,4 +174,10 @@
-
+
+
+
Для выделения нескольких форумов, отмечайте их с нажатой клавишей Ctrl
+
Для того чтобы правильно показывалась иерархия разделов/подразделов в списке на странице "Трекер", во всех корневых разделах должна быть разрешена регистрация торрентов если в каком-то их подразделе она тоже разрешена, иначе корневой раздел в этот список не попадает и структура списка будет выглядеть неправильно (подразделы одного корневого раздела "попадут" в другой)