From 6b71a077944a4bb670e3fca20a5710158c30150e Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Fri, 13 Oct 2023 17:10:06 +0700 Subject: [PATCH] Minor improvements (#972) * Minor improvements * Updated --- bt/announce.php | 9 +- library/attach_mod/displaying_torrent.php | 2 +- library/includes/functions.php | 189 ++++++---------------- library/includes/ucp/viewprofile.php | 1 - 4 files changed, 58 insertions(+), 143 deletions(-) diff --git a/bt/announce.php b/bt/announce.php index 436e3c5b3..16fcde9cc 100644 --- a/bt/announce.php +++ b/bt/announce.php @@ -68,8 +68,10 @@ if (!isset($info_hash)) { // Store info hash in hex format $info_hash_hex = bin2hex($info_hash); + // Store peer id $peer_id_sql = rtrim(DB()->escape(substr($peer_id, 0, 10)), ' '); + // Check info_hash version if (strlen($info_hash) === 32) { $is_bt_v2 = true; @@ -377,8 +379,8 @@ if (!$output) { if ($compact_mode) { - $peers = ''; - $peers6 = ''; + $peers = ''; + $peers6 = ''; foreach ($rowset as $peer) { $ip = \TorrentPier\Helpers\IPHelper::long2ip_extended($peer['ip']); @@ -386,8 +388,7 @@ if (!$output) { if (\TorrentPier\Helpers\IPHelper::isValidv6($ip)) { $peers6 .= $endian; - } - else{ + } else { $peers .= $endian; } } diff --git a/library/attach_mod/displaying_torrent.php b/library/attach_mod/displaying_torrent.php index e7278ec46..c676606e2 100644 --- a/library/attach_mod/displaying_torrent.php +++ b/library/attach_mod/displaying_torrent.php @@ -444,7 +444,7 @@ if ($tor_reged && $tor_info) { $template->assign_block_vars("$x_full.$x_row", [ 'ROW_BGR' => $row_bgr, 'NAME' => ($peer['update_time']) ? $name : "$name", - 'PEER_ID' => isset($peer['peer_id']) ? get_user_client($peer['peer_id']) : 'unknown', + 'PEER_ID' => isset($peer['peer_id']) ? get_user_torrent_client($peer['peer_id']) : 'unknown', 'COMPL_PRC' => $compl_perc, 'UP_TOTAL' => ($max_up_id[$x] == $pid) ? "$up_tot" : $up_tot, 'DOWN_TOTAL' => ($max_down_id[$x] == $pid) ? "$down_tot" : $down_tot, diff --git a/library/includes/functions.php b/library/includes/functions.php index 2ff674ee4..7d6c81763 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -1173,142 +1173,53 @@ 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) +/** + * Get user's torrent client string + * + * @param string $peer_id + * @return mixed|string + */ +function get_user_torrent_client(string $peer_id): mixed { + static $icons_extension = '.png'; 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', + '-AG' => 'Ares', '-AZ' => 'Vuze', '-A~' => 'Ares', '-BC' => 'BitComet', + '-BE' => 'BitTorrent SDK', '-BI' => 'BiglyBT', '-BL' => 'BitLord', '-BT' => 'BitTorrent', + '-CT' => 'CTorrent', '-DE' => 'Deluge', '-FD' => 'Free Download Manager', 'FD6' => 'Free Download Manager', + '-FG' => 'FlashGet', '-FL' => 'Folx', '-HL' => 'Halite', '-KG' => 'KGet', + '-KT' => 'KTorrent', '-LT' => 'libTorrent', '-Lr' => 'LibreTorrent', '-MG' => 'MediaGet', + '-TR' => 'Transmission', '-tT' => 'tTorrent', '-UM' => "uTorrent Mac", '-UT' => "uTorrent", + '-UW' => "uTorrent Web", '-WW' => 'WebTorrent', '-WD' => 'WebTorrent', '-XL' => 'Xunlei', + '-PI' => 'PicoTorrent', '-qB' => 'qBittorrent', 'M' => 'BitTorrent', 'MG' => 'MediaGet', + 'OP' => 'Opera', 'TIX' => 'Tixati', 'aria2-' => 'Aria2', 'A2' => 'Aria2', + /** + * ================================ Other ================================ + * '-BB' => 'BitBuddy', '-AR' => 'Arctic', '-AT' => 'Artemis', '-AV' => 'Avicora', + * '-AX' => 'BitPump', '-BB' => 'BitBuddy', '-AD' => 'Advanced Download Manager', '-BF' => 'BitFlu', + * '-BG' => 'BTGetit', '-BH' => 'BitZilla', '-BM' => 'BitMagnet', '-BN' => 'Baidu Netdisk', + * '-BOW' => 'Bits on Wheels', '-BP' => 'BitTorrent Pro (Azureus + Spyware)', '-BR' => 'BitRocket', '-BS' => 'BTSlave', + * '-BW' => 'BitTorrent Web', '-BX' => 'BittorrentX', '-CD' => 'Enhanced CTorrent', '-DP' => 'Propagate Data Client', + * '-EB' => 'EBit', '-ES' => 'Electric Sheep', '-FC' => 'FileCroc', '-HN' => 'Hydranode', + * '-FT' => 'FoxTorrent/RedSwoosh', '-FW' => 'FrostWire', '-FX' => 'Freebox', '-G3' => 'G3 Torrent', + * '-GR' => 'GetRight', '-GS' => 'GSTorrent', '-HK' => 'Hekate', '-LW' => 'LimeWire', + * '-LC' => 'LeechCraft', '-LH' => 'LH-ABC', '-LP' => 'Lphant', '-UE' => "uTorrent Embedded", + * '-UL' => 'uLeecher!', '-TS' => 'Torrentstorm', '-TT' => 'TuoTu', '-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', '-WY' => 'FireTorrent', '-XC' => 'Xtorrent', '-XF' => 'Xfplay', + * '-VG' => 'Vagaa', '-WS' => 'HTTP Seed', '-WT' => 'BitLet', '-WT-' => 'BitLet', + * '-XS' => 'XSwifter', '-XT' => 'XanTorrent', '-XX' => 'Xtorrent', '-ZO' => 'Zona', + * '-ZT' => 'Zip Torrent', '-bk' => 'BitKitten (libtorrent)', '-lt' => 'libTorrent (Rakshasa)', '-pb' => 'pbTorrent', 'Mbrst' => 'burst!', + * '-st' => 'SharkTorrent', '346-' => 'TorrentTopia', 'AZ2500BT' => 'BitTyrant (Azureus Mod)', 'BLZ' => 'Blizzard Downloader', + * 'DNA' => 'BitTorrent DNA', 'FD6' => 'Free Download Manager 6', 'LIME' => 'Limewire', 'Pando' => 'Pando', + * 'Plus' => 'Plus!', 'Q' => 'Queen Bee', 'QVOD' => 'QVOD', 'S3' => 'Amazon S3', + * 'btpd' => 'BT Protocol Daemon', 'eX' => 'eXeem', 'martini' => 'Martini Man', + * ======================================================================= + **/ ]; $bestMatchLength = 0; @@ -1321,9 +1232,13 @@ function get_user_client($peer_id) } if (!empty($bestMatch)) { - return '' . $bestMatch . ''; - } - else { + $client_icons_dir = IMAGES_DIR . '/clients/' . $bestMatch . $icons_extension; + if (file_exists($client_icons_dir)) { + return '' . $peer_id . ''; + } else { + return $bestMatch; + } + } else { return $peer_id; } } diff --git a/library/includes/ucp/viewprofile.php b/library/includes/ucp/viewprofile.php index 053d79179..6aaf6412b 100644 --- a/library/includes/ucp/viewprofile.php +++ b/library/includes/ucp/viewprofile.php @@ -77,7 +77,6 @@ if (bf($profiledata['user_opt'], 'user_opt', 'dis_sig')) { $template->assign_vars([ 'PAGE_TITLE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']), 'USERNAME' => $profiledata['username'], - 'PROFILE_USER_ID' => $profiledata['user_id'], 'PROFILE_USER' => $profile_user_id, 'USER_REGDATE' => bb_date($profiledata['user_regdate'], 'Y-m-d H:i', false),