中秋节快乐
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\api;
|
||||
|
||||
use think\App;
|
||||
use think\facade\View;
|
||||
|
||||
use app\model\Conf as ConfModel;
|
||||
use app\model\Token as TokenModel;
|
||||
|
||||
/**
|
||||
* 控制器基础类
|
||||
*/
|
||||
abstract class QfShop
|
||||
{
|
||||
/**
|
||||
* 构造方法
|
||||
* @access public
|
||||
* @param App $app 应用对象
|
||||
*/
|
||||
public function __construct(App $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->request = $this->app->request;
|
||||
|
||||
// 控制器初始化
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
// 初始化
|
||||
protected function initialize()
|
||||
{
|
||||
//访问XMLHttpRequest已被CORS政策阻止
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
|
||||
$this->confModel = new ConfModel();
|
||||
$configs = $this->confModel->select()->toArray();
|
||||
$c = [];
|
||||
foreach ($configs as $config) {
|
||||
$c[$config['conf_key']] = $config['conf_value'];
|
||||
}
|
||||
config($c, 'qfshop');
|
||||
}
|
||||
public function __call($method, $args)
|
||||
{
|
||||
return jerr("API接口方法不存在", 404);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检测授权 获取当前用户登录信息
|
||||
* @param $type false不提示登录失败状态
|
||||
* @param user_id 顾客时为用户id
|
||||
* @param action 操作者 顾客端为手机号,管理端为登录账号
|
||||
* @param client_type 0=顾客 1=管理组 -1=游客
|
||||
*/
|
||||
protected function getLoginUser($type = true)
|
||||
{
|
||||
$is_login = true;
|
||||
// 获取请求中的token
|
||||
$access_token = request()->header('X-CSRF-TOKEN');
|
||||
if (!$access_token) {
|
||||
if($type){
|
||||
return jerr("用户未登录", 401);
|
||||
}else{
|
||||
$is_login = false;
|
||||
}
|
||||
}
|
||||
$Token = new TokenModel();
|
||||
$user = $Token->getToken($access_token);
|
||||
if (!$user) {
|
||||
if($type){
|
||||
return jerr("登录过期,请重新登录", 401);
|
||||
}else{
|
||||
$is_login = false;
|
||||
}
|
||||
}
|
||||
if($is_login){
|
||||
$user['action'] = $user['mobile'];
|
||||
$user['client_type'] = 0;
|
||||
unset($user['mobile']);
|
||||
unset($user['status']);
|
||||
return $user;
|
||||
}else{
|
||||
$user['client_type'] = -1;
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\QfShop;
|
||||
|
||||
class Error extends QfShop
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return jerr("Error", 404);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\QfShop;
|
||||
|
||||
use Lizhichao\Word\VicWord;
|
||||
|
||||
|
||||
|
||||
class Index extends QfShop
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return jok("Hello World!");
|
||||
}
|
||||
public function search() {
|
||||
$fc = new VicWord();
|
||||
$keywords = input('keywords');
|
||||
$keywords = $fc->getAutoWord($keywords);
|
||||
|
||||
$keywords = filterAndExtractWords($keywords);
|
||||
|
||||
|
||||
return jok("Hello World!",$keywords);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,710 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\App;
|
||||
use think\facade\Cache;
|
||||
use app\api\QfShop;
|
||||
|
||||
class Open extends QfShop
|
||||
{
|
||||
public function __construct(App $app)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->url = "";
|
||||
$this->is_type = 0;
|
||||
$this->cookie = ""; //夸克登录凭证
|
||||
$this->Authorization = ""; //阿里登录凭证
|
||||
$this->expired_type = 1; //1分享永久 2临时
|
||||
$this->to_pdir_fid = ""; //存入目标文件
|
||||
$this->ad_fid = "";
|
||||
$this->code = ""; //提取码
|
||||
$this->isType = 0; //等于1时仅校验是否有效并提取资源信息
|
||||
$this->urlHeader = array(
|
||||
'Accept: application/json, text/plain, */*',
|
||||
'Accept-Language: zh-CN,zh;q=0.9',
|
||||
'content-type: application/json;charset=UTF-8',
|
||||
'sec-ch-ua: "Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"',
|
||||
'sec-ch-ua-mobile: ?0',
|
||||
'sec-ch-ua-platform: "Windows"',
|
||||
'sec-fetch-dest: empty',
|
||||
'sec-fetch-mode: cors',
|
||||
'sec-fetch-site: same-site',
|
||||
'Referer: https://pan.quark.cn/',
|
||||
'Referrer-Policy: strict-origin-when-cross-origin',
|
||||
'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
||||
);
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return jok('Hello World');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取夸克网盘文件夹
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getFiles()
|
||||
{
|
||||
$this->cookie = input('cookie')??'';
|
||||
$urlData = [];
|
||||
$queryParams = [
|
||||
'pr' => 'ucpro',
|
||||
'fr' => 'pc',
|
||||
'uc_param_str' => '',
|
||||
'pdir_fid' => 0,
|
||||
'_page' => 1,
|
||||
'_size' => 50,
|
||||
'_fetch_total' => 1,
|
||||
'_fetch_sub_dirs' => 0,
|
||||
'_sort' => 'file_type:asc,updated_at:desc',
|
||||
];
|
||||
|
||||
$this->urlHeader[] = 'cookie: ' . $this->cookie;
|
||||
$res = curlHelper("https://drive-pc.quark.cn/1/clouddrive/file/sort", "GET", json_encode($urlData), $this->urlHeader,$queryParams)['body'];
|
||||
$res = json_decode($res, true);
|
||||
if($res['status'] !== 200){
|
||||
return jerr($res['message']=='require login [guest]'?'夸克未登录,请检查cookie':$res['message']);
|
||||
}
|
||||
|
||||
return jok('获取成功',$res['data']['list']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键转存并分享资源
|
||||
*
|
||||
* type 0 夸克 1阿里
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function transfer()
|
||||
{
|
||||
$url = input("url");
|
||||
$this->code = input('code')??'';
|
||||
$this->isType = input('isType')??0;
|
||||
|
||||
if($this->isType != 1){ //直接入口就不用cookie 防止账号异常
|
||||
$this->cookie = input('cookie')??'';
|
||||
$this->Authorization = input('Authorization')??'';
|
||||
}
|
||||
|
||||
$this->expired_type = input('expired_type')??1;
|
||||
$this->to_pdir_fid = input('to_pdir_fid')??"";
|
||||
$this->ad_fid = input('ad_fid')??"";
|
||||
|
||||
if (strpos($url, '?entry=') !== false) {
|
||||
$entry = preg_match('/\?entry=([^&]+)/', $url, $matches) ? $matches[1] : '';
|
||||
$url = preg_match('/.*(?=\?entry=)/', $url, $matches) ? $matches[0] : '';
|
||||
}
|
||||
|
||||
$substring = strstr($url, 's/');
|
||||
if ($substring !== false) {
|
||||
$pwd_id = substr($substring, 2); // 去除 's/' 部分
|
||||
} else {
|
||||
return jerr("资源地址格式有误");
|
||||
}
|
||||
|
||||
$this->urlHeader[] = 'cookie: ' . $this->cookie;
|
||||
|
||||
$patterns = [
|
||||
'pan.quark.cn' => 0,
|
||||
'www.alipan.com' => 1,
|
||||
'www.aliyundrive.com' => 1,
|
||||
// 'pan.baidu.com' => 2,
|
||||
'drive.uc.cn' => 3,
|
||||
// 'pan.xunlei.com' => 4,
|
||||
];
|
||||
|
||||
$url_type = -1; // 默认值为 -1
|
||||
foreach ($patterns as $pattern => $type) {
|
||||
if (strpos($url, $pattern) !== false) {
|
||||
$url_type = $type;
|
||||
break; // 一旦匹配成功,退出循环
|
||||
}
|
||||
}
|
||||
|
||||
$this->url = $url;
|
||||
|
||||
if ($url_type == 0) {
|
||||
//夸克
|
||||
if(empty($this->cookie) && $this->isType==0){
|
||||
jerr("参数有误");
|
||||
}
|
||||
$this->transferQuark(strtok($pwd_id, '#'));
|
||||
} else if($url_type == 1){
|
||||
//阿里
|
||||
if(empty($this->Authorization) && $this->isType==0){
|
||||
jerr("参数有误");
|
||||
}
|
||||
$this->transferAlipan($pwd_id);
|
||||
} else if($url_type == 2){
|
||||
//百度
|
||||
// $this->transferBaidu($pwd_id);
|
||||
} else if($url_type == 3){
|
||||
//UC
|
||||
$this->transferUc($pwd_id);
|
||||
} else {
|
||||
return jerr("资源地址格式有误");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 夸克 - 一键转存并分享资源
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function transferQuark($pwd_id){
|
||||
//获取要转存夸克资源的stoken
|
||||
$infoData = $this->getStoken($pwd_id);
|
||||
|
||||
if($this->isType == 1){
|
||||
$urls['title'] = $infoData['title'];
|
||||
$urls['share_url'] = $this->url;
|
||||
return jok('检验成功', $urls);
|
||||
}
|
||||
|
||||
|
||||
$stoken = $infoData['stoken'];
|
||||
|
||||
|
||||
//获取要转存夸克资源的详细内容
|
||||
$detail = $this->getShare($pwd_id,$stoken);
|
||||
|
||||
$fid_list = [];
|
||||
$fid_token_list = [];
|
||||
$title = $detail['share']['title']; //资源名称
|
||||
foreach ($detail['list'] as $key => $value) {
|
||||
$fid_list[] = $value['fid'];
|
||||
$fid_token_list[] = $value['share_fid_token'];
|
||||
}
|
||||
|
||||
//转存资源到指定文件夹
|
||||
$task_id = $this->getShareSave($pwd_id,$stoken,$fid_list,$fid_token_list);
|
||||
|
||||
//转存后根据task_id获取转存到自己网盘后的信息
|
||||
$retry_index = 0;
|
||||
$myData = '';
|
||||
while ($myData=='' || $myData['status'] != 2) {
|
||||
$myData = $this->getShareTask($task_id, $retry_index);
|
||||
$retry_index++;
|
||||
// 可以添加一个最大重试次数的限制,防止无限循环
|
||||
if ($retry_index > 50) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
//删除转存后可能有的广告
|
||||
$banned = Config('qfshop.quark_banned')??''; //如果出现这些字样就删除
|
||||
if(!empty($banned)){
|
||||
$bannedList = explode(',', $banned);
|
||||
$pdir_fid = $myData['save_as']['save_as_top_fids'][0];
|
||||
$dellist = [];
|
||||
$plist = $this->getPdirFid($pdir_fid);
|
||||
if(!empty($plist)){
|
||||
foreach ($plist as $key => $value) {
|
||||
// 检查$value['file_name']是否包含$bannedList中的任何一项
|
||||
$contains = false;
|
||||
foreach ($bannedList as $item) {
|
||||
if (strpos($value['file_name'], $item) !== false) {
|
||||
$contains = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($contains) {
|
||||
$dellist[] = $value['fid'];
|
||||
}
|
||||
}
|
||||
if(count($plist) === count($dellist)){
|
||||
//要删除的资源数如果和原数据资源数一样 就全部删除并终止下面的分享
|
||||
$this->deletepdirFid([$pdir_fid]);
|
||||
return jerr("资源内容为空");
|
||||
}else{
|
||||
if (!empty($dellist)) {
|
||||
$this->deletepdirFid($dellist);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
|
||||
//分享资源并拿到更新后的task_id
|
||||
$task_id = $this->getShareBtn($myData['save_as']['save_as_top_fids'],$title);
|
||||
|
||||
//根据task_id拿到share_id
|
||||
$retry_index = 0;
|
||||
$myData = '';
|
||||
while ($myData=='' || $myData['status'] != 2) {
|
||||
$myData = $this->getShareTask($task_id, $retry_index);
|
||||
$retry_index++;
|
||||
// 可以添加一个最大重试次数的限制,防止无限循环
|
||||
if ($retry_index > 50) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//根据share_id 获取到分享链接
|
||||
$share = $this->getSharePassword($myData['share_id']);
|
||||
$share['fid'] = $share['first_file']['fid'];
|
||||
|
||||
return jok('转存成功', $share);
|
||||
}
|
||||
|
||||
/**
|
||||
* 阿里 - 一键转存并分享资源
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function transferAlipan($share_id)
|
||||
{
|
||||
$data = [];
|
||||
$infos = $this->getAlipan1($share_id);
|
||||
|
||||
if($this->isType == 1){
|
||||
$urls['title'] = $infos['share_name'];
|
||||
$urls['share_url'] = $this->url;
|
||||
return jok('检验成功', $urls);
|
||||
}
|
||||
|
||||
|
||||
//通过分享id获取file_id
|
||||
$file_infos = $infos['file_infos'];
|
||||
|
||||
//通过分享id获取X-Share-Token
|
||||
$share_token = $this->getAlipan2($share_id);
|
||||
|
||||
$data3['requests'] = [];
|
||||
$data3['resource'] = 'file';
|
||||
|
||||
foreach ($file_infos as $key=>$value) {
|
||||
$data3['requests'][$key]['body']['auto_rename'] = true;
|
||||
$data3['requests'][$key]['body']['file_id'] = $value['file_id'];
|
||||
$data3['requests'][$key]['body']['share_id'] = $share_id;
|
||||
$data3['requests'][$key]['body']['to_drive_id'] = '2008425230';
|
||||
$data3['requests'][$key]['body']['to_parent_file_id'] = '66a20824c3846d890f6542c6aac2c79822d2a64f';
|
||||
$data3['requests'][$key]['headers']['Content-Type'] = 'application/json';
|
||||
$data3['requests'][$key]['id'] = $key.'';
|
||||
$data3['requests'][$key]['method'] = 'POST';
|
||||
$data3['requests'][$key]['url'] = '/file/copy';
|
||||
}
|
||||
|
||||
//保存
|
||||
$responses = $this->getAlipan3($data3,$share_token);
|
||||
$data4['drive_id'] = '2008425230';
|
||||
$data4['expiration'] = '';
|
||||
$data4['share_pwd'] = '';
|
||||
$data4['file_id_list'] = [];
|
||||
|
||||
foreach ($responses as $key=>$value){
|
||||
$data4['file_id_list'][] = $value['body']['file_id'];
|
||||
}
|
||||
|
||||
//分享
|
||||
$share = $this->getAlipan4($data4);
|
||||
|
||||
$data['share_url'] = $share['share_url'];
|
||||
$data['title'] = $share['share_title'];
|
||||
|
||||
return jok('转存成功', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* UC- 一键转存并分享资源
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function transferUc($pwd_id){
|
||||
$infoData = $this->getStokenUc($pwd_id);
|
||||
|
||||
if($this->isType == 1){
|
||||
$urls['title'] = $infoData['title'];
|
||||
$urls['share_url'] = $this->url;
|
||||
return jok('检验成功', $urls);
|
||||
}else{
|
||||
return jerr('暂不支持转存');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取要转存资源的stoken
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getStoken($pwd_id)
|
||||
{
|
||||
$urlData = array(
|
||||
'passcode' => '',
|
||||
'pwd_id' => $pwd_id,
|
||||
);
|
||||
$res = curlHelper("https://drive-pc.quark.cn/1/clouddrive/share/sharepage/token?pr=ucpro&fr=pc&uc_param_str=", "POST",json_encode($urlData), $this->urlHeader)['body'];
|
||||
$res = json_decode($res, true);
|
||||
if($res['status'] !== 200){
|
||||
return jerr($res['message']);
|
||||
}
|
||||
$data = $res['data'];
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取要转存资源的详细内容
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getShare($pwd_id,$stoken)
|
||||
{
|
||||
$urlData = array();
|
||||
$queryParams = [
|
||||
"pr" => "ucpro",
|
||||
"fr" => "pc",
|
||||
"uc_param_str" => "",
|
||||
"pwd_id" => $pwd_id,
|
||||
"stoken" => $stoken,
|
||||
"pdir_fid" => "0",
|
||||
"force" => "0",
|
||||
"_page" => "1",
|
||||
"_size" => "100",
|
||||
"_fetch_banner" => "1",
|
||||
"_fetch_share" => "1",
|
||||
"_fetch_total" => "1",
|
||||
"_sort" => "file_type:asc,updated_at:desc"
|
||||
];
|
||||
$res = curlHelper("https://drive-pc.quark.cn/1/clouddrive/share/sharepage/detail", "GET", json_encode($urlData), $this->urlHeader,$queryParams)['body'];
|
||||
$res = json_decode($res, true);
|
||||
if($res['status'] !== 200){
|
||||
return jerr($res['message']);
|
||||
}
|
||||
return $res['data'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转存资源到指定文件夹
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getShareSave($pwd_id,$stoken,$fid_list,$fid_token_list)
|
||||
{
|
||||
$to_pdir_fid = $this->to_pdir_fid??"";
|
||||
$urlData = array(
|
||||
'fid_list' => $fid_list,
|
||||
'fid_token_list' => $fid_token_list,
|
||||
'to_pdir_fid' => $to_pdir_fid,
|
||||
'pwd_id' => $pwd_id,
|
||||
'stoken' => $stoken,
|
||||
'pdir_fid' => "0",
|
||||
'scene' => "link",
|
||||
);
|
||||
$queryParams = [
|
||||
"entry" => "update_share",
|
||||
"pr" => "ucpro",
|
||||
"fr" => "pc",
|
||||
"uc_param_str" => ""
|
||||
];
|
||||
$res = curlHelper("https://drive-pc.quark.cn/1/clouddrive/share/sharepage/save", "POST", json_encode($urlData), $this->urlHeader,$queryParams)['body'];
|
||||
$res = json_decode($res, true);
|
||||
if($res['status'] !== 200){
|
||||
return jerr($res['message']=='require login [guest]'?'夸克未登录,请检查cookie':$res['message']);
|
||||
}
|
||||
return $res['data']['task_id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 分享资源拿到task_id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getShareBtn($fid_list,$title)
|
||||
{
|
||||
if(!empty($this->ad_fid)){
|
||||
$fid_list[] = $this->ad_fid;
|
||||
}
|
||||
$urlData = array(
|
||||
'fid_list' => $fid_list,
|
||||
'expired_type' => $this->expired_type,
|
||||
'title' => $title,
|
||||
'url_type' => 1,
|
||||
);
|
||||
$queryParams = [
|
||||
"pr" => "ucpro",
|
||||
"fr" => "pc",
|
||||
"uc_param_str" => ""
|
||||
];
|
||||
$res = curlHelper("https://drive-pc.quark.cn/1/clouddrive/share", "POST", json_encode($urlData), $this->urlHeader,$queryParams)['body'];
|
||||
$res = json_decode($res, true);
|
||||
if($res['status'] !== 200){
|
||||
return jerr($res['message']);
|
||||
}
|
||||
return $res['data']['task_id'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据task_id拿到自己的资源信息
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getShareTask($task_id,$retry_index)
|
||||
{
|
||||
$urlData = array();
|
||||
$queryParams = [
|
||||
"pr" => "ucpro",
|
||||
"fr" => "pc",
|
||||
"uc_param_str" => "",
|
||||
"task_id" => $task_id,
|
||||
"retry_index" => $retry_index
|
||||
];
|
||||
$res = curlHelper("https://drive-pc.quark.cn/1/clouddrive/task", "GET", json_encode($urlData), $this->urlHeader, $queryParams)['body'];
|
||||
$res = json_decode($res, true);
|
||||
if($res['status'] !== 200){
|
||||
return jerr($res['message']);
|
||||
}
|
||||
return $res['data'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据share_id 获取到分享链接
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getSharePassword($share_id)
|
||||
{
|
||||
$urlData = array(
|
||||
'share_id' => $share_id,
|
||||
);
|
||||
$queryParams = [
|
||||
"pr" => "ucpro",
|
||||
"fr" => "pc",
|
||||
"uc_param_str" => ""
|
||||
];
|
||||
$res = curlHelper("https://drive-pc.quark.cn/1/clouddrive/share/password", "POST", json_encode($urlData), $this->urlHeader,$queryParams)['body'];
|
||||
$res = json_decode($res, true);
|
||||
if($res['status'] !== 200){
|
||||
return jerr($res['message']);
|
||||
}
|
||||
return $res['data'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deletepdirFid($filelist)
|
||||
{
|
||||
$urlData = array(
|
||||
'action_type' => 2,
|
||||
'exclude_fids' => [],
|
||||
'filelist' => $filelist,
|
||||
);
|
||||
$queryParams = [
|
||||
"pr" => "ucpro",
|
||||
"fr" => "pc",
|
||||
"uc_param_str" => ""
|
||||
];
|
||||
curlHelper("https://drive-pc.quark.cn/1/clouddrive/file/delete", "POST", json_encode($urlData), $this->urlHeader,$queryParams)['body'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取夸克网盘指定文件夹内容
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getPdirFid($pdir_fid)
|
||||
{
|
||||
$urlData = [];
|
||||
$queryParams = [
|
||||
'pr' => 'ucpro',
|
||||
'fr' => 'pc',
|
||||
'uc_param_str' => '',
|
||||
'pdir_fid' => $pdir_fid,
|
||||
'_page' => 1,
|
||||
'_size' => 200,
|
||||
'_fetch_total' => 1,
|
||||
'_fetch_sub_dirs' => 0,
|
||||
'_sort' => 'file_type:asc,updated_at:desc',
|
||||
];
|
||||
$res = curlHelper("https://drive-pc.quark.cn/1/clouddrive/file/sort", "GET", json_encode($urlData), $this->urlHeader,$queryParams)['body'];
|
||||
$res = json_decode($res, true);
|
||||
if($res['status'] !== 200){
|
||||
return [];
|
||||
}
|
||||
return $res['data']['list'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 阿里-0-通过分享id获取file_id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getAlipan1($share_id)
|
||||
{
|
||||
$urlData = [
|
||||
'share_id' => $share_id,
|
||||
];
|
||||
$urlHeader = array(
|
||||
'Content-Type: application/json',
|
||||
);
|
||||
$res = curlHelper("https://api.aliyundrive.com/adrive/v3/share_link/get_share_by_anonymous", "POST", json_encode($urlData),$urlHeader)['body'];
|
||||
$res = json_decode($res, true);
|
||||
if(!isset($res['file_infos'])){
|
||||
return jerr($res['message']??'转存失败1');
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 阿里-0-通过分享id获取X-Share-Token
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getAlipan2($share_id)
|
||||
{
|
||||
$urlData = array(
|
||||
'share_id' => $share_id,
|
||||
);
|
||||
$urlHeader = array(
|
||||
'Accept: application/json, text/plain, */*',
|
||||
'Accept-Encoding: gzip, deflate, br, zstd',
|
||||
'Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
||||
'Authorization: '.$this->Authorization,
|
||||
'Content-Type: application/json',
|
||||
'Origin: https://www.alipan.com',
|
||||
'Priority: u=1, i',
|
||||
'Referer: https://www.alipan.com/',
|
||||
'Sec-Ch-Ua: "Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"',
|
||||
'Sec-Ch-Ua-Mobile: ?0',
|
||||
'Sec-Ch-Ua-Platform: "Windows"',
|
||||
'Sec-Fetch-Dest: empty',
|
||||
'Sec-Fetch-Mode: cors',
|
||||
'Sec-Fetch-Site: same-site',
|
||||
'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0',
|
||||
'X-Canary: client=web,app=share,version=v2.3.1'
|
||||
);
|
||||
$res = curlHelper("https://api.aliyundrive.com/v2/share_link/get_share_token", "POST", json_encode($urlData), $urlHeader)['body'];
|
||||
$res = json_decode($res, true);
|
||||
if(!isset($res['share_token'])){
|
||||
return jerr($res['message']??'转存失败2');
|
||||
}
|
||||
return $res['share_token'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 阿里-1-保存
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getAlipan3($urlData,$share_token)
|
||||
{
|
||||
$urlHeader = array(
|
||||
'Accept: application/json, text/plain, */*',
|
||||
'Accept-Encoding: gzip, deflate, br, zstd',
|
||||
'Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
||||
'Authorization: '.$this->Authorization,
|
||||
'Content-Type: application/json',
|
||||
'Origin: https://www.alipan.com',
|
||||
'Priority: u=1, i',
|
||||
'Referer: https://www.alipan.com/',
|
||||
'Sec-Ch-Ua: "Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"',
|
||||
'Sec-Ch-Ua-Mobile: ?0',
|
||||
'Sec-Ch-Ua-Platform: "Windows"',
|
||||
'Sec-Fetch-Dest: empty',
|
||||
'Sec-Fetch-Mode: cors',
|
||||
'Sec-Fetch-Site: same-site',
|
||||
'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0',
|
||||
'X-Canary: client=web,app=share,version=v2.3.1',
|
||||
'X-Share-Token: '.$share_token
|
||||
);
|
||||
$res = curlHelper("https://api.aliyundrive.com/adrive/v4/batch", "POST", json_encode($urlData), $urlHeader)['body'];
|
||||
$res = json_decode($res, true);
|
||||
if(!isset($res['responses'])){
|
||||
return jerr($res['message']??'转存失败3');
|
||||
}
|
||||
return $res['responses'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 阿里-2-分享
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getAlipan4($urlData)
|
||||
{
|
||||
$urlHeader = array(
|
||||
'Accept: application/json, text/plain, */*',
|
||||
'Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
||||
'Authorization: '.$this->Authorization,
|
||||
'Content-Type: application/json',
|
||||
'Origin: https://www.alipan.com',
|
||||
'Priority: u=1, i',
|
||||
'Referer: https://www.alipan.com/',
|
||||
'Sec-Ch-Ua: "Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"',
|
||||
'Sec-Ch-Ua-Mobile: ?0',
|
||||
'Sec-Ch-Ua-Platform: "Windows"',
|
||||
'Sec-Fetch-Dest: empty',
|
||||
'Sec-Fetch-Mode: cors',
|
||||
'Sec-Fetch-Site: same-site',
|
||||
'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0',
|
||||
'X-Canary: client=web,app=share,version=v2.3.1'
|
||||
);
|
||||
$res = curlHelper("https://api.aliyundrive.com/adrive/v2/share_link/create", "POST", json_encode($urlData), $urlHeader)['body'];
|
||||
$res = json_decode($res, true);
|
||||
return jerr($res);
|
||||
if(!isset($res['share_url'])){
|
||||
return jerr($res['message']??'转存失败4');
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* UC 00000
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getStokenUc($pwd_id)
|
||||
{
|
||||
$urlData = array(
|
||||
'passcode' => '',
|
||||
'pwd_id' => $pwd_id,
|
||||
);
|
||||
$urlHeader = array(
|
||||
'Accept: application/json, text/plain, */*',
|
||||
'Accept-Language: zh-CN,zh;q=0.9',
|
||||
'content-type: application/json;charset=UTF-8',
|
||||
'sec-ch-ua: "Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"',
|
||||
'sec-ch-ua-mobile: ?0',
|
||||
'sec-ch-ua-platform: "Windows"',
|
||||
'sec-fetch-dest: empty',
|
||||
'sec-fetch-mode: cors',
|
||||
'sec-fetch-site: same-site',
|
||||
'Referer: https://drive.uc.cn/',
|
||||
'Referrer-Policy: strict-origin-when-cross-origin',
|
||||
'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
||||
);
|
||||
|
||||
$res = curlHelper("https://pc-api.uc.cn/1/clouddrive/share/sharepage/token?pr=UCBrowser&fr=pc", "POST",json_encode($urlData),$urlHeader)['body'];
|
||||
$res = json_decode($res, true);
|
||||
if($res['status'] !== 200){
|
||||
return jerr($res['message']);
|
||||
}
|
||||
$data = $res['data'];
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,628 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\App;
|
||||
use app\api\QfShop;
|
||||
use app\model\Source as SourceModel;
|
||||
use app\model\Days as DaysModel;
|
||||
|
||||
class Other extends QfShop
|
||||
{
|
||||
public function __construct(App $app)
|
||||
{
|
||||
parent::__construct($app);
|
||||
//第三方转存接口地址
|
||||
$this->url = "https://pan.xinyuedh.com";
|
||||
$this->model = new SourceModel();
|
||||
$this->cookie = Config('qfshop.quark_cookie');
|
||||
}
|
||||
|
||||
public function Alone_search2()
|
||||
{
|
||||
$searchdata = input('');
|
||||
if (empty($searchdata['alone_title'])) {
|
||||
return jerr("请输入要看的内容");
|
||||
}
|
||||
|
||||
$type = $searchdata['type']??0;
|
||||
$title = $searchdata['alone_title'];
|
||||
|
||||
$searchList = []; //查询的结果集
|
||||
$num_total = $type?2:20; //最多想要几条结果
|
||||
$num_success = 0;
|
||||
|
||||
// 处理第2个源
|
||||
foreach (source2($title) as $value) {
|
||||
if ($num_success >= $num_total) {
|
||||
break; // 有效结果数量已达到,则跳出循环
|
||||
}
|
||||
// 如果 URL 不存在则新增 $value
|
||||
if (!$this->urlExists($searchList, $value['url'])) {
|
||||
$searchList[] = $value;
|
||||
$num_success++;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理第4个源
|
||||
if ($num_success < $num_total) {
|
||||
foreach (source4($title) as $value) {
|
||||
if ($num_success >= $num_total) {
|
||||
break; // 有效结果数量已达到,则跳出循环
|
||||
}
|
||||
// 如果 URL 不存在则新增 $value
|
||||
if (!$this->urlExists($searchList, $value['url'])) {
|
||||
$searchList[] = $value;
|
||||
$num_success++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 处理第3个源
|
||||
if ($num_success < $num_total) {
|
||||
foreach (source3($title) as $value) {
|
||||
if ($num_success >= $num_total) {
|
||||
break; // 有效结果数量已达到,则跳出循环
|
||||
}
|
||||
// 如果 URL 不存在则新增 $value
|
||||
if (!$this->urlExists($searchList, $value['url'])) {
|
||||
$searchList[] = $value;
|
||||
$num_success++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 处理第1个源 第一个源放最后
|
||||
if ($num_success < $num_total) {
|
||||
foreach (source1($title) as $value) {
|
||||
if ($num_success >= $num_total) {
|
||||
break; // 有效结果数量已达到,则跳出循环
|
||||
}
|
||||
// 如果 URL 不存在则新增 $value
|
||||
if (!$this->urlExists($searchList, $value['url'])) {
|
||||
$searchList[] = $value;
|
||||
$num_success++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return jok('临时资源获取成功',$searchList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 全网搜索 该接口仅用于微信自动回复
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function Alone_search()
|
||||
{
|
||||
|
||||
$searchdata = input('post.');
|
||||
if (empty($searchdata['alone_title'])) {
|
||||
return jerr("请输入要看的内容");
|
||||
}
|
||||
$title = $searchdata['alone_title'];
|
||||
|
||||
|
||||
$map[] = ['status', '=', 1];
|
||||
$map[] = ['is_delete', '=', 0];
|
||||
$map[] = ['is_time', '=', 1];
|
||||
$map[] = ['title|description', 'like', '%' . trim($title) . '%'];
|
||||
|
||||
$urls = $this->model->where($map)->field('source_id as id, title, url')->order('update_time', 'desc')->limit(5)->select()->toArray();
|
||||
if (!empty($urls)) {
|
||||
|
||||
// 获取所有需要更新的ID
|
||||
$ids = [];
|
||||
foreach ($urls as $item) {
|
||||
$ids[] = $item['id'];
|
||||
}
|
||||
|
||||
// 更新数据库中的 update_time 字段
|
||||
if (!empty($ids)) {
|
||||
$this->model->whereIn('source_id', $ids)->update(['update_time' => time()]);
|
||||
}
|
||||
|
||||
return jok('临时资源获取成功',$urls);
|
||||
}
|
||||
|
||||
$searchList = []; //查询的结果集
|
||||
$datas = []; //最终数据
|
||||
$num_total = 2; //最多想要几条结果
|
||||
$num_success = 0;
|
||||
|
||||
// 处理第2个源
|
||||
foreach (source2($title) as $value) {
|
||||
if ($num_success >= $num_total) {
|
||||
break; // 有效结果数量已达到,则跳出循环
|
||||
}
|
||||
// 如果 URL 不存在则新增 $value
|
||||
if (!$this->urlExists($searchList, $value['url'])) {
|
||||
$searchList[] = $value;
|
||||
$this->processUrl($value, $num_success, $datas);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 处理第4个源
|
||||
if ($num_success < $num_total) {
|
||||
foreach (source4($title) as $value) {
|
||||
if ($num_success >= $num_total) {
|
||||
break; // 有效结果数量已达到,则跳出循环
|
||||
}
|
||||
// 如果 URL 不存在则新增 $value
|
||||
if (!$this->urlExists($searchList, $value['url'])) {
|
||||
$searchList[] = $value;
|
||||
$this->processUrl($value, $num_success, $datas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 处理第3个源
|
||||
if ($num_success < $num_total) {
|
||||
foreach (source3($title) as $value) {
|
||||
if ($num_success >= $num_total) {
|
||||
break; // 有效结果数量已达到,则跳出循环
|
||||
}
|
||||
// 如果 URL 不存在则新增 $value
|
||||
if (!$this->urlExists($searchList, $value['url'])) {
|
||||
$searchList[] = $value;
|
||||
$this->processUrl($value, $num_success, $datas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 处理第1个源 第一个源放最后
|
||||
if ($num_success < $num_total) {
|
||||
foreach (source1($title) as $value) {
|
||||
if ($num_success >= $num_total) {
|
||||
break; // 有效结果数量已达到,则跳出循环
|
||||
}
|
||||
// 如果 URL 不存在则新增 $value
|
||||
if (!$this->urlExists($searchList, $value['url'])) {
|
||||
$searchList[] = $value;
|
||||
$this->processUrl($value, $num_success, $datas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return jok('临时资源获取成功',$datas);
|
||||
}
|
||||
|
||||
// 检查 URL 是否已存在(忽略查询参数)
|
||||
public function urlExists($searchList, $urlToCheck) {
|
||||
// 解析待检查的 URL
|
||||
$parsedUrlToCheck = parse_url($urlToCheck);
|
||||
|
||||
foreach ($searchList as $item) {
|
||||
$parsedUrl = parse_url($item['url']);
|
||||
|
||||
// 比较 scheme, host 和 path
|
||||
if ($parsedUrlToCheck['scheme'] === $parsedUrl['scheme'] &&
|
||||
$parsedUrlToCheck['host'] === $parsedUrl['host'] &&
|
||||
$parsedUrlToCheck['path'] === $parsedUrl['path']) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 临时资源转存
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function processUrl($value, &$num_success, &$datas)
|
||||
{
|
||||
$substring = strstr($value['url'], 's/');
|
||||
if ($substring === false) {
|
||||
return; // 模拟 continue 行为
|
||||
}
|
||||
|
||||
$pwd_id = substr($substring, 2); // 去除 's/' 部分
|
||||
|
||||
$urlData = array(
|
||||
'cookie' => $this->cookie,
|
||||
'url' => $value['url'],
|
||||
'expired_type' => 2,
|
||||
'to_pdir_fid' => '61bad1e1380d47c78d6f5d86c877efb9', //存入目标文件
|
||||
'ad_fid' => '3b57147245774d88bafba7f43152f4bd', //分享时带上这个文件
|
||||
);
|
||||
$res = curlHelper($this->url."/api/open/transfer", "POST", $urlData)['body'];
|
||||
$res = json_decode($res, true);
|
||||
|
||||
if($res['code'] !== 200){
|
||||
return; // 模拟 continue 行为
|
||||
}
|
||||
|
||||
$patterns = '/^\d+\./';
|
||||
$title = preg_replace($patterns, '', $value['title']);
|
||||
// 添加资源到系统中
|
||||
$data["title"] =$title;
|
||||
$data["url"] =$res['data']['share_url'];
|
||||
$data["is_type"] = determineIsType($data["url"]);
|
||||
$data["fid"] =$res['data']['fid']??'';
|
||||
$data["is_time"] = 1;
|
||||
$data["update_time"] = time();
|
||||
$data["create_time"] = time();
|
||||
$this->model->insertGetId($data);
|
||||
$datas[] =$data;
|
||||
$num_success++;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 十分钟后清除临时资源
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete_search()
|
||||
{
|
||||
// 搜索条件
|
||||
$map[] = ['is_time', '=', 1];
|
||||
$map[] = ['update_time', '<=', time() - (30 * 60)];
|
||||
$abc = $this->model->where($map)->select();
|
||||
|
||||
|
||||
$this->model->where($map)->chunk(100, function ($order) {
|
||||
foreach ($order as $value) {
|
||||
$deles = $value->toArray();
|
||||
$filelist = [];
|
||||
$filelist[] = $deles['fid'];
|
||||
|
||||
|
||||
$urlData = array(
|
||||
'action_type' => 2,
|
||||
'exclude_fids' => [],
|
||||
'filelist' => $filelist,
|
||||
);
|
||||
$urlHeader = array(
|
||||
'Accept: application/json, text/plain, */*',
|
||||
'Accept-Language: zh-CN,zh;q=0.9',
|
||||
'content-type: application/json;charset=UTF-8',
|
||||
'sec-ch-ua: "Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"',
|
||||
'sec-ch-ua-mobile: ?0',
|
||||
'sec-ch-ua-platform: "Windows"',
|
||||
'sec-fetch-dest: empty',
|
||||
'sec-fetch-mode: cors',
|
||||
'sec-fetch-site: same-site',
|
||||
'Referer: https://pan.quark.cn/',
|
||||
'Referrer-Policy: strict-origin-when-cross-origin',
|
||||
'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
||||
'cookie: '.$this->cookie,
|
||||
);
|
||||
$res = curlHelper("https://drive-pc.quark.cn/1/clouddrive/file/delete?pr=ucpro&fr=pc&uc_param_str=", "POST", json_encode($urlData), $urlHeader)['body'];
|
||||
$res = json_decode($res, true);
|
||||
if($res['status'] == 200){
|
||||
$this->model->where('fid', $deles['fid'])->delete();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return jok('临时资源删除成功',$abc);
|
||||
}
|
||||
|
||||
|
||||
public function alone_zhuanshu22222()
|
||||
{
|
||||
$list = [];
|
||||
try {
|
||||
$result = curlHelper("https://duanju.niurl.cn/api.php", "GET")['body'];
|
||||
$list = json_decode($result, true);
|
||||
$list = $list['data'];
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
if (count($list) > 100) {
|
||||
$list = array_slice($list, 0, 100); // 如果超过100位,则截取前100位
|
||||
}
|
||||
$list = array_reverse($list);
|
||||
|
||||
foreach ($list as $key => $value){
|
||||
//如果资源不是今天或者昨天的 就跳过 只采集今天昨天的资源
|
||||
if($value['addtime'] != date('Y-m-d') && $value['addtime'] != date('Y-m-d', strtotime('-1 day'))){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//如已有此资源 跳过
|
||||
$detail = $this->model->where('title', $value['name'])->find();
|
||||
if(!empty($detail)){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$url = $value['url'];
|
||||
$substring = strstr($url, 's/');
|
||||
if ($substring !== false) {
|
||||
$pwd_id = substr($substring, 2); // 去除 's/' 部分
|
||||
} else {
|
||||
//资源地址格式有误
|
||||
continue;
|
||||
}
|
||||
$urlData = array(
|
||||
'cookie' => Config('qfshop.quark_cookie'),
|
||||
'url' => $url,
|
||||
);
|
||||
$res = curlHelper($this->url."/api/open/transfer", "POST", $urlData)['body'];
|
||||
$res = json_decode($res, true);
|
||||
if($res['code'] !== 200){
|
||||
continue;
|
||||
}
|
||||
|
||||
//添加资源到系统中
|
||||
$data["title"] = $value['name'];
|
||||
$data["url"] = $res['data']['share_url'];
|
||||
$data["update_time"] = time();
|
||||
$data["create_time"] = time();
|
||||
$this->model->insertGetId($data);
|
||||
}
|
||||
|
||||
return jok('123456');
|
||||
}
|
||||
|
||||
public function alone_zhuanshu()
|
||||
{
|
||||
$list = [];
|
||||
$add_num = 0;
|
||||
$parameters = array(
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'6fbefc1f535f48a38cbb580f9553fcea', //4月夸克文件夹fid
|
||||
'6da509da98124e1d98cd3aa70f1ad7fa',
|
||||
'2b805566aee0430ca6a3a0ba995685bd',
|
||||
'93996a5d87b64c36849c442374fd1bbf',
|
||||
'499e29a766704e00ac0e6e3d1c7b252a',
|
||||
'4c69edb70454496688813de3cd6a27f8',
|
||||
'fed17385093446b78e8c2f286f683100',
|
||||
'38233cc7b14148fea33ea9998c19dc22',
|
||||
'70c3c5d7a1cc442eb998428893b00e94'
|
||||
);
|
||||
|
||||
// try {
|
||||
// $result = curlHelper("https://duanju.niurl.cn/api.php", "GET")['body'];
|
||||
// $list = json_decode($result, true);
|
||||
// $list = $list['data'];
|
||||
|
||||
// } catch (Exception $e) {
|
||||
// }
|
||||
try {
|
||||
$list1 = [];
|
||||
$result = curlHelper("https://kuoapp.com/duanju/get.php?day=".date('Y-m-d'), "GET")['body'];
|
||||
$res1 = json_decode($result, true);
|
||||
if (is_array($res1) && array_keys($res1) === range(0, count($res1) - 1)) {
|
||||
$list1 = $res1;
|
||||
}
|
||||
|
||||
$list2 = [];
|
||||
$result = curlHelper("https://kuoapp.com/duanju/get.php?day=".date('Y-m-d', strtotime('-1 day')), "GET")['body'];
|
||||
$res2 = json_decode($result, true);
|
||||
if (is_array($res2) && array_keys($res2) === range(0, count($res2) - 1)) {
|
||||
$list2 = $res2;
|
||||
}
|
||||
$list = array_merge($list1, $list2); // 合并两个数组
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
if (count($list) > 100) {
|
||||
$list = array_slice($list, 0, 100); // 如果超过100位,则截取前100位
|
||||
}
|
||||
$list = array_reverse($list);
|
||||
|
||||
|
||||
foreach ($list as $key => $value){
|
||||
// 如果资源不是今天或者昨天的 就跳过 只采集今天昨天的资源
|
||||
if($value['addtime'] != date('Y-m-d') && $value['addtime'] != date('Y-m-d', strtotime('-1 day'))){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//如已有此资源 跳过
|
||||
$value['name'] = str_replace(["\u0000", "\x00", "\0"], '', $value['name']);
|
||||
$detail = $this->model->where('title', $value['name'])->find();
|
||||
if(!empty($detail)){
|
||||
continue;
|
||||
}
|
||||
|
||||
//整理数据 按天创建夸克文件夹
|
||||
$dateString = $value['addtime']; // 哪一天的资源 如:2024-04-01
|
||||
$timestamp = strtotime($dateString); // 将日期转换为时间戳
|
||||
$newDateString = date('n月j日', $timestamp); // 夸克文件夹的名称 格式: 4月1日
|
||||
$month = date('n', $timestamp); //月份 格式:4
|
||||
|
||||
$DaysModel = new DaysModel();
|
||||
|
||||
$fids = $DaysModel->where(["time"=>$dateString])->find();
|
||||
if (!$fids){
|
||||
//去创建文件夹获取fid
|
||||
$urlData = array(
|
||||
'dir_init_lock' => false,
|
||||
'dir_path' => "",
|
||||
'file_name' => $newDateString,
|
||||
'pdir_fid' => $parameters[$month-1],
|
||||
);
|
||||
$urlHeader = array(
|
||||
'Accept: application/json, text/plain, */*',
|
||||
'Accept-Language: zh-CN,zh;q=0.9',
|
||||
'content-type: application/json;charset=UTF-8',
|
||||
'sec-ch-ua: "Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"',
|
||||
'sec-ch-ua-mobile: ?0',
|
||||
'sec-ch-ua-platform: "Windows"',
|
||||
'sec-fetch-dest: empty',
|
||||
'sec-fetch-mode: cors',
|
||||
'sec-fetch-site: same-site',
|
||||
'Referer: https://pan.quark.cn/',
|
||||
'Referrer-Policy: strict-origin-when-cross-origin',
|
||||
'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
||||
'cookie: '.Config('qfshop.quark_cookie'),
|
||||
);
|
||||
$quark = curlHelper("https://drive-pc.quark.cn/1/clouddrive/file?pr=ucpro&fr=pc&uc_param_str=", "POST", json_encode($urlData), $urlHeader)['body'];
|
||||
$quark = json_decode($quark, true);
|
||||
if($quark['status'] !== 200){
|
||||
continue;
|
||||
}
|
||||
|
||||
$fid = $quark['data']['fid'];
|
||||
|
||||
$DaysModel->insert([
|
||||
"fid" => $fid,
|
||||
"time" => $dateString,
|
||||
]);
|
||||
$fids = $DaysModel->where(["time"=>$dateString])->find();
|
||||
}
|
||||
//最终我要获取 $fids['fid'] 这个参数
|
||||
|
||||
$url = $value['url'];
|
||||
$substring = strstr($url, 's/');
|
||||
if ($substring !== false) {
|
||||
$pwd_id = substr($substring, 2); // 去除 's/' 部分
|
||||
} else {
|
||||
//资源地址格式有误
|
||||
continue;
|
||||
}
|
||||
$urlData = array(
|
||||
'cookie' => Config('qfshop.quark_cookie'),
|
||||
'url' => $url,
|
||||
'to_pdir_fid' => $fids['fid']??''
|
||||
);
|
||||
$res = curlHelper($this->url."/api/open/transfer", "POST", $urlData)['body'];
|
||||
$res = json_decode($res, true);
|
||||
if($res['code'] !== 200){
|
||||
continue;
|
||||
}
|
||||
|
||||
//添加资源到系统中
|
||||
$data["title"] = $value['name'];
|
||||
$data["url"] = $res['data']['share_url'];
|
||||
$addtime = time();
|
||||
if(!empty($value['addtime'])){
|
||||
$addtime = $value['addtime'].' '.date('H:i');
|
||||
$addtime = strtotime($addtime);
|
||||
}
|
||||
$data["update_time"] = $addtime;
|
||||
$data["create_time"] = $addtime;
|
||||
$data["source_category_id"] = 1;
|
||||
$this->model->insertGetId($data);
|
||||
$add_num++;
|
||||
}
|
||||
|
||||
return jok(date('Y-m-d H:i').' Added number of resources',$add_num);
|
||||
}
|
||||
|
||||
public function aaaa()
|
||||
{
|
||||
$dateString = date('Y-m-d');
|
||||
$timestamp = strtotime($dateString); // 将日期转换为时间戳
|
||||
$newDateString = date('n月j日', $timestamp); // 夸克文件夹的名称 格式: 6月1日
|
||||
$month = date('n', $timestamp); //月份 格式:6
|
||||
|
||||
$list = [];
|
||||
try {
|
||||
$list1 = [];
|
||||
$result = curlHelper("https://kuoapp.com/duanju/get.php?day=".date('Y-m-d'), "GET")['body'];
|
||||
$res1 = json_decode($result, true);
|
||||
if (is_array($res1) && array_keys($res1) === range(0, count($res1) - 1)) {
|
||||
$list1 = $res1;
|
||||
}
|
||||
|
||||
$list2 = [];
|
||||
$result = curlHelper("https://kuoapp.com/duanju/get.php?day=".date('Y-m-d', strtotime('-1 day')), "GET")['body'];
|
||||
$res2 = json_decode($result, true);
|
||||
if (is_array($res2) && array_keys($res2) === range(0, count($res2) - 1)) {
|
||||
$list2 = $res2;
|
||||
}
|
||||
$list = array_merge($list1, $list2); // 合并两个数组
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
return jok('123456',date('H:i'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 在线观看接口 该接口仅用于微信自动回复
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function Alone_online()
|
||||
{
|
||||
if(!Config('qfshop.mp4_online')){
|
||||
return jok('在线资源地址', []);
|
||||
}
|
||||
// 获取输入数据
|
||||
$searchdata = input('');
|
||||
if (empty($searchdata['alone_title'])) {
|
||||
return jerr("请输入要看的内容");
|
||||
}
|
||||
$title = $searchdata['alone_title'];
|
||||
|
||||
// 定义请求头
|
||||
$urlHeader = [
|
||||
'cookie: thinkphp_show_page_trace=0|0; pwmd5=9c2c9cc26c93ed2d7560cfc4ae4d4ac3; userid=312; usergroup=1; username=18339988501; usertime=2024-08-06+15%3A41%3A26; usersin=04e882c0b3f468fba62a5d1f03174aea',
|
||||
'Content-Type: application/json'
|
||||
];
|
||||
|
||||
// 查询参数
|
||||
$queryParams = [
|
||||
'page' => 1,
|
||||
'limit' => 1,
|
||||
'name' => $title,
|
||||
'type' => '',
|
||||
];
|
||||
|
||||
// 发送GET请求
|
||||
$res = curlHelper("https://vvc.qeduanju.cn/promote/list.html", "GET", json_encode([]), $urlHeader, $queryParams)['body'];
|
||||
$res = json_decode($res, true);
|
||||
|
||||
// 检查响应并处理数据
|
||||
if ($res && $res['code'] == 0 && $res['count'] > 0) {
|
||||
$data = [];
|
||||
$ids = [];
|
||||
|
||||
foreach ($res['data'] as $value) {
|
||||
$data[] = [
|
||||
'id' => $value['id'],
|
||||
'title' => $value['name']
|
||||
];
|
||||
$ids[] = $value['id'];
|
||||
}
|
||||
|
||||
// POST请求的数据
|
||||
$urlData = [
|
||||
"id" => $ids,
|
||||
"pzid" => 283
|
||||
];
|
||||
|
||||
// 发送POST请求
|
||||
$res2 = curlHelper("https://vvc.qeduanju.cn/promote/dwz.html", "POST", json_encode($urlData), $urlHeader, $queryParams)['body'];
|
||||
$res2 = json_decode($res2, true);
|
||||
|
||||
if ($res2 && $res2['code'] == 0) {
|
||||
$finalData = [];
|
||||
foreach ($res2['data'] as $value) {
|
||||
foreach ($data as &$item) {
|
||||
if ($item['id'] == $value['id']) {
|
||||
$finalData[] = [
|
||||
'title' => '【在线观看】'.$item['title'],
|
||||
'url' => $value['url']
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
return jok('在线资源地址', $finalData);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有找到匹配数据,返回空数据
|
||||
return jok('在线资源地址', []);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\QfShop;
|
||||
use app\model\Source as SourceModel;
|
||||
use app\model\SourceCategory as SourceCategoryModel;
|
||||
|
||||
class Search extends QfShop
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$SourceModel = new SourceModel();
|
||||
$data = $SourceModel->getList(input(''));
|
||||
return jok('获取成功',$data);
|
||||
}
|
||||
|
||||
public function getDetail()
|
||||
{
|
||||
$SourceModel = new SourceModel();
|
||||
$data = $SourceModel->getDetail(input(''));
|
||||
return jok('获取成功',$data);
|
||||
}
|
||||
|
||||
public function getNew()
|
||||
{
|
||||
$SourceModel = new SourceModel();
|
||||
$data = input('');
|
||||
$data['page_size'] = $data['page_size']??20;
|
||||
$data = $SourceModel->getNew($data);
|
||||
return jok('获取成功',$data);
|
||||
}
|
||||
|
||||
public function getHot()
|
||||
{
|
||||
$SourceModel = new SourceModel();
|
||||
$data = $SourceModel->getHot(input(''));
|
||||
return jok('获取成功',$data);
|
||||
}
|
||||
|
||||
public function getCategory()
|
||||
{
|
||||
$SourceCategoryModel = new SourceCategoryModel();
|
||||
$data = $SourceCategoryModel->getList(input(''));
|
||||
return jok('获取成功',$data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\App;
|
||||
use app\api\QfShop;
|
||||
use think\facade\Cache;
|
||||
use Carbon\Carbon;
|
||||
use quarkPlugin\QuarkPlugin;
|
||||
use app\model\SourceCategory as SourceCategoryModel;
|
||||
|
||||
class Source extends QfShop
|
||||
{
|
||||
public function __construct(App $app)
|
||||
{
|
||||
parent::__construct($app);
|
||||
}
|
||||
public function day()
|
||||
{
|
||||
// 当前日期
|
||||
$currentDate = Carbon::today()->toDateString();
|
||||
// 缓存键名
|
||||
$cacheKey = 'api_alone_date_' . $currentDate;
|
||||
|
||||
// 检查缓存中是否存在该键
|
||||
if (Cache::has($cacheKey)) {
|
||||
return jerr("该接口今天已经执行过,请1小时后再试!");
|
||||
}
|
||||
|
||||
Cache::set($cacheKey, time(), 2400);
|
||||
|
||||
|
||||
|
||||
$SourceCategoryModel = new SourceCategoryModel();
|
||||
$map[] = ['is_update', '=', 1];
|
||||
$data = $SourceCategoryModel->where($map)->column('source_category_id');
|
||||
$ids = implode(',', $data);
|
||||
|
||||
$quarkPlugin = new QuarkPlugin();
|
||||
$quarkPlugin->transferAll($ids,2);
|
||||
return jok('已提交任务,稍后查看结果');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\App;
|
||||
use app\api\QfShop;
|
||||
use app\model\User as Usermodel;
|
||||
use app\model\Ads as Adsmodel;
|
||||
use app\model\Feedback as FeedbackModel;
|
||||
use app\model\SourceCategory as SourceCategoryModel;
|
||||
|
||||
class Tool extends QfShop
|
||||
{
|
||||
/**
|
||||
* 系统配置参数
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
$data = [
|
||||
'app_name' => Config('qfshop.app_name'),
|
||||
'qcode' => getimgurl(Config('qfshop.qcode')),
|
||||
'logo' => getimgurl(Config('qfshop.logo')),
|
||||
'app_description' => Config('qfshop.app_description'),
|
||||
];
|
||||
return jok('获取成功',$data);
|
||||
}
|
||||
/**
|
||||
* 上传图片
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function Upload()
|
||||
{
|
||||
// 获取当前登录的用户信息
|
||||
$userInfo = $this->getLoginUser();
|
||||
|
||||
try {
|
||||
$file = request()->file('file');
|
||||
} catch (\Exception $error) {
|
||||
return jerr('上传文件失败,请检查你的文件!');
|
||||
}
|
||||
$Usermodel = new Usermodel();
|
||||
$data = $Usermodel->Upload($file, $userInfo);
|
||||
return jok('上传成功',$data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据广告位关键词获取广告图片列表
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getAdsCode()
|
||||
{
|
||||
$Adsmodel = new Adsmodel();
|
||||
$data = $Adsmodel->getAdsCode(input(''));
|
||||
return jok('获取成功',$data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户反馈
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function feedback()
|
||||
{
|
||||
$data = input('');
|
||||
if (empty($data['content'])) {
|
||||
return jerr("请输入要看的内容");
|
||||
}
|
||||
$FeedbackModel = new FeedbackModel();
|
||||
$FeedbackModel->save(['content' => $data['content']]);
|
||||
return jok('已反馈');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取首页排行榜数据
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function ranking()
|
||||
{
|
||||
$channel = input('channel');
|
||||
$is_m = input('is_m')??0;
|
||||
|
||||
if (empty($channel)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// 使用 ThinkPHP 提供的 runtime_path() 函数获取 runtime 目录路径
|
||||
$cacheDir = runtime_path('cache'); // runtime/cache 目录
|
||||
if (!is_dir($cacheDir)) {
|
||||
mkdir($cacheDir, 0755, true); // 确保缓存目录存在
|
||||
}
|
||||
|
||||
// 根据 channel 值生成缓存文件名
|
||||
$cacheFile = $cacheDir . "ranking_data_{$channel}.cache";
|
||||
$cacheTime = 12*3600; // 缓存时间为 12 小时
|
||||
|
||||
// 检查缓存文件是否存在且在缓存时间内
|
||||
if (file_exists($cacheFile) && (time() - filemtime($cacheFile)) < $cacheTime) {
|
||||
// 从缓存中读取数据
|
||||
$data = json_decode(file_get_contents($cacheFile), true);
|
||||
} else {
|
||||
$data = [];
|
||||
if (!empty($channel)) {
|
||||
$queryParams = array(
|
||||
"area" => "全部",
|
||||
"year" => "全部",
|
||||
"channel" => $channel,
|
||||
"rank_type" => "最热",
|
||||
"cate" => "全部",
|
||||
"from" => "hot_page",
|
||||
"start" => 0,
|
||||
"hit" => Config('qfshop.ranking_num') ?? 1,
|
||||
);
|
||||
$res = curlHelper("https://biz.quark.cn/api/trending/ranking/getYingshiRanking", "GET", null, [], $queryParams)['body'];
|
||||
$res = json_decode($res, true);
|
||||
try {
|
||||
foreach ($res['data']['hits']['hit']['item'] as $key => $value) {
|
||||
$data[] = array(
|
||||
"title" => $value['title'],
|
||||
"src" => $value['src'],
|
||||
"ranking" => $value['ranking'],
|
||||
"hot_score" => $value['hot_score'],
|
||||
"desc" => $value['desc'],
|
||||
);
|
||||
}
|
||||
} catch (Exception $error) {
|
||||
$data = [];
|
||||
}
|
||||
|
||||
// 将数据缓存到文件中
|
||||
file_put_contents($cacheFile, json_encode($data));
|
||||
}
|
||||
}
|
||||
|
||||
if($is_m==1){
|
||||
$ranking_m_num = Config('qfshop.ranking_m_num') ?? 6;
|
||||
$data = array_slice($data, 0, $ranking_m_num);
|
||||
}
|
||||
|
||||
return jok('获取成功', $data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\App;
|
||||
use app\api\QfShop;
|
||||
|
||||
use EasyWeChat\Factory;
|
||||
use EasyWeChat\OfficialAccount\Application;
|
||||
|
||||
use app\model\Source as SourceModel;
|
||||
|
||||
class Wechat extends QfShop
|
||||
{
|
||||
/*
|
||||
微信公众平台配置如下:
|
||||
微信公众平台-基本配置-生成AppSecret并设置ip白名单
|
||||
启用服务器配置即可
|
||||
URL:你的域名/api/wechat/serve
|
||||
Token:自行生成
|
||||
EncodingAESKey:随机生成即可
|
||||
消息加解密方式:推荐即可
|
||||
*/
|
||||
private $config = [
|
||||
'app_id' => 'wx7d0373771cf5e395',//公众号appid
|
||||
'secret' => '3e9fefc1ccc573afb4141bf2e4e6ac3b',//公众号secret
|
||||
'token' => 'aDA3Ve61uNpn5xXKgPm49wtqL2ZlvDac', //Token 自行生成32字符串 英文或数字
|
||||
'aes_key' => 'r0HkOAEGKkaYdJLvaCy9ldtgzhMzDUJYPoLxUc62OMA' //微信公众平台生成后填写到这里
|
||||
];
|
||||
|
||||
public function serve()
|
||||
{
|
||||
// 创建一个微信公众账号实例,使用指定的配置
|
||||
$app = Factory::officialAccount($this->config);
|
||||
|
||||
// 设置消息处理回调函数
|
||||
$app->server->push(function ($message) {
|
||||
// 检查用户消息内容中是否包含“搜剧”关键字
|
||||
if (strpos($message['Content'], '搜') !== false) {
|
||||
|
||||
// 去除“搜剧”关键字和空格,提取用户输入的剧名
|
||||
$newString = str_replace(['搜剧', ' '], '', $message['Content']);
|
||||
$newString = str_replace(['搜', ' '], '', $message['Content']);
|
||||
|
||||
// 实例化资源模型,并搜索匹配的剧名
|
||||
$SourceModel = new SourceModel();
|
||||
$list = $SourceModel->where('title', 'like', '%' . $newString . '%')->limit(5)->select();
|
||||
|
||||
// 构建回复内容
|
||||
if (!$list->isEmpty()) {
|
||||
$content = "";
|
||||
foreach ($list as $item) {
|
||||
if ($content) {
|
||||
$content = $content."\n".$item['title']."\n".$item['url']."\n --------------------";
|
||||
} else {
|
||||
$content = $item['title']."\n".$item['url']."\n --------------------";
|
||||
}
|
||||
}
|
||||
// 添加操作步骤说明
|
||||
$content = $content."\n 步骤:点击上方链接-打开网盘-点立即查看-点右下角保存-打开文件-按文件名排序即可从第一集开始-自动-全集播放";
|
||||
} else {
|
||||
// 如果没有找到匹配的剧名,提示用户减少关键词尝试搜索
|
||||
$content = "未找到,减少关键词尝试搜索。";
|
||||
}
|
||||
|
||||
return $content; // 返回匹配结果或提示信息
|
||||
}
|
||||
|
||||
// 如果不匹配条件,返回空字符串或不做任何回复
|
||||
return '';
|
||||
});
|
||||
|
||||
// 开始处理微信服务器的请求并返回响应
|
||||
$response = $app->server->serve();
|
||||
$response->send(); // 发送响应
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
[2024-04-07T15:46:10.672053+08:00] EasyWeChat.DEBUG: Request received: {"method":"GET","uri":"https://pan.xinyuedh.com/api/wechat?s=%2Fapi%2Fwechat","content-type":null,"content":""}
|
||||
[2024-04-07T15:46:10.719415+08:00] EasyWeChat.DEBUG: Server response created: {"content":"success"}
|
||||
[2024-04-07T15:46:38.369913+08:00] EasyWeChat.DEBUG: Request received: {"method":"GET","uri":"https://pan.xinyuedh.com/api/wechat?s=%2Fapi%2Fwechat","content-type":null,"content":""}
|
||||
[2024-04-07T15:46:38.377289+08:00] EasyWeChat.DEBUG: Server response created: {"content":"success"}
|
||||
Reference in New Issue
Block a user