diff --git a/.env.example b/.env.example index 63cf76e..1227151 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,5 @@ proxy= -#Tor的Socks5代理 +#Tor的Socks5代理,如 192.168.1.1:1080 RedisHost= #Redis主机名 @@ -19,5 +19,16 @@ ZlibraryLogin=loginzlib2vrak5zzpcocc3ouizykn6k5qecgj2tzlnab5wcbqhembyd.onion Zlibrary=bookszlibb74ugqojhzhg2a63w5i2atv5bqarulgczawnbmsb6s6qead.onion #除非Zlib的洋葱域名改变否则无需更改 -version=1.0.1 -#无需更改 \ No newline at end of file +reg_url="https://zh.singlelogin.rs/registration" +#注册按钮的链接 + +public_login=zh.singlelogin.rs +#公网登录域名 + +public_url=zh.z-library.rs +#公网域名 + +copyright=MimirLib +copyright_url="https://mimir.pp.ua" +version=1.2.2 +#无需更改 diff --git a/.gitignore b/.gitignore index b3da0af..294c86a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .env -.history \ No newline at end of file +.history +runtime/* +books/* diff --git a/app/controller/File.php b/app/controller/File.php index 2f4777d..dc24fd8 100644 --- a/app/controller/File.php +++ b/app/controller/File.php @@ -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 } -} \ No newline at end of file +} diff --git a/app/controller/IndexController.php b/app/controller/IndexController.php index d54f0ed..8d9bc80 100644 --- a/app/controller/IndexController.php +++ b/app/controller/IndexController.php @@ -19,6 +19,8 @@ class IndexController $response = response(); $id=$request->cookie('id', 'blank'); $key=$request->cookie('key', 'blank'); + $tor=$request->cookie('tor', 'false'); + if($key=='blank' || $id=='blank'){ return redirect('/login'); } @@ -34,29 +36,47 @@ class IndexController $response->withBody($redis->hget($rpath,'body')); return $response; } - - $url='http://'.getenv('Zlibrary').$path; - $auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh','selectedSiteMode'=>'books'); - $return = Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,getenv('Zlibrary'))->get($url); - $response->withHeaders($return->headers()); + + $host=getenv('public_url'); + $httpquery=Http::timeout(60); + $onion=''; + $torstatus='Off'; + if($tor=='true'){ + $host=getenv('Zlibrary'); + $httpquery=$httpquery->withProxy('socks5h://'.getenv('proxy')); + $onion=''; + $torstatus='On'; + } + + $url='http://'.$host.$path; + + $auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh','siteLanguage'=>'zh','selectedSiteMode'=>'books'); + $return = $httpquery->withCookies($auth,$host)->get($url); $back=$return->body(); if($return->header('Content-Type')=='text/html; charset=UTF-8'){ $ver=getenv('version'); + $copyright=getenv('copyright'); + $copyright_url=getenv('copyright_url'); + $front= <<
- Zlibrary Proxy(v$ver) UserID:$id [退出账号] [PublicMirrorsNetwork] + Zlibrary Proxy(v$ver) UserID:$id [$onion Tor $torstatus] [退出账号] [$copyright]
EOF; $back=$front.$back; } + $backhead=$return->headers(); + $backhead['Content-Length']=strlen($back); + + $response->withHeaders($backhead); /**Make Cache */ if($path=='/resources/build/global.js?0.495' || $path=='/resources/build/global.css?0.495' || $path=='/resources/ext/freewall.js' || preg_match("/^image*/",$return->header('Content-Type')) ){ - $redis->hset($rpath,'CT',json_encode($return->headers())); + $redis->hset($rpath,'CT',json_encode($backhead)); $redis->hset($rpath,'body',$back); $redis->expire($rpath,43200); } @@ -76,6 +96,8 @@ EOF; $username=$request->post('name','blank'); $password=$request->post('password','blank'); $code=$request->post('code','blank'); + $tor=$request->post('tor',false); + if($username=='blank' || $password=='blank' || $code=='blank'){ return json(['code'=>500, 'msg'=>'缺少参数']); } @@ -102,8 +124,15 @@ EOF; return json(['code' => 400, 'msg' => '输入的验证码不正确']); } - $url='http://'.getenv('ZlibraryLogin').'/rpc.php'; - $response = Http::withProxy('socks5h://'.getenv('proxy'))->post("$url", ['isModal' => true,'email'=>"$username",'password'=>"$password",'site_mode'=>'books','action'=>'login','redirectUrl'=>'','isSinglelogin'=>'1','isTorVersion'=>'1','gg_json_mode'=>'1']); + $url='https://'.getenv('public_login').'/rpc.php'; + $response=Http::timeout(60); + if($tor=='true'){ + $url='http://'.getenv('ZlibraryLogin').'/rpc.php'; + $response=$response->withProxy('socks5h://'.getenv('proxy')); + } + $response = $response->post("$url", ['isModal' => true,'email'=>"$username",'password'=>"$password",'site_mode'=>'books','action'=>'login','redirectUrl'=>'','isSinglelogin'=>'1','isTorVersion'=>'1','gg_json_mode'=>'1']); + #print_r($response); + if(!$response->successful()){ return json(['code' => 501, 'msg' => '登陆失败,服务端错误']); } @@ -112,7 +141,13 @@ EOF; if(isset($return->response->validationError)){ return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]); } - $url=parse_url($return->response->params)['query']; + #print_r($return->response); + $rawparma=$return->response->params; + if($tor=='true'){ + $rawparma=$return->response->priorityRedirectUrl; + } + $url=parse_url($rawparma)['query']; +#print_r($url); $queryParts = explode('&', $url); $params = array(); foreach ($queryParts as $param) { @@ -120,7 +155,7 @@ EOF; $params[$item[0]] = $item[1]; } - return json(['code'=>200,'msg'=>'登陆成功','userid'=>$params['remix_userid']])->cookie('id', $params['remix_userid'],43200,'/')->cookie('key', $params['remix_userkey'],43200,'/'); + return json(['code'=>200,'msg'=>'登陆成功','userid'=>$params['remix_userid']])->cookie('id', $params['remix_userid'],43200,'/')->cookie('key', $params['remix_userkey'],43200,'/')->cookie('tor', $tor,43200,'/'); } public function code(Request $request) { @@ -150,6 +185,8 @@ EOF; $id=$request->cookie('id', 'blank'); $key=$request->cookie('key', 'blank'); + $tor=$request->cookie('tor', 'false'); + if($key=='blank' || $id=='blank'){ return redirect('/login'); } @@ -158,6 +195,7 @@ EOF; 'id' => $id, 'key'=> $key, 'path'=> $path, + 'tor'=>$tor, ]); return view('index'); @@ -169,5 +207,17 @@ EOF; return response()->file(base_path() . '/app/controller/IndexController.php'); } + public function tor(Request $request) + { + $to=$request->input('to','/'); + $tor=$request->cookie('tor','false'); + if($tor=='true'){ + $tor='false'; + }else{ + $tor='true'; + } + return redirect($to)->cookie('tor', $tor,43200,'/'); + + } } diff --git a/app/view/index.html b/app/view/index.html index 80684a0..1e0b064 100644 --- a/app/view/index.html +++ b/app/view/index.html @@ -56,7 +56,15 @@
- Zlibrary Proxy(v) UserID: [退出账号] + '; + $torstatus='Off'; + if($tor=='true'){ + $onion=''; + $torstatus='On'; + } + ?> + Zlibrary Proxy(v) UserID: [ Tor ] [退出账号]
@@ -82,6 +90,9 @@ +
@@ -144,8 +155,10 @@ $('#start').hide(); } if (data.code == 500) { - $('#notice').html('文件过大(大于30Mb),暂时无法通过ZlibProxy下载'); + $('#notice').html('文件过大(大于30Mb),暂时无法通过ZlibProxy下载
但您可以尝试从外部链接下载(可能需要梯子)'); $('#start').hide(); + $('#outdown').show(); + window.outurl=data.url; } if (data.code == 400) { $('#notice').html('图书不存在……请尝试别的图书'); @@ -155,10 +168,19 @@ $('#notice').html('缺少参数或未登录'); setTimeout(function(){$(location).attr('href','/login')},1500); } + if (data.code == 808) { + $('#notice').html('Zlib要求您前往外部链接下载(可能是因为今日次数用完,或触发风控)
请点击前往外部链接查看(可能需要梯子)'); + $('#start').hide(); + $('#outdown').show(); + window.outurl=data.msg; + } $('#load').hide(); }, }); } + function outdownload(){ + window.open(window.outurl); + } diff --git a/app/view/login.html b/app/view/login.html index 29864aa..fdcef09 100644 --- a/app/view/login.html +++ b/app/view/login.html @@ -59,6 +59,68 @@ 90% { transform: scaley(1); } } + /* 开关 - 滑块周围的框 */ +.switch { + position: relative; + display: inline-block; + width: 60px; + height: 34px; +} + +/* 隐藏默认 HTML 复选框 */ +.switch input { + opacity: 0; + width: 0; + height: 0; +} + +/* 滑块 */ +.slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #2fbc47; + -webkit-transition: .4s; + transition: .4s; +} + +.slider:before { + position: absolute; + content: ""; + height: 26px; + width: 26px; + left: 4px; + bottom: 4px; + background-color: white; + -webkit-transition: .4s; + transition: .4s; +} + +input:checked + .slider { + background-color: #2196F3; +} + +input:focus + .slider { + box-shadow: 0 0 1px #2196F3; +} + +input:checked + .slider:before { + -webkit-transform: translateX(26px); + -ms-transform: translateX(26px); + transform: translateX(26px); +} + +/* 圆形滑块 */ +.slider.round { + border-radius: 34px; +} + +.slider.round:before { + border-radius: 50%; +} ZlibraryProxy-登录 @@ -73,8 +135,8 @@

Z-library Proxy


-

这是一个Zlibrary的代理镜像

- 由[PublicMirrorsNetwork]维护 +

这是一个Zlibrary的代理镜像 ver:

+ 由[]维护
本代理利用广大的Tor代理和中继节点,基于TOR技术提供服务 @@ -83,7 +145,7 @@
使用前请确保您的行为符合当地法律
- 由于Zlibrary的邮件服务器已经宕机,任何新注册和更改密码请求均无效,均无法使用,如果您的账号还未通过邮箱激活将无法使用本服务 + 选择公网时速度更快,当公网不可用时,请选择TOR网络,TOR网络速度较慢但更安全。
本代理不会保存您的密码(仅在浏览器cookies保存您的ID)
@@ -93,6 +155,11 @@

登录到Z-Library


+

公网 TOR网络 +

@@ -116,13 +183,16 @@

- 点击登录代表您同意并接受PMNET TOS + + +
+ 点击登录代表您同意并接受TOS