Peer client display support (#968)

Show torrent client icons for statistics
This commit is contained in:
Cønstantine K ̷o̷valensky 2023-10-13 13:23:21 +04:00 committed by GitHub
commit 73150d2584
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 171 additions and 7 deletions

View file

@ -1173,6 +1173,161 @@ function bb_date($gmepoch, $format = false, $friendly_date = true)
return ($bb_cfg['translate_dates']) ? strtr(strtoupper($date), $lang['DATETIME']) : $date;
}
// Get user's torrent client string
function get_user_client($peer_id)
{
static $clients = [
///'-AD' => 'Advanced Download Manager',
'-AG' => 'Ares',
//'-AR' => 'Arctic',
//'-AT' => 'Artemis',
//'-AV' => 'Avicora',
//'-AX' => 'BitPump',
'-AZ' => 'Vuze',
'-A~' => 'Ares',
//'-BB' => 'BitBuddy',
'-BC' => 'BitComet',
'-BE' => 'BitTorrent SDK',
//'-BF' => 'BitFlu',
//'-BG' => 'BTGetit',
//'-BH' => 'BitZilla',
'-BI' => 'BiglyBT',
'-BL' => 'BitLord',
//'-BM' => 'BitMagnet',
//'-BN' => 'Baidu Netdisk',
//'-BOW' => 'Bits on Wheels',
//'-BP' => 'BitTorrent Pro (Azureus + Spyware)',
//'-BR' => 'BitRocket',
//'-BS' => 'BTSlave',
'-BT' => 'BitTorrent',
//'-BW' => 'BitTorrent Web',
//'-BX' => 'BittorrentX',
//'-CD' => 'Enhanced CTorrent',
'-CT' => 'CTorrent',
'-DE' => 'Deluge',
//'-DP' => 'Propagate Data Client',
//'-EB' => 'EBit',
//'-ES' => 'Electric Sheep',
//'-FC' => 'FileCroc',
'-FD' => 'Free Download Manager',
'FD6' => 'Free Download Manager',
'-FG' => 'FlashGet',
'-FL' => 'Folx',
//'-FT' => 'FoxTorrent/RedSwoosh',
//'-FW' => 'FrostWire',
//'-FX' => 'Freebox',
//'-G3' => 'G3 Torrent',
//'-GR' => 'GetRight',
//'-GS' => 'GSTorrent',
//'-HK' => 'Hekate',
'-HL' => 'Halite',
//'-HN' => 'Hydranode',
'-KG' => 'KGet',
'-KT' => 'KTorrent',
//'-LC' => 'LeechCraft',
//'-LH' => 'LH-ABC',
//'-LP' => 'Lphant',
'-LT' => 'libTorrent',
//'-LW' => 'LimeWire',
'-Lr' => 'LibreTorrent',
'-MG' => 'MediaGet',
//'-MK' => 'Meerkat',
//'-ML' => 'MLDonkey',
//'-MO' => 'MonoTorrent',
//'-MP' => 'MooPolice',
//'-MR' => 'Miro',
//'-MT' => 'Moonlight',
//'-NE' => 'BT Next Evolution',
//'-NX' => 'Net Transport',
//'-OS' => 'OneSwarm',
//'-OT' => 'OmegaTorrent',
//'-PD' => 'Pando',
///'-PI' => 'PicoTorrent',
//'-QD' => 'QQDownload',
//'-QT' => 'QT 4 Torrent example',
//'-RS' => 'Rufus',
//'-RT' => 'Retriever',
//'-RZ' => 'RezTorrent',
//'-SB' => 'Swiftbit',
///'-SD' => 'Thunder',
//'-SM' => 'SoMud',
///'-SP' => 'BitSpirit',
//'-SS' => 'SwarmScope',
//'-ST' => 'SymTorrent',
//'-SZ' => 'Shareaza',
//'-S~' => 'Shareaza',
//'-TB' => 'Torch Browser',
//'-TN' => 'Torrent .NET',
'-TR' => 'Transmission',
//'-TS' => 'Torrentstorm',
//'-TT' => 'TuoTu',
'-tT' => 'tTorrent',
//'-UE' => "uTorrent Embedded",
//'-UL' => 'uLeecher!',
'-UM' => "uTorrent Mac",
'-UT' => "uTorrent",
'-UW' => "uTorrent Web",
//'-VG' => 'Vagaa',
//'-WS' => 'HTTP Seed',
//'-WT' => 'BitLet',
//'-WT-' => 'BitLet',
'-WW' => 'WebTorrent',
'-WD' => 'WebTorrent',
//'-WY' => 'FireTorrent',
//'-XC' => 'Xtorrent',
//'-XF' => 'Xfplay',
'-XL' => 'Xunlei',
//'-XS' => 'XSwifter',
//'-XT' => 'XanTorrent',
//'-XX' => 'Xtorrent',
///'-ZO' => 'Zona',
//'-ZT' => 'Zip Torrent',
//'-bk' => 'BitKitten (libtorrent)',
//'-lt' => 'libTorrent (Rakshasa)',
//'-pb' => 'pbTorrent',
'-PI' => 'PicoTorrent',
'-qB' => 'qBittorrent',
//'-st' => 'SharkTorrent',
//'346-' => 'TorrentTopia',
//'AZ2500BT' => 'BitTyrant (Azureus Mod)',
//'BLZ' => 'Blizzard Downloader',
//'DNA' => 'BitTorrent DNA',
//'FD6' => 'Free Download Manager 6',
//'LIME' => 'Limewire',
'M' => 'BitTorrent',
'MG' => 'MediaGet',
//'Mbrst' => 'burst!',
'OP' => 'Opera',
//'Pando' => 'Pando',
//'Plus' => 'Plus!',
//'Q' => 'Queen Bee',
//'QVOD' => 'QVOD',
///'S3' => 'Amazon S3',
'TIX' => 'Tixati',
'aria2-' => 'Aria2',
'A2' => 'Aria2',
//'btpd' => 'BT Protocol Daemon',
//'eX' => 'eXeem',
//'martini' => 'Martini Man',
];
$bestMatchLength = 0;
$peer_id = htmlCHR($peer_id);
foreach ($clients as $key => $clientName) {
if (str_starts_with($peer_id, $key) !== false && strlen($key) > $bestMatchLength) {
$bestMatch = $clientName;
$bestMatchLength = strlen($key);
}
}
if (!empty($bestMatch)) {
return '<img width="auto" height="auto" style="display:inline!important;vertical-align:middle" src="/styles/images/clients/'. $bestMatch .'.png" alt="' . $bestMatch . '" title="' . $peer_id . '">';
}
else {
return $peer_id;
}
}
function birthday_age($date)
{
global $bb_cfg;