From 60899a0184b7b0aa602176b77a33b5f2d8293429 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sat, 14 Dec 2024 15:03:28 +0700 Subject: [PATCH] [Configurable] Show magnet-links for guests (#1712) * [Configurable] Show magnet links for guests * Update mysql.sql * Update legacy-changes.txt * Updated * Update main.php * Update functions.php * Updated * Update viewforum.tpl * Update viewtopic_attach.tpl * Update viewforum.tpl * Update CHANGELOG.md --- CHANGELOG.md | 1 + admin/admin_board.php | 1 + install/sql/mysql.sql | 1 + install/upgrade/legacy-changes.txt | 3 +++ library/includes/functions.php | 2 +- library/language/source/main.php | 1 + styles/templates/admin/admin_board.tpl | 7 +++++++ styles/templates/default/tpl_config.php | 1 - styles/templates/default/tracker.tpl | 2 +- styles/templates/default/viewforum.tpl | 2 +- styles/templates/default/viewtopic_attach.tpl | 2 +- 11 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff847457e..5372853f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ **Merged pull requests:** - Release 2.4.5 🍧️ ([belomaxorka](https://github.com/belomaxorka)) +- [Configurable] Show magnet-links for guests [\#1712](https://github.com/torrentpier/torrentpier/pull/1712) ([belomaxorka](https://github.com/belomaxorka)) - Set `cursor: pointer;` for buttons, inputs (buttons) [\#1710](https://github.com/torrentpier/torrentpier/pull/1710), [\#1711](https://github.com/torrentpier/torrentpier/pull/1711) ([belomaxorka](https://github.com/belomaxorka)) - Minor improvements [\#1705](https://github.com/torrentpier/torrentpier/pull/1705) ([belomaxorka](https://github.com/belomaxorka)) - New Crowdin updates [\#1704](https://github.com/torrentpier/torrentpier/pull/1704), [\#1706](https://github.com/torrentpier/torrentpier/pull/1706) ([Exileum](https://github.com/Exileum)) diff --git a/admin/admin_board.php b/admin/admin_board.php index fdc736d79..19f359a87 100644 --- a/admin/admin_board.php +++ b/admin/admin_board.php @@ -61,6 +61,7 @@ switch ($mode) { 'CONFIG_MODS' => true, 'MAGNET_LINKS_ENABLED' => $new['magnet_links_enabled'], + 'MAGNET_LINKS_FOR_GUESTS' => $new['magnet_links_for_guests'], 'GENDER' => $new['gender'], 'CALLSEED' => $new['callseed'], 'TOR_STATS' => $new['tor_stats'], diff --git a/install/sql/mysql.sql b/install/sql/mysql.sql index 858e4a7c9..5231b54d1 100644 --- a/install/sql/mysql.sql +++ b/install/sql/mysql.sql @@ -583,6 +583,7 @@ VALUES ('allow_autologin', '1'), ('xs_use_cache', '1'), ('cron_check_interval', '180'), ('magnet_links_enabled', '1'), + ('magnet_links_for_guests', '0'), ('gender', '1'), ('callseed', '0'), ('tor_stats', '1'), diff --git a/install/upgrade/legacy-changes.txt b/install/upgrade/legacy-changes.txt index 20779f357..05cdb974b 100644 --- a/install/upgrade/legacy-changes.txt +++ b/install/upgrade/legacy-changes.txt @@ -148,3 +148,6 @@ UPDATE `bb_cron` SET `run_interval` = '00:10:00' WHERE `cron_script` = 'tr_seed_ // 2.4.5-rc.1 INSERT INTO `bb_extensions` (`group_id`, `extension`, `comment`) VALUES ('1', 'avif', ''), ('3', 'm3u', ''); ALTER TABLE `bb_topics` ADD COLUMN `topic_allow_robots` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0'; + +// 2.4.5 +INSERT INTO bb_config VALUES ('magnet_links_for_guests', '0'); diff --git a/library/includes/functions.php b/library/includes/functions.php index 49a9ddafa..b34cca375 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -1812,7 +1812,7 @@ function create_magnet(string $infohash, string $infohash_v2, string $auth_key, } // Only for registered users - if (IS_GUEST && $bb_cfg['bt_tor_browse_only_reg']) { + if (!$bb_cfg['magnet_links_for_guests'] && IS_GUEST) { return false; } diff --git a/library/language/source/main.php b/library/language/source/main.php index b18f84693..4fb6d622d 100644 --- a/library/language/source/main.php +++ b/library/language/source/main.php @@ -1400,6 +1400,7 @@ $lang['SEEDING'] = 'Seed'; $lang['LEECHING'] = 'Leech'; $lang['IS_REGISTERED'] = 'Registered'; $lang['MAGNET'] = 'Magnet-link'; +$lang['MAGNET_FOR_GUESTS'] = 'Show magnet-link for guests'; $lang['MAGNET_v2'] = 'Magnet-link (BitTorrent v2 supported)'; //torrent status mod diff --git a/styles/templates/admin/admin_board.tpl b/styles/templates/admin/admin_board.tpl index 92188f4dd..5d5e88821 100644 --- a/styles/templates/admin/admin_board.tpl +++ b/styles/templates/admin/admin_board.tpl @@ -171,6 +171,13 @@ + +

{L_MAGNET_FOR_GUESTS}

+ +    + + +

{L_GENDER}

diff --git a/styles/templates/default/tpl_config.php b/styles/templates/default/tpl_config.php index d82079523..bc19b2df2 100644 --- a/styles/templates/default/tpl_config.php +++ b/styles/templates/default/tpl_config.php @@ -124,7 +124,6 @@ $template->assign_vars([ 'TOPIC_LEFT_COL_SPACER_WITDH' => $bb_cfg['topic_left_column_witdh'] - 8, // 8px padding 'POST_IMG_WIDTH_DECR_JS' => $bb_cfg['topic_left_column_witdh'] + $bb_cfg['post_img_width_decr'], 'ATTACH_IMG_WIDTH_DECR_JS' => $bb_cfg['topic_left_column_witdh'] + $bb_cfg['attach_img_width_decr'], - 'MAGNET_LINKS' => $bb_cfg['magnet_links_enabled'], 'FEED_IMG' => '' . $lang['ATOM_FEED'] . '', ]); diff --git a/styles/templates/default/tracker.tpl b/styles/templates/default/tracker.tpl index f864e5042..b8722d79d 100644 --- a/styles/templates/default/tracker.tpl +++ b/styles/templates/default/tracker.tpl @@ -404,7 +404,7 @@ ajax.callback.view_post = function(data) { {tor.TOR_SIZE_RAW} - {tor.TOR_SIZE} {tor.MAGNET} + {tor.TOR_SIZE} {tor.MAGNET} {tor.TOR_SIZE} {tor.SEEDS} diff --git a/styles/templates/default/viewforum.tpl b/styles/templates/default/viewforum.tpl index fdd6b3339..a6596ba8f 100644 --- a/styles/templates/default/viewforum.tpl +++ b/styles/templates/default/viewforum.tpl @@ -466,7 +466,7 @@ td.topic_id { cursor: pointer; }
{t.tor.SEEDERS} | {t.tor.LEECHERS}
-
{t.tor.TOR_SIZE}{t.tor.TOR_SIZE} {t.tor.MAGNET}
+
{t.tor.TOR_SIZE}{t.tor.TOR_SIZE} {t.tor.MAGNET}
diff --git a/styles/templates/default/viewtopic_attach.tpl b/styles/templates/default/viewtopic_attach.tpl index dd77ef39e..9590cd02f 100644 --- a/styles/templates/default/viewtopic_attach.tpl +++ b/styles/templates/default/viewtopic_attach.tpl @@ -147,7 +147,7 @@ {postrow.attach.tor_reged.DOWNLOAD_NAME} {L_BT_FLIST_LINK_TITLE} -  {postrow.attach.tor_reged.MAGNET} +  {postrow.attach.tor_reged.MAGNET}