From 47e8c9a7ee68b199eaa9af9951db396aaf3eea83 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Mon, 2 Dec 2024 18:11:52 +0700 Subject: [PATCH] Show torrent unregister action in log actions (#1696) * Show torrent unregister action in log actions * Update LogAction.php * Update CHANGELOG.md * Update main.php * Update main.php --- CHANGELOG.md | 1 + admin/admin_log.php | 1 + library/language/source/main.php | 1 + src/Legacy/LogAction.php | 1 + src/Legacy/Torrent.php | 14 +++++++++++--- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3e3ccbef..00b28a44f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - Improved BitTorrent clients ban functionality [\#1657](https://github.com/torrentpier/torrentpier/pull/1657) ([belomaxorka](https://github.com/belomaxorka)) - Improved `filelist.php` [\#1586](https://github.com/torrentpier/torrentpier/pull/1586) ([belomaxorka](https://github.com/belomaxorka)) - Invites: Permanent invites feature [\#1670](https://github.com/torrentpier/torrentpier/pull/1670) ([belomaxorka](https://github.com/belomaxorka)) +- Show torrent unregister action in log actions [\#1696](https://github.com/torrentpier/torrentpier/pull/1696) ([belomaxorka](https://github.com/belomaxorka)) - Show torrent status changes in actions log [\#1688](https://github.com/torrentpier/torrentpier/pull/1688) ([belomaxorka](https://github.com/belomaxorka)) - Show torrent type (gold / silver) changes in actions log [\#1689](https://github.com/torrentpier/torrentpier/pull/1689) ([belomaxorka](https://github.com/belomaxorka)) - Changed database encoding to `utf8mb4_unicode_ci` [\#1684](https://github.com/torrentpier/torrentpier/pull/1684) ([belomaxorka](https://github.com/belomaxorka)) diff --git a/admin/admin_log.php b/admin/admin_log.php index 7b2a03def..ebea96a51 100644 --- a/admin/admin_log.php +++ b/admin/admin_log.php @@ -227,6 +227,7 @@ if ($log_rowset) { case $log_type['mod_topic_unset_downloaded']: case $log_type['mod_topic_change_tor_status']: case $log_type['mod_topic_change_tor_type']: + case $log_type['mod_topic_tor_unregister']: case $log_type['mod_topic_renamed']: case $log_type['mod_post_delete']: case $log_type['mod_post_pin']: diff --git a/library/language/source/main.php b/library/language/source/main.php index ee9e69e85..b18f84693 100644 --- a/library/language/source/main.php +++ b/library/language/source/main.php @@ -2815,6 +2815,7 @@ $lang['LOG_ACTION']['LOG_TYPE'] = [ 'mod_topic_unset_downloaded' => 'Topic:
unset downloaded', 'mod_topic_change_tor_status' => 'Topic:
changed torrent status', 'mod_topic_change_tor_type' => 'Topic:
changed torrent type', + 'mod_topic_tor_unregister' => 'Topic:
torrent unregistered', 'mod_topic_renamed' => 'Topic:
renamed', 'mod_post_delete' => 'Post:
deleted', 'mod_post_pin' => 'Post:
pinned', diff --git a/src/Legacy/LogAction.php b/src/Legacy/LogAction.php index 7934680b0..99c6ffbda 100644 --- a/src/Legacy/LogAction.php +++ b/src/Legacy/LogAction.php @@ -32,6 +32,7 @@ class LogAction 'mod_topic_renamed' => 14, 'mod_topic_change_tor_status' => 15, 'mod_topic_change_tor_type' => 16, + 'mod_topic_tor_unregister' => 17, ]; public $log_type_select = []; public $log_disabled = false; diff --git a/src/Legacy/Torrent.php b/src/Legacy/Torrent.php index 3f9a1a68f..330a7778c 100644 --- a/src/Legacy/Torrent.php +++ b/src/Legacy/Torrent.php @@ -38,7 +38,7 @@ class Torrent $sql = " SELECT a.post_id, d.physical_filename, d.extension, d.tracker_status, d.mimetype, - t.topic_first_post_id, + t.topic_first_post_id, t.topic_title, p.poster_id, p.topic_id, p.forum_id, f.allow_reg_tracker FROM @@ -97,16 +97,17 @@ class Torrent */ public static function tracker_unregister($attach_id, $mode = '') { - global $lang, $bb_cfg; + global $lang, $bb_cfg, $log_action; $attach_id = (int)$attach_id; - $post_id = $topic_id = $forum_id = $info_hash = null; + $post_id = $topic_id = $topic_title = $forum_id = $info_hash = null; // Get torrent info if ($torrent = self::get_torrent_info($attach_id)) { $post_id = $torrent['post_id']; $topic_id = $torrent['topic_id']; $forum_id = $torrent['forum_id']; + $topic_title = $torrent['topic_title']; } if ($mode == 'request') { @@ -152,6 +153,13 @@ class Torrent $torrServer->removeM3U($attach_id); } + // Log action + $log_action->mod('mod_topic_tor_unregister', [ + 'forum_id' => $forum_id, + 'topic_id' => $topic_id, + 'topic_title' => $topic_title, + ]); + // Ocelot if ($bb_cfg['ocelot']['enabled']) { if ($row = DB()->fetch_row("SELECT info_hash FROM " . BB_BT_TORRENTS . " WHERE attach_id = $attach_id LIMIT 1")) {