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:
Roman Kelesidis 2024-07-22 15:02:54 +07:00 committed by GitHub
commit 4a16ad2c51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 38 additions and 15 deletions

View file

@ -291,6 +291,20 @@ function make_rand_str(int $length = 10): string
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)
{
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
if (!defined('IN_TRACKER')) {
// Init board