mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 22:03:49 -07:00
Peer ID was erased if it contained non-latin characters (#1185)
This commit is contained in:
parent
ceaa0d1901
commit
5f6ade8db9
1 changed files with 5 additions and 4 deletions
|
@ -80,14 +80,14 @@ if (!isset($info_hash)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store info hash in hex format
|
// Store info hash in hex format
|
||||||
$info_hash_hex = mb_check_encoding($info_hash, 'UTF8') ? $info_hash : bin2hex($info_hash);
|
$info_hash_hex = bin2hex($info_hash);
|
||||||
|
|
||||||
// Store peer id
|
// Store peer id
|
||||||
$peer_id_sql = rtrim(DB()->escape(htmlCHR($peer_id)), ' ');
|
$peer_id_sql = rtrim(DB()->escape(preg_replace('/[^a-zA-Z0-9\-\_\.]/', '', $peer_id)), ' ');
|
||||||
|
|
||||||
// Check info_hash length
|
// Check info_hash length
|
||||||
if (strlen($info_hash) !== 20) {
|
if (strlen($info_hash) !== 20) {
|
||||||
msg_die('Invalid info_hash: ' . $info_hash_hex);
|
msg_die('Invalid info_hash: ' . (mb_check_encoding($info_hash, 'UTF8') ? $info_hash : $info_hash_hex));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($port) || $port < 0 || $port > 0xFFFF) {
|
if (!isset($port) || $port < 0 || $port > 0xFFFF) {
|
||||||
|
@ -390,12 +390,13 @@ if (!$output) {
|
||||||
// Retrieve peers
|
// Retrieve peers
|
||||||
$numwant = (int)$bb_cfg['tracker']['numwant'];
|
$numwant = (int)$bb_cfg['tracker']['numwant'];
|
||||||
$compact_mode = ($bb_cfg['tracker']['compact_mode'] || !empty($compact));
|
$compact_mode = ($bb_cfg['tracker']['compact_mode'] || !empty($compact));
|
||||||
|
$priority = $seeder ? 'seeder ASC, RAND()' : 'RAND()';
|
||||||
|
|
||||||
$rowset = DB()->fetch_rowset("
|
$rowset = DB()->fetch_rowset("
|
||||||
SELECT ip, ipv6, port
|
SELECT ip, ipv6, port
|
||||||
FROM " . BB_BT_TRACKER . "
|
FROM " . BB_BT_TRACKER . "
|
||||||
WHERE topic_id = $topic_id
|
WHERE topic_id = $topic_id
|
||||||
ORDER BY seeder ASC, RAND()
|
ORDER BY $priority
|
||||||
LIMIT $numwant
|
LIMIT $numwant
|
||||||
");
|
");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue