From 37b43574354d6fff32e3649da51743a49978c52d Mon Sep 17 00:00:00 2001
From: HFO4 <912394456@qq.com>
Date: Fri, 23 Mar 2018 18:23:12 +0800
Subject: [PATCH 01/62] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=98=BF=E9=87=8C?=
=?UTF-8?q?=E4=BA=91OSS=E5=85=AC=E5=85=B1=E7=A9=BA=E9=97=B4=E6=97=A0?=
=?UTF-8?q?=E6=B3=95=E4=B8=8B=E8=BD=BD=E6=96=87=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/index/model/FileManage.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/application/index/model/FileManage.php b/application/index/model/FileManage.php
index 19cb669e..ba639c38 100644
--- a/application/index/model/FileManage.php
+++ b/application/index/model/FileManage.php
@@ -799,8 +799,7 @@ class FileManage extends Model{
public function ossDownload(){
if(!$this->policyData['bucket_private']){
- $fileUrl = $this->policyData["url"].$this->fileData["pre_name"]."?response-content-disposition=".urlencode('attachment; filename='.$this->fileData["orign_name"]);
- return[true,$fileUrl];
+ return[true,"/File/OssDownload?url=".urlencode($this->policyData["url"].$this->fileData["pre_name"])."&name=".urlencode($this->fileData["orign_name"])];
}else{
$accessKeyId = $this->policyData["ak"];
$accessKeySecret = $this->policyData["sk"];
From 0fe4e8a8dbb339837d31d9434ff5e2ae6f76ce1c Mon Sep 17 00:00:00 2001
From: HFO4 <912394456@qq.com>
Date: Sat, 24 Mar 2018 22:25:30 +0800
Subject: [PATCH 02/62] =?UTF-8?q?=E5=8F=91=E9=80=81=E6=B5=8B=E8=AF=95?=
=?UTF-8?q?=E9=82=AE=E4=BB=B6=E8=BF=94=E5=9B=9E=E6=9B=B4=E5=A4=9ADebug?=
=?UTF-8?q?=E4=BF=A1=E6=81=AF(Fix=20#46)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/index/controller/WebDav.php | 2 +-
application/index/model/Mail.php | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/application/index/controller/WebDav.php b/application/index/controller/WebDav.php
index ffdd15ea..7d8ca31d 100644
--- a/application/index/controller/WebDav.php
+++ b/application/index/controller/WebDav.php
@@ -28,7 +28,7 @@ class WebDav extends Controller{
$publicDir = new Directory($this->uid."/");
$server = new DAV\Server($publicDir);
- $server->setBaseUri('/WebDav/Api/uid/'.$this->uid);
+ $server->setBaseUri('/WebDav/Api/uid/'.$this->uid."/");
$lockBackend = new DAV\Locks\Backend\File(ROOT_PATH.'public/locks');
$lockPlugin = new DAV\Locks\Plugin($lockBackend);
$server->addPlugin($lockPlugin);
diff --git a/application/index/model/Mail.php b/application/index/model/Mail.php
index c7eb4dca..07f131c5 100644
--- a/application/index/model/Mail.php
+++ b/application/index/model/Mail.php
@@ -45,13 +45,16 @@ class Mail extends Model{
$mail->Username =$this->smtpUser;
$mail->Password = $this->smtpPass;
$mail->From = $this->fromAdress;
+ $mail->SMTPDebug = 1;
+ $mail->Debugoutput = function($str, $level) {
+ $this->errorMsg .= $str;
+ };
$mail->isHTML(true);
$mail->addAddress($to,$name);
$mail->Subject = $title;
$mail->Body = $content;
$status = $mail->send();
if(!$status){
- $this->errorMsg = $mail->ErrorInfo;
return false;
}
return true;
From 622b80a68076b880c13a31e0fd93f873d1176825 Mon Sep 17 00:00:00 2001
From: HFO4 <912394456@qq.com>
Date: Thu, 29 Mar 2018 21:39:04 +0800
Subject: [PATCH 03/62] =?UTF-8?q?=E5=BC=80=E5=90=AFDebug=E3=80=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/config.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/application/config.php b/application/config.php
index a7d2ce8a..30b42d7b 100644
--- a/application/config.php
+++ b/application/config.php
@@ -18,7 +18,7 @@ return [
// 应用命名空间
'app_namespace' => 'app',
// 应用调试模式
- 'app_debug' => false,
+ 'app_debug' => true,
// 应用Trace
'app_trace' => false,
// 应用模式状态
From 7536c8695b89c93e980c3353917c6e69e9a628f5 Mon Sep 17 00:00:00 2001
From: HFO4 <912394456@qq.com>
Date: Thu, 29 Mar 2018 21:41:40 +0800
Subject: [PATCH 04/62] =?UTF-8?q?=E6=9B=B4=E6=96=B0remote=E7=B1=BB?=
=?UTF-8?q?=E5=9E=8B=E6=8E=A5=E5=8F=A3URL?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
static/js/qiniu.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/static/js/qiniu.js b/static/js/qiniu.js
index c6d01ae7..1672240b 100644
--- a/static/js/qiniu.js
+++ b/static/js/qiniu.js
@@ -1148,7 +1148,7 @@ function QiniuJsSDK() {
// http://developer.qiniu.com/docs/v6/api/reference/up/bput.html
if(uploadConfig.saveType == "remote"){
up.setOption({
- 'url': qiniuUploadUrl + 'chunk.php',
+ 'url': qiniuUploadUrl + 'chunk',
'multipart': false,
'chunk_size': chunk_size,
'required_features': "chunks",
@@ -1213,7 +1213,7 @@ function QiniuJsSDK() {
});
if(uploadConfig.saveType == "remote"){
up.setOption({
- 'url': qiniuUploadUrl + 'chunk.php'
+ 'url': qiniuUploadUrl + 'chunk'
});
}
logger.debug("up.setOption url: ", qiniuUploadUrl + '/mkblk/' + leftSize);
@@ -1501,7 +1501,7 @@ function QiniuJsSDK() {
local_path = '/path/'+that.URLSafeBase64Encode(pathTmp);
}
if(uploadConfig.saveType == "remote"){
- var url = qiniuUploadUrl + 'mkfile.php?size=' + file.size +"&key="+ key+"&fname="+ fname +"&path="+local_path;
+ var url = qiniuUploadUrl + 'mkfile?size=' + file.size +"&key="+ key+"&fname="+ fname +"&path="+local_path;
}else{
var url = qiniuUploadUrl + '/mkfile/' + file.size + key + fname + x_vars_url+local_path;
}
From 32ca1132f2790eab07e118162412e2500c98d055 Mon Sep 17 00:00:00 2001
From: HFO4 <912394456@qq.com>
Date: Thu, 5 Apr 2018 13:24:52 +0800
Subject: [PATCH 05/62] =?UTF-8?q?aria2=E5=88=9D=E5=A7=8B=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../index/controller/RemoteDownload.php | 40 +++++++++++++++++++
application/index/model/Aria2.php | 15 +++++++
static/js/qiniu.js | 6 +--
3 files changed, 58 insertions(+), 3 deletions(-)
create mode 100644 application/index/controller/RemoteDownload.php
create mode 100644 application/index/model/Aria2.php
diff --git a/application/index/controller/RemoteDownload.php b/application/index/controller/RemoteDownload.php
new file mode 100644
index 00000000..2b3ef331
--- /dev/null
+++ b/application/index/controller/RemoteDownload.php
@@ -0,0 +1,40 @@
+userObj = new User(cookie('user_id'),cookie('login_key'));
+ if(!$this->userObj->loginStatus){
+ echo "Bad request";
+ exit();
+ }
+ }
+
+ private function checkPerimission($permissionId){
+ $permissionData = $this->userObj->groupData["aria2"];
+ if(explode(",",$permissionData)[$permissionId] != "1"){
+ return false;
+ }
+ return true;
+ }
+
+ public function addUrl(){
+ if(!$this->checkPerimission(0)){
+ return json(['error'=>1,'message'=>'您当前的无用户无法执行此操作']);
+ }
+ $aria2Options = Option::getValues(["aria2"]);
+ $aria2 = new Aria2($aria2Options);
+ }
+
+}
\ No newline at end of file
diff --git a/application/index/model/Aria2.php b/application/index/model/Aria2.php
new file mode 100644
index 00000000..68d037e8
--- /dev/null
+++ b/application/index/model/Aria2.php
@@ -0,0 +1,15 @@
+
\ No newline at end of file
diff --git a/static/js/qiniu.js b/static/js/qiniu.js
index 1672240b..c6d01ae7 100644
--- a/static/js/qiniu.js
+++ b/static/js/qiniu.js
@@ -1148,7 +1148,7 @@ function QiniuJsSDK() {
// http://developer.qiniu.com/docs/v6/api/reference/up/bput.html
if(uploadConfig.saveType == "remote"){
up.setOption({
- 'url': qiniuUploadUrl + 'chunk',
+ 'url': qiniuUploadUrl + 'chunk.php',
'multipart': false,
'chunk_size': chunk_size,
'required_features': "chunks",
@@ -1213,7 +1213,7 @@ function QiniuJsSDK() {
});
if(uploadConfig.saveType == "remote"){
up.setOption({
- 'url': qiniuUploadUrl + 'chunk'
+ 'url': qiniuUploadUrl + 'chunk.php'
});
}
logger.debug("up.setOption url: ", qiniuUploadUrl + '/mkblk/' + leftSize);
@@ -1501,7 +1501,7 @@ function QiniuJsSDK() {
local_path = '/path/'+that.URLSafeBase64Encode(pathTmp);
}
if(uploadConfig.saveType == "remote"){
- var url = qiniuUploadUrl + 'mkfile?size=' + file.size +"&key="+ key+"&fname="+ fname +"&path="+local_path;
+ var url = qiniuUploadUrl + 'mkfile.php?size=' + file.size +"&key="+ key+"&fname="+ fname +"&path="+local_path;
}else{
var url = qiniuUploadUrl + '/mkfile/' + file.size + key + fname + x_vars_url+local_path;
}
From 2ade8861c96be89c7dbda38b22ef8e972f594a6a Mon Sep 17 00:00:00 2001
From: HFO4 <912394456@qq.com>
Date: Thu, 5 Apr 2018 17:07:36 +0800
Subject: [PATCH 06/62] =?UTF-8?q?aria2=E4=B8=8B=E8=BD=BD=E8=AF=B7=E6=B1=82?=
=?UTF-8?q?=E5=AE=8C=E6=88=90=EF=BC=8C=E5=B9=B6=E4=B8=94=E4=BF=AE=E5=A4=8D?=
=?UTF-8?q?=E4=B8=80=E4=B8=AA=E8=BF=9C=E7=A8=8B=E6=9C=8D=E5=8A=A1=E7=AB=AF?=
=?UTF-8?q?path=E7=9A=84bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../index/controller/RemoteDownload.php | 1 +
application/index/model/Aria2.php | 42 ++++++++++++++++++-
public/downloads/.gitignore | 2 +
static/js/qiniu.js | 2 +
4 files changed, 46 insertions(+), 1 deletion(-)
create mode 100644 public/downloads/.gitignore
diff --git a/application/index/controller/RemoteDownload.php b/application/index/controller/RemoteDownload.php
index 2b3ef331..af749e74 100644
--- a/application/index/controller/RemoteDownload.php
+++ b/application/index/controller/RemoteDownload.php
@@ -35,6 +35,7 @@ class RemoteDownload extends Controller{
}
$aria2Options = Option::getValues(["aria2"]);
$aria2 = new Aria2($aria2Options);
+ $downloadStart = $aria2->addUrl(input("post.url"));
}
}
\ No newline at end of file
diff --git a/application/index/model/Aria2.php b/application/index/model/Aria2.php
index 68d037e8..d01446e7 100644
--- a/application/index/model/Aria2.php
+++ b/application/index/model/Aria2.php
@@ -6,9 +6,49 @@ use think\Db;
class Aria2 extends Model{
-
+ private $authToken;
+ private $apiUrl;
+ private $savePath;
+ private $saveOptions;
+ public $reqStatus;
+ public $reqMsg;
+
public function __construct($options){
+ $this->authToken = $options["aria2_token"];
+ $this->apiUrl = rtrim($options["aria2_rpcurl"],"/")."/";
+ $this->saveOptions = json_decode($options["aria2_options"],true);
+ $this->savePath = $options["aria2_tmppath"];
+ }
+
+ public function addUrl($url){
+ //{"params": ["token:123123132",["https://www.baidu.com/img/baidu_jgylogo3.gif"],{"dir":"../"}], "jsonrpc": "2.0", "id": "qer", "method": "aria2.addUri"}
+ $reqFileds = [
+ "params" => ["token:".$this->authToken,[
+ $url,["dir" => $this->savePath],
+ ]],
+ "jsonrpc" => "2.0",
+ "id" => uniqid(),
+ "method" => "aria2.addUri"
+ ];
+ $reqFileds["params"][1][1] = array_merge($reqFileds["params"][1][1],$this->saveOptions);
+ $reqFileds = json_encode($reqFileds,JSON_OBJECT_AS_ARRAY);
+ $respondData = $this->sendReq($reqFileds);
+ }
+ private function sendReq($data){
+ $curl = curl_init();
+ curl_setopt($curl, CURLOPT_URL, $this->apiUrl."jsonrpc");
+ curl_setopt($curl, CURLOPT_POST, 1);
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
+ curl_setopt($curl, CURLOPT_TIMEOUT, 15);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+ $tmpInfo = curl_exec($curl); // 执行操作
+ if (curl_errno($curl)) {
+ $this->reqStatus = 0;
+ $this->reqMsg = "请求失败,".curl_error($curl);
+ }
+ curl_close($curl); // 关闭CURL会话
+ return json_decode($tmpInfo); // 返回数据,json格式
}
}
diff --git a/public/downloads/.gitignore b/public/downloads/.gitignore
new file mode 100644
index 00000000..c96a04f0
--- /dev/null
+++ b/public/downloads/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
\ No newline at end of file
diff --git a/static/js/qiniu.js b/static/js/qiniu.js
index c6d01ae7..2800307f 100644
--- a/static/js/qiniu.js
+++ b/static/js/qiniu.js
@@ -1501,6 +1501,8 @@ function QiniuJsSDK() {
local_path = '/path/'+that.URLSafeBase64Encode(pathTmp);
}
if(uploadConfig.saveType == "remote"){
+ pathTmp = file.path;
+ local_path = that.URLSafeBase64Encode(pathTmp);
var url = qiniuUploadUrl + 'mkfile.php?size=' + file.size +"&key="+ key+"&fname="+ fname +"&path="+local_path;
}else{
var url = qiniuUploadUrl + '/mkfile/' + file.size + key + fname + x_vars_url+local_path;
From 126aacca63936668c2257303f07d5d46352d314c Mon Sep 17 00:00:00 2001
From: HFO4 <912394456@qq.com>
Date: Fri, 6 Apr 2018 10:26:10 +0800
Subject: [PATCH 07/62] =?UTF-8?q?=E7=A6=BB=E7=BA=BF=E4=B8=8B=E8=BD=BD?=
=?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=8F=8A=E6=95=B0=E6=8D=AE=E5=BA=93=E8=AE=B0?=
=?UTF-8?q?=E5=BD=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../index/controller/RemoteDownload.php | 18 ++++++++++++
application/index/model/Aria2.php | 29 ++++++++++++-------
2 files changed, 37 insertions(+), 10 deletions(-)
diff --git a/application/index/controller/RemoteDownload.php b/application/index/controller/RemoteDownload.php
index af749e74..72d9eae5 100644
--- a/application/index/controller/RemoteDownload.php
+++ b/application/index/controller/RemoteDownload.php
@@ -29,6 +29,19 @@ class RemoteDownload extends Controller{
return true;
}
+ private function insertRecord($aria2,$url){
+ Db::name("download")->insert([
+ "pid" => $aria2->pid,
+ "path_id" => $aria2->pathId,
+ "owner" => $this->userObj->uid,
+ "save_dir" => 1,
+ "status" => "ready",
+ "msg" => "",
+ "info"=>"",
+ "source" =>$url,
+ ]);
+ }
+
public function addUrl(){
if(!$this->checkPerimission(0)){
return json(['error'=>1,'message'=>'您当前的无用户无法执行此操作']);
@@ -36,6 +49,11 @@ class RemoteDownload extends Controller{
$aria2Options = Option::getValues(["aria2"]);
$aria2 = new Aria2($aria2Options);
$downloadStart = $aria2->addUrl(input("post.url"));
+ if($aria2->reqStatus){
+ $this->insertRecord($aria2,input("post.url"));
+ }else{
+ return json(['error'=>1,'message'=>$aria2->reqMsg]);
+ }
}
}
\ No newline at end of file
diff --git a/application/index/model/Aria2.php b/application/index/model/Aria2.php
index d01446e7..c3e5d435 100644
--- a/application/index/model/Aria2.php
+++ b/application/index/model/Aria2.php
@@ -12,27 +12,36 @@ class Aria2 extends Model{
private $saveOptions;
public $reqStatus;
public $reqMsg;
+ public $pathId;
+ public $pid;
public function __construct($options){
$this->authToken = $options["aria2_token"];
$this->apiUrl = rtrim($options["aria2_rpcurl"],"/")."/";
$this->saveOptions = json_decode($options["aria2_options"],true);
- $this->savePath = $options["aria2_tmppath"];
+ $this->savePath = rtrim(rtrim($options["aria2_tmppath"],"/"),"\\").DS;
}
public function addUrl($url){
- //{"params": ["token:123123132",["https://www.baidu.com/img/baidu_jgylogo3.gif"],{"dir":"../"}], "jsonrpc": "2.0", "id": "qer", "method": "aria2.addUri"}
+ $this->pathId = uniqid();
$reqFileds = [
- "params" => ["token:".$this->authToken,[
- $url,["dir" => $this->savePath],
- ]],
+ "params" => ["token:".$this->authToken,
+ [$url],["dir" => $this->savePath.$this->pathId],
+ ],
"jsonrpc" => "2.0",
- "id" => uniqid(),
+ "id" => $this->pathId,
"method" => "aria2.addUri"
];
- $reqFileds["params"][1][1] = array_merge($reqFileds["params"][1][1],$this->saveOptions);
+ $reqFileds["params"][2] = array_merge($reqFileds["params"][2],$this->saveOptions);
$reqFileds = json_encode($reqFileds,JSON_OBJECT_AS_ARRAY);
$respondData = $this->sendReq($reqFileds);
+ if(isset($respondData["result"])){
+ $this->reqStatus = 1;
+ $this->pid = $respondData["result"];
+ }else{
+ $this->reqStatus = 0;
+ $this->reqMsg = $respondData["error"]["message"];
+ }
}
private function sendReq($data){
@@ -42,13 +51,13 @@ class Aria2 extends Model{
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_TIMEOUT, 15);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
- $tmpInfo = curl_exec($curl); // 执行操作
+ $tmpInfo = curl_exec($curl);
if (curl_errno($curl)) {
$this->reqStatus = 0;
$this->reqMsg = "请求失败,".curl_error($curl);
}
- curl_close($curl); // 关闭CURL会话
- return json_decode($tmpInfo); // 返回数据,json格式
+ curl_close($curl);
+ return json_decode($tmpInfo,true);
}
}
From aabc32efb53d8c8b2214e18c38ad5674d672f8a1 Mon Sep 17 00:00:00 2001
From: HFO4 <912394456@qq.com>
Date: Fri, 6 Apr 2018 16:21:40 +0800
Subject: [PATCH 08/62] =?UTF-8?q?aria2=E7=8A=B6=E6=80=81=E6=9F=A5=E8=AF=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../index/controller/RemoteDownload.php | 15 +++-
application/index/model/Aria2.php | 89 +++++++++++++++++++
2 files changed, 103 insertions(+), 1 deletion(-)
diff --git a/application/index/controller/RemoteDownload.php b/application/index/controller/RemoteDownload.php
index 72d9eae5..04201747 100644
--- a/application/index/controller/RemoteDownload.php
+++ b/application/index/controller/RemoteDownload.php
@@ -43,7 +43,8 @@ class RemoteDownload extends Controller{
}
public function addUrl(){
- if(!$this->checkPerimission(0)){
+ $policyData = Db::name("policy")->where("id",$this->userObj->groupData["policy_name"])->find();
+ if(!$this->checkPerimission(0) || $policyData["policy_type"] != "local"){
return json(['error'=>1,'message'=>'您当前的无用户无法执行此操作']);
}
$aria2Options = Option::getValues(["aria2"]);
@@ -56,4 +57,16 @@ class RemoteDownload extends Controller{
}
}
+ public function FlushStatus(){
+ $aria2Options = Option::getValues(["aria2"]);
+ $aria2 = new Aria2($aria2Options);
+ if(!input("?post.id")){
+ return json(['error'=>1,'message'=>"信息不完整"]);
+ }
+ $policyData = Db::name("policy")->where("id",$this->userObj->groupData["policy_name"])->find();
+ if(!$aria2->flushStatus(input("post.id"),$this->userObj->uid,$policyData)){
+ return json(['error'=>1,'message'=>$aria2->reqMsg]);
+ }
+ }
+
}
\ No newline at end of file
diff --git a/application/index/model/Aria2.php b/application/index/model/Aria2.php
index c3e5d435..ebaf3429 100644
--- a/application/index/model/Aria2.php
+++ b/application/index/model/Aria2.php
@@ -14,6 +14,8 @@ class Aria2 extends Model{
public $reqMsg;
public $pathId;
public $pid;
+ private $uid;
+ private $policy;
public function __construct($options){
$this->authToken = $options["aria2_token"];
@@ -44,6 +46,93 @@ class Aria2 extends Model{
}
}
+ public function flushStatus($id,$uid,$policy){
+ $this->uid = $uid;
+ $this->policy = $policy;
+ $downloadInfo = Db::name("download")->where("id",$id)->find();
+ if(empty($downloadInfo)){
+ $this->reqStatus = 0;
+ $this->reqMsg = "未找到下载记录";
+ return false;
+ }
+ if(in_array($downloadInfo["status"], ["error","complete"])){
+ $this->reqStatus = 1;
+ return true;
+ }
+ if($uid != $downloadInfo["owner"]){
+ $this->reqStatus = 0;
+ $this->reqMsg = "无权操作";
+ return false;
+ }
+ $reqFileds = [
+ "params" => ["token:".$this->authToken,$downloadInfo["pid"]],
+ "jsonrpc" => "2.0",
+ "id" => uniqid(),
+ "method" => "aria2.tellStatus"
+ ];
+ $reqFileds = json_encode($reqFileds,JSON_OBJECT_AS_ARRAY);
+ $respondData = $this->sendReq($reqFileds);
+ if(isset($respondData["result"])){
+ if($this->storageCheck($respondData["result"],$downloadInfo)){
+ Db::name("download")->where("id",$id)
+ ->update([
+ "status" => $respondData["result"]["status"],
+ "last_update" => date("Y-m-d h:i:s"),
+ "info" => json_encode([
+ "completedLength" => $respondData["result"]["completedLength"],
+ "totalLength" => $respondData["result"]["totalLength"],
+ "dir" => $respondData["result"]["dir"],
+ "downloadSpeed" => $respondData["result"]["downloadSpeed"],
+ "errorMessage" => $respondData["result"]["errorMessage"],
+ ]),
+ ]);
+ switch ($respondData["result"]["status"]) {
+ case 'complete':
+ $this->setComplete($respondData["result"],$downloadInfo);
+ break;
+
+ default:
+ # code...
+ break;
+ }
+ }else{
+ $this->reqStatus = 0;
+ $this->reqMsg = "空间容量不足";
+ //取消离线下载
+ return false;
+ }
+ }else{
+ $this->reqStatus = 0;
+ $this->reqMsg = $respondData["error"]["message"];
+ }
+ return true;
+ }
+
+ private function setComplete($quenInfo,$sqlData){
+ FileManage::storageCheckOut($this->uid,(int)$quenInfo["totalLength"]);
+ if($this->policy["policy_type"] != "local"){
+ return false;
+ }
+ $suffixTmp = explode('.', $quenInfo["dir"]);
+ $fileSuffix = array_pop($suffixTmp);
+ $allowedSuffix = explode(',', UploadHandler::getAllowedExt(json_decode($this->policy["filetype"],true)));
+ $sufficCheck = !in_array($fileSuffix,$allowedSuffix);
+ if(empty(UploadHandler::getAllowedExt(json_decode($this->policy["filetype"],true)))){
+ $sufficCheck = false;
+ }
+ var_dump($sufficCheck);
+ }
+
+ private function storageCheck($quenInfo,$sqlData){
+ if(!FileManage::sotrageCheck($this->uid,(int)$quenInfo["totalLength"])){
+ return false;
+ }
+ if(!FileManage::sotrageCheck($this->uid,(int)$quenInfo["completedLength"])){
+ return false;
+ }
+ return true;
+ }
+
private function sendReq($data){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $this->apiUrl."jsonrpc");
From f4a4ca02b5163731c84f642f1872f72e8b9c4398 Mon Sep 17 00:00:00 2001
From: HFO4 <912394456@qq.com>
Date: Fri, 6 Apr 2018 21:09:24 +0800
Subject: [PATCH 09/62] =?UTF-8?q?aria2=E4=B8=8B=E8=BD=BD=E5=AE=8C=E6=88=90?=
=?UTF-8?q?=E5=90=8E=E7=9A=84=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/index/model/Aria2.php | 46 +++++++++++++++++++++++++++----
1 file changed, 40 insertions(+), 6 deletions(-)
diff --git a/application/index/model/Aria2.php b/application/index/model/Aria2.php
index ebaf3429..8b7f57b0 100644
--- a/application/index/model/Aria2.php
+++ b/application/index/model/Aria2.php
@@ -81,9 +81,9 @@ class Aria2 extends Model{
"info" => json_encode([
"completedLength" => $respondData["result"]["completedLength"],
"totalLength" => $respondData["result"]["totalLength"],
- "dir" => $respondData["result"]["dir"],
+ "dir" => $respondData["result"]["files"][0]["path"],
"downloadSpeed" => $respondData["result"]["downloadSpeed"],
- "errorMessage" => $respondData["result"]["errorMessage"],
+ "errorMessage" => isset($respondData["result"]["errorMessage"]) ? $respondData["result"]["errorMessage"] : "",
]),
]);
switch ($respondData["result"]["status"]) {
@@ -109,18 +109,52 @@ class Aria2 extends Model{
}
private function setComplete($quenInfo,$sqlData){
- FileManage::storageCheckOut($this->uid,(int)$quenInfo["totalLength"]);
if($this->policy["policy_type"] != "local"){
+ //取消任务
return false;
}
$suffixTmp = explode('.', $quenInfo["dir"]);
$fileSuffix = array_pop($suffixTmp);
- $allowedSuffix = explode(',', UploadHandler::getAllowedExt(json_decode($this->policy["filetype"],true)));
+ $uploadHandller = new UploadHandler($this->policy["id"],$this->uid);
+ $allowedSuffix = explode(',', $uploadHandller->getAllowedExt(json_decode($this->policy["filetype"],true)));
$sufficCheck = !in_array($fileSuffix,$allowedSuffix);
- if(empty(UploadHandler::getAllowedExt(json_decode($this->policy["filetype"],true)))){
+ if(empty($uploadHandller->getAllowedExt(json_decode($this->policy["filetype"],true)))){
$sufficCheck = false;
}
- var_dump($sufficCheck);
+ if($sufficCheck){
+ //取消任务
+ $this->setError();
+ return false;
+ }
+ if($this->policy['autoname']){
+ $fileName = $uploadHandller->getObjName($this->policy['namerule'],"local",basename($quenInfo["files"][0]["path"]));
+ }else{
+ $fileName = basename($quenInfo["files"][0]["path"]);
+ }
+ $generatePath = $uploadHandller->getDirName($this->policy['dirrule']);
+ $savePath = ROOT_PATH . 'public/uploads/'.$generatePath.DS.$fileName;
+ is_dir(dirname($savePath))? :mkdir(dirname($savePath),0777,true);
+ rename($quenInfo["files"][0]["path"],$savePath);
+ @unlink(dirname($quenInfo["files"][0]["path"]));
+ $jsonData = array(
+ "path" => "",
+ "fname" => basename($quenInfo["files"][0]["path"]),
+ "objname" => $generatePath.DS.$fileName,
+ "fsize" => $quenInfo["totalLength"],
+ );
+ @list($width, $height, $type, $attr) = getimagesize($savePath);
+ $picInfo = empty($width)?" ":$width.",".$height;
+ $addAction = FileManage::addFile($jsonData,$this->policy,$this->uid,$picInfo);
+ if(!$addAction[0]){
+ //取消任务
+ $this->setError();
+ return false;
+ }
+ FileManage::storageCheckOut($this->uid,(int)$quenInfo["totalLength"]);
+ }
+
+ private function setError(){
+
}
private function storageCheck($quenInfo,$sqlData){
From c4ecee4897c18bf903a5c0afcf4c2566e5956207 Mon Sep 17 00:00:00 2001
From: HFO4 <912394456@qq.com>
Date: Fri, 6 Apr 2018 21:24:56 +0800
Subject: [PATCH 10/62] =?UTF-8?q?=E5=85=B3=E9=97=ADDebug=EF=BC=8C=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/config.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/application/config.php b/application/config.php
index 30b42d7b..abd98202 100644
--- a/application/config.php
+++ b/application/config.php
@@ -18,7 +18,7 @@ return [
// 应用命名空间
'app_namespace' => 'app',
// 应用调试模式
- 'app_debug' => true,
+ 'app_debug' => false,
// 应用Trace
'app_trace' => false,
// 应用模式状态
@@ -156,7 +156,7 @@ return [
'exception_tmpl' => THINK_PATH . 'tpl' . DS . 'think_exception.tpl',
// 错误显示信息,非调试模式有效
- 'error_message' => '页面错误!请稍后再试~',
+ 'error_message' => '出现错误,我们都有不顺利的时候,请坐和放宽',
// 显示错误信息
'show_error_msg' => false,
// 异常处理handle类 留空使用 \think\exception\Handle
From 1af411daee0632b30734cb9578344f500bdbb9e8 Mon Sep 17 00:00:00 2001
From: HFO4 <912394456@qq.com>
Date: Fri, 6 Apr 2018 21:28:48 +0800
Subject: [PATCH 11/62] =?UTF-8?q?=E5=85=B3=E9=97=ADDebug=EF=BC=8C=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/config.php | 2 +-
thinkphp/tpl/think_exception.tpl | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/application/config.php b/application/config.php
index abd98202..38405e4a 100644
--- a/application/config.php
+++ b/application/config.php
@@ -156,7 +156,7 @@ return [
'exception_tmpl' => THINK_PATH . 'tpl' . DS . 'think_exception.tpl',
// 错误显示信息,非调试模式有效
- 'error_message' => '出现错误,我们都有不顺利的时候,请坐和放宽',
+ 'error_message' => '很抱歉,出现错误 :(',
// 显示错误信息
'show_error_msg' => false,
// 异常处理handle类 留空使用 \think\exception\Handle
diff --git a/thinkphp/tpl/think_exception.tpl b/thinkphp/tpl/think_exception.tpl
index 06035770..89866be1 100644
--- a/thinkphp/tpl/think_exception.tpl
+++ b/thinkphp/tpl/think_exception.tpl
@@ -361,7 +361,9 @@
From ee569197478642fcfd929e5a3927aaa928711170 Mon Sep 17 00:00:00 2001
From: HFO4 <912394456@qq.com>
Date: Sat, 7 Apr 2018 11:02:43 +0800
Subject: [PATCH 12/62] =?UTF-8?q?aria2=E4=B8=8B=E8=BD=BD=E5=A4=B1=E8=B4=A5?=
=?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/config.php | 2 +-
application/index/model/Aria2.php | 50 +++++++++++++++++++++++++++----
2 files changed, 46 insertions(+), 6 deletions(-)
diff --git a/application/config.php b/application/config.php
index 38405e4a..fd8a9488 100644
--- a/application/config.php
+++ b/application/config.php
@@ -18,7 +18,7 @@ return [
// 应用命名空间
'app_namespace' => 'app',
// 应用调试模式
- 'app_debug' => false,
+ 'app_debug' => true,
// 应用Trace
'app_trace' => false,
// 应用模式状态
diff --git a/application/index/model/Aria2.php b/application/index/model/Aria2.php
index 8b7f57b0..ab6617cf 100644
--- a/application/index/model/Aria2.php
+++ b/application/index/model/Aria2.php
@@ -85,6 +85,7 @@ class Aria2 extends Model{
"downloadSpeed" => $respondData["result"]["downloadSpeed"],
"errorMessage" => isset($respondData["result"]["errorMessage"]) ? $respondData["result"]["errorMessage"] : "",
]),
+ "msg" => isset($respondData["result"]["errorMessage"]) ? $respondData["result"]["errorMessage"] : "",
]);
switch ($respondData["result"]["status"]) {
case 'complete':
@@ -98,7 +99,7 @@ class Aria2 extends Model{
}else{
$this->reqStatus = 0;
$this->reqMsg = "空间容量不足";
- //取消离线下载
+ $this->setError($respondData["result"],$downloadInfo,"空间容量不足");
return false;
}
}else{
@@ -110,7 +111,7 @@ class Aria2 extends Model{
private function setComplete($quenInfo,$sqlData){
if($this->policy["policy_type"] != "local"){
- //取消任务
+ $this->setError($quenInfo,$sqlData,"您当前的上传策略无法使用离线下载");
return false;
}
$suffixTmp = explode('.', $quenInfo["dir"]);
@@ -123,7 +124,7 @@ class Aria2 extends Model{
}
if($sufficCheck){
//取消任务
- $this->setError();
+ $this->setError($quenInfo,$sqlData,"文件类型不被允许");
return false;
}
if($this->policy['autoname']){
@@ -147,14 +148,53 @@ class Aria2 extends Model{
$addAction = FileManage::addFile($jsonData,$this->policy,$this->uid,$picInfo);
if(!$addAction[0]){
//取消任务
- $this->setError();
+ $this->setError($quenInfo,$sqlData,$addAction[1]);
return false;
}
FileManage::storageCheckOut($this->uid,(int)$quenInfo["totalLength"]);
}
- private function setError(){
+ private function setError($quenInfo,$sqlData,$msg,$status="error"){
+ $this->Remove($sqlData["pid"],$sqlData);
+ $this->removeDownloadResult($sqlData["pid"],$sqlData);
+ if(file_exists($quenInfo["files"][0]["path"])){
+ @unlink($quenInfo["files"][0]["path"]);
+ @unlink(dirname($quenInfo["files"][0]["path"]));
+ }
+ Db::name("download")->where("id",$sqlData["id"])->update([
+ "msg" => $msg,
+ "status" => $status,
+ ]);
+ }
+ public function Remove($gid,$sqlData){
+ $reqFileds = [
+ "params" => ["token:".$this->authToken,$gid],
+ "jsonrpc" => "2.0",
+ "id" => uniqid(),
+ "method" => "aria2.remove"
+ ];
+ $reqFileds = json_encode($reqFileds,JSON_OBJECT_AS_ARRAY);
+ $respondData = $this->sendReq($reqFileds);
+ if(isset($respondData["result"])){
+ return true;
+ }
+ return false;
+ }
+
+ public function removeDownloadResult($gid,$sqlData){
+ $reqFileds = [
+ "params" => ["token:".$this->authToken,$gid],
+ "jsonrpc" => "2.0",
+ "id" => uniqid(),
+ "method" => "aria2.removeDownloadResult"
+ ];
+ $reqFileds = json_encode($reqFileds,JSON_OBJECT_AS_ARRAY);
+ $respondData = $this->sendReq($reqFileds);
+ if(isset($respondData["result"])){
+ return true;
+ }
+ return false;
}
private function storageCheck($quenInfo,$sqlData){
From 1b87365b8a4e2108f51f57ad4b019949aee32ad7 Mon Sep 17 00:00:00 2001
From: HFO4 <912394456@qq.com>
Date: Sat, 7 Apr 2018 15:16:57 +0800
Subject: [PATCH 13/62] =?UTF-8?q?aria2=20=E7=A7=8D=E5=AD=90=E4=B8=8B?=
=?UTF-8?q?=E8=BD=BD=E5=8F=8A=E5=A4=9A=E6=96=87=E4=BB=B6=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../index/controller/RemoteDownload.php | 18 +++
application/index/model/Aria2.php | 107 +++++++++++++-----
2 files changed, 99 insertions(+), 26 deletions(-)
diff --git a/application/index/controller/RemoteDownload.php b/application/index/controller/RemoteDownload.php
index 04201747..1259d512 100644
--- a/application/index/controller/RemoteDownload.php
+++ b/application/index/controller/RemoteDownload.php
@@ -39,6 +39,8 @@ class RemoteDownload extends Controller{
"msg" => "",
"info"=>"",
"source" =>$url,
+ "file_index" => 0,
+ "is_single" => 1,
]);
}
@@ -57,6 +59,22 @@ class RemoteDownload extends Controller{
}
}
+ public function AddTorrent(){
+ $policyData = Db::name("policy")->where("id",$this->userObj->groupData["policy_name"])->find();
+ if(!$this->checkPerimission(0) || $policyData["policy_type"] != "local"){
+ return json(['error'=>1,'message'=>'您当前的无用户无法执行此操作']);
+ }
+ $aria2Options = Option::getValues(["aria2"]);
+ $aria2 = new Aria2($aria2Options);
+ $torrentObj = new \app\index\model\FileManage(input("post.path"),$this->userObj->uid);
+ $downloadStart = $aria2->addTorrent($torrentObj->signTmpUrl());
+ if($aria2->reqStatus){
+ $this->insertRecord($aria2,input("post.path"));
+ }else{
+ return json(['error'=>1,'message'=>$aria2->reqMsg]);
+ }
+ }
+
public function FlushStatus(){
$aria2Options = Option::getValues(["aria2"]);
$aria2 = new Aria2($aria2Options);
diff --git a/application/index/model/Aria2.php b/application/index/model/Aria2.php
index ab6617cf..b6c44481 100644
--- a/application/index/model/Aria2.php
+++ b/application/index/model/Aria2.php
@@ -46,6 +46,28 @@ class Aria2 extends Model{
}
}
+ public function addTorrent($torrentUrl){
+ $this->pathId = uniqid();
+ $reqFileds = [
+ "params" => ["token:".$this->authToken,
+ [$torrentUrl],["dir" => $this->savePath.$this->pathId],
+ ],
+ "jsonrpc" => "2.0",
+ "id" => $this->pathId,
+ "method" => "aria2.addUri"
+ ];
+ $reqFileds["params"][2] = array_merge($reqFileds["params"][2],$this->saveOptions);
+ $reqFileds = json_encode($reqFileds,JSON_OBJECT_AS_ARRAY);
+ $respondData = $this->sendReq($reqFileds);
+ if(isset($respondData["result"])){
+ $this->reqStatus = 1;
+ $this->pid = $respondData["result"];
+ }else{
+ $this->reqStatus = 0;
+ $this->reqMsg = $respondData["error"]["message"];
+ }
+ }
+
public function flushStatus($id,$uid,$policy){
$this->uid = $uid;
$this->policy = $policy;
@@ -74,14 +96,25 @@ class Aria2 extends Model{
$respondData = $this->sendReq($reqFileds);
if(isset($respondData["result"])){
if($this->storageCheck($respondData["result"],$downloadInfo)){
+ if($downloadInfo["is_single"] && count($respondData["result"]["files"]) >1){
+ $this->updateToMuiltpe($respondData["result"],$downloadInfo);
+ return false;
+ }
+ if(isset($respondData["result"]["followedBy"])){
+ Db::name("download")->where("id",$id)
+ ->update([
+ "pid" => $respondData["result"]["followedBy"][0],
+ ]);
+ return false;
+ }
Db::name("download")->where("id",$id)
->update([
"status" => $respondData["result"]["status"],
"last_update" => date("Y-m-d h:i:s"),
"info" => json_encode([
- "completedLength" => $respondData["result"]["completedLength"],
- "totalLength" => $respondData["result"]["totalLength"],
- "dir" => $respondData["result"]["files"][0]["path"],
+ "completedLength" => $respondData["result"]["files"][$downloadInfo["file_index"]]["completedLength"],
+ "totalLength" => $respondData["result"]["files"][$downloadInfo["file_index"]]["length"],
+ "dir" => $respondData["result"]["files"][$downloadInfo["file_index"]]["path"],
"downloadSpeed" => $respondData["result"]["downloadSpeed"],
"errorMessage" => isset($respondData["result"]["errorMessage"]) ? $respondData["result"]["errorMessage"] : "",
]),
@@ -105,10 +138,30 @@ class Aria2 extends Model{
}else{
$this->reqStatus = 0;
$this->reqMsg = $respondData["error"]["message"];
+ $this->setError($respondData,$downloadInfo,$respondData["error"]["message"],"error",false);
+ return false;
}
return true;
}
+ private function updateToMuiltpe($quenInfo,$sqlData){
+ foreach ($quenInfo["files"] as $key => $value) {
+ Db::name("download")->insert([
+ "pid" => $sqlData["pid"],
+ "path_id" => $sqlData["path_id"],
+ "owner" => $sqlData["owner"],
+ "save_dir" => 1,
+ "status" => "ready",
+ "msg" => "",
+ "info"=>"",
+ "source" =>$sqlData["source"],
+ "file_index" => $key,
+ "is_single" => 0,
+ ]);
+ }
+ Db::name("download")->where("id",$sqlData["id"])->delete();
+ }
+
private function setComplete($quenInfo,$sqlData){
if($this->policy["policy_type"] != "local"){
$this->setError($quenInfo,$sqlData,"您当前的上传策略无法使用离线下载");
@@ -128,20 +181,20 @@ class Aria2 extends Model{
return false;
}
if($this->policy['autoname']){
- $fileName = $uploadHandller->getObjName($this->policy['namerule'],"local",basename($quenInfo["files"][0]["path"]));
+ $fileName = $uploadHandller->getObjName($this->policy['namerule'],"local",basename($quenInfo["files"][$sqlData["file_index"]]["path"]));
}else{
- $fileName = basename($quenInfo["files"][0]["path"]);
+ $fileName = basename($quenInfo["files"][$sqlData["file_index"]]["path"]);
}
$generatePath = $uploadHandller->getDirName($this->policy['dirrule']);
$savePath = ROOT_PATH . 'public/uploads/'.$generatePath.DS.$fileName;
is_dir(dirname($savePath))? :mkdir(dirname($savePath),0777,true);
- rename($quenInfo["files"][0]["path"],$savePath);
- @unlink(dirname($quenInfo["files"][0]["path"]));
+ rename($quenInfo["files"][$sqlData["file_index"]]["path"],$savePath);
+ @unlink(dirname($quenInfo["files"][$sqlData["file_index"]]["path"]));
$jsonData = array(
"path" => "",
- "fname" => basename($quenInfo["files"][0]["path"]),
+ "fname" => basename($quenInfo["files"][$sqlData["file_index"]]["path"]),
"objname" => $generatePath.DS.$fileName,
- "fsize" => $quenInfo["totalLength"],
+ "fsize" => $quenInfo["files"][$sqlData["file_index"]]["length"],
);
@list($width, $height, $type, $attr) = getimagesize($savePath);
$picInfo = empty($width)?" ":$width.",".$height;
@@ -151,15 +204,17 @@ class Aria2 extends Model{
$this->setError($quenInfo,$sqlData,$addAction[1]);
return false;
}
- FileManage::storageCheckOut($this->uid,(int)$quenInfo["totalLength"]);
+ FileManage::storageCheckOut($this->uid,(int)$quenInfo["files"][$sqlData["file_index"]]["length"]);
}
- private function setError($quenInfo,$sqlData,$msg,$status="error"){
+ private function setError($quenInfo,$sqlData,$msg,$status="error",$delete=true){
$this->Remove($sqlData["pid"],$sqlData);
$this->removeDownloadResult($sqlData["pid"],$sqlData);
- if(file_exists($quenInfo["files"][0]["path"])){
- @unlink($quenInfo["files"][0]["path"]);
- @unlink(dirname($quenInfo["files"][0]["path"]));
+ if($delete){
+ if(file_exists($quenInfo["files"][$sqlData["file_index"]]["path"])){
+ @unlink($quenInfo["files"][$sqlData["file_index"]]["path"]);
+ @unlink(dirname($quenInfo["files"][$sqlData["file_index"]]["path"]));
+ }
}
Db::name("download")->where("id",$sqlData["id"])->update([
"msg" => $msg,
@@ -209,18 +264,18 @@ class Aria2 extends Model{
private function sendReq($data){
$curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, $this->apiUrl."jsonrpc");
- curl_setopt($curl, CURLOPT_POST, 1);
- curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
- curl_setopt($curl, CURLOPT_TIMEOUT, 15);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
- $tmpInfo = curl_exec($curl);
- if (curl_errno($curl)) {
- $this->reqStatus = 0;
- $this->reqMsg = "请求失败,".curl_error($curl);
- }
- curl_close($curl);
- return json_decode($tmpInfo,true);
+ curl_setopt($curl, CURLOPT_URL, $this->apiUrl."jsonrpc");
+ curl_setopt($curl, CURLOPT_POST, 1);
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
+ curl_setopt($curl, CURLOPT_TIMEOUT, 15);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+ $tmpInfo = curl_exec($curl);
+ if (curl_errno($curl)) {
+ $this->reqStatus = 0;
+ $this->reqMsg = "请求失败,".curl_error($curl);
+ }
+ curl_close($curl);
+ return json_decode($tmpInfo,true);
}
}
From b8b63662eaa2bd8a33e691b16a6d3c3c5f753f05 Mon Sep 17 00:00:00 2001
From: HFO4 <912394456@qq.com>
Date: Mon, 9 Apr 2018 22:04:56 +0800
Subject: [PATCH 14/62] =?UTF-8?q?=E7=A6=BB=E7=BA=BF=E4=B8=8B=E8=BD=BD?=
=?UTF-8?q?=E6=B7=BB=E5=8A=A0URL=E4=BA=A4=E4=BA=92=E7=95=8C=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../index/controller/RemoteDownload.php | 3 +-
application/index/model/Aria2.php | 7 +++
application/index/view/home/home.html | 2 +
static/js/angular-filemanager.min.js | 49 +++++++++++++++++--
static/js/home.js | 3 ++
5 files changed, 59 insertions(+), 5 deletions(-)
diff --git a/application/index/controller/RemoteDownload.php b/application/index/controller/RemoteDownload.php
index 1259d512..98225cac 100644
--- a/application/index/controller/RemoteDownload.php
+++ b/application/index/controller/RemoteDownload.php
@@ -54,8 +54,9 @@ class RemoteDownload extends Controller{
$downloadStart = $aria2->addUrl(input("post.url"));
if($aria2->reqStatus){
$this->insertRecord($aria2,input("post.url"));
+ return json(["result"=>['success'=>true,'error'=>null]]);
}else{
- return json(['error'=>1,'message'=>$aria2->reqMsg]);
+ return json(["result"=>['success'=>false,'error'=>$aria2->reqMsg]]);
}
}
diff --git a/application/index/model/Aria2.php b/application/index/model/Aria2.php
index b6c44481..508bc919 100644
--- a/application/index/model/Aria2.php
+++ b/application/index/model/Aria2.php
@@ -129,6 +129,13 @@ class Aria2 extends Model{
# code...
break;
}
+ if(($respondData["result"]["files"][$downloadInfo["file_index"]]["completedLength"] == $respondData["result"]["files"][$downloadInfo["file_index"]]["length"]) && $respondData["result"]["status"]=="active"){
+ $this->setComplete($respondData["result"],$downloadInfo);
+ Db::name("download")->where("id",$id)
+ ->update([
+ "status" => "complete",
+ ]);
+ }
}else{
$this->reqStatus = 0;
$this->reqMsg = "空间容量不足";
diff --git a/application/index/view/home/home.html b/application/index/view/home/home.html
index 593b101f..76332275 100644
--- a/application/index/view/home/home.html
+++ b/application/index/view/home/home.html
@@ -28,6 +28,8 @@
allowSource : "{$policyData.origin_link}",
upUrl : "{$policyData.server}",
allowShare:"{$groupData.allow_share}",
+ allowRemoteDownload:"{:explode(",",$groupData.aria2)[0]}",
+ allowTorrentDownload:"{:explode(",",$groupData.aria2)[1]}",
};
diff --git a/static/js/angular-filemanager.min.js b/static/js/angular-filemanager.min.js
index 25542c33..bb1c720d 100644
--- a/static/js/angular-filemanager.min.js
+++ b/static/js/angular-filemanager.min.js
@@ -323,6 +323,17 @@ function(e, r) {
e.modal("move", !0)
})
},
+ e.startRemoteDownload = function(){
+ if(e.temp['url'] == ""){
+ return e.apiMiddleware.apiHandler.error = a.instant("下载URL不能为空");
+ }else{
+ e.apiMiddleware.apiHandler.error = !1;
+ return void e.apiMiddleware.startRemoteDownload(e.temp['url'],n.selectedModalPath).then(function() {
+ e.modal("remoteDownload", !0);
+ toastr["success"]("离线下载任务已创建");
+ })
+ }
+ }
e.rename = function() {
var r = e.singleSelection(),
n = r.tempModel.name,
@@ -456,6 +467,11 @@ function(e) {
i = "/" + n.join("/");
return e.singleSelection() && !e.singleSelection().isFolder() && (i += "/" + e.singleSelection().tempModel.name),
i.replace(/\/\//, "/")
+ },
+ r.getSelectedPathForDownload = function() {
+ var path = r.selectedModalPath.filter(Boolean);
+ var result = '/' + path.join('/');
+ return result.replace(/\/\//, '/');
}
}
])
@@ -739,7 +755,7 @@ function(e) {
e.module("FileManagerApp").provider("fileManagerConfig",
function() {
var r = {
- appName: "angular-filemanager v1.5",
+ appName: "Cloudreve FileManager",
defaultLang: "zh_cn",
listUrl: "/File/ListFile",
previewUrl:"/File/Preview",
@@ -757,6 +773,7 @@ function(e) {
extractUrl: "bridges/php/handler.php",
permissionsUrl: "bridges/php/handler.php",
sourceUrl:"/File/gerSource",
+ remoteDownloadUrl: "/RemoteDownload/addUrl",
basePath: "/",
searchForm: !0,
sidebar: !0,
@@ -778,7 +795,9 @@ function(e) {
remove: !0,
createFolder: !0,
pickFiles: !1,
- pickFolders: !1
+ pickFolders: !1,
+ allowRemoteDownload: !1,
+ allowTorrentDownload: !1,
},
multipleDownloadFileName: "angular-filemanager.zip",
filterFileExtensions: [],
@@ -994,6 +1013,25 @@ function(e, r) {
}),
s.promise
},
+ o.prototype.startRemoteDownload = function(api,url,path) {
+ var o = this,
+ s = n.defer(),
+ l = {
+ action: "remoteDownload",
+ path: path,
+ url:url
+ };
+ return o.inprocess = !0,
+ o.error = "",
+ e.post(api, l).success(function(e, r) {
+ o.deferredHandler(e, s, r)
+ }).error(function(e, r) {
+ o.deferredHandler(e, s, r, a.instant("error_moving"))
+ })["finally"](function() {
+ o.inprocess = !1
+ }),
+ s.promise
+ },
o.prototype.remove = function(r, i,dir) {
var t = this,
o = n.defer(),
@@ -1307,6 +1345,9 @@ function(e) {
var dirList = this.getFileList(dir);
return this.apiHandler.move(r.moveUrl,dirList ,i, this.getPath(n))
},
+ i.prototype.startRemoteDownload = function(url,path) {
+ return this.apiHandler.startRemoteDownload(r.remoteDownloadUrl,url ,this.getPath(path))
+ },
i.prototype.remove = function(e,dir) {
var n = this.getFileList(e);
var dirList = this.getFileList(dir);
@@ -1516,8 +1557,8 @@ angular.module("FileManagerApp").run(["$templateCache",
e.put("src/templates/main-table-modal.html", ''),
e.put("src/templates/main-table.html", '\r\n'),
e.put("src/templates/main.html", '\r\n
\r\n\r\n
\r\n\r\n
\r\n
\r\n
\r\n'),
- e.put("src/templates/modals.html", '\r\n
\r\n
\r\n \r\n
\r\n
\r\n
![{{singleSelection().model.name}}]()
\r\n
{{\'loading\' | translate}} ...\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n\r\n \r\n
\r\n
\r\n \r\n
\r\n
{{singleSelection() && singleSelection().model.name}} 的源文件地址: \r\n \r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n\r\n \r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
{{\'loading\' | translate}} ...\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n \r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
{{\'loading\' | translate}} ...\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n \r\n\r\n\r\n\r\n\r\n \r\n
\r\n
\r\n \r\n
\r\n
的分享地址: \r\n \r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n\r\n \r\n\r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n'),
- e.put("src/templates/navbar.html", '\r\n'),
+ e.put("src/templates/modals.html", '\r\n
\r\n
\r\n \r\n
\r\n
\r\n
![{{singleSelection().model.name}}]()
\r\n
{{\'loading\' | translate}} ...\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n\r\n \r\n
\r\n
\r\n \r\n
\r\n
{{singleSelection() && singleSelection().model.name}} 的源文件地址: \r\n \r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n\r\n \r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
{{\'loading\' | translate}} ...\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n \r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
{{\'loading\' | translate}} ...\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n\r\n\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n\r\n\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
的分享地址: \r\n \r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n\r\n \r\n\r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n\r\n\r\n\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n'),
+ e.put("src/templates/navbar.html", '