diff --git a/app/Filament/Resources/System/SettingResource/Pages/EditSetting.php b/app/Filament/Resources/System/SettingResource/Pages/EditSetting.php index 92bda9d3..95b8f914 100644 --- a/app/Filament/Resources/System/SettingResource/Pages/EditSetting.php +++ b/app/Filament/Resources/System/SettingResource/Pages/EditSetting.php @@ -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; diff --git a/app/Models/User.php b/app/Models/User.php index 4fa1ccd1..e6f21f62 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -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 } + + } diff --git a/app/Repositories/TagRepository.php b/app/Repositories/TagRepository.php index c871a526..2353101d 100644 --- a/app/Repositories/TagRepository.php +++ b/app/Repositories/TagRepository.php @@ -154,5 +154,20 @@ class TagRepository extends BaseRepository return self::$allTags; } + public function buildSelect($name, $value): string + { + $list = $this->listAll(); + $select = sprintf(''; + return $select; + } + } diff --git a/include/cleanup.php b/include/cleanup.php index 9cba944e..a9410767 100644 --- a/include/cleanup.php +++ b/include/cleanup.php @@ -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'; diff --git a/include/cleanup_cli.php b/include/cleanup_cli.php index 1118c783..e1b4152a 100644 --- a/include/cleanup_cli.php +++ b/include/cleanup_cli.php @@ -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) { diff --git a/include/constants.php b/include/constants.php index 1ed4c7b5..35c9e939 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ $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; } diff --git a/include/globalfunctions.php b/include/globalfunctions.php index 242256f7..09b50ebf 100644 --- a/include/globalfunctions.php +++ b/include/globalfunctions.php @@ -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')); +} diff --git a/lang/chs/lang_mybonus.php b/lang/chs/lang_mybonus.php index 28b45e47..f6b04e0f 100644 --- a/lang/chs/lang_mybonus.php +++ b/lang/chs/lang_mybonus.php @@ -91,12 +91,13 @@ $lang_mybonus = array 'text_bonus_gift_note' => "可能你不需要魔力值,为什么不把它送给那些需要的人呢?你可以把自己的魔力值作为礼物送给别人。交易完成后,你的魔力值会减少,礼物接收者的魔力值则会增加。同时,接收者会收到一条关于你的馈赠的短讯。", 'text_error' => "错误", 'text_ratio_too_high' => "分享率已很高", - 'text_bonus_formula_one' => "每小时获得的魔力值点数由下面的公式给出
    \"A
    \"B
+ 'text_bonus_formula_one' => "每小时获得的魔力值点数由下面的公式给出

    
    
式中简言之,为做种人数少、文件体积大的种子做种能获得更多魔力值。", + 'text_bonus_formula_wi' => "
  • Wi为第i个种子的权重系数,默认为 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' => '官种加成', ); ?> diff --git a/lang/chs/lang_settings.php b/lang/chs/lang_settings.php index da6f8585..8ba8e403 100644 --- a/lang/chs/lang_settings.php +++ b/lang/chs/lang_settings.php @@ -218,6 +218,7 @@ $lang_settings = array 'text_bonus_formula_four' => "。默认为'4'", 'text_bonus_formula_five' => "Si为第i个种子的大小,单位是GB", 'text_bonus_formula_six' => "Ni为第i个种子当前的做种者数
  • N0为参数。N0 = ", + 'text_bonus_formula_zero_bonus_factor' => "Wi为第i个种子权重系数。默认为 1,零魔种子为 ", 'text_bonus_formula_seven' => "。默认为'7'", 'text_bonus_formula_eight' => "B为1小时中用户获得的做种魔力值点数", 'text_bonus_formula_nine' => "B0为参数,代表用户1小时获得魔力值的上限。B0 = ", @@ -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' => '。带此标签的种子为零魔种子', ); ?> diff --git a/lang/cht/lang_mybonus.php b/lang/cht/lang_mybonus.php index fcce5ccf..e77b7aad 100644 --- a/lang/cht/lang_mybonus.php +++ b/lang/cht/lang_mybonus.php @@ -91,12 +91,13 @@ $lang_mybonus = array 'text_bonus_gift_note' => "可能你不需要魔力值,為什麼不把它送給那些需要的人呢?你可以把自己的魔力值作為禮物送給別人。交易完成後,你的魔力值會減少,禮物接收者的魔力值則會增加。同時,接收者會收到一條關於你的饋贈的短訊。", 'text_error' => "錯誤", 'text_ratio_too_high' => "分享率已很高", - 'text_bonus_formula_one' => "每小時獲得的魔力值點數由下面的公式給出
        \"A
        \"B
    + 'text_bonus_formula_one' => "每小時獲得的魔力值點數由下面的公式給出

        
        
    式中簡言之,為做種人數少、文件體積大的種子做種能獲得更多魔力值。", + 'text_bonus_formula_wi' => "
  • Wi為第i個種子的權重系數,默認為 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' => '官種加成', + ); ?> diff --git a/lang/cht/lang_settings.php b/lang/cht/lang_settings.php index af79ecf1..b498d177 100644 --- a/lang/cht/lang_settings.php +++ b/lang/cht/lang_settings.php @@ -218,6 +218,7 @@ $lang_settings = array 'text_bonus_formula_four' => "。預設為'4'", 'text_bonus_formula_five' => "Si為第i個種子的大小,單位是GB", 'text_bonus_formula_six' => "Ni為第i個種子目前的做種者數
  • N0為參數。N0 = ", + 'text_bonus_formula_zero_bonus_factor' => "Wi為第i個種子權重系數。默認為 1,零魔種子為 ", 'text_bonus_formula_seven' => "。預設為'7'", 'text_bonus_formula_eight' => "B為1小時中用戶獲得的做種魔力值點數", 'text_bonus_formula_nine' => "B0為參數,代表用戶1小時獲得魔力值的上限。B0 = ", @@ -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' => '。帶此標簽的種子為零魔種子', ); ?> diff --git a/lang/en/lang_mybonus.php b/lang/en/lang_mybonus.php index b0b09edd..995ae057 100644 --- a/lang/en/lang_mybonus.php +++ b/lang/en/lang_mybonus.php @@ -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
        \"A
        \"B
    + 'text_bonus_formula_one' => "The number of karma points gained per hour is given by the following formula

        
        
    whereIn a nutshell, you can get more bonus by seeding less-seeded and larger torrents.", + 'text_bonus_formula_wi' => "
  • Wi is the ith 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