commit
4877a8e292
3 changed files with 45 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -361,7 +361,9 @@
|
|||
<?php } else { ?>
|
||||
<div class="exception">
|
||||
|
||||
<div class="info"><h1><?php echo htmlentities($message); ?></h1></div>
|
||||
<div class="info"><h1><?php echo htmlentities($message); ?></h1>
|
||||
<p>我们都有不顺利的时候,请坐和放宽~</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
|
Loading…
Add table
Reference in a new issue