This commit is contained in:
Yury Pikhtarev 2023-04-14 15:09:58 +03:00
commit 20337c4b85
22 changed files with 413 additions and 1040 deletions

9
dl.php
View file

@ -9,12 +9,9 @@
define('BB_SCRIPT', 'dl'); define('BB_SCRIPT', 'dl');
define('NO_GZIP', true); define('NO_GZIP', true);
define('BB_ROOT', './');
require __DIR__ . '/common.php'; require __DIR__ . '/common.php';
require ATTACH_DIR . '/attachment_mod.php';
$datastore->enqueue(array( $datastore->enqueue(array(
'attach_extensions',
'cat_forums', 'cat_forums',
)); ));
@ -24,13 +21,13 @@ $thumbnail = request_var('thumb', 0);
// Send file to browser // Send file to browser
function send_file_to_browser($attachment, $upload_dir) function send_file_to_browser($attachment, $upload_dir)
{ {
global $bb_cfg, $lang, $userdata; global $bb_cfg, $lang;
$filename = ($upload_dir == '') ? $attachment['physical_filename'] : $upload_dir . '/' . $attachment['physical_filename']; $filename = ($upload_dir == '') ? $attachment['physical_filename'] : $upload_dir . '/' . $attachment['physical_filename'];
$gotit = false; $gotit = false;
if (@!file_exists(@amod_realpath($filename))) { if (!file_exists($filename)) {
bb_die($lang['ERROR_NO_ATTACHMENT'] . "<br /><br />" . $filename . "<br /><br />" . $lang['TOR_NOT_FOUND']); bb_die($lang['ERROR_NO_ATTACHMENT'] . "<br /><br />" . $filename . "<br /><br />" . $lang['TOR_NOT_FOUND']);
} else { } else {
$gotit = true; $gotit = true;
@ -146,7 +143,7 @@ $datastore->rm('cat_forums');
// //
// Get Information on currently allowed Extensions // Get Information on currently allowed Extensions
// //
$rows = get_extension_informations(); $rows = get_extension_informations(); //todo
$num_rows = count($rows); $num_rows = count($rows);
for ($i = 0; $i < $num_rows; $i++) { for ($i = 0; $i < $num_rows; $i++) {

View file

@ -1,114 +1,5 @@
SET SQL_MODE = ""; 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` -- 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` CREATE TABLE IF NOT EXISTS `bb_bt_torrents`
( (
`info_hash` VARBINARY(20) NOT NULL DEFAULT '', `info_hash` VARBINARY(20) NOT NULL DEFAULT '',
`post_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
`poster_id` MEDIUMINT(9) NOT NULL DEFAULT '0', `poster_id` MEDIUMINT(9) NOT NULL DEFAULT '0',
`topic_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0', `topic_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
`forum_id` SMALLINT(5) 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', `size` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
`reg_time` INT(11) NOT NULL DEFAULT '0', `reg_time` INT(11) NOT NULL DEFAULT '0',
`call_seed_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_up` INT(11) NOT NULL DEFAULT '0',
`speed_down` INT(11) NOT NULL DEFAULT '0', `speed_down` INT(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`info_hash`), PRIMARY KEY (`info_hash`),
UNIQUE KEY `post_id` (`post_id`),
UNIQUE KEY `topic_id` (`topic_id`), UNIQUE KEY `topic_id` (`topic_id`),
UNIQUE KEY `attach_id` (`attach_id`),
KEY `reg_time` (`reg_time`), KEY `reg_time` (`reg_time`),
KEY `forum_id` (`forum_id`), KEY `forum_id` (`forum_id`),
KEY `poster_id` (`poster_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', `topic_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
`user_id` MEDIUMINT(9) 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_up_total` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
`t_down_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', `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_dateformat', 'Y-m-d H:i'),
('default_lang', 'ru'), ('default_lang', 'ru'),
('flood_interval', '15'), ('flood_interval', '15'),
('hot_threshold', '300'),
('login_reset_time', '30'), ('login_reset_time', '30'),
('max_autologin_time', '10'), ('max_autologin_time', '10'),
('max_login_attempts', '5'), ('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`, 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`, `last_run`, `next_run`, `run_interval`, `log_enabled`, `log_file`, `log_sql_queries`,
`disable_board`, `run_counter`) `disable_board`, `run_counter`)
VALUES ('1', 'Attach maintenance', 'attach_maintenance.php', 'daily', '', '05:00:00', '40', '', '', '', '1', '', '0', VALUES ('1', 'Board maintenance', 'board_maintenance.php', 'daily', '', '05:00:00', '40', '', '', '', '1', '', '0', '1',
'1', '0'),
('1', 'Board maintenance', 'board_maintenance.php', 'daily', '', '05:00:00', '40', '', '', '', '1', '', '0', '1',
'0'), '0'),
('1', 'Prune forums', 'prune_forums.php', 'daily', '', '05:00:00', '50', '', '', '', '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', '', ('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 -- 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` -- Table structure for `bb_forums`
-- ---------------------------- -- ----------------------------
@ -917,7 +722,6 @@ CREATE TABLE IF NOT EXISTS `bb_posts`
`post_username` VARCHAR(25) NOT NULL DEFAULT '', `post_username` VARCHAR(25) NOT NULL DEFAULT '',
`post_edit_time` INT(11) NOT NULL DEFAULT '0', `post_edit_time` INT(11) NOT NULL DEFAULT '0',
`post_edit_count` SMALLINT(5) UNSIGNED 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', `user_post` TINYINT(1) NOT NULL DEFAULT '1',
`mc_comment` TEXT NOT NULL DEFAULT '', `mc_comment` TEXT NOT NULL DEFAULT '',
`mc_type` TINYINT(1) NOT NULL DEFAULT '0', `mc_type` TINYINT(1) NOT NULL DEFAULT '0',
@ -935,7 +739,7 @@ CREATE TABLE IF NOT EXISTS `bb_posts`
-- Records of bb_posts -- Records of bb_posts
-- ---------------------------- -- ----------------------------
INSERT INTO `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` -- Table structure for `bb_posts_html`
@ -1034,28 +838,6 @@ CREATE TABLE IF NOT EXISTS `bb_privmsgs_text`
-- Records of 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` -- 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_first_post_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
`topic_last_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_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', `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_last_post_time` INT(11) NOT NULL DEFAULT '0',
`topic_show_first_post` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0', `topic_show_first_post` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`topic_id`), PRIMARY KEY (`topic_id`),
@ -1265,27 +1049,7 @@ CREATE TABLE IF NOT EXISTS `bb_topics`
INSERT INTO `bb_topics` INSERT INTO `bb_topics`
VALUES ('1', '1', 'Добро пожаловать в TorrentPier Bison', '2', UNIX_TIMESTAMP(), '0', '0', '0', '0', '0', '1', '1', '0', VALUES ('1', '1', 'Добро пожаловать в TorrentPier Bison', '2', UNIX_TIMESTAMP(), '0', '0', '0', '0', '0', '1', '1', '0',
'0', '0',
'0', UNIX_TIMESTAMP(), '0'); '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
-- ----------------------------
-- ---------------------------- -- ----------------------------
-- Table structure for `bb_topic_tpl` -- Table structure for `bb_topic_tpl`

View file

@ -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_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 ''; 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'; 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`;

View file

@ -13,11 +13,11 @@ if (!defined('IN_AJAX')) {
global $userdata, $bb_cfg, $lang; global $userdata, $bb_cfg, $lang;
if (!isset($this->request['attach_id'])) { if (!isset($this->request['topic_id'])) {
$this->ajax_die($lang['EMPTY_ATTACH_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']; $mode = (string)$this->request['mode'];
if ($bb_cfg['tor_comment']) { if ($bb_cfg['tor_comment']) {
@ -26,11 +26,11 @@ if ($bb_cfg['tor_comment']) {
$tor = DB()->fetch_row(" $tor = DB()->fetch_row("
SELECT 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 FROM " . BB_BT_TORRENTS . " tor
INNER JOIN " . BB_FORUMS . " f ON(f.forum_id = tor.forum_id) INNER JOIN " . BB_FORUMS . " f ON(f.forum_id = tor.forum_id)
INNER JOIN " . BB_TOPICS . " t ON(t.topic_id = tor.topic_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 LIMIT 1
"); ");
@ -68,7 +68,7 @@ switch ($mode) {
if (!IS_ADMIN) { if (!IS_ADMIN) {
$this->verify_mod_rights($tor['forum_id']); $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 { } else {
$this->verify_mod_rights($tor['forum_id']); $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] . ' <b> ' . $lang['TOR_STATUS_NAME'][$new_status] . '</b> &middot; ' . profile_url($userdata) . ' &middot; <i>' . delta_time(TIMENOW) . $lang['TOR_BACK'] . '</i>'; $this->response['status'] = $bb_cfg['tor_icons'][$new_status] . ' <b> ' . $lang['TOR_STATUS_NAME'][$new_status] . '</b> &middot; ' . profile_url($userdata) . ' &middot; <i>' . delta_time(TIMENOW) . $lang['TOR_BACK'] . '</i>';
@ -108,7 +108,7 @@ switch ($mode) {
} }
$subject = sprintf($lang['TOR_AUTH_TITLE'], $tor['topic_title']); $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']) { if ($comment && $comment != $lang['COMMENT']) {
$message .= "\n\n[b]" . $lang['COMMENT'] . '[/b]: ' . $comment; $message .= "\n\n[b]" . $lang['COMMENT'] . '[/b]: ' . $comment;
@ -119,4 +119,4 @@ switch ($mode) {
break; break;
} }
$this->response['attach_id'] = $attach_id; $this->response['topic_id'] = $topic_id;

View file

@ -13,51 +13,22 @@ if (!defined('IN_AJAX')) {
global $userdata, $bb_cfg, $lang; global $userdata, $bb_cfg, $lang;
if (!isset($this->request['attach_id'])) { if (!isset($this->request['t'])) {
$this->ajax_die($lang['EMPTY_ATTACH_ID']); $this->ajax_die($lang['EMPTY_ATTACH_ID']);
} }
if (!isset($this->request['type'])) { 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']; $type = (string)$this->request['type'];
$torrent = DB()->fetch_row(" if (!IS_AM) {
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) {
$this->ajax_die($lang['ONLY_FOR_MOD']); $this->ajax_die($lang['ONLY_FOR_MOD']);
} }
$title = $url = ''; $title = $url = '';
switch ($type) { switch ($type) {
case 'set_gold': case 'set_gold':
case 'set_silver': case 'set_silver':
@ -69,35 +40,35 @@ switch ($type) {
} else { } else {
$tor_type = 0; $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']; $title = $lang['CHANGE_TOR_TYPE'];
$url = make_url(TOPIC_URL . $torrent['topic_id']); $url = make_url(TOPIC_URL . $topic_id);
break; break;
case 'reg': case 'reg':
\TorrentPier\Legacy\Torrent::tracker_register($attach_id); \TorrentPier\Legacy\Torrent::tracker_register($topic_id);
$url = (TOPIC_URL . $torrent['topic_id']); $url = (TOPIC_URL . $topic_id);
break; break;
case 'unreg': case 'unreg':
\TorrentPier\Legacy\Torrent::tracker_unregister($attach_id); \TorrentPier\Legacy\Torrent::tracker_unregister($topic_id);
$url = (TOPIC_URL . $torrent['topic_id']); $url = (TOPIC_URL . $topic_id);
break; break;
case 'del_torrent': case 'del_torrent':
if (empty($this->request['confirmed'])) { if (empty($this->request['confirmed'])) {
$this->prompt_for_confirm($lang['DEL_TORRENT']); $this->prompt_for_confirm($lang['DEL_TORRENT']);
} }
\TorrentPier\Legacy\Torrent::delete_torrent($attach_id); \TorrentPier\Legacy\Torrent::delete_torrent($topic_id);
$url = make_url(TOPIC_URL . $torrent['topic_id']); $url = make_url(TOPIC_URL . $topic_id);
break; break;
case 'del_torrent_move_topic': case 'del_torrent_move_topic':
if (empty($this->request['confirmed'])) { if (empty($this->request['confirmed'])) {
$this->prompt_for_confirm($lang['DEL_MOVE_TORRENT']); $this->prompt_for_confirm($lang['DEL_MOVE_TORRENT']);
} }
\TorrentPier\Legacy\Torrent::delete_torrent($attach_id); \TorrentPier\Legacy\Torrent::delete_torrent($topic_id);
$url = make_url("modcp.php?t={$torrent['topic_id']}&mode=move&sid={$userdata['session_id']}"); $url = make_url("modcp.php?t=$topic_id&mode=move");
break; break;
} }

View file

@ -25,13 +25,13 @@ switch ($mode) {
$this->ajax_die($lang['STATUS_DOES_EXIST'] . $new_status); $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) { foreach ($topic_ids as $topic_id) {
\TorrentPier\Legacy\Torrent::change_tor_status($attach_id, $status); \TorrentPier\Legacy\Torrent::change_tor_status($topic_id, $status);
} }
$this->response['status'] = $bb_cfg['tor_icons'][$status]; $this->response['status'] = $bb_cfg['tor_icons'][$status];
$this->response['topics'] = explode(',', $topics); $this->response['topics'] = $topic_ids;
break; break;
case 'edit_topic_title': case 'edit_topic_title':
@ -53,7 +53,7 @@ switch ($mode) {
$topic_title_sql = DB()->escape($new_title); $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'])); $news_forums = array_flip(explode(',', $bb_cfg['latest_news_forum_id']));

View file

@ -110,7 +110,7 @@ switch ($this->request['type']) {
$message = htmlCHR($message, false, ENT_NOQUOTES); $message = htmlCHR($message, false, ENT_NOQUOTES);
$this->response['message_html'] = bbcode2html($message); $this->response['message_html'] = bbcode2html($message);
$this->response['res_id'] = @$this->request['res_id']; $this->response['res_id'] = $this->request['res_id'];
break; break;
case 'edit': case 'edit':
@ -121,7 +121,7 @@ switch ($this->request['type']) {
if ($post['poster_id'] != $userdata['user_id'] && !$is_auth['auth_mod']) { if ($post['poster_id'] != $userdata['user_id'] && !$is_auth['auth_mod']) {
$this->ajax_die($lang['EDIT_OWN_POSTS']); $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); $this->response['redirect'] = make_url(POSTING_URL . '?mode=editpost&p=' . $post_id);
} elseif ($this->request['type'] == 'editor') { } elseif ($this->request['type'] == 'editor') {
$text = (string)$this->request['text']; $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'])); $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']) { 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_text = str_replace('\n', "\n", $text);
$s_topic_title = str_replace('\n', "\n", $post['topic_title']); $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']}"; $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"; $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 ($userdata['user_level'] == USER) {
if (TIMENOW - $row['last_post_time'] < $bb_cfg['flood_interval']) { if (TIMENOW - $row['last_post_time'] < $bb_cfg['flood_interval']) {
$this->ajax_die($lang['FLOOD_ERROR']); $this->ajax_die($lang['FLOOD_ERROR']);
@ -281,11 +281,6 @@ switch ($this->request['type']) {
'post_text' => $message, '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 feed
update_atom('topic', (int)$this->request['topic_id']); update_atom('topic', (int)$this->request['topic_id']);

View file

@ -13,20 +13,17 @@ if (!defined('IN_AJAX')) {
global $lang; global $lang;
if (!isset($this->request['attach_id'])) { if (!isset($this->request['t'])) {
$this->ajax_die($lang['EMPTY_ATTACH_ID']); $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) { $file_path = get_attach_path($topic_id, 8);
$this->ajax_die($lang['ERROR_BUILD']);
}
$filename = get_attachments_dir() . '/' . $torrent['physical_filename']; if (file_exists($file_path) && !$file_contents = file_get_contents($file_path)) {
if (file_exists($filename) && !$file_contents = file_get_contents($filename)) {
if (IS_AM) { 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 { } else {
$this->ajax_die($lang['ERROR_NO_ATTACHMENT']); $this->ajax_die($lang['ERROR_NO_ATTACHMENT']);
} }

View file

@ -8,10 +8,8 @@
*/ */
define('BB_SCRIPT', 'posting'); define('BB_SCRIPT', 'posting');
define('BB_ROOT', './');
require __DIR__ . '/common.php'; require __DIR__ . '/common.php';
require INC_DIR . '/bbcode.php'; require INC_DIR . '/bbcode.php';
require ATTACH_DIR . '/attachment_mod.php';
$page_cfg['load_tpl_vars'] = array('post_icons'); $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']); bb_die($lang['NO_SUCH_POST']);
} }
// The user is not authed, if they're not logged in then redirect $bb_cfg['attach']['allowed_ext'] = ($post_info['allow_reg_tracker']) ? $bb_cfg['tor_forums_allowed_ext'] : $bb_cfg['gen_forums_allowed_ext'];
// them, else show them an error message $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_auth[$is_auth_type]) {
if (!IS_GUEST) { if (!IS_GUEST) {
bb_die(sprintf($lang['SORRY_' . strtoupper($is_auth_type)], $is_auth[$is_auth_type . '_type'])); bb_die(sprintf($lang['SORRY_' . strtoupper($is_auth_type)], $is_auth[$is_auth_type . '_type']));
@ -245,26 +244,13 @@ if ($mode == 'new_rel') {
exit; 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']); $update_post_time = !empty($_POST['update_post_time']);
execute_posting_attachment_handling();
// если за время пока вы писали ответ, в топике появились новые сообщения, перед тем как ваше сообщение будет отправлено, выводится предупреждение с обзором этих сообщений // если за время пока вы писали ответ, в топике появились новые сообщения, перед тем как ваше сообщение будет отправлено, выводится предупреждение с обзором этих сообщений
$topic_has_new_posts = false; $topic_has_new_posts = false;
if (!IS_GUEST && $mode != 'newtopic' && ($submit || $preview || $mode == 'quote' || $mode == 'reply') && isset($_COOKIE[COOKIE_TOPIC])) { 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 $sql = "SELECT p.*, pt.post_text, u.username, u.user_rank
FROM " . BB_POSTS . " p, " . BB_POSTS_TEXT . " pt, " . BB_USERS . " u FROM " . BB_POSTS . " p, " . BB_POSTS_TEXT . " pt, " . BB_USERS . " u
WHERE p.topic_id = " . (int)$topic_id . " 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']; $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); \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') { if ($mode == 'newtopic' || $mode == 'reply') {
set_tracks(COOKIE_TOPIC, $tracking_topics, $topic_id); 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 (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 (!DB()->fetch_row("SELECT attach_id FROM " . BB_BT_TORRENTS . " WHERE attach_id = " . TORRENT_ATTACH_ID)) {
if ($bb_cfg['premod']) { if ($bb_cfg['premod']) {
@ -529,7 +513,7 @@ if ($mode == 'newtopic' || ($mode == 'editpost' && $post_data['first_post'])) {
//bt //bt
$topic_dl_type = $post_info['topic_dl_type'] ?? 0; $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 = " $sql = "
SELECT tor.attach_id SELECT tor.attach_id
FROM " . BB_POSTS . " p FROM " . BB_POSTS . " p
@ -557,7 +541,7 @@ if ($post_info['allow_reg_tracker'] && $post_data['first_post'] && ($topic_dl_ty
$topic_type_toggle .= '<nobr><input type="checkbox" name="' . $dl_type_name . '" id="topic_dl_type_id" ' . $dl_ds . $dl_ch . ' /><label for="topic_dl_type_id"> ' . $lang['POST_DOWNLOAD'] . '</label></nobr>'; $topic_type_toggle .= '<nobr><input type="checkbox" name="' . $dl_type_name . '" id="topic_dl_type_id" ' . $dl_ds . $dl_ch . ' /><label for="topic_dl_type_id"> ' . $lang['POST_DOWNLOAD'] . '</label></nobr>';
$topic_type_toggle .= $dl_hid; $topic_type_toggle .= $dl_hid;
} }
} }**/
//bt end //bt end
// Get poster release group data // Get poster release group data
@ -603,7 +587,6 @@ $template->set_filenames(array(
'body' => 'posting.tpl', 'body' => 'posting.tpl',
)); ));
// Output the data to the template
$template->assign_vars(array( $template->assign_vars(array(
'FORUM_NAME' => htmlCHR($forum_name), 'FORUM_NAME' => htmlCHR($forum_name),
'PAGE_TITLE' => $page_title, 'PAGE_TITLE' => $page_title,
@ -620,9 +603,8 @@ $template->assign_vars(array(
'POSTER_RGROUPS' => isset($poster_rgroups) && !empty($poster_rgroups) ? $poster_rgroups : '', 'POSTER_RGROUPS' => isset($poster_rgroups) && !empty($poster_rgroups) ? $poster_rgroups : '',
'ATTACH_RG_SIG' => ($switch_rg_sig) ?: false, 'ATTACH_RG_SIG' => ($switch_rg_sig) ?: false,
'U_VIEWTOPIC' => ($mode == 'reply') ? "viewtopic.php?" . POST_TOPIC_URL . "=$topic_id&amp;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_TYPE_TOGGLE' => $topic_type_toggle,
'S_TOPIC_ID' => $topic_id, 'S_TOPIC_ID' => $topic_id,
'S_POST_ACTION' => POSTING_URL, 'S_POST_ACTION' => POSTING_URL,

View file

@ -8,7 +8,6 @@
*/ */
define('BB_SCRIPT', 'search'); define('BB_SCRIPT', 'search');
define('BB_ROOT', './');
require __DIR__ . '/common.php'; require __DIR__ . '/common.php';
require INC_DIR . '/bbcode.php'; require INC_DIR . '/bbcode.php';
@ -30,7 +29,7 @@ if (isset($_POST['del_my_post'])) {
<a href="index.php">' . $lang['INDEX_RETURN'] . '</a> <a href="index.php">' . $lang['INDEX_RETURN'] . '</a>
'); ');
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']); bb_die($lang['NONE_SELECTED']);
} }
@ -794,16 +793,16 @@ else {
'FORUM_ID' => $forum_id, 'FORUM_ID' => $forum_id,
'FORUM_NAME' => $forum_name_html[$forum_id], 'FORUM_NAME' => $forum_name_html[$forum_id],
'TOPIC_ID' => $topic_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']), 'TOPIC_TITLE' => wbr($topic['topic_title']),
'IS_UNREAD' => $is_unread, 'IS_UNREAD' => $is_unread,
'TOPIC_ICON' => get_topic_icon($topic, $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'], 'REPLIES' => $topic['topic_replies'],
'ATTACH' => $topic['topic_attachment'], 'ATTACH' => $topic['attach_ext_id'],
'STATUS' => $topic['topic_status'], 'STATUS' => $topic['topic_status'],
'TYPE' => $topic['topic_type'], 'TYPE' => $topic['topic_type'],
'DL' => ($topic['topic_dl_type'] == TOPIC_DL_TYPE_DL), 'DL' => $topic['tracker_status'] ?? null,
'POLL' => $topic['topic_vote'], 'POLL' => $topic['topic_vote'],
'DL_CLASS' => isset($topic['dl_status']) ? $dl_link_css[$topic['dl_status']] : '', 'DL_CLASS' => isset($topic['dl_status']) ? $dl_link_css[$topic['dl_status']] : '',

View file

@ -107,7 +107,6 @@ class Common
topic_first_post_id INT UNSIGNED NOT NULL DEFAULT '0', topic_first_post_id INT UNSIGNED NOT NULL DEFAULT '0',
topic_last_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_last_post_time INT UNSIGNED NOT NULL DEFAULT '0',
topic_attachment INT UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (topic_id) PRIMARY KEY (topic_id)
) ENGINE = MEMORY ) ENGINE = MEMORY
"); ");
@ -122,11 +121,9 @@ class Common
COUNT(p.post_id) AS total_posts, COUNT(p.post_id) AS total_posts,
MIN(p.post_id) AS topic_first_post_id, MIN(p.post_id) AS topic_first_post_id,
MAX(p.post_id) AS topic_last_post_id, MAX(p.post_id) AS topic_last_post_id,
MAX(p.post_time) AS topic_last_post_time, MAX(p.post_time) AS topic_last_post_time
IF(MAX(a.attach_id), 1, 0) AS topic_attachment
FROM " . BB_TOPICS . " t FROM " . BB_TOPICS . " t
LEFT JOIN " . BB_POSTS . " p ON(p.topic_id = t.topic_id) 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 t.topic_status != " . TOPIC_MOVED . "
$where_sql $where_sql
GROUP BY t.topic_id GROUP BY t.topic_id
@ -139,8 +136,7 @@ class Common
t.topic_replies = tmp.total_posts - 1, t.topic_replies = tmp.total_posts - 1,
t.topic_first_post_id = tmp.topic_first_post_id, t.topic_first_post_id = tmp.topic_first_post_id,
t.topic_last_post_id = tmp.topic_last_post_id, t.topic_last_post_id = tmp.topic_last_post_id,
t.topic_last_post_time = tmp.topic_last_post_time, t.topic_last_post_time = tmp.topic_last_post_time
t.topic_attachment = tmp.topic_attachment
WHERE WHERE
t.topic_id = tmp.topic_id t.topic_id = tmp.topic_id
"); ");
@ -157,7 +153,7 @@ class Common
$all_users = ($id === 'all'); $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; break;
} }
@ -222,7 +218,7 @@ class Common
$topic_csv = []; $topic_csv = [];
$prune = ($mode_or_topic_id === 'prune'); $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; return false;
} }
@ -325,31 +321,6 @@ class Common
LEFT JOIN " . BB_POLL_USERS . " pu USING(topic_id) 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) // Delete posts, posts_text, attachments (from DB)
DB()->query(" DB()->query("
DELETE p, pt, ps, a, d, ph 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_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_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_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(" DB()->query("
DELETE t, tw DELETE t
FROM " . $tmp_delete_topics . " del FROM " . $tmp_delete_topics . " del
LEFT JOIN " . BB_TOPICS . " t USING(topic_id) LEFT JOIN " . BB_TOPICS . " t USING(topic_id)
LEFT JOIN " . BB_TOPICS_WATCH . " tw USING(topic_id)
"); ");
// Delete topic moved stubs // 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; return false;
} }
@ -621,30 +589,7 @@ class Common
return 0; return 0;
} }
// Delete attachments (from disk) // Delete posts, posts_text (from DB)
$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)
DB()->query(" DB()->query("
DELETE p, pt, ps, tor, a, d, ph DELETE p, pt, ps, tor, a, d, ph
FROM " . $tmp_delete_posts . " del 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_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_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_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 // Log action
@ -729,18 +672,15 @@ class Common
FROM " . BB_USER_GROUP . " ug 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_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_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) WHERE ug.user_id IN($user_csv)
"); ");
DB()->query(" DB()->query("
DELETE u, ban, pu, s, tw, asn DELETE u, ban, pu, s, asn
FROM " . BB_USERS . " u FROM " . BB_USERS . " u
LEFT JOIN " . BB_BANLIST . " ban ON(ban.ban_userid = u.user_id) 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_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_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) LEFT JOIN " . BB_AUTH_ACCESS_SNAP . " asn ON(asn.user_id = u.user_id)
WHERE u.user_id IN($user_csv) WHERE u.user_id IN($user_csv)
"); ");

View file

@ -136,11 +136,11 @@ class Post
} }
if ($mode == 'newtopic' || ($mode == 'editpost' && $post_data['first_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 = " $sql_insert = "
INSERT INTO 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 VALUES
('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_dl_type) ('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_dl_type)
"; ";
@ -151,7 +151,7 @@ class Post
SET SET
topic_title = '$post_subject', topic_title = '$post_subject',
topic_type = $topic_type, topic_type = $topic_type,
topic_dl_type = $topic_dl_type tracker_status = $topic_dl_type
WHERE WHERE
topic_id = $topic_id topic_id = $topic_id
"; ";
@ -172,7 +172,7 @@ class Post
if ($update_post_time && $mode == 'editpost' && $post_data['last_post'] && !$post_data['first_post']) { if ($update_post_time && $mode == 'editpost' && $post_data['last_post'] && !$post_data['first_post']) {
$edited_sql .= ", post_time = $current_time "; $edited_sql .= ", post_time = $current_time ";
//lpt //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"; $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); 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 * Insert post to the existing thread
* *

View file

@ -15,80 +15,40 @@ namespace TorrentPier\Legacy;
*/ */
class Torrent 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 * Check that user has access to torrent download
* *
* @param int $forum_id * @param int $forum_id
* @param int $poster_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) { if (IS_ADMIN || $userdata['user_id'] == $poster_id) {
return true; return;
} }
$is_auth = auth(AUTH_ALL, $forum_id, $userdata); if (IS_MOD)
{
if ($poster_id != $userdata['user_id'] && !$is_auth['auth_mod']) { $is_auth = auth(AUTH_MOD, $forum_id, $userdata);
bb_die($lang['NOT_MODERATOR']); if ($is_auth['auth_mod']) {
} elseif (!$is_auth['auth_view'] || !$is_auth['auth_attachments'] || $attach_config['disable_mod']) { return;
bb_die(sprintf($lang['SORRY_AUTH_READ'], $is_auth['auth_read_type'])); }
} }
return $is_auth;
bb_die($lang['NOT_AUTHORISED']);
} }
/** /**
* Unregister torrent from tracker * Unregister torrent from tracker
* *
* @param int $attach_id * @param int $topic_id
* @param string $mode * @param string $mode
*/ */
public static function tracker_unregister($attach_id, $mode = '') public static function tracker_unregister($topic_id, $mode = '')
{ {
global $lang, $bb_cfg; global $lang, $bb_cfg;
@ -148,18 +108,11 @@ class Torrent
} }
// Delete 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)) { if (!DB()->sql_query($sql)) {
bb_die('Could not delete torrent from torrents table'); 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') { if ($mode == 'request') {
set_die_append_msg($forum_id, $topic_id); set_die_append_msg($forum_id, $topic_id);
@ -264,22 +217,21 @@ class Torrent
/** /**
* Register torrent on tracker * Register torrent on tracker
* *
* @param int $attach_id * @param int $topic_id
* @param string $mode * @param string $mode
* @param int $tor_status * @param int $tor_status
* @param int $reg_time * @param int $reg_time
* *
* @return bool * @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; global $bb_cfg, $lang, $reg_mode;
$announce_urls = []; $announce_urls = [];
$attach_id = (int)$attach_id;
$reg_mode = $mode; $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']); bb_die($lang['TOR_NOT_FOUND']);
} }
@ -374,8 +326,8 @@ class Torrent
$size = sprintf('%.0f', (float)$totallen); $size = sprintf('%.0f', (float)$totallen);
$columns = ' info_hash, 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, $attach_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)"; $sql = "INSERT INTO " . BB_BT_TORRENTS . " ($columns) VALUES ($values)";
@ -390,13 +342,6 @@ class Torrent
bb_die('Could not register torrent on tracker'); 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 // set DL-Type for topic
if ($bb_cfg['bt_set_dltype_on_tor_reg']) { 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"; $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') { if ($reg_mode == 'request' || $reg_mode == 'newtopic') {
set_die_append_msg($forum_id, $topic_id); set_die_append_msg($forum_id, $topic_id);
$mess = sprintf($lang['BT_REGISTERED'], DL_URL . $attach_id); bb_die(sprintf($lang['BT_REGISTERED'], DL_URL . $topic_id));
bb_die($mess);
} }
return true; return true;
@ -422,42 +366,21 @@ class Torrent
/** /**
* Set passkey and send torrent to the browser * 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; global $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 = ''; $post_id = $poster_id = $passkey_val = '';
$topic_id = $t_data['topic_id'];
$poster_id = $t_data['topic_poster'];
$user_id = $userdata['user_id']; $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 if (!isset($row['tor_status'])) {
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']); 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']; $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 ($min_ratio && $user_id != $poster_id && ($user_ratio = get_bt_ratio($bt_userdata)) !== null) {
@ -495,6 +418,10 @@ class Torrent
// Announce URL // Announce URL
$ann_url = $bb_cfg['bt_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); $file_contents = file_get_contents($filename);
if (!$tor = \Rych\Bencode\Bencode::decode($file_contents)) { if (!$tor = \Rych\Bencode\Bencode::decode($file_contents)) {
bb_die('This is not a bencoded file'); bb_die('This is not a bencoded file');
@ -598,7 +525,7 @@ class Torrent
} }
// Update // 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) { if (DB()->affected_rows() == 1) {
// Ocelot // Ocelot
if ($bb_cfg['ocelot']['enabled']) { if ($bb_cfg['ocelot']['enabled']) {

View file

@ -174,4 +174,10 @@
</form> </form>
<br clear="all" /> <br />
<p class="med tCenter"><b>Для выделения нескольких форумов, отмечайте их с нажатой клавишей <i>Ctrl</i></b></p>
<p class="med bCenter w85">Для того чтобы правильно показывалась иерархия разделов/подразделов в списке на странице "Трекер", во всех корневых разделах должна быть разрешена регистрация торрентов если в каком-то их подразделе она тоже разрешена, иначе корневой раздел в этот список не попадает и структура списка будет выглядеть неправильно (подразделы одного корневого раздела "попадут" в другой)</p>
<br />

View file

@ -34,7 +34,7 @@
</tr> </tr>
<tr> <tr>
<td colspan="2" class="row1 tCenter"> <td colspan="2" class="row1 tCenter">
<p>{L_PRUNE_TOPICS_NOT_POSTED} <input class="post" type="text" name="prunedays" size="4" /> {L_DAYS}</p> <p>{L_PRUNE_TOPICS_NOT_POSTED} <input class="post" type="text" name="prunedays" size="4" /> {L_DAYS}<sup>1</sup></p>
<p class="med"><label><input class="post" type="checkbox" name="prune_all_topic_types" value="1" />{L_DELETE_ALL_TOPICS}</label></p> <p class="med"><label><input class="post" type="checkbox" name="prune_all_topic_types" value="1" />{L_DELETE_ALL_TOPICS}</label></p>
</td> </td>
</tr> </tr>
@ -46,3 +46,11 @@
</table> </table>
</form> </form>
<br />
<div class="med">
<p><sup>1</sup> Если вы не введёте число, то будут удалены <b>все темы</b>.</p>
</div>
<br />

View file

@ -58,8 +58,7 @@
<form action="{S_POST_ACTION}" method="post" name="post" onsubmit="if(checkForm(this)){ dis_submit_btn(); }else{ return false; }" {S_FORM_ENCTYPE}> <form action="{S_POST_ACTION}" method="post" name="post" onsubmit="if(checkForm(this)){ dis_submit_btn(); }else{ return false; }" {S_FORM_ENCTYPE}>
{S_HIDDEN_FORM_FIELDS} {S_HIDDEN_FORM_FIELDS}
{ADD_ATTACH_HIDDEN_FIELDS} <!-- IF TOR_REQUIRED --><input type="hidden" name="tor_required" value="1" /><!-- ENDIF -->
{POSTED_ATTACHMENTS_HIDDEN_FIELDS}
<table class="bordered"> <table class="bordered">
<col class="row1"> <col class="row1">
@ -136,7 +135,6 @@
</div> </div>
</td> </td>
</tr> </tr>
<!-- IF ATTACHBOX -->
<!-- IF POSTER_RGROUPS --> <!-- IF POSTER_RGROUPS -->
<tr> <tr>
<td class="vTop pad_4" valign="top"><b>{L_POST_RELEASE_FROM_GROUP}</b></td> <td class="vTop pad_4" valign="top"><b>{L_POST_RELEASE_FROM_GROUP}</b></td>
@ -149,18 +147,75 @@
</td> </td>
</tr> </tr>
<!-- ENDIF / POSTER_RGROUPS --> <!-- ENDIF / POSTER_RGROUPS -->
<!-- ENDIF / ATTACHBOX -->
<!-- ENDIF / LOGGED_IN --> <!-- ENDIF / LOGGED_IN -->
<!-- BEGIN switch_type_toggle --> <!-- BEGIN switch_type_toggle -->
<tr> <tr>
<td colspan="2" class="row2 tCenter pad_6">{S_TYPE_TOGGLE}</td> <td colspan="2" class="row2 tCenter pad_6">{S_TYPE_TOGGLE}</td>
</tr> </tr>
<!-- END switch_type_toggle --> <!-- END switch_type_toggle -->
<!-- IF ATTACHBOX --><!-- INCLUDE posting_attach.tpl --><!-- ENDIF -->
</table> </table>
</form> </form>
<!-- IF SHOW_ATTACH -->
<div style="display: none;">
<div id="file-up-input">
<input type="hidden" name="MAX_FILE_SIZE" value="{$bb_cfg['attach']['max_size']}" />
<input type="file" name="attach" size="50" id="file-up-btn" />
&nbsp;
<a href="#" class="med" onclick="show_load_file_link(); return false;">удалить</a>
</div>
<div id="file-up-new">
<a id="file-up-a" href="#" class="med bold" onclick="show_file_up_input(); return false;">загрузить файл</a>&nbsp;
</div>
<div id="file-up-del">
<a href="#" class="med bold" onclick="if (window.confirm(this.innerHTML+'?')){ ajax.del_attach() } return false;">удалить прикреплённый файл</a>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
<!-- IF FILE_ATTACHED -->
$('#file-up-box').html( $('#file-up-del').html() );
<!-- ELSE -->
show_load_file_link();
<!-- ENDIF -->
$('#file-up').show();
$('#post-preview-btn').click(function(){
if ( $('#file-up-btn').val() ) {
return window.confirm('Вы можете прикрепить файл только вместе с отправкой сообщения.\n\nОтменить загрузку файла?\n ');
}
});
});
function show_load_file_link ()
{
$('#file-up-box').html( $('#file-up-new').html() );
$('#file-up-desc').show();
}
function show_file_up_input ()
{
$('#file-up-box').html( $('#file-up-input').html() );
$('#file-up-desc').html('выберите нужный файл, он будет загружен автоматически при отправке сообщения');
}
ajax.del_attach = function() {
ajax.exec({
action : 'del_attach',
topic_id : '{POSTING_TOPIC_ID}'
});
};
ajax.callback.del_attach = function(data){
show_load_file_link();
}
</script>
<!-- ENDIF / SHOW_ATTACH -->
<!-- IF TPL_TOPIC_REVIEW --> <!-- IF TPL_TOPIC_REVIEW -->
<!--========================================================================--> <!--========================================================================-->

View file

@ -104,6 +104,16 @@ ajax.callback.posts = function(data) {
onkeyup = "storeCaret(this);" onkeyup = "storeCaret(this);"
>{MESSAGE}</textarea> >{MESSAGE}</textarea>
<!-- IF SHOW_ATTACH -->
<div id="file-up" style="display: none;">
<div id="file-up-box"></div>
<div id="file-up-desc" class="small" style="display: none;">максимальный размер: <b>{ATTACH_MAX_SIZE}</b>, файлы: <b>{ALLOWED_EXT}</b></div>
<!-- IF TOR_ATTACHED && AUTH_MOD -->
<a href="#" class="med bold" onclick="if (window.confirm(this.innerHTML+'?')){ ajax.del_attach() } return false;">удалить прикреплённый файл</a>
<!-- ENDIF -->
</div>
<!-- ENDIF -->
<div class="mrg_8 tCenter"> <div class="mrg_8 tCenter">
<div id="post-buttons-block" style="display: none;"> <div id="post-buttons-block" style="display: none;">
<div class="pad_4" align="center">{CAPTCHA_HTML}</div> <div class="pad_4" align="center">{CAPTCHA_HTML}</div>
@ -130,6 +140,14 @@ function debounce (el_id, time_ms)
} }
$('#post-submit-btn').click(function(event){ $('#post-submit-btn').click(function(event){
<!-- IF TOR_REQUIRED -->
if ( $('#file-up-btn').val() === '' ) {
event.stopPropagation();
alert('Вы забыли прикрепить торрент файл (кликните "загрузить файл")');
$('#file-up-a').removeClass('med').addClass('adm').animate({fontSize: '24px'}, 200).animate({fontSize: '16px'}, 200);
return false;
}
<!-- ENDIF / TOR_REQUIRED -->
$('#post-submit-btn').after('<input id="post-submit" type="hidden" name="post" value="1" />'); $('#post-submit-btn').after('<input id="post-submit" type="hidden" name="post" value="1" />');
}); });
$('#post-js-warn').hide(); $('#post-js-warn').hide();

View file

@ -2,15 +2,15 @@
<script type="text/javascript"> <script type="text/javascript">
ajax.openedPosts = {}; ajax.openedPosts = {};
ajax.view_post = function(post_id, src) { ajax.view_post = function(topic_id, src) {
if (!ajax.openedPosts[post_id]) { if (!ajax.openedPosts[topic_id]) {
ajax.exec({ ajax.exec({
action : 'view_post', action : 'view_post',
post_id : post_id topic_id : topic_id
}); });
} }
else { else {
var $post = $('#post_'+post_id); var $post = $('#post_'+topic_id);
if ($post.is(':visible')) { if ($post.is(':visible')) {
$post.hide(); $post.hide();
} else { } else {
@ -21,29 +21,29 @@ ajax.view_post = function(post_id, src) {
}; };
ajax.callback.view_post = function(data) { ajax.callback.view_post = function(data) {
var post_id = data.post_id; var topic_id = data.topic_id;
var $tor = $('#tor_'+post_id); var $tor = $('#tor_'+topic_id);
window.location.href='#tor_'+post_id; window.location.href='#tor_'+topic_id;
$('#post-row tr') $('#post-row tr')
.clone() .clone()
.attr({ id: 'post_'+post_id }) .attr({ id: 'post_'+topic_id })
.find('div.post_body').html(data.post_html).end() .find('div.post_body').html(data.post_html).end()
.find('a.tLink').attr({ href: $('a.tLink', $tor).attr('href') }).end() .find('a.tLink').attr({ href: $('a.tLink', $tor).attr('href') }).end()
.find('a.dLink').attr({ href: $('a.tr-dl', $tor).attr('href') }).end() .find('a.dLink').attr({ href: $('a.tr-dl', $tor).attr('href') }).end()
.insertAfter($tor) .insertAfter($tor)
; ;
initPostBBCode('#post_'+post_id); initPostBBCode('#post_'+topic_id);
var maxH = screen.height - 290; var maxH = screen.height - 290;
var maxW = screen.width - 60; var maxW = screen.width - 60;
var $post = $('div.post_wrap', $('#post_'+post_id)); var $post = $('div.post_wrap', $('#post_'+topic_id));
var $links = $('div.post_links', $('#post_'+post_id)); var $links = $('div.post_links', $('#post_'+topic_id));
$post.css({ maxWidth: maxW, maxHeight: maxH }); $post.css({ maxWidth: maxW, maxHeight: maxH });
$links.css({ maxWidth: maxW }); $links.css({ maxWidth: maxW });
if ($.browser.msie) { if ($.browser.msie) {
if ($post.height() > maxH) { $post.height(maxH); } if ($post.height() > maxH) { $post.height(maxH); }
if ($post.width() > maxW) { $post.width(maxW); $links.width(maxW); } if ($post.width() > maxW) { $post.width(maxW); $links.width(maxW); }
} }
ajax.openedPosts[post_id] = true; ajax.openedPosts[topic_id] = true;
}; };
</script> </script>
@ -181,7 +181,7 @@ $(function(){
<th class="thHead">{L_TOR_SEARCH_TITLE}</th> <th class="thHead">{L_TOR_SEARCH_TITLE}</th>
</tr> </tr>
<tr> <tr>
<td class="row4" style="padding: 4px";> <td class="row4" style="padding: 4px;">
<table class="fieldsets borderless bCenter pad_0" cellspacing="0"> <table class="fieldsets borderless bCenter pad_0" cellspacing="0">
<tr> <tr>
@ -238,7 +238,7 @@ $(function(){
/>&nbsp;{L_HIDE_CONTENTS} />&nbsp;{L_HIDE_CONTENTS}
</label> </label>
</p> </p>
<!-- IF $bb_cfg['tracker']['gold_silver_enabled'] --><p class="chbox">{TOR_TYPE_CHBOX}</p><!-- ENDIF --> <p class="chbox">{TOR_TYPE_CHBOX}</p>
</div> </div>
</fieldset> </fieldset>
<fieldset> <fieldset>
@ -393,7 +393,7 @@ $(function(){
</tr> </tr>
</thead> </thead>
<!-- BEGIN tor --> <!-- BEGIN tor -->
<tr class="tCenter <!-- IF SHOW_CURSOR -->hl-tr<!-- ENDIF -->" id="tor_{tor.POST_ID}"> <tr class="tCenter <!-- IF SHOW_CURSOR -->hl-tr<!-- ENDIF -->" id="tor_{tor.TOPIC_ID}">
<td class="row1"><!-- IF tor.USER_AUTHOR --><p style="padding-bottom: 3px">&nbsp;<b>&reg;</b>&nbsp;</p><!-- ELSEIF tor.IS_NEW -->{MINIPOST_IMG_NEW}<!-- ELSE -->{MINIPOST_IMG}<!-- ENDIF --></td> <td class="row1"><!-- IF tor.USER_AUTHOR --><p style="padding-bottom: 3px">&nbsp;<b>&reg;</b>&nbsp;</p><!-- ELSEIF tor.IS_NEW -->{MINIPOST_IMG_NEW}<!-- ELSE -->{MINIPOST_IMG}<!-- ENDIF --></td>
<td class="row1 tCenter" title="{tor.TOR_STATUS_TEXT}">{tor.TOR_STATUS_ICON}</td> <td class="row1 tCenter" title="{tor.TOR_STATUS_TEXT}">{tor.TOR_STATUS_ICON}</td>
<!-- IF SHOW_CAT --> <!-- IF SHOW_CAT -->
@ -403,7 +403,7 @@ $(function(){
<td class="row1"><a class="gen" href="{TR_FORUM_URL}{tor.FORUM_ID}">{tor.FORUM_NAME}</a></td> <td class="row1"><a class="gen" href="{TR_FORUM_URL}{tor.FORUM_ID}">{tor.FORUM_NAME}</a></td>
<!-- ENDIF --> <!-- ENDIF -->
<td class="row4 med tLeft"> <td class="row4 med tLeft">
<a class="{tor.DL_CLASS}<!-- IF AJAX_TOPICS --> folded2<!-- ENDIF --> tLink" <!-- IF AJAX_TOPICS -->onclick="ajax.view_post({tor.POST_ID}, this); return false;"<!-- ENDIF --> href="{TOPIC_URL}{tor.TOPIC_ID}"><!-- IF tor.TOR_FROZEN -->{tor.TOPIC_TITLE}<!-- ELSE -->{tor.TOR_TYPE}<b>{tor.TOPIC_TITLE}</b><!-- ENDIF --></a> <a class="{tor.DL_CLASS}<!-- IF AJAX_TOPICS --> folded2<!-- ENDIF --> tLink" <!-- IF AJAX_TOPICS -->onclick="ajax.view_post({tor.TOPIC_ID}, this); return false;"<!-- ENDIF --> href="{TOPIC_URL}{tor.TOPIC_ID}"><!-- IF tor.TOR_FROZEN -->{tor.TOPIC_TITLE}<!-- ELSE -->{tor.TOR_TYPE}<b>{tor.TOPIC_TITLE}</b><!-- ENDIF --></a>
<!-- IF SHOW_TIME_TOPICS --><div class="tr_tm">{tor.TOPIC_TIME}</div><!-- ENDIF --> <!-- IF SHOW_TIME_TOPICS --><div class="tr_tm">{tor.TOPIC_TIME}</div><!-- ENDIF -->
</td> </td>
<!-- IF SHOW_AUTHOR --> <!-- IF SHOW_AUTHOR -->
@ -411,7 +411,7 @@ $(function(){
<!-- ENDIF --> <!-- ENDIF -->
<td class="row4 small nowrap"> <td class="row4 small nowrap">
<u>{tor.TOR_SIZE_RAW}</u> <u>{tor.TOR_SIZE_RAW}</u>
<!-- IF not tor.TOR_FROZEN --><a class="small tr-dl" title="{L_DOWNLOAD}" href="{DOWNLOAD_URL}{tor.ATTACH_ID}">{tor.TOR_SIZE}</a> <!-- IF MAGNET_LINKS --><span title="{L_MAGNET}">{tor.MAGNET}</span><!-- ENDIF --><!-- ELSE --> <!-- IF not tor.TOR_FROZEN --><a class="small tr-dl" title="{L_DOWNLOAD}" href="{DOWNLOAD_URL}{tor.TOPIC_ID}">{tor.TOR_SIZE}</a> <!-- IF MAGNET_LINKS --><span title="{L_MAGNET}">{tor.MAGNET}</span><!-- ENDIF --><!-- ELSE -->
{tor.TOR_SIZE}<!-- ENDIF --> {tor.TOR_SIZE}<!-- ENDIF -->
</td> </td>
<td class="row4 seedmed" title="{tor.SEEDS_TITLE}"><b>{tor.SEEDS}</b></td> <td class="row4 seedmed" title="{tor.SEEDS_TITLE}"><b>{tor.SEEDS}</b></td>

View file

@ -170,7 +170,7 @@ ajax.callback.post_mod_comment = function(data) {
</tr> </tr>
</table> </table>
<!-- IF SHOW_DL_LIST || SHOW_TOR_ACT --><!-- INCLUDE viewtopic_torrent.tpl --><!-- ENDIF --> <!-- IF SHOW_TOR_STATS --><!-- INCLUDE viewtopic_tor_stats.tpl --><!-- ENDIF -->
<!-- IF TOPIC_HAS_POLL or CAN_MANAGE_POLL --> <!-- IF TOPIC_HAS_POLL or CAN_MANAGE_POLL -->
<form id="poll-form" method="post" action="poll.php" style="display: none;"> <form id="poll-form" method="post" action="poll.php" style="display: none;">
@ -199,6 +199,7 @@ function poll_manage (mode, confirm_msg)
$('#poll-submit-btn').click(); $('#poll-submit-btn').click();
return false; return false;
} }
function build_poll_add_form (src_el) function build_poll_add_form (src_el)
{ {
$('#poll').empty().append( $('#poll-edit-tpl').contents() ).show(); $('#poll').empty().append( $('#poll-edit-tpl').contents() ).show();
@ -230,6 +231,7 @@ function build_poll_add_form (src_el)
</div> </div>
<!-- ENDIF --> <!-- ENDIF -->
<!-- IF LOGGED_IN -->
<table class="w100 border bw_TRL" cellpadding="0" cellspacing="0"> <table class="w100 border bw_TRL" cellpadding="0" cellspacing="0">
<tr> <tr>
<td class="cat pad_2"> <td class="cat pad_2">
@ -273,6 +275,7 @@ function build_poll_add_form (src_el)
</td> </td>
</tr> </tr>
</table> </table>
<!-- ENDIF -->
<!-- IF LOGGED_IN --> <!-- IF LOGGED_IN -->
<div class="menu-sub" id="topic-options"> <div class="menu-sub" id="topic-options">
@ -322,6 +325,8 @@ function build_poll_add_form (src_el)
onclick="user.set('sp_op', this.checked ? 1 : 0);" onclick="user.set('sp_op', this.checked ? 1 : 0);"
/>{L_SHOW_OPENED} />{L_SHOW_OPENED}
</label> </label>
</p>
<p>
<label> <label>
<input type="checkbox" <!-- IF SHOW_IMG_AFTER_LOAD -->{CHECKED}<!-- ENDIF --> <input type="checkbox" <!-- IF SHOW_IMG_AFTER_LOAD -->{CHECKED}<!-- ENDIF -->
onclick="user.set('i_aft_l', this.checked ? 1 : 0);" onclick="user.set('i_aft_l', this.checked ? 1 : 0);"
@ -369,7 +374,6 @@ function build_poll_add_form (src_el)
<!-- IF postrow.POSTER_JOINED --><p class="joined" title="{postrow.POSTER_JOINED_DATE}"><em>{L_LONGEVITY}:</em> {postrow.POSTER_JOINED}</p><!-- ENDIF --> <!-- IF postrow.POSTER_JOINED --><p class="joined" title="{postrow.POSTER_JOINED_DATE}"><em>{L_LONGEVITY}:</em> {postrow.POSTER_JOINED}</p><!-- ENDIF -->
<!-- IF postrow.POSTER_POSTS --><p class="posts"><em>{L_POSTS}:</em> {postrow.POSTER_POSTS}</p><!-- ENDIF --> <!-- IF postrow.POSTER_POSTS --><p class="posts"><em>{L_POSTS}:</em> {postrow.POSTER_POSTS}</p><!-- ENDIF -->
<!-- IF postrow.POSTER_FROM --><p class="from"><em>{L_LOCATION}:</em> {postrow.POSTER_FROM}</p><!-- ENDIF --> <!-- IF postrow.POSTER_FROM --><p class="from"><em>{L_LOCATION}:</em> {postrow.POSTER_FROM}</p><!-- ENDIF -->
<!-- IF postrow.POSTER_BIRTHDAY --><p class="birthday">{postrow.POSTER_BIRTHDAY}</p><!-- ENDIF --> <!-- IF postrow.POSTER_BIRTHDAY --><p class="birthday">{postrow.POSTER_BIRTHDAY}</p><!-- ENDIF -->
<!-- ENDIF --> <!-- ENDIF -->
@ -378,6 +382,7 @@ function build_poll_add_form (src_el)
</td> </td>
<td class="message td2" rowspan="2"> <td class="message td2" rowspan="2">
<!-- IF LOGGED_IN -->
<div class="post_head"> <div class="post_head">
<p style="float: left;<!-- IF TEXT_BUTTONS --> padding: 4px 0 3px;<!-- ELSE --> padding-top: 5px;<!-- ENDIF -->"> <p style="float: left;<!-- IF TEXT_BUTTONS --> padding: 4px 0 3px;<!-- ELSE --> padding-top: 5px;<!-- ENDIF -->">
<!-- IF postrow.IS_UNREAD -->{MINIPOST_IMG_NEW}<!-- ELSE -->{MINIPOST_IMG}<!-- ENDIF --> <!-- IF postrow.IS_UNREAD -->{MINIPOST_IMG_NEW}<!-- ELSE -->{MINIPOST_IMG}<!-- ENDIF -->
@ -402,6 +407,7 @@ function build_poll_add_form (src_el)
</p> </p>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
<!-- ENDIF -->
<div class="post_body"> <div class="post_body">
<div class="post_wrap"> <div class="post_wrap">
@ -423,10 +429,48 @@ function build_poll_add_form (src_el)
<div id="mc_comment_{postrow.POST_ID}">{postrow.MC_COMMENT}</div> <div id="mc_comment_{postrow.POST_ID}">{postrow.MC_COMMENT}</div>
</div> </div>
</div> </div>
{postrow.ATTACHMENTS}
<!-- IF postrow.IS_FIRST_POST -->
<!-- IF SHOW_GUEST_DL_STUB -->
<!-- INCLUDE viewtopic_tor_guest.tpl -->
<!-- ELSEIF SHOW_TOR_NOT_REGGED -->
<div class="clear"></div>
<div class="spacer_8"></div>
<fieldset class="attach">
<legend>{TOPIC_ATTACH_ICON} {L_ATTACHMENT}</legend>
<p class="attach_link"><b>Торрент не зарегистрирован на трекере</b> <!-- IF TRACKER_REG_LINK -->&nbsp;[ {TRACKER_REG_LINK} ]<!-- ENDIF --></p>
</fieldset>
<div class="spacer_12"></div>
<!-- ELSEIF SHOW_TOR_REGGED -->
<!-- INCLUDE viewtopic_tor_attach.tpl -->
<!-- ELSEIF SHOW_ATTACH_DL_LINK -->
<div class="clear"></div>
<div class="spacer_8"></div>
<fieldset class="attach">
<legend>{TOPIC_ATTACH_ICON} {L_ATTACHMENT}</legend>
<p class="attach_link"><a href="{$bb_cfg['dl_url']}{TOPIC_ID}" class="dl-stub"><b>Скачать прикреплённый файл</b></a> &nbsp;<span class="med">({ATTACH_FILESIZE})</span></p>
</fieldset>
<!-- ELSEIF IS_GUEST -->
<div class="clear"></div>
<div class="spacer_6"></div>
<!-- ENDIF -->
<!-- ENDIF / IS_FIRST_POST -->
</div><!--/post_wrap--> </div><!--/post_wrap-->
<!-- IF not postrow.IS_FIRST_POST -->
<!-- IF postrow.SIGNATURE -->{postrow.SIGNATURE}<!-- ENDIF --> <!-- IF postrow.SIGNATURE -->{postrow.SIGNATURE}<!-- ENDIF -->
<!-- IF postrow.EDITED_MESSAGE --><div class="last_edited">{postrow.EDITED_MESSAGE}</div><!-- ENDIF --> <!-- IF postrow.EDITED_MESSAGE --><div class="last_edited">{postrow.EDITED_MESSAGE}</div><!-- ENDIF -->
<!-- ENDIF -->
</div><!--/post_body--> </div><!--/post_body-->
<!-- IF AUTH_MOD --> <!-- IF AUTH_MOD -->
@ -570,29 +614,12 @@ function build_poll_add_form (src_el)
</td> </td>
</tr> </tr>
<tr id="post_opt" class="row2">
<td class="td2 med tCenter pad_4">
<label><input type="checkbox" name="notify" <!-- IF QR_NOTIFY_CHECKED -->checked="checked"<!-- ENDIF --> <!-- IF not LOGGED_IN -->disabled="disabled"<!-- ENDIF --> />
{L_QR_NOTIFY}&nbsp;</label>
</td>
</tr>
</table><!--/topic_quick_reply--> </table><!--/topic_quick_reply-->
</form> </form>
<!-- ENDIF / QUICK_REPLY --> <!-- ENDIF / QUICK_REPLY -->
<table class="topic" cellpadding="0" cellspacing="0"> <!-- IF LOGGED_IN -->
<tr>
<td class="catBottom med">
<form method="post" action="{S_POST_DAYS_ACTION}">
{L_DISPLAY_POSTS}: {S_SELECT_POST_DAYS}&nbsp;
{S_SELECT_POST_ORDER}&nbsp;
<input type="submit" value="{L_GO}" class="lite" name="submit" />
</form>
</td>
</tr>
</table>
<table cellpadding="0" class="w100" style="padding-top: 2px;"> <table cellpadding="0" class="w100" style="padding-top: 2px;">
<tr> <tr>
<td valign="top"> <td valign="top">
@ -606,8 +633,9 @@ function build_poll_add_form (src_el)
</td> </td>
</tr> </tr>
</table> </table>
<!-- ENDIF -->
<!--bottom_info--> <!-- IF LOGGED_IN -->
<div class="bottom_info"> <div class="bottom_info">
<div class="jumpbox"></div> <div class="jumpbox"></div>
@ -622,25 +650,18 @@ function build_poll_add_form (src_el)
<table width="100%"> <table width="100%">
<tr> <tr>
<td width="40%" valign="top" nowrap="nowrap"><span class="small">{S_WATCH_TOPIC}</span><br /> <td valign="top" nowrap="nowrap">
<div class="small"> <div class="small">
<!-- IF S_TOPIC_ADMIN --> <!-- IF S_TOPIC_ADMIN -->
<br clear="all" /> <br clear="all" />
<div style="float: left;">{S_TOPIC_ADMIN}</div> <div style="float: left;">{L_MANAGE}: {S_TOPIC_ADMIN}</div>
<!-- ENDIF --> <!-- ENDIF -->
<!-- IF IS_ADMIN --> <!-- IF IS_ADMIN -->
<div class="med" style="float: right;">
Admin:&nbsp;
<a href="{U_LOGS}">{L_LOGS}</a>&nbsp;
</div>
<!-- ENDIF -->
<!-- IF S_DL_DELETE -->
<br clear="all" /> <br clear="all" />
<div style="float: left;">{S_DL_DELETE}</div> <div style="float: left;"><a href="{U_LOGS}">{L_LOGS}</a></div>
<!-- ENDIF --> <!-- ENDIF -->
<br clear="all" />
<div style="float: left;">{S_AUTH_LIST}</div>
</div> </div>
</td> </td>
</tr> </tr>
</table> </table>
<!-- ENDIF / LOGGED_IN -->

View file

@ -8,7 +8,6 @@
*/ */
define('BB_SCRIPT', 'tracker'); define('BB_SCRIPT', 'tracker');
define('BB_ROOT', './');
require __DIR__ . '/common.php'; require __DIR__ . '/common.php';
// Page config // Page config
@ -639,7 +638,7 @@ if ($allowed_forums) {
// SELECT // SELECT
$select = " $select = "
SELECT SELECT
tor.topic_id, tor.post_id, tor.attach_id, tor.size, tor.reg_time, tor.complete_count, tor.seeder_last_seen, tor.tor_status, tor.tor_type, tor.topic_id, tor.size, tor.reg_time, tor.complete_count, tor.seeder_last_seen, tor.tor_status, tor.tor_type,
t.topic_title, t.topic_time, t.topic_replies, t.topic_views, sn.seeders, sn.leechers, tor.info_hash t.topic_title, t.topic_time, t.topic_replies, t.topic_views, sn.seeders, sn.leechers, tor.info_hash
"; ";
$select .= (!$hide_speed) ? ", sn.speed_up, sn.speed_down" : ''; $select .= (!$hide_speed) ? ", sn.speed_up, sn.speed_down" : '';
@ -696,7 +695,6 @@ if ($allowed_forums) {
$seeds = $tor['seeders']; $seeds = $tor['seeders'];
$leechs = $tor['leechers']; $leechs = $tor['leechers'];
$s_last = $tor['seeder_last_seen']; $s_last = $tor['seeder_last_seen'];
$att_id = $tor['attach_id'];
$size = $tor['size']; $size = $tor['size'];
$tor_magnet = create_magnet($tor['info_hash'], $passkey['auth_key']); $tor_magnet = create_magnet($tor['info_hash'], $passkey['auth_key']);
$compl = $tor['complete_count']; $compl = $tor['complete_count'];
@ -719,7 +717,6 @@ if ($allowed_forums) {
'TOPIC_ID' => $tor['topic_id'], 'TOPIC_ID' => $tor['topic_id'],
'TOPIC_TITLE' => wbr($tor['topic_title']), 'TOPIC_TITLE' => wbr($tor['topic_title']),
'TOPIC_TIME' => bb_date($tor['topic_time'], 'd-M-y') . ' <b>&middot;</b> ' . delta_time($tor['topic_time']), 'TOPIC_TIME' => bb_date($tor['topic_time'], 'd-M-y') . ' <b>&middot;</b> ' . delta_time($tor['topic_time']),
'POST_ID' => $tor['post_id'],
'POSTER_ID' => $poster_id, 'POSTER_ID' => $poster_id,
'USERNAME' => ($hide_author) ? '' : profile_url(array('username' => $tor['username'], 'user_rank' => $tor['user_rank'])), 'USERNAME' => ($hide_author) ? '' : profile_url(array('username' => $tor['username'], 'user_rank' => $tor['user_rank'])),
@ -729,7 +726,6 @@ if ($allowed_forums) {
'IS_NEW' => (!IS_GUEST && $tor['reg_time'] > $lastvisit), 'IS_NEW' => (!IS_GUEST && $tor['reg_time'] > $lastvisit),
'USER_AUTHOR' => (!IS_GUEST && $poster_id == $user_id), 'USER_AUTHOR' => (!IS_GUEST && $poster_id == $user_id),
'ATTACH_ID' => $att_id,
'MAGNET' => $tor_magnet, 'MAGNET' => $tor_magnet,
'TOR_TYPE' => is_gold($tor['tor_type']), 'TOR_TYPE' => is_gold($tor['tor_type']),
@ -742,7 +738,7 @@ if ($allowed_forums) {
'UL_SPEED' => $ul_sp, 'UL_SPEED' => $ul_sp,
'DL_SPEED' => $dl_sp, 'DL_SPEED' => $dl_sp,
'SEEDS' => $seeds ?: 0, 'SEEDS' => $seeds ?: 0,
'SEEDS_TITLE' => ($seeds) ? $lang['SEEDERS'] : ($lang['SEED_NOT_SEEN'] . ":\n " . (($s_last) ? bb_date($s_last, $date_format) : $lang['NEVER'])), 'SEEDS_TITLE' => $seeds ? $lang['SEEDERS'] : ($lang['SEED_NOT_SEEN'] . ":\n " . (($s_last) ? bb_date($s_last, $date_format) : $lang['NEVER'])),
'LEECHS' => $leechs ?: 0, 'LEECHS' => $leechs ?: 0,
'COMPLETED' => $compl ?: 0, 'COMPLETED' => $compl ?: 0,
'REPLIES' => $tor['topic_replies'], 'REPLIES' => $tor['topic_replies'],

View file

@ -8,7 +8,6 @@
*/ */
define('BB_SCRIPT', 'forum'); define('BB_SCRIPT', 'forum');
define('BB_ROOT', './');
require __DIR__ . '/common.php'; require __DIR__ . '/common.php';
$page_cfg['include_bbcode_js'] = true; $page_cfg['include_bbcode_js'] = true;
@ -47,17 +46,19 @@ if (!$forums = $datastore->get('cat_forums')) {
$datastore->update('cat_forums'); $datastore->update('cat_forums');
$forums = $datastore->get('cat_forums'); $forums = $datastore->get('cat_forums');
} }
if (!$forum_id or !$forum_data = @$forums['forum'][$forum_id]) { if (!$forum_id || !($forum_data = $forums['forum'][$forum_id])) {
bb_die($lang['FORUM_NOT_EXIST']); bb_die($lang['FORUM_NOT_EXIST']);
} }
// Only new // Only new
$only_new = $user->opt_js['only_new']; $only_new = $user->opt_js['only_new'];
$only_new_sql = ''; $only_new_sql = $only_new_hint = '';
if ($only_new == ONLY_NEW_POSTS) { if ($only_new == ONLY_NEW_POSTS) {
$only_new_sql = "AND t.topic_last_post_time > $lastvisit"; $only_new_sql = "AND t.topic_last_post_time > $lastvisit";
$only_new_hint = 'показаны только новые сообщения';
} elseif ($only_new == ONLY_NEW_TOPICS) { } elseif ($only_new == ONLY_NEW_TOPICS) {
$only_new_sql = "AND t.topic_time > $lastvisit"; $only_new_sql = "AND t.topic_time > $lastvisit";
$only_new_hint = 'показаны только новые темы';
} }
// Auth // Auth
@ -75,12 +76,11 @@ if (!$is_auth['auth_view']) {
bb_die($message); bb_die($message);
} }
set_die_append_msg($forum_id);
// Redirect to login page if not admin session // Redirect to login page if not admin session
$mod_redirect_url = ''; $mod_redirect_url = '';
// Filter by torrent status
$tor_status = -1; // all by default
if ($is_auth['auth_mod']) { if ($is_auth['auth_mod']) {
$redirect = $_POST['redirect'] ?? $_SERVER['REQUEST_URI']; $redirect = $_POST['redirect'] ?? $_SERVER['REQUEST_URI'];
$redirect = url_arg($redirect, 'mod', 1, '&'); $redirect = url_arg($redirect, 'mod', 1, '&');
@ -89,20 +89,6 @@ if ($is_auth['auth_mod']) {
if ($moderation && !$userdata['session_admin']) { if ($moderation && !$userdata['session_admin']) {
redirect($mod_redirect_url); redirect($mod_redirect_url);
} }
if (isset($_REQUEST['tst']) && $_REQUEST['tst'] != -1) {
$tor_status = (int)$_REQUEST['tst'];
// reset other req values
unset($_REQUEST['sort'], $_REQUEST['order'], $_REQUEST[$title_match_key]);
$show_type_separator = false;
}
$select_tst = array_merge(array($lang['TOR_STATUS_SELECT_ALL'] => -1), array_flip($lang['TOR_STATUS_NAME']));
$template->assign_vars(array(
'SELECT_TST' => build_select('tst', $select_tst, $tor_status),
));
$select_st = array_merge(array($lang['TOR_STATUS_SELECT_ACTION'] => -1), array_flip($lang['TOR_STATUS_NAME']));
$template->assign_vars(array(
'SELECT_ST' => build_select('st', $select_st, -1),
));
} }
// Topics read tracks // Topics read tracks
@ -111,8 +97,6 @@ $tracking_forums = get_tracks('forum');
if ($mark_read && !IS_GUEST) { if ($mark_read && !IS_GUEST) {
set_tracks(COOKIE_FORUM, $tracking_forums, $forum_id); set_tracks(COOKIE_FORUM, $tracking_forums, $forum_id);
set_die_append_msg($forum_id);
bb_die($lang['TOPICS_MARKED_READ']); bb_die($lang['TOPICS_MARKED_READ']);
} }
@ -144,6 +128,7 @@ if (!$forum_data['forum_parent'] && isset($forums['f'][$forum_id]['subforums'])
WHERE f.forum_parent = $forum_id WHERE f.forum_parent = $forum_id
$only_new_sql $only_new_sql
$ignore_forum_sql $ignore_forum_sql
GROUP BY f.forum_id
ORDER BY f.forum_order ORDER BY f.forum_order
"; ";
@ -181,7 +166,7 @@ if (!$forum_data['forum_parent'] && isset($forums['f'][$forum_id]['subforums'])
$template->assign_block_vars('f', array( $template->assign_block_vars('f', array(
'FORUM_FOLDER_IMG' => $folder_image, 'FORUM_FOLDER_IMG' => $folder_image,
'FORUM_ID' => $sf_forum_id,
'FORUM_NAME' => $fname_html, 'FORUM_NAME' => $fname_html,
'FORUM_DESC' => $forums['f'][$sf_forum_id]['forum_desc'], 'FORUM_DESC' => $forums['f'][$sf_forum_id]['forum_desc'],
'U_VIEWFORUM' => FORUM_URL . $sf_forum_id, 'U_VIEWFORUM' => FORUM_URL . $sf_forum_id,
@ -215,7 +200,7 @@ $topics_per_page = $bb_cfg['topics_per_page'];
$select_tpp = ''; $select_tpp = '';
if ($is_auth['auth_mod']) { if ($is_auth['auth_mod']) {
if ($req_tpp = abs((int)(@$_REQUEST['tpp'])) and in_array($req_tpp, $bb_cfg['allowed_topics_per_page'])) { if (($req_tpp = abs((int)(@$_REQUEST['tpp']))) && in_array($req_tpp, $bb_cfg['allowed_topics_per_page'])) {
$topics_per_page = $req_tpp; $topics_per_page = $req_tpp;
} }
@ -225,36 +210,28 @@ if ($is_auth['auth_mod']) {
} }
} }
// Generate a 'Show topics in previous x days' select box. // Filter by torrent status
$topic_days = 0; // all the time $tor_status = -1; // all by default
if ($is_auth['auth_mod']) {
if (isset($_REQUEST['tst']) && $_REQUEST['tst'] != -1) {
$tor_status = (int)$_REQUEST['tst'];
// reset other req values
unset($_REQUEST['sort'], $_REQUEST['order'], $_REQUEST[$title_match_key]);
$show_type_separator = false;
}
$select_tst = array_merge(array($lang['TOR_STATUS_SELECT_ALL'] => -1), array_flip($lang['TOR_STATUS_NAME']));
$template->assign_vars(array(
'SELECT_TST' => build_select('tst', $select_tst, $tor_status),
));
$select_st = array_merge(array($lang['TOR_STATUS_SELECT_ACTION'] => -1), array_flip($lang['TOR_STATUS_NAME']));
$template->assign_vars(array(
'SELECT_ST' => build_select('st', $select_st, -1),
));
}
$forum_topics = $forum_data['forum_topics']; $forum_topics = $forum_data['forum_topics'];
$sel_previous_days = array(
0 => $lang['ALL_POSTS'],
1 => $lang['1_DAY'],
7 => $lang['7_DAYS'],
14 => $lang['2_WEEKS'],
30 => $lang['1_MONTH'],
90 => $lang['3_MONTHS'],
180 => $lang['6_MONTHS'],
364 => $lang['1_YEAR'],
);
if (!empty($_REQUEST['topicdays'])) {
if ($req_topic_days = abs((int)$_REQUEST['topicdays']) and isset($sel_previous_days[$req_topic_days])) {
$sql = "
SELECT COUNT(*) AS forum_topics
FROM " . BB_TOPICS . "
WHERE forum_id = $forum_id
AND topic_last_post_time > " . (TIMENOW - 86400 * $req_topic_days) . "
";
if ($row = DB()->fetch_row($sql)) {
$topic_days = $req_topic_days;
$forum_topics = $row['forum_topics'];
}
}
}
// Correct $start value // Correct $start value
if ($start > $forum_topics) { if ($start > $forum_topics) {
redirect(FORUM_URL . $forum_id); redirect(FORUM_URL . $forum_id);
@ -273,8 +250,6 @@ $order_method = get_forum_display_sort_option($order_value, 'field', 'order');
$order_sql = "ORDER BY t.topic_type DESC, $sort_method $order_method"; $order_sql = "ORDER BY t.topic_type DESC, $sort_method $order_method";
$limit_topics_time_sql = ($topic_days) ? "AND t.topic_last_post_time > " . (TIMENOW - 86400 * $topic_days) : '';
$select_tor_sql = $join_tor_sql = ''; $select_tor_sql = $join_tor_sql = '';
$join_dl = ($bb_cfg['show_dl_status_in_forum'] && !IS_GUEST); $join_dl = ($bb_cfg['show_dl_status_in_forum'] && !IS_GUEST);
@ -285,7 +260,7 @@ if ($forum_data['allow_reg_tracker']) {
} }
$select_tor_sql = ', $select_tor_sql = ',
bt.auth_key, tor.info_hash, tor.size AS tor_size, tor.reg_time, tor.complete_count, tor.seeder_last_seen, tor.attach_id, tor.tor_status, tor.tor_type, bt.auth_key, tor.info_hash, tor.size AS tor_size, tor.reg_time, tor.complete_count, tor.seeder_last_seen, tor.tor_status, tor.tor_type,
sn.seeders, sn.leechers sn.seeders, sn.leechers
'; ';
$select_tor_sql .= ($join_dl) ? ', dl.user_status AS dl_status' : ''; $select_tor_sql .= ($join_dl) ? ', dl.user_status AS dl_status' : '';
@ -322,7 +297,6 @@ $sql = "
WHERE t.forum_id = $forum_id WHERE t.forum_id = $forum_id
$only_new_sql $only_new_sql
$title_match_sql $title_match_sql
$limit_topics_time_sql
$order_sql $order_sql
LIMIT $start, $topics_per_page LIMIT $start, $topics_per_page
"; ";
@ -369,23 +343,10 @@ if ($forum_data['allow_reg_tracker']) {
// Post URL generation for templating vars // Post URL generation for templating vars
$template->assign_vars(array( $template->assign_vars(array(
'U_POST_NEW_TOPIC' => $post_new_topic_url, 'U_POST_NEW_TOPIC' => $post_new_topic_url,
'S_SELECT_TOPIC_DAYS' => build_select('topicdays', array_flip($sel_previous_days), $topic_days),
'S_POST_DAYS_ACTION' => FORUM_URL . "$forum_id&amp;start=$start", 'S_POST_DAYS_ACTION' => FORUM_URL . "$forum_id&amp;start=$start",
'S_DISPLAY_ORDER' => $s_display_order, 'S_DISPLAY_ORDER' => $s_display_order,
)); ));
// User authorisation levels output
$u_auth = array();
$u_auth[] = ($is_auth['auth_post']) ? $lang['RULES_POST_CAN'] : $lang['RULES_POST_CANNOT'];
$u_auth[] = ($is_auth['auth_reply']) ? $lang['RULES_REPLY_CAN'] : $lang['RULES_REPLY_CANNOT'];
$u_auth[] = ($is_auth['auth_edit']) ? $lang['RULES_EDIT_CAN'] : $lang['RULES_EDIT_CANNOT'];
$u_auth[] = ($is_auth['auth_delete']) ? $lang['RULES_DELETE_CAN'] : $lang['RULES_DELETE_CANNOT'];
$u_auth[] = ($is_auth['auth_vote']) ? $lang['RULES_VOTE_CAN'] : $lang['RULES_VOTE_CANNOT'];
$u_auth[] = ($is_auth['auth_attachments']) ? $lang['RULES_ATTACH_CAN'] : $lang['RULES_ATTACH_CANNOT'];
$u_auth[] = ($is_auth['auth_download']) ? $lang['RULES_DOWNLOAD_CAN'] : $lang['RULES_DOWNLOAD_CANNOT'];
$u_auth[] = ($is_auth['auth_mod']) ? $lang['RULES_MODERATE'] : '';
$u_auth = implode("<br />\n", $u_auth);
$template->assign_vars(array( $template->assign_vars(array(
'SHOW_JUMPBOX' => true, 'SHOW_JUMPBOX' => true,
'PAGE_TITLE' => htmlCHR($forum_data['forum_name']), 'PAGE_TITLE' => htmlCHR($forum_data['forum_name']),
@ -409,7 +370,6 @@ $template->assign_vars(array(
'TITLE_MATCH' => htmlCHR($title_match), 'TITLE_MATCH' => htmlCHR($title_match),
'SELECT_TPP' => ($select_tpp) ? build_select('tpp', $select_tpp, $topics_per_page, null, null, 'onchange="$(\'#tpp\').submit();"') : '', 'SELECT_TPP' => ($select_tpp) ? build_select('tpp', $select_tpp, $topics_per_page, null, null, 'onchange="$(\'#tpp\').submit();"') : '',
'T_POST_NEW_TOPIC' => ($forum_data['forum_status'] == FORUM_LOCKED) ? $lang['FORUM_LOCKED'] : $post_new_topic, 'T_POST_NEW_TOPIC' => ($forum_data['forum_status'] == FORUM_LOCKED) ? $lang['FORUM_LOCKED'] : $post_new_topic,
'S_AUTH_LIST' => $u_auth,
'U_VIEW_FORUM' => FORUM_URL . $forum_id, 'U_VIEW_FORUM' => FORUM_URL . $forum_id,
'U_MARK_READ' => FORUM_URL . $forum_id . "&amp;mark=topics", 'U_MARK_READ' => FORUM_URL . $forum_id . "&amp;mark=topics",
'U_SEARCH_SELF' => "search.php?uid={$userdata['user_id']}&f=$forum_id", 'U_SEARCH_SELF' => "search.php?uid={$userdata['user_id']}&f=$forum_id",
@ -421,7 +381,6 @@ foreach ($topic_rowset as $topic) {
$topic_id = $topic['topic_id']; $topic_id = $topic['topic_id'];
$moved = ($topic['topic_status'] == TOPIC_MOVED); $moved = ($topic['topic_status'] == TOPIC_MOVED);
$replies = $topic['topic_replies']; $replies = $topic['topic_replies'];
$t_hot = ($replies >= $bb_cfg['hot_threshold']);
$t_type = $topic['topic_type']; $t_type = $topic['topic_type'];
$separator = ''; $separator = '';
$is_unread = is_unread($topic['topic_last_post_time'], $topic_id, $forum_id); $is_unread = is_unread($topic['topic_last_post_time'], $topic_id, $forum_id);
@ -442,12 +401,12 @@ foreach ($topic_rowset as $topic) {
$template->assign_block_vars('t', array( $template->assign_block_vars('t', array(
'FORUM_ID' => $forum_id, 'FORUM_ID' => $forum_id,
'TOPIC_ID' => $topic_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']), 'TOPIC_TITLE' => wbr($topic['topic_title']),
'TOPICS_SEPARATOR' => $separator, 'TOPICS_SEPARATOR' => $separator,
'IS_UNREAD' => $is_unread, 'IS_UNREAD' => $is_unread,
'TOPIC_ICON' => get_topic_icon($topic, $is_unread), 'TOPIC_ICON' => get_topic_icon($topic, $is_unread),
'PAGINATION' => ($moved) ? '' : build_topic_pagination(TOPIC_URL . $topic_id, $replies, $bb_cfg['posts_per_page']), 'PAGINATION' => $moved ? '' : build_topic_pagination(TOPIC_URL . $topic_id, $replies, $bb_cfg['posts_per_page']),
'REPLIES' => $replies, 'REPLIES' => $replies,
'VIEWS' => $topic['topic_views'], 'VIEWS' => $topic['topic_views'],
'TOR_STALED' => ($forum_data['allow_reg_tracker'] && !($t_type == POST_ANNOUNCE || $t_type == POST_STICKY || $topic['tor_size'])), 'TOR_STALED' => ($forum_data['allow_reg_tracker'] && !($t_type == POST_ANNOUNCE || $t_type == POST_STICKY || $topic['tor_size'])),
@ -457,10 +416,10 @@ foreach ($topic_rowset as $topic) {
'TOR_STATUS_ICON' => isset($topic['tor_status']) ? $bb_cfg['tor_icons'][$topic['tor_status']] : '', 'TOR_STATUS_ICON' => isset($topic['tor_status']) ? $bb_cfg['tor_icons'][$topic['tor_status']] : '',
'TOR_STATUS_TEXT' => isset($topic['tor_status']) ? $lang['TOR_STATUS_NAME'][$topic['tor_status']] : '', 'TOR_STATUS_TEXT' => isset($topic['tor_status']) ? $lang['TOR_STATUS_NAME'][$topic['tor_status']] : '',
'ATTACH' => $topic['topic_attachment'] ?? false, 'ATTACH' => $topic['attach_ext_id'],
'STATUS' => $topic['topic_status'], 'STATUS' => $topic['topic_status'],
'TYPE' => $topic['topic_type'], 'TYPE' => $topic['topic_type'],
'DL' => ($topic['topic_dl_type'] == TOPIC_DL_TYPE_DL && !$forum_data['allow_reg_tracker']), 'DL' => isset($topic['tracker_status']) && !$forum_data['allow_reg_tracker'],
'POLL' => $topic['topic_vote'], 'POLL' => $topic['topic_vote'],
'DL_CLASS' => isset($topic['dl_status']) ? $dl_link_css[$topic['dl_status']] : '', 'DL_CLASS' => isset($topic['dl_status']) ? $dl_link_css[$topic['dl_status']] : '',
@ -478,7 +437,6 @@ foreach ($topic_rowset as $topic) {
'LEECHERS' => (int)$topic['leechers'], 'LEECHERS' => (int)$topic['leechers'],
'TOR_SIZE' => humn_size($topic['tor_size']), 'TOR_SIZE' => humn_size($topic['tor_size']),
'COMPL_CNT' => (int)$topic['complete_count'], 'COMPL_CNT' => (int)$topic['complete_count'],
'ATTACH_ID' => $topic['attach_id'],
'MAGNET' => $tor_magnet, 'MAGNET' => $tor_magnet,
)); ));
} }
@ -491,7 +449,6 @@ $pg_url .= ($sort_value) ? "&sort=$sort_value" : '';
$pg_url .= ($order_value) ? "&order=$order_value" : ''; $pg_url .= ($order_value) ? "&order=$order_value" : '';
$template->assign_var('MOD_URL', $pg_url); $template->assign_var('MOD_URL', $pg_url);
$pg_url = FORUM_URL . $forum_id; $pg_url = FORUM_URL . $forum_id;
$pg_url .= ($topic_days) ? "&amp;topicdays=$topic_days" : '';
$pg_url .= ($sort_value) ? "&amp;sort=$sort_value" : ''; $pg_url .= ($sort_value) ? "&amp;sort=$sort_value" : '';
$pg_url .= ($order_value) ? "&amp;order=$order_value" : ''; $pg_url .= ($order_value) ? "&amp;order=$order_value" : '';
$pg_url .= ($moderation) ? "&amp;mod=1" : ''; $pg_url .= ($moderation) ? "&amp;mod=1" : '';
@ -503,7 +460,7 @@ if ($found_topics) {
if ($only_new) { if ($only_new) {
$no_topics_msg = $lang['NO_NEW_POSTS']; $no_topics_msg = $lang['NO_NEW_POSTS'];
} else { } else {
$no_topics_msg = ($topic_days || $title_match) ? $lang['NO_SEARCH_MATCH'] : $lang['NO_TOPICS_POST_ONE']; $no_topics_msg = $title_match ? $lang['NO_SEARCH_MATCH'] : $lang['NO_TOPICS_POST_ONE'];
} }
$template->assign_vars(array( $template->assign_vars(array(
'NO_TOPICS' => $no_topics_msg, 'NO_TOPICS' => $no_topics_msg,

View file

@ -8,10 +8,12 @@
*/ */
define('BB_SCRIPT', 'topic'); define('BB_SCRIPT', 'topic');
define('BB_ROOT', './');
require __DIR__ . '/common.php'; require __DIR__ . '/common.php';
require INC_DIR . '/bbcode.php'; require INC_DIR . '/bbcode.php';
// Start session
$user->session_start();
$datastore->enqueue(array( $datastore->enqueue(array(
'ranks', 'ranks',
'cat_forums', 'cat_forums',
@ -23,22 +25,17 @@ $page_cfg['load_tpl_vars'] = array(
'topic_icons', 'topic_icons',
); );
$newest = $next_topic_id = 0;
$start = isset($_GET['start']) ? abs((int)$_GET['start']) : 0;
$topic_id = isset($_GET[POST_TOPIC_URL]) ? (int)$_GET[POST_TOPIC_URL] : 0; $topic_id = isset($_GET[POST_TOPIC_URL]) ? (int)$_GET[POST_TOPIC_URL] : 0;
$post_id = (!$topic_id && isset($_GET[POST_POST_URL])) ? (int)$_GET[POST_POST_URL] : 0; $post_id = (!$topic_id && isset($_GET[POST_POST_URL])) ? (int)$_GET[POST_POST_URL] : 0;
$start = (!$post_id && isset($_GET['start'])) ? min(abs(intval($_GET['start'])), 10000) : 0;
// Start session $newest = 0;
$user->session_start();
set_die_append_msg();
// Posts per page // Posts per page
$posts_per_page = $bb_cfg['posts_per_page']; $posts_per_page = $bb_cfg['posts_per_page'];
$select_ppp = ''; $select_ppp = '';
if ($userdata['session_admin']) { if ($userdata['session_admin']) {
if ($req_ppp = abs((int)(@$_REQUEST['ppp'])) and in_array($req_ppp, $bb_cfg['allowed_posts_per_page'])) { if (($req_ppp = abs((int)(@$_REQUEST['ppp']))) && in_array($req_ppp, $bb_cfg['allowed_posts_per_page'])) {
$posts_per_page = $req_ppp; $posts_per_page = $req_ppp;
} }
@ -54,6 +51,8 @@ if (isset($_REQUEST['single'])) {
$start = floor($start / $posts_per_page) * $posts_per_page; $start = floor($start / $posts_per_page) * $posts_per_page;
} }
set_die_append_msg();
if (!$topic_id && !$post_id) { if (!$topic_id && !$post_id) {
bb_die($lang['TOPIC_POST_NOT_EXIST']); bb_die($lang['TOPIC_POST_NOT_EXIST']);
} }
@ -61,49 +60,31 @@ if (!$topic_id && !$post_id) {
$tracking_topics = get_tracks('topic'); $tracking_topics = get_tracks('topic');
$tracking_forums = get_tracks('forum'); $tracking_forums = get_tracks('forum');
// Find topic id if user requested a newer or older topic
if ($topic_id && isset($_GET['view']) && ($_GET['view'] == 'next' || $_GET['view'] == 'previous')) {
$sql_condition = ($_GET['view'] == 'next') ? '>' : '<';
$sql_ordering = ($_GET['view'] == 'next') ? 'ASC' : 'DESC';
$sql = "SELECT t.topic_id
FROM " . BB_TOPICS . " t, " . BB_TOPICS . " t2
WHERE t2.topic_id = $topic_id
AND t.forum_id = t2.forum_id
AND t.topic_moved_id = 0
AND t.topic_last_post_id $sql_condition t2.topic_last_post_id
ORDER BY t.topic_last_post_id $sql_ordering
LIMIT 1";
if ($row = DB()->fetch_row($sql)) {
$next_topic_id = $topic_id = $row['topic_id'];
} else {
$message = ($_GET['view'] == 'next') ? $lang['NO_NEWER_TOPICS'] : $lang['NO_OLDER_TOPICS'];
bb_die($message);
}
}
// Get forum/topic data // Get forum/topic data
$t_data = false;
if ($topic_id) { if ($topic_id) {
$sql = "SELECT t.*, f.*, tw.notify_status $t_data = DB()->fetch_row("
FROM " . BB_TOPICS . " t SELECT t.*, f.*
LEFT JOIN " . BB_FORUMS . " f USING(forum_id) FROM ". BB_TOPICS ." t, ". BB_FORUMS ." f
LEFT JOIN " . BB_TOPICS_WATCH . " tw ON(tw.topic_id = t.topic_id AND tw.user_id = {$userdata['user_id']})
WHERE t.topic_id = $topic_id WHERE t.topic_id = $topic_id
"; AND f.forum_id = t.forum_id
LIMIT 1
");
} elseif ($post_id) { } elseif ($post_id) {
$sql = "SELECT t.*, f.*, p.post_time, tw.notify_status $t_data = DB()->fetch_row("
FROM " . BB_TOPICS . " t SELECT t.*, f.*, p.post_time
LEFT JOIN " . BB_FORUMS . " f USING(forum_id) FROM ". BB_TOPICS ." t, ". BB_FORUMS ." f, ". BB_POSTS ." p
LEFT JOIN " . BB_POSTS . " p USING(topic_id)
LEFT JOIN " . BB_TOPICS_WATCH . " tw ON(tw.topic_id = t.topic_id AND tw.user_id = {$userdata['user_id']})
WHERE p.post_id = $post_id WHERE p.post_id = $post_id
"; AND t.topic_id = p.topic_id
AND f.forum_id = t.forum_id
LIMIT 1
");
} else { } else {
bb_die($lang['TOPIC_POST_NOT_EXIST']); bb_die($lang['TOPIC_POST_NOT_EXIST']);
} }
if (!$t_data = DB()->fetch_row($sql)) { if (!$t_data) {
meta_refresh('index.php', 10); meta_refresh('index.php', 10);
bb_die($lang['TOPIC_POST_NOT_EXIST']); bb_die($lang['TOPIC_POST_NOT_EXIST']);
} }
@ -111,7 +92,7 @@ if (!$t_data = DB()->fetch_row($sql)) {
$forum_topic_data =& $t_data; $forum_topic_data =& $t_data;
$topic_id = $t_data['topic_id']; $topic_id = $t_data['topic_id'];
$forum_id = $t_data['forum_id']; $forum_id = $t_data['forum_id'];
$topic_attachment = isset($t_data['topic_attachment']) ? (int)$t_data['topic_attachment'] : null; $total_replies = $t_data['topic_replies'] + 1;
if ($t_data['allow_porno_topic'] && bf($userdata['user_opt'], 'user_opt', 'user_porn_forums')) { if ($t_data['allow_porno_topic'] && bf($userdata['user_opt'], 'user_opt', 'user_porn_forums')) {
bb_die($lang['ERROR_PORNO_FORUM']); bb_die($lang['ERROR_PORNO_FORUM']);
@ -122,42 +103,10 @@ if ($userdata['session_admin'] && !empty($_REQUEST['mod'])) {
$datastore->enqueue(array('viewtopic_forum_select')); $datastore->enqueue(array('viewtopic_forum_select'));
} }
} }
if ($topic_attachment) {
$datastore->enqueue(array(
'attach_extensions',
));
}
set_die_append_msg($forum_id); set_die_append_msg($forum_id);
// Find newest post
if (($next_topic_id || @$_GET['view'] === 'newest') && !IS_GUEST && $topic_id) {
$post_time = 'post_time >= ' . get_last_read($topic_id, $forum_id);
$post_id_altern = ($next_topic_id) ? '' : ' OR post_id = ' . $t_data['topic_last_post_id'];
$sql = "SELECT post_id, post_time
FROM " . BB_POSTS . "
WHERE topic_id = $topic_id
AND ($post_time $post_id_altern)
ORDER BY post_time ASC
LIMIT 1";
if ($row = DB()->fetch_row($sql)) {
$post_id = $newest = $row['post_id'];
$t_data['post_time'] = $row['post_time'];
}
}
if ($post_id && !empty($t_data['post_time']) && ($t_data['topic_replies'] + 1) > $posts_per_page) {
$sql = "SELECT COUNT(post_id) AS prev_posts
FROM " . BB_POSTS . "
WHERE topic_id = $topic_id
AND post_time <= {$t_data['post_time']}";
if ($row = DB()->fetch_row($sql)) {
$t_data['prev_posts'] = $row['prev_posts'];
}
}
// Auth check // Auth check
$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $t_data); $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $t_data);
@ -165,7 +114,7 @@ $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $t_data);
if (!$is_auth['auth_read']) { if (!$is_auth['auth_read']) {
if (IS_GUEST) { if (IS_GUEST) {
$redirect = ($post_id) ? POST_URL . "$post_id#$post_id" : TOPIC_URL . $topic_id; $redirect = ($post_id) ? POST_URL . "$post_id#$post_id" : TOPIC_URL . $topic_id;
$redirect .= ($start && !$post_id) ? "&start=$start" : ''; $redirect .= ($start) ? "&start=$start" : '';
redirect(LOGIN_URL . "?redirect=$redirect"); redirect(LOGIN_URL . "?redirect=$redirect");
} }
bb_die($lang['TOPIC_POST_NOT_EXIST']); bb_die($lang['TOPIC_POST_NOT_EXIST']);
@ -225,84 +174,6 @@ if ($post_id && !empty($t_data['prev_posts'])) {
$start = floor(($t_data['prev_posts'] - 1) / $posts_per_page) * $posts_per_page; $start = floor(($t_data['prev_posts'] - 1) / $posts_per_page) * $posts_per_page;
} }
// Is user watching this thread?
$can_watch_topic = $is_watching_topic = false;
if ($bb_cfg['topic_notify_enabled']) {
if ($userdata['session_logged_in']) {
$can_watch_topic = true;
if (!empty($t_data['notify_status']) && $t_data['notify_status']) {
if (isset($_GET['unwatch'])) {
if ($_GET['unwatch'] == 'topic') {
$is_watching_topic = 0;
DB()->query("DELETE FROM " . BB_TOPICS_WATCH . " WHERE topic_id = $topic_id AND user_id = {$userdata['user_id']}");
}
set_die_append_msg($forum_id, $topic_id);
bb_die($lang['NO_LONGER_WATCHING']);
} else {
$is_watching_topic = true;
if (!$t_data['notify_status']) {
DB()->query("UPDATE " . BB_TOPICS_WATCH . " SET notify_status = " . TOPIC_WATCH_NOTIFIED . " WHERE topic_id = $topic_id AND user_id = {$userdata['user_id']}");
}
}
} else {
if (isset($_GET['watch'])) {
if ($_GET['watch'] == 'topic') {
$is_watching_topic = true;
DB()->query("
INSERT INTO " . BB_TOPICS_WATCH . " (user_id, topic_id, notify_status)
VALUES (" . $userdata['user_id'] . ", $topic_id, " . TOPIC_WATCH_NOTIFIED . ")
");
}
set_die_append_msg($forum_id, $topic_id);
bb_die($lang['YOU_ARE_WATCHING']);
} else {
$is_watching_topic = 0;
}
}
} else {
if (isset($_GET['unwatch'])) {
if ($_GET['unwatch'] == 'topic') {
redirect(LOGIN_URL . "?redirect=" . TOPIC_URL . "$topic_id&unwatch=topic");
}
}
}
}
// Generate a 'Show posts in previous x days' select box. If the postdays var is POSTed
// then get it's value, find the number of topics with dates newer than it (to properly
// handle pagination) and alter the main query
$post_days = 0;
$limit_posts_time = '';
$total_replies = $t_data['topic_replies'] + 1;
if (!empty($_REQUEST['postdays'])) {
if ($post_days = (int)$_REQUEST['postdays']) {
if (!empty($_POST['postdays'])) {
$start = 0;
}
$min_post_time = TIMENOW - ($post_days * 86400);
$sql = "SELECT COUNT(p.post_id) AS num_posts
FROM " . BB_TOPICS . " t, " . BB_POSTS . " p
WHERE t.topic_id = $topic_id
AND p.topic_id = t.topic_id
AND p.post_time > $min_post_time";
$total_replies = ($row = DB()->fetch_row($sql)) ? $row['num_posts'] : 0;
$limit_posts_time = "AND p.post_time >= $min_post_time ";
}
}
// Decide how to order the post display
$post_order = (isset($_POST['postorder']) && $_POST['postorder'] !== 'asc') ? 'desc' : 'asc';
// //
// Go ahead and pull all data for this topic // Go ahead and pull all data for this topic
// //
@ -346,9 +217,8 @@ $sql = "
LEFT JOIN " . BB_USERS . " u2 ON(u2.user_id = p.mc_user_id) LEFT JOIN " . BB_USERS . " u2 ON(u2.user_id = p.mc_user_id)
LEFT JOIN " . BB_GROUPS . " g ON(g.group_id = p.poster_rg_id) LEFT JOIN " . BB_GROUPS . " g ON(g.group_id = p.poster_rg_id)
WHERE p.topic_id = $topic_id WHERE p.topic_id = $topic_id
$limit_posts_time
GROUP BY p.post_id GROUP BY p.post_id
ORDER BY p.post_time $post_order ORDER BY p.post_time ASC
LIMIT $start, $posts_per_page LIMIT $start, $posts_per_page
"; ";
@ -379,8 +249,6 @@ if (count($orig_word)) {
$new_topic_url = POSTING_URL . "?mode=newtopic&amp;f=" . $forum_id; $new_topic_url = POSTING_URL . "?mode=newtopic&amp;f=" . $forum_id;
$reply_topic_url = POSTING_URL . "?mode=reply&amp;t=" . $topic_id; $reply_topic_url = POSTING_URL . "?mode=reply&amp;t=" . $topic_id;
$view_forum_url = FORUM_URL . $forum_id; $view_forum_url = FORUM_URL . $forum_id;
$view_prev_topic_url = TOPIC_URL . $topic_id . "&amp;view=previous#newest";
$view_next_topic_url = TOPIC_URL . $topic_id . "&amp;view=next#newest";
$reply_img = ($t_data['forum_status'] == FORUM_LOCKED || $t_data['topic_status'] == TOPIC_LOCKED) ? $images['reply_locked'] : $images['reply_new']; $reply_img = ($t_data['forum_status'] == FORUM_LOCKED || $t_data['topic_status'] == TOPIC_LOCKED) ? $images['reply_locked'] : $images['reply_new'];
$reply_alt = ($t_data['forum_status'] == FORUM_LOCKED || $t_data['topic_status'] == TOPIC_LOCKED) ? $lang['TOPIC_LOCKED_SHORT'] : $lang['REPLY_TO_TOPIC']; $reply_alt = ($t_data['forum_status'] == FORUM_LOCKED || $t_data['topic_status'] == TOPIC_LOCKED) ? $lang['TOPIC_LOCKED_SHORT'] : $lang['REPLY_TO_TOPIC'];
@ -388,76 +256,26 @@ $reply_alt = ($t_data['forum_status'] == FORUM_LOCKED || $t_data['topic_status']
// Set 'body' template for attach_mod // Set 'body' template for attach_mod
$template->set_filenames(array('body' => 'viewtopic.tpl')); $template->set_filenames(array('body' => 'viewtopic.tpl'));
//
// User authorisation levels output
//
$s_auth_can = (($is_auth['auth_post']) ? $lang['RULES_POST_CAN'] : $lang['RULES_POST_CANNOT']) . '<br />';
$s_auth_can .= (($is_auth['auth_reply']) ? $lang['RULES_REPLY_CAN'] : $lang['RULES_REPLY_CANNOT']) . '<br />';
$s_auth_can .= (($is_auth['auth_edit']) ? $lang['RULES_EDIT_CAN'] : $lang['RULES_EDIT_CANNOT']) . '<br />';
$s_auth_can .= (($is_auth['auth_delete']) ? $lang['RULES_DELETE_CAN'] : $lang['RULES_DELETE_CANNOT']) . '<br />';
$s_auth_can .= (($is_auth['auth_vote']) ? $lang['RULES_VOTE_CAN'] : $lang['RULES_VOTE_CANNOT']) . '<br />';
$s_auth_can .= (($is_auth['auth_attachments']) ? $lang['RULES_ATTACH_CAN'] : $lang['RULES_ATTACH_CANNOT']) . '<br />';
$s_auth_can .= (($is_auth['auth_download']) ? $lang['RULES_DOWNLOAD_CAN'] : $lang['RULES_DOWNLOAD_CANNOT']) . '<br />';
// Moderator output // Moderator output
$topic_mod = ''; $topic_mod = '';
if ($is_auth['auth_mod']) { if ($is_auth['auth_mod']) {
$s_auth_can .= $lang['RULES_MODERATE']; $s_auth_can = $lang['RULES_MODERATE'];
$topic_mod .= "<a href=\"modcp.php?" . POST_TOPIC_URL . "=$topic_id&amp;mode=delete&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_delete'] . '" alt="' . $lang['DELETE_TOPIC'] . '" title="' . $lang['DELETE_TOPIC'] . '" border="0" /></a>&nbsp;'; $topic_mod .= "<a href=\"modcp.php?" . POST_TOPIC_URL . "=$topic_id&amp;mode=delete&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_delete'] . '" alt="' . $lang['DELETE_TOPIC'] . '" title="' . $lang['DELETE_TOPIC'] . '" border="0" /></a>&nbsp;';
$topic_mod .= "<a href=\"modcp.php?" . POST_TOPIC_URL . "=$topic_id&amp;mode=move&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_move'] . '" alt="' . $lang['MOVE_TOPIC'] . '" title="' . $lang['MOVE_TOPIC'] . '" border="0" /></a>&nbsp;'; $topic_mod .= "<a href=\"modcp.php?" . POST_TOPIC_URL . "=$topic_id&amp;mode=move&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_move'] . '" alt="' . $lang['MOVE_TOPIC'] . '" title="' . $lang['MOVE_TOPIC'] . '" border="0" /></a>&nbsp;';
$topic_mod .= ($t_data['topic_status'] == TOPIC_UNLOCKED) ? "<a href=\"modcp.php?" . POST_TOPIC_URL . "=$topic_id&amp;mode=lock&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_lock'] . '" alt="' . $lang['LOCK_TOPIC'] . '" title="' . $lang['LOCK_TOPIC'] . '" border="0" /></a>&nbsp;' : "<a href=\"modcp.php?" . POST_TOPIC_URL . "=$topic_id&amp;mode=unlock&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_unlock'] . '" alt="' . $lang['UNLOCK_TOPIC'] . '" title="' . $lang['UNLOCK_TOPIC'] . '" border="0" /></a>&nbsp;'; $topic_mod .= ($t_data['topic_status'] == TOPIC_UNLOCKED) ? "<a href=\"modcp.php?" . POST_TOPIC_URL . "=$topic_id&amp;mode=lock&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_lock'] . '" alt="' . $lang['LOCK_TOPIC'] . '" title="' . $lang['LOCK_TOPIC'] . '" border="0" /></a>&nbsp;' : "<a href=\"modcp.php?" . POST_TOPIC_URL . "=$topic_id&amp;mode=unlock&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_unlock'] . '" alt="' . $lang['UNLOCK_TOPIC'] . '" title="' . $lang['UNLOCK_TOPIC'] . '" border="0" /></a>&nbsp;';
$topic_mod .= "<a href=\"modcp.php?" . POST_TOPIC_URL . "=$topic_id&amp;mode=split&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_split'] . '" alt="' . $lang['SPLIT_TOPIC'] . '" title="' . $lang['SPLIT_TOPIC'] . '" border="0" /></a>&nbsp;'; $topic_mod .= "<a href=\"modcp.php?" . POST_TOPIC_URL . "=$topic_id&amp;mode=split&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_split'] . '" alt="' . $lang['SPLIT_TOPIC'] . '" title="' . $lang['SPLIT_TOPIC'] . '" border="0" /></a>&nbsp;';
if ($t_data['allow_reg_tracker'] || $t_data['topic_dl_type'] == TOPIC_DL_TYPE_DL || IS_ADMIN) {
if ($t_data['topic_dl_type'] == TOPIC_DL_TYPE_DL) {
$topic_mod .= "<a href=\"modcp.php?" . POST_TOPIC_URL . "=$topic_id&amp;mode=unset_download&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_normal'] . '" alt="' . $lang['UNSET_DL_STATUS'] . '" title="' . $lang['UNSET_DL_STATUS'] . '" border="0" /></a>';
} else {
$topic_mod .= "<a href=\"modcp.php?" . POST_TOPIC_URL . "=$topic_id&amp;mode=set_download&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_dl'] . '" alt="' . $lang['SET_DL_STATUS'] . '" title="' . $lang['SET_DL_STATUS'] . '" border="0" /></a>';
}
}
} elseif (($t_data['topic_poster'] == $userdata['user_id']) && $userdata['session_logged_in'] && $t_data['self_moderated']) { } elseif (($t_data['topic_poster'] == $userdata['user_id']) && $userdata['session_logged_in'] && $t_data['self_moderated']) {
$topic_mod .= "<a href=\"modcp.php?" . POST_TOPIC_URL . "=$topic_id&amp;mode=move&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_move'] . '" alt="' . $lang['MOVE_TOPIC'] . '" title="' . $lang['MOVE_TOPIC'] . '" border="0" /></a>&nbsp;'; $topic_mod .= "<a href=\"modcp.php?" . POST_TOPIC_URL . "=$topic_id&amp;mode=move&amp;sid=" . $userdata['session_id'] . '><img src="' . $images['topic_mod_move'] . '" alt="' . $lang['MOVE_TOPIC'] . '" title="' . $lang['MOVE_TOPIC'] . '" border="0" /></a>&nbsp;';
}
// Topic watch information
$s_watching_topic = $s_watching_topic_img = '';
if ($can_watch_topic) {
if ($is_watching_topic) {
$s_watching_topic = "<a href=\"" . TOPIC_URL . $topic_id . "&amp;unwatch=topic&amp;start=$start&amp;sid=" . $userdata['session_id'] . '">' . $lang['STOP_WATCHING_TOPIC'] . '</a>';
$s_watching_topic_img = (isset($images['topic_un_watch'])) ? "<a href=\"" . TOPIC_URL . "$topic_id&amp;unwatch=topic&amp;start=$start&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_un_watch'] . '" alt="' . $lang['STOP_WATCHING_TOPIC'] . '" title="' . $lang['STOP_WATCHING_TOPIC'] . '" border="0"></a>' : '';
} else {
$s_watching_topic = "<a href=\"" . TOPIC_URL . $topic_id . "&amp;watch=topic&amp;start=$start&amp;sid=" . $userdata['session_id'] . '">' . $lang['START_WATCHING_TOPIC'] . '</a>';
$s_watching_topic_img = (isset($images['Topic_watch'])) ? "<a href=\"" . TOPIC_URL . "$topic_id&amp;watch=topic&amp;start=$start&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['Topic_watch'] . '" alt="' . $lang['START_WATCHING_TOPIC'] . '" title="' . $lang['START_WATCHING_TOPIC'] . '" border="0"></a>' : '';
}
} }
// If we've got a hightlight set pass it on to pagination, // If we've got a hightlight set pass it on to pagination,
$pg_url = TOPIC_URL . $topic_id; $pg_url = TOPIC_URL . $topic_id;
$pg_url .= $post_days ? "&amp;postdays=$post_days" : '';
$pg_url .= ($post_order != 'asc') ? "&amp;postorder=$post_order" : '';
$pg_url .= isset($_REQUEST['single']) ? "&amp;single=1" : ''; $pg_url .= isset($_REQUEST['single']) ? "&amp;single=1" : '';
$pg_url .= $moderation ? "&amp;mod=1" : ''; $pg_url .= $moderation ? "&amp;mod=1" : '';
$pg_url .= ($posts_per_page != $bb_cfg['posts_per_page']) ? "&amp;ppp=$posts_per_page" : ''; $pg_url .= ($posts_per_page != $bb_cfg['posts_per_page']) ? "&amp;ppp=$posts_per_page" : '';
generate_pagination($pg_url, $total_replies, $posts_per_page, $start); generate_pagination($pg_url, $total_replies, $posts_per_page, $start);
// Selects
$sel_previous_days = array(
0 => $lang['ALL_POSTS'],
1 => $lang['1_DAY'],
7 => $lang['7_DAYS'],
14 => $lang['2_WEEKS'],
30 => $lang['1_MONTH'],
90 => $lang['3_MONTHS'],
180 => $lang['6_MONTHS'],
364 => $lang['1_YEAR'],
);
$sel_post_order_ary = array(
$lang['OLDEST_FIRST'] => 'asc',
$lang['NEWEST_FIRST'] => 'desc',
);
$topic_has_poll = ($t_data['topic_vote'] && !IS_GUEST); $topic_has_poll = ($t_data['topic_vote'] && !IS_GUEST);
$poll_time_expired = ($t_data['topic_time'] < TIMENOW - $bb_cfg['poll_max_days'] * 86400); $poll_time_expired = ($t_data['topic_time'] < TIMENOW - $bb_cfg['poll_max_days'] * 86400);
$can_manage_poll = ($t_data['topic_poster'] == $userdata['user_id'] || $is_auth['auth_mod']); $can_manage_poll = ($t_data['topic_poster'] == $userdata['user_id'] || $is_auth['auth_mod']);
@ -484,6 +302,7 @@ $template->assign_vars(array(
'REPLY_IMG' => $reply_img, 'REPLY_IMG' => $reply_img,
'SHOW_BOT_NICK' => $bb_cfg['show_bot_nick'], 'SHOW_BOT_NICK' => $bb_cfg['show_bot_nick'],
'T_POST_REPLY' => $reply_alt, 'T_POST_REPLY' => $reply_alt,
'SHOW_TOR_REGGED' => false,
'HIDE_AVATAR' => $user->opt_js['h_av'], 'HIDE_AVATAR' => $user->opt_js['h_av'],
'HIDE_RANK_IMG' => ($user->opt_js['h_rnk_i'] && $bb_cfg['show_rank_image']), 'HIDE_RANK_IMG' => ($user->opt_js['h_rnk_i'] && $bb_cfg['show_rank_image']),
@ -503,26 +322,18 @@ $template->assign_vars(array(
'IN_MODERATION' => $moderation, 'IN_MODERATION' => $moderation,
'SELECT_PPP' => ($moderation && $select_ppp && $total_replies > $posts_per_page) ? build_select('ppp', $select_ppp, $posts_per_page, null, null, 'onchange="$(\'#ppp\').submit();"') : '', 'SELECT_PPP' => ($moderation && $select_ppp && $total_replies > $posts_per_page) ? build_select('ppp', $select_ppp, $posts_per_page, null, null, 'onchange="$(\'#ppp\').submit();"') : '',
'S_SELECT_POST_DAYS' => build_select('postdays', array_flip($sel_previous_days), $post_days),
'S_SELECT_POST_ORDER' => build_select('postorder', $sel_post_order_ary, $post_order),
'S_POST_DAYS_ACTION' => TOPIC_URL . $topic_id . "&amp;start=$start",
'S_AUTH_LIST' => $s_auth_can,
'S_TOPIC_ADMIN' => $topic_mod,
'S_WATCH_TOPIC' => $s_watching_topic,
'S_WATCH_TOPIC_IMG' => $s_watching_topic_img,
'U_VIEW_TOPIC' => TOPIC_URL . $topic_id,
'U_VIEW_FORUM' => $view_forum_url,
'U_VIEW_OLDER_TOPIC' => $view_prev_topic_url,
'U_VIEW_NEWER_TOPIC' => $view_next_topic_url,
'U_POST_NEW_TOPIC' => $new_topic_url,
'U_POST_REPLY_TOPIC' => $reply_topic_url,
'U_SEARCH_SELF' => "search.php?uid={$userdata['user_id']}&t=$topic_id&dm=1",
'TOPIC_HAS_POLL' => $topic_has_poll, 'TOPIC_HAS_POLL' => $topic_has_poll,
'POLL_IS_EDITABLE' => (!$poll_time_expired), 'POLL_IS_EDITABLE' => (!$poll_time_expired),
'POLL_IS_FINISHED' => ($t_data['topic_vote'] == POLL_FINISHED), 'POLL_IS_FINISHED' => ($t_data['topic_vote'] == POLL_FINISHED),
'CAN_MANAGE_POLL' => $can_manage_poll, 'CAN_MANAGE_POLL' => $can_manage_poll,
'CAN_ADD_POLL' => $can_add_poll, 'CAN_ADD_POLL' => $can_add_poll,
'S_TOPIC_ADMIN' => $topic_mod,
'U_VIEW_TOPIC' => TOPIC_URL . $topic_id,
'U_VIEW_FORUM' => $view_forum_url,
'U_POST_NEW_TOPIC' => $new_topic_url,
'U_POST_REPLY_TOPIC' => $reply_topic_url,
'U_SEARCH_SELF' => "search.php?uid={$userdata['user_id']}&t=$topic_id&dm=1",
)); ));
// Does this topic contain DL-List? // Does this topic contain DL-List?
@ -533,11 +344,6 @@ $template->assign_vars(array(
)); ));
require INC_DIR . '/torrent_show_dl_list.php'; require INC_DIR . '/torrent_show_dl_list.php';
if ($topic_attachment) {
require ATTACH_DIR . '/attachment_mod.php';
init_display_post_attachments($t_data['topic_attachment']);
}
// //
// Update the topic view counter // Update the topic view counter
// //
@ -569,6 +375,9 @@ $prev_post_time = $max_post_time = 0;
for ($i = 0; $i < $total_posts; $i++) { for ($i = 0; $i < $total_posts; $i++) {
$poster_id = $postrow[$i]['user_id']; $poster_id = $postrow[$i]['user_id'];
$poster = ($poster_id == GUEST_UID) ? $lang['GUEST'] : $postrow[$i]['username']; $poster = ($poster_id == GUEST_UID) ? $lang['GUEST'] : $postrow[$i]['username'];
$poster_guest = ($poster_id == GUEST_UID);
$poster_bot = ($poster_id == BOT_UID);
$post_date = bb_date($postrow[$i]['post_time'], $bb_cfg['post_date_format']); $post_date = bb_date($postrow[$i]['post_time'], $bb_cfg['post_date_format']);
$max_post_time = max($max_post_time, $postrow[$i]['post_time']); $max_post_time = max($max_post_time, $postrow[$i]['post_time']);
$poster_posts = ($poster_id != GUEST_UID) ? $postrow[$i]['user_posts'] : ''; $poster_posts = ($poster_id != GUEST_UID) ? $postrow[$i]['user_posts'] : '';
@ -576,11 +385,12 @@ for ($i = 0; $i < $total_posts; $i++) {
$poster_joined = ($poster_id != GUEST_UID) ? $lang['JOINED'] . ': ' . bb_date($postrow[$i]['user_regdate'], $bb_cfg['date_format']) : ''; $poster_joined = ($poster_id != GUEST_UID) ? $lang['JOINED'] . ': ' . bb_date($postrow[$i]['user_regdate'], $bb_cfg['date_format']) : '';
$poster_longevity = ($poster_id != GUEST_UID) ? delta_time($postrow[$i]['user_regdate']) : ''; $poster_longevity = ($poster_id != GUEST_UID) ? delta_time($postrow[$i]['user_regdate']) : '';
$post_id = $postrow[$i]['post_id']; $post_id = $postrow[$i]['post_id'];
$mc_type = $postrow[$i]['mc_type']; $mc_type = $postrow[$i]['mc_type'];
$mc_comment = $postrow[$i]['mc_comment']; $mc_comment = $postrow[$i]['mc_comment'];
$mc_user_id = profile_url(array('username' => $postrow[$i]['mc_username'], 'user_id' => $postrow[$i]['mc_user_id'], 'user_rank' => $postrow[$i]['mc_user_rank'])); $mc_user_id = profile_url(array('username' => $postrow[$i]['mc_username'], 'user_id' => $postrow[$i]['mc_user_id'], 'user_rank' => $postrow[$i]['mc_user_rank']));
$rg_id = ($postrow[$i]['poster_rg_id']) ?: 0; $rg_id = $postrow[$i]['poster_rg_id'] ?: 0;
$rg_avatar = get_avatar(GROUP_AVATAR_MASK . $rg_id, $postrow[$i]['rg_avatar_id']); $rg_avatar = get_avatar(GROUP_AVATAR_MASK . $rg_id, $postrow[$i]['rg_avatar_id']);
$rg_name = ($postrow[$i]['group_name']) ? htmlCHR($postrow[$i]['group_name']) : ''; $rg_name = ($postrow[$i]['group_name']) ? htmlCHR($postrow[$i]['group_name']) : '';
$rg_signature = ($postrow[$i]['group_signature']) ? bbcode2html(htmlCHR($postrow[$i]['group_signature'])) : ''; $rg_signature = ($postrow[$i]['group_signature']) ? bbcode2html(htmlCHR($postrow[$i]['group_signature'])) : '';
@ -592,7 +402,7 @@ for ($i = 0; $i < $total_posts; $i++) {
$poster_rank = $rank_image = ''; $poster_rank = $rank_image = '';
$user_rank = $postrow[$i]['user_rank']; $user_rank = $postrow[$i]['user_rank'];
if (!$user->opt_js['h_rnk_i'] and isset($ranks[$user_rank])) { if (!$user->opt_js['h_rnk_i'] && isset($ranks[$user_rank])) {
$rank_image = ($bb_cfg['show_rank_image'] && $ranks[$user_rank]['rank_image']) ? '<img src="' . $ranks[$user_rank]['rank_image'] . '" alt="" title="" border="0" />' : ''; $rank_image = ($bb_cfg['show_rank_image'] && $ranks[$user_rank]['rank_image']) ? '<img src="' . $ranks[$user_rank]['rank_image'] . '" alt="" title="" border="0" />' : '';
$poster_rank = ($bb_cfg['show_rank_text']) ? $ranks[$user_rank]['rank_title'] : ''; $poster_rank = ($bb_cfg['show_rank_text']) ? $ranks[$user_rank]['rank_title'] : '';
} }
@ -603,7 +413,7 @@ for ($i = 0; $i < $total_posts; $i++) {
} }
// Buttons // Buttons
$pm_btn = $profile_btn = $delpost_btn = $edit_btn = $ip_btn = $quote_btn = ''; $pm_btn = $profile_btn = $delpost_btn = $edit_btn = $ip_btn = '';
if ($poster_id != GUEST_UID) { if ($poster_id != GUEST_UID) {
$profile_btn = true; $profile_btn = true;
@ -611,7 +421,6 @@ for ($i = 0; $i < $total_posts; $i++) {
} }
if ($poster_id != BOT_UID) { if ($poster_id != BOT_UID) {
$quote_btn = true;
$edit_btn = (($userdata['user_id'] == $poster_id && $is_auth['auth_edit']) || $is_auth['auth_mod']); $edit_btn = (($userdata['user_id'] == $poster_id && $is_auth['auth_edit']) || $is_auth['auth_mod']);
$ip_btn = ($is_auth['auth_mod'] || IS_MOD); $ip_btn = ($is_auth['auth_mod'] || IS_MOD);
} }
@ -695,26 +504,29 @@ for ($i = 0; $i < $total_posts; $i++) {
$template->assign_block_vars('postrow', array( $template->assign_block_vars('postrow', array(
'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2', 'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2',
'POST_ID' => $post_id, 'POST_ID' => $post_id,
'IS_NEWEST' => ($post_id == $newest), 'IS_NEWEST' => $post_id == $newest,
'IS_FIRST_POST' => $is_first_post,
'POSTER_NAME' => profile_url(array('username' => $poster, 'user_rank' => $user_rank)), 'POSTER_NAME' => profile_url(array('username' => $poster, 'user_rank' => $user_rank)),
'POSTER_NAME_JS' => addslashes($poster), 'POSTER_NAME_JS' => addslashes($poster),
'POSTER_RANK' => $poster_rank, 'POSTER_RANK' => $poster_rank,
'RANK_IMAGE' => $rank_image, 'RANK_IMAGE' => $rank_image,
'POSTER_JOINED' => ($bb_cfg['show_poster_joined']) ? $poster_longevity : '', 'POSTER_JOINED' => $bb_cfg['show_poster_joined'] ? $poster_longevity : '',
'POSTER_JOINED_DATE' => $poster_joined, 'POSTER_JOINED_DATE' => $poster_joined,
'POSTER_POSTS' => ($bb_cfg['show_poster_posts']) ? $poster_posts : '', 'POSTER_POSTS' => $bb_cfg['show_poster_posts'] ? $poster_posts : '',
'POSTER_FROM' => ($bb_cfg['show_poster_from']) ? wbr($poster_from) : '', 'POSTER_FROM' => $bb_cfg['show_poster_from'] ? wbr($poster_from) : '',
'POSTER_BOT' => ($poster_id == BOT_UID), 'POSTER_GENDER' => $bb_cfg['gender'] ? gender_image($postrow[$i]['user_gender']) : '',
'POSTER_ID' => $poster_id, 'POSTER_ID' => $poster_id,
'POSTER_AUTHOR' => ($poster_id == $t_data['topic_poster']), 'POSTER_BOT' => $poster_bot,
'POSTER_GENDER' => ($bb_cfg['gender']) ? gender_image($postrow[$i]['user_gender']) : '', 'POSTER_GUEST' => $poster_guest,
'POSTED_AFTER' => ($prev_post_time) ? delta_time($postrow[$i]['post_time'], $prev_post_time) : '', 'POSTER_AUTHOR' => $poster_id == $t_data['topic_poster'],
'POSTED_AFTER' => $prev_post_time ? delta_time($postrow[$i]['post_time'], $prev_post_time) : '',
'IS_UNREAD' => is_unread($postrow[$i]['post_time'], $topic_id, $forum_id), 'IS_UNREAD' => is_unread($postrow[$i]['post_time'], $topic_id, $forum_id),
'IS_FIRST_POST' => (!$start && $is_first_post), 'MOD_CHECKBOX' => $moderation && ($start || defined('SPLIT_FORM_START')),
'MOD_CHECKBOX' => ($moderation && ($start || defined('SPLIT_FORM_START'))),
'POSTER_AVATAR' => $poster_avatar, 'POSTER_AVATAR' => $poster_avatar,
'POST_NUMBER' => ($i + $start + 1), 'POST_NUMBER' => $i + $start + 1,
'POST_DATE' => $post_date, 'POST_DATE' => $post_date,
'MESSAGE' => $message, 'MESSAGE' => $message,
'SIGNATURE' => $user_sig, 'SIGNATURE' => $user_sig,
@ -723,15 +535,15 @@ for ($i = 0; $i < $total_posts; $i++) {
'PM' => $pm_btn, 'PM' => $pm_btn,
'PROFILE' => $profile_btn, 'PROFILE' => $profile_btn,
'QUOTE' => $quote_btn, 'QUOTE' => (!$poster_bot),
'EDIT' => $edit_btn, 'EDIT' => $edit_btn,
'DELETE' => $delpost_btn, 'DELETE' => (!$is_first_post) ? $delpost_btn : '',
'IP' => $ip_btn, 'IP' => $ip_btn,
'POSTER_BIRTHDAY' => user_birthday_icon($postrow[$i]['user_birthday'], $postrow[$i]['user_id']), 'POSTER_BIRTHDAY' => user_birthday_icon($postrow[$i]['user_birthday'], $postrow[$i]['user_id']),
'MC_COMMENT' => ($mc_type) ? bbcode2html($mc_comment) : '', 'MC_COMMENT' => $mc_type ? bbcode2html($mc_comment) : '',
'MC_BBCODE' => ($mc_type) ? $mc_comment : '', 'MC_BBCODE' => $mc_type ? $mc_comment : '',
'MC_CLASS' => $mc_class, 'MC_CLASS' => $mc_class,
'MC_TITLE' => sprintf($lang['MC_COMMENT'][$mc_type]['title'], $mc_user_id), 'MC_TITLE' => sprintf($lang['MC_COMMENT'][$mc_type]['title'], $mc_user_id),
'MC_SELECT_TYPE' => build_select("mc_type_$post_id", array_flip($mc_select_type), $mc_type), 'MC_SELECT_TYPE' => build_select("mc_type_$post_id", array_flip($mc_select_type), $mc_type),
@ -744,11 +556,20 @@ for ($i = 0; $i < $total_posts; $i++) {
'RG_SIG_ATTACH' => $postrow[$i]['attach_rg_sig'], 'RG_SIG_ATTACH' => $postrow[$i]['attach_rg_sig'],
)); ));
if (isset($postrow[$i]['post_attachment']) && $is_auth['auth_download'] && function_exists('display_post_attachments')) { if ($is_first_post && $t_data['attach_ext_id']) {
display_post_attachments($post_id, $postrow[$i]['post_attachment']); if (IS_GUEST) {
$template->assign_var('SHOW_GUEST_DL_STUB', ($t_data['attach_ext_id'] == 8));
} elseif ($t_data['attach_ext_id'] == 8) {
require(INC_DIR . 'viewtopic_torrent.php');
} else {
$template->assign_vars(array(
'SHOW_ATTACH_DL_LINK' => true,
'ATTACH_FILESIZE' => humn_size($t_data['filesize']),
));
}
} }
if ($moderation && !defined('SPLIT_FORM_START') && ($start || $post_id == $t_data['topic_first_post_id'])) { if ($moderation && !defined('SPLIT_FORM_START') && ($start || $is_first_post)) {
define('SPLIT_FORM_START', true); define('SPLIT_FORM_START', true);
} }
@ -776,16 +597,8 @@ if ($bb_cfg['show_quick_reply']) {
'QUICK_REPLY' => true, 'QUICK_REPLY' => true,
'QR_POST_ACTION' => POSTING_URL, 'QR_POST_ACTION' => POSTING_URL,
'QR_TOPIC_ID' => $topic_id, 'QR_TOPIC_ID' => $topic_id,
'CAPTCHA_HTML' => (IS_GUEST) ? bb_captcha('get') : '', 'CAPTCHA_HTML' => IS_GUEST ? bb_captcha('get') : '',
)); ));
if (!IS_GUEST) {
$notify_user = bf($userdata['user_opt'], 'user_opt', 'user_notify');
$template->assign_vars(array(
'QR_NOTIFY_CHECKED' => ($notify_user) ? $notify_user && $is_watching_topic : $is_watching_topic,
));
}
} }
} }