diff --git a/app/Filament/Resources/System/UsernameChangeLogResource.php b/app/Filament/Resources/System/UsernameChangeLogResource.php index f9a5e6a6..57e2cc47 100644 --- a/app/Filament/Resources/System/UsernameChangeLogResource.php +++ b/app/Filament/Resources/System/UsernameChangeLogResource.php @@ -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)), ]) diff --git a/app/Filament/Resources/Torrent/TorrentResource.php b/app/Filament/Resources/Torrent/TorrentResource.php index f4b09701..04771692 100644 --- a/app/Filament/Resources/Torrent/TorrentResource.php +++ b/app/Filament/Resources/Torrent/TorrentResource.php @@ -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') diff --git a/app/Filament/Resources/User/ClaimResource.php b/app/Filament/Resources/User/ClaimResource.php index d7970ce8..f0b77c1f 100644 --- a/app/Filament/Resources/User/ClaimResource.php +++ b/app/Filament/Resources/User/ClaimResource.php @@ -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())), diff --git a/app/Filament/Resources/User/ExamUserResource.php b/app/Filament/Resources/User/ExamUserResource.php index b1b24dae..e8a2226b 100644 --- a/app/Filament/Resources/User/ExamUserResource.php +++ b/app/Filament/Resources/User/ExamUserResource.php @@ -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(), diff --git a/app/Filament/Resources/User/HitAndRunResource.php b/app/Filament/Resources/User/HitAndRunResource.php index 654df0cb..cca3645a 100644 --- a/app/Filament/Resources/User/HitAndRunResource.php +++ b/app/Filament/Resources/User/HitAndRunResource.php @@ -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')), diff --git a/app/Filament/Resources/User/UserMedalResource.php b/app/Filament/Resources/User/UserMedalResource.php index 7d83cfc4..c790aa38 100644 --- a/app/Filament/Resources/User/UserMedalResource.php +++ b/app/Filament/Resources/User/UserMedalResource.php @@ -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(), diff --git a/app/Filament/Resources/User/UserResource.php b/app/Filament/Resources/User/UserResource.php index e2f86cde..9e32fc54 100644 --- a/app/Filament/Resources/User/UserResource.php +++ b/app/Filament/Resources/User/UserResource.php @@ -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) diff --git a/app/Models/HitAndRun.php b/app/Models/HitAndRun.php index 621a53d6..c93fc77c 100644 --- a/app/Models/HitAndRun.php +++ b/app/Models/HitAndRun.php @@ -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'; diff --git a/app/Repositories/HitAndRunRepository.php b/app/Repositories/HitAndRunRepository.php index 52f3bf37..567898e9 100644 --- a/app/Repositories/HitAndRunRepository.php +++ b/app/Repositories/HitAndRunRepository.php @@ -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 diff --git a/app/Repositories/TrackerRepository.php b/app/Repositories/TrackerRepository.php index 85f8795c..c438d3b0 100644 --- a/app/Repositories/TrackerRepository.php +++ b/app/Repositories/TrackerRepository.php @@ -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)"); } diff --git a/app/Repositories/UserRepository.php b/app/Repositories/UserRepository.php index fccf5f78..a72290f5 100644 --- a/app/Repositories/UserRepository.php +++ b/app/Repositories/UserRepository.php @@ -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; diff --git a/include/constants.php b/include/constants.php index 7ffc5c54..d7416b2d 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ $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)"); } diff --git a/public/myhr.php b/public/myhr.php index 04d87071..e5730e0f 100644 --- a/public/myhr.php +++ b/public/myhr.php @@ -83,7 +83,7 @@ if ($rescount) { $hasActionRemove = false; foreach($list as $row) { $columnAction = ''; - 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('', $lang_myhr['action_remove'], $row->id); } diff --git a/resources/lang/en/message.php b/resources/lang/en/message.php index c9fb81d4..3d27859b 100644 --- a/resources/lang/en/message.php +++ b/resources/lang/en/message.php @@ -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', diff --git a/resources/lang/zh_CN/message.php b/resources/lang/zh_CN/message.php index 30ff49e6..f030b00e 100644 --- a/resources/lang/zh_CN/message.php +++ b/resources/lang/zh_CN/message.php @@ -15,6 +15,10 @@ return [ 'subject' => '下载权限取消', 'body' => '你的下载权限被取消,可能的原因是过低的分享率或行为不当。By: :operator', ], + 'download_disable_upload_over_speed' => [ + 'subject' => '下载权限取消', + 'body' => '你因上传速度过快下载权限被取消,若是盒子用户请备案。', + ], 'download_enable' => [ 'subject' => '下载权限恢复', 'body' => '你的下载权限恢复,你现在可以下载种子。By: :operator', diff --git a/resources/lang/zh_TW/message.php b/resources/lang/zh_TW/message.php index b2978f75..99aaceb2 100644 --- a/resources/lang/zh_TW/message.php +++ b/resources/lang/zh_TW/message.php @@ -14,6 +14,10 @@ return [ 'subject' => '下載權限取消', 'body' => '你的下載權限被取消,可能的原因是過低的分享率或行為不當。By: :operator', ], + 'download_disable_upload_over_speed' => [ + 'subject' => '下載權限取消', + 'body' => '你因上傳速度過快下載權限被取消,若是盒子用戶請備案。', + ], 'download_enable' => [ 'subject' => '下載權限恢復', 'body' => '你的下載權限恢復,你現在可以下載種子。By: :operator',