From f154d706f88466dd91066ce84ce80dc260220364 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Wed, 24 Jan 2024 01:03:38 +0700 Subject: [PATCH] Added ability to view "Watching topics" of other people's (Admins) (#1336) * Added ability to view "Watching topics" of other people's (For admins only) * Update CHANGELOG.md --- CHANGELOG.md | 1 + library/includes/functions.php | 2 +- library/includes/ucp/topic_watch.php | 11 +++++++++++ library/language/source/main.php | 2 +- styles/templates/default/usercp_viewprofile.tpl | 2 +- tracker.php | 1 - 6 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da6f79814..24b0b09af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ **Merged pull requests:** - Release 2.4.1 🦉 ([belomaxorka](https://github.com/belomaxorka), [kovalensky](https://github.com/kovalensky)) +- Added ability to view "Watching topics" of other people's (For admins only) [\#1336](https://github.com/torrentpier/torrentpier/pull/1336) ([belomaxorka](https://github.com/belomaxorka)) - Added `bt_announce_url` autofill [\#1331](https://github.com/torrentpier/torrentpier/pull/1331) ([belomaxorka](https://github.com/belomaxorka)) - Added "Random release" button in tracker.php [\#1334](https://github.com/torrentpier/torrentpier/pull/1334) ([belomaxorka](https://github.com/belomaxorka)) - Added support for fastly cdn [\#1327](https://github.com/torrentpier/torrentpier/pull/1327) ([belomaxorka](https://github.com/belomaxorka), [kovalensky](https://github.com/kovalensky)) diff --git a/library/includes/functions.php b/library/includes/functions.php index 1ed58ffad..5f686a27c 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -755,7 +755,7 @@ function get_username($user_id) return $usernames; } - $row = DB()->fetch_row("SELECT username FROM " . BB_USERS . " WHERE user_id = $user_id LIMIT 1"); + $row = DB()->fetch_row("SELECT username FROM " . BB_USERS . " WHERE user_id = '" . DB()->escape($user_id) . "' LIMIT 1"); return $row['username']; } diff --git a/library/includes/ucp/topic_watch.php b/library/includes/ucp/topic_watch.php index 753020e64..3983fcdd0 100644 --- a/library/includes/ucp/topic_watch.php +++ b/library/includes/ucp/topic_watch.php @@ -21,6 +21,17 @@ $page_cfg['include_bbcode_js'] = true; $tracking_topics = get_tracks('topic'); $user_id = $userdata['user_id']; +if (isset($_GET['uid'])) { + if (get_username($_GET['uid'])) { + if ($_GET['uid'] == $userdata['user_id'] || IS_ADMIN) { + $user_id = DB()->escape($_GET['uid']); + } else { + bb_die($lang['NOT_AUTHORISED']); + } + } else { + bb_die($lang['USER_NOT_EXIST']); + } +} $start = isset($_GET['start']) ? abs((int)$_GET['start']) : 0; $per_page = $bb_cfg['topics_per_page']; diff --git a/library/language/source/main.php b/library/language/source/main.php index f919480be..3e3ecb7bb 100644 --- a/library/language/source/main.php +++ b/library/language/source/main.php @@ -1584,7 +1584,7 @@ $lang['DEL_LIST_INFO'] = 'To delete an order from the list, click on the icon to // Watched topics $lang['WATCHED_TOPICS'] = 'Watched topics'; -$lang['NO_WATCHED_TOPICS'] = 'You are not watching any topics'; +$lang['NO_WATCHED_TOPICS'] = 'No watching any topics'; // set_die_append_msg $lang['INDEX_RETURN'] = 'Back to home page'; diff --git a/styles/templates/default/usercp_viewprofile.tpl b/styles/templates/default/usercp_viewprofile.tpl index 333d3fb51..528ebb870 100644 --- a/styles/templates/default/usercp_viewprofile.tpl +++ b/styles/templates/default/usercp_viewprofile.tpl @@ -377,7 +377,7 @@ ajax.callback.index_data = function(data) { [ {L_SEARCH_USER_POSTS} ] [ {L_SEARCH_USER_TOPICS} ] [ {L_SEARCH_RELEASES} ] - [ {L_WATCHED_TOPICS} ] + [ {L_WATCHED_TOPICS} ] [ {FEED_IMG} ]

diff --git a/tracker.php b/tracker.php index 0c2e9bee1..56b1e9456 100644 --- a/tracker.php +++ b/tracker.php @@ -301,7 +301,6 @@ if (isset($_GET[$user_releases_key])) { if (isset($_GET['random_release'])) { if ($random_release = DB()->fetch_row("SELECT topic_id FROM " . BB_BT_TORRENTS . " WHERE tor_status NOT IN(" . implode(', ', array_keys($bb_cfg['tor_frozen'])) . ") ORDER BY RAND() LIMIT 1")) { redirect(TOPIC_URL . $random_release['topic_id']); - unset($random_release); } else { bb_die($lang['NO_MATCH']); }