first
This commit is contained in:
commit
e187878b7a
23
.env.example
Normal file
23
.env.example
Normal file
@ -0,0 +1,23 @@
|
||||
proxy=
|
||||
#Tor的Socks5代理
|
||||
|
||||
RedisHost=
|
||||
#Redis主机名
|
||||
|
||||
RedisPassword=
|
||||
#Redis密码
|
||||
|
||||
RedisPort=6379
|
||||
#Redis端口
|
||||
|
||||
RedisDatabase=1
|
||||
#Redis数据库号
|
||||
|
||||
ZlibraryLogin=loginzlib2vrak5zzpcocc3ouizykn6k5qecgj2tzlnab5wcbqhembyd.onion
|
||||
#除非Zlib的洋葱域名改变否则无需更改
|
||||
|
||||
Zlibrary=bookszlibb74ugqojhzhg2a63w5i2atv5bqarulgczawnbmsb6s6qead.onion
|
||||
#除非Zlib的洋葱域名改变否则无需更改
|
||||
|
||||
version=1.0.1
|
||||
#无需更改
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.env
|
0
.history/.env_20230101172316
Normal file
0
.history/.env_20230101172316
Normal file
1
.history/.env_20230101172348
Normal file
1
.history/.env_20230101172348
Normal file
@ -0,0 +1 @@
|
||||
proxy = 45.150.224.46:19100
|
1
.history/.env_20230101173049
Normal file
1
.history/.env_20230101173049
Normal file
@ -0,0 +1 @@
|
||||
proxy = 10.1.5.2:19100
|
5
.history/.env_20230101181726
Normal file
5
.history/.env_20230101181726
Normal file
@ -0,0 +1,5 @@
|
||||
proxy = 10.1.5.2:19100
|
||||
redis.host = 121.228.166.201
|
||||
redis.password = qi2005112
|
||||
redis.port = 16379
|
||||
redis.database = 17
|
5
.history/.env_20230101182453
Normal file
5
.history/.env_20230101182453
Normal file
@ -0,0 +1,5 @@
|
||||
proxy = 10.1.5.2:19100
|
||||
redis.host = 121.228.166.201
|
||||
redis.password = Qi2005112!
|
||||
redis.port = 16379
|
||||
redis.database = 17
|
5
.history/.env_20230101182642
Normal file
5
.history/.env_20230101182642
Normal file
@ -0,0 +1,5 @@
|
||||
proxy = 10.1.5.2:19100
|
||||
redis.host = 121.228.166.201
|
||||
redispassword = Qi2005112!
|
||||
redis.port = 16379
|
||||
redis.database = 17
|
5
.history/.env_20230101182748
Normal file
5
.history/.env_20230101182748
Normal file
@ -0,0 +1,5 @@
|
||||
proxy=10.1.5.2:19100
|
||||
RedisHost=121.228.166.201
|
||||
RedisPassword=Qi2005112!
|
||||
RedisPort=16379
|
||||
RedisDatabase=17
|
7
.history/.env_20230101191643
Normal file
7
.history/.env_20230101191643
Normal file
@ -0,0 +1,7 @@
|
||||
proxy=10.1.5.2:19100
|
||||
RedisHost=121.228.166.201
|
||||
RedisPassword=Qi2005112!
|
||||
RedisPort=16379
|
||||
RedisDatabase=17
|
||||
ZlibraryLogin=http://loginzlib2vrak5zzpcocc3ouizykn6k5qecgj2tzlnab5wcbqhembyd.onion/
|
||||
Zlibrary=http://bookszlibb74ugqojhzhg2a63w5i2atv5bqarulgczawnbmsb6s6qead.onion/
|
8
.history/.env_20230101203601
Normal file
8
.history/.env_20230101203601
Normal file
@ -0,0 +1,8 @@
|
||||
proxy=10.1.5.2:19100
|
||||
RedisHost=121.228.166.201
|
||||
RedisPassword=Qi2005112!
|
||||
RedisPort=16379
|
||||
RedisDatabase=17
|
||||
ZlibraryLogin=http://loginzlib2vrak5zzpcocc3ouizykn6k5qecgj2tzlnab5wcbqhembyd.onion/
|
||||
Zlibrary=http://bookszlibb74ugqojhzhg2a63w5i2atv5bqarulgczawnbmsb6s6qead.onion/
|
||||
version=1.0.1
|
8
.history/.env_20230101205534
Normal file
8
.history/.env_20230101205534
Normal file
@ -0,0 +1,8 @@
|
||||
proxy=10.1.5.2:19100
|
||||
RedisHost=121.228.166.201
|
||||
RedisPassword=Qi2005112!
|
||||
RedisPort=16379
|
||||
RedisDatabase=17
|
||||
ZlibraryLogin=http://loginzlib2vrak5zzpcocc3ouizykn6k5qecgj2tzlnab5wcbqhembyd.onion
|
||||
Zlibrary=http://bookszlibb74ugqojhzhg2a63w5i2atv5bqarulgczawnbmsb6s6qead.onion
|
||||
version=1.0.1
|
8
.history/.env_20230101210425
Normal file
8
.history/.env_20230101210425
Normal file
@ -0,0 +1,8 @@
|
||||
proxy=10.1.5.2:19100
|
||||
RedisHost=121.228.166.201
|
||||
RedisPassword=Qi2005112!
|
||||
RedisPort=16379
|
||||
RedisDatabase=17
|
||||
ZlibraryLogin=loginzlib2vrak5zzpcocc3ouizykn6k5qecgj2tzlnab5wcbqhembyd.onion
|
||||
Zlibrary=bookszlibb74ugqojhzhg2a63w5i2atv5bqarulgczawnbmsb6s6qead.onion
|
||||
version=1.0.1
|
8
.history/.env_20230101220200
Normal file
8
.history/.env_20230101220200
Normal file
@ -0,0 +1,8 @@
|
||||
proxy=10.1.5.2:19100
|
||||
RedisHost=121.228.166.201
|
||||
RedisPassword=Qi2005112!
|
||||
RedisPort=16379
|
||||
RedisDatabase=17
|
||||
ZlibraryLogin=loginzlib2vrak5zzpcocc3ouizykn6k5qecgj2tzlnab5wcbqhembyd.onion
|
||||
Zlibrary=bookszlibb74ugqojhzhg2a63w5i2atv5bqarulgczawnbmsb6s6qead.onion/
|
||||
version=1.0.1
|
8
.history/.env_20230101220201
Normal file
8
.history/.env_20230101220201
Normal file
@ -0,0 +1,8 @@
|
||||
proxy=10.1.5.2:19100
|
||||
RedisHost=121.228.166.201
|
||||
RedisPassword=Qi2005112!
|
||||
RedisPort=16379
|
||||
RedisDatabase=17
|
||||
ZlibraryLogin=loginzlib2vrak5zzpcocc3ouizykn6k5qecgj2tzlnab5wcbqhembyd.onion
|
||||
Zlibrary=bookszlibb74ugqojhzhg2a63w5i2atv5bqarulgczawnbmsb6s6qead.onion
|
||||
version=1.0.1
|
0
.history/.env_20230101231839.example
Normal file
0
.history/.env_20230101231839.example
Normal file
15
.history/.env_20230101231841.example
Normal file
15
.history/.env_20230101231841.example
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2023 enoch@Laysense.com
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
23
.history/.env_20230101232035.example
Normal file
23
.history/.env_20230101232035.example
Normal file
@ -0,0 +1,23 @@
|
||||
proxy=
|
||||
#Tor的Socks5代理
|
||||
|
||||
RedisHost=
|
||||
#Redis主机名
|
||||
|
||||
RedisPassword=
|
||||
#Redis密码
|
||||
|
||||
RedisPort=6379
|
||||
#Redis端口
|
||||
|
||||
RedisDatabase=1
|
||||
#Redis数据库号
|
||||
|
||||
ZlibraryLogin=loginzlib2vrak5zzpcocc3ouizykn6k5qecgj2tzlnab5wcbqhembyd.onion
|
||||
#除非Zlib的洋葱域名改变否则无需更改
|
||||
|
||||
Zlibrary=bookszlibb74ugqojhzhg2a63w5i2atv5bqarulgczawnbmsb6s6qead.onion
|
||||
#除非Zlib的洋葱域名改变否则无需更改
|
||||
|
||||
version=1.0.1
|
||||
#无需更改
|
0
.history/.gitignore_20230101172312
Normal file
0
.history/.gitignore_20230101172312
Normal file
1
.history/.gitignore_20230101172323
Normal file
1
.history/.gitignore_20230101172323
Normal file
@ -0,0 +1 @@
|
||||
.env
|
0
.history/app/controller/File_20230102143247.php
Normal file
0
.history/app/controller/File_20230102143247.php
Normal file
15
.history/app/controller/File_20230102143249.php
Normal file
15
.history/app/controller/File_20230102143249.php
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2023 enoch@Laysense.com
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
17
.history/app/controller/File_20230102143332.php
Normal file
17
.history/app/controller/File_20230102143332.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
use Respect\Validation\Validator as v;
|
||||
use support\Request;
|
||||
use yzh52521\EasyHttp\Response;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
use yzh52521\EasyHttp\Http;
|
||||
use support\Redis;
|
||||
use support\View;
|
||||
|
||||
class File
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
19
.history/app/controller/File_20230102143346.php
Normal file
19
.history/app/controller/File_20230102143346.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
use Respect\Validation\Validator as v;
|
||||
use support\Request;
|
||||
use yzh52521\EasyHttp\Response;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
use yzh52521\EasyHttp\Http;
|
||||
use support\Redis;
|
||||
use support\View;
|
||||
|
||||
class File
|
||||
{
|
||||
public function check(Request $request)
|
||||
{
|
||||
}
|
||||
}
|
36
.history/app/controller/File_20230102152508.php
Normal file
36
.history/app/controller/File_20230102152508.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
use Respect\Validation\Validator as v;
|
||||
use support\Request;
|
||||
use yzh52521\EasyHttp\Response;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
use yzh52521\EasyHttp\Http;
|
||||
use support\Redis;
|
||||
use support\View;
|
||||
|
||||
class File
|
||||
{
|
||||
public function check(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
if($path=='blank'){
|
||||
return json(['code'=>500,'msg'=>'缺少参数']);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
|
||||
$file=base_path().'/books/'.$name.'bin'
|
||||
if(file_exists($file)){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>trans_byte(filesize($file))]);
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
}
|
||||
}
|
36
.history/app/controller/File_20230102154544.php
Normal file
36
.history/app/controller/File_20230102154544.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
use Respect\Validation\Validator as v;
|
||||
use support\Request;
|
||||
use yzh52521\EasyHttp\Response;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
use yzh52521\EasyHttp\Http;
|
||||
use support\Redis;
|
||||
use support\View;
|
||||
|
||||
class File
|
||||
{
|
||||
public function check(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
if($path=='blank'){
|
||||
return json(['code'=>500,'msg'=>'缺少参数']);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
|
||||
$file=base_path().'/books/'.$name.'bin';
|
||||
if(file_exists($file)){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>trans_byte(filesize($file))]);
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
}
|
||||
}
|
56
.history/app/controller/File_20230102165530.php
Normal file
56
.history/app/controller/File_20230102165530.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
use Respect\Validation\Validator as v;
|
||||
use support\Request;
|
||||
use yzh52521\EasyHttp\Response;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
use yzh52521\EasyHttp\Http;
|
||||
use support\Redis;
|
||||
use support\View;
|
||||
|
||||
class File
|
||||
{
|
||||
public function check(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
if($path=='blank'){
|
||||
return json(['code'=>500,'msg'=>'缺少参数']);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
|
||||
$file=base_path().'/books/'.$name.'bin';
|
||||
if(file_exists($file)){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>trans_byte(filesize($file))]);
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
}
|
||||
public function download(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh','selectedSiteMode'=>'books');
|
||||
$url=getenv('Zlibrary')."$path";
|
||||
$head=Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,getenv('Zlibrary'))->head($url);
|
||||
$size=round(($head->header('Content-Length')/1048576),2);
|
||||
if($size>=40){
|
||||
return json(['code'=>500,'msg'=>'文件太大了!']);
|
||||
}
|
||||
if($head->header('Content-Type')=='text/html; charset=UTF-8'){
|
||||
return json(['code'=>404,'msg'=>'链接错误']);
|
||||
}
|
||||
|
||||
|
||||
}
|
56
.history/app/controller/File_20230102170445.php
Normal file
56
.history/app/controller/File_20230102170445.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
use Respect\Validation\Validator as v;
|
||||
use support\Request;
|
||||
use yzh52521\EasyHttp\Response;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
use yzh52521\EasyHttp\Http;
|
||||
use support\Redis;
|
||||
use support\View;
|
||||
|
||||
class File
|
||||
{
|
||||
public function check(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
if($path=='blank'){
|
||||
return json(['code'=>500,'msg'=>'缺少参数']);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
|
||||
$file=base_path().'/books/'.$name.'bin';
|
||||
if(file_exists($file)){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>trans_byte(filesize($file))]);
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
}
|
||||
public function download(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh','selectedSiteMode'=>'books');
|
||||
$url=getenv('Zlibrary')."$path";
|
||||
$head=Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,getenv('Zlibrary'))->head($url);
|
||||
$size=round(($head->header('Content-Length')/1048576),2);
|
||||
if($size>=30){
|
||||
return json(['code'=>500,'msg'=>'文件太大了!']);
|
||||
}
|
||||
if($head->header('Content-Type')=='text/html; charset=UTF-8'){
|
||||
return json(['code'=>404,'msg'=>'链接错误']);
|
||||
}
|
||||
|
||||
|
||||
}
|
64
.history/app/controller/File_20230102171742.php
Normal file
64
.history/app/controller/File_20230102171742.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
use Respect\Validation\Validator as v;
|
||||
use support\Request;
|
||||
use yzh52521\EasyHttp\Response;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
use yzh52521\EasyHttp\Http;
|
||||
use support\Redis;
|
||||
use support\View;
|
||||
|
||||
class File
|
||||
{
|
||||
public function check(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
if($path=='blank'){
|
||||
return json(['code'=>500,'msg'=>'缺少参数']);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
|
||||
$file=base_path().'/books/'.$name.'bin';
|
||||
if(file_exists($file)){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>trans_byte(filesize($file))]);
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
}
|
||||
public function download(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh','selectedSiteMode'=>'books');
|
||||
$url=getenv('Zlibrary')."$path";
|
||||
$get=Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,getenv('Zlibrary'))
|
||||
$head=$get->head($url);
|
||||
$size=round(($head->header('Content-Length')/1048576),2);
|
||||
if($size>=30){
|
||||
return json(['code'=>500,'msg'=>'文件太大了!']);
|
||||
}
|
||||
if($head->header('Content-Type')=='text/html; charset=UTF-8'){
|
||||
return json(['code'=>404,'msg'=>'链接错误']);
|
||||
}
|
||||
$redis = Redis::connection('default');
|
||||
$redis->hset('BookCache_'.base64_encode($path),'Time',time());
|
||||
$redis->hset('BookCache_'.base64_encode($path),'Date',date("Y/m/d H:i:s"));
|
||||
mkdir(base_path().'/books/'.date("Y/m/"),0777,true);
|
||||
$filepath=base_path().'/books/'.date("Y/m/").$name.'bin';
|
||||
$return=$get->get($url);
|
||||
$file = fopen("$filepath","w");
|
||||
|
||||
|
||||
}
|
64
.history/app/controller/File_20230102171809.php
Normal file
64
.history/app/controller/File_20230102171809.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
use Respect\Validation\Validator as v;
|
||||
use support\Request;
|
||||
use yzh52521\EasyHttp\Response;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
use yzh52521\EasyHttp\Http;
|
||||
use support\Redis;
|
||||
use support\View;
|
||||
|
||||
class File
|
||||
{
|
||||
public function check(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
if($path=='blank'){
|
||||
return json(['code'=>500,'msg'=>'缺少参数']);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
|
||||
$file=base_path().'/books/'.$name.'bin';
|
||||
if(file_exists($file)){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>trans_byte(filesize($file))]);
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
}
|
||||
public function download(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh','selectedSiteMode'=>'books');
|
||||
$url=getenv('Zlibrary')."$path";
|
||||
$get=Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,getenv('Zlibrary'));
|
||||
$head=$get->head($url);
|
||||
$size=round(($head->header('Content-Length')/1048576),2);
|
||||
if($size>=30){
|
||||
return json(['code'=>500,'msg'=>'文件太大了!']);
|
||||
}
|
||||
if($head->header('Content-Type')=='text/html; charset=UTF-8'){
|
||||
return json(['code'=>404,'msg'=>'链接错误']);
|
||||
}
|
||||
$redis = Redis::connection('default');
|
||||
$redis->hset('BookCache_'.base64_encode($path),'Time',time());
|
||||
$redis->hset('BookCache_'.base64_encode($path),'Date',date("Y/m/d H:i:s"));
|
||||
mkdir(base_path().'/books/'.date("Y/m/"),0777,true);
|
||||
$filepath=base_path().'/books/'.date("Y/m/").$name.'bin';
|
||||
$return=$get->get($url);
|
||||
$file = fopen("$filepath","w");
|
||||
|
||||
|
||||
}
|
65
.history/app/controller/File_20230102171818.php
Normal file
65
.history/app/controller/File_20230102171818.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
use Respect\Validation\Validator as v;
|
||||
use support\Request;
|
||||
use yzh52521\EasyHttp\Response;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
use yzh52521\EasyHttp\Http;
|
||||
use support\Redis;
|
||||
use support\View;
|
||||
|
||||
class File
|
||||
{
|
||||
public function check(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
if($path=='blank'){
|
||||
return json(['code'=>500,'msg'=>'缺少参数']);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
|
||||
$file=base_path().'/books/'.$name.'bin';
|
||||
if(file_exists($file)){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>trans_byte(filesize($file))]);
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
}
|
||||
public function download(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh','selectedSiteMode'=>'books');
|
||||
$url=getenv('Zlibrary')."$path";
|
||||
$get=Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,getenv('Zlibrary'));
|
||||
$head=$get->head($url);
|
||||
$size=round(($head->header('Content-Length')/1048576),2);
|
||||
if($size>=30){
|
||||
return json(['code'=>500,'msg'=>'文件太大了!']);
|
||||
}
|
||||
if($head->header('Content-Type')=='text/html; charset=UTF-8'){
|
||||
return json(['code'=>404,'msg'=>'链接错误']);
|
||||
}
|
||||
$redis = Redis::connection('default');
|
||||
$redis->hset('BookCache_'.base64_encode($path),'Time',time());
|
||||
$redis->hset('BookCache_'.base64_encode($path),'Date',date("Y/m/d H:i:s"));
|
||||
mkdir(base_path().'/books/'.date("Y/m/"),0777,true);
|
||||
$filepath=base_path().'/books/'.date("Y/m/").$name.'bin';
|
||||
$return=$get->get($url);
|
||||
$file = fopen("$filepath","w");
|
||||
}
|
||||
|
||||
|
||||
}
|
72
.history/app/controller/File_20230102172707.php
Normal file
72
.history/app/controller/File_20230102172707.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
use Respect\Validation\Validator as v;
|
||||
use support\Request;
|
||||
use yzh52521\EasyHttp\Response;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
use yzh52521\EasyHttp\Http;
|
||||
use support\Redis;
|
||||
use support\View;
|
||||
|
||||
class File
|
||||
{
|
||||
public function check(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
if($path=='blank'){
|
||||
return json(['code'=>500,'msg'=>'缺少参数']);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
|
||||
$file=base_path().'/books/'.$name.'bin';
|
||||
if(file_exists($file)){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>trans_byte(filesize($file))]);
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
}
|
||||
public function download(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh','selectedSiteMode'=>'books');
|
||||
$url=getenv('Zlibrary')."$path";
|
||||
$get=Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,getenv('Zlibrary'));
|
||||
$head=$get->head($url);
|
||||
$size=round(($head->header('Content-Length')/1048576),2);
|
||||
if($size>=30){
|
||||
return json(['code'=>500,'msg'=>'文件太大了!']);
|
||||
}
|
||||
if($head->header('Content-Type')=='text/html; charset=UTF-8'){
|
||||
return json(['code'=>404,'msg'=>'链接错误']);
|
||||
}
|
||||
$redis = Redis::connection('default');
|
||||
$redis->hset('BookCache_'.$name,'Time',time());
|
||||
$redis->hset('BookCache_'.$name,'Date',date("Y/m/d H:i:s"));
|
||||
if(!is_dir(base_path().'/books/'.date("Y/m/"))){
|
||||
mkdir(base_path().'/books/'.date("Y/m/"),0777,true);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
$filepath=base_path().'/books/'.date("Y/m/").$name.'.bin';
|
||||
$return=$get->get($url);
|
||||
$file = fopen("$filepath","w");
|
||||
fwrite($file,$return);
|
||||
fclose($file);
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
return json(['code'=>200]);
|
||||
}
|
||||
|
||||
|
||||
}
|
74
.history/app/controller/File_20230102172825.php
Normal file
74
.history/app/controller/File_20230102172825.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
use Respect\Validation\Validator as v;
|
||||
use support\Request;
|
||||
use yzh52521\EasyHttp\Response;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
use yzh52521\EasyHttp\Http;
|
||||
use support\Redis;
|
||||
use support\View;
|
||||
|
||||
class File
|
||||
{
|
||||
public function check(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
if($path=='blank'){
|
||||
return json(['code'=>500,'msg'=>'缺少参数']);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
|
||||
$file=base_path().'/books/'.$name.'bin';
|
||||
if(file_exists($file)){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>trans_byte(filesize($file))]);
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
}
|
||||
public function download(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh','selectedSiteMode'=>'books');
|
||||
$url=getenv('Zlibrary')."$path";
|
||||
$get=Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,getenv('Zlibrary'));
|
||||
$head=$get->head($url);
|
||||
$size=round(($head->header('Content-Length')/1048576),2);
|
||||
if($size>=30){
|
||||
return json(['code'=>500,'msg'=>'文件太大了!']);
|
||||
}
|
||||
if($head->header('Content-Type')=='text/html; charset=UTF-8'){
|
||||
return json(['code'=>404,'msg'=>'链接错误']);
|
||||
}
|
||||
$redis = Redis::connection('default');
|
||||
$redis->hset('BookCache_'.$name,'Time',time());
|
||||
$redis->hset('BookCache_'.$name,'Date',date("Y/m/d H:i:s"));
|
||||
if(!is_dir(base_path().'/books/'.date("Y/m/"))){
|
||||
mkdir(base_path().'/books/'.date("Y/m/"),0777,true);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
$filepath=base_path().'/books/'.date("Y/m/").$name.'.bin';
|
||||
$return=$get->get($url);
|
||||
$file = fopen("$filepath","w");
|
||||
fwrite($file,$return);
|
||||
fclose($file);
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
$redis->hset('BookCache_'.$name,'Size',$size);
|
||||
$redis->hset('BookCache_'.$name,'Status','OK');
|
||||
return json(['code'=>200]);
|
||||
}
|
||||
|
||||
|
||||
}
|
75
.history/app/controller/File_20230102172833.php
Normal file
75
.history/app/controller/File_20230102172833.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
use Respect\Validation\Validator as v;
|
||||
use support\Request;
|
||||
use yzh52521\EasyHttp\Response;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
use yzh52521\EasyHttp\Http;
|
||||
use support\Redis;
|
||||
use support\View;
|
||||
|
||||
class File
|
||||
{
|
||||
public function check(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
if($path=='blank'){
|
||||
return json(['code'=>500,'msg'=>'缺少参数']);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
|
||||
$file=base_path().'/books/'.$name.'bin';
|
||||
if(file_exists($file)){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>trans_byte(filesize($file))]);
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
}
|
||||
public function download(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh','selectedSiteMode'=>'books');
|
||||
$url=getenv('Zlibrary')."$path";
|
||||
$get=Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,getenv('Zlibrary'));
|
||||
$head=$get->head($url);
|
||||
$size=round(($head->header('Content-Length')/1048576),2);
|
||||
if($size>=30){
|
||||
return json(['code'=>500,'msg'=>'文件太大了!']);
|
||||
}
|
||||
if($head->header('Content-Type')=='text/html; charset=UTF-8'){
|
||||
return json(['code'=>404,'msg'=>'链接错误']);
|
||||
}
|
||||
$redis = Redis::connection('default');
|
||||
$redis->hset('BookCache_'.$name,'Time',time());
|
||||
$redis->hset('BookCache_'.$name,'Date',date("Y/m/d H:i:s"));
|
||||
$redis->hset('BookCache_'.$name,'Status','Downloading');
|
||||
if(!is_dir(base_path().'/books/'.date("Y/m/"))){
|
||||
mkdir(base_path().'/books/'.date("Y/m/"),0777,true);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
$filepath=base_path().'/books/'.date("Y/m/").$name.'.bin';
|
||||
$return=$get->get($url);
|
||||
$file = fopen("$filepath","w");
|
||||
fwrite($file,$return);
|
||||
fclose($file);
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
$redis->hset('BookCache_'.$name,'Size',$size);
|
||||
$redis->hset('BookCache_'.$name,'Status','OK');
|
||||
return json(['code'=>200]);
|
||||
}
|
||||
|
||||
|
||||
}
|
79
.history/app/controller/File_20230102173122.php
Normal file
79
.history/app/controller/File_20230102173122.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
use Respect\Validation\Validator as v;
|
||||
use support\Request;
|
||||
use yzh52521\EasyHttp\Response;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
use yzh52521\EasyHttp\Http;
|
||||
use support\Redis;
|
||||
use support\View;
|
||||
|
||||
class File
|
||||
{
|
||||
public function check(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
if($path=='blank'){
|
||||
return json(['code'=>500,'msg'=>'缺少参数']);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
$redis = Redis::connection('default');
|
||||
$file=base_path().'/books/'.$name.'bin';
|
||||
if($redis->exist('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>$redis->hget('BookCache_'.$name,'Size')]);
|
||||
}else{
|
||||
return json(['code'=>202,'msg'=>'文件下载中'])
|
||||
}
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
}
|
||||
public function download(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh','selectedSiteMode'=>'books');
|
||||
$url=getenv('Zlibrary')."$path";
|
||||
$get=Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,getenv('Zlibrary'));
|
||||
$head=$get->head($url);
|
||||
$size=round(($head->header('Content-Length')/1048576),2);
|
||||
if($size>=30){
|
||||
return json(['code'=>500,'msg'=>'文件太大了!']);
|
||||
}
|
||||
if($head->header('Content-Type')=='text/html; charset=UTF-8'){
|
||||
return json(['code'=>404,'msg'=>'链接错误']);
|
||||
}
|
||||
$redis = Redis::connection('default');
|
||||
$redis->hset('BookCache_'.$name,'Time',time());
|
||||
$redis->hset('BookCache_'.$name,'Date',date("Y/m/d H:i:s"));
|
||||
$redis->hset('BookCache_'.$name,'Status','Downloading');
|
||||
if(!is_dir(base_path().'/books/'.date("Y/m/"))){
|
||||
mkdir(base_path().'/books/'.date("Y/m/"),0777,true);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
$filepath=base_path().'/books/'.date("Y/m/").$name.'.bin';
|
||||
$return=$get->get($url);
|
||||
$file = fopen("$filepath","w");
|
||||
fwrite($file,$return);
|
||||
fclose($file);
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
$redis->hset('BookCache_'.$name,'Size',$size);
|
||||
$redis->hset('BookCache_'.$name,'Status','OK');
|
||||
return json(['code'=>200]);
|
||||
}
|
||||
|
||||
|
||||
}
|
79
.history/app/controller/File_20230102173124.php
Normal file
79
.history/app/controller/File_20230102173124.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
use Respect\Validation\Validator as v;
|
||||
use support\Request;
|
||||
use yzh52521\EasyHttp\Response;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
use yzh52521\EasyHttp\Http;
|
||||
use support\Redis;
|
||||
use support\View;
|
||||
|
||||
class File
|
||||
{
|
||||
public function check(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
if($path=='blank'){
|
||||
return json(['code'=>500,'msg'=>'缺少参数']);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
$redis = Redis::connection('default');
|
||||
$file=base_path().'/books/'.$name.'bin';
|
||||
if($redis->exist('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>$redis->hget('BookCache_'.$name,'Size')]);
|
||||
}else{
|
||||
return json(['code'=>202,'msg'=>'文件下载中']);
|
||||
}
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
}
|
||||
public function download(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh','selectedSiteMode'=>'books');
|
||||
$url=getenv('Zlibrary')."$path";
|
||||
$get=Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,getenv('Zlibrary'));
|
||||
$head=$get->head($url);
|
||||
$size=round(($head->header('Content-Length')/1048576),2);
|
||||
if($size>=30){
|
||||
return json(['code'=>500,'msg'=>'文件太大了!']);
|
||||
}
|
||||
if($head->header('Content-Type')=='text/html; charset=UTF-8'){
|
||||
return json(['code'=>404,'msg'=>'链接错误']);
|
||||
}
|
||||
$redis = Redis::connection('default');
|
||||
$redis->hset('BookCache_'.$name,'Time',time());
|
||||
$redis->hset('BookCache_'.$name,'Date',date("Y/m/d H:i:s"));
|
||||
$redis->hset('BookCache_'.$name,'Status','Downloading');
|
||||
if(!is_dir(base_path().'/books/'.date("Y/m/"))){
|
||||
mkdir(base_path().'/books/'.date("Y/m/"),0777,true);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
$filepath=base_path().'/books/'.date("Y/m/").$name.'.bin';
|
||||
$return=$get->get($url);
|
||||
$file = fopen("$filepath","w");
|
||||
fwrite($file,$return);
|
||||
fclose($file);
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
$redis->hset('BookCache_'.$name,'Size',$size);
|
||||
$redis->hset('BookCache_'.$name,'Status','OK');
|
||||
return json(['code'=>200]);
|
||||
}
|
||||
|
||||
|
||||
}
|
79
.history/app/controller/File_20230102173125.php
Normal file
79
.history/app/controller/File_20230102173125.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
use Respect\Validation\Validator as v;
|
||||
use support\Request;
|
||||
use yzh52521\EasyHttp\Response;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
use yzh52521\EasyHttp\Http;
|
||||
use support\Redis;
|
||||
use support\View;
|
||||
|
||||
class File
|
||||
{
|
||||
public function check(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
if($path=='blank'){
|
||||
return json(['code'=>500,'msg'=>'缺少参数']);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
$redis = Redis::connection('default');
|
||||
$file=base_path().'/books/'.$name.'bin';
|
||||
if($redis->exist('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>$redis->hget('BookCache_'.$name,'Size')]);
|
||||
}else{
|
||||
return json(['code'=>202,'msg'=>'文件下载中']);
|
||||
}
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
}
|
||||
public function download(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录']);
|
||||
}
|
||||
$path=$request->input('path','blank');
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh','selectedSiteMode'=>'books');
|
||||
$url=getenv('Zlibrary')."$path";
|
||||
$get=Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,getenv('Zlibrary'));
|
||||
$head=$get->head($url);
|
||||
$size=round(($head->header('Content-Length')/1048576),2);
|
||||
if($size>=30){
|
||||
return json(['code'=>500,'msg'=>'文件太大了!']);
|
||||
}
|
||||
if($head->header('Content-Type')=='text/html; charset=UTF-8'){
|
||||
return json(['code'=>404,'msg'=>'链接错误']);
|
||||
}
|
||||
$redis = Redis::connection('default');
|
||||
$redis->hset('BookCache_'.$name,'Time',time());
|
||||
$redis->hset('BookCache_'.$name,'Date',date("Y/m/d H:i:s"));
|
||||
$redis->hset('BookCache_'.$name,'Status','Downloading');
|
||||
if(!is_dir(base_path().'/books/'.date("Y/m/"))){
|
||||
mkdir(base_path().'/books/'.date("Y/m/"),0777,true);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
$filepath=base_path().'/books/'.date("Y/m/").$name.'.bin';
|
||||
$return=$get->get($url);
|
||||
$file = fopen("$filepath","w");
|
||||
fwrite($file,$return);
|
||||
fclose($file);
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
$redis->hset('BookCache_'.$name,'Size',$size);
|
||||
$redis->hset('BookCache_'.$name,'Status','OK');
|
||||
return json(['code'=>200]);
|
||||
}
|
||||
|
||||
|
||||
}
|
82
.history/app/controller/File_20230102173220.php
Normal file
82
.history/app/controller/File_20230102173220.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
use Respect\Validation\Validator as v;
|
||||
use support\Request;
|
||||
use yzh52521\EasyHttp\Response;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
use yzh52521\EasyHttp\Http;
|
||||
use support\Redis;
|
||||
use support\View;
|
||||
|
||||
class File
|
||||
{
|
||||
public function check(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->input('path','blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录或参数错误']);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
$redis = Redis::connection('default');
|
||||
$file=base_path().'/books/'.$name.'bin';
|
||||
if($redis->exist('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>$redis->hget('BookCache_'.$name,'Size')]);
|
||||
}else{
|
||||
return json(['code'=>202,'msg'=>'文件下载中']);
|
||||
}
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
}
|
||||
public function download(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->input('path','blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录或参数错误']);
|
||||
}
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh','selectedSiteMode'=>'books');
|
||||
$url=getenv('Zlibrary')."$path";
|
||||
$get=Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,getenv('Zlibrary'));
|
||||
$head=$get->head($url);
|
||||
$size=round(($head->header('Content-Length')/1048576),2);
|
||||
if($size>=30){
|
||||
return json(['code'=>500,'msg'=>'文件太大了!']);
|
||||
}
|
||||
if($head->header('Content-Type')=='text/html; charset=UTF-8'){
|
||||
return json(['code'=>404,'msg'=>'链接错误']);
|
||||
}
|
||||
$redis = Redis::connection('default');
|
||||
$redis->hset('BookCache_'.$name,'Time',time());
|
||||
$redis->hset('BookCache_'.$name,'Date',date("Y/m/d H:i:s"));
|
||||
$redis->hset('BookCache_'.$name,'Status','Downloading');
|
||||
if(!is_dir(base_path().'/books/'.date("Y/m/"))){
|
||||
mkdir(base_path().'/books/'.date("Y/m/"),0777,true);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
$filepath=base_path().'/books/'.date("Y/m/").$name.'.bin';
|
||||
$return=$get->get($url);
|
||||
$file = fopen("$filepath","w");
|
||||
fwrite($file,$return);
|
||||
fclose($file);
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
$redis->hset('BookCache_'.$name,'Size',$size);
|
||||
$redis->hset('BookCache_'.$name,'Status','OK');
|
||||
return json(['code'=>200]);
|
||||
}
|
||||
public function download(Request $request)
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
97
.history/app/controller/File_20230102173627.php
Normal file
97
.history/app/controller/File_20230102173627.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
use Respect\Validation\Validator as v;
|
||||
use support\Request;
|
||||
use yzh52521\EasyHttp\Response;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
use yzh52521\EasyHttp\Http;
|
||||
use support\Redis;
|
||||
use support\View;
|
||||
|
||||
class File
|
||||
{
|
||||
public function check(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->input('path','blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录或参数错误']);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
$redis = Redis::connection('default');
|
||||
if($redis->exist('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>$redis->hget('BookCache_'.$name,'Size')]);
|
||||
}else{
|
||||
return json(['code'=>202,'msg'=>'文件下载中']);
|
||||
}
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
}
|
||||
public function download(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->input('path','blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录或参数错误']);
|
||||
}
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh','selectedSiteMode'=>'books');
|
||||
$url=getenv('Zlibrary')."$path";
|
||||
$get=Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,getenv('Zlibrary'));
|
||||
$head=$get->head($url);
|
||||
$size=round(($head->header('Content-Length')/1048576),2);
|
||||
if($size>=30){
|
||||
return json(['code'=>500,'msg'=>'文件太大了!']);
|
||||
}
|
||||
if($head->header('Content-Type')=='text/html; charset=UTF-8'){
|
||||
return json(['code'=>404,'msg'=>'链接错误']);
|
||||
}
|
||||
$redis = Redis::connection('default');
|
||||
$name=base64_encode($path);
|
||||
$redis->hset('BookCache_'.$name,'Time',time());
|
||||
$redis->hset('BookCache_'.$name,'Date',date("Y/m/d H:i:s"));
|
||||
$redis->hset('BookCache_'.$name,'Status','Downloading');
|
||||
if(!is_dir(base_path().'/books/'.date("Y/m/"))){
|
||||
mkdir(base_path().'/books/'.date("Y/m/"),0777,true);
|
||||
}
|
||||
|
||||
$filepath=base_path().'/books/'.date("Y/m/").$name.'.bin';
|
||||
$return=$get->get($url);
|
||||
$file = fopen("$filepath","w");
|
||||
fwrite($file,$return);
|
||||
fclose($file);
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
$redis->hset('BookCache_'.$name,'Size',$size);
|
||||
$redis->hset('BookCache_'.$name,'Status','OK');
|
||||
return json(['code'=>200]);
|
||||
}
|
||||
public function get(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->input('path','blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录或参数错误']);
|
||||
}
|
||||
$redis = Redis::connection('default');
|
||||
$name=base64_encode($path);
|
||||
if($redis->exist('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return response()->download($redis->hget('BookCache_'.$name,'Path'));
|
||||
}else{
|
||||
return json(['code'=>202,'msg'=>'文件仍在下载中']);
|
||||
}
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
99
.history/app/controller/File_20230102174259.php
Normal file
99
.history/app/controller/File_20230102174259.php
Normal file
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
use Respect\Validation\Validator as v;
|
||||
use support\Request;
|
||||
use yzh52521\EasyHttp\Response;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
use yzh52521\EasyHttp\Http;
|
||||
use support\Redis;
|
||||
use support\View;
|
||||
|
||||
class File
|
||||
{
|
||||
public function check(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->input('path','blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录或参数错误']);
|
||||
}
|
||||
$name=base64_encode($path);
|
||||
$redis = Redis::connection('default');
|
||||
if($redis->exist('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>$redis->hget('BookCache_'.$name,'Size')]);
|
||||
}else{
|
||||
return json(['code'=>202,'msg'=>'文件下载中']);
|
||||
}
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
}
|
||||
public function download(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->input('path','blank');
|
||||
if($key=='blank' || $id=='blank'){
|
||||
return json(['code'=>509,'msg'=>'未登录或参数错误']);
|
||||
}
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh','selectedSiteMode'=>'books');
|
||||
$url=getenv('Zlibrary')." |