From 9d3bc2c178cce16ccea16c6dc23043ce8bb5120c Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Wed, 1 May 2024 12:36:06 +0700 Subject: [PATCH] Minor improvements (#1458) * Minor improvements * Updated * Update modcp.php * Update modcp.tpl * Update modcp.php * Update modcp.tpl * Update viewtopic.php * Update posting.php * Updated * Update viewtopic.tpl * Update admin_log.tpl * Updated * Update modcp.php * Update modcp.php * Update CHANGELOG.md * Revert "Update CHANGELOG.md" This reverts commit 7933176d330c48148de7b139cf234220acc0b85d. * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md --- CHANGELOG.md | 2 +- dl_list.php | 4 ++-- modcp.php | 26 +++++++++++---------- posting.php | 8 +++---- styles/templates/admin/admin_log.tpl | 2 +- styles/templates/default/index_map.tpl | 2 +- styles/templates/default/modcp.tpl | 6 ++++- styles/templates/default/search_results.tpl | 2 +- styles/templates/default/viewforum.tpl | 2 +- styles/templates/default/viewtopic.tpl | 6 ++--- viewtopic.php | 6 ++--- 11 files changed, 36 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75f357772..160300e58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ - Fixed quote selection for smiles [\#1457](https://github.com/torrentpier/torrentpier/pull/1457) ([belomaxorka](https://github.com/belomaxorka)) - Demo mode: Allow registering torrents by default [\#1440](https://github.com/torrentpier/torrentpier/pull/1440) ([belomaxorka](https://github.com/belomaxorka)) - Code refactoring [\#1441](https://github.com/torrentpier/torrentpier/pull/1441) ([belomaxorka](https://github.com/belomaxorka)) -- Minor improvements [\#1435](https://github.com/torrentpier/torrentpier/pull/1435), [\#1443](https://github.com/torrentpier/torrentpier/pull/1443), [\#1446](https://github.com/torrentpier/torrentpier/pull/1446), [\#1450](https://github.com/torrentpier/torrentpier/pull/1450), [\#1452](https://github.com/torrentpier/torrentpier/pull/1452) ([belomaxorka](https://github.com/belomaxorka)) +- Minor improvements [\#1435](https://github.com/torrentpier/torrentpier/pull/1435), [\#1443](https://github.com/torrentpier/torrentpier/pull/1443), [\#1446](https://github.com/torrentpier/torrentpier/pull/1446), [\#1450](https://github.com/torrentpier/torrentpier/pull/1450), [\#1452](https://github.com/torrentpier/torrentpier/pull/1452), [\#1458](https://github.com/torrentpier/torrentpier/pull/1458) ([belomaxorka](https://github.com/belomaxorka)) - Updated deps [\#1454](https://github.com/torrentpier/torrentpier/pull/1454), [\#1455](https://github.com/torrentpier/torrentpier/pull/1455), [\#1459](https://github.com/torrentpier/torrentpier/pull/1459), [\#1460](https://github.com/torrentpier/torrentpier/pull/1460) ([belomaxorka](https://github.com/belomaxorka)) - New Crowdin updates [\#1444](https://github.com/torrentpier/torrentpier/pull/1444), [\#1447](https://github.com/torrentpier/torrentpier/pull/1447), [\#1453](https://github.com/torrentpier/torrentpier/pull/1453) ([Exileum](https://github.com/Exileum)) diff --git a/dl_list.php b/dl_list.php index eb4124e9d..1cd3dfad4 100644 --- a/dl_list.php +++ b/dl_list.php @@ -11,8 +11,8 @@ define('BB_SCRIPT', 'dl_list'); require __DIR__ . '/common.php'; -$forum_id = isset($_REQUEST[POST_FORUM_URL]) ? (int)$_REQUEST[POST_FORUM_URL] : 0; -$topic_id = isset($_REQUEST[POST_TOPIC_URL]) ? (int)$_REQUEST[POST_TOPIC_URL] : 0; +$forum_id = $_REQUEST[POST_FORUM_URL] ?? 0; +$topic_id = $_REQUEST[POST_TOPIC_URL] ?? 0; $mode = isset($_REQUEST['mode']) ? (string)$_REQUEST['mode'] : ''; $confirmed = isset($_POST['confirm']); diff --git a/modcp.php b/modcp.php index a151eb0cc..f72b19b3b 100644 --- a/modcp.php +++ b/modcp.php @@ -73,9 +73,9 @@ function validate_mode_condition($request_index, $mod_action = '') $user->session_start(['req_login' => true]); // Obtain initial vars -$forum_id = $_REQUEST['f'] ?? 0; -$topic_id = $_REQUEST['t'] ?? 0; -$post_id = $_REQUEST['p'] ?? 0; +$forum_id = $_REQUEST[POST_FORUM_URL] ?? 0; +$topic_id = $_REQUEST[POST_TOPIC_URL] ?? 0; +$post_id = $_REQUEST[POST_POST_URL] ?? 0; $start = isset($_REQUEST['start']) ? abs((int)$_REQUEST['start']) : 0; $confirmed = isset($_POST['confirm']); @@ -599,8 +599,10 @@ switch ($mode) { bb_die($lang['NO_SUCH_POST']); } + $no_lookup = false; if (!$ip_this_post = \TorrentPier\Helpers\IPHelper::long2ip_extended($post_row['poster_ip'])) { $ip_this_post = $lang['NOT_AVAILABLE']; + $no_lookup = true; } $ip_this_post = ($rdns_ip_num == $ip_this_post) ? gethostbyaddr($ip_this_post) : $ip_this_post; @@ -610,8 +612,9 @@ switch ($mode) { $template->assign_vars([ 'TPL_MODCP_IP' => true, 'IP' => $ip_this_post, - 'U_LOOKUP_IP' => "modcp.php?mode=ip&" . POST_POST_URL . "=$post_id&" . POST_TOPIC_URL . "=$topic_id&rdns=$ip_this_post&sid=" . $userdata['session_id'], + 'U_LOOKUP_IP' => !$no_lookup ? "modcp.php?mode=ip&" . POST_POST_URL . "=$post_id&" . POST_TOPIC_URL . "=$topic_id&rdns=$ip_this_post&sid=" . $userdata['session_id'] : '', ]); + unset($no_lookup); // // Get other IP's this user has posted under @@ -631,8 +634,10 @@ switch ($mode) { continue; } + $no_lookup = false; if (!$ip = \TorrentPier\Helpers\IPHelper::long2ip_extended($row['poster_ip'])) { $ip = $lang['NOT_AVAILABLE']; + $no_lookup = true; } $ip = ($rdns_ip_num == $ip || $rdns_ip_num == 'all') ? gethostbyaddr($ip) : $ip; @@ -640,8 +645,9 @@ switch ($mode) { 'ROW_CLASS' => !($i % 2) ? 'row4' : 'row5', 'IP' => $ip, 'POSTS' => $row['postings'], - 'U_LOOKUP_IP' => "modcp.php?mode=ip&" . POST_POST_URL . "=$post_id&" . POST_TOPIC_URL . "=$topic_id&rdns=" . $ip . "&sid=" . $userdata['session_id'], + 'U_LOOKUP_IP' => !$no_lookup ? "modcp.php?mode=ip&" . POST_POST_URL . "=$post_id&" . POST_TOPIC_URL . "=$topic_id&rdns=" . $ip . "&sid=" . $userdata['session_id'] : '', ]); + unset($no_lookup); $i++; } while ($row = DB()->sql_fetchrow($result)); @@ -651,7 +657,7 @@ switch ($mode) { // Get other users who've posted under this IP // $sql = "SELECT - u.user_id, + u.user_id, u.user_rank, IF(u.user_id = $anon, p.post_username, u.username) AS username, COUNT(*) as postings FROM " . BB_USERS . " u, " . BB_POSTS . " p @@ -667,15 +673,11 @@ switch ($mode) { if ($row = DB()->sql_fetchrow($result)) { $i = 0; do { - $id = $row['user_id']; - $username = (!$row['username']) ? $lang['GUEST'] : $row['username']; - $template->assign_block_vars('userrow', [ 'ROW_CLASS' => !($i % 2) ? 'row4' : 'row5', - 'USERNAME' => $username, + 'USERNAME' => profile_url($row), 'POSTS' => $row['postings'], - 'U_PROFILE' => ($id == GUEST_UID) ? "modcp.php?mode=ip&p=$post_id&t=$topic_id" : PROFILE_URL . $id, - 'U_SEARCHPOSTS' => "search.php?search_author=1&uid=$id", + 'U_SEARCHPOSTS' => "search.php?search_author=1&uid={$row['user_id']}", ]); $i++; diff --git a/posting.php b/posting.php index 53690a0fd..69dacb46e 100644 --- a/posting.php +++ b/posting.php @@ -202,17 +202,17 @@ if (!$is_auth[$is_auth_type]) { switch ($mode) { case 'newtopic': - $redirect = "mode=newtopic&f=$forum_id"; + $redirect = "mode=newtopic&" . POST_FORUM_URL . "=$forum_id"; break; case 'new_rel': - $redirect = "mode=new_rel&f=$forum_id"; + $redirect = "mode=new_rel&" . POST_FORUM_URL . "=$forum_id"; break; case 'reply': - $redirect = "mode=reply&t=$topic_id"; + $redirect = "mode=reply&" . POST_TOPIC_URL . "=$topic_id"; break; case 'quote': case 'editpost': - $redirect = "mode=quote&p=$post_id"; + $redirect = "mode=quote&" . POST_POST_URL . "=$post_id"; break; default: $redirect = ''; diff --git a/styles/templates/admin/admin_log.tpl b/styles/templates/admin/admin_log.tpl index 2bb57477e..c22dd4bdd 100644 --- a/styles/templates/admin/admin_log.tpl +++ b/styles/templates/admin/admin_log.tpl @@ -19,7 +19,7 @@

{L_ACTIONS_LOG}

- + diff --git a/styles/templates/default/index_map.tpl b/styles/templates/default/index_map.tpl index 2fa89cea7..62106d66f 100644 --- a/styles/templates/default/index_map.tpl +++ b/styles/templates/default/index_map.tpl @@ -55,7 +55,7 @@ $(function(){ - + diff --git a/styles/templates/default/modcp.tpl b/styles/templates/default/modcp.tpl index ce25fe14f..573b40756 100644 --- a/styles/templates/default/modcp.tpl +++ b/styles/templates/default/modcp.tpl @@ -15,7 +15,9 @@ @@ -24,7 +26,7 @@ @@ -38,7 +40,9 @@ diff --git a/styles/templates/default/search_results.tpl b/styles/templates/default/search_results.tpl index dc8bc2a1e..ca5568e90 100644 --- a/styles/templates/default/search_results.tpl +++ b/styles/templates/default/search_results.tpl @@ -53,7 +53,7 @@ {QUOTE_IMG}{POST_BTN_SPACER}{EDIT_POST_IMG}{POST_BTN_SPACER}{DELETE_POST_IMG}{POST_BTN_SPACER} - {IP_POST_IMG}{POST_BTN_SPACER} + {IP_POST_IMG}{POST_BTN_SPACER}

diff --git a/styles/templates/default/viewforum.tpl b/styles/templates/default/viewforum.tpl index 827aa88e5..638706606 100644 --- a/styles/templates/default/viewforum.tpl +++ b/styles/templates/default/viewforum.tpl @@ -153,7 +153,7 @@ ajax.callback.mod_action = function (data) {

{IP}

+

[ {L_LOOKUP_IP}

+
-

{userrow.USERNAME}

+

{userrow.USERNAME}

[ {L_POSTS}: {userrow.POSTS} ]

[ {L_SEARCH_USER_POSTS_SHORT}

{iprow.IP}

[ {L_POSTS}: {iprow.POSTS} ]

+

[ {L_LOOKUP_IP}

+
diff --git a/viewtopic.php b/viewtopic.php index c9caf54c1..4718b574a 100644 --- a/viewtopic.php +++ b/viewtopic.php @@ -358,8 +358,8 @@ if (!$ranks = $datastore->get('ranks')) { $topic_title = $wordCensor->censorString($topic_title); // Post, reply and other URL generation for templating vars -$new_topic_url = POSTING_URL . "?mode=newtopic&f=" . $forum_id; -$reply_topic_url = POSTING_URL . "?mode=reply&t=" . $topic_id; +$new_topic_url = POSTING_URL . "?mode=newtopic&" . POST_FORUM_URL . "=$forum_id"; +$reply_topic_url = POSTING_URL . "?mode=reply&" . POST_TOPIC_URL . "=$topic_id"; $view_forum_url = FORUM_URL . $forum_id; $view_prev_topic_url = TOPIC_URL . $topic_id . "&view=previous#newest"; $view_next_topic_url = TOPIC_URL . $topic_id . "&view=next#newest"; @@ -494,7 +494,7 @@ $template->assign_vars([ 'U_VIEW_NEWER_TOPIC' => $view_next_topic_url, 'U_POST_NEW_TOPIC' => $new_topic_url, 'U_POST_REPLY_TOPIC' => $reply_topic_url, - 'U_SEARCH_SELF' => "search.php?uid={$userdata['user_id']}&t=$topic_id&dm=1", + 'U_SEARCH_SELF' => "search.php?uid={$userdata['user_id']}&" . POST_TOPIC_URL . "=$topic_id&dm=1", 'TOPIC_HAS_POLL' => $topic_has_poll, 'POLL_IS_EDITABLE' => !$poll_time_expired,