BitTorrent v2 support enhancements 🥳 (#876)

* BitTorrent v2 support enchancements

* Added torrent name sanitizing

* Using faster language construct instead of function call for name sanitizing

* Minor improvements

- Fixed deformed avatars => get_avatar() function
- Removed outdated dc links support

* Code comments

* Changed function name

* Added table generation function with file list

For search engines to index

* Used humn_size function for size formatting in table generation

* Fixed typo

* Removed useless language variables

* Fixed code formatting

* Fixed broken displaying magnet link

* Torrent fields sanitization in table

* Fixed info hash issue

* Support for v2 only torrents

* Code re-formatting

* Typo

* Update Torrent.php

* Update functions.php

* Updated

* Updated

* Update Torrent.php

* Update TorrentFileList.php

* Update Torrent.php

* Update Torrent.php

* Update Torrent.php

* Update Torrent.php

* Error msg

* Update Torrent.php

* Update Torrent.php

* Updated

* Update Torrent.php

* Update Torrent.php

* Update config.php

* Update mysql.sql

* Update mysql.sql

* Update mysql.sql

* Update mysql.sql

* Update mysql.sql

* String fixes

* Update TorrentFileList.php

---------

Co-authored-by: Roman Kelesidis <roman25052006.kelesh@gmail.com>
This commit is contained in:
Constantine Kovalensky 2023-09-02 21:55:21 +04:00 committed by GitHub
commit 50926639cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 139 additions and 85 deletions

View file

@ -53,7 +53,11 @@ function msg_die($msg)
require __DIR__ . '/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