diff --git a/CHANGELOG.md b/CHANGELOG.md index 0af35e70..e72b774e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ **Merged pull requests:** - Release v2.1.5-2023.08 🎉 +- Fixed info hash v2 issue [\#233](https://github.com/torrentpier/torrentpier-lts/pull/233) ([belomaxorka](https://github.com/belomaxorka)) - BitTorrent v2 support 🐸 [\#230](https://github.com/torrentpier/torrentpier-lts/pull/230) ([belomaxorka](https://github.com/belomaxorka)) - Captcha improvements [\#229](https://github.com/torrentpier/torrentpier-lts/pull/229) ([belomaxorka](https://github.com/belomaxorka)) - Show renamed topic actions in log actions [\#227](https://github.com/torrentpier/torrentpier-lts/pull/227) ([belomaxorka](https://github.com/belomaxorka)) diff --git a/bt/announce.php b/bt/announce.php index f6d10fc5..9aa64371 100644 --- a/bt/announce.php +++ b/bt/announce.php @@ -240,7 +240,11 @@ else { // Verify if torrent registered on tracker and user authorized $info_hash_sql = rtrim(DB()->escape($info_hash), ' '); - $info_hash_where = $is_bt_v2 ? "WHERE tor.info_hash_v2 = '$info_hash_sql'" : "WHERE tor.info_hash = '$info_hash_sql'"; + /** + * Поскольку торрент-клиенты в настоящее время обрезают инфо-хэш до 20 символов (независимо от его типа, как известно v1 = 20 символов, а v2 = 32 символа), + * то результатов $is_bt_v2 (исходя из длины строки определяем тип инфо-хэша) проверки нам будет мало, именно поэтому происходит поиск v2 хэша, если торрент является v1 (по длинне) и если в tor.info_hash столбце нету v1 хэша. + */ + $info_hash_where = $is_bt_v2 ? "WHERE tor.info_hash_v2 = '$info_hash_sql'" : "WHERE tor.info_hash = '$info_hash_sql' OR tor.info_hash_v2 LIKE '$info_hash_sql%'"; $passkey_sql = DB()->escape($passkey); $sql = " diff --git a/bt/scrape.php b/bt/scrape.php index ce28a875..389c61f2 100644 --- a/bt/scrape.php +++ b/bt/scrape.php @@ -57,7 +57,11 @@ define('TR_ROOT', './'); require(TR_ROOT . 'includes/init_tr.php'); $info_hash_sql = rtrim(DB()->escape($info_hash), ' '); -$info_hash_where = $is_bt_v2 ? "WHERE tor.info_hash_v2 = '$info_hash_sql'" : "WHERE tor.info_hash = '$info_hash_sql'"; +/** + * Поскольку торрент-клиенты в настоящее время обрезают инфо-хэш до 20 символов (независимо от его типа, как известно v1 = 20 символов, а v2 = 32 символа), + * то результатов $is_bt_v2 (исходя из длины строки определяем тип инфо-хэша) проверки нам будет мало, именно поэтому происходит поиск v2 хэша, если торрент является v1 (по длинне) и если в tor.info_hash столбце нету v1 хэша. + */ +$info_hash_where = $is_bt_v2 ? "WHERE tor.info_hash_v2 = '$info_hash_sql'" : "WHERE tor.info_hash = '$info_hash_sql' OR tor.info_hash_v2 LIKE '$info_hash_sql%'"; $row = DB()->fetch_row(" SELECT tor.complete_count, snap.seeders, snap.leechers