reward torrent add times limit

This commit is contained in:
xiaomlove
2025-09-08 13:05:42 +07:00
parent 22a91a5851
commit 500df6b922
7 changed files with 43 additions and 26 deletions
+5
View File
@@ -317,5 +317,10 @@ class Setting extends NexusModel
return Torrent::BONUS_REWARD_VALUES;
}
public static function getBonusRewardTimesLimit(): int
{
return (int)self::get("torrent.reward_times_limit", 0);
}
}
+2
View File
@@ -823,6 +823,8 @@ $lang_settings = array
'text_bonus_mini_size_help' => '。小于此体积的种子不参与魔力计算。单位:字节(Byte),如 1 Byte = 1024 KiB。',
'row_reward_bonus_options' => '魔力值奖励选项',
'text_reward_bonus_options_note' => '种子详情页的魔力值奖励选项,多个用英文逗号分割',
'row_reward_times_limit' => '魔力奖励次数限制',
'text_reward_times_limit_note' => '种子详情页的魔力奖励每人每天次数限制,设置为 0 不限制。默认:0',
);
?>
+2
View File
@@ -821,6 +821,8 @@ $lang_settings = array
'text_bonus_mini_size_help' => '。小於此體積的種子不參與魔力計算。單位:字節(Byte),如 1 Byte = 1024 KiB。',
'row_reward_bonus_options' => '魔力值獎勵選項',
'text_reward_bonus_options_note' => '種子詳情頁的魔力值獎勵選項,多個用英文逗號分割',
'row_reward_times_limit' => '魔力獎勵次數限制',
'text_reward_times_limit_note' => '種子詳情頁的魔力獎勵每人每天次數限制,設置爲 0 不限制。默認:0',
);
?>
+2
View File
@@ -821,6 +821,8 @@ $lang_settings = array
'text_bonus_mini_size_help' => '. Torrent size smaller than this volume are not included in the bonus calculation. Unit: bytes (Byte), e.g., 1 Byte = 1024 KiB.',
'row_reward_bonus_options' => 'Reward Bonus Options',
'text_reward_bonus_options_note' => 'Reward bonus options on the torrent details page, multiple options separated by commas',
'row_reward_times_limit' => 'Reward Frequency Limit',
'text_reward_times_limit_note' => 'Daily limit per user for bonus rewards on seed detail pages. Set to 0 for no limit. Default: 0',
);
?>
+16 -16
View File
@@ -93,22 +93,22 @@ function unpreview(obj){
function saveMagicValue(torrentid,value)
{
var list=ajax.posts('magic.php','value='+value +'&id='+torrentid);
// document.getElementById("thanksbutton").innerHTML = document.getElementById("thanksadded").innerHTML;
document.getElementById("magic_add").value += value;
document.getElementById("magic_add").style.display = '';
document.getElementById("listNumber").style.display = 'none';
document.getElementById("current_user_magic").style.display = '';
var sumAll = document.getElementById("spanSumAll").innerHTML;
document.getElementById("spanSumAll").innerHTML = sumAll*1 + value;
if(document.getElementById("count_user_spa")){
var userAll = document.getElementById("count_user_spa").innerHTML;
document.getElementById("count_user_spa").innerHTML = userAll*1 + 1;
}
//document.getElementById("listNumber").innerHTML = "<input class=\"btn\" type=\"button\" id="magic_add" value=\""+value+"\" disabled=\"disabled\" />";
// document.getElementById("addcuruser").innerHTML = document.getElementById("curuser").innerHTML;
jQuery.post("magic.php", {"value": value, "id": torrentid}, function(res) {
if (res.ret !== 0) {
alert(res.msg)
return
}
document.getElementById("magic_add").value += value;
document.getElementById("magic_add").style.display = '';
document.getElementById("listNumber").style.display = 'none';
document.getElementById("current_user_magic").style.display = '';
var sumAll = document.getElementById("spanSumAll").innerHTML;
document.getElementById("spanSumAll").innerHTML = sumAll*1 + value;
if(document.getElementById("count_user_spa")){
var userAll = document.getElementById("count_user_spa").innerHTML;
document.getElementById("count_user_spa").innerHTML = userAll*1 + 1;
}
}, "json")
}
// java_klappe.js
+14 -9
View File
@@ -3,29 +3,34 @@ require "../include/bittorrent.php";
dbconn();
loggedinorreturn();
if (isset($_GET['id'])) stderr("Party is over!", "This trick doesn't work anymore. You need to click the button!");
$userid = $CURUSER["id"];
$torrentid = (int) $_POST["id"];
$value = (int) abs($_POST['value']);
if (!in_array($value, \App\Models\Setting::getBonusRewardOptions())) {
stderr('Error', 'Invalid value.');
exit(json_encode(fail("Invalid value.", $_POST)));
}
if($value <= 0) stderr('Error', 'Value must be positive.');
if($value > $CURUSER['seedbonus']) stderr('Error','You do not have such bonus!');
if($value > $CURUSER['seedbonus']) exit(json_encode(fail('You do not have such bonus!', $_POST)));
$tsql = sql_query("SELECT owner FROM torrents WHERE id = $torrentid") or sqlerr(__FILE__,__LINE__);
$arr = mysql_fetch_assoc($tsql);
if (!$arr) stderr("Error", "Invalid torrent id!");
if (!$arr) exit(json_encode(fail("Invalid torrent id!", $_POST)));
$torrentowner = $arr['owner'];
if($torrentowner == $userid) stderr('Error', 'You are giving magic to yourself.');
if($torrentowner == $userid) exit(json_encode(fail('You are giving magic to yourself.', $_POST)));
$tsql = sql_query("SELECT COUNT(*) FROM magic WHERE torrentid=$torrentid and userid=$userid") or sqlerr(__FILE__,__LINE__);
$trows = mysql_fetch_assoc($tsql);
$t_ab = $trows[0];
if ($t_ab != 0) stderr("Error", "You already gave the magic value!");
if ($t_ab != 0) exit(json_encode(fail("You already gave the magic value!", $_POST)));
$todayStr = now()->startOfDay();
$todayCount = \App\Models\Reward::query()
->where('userid', $userid)
->where('created_at', ">=", $todayStr)
->count();
$timesLimit = \App\Models\Setting::getBonusRewardTimesLimit();
if ($timesLimit > 0 && $todayCount >= $timesLimit) exit(json_encode(fail("You already reach times limit!", $_POST)));
$torrentOwnerInfo = \App\Models\User::query()->find($torrentowner, \App\Models\User::$commonFields);
if (!$torrentOwnerInfo) {
stderr('Error', 'Invalid torrent owner!');
exit(json_encode(fail("Invalid torrent owner!", $_POST)));
}
if (isset($userid) && isset($torrentid)&& isset($value)) {
sql_query("INSERT INTO magic (torrentid, userid,value) VALUES ($torrentid, $userid, $value)") or sqlerr(__FILE__,__LINE__);
+2 -1
View File
@@ -158,7 +158,7 @@ elseif($action == 'savesettings_torrent') // save account
'thirtypercentleechbecome', 'expirethirtypercentleech', 'sticky_first_level_background_color', 'sticky_second_level_background_color',
'download_support_passkey', 'claim_enabled', 'claim_torrent_ttl', 'claim_torrent_user_counts_up_limit', 'claim_user_torrent_counts_up_limit', 'claim_remove_deduct_user_bonus',
'claim_give_up_deduct_user_bonus', 'claim_bonus_multiplier', 'claim_reach_standard_seed_time', 'claim_reach_standard_uploaded', 'approval_status_icon_enabled', 'approval_status_none_visible',
'nfo_view_style_default', 'tax_factor', 'max_price', 'paid_torrent_enabled', 'reward_bonus_options'
'nfo_view_style_default', 'tax_factor', 'max_price', 'paid_torrent_enabled', 'reward_bonus_options', 'reward_times_limit'
);
$validConfig = apply_filter('setting_valid_config', $validConfig);
GetVar($validConfig);
@@ -748,6 +748,7 @@ elseif ($action == 'torrentsettings')
tr($lang_settings['row_tax_factor'],"<input type='number' name=tax_factor style=\"width: 100px\" value={$TORRENT['tax_factor']}> ".$lang_settings['text_tax_factor_note'], 1);
tr($lang_settings['row_max_price'],"<input type='number' name=max_price style=\"width: 100px\" value={$TORRENT['max_price']}> ".$lang_settings['text_max_price_note'], 1);
tr($lang_settings['row_reward_bonus_options'],"<input type='text' name=reward_bonus_options style=\"width: 200px\" value={$TORRENT['reward_bonus_options']}> ".$lang_settings['text_reward_bonus_options_note'], 1);
tr($lang_settings['row_reward_times_limit'],"<input type='number' name=reward_times_limit style=\"width: 100px\" value={$TORRENT['reward_times_limit']}> ".$lang_settings['text_reward_times_limit_note'], 1);
// yesorno($lang_settings['row_promotion_rules'], 'prorules', $TORRENT["prorules"], $lang_settings['text_promotion_rules_note']);
tr($lang_settings['row_random_promotion'], $lang_settings['text_random_promotion_note_one']."<ul><li><input type='text' style=\"width: 50px\" name=randomhalfleech value='".(isset($TORRENT["randomhalfleech"]) ? $TORRENT["randomhalfleech"] : 5 )."'>".$lang_settings['text_halfleech_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomfree value='".(isset($TORRENT["randomfree"]) ? $TORRENT["randomfree"] : 2 )."'>".$lang_settings['text_free_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomtwoup value='".(isset($TORRENT["randomtwoup"]) ? $TORRENT["randomtwoup"] : 2 )."'>".$lang_settings['text_twoup_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomtwoupfree value='".(isset($TORRENT["randomtwoupfree"]) ? $TORRENT["randomtwoupfree"] : 1 )."'>".$lang_settings['text_freetwoup_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomtwouphalfdown value='".(isset($TORRENT["randomtwouphalfdown"]) ? $TORRENT["randomtwouphalfdown"] : 0 )."'>".$lang_settings['text_twouphalfleech_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomthirtypercentdown value='".(isset($TORRENT["randomthirtypercentdown"]) ? $TORRENT["randomthirtypercentdown"] : 0 )."'>".$lang_settings['text_thirtypercentleech_chance_becoming']."</li></ul>".$lang_settings['text_random_promotion_note_two'], 1);