From f5d65b8911c5e864f000348a6d1aefbb4c09c2b4 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sun, 4 May 2025 10:38:38 +0300 Subject: [PATCH] feat: Added ability to hide BitTorrent client in peers list (#1890) * feat: Added ability to hide peer torrent client * Update displaying_torrent.php * Update functions.php * Update register.php * Updated --- composer.lock | 40 ++++++++++---------- library/attach_mod/displaying_torrent.php | 11 +++++- library/includes/functions.php | 1 + library/includes/ucp/register.php | 1 + library/language/source/main.php | 1 + styles/templates/default/usercp_register.tpl | 7 ++++ 6 files changed, 39 insertions(+), 22 deletions(-) diff --git a/composer.lock b/composer.lock index f29ecfabc..02bb5624b 100644 --- a/composer.lock +++ b/composer.lock @@ -3145,16 +3145,16 @@ }, { "name": "symfony/mailer", - "version": "v6.4.18", + "version": "v6.4.21", "source": { "type": "git", "url": "https://github.com/symfony/mailer.git", - "reference": "e93a6ae2767d7f7578c2b7961d9d8e27580b2b11" + "reference": "ada2809ccd4ec27aba9fc344e3efdaec624c6438" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mailer/zipball/e93a6ae2767d7f7578c2b7961d9d8e27580b2b11", - "reference": "e93a6ae2767d7f7578c2b7961d9d8e27580b2b11", + "url": "https://api.github.com/repos/symfony/mailer/zipball/ada2809ccd4ec27aba9fc344e3efdaec624c6438", + "reference": "ada2809ccd4ec27aba9fc344e3efdaec624c6438", "shasum": "" }, "require": { @@ -3205,7 +3205,7 @@ "description": "Helps sending emails", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/mailer/tree/v6.4.18" + "source": "https://github.com/symfony/mailer/tree/v6.4.21" }, "funding": [ { @@ -3221,20 +3221,20 @@ "type": "tidelift" } ], - "time": "2025-01-24T15:27:15+00:00" + "time": "2025-04-26T23:47:35+00:00" }, { "name": "symfony/mime", - "version": "v6.4.19", + "version": "v6.4.21", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "ac537b6c55ccc2c749f3c979edfa9ec14aaed4f3" + "reference": "fec8aa5231f3904754955fad33c2db50594d22d1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/ac537b6c55ccc2c749f3c979edfa9ec14aaed4f3", - "reference": "ac537b6c55ccc2c749f3c979edfa9ec14aaed4f3", + "url": "https://api.github.com/repos/symfony/mime/zipball/fec8aa5231f3904754955fad33c2db50594d22d1", + "reference": "fec8aa5231f3904754955fad33c2db50594d22d1", "shasum": "" }, "require": { @@ -3290,7 +3290,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v6.4.19" + "source": "https://github.com/symfony/mime/tree/v6.4.21" }, "funding": [ { @@ -3306,7 +3306,7 @@ "type": "tidelift" } ], - "time": "2025-02-17T21:23:52+00:00" + "time": "2025-04-27T13:27:38+00:00" }, { "name": "symfony/polyfill", @@ -3648,16 +3648,16 @@ "packages-dev": [ { "name": "symfony/var-dumper", - "version": "v6.4.18", + "version": "v6.4.21", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "4ad10cf8b020e77ba665305bb7804389884b4837" + "reference": "22560f80c0c5cd58cc0bcaf73455ffd81eb380d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/4ad10cf8b020e77ba665305bb7804389884b4837", - "reference": "4ad10cf8b020e77ba665305bb7804389884b4837", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/22560f80c0c5cd58cc0bcaf73455ffd81eb380d5", + "reference": "22560f80c0c5cd58cc0bcaf73455ffd81eb380d5", "shasum": "" }, "require": { @@ -3713,7 +3713,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v6.4.18" + "source": "https://github.com/symfony/var-dumper/tree/v6.4.21" }, "funding": [ { @@ -3729,7 +3729,7 @@ "type": "tidelift" } ], - "time": "2025-01-17T11:26:11+00:00" + "time": "2025-04-09T07:34:50+00:00" } ], "aliases": [], @@ -3743,6 +3743,6 @@ "platform": { "php": ">=8.1" }, - "platform-dev": [], - "plugin-api-version": "2.3.0" + "platform-dev": {}, + "plugin-api-version": "2.6.0" } diff --git a/library/attach_mod/displaying_torrent.php b/library/attach_mod/displaying_torrent.php index a8dda29f1..84e9fa359 100644 --- a/library/attach_mod/displaying_torrent.php +++ b/library/attach_mod/displaying_torrent.php @@ -301,7 +301,7 @@ if ($tor_reged && $tor_info) { $sql = "SELECT tr.user_id, tr.ip, tr.ipv6, tr.port, tr.peer_id, tr.uploaded, tr.downloaded, tr.remain, tr.seeder, tr.releaser, tr.speed_up, tr.speed_down, tr.update_time, - tr.complete_percent, u.username, u.user_rank + tr.complete_percent, u.username, u.user_rank, u.user_opt FROM " . BB_BT_TRACKER . " tr LEFT JOIN " . BB_USERS . " u ON u.user_id = tr.user_id WHERE tr.topic_id = $tor_id @@ -455,10 +455,17 @@ if ($tor_reged && $tor_info) { $row_bgr = ($change_peers_bgr_over) ? " class=\"$bgr_class\" onmouseover=\"this.className='$bgr_class_over';\" onmouseout=\"this.className='$bgr_class';\"" : ''; $tr[$x]++; + $peerTorrentClient = $lang['UNKNOWN']; + if (IS_AM || $peer['user_id'] == $userdata['user_id'] || !bf($peer['user_opt'], 'user_opt', 'user_hide_torrent_client')) { + if (isset($peer['peer_id'])) { + $peerTorrentClient = get_user_torrent_client($peer['peer_id']); + } + } + $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_torrent_client($peer['peer_id']) : $lang['UNKNOWN'], + 'PEER_ID' => $peerTorrentClient, 'COUNTRY' => render_flag(infoByIP((!empty($peer['ipv6']) ? $peer['ipv6'] : $peer['ip']), $peer['port'])['countryCode'], false), 'COMPL_PRC' => $compl_perc, 'UP_TOTAL' => ($max_up_id[$x] == $pid) ? "$up_tot" : $up_tot, diff --git a/library/includes/functions.php b/library/includes/functions.php index 850a344ef..a383c00d3 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -197,6 +197,7 @@ $bf['user_opt'] = [ 'dis_post_edit' => 13, // [PROHIBITIONS] Block editing own posts / topics 'user_dls' => 14, // [SETTINGS] Hide list of "Current downloads" in my profile 'user_retracker' => 15, // [SETTINGS] Add my retracker into downloaded torrent files + 'user_hide_torrent_client' => 16 // [SETTINGS] Option to hide user's torrent client in peer list ]; function bit2dec($bit_num) diff --git a/library/includes/ucp/register.php b/library/includes/ucp/register.php index 25acbfc0a..6abf55c1e 100644 --- a/library/includes/ucp/register.php +++ b/library/includes/ucp/register.php @@ -365,6 +365,7 @@ foreach ($profile_fields as $field => $can_edit) { 'user_dls' => $reg_mode ? false : true, 'user_callseed' => $reg_mode ? true : true, 'user_retracker' => $reg_mode ? true : true, + 'user_hide_torrent_client' => $reg_mode ? true : true, ]; foreach ($update_user_opt as $opt => $can_change_opt) { diff --git a/library/language/source/main.php b/library/language/source/main.php index 65fd05fd1..c8ee2c495 100644 --- a/library/language/source/main.php +++ b/library/language/source/main.php @@ -1879,6 +1879,7 @@ $lang['DL_ULR'] = 'ULR'; $lang['DL_STOPPED'] = 'stopped'; $lang['DL_UPD'] = 'upd: '; $lang['DL_INFO'] = 'shows data only for the current session'; +$lang['HIDE_PEER_TORRENT_CLIENT'] = 'Hide my BitTorrent client name in peer list'; // Post PIN $lang['POST_PIN'] = 'Pin first post'; diff --git a/styles/templates/default/usercp_register.tpl b/styles/templates/default/usercp_register.tpl index a19d17371..9f3016280 100644 --- a/styles/templates/default/usercp_register.tpl +++ b/styles/templates/default/usercp_register.tpl @@ -319,6 +319,13 @@ + + {L_HIDE_PEER_TORRENT_CLIENT}: + +    + + + {L_AVATAR_PANEL}