From c2599a7c22f19cdba8117fe85348f2ff5ce54ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B8nstantine=20Kovalensky?= <45331093+kovalensky@users.noreply.github.com> Date: Wed, 8 Nov 2023 16:25:56 +0400 Subject: [PATCH] Show options for version debugging of user clients (#1061) --- admin/stats/tracker.php | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/admin/stats/tracker.php b/admin/stats/tracker.php index 7fce46456..2e317db07 100644 --- a/admin/stats/tracker.php +++ b/admin/stats/tracker.php @@ -76,13 +76,19 @@ foreach ($rowset as $cnt => $row) { } // Detailed statistics for peer clients -$clients = []; -$client_count = 0; + $client_list = ''; +$numwant = !empty($_GET['client_numwant']) ? (int)$_GET['client_numwant'] : 100; +$client_full = !empty($_GET['client_length']) ? (int)$_GET['client_length'] : false; + $rowset = DB()->fetch_rowset('SELECT peer_id AS client FROM ' . TMP_TRACKER_TABLE); + if (!empty($rowset)) { + + $client_count = 0; + foreach ($rowset as $cnt => $row) { - $clientString = substr($row['client'], 0, 3); + $clientString = $client_full ? substr($row['client'], 0, $client_full) : substr($row['client'], 0, 3); if (!isset($clients[$clientString])) { $clients[$clientString] = 1; } @@ -90,14 +96,14 @@ if (!empty($rowset)) { $clients[$clientString]++; } $client_count++; -} + } -foreach ($clients as $value => $count) { - $percentage = ($count / $client_count) * 100; - $clients_percentage[] = get_user_torrent_client($value) . " ($count) => $percentage%"; -} + foreach ($clients as $client => $count) { + $percentage = ($count / $client_count) * 100; + $clients_percentage[] = ($client_full ? $client : get_user_torrent_client($client)) . " [$count] => $percentage%"; + } -$client_list = implode('
', $clients_percentage); + $client_list = implode('
', array_slice($clients_percentage, 0, $numwant)); } function commify_callback($matches) @@ -142,10 +148,13 @@ echo ' clients: -   + $client_list - +
\n"; +echo (count($clients_percentage) > $numwant) ? ('' . 'Show more' . '
') : ''; +echo $client_full ? '
Get more length and numbers via modifying the parameters in the url' : 'Peer_ids with more length (version debugging)'; +echo ''; echo ''; echo '
';