From f8f8af1f532518f625d3e6f463870ed7d52be512 Mon Sep 17 00:00:00 2001 From: Anyon Date: Thu, 7 Jun 2018 14:47:14 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]ComposerUpdate=E5=8F=8A?= =?UTF-8?q?=E6=A1=86=E6=9E=B6=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{tags.php => admin/middleware/Auth.php} | 57 ++++++++++++++----- application/middleware.php | 18 ++++++ application/store/controller/wechat/Demo.php | 1 + config/app.php | 57 +++++++++++++++---- config/cache.php | 29 ++++++---- config/console.php | 19 +++++++ config/cookie.php | 4 +- config/database.php | 9 +++ config/log.php | 16 +++++- config/template.php | 25 ++++---- config/trace.php | 1 + vendor/autoload.php | 2 +- vendor/composer/autoload_classmap.php | 1 + vendor/composer/autoload_real.php | 14 ++--- vendor/composer/autoload_static.php | 9 +-- vendor/composer/installed.json | 8 +-- vendor/zoujingli/weopen-developer/README.md | 5 +- 17 files changed, 202 insertions(+), 73 deletions(-) rename application/{tags.php => admin/middleware/Auth.php} (51%) create mode 100644 application/middleware.php create mode 100644 config/console.php diff --git a/application/tags.php b/application/admin/middleware/Auth.php similarity index 51% rename from application/tags.php rename to application/admin/middleware/Auth.php index 30c1a48cb..8dd0a3d1f 100644 --- a/application/tags.php +++ b/application/admin/middleware/Auth.php @@ -12,29 +12,60 @@ // | github开源项目:https://github.com/zoujingli/ThinkAdmin // +---------------------------------------------------------------------- -namespace think; +namespace app\admin\middleware; use service\NodeService; -use think\exception\HttpResponseException; +use think\Db; +use think\Request; -return [ - // 控制器开始前,进行权限检查 - 'action_begin' => function () { - $request = app('request'); +/** + * 系统权限访问管理 + * Class Auth + * @package app\admin\middleware + */ +class Auth +{ + /** + * @param Request $request + * @param \Closure $next + * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException + * @throws \think\exception\DbException + */ + public function handle($request, \Closure $next) + { list($module, $controller, $action) = [$request->module(), $request->controller(), $request->action()]; - $node = NodeService::parseNodeStr("{$module}/{$controller}/{$action}"); - $info = Db::name('SystemNode')->cache(true, 30)->where(['node' => $node])->find(); - $access = ['is_menu' => intval(!empty($info['is_menu'])), 'is_auth' => intval(!empty($info['is_auth'])), 'is_login' => empty($info['is_auth']) ? intval(!empty($info['is_login'])) : 1]; + $access = $this->buildAuth($node = NodeService::parseNodeStr("{$module}/{$controller}/{$action}")); // 登录状态检查 if (!empty($access['is_login']) && !session('user')) { $msg = ['code' => 0, 'msg' => '抱歉,您还没有登录获取访问权限!', 'url' => url('@admin/login')]; - throw new HttpResponseException($request->isAjax() ? json($msg) : redirect($msg['url'])); + return $request->isAjax() ? json($msg) : redirect($msg['url']); } // 访问权限检查 if (!empty($access['is_auth']) && !auth($node)) { - throw new HttpResponseException(json(['code' => 0, 'msg' => '抱歉,您没有访问该模块的权限!'])); + return json(['code' => 0, 'msg' => '抱歉,您没有访问该模块的权限!']); } // 模板常量声明 app('view')->init(config('template.'))->assign(['classuri' => NodeService::parseNodeStr("{$module}/{$controller}")]); - }, -]; + return $next($request); + } + + /** + * 根据节点获取对应权限配置 + * @param string $node 权限节点 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException + * @throws \think\exception\DbException + */ + private function buildAuth($node) + { + $info = Db::name('SystemNode')->cache(true, 30)->where(['node' => $node])->find(); + return [ + 'is_menu' => intval(!empty($info['is_menu'])), + 'is_auth' => intval(!empty($info['is_auth'])), + 'is_login' => empty($info['is_auth']) ? intval(!empty($info['is_login'])) : 1, + ]; + } +} diff --git a/application/middleware.php b/application/middleware.php new file mode 100644 index 000000000..1dabca938 --- /dev/null +++ b/application/middleware.php @@ -0,0 +1,18 @@ + '测试商品', diff --git a/config/app.php b/config/app.php index 31a6cd419..5a8700eef 100644 --- a/config/app.php +++ b/config/app.php @@ -12,13 +12,17 @@ // | github开源项目:https://github.com/zoujingli/ThinkAdmin // +---------------------------------------------------------------------- +use think\facade\Env; + return [ + // 应用名称 + 'app_name' => '', + // 应用地址 + 'app_host' => '', // 应用调试模式 'app_debug' => true, // 应用Trace 'app_trace' => false, - // 应用模式状态 - 'app_status' => '', // 是否支持多模块 'app_multi_module' => true, // 入口自动绑定模块 @@ -34,17 +38,22 @@ return [ // 默认JSONP处理方法 'var_jsonp_handler' => 'callback', // 默认时区 - 'default_timezone' => 'PRC', + 'default_timezone' => 'Asia/Shanghai', // 是否开启多语言 'lang_switch_on' => false, // 默认全局过滤方法 用逗号分隔多个 - 'default_filter' => 'trim', + 'default_filter' => '', // 默认语言 'default_lang' => 'zh-cn', // 应用类库后缀 'class_suffix' => false, // 控制器类后缀 'controller_suffix' => false, + + // +---------------------------------------------------------------------- + // | 模块设置 + // +---------------------------------------------------------------------- + // 默认模块名 'default_module' => 'index', // 禁止访问模块 @@ -55,32 +64,47 @@ return [ 'default_action' => 'index', // 默认验证器 'default_validate' => '', + // 默认的空模块名 + 'empty_module' => '', // 默认的空控制器名 'empty_controller' => 'Error', + // 操作方法前缀 + 'use_action_prefix' => false, // 操作方法后缀 'action_suffix' => '', // 自动搜索控制器 'controller_auto_search' => false, + + // +---------------------------------------------------------------------- + // | URL设置 + // +---------------------------------------------------------------------- + // PATHINFO变量名 用于兼容模式 'var_pathinfo' => 's', // 兼容PATH_INFO获取 'pathinfo_fetch' => ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL'], // pathinfo分隔符 'pathinfo_depr' => '/', + // HTTPS代理标识 + 'https_agent_name' => '', + // IP代理获取标识 + 'http_agent_ip' => 'X-REAL-IP', // URL伪静态后缀 'url_html_suffix' => 'html', // URL普通方式参数 用于自动生成 'url_common_param' => false, // URL参数方式 0 按名称成对解析 1 按顺序解析 'url_param_type' => 1, - // 路由使用完整匹配 - 'route_complete_match' => false, + // 是否开启路由延迟解析 + 'url_lazy_route' => false, // 是否强制使用路由 'url_route_must' => false, + // 合并路由规则 + 'route_rule_merge' => false, + // 路由是否完全匹配 + 'route_complete_match' => false, // 使用注解路由 'route_annotation' => false, - // 域名部署 - 'url_domain_deploy' => false, // 域名根,如thinkphp.cn 'url_domain_root' => '', // 是否自动转换URL中的控制器和操作名 @@ -97,11 +121,22 @@ return [ 'request_cache' => false, // 请求缓存有效期 'request_cache_expire' => null, + // 全局请求缓存排除规则 + 'request_cache_except' => [], + // 是否开启路由缓存 + 'route_check_cache' => false, + // 路由缓存的Key自定义设置(闭包),默认为当前URL和请求类型的md5 + 'route_check_cache_key' => '', + // 路由缓存类型及参数 + 'route_cache_option' => '', + // 默认跳转页面对应的模板文件 - 'dispatch_success_tmpl' => env('think_path') . 'tpl/dispatch_jump.tpl', - 'dispatch_error_tmpl' => env('think_path') . 'tpl/dispatch_jump.tpl', + 'dispatch_success_tmpl' => Env::get('think_path') . 'tpl/dispatch_jump.tpl', + 'dispatch_error_tmpl' => Env::get('think_path') . 'tpl/dispatch_jump.tpl', + // 异常页面的模板文件 - 'exception_tmpl' => env('think_path') . 'tpl/think_exception.tpl', + 'exception_tmpl' => Env::get('think_path') . 'tpl/think_exception.tpl', + // 错误显示信息,非调试模式有效 'error_message' => '页面错误!请稍后再试~', // 显示错误信息 diff --git a/config/cache.php b/config/cache.php index ca1d9e077..985dbb1c4 100644 --- a/config/cache.php +++ b/config/cache.php @@ -1,20 +1,25 @@ +// +---------------------------------------------------------------------- // +---------------------------------------------------------------------- -// | ThinkAdmin -// +---------------------------------------------------------------------- -// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ] -// +---------------------------------------------------------------------- -// | 官方网站: http://think.ctolog.com -// +---------------------------------------------------------------------- -// | 开源协议 ( https://mit-license.org ) -// +---------------------------------------------------------------------- -// | github开源项目:https://github.com/zoujingli/ThinkAdmin +// | 缓存设置 // +---------------------------------------------------------------------- return [ - 'expire' => 0, - 'prefix' => '', - 'path' => '', + // 驱动方式 'type' => 'File', + // 缓存保存目录 + 'path' => '', + // 缓存前缀 + 'prefix' => '', + // 缓存有效期 0表示永久缓存 + 'expire' => 0, ]; diff --git a/config/console.php b/config/console.php new file mode 100644 index 000000000..4bbb5c015 --- /dev/null +++ b/config/console.php @@ -0,0 +1,19 @@ + 'Think Console', + 'version' => '0.1', + 'user' => null, +]; diff --git a/config/cookie.php b/config/cookie.php index 12d5969b2..a41d42c6d 100644 --- a/config/cookie.php +++ b/config/cookie.php @@ -21,9 +21,9 @@ return [ 'path' => '/', // cookie 有效域名 'domain' => '', - // cookie 启用安全传输 + // cookie 启用安全传输 'secure' => false, - // httponly 设置 + // httponly设置 'httponly' => '', // 是否使用 setcookie 'setcookie' => true, diff --git a/config/database.php b/config/database.php index 99a0d78c9..7c20594fe 100644 --- a/config/database.php +++ b/config/database.php @@ -13,6 +13,7 @@ // +---------------------------------------------------------------------- return [ + // 数据库类型 'type' => 'mysql', // 服务器地址 'hostname' => '127.0.0.1', @@ -42,6 +43,8 @@ return [ 'master_num' => 1, // 指定从服务器序号 'slave_no' => '', + // 自动读取主库数据 + 'read_master' => false, // 是否严格检查字段是否存在 'fields_strict' => true, // 数据集返回类型 @@ -52,6 +55,12 @@ return [ 'datetime_format' => 'Y-m-d H:i:s', // 是否需要进行SQL性能分析 'sql_explain' => false, + // Builder类 + 'builder' => '', // Query类 'query' => '\\think\\db\\Query', + // 是否需要断线重连 + 'break_reconnect' => false, + // 断线标识字符串 + 'break_match_str' => [], ]; diff --git a/config/log.php b/config/log.php index a87698208..4aad205ea 100644 --- a/config/log.php +++ b/config/log.php @@ -13,8 +13,18 @@ // +---------------------------------------------------------------------- return [ - 'path' => '', + // 日志记录方式,内置 file socket 支持扩展 'type' => 'File', - 'file_size' => 1024 * 1024 * 10, + // 日志保存目录 + 'path' => '', + // 日志记录级别 + 'level' => [], + // 单文件日志写入 + 'single' => false, + // 独立日志级别 'apart_level' => ['emergency', 'alert', 'critical', 'error', 'sql'], -]; + // 最大日志文件数量 + 'max_files' => 0, + // 是否关闭日志写入 + 'close' => false, +]; \ No newline at end of file diff --git a/config/template.php b/config/template.php index 3c7c0cce8..31cc384df 100644 --- a/config/template.php +++ b/config/template.php @@ -18,26 +18,21 @@ $uriRoot = rtrim(preg_match('/\.php$/', $appRoot) ? dirname($appRoot) : $appRoot return [ // 模板引擎类型 支持 php think 支持扩展 - 'type' => 'Think', + 'type' => 'Think', + // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 3 保持操作方法 + 'auto_rule' => 1, // 模板路径 - 'view_path' => '', + 'view_path' => '', // 模板后缀 - 'view_suffix' => 'html', + 'view_suffix' => 'html', // 模板文件名分隔符 - 'view_depr' => DIRECTORY_SEPARATOR, + 'view_depr' => DIRECTORY_SEPARATOR, // 模板引擎普通标签开始标记 - 'tpl_begin' => '{', + 'tpl_begin' => '{', // 模板引擎普通标签结束标记 - 'tpl_end' => '}', + 'tpl_end' => '}', // 标签库标签开始标记 - 'taglib_begin' => '{', + 'taglib_begin' => '{', // 标签库标签结束标记 - 'taglib_end' => '}', - // 定义模板替换字符串 - 'tpl_replace_string' => [ - '__APP__' => $appRoot, - '__ROOT__' => $uriRoot, - '__STATIC__' => $uriRoot . "/static", - ], + 'taglib_end' => '}', ]; - diff --git a/config/trace.php b/config/trace.php index b1d2ade4d..49945a903 100644 --- a/config/trace.php +++ b/config/trace.php @@ -13,5 +13,6 @@ // +---------------------------------------------------------------------- return [ + // 内置Html Console 支持扩展 'type' => 'Html', ]; diff --git a/vendor/autoload.php b/vendor/autoload.php index df648040b..67f4a311f 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit3b653bd8f42dcddd1a5ffaa4b92dcf0f::getLoader(); +return ComposerAutoloaderInit6a1d9670263853112be0eb50705ac527::getLoader(); diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 6094efaa2..89ef9c340 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -175,6 +175,7 @@ return array( 'app\\admin\\controller\\Node' => $baseDir . '/application/admin/controller/Node.php', 'app\\admin\\controller\\Plugs' => $baseDir . '/application/admin/controller/Plugs.php', 'app\\admin\\controller\\User' => $baseDir . '/application/admin/controller/User.php', + 'app\\admin\\middleware\\Auth' => $baseDir . '/application/admin/middleware/Auth.php', 'app\\index\\controller\\Index' => $baseDir . '/application/index/controller/Index.php', 'app\\store\\controller\\Express' => $baseDir . '/application/store/controller/Express.php', 'app\\store\\controller\\Goods' => $baseDir . '/application/store/controller/Goods.php', diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 6de2029a7..83dd59e65 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit3b653bd8f42dcddd1a5ffaa4b92dcf0f +class ComposerAutoloaderInit6a1d9670263853112be0eb50705ac527 { private static $loader; @@ -19,15 +19,15 @@ class ComposerAutoloaderInit3b653bd8f42dcddd1a5ffaa4b92dcf0f return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit3b653bd8f42dcddd1a5ffaa4b92dcf0f', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit6a1d9670263853112be0eb50705ac527', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit3b653bd8f42dcddd1a5ffaa4b92dcf0f', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit6a1d9670263853112be0eb50705ac527', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit3b653bd8f42dcddd1a5ffaa4b92dcf0f::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit6a1d9670263853112be0eb50705ac527::getInitializer($loader)); } else { $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -48,19 +48,19 @@ class ComposerAutoloaderInit3b653bd8f42dcddd1a5ffaa4b92dcf0f $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit3b653bd8f42dcddd1a5ffaa4b92dcf0f::$files; + $includeFiles = Composer\Autoload\ComposerStaticInit6a1d9670263853112be0eb50705ac527::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire3b653bd8f42dcddd1a5ffaa4b92dcf0f($fileIdentifier, $file); + composerRequire6a1d9670263853112be0eb50705ac527($fileIdentifier, $file); } return $loader; } } -function composerRequire3b653bd8f42dcddd1a5ffaa4b92dcf0f($fileIdentifier, $file) +function composerRequire6a1d9670263853112be0eb50705ac527($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 23ffc756a..29f7c305a 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit3b653bd8f42dcddd1a5ffaa4b92dcf0f +class ComposerStaticInit6a1d9670263853112be0eb50705ac527 { public static $files = array ( '1cfd2761b63b0a29ed23657ea394cb2d' => __DIR__ . '/..' . '/topthink/think-captcha/src/helper.php', @@ -265,6 +265,7 @@ class ComposerStaticInit3b653bd8f42dcddd1a5ffaa4b92dcf0f 'app\\admin\\controller\\Node' => __DIR__ . '/../..' . '/application/admin/controller/Node.php', 'app\\admin\\controller\\Plugs' => __DIR__ . '/../..' . '/application/admin/controller/Plugs.php', 'app\\admin\\controller\\User' => __DIR__ . '/../..' . '/application/admin/controller/User.php', + 'app\\admin\\middleware\\Auth' => __DIR__ . '/../..' . '/application/admin/middleware/Auth.php', 'app\\index\\controller\\Index' => __DIR__ . '/../..' . '/application/index/controller/Index.php', 'app\\store\\controller\\Express' => __DIR__ . '/../..' . '/application/store/controller/Express.php', 'app\\store\\controller\\Goods' => __DIR__ . '/../..' . '/application/store/controller/Goods.php', @@ -302,9 +303,9 @@ class ComposerStaticInit3b653bd8f42dcddd1a5ffaa4b92dcf0f public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit3b653bd8f42dcddd1a5ffaa4b92dcf0f::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit3b653bd8f42dcddd1a5ffaa4b92dcf0f::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit3b653bd8f42dcddd1a5ffaa4b92dcf0f::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit6a1d9670263853112be0eb50705ac527::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit6a1d9670263853112be0eb50705ac527::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit6a1d9670263853112be0eb50705ac527::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 736ef4eae..f7a90c3b6 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -146,12 +146,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/WeOpenDeveloper.git", - "reference": "d5fb9d2b307251c7faedcb61758119bcb5b836d0" + "reference": "f0b34848d75147b16632bdec1583172936c2fff4" }, "dist": { "type": "zip", - "url": "https://files.phpcomposer.com/files/zoujingli/WeOpenDeveloper/d5fb9d2b307251c7faedcb61758119bcb5b836d0.zip", - "reference": "d5fb9d2b307251c7faedcb61758119bcb5b836d0", + "url": "https://files.phpcomposer.com/files/zoujingli/WeOpenDeveloper/f0b34848d75147b16632bdec1583172936c2fff4.zip", + "reference": "f0b34848d75147b16632bdec1583172936c2fff4", "shasum": "" }, "require": { @@ -160,7 +160,7 @@ "php": ">=5.4", "zoujingli/wechat-developer": "^1.0" }, - "time": "2018-05-23T07:29:30+00:00", + "time": "2018-06-04T09:19:16+00:00", "type": "library", "installation-source": "dist", "autoload": { diff --git a/vendor/zoujingli/weopen-developer/README.md b/vendor/zoujingli/weopen-developer/README.md index f46107bf9..d7e751614 100644 --- a/vendor/zoujingli/weopen-developer/README.md +++ b/vendor/zoujingli/weopen-developer/README.md @@ -1,4 +1,7 @@ -[![Latest Stable Version](https://poser.pugx.org/zoujingli/weopen-developer/v/stable)](https://packagist.org/packages/weopen-developer) [![Latest Unstable Version](https://poser.pugx.org/zoujingli/weopen-developer/v/unstable)](https://packagist.org/packages/zoujingli/weopen-developer) [![Total Downloads](https://poser.pugx.org/zoujingli/weopen-developer/downloads)](https://packagist.org/packages/weopen-developer) [![License](https://poser.pugx.org/zoujingli/weopen-developer/license)](https://packagist.org/packages/weopen-developer) +[![Latest Stable Version](https://poser.pugx.org/zoujingli/weopen-developer/v/stable)](https://packagist.org/packages/zoujingli/weopen-developer) +[![Latest Unstable Version](https://poser.pugx.org/zoujingli/weopen-developer/v/unstable)](https://packagist.org/packages/zoujingli/weopen-developer) +[![Total Downloads](https://poser.pugx.org/zoujingli/weopen-developer/downloads)](https://packagist.org/packages/zoujingli/weopen-developer) +[![License](https://poser.pugx.org/zoujingli/weopen-developer/license)](https://packagist.org/packages/zoujingli/weopen-developer) # WeOpenDeveloper WeOpenDeveloper 为微信开放平台服务开发工具,基于 WeChatDeveloper 可对公众号进行管理。