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')."$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);
|
||||
$filerealname=explode('"',explode(";",$head->header('Content-Disposition'))[1])[1];
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
$redis->hset('BookCache_'.$name,'Size',$size);
|
||||
$redis->hset('BookCache_'.$name,'Name',$filerealname);
|
||||
$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_20230102174312.php
Normal file
99
.history/app/controller/File_20230102174312.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')."$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);
|
||||
$filerealname=explode('"',explode(";",$head->header('Content-Disposition'))[1])[1];
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
$redis->hset('BookCache_'.$name,'Size',$size);
|
||||
$redis->hset('BookCache_'.$name,'Name',$filerealname);
|
||||
$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'),$redis->hget('BookCache_'.$name,'Name'));
|
||||
}else{
|
||||
return json(['code'=>202,'msg'=>'文件仍在下载中']);
|
||||
}
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
99
.history/app/controller/File_20230102182057.php
Normal file
99
.history/app/controller/File_20230102182057.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'),'name'=>$redis->hget('BookCache_'.$name,'Name')]);
|
||||
}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);
|
||||
$filerealname=explode('"',explode(";",$head->header('Content-Disposition'))[1])[1];
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
$redis->hset('BookCache_'.$name,'Size',$size);
|
||||
$redis->hset('BookCache_'.$name,'Name',$filerealname);
|
||||
$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'),$redis->hget('BookCache_'.$name,'Name'));
|
||||
}else{
|
||||
return json(['code'=>202,'msg'=>'文件仍在下载中']);
|
||||
}
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
99
.history/app/controller/File_20230102183433.php
Normal file
99
.history/app/controller/File_20230102183433.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'),'name'=>$redis->hget('BookCache_'.$name,'Name')]);
|
||||
}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);
|
||||
$filerealname=explode('"',explode(";",$head->header('Content-Disposition'))[1])[1];
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
$redis->hset('BookCache_'.$name,'Size',$size);
|
||||
$redis->hset('BookCache_'.$name,'Name',$filerealname);
|
||||
$redis->hset('BookCache_'.$name,'Status','OK');
|
||||
return json(['code'=>200,'name'=>"$filerealname",'size'=>"$size"]);
|
||||
}
|
||||
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'),$redis->hget('BookCache_'.$name,'Name'));
|
||||
}else{
|
||||
return json(['code'=>202,'msg'=>'文件仍在下载中']);
|
||||
}
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
99
.history/app/controller/File_20230102184127.php
Normal file
99
.history/app/controller/File_20230102184127.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->exists('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>$redis->hget('BookCache_'.$name,'Size'),'name'=>$redis->hget('BookCache_'.$name,'Name')]);
|
||||
}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);
|
||||
$filerealname=explode('"',explode(";",$head->header('Content-Disposition'))[1])[1];
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
$redis->hset('BookCache_'.$name,'Size',$size);
|
||||
$redis->hset('BookCache_'.$name,'Name',$filerealname);
|
||||
$redis->hset('BookCache_'.$name,'Status','OK');
|
||||
return json(['code'=>200,'name'=>"$filerealname",'size'=>"$size"]);
|
||||
}
|
||||
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->exists('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return response()->download($redis->hget('BookCache_'.$name,'Path'),$redis->hget('BookCache_'.$name,'Name'));
|
||||
}else{
|
||||
return json(['code'=>202,'msg'=>'文件仍在下载中']);
|
||||
}
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
100
.history/app/controller/File_20230102184835.php
Normal file
100
.history/app/controller/File_20230102184835.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?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->exists('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>$redis->hget('BookCache_'.$name,'Size'),'name'=>$redis->hget('BookCache_'.$name,'Name')]);
|
||||
}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);
|
||||
echo($size);
|
||||
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);
|
||||
$filerealname=explode('"',explode(";",$head->header('Content-Disposition'))[1])[1];
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
$redis->hset('BookCache_'.$name,'Size',$size);
|
||||
$redis->hset('BookCache_'.$name,'Name',$filerealname);
|
||||
$redis->hset('BookCache_'.$name,'Status','OK');
|
||||
return json(['code'=>200,'name'=>"$filerealname",'size'=>"$size"]);
|
||||
}
|
||||
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->exists('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return response()->download($redis->hget('BookCache_'.$name,'Path'),$redis->hget('BookCache_'.$name,'Name'));
|
||||
}else{
|
||||
return json(['code'=>202,'msg'=>'文件仍在下载中']);
|
||||
}
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
100
.history/app/controller/File_20230102185014.php
Normal file
100
.history/app/controller/File_20230102185014.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?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->exists('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>$redis->hget('BookCache_'.$name,'Size'),'name'=>$redis->hget('BookCache_'.$name,'Name')]);
|
||||
}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((number_format($head->header('Content-Length'))/1048576),2);
|
||||
echo($size);
|
||||
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);
|
||||
$filerealname=explode('"',explode(";",$head->header('Content-Disposition'))[1])[1];
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
$redis->hset('BookCache_'.$name,'Size',$size);
|
||||
$redis->hset('BookCache_'.$name,'Name',$filerealname);
|
||||
$redis->hset('BookCache_'.$name,'Status','OK');
|
||||
return json(['code'=>200,'name'=>"$filerealname",'size'=>"$size"]);
|
||||
}
|
||||
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->exists('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return response()->download($redis->hget('BookCache_'.$name,'Path'),$redis->hget('BookCache_'.$name,'Name'));
|
||||
}else{
|
||||
return json(['code'=>202,'msg'=>'文件仍在下载中']);
|
||||
}
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
101
.history/app/controller/File_20230102185148.php
Normal file
101
.history/app/controller/File_20230102185148.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?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->exists('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>$redis->hget('BookCache_'.$name,'Size'),'name'=>$redis->hget('BookCache_'.$name,'Name')]);
|
||||
}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);
|
||||
$ContentLength=(int)$head->header('Content-Length');
|
||||
$size=round(($ContentLength/1048576),2);
|
||||
echo($size);
|
||||
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);
|
||||
$filerealname=explode('"',explode(";",$head->header('Content-Disposition'))[1])[1];
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
$redis->hset('BookCache_'.$name,'Size',$size);
|
||||
$redis->hset('BookCache_'.$name,'Name',$filerealname);
|
||||
$redis->hset('BookCache_'.$name,'Status','OK');
|
||||
return json(['code'=>200,'name'=>"$filerealname",'size'=>"$size"]);
|
||||
}
|
||||
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->exists('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return response()->download($redis->hget('BookCache_'.$name,'Path'),$redis->hget('BookCache_'.$name,'Name'));
|
||||
}else{
|
||||
return json(['code'=>202,'msg'=>'文件仍在下载中']);
|
||||
}
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
101
.history/app/controller/File_20230102185322.php
Normal file
101
.history/app/controller/File_20230102185322.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?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->exists('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>$redis->hget('BookCache_'.$name,'Size'),'name'=>$redis->hget('BookCache_'.$name,'Name')]);
|
||||
}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";
|
||||
echo($url);
|
||||
$get=Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,getenv('Zlibrary'));
|
||||
$head=$get->head($url);
|
||||
$ContentLength=(int)$head->header('Content-Length');
|
||||
$size=round(($ContentLength/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);
|
||||
$filerealname=explode('"',explode(";",$head->header('Content-Disposition'))[1])[1];
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
$redis->hset('BookCache_'.$name,'Size',$size);
|
||||
$redis->hset('BookCache_'.$name,'Name',$filerealname);
|
||||
$redis->hset('BookCache_'.$name,'Status','OK');
|
||||
return json(['code'=>200,'name'=>"$filerealname",'size'=>"$size"]);
|
||||
}
|
||||
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->exists('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return response()->download($redis->hget('BookCache_'.$name,'Path'),$redis->hget('BookCache_'.$name,'Name'));
|
||||
}else{
|
||||
return json(['code'=>202,'msg'=>'文件仍在下载中']);
|
||||
}
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
101
.history/app/controller/File_20230102185353.php
Normal file
101
.history/app/controller/File_20230102185353.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?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->exists('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>$redis->hget('BookCache_'.$name,'Size'),'name'=>$redis->hget('BookCache_'.$name,'Name')]);
|
||||
}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='http://'.getenv('Zlibrary')."$path";
|
||||
echo($url);
|
||||
$get=Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,getenv('Zlibrary'));
|
||||
$head=$get->head($url);
|
||||
$ContentLength=(int)$head->header('Content-Length');
|
||||
$size=round(($ContentLength/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);
|
||||
$filerealname=explode('"',explode(";",$head->header('Content-Disposition'))[1])[1];
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
$redis->hset('BookCache_'.$name,'Size',$size);
|
||||
$redis->hset('BookCache_'.$name,'Name',$filerealname);
|
||||
$redis->hset('BookCache_'.$name,'Status','OK');
|
||||
return json(['code'=>200,'name'=>"$filerealname",'size'=>"$size"]);
|
||||
}
|
||||
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->exists('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return response()->download($redis->hget('BookCache_'.$name,'Path'),$redis->hget('BookCache_'.$name,'Name'));
|
||||
}else{
|
||||
return json(['code'=>202,'msg'=>'文件仍在下载中']);
|
||||
}
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
100
.history/app/controller/File_20230102185511.php
Normal file
100
.history/app/controller/File_20230102185511.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?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->exists('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>$redis->hget('BookCache_'.$name,'Size'),'name'=>$redis->hget('BookCache_'.$name,'Name')]);
|
||||
}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='http://'.getenv('Zlibrary')."$path";
|
||||
$get=Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,getenv('Zlibrary'));
|
||||
$head=$get->head($url);
|
||||
$ContentLength=(int)$head->header('Content-Length');
|
||||
$size=round(($ContentLength/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);
|
||||
$filerealname=explode('"',explode(";",$head->header('Content-Disposition'))[1])[1];
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
$redis->hset('BookCache_'.$name,'Size',$size);
|
||||
$redis->hset('BookCache_'.$name,'Name',$filerealname);
|
||||
$redis->hset('BookCache_'.$name,'Status','OK');
|
||||
return json(['code'=>200,'name'=>"$filerealname",'size'=>"$size"]);
|
||||
}
|
||||
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->exists('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return response()->download($redis->hget('BookCache_'.$name,'Path'),$redis->hget('BookCache_'.$name,'Name'));
|
||||
}else{
|
||||
return json(['code'=>202,'msg'=>'文件仍在下载中']);
|
||||
}
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
100
.history/app/controller/File_20230102185714.php
Normal file
100
.history/app/controller/File_20230102185714.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?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->exists('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>$redis->hget('BookCache_'.$name,'Size'),'name'=>$redis->hget('BookCache_'.$name,'Name')]);
|
||||
}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='http://'.getenv('Zlibrary')."$path";
|
||||
$get=Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,getenv('Zlibrary'));
|
||||
$head=$get->head($url);
|
||||
$ContentLength=(int)$head->header('Content-Length');
|
||||
$size=round(($ContentLength/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)->body();
|
||||
$file = fopen("$filepath","w");
|
||||
fwrite($file,$return);
|
||||
fclose($file);
|
||||
$filerealname=explode('"',explode(";",$head->header('Content-Disposition'))[1])[1];
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
$redis->hset('BookCache_'.$name,'Size',$size);
|
||||
$redis->hset('BookCache_'.$name,'Name',$filerealname);
|
||||
$redis->hset('BookCache_'.$name,'Status','OK');
|
||||
return json(['code'=>200,'name'=>"$filerealname",'size'=>"$size"]);
|
||||
}
|
||||
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->exists('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return response()->download($redis->hget('BookCache_'.$name,'Path'),$redis->hget('BookCache_'.$name,'Name'));
|
||||
}else{
|
||||
return json(['code'=>202,'msg'=>'文件仍在下载中']);
|
||||
}
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
101
.history/app/controller/File_20230102190051.php
Normal file
101
.history/app/controller/File_20230102190051.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?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->exists('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
return json(['code'=>200, 'msg'=>'找到文件', 'size'=>$redis->hget('BookCache_'.$name,'Size'),'name'=>$redis->hget('BookCache_'.$name,'Name')]);
|
||||
}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='http://'.getenv('Zlibrary')."$path";
|
||||
$get=Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,getenv('Zlibrary'));
|
||||
$head=$get->head($url);
|
||||
$ContentLength=(int)$head->header('Content-Length');
|
||||
$size=round(($ContentLength/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)->body();
|
||||
$file = fopen("$filepath","w");
|
||||
fwrite($file,$return);
|
||||
fclose($file);
|
||||
$filerealname=explode('"',explode(";",$head->header('Content-Disposition'))[1])[1];
|
||||
$redis->hset('BookCache_'.$name,'Path',$filepath);
|
||||
$redis->hset('BookCache_'.$name,'Size',$size);
|
||||
$redis->hset('BookCache_'.$name,'Name',$filerealname);
|
||||
$redis->hset('BookCache_'.$name,'Status','OK');
|
||||
return json(['code'=>200,'name'=>"$filerealname",'size'=>"$size"]);
|
||||
}
|
||||
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->exists('BookCache_'.$name)){
|
||||
if($redis->hget('BookCache_'.$name,'Status')=='OK'){
|
||||
$redis->hset('BookCache_'.$name,'LastDown',time());
|
||||
return response()->download($redis->hget('BookCache_'.$name,'Path'),$redis->hget('BookCache_'.$name,'Name'));
|
||||
}else{
|
||||
return json(['code'=>202,'msg'=>'文件仍在下载中']);
|
||||
}
|
||||
}else {
|
||||
return json(['code'=>201, 'msg'=>'未找到文件']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
24
.history/app/controller/IndexController_20221212162407.php
Normal file
24
.history/app/controller/IndexController_20221212162407.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use support\Request;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return response('hello webman');
|
||||
}
|
||||
|
||||
public function view(Request $request)
|
||||
{
|
||||
return view('index/view', ['name' => 'webman']);
|
||||
}
|
||||
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
24
.history/app/controller/IndexController_20230101173342.php
Normal file
24
.history/app/controller/IndexController_20230101173342.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use support\Request;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return response('hello webman');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
28
.history/app/controller/IndexController_20230101182420.php
Normal file
28
.history/app/controller/IndexController_20230101182420.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use support\Request;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return response('hello webman');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
40
.history/app/controller/IndexController_20230101183521.php
Normal file
40
.history/app/controller/IndexController_20230101183521.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use support\Request;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return response('hello webman');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
41
.history/app/controller/IndexController_20230101183610.php
Normal file
41
.history/app/controller/IndexController_20230101183610.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
|
||||
use support\Request;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return response('hello webman');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
42
.history/app/controller/IndexController_20230101184256.php
Normal file
42
.history/app/controller/IndexController_20230101184256.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
use Webman\Captcha\CaptchaBuilder;
|
||||
use Respect\Validation\Validator as v;
|
||||
use support\Request;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return response('hello webman');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
|
||||
return view('login');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
73
.history/app/controller/IndexController_20230101190155.php
Normal file
73
.history/app/controller/IndexController_20230101190155.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return response('hello webman');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('username','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
return json(['code' => 400, 'msg' => '输入的验证码不正确']);
|
||||
}
|
||||
|
||||
return view('login');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
82
.history/app/controller/IndexController_20230101192447.php
Normal file
82
.history/app/controller/IndexController_20230101192447.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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return response('hello webman');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('username','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
return json(['code' => 400, 'msg' => '输入的验证码不正确']);
|
||||
}
|
||||
|
||||
$url=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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
print_r($return);
|
||||
|
||||
return view('login');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
82
.history/app/controller/IndexController_20230101192731.php
Normal file
82
.history/app/controller/IndexController_20230101192731.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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return response('hello webman');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
return json(['code' => 400, 'msg' => '输入的验证码不正确']);
|
||||
}
|
||||
|
||||
$url=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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
print_r($return);
|
||||
|
||||
return view('login');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
85
.history/app/controller/IndexController_20230101192934.php
Normal file
85
.history/app/controller/IndexController_20230101192934.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return response('hello webman');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
return json(['code' => 400, 'msg' => '输入的验证码不正确']);
|
||||
}
|
||||
|
||||
$url=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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
print_r($return);
|
||||
if(!empty($return->errors)){
|
||||
return json(['code' => 502, 'msg' => '登陆失败:']);
|
||||
}
|
||||
|
||||
return view('login');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
85
.history/app/controller/IndexController_20230101193243.php
Normal file
85
.history/app/controller/IndexController_20230101193243.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return response('hello webman');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
return json(['code' => 400, 'msg' => '输入的验证码不正确']);
|
||||
}
|
||||
|
||||
$url=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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
print_r($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
|
||||
return view('login');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
94
.history/app/controller/IndexController_20230101194651.php
Normal file
94
.history/app/controller/IndexController_20230101194651.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return response('hello webman');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
return json(['code' => 400, 'msg' => '输入的验证码不正确']);
|
||||
}
|
||||
|
||||
$url=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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
print_r($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$params[$item[0]] = $item[1];
|
||||
}
|
||||
|
||||
return json(['code'=>200,'msg'=>'登陆成功','userid'=>$params['remix_userid']])->cookie('id', $params['remix_userid'],7200,'/')->cookie('key', $params['remix_userkey'],7200,'/');
|
||||
|
||||
return view('login');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
92
.history/app/controller/IndexController_20230101194656.php
Normal file
92
.history/app/controller/IndexController_20230101194656.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return response('hello webman');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
return json(['code' => 400, 'msg' => '输入的验证码不正确']);
|
||||
}
|
||||
|
||||
$url=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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
print_r($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$params[$item[0]] = $item[1];
|
||||
}
|
||||
|
||||
return json(['code'=>200,'msg'=>'登陆成功','userid'=>$params['remix_userid']])->cookie('id', $params['remix_userid'],7200,'/')->cookie('key', $params['remix_userkey'],7200,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
92
.history/app/controller/IndexController_20230101194904.php
Normal file
92
.history/app/controller/IndexController_20230101194904.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return response('hello webman');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
return json(['code' => 400, 'msg' => '输入的验证码不正确']);
|
||||
}
|
||||
|
||||
$url=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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
print_r($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
96
.history/app/controller/IndexController_20230101202315.php
Normal file
96
.history/app/controller/IndexController_20230101202315.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($id=='blank' || $key='blank'){
|
||||
return redirect('/login');
|
||||
}
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
return json(['code' => 400, 'msg' => '输入的验证码不正确']);
|
||||
}
|
||||
|
||||
$url=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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
print_r($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
95
.history/app/controller/IndexController_20230101203357.php
Normal file
95
.history/app/controller/IndexController_20230101203357.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
if($id=='blank' || $key='blank'){
|
||||
return redirect('/login');
|
||||
}
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
return json(['code' => 400, 'msg' => '输入的验证码不正确']);
|
||||
}
|
||||
|
||||
$url=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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
96
.history/app/controller/IndexController_20230101205503.php
Normal file
96
.history/app/controller/IndexController_20230101205503.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$route=$request->get('route','/')
|
||||
if($id=='blank' || $key='blank'){
|
||||
return redirect('/login');
|
||||
}
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
return json(['code' => 400, 'msg' => '输入的验证码不正确']);
|
||||
}
|
||||
|
||||
$url=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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
96
.history/app/controller/IndexController_20230101205507.php
Normal file
96
.history/app/controller/IndexController_20230101205507.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$route=$request->get('route','')
|
||||
if($id=='blank' || $key='blank'){
|
||||
return redirect('/login');
|
||||
}
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
return json(['code' => 400, 'msg' => '输入的验证码不正确']);
|
||||
}
|
||||
|
||||
$url=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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
93
.history/app/controller/IndexController_20230101205513.php
Normal file
93
.history/app/controller/IndexController_20230101205513.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$route=$request->get('route','');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
return json(['code' => 400, 'msg' => '输入的验证码不正确']);
|
||||
}
|
||||
|
||||
$url=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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
93
.history/app/controller/IndexController_20230101205522.php
Normal file
93
.history/app/controller/IndexController_20230101205522.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$route=$request->get('route','/');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
return json(['code' => 400, 'msg' => '输入的验证码不正确']);
|
||||
}
|
||||
|
||||
$url=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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
93
.history/app/controller/IndexController_20230101205548.php
Normal file
93
.history/app/controller/IndexController_20230101205548.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$route=$request->get('route','/');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
return json(['code' => 400, 'msg' => '输入的验证码不正确']);
|
||||
}
|
||||
|
||||
$url=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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
97
.history/app/controller/IndexController_20230101210439.php
Normal file
97
.history/app/controller/IndexController_20230101210439.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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$route=$request->route;
|
||||
$path=$route->getPath();
|
||||
$url='http://'.getenv('ZlibraryLogin').$path;
|
||||
$response = Http::withProxy('socks5h://'.getenv('proxy'))->get($url)
|
||||
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
return json(['code' => 400, 'msg' => '输入的验证码不正确']);
|
||||
}
|
||||
|
||||
$url=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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
97
.history/app/controller/IndexController_20230101210449.php
Normal file
97
.history/app/controller/IndexController_20230101210449.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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$route=$request->route;
|
||||
$path=$route->getPath();
|
||||
$url='http://'.getenv('ZlibraryLogin').$path;
|
||||
$response = Http::withProxy('socks5h://'.getenv('proxy'))->get($url)
|
||||
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
98
.history/app/controller/IndexController_20230101210659.php
Normal file
98
.history/app/controller/IndexController_20230101210659.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$route=$request->route;
|
||||
$path=$route->getPath();
|
||||
$url='http://'.getenv('ZlibraryLogin').$path;
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh');
|
||||
$response = Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,'.'.getenv('ZlibraryLogin'))->get($url);
|
||||
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
107
.history/app/controller/IndexController_20230101215122.php
Normal file
107
.history/app/controller/IndexController_20230101215122.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$route=$request->route;
|
||||
$path=$route->getPath();
|
||||
$url='http://'.getenv('ZlibraryLogin').$path;
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh');
|
||||
$return = Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,'.'.getenv('ZlibraryLogin'))->get($url);
|
||||
$response->withHeaders($return->headers());
|
||||
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($return->body());
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
110
.history/app/controller/IndexController_20230101215326.php
Normal file
110
.history/app/controller/IndexController_20230101215326.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
#$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$route=$request->route;
|
||||
print_r($route);
|
||||
return response('123');
|
||||
|
||||
$path=$route->getPath();
|
||||
$url='http://'.getenv('ZlibraryLogin').$path;
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh');
|
||||
$return = Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,'.'.getenv('ZlibraryLogin'))->get($url);
|
||||
$response->withHeaders($return->headers());
|
||||
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($return->body());
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
110
.history/app/controller/IndexController_20230101215401.php
Normal file
110
.history/app/controller/IndexController_20230101215401.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
#$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$route=$request->path();
|
||||
print_r($route);
|
||||
return response('123');
|
||||
|
||||
$path=$route->getPath();
|
||||
$url='http://'.getenv('ZlibraryLogin').$path;
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh');
|
||||
$return = Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,'.'.getenv('ZlibraryLogin'))->get($url);
|
||||
$response->withHeaders($return->headers());
|
||||
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($return->body());
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
110
.history/app/controller/IndexController_20230101215431.php
Normal file
110
.history/app/controller/IndexController_20230101215431.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
#$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$route=$request->uri();
|
||||
print_r($route);
|
||||
return response('123');
|
||||
|
||||
$path=$route->getPath();
|
||||
$url='http://'.getenv('ZlibraryLogin').$path;
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh');
|
||||
$return = Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,'.'.getenv('ZlibraryLogin'))->get($url);
|
||||
$response->withHeaders($return->headers());
|
||||
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($return->body());
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
106
.history/app/controller/IndexController_20230101215457.php
Normal file
106
.history/app/controller/IndexController_20230101215457.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->uri();
|
||||
$url='http://'.getenv('ZlibraryLogin').$path;
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh');
|
||||
$return = Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,'.'.getenv('ZlibraryLogin'))->get($url);
|
||||
$response->withHeaders($return->headers());
|
||||
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($return->body());
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
106
.history/app/controller/IndexController_20230101215743.php
Normal file
106
.history/app/controller/IndexController_20230101215743.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->uri();
|
||||
$url='http://'.getenv('Zlibrary').$path;
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh');
|
||||
$return = Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,'.'.getenv('ZlibraryLogin'))->get($url);
|
||||
$response->withHeaders($return->headers());
|
||||
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($return->body());
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
109
.history/app/controller/IndexController_20230101220103.php
Normal file
109
.history/app/controller/IndexController_20230101220103.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->uri();
|
||||
if($path==''||$path=='/'){
|
||||
$path='/?signAll=1&ts=1657';
|
||||
}
|
||||
$url='http://'.getenv('Zlibrary').$path;
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh');
|
||||
$return = Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,'.'.getenv('ZlibraryLogin'))->get($url);
|
||||
$response->withHeaders($return->headers());
|
||||
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($return->body());
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
109
.history/app/controller/IndexController_20230101220342.php
Normal file
109
.history/app/controller/IndexController_20230101220342.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->uri();
|
||||
if($path==''||$path=='/'){
|
||||
$path='/?signAll=1&ts=1657';
|
||||
}
|
||||
$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('ZlibraryLogin'))->get($url);
|
||||
$response->withHeaders($return->headers());
|
||||
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($return->body());
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
109
.history/app/controller/IndexController_20230101220540.php
Normal file
109
.history/app/controller/IndexController_20230101220540.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->uri();
|
||||
if($path==''||$path=='/'){
|
||||
$path='/?signAll=1&ts=1657';
|
||||
}
|
||||
$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,'.'.$request->host();)->get($url);
|
||||
$response->withHeaders($return->headers());
|
||||
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($return->body());
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
109
.history/app/controller/IndexController_20230101220542.php
Normal file
109
.history/app/controller/IndexController_20230101220542.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->uri();
|
||||
if($path==''||$path=='/'){
|
||||
$path='/?signAll=1&ts=1657';
|
||||
}
|
||||
$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,'.'.$request->host())->get($url);
|
||||
$response->withHeaders($return->headers());
|
||||
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($return->body());
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
110
.history/app/controller/IndexController_20230101221211.php
Normal file
110
.history/app/controller/IndexController_20230101221211.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->uri();
|
||||
if($path==''||$path=='/'){
|
||||
$path='/?signAll=1&ts=1657';
|
||||
}
|
||||
$url='http://'.getenv('Zlibrary').$path;
|
||||
echo($url);
|
||||
$auth=array('remix_userid'=>"$id",'remix_userkey'=>"$key",'siteLanguageV2'=>'zh','selectedSiteMode'=>'books');
|
||||
$return = Http::withProxy('socks5h://'.getenv('proxy'))->withCookies($auth,'.'.$request->host())->get($url);
|
||||
$response->withHeaders($return->headers());
|
||||
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($return->body());
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
110
.history/app/controller/IndexController_20230101221246.php
Normal file
110
.history/app/controller/IndexController_20230101221246.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->uri();
|
||||
if($path==''||$path=='/'){
|
||||
$path='/?signAll=1&ts=1657';
|
||||
}
|
||||
$url='http://'.getenv('Zlibrary').$path;
|
||||
echo($url);
|
||||
$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());
|
||||
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($return->body());
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
109
.history/app/controller/IndexController_20230101221441.php
Normal file
109
.history/app/controller/IndexController_20230101221441.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->uri();
|
||||
if($path==''||$path=='/'){
|
||||
$path='/?signAll=1&ts=1657';
|
||||
}
|
||||
$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'))->withCookies($auth,getenv('ZlibraryLogin'))->get($url);
|
||||
$response->withHeaders($return->headers());
|
||||
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($return->body());
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
109
.history/app/controller/IndexController_20230101221736.php
Normal file
109
.history/app/controller/IndexController_20230101221736.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->uri();
|
||||
if($path==''||$path=='/'){
|
||||
$path='/?signAll=1&ts=1657';
|
||||
}
|
||||
$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());
|
||||
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($return->body());
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
112
.history/app/controller/IndexController_20230101222759.php
Normal file
112
.history/app/controller/IndexController_20230101222759.php
Normal file
@ -0,0 +1,112 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->uri();
|
||||
if($path==''||$path=='/'){
|
||||
$path='/?signAll=1&ts=1657';
|
||||
}
|
||||
$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());
|
||||
$back=$return->body();
|
||||
if($return->header('Content-Type')=='text/html; charset=utf-8'){
|
||||
$back='<div><a href="/logout">退出</a></div>'.$back;
|
||||
}
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($back);
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
112
.history/app/controller/IndexController_20230101222959.php
Normal file
112
.history/app/controller/IndexController_20230101222959.php
Normal file
@ -0,0 +1,112 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->uri();
|
||||
if($path==''||$path=='/'){
|
||||
$path='/?signAll=1&ts=1657';
|
||||
}
|
||||
$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());
|
||||
$back=$return->body();
|
||||
if($return->header('Content-Type')=='text/html; charset=utf-8'){
|
||||
$back='<html><body><div><a href="/logout">退出</a></div></body></html>'.$back;
|
||||
}
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($back);
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
113
.history/app/controller/IndexController_20230101223138.php
Normal file
113
.history/app/controller/IndexController_20230101223138.php
Normal file
@ -0,0 +1,113 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->uri();
|
||||
if($path==''||$path=='/'){
|
||||
$path='/?signAll=1&ts=1657';
|
||||
}
|
||||
$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());
|
||||
$back=$return->body();
|
||||
if($return->header('Content-Type')=='text/html; charset=utf-8'){
|
||||
$back='<html><body><div><a href="/logout">退出</a></div></body></html>'.$back;
|
||||
echo($back);
|
||||
}
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($back);
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
114
.history/app/controller/IndexController_20230101223213.php
Normal file
114
.history/app/controller/IndexController_20230101223213.php
Normal file
@ -0,0 +1,114 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->uri();
|
||||
if($path==''||$path=='/'){
|
||||
$path='/?signAll=1&ts=1657';
|
||||
}
|
||||
$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());
|
||||
$back=$return->body();
|
||||
echo($return->header('Content-Type'));
|
||||
if($return->header('Content-Type')=='text/html; charset=utf-8'){
|
||||
$back='<html><body><div><a href="/logout">退出</a></div></body></html>'.$back;
|
||||
echo($back);
|
||||
}
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($back);
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
114
.history/app/controller/IndexController_20230101223238.php
Normal file
114
.history/app/controller/IndexController_20230101223238.php
Normal file
@ -0,0 +1,114 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->uri();
|
||||
if($path==''||$path=='/'){
|
||||
$path='/?signAll=1&ts=1657';
|
||||
}
|
||||
$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());
|
||||
$back=$return->body();
|
||||
echo($return->header('Content-Type'));
|
||||
if($return->header('Content-Type')=='text/html; charset=UTF-8'){
|
||||
$back='<html><body><div><a href="/logout">退出</a></div></body></html>'.$back;
|
||||
echo($back);
|
||||
}
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($back);
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
123
.history/app/controller/IndexController_20230101224226.php
Normal file
123
.history/app/controller/IndexController_20230101224226.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->uri();
|
||||
if($path==''||$path=='/'){
|
||||
$path='/?signAll=1&ts=1657';
|
||||
}
|
||||
$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());
|
||||
$back=$return->body();
|
||||
echo($return->header('Content-Type'));
|
||||
if($return->header('Content-Type')=='text/html; charset=UTF-8'){
|
||||
$ver=getenv('version');
|
||||
$front= <<<EOF
|
||||
<html><body>
|
||||
<center>
|
||||
<div style="background-color: bisque;color: black;position:fixed!important;font-size:1.8rem;line-height:1.618;">
|
||||
Zlibrary Proxy(v$ver) UserID:$id <a style="color: coral;" href="/login/logout">[退出账号]</a>
|
||||
</div>
|
||||
</center></body></html>
|
||||
EOF;
|
||||
$back=$front.$back;
|
||||
echo($back);
|
||||
}
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($back);
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
123
.history/app/controller/IndexController_20230101224323.php
Normal file
123
.history/app/controller/IndexController_20230101224323.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->uri();
|
||||
if($path==''||$path=='/'){
|
||||
$path='/?signAll=1&ts=1657';
|
||||
}
|
||||
$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());
|
||||
$back=$return->body();
|
||||
echo($return->header('Content-Type'));
|
||||
if($return->header('Content-Type')=='text/html; charset=UTF-8'){
|
||||
$ver=getenv('version');
|
||||
$front= <<<EOF
|
||||
<html><body>
|
||||
<center>
|
||||
<div style="background-color: bisque;color: black;position:fixed!important;font-size:1.8rem;line-height:1.618;z-index:9999!important">
|
||||
Zlibrary Proxy(v$ver) UserID:$id <a style="color: coral;" href="/login/logout">[退出账号]</a>
|
||||
</div>
|
||||
</center></body></html>
|
||||
EOF;
|
||||
$back=$front.$back;
|
||||
echo($back);
|
||||
}
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($back);
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
123
.history/app/controller/IndexController_20230101224742.php
Normal file
123
.history/app/controller/IndexController_20230101224742.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->uri();
|
||||
if($path==''||$path=='/'){
|
||||
$path='/?signAll=1&ts=1657';
|
||||
}
|
||||
$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());
|
||||
$back=$return->body();
|
||||
echo($return->header('Content-Type'));
|
||||
if($return->header('Content-Type')=='text/html; charset=UTF-8'){
|
||||
$ver=getenv('version');
|
||||
$front= <<<EOF
|
||||
<html><body>
|
||||
<center style="max-width:38em;padding:13px;">
|
||||
<div style="background-color: bisque;color: black;position:fixed!important;font-size:1.8rem;line-height:1.618;z-index:9999!important;text-align:-webkit-center;">
|
||||
Zlibrary Proxy(v$ver) UserID:$id <a style="color: coral;" href="/login/logout">[退出账号]</a>
|
||||
</div>
|
||||
</center></body></html>
|
||||
EOF;
|
||||
$back=$front.$back;
|
||||
echo($back);
|
||||
}
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($back);
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
123
.history/app/controller/IndexController_20230101224840.php
Normal file
123
.history/app/controller/IndexController_20230101224840.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->uri();
|
||||
if($path==''||$path=='/'){
|
||||
$path='/?signAll=1&ts=1657';
|
||||
}
|
||||
$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());
|
||||
$back=$return->body();
|
||||
echo($return->header('Content-Type'));
|
||||
if($return->header('Content-Type')=='text/html; charset=UTF-8'){
|
||||
$ver=getenv('version');
|
||||
$front= <<<EOF
|
||||
<html><body>
|
||||
<center>
|
||||
<div style="background-color: bisque;color: black;position:fixed!important;font-size:1.8rem;line-height:1.618;z-index:9999!important;text-align:-webkit-center;">
|
||||
Zlibrary Proxy(v$ver) UserID:$id <a style="color: coral;" href="/login/logout">[退出账号]</a>
|
||||
</div>
|
||||
</center></body></html>
|
||||
EOF;
|
||||
$back=$front.$back;
|
||||
echo($back);
|
||||
}
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($back);
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
123
.history/app/controller/IndexController_20230101225029.php
Normal file
123
.history/app/controller/IndexController_20230101225029.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?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;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$response = response();
|
||||
$id=$request->cookie('id', 'blank');
|
||||
$key=$request->cookie('key', 'blank');
|
||||
$path=$request->uri();
|
||||
if($path==''||$path=='/'){
|
||||
$path='/?signAll=1&ts=1657';
|
||||
}
|
||||
$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());
|
||||
$back=$return->body();
|
||||
echo($return->header('Content-Type'));
|
||||
if($return->header('Content-Type')=='text/html; charset=UTF-8'){
|
||||
$ver=getenv('version');
|
||||
$front= <<<EOF
|
||||
<html><body>
|
||||
<center>
|
||||
<div style="background-color: bisque;color: black;position:fixed!important;font-size:1.8rem;line-height:1.618;z-index:9999!important;text-align:-webkit-center;">
|
||||
Zlibrary Proxy(v$ver) UserID:$id <a style="color: coral;" href="/login/logout">[退出账号]</a><a style="color: black;" href="//www.pmnet.gq" target="_blank_pmnet"> [PublicMirrorsNetwork]</a>
|
||||
</div>
|
||||
</center></body></html>
|
||||
EOF;
|
||||
$back=$front.$back;
|
||||
echo($back);
|
||||
}
|
||||
/**
|
||||
* if($return->header('Content-Type')[0]=='image/svg+xml'){
|
||||
|
||||
*}
|
||||
*/
|
||||
$response->withBody($back);
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
return view('login');
|
||||
}
|
||||
public function check(Request $request)
|
||||
{
|
||||
$username=$request->post('name','blank');
|
||||
$password=$request->post('password','blank');
|
||||
$code=$request->post('code','blank');
|
||||
if($username=='blank' || $password=='blank' || $code=='blank'){
|
||||
return json(['code'=>500, 'msg'=>'缺少参数']);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::Email()->setName('用户名')->check($username);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->setName('密码')->noWhitespace()->check($password);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
try {
|
||||
$V=v::stringType()->length(5, 5)->setName('验证码')->noWhitespace()->check($code);
|
||||
} catch (ValidationException $exception) {
|
||||
return json(['code'=>500, 'msg'=>$exception->getMessage()]);
|
||||
}
|
||||
|
||||
if (strtolower($code) !== $request->session()->get('captcha')) {
|
||||
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']);
|
||||
if(!$response->successful()){
|
||||
return json(['code' => 501, 'msg' => '登陆失败,服务端错误']);
|
||||
}
|
||||
$return=$response->body();
|
||||
$return=json_decode($return);
|
||||
if(isset($return->response->validationError)){
|
||||
return json(['code' => 502, 'msg' => 'Zlib登陆失败:'.$return->response->message]);
|
||||
}
|
||||
$url=parse_url($return->response->params)['query'];
|
||||
$queryParts = explode('&', $url);
|
||||
$params = array();
|
||||
foreach ($queryParts as $param) {
|
||||
$item = explode('=', $param);
|
||||
$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,'/');
|
||||
}
|
||||
public function code(Request $request)
|
||||
{
|
||||
// 初始化验证码类
|
||||
$builder = new CaptchaBuilder;
|
||||
// 生成验证码
|
||||
$builder->build();
|
||||
// 将验证码的值存储到session中
|
||||
$request->session()->set('captcha', strtolower($builder->getPhrase()));
|
||||
// 获得验证码图片二进制数据
|
||||
$img_content = $builder->get();
|
||||
// 输出验证码二进制数据
|
||||
return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
|
||||
}
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user