mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 20:17:24 +08:00
improve claim settle
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Repositories\ClaimRepository;
|
use App\Repositories\ClaimRepository;
|
||||||
use App\Repositories\ExamRepository;
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
class ClaimSettle extends Command
|
class ClaimSettle extends Command
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ class Test extends Command
|
|||||||
// $r = $rep->getContinuousPoints(11);
|
// $r = $rep->getContinuousPoints(11);
|
||||||
|
|
||||||
$arr = [1,2];
|
$arr = [1,2];
|
||||||
$r = collect($arr)->map(fn($item) => $item * 2)->implode(',');
|
$r = Carbon::now()->format('d');
|
||||||
dd($r, $arr);
|
dd($r, $arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Console;
|
namespace App\Console;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Console\Scheduling\Schedule;
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||||
|
|
||||||
@@ -24,14 +25,15 @@ class Kernel extends ConsoleKernel
|
|||||||
*/
|
*/
|
||||||
protected function schedule(Schedule $schedule)
|
protected function schedule(Schedule $schedule)
|
||||||
{
|
{
|
||||||
$schedule->command('exam:assign_cronjob')->everyMinute();
|
$schedule->command('exam:assign_cronjob')->everyMinute()->withoutOverlapping();
|
||||||
$schedule->command('exam:checkout_cronjob')->everyMinute();
|
$schedule->command('exam:checkout_cronjob')->everyMinute()->withoutOverlapping();
|
||||||
$schedule->command('exam:update_progress --bulk=1')->hourly();
|
$schedule->command('exam:update_progress --bulk=1')->hourly()->withoutOverlapping();
|
||||||
$schedule->command('backup:cronjob')->everyMinute();
|
$schedule->command('backup:cronjob')->everyMinute()->withoutOverlapping();
|
||||||
$schedule->command('hr:update_status')->everyMinute();
|
$schedule->command('hr:update_status')->everyMinute()->withoutOverlapping();
|
||||||
$schedule->command('hr:update_status --ignore_time=1')->hourly();
|
$schedule->command('hr:update_status --ignore_time=1')->hourly()->withoutOverlapping();
|
||||||
$schedule->command('user:delete_expired_token')->dailyAt('04:00');
|
$schedule->command('user:delete_expired_token')->dailyAt('04:00');
|
||||||
$schedule->command('claim:settle')->monthlyOn();
|
$schedule->command('claim:settle')->hourly()->between("00:00", "12:00")
|
||||||
|
->when(function () {Carbon::now()->format('d') == '01';})->withoutOverlapping();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ class Claim extends NexusModel
|
|||||||
return $this->belongsTo(Snatch::class, 'snatched_id');
|
return $this->belongsTo(Snatch::class, 'snatched_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getConfigIsEnabled(): bool
|
||||||
|
{
|
||||||
|
return Setting::get('torrent.claim_enabled', 'no') == 'yes';
|
||||||
|
}
|
||||||
|
|
||||||
public static function getConfigTorrentTTL()
|
public static function getConfigTorrentTTL()
|
||||||
{
|
{
|
||||||
return Setting::get('torrent.claim_torrent_ttl', self::TORRENT_TTL);
|
return Setting::get('torrent.claim_torrent_ttl', self::TORRENT_TTL);
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Repositories;
|
namespace App\Repositories;
|
||||||
|
|
||||||
use App\Models\BonusLogs;
|
|
||||||
use App\Models\Claim;
|
use App\Models\Claim;
|
||||||
use App\Models\Message;
|
use App\Models\Message;
|
||||||
use App\Models\Setting;
|
|
||||||
use App\Models\Snatch;
|
use App\Models\Snatch;
|
||||||
use App\Models\Torrent;
|
use App\Models\Torrent;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use JetBrains\PhpStorm\ArrayShape;
|
|
||||||
use Nexus\Database\NexusDB;
|
use Nexus\Database\NexusDB;
|
||||||
|
|
||||||
class ClaimRepository extends BaseRepository
|
class ClaimRepository extends BaseRepository
|
||||||
@@ -27,6 +24,10 @@ class ClaimRepository extends BaseRepository
|
|||||||
|
|
||||||
public function store($uid, $torrentId)
|
public function store($uid, $torrentId)
|
||||||
{
|
{
|
||||||
|
$isEnabled = Claim::getConfigIsEnabled();
|
||||||
|
if ($isEnabled) {
|
||||||
|
throw new \RuntimeException(nexus_trans("torrent.claim_disabled"));
|
||||||
|
}
|
||||||
$exists = Claim::query()->where('uid', $uid)->where('torrent_id', $torrentId)->exists();
|
$exists = Claim::query()->where('uid', $uid)->where('torrent_id', $torrentId)->exists();
|
||||||
if ($exists) {
|
if ($exists) {
|
||||||
throw new \RuntimeException(nexus_trans("torrent.claim_already"));
|
throw new \RuntimeException(nexus_trans("torrent.claim_already"));
|
||||||
@@ -34,7 +35,12 @@ class ClaimRepository extends BaseRepository
|
|||||||
$max = Claim::getConfigTorrentUpLimit();
|
$max = Claim::getConfigTorrentUpLimit();
|
||||||
$count = Claim::query()->where('uid', $uid)->count();
|
$count = Claim::query()->where('uid', $uid)->count();
|
||||||
if ($count >= $max) {
|
if ($count >= $max) {
|
||||||
throw new \RuntimeException(nexus_trans("torrent.claim_number_reach_maximum"));
|
throw new \RuntimeException(nexus_trans("torrent.claim_number_reach_torrent_maximum"));
|
||||||
|
}
|
||||||
|
$max = Claim::getConfigUserUpLimit();
|
||||||
|
$count = Claim::query()->where('torrent_id', $torrentId)->count();
|
||||||
|
if ($count >= $max) {
|
||||||
|
throw new \RuntimeException(nexus_trans("torrent.claim_number_reach_user_maximum"));
|
||||||
}
|
}
|
||||||
$snatch = Snatch::query()->where('userid', $uid)->where('torrentid', $torrentId)->first();
|
$snatch = Snatch::query()->where('userid', $uid)->where('torrentid', $torrentId)->first();
|
||||||
if (!$snatch) {
|
if (!$snatch) {
|
||||||
@@ -70,6 +76,10 @@ class ClaimRepository extends BaseRepository
|
|||||||
|
|
||||||
public function delete($id, $uid)
|
public function delete($id, $uid)
|
||||||
{
|
{
|
||||||
|
$isEnabled = Claim::getConfigIsEnabled();
|
||||||
|
if ($isEnabled) {
|
||||||
|
throw new \RuntimeException(nexus_trans("torrent.claim_disabled"));
|
||||||
|
}
|
||||||
$model = Claim::query()->findOrFail($id);
|
$model = Claim::query()->findOrFail($id);
|
||||||
if ($model->uid != $uid) {
|
if ($model->uid != $uid) {
|
||||||
throw new \RuntimeException("No permission");
|
throw new \RuntimeException("No permission");
|
||||||
@@ -93,29 +103,38 @@ class ClaimRepository extends BaseRepository
|
|||||||
|
|
||||||
public function settleCronjob(): array
|
public function settleCronjob(): array
|
||||||
{
|
{
|
||||||
$query = Claim::query()->select(['uid'])->groupBy('uid');
|
$startOfThisMonth = Carbon::now()->startOfMonth();
|
||||||
|
$query = Claim::query()
|
||||||
|
->select(['uid'])
|
||||||
|
->where('last_settle_at', '<', $startOfThisMonth)
|
||||||
|
->groupBy('uid')
|
||||||
|
;
|
||||||
$size = 10000;
|
$size = 10000;
|
||||||
$page = 1;
|
|
||||||
$successCount = $failCount = 0;
|
$successCount = $failCount = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
$logPrefix = "page: $page, size: $size";
|
$logPrefix = "size: $size";
|
||||||
$result = (clone $query)->forPage($page, $size)->get();
|
$result = (clone $query)->take($size)->get();
|
||||||
if ($result->isEmpty()) {
|
if ($result->isEmpty()) {
|
||||||
do_log("$logPrefix, no more data...");
|
do_log("$logPrefix, no more data...");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
do_log("get counts: " . $result->count());
|
||||||
foreach ($result as $row) {
|
foreach ($result as $row) {
|
||||||
$uid = $row->uid;
|
$uid = $row->uid;
|
||||||
do_log("$logPrefix, begin to settle user: $uid...");
|
do_log("$logPrefix, begin to settle user: $uid...");
|
||||||
$result = $this->settleUser($row->uid);
|
try {
|
||||||
do_log("$logPrefix, settle user: $uid done!, result: " . var_export($result, true));
|
$result = $this->settleUser($uid);
|
||||||
if ($result) {
|
do_log("$logPrefix, settle user: $uid done!, result: " . var_export($result, true));
|
||||||
$successCount++;
|
if ($result) {
|
||||||
} else {
|
$successCount++;
|
||||||
|
} else {
|
||||||
|
$failCount++;
|
||||||
|
}
|
||||||
|
} catch (\Throwable $exception) {
|
||||||
|
do_log("$logPrefix, settle user: $uid fail!, error: " . $exception->getMessage() . $exception->getTraceAsString(), 'error');
|
||||||
$failCount++;
|
$failCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$page++;
|
|
||||||
}
|
}
|
||||||
return ['success_count' => $successCount, 'fail_count' => $failCount];
|
return ['success_count' => $successCount, 'fail_count' => $failCount];
|
||||||
}
|
}
|
||||||
@@ -185,6 +204,12 @@ class ClaimRepository extends BaseRepository
|
|||||||
$totalDeduct = $bonusDeduct * count($unReachedIdArr);
|
$totalDeduct = $bonusDeduct * count($unReachedIdArr);
|
||||||
do_log("totalDeduct: $totalDeduct", 'alert');
|
do_log("totalDeduct: $totalDeduct", 'alert');
|
||||||
|
|
||||||
|
$message = $this->buildMessage(
|
||||||
|
$user, $reachedTorrentIdArr, $unReachedTorrentIdArr, $remainTorrentIdArr,
|
||||||
|
$bonusResult, $bonusFinal, $seedTimeHoursAvg, $bonusDeduct, $totalDeduct
|
||||||
|
);
|
||||||
|
do_log("message: " . nexus_json_encode($message), 'alert');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Just do a test, debug from log
|
* Just do a test, debug from log
|
||||||
*/
|
*/
|
||||||
@@ -193,35 +218,50 @@ class ClaimRepository extends BaseRepository
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Increase user bonus
|
//Wrap with transaction
|
||||||
User::query()->where('id', $uid)->increment('seedbonus', $bonusFinal);
|
DB::transaction(function () use ($uid, $unReachedIdArr, $toUpdateIdArr, $bonusFinal, $totalDeduct, $uploadedCaseWhen, $seedTimeCaseWhen, $message, $now) {
|
||||||
do_log("Increase user bonus: $bonusFinal", 'alert');
|
//Increase user bonus
|
||||||
|
User::query()->where('id', $uid)->increment('seedbonus', $bonusFinal);
|
||||||
|
do_log("Increase user bonus: $bonusFinal", 'alert');
|
||||||
|
|
||||||
//Handle unreached
|
//Handle unreached
|
||||||
if (!empty($unReachedIdArr)) {
|
if (!empty($unReachedIdArr)) {
|
||||||
Claim::query()->whereIn('id', $unReachedIdArr)->delete();
|
Claim::query()->whereIn('id', $unReachedIdArr)->delete();
|
||||||
User::query()->where('id', $uid)->decrement('seedbonus', $totalDeduct);
|
User::query()->where('id', $uid)->decrement('seedbonus', $totalDeduct);
|
||||||
do_log("Deduct user bonus: $totalDeduct", 'alert');
|
do_log("Deduct user bonus: $totalDeduct", 'alert');
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update claim `last_settle_at` and init `seed_time_begin` & `uploaded_begin`
|
//Update claim `last_settle_at` and init `seed_time_begin` & `uploaded_begin`
|
||||||
$sql = sprintf(
|
$sql = sprintf(
|
||||||
"update claims set uploaded_begin = case id %s end, seed_time_begin = case id %s end, last_settle_at = '%s', updated_at = '%s' where id in (%s)",
|
"update claims set uploaded_begin = case id %s end, seed_time_begin = case id %s end, last_settle_at = '%s', updated_at = '%s' where id in (%s)",
|
||||||
implode(' ', $uploadedCaseWhen), implode(' ', $seedTimeCaseWhen), $now->toDateTimeString(), $now->toDateTimeString(), implode(',', $toUpdateIdArr)
|
implode(' ', $uploadedCaseWhen), implode(' ', $seedTimeCaseWhen), $now->toDateTimeString(), $now->toDateTimeString(), implode(',', $toUpdateIdArr)
|
||||||
);
|
);
|
||||||
$affectedRows = DB::update($sql);
|
$affectedRows = DB::update($sql);
|
||||||
do_log("query: $sql, affectedRows: $affectedRows");
|
do_log("query: $sql, affectedRows: $affectedRows");
|
||||||
|
|
||||||
//Send message
|
//Send message
|
||||||
|
Message::query()->insert($message);
|
||||||
|
});
|
||||||
|
do_log("[DONE], cost time: " . (time() - $now->timestamp) . " seconds");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildMessage(
|
||||||
|
User $user, $reachedTorrentIdArr, $unReachedTorrentIdArr, $remainTorrentIdArr,
|
||||||
|
$bonusResult, $bonusFinal, $seedTimeHoursAvg, $deductPerTorrent, $deductTotal
|
||||||
|
) {
|
||||||
|
$now = Carbon::now();
|
||||||
|
$allTorrentIdArr = array_merge($reachedTorrentIdArr, $unReachedTorrentIdArr, $remainTorrentIdArr);
|
||||||
$torrentInfo = Torrent::query()
|
$torrentInfo = Torrent::query()
|
||||||
->whereIn('id', array_merge($reachedTorrentIdArr, $unReachedTorrentIdArr, $remainTorrentIdArr))
|
->whereIn('id', $allTorrentIdArr)
|
||||||
->get(Torrent::$commentFields)
|
->get(Torrent::$commentFields)
|
||||||
->keyBy('id')
|
->keyBy('id')
|
||||||
;
|
;
|
||||||
$msg = [];
|
$msg = [];
|
||||||
$locale = $user->locale;
|
$locale = $user->locale;
|
||||||
|
do_log("build message, user: {$user->id}, locale: $locale");
|
||||||
$msg[] = nexus_trans('claim.msg_title', ['month' => $now->clone()->subMonths(1)->format('Y-m')], $locale);
|
$msg[] = nexus_trans('claim.msg_title', ['month' => $now->clone()->subMonths(1)->format('Y-m')], $locale);
|
||||||
$msg[] = nexus_trans('claim.claim_total', [ 'total' => $list->count()], $locale);
|
$msg[] = nexus_trans('claim.claim_total', [ 'total' => count($allTorrentIdArr)], $locale);
|
||||||
|
|
||||||
$reachList = collect($reachedTorrentIdArr)->map(
|
$reachList = collect($reachedTorrentIdArr)->map(
|
||||||
fn($item) => sprintf("[url=details.php?id=%s]%s[/url]", $item, $torrentInfo->get($item)->name)
|
fn($item) => sprintf("[url=details.php?id=%s]%s[/url]", $item, $torrentInfo->get($item)->name)
|
||||||
@@ -229,10 +269,10 @@ class ClaimRepository extends BaseRepository
|
|||||||
$msg[] = nexus_trans("claim.claim_reached_counts", ['counts' => count($reachedTorrentIdArr)], $locale) . "\n$reachList";
|
$msg[] = nexus_trans("claim.claim_reached_counts", ['counts' => count($reachedTorrentIdArr)], $locale) . "\n$reachList";
|
||||||
$msg[] = nexus_trans(
|
$msg[] = nexus_trans(
|
||||||
"claim.claim_reached_summary", [
|
"claim.claim_reached_summary", [
|
||||||
'bonus_per_hour' => number_format($bonusResult['seed_bonus'], 2),
|
'bonus_per_hour' => number_format($bonusResult['seed_bonus'], 2),
|
||||||
'hours'=> number_format($seedTimeHoursAvg, 2),
|
'hours'=> number_format($seedTimeHoursAvg, 2),
|
||||||
'bonus_total'=> number_format($bonusFinal, 2)
|
'bonus_total'=> number_format($bonusFinal, 2)
|
||||||
], $locale
|
], $locale
|
||||||
);
|
);
|
||||||
|
|
||||||
$remainList = collect($remainTorrentIdArr)->map(
|
$remainList = collect($remainTorrentIdArr)->map(
|
||||||
@@ -244,24 +284,19 @@ class ClaimRepository extends BaseRepository
|
|||||||
fn($item) => sprintf("[url=details.php?id=%s]%s[/url]", $item, $torrentInfo->get($item)->name)
|
fn($item) => sprintf("[url=details.php?id=%s]%s[/url]", $item, $torrentInfo->get($item)->name)
|
||||||
)->implode("\n");
|
)->implode("\n");
|
||||||
$msg[] = nexus_trans("claim.claim_unreached_remove_counts", ['counts' => count($unReachedTorrentIdArr)], $locale) . "\n$unReachList";
|
$msg[] = nexus_trans("claim.claim_unreached_remove_counts", ['counts' => count($unReachedTorrentIdArr)], $locale) . "\n$unReachList";
|
||||||
if ($totalDeduct) {
|
if ($deductTotal) {
|
||||||
$msg[] = nexus_trans(
|
$msg[] = nexus_trans(
|
||||||
"claim.claim_unreached_summary", [
|
"claim.claim_unreached_summary", [
|
||||||
'deduct_per_torrent '=> number_format($bonusDeduct, 2),
|
'deduct_per_torrent '=> number_format($deductPerTorrent, 2),
|
||||||
'deduct_total' => number_format($totalDeduct, 2)
|
'deduct_total' => number_format($deductTotal, 2)
|
||||||
], $locale
|
], $locale
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
return [
|
||||||
$message = [
|
'receiver' => $user->id,
|
||||||
'receiver' => $uid,
|
|
||||||
'added' => $now,
|
'added' => $now,
|
||||||
'subject' => nexus_trans('claim.msg_subject', ['month' => $now->clone()->subMonths(1)->format('Y-m')], $locale),
|
'subject' => nexus_trans('claim.msg_subject', ['month' => $now->clone()->subMonths(1)->format('Y-m')], $locale),
|
||||||
'msg' => implode("\n\n", $msg),
|
'msg' => implode("\n\n", $msg),
|
||||||
];
|
];
|
||||||
Message::query()->insert($message);
|
|
||||||
|
|
||||||
do_log("[DONE], cost time: " . (time() - $now->timestamp) . " seconds");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ return new class extends Migration
|
|||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
|
if (Schema::hasTable('claims')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Schema::create('claims', function (Blueprint $table) {
|
Schema::create('claims', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->integer('uid');
|
$table->integer('uid');
|
||||||
@@ -20,7 +23,7 @@ return new class extends Migration
|
|||||||
$table->integer('snatched_id')->index();
|
$table->integer('snatched_id')->index();
|
||||||
$table->bigInteger('seed_time_begin')->default(0);
|
$table->bigInteger('seed_time_begin')->default(0);
|
||||||
$table->bigInteger('uploaded_begin')->default(0);
|
$table->bigInteger('uploaded_begin')->default(0);
|
||||||
$table->dateTime('last_settle_at')->nullable();
|
$table->dateTime('last_settle_at')->nullable()->index();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->unique(['uid', 'torrent_id']);
|
$table->unique(['uid', 'torrent_id']);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.8');
|
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.8');
|
||||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-05-05');
|
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-05-06');
|
||||||
defined('IN_TRACKER') || define('IN_TRACKER', true);
|
defined('IN_TRACKER') || define('IN_TRACKER', true);
|
||||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||||
|
|||||||
@@ -2598,7 +2598,7 @@ else {
|
|||||||
<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?>
|
<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?>
|
||||||
<font class='color_connectable'><?php echo $lang_functions['text_connectable'] ?></font><?php echo $connectable?> <?php echo maxslots();?>
|
<font class='color_connectable'><?php echo $lang_functions['text_connectable'] ?></font><?php echo $connectable?> <?php echo maxslots();?>
|
||||||
<?php if(\App\Models\HitAndRun::getIsEnabled()) { ?><font class='color_bonus'>H&R: </font> <?php echo sprintf('[<a href="myhr.php">%s</a>]', (new \App\Repositories\HitAndRunRepository())->getStatusStats($CURUSER['id']))?><?php }?>
|
<?php if(\App\Models\HitAndRun::getIsEnabled()) { ?><font class='color_bonus'>H&R: </font> <?php echo sprintf('[<a href="myhr.php">%s</a>]', (new \App\Repositories\HitAndRunRepository())->getStatusStats($CURUSER['id']))?><?php }?>
|
||||||
<font class='color_bonus'><?php echo $lang_functions['menu_claim']?></font> <?php echo sprintf('[<a href="claim.php?uid=%s">%s</a>]', $CURUSER['id'], (new \App\Repositories\ClaimRepository())->getStats($CURUSER['id']))?>
|
<?php if(\App\Models\Claim::getConfigIsEnabled()) { ?><font class='color_bonus'><?php echo $lang_functions['menu_claim']?></font> <?php echo sprintf('[<a href="claim.php?uid=%s">%s</a>]', $CURUSER['id'], (new \App\Repositories\ClaimRepository())->getStats($CURUSER['id']))?><?php }?>
|
||||||
<?php if(get_user_class() >= UC_SYSOP) { ?> [<a href="/admin" target="_blank"><?php echo $lang_functions['text_management_system'] ?></a>]<?php }?>
|
<?php if(get_user_class() >= UC_SYSOP) { ?> [<a href="/admin" target="_blank"><?php echo $lang_functions['text_management_system'] ?></a>]<?php }?>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -745,6 +745,7 @@ $lang_settings = array
|
|||||||
'row_show_top_uploader' => '显示最多上传(种子数)',
|
'row_show_top_uploader' => '显示最多上传(种子数)',
|
||||||
'text_show_top_uploader_note' => "默认'否'。在首页显示最多上传的用户(按种子数计算)。",
|
'text_show_top_uploader_note' => "默认'否'。在首页显示最多上传的用户(按种子数计算)。",
|
||||||
'claim_label' => '种子认领',
|
'claim_label' => '种子认领',
|
||||||
|
'claim_enabled' => '启用认领',
|
||||||
'claim_torrent_ttl' => '种子发布 %s 天后可以认领。',
|
'claim_torrent_ttl' => '种子发布 %s 天后可以认领。',
|
||||||
'claim_torrent_user_counts_up_limit' => '一个种子最多可以被 %s 个用户认领。',
|
'claim_torrent_user_counts_up_limit' => '一个种子最多可以被 %s 个用户认领。',
|
||||||
'claim_user_torrent_counts_up_limit' => '一个用户最多可以认领 %s 个种子。',
|
'claim_user_torrent_counts_up_limit' => '一个用户最多可以认领 %s 个种子。',
|
||||||
|
|||||||
@@ -744,6 +744,7 @@ $lang_settings = array
|
|||||||
'row_show_top_uploader' => '顯示最多上傳(種子數)',
|
'row_show_top_uploader' => '顯示最多上傳(種子數)',
|
||||||
'text_show_top_uploader_note' => "默認'否'。在首頁顯示最多上傳的用戶(按種子數計算)。",
|
'text_show_top_uploader_note' => "默認'否'。在首頁顯示最多上傳的用戶(按種子數計算)。",
|
||||||
'claim_label' => '種子認領',
|
'claim_label' => '種子認領',
|
||||||
|
'claim_enabled' => '啟用認領',
|
||||||
'claim_torrent_ttl' => '種子發布 %s 天後可以認領。',
|
'claim_torrent_ttl' => '種子發布 %s 天後可以認領。',
|
||||||
'claim_torrent_user_counts_up_limit' => '一個種子最多可以被 %s 個用戶認領。',
|
'claim_torrent_user_counts_up_limit' => '一個種子最多可以被 %s 個用戶認領。',
|
||||||
'claim_user_torrent_counts_up_limit' => '一個用戶最多可以認領 %s 個種子。',
|
'claim_user_torrent_counts_up_limit' => '一個用戶最多可以認領 %s 個種子。',
|
||||||
|
|||||||
@@ -744,6 +744,7 @@ $lang_settings = array
|
|||||||
'row_show_top_uploader' => 'Show top uploaded(Torrent count)',
|
'row_show_top_uploader' => 'Show top uploaded(Torrent count)',
|
||||||
'text_show_top_uploader_note' => "Default 'No'. Show top upload user(Torrent count) at homepage.",
|
'text_show_top_uploader_note' => "Default 'No'. Show top upload user(Torrent count) at homepage.",
|
||||||
'claim_label' => 'Torrent claim',
|
'claim_label' => 'Torrent claim',
|
||||||
|
'claim_enabled' => 'Claim enabled',
|
||||||
'claim_torrent_ttl' => 'Torrent can be claimed after %s of days of release.',
|
'claim_torrent_ttl' => 'Torrent can be claimed after %s of days of release.',
|
||||||
'claim_torrent_user_counts_up_limit' => 'A Torrent can be claimed by up to %s of users.',
|
'claim_torrent_user_counts_up_limit' => 'A Torrent can be claimed by up to %s of users.',
|
||||||
'claim_user_torrent_counts_up_limit' => 'A user can claim up to %s of torrents.',
|
'claim_user_torrent_counts_up_limit' => 'A user can claim up to %s of torrents.',
|
||||||
|
|||||||
@@ -322,6 +322,8 @@ return array (
|
|||||||
'minvotes' => '10',
|
'minvotes' => '10',
|
||||||
'sticky_first_level_background_color' => '#89c9e6',
|
'sticky_first_level_background_color' => '#89c9e6',
|
||||||
'sticky_second_level_background_color' => '#aadbf3',
|
'sticky_second_level_background_color' => '#aadbf3',
|
||||||
|
'download_support_passkey' => 'yes',
|
||||||
|
'claim_enabled' => 'no',
|
||||||
'claim_torrent_ttl' => \App\Models\Claim::TORRENT_TTL,
|
'claim_torrent_ttl' => \App\Models\Claim::TORRENT_TTL,
|
||||||
'claim_torrent_user_counts_up_limit' => \App\Models\Claim::USER_UP_LIMIT,
|
'claim_torrent_user_counts_up_limit' => \App\Models\Claim::USER_UP_LIMIT,
|
||||||
'claim_user_torrent_counts_up_limit' => \App\Models\Claim::TORRENT_UP_LIMIT,
|
'claim_user_torrent_counts_up_limit' => \App\Models\Claim::TORRENT_UP_LIMIT,
|
||||||
@@ -363,7 +365,6 @@ return array (
|
|||||||
'watermarkquality' => '85',
|
'watermarkquality' => '85',
|
||||||
'altthumbwidth' => '180',
|
'altthumbwidth' => '180',
|
||||||
'altthumbheight' => '135',
|
'altthumbheight' => '135',
|
||||||
'download_support_passkey' => 'yes',
|
|
||||||
),
|
),
|
||||||
'advertisement' =>
|
'advertisement' =>
|
||||||
array (
|
array (
|
||||||
|
|||||||
+1
-1
@@ -142,7 +142,7 @@ if (!$row) {
|
|||||||
|
|
||||||
// ------------- start claim block ------------------//
|
// ------------- start claim block ------------------//
|
||||||
$claimTorrentTTL = \App\Models\Claim::getConfigTorrentTTL();
|
$claimTorrentTTL = \App\Models\Claim::getConfigTorrentTTL();
|
||||||
if (\Carbon\Carbon::parse($row['added'])->addDays($claimTorrentTTL)->lte(\Carbon\Carbon::now())) {
|
if (\App\Models\Claim::getConfigIsEnabled() && \Carbon\Carbon::parse($row['added'])->addDays($claimTorrentTTL)->lte(\Carbon\Carbon::now())) {
|
||||||
$baseClaimQuery = \App\Models\Claim::query()->where('torrent_id', $id);
|
$baseClaimQuery = \App\Models\Claim::query()->where('torrent_id', $id);
|
||||||
$claimCounts = (clone $baseClaimQuery)->count();
|
$claimCounts = (clone $baseClaimQuery)->count();
|
||||||
$isClaimed = (clone $baseClaimQuery)->where('uid', $CURUSER['id'])->exists();
|
$isClaimed = (clone $baseClaimQuery)->where('uid', $CURUSER['id'])->exists();
|
||||||
|
|||||||
+2
-1
@@ -150,7 +150,7 @@ elseif($action == 'savesettings_torrent') // save account
|
|||||||
'expirefree','expiretwoup','expiretwoupfree','expiretwouphalfleech', 'expirenormal','hotdays','hotseeder','halfleechbecome','freebecome',
|
'expirefree','expiretwoup','expiretwoupfree','expiretwouphalfleech', 'expirenormal','hotdays','hotseeder','halfleechbecome','freebecome',
|
||||||
'twoupbecome','twoupfreebecome', 'twouphalfleechbecome','normalbecome','uploaderdouble','deldeadtorrent', 'randomthirtypercentdown',
|
'twoupbecome','twoupfreebecome', 'twouphalfleechbecome','normalbecome','uploaderdouble','deldeadtorrent', 'randomthirtypercentdown',
|
||||||
'thirtypercentleechbecome', 'expirethirtypercentleech', 'sticky_first_level_background_color', 'sticky_second_level_background_color',
|
'thirtypercentleechbecome', 'expirethirtypercentleech', 'sticky_first_level_background_color', 'sticky_second_level_background_color',
|
||||||
'download_support_passkey', 'claim_torrent_ttl', 'claim_torrent_user_counts_up_limit', 'claim_user_torrent_counts_up_limit', 'claim_remove_deduct_user_bonus',
|
'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'
|
'claim_give_up_deduct_user_bonus', 'claim_bonus_multiplier', 'claim_reach_standard_seed_time', 'claim_reach_standard_uploaded'
|
||||||
);
|
);
|
||||||
GetVar($validConfig);
|
GetVar($validConfig);
|
||||||
@@ -666,6 +666,7 @@ elseif ($action == 'torrentsettings')
|
|||||||
</ul>".$lang_settings['text_promotion_timeout_note_two'], 1);
|
</ul>".$lang_settings['text_promotion_timeout_note_two'], 1);
|
||||||
|
|
||||||
tr($lang_settings['claim_label'], "<ul>
|
tr($lang_settings['claim_label'], "<ul>
|
||||||
|
<li>".$lang_settings['claim_enabled'] . sprintf(' <label><input type="radio" name="claim_enabled" value="yes"%s/>Yes</label><label><input type="radio" name="claim_enabled" value="no"%s/>No</label>', $TORRENT['claim_enabled'] == 'yes' ? ' checked' : '', $TORRENT['claim_enabled'] == 'no' ? ' checked' : '')."</li>
|
||||||
<li>".sprintf($lang_settings['claim_torrent_ttl'], sprintf('<input type="number" name="claim_torrent_ttl" value="%s" style="width: 50px"/>', $TORRENT['claim_torrent_ttl'] ?? \App\Models\Claim::TORRENT_TTL))."</li>
|
<li>".sprintf($lang_settings['claim_torrent_ttl'], sprintf('<input type="number" name="claim_torrent_ttl" value="%s" style="width: 50px"/>', $TORRENT['claim_torrent_ttl'] ?? \App\Models\Claim::TORRENT_TTL))."</li>
|
||||||
<li>".sprintf($lang_settings['claim_torrent_user_counts_up_limit'], sprintf('<input type="number" name="claim_torrent_user_counts_up_limit" value="%s" style="width: 50px"/>', $TORRENT['claim_torrent_user_counts_up_limit'] ?? \App\Models\Claim::USER_UP_LIMIT))."</li>
|
<li>".sprintf($lang_settings['claim_torrent_user_counts_up_limit'], sprintf('<input type="number" name="claim_torrent_user_counts_up_limit" value="%s" style="width: 50px"/>', $TORRENT['claim_torrent_user_counts_up_limit'] ?? \App\Models\Claim::USER_UP_LIMIT))."</li>
|
||||||
<li>".sprintf($lang_settings['claim_user_torrent_counts_up_limit'], sprintf('<input type="number" name="claim_user_torrent_counts_up_limit" value="%s" style="width: 50px"/>', $TORRENT['claim_user_torrent_counts_up_limit'] ?? \App\Models\Claim::TORRENT_UP_LIMIT))."</li>
|
<li>".sprintf($lang_settings['claim_user_torrent_counts_up_limit'], sprintf('<input type="number" name="claim_user_torrent_counts_up_limit" value="%s" style="width: 50px"/>', $TORRENT['claim_user_torrent_counts_up_limit'] ?? \App\Models\Claim::TORRENT_UP_LIMIT))."</li>
|
||||||
|
|||||||
@@ -294,8 +294,8 @@ tr_small($lang_userdetails['row_torrent_comment'], ($torrentcomments && ($user["
|
|||||||
tr_small($lang_userdetails['row_forum_posts'], ($forumposts && ($user["id"] == $CURUSER["id"] || get_user_class() >= $viewhistory_class) ? "<a href=\"userhistory.php?action=viewposts&id=".$id."\" title=\"".$lang_userdetails['link_view_posts']."\">".$forumposts."</a>" : $forumposts), 1);
|
tr_small($lang_userdetails['row_forum_posts'], ($forumposts && ($user["id"] == $CURUSER["id"] || get_user_class() >= $viewhistory_class) ? "<a href=\"userhistory.php?action=viewposts&id=".$id."\" title=\"".$lang_userdetails['link_view_posts']."\">".$forumposts."</a>" : $forumposts), 1);
|
||||||
|
|
||||||
if ($user["id"] == $CURUSER["id"] || get_user_class() >= $viewhistory_class) {
|
if ($user["id"] == $CURUSER["id"] || get_user_class() >= $viewhistory_class) {
|
||||||
tr_small($lang_userdetails['row_karma_points'], htmlspecialchars($user['seedbonus']), 1);
|
tr_small($lang_userdetails['row_karma_points'], number_format($user['seedbonus'], 1), 1);
|
||||||
tr_small($lang_functions['text_seed_points'], htmlspecialchars($user['seed_points']), 1);
|
tr_small($lang_functions['text_seed_points'], number_format($user['seed_points'], 1), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -485,7 +485,7 @@ if (get_user_class() >= $prfmanage_class && $user["class"] < get_user_class())
|
|||||||
{
|
{
|
||||||
tr($lang_userdetails['row_amount_uploaded'], "<input type=\"text\" size=\"60\" name=\"uploaded\" value=\"" . htmlspecialchars($user['uploaded']) . "\" /><input type=\"hidden\" name=\"ori_uploaded\" value=\"" . htmlspecialchars($user['uploaded']) . "\" />", 1);
|
tr($lang_userdetails['row_amount_uploaded'], "<input type=\"text\" size=\"60\" name=\"uploaded\" value=\"" . htmlspecialchars($user['uploaded']) . "\" /><input type=\"hidden\" name=\"ori_uploaded\" value=\"" . htmlspecialchars($user['uploaded']) . "\" />", 1);
|
||||||
tr($lang_userdetails['row_amount_downloaded'], "<input type=\"text\" size=\"60\" name=\"downloaded\" value=\"" .htmlspecialchars($user['downloaded']) . "\" /><input type=\"hidden\" name=\"ori_downloaded\" value=\"" .htmlspecialchars($user['downloaded']) . "\" />", 1);
|
tr($lang_userdetails['row_amount_downloaded'], "<input type=\"text\" size=\"60\" name=\"downloaded\" value=\"" .htmlspecialchars($user['downloaded']) . "\" /><input type=\"hidden\" name=\"ori_downloaded\" value=\"" .htmlspecialchars($user['downloaded']) . "\" />", 1);
|
||||||
tr($lang_userdetails['row_seeding_karma'], "<input type=\"text\" size=\"60\" name=\"bonus\" value=\"" .htmlspecialchars($user['seedbonus']) . "\" /><input type=\"hidden\" name=\"ori_bonus\" value=\"" .htmlspecialchars($user['seedbonus']) . "\" />", 1);
|
tr($lang_userdetails['row_seeding_karma'], "<input type=\"text\" size=\"60\" name=\"bonus\" value=\"" .number_format($user['seedbonus'], 1) . "\" /><input type=\"hidden\" name=\"ori_bonus\" value=\"" .number_format($user['seedbonus'], 1) . "\" />", 1);
|
||||||
tr($lang_userdetails['row_invites'], "<input type=\"text\" size=\"60\" name=\"invites\" value=\"" .htmlspecialchars($user['invites']) . "\" />", 1);
|
tr($lang_userdetails['row_invites'], "<input type=\"text\" size=\"60\" name=\"invites\" value=\"" .htmlspecialchars($user['invites']) . "\" />", 1);
|
||||||
}
|
}
|
||||||
tr($lang_userdetails['row_passkey'], "<input name=\"resetkey\" value=\"yes\" type=\"checkbox\" />".$lang_userdetails['checkbox_reset_passkey'], 1);
|
tr($lang_userdetails['row_passkey'], "<input name=\"resetkey\" value=\"yes\" type=\"checkbox\" />".$lang_userdetails['checkbox_reset_passkey'], 1);
|
||||||
|
|||||||
@@ -41,5 +41,7 @@ return [
|
|||||||
'claim_already' => 'Claimed already',
|
'claim_already' => 'Claimed already',
|
||||||
'no_snatch' => 'Never download this torrent yet',
|
'no_snatch' => 'Never download this torrent yet',
|
||||||
'can_no_be_claimed_yet' => 'Can not be claimed yet',
|
'can_no_be_claimed_yet' => 'Can not be claimed yet',
|
||||||
'claim_number_reach_maximum' => 'The maximum number of torrent claimed is reached',
|
'claim_number_reach_user_maximum' => 'The maximum number of user is reached',
|
||||||
|
'claim_number_reach_torrent_maximum' => 'The maximum number of torrent is reached',
|
||||||
|
'claim_disabled' => 'Claim is disabled',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -41,5 +41,7 @@ return [
|
|||||||
'claim_already' => '此种子已经认领',
|
'claim_already' => '此种子已经认领',
|
||||||
'no_snatch' => '没有下载过此种子',
|
'no_snatch' => '没有下载过此种子',
|
||||||
'can_no_be_claimed_yet' => '还不能被认领',
|
'can_no_be_claimed_yet' => '还不能被认领',
|
||||||
'claim_number_reach_maximum' => '认领种子数达到上限',
|
'claim_number_reach_user_maximum' => '认领达到人数上限',
|
||||||
|
'claim_number_reach_torrent_maximum' => '认领达到种子数上限',
|
||||||
|
'claim_disabled' => '认领未启用',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -41,5 +41,7 @@ return [
|
|||||||
'claim_already' => '此種子已經認領',
|
'claim_already' => '此種子已經認領',
|
||||||
'no_snatch' => '沒有下載過此種子',
|
'no_snatch' => '沒有下載過此種子',
|
||||||
'can_no_be_claimed_yet' => '還不能被認領',
|
'can_no_be_claimed_yet' => '還不能被認領',
|
||||||
'claim_number_reach_maximum' => '認領種子數達到上限',
|
'claim_number_reach_user_maximum' => '認領達到人數上限',
|
||||||
|
'claim_number_reach_torrent_maximum' => '認領達到種子數上限',
|
||||||
|
'claim_disabled' => '認領未啟用',
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user