diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php
index aebb3808..819ad92a 100644
--- a/app/Console/Commands/Test.php
+++ b/app/Console/Commands/Test.php
@@ -20,6 +20,7 @@ use App\Models\Tag;
use App\Models\Torrent;
use App\Models\TorrentOperationLog;
use App\Models\User;
+use App\Models\UserBanLog;
use App\Repositories\AgentAllowRepository;
use App\Repositories\AttendanceRepository;
use App\Repositories\ExamRepository;
@@ -89,10 +90,7 @@ class Test extends Command
*/
public function handle()
{
- $rep = new \NexusPlugin\HitAndRun\HitAndRunRepository();
- $rep->initSectionHitAndRunSetting(SearchBox::SECTION_BROWSE . "_");
- $rep->initSectionHitAndRunSetting(SearchBox::SECTION_SPECIAL . "_");
- clear_setting_cache();
+ UserBanLog::clearUserBanLogDuplicate();
}
diff --git a/app/Models/UserBanLog.php b/app/Models/UserBanLog.php
index c6201fbc..081ed06b 100644
--- a/app/Models/UserBanLog.php
+++ b/app/Models/UserBanLog.php
@@ -7,4 +7,23 @@ class UserBanLog extends NexusModel
protected $table = 'user_ban_logs';
protected $fillable = ['uid', 'username', 'operator', 'reason'];
+
+ public static function clearUserBanLogDuplicate()
+ {
+ $lists = UserBanLog::query()
+ ->selectRaw("min(id) as id, uid, count(*) as counts")
+ ->groupBy('uid')
+ ->having("counts", ">", 1)
+ ->get();
+ if ($lists->isEmpty()) {
+ do_log("sql: " . last_query() . ", no data to delete");
+ return;
+ }
+ $idArr = $lists->pluck("id")->toArray();
+ $uidArr = $lists->pluck('uid')->toArray();
+ $result = UserBanLog::query()->whereIn("uid", $uidArr)->whereNotIn("id", $idArr)->delete();
+ do_log("sql: " . last_query() . ", result: $result");
+ }
+
+
}
diff --git a/include/cleanup.php b/include/cleanup.php
index a9410767..6e58b676 100644
--- a/include/cleanup.php
+++ b/include/cleanup.php
@@ -1019,6 +1019,15 @@ function docleanup($forceAll = 0, $printProgress = false) {
if ($printProgress) {
printProgress($log);
}
+
+ //remove duplicate user ban logs
+ $log = "clear user ban log duplicate";
+ \App\Models\UserBanLog::clearUserBanLogDuplicate();
+ do_log($log);
+ if ($printProgress) {
+ printProgress($log);
+ }
+
$log = 'Full cleanup is done';
do_log($log);
if ($printProgress) {
diff --git a/include/functions.php b/include/functions.php
index 4f356865..844359f9 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -5969,4 +5969,95 @@ JS;
\Nexus\Nexus::js($js, 'footer', false);
return $input;
}
+
+function build_bonus_table(array $user, array $bonusResult = [], array $options = [])
+{
+ if (empty($bonusResult)) {
+ $bonusResult = calculate_seed_bonus($user['id']);
+ }
+ $officialTag = get_setting('bonus.official_tag');
+ $officialAdditionalFactor = get_setting('bonus.official_addition', 0);
+ $haremFactor = get_setting('bonus.harem_addition');
+ $haremAddition = calculate_harem_addition($user['id']);
+ $isDonor = is_donor($user);
+ $donortimes_bonus = get_setting('bonus.donortimes');
+ $baseBonusFactor = 1;
+ if ($isDonor) {
+ $baseBonusFactor = $donortimes_bonus;
+ }
+ $baseBonus = $bonusResult['seed_bonus'] * $baseBonusFactor;
+ $totalBonus = number_format( $baseBonus + $haremAddition * $haremFactor + $bonusResult['official_bonus'] * $officialAdditionalFactor, 3);
+
+ $rowSpan = 1;
+ $hasHaremAddition = $hasOfficialAddition = false;
+ if ($haremFactor > 0) {
+ $rowSpan++;
+ $hasHaremAddition = true;
+ }
+ if ($officialAdditionalFactor > 0 && $officialTag) {
+ $rowSpan++;
+ $hasOfficialAddition = true;
+ }
+
+ $table = sprintf('
', $options['table_style'] ?? '');
+ $table .= '';
+ $table .= sprintf('| %s | ', nexus_trans('bonus.table_thead.reward_type'));
+ $table .= sprintf('%s | ', nexus_trans('bonus.table_thead.count'));
+ $table .= sprintf('%s | ', nexus_trans('bonus.table_thead.size'));
+ $table .= sprintf('%s | ', nexus_trans('bonus.table_thead.a_value'));
+ $table .= sprintf('%s | ', nexus_trans('bonus.table_thead.bonus_base'));
+ $table .= sprintf('%s | ', nexus_trans('bonus.table_thead.factor'));
+ $table .= sprintf('%s | ', nexus_trans('bonus.table_thead.got_bonus'));
+ $table .= sprintf('%s | ', nexus_trans('bonus.table_thead.total'));
+ $table .= '
';
+
+ $table .= sprintf(
+ '| %s | %s | %s | %s | %s | %s | %s | %s |
',
+ nexus_trans('bonus.reward_types.basic'),
+ $bonusResult['torrent_peer_count'],
+ mksize($bonusResult['size']),
+ number_format($bonusResult['A'], 3),
+ number_format($bonusResult['seed_bonus'],3),
+ $baseBonusFactor,
+ number_format($baseBonus,3),
+ $rowSpan,
+ $totalBonus
+ );
+
+ if ($hasOfficialAddition) {
+ $table .= sprintf(
+ '| %s | %s | %s | %s | %s | %s | %s |
',
+ nexus_trans('bonus.reward_types.official_addition'),
+ $bonusResult['official_torrent_peer_count'],
+ mksize($bonusResult['official_size']),
+ number_format($bonusResult['official_a'], 3),
+ number_format($bonusResult['official_bonus'], 3),
+ $officialAdditionalFactor,
+ number_format($bonusResult['official_bonus'] * $officialAdditionalFactor, 3)
+ );
+ }
+
+ if ($hasHaremAddition) {
+ $table .= sprintf(
+ '| %s | %s | %s | %s | %s | %s | %s |
',
+ nexus_trans('bonus.reward_types.harem_addition'),
+ '--',
+ '--',
+ '--',
+ number_format($haremAddition, 3),
+ $haremFactor,
+ number_format($haremAddition * $haremFactor, 3)
+ );
+ }
+ $table .= '
';
+
+ return [
+ 'table' => $table,
+ 'has_harem_addition' => $hasHaremAddition,
+ 'harem_addition_factor' => $haremFactor,
+ 'has_official_addition' => $hasOfficialAddition,
+ 'official_addition_factor' => $officialAdditionalFactor,
+ ];
+
+}
?>
diff --git a/lang/chs/lang_mybonus.php b/lang/chs/lang_mybonus.php
index 98999c84..21653080 100644
--- a/lang/chs/lang_mybonus.php
+++ b/lang/chs/lang_mybonus.php
@@ -146,7 +146,7 @@ $lang_mybonus = array
'bonus_base' => '基础魔力',
'lock_text' => '系统限制 %s 秒内只能点击交换按钮一次!',
'text_get_by_seeding_official' => '官种加成每小时将额外得到如下的魔力值',
- 'official_calculate_method' => '官种奖励计算公式同上,只是仅针对官种进行计算',
+ 'official_calculate_method' => '官种奖励计算公式同上,只是仅针对官种进行计算,不考虑低保',
'official_tag_bonus_additional_factor' => '最终奖励为计算所得官种奖励乘以官种系数,当前官种系数为: ',
'reward_type_official_addition' => '官种加成',
'text_get_by_harem' => '后宫加成每小时将额外得到如下的魔力值',
diff --git a/lang/chs/lang_userdetails.php b/lang/chs/lang_userdetails.php
index d27d81cd..4546c3a2 100644
--- a/lang/chs/lang_userdetails.php
+++ b/lang/chs/lang_userdetails.php
@@ -155,5 +155,6 @@ $lang_userdetails = array
'row_user_props' => '道具',
'meta_key_change_username_username' => '新用户名',
'consume' => '使用',
+ 'text_bonus_table' => '时魔',
);
?>
diff --git a/lang/cht/lang_mybonus.php b/lang/cht/lang_mybonus.php
index 6fb176ba..70c265bf 100644
--- a/lang/cht/lang_mybonus.php
+++ b/lang/cht/lang_mybonus.php
@@ -146,7 +146,7 @@ $lang_mybonus = array
'bonus_base' => '基礎魔力',
'lock_text' => '系統限製 %s 秒內只能點擊交換按鈕一次!',
'text_get_by_seeding_official' => '官種加成每小時將額外得到如下的魔力值',
- 'official_calculate_method' => '官種獎勵計算公式同上,只是僅針對官種進行計算',
+ 'official_calculate_method' => '官種獎勵計算公式同上,只是僅針對官種進行計算,不考慮低保',
'official_tag_bonus_additional_factor' => '最終獎勵為計算所得官種獎勵乘以官種系數,當前官種系數為: ',
'reward_type_official_addition' => '官種加成',
'text_get_by_harem' => '後宮加成每小時將額外得到如下的魔力值',
diff --git a/lang/cht/lang_userdetails.php b/lang/cht/lang_userdetails.php
index f9dc757d..4a3c0a98 100644
--- a/lang/cht/lang_userdetails.php
+++ b/lang/cht/lang_userdetails.php
@@ -155,5 +155,6 @@ $lang_userdetails = array
'row_user_props' => '道具',
'meta_key_change_username_username' => '新用戶名',
'consume' => '使用',
+ 'text_bonus_table' => '時魔',
);
?>
diff --git a/lang/en/lang_mybonus.php b/lang/en/lang_mybonus.php
index 83b6717e..70179d9f 100644
--- a/lang/en/lang_mybonus.php
+++ b/lang/en/lang_mybonus.php
@@ -146,7 +146,7 @@ where- A is an intermediate variable
- Ti is the i<
'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_calculate_method' => 'The formula for calculating the official reward is the same as above, but only for the official type, No consideration for low income',
'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',
'text_get_by_harem' => 'The harem addition will give the following additional bonus value per hour',
diff --git a/lang/en/lang_userdetails.php b/lang/en/lang_userdetails.php
index 44546aae..6be9dc95 100644
--- a/lang/en/lang_userdetails.php
+++ b/lang/en/lang_userdetails.php
@@ -155,5 +155,6 @@ $lang_userdetails = array
'row_user_props' => 'Props',
'meta_key_change_username_username' => 'New username',
'consume' => 'Use',
+ 'text_bonus_table' => 'Bonus per hour',
);
?>
diff --git a/nexus/Install/Update.php b/nexus/Install/Update.php
index 54ff934a..f9d4d312 100644
--- a/nexus/Install/Update.php
+++ b/nexus/Install/Update.php
@@ -15,6 +15,7 @@ use App\Models\Tag;
use App\Models\Torrent;
use App\Models\TorrentTag;
use App\Models\User;
+use App\Models\UserBanLog;
use App\Repositories\AttendanceRepository;
use App\Repositories\BonusRepository;
use App\Repositories\ExamRepository;
@@ -391,6 +392,8 @@ class Update extends Install
$command .= " --exclude=$exclude";
}
$this->executeCommand($command);
+ //remove original file
+ unlink($filename);
break;
}
}
@@ -444,5 +447,4 @@ class Update extends Install
}
-
}
diff --git a/public/mybonus.php b/public/mybonus.php
index 2aa8e53c..3a51e839 100644
--- a/public/mybonus.php
+++ b/public/mybonus.php
@@ -428,18 +428,8 @@ print("
");
$seedBonusResult = calculate_seed_bonus($CURUSER['id']);
$A = $seedBonusResult['A'];
-$officialAdditionalFactor = get_setting('bonus.official_addition', 0);
-$officialTag = get_setting('bonus.official_tag');
-$haremFactor = get_setting('bonus.harem_addition');
-$haremAddition = calculate_harem_addition($CURUSER['id']);
-$isDonor = is_donor($CURUSER);
-$baseBonusFactor = 1;
-if ($isDonor) {
- $baseBonusFactor = $donortimes_bonus;
-}
-$baseBonus = $seedBonusResult['seed_bonus'] * $baseBonusFactor;
-$totalBonus = number_format( $baseBonus + $haremAddition * $haremFactor + $seedBonusResult['official_bonus'] * $officialAdditionalFactor, 3);
+$bonusTableResult = build_bonus_table($CURUSER, $seedBonusResult, ['table_style' => 'width: 50%']);
$percent = $seedBonusResult['seed_bonus'] * 100 / ($bzero_bonus + $perseeding_bonus * $maxseeding_bonus);
print("".$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).")
");
@@ -450,70 +440,24 @@ else $loadpic = "loadbargreen";
$width = $percent * 4;
print(" |
");
-$rowSpan = 1;
-$hasHaremAddition = $hasOfficialAddition = false;
-if ($haremFactor > 0) {
- $rowSpan++;
- $hasHaremAddition = true;
-}
-if ($officialAdditionalFactor > 0 && $officialTag) {
- $rowSpan++;
- $hasOfficialAddition = true;
-}
-$summaryTable = '';
-$summaryTable .= '| '.$lang_mybonus['reward_type'].' | '.$lang_mybonus['col_count'].' | '.$lang_mybonus['col_size'].' | '.$lang_mybonus['col_a'].' | '.$lang_mybonus['bonus_base'].' | '.$lang_mybonus['factor'].' | '.$lang_mybonus['got_bonus'].' | '.$lang_mybonus['total'].' |
';
-$summaryTable .= sprintf(
- '| %s | %s | %s | %s | %s | %s | %s | %s |
',
- $lang_mybonus['reward_type_basic'],
- $seedBonusResult['torrent_peer_count'],
- mksize($seedBonusResult['size']),
- number_format($seedBonusResult['A'], 3),
- number_format($seedBonusResult['seed_bonus'],3),
- $baseBonusFactor,
- number_format($baseBonus,3),
- $rowSpan,
- $totalBonus
-);
-
-if ($hasOfficialAddition) {
+if ($bonusTableResult['has_official_addition']) {
print("".$lang_mybonus['text_get_by_seeding_official']."
");
print("");
print("- ".$lang_mybonus['official_calculate_method']."
");
- print("- ".$lang_mybonus['official_tag_bonus_additional_factor'].$officialAdditionalFactor."
");
+ print("- ".$lang_mybonus['official_tag_bonus_additional_factor'].$bonusTableResult['official_addition_factor']."
");
print("
");
- $summaryTable .= sprintf(
- '| %s | %s | %s | %s | %s | %s | %s |
',
- $lang_mybonus['reward_type_official_addition'],
- $seedBonusResult['official_torrent_peer_count'],
- mksize($seedBonusResult['official_size']),
- number_format($seedBonusResult['official_a'], 3),
- number_format($seedBonusResult['official_bonus'], 3),
- $officialAdditionalFactor,
- number_format($seedBonusResult['official_bonus'] * $officialAdditionalFactor, 3)
- );
}
-if ($hasHaremAddition) {
+if ($bonusTableResult['has_harem_addition']) {
print("".$lang_mybonus['text_get_by_harem']."
");
print("");
print("- ".sprintf($lang_mybonus['harem_additional_desc'], $CURUSER['id'])."
");
- print("- ".$lang_mybonus['harem_additional_factor'].$haremFactor."
");
+ print("- ".$lang_mybonus['harem_additional_factor'].$bonusTableResult['harem_addition_factor']."
");
print("
");
- $summaryTable .= sprintf(
- '| %s | %s | %s | %s | %s | %s | %s |
',
- $lang_mybonus['reward_type_harem_addition'],
- '--',
- '--',
- '--',
- number_format($haremAddition, 3),
- $haremFactor,
- number_format($haremAddition * $haremFactor, 3)
- );
}
-$summaryTable .= '
';
print("".$lang_mybonus['text_bonus_summary']."
");
-print ''.$summaryTable.'
';
+print ''.$bonusTableResult['table'].'
';
print("".$lang_mybonus['text_other_things_get_bonus']."
");
print("");
diff --git a/public/userdetails.php b/public/userdetails.php
index fb0cd08d..f5900081 100644
--- a/public/userdetails.php
+++ b/public/userdetails.php
@@ -394,6 +394,10 @@ if ($user["id"] == $CURUSER["id"] || user_can('viewhistory')) {
tr_small($lang_functions['text_seed_points'], number_format($user['seed_points'], 1), 1);
}
+if (user_can('prfmanage') && $user["class"] < get_user_class()) {
+ $bonusTable = build_bonus_table($user);
+ tr_small($lang_userdetails['text_bonus_table'], $bonusTable['table'], 1);
+}
if ($user["ip"] && (user_can('torrenthistory') || $user["id"] == $CURUSER["id"])){
diff --git a/resources/lang/en/bonus.php b/resources/lang/en/bonus.php
index 323dbe07..3b772e0d 100644
--- a/resources/lang/en/bonus.php
+++ b/resources/lang/en/bonus.php
@@ -3,4 +3,19 @@
return [
'comment_buy_medal' => 'Spend :bonus bonus buy :medal_name',
'comment_buy_attendance_card' => 'Spend :bonus bonus buy one attend card',
+ 'table_thead' => [
+ 'reward_type' => 'Reward type',
+ 'count' => 'Count',
+ 'size' => 'Size',
+ 'a_value' => 'A Value',
+ 'bonus_base' => 'Basic bonus',
+ 'factor' => 'Factor',
+ 'got_bonus' => 'Got bonus',
+ 'total' => 'Total',
+ ],
+ 'reward_types' => [
+ 'basic' => 'Basic reward',
+ 'harem_addition' => 'Harem addition',
+ 'official_addition' => 'Official addition',
+ ],
];
diff --git a/resources/lang/zh_CN/bonus.php b/resources/lang/zh_CN/bonus.php
index 26000772..aa7ead52 100644
--- a/resources/lang/zh_CN/bonus.php
+++ b/resources/lang/zh_CN/bonus.php
@@ -3,4 +3,19 @@
return [
'comment_buy_medal' => '花费 :bonus 魔力购买了 :medal_name',
'comment_buy_attendance_card' => '花费 :bonus 魔力购买了 1 张补签卡',
+ 'table_thead' => [
+ 'reward_type' => '奖励类型',
+ 'count' => '数量',
+ 'size' => '体积',
+ 'a_value' => 'A 值',
+ 'bonus_base' => '基础魔力',
+ 'factor' => '系数',
+ 'got_bonus' => '获得魔力',
+ 'total' => '合计',
+ ],
+ 'reward_types' => [
+ 'basic' => '基本奖励',
+ 'harem_addition' => '后宫加成',
+ 'official_addition' => '官种加成',
+ ],
];
diff --git a/resources/lang/zh_TW/bonus.php b/resources/lang/zh_TW/bonus.php
index 0e57807c..a5cae0da 100644
--- a/resources/lang/zh_TW/bonus.php
+++ b/resources/lang/zh_TW/bonus.php
@@ -3,4 +3,19 @@
return [
'comment_buy_medal' => '花費 :bonus 魔力購買了 :medal_name',
'comment_buy_attendance_card' => '花費 :bonus 魔力購買了 1 張補簽卡',
+ 'table_thead' => [
+ 'reward_type' => '獎勵類型',
+ 'count' => '數量',
+ 'size' => '體積',
+ 'a_value' => 'A 值',
+ 'bonus_base' => '基礎魔力',
+ 'factor' => '系數',
+ 'got_bonus' => '獲得魔力',
+ 'total' => '合計',
+ ],
+ 'reward_types' => [
+ 'basic' => '基本獎勵',
+ 'harem_addition' => '後宮加成',
+ 'official_addition' => '官種加成',
+ ],
];