Fixed empty $auth_key after gen passkey (#670)

This commit is contained in:
Roman Kelesidis 2023-04-02 15:18:05 +07:00 committed by GitHub
commit d6b94ac91f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 5 deletions

View file

@ -143,7 +143,7 @@ if ($tor_reged && $tor_info) {
// Magnet link // Magnet link
$passkey = DB()->fetch_row("SELECT auth_key FROM " . BB_BT_USERS . " WHERE user_id = " . (int)$bt_user_id . " LIMIT 1"); $passkey = DB()->fetch_row("SELECT auth_key FROM " . BB_BT_USERS . " WHERE user_id = " . (int)$bt_user_id . " LIMIT 1");
$tor_magnet = create_magnet($tor_info['info_hash'], $passkey['auth_key']); $tor_magnet = create_magnet($tor_info['info_hash'], ($passkey['auth_key'] ?? ''));
// ratio limits // ratio limits
$min_ratio_dl = $bb_cfg['bt_min_ratio_allow_dl_tor']; $min_ratio_dl = $bb_cfg['bt_min_ratio_allow_dl_tor'];

View file

@ -1861,16 +1861,17 @@ function pad_with_space($str)
* *
* @return string * @return string
*/ */
function create_magnet($infohash, $auth_key) function create_magnet($infohash, $auth_key): string
{ {
global $bb_cfg, $images, $lang, $userdata; global $bb_cfg, $images, $lang, $userdata;
if (IS_GUEST && $bb_cfg['bt_tor_browse_only_reg']) { if (IS_GUEST && $bb_cfg['bt_tor_browse_only_reg']) {
$passkey = ''; $passkey = false;
} elseif (empty($auth_key)) { } elseif (empty($auth_key)) {
if (!$passkey = \TorrentPier\Legacy\Torrent::generate_passkey($userdata['user_id'], true)) { if (!$passkey = \TorrentPier\Legacy\Torrent::generate_passkey($userdata['user_id'], true)) {
bb_die($lang['PASSKEY_ERR_EMPTY']); bb_die($lang['PASSKEY_ERR_EMPTY']);
} }
$auth_key = $passkey;
} else { } else {
$passkey = $auth_key; $passkey = $auth_key;
} }

View file

@ -698,7 +698,7 @@ if ($allowed_forums) {
$s_last = $tor['seeder_last_seen']; $s_last = $tor['seeder_last_seen'];
$att_id = $tor['attach_id']; $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'];
$dl_sp = ($dl) ? humn_size($dl, 0, 'KB') . '/s' : '0 KB/s'; $dl_sp = ($dl) ? humn_size($dl, 0, 'KB') . '/s' : '0 KB/s';
$ul_sp = ($ul) ? humn_size($ul, 0, 'KB') . '/s' : '0 KB/s'; $ul_sp = ($ul) ? humn_size($ul, 0, 'KB') . '/s' : '0 KB/s';

View file

@ -471,7 +471,7 @@ foreach ($topic_rowset as $topic) {
)); ));
if (isset($topic['tor_size'])) { if (isset($topic['tor_size'])) {
$tor_magnet = create_magnet($topic['info_hash'], $topic['auth_key']); $tor_magnet = create_magnet($topic['info_hash'], ($topic['auth_key'] ?? ''));
$template->assign_block_vars('t.tor', array( $template->assign_block_vars('t.tor', array(
'SEEDERS' => (int)$topic['seeders'], 'SEEDERS' => (int)$topic['seeders'],