Продолжение исправлений ошибок после интеграции новой системы вложений. Небольшая чистка таблиц.

This commit is contained in:
Exile 2016-02-17 05:22:00 +03:00
commit 7518f87997
10 changed files with 53 additions and 71 deletions

View file

@ -46,7 +46,7 @@ $user_list = DB()->fetch_rowset("
"); ");
$subject = sprintf($lang['CALLSEED_SUBJECT'], $t_data['topic_title']); $subject = sprintf($lang['CALLSEED_SUBJECT'], $t_data['topic_title']);
$message = sprintf($lang['CALLSEED_TEXT'], make_url(TOPIC_URL . $topic_id), $t_data['topic_title'], make_url(DOWNLOAD_URL . $t_data['attach_id'])); $message = sprintf($lang['CALLSEED_TEXT'], make_url(TOPIC_URL . $topic_id), $t_data['topic_title'], make_url(DOWNLOAD_URL . $topic_id));
if ($user_list) if ($user_list)
{ {
@ -76,7 +76,7 @@ function topic_info ($topic_id)
$sql = " $sql = "
SELECT SELECT
tor.poster_id, tor.forum_id, tor.attach_id, tor.call_seed_time, tor.poster_id, tor.forum_id, tor.call_seed_time,
t.topic_title, sn.seeders t.topic_title, sn.seeders
FROM ". BB_BT_TORRENTS ." tor FROM ". BB_BT_TORRENTS ." tor
LEFT JOIN ". BB_TOPICS ." t USING(topic_id) LEFT JOIN ". BB_TOPICS ." t USING(topic_id)

28
dl.php
View file

@ -33,18 +33,17 @@ if (!$t_data['attach_ext_id'])
// Auth check // Auth check
$is_auth = auth(AUTH_ALL, $t_data['forum_id'], $userdata, $t_data); $is_auth = auth(AUTH_ALL, $t_data['forum_id'], $userdata, $t_data);
$guest_allow = false; if (!IS_GUEST)
if (!IS_GUEST) $guest_allow = true; {
if (IS_GUEST && $bb_cfg['guest_tracker']) $guest_allow = true; if (!$is_auth['auth_download']) login_redirect($bb_cfg['dl_url'] . $topic_id);
if ($t_data['attach_ext_id'] != 8 && !$is_auth['auth_download']) login_redirect($bb_cfg['dl_url'] . $topic_id); }
if ($t_data['attach_ext_id'] == 8 && (!$is_auth['auth_download'] || !$guest_allow)) login_redirect($bb_cfg['dl_url'] . $topic_id); elseif (!$bb_cfg['tracker']['guest_tracker'])
{
login_redirect($bb_cfg['dl_url'] . $topic_id);
}
// Downloads counter
// Проверка рефёрера (не качать с других сайтов) DB()->sql_query('UPDATE ' . BB_TOPICS . ' SET attach_dl_cnt = attach_dl_cnt + 1 WHERE topic_id = ' . $topic_id);
$referer = (!empty($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : '';
if (!preg_match("/". $bb_cfg['server_name']."/", $referer)) exit;
DB()->sql_query('UPDATE ' . BB_TOPICS . ' SET download_count = download_count + 1 WHERE topic_id = ' . (int) $t_data['topic_id']);
// Captcha for guest // Captcha for guest
if (IS_GUEST && !bb_captcha('check')) if (IS_GUEST && !bb_captcha('check'))
@ -52,7 +51,7 @@ if (IS_GUEST && !bb_captcha('check'))
global $template; global $template;
$redirect_url = isset($_POST['redirect_url']) ? $_POST['redirect_url'] : (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/'); $redirect_url = isset($_POST['redirect_url']) ? $_POST['redirect_url'] : (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/');
$message = '<form action="'. DOWNLOAD_URL . $attachment['attach_id'] .'" method="post">'; $message = '<form action="'. DOWNLOAD_URL . $topic_id .'" method="post">'; //!
$message .= $lang['CAPTCHA'].':'; $message .= $lang['CAPTCHA'].':';
$message .= '<div class="mrg_10" align="center">'. bb_captcha('get') .'</div>'; $message .= '<div class="mrg_10" align="center">'. bb_captcha('get') .'</div>';
$message .= '<input type="hidden" name="redirect_url" value="'. $redirect_url .'" />'; $message .= '<input type="hidden" name="redirect_url" value="'. $redirect_url .'" />';
@ -71,17 +70,12 @@ if (IS_GUEST && !bb_captcha('check'))
$t_data['user_id'] = $userdata['user_id']; $t_data['user_id'] = $userdata['user_id'];
$t_data['is_am'] = IS_AM; $t_data['is_am'] = IS_AM;
//die(var_dump($t_data));
// Torrent // Torrent
if ($t_data['attach_ext_id'] == 8) if ($t_data['attach_ext_id'] == 8)
{
if (!(isset($_GET['original']) && !IS_USER))
{ {
require(INC_DIR .'functions_torrent.php'); require(INC_DIR .'functions_torrent.php');
send_torrent_with_passkey($t_data); send_torrent_with_passkey($t_data);
} }
}
// All other // All other
$file_path = get_attach_path($topic_id, $t_data['attach_ext_id']); $file_path = get_attach_path($topic_id, $t_data['attach_ext_id']);

View file

@ -181,24 +181,6 @@ CREATE TABLE IF NOT EXISTS `bb_bt_torstat` (
-- Records of bb_bt_torstat -- Records of bb_bt_torstat
-- ---------------------------- -- ----------------------------
-- ----------------------------
-- Table structure for `bb_bt_tor_dl_stat`
-- ----------------------------
DROP TABLE IF EXISTS `bb_bt_tor_dl_stat`;
CREATE TABLE IF NOT EXISTS `bb_bt_tor_dl_stat` (
`topic_id` mediumint(8) unsigned NOT NULL DEFAULT '0',
`user_id` mediumint(9) NOT NULL DEFAULT '0',
`attach_id` mediumint(8) unsigned NOT NULL DEFAULT '0',
`t_up_total` bigint(20) unsigned NOT NULL DEFAULT '0',
`t_down_total` bigint(20) unsigned NOT NULL DEFAULT '0',
`t_bonus_total` bigint(20) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`topic_id`,`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of bb_bt_tor_dl_stat
-- ----------------------------
-- ---------------------------- -- ----------------------------
-- Table structure for `bb_bt_tracker` -- Table structure for `bb_bt_tracker`
-- ---------------------------- -- ----------------------------
@ -882,6 +864,7 @@ CREATE TABLE IF NOT EXISTS `bb_topics` (
`topic_moved_id` mediumint(8) unsigned NOT NULL DEFAULT '0', `topic_moved_id` mediumint(8) unsigned 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_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', `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',
@ -895,7 +878,7 @@ CREATE TABLE IF NOT EXISTS `bb_topics` (
-- ---------------------------- -- ----------------------------
-- Records of bb_topics -- Records of bb_topics
-- ---------------------------- -- ----------------------------
INSERT INTO `bb_topics` VALUES ('1', '1', 'Добро пожаловать в TorrentPier', '2', UNIX_TIMESTAMP(), '2', '0', '0', '0', '0', '1', '1', '0', '0', '0', '0', UNIX_TIMESTAMP(), '0'); INSERT INTO `bb_topics` VALUES ('1', '1', 'Добро пожаловать в TorrentPier', '2', UNIX_TIMESTAMP(), '2', '0', '0', '0', '0', '1', '1', '0', '0', '0', '0', '0', UNIX_TIMESTAMP(), '0');
-- ---------------------------- -- ----------------------------
-- Table structure for `bb_topics_watch` -- Table structure for `bb_topics_watch`

View file

@ -54,7 +54,7 @@ DROP TABLE IF EXISTS `bb_captcha`;
DELETE FROM `bb_cron` WHERE `cron_script` = 'captcha_gen_gc.php'; DELETE FROM `bb_cron` WHERE `cron_script` = 'captcha_gen_gc.php';
INSERT INTO `bb_cron` VALUES ('', '1', 'Accrual seedbonus', 'tr_seed_bonus.php', 'interval', '', '', '25', '', '', '00:15:00', '0', '', '0', '0', '0'); INSERT INTO `bb_cron` VALUES ('', '1', 'Accrual seedbonus', 'tr_seed_bonus.php', 'interval', '', '', '25', '', '', '00:15:00', '0', '', '0', '0', '0');
// 2.1.6 // 2.2.0
DROP TABLE IF EXISTS `bb_ads`; DROP TABLE IF EXISTS `bb_ads`;
DELETE FROM `bb_config` WHERE `config_name` = 'active_ads'; DELETE FROM `bb_config` WHERE `config_name` = 'active_ads';
DELETE FROM `bb_cron` WHERE `cron_script` = 'attach_maintenance.php'; DELETE FROM `bb_cron` WHERE `cron_script` = 'attach_maintenance.php';
@ -73,5 +73,8 @@ DELETE FROM `bb_config` WHERE `config_name` = 'bt_check_announce_url';
ALTER TABLE `bb_forums` ADD `forum_last_topic_time` INT NOT NULL AFTER `forum_last_post_id`; ALTER TABLE `bb_forums` ADD `forum_last_topic_time` INT NOT NULL AFTER `forum_last_post_id`;
DROP TABLE IF EXISTS `bb_extensions`; DROP TABLE IF EXISTS `bb_extensions`;
DROP TABLE IF EXISTS `bb_extension_groups`; DROP TABLE IF EXISTS `bb_extension_groups`;
define('BB_ATTACHMENTS_DESC', 'bb_attachments_desc'); - удалить при апгрейде DROP TABLE IF EXISTS `bb_attachments_desc`;
define('BB_ATTACHMENTS', 'bb_attachments'); - удалить при апгрейде DROP TABLE IF EXISTS `bb_attachments`;
ALTER TABLE `bb_topics` ADD `tracker_id` TINYINT(4) NOT NULL DEFAULT '0' AFTER `topic_moved_id`;
ALTER TABLE `bb_topics` ADD `attach_dl_cnt` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0' AFTER `attach_ext_id`;
DROP TABLE IF EXISTS `bb_bt_tor_dl_stat`;

View file

@ -18,14 +18,15 @@ 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)
{ {
change_tor_status($attach_id, $status); 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':

View file

@ -6,7 +6,7 @@ global $lang;
if (!isset($this->request['t'])) if (!isset($this->request['t']))
{ {
$this->ajax_die($lang['EMPTY_ATTACH_ID']); $this->ajax_die('empty topic_id'); // TODO: перевести
} }
$topic_id = (int) $this->request['t']; $topic_id = (int) $this->request['t'];

View file

@ -477,6 +477,7 @@ $config = [
'retracker' => true, 'retracker' => true,
'retracker_host' => 'http://retracker.local/announce', 'retracker_host' => 'http://retracker.local/announce',
'freeleech' => false, 'freeleech' => false,
'guest_tracker' => false,
], ],
// Ratio settings // Ratio settings

View file

@ -155,7 +155,7 @@ if ($tor_reged)
'FILESIZE' => $tor_file_size, 'FILESIZE' => $tor_file_size,
'MAGNET' => $tor_magnet, 'MAGNET' => $tor_magnet,
'HASH' => strtoupper(bin2hex($tor_info['info_hash'])), 'HASH' => strtoupper(bin2hex($tor_info['info_hash'])),
'DOWNLOAD_COUNT' => sprintf($lang['DOWNLOAD_NUMBER'], 666/*$download_count*/), // TODO: подсчет числа скачиваний вложения (?) или удалить 'DOWNLOAD_COUNT' => declension($t_data['attach_dl_cnt'], 'times'),
'REGED_TIME' => bb_date($tor_info['reg_time']), 'REGED_TIME' => bb_date($tor_info['reg_time']),
'SHOW_TOR_REGGED' => true, 'SHOW_TOR_REGGED' => true,

View file

@ -478,7 +478,7 @@ td.topic_id { cursor: pointer; }
<!-- BEGIN tor --> <!-- BEGIN tor -->
<div title="{L_DL_TORRENT}"> <div title="{L_DL_TORRENT}">
<div><span class="seedmed" title="Seeders"><b>{t.tor.SEEDERS}</b></span><span class="med"> | </span><span class="leechmed" title="Leechers"><b>{t.tor.LEECHERS}</b></span></div> <div><span class="seedmed" title="Seeders"><b>{t.tor.SEEDERS}</b></span><span class="med"> | </span><span class="leechmed" title="Leechers"><b>{t.tor.LEECHERS}</b></span></div>
<div style="padding-top: 2px" class="small"><!-- IF t.TOR_FROZEN -->{t.tor.TOR_SIZE}<!-- ELSE --><a href="{DOWNLOAD_URL}{t.tor.ATTACH_ID}" class="small" style="text-decoration: none">{t.tor.TOR_SIZE}</a> <!-- IF MAGNET_LINKS -->{t.tor.MAGNET}<!-- ENDIF --><!-- ENDIF --></div> <div style="padding-top: 2px" class="small"><!-- IF t.TOR_FROZEN -->{t.tor.TOR_SIZE}<!-- ELSE --><a href="{DOWNLOAD_URL}{t.TOPIC_ID}" class="small" style="text-decoration: none">{t.tor.TOR_SIZE}</a> <!-- IF MAGNET_LINKS -->{t.tor.MAGNET}<!-- ENDIF --><!-- ENDIF --></div>
</div> </div>
<!-- END tor --> <!-- END tor -->
</td> </td>

View file

@ -100,7 +100,7 @@
</tr> </tr>
<tr class="row1"> <tr class="row1">
<td>{L_COMPLETED}:</td> <td>{L_COMPLETED}:</td>
<td><span title="{L_DOWNLOADED}: {DOWNLOAD_COUNT}">{TOR_COMPLETED}</span></td> <td>{DOWNLOAD_COUNT}</td>
</tr> </tr>
<tr class="row1"> <tr class="row1">
<td>{L_SIZE}:</td> <td>{L_SIZE}:</td>