diff --git a/app/Filament/Resources/User/ClaimResource.php b/app/Filament/Resources/User/ClaimResource.php index 6a1eda51..d7970ce8 100644 --- a/app/Filament/Resources/User/ClaimResource.php +++ b/app/Filament/Resources/User/ClaimResource.php @@ -47,6 +47,7 @@ class ClaimResource extends Resource return $table ->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('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)), diff --git a/app/Filament/Resources/User/ExamUserResource.php b/app/Filament/Resources/User/ExamUserResource.php index 7fbb641d..c462004b 100644 --- a/app/Filament/Resources/User/ExamUserResource.php +++ b/app/Filament/Resources/User/ExamUserResource.php @@ -50,6 +50,7 @@ class ExamUserResource extends Resource return $table ->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('exam.name')->label(__('label.exam.label')), Tables\Columns\TextColumn::make('begin')->label(__('label.begin'))->dateTime(), diff --git a/app/Filament/Resources/User/HitAndRunResource.php b/app/Filament/Resources/User/HitAndRunResource.php index e5029c8e..17d4e132 100644 --- a/app/Filament/Resources/User/HitAndRunResource.php +++ b/app/Filament/Resources/User/HitAndRunResource.php @@ -36,24 +36,12 @@ class HitAndRunResource extends Resource return self::getNavigationLabel(); } -// public static function form(Form $form): Form -// { -// return $form -// ->schema(Forms\Components\Card::make()->schema([ -//// Forms\Components\Select::make('user')->relationship('user', 'username')->required(), -//// Forms\Components\Select::make('torrent_id')->relationship('torrent', 'name')->required(), -// Forms\Components\Radio::make('status')->options(HitAndRun::listStatus(true))->inline()->required(), -//// Forms\Components\Select::make('snatch_id')->relationship('snatch', 'uploaded'), -// Forms\Components\Textarea::make('comment'), -// Forms\Components\DateTimePicker::make('created_at')->displayFormat('Y-m-d H:i:s'), -// ])); -// } - public static function table(Table $table): Table { return $table ->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('torrent.name')->limit(30)->label(__('label.torrent.label')), Tables\Columns\TextColumn::make('snatch.uploadText')->label(__('label.uploaded')), diff --git a/app/Filament/Resources/User/UserMedalResource.php b/app/Filament/Resources/User/UserMedalResource.php index ceaff602..7d83cfc4 100644 --- a/app/Filament/Resources/User/UserMedalResource.php +++ b/app/Filament/Resources/User/UserMedalResource.php @@ -46,6 +46,7 @@ class UserMedalResource extends Resource return $table ->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('medal.name')->label(__('label.medal.label'))->searchable(), Tables\Columns\ImageColumn::make('medal.image_large')->label(__('label.image')), diff --git a/app/Filament/Resources/User/UserResource.php b/app/Filament/Resources/User/UserResource.php index d5ac350c..df624976 100644 --- a/app/Filament/Resources/User/UserResource.php +++ b/app/Filament/Resources/User/UserResource.php @@ -69,6 +69,7 @@ class UserResource extends Resource ->sortable()->label(__("label.downloaded")), Tables\Columns\BadgeColumn::make('status')->colors(['success' => 'confirmed', 'warning' => 'pending'])->label(__("label.user.status")), Tables\Columns\BadgeColumn::make('enabled')->colors(['success' => 'yes', 'danger' => 'no'])->label(__("label.user.enabled")), + Tables\Columns\BadgeColumn::make('downloadpos')->colors(['success' => 'yes', 'danger' => 'no'])->label(__("label.user.downloadpos")), Tables\Columns\TextColumn::make('added')->sortable()->dateTime('Y-m-d H:i')->label(__("label.added")), Tables\Columns\TextColumn::make('last_access')->dateTime()->label(__("label.last_access")), ]) @@ -77,6 +78,7 @@ class UserResource extends Resource Tables\Filters\SelectFilter::make('class')->options(array_column(User::$classes, 'text'))->label(__('label.user.class')), Tables\Filters\SelectFilter::make('status')->options(['confirmed' => 'confirmed', 'pending' => 'pending'])->label(__('label.user.status')), Tables\Filters\SelectFilter::make('enabled')->options(self::$yesOrNo)->label(__('label.user.enabled')), + Tables\Filters\SelectFilter::make('downloadpos')->options(self::$yesOrNo)->label(__('label.user.downloadpos')), ]) ->actions([ Tables\Actions\ViewAction::make(), diff --git a/app/Models/Complain.php b/app/Models/Complain.php new file mode 100644 index 00000000..90e0a4d5 --- /dev/null +++ b/app/Models/Complain.php @@ -0,0 +1,9 @@ +update([ 'status' => HitAndRun::STATUS_PARDONED, - 'comment' => NexusDB::raw("concat(comment, '\n$comment')"), + 'comment' => NexusDB::raw("if(comment = '', '$comment', concat_ws('\n', '$comment', comment))"), ]); }); @@ -106,7 +106,7 @@ class BonusRepository extends BaseRepository $user = $this->getUser($user); if ($user->seedbonus < $requireBonus) { do_log("user: {$user->id}, bonus: {$user->seedbonus} < requireBonus: $requireBonus", 'error'); - throw new \LogicException("User bonus point not enough."); + throw new \LogicException("User bonus not enough."); } NexusDB::transaction(function () use ($user, $requireBonus, $logBusinessType, $logComment, $userUpdates) { $logComment = addslashes($logComment); diff --git a/include/constants.php b/include/constants.php index cf3e22cc..523f1ffc 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ '已处理申诉', 'no_complaints_have_been_processed' => '暂无已处理的申诉', 'text_view_band_log' => '查看封禁记录', + 'reply_notify_subject' => '申诉回复', + 'reply_notify_body' => '你在网站 %s 的申诉有了回复,点此 查看。', ]; diff --git a/lang/chs/lang_myhr.php b/lang/chs/lang_myhr.php index bcf4e6a1..79626ab2 100644 --- a/lang/chs/lang_myhr.php +++ b/lang/chs/lang_myhr.php @@ -10,5 +10,5 @@ $lang_myhr = [ 'th_completed_at' => '下载完成时间', 'th_ttl' => '剩余考察时间', 'th_comment' => '备注', - + 'action_remove' => '消除', ]; diff --git a/lang/cht/lang_complains.php b/lang/cht/lang_complains.php index 4e90da7c..bccbc8fe 100644 --- a/lang/cht/lang_complains.php +++ b/lang/cht/lang_complains.php @@ -27,4 +27,6 @@ $lang_complains = [ 'complaints_processed' => '已處理申訴', 'no_complaints_have_been_processed' => '暫無已處理的申訴', 'text_view_band_log' => '查看封禁記錄', + 'reply_notify_subject' => '申訴回復', + 'reply_notify_body' => '你在網站 %s 的申訴有了回復,點此 查看。', ]; diff --git a/lang/cht/lang_myhr.php b/lang/cht/lang_myhr.php index 9b553fb4..58956f8f 100644 --- a/lang/cht/lang_myhr.php +++ b/lang/cht/lang_myhr.php @@ -10,5 +10,5 @@ $lang_myhr = [ 'th_completed_at' => '下載完成時間', 'th_ttl' => '剩余考察時間', 'th_comment' => '備註', - + 'action_remove' => '消除', ]; diff --git a/lang/en/lang_complains.php b/lang/en/lang_complains.php index 6bf950fe..2dfd4254 100644 --- a/lang/en/lang_complains.php +++ b/lang/en/lang_complains.php @@ -27,4 +27,6 @@ $lang_complains = [ 'complaints_processed' => 'Complaints processed', 'no_complaints_have_been_processed' => 'No complaints have been processed', 'text_view_band_log' => 'View ban log', + 'reply_notify_subject' => 'Complaint replied', + 'reply_notify_body' => 'You have a reply to your complaint on the site %s, click here to see it.', ]; diff --git a/lang/en/lang_myhr.php b/lang/en/lang_myhr.php index bb9a29ec..8ae2ec32 100644 --- a/lang/en/lang_myhr.php +++ b/lang/en/lang_myhr.php @@ -10,5 +10,5 @@ $lang_myhr = [ 'th_completed_at' => 'Completed at', 'th_ttl' => 'Inspecting time left', 'th_comment' => 'Comment', - + 'action_remove' => 'Remove', ]; diff --git a/public/ajax.php b/public/ajax.php index 793db6b3..9e611726 100644 --- a/public/ajax.php +++ b/public/ajax.php @@ -109,3 +109,10 @@ function removeSeedBoxRecord($params) $rep = new \App\Repositories\SeedBoxRepository(); return $rep->delete($params['id'], $CURUSER['id']); } + +function removeHitAndRun($params) +{ + global $CURUSER; + $rep = new \App\Repositories\BonusRepository(); + return $rep->consumeToCancelHitAndRun($CURUSER['id'], $params['id']); +} diff --git a/public/complains.php b/public/complains.php index f577dccc..462ea57a 100644 --- a/public/complains.php +++ b/public/complains.php @@ -6,8 +6,10 @@ require get_langfile_path(); $isLogin = isset($CURUSER['id']); $isAdmin = get_user_class() >= $staffmem_class; -if($isLogin && !$isAdmin) permissiondenied(); - +if($isLogin && !$isAdmin) { + permissiondenied(); +} +$uid = $CURUSER['id'] ?? 0; if($_SERVER['REQUEST_METHOD'] === 'POST'){ switch($action = filter_input(INPUT_POST, 'action', FILTER_SANITIZE_FULL_SPECIAL_CHARS)){ case 'new': @@ -23,8 +25,17 @@ if($_SERVER['REQUEST_METHOD'] === 'POST'){ case 'reply': $id = filter_input(INPUT_POST, 'id', FILTER_VALIDATE_INT); $body = filter_input(INPUT_POST, 'body', FILTER_SANITIZE_FULL_SPECIAL_CHARS); + $complain = \App\Models\Complain::query()->findOrFail($id); if(empty($id) || empty($body)) stderr($lang_functions['std_error'], $lang_complains['text_new_failure']); - sql_query(sprintf('INSERT INTO complain_replies (complain, userid, added, body) VALUES (%u, %u, NOW(), %s)', $id, isset($CURUSER['id']) ? $CURUSER['id'] : 0, sqlesc($body))) or sqlerr(__FILE__, __LINE__); + sql_query(sprintf('INSERT INTO complain_replies (complain, userid, added, body) VALUES (%u, %u, NOW(), %s)', $id, $uid, sqlesc($body))) or sqlerr(__FILE__, __LINE__); + if ($uid > 0) { + try { + $toolRep = new \App\Repositories\ToolRepository(); + $toolRep->sendMail($complain->email, $lang_complains['reply_notify_subject'], sprintf($lang_complains['reply_notify_body'], get_setting('basic.SITENAME'), getSchemeAndHttpHost() . '/complains.php?action=view&id=' . $complain->uuid)); + } catch (\Exception $exception) { + do_log($exception->getMessage(), 'error'); + } + } nexus_redirect($_SERVER['HTTP_REFERER']); break; case 'answered': diff --git a/public/myhr.php b/public/myhr.php index 6e00b098..28729e73 100644 --- a/public/myhr.php +++ b/public/myhr.php @@ -13,7 +13,7 @@ if (!empty($_GET['userid'])) { $userid = $_GET['userid']; $pagerParams['userid'] = $userid; } -$userInfo = \App\Models\User::query()->find($userid); +$userInfo = \App\Models\User::query()->find($userid, \App\Models\User::$commonFields); if (empty($userInfo)) { stderr('Error', "User not exists."); } @@ -50,7 +50,7 @@ print $filterForm; $baseQuery = \App\Models\HitAndRun::query()->where('uid', $userid)->where('status', $status); $rescount = (clone $baseQuery)->count(); list($pagertop, $pagerbottom, $limit, $offset, $pageSize) = pager(50, $rescount, sprintf('?%s&', $queryString)); -print("
| {$lang_myhr['th_hr_id']} | {$lang_myhr['th_torrent_name']} | @@ -61,6 +61,7 @@ print("|||||
| {$lang_myhr['th_completed_at']} | {$lang_myhr['th_ttl']} | {$lang_myhr['th_comment']} | +{$lang_functions['std_action']} | ', $lang_myhr['action_remove'], $row->id); + } print(" | ||
| " . $row->id . " | " . optional($row->torrent)->name . " | @@ -89,9 +95,29 @@ if ($rescount) {" . ($row->status == \App\Models\HitAndRun::STATUS_INSPECTING ? mkprettytime(3600 * get_setting('hr.seed_time_minimum') - $row->snatch->seedtime) : '---') . " | " . format_datetime($row->snatch->completedat) . " | " . ($row->status == \App\Models\HitAndRun::STATUS_INSPECTING ? mkprettytime(\Carbon\Carbon::now()->diffInSeconds($row->snatch->completedat->addHours(get_setting('hr.inspect_time')))) : '---') . " | -" . nl2br($row->comment) . " | +" . nl2br(trim($row->comment)) . " | + {$columnAction}