master #2

Merged
enoch merged 2 commits from master into main 2024-11-07 18:20:06 +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('/');
}
$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)

View File

@ -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');
}
}

View File

@ -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('/');