From c9e0b6f1e6d17f9dd4822905650aa3f104c64a45 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Fri, 12 Aug 2022 15:36:12 +0800 Subject: [PATCH] improve viewpeerlist --- public/viewpeerlist.php | 46 ++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/public/viewpeerlist.php b/public/viewpeerlist.php index 6538bd75..98943914 100644 --- a/public/viewpeerlist.php +++ b/public/viewpeerlist.php @@ -16,6 +16,7 @@ function get_location_column($e, $isStrongPrivacy, $canView): string { global $enablelocation_tweak, $seedBoxRep, $lang_functions, $lang_viewpeerlist; $address = $ips = []; + //First, build the location if ($enablelocation_tweak == 'yes') { if (!empty($e['ipv4'])) { list($loc_pub, $loc_mod) = get_ip_location($e['ipv4']); @@ -29,7 +30,11 @@ function get_location_column($e, $isStrongPrivacy, $canView): string $address[] = $loc_pub . $seedBoxIcon; $ips[] = $e['ipv6']; } - $title = sprintf('%s%s%s', $lang_functions['text_user_ip'], ': ', implode(', ', $ips)); + if ($canView) { + $title = sprintf('%s%s%s', $lang_functions['text_user_ip'], ': ', implode(', ', $ips)); + } else { + $title = ''; + } $addressStr = implode('
', $address); $location = '
'.$addressStr.'
'; } else { @@ -104,30 +109,23 @@ function dltable($name, $arr, $torrent) $s .= "\n"; $secs = max(1, ($e["la"] - $e["st"])); $columnLocation = $usernameSeedBoxIcon = ''; - if ($privacy == "strong" || ($torrent['anonymous'] == 'yes' && $e['userid'] == $torrent['owner'])) { - if (get_user_class() >= $viewanonymous_class || $e['userid'] == $CURUSER['id']) { - if ($showLocationColumn) { - $columnLocation = get_location_column($e, true, true); - } else { - $usernameSeedBoxIcon = get_username_seed_box_icon($e); - } - $columnUsername = "".$lang_viewpeerlist['text_anonymous']."".$usernameSeedBoxIcon."
(" . get_username($e['userid']) . ")\n"; - } else { - if ($showLocationColumn) { - $columnLocation = get_location_column($e, true, false); - } else { - $usernameSeedBoxIcon = get_username_seed_box_icon($e); - } - $columnUsername = "".$lang_viewpeerlist['text_anonymous']."".$usernameSeedBoxIcon."\n"; - } - } else { - if ($showLocationColumn) { - $columnLocation = get_location_column($e, false, false); - } else { - $usernameSeedBoxIcon = get_username_seed_box_icon($e); - } - $columnUsername = "" . get_username($e['userid']).$usernameSeedBoxIcon."\n"; + $isStrongPrivacy = $privacy == "strong" || ($torrent['anonymous'] == 'yes' && $e['userid'] == $torrent['owner']); + $canView = get_user_class() >= $viewanonymous_class || $e['userid'] == $CURUSER['id']; + if ($showLocationColumn) { + $columnLocation = get_location_column($e, $isStrongPrivacy, $canView); + } else { + $usernameSeedBoxIcon = get_username_seed_box_icon($e); } + if ($isStrongPrivacy) { + $columnUsername = "".$lang_viewpeerlist['text_anonymous']."".$usernameSeedBoxIcon; + if ($canView) { + $columnUsername .= "
(" . get_username($e['userid']) . ")"; + } + $columnUsername .= ""; + } else { + $columnUsername = "" . get_username($e['userid']).$usernameSeedBoxIcon.""; + } + $s .= $columnUsername . $columnLocation; $s .= "" . ($e['connectable'] == "yes" ? $lang_viewpeerlist['text_yes'] : "".$lang_viewpeerlist['text_no']."") . "\n";