official additioin + zero bonus

This commit is contained in:
xiaomlove
2022-09-25 16:33:52 +08:00
parent e94c7340e4
commit 3f559de57f
21 changed files with 206 additions and 55 deletions
@@ -6,6 +6,7 @@ use App\Filament\OptionsTrait;
use App\Filament\Resources\System\SettingResource;
use App\Models\HitAndRun;
use App\Models\Setting;
use App\Models\Tag;
use Filament\Facades\Filament;
use Filament\Forms\ComponentContainer;
use Filament\Forms\Concerns\InteractsWithForms;
+3 -1
View File
@@ -211,7 +211,7 @@ class User extends Authenticatable implements FilamentUser, HasName
'id', 'username', 'email', 'class', 'status', 'added', 'avatar',
'uploaded', 'downloaded', 'seedbonus', 'seedtime', 'leechtime',
'invited_by', 'enabled', 'seed_points', 'last_access', 'invites',
'lang', 'attendance_card', 'privacy', 'noad', 'downloadpos',
'lang', 'attendance_card', 'privacy', 'noad', 'downloadpos', 'donoruntil', 'donor'
];
public static function getDefaultUserAttributes(): array
@@ -535,4 +535,6 @@ class User extends Authenticatable implements FilamentUser, HasName
}
}
+15
View File
@@ -154,5 +154,20 @@ class TagRepository extends BaseRepository
return self::$allTags;
}
public function buildSelect($name, $value): string
{
$list = $this->listAll();
$select = sprintf('<select name="%s"><option value="">%s</option>', $name, nexus_trans('nexus.select_one_please'));
foreach ($list as $item) {
$selected = '';
if ($item->id == $value) {
$selected = ' selected';
}
$select .= sprintf('<option value="%s"%s>%s</option>', $item->id, $selected, $item->name);
}
$select .= '</select>';
return $select;
}
}
+23 -9
View File
@@ -265,22 +265,36 @@ function docleanup($forceAll = 0, $printProgress = false) {
if (mysql_num_rows($res) > 0)
{
$haremAdditionFactor = get_setting('bonus.harem_addition');
$officialAdditionFactor = get_setting('bonus.official_addition');
while ($arr = mysql_fetch_assoc($res)) //loop for different users
{
$userInfo = get_user_row($arr['userid']);
$isDonor = is_donor($userInfo);
$seedBonusResult = calculate_seed_bonus($arr['userid']);
$dividend = 3600 / $autoclean_interval_one;
$all_bonus = $seedBonusResult['all_bonus'] / $dividend;
$seed_points = $seedBonusResult['seed_points'] / $dividend;
$bonusLog = "[CLEANUP_CALCULATE_SEED_BONUS], user: {$arr['userid']}, seedBonusResult: " . nexus_json_encode($seedBonusResult) . ", all_bonus: $all_bonus, seed_points: $seed_points";
if ($haremAdditionFactor > 0) {
$haremAddition = calculate_harem_addition($arr['userid']) * $haremAdditionFactor / $dividend;
$all_bonus += $haremAddition;
$bonusLog .= ", haremAddition: $haremAddition, new all_bonus: $all_bonus";
$bonusLog = "[CLEANUP_CALCULATE_SEED_BONUS], user: {$arr['userid']}, seedBonusResult: " . nexus_json_encode($seedBonusResult);
$all_bonus = $seedBonusResult['seed_bonus'];
$bonusLog .= ", all_bonus: $all_bonus";
if ($isDonor) {
$all_bonus = $all_bonus * $donortimes_bonus;
$bonusLog .= ", isDonor, donortimes_bonus: $donortimes_bonus, all_bonus: $all_bonus";
}
if ($officialAdditionFactor > 0) {
$officialAddition = $seedBonusResult['official_bonus'] * $officialAdditionFactor;
$all_bonus += $officialAddition;
$bonusLog .= ", officialAdditionFactor: $officialAdditionFactor, official_bonus: {$seedBonusResult['official_bonus']}, officialAddition: $officialAddition, all_bonus: $all_bonus";
}
if ($haremAdditionFactor > 0) {
$haremBonus = calculate_harem_addition($arr['userid']);
$haremAddition = $haremBonus * $haremAdditionFactor;
$all_bonus += $haremAddition;
$bonusLog .= ", haremAdditionFactor: $haremAdditionFactor, haremBonus: $haremBonus, haremAddition: $haremAddition, all_bonus: $all_bonus";
}
$dividend = 3600 / $autoclean_interval_one;
$all_bonus = $all_bonus / $dividend;
$seed_points = $seedBonusResult['seed_points'] / $dividend;
$sql = "update users set seed_points = ifnull(seed_points, 0) + $seed_points, seedbonus = seedbonus + $all_bonus where id = {$arr["userid"]}";
do_log("$bonusLog, query: $sql");
sql_query($sql);
}
}
$log = 'calculate seeding bonus';
+2 -1
View File
@@ -23,13 +23,14 @@ if (isset($_SERVER['argv'][1])) {
$force = $_SERVER['argv'][1] ? 1 : 0;
}
$logPrefix = "[CLEANUP_CLI]";
$begin = time();
try {
if ($force) {
$result = docleanup(1, true);
} else {
$result = autoclean(true);
}
$log = "$logPrefix, DONE: $result";
$log = "$logPrefix, DONE: $result, cost time in seconds: " . (time() - $begin);
do_log($log);
printProgress($log);
} catch (\Exception $exception) {
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.27');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-09-20');
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.28');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-09-25');
defined('IN_TRACKER') || define('IN_TRACKER', false);
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
+33 -18
View File
@@ -5828,35 +5828,50 @@ function calculate_seed_bonus($uid, $torrentIdArr = null): array
} else {
$sql = "select torrents.id, torrents.added, torrents.size, torrents.seeders, peers.id as peerID from torrents LEFT JOIN peers ON peers.torrent = torrents.id WHERE peers.userid = $uid AND peers.seeder ='yes' group by peers.torrent, peers.peer_id";
}
$tagGrouped = [];
$torrentResult = \Nexus\Database\NexusDB::select($sql);
do_log("$logPrefix, sql: $sql, count: " . count($torrentResult));
if (!empty($torrentResult)) {
$torrentIdArrReal = array_column($torrentResult, 'id');
$tagResult = \Nexus\Database\NexusDB::select(sprintf("select torrent_id, tag_id from torrent_tags where torrent_id in (%s)", implode(',', $torrentIdArrReal)));
foreach ($tagResult as $tagItem) {
$tagGrouped[$tagItem['torrent_id']][$tagItem['tag_id']] = 1;
}
}
$officialTag = \App\Models\Setting::get('system.official_tag');
$officialAdditionalFactor = \App\Models\Setting::get('bonus.official_addition');
$zeroBonusTag = \App\Models\Setting::get('bonus.zero_bonus_tag');
$zeroBonusFactor = \App\Models\Setting::get('bonus.zero_bonus_factor');
do_log("$logPrefix, sql: $sql, count: " . count($torrentResult) . ", officialTag: $officialTag, officialAdditionalFactor: $officialAdditionalFactor, zeroBonusTag: $zeroBonusTag, zeroBonusFactor: $zeroBonusFactor");
$official_a = 0;
foreach ($torrentResult as $torrent)
{
$weeks_alive = ($timenow - strtotime($torrent['added'])) / $sectoweek;
$gb_size = $torrent['size'] / 1073741824;
$gb_size = $gb_size_raw = $torrent['size'] / 1073741824;
if ($zeroBonusTag && isset($tagGrouped[$torrent['id']][$zeroBonusTag]) && is_numeric($zeroBonusFactor)) {
$gb_size = $gb_size * $zeroBonusFactor;
}
$temp = (1 - exp($valueone * $weeks_alive)) * $gb_size * (1 + $sqrtof2 * exp($valuethree * ($torrent['seeders'] - 1)));
do_log(sprintf(
"$logPrefix, torrent: %s, peer ID: %s, weeks: %s, size: %s GB, increase A: %s",
$torrent['id'], $torrent['peerID'], $weeks_alive, $gb_size, $temp
));
$A += $temp;
$count++;
$torrent_peer_count++;
$officialAIncrease = 0;
if ($officialTag && isset($tagGrouped[$torrent['id']][$officialTag])) {
$officialAIncrease = $temp;
}
$official_a += $officialAIncrease;
do_log(sprintf(
"$logPrefix, torrent: %s, peer ID: %s, weeks: %s, size_raw: %s GB, size: %s GB, increase A: %s, increase official A: %s",
$torrent['id'], $torrent['peerID'], $weeks_alive, $gb_size_raw, $gb_size, $temp, $officialAIncrease
));
}
if ($count > $maxseeding_bonus)
$count = $maxseeding_bonus;
$all_bonus = $seed_bonus = $seed_points = $valuetwo * atan($A / $l_bonus) + ($perseeding_bonus * $count);
$is_donor_info = \Nexus\Database\NexusDB::getOne('users', "id = $uid", "donor, donoruntil");
$is_donor_until = $is_donor_info['donoruntil'];
$is_donor = $is_donor_info['donor'] == 'yes' && ($is_donor_until === null || $is_donor_until == '0000-00-00 00:00:00' || $is_donor_until >= date('Y-m-d H:i:s'));
$is_donor = intval($is_donor);
$log = "$logPrefix, original bonus: $all_bonus, is_donor: $is_donor, donortimes_bonus: $donortimes_bonus";
if ($is_donor && $donortimes_bonus > 0) {
$all_bonus = $all_bonus * $donortimes_bonus;
$log .= ", do multiple, all_bonus: $all_bonus";
}
$result = compact('seed_points','seed_bonus', 'all_bonus', 'A', 'count', 'torrent_peer_count');
do_log("$log, result: " . json_encode($result));
$seed_bonus = $seed_points = $valuetwo * atan($A / $l_bonus) + ($perseeding_bonus * $count);
$official_bonus = $valuetwo * atan($official_a / $l_bonus) + ($perseeding_bonus * $count);
$result = compact('seed_points','seed_bonus', 'A', 'count', 'torrent_peer_count', 'official_a', 'official_bonus');
$result['donor_times'] = $donortimes_bonus;
$result['official_additional_factor'] = $officialAdditionalFactor;
do_log("$logPrefix, result: " . json_encode($result));
return $result;
}
+6
View File
@@ -730,6 +730,7 @@ function get_user_row($id)
} else {
$arr['__is_rainbow'] = 0;
}
$arr['__is_donor'] = is_donor($arr);
return apply_filter("user_row", $arr);
});
@@ -1031,3 +1032,8 @@ function user_can($permission, $fail = false, $uid = 0): bool
}
throw new \App\Exceptions\InsufficientPermissionException();
}
function is_donor(array $userInfo): bool
{
return $userInfo['donor'] == 'yes' && ($userInfo['donoruntil'] === null || $userInfo['donoruntil'] == '0000-00-00 00:00:00' || $userInfo['donoruntil'] >= date('Y-m-d H:i:s'));
}
+7 -2
View File
@@ -91,12 +91,13 @@ $lang_mybonus = array
'text_bonus_gift_note' => "可能你不需要魔力值,为什么不把它送给那些需要的人呢?你可以把自己的魔力值作为礼物送给别人。交易完成后,你的魔力值会减少,礼物接收者的魔力值则会增加。同时,接收者会收到一条关于你的馈赠的短讯。",
'text_error' => "错误",
'text_ratio_too_high' => "分享率已很高",
'text_bonus_formula_one' => "每小时获得的魔力值点数由下面的公式给出<br />&nbsp;&nbsp;&nbsp;&nbsp;<img src=pic/bonusformulaa.png alt=\"A = sigma( ( 1 - 10 ^ ( - Ti / T0 ) ) * Si * ( 1 + sqrt( 2 ) * 10 ^ ( - ( Ni - 1 ) / ( N0 - 1 ) ) )\" title=\"A = sigma( ( 1 - 10 ^ ( - Ti / T0 ) ) * Si * ( 1 + sqrt( 2 ) * 10 ^ ( - ( Ni - 1 ) / ( N0 - 1 ) ) )\"><br />&nbsp;&nbsp;&nbsp;&nbsp;<img src=pic/bonusformulab.png alt=\"B = B0 * 2 / pi * arctan( A / L )\" title=\"B = B0 * 2 / pi * arctan( A / L )\"><br />
'text_bonus_formula_one' => "每小时获得的魔力值点数由下面的公式给出<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<img src=pic/bonusformulaa.svg title=\"A = sigma( ( 1 - 10 ^ ( - Ti / T0 ) ) * Si * ( 1 + sqrt( 2 ) * 10 ^ ( - ( Ni - 1 ) / ( N0 - 1 ) ) ) * Wi\"><br />&nbsp;&nbsp;&nbsp;&nbsp;<img src=pic/bonusformulab.png title=\"B = B0 * 2 / pi * arctan( A / L )\"><br />
式中<ul><li><b>A</b>为中间变量</li><li><b>Ti</b>为第<b>i</b>个种子的生存时间, 即自种子发布起到现在所经过的时间, 单位是周</li><li><b>T0</b>为参数。<b>T0</b> = ",
'text_bonus_formula_two' => "</li><li><b>Si</b>为第<b>i</b>个种子的大小,单位是GB</li><li><b>Ni</b>为第<b>i</b>个种子当前的做种者数</li><li><b>N0</b>为参数。<b>N0</b> = ",
'text_bonus_formula_three' => "</li><li><b>B</b>为1小时中用户获得的做种魔力值点数</li><li><b>B0</b>为参数,代表用户1小时获得魔力值的上限。<b>B0</b> = ",
'text_bonus_formula_four' => "</li><li><b>L</b>为参数。<b>L</b> = ",
'text_bonus_formula_five' => "</li></ul>简言之,为做种人数少、文件体积大的种子做种能获得更多魔力值。",
'text_bonus_formula_wi' => "</li><li><b>Wi</b>为第<b>i</b>个种子的权重系数,默认为 1,零魔种子为 ",
'text_user_with_ratio_above' => "分享率高于",
'text_and_uploaded_amount_above' => "且上传量大于",
'text_cannot_exchange_uploading' => "GB的用户不能换取更多的上传量。",
@@ -137,13 +138,17 @@ $lang_mybonus = array
'text_success_buy_attendance_card' => '成功购买了一张补签卡。',
'text_harem_addition_get' => '当前后宫加成每小时获得 %s 魔力',
'reward_type' => '奖励类型',
'addition' => '加成',
'factor' => '系数',
'got_bonus' => '获得魔力',
'total' => '合计',
'reward_type_basic' => '基本奖励',
'reward_type_harem_addition' => '后宫加成',
'bonus_base' => '基础魔力',
'lock_text' => '系统限制 %s 秒内只能点击交换按钮一次!',
'text_get_by_seeding_official' => '官种每小时将额外得到如下的魔力值',
'official_calculate_method' => '官种奖励计算公式同上,只是仅针对官种进行计算',
'official_tag_bonus_additional_factor' => '最终奖励为计算所得官种奖励乘以官种系数,当前官种系数为: ',
'reward_type_official_addition' => '官种加成',
);
?>
+9
View File
@@ -218,6 +218,7 @@ $lang_settings = array
'text_bonus_formula_four' => "。默认为'4'",
'text_bonus_formula_five' => "<b>Si</b>为第<b>i</b>个种子的大小,单位是GB",
'text_bonus_formula_six' => "<b>Ni</b>为第<b>i</b>个种子当前的做种者数</li><li><b>N0</b>为参数。<b>N0</b> = ",
'text_bonus_formula_zero_bonus_factor' => "<b>Wi</b>为第<b>i</b>个种子权重系数。默认为 1,零魔种子为 ",
'text_bonus_formula_seven' => "。默认为'7'",
'text_bonus_formula_eight' => "<b>B</b>为1小时中用户获得的做种魔力值点数",
'text_bonus_formula_nine' => "<b>B0</b>为参数,代表用户1小时获得魔力值的上限。<b>B0</b> = ",
@@ -779,6 +780,14 @@ $lang_settings = array
'text_ten_gb_download_credit_note' => " 个魔力值,如果他选择交换10.0 GB下载量。默认'1000'。",
'row_hundred_gb_download_credit' => "100.0 GB 下载量",
'text_hundred_gb_download_credit_note' => " 个魔力值,如果他选择交换100.0 GB下载量。默认'8000'。",
'row_official_addition' => '官种加成',
'text_user_would_get_by_official' => '用户将获得官种正常魔力值的',
'text_addition_addition_note' => '倍作为奖励(系数,如填入 0.01,官种获得 100 魔力则奖励用户 100 * 0.01 = 1',
'zero_bonus_factor_default' => '。默认为:0.2',
'row_official_tag' => '官种标签',
'text_official_tag_note' => '。带此标签的种子为官种',
'row_zero_bonus_tag' => '零魔标签',
'text_zero_bonus_tag_note' => '。带此标签的种子为零魔种子',
);
?>
+8 -2
View File
@@ -91,12 +91,13 @@ $lang_mybonus = array
'text_bonus_gift_note' => "可能你不需要魔力值,為什麼不把它送給那些需要的人呢?你可以把自己的魔力值作為禮物送給別人。交易完成後,你的魔力值會減少,禮物接收者的魔力值則會增加。同時,接收者會收到一條關於你的饋贈的短訊。",
'text_error' => "錯誤",
'text_ratio_too_high' => "分享率已很高",
'text_bonus_formula_one' => "每小時獲得的魔力值點數由下面的公式給出<br />&nbsp;&nbsp;&nbsp;&nbsp;<img src=pic/bonusformulaa.png alt=\"A = sigma( ( 1 - 10 ^ ( - Ti / T0 ) ) * Si * ( 1 + sqrt( 2 ) * 10 ^ ( - ( Ni - 1 ) / ( N0 - 1 ) ) )\" title=\"A = sigma( ( 1 - 10 ^ ( - Ti / T0 ) ) * Si * ( 1 + sqrt( 2 ) * 10 ^ ( - ( Ni - 1 ) / ( N0 - 1 ) ) )\"><br />&nbsp;&nbsp;&nbsp;&nbsp;<img src=pic/bonusformulab.png alt=\"B = B0 * 2 / pi * arctan( A / L )\" title=\"B = B0 * 2 / pi * arctan( A / L )\"><br />
'text_bonus_formula_one' => "每小時獲得的魔力值點數由下面的公式給出<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<img src=pic/bonusformulaa.svg title=\"A = sigma( ( 1 - 10 ^ ( - Ti / T0 ) ) * Si * ( 1 + sqrt( 2 ) * 10 ^ ( - ( Ni - 1 ) / ( N0 - 1 ) ) ) * Wi\"><br />&nbsp;&nbsp;&nbsp;&nbsp;<img src=pic/bonusformulab.png title=\"B = B0 * 2 / pi * arctan( A / L )\"><br />
式中<ul><li><b>A</b>為中間變量</li><li><b>Ti</b>為第<b>i</b>個種子的生存時間, 即自種子發布起到現在所經過的時間, 單位是周</li><li><b>T0</b>為參數。<b>T0</b> = ",
'text_bonus_formula_two' => "</li><li><b>Si</b>為第<b>i</b>個種子的大小,單位是GB</li><li><b>Ni</b>為第<b>i</b>個種子當前的做種者數</li><li><b>N0</b>為參數。<b>N0</b> = ",
'text_bonus_formula_three' => "</li><li><b>B</b>為1小時中用戶獲得的做種魔力值點數</li><li><b>B0</b>為參數,代表用戶1小時獲得魔力值的上限。<b>B0</b> = ",
'text_bonus_formula_four' => "</li><li><b>L</b>為參數。<b>L</b> = ",
'text_bonus_formula_five' => "</li></ul>簡言之,為做種人數少、文件體積大的種子做種能獲得更多魔力值。",
'text_bonus_formula_wi' => "</li><li><b>Wi</b>為第<b>i</b>個種子的權重系數,默認為 1,零魔種子為 ",
'text_user_with_ratio_above' => "分享率高于",
'text_and_uploaded_amount_above' => "且上傳量大于",
'text_cannot_exchange_uploading' => "GB的用戶不能換取更多的上傳量。",
@@ -137,13 +138,18 @@ $lang_mybonus = array
'text_success_buy_attendance_card' => '成功購買了一張補簽卡。',
'text_harem_addition_get' => '當前後宮加成每小時獲得 %s 魔力',
'reward_type' => '獎勵類型',
'addition' => '加成',
'factor' => '系數',
'got_bonus' => '獲得魔力',
'total' => '合計',
'reward_type_basic' => '基本獎勵',
'reward_type_harem_addition' => '後宮加成',
'bonus_base' => '基礎魔力',
'lock_text' => '系統限製 %s 秒內只能點擊交換按鈕一次!',
'text_get_by_seeding_official' => '官種每小時將額外得到如下的魔力值',
'official_calculate_method' => '官種獎勵計算公式同上,只是僅針對官種進行計算',
'official_tag_bonus_additional_factor' => '最終獎勵為計算所得官種獎勵乘以官種系數,當前官種系數為: ',
'reward_type_official_addition' => '官種加成',
);
?>
+9
View File
@@ -218,6 +218,7 @@ $lang_settings = array
'text_bonus_formula_four' => "。預設為'4'",
'text_bonus_formula_five' => "<b>Si</b>為第<b>i</b>個種子的大小,單位是GB",
'text_bonus_formula_six' => "<b>Ni</b>為第<b>i</b>個種子目前的做種者數</li><li><b>N0</b>為參數。<b>N0</b> = ",
'text_bonus_formula_zero_bonus_factor' => "<b>Wi</b>為第<b>i</b>個種子權重系數。默認為 1,零魔種子為 ",
'text_bonus_formula_seven' => "。預設為'7'",
'text_bonus_formula_eight' => "<b>B</b>為1小時中用戶獲得的做種魔力值點數",
'text_bonus_formula_nine' => "<b>B0</b>為參數,代表用戶1小時獲得魔力值的上限。<b>B0</b> = ",
@@ -779,6 +780,14 @@ $lang_settings = array
'text_ten_gb_download_credit_note' => " 個魔力值,如果他選擇交換10.0 GB下載量。默認'1000'。",
'row_hundred_gb_download_credit' => "100.0 GB 下載量",
'text_hundred_gb_download_credit_note' => " 個魔力值,如果他選擇交換100.0 GB下載量。默認'8000'。",
'row_official_addition' => '官種加成',
'text_user_would_get_by_official' => '用戶將獲得官種正常魔力值的',
'text_addition_addition_note' => '倍作為獎勵(系數,如填入 0.01,官種獲得 100 魔力則獎勵用戶 100 * 0.01 = 1',
'zero_bonus_factor_default' => '。默認為:0.2',
'row_official_tag' => '官種標簽',
'text_official_tag_note' => '。帶此標簽的種子為官種',
'row_zero_bonus_tag' => '零魔標簽',
'text_zero_bonus_tag_note' => '。帶此標簽的種子為零魔種子',
);
?>
+7 -2
View File
@@ -91,12 +91,13 @@ $lang_mybonus = array
'text_bonus_gift_note' => "Well perhaps you don't need the upload credit, but you know somebody that could use the Karma boost! You are now able to give your Karma credits as a gift! The points are then removed from your Bonus Bank and added to the account of a user of your choice! And they receive a PM with all the info as well as who it came from...",
'text_error' => "Error",
'text_ratio_too_high' => "Your ratio is high",
'text_bonus_formula_one' => "The number of karma points gained per hour is given by the following formula<br />&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"pic/bonusformulaa.png\" alt=\"A = sigma( ( 1 - 10 ^ ( - Ti / T0 ) ) * Si * ( 1 + sqrt( 2 ) * 10 ^ ( - ( Ni - 1 ) / ( N0 - 1 ) ) )\" title=\"A = sigma( ( 1 - 10 ^ ( - Ti / T0 ) ) * Si * ( 1 + sqrt( 2 ) * 10 ^ ( - ( Ni - 1 ) / ( N0 - 1 ) ) )\" /><br />&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"pic/bonusformulab.png\" alt=\"B = B0 * 2 / pi * arctan( A / L )\" title=\"B = B0 * 2 / pi * arctan( A / L )\" /><br />
'text_bonus_formula_one' => "The number of karma points gained per hour is given by the following formula<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"pic/bonusformulaa.svg\" title=\"A = sigma( ( 1 - 10 ^ ( - Ti / T0 ) ) * Si * ( 1 + sqrt( 2 ) * 10 ^ ( - ( Ni - 1 ) / ( N0 - 1 ) ) ) * Wi\" /><br />&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"pic/bonusformulab.png\" title=\"B = B0 * 2 / pi * arctan( A / L )\" /><br />
where<ul><li><b>A</b> is an intermediate variable</li><li><b>Ti</b> is the <b>i</b>th torrent's Time Alive (TA), i.e. time elapsed since the torrent was uploaded, in weeks</li><li><b>T0</b> is a parameter. <b>T0</b> = ",
'text_bonus_formula_two' => "</li><li><b>Si</b> is the <b>i</b>th torrent's size, in GB</li><li><b>Ni</b> is the number of current seeders of the <b>i</b>th torrent</li><li><b>N0</b> is a parameter. <b>N0</b> = ",
'text_bonus_formula_three' => "</li><li><b>B</b> is the number of karma points gained by seeding in an hour</li><li><b>B0</b> is a parameter, which stands for the maximum bonus points per hour a user can get by seeding. <b>B0</b> = ",
'text_bonus_formula_four' => "</li><li><b>L</b> is a parameter. <b>L</b> = ",
'text_bonus_formula_five' => "</li></ul>In a nutshell, you can get more bonus by seeding less-seeded and larger torrents.",
'text_bonus_formula_wi' => "</li><li><b>Wi</b> is the <b>i</b>th torrent's weight, default is 1, zero torrent is ",
'text_user_with_ratio_above' => "User with ratio above ",
'text_and_uploaded_amount_above' => " and uploaded amount above ",
'text_cannot_exchange_uploading' => " GB cannot exchange for more uploading credit.",
@@ -137,13 +138,17 @@ where<ul><li><b>A</b> is an intermediate variable</li><li><b>Ti</b> is the <b>i<
'text_success_buy_attendance_card' => 'Success buy 1 attendance card.',
'text_harem_addition_get' => 'Current harem addition gains %s bonus per hour',
'reward_type' => 'Reward type',
'addition' => 'Addition',
'factor' => 'Factor',
'got_bonus' => 'Got bonus',
'total' => 'Total',
'reward_type_basic' => 'Basic reward',
'reward_type_harem_addition' => 'Harem addition',
'bonus_base' => 'Base bonus',
'lock_text' => 'The system limits you to one click on the exchange button within %s seconds!',
'text_get_by_seeding_official' => 'The official torrents will receive the following additional bonus value per hour',
'official_calculate_method' => 'The formula for calculating the official reward is the same as above, but only for the official type',
'official_tag_bonus_additional_factor' => 'The final reward is the calculated official type reward multiplied by the official type factor, the current official type factor is: ',
'reward_type_official_addition' => 'Official addition',
);
?>
+9
View File
@@ -218,6 +218,7 @@ $lang_settings = array
'text_bonus_formula_four' => ". Default '4'",
'text_bonus_formula_five' => "<b>Si</b> is the <b>i</b>th torrent's size, in GB",
'text_bonus_formula_six' => "<b>Ni</b> is the number of current seeders of the <b>i</b>th torrent</li><li><b>N0</b> is a parameter. <b>N0</b> = ",
'text_bonus_formula_zero_bonus_factor' => "<b>Wi</b> is the <b>i</b>th torrent's weight. Default is 1, zero torrent is ",
'text_bonus_formula_seven' => ". Default '7'",
'text_bonus_formula_eight' => "<b>B</b> is the number of karma points gained by seeding in an hour",
'text_bonus_formula_nine' => "<b>B0</b> is a parameter, which standards for the maximum bonus points per hour a user can get by seeding. <b>B0</b> = ",
@@ -779,6 +780,14 @@ $lang_settings = array
'text_ten_gb_download_credit_note' => " bonus points to exchange for 10.0 GB downloading credit. Default '1000'.",
'row_hundred_gb_download_credit' => "100.0 GB downloading credit",
'text_hundred_gb_download_credit_note' => " bonus points to exchange for 100.0 GB downloading credit. Default '8000'.",
'row_official_addition' => 'Official addition',
'text_user_would_get_by_official' => 'The user will receive the normal bonus value of the official torrent',
'text_addition_addition_note' => 'times as reward (factor, e.g. fill in 0.01, if official torrens gets 100 bonus then reward user 100 * 0.01 = 1)',
'zero_bonus_factor_default' => '. Default is: 0.2',
'row_official_tag' => 'Official tag',
'text_official_tag_note' => '. Torrents with this tag are official torrents',
'row_zero_bonus_tag' => 'Zero bonus tag',
'text_zero_bonus_tag_note' => '. Torrents with this tag are zero bonus torrents',
);
?>
+2
View File
@@ -236,6 +236,8 @@ return array (
'hundredgbupload' => 10000,
'tengbdownload' => 1000,
'hundredgbdownload' => 8000,
'official_addition' => '0.5',
'zero_bonus_factor' => '0.2',
),
'account' =>
array (
+46 -16
View File
@@ -420,7 +420,7 @@ print("<h1>".$lang_mybonus['text_get_by_seeding']."</h1>");
print("<ul>");
if ($perseeding_bonus > 0)
print("<li>".$perseeding_bonus.$lang_mybonus['text_point'].add_s($perseeding_bonus).$lang_mybonus['text_for_seeding_torrent'].$maxseeding_bonus.$lang_mybonus['text_torrent'].add_s($maxseeding_bonus).")</li>");
print("<li>".$lang_mybonus['text_bonus_formula_one'].$tzero_bonus.$lang_mybonus['text_bonus_formula_two'].$nzero_bonus.$lang_mybonus['text_bonus_formula_three'].$bzero_bonus.$lang_mybonus['text_bonus_formula_four'].$l_bonus.$lang_mybonus['text_bonus_formula_five']."</li>");
print("<li>".$lang_mybonus['text_bonus_formula_one'].$tzero_bonus.$lang_mybonus['text_bonus_formula_two'].$nzero_bonus.$lang_mybonus['text_bonus_formula_wi'].get_setting('bonus.zero_bonus_factor').$lang_mybonus['text_bonus_formula_three'].$bzero_bonus.$lang_mybonus['text_bonus_formula_four'].$l_bonus.$lang_mybonus['text_bonus_formula_five']."</li>");
if ($donortimes_bonus)
print("<li>".$lang_mybonus['text_donors_always_get'].$donortimes_bonus.$lang_mybonus['text_times_of_bonus']."</li>");
@@ -450,11 +450,10 @@ print("</ul>");
// $all_bonus = $valuetwo * atan($A / $l_bonus) + ($perseeding_bonus * $count);
$seedBonusResult = calculate_seed_bonus($CURUSER['id']);
$all_bonus = $seedBonusResult['all_bonus'];
$A = $seedBonusResult['A'];
$percent = $all_bonus * 100 / ($bzero_bonus + $perseeding_bonus * $maxseeding_bonus);
print("<div align=\"center\">".$lang_mybonus['text_you_are_currently_getting'].round($all_bonus,3).$lang_mybonus['text_point'].add_s($all_bonus).$lang_mybonus['text_per_hour']." (A = ".round($A,1).")</div><table align=\"center\" border=\"0\" width=\"400\"><tr><td class=\"loadbarbg\" style='border: none; padding: 0px;'>");
$percent = $seedBonusResult['seed_bonus'] * 100 / ($bzero_bonus + $perseeding_bonus * $maxseeding_bonus);
print("<div align=\"center\">".$lang_mybonus['text_you_are_currently_getting'].round($seedBonusResult['seed_bonus'],3).$lang_mybonus['text_point'].add_s($seedBonusResult['seed_bonus']).$lang_mybonus['text_per_hour']." (A = ".round($A,1).")</div><table align=\"center\" border=\"0\" width=\"400\"><tr><td class=\"loadbarbg\" style='border: none; padding: 0px;'>");
if ($percent <= 30) $loadpic = "loadbarred";
elseif ($percent <= 60) $loadpic = "loadbaryellow";
@@ -462,26 +461,57 @@ $A = $seedBonusResult['A'];
$width = $percent * 4;
print("<img class=\"".$loadpic."\" src=\"pic/trans.gif\" style=\"width: ".$width."px;\" alt=\"".$percent."%\" /></td></tr></table>");
$factor = get_setting('bonus.harem_addition');
$addition = calculate_harem_addition($CURUSER['id']);
$totalBonus = number_format($all_bonus + $addition * $factor, 3);
$officialAdditionalFactor = get_setting('bonus.official_addition');
if ($officialAdditionalFactor > 0) {
print("<h1>".$lang_mybonus['text_get_by_seeding_official']."</h1>");
print("<ul>");
print("<li>".$lang_mybonus['official_calculate_method']."</li>");
print("<li>".$lang_mybonus['official_tag_bonus_additional_factor'].$officialAdditionalFactor."</li>");
print("</ul>");
}
$haremFactor = get_setting('bonus.harem_addition');
$haremAddition = calculate_harem_addition($CURUSER['id']);
$isDonor = is_donor($CURUSER);
$baseBonusFactor = 1;
if ($isDonor) {
$baseBonusFactor = $donortimes_bonus;
}
$totalBonus = number_format($seedBonusResult['seed_bonus'] * $baseBonusFactor + $haremAddition * $haremFactor + $seedBonusResult['official_bonus'] * $officialAdditionalFactor, 3);
$rowSpan = 1;
if ($haremFactor > 0) {
$rowSpan++;
}
if ($officialAdditionalFactor > 0) {
$rowSpan++;
}
$summaryTable = '<table cellspacing="4" cellpadding="4" style="width: 50%"><tbody>';
$summaryTable .= '<tr style="font-weight: bold"><td>'.$lang_mybonus['reward_type'].'</td><td>'.$lang_mybonus['bonus_base'].'</td><td>'.$lang_mybonus['addition'].'</td><td>'.$lang_mybonus['got_bonus'].'</td><td>'.$lang_mybonus['total'].'</td></tr>';
$summaryTable .= '<tr style="font-weight: bold"><td>'.$lang_mybonus['reward_type'].'</td><td>'.$lang_mybonus['bonus_base'].'</td><td>'.$lang_mybonus['factor'].'</td><td>'.$lang_mybonus['got_bonus'].'</td><td>'.$lang_mybonus['total'].'</td></tr>';
$summaryTable .= sprintf(
'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td rowspan="2">%s</td></tr>',
'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td rowspan="%s">%s</td></tr>',
$lang_mybonus['reward_type_basic'],
round($all_bonus,3),
'-',
round($all_bonus,3),
number_format($seedBonusResult['seed_bonus'],3),
$baseBonusFactor,
number_format($seedBonusResult['seed_bonus'],3),
$rowSpan,
$totalBonus
);
if ($factor > 0) {
if ($haremFactor > 0) {
$summaryTable .= sprintf(
'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>',
$lang_mybonus['reward_type_harem_addition'],
number_format($addition, 3),
number_format($factor * 100, 2) . '%',
number_format($addition * $factor, 3)
number_format($haremAddition, 3),
$haremFactor,
number_format($haremAddition * $haremFactor, 3)
);
}
if ($officialAdditionalFactor > 0) {
$summaryTable .= sprintf(
'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>',
$lang_mybonus['reward_type_official_addition'],
number_format($seedBonusResult['official_bonus'], 3),
$officialAdditionalFactor,
number_format($seedBonusResult['official_bonus'] * $officialAdditionalFactor, 3)
);
}
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 13 KiB

+17 -2
View File
@@ -97,7 +97,7 @@ elseif ($action == 'savesettings_bonus') // save bonus
'addcomment','pollvote','offervote', 'funboxvote','saythanks','receivethanks','funboxreward','onegbupload','fivegbupload',
'tengbupload', 'ratiolimit','dlamountlimit','oneinvite','customtitle','vipstatus','bonusgift', 'basictax', 'taxpercentage',
'prolinkpoint', 'prolinktime', 'attendance_initial', 'attendance_step', 'attendance_max', 'cancel_hr', 'attendance_card',
'harem_addition', 'hundredgbupload', 'tengbdownload', 'hundredgbdownload'
'harem_addition', 'hundredgbupload', 'tengbdownload', 'hundredgbdownload', 'official_addition', 'official_tag', 'zero_bonus_tag', 'zero_bonus_factor',
);
GetVar($validConfig);
$BONUS = [];
@@ -562,7 +562,18 @@ elseif ($action == 'bonussettings'){
print("<tr><td colspan=2 align=center><b>".$lang_settings['text_bonus_by_seeding']."</b></td></tr>");
tr($lang_settings['row_donor_gets_double'], $lang_settings['text_donor_gets']."<input type='text' style=\"width: 50px\" name=donortimes value='".(isset($BONUS["donortimes"]) ? $BONUS["donortimes"] : 2 )."'>".$lang_settings['text_times_as_many'],1);
tr($lang_settings['row_basic_seeding_bonus'], $lang_settings['text_user_would_get']."<input type='text' style=\"width: 50px\" name=perseeding value='".(isset($BONUS["perseeding"]) ? $BONUS["perseeding"] : 1 )."'>".$lang_settings['text_bonus_points']."<input type='text' style=\"width: 50px\" name=maxseeding value='".(isset($BONUS["maxseeding"]) ? $BONUS["maxseeding"] : 7 )."'>".$lang_settings['text_torrents_default'], 1);
tr($lang_settings['row_seeding_formula'], $lang_settings['text_bonus_formula_one']."<br />&nbsp;&nbsp;&nbsp;&nbsp;<img src=pic/bonusformulaa.png alt=\"A = sigma( ( 1 - 10 ^ ( - Ti / T0 ) ) * Si * ( 1 + sqrt( 2 ) * 10 ^ ( - ( Ni - 1 ) / ( N0 - 1 ) ) )\" title=\"A = sigma( ( 1 - 10 ^ ( - Ti / T0 ) ) * Si * ( 1 + sqrt( 2 ) * 10 ^ ( - ( Ni - 1 ) / ( N0 - 1 ) ) )\"><br />&nbsp;&nbsp;&nbsp;&nbsp;<img src=pic/bonusformulab.png alt=\"B = B0 * 2 / pi * arctan( A / L )\" title=\"B = B0 * 2 / pi * arctan( A / L )\"><br />".$lang_settings['text_where']."<ul><li>".$lang_settings['text_bonus_formula_two']."</li><li>".$lang_settings['text_bonus_formula_three']."<input type='text' style=\"width: 50px\" name=tzero value='".(isset($BONUS["tzero"]) ? $BONUS["tzero"] : 4 )."'>".$lang_settings['text_bonus_formula_four']."</li><li>".$lang_settings['text_bonus_formula_five']."</li><li>".$lang_settings['text_bonus_formula_six']."<input type='text' style=\"width: 50px\" name=nzero value='".(isset($BONUS["nzero"]) ? $BONUS["nzero"] : 7 )."'>".$lang_settings['text_bonus_formula_seven']."</li><li>".$lang_settings['text_bonus_formula_eight']."</li><li>".$lang_settings['text_bonus_formula_nine']."<input type='text' style=\"width: 50px\" name=bzero value='".(isset($BONUS["bzero"]) ? $BONUS["bzero"] : 100 )."'>".$lang_settings['text_bonus_formula_ten']."</li><li>".$lang_settings['text_bonus_formula_eleven']."<input type='text' style=\"width: 50px\" name=l value='".(isset($BONUS["l"]) ? $BONUS["l"] : 300 )."'>".$lang_settings['text_bonus_formula_twelve']."</li></ul>\n", 1);
$formulaLiArr = [];
$formulaLiArr[] = "<li>".$lang_settings['text_bonus_formula_two']."</li>";
$formulaLiArr[] = "<li>".$lang_settings['text_bonus_formula_three']."<input type='text' style=\"width: 50px\" name=tzero value='".(isset($BONUS["tzero"]) ? $BONUS["tzero"] : 4 )."'>".$lang_settings['text_bonus_formula_four']."</li>";
$formulaLiArr[] = "<li>".$lang_settings['text_bonus_formula_five']."</li>";
$formulaLiArr[] = "<li>".$lang_settings['text_bonus_formula_six']."<input type='text' style=\"width: 50px\" name=nzero value='".(isset($BONUS["nzero"]) ? $BONUS["nzero"] : 7 )."'>".$lang_settings['text_bonus_formula_seven']."</li>";
$formulaLiArr[] = "<li>".$lang_settings['text_bonus_formula_zero_bonus_factor']."<input type='text' style=\"width: 50px\" name=zero_bonus_factor value='".(isset($BONUS["zero_bonus_factor"]) ? $BONUS["zero_bonus_factor"] : 0.2 )."'>".$lang_settings['zero_bonus_factor_default']."</li>";
$formulaLiArr[] = "<li>".$lang_settings['text_bonus_formula_eight']."</li>";
$formulaLiArr[] = "<li>".$lang_settings['text_bonus_formula_nine']."<input type='text' style=\"width: 50px\" name=bzero value='".(isset($BONUS["bzero"]) ? $BONUS["bzero"] : 100 )."'>".$lang_settings['text_bonus_formula_ten']."</li>";
$formulaLiArr[] = "<li>".$lang_settings['text_bonus_formula_eleven']."<input type='text' style=\"width: 50px\" name=l value='".(isset($BONUS["l"]) ? $BONUS["l"] : 300 )."'>".$lang_settings['text_bonus_formula_twelve']."</li>";
tr($lang_settings['row_seeding_formula'], $lang_settings['text_bonus_formula_one']."<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<img src=pic/bonusformulaa.svg title=\"A = sigma( ( 1 - 10 ^ ( - Ti / T0 ) ) * Si * ( 1 + sqrt( 2 ) * 10 ^ ( - ( Ni - 1 ) / ( N0 - 1 ) ) ) * Wi\"><br />&nbsp;&nbsp;&nbsp;&nbsp;<img src=pic/bonusformulab.png alt=\"B = B0 * 2 / pi * arctan( A / L )\" title=\"B = B0 * 2 / pi * arctan( A / L )\"><br />".$lang_settings['text_where']."<ul>".implode("", $formulaLiArr)."</ul>", 1);
print("<tr><td colspan=2 align=center><b>".$lang_settings['text_misc_ways_get_bonus']."</b></td></tr>");
tr($lang_settings['row_uploading_torrent'],$lang_settings['text_user_would_get']."<input type='text' style=\"width: 50px\" name=uploadtorrent value='".(isset($BONUS["uploadtorrent"]) ? $BONUS["uploadtorrent"] : 15 )."'>".$lang_settings['text_uploading_torrent_note'], 1);
tr($lang_settings['row_uploading_subtitle'],$lang_settings['text_user_would_get']."<input type='text' style=\"width: 50px\" name=uploadsubtitle value='".(isset($BONUS["uploadsubtitle"]) ? $BONUS["uploadsubtitle"] : 5 )."'>".$lang_settings['text_uploading_subtitle_note'], 1);
@@ -576,7 +587,11 @@ elseif ($action == 'bonussettings'){
tr($lang_settings['row_funbox_stuff_reward'],$lang_settings['text_user_would_get']."<input type='text' style=\"width: 50px\" name=funboxreward value='".(isset($BONUS["funboxreward"]) ? $BONUS["funboxreward"] : 5 )."'>".$lang_settings['text_funbox_stuff_reward_note'], 1);
tr($lang_settings['row_promotion_link_click'],$lang_settings['text_user_would_get']."<input type='text' style=\"width: 50px\" name=prolinkpoint value='".(isset($BONUS["prolinkpoint"]) ? $BONUS["prolinkpoint"] : 0 )."'>".$lang_settings['text_promotion_link_note_one']."<input type='text' style=\"width: 50px\" name=prolinktime value='".(isset($BONUS["prolinktime"]) ? $BONUS["prolinktime"] : 600 )."'>".$lang_settings['text_promotion_link_note_two'], 1);
tr($lang_settings['row_harem_addition'],$lang_settings['text_user_would_get_by_harem']."<input type='text' style=\"width: 50px\" name=harem_addition value='".(isset($BONUS["harem_addition"]) ? $BONUS["harem_addition"] : 0 )."'>".$lang_settings['text_harem_addition_note'], 1);
tr($lang_settings['row_official_addition'],$lang_settings['text_user_would_get_by_official']."<input type='text' style=\"width: 50px\" name=official_addition value='".(isset($BONUS["official_addition"]) ? $BONUS["official_addition"] : 0.5 )."'>".$lang_settings['text_addition_addition_note'], 1);
$tagRep = new \App\Repositories\TagRepository();
tr($lang_settings['row_official_tag'], $tagRep->buildSelect('official_tag', $BONUS["official_tag"] ?? '') . $lang_settings['text_official_tag_note'], 1);
tr($lang_settings['row_zero_bonus_tag'], $tagRep->buildSelect('zero_bonus_tag', $BONUS["zero_bonus_tag"] ?? '') . $lang_settings['text_zero_bonus_tag_note'], 1);
print("<tr><td colspan=2 align=center><b>".$lang_settings['text_things_cost_bonus']."</b></td></tr>");
tr($lang_settings['row_one_gb_credit'],$lang_settings['text_it_costs_user']."<input type='text' style=\"width: 50px\" name=onegbupload value='".(isset($BONUS["onegbupload"]) ? $BONUS["onegbupload"] : 300 )."'>".$lang_settings['text_one_gb_credit_note'], 1);
+2
View File
@@ -2,4 +2,6 @@
return [
'invalid_argument' => 'Invalid argument',
'require_argument' => ':argument cannot be empty',
'select_one_please' => 'Please select one',
];
+1
View File
@@ -3,4 +3,5 @@
return [
'invalid_argument' => '参数错误',
'require_argument' => ':argument 不能为空',
'select_one_please' => '请选择一项',
];
+2
View File
@@ -2,4 +2,6 @@
return [
'invalid_argument' => '參數錯誤',
'require_argument' => ':argument 不能為空',
'select_one_please' => '請選擇一項',
];