Added showing releaser stats in profile (#1568)

* Added showing releaser stats in profile

* Update viewprofile.php

* Update usercp_viewprofile.tpl

* Update CHANGELOG.md

* Update viewprofile.php
This commit is contained in:
Roman Kelesidis 2024-08-03 13:08:27 +07:00 committed by GitHub
commit 7f746af5d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 70 additions and 26 deletions

View file

@ -122,6 +122,37 @@ switch ($mode) {
$this->ajax_die($lang['BT_NULL_RATIO_SUCCESS']);
break;
case 'releaser_stats':
$user_id = (int)$this->request['user_id'];
if (!IS_ADMIN && $user_id != $userdata['user_id']) {
$this->ajax_die($lang['NOT_AUTHORISED']);
}
$sql = "
SELECT COUNT(tor.poster_id) as total_releases, SUM(tor.size) as total_size, tor.poster_id, SUM(ad.download_count) as download_count
FROM " . BB_BT_TORRENTS . " tor
LEFT JOIN " . BB_USERS . " u ON(u.user_id = tor.poster_id)
LEFT JOIN " . BB_ATTACHMENTS_DESC . " ad ON(ad.attach_id = tor.attach_id)
LEFT JOIN " . BB_BT_USERS . " ut ON(ut.user_id = tor.poster_id)
WHERE u.user_id = $user_id
GROUP BY tor.poster_id
ORDER BY SUM(ad.download_count) DESC
";
$total_releases_size = $total_releases = $total_releases_completed = 0;
if ($row = DB()->fetch_row($sql)) {
$total_releases = $row['total_releases'];
$total_releases_size = humn_size($row['total_size']);
$total_releases_completed = $row['download_count'];
}
$html = '[
' . $lang['RELEASES'] . ': <span class="seed bold">' . $total_releases . '</span> |
' . $lang['RELEASER_STAT_SIZE'] . ' <span class="seed bold">' . $total_releases_size . '</span> |
' . $lang['DOWNLOADED'] . ': <span class="seed bold">' . declension((int)$total_releases_completed, 'times') . '</span> ]
';
break;
case 'get_traf_stats':
if (!RATIO_ENABLED) {
$this->ajax_die($lang['MODULE_OFF']);