diff --git a/application/admin/service/NodeService.php b/application/admin/service/NodeService.php index d6a77e578..ea43eb3e8 100644 --- a/application/admin/service/NodeService.php +++ b/application/admin/service/NodeService.php @@ -152,7 +152,7 @@ class NodeService /** * 强制验证访问权限 - * --- 需要加载对应的控制器 + * --- 需要加载控制器解析注释 * @param null|string $node * @return boolean * @throws \ReflectionException @@ -166,11 +166,8 @@ class NodeService $reflection = new \ReflectionClass($class); if ($reflection->hasMethod($action)) { $comment = preg_replace("/\s/", '', $reflection->getMethod($action)->getDocComment()); - if (stripos($comment, '@authtrue') === false) { - return true; - } else { - return in_array($real, (array)session('admin_user.nodes')); - } + if (stripos($comment, '@authtrue') === false) return true; + return in_array($real, (array)session('admin_user.nodes')); } } return true; diff --git a/application/admin/sys.php b/application/admin/sys.php index 87eb61070..84a977c93 100644 --- a/application/admin/sys.php +++ b/application/admin/sys.php @@ -23,7 +23,7 @@ use think\Request; if (!function_exists('auth')) { /** * 节点访问权限检查 - * @param string $node + * @param string $node 需要检查的节点 * @return boolean * @throws ReflectionException */ @@ -70,11 +70,13 @@ if (!function_exists('local_image')) { /** * 下载远程文件到本地 * @param string $url 远程图片地址 + * @param boolean $force 是否强制重新下载 + * @param integer $expire 强制本地存储时间 * @return string */ - function local_image($url) + function local_image($url, $force = false, $expire = 0) { - $result = File::down($url); + $result = File::down($url, $force, $expire); if (isset($result['url'])) { return $result['url']; } else { @@ -86,16 +88,16 @@ if (!function_exists('local_image')) { if (!function_exists('base64_image')) { /** * base64 图片上传接口 - * @param string $content - * @param string $predir + * @param string $content 图片base64内容 + * @param string $dirname 图片存储目录 * @return string */ - function base64_image($content, $predir = 'base64/') + function base64_image($content, $dirname = 'base64/') { try { if (preg_match('|^data:image/(.*?);base64,|i', $content)) { list($ext, $base) = explode('|||', preg_replace('|^data:image/(.*?);base64,|i', '$1|||', $content)); - $info = File::save($predir . md5($base) . '.' . (empty($ext) ? 'tmp' : $ext), base64_decode($base)); + $info = File::save($dirname . md5($base) . '.' . (empty($ext) ? 'tmp' : $ext), base64_decode($base)); return $info['url']; } else { return $content; @@ -108,7 +110,6 @@ if (!function_exists('base64_image')) { // 访问权限检查中间键 Middleware::add(function (Request $request, \Closure $next) { - // 验证访问节点权限 if (NodeService::forceAuth()) { return $next($request); } elseif (NodeService::islogin()) {