From dc706ca20185b2a02b7bf461a382ad46c6872f73 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Mon, 5 Dec 2022 17:35:39 +0800 Subject: [PATCH] invite add seed bonus --- include/functions.php | 10 ++-- lang/chs/lang_invite.php | 6 +++ lang/cht/lang_invite.php | 6 +++ lang/en/lang_invite.php | 6 +++ public/invite.php | 89 +++++++++++++++++++++++++++++++--- resources/lang/en/nexus.php | 2 + resources/lang/zh_TW/nexus.php | 2 + 7 files changed, 110 insertions(+), 11 deletions(-) diff --git a/include/functions.php b/include/functions.php index 561f6c6d..31367ce2 100644 --- a/include/functions.php +++ b/include/functions.php @@ -5957,9 +5957,9 @@ function calculate_seed_bonus($uid, $torrentIdArr = null): array $torrentIdArr = [-1]; } $idStr = implode(',', \Illuminate\Support\Arr::wrap($torrentIdArr)); - $sql = "select torrents.id, torrents.added, torrents.size, torrents.seeders, 'NO_PEER_ID' as peerID from torrents WHERE id in ($idStr)"; + $sql = "select torrents.id, torrents.added, torrents.size, torrents.seeders, 'NO_PEER_ID' as peerID, '' as last_action from torrents WHERE id in ($idStr)"; } else { - $sql = "select torrents.id, torrents.added, torrents.size, torrents.seeders, peers.id as peerID from torrents LEFT JOIN peers ON peers.torrent = torrents.id WHERE peers.userid = $uid AND peers.seeder ='yes' group by peers.torrent, peers.peer_id"; + $sql = "select torrents.id, torrents.added, torrents.size, torrents.seeders, peers.id as peerID, peers.last_action from torrents LEFT JOIN peers ON peers.torrent = torrents.id WHERE peers.userid = $uid AND peers.seeder ='yes' group by peers.torrent, peers.peer_id"; } $tagGrouped = []; $torrentResult = \Nexus\Database\NexusDB::select($sql); @@ -5975,8 +5975,12 @@ function calculate_seed_bonus($uid, $torrentIdArr = null): array $zeroBonusTag = \App\Models\Setting::get('bonus.zero_bonus_tag'); $zeroBonusFactor = \App\Models\Setting::get('bonus.zero_bonus_factor'); do_log("$logPrefix, sql: $sql, count: " . count($torrentResult) . ", officialTag: $officialTag, officialAdditionalFactor: $officialAdditionalFactor, zeroBonusTag: $zeroBonusTag, zeroBonusFactor: $zeroBonusFactor"); + $last_action = ""; foreach ($torrentResult as $torrent) { + if ($torrent['last_action'] > $last_action) { + $last_action = $torrent['last_action']; + } $size = bcadd($size, $torrent['size']); $weeks_alive = ($timenow - strtotime($torrent['added'])) / $sectoweek; $gb_size = $gb_size_raw = $torrent['size'] / 1073741824; @@ -6005,7 +6009,7 @@ function calculate_seed_bonus($uid, $torrentIdArr = null): array //Official addition don't think about the minimum value $official_bonus = $valuetwo * atan($official_a / $l_bonus); $result = compact( - 'seed_points','seed_bonus', 'A', 'count', 'torrent_peer_count', 'size', + 'seed_points','seed_bonus', 'A', 'count', 'torrent_peer_count', 'size', 'last_action', 'official_bonus', 'official_a', 'official_torrent_peer_count', 'official_size' ); $result['donor_times'] = $donortimes_bonus; diff --git a/lang/chs/lang_invite.php b/lang/chs/lang_invite.php index 97f4b674..36e13820 100644 --- a/lang/chs/lang_invite.php +++ b/lang/chs/lang_invite.php @@ -51,6 +51,12 @@ $lang_invite = array 'harem_addition' => '后宫加成', 'signup_link_help' => '右键复制', 'signup_link' => '注册链接', + 'text_seed_torrent_count' => '当前做种数', + 'text_seed_torrent_size' => '当前做种体积', + 'text_seed_torrent_bonus_per_hour' => '当前纯做种时魔', + 'text_seed_torrent_bonus_per_hour_help' => '即做种积分,单纯做种的值,不考虑捐赠、官种、后宫等任何加成', + 'text_seed_torrent_last_announce_at' => '最后做种汇报时间', + 'text_enabled' => '启用', ); ?> diff --git a/lang/cht/lang_invite.php b/lang/cht/lang_invite.php index bfe290c5..6351cdde 100644 --- a/lang/cht/lang_invite.php +++ b/lang/cht/lang_invite.php @@ -51,6 +51,12 @@ $lang_invite = array 'harem_addition' => '後宮加成', 'signup_link_help' => '右鍵復製', 'signup_link' => '註冊鏈接', + 'text_seed_torrent_count' => '當前做種數', + 'text_seed_torrent_size' => '當前做種體積', + 'text_seed_torrent_bonus_per_hour' => '當前純做種時魔', + 'text_seed_torrent_bonus_per_hour_help' => '即做種積分,單純做種的值,不考慮捐贈、官種、後宮等任何加成', + 'text_seed_torrent_last_announce_at' => '最後做種匯報時間', + 'text_enabled' => '啟用', ); ?> diff --git a/lang/en/lang_invite.php b/lang/en/lang_invite.php index 4185e322..92a759c4 100644 --- a/lang/en/lang_invite.php +++ b/lang/en/lang_invite.php @@ -54,6 +54,12 @@ Best Regards, 'harem_addition' => 'Harem addition', 'signup_link_help' => 'Right click to copy', 'signup_link' => 'Signup link', + 'text_seed_torrent_count' => 'Seeding counts', + 'text_seed_torrent_size' => 'Seeding size', + 'text_seed_torrent_bonus_per_hour' => 'Seeding bonus per hour', + 'text_seed_torrent_bonus_per_hour_help' => 'That is, seed points, do not consider donations, official torrent, harems and any other additions', + 'text_seed_torrent_last_announce_at' => 'Last announce time', + 'text_enabled' => 'Enabled', ); ?> diff --git a/public/invite.php b/public/invite.php index 01efb9bd..db211012 100644 --- a/public/invite.php +++ b/public/invite.php @@ -70,11 +70,61 @@ if ($type == 'new'){ } else { inviteMenu($menuSelected); if ($menuSelected == 'invitee') { - $rel = sql_query("SELECT COUNT(*) FROM users WHERE invited_by = ".mysql_real_escape_string($id)) or sqlerr(__FILE__, __LINE__); + $whereStr = "invited_by = " . sqlesc($id); + if (!empty($_GET['status'])) { + $whereStr .= " and status = " . sqlesc($_GET['status']); + } + if (!empty($_GET['enabled'])) { + $whereStr .= " and enabled = " . sqlesc($_GET['enabled']); + } + $rel = sql_query("SELECT COUNT(*) FROM users WHERE $whereStr") or sqlerr(__FILE__, __LINE__); $arro = mysql_fetch_row($rel); $number = $arro[0]; - - print("". + $textSelectOnePlease = nexus_trans('nexus.select_one_please'); + $enabledOptions = $statusOptions = ''; + foreach (['yes', 'no'] as $item) { + $enabledOptions .= sprintf( + '', + $item, $_GET['enabled'] == $item ? ' selected' : '', strtoupper($item) + ); + } + foreach (['pending' => $lang_invite['text_pending'], 'confirmed' => $lang_invite['text_confirmed']] as $name => $text) { + $statusOptions .= sprintf( + '', + $name, $_GET['status'] == $name ? ' selected' : '', $text + ); + } + $resetText = nexus_trans('label.reset'); + $filterForm = << + + + + {$lang_invite['text_enabled']}: + +    + {$lang_invite['text_status']}: + +    + + + + +FORM; + $resetJs = <<". "
"); if(!$number){ @@ -82,13 +132,25 @@ if ($type == 'new'){ } else { list($pagertop, $pagerbottom, $limit) = pager($pageSize, $number, "?id=$id&menu=$menuSelected&"); $haremAdditionFactor = get_setting('bonus.harem_addition'); - $ret = sql_query("SELECT id, username, email, uploaded, downloaded, status, warned, enabled, donor, email FROM users WHERE invited_by = ".mysql_real_escape_string($id) . " $limit") or sqlerr(); + $ret = sql_query("SELECT id, username, email, uploaded, downloaded, status, warned, enabled, donor, email FROM users WHERE $whereStr $limit") or sqlerr(); $num = mysql_num_rows($ret); - print("
"); + print(" + + + + + + + + + +" + ); if ($haremAdditionFactor > 0) { print(''); } + print(""); print(""); if ($CURUSER['id'] == $id || get_user_class() >= UC_SYSOP) { print(""); @@ -98,7 +160,6 @@ if ($type == 'new'){ for ($i = 0; $i < $num; ++$i) { $arr = mysql_fetch_assoc($ret); - $user = ""; if ($arr["downloaded"] > 0) { $ratio = number_format($arr["uploaded"] / $arr["downloaded"], 3); @@ -115,11 +176,23 @@ if ($type == 'new'){ $status = "".$lang_invite['text_confirmed'].""; else $status = "".$lang_invite['text_pending'].""; + $seedBonusResult = calculate_seed_bonus($arr['id']); + print(" + + + + + + + + + +"); - print("$user"); if ($haremAdditionFactor > 0) { - print (""); + print (""); } + print(""); print(""); if ($CURUSER['id'] == $id || get_user_class() >= UC_SYSOP){ print("
".$lang_invite['text_username']."".$lang_invite['text_email']."".$lang_invite['text_uploaded']."".$lang_invite['text_downloaded']."".$lang_invite['text_ratio']."
".$lang_invite['text_username']."".$lang_invite['text_email']."".$lang_invite['text_enabled']."".$lang_invite['text_uploaded']."".$lang_invite['text_downloaded']."".$lang_invite['text_ratio']."".$lang_invite['text_seed_torrent_count']."".$lang_invite['text_seed_torrent_size']."".$lang_invite['text_seed_torrent_bonus_per_hour']."'.$lang_invite['harem_addition'].'".$lang_invite['text_seed_torrent_last_announce_at']."".$lang_invite['text_status']."".$lang_invite['text_confirm']."" . get_username($arr['id']) . "
".get_username($arr['id'])."{$arr['email']}".$arr['enabled']."" . mksize($arr['uploaded']) . "" . mksize($arr['downloaded']) . "$ratio{$seedBonusResult['count']}".mksize($seedBonusResult['size'])."".number_format($seedBonusResult['seed_points'], 3)."
{$arr['email']}" . mksize($arr['uploaded']) . "" . mksize($arr['downloaded']) . "$ratio".number_format(calculate_seed_bonus($arr['id'])['all_bonus'] * $haremAdditionFactor, 3)."".number_format($seedBonusResult['seed_points'] * $haremAdditionFactor, 3)."{$seedBonusResult['last_action']}$status"); diff --git a/resources/lang/en/nexus.php b/resources/lang/en/nexus.php index f5ec03f0..2adb7113 100644 --- a/resources/lang/en/nexus.php +++ b/resources/lang/en/nexus.php @@ -8,4 +8,6 @@ return [ 'time_units' => [ 'week' => 'weeks', ], + 'select_all' => 'Select all', + 'unselect_all' => 'Unselect all', ]; diff --git a/resources/lang/zh_TW/nexus.php b/resources/lang/zh_TW/nexus.php index 47d923a9..65d92c0f 100644 --- a/resources/lang/zh_TW/nexus.php +++ b/resources/lang/zh_TW/nexus.php @@ -8,4 +8,6 @@ return [ 'time_units' => [ 'week' => '周', ], + 'select_all' => '全選', + 'unselect_all' => '全不選', ];