From f83602333f0fcb8abb3561c22b018b91dc4eecd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=94=E5=A7=AC=E6=A1=91?= Date: Thu, 28 Jan 2021 00:15:55 -0500 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4|=E5=90=88=E5=B9=B6=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E4=BD=BF=E7=94=A8|=E7=B1=BB=E4=BC=BC=E7=9A=84?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E9=85=8D=E7=BD=AE&=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=85=B3=E9=97=AD=E5=B7=A5=E5=8D=95=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/bug-report.md | 2 +- .../Controllers/Admin/SystemController.php | 16 +-- app/Http/Controllers/UserController.php | 6 +- app/Jobs/VNet/editUser.php | 2 +- app/Providers/SettingServiceProvider.php | 25 ++--- .../2021_01_27_080544_config_clean.php | 36 +++++++ database/seeds/PresetSeeder.php | 7 -- resources/lang/zh-CN/user.php | 2 +- resources/views/admin/config/system.blade.php | 101 ++++-------------- resources/views/auth/captcha.blade.php | 2 +- 10 files changed, 81 insertions(+), 118 deletions(-) create mode 100644 database/migrations/2021_01_27_080544_config_clean.php diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index 6480d721..8f0a153c 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -3,7 +3,7 @@ name: 错误报告 - Bug Report about: '创建错误报告以帮助我们改进 ' title: "[BUG]" labels: '' -assignees: ZBrettonYe +assignees: '' --- diff --git a/app/Http/Controllers/Admin/SystemController.php b/app/Http/Controllers/Admin/SystemController.php index df401c31..4a535a6d 100644 --- a/app/Http/Controllers/Admin/SystemController.php +++ b/app/Http/Controllers/Admin/SystemController.php @@ -54,17 +54,7 @@ class SystemController extends Controller private function getCaptcha() { - if (sysConfig('geetest_id') && sysConfig('geetest_key')) { - $captcha[] = '2'; - } - if (sysConfig('google_captcha_secret') && sysConfig('google_captcha_sitekey')) { - $captcha[] = '3'; - } - if (sysConfig('hcaptcha_secret') && sysConfig('hcaptcha_sitekey')) { - $captcha[] = '4'; - } - - return $captcha ?? []; + return sysConfig('captcha_secret') && sysConfig('captcha_key'); } public function setExtend(Request $request): RedirectResponse // 设置系统扩展信息,例如客服、统计代码 @@ -113,6 +103,10 @@ class SystemController extends Controller return Response::json(['status' => 'fail', 'message' => '请先完善该支付渠道的必要参数!']); } + if ($value > 1 && $name === 'is_captcha' && ! $this->getCaptcha()) { + return Response::json(['status' => 'fail', 'message' => '请先完善验证码的必要参数!']); + } + // 演示环境禁止修改特定配置项 if (config('app.demo')) { $denyConfig = [ diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index a160e95e..375b9830 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -197,7 +197,7 @@ class UserController extends Controller // 余额充值商品,只取10个 $renewOrder = Order::userActivePlan($user->id)->first(); $renewPrice = $renewOrder->goods ?? 0; - // 有重置日时按照重置日为标准,否者就以过期日为标准 + // 有重置日时按照重置日为标准,否则就以过期日为标准 $dataPlusDays = $user->reset_time ?? $user->expired_at; return view('user.services', [ @@ -337,7 +337,7 @@ class UserController extends Controller { $id = $request->input('id'); - if (Ticket::uid()->whereId($id)->close()) { + if (Ticket::uid()->whereId($id)->firstOrFail()->close()) { return Response::json(['status' => 'success', 'message' => trans('common.close_item', ['attribute' => trans('common.success')])]); } @@ -438,7 +438,7 @@ class UserController extends Controller public function buy(Goods $good) { $user = auth()->user(); - // 有重置日时按照重置日为标准,否者就以过期日为标准 + // 有重置日时按照重置日为标准,否则就以过期日为标准 $dataPlusDays = $user->reset_time ?? $user->expired_at; return view('user.buy', [ diff --git a/app/Jobs/VNet/editUser.php b/app/Jobs/VNet/editUser.php index 4ffb6c66..4903e181 100644 --- a/app/Jobs/VNet/editUser.php +++ b/app/Jobs/VNet/editUser.php @@ -41,7 +41,7 @@ class editUser implements ShouldQueue $host = ($node->server ?: $node->ip).':'.$node->push_port; $secret = $node->auth->secret; - // 如果用户已存在节点内,则执行修改;否者为添加 + // 如果用户已存在节点内,则执行修改;否则为添加 $list = $this->list($host, $secret); if ($list && in_array($this->data['uid'], $list)) { $this->send($host, $secret); diff --git a/app/Providers/SettingServiceProvider.php b/app/Providers/SettingServiceProvider.php index 955513e1..c1f132a7 100644 --- a/app/Providers/SettingServiceProvider.php +++ b/app/Providers/SettingServiceProvider.php @@ -15,14 +15,12 @@ class SettingServiceProvider extends ServiceProvider public function boot() { $toApp = collect([ - 'geetest_id' => 'geetest.id', - 'geetest_key' => 'geetest.key', - 'google_captcha_secret' => 'NoCaptcha.secret', - 'google_captcha_sitekey' => 'NoCaptcha.sitekey', - 'hcaptcha_secret' => 'HCaptcha.secret', - 'hcaptcha_sitekey' => 'HCaptcha.sitekey', + 2 => ['geetest.id', 'geetest.key'], + 3 => ['NoCaptcha.secret', 'NoCaptcha.sitekey'], + 4 => ['HCaptcha.secret', 'HCaptcha.sitekey'], ]); - $notifications = collect([ + + $notifications = [ 'account_expire_notification', 'data_anomaly_notification', 'data_exhaust_notification', @@ -34,14 +32,14 @@ class SettingServiceProvider extends ServiceProvider 'ticket_closed_notification', 'ticket_created_notification', 'ticket_replied_notification', - ]); + ]; $payments = ['is_AliPay', 'is_QQPay', 'is_WeChatPay', 'is_otherPay']; if (! Cache::has('settings')) { Cache::forever('settings', Config::whereNotNull('value')->get()); } $settings = Cache::get('settings'); $modified = $settings - ->whereNotIn('name', $toApp->keys()->merge($notifications)) // 设置一般系统选项 + ->whereNotIn('name', $notifications) // 设置一般系统选项 ->pluck('value', 'name') ->merge($settings->whereIn('name', $notifications)->pluck('value', 'name')->map(function ($item) { return self::setChannel(json_decode($item, true)); // 设置通知相关选项 @@ -51,9 +49,12 @@ class SettingServiceProvider extends ServiceProvider ->toArray(); config(['settings' => $modified]); // 设置系统参数 - $settings->whereIn('name', $toApp->keys())->pluck('value', 'name')->each(function ($item, $key) use ($toApp) { - config([$toApp[$key] => $item]); // 设置PHP软件包相关配置 - }); + + if (config('settings.is_captcha') > 1) { + config([$toApp[config('settings.is_captcha')][0] => config('settings.captcha_secret')]); + config([$toApp[config('settings.is_captcha')][1] => config('settings.captcha_key')]); + } + collect([ 'website_name' => 'app.name', 'website_url' => 'app.url', diff --git a/database/migrations/2021_01_27_080544_config_clean.php b/database/migrations/2021_01_27_080544_config_clean.php new file mode 100644 index 00000000..6ee703d7 --- /dev/null +++ b/database/migrations/2021_01_27_080544_config_clean.php @@ -0,0 +1,36 @@ +configs)->delete(); + foreach ($this->newConfigs as $config) { + \App\Models\Config::insert(['name' => $config]); + } + } + + public function down() + { + foreach ($this->configs as $config) { + \App\Models\Config::insert(['name' => $config]); + } + \App\Models\Config::whereIn('name', $this->newConfigs)->delete(); + } +} diff --git a/database/seeds/PresetSeeder.php b/database/seeds/PresetSeeder.php index 08fbbdaf..784131e1 100644 --- a/database/seeds/PresetSeeder.php +++ b/database/seeds/PresetSeeder.php @@ -94,7 +94,6 @@ class PresetSeeder extends Seeder 'AppStore_password', 'is_activate_account', 'node_daily_report', - 'mix_subscribe', 'rand_subscribe', 'is_custom_subscribe', 'is_AliPay', @@ -111,10 +110,6 @@ class PresetSeeder extends Seeder 'f2fpay_public_key', 'website_security_code', 'subject_name', - 'geetest_id', - 'geetest_key', - 'google_captcha_sitekey', - 'google_captcha_secret', 'user_invite_days', 'admin_invite_days', 'offline_check_times', @@ -124,8 +119,6 @@ class PresetSeeder extends Seeder 'maintenance_time', 'maintenance_content', 'bark_key', - 'hcaptcha_secret', - 'hcaptcha_sitekey', 'paypal_username', 'paypal_password', 'paypal_secret', diff --git a/resources/lang/zh-CN/user.php b/resources/lang/zh-CN/user.php index 4e0112b0..badc2dee 100644 --- a/resources/lang/zh-CN/user.php +++ b/resources/lang/zh-CN/user.php @@ -159,7 +159,7 @@ return [ 'creating' => '创建支付单中...', 'redirect_stripe' => '转跳至Stripe支付界面...', 'qrcode_tips' => '请使用:software扫描二维码', - 'close_tips' => '请在:minutes分钟内完成支付,否者订单将会自动关闭', + 'close_tips' => '请在:minutes分钟内完成支付,否则订单将会自动关闭', 'mobile_tips' => '手机用户:长按二维码 -> 保存图片 ->打开支付软件 -> 扫一扫 -> 选择相册 进行付款', ], 'invoice' => [ diff --git a/resources/views/admin/config/system.blade.php b/resources/views/admin/config/system.blade.php index 336ff7d4..9832bbd5 100644 --- a/resources/views/admin/config/system.blade.php +++ b/resources/views/admin/config/system.blade.php @@ -469,7 +469,7 @@
- + @@ -493,16 +493,6 @@
-
-
- -
- - 启用后,订阅信息中将包含V2Ray节点信息(仅支持Shadowrocket、Quantumult、v2rayN) -
-
-
@@ -525,7 +515,7 @@
- +
@@ -533,7 +523,7 @@
- 用于 VNet后端授权,此域名需要解析A记录到面板,例:https://demo.proxypanel.ml + 例:https://demo.proxypanel.ml
@@ -626,9 +616,10 @@
+
- +
- 启用后登录、注册需要输入验证码 + 启用后 登录/注册 需要进行验证码认证
- +
- + - +
- 本功能需要极验后台申请权限及应用 + 浏览设置指南来设置
- +
- + - - -
-
-
-
-
-
- -
-
- - - - -
- 本功能需要GooglereCAPTCHA后台申请权限及应用 (申请需科学上网,日常验证不用) -
-
-
-
-
- -
-
- - - - -
-
-
-
-
-
- -
-
- - - - -
- 本功能需要hCaptcha后台申请权限及应用 -
-
-
-
-
- -
-
- - - +
@@ -1374,7 +1311,8 @@
- + @@ -1807,7 +1745,11 @@ disablePayment(document.getElementById('is_QQPay').getElementsByTagName('option')); disablePayment(document.getElementById('is_WeChatPay').getElementsByTagName('option')); disablePayment(document.getElementById('is_otherPay').getElementsByTagName('option')); + + @if (!$captcha) disableCaptcha(document.getElementById('is_captcha').getElementsByTagName('option')); + @endif + }); function disablePayment(op) { @@ -1821,10 +1763,7 @@ function disableCaptcha(op) { for (let i = 2; i < op.length; i++) { - @json($captcha). - includes(op[i].value) - ? op[i].disabled = false - : op[i].disabled = true; + op[i].disabled = true; } } diff --git a/resources/views/auth/captcha.blade.php b/resources/views/auth/captcha.blade.php index 628213d6..a25db3e5 100644 --- a/resources/views/auth/captcha.blade.php +++ b/resources/views/auth/captcha.blade.php @@ -2,7 +2,7 @@ @case(1)
- + {{trans('auth.captcha.attribute')}}
@break