mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 05:43:55 -07:00
Some improvements for ratio functionality (#1552)
* Some improvements for ratio functionality * Update usercp_viewprofile.tpl * Update functions.php * Update CHANGELOG.md
This commit is contained in:
parent
f4652a4123
commit
4a16ad2c51
6 changed files with 38 additions and 15 deletions
|
@ -21,6 +21,7 @@
|
||||||
- Bring back forum description in `viewforum.php` [\#1540](https://github.com/torrentpier/torrentpier/pull/1540) ([belomaxorka](https://github.com/belomaxorka))
|
- Bring back forum description in `viewforum.php` [\#1540](https://github.com/torrentpier/torrentpier/pull/1540) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
- Some security improvements 🔑 [\#1503](https://github.com/torrentpier/torrentpier/pull/1503), [\#1505](https://github.com/torrentpier/torrentpier/pull/1505) ([belomaxorka](https://github.com/belomaxorka))
|
- Some security improvements 🔑 [\#1503](https://github.com/torrentpier/torrentpier/pull/1503), [\#1505](https://github.com/torrentpier/torrentpier/pull/1505) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
- Some improvements for integrity checker [\#1501](https://github.com/torrentpier/torrentpier/pull/1501) ([belomaxorka](https://github.com/belomaxorka))
|
- Some improvements for integrity checker [\#1501](https://github.com/torrentpier/torrentpier/pull/1501) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
|
- Some improvements for ratio functionality [\#1552](https://github.com/torrentpier/torrentpier/pull/1552) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
- Hide in topic: Added country hiding [\#1535](https://github.com/torrentpier/torrentpier/pull/1535) ([belomaxorka](https://github.com/belomaxorka))
|
- Hide in topic: Added country hiding [\#1535](https://github.com/torrentpier/torrentpier/pull/1535) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
- Hide vote button in topic for guests [\#1507](https://github.com/torrentpier/torrentpier/pull/1507) ([belomaxorka](https://github.com/belomaxorka))
|
- Hide vote button in topic for guests [\#1507](https://github.com/torrentpier/torrentpier/pull/1507) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
- Word censor code optimization [\#1537](https://github.com/torrentpier/torrentpier/pull/1537) ([belomaxorka](https://github.com/belomaxorka))
|
- Word censor code optimization [\#1537](https://github.com/torrentpier/torrentpier/pull/1537) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
|
|
|
@ -225,8 +225,11 @@ if ($lp_info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ratio limits
|
// Ratio limits
|
||||||
if ((TR_RATING_LIMITS || $bb_cfg['tracker']['limit_concurrent_ips']) && !$stopped) {
|
if ((RATIO_ENABLED || $bb_cfg['tracker']['limit_concurrent_ips']) && !$stopped) {
|
||||||
$user_ratio = ($row['u_down_total'] && $row['u_down_total'] > MIN_DL_FOR_RATIO) ? ($row['u_up_total'] + $row['u_up_release'] + $row['u_up_bonus']) / $row['u_down_total'] : 1;
|
$user_ratio = get_bt_ratio($row);
|
||||||
|
if ($user_ratio === null) {
|
||||||
|
$user_ratio = 1;
|
||||||
|
}
|
||||||
$rating_msg = '';
|
$rating_msg = '';
|
||||||
|
|
||||||
if (!$seeder) {
|
if (!$seeder) {
|
||||||
|
|
19
common.php
19
common.php
|
@ -291,6 +291,20 @@ function make_rand_str(int $length = 10): string
|
||||||
return $randomString;
|
return $randomString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates user ratio
|
||||||
|
*
|
||||||
|
* @param array $btu
|
||||||
|
* @return float|null
|
||||||
|
*/
|
||||||
|
function get_bt_ratio(array $btu): ?float
|
||||||
|
{
|
||||||
|
return
|
||||||
|
(!empty($btu['u_down_total']) && $btu['u_down_total'] > MIN_DL_FOR_RATIO)
|
||||||
|
? round((($btu['u_up_total'] + $btu['u_up_release'] + $btu['u_up_bonus']) / $btu['u_down_total']), 2)
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
function array_deep(&$var, $fn, $one_dimensional = false, $array_only = false, $timeout = false)
|
function array_deep(&$var, $fn, $one_dimensional = false, $array_only = false, $timeout = false)
|
||||||
{
|
{
|
||||||
if ($timeout) {
|
if ($timeout) {
|
||||||
|
@ -345,6 +359,11 @@ function sys(string $param)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some shared defines
|
||||||
|
*/
|
||||||
|
define('RATIO_ENABLED', TR_RATING_LIMITS && MIN_DL_FOR_RATIO > 0);
|
||||||
|
|
||||||
// Initialization
|
// Initialization
|
||||||
if (!defined('IN_TRACKER')) {
|
if (!defined('IN_TRACKER')) {
|
||||||
// Init board
|
// Init board
|
||||||
|
|
|
@ -90,7 +90,7 @@ switch ($mode) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'null_ratio':
|
case 'null_ratio':
|
||||||
if (!$bb_cfg['ratio_null_enabled']) {
|
if (!$bb_cfg['ratio_null_enabled'] || !RATIO_ENABLED) {
|
||||||
$this->ajax_die($lang['MODULE_OFF']);
|
$this->ajax_die($lang['MODULE_OFF']);
|
||||||
}
|
}
|
||||||
if (empty($this->request['confirmed'])) {
|
if (empty($this->request['confirmed'])) {
|
||||||
|
@ -123,6 +123,10 @@ switch ($mode) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'get_traf_stats':
|
case 'get_traf_stats':
|
||||||
|
if (!RATIO_ENABLED) {
|
||||||
|
$this->ajax_die($lang['MODULE_OFF']);
|
||||||
|
}
|
||||||
|
|
||||||
$user_id = (int)$this->request['user_id'];
|
$user_id = (int)$this->request['user_id'];
|
||||||
$btu = get_bt_userdata($user_id);
|
$btu = get_bt_userdata($user_id);
|
||||||
$profiledata = get_userdata($user_id);
|
$profiledata = get_userdata($user_id);
|
||||||
|
|
|
@ -844,14 +844,6 @@ function get_bt_userdata($user_id)
|
||||||
return $btu;
|
return $btu;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_bt_ratio($btu): ?float
|
|
||||||
{
|
|
||||||
return
|
|
||||||
(!empty($btu['u_down_total']) && $btu['u_down_total'] > MIN_DL_FOR_RATIO)
|
|
||||||
? round((($btu['u_up_total'] + $btu['u_up_release'] + $btu['u_up_bonus']) / $btu['u_down_total']), 2)
|
|
||||||
: null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_bt_userdata($user_id): void
|
function show_bt_userdata($user_id): void
|
||||||
{
|
{
|
||||||
global $template;
|
global $template;
|
||||||
|
@ -868,8 +860,8 @@ function show_bt_userdata($user_id): void
|
||||||
'DOWN_TOTAL' => humn_size($btu['u_down_total']),
|
'DOWN_TOTAL' => humn_size($btu['u_down_total']),
|
||||||
'DOWN_TOTAL_BYTES' => $btu['u_down_total'],
|
'DOWN_TOTAL_BYTES' => $btu['u_down_total'],
|
||||||
'USER_RATIO' => get_bt_ratio($btu),
|
'USER_RATIO' => get_bt_ratio($btu),
|
||||||
'MIN_DL_FOR_RATIO' => humn_size(MIN_DL_FOR_RATIO),
|
'MIN_DL_FOR_RATIO' => humn_size((int)MIN_DL_FOR_RATIO),
|
||||||
'MIN_DL_BYTES' => MIN_DL_FOR_RATIO,
|
'MIN_DL_BYTES' => (int)MIN_DL_FOR_RATIO,
|
||||||
'AUTH_KEY' => $btu['auth_key'],
|
'AUTH_KEY' => $btu['auth_key'],
|
||||||
|
|
||||||
'TD_DL' => humn_size($btu['down_today']),
|
'TD_DL' => humn_size($btu['down_today']),
|
||||||
|
|
|
@ -130,6 +130,7 @@ ajax.callback.group_membership = function(data) {
|
||||||
</script>
|
</script>
|
||||||
<!-- ENDIF / IS_AM -->
|
<!-- ENDIF / IS_AM -->
|
||||||
|
|
||||||
|
<!-- IF #RATIO_ENABLED -->
|
||||||
<!-- IF TRAF_STATS || $bb_cfg['ratio_null_enabled'] -->
|
<!-- IF TRAF_STATS || $bb_cfg['ratio_null_enabled'] -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
ajax.index_data = function(mode) {
|
ajax.index_data = function(mode) {
|
||||||
|
@ -151,6 +152,7 @@ ajax.callback.index_data = function(data) {
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<!-- ENDIF -->
|
<!-- ENDIF -->
|
||||||
|
<!-- ENDIF -->
|
||||||
|
|
||||||
<!-- IF SHOW_PASSKEY -->
|
<!-- IF SHOW_PASSKEY -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
@ -384,6 +386,7 @@ ajax.callback.index_data = function(data) {
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<!-- IF #RATIO_ENABLED -->
|
||||||
<tr id="bt_user_ratio" <!-- IF TRAF_STATS -->style="display: none;"<!-- ENDIF -->>
|
<tr id="bt_user_ratio" <!-- IF TRAF_STATS -->style="display: none;"<!-- ENDIF -->>
|
||||||
<th>{L_USER_RATIO}:</th>
|
<th>{L_USER_RATIO}:</th>
|
||||||
<td>
|
<td>
|
||||||
|
@ -415,6 +418,7 @@ ajax.callback.index_data = function(data) {
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- ENDIF -->
|
<!-- ENDIF -->
|
||||||
|
<!-- ENDIF -->
|
||||||
|
|
||||||
<!-- IF LOCATION -->
|
<!-- IF LOCATION -->
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue