mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 13:54:02 -07:00
Show user clients percentage in tracker statistics (#1057)
This commit is contained in:
parent
6e0a9964f0
commit
24a297d524
2 changed files with 35 additions and 5 deletions
|
@ -30,14 +30,16 @@ DB()->query('
|
|||
CREATE TEMPORARY TABLE ' . TMP_TRACKER_TABLE . " (
|
||||
`topic_id` mediumint(8) unsigned NOT NULL default '0',
|
||||
`user_id` mediumint(9) NOT NULL default '0',
|
||||
`ip` char(8) binary NOT NULL default '0',
|
||||
`ip` char(42) binary default '0',
|
||||
`ipv6` char(42) binary default '0',
|
||||
`peer_id` char(20) binary default '0',
|
||||
`seeder` tinyint(1) NOT NULL default '0',
|
||||
`speed_up` mediumint(8) unsigned NOT NULL default '0',
|
||||
`speed_down` mediumint(8) unsigned NOT NULL default '0',
|
||||
`update_time` int(11) NOT NULL default '0'
|
||||
)
|
||||
SELECT
|
||||
topic_id, user_id, ip, seeder, speed_up, speed_down, update_time
|
||||
topic_id, user_id, ip, ipv6, peer_id, seeder, speed_up, speed_down, update_time
|
||||
FROM " . BB_BT_TRACKER . '
|
||||
');
|
||||
|
||||
|
@ -73,6 +75,21 @@ foreach ($rowset as $cnt => $row) {
|
|||
$peers_in_last_sec[] = sprintf('%3s', $row['peers']) . (($cnt && !(++$cnt % 15)) ? " \n" : '');
|
||||
}
|
||||
|
||||
$clients = [];
|
||||
$rowset = DB()->fetch_rowset('SELECT peer_id AS client FROM ' . TMP_TRACKER_TABLE);
|
||||
foreach ($rowset as $cnt => $row) {
|
||||
$clients[] = get_user_torrent_client(substr($row['client'], 0, 3), true);
|
||||
}
|
||||
|
||||
$client_count = count($clients);
|
||||
$client_values = array_count_values($clients);
|
||||
|
||||
foreach ($client_values as $value => $count) {
|
||||
$percentage = ($count / $client_count) * 100;
|
||||
$clients_percentage[] ="$value ($count) => $percentage%";
|
||||
}
|
||||
$clients = implode('<br>', $clients_percentage);
|
||||
|
||||
function commify_callback($matches)
|
||||
{
|
||||
return commify($matches[0]);
|
||||
|
@ -112,6 +129,13 @@ echo "\n<tr><td align=center> peers: in last " . implode(' / ', $peers_in_last_m
|
|||
echo "\n<td align=center>" . implode(' / ', $peers_in_last_min) . "</td></tr>\n";
|
||||
echo "\n<tr><td align=center> peers in last $peers_in_last_sec_limit sec <br /> [ per second, DESC order --> ] <br /> last peer: $stat[last_peer_time] seconds ago <br /> " . date('j M H:i:s [T O]') . " </td>\n";
|
||||
echo '<td align=center style="font-size: 13px; font-family: \'Courier New\',Courier,monospace;"><pre> ' . implode(' ', $peers_in_last_sec) . "</pre></td></tr>\n";
|
||||
echo "\n
|
||||
<tr><td align=center> clients: </td>
|
||||
<td align=center>
|
||||
|
||||
$clients
|
||||
</td></tr>
|
||||
\n";
|
||||
echo '</table>';
|
||||
echo '<div align="center"><pre>';
|
||||
|
||||
|
|
|
@ -1179,7 +1179,7 @@ function bb_date($gmepoch, $format = false, $friendly_date = true)
|
|||
* @param string $peer_id
|
||||
* @return mixed|string
|
||||
*/
|
||||
function get_user_torrent_client(string $peer_id): mixed
|
||||
function get_user_torrent_client(string $peer_id, bool $nameOnly = false): mixed
|
||||
{
|
||||
static $icons_extension = '.png';
|
||||
static $clients = [
|
||||
|
@ -1231,12 +1231,18 @@ function get_user_torrent_client(string $peer_id): mixed
|
|||
}
|
||||
}
|
||||
|
||||
if (!empty($bestMatch)) {
|
||||
if ($nameOnly) {
|
||||
if (!empty($bestMatchLength)) {
|
||||
return $bestMatch;
|
||||
}
|
||||
return $peer_id;
|
||||
}
|
||||
|
||||
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 $peer_id;
|
||||
|
||||
}
|
||||
|
||||
function birthday_age($date)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue