Added ability to reset ratio (#1545)

* Minor improvements

* Update index_data.php

* Updated

* Update usercp_viewprofile.tpl

* Update mysql.sql

* Update main.php

* Update CHANGELOG.md
This commit is contained in:
Roman Kelesidis 2024-07-19 14:25:47 +07:00 committed by GitHub
commit 0eba082d41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 61 additions and 2 deletions

View file

@ -8,6 +8,7 @@
- Release 2.4.4 🦩 ([belomaxorka](https://github.com/belomaxorka))
- CWE-502 Fixed: Deserialization of untrusted data ([belomaxorka](https://github.com/belomaxorka))
- Create tech stack docs (techstack.yml and techstack.md) [\#1521](https://github.com/torrentpier/torrentpier/pull/1521), [\#1522](https://github.com/torrentpier/torrentpier/pull/1522) ([belomaxorka](https://github.com/belomaxorka))
- Added ability to reset ratio [\#1545](https://github.com/torrentpier/torrentpier/pull/1545) ([belomaxorka](https://github.com/belomaxorka))
- Fixed broken "Disable Board" function [\#1529](https://github.com/torrentpier/torrentpier/pull/1529) ([belomaxorka](https://github.com/belomaxorka))
- Fixed seed bonus accrual [\#1518](https://github.com/torrentpier/torrentpier/pull/1518) ([belomaxorka](https://github.com/belomaxorka))
- [BETA] Added emojis support 😄😁 [\#1514](https://github.com/torrentpier/torrentpier/pull/1514) ([belomaxorka](https://github.com/belomaxorka))

View file

@ -424,6 +424,7 @@ CREATE TABLE IF NOT EXISTS `bb_bt_users`
`up_release_yesterday` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
`up_bonus_yesterday` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
`points_yesterday` FLOAT(16, 2) UNSIGNED NOT NULL DEFAULT '0.00',
`ratio_nulled` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`user_id`),
UNIQUE KEY `auth_key` (`auth_key`)
)

View file

@ -89,6 +89,39 @@ switch ($mode) {
$datastore->rm('moderators');
break;
case 'null_ratio':
if (!$bb_cfg['ratio_null_enabled']) {
$this->ajax_die($lang['MODULE_OFF']);
}
if (empty($this->request['confirmed'])) {
$this->prompt_for_confirm($lang['BT_NULL_RATIO_ALERT']);
}
$user_id = (int)$this->request['user_id'];
if (!IS_ADMIN && $user_id != $userdata['user_id']) {
$this->ajax_die($lang['NOT_AUTHORISED']);
}
$btu = get_bt_userdata($user_id);
$ratio_nulled = (bool)$btu['ratio_nulled'];
$user_ratio = get_bt_ratio($btu);
if (($user_ratio === null) && !IS_ADMIN) {
$this->ajax_die($lang['BT_NULL_RATIO_NONE']);
}
if ($ratio_nulled && !IS_ADMIN) {
$this->ajax_die($lang['BT_NULL_RATIO_AGAIN']);
}
if (($user_ratio >= $bb_cfg['ratio_to_null']) && !IS_ADMIN) {
$this->ajax_die(sprintf($lang['BT_NULL_RATIO_NOT_NEEDED'], $bb_cfg['ratio_to_null']));
}
$ratio_nulled_sql = !IS_ADMIN ? ', ratio_nulled = 1' : '';
DB()->query("UPDATE " . BB_BT_USERS . " SET u_up_total = 0, u_down_total = 0, u_up_release = 0, u_up_bonus = 0 $ratio_nulled_sql WHERE user_id = " . $user_id);
CACHE('bb_cache')->rm('btu_' . $user_id);
$this->ajax_die($lang['BT_NULL_RATIO_SUCCESS']);
break;
case 'get_traf_stats':
$user_id = (int)$this->request['user_id'];
$btu = get_bt_userdata($user_id);

View file

@ -138,6 +138,10 @@ $bb_cfg['show_dl_status_in_forum'] = true;
$bb_cfg['show_tor_info_in_dl_list'] = true;
$bb_cfg['allow_dl_list_names_mode'] = true;
// Null ratio
$bb_cfg['ratio_null_enabled'] = true;
$bb_cfg['ratio_to_null'] = $bb_cfg['bt_min_ratio_allow_dl_tor']; // 0.3
// Days to keep torrent registered
$bb_cfg['seeder_last_seen_days_keep'] = 0; // Max time storing for the last seen peer status
$bb_cfg['seeder_never_seen_days_keep'] = 0; // Max time for storing status - Never seen

View file

@ -74,6 +74,12 @@ if (bf($profiledata['user_opt'], 'user_opt', 'dis_sig')) {
$signature = bbcode2html($signature);
}
// 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']));
}
// Ban information
if ($banInfo = getBanInfo((int)$profiledata['user_id'])) {
$template->assign_block_vars('ban', [

View file

@ -3060,3 +3060,11 @@ $lang['EMAILER_SUBJECT'] = [
'USER_WELCOME' => 'Welcome to the site %s',
'USER_WELCOME_INACTIVE' => 'Welcome to the site %s',
];
// Null ratio
$lang['BT_NULL_RATIO'] = 'Reset ratio';
$lang['BT_NULL_RATIO_NONE'] = 'You don\'t have a ratio';
$lang['BT_NULL_RATIO_ALERT'] = "Attention!\n\nAre you sure you want to reset your ratio?";
$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!';

View file

@ -130,7 +130,7 @@ ajax.callback.group_membership = function(data) {
</script>
<!-- ENDIF / IS_AM -->
<!-- IF TRAF_STATS -->
<!-- IF TRAF_STATS || $bb_cfg['ratio_null_enabled'] -->
<script type="text/javascript">
ajax.index_data = function(mode) {
ajax.exec({
@ -140,6 +140,9 @@ ajax.index_data = function(mode) {
});
};
ajax.callback.index_data = function(data) {
if (data.mode === 'null_ratio') {
return;
}
$('#traf-stats-tbl').html(data.html);
$('#bt_user_ratio').html(data.user_ratio);
$('#traf-stats-span').hide();
@ -399,6 +402,9 @@ ajax.callback.index_data = function(data) {
<b id="passkey" class="med bold"><!-- IF AUTH_KEY -->{AUTH_KEY}<!-- ELSE -->{L_NOSELECT}<!-- ENDIF --></b>&nbsp;|&nbsp;<a href="#" onclick="ajax.exec({ action: 'passkey', mode: 'generate', user_id : {PROFILE_USER_ID} }); return false;">{L_BT_GEN_PASSKEY}</a>
</span> ]
<!-- ENDIF -->
<!-- IF PROFILE_USER || IS_ADMIN --><!-- IF $bb_cfg['ratio_null_enabled'] --><!-- IF not NULLED_RATIO or IS_ADMIN -->
[ <a class="med" href="#" onclick="ajax.index_data('null_ratio'); return false;">{L_BT_NULL_RATIO}</a> ]
<!-- ENDIF --><!-- ENDIF --><!-- ENDIF -->
</td>
</tr>

View file

@ -825,7 +825,7 @@ if ($bb_cfg['tracker']['search_by_tor_status']) {
$statuses .= '<tr>';
foreach ($statuses_part as $status_id => $status_styles) {
$checked_status = in_array($status_id, $status) ? 'checked' : '';
$statuses .= '<td><p class="chbox"><input type="checkbox" name="status[]" value="' . $status_id . '"' . $checked_status . '>' . $status_styles . '&nbsp;' . $lang['TOR_STATUS_NAME'][$status_id] . '</p></td>';
$statuses .= '<td><p class="chbox"><label><input type="checkbox" name="status[]" value="' . $status_id . '"' . $checked_status . '>' . $status_styles . '&nbsp;' . $lang['TOR_STATUS_NAME'][$status_id] . '</label></p></td>';
}
$statuses .= '</tr>';
}