From 58e25f995a0e48ccb625729e25ac6e9ba9f15516 Mon Sep 17 00:00:00 2001 From: XiaoLFeng Date: Tue, 27 Jun 2023 20:40:19 +0800 Subject: [PATCH 01/31] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=8B=E9=93=BE?= =?UTF-8?q?=E6=BC=8F=E6=B4=9E=E8=A1=A5=E4=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Function/Link.php | 2 +- resources/views/function/make-friend.blade.php | 2 +- resources/views/mail/link-custom-add.blade.php | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Function/Link.php b/app/Http/Controllers/Function/Link.php index fba3798..dc594fd 100644 --- a/app/Http/Controllers/Function/Link.php +++ b/app/Http/Controllers/Function/Link.php @@ -48,7 +48,7 @@ public function apiCustomAdd(Request $request): JsonResponse 'userRss' => 'string|regex:#[a-zA-z]+://[^\s]*#', 'userLocation' => 'required|int', 'userSelColor' => 'required|int', - 'userRemark' => 'required|string', + 'userRemark' => 'string', ]); // 检查发现错误 diff --git a/resources/views/function/make-friend.blade.php b/resources/views/function/make-friend.blade.php index 8d80588..4b20030 100644 --- a/resources/views/function/make-friend.blade.php +++ b/resources/views/function/make-friend.blade.php @@ -297,7 +297,7 @@ function ajax() { success: function (returnData) { if (returnData.output === "Success") { Toast.toggle('友链申请成功',''); - location.href = '{{ route('home') }}' + location.href = '{{ route('function.link') }}' } else { Toast('未知错误',''); } diff --git a/resources/views/mail/link-custom-add.blade.php b/resources/views/mail/link-custom-add.blade.php index e52d01a..1484214 100644 --- a/resources/views/mail/link-custom-add.blade.php +++ b/resources/views/mail/link-custom-add.blade.php @@ -7,7 +7,7 @@ - + -- 2.43.0 From 5d09afaa25071e9af05a399dabcb056a63369be3 Mon Sep 17 00:00:00 2001 From: XiaoLFeng Date: Tue, 27 Jun 2023 20:40:19 +0800 Subject: [PATCH 02/31] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=8B=E9=93=BE?= =?UTF-8?q?=E6=BC=8F=E6=B4=9E=E8=A1=A5=E4=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Function/Link.php | 2 +- resources/views/function/make-friend.blade.php | 6 ++++-- resources/views/mail/link-custom-add.blade.php | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Function/Link.php b/app/Http/Controllers/Function/Link.php index fba3798..dc594fd 100644 --- a/app/Http/Controllers/Function/Link.php +++ b/app/Http/Controllers/Function/Link.php @@ -48,7 +48,7 @@ public function apiCustomAdd(Request $request): JsonResponse 'userRss' => 'string|regex:#[a-zA-z]+://[^\s]*#', 'userLocation' => 'required|int', 'userSelColor' => 'required|int', - 'userRemark' => 'required|string', + 'userRemark' => 'string', ]); // 检查发现错误 diff --git a/resources/views/function/make-friend.blade.php b/resources/views/function/make-friend.blade.php index 8d80588..1a6ecc4 100644 --- a/resources/views/function/make-friend.blade.php +++ b/resources/views/function/make-friend.blade.php @@ -296,8 +296,10 @@ function ajax() { dataType: "json", success: function (returnData) { if (returnData.output === "Success") { - Toast.toggle('友链申请成功',''); - location.href = '{{ route('home') }}' + Toast.toggle('友链申请成功,即将跳转',''); + setTimeout(function () { + location.href = '{{ route('function.link') }}'; + },3000); } else { Toast('未知错误',''); } diff --git a/resources/views/mail/link-custom-add.blade.php b/resources/views/mail/link-custom-add.blade.php index e52d01a..1484214 100644 --- a/resources/views/mail/link-custom-add.blade.php +++ b/resources/views/mail/link-custom-add.blade.php @@ -7,7 +7,7 @@
$G_TitleName{{ env('APP_NAME') }}
@@ -26,7 +26,7 @@ 您好 {{ $userBlog }} 的站长:{{ $userEmail }}
您在本博客({{ env('APP_NAME') }})申请了友链
-
+
请在确认一次您的信息是否正确:
  • 博主邮箱:{{ $userEmail }}
  • @@ -35,7 +35,7 @@
  • 图片地址:{{ $userIcon }}
  • 贵站介绍:{{ $userDescription }}
  • 备注内容:{{ $userRemark }}
  • -
  • RSS地址:{{ $userRSS }}
  • + @if(!empty($checkRssJudge))
  • RSS地址:{{ $userRSS }}
  • @endif
- + -- 2.43.0 From 994b1e907f05e697d032c6173aad75c9657769a1 Mon Sep 17 00:00:00 2001 From: XiaoLFeng Date: Tue, 27 Jun 2023 20:50:33 +0800 Subject: [PATCH 03/31] =?UTF-8?q?=E5=8F=91=E9=80=81=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/views/mail/link-custom-add.blade.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/views/mail/link-custom-add.blade.php b/resources/views/mail/link-custom-add.blade.php index 1484214..8a7982b 100644 --- a/resources/views/mail/link-custom-add.blade.php +++ b/resources/views/mail/link-custom-add.blade.php @@ -7,7 +7,7 @@
$G_TitleName{{ env('APP_NAME') }}
@@ -26,7 +26,7 @@ 您好 {{ $userBlog }} 的站长:{{ $userEmail }}
您在本博客({{ env('APP_NAME') }})申请了友链
-
+
请在确认一次您的信息是否正确:
  • 博主邮箱:{{ $userEmail }}
  • @@ -35,7 +35,7 @@
  • 图片地址:{{ $userIcon }}
  • 贵站介绍:{{ $userDescription }}
  • 备注内容:{{ $userRemark }}
  • -
  • RSS地址:{{ $userRSS }}
  • + @if(!empty($checkRssJudge))
  • RSS地址:{{ $userRSS }}
  • @endif
- + -- 2.43.0 From 06c6b57ad6928c3edfadda6e76470af17332bcc5 Mon Sep 17 00:00:00 2001 From: XiaoLFeng Date: Tue, 27 Jun 2023 20:58:17 +0800 Subject: [PATCH 04/31] =?UTF-8?q?=E9=81=BF=E5=85=8D=E9=82=AE=E7=AE=B1?= =?UTF-8?q?=E6=B3=84=E9=9C=B2=EF=BC=8C=E5=BF=85=E9=A1=BB=E5=86=99=E5=85=A5?= =?UTF-8?q?=E5=AE=8C=E6=95=B4=E7=9A=84=E9=82=AE=E7=AE=B1=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Function/Link.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Function/Link.php b/app/Http/Controllers/Function/Link.php index dc594fd..0acf056 100644 --- a/app/Http/Controllers/Function/Link.php +++ b/app/Http/Controllers/Function/Link.php @@ -143,7 +143,7 @@ public function apiCustomSearch(Request $request): JsonResponse ->where([ ['blogName', 'LIKE', '%' . $request->location_search . '%', 'or'], ['blogUrl', 'LIKE', '%' . $request->location_search . '%', 'or'], - ['blogOwnEmail', 'LIKE', '%' . $request->location_search . '%', 'or']]) + ['blogOwnEmail', '=', $request->location_search, 'or']]) ->select('blogName','blogUrl','blogDescription','blogIcon') ->orderBy('id') ->get() -- 2.43.0 From 2d267e55bac10003ea07396566d60d25c8ae8e9c Mon Sep 17 00:00:00 2001 From: XiaoLFeng Date: Tue, 27 Jun 2023 23:46:40 +0800 Subject: [PATCH 05/31] =?UTF-8?q?=E5=8F=8B=E9=93=BE=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Function/Link.php | 79 +++++-- .../views/function/edit-search.blade.php | 208 ++++++++++++++++++ 2 files changed, 272 insertions(+), 15 deletions(-) create mode 100644 resources/views/function/edit-search.blade.php diff --git a/app/Http/Controllers/Function/Link.php b/app/Http/Controllers/Function/Link.php index 0acf056..395c926 100644 --- a/app/Http/Controllers/Function/Link.php +++ b/app/Http/Controllers/Function/Link.php @@ -13,10 +13,12 @@ use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\View; use Illuminate\Http\JsonResponse; -use Illuminate\Http\Request; +use Illuminate\Http\RedirectResponse; +use Illuminate\Http\Request as HttpRequest; use Illuminate\Mail\Message; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Mail; +use Illuminate\Support\Facades\Request; use Illuminate\Support\Facades\Response; use Illuminate\Support\Facades\Validator; @@ -30,7 +32,7 @@ public function __construct() $this->data = $data->data; } - public function apiCustomAdd(Request $request): JsonResponse + public function apiCustomAdd(HttpRequest $request): JsonResponse { /** @var array $returnData Json的 return 返回值 */ /** @var Validator $dataCheck 数据判断 */ @@ -134,7 +136,7 @@ public function apiCustomAdd(Request $request): JsonResponse return Response::json($returnData, $returnData['code']); } - public function apiCustomSearch(Request $request): JsonResponse + public function apiCustomSearch(HttpRequest $request): JsonResponse { /** @var array $returnData Json的 return 返回值 */ if (!empty($request->location_search)) { @@ -144,7 +146,7 @@ public function apiCustomSearch(Request $request): JsonResponse ['blogName', 'LIKE', '%' . $request->location_search . '%', 'or'], ['blogUrl', 'LIKE', '%' . $request->location_search . '%', 'or'], ['blogOwnEmail', '=', $request->location_search, 'or']]) - ->select('blogName','blogUrl','blogDescription','blogIcon') + ->select('id', 'blogName', 'blogUrl', 'blogDescription', 'blogIcon') ->orderBy('id') ->get() ->toArray(); @@ -170,7 +172,7 @@ public function apiCustomSearch(Request $request): JsonResponse if ($request->searchType == 'blogName') { $resultData = DB::table('blog_link') ->where([['blogName', 'LIKE', '%' . $request->location_search . '%']]) - ->select('blogName','blogUrl','blogDescription','blogIcon') + ->select('id', 'blogName', 'blogUrl', 'blogDescription', 'blogIcon') ->orderBy('id') ->get() ->toArray(); @@ -195,7 +197,7 @@ public function apiCustomSearch(Request $request): JsonResponse } elseif ($request->searchType == 'blogUrl') { $resultData = DB::table('blog_link') ->where([['blogUrl', 'LIKE', '%' . $request->location_search . '%']]) - ->select('blogName','blogUrl','blogDescription','blogIcon') + ->select('id', 'blogName', 'blogUrl', 'blogDescription', 'blogIcon') ->orderBy('id') ->get() ->toArray(); @@ -236,10 +238,45 @@ public function apiCustomSearch(Request $request): JsonResponse ], ]; } - return Response::json($returnData,$returnData['code']); + return Response::json($returnData, $returnData['code']); } - protected function viewLink(Request $request): Factory|View|Application + public function viewEditFriend($friendId): Application|Factory|View|RedirectResponse + { + // 检查内容是否为空 + if (!empty($friendId)) { + $this->data['webSubTitle'] = '修改友链'; + + // 检查这个ID是否存在 + $resultBlog = DB::table('blog_link') + ->find($friendId); + if (!empty($resultBlog->id)) { + // 检查是否存在Cookie作为已验证 + if (Request::hasCookie('friend_edit')) { + // 检查COOKIE与所验证ID是否匹配 + if (password_verify($friendId,Request::cookie('friend_edit'))) { + return view('function.edit-friend', $this->data); + } else { + response()->withCookie(cookie('friend_edit',null,time()-1)); + return Response::redirectTo(route('function.edit-search')); + } + } else { + // 验证页面 + // 加密用户邮箱 + $this->data['blog'] = $resultBlog; + return view('function.edit-check', $this->data); + } + } else { + // 不存在这一个ID用户 + return Response::redirectTo(route('function.edit-search')); + } + } else { + // ID为空的时候就返回数据 + return Response::redirectTo(route('function.edit-search')); + } + } + + protected function viewLink(HttpRequest $request): Factory|View|Application { $this->data['webSubTitle'] = '友链'; $this->GetFriendsLink($this->data); @@ -266,16 +303,28 @@ protected function viewMakeFriend(): Factory|View|Application return view('function.make-friend', $this->data); } - protected function viewEditFriend(): Factory|View|Application - { - $this->data['webSubTitle'] = '修改友链'; - - return view('function.edit-friend', $this->data); - } - protected function viewSearchFriends(): Factory|View|Application { $this->data['webSubTitle'] = '查询列表'; return view('function.edit-search', $this->data); } + + protected function viewSearchFriend($friendId): Factory|View|Application|RedirectResponse + { + $this->data['webSubTitle'] = '查询列表'; + if (!empty($friendId)) { + // 检查 friendId 是否存在 + $resultBlog = DB::table('blog_link') + ->select('id','blogOwnEmail') + ->find($friendId); + if (!empty($resultBlog->id)) { + $this->data['blog'] = $resultBlog; + return view('function.edit-check', $this->data); + } else { + return Response::redirectTo(route('function.edit-search')); + } + } else { + return Response::redirectTo(route('function.edit-search')); + } + } } diff --git a/resources/views/function/edit-search.blade.php b/resources/views/function/edit-search.blade.php new file mode 100644 index 0000000..7dc0cd4 --- /dev/null +++ b/resources/views/function/edit-search.blade.php @@ -0,0 +1,208 @@ + + + + + + + + + @include('modules.head') + {!! $webHeader !!} + + +
+ @include('modules.navbar') +
+ +
+
+
+ + + +
+ + +
+
+ + +
+
+
+
+

+ 在上方进行友链检索

+

+ 选择内容输入博客名字、博客地址查询博客信息执行修改

+
+
+
+
+ + @include('modules.footer') +
+
+ + + + + + +{!! $webFooter !!} + -- 2.43.0 From 0e52e7370c338abd16beb09f4c56dd045e412fc0 Mon Sep 17 00:00:00 2001 From: XiaoLFeng Date: Wed, 28 Jun 2023 14:47:25 +0800 Subject: [PATCH 06/31] =?UTF-8?q?=E5=8F=8B=E9=93=BE=E7=AD=9B=E9=80=89?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E8=A1=A8/API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/api.php | 1 + routes/web.php | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/routes/api.php b/routes/api.php index 503f5cb..c538bc5 100644 --- a/routes/api.php +++ b/routes/api.php @@ -45,5 +45,6 @@ Route::prefix('custom')->group(function () { Route::post('add',[Link::class,'apiCustomAdd'])->name('api.link.custom.add'); Route::get('search',[Link::class, 'apiCustomSearch'])->name('api.link.custom.search'); + Route::post('blogCheck',[Link::class,'apiCustomBlogCheck'])->name('api.link.custom.blogCheck'); }); }); diff --git a/routes/web.php b/routes/web.php index 64a8a73..7d18a0c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -32,7 +32,11 @@ Route::get('link',[UserLink::class, 'viewLink'])->name('function.link'); Route::get('make-friend',[UserLink::class, 'viewMakeFriend'])->name('function.make-friend'); Route::get('edit-search',[UserLink::class, 'viewSearchFriends'])->name('function.edit-search'); - Route::get('edit-friend',[UserLink::class, 'viewEditFriend'])->name('function.edit-friend'); + Route::get('edit-search/{friendId}',[UserLink::class,'viewSearchFriend'])->name('function.edit-searchOnly'); + Route::get('edit-friend/{friendId}',function ($friendId) { + $userLink = new UserLink(); + return $userLink->viewEditFriend($friendId); + })->name('function.edit-friend'); Route::get('sponsor',function () { return view('function.sponsor'); })->name('function.sponsor'); -- 2.43.0 From 61d3b3b9fb8e1c58b7a80bb72602c65212c9d7c2 Mon Sep 17 00:00:00 2001 From: XiaoLFeng Date: Wed, 28 Jun 2023 14:47:31 +0800 Subject: [PATCH 07/31] =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2023_06_28_054011_create_code_table.php | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 database/migrations/2023_06_28_054011_create_code_table.php diff --git a/database/migrations/2023_06_28_054011_create_code_table.php b/database/migrations/2023_06_28_054011_create_code_table.php new file mode 100644 index 0000000..5b4c5d1 --- /dev/null +++ b/database/migrations/2023_06_28_054011_create_code_table.php @@ -0,0 +1,46 @@ +id() + ->comment('自动ID'); + $table->string('email',100) + ->comment('邮箱'); + $table->string('code',64) + ->comment('验证码内容'); + $table->string('type',40) + ->comment('类型(例如:CODE-CUSTOM-CHECK)'); + $table->integer('sendTime') + ->comment('发送时间'); + $table->integer('time') + ->comment('存储结束时间戳'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('code'); + } +} -- 2.43.0 From d7b4915e886c3906917f8a3cdc5be57a6433f4a5 Mon Sep 17 00:00:00 2001 From: XiaoLFeng Date: Wed, 28 Jun 2023 14:47:48 +0800 Subject: [PATCH 08/31] =?UTF-8?q?mail=E6=A8=A1=E6=9D=BFcustom-check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/mail/link-custom-check.blade.php | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 resources/views/mail/link-custom-check.blade.php diff --git a/resources/views/mail/link-custom-check.blade.php b/resources/views/mail/link-custom-check.blade.php new file mode 100644 index 0000000..273202b --- /dev/null +++ b/resources/views/mail/link-custom-check.blade.php @@ -0,0 +1,54 @@ + + + + + Mail + + +
{{ env('APP_NAME') }}{{ env('APP_NAME') }}
@@ -26,6 +26,7 @@ 您好 {{ $userBlog }} 的站长:{{ $userEmail }}
您在本博客({{ env('APP_NAME') }})申请了友链
+ 邮件为通知您您已成功申请友链,需等待站长进行审核,我们将在审核完毕后再次发送邮件通知您
请在确认一次您的信息是否正确:
    @@ -34,7 +35,7 @@
  • 贵站地址:{{ $userUrl }}
  • 图片地址:{{ $userIcon }}
  • 贵站介绍:{{ $userDescription }}
  • -
  • 备注内容:{{ $userRemark }}
  • + @if(!empty($userRemark))
  • 备注内容:{{ $userRemark }}
  • @endif @if(!empty($checkRssJudge))
  • RSS地址:{{ $userRSS }}
  • @endif
+ + + + + + + + + +
{{ env('APP_NAME') }}
+ + + + + + + + + + +
+ 时间: {{ date('Y-m-d H:i',$sendTime) }} +
+ Dear. {{ $userEmail }} +
+ 您在本博客({{ env('APP_NAME') }})正在进行 友链自助修改 操作。 +
+ 您的验证码为:{{ $verifyCode }} 验证码15分钟有效
+
+ 若您未在本站进行对应操作,请勿外泄验证码,忽略本邮件即可!谢谢您对本站的支持
+ 验证UU码:CODE-CUSTOM-CHECK +
+
+ + + + +
+ © 2022 - {{ date('Y') }}. {{ env('APP_NAME') }} All Rights Reserved.
+ 本邮件为自动发出,请勿直接回复 +
+
+ + + + -- 2.43.0 From f8364f698c8bbe1b56bc3c5b3e25a62c9d13db97 Mon Sep 17 00:00:00 2001 From: XiaoLFeng Date: Wed, 28 Jun 2023 14:48:24 +0800 Subject: [PATCH 09/31] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=BC=98=E5=8C=96?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E6=B7=BB=E5=8A=A0API=E5=86=85=E5=AE=B9?= =?UTF-8?q?=EF=BC=88=E6=A3=80=E6=9F=A5=E7=AB=99=E9=95=BF=E5=88=97=E8=A1=A8?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Function/Link.php | 162 ++++++++++++++++++++++++- 1 file changed, 160 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Function/Link.php b/app/Http/Controllers/Function/Link.php index 395c926..ee85a7d 100644 --- a/app/Http/Controllers/Function/Link.php +++ b/app/Http/Controllers/Function/Link.php @@ -25,6 +25,7 @@ class Link extends Controller { protected array $data; + private array $sendEmail; public function __construct() { @@ -32,6 +33,12 @@ public function __construct() $this->data = $data->data; } + /** + * 添加友链API + * + * @param HttpRequest $request 获取HTTP中 Request 数据 + * @return JsonResponse 返回JSON数据 + */ public function apiCustomAdd(HttpRequest $request): JsonResponse { /** @var array $returnData Json的 return 返回值 */ @@ -136,6 +143,12 @@ public function apiCustomAdd(HttpRequest $request): JsonResponse return Response::json($returnData, $returnData['code']); } + /** + * 搜索友链数据 + * + * @param HttpRequest $request 获取HTTP中 Request 数据 + * @return JsonResponse 返回JSON数据 + */ public function apiCustomSearch(HttpRequest $request): JsonResponse { /** @var array $returnData Json的 return 返回值 */ @@ -241,6 +254,151 @@ public function apiCustomSearch(HttpRequest $request): JsonResponse return Response::json($returnData, $returnData['code']); } + /** + * 检查数据验证是否正确 + * + * @param HttpRequest $request 获取HTTP中 Request 数据 + * @return JsonResponse 返回JSON数据 + */ + public function apiCustomBlogCheck(HttpRequest $request): JsonResponse + { + /** @var array $returnData Json的 return 返回值 */ + // 验证数据 + $resultBlog = DB::table('blog_link') + ->select('id', 'blogOwnEmail') + ->find((int)$request->id); + if (!empty($resultBlog->id)) { + // 检查输入博客是否对应 + if (!empty($resultBlog->blogOwnEmail)) { + if (strcmp($resultBlog->blogOwnEmail, $request->email) == 0) { + // 生成验证码(筛查内容) + $resultVerifyCode = DB::table('code') + ->where([ + ['email', '=', $resultBlog->blogOwnEmail], + ['type', '=', 'CODE-CUSTOM-CHECK'], + ['time', '>', time()]]) + ->get() + ->toArray(); + // 不存在验证码,生成验证码并存入数据库中 + if (empty($resultVerifyCode[0]->id)) { + // 生成6位数验证码 + $verifyCode = null; + for ($i = 0; $i < 6; $i++) + $verifyCode .= rand(0, 9); + + // 存入数据库 + DB::table('code') + ->insert([ + 'email' => $resultBlog->blogOwnEmail, + 'code' => $verifyCode, + 'type' => 'CODE-CUSTOM-CHECK', + 'sendTime' => time(), + 'time' => time()+900, + ]); + // 数据整理 + $this->sendEmail = [ + 'userEmail' => $resultBlog->blogOwnEmail, + 'verifyCode' => $verifyCode, + 'sendTime' => time(), + ]; + $this->apiCustomBlogCheckSendEmail(); + $returnData = [ + 'output' => 'Success', + 'code' => 200, + 'data' => [ + 'message' => '发送成功', + ], + ]; + } else { + // 存在验证码,检查验证码是否需要重新发送 + $data = DB::table('code') + ->where([ + ['email','=',$resultBlog->blogOwnEmail], + ['type','=','CODE-CUSTOM-CHECK'], + ['time','>',time()]]) + ->get() + ->toArray(); + $this->sendEmail = [ + 'userEmail' => $data[0]->email, + 'verifyCode' => $data[0]->code, + 'sendTime' => time(), + ]; + if ($resultVerifyCode[0]->sendTime < time()-60) { + // 发送验证码 + DB::table('code') + ->where([ + ['email','=',$resultBlog->blogOwnEmail], + ['type','=','CODE-CUSTOM-CHECK'], + ['time','>',time()]]) + ->update(['sendTime' => time()]); + $this->apiCustomBlogCheckSendEmail(); + $returnData = [ + 'output' => 'Success', + 'code' => 200, + 'data' => [ + 'message' => '重新发送成功', + ], + ]; + } else { + // 避免重复发送 + $returnData = [ + 'output' => 'SendingTimeTooFast', + 'code' => 403, + 'data' => [ + 'message' => '邮件重新发送时间过快', + 'data' => [ + 'time' => 60 - (time() - $resultVerifyCode[0]->sendTime), + ], + ], + ]; + } + } + } else { + $returnData = [ + 'output' => 'EmailMismatch', + 'code' => 403, + 'data' => [ + 'message' => '邮箱与对应ID不匹配', + ], + ]; + } + } else { + $returnData = [ + 'output' => 'NoEmail', + 'code' => 403, + 'data' => [ + 'message' => '对应ID没有绑定邮箱,请联系管理员', + ], + ]; + } + } else { + $returnData = [ + 'output' => 'NoBlog', + 'code' => 403, + 'data' => [ + 'message' => '没有ID对应博客', + ], + ]; + } + return Response::json($returnData, $returnData['code']); + } + + /** + * 站长认证邮件发送模板 + * + * @param array $data + * @return void + */ + private function apiCustomBlogCheckSendEmail(): void + { + // 验证通过发送邮件 + Mail::send('mail.link-custom-check', $this->sendEmail, function (Message $mail) { + $mail->from(env('MAIL_USERNAME'), env('APP_NAME')); + $mail->to($this->sendEmail['userEmail']); + $mail->subject(env('APP_NAME') . '-验证码(友链自助修改)'); + }); + } + public function viewEditFriend($friendId): Application|Factory|View|RedirectResponse { // 检查内容是否为空 @@ -254,10 +412,10 @@ public function viewEditFriend($friendId): Application|Factory|View|RedirectResp // 检查是否存在Cookie作为已验证 if (Request::hasCookie('friend_edit')) { // 检查COOKIE与所验证ID是否匹配 - if (password_verify($friendId,Request::cookie('friend_edit'))) { + if (password_verify($friendId, Request::cookie('friend_edit'))) { return view('function.edit-friend', $this->data); } else { - response()->withCookie(cookie('friend_edit',null,time()-1)); + response()->withCookie(cookie('friend_edit', null, time() - 1)); return Response::redirectTo(route('function.edit-search')); } } else { -- 2.43.0 From 6f88364d3a011be4256c14343f8eee0465a5b2fd Mon Sep 17 00:00:00 2001 From: XiaoLFeng Date: Wed, 28 Jun 2023 14:48:43 +0800 Subject: [PATCH 10/31] =?UTF-8?q?=E7=BC=96=E8=BE=91=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/views/console/friends-link/edit.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/console/friends-link/edit.blade.php b/resources/views/console/friends-link/edit.blade.php index 071f348..20a5b82 100644 --- a/resources/views/console/friends-link/edit.blade.php +++ b/resources/views/console/friends-link/edit.blade.php @@ -172,7 +172,7 @@ class="w-16 h-16 p-1 rounded-full ring-2 ring-gray-300 dark:ring-gray-500 me-2 s