mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-20 13:24:01 -07:00
Show icons for clients while in the tracker statistics (#1058)
This commit is contained in:
parent
24a297d524
commit
30c31144ca
2 changed files with 13 additions and 15 deletions
|
@ -76,18 +76,24 @@ foreach ($rowset as $cnt => $row) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$clients = [];
|
$clients = [];
|
||||||
|
$client_count = 0;
|
||||||
$rowset = DB()->fetch_rowset('SELECT peer_id AS client FROM ' . TMP_TRACKER_TABLE);
|
$rowset = DB()->fetch_rowset('SELECT peer_id AS client FROM ' . TMP_TRACKER_TABLE);
|
||||||
foreach ($rowset as $cnt => $row) {
|
foreach ($rowset as $cnt => $row) {
|
||||||
$clients[] = get_user_torrent_client(substr($row['client'], 0, 3), true);
|
$clientString = substr($row['client'], 0, 3);
|
||||||
|
if (!isset($clients[$clientString])) {
|
||||||
|
$clients[$clientString] = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$clients[$clientString]++;
|
||||||
|
}
|
||||||
|
$client_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$client_count = count($clients);
|
foreach ($clients as $value => $count) {
|
||||||
$client_values = array_count_values($clients);
|
|
||||||
|
|
||||||
foreach ($client_values as $value => $count) {
|
|
||||||
$percentage = ($count / $client_count) * 100;
|
$percentage = ($count / $client_count) * 100;
|
||||||
$clients_percentage[] ="$value ($count) => $percentage%";
|
$clients_percentage[] = get_user_torrent_client($value) . " ($count) => $percentage%";
|
||||||
}
|
}
|
||||||
|
|
||||||
$clients = implode('<br>', $clients_percentage);
|
$clients = implode('<br>', $clients_percentage);
|
||||||
|
|
||||||
function commify_callback($matches)
|
function commify_callback($matches)
|
||||||
|
|
|
@ -1179,9 +1179,8 @@ function bb_date($gmepoch, $format = false, $friendly_date = true)
|
||||||
* @param string $peer_id
|
* @param string $peer_id
|
||||||
* @return mixed|string
|
* @return mixed|string
|
||||||
*/
|
*/
|
||||||
function get_user_torrent_client(string $peer_id, bool $nameOnly = false): mixed
|
function get_user_torrent_client(string $peer_id): mixed
|
||||||
{
|
{
|
||||||
static $icons_extension = '.png';
|
|
||||||
static $clients = [
|
static $clients = [
|
||||||
'-AG' => 'Ares', '-AZ' => 'Vuze', '-A~' => 'Ares', '-BC' => 'BitComet',
|
'-AG' => 'Ares', '-AZ' => 'Vuze', '-A~' => 'Ares', '-BC' => 'BitComet',
|
||||||
'-BE' => 'BitTorrent SDK', '-BI' => 'BiglyBT', '-BL' => 'BitLord', '-BT' => 'BitTorrent',
|
'-BE' => 'BitTorrent SDK', '-BI' => 'BiglyBT', '-BL' => 'BitLord', '-BT' => 'BitTorrent',
|
||||||
|
@ -1231,13 +1230,6 @@ function get_user_torrent_client(string $peer_id, bool $nameOnly = false): mixed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($nameOnly) {
|
|
||||||
if (!empty($bestMatchLength)) {
|
|
||||||
return $bestMatch;
|
|
||||||
}
|
|
||||||
return $peer_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($bestMatchLength)) {
|
if (!empty($bestMatchLength)) {
|
||||||
return '<img width="auto" height="auto" style="display:inline!important;vertical-align:middle" src="/styles/images/clients/' . $bestMatch . '.png" alt="' . $bestMatch . '" title="' . $peer_id . '">';
|
return '<img width="auto" height="auto" style="display:inline!important;vertical-align:middle" src="/styles/images/clients/' . $bestMatch . '.png" alt="' . $bestMatch . '" title="' . $peer_id . '">';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue