mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
harem addition
This commit is contained in:
@@ -264,45 +264,23 @@ function docleanup($forceAll = 0, $printProgress = false) {
|
||||
$res = sql_query("SELECT DISTINCT userid FROM peers WHERE seeder = 'yes'") or sqlerr(__FILE__, __LINE__);
|
||||
if (mysql_num_rows($res) > 0)
|
||||
{
|
||||
// $sqrtof2 = sqrt(2);
|
||||
// $logofpointone = log(0.1);
|
||||
// $valueone = $logofpointone / $tzero_bonus;
|
||||
// $pi = 3.141592653589793;
|
||||
// $valuetwo = $bzero_bonus * ( 2 / $pi);
|
||||
// $valuethree = $logofpointone / ($nzero_bonus - 1);
|
||||
// $timenow = TIMENOW;
|
||||
// $sectoweek = 7*24*60*60;
|
||||
$haremAdditionFactor = get_setting('bonus.harem_addition');
|
||||
while ($arr = mysql_fetch_assoc($res)) //loop for different users
|
||||
{
|
||||
// $A = 0;
|
||||
// $count = 0;
|
||||
// $all_bonus = 0;
|
||||
// $torrentres = sql_query("select torrents.added, torrents.size, torrents.seeders from torrents LEFT JOIN peers ON peers.torrent = torrents.id WHERE peers.userid = {$arr['userid']} AND peers.seeder ='yes' group by torrents.id") or sqlerr(__FILE__, __LINE__);
|
||||
// while ($torrent = mysql_fetch_array($torrentres))
|
||||
// {
|
||||
// $weeks_alive = ($timenow - strtotime($torrent['added'])) / $sectoweek;
|
||||
// $gb_size = $torrent['size'] / 1073741824;
|
||||
// $temp = (1 - exp($valueone * $weeks_alive)) * $gb_size * (1 + $sqrtof2 * exp($valuethree * ($torrent['seeders'] - 1)));
|
||||
// $A += $temp;
|
||||
// $count++;
|
||||
// }
|
||||
// if ($count > $maxseeding_bonus)
|
||||
// $count = $maxseeding_bonus;
|
||||
// $all_bonus = $seedPoints = ($valuetwo * atan($A / $l_bonus) + ($perseeding_bonus * $count)) / (3600 / $autoclean_interval_one);
|
||||
// $is_donor = get_single_value("users","donor","WHERE id=".$arr['userid']);
|
||||
// $log = "[UPDATE_BONUS], user: {$arr['userid']}, original bonus: $all_bonus, is_donor: $is_donor, donortimes_bonus: $donortimes_bonus";
|
||||
// if ($is_donor == 'yes' && $donortimes_bonus > 0) {
|
||||
// $all_bonus = $all_bonus * $donortimes_bonus;
|
||||
// $log .= ", do multiple, all_bonus: $all_bonus";
|
||||
// }
|
||||
// do_log($log);
|
||||
$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";
|
||||
}
|
||||
$sql = "update users set seed_points = ifnull(seed_points, 0) + $seed_points, seedbonus = seedbonus + $all_bonus where id = {$arr["userid"]}";
|
||||
do_log("[CLEANUP_CALCULATE_SEED_BONUS], result: " . nexus_json_encode($seedBonusResult) . ", query: $sql");
|
||||
do_log("$bonusLog, query: $sql");
|
||||
sql_query($sql);
|
||||
|
||||
}
|
||||
}
|
||||
$log = 'calculate seeding bonus';
|
||||
|
||||
@@ -5730,4 +5730,21 @@ function calculate_seed_bonus($uid, $torrentIdArr = null): array
|
||||
return $result;
|
||||
}
|
||||
|
||||
function calculate_harem_addition($uid)
|
||||
{
|
||||
$harems = \App\Models\User::query()
|
||||
->where('invited_by', $uid)
|
||||
->where('status', \App\Models\User::STATUS_CONFIRMED)
|
||||
->where('enabled', \App\Models\User::ENABLED_YES)
|
||||
->get(['id']);
|
||||
$addition = 0;
|
||||
$haremsCount = $harems->count();
|
||||
foreach ($harems as $harem) {
|
||||
$result = calculate_seed_bonus($harem->id);
|
||||
$addition += $result['all_bonus'];
|
||||
}
|
||||
do_log("[HAREM_ADDITION], user: $uid, haremsCount: $haremsCount ,addition: $addition");
|
||||
return $addition;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -130,6 +130,14 @@ $lang_mybonus = array
|
||||
'text_attendance_card' => '购买补签卡',
|
||||
'text_attendance_card_note' => '补签一天消耗一张,补签目标日期所得魔力奖励按照正常计算,即目标日期往前推计算连续天数获得奖励。',
|
||||
'text_success_buy_attendance_card' => '成功购买了一张补签卡。',
|
||||
'text_harem_addition_get' => '当前后宫加成每小时获得 %s 魔力',
|
||||
'reward_type' => '奖励类型',
|
||||
'addition' => '加成',
|
||||
'got_bonus' => '获得魔力',
|
||||
'total' => '合计',
|
||||
'reward_type_basic' => '基本奖励',
|
||||
'reward_type_harem_addition' => '后宫加成',
|
||||
'bonus_base' => '基础魔力',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -766,6 +766,9 @@ $lang_settings = array
|
||||
'row_imdb_language' => 'IMDB 语言',
|
||||
'text_imdb_language_note' => '抓取 IMDB 数据使用的语言。',
|
||||
'text_login_type_passkey' => 'passkey',
|
||||
'row_harem_addition' => '后宫加成',
|
||||
'text_user_would_get_by_harem' => '用户将获得直属后宫魔力值的',
|
||||
'text_harem_addition_note' => '倍作为奖励(系数,如填入 0.01,后宫获得 100 魔力则奖励用户 100 * 0.01 = 1)',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -130,6 +130,14 @@ $lang_mybonus = array
|
||||
'text_attendance_card' => '購買補簽卡',
|
||||
'text_attendance_card_note' => '補簽一天消耗一張,補簽目標日期所得魔力獎勵按照正常計算,即目標日期往前推計算連續天數獲得獎勵。',
|
||||
'text_success_buy_attendance_card' => '成功購買了一張補簽卡。',
|
||||
'text_harem_addition_get' => '當前後宮加成每小時獲得 %s 魔力',
|
||||
'reward_type' => '獎勵類型',
|
||||
'addition' => '加成',
|
||||
'got_bonus' => '獲得魔力',
|
||||
'total' => '合計',
|
||||
'reward_type_basic' => '基本獎勵',
|
||||
'reward_type_harem_addition' => '後宮加成',
|
||||
'bonus_base' => '基礎魔力',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -766,6 +766,9 @@ $lang_settings = array
|
||||
'row_imdb_language' => 'IMDB 語言',
|
||||
'text_imdb_language_note' => '抓取 IMDB 數據使用的語言。',
|
||||
'text_login_type_passkey' => 'passkey',
|
||||
'row_harem_addition' => '後宮加成',
|
||||
'text_user_would_get_by_harem' => '用戶將獲得直屬後宮魔力值的',
|
||||
'text_harem_addition_note' => '倍作為獎勵(系數,如填入 0.01,後宮獲得 100 魔力則獎勵用戶 100 * 0.01 = 1)',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -130,6 +130,14 @@ where<ul><li><b>A</b> is an intermediate variable</li><li><b>Ti</b> is the <b>i<
|
||||
'text_attendance_card' => 'Buy attendance card',
|
||||
'text_attendance_card_note' => 'One day to make up the attendance consume one, attend of the target date of the bonus rewards in accordance with the normal calculation, that is, the target date forward to calculate the number of continuous days to obtain rewards.',
|
||||
'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',
|
||||
'got_bonus' => 'Got bonus',
|
||||
'total' => 'Total',
|
||||
'reward_type_basic' => 'Basic reward',
|
||||
'reward_type_harem_addition' => 'Harem addition',
|
||||
'bonus_base' => 'Base bonus',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -766,6 +766,9 @@ $lang_settings = array
|
||||
'row_imdb_language' => 'IMDB Language',
|
||||
'text_imdb_language_note' => 'Languages used to crawl IMDB data.',
|
||||
'text_login_type_passkey' => 'passkey',
|
||||
'row_harem_addition' => 'Harem addition',
|
||||
'text_user_would_get_by_harem' => 'The user will receive the bonus value of the direct harem',
|
||||
'text_harem_addition_note' => 'times as reward (factor, e.g. fill in 0.01, if harem gets 100 bonus then reward user 100 * 0.01 = 1)',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -391,6 +391,7 @@ if ($perseeding_bonus > 0)
|
||||
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>");
|
||||
if ($donortimes_bonus)
|
||||
print("<li>".$lang_mybonus['text_donors_always_get'].$donortimes_bonus.$lang_mybonus['text_times_of_bonus']."</li>");
|
||||
|
||||
print("</ul>");
|
||||
|
||||
// $sqrtof2 = sqrt(2);
|
||||
@@ -429,6 +430,32 @@ $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);
|
||||
$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 .= sprintf(
|
||||
'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td rowspan="2">%s</td></tr>',
|
||||
$lang_mybonus['reward_type_basic'],
|
||||
round($all_bonus,3),
|
||||
'-',
|
||||
round($all_bonus,3),
|
||||
$totalBonus
|
||||
);
|
||||
if ($factor > 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)
|
||||
);
|
||||
}
|
||||
$summaryTable .= '</tbody></table>';
|
||||
|
||||
print '<div style="display: flex;justify-content: center;margin-top: 20px;">'.$summaryTable.'</div>';
|
||||
|
||||
print("<h1>".$lang_mybonus['text_other_things_get_bonus']."</h1>");
|
||||
print("<ul>");
|
||||
if ($uploadtorrent_bonus > 0)
|
||||
|
||||
@@ -94,7 +94,13 @@ elseif ($action == 'savesettings_code') // save database
|
||||
elseif ($action == 'savesettings_bonus') // save bonus
|
||||
{
|
||||
stdhead($lang_settings['head_save_bonus_settings']);
|
||||
$validConfig = array('donortimes','perseeding','maxseeding','tzero','nzero','bzero','l', 'uploadtorrent','uploadsubtitle','starttopic','makepost','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');
|
||||
$validConfig = array(
|
||||
'donortimes','perseeding','maxseeding','tzero','nzero','bzero','l', 'uploadtorrent','uploadsubtitle','starttopic','makepost',
|
||||
'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'
|
||||
);
|
||||
GetVar($validConfig);
|
||||
$BONUS = [];
|
||||
foreach($validConfig as $config) {
|
||||
@@ -553,6 +559,9 @@ elseif ($action == 'bonussettings'){
|
||||
tr($lang_settings['row_saying_thanks'], $lang_settings['text_giver_and_receiver_get']."<input type='text' style=\"width: 50px\" name=saythanks value='".(isset($BONUS["saythanks"]) ? $BONUS["saythanks"] : 0.5 )."'>".$lang_settings['text_saying_thanks_and']."<input type='text' style=\"width: 50px\" name=receivethanks value='".(isset($BONUS["receivethanks"]) ? $BONUS["receivethanks"] : 0 )."'>".$lang_settings['text_saying_thanks_default'], 1);
|
||||
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);
|
||||
|
||||
|
||||
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);
|
||||
tr($lang_settings['row_five_gb_credit'],$lang_settings['text_it_costs_user']."<input type='text' style=\"width: 50px\" name=fivegbupload value='".(isset($BONUS["fivegbupload"]) ? $BONUS["fivegbupload"] : 800 )."'>".$lang_settings['text_five_gb_credit_note'], 1);
|
||||
|
||||
@@ -21,6 +21,7 @@ return [
|
||||
'upload_speed' => 'Upload speed',
|
||||
'download_speed' => 'Download speed',
|
||||
'isp' => 'ISP',
|
||||
'menu' => 'Menu',
|
||||
],
|
||||
'resources' => [
|
||||
'agent_allow' => [
|
||||
|
||||
@@ -21,6 +21,7 @@ return [
|
||||
'upload_speed' => '上行帶寬',
|
||||
'download_speed' => '下行帶寬',
|
||||
'isp' => 'ISP',
|
||||
'menu' => '菜單',
|
||||
],
|
||||
'resources' => [
|
||||
'agent_allow' => [
|
||||
|
||||
Reference in New Issue
Block a user