作者 liyuhang

csdm

要显示太多修改。

为保证性能只显示 49 of 49+ 个文件。

  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.
  1 +ThinkPHP 5.0
  2 +===============
  3 +
  4 +[![Total Downloads](https://poser.pugx.org/topthink/think/downloads)](https://packagist.org/packages/topthink/think)
  5 +[![Latest Stable Version](https://poser.pugx.org/topthink/think/v/stable)](https://packagist.org/packages/topthink/think)
  6 +[![Latest Unstable Version](https://poser.pugx.org/topthink/think/v/unstable)](https://packagist.org/packages/topthink/think)
  7 +[![License](https://poser.pugx.org/topthink/think/license)](https://packagist.org/packages/topthink/think)
  8 +
  9 +ThinkPHP5在保持快速开发和大道至简的核心理念不变的同时,PHP版本要求提升到5.4,对已有的CBD模式做了更深的强化,优化核心,减少依赖,基于全新的架构思想和命名空间实现,是ThinkPHP突破原有框架思路的颠覆之作,其主要特性包括:
  10 +
  11 + + 基于命名空间和众多PHP新特性
  12 + + 核心功能组件化
  13 + + 强化路由功能
  14 + + 更灵活的控制器
  15 + + 重构的模型和数据库类
  16 + + 配置文件可分离
  17 + + 重写的自动验证和完成
  18 + + 简化扩展机制
  19 + + API支持完善
  20 + + 改进的Log类
  21 + + 命令行访问支持
  22 + + REST支持
  23 + + 引导文件支持
  24 + + 方便的自动生成定义
  25 + + 真正惰性加载
  26 + + 分布式环境支持
  27 + + 更多的社交类库
  28 +
  29 +> ThinkPHP5的运行环境要求PHP5.4以上。
  30 +
  31 +详细开发文档参考 [ThinkPHP5完全开发手册](http://www.kancloud.cn/manual/thinkphp5)
  32 +
  33 +## 目录结构
  34 +
  35 +初始的目录结构如下:
  36 +
  37 +~~~
  38 +www WEB部署目录(或者子目录)
  39 +├─application 应用目录
  40 +│ ├─common 公共模块目录(可以更改)
  41 +│ ├─module_name 模块目录
  42 +│ │ ├─config.php 模块配置文件
  43 +│ │ ├─common.php 模块函数文件
  44 +│ │ ├─controller 控制器目录
  45 +│ │ ├─model 模型目录
  46 +│ │ ├─view 视图目录
  47 +│ │ └─ ... 更多类库目录
  48 +│ │
  49 +│ ├─command.php 命令行工具配置文件
  50 +│ ├─common.php 公共函数文件
  51 +│ ├─config.php 公共配置文件
  52 +│ ├─route.php 路由配置文件
  53 +│ ├─tags.php 应用行为扩展定义文件
  54 +│ └─database.php 数据库配置文件
  55 +
  56 +├─public WEB目录(对外访问目录)
  57 +│ ├─index.php 入口文件
  58 +│ ├─router.php 快速测试文件
  59 +│ └─.htaccess 用于apache的重写
  60 +
  61 +├─thinkphp 框架系统目录
  62 +│ ├─lang 语言文件目录
  63 +│ ├─library 框架类库目录
  64 +│ │ ├─think Think类库包目录
  65 +│ │ └─traits 系统Trait目录
  66 +│ │
  67 +│ ├─tpl 系统模板目录
  68 +│ ├─base.php 基础定义文件
  69 +│ ├─console.php 控制台入口文件
  70 +│ ├─convention.php 框架惯例配置文件
  71 +│ ├─helper.php 助手函数文件
  72 +│ ├─phpunit.xml phpunit配置文件
  73 +│ └─start.php 框架入口文件
  74 +
  75 +├─extend 扩展类库目录
  76 +├─runtime 应用的运行时目录(可写,可定制)
  77 +├─vendor 第三方类库目录(Composer依赖库)
  78 +├─build.php 自动生成定义文件(参考)
  79 +├─composer.json composer 定义文件
  80 +├─LICENSE.txt 授权说明文件
  81 +├─README.md README 文件
  82 +├─think 命令行入口文件
  83 +~~~
  84 +
  85 +> router.php用于php自带webserver支持,可用于快速测试
  86 +> 切换到public目录后,启动命令:php -S localhost:8888 router.php
  87 +> 上面的目录结构和名称是可以改变的,这取决于你的入口文件和配置参数。
  88 +
  89 +## 命名规范
  90 +
  91 +`ThinkPHP5`遵循PSR-2命名规范和PSR-4自动加载规范,并且注意如下规范:
  92 +
  93 +### 目录和文件
  94 +
  95 +* 目录不强制规范,驼峰和小写+下划线模式均支持;
  96 +* 类库、函数文件统一以`.php`为后缀;
  97 +* 类的文件名均以命名空间定义,并且命名空间的路径和类库文件所在路径一致;
  98 +* 类名和类文件名保持一致,统一采用驼峰法命名(首字母大写);
  99 +
  100 +### 函数和类、属性命名
  101 +* 类的命名采用驼峰法,并且首字母大写,例如 `User`、`UserType`,默认不需要添加后缀,例如`UserController`应该直接命名为`User`
  102 +* 函数的命名使用小写字母和下划线(小写字母开头)的方式,例如 `get_client_ip`
  103 +* 方法的命名使用驼峰法,并且首字母小写,例如 `getUserName`
  104 +* 属性的命名使用驼峰法,并且首字母小写,例如 `tableName`、`instance`
  105 +* 以双下划线“__”打头的函数或方法作为魔法方法,例如 `__call` 和 `__autoload`
  106 +
  107 +### 常量和配置
  108 +* 常量以大写字母和下划线命名,例如 `APP_PATH`和 `THINK_PATH`
  109 +* 配置参数以小写字母和下划线命名,例如 `url_route_on` 和`url_convert`
  110 +
  111 +### 数据表和字段
  112 +* 数据表和字段采用小写加下划线方式命名,并注意字段名不要以下划线开头,例如 `think_user` 表和 `user_name`字段,不建议使用驼峰和中文作为数据表字段命名。
  113 +
  114 +## 参与开发
  115 +请参阅 [ThinkPHP5 核心框架包](https://github.com/top-think/framework)
  116 +
  117 +## 版权信息
  118 +
  119 +ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
  120 +
  121 +本项目包含的第三方源码和二进制文件之版权信息另行标注。
  122 +
  123 +版权所有Copyright © 2006-2016 by ThinkPHP (http://thinkphp.cn)
  124 +
  125 +All rights reserved。
  126 +
  127 +ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
  128 +
  129 +更多细节参阅 [LICENSE.txt](LICENSE.txt)
  1 +deny from all
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: asus
  5 + * Date: 2019/3/13
  6 + * Time: 10:30
  7 + */
  8 +return [
  9 + '200'=>'返回成功',
  10 + '202'=>'请求失败',
  11 +];
  1 +<?php
  2 +
  3 +namespace app\api\controller;
  4 +
  5 +use app\admin\controller\Base;
  6 +use app\admin\model\AdminLog as AdminLogModel;
  7 +
  8 +class AdminLog extends Base
  9 +{
  10 + /**
  11 + * @name:日志列表
  12 + * @return void
  13 + * @author :liyuhang
  14 + * @method :get
  15 + */
  16 + public function lists(){
  17 + //搜索条件处理
  18 + if(isset($this->param['text']) && !empty($this->param['text'])){
  19 + $this->param['text'] = ['like','%'.$this->param['text'].'%'];
  20 + }
  21 + $adminLogModel = new AdminLogModel();
  22 + $lists = $adminLogModel->manager()->where($this->param)->page($this->p, $this->row)->order('id desc')->select()->toArray();
  23 + $this->allCount = $adminLogModel->allCount;
  24 + $this->result($lists);
  25 + }
  26 +}
  1 +<?php
  2 +
  3 +namespace app\admin\controller;
  4 +
  5 +
  6 +use think\Cache;
  7 +use think\Config;
  8 +use think\Request;
  9 +use think\Response;
  10 +
  11 +class Base
  12 +{
  13 + protected $method; // 当前请求类型
  14 + protected $type; // 当前资源类型
  15 + // 输出类型
  16 + protected $_btw = [0, 0]; // 时间区间等
  17 + protected $url = '';//分享地址
  18 + protected $restMethodList = 'post,get';
  19 + protected $restDefaultType = '';
  20 + protected $header = []; //输出header数据
  21 + protected $request = [];
  22 + protected $accessToken = '';
  23 + protected $p = 1; //分页页数
  24 + protected $order = ""; //排序
  25 + protected $row = 10; //默认分页数
  26 + protected $user = []; //登录对象
  27 + protected $uid = 0;
  28 + protected $param = []; //post参数
  29 + protected $map = [];//post处理过后的参数
  30 + protected $allCount = 0; //数据总条数
  31 + protected $token = ''; //token
  32 + protected $allow_fun = [//登录不需要验证的方法
  33 + 'com'=>'*',
  34 + 'user'=>',login,'
  35 + ];
  36 + /**
  37 + * @name:公共方法参数处理
  38 + */
  39 + public function __construct(Request $request)
  40 + {
  41 + session_start();
  42 + // 指定允许其他域名访问
  43 + $http_origin = "*";
  44 + if(isset($_SERVER['HTTP_ORIGIN'])){
  45 + $http_origin = $_SERVER['HTTP_ORIGIN'];
  46 + }
  47 + header("Access-Control-Allow-Origin:".$http_origin);
  48 + header('Access-Control-Allow-Methods:POST,GET'); //支持的http 动作
  49 + header('Access-Control-Allow-Credentials: true');
  50 + header('Access-Control-Max-Age: 1000');
  51 + header('Access-Control-Allow-Headers:Origin, X-Requested-With, Content-Type, Accept, Authorization, token'); //响应头 请按照自己需求添加。
  52 + if (strtolower($_SERVER['REQUEST_METHOD']) == 'options') {
  53 + exit;
  54 + }
  55 + $this->request = $request;
  56 + $this->method = $request->method();
  57 + $this->param = $request->param();
  58 + $this->map = $request->get();
  59 + $this->get_data();
  60 + $this->validate();
  61 + $this->authToken();
  62 + }
  63 + /**
  64 + * @name:判断当前状态是否登录
  65 + */
  66 + private function authToken() {
  67 + $ctr = strtolower($this->request->controller());
  68 + $action = strtolower($this->request->action());
  69 + if(isset($this->allow_fun[$ctr]) && (($this->allow_fun[$ctr] == '*') || strpos($this->allow_fun[$ctr], sprintf(',%s,', $action)) > -1)){
  70 + return;
  71 + }
  72 + if (isset($this->param['token']) && !empty($this->param['token'])) {
  73 + $this->accessToken = $this->param['token'];
  74 + } else {
  75 + $this->accessToken = $this->request->header('token');
  76 + }
  77 + if(!Cache::has($this->accessToken)){
  78 + $this->response('请登录!', 202,[]);
  79 + }
  80 + //获取当前的session_id
  81 + $cache = Cache::get($this->accessToken);
  82 + if(!$cache){ //由于机器人没法登陆,需要跳过登陆验证
  83 + $this->response('请登录!', 202,[]);
  84 + }
  85 + $this->user = $cache;
  86 + if($cache){
  87 + $this->uid = $this->user['id'];
  88 + }
  89 + }
  90 +
  91 + /**
  92 + * 验证
  93 + * @return
  94 + */
  95 + private function validate() {
  96 + if (false === stripos($this->restMethodList, $this->method)) {
  97 + // 请求方式非法 则用默认请求方法
  98 + $this->response('请求方式非法', 203, '只允许' . $this->restMethodList);
  99 + }
  100 + $ctr = strtolower($this->request->controller());
  101 + $action = strtolower($this->request->action());
  102 + $config = Config::get('validate.'.$ctr.'_'.$action);
  103 + if(isset($config) && !empty($config)){
  104 + if(false === stripos($config['allow_method'], $this->method)){
  105 + $this->response('请求方式错误',203,'只允许'.$config['allow_method']);
  106 + }else{
  107 + $this->response('请配置请求方式',203,[]);
  108 + }
  109 + }
  110 + }
  111 + /**
  112 + * @name:get所有参数处理
  113 + */
  114 + private function get_data() {
  115 + //获取兼容路由参数
  116 + $get_data = array_merge($this->map, $this->request->route());
  117 + foreach ($get_data as $k => $v) {
  118 + if(is_array($v)){
  119 + continue;
  120 + }
  121 + switch ($k) {
  122 + case "order":
  123 + strpos($v, "-") > -1 ? $v = str_replace("-", " ", $v) : $v = $v . " desc";
  124 + $this->order = $v;
  125 + break;
  126 + case "p":
  127 + $this->p = $v;
  128 + break;
  129 + case "row":
  130 + $this->row = $v;
  131 + break;
  132 + case "name":
  133 + $this->map[$k] = ['like','%'.$v.'%'];
  134 + break;
  135 + case "start":
  136 + $this->_btw[0] = $v;
  137 + $this->_btw[1] = date('Y-m-d H:i:s',time());
  138 + $this->map['created_time'] = ['between', $this->_btw];
  139 + break;
  140 + case "end":
  141 + $this->_btw[1] = $v;
  142 + $this->map['created_time'] = ['between', $this->_btw];
  143 + break;
  144 + case "debug":
  145 + defined("DEBUG") || define("DEBUG", $v);
  146 + break;
  147 + case 'XDEBUG_SESSION_START':
  148 + break;
  149 + default:
  150 + if (!empty($v)) {
  151 + $this->map[$k] = $v;
  152 + }
  153 + break;
  154 + }
  155 + }
  156 + }
  157 + /**
  158 + * 生成图片文件地址
  159 + * @param type $sha1 sha1
  160 + * @param type $type image
  161 + * @return type
  162 + */
  163 + function getFileUrl($sha1, $type = 'image')
  164 + {
  165 + $url = '';
  166 + switch ($type) {
  167 + case 'image':
  168 + if (strpos($sha1, "http://") !== false) {
  169 + $url = $sha1;
  170 + } else {
  171 + $url = $sha1 ? url('/image/' . $sha1, '', '', true) : '';
  172 + }
  173 + break;
  174 + case 'images':
  175 + break;
  176 + case 'file':
  177 + $url = $sha1 ? url('/file/' . $sha1, '', '',true) : '';
  178 + break;
  179 + }
  180 + return $url;
  181 + }
  182 +
  183 + /**
  184 + * REST 调用
  185 + * @access public
  186 + * @param string $method 方法名
  187 + * @return mixed
  188 + * @throws Exception
  189 + */
  190 + public function _empty($method) {
  191 + $this->response('非法操作=>' . $method, 404);
  192 + }
  193 +
  194 + /**
  195 + * 通用数据输出
  196 + * @param $msg
  197 + * @param $code
  198 + * @param $data
  199 + * @param $result_code
  200 + * @param $type
  201 + * @return
  202 + */
  203 + protected function response($msg, $code = 200, $data = '', $result_code = null, $type = 'json') {
  204 + $result_code === null && $result_code = $code;
  205 + $result = [
  206 + 'code' => $result_code,
  207 + 'msg' => $msg,
  208 + 'data' => $this->_extents($data),
  209 + ];
  210 + $this->setHeader('X_End_Time', $this->request->time());
  211 + $response = Response::create($result, $type)->code($code)->header($this->header);
  212 + throw new \think\exception\HttpResponseException($response);
  213 + }
  214 + /**
  215 + * @name:返回参数处理
  216 + */
  217 + protected function _extents($data) {
  218 +
  219 + if (empty($data) || !is_array($data)) {
  220 + return empty($data) ? is_array($data) ? [] : '' : $data;
  221 + }
  222 + foreach ($data as $k => $v) {
  223 + if (is_array($v)) {
  224 + $data[$k] = $this->_extents($v);
  225 + } else {
  226 + if (is_null($v)) {
  227 + $data[$k] = '';
  228 + continue;
  229 + }
  230 + switch ((string) $k) {
  231 + case 'file':
  232 + $data[$k . '_link'] = getFileUrl($v, 'file');
  233 + break;
  234 + }
  235 + }
  236 + }
  237 + return $data;
  238 + }
  239 +
  240 +
  241 + /**
  242 + * 设置header
  243 + * @param $name
  244 + * @param $value
  245 + * @return
  246 + */
  247 + protected function setHeader($name, $value) {
  248 + if (is_array($name)) {
  249 + $this->header = array_merge($this->header, $name);
  250 + } else {
  251 + $this->header[$name] = $value;
  252 + }
  253 + return $this;
  254 + }
  255 +
  256 + /**
  257 + * post方法请求输出数据
  258 + * @param $data
  259 + * @return
  260 + */
  261 + public function result($list) {
  262 + $data['data'] = $list;
  263 + $data['page'] = $this->setPages();
  264 + $this->response('success', 200, $data);
  265 +
  266 + }
  267 + /**
  268 + * @name:请求头设置分页返回参数()
  269 + * @return
  270 + */
  271 + public function setPages() {
  272 + $page_count = $this->allCount > $this->row ? ceil($this->allCount / $this->row) : 1;
  273 + $this->setHeader('X-Pagination-Total-Count', $this->allCount); //总条数
  274 + $this->setHeader('X-Pagination-Page-Count', $page_count); //总页数
  275 + $this->setHeader('X-Pagination-Current-Page', $this->p); //当前页数
  276 + $this->setHeader('X-Pagination-Per-Page', $this->row); //每页条数
  277 + }
  278 +
  279 + /**
  280 + * @name:上传文件返回文件名
  281 + * @return
  282 + */
  283 + public function upload($file_name = ''){
  284 + $files = $this->request->file('file');
  285 + if(empty($files)){
  286 + return $this->response('没有上传文件',202);
  287 + }
  288 + if(empty($file_name)){
  289 + $res = $files->rule('uniqid')->move(ROOT_PATH.'./uploads/');
  290 + }else{
  291 + $res = $files->rule('uniqid')->move(ROOT_PATH.'./uploads/'.$file_name);
  292 + }
  293 + if($res === false){
  294 + return $this->response($files->getError(),202);
  295 + }
  296 + $path = $res->getSaveName();
  297 + return $path;
  298 + }
  299 +
  300 + /**
  301 + * @name:上传返回文件详情
  302 + */
  303 + public function uploads(){
  304 + $files = $this->request->file('file');
  305 + if(empty($files)){
  306 + return $this->response('没有上传文件',202);
  307 + }
  308 + if(empty($file_name)){
  309 + $res = $files->rule('uniqid')->move(ROOT_PATH.'./uploads/');
  310 + }else{
  311 + $res = $files->rule('uniqid')->move(ROOT_PATH.'./uploads/'.$file_name);
  312 + }
  313 + if($res === false){
  314 + return $this->response($files->getError(),202);
  315 + }
  316 + $data['path'] = $res->getSaveName();
  317 + $data['size'] = $res->getSize();
  318 + return $data;
  319 + }
  320 +}
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: asus
  5 + * Date: 2019/6/12
  6 + * Time: 11:08
  7 + */
  8 +
  9 +namespace app\api\controller;
  10 +
  11 +
  12 +use think\captcha\Captcha;
  13 +use think\Validate;
  14 +use app\api\model\Manager as ManagerModel;
  15 +class Com extends Base
  16 +{
  17 + /**
  18 + * @name:获取验证码
  19 + * @method:get
  20 + */
  21 + public function code(){
  22 + $this->response('验证码',200,'111');
  23 + $config = [
  24 + // 验证码字体大小
  25 + 'fontSize' => 30,
  26 + // 验证码位数
  27 + 'length' => 6,
  28 + // 关闭验证码杂点
  29 + 'useNoise' => false,
  30 + ];
  31 + $captcha = new Captcha($config);
  32 + Session::set('captcha',);
  33 + $this->response('验证码',200,$captcha->entry());
  34 + }
  35 + /**
  36 + * 管理员登录
  37 + * @method:post
  38 + * @param $account $password
  39 + */
  40 + public function login(){
  41 + $rule = [
  42 + ['account','require|max:15','账号不能为空|最多不能超过25个字符'],
  43 + ['password','require|max:30','密码不能为空|必须在1~50字符之间'],
  44 + ];
  45 + $validate = new Validate($rule);
  46 + if ($validate->check($this->param) === false) {
  47 + $this->response($validate->getError(), 202);
  48 + }
  49 + $manager = new ManagerModel();
  50 + $info = $manager->login($this->param['account'],$this->param['password']);
  51 + if(empty($info)){
  52 + $this->response('账号或者密码错误',202,[]);
  53 + }
  54 + $this->response('登录成功',200,$info);
  55 + }
  56 +}
  1 +<?php
  2 +
  3 +namespace app\api\controller;
  4 +
  5 +use app\admin\controller\Base;
  6 +use app\admin\model\Manager as ManagerModel;
  7 +use think\Validate;
  8 +
  9 +/**
  10 + * @name:管理员管理
  11 +*/
  12 +class Manager extends Base
  13 +{
  14 + /**
  15 + * @name:获取管理员列表
  16 + * @method:get
  17 + * @param /p:页数 row:条数
  18 + */
  19 + public function lists(){
  20 + $managerModel = new ManagerModel();
  21 + $lists = $managerModel->lists($this->param,$this->p,$this->row,'sort desc');
  22 + $this->allCount = $managerModel->allCount;
  23 + $this->result($lists);
  24 + }
  25 +
  26 + /**
  27 + * @name:添加管理员
  28 + * @method:post
  29 + * @param:
  30 + */
  31 + public function add(){
  32 + /*参数验证*/
  33 + $rules = [
  34 + ['username','require|max:25','名称必须|名称最多不能超过25个字符'],
  35 + ['password','password|between:6,25','密码必须|年龄必须在6~26之间'],
  36 + ['re_password','require||confirm:password','密码必须|两次密码不一致'],
  37 + ];
  38 + $validate = new Validate($rules);
  39 + $res = $validate->check($this->param);
  40 + if(!$res){
  41 + $this->response($validate->getError(),400,[]);
  42 + }
  43 + $managerModel = new ManagerModel();
  44 + $res = $managerModel->add($this->param);
  45 + if($res === false){
  46 + $this->response('添加失败',202,[]);
  47 + }
  48 + $this->response('添加成功',200);
  49 + }
  50 +
  51 + /**
  52 + * @name : 编辑管理员
  53 + * @return void
  54 + * @author :liyuhang
  55 + * @method
  56 + */
  57 +
  58 + public function edit(){
  59 + $rules = [
  60 + ['id','require','必须'],
  61 + ];
  62 + if(isset($this->param['password']) && !empty($this->param['password'])){
  63 + array_push($rules,['password','password|between:6,25','密码必须|年龄必须在6~26之间']);
  64 + array_push($rules,['re_password','require||confirm:password','密码必须|两次密码不一致']);
  65 + }
  66 + $validate = new Validate($rules);
  67 + $res = $validate->check($this->param);
  68 + if(!$res){
  69 + $this->response($validate->getError(),400,[]);
  70 + }
  71 + $managerModel = new ManagerModel();
  72 + if(isset($this->param['password'])){
  73 + $this->param['password'] = think_center_md5($this->param['password']);
  74 + }
  75 + $res = $managerModel->edit($this->param,['id'=>$this->param['id']]);
  76 + if($res === false){
  77 + $this->response('编辑失败',202,[]);
  78 + }
  79 + $this->response('编辑成功',200);
  80 + }
  81 +
  82 + /**
  83 + * @name :修改当前管理员状态
  84 + * @return void
  85 + * @author :liyuhang
  86 + * @method
  87 + */
  88 + public function status()
  89 + {
  90 + /*参数验证*/
  91 + $rules = [
  92 + ['id','require','必须'],
  93 + ['status','require','必须'],
  94 + ];
  95 + $validate = new Validate($rules);
  96 + $res = $validate->check($this->param);
  97 + if(!$res){
  98 + $this->response($validate->getError(),202,[]);
  99 + }
  100 + $managerModel = new ManagerModel();
  101 + $info = $managerModel->read(['id'=>$this->param['id']]);
  102 + if(empty($info)){
  103 + $this->response('当前管理员不存在','');
  104 + }
  105 + $res = $managerModel->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]);
  106 + if ($res === false) {
  107 + $this->response('修改状态失败',202,[]);
  108 + } else {
  109 + $this->response($this->param['status'] == 1 ? '启用成功': '禁用成功',200,[]);
  110 + }
  111 + }
  112 +
  113 + /**
  114 + * @name:排序
  115 + * @return void
  116 + * @author :liyuhang
  117 + * @method
  118 + */
  119 + public function sort()
  120 + {
  121 + /*参数验证*/
  122 + $rules = [
  123 + ['id','require','必须'],
  124 + ['sort','require','必须'],
  125 + ];
  126 + $validate = new Validate($rules);
  127 + $res = $validate->check($this->param);
  128 + if(!$res){
  129 + $this->response($validate->getError(),202,[]);
  130 + }
  131 + $res = ManagerModel::where('id', $this->param['id'])->update(['sort' => $this->param['sort']]);
  132 + if ($res === false) {
  133 + $this->response('排序失败',202,[]);
  134 + } else {
  135 + $this->response('成功',200,[]);;
  136 + }
  137 + }
  138 +
  139 + /**
  140 + * @name
  141 + * @return void
  142 + * @author :liyuhang
  143 + * @method
  144 + */
  145 + public function delete(){
  146 + $rules = [
  147 + ['id','require','必须'],
  148 + ];
  149 + $validate = new Validate($rules);
  150 + $res = $validate->check($this->param);
  151 + if(!$res){
  152 + $this->response($validate->getError(),202,[]);
  153 + }
  154 + $managerModel = new ManagerModel();
  155 + $res = $managerModel->edit(['deleted'=>0],['id'=>$this->param['id']]);
  156 + if ($res === false) {
  157 + $this->response('排序失败',202,[]);
  158 + } else {
  159 + $this->response('成功',200,[]);;
  160 + }
  161 + }
  162 +}
  1 +<?php
  2 +
  3 +/**
  4 + * 验证规则
  5 + */
  6 +return [
  7 + 'manager_lists' => [
  8 + 'allow_method' => 'get',
  9 + ],
  10 + 'manager_add' => [
  11 + 'allow_method' => 'post',
  12 + ],
  13 + 'manager_edit' => [
  14 + 'allow_method' => 'post',
  15 + ],
  16 + 'manager_status' => [
  17 + 'allow_method' => 'get',
  18 + ],
  19 + 'com_code' => [
  20 + 'allow_method' => 'post',
  21 + ],
  22 +];
  1 +<?php
  2 +
  3 +namespace app\admin\model;
  4 +
  5 +class AdminLog extends Base
  6 +{
  7 + protected $autoWriteTimestamp = 'datetime';
  8 +
  9 + /**
  10 + * @name 一对多
  11 + * @return \think\model\relation\HasMany
  12 + * @author :liyuhang
  13 + * @method
  14 + */
  15 + public function manager()
  16 + {
  17 + return $this->hasMany('manager')->field('username');
  18 + }
  19 +}
  1 +<?php
  2 +
  3 +namespace app\admin\model;
  4 +
  5 +use think\Model;
  6 +
  7 +/**
  8 + * 模型基类
  9 + */
  10 +abstract class Base extends Model
  11 +{
  12 +
  13 + public $allCount = 0;
  14 + protected $resultSetType = 'collection';
  15 +
  16 + /**
  17 + * 列表
  18 + * @param $map
  19 + * @param $p
  20 + * @param $row
  21 + * @param string $order
  22 + * @param $fields
  23 + * @return $lists
  24 + */
  25 + public function lists($map, $p, $row, $order = 'id desc', $fields = true)
  26 + {
  27 + $order || $order = 'id desc';
  28 + $lists = $this->field($fields)->where($map)->page($p, $row)->order($order)->select()->toArray();
  29 + if (!empty($lists)) {
  30 + $this->allCount = $this->where($map)->count();
  31 + }
  32 + return $lists;
  33 + }
  34 + /**
  35 + * 详情
  36 + * @param $data
  37 + * @return $info
  38 + */
  39 + protected function read($data)
  40 + {
  41 + $info = $this->where($data)->find();
  42 + if (!empty($info)) {
  43 + $info = $info->toArray();
  44 + }
  45 + return $info;
  46 + }
  47 +
  48 + /*
  49 + * 新增
  50 + * @param array $data
  51 + * @return bool
  52 + */
  53 + public function add($data)
  54 + {
  55 + return $this->allowField(true)->save($data);
  56 + }
  57 +
  58 + /*
  59 + * 更新
  60 + * @param array $update
  61 + * @param array $condition
  62 + * @return bool
  63 + */
  64 + public function edit($update, $condition)
  65 + {
  66 + return $this->isUpdate(true)->allowField(true)->save($update, $condition);
  67 + }
  68 +
  69 + /*
  70 + * 删除
  71 + * @param array $condition
  72 + * @return bool
  73 + */
  74 + public function del($condition)
  75 + {
  76 + return $this->destroy($condition);
  77 + }
  78 +
  79 +}
  1 +<?php
  2 +
  3 +namespace app\admin\model;
  4 +
  5 +class Manager extends Base
  6 +{
  7 + protected $autoWriteTimestamp = 'datetime';
  8 +
  9 +
  10 +}
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: asus
  5 + * Date: 2019/3/13
  6 + * Time: 10:30
  7 + */
  8 +return [
  9 + '200'=>'返回成功',
  10 + '202'=>'请求失败',
  11 + '203'=>'请求方式错误'
  12 +];
  1 +<?php
  2 +namespace app\api\controller;
  3 +
  4 +use think\Cache;
  5 +use think\Config;
  6 +use think\Request;
  7 +use think\Response;
  8 +use think\Validate;
  9 +/**
  10 + * 接口基类
  11 + * @author liyuhang <523277027@qq.com>
  12 + */
  13 +abstract class Base{
  14 + protected $method; // 当前请求类型
  15 + protected $type; // 当前资源类型
  16 + // 输出类型
  17 + protected $_btw = [0, 0]; // 时间区间等
  18 + protected $url = '';//分享地址
  19 + protected $restMethodList = 'post,get';
  20 + protected $restDefaultType = '';
  21 + protected $header = []; //输出header数据
  22 + protected $request = [];
  23 + protected $accessToken = '';
  24 + protected $p = 1; //分页页数
  25 + protected $order = ""; //排序
  26 + protected $row = 10; //默认分页数
  27 + protected $user = []; //登录对象
  28 + protected $uid = 0;
  29 + protected $param = []; //post参数
  30 + protected $map = [];//post处理过后的参数
  31 + protected $allCount = 0; //数据总条数
  32 + protected $token = ''; //token
  33 + protected $allow_fun = [//登录不需要验证的方法
  34 + 'com'=>'*',
  35 + 'user'=>',login,'
  36 + ];
  37 +
  38 + /**
  39 + * 架构函数 取得模板对象实例
  40 + * @access public
  41 + */
  42 + public function __construct(Request $request) {
  43 + session_start();
  44 + // 指定允许其他域名访问
  45 + $http_origin = "*";
  46 + if(isset($_SERVER['HTTP_ORIGIN'])){
  47 + $http_origin = $_SERVER['HTTP_ORIGIN'];
  48 + }
  49 + header("Access-Control-Allow-Origin:".$http_origin);
  50 + header('Access-Control-Allow-Methods:POST,GET'); //支持的http 动作
  51 + header('Access-Control-Allow-Credentials: true');
  52 + header('Access-Control-Max-Age: 1000');
  53 + header('Access-Control-Allow-Headers:Origin, X-Requested-With, Content-Type, Accept, Authorization, token'); //响应头 请按照自己需求添加。
  54 + if (strtolower($_SERVER['REQUEST_METHOD']) == 'options') {
  55 + exit;
  56 + }
  57 + $this->request = $request;
  58 + $referer = $this->request->server('referer');
  59 + if ($referer && strpos($referer, 'www.*.com') > -1) {
  60 + $this->response('系统检测到您的环境存在安全风险,拒绝了您的访问!', 503);
  61 + }
  62 + // 请求方式检测
  63 + $this->method = strtolower($request->method());
  64 + $this->param = $this->request->param();
  65 + $this->map = $this->request->get();
  66 + $this->_getdata();
  67 + $this->validate();
  68 + $this->authToken();
  69 + }
  70 + /**
  71 + * @name:判断当前状态是否登录
  72 + */
  73 + private function authToken() {
  74 + $ctr = strtolower($this->request->controller());
  75 + $action = strtolower($this->request->action());
  76 + if(isset($this->allow_fun[$ctr]) && (($this->allow_fun[$ctr] == '*') || strpos($this->allow_fun[$ctr], sprintf(',%s,', $action)) > -1)){
  77 + return;
  78 + }
  79 + if (isset($this->param['token']) && !empty($this->param['token'])) {
  80 + $this->accessToken = $this->param['token'];
  81 + } else {
  82 + $this->accessToken = $this->request->header('token');
  83 + }
  84 + if(!Cache::has($this->accessToken)){
  85 + $this->response('请登录!', 202,[]);
  86 + }
  87 + //获取当前的session_id
  88 + $cache = Cache::get($this->accessToken);
  89 + if(!$cache){ //由于机器人没法登陆,需要跳过登陆验证
  90 + $this->response('请登录!', 202,[]);
  91 + }
  92 + $this->user = $cache;
  93 + if($cache){
  94 + $this->uid = $this->user['id'];
  95 + }
  96 + }
  97 +
  98 + /**
  99 + * 验证
  100 + * @return
  101 + */
  102 + private function validate() {
  103 + if (false === stripos($this->restMethodList, $this->method)) {
  104 + // 请求方式非法 则用默认请求方法
  105 + $this->response('请求方式非法', 415, '只允许' . $this->restMethodList);
  106 + }
  107 + $ctr = strtolower($this->request->controller());
  108 + $action = strtolower($this->request->action());
  109 + $config = Config::get('validate.'.$ctr.'_'.$action);
  110 + if(isset($config) || !empty($config)){
  111 + if(false === stripos($config['allow_method'], $this->method)){
  112 + $this->response('请求方式错误',415,'只允许'.$config['allow_method']);
  113 + }
  114 + }
  115 + }
  116 + /**
  117 + * post公共参数初始化
  118 + */
  119 + private function _getdata() {
  120 + //获取兼容路由参数
  121 + $getdata = array_merge($this->request->param(), $this->request->route());
  122 + foreach ($getdata as $k => $v) {
  123 +
  124 + if(is_array($v)){
  125 + continue;
  126 + }
  127 + switch ($k) {
  128 + case "order":
  129 + strpos($v, "-") > -1 ? $v = str_replace("-", " ", $v) : $v = $v . " desc";
  130 + $this->order = $v;
  131 + break;
  132 + case "p":
  133 + $this->p = $v;
  134 + break;
  135 + case "row":
  136 + $this->row = $v;
  137 + break;
  138 + case "name":
  139 + $this->map[$k] = ['like','%'.$v.'%'];
  140 + break;
  141 + case "start":
  142 + $this->_btw[0] = $v;
  143 + $this->_btw[1] = date('Y-m-d H:i:s',time());
  144 + $this->map['created_time'] = ['between', $this->_btw];
  145 + break;
  146 + case "end":
  147 + $this->_btw[1] = $v;
  148 + $this->map['created_time'] = ['between', $this->_btw];
  149 + break;
  150 + case "debug":
  151 + defined("DEBUG") || define("DEBUG", $v);
  152 + break;
  153 + case 'XDEBUG_SESSION_START':
  154 + break;
  155 + default:
  156 + if (!empty($v)) {
  157 + $this->map[$k] = $v;
  158 + }
  159 + break;
  160 + }
  161 + }
  162 + }
  163 +
  164 + /**
  165 + * REST 调用
  166 + * @access public
  167 + * @param string $method 方法名
  168 + * @return mixed
  169 + * @throws Exception
  170 + */
  171 + public function _empty($method) {
  172 + $this->response('非法操作=>' . $method, 404);
  173 + }
  174 +
  175 + /**
  176 + * 通用数据输出
  177 + * @param $msg
  178 + * @param $code
  179 + * @param $data
  180 + * @param $result_code
  181 + * @param $type
  182 + * @return
  183 + */
  184 + protected function response($msg, $code = 200, $data = '', $result_code = null, $type = 'json') {
  185 + $result_code === null && $result_code = $code;
  186 + $result = [
  187 + 'code' => $result_code,
  188 + 'msg' => $msg,
  189 + 'data' => $this->_extents($data),
  190 + ];
  191 + $this->setHeader('X_End_Time', $this->request->time());
  192 + $response = Response::create($result, $type)->code($code)->header($this->header);
  193 + throw new \think\exception\HttpResponseException($response);
  194 + }
  195 +
  196 + /**
  197 + * post方法请求输出数据
  198 + * @param $data
  199 + * @return
  200 + */
  201 + protected function result($list) {
  202 + $data['data'] = $list;
  203 + $data['page'] = $this->setPages();
  204 + $this->response('success', 200, $data);
  205 +
  206 + }
  207 +
  208 + protected function _extents($data) {
  209 +
  210 + if (empty($data) || !is_array($data)) {
  211 + return empty($data) ? is_array($data) ? [] : '' : $data;
  212 + }
  213 + foreach ($data as $k => $v) {
  214 + if (is_array($v)) {
  215 + $data[$k] = $this->_extents($v);
  216 + } else {
  217 + if (is_null($v)) {
  218 + $data[$k] = '';
  219 + continue;
  220 + }
  221 + switch ((string) $k) {
  222 + case 'file':
  223 + $data[$k . '_link'] = getFileUrl($v, 'file');
  224 + break;
  225 + }
  226 + }
  227 + }
  228 + return $data;
  229 + }
  230 +
  231 + /**
  232 + * 设置header
  233 + * @param $name
  234 + * @param $value
  235 + * @return
  236 + */
  237 + protected function setHeader($name, $value) {
  238 + if (is_array($name)) {
  239 + $this->header = array_merge($this->header, $name);
  240 + } else {
  241 + $this->header[$name] = $value;
  242 + }
  243 + return $this;
  244 + }
  245 +
  246 + /**
  247 + * 请求头设置分页返回参数()
  248 + */
  249 + public function setPage() {
  250 +
  251 + $page_count = $this->allCount > $this->row ? ceil($this->allCount / $this->row) : 1;
  252 + $this->setHeader('X-Pagination-Total-Count', $this->allCount); //总条数
  253 + $this->setHeader('X-Pagination-Page-Count', $page_count); //总页数
  254 + $this->setHeader('X-Pagination-Current-Page', $this->p); //当前页数
  255 + $this->setHeader('X-Pagination-Per-Page', $this->row); //每页条数
  256 + }
  257 +
  258 + /**
  259 + * 直接返回设置分页返回参数()
  260 + */
  261 + protected function setPages() {
  262 + $page_count = $this->allCount > $this->row ? ceil($this->allCount / $this->row) : 1;
  263 + $this->header['Total-Count'] = $this->allCount; //总条数
  264 + $this->header['Page-Count'] = $page_count; //总页数
  265 + $this->header['Current-Page'] = $this->p; //当前页数
  266 + $this->header['Per-Page'] = $this->row; //每页条数
  267 + return $this->header;
  268 + }
  269 +
  270 + //敏感词过滤
  271 + protected function badword($content) {
  272 + $str = str_replace(explode('|', config('sensitive_words')), '***', $content);
  273 + return $str;
  274 + }
  275 +
  276 +}
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: asus
  5 + * Date: 2019/6/12
  6 + * Time: 11:08
  7 + */
  8 +
  9 +namespace app\api\controller;
  10 +
  11 +
  12 +use think\captcha\Captcha;
  13 +use think\Validate;
  14 +use app\api\model\Manager as ManagerModel;
  15 +class Com extends Base
  16 +{
  17 + /**
  18 + * @name:获取验证码
  19 + * @method:get
  20 + */
  21 + public function code(){
  22 + $this->response('验证码',200,'111');
  23 + $config = [
  24 + // 验证码字体大小
  25 + 'fontSize' => 30,
  26 + // 验证码位数
  27 + 'length' => 6,
  28 + // 关闭验证码杂点
  29 + 'useNoise' => false,
  30 + ];
  31 + $captcha = new Captcha($config);
  32 + $this->response('验证码',200,$captcha->entry());
  33 + }
  34 + /**
  35 + * 管理员登录
  36 + * @method:post
  37 + * @param $account $password
  38 + */
  39 + public function login(){
  40 + $rule = [
  41 + ['account','require|max:15','账号不能为空|最多不能超过25个字符'],
  42 + ['password','require|max:30','密码不能为空|必须在1~50字符之间'],
  43 + ];
  44 + $validate = new Validate($rule);
  45 + if ($validate->check($this->param) === false) {
  46 + $this->response($validate->getError(), 202);
  47 + }
  48 + $manager = new ManagerModel();
  49 + $info = $manager->login($this->param['account'],$this->param['password']);
  50 + if(empty($info)){
  51 + $this->response('账号或者密码错误',202,[]);
  52 + }
  53 + $this->response('登录成功',200,$info);
  54 + }
  55 +}
  1 +<?php
  2 +
  3 +/**
  4 + * 验证规则
  5 + */
  6 +return [
  7 + 'com_code' => [
  8 + 'allow_method' => 'post',
  9 + 'param' => [
  10 +
  11 + ],
  12 + ],
  13 +];
  1 +<?php
  2 +
  3 +namespace app\api\model;
  4 +
  5 +use think\Model;
  6 +
  7 +/**
  8 + * 模型基类
  9 + */
  10 +abstract class Base extends Model
  11 +{
  12 +
  13 + public $allCount = 0;
  14 + protected $resultSetType = 'collection';
  15 +
  16 + /**
  17 + * 列表
  18 + * @param $map
  19 + * @param $p
  20 + * @param $row
  21 + * @param string $order
  22 + * @param $fields
  23 + * @return $lists
  24 + */
  25 + public function lists($map, $p, $row, $order = 'id desc', $fields = true)
  26 + {
  27 + $order || $order = 'id desc';
  28 + $lists = $this->field($fields)->where($map)->page($p, $row)->order($order)->select()->toArray();
  29 + if (!empty($lists)) {
  30 + $this->allCount = $this->where($map)->count();
  31 + }
  32 + return $lists;
  33 + }
  34 + /**
  35 + * 详情
  36 + * @param $data
  37 + * @return $info
  38 + */
  39 + protected function read($data)
  40 + {
  41 + $info = $this->where($data)->find();
  42 + if (!empty($info)) {
  43 + $info = $info->toArray();
  44 + }
  45 + return $info;
  46 + }
  47 +
  48 + /*
  49 + * 新增
  50 + * @param array $data
  51 + * @return bool
  52 + */
  53 + public function add($data)
  54 + {
  55 + return $this->allowField(true)->save($data);
  56 + }
  57 +
  58 + /*
  59 + * 更新
  60 + * @param array $update
  61 + * @param array $condition
  62 + * @return bool
  63 + */
  64 + public function edit($update, $condition)
  65 + {
  66 + return $this->allowField(true)->save($update, $condition);
  67 + }
  68 +
  69 + /*
  70 + * 删除
  71 + * @param array $condition
  72 + * @return bool
  73 + */
  74 + public function del($condition)
  75 + {
  76 + return $this->destroy($condition);
  77 + }
  78 +
  79 +}
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: asus
  5 + * Date: 2019/11/26
  6 + * Time: 10:49
  7 + */
  8 +
  9 +namespace app\api\model;
  10 +
  11 +
  12 +use think\Cache;
  13 +
  14 +class Manager extends Base
  15 +{
  16 + protected $autoWriteTimestamp = 'datetime';
  17 +
  18 + /**
  19 + * 登录 @param $account:账号 $password:密码
  20 + */
  21 + public function login($account,$password){
  22 + //获取当前用户的账号详情
  23 + $info = $this->read(['account'=>$account,'password'=>$password]);
  24 + if(empty($info) || $info['status'] == 1){
  25 + return [];
  26 + }
  27 + //更新数据
  28 + $token = sha1(uniqid());
  29 + $last_login_time = date('Y-m-d H:i:s',time());
  30 + $last_ip = request()->ip();
  31 + //更新登录时间与登录ip
  32 + $rs = $this->edit(['token'=>$token,'update_time'=>$last_login_time,'last_ip'=>$last_ip],['id'=>$info['id']]);
  33 + if($rs === false){
  34 + return [];
  35 + }
  36 + //清空上一次缓存,实现单点登录
  37 + Cache::rm($info['token']);
  38 + //更新
  39 + $info['token'] = $token;
  40 + $info['update_time'] = $last_login_time;
  41 + $info['last_ip'] = $last_ip;
  42 + //过滤密码
  43 + unset($info['password']);
  44 + //生成缓存
  45 + $expire = 3600 * 24 * 7;
  46 + Cache::set($token, $info, $expire);
  47 + return $info;
  48 + }
  49 +}
  1 +<?php
  2 +// +----------------------------------------------------------------------
  3 +// | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4 +// +----------------------------------------------------------------------
  5 +// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
  6 +// +----------------------------------------------------------------------
  7 +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8 +// +----------------------------------------------------------------------
  9 +// | Author: yunwuxin <448901948@qq.com>
  10 +// +----------------------------------------------------------------------
  11 +
  12 +return [];
  1 +<?php
  2 +use OSS\OssClient; // | OSS客户端类,用户通过OssClient的实例调用接口 |
  3 +use OSS\Core\OssException; // | OSS异常类,用户在使用的过程中,只需要注意这个异常|
  4 +
  5 +// 应用公共文件
  6 +define('MANAGER_AUTH_KEY', 'k]J$[8b)%0Fv=lmecB3qI|D4@#LdC`xOaN6-{QWZ'); //加密KEY
  7 +//获取毫秒
  8 +function getMillisecond()
  9 +{
  10 + list($t1, $t2) = explode(' ', microtime());
  11 + return (float) sprintf('%.0f', (floatval($t1) + floatval($t2)) * 1000);
  12 +}
  13 +function microtime_format($tag, $time)
  14 +{
  15 + $a = substr($time, 0, 10);
  16 + $b = substr($time, 10);
  17 + $date = date($tag, $a) . '-' . $b;
  18 + return $date;
  19 +}
  20 +
  21 +/**
  22 + * 获取文件后缀名,并判断是否合法
  23 + *
  24 + * @param string $file_name
  25 + * @param array $allow_type
  26 + * @return blob
  27 + */
  28 +function get_file_suffix($file_name, $allow_type = array())
  29 +{
  30 + $fnarray=explode('.', $file_name);
  31 + $file_suffix = strtolower(array_pop($fnarray));
  32 + if (empty($allow_type)) {
  33 + return $file_suffix;
  34 + } else {
  35 +
  36 + if (in_array($file_suffix, $allow_type)) {
  37 + return true;
  38 + } else {
  39 + return false;
  40 + }
  41 + }
  42 +}
  43 +/**
  44 + * 远程文件下载
  45 + * @param $file_url
  46 + * @param $filePath 保存路径
  47 + */
  48 +function downfile($file_url, $filePath)
  49 +{
  50 + $header[] = "content-type: application/x-www-form-urlencoded;
  51 + charset = UTF-8";
  52 + $ch1 = curl_init();
  53 + $timeout = 60;
  54 + curl_setopt($ch1, CURLOPT_URL, $file_url);
  55 + curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
  56 + curl_setopt($ch1, CURLOPT_HTTPHEADER, $header);
  57 + curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout);
  58 + curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false);
  59 + curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, false);
  60 + $content = curl_exec($ch1);
  61 + curl_close($ch1);
  62 +// $content = file_get_contents($file_url);
  63 + if (file_put_contents($filePath, $content)) {
  64 + return true;
  65 + } else {
  66 + return false;
  67 + }
  68 +}
  69 +
  70 +//手机验证格式
  71 +function check_mobile($mobile_phone)
  72 +{
  73 + $mobile_phone = trim($mobile_phone);
  74 + if (preg_match("/^1[3-9]{1}[0-9]{9}$/", $mobile_phone)) {
  75 + return $mobile_phone;
  76 + } else {
  77 + return false;
  78 + }
  79 +}
  80 +
  81 +//验证邮箱格式
  82 +function checke_mail($email)
  83 +{
  84 + $pattern = "/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/"; //[ch]定义验证email正则表达式
  85 + if (preg_match($pattern, $email, $counts)) {
  86 + return true;
  87 + } else {
  88 + return false;
  89 + }
  90 +}
  91 +
  92 +/**
  93 + * 取得文件扩展
  94 + *
  95 + * @param $filename
  96 + * @return
  97 + */
  98 +function fileext($filename)
  99 +{
  100 + return strtolower(trim(substr(strrchr($filename, '.'), 1, 10)));
  101 +}
  102 +
  103 +/**
  104 + * IE浏览器判断
  105 + */
  106 +function is_ie()
  107 +{
  108 + $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
  109 + if ((strpos($useragent, 'opera') !== false) || (strpos($useragent, 'konqueror') !== false)) {
  110 + return false;
  111 + }
  112 +
  113 + if (strpos($useragent, 'msie ') !== false) {
  114 + return true;
  115 + }
  116 +
  117 + return false;
  118 +}
  119 +
  120 +/**
  121 + * 创建目录
  122 + * @param string $path 要创建的目录
  123 + * @return boolean 创建状态,true-成功,false-失败
  124 + */
  125 +function mkdirs($path, $mode = 0755)
  126 +{
  127 + if (!is_dir(dirname($path))) {
  128 + mkdirs(dirname($path), $mode);
  129 + }
  130 + if (!file_exists($path)) {
  131 + return @mkdir($path, $mode);
  132 + }
  133 +}
  134 +
  135 +/**
  136 + * 压缩音频文件
  137 + * @param string $file 需要压缩的文件路径
  138 + * @param string $path 压缩后的文件路径
  139 + * @return boolean
  140 + */
  141 +function ffmpeg($file, $path)
  142 +{
  143 + $rest = shell_exec("(ffmpeg -i " . $file . " -vn -c:a libmp3lame -b:a 128k -ac 2 " . $path . " >/dev/null & ) ");
  144 + return true;
  145 +}
  146 +
  147 +/**
  148 + * 系统非常规MD5加密方法
  149 + * @param string $str 要加密的字符串
  150 + * @return string
  151 + */
  152 +function think_center_md5($str, $key = '')
  153 +{
  154 + return '' === $str ? '' : md5(sha1($str) . $key);
  155 +}
  156 +//apk文件路径生成hash值
  157 +function file_hash($path){
  158 +
  159 + $cmd = '-tfile_sha -s'.base64_encode($path);
  160 + $hash = call($cmd);
  161 +
  162 + return $hash;
  163 +}
  164 +function call($icbp_info){
  165 + if($icbp_info==""){
  166 + \think\Log::write('info', '执行的hst_icbp命令:命令没有参数 --line:'.__LINE__);
  167 + return false;
  168 + exit;
  169 + }
  170 + $descriptorspec = array(
  171 + 0 => array("pipe", "r"), // stdin
  172 + 1 => array("pipe", "w"), // stdout
  173 + 2 => array("pipe", "w") // stderr
  174 + );
  175 +
  176 + $cmd = '/home/alg_icbp/hst_icbp '.$icbp_info; // 替换为你要执行的shell脚本
  177 + \think\Log::write('info', '执行的cmd命令:'.print_r($cmd,true).'--line:'.__LINE__);
  178 + $proc = proc_open($cmd, $descriptorspec, $pipes, null, null);
  179 +
  180 + // $proc为false,表明命令执行失败
  181 + if ($proc == false) {
  182 + // do sth with HTTP response
  183 + } else {
  184 + $stdout = stream_get_contents($pipes[1]);
  185 + fclose($pipes[1]);
  186 + $stderr = stream_get_contents($pipes[2]);
  187 + fclose($pipes[2]);
  188 + $status = proc_close($proc); // 释放proc
  189 + }
  190 +
  191 + $data = array(
  192 + 'code' => 0,
  193 + 'msg' => array(
  194 + 'stdout' => $stdout,
  195 + 'stderr' => $stderr,
  196 + 'retval' => $status
  197 + )
  198 + );
  199 + \think\Log::write('info', '执行的CMD命令结果:'.print_r($data['msg']['stdout'],true).'--line:'.__LINE__);
  200 + return $data['msg']['stdout'];
  201 +}
  202 +/**
  203 + * 系统加密方法
  204 + * @param string $data 要加密的字符串
  205 + * @param string $key 加密密钥
  206 + * @param int $expire 过期时间 单位 秒
  207 + * @return string
  208 + * @author 麦当苗儿 <zuojiazi@vip.qq.com>
  209 + */
  210 +function think_encrypt($data, $key, $expire = 0)
  211 +{
  212 + $key = md5($key);
  213 + $data = base64_encode($data);
  214 + $x = 0;
  215 + $len = strlen($data);
  216 + $l = strlen($key);
  217 + $char = '';
  218 + for ($i = 0; $i < $len; $i++) {
  219 + if ($x == $l) {
  220 + $x = 0;
  221 + }
  222 +
  223 + $char .= substr($key, $x, 1);
  224 + $x++;
  225 + }
  226 +
  227 + $str = sprintf('%010d', $expire ? $expire + time() : 0);
  228 +
  229 + for ($i = 0; $i < $len; $i++) {
  230 + $str .= chr(ord(substr($data, $i, 1)) + (ord(substr($char, $i, 1))) % 256);
  231 + }
  232 + return str_replace(array('+', '/', '='), array('-', '_', ''), base64_encode($str));
  233 +}
  234 +
  235 +/**
  236 + * 系统解密方法
  237 + * @param string $data 要解密的字符串 (必须是think_encrypt方法加密的字符串)
  238 + * @param string $key 加密密钥
  239 + * @return string
  240 + * @author 麦当苗儿 <zuojiazi@vip.qq.com>
  241 + */
  242 +function think_decrypt($data, $key)
  243 +{
  244 + $key = md5($key);
  245 + $data = str_replace(array('-', '_'), array('+', '/'), $data);
  246 + $mod4 = strlen($data) % 4;
  247 + if ($mod4) {
  248 + $data .= substr('====', $mod4);
  249 + }
  250 + $data = base64_decode($data);
  251 + $expire = substr($data, 0, 10);
  252 + $data = substr($data, 10);
  253 +
  254 + if ($expire > 0 && $expire < time()) {
  255 + return '';
  256 + }
  257 + $x = 0;
  258 + $len = strlen($data);
  259 + $l = strlen($key);
  260 + $char = $str = '';
  261 +
  262 + for ($i = 0; $i < $len; $i++) {
  263 + if ($x == $l) {
  264 + $x = 0;
  265 + }
  266 +
  267 + $char .= substr($key, $x, 1);
  268 + $x++;
  269 + }
  270 +
  271 + for ($i = 0; $i < $len; $i++) {
  272 + if (ord(substr($data, $i, 1)) < ord(substr($char, $i, 1))) {
  273 + $str .= chr((ord(substr($data, $i, 1)) + 256) - ord(substr($char, $i, 1)));
  274 + } else {
  275 + $str .= chr(ord(substr($data, $i, 1)) - ord(substr($char, $i, 1)));
  276 + }
  277 + }
  278 + return base64_decode($str);
  279 +}
  280 +
  281 +/**
  282 + * 判断字符串是否以指定字符开头
  283 + * @param $str '字符串'
  284 + * @param $needle '指定字符'
  285 + * @return
  286 + */
  287 +function startWith($str, $needle)
  288 +{
  289 + return strpos($str, $needle) === 0;
  290 +}
  291 +
  292 +/**
  293 + *
  294 + * @return int
  295 + */
  296 +function is_login()
  297 +{
  298 + //判断当前用户是否还存在
  299 + $token = session('user_auth');
  300 +
  301 + $user = \think\Cache::get($token);
  302 +
  303 + //TODO::版本号
  304 + if (empty($user)) {
  305 + return '';
  306 + } else {
  307 + return $user;
  308 + }
  309 +}
  310 +function getMemberRoleToString($role, $field = 'nickname')
  311 +{
  312 + $lists = app\admin\model\Manager::where('role', $role)->column('nickname');
  313 + return implode(',', $lists);
  314 +}
  315 +/**
  316 + * 判断是否是超级管理员
  317 + * @param $uid
  318 + * @return
  319 + */
  320 +function is_administrator($uid = null)
  321 +{
  322 + return $uid && (intval($uid) === \think\Config::get('is_administrator_id')) ? 1 : 0;
  323 +}
  324 +
  325 +
  326 +/**
  327 + * 获取菜单树(html)
  328 + * @param $pid
  329 + * @param $id
  330 + * @param $table
  331 + * @return
  332 + */
  333 +function getTree($pid = 0, $id = 0, $ispid = false)
  334 +{
  335 +
  336 + $auth = new \app\admin\model\AuthRule();
  337 + $map = ['id' => ['neq', $id]];
  338 + $ispid && $map['pid'] = 0;
  339 +// $map['type'] = ['lt', 3];
  340 + $menu = $auth->where($map)->field('id,title,pid')->select()->toArray();
  341 + $tree = " <option value=\"0\">顶级菜单</option>";
  342 + foreach ($menu as $k => $v) {
  343 + if ($v['pid'] == 0) {
  344 + if ($ispid) {
  345 + $tree .= "<option value=\"" . $v['id'] . "\" ";
  346 + if ($v['id'] == $pid) {
  347 + $tree .= "selected=\"selected\"";
  348 + }
  349 + $tree .= " >" . $v['title'] . "</option>";
  350 + continue;
  351 + }
  352 +
  353 + $cate_prent = new \tree\Tree($menu);
  354 + $tree .= "<option value=\"" . $v['id'] . "\" ";
  355 + if ($v['id'] == $pid) {
  356 + $tree .= "selected=\"selected\"";
  357 + }
  358 + $tree .= " >" . $v['title'] . "</option>";
  359 + $tree .= $cate_prent->get_tree($v['id'], "<option value=\$id \$selected>\$spacer\$title</option>", $pid);
  360 + }
  361 + }
  362 +
  363 + return $tree;
  364 +}
  365 +/**
  366 + * 生成图片文件地址
  367 + * @param type $sha1 sha1
  368 + * @param type $type image
  369 + * @return type
  370 + */
  371 +function getFileUrl($sha1, $type = 'image')
  372 +{
  373 + $url = '';
  374 + switch ($type) {
  375 + case 'image':
  376 + if (strpos($sha1, "http://") !== false) {
  377 + $url = $sha1;
  378 + } else {
  379 + $url = $sha1 ? url('/image/' . $sha1, '', '', true) : '';
  380 + }
  381 + break;
  382 + case 'images':
  383 + break;
  384 + case 'file':
  385 + $url = $sha1 ? url('/file/' . $sha1, '', '',true) : '';
  386 + break;
  387 + }
  388 + return $url;
  389 +}
  390 +
  391 +/**
  392 + * 发送http post请求
  393 + * @param type $url
  394 + * @param type $post_data
  395 + */
  396 +function http_post($url, $post_data)
  397 +{
  398 + $header[] = "charset = UTF-8";
  399 + $ch = curl_init();
  400 + curl_setopt($ch, CURLOPT_URL, $url);
  401 + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  402 + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  403 + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  404 + curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  405 + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
  406 + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  407 + curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
  408 + curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  409 + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  410 + $res = curl_exec($ch);
  411 + if (curl_errno($ch)) {
  412 + \think\Log::write(print_r(curl_errno($ch),1),'debug---1');
  413 + }
  414 + curl_close($ch);
  415 + return json_decode($res, true);
  416 +}
  417 +/**
  418 + * 发送http get请求
  419 + * @param type $url
  420 + * @return type
  421 + */
  422 +function http_get($url)
  423 +{
  424 + $header[] = "content-type: application/x-www-form-urlencoded;
  425 + charset = UTF-8";
  426 + $ch1 = curl_init();
  427 + $timeout = 5;
  428 + curl_setopt($ch1, CURLOPT_URL, $url);
  429 + curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
  430 + curl_setopt($ch1, CURLOPT_HTTPHEADER, $header);
  431 + curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout);
  432 + curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false);
  433 + curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, false);
  434 + $accesstxt = curl_exec($ch1);
  435 + curl_close($ch1);
  436 + return json_decode($accesstxt, true);
  437 +}
  438 +
  439 +
  440 +/**
  441 + * 正则验证手机号
  442 + * @param $tel 11位手机号
  443 + * @return bool
  444 + */
  445 +function is_mobile($tel)
  446 +{
  447 + if (!preg_match("/^1[3,6,5,8,7][0-9]{9}$/", $tel)) {
  448 + return false;
  449 + }
  450 +
  451 + return true;
  452 +}
  453 +
  454 +/**
  455 + * 生成随机字符串
  456 + * @param int $length 要生成的随机字符串长度
  457 + * @param string $type 随机码类型:0 数字+大小写字母 1 数字 2 小写字母 3 大写字母 4 特殊字符 -1 数字+大小写字母+特殊字符
  458 + * @return string
  459 + */
  460 +function randCode($length = 5, $type = 0)
  461 +{
  462 + $arr = array(1 => "0123456789", 2 => "abcdefghijklmnopqrstuvwxyz", 3 => "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 4 => "~@#$%^&*(){}[]|");
  463 + if ($type == 0) {
  464 + array_pop($arr);
  465 + $string = implode("", $arr);
  466 + } elseif ($type == "-1") {
  467 + $string = implode("", $arr);
  468 + } else {
  469 + $string = $arr[$type];
  470 + }
  471 + $count = strlen($string) - 1;
  472 + $code = '';
  473 + for ($i = 0; $i < $length; $i++) {
  474 + $code .= $string[rand(0, $count)];
  475 + }
  476 + return $code;
  477 +}
  478 +
  479 +
  480 +/**
  481 + * 随机取数组N个元素
  482 + *
  483 + * @param array $arr 原数组
  484 + * @param int $num 个数
  485 + * @return array
  486 + */
  487 +function array_random($arr = [], $num = 1)
  488 +{
  489 + shuffle($arr);
  490 + $r = [];
  491 + $num = $num > count($arr) ? count($arr) : $num;
  492 + for ($i = 0; $i < $num; $i++) {
  493 + $r[] = $arr[$i];
  494 + }
  495 + return 1 == $num ? $r[0] : $r;
  496 +}
  497 +
  498 +/**
  499 + *
  500 + * @param type $len 邀请码长度
  501 + * @return varchar $string 字符串
  502 + * /
  503 + */
  504 +function rand_code($len)
  505 +{
  506 + $chars = '0123456789abcdefghijklmnopqrstuvwxyz';
  507 + $string = substr(time(), -4);
  508 + for (; $len >= 1; $len--) {
  509 + $position = rand() % strlen($chars);
  510 + $position2 = rand() % strlen($string);
  511 + $string = substr_replace($string, substr($chars, $position, 1), $position2, 0);
  512 + }
  513 + return $string;
  514 +}
  515 +/**
  516 + * 截取字符串
  517 + */
  518 +function substrs($str){
  519 + //去除标签
  520 + $str = strip_tags($str);
  521 + return substr($str,0,50);
  522 +}
  523 +
  524 +/***
  525 + * 写入日志
  526 + * @param operator:操作人
  527 + * @param remark:详情
  528 + */
  529 +function set_log($data){
  530 + $log = new \app\admin\model\YLog();
  531 + return $log->add($data);
  532 +}
  533 +
  534 +/***
  535 + *使用mq发送消息
  536 + */
  537 +function set_mq_msg($rout_key,$msg){
  538 + $str = '/home/anmi/amqp_sendstring 127.0.0.1 5672 amq.topic ctrl 123';
  539 + shell_exec($str);
  540 + return;
  541 +}
  542 +
  543 +//验证ip是否合法
  544 +function isOk_ip($ip){
  545 + if(preg_match('/^((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1 -9]?\d))))$/', $ip)) {
  546 + return 1;
  547 + }else{
  548 + return 0;
  549 + }
  550 +}
  551 +
  552 +/**
  553 + * @name:修改ini文件参数
  554 + * @param $key
  555 + * @param $value
  556 + * @param $filename//文件路径
  557 + */
  558 +function system_config($key,$value,$filename){
  559 + $str = "sed -i 's/".$key."=.*/".$key."=".$value."/g' ".$filename;
  560 + calls($str);
  561 +}
  562 +
  563 +
  564 +//读取ini文件
  565 +function set_ini_file($file_name){
  566 + if(!is_file($file_name)){
  567 + $this->error('当前文件不存在','');
  568 + }
  569 + return parse_ini_file($file_name);
  570 +}
  571 +
  572 +//读取非ini文件
  573 +function get_sip_id($file_name){
  574 + $list = file_get_contents($file_name);
  575 + $list = str_replace(array("\r\n", "\r", "\n"), ',', $list);
  576 + $list = trim($list,',');
  577 + $list = explode(',',$list);
  578 + $arr = '';
  579 + foreach ($list as $v){
  580 + if(strpos($v,'SIP_ID') !== false){
  581 + $arr = str_replace('SIP_ID=','',$v);
  582 + break;
  583 + }
  584 + }
  585 + return $arr;
  586 +}
  587 +//发送sip消息到资源服务器
  588 +function send_msg($data){
  589 + //ycx 修改 20190809 如果配置文件中设置了内网IP就使用内网
  590 + $sip_to_server = config('sip_to_server');
  591 + if(config('sip_to_server_inner')){
  592 + $sip_to_server = config('sip_to_server_inner');
  593 + }
  594 + \think\Log::write(print_r(config('sip')." miscapps send_message '".config('sip_to_account')."' '".config('sip_to_resource_account')."' '"
  595 + .base64_encode(json_encode($data)). "' '".config('sip_to_resource_account')."' '".$sip_to_server."' ''",1),'debug');
  596 + shell_exec(config('sip')." miscapps send_message '".config('sip_to_account')."' '".config('sip_to_resource_account')."' '"
  597 + .base64_encode(json_encode($data)). "' '".config('sip_to_resource_account')."' '".$sip_to_server."' ''");
  598 +}
  599 +//发送sip消息通知客户端
  600 +function send_app_msg($data,$sip){
  601 + $sip_to_server = config('sip_to_server');
  602 + // if(config('sip_to_server_inner')){
  603 + // $sip_to_server = config('sip_to_server_inner');
  604 + //}
  605 + \think\Log::write(print_r(config('sip')." miscapps send_message '".config('sip_to_account')."' '".$sip."' '"
  606 + .base64_encode(json_encode($data)). "' '".$sip."' '".$sip_to_server."' ''",1),'debug');
  607 + shell_exec(config('sip')." miscapps send_message '".config('sip_to_account')."' '".$sip."' '"
  608 + .base64_encode(json_encode($data)). "' '".$sip."' '".$sip_to_server."' ''");
  609 +}
  1 +<?php
  2 +// +----------------------------------------------------------------------
  3 +// | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4 +// +----------------------------------------------------------------------
  5 +// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
  6 +// +----------------------------------------------------------------------
  7 +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8 +// +----------------------------------------------------------------------
  9 +// | Author: liu21st <liu21st@gmail.com>
  10 +// +----------------------------------------------------------------------
  11 +
  12 +return [
  13 + // +----------------------------------------------------------------------
  14 + // | 应用设置
  15 + // +----------------------------------------------------------------------
  16 +
  17 + // 应用命名空间
  18 + 'app_namespace' => 'app',
  19 + // 应用调试模式
  20 + 'app_debug' => true,
  21 + // 应用Trace
  22 + 'app_trace' => false,
  23 + // 应用模式状态
  24 + 'app_status' => '',
  25 + // 是否支持多模块
  26 + 'app_multi_module' => true,
  27 + // 入口自动绑定模块
  28 + 'auto_bind_module' => false,
  29 + // 注册的根命名空间
  30 + 'root_namespace' => [],
  31 + // 扩展函数文件
  32 + 'extra_file_list' => [THINK_PATH . 'helper' . EXT],
  33 + // 默认输出类型
  34 + 'default_return_type' => 'html',
  35 + // 默认AJAX 数据返回格式,可选json xml ...
  36 + 'default_ajax_return' => 'json',
  37 + // 默认JSONP格式返回的处理方法
  38 + 'default_jsonp_handler' => 'jsonpReturn',
  39 + // 默认JSONP处理方法
  40 + 'var_jsonp_handler' => 'callback',
  41 + // 默认时区
  42 + 'default_timezone' => 'PRC',
  43 + // 是否开启多语言
  44 + 'lang_switch_on' => false,
  45 + // 默认全局过滤方法 用逗号分隔多个
  46 + 'default_filter' => '',
  47 + // 默认语言
  48 + 'default_lang' => 'zh-cn',
  49 + // 应用类库后缀
  50 + 'class_suffix' => false,
  51 + // 控制器类后缀
  52 + 'controller_suffix' => false,
  53 +
  54 + // +----------------------------------------------------------------------
  55 + // | 模块设置
  56 + // +----------------------------------------------------------------------
  57 +
  58 + // 默认模块名
  59 + 'default_module' => 'index',
  60 + // 禁止访问模块
  61 + 'deny_module_list' => ['common'],
  62 + // 默认控制器名
  63 + 'default_controller' => 'Index',
  64 + // 默认操作名
  65 + 'default_action' => 'index',
  66 + // 默认验证器
  67 + 'default_validate' => '',
  68 + // 默认的空控制器名
  69 + 'empty_controller' => 'Error',
  70 + // 操作方法后缀
  71 + 'action_suffix' => '',
  72 + // 自动搜索控制器
  73 + 'controller_auto_search' => false,
  74 +
  75 + // +----------------------------------------------------------------------
  76 + // | URL设置
  77 + // +----------------------------------------------------------------------
  78 +
  79 + // PATHINFO变量名 用于兼容模式
  80 + 'var_pathinfo' => 's',
  81 + // 兼容PATH_INFO获取
  82 + 'pathinfo_fetch' => ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL'],
  83 + // pathinfo分隔符
  84 + 'pathinfo_depr' => '/',
  85 + // URL伪静态后缀
  86 + 'url_html_suffix' => 'html',
  87 + // URL普通方式参数 用于自动生成
  88 + 'url_common_param' => false,
  89 + // URL参数方式 0 按名称成对解析 1 按顺序解析
  90 + 'url_param_type' => 0,
  91 + // 是否开启路由
  92 + 'url_route_on' => true,
  93 + // 路由使用完整匹配
  94 + 'route_complete_match' => false,
  95 + // 路由配置文件(支持配置多个)
  96 + 'route_config_file' => ['route'],
  97 + // 是否强制使用路由
  98 + 'url_route_must' => false,
  99 + // 域名部署
  100 + 'url_domain_deploy' => false,
  101 + // 域名根,如thinkphp.cn
  102 + 'url_domain_root' => '',
  103 + // 是否自动转换URL中的控制器和操作名
  104 + 'url_convert' => true,
  105 + // 默认的访问控制器层
  106 + 'url_controller_layer' => 'controller',
  107 + // 表单请求类型伪装变量
  108 + 'var_method' => '_method',
  109 + // 表单ajax伪装变量
  110 + 'var_ajax' => '_ajax',
  111 + // 表单pjax伪装变量
  112 + 'var_pjax' => '_pjax',
  113 + // 是否开启请求缓存 true自动缓存 支持设置请求缓存规则
  114 + 'request_cache' => false,
  115 + // 请求缓存有效期
  116 + 'request_cache_expire' => null,
  117 +
  118 + // +----------------------------------------------------------------------
  119 + // | 模板设置
  120 + // +----------------------------------------------------------------------
  121 +
  122 + 'template' => [
  123 + // 模板引擎类型 支持 php think 支持扩展
  124 + 'type' => 'Think',
  125 + // 模板路径
  126 + 'view_path' => '',
  127 + // 模板后缀
  128 + 'view_suffix' => 'html',
  129 + // 模板文件名分隔符
  130 + 'view_depr' => DS,
  131 + // 模板引擎普通标签开始标记
  132 + 'tpl_begin' => '{',
  133 + // 模板引擎普通标签结束标记
  134 + 'tpl_end' => '}',
  135 + // 标签库标签开始标记
  136 + 'taglib_begin' => '{',
  137 + // 标签库标签结束标记
  138 + 'taglib_end' => '}',
  139 + ],
  140 +
  141 + // 视图输出字符串内容替换
  142 + 'view_replace_str' => [],
  143 + // 默认跳转页面对应的模板文件
  144 + 'dispatch_success_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
  145 + 'dispatch_error_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
  146 +
  147 + // +----------------------------------------------------------------------
  148 + // | 异常及错误设置
  149 + // +----------------------------------------------------------------------
  150 +
  151 + // 异常页面的模板文件
  152 + 'exception_tmpl' => THINK_PATH . 'tpl' . DS . 'think_exception.tpl',
  153 +
  154 + // 错误显示信息,非调试模式有效
  155 + 'error_message' => '页面错误!请稍后再试~',
  156 + // 显示错误信息
  157 + 'show_error_msg' => false,
  158 + // 异常处理handle类 留空使用 \think\exception\Handle
  159 + 'exception_handle' => '',
  160 +
  161 + // +----------------------------------------------------------------------
  162 + // | 日志设置
  163 + // +----------------------------------------------------------------------
  164 +
  165 + 'log' => [
  166 + // 日志记录方式,内置 file socket 支持扩展
  167 + 'type' => 'File',
  168 + // 日志保存目录
  169 + 'path' => LOG_PATH,
  170 + // 日志记录级别
  171 + 'level' => [],
  172 + ],
  173 +
  174 + // +----------------------------------------------------------------------
  175 + // | Trace设置 开启 app_trace 后 有效
  176 + // +----------------------------------------------------------------------
  177 + 'trace' => [
  178 + // 内置Html Console 支持扩展
  179 + 'type' => 'Html',
  180 + ],
  181 +
  182 + // +----------------------------------------------------------------------
  183 + // | 缓存设置
  184 + // +----------------------------------------------------------------------
  185 +
  186 + 'cache' => [
  187 + // 驱动方式
  188 + 'type' => 'File',
  189 + // 缓存保存目录
  190 + 'path' => CACHE_PATH,
  191 + // 缓存前缀
  192 + 'prefix' => '',
  193 + // 缓存有效期 0表示永久缓存
  194 + 'expire' => 0,
  195 + ],
  196 +
  197 + // +----------------------------------------------------------------------
  198 + // | 会话设置
  199 + // +----------------------------------------------------------------------
  200 +
  201 + 'session' => [
  202 + 'id' => '',
  203 + // SESSION_ID的提交变量,解决flash上传跨域
  204 + 'var_session_id' => '',
  205 + // SESSION 前缀
  206 + 'prefix' => 'think',
  207 + // 驱动方式 支持redis memcache memcached
  208 + 'type' => '',
  209 + // 是否自动开启 SESSION
  210 + 'auto_start' => true,
  211 + ],
  212 +
  213 + // +----------------------------------------------------------------------
  214 + // | Cookie设置
  215 + // +----------------------------------------------------------------------
  216 + 'cookie' => [
  217 + // cookie 名称前缀
  218 + 'prefix' => '',
  219 + // cookie 保存时间
  220 + 'expire' => 0,
  221 + // cookie 保存路径
  222 + 'path' => '/',
  223 + // cookie 有效域名
  224 + 'domain' => '',
  225 + // cookie 启用安全传输
  226 + 'secure' => false,
  227 + // httponly设置
  228 + 'httponly' => '',
  229 + // 是否使用 setcookie
  230 + 'setcookie' => true,
  231 + ],
  232 +
  233 + //分页配置
  234 + 'paginate' => [
  235 + 'type' => 'bootstrap',
  236 + 'var_page' => 'page',
  237 + 'list_rows' => 15,
  238 + ],
  239 +];
  1 +<?php
  2 +// +----------------------------------------------------------------------
  3 +// | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4 +// +----------------------------------------------------------------------
  5 +// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
  6 +// +----------------------------------------------------------------------
  7 +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8 +// +----------------------------------------------------------------------
  9 +// | Author: liu21st <liu21st@gmail.com>
  10 +// +----------------------------------------------------------------------
  11 +
  12 +return [
  13 + // 数据库类型
  14 + 'type' => 'mysql',
  15 + // 服务器地址
  16 + 'hostname' => '127.0.0.1',
  17 + // 数据库名
  18 + 'database' => 'tp',
  19 + // 用户名
  20 + 'username' => 'root',
  21 + // 密码
  22 + 'password' => '123456',
  23 + // 端口
  24 + 'hostport' => '3306',
  25 + // 连接dsn
  26 + 'dsn' => '',
  27 + // 数据库连接参数
  28 + 'params' => [],
  29 + // 数据库编码默认采用utf8
  30 + 'charset' => 'utf8',
  31 + // 数据库表前缀
  32 + 'prefix' => 'tp_',
  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' => true,
  49 + // 时间字段取出后的默认时间格式
  50 + 'datetime_format' => 'Y-m-d H:i:s',
  51 + // 是否需要进行SQL性能分析
  52 + 'sql_explain' => false,
  53 + // Builder类
  54 + 'builder' => '',
  55 + // Query类
  56 + 'query' => '\\think\\db\\Query',
  57 +];
  1 +<?php
  2 +// +----------------------------------------------------------------------
  3 +// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  4 +// +----------------------------------------------------------------------
  5 +// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
  6 +// +----------------------------------------------------------------------
  7 +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8 +// +----------------------------------------------------------------------
  9 +// | Author: yunwuxin <448901948@qq.com>
  10 +// +----------------------------------------------------------------------
  11 +
  12 +return [
  13 + 'connector' => 'Sync'
  14 +];
  1 +<?php
  2 +
  3 +/**
  4 + * 验证规则
  5 + */
  6 +return [
  7 + 'com_code' => [
  8 + 'allow_method' => 'post',
  9 + ],
  10 +];
  1 +<?php
  2 +
  3 +return [
  4 + /**
  5 + * 图片上传配置
  6 + */
  7 + 'upload_img' => [
  8 + //验证
  9 + 'rule' => [
  10 + 'size' => 3 * 1024 * 1024, //大小限制
  11 + 'ext' => 'jpeg,jpg,png,gif', //文件类型限制
  12 + ],
  13 + //生成文件规则
  14 + 'savename' => 'uniqid',
  15 + //缩略图缓存路径(可删除)
  16 + 'cache' => ROOT_PATH . 'runtime/images/',
  17 + //设置静态缓存参数(304)
  18 + 'header_cache' => [
  19 + 'Cache-Control' => 'max-age=2592000',
  20 + 'Pragma' => 'cache',
  21 + 'Expires' => "%Expires%", // cache 1 month
  22 + 'etag' => "%etag%",
  23 + 'Last-Modified' => "%Last-Modified%",
  24 + 'Content-Description' => 'File Transfer',
  25 + ],
  26 + //图片保存根路径
  27 + 'path' => './uploads/images/',
  28 + //图片上传变量名
  29 + 'name' => 'image',
  30 + ],
  31 + /**
  32 + * 文件上传配置
  33 + */
  34 + 'upload_file' => [
  35 + //验证
  36 + 'rule' => [
  37 + 'size' => 50 * 1024 * 1024, //大小限制
  38 + ],
  39 + 'cache' => ROOT_PATH . 'runtime/file/',
  40 + //生成文件规则
  41 + 'savename' => 'uniqid',
  42 + 'header_cache' => [
  43 + 'Accept-Ranges' => 'bytes',
  44 + 'Cache-Control' => 'public',
  45 + 'Pragma' => 'cache',
  46 + 'Expires' => "%Expires%", // cache 1 month
  47 + 'etag' => "%etag%",
  48 + 'Last-Modified' => "%Last-Modified%",
  49 + ],
  50 + //文件保存根路径
  51 + 'path' => './uploads/files/',
  52 + //文件上传变量名
  53 + 'name' => 'file',
  54 + //压缩文件临时保存根路径
  55 + 'temp_path' => ROOT_PATH . 'runtime/file/',
  56 + //mime限制
  57 +// 'mime_type' => ['video/x-ms-asf', 'application/octet-stream', 'audio/mp4', 'audio/x-flac', 'audio/mpeg', 'audio/x-wav'],
  58 + ],
  59 + /**
  60 + * 文件上传配置
  61 + */
  62 + 'upload_audio' => [
  63 + //验证
  64 + 'rule' => [
  65 + 'size' => 50 * 1024 * 1024, //大小限制
  66 + ],
  67 + 'cache' => ROOT_PATH . 'runtime/file/',
  68 + //生成文件规则
  69 + 'savename' => 'uniqid',
  70 + 'header_cache' => [
  71 + 'Accept-Ranges' => 'bytes',
  72 + 'Cache-Control' => 'public',
  73 + 'Pragma' => 'cache',
  74 + 'Expires' => "%Expires%", // cache 1 month
  75 + 'etag' => "%etag%",
  76 + 'Last-Modified' => "%Last-Modified%",
  77 + ],
  78 + //文件保存根路径
  79 + 'path' => './uploads/files/',
  80 + //文件上传变量名
  81 + 'name' => 'file',
  82 + //压缩文件临时保存根路径
  83 + 'temp_path' => ROOT_PATH . 'runtime/file/',
  84 +
  85 + ],
  86 +];
  1 +<?php
  2 +
  3 +namespace app\files\controller;
  4 +
  5 +use think\Request;
  6 +use think\Response;
  7 +
  8 +/**
  9 + * 通用文件处理
  10 + */
  11 +class File
  12 +{
  13 +
  14 + protected $request;
  15 + protected $config;
  16 +
  17 + public function __construct(Request $request)
  18 + {
  19 + $this->request = $request;
  20 + $this->config = config('upload_file');
  21 + }
  22 +
  23 + /**
  24 + * 输出返回数据
  25 + * @access protected
  26 + * @param mixed $data 要返回的数据
  27 + * @param String $type 返回类型 JSON XML
  28 + * @param integer $code HTTP状态码
  29 + * @return Response
  30 + */
  31 + protected function response($msg, $code = 200, $data = '', $type = 'json')
  32 + {
  33 + $result = [
  34 + 'code' => $code,
  35 + 'msg' => $msg,
  36 + 'data' => $data,
  37 + '_link' => '',
  38 + ];
  39 + if ($data) {
  40 + if (is_array($data)) {
  41 + foreach ($data as $key => $value) {
  42 + $result['_link'][] = getFileUrl($value, 'file');
  43 + }
  44 + } else {
  45 + $result['_link'] = getFileUrl($data, 'file');
  46 + }
  47 + }
  48 + $header = ['x_end_time' => $this->request->time()];
  49 + return Response::create($result, $type)->code($code)->header($header);
  50 + }
  51 +
  52 +
  53 + /**
  54 + * 文件上传
  55 + */
  56 + public function upload() {
  57 + $files = $this->request->file($this->config['name']);
  58 + if (empty($files)) {
  59 + return $this->response('没有上传的文件!', 400);
  60 + }
  61 + $type = $this->request->param('type', 'single');
  62 + if ($type == 'multi') {
  63 + return $this->multi($files);
  64 + } else {
  65 + return $this->single($files);
  66 + }
  67 + }
  68 +
  69 + /**
  70 + * 文件下载
  71 + *
  72 + * @return \think\Response
  73 + */
  74 + public function index($sha1, $type = 128) {
  75 + $info = db('file')->where('sha1', $sha1)->find();
  76 + if (empty($info)) {
  77 + return $this->response('指定文件不存在!', 404);
  78 + }
  79 + $path = '../../' . $info['path'];
  80 + if (!is_file($path)) {
  81 + return $this->response('指定文件已被系统删除!', 404);
  82 + }
  83 + $content = file_get_contents($path);
  84 + $header['Content-Length'] = $info['size'];
  85 + if (preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT'])) {
  86 + //for IE
  87 + $header['Content-Disposition'] = 'attachment; filename="' . rawurlencode(time() . '.' . $info['ext']) . '"';
  88 + } else {
  89 + $header['Content-Disposition'] = 'attachment; filename="' . time() . '.' . $info['ext'] . '"';
  90 + }
  91 + return response($content, 200, $header);
  92 + }
  93 +
  94 + /**
  95 + * 单文件上传
  96 + * @param type $file file对象
  97 + * @return type
  98 + */
  99 + private function single($file) {
  100 + if (is_array($file)) {
  101 + $file = current($file);
  102 + }
  103 + if ($file->check($this->config['rule']) === false) {
  104 + return $this->response($file->getMime() . $file->getError() . $this->config['rule']['type'], 400);
  105 + }
  106 + $info = db('file')->where('sha1', $file->hash())->find();
  107 + if (empty($info)) {
  108 + $res = $file->rule($this->config['savename'])->move(ROOT_PATH . $this->config['path']);
  109 + if ($res === false) {
  110 + return $this->response($file->getError(), 400);
  111 + }
  112 + $info = [
  113 + 'path' => $this->config['path'] . $res->getSaveName(),
  114 + 'create_time' => $this->request->time(),
  115 + 'sha1' => $res->hash(),
  116 + 'size' => $res->getSize(),
  117 + 'ext' => $res->getExtension(),
  118 + ];
  119 + db('file')->insert($info);
  120 + }
  121 +
  122 + return $this->response('上传成功!', 200, $file->hash());
  123 + }
  124 +
  125 + /**
  126 + * 多文件上传
  127 + * @param type $files file对象集合
  128 + * @return type
  129 + */
  130 + private function multi($files) {
  131 + if (!is_array($files)) {
  132 + $files = [$files];
  133 + }
  134 + $savedata = [];
  135 + $data = [];
  136 + foreach ($files as $file) {
  137 + if ($file->check($this->config['rule']) === false) {
  138 + return $this->response($file->getError(), 400);
  139 + }
  140 + $info = db('picture')->where('sha1', $file->hash())->find();
  141 + if (empty($info)) {
  142 + $res = $file->rule($this->config['savename'])->move(ROOT_PATH . $this->config['path']);
  143 + if ($res === false) {
  144 + return $this->response($file->getError(), 400);
  145 + }
  146 + $savedata[] = [
  147 + 'path' => $this->config['path'] . $res->getSaveName(),
  148 + 'create_time' => $this->request->time(),
  149 + 'sha1' => $res->hash(),
  150 + 'size' => $res->getSize(),
  151 + 'mime' => $res->getMime(),
  152 + 'ext' => $res->getExtension(),
  153 + ];
  154 + }
  155 + $data[] = $file->hash();
  156 + }
  157 + if (!empty($savedata)) {
  158 + db('file')->insertAll($savedata);
  159 + }
  160 + return $this->response('上传成功!', 200, $data);
  161 + }
  162 +
  163 +}
  1 +<?php
  2 +
  3 +namespace app\files\controller;
  4 +
  5 +use think\Request;
  6 +use think\Response;
  7 +use think\Cache;
  8 +
  9 +/**
  10 + * 通用图片处理
  11 + */
  12 +class Image {
  13 +
  14 + protected $request;
  15 + protected $config;
  16 +
  17 +
  18 + /**
  19 + * 缓存前缀
  20 + */
  21 + const PREFIX = '_image_';
  22 + const EXPIRE = 2592000;
  23 +
  24 + public function __construct(Request $request) {
  25 + $this->request = $request;
  26 + $this->config = config('upload_img');
  27 + }
  28 +
  29 + /**
  30 + * 输出返回数据
  31 + * @access protected
  32 + * @param mixed $data 要返回的数据
  33 + * @param String $type 返回类型 JSON XML
  34 + * @param integer $code HTTP状态码
  35 + * @return Response
  36 + */
  37 + protected function response($msg, $code = 200, $data = '', $type = 'json') {
  38 + $result = [
  39 + 'code' => $code,
  40 + 'msg' => $msg,
  41 + 'data' => $data,
  42 + '_link' => '',
  43 + ];
  44 + if ($data) {
  45 + if (is_array($data)) {
  46 + foreach ($data as $key => $value) {
  47 + $result['_link'][] = getFileUrl($value);
  48 + }
  49 + } else {
  50 + $result['_link'] = getFileUrl($data);
  51 + }
  52 + }
  53 + $header = ['x_end_time' => $this->request->time()];
  54 + $response = Response::create($result, $type)->code($code)->header($header);
  55 + throw new \think\exception\HttpResponseException($response);
  56 + }
  57 +
  58 + /**
  59 + * 显示资源列表
  60 + *
  61 + * @return \think\Response
  62 + */
  63 + public function index($sha1, $w = 0, $h = 0, $type = 3) {
  64 + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
  65 + header("HTTP/1.1 304 Not Modified");
  66 + exit;
  67 + }
  68 + $info = Cache::get(self::PREFIX . $sha1);
  69 + if (empty($info)) {
  70 + $info = db('picture')->where('sha1', $sha1)->find();
  71 + if (empty($info)) {
  72 + return $this->response('指定图片不存在!', 404);
  73 + }
  74 + Cache::set(self::PREFIX . $sha1, $info, self::EXPIRE);
  75 + }
  76 + $path = '../../' . $info['path'];
  77 + if (!is_file($path)) {
  78 +// db('picture')->delete($info['id']);
  79 + return $this->response('指定图片已被系统删除!', 404,$path);
  80 + }
  81 + $content = '';
  82 + $last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT";
  83 + $header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'], [$last_modified_time, $sha1 . ':' . $w . '_' . $h . '_' . $type, $last_modified_time], $this->config['header_cache']);
  84 + if ($w > 0 && $h > 0) {
  85 + $path = $this->cacheImage($info, $w, $h, $type);
  86 + $content = file_get_contents($path);
  87 + $header['Content-Length'] = strlen($content);
  88 + } else {
  89 + $content = file_get_contents($path);
  90 + $header['Content-Length'] = $info['size'];
  91 + }
  92 + return response($content, 200, $header);
  93 + }
  94 +
  95 + /**
  96 + * 生成缩略图缓存
  97 + * @param type $info
  98 + * @param type $w
  99 + * @param type $h
  100 + * @return string
  101 + */
  102 + private function cacheImage($info, $w, $h, $type = 1) {
  103 + $cache = $this->config['cache'] . substr($info['sha1'], 0, 2) . DS . substr($info['sha1'], 2) . DS;
  104 + $filename = $cache . $w . '_' . $h . '_' . $type;
  105 + $this->_mkdir($cache);
  106 + if (is_file($filename)) {
  107 + return $filename;
  108 + }
  109 + $img = \think\Image::open('./.' . $info['path']);
  110 + $img->thumb($w, $h, $type)->save($filename);
  111 + return $filename;
  112 + }
  113 +
  114 + /**
  115 + * 创建目录
  116 + * @param string $savepath 要创建的穆里
  117 + * @return boolean 创建状态,true-成功,false-失败
  118 + */
  119 + private function _mkdir($path) {
  120 + if (is_dir($path)) {
  121 + return true;
  122 + }
  123 + if (mkdir($path, 0755, true)) {
  124 + return true;
  125 + } else {
  126 + return false;
  127 + }
  128 + }
  129 +
  130 + /**
  131 + * 图片上传
  132 + */
  133 + public function upload() {
  134 + $files = $this->request->file($this->config['name']);
  135 + if (empty($files)) {
  136 + $this->response('没有上传的文件!', 400);
  137 + }
  138 + $type = $this->request->param('type', 'single');
  139 + if ($type == 'multi') {
  140 + return $this->multi($files);
  141 + } else {
  142 + return $this->single($files);
  143 + }
  144 + }
  145 +
  146 + /**
  147 + * 单图片上传
  148 + * @param type $file file对象
  149 + * @return type
  150 + */
  151 + private function single($file) {
  152 + if (is_array($file)) {
  153 + $file = current($file);
  154 + }
  155 + if ($file->check($this->config['rule']) === false) {
  156 + return $this->response($file->getError(), 400);
  157 + }
  158 + $info = db('picture')->where('sha1', $file->hash())->find();
  159 + if (empty($info) || !is_file('./.' . $info['path'])) {
  160 + if (isset($info['path']) && !is_file('./.' . $info['path'])) {
  161 + db('picture')->delete($info['id']);
  162 + }
  163 + $res = $file->rule($this->config['savename'])->move(ROOT_PATH . $this->config['path']);
  164 + if ($res === false) {
  165 + return $this->response($file->getError(), 400);
  166 + }
  167 + $data = [
  168 + 'path' => $this->config['path'] . $res->getSaveName(),
  169 + 'create_time' => $this->request->time(),
  170 + 'sha1' => $res->hash(),
  171 + 'size' => $res->getSize(),
  172 + ];
  173 + if (isset($info['id'])) {
  174 + $data['id'] = $info['id'];
  175 + db('picture')->update($data);
  176 + Cache::set(self::PREFIX . $data['sha1'], $info, self::EXPIRE);
  177 + } else {
  178 + db('picture')->insert($data);
  179 + }
  180 + }
  181 + $this->response('上传成功!', 200, $file->hash());
  182 + }
  183 +
  184 + /**
  185 + * 多图片上传
  186 + * @param type $files file对象集合
  187 + * @return type
  188 + */
  189 + private function multi($files) {
  190 + if (!is_array($files)) {
  191 + $files = [$files];
  192 + }
  193 + $savedata = [];
  194 + $data = [];
  195 + foreach ($files as $file) {
  196 + if ($file->check($this->config['rule']) === false) {
  197 + return $this->response($file->getError(), 400);
  198 + }
  199 + $info = db('picture')->where('sha1', $file->hash())->find();
  200 + if (empty($info) || !is_file('./.' . $info['path'])) {
  201 + if (isset($info['path']) && !is_file('./.' . $info['path'])) {
  202 + db('picture')->delete($info['id']);
  203 + }
  204 + $res = $file->rule($this->config['savename'])->move(ROOT_PATH . $this->config['path']);
  205 + if ($res === false) {
  206 + return $this->response($file->getError(), 400);
  207 + }
  208 + $savedata[] = [
  209 + 'path' => $this->config['path'] . $res->getSaveName(),
  210 + 'create_time' => $this->request->time(),
  211 + 'sha1' => $res->hash(),
  212 + 'size' => $res->getSize(),
  213 + ];
  214 + }
  215 + $data[] = $file->hash();
  216 + }
  217 + if (!empty($savedata)) {
  218 + db('picture')->insertAll($savedata);
  219 + }
  220 + $this->response('上传成功!', 200, $data);
  221 + }
  222 +
  223 +}
  1 +<?php
  2 +namespace app\index\controller;
  3 +
  4 +class Index
  5 +{
  6 + public function index()
  7 + {
  8 + return '<style type="text/css">*{ padding: 0; margin: 0; } .think_default_text{ 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 }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p> ThinkPHP V5<br/><span style="font-size:30px">十年磨一剑 - 为API开发设计的高性能框架</span></p><span style="font-size:22px;">[ V5.0 版本由 <a href="http://www.qiniu.com" target="qiniu">七牛云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script><script type="text/javascript" src="http://ad.topthink.com/Public/static/client.js"></script><thinkad id="ad_bd568ce7058a1091"></thinkad>';
  9 + }
  10 +}
  1 +<?php
  2 +use think\Route;
  3 +// +----------------------------------------------------------------------
  4 +// | ThinkPHP [ WE CAN DO IT JUST THINK ]
  5 +// +----------------------------------------------------------------------
  6 +// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
  7 +// +----------------------------------------------------------------------
  8 +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  9 +// +----------------------------------------------------------------------
  10 +// | Author: liu21st <liu21st@gmail.com>
  11 +// +----------------------------------------------------------------------
  12 +
  13 + /**
  14 + * 图片路由
  15 + */
  16 + Route::get('image/:sha1', 'files/image/index', [], ['w' => '\d+', 'h' => '\d+', 'type' => '\d+']);
  17 + /**
  18 + * 文件路由
  19 + */
  20 + Route::get('file/:sha1', 'files/file/index');
  21 +
  1 +<?php
  2 +// +----------------------------------------------------------------------
  3 +// | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4 +// +----------------------------------------------------------------------
  5 +// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
  6 +// +----------------------------------------------------------------------
  7 +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8 +// +----------------------------------------------------------------------
  9 +// | Author: liu21st <liu21st@gmail.com>
  10 +// +----------------------------------------------------------------------
  11 +
  12 +// 应用行为扩展定义文件
  13 +return [
  14 + // 应用初始化
  15 + 'app_init' => [],
  16 + // 应用开始
  17 + 'app_begin' => [],
  18 + // 模块初始化
  19 + 'module_init' => [],
  20 + // 操作开始执行
  21 + 'action_begin' => [],
  22 + // 视图内容过滤
  23 + 'view_filter' => [],
  24 + // 日志写入
  25 + 'log_write' => [],
  26 + // 应用结束
  27 + 'app_end' => [],
  28 +];
  1 +<?php
  2 +// +----------------------------------------------------------------------
  3 +// | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4 +// +----------------------------------------------------------------------
  5 +// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
  6 +// +----------------------------------------------------------------------
  7 +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8 +// +----------------------------------------------------------------------
  9 +// | Author: liu21st <liu21st@gmail.com>
  10 +// +----------------------------------------------------------------------
  11 +
  12 +return [
  13 + // 生成应用公共文件
  14 + '__file__' => ['common.php', 'config.php', 'database.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 +];
  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 + "repositories": {
  19 + "packagist": {
  20 + "type": "composer",
  21 + "url": "https://packagist.phpcomposer.com"
  22 + }
  23 + },
  24 + "require": {
  25 + "php": ">=5.4.0",
  26 + "topthink/framework": "^5.0",
  27 + "topthink/think-image": "^1.0",
  28 + "topthink/think-captcha": "^1.0",
  29 + "topthink/think-mongo": "^1.0",
  30 + "topthink/think-migration": "^1.0",
  31 + "topthink/think-angular": "^1.0",
  32 + "topthink/think-sae": "^1.0",
  33 + "topthink/think-worker": "^1.0",
  34 + "topthink/think-queue": "^1.0",
  35 + "topthink/think-testing": "^1.0"
  36 + },
  37 + "extra": {
  38 + "think-path": "thinkphp"
  39 + },
  40 + "config": {
  41 + "preferred-install": "dist"
  42 + }
  43 +}
  1 +{
  2 + "_readme": [
  3 + "This file locks the dependencies of your project to a known state",
  4 + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
  5 + "This file is @generated automatically"
  6 + ],
  7 + "hash": "6b9a74290d1ce77641321c846475ab00",
  8 + "content-hash": "09c3d6cb820b0f7e546b8d5395b3e723",
  9 + "packages": [
  10 + {
  11 + "name": "doctrine/instantiator",
  12 + "version": "1.0.5",
  13 + "source": {
  14 + "type": "git",
  15 + "url": "https://github.com/doctrine/instantiator.git",
  16 + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d"
  17 + },
  18 + "dist": {
  19 + "type": "zip",
  20 + "url": "https://packagist.phpcomposer.com/files/doctrine/instantiator/8e884e78f9f0eb1329e445619e04456e64d8051d.zip",
  21 + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d",
  22 + "shasum": ""
  23 + },
  24 + "require": {
  25 + "php": ">=5.3,<8.0-DEV"
  26 + },
  27 + "require-dev": {
  28 + "athletic/athletic": "~0.1.8",
  29 + "ext-pdo": "*",
  30 + "ext-phar": "*",
  31 + "phpunit/phpunit": "~4.0",
  32 + "squizlabs/php_codesniffer": "~2.0"
  33 + },
  34 + "type": "library",
  35 + "extra": {
  36 + "branch-alias": {
  37 + "dev-master": "1.0.x-dev"
  38 + }
  39 + },
  40 + "autoload": {
  41 + "psr-4": {
  42 + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
  43 + }
  44 + },
  45 + "notification-url": "https://packagist.org/downloads/",
  46 + "license": [
  47 + "MIT"
  48 + ],
  49 + "authors": [
  50 + {
  51 + "name": "Marco Pivetta",
  52 + "email": "ocramius@gmail.com",
  53 + "homepage": "http://ocramius.github.com/"
  54 + }
  55 + ],
  56 + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
  57 + "homepage": "https://github.com/doctrine/instantiator",
  58 + "keywords": [
  59 + "constructor",
  60 + "instantiate"
  61 + ],
  62 + "time": "2015-06-14 21:17:01"
  63 + },
  64 + {
  65 + "name": "phpdocumentor/reflection-common",
  66 + "version": "1.0",
  67 + "source": {
  68 + "type": "git",
  69 + "url": "https://github.com/phpDocumentor/ReflectionCommon.git",
  70 + "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c"
  71 + },
  72 + "dist": {
  73 + "type": "zip",
  74 + "url": "https://packagist.phpcomposer.com/files/phpDocumentor/ReflectionCommon/144c307535e82c8fdcaacbcfc1d6d8eeb896687c.zip",
  75 + "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c",
  76 + "shasum": ""
  77 + },
  78 + "require": {
  79 + "php": ">=5.5"
  80 + },
  81 + "require-dev": {
  82 + "phpunit/phpunit": "^4.6"
  83 + },
  84 + "type": "library",
  85 + "extra": {
  86 + "branch-alias": {
  87 + "dev-master": "1.0.x-dev"
  88 + }
  89 + },
  90 + "autoload": {
  91 + "psr-4": {
  92 + "phpDocumentor\\Reflection\\": [
  93 + "src"
  94 + ]
  95 + }
  96 + },
  97 + "notification-url": "https://packagist.org/downloads/",
  98 + "license": [
  99 + "MIT"
  100 + ],
  101 + "authors": [
  102 + {
  103 + "name": "Jaap van Otterdijk",
  104 + "email": "opensource@ijaap.nl"
  105 + }
  106 + ],
  107 + "description": "Common reflection classes used by phpdocumentor to reflect the code structure",
  108 + "homepage": "http://www.phpdoc.org",
  109 + "keywords": [
  110 + "FQSEN",
  111 + "phpDocumentor",
  112 + "phpdoc",
  113 + "reflection",
  114 + "static analysis"
  115 + ],
  116 + "time": "2015-12-27 11:43:31"
  117 + },
  118 + {
  119 + "name": "phpdocumentor/reflection-docblock",
  120 + "version": "3.1.1",
  121 + "source": {
  122 + "type": "git",
  123 + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
  124 + "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e"
  125 + },
  126 + "dist": {
  127 + "type": "zip",
  128 + "url": "https://packagist.phpcomposer.com/files/phpDocumentor/ReflectionDocBlock/8331b5efe816ae05461b7ca1e721c01b46bafb3e.zip",
  129 + "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e",
  130 + "shasum": ""
  131 + },
  132 + "require": {
  133 + "php": ">=5.5",
  134 + "phpdocumentor/reflection-common": "^1.0@dev",
  135 + "phpdocumentor/type-resolver": "^0.2.0",
  136 + "webmozart/assert": "^1.0"
  137 + },
  138 + "require-dev": {
  139 + "mockery/mockery": "^0.9.4",
  140 + "phpunit/phpunit": "^4.4"
  141 + },
  142 + "type": "library",
  143 + "autoload": {
  144 + "psr-4": {
  145 + "phpDocumentor\\Reflection\\": [
  146 + "src/"
  147 + ]
  148 + }
  149 + },
  150 + "notification-url": "https://packagist.org/downloads/",
  151 + "license": [
  152 + "MIT"
  153 + ],
  154 + "authors": [
  155 + {
  156 + "name": "Mike van Riel",
  157 + "email": "me@mikevanriel.com"
  158 + }
  159 + ],
  160 + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
  161 + "time": "2016-09-30 07:12:33"
  162 + },
  163 + {
  164 + "name": "phpdocumentor/type-resolver",
  165 + "version": "0.2.1",
  166 + "source": {
  167 + "type": "git",
  168 + "url": "https://github.com/phpDocumentor/TypeResolver.git",
  169 + "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb"
  170 + },
  171 + "dist": {
  172 + "type": "zip",
  173 + "url": "https://packagist.phpcomposer.com/files/phpDocumentor/TypeResolver/e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb.zip",
  174 + "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb",
  175 + "shasum": ""
  176 + },
  177 + "require": {
  178 + "php": ">=5.5",
  179 + "phpdocumentor/reflection-common": "^1.0"
  180 + },
  181 + "require-dev": {
  182 + "mockery/mockery": "^0.9.4",
  183 + "phpunit/phpunit": "^5.2||^4.8.24"
  184 + },
  185 + "type": "library",
  186 + "extra": {
  187 + "branch-alias": {
  188 + "dev-master": "1.0.x-dev"
  189 + }
  190 + },
  191 + "autoload": {
  192 + "psr-4": {
  193 + "phpDocumentor\\Reflection\\": [
  194 + "src/"
  195 + ]
  196 + }
  197 + },
  198 + "notification-url": "https://packagist.org/downloads/",
  199 + "license": [
  200 + "MIT"
  201 + ],
  202 + "authors": [
  203 + {
  204 + "name": "Mike van Riel",
  205 + "email": "me@mikevanriel.com"
  206 + }
  207 + ],
  208 + "time": "2016-11-25 06:54:22"
  209 + },
  210 + {
  211 + "name": "phpspec/prophecy",
  212 + "version": "v1.6.2",
  213 + "source": {
  214 + "type": "git",
  215 + "url": "https://github.com/phpspec/prophecy.git",
  216 + "reference": "6c52c2722f8460122f96f86346600e1077ce22cb"
  217 + },
  218 + "dist": {
  219 + "type": "zip",
  220 + "url": "https://packagist.phpcomposer.com/files/phpspec/prophecy/6c52c2722f8460122f96f86346600e1077ce22cb.zip",
  221 + "reference": "6c52c2722f8460122f96f86346600e1077ce22cb",
  222 + "shasum": ""
  223 + },
  224 + "require": {
  225 + "doctrine/instantiator": "^1.0.2",
  226 + "php": "^5.3|^7.0",
  227 + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2",
  228 + "sebastian/comparator": "^1.1",
  229 + "sebastian/recursion-context": "^1.0|^2.0"
  230 + },
  231 + "require-dev": {
  232 + "phpspec/phpspec": "^2.0",
  233 + "phpunit/phpunit": "^4.8 || ^5.6.5"
  234 + },
  235 + "type": "library",
  236 + "extra": {
  237 + "branch-alias": {
  238 + "dev-master": "1.6.x-dev"
  239 + }
  240 + },
  241 + "autoload": {
  242 + "psr-0": {
  243 + "Prophecy\\": "src/"
  244 + }
  245 + },
  246 + "notification-url": "https://packagist.org/downloads/",
  247 + "license": [
  248 + "MIT"
  249 + ],
  250 + "authors": [
  251 + {
  252 + "name": "Konstantin Kudryashov",
  253 + "email": "ever.zet@gmail.com",
  254 + "homepage": "http://everzet.com"
  255 + },
  256 + {
  257 + "name": "Marcello Duarte",
  258 + "email": "marcello.duarte@gmail.com"
  259 + }
  260 + ],
  261 + "description": "Highly opinionated mocking framework for PHP 5.3+",
  262 + "homepage": "https://github.com/phpspec/prophecy",
  263 + "keywords": [
  264 + "Double",
  265 + "Dummy",
  266 + "fake",
  267 + "mock",
  268 + "spy",
  269 + "stub"
  270 + ],
  271 + "time": "2016-11-21 14:58:47"
  272 + },
  273 + {
  274 + "name": "phpunit/php-code-coverage",
  275 + "version": "2.2.4",
  276 + "source": {
  277 + "type": "git",
  278 + "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
  279 + "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979"
  280 + },
  281 + "dist": {
  282 + "type": "zip",
  283 + "url": "https://packagist.phpcomposer.com/files/sebastianbergmann/php-code-coverage/eabf68b476ac7d0f73793aada060f1c1a9bf8979.zip",
  284 + "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979",
  285 + "shasum": ""
  286 + },
  287 + "require": {
  288 + "php": ">=5.3.3",
  289 + "phpunit/php-file-iterator": "~1.3",
  290 + "phpunit/php-text-template": "~1.2",
  291 + "phpunit/php-token-stream": "~1.3",
  292 + "sebastian/environment": "^1.3.2",
  293 + "sebastian/version": "~1.0"
  294 + },
  295 + "require-dev": {
  296 + "ext-xdebug": ">=2.1.4",
  297 + "phpunit/phpunit": "~4"
  298 + },
  299 + "suggest": {
  300 + "ext-dom": "*",
  301 + "ext-xdebug": ">=2.2.1",
  302 + "ext-xmlwriter": "*"
  303 + },
  304 + "type": "library",
  305 + "extra": {
  306 + "branch-alias": {
  307 + "dev-master": "2.2.x-dev"
  308 + }
  309 + },
  310 + "autoload": {
  311 + "classmap": [
  312 + "src/"
  313 + ]
  314 + },
  315 + "notification-url": "https://packagist.org/downloads/",
  316 + "license": [
  317 + "BSD-3-Clause"
  318 + ],
  319 + "authors": [
  320 + {
  321 + "name": "Sebastian Bergmann",
  322 + "email": "sb@sebastian-bergmann.de",
  323 + "role": "lead"
  324 + }
  325 + ],
  326 + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
  327 + "homepage": "https://github.com/sebastianbergmann/php-code-coverage",
  328 + "keywords": [
  329 + "coverage",
  330 + "testing",
  331 + "xunit"
  332 + ],
  333 + "time": "2015-10-06 15:47:00"
  334 + },
  335 + {
  336 + "name": "phpunit/php-file-iterator",
  337 + "version": "1.4.2",
  338 + "source": {
  339 + "type": "git",
  340 + "url": "https://github.com/sebastianbergmann/php-file-iterator.git",
  341 + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5"
  342 + },
  343 + "dist": {
  344 + "type": "zip",
  345 + "url": "https://packagist.phpcomposer.com/files/sebastianbergmann/php-file-iterator/3cc8f69b3028d0f96a9078e6295d86e9bf019be5.zip",
  346 + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5",
  347 + "shasum": ""
  348 + },
  349 + "require": {
  350 + "php": ">=5.3.3"
  351 + },
  352 + "type": "library",
  353 + "extra": {
  354 + "branch-alias": {
  355 + "dev-master": "1.4.x-dev"
  356 + }
  357 + },
  358 + "autoload": {
  359 + "classmap": [
  360 + "src/"
  361 + ]
  362 + },
  363 + "notification-url": "https://packagist.org/downloads/",
  364 + "license": [
  365 + "BSD-3-Clause"
  366 + ],
  367 + "authors": [
  368 + {
  369 + "name": "Sebastian Bergmann",
  370 + "email": "sb@sebastian-bergmann.de",
  371 + "role": "lead"
  372 + }
  373 + ],
  374 + "description": "FilterIterator implementation that filters files based on a list of suffixes.",
  375 + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
  376 + "keywords": [
  377 + "filesystem",
  378 + "iterator"
  379 + ],
  380 + "time": "2016-10-03 07:40:28"
  381 + },
  382 + {
  383 + "name": "phpunit/php-text-template",
  384 + "version": "1.2.1",
  385 + "source": {
  386 + "type": "git",
  387 + "url": "https://github.com/sebastianbergmann/php-text-template.git",
  388 + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686"
  389 + },
  390 + "dist": {
  391 + "type": "zip",
  392 + "url": "https://packagist.phpcomposer.com/files/sebastianbergmann/php-text-template/31f8b717e51d9a2afca6c9f046f5d69fc27c8686.zip",
  393 + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
  394 + "shasum": ""
  395 + },
  396 + "require": {
  397 + "php": ">=5.3.3"
  398 + },
  399 + "type": "library",
  400 + "autoload": {
  401 + "classmap": [
  402 + "src/"
  403 + ]
  404 + },
  405 + "notification-url": "https://packagist.org/downloads/",
  406 + "license": [
  407 + "BSD-3-Clause"
  408 + ],
  409 + "authors": [
  410 + {
  411 + "name": "Sebastian Bergmann",
  412 + "email": "sebastian@phpunit.de",
  413 + "role": "lead"
  414 + }
  415 + ],
  416 + "description": "Simple template engine.",
  417 + "homepage": "https://github.com/sebastianbergmann/php-text-template/",
  418 + "keywords": [
  419 + "template"
  420 + ],
  421 + "time": "2015-06-21 13:50:34"
  422 + },
  423 + {
  424 + "name": "phpunit/php-timer",
  425 + "version": "1.0.8",
  426 + "source": {
  427 + "type": "git",
  428 + "url": "https://github.com/sebastianbergmann/php-timer.git",
  429 + "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260"
  430 + },
  431 + "dist": {
  432 + "type": "zip",
  433 + "url": "https://packagist.phpcomposer.com/files/sebastianbergmann/php-timer/38e9124049cf1a164f1e4537caf19c99bf1eb260.zip",
  434 + "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260",
  435 + "shasum": ""
  436 + },
  437 + "require": {
  438 + "php": ">=5.3.3"
  439 + },
  440 + "require-dev": {
  441 + "phpunit/phpunit": "~4|~5"
  442 + },
  443 + "type": "library",
  444 + "autoload": {
  445 + "classmap": [
  446 + "src/"
  447 + ]
  448 + },
  449 + "notification-url": "https://packagist.org/downloads/",
  450 + "license": [
  451 + "BSD-3-Clause"
  452 + ],
  453 + "authors": [
  454 + {
  455 + "name": "Sebastian Bergmann",
  456 + "email": "sb@sebastian-bergmann.de",
  457 + "role": "lead"
  458 + }
  459 + ],
  460 + "description": "Utility class for timing",
  461 + "homepage": "https://github.com/sebastianbergmann/php-timer/",
  462 + "keywords": [
  463 + "timer"
  464 + ],
  465 + "time": "2016-05-12 18:03:57"
  466 + },
  467 + {
  468 + "name": "phpunit/php-token-stream",
  469 + "version": "1.4.9",
  470 + "source": {
  471 + "type": "git",
  472 + "url": "https://github.com/sebastianbergmann/php-token-stream.git",
  473 + "reference": "3b402f65a4cc90abf6e1104e388b896ce209631b"
  474 + },
  475 + "dist": {
  476 + "type": "zip",
  477 + "url": "https://packagist.phpcomposer.com/files/sebastianbergmann/php-token-stream/3b402f65a4cc90abf6e1104e388b896ce209631b.zip",
  478 + "reference": "3b402f65a4cc90abf6e1104e388b896ce209631b",
  479 + "shasum": ""
  480 + },
  481 + "require": {
  482 + "ext-tokenizer": "*",
  483 + "php": ">=5.3.3"
  484 + },
  485 + "require-dev": {
  486 + "phpunit/phpunit": "~4.2"
  487 + },
  488 + "type": "library",
  489 + "extra": {
  490 + "branch-alias": {
  491 + "dev-master": "1.4-dev"
  492 + }
  493 + },
  494 + "autoload": {
  495 + "classmap": [
  496 + "src/"
  497 + ]
  498 + },
  499 + "notification-url": "https://packagist.org/downloads/",
  500 + "license": [
  501 + "BSD-3-Clause"
  502 + ],
  503 + "authors": [
  504 + {
  505 + "name": "Sebastian Bergmann",
  506 + "email": "sebastian@phpunit.de"
  507 + }
  508 + ],
  509 + "description": "Wrapper around PHP's tokenizer extension.",
  510 + "homepage": "https://github.com/sebastianbergmann/php-token-stream/",
  511 + "keywords": [
  512 + "tokenizer"
  513 + ],
  514 + "time": "2016-11-15 14:06:22"
  515 + },
  516 + {
  517 + "name": "phpunit/phpunit",
  518 + "version": "4.8.32",
  519 + "source": {
  520 + "type": "git",
  521 + "url": "https://github.com/sebastianbergmann/phpunit.git",
  522 + "reference": "f5e1941a8dacf0d904753ff2895c6f68e54bcee1"
  523 + },
  524 + "dist": {
  525 + "type": "zip",
  526 + "url": "https://packagist.phpcomposer.com/files/sebastianbergmann/phpunit/f5e1941a8dacf0d904753ff2895c6f68e54bcee1.zip",
  527 + "reference": "f5e1941a8dacf0d904753ff2895c6f68e54bcee1",
  528 + "shasum": ""
  529 + },
  530 + "require": {
  531 + "ext-dom": "*",
  532 + "ext-json": "*",
  533 + "ext-pcre": "*",
  534 + "ext-reflection": "*",
  535 + "ext-spl": "*",
  536 + "php": ">=5.3.3",
  537 + "phpspec/prophecy": "^1.3.1",
  538 + "phpunit/php-code-coverage": "~2.1",
  539 + "phpunit/php-file-iterator": "~1.4",
  540 + "phpunit/php-text-template": "~1.2",
  541 + "phpunit/php-timer": "^1.0.6",
  542 + "phpunit/phpunit-mock-objects": "~2.3",
  543 + "sebastian/comparator": "~1.2.2",
  544 + "sebastian/diff": "~1.2",
  545 + "sebastian/environment": "~1.3",
  546 + "sebastian/exporter": "~1.2",
  547 + "sebastian/global-state": "~1.0",
  548 + "sebastian/version": "~1.0",
  549 + "symfony/yaml": "~2.1|~3.0"
  550 + },
  551 + "suggest": {
  552 + "phpunit/php-invoker": "~1.1"
  553 + },
  554 + "bin": [
  555 + "phpunit"
  556 + ],
  557 + "type": "library",
  558 + "extra": {
  559 + "branch-alias": {
  560 + "dev-master": "4.8.x-dev"
  561 + }
  562 + },
  563 + "autoload": {
  564 + "classmap": [
  565 + "src/"
  566 + ]
  567 + },
  568 + "notification-url": "https://packagist.org/downloads/",
  569 + "license": [
  570 + "BSD-3-Clause"
  571 + ],
  572 + "authors": [
  573 + {
  574 + "name": "Sebastian Bergmann",
  575 + "email": "sebastian@phpunit.de",
  576 + "role": "lead"
  577 + }
  578 + ],
  579 + "description": "The PHP Unit Testing framework.",
  580 + "homepage": "https://phpunit.de/",
  581 + "keywords": [
  582 + "phpunit",
  583 + "testing",
  584 + "xunit"
  585 + ],
  586 + "time": "2017-01-22 08:37:05"
  587 + },
  588 + {
  589 + "name": "phpunit/phpunit-mock-objects",
  590 + "version": "2.3.8",
  591 + "source": {
  592 + "type": "git",
  593 + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
  594 + "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983"
  595 + },
  596 + "dist": {
  597 + "type": "zip",
  598 + "url": "https://packagist.phpcomposer.com/files/sebastianbergmann/phpunit-mock-objects/ac8e7a3db35738d56ee9a76e78a4e03d97628983.zip",
  599 + "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983",
  600 + "shasum": ""
  601 + },
  602 + "require": {
  603 + "doctrine/instantiator": "^1.0.2",
  604 + "php": ">=5.3.3",
  605 + "phpunit/php-text-template": "~1.2",
  606 + "sebastian/exporter": "~1.2"
  607 + },
  608 + "require-dev": {
  609 + "phpunit/phpunit": "~4.4"
  610 + },
  611 + "suggest": {
  612 + "ext-soap": "*"
  613 + },
  614 + "type": "library",
  615 + "extra": {
  616 + "branch-alias": {
  617 + "dev-master": "2.3.x-dev"
  618 + }
  619 + },
  620 + "autoload": {
  621 + "classmap": [
  622 + "src/"
  623 + ]
  624 + },
  625 + "notification-url": "https://packagist.org/downloads/",
  626 + "license": [
  627 + "BSD-3-Clause"
  628 + ],
  629 + "authors": [
  630 + {
  631 + "name": "Sebastian Bergmann",
  632 + "email": "sb@sebastian-bergmann.de",
  633 + "role": "lead"
  634 + }
  635 + ],
  636 + "description": "Mock Object library for PHPUnit",
  637 + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
  638 + "keywords": [
  639 + "mock",
  640 + "xunit"
  641 + ],
  642 + "time": "2015-10-02 06:51:40"
  643 + },
  644 + {
  645 + "name": "sebastian/comparator",
  646 + "version": "1.2.2",
  647 + "source": {
  648 + "type": "git",
  649 + "url": "https://github.com/sebastianbergmann/comparator.git",
  650 + "reference": "6a1ed12e8b2409076ab22e3897126211ff8b1f7f"
  651 + },
  652 + "dist": {
  653 + "type": "zip",
  654 + "url": "https://packagist.phpcomposer.com/files/sebastianbergmann/comparator/6a1ed12e8b2409076ab22e3897126211ff8b1f7f.zip",
  655 + "reference": "6a1ed12e8b2409076ab22e3897126211ff8b1f7f",
  656 + "shasum": ""
  657 + },
  658 + "require": {
  659 + "php": ">=5.3.3",
  660 + "sebastian/diff": "~1.2",
  661 + "sebastian/exporter": "~1.2 || ~2.0"
  662 + },
  663 + "require-dev": {
  664 + "phpunit/phpunit": "~4.4"
  665 + },
  666 + "type": "library",
  667 + "extra": {
  668 + "branch-alias": {
  669 + "dev-master": "1.2.x-dev"
  670 + }
  671 + },
  672 + "autoload": {
  673 + "classmap": [
  674 + "src/"
  675 + ]
  676 + },
  677 + "notification-url": "https://packagist.org/downloads/",
  678 + "license": [
  679 + "BSD-3-Clause"
  680 + ],
  681 + "authors": [
  682 + {
  683 + "name": "Jeff Welch",
  684 + "email": "whatthejeff@gmail.com"
  685 + },
  686 + {
  687 + "name": "Volker Dusch",
  688 + "email": "github@wallbash.com"
  689 + },
  690 + {
  691 + "name": "Bernhard Schussek",
  692 + "email": "bschussek@2bepublished.at"
  693 + },
  694 + {
  695 + "name": "Sebastian Bergmann",
  696 + "email": "sebastian@phpunit.de"
  697 + }
  698 + ],
  699 + "description": "Provides the functionality to compare PHP values for equality",
  700 + "homepage": "http://www.github.com/sebastianbergmann/comparator",
  701 + "keywords": [
  702 + "comparator",
  703 + "compare",
  704 + "equality"
  705 + ],
  706 + "time": "2016-11-19 09:18:40"
  707 + },
  708 + {
  709 + "name": "sebastian/diff",
  710 + "version": "1.4.1",
  711 + "source": {
  712 + "type": "git",
  713 + "url": "https://github.com/sebastianbergmann/diff.git",
  714 + "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e"
  715 + },
  716 + "dist": {
  717 + "type": "zip",
  718 + "url": "https://packagist.phpcomposer.com/files/sebastianbergmann/diff/13edfd8706462032c2f52b4b862974dd46b71c9e.zip",
  719 + "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e",
  720 + "shasum": ""
  721 + },
  722 + "require": {
  723 + "php": ">=5.3.3"
  724 + },
  725 + "require-dev": {
  726 + "phpunit/phpunit": "~4.8"
  727 + },
  728 + "type": "library",
  729 + "extra": {
  730 + "branch-alias": {
  731 + "dev-master": "1.4-dev"
  732 + }
  733 + },
  734 + "autoload": {
  735 + "classmap": [
  736 + "src/"
  737 + ]
  738 + },
  739 + "notification-url": "https://packagist.org/downloads/",
  740 + "license": [
  741 + "BSD-3-Clause"
  742 + ],
  743 + "authors": [
  744 + {
  745 + "name": "Kore Nordmann",
  746 + "email": "mail@kore-nordmann.de"
  747 + },
  748 + {
  749 + "name": "Sebastian Bergmann",
  750 + "email": "sebastian@phpunit.de"
  751 + }
  752 + ],
  753 + "description": "Diff implementation",
  754 + "homepage": "https://github.com/sebastianbergmann/diff",
  755 + "keywords": [
  756 + "diff"
  757 + ],
  758 + "time": "2015-12-08 07:14:41"
  759 + },
  760 + {
  761 + "name": "sebastian/environment",
  762 + "version": "1.3.8",
  763 + "source": {
  764 + "type": "git",
  765 + "url": "https://github.com/sebastianbergmann/environment.git",
  766 + "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea"
  767 + },
  768 + "dist": {
  769 + "type": "zip",
  770 + "url": "https://packagist.phpcomposer.com/files/sebastianbergmann/environment/be2c607e43ce4c89ecd60e75c6a85c126e754aea.zip",
  771 + "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea",
  772 + "shasum": ""
  773 + },
  774 + "require": {
  775 + "php": "^5.3.3 || ^7.0"
  776 + },
  777 + "require-dev": {
  778 + "phpunit/phpunit": "^4.8 || ^5.0"
  779 + },
  780 + "type": "library",
  781 + "extra": {
  782 + "branch-alias": {
  783 + "dev-master": "1.3.x-dev"
  784 + }
  785 + },
  786 + "autoload": {
  787 + "classmap": [
  788 + "src/"
  789 + ]
  790 + },
  791 + "notification-url": "https://packagist.org/downloads/",
  792 + "license": [
  793 + "BSD-3-Clause"
  794 + ],
  795 + "authors": [
  796 + {
  797 + "name": "Sebastian Bergmann",
  798 + "email": "sebastian@phpunit.de"
  799 + }
  800 + ],
  801 + "description": "Provides functionality to handle HHVM/PHP environments",
  802 + "homepage": "http://www.github.com/sebastianbergmann/environment",
  803 + "keywords": [
  804 + "Xdebug",
  805 + "environment",
  806 + "hhvm"
  807 + ],
  808 + "time": "2016-08-18 05:49:44"
  809 + },
  810 + {
  811 + "name": "sebastian/exporter",
  812 + "version": "1.2.2",
  813 + "source": {
  814 + "type": "git",
  815 + "url": "https://github.com/sebastianbergmann/exporter.git",
  816 + "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4"
  817 + },
  818 + "dist": {
  819 + "type": "zip",
  820 + "url": "https://packagist.phpcomposer.com/files/sebastianbergmann/exporter/42c4c2eec485ee3e159ec9884f95b431287edde4.zip",
  821 + "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4",
  822 + "shasum": ""
  823 + },
  824 + "require": {
  825 + "php": ">=5.3.3",
  826 + "sebastian/recursion-context": "~1.0"
  827 + },
  828 + "require-dev": {
  829 + "ext-mbstring": "*",
  830 + "phpunit/phpunit": "~4.4"
  831 + },
  832 + "type": "library",
  833 + "extra": {
  834 + "branch-alias": {
  835 + "dev-master": "1.3.x-dev"
  836 + }
  837 + },
  838 + "autoload": {
  839 + "classmap": [
  840 + "src/"
  841 + ]
  842 + },
  843 + "notification-url": "https://packagist.org/downloads/",
  844 + "license": [
  845 + "BSD-3-Clause"
  846 + ],
  847 + "authors": [
  848 + {
  849 + "name": "Jeff Welch",
  850 + "email": "whatthejeff@gmail.com"
  851 + },
  852 + {
  853 + "name": "Volker Dusch",
  854 + "email": "github@wallbash.com"
  855 + },
  856 + {
  857 + "name": "Bernhard Schussek",
  858 + "email": "bschussek@2bepublished.at"
  859 + },
  860 + {
  861 + "name": "Sebastian Bergmann",
  862 + "email": "sebastian@phpunit.de"
  863 + },
  864 + {
  865 + "name": "Adam Harvey",
  866 + "email": "aharvey@php.net"
  867 + }
  868 + ],
  869 + "description": "Provides the functionality to export PHP variables for visualization",
  870 + "homepage": "http://www.github.com/sebastianbergmann/exporter",
  871 + "keywords": [
  872 + "export",
  873 + "exporter"
  874 + ],
  875 + "time": "2016-06-17 09:04:28"
  876 + },
  877 + {
  878 + "name": "sebastian/global-state",
  879 + "version": "1.1.1",
  880 + "source": {
  881 + "type": "git",
  882 + "url": "https://github.com/sebastianbergmann/global-state.git",
  883 + "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4"
  884 + },
  885 + "dist": {
  886 + "type": "zip",
  887 + "url": "https://packagist.phpcomposer.com/files/sebastianbergmann/global-state/bc37d50fea7d017d3d340f230811c9f1d7280af4.zip",
  888 + "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4",
  889 + "shasum": ""
  890 + },
  891 + "require": {
  892 + "php": ">=5.3.3"
  893 + },
  894 + "require-dev": {
  895 + "phpunit/phpunit": "~4.2"
  896 + },
  897 + "suggest": {
  898 + "ext-uopz": "*"
  899 + },
  900 + "type": "library",
  901 + "extra": {
  902 + "branch-alias": {
  903 + "dev-master": "1.0-dev"
  904 + }
  905 + },
  906 + "autoload": {
  907 + "classmap": [
  908 + "src/"
  909 + ]
  910 + },
  911 + "notification-url": "https://packagist.org/downloads/",
  912 + "license": [
  913 + "BSD-3-Clause"
  914 + ],
  915 + "authors": [
  916 + {
  917 + "name": "Sebastian Bergmann",
  918 + "email": "sebastian@phpunit.de"
  919 + }
  920 + ],
  921 + "description": "Snapshotting of global state",
  922 + "homepage": "http://www.github.com/sebastianbergmann/global-state",
  923 + "keywords": [
  924 + "global state"
  925 + ],
  926 + "time": "2015-10-12 03:26:01"
  927 + },
  928 + {
  929 + "name": "sebastian/recursion-context",
  930 + "version": "1.0.2",
  931 + "source": {
  932 + "type": "git",
  933 + "url": "https://github.com/sebastianbergmann/recursion-context.git",
  934 + "reference": "913401df809e99e4f47b27cdd781f4a258d58791"
  935 + },
  936 + "dist": {
  937 + "type": "zip",
  938 + "url": "https://packagist.phpcomposer.com/files/sebastianbergmann/recursion-context/913401df809e99e4f47b27cdd781f4a258d58791.zip",
  939 + "reference": "913401df809e99e4f47b27cdd781f4a258d58791",
  940 + "shasum": ""
  941 + },
  942 + "require": {
  943 + "php": ">=5.3.3"
  944 + },
  945 + "require-dev": {
  946 + "phpunit/phpunit": "~4.4"
  947 + },
  948 + "type": "library",
  949 + "extra": {
  950 + "branch-alias": {
  951 + "dev-master": "1.0.x-dev"
  952 + }
  953 + },
  954 + "autoload": {
  955 + "classmap": [
  956 + "src/"
  957 + ]
  958 + },
  959 + "notification-url": "https://packagist.org/downloads/",
  960 + "license": [
  961 + "BSD-3-Clause"
  962 + ],
  963 + "authors": [
  964 + {
  965 + "name": "Jeff Welch",
  966 + "email": "whatthejeff@gmail.com"
  967 + },
  968 + {
  969 + "name": "Sebastian Bergmann",
  970 + "email": "sebastian@phpunit.de"
  971 + },
  972 + {
  973 + "name": "Adam Harvey",
  974 + "email": "aharvey@php.net"
  975 + }
  976 + ],
  977 + "description": "Provides functionality to recursively process PHP variables",
  978 + "homepage": "http://www.github.com/sebastianbergmann/recursion-context",
  979 + "time": "2015-11-11 19:50:13"
  980 + },
  981 + {
  982 + "name": "sebastian/version",
  983 + "version": "1.0.6",
  984 + "source": {
  985 + "type": "git",
  986 + "url": "https://github.com/sebastianbergmann/version.git",
  987 + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6"
  988 + },
  989 + "dist": {
  990 + "type": "zip",
  991 + "url": "https://packagist.phpcomposer.com/files/sebastianbergmann/version/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6.zip",
  992 + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6",
  993 + "shasum": ""
  994 + },
  995 + "type": "library",
  996 + "autoload": {
  997 + "classmap": [
  998 + "src/"
  999 + ]
  1000 + },
  1001 + "notification-url": "https://packagist.org/downloads/",
  1002 + "license": [
  1003 + "BSD-3-Clause"
  1004 + ],
  1005 + "authors": [
  1006 + {
  1007 + "name": "Sebastian Bergmann",
  1008 + "email": "sebastian@phpunit.de",
  1009 + "role": "lead"
  1010 + }
  1011 + ],
  1012 + "description": "Library that helps with managing the version number of Git-hosted PHP projects",
  1013 + "homepage": "https://github.com/sebastianbergmann/version",
  1014 + "time": "2015-06-21 13:59:46"
  1015 + },
  1016 + {
  1017 + "name": "symfony/dom-crawler",
  1018 + "version": "v2.8.16",
  1019 + "source": {
  1020 + "type": "git",
  1021 + "url": "https://github.com/symfony/dom-crawler.git",
  1022 + "reference": "52cc211afa9458c0a54c478010a55f44892c1c02"
  1023 + },
  1024 + "dist": {
  1025 + "type": "zip",
  1026 + "url": "https://packagist.phpcomposer.com/files/symfony/dom-crawler/52cc211afa9458c0a54c478010a55f44892c1c02.zip",
  1027 + "reference": "52cc211afa9458c0a54c478010a55f44892c1c02",
  1028 + "shasum": ""
  1029 + },
  1030 + "require": {
  1031 + "php": ">=5.3.9",
  1032 + "symfony/polyfill-mbstring": "~1.0"
  1033 + },
  1034 + "require-dev": {
  1035 + "symfony/css-selector": "~2.8|~3.0.0"
  1036 + },
  1037 + "suggest": {
  1038 + "symfony/css-selector": ""
  1039 + },
  1040 + "type": "library",
  1041 + "extra": {
  1042 + "branch-alias": {
  1043 + "dev-master": "2.8-dev"
  1044 + }
  1045 + },
  1046 + "autoload": {
  1047 + "psr-4": {
  1048 + "Symfony\\Component\\DomCrawler\\": ""
  1049 + },
  1050 + "exclude-from-classmap": [
  1051 + "/Tests/"
  1052 + ]
  1053 + },
  1054 + "notification-url": "https://packagist.org/downloads/",
  1055 + "license": [
  1056 + "MIT"
  1057 + ],
  1058 + "authors": [
  1059 + {
  1060 + "name": "Fabien Potencier",
  1061 + "email": "fabien@symfony.com"
  1062 + },
  1063 + {
  1064 + "name": "Symfony Community",
  1065 + "homepage": "https://symfony.com/contributors"
  1066 + }
  1067 + ],
  1068 + "description": "Symfony DomCrawler Component",
  1069 + "homepage": "https://symfony.com",
  1070 + "time": "2017-01-02 20:30:24"
  1071 + },
  1072 + {
  1073 + "name": "symfony/polyfill-mbstring",
  1074 + "version": "v1.3.0",
  1075 + "source": {
  1076 + "type": "git",
  1077 + "url": "https://github.com/symfony/polyfill-mbstring.git",
  1078 + "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4"
  1079 + },
  1080 + "dist": {
  1081 + "type": "zip",
  1082 + "url": "https://packagist.phpcomposer.com/files/symfony/polyfill-mbstring/e79d363049d1c2128f133a2667e4f4190904f7f4.zip",
  1083 + "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4",
  1084 + "shasum": ""
  1085 + },
  1086 + "require": {
  1087 + "php": ">=5.3.3"
  1088 + },
  1089 + "suggest": {
  1090 + "ext-mbstring": "For best performance"
  1091 + },
  1092 + "type": "library",
  1093 + "extra": {
  1094 + "branch-alias": {
  1095 + "dev-master": "1.3-dev"
  1096 + }
  1097 + },
  1098 + "autoload": {
  1099 + "psr-4": {
  1100 + "Symfony\\Polyfill\\Mbstring\\": ""
  1101 + },
  1102 + "files": [
  1103 + "bootstrap.php"
  1104 + ]
  1105 + },
  1106 + "notification-url": "https://packagist.org/downloads/",
  1107 + "license": [
  1108 + "MIT"
  1109 + ],
  1110 + "authors": [
  1111 + {
  1112 + "name": "Nicolas Grekas",
  1113 + "email": "p@tchwork.com"
  1114 + },
  1115 + {
  1116 + "name": "Symfony Community",
  1117 + "homepage": "https://symfony.com/contributors"
  1118 + }
  1119 + ],
  1120 + "description": "Symfony polyfill for the Mbstring extension",
  1121 + "homepage": "https://symfony.com",
  1122 + "keywords": [
  1123 + "compatibility",
  1124 + "mbstring",
  1125 + "polyfill",
  1126 + "portable",
  1127 + "shim"
  1128 + ],
  1129 + "time": "2016-11-14 01:06:16"
  1130 + },
  1131 + {
  1132 + "name": "symfony/yaml",
  1133 + "version": "v3.2.2",
  1134 + "source": {
  1135 + "type": "git",
  1136 + "url": "https://github.com/symfony/yaml.git",
  1137 + "reference": "50eadbd7926e31842893c957eca362b21592a97d"
  1138 + },
  1139 + "dist": {
  1140 + "type": "zip",
  1141 + "url": "https://packagist.phpcomposer.com/files/symfony/yaml/50eadbd7926e31842893c957eca362b21592a97d.zip",
  1142 + "reference": "50eadbd7926e31842893c957eca362b21592a97d",
  1143 + "shasum": ""
  1144 + },
  1145 + "require": {
  1146 + "php": ">=5.5.9"
  1147 + },
  1148 + "require-dev": {
  1149 + "symfony/console": "~2.8|~3.0"
  1150 + },
  1151 + "suggest": {
  1152 + "symfony/console": "For validating YAML files using the lint command"
  1153 + },
  1154 + "type": "library",
  1155 + "extra": {
  1156 + "branch-alias": {
  1157 + "dev-master": "3.2-dev"
  1158 + }
  1159 + },
  1160 + "autoload": {
  1161 + "psr-4": {
  1162 + "Symfony\\Component\\Yaml\\": ""
  1163 + },
  1164 + "exclude-from-classmap": [
  1165 + "/Tests/"
  1166 + ]
  1167 + },
  1168 + "notification-url": "https://packagist.org/downloads/",
  1169 + "license": [
  1170 + "MIT"
  1171 + ],
  1172 + "authors": [
  1173 + {
  1174 + "name": "Fabien Potencier",
  1175 + "email": "fabien@symfony.com"
  1176 + },
  1177 + {
  1178 + "name": "Symfony Community",
  1179 + "homepage": "https://symfony.com/contributors"
  1180 + }
  1181 + ],
  1182 + "description": "Symfony Yaml Component",
  1183 + "homepage": "https://symfony.com",
  1184 + "time": "2017-01-03 13:51:32"
  1185 + },
  1186 + {
  1187 + "name": "topthink/framework",
  1188 + "version": "v5.0.5",
  1189 + "source": {
  1190 + "type": "git",
  1191 + "url": "https://github.com/top-think/framework.git",
  1192 + "reference": "86cc9378a0c46e66dabed6681f8b8de758585ae1"
  1193 + },
  1194 + "dist": {
  1195 + "type": "zip",
  1196 + "url": "https://packagist.phpcomposer.com/files/top-think/framework/86cc9378a0c46e66dabed6681f8b8de758585ae1.zip",
  1197 + "reference": "86cc9378a0c46e66dabed6681f8b8de758585ae1",
  1198 + "shasum": ""
  1199 + },
  1200 + "require": {
  1201 + "php": ">=5.4.0",
  1202 + "topthink/think-installer": "~1.0"
  1203 + },
  1204 + "require-dev": {
  1205 + "johnkary/phpunit-speedtrap": "^1.0",
  1206 + "mikey179/vfsstream": "~1.6",
  1207 + "phpdocumentor/reflection-docblock": "^2.0",
  1208 + "phploc/phploc": "2.*",
  1209 + "phpunit/phpunit": "4.8.*",
  1210 + "sebastian/phpcpd": "2.*"
  1211 + },
  1212 + "type": "think-framework",
  1213 + "autoload": {
  1214 + "psr-4": {
  1215 + "think\\": "library/think"
  1216 + }
  1217 + },
  1218 + "notification-url": "https://packagist.org/downloads/",
  1219 + "license": [
  1220 + "Apache-2.0"
  1221 + ],
  1222 + "authors": [
  1223 + {
  1224 + "name": "liu21st",
  1225 + "email": "liu21st@gmail.com"
  1226 + }
  1227 + ],
  1228 + "description": "the new thinkphp framework",
  1229 + "homepage": "http://thinkphp.cn/",
  1230 + "keywords": [
  1231 + "framework",
  1232 + "orm",
  1233 + "thinkphp"
  1234 + ],
  1235 + "time": "2017-01-23 05:59:21"
  1236 + },
  1237 + {
  1238 + "name": "topthink/think-angular",
  1239 + "version": "1.0.9",
  1240 + "source": {
  1241 + "type": "git",
  1242 + "url": "https://github.com/top-think/think-angular.git",
  1243 + "reference": "71c5d575f654b16fe708a22315612ed92cc42dc5"
  1244 + },
  1245 + "dist": {
  1246 + "type": "zip",
  1247 + "url": "https://packagist.phpcomposer.com/files/top-think/think-angular/71c5d575f654b16fe708a22315612ed92cc42dc5.zip",
  1248 + "reference": "71c5d575f654b16fe708a22315612ed92cc42dc5",
  1249 + "shasum": ""
  1250 + },
  1251 + "require": {
  1252 + "php": ">=5.4.0"
  1253 + },
  1254 + "type": "library",
  1255 + "autoload": {
  1256 + "classmap": {
  1257 + "think\\view\\driver\\Angular": "drivers/thinkphp5/Angular.php"
  1258 + },
  1259 + "psr-4": {
  1260 + "think\\angular\\": "src/"
  1261 + }
  1262 + },
  1263 + "notification-url": "https://packagist.org/downloads/",
  1264 + "license": [
  1265 + "Apache2"
  1266 + ],
  1267 + "authors": [
  1268 + {
  1269 + "name": "玩具机器人",
  1270 + "email": "zhaishuaigan@qq.com"
  1271 + }
  1272 + ],
  1273 + "description": "think angular view engine",
  1274 + "homepage": "http://kancloud.cn/shuai/php-angular",
  1275 + "time": "2016-12-21 04:21:12"
  1276 + },
  1277 + {
  1278 + "name": "topthink/think-captcha",
  1279 + "version": "v1.0.7",
  1280 + "source": {
  1281 + "type": "git",
  1282 + "url": "https://github.com/top-think/think-captcha.git",
  1283 + "reference": "0c55455df26a1626a60d0dc35d2d89002b741d44"
  1284 + },
  1285 + "dist": {
  1286 + "type": "zip",
  1287 + "url": "https://packagist.phpcomposer.com/files/top-think/think-captcha/0c55455df26a1626a60d0dc35d2d89002b741d44.zip",
  1288 + "reference": "0c55455df26a1626a60d0dc35d2d89002b741d44",
  1289 + "shasum": ""
  1290 + },
  1291 + "type": "library",
  1292 + "autoload": {
  1293 + "psr-4": {
  1294 + "think\\captcha\\": "src/"
  1295 + },
  1296 + "files": [
  1297 + "src/helper.php"
  1298 + ]
  1299 + },
  1300 + "notification-url": "https://packagist.org/downloads/",
  1301 + "license": [
  1302 + "Apache-2.0"
  1303 + ],
  1304 + "authors": [
  1305 + {
  1306 + "name": "yunwuxin",
  1307 + "email": "448901948@qq.com"
  1308 + }
  1309 + ],
  1310 + "description": "captcha package for thinkphp5",
  1311 + "time": "2016-07-06 01:47:11"
  1312 + },
  1313 + {
  1314 + "name": "topthink/think-helper",
  1315 + "version": "v1.0.5",
  1316 + "source": {
  1317 + "type": "git",
  1318 + "url": "https://github.com/top-think/think-helper.git",
  1319 + "reference": "ed64408cdc4cdbd390365ba0906d208b987af520"
  1320 + },
  1321 + "dist": {
  1322 + "type": "zip",
  1323 + "url": "https://packagist.phpcomposer.com/files/top-think/think-helper/ed64408cdc4cdbd390365ba0906d208b987af520.zip",
  1324 + "reference": "ed64408cdc4cdbd390365ba0906d208b987af520",
  1325 + "shasum": ""
  1326 + },
  1327 + "type": "library",
  1328 + "autoload": {
  1329 + "psr-4": {
  1330 + "think\\helper\\": "src"
  1331 + },
  1332 + "files": [
  1333 + "src/helper.php"
  1334 + ]
  1335 + },
  1336 + "notification-url": "https://packagist.org/downloads/",
  1337 + "license": [
  1338 + "Apache-2.0"
  1339 + ],
  1340 + "authors": [
  1341 + {
  1342 + "name": "yunwuxin",
  1343 + "email": "448901948@qq.com"
  1344 + }
  1345 + ],
  1346 + "description": "The ThinkPHP5 Helper Package",
  1347 + "time": "2016-12-01 07:08:40"
  1348 + },
  1349 + {
  1350 + "name": "topthink/think-image",
  1351 + "version": "v1.0.7",
  1352 + "source": {
  1353 + "type": "git",
  1354 + "url": "https://github.com/top-think/think-image.git",
  1355 + "reference": "8586cf47f117481c6d415b20f7dedf62e79d5512"
  1356 + },
  1357 + "dist": {
  1358 + "type": "zip",
  1359 + "url": "https://packagist.phpcomposer.com/files/top-think/think-image/8586cf47f117481c6d415b20f7dedf62e79d5512.zip",
  1360 + "reference": "8586cf47f117481c6d415b20f7dedf62e79d5512",
  1361 + "shasum": ""
  1362 + },
  1363 + "require": {
  1364 + "ext-gd": "*"
  1365 + },
  1366 + "require-dev": {
  1367 + "phpunit/phpunit": "4.8.*",
  1368 + "topthink/framework": "^5.0"
  1369 + },
  1370 + "type": "library",
  1371 + "autoload": {
  1372 + "psr-4": {
  1373 + "think\\": "src"
  1374 + }
  1375 + },
  1376 + "notification-url": "https://packagist.org/downloads/",
  1377 + "license": [
  1378 + "Apache-2.0"
  1379 + ],
  1380 + "authors": [
  1381 + {
  1382 + "name": "yunwuxin",
  1383 + "email": "448901948@qq.com"
  1384 + }
  1385 + ],
  1386 + "description": "The ThinkPHP5 Image Package",
  1387 + "time": "2016-09-29 06:05:43"
  1388 + },
  1389 + {
  1390 + "name": "topthink/think-installer",
  1391 + "version": "v1.0.11",
  1392 + "source": {
  1393 + "type": "git",
  1394 + "url": "https://github.com/top-think/think-installer.git",
  1395 + "reference": "4c6e1ebecd1afce3f4ccc47e147d61bbe1bf641d"
  1396 + },
  1397 + "dist": {
  1398 + "type": "zip",
  1399 + "url": "https://packagist.phpcomposer.com/files/top-think/think-installer/4c6e1ebecd1afce3f4ccc47e147d61bbe1bf641d.zip",
  1400 + "reference": "4c6e1ebecd1afce3f4ccc47e147d61bbe1bf641d",
  1401 + "shasum": ""
  1402 + },
  1403 + "require": {
  1404 + "composer-plugin-api": "^1.0"
  1405 + },
  1406 + "require-dev": {
  1407 + "composer/composer": "1.0.*@dev"
  1408 + },
  1409 + "type": "composer-plugin",
  1410 + "extra": {
  1411 + "class": "think\\composer\\Plugin"
  1412 + },
  1413 + "autoload": {
  1414 + "psr-4": {
  1415 + "think\\composer\\": "src"
  1416 + }
  1417 + },
  1418 + "notification-url": "https://packagist.org/downloads/",
  1419 + "license": [
  1420 + "Apache-2.0"
  1421 + ],
  1422 + "authors": [
  1423 + {
  1424 + "name": "yunwuxin",
  1425 + "email": "448901948@qq.com"
  1426 + }
  1427 + ],
  1428 + "time": "2016-12-01 09:08:45"
  1429 + },
  1430 + {
  1431 + "name": "topthink/think-migration",
  1432 + "version": "v1.0.6",
  1433 + "source": {
  1434 + "type": "git",
  1435 + "url": "https://github.com/top-think/think-migration.git",
  1436 + "reference": "b2960f9b86c9231f593d5cfb84798176e332c987"
  1437 + },
  1438 + "dist": {
  1439 + "type": "zip",
  1440 + "url": "https://packagist.phpcomposer.com/files/top-think/think-migration/b2960f9b86c9231f593d5cfb84798176e332c987.zip",
  1441 + "reference": "b2960f9b86c9231f593d5cfb84798176e332c987",
  1442 + "shasum": ""
  1443 + },
  1444 + "type": "library",
  1445 + "autoload": {
  1446 + "psr-4": {
  1447 + "Phinx\\": "phinx/src/Phinx",
  1448 + "think\\migration\\": "src"
  1449 + },
  1450 + "files": [
  1451 + "src/config.php"
  1452 + ]
  1453 + },
  1454 + "notification-url": "https://packagist.org/downloads/",
  1455 + "license": [
  1456 + "Apache-2.0"
  1457 + ],
  1458 + "authors": [
  1459 + {
  1460 + "name": "yunwuxin",
  1461 + "email": "448901948@qq.com"
  1462 + }
  1463 + ],
  1464 + "time": "2016-10-17 03:31:17"
  1465 + },
  1466 + {
  1467 + "name": "topthink/think-mongo",
  1468 + "version": "v1.2",
  1469 + "source": {
  1470 + "type": "git",
  1471 + "url": "https://github.com/top-think/think-mongo.git",
  1472 + "reference": "d26ddc47e85d2a1a41a6e38f155610a1c8f66f70"
  1473 + },
  1474 + "dist": {
  1475 + "type": "zip",
  1476 + "url": "https://packagist.phpcomposer.com/files/top-think/think-mongo/d26ddc47e85d2a1a41a6e38f155610a1c8f66f70.zip",
  1477 + "reference": "d26ddc47e85d2a1a41a6e38f155610a1c8f66f70",
  1478 + "shasum": ""
  1479 + },
  1480 + "type": "library",
  1481 + "autoload": {
  1482 + "psr-4": {
  1483 + "think\\mongo\\": "src"
  1484 + },
  1485 + "files": []
  1486 + },
  1487 + "notification-url": "https://packagist.org/downloads/",
  1488 + "license": [
  1489 + "Apache-2.0"
  1490 + ],
  1491 + "authors": [
  1492 + {
  1493 + "name": "liu21st",
  1494 + "email": "liu21st@gmail.com"
  1495 + }
  1496 + ],
  1497 + "description": "mongodb driver for thinkphp5",
  1498 + "time": "2016-11-17 13:20:01"
  1499 + },
  1500 + {
  1501 + "name": "topthink/think-queue",
  1502 + "version": "v1.1.2",
  1503 + "source": {
  1504 + "type": "git",
  1505 + "url": "https://github.com/top-think/think-queue.git",
  1506 + "reference": "503c5b809585ca60cba9485a233aa8be4b22c990"
  1507 + },
  1508 + "dist": {
  1509 + "type": "zip",
  1510 + "url": "https://packagist.phpcomposer.com/files/top-think/think-queue/503c5b809585ca60cba9485a233aa8be4b22c990.zip",
  1511 + "reference": "503c5b809585ca60cba9485a233aa8be4b22c990",
  1512 + "shasum": ""
  1513 + },
  1514 + "require": {
  1515 + "topthink/think-helper": ">=1.0.4",
  1516 + "topthink/think-installer": ">=1.0.10"
  1517 + },
  1518 + "type": "think-extend",
  1519 + "extra": {
  1520 + "think-config": {
  1521 + "queue": "src/config.php"
  1522 + }
  1523 + },
  1524 + "autoload": {
  1525 + "psr-4": {
  1526 + "think\\": "src"
  1527 + },
  1528 + "files": [
  1529 + "src/common.php"
  1530 + ]
  1531 + },
  1532 + "notification-url": "https://packagist.org/downloads/",
  1533 + "license": [
  1534 + "Apache-2.0"
  1535 + ],
  1536 + "authors": [
  1537 + {
  1538 + "name": "yunwuxin",
  1539 + "email": "448901948@qq.com"
  1540 + }
  1541 + ],
  1542 + "description": "The ThinkPHP5 Queue Package",
  1543 + "time": "2016-12-01 04:29:39"
  1544 + },
  1545 + {
  1546 + "name": "topthink/think-sae",
  1547 + "version": "v1.1",
  1548 + "source": {
  1549 + "type": "git",
  1550 + "url": "https://github.com/top-think/think-sae.git",
  1551 + "reference": "e31ee4ec073c0ffc5dbc7292f8268661e5265091"
  1552 + },
  1553 + "dist": {
  1554 + "type": "zip",
  1555 + "url": "https://packagist.phpcomposer.com/files/top-think/think-sae/e31ee4ec073c0ffc5dbc7292f8268661e5265091.zip",
  1556 + "reference": "e31ee4ec073c0ffc5dbc7292f8268661e5265091",
  1557 + "shasum": ""
  1558 + },
  1559 + "type": "library",
  1560 + "autoload": {
  1561 + "psr-4": {
  1562 + "think\\sae\\": "src"
  1563 + },
  1564 + "files": []
  1565 + },
  1566 + "notification-url": "https://packagist.org/downloads/",
  1567 + "license": [
  1568 + "Apache-2.0"
  1569 + ],
  1570 + "authors": [
  1571 + {
  1572 + "name": "liu21st",
  1573 + "email": "liu21st@gmail.com"
  1574 + }
  1575 + ],
  1576 + "description": "sae support for thinkphp5",
  1577 + "time": "2016-10-08 10:53:21"
  1578 + },
  1579 + {
  1580 + "name": "topthink/think-testing",
  1581 + "version": "v1.0.6",
  1582 + "source": {
  1583 + "type": "git",
  1584 + "url": "https://github.com/top-think/think-testing.git",
  1585 + "reference": "e89794e5c58aa5587f7b08038e9468150870b185"
  1586 + },
  1587 + "dist": {
  1588 + "type": "zip",
  1589 + "url": "https://packagist.phpcomposer.com/files/top-think/think-testing/e89794e5c58aa5587f7b08038e9468150870b185.zip",
  1590 + "reference": "e89794e5c58aa5587f7b08038e9468150870b185",
  1591 + "shasum": ""
  1592 + },
  1593 + "require": {
  1594 + "phpunit/phpunit": "^4.8.26",
  1595 + "symfony/dom-crawler": "^2.8.8",
  1596 + "topthink/think-helper": "~1.0",
  1597 + "topthink/think-installer": "~1.0"
  1598 + },
  1599 + "type": "think-testing",
  1600 + "autoload": {
  1601 + "psr-4": {
  1602 + "think\\testing\\": "src"
  1603 + },
  1604 + "files": [
  1605 + "src/config.php"
  1606 + ]
  1607 + },
  1608 + "notification-url": "https://packagist.org/downloads/",
  1609 + "license": [
  1610 + "Apache-2.0"
  1611 + ],
  1612 + "authors": [
  1613 + {
  1614 + "name": "yunwuxin",
  1615 + "email": "448901948@qq.com"
  1616 + }
  1617 + ],
  1618 + "time": "2016-08-08 09:43:56"
  1619 + },
  1620 + {
  1621 + "name": "topthink/think-worker",
  1622 + "version": "v1.0.1",
  1623 + "source": {
  1624 + "type": "git",
  1625 + "url": "https://github.com/top-think/think-worker.git",
  1626 + "reference": "b609ff5e38dbb7194aab027d2b2c6b31a7ed1bd1"
  1627 + },
  1628 + "dist": {
  1629 + "type": "zip",
  1630 + "url": "https://packagist.phpcomposer.com/files/top-think/think-worker/b609ff5e38dbb7194aab027d2b2c6b31a7ed1bd1.zip",
  1631 + "reference": "b609ff5e38dbb7194aab027d2b2c6b31a7ed1bd1",
  1632 + "shasum": ""
  1633 + },
  1634 + "require": {
  1635 + "workerman/workerman": "^3.3.0"
  1636 + },
  1637 + "type": "library",
  1638 + "autoload": {
  1639 + "psr-4": {
  1640 + "think\\worker\\": "src"
  1641 + },
  1642 + "files": []
  1643 + },
  1644 + "notification-url": "https://packagist.org/downloads/",
  1645 + "license": [
  1646 + "Apache-2.0"
  1647 + ],
  1648 + "authors": [
  1649 + {
  1650 + "name": "liu21st",
  1651 + "email": "liu21st@gmail.com"
  1652 + }
  1653 + ],
  1654 + "description": "workerman extend for thinkphp5",
  1655 + "time": "2016-10-08 06:07:03"
  1656 + },
  1657 + {
  1658 + "name": "webmozart/assert",
  1659 + "version": "1.2.0",
  1660 + "source": {
  1661 + "type": "git",
  1662 + "url": "https://github.com/webmozart/assert.git",
  1663 + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f"
  1664 + },
  1665 + "dist": {
  1666 + "type": "zip",
  1667 + "url": "https://packagist.phpcomposer.com/files/webmozart/assert/2db61e59ff05fe5126d152bd0655c9ea113e550f.zip",
  1668 + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f",
  1669 + "shasum": ""
  1670 + },
  1671 + "require": {
  1672 + "php": "^5.3.3 || ^7.0"
  1673 + },
  1674 + "require-dev": {
  1675 + "phpunit/phpunit": "^4.6",
  1676 + "sebastian/version": "^1.0.1"
  1677 + },
  1678 + "type": "library",
  1679 + "extra": {
  1680 + "branch-alias": {
  1681 + "dev-master": "1.3-dev"
  1682 + }
  1683 + },
  1684 + "autoload": {
  1685 + "psr-4": {
  1686 + "Webmozart\\Assert\\": "src/"
  1687 + }
  1688 + },
  1689 + "notification-url": "https://packagist.org/downloads/",
  1690 + "license": [
  1691 + "MIT"
  1692 + ],
  1693 + "authors": [
  1694 + {
  1695 + "name": "Bernhard Schussek",
  1696 + "email": "bschussek@gmail.com"
  1697 + }
  1698 + ],
  1699 + "description": "Assertions to validate method input/output with nice error messages.",
  1700 + "keywords": [
  1701 + "assert",
  1702 + "check",
  1703 + "validate"
  1704 + ],
  1705 + "time": "2016-11-23 20:04:58"
  1706 + },
  1707 + {
  1708 + "name": "workerman/workerman",
  1709 + "version": "v3.3.6",
  1710 + "source": {
  1711 + "type": "git",
  1712 + "url": "https://github.com/walkor/Workerman.git",
  1713 + "reference": "cc02f47bb7bd5f2ce053cf75fcac02565aa729cf"
  1714 + },
  1715 + "dist": {
  1716 + "type": "zip",
  1717 + "url": "https://packagist.phpcomposer.com/files/walkor/Workerman/cc02f47bb7bd5f2ce053cf75fcac02565aa729cf.zip",
  1718 + "reference": "cc02f47bb7bd5f2ce053cf75fcac02565aa729cf",
  1719 + "shasum": ""
  1720 + },
  1721 + "require": {
  1722 + "php": ">=5.3"
  1723 + },
  1724 + "suggest": {
  1725 + "ext-event": "For better performance."
  1726 + },
  1727 + "type": "library",
  1728 + "autoload": {
  1729 + "psr-4": {
  1730 + "Workerman\\": "./"
  1731 + }
  1732 + },
  1733 + "notification-url": "https://packagist.org/downloads/",
  1734 + "license": [
  1735 + "MIT"
  1736 + ],
  1737 + "authors": [
  1738 + {
  1739 + "name": "walkor",
  1740 + "email": "walkor@workerman.net",
  1741 + "homepage": "http://www.workerman.net",
  1742 + "role": "Developer"
  1743 + }
  1744 + ],
  1745 + "description": "An asynchronous event driven PHP framework for easily building fast, scalable network applications.",
  1746 + "homepage": "http://www.workerman.net",
  1747 + "keywords": [
  1748 + "asynchronous",
  1749 + "event-loop"
  1750 + ],
  1751 + "time": "2016-12-22 14:28:34"
  1752 + }
  1753 + ],
  1754 + "packages-dev": [],
  1755 + "aliases": [],
  1756 + "minimum-stability": "stable",
  1757 + "stability-flags": [],
  1758 + "prefer-stable": false,
  1759 + "prefer-lowest": false,
  1760 + "platform": {
  1761 + "php": ">=5.4.0"
  1762 + },
  1763 + "platform-dev": []
  1764 +}
  1 +*
  2 +!.gitignore
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<phpunit backupGlobals="false"
  3 + backupStaticAttributes="false"
  4 + colors="true"
  5 + convertErrorsToExceptions="true"
  6 + convertNoticesToExceptions="true"
  7 + convertWarningsToExceptions="true"
  8 + processIsolation="false"
  9 + stopOnFailure="false"
  10 + syntaxCheck="false">
  11 + <testsuites>
  12 + <testsuite name="Application Test Suite">
  13 + <directory>./tests/</directory>
  14 + </testsuite>
  15 + </testsuites>
  16 + <filter>
  17 + <whitelist>
  18 + <directory suffix=".php">application/</directory>
  19 + </whitelist>
  20 + </filter>
  21 +</phpunit>
不能预览此文件类型
  1 +<?php
  2 +// +----------------------------------------------------------------------
  3 +// | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4 +// +----------------------------------------------------------------------
  5 +// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
  6 +// +----------------------------------------------------------------------
  7 +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8 +// +----------------------------------------------------------------------
  9 +// | Author: liu21st <liu21st@gmail.com>
  10 +// +----------------------------------------------------------------------
  11 +
  12 +// [ 应用入口文件 ]
  13 +
  14 +// 定义应用目录
  15 +define('APP_PATH', __DIR__ . '/../application/');
  16 +// 加载框架引导文件
  17 +require __DIR__ . '/../thinkphp/start.php';
  1 +User-agent: *
  2 +Disallow:
  1 +<?php
  2 +// +----------------------------------------------------------------------
  3 +// | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4 +// +----------------------------------------------------------------------
  5 +// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
  6 +// +----------------------------------------------------------------------
  7 +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8 +// +----------------------------------------------------------------------
  9 +// | Author: liu21st <liu21st@gmail.com>
  10 +// +----------------------------------------------------------------------
  11 +// $Id$
  12 +
  13 +if (is_file($_SERVER["DOCUMENT_ROOT"] . $_SERVER["REQUEST_URI"])) {
  14 + return false;
  15 +} else {
  16 + require __DIR__ . "/index.php";
  17 +}
  1 +*
  2 +!.gitignore
  1 +*
  2 +!.gitignore
  1 +<?php
  2 +// +----------------------------------------------------------------------
  3 +// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  4 +// +----------------------------------------------------------------------
  5 +// | Copyright (c) 2006-2015 http://thinkphp.cn All rights reserved.
  6 +// +----------------------------------------------------------------------
  7 +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8 +// +----------------------------------------------------------------------
  9 +// | Author: yunwuxin <448901948@qq.com>
  10 +// +----------------------------------------------------------------------
  11 +namespace tests;
  12 +
  13 +class ExampleTest extends TestCase
  14 +{
  15 +
  16 + public function testBasicExample()
  17 + {
  18 + $this->visit('/')->see('ThinkPHP');
  19 + }
  20 +}
  1 +<?php
  2 +// +----------------------------------------------------------------------
  3 +// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  4 +// +----------------------------------------------------------------------
  5 +// | Copyright (c) 2006-2015 http://thinkphp.cn All rights reserved.
  6 +// +----------------------------------------------------------------------
  7 +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8 +// +----------------------------------------------------------------------
  9 +// | Author: yunwuxin <448901948@qq.com>
  10 +// +----------------------------------------------------------------------
  11 +namespace tests;
  12 +
  13 +class TestCase extends \think\testing\TestCase
  14 +{
  15 + protected $baseUrl = 'http://localhost';
  16 +}
  1 +#!/usr/bin/env php
  2 +<?php
  3 +// +----------------------------------------------------------------------
  4 +// | ThinkPHP [ WE CAN DO IT JUST THINK ]
  5 +// +----------------------------------------------------------------------
  6 +// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
  7 +// +----------------------------------------------------------------------
  8 +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  9 +// +----------------------------------------------------------------------
  10 +// | Author: yunwuxin <448901948@qq.com>
  11 +// +----------------------------------------------------------------------
  12 +
  13 +// 定义项目路径
  14 +define('APP_PATH', __DIR__ . '/application/');
  15 +
  16 +// 加载框架引导文件
  17 +require './thinkphp/console.php';
  1 +/composer.lock
  2 +/vendor
  3 +.idea
  4 +.DS_Store
  1 +deny from all
  1 +sudo: false
  2 +
  3 +language: php
  4 +
  5 +services:
  6 + - memcached
  7 + - mongodb
  8 + - mysql
  9 + - postgresql
  10 + - redis-server
  11 +
  12 +matrix:
  13 + fast_finish: true
  14 + include:
  15 + - php: 5.4
  16 + - php: 5.5
  17 + - php: 5.6
  18 + - php: 7.0
  19 + - php: hhvm
  20 + allow_failures:
  21 + - php: hhvm
  22 +
  23 +cache:
  24 + directories:
  25 + - $HOME/.composer/cache
  26 +
  27 +before_install:
  28 + - composer self-update
  29 + - mysql -e "create database IF NOT EXISTS test;" -uroot
  30 + - psql -c 'DROP DATABASE IF EXISTS test;' -U postgres
  31 + - psql -c 'create database test;' -U postgres
  32 +
  33 +install:
  34 + - ./tests/script/install.sh
  35 +
  36 +script:
  37 + ## LINT
  38 + - find . -path ./vendor -prune -o -type f -name \*.php -exec php -l {} \;
  39 + ## PHP Copy/Paste Detector
  40 + - vendor/bin/phpcpd --verbose --exclude vendor ./ || true
  41 + ## PHPLOC
  42 + - vendor/bin/phploc --exclude vendor ./
  43 + ## PHPUNIT
  44 + - vendor/bin/phpunit --coverage-clover=coverage.xml --configuration=phpunit.xml
  45 +
  46 +after_success:
  47 + - bash <(curl -s https://codecov.io/bash)