清空
This commit is contained in:
@@ -1,92 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\QfShop;
|
||||
|
||||
class Error extends QfShop
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return jerr("Error", 404);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\QfShop;
|
||||
|
||||
class Index extends QfShop
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return jok("Hello World!");
|
||||
}
|
||||
public function search() {
|
||||
return jok("Hello World!");
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\App;
|
||||
use app\api\QfShop;
|
||||
use app\model\Source as SourceModel;
|
||||
|
||||
class Other extends QfShop
|
||||
{
|
||||
public function __construct(App $app)
|
||||
{
|
||||
parent::__construct($app);
|
||||
//第三方转存接口地址
|
||||
$this->url = "https://pan.xinyuedh.com";
|
||||
$this->model = new SourceModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 全网搜索 该接口仅用于微信自动回复
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function search()
|
||||
{
|
||||
|
||||
$param = input('');
|
||||
if (empty($param['title'])) {
|
||||
return jerr("请输入要看的内容");
|
||||
}
|
||||
|
||||
$searchData = array(
|
||||
'cookie' => Config('qfshop.quark_cookie'),
|
||||
'title' => $param['title'],
|
||||
);
|
||||
$res = curlHelper($this->url."/api/open/network_search", "POST", $searchData)['body'];
|
||||
$res = json_decode($res, true);
|
||||
|
||||
if($res['code'] !== 200){
|
||||
return jerr($res['message']);
|
||||
}
|
||||
|
||||
$urls = $res['data'];
|
||||
|
||||
$datas = [];
|
||||
foreach ($urls as $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;
|
||||
}
|
||||
$patterns = '/^\d+\./';
|
||||
$title = preg_replace($patterns, '', $res['data']['title']);
|
||||
//添加资源到系统中
|
||||
$data["title"] = $title.'('.$param['title'].')';
|
||||
$data["url"] = $res['data']['share_url'];
|
||||
$data["fid"] = $res['data']['first_file']['fid'];
|
||||
$data["is_time"] = 1;
|
||||
$data["update_time"] = time();
|
||||
$data["create_time"] = time();
|
||||
$this->model->insertGetId($data);
|
||||
$datas[] = $data;
|
||||
}
|
||||
|
||||
return jok('临时资源获取成功',$datas);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 十分钟后清除临时资源
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete_search()
|
||||
{
|
||||
// 搜索条件
|
||||
$map[] = ['is_time', '=', 1];
|
||||
$map[] = ['create_time', '<=', time() - (10 * 60)];
|
||||
|
||||
|
||||
$this->model->where($map)->chunk(100, function ($order) {
|
||||
foreach ($order as $value) {
|
||||
$deles = $value->toArray();
|
||||
$filelist = [];
|
||||
$filelist[] = $deles['fid'];
|
||||
|
||||
|
||||
$urlData = '{ "action_type": 2, "exclude_fids": [], "filelist": '.json_encode($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: '.Config('qfshop.quark_cookie'),
|
||||
);
|
||||
$res = curlHelper("https://drive-pc.quark.cn/1/clouddrive/file/delete?pr=ucpro&fr=pc&uc_param_str=", "POST", $urlData, $urlHeader)['body'];
|
||||
$res = json_decode($res, true);
|
||||
if($res['status'] == 200){
|
||||
$this->model->where('fid', $deles['fid'])->delete();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return jok('临时资源删除成功');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?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 = $SourceModel->getNew(input(''));
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\App;
|
||||
use app\api\QfShop;
|
||||
use think\facade\Cache;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use app\model\Source as SourceModel;
|
||||
use app\model\SourceLog as SourceLogModel;
|
||||
|
||||
class Source extends QfShop
|
||||
{
|
||||
public function __construct(App $app)
|
||||
{
|
||||
parent::__construct($app);
|
||||
//第三方转存接口地址
|
||||
$this->url = "https://pan.xinyuedh.com";
|
||||
|
||||
$this->model = new SourceModel();
|
||||
$this->SourceLogModel = new SourceLogModel();
|
||||
}
|
||||
public function day()
|
||||
{
|
||||
// 当前日期
|
||||
$currentDate = Carbon::today()->toDateString();
|
||||
// 缓存键名
|
||||
$cacheKey = 'api_alone_date_' . $currentDate;
|
||||
|
||||
// 检查缓存中是否存在该键
|
||||
if (Cache::has($cacheKey)) {
|
||||
return jerr("请勿频繁调用,一个小时后再试!");
|
||||
}
|
||||
|
||||
Cache::set($cacheKey, time(), 3600);
|
||||
|
||||
ini_set('max_execution_time', -1);
|
||||
//分页转存
|
||||
$page_no = 1;
|
||||
$dataList = '';
|
||||
$logId = '';
|
||||
while ($dataList=='' || !empty($dataList['items'])) {
|
||||
$searchData = array(
|
||||
'page_no' => $page_no,
|
||||
'page_size' => 100,
|
||||
'type' => 2,
|
||||
'day' => 2,
|
||||
);
|
||||
$res = curlHelper($this->url."/api/search", "POST", $searchData)['body'];
|
||||
$res = json_decode($res, true);
|
||||
|
||||
if($res['code'] !== 200){
|
||||
ini_set('max_execution_time', 300);
|
||||
return jerr($res['message']);
|
||||
}
|
||||
$dataList = $res['data'];
|
||||
$page_no++;
|
||||
|
||||
if($logId == ''){
|
||||
$logId = $this->SourceLogModel->addLog('每日更新',$dataList['total_result']);
|
||||
}
|
||||
|
||||
foreach ($dataList['items'] as $key => $value) {
|
||||
//如已有此资源 跳过
|
||||
$detail = $this->model->where('title', $value['title'])->find();
|
||||
if(!empty($detail)){
|
||||
$this->SourceLogModel->editLog($logId,$dataList['total_result'],'skip_num','重复跳过转存');
|
||||
continue;
|
||||
}
|
||||
|
||||
$url = $value['url'];
|
||||
$substring = strstr($url, 's/');
|
||||
|
||||
if ($substring !== false) {
|
||||
$pwd_id = substr($substring, 2); // 去除 's/' 部分
|
||||
} else {
|
||||
$this->SourceLogModel->editLog($logId,$dataList['total_result'],'fail_num','资源地址格式有误');
|
||||
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){
|
||||
if($res['message'] == 'capacity limit[{0}]'){
|
||||
$this->SourceLogModel->editLog($logId,$dataList['total_result'],'fail_num',$res['message']);
|
||||
break;
|
||||
}else{
|
||||
$this->SourceLogModel->editLog($logId,$dataList['total_result'],'fail_num',$res['message']);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//添加资源到系统中
|
||||
$data["title"] = $value['title'];
|
||||
$data["url"] = $res['data']['share_url'];
|
||||
$data["update_time"] = time();
|
||||
$data["create_time"] = time();
|
||||
$this->model->insertGetId($data);
|
||||
$this->SourceLogModel->editLog($logId,$dataList['total_result'],'new_num','');
|
||||
}
|
||||
// 可以添加一个最大重试次数的限制,防止无限循环
|
||||
if ($page_no > 1000) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->SourceLogModel->editLog($logId,$dataList['total_result'],'','',3);
|
||||
ini_set('max_execution_time', 300);
|
||||
return jok('已提交任务,稍后查看结果',$dataList);
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
<?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;
|
||||
|
||||
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('已反馈');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user