mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
add H&R include rate
This commit is contained in:
@@ -175,6 +175,7 @@ class EditSetting extends Page implements Forms\Contracts\HasForms
|
||||
Forms\Components\TextInput::make('hr.seed_time_minimum')->helperText(__('label.setting.hr.seed_time_minimum_help'))->label(__('label.setting.hr.seed_time_minimum'))->integer(),
|
||||
Forms\Components\TextInput::make('hr.ignore_when_ratio_reach')->helperText(__('label.setting.hr.ignore_when_ratio_reach_help'))->label(__('label.setting.hr.ignore_when_ratio_reach'))->integer(),
|
||||
Forms\Components\TextInput::make('hr.ban_user_when_counts_reach')->helperText(__('label.setting.hr.ban_user_when_counts_reach_help'))->label(__('label.setting.hr.ban_user_when_counts_reach'))->integer(),
|
||||
Forms\Components\TextInput::make('hr.include_rate')->helperText(__('label.setting.hr.include_rate_help'))->label(__('label.setting.hr.include_rate'))->numeric(),
|
||||
];
|
||||
return apply_filter("hit_and_run_setting_schema", $default);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.7');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-09-04');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-09-14');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
@@ -431,6 +431,7 @@ return array (
|
||||
'seed_time_minimum' => '',
|
||||
'ignore_when_ratio_reach' => '',
|
||||
'ban_user_when_counts_reach' => '',
|
||||
'include_rate' => 1,
|
||||
],
|
||||
'seed_box' => [
|
||||
'enabled' => 'no',
|
||||
|
||||
@@ -645,14 +645,25 @@ elseif(isset($self))
|
||||
if (!empty($snatchInfo)) {
|
||||
sql_query("UPDATE snatched SET uploaded = uploaded + $trueupthis, downloaded = downloaded + $truedownthis, to_go = $left, $announcetime, last_action = ".$dt." $finished_snatched WHERE id = {$snatchInfo['id']}") or err("SL Err 2");
|
||||
do_action('snatched_saved', $torrent, $snatchInfo);
|
||||
if ($event == 'completed' && $az['class'] < \App\Models\HitAndRun::MINIMUM_IGNORE_USER_CLASS && !$isDonor && isset($torrent['mode'])) {
|
||||
//think about H&R
|
||||
// $hrMode = get_setting('hr.mode');
|
||||
$hrMode = \App\Models\HitAndRun::getConfig('mode', $torrent['mode']);
|
||||
if ($hrMode == \App\Models\HitAndRun::MODE_GLOBAL || ($hrMode == \App\Models\HitAndRun::MODE_MANUAL && $torrent['hr'] == \App\Models\Torrent::HR_YES)) {
|
||||
$sql = "insert into hit_and_runs (uid, torrent_id, snatched_id) values ($userid, $torrentid, {$snatchInfo['id']}) on duplicate key update updated_at = " . sqlesc(date('Y-m-d H:i:s'));
|
||||
$affectedRows = sql_query($sql);
|
||||
do_log("[INSERT_H&R], $sql, affectedRows: $affectedRows");
|
||||
if ($az['class'] < \App\Models\HitAndRun::MINIMUM_IGNORE_USER_CLASS && !$isDonor && isset($torrent['mode'])) {
|
||||
$includeRate = \App\Models\HitAndRun::getConfig('include_rate', $torrent['mode']);
|
||||
if ($includeRate === "" || $includeRate === null) {
|
||||
//not set yet
|
||||
$includeRate = 1;
|
||||
}
|
||||
$includeHr = false;
|
||||
if ($includeRate >= 1 && $event == "completed") {
|
||||
$includeHr = true;
|
||||
} elseif ($includeRate < 1 && $includeRate >= 0 && $seeder == "no" && ($left <= $torrent['size'] * (1 - $includeRate))) {
|
||||
$includeHr = true;
|
||||
}
|
||||
if ($includeHr) {
|
||||
$hrMode = \App\Models\HitAndRun::getConfig('mode', $torrent['mode']);
|
||||
if ($hrMode == \App\Models\HitAndRun::MODE_GLOBAL || ($hrMode == \App\Models\HitAndRun::MODE_MANUAL && $torrent['hr'] == \App\Models\Torrent::HR_YES)) {
|
||||
$sql = "insert into hit_and_runs (uid, torrent_id, snatched_id) values ($userid, $torrentid, {$snatchInfo['id']}) on duplicate key update updated_at = " . sqlesc(date('Y-m-d H:i:s'));
|
||||
$affectedRows = sql_query($sql);
|
||||
do_log("[INSERT_H&R], $sql, affectedRows: $affectedRows");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,8 @@ return [
|
||||
'ignore_when_ratio_reach_help' => 'The minimum sharing rate to meet the standard',
|
||||
'ban_user_when_counts_reach' => 'H&R counts limit',
|
||||
'ban_user_when_counts_reach_help' => 'The number of H&R reaches this value and the account will be disabled',
|
||||
'include_rate' => 'Require completion rate',
|
||||
'include_rate_help' => 'Count H&R only when the download completion rate (decimal between 0 ~ 1) reaches this value. Default: 1'
|
||||
],
|
||||
'seed_box' => [
|
||||
'tab_header' => 'SeedBox',
|
||||
|
||||
@@ -72,6 +72,8 @@ return [
|
||||
'ignore_when_ratio_reach_help' => '达标的最小分享率',
|
||||
'ban_user_when_counts_reach' => 'H&R 数量上限',
|
||||
'ban_user_when_counts_reach_help' => 'H&R 数量达到此值,账号会被禁用',
|
||||
'include_rate' => '计入完成率',
|
||||
'include_rate_help' => '当下载完成率(0 ~ 1 之间的小数)达到此值时才计入 H&R。默认:1'
|
||||
],
|
||||
'seed_box' => [
|
||||
'tab_header' => 'SeedBox',
|
||||
|
||||
@@ -72,6 +72,8 @@ return [
|
||||
'ignore_when_ratio_reach_help' => '達標的最小分享率',
|
||||
'ban_user_when_counts_reach' => 'H&R 數量上限',
|
||||
'ban_user_when_counts_reach_help' => 'H&R 數量達到此值,賬號會被禁用',
|
||||
'include_rate' => '計入完成率',
|
||||
'include_rate_help' => '當下載完成率(0 ~ 1 之間的小數)達到此值時才計入 H&R。默認:1'
|
||||
],
|
||||
'seed_box' => [
|
||||
'tab_header' => 'SeedBox',
|
||||
|
||||
Reference in New Issue
Block a user