mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-22 02:47:27 +08:00
userdetails page show bonus table
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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('<table cellpadding="5" style="%s">', $options['table_style'] ?? '');
|
||||
$table .= '<tr>';
|
||||
$table .= sprintf('<td class="colhead">%s</td>', nexus_trans('bonus.table_thead.reward_type'));
|
||||
$table .= sprintf('<td class="colhead">%s</td>', nexus_trans('bonus.table_thead.count'));
|
||||
$table .= sprintf('<td class="colhead">%s</td>', nexus_trans('bonus.table_thead.size'));
|
||||
$table .= sprintf('<td class="colhead">%s</td>', nexus_trans('bonus.table_thead.a_value'));
|
||||
$table .= sprintf('<td class="colhead">%s</td>', nexus_trans('bonus.table_thead.bonus_base'));
|
||||
$table .= sprintf('<td class="colhead">%s</td>', nexus_trans('bonus.table_thead.factor'));
|
||||
$table .= sprintf('<td class="colhead">%s</td>', nexus_trans('bonus.table_thead.got_bonus'));
|
||||
$table .= sprintf('<td class="colhead">%s</td>', nexus_trans('bonus.table_thead.total'));
|
||||
$table .= '</tr>';
|
||||
|
||||
$table .= sprintf(
|
||||
'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td rowspan="%s">%s</td></tr>',
|
||||
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(
|
||||
'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>',
|
||||
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(
|
||||
'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>',
|
||||
nexus_trans('bonus.reward_types.harem_addition'),
|
||||
'--',
|
||||
'--',
|
||||
'--',
|
||||
number_format($haremAddition, 3),
|
||||
$haremFactor,
|
||||
number_format($haremAddition * $haremFactor, 3)
|
||||
);
|
||||
}
|
||||
$table .= '</table>';
|
||||
|
||||
return [
|
||||
'table' => $table,
|
||||
'has_harem_addition' => $hasHaremAddition,
|
||||
'harem_addition_factor' => $haremFactor,
|
||||
'has_official_addition' => $hasOfficialAddition,
|
||||
'official_addition_factor' => $officialAdditionalFactor,
|
||||
];
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -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' => '后宫加成每小时将额外得到如下的魔力值',
|
||||
|
||||
@@ -155,5 +155,6 @@ $lang_userdetails = array
|
||||
'row_user_props' => '道具',
|
||||
'meta_key_change_username_username' => '新用户名',
|
||||
'consume' => '使用',
|
||||
'text_bonus_table' => '时魔',
|
||||
);
|
||||
?>
|
||||
|
||||
@@ -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' => '後宮加成每小時將額外得到如下的魔力值',
|
||||
|
||||
@@ -155,5 +155,6 @@ $lang_userdetails = array
|
||||
'row_user_props' => '道具',
|
||||
'meta_key_change_username_username' => '新用戶名',
|
||||
'consume' => '使用',
|
||||
'text_bonus_table' => '時魔',
|
||||
);
|
||||
?>
|
||||
|
||||
@@ -146,7 +146,7 @@ where<ul><li><b>A</b> is an intermediate variable</li><li><b>Ti</b> is the <b>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',
|
||||
|
||||
@@ -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',
|
||||
);
|
||||
?>
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+6
-62
@@ -428,18 +428,8 @@ print("</ul>");
|
||||
|
||||
$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("<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;'>");
|
||||
@@ -450,70 +440,24 @@ else $loadpic = "loadbargreen";
|
||||
$width = $percent * 4;
|
||||
print("<img class=\"".$loadpic."\" src=\"pic/trans.gif\" style=\"width: ".$width."px;\" alt=\"".$percent."%\" /></td></tr></table>");
|
||||
|
||||
$rowSpan = 1;
|
||||
$hasHaremAddition = $hasOfficialAddition = false;
|
||||
if ($haremFactor > 0) {
|
||||
$rowSpan++;
|
||||
$hasHaremAddition = true;
|
||||
}
|
||||
if ($officialAdditionalFactor > 0 && $officialTag) {
|
||||
$rowSpan++;
|
||||
$hasOfficialAddition = true;
|
||||
}
|
||||
$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['col_count'].'</td><td>'.$lang_mybonus['col_size'].'</td><td>'.$lang_mybonus['col_a'].'</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>%s</td><td>%s</td><td>%s</td><td rowspan="%s">%s</td></tr>',
|
||||
$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("<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("<li>".$lang_mybonus['official_tag_bonus_additional_factor'].$bonusTableResult['official_addition_factor']."</li>");
|
||||
print("</ul>");
|
||||
$summaryTable .= sprintf(
|
||||
'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>',
|
||||
$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("<h1>".$lang_mybonus['text_get_by_harem']."</h1>");
|
||||
print("<ul>");
|
||||
print("<li>".sprintf($lang_mybonus['harem_additional_desc'], $CURUSER['id'])."</li>");
|
||||
print("<li>".$lang_mybonus['harem_additional_factor'].$haremFactor."</li>");
|
||||
print("<li>".$lang_mybonus['harem_additional_factor'].$bonusTableResult['harem_addition_factor']."</li>");
|
||||
print("</ul>");
|
||||
$summaryTable .= sprintf(
|
||||
'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>',
|
||||
$lang_mybonus['reward_type_harem_addition'],
|
||||
'--',
|
||||
'--',
|
||||
'--',
|
||||
number_format($haremAddition, 3),
|
||||
$haremFactor,
|
||||
number_format($haremAddition * $haremFactor, 3)
|
||||
);
|
||||
}
|
||||
$summaryTable .= '</tbody></table>';
|
||||
|
||||
print("<h1>".$lang_mybonus['text_bonus_summary']."</h1>");
|
||||
print '<div style="display: flex;justify-content: center;margin-top: 20px;">'.$summaryTable.'</div>';
|
||||
print '<div style="display: flex;justify-content: center;margin-top: 20px;">'.$bonusTableResult['table'].'</div>';
|
||||
|
||||
print("<h1>".$lang_mybonus['text_other_things_get_bonus']."</h1>");
|
||||
print("<ul>");
|
||||
|
||||
@@ -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"])){
|
||||
|
||||
|
||||
@@ -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',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -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' => '官种加成',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -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' => '官種加成',
|
||||
],
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user