Compare commits

...

3 Commits

Author SHA1 Message Date
9c6893a67c Merge pull request 'master' (#2) from master into main
Reviewed-on: #2
2024-11-07 18:20:05 +08:00
Enoch
3f2862d118 更新:删除功能、Gov.cn的备案解决。 2024-11-07 18:11:45 +08:00
Enoch
15d968f0c8 s 2024-11-05 17:00:48 +08:00
4 changed files with 37 additions and 8 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
runtime/*
*.log

View File

@ -36,7 +36,6 @@ class Account
return redirect('/'); return redirect('/');
} }
$record=Db::table('links')->where('user', "$user")->get(); $record=Db::table('links')->where('user', "$user")->get();
print_r($record);
return view('my', ['user' => $user,'realname' => $realname,'record' => $record]); return view('my', ['user' => $user,'realname' => $realname,'record' => $record]);
} }
public function captcha(Request $request) public function captcha(Request $request)

View File

@ -26,8 +26,10 @@ class Server
} }
$realname=$session->get('realname',null); $realname=$session->get('realname',null);
#$domain=parse_url($url)['host'];
$domain=$url; $domain=$url;
$domain_name=parse_url($url)['host'];
$response = Http::post('https://api.uutool.cn/beian/icp/', ['site' => "$domain"])->json(); $response = Http::post('https://api.uutool.cn/beian/icp/', ['site' => "$domain"])->json();
if(isset($response->data->is_icp)){ if(isset($response->data->is_icp)){
if($response->data->is_icp==1){ if($response->data->is_icp==1){
@ -35,13 +37,19 @@ class Server
$owner=$icp->icp_org; $owner=$icp->icp_org;
$webid=$icp->icp_no; $webid=$icp->icp_no;
}else{ }else{
$icp=null; if(str_ends_with($domain_name, '.gov.cn')){
if($user==null){ $icp='GOV';
$owner='anonymous'; $owner='政府机构';
$webid='GOVERNMENT_WEBSITE';
}else{ }else{
$owner=$realname; $icp=null;
if($user==null){
$owner='anonymous';
}else{
$owner=$realname;
}
$webid=null;
} }
$webid=null;
} }
}else{ }else{
return json(['code' => 405, 'msg' => '备案查询接口响应异常,请稍后重试']); 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');
}
} }

View File

@ -20,6 +20,7 @@ Route::any('/!/loginapi', [app\controller\Account::class, 'loginapi']);
Route::any('/!/my', [app\controller\Account::class, 'my']); Route::any('/!/my', [app\controller\Account::class, 'my']);
Route::any('/!/logout', [app\controller\Account::class, 'logout']); Route::any('/!/logout', [app\controller\Account::class, 'logout']);
Route::any('/!/captcha', [app\controller\Account::class, 'captcha']); 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::any('/{link}', [app\controller\Server::class, 'view']);
Route::fallback(function(){ Route::fallback(function(){
return redirect('/'); return redirect('/');