admin user add link + upload over speed msg

This commit is contained in:
xiaomlove
2022-10-06 18:19:39 +08:00
parent 2737302281
commit fac5ad3cc8
17 changed files with 67 additions and 18 deletions

View File

@@ -12,6 +12,7 @@ use Filament\Resources\Table;
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Support\HtmlString;
class UsernameChangeLogResource extends Resource
{
@@ -50,8 +51,15 @@ class UsernameChangeLogResource extends Resource
Tables\Columns\TextColumn::make('uid')->searchable(),
Tables\Columns\TextColumn::make('user.username')->searchable()->label(__('label.username')),
Tables\Columns\TextColumn::make('username_old')->searchable()->label(__('username-change-log.labels.username_old')),
Tables\Columns\TextColumn::make('username_new')->searchable()->label(__('username-change-log.labels.username_new')),
Tables\Columns\TextColumn::make('operator')->searchable()->label(__('label.operator')),
Tables\Columns\TextColumn::make('username_new')
->searchable()
->label(__('username-change-log.labels.username_new'))
->formatStateUsing(fn ($record) => new HtmlString(get_username($record->id, false, true, true, true)))
,
Tables\Columns\TextColumn::make('operator')
->searchable()
->label(__('label.operator'))
,
Tables\Columns\TextColumn::make('created_at')->label(__('label.created_at'))->formatStateUsing(fn ($state) => format_datetime($state)),
])

View File

@@ -103,8 +103,7 @@ class TorrentResource extends Resource
Tables\Columns\TextColumn::make('added')->label(__('label.added'))->dateTime(),
Tables\Columns\TextColumn::make('user.username')
->label(__('label.torrent.owner'))
->url(fn ($record) => sprintf('/userdetails.php?id=%s', $record->owner))
->openUrlInNewTab(true)
->formatStateUsing(fn ($record) => new HtmlString(get_username($record->owner, false, true, true, true)))
,
])
->defaultSort('id', 'desc')

View File

@@ -13,6 +13,7 @@ use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Support\HtmlString;
class ClaimResource extends Resource
{
@@ -48,7 +49,11 @@ class ClaimResource extends Resource
->columns([
Tables\Columns\TextColumn::make('id')->sortable(),
Tables\Columns\TextColumn::make('uid')->searchable(),
Tables\Columns\TextColumn::make('user.username')->label(__('label.user.label'))->searchable(),
Tables\Columns\TextColumn::make('user.username')
->label(__('label.user.label'))
->searchable()
->formatStateUsing(fn ($record) => new HtmlString(get_username($record->id, false, true, true, true)))
,
Tables\Columns\TextColumn::make('torrent.name')->limit(40)->label(__('label.torrent.label'))->searchable(),
Tables\Columns\TextColumn::make('torrent.size')->label(__('label.torrent.size'))->formatStateUsing(fn (Model $record) => mksize($record->torrent->size)),
Tables\Columns\TextColumn::make('torrent.added')->label(__('label.torrent.ttl'))->formatStateUsing(fn (Model $record) => mkprettytime($record->torrent->added->diffInSeconds())),

View File

@@ -16,6 +16,7 @@ use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\HtmlString;
class ExamUserResource extends Resource
{
@@ -51,7 +52,11 @@ class ExamUserResource extends Resource
->columns([
Tables\Columns\TextColumn::make('id')->sortable(),
Tables\Columns\TextColumn::make('uid')->searchable(),
Tables\Columns\TextColumn::make('user.username')->label(__('label.username'))->searchable(),
Tables\Columns\TextColumn::make('user.username')
->label(__('label.username'))
->searchable()
->formatStateUsing(fn ($record) => new HtmlString(get_username($record->id, false, true, true, true)))
,
Tables\Columns\TextColumn::make('exam.name')->label(__('label.exam.label')),
Tables\Columns\TextColumn::make('begin')->label(__('label.begin'))->dateTime(),
Tables\Columns\TextColumn::make('end')->label(__('label.end'))->dateTime(),

View File

@@ -15,6 +15,7 @@ use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\HtmlString;
class HitAndRunResource extends Resource
{
@@ -42,7 +43,12 @@ class HitAndRunResource extends Resource
->columns([
Tables\Columns\TextColumn::make('id')->sortable(),
Tables\Columns\TextColumn::make('uid')->searchable(),
Tables\Columns\TextColumn::make('user.username')->searchable()->label(__('label.username')),
Tables\Columns\TextColumn::make('user.username')
->searchable()
->label(__('label.username'))
->formatStateUsing(fn ($record) => new HtmlString(get_username($record->id, false, true, true, true)))
,
Tables\Columns\TextColumn::make('torrent.name')->limit(30)->label(__('label.torrent.label')),
Tables\Columns\TextColumn::make('snatch.uploadText')->label(__('label.uploaded')),
Tables\Columns\TextColumn::make('snatch.downloadText')->label(__('label.downloaded')),

View File

@@ -12,6 +12,7 @@ use Filament\Resources\Table;
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Support\HtmlString;
class UserMedalResource extends Resource
{
@@ -47,7 +48,11 @@ class UserMedalResource extends Resource
->columns([
Tables\Columns\TextColumn::make('id')->sortable(),
Tables\Columns\TextColumn::make('uid')->searchable(),
Tables\Columns\TextColumn::make('user.username')->label(__('label.username'))->searchable(),
Tables\Columns\TextColumn::make('user.username')
->label(__('label.username'))
->searchable()
->formatStateUsing(fn ($record) => new HtmlString(get_username($record->id, false, true, true, true)))
,
Tables\Columns\TextColumn::make('medal.name')->label(__('label.medal.label'))->searchable(),
Tables\Columns\ImageColumn::make('medal.image_large')->label(__('label.image')),
Tables\Columns\TextColumn::make('expire_at')->label(__('label.expire_at'))->dateTime(),

View File

@@ -61,7 +61,7 @@ class UserResource extends Resource
->columns([
Tables\Columns\TextColumn::make('id')->sortable()->searchable(),
Tables\Columns\TextColumn::make('username')->searchable()->label(__("label.user.username"))
->formatStateUsing(fn ($record) => new HtmlString(get_username($record->id, false, true, false, true))),
->formatStateUsing(fn ($record) => new HtmlString(get_username($record->id, false, true, true, true))),
Tables\Columns\TextColumn::make('email')->searchable()->label(__("label.email")),
Tables\Columns\TextColumn::make('class')->label('Class')
->formatStateUsing(fn(Tables\Columns\Column $column) => $column->getRecord()->classText)

View File

@@ -26,6 +26,11 @@ class HitAndRun extends NexusModel
self::STATUS_PARDONED => ['text' => 'Pardoned'],
];
const CAN_PARDON_STATUS = [
self::STATUS_INSPECTING,
self::STATUS_UNREACHED,
];
const MODE_DISABLED = 'disabled';
const MODE_MANUAL = 'manual';
const MODE_GLOBAL = 'global';

View File

@@ -464,7 +464,7 @@ class HitAndRunRepository extends BaseRepository
private function getCanPardonStatus(): array
{
return [HitAndRun::STATUS_INSPECTING, HitAndRun::STATUS_UNREACHED];
return HitAndRun::CAN_PARDON_STATUS;
}
public function renderOnUploadPage($value, $searchBoxId): string

View File

@@ -593,7 +593,7 @@ class TrackerRepository extends BaseRepository
$notSeedBoxMaxSpeedMbps = Setting::get('seed_box.not_seed_box_max_speed');
do_log("upSpeedMbps: $upSpeedMbps, notSeedBoxMaxSpeedMbps: $notSeedBoxMaxSpeedMbps");
if ($upSpeedMbps > $notSeedBoxMaxSpeedMbps) {
(new \App\Repositories\UserRepository())->updateDownloadPrivileges(null, $user, 'no');
(new \App\Repositories\UserRepository())->updateDownloadPrivileges(null, $user, 'no', 'upload_over_speed');
do_log("user: {$user->id} downloading privileges have been disabled! (over speed)", 'error');
throw new TrackerException("Your downloading privileges have been disabled! (over speed)");
}

View File

@@ -326,7 +326,7 @@ class UserRepository extends BaseRepository
}
public function updateDownloadPrivileges($operator, $user, $status)
public function updateDownloadPrivileges($operator, $user, $status, $disableReasonKey = null)
{
if (!in_array($status, ['yes', 'no'])) {
throw new \InvalidArgumentException("Invalid status: $status");
@@ -345,8 +345,12 @@ class UserRepository extends BaseRepository
if ($status == 'no') {
$update = ['downloadpos' => 'no'];
$modComment = date('Y-m-d') . " - Download disable by " . $operatorUsername;
$message['subject'] = nexus_trans('message.download_disable.subject', [], $targetUser->locale);
$message['msg'] = nexus_trans('message.download_disable.body', ['operator' => $operatorUsername], $targetUser->locale);
$msgTransPrefix = "message.download_disable";
if ($disableReasonKey !== null) {
$msgTransPrefix .= "_$disableReasonKey";
}
$message['subject'] = nexus_trans("$msgTransPrefix.subject", [], $targetUser->locale);
$message['msg'] = nexus_trans("$msgTransPrefix.body", ['operator' => $operatorUsername], $targetUser->locale);
} else {
$update = ['downloadpos' => 'yes'];
$modComment = date('Y-m-d') . " - Download enable by " . $operatorUsername;

View File

@@ -1,6 +1,6 @@
<?php
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.28');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-10-04');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-10-06');
defined('IN_TRACKER') || define('IN_TRACKER', false);
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");

View File

@@ -405,7 +405,7 @@ else // continue an existing session
$upSpeedMbps = number_format(($trueupthis / $self['announcetime'] / 1024 / 1024) * 8);
do_log("notSeedBoxMaxSpeedMbps: $notSeedBoxMaxSpeedMbps, upSpeedMbps: $upSpeedMbps");
if ($upSpeedMbps > $notSeedBoxMaxSpeedMbps) {
(new \App\Repositories\UserRepository())->updateDownloadPrivileges(null, $userid, 'no');
(new \App\Repositories\UserRepository())->updateDownloadPrivileges(null, $userid, 'no', 'upload_over_speed');
do_log("user: $userid downloading privileges have been disabled! (over speed), notSeedBoxMaxSpeedMbps: $notSeedBoxMaxSpeedMbps > upSpeedMbps: $upSpeedMbps", 'error');
err("Your downloading privileges have been disabled! (over speed)");
}

View File

@@ -83,7 +83,7 @@ if ($rescount) {
$hasActionRemove = false;
foreach($list as $row) {
$columnAction = '<td class="rowfollow nowrap" align="center">';
if ($row->uid == $CURUSER['id'] && $row->status == \App\Models\HitAndRun::STATUS_INSPECTING) {
if ($row->uid == $CURUSER['id'] && in_array($row->status, \App\Models\HitAndRun::CAN_PARDON_STATUS)) {
$hasActionRemove = true;
$columnAction .= sprintf('<input class="remove-hr" type="button" value="%s" data-id="%s">', $lang_myhr['action_remove'], $row->id);
}

View File

@@ -12,9 +12,13 @@ return [
'field_value_change_message_subject' => ':field changed',
'download_disable' => [
'subject' => 'Download permission cancellation',
'subject' => 'Download permission canceled',
'body' => 'Your download privileges has revoked, possibly due to low sharing rates or misbehavior. By: :operator',
],
'download_disable_upload_over_speed' => [
'subject' => 'Download permission canceled',
'body' => 'Your download permission has been cancelled due to excessive upload speed, please file if you are a seed box user.' ,
],
'download_enable' => [
'subject' => 'Download permission restored',
'body' => 'Your download privileges restored, you can now download torrents. By: :operator',

View File

@@ -15,6 +15,10 @@ return [
'subject' => '下载权限取消',
'body' => '你的下载权限被取消可能的原因是过低的分享率或行为不当。By: :operator',
],
'download_disable_upload_over_speed' => [
'subject' => '下载权限取消',
'body' => '你因上传速度过快下载权限被取消,若是盒子用户请备案。',
],
'download_enable' => [
'subject' => '下载权限恢复',
'body' => '你的下载权限恢复你现在可以下载种子。By: :operator',

View File

@@ -14,6 +14,10 @@ return [
'subject' => '下載權限取消',
'body' => '你的下載權限被取消可能的原因是過低的分享率或行為不當。By: :operator',
],
'download_disable_upload_over_speed' => [
'subject' => '下載權限取消',
'body' => '你因上傳速度過快下載權限被取消,若是盒子用戶請備案。',
],
'download_enable' => [
'subject' => '下載權限恢復',
'body' => '你的下載權限恢復你現在可以下載種子。By: :operator',