From 2d267e55bac10003ea07396566d60d25c8ae8e9c Mon Sep 17 00:00:00 2001 From: XiaoLFeng Date: Tue, 27 Jun 2023 23:46:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=8B=E9=93=BE=E6=9F=A5=E6=89=BE=E6=A8=A1?= =?UTF-8?q?=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 !!} +