diff --git a/CHANGELOG.md b/CHANGELOG.md
index cb05f7c3a..f4f6d92ec 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@
- Release 2.4.5 🦕 ([belomaxorka](https://github.com/belomaxorka))
- Added some new HTML meta-tags [\#1562](https://github.com/torrentpier/torrentpier/pull/1562) ([belomaxorka](https://github.com/belomaxorka))
+- Added showing releaser stats in profile [\#1568](https://github.com/torrentpier/torrentpier/pull/1568) ([belomaxorka](https://github.com/belomaxorka))
- Fixed `md5()` deprecated in PHP 8.4 [\#1561](https://github.com/torrentpier/torrentpier/pull/1561) ([belomaxorka](https://github.com/belomaxorka))
- Increased `USEREMAIL_MAX_LENGTH` [\#1566](https://github.com/torrentpier/torrentpier/pull/1566) ([belomaxorka](https://github.com/belomaxorka))
diff --git a/library/ajax/index_data.php b/library/ajax/index_data.php
index e619ff81c..f09ea9cc9 100644
--- a/library/ajax/index_data.php
+++ b/library/ajax/index_data.php
@@ -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'] . ': ' . $total_releases . ' |
+ ' . $lang['RELEASER_STAT_SIZE'] . ' ' . $total_releases_size . ' |
+ ' . $lang['DOWNLOADED'] . ': ' . declension((int)$total_releases_completed, 'times') . ' ]
+ ';
+ break;
+
case 'get_traf_stats':
if (!RATIO_ENABLED) {
$this->ajax_die($lang['MODULE_OFF']);
diff --git a/library/includes/ucp/viewprofile.php b/library/includes/ucp/viewprofile.php
index 45d5a8ea9..7cdf9eb2e 100644
--- a/library/includes/ucp/viewprofile.php
+++ b/library/includes/ucp/viewprofile.php
@@ -75,9 +75,8 @@ if (bf($profiledata['user_opt'], 'user_opt', 'dis_sig')) {
}
// Null ratio
-if ($bb_cfg['ratio_null_enabled']) {
- $btu = get_bt_userdata($profiledata['user_id']);
- $template->assign_vars(array('NULLED_RATIO' => (bool)$btu['ratio_nulled']));
+if ($bb_cfg['ratio_null_enabled'] && $btu = get_bt_userdata($profiledata['user_id'])) {
+ $template->assign_vars(array('NULLED_RATIO' => $btu['ratio_nulled']));
}
// Ban information
diff --git a/library/language/source/main.php b/library/language/source/main.php
index dad374092..8771e3ec8 100644
--- a/library/language/source/main.php
+++ b/library/language/source/main.php
@@ -3069,3 +3069,8 @@ $lang['BT_NULL_RATIO_ALERT'] = "Attention!\n\nAre you sure you want to reset you
$lang['BT_NULL_RATIO_AGAIN'] = 'You have already reset your ratio!';
$lang['BT_NULL_RATIO_NOT_NEEDED'] = 'You have a good ratio. Reset is possible only with a ratio less than %s';
$lang['BT_NULL_RATIO_SUCCESS'] = 'The ratio has been reset successfully!';
+
+// Releaser stats
+$lang['RELEASER_STAT_SIZE'] = 'Total size:';
+$lang['RELEASER_STAT'] = 'Releaser stats:';
+$lang['RELEASER_STAT_SHOW'] = 'Show stats';
diff --git a/styles/templates/default/usercp_viewprofile.tpl b/styles/templates/default/usercp_viewprofile.tpl
index a8387dd19..5ee0cf144 100644
--- a/styles/templates/default/usercp_viewprofile.tpl
+++ b/styles/templates/default/usercp_viewprofile.tpl
@@ -130,29 +130,31 @@ ajax.callback.group_membership = function(data) {
-
-
-
-