From 2ae9f72c1bff3e366224c19f9022f7b26dc66787 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Mon, 2 Dec 2024 23:11:44 +0700 Subject: [PATCH] Make `get_torrent_info()` as public method for re-use (#1697) * Make `get_torrent_info()` as public method for re-use * Update CHANGELOG.md --- CHANGELOG.md | 1 + library/ajax/change_torrent.php | 24 ++---------------------- src/Legacy/Torrent.php | 2 +- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00b28a44f..d15790c0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - 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)) - Demo mode: Save user language in cookies [\#1584](https://github.com/torrentpier/torrentpier/pull/1584) ([belomaxorka](https://github.com/belomaxorka)) +- Make `get_torrent_info()` as public method for re-use [\#1697](https://github.com/torrentpier/torrentpier/pull/1697) ([belomaxorka](https://github.com/belomaxorka)) - BBCode: Fixed relative links working [\#1613](https://github.com/torrentpier/torrentpier/pull/1613) ([belomaxorka](https://github.com/belomaxorka)) - Fixed empty `topic_id` in log actions after topic rename [\#1687](https://github.com/torrentpier/torrentpier/pull/1687) ([belomaxorka](https://github.com/belomaxorka)) - Fixed broken torrent stats displaying [\#1672](https://github.com/torrentpier/torrentpier/pull/1672), [\#1673](https://github.com/torrentpier/torrentpier/pull/1673) ([belomaxorka](https://github.com/belomaxorka)) diff --git a/library/ajax/change_torrent.php b/library/ajax/change_torrent.php index 4e7559510..f1146d63d 100644 --- a/library/ajax/change_torrent.php +++ b/library/ajax/change_torrent.php @@ -19,31 +19,11 @@ if (!isset($this->request['attach_id'])) { if (!isset($this->request['type'])) { $this->ajax_die('empty type'); } + $attach_id = (int)$this->request['attach_id']; $type = (string)$this->request['type']; -$torrent = DB()->fetch_row(" - SELECT - a.post_id, d.physical_filename, d.extension, d.tracker_status, - t.topic_first_post_id, t.topic_title, - p.poster_id, p.topic_id, p.forum_id, - f.allow_reg_tracker - FROM - " . BB_ATTACHMENTS . " a, - " . BB_ATTACHMENTS_DESC . " d, - " . BB_POSTS . " p, - " . BB_TOPICS . " t, - " . BB_FORUMS . " f - WHERE - a.attach_id = $attach_id - AND d.attach_id = $attach_id - AND p.post_id = a.post_id - AND t.topic_id = p.topic_id - AND f.forum_id = p.forum_id - LIMIT 1 - "); - -if (!$torrent) { +if (!$torrent = \TorrentPier\Legacy\Torrent::get_torrent_info($attach_id)) { $this->ajax_die($lang['INVALID_ATTACH_ID']); } diff --git a/src/Legacy/Torrent.php b/src/Legacy/Torrent.php index 330a7778c..65d571686 100644 --- a/src/Legacy/Torrent.php +++ b/src/Legacy/Torrent.php @@ -29,7 +29,7 @@ class Torrent * * @return array */ - private static function get_torrent_info($attach_id) + public static function get_torrent_info($attach_id) { global $lang;