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 1/3] =?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 2/3] =?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 3/3] =?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 @@
-

+

+

我们都有不顺利的时候,请坐和放宽~

+