From 8872abe6b37e3c104f9be1e25f6d1468dc2998e0 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Tue, 12 Jul 2022 17:42:26 +0800 Subject: [PATCH] improve announce update torrent visible --- app/Console/Commands/Test.php | 6 +- .../Resources/Torrent/TorrentResource.php | 2 +- app/Filament/Resources/User/UserResource.php | 2 +- app/Models/User.php | 4 +- app/Policies/TorrentPolicy.php | 2 +- app/Policies/TorrentStatePolicy.php | 20 ++- app/Policies/UserPolicy.php | 2 +- app/Providers/AuthServiceProvider.php | 8 +- composer.json | 1 - composer.lock | 90 +--------- config/permission.php | 161 ------------------ ..._07_09_011856_create_permission_tables.php | 141 --------------- include/constants.php | 4 +- public/announce.php | 21 ++- public/details.php | 2 +- public/viewpeerlist.php | 4 +- resources/lang/en/admin.php | 2 + resources/lang/en/label.php | 13 +- resources/lang/zh_CN/admin.php | 2 + resources/lang/zh_CN/label.php | 17 +- resources/lang/zh_TW/admin.php | 2 + resources/lang/zh_TW/label.php | 13 +- 22 files changed, 98 insertions(+), 421 deletions(-) delete mode 100644 config/permission.php delete mode 100644 database/migrations/2022_07_09_011856_create_permission_tables.php diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index 45b77e30..506b1771 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -4,6 +4,7 @@ namespace App\Console\Commands; use App\Events\TorrentUpdated; use App\Http\Resources\TagResource; +use App\Models\Ability; use App\Models\Attendance; use App\Models\Exam; use App\Models\ExamProgress; @@ -11,6 +12,7 @@ use App\Models\ExamUser; use App\Models\HitAndRun; use App\Models\Medal; use App\Models\Peer; +use App\Models\Role; use App\Models\SearchBox; use App\Models\Snatch; use App\Models\Tag; @@ -44,6 +46,7 @@ use NexusPlugin\PostLike\PostLikeRepository; use NexusPlugin\StickyPromotion\Models\StickyPromotion; use NexusPlugin\StickyPromotion\Models\StickyPromotionParticipator; use Rhilip\Bencode\Bencode; +use Silber\Bouncer\Bouncer; class Test extends Command { @@ -78,8 +81,7 @@ class Test extends Command */ public function handle() { - $r = NexusDB::cache_get('ssbb'); - dd($r); + Ability::initDefaults(); } diff --git a/app/Filament/Resources/Torrent/TorrentResource.php b/app/Filament/Resources/Torrent/TorrentResource.php index c91d477e..aafce21c 100644 --- a/app/Filament/Resources/Torrent/TorrentResource.php +++ b/app/Filament/Resources/Torrent/TorrentResource.php @@ -56,7 +56,7 @@ class TorrentResource extends Resource public static function table(Table $table): Table { - $showApproval = Setting::get('torrent.approval_status_none_visible') == 'no'; + $showApproval = Setting::get('torrent.approval_status_none_visible') == 'no' || Setting::get('torrent.approval_status_icon_enabled') == 'yes'; return $table ->columns([ Tables\Columns\TextColumn::make('id')->sortable(), diff --git a/app/Filament/Resources/User/UserResource.php b/app/Filament/Resources/User/UserResource.php index dc18b197..d5ac350c 100644 --- a/app/Filament/Resources/User/UserResource.php +++ b/app/Filament/Resources/User/UserResource.php @@ -55,7 +55,7 @@ class UserResource extends Resource { return $table ->columns([ - Tables\Columns\TextColumn::make('id')->sortable(), + Tables\Columns\TextColumn::make('id')->sortable()->searchable(), Tables\Columns\TextColumn::make('username')->searchable()->label(__("label.user.username")), Tables\Columns\TextColumn::make('email')->searchable()->label(__("label.email")), Tables\Columns\TextColumn::make('class')->label('Class') diff --git a/app/Models/User.php b/app/Models/User.php index d7217bca..c2e1c519 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -17,11 +17,10 @@ use Laravel\Sanctum\HasApiTokens; use Nexus\Database\NexusDB; use Filament\Models\Contracts\FilamentUser; use Filament\Models\Contracts\HasName; -use Spatie\Permission\Traits\HasRoles; class User extends Authenticatable implements FilamentUser, HasName { - use HasFactory, Notifiable, HasApiTokens, HasRoles; + use HasFactory, Notifiable, HasApiTokens; public $timestamps = false; @@ -91,6 +90,7 @@ class User extends Authenticatable implements FilamentUser, HasName 'invites' => '邀请', ]; + public function getClassTextAttribute(): string { if (!isset(self::$classes[$this->class]['text'])) { diff --git a/app/Policies/TorrentPolicy.php b/app/Policies/TorrentPolicy.php index 1a60b993..915677e0 100644 --- a/app/Policies/TorrentPolicy.php +++ b/app/Policies/TorrentPolicy.php @@ -94,7 +94,7 @@ class TorrentPolicy extends BasePolicy private function can(User $user) { - if ($user->class >= User::CLASS_SYSOP) { + if ($user->class >= User::CLASS_ADMINISTRATOR) { return true; } return false; diff --git a/app/Policies/TorrentStatePolicy.php b/app/Policies/TorrentStatePolicy.php index c4b3671e..aeee0478 100644 --- a/app/Policies/TorrentStatePolicy.php +++ b/app/Policies/TorrentStatePolicy.php @@ -19,7 +19,7 @@ class TorrentStatePolicy extends BasePolicy */ public function viewAny(User $user) { - // + return true; } /** @@ -31,7 +31,7 @@ class TorrentStatePolicy extends BasePolicy */ public function view(User $user, TorrentState $torrentState) { - // + return true; } /** @@ -42,7 +42,7 @@ class TorrentStatePolicy extends BasePolicy */ public function create(User $user) { - // + return false; } /** @@ -54,7 +54,7 @@ class TorrentStatePolicy extends BasePolicy */ public function update(User $user, TorrentState $torrentState) { - // + return $this->can($user); } /** @@ -66,7 +66,7 @@ class TorrentStatePolicy extends BasePolicy */ public function delete(User $user, TorrentState $torrentState) { - // + } /** @@ -78,7 +78,7 @@ class TorrentStatePolicy extends BasePolicy */ public function restore(User $user, TorrentState $torrentState) { - // + } /** @@ -92,4 +92,12 @@ class TorrentStatePolicy extends BasePolicy { // } + + private function can(User $user) + { + if ($user->class >= User::CLASS_ADMINISTRATOR) { + return true; + } + return false; + } } diff --git a/app/Policies/UserPolicy.php b/app/Policies/UserPolicy.php index 9f3fce00..05c02851 100644 --- a/app/Policies/UserPolicy.php +++ b/app/Policies/UserPolicy.php @@ -93,7 +93,7 @@ class UserPolicy extends BasePolicy private function can(User $user) { - if ($user->class >= User::CLASS_SYSOP) { + if ($user->class >= User::CLASS_ADMINISTRATOR) { return true; } return false; diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 8b71f750..54cc589b 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -4,6 +4,8 @@ namespace App\Providers; use App\Auth\NexusWebGuard; use App\Auth\NexusWebUserProvider; +use App\Models\Permission; +use App\Models\Role; use App\Models\User; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; use Illuminate\Http\Request; @@ -36,8 +38,12 @@ class AuthServiceProvider extends ServiceProvider Auth::extend('nexus-web', function ($app, $name, array $config) { // 返回 Illuminate\Contracts\Auth\Guard 的实例 ... - return new NexusWebGuard($app->make('request'), new NexusWebUserProvider()); + return new NexusWebGuard($app['request'], new NexusWebUserProvider()); }); + +// Bouncer::useAbilityModel(Permission::class); +// Bouncer::useRoleModel(Role::class); +// Bouncer::useUserModel(User::class); } private function getUserByCookie($cookie) diff --git a/composer.json b/composer.json index c31fa0c8..f806f5d8 100644 --- a/composer.json +++ b/composer.json @@ -49,7 +49,6 @@ "orangehill/iseed": "^3.0", "phpgangsta/googleauthenticator": "dev-master", "rhilip/bencode": "^2.0", - "spatie/laravel-permission": "^5.5", "spiral/roadrunner": "^2.8" }, "require-dev": { diff --git a/composer.lock b/composer.lock index a452c95b..6425391a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7a9971b631dca4a5322634b89075a35b", + "content-hash": "3f8e2bfc2d866abff6ef37466f43be7c", "packages": [ { "name": "akaunting/laravel-money", @@ -6181,94 +6181,6 @@ ], "time": "2022-06-28T14:29:26+00:00" }, - { - "name": "spatie/laravel-permission", - "version": "5.5.5", - "source": { - "type": "git", - "url": "https://github.com/spatie/laravel-permission.git", - "reference": "f2303a70be60919811ca8afc313e8244fda00974" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-permission/zipball/f2303a70be60919811ca8afc313e8244fda00974", - "reference": "f2303a70be60919811ca8afc313e8244fda00974", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "illuminate/auth": "^7.0|^8.0|^9.0", - "illuminate/container": "^7.0|^8.0|^9.0", - "illuminate/contracts": "^7.0|^8.0|^9.0", - "illuminate/database": "^7.0|^8.0|^9.0", - "php": "^7.3|^8.0|^8.1" - }, - "require-dev": { - "orchestra/testbench": "^5.0|^6.0|^7.0", - "phpunit/phpunit": "^9.4", - "predis/predis": "^1.1" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "Spatie\\Permission\\PermissionServiceProvider" - ] - }, - "branch-alias": { - "dev-main": "5.x-dev", - "dev-master": "5.x-dev" - } - }, - "autoload": { - "files": [ - "src/helpers.php" - ], - "psr-4": { - "Spatie\\Permission\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Freek Van der Herten", - "email": "freek@spatie.be", - "homepage": "https://spatie.be", - "role": "Developer" - } - ], - "description": "Permission handling for Laravel 6.0 and up", - "homepage": "https://github.com/spatie/laravel-permission", - "keywords": [ - "acl", - "laravel", - "permission", - "permissions", - "rbac", - "roles", - "security", - "spatie" - ], - "support": { - "issues": "https://github.com/spatie/laravel-permission/issues", - "source": "https://github.com/spatie/laravel-permission/tree/5.5.5" - }, - "funding": [ - { - "url": "https://github.com/spatie", - "type": "github" - } - ], - "time": "2022-06-29T23:11:42+00:00" - }, { "name": "spiral/goridge", "version": "v3.1.2", diff --git a/config/permission.php b/config/permission.php deleted file mode 100644 index 5b6e184c..00000000 --- a/config/permission.php +++ /dev/null @@ -1,161 +0,0 @@ - [ - - /* - * When using the "HasPermissions" trait from this package, we need to know which - * Eloquent model should be used to retrieve your permissions. Of course, it - * is often just the "Permission" model but you may use whatever you like. - * - * The model you want to use as a Permission model needs to implement the - * `Spatie\Permission\Contracts\Permission` contract. - */ - - 'permission' => Spatie\Permission\Models\Permission::class, - - /* - * When using the "HasRoles" trait from this package, we need to know which - * Eloquent model should be used to retrieve your roles. Of course, it - * is often just the "Role" model but you may use whatever you like. - * - * The model you want to use as a Role model needs to implement the - * `Spatie\Permission\Contracts\Role` contract. - */ - - 'role' => Spatie\Permission\Models\Role::class, - - ], - - 'table_names' => [ - - /* - * When using the "HasRoles" trait from this package, we need to know which - * table should be used to retrieve your roles. We have chosen a basic - * default value but you may easily change it to any table you like. - */ - - 'roles' => 'roles', - - /* - * When using the "HasPermissions" trait from this package, we need to know which - * table should be used to retrieve your permissions. We have chosen a basic - * default value but you may easily change it to any table you like. - */ - - 'permissions' => 'permissions', - - /* - * When using the "HasPermissions" trait from this package, we need to know which - * table should be used to retrieve your models permissions. We have chosen a - * basic default value but you may easily change it to any table you like. - */ - - 'model_has_permissions' => 'model_has_permissions', - - /* - * When using the "HasRoles" trait from this package, we need to know which - * table should be used to retrieve your models roles. We have chosen a - * basic default value but you may easily change it to any table you like. - */ - - 'model_has_roles' => 'model_has_roles', - - /* - * When using the "HasRoles" trait from this package, we need to know which - * table should be used to retrieve your roles permissions. We have chosen a - * basic default value but you may easily change it to any table you like. - */ - - 'role_has_permissions' => 'role_has_permissions', - ], - - 'column_names' => [ - /* - * Change this if you want to name the related pivots other than defaults - */ - 'role_pivot_key' => null, //default 'role_id', - 'permission_pivot_key' => null, //default 'permission_id', - - /* - * Change this if you want to name the related model primary key other than - * `model_id`. - * - * For example, this would be nice if your primary keys are all UUIDs. In - * that case, name this `model_uuid`. - */ - - 'model_morph_key' => 'model_id', - - /* - * Change this if you want to use the teams feature and your related model's - * foreign key is other than `team_id`. - */ - - 'team_foreign_key' => 'team_id', - ], - - /* - * When set to true, the method for checking permissions will be registered on the gate. - * Set this to false, if you want to implement custom logic for checking permissions. - */ - - 'register_permission_check_method' => true, - - /* - * When set to true the package implements teams using the 'team_foreign_key'. If you want - * the migrations to register the 'team_foreign_key', you must set this to true - * before doing the migration. If you already did the migration then you must make a new - * migration to also add 'team_foreign_key' to 'roles', 'model_has_roles', and - * 'model_has_permissions'(view the latest version of package's migration file) - */ - - 'teams' => false, - - /* - * When set to true, the required permission names are added to the exception - * message. This could be considered an information leak in some contexts, so - * the default setting is false here for optimum safety. - */ - - 'display_permission_in_exception' => false, - - /* - * When set to true, the required role names are added to the exception - * message. This could be considered an information leak in some contexts, so - * the default setting is false here for optimum safety. - */ - - 'display_role_in_exception' => false, - - /* - * By default wildcard permission lookups are disabled. - */ - - 'enable_wildcard_permission' => false, - - 'cache' => [ - - /* - * By default all permissions are cached for 24 hours to speed up performance. - * When permissions or roles are updated the cache is flushed automatically. - */ - - 'expiration_time' => \DateInterval::createFromDateString('24 hours'), - - /* - * The cache key used to store all permissions. - */ - - 'key' => 'spatie.permission.cache', - - /* - * You may optionally indicate a specific cache driver to use for permission and - * role caching using any of the `store` drivers listed in the cache.php config - * file. Using 'default' here means to use the `default` set in cache.php. - */ - - 'store' => 'default', - ], -]; diff --git a/database/migrations/2022_07_09_011856_create_permission_tables.php b/database/migrations/2022_07_09_011856_create_permission_tables.php deleted file mode 100644 index f3711956..00000000 --- a/database/migrations/2022_07_09_011856_create_permission_tables.php +++ /dev/null @@ -1,141 +0,0 @@ -bigIncrements('id'); // permission id - $table->string('name', 125); // For MySQL 8.0 use string('name', 125); - $table->string('guard_name', 125); // For MySQL 8.0 use string('guard_name', 125); - $table->timestamps(); - - $table->unique(['name', 'guard_name']); - }); - - Schema::create($tableNames['roles'], function (Blueprint $table) use ($teams, $columnNames) { - $table->bigIncrements('id'); // role id - if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing - $table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable(); - $table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index'); - } - $table->string('name', 125); // For MySQL 8.0 use string('name', 125); - $table->string('guard_name', 125); // For MySQL 8.0 use string('guard_name', 125); - $table->timestamps(); - if ($teams || config('permission.testing')) { - $table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']); - } else { - $table->unique(['name', 'guard_name']); - } - }); - - Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) { - $table->unsignedBigInteger(PermissionRegistrar::$pivotPermission); - - $table->string('model_type'); - $table->unsignedBigInteger($columnNames['model_morph_key']); - $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index'); - - $table->foreign(PermissionRegistrar::$pivotPermission) - ->references('id') // permission id - ->on($tableNames['permissions']) - ->onDelete('cascade'); - if ($teams) { - $table->unsignedBigInteger($columnNames['team_foreign_key']); - $table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index'); - - $table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'], - 'model_has_permissions_permission_model_type_primary'); - } else { - $table->primary([PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'], - 'model_has_permissions_permission_model_type_primary'); - } - - }); - - Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) { - $table->unsignedBigInteger(PermissionRegistrar::$pivotRole); - - $table->string('model_type'); - $table->unsignedBigInteger($columnNames['model_morph_key']); - $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index'); - - $table->foreign(PermissionRegistrar::$pivotRole) - ->references('id') // role id - ->on($tableNames['roles']) - ->onDelete('cascade'); - if ($teams) { - $table->unsignedBigInteger($columnNames['team_foreign_key']); - $table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index'); - - $table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'], - 'model_has_roles_role_model_type_primary'); - } else { - $table->primary([PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'], - 'model_has_roles_role_model_type_primary'); - } - }); - - Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) { - $table->unsignedBigInteger(PermissionRegistrar::$pivotPermission); - $table->unsignedBigInteger(PermissionRegistrar::$pivotRole); - - $table->foreign(PermissionRegistrar::$pivotPermission) - ->references('id') // permission id - ->on($tableNames['permissions']) - ->onDelete('cascade'); - - $table->foreign(PermissionRegistrar::$pivotRole) - ->references('id') // role id - ->on($tableNames['roles']) - ->onDelete('cascade'); - - $table->primary([PermissionRegistrar::$pivotPermission, PermissionRegistrar::$pivotRole], 'role_has_permissions_permission_id_role_id_primary'); - }); - - app('cache') - ->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null) - ->forget(config('permission.cache.key')); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - $tableNames = config('permission.table_names'); - - if (empty($tableNames)) { - throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.'); - } - - Schema::drop($tableNames['role_has_permissions']); - Schema::drop($tableNames['model_has_roles']); - Schema::drop($tableNames['model_has_permissions']); - Schema::drop($tableNames['roles']); - Schema::drop($tableNames['permissions']); - } -} diff --git a/include/constants.php b/include/constants.php index 220cab56..5d6e49a0 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ $self["seeder"]) - //count directly since 1.7.4 -// $updateset[] = ($seeder == "yes" ? "seeders = seeders + 1, leechers = leechers - 1" : "seeders = seeders - 1, leechers = leechers + 1"); + if ($seeder <> $self["seeder"]) { +// $updateset[] = ($seeder == "yes" ? "seeders = seeders + 1, leechers = leechers - 1" : "seeders = seeders - 1, leechers = leechers + 1"); + $hasChangeSeederLeecher = true; + } $snatchInfo = \App\Models\Snatch::query() ->where('torrentid', $torrentid) ->where('userid', $userid) @@ -524,7 +527,7 @@ else if (mysql_affected_rows()) { // $updateset[] = ($seeder == "yes" ? "seeders = seeders + 1" : "leechers = leechers + 1"); - + $hasChangeSeederLeecher = true; $check = @mysql_fetch_row(@sql_query("SELECT COUNT(*) FROM snatched WHERE torrentid = $torrentid AND userid = $userid")); if (!$check['0']) sql_query("INSERT INTO snatched (torrentid, userid, ip, port, uploaded, downloaded, to_go, startdat, last_action) VALUES ($torrentid, $userid, ".sqlesc($ip).", $port, $uploaded, $downloaded, $left, $dt, $dt)") or err("SL Err 4"); @@ -548,11 +551,13 @@ if (isset($event) && !empty($event)) { $updateset[] = 'leechers = ' . get_row_count("peers", "where torrent = $torrentid and to_go > 0"); } -if (count($updateset)) // Update only when there is change in peer counts +if (count($updateset) || $hasChangeSeederLeecher) // Update only when there is change in peer counts { $updateset[] = "visible = 'yes'"; $updateset[] = "last_action = $dt"; - sql_query("UPDATE torrents SET " . join(",", $updateset) . " WHERE id = $torrentid"); + $sql = "UPDATE torrents SET " . join(",", $updateset) . " WHERE id = $torrentid"; + sql_query($sql); + do_log("[ANNOUNCE_UPDATE_TORRENT], $sql"); } if($client_familyid != 0 && $client_familyid != $az['clientselect']) { @@ -571,7 +576,9 @@ if ($az['class'] == UC_VIP) { } if(count($USERUPDATESET) && $userid) { - sql_query("UPDATE users SET " . join(",", $USERUPDATESET) . " WHERE id = ".$userid); + $sql = "UPDATE users SET " . join(",", $USERUPDATESET) . " WHERE id = ".$userid; + sql_query($sql); + do_log("[ANNOUNCE_UPDATE_USER], $sql"); } do_action('announced', $torrent, $az, $_REQUEST); benc_resp($rep_dict); diff --git a/public/details.php b/public/details.php index 335114ee..11c0f8bc 100644 --- a/public/details.php +++ b/public/details.php @@ -156,7 +156,7 @@ if (!$row) { if (get_user_class() >= $askreseed_class && $row['seeders'] == 0) { $actions[] = "\"reseed\" ".$lang_details['text_ask_for_reseed'] .""; } - if (get_user_class() >= $torrentmanage_class && get_setting('torrent.approval_status_none_visible') == 'no') { + if (get_user_class() >= $torrentmanage_class && (get_setting('torrent.approval_status_icon_enabled') == 'yes' || get_setting('torrent.approval_status_none_visible') == 'no')) { $approvalIcon = ''; $actions[] = sprintf( '%s %s', diff --git a/public/viewpeerlist.php b/public/viewpeerlist.php index 620e37e2..c698c6d9 100644 --- a/public/viewpeerlist.php +++ b/public/viewpeerlist.php @@ -36,8 +36,10 @@ function dltable($name, $arr, $torrent) "".$lang_viewpeerlist['col_client']."\n"; $now = time(); $num = 0; + $privacyData = \App\Models\User::query()->whereIn('id', array_column($arr, 'userid'))->get(['id', 'privacy'])->keyBy('id'); foreach ($arr as $e) { - $privacy = get_single_value("users", "privacy","WHERE id=".sqlesc($e['userid'])); +// $privacy = get_single_value("users", "privacy","WHERE id=".sqlesc($e['userid'])); + $privacy = $privacyData->get($e['userid'])->privacy ?? ''; ++$num; $highlight = $CURUSER["id"] == $e['userid'] ? " bgcolor=#BBAF9B" : ""; diff --git a/resources/lang/en/admin.php b/resources/lang/en/admin.php index bc633c2e..5110c257 100644 --- a/resources/lang/en/admin.php +++ b/resources/lang/en/admin.php @@ -15,6 +15,8 @@ return [ 'claims' => 'User claims', 'torrent_list' => 'Torrents', 'torrent_state' => 'Free leach', + 'roles_list' => 'Roles', + 'ability_list' => 'Permissions', ], 'resources' => [ 'agent_allow' => [ diff --git a/resources/lang/en/label.php b/resources/lang/en/label.php index 64d54e57..b0d6eaaa 100644 --- a/resources/lang/en/label.php +++ b/resources/lang/en/label.php @@ -83,6 +83,9 @@ return [ 'duration' => 'Duration', 'duration_help' => 'Unit: days. If left blank, the user has permanent possession', ], + 'user_medal' => [ + 'label' => 'User medal', + ], 'exam' => [ 'label' => 'Exam', 'is_done' => 'Is done', @@ -106,6 +109,7 @@ return [ 'index_result' => 'Result', ], 'exam_user' => [ + 'label' => 'Exam user', 'is_done' => 'Is done', ], 'torrent' => [ @@ -123,7 +127,7 @@ return [ 'visible' => 'Visible', ], 'hit_and_run' => [ - + 'label' => 'User H&R', ], 'tag' => [ 'label' => 'Tag', @@ -135,6 +139,7 @@ return [ 'border_radius' => 'Border radius', ], 'agent_allow' => [ + 'label' => 'Agent allow', 'family' => 'Family', 'start_name' => 'Start name', 'peer_id_start' => 'Peer ID start', @@ -149,16 +154,22 @@ return [ 'allowhttps' => 'Allow https', ], 'agent_deny' => [ + 'label' => 'Agent deny', 'peer_id' => 'Peer ID', 'agent' => 'Agent', ], 'claim' => [ + 'label' => 'User claim', 'last_settle_at' => 'Last settle at', 'seed_time_this_month' => 'St. this month', 'uploaded_this_month' => 'Up. this month', 'is_reached_this_month' => 'Reached', ], 'torrent_state' => [ + 'label' => 'Global promotion', 'global_sp_state' => 'Global promotion state', ], + 'role' => [ + 'class' => 'Relate user class', + ], ]; diff --git a/resources/lang/zh_CN/admin.php b/resources/lang/zh_CN/admin.php index 78e15086..11f4e28e 100644 --- a/resources/lang/zh_CN/admin.php +++ b/resources/lang/zh_CN/admin.php @@ -15,6 +15,8 @@ return [ 'claims' => '用户认领', 'torrent_list' => '种子', 'torrent_state' => '全站优惠', + 'roles_list' => '角色', + 'ability_list' => '权限', ], 'resources' => [ 'agent_allow' => [ diff --git a/resources/lang/zh_CN/label.php b/resources/lang/zh_CN/label.php index 440eae8e..7f71d41e 100644 --- a/resources/lang/zh_CN/label.php +++ b/resources/lang/zh_CN/label.php @@ -83,6 +83,9 @@ return [ 'duration' => '有效时长', 'duration_help' => '单位:天。如果留空,用户永久拥有', ], + 'user_medal' => [ + 'label' => '用户勋章', + ], 'exam' => [ 'label' => '考核', 'is_discovered' => '自动发现', @@ -105,6 +108,7 @@ return [ 'index_result' => '结果', ], 'exam_user' => [ + 'label' => '用户考核', 'is_done' => '是否完成', ], 'torrent' => [ @@ -122,7 +126,7 @@ return [ 'visible' => '活种', ], 'hit_and_run' => [ - + 'label' => '用户 H&R', ], 'tag' => [ 'label' => '标签', @@ -134,6 +138,7 @@ return [ 'border_radius' => '边框圆角', ], 'agent_allow' => [ + 'label' => '允许客户端', 'family' => '系列', 'start_name' => '起始名称', 'peer_id_start' => 'Peer ID 超始', @@ -148,16 +153,26 @@ return [ 'allowhttps' => '允许 https', ], 'agent_deny' => [ + 'label' => '拒绝客戶端', 'peer_id' => 'Peer ID', 'agent' => 'Agent', ], 'claim' => [ + 'label' => '用户认领', 'last_settle_at' => '上次结算时间', 'seed_time_this_month' => '本月做种时间', 'uploaded_this_month' => '本月上传量', 'is_reached_this_month' => '本月是否达标', ], 'torrent_state' => [ + 'label' => '全站优惠', 'global_sp_state' => '全站优惠', ], + 'role' => [ + 'class' => '关联用户等级', + ], + 'ability' => [ + 'name' => '标识', + 'title' => '名称', + ], ]; diff --git a/resources/lang/zh_TW/admin.php b/resources/lang/zh_TW/admin.php index 2d7729fb..cf1ae424 100644 --- a/resources/lang/zh_TW/admin.php +++ b/resources/lang/zh_TW/admin.php @@ -15,6 +15,8 @@ return [ 'claims' => '用戶認領', 'torrent_list' => '種子', 'torrent_state' => '全站優惠', + 'roles_list' => '角色', + 'ability_list' => '權限', ], 'resources' => [ 'agent_allow' => [ diff --git a/resources/lang/zh_TW/label.php b/resources/lang/zh_TW/label.php index 835b6ee7..d1e44fb4 100644 --- a/resources/lang/zh_TW/label.php +++ b/resources/lang/zh_TW/label.php @@ -83,6 +83,9 @@ return [ 'duration' => '有效時長', 'duration_help' => '單位:天。如果留空,用戶永久擁有', ], + 'user_medal' => [ + 'label' => '用戶勛章', + ], 'exam' => [ 'label' => '考核', 'is_done' => '是否完成', @@ -106,6 +109,7 @@ return [ 'index_result' => '結果', ], 'exam_user' => [ + 'label' => '用戶考核', 'is_done' => '是否完成', ], 'torrent' => [ @@ -123,7 +127,7 @@ return [ 'visible' => '活種', ], 'hit_and_run' => [ - + 'label' => '用戶 H&R', ], 'tag' => [ 'label' => '標簽', @@ -135,6 +139,7 @@ return [ 'border_radius' => '邊框圓角', ], 'agent_allow' => [ + 'label' => '允許客戶端', 'family' => '系列', 'start_name' => '起始名稱', 'peer_id_start' => 'Peer ID 超始', @@ -149,16 +154,22 @@ return [ 'allowhttps' => '允許 https', ], 'agent_deny' => [ + 'label' => '拒絕客戶端', 'peer_id' => 'Peer ID', 'agent' => 'Agent', ], 'claim' => [ + 'label' => '用戶認領', 'last_settle_at' => '上次結算時間', 'seed_time_this_month' => '本月做種時間', 'uploaded_this_month' => '本月上傳量', 'is_reached_this_month' => '本月是否達標', ], 'torrent_state' => [ + 'label' => '全站優惠', 'global_sp_state' => '全站優惠', ], + 'role' => [ + 'class' => '關聯用户等級', + ], ];