├── .gitignore ├── .idea ├── inspectionProfiles │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── site-admin.iml └── workspace.xml ├── LICENSE.txt ├── README.md ├── addons ├── demo │ ├── Demo.php │ ├── config.php │ ├── controller │ │ └── Index.php │ ├── info.html │ └── view │ │ └── index │ │ └── exec.html ├── logs │ ├── Logs.php │ ├── controller │ │ ├── admin.php │ │ └── index.php │ └── widget.html ├── systeminfo │ ├── Systeminfo.php │ ├── config.php │ └── widget.html └── temp │ ├── Temp.php │ ├── config.php │ ├── controller │ └── Index.php │ ├── info.html │ └── view │ └── index │ └── exec.html ├── application ├── .htaccess ├── admin │ ├── controller │ │ ├── Addons.php │ │ ├── Base.php │ │ ├── Hooks.php │ │ ├── Index.php │ │ └── User.php │ └── view │ │ ├── addons │ │ ├── create.html │ │ └── index.html │ │ ├── hooks │ │ ├── add.html │ │ ├── edit.html │ │ └── index.html │ │ ├── index │ │ ├── index.html │ │ └── main.html │ │ └── layout │ │ └── base.html ├── command.php ├── common.php ├── common │ ├── behavior │ │ ├── App.php │ │ ├── Auth.php │ │ └── Init.php │ ├── model │ │ ├── Addons.php │ │ ├── Base.php │ │ ├── Config.php │ │ └── Hooks.php │ └── validate │ │ ├── Addons.php │ │ └── Hooks.php ├── http │ ├── exception │ │ └── Handle.php │ └── middleware │ │ └── Check.php └── tags.php ├── build.php ├── composer.json ├── composer.lock ├── config ├── app.php ├── cache.php ├── cookie.php ├── database.php ├── log.php ├── midleware.php ├── session.php ├── template.php └── trace.php ├── core ├── .gitignore ├── .htaccess ├── CONTRIBUTING.md ├── LICENSE.txt ├── README.md ├── base.php ├── composer.json ├── convention.php ├── helper.php ├── lang │ └── zh-cn.php ├── library │ ├── think │ │ ├── App.php │ │ ├── Build.php │ │ ├── Cache.php │ │ ├── Collection.php │ │ ├── Config.php │ │ ├── Console.php │ │ ├── Container.php │ │ ├── Controller.php │ │ ├── Cookie.php │ │ ├── Db.php │ │ ├── Debug.php │ │ ├── Env.php │ │ ├── Error.php │ │ ├── Exception.php │ │ ├── Facade.php │ │ ├── File.php │ │ ├── Hook.php │ │ ├── Lang.php │ │ ├── Loader.php │ │ ├── Log.php │ │ ├── Middleware.php │ │ ├── Model.php │ │ ├── Paginator.php │ │ ├── Process.php │ │ ├── Request.php │ │ ├── Response.php │ │ ├── Route.php │ │ ├── Session.php │ │ ├── Template.php │ │ ├── Url.php │ │ ├── Validate.php │ │ ├── View.php │ │ ├── cache │ │ │ ├── Driver.php │ │ │ └── driver │ │ │ │ ├── File.php │ │ │ │ ├── Lite.php │ │ │ │ ├── Memcache.php │ │ │ │ ├── Memcached.php │ │ │ │ ├── Redis.php │ │ │ │ ├── Sqlite.php │ │ │ │ ├── Wincache.php │ │ │ │ └── Xcache.php │ │ ├── config │ │ │ └── driver │ │ │ │ ├── Ini.php │ │ │ │ ├── Json.php │ │ │ │ └── Xml.php │ │ ├── console │ │ │ ├── Command.php │ │ │ ├── Input.php │ │ │ ├── LICENSE │ │ │ ├── Output.php │ │ │ ├── bin │ │ │ │ ├── README.md │ │ │ │ └── hiddeninput.exe │ │ │ ├── command │ │ │ │ ├── Build.php │ │ │ │ ├── Clear.php │ │ │ │ ├── Help.php │ │ │ │ ├── Lists.php │ │ │ │ ├── Make.php │ │ │ │ ├── RunServer.php │ │ │ │ ├── make │ │ │ │ │ ├── Controller.php │ │ │ │ │ ├── Middleware.php │ │ │ │ │ ├── Model.php │ │ │ │ │ └── stubs │ │ │ │ │ │ ├── controller.api.stub │ │ │ │ │ │ ├── controller.plain.stub │ │ │ │ │ │ ├── controller.stub │ │ │ │ │ │ ├── middleware.stub │ │ │ │ │ │ └── model.stub │ │ │ │ └── optimize │ │ │ │ │ ├── Autoload.php │ │ │ │ │ ├── Config.php │ │ │ │ │ ├── Route.php │ │ │ │ │ └── Schema.php │ │ │ ├── input │ │ │ │ ├── Argument.php │ │ │ │ ├── Definition.php │ │ │ │ └── Option.php │ │ │ └── output │ │ │ │ ├── Ask.php │ │ │ │ ├── Descriptor.php │ │ │ │ ├── Formatter.php │ │ │ │ ├── Question.php │ │ │ │ ├── descriptor │ │ │ │ └── Console.php │ │ │ │ ├── driver │ │ │ │ ├── Buffer.php │ │ │ │ ├── Console.php │ │ │ │ └── Nothing.php │ │ │ │ ├── formatter │ │ │ │ ├── Stack.php │ │ │ │ └── Style.php │ │ │ │ └── question │ │ │ │ ├── Choice.php │ │ │ │ └── Confirmation.php │ │ ├── db │ │ │ ├── Builder.php │ │ │ ├── Connection.php │ │ │ ├── Expression.php │ │ │ ├── Query.php │ │ │ ├── builder │ │ │ │ ├── Mysql.php │ │ │ │ ├── Pgsql.php │ │ │ │ ├── Sqlite.php │ │ │ │ └── Sqlsrv.php │ │ │ ├── connector │ │ │ │ ├── Mysql.php │ │ │ │ ├── Pgsql.php │ │ │ │ ├── Sqlite.php │ │ │ │ ├── Sqlsrv.php │ │ │ │ └── pgsql.sql │ │ │ └── exception │ │ │ │ ├── BindParamException.php │ │ │ │ ├── DataNotFoundException.php │ │ │ │ └── ModelNotFoundException.php │ │ ├── debug │ │ │ ├── Console.php │ │ │ └── Html.php │ │ ├── exception │ │ │ ├── ClassNotFoundException.php │ │ │ ├── DbException.php │ │ │ ├── ErrorException.php │ │ │ ├── Handle.php │ │ │ ├── HttpException.php │ │ │ ├── HttpResponseException.php │ │ │ ├── PDOException.php │ │ │ ├── RouteNotFoundException.php │ │ │ ├── TemplateNotFoundException.php │ │ │ ├── ThrowableError.php │ │ │ └── ValidateException.php │ │ ├── facade │ │ │ ├── App.php │ │ │ ├── Build.php │ │ │ ├── Cache.php │ │ │ ├── Config.php │ │ │ ├── Cookie.php │ │ │ ├── Debug.php │ │ │ ├── Env.php │ │ │ ├── Hook.php │ │ │ ├── Lang.php │ │ │ ├── Log.php │ │ │ ├── Middleware.php │ │ │ ├── Request.php │ │ │ ├── Response.php │ │ │ ├── Route.php │ │ │ ├── Session.php │ │ │ ├── Url.php │ │ │ ├── Validate.php │ │ │ └── View.php │ │ ├── log │ │ │ └── driver │ │ │ │ ├── File.php │ │ │ │ ├── Socket.php │ │ │ │ └── Test.php │ │ ├── model │ │ │ ├── Collection.php │ │ │ ├── Pivot.php │ │ │ ├── Relation.php │ │ │ ├── concern │ │ │ │ ├── Attribute.php │ │ │ │ ├── Conversion.php │ │ │ │ ├── ModelEvent.php │ │ │ │ ├── RelationShip.php │ │ │ │ ├── SoftDelete.php │ │ │ │ └── TimeStamp.php │ │ │ └── relation │ │ │ │ ├── BelongsTo.php │ │ │ │ ├── BelongsToMany.php │ │ │ │ ├── HasMany.php │ │ │ │ ├── HasManyThrough.php │ │ │ │ ├── HasOne.php │ │ │ │ ├── MorphMany.php │ │ │ │ ├── MorphOne.php │ │ │ │ ├── MorphTo.php │ │ │ │ └── OneToOne.php │ │ ├── paginator │ │ │ ├── Collection.php │ │ │ └── driver │ │ │ │ └── Bootstrap.php │ │ ├── process │ │ │ ├── Builder.php │ │ │ ├── Utils.php │ │ │ ├── exception │ │ │ │ ├── Faild.php │ │ │ │ ├── Failed.php │ │ │ │ └── Timeout.php │ │ │ └── pipes │ │ │ │ ├── Pipes.php │ │ │ │ ├── Unix.php │ │ │ │ └── Windows.php │ │ ├── response │ │ │ ├── Json.php │ │ │ ├── Jsonp.php │ │ │ ├── Jump.php │ │ │ ├── Redirect.php │ │ │ ├── View.php │ │ │ └── Xml.php │ │ ├── route │ │ │ ├── AliasRule.php │ │ │ ├── Dispatch.php │ │ │ ├── Domain.php │ │ │ ├── Resource.php │ │ │ ├── Rule.php │ │ │ ├── RuleGroup.php │ │ │ ├── RuleItem.php │ │ │ ├── RuleName.php │ │ │ └── dispatch │ │ │ │ ├── Callback.php │ │ │ │ ├── Controller.php │ │ │ │ ├── Module.php │ │ │ │ ├── Redirect.php │ │ │ │ ├── Response.php │ │ │ │ ├── Url.php │ │ │ │ └── View.php │ │ ├── session │ │ │ └── driver │ │ │ │ ├── Memcache.php │ │ │ │ ├── Memcached.php │ │ │ │ └── Redis.php │ │ ├── template │ │ │ ├── TagLib.php │ │ │ ├── driver │ │ │ │ └── File.php │ │ │ └── taglib │ │ │ │ └── Cx.php │ │ ├── validate │ │ │ └── ValidateRule.php │ │ └── view │ │ │ └── driver │ │ │ ├── Php.php │ │ │ └── Think.php │ └── traits │ │ └── controller │ │ └── Jump.php ├── logo.png ├── phpunit.xml.dist └── tpl │ ├── default_index.tpl │ ├── dispatch_jump.tpl │ ├── page_trace.tpl │ └── think_exception.tpl ├── extend └── .gitignore ├── public ├── .htaccess ├── favicon.ico ├── index.php ├── robots.txt ├── router.php └── static │ └── .gitignore ├── route ├── admin.php └── route.php ├── runtime └── .gitignore ├── think └── vendor └── .gitignore /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/site-admin.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | Data flow issuesJavaScript 14 | 15 | 16 | Error handlingJavaScript 17 | 18 | 19 | JavaScript 20 | 21 | 22 | JavaScript validity issuesJavaScript 23 | 24 | 25 | SQL 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 39 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 3 | 版权所有Copyright © 2006-2016 by ThinkPHP (http://thinkphp.cn) 4 | All rights reserved。 5 | ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 6 | 7 | Apache Licence是著名的非盈利开源组织Apache采用的协议。 8 | 该协议和BSD类似,鼓励代码共享和尊重原作者的著作权, 9 | 允许代码修改,再作为开源或商业软件发布。需要满足 10 | 的条件: 11 | 1. 需要给代码的用户一份Apache Licence ; 12 | 2. 如果你修改了代码,需要在被修改的文件中说明; 13 | 3. 在延伸的代码中(修改和有源代码衍生的代码中)需要 14 | 带有原来代码中的协议,商标,专利声明和其他原来作者规 15 | 定需要包含的说明; 16 | 4. 如果再发布的产品中包含一个Notice文件,则在Notice文 17 | 件中需要带有本协议内容。你可以在Notice中增加自己的 18 | 许可,但不可以表现为对Apache Licence构成更改。 19 | 具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | POSSIBILITY OF SUCH DAMAGE. 33 | -------------------------------------------------------------------------------- /addons/demo/Demo.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | namespace addons\demo; 12 | 13 | use think\Addons; 14 | 15 | /** 16 | * 插件测试 17 | * @author byron sampson 18 | */ 19 | class Demo extends Addons 20 | { 21 | public $info = [ 22 | 'name' => 'demo', 23 | 'title' => '演示插件', 24 | 'description' => 'thinkph5.1 演示插件', 25 | 'status' => 0, 26 | 'author' => 'byron sampson', 27 | 'version' => '0.1' 28 | ]; 29 | 30 | /** 31 | * 插件安装方法 32 | * @return bool 33 | */ 34 | public function install() 35 | { 36 | return true; 37 | } 38 | 39 | /** 40 | * 插件卸载方法 41 | * @return bool 42 | */ 43 | public function uninstall() 44 | { 45 | return true; 46 | } 47 | 48 | /** 49 | * 实现的 pageHeader 钩子方法 50 | * @return mixed 51 | */ 52 | public function pageHeader($param) 53 | { 54 | echo '

开始处理钩子啦

'; 55 | echo '

打印传给钩子的参数:

'; 56 | dump($param); 57 | echo '

打印插件配置:

'; 58 | dump($this->getConfig()); 59 | 60 | // 这里可以通过钩子来调用钩子模板 61 | return $this->fetch('info'); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /addons/demo/config.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | return [ 12 | 'display' => [ 13 | 'title' => '是否显示:', 14 | 'type' => 'radio', 15 | 'options' => [ 16 | '1' => '显示', 17 | '0' => '不显示' 18 | ], 19 | 'value' => '1' 20 | ] 21 | ]; 22 | -------------------------------------------------------------------------------- /addons/demo/controller/Index.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace addons\demo\controller; 13 | 14 | use think\addons\Controller; 15 | 16 | class Index extends Controller 17 | { 18 | public function exec() 19 | { 20 | echo '

我是temp插件中Index控制器的exec方法

'; 21 | return $this->fetch(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /addons/demo/info.html: -------------------------------------------------------------------------------- 1 |

我是钩子模板

2 |

我是在钩子中生成的url

3 |

{:addon_url('temp://index/exec', [], true, true)}

4 |

钩子处理结束啦

5 | -------------------------------------------------------------------------------- /addons/demo/view/index/exec.html: -------------------------------------------------------------------------------- 1 |

我是temp插件的exec模板

2 | -------------------------------------------------------------------------------- /addons/logs/Logs.php: -------------------------------------------------------------------------------- 1 | 'logs', 15 | 'title' => '历史日志', 16 | 'description' => '', 17 | 'status' => 1, 18 | 'author' => 'zz-admin', 19 | 'version' => '0.1' 20 | ); 21 | 22 | public function install() 23 | { 24 | return true; 25 | } 26 | 27 | public function uninstall() 28 | { 29 | return true; 30 | } 31 | 32 | // 实现的 adminIndex 钩子方法 33 | public function adminIndex($param) 34 | { 35 | $this->assign('addons_info', $this->info); 36 | return $this->fetch('widget'); 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /addons/logs/controller/admin.php: -------------------------------------------------------------------------------- 1 | namespace addons\demo\controller; 2 | 3 | use think\addons\Controller; 4 | 5 | class Admin extends Controller 6 | { 7 | // 索引入口 8 | public function index() 9 | { 10 | return 'hello addons admin'; 11 | } 12 | } -------------------------------------------------------------------------------- /addons/logs/controller/index.php: -------------------------------------------------------------------------------- 1 | namespace addons\demo\controller; 2 | 3 | use think\addons\Controller; 4 | 5 | class Index extends Controller 6 | { 7 | // 索引入口 8 | public function index() 9 | { 10 | return 'hello addons index'; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /addons/logs/widget.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |
6 | {$addons_info.title|default=lang('logs')} 7 |
8 |
    9 |
  • 10 | 11 |
    12 |

    4月23日

    13 |

    14 | Zz Admin 后台管理系统项目正式启动。 15 |
    管理后台由 layui 前端框架,layuiCMS后台皮肤为基础做的二次开发。 16 |
    现在已经完成了 think-addons 的后台管理功能,包括钩子管理、插件管理。后续还会加入 think-auth 模块,以及权限分组分角色的管理界面,敬请期待~ 17 |

    18 |
    19 |
  • 20 |
21 |
22 |
23 |
24 |
-------------------------------------------------------------------------------- /addons/systeminfo/Systeminfo.php: -------------------------------------------------------------------------------- 1 | - < | WECHAT: wx5ini99 11 | * / \ | DATETIME: 2018/4/19 12 | * // \\ | 13 | * //| . |\\ | 14 | * "'\ /'"_.-~^`'-. | 15 | * \ _ /--' ` | 16 | * ___)( )(___ |----------------------------------------- 17 | * (((__) (__))) | 高山仰止,景行行止.虽不能至,心向往之。 18 | * +---------------------------------------------------------------------- 19 | * | Copyright (c) 2017 http://www.zzstudio.net All rights reserved. 20 | * +---------------------------------------------------------------------- 21 | */ 22 | namespace addons\systeminfo; 23 | 24 | use think\Db; 25 | use think\Addons; 26 | 27 | /** 28 | * 系统环境信息插件 29 | * @author byron sampson 30 | */ 31 | class Systeminfo extends Addons 32 | { 33 | public $info = [ 34 | 'name' => 'systeminfo', 35 | 'title' => '系统环境信息', 36 | 'description' => '用于显示一些服务器的信息', 37 | 'status' => 0, 38 | 'author' => 'byron sampson', 39 | 'version' => '0.1' 40 | ]; 41 | 42 | /** 43 | * 插件安装方法 44 | * @return bool 45 | */ 46 | public function install() 47 | { 48 | return true; 49 | } 50 | 51 | /** 52 | * 插件卸载方法 53 | * @return bool 54 | */ 55 | public function uninstall() 56 | { 57 | return true; 58 | } 59 | 60 | /** 61 | * 实现的 adminIndex 钩子方法 62 | * @param $param 63 | * @return mixed 64 | * @throws \Exception 65 | */ 66 | public function adminIndex($param) 67 | { 68 | $config = $this->getConfig(); 69 | $this->assign('addons_config', $config); 70 | $this->assign('system_info_mysql', Db::query("select version() as v;")); 71 | if ($config['display']) { 72 | return $this->fetch('widget'); 73 | } 74 | } 75 | 76 | } -------------------------------------------------------------------------------- /addons/systeminfo/config.php: -------------------------------------------------------------------------------- 1 | 8 | // +---------------------------------------------------------------------- 9 | 10 | return [ 11 | 'title' => [//配置在表单中的键名 ,这个会是config[title] 12 | 'title' => '显示标题:',//表单的文字 13 | 'type' => 'text', //表单的类型:text、textarea、checkbox、radio、select等 14 | 'value' => '系统信息', //表单的默认值 15 | ], 16 | 'display' => [ 17 | 'title' => '是否显示:', 18 | 'type' => 'radio', 19 | 'options' => [ 20 | '1' => '显示', 21 | '0' => '不显示' 22 | ], 23 | 'value' => '1' 24 | ] 25 | ]; 26 | -------------------------------------------------------------------------------- /addons/systeminfo/widget.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | {$addons_config.title|default=lang('system info')} 5 |
6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
系统版本{$Think.SYS_VERSION}
操作系统{$Think.const.PHP_OS}
ThinkPHP{$Think.VERSION}
运行环境{$_SERVER['SERVER_SOFTWARE']}
MySQL{$system_info_mysql.0.v}
上传限制{:ini_get('upload_max_filesize')}
34 |
35 |
36 |
37 |
-------------------------------------------------------------------------------- /addons/temp/Temp.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | namespace addons\temp; 12 | 13 | use think\Addons; 14 | 15 | /** 16 | * 插件测试 17 | * @author byron sampson 18 | */ 19 | class Temp extends Addons 20 | { 21 | public $info = [ 22 | 'name' => 'temp', 23 | 'title' => '插件测试', 24 | 'description' => 'thinkph5插件测试', 25 | 'status' => 0, 26 | 'author' => 'byron sampson', 27 | 'version' => '0.1' 28 | ]; 29 | 30 | /** 31 | * 插件安装方法 32 | * @return bool 33 | */ 34 | public function install() 35 | { 36 | return true; 37 | } 38 | 39 | /** 40 | * 插件卸载方法 41 | * @return bool 42 | */ 43 | public function uninstall() 44 | { 45 | return true; 46 | } 47 | 48 | /** 49 | * 实现的testHook钩子方法 50 | * @return mixed 51 | */ 52 | public function pageFooter($param) 53 | { 54 | echo '

开始处理钩子啦

'; 55 | echo '

打印传给钩子的参数:

'; 56 | dump($param); 57 | echo '

打印插件配置:

'; 58 | dump($this->getConfig()); 59 | 60 | // 这里可以通过钩子来调用钩子模板 61 | return $this->fetch('info'); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /addons/temp/config.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | return [ 12 | 'display' => [ 13 | 'title' => '是否显示:', 14 | 'type' => 'radio', 15 | 'options' => [ 16 | '1' => '显示', 17 | '0' => '不显示' 18 | ], 19 | 'value' => '1' 20 | ] 21 | ]; 22 | -------------------------------------------------------------------------------- /addons/temp/controller/Index.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace addons\temp\controller; 13 | 14 | use think\addons\Controller; 15 | 16 | class Index extends Controller 17 | { 18 | public function exec() 19 | { 20 | echo '

我是temp插件中Index控制器的exec方法

'; 21 | return $this->fetch(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /addons/temp/info.html: -------------------------------------------------------------------------------- 1 |

我是钩子模板

2 |

我是在钩子中生成的url

3 |

{:addon_url('temp://index/exec', [], true, true)}

4 |

钩子处理结束啦

5 | -------------------------------------------------------------------------------- /addons/temp/view/index/exec.html: -------------------------------------------------------------------------------- 1 |

我是temp插件的exec模板

2 | -------------------------------------------------------------------------------- /application/.htaccess: -------------------------------------------------------------------------------- 1 | deny from all -------------------------------------------------------------------------------- /application/admin/controller/Base.php: -------------------------------------------------------------------------------- 1 | - < | WECHAT: wx5ini99 11 | * / \ | DATETIME: 2018/4/19 12 | * // \\ | 13 | * //| . |\\ | 14 | * "'\ /'"_.-~^`'-. | 15 | * \ _ /--' ` | 16 | * ___)( )(___ |----------------------------------------- 17 | * (((__) (__))) | 高山仰止,景行行止.虽不能至,心向往之。 18 | * +---------------------------------------------------------------------- 19 | * | Copyright (c) 2017 http://www.zzstudio.net All rights reserved. 20 | * +---------------------------------------------------------------------- 21 | */ 22 | 23 | namespace app\admin\controller; 24 | 25 | use think\Controller; 26 | 27 | class Base extends Controller 28 | { 29 | // 分页变量 30 | protected $page = 0; 31 | protected $limit = 10; 32 | 33 | /** 34 | * 构造方法 35 | * @access public 36 | */ 37 | public function __construct() 38 | { 39 | parent::__construct(); 40 | $this->page = input('page', 0); 41 | $this->limit = input('limit', 10); 42 | } 43 | 44 | /** 45 | * 返回 table 所需格式 46 | * @param array $list 47 | * @return mixed 48 | */ 49 | protected function toTable($list = []) 50 | { 51 | if (is_object($list)) { 52 | $list = $list->toArray(); 53 | } 54 | 55 | $data = [ 56 | 'code' => 0, 57 | 'msg' => 'ok', 58 | 'count' => isset($list['total']) ? $list['total'] : count($list) 59 | ]; 60 | 61 | return json(array_merge($data, $list)); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /application/admin/controller/Index.php: -------------------------------------------------------------------------------- 1 | - < | WECHAT: wx5ini99 11 | * / \ | DATETIME: 2018/4/19 12 | * // \\ | 13 | * //| . |\\ | 14 | * "'\ /'"_.-~^`'-. | 15 | * \ _ /--' ` | 16 | * ___)( )(___ |----------------------------------------- 17 | * (((__) (__))) | 高山仰止,景行行止.虽不能至,心向往之。 18 | * +---------------------------------------------------------------------- 19 | * | Copyright (c) 2017 http://www.zzstudio.net All rights reserved. 20 | * +---------------------------------------------------------------------- 21 | */ 22 | 23 | namespace app\admin\controller; 24 | 25 | class Index extends Base 26 | { 27 | /** 28 | * 后台索引 29 | * @return mixed 30 | */ 31 | public function index() 32 | { 33 | return $this->fetch(); 34 | } 35 | 36 | public function main() 37 | { 38 | return $this->fetch(); 39 | } 40 | 41 | /** 42 | * 系统菜单 43 | * @return string|\think\response\Json 44 | */ 45 | public function navs() 46 | { 47 | $navs = [ 48 | [ 49 | "title" => "系统扩展", 50 | "icon" => "fa-cubes", 51 | "href" => url('extend/index'), 52 | "spread" => true, 53 | "children" => [ 54 | [ 55 | "title" => "插件管理", 56 | "icon" => "fa-plug", 57 | "href" => url('addons/index'), 58 | "spread" => false 59 | ], 60 | [ 61 | "title" => "钩子管理", 62 | "icon" => "fa-anchor", 63 | "href" => url('hooks/index'), 64 | "spread" => false 65 | ] 66 | ] 67 | ] 68 | ]; 69 | return json($navs); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /application/admin/controller/User.php: -------------------------------------------------------------------------------- 1 | - < | WECHAT: wx5ini99 11 | * / \ | DATETIME: 2018/4/19 12 | * // \\ | 13 | * //| . |\\ | 14 | * "'\ /'"_.-~^`'-. | 15 | * \ _ /--' ` | 16 | * ___)( )(___ |----------------------------------------- 17 | * (((__) (__))) | 高山仰止,景行行止.虽不能至,心向往之。 18 | * +---------------------------------------------------------------------- 19 | * | Copyright (c) 2017 http://www.zzstudio.net All rights reserved. 20 | * +---------------------------------------------------------------------- 21 | */ 22 | namespace app\admin\controller; 23 | 24 | class User extends Base 25 | { 26 | /** 27 | * 用户登录 28 | * @return mixed 29 | */ 30 | public function login() 31 | { 32 | return $this->fetch(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /application/admin/view/hooks/add.html: -------------------------------------------------------------------------------- 1 | {extend name="layout/base"} 2 | 3 | {block name="style"} 4 | 5 | {/block} 6 | 7 | {block name="body"} 8 |
9 |
10 | 新建钩子 11 |
12 |
13 |
14 | 15 |
16 | 17 |
可用于 hook('钩子名称') 来执行钩子业务,插件会根据此名称生成钩子方法。
18 |
19 |
20 |
21 | 22 |
23 | 24 |
钩子的描述信息
25 |
26 |
27 |
28 |
29 | 30 | 31 |
32 |
33 |
34 |
35 | {/block} 36 | 37 | {block name="script"} 38 | 39 | {/block} -------------------------------------------------------------------------------- /application/admin/view/hooks/edit.html: -------------------------------------------------------------------------------- 1 | {extend name="layout/base"} 2 | 3 | {block name="style"} 4 | 5 | {/block} 6 | 7 | {block name="body"} 8 |
9 |
10 | 编辑钩子 11 |
12 |
13 |
14 | 15 |
16 | 17 |
可用于 hook('钩子名称') 来执行钩子业务,插件会根据此名称生成钩子方法。
18 |
19 |
20 |
21 | 22 |
23 | 24 |
钩子的描述信息
25 |
26 |
27 |
28 |
29 | 30 | 31 | 32 |
33 |
34 |
35 |
36 | {/block} 37 | 38 | {block name="script"} 39 | 40 | {/block} -------------------------------------------------------------------------------- /application/admin/view/hooks/index.html: -------------------------------------------------------------------------------- 1 | {extend name="layout/base"} 2 | 3 | {block name="style"} 4 | 5 | {/block} 6 | 7 | {block name="body"} 8 |
9 |
10 |
11 |
12 |
13 | 14 |
15 | 16 |
17 |
18 |
19 | 新建 20 |
21 |
22 | 23 |
24 |
25 |
26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |
ID名称描述操作
37 |
38 |
39 | {/block} 40 | 41 | {block name="script"} 42 | 48 | 49 | {/block} -------------------------------------------------------------------------------- /application/admin/view/index/main.html: -------------------------------------------------------------------------------- 1 | {extend name="layout/base"} 2 | 3 | {block name="style"} 4 | 5 | {/block} 6 | 7 | {block name="body"} 8 |
9 |
10 |

本平台基于 ThinkPHP {$Think.version}、layui 2.2.6 开发,支持除 layim 外所有的 Layui 组件。

11 |

12 | 项目地址:GitHub 下载 13 | [注:本框架仅作为学习交流使用,切勿用于商业用途] 14 |

15 |

技术交流QQ群:Web开发兴趣小组(加群时请注明来自本框架)

16 |
17 |
18 | {:hook('adminIndex')} 19 |
20 |
21 | {/block} -------------------------------------------------------------------------------- /application/admin/view/layout/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | zz admin 后台管理 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | {block name="style"}{/block} 19 | 20 | 21 | 40 | 41 | 42 | 43 | 44 |
45 | {block name="header"}{/block} 46 | {block name="side"}{/block} 47 | {block name="body"}{/block} 48 | {block name="footer"}{/block} 49 |
50 | 51 | {block name="script"}{/block} 52 | -------------------------------------------------------------------------------- /application/command.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | return []; 13 | -------------------------------------------------------------------------------- /application/common/behavior/App.php: -------------------------------------------------------------------------------- 1 | - < | WECHAT: wx5ini99 11 | * / \ | DATETIME: 2018/4/19 12 | * // \\ | 13 | * //| . |\\ | 14 | * "'\ /'"_.-~^`'-. | 15 | * \ _ /--' ` | 16 | * ___)( )(___ |----------------------------------------- 17 | * (((__) (__))) | 高山仰止,景行行止.虽不能至,心向往之。 18 | * +---------------------------------------------------------------------- 19 | * | Copyright (c) 2017 http://www.zzstudio.net All rights reserved. 20 | * +---------------------------------------------------------------------- 21 | */ 22 | namespace app\common\behavior; 23 | 24 | use think\facade\Config; 25 | use think\facade\Cache; 26 | use think\facade\Env; 27 | use app\common\model\Config AS Setting; 28 | 29 | class App 30 | { 31 | /** 32 | * 行为初始化 33 | * @param $params 34 | */ 35 | public function run($params) 36 | { 37 | // 当前版本 38 | define('SYS_VERSION', '1.0.0 beta'); 39 | 40 | // 读取数据库中的配置 41 | $config = Env::get('app_debug') ? [] : Cache::pull('DB_CONFIG_DATA'); 42 | // 如果未发现配置缓存则从数据库获取 43 | if (empty($config)) { 44 | $Setting = new Setting; 45 | $config = $Setting->lists(); 46 | Cache::set('DB_CONFIG_DATA', $config); 47 | } 48 | 49 | // 系统创始人user_id 50 | $config['founder'] = 1; 51 | 52 | Config::set($config, 'cfg'); //添加配置 53 | } 54 | } -------------------------------------------------------------------------------- /application/common/behavior/Auth.php: -------------------------------------------------------------------------------- 1 | - < | WECHAT: wx5ini99 11 | * / \ | DATETIME: 2018/4/19 12 | * // \\ | 13 | * //| . |\\ | 14 | * "'\ /'"_.-~^`'-. | 15 | * \ _ /--' ` | 16 | * ___)( )(___ |----------------------------------------- 17 | * (((__) (__))) | 高山仰止,景行行止.虽不能至,心向往之。 18 | * +---------------------------------------------------------------------- 19 | * | Copyright (c) 2017 http://www.zzstudio.net All rights reserved. 20 | * +---------------------------------------------------------------------- 21 | */ 22 | namespace app\common\behavior; 23 | 24 | use think\exception\HttpResponseException; 25 | 26 | class Auth 27 | { 28 | public function run() 29 | { 30 | $module = request()->module(); 31 | $controller = request()->controller(); 32 | $action = request()->action(); 33 | 34 | $allow = ['user/index/login']; 35 | 36 | if(!is_login() && !in_array_case("{$module}/{$controller}/{$action}", $allow)) { 37 | $response = redirect(url('/user/login')); 38 | throw new HttpResponseException($response); 39 | } 40 | 41 | } 42 | } -------------------------------------------------------------------------------- /application/common/behavior/Init.php: -------------------------------------------------------------------------------- 1 | - < | WECHAT: wx5ini99 11 | * / \ | DATETIME: 2018/4/19 12 | * // \\ | 13 | * //| . |\\ | 14 | * "'\ /'"_.-~^`'-. | 15 | * \ _ /--' ` | 16 | * ___)( )(___ |----------------------------------------- 17 | * (((__) (__))) | 高山仰止,景行行止.虽不能至,心向往之。 18 | * +---------------------------------------------------------------------- 19 | * | Copyright (c) 2017 http://www.zzstudio.net All rights reserved. 20 | * +---------------------------------------------------------------------- 21 | */ 22 | namespace app\common\behavior; 23 | 24 | use think\facade\Config; 25 | use think\facade\Env; 26 | 27 | class Init 28 | { 29 | /** 30 | * 应用初始化行为 31 | */ 32 | public function run() 33 | { 34 | $request = request(); 35 | $module = $request->module(); 36 | $controller = $request->controller(); 37 | $action = $request->action(); 38 | $root = $request->root(); 39 | 40 | // 如果api模块则跳出自定义行为 41 | if (strtolower($module) == 'api') { 42 | return; 43 | } 44 | 45 | // debug时关闭模板编译缓存 46 | if (Env::get('app_debug')) { 47 | Config::set('template.tpl_cache', false); 48 | } 49 | 50 | // 模板相关配置 51 | $template['tpl_replace_string'] = [ 52 | '__URL__' => $request->url(), 53 | '__ROOT__' => $root . "/", 54 | '__STATIC__' => $root . "/static", //"http://static.xxx.com", 55 | '__IMG__' => $root . "/static/${module}/images", 56 | '__CSS__' => $root . "/static/${module}/css", 57 | '__JS__' => $root . "/static/${module}/js", 58 | ]; 59 | Config::set($template, 'template'); 60 | } 61 | } -------------------------------------------------------------------------------- /application/common/model/Base.php: -------------------------------------------------------------------------------- 1 | - < | WECHAT: wx5ini99 11 | * / \ | DATETIME: 2018/4/19 12 | * // \\ | 13 | * //| . |\\ | 14 | * "'\ /'"_.-~^`'-. | 15 | * \ _ /--' ` | 16 | * ___)( )(___ |----------------------------------------- 17 | * (((__) (__))) | 高山仰止,景行行止.虽不能至,心向往之。 18 | * +---------------------------------------------------------------------- 19 | * | Copyright (c) 2017 http://www.zzstudio.net All rights reserved. 20 | * +---------------------------------------------------------------------- 21 | */ 22 | namespace app\common\model; 23 | 24 | class Base extends \think\Model 25 | { 26 | // 开启自动写入时间戳字段 27 | protected $autoWriteTimestamp = true; 28 | 29 | /** 30 | * list_order设置器 31 | * @param int $val 32 | * @return int|mixed 33 | */ 34 | protected function setListOrderAttr($val = 0) 35 | { 36 | if (!$val) { 37 | $val = $this->max($this->getPk()) + 1; 38 | } 39 | return $val; 40 | } 41 | 42 | /** 43 | * 排序列表 44 | * @param array $list 45 | * @param string $pk 主键 46 | * @param string $sort 排序字段 47 | * @return array|false|\think\Collection 48 | * @throws \Exception 49 | */ 50 | public function listSort($list = [], $pk = 'id', $sort = 'list_order') 51 | { 52 | $pk = empty($pk) ? $this->getPk() : $pk; 53 | 54 | $dataSet = []; 55 | foreach ($list as $id => $order) { 56 | $dataSet[] = [$pk => $id, $sort => $order]; 57 | } 58 | 59 | return $this->saveAll($dataSet); 60 | } 61 | 62 | /** 63 | * 快速排序 64 | * @param int $id 65 | * @param string $exp 66 | * @return bool 67 | * @throws \Exception 68 | */ 69 | public function sort($id = 0, $exp = '=') 70 | { 71 | if ($exp == '>=') { 72 | $order = 'asc'; 73 | } else { 74 | $order = 'desc'; 75 | } 76 | $list_order = $this->where(['id'=>$id])->value('list_order'); 77 | $list = $this->where('list_order', $exp, $list_order)->limit(2)->order('list_order', $order)->column('id,list_order'); 78 | if (count($list) < 2) { 79 | return false; 80 | } 81 | 82 | $first = array_shift($list); 83 | $last = array_shift($list); 84 | 85 | $this->saveAll([ 86 | ['id' => $first['id'], 'list_order' => $last['list_order']], 87 | ['id' => $last['id'], 'list_order' => $first['list_order']] 88 | ]); 89 | 90 | return true; 91 | } 92 | } -------------------------------------------------------------------------------- /application/common/model/Hooks.php: -------------------------------------------------------------------------------- 1 | - < | WECHAT: wx5ini99 11 | * / \ | DATETIME: 2018/4/19 12 | * // \\ | 13 | * //| . |\\ | 14 | * "'\ /'"_.-~^`'-. | 15 | * \ _ /--' ` | 16 | * ___)( )(___ |----------------------------------------- 17 | * (((__) (__))) | 高山仰止,景行行止.虽不能至,心向往之。 18 | * +---------------------------------------------------------------------- 19 | * | Copyright (c) 2017 http://www.zzstudio.net All rights reserved. 20 | * +---------------------------------------------------------------------- 21 | */ 22 | namespace app\common\model; 23 | 24 | class Hooks extends Base 25 | { 26 | // 数据完成配置 27 | protected $auto = ['update_time']; 28 | protected $insert = ['create_time', 'status' => 1]; 29 | 30 | 31 | } -------------------------------------------------------------------------------- /application/common/validate/Addons.php: -------------------------------------------------------------------------------- 1 | - < | WECHAT: wx5ini99 11 | * / \ | DATETIME: 2018/4/19 12 | * // \\ | 13 | * //| . |\\ | 14 | * "'\ /'"_.-~^`'-. | 15 | * \ _ /--' ` | 16 | * ___)( )(___ |----------------------------------------- 17 | * (((__) (__))) | 高山仰止,景行行止.虽不能至,心向往之。 18 | * +---------------------------------------------------------------------- 19 | * | Copyright (c) 2017 http://www.zzstudio.net All rights reserved. 20 | * +---------------------------------------------------------------------- 21 | */ 22 | namespace app\common\validate; 23 | 24 | use think\Validate; 25 | 26 | class Addons extends Validate 27 | { 28 | protected $rule = [ 29 | 'name|插件目录' => 'require|max:25|unique:addons', 30 | 'title|插件名称' => 'require|max:50', 31 | 'description|描述' => 'max:120', 32 | 'version|版本号' => 'require|max:10', 33 | 'author|作者' => 'require|max:20', 34 | ]; 35 | 36 | protected $scene = []; 37 | } -------------------------------------------------------------------------------- /application/common/validate/Hooks.php: -------------------------------------------------------------------------------- 1 | - < | WECHAT: wx5ini99 11 | * / \ | DATETIME: 2018/4/19 12 | * // \\ | 13 | * //| . |\\ | 14 | * "'\ /'"_.-~^`'-. | 15 | * \ _ /--' ` | 16 | * ___)( )(___ |----------------------------------------- 17 | * (((__) (__))) | 高山仰止,景行行止.虽不能至,心向往之。 18 | * +---------------------------------------------------------------------- 19 | * | Copyright (c) 2017 http://www.zzstudio.net All rights reserved. 20 | * +---------------------------------------------------------------------- 21 | */ 22 | namespace app\common\validate; 23 | 24 | use think\Validate; 25 | 26 | class Hooks extends Validate 27 | { 28 | protected $rule = [ 29 | 'id|ID' => 'require|number', 30 | 'name|钩子名称' => 'require|max:25|unique:hooks', 31 | 'description|描述' => 'max:120' 32 | ]; 33 | 34 | protected $scene = [ 35 | 'add' => ['name','description'], 36 | ]; 37 | } -------------------------------------------------------------------------------- /application/http/exception/Handle.php: -------------------------------------------------------------------------------- 1 | - < | WECHAT: wx5ini99 11 | * / \ | DATETIME: 2018/4/19 12 | * // \\ | 13 | * //| . |\\ | 14 | * "'\ /'"_.-~^`'-. | 15 | * \ _ /--' ` | 16 | * ___)( )(___ |----------------------------------------- 17 | * (((__) (__))) | 高山仰止,景行行止.虽不能至,心向往之。 18 | * +---------------------------------------------------------------------- 19 | * | Copyright (c) 2017 http://www.zzstudio.net All rights reserved. 20 | * +---------------------------------------------------------------------- 21 | */ 22 | 23 | namespace app\http\exception; 24 | 25 | use Exception; 26 | use think\exception\HttpException; 27 | use think\exception\ValidateException; 28 | 29 | class Handle extends \think\exception\Handle 30 | { 31 | /** 32 | * 系统异常处理接管 33 | * @param Exception $e 34 | * @return string|\think\Response|\think\response\Json 35 | */ 36 | public function render(Exception $e) 37 | { 38 | // 参数验证错误 39 | if ($e instanceof ValidateException) { 40 | if (request()->isAjax()) { 41 | $result = [ 42 | 'status' => 422, 43 | 'code' => 0, 44 | 'msg' => $e->getMessage() 45 | ]; 46 | return json($result); 47 | } 48 | } 49 | 50 | // 请求异常 51 | if ($e instanceof HttpException && request()->isAjax()) { 52 | $result = [ 53 | 'status' => $e->getStatusCode(), 54 | 'code' => 0, 55 | 'msg' => $e->getMessage() 56 | ]; 57 | return json($result); 58 | } 59 | 60 | // 其他错误交给系统处理 61 | return parent::render($e); 62 | } 63 | } -------------------------------------------------------------------------------- /application/http/middleware/Check.php: -------------------------------------------------------------------------------- 1 | - < | WECHAT: wx5ini99 11 | * / \ | DATETIME: 2018/4/19 12 | * // \\ | 13 | * //| . |\\ | 14 | * "'\ /'"_.-~^`'-. | 15 | * \ _ /--' ` | 16 | * ___)( )(___ |----------------------------------------- 17 | * (((__) (__))) | 高山仰止,景行行止.虽不能至,心向往之。 18 | * +---------------------------------------------------------------------- 19 | * | Copyright (c) 2017 http://www.zzstudio.net All rights reserved. 20 | * +---------------------------------------------------------------------- 21 | */ 22 | 23 | namespace app\http\middleware; 24 | 25 | class Check 26 | { 27 | /** 28 | * check 中间件 29 | * @param $request 30 | * @param \Closure $next 31 | * @return mixed 32 | */ 33 | public function handle($request, \Closure $next) 34 | { 35 | return $next($request); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /application/tags.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | // 应用行为扩展定义文件 13 | return [ 14 | // 应用初始化 15 | 'app_init' => [ 16 | 'app\\common\\behavior\\App' 17 | ], 18 | // 应用开始 19 | 'app_begin' => [], 20 | // 模块初始化 21 | 'module_init' => [ 22 | 'app\\common\\behavior\\Init' 23 | ], 24 | // 操作开始执行 25 | 'action_begin' => [], 26 | // 视图内容过滤 27 | 'view_filter' => [], 28 | // 日志写入 29 | 'log_write' => [], 30 | // 应用结束 31 | 'app_end' => [], 32 | ]; 33 | -------------------------------------------------------------------------------- /build.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | return [ 13 | // 生成应用公共文件 14 | '__file__' => ['common.php'], 15 | 16 | // 定义demo模块的自动生成 (按照实际定义的文件名生成) 17 | 'demo' => [ 18 | '__file__' => ['common.php'], 19 | '__dir__' => ['behavior', 'controller', 'model', 'view'], 20 | 'controller' => ['Index', 'Test', 'UserType'], 21 | 'model' => ['User', 'UserType'], 22 | 'view' => ['index/index'], 23 | ], 24 | 25 | // 其他更多的模块定义 26 | ]; 27 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "topthink/think", 3 | "description": "the new thinkphp framework", 4 | "type": "project", 5 | "keywords": [ 6 | "framework", 7 | "thinkphp", 8 | "ORM" 9 | ], 10 | "homepage": "http://thinkphp.cn/", 11 | "license": "Apache-2.0", 12 | "authors": [ 13 | { 14 | "name": "liu21st", 15 | "email": "liu21st@gmail.com" 16 | } 17 | ], 18 | "require": { 19 | "php": ">=5.6.0", 20 | "topthink/framework": "5.1.*", 21 | "zz-studio/think-addons": "dev-master", 22 | "zz-studio/think-wechat": "dev-master" 23 | }, 24 | "autoload": { 25 | "psr-4": { 26 | "app\\": "application" 27 | } 28 | }, 29 | "extra": { 30 | "think-path": "core" 31 | }, 32 | "config": { 33 | "preferred-install": "dist" 34 | }, 35 | "repositories": { 36 | "packagist": { 37 | "type": "composer", 38 | "url": "https://packagist.phpcomposer.com" 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | // +---------------------------------------------------------------------- 13 | // | 缓存设置 14 | // +---------------------------------------------------------------------- 15 | 16 | return [ 17 | // 驱动方式 18 | 'type' => 'File', 19 | // 缓存保存目录 20 | 'path' => '', 21 | // 缓存前缀 22 | 'prefix' => '', 23 | // 缓存有效期 0表示永久缓存 24 | 'expire' => 0, 25 | ]; 26 | -------------------------------------------------------------------------------- /config/cookie.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | // +---------------------------------------------------------------------- 13 | // | Cookie设置 14 | // +---------------------------------------------------------------------- 15 | return [ 16 | // cookie 名称前缀 17 | 'prefix' => '', 18 | // cookie 保存时间 19 | 'expire' => 0, 20 | // cookie 保存路径 21 | 'path' => '/', 22 | // cookie 有效域名 23 | 'domain' => '', 24 | // cookie 启用安全传输 25 | 'secure' => false, 26 | // httponly设置 27 | 'httponly' => '', 28 | // 是否使用 setcookie 29 | 'setcookie' => true, 30 | ]; 31 | -------------------------------------------------------------------------------- /config/database.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | return [ 13 | // 数据库类型 14 | 'type' => 'mysql', 15 | // 服务器地址 16 | 'hostname' => '127.0.0.1', 17 | // 数据库名 18 | 'database' => 'zzstudio_db', 19 | // 用户名 20 | 'username' => 'root', 21 | // 密码 22 | 'password' => 'root', 23 | // 端口 24 | 'hostport' => '', 25 | // 连接dsn 26 | 'dsn' => '', 27 | // 数据库连接参数 28 | 'params' => [], 29 | // 数据库编码默认采用utf8 30 | 'charset' => 'utf8', 31 | // 数据库表前缀 32 | 'prefix' => 'zzstudio_', 33 | // 数据库调试模式 34 | 'debug' => true, 35 | // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) 36 | 'deploy' => 0, 37 | // 数据库读写是否分离 主从式有效 38 | 'rw_separate' => false, 39 | // 读写分离后 主服务器数量 40 | 'master_num' => 1, 41 | // 指定从服务器序号 42 | 'slave_no' => '', 43 | // 是否严格检查字段是否存在 44 | 'fields_strict' => true, 45 | // 数据集返回类型 46 | 'resultset_type' => 'array', 47 | // 自动写入时间戳字段 48 | 'auto_timestamp' => false, 49 | // 时间字段取出后的默认时间格式 50 | 'datetime_format' => 'Y-m-d H:i:s', 51 | // 是否需要进行SQL性能分析 52 | 'sql_explain' => false, 53 | // Query类 54 | 'query' => '\\think\\db\\Query', 55 | ]; 56 | -------------------------------------------------------------------------------- /config/log.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | // +---------------------------------------------------------------------- 13 | // | 日志设置 14 | // +---------------------------------------------------------------------- 15 | return [ 16 | // 日志记录方式,内置 file socket 支持扩展 17 | 'type' => 'File', 18 | // 日志保存目录 19 | 'path' => '', 20 | // 日志记录级别 21 | 'level' => [], 22 | ]; 23 | -------------------------------------------------------------------------------- /config/midleware.php: -------------------------------------------------------------------------------- 1 | - < | WECHAT: wx5ini99 11 | * / \ | DATETIME: 2018/4/19 12 | * // \\ | 13 | * //| . |\\ | 14 | * "'\ /'"_.-~^`'-. | 15 | * \ _ /--' ` | 16 | * ___)( )(___ |----------------------------------------- 17 | * (((__) (__))) | 高山仰止,景行行止.虽不能至,心向往之。 18 | * +---------------------------------------------------------------------- 19 | * | Copyright (c) 2017 http://www.zzstudio.net All rights reserved. 20 | * +---------------------------------------------------------------------- 21 | */ 22 | return [ 23 | 'check' => app\http\middleware\Check::class 24 | ]; -------------------------------------------------------------------------------- /config/session.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | // +---------------------------------------------------------------------- 13 | // | 会话设置 14 | // +---------------------------------------------------------------------- 15 | 16 | return [ 17 | 'id' => '', 18 | // SESSION_ID的提交变量,解决flash上传跨域 19 | 'var_session_id' => '', 20 | // SESSION 前缀 21 | 'prefix' => 'think', 22 | // 驱动方式 支持redis memcache memcached 23 | 'type' => '', 24 | // 是否自动开启 SESSION 25 | 'auto_start' => true, 26 | ]; 27 | -------------------------------------------------------------------------------- /config/template.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | // +---------------------------------------------------------------------- 13 | // | 模板设置 14 | // +---------------------------------------------------------------------- 15 | 16 | return [ 17 | // 模板引擎类型 支持 php think 支持扩展 18 | 'type' => 'Think', 19 | // 模板路径 20 | 'view_path' => '', 21 | // 模板后缀 22 | 'view_suffix' => 'html', 23 | // 模板文件名分隔符 24 | 'view_depr' => DIRECTORY_SEPARATOR, 25 | // 模板引擎普通标签开始标记 26 | 'tpl_begin' => '{', 27 | // 模板引擎普通标签结束标记 28 | 'tpl_end' => '}', 29 | // 标签库标签开始标记 30 | 'taglib_begin' => '{', 31 | // 标签库标签结束标记 32 | 'taglib_end' => '}', 33 | ]; 34 | -------------------------------------------------------------------------------- /config/trace.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | // +---------------------------------------------------------------------- 13 | // | Trace设置 开启 app_trace 后 有效 14 | // +---------------------------------------------------------------------- 15 | return [ 16 | // 内置Html Console 支持扩展 17 | 'type' => 'Html', 18 | ]; 19 | -------------------------------------------------------------------------------- /core/.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | composer.phar 3 | composer.lock 4 | .DS_Store 5 | Thumbs.db 6 | /phpunit.xml 7 | /.idea 8 | /.vscode -------------------------------------------------------------------------------- /core/.htaccess: -------------------------------------------------------------------------------- 1 | deny from all -------------------------------------------------------------------------------- /core/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 如何贡献我的源代码 2 | === 3 | 4 | 此文档介绍了 ThinkPHP 团队的组成以及运转机制,您提交的代码将给 ThinkPHP 项目带来什么好处,以及如何才能加入我们的行列。 5 | 6 | ## 通过 Github 贡献代码 7 | 8 | ThinkPHP 目前使用 Git 来控制程序版本,如果你想为 ThinkPHP 贡献源代码,请先大致了解 Git 的使用方法。我们目前把项目托管在 GitHub 上,任何 GitHub 用户都可以向我们贡献代码。 9 | 10 | 参与的方式很简单,`fork`一份 ThinkPHP 的代码到你的仓库中,修改后提交,并向我们发起`pull request`申请,我们会及时对代码进行审查并处理你的申请并。审查通过后,你的代码将被`merge`进我们的仓库中,这样你就会自动出现在贡献者名单里了,非常方便。 11 | 12 | 我们希望你贡献的代码符合: 13 | 14 | * ThinkPHP 的编码规范 15 | * 适当的注释,能让其他人读懂 16 | * 遵循 Apache2 开源协议 17 | 18 | **如果想要了解更多细节或有任何疑问,请继续阅读下面的内容** 19 | 20 | ### 注意事项 21 | 22 | * 本项目代码格式化标准选用 [**PSR-2**](http://www.kancloud.cn/thinkphp/php-fig-psr/3141); 23 | * 类名和类文件名遵循 [**PSR-4**](http://www.kancloud.cn/thinkphp/php-fig-psr/3144); 24 | * 对于 Issues 的处理,请使用诸如 `fix #xxx(Issue ID)` 的 commit title 直接关闭 issue。 25 | * 系统会自动在 PHP 5.4 5.5 5.6 7.0 和 HHVM 上测试修改,其中 HHVM 下的测试容许报错,请确保你的修改符合 PHP 5.4 ~ 5.6 和 PHP 7.0 的语法规范; 26 | * 管理员不会合并造成 CI faild 的修改,若出现 CI faild 请检查自己的源代码或修改相应的[单元测试文件](tests); 27 | 28 | ## GitHub Issue 29 | 30 | GitHub 提供了 Issue 功能,该功能可以用于: 31 | 32 | * 提出 bug 33 | * 提出功能改进 34 | * 反馈使用体验 35 | 36 | 该功能不应该用于: 37 | 38 | * 提出修改意见(涉及代码署名和修订追溯问题) 39 | * 不友善的言论 40 | 41 | ## 快速修改 42 | 43 | **GitHub 提供了快速编辑文件的功能** 44 | 45 | 1. 登录 GitHub 帐号; 46 | 2. 浏览项目文件,找到要进行修改的文件; 47 | 3. 点击右上角铅笔图标进行修改; 48 | 4. 填写 `Commit changes` 相关内容(Title 必填); 49 | 5. 提交修改,等待 CI 验证和管理员合并。 50 | 51 | **若您需要一次提交大量修改,请继续阅读下面的内容** 52 | 53 | ## 完整流程 54 | 55 | 1. `fork`本项目; 56 | 2. 克隆(`clone`)你 `fork` 的项目到本地; 57 | 3. 新建分支(`branch`)并检出(`checkout`)新分支; 58 | 4. 添加本项目到你的本地 git 仓库作为上游(`upstream`); 59 | 5. 进行修改,若你的修改包含方法或函数的增减,请记得修改[单元测试文件](tests); 60 | 6. 变基(衍合 `rebase`)你的分支到上游 master 分支; 61 | 7. `push` 你的本地仓库到 GitHub; 62 | 8. 提交 `pull request`; 63 | 9. 等待 CI 验证(若不通过则重复 5~7,GitHub 会自动更新你的 `pull request`); 64 | 10. 等待管理员处理,并及时 `rebase` 你的分支到上游 master 分支(若上游 master 分支有修改)。 65 | 66 | *若有必要,可以 `git push -f` 强行推送 rebase 后的分支到自己的 `fork`* 67 | 68 | *绝对不可以使用 `git push -f` 强行推送修改到上游* 69 | 70 | ### 注意事项 71 | 72 | * 若对上述流程有任何不清楚的地方,请查阅 GIT 教程,如 [这个](http://backlogtool.com/git-guide/cn/); 73 | * 对于代码**不同方面**的修改,请在自己 `fork` 的项目中**创建不同的分支**(原因参见`完整流程`第9条备注部分); 74 | * 变基及交互式变基操作参见 [Git 交互式变基](http://pakchoi.me/2015/03/17/git-interactive-rebase/) 75 | 76 | ## 推荐资源 77 | 78 | ### 开发环境 79 | 80 | * XAMPP for Windows 5.5.x 81 | * WampServer (for Windows) 82 | * upupw Apache PHP5.4 ( for Windows) 83 | 84 | 或自行安装 85 | 86 | - Apache / Nginx 87 | - PHP 5.4 ~ 5.6 88 | - MySQL / MariaDB 89 | 90 | *Windows 用户推荐添加 PHP bin 目录到 PATH,方便使用 composer* 91 | 92 | *Linux 用户自行配置环境, Mac 用户推荐使用内置 Apache 配合 Homebrew 安装 PHP 和 MariaDB* 93 | 94 | ### 编辑器 95 | 96 | Sublime Text 3 + phpfmt 插件 97 | 98 | phpfmt 插件参数 99 | 100 | ```json 101 | { 102 | "autocomplete": true, 103 | "enable_auto_align": true, 104 | "format_on_save": true, 105 | "indent_with_space": true, 106 | "psr1_naming": false, 107 | "psr2": true, 108 | "version": 4 109 | } 110 | ``` 111 | 112 | 或其他 编辑器 / IDE 配合 PSR2 自动格式化工具 113 | 114 | ### Git GUI 115 | 116 | * SourceTree 117 | * GitHub Desktop 118 | 119 | 或其他 Git 图形界面客户端 120 | -------------------------------------------------------------------------------- /core/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 3 | 版权所有Copyright © 2006-2016 by ThinkPHP (http://thinkphp.cn) 4 | All rights reserved。 5 | ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 6 | 7 | Apache Licence是著名的非盈利开源组织Apache采用的协议。 8 | 该协议和BSD类似,鼓励代码共享和尊重原作者的著作权, 9 | 允许代码修改,再作为开源或商业软件发布。需要满足 10 | 的条件: 11 | 1. 需要给代码的用户一份Apache Licence ; 12 | 2. 如果你修改了代码,需要在被修改的文件中说明; 13 | 3. 在延伸的代码中(修改和有源代码衍生的代码中)需要 14 | 带有原来代码中的协议,商标,专利声明和其他原来作者规 15 | 定需要包含的说明; 16 | 4. 如果再发布的产品中包含一个Notice文件,则在Notice文 17 | 件中需要带有本协议内容。你可以在Notice中增加自己的 18 | 许可,但不可以表现为对Apache Licence构成更改。 19 | 具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | POSSIBILITY OF SUCH DAMAGE. 33 | -------------------------------------------------------------------------------- /core/README.md: -------------------------------------------------------------------------------- 1 | ![](http://www.thinkphp.cn/Uploads/editor/2016-06-23/576b4732a6e04.png) 2 | 3 | ThinkPHP 5.1 —— 12载初心,你值得信赖的PHP框架 4 | =============== 5 | 6 | [![Build Status](https://travis-ci.org/top-think/framework.svg?branch=master)](https://travis-ci.org/top-think/framework) 7 | [![Total Downloads](https://poser.pugx.org/topthink/framework/downloads)](https://packagist.org/packages/topthink/framework) 8 | [![Latest Stable Version](https://poser.pugx.org/topthink/framework/v/stable)](https://packagist.org/packages/topthink/framework) 9 | [![License](https://poser.pugx.org/topthink/framework/license)](https://packagist.org/packages/topthink/framework) 10 | 11 | ThinkPHP5.1对底层架构做了进一步的改进,减少依赖,其主要特性包括: 12 | 13 | + 采用容器统一管理对象 14 | + 支持Facade 15 | + 更易用的路由 16 | + 注解路由支持 17 | + 路由跨域请求支持 18 | + 验证类增强 19 | + 配置和路由目录独立 20 | + 取消系统常量 21 | + 类库别名机制 22 | + 模型和数据库增强 23 | + 依赖注入完善 24 | + 支持PSR-3日志规范 25 | 26 | ### 废除的功能: 27 | 28 | + 聚合模型 29 | + 内置控制器扩展类 30 | + 模型自动验证 31 | 32 | > ThinkPHP5.1的运行环境要求PHP5.6+。 33 | 34 | 35 | ## 在线手册 36 | 37 | + [完全开发手册](https://www.kancloud.cn/manual/thinkphp5_1/content) 38 | + [升级指导](https://www.kancloud.cn/manual/thinkphp5_1/354155) 39 | 40 | ## 命名规范 41 | 42 | `ThinkPHP5`遵循PSR-2命名规范和PSR-4自动加载规范。 43 | 44 | ## 参与开发 45 | 46 | 请参阅 [ThinkPHP5 核心框架包](https://github.com/top-think/framework)。 47 | 48 | ## 版权信息 49 | 50 | ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 51 | 52 | 本项目包含的第三方源码和二进制文件之版权信息另行标注。 53 | 54 | 版权所有Copyright © 2006-2018 by ThinkPHP (http://thinkphp.cn) 55 | 56 | All rights reserved。 57 | 58 | ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 59 | 60 | 更多细节参阅 [LICENSE.txt](LICENSE.txt) 61 | -------------------------------------------------------------------------------- /core/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "topthink/framework", 3 | "description": "the new thinkphp framework", 4 | "type": "think-framework", 5 | "keywords": [ 6 | "framework", 7 | "thinkphp", 8 | "ORM" 9 | ], 10 | "homepage": "http://thinkphp.cn/", 11 | "license": "Apache-2.0", 12 | "authors": [ 13 | { 14 | "name": "liu21st", 15 | "email": "liu21st@gmail.com" 16 | }, 17 | { 18 | "name": "yunwuxin", 19 | "email": "448901948@qq.com" 20 | } 21 | ], 22 | "require": { 23 | "php": ">=5.6.0", 24 | "topthink/think-installer": "~1.0" 25 | }, 26 | "require-dev": { 27 | "phpunit/phpunit": "^5.0|^6.0", 28 | "johnkary/phpunit-speedtrap": "^1.0", 29 | "mikey179/vfsStream": "~1.6", 30 | "phploc/phploc": "2.*", 31 | "sebastian/phpcpd": "2.*", 32 | "squizlabs/php_codesniffer": "2.*", 33 | "phpdocumentor/reflection-docblock": "^2.0" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /core/library/think/Env.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think; 13 | 14 | class Env 15 | { 16 | /** 17 | * 环境变量数据 18 | * @var array 19 | */ 20 | protected $data = []; 21 | 22 | public function __construct() 23 | { 24 | $this->data = $_ENV; 25 | } 26 | 27 | /** 28 | * 读取环境变量定义文件 29 | * @access public 30 | * @param string $file 环境变量定义文件 31 | * @return void 32 | */ 33 | public function load($file) 34 | { 35 | $env = parse_ini_file($file, true); 36 | $this->set($env); 37 | } 38 | 39 | /** 40 | * 获取环境变量值 41 | * @access public 42 | * @param string $name 环境变量名 43 | * @param mixed $default 默认值 44 | * @return mixed 45 | */ 46 | public function get($name = null, $default = null) 47 | { 48 | if (is_null($name)) { 49 | return $this->data; 50 | } 51 | 52 | $name = strtoupper(str_replace('.', '_', $name)); 53 | 54 | if (isset($this->data[$name])) { 55 | return $this->data[$name]; 56 | } 57 | 58 | return $this->getEnv($name, $default); 59 | } 60 | 61 | protected function getEnv($name, $default = null) 62 | { 63 | $result = getenv('PHP_' . $name); 64 | 65 | if (false === $result) { 66 | return $default; 67 | } 68 | 69 | if ('false' === $result) { 70 | $result = false; 71 | } elseif ('true' === $result) { 72 | $result = true; 73 | } 74 | 75 | if (!isset($this->data[$name])) { 76 | $this->data[$name] = $result; 77 | } 78 | 79 | return $result; 80 | } 81 | 82 | /** 83 | * 设置环境变量值 84 | * @access public 85 | * @param string|array $env 环境变量 86 | * @param mixed $value 值 87 | * @return void 88 | */ 89 | public function set($env, $value = null) 90 | { 91 | if (is_array($env)) { 92 | $env = array_change_key_case($env, CASE_UPPER); 93 | 94 | foreach ($env as $key => $val) { 95 | if (is_array($val)) { 96 | foreach ($val as $k => $v) { 97 | $this->data[$key . '_' . strtoupper($k)] = $v; 98 | } 99 | } else { 100 | $this->data[$key] = $val; 101 | } 102 | } 103 | } else { 104 | $name = strtoupper(str_replace('.', '_', $env)); 105 | 106 | $this->data[$name] = $value; 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /core/library/think/Exception.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think; 13 | 14 | class Exception extends \Exception 15 | { 16 | 17 | /** 18 | * 保存异常页面显示的额外Debug数据 19 | * @var array 20 | */ 21 | protected $data = []; 22 | 23 | /** 24 | * 设置异常额外的Debug数据 25 | * 数据将会显示为下面的格式 26 | * 27 | * Exception Data 28 | * -------------------------------------------------- 29 | * Label 1 30 | * key1 value1 31 | * key2 value2 32 | * Label 2 33 | * key1 value1 34 | * key2 value2 35 | * 36 | * @access protected 37 | * @param string $label 数据分类,用于异常页面显示 38 | * @param array $data 需要显示的数据,必须为关联数组 39 | */ 40 | final protected function setData($label, array $data) 41 | { 42 | $this->data[$label] = $data; 43 | } 44 | 45 | /** 46 | * 获取异常额外Debug数据 47 | * 主要用于输出到异常页面便于调试 48 | * @access public 49 | * @return array 由setData设置的Debug数据 50 | */ 51 | final public function getData() 52 | { 53 | return $this->data; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /core/library/think/config/driver/Ini.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\config\driver; 13 | 14 | class Ini 15 | { 16 | public function parse($config) 17 | { 18 | if (is_file($config)) { 19 | return parse_ini_file($config, true); 20 | } else { 21 | return parse_ini_string($config, true); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/library/think/config/driver/Json.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\config\driver; 13 | 14 | class Json 15 | { 16 | public function parse($config) 17 | { 18 | if (is_file($config)) { 19 | $config = file_get_contents($config); 20 | } 21 | 22 | $result = json_decode($config, true); 23 | 24 | return $result; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/library/think/config/driver/Xml.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\config\driver; 13 | 14 | class Xml 15 | { 16 | public function parse($config) 17 | { 18 | if (is_file($config)) { 19 | $content = simplexml_load_file($config); 20 | } else { 21 | $content = simplexml_load_string($config); 22 | } 23 | 24 | $result = (array) $content; 25 | foreach ($result as $key => $val) { 26 | if (is_object($val)) { 27 | $result[$key] = (array) $val; 28 | } 29 | } 30 | 31 | return $result; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /core/library/think/console/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2004-2016 Fabien Potencier 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /core/library/think/console/bin/README.md: -------------------------------------------------------------------------------- 1 | console 工具使用 hiddeninput.exe 在 windows 上隐藏密码输入,该二进制文件由第三方提供,相关源码和其他细节可以在 [Hidden Input](https://github.com/Seldaek/hidden-input) 找到。 2 | -------------------------------------------------------------------------------- /core/library/think/console/bin/hiddeninput.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz-studio/zz-admin/99c6bbc5f93334ebb9cfae2353ac30074dae7cad/core/library/think/console/bin/hiddeninput.exe -------------------------------------------------------------------------------- /core/library/think/console/command/Build.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\command; 13 | 14 | use think\console\Command; 15 | use think\console\Input; 16 | use think\console\input\Option; 17 | use think\console\Output; 18 | use think\facade\App; 19 | use think\facade\Build as AppBuild; 20 | 21 | class Build extends Command 22 | { 23 | 24 | /** 25 | * {@inheritdoc} 26 | */ 27 | protected function configure() 28 | { 29 | $this->setName('build') 30 | ->setDefinition([ 31 | new Option('config', null, Option::VALUE_OPTIONAL, "build.php path"), 32 | new Option('module', null, Option::VALUE_OPTIONAL, "module name"), 33 | ]) 34 | ->setDescription('Build Application Dirs'); 35 | } 36 | 37 | protected function execute(Input $input, Output $output) 38 | { 39 | if ($input->hasOption('module')) { 40 | AppBuild::module($input->getOption('module')); 41 | $output->writeln("Successed"); 42 | return; 43 | } 44 | 45 | if ($input->hasOption('config')) { 46 | $build = include $input->getOption('config'); 47 | } else { 48 | $build = include App::getAppPath() . 'build.php'; 49 | } 50 | 51 | if (empty($build)) { 52 | $output->writeln("Build Config Is Empty"); 53 | return; 54 | } 55 | 56 | AppBuild::run($build); 57 | $output->writeln("Successed"); 58 | 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /core/library/think/console/command/Clear.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | namespace think\console\command; 12 | 13 | use think\console\Command; 14 | use think\console\Input; 15 | use think\console\input\Option; 16 | use think\console\Output; 17 | use think\facade\App; 18 | 19 | class Clear extends Command 20 | { 21 | protected function configure() 22 | { 23 | // 指令配置 24 | $this 25 | ->setName('clear') 26 | ->addOption('path', 'd', Option::VALUE_OPTIONAL, 'path to clear', null) 27 | ->addOption('cache', 'c', Option::VALUE_NONE, 'clear cache file') 28 | ->addOption('log', 'l', Option::VALUE_NONE, 'clear log file') 29 | ->addOption('dir', 'r', Option::VALUE_NONE, 'clear empty dir') 30 | ->setDescription('Clear runtime file'); 31 | } 32 | 33 | protected function execute(Input $input, Output $output) 34 | { 35 | if ($input->getOption('cache')) { 36 | $path = App::getRuntimePath() . 'cache'; 37 | } elseif ($input->getOption('log')) { 38 | $path = App::getRuntimePath() . 'log'; 39 | } else { 40 | $path = $input->getOption('path') ?: App::getRuntimePath(); 41 | } 42 | 43 | $rmdir = $input->getOption('dir') ? true : false; 44 | $this->clear(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR, $rmdir); 45 | $output->writeln("Clear Successed"); 46 | } 47 | 48 | protected function clear($path, $rmdir) 49 | { 50 | $files = is_dir($path) ? scandir($path) : []; 51 | 52 | foreach ($files as $file) { 53 | if ('.' != $file && '..' != $file && is_dir($path . $file)) { 54 | array_map('unlink', glob($path . $file . DIRECTORY_SEPARATOR . '*.*')); 55 | if ($rmdir) { 56 | rmdir($path . $file); 57 | } 58 | } elseif ('.gitignore' != $file && is_file($path . $file)) { 59 | unlink($path . $file); 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /core/library/think/console/command/Help.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\command; 13 | 14 | use think\console\Command; 15 | use think\console\Input; 16 | use think\console\input\Argument as InputArgument; 17 | use think\console\input\Option as InputOption; 18 | use think\console\Output; 19 | 20 | class Help extends Command 21 | { 22 | 23 | private $command; 24 | 25 | /** 26 | * {@inheritdoc} 27 | */ 28 | protected function configure() 29 | { 30 | $this->ignoreValidationErrors(); 31 | 32 | $this->setName('help')->setDefinition([ 33 | new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'), 34 | new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'), 35 | ])->setDescription('Displays help for a command')->setHelp(<<%command.name% command displays help for a given command: 37 | 38 | php %command.full_name% list 39 | 40 | To display the list of available commands, please use the list command. 41 | EOF 42 | ); 43 | } 44 | 45 | /** 46 | * Sets the command. 47 | * @param Command $command The command to set 48 | */ 49 | public function setCommand(Command $command) 50 | { 51 | $this->command = $command; 52 | } 53 | 54 | /** 55 | * {@inheritdoc} 56 | */ 57 | protected function execute(Input $input, Output $output) 58 | { 59 | if (null === $this->command) { 60 | $this->command = $this->getConsole()->find($input->getArgument('command_name')); 61 | } 62 | 63 | $output->describe($this->command, [ 64 | 'raw_text' => $input->getOption('raw'), 65 | ]); 66 | 67 | $this->command = null; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /core/library/think/console/command/Lists.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\command; 13 | 14 | use think\console\Command; 15 | use think\console\Input; 16 | use think\console\Output; 17 | use think\console\input\Argument as InputArgument; 18 | use think\console\input\Option as InputOption; 19 | use think\console\input\Definition as InputDefinition; 20 | 21 | class Lists extends Command 22 | { 23 | 24 | /** 25 | * {@inheritdoc} 26 | */ 27 | protected function configure() 28 | { 29 | $this->setName('list')->setDefinition($this->createDefinition())->setDescription('Lists commands')->setHelp(<<%command.name% command lists all commands: 31 | 32 | php %command.full_name% 33 | 34 | You can also display the commands for a specific namespace: 35 | 36 | php %command.full_name% test 37 | 38 | It's also possible to get raw list of commands (useful for embedding command runner): 39 | 40 | php %command.full_name% --raw 41 | EOF 42 | ); 43 | } 44 | 45 | /** 46 | * {@inheritdoc} 47 | */ 48 | public function getNativeDefinition() 49 | { 50 | return $this->createDefinition(); 51 | } 52 | 53 | /** 54 | * {@inheritdoc} 55 | */ 56 | protected function execute(Input $input, Output $output) 57 | { 58 | $output->describe($this->getConsole(), [ 59 | 'raw_text' => $input->getOption('raw'), 60 | 'namespace' => $input->getArgument('namespace'), 61 | ]); 62 | } 63 | 64 | /** 65 | * {@inheritdoc} 66 | */ 67 | private function createDefinition() 68 | { 69 | return new InputDefinition([ 70 | new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'), 71 | new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list') 72 | ]); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /core/library/think/console/command/RunServer.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | namespace think\console\command; 12 | 13 | use think\console\Command; 14 | use think\console\Input; 15 | use think\console\input\Option; 16 | use think\console\Output; 17 | use think\facade\App; 18 | 19 | class RunServer extends Command 20 | { 21 | 22 | public function configure() 23 | { 24 | $this->setName('run') 25 | ->addOption('host', 'H', Option::VALUE_OPTIONAL, 26 | 'The host to server the application on', '127.0.0.1') 27 | ->addOption('port', 'p', Option::VALUE_OPTIONAL, 28 | 'The port to server the application on', 8000) 29 | ->addOption('root', 'r', Option::VALUE_OPTIONAL, 30 | 'The document root of the application', App::getRootPath() . 'public') 31 | ->setDescription('PHP Built-in Server for ThinkPHP'); 32 | } 33 | 34 | public function execute(Input $input, Output $output) 35 | { 36 | $host = $input->getOption('host'); 37 | $port = $input->getOption('port'); 38 | $root = $input->getOption('root'); 39 | 40 | $command = sprintf( 41 | 'php -S %s:%d -t %s %s', 42 | $host, 43 | $port, 44 | escapeshellarg($root), 45 | escapeshellarg($root . DIRECTORY_SEPARATOR . 'router.php') 46 | ); 47 | 48 | $output->writeln(sprintf('ThinkPHP Development server is started On ', $host, $port)); 49 | $output->writeln(sprintf('You can exit with `CTRL-C`')); 50 | $output->writeln(sprintf('Document root is: %s', $root)); 51 | passthru($command); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /core/library/think/console/command/make/Controller.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\command\make; 13 | 14 | use think\console\command\Make; 15 | use think\console\input\Option; 16 | use think\facade\Config; 17 | 18 | class Controller extends Make 19 | { 20 | 21 | protected $type = "Controller"; 22 | 23 | protected function configure() 24 | { 25 | parent::configure(); 26 | $this->setName('make:controller') 27 | ->addOption('api', null, Option::VALUE_NONE, 'Generate an api controller class.') 28 | ->addOption('plain', null, Option::VALUE_NONE, 'Generate an empty controller class.') 29 | ->setDescription('Create a new resource controller class'); 30 | } 31 | 32 | protected function getStub() 33 | { 34 | $stubPath = __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR; 35 | 36 | if ($this->input->getOption('api')) { 37 | return $stubPath . 'controller.api.stub'; 38 | } 39 | 40 | if ($this->input->getOption('plain')) { 41 | return $stubPath . 'controller.plain.stub'; 42 | } 43 | 44 | return $stubPath . 'controller.stub'; 45 | } 46 | 47 | protected function getClassName($name) 48 | { 49 | return parent::getClassName($name) . (Config::get('controller_suffix') ? ucfirst(Config::get('url_controller_layer')) : ''); 50 | } 51 | 52 | protected function getNamespace($appNamespace, $module) 53 | { 54 | return parent::getNamespace($appNamespace, $module) . '\controller'; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /core/library/think/console/command/make/Middleware.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\command\make; 13 | 14 | use think\console\command\Make; 15 | 16 | class Middleware extends Make 17 | { 18 | protected $type = "Middleware"; 19 | 20 | protected function configure() 21 | { 22 | parent::configure(); 23 | $this->setName('make:middleware') 24 | ->setDescription('Create a new middleware class'); 25 | } 26 | 27 | protected function getStub() 28 | { 29 | return __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'middleware.stub'; 30 | } 31 | 32 | protected function getNamespace($appNamespace, $module) 33 | { 34 | return parent::getNamespace($appNamespace, 'http') . '\middleware'; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/library/think/console/command/make/Model.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\command\make; 13 | 14 | use think\console\command\Make; 15 | 16 | class Model extends Make 17 | { 18 | protected $type = "Model"; 19 | 20 | protected function configure() 21 | { 22 | parent::configure(); 23 | $this->setName('make:model') 24 | ->setDescription('Create a new model class'); 25 | } 26 | 27 | protected function getStub() 28 | { 29 | return __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'model.stub'; 30 | } 31 | 32 | protected function getNamespace($appNamespace, $module) 33 | { 34 | return parent::getNamespace($appNamespace, $module) . '\model'; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/library/think/console/command/make/stubs/controller.api.stub: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | namespace think\console\command\optimize; 12 | 13 | use think\console\Command; 14 | use think\console\Input; 15 | use think\console\Output; 16 | use think\Container; 17 | 18 | class Route extends Command 19 | { 20 | /** @var Output */ 21 | protected $output; 22 | 23 | protected function configure() 24 | { 25 | $this->setName('optimize:route') 26 | ->setDescription('Build route cache.'); 27 | } 28 | 29 | protected function execute(Input $input, Output $output) 30 | { 31 | $filename = Container::get('app')->getRuntimePath() . 'route.php'; 32 | if (is_file($filename)) { 33 | unlink($filename); 34 | } 35 | file_put_contents($filename, $this->buildRouteCache()); 36 | $output->writeln('Succeed!'); 37 | } 38 | 39 | protected function buildRouteCache() 40 | { 41 | Container::get('route')->setName([]); 42 | Container::get('route')->lazy(false); 43 | // 路由检测 44 | $path = Container::get('app')->getRoutePath(); 45 | 46 | $files = is_dir($path) ? scandir($path) : []; 47 | 48 | foreach ($files as $file) { 49 | if (strpos($file, '.php')) { 50 | $filename = $path . DIRECTORY_SEPARATOR . $file; 51 | // 导入路由配置 52 | $rules = include $filename; 53 | if (is_array($rules)) { 54 | Container::get('route')->import($rules); 55 | } 56 | } 57 | } 58 | 59 | if (Container::get('config')->get('route_annotation')) { 60 | include Container::get('build')->buildRoute(); 61 | } 62 | 63 | $content = 'getName(), true) . ';'; 65 | return $content; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /core/library/think/console/output/driver/Buffer.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\output\driver; 13 | 14 | use think\console\Output; 15 | 16 | class Buffer 17 | { 18 | /** 19 | * @var string 20 | */ 21 | private $buffer = ''; 22 | 23 | public function __construct(Output $output) 24 | { 25 | // do nothing 26 | } 27 | 28 | public function fetch() 29 | { 30 | $content = $this->buffer; 31 | $this->buffer = ''; 32 | return $content; 33 | } 34 | 35 | public function write($messages, $newline = false, $options = Output::OUTPUT_NORMAL) 36 | { 37 | $messages = (array) $messages; 38 | 39 | foreach ($messages as $message) { 40 | $this->buffer .= $message; 41 | } 42 | if ($newline) { 43 | $this->buffer .= "\n"; 44 | } 45 | } 46 | 47 | public function renderException(\Exception $e) 48 | { 49 | // do nothing 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /core/library/think/console/output/driver/Nothing.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\output\driver; 13 | 14 | use think\console\Output; 15 | 16 | class Nothing 17 | { 18 | 19 | public function __construct(Output $output) 20 | { 21 | // do nothing 22 | } 23 | 24 | public function write($messages, $newline = false, $options = Output::OUTPUT_NORMAL) 25 | { 26 | // do nothing 27 | } 28 | 29 | public function renderException(\Exception $e) 30 | { 31 | // do nothing 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /core/library/think/console/output/formatter/Stack.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\output\formatter; 13 | 14 | class Stack 15 | { 16 | 17 | /** 18 | * @var Style[] 19 | */ 20 | private $styles; 21 | 22 | /** 23 | * @var Style 24 | */ 25 | private $emptyStyle; 26 | 27 | /** 28 | * 构造方法 29 | * @param Style|null $emptyStyle 30 | */ 31 | public function __construct(Style $emptyStyle = null) 32 | { 33 | $this->emptyStyle = $emptyStyle ?: new Style(); 34 | $this->reset(); 35 | } 36 | 37 | /** 38 | * 重置堆栈 39 | */ 40 | public function reset() 41 | { 42 | $this->styles = []; 43 | } 44 | 45 | /** 46 | * 推一个样式进入堆栈 47 | * @param Style $style 48 | */ 49 | public function push(Style $style) 50 | { 51 | $this->styles[] = $style; 52 | } 53 | 54 | /** 55 | * 从堆栈中弹出一个样式 56 | * @param Style|null $style 57 | * @return Style 58 | * @throws \InvalidArgumentException 59 | */ 60 | public function pop(Style $style = null) 61 | { 62 | if (empty($this->styles)) { 63 | return $this->emptyStyle; 64 | } 65 | 66 | if (null === $style) { 67 | return array_pop($this->styles); 68 | } 69 | 70 | /** 71 | * @var int $index 72 | * @var Style $stackedStyle 73 | */ 74 | foreach (array_reverse($this->styles, true) as $index => $stackedStyle) { 75 | if ($style->apply('') === $stackedStyle->apply('')) { 76 | $this->styles = array_slice($this->styles, 0, $index); 77 | 78 | return $stackedStyle; 79 | } 80 | } 81 | 82 | throw new \InvalidArgumentException('Incorrectly nested style tag found.'); 83 | } 84 | 85 | /** 86 | * 计算堆栈的当前样式。 87 | * @return Style 88 | */ 89 | public function getCurrent() 90 | { 91 | if (empty($this->styles)) { 92 | return $this->emptyStyle; 93 | } 94 | 95 | return $this->styles[count($this->styles) - 1]; 96 | } 97 | 98 | /** 99 | * @param Style $emptyStyle 100 | * @return Stack 101 | */ 102 | public function setEmptyStyle(Style $emptyStyle) 103 | { 104 | $this->emptyStyle = $emptyStyle; 105 | 106 | return $this; 107 | } 108 | 109 | /** 110 | * @return Style 111 | */ 112 | public function getEmptyStyle() 113 | { 114 | return $this->emptyStyle; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /core/library/think/console/output/question/Confirmation.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\output\question; 13 | 14 | use think\console\output\Question; 15 | 16 | class Confirmation extends Question 17 | { 18 | 19 | private $trueAnswerRegex; 20 | 21 | /** 22 | * 构造方法 23 | * @param string $question 问题 24 | * @param bool $default 默认答案 25 | * @param string $trueAnswerRegex 验证正则 26 | */ 27 | public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i') 28 | { 29 | parent::__construct($question, (bool) $default); 30 | 31 | $this->trueAnswerRegex = $trueAnswerRegex; 32 | $this->setNormalizer($this->getDefaultNormalizer()); 33 | } 34 | 35 | /** 36 | * 获取默认的答案回调 37 | * @return callable 38 | */ 39 | private function getDefaultNormalizer() 40 | { 41 | $default = $this->getDefault(); 42 | $regex = $this->trueAnswerRegex; 43 | 44 | return function ($answer) use ($default, $regex) { 45 | if (is_bool($answer)) { 46 | return $answer; 47 | } 48 | 49 | $answerIsTrue = (bool) preg_match($regex, $answer); 50 | if (false === $default) { 51 | return $answer && $answerIsTrue; 52 | } 53 | 54 | return !$answer || $answerIsTrue; 55 | }; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /core/library/think/db/Expression.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\db; 13 | 14 | class Expression 15 | { 16 | /** 17 | * 查询表达式 18 | * 19 | * @var string 20 | */ 21 | protected $value; 22 | 23 | /** 24 | * 创建一个查询表达式 25 | * 26 | * @param string $value 27 | * @return void 28 | */ 29 | public function __construct($value) 30 | { 31 | $this->value = $value; 32 | } 33 | 34 | /** 35 | * 获取表达式 36 | * 37 | * @return string 38 | */ 39 | public function getValue() 40 | { 41 | return $this->value; 42 | } 43 | 44 | public function __toString() 45 | { 46 | return (string) $this->value; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /core/library/think/db/builder/Pgsql.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\db\builder; 13 | 14 | use think\db\Builder; 15 | use think\db\Query; 16 | 17 | /** 18 | * Pgsql数据库驱动 19 | */ 20 | class Pgsql extends Builder 21 | { 22 | 23 | protected $insertSql = 'INSERT INTO %TABLE% (%FIELD%) VALUES (%DATA%) %COMMENT%'; 24 | protected $insertAllSql = 'INSERT INTO %TABLE% (%FIELD%) %DATA% %COMMENT%'; 25 | 26 | /** 27 | * limit分析 28 | * @access protected 29 | * @param Query $query 查询对象 30 | * @param mixed $limit 31 | * @return string 32 | */ 33 | public function parseLimit(Query $query, $limit) 34 | { 35 | $limitStr = ''; 36 | 37 | if (!empty($limit)) { 38 | $limit = explode(',', $limit); 39 | if (count($limit) > 1) { 40 | $limitStr .= ' LIMIT ' . $limit[1] . ' OFFSET ' . $limit[0] . ' '; 41 | } else { 42 | $limitStr .= ' LIMIT ' . $limit[0] . ' '; 43 | } 44 | } 45 | 46 | return $limitStr; 47 | } 48 | 49 | /** 50 | * 字段和表名处理 51 | * @access public 52 | * @param Query $query 查询对象 53 | * @param mixed $key 字段名 54 | * @param bool $strict 严格检测 55 | * @return string 56 | */ 57 | public function parseKey(Query $query, $key, $strict = false) 58 | { 59 | if (is_int($key)) { 60 | return $key; 61 | } elseif ($key instanceof Expression) { 62 | return $key->getValue(); 63 | } 64 | 65 | $key = trim($key); 66 | 67 | if (strpos($key, '->') && false === strpos($key, '(')) { 68 | // JSON字段支持 69 | list($field, $name) = explode('->', $key); 70 | $key = $field . '->>\'' . $name . '\''; 71 | } elseif (strpos($key, '.')) { 72 | list($table, $key) = explode('.', $key, 2); 73 | 74 | $alias = $query->getOptions('alias'); 75 | 76 | if ('__TABLE__' == $table) { 77 | $table = $query->getOptions('table'); 78 | $table = is_array($table) ? array_shift($table) : $table; 79 | } 80 | 81 | if (isset($alias[$table])) { 82 | $table = $alias[$table]; 83 | } 84 | } 85 | 86 | if (isset($table)) { 87 | $key = $table . '.' . $key; 88 | } 89 | 90 | return $key; 91 | } 92 | 93 | /** 94 | * 随机排序 95 | * @access protected 96 | * @param Query $query 查询对象 97 | * @return string 98 | */ 99 | protected function parseRand(Query $query) 100 | { 101 | return 'RANDOM()'; 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /core/library/think/db/builder/Sqlite.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\db\builder; 13 | 14 | use think\db\Builder; 15 | use think\db\Query; 16 | 17 | /** 18 | * Sqlite数据库驱动 19 | */ 20 | class Sqlite extends Builder 21 | { 22 | 23 | /** 24 | * limit 25 | * @access public 26 | * @param Query $query 查询对象 27 | * @param mixed $limit 28 | * @return string 29 | */ 30 | public function parseLimit(Query $query, $limit) 31 | { 32 | $limitStr = ''; 33 | 34 | if (!empty($limit)) { 35 | $limit = explode(',', $limit); 36 | if (count($limit) > 1) { 37 | $limitStr .= ' LIMIT ' . $limit[1] . ' OFFSET ' . $limit[0] . ' '; 38 | } else { 39 | $limitStr .= ' LIMIT ' . $limit[0] . ' '; 40 | } 41 | } 42 | 43 | return $limitStr; 44 | } 45 | 46 | /** 47 | * 随机排序 48 | * @access protected 49 | * @param Query $query 查询对象 50 | * @return string 51 | */ 52 | protected function parseRand(Query $query) 53 | { 54 | return 'RANDOM()'; 55 | } 56 | 57 | /** 58 | * 字段和表名处理 59 | * @access public 60 | * @param Query $query 查询对象 61 | * @param mixed $key 字段名 62 | * @param bool $strict 严格检测 63 | * @return string 64 | */ 65 | public function parseKey(Query $query, $key, $strict = false) 66 | { 67 | if (is_int($key)) { 68 | return $key; 69 | } elseif ($key instanceof Expression) { 70 | return $key->getValue(); 71 | } 72 | 73 | $key = trim($key); 74 | 75 | if (strpos($key, '.')) { 76 | list($table, $key) = explode('.', $key, 2); 77 | 78 | $alias = $query->getOptions('alias'); 79 | 80 | if ('__TABLE__' == $table) { 81 | $table = $query->getOptions('table'); 82 | $table = is_array($table) ? array_shift($table) : $table; 83 | } 84 | 85 | if (isset($alias[$table])) { 86 | $table = $alias[$table]; 87 | } 88 | } 89 | 90 | if (isset($table)) { 91 | $key = $table . '.' . $key; 92 | } 93 | 94 | return $key; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /core/library/think/db/exception/BindParamException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\db\exception; 13 | 14 | use think\exception\DbException; 15 | 16 | /** 17 | * PDO参数绑定异常 18 | */ 19 | class BindParamException extends DbException 20 | { 21 | 22 | /** 23 | * BindParamException constructor. 24 | * @access public 25 | * @param string $message 26 | * @param array $config 27 | * @param string $sql 28 | * @param array $bind 29 | * @param int $code 30 | */ 31 | public function __construct($message, $config, $sql, $bind, $code = 10502) 32 | { 33 | $this->setData('Bind Param', $bind); 34 | parent::__construct($message, $config, $sql, $code); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/library/think/db/exception/DataNotFoundException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\db\exception; 13 | 14 | use think\exception\DbException; 15 | 16 | class DataNotFoundException extends DbException 17 | { 18 | protected $table; 19 | 20 | /** 21 | * DbException constructor. 22 | * @access public 23 | * @param string $message 24 | * @param string $table 25 | * @param array $config 26 | */ 27 | public function __construct($message, $table = '', array $config = []) 28 | { 29 | $this->message = $message; 30 | $this->table = $table; 31 | 32 | $this->setData('Database Config', $config); 33 | } 34 | 35 | /** 36 | * 获取数据表名 37 | * @access public 38 | * @return string 39 | */ 40 | public function getTable() 41 | { 42 | return $this->table; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /core/library/think/db/exception/ModelNotFoundException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\db\exception; 13 | 14 | use think\exception\DbException; 15 | 16 | class ModelNotFoundException extends DbException 17 | { 18 | protected $model; 19 | 20 | /** 21 | * 构造方法 22 | * @access public 23 | * @param string $message 24 | * @param string $model 25 | * @param array $config 26 | */ 27 | public function __construct($message, $model = '', array $config = []) 28 | { 29 | $this->message = $message; 30 | $this->model = $model; 31 | 32 | $this->setData('Database Config', $config); 33 | } 34 | 35 | /** 36 | * 获取模型类名 37 | * @access public 38 | * @return string 39 | */ 40 | public function getModel() 41 | { 42 | return $this->model; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /core/library/think/exception/ClassNotFoundException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | class ClassNotFoundException extends \RuntimeException 15 | { 16 | protected $class; 17 | public function __construct($message, $class = '') 18 | { 19 | $this->message = $message; 20 | $this->class = $class; 21 | } 22 | 23 | /** 24 | * 获取类名 25 | * @access public 26 | * @return string 27 | */ 28 | public function getClass() 29 | { 30 | return $this->class; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /core/library/think/exception/DbException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | use think\Exception; 15 | 16 | /** 17 | * Database相关异常处理类 18 | */ 19 | class DbException extends Exception 20 | { 21 | /** 22 | * DbException constructor. 23 | * @access public 24 | * @param string $message 25 | * @param array $config 26 | * @param string $sql 27 | * @param int $code 28 | */ 29 | public function __construct($message, array $config, $sql, $code = 10500) 30 | { 31 | $this->message = $message; 32 | $this->code = $code; 33 | 34 | $this->setData('Database Status', [ 35 | 'Error Code' => $code, 36 | 'Error Message' => $message, 37 | 'Error SQL' => $sql, 38 | ]); 39 | 40 | unset($config['username'], $config['password']); 41 | $this->setData('Database Config', $config); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /core/library/think/exception/ErrorException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | use think\Exception; 15 | 16 | /** 17 | * ThinkPHP错误异常 18 | * 主要用于封装 set_error_handler 和 register_shutdown_function 得到的错误 19 | * 除开从 think\Exception 继承的功能 20 | * 其他和PHP系统\ErrorException功能基本一样 21 | */ 22 | class ErrorException extends Exception 23 | { 24 | /** 25 | * 用于保存错误级别 26 | * @var integer 27 | */ 28 | protected $severity; 29 | 30 | /** 31 | * 错误异常构造函数 32 | * @access public 33 | * @param integer $severity 错误级别 34 | * @param string $message 错误详细信息 35 | * @param string $file 出错文件路径 36 | * @param integer $line 出错行号 37 | */ 38 | public function __construct($severity, $message, $file, $line) 39 | { 40 | $this->severity = $severity; 41 | $this->message = $message; 42 | $this->file = $file; 43 | $this->line = $line; 44 | $this->code = 0; 45 | } 46 | 47 | /** 48 | * 获取错误级别 49 | * @access public 50 | * @return integer 错误级别 51 | */ 52 | final public function getSeverity() 53 | { 54 | return $this->severity; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /core/library/think/exception/HttpException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | class HttpException extends \RuntimeException 15 | { 16 | private $statusCode; 17 | private $headers; 18 | 19 | public function __construct($statusCode, $message = null, \Exception $previous = null, array $headers = [], $code = 0) 20 | { 21 | $this->statusCode = $statusCode; 22 | $this->headers = $headers; 23 | 24 | parent::__construct($message, $code, $previous); 25 | } 26 | 27 | public function getStatusCode() 28 | { 29 | return $this->statusCode; 30 | } 31 | 32 | public function getHeaders() 33 | { 34 | return $this->headers; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/library/think/exception/HttpResponseException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | use think\Response; 15 | 16 | class HttpResponseException extends \RuntimeException 17 | { 18 | /** 19 | * @var Response 20 | */ 21 | protected $response; 22 | 23 | public function __construct(Response $response) 24 | { 25 | $this->response = $response; 26 | } 27 | 28 | public function getResponse() 29 | { 30 | return $this->response; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /core/library/think/exception/PDOException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | /** 15 | * PDO异常处理类 16 | * 重新封装了系统的\PDOException类 17 | */ 18 | class PDOException extends DbException 19 | { 20 | /** 21 | * PDOException constructor. 22 | * @access public 23 | * @param \PDOException $exception 24 | * @param array $config 25 | * @param string $sql 26 | * @param int $code 27 | */ 28 | public function __construct(\PDOException $exception, array $config, $sql, $code = 10501) 29 | { 30 | $error = $exception->errorInfo; 31 | 32 | $this->setData('PDO Error Info', [ 33 | 'SQLSTATE' => $error[0], 34 | 'Driver Error Code' => isset($error[1]) ? $error[1] : 0, 35 | 'Driver Error Message' => isset($error[2]) ? $error[2] : '', 36 | ]); 37 | 38 | parent::__construct($exception->getMessage(), $config, $sql, $code); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/library/think/exception/RouteNotFoundException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | class RouteNotFoundException extends HttpException 15 | { 16 | 17 | public function __construct() 18 | { 19 | parent::__construct(404, 'Route Not Found'); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /core/library/think/exception/TemplateNotFoundException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | class TemplateNotFoundException extends \RuntimeException 15 | { 16 | protected $template; 17 | 18 | public function __construct($message, $template = '') 19 | { 20 | $this->message = $message; 21 | $this->template = $template; 22 | } 23 | 24 | /** 25 | * 获取模板文件 26 | * @access public 27 | * @return string 28 | */ 29 | public function getTemplate() 30 | { 31 | return $this->template; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /core/library/think/exception/ThrowableError.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | class ThrowableError extends \ErrorException 15 | { 16 | public function __construct(\Throwable $e) 17 | { 18 | 19 | if ($e instanceof \ParseError) { 20 | $message = 'Parse error: ' . $e->getMessage(); 21 | $severity = E_PARSE; 22 | } elseif ($e instanceof \TypeError) { 23 | $message = 'Type error: ' . $e->getMessage(); 24 | $severity = E_RECOVERABLE_ERROR; 25 | } else { 26 | $message = 'Fatal error: ' . $e->getMessage(); 27 | $severity = E_ERROR; 28 | } 29 | 30 | parent::__construct( 31 | $message, 32 | $e->getCode(), 33 | $severity, 34 | $e->getFile(), 35 | $e->getLine() 36 | ); 37 | 38 | $this->setTrace($e->getTrace()); 39 | } 40 | 41 | protected function setTrace($trace) 42 | { 43 | $traceReflector = new \ReflectionProperty('Exception', 'trace'); 44 | $traceReflector->setAccessible(true); 45 | $traceReflector->setValue($this, $trace); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /core/library/think/exception/ValidateException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | class ValidateException extends \RuntimeException 15 | { 16 | protected $error; 17 | 18 | public function __construct($error) 19 | { 20 | $this->error = $error; 21 | $this->message = is_array($error) ? implode("\n\r", $error) : $error; 22 | } 23 | 24 | /** 25 | * 获取验证错误信息 26 | * @access public 27 | * @return array|string 28 | */ 29 | public function getError() 30 | { 31 | return $this->error; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /core/library/think/facade/App.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\facade; 13 | 14 | use think\Facade; 15 | 16 | /** 17 | * @see \think\App 18 | * @mixin \think\App 19 | * @method \think\App bind(string $bind) static 绑定模块或者控制器 20 | * @method void initialize() static 初始化应用 21 | * @method void init(string $module='') static 初始化模块 22 | * @method \think\Response run() static 执行应用 23 | * @method \think\App dispatch(\think\route\Dispatch $dispatch) static 设置当前请求的调度信息 24 | * @method void log(mixed $log, string $type = 'info') static 记录调试信息 25 | * @method mixed config(string $name='') static 获取配置参数 26 | * @method \think\route\Dispatch routeCheck() static URL路由检测(根据PATH_INFO) 27 | * @method \think\App routeMust(bool $must = false) static 设置应用的路由检测机制 28 | * @method \think\Model model(string $name = '', string $layer = 'model', bool $appendSuffix = false, string $common = 'common') static 实例化模型 29 | * @method object controller(string $name, string $layer = 'controller', bool $appendSuffix = false, string $empty = '') static 实例化控制器 30 | * @method \think\Validate validate(string $name = '', string $layer = 'validate', bool $appendSuffix = false, string $common = 'common') static 实例化验证器类 31 | * @method \think\db\Query db(mixed $config = [], mixed $name = false) static 数据库初始化 32 | * @method mixed action(string $url, $vars = [], $layer = 'controller', $appendSuffix = false) static 调用模块的操作方法 33 | * @method string parseClass(string $module, string $layer, string $name, bool $appendSuffix = false) static 解析应用类的类名 34 | * @method string version() static 获取框架版本 35 | * @method bool isDebug() static 是否为调试模式 36 | * @method string getModulePath() static 获取当前模块路径 37 | * @method void setModulePath(string $path) static 设置当前模块路径 38 | * @method string getRootPath() static 获取应用根目录 39 | * @method string getAppPath() static 获取应用类库目录 40 | * @method string getRuntimePath() static 获取应用运行时目录 41 | * @method string getThinkPath() static 获取核心框架目录 42 | * @method string getRoutePath() static 获取路由目录 43 | * @method string getConfigPath() static 获取应用配置目录 44 | * @method string getConfigExt() static 获取配置后缀 45 | * @method string setNamespace(string $namespace) static 设置应用类库命名空间 46 | * @method string getNamespace() static 获取应用类库命名空间 47 | * @method string getSuffix() static 是否启用类库后缀 48 | * @method float getBeginTime() static 获取应用开启时间 49 | * @method integer getBeginMem() static 获取应用初始内存占用 50 | * @method \think\Container container() static 获取容器实例 51 | */ 52 | class App extends Facade 53 | { 54 | } 55 | -------------------------------------------------------------------------------- /core/library/think/facade/Build.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\facade; 13 | 14 | use think\Facade; 15 | 16 | /** 17 | * @see \think\Build 18 | * @mixin \think\Build 19 | * @method void run(array $build = [], string $namespace = 'app', bool $suffix = false) static 根据传入的build资料创建目录和文件 20 | * @method void module(string $module = '', array $list = [], string $namespace = 'app', bool $suffix = false) static 创建模块 21 | */ 22 | class Build extends Facade 23 | { 24 | } 25 | -------------------------------------------------------------------------------- /core/library/think/facade/Cache.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\facade; 13 | 14 | use think\Facade; 15 | 16 | /** 17 | * @see \think\Cache 18 | * @mixin \think\Cache 19 | * @method \think\cache\Driver connect(array $options = [], mixed $name = false) static 连接缓存 20 | * @method \think\cache\Driver init(array $options = []) static 初始化缓存 21 | * @method \think\cache\Driver store(string $name = '') static 切换缓存类型 22 | * @method bool has(string $name) static 判断缓存是否存在 23 | * @method mixed get(string $name, mixed $default = false) static 读取缓存 24 | * @method mixed pull(string $name) static 读取缓存并删除 25 | * @method mixed set(string $name, mixed $value, int $expire = null) static 设置缓存 26 | * @method mixed remember(string $name, mixed $value, int $expire = null) static 如果不存在则写入缓存 27 | * @method mixed inc(string $name, int $step = 1) static 自增缓存(针对数值缓存) 28 | * @method mixed dec(string $name, int $step = 1) static 自减缓存(针对数值缓存) 29 | * @method bool rm(string $name) static 删除缓存 30 | * @method bool clear(string $tag = null) static 清除缓存 31 | * @method mixed tag(string $name, mixed $keys = null, bool $overlay = false) static 缓存标签 32 | * @method object handler() static 返回句柄对象,可执行其它高级方法 33 | */ 34 | class Cache extends Facade 35 | { 36 | } 37 | -------------------------------------------------------------------------------- /core/library/think/facade/Config.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\facade; 13 | 14 | use think\Facade; 15 | 16 | /** 17 | * @see \think\Config 18 | * @mixin \think\Config 19 | * @method bool has(string $name) static 检测配置是否存在 20 | * @method array pull(string $name) static 获取一级配置 21 | * @method mixed get(string $name) static 获取配置参数 22 | * @method mixed set(string $name, mixed $value = null) static 设置配置参数 23 | * @method array reset(string $prefix ='') static 重置配置参数 24 | */ 25 | class Config extends Facade 26 | { 27 | } 28 | -------------------------------------------------------------------------------- /core/library/think/facade/Cookie.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\facade; 13 | 14 | use think\Facade; 15 | 16 | /** 17 | * @see \think\Cookie 18 | * @mixin \think\Cookie 19 | * @method void init(array $config = []) static 初始化 20 | * @method bool has(string $name,string $prefix = null) static 判断Cookie数据 21 | * @method mixed prefix(string $prefix = '') static 设置或者获取cookie作用域(前缀) 22 | * @method mixed get(string $name,string $prefix = null) static Cookie获取 23 | * @method mixed set(string $name, mixed $value = null, mixed $option = null) static 设置Cookie 24 | * @method void forever(string $name, mixed $value = null, mixed $option = null) static 永久保存Cookie数据 25 | * @method void delete(string $name, string $prefix = null) static Cookie删除 26 | * @method void clear($prefix = null) static Cookie清空 27 | */ 28 | class Cookie extends Facade 29 | { 30 | } 31 | -------------------------------------------------------------------------------- /core/library/think/facade/Debug.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\facade; 13 | 14 | use think\Facade; 15 | 16 | /** 17 | * @see \think\Debug 18 | * @mixin \think\Debug 19 | * @method void remark(string $name, mixed $value = '') static 记录时间(微秒)和内存使用情况 20 | * @method int getRangeTime(string $start, string $end, mixed $dec = 6) static 统计某个区间的时间(微秒)使用情况 21 | * @method int getUseTime(int $dec = 6) static 统计从开始到统计时的时间(微秒)使用情况 22 | * @method string getThroughputRate(string $start, string $end, mixed $dec = 6) static 获取当前访问的吞吐率情况 23 | * @method string getRangeMem(string $start, string $end, mixed $dec = 2) static 记录区间的内存使用情况 24 | * @method int getUseMem(int $dec = 2) static 统计从开始到统计时的内存使用情况 25 | * @method string getMemPeak(string $start, string $end, mixed $dec = 2) static 统计区间的内存峰值情况 26 | * @method mixed getFile(bool $detail = false) static 获取文件加载信息 27 | * @method mixed dump(mixed $var, bool $echo = true, string $label = null, int $flags = ENT_SUBSTITUTE) static 浏览器友好的变量输出 28 | */ 29 | class Debug extends Facade 30 | { 31 | } 32 | -------------------------------------------------------------------------------- /core/library/think/facade/Env.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\facade; 13 | 14 | use think\Facade; 15 | 16 | /** 17 | * @see \think\Env 18 | * @mixin \think\Env 19 | * @method void load(string $file) static 读取环境变量定义文件 20 | * @method mixed get(string $name = null, mixed $default = null) static 获取环境变量值 21 | * @method void set(mixed $env, string $value = null) static 设置环境变量值 22 | */ 23 | class Env extends Facade 24 | { 25 | } 26 | -------------------------------------------------------------------------------- /core/library/think/facade/Hook.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\facade; 13 | 14 | use think\Facade; 15 | 16 | /** 17 | * @see \think\Hook 18 | * @mixin \think\Hook 19 | * @method \think\Hook alias(mixed $name, mixed $behavior = null) static 指定行为标识 20 | * @method void add(string $tag, mixed $behavior, bool $first = false) static 动态添加行为扩展到某个标签 21 | * @method void import(array $tags, bool $recursive = true) static 批量导入插件 22 | * @method array get(string $tag = '') static 获取插件信息 23 | * @method mixed listen(string $tag, mixed $params = null, bool $once = false) static 监听标签的行为 24 | * @method mixed exec(mixed $class, mixed $params = null) static 执行行为 25 | */ 26 | class Hook extends Facade 27 | { 28 | } 29 | -------------------------------------------------------------------------------- /core/library/think/facade/Lang.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\facade; 13 | 14 | use think\Facade; 15 | 16 | /** 17 | * @see \think\Lang 18 | * @mixin \think\Lang 19 | * @method mixed range($range = '') static 设定当前的语言 20 | * @method mixed set(mixed $name, string $value = null, string $range = '') static 设置语言定义 21 | * @method array load(mixed $file, string $range = '') static 加载语言定义 22 | * @method mixed get(string $name = null, array $vars = [], string $range = '') static 获取语言定义 23 | * @method mixed has(string $name, string $range = '') static 获取语言定义 24 | * @method string detect() static 自动侦测设置获取语言选择 25 | * @method void saveToCookie(string $lang = null) static 设置当前语言到Cookie 26 | * @method void setLangDetectVar(string $var) static 设置语言自动侦测的变量 27 | * @method void setLangCookieVar(string $var) static 设置语言的cookie保存变量 28 | * @method void setAllowLangList(array $list) static 设置允许的语言列表 29 | */ 30 | class Lang extends Facade 31 | { 32 | } 33 | -------------------------------------------------------------------------------- /core/library/think/facade/Log.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\facade; 13 | 14 | use think\Facade; 15 | 16 | /** 17 | * @see \think\Log 18 | * @mixin \think\Log 19 | * @method \think\Log init(array $config = []) static 日志初始化 20 | * @method mixed getLog(string $type = '') static 获取日志信息 21 | * @method \think\Log record(mixed $msg, string $type = 'info', array $context = []) static 记录日志信息 22 | * @method \think\Log clear() static 清空日志信息 23 | * @method \think\Log key(string $key) static 当前日志记录的授权key 24 | * @method bool check(array $config) static 检查日志写入权限 25 | * @method bool save() static 保存调试信息 26 | * @method void write(mixed $msg, string $type = 'info', bool $force = false) static 实时写入日志信息 27 | * @method void log(string $level,mixed $message, array $context = []) static 记录日志信息 28 | * @method void emergency(mixed $message, array $context = []) static 记录emergency信息 29 | * @method void alert(mixed $message, array $context = []) static 记录alert信息 30 | * @method void critical(mixed $message, array $context = []) static 记录critical信息 31 | * @method void error(mixed $message, array $context = []) static 记录error信息 32 | * @method void warning(mixed $message, array $context = []) static 记录warning信息 33 | * @method void notice(mixed $message, array $context = []) static 记录notice信息 34 | * @method void info(mixed $message, array $context = []) static 记录info信息 35 | * @method void debug(mixed $message, array $context = []) static 记录debug信息 36 | * @method void sql(mixed $message, array $context = []) static 记录sql信息 37 | */ 38 | class Log extends Facade 39 | { 40 | } 41 | -------------------------------------------------------------------------------- /core/library/think/facade/Middleware.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\facade; 13 | 14 | use think\Facade; 15 | 16 | /** 17 | * @see \think\Middleware 18 | * @mixin \think\Middleware 19 | * @method void import(array $middlewares = []) static 批量设置中间件 20 | * @method void add(mixed $middleware) static 添加中间件到队列 21 | * @method void unshift(mixed $middleware) static 添加中间件到队列开头 22 | * @method array all() static 获取中间件队列 23 | * @method \think\Response dispatch(\think\Request $request) static 执行中间件调度 24 | */ 25 | class Middleware extends Facade 26 | { 27 | } 28 | -------------------------------------------------------------------------------- /core/library/think/facade/Response.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\facade; 13 | 14 | use think\Facade; 15 | 16 | /** 17 | * @see \think\Response 18 | * @mixin \think\Response 19 | * @method \think\response create(mixed $data = '', string $type = '', int $code = 200, array $header = [], array $options = []) static 创建Response对象 20 | * @method void send() static 发送数据到客户端 21 | * @method \think\Response options(mixed $options = []) static 输出的参数 22 | * @method \think\Response data(mixed $data) static 输出数据设置 23 | * @method \think\Response header(mixed $name, string $value = null) static 设置响应头 24 | * @method \think\Response content(mixed $content) static 设置页面输出内容 25 | * @method \think\Response code(int $code) static 发送HTTP状态 26 | * @method \think\Response lastModified(string $time) static LastModified 27 | * @method \think\Response expires(string $time) static expires 28 | * @method \think\Response eTag(string $eTag) static eTag 29 | * @method \think\Response cacheControl(string $cache) static 页面缓存控制 30 | * @method \think\Response contentType(string $contentType, string $charset = 'utf-8') static 页面输出类型 31 | * @method mixed getHeader(string $name) static 获取头部信息 32 | * @method mixed getData() static 获取原始数据 33 | * @method mixed getContent() static 获取输出数据 34 | * @method int getCode() static 获取状态码 35 | */ 36 | class Response extends Facade 37 | { 38 | } 39 | -------------------------------------------------------------------------------- /core/library/think/facade/Session.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\facade; 13 | 14 | use think\Facade; 15 | 16 | /** 17 | * @see \think\Session 18 | * @mixin \think\Session 19 | * @method void init(array $config = []) static session初始化 20 | * @method bool has(string $name,string $prefix = null) static 判断session数据 21 | * @method mixed prefix(string $prefix = '') static 设置或者获取session作用域(前缀) 22 | * @method mixed get(string $name,string $prefix = null) static session获取 23 | * @method mixed pull(string $name,string $prefix = null) static session获取并删除 24 | * @method void push(string $key, mixed $value) static 添加数据到一个session数组 25 | * @method void set(string $name, mixed $value , string $prefix = null) static 设置session数据 26 | * @method void flash(string $name, mixed $value = null) static session设置 下一次请求有效 27 | * @method void flush() static 清空当前请求的session数据 28 | * @method void delete(string $name, string $prefix = null) static 删除session数据 29 | * @method void clear($prefix = null) static 清空session数据 30 | * @method void start() static 启动session 31 | * @method void destroy() static 销毁session 32 | * @method void pause() static 暂停session 33 | * @method void regenerate(bool $delete = false) static 重新生成session_id 34 | */ 35 | class Session extends Facade 36 | { 37 | } 38 | -------------------------------------------------------------------------------- /core/library/think/facade/Url.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\facade; 13 | 14 | use think\Facade; 15 | 16 | /** 17 | * @see \think\Url 18 | * @mixin \think\Url 19 | * @method string build(string $url = '', mixed $vars = '', mixed $suffix = true, mixed $domain = false) static URL生成 支持路由反射 20 | * @method void root(string $root) static 指定当前生成URL地址的root 21 | */ 22 | class Url extends Facade 23 | { 24 | } 25 | -------------------------------------------------------------------------------- /core/library/think/facade/View.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\facade; 13 | 14 | use think\Facade; 15 | 16 | /** 17 | * @see \think\View 18 | * @mixin \think\View 19 | * @method \think\View init(mixed $engine = [], array $replace = []) static 初始化 20 | * @method \think\View share(mixed $name, mixed $value = '') static 模板变量静态赋值 21 | * @method \think\View assign(mixed $name, mixed $value = '') static 模板变量赋值 22 | * @method \think\View config(mixed $name, mixed $value = '') static 配置模板引擎 23 | * @method \think\View exists(mixed $name) static 检查模板是否存在 24 | * @method \think\View filter(Callable $filter) static 视图内容过滤 25 | * @method \think\View engine(mixed $engine = []) static 设置当前模板解析的引擎 26 | * @method string fetch(string $template = '', array $vars = [], array $replace = [], array $config = [], bool $renderContent = false) static 解析和获取模板内容 27 | * @method string display(string $content = '', array $vars = [], array $replace = [], array $config = []) static 渲染内容输出 28 | */ 29 | class View extends Facade 30 | { 31 | } 32 | -------------------------------------------------------------------------------- /core/library/think/log/driver/Test.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\log\driver; 13 | 14 | /** 15 | * 模拟测试输出 16 | */ 17 | class Test 18 | { 19 | /** 20 | * 日志写入接口 21 | * @access public 22 | * @param array $log 日志信息 23 | * @return bool 24 | */ 25 | public function save(array $log = []) 26 | { 27 | return true; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /core/library/think/model/Collection.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\model; 13 | 14 | use think\Collection as BaseCollection; 15 | use think\Model; 16 | 17 | class Collection extends BaseCollection 18 | { 19 | /** 20 | * 延迟预载入关联查询 21 | * @access public 22 | * @param mixed $relation 关联 23 | * @return $this 24 | */ 25 | public function load($relation) 26 | { 27 | $item = current($this->items); 28 | $item->eagerlyResultSet($this->items, $relation); 29 | 30 | return $this; 31 | } 32 | 33 | /** 34 | * 设置需要隐藏的输出属性 35 | * @access public 36 | * @param array $hidden 属性列表 37 | * @param bool $override 是否覆盖 38 | * @return $this 39 | */ 40 | public function hidden($hidden = [], $override = false) 41 | { 42 | $this->each(function ($model) use ($hidden, $override) { 43 | /** @var Model $model */ 44 | $model->hidden($hidden, $override); 45 | }); 46 | 47 | return $this; 48 | } 49 | 50 | /** 51 | * 设置需要输出的属性 52 | * @access public 53 | * @param array $visible 54 | * @param bool $override 是否覆盖 55 | * @return $this 56 | */ 57 | public function visible($visible = [], $override = false) 58 | { 59 | $this->each(function ($model) use ($visible, $override) { 60 | /** @var Model $model */ 61 | $model->visible($visible, $override); 62 | }); 63 | 64 | return $this; 65 | } 66 | 67 | /** 68 | * 设置需要追加的输出属性 69 | * @access public 70 | * @param array $append 属性列表 71 | * @param bool $override 是否覆盖 72 | * @return $this 73 | */ 74 | public function append($append = [], $override = false) 75 | { 76 | $this->each(function ($model) use ($append, $override) { 77 | /** @var Model $model */ 78 | $model && $model->append($append, $override); 79 | }); 80 | 81 | return $this; 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /core/library/think/model/Pivot.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\model; 13 | 14 | use think\Model; 15 | 16 | class Pivot extends Model 17 | { 18 | 19 | /** @var Model */ 20 | public $parent; 21 | 22 | protected $autoWriteTimestamp = false; 23 | 24 | /** 25 | * 架构函数 26 | * @access public 27 | * @param array|object $data 数据 28 | * @param Model $parent 上级模型 29 | * @param string $table 中间数据表名 30 | */ 31 | public function __construct($data = [], Model $parent = null, $table = '') 32 | { 33 | $this->parent = $parent; 34 | 35 | if (is_null($this->name)) { 36 | $this->name = $table; 37 | } 38 | 39 | parent::__construct($data); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /core/library/think/model/concern/TimeStamp.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\model\concern; 13 | 14 | /** 15 | * 自动时间戳 16 | */ 17 | trait TimeStamp 18 | { 19 | /** 20 | * 是否需要自动写入时间戳 如果设置为字符串 则表示时间字段的类型 21 | * @var bool|string 22 | */ 23 | protected $autoWriteTimestamp; 24 | 25 | /** 26 | * 创建时间字段 false表示关闭 27 | * @var false|string 28 | */ 29 | protected $createTime = 'create_time'; 30 | 31 | /** 32 | * 更新时间字段 false表示关闭 33 | * @var false|string 34 | */ 35 | protected $updateTime = 'update_time'; 36 | 37 | /** 38 | * 时间字段显示格式 39 | * @var string 40 | */ 41 | protected $dateFormat; 42 | 43 | /** 44 | * 时间日期字段格式化处理 45 | * @access protected 46 | * @param mixed $time 时间日期表达式 47 | * @param mixed $format 日期格式 48 | * @param bool $timestamp 是否进行时间戳转换 49 | * @return mixed 50 | */ 51 | protected function formatDateTime($time, $format, $timestamp = false) 52 | { 53 | if (false !== strpos($format, '\\')) { 54 | $time = new $format($time); 55 | } elseif (!$timestamp && false !== $format) { 56 | $time = date($format, $time); 57 | } 58 | 59 | return $time; 60 | } 61 | 62 | /** 63 | * 检查时间字段写入 64 | * @access protected 65 | * @return void 66 | */ 67 | protected function checkTimeStampWrite() 68 | { 69 | // 自动写入创建时间和更新时间 70 | if ($this->autoWriteTimestamp) { 71 | if ($this->createTime && !isset($this->data[$this->createTime])) { 72 | $this->data[$this->createTime] = $this->autoWriteTimestamp($this->createTime); 73 | } 74 | if ($this->updateTime && !isset($this->data[$this->updateTime])) { 75 | $this->data[$this->updateTime] = $this->autoWriteTimestamp($this->updateTime); 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /core/library/think/paginator/Collection.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\paginator; 13 | 14 | use Exception; 15 | use think\Paginator; 16 | 17 | /** 18 | * Class Collection 19 | * @package think\paginator 20 | * @method integer total() 21 | * @method integer listRows() 22 | * @method integer currentPage() 23 | * @method string render() 24 | * @method Paginator fragment($fragment) 25 | * @method Paginator appends($key, $value) 26 | * @method integer lastPage() 27 | * @method boolean hasPages() 28 | */ 29 | class Collection extends \think\Collection 30 | { 31 | 32 | /** @var Paginator */ 33 | protected $paginator; 34 | 35 | public function __construct($items = [], Paginator $paginator = null) 36 | { 37 | $this->paginator = $paginator; 38 | parent::__construct($items); 39 | } 40 | 41 | public static function make($items = [], Paginator $paginator = null) 42 | { 43 | return new static($items, $paginator); 44 | } 45 | 46 | public function toArray() 47 | { 48 | if ($this->paginator) { 49 | try { 50 | $total = $this->total(); 51 | } catch (Exception $e) { 52 | $total = null; 53 | } 54 | 55 | return [ 56 | 'total' => $total, 57 | 'per_page' => $this->listRows(), 58 | 'current_page' => $this->currentPage(), 59 | 'data' => parent::toArray(), 60 | ]; 61 | } else { 62 | return parent::toArray(); 63 | } 64 | } 65 | 66 | public function __call($method, $args) 67 | { 68 | if ($this->paginator && method_exists($this->paginator, $method)) { 69 | return call_user_func_array([$this->paginator, $method], $args); 70 | } else { 71 | throw new Exception('method not exists:' . __CLASS__ . '->' . $method); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /core/library/think/process/Utils.php: -------------------------------------------------------------------------------- 1 | 8 | // +---------------------------------------------------------------------- 9 | 10 | namespace think\process; 11 | 12 | class Utils 13 | { 14 | 15 | /** 16 | * 转义字符串 17 | * @param string $argument 18 | * @return string 19 | */ 20 | public static function escapeArgument($argument) 21 | { 22 | 23 | if ('' === $argument) { 24 | return escapeshellarg($argument); 25 | } 26 | $escapedArgument = ''; 27 | $quote = false; 28 | foreach (preg_split('/(")/i', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) { 29 | if ('"' === $part) { 30 | $escapedArgument .= '\\"'; 31 | } elseif (self::isSurroundedBy($part, '%')) { 32 | // Avoid environment variable expansion 33 | $escapedArgument .= '^%"' . substr($part, 1, -1) . '"^%'; 34 | } else { 35 | // escape trailing backslash 36 | if ('\\' === substr($part, -1)) { 37 | $part .= '\\'; 38 | } 39 | $quote = true; 40 | $escapedArgument .= $part; 41 | } 42 | } 43 | if ($quote) { 44 | $escapedArgument = '"' . $escapedArgument . '"'; 45 | } 46 | return $escapedArgument; 47 | } 48 | 49 | /** 50 | * 验证并进行规范化Process输入。 51 | * @param string $caller 52 | * @param mixed $input 53 | * @return string 54 | * @throws \InvalidArgumentException 55 | */ 56 | public static function validateInput($caller, $input) 57 | { 58 | if (null !== $input) { 59 | if (is_resource($input)) { 60 | return $input; 61 | } 62 | if (is_scalar($input)) { 63 | return (string) $input; 64 | } 65 | throw new \InvalidArgumentException(sprintf('%s only accepts strings or stream resources.', $caller)); 66 | } 67 | return $input; 68 | } 69 | 70 | private static function isSurroundedBy($arg, $char) 71 | { 72 | return 2 < strlen($arg) && $char === $arg[0] && $char === $arg[strlen($arg) - 1]; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /core/library/think/process/exception/Faild.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\process\exception; 13 | 14 | use think\Process; 15 | 16 | class Faild extends \RuntimeException 17 | { 18 | 19 | private $process; 20 | 21 | public function __construct(Process $process) 22 | { 23 | if ($process->isSuccessful()) { 24 | throw new \InvalidArgumentException('Expected a failed process, but the given process was successful.'); 25 | } 26 | 27 | $error = sprintf('The command "%s" failed.' . "\nExit Code: %s(%s)", $process->getCommandLine(), $process->getExitCode(), $process->getExitCodeText()); 28 | 29 | if (!$process->isOutputDisabled()) { 30 | $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", $process->getOutput(), $process->getErrorOutput()); 31 | } 32 | 33 | parent::__construct($error); 34 | 35 | $this->process = $process; 36 | } 37 | 38 | public function getProcess() 39 | { 40 | return $this->process; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /core/library/think/process/exception/Failed.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\process\exception; 13 | 14 | use think\Process; 15 | 16 | class Failed extends \RuntimeException 17 | { 18 | 19 | private $process; 20 | 21 | public function __construct(Process $process) 22 | { 23 | if ($process->isSuccessful()) { 24 | throw new \InvalidArgumentException('Expected a failed process, but the given process was successful.'); 25 | } 26 | 27 | $error = sprintf('The command "%s" failed.' . "\nExit Code: %s(%s)", $process->getCommandLine(), $process->getExitCode(), $process->getExitCodeText()); 28 | 29 | if (!$process->isOutputDisabled()) { 30 | $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", $process->getOutput(), $process->getErrorOutput()); 31 | } 32 | 33 | parent::__construct($error); 34 | 35 | $this->process = $process; 36 | } 37 | 38 | public function getProcess() 39 | { 40 | return $this->process; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /core/library/think/process/exception/Timeout.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\process\exception; 13 | 14 | use think\Process; 15 | 16 | class Timeout extends \RuntimeException 17 | { 18 | 19 | const TYPE_GENERAL = 1; 20 | const TYPE_IDLE = 2; 21 | 22 | private $process; 23 | private $timeoutType; 24 | 25 | public function __construct(Process $process, $timeoutType) 26 | { 27 | $this->process = $process; 28 | $this->timeoutType = $timeoutType; 29 | 30 | parent::__construct(sprintf('The process "%s" exceeded the timeout of %s seconds.', $process->getCommandLine(), $this->getExceededTimeout())); 31 | } 32 | 33 | public function getProcess() 34 | { 35 | return $this->process; 36 | } 37 | 38 | public function isGeneralTimeout() 39 | { 40 | return $this->timeoutType === self::TYPE_GENERAL; 41 | } 42 | 43 | public function isIdleTimeout() 44 | { 45 | return $this->timeoutType === self::TYPE_IDLE; 46 | } 47 | 48 | public function getExceededTimeout() 49 | { 50 | switch ($this->timeoutType) { 51 | case self::TYPE_GENERAL: 52 | return $this->process->getTimeout(); 53 | 54 | case self::TYPE_IDLE: 55 | return $this->process->getIdleTimeout(); 56 | 57 | default: 58 | throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType)); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /core/library/think/process/pipes/Pipes.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\process\pipes; 13 | 14 | abstract class Pipes 15 | { 16 | 17 | /** @var array */ 18 | public $pipes = []; 19 | 20 | /** @var string */ 21 | protected $inputBuffer = ''; 22 | /** @var resource|null */ 23 | protected $input; 24 | 25 | /** @var bool */ 26 | private $blocked = true; 27 | 28 | const CHUNK_SIZE = 16384; 29 | 30 | /** 31 | * 返回用于 proc_open 描述符的数组 32 | * @return array 33 | */ 34 | abstract public function getDescriptors(); 35 | 36 | /** 37 | * 返回一个数组的索引由其相关的流,以防这些管道使用的临时文件的文件名。 38 | * @return string[] 39 | */ 40 | abstract public function getFiles(); 41 | 42 | /** 43 | * 文件句柄和管道中读取数据。 44 | * @param bool $blocking 是否使用阻塞调用 45 | * @param bool $close 是否要关闭管道,如果他们已经到达 EOF。 46 | * @return string[] 47 | */ 48 | abstract public function readAndWrite($blocking, $close = false); 49 | 50 | /** 51 | * 返回当前状态如果有打开的文件句柄或管道。 52 | * @return bool 53 | */ 54 | abstract public function areOpen(); 55 | 56 | /** 57 | * {@inheritdoc} 58 | */ 59 | public function close() 60 | { 61 | foreach ($this->pipes as $pipe) { 62 | fclose($pipe); 63 | } 64 | $this->pipes = []; 65 | } 66 | 67 | /** 68 | * 检查系统调用已被中断 69 | * @return bool 70 | */ 71 | protected function hasSystemCallBeenInterrupted() 72 | { 73 | $lastError = error_get_last(); 74 | 75 | return isset($lastError['message']) && false !== stripos($lastError['message'], 'interrupted system call'); 76 | } 77 | 78 | protected function unblock() 79 | { 80 | if (!$this->blocked) { 81 | return; 82 | } 83 | 84 | foreach ($this->pipes as $pipe) { 85 | stream_set_blocking($pipe, 0); 86 | } 87 | if (null !== $this->input) { 88 | stream_set_blocking($this->input, 0); 89 | } 90 | 91 | $this->blocked = false; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /core/library/think/response/Json.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\response; 13 | 14 | use think\Response; 15 | 16 | class Json extends Response 17 | { 18 | // 输出参数 19 | protected $options = [ 20 | 'json_encode_param' => JSON_UNESCAPED_UNICODE, 21 | ]; 22 | 23 | protected $contentType = 'application/json'; 24 | 25 | /** 26 | * 处理数据 27 | * @access protected 28 | * @param mixed $data 要处理的数据 29 | * @return mixed 30 | * @throws \Exception 31 | */ 32 | protected function output($data) 33 | { 34 | try { 35 | // 返回JSON数据格式到客户端 包含状态信息 36 | $data = json_encode($data, $this->options['json_encode_param']); 37 | 38 | if (false === $data) { 39 | throw new \InvalidArgumentException(json_last_error_msg()); 40 | } 41 | 42 | return $data; 43 | } catch (\Exception $e) { 44 | if ($e->getPrevious()) { 45 | throw $e->getPrevious(); 46 | } 47 | throw $e; 48 | } 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /core/library/think/response/Jsonp.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\response; 13 | 14 | use think\Container; 15 | use think\Response; 16 | 17 | class Jsonp extends Response 18 | { 19 | // 输出参数 20 | protected $options = [ 21 | 'var_jsonp_handler' => 'callback', 22 | 'default_jsonp_handler' => 'jsonpReturn', 23 | 'json_encode_param' => JSON_UNESCAPED_UNICODE, 24 | ]; 25 | 26 | protected $contentType = 'application/javascript'; 27 | 28 | /** 29 | * 处理数据 30 | * @access protected 31 | * @param mixed $data 要处理的数据 32 | * @return mixed 33 | * @throws \Exception 34 | */ 35 | protected function output($data) 36 | { 37 | try { 38 | // 返回JSON数据格式到客户端 包含状态信息 [当url_common_param为false时是无法获取到$_GET的数据的,故使用Request来获取] 39 | $var_jsonp_handler = Container::get('request')->param($this->options['var_jsonp_handler'], ""); 40 | $handler = !empty($var_jsonp_handler) ? $var_jsonp_handler : $this->options['default_jsonp_handler']; 41 | 42 | $data = json_encode($data, $this->options['json_encode_param']); 43 | 44 | if (false === $data) { 45 | throw new \InvalidArgumentException(json_last_error_msg()); 46 | } 47 | 48 | $data = $handler . '(' . $data . ');'; 49 | 50 | return $data; 51 | } catch (\Exception $e) { 52 | if ($e->getPrevious()) { 53 | throw $e->getPrevious(); 54 | } 55 | throw $e; 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /core/library/think/response/Jump.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\response; 13 | 14 | use think\Container; 15 | use think\Response; 16 | 17 | class Jump extends Response 18 | { 19 | protected $contentType = 'text/html'; 20 | 21 | /** 22 | * 处理数据 23 | * @access protected 24 | * @param mixed $data 要处理的数据 25 | * @return mixed 26 | * @throws \Exception 27 | */ 28 | protected function output($data) 29 | { 30 | $config = Container::get('config'); 31 | $data = Container::get('view') 32 | ->init($config->pull('template')) 33 | ->fetch($this->options['jump_template'], $data); 34 | return $data; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/library/think/response/View.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\response; 13 | 14 | use think\Container; 15 | use think\Response; 16 | 17 | class View extends Response 18 | { 19 | // 输出参数 20 | protected $options = []; 21 | protected $vars = []; 22 | protected $filter; 23 | protected $contentType = 'text/html'; 24 | 25 | /** 26 | * 处理数据 27 | * @access protected 28 | * @param mixed $data 要处理的数据 29 | * @return mixed 30 | */ 31 | protected function output($data) 32 | { 33 | // 渲染模板输出 34 | $config = Container::get('config'); 35 | return Container::get('view') 36 | ->init($config->pull('template')) 37 | ->filter($this->filter) 38 | ->fetch($data, $this->vars); 39 | } 40 | 41 | /** 42 | * 获取视图变量 43 | * @access public 44 | * @param string $name 模板变量 45 | * @return mixed 46 | */ 47 | public function getVars($name = null) 48 | { 49 | if (is_null($name)) { 50 | return $this->vars; 51 | } else { 52 | return isset($this->vars[$name]) ? $this->vars[$name] : null; 53 | } 54 | } 55 | 56 | /** 57 | * 模板变量赋值 58 | * @access public 59 | * @param mixed $name 变量名 60 | * @param mixed $value 变量值 61 | * @return $this 62 | */ 63 | public function assign($name, $value = '') 64 | { 65 | if (is_array($name)) { 66 | $this->vars = array_merge($this->vars, $name); 67 | } else { 68 | $this->vars[$name] = $value; 69 | } 70 | 71 | return $this; 72 | } 73 | 74 | /** 75 | * 视图内容过滤 76 | * @access public 77 | * @param callable $filter 78 | * @return $this 79 | */ 80 | public function filter($filter) 81 | { 82 | $this->filter = $filter; 83 | return $this; 84 | } 85 | 86 | /** 87 | * 检查模板是否存在 88 | * @access private 89 | * @param string|array $name 参数名 90 | * @return bool 91 | */ 92 | public function exists($name) 93 | { 94 | return Container::get('view') 95 | ->init(Container::get('config')->pull('template')) 96 | ->exists($name); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /core/library/think/route/Dispatch.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\route; 13 | 14 | use think\Container; 15 | 16 | abstract class Dispatch 17 | { 18 | // 应用实例 19 | protected $app; 20 | // 调度信息 21 | protected $dispatch; 22 | // 调度参数 23 | protected $param; 24 | // 状态码 25 | protected $code; 26 | // 是否进行大小写转换 27 | protected $convert; 28 | 29 | public function __construct($dispatch, $param = [], $code = null) 30 | { 31 | $this->app = Container::get('app'); 32 | $this->dispatch = $dispatch; 33 | $this->param = $param; 34 | $this->code = $code; 35 | $this->init(); 36 | } 37 | 38 | protected function init() 39 | {} 40 | 41 | public function convert($convert) 42 | { 43 | $this->convert = $convert; 44 | 45 | return $this; 46 | } 47 | 48 | public function getDispatch() 49 | { 50 | return $this->dispatch; 51 | } 52 | 53 | public function getParam() 54 | { 55 | return $this->param; 56 | } 57 | 58 | abstract public function run(); 59 | 60 | } 61 | -------------------------------------------------------------------------------- /core/library/think/route/RuleName.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\route; 13 | 14 | class RuleName 15 | { 16 | protected $item = []; 17 | 18 | /** 19 | * 注册路由标识 20 | * @access public 21 | * @param string $name 路由标识 22 | * @param array $value 路由规则 23 | * @param bool $first 是否置顶 24 | * @return void 25 | */ 26 | public function set($name, $value, $first = false) 27 | { 28 | if ($first && isset($this->item[$name])) { 29 | array_unshift($this->item[$name], $value); 30 | } else { 31 | $this->item[$name][] = $value; 32 | } 33 | } 34 | 35 | /** 36 | * 导入路由标识 37 | * @access public 38 | * @param array $name 路由标识 39 | * @return void 40 | */ 41 | public function import($item) 42 | { 43 | $this->item = $item; 44 | } 45 | 46 | /** 47 | * 根据路由标识获取路由信息(用于URL生成) 48 | * @access public 49 | * @param string $name 路由标识 50 | * @return array|null 51 | */ 52 | public function get($name = null) 53 | { 54 | if (is_null($name)) { 55 | return $this->item; 56 | } 57 | 58 | $name = strtolower($name); 59 | 60 | return isset($this->item[$name]) ? $this->item[$name] : null; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /core/library/think/route/dispatch/Callback.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\route\dispatch; 13 | 14 | use think\Container; 15 | use think\route\Dispatch; 16 | 17 | class Callback extends Dispatch 18 | { 19 | public function run() 20 | { 21 | // 执行回调方法 22 | $vars = array_merge($this->app['request']->param(), $this->param); 23 | 24 | return Container::getInstance()->invoke($this->dispatch, $vars); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /core/library/think/route/dispatch/Controller.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\route\dispatch; 13 | 14 | use think\route\Dispatch; 15 | 16 | class Controller extends Dispatch 17 | { 18 | public function run() 19 | { 20 | // 执行控制器的操作方法 21 | $vars = array_merge($this->app['request']->param(), $this->param); 22 | 23 | return $this->app->action( 24 | $this->dispatch, $vars, 25 | $this->app->config('app.url_controller_layer'), 26 | $this->app->config('app.controller_suffix') 27 | ); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /core/library/think/route/dispatch/Redirect.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\route\dispatch; 13 | 14 | use think\Response; 15 | use think\route\Dispatch; 16 | 17 | class Redirect extends Dispatch 18 | { 19 | public function run() 20 | { 21 | return Response::create($this->dispatch, 'redirect')->code($this->code); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/library/think/route/dispatch/Response.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\route\dispatch; 13 | 14 | use think\route\Dispatch; 15 | 16 | class Response extends Dispatch 17 | { 18 | public function run() 19 | { 20 | return $this->dispatch; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/library/think/route/dispatch/View.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\route\dispatch; 13 | 14 | use think\Response; 15 | use think\route\Dispatch; 16 | 17 | class View extends Dispatch 18 | { 19 | public function run() 20 | { 21 | // 渲染模板输出 22 | $vars = array_merge($this->app['request']->param(), $this->param); 23 | 24 | return Response::create($this->dispatch, 'view')->assign($vars); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/library/think/template/driver/File.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\template\driver; 13 | 14 | use think\Exception; 15 | 16 | class File 17 | { 18 | /** 19 | * 写入编译缓存 20 | * @access public 21 | * @param string $cacheFile 缓存的文件名 22 | * @param string $content 缓存的内容 23 | * @return void|array 24 | */ 25 | public function write($cacheFile, $content) 26 | { 27 | // 检测模板目录 28 | $dir = dirname($cacheFile); 29 | 30 | if (!is_dir($dir)) { 31 | mkdir($dir, 0755, true); 32 | } 33 | 34 | // 生成模板缓存文件 35 | if (false === file_put_contents($cacheFile, $content)) { 36 | throw new Exception('cache write error:' . $cacheFile, 11602); 37 | } 38 | } 39 | 40 | /** 41 | * 读取编译编译 42 | * @access public 43 | * @param string $cacheFile 缓存的文件名 44 | * @param array $vars 变量数组 45 | * @return void 46 | */ 47 | public function read($cacheFile, $vars = []) 48 | { 49 | if (!empty($vars) && is_array($vars)) { 50 | // 模板阵列变量分解成为独立变量 51 | if (isset($vars['cacheFile'])) { 52 | $_think_cacheFile = $cacheFile; 53 | $cacheFile = $vars['cacheFile']; 54 | unset($vars['cacheFile'], $vars['_think_cacheFile']); 55 | extract($vars, EXTR_OVERWRITE); 56 | include $_think_cacheFile; 57 | return; 58 | } 59 | extract($vars); 60 | } 61 | 62 | //载入模版缓存文件 63 | include $cacheFile; 64 | } 65 | 66 | /** 67 | * 检查编译缓存是否有效 68 | * @access public 69 | * @param string $cacheFile 缓存的文件名 70 | * @param int $cacheTime 缓存时间 71 | * @return boolean 72 | */ 73 | public function check($cacheFile, $cacheTime) 74 | { 75 | // 缓存文件不存在, 直接返回false 76 | if (!file_exists($cacheFile)) { 77 | return false; 78 | } 79 | 80 | if (0 != $cacheTime && time() > filemtime($cacheFile) + $cacheTime) { 81 | // 缓存是否在有效期 82 | return false; 83 | } 84 | 85 | return true; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /core/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz-studio/zz-admin/99c6bbc5f93334ebb9cfae2353ac30074dae7cad/core/logo.png -------------------------------------------------------------------------------- /core/phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | ./library/think/*/tests/ 27 | 28 | 29 | 30 | 31 | 32 | ./library/ 33 | 34 | ./library/think/*/tests 35 | ./library/think/*/assets 36 | ./library/think/*/resources 37 | ./library/think/*/vendor 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /core/tpl/default_index.tpl: -------------------------------------------------------------------------------- 1 | *{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }

:) 2018新年快乐

ThinkPHP V5.1
12载初心不改(2006-2018) - 你值得信赖的PHP框架

'; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /core/tpl/dispatch_jump.tpl: -------------------------------------------------------------------------------- 1 | {__NOLAYOUT__} 2 | 3 | 4 | 5 | 6 | 跳转提示 7 | 17 | 18 | 19 |
20 | 21 | 22 |

:)

23 |

24 | 25 | 26 |

:(

27 |

28 | 29 | 30 |

31 |

32 | 页面自动 跳转 等待时间: 33 |

34 |
35 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /extend/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | Options +FollowSymlinks -Multiviews 3 | RewriteEngine On 4 | 5 | RewriteCond %{REQUEST_FILENAME} !-d 6 | RewriteCond %{REQUEST_FILENAME} !-f 7 | RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] 8 | 9 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zz-studio/zz-admin/99c6bbc5f93334ebb9cfae2353ac30074dae7cad/public/favicon.ico -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | // [ 应用入口文件 ] 13 | namespace think; 14 | 15 | // 加载基础文件 16 | require __DIR__ . '/../core/base.php'; 17 | 18 | // 支持事先使用静态方法设置Request对象和Config对象 19 | 20 | // 执行应用并响应 21 | Container::get('app')->run()->send(); -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /public/router.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | // $Id$ 12 | 13 | if (is_file($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SCRIPT_NAME"])) { 14 | return false; 15 | } else { 16 | require __DIR__ . "/index.php"; 17 | } 18 | -------------------------------------------------------------------------------- /public/static/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /route/admin.php: -------------------------------------------------------------------------------- 1 | - < | WECHAT: wx5ini99 11 | * / \ | DATETIME: 2018/4/19 12 | * // \\ | 13 | * //| . |\\ | 14 | * "'\ /'"_.-~^`'-. | 15 | * \ _ /--' ` | 16 | * ___)( )(___ |----------------------------------------- 17 | * (((__) (__))) | 高山仰止,景行行止.虽不能至,心向往之。 18 | * +---------------------------------------------------------------------- 19 | * | Copyright (c) 2017 http://www.zzstudio.net All rights reserved. 20 | * +---------------------------------------------------------------------- 21 | */ 22 | 23 | // 系统钩子管理验证 24 | Route::get('admin/hooks/add', 'admin/hooks/add'); 25 | Route::post('admin/hooks/add', 'admin/hooks/add')->validate('app\common\validate\Hooks', 'add'); 26 | Route::get('admin/hooks/edit', 'admin/hooks/edit')->validate(['id' => 'require|number']); 27 | Route::post('admin/hooks/edit', 'admin/hooks/edit')->model('id', 'app\common\model\Hooks')->validate('app\common\validate\Hooks', 'edit'); 28 | 29 | // 系统插件验证 30 | Route::post('admin/addons/preview', 'admin/addons/preview')->mergeExtraVars()->validate('app\common\validate\Addons'); 31 | Route::get('admin/addons/create', 'admin/addons/create'); 32 | Route::post('admin/addons/create', 'admin/addons/create')->validate('app\common\validate\Addons'); -------------------------------------------------------------------------------- /route/route.php: -------------------------------------------------------------------------------- 1 | - < | WECHAT: wx5ini99 11 | * / \ | DATETIME: 2018/4/19 12 | * // \\ | 13 | * //| . |\\ | 14 | * "'\ /'"_.-~^`'-. | 15 | * \ _ /--' ` | 16 | * ___)( )(___ |----------------------------------------- 17 | * (((__) (__))) | 高山仰止,景行行止.虽不能至,心向往之。 18 | * +---------------------------------------------------------------------- 19 | * | Copyright (c) 2017 http://www.zzstudio.net All rights reserved. 20 | * +---------------------------------------------------------------------- 21 | */ 22 | return [ 23 | 24 | ]; 25 | -------------------------------------------------------------------------------- /runtime/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /think: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | 11 | // +---------------------------------------------------------------------- 12 | 13 | namespace think; 14 | 15 | // 加载基础文件 16 | require __DIR__ . '/core/base.php'; 17 | 18 | // 执行应用 19 | Container::get('app', [__DIR__ . '/application/'])->initialize(); 20 | Console::init(); -------------------------------------------------------------------------------- /vendor/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore --------------------------------------------------------------------------------