From 6e0786bdee8f1a2557f9ac1dc628983bcafe3f5f Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Tue, 6 May 2025 12:55:18 +0300 Subject: [PATCH] feat(announcer): Check for frozen torrents (#1770) * feat(announcer): Check for frozen torrents * Update announce.php * Update announce.php * Update announce.php * Update announce.php * Update announce.php * Update announce.php * Updated * Update announce.php * Update announce.php * Update announce.php * Update announce.php * Update announce.php --- bt/announce.php | 18 ++++++++++++++++-- library/defines.php | 10 ++++++++++ library/includes/init_bb.php | 10 ---------- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/bt/announce.php b/bt/announce.php index 67ade667b..91d9d1e23 100644 --- a/bt/announce.php +++ b/bt/announce.php @@ -248,9 +248,10 @@ if ($lp_info) { $passkey_sql = DB()->escape($passkey); $sql = " - SELECT tor.topic_id, tor.poster_id, tor.tor_type, tor.info_hash, tor.info_hash_v2, u.* + SELECT tor.topic_id, tor.poster_id, tor.tor_type, tor.tor_status, tor.info_hash, tor.info_hash_v2, bt.*, u.user_level FROM " . BB_BT_TORRENTS . " tor - LEFT JOIN " . BB_BT_USERS . " u ON u.auth_key = '$passkey_sql' + LEFT JOIN " . BB_BT_USERS . " bt ON bt.auth_key = '$passkey_sql' + LEFT JOIN " . BB_USERS . " u ON u.user_id = bt.user_id $info_hash_where LIMIT 1 "; @@ -266,9 +267,22 @@ if ($lp_info) { // Assign variables $user_id = $row['user_id']; + define('IS_GUEST', (int)$user_id === GUEST_UID); + define('IS_ADMIN', !IS_GUEST && (int)$row['user_level'] === ADMIN); + define('IS_MOD', !IS_GUEST && (int)$row['user_level'] === MOD); + define('IS_GROUP_MEMBER', !IS_GUEST && (int)$row['user_level'] === GROUP_MEMBER); + define('IS_USER', !IS_GUEST && (int)$row['user_level'] === USER); + define('IS_SUPER_ADMIN', IS_ADMIN && isset($bb_cfg['super_admins'][$user_id])); + define('IS_AM', IS_ADMIN || IS_MOD); $topic_id = $row['topic_id']; $releaser = (int)($user_id == $row['poster_id']); $tor_type = $row['tor_type']; + $tor_status = $row['tor_status']; + + // Check tor status + if (!IS_AM && isset($bb_cfg['tor_frozen'][$tor_status]) && !(isset($bb_cfg['tor_frozen_author_download'][$tor_status]) && $releaser)) { + msg_die('Torrent frozen and cannot be downloaded'); + } // Check hybrid status if (!empty($row['info_hash']) && !empty($row['info_hash_v2'])) { diff --git a/library/defines.php b/library/defines.php index dbb636585..30d3d3ab2 100644 --- a/library/defines.php +++ b/library/defines.php @@ -89,6 +89,7 @@ define('BB_BT_TORRENTS', 'bb_bt_torrents'); define('BB_BT_TRACKER', 'bb_bt_tracker'); define('BB_BT_TRACKER_SNAP', 'bb_bt_tracker_snap'); define('BB_BT_USERS', 'bb_bt_users'); +define('BB_USERS', 'bb_users'); define('BT_AUTH_KEY_LENGTH', 20); // Passkey length // Torrents (reserved: -1) @@ -134,6 +135,15 @@ define('ONLY_NEW_TOPICS', 2); define('GUEST_UID', -1); define('BOT_UID', -746); +// User Levels +define('DELETED', -1); +define('USER', 0); +define('ADMIN', 1); +define('MOD', 2); +define('GROUP_MEMBER', 20); +define('CP_HOLDER', 25); +define('EXCLUDED_USERS', implode(',', [GUEST_UID, BOT_UID])); + // Ratio limits define('TR_RATING_LIMITS', true); // ON/OFF define('MIN_DL_FOR_RATIO', 10737418240); // 10 GB in bytes, 0 - disable diff --git a/library/includes/init_bb.php b/library/includes/init_bb.php index e9ba19f4b..932dba5a1 100644 --- a/library/includes/init_bb.php +++ b/library/includes/init_bb.php @@ -104,15 +104,6 @@ function bb_setcookie(string $name, mixed $val, int $lifetime = COOKIE_PERSIST, } } -// User Levels -define('DELETED', -1); -define('USER', 0); -define('ADMIN', 1); -define('MOD', 2); -define('GROUP_MEMBER', 20); -define('CP_HOLDER', 25); -define('EXCLUDED_USERS', implode(',', [GUEST_UID, BOT_UID])); - // User related define('USER_ACTIVATION_NONE', 0); define('USER_ACTIVATION_SELF', 1); @@ -257,7 +248,6 @@ define('BB_TOPIC_TPL', 'bb_topic_tpl'); define('BB_TOPICS', 'bb_topics'); define('BB_TOPICS_WATCH', 'bb_topics_watch'); define('BB_USER_GROUP', 'bb_user_group'); -define('BB_USERS', 'bb_users'); define('BB_WORDS', 'bb_words'); define('BB_THX', 'bb_thx');