mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 18:48:21 -07:00
BitTorrent v2 support 🐸 (#866)
* BitTorrent v2 support * Update TorrentFileList.php * BitTorrent v2 support Added support for BitTorrent v2 file hash displaying, magnet links * Updated * Updated * Update changes.txt * Update Torrent.php * Update Torrent.php * Updated * Added support in announcer * Update announce.php * Update scrape.php * Update scrape.php * Update scrape.php * Changed the condition for single files * Update scrape.php * Update displaying_torrent.php * Update displaying_torrent.php * Update displaying_torrent.php --------- Co-authored-by: Roman Kelesidis <roman25052006.kelesh@gmail.com>
This commit is contained in:
parent
a2e8817b5f
commit
fadce7a297
10 changed files with 104 additions and 27 deletions
|
@ -22,11 +22,21 @@ if (isset($_GET['?info_hash']) && !isset($_GET['info_hash'])) {
|
|||
$_GET['info_hash'] = $_GET['?info_hash'];
|
||||
}
|
||||
|
||||
if (!isset($_GET['info_hash']) || strlen($_GET['info_hash']) != 20) {
|
||||
msg_die('Invalid info_hash');
|
||||
$is_bt_v2 = null;
|
||||
$info_hash = isset($_GET['info_hash']) ? (string)$_GET['info_hash'] : null;
|
||||
|
||||
if (!isset($info_hash)) {
|
||||
msg_die('info_hash does not exists');
|
||||
}
|
||||
|
||||
$info_hash = $_GET['info_hash'];
|
||||
// Check info_hash version
|
||||
if (strlen($info_hash) == 32) {
|
||||
$is_bt_v2 = true;
|
||||
} elseif (strlen($info_hash) == 20) {
|
||||
$is_bt_v2 = false;
|
||||
} else {
|
||||
msg_die('Invalid info_hash');
|
||||
}
|
||||
|
||||
function msg_die($msg)
|
||||
{
|
||||
|
@ -42,15 +52,20 @@ 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'";
|
||||
|
||||
$row = DB()->fetch_row("
|
||||
SELECT tor.complete_count, snap.seeders, snap.leechers
|
||||
FROM " . BB_BT_TORRENTS . " tor
|
||||
LEFT JOIN " . BB_BT_TRACKER_SNAP . " snap ON (snap.topic_id = tor.topic_id)
|
||||
WHERE tor.info_hash = '$info_hash_sql'
|
||||
$info_hash_where
|
||||
LIMIT 1
|
||||
");
|
||||
|
||||
if (!$row) {
|
||||
msg_die('Torrent not registered, info_hash = ' . bin2hex($info_hash_sql));
|
||||
}
|
||||
|
||||
$output['files'][$info_hash] = [
|
||||
'complete' => (int)$row['seeders'],
|
||||
'downloaded' => (int)$row['complete_count'],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue