This commit is contained in:
xiaomlove
2021-12-14 16:22:03 +08:00
parent 19d7e048df
commit 3fa8fd19c0
29 changed files with 319 additions and 45 deletions

View File

@@ -96,7 +96,11 @@ function promotion($class, $down_floor_gb, $minratio, $time_week, $addinvite = 0
if ($down_floor_gb){
$limit = $down_floor_gb*1024*1024*1024;
$maxdt = date("Y-m-d H:i:s",(TIMENOW - 86400*7*$time_week));
$sql = "SELECT id, max_class_once FROM users WHERE class = $oriclass AND downloaded >= $limit AND uploaded / downloaded >= $minratio AND added < ".sqlesc($maxdt);
$minSeedPoints = \App\Models\User::getMinSeedPoints($class);
if ($minSeedPoints === false) {
throw new \RuntimeException("class: $class can't get min seed points.");
}
$sql = "SELECT id, max_class_once FROM users WHERE class = $oriclass AND downloaded >= $limit AND seed_points >= $minSeedPoints AND uploaded / downloaded >= $minratio AND added < ".sqlesc($maxdt);
$res = sql_query($sql) or sqlerr(__FILE__, __LINE__);
$matchUserCount = mysql_num_rows($res);
do_log("sql: $sql, match user count: $matchUserCount");
@@ -122,9 +126,12 @@ function promotion($class, $down_floor_gb, $minratio, $time_week, $addinvite = 0
function demotion($class,$deratio){
global $lang_cleanup_target;
$newclass = $class - 1;
$res = sql_query("SELECT id FROM users WHERE class = $class AND uploaded / downloaded < $deratio") or sqlerr(__FILE__, __LINE__);
$minSeedPoints = \App\Models\User::getMinSeedPoints($class);
if ($minSeedPoints === false) {
throw new \RuntimeException("class: $class can't get min seed points.");
}
$res = sql_query("SELECT id FROM users WHERE class = $class AND seed_points < $minSeedPoints AND uploaded / downloaded < $deratio") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) > 0)
{
$dt = sqlesc(date("Y-m-d H:i:s"));
@@ -280,11 +287,12 @@ function docleanup($forceAll = 0, $printProgress = false) {
}
if ($count > $maxseeding_bonus)
$count = $maxseeding_bonus;
$all_bonus = ($valuetwo * atan($A / $l_bonus) + ($perseeding_bonus * $count)) / (3600 / $autoclean_interval_one);
$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']);
if ($is_donor == 'yes' && $donortimes_bonus > 0)
$all_bonus = $all_bonus * $donortimes_bonus;
KPS("+",$all_bonus,$arr["userid"]);
\App\Models\User::query()->where('id', $arr["userid"])->update(['seed_points' => new \Illuminate\Database\Query\Expression("seed_points + $seedPoints")]);
}
}
$log = 'calculate seeding bonus';

View File

@@ -2476,14 +2476,16 @@ else {
<?php if (get_user_class() >= UC_SYSOP) { ?> [<a href="settings.php"><?php echo $lang_functions['text_site_settings'] ?></a>]<?php } ?>
[<a href="torrents.php?inclbookmarked=1&amp;allsec=1&amp;incldead=0"><?php echo $lang_functions['text_bookmarks'] ?></a>]
<font class = 'color_bonus'><?php echo $lang_functions['text_bonus'] ?></font>[<a href="mybonus.php"><?php echo $lang_functions['text_use'] ?></a>]: <?php echo number_format($CURUSER['seedbonus'], 1)?>
<font class = 'color_bonus'><?php echo $lang_functions['text_seed_points'] ?></font>: <?php echo number_format($CURUSER['seed_points'], 1)?>
<?php if($attendance){ printf('&nbsp;'.$lang_functions['text_attended'], $attendance['points']); }else{ printf(' <a href="attendance.php" class="faqlink">%s</a>', $lang_functions['text_attendance']);}?>
<font class = 'color_invite'><?php echo $lang_functions['text_invite'] ?></font>[<a href="invite.php?id=<?php echo $CURUSER['id']?>"><?php echo $lang_functions['text_send'] ?></a>]: <?php echo $CURUSER['invites']?>
<?php if(get_setting('hr.mode') != \App\Models\HitAndRun::MODE_DISABLED) { ?><font class='color_bonus'>H&R: </font> <?php echo sprintf('[<a href="myhr.php">%s/%s</a>]', get_row_count('hit_and_runs', "where uid = {$CURUSER['id']} and status = 3"), get_setting('hr.ban_user_when_counts_reach'))?><?php }?><br />
<br />
<font class="color_ratio"><?php echo $lang_functions['text_ratio'] ?></font> <?php echo $ratio?>
<font class='color_uploaded'><?php echo $lang_functions['text_uploaded'] ?></font> <?php echo mksize($CURUSER['uploaded'])?>
<font class='color_downloaded'> <?php echo $lang_functions['text_downloaded'] ?></font> <?php echo mksize($CURUSER['downloaded'])?>
<font class='color_active'><?php echo $lang_functions['text_active_torrents'] ?></font> <img class="arrowup" alt="Torrents seeding" title="<?php echo $lang_functions['title_torrents_seeding'] ?>" src="pic/trans.gif" /><?php echo $activeseed?> <img class="arrowdown" alt="Torrents leeching" title="<?php echo $lang_functions['title_torrents_leeching'] ?>" src="pic/trans.gif" /><?php echo $activeleech?>&nbsp;&nbsp;
<font class='color_connectable'><?php echo $lang_functions['text_connectable'] ?></font><?php echo $connectable?> <?php echo maxslots();?>
<?php if(get_setting('hr.mode') != \App\Models\HitAndRun::MODE_DISABLED) { ?><font class='color_bonus'>H&R: </font> <?php echo sprintf('[<a href="myhr.php">%s/%s</a>]', get_row_count('hit_and_runs', "where uid = {$CURUSER['id']} and status = 3"), get_setting('hr.ban_user_when_counts_reach'))?><?php }?>
<?php if(get_user_class() >= UC_SYSOP) { ?> [<a href="/admin" target="_blank"><?php echo $lang_functions['text_management_system'] ?></a>]<?php }?>
</span>
</td>