diff --git a/controller/ApiController.php b/controller/ApiController.php index 71d866c..16dcac2 100644 --- a/controller/ApiController.php +++ b/controller/ApiController.php @@ -23,12 +23,15 @@ Class ApiController extends Controller { $params = array( 'version' => $this->version, 'list' => array( - '列表' => '/api/ls/', + '验证码图片' => '/api/captcha/', + '登陆' => '/api/login/', + '目录/文件列表' => '/api/ls/', //文件操作 '重命名' => '/api/rename/', '删除文件' => '/api/delete/', - '移动' => '/api/move/', + '移动目录/文件' => '/api/move/', + 'base64文件上传' => '/api/uploadbase64/', //目录操作 '创建目录' => '/api/mkdir/', @@ -96,13 +99,12 @@ Class ApiController extends Controller { $cateId = $this->get('id', $menus[0]['id']); - $data['menus'] = $menus; - - //替换realpath,改为相对路径返回 - $basePath = realpath($target); - if (!preg_match('/\/$/', $basePath)) { - $basePath .= '/'; + if (empty($scanResults[$cateId])) { + $err = "目录ID {$cateId} 不存在!"; + return $this->renderJson(compact('code', 'msg', 'err', 'data'), $this->httpStatus['notFound']); } + + $data['menus'] = $menus; $data['dirTree'] = $scanResults[$cateId]; $code = 1; @@ -432,10 +434,10 @@ Class ApiController extends Controller { //get captcha code $userData = $this->getAdmUserData(); $captcha_code = !empty($userData['captcha_code']) ? $userData['captcha_code'] : ''; - if ($admConfig['captcha'] && empty($captcha_code)) { + if (!empty($admConfig['captcha']) && empty($captcha_code)) { $err = "请刷新网页,如果验证码图片无法显示请联系管理员!"; return $this->renderJson(compact('code', 'msg', 'err', 'data')); - }else if ($admConfig['captcha'] && !empty($captcha_code) && $captcha != $captcha_code) { + }else if (!empty($admConfig['captcha']) && !empty($captcha_code) && $captcha != $captcha_code) { $err = "验证码不正确,请注意字母大小写!"; return $this->renderJson(compact('code', 'msg', 'err', 'data')); }