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
This commit is contained in:
Roman Kelesidis 2025-05-06 12:55:18 +03:00 committed by GitHub
commit 6e0786bdee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 12 deletions

View file

@ -248,9 +248,10 @@ if ($lp_info) {
$passkey_sql = DB()->escape($passkey); $passkey_sql = DB()->escape($passkey);
$sql = " $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 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 $info_hash_where
LIMIT 1 LIMIT 1
"; ";
@ -266,9 +267,22 @@ if ($lp_info) {
// Assign variables // Assign variables
$user_id = $row['user_id']; $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']; $topic_id = $row['topic_id'];
$releaser = (int)($user_id == $row['poster_id']); $releaser = (int)($user_id == $row['poster_id']);
$tor_type = $row['tor_type']; $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 // Check hybrid status
if (!empty($row['info_hash']) && !empty($row['info_hash_v2'])) { if (!empty($row['info_hash']) && !empty($row['info_hash_v2'])) {

View file

@ -89,6 +89,7 @@ define('BB_BT_TORRENTS', 'bb_bt_torrents');
define('BB_BT_TRACKER', 'bb_bt_tracker'); define('BB_BT_TRACKER', 'bb_bt_tracker');
define('BB_BT_TRACKER_SNAP', 'bb_bt_tracker_snap'); define('BB_BT_TRACKER_SNAP', 'bb_bt_tracker_snap');
define('BB_BT_USERS', 'bb_bt_users'); define('BB_BT_USERS', 'bb_bt_users');
define('BB_USERS', 'bb_users');
define('BT_AUTH_KEY_LENGTH', 20); // Passkey length define('BT_AUTH_KEY_LENGTH', 20); // Passkey length
// Torrents (reserved: -1) // Torrents (reserved: -1)
@ -134,6 +135,15 @@ define('ONLY_NEW_TOPICS', 2);
define('GUEST_UID', -1); define('GUEST_UID', -1);
define('BOT_UID', -746); 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 // Ratio limits
define('TR_RATING_LIMITS', true); // ON/OFF define('TR_RATING_LIMITS', true); // ON/OFF
define('MIN_DL_FOR_RATIO', 10737418240); // 10 GB in bytes, 0 - disable define('MIN_DL_FOR_RATIO', 10737418240); // 10 GB in bytes, 0 - disable

View file

@ -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 // User related
define('USER_ACTIVATION_NONE', 0); define('USER_ACTIVATION_NONE', 0);
define('USER_ACTIVATION_SELF', 1); define('USER_ACTIVATION_SELF', 1);
@ -257,7 +248,6 @@ define('BB_TOPIC_TPL', 'bb_topic_tpl');
define('BB_TOPICS', 'bb_topics'); define('BB_TOPICS', 'bb_topics');
define('BB_TOPICS_WATCH', 'bb_topics_watch'); define('BB_TOPICS_WATCH', 'bb_topics_watch');
define('BB_USER_GROUP', 'bb_user_group'); define('BB_USER_GROUP', 'bb_user_group');
define('BB_USERS', 'bb_users');
define('BB_WORDS', 'bb_words'); define('BB_WORDS', 'bb_words');
define('BB_THX', 'bb_thx'); define('BB_THX', 'bb_thx');