mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 13:54:02 -07:00
Fix magnet link passkey creation for new users
Signed-off-by: Yuriy Pikhtarev <iglix@me.com>
This commit is contained in:
parent
c1fb1479ad
commit
1cbc084f2e
5 changed files with 26 additions and 8 deletions
|
@ -143,7 +143,7 @@ if ($tor_reged && $tor_info) {
|
|||
|
||||
// Magnet link
|
||||
$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
|
||||
$min_ratio_dl = $bb_cfg['bt_min_ratio_allow_dl_tor'];
|
||||
|
|
|
@ -1912,11 +1912,30 @@ function pad_with_space($str)
|
|||
return $str ? " $str " : $str;
|
||||
}
|
||||
|
||||
function create_magnet($infohash, $auth_key, $logged_in)
|
||||
/**
|
||||
* Create magnet link
|
||||
*
|
||||
* @param string $infohash
|
||||
* @param string|bool $auth_key
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function create_magnet($infohash, $auth_key)
|
||||
{
|
||||
global $bb_cfg, $_GET, $images;
|
||||
global $bb_cfg, $images, $lang, $userdata;
|
||||
|
||||
if (IS_GUEST && $bb_cfg['bt_tor_browse_only_reg']) {
|
||||
$passkey = '';
|
||||
} elseif (empty($auth_key)) {
|
||||
if (!$passkey = \TorrentPier\Legacy\Torrent::generate_passkey($userdata['user_id'], true)) {
|
||||
bb_die($lang['PASSKEY_ERR_EMPTY']);
|
||||
}
|
||||
} else {
|
||||
$passkey = $auth_key;
|
||||
}
|
||||
|
||||
$passkey_url = $passkey ? "?{$bb_cfg['passkey_key']}=$auth_key" : '';
|
||||
|
||||
$passkey_url = ((!$logged_in || isset($_GET['no_passkey'])) && $bb_cfg['bt_tor_browse_only_reg']) ? '' : "?{$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>';
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue