diff --git a/app/Filament/Resources/System/ExamResource.php b/app/Filament/Resources/System/ExamResource.php index 7340c399..1156f8e6 100644 --- a/app/Filament/Resources/System/ExamResource.php +++ b/app/Filament/Resources/System/ExamResource.php @@ -77,7 +77,7 @@ class ExamResource extends Resource // ]) ->actions([ - Tables\Actions\EditAction::make(), +// Tables\Actions\EditAction::make(), ]) ->bulkActions([ Tables\Actions\DeleteBulkAction::make(), @@ -95,8 +95,8 @@ class ExamResource extends Resource { return [ 'index' => Pages\ListExams::route('/'), - 'create' => Pages\CreateExam::route('/create'), - 'edit' => Pages\EditExam::route('/{record}/edit'), +// 'create' => Pages\CreateExam::route('/create'), +// 'edit' => Pages\EditExam::route('/{record}/edit'), ]; } } diff --git a/app/Filament/Resources/System/ExamResource/Pages/ListExams.php b/app/Filament/Resources/System/ExamResource/Pages/ListExams.php index 93a2992e..8cc2ccc0 100644 --- a/app/Filament/Resources/System/ExamResource/Pages/ListExams.php +++ b/app/Filament/Resources/System/ExamResource/Pages/ListExams.php @@ -14,7 +14,7 @@ class ListExams extends PageList protected function getActions(): array { return [ - Actions\CreateAction::make(), +// Actions\CreateAction::make(), ]; } } diff --git a/app/Filament/Resources/System/SettingResource.php b/app/Filament/Resources/System/SettingResource.php index f6a1e505..12d2d9c1 100644 --- a/app/Filament/Resources/System/SettingResource.php +++ b/app/Filament/Resources/System/SettingResource.php @@ -24,6 +24,8 @@ class SettingResource extends Resource protected static ?string $navigationGroup = 'System'; + protected static bool $shouldRegisterNavigation = false; + protected static function getNavigationLabel(): string { return __('admin.sidebar.settings'); diff --git a/app/Filament/Resources/User/UserResource.php b/app/Filament/Resources/User/UserResource.php index 5303cd19..fbca1a51 100644 --- a/app/Filament/Resources/User/UserResource.php +++ b/app/Filament/Resources/User/UserResource.php @@ -32,14 +32,14 @@ class UserResource extends Resource public static function form(Form $form): Form { return $form - ->schema(Forms\Components\Card::make()->schema([ + ->schema([ Forms\Components\TextInput::make('username')->required(), Forms\Components\TextInput::make('email')->required(), - Forms\Components\TextInput::make('password')->password()->required(), - Forms\Components\TextInput::make('password_confirmation')->password()->required()->same('password'), + Forms\Components\TextInput::make('password')->password()->required()->visibleOn(Pages\CreateUser::class), + Forms\Components\TextInput::make('password_confirmation')->password()->required()->same('password')->visibleOn(Pages\CreateUser::class), Forms\Components\TextInput::make('id')->integer(), Forms\Components\Select::make('class')->options(array_column(User::$classes, 'text')), - ])); + ]); } public static function table(Table $table): Table @@ -90,6 +90,7 @@ class UserResource extends Resource 'index' => Pages\ListUsers::route('/'), 'create' => Pages\CreateUser::route('/create'), // 'edit' => Pages\EditUser::route('/{record}/edit'), + 'view' => Pages\ViewUser::route('/{record}'), ]; } diff --git a/app/Filament/Resources/User/UserResource/Pages/ViewUser.php b/app/Filament/Resources/User/UserResource/Pages/ViewUser.php new file mode 100644 index 00000000..64857ce0 --- /dev/null +++ b/app/Filament/Resources/User/UserResource/Pages/ViewUser.php @@ -0,0 +1,12 @@ + &$info) { + $text = nexus_trans("torrent.approval.status_text.$status"); + $info['text'] = $text; + $keyValue[$status] = $text; + } + if ($onlyKeyValue) { + return $keyValue; + } + return $result; + } + public function getHrAttribute(): string { $hrMode = Setting::get('hr.mode'); diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 724e8548..01648e95 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -9,6 +9,7 @@ use Illuminate\Support\ServiceProvider; use Illuminate\Http\Resources\Json\JsonResource; use Nexus\Nexus; use Filament\Facades\Filament; +use Illuminate\Contracts\View\View; class AppServiceProvider extends ServiceProvider { @@ -40,5 +41,10 @@ class AppServiceProvider extends ServiceProvider ]); }); +// Filament::registerRenderHook( +// 'content.end', +// fn (): View => view('filament.footer'), +// ); + } } diff --git a/app/Repositories/TorrentRepository.php b/app/Repositories/TorrentRepository.php index bab2a9b9..58b5a453 100644 --- a/app/Repositories/TorrentRepository.php +++ b/app/Repositories/TorrentRepository.php @@ -473,7 +473,12 @@ class TorrentRepository extends BaseRepository { $user = $this->getUser($user); $torrent = Torrent::query()->findOrFail($params['torrent_id'], ['id', 'banned', 'approval_status', 'visible', 'owner']); - if ($torrent->approval_status == $params['approval_status']) { + $lastLog = TorrentOperationLog::query() + ->where('torrent_id', $params['torrent_id']) + ->where('uid', $user->id) + ->orderBy('id', 'desc') + ->first(); + if ($torrent->approval_status == $params['approval_status'] && $lastLog && $lastLog->comment == $params['comment']) { //No change return $params; } @@ -492,12 +497,9 @@ class TorrentRepository extends BaseRepository } elseif ($params['approval_status'] == Torrent::APPROVAL_STATUS_DENY) { $torrentUpdate['banned'] = 'yes'; $torrentUpdate['visible'] = 'no'; - if ($torrent->approval_status != $params['approval_status']) { - $torrentOperationLog['action_type'] = TorrentOperationLog::ACTION_TYPE_APPROVAL_DENY; - } - if ($torrent->approval_status == Torrent::APPROVAL_STATUS_ALLOW) { - $notifyUser = true; - } + //Deny, record and notify all the time + $torrentOperationLog['action_type'] = TorrentOperationLog::ACTION_TYPE_APPROVAL_DENY; + $notifyUser = true; } elseif ($params['approval_status'] == Torrent::APPROVAL_STATUS_NONE) { $torrentUpdate['banned'] = 'no'; $torrentUpdate['visible'] = 'yes'; diff --git a/include/functions.php b/include/functions.php index 9069df6c..4d347212 100644 --- a/include/functions.php +++ b/include/functions.php @@ -2738,11 +2738,26 @@ if ($msgalert) if (get_user_class() >= $staffmem_class) { + //torrent approval + if (get_setting('torrent.approval_status_none_visible') == 'no') { + $cacheKey = 'TORRENT_APPROVAL_NONE'; + $toApprovalCounts = $Cache->get_value($cacheKey); + if ($toApprovalCounts === false) { + $toApprovalCounts = get_row_count('torrents', 'where approval_status = 0'); + $Cache->cache_value($cacheKey, $toApprovalCounts, 60); + } + if ($toApprovalCounts) { + msgalert('torrents.php?approval_status=0', sprintf($lang_functions['text_torrent_to_approval'], is_or_are($toApprovalCounts), $toApprovalCounts, add_s($toApprovalCounts)), 'darkred'); + } + } + if(($complaints = $Cache->get_value('COMPLAINTS_COUNT_CACHE')) === false){ $complaints = get_row_count('complains', 'WHERE answered = 0'); $Cache->cache_value('COMPLAINTS_COUNT_CACHE', $complaints, 600); } - if($complaints) msgalert('complains.php?action=list', sprintf($lang_functions['text_complains'], is_or_are($complaints), $complaints, add_s($complaints)), 'darkred'); + if($complaints) { + msgalert('complains.php?action=list', sprintf($lang_functions['text_complains'], is_or_are($complaints), $complaints, add_s($complaints)), 'darkred'); + } $numreports = $Cache->get_value('staff_new_report_count'); if ($numreports == ""){ diff --git a/lang/chs/lang_functions.php b/lang/chs/lang_functions.php index 9074804d..e78780fc 100644 --- a/lang/chs/lang_functions.php +++ b/lang/chs/lang_functions.php @@ -322,6 +322,7 @@ $lang_functions = array 'text_complains' => '有%s%u个待处理的申诉%s', 'text_contactstaff' => '联系管理组', 'full_site_promotion_in_effect' => '全站 [%s] 生效中!', + 'text_torrent_to_approval' => '有 %s%u 个待审核的种子%s', ); ?> diff --git a/lang/chs/lang_torrents.php b/lang/chs/lang_torrents.php index 208fc88f..4acacb35 100644 --- a/lang/chs/lang_torrents.php +++ b/lang/chs/lang_torrents.php @@ -58,6 +58,7 @@ $lang_torrents = array 'text_tv' => "电视:", 'text_music' => "音乐:", 'text_software' => "软件:", + 'text_approval_status' => '审核状态:', ); ?> diff --git a/lang/cht/lang_functions.php b/lang/cht/lang_functions.php index 4b926811..f0583685 100644 --- a/lang/cht/lang_functions.php +++ b/lang/cht/lang_functions.php @@ -329,6 +329,7 @@ $lang_functions = array 'text_complains' => '有%s%u個待處理的申诉%s', 'text_contactstaff' => '聯系管理組', 'full_site_promotion_in_effect' => '全站 [%s] 生效中!', + 'text_torrent_to_approval' => '有 %s%u 個待審核的種子%s', ); ?> diff --git a/lang/cht/lang_torrents.php b/lang/cht/lang_torrents.php index 7401bfe6..0dc2ec2b 100644 --- a/lang/cht/lang_torrents.php +++ b/lang/cht/lang_torrents.php @@ -58,6 +58,7 @@ $lang_torrents = array 'text_tv' => "電視:", 'text_music' => "音樂:", 'text_software' => "軟件:", + 'text_approval_status' => '審核狀態:', ); ?> diff --git a/lang/en/lang_functions.php b/lang/en/lang_functions.php index f0f314de..6c9c8d0f 100644 --- a/lang/en/lang_functions.php +++ b/lang/en/lang_functions.php @@ -330,7 +330,7 @@ $lang_functions = array 'text_complains' => 'There %s %u pending complaint%s.', 'text_contactstaff' => 'Contact staff', 'full_site_promotion_in_effect' => 'Full site [%s] in effect!', - + 'text_torrent_to_approval' => 'There %s%u not approval torrent%s.', ); ?> diff --git a/lang/en/lang_torrents.php b/lang/en/lang_torrents.php index 60b9bdde..026c1b3e 100644 --- a/lang/en/lang_torrents.php +++ b/lang/en/lang_torrents.php @@ -58,6 +58,7 @@ $lang_torrents = array 'text_tv' => "TV:", 'text_music' => "Music:", 'text_software' => "Software:", + 'text_approval_status' => 'Approval status:', ); ?> diff --git a/public/getusertorrentlistajax.php b/public/getusertorrentlistajax.php index d695c12c..36d2d580 100644 --- a/public/getusertorrentlistajax.php +++ b/public/getusertorrentlistajax.php @@ -11,9 +11,16 @@ header("Pragma: no-cache" ); $torrentRep = new \App\Repositories\TorrentRepository(); +$id = intval($_GET['userid'] ?? 0); +$type = $_GET['type']; +if (!in_array($type,array('uploaded','seeding','leeching','completed','incomplete'))) + die; +if(get_user_class() < $torrenthistory_class && $id != $CURUSER["id"]) + permissiondenied(); + function maketable($res, $mode = 'seeding') { - global $lang_getusertorrentlistajax,$CURUSER,$smalldescription_main, $lang_functions; + global $lang_getusertorrentlistajax,$CURUSER,$smalldescription_main, $lang_functions, $id; global $torrentRep; switch ($mode) { @@ -94,11 +101,31 @@ function maketable($res, $mode = 'seeding') } default: break; } + $results = $torrentIdArr = []; + while ($row = mysql_fetch_assoc($res)) { + $results[] = $row; + $torrentIdArr[] = $row['torrent']; + } + if ($mode == 'uploaded') { + //get seedtime, uploaded from snatch + $seedTimeAndUploaded = \App\Models\Snatch::query() + ->where('userid', $id) + ->whereIn('torrentid', $torrentIdArr) + ->select(['seedtime', 'uploaded', 'torrentid']) + ->get() + ->keyBy('torrentid'); + } + $ret = "". ($showsize ? "" : "").($showsenum ? "" : "").($showlenum ? "" : "").($showuploaded ? "" : "") . ($showdownloaded ? "" : "").($showratio ? "" : "").($showsetime ? "" : "").($showletime ? "" : "").($showcotime ? "" : "").($showanonymous ? "" : "")."\n"; $total_size = 0; - while ($arr = mysql_fetch_assoc($res)) + foreach ($results as $arr) { + if ($mode == 'uploaded') { + $seedTimeAndUploadedData = $seedTimeAndUploaded->get($arr['torrent']); + $arr['seedtime'] = $seedTimeAndUploadedData ? $seedTimeAndUploadedData->seedtime : 0; + $arr['uploaded'] = $seedTimeAndUploadedData ? $seedTimeAndUploadedData->uploaded : 0; + } $catimage = htmlspecialchars($arr["image"]); $catname = htmlspecialchars($arr["catname"]); @@ -178,18 +205,12 @@ function maketable($res, $mode = 'seeding') return [$ret, $total_size]; } -$id = intval($_GET['userid'] ?? 0); -$type = $_GET['type']; -if (!in_array($type,array('uploaded','seeding','leeching','completed','incomplete'))) -die; -if(get_user_class() < $torrenthistory_class && $id != $CURUSER["id"]) -permissiondenied(); - switch ($type) { case 'uploaded': { - $res = sql_query("SELECT torrents.id AS torrent, torrents.name as torrentname, small_descr, seeders, leechers, anonymous, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr, snatched.seedtime, snatched.uploaded FROM torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories ON torrents.category = categories.id WHERE torrents.owner=$id AND snatched.userid=$id " . (($CURUSER["id"] != $id)?((get_user_class() < $viewanonymous_class) ? " AND anonymous = 'no'":""):"") ." ORDER BY torrents.added DESC") or sqlerr(__FILE__, __LINE__); +// $res = sql_query("SELECT torrents.id AS torrent, torrents.name as torrentname, small_descr, seeders, leechers, anonymous, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr, snatched.seedtime, snatched.uploaded FROM torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories ON torrents.category = categories.id WHERE torrents.owner=$id AND snatched.userid=$id " . (($CURUSER["id"] != $id)?((get_user_class() < $viewanonymous_class) ? " AND anonymous = 'no'":""):"") ." ORDER BY torrents.added DESC") or sqlerr(__FILE__, __LINE__); + $res = sql_query("SELECT torrents.id AS torrent, torrents.name as torrentname, small_descr, seeders, leechers, anonymous, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr FROM torrents LEFT JOIN categories ON torrents.category = categories.id WHERE torrents.owner=$id " . (($CURUSER["id"] != $id)?((get_user_class() < $viewanonymous_class) ? " AND anonymous = 'no'":""):"") ." ORDER BY torrents.added DESC") or sqlerr(__FILE__, __LINE__); $count = mysql_num_rows($res); if ($count > 0) { diff --git a/public/torrents.php b/public/torrents.php index 2ca88545..a5d69953 100644 --- a/public/torrents.php +++ b/public/torrents.php @@ -808,7 +808,19 @@ if (isset($searchstr)) //approval status $approvalStatusNoneVisible = get_setting('torrent.approval_status_none_visible'); -if ($approvalStatusNoneVisible == 'no' && get_user_class() < $staffmem_class) { +$approvalStatusIconEnabled = get_setting('torrent.approval_status_icon_enabled'); +$approvalStatus = null; +$showApprovalStatusFilter = false; +//when enable approval status icon, all user can use this filter, otherwise only staff member can use +if ($approvalStatusIconEnabled == 'yes' || get_user_class() >= $staffmem_class) { + $showApprovalStatusFilter = true; +} +//when user can use approval status filter, and pass `approval_status` parameter, will affect +//OR if [not approval can not be view] and not staff member, force to view approval allowed +if ($showApprovalStatusFilter && isset($_REQUEST['approval_status']) && is_numeric($_REQUEST['approval_status'])) { + $approvalStatus = intval($_REQUEST['approval_status']); + $wherea[] = "torrents.approval_status = $approvalStatus"; +} elseif ($approvalStatusNoneVisible == 'no' && get_user_class() < $staffmem_class) { $wherea[] = "torrents.approval_status = " . \App\Models\Torrent::APPROVAL_STATUS_ALLOW; } @@ -1029,6 +1041,30 @@ if ($allsec != 1 || $enablespecial != 'yes'){ //do not print searchbox if showin + + + + + + + + + + +
".$lang_getusertorrentlistajax['col_type']."".$lang_getusertorrentlistajax['col_name']."\"size\"\"seeders\"\"leechers\"".$lang_getusertorrentlistajax['col_uploaded']."".$lang_getusertorrentlistajax['col_downloaded']."".$lang_getusertorrentlistajax['col_ratio']."".$lang_getusertorrentlistajax['col_se_time']."".$lang_getusertorrentlistajax['col_le_time']."".$lang_getusertorrentlistajax['col_time_completed']."".$lang_getusertorrentlistajax['col_anonymous']."
+
+
+ +
+ +
diff --git a/resources/views/filament/footer.blade.php b/resources/views/filament/footer.blade.php new file mode 100644 index 00000000..07c537d9 --- /dev/null +++ b/resources/views/filament/footer.blade.php @@ -0,0 +1,5 @@ + diff --git a/routes/web.php b/routes/web.php index f6b7c52b..5fcda2e2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -14,9 +14,6 @@ use Illuminate\Support\Facades\Route; */ Route::get('/', function () { - return redirect('https://nexusphp.org'); + return redirect('index.php'); }); -Route::get('test', function () { - dd(request()->cookie()); -});