Peer client display support (#968)

Show torrent client icons for statistics
This commit is contained in:
Cønstantine K ̷o̷valensky 2023-10-13 13:23:21 +04:00 committed by GitHub
commit 73150d2584
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 171 additions and 7 deletions

View file

@ -68,7 +68,8 @@ if (!isset($info_hash)) {
// Store info hash in hex format
$info_hash_hex = bin2hex($info_hash);
// Store peer id
$peer_id_sql = rtrim(DB()->escape(substr($peer_id, 0, 10)), ' ');
// Check info_hash version
if (strlen($info_hash) === 32) {
$is_bt_v2 = true;
@ -189,7 +190,7 @@ if ($lp_info) {
$tor_type = $row['tor_type'];
// Check hybrid torrents
if (!empty($row['info_hash'], $row['info_hash_v2'])) {
if (!empty($row['info_hash']) && !empty($row['info_hash_v2'])) {
// Helpful dev variables
$is_hybrid = true;
$hybrid_v1_hash = &$row['info_hash'];
@ -316,6 +317,7 @@ if (isset($hybrid_tor_update) || !isset($is_hybrid)) { // Update statistics only
$sql .= ", speed_down = $speed_down";
$sql .= ", complete = $complete";
$sql .= ", peer_id = '$peer_id_sql'";
$sql .= " WHERE peer_hash = '$peer_hash'";
$sql .= " LIMIT 1";
@ -326,8 +328,8 @@ if (isset($hybrid_tor_update) || !isset($is_hybrid)) { // Update statistics only
}
if (!$lp_info || !$peer_info_updated) {
$columns = 'peer_hash, topic_id, user_id, ip, port, seeder, releaser, tor_type, uploaded, downloaded, remain, speed_up, speed_down, up_add, down_add, update_time, complete';
$values = "'$peer_hash', $topic_id, $user_id, '$ip_sql', $port, $seeder, $releaser, $tor_type, $uploaded, $downloaded, $left, $speed_up, $speed_down, $up_add, $down_add, $update_time, $complete";
$columns = 'peer_hash, topic_id, user_id, ip, port, seeder, releaser, tor_type, uploaded, downloaded, remain, speed_up, speed_down, up_add, down_add, update_time, complete, peer_id';
$values = "'$peer_hash', $topic_id, $user_id, '$ip_sql', $port, $seeder, $releaser, $tor_type, $uploaded, $downloaded, $left, $speed_up, $speed_down, $up_add, $down_add, $update_time, $complete, '$peer_id_sql'";
DB()->query("REPLACE INTO " . BB_BT_TRACKER . " ($columns) VALUES ($values)");
}

View file

@ -263,6 +263,7 @@ if ($tor_reged && $tor_info) {
'sup' => 'tr.speed_up',
'sdown' => 'tr.speed_down',
'time' => 'tr.update_time'
'peer_id' => 'tr.peer_id',
];
foreach ($peer_orders as $get_key => $order_by_value) {
@ -288,7 +289,7 @@ if ($tor_reged && $tor_info) {
LIMIT $show_peers_limit";
} else {
$sql = "SELECT
tr.user_id, tr.ip, tr.port, tr.uploaded, tr.downloaded, tr.remain,
tr.user_id, tr.ip, tr.port, tr.peer_id, tr.uploaded, tr.downloaded, tr.remain,
tr.seeder, tr.releaser, tr.speed_up, tr.speed_down, tr.update_time,
tr.complete_percent, u.username, u.user_rank
FROM " . BB_BT_TRACKER . " tr
@ -443,6 +444,7 @@ if ($tor_reged && $tor_info) {
$template->assign_block_vars("$x_full.$x_row", [
'ROW_BGR' => $row_bgr,
'NAME' => ($peer['update_time']) ? $name : "<s>$name</s>",
'PEER_ID' => isset($peer['peer_id']) ? get_user_client($peer['peer_id']) : 'unknown',
'COMPL_PRC' => $compl_perc,
'UP_TOTAL' => ($max_up_id[$x] == $pid) ? "<b>$up_tot</b>" : $up_tot,
'DOWN_TOTAL' => ($max_down_id[$x] == $pid) ? "<b>$down_tot</b>" : $down_tot,

View file

@ -1173,6 +1173,161 @@ function bb_date($gmepoch, $format = false, $friendly_date = true)
return ($bb_cfg['translate_dates']) ? strtr(strtoupper($date), $lang['DATETIME']) : $date;
}
// Get user's torrent client string
function get_user_client($peer_id)
{
static $clients = [
///'-AD' => 'Advanced Download Manager',
'-AG' => 'Ares',
//'-AR' => 'Arctic',
//'-AT' => 'Artemis',
//'-AV' => 'Avicora',
//'-AX' => 'BitPump',
'-AZ' => 'Vuze',
'-A~' => 'Ares',
//'-BB' => 'BitBuddy',
'-BC' => 'BitComet',
'-BE' => 'BitTorrent SDK',
//'-BF' => 'BitFlu',
//'-BG' => 'BTGetit',
//'-BH' => 'BitZilla',
'-BI' => 'BiglyBT',
'-BL' => 'BitLord',
//'-BM' => 'BitMagnet',
//'-BN' => 'Baidu Netdisk',
//'-BOW' => 'Bits on Wheels',
//'-BP' => 'BitTorrent Pro (Azureus + Spyware)',
//'-BR' => 'BitRocket',
//'-BS' => 'BTSlave',
'-BT' => 'BitTorrent',
//'-BW' => 'BitTorrent Web',
//'-BX' => 'BittorrentX',
//'-CD' => 'Enhanced CTorrent',
'-CT' => 'CTorrent',
'-DE' => 'Deluge',
//'-DP' => 'Propagate Data Client',
//'-EB' => 'EBit',
//'-ES' => 'Electric Sheep',
//'-FC' => 'FileCroc',
'-FD' => 'Free Download Manager',
'FD6' => 'Free Download Manager',
'-FG' => 'FlashGet',
'-FL' => 'Folx',
//'-FT' => 'FoxTorrent/RedSwoosh',
//'-FW' => 'FrostWire',
//'-FX' => 'Freebox',
//'-G3' => 'G3 Torrent',
//'-GR' => 'GetRight',
//'-GS' => 'GSTorrent',
//'-HK' => 'Hekate',
'-HL' => 'Halite',
//'-HN' => 'Hydranode',
'-KG' => 'KGet',
'-KT' => 'KTorrent',
//'-LC' => 'LeechCraft',
//'-LH' => 'LH-ABC',
//'-LP' => 'Lphant',
'-LT' => 'libTorrent',
//'-LW' => 'LimeWire',
'-Lr' => 'LibreTorrent',
'-MG' => 'MediaGet',
//'-MK' => 'Meerkat',
//'-ML' => 'MLDonkey',
//'-MO' => 'MonoTorrent',
//'-MP' => 'MooPolice',
//'-MR' => 'Miro',
//'-MT' => 'Moonlight',
//'-NE' => 'BT Next Evolution',
//'-NX' => 'Net Transport',
//'-OS' => 'OneSwarm',
//'-OT' => 'OmegaTorrent',
//'-PD' => 'Pando',
///'-PI' => 'PicoTorrent',
//'-QD' => 'QQDownload',
//'-QT' => 'QT 4 Torrent example',
//'-RS' => 'Rufus',
//'-RT' => 'Retriever',
//'-RZ' => 'RezTorrent',
//'-SB' => 'Swiftbit',
///'-SD' => 'Thunder',
//'-SM' => 'SoMud',
///'-SP' => 'BitSpirit',
//'-SS' => 'SwarmScope',
//'-ST' => 'SymTorrent',
//'-SZ' => 'Shareaza',
//'-S~' => 'Shareaza',
//'-TB' => 'Torch Browser',
//'-TN' => 'Torrent .NET',
'-TR' => 'Transmission',
//'-TS' => 'Torrentstorm',
//'-TT' => 'TuoTu',
'-tT' => 'tTorrent',
//'-UE' => "uTorrent Embedded",
//'-UL' => 'uLeecher!',
'-UM' => "uTorrent Mac",
'-UT' => "uTorrent",
'-UW' => "uTorrent Web",
//'-VG' => 'Vagaa',
//'-WS' => 'HTTP Seed',
//'-WT' => 'BitLet',
//'-WT-' => 'BitLet',
'-WW' => 'WebTorrent',
'-WD' => 'WebTorrent',
//'-WY' => 'FireTorrent',
//'-XC' => 'Xtorrent',
//'-XF' => 'Xfplay',
'-XL' => 'Xunlei',
//'-XS' => 'XSwifter',
//'-XT' => 'XanTorrent',
//'-XX' => 'Xtorrent',
///'-ZO' => 'Zona',
//'-ZT' => 'Zip Torrent',
//'-bk' => 'BitKitten (libtorrent)',
//'-lt' => 'libTorrent (Rakshasa)',
//'-pb' => 'pbTorrent',
'-PI' => 'PicoTorrent',
'-qB' => 'qBittorrent',
//'-st' => 'SharkTorrent',
//'346-' => 'TorrentTopia',
//'AZ2500BT' => 'BitTyrant (Azureus Mod)',
//'BLZ' => 'Blizzard Downloader',
//'DNA' => 'BitTorrent DNA',
//'FD6' => 'Free Download Manager 6',
//'LIME' => 'Limewire',
'M' => 'BitTorrent',
'MG' => 'MediaGet',
//'Mbrst' => 'burst!',
'OP' => 'Opera',
//'Pando' => 'Pando',
//'Plus' => 'Plus!',
//'Q' => 'Queen Bee',
//'QVOD' => 'QVOD',
///'S3' => 'Amazon S3',
'TIX' => 'Tixati',
'aria2-' => 'Aria2',
'A2' => 'Aria2',
//'btpd' => 'BT Protocol Daemon',
//'eX' => 'eXeem',
//'martini' => 'Martini Man',
];
$bestMatchLength = 0;
$peer_id = htmlCHR($peer_id);
foreach ($clients as $key => $clientName) {
if (str_starts_with($peer_id, $key) !== false && strlen($key) > $bestMatchLength) {
$bestMatch = $clientName;
$bestMatchLength = strlen($key);
}
}
if (!empty($bestMatch)) {
return '<img width="auto" height="auto" style="display:inline!important;vertical-align:middle" src="/styles/images/clients/'. $bestMatch .'.png" alt="' . $bestMatch . '" title="' . $peer_id . '">';
}
else {
return $peer_id;
}
}
function birthday_age($date)
{
global $bb_cfg;

View file

@ -77,6 +77,7 @@ if (bf($profiledata['user_opt'], 'user_opt', 'dis_sig')) {
$template->assign_vars([
'PAGE_TITLE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']),
'USERNAME' => $profiledata['username'],
'PROFILE_USER_ID' => $profiledata['user_id'],
'PROFILE_USER' => $profile_user_id,
'USER_REGDATE' => bb_date($profiledata['user_regdate'], 'Y-m-d H:i', false),
@ -90,7 +91,6 @@ $template->assign_vars([
'ICQ' => $profiledata['user_icq'],
'LAST_VISIT_TIME' => ($profiledata['user_lastvisit']) ? (!$profile_user_id && bf($profiledata['user_opt'], 'user_opt', 'user_viewonline') && !IS_ADMIN) ? $lang['HIDDEN_USER'] : bb_date($profiledata['user_lastvisit'], 'Y-m-d H:i', false) : $lang['NEVER'],
'LAST_ACTIVITY_TIME' => ($profiledata['user_session_time']) ? (!$profile_user_id && bf($profiledata['user_opt'], 'user_opt', 'user_viewonline') && !IS_ADMIN) ? $lang['HIDDEN_USER'] : bb_date($profiledata['user_session_time'], 'Y-m-d H:i', false) : $lang['NEVER'],
'USER_ACTIVE' => $profiledata['user_active'],
'LOCATION' => $profiledata['user_from'],
'OCCUPATION' => $profiledata['user_occ'],

View file

@ -1542,6 +1542,7 @@ $lang['DL_DL'] = 'DL';
$lang['DL_UL_SPEED'] = 'UL speed';
$lang['DL_DL_SPEED'] = 'DL speed';
$lang['DL_PORT'] = 'Port';
$lang['DL_CLIENT'] = 'Client';
$lang['DL_FORMULA'] = 'Formula: Uploaded/TorrentSize';
$lang['DL_ULR'] = 'URL';
$lang['DL_STOPPED'] = 'stopped';

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 780 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 885 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 729 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

View file

@ -154,6 +154,7 @@ ajax.callback.callseed = function (data) {
<!-- BEGIN porthead -->
<th class="{sorter: 'digit'}"><b class="tbs-text">{L_DL_PORT}</b><img width="75" class="spacer" src="{SPACER}" alt="" /></th>
<!-- END porthead -->
<th class="{sorter: 'text'}"><b class="tbs-text">{L_DL_CLIENT}</b><img width="75" class="spacer" src="{SPACER}" alt="" /></th>
</tr>
</thead>
<!-- BEGIN srow -->
@ -170,6 +171,7 @@ ajax.callback.callseed = function (data) {
<!-- BEGIN port -->
<td>{sfull.srow.port.PORT}</td>
<!-- END port -->
<td>{sfull.srow.PEER_ID}</td>
</tr>
<!-- END srow -->
</table>
@ -202,7 +204,8 @@ ajax.callback.callseed = function (data) {
<!-- END iphead -->
<!-- BEGIN porthead -->
<th class="{sorter: 'digit'}"><b class="tbs-text">{L_DL_PORT}</b><img width="75" class="spacer" src="{SPACER}" alt="" /></th>
<!-- END porthead -->
<!-- END porthead -->
<th class="{sorter: 'text'}"><b class="tbs-text">{L_DL_CLIENT}</b><img width="75" class="spacer" src="{SPACER}" alt="" /></th>
</tr>
</thead>
<!-- BEGIN lrow -->
@ -219,6 +222,7 @@ ajax.callback.callseed = function (data) {
<!-- BEGIN port -->
<td>{lfull.lrow.port.PORT}</td>
<!-- END port -->
<td>{lfull.lrow.PEER_ID}</td>
</tr>
<!-- END lrow -->
</table>