mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 13:54:02 -07:00
Use built-in binary hash feature (#1032)
This commit is contained in:
parent
2a3a982d78
commit
17640a52c6
2 changed files with 6 additions and 5 deletions
|
@ -1059,6 +1059,7 @@ $lang['BT_ADDED'] = 'Added';
|
||||||
$lang['BT_REG_ON_TRACKER'] = 'Register on tracker';
|
$lang['BT_REG_ON_TRACKER'] = 'Register on tracker';
|
||||||
$lang['BT_REG_FAIL'] = 'Could not register torrent on tracker';
|
$lang['BT_REG_FAIL'] = 'Could not register torrent on tracker';
|
||||||
$lang['BT_REG_FAIL_SAME_HASH'] = 'Another torrent with same info_hash already <a href="%s"><b>registered</b></a>';
|
$lang['BT_REG_FAIL_SAME_HASH'] = 'Another torrent with same info_hash already <a href="%s"><b>registered</b></a>';
|
||||||
|
$lang['BT_V2_ONLY_DISALLOWED'] = 'v2-only torrents have been disabled by the administrator at the moment, allowed: v1 and hybrids';
|
||||||
$lang['BT_UNREG_FROM_TRACKER'] = 'Remove from tracker';
|
$lang['BT_UNREG_FROM_TRACKER'] = 'Remove from tracker';
|
||||||
$lang['BT_UNREGISTERED'] = 'Torrent unregistered';
|
$lang['BT_UNREGISTERED'] = 'Torrent unregistered';
|
||||||
$lang['BT_UNREGISTERED_ALREADY'] = 'Torrent already unregistered';
|
$lang['BT_UNREGISTERED_ALREADY'] = 'Torrent already unregistered';
|
||||||
|
|
|
@ -357,20 +357,19 @@ class Torrent
|
||||||
$bt_v1 = true;
|
$bt_v1 = true;
|
||||||
}
|
}
|
||||||
if ($bb_cfg['tracker']['disabled_v2_torrents'] && isset($bt_v2) && !isset($bt_v1)) {
|
if ($bb_cfg['tracker']['disabled_v2_torrents'] && isset($bt_v2) && !isset($bt_v1)) {
|
||||||
self::torrent_error_exit('v2-only torrents were disabled, allowed: v1 and hybrids');
|
self::torrent_error_exit($lang['BT_V2_ONLY_DISALLOWED']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getting info_hash v1
|
// Getting info_hash v1
|
||||||
if (isset($bt_v1)) {
|
if (isset($bt_v1)) {
|
||||||
$info_hash = pack('H*', hash('sha1', \Arokettu\Bencode\Bencode::encode($info)));
|
$info_hash = hash('sha1', \Arokettu\Bencode\Bencode::encode($info), true);
|
||||||
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
|
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
|
||||||
$info_hash_where = "WHERE info_hash = '$info_hash_sql'";
|
$info_hash_where = "WHERE info_hash = '$info_hash_sql'";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getting info_hash v2
|
// Getting info_hash v2
|
||||||
if (isset($bt_v2)) {
|
if (isset($bt_v2)) {
|
||||||
$v2_hash = hash('sha256', \Arokettu\Bencode\Bencode::encode($info));
|
$info_hash_v2 = hash('sha256', \Arokettu\Bencode\Bencode::encode($info), true);
|
||||||
$info_hash_v2 = pack('H*', $v2_hash);
|
|
||||||
$info_hash_v2_sql = rtrim(DB()->escape($info_hash_v2), ' ');
|
$info_hash_v2_sql = rtrim(DB()->escape($info_hash_v2), ' ');
|
||||||
$info_hash_where = "WHERE info_hash_v2 = '$info_hash_v2_sql'";
|
$info_hash_where = "WHERE info_hash_v2 = '$info_hash_v2_sql'";
|
||||||
}
|
}
|
||||||
|
@ -390,7 +389,8 @@ class Torrent
|
||||||
|
|
||||||
if (isset($info['length'])) {
|
if (isset($info['length'])) {
|
||||||
$totallen = (float)$info['length'];
|
$totallen = (float)$info['length'];
|
||||||
} elseif (isset($bt_v1, $info['files']) && \is_array($info['files'])) {
|
}
|
||||||
|
elseif (isset($bt_v1, $info['files']) && \is_array($info['files'])) {
|
||||||
foreach ($info['files'] as $fn => $f) {
|
foreach ($info['files'] as $fn => $f) {
|
||||||
// Exclude padding files
|
// Exclude padding files
|
||||||
if (($f['attr'] ?? null) !== 'p') {
|
if (($f['attr'] ?? null) !== 'p') {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue