diff --git a/application/config.php b/application/config.php index 30b42d7b..38405e4a 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 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){ 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 @@
-

+

+

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

+