This commit is contained in:
2024-06-21 20:30:44 +08:00
parent ea68301ae2
commit 60e0273d25
8 changed files with 205 additions and 72 deletions
+19 -6
View File
@@ -38,20 +38,33 @@ class File
$id=$request->cookie('id', 'blank');
$key=$request->cookie('key', 'blank');
$path=$request->input('path','blank');
$tor=$request->cookie('tor', 'false');
if($key=='blank' || $id=='blank'){
return json(['code'=>509,'msg'=>'未登录或参数错误']);
}
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh','selectedSiteMode'=>'books');
$url='http://'.getenv('Zlibrary')."$path";
$get=Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,getenv('Zlibrary'));
$host=getenv('public_url');
$httpquery=Http::timeout(60);
if($tor=='true'){
$host=getenv('Zlibrary');
$httpquery=$httpquery->withProxy('socks5h://'.getenv('proxy'));
}
$url='http://'.$host.$path;
$get=$httpquery->withRedirect(['max'=> 5,'track_redirects' => true])->withCookies($auth,$host);
$head=$get->head($url);
$ContentLength=(int)$head->header('Content-Length');
$ContentLength=(int)$head->header('Content-Length');
$size=round(($ContentLength/1048576),2);
$redirectback=explode(', ',$head->header('X-Guzzle-Redirect-History'));
$outurl=end($redirectback);
if($size>=30){
return json(['code'=>500,'msg'=>'文件太大了!']);
return json(['code'=>500,'msg'=>'文件太大了!','url'=>$outurl]);
}
if($head->header('Content-Type')=='text/html; charset=UTF-8'){
return json(['code'=>404,'msg'=>'链接错误']);
# print_r($head);
# return json(['code'=>404,'msg'=>'链接错误']);
return json(['code'=>808,'msg'=>$outurl]);
}
$redis = Redis::connection('default');
$name=base64_encode($path);
@@ -98,4 +111,4 @@ class File
}
}
}