From 15d968f0c879c1ea0bc19459fdb9096c1ba968b6 Mon Sep 17 00:00:00 2001 From: Enoch Date: Tue, 5 Nov 2024 17:00:48 +0800 Subject: [PATCH 1/2] s --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b803ddc --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +runtime/* +*.log \ No newline at end of file From 3f2862d11849386076eefd0bdaa572b57c52b5cf Mon Sep 17 00:00:00 2001 From: Enoch Date: Thu, 7 Nov 2024 18:11:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0:=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E3=80=81Gov.cn=E7=9A=84=E5=A4=87=E6=A1=88?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/Account.php | 1 - app/controller/Server.php | 41 +++++++++++++++++++++++++++++++------- config/route.php | 1 + 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/app/controller/Account.php b/app/controller/Account.php index 3be9be3..6fe95e6 100644 --- a/app/controller/Account.php +++ b/app/controller/Account.php @@ -36,7 +36,6 @@ class Account return redirect('/'); } $record=Db::table('links')->where('user', "$user")->get(); - print_r($record); return view('my', ['user' => $user,'realname' => $realname,'record' => $record]); } public function captcha(Request $request) diff --git a/app/controller/Server.php b/app/controller/Server.php index 61c66f5..9323a56 100644 --- a/app/controller/Server.php +++ b/app/controller/Server.php @@ -26,8 +26,10 @@ class Server } $realname=$session->get('realname',null); - #$domain=parse_url($url)['host']; $domain=$url; + $domain_name=parse_url($url)['host']; + + $response = Http::post('https://api.uutool.cn/beian/icp/', ['site' => "$domain"])->json(); if(isset($response->data->is_icp)){ if($response->data->is_icp==1){ @@ -35,13 +37,19 @@ class Server $owner=$icp->icp_org; $webid=$icp->icp_no; }else{ - $icp=null; - if($user==null){ - $owner='anonymous'; + if(str_ends_with($domain_name, '.gov.cn')){ + $icp='GOV'; + $owner='政府机构'; + $webid='GOVERNMENT_WEBSITE'; }else{ - $owner=$realname; + $icp=null; + if($user==null){ + $owner='anonymous'; + }else{ + $owner=$realname; + } + $webid=null; } - $webid=null; } }else{ return json(['code' => 405, 'msg' => '备案查询接口响应异常,请稍后重试']); @@ -102,6 +110,25 @@ class Server } } - + public function delete(Request $request,$link) + { + $session = $request->session(); + $user=$session->get('user',null); + if($user==null){ + return json(['code' => 505, 'msg' => '需要登陆后才可使用']); + } + if($link==null){ + return json(['code' => 404, 'msg' => '缺少参数']); + } + $source=Db::table('links')->where('link', "$link")->first(); + if($source==null){ + return json(['code' => 404, 'msg' => '链接不存在']); + } + if($source->user!=$user){ + return json(['code' => 403, 'msg' => '无权删除']); + } + Db::table('links')->where('link', "$link")->delete(); + return redirect('/!/my'); + } } diff --git a/config/route.php b/config/route.php index 8c73113..e381c41 100644 --- a/config/route.php +++ b/config/route.php @@ -20,6 +20,7 @@ Route::any('/!/loginapi', [app\controller\Account::class, 'loginapi']); Route::any('/!/my', [app\controller\Account::class, 'my']); Route::any('/!/logout', [app\controller\Account::class, 'logout']); Route::any('/!/captcha', [app\controller\Account::class, 'captcha']); +Route::any('/!/delete/{link}', [app\controller\Server::class, 'delete']); Route::any('/{link}', [app\controller\Server::class, 'view']); Route::fallback(function(){ return redirect('/');