Fix magnet link passkey creation for new users (#122)

https://github.com/torrentpier/torrentpier/pull/461
This commit is contained in:
Roman Kelesidis 2023-04-02 14:52:32 +07:00 committed by GitHub
parent f845d1230a
commit c011d71b89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 8 deletions

View File

@ -10,6 +10,7 @@
- Torrent file content sort fix [\#119](https://github.com/torrentpier/torrentpier-lts/pull/119) ([belomaxorka](https://github.com/belomaxorka)) - Torrent file content sort fix [\#119](https://github.com/torrentpier/torrentpier-lts/pull/119) ([belomaxorka](https://github.com/belomaxorka))
- Fix release template editor [\#120](https://github.com/torrentpier/torrentpier-lts/pull/120) ([belomaxorka](https://github.com/belomaxorka)) - Fix release template editor [\#120](https://github.com/torrentpier/torrentpier-lts/pull/120) ([belomaxorka](https://github.com/belomaxorka))
- Fix some notices in admin panel reported by BugSnag [\#121](https://github.com/torrentpier/torrentpier-lts/pull/121) ([belomaxorka](https://github.com/belomaxorka)) - Fix some notices in admin panel reported by BugSnag [\#121](https://github.com/torrentpier/torrentpier-lts/pull/121) ([belomaxorka](https://github.com/belomaxorka))
- Fix magnet link passkey creation for new users [\#122](https://github.com/torrentpier/torrentpier-lts/pull/122) ([belomaxorka](https://github.com/belomaxorka))
## [v2.1.5-2023.03](https://github.com/torrentpier/torrentpier-lts/tree/v2.1.5-2023.03) (2023-04-04) ## [v2.1.5-2023.03](https://github.com/torrentpier/torrentpier-lts/tree/v2.1.5-2023.03) (2023-04-04)
[Full Changelog](https://github.com/torrentpier/torrentpier-lts/compare/v2.1.5-2023.03...main) [Full Changelog](https://github.com/torrentpier/torrentpier-lts/compare/v2.1.5-2023.03...main)

View File

@ -154,7 +154,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'], $userdata['session_logged_in']); $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

@ -72,8 +72,8 @@ $domain_name = 'torrentpier.com'; // enter here your primary domain name of your
$domain_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : $domain_name; $domain_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : $domain_name;
// Version info // Version info
$bb_cfg['tp_version'] = '2.1.5-2023.03'; $bb_cfg['tp_version'] = '2.1.5-2023.04';
$bb_cfg['tp_release_date'] = '04-04-2023'; $bb_cfg['tp_release_date'] = '04-05-2023';
$bb_cfg['tp_release_state'] = 'LTS'; $bb_cfg['tp_release_state'] = 'LTS';
$bb_cfg['tp_zf_version'] = '2.4.13'; $bb_cfg['tp_zf_version'] = '2.4.13';

View File

@ -2560,11 +2560,29 @@ function pad_with_space ($str)
return ($str) ? " $str " : $str; return ($str) ? " $str " : $str;
} }
function create_magnet ($infohash, $auth_key, $logged_in) function create_magnet ($infohash, $auth_key)
{ {
global $bb_cfg, $_GET, $userdata, $images; global $bb_cfg, $images, $lang, $userdata;
$passkey_url = ((!$logged_in || isset($_GET['no_passkey'])) && $bb_cfg['bt_tor_browse_only_reg']) ? '' : "?{$bb_cfg['passkey_key']}=$auth_key"; if (IS_GUEST && $bb_cfg['bt_tor_browse_only_reg'])
{
$passkey = '';
}
elseif (empty($auth_key))
{
require(INC_DIR .'functions_torrent.php');
if (!$passkey = generate_passkey($userdata['user_id'], true))
{
bb_die($lang['PASSKEY_ERR_EMPTY']);
}
$auth_key = $passkey;
}
else
{
$passkey = $auth_key;
}
$passkey_url = $passkey ? "?{$bb_cfg['passkey_key']}=$auth_key" : '';
return '<a href="magnet:?xt=urn:btih:'. bin2hex($infohash) .'&tr='. urlencode($bb_cfg['bt_announce_url'] . $passkey_url) .'"><img src="'. $images['icon_magnet'] .'" width="12" height="12" border="0" /></a>'; return '<a href="magnet:?xt=urn:btih:'. bin2hex($infohash) .'&tr='. urlencode($bb_cfg['bt_announce_url'] . $passkey_url) .'"><img src="'. $images['icon_magnet'] .'" width="12" height="12" border="0" /></a>';
} }

View File

@ -787,7 +787,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'], $userdata['session_logged_in']); $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

@ -512,7 +512,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'], $userdata['session_logged_in']); $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'],