正在显示
28 个修改的文件
包含
2233 行增加
和
2096 行删除
application/admin/validate/item/Details.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\validate\item; | ||
4 | + | ||
5 | +use think\Validate; | ||
6 | + | ||
7 | +class Details extends Validate | ||
8 | +{ | ||
9 | + /** | ||
10 | + * 验证规则 | ||
11 | + */ | ||
12 | + protected $rule = [ | ||
13 | + ]; | ||
14 | + /** | ||
15 | + * 提示消息 | ||
16 | + */ | ||
17 | + protected $message = [ | ||
18 | + ]; | ||
19 | + /** | ||
20 | + * 验证场景 | ||
21 | + */ | ||
22 | + protected $scene = [ | ||
23 | + 'add' => [], | ||
24 | + 'edit' => [], | ||
25 | + ]; | ||
26 | + | ||
27 | +} |
1 | -<table class="table table-striped"> | ||
2 | - <thead> | ||
3 | - <tr> | ||
4 | - <th>{:__('个人名称')}</th> | ||
5 | - <th>{:__('个人票数')}</th> | ||
6 | - </tr> | ||
7 | - </thead> | ||
8 | - <tbody> | ||
9 | - {/*{volist name="row" id="vo"&cc; | ||
10 | - <tr> | ||
11 | - <td>{$key&cc;</td> | ||
12 | - <td style="word-break: break-all;">{$vo|htmlentities&cc;</td> | ||
13 | - </tr> | ||
14 | - {/volist&cc;*/} | ||
15 | - <tr> | ||
16 | - <td>{$row.name}</td> | ||
17 | - <td style="word-break: break-all;">{$row.score}</td> | ||
18 | - </tr> | ||
19 | - </tbody> | ||
20 | -</table> | ||
21 | -<div class="hide layer-footer"> | ||
22 | - <label class="control-label col-xs-12 col-sm-2"></label> | ||
23 | - <div class="col-xs-12 col-sm-8"> | ||
24 | - <button type="reset" class="btn btn-primary btn-embossed btn-close" onclick="Layer.closeAll();">{:__('Close')}</button> | ||
25 | - </div> | ||
26 | -</div> | 1 | +<table class="table table-striped"> |
2 | + <thead> | ||
3 | + <tr> | ||
4 | + <th>{:__('个人名称')}</th> | ||
5 | + <th>{:__('个人票数')}</th> | ||
6 | + </tr> | ||
7 | + </thead> | ||
8 | + <tbody> | ||
9 | + {/*{volist name="row" id="vo"&cc; | ||
10 | + <tr> | ||
11 | + <td>{$key&cc;</td> | ||
12 | + <td style="word-break: break-all;">{$vo|htmlentities&cc;</td> | ||
13 | + </tr> | ||
14 | + {/volist&cc;*/} | ||
15 | + <tr> | ||
16 | + <td>{$row.name}</td> | ||
17 | + <td style="word-break: break-all;">{$row.score}</td> | ||
18 | + </tr> | ||
19 | + </tbody> | ||
20 | +</table> | ||
21 | +<div class="hide layer-footer"> | ||
22 | + <label class="control-label col-xs-12 col-sm-2"></label> | ||
23 | + <div class="col-xs-12 col-sm-8"> | ||
24 | + <button type="reset" class="btn btn-primary btn-embossed btn-close" onclick="Layer.closeAll();">{:__('Close')}</button> | ||
25 | + </div> | ||
26 | +</div> |
1 | -<table class="table table-striped"> | ||
2 | - <thead> | ||
3 | - <tr> | ||
4 | - <th>{:__('战队名称')}</th> | ||
5 | - <th>{:__('战队票数')}</th> | ||
6 | - </tr> | ||
7 | - </thead> | ||
8 | - <tbody> | ||
9 | - {/*{volist name="row" id="vo"&cc; | ||
10 | - <tr> | ||
11 | - <td>{$key&cc;</td> | ||
12 | - <td style="word-break: break-all;">{$vo|htmlentities&cc;</td> | ||
13 | - </tr> | ||
14 | - {/volist&cc;*/} | ||
15 | - <tr> | ||
16 | - <td>{$row.title}</td> | ||
17 | - <td style="word-break: break-all;">{$row.score}</td> | ||
18 | - </tr> | ||
19 | - </tbody> | ||
20 | -</table> | ||
21 | -<div class="hide layer-footer"> | ||
22 | - <label class="control-label col-xs-12 col-sm-2"></label> | ||
23 | - <div class="col-xs-12 col-sm-8"> | ||
24 | - <button type="reset" class="btn btn-primary btn-embossed btn-close" onclick="Layer.closeAll();">{:__('Close')}</button> | ||
25 | - </div> | ||
26 | -</div> | 1 | +<table class="table table-striped"> |
2 | + <thead> | ||
3 | + <tr> | ||
4 | + <th>{:__('战队名称')}</th> | ||
5 | + <th>{:__('战队票数')}</th> | ||
6 | + </tr> | ||
7 | + </thead> | ||
8 | + <tbody> | ||
9 | + {/*{volist name="row" id="vo"&cc; | ||
10 | + <tr> | ||
11 | + <td>{$key&cc;</td> | ||
12 | + <td style="word-break: break-all;">{$vo|htmlentities&cc;</td> | ||
13 | + </tr> | ||
14 | + {/volist&cc;*/} | ||
15 | + <tr> | ||
16 | + <td>{$row.title}</td> | ||
17 | + <td style="word-break: break-all;">{$row.score}</td> | ||
18 | + </tr> | ||
19 | + </tbody> | ||
20 | +</table> | ||
21 | +<div class="hide layer-footer"> | ||
22 | + <label class="control-label col-xs-12 col-sm-2"></label> | ||
23 | + <div class="col-xs-12 col-sm-8"> | ||
24 | + <button type="reset" class="btn btn-primary btn-embossed btn-close" onclick="Layer.closeAll();">{:__('Close')}</button> | ||
25 | + </div> | ||
26 | +</div> |
1 | -<?php | ||
2 | - | ||
3 | -namespace app\api\controller; | ||
4 | - | ||
5 | -use app\common\controller\Api; | ||
6 | - | ||
7 | -/** | ||
8 | - * 活动接口 | ||
9 | - * @ApiWeigh (97) | ||
10 | - */ | ||
11 | -class Activity extends Api | ||
12 | -{ | ||
13 | - protected $noNeedLogin = ['']; | ||
14 | - protected $noNeedRight = ['*']; | ||
15 | - | ||
16 | - /** | ||
17 | - * @ApiTitle (活动首页) | ||
18 | - * @ApiMethod (POST) | ||
19 | - * @ApiReturn ({"code":状态码, | ||
20 | - "msg":"提示信息" | ||
21 | - "time": "时间戳", | ||
22 | - "data": [ | ||
23 | - "id": 1, | ||
24 | - "title": "活动名称", | ||
25 | - "images": "活动图片", | ||
26 | - "depict": "描述", | ||
27 | - ] | ||
28 | - }) | ||
29 | - */ | ||
30 | - public function index() | ||
31 | - { | ||
32 | - $data = db('activity') | ||
33 | - ->order('createtime DESC') | ||
34 | - ->select(); | ||
35 | - if (!$data) { | ||
36 | - $this->error('当前还没有活动', ['status' => 2]); | ||
37 | - } | ||
38 | - foreach ($data as $k => $v) { | ||
39 | - $data[$k]['images'] = cdnurl($v['images'], true); | ||
40 | - $data[$k]['createtime'] = date('Y-m-d', $v['createtime']); | ||
41 | - } | ||
42 | - $this->success('全部项目', $data); | ||
43 | - | ||
44 | - } | ||
45 | - | ||
46 | - /** | ||
47 | - * @ApiTitle (项目校区) | ||
48 | - * @ApiMethod (POST) | ||
49 | - * @ApiParams (name="id", type="string", required=false, description="活动id") | ||
50 | - * @ApiReturnParams (name="code", type="integer", required=true, description="状态码") | ||
51 | - * @ApiReturnParams (name="msg", type="string", required=true, description="提示语") | ||
52 | - * @ApiReturnParams (name="data", type="object", description="扩展数据返回") | ||
53 | - * @ApiReturn ({ | ||
54 | - "code":"状态码", | ||
55 | - "msg": "提示消息", | ||
56 | - "data": {} | ||
57 | - }) | ||
58 | - */ | ||
59 | - public function getSchoolItem() | ||
60 | - { | ||
61 | - $id = $this->request->param('id'); | ||
62 | - if (empty($id)) { | ||
63 | - $this->error('参数错误', ['status' => 3]); | ||
64 | - } | ||
65 | - $data = db('campus c') | ||
66 | - ->join('activity a','a.id = c.activity_id') | ||
67 | - ->join('school s','s.id = c.school_id') | ||
68 | - ->where('c.activity_id', $id) | ||
69 | - ->field('c.*,a.title as activity_name,s.title as school_name') | ||
70 | - ->paginate(10,false); | ||
71 | - if (empty($data)) { | ||
72 | - $this->error('空空', ['status' => 3]); | ||
73 | - } | ||
74 | - $this->success('项目校区', $data); | ||
75 | - } | ||
76 | - | ||
77 | - /** | ||
78 | - * @ApiTitle (项目日期场次) | ||
79 | - * @ApiMethod (POST) | ||
80 | - * @ApiParams (name="id", type="string", required=false, description="校区id") | ||
81 | - * @ApiReturnParams (name="code", type="integer", required=true, description="状态码") | ||
82 | - * @ApiReturnParams (name="msg", type="string", required=true, description="提示语") | ||
83 | - * @ApiReturnParams (name="data", type="object", description="扩展数据返回") | ||
84 | - * @ApiReturn ({ | ||
85 | - "code":"状态码", | ||
86 | - "msg": "提示消息", | ||
87 | - "data": { | ||
88 | - "campus_title": "校区名称", | ||
89 | - "ronda_title": "场次", | ||
90 | - "ronda_holdtime": "场次时间", | ||
91 | - "title": "项目名称", | ||
92 | - "images": "项目图片", | ||
93 | - "details": "项目详情" | ||
94 | - } | ||
95 | - }) | ||
96 | - */ | ||
97 | - public function getItemRonda() | ||
98 | - { | ||
99 | - $id = $this->request->param('id'); | ||
100 | - if (empty($id)) { | ||
101 | - $this->error('参数错误', ['status' => 2]); | ||
102 | - } | ||
103 | - $data = db('item i') | ||
104 | - ->join('item_details d','d.item_id = i.id') | ||
105 | - ->join('ronda r','i.ronda_id = r.id') | ||
106 | - ->join('campus c','c.id = i.campus_id') | ||
107 | - ->field('c.title as campus_title,r.title as ronda_title,r.holdtime as ronda_holdtime,i.title,d.images,i.details') | ||
108 | - ->where('i.campus_id',$id) | ||
109 | - ->paginate(10) | ||
110 | - ->each(function ($item,$key){ | ||
111 | - $item['images'] = cdnurl($item['images'],true); | ||
112 | - return $item; | ||
113 | - }); | ||
114 | - $this->success('项目场次日期', $data); | ||
115 | - } | ||
116 | - | ||
117 | - /** | ||
118 | - * @ApiTitle (项目详情) | ||
119 | - * @ApiMethod (POST) | ||
120 | - * @ApiParams (name="id", type="string", required=false, description="项目id") | ||
121 | - * @ApiReturnParams (name="code", type="integer", required=true, description="状态码") | ||
122 | - * @ApiReturnParams (name="msg", type="string", required=true, description="提示语") | ||
123 | - * @ApiReturnParams (name="data", type="object", description="扩展数据返回") | ||
124 | - * @ApiReturn ({ | ||
125 | - "code":"状态码", | ||
126 | - "msg": "提示消息", | ||
127 | - "data": { | ||
128 | - "campus_title": "校区名称", | ||
129 | - "images": "项目图片", | ||
130 | - "details": "项目详情" | ||
131 | - }) | ||
132 | - */ | ||
133 | - public function getItemDetails() | ||
134 | - { | ||
135 | - $id = $this->request->param('id'); | ||
136 | - $data = db('item i') | ||
137 | - ->join('item_details d','d.item_id = i.id') | ||
138 | - ->join('campus c','c.id = i.campus_id') | ||
139 | - ->field('c.title as campus_title,d.images,i.details') | ||
140 | - ->where('i.id', $id) | ||
141 | - ->find(); | ||
142 | - $data['images'] = cdnurl($data['images'], true); | ||
143 | - $this->success('获取项目详情成功', $data); | ||
144 | - } | 1 | +<?php |
2 | + | ||
3 | +namespace app\api\controller; | ||
4 | + | ||
5 | +use app\common\controller\Api; | ||
6 | + | ||
7 | +/** | ||
8 | + * 活动接口 | ||
9 | + * @ApiWeigh (97) | ||
10 | + */ | ||
11 | +class Activity extends Api | ||
12 | +{ | ||
13 | + protected $noNeedLogin = ['']; | ||
14 | + protected $noNeedRight = ['*']; | ||
15 | + | ||
16 | + /** | ||
17 | + * @ApiTitle (活动首页) | ||
18 | + * @ApiMethod (POST) | ||
19 | + * @ApiReturn ({"code":状态码, | ||
20 | + "msg":"提示信息" | ||
21 | + "time": "时间戳", | ||
22 | + "data": [ | ||
23 | + "id": 1, | ||
24 | + "title": "活动名称", | ||
25 | + "images": "活动图片", | ||
26 | + "depict": "描述", | ||
27 | + ] | ||
28 | + }) | ||
29 | + */ | ||
30 | + public function index() | ||
31 | + { | ||
32 | + $data = db('activity') | ||
33 | + ->order('createtime DESC') | ||
34 | + ->select(); | ||
35 | + if (!$data) { | ||
36 | + $this->error('当前还没有活动', ['status' => 2]); | ||
37 | + } | ||
38 | + foreach ($data as $k => $v) { | ||
39 | + $data[$k]['images'] = cdnurl($v['images'], true); | ||
40 | + $data[$k]['createtime'] = date('Y-m-d', $v['createtime']); | ||
41 | + } | ||
42 | + $this->success('全部项目', $data); | ||
43 | + | ||
44 | + } | ||
45 | + | ||
46 | + /** | ||
47 | + * @ApiTitle (项目校区) | ||
48 | + * @ApiMethod (POST) | ||
49 | + * @ApiParams (name="id", type="string", required=false, description="活动id") | ||
50 | + * @ApiReturnParams (name="code", type="integer", required=true, description="状态码") | ||
51 | + * @ApiReturnParams (name="msg", type="string", required=true, description="提示语") | ||
52 | + * @ApiReturnParams (name="data", type="object", description="扩展数据返回") | ||
53 | + * @ApiReturn ({ | ||
54 | + "code":"状态码", | ||
55 | + "msg": "提示消息", | ||
56 | + "data": {} | ||
57 | + }) | ||
58 | + */ | ||
59 | + public function getSchoolItem() | ||
60 | + { | ||
61 | + $id = $this->request->param('id'); | ||
62 | + if (empty($id)) { | ||
63 | + $this->error('参数错误', ['status' => 3]); | ||
64 | + } | ||
65 | + $data = db('campus c') | ||
66 | + ->join('activity a','a.id = c.activity_id') | ||
67 | + ->join('school s','s.id = c.school_id') | ||
68 | + ->where('c.activity_id', $id) | ||
69 | + ->field('c.*,a.title as activity_name,s.title as school_name') | ||
70 | + ->paginate(10,false); | ||
71 | + if (empty($data)) { | ||
72 | + $this->error('空空', ['status' => 3]); | ||
73 | + } | ||
74 | + $this->success('项目校区', $data); | ||
75 | + } | ||
76 | + | ||
77 | + /** | ||
78 | + * @ApiTitle (项目日期场次) | ||
79 | + * @ApiMethod (POST) | ||
80 | + * @ApiParams (name="id", type="string", required=false, description="校区id") | ||
81 | + * @ApiReturnParams (name="code", type="integer", required=true, description="状态码") | ||
82 | + * @ApiReturnParams (name="msg", type="string", required=true, description="提示语") | ||
83 | + * @ApiReturnParams (name="data", type="object", description="扩展数据返回") | ||
84 | + * @ApiReturn ({ | ||
85 | + "code":"状态码", | ||
86 | + "msg": "提示消息", | ||
87 | + "data": { | ||
88 | + "campus_title": "校区名称", | ||
89 | + "ronda_title": "场次", | ||
90 | + "ronda_holdtime": "场次时间", | ||
91 | + "title": "项目名称", | ||
92 | + "images": "项目图片", | ||
93 | + "details": "项目详情" | ||
94 | + } | ||
95 | + }) | ||
96 | + */ | ||
97 | + public function getItemRonda() | ||
98 | + { | ||
99 | + $id = $this->request->param('id'); | ||
100 | + if (empty($id)) { | ||
101 | + $this->error('参数错误', ['status' => 2]); | ||
102 | + } | ||
103 | + $data = db('item i') | ||
104 | + ->join('item_details d','d.item_id = i.id') | ||
105 | + ->join('ronda r','i.ronda_id = r.id') | ||
106 | + ->join('campus c','c.id = i.campus_id') | ||
107 | + ->field('c.title as campus_title,r.title as ronda_title,r.holdtime as ronda_holdtime,i.title,d.images,i.details') | ||
108 | + ->where('i.campus_id',$id) | ||
109 | + ->paginate(10) | ||
110 | + ->each(function ($item,$key){ | ||
111 | + $item['images'] = cdnurl($item['images'],true); | ||
112 | + return $item; | ||
113 | + }); | ||
114 | + $this->success('项目场次日期', $data); | ||
115 | + } | ||
116 | + | ||
117 | + /** | ||
118 | + * @ApiTitle (项目详情) | ||
119 | + * @ApiMethod (POST) | ||
120 | + * @ApiParams (name="id", type="string", required=false, description="项目id") | ||
121 | + * @ApiReturnParams (name="code", type="integer", required=true, description="状态码") | ||
122 | + * @ApiReturnParams (name="msg", type="string", required=true, description="提示语") | ||
123 | + * @ApiReturnParams (name="data", type="object", description="扩展数据返回") | ||
124 | + * @ApiReturn ({ | ||
125 | + "code":"状态码", | ||
126 | + "msg": "提示消息", | ||
127 | + "data": { | ||
128 | + "campus_title": "校区名称", | ||
129 | + "images": "项目图片", | ||
130 | + "details": "项目详情" | ||
131 | + }) | ||
132 | + */ | ||
133 | + public function getItemDetails() | ||
134 | + { | ||
135 | + $id = $this->request->param('id'); | ||
136 | + $data = db('item i') | ||
137 | + ->join('item_details d','d.item_id = i.id') | ||
138 | + ->join('campus c','c.id = i.campus_id') | ||
139 | + ->field('c.title as campus_title,d.images,i.details') | ||
140 | + ->where('i.id', $id) | ||
141 | + ->find(); | ||
142 | + $data['images'] = cdnurl($data['images'], true); | ||
143 | + $this->success('获取项目详情成功', $data); | ||
144 | + } | ||
145 | } | 145 | } |
1 | -<?php | ||
2 | - | ||
3 | -namespace app\api\controller; | ||
4 | - | ||
5 | -use app\common\controller\Api; | ||
6 | -use think\Db; | ||
7 | -use think\Exception; | ||
8 | -use think\exception\PDOException; | ||
9 | - | ||
10 | -/** | ||
11 | - * 绑定资质 | ||
12 | - * @ApiWeigh (96) | ||
13 | - */ | ||
14 | -class Bind extends Api | ||
15 | -{ | ||
16 | - protected $noNeedLogin = ['']; | ||
17 | - protected $noNeedRight = ['*']; | ||
18 | - | ||
19 | - | ||
20 | - /** | ||
21 | - * @ApiTitle (输入学号绑定信息) | ||
22 | - * @ApiMethod (POST) | ||
23 | - * @ApiParams (name="xh", type="string", required=true, description="学号") | ||
24 | - * @ApiReturn ({ | ||
25 | - "code":"状态码", | ||
26 | - "msg": "提示消息", | ||
27 | - "data": {} | ||
28 | - }) | ||
29 | - */ | ||
30 | - public function inputSno() | ||
31 | - { | ||
32 | - $sno = $this->request->param('sno'); | ||
33 | - $user = $this->auth->getUserinfo(); | ||
34 | - if (empty($sno)) { | ||
35 | - $this->error('参数错误', ['status' => 2]); | ||
36 | - } | ||
37 | - $is_bind = db('user')->where('id', $user['id'])->value('bind_study'); | ||
38 | - if ($is_bind == 1) { | ||
39 | - $this->error('您当前已经绑定过学生了,请勿重复操作', $is_bind); | ||
40 | - } | ||
41 | - Db::startTrans(); | ||
42 | - try { | ||
43 | - db('study') | ||
44 | - ->where('sno', $sno) | ||
45 | - ->update([ | ||
46 | - 'user_id' => $user['id'], | ||
47 | - 'updatetime' => time() | ||
48 | - ]); | ||
49 | - \db('user') | ||
50 | - ->where('id', $user['id']) | ||
51 | - ->update([ | ||
52 | - 'bind_study' => 1, | ||
53 | - 'updatetime' => time() | ||
54 | - ]); | ||
55 | - Db::commit(); | ||
56 | - } catch (Exception $e) { | ||
57 | - Db::rollback(); | ||
58 | - $this->error('参数错误', $e->getMessage()); | ||
59 | - } | ||
60 | - $this->success('绑定成功'); | ||
61 | - } | ||
62 | - | ||
63 | - /** | ||
64 | - * @ApiTitle (扫码绑定信息) | ||
65 | - * @ApiMethod (POST) | ||
66 | - * @ApiParams (name="unique", type="string", required=true, description="条形码id") | ||
67 | - * @ApiReturn ({ | ||
68 | - "code":"状态码", | ||
69 | - "msg": "提示消息", | ||
70 | - "data": {} | ||
71 | - }) | ||
72 | - */ | ||
73 | - public function scanCode() | ||
74 | - { | ||
75 | - $unique = $this->request->param('unique'); | ||
76 | - $user = $this->auth->getUserinfo(); | ||
77 | - if (empty($unique)) { | ||
78 | - $this->error('参数错误', ['status' => 2]); | ||
79 | - } | ||
80 | - $is_bind = db('user')->where('id', $user['id'])->value('bind_study'); | ||
81 | - if ($is_bind == 1) { | ||
82 | - $this->error('您当前已经绑定过学生了,请勿重复操作', $is_bind); | ||
83 | - } | ||
84 | - Db::startTrans(); | ||
85 | - try { | ||
86 | - db('study') | ||
87 | - ->where('unique', $unique) | ||
88 | - ->update([ | ||
89 | - 'user_id' => $user['id'], | ||
90 | - 'updatetime' => time() | ||
91 | - ]); | ||
92 | - \db('user') | ||
93 | - ->where('id', $user['id']) | ||
94 | - ->update([ | ||
95 | - 'bind_study' => 1, | ||
96 | - 'updatetime' => time() | ||
97 | - ]); | ||
98 | - Db::commit(); | ||
99 | - } catch (Exception $e) { | ||
100 | - Db::rollback(); | ||
101 | - $this->error('参数错误', $e->getMessage()); | ||
102 | - } | ||
103 | - $data = db('study')->where('unique', $unique)->field('id,grade,name,sno')->find(); | ||
104 | - $this->success('绑定成功', [$data, 'status' => 1]); | ||
105 | - } | ||
106 | - | ||
107 | - /** | ||
108 | - * @ApiTitle (项目管理[老师]) | ||
109 | - * @ApiMethod (POST) | ||
110 | - * @ApiReturn ({ | ||
111 | - "code":"状态码", | ||
112 | - "msg": "提示消息", | ||
113 | - "data": { | ||
114 | - "id": 项目id, | ||
115 | - "title": "项目名称", | ||
116 | - "radar_id": "维度id", | ||
117 | - "user_id": "用户id", | ||
118 | - "ronda_id": "场次id", | ||
119 | - "score": "项目积分", | ||
120 | - "createtime": "创建时间", | ||
121 | - "updatetime": "更新时间" | ||
122 | - } | ||
123 | - }) | ||
124 | - */ | ||
125 | - public function teachItem() | ||
126 | - { | ||
127 | - $user = $this->auth->getUserinfo(); | ||
128 | - $data = db('item') | ||
129 | - ->where('user_id', $user['id']) | ||
130 | - ->select(); | ||
131 | - if (empty($data)) { | ||
132 | - $this->error('当前还未关联项目', ['status' => 2]); | ||
133 | - } | ||
134 | - $this->success('获取项目成功', [$data, 'status' => 1]); | ||
135 | - } | ||
136 | - | ||
137 | - /** | ||
138 | - * @ApiTitle (活动现场[扫码]) | ||
139 | - * @ApiMethod (POST) | ||
140 | - * @ApiParams (name="items_id", type="string", required=true, description="项目id") | ||
141 | - * @ApiParams (name="unique", type="string", required=true, description="条形码唯一标识") | ||
142 | - * @ApiReturn ({ | ||
143 | - "code":"状态码", | ||
144 | - "msg": "提示消息", | ||
145 | - "data": { | ||
146 | - "name": "姓名", | ||
147 | - "gender": "性别", | ||
148 | - "sno": "学号" | ||
149 | - } | ||
150 | - }) | ||
151 | - */ | ||
152 | - public function Ewm() | ||
153 | - { | ||
154 | - $items_id = $this->request->param('items_id'); | ||
155 | - $unique = $this->request->param('unique'); | ||
156 | - if (empty($unique) && empty($items_id)) { | ||
157 | - $this->error('参数错误', ['status' => 2]); | ||
158 | - } | ||
159 | - $study = db('study')->where('unique', $unique)->field('id,grade,name,sno,team_id,earn_score')->find(); | ||
160 | - $item = db('item')->where('id', $items_id)->field('score,title,campus_id')->find(); | ||
161 | - $team = \db('team')->where('id', $study['team_id'])->field('title,score')->find(); | ||
162 | - $sum1 = $team['score'] + $item['score']; //合计战队总分 | ||
163 | - $sum2 = $study['earn_score'] + $item['score']; //合计个人总分 | ||
164 | - Db::startTrans(); | ||
165 | - try { | ||
166 | - db('study_score_log')->insert([ | ||
167 | - 'item_id' => $items_id, | ||
168 | - 'campus_id' => $item['campus_id'], | ||
169 | - 'study_id' => $study['id'], | ||
170 | - 'team_id' => $study['team_id'], | ||
171 | - 'score' => $item['score'], | ||
172 | - 'memo' => $study['name'] . '参加' . $item['title'] . '项目给' . $team['title'] . '加分', | ||
173 | - 'createtime' => time() | ||
174 | - ]); | ||
175 | - db('study') | ||
176 | - ->where('id', $study['id']) | ||
177 | - ->update([ | ||
178 | - 'earn_score' => $sum2, | ||
179 | - ]); | ||
180 | - \db('team') | ||
181 | - ->where('id', $study['team_id']) | ||
182 | - ->update([ | ||
183 | - 'score' => $sum1, | ||
184 | - 'updatetime' => time() | ||
185 | - ]); | ||
186 | - Db::commit(); | ||
187 | - } catch (Exception $e) { | ||
188 | - Db::rollback(); | ||
189 | - $this->error('连接错误', ['status' => 3]); | ||
190 | - } | ||
191 | - $data = db('study')->where('unique', $unique)->field('name,gender,sno')->find(); | ||
192 | - $this->success('扫码成功', [$data, 'status' => 1]); | ||
193 | - } | ||
194 | - | ||
195 | - /** | ||
196 | - * @ApiTitle (获取学生信息) | ||
197 | - * @ApiMethod (POST) | ||
198 | - * @ApiParams (name="campus_id", type="string", required=true, description="校区id") | ||
199 | - * @ApiReturn ({ | ||
200 | - "code":"状态码", | ||
201 | - "msg": "提示消息", | ||
202 | - "data": { | ||
203 | - "avatar": "学生头像", | ||
204 | - "name": "学生名称", | ||
205 | - "earn_score": "学生获得分数" | ||
206 | - "study_score": 学生积分构成{ | ||
207 | - "total": 2, | ||
208 | - "per_page": 3, | ||
209 | - "current_page": 1, | ||
210 | - "last_page": 1, | ||
211 | - "data": [ | ||
212 | - { | ||
213 | - "item_id": 项目id, | ||
214 | - "sum_score": "项目所获分数", | ||
215 | - "item_ronda": 项目对应雷达维度名称[ | ||
216 | - { | ||
217 | - "radar_id": 雷达维度id, | ||
218 | - "title": "雷达维度名称" | ||
219 | - } | ||
220 | - ] | ||
221 | - },} | ||
222 | - }) | ||
223 | - */ | ||
224 | - public function getScore() | ||
225 | - { | ||
226 | - $user = $this->auth->getUserinfo(); | ||
227 | - $campus_id = $this->request->param('campus_id'); | ||
228 | - $sid = \db('study')->where('user_id', $user['id'])->value('id'); | ||
229 | - //获取学生的信息 | ||
230 | - $data = \db('study')->where('id', $sid)->field('avatar,name,earn_score')->find(); | ||
231 | - $data['avatar'] = cdnurl( $data['avatar'], true); | ||
232 | - //获取雷达维度 | ||
233 | - $data['study_score'] = \db('study_score_log') | ||
234 | - ->distinct('item_id') | ||
235 | - ->field('item_id,SUM(score) as sum_score') | ||
236 | - ->group('item_id') | ||
237 | - ->where(['campus_id' => $campus_id, 'study_id' => $sid]) | ||
238 | - ->paginate(3, false) | ||
239 | - ->each(function ($item, $key) { | ||
240 | - $item['item_radar'] = \db('item i') | ||
241 | - ->join('radar r', 'i.radar_id = r.id') | ||
242 | - ->where('i.id', $item['item_id']) | ||
243 | - ->field('i.radar_id,r.title') | ||
244 | - ->select(); | ||
245 | - return $item; | ||
246 | - }); | ||
247 | - $this->success('获取学生信息成功', $data); | ||
248 | - } | ||
249 | - | 1 | +<?php |
2 | + | ||
3 | +namespace app\api\controller; | ||
4 | + | ||
5 | +use app\common\controller\Api; | ||
6 | +use think\Db; | ||
7 | +use think\Exception; | ||
8 | +use think\exception\PDOException; | ||
9 | + | ||
10 | +/** | ||
11 | + * 绑定资质 | ||
12 | + * @ApiWeigh (96) | ||
13 | + */ | ||
14 | +class Bind extends Api | ||
15 | +{ | ||
16 | + protected $noNeedLogin = ['']; | ||
17 | + protected $noNeedRight = ['*']; | ||
18 | + | ||
19 | + | ||
20 | + /** | ||
21 | + * @ApiTitle (输入学号绑定信息) | ||
22 | + * @ApiMethod (POST) | ||
23 | + * @ApiParams (name="xh", type="string", required=true, description="学号") | ||
24 | + * @ApiReturn ({ | ||
25 | + "code":"状态码", | ||
26 | + "msg": "提示消息", | ||
27 | + "data": {} | ||
28 | + }) | ||
29 | + */ | ||
30 | + public function inputSno() | ||
31 | + { | ||
32 | + $sno = $this->request->param('sno'); | ||
33 | + $user = $this->auth->getUserinfo(); | ||
34 | + if (empty($sno)) { | ||
35 | + $this->error('参数错误', ['status' => 2]); | ||
36 | + } | ||
37 | + $is_bind = db('user')->where('id', $user['id'])->value('bind_study'); | ||
38 | + if ($is_bind == 1) { | ||
39 | + $this->error('您当前已经绑定过学生了,请勿重复操作', $is_bind); | ||
40 | + } | ||
41 | + Db::startTrans(); | ||
42 | + try { | ||
43 | + db('study') | ||
44 | + ->where('sno', $sno) | ||
45 | + ->update([ | ||
46 | + 'user_id' => $user['id'], | ||
47 | + 'updatetime' => time() | ||
48 | + ]); | ||
49 | + \db('user') | ||
50 | + ->where('id', $user['id']) | ||
51 | + ->update([ | ||
52 | + 'bind_study' => 1, | ||
53 | + 'updatetime' => time() | ||
54 | + ]); | ||
55 | + Db::commit(); | ||
56 | + } catch (Exception $e) { | ||
57 | + Db::rollback(); | ||
58 | + $this->error('参数错误', $e->getMessage()); | ||
59 | + } | ||
60 | + $this->success('绑定成功'); | ||
61 | + } | ||
62 | + | ||
63 | + /** | ||
64 | + * @ApiTitle (扫码绑定信息) | ||
65 | + * @ApiMethod (POST) | ||
66 | + * @ApiParams (name="unique", type="string", required=true, description="条形码id") | ||
67 | + * @ApiReturn ({ | ||
68 | + "code":"状态码", | ||
69 | + "msg": "提示消息", | ||
70 | + "data": {} | ||
71 | + }) | ||
72 | + */ | ||
73 | + public function scanCode() | ||
74 | + { | ||
75 | + $unique = $this->request->param('unique'); | ||
76 | + $user = $this->auth->getUserinfo(); | ||
77 | + if (empty($unique)) { | ||
78 | + $this->error('参数错误', ['status' => 2]); | ||
79 | + } | ||
80 | + $is_bind = db('user')->where('id', $user['id'])->value('bind_study'); | ||
81 | + if ($is_bind == 1) { | ||
82 | + $this->error('您当前已经绑定过学生了,请勿重复操作', $is_bind); | ||
83 | + } | ||
84 | + Db::startTrans(); | ||
85 | + try { | ||
86 | + db('study') | ||
87 | + ->where('unique', $unique) | ||
88 | + ->update([ | ||
89 | + 'user_id' => $user['id'], | ||
90 | + 'updatetime' => time() | ||
91 | + ]); | ||
92 | + \db('user') | ||
93 | + ->where('id', $user['id']) | ||
94 | + ->update([ | ||
95 | + 'bind_study' => 1, | ||
96 | + 'updatetime' => time() | ||
97 | + ]); | ||
98 | + Db::commit(); | ||
99 | + } catch (Exception $e) { | ||
100 | + Db::rollback(); | ||
101 | + $this->error('参数错误', $e->getMessage()); | ||
102 | + } | ||
103 | + $data = db('study')->where('unique', $unique)->field('id,grade,name,sno')->find(); | ||
104 | + $this->success('绑定成功', [$data, 'status' => 1]); | ||
105 | + } | ||
106 | + | ||
107 | + /** | ||
108 | + * @ApiTitle (项目管理[老师]) | ||
109 | + * @ApiMethod (POST) | ||
110 | + * @ApiReturn ({ | ||
111 | + "code":"状态码", | ||
112 | + "msg": "提示消息", | ||
113 | + "data": { | ||
114 | + "id": 项目id, | ||
115 | + "title": "项目名称", | ||
116 | + "radar_id": "维度id", | ||
117 | + "user_id": "用户id", | ||
118 | + "ronda_id": "场次id", | ||
119 | + "score": "项目积分", | ||
120 | + "createtime": "创建时间", | ||
121 | + "updatetime": "更新时间" | ||
122 | + } | ||
123 | + }) | ||
124 | + */ | ||
125 | + public function teachItem() | ||
126 | + { | ||
127 | + $user = $this->auth->getUserinfo(); | ||
128 | + $data = db('item') | ||
129 | + ->where('user_id', $user['id']) | ||
130 | + ->select(); | ||
131 | + if (empty($data)) { | ||
132 | + $this->error('当前还未关联项目', ['status' => 2]); | ||
133 | + } | ||
134 | + $this->success('获取项目成功', [$data, 'status' => 1]); | ||
135 | + } | ||
136 | + | ||
137 | + /** | ||
138 | + * @ApiTitle (活动现场[扫码]) | ||
139 | + * @ApiMethod (POST) | ||
140 | + * @ApiParams (name="items_id", type="string", required=true, description="项目id") | ||
141 | + * @ApiParams (name="unique", type="string", required=true, description="条形码唯一标识") | ||
142 | + * @ApiReturn ({ | ||
143 | + "code":"状态码", | ||
144 | + "msg": "提示消息", | ||
145 | + "data": { | ||
146 | + "name": "姓名", | ||
147 | + "gender": "性别", | ||
148 | + "sno": "学号" | ||
149 | + } | ||
150 | + }) | ||
151 | + */ | ||
152 | + public function Ewm() | ||
153 | + { | ||
154 | + $items_id = $this->request->param('items_id'); | ||
155 | + $unique = $this->request->param('unique'); | ||
156 | + if (empty($unique) && empty($items_id)) { | ||
157 | + $this->error('参数错误', ['status' => 2]); | ||
158 | + } | ||
159 | + $study = db('study')->where('unique', $unique)->field('id,grade,name,sno,team_id,earn_score')->find(); | ||
160 | + $item = db('item')->where('id', $items_id)->field('score,title,campus_id')->find(); | ||
161 | + $team = \db('team')->where('id', $study['team_id'])->field('title,score')->find(); | ||
162 | + $sum1 = $team['score'] + $item['score']; //合计战队总分 | ||
163 | + $sum2 = $study['earn_score'] + $item['score']; //合计个人总分 | ||
164 | + Db::startTrans(); | ||
165 | + try { | ||
166 | + db('study_score_log')->insert([ | ||
167 | + 'item_id' => $items_id, | ||
168 | + 'campus_id' => $item['campus_id'], | ||
169 | + 'study_id' => $study['id'], | ||
170 | + 'team_id' => $study['team_id'], | ||
171 | + 'score' => $item['score'], | ||
172 | + 'memo' => $study['name'] . '参加' . $item['title'] . '项目给' . $team['title'] . '加分', | ||
173 | + 'createtime' => time() | ||
174 | + ]); | ||
175 | + db('study') | ||
176 | + ->where('id', $study['id']) | ||
177 | + ->update([ | ||
178 | + 'earn_score' => $sum2, | ||
179 | + ]); | ||
180 | + \db('team') | ||
181 | + ->where('id', $study['team_id']) | ||
182 | + ->update([ | ||
183 | + 'score' => $sum1, | ||
184 | + 'updatetime' => time() | ||
185 | + ]); | ||
186 | + Db::commit(); | ||
187 | + } catch (Exception $e) { | ||
188 | + Db::rollback(); | ||
189 | + $this->error('连接错误', ['status' => 3]); | ||
190 | + } | ||
191 | + $data = db('study')->where('unique', $unique)->field('name,gender,sno')->find(); | ||
192 | + $this->success('扫码成功', [$data, 'status' => 1]); | ||
193 | + } | ||
194 | + | ||
195 | + /** | ||
196 | + * @ApiTitle (获取学生信息) | ||
197 | + * @ApiMethod (POST) | ||
198 | + * @ApiParams (name="campus_id", type="string", required=true, description="校区id") | ||
199 | + * @ApiReturn ({ | ||
200 | + "code":"状态码", | ||
201 | + "msg": "提示消息", | ||
202 | + "data": { | ||
203 | + "avatar": "学生头像", | ||
204 | + "name": "学生名称", | ||
205 | + "earn_score": "学生获得分数" | ||
206 | + "study_score": 学生积分构成{ | ||
207 | + "total": 2, | ||
208 | + "per_page": 3, | ||
209 | + "current_page": 1, | ||
210 | + "last_page": 1, | ||
211 | + "data": [ | ||
212 | + { | ||
213 | + "item_id": 项目id, | ||
214 | + "sum_score": "项目所获分数", | ||
215 | + "item_ronda": 项目对应雷达维度名称[ | ||
216 | + { | ||
217 | + "radar_id": 雷达维度id, | ||
218 | + "title": "雷达维度名称" | ||
219 | + } | ||
220 | + ] | ||
221 | + },} | ||
222 | + }) | ||
223 | + */ | ||
224 | + public function getScore() | ||
225 | + { | ||
226 | + $user = $this->auth->getUserinfo(); | ||
227 | + $campus_id = $this->request->param('campus_id'); | ||
228 | + $sid = \db('study')->where('user_id', $user['id'])->value('id'); | ||
229 | + //获取学生的信息 | ||
230 | + $data = \db('study')->where('id', $sid)->field('avatar,name,earn_score')->find(); | ||
231 | + $data['avatar'] = cdnurl( $data['avatar'], true); | ||
232 | + //获取雷达维度 | ||
233 | + $data['study_score'] = \db('study_score_log') | ||
234 | + ->distinct('item_id') | ||
235 | + ->field('item_id,SUM(score) as sum_score') | ||
236 | + ->group('item_id') | ||
237 | + ->where(['campus_id' => $campus_id, 'study_id' => $sid]) | ||
238 | + ->paginate(3, false) | ||
239 | + ->each(function ($item, $key) { | ||
240 | + $item['item_radar'] = \db('item i') | ||
241 | + ->join('radar r', 'i.radar_id = r.id') | ||
242 | + ->where('i.id', $item['item_id']) | ||
243 | + ->field('i.radar_id,r.title') | ||
244 | + ->select(); | ||
245 | + return $item; | ||
246 | + }); | ||
247 | + $this->success('获取学生信息成功', $data); | ||
248 | + } | ||
249 | + | ||
250 | } | 250 | } |
application/api/controller/Crontab.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace app\api\controller; | ||
4 | + | ||
5 | + | ||
6 | +use app\common\controller\Api; | ||
7 | + | ||
8 | +/** | ||
9 | + * 定时任务 | ||
10 | + * @ApiWeigh (94) | ||
11 | + */ | ||
12 | +class Crontab extends Api | ||
13 | +{ | ||
14 | + protected $noNeedLogin = ['*']; | ||
15 | + protected $noNeedRight = ['*']; | ||
16 | + | ||
17 | + | ||
18 | + /** | ||
19 | + * @ApiTitle (首页) | ||
20 | + */ | ||
21 | + public function index(){ | ||
22 | + $res = db('study')->field('earn_score')->select(); | ||
23 | + function sort($res){ | ||
24 | + $len = count($res); | ||
25 | + for ($i = 0; $i < $len - 1; $i++) {//循环比对的轮数 | ||
26 | + for ($j = 0; $j < $len - $i - 1; $j++) {//当前轮相邻元素循环对比 | ||
27 | + if ($res[$j] < $res[$j + 1]) {//如果前边的小于后边的 | ||
28 | + $tmp = $res[$j];//交换数据 | ||
29 | + $res[$j] = $res[$j + 1]; | ||
30 | + $res[$j + 1] = $tmp; | ||
31 | + } | ||
32 | + } | ||
33 | + } | ||
34 | + return $res; | ||
35 | + } | ||
36 | + $this->success('',sort($res)); | ||
37 | + } | ||
38 | +} |
1 | -<?php | ||
2 | - | ||
3 | -namespace app\api\controller; | ||
4 | - | ||
5 | -use app\common\controller\Api; | ||
6 | - | ||
7 | -/** | ||
8 | - * 数据大屏 | ||
9 | - * @ApiWeigh (95) | ||
10 | - */ | ||
11 | -class Screen extends Api | ||
12 | -{ | ||
13 | - protected $noNeedLogin = ['*']; | ||
14 | - protected $noNeedRight = ['*']; | ||
15 | - | ||
16 | - /** | ||
17 | - * @ApiTitle (大屏管理) | ||
18 | - * @ApiMethod (POST) | ||
19 | - * @ApiReturn ({"code":状态码, | ||
20 | - "msg":"提示信息" | ||
21 | - "time": "时间戳", | ||
22 | - "data": "大屏图片", | ||
23 | - "time": "当前时间", | ||
24 | - "campus": "活动名称", | ||
25 | - "team_rank": 战队排行[从高到底排], | ||
26 | - "study_rank": 个人排行[每个战队中从高到低排] | ||
27 | - } | ||
28 | - */ | ||
29 | - public function index(){ | ||
30 | - $time = time(); | ||
31 | - $list = []; | ||
32 | - $data = db('screen')->find(); | ||
33 | - $list['images'] = cdnurl($data['images'],true); | ||
34 | - if ($data['starttime']<=$time && $data['endtime']>=$time){ | ||
35 | - $day = intval(($data['endtime']-$time)/86400); | ||
36 | - $hour = intval((($data['endtime']-$time)%86400)/3600); | ||
37 | - $minute = intval(((($data['endtime']-$time)%86400)%3600)/60); | ||
38 | - $second = intval(((($data['endtime']-$time)%86400)%3600)%60); | ||
39 | - $list['count_down'] = "距离活动结束还有".$day."天".$hour."时".$minute."分".$second."秒"; | ||
40 | - }else if ($data['endtime']<=$time){ | ||
41 | - $list['count_down'] = "距离活动结束还有00天00时00分00秒"; | ||
42 | - } | ||
43 | - $list['screen_name'] = $data['title']; | ||
44 | - $list['campus_name'] = db('campus c') | ||
45 | - ->where('c.id',$data['campus_id']) | ||
46 | - ->value('title'); | ||
47 | - $list['time'] = date('Y-m-d H:i:s',time()); | ||
48 | - $list['team_rank'] = \db('study_score_log') | ||
49 | - ->field('SUM(score) as sum_score,team_id') | ||
50 | - ->where('campus_id',$data['campus_id']) | ||
51 | - ->group('team_id') | ||
52 | - ->order('sum_score DESC') | ||
53 | - ->limit(4) | ||
54 | - ->select(); | ||
55 | - $list['study_rank'] = db('study_score_log') | ||
56 | - ->field('study_id,SUM(score) as sum_score,team_id') | ||
57 | - ->where('campus_id',$data['campus_id']) | ||
58 | - ->order('sum_score DESC') | ||
59 | - ->group('study_id') | ||
60 | - ->limit('0,10') | ||
61 | - ->select(); | ||
62 | - $this->success('获取成功',$list); | ||
63 | - } | ||
64 | - | 1 | +<?php |
2 | + | ||
3 | +namespace app\api\controller; | ||
4 | + | ||
5 | +use app\common\controller\Api; | ||
6 | + | ||
7 | +/** | ||
8 | + * 数据大屏 | ||
9 | + * @ApiWeigh (95) | ||
10 | + */ | ||
11 | +class Screen extends Api | ||
12 | +{ | ||
13 | + protected $noNeedLogin = ['*']; | ||
14 | + protected $noNeedRight = ['*']; | ||
15 | + | ||
16 | + /** | ||
17 | + * @ApiTitle (大屏管理) | ||
18 | + * @ApiMethod (POST) | ||
19 | + * @ApiReturn ({"code":状态码, | ||
20 | + "msg":"提示信息" | ||
21 | + "time": "时间戳", | ||
22 | + "data": "大屏图片", | ||
23 | + "time": "当前时间", | ||
24 | + "campus": "活动名称", | ||
25 | + "team_rank": 战队排行[从高到底排], | ||
26 | + "study_rank": 个人排行[每个战队中从高到低排] | ||
27 | + } | ||
28 | + */ | ||
29 | + public function index(){ | ||
30 | + $time = time(); | ||
31 | + $list = []; | ||
32 | + $data = db('screen')->find(); | ||
33 | + $list['images'] = cdnurl($data['images'],true); | ||
34 | + if ($data['starttime']<=$time && $data['endtime']>=$time){ | ||
35 | + $day = intval(($data['endtime']-$time)/86400); | ||
36 | + $hour = intval((($data['endtime']-$time)%86400)/3600); | ||
37 | + $minute = intval(((($data['endtime']-$time)%86400)%3600)/60); | ||
38 | + $second = intval(((($data['endtime']-$time)%86400)%3600)%60); | ||
39 | + $list['count_down'] = "距离活动结束还有".$day."天".$hour."时".$minute."分".$second."秒"; | ||
40 | + }else if ($data['endtime']<=$time){ | ||
41 | + $list['count_down'] = "距离活动结束还有00天00时00分00秒"; | ||
42 | + } | ||
43 | + $list['screen_name'] = $data['title']; | ||
44 | + $list['campus_name'] = db('campus c') | ||
45 | + ->where('c.id',$data['campus_id']) | ||
46 | + ->value('title'); | ||
47 | + $list['time'] = date('Y-m-d H:i:s',time()); | ||
48 | + $list['team_rank'] = \db('study_score_log') | ||
49 | + ->field('SUM(score) as sum_score,team_id') | ||
50 | + ->where('campus_id',$data['campus_id']) | ||
51 | + ->group('team_id') | ||
52 | + ->order('sum_score DESC') | ||
53 | + ->limit(4) | ||
54 | + ->select(); | ||
55 | + $list['study_rank'] = db('study_score_log') | ||
56 | + ->field('study_id,SUM(score) as sum_score,team_id') | ||
57 | + ->where('campus_id',$data['campus_id']) | ||
58 | + ->order('sum_score DESC') | ||
59 | + ->group('study_id') | ||
60 | + ->limit('0,10') | ||
61 | + ->select(); | ||
62 | + $this->success('获取成功',$list); | ||
63 | + } | ||
64 | + | ||
65 | } | 65 | } |
1 | -<?php | ||
2 | - | ||
3 | -namespace app\common\controller; | ||
4 | - | ||
5 | -use tinymeng\code\Generate; | ||
6 | - | ||
7 | -class Resource | ||
8 | -{ | ||
9 | - public static function StudyBar($unique){ | ||
10 | - $generate = Generate::bar(); | ||
11 | - $file_path = $generate->create($unique,false,true); | ||
12 | - $file_path = substr($file_path,strripos($file_path,"public")+6); | ||
13 | - return $file_path; | ||
14 | - } | 1 | +<?php |
2 | + | ||
3 | +namespace app\common\controller; | ||
4 | + | ||
5 | +use tinymeng\code\Generate; | ||
6 | + | ||
7 | +class Resource | ||
8 | +{ | ||
9 | + public static function StudyBar($unique){ | ||
10 | + $generate = Generate::bar(); | ||
11 | + $file_path = $generate->create($unique,false,true); | ||
12 | + $file_path = substr($file_path,strripos($file_path,"public")+6); | ||
13 | + return $file_path; | ||
14 | + } | ||
15 | } | 15 | } |
@@ -41,5 +41,5 @@ return array ( | @@ -41,5 +41,5 @@ return array ( | ||
41 | 'category2' => 'Category2', | 41 | 'category2' => 'Category2', |
42 | 'custom' => 'Custom', | 42 | 'custom' => 'Custom', |
43 | ), | 43 | ), |
44 | - 'privacy_policy' => '<p><img src="http://campus.cn/uploads/20230307/e7ab2a28f4cb819fd6536ce7381583a9.png"/></p><p>用户:在手机、平板电脑、电脑等注册成为平台(以下简称“平台”或“平台方”)的使用者,通过平台发布、查看、接收图文/音频/视频信息或其他文件,或与其他用户进行延时/实时交流的用户(以下简称“用户”)。</p>', | 44 | + 'privacy_policy' => '<p><img src="http://rramxwmk1.hb-bkt.clouddn.com/uploads/20230310/e7ab2a28f4cb819fd6536ce7381583a9.png"/></p><p>用户:在手机、平板电脑、电脑等注册成为平台(以下简称“平台”或“平台方”)的使用者,通过平台发布、查看、接收图文/音频/视频信息或其他文件,或与其他用户进行延时/实时交流的用户(以下简称“用户”)。</p>', |
45 | ); | 45 | ); |
@@ -1871,15 +1871,15 @@ | @@ -1871,15 +1871,15 @@ | ||
1871 | <div class="tab-pane" id="sample0"> | 1871 | <div class="tab-pane" id="sample0"> |
1872 | <div class="row"> | 1872 | <div class="row"> |
1873 | <div class="col-md-12"> | 1873 | <div class="col-md-12"> |
1874 | - <pre id="sample_response0">{"code":状态码, | ||
1875 | - "msg":"提示信息" | ||
1876 | - "time": "时间戳", | ||
1877 | - "data": [ | ||
1878 | - "id": 1, | ||
1879 | - "title": "活动名称", | ||
1880 | - "images": "活动图片", | ||
1881 | - "depict": "描述", | ||
1882 | - ] | 1874 | + <pre id="sample_response0">{"code":状态码, |
1875 | + "msg":"提示信息" | ||
1876 | + "time": "时间戳", | ||
1877 | + "data": [ | ||
1878 | + "id": 1, | ||
1879 | + "title": "活动名称", | ||
1880 | + "images": "活动图片", | ||
1881 | + "depict": "描述", | ||
1882 | + ] | ||
1883 | }</pre> | 1883 | }</pre> |
1884 | </div> | 1884 | </div> |
1885 | </div> | 1885 | </div> |
@@ -2036,10 +2036,10 @@ | @@ -2036,10 +2036,10 @@ | ||
2036 | <div class="tab-pane" id="sample1"> | 2036 | <div class="tab-pane" id="sample1"> |
2037 | <div class="row"> | 2037 | <div class="row"> |
2038 | <div class="col-md-12"> | 2038 | <div class="col-md-12"> |
2039 | - <pre id="sample_response1">{ | ||
2040 | - "code":"状态码", | ||
2041 | - "msg": "提示消息", | ||
2042 | - "data": {} | 2039 | + <pre id="sample_response1">{ |
2040 | + "code":"状态码", | ||
2041 | + "msg": "提示消息", | ||
2042 | + "data": {} | ||
2043 | }</pre> | 2043 | }</pre> |
2044 | </div> | 2044 | </div> |
2045 | </div> | 2045 | </div> |
@@ -2196,17 +2196,17 @@ | @@ -2196,17 +2196,17 @@ | ||
2196 | <div class="tab-pane" id="sample2"> | 2196 | <div class="tab-pane" id="sample2"> |
2197 | <div class="row"> | 2197 | <div class="row"> |
2198 | <div class="col-md-12"> | 2198 | <div class="col-md-12"> |
2199 | - <pre id="sample_response2">{ | ||
2200 | - "code":"状态码", | ||
2201 | - "msg": "提示消息", | ||
2202 | - "data": { | ||
2203 | - "campus_title": "校区名称", | ||
2204 | - "ronda_title": "场次", | ||
2205 | - "ronda_holdtime": "场次时间", | ||
2206 | - "title": "项目名称", | ||
2207 | - "images": "项目图片", | ||
2208 | - "details": "项目详情" | ||
2209 | - } | 2199 | + <pre id="sample_response2">{ |
2200 | + "code":"状态码", | ||
2201 | + "msg": "提示消息", | ||
2202 | + "data": { | ||
2203 | + "campus_title": "校区名称", | ||
2204 | + "ronda_title": "场次", | ||
2205 | + "ronda_holdtime": "场次时间", | ||
2206 | + "title": "项目名称", | ||
2207 | + "images": "项目图片", | ||
2208 | + "details": "项目详情" | ||
2209 | + } | ||
2210 | }</pre> | 2210 | }</pre> |
2211 | </div> | 2211 | </div> |
2212 | </div> | 2212 | </div> |
@@ -2363,13 +2363,13 @@ | @@ -2363,13 +2363,13 @@ | ||
2363 | <div class="tab-pane" id="sample3"> | 2363 | <div class="tab-pane" id="sample3"> |
2364 | <div class="row"> | 2364 | <div class="row"> |
2365 | <div class="col-md-12"> | 2365 | <div class="col-md-12"> |
2366 | - <pre id="sample_response3">{ | ||
2367 | - "code":"状态码", | ||
2368 | - "msg": "提示消息", | ||
2369 | - "data": { | ||
2370 | - "campus_title": "校区名称", | ||
2371 | - "images": "项目图片", | ||
2372 | - "details": "项目详情" | 2366 | + <pre id="sample_response3">{ |
2367 | + "code":"状态码", | ||
2368 | + "msg": "提示消息", | ||
2369 | + "data": { | ||
2370 | + "campus_title": "校区名称", | ||
2371 | + "images": "项目图片", | ||
2372 | + "details": "项目详情" | ||
2373 | }</pre> | 2373 | }</pre> |
2374 | </div> | 2374 | </div> |
2375 | </div> | 2375 | </div> |
@@ -2503,10 +2503,10 @@ | @@ -2503,10 +2503,10 @@ | ||
2503 | <div class="tab-pane" id="sample4"> | 2503 | <div class="tab-pane" id="sample4"> |
2504 | <div class="row"> | 2504 | <div class="row"> |
2505 | <div class="col-md-12"> | 2505 | <div class="col-md-12"> |
2506 | - <pre id="sample_response4">{ | ||
2507 | - "code":"状态码", | ||
2508 | - "msg": "提示消息", | ||
2509 | - "data": {} | 2506 | + <pre id="sample_response4">{ |
2507 | + "code":"状态码", | ||
2508 | + "msg": "提示消息", | ||
2509 | + "data": {} | ||
2510 | }</pre> | 2510 | }</pre> |
2511 | </div> | 2511 | </div> |
2512 | </div> | 2512 | </div> |
@@ -2638,10 +2638,10 @@ | @@ -2638,10 +2638,10 @@ | ||
2638 | <div class="tab-pane" id="sample5"> | 2638 | <div class="tab-pane" id="sample5"> |
2639 | <div class="row"> | 2639 | <div class="row"> |
2640 | <div class="col-md-12"> | 2640 | <div class="col-md-12"> |
2641 | - <pre id="sample_response5">{ | ||
2642 | - "code":"状态码", | ||
2643 | - "msg": "提示消息", | ||
2644 | - "data": {} | 2641 | + <pre id="sample_response5">{ |
2642 | + "code":"状态码", | ||
2643 | + "msg": "提示消息", | ||
2644 | + "data": {} | ||
2645 | }</pre> | 2645 | }</pre> |
2646 | </div> | 2646 | </div> |
2647 | </div> | 2647 | </div> |
@@ -2755,19 +2755,19 @@ | @@ -2755,19 +2755,19 @@ | ||
2755 | <div class="tab-pane" id="sample6"> | 2755 | <div class="tab-pane" id="sample6"> |
2756 | <div class="row"> | 2756 | <div class="row"> |
2757 | <div class="col-md-12"> | 2757 | <div class="col-md-12"> |
2758 | - <pre id="sample_response6">{ | ||
2759 | - "code":"状态码", | ||
2760 | - "msg": "提示消息", | ||
2761 | - "data": { | ||
2762 | - "id": 项目id, | ||
2763 | - "title": "项目名称", | ||
2764 | - "radar_id": "维度id", | ||
2765 | - "user_id": "用户id", | ||
2766 | - "ronda_id": "场次id", | ||
2767 | - "score": "项目积分", | ||
2768 | - "createtime": "创建时间", | ||
2769 | - "updatetime": "更新时间" | ||
2770 | - } | 2758 | + <pre id="sample_response6">{ |
2759 | + "code":"状态码", | ||
2760 | + "msg": "提示消息", | ||
2761 | + "data": { | ||
2762 | + "id": 项目id, | ||
2763 | + "title": "项目名称", | ||
2764 | + "radar_id": "维度id", | ||
2765 | + "user_id": "用户id", | ||
2766 | + "ronda_id": "场次id", | ||
2767 | + "score": "项目积分", | ||
2768 | + "createtime": "创建时间", | ||
2769 | + "updatetime": "更新时间" | ||
2770 | + } | ||
2771 | }</pre> | 2771 | }</pre> |
2772 | </div> | 2772 | </div> |
2773 | </div> | 2773 | </div> |
@@ -2909,14 +2909,14 @@ | @@ -2909,14 +2909,14 @@ | ||
2909 | <div class="tab-pane" id="sample7"> | 2909 | <div class="tab-pane" id="sample7"> |
2910 | <div class="row"> | 2910 | <div class="row"> |
2911 | <div class="col-md-12"> | 2911 | <div class="col-md-12"> |
2912 | - <pre id="sample_response7">{ | ||
2913 | - "code":"状态码", | ||
2914 | - "msg": "提示消息", | ||
2915 | - "data": { | ||
2916 | - "name": "姓名", | ||
2917 | - "gender": "性别", | ||
2918 | - "sno": "学号" | ||
2919 | - } | 2912 | + <pre id="sample_response7">{ |
2913 | + "code":"状态码", | ||
2914 | + "msg": "提示消息", | ||
2915 | + "data": { | ||
2916 | + "name": "姓名", | ||
2917 | + "gender": "性别", | ||
2918 | + "sno": "学号" | ||
2919 | + } | ||
2920 | }</pre> | 2920 | }</pre> |
2921 | </div> | 2921 | </div> |
2922 | </div> | 2922 | </div> |
@@ -3048,29 +3048,29 @@ | @@ -3048,29 +3048,29 @@ | ||
3048 | <div class="tab-pane" id="sample8"> | 3048 | <div class="tab-pane" id="sample8"> |
3049 | <div class="row"> | 3049 | <div class="row"> |
3050 | <div class="col-md-12"> | 3050 | <div class="col-md-12"> |
3051 | - <pre id="sample_response8">{ | ||
3052 | - "code":"状态码", | ||
3053 | - "msg": "提示消息", | ||
3054 | - "data": { | ||
3055 | - "avatar": "学生头像", | ||
3056 | - "name": "学生名称", | ||
3057 | - "earn_score": "学生获得分数" | ||
3058 | - "study_score": 学生积分构成{ | ||
3059 | - "total": 2, | ||
3060 | - "per_page": 3, | ||
3061 | - "current_page": 1, | ||
3062 | - "last_page": 1, | ||
3063 | - "data": [ | ||
3064 | - { | ||
3065 | - "item_id": 项目id, | ||
3066 | - "sum_score": "项目所获分数", | ||
3067 | - "item_ronda": 项目对应雷达维度名称[ | ||
3068 | - { | ||
3069 | - "radar_id": 雷达维度id, | ||
3070 | - "title": "雷达维度名称" | ||
3071 | - } | ||
3072 | - ] | ||
3073 | - },} | 3051 | + <pre id="sample_response8">{ |
3052 | + "code":"状态码", | ||
3053 | + "msg": "提示消息", | ||
3054 | + "data": { | ||
3055 | + "avatar": "学生头像", | ||
3056 | + "name": "学生名称", | ||
3057 | + "earn_score": "学生获得分数" | ||
3058 | + "study_score": 学生积分构成{ | ||
3059 | + "total": 2, | ||
3060 | + "per_page": 3, | ||
3061 | + "current_page": 1, | ||
3062 | + "last_page": 1, | ||
3063 | + "data": [ | ||
3064 | + { | ||
3065 | + "item_id": 项目id, | ||
3066 | + "sum_score": "项目所获分数", | ||
3067 | + "item_ronda": 项目对应雷达维度名称[ | ||
3068 | + { | ||
3069 | + "radar_id": 雷达维度id, | ||
3070 | + "title": "雷达维度名称" | ||
3071 | + } | ||
3072 | + ] | ||
3073 | + },} | ||
3074 | }</pre> | 3074 | }</pre> |
3075 | </div> | 3075 | </div> |
3076 | </div> | 3076 | </div> |
@@ -194,67 +194,67 @@ if (Config.modulename === 'index' && Config.controllername === 'user' && ['login | @@ -194,67 +194,67 @@ if (Config.modulename === 'index' && Config.controllername === 'user' && ['login | ||
194 | $("#register-form,#login-form").append(Config.third.loginhtml || ''); | 194 | $("#register-form,#login-form").append(Config.third.loginhtml || ''); |
195 | } | 195 | } |
196 | 196 | ||
197 | -window.UEDITOR_HOME_URL = Config.__CDN__ + "/assets/addons/ueditor/"; | ||
198 | -require.config({ | ||
199 | - paths: { | ||
200 | - 'ueditor.config': '../addons/ueditor/ueditor.config', | ||
201 | - 'ueditor': '../addons/ueditor/ueditor.all.min', | ||
202 | - 'ueditor.zh': '../addons/ueditor/i18n/zh-cn/zh-cn', | ||
203 | - 'zeroclipboard': '../addons/ueditor/third-party/zeroclipboard/ZeroClipboard.min', | ||
204 | - }, | ||
205 | - shim: { | ||
206 | - 'ueditor': { | ||
207 | - deps: ['zeroclipboard', 'ueditor.config'], | ||
208 | - exports: 'UE', | ||
209 | - init: function (ZeroClipboard) { | ||
210 | - //导出到全局变量,供ueditor使用 | ||
211 | - window.ZeroClipboard = ZeroClipboard; | ||
212 | - }, | ||
213 | - }, | ||
214 | - 'ueditor.zh': ['ueditor'] | ||
215 | - } | ||
216 | -}); | ||
217 | -require(['form', 'upload'], function (Form, Upload) { | ||
218 | - var _bindevent = Form.events.bindevent; | ||
219 | - Form.events.bindevent = function (form) { | ||
220 | - _bindevent.apply(this, [form]); | ||
221 | - try { | ||
222 | - //绑定editor事件 | ||
223 | - require(['ueditor', 'ueditor.zh'], function (UE, undefined) { | ||
224 | - UE.list = []; | ||
225 | - window.UEDITOR_CONFIG['uploadService'] = function (context, editor) { | ||
226 | - return { | ||
227 | - Upload: () => { return Upload }, | ||
228 | - Fast: () => { return Fast }, | ||
229 | - } | ||
230 | - }; | ||
231 | - $(Config.ueditor.classname || '.editor', form).each(function () { | ||
232 | - var id = $(this).attr("id"); | ||
233 | - var name = $(this).attr("name"); | ||
234 | - $(this).removeClass('form-control'); | ||
235 | - UE.list[id] = UE.getEditor(id, { | ||
236 | - allowDivTransToP: false, //阻止div自动转p标签 | ||
237 | - initialFrameWidth: '100%', | ||
238 | - initialFrameHeight: 320, | ||
239 | - autoFloatEnabled: false, | ||
240 | - baiduMapAk: Config.ueditor.baiduMapAk || '', //百度地图api密钥(ak) | ||
241 | - // autoHeightEnabled: true, //自动高度 | ||
242 | - zIndex: 90, | ||
243 | - xssFilterRules: false, | ||
244 | - outputXssFilter: false, | ||
245 | - inputXssFilter: false, | ||
246 | - catchRemoteImageEnable: true, | ||
247 | - imageAllowFiles: '',//允许上传的图片格式,编辑器默认[".png", ".jpg", ".jpeg", ".gif", ".bmp"] | ||
248 | - }); | ||
249 | - UE.list[id].addListener("contentChange", function () { | ||
250 | - $('#' + id).val(this.getContent()); | ||
251 | - $('textarea[name="' + name + '"]').val(this.getContent()); | ||
252 | - }) | ||
253 | - }); | ||
254 | - }) | ||
255 | - } catch (e) { | ||
256 | - console.log('绑定editor事件', e) | ||
257 | - } | ||
258 | - } | 197 | +window.UEDITOR_HOME_URL = Config.__CDN__ + "/assets/addons/ueditor/"; |
198 | +require.config({ | ||
199 | + paths: { | ||
200 | + 'ueditor.config': '../addons/ueditor/ueditor.config', | ||
201 | + 'ueditor': '../addons/ueditor/ueditor.all.min', | ||
202 | + 'ueditor.zh': '../addons/ueditor/i18n/zh-cn/zh-cn', | ||
203 | + 'zeroclipboard': '../addons/ueditor/third-party/zeroclipboard/ZeroClipboard.min', | ||
204 | + }, | ||
205 | + shim: { | ||
206 | + 'ueditor': { | ||
207 | + deps: ['zeroclipboard', 'ueditor.config'], | ||
208 | + exports: 'UE', | ||
209 | + init: function (ZeroClipboard) { | ||
210 | + //导出到全局变量,供ueditor使用 | ||
211 | + window.ZeroClipboard = ZeroClipboard; | ||
212 | + }, | ||
213 | + }, | ||
214 | + 'ueditor.zh': ['ueditor'] | ||
215 | + } | ||
216 | +}); | ||
217 | +require(['form', 'upload'], function (Form, Upload) { | ||
218 | + var _bindevent = Form.events.bindevent; | ||
219 | + Form.events.bindevent = function (form) { | ||
220 | + _bindevent.apply(this, [form]); | ||
221 | + try { | ||
222 | + //绑定editor事件 | ||
223 | + require(['ueditor', 'ueditor.zh'], function (UE, undefined) { | ||
224 | + UE.list = []; | ||
225 | + window.UEDITOR_CONFIG['uploadService'] = function (context, editor) { | ||
226 | + return { | ||
227 | + Upload: () => { return Upload }, | ||
228 | + Fast: () => { return Fast }, | ||
229 | + } | ||
230 | + }; | ||
231 | + $(Config.ueditor.classname || '.editor', form).each(function () { | ||
232 | + var id = $(this).attr("id"); | ||
233 | + var name = $(this).attr("name"); | ||
234 | + $(this).removeClass('form-control'); | ||
235 | + UE.list[id] = UE.getEditor(id, { | ||
236 | + allowDivTransToP: false, //阻止div自动转p标签 | ||
237 | + initialFrameWidth: '100%', | ||
238 | + initialFrameHeight: 320, | ||
239 | + autoFloatEnabled: false, | ||
240 | + baiduMapAk: Config.ueditor.baiduMapAk || '', //百度地图api密钥(ak) | ||
241 | + // autoHeightEnabled: true, //自动高度 | ||
242 | + zIndex: 90, | ||
243 | + xssFilterRules: false, | ||
244 | + outputXssFilter: false, | ||
245 | + inputXssFilter: false, | ||
246 | + catchRemoteImageEnable: true, | ||
247 | + imageAllowFiles: '',//允许上传的图片格式,编辑器默认[".png", ".jpg", ".jpeg", ".gif", ".bmp"] | ||
248 | + }); | ||
249 | + UE.list[id].addListener("contentChange", function () { | ||
250 | + $('#' + id).val(this.getContent()); | ||
251 | + $('textarea[name="' + name + '"]').val(this.getContent()); | ||
252 | + }) | ||
253 | + }); | ||
254 | + }) | ||
255 | + } catch (e) { | ||
256 | + console.log('绑定editor事件', e) | ||
257 | + } | ||
258 | + } | ||
259 | }); | 259 | }); |
260 | }); | 260 | }); |
public/pAdEvmLZkR.php
0 → 100644
1 | +<?php | ||
2 | + | ||
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 | +// 使用此文件可以达到隐藏admin模块的效果 | ||
14 | +// 为了你的安全,强烈不建议将此文件名修改成admin.php | ||
15 | +// 定义应用目录 | ||
16 | +define('APP_PATH', __DIR__ . '/../application/'); | ||
17 | + | ||
18 | +// 判断是否安装 | ||
19 | +if (!is_file(APP_PATH . 'admin/command/Install/install.lock')) { | ||
20 | + header("location:./install.php"); | ||
21 | + exit; | ||
22 | +} | ||
23 | + | ||
24 | +// 加载框架引导文件 | ||
25 | +require __DIR__ . '/../thinkphp/base.php'; | ||
26 | + | ||
27 | +// 绑定到admin模块 | ||
28 | +\think\Route::bind('admin'); | ||
29 | + | ||
30 | +// 关闭路由 | ||
31 | +\think\App::route(false); | ||
32 | + | ||
33 | +// 设置根url | ||
34 | +\think\Url::root(''); | ||
35 | + | ||
36 | +// 执行应用 | ||
37 | +\think\App::run()->send(); |
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) | 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) |
1 | -如何贡献我的源代码 | ||
2 | -=== | ||
3 | - | ||
4 | -此文档介绍了 ThinkPHP 团队的组成以及运转机制,您提交的代码将给 ThinkPHP 项目带来什么好处,以及如何才能加入我们的行列。 | ||
5 | - | ||
6 | -## 通过 Github 贡献代码 | ||
7 | - | ||
8 | -ThinkPHP 目前使用 Git 来控制程序版本,如果你想为 ThinkPHP 贡献源代码,请先大致了解 Git 的使用方法。我们目前把项目托管在 GitHub 上,任何 GitHub 用户都可以向我们贡献代码。 | ||
9 | - | ||
10 | -参与的方式很简单,`fork`一份 ThinkPHP 的代码到你的仓库中,修改后提交,并向我们发起`pull request`申请,我们会及时对代码进行审查并处理你的申请。审查通过后,你的代码将被`merge`进我们的仓库中,这样你就会自动出现在贡献者名单里了,非常方便。 | ||
11 | - | ||
12 | -我们希望你贡献的代码符合: | ||
13 | - | ||
14 | -* ThinkPHP 的编码规范 | ||
15 | -* 适当的注释,能让其他人读懂 | ||
16 | -* 遵循 Apache2 开源协议 | ||
17 | - | ||
18 | -**如果想要了解更多细节或有任何疑问,请继续阅读下面的内容** | ||
19 | - | ||
20 | -### 注意事项 | ||
21 | - | ||
22 | -* 本项目代码格式化标准选用 [**PSR-2**](http://www.kancloud.cn/thinkphp/php-fig-psr/3141); | ||
23 | -* 类名和类文件名遵循 [**PSR-4**](http://www.kancloud.cn/thinkphp/php-fig-psr/3144); | ||
24 | -* 对于 Issues 的处理,请使用诸如 `fix #xxx(Issue ID)` 的 commit title 直接关闭 issue。 | ||
25 | -* 系统会自动在 PHP 5.4 5.5 5.6 7.0 和 HHVM 上测试修改,其中 HHVM 下的测试容许报错,请确保你的修改符合 PHP 5.4 ~ 5.6 和 PHP 7.0 的语法规范; | ||
26 | -* 管理员不会合并造成 CI faild 的修改,若出现 CI faild 请检查自己的源代码或修改相应的[单元测试文件](tests); | ||
27 | - | ||
28 | -## GitHub Issue | ||
29 | - | ||
30 | -GitHub 提供了 Issue 功能,该功能可以用于: | ||
31 | - | ||
32 | -* 提出 bug | ||
33 | -* 提出功能改进 | ||
34 | -* 反馈使用体验 | ||
35 | - | ||
36 | -该功能不应该用于: | ||
37 | - | ||
38 | - * 提出修改意见(涉及代码署名和修订追溯问题) | ||
39 | - * 不友善的言论 | ||
40 | - | ||
41 | -## 快速修改 | ||
42 | - | ||
43 | -**GitHub 提供了快速编辑文件的功能** | ||
44 | - | ||
45 | -1. 登录 GitHub 帐号; | ||
46 | -2. 浏览项目文件,找到要进行修改的文件; | ||
47 | -3. 点击右上角铅笔图标进行修改; | ||
48 | -4. 填写 `Commit changes` 相关内容(Title 必填); | ||
49 | -5. 提交修改,等待 CI 验证和管理员合并。 | ||
50 | - | ||
51 | -**若您需要一次提交大量修改,请继续阅读下面的内容** | ||
52 | - | ||
53 | -## 完整流程 | ||
54 | - | ||
55 | -1. `fork`本项目; | ||
56 | -2. 克隆(`clone`)你 `fork` 的项目到本地; | ||
57 | -3. 新建分支(`branch`)并检出(`checkout`)新分支; | ||
58 | -4. 添加本项目到你的本地 git 仓库作为上游(`upstream`); | ||
59 | -5. 进行修改,若你的修改包含方法或函数的增减,请记得修改[单元测试文件](tests); | ||
60 | -6. 变基(衍合 `rebase`)你的分支到上游 master 分支; | ||
61 | -7. `push` 你的本地仓库到 GitHub; | ||
62 | -8. 提交 `pull request`; | ||
63 | -9. 等待 CI 验证(若不通过则重复 5~7,不需要重新提交 `pull request`,GitHub 会自动更新你的 `pull request`); | ||
64 | -10. 等待管理员处理,并及时 `rebase` 你的分支到上游 master 分支(若上游 master 分支有修改)。 | ||
65 | - | ||
66 | -*若有必要,可以 `git push -f` 强行推送 rebase 后的分支到自己的 `fork`* | ||
67 | - | ||
68 | -*绝对不可以使用 `git push -f` 强行推送修改到上游* | ||
69 | - | ||
70 | -### 注意事项 | ||
71 | - | ||
72 | -* 若对上述流程有任何不清楚的地方,请查阅 GIT 教程,如 [这个](http://backlogtool.com/git-guide/cn/); | ||
73 | -* 对于代码**不同方面**的修改,请在自己 `fork` 的项目中**创建不同的分支**(原因参见`完整流程`第9条备注部分); | ||
74 | -* 变基及交互式变基操作参见 [Git 交互式变基](http://pakchoi.me/2015/03/17/git-interactive-rebase/) | ||
75 | - | ||
76 | -## 推荐资源 | ||
77 | - | ||
78 | -### 开发环境 | ||
79 | - | ||
80 | -* XAMPP for Windows 5.5.x | ||
81 | -* WampServer (for Windows) | ||
82 | -* upupw Apache PHP5.4 ( for Windows) | ||
83 | - | ||
84 | -或自行安装 | ||
85 | - | ||
86 | -- Apache / Nginx | ||
87 | -- PHP 5.4 ~ 5.6 | ||
88 | -- MySQL / MariaDB | ||
89 | - | ||
90 | -*Windows 用户推荐添加 PHP bin 目录到 PATH,方便使用 composer* | ||
91 | - | ||
92 | -*Linux 用户自行配置环境, Mac 用户推荐使用内置 Apache 配合 Homebrew 安装 PHP 和 MariaDB* | ||
93 | - | ||
94 | -### 编辑器 | ||
95 | - | ||
96 | -Sublime Text 3 + phpfmt 插件 | ||
97 | - | ||
98 | -phpfmt 插件参数 | ||
99 | - | ||
100 | -```json | ||
101 | -{ | ||
102 | - "autocomplete": true, | ||
103 | - "enable_auto_align": true, | ||
104 | - "format_on_save": true, | ||
105 | - "indent_with_space": true, | ||
106 | - "psr1_naming": false, | ||
107 | - "psr2": true, | ||
108 | - "version": 4 | ||
109 | -} | ||
110 | -``` | ||
111 | - | ||
112 | -或其他 编辑器 / IDE 配合 PSR2 自动格式化工具 | ||
113 | - | ||
114 | -### Git GUI | ||
115 | - | ||
116 | -* SourceTree | ||
117 | -* GitHub Desktop | ||
118 | - | ||
119 | -或其他 Git 图形界面客户端 | 1 | +如何贡献我的源代码 |
2 | +=== | ||
3 | + | ||
4 | +此文档介绍了 ThinkPHP 团队的组成以及运转机制,您提交的代码将给 ThinkPHP 项目带来什么好处,以及如何才能加入我们的行列。 | ||
5 | + | ||
6 | +## 通过 Github 贡献代码 | ||
7 | + | ||
8 | +ThinkPHP 目前使用 Git 来控制程序版本,如果你想为 ThinkPHP 贡献源代码,请先大致了解 Git 的使用方法。我们目前把项目托管在 GitHub 上,任何 GitHub 用户都可以向我们贡献代码。 | ||
9 | + | ||
10 | +参与的方式很简单,`fork`一份 ThinkPHP 的代码到你的仓库中,修改后提交,并向我们发起`pull request`申请,我们会及时对代码进行审查并处理你的申请。审查通过后,你的代码将被`merge`进我们的仓库中,这样你就会自动出现在贡献者名单里了,非常方便。 | ||
11 | + | ||
12 | +我们希望你贡献的代码符合: | ||
13 | + | ||
14 | +* ThinkPHP 的编码规范 | ||
15 | +* 适当的注释,能让其他人读懂 | ||
16 | +* 遵循 Apache2 开源协议 | ||
17 | + | ||
18 | +**如果想要了解更多细节或有任何疑问,请继续阅读下面的内容** | ||
19 | + | ||
20 | +### 注意事项 | ||
21 | + | ||
22 | +* 本项目代码格式化标准选用 [**PSR-2**](http://www.kancloud.cn/thinkphp/php-fig-psr/3141); | ||
23 | +* 类名和类文件名遵循 [**PSR-4**](http://www.kancloud.cn/thinkphp/php-fig-psr/3144); | ||
24 | +* 对于 Issues 的处理,请使用诸如 `fix #xxx(Issue ID)` 的 commit title 直接关闭 issue。 | ||
25 | +* 系统会自动在 PHP 5.4 5.5 5.6 7.0 和 HHVM 上测试修改,其中 HHVM 下的测试容许报错,请确保你的修改符合 PHP 5.4 ~ 5.6 和 PHP 7.0 的语法规范; | ||
26 | +* 管理员不会合并造成 CI faild 的修改,若出现 CI faild 请检查自己的源代码或修改相应的[单元测试文件](tests); | ||
27 | + | ||
28 | +## GitHub Issue | ||
29 | + | ||
30 | +GitHub 提供了 Issue 功能,该功能可以用于: | ||
31 | + | ||
32 | +* 提出 bug | ||
33 | +* 提出功能改进 | ||
34 | +* 反馈使用体验 | ||
35 | + | ||
36 | +该功能不应该用于: | ||
37 | + | ||
38 | + * 提出修改意见(涉及代码署名和修订追溯问题) | ||
39 | + * 不友善的言论 | ||
40 | + | ||
41 | +## 快速修改 | ||
42 | + | ||
43 | +**GitHub 提供了快速编辑文件的功能** | ||
44 | + | ||
45 | +1. 登录 GitHub 帐号; | ||
46 | +2. 浏览项目文件,找到要进行修改的文件; | ||
47 | +3. 点击右上角铅笔图标进行修改; | ||
48 | +4. 填写 `Commit changes` 相关内容(Title 必填); | ||
49 | +5. 提交修改,等待 CI 验证和管理员合并。 | ||
50 | + | ||
51 | +**若您需要一次提交大量修改,请继续阅读下面的内容** | ||
52 | + | ||
53 | +## 完整流程 | ||
54 | + | ||
55 | +1. `fork`本项目; | ||
56 | +2. 克隆(`clone`)你 `fork` 的项目到本地; | ||
57 | +3. 新建分支(`branch`)并检出(`checkout`)新分支; | ||
58 | +4. 添加本项目到你的本地 git 仓库作为上游(`upstream`); | ||
59 | +5. 进行修改,若你的修改包含方法或函数的增减,请记得修改[单元测试文件](tests); | ||
60 | +6. 变基(衍合 `rebase`)你的分支到上游 master 分支; | ||
61 | +7. `push` 你的本地仓库到 GitHub; | ||
62 | +8. 提交 `pull request`; | ||
63 | +9. 等待 CI 验证(若不通过则重复 5~7,不需要重新提交 `pull request`,GitHub 会自动更新你的 `pull request`); | ||
64 | +10. 等待管理员处理,并及时 `rebase` 你的分支到上游 master 分支(若上游 master 分支有修改)。 | ||
65 | + | ||
66 | +*若有必要,可以 `git push -f` 强行推送 rebase 后的分支到自己的 `fork`* | ||
67 | + | ||
68 | +*绝对不可以使用 `git push -f` 强行推送修改到上游* | ||
69 | + | ||
70 | +### 注意事项 | ||
71 | + | ||
72 | +* 若对上述流程有任何不清楚的地方,请查阅 GIT 教程,如 [这个](http://backlogtool.com/git-guide/cn/); | ||
73 | +* 对于代码**不同方面**的修改,请在自己 `fork` 的项目中**创建不同的分支**(原因参见`完整流程`第9条备注部分); | ||
74 | +* 变基及交互式变基操作参见 [Git 交互式变基](http://pakchoi.me/2015/03/17/git-interactive-rebase/) | ||
75 | + | ||
76 | +## 推荐资源 | ||
77 | + | ||
78 | +### 开发环境 | ||
79 | + | ||
80 | +* XAMPP for Windows 5.5.x | ||
81 | +* WampServer (for Windows) | ||
82 | +* upupw Apache PHP5.4 ( for Windows) | ||
83 | + | ||
84 | +或自行安装 | ||
85 | + | ||
86 | +- Apache / Nginx | ||
87 | +- PHP 5.4 ~ 5.6 | ||
88 | +- MySQL / MariaDB | ||
89 | + | ||
90 | +*Windows 用户推荐添加 PHP bin 目录到 PATH,方便使用 composer* | ||
91 | + | ||
92 | +*Linux 用户自行配置环境, Mac 用户推荐使用内置 Apache 配合 Homebrew 安装 PHP 和 MariaDB* | ||
93 | + | ||
94 | +### 编辑器 | ||
95 | + | ||
96 | +Sublime Text 3 + phpfmt 插件 | ||
97 | + | ||
98 | +phpfmt 插件参数 | ||
99 | + | ||
100 | +```json | ||
101 | +{ | ||
102 | + "autocomplete": true, | ||
103 | + "enable_auto_align": true, | ||
104 | + "format_on_save": true, | ||
105 | + "indent_with_space": true, | ||
106 | + "psr1_naming": false, | ||
107 | + "psr2": true, | ||
108 | + "version": 4 | ||
109 | +} | ||
110 | +``` | ||
111 | + | ||
112 | +或其他 编辑器 / IDE 配合 PSR2 自动格式化工具 | ||
113 | + | ||
114 | +### Git GUI | ||
115 | + | ||
116 | +* SourceTree | ||
117 | +* GitHub Desktop | ||
118 | + | ||
119 | +或其他 Git 图形界面客户端 |
1 | - | ||
2 | -ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 | ||
3 | -版权所有Copyright © 2006-2017 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 | + |
2 | +ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 | ||
3 | +版权所有Copyright © 2006-2017 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(FastAdmin 团队长期维护) | ||
2 | - | ||
3 | -## 维护原因 | ||
4 | - | ||
5 | -FastAdmin 致力于服务开发者,为开发者节省时间,为了 FastAdmin 开源项目持续发展下去。 | ||
6 | - | ||
7 | -## 参与开源 | ||
8 | - | ||
9 | -[贡献代码](https://doc.fastadmin.net/doc/contributing.html) | ||
10 | - | ||
11 | - | ||
12 | -## 使用方法 | ||
13 | - | ||
14 | -- 本框架已经应用在 FastAdmin 后台框架中,在 FastAdmin 项目中使用 `composer update topthink/framework -vvv` 命令即可更新。 | ||
15 | - | ||
16 | -- 非 FastAdmin 的 ThinkPHP5.0 项目使用此仓库,请修改 `composer.json` 添加以下配置,在执行`composer update topthink/framework -vvv` 命令,具体可以参考 FastAdmin 项目目录下的 `composer.json` 文件内容。 | ||
17 | - ``` | ||
18 | - "repositories": [ | ||
19 | - { | ||
20 | - "type": "git", | ||
21 | - "url": "https://gitee.com/fastadminnet/framework.git" | ||
22 | - } | ||
23 | - ] | ||
24 | - ``` | ||
25 | - | ||
26 | -## 环境要求 | ||
27 | - | ||
28 | -php 7.1+ | ||
29 | - | ||
30 | - | ||
31 | - | ||
32 | -## ThinkPHP 介绍 | ||
33 | - | ||
34 | -ThinkPHP5 在保持快速开发和大道至简的核心理念不变的同时,优化核心,减少依赖,基于全新的架构思想和命名空间实现,是 ThinkPHP 突破原有框架思路的颠覆之作,其主要特性包括: | ||
35 | - | ||
36 | - + 基于命名空间和众多PHP新特性 | ||
37 | - + 核心功能组件化 | ||
38 | - + 强化路由功能 | ||
39 | - + 更灵活的控制器 | ||
40 | - + 重构的模型和数据库类 | ||
41 | - + 配置文件可分离 | ||
42 | - + 重写的自动验证和完成 | ||
43 | - + 简化扩展机制 | ||
44 | - + API支持完善 | ||
45 | - + 改进的Log类 | ||
46 | - + 命令行访问支持 | ||
47 | - + REST支持 | ||
48 | - + 引导文件支持 | ||
49 | - + 方便的自动生成定义 | ||
50 | - + 真正惰性加载 | ||
51 | - + 分布式环境支持 | ||
52 | - + 支持Composer | ||
53 | - + 支持MongoDb | ||
54 | - | ||
55 | -详细开发文档参考 [ThinkPHP5完全开发手册](http://www.kancloud.cn/manual/thinkphp5) 以及[ThinkPHP5入门系列教程](http://www.kancloud.cn/special/thinkphp5_quickstart) | ||
56 | - | ||
57 | -## 版权信息 | ||
58 | - | ||
59 | -ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 | ||
60 | - | ||
61 | -本项目包含的第三方源码和二进制文件之版权信息另行标注。 | ||
62 | - | ||
63 | -版权所有Copyright © 2006-2022 by ThinkPHP (http://thinkphp.cn) | ||
64 | - | ||
65 | -All rights reserved。 | ||
66 | - | ||
67 | -ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 | ||
68 | - | ||
69 | -更多细节参阅 [LICENSE.txt](LICENSE.txt) | 1 | +# ThinkPHP 5.0(FastAdmin 团队长期维护) |
2 | + | ||
3 | +## 维护原因 | ||
4 | + | ||
5 | +FastAdmin 致力于服务开发者,为开发者节省时间,为了 FastAdmin 开源项目持续发展下去。 | ||
6 | + | ||
7 | +## 参与开源 | ||
8 | + | ||
9 | +[贡献代码](https://doc.fastadmin.net/doc/contributing.html) | ||
10 | + | ||
11 | + | ||
12 | +## 使用方法 | ||
13 | + | ||
14 | +- 本框架已经应用在 FastAdmin 后台框架中,在 FastAdmin 项目中使用 `composer update topthink/framework -vvv` 命令即可更新。 | ||
15 | + | ||
16 | +- 非 FastAdmin 的 ThinkPHP5.0 项目使用此仓库,请修改 `composer.json` 添加以下配置,在执行`composer update topthink/framework -vvv` 命令,具体可以参考 FastAdmin 项目目录下的 `composer.json` 文件内容。 | ||
17 | + ``` | ||
18 | + "repositories": [ | ||
19 | + { | ||
20 | + "type": "git", | ||
21 | + "url": "https://gitee.com/fastadminnet/framework.git" | ||
22 | + } | ||
23 | + ] | ||
24 | + ``` | ||
25 | + | ||
26 | +## 环境要求 | ||
27 | + | ||
28 | +php 7.1+ | ||
29 | + | ||
30 | + | ||
31 | + | ||
32 | +## ThinkPHP 介绍 | ||
33 | + | ||
34 | +ThinkPHP5 在保持快速开发和大道至简的核心理念不变的同时,优化核心,减少依赖,基于全新的架构思想和命名空间实现,是 ThinkPHP 突破原有框架思路的颠覆之作,其主要特性包括: | ||
35 | + | ||
36 | + + 基于命名空间和众多PHP新特性 | ||
37 | + + 核心功能组件化 | ||
38 | + + 强化路由功能 | ||
39 | + + 更灵活的控制器 | ||
40 | + + 重构的模型和数据库类 | ||
41 | + + 配置文件可分离 | ||
42 | + + 重写的自动验证和完成 | ||
43 | + + 简化扩展机制 | ||
44 | + + API支持完善 | ||
45 | + + 改进的Log类 | ||
46 | + + 命令行访问支持 | ||
47 | + + REST支持 | ||
48 | + + 引导文件支持 | ||
49 | + + 方便的自动生成定义 | ||
50 | + + 真正惰性加载 | ||
51 | + + 分布式环境支持 | ||
52 | + + 支持Composer | ||
53 | + + 支持MongoDb | ||
54 | + | ||
55 | +详细开发文档参考 [ThinkPHP5完全开发手册](http://www.kancloud.cn/manual/thinkphp5) 以及[ThinkPHP5入门系列教程](http://www.kancloud.cn/special/thinkphp5_quickstart) | ||
56 | + | ||
57 | +## 版权信息 | ||
58 | + | ||
59 | +ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 | ||
60 | + | ||
61 | +本项目包含的第三方源码和二进制文件之版权信息另行标注。 | ||
62 | + | ||
63 | +版权所有Copyright © 2006-2022 by ThinkPHP (http://thinkphp.cn) | ||
64 | + | ||
65 | +All rights reserved。 | ||
66 | + | ||
67 | +ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 | ||
68 | + | ||
69 | +更多细节参阅 [LICENSE.txt](LICENSE.txt) |
1 | -<?php | ||
2 | -// +---------------------------------------------------------------------- | ||
3 | -// | ThinkPHP [ WE CAN DO IT JUST THINK ] | ||
4 | -// +---------------------------------------------------------------------- | ||
5 | -// | Copyright (c) 2006~2018 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 | -define('THINK_VERSION', '5.0.24'); | ||
13 | -define('THINK_START_TIME', microtime(true)); | ||
14 | -define('THINK_START_MEM', memory_get_usage()); | ||
15 | -define('EXT', '.php'); | ||
16 | -define('DS', DIRECTORY_SEPARATOR); | ||
17 | -defined('THINK_PATH') or define('THINK_PATH', __DIR__ . DS); | ||
18 | -define('LIB_PATH', THINK_PATH . 'library' . DS); | ||
19 | -define('CORE_PATH', LIB_PATH . 'think' . DS); | ||
20 | -define('TRAIT_PATH', LIB_PATH . 'traits' . DS); | ||
21 | -defined('APP_PATH') or define('APP_PATH', dirname($_SERVER['SCRIPT_FILENAME']) . DS); | ||
22 | -defined('ROOT_PATH') or define('ROOT_PATH', dirname(realpath(APP_PATH)) . DS); | ||
23 | -defined('EXTEND_PATH') or define('EXTEND_PATH', ROOT_PATH . 'extend' . DS); | ||
24 | -defined('VENDOR_PATH') or define('VENDOR_PATH', ROOT_PATH . 'vendor' . DS); | ||
25 | -defined('RUNTIME_PATH') or define('RUNTIME_PATH', ROOT_PATH . 'runtime' . DS); | ||
26 | -defined('LOG_PATH') or define('LOG_PATH', RUNTIME_PATH . 'log' . DS); | ||
27 | -defined('CACHE_PATH') or define('CACHE_PATH', RUNTIME_PATH . 'cache' . DS); | ||
28 | -defined('TEMP_PATH') or define('TEMP_PATH', RUNTIME_PATH . 'temp' . DS); | ||
29 | -defined('CONF_PATH') or define('CONF_PATH', APP_PATH); // 配置文件目录 | ||
30 | -defined('CONF_EXT') or define('CONF_EXT', EXT); // 配置文件后缀 | ||
31 | -defined('ENV_PREFIX') or define('ENV_PREFIX', 'PHP_'); // 环境变量的配置前缀 | ||
32 | - | ||
33 | -// 环境常量 | ||
34 | -define('IS_CLI', PHP_SAPI == 'cli' ? true : false); | ||
35 | -define('IS_WIN', strpos(PHP_OS, 'WIN') !== false); | ||
36 | - | ||
37 | -// 载入Loader类 | ||
38 | -require CORE_PATH . 'Loader.php'; | ||
39 | - | ||
40 | -// 加载环境变量配置文件 | ||
41 | -if (is_file(ROOT_PATH . '.env')) { | ||
42 | - $env = parse_ini_file(ROOT_PATH . '.env', true); | ||
43 | - | ||
44 | - foreach ($env as $key => $val) { | ||
45 | - $name = ENV_PREFIX . strtoupper($key); | ||
46 | - | ||
47 | - if (is_array($val)) { | ||
48 | - foreach ($val as $k => $v) { | ||
49 | - $item = $name . '_' . strtoupper($k); | ||
50 | - putenv("$item=$v"); | ||
51 | - } | ||
52 | - } else { | ||
53 | - putenv("$name=$val"); | ||
54 | - } | ||
55 | - } | ||
56 | -} | ||
57 | - | ||
58 | -// 注册自动加载 | ||
59 | -\think\Loader::register(); | ||
60 | - | ||
61 | -// 注册错误和异常处理机制 | ||
62 | -\think\Error::register(); | ||
63 | - | ||
64 | -// 加载惯例配置文件 | ||
65 | -\think\Config::set(include THINK_PATH . 'convention' . EXT); | 1 | +<?php |
2 | +// +---------------------------------------------------------------------- | ||
3 | +// | ThinkPHP [ WE CAN DO IT JUST THINK ] | ||
4 | +// +---------------------------------------------------------------------- | ||
5 | +// | Copyright (c) 2006~2018 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 | +define('THINK_VERSION', '5.0.25'); | ||
13 | +define('THINK_START_TIME', microtime(true)); | ||
14 | +define('THINK_START_MEM', memory_get_usage()); | ||
15 | +define('EXT', '.php'); | ||
16 | +define('DS', DIRECTORY_SEPARATOR); | ||
17 | +defined('THINK_PATH') or define('THINK_PATH', __DIR__ . DS); | ||
18 | +define('LIB_PATH', THINK_PATH . 'library' . DS); | ||
19 | +define('CORE_PATH', LIB_PATH . 'think' . DS); | ||
20 | +define('TRAIT_PATH', LIB_PATH . 'traits' . DS); | ||
21 | +defined('APP_PATH') or define('APP_PATH', dirname($_SERVER['SCRIPT_FILENAME']) . DS); | ||
22 | +defined('ROOT_PATH') or define('ROOT_PATH', dirname(realpath(APP_PATH)) . DS); | ||
23 | +defined('EXTEND_PATH') or define('EXTEND_PATH', ROOT_PATH . 'extend' . DS); | ||
24 | +defined('VENDOR_PATH') or define('VENDOR_PATH', ROOT_PATH . 'vendor' . DS); | ||
25 | +defined('RUNTIME_PATH') or define('RUNTIME_PATH', ROOT_PATH . 'runtime' . DS); | ||
26 | +defined('LOG_PATH') or define('LOG_PATH', RUNTIME_PATH . 'log' . DS); | ||
27 | +defined('CACHE_PATH') or define('CACHE_PATH', RUNTIME_PATH . 'cache' . DS); | ||
28 | +defined('TEMP_PATH') or define('TEMP_PATH', RUNTIME_PATH . 'temp' . DS); | ||
29 | +defined('CONF_PATH') or define('CONF_PATH', APP_PATH); // 配置文件目录 | ||
30 | +defined('CONF_EXT') or define('CONF_EXT', EXT); // 配置文件后缀 | ||
31 | +defined('ENV_PREFIX') or define('ENV_PREFIX', 'PHP_'); // 环境变量的配置前缀 | ||
32 | + | ||
33 | +// 环境常量 | ||
34 | +define('IS_CLI', PHP_SAPI == 'cli' ? true : false); | ||
35 | +define('IS_WIN', strpos(PHP_OS, 'WIN') !== false); | ||
36 | + | ||
37 | +// 载入Loader类 | ||
38 | +require CORE_PATH . 'Loader.php'; | ||
39 | + | ||
40 | +// 加载环境变量配置文件 | ||
41 | +if (is_file(ROOT_PATH . '.env')) { | ||
42 | + $env = parse_ini_file(ROOT_PATH . '.env', true); | ||
43 | + | ||
44 | + foreach ($env as $key => $val) { | ||
45 | + $name = ENV_PREFIX . strtoupper($key); | ||
46 | + | ||
47 | + if (is_array($val)) { | ||
48 | + foreach ($val as $k => $v) { | ||
49 | + $item = $name . '_' . strtoupper($k); | ||
50 | + putenv("$item=$v"); | ||
51 | + } | ||
52 | + } else { | ||
53 | + putenv("$name=$val"); | ||
54 | + } | ||
55 | + } | ||
56 | +} | ||
57 | + | ||
58 | +// 注册自动加载 | ||
59 | +\think\Loader::register(); | ||
60 | + | ||
61 | +// 注册错误和异常处理机制 | ||
62 | +\think\Error::register(); | ||
63 | + | ||
64 | +// 加载惯例配置文件 | ||
65 | +\think\Config::set(include THINK_PATH . 'convention' . EXT); |
1 | -comment: | ||
2 | - layout: header, changes, diff | ||
3 | -coverage: | ||
4 | - ignore: | ||
5 | - - base.php | ||
6 | - - helper.php | ||
7 | - - convention.php | ||
8 | - - lang/zh-cn.php | ||
9 | - - start.php | ||
10 | - - console.php | ||
11 | - status: | ||
12 | - patch: false | 1 | +comment: |
2 | + layout: header, changes, diff | ||
3 | +coverage: | ||
4 | + ignore: | ||
5 | + - base.php | ||
6 | + - helper.php | ||
7 | + - convention.php | ||
8 | + - lang/zh-cn.php | ||
9 | + - start.php | ||
10 | + - console.php | ||
11 | + status: | ||
12 | + patch: false |
1 | -{ | ||
2 | - "name": "topthink/framework", | ||
3 | - "description": "the new thinkphp framework", | ||
4 | - "type": "think-framework", | ||
5 | - "keywords": [ | ||
6 | - "framework", | ||
7 | - "thinkphp", | ||
8 | - "ORM" | ||
9 | - ], | ||
10 | - "homepage": "http://thinkphp.cn/", | ||
11 | - "license": "Apache-2.0", | ||
12 | - "authors": [ | ||
13 | - { | ||
14 | - "name": "liu21st", | ||
15 | - "email": "liu21st@gmail.com" | ||
16 | - } | ||
17 | - ], | ||
18 | - "require": { | ||
19 | - "php": ">=7.1.0", | ||
20 | - "topthink/think-installer": "~1.0" | ||
21 | - }, | ||
22 | - "require-dev": { | ||
23 | - "phpunit/phpunit": "4.8.*", | ||
24 | - "johnkary/phpunit-speedtrap": "^1.0", | ||
25 | - "mikey179/vfsstream": "~1.6", | ||
26 | - "phploc/phploc": "2.*", | ||
27 | - "sebastian/phpcpd": "2.*", | ||
28 | - "phpdocumentor/reflection-docblock": "^2.0" | ||
29 | - }, | ||
30 | - "autoload": { | ||
31 | - "psr-4": { | ||
32 | - "think\\": "library/think" | ||
33 | - } | ||
34 | - } | ||
35 | -} | 1 | +{ |
2 | + "name": "topthink/framework", | ||
3 | + "description": "the new thinkphp framework", | ||
4 | + "type": "think-framework", | ||
5 | + "keywords": [ | ||
6 | + "framework", | ||
7 | + "thinkphp", | ||
8 | + "ORM" | ||
9 | + ], | ||
10 | + "homepage": "http://thinkphp.cn/", | ||
11 | + "license": "Apache-2.0", | ||
12 | + "authors": [ | ||
13 | + { | ||
14 | + "name": "liu21st", | ||
15 | + "email": "liu21st@gmail.com" | ||
16 | + } | ||
17 | + ], | ||
18 | + "require": { | ||
19 | + "php": ">=7.1.0", | ||
20 | + "topthink/think-installer": "~1.0" | ||
21 | + }, | ||
22 | + "require-dev": { | ||
23 | + "phpunit/phpunit": "4.8.*", | ||
24 | + "johnkary/phpunit-speedtrap": "^1.0", | ||
25 | + "mikey179/vfsstream": "~1.6", | ||
26 | + "phploc/phploc": "2.*", | ||
27 | + "sebastian/phpcpd": "2.*", | ||
28 | + "phpdocumentor/reflection-docblock": "^2.0" | ||
29 | + }, | ||
30 | + "autoload": { | ||
31 | + "psr-4": { | ||
32 | + "think\\": "library/think" | ||
33 | + } | ||
34 | + } | ||
35 | +} |
1 | -<?php | ||
2 | -// +---------------------------------------------------------------------- | ||
3 | -// | ThinkPHP [ WE CAN DO IT JUST THINK IT ] | ||
4 | -// +---------------------------------------------------------------------- | ||
5 | -// | Copyright (c) 2006-2017 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 | -namespace think; | ||
13 | - | ||
14 | -// ThinkPHP 引导文件 | ||
15 | -// 加载基础文件 | ||
16 | -require __DIR__ . '/base.php'; | ||
17 | - | ||
18 | -// 执行应用 | ||
19 | -App::initCommon(); | ||
20 | -Console::init(); | 1 | +<?php |
2 | +// +---------------------------------------------------------------------- | ||
3 | +// | ThinkPHP [ WE CAN DO IT JUST THINK IT ] | ||
4 | +// +---------------------------------------------------------------------- | ||
5 | +// | Copyright (c) 2006-2017 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 | +namespace think; | ||
13 | + | ||
14 | +// ThinkPHP 引导文件 | ||
15 | +// 加载基础文件 | ||
16 | +require __DIR__ . '/base.php'; | ||
17 | + | ||
18 | +// 执行应用 | ||
19 | +App::initCommon(); | ||
20 | +Console::init(); |
1 | -<?php | ||
2 | - | ||
3 | -return [ | ||
4 | - // +---------------------------------------------------------------------- | ||
5 | - // | 应用设置 | ||
6 | - // +---------------------------------------------------------------------- | ||
7 | - // 默认Host地址 | ||
8 | - 'app_host' => '', | ||
9 | - // 应用调试模式 | ||
10 | - 'app_debug' => false, | ||
11 | - // 应用Trace | ||
12 | - 'app_trace' => false, | ||
13 | - // 应用模式状态 | ||
14 | - 'app_status' => '', | ||
15 | - // 是否支持多模块 | ||
16 | - 'app_multi_module' => true, | ||
17 | - // 入口自动绑定模块 | ||
18 | - 'auto_bind_module' => false, | ||
19 | - // 注册的根命名空间 | ||
20 | - 'root_namespace' => [], | ||
21 | - // 扩展函数文件 | ||
22 | - 'extra_file_list' => [THINK_PATH . 'helper' . EXT], | ||
23 | - // 默认输出类型 | ||
24 | - 'default_return_type' => 'html', | ||
25 | - // 默认AJAX 数据返回格式,可选json xml ... | ||
26 | - 'default_ajax_return' => 'json', | ||
27 | - // 默认JSONP格式返回的处理方法 | ||
28 | - 'default_jsonp_handler' => 'jsonpReturn', | ||
29 | - // 默认JSONP处理方法 | ||
30 | - 'var_jsonp_handler' => 'callback', | ||
31 | - // 默认时区 | ||
32 | - 'default_timezone' => 'PRC', | ||
33 | - // 是否开启多语言 | ||
34 | - 'lang_switch_on' => false, | ||
35 | - // 默认全局过滤方法 用逗号分隔多个 | ||
36 | - 'default_filter' => '', | ||
37 | - // 默认语言 | ||
38 | - 'default_lang' => 'zh-cn', | ||
39 | - // 应用类库后缀 | ||
40 | - 'class_suffix' => false, | ||
41 | - // 控制器类后缀 | ||
42 | - 'controller_suffix' => false, | ||
43 | - | ||
44 | - // +---------------------------------------------------------------------- | ||
45 | - // | 模块设置 | ||
46 | - // +---------------------------------------------------------------------- | ||
47 | - | ||
48 | - // 默认模块名 | ||
49 | - 'default_module' => 'index', | ||
50 | - // 禁止访问模块 | ||
51 | - 'deny_module_list' => ['common'], | ||
52 | - // 默认控制器名 | ||
53 | - 'default_controller' => 'Index', | ||
54 | - // 默认操作名 | ||
55 | - 'default_action' => 'index', | ||
56 | - // 默认验证器 | ||
57 | - 'default_validate' => '', | ||
58 | - // 默认的空控制器名 | ||
59 | - 'empty_controller' => 'Error', | ||
60 | - // 操作方法前缀 | ||
61 | - 'use_action_prefix' => false, | ||
62 | - // 操作方法后缀 | ||
63 | - 'action_suffix' => '', | ||
64 | - // 自动搜索控制器 | ||
65 | - 'controller_auto_search' => false, | ||
66 | - | ||
67 | - // +---------------------------------------------------------------------- | ||
68 | - // | URL设置 | ||
69 | - // +---------------------------------------------------------------------- | ||
70 | - | ||
71 | - // PATHINFO变量名 用于兼容模式 | ||
72 | - 'var_pathinfo' => 's', | ||
73 | - // 兼容PATH_INFO获取 | ||
74 | - 'pathinfo_fetch' => ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL'], | ||
75 | - // pathinfo分隔符 | ||
76 | - 'pathinfo_depr' => '/', | ||
77 | - // HTTPS代理标识 | ||
78 | - 'https_agent_name' => '', | ||
79 | - // URL伪静态后缀 | ||
80 | - 'url_html_suffix' => 'html', | ||
81 | - // URL普通方式参数 用于自动生成 | ||
82 | - 'url_common_param' => false, | ||
83 | - // URL参数方式 0 按名称成对解析 1 按顺序解析 | ||
84 | - 'url_param_type' => 0, | ||
85 | - // 是否开启路由 | ||
86 | - 'url_route_on' => true, | ||
87 | - // 路由配置文件(支持配置多个) | ||
88 | - 'route_config_file' => ['route'], | ||
89 | - // 路由使用完整匹配 | ||
90 | - 'route_complete_match' => false, | ||
91 | - // 是否强制使用路由 | ||
92 | - 'url_route_must' => false, | ||
93 | - // 域名部署 | ||
94 | - 'url_domain_deploy' => false, | ||
95 | - // 域名根,如thinkphp.cn | ||
96 | - 'url_domain_root' => '', | ||
97 | - // 是否自动转换URL中的控制器和操作名 | ||
98 | - 'url_convert' => true, | ||
99 | - // 默认的访问控制器层 | ||
100 | - 'url_controller_layer' => 'controller', | ||
101 | - // 表单请求类型伪装变量 | ||
102 | - 'var_method' => '_method', | ||
103 | - // 表单ajax伪装变量 | ||
104 | - 'var_ajax' => '_ajax', | ||
105 | - // 表单pjax伪装变量 | ||
106 | - 'var_pjax' => '_pjax', | ||
107 | - // 是否开启请求缓存 true自动缓存 支持设置请求缓存规则 | ||
108 | - 'request_cache' => false, | ||
109 | - // 请求缓存有效期 | ||
110 | - 'request_cache_expire' => null, | ||
111 | - // 全局请求缓存排除规则 | ||
112 | - 'request_cache_except' => [], | ||
113 | - | ||
114 | - // +---------------------------------------------------------------------- | ||
115 | - // | 模板设置 | ||
116 | - // +---------------------------------------------------------------------- | ||
117 | - | ||
118 | - 'template' => [ | ||
119 | - // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 | ||
120 | - 'auto_rule' => 1, | ||
121 | - // 模板引擎类型 支持 php think 支持扩展 | ||
122 | - 'type' => 'Think', | ||
123 | - // 视图基础目录,配置目录为所有模块的视图起始目录 | ||
124 | - 'view_base' => '', | ||
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 | - // 是否记录trace信息到日志 | ||
161 | - 'record_trace' => false, | ||
162 | - | ||
163 | - // +---------------------------------------------------------------------- | ||
164 | - // | 日志设置 | ||
165 | - // +---------------------------------------------------------------------- | ||
166 | - | ||
167 | - 'log' => [ | ||
168 | - // 日志记录方式,内置 file socket 支持扩展 | ||
169 | - 'type' => 'File', | ||
170 | - // 日志保存目录 | ||
171 | - 'path' => LOG_PATH, | ||
172 | - // 日志记录级别 | ||
173 | - 'level' => [], | ||
174 | - ], | ||
175 | - | ||
176 | - // +---------------------------------------------------------------------- | ||
177 | - // | Trace设置 开启 app_trace 后 有效 | ||
178 | - // +---------------------------------------------------------------------- | ||
179 | - 'trace' => [ | ||
180 | - // 内置Html Console 支持扩展 | ||
181 | - 'type' => 'Html', | ||
182 | - ], | ||
183 | - | ||
184 | - // +---------------------------------------------------------------------- | ||
185 | - // | 缓存设置 | ||
186 | - // +---------------------------------------------------------------------- | ||
187 | - | ||
188 | - 'cache' => [ | ||
189 | - // 驱动方式 | ||
190 | - 'type' => 'File', | ||
191 | - // 缓存保存目录 | ||
192 | - 'path' => CACHE_PATH, | ||
193 | - // 缓存前缀 | ||
194 | - 'prefix' => '', | ||
195 | - // 缓存有效期 0表示永久缓存 | ||
196 | - 'expire' => 0, | ||
197 | - ], | ||
198 | - | ||
199 | - // +---------------------------------------------------------------------- | ||
200 | - // | 会话设置 | ||
201 | - // +---------------------------------------------------------------------- | ||
202 | - | ||
203 | - 'session' => [ | ||
204 | - 'id' => '', | ||
205 | - // SESSION_ID的提交变量,解决flash上传跨域 | ||
206 | - 'var_session_id' => '', | ||
207 | - // SESSION 前缀 | ||
208 | - 'prefix' => 'think', | ||
209 | - // 驱动方式 支持redis memcache memcached | ||
210 | - 'type' => '', | ||
211 | - // 是否自动开启 SESSION | ||
212 | - 'auto_start' => true, | ||
213 | - 'httponly' => true, | ||
214 | - 'secure' => false, | ||
215 | - ], | ||
216 | - | ||
217 | - // +---------------------------------------------------------------------- | ||
218 | - // | Cookie设置 | ||
219 | - // +---------------------------------------------------------------------- | ||
220 | - 'cookie' => [ | ||
221 | - // cookie 名称前缀 | ||
222 | - 'prefix' => '', | ||
223 | - // cookie 保存时间 | ||
224 | - 'expire' => 0, | ||
225 | - // cookie 保存路径 | ||
226 | - 'path' => '/', | ||
227 | - // cookie 有效域名 | ||
228 | - 'domain' => '', | ||
229 | - // cookie 启用安全传输 | ||
230 | - 'secure' => false, | ||
231 | - // httponly设置 | ||
232 | - 'httponly' => '', | ||
233 | - // 是否使用 setcookie | ||
234 | - 'setcookie' => true, | ||
235 | - ], | ||
236 | - | ||
237 | - // +---------------------------------------------------------------------- | ||
238 | - // | 数据库设置 | ||
239 | - // +---------------------------------------------------------------------- | ||
240 | - | ||
241 | - 'database' => [ | ||
242 | - // 数据库类型 | ||
243 | - 'type' => 'mysql', | ||
244 | - // 数据库连接DSN配置 | ||
245 | - 'dsn' => '', | ||
246 | - // 服务器地址 | ||
247 | - 'hostname' => '127.0.0.1', | ||
248 | - // 数据库名 | ||
249 | - 'database' => '', | ||
250 | - // 数据库用户名 | ||
251 | - 'username' => 'root', | ||
252 | - // 数据库密码 | ||
253 | - 'password' => '', | ||
254 | - // 数据库连接端口 | ||
255 | - 'hostport' => '', | ||
256 | - // 数据库连接参数 | ||
257 | - 'params' => [], | ||
258 | - // 数据库编码默认采用utf8 | ||
259 | - 'charset' => 'utf8', | ||
260 | - // 数据库表前缀 | ||
261 | - 'prefix' => '', | ||
262 | - // 数据库调试模式 | ||
263 | - 'debug' => false, | ||
264 | - // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) | ||
265 | - 'deploy' => 0, | ||
266 | - // 数据库读写是否分离 主从式有效 | ||
267 | - 'rw_separate' => false, | ||
268 | - // 读写分离后 主服务器数量 | ||
269 | - 'master_num' => 1, | ||
270 | - // 指定从服务器序号 | ||
271 | - 'slave_no' => '', | ||
272 | - // 是否严格检查字段是否存在 | ||
273 | - 'fields_strict' => true, | ||
274 | - // 数据集返回类型 | ||
275 | - 'resultset_type' => 'array', | ||
276 | - // 自动写入时间戳字段 | ||
277 | - 'auto_timestamp' => false, | ||
278 | - // 时间字段取出后的默认时间格式 | ||
279 | - 'datetime_format' => 'Y-m-d H:i:s', | ||
280 | - // 是否需要进行SQL性能分析 | ||
281 | - 'sql_explain' => false, | ||
282 | - ], | ||
283 | - | ||
284 | - //分页配置 | ||
285 | - 'paginate' => [ | ||
286 | - 'type' => 'bootstrap', | ||
287 | - 'var_page' => 'page', | ||
288 | - 'list_rows' => 15, | ||
289 | - ], | ||
290 | - | ||
291 | - //控制台配置 | ||
292 | - 'console' => [ | ||
293 | - 'name' => 'Think Console', | ||
294 | - 'version' => '0.1', | ||
295 | - 'user' => null, | ||
296 | - ], | ||
297 | - | ||
298 | -]; | 1 | +<?php |
2 | + | ||
3 | +return [ | ||
4 | + // +---------------------------------------------------------------------- | ||
5 | + // | 应用设置 | ||
6 | + // +---------------------------------------------------------------------- | ||
7 | + // 默认Host地址 | ||
8 | + 'app_host' => '', | ||
9 | + // 应用调试模式 | ||
10 | + 'app_debug' => false, | ||
11 | + // 应用Trace | ||
12 | + 'app_trace' => false, | ||
13 | + // 应用模式状态 | ||
14 | + 'app_status' => '', | ||
15 | + // 是否支持多模块 | ||
16 | + 'app_multi_module' => true, | ||
17 | + // 入口自动绑定模块 | ||
18 | + 'auto_bind_module' => false, | ||
19 | + // 注册的根命名空间 | ||
20 | + 'root_namespace' => [], | ||
21 | + // 扩展函数文件 | ||
22 | + 'extra_file_list' => [THINK_PATH . 'helper' . EXT], | ||
23 | + // 默认输出类型 | ||
24 | + 'default_return_type' => 'html', | ||
25 | + // 默认AJAX 数据返回格式,可选json xml ... | ||
26 | + 'default_ajax_return' => 'json', | ||
27 | + // 默认JSONP格式返回的处理方法 | ||
28 | + 'default_jsonp_handler' => 'jsonpReturn', | ||
29 | + // 默认JSONP处理方法 | ||
30 | + 'var_jsonp_handler' => 'callback', | ||
31 | + // 默认时区 | ||
32 | + 'default_timezone' => 'PRC', | ||
33 | + // 是否开启多语言 | ||
34 | + 'lang_switch_on' => false, | ||
35 | + // 默认全局过滤方法 用逗号分隔多个 | ||
36 | + 'default_filter' => '', | ||
37 | + // 默认语言 | ||
38 | + 'default_lang' => 'zh-cn', | ||
39 | + // 应用类库后缀 | ||
40 | + 'class_suffix' => false, | ||
41 | + // 控制器类后缀 | ||
42 | + 'controller_suffix' => false, | ||
43 | + | ||
44 | + // +---------------------------------------------------------------------- | ||
45 | + // | 模块设置 | ||
46 | + // +---------------------------------------------------------------------- | ||
47 | + | ||
48 | + // 默认模块名 | ||
49 | + 'default_module' => 'index', | ||
50 | + // 禁止访问模块 | ||
51 | + 'deny_module_list' => ['common'], | ||
52 | + // 默认控制器名 | ||
53 | + 'default_controller' => 'Index', | ||
54 | + // 默认操作名 | ||
55 | + 'default_action' => 'index', | ||
56 | + // 默认验证器 | ||
57 | + 'default_validate' => '', | ||
58 | + // 默认的空控制器名 | ||
59 | + 'empty_controller' => 'Error', | ||
60 | + // 操作方法前缀 | ||
61 | + 'use_action_prefix' => false, | ||
62 | + // 操作方法后缀 | ||
63 | + 'action_suffix' => '', | ||
64 | + // 自动搜索控制器 | ||
65 | + 'controller_auto_search' => false, | ||
66 | + | ||
67 | + // +---------------------------------------------------------------------- | ||
68 | + // | URL设置 | ||
69 | + // +---------------------------------------------------------------------- | ||
70 | + | ||
71 | + // PATHINFO变量名 用于兼容模式 | ||
72 | + 'var_pathinfo' => 's', | ||
73 | + // 兼容PATH_INFO获取 | ||
74 | + 'pathinfo_fetch' => ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL'], | ||
75 | + // pathinfo分隔符 | ||
76 | + 'pathinfo_depr' => '/', | ||
77 | + // HTTPS代理标识 | ||
78 | + 'https_agent_name' => '', | ||
79 | + // URL伪静态后缀 | ||
80 | + 'url_html_suffix' => 'html', | ||
81 | + // URL普通方式参数 用于自动生成 | ||
82 | + 'url_common_param' => false, | ||
83 | + // URL参数方式 0 按名称成对解析 1 按顺序解析 | ||
84 | + 'url_param_type' => 0, | ||
85 | + // 是否开启路由 | ||
86 | + 'url_route_on' => true, | ||
87 | + // 路由配置文件(支持配置多个) | ||
88 | + 'route_config_file' => ['route'], | ||
89 | + // 路由使用完整匹配 | ||
90 | + 'route_complete_match' => false, | ||
91 | + // 是否强制使用路由 | ||
92 | + 'url_route_must' => false, | ||
93 | + // 域名部署 | ||
94 | + 'url_domain_deploy' => false, | ||
95 | + // 域名根,如thinkphp.cn | ||
96 | + 'url_domain_root' => '', | ||
97 | + // 是否自动转换URL中的控制器和操作名 | ||
98 | + 'url_convert' => true, | ||
99 | + // 默认的访问控制器层 | ||
100 | + 'url_controller_layer' => 'controller', | ||
101 | + // 表单请求类型伪装变量 | ||
102 | + 'var_method' => '_method', | ||
103 | + // 表单ajax伪装变量 | ||
104 | + 'var_ajax' => '_ajax', | ||
105 | + // 表单pjax伪装变量 | ||
106 | + 'var_pjax' => '_pjax', | ||
107 | + // 是否开启请求缓存 true自动缓存 支持设置请求缓存规则 | ||
108 | + 'request_cache' => false, | ||
109 | + // 请求缓存有效期 | ||
110 | + 'request_cache_expire' => null, | ||
111 | + // 全局请求缓存排除规则 | ||
112 | + 'request_cache_except' => [], | ||
113 | + | ||
114 | + // +---------------------------------------------------------------------- | ||
115 | + // | 模板设置 | ||
116 | + // +---------------------------------------------------------------------- | ||
117 | + | ||
118 | + 'template' => [ | ||
119 | + // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 | ||
120 | + 'auto_rule' => 1, | ||
121 | + // 模板引擎类型 支持 php think 支持扩展 | ||
122 | + 'type' => 'Think', | ||
123 | + // 视图基础目录,配置目录为所有模块的视图起始目录 | ||
124 | + 'view_base' => '', | ||
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 | + // 是否记录trace信息到日志 | ||
161 | + 'record_trace' => false, | ||
162 | + | ||
163 | + // +---------------------------------------------------------------------- | ||
164 | + // | 日志设置 | ||
165 | + // +---------------------------------------------------------------------- | ||
166 | + | ||
167 | + 'log' => [ | ||
168 | + // 日志记录方式,内置 file socket 支持扩展 | ||
169 | + 'type' => 'File', | ||
170 | + // 日志保存目录 | ||
171 | + 'path' => LOG_PATH, | ||
172 | + // 日志记录级别 | ||
173 | + 'level' => [], | ||
174 | + ], | ||
175 | + | ||
176 | + // +---------------------------------------------------------------------- | ||
177 | + // | Trace设置 开启 app_trace 后 有效 | ||
178 | + // +---------------------------------------------------------------------- | ||
179 | + 'trace' => [ | ||
180 | + // 内置Html Console 支持扩展 | ||
181 | + 'type' => 'Html', | ||
182 | + ], | ||
183 | + | ||
184 | + // +---------------------------------------------------------------------- | ||
185 | + // | 缓存设置 | ||
186 | + // +---------------------------------------------------------------------- | ||
187 | + | ||
188 | + 'cache' => [ | ||
189 | + // 驱动方式 | ||
190 | + 'type' => 'File', | ||
191 | + // 缓存保存目录 | ||
192 | + 'path' => CACHE_PATH, | ||
193 | + // 缓存前缀 | ||
194 | + 'prefix' => '', | ||
195 | + // 缓存有效期 0表示永久缓存 | ||
196 | + 'expire' => 0, | ||
197 | + ], | ||
198 | + | ||
199 | + // +---------------------------------------------------------------------- | ||
200 | + // | 会话设置 | ||
201 | + // +---------------------------------------------------------------------- | ||
202 | + | ||
203 | + 'session' => [ | ||
204 | + 'id' => '', | ||
205 | + // SESSION_ID的提交变量,解决flash上传跨域 | ||
206 | + 'var_session_id' => '', | ||
207 | + // SESSION 前缀 | ||
208 | + 'prefix' => 'think', | ||
209 | + // 驱动方式 支持redis memcache memcached | ||
210 | + 'type' => '', | ||
211 | + // 是否自动开启 SESSION | ||
212 | + 'auto_start' => true, | ||
213 | + 'httponly' => true, | ||
214 | + 'secure' => false, | ||
215 | + ], | ||
216 | + | ||
217 | + // +---------------------------------------------------------------------- | ||
218 | + // | Cookie设置 | ||
219 | + // +---------------------------------------------------------------------- | ||
220 | + 'cookie' => [ | ||
221 | + // cookie 名称前缀 | ||
222 | + 'prefix' => '', | ||
223 | + // cookie 保存时间 | ||
224 | + 'expire' => 0, | ||
225 | + // cookie 保存路径 | ||
226 | + 'path' => '/', | ||
227 | + // cookie 有效域名 | ||
228 | + 'domain' => '', | ||
229 | + // cookie 启用安全传输 | ||
230 | + 'secure' => false, | ||
231 | + // httponly设置 | ||
232 | + 'httponly' => '', | ||
233 | + // 是否使用 setcookie | ||
234 | + 'setcookie' => true, | ||
235 | + ], | ||
236 | + | ||
237 | + // +---------------------------------------------------------------------- | ||
238 | + // | 数据库设置 | ||
239 | + // +---------------------------------------------------------------------- | ||
240 | + | ||
241 | + 'database' => [ | ||
242 | + // 数据库类型 | ||
243 | + 'type' => 'mysql', | ||
244 | + // 数据库连接DSN配置 | ||
245 | + 'dsn' => '', | ||
246 | + // 服务器地址 | ||
247 | + 'hostname' => '127.0.0.1', | ||
248 | + // 数据库名 | ||
249 | + 'database' => '', | ||
250 | + // 数据库用户名 | ||
251 | + 'username' => 'root', | ||
252 | + // 数据库密码 | ||
253 | + 'password' => '', | ||
254 | + // 数据库连接端口 | ||
255 | + 'hostport' => '', | ||
256 | + // 数据库连接参数 | ||
257 | + 'params' => [], | ||
258 | + // 数据库编码默认采用utf8 | ||
259 | + 'charset' => 'utf8', | ||
260 | + // 数据库表前缀 | ||
261 | + 'prefix' => '', | ||
262 | + // 数据库调试模式 | ||
263 | + 'debug' => false, | ||
264 | + // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) | ||
265 | + 'deploy' => 0, | ||
266 | + // 数据库读写是否分离 主从式有效 | ||
267 | + 'rw_separate' => false, | ||
268 | + // 读写分离后 主服务器数量 | ||
269 | + 'master_num' => 1, | ||
270 | + // 指定从服务器序号 | ||
271 | + 'slave_no' => '', | ||
272 | + // 是否严格检查字段是否存在 | ||
273 | + 'fields_strict' => true, | ||
274 | + // 数据集返回类型 | ||
275 | + 'resultset_type' => 'array', | ||
276 | + // 自动写入时间戳字段 | ||
277 | + 'auto_timestamp' => false, | ||
278 | + // 时间字段取出后的默认时间格式 | ||
279 | + 'datetime_format' => 'Y-m-d H:i:s', | ||
280 | + // 是否需要进行SQL性能分析 | ||
281 | + 'sql_explain' => false, | ||
282 | + ], | ||
283 | + | ||
284 | + //分页配置 | ||
285 | + 'paginate' => [ | ||
286 | + 'type' => 'bootstrap', | ||
287 | + 'var_page' => 'page', | ||
288 | + 'list_rows' => 15, | ||
289 | + ], | ||
290 | + | ||
291 | + //控制台配置 | ||
292 | + 'console' => [ | ||
293 | + 'name' => 'Think Console', | ||
294 | + 'version' => '0.1', | ||
295 | + 'user' => null, | ||
296 | + ], | ||
297 | + | ||
298 | +]; |
1 | -<?php | ||
2 | -// +---------------------------------------------------------------------- | ||
3 | -// | ThinkPHP [ WE CAN DO IT JUST THINK ] | ||
4 | -// +---------------------------------------------------------------------- | ||
5 | -// | Copyright (c) 2006~2018 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 | -// ThinkPHP 助手函数 | ||
14 | -//------------------------- | ||
15 | - | ||
16 | -use think\Cache; | ||
17 | -use think\Config; | ||
18 | -use think\Cookie; | ||
19 | -use think\Db; | ||
20 | -use think\Debug; | ||
21 | -use think\exception\HttpException; | ||
22 | -use think\exception\HttpResponseException; | ||
23 | -use think\Lang; | ||
24 | -use think\Loader; | ||
25 | -use think\Log; | ||
26 | -use think\Model; | ||
27 | -use think\Request; | ||
28 | -use think\Response; | ||
29 | -use think\Session; | ||
30 | -use think\Url; | ||
31 | -use think\View; | ||
32 | - | ||
33 | -if (!function_exists('load_trait')) { | ||
34 | - /** | ||
35 | - * 快速导入Traits PHP5.5以上无需调用 | ||
36 | - * @param string $class trait库 | ||
37 | - * @param string $ext 类库后缀 | ||
38 | - * @return boolean | ||
39 | - */ | ||
40 | - function load_trait($class, $ext = EXT) | ||
41 | - { | ||
42 | - return Loader::import($class, TRAIT_PATH, $ext); | ||
43 | - } | ||
44 | -} | ||
45 | - | ||
46 | -if (!function_exists('exception')) { | ||
47 | - /** | ||
48 | - * 抛出异常处理 | ||
49 | - * | ||
50 | - * @param string $msg 异常消息 | ||
51 | - * @param integer $code 异常代码 默认为0 | ||
52 | - * @param string $exception 异常类 | ||
53 | - * | ||
54 | - * @throws Exception | ||
55 | - */ | ||
56 | - function exception($msg, $code = 0, $exception = '') | ||
57 | - { | ||
58 | - $e = $exception ?: '\think\Exception'; | ||
59 | - throw new $e($msg, $code); | ||
60 | - } | ||
61 | -} | ||
62 | - | ||
63 | -if (!function_exists('debug')) { | ||
64 | - /** | ||
65 | - * 记录时间(微秒)和内存使用情况 | ||
66 | - * @param string $start 开始标签 | ||
67 | - * @param string $end 结束标签 | ||
68 | - * @param integer|string $dec 小数位 如果是m 表示统计内存占用 | ||
69 | - * @return mixed | ||
70 | - */ | ||
71 | - function debug($start, $end = '', $dec = 6) | ||
72 | - { | ||
73 | - if ('' == $end) { | ||
74 | - Debug::remark($start); | ||
75 | - } else { | ||
76 | - return 'm' == $dec ? Debug::getRangeMem($start, $end) : Debug::getRangeTime($start, $end, $dec); | ||
77 | - } | ||
78 | - } | ||
79 | -} | ||
80 | - | ||
81 | -if (!function_exists('lang')) { | ||
82 | - /** | ||
83 | - * 获取语言变量值 | ||
84 | - * @param string $name 语言变量名 | ||
85 | - * @param array $vars 动态变量值 | ||
86 | - * @param string $lang 语言 | ||
87 | - * @return mixed | ||
88 | - */ | ||
89 | - function lang($name, $vars = [], $lang = '') | ||
90 | - { | ||
91 | - return Lang::get($name, $vars, $lang); | ||
92 | - } | ||
93 | -} | ||
94 | - | ||
95 | -if (!function_exists('config')) { | ||
96 | - /** | ||
97 | - * 获取和设置配置参数 | ||
98 | - * @param string|array $name 参数名 | ||
99 | - * @param mixed $value 参数值 | ||
100 | - * @param string $range 作用域 | ||
101 | - * @return mixed | ||
102 | - */ | ||
103 | - function config($name = '', $value = null, $range = '') | ||
104 | - { | ||
105 | - if (is_null($value) && is_string($name)) { | ||
106 | - return 0 === strpos($name, '?') ? Config::has(substr($name, 1), $range) : Config::get($name, $range); | ||
107 | - } else { | ||
108 | - return Config::set($name, $value, $range); | ||
109 | - } | ||
110 | - } | ||
111 | -} | ||
112 | - | ||
113 | -if (!function_exists('input')) { | ||
114 | - /** | ||
115 | - * 获取输入数据 支持默认值和过滤 | ||
116 | - * @param string $key 获取的变量名 | ||
117 | - * @param mixed $default 默认值 | ||
118 | - * @param string $filter 过滤方法 | ||
119 | - * @return mixed | ||
120 | - */ | ||
121 | - function input($key = '', $default = null, $filter = '') | ||
122 | - { | ||
123 | - if (0 === strpos($key, '?')) { | ||
124 | - $key = substr($key, 1); | ||
125 | - $has = true; | ||
126 | - } | ||
127 | - if ($pos = strpos($key, '.')) { | ||
128 | - // 指定参数来源 | ||
129 | - list($method, $key) = explode('.', $key, 2); | ||
130 | - if (!in_array($method, ['get', 'post', 'put', 'patch', 'delete', 'route', 'param', 'request', 'session', 'cookie', 'server', 'env', 'path', 'file'])) { | ||
131 | - $key = $method . '.' . $key; | ||
132 | - $method = 'param'; | ||
133 | - } | ||
134 | - } else { | ||
135 | - // 默认为自动判断 | ||
136 | - $method = 'param'; | ||
137 | - } | ||
138 | - if (isset($has)) { | ||
139 | - return request()->has($key, $method, $default); | ||
140 | - } else { | ||
141 | - return request()->$method($key, $default, $filter); | ||
142 | - } | ||
143 | - } | ||
144 | -} | ||
145 | - | ||
146 | -if (!function_exists('widget')) { | ||
147 | - /** | ||
148 | - * 渲染输出Widget | ||
149 | - * @param string $name Widget名称 | ||
150 | - * @param array $data 传入的参数 | ||
151 | - * @return mixed | ||
152 | - */ | ||
153 | - function widget($name, $data = []) | ||
154 | - { | ||
155 | - return Loader::action($name, $data, 'widget'); | ||
156 | - } | ||
157 | -} | ||
158 | - | ||
159 | -if (!function_exists('model')) { | ||
160 | - /** | ||
161 | - * 实例化Model | ||
162 | - * @param string $name Model名称 | ||
163 | - * @param string $layer 业务层名称 | ||
164 | - * @param bool $appendSuffix 是否添加类名后缀 | ||
165 | - * @return \think\Model | ||
166 | - */ | ||
167 | - function model($name = '', $layer = 'model', $appendSuffix = false) | ||
168 | - { | ||
169 | - return Loader::model($name, $layer, $appendSuffix); | ||
170 | - } | ||
171 | -} | ||
172 | - | ||
173 | -if (!function_exists('validate')) { | ||
174 | - /** | ||
175 | - * 实例化验证器 | ||
176 | - * @param string $name 验证器名称 | ||
177 | - * @param string $layer 业务层名称 | ||
178 | - * @param bool $appendSuffix 是否添加类名后缀 | ||
179 | - * @return \think\Validate | ||
180 | - */ | ||
181 | - function validate($name = '', $layer = 'validate', $appendSuffix = false) | ||
182 | - { | ||
183 | - return Loader::validate($name, $layer, $appendSuffix); | ||
184 | - } | ||
185 | -} | ||
186 | - | ||
187 | -if (!function_exists('db')) { | ||
188 | - /** | ||
189 | - * 实例化数据库类 | ||
190 | - * @param string $name 操作的数据表名称(不含前缀) | ||
191 | - * @param array|string $config 数据库配置参数 | ||
192 | - * @param bool $force 是否强制重新连接 | ||
193 | - * @return \think\db\Query | ||
194 | - */ | ||
195 | - function db($name = '', $config = [], $force = false) | ||
196 | - { | ||
197 | - return Db::connect($config, $force)->name($name); | ||
198 | - } | ||
199 | -} | ||
200 | - | ||
201 | -if (!function_exists('controller')) { | ||
202 | - /** | ||
203 | - * 实例化控制器 格式:[模块/]控制器 | ||
204 | - * @param string $name 资源地址 | ||
205 | - * @param string $layer 控制层名称 | ||
206 | - * @param bool $appendSuffix 是否添加类名后缀 | ||
207 | - * @return \think\Controller | ||
208 | - */ | ||
209 | - function controller($name, $layer = 'controller', $appendSuffix = false) | ||
210 | - { | ||
211 | - return Loader::controller($name, $layer, $appendSuffix); | ||
212 | - } | ||
213 | -} | ||
214 | - | ||
215 | -if (!function_exists('action')) { | ||
216 | - /** | ||
217 | - * 调用模块的操作方法 参数格式 [模块/控制器/]操作 | ||
218 | - * @param string $url 调用地址 | ||
219 | - * @param string|array $vars 调用参数 支持字符串和数组 | ||
220 | - * @param string $layer 要调用的控制层名称 | ||
221 | - * @param bool $appendSuffix 是否添加类名后缀 | ||
222 | - * @return mixed | ||
223 | - */ | ||
224 | - function action($url, $vars = [], $layer = 'controller', $appendSuffix = false) | ||
225 | - { | ||
226 | - return Loader::action($url, $vars, $layer, $appendSuffix); | ||
227 | - } | ||
228 | -} | ||
229 | - | ||
230 | -if (!function_exists('import')) { | ||
231 | - /** | ||
232 | - * 导入所需的类库 同java的Import 本函数有缓存功能 | ||
233 | - * @param string $class 类库命名空间字符串 | ||
234 | - * @param string $baseUrl 起始路径 | ||
235 | - * @param string $ext 导入的文件扩展名 | ||
236 | - * @return boolean | ||
237 | - */ | ||
238 | - function import($class, $baseUrl = '', $ext = EXT) | ||
239 | - { | ||
240 | - return Loader::import($class, $baseUrl, $ext); | ||
241 | - } | ||
242 | -} | ||
243 | - | ||
244 | -if (!function_exists('vendor')) { | ||
245 | - /** | ||
246 | - * 快速导入第三方框架类库 所有第三方框架的类库文件统一放到 系统的Vendor目录下面 | ||
247 | - * @param string $class 类库 | ||
248 | - * @param string $ext 类库后缀 | ||
249 | - * @return boolean | ||
250 | - */ | ||
251 | - function vendor($class, $ext = EXT) | ||
252 | - { | ||
253 | - return Loader::import($class, VENDOR_PATH, $ext); | ||
254 | - } | ||
255 | -} | ||
256 | - | ||
257 | -if (!function_exists('dump')) { | ||
258 | - /** | ||
259 | - * 浏览器友好的变量输出 | ||
260 | - * @param mixed $var 变量 | ||
261 | - * @param boolean $echo 是否输出 默认为true 如果为false 则返回输出字符串 | ||
262 | - * @param string $label 标签 默认为空 | ||
263 | - * @return void|string | ||
264 | - */ | ||
265 | - function dump($var, $echo = true, $label = null) | ||
266 | - { | ||
267 | - return Debug::dump($var, $echo, $label); | ||
268 | - } | ||
269 | -} | ||
270 | - | ||
271 | -if (!function_exists('url')) { | ||
272 | - /** | ||
273 | - * Url生成 | ||
274 | - * @param string $url 路由地址 | ||
275 | - * @param string|array $vars 变量 | ||
276 | - * @param bool|string $suffix 生成的URL后缀 | ||
277 | - * @param bool|string $domain 域名 | ||
278 | - * @return string | ||
279 | - */ | ||
280 | - function url($url = '', $vars = '', $suffix = true, $domain = false) | ||
281 | - { | ||
282 | - return Url::build($url, $vars, $suffix, $domain); | ||
283 | - } | ||
284 | -} | ||
285 | - | ||
286 | -if (!function_exists('session')) { | ||
287 | - /** | ||
288 | - * Session管理 | ||
289 | - * @param string|array $name session名称,如果为数组表示进行session设置 | ||
290 | - * @param mixed $value session值 | ||
291 | - * @param string $prefix 前缀 | ||
292 | - * @return mixed | ||
293 | - */ | ||
294 | - function session($name, $value = '', $prefix = null) | ||
295 | - { | ||
296 | - if (is_array($name)) { | ||
297 | - // 初始化 | ||
298 | - Session::init($name); | ||
299 | - } elseif (is_null($name)) { | ||
300 | - // 清除 | ||
301 | - Session::clear('' === $value ? null : $value); | ||
302 | - } elseif ('' === $value) { | ||
303 | - // 判断或获取 | ||
304 | - return 0 === strpos($name, '?') ? Session::has(substr($name, 1), $prefix) : Session::get($name, $prefix); | ||
305 | - } elseif (is_null($value)) { | ||
306 | - // 删除 | ||
307 | - return Session::delete($name, $prefix); | ||
308 | - } else { | ||
309 | - // 设置 | ||
310 | - return Session::set($name, $value, $prefix); | ||
311 | - } | ||
312 | - } | ||
313 | -} | ||
314 | - | ||
315 | -if (!function_exists('cookie')) { | ||
316 | - /** | ||
317 | - * Cookie管理 | ||
318 | - * @param string|array $name cookie名称,如果为数组表示进行cookie设置 | ||
319 | - * @param mixed $value cookie值 | ||
320 | - * @param mixed $option 参数 | ||
321 | - * @return mixed | ||
322 | - */ | ||
323 | - function cookie($name, $value = '', $option = null) | ||
324 | - { | ||
325 | - if (is_array($name)) { | ||
326 | - // 初始化 | ||
327 | - Cookie::init($name); | ||
328 | - } elseif (is_null($name)) { | ||
329 | - // 清除 | ||
330 | - Cookie::clear($value); | ||
331 | - } elseif ('' === $value) { | ||
332 | - // 获取 | ||
333 | - return 0 === strpos($name, '?') ? Cookie::has(substr($name, 1), $option) : Cookie::get($name, $option); | ||
334 | - } elseif (is_null($value)) { | ||
335 | - // 删除 | ||
336 | - return Cookie::delete($name); | ||
337 | - } else { | ||
338 | - // 设置 | ||
339 | - return Cookie::set($name, $value, $option); | ||
340 | - } | ||
341 | - } | ||
342 | -} | ||
343 | - | ||
344 | -if (!function_exists('cache')) { | ||
345 | - /** | ||
346 | - * 缓存管理 | ||
347 | - * @param mixed $name 缓存名称,如果为数组表示进行缓存设置 | ||
348 | - * @param mixed $value 缓存值 | ||
349 | - * @param mixed $options 缓存参数 | ||
350 | - * @param string $tag 缓存标签 | ||
351 | - * @return mixed | ||
352 | - */ | ||
353 | - function cache($name, $value = '', $options = null, $tag = null) | ||
354 | - { | ||
355 | - if (is_array($options)) { | ||
356 | - // 缓存操作的同时初始化 | ||
357 | - $cache = Cache::connect($options); | ||
358 | - } elseif (is_array($name)) { | ||
359 | - // 缓存初始化 | ||
360 | - return Cache::connect($name); | ||
361 | - } else { | ||
362 | - $cache = Cache::init(); | ||
363 | - } | ||
364 | - | ||
365 | - if (is_null($name)) { | ||
366 | - return $cache->clear($value); | ||
367 | - } elseif ('' === $value) { | ||
368 | - // 获取缓存 | ||
369 | - return 0 === strpos($name, '?') ? $cache->has(substr($name, 1)) : $cache->get($name); | ||
370 | - } elseif (is_null($value)) { | ||
371 | - // 删除缓存 | ||
372 | - return $cache->rm($name); | ||
373 | - } elseif (0 === strpos($name, '?') && '' !== $value) { | ||
374 | - $expire = is_numeric($options) ? $options : null; | ||
375 | - return $cache->remember(substr($name, 1), $value, $expire); | ||
376 | - } else { | ||
377 | - // 缓存数据 | ||
378 | - if (is_array($options)) { | ||
379 | - $expire = isset($options['expire']) ? $options['expire'] : null; //修复查询缓存无法设置过期时间 | ||
380 | - } else { | ||
381 | - $expire = is_numeric($options) ? $options : null; //默认快捷缓存设置过期时间 | ||
382 | - } | ||
383 | - if (is_null($tag)) { | ||
384 | - return $cache->set($name, $value, $expire); | ||
385 | - } else { | ||
386 | - return $cache->tag($tag)->set($name, $value, $expire); | ||
387 | - } | ||
388 | - } | ||
389 | - } | ||
390 | -} | ||
391 | - | ||
392 | -if (!function_exists('trace')) { | ||
393 | - /** | ||
394 | - * 记录日志信息 | ||
395 | - * @param mixed $log log信息 支持字符串和数组 | ||
396 | - * @param string $level 日志级别 | ||
397 | - * @return void|array | ||
398 | - */ | ||
399 | - function trace($log = '[think]', $level = 'log') | ||
400 | - { | ||
401 | - if ('[think]' === $log) { | ||
402 | - return Log::getLog(); | ||
403 | - } else { | ||
404 | - Log::record($log, $level); | ||
405 | - } | ||
406 | - } | ||
407 | -} | ||
408 | - | ||
409 | -if (!function_exists('request')) { | ||
410 | - /** | ||
411 | - * 获取当前Request对象实例 | ||
412 | - * @return Request | ||
413 | - */ | ||
414 | - function request() | ||
415 | - { | ||
416 | - return Request::instance(); | ||
417 | - } | ||
418 | -} | ||
419 | - | ||
420 | -if (!function_exists('response')) { | ||
421 | - /** | ||
422 | - * 创建普通 Response 对象实例 | ||
423 | - * @param mixed $data 输出数据 | ||
424 | - * @param int|string $code 状态码 | ||
425 | - * @param array $header 头信息 | ||
426 | - * @param string $type | ||
427 | - * @return Response | ||
428 | - */ | ||
429 | - function response($data = [], $code = 200, $header = [], $type = 'html') | ||
430 | - { | ||
431 | - return Response::create($data, $type, $code, $header); | ||
432 | - } | ||
433 | -} | ||
434 | - | ||
435 | -if (!function_exists('view')) { | ||
436 | - /** | ||
437 | - * 渲染模板输出 | ||
438 | - * @param string $template 模板文件 | ||
439 | - * @param array $vars 模板变量 | ||
440 | - * @param array $replace 模板替换 | ||
441 | - * @param integer $code 状态码 | ||
442 | - * @return \think\response\View | ||
443 | - */ | ||
444 | - function view($template = '', $vars = [], $replace = [], $code = 200) | ||
445 | - { | ||
446 | - return Response::create($template, 'view', $code)->replace($replace)->assign($vars); | ||
447 | - } | ||
448 | -} | ||
449 | - | ||
450 | -if (!function_exists('json')) { | ||
451 | - /** | ||
452 | - * 获取\think\response\Json对象实例 | ||
453 | - * @param mixed $data 返回的数据 | ||
454 | - * @param integer $code 状态码 | ||
455 | - * @param array $header 头部 | ||
456 | - * @param array $options 参数 | ||
457 | - * @return \think\response\Json | ||
458 | - */ | ||
459 | - function json($data = [], $code = 200, $header = [], $options = []) | ||
460 | - { | ||
461 | - return Response::create($data, 'json', $code, $header, $options); | ||
462 | - } | ||
463 | -} | ||
464 | - | ||
465 | -if (!function_exists('jsonp')) { | ||
466 | - /** | ||
467 | - * 获取\think\response\Jsonp对象实例 | ||
468 | - * @param mixed $data 返回的数据 | ||
469 | - * @param integer $code 状态码 | ||
470 | - * @param array $header 头部 | ||
471 | - * @param array $options 参数 | ||
472 | - * @return \think\response\Jsonp | ||
473 | - */ | ||
474 | - function jsonp($data = [], $code = 200, $header = [], $options = []) | ||
475 | - { | ||
476 | - return Response::create($data, 'jsonp', $code, $header, $options); | ||
477 | - } | ||
478 | -} | ||
479 | - | ||
480 | -if (!function_exists('xml')) { | ||
481 | - /** | ||
482 | - * 获取\think\response\Xml对象实例 | ||
483 | - * @param mixed $data 返回的数据 | ||
484 | - * @param integer $code 状态码 | ||
485 | - * @param array $header 头部 | ||
486 | - * @param array $options 参数 | ||
487 | - * @return \think\response\Xml | ||
488 | - */ | ||
489 | - function xml($data = [], $code = 200, $header = [], $options = []) | ||
490 | - { | ||
491 | - return Response::create($data, 'xml', $code, $header, $options); | ||
492 | - } | ||
493 | -} | ||
494 | - | ||
495 | -if (!function_exists('redirect')) { | ||
496 | - /** | ||
497 | - * 获取\think\response\Redirect对象实例 | ||
498 | - * @param mixed $url 重定向地址 支持Url::build方法的地址 | ||
499 | - * @param array|integer $params 额外参数 | ||
500 | - * @param integer $code 状态码 | ||
501 | - * @param array $with 隐式传参 | ||
502 | - * @return \think\response\Redirect | ||
503 | - */ | ||
504 | - function redirect($url = [], $params = [], $code = 302, $with = []) | ||
505 | - { | ||
506 | - if (is_integer($params)) { | ||
507 | - $code = $params; | ||
508 | - $params = []; | ||
509 | - } | ||
510 | - return Response::create($url, 'redirect', $code)->params($params)->with($with); | ||
511 | - } | ||
512 | -} | ||
513 | - | ||
514 | -if (!function_exists('abort')) { | ||
515 | - /** | ||
516 | - * 抛出HTTP异常 | ||
517 | - * @param integer|Response $code 状态码 或者 Response对象实例 | ||
518 | - * @param string $message 错误信息 | ||
519 | - * @param array $header 参数 | ||
520 | - */ | ||
521 | - function abort($code, $message = null, $header = []) | ||
522 | - { | ||
523 | - if ($code instanceof Response) { | ||
524 | - throw new HttpResponseException($code); | ||
525 | - } else { | ||
526 | - throw new HttpException($code, $message, null, $header); | ||
527 | - } | ||
528 | - } | ||
529 | -} | ||
530 | - | ||
531 | -if (!function_exists('halt')) { | ||
532 | - /** | ||
533 | - * 调试变量并且中断输出 | ||
534 | - * @param mixed $var 调试变量或者信息 | ||
535 | - */ | ||
536 | - function halt($var) | ||
537 | - { | ||
538 | - dump($var); | ||
539 | - throw new HttpResponseException(new Response); | ||
540 | - } | ||
541 | -} | ||
542 | - | ||
543 | -if (!function_exists('token')) { | ||
544 | - /** | ||
545 | - * 生成表单令牌 | ||
546 | - * @param string $name 令牌名称 | ||
547 | - * @param mixed $type 令牌生成方法 | ||
548 | - * @return string | ||
549 | - */ | ||
550 | - function token($name = '__token__', $type = 'md5') | ||
551 | - { | ||
552 | - $token = Request::instance()->token($name, $type); | ||
553 | - return '<input type="hidden" name="' . $name . '" value="' . $token . '" />'; | ||
554 | - } | ||
555 | -} | ||
556 | - | ||
557 | -if (!function_exists('load_relation')) { | ||
558 | - /** | ||
559 | - * 延迟预载入关联查询 | ||
560 | - * @param mixed $resultSet 数据集 | ||
561 | - * @param mixed $relation 关联 | ||
562 | - * @return array | ||
563 | - */ | ||
564 | - function load_relation($resultSet, $relation) | ||
565 | - { | ||
566 | - $item = current($resultSet); | ||
567 | - if ($item instanceof Model) { | ||
568 | - $item->eagerlyResultSet($resultSet, $relation); | ||
569 | - } | ||
570 | - return $resultSet; | ||
571 | - } | ||
572 | -} | ||
573 | - | ||
574 | -if (!function_exists('collection')) { | ||
575 | - /** | ||
576 | - * 数组转换为数据集对象 | ||
577 | - * @param array $resultSet 数据集数组 | ||
578 | - * @return \think\model\Collection|\think\Collection | ||
579 | - */ | ||
580 | - function collection($resultSet) | ||
581 | - { | ||
582 | - $item = current($resultSet); | ||
583 | - if ($item instanceof Model) { | ||
584 | - return \think\model\Collection::make($resultSet); | ||
585 | - } else { | ||
586 | - return \think\Collection::make($resultSet); | ||
587 | - } | ||
588 | - } | ||
589 | -} | 1 | +<?php |
2 | +// +---------------------------------------------------------------------- | ||
3 | +// | ThinkPHP [ WE CAN DO IT JUST THINK ] | ||
4 | +// +---------------------------------------------------------------------- | ||
5 | +// | Copyright (c) 2006~2018 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 | +// ThinkPHP 助手函数 | ||
14 | +//------------------------- | ||
15 | + | ||
16 | +use think\Cache; | ||
17 | +use think\Config; | ||
18 | +use think\Cookie; | ||
19 | +use think\Db; | ||
20 | +use think\Debug; | ||
21 | +use think\exception\HttpException; | ||
22 | +use think\exception\HttpResponseException; | ||
23 | +use think\Lang; | ||
24 | +use think\Loader; | ||
25 | +use think\Log; | ||
26 | +use think\Model; | ||
27 | +use think\Request; | ||
28 | +use think\Response; | ||
29 | +use think\Session; | ||
30 | +use think\Url; | ||
31 | +use think\View; | ||
32 | + | ||
33 | +if (!function_exists('load_trait')) { | ||
34 | + /** | ||
35 | + * 快速导入Traits PHP5.5以上无需调用 | ||
36 | + * @param string $class trait库 | ||
37 | + * @param string $ext 类库后缀 | ||
38 | + * @return boolean | ||
39 | + */ | ||
40 | + function load_trait($class, $ext = EXT) | ||
41 | + { | ||
42 | + return Loader::import($class, TRAIT_PATH, $ext); | ||
43 | + } | ||
44 | +} | ||
45 | + | ||
46 | +if (!function_exists('exception')) { | ||
47 | + /** | ||
48 | + * 抛出异常处理 | ||
49 | + * | ||
50 | + * @param string $msg 异常消息 | ||
51 | + * @param integer $code 异常代码 默认为0 | ||
52 | + * @param string $exception 异常类 | ||
53 | + * | ||
54 | + * @throws Exception | ||
55 | + */ | ||
56 | + function exception($msg, $code = 0, $exception = '') | ||
57 | + { | ||
58 | + $e = $exception ?: '\think\Exception'; | ||
59 | + throw new $e($msg, $code); | ||
60 | + } | ||
61 | +} | ||
62 | + | ||
63 | +if (!function_exists('debug')) { | ||
64 | + /** | ||
65 | + * 记录时间(微秒)和内存使用情况 | ||
66 | + * @param string $start 开始标签 | ||
67 | + * @param string $end 结束标签 | ||
68 | + * @param integer|string $dec 小数位 如果是m 表示统计内存占用 | ||
69 | + * @return mixed | ||
70 | + */ | ||
71 | + function debug($start, $end = '', $dec = 6) | ||
72 | + { | ||
73 | + if ('' == $end) { | ||
74 | + Debug::remark($start); | ||
75 | + } else { | ||
76 | + return 'm' == $dec ? Debug::getRangeMem($start, $end) : Debug::getRangeTime($start, $end, $dec); | ||
77 | + } | ||
78 | + } | ||
79 | +} | ||
80 | + | ||
81 | +if (!function_exists('lang')) { | ||
82 | + /** | ||
83 | + * 获取语言变量值 | ||
84 | + * @param string $name 语言变量名 | ||
85 | + * @param array $vars 动态变量值 | ||
86 | + * @param string $lang 语言 | ||
87 | + * @return mixed | ||
88 | + */ | ||
89 | + function lang($name, $vars = [], $lang = '') | ||
90 | + { | ||
91 | + return Lang::get($name, $vars, $lang); | ||
92 | + } | ||
93 | +} | ||
94 | + | ||
95 | +if (!function_exists('config')) { | ||
96 | + /** | ||
97 | + * 获取和设置配置参数 | ||
98 | + * @param string|array $name 参数名 | ||
99 | + * @param mixed $value 参数值 | ||
100 | + * @param string $range 作用域 | ||
101 | + * @return mixed | ||
102 | + */ | ||
103 | + function config($name = '', $value = null, $range = '') | ||
104 | + { | ||
105 | + if (is_null($value) && is_string($name)) { | ||
106 | + return 0 === strpos($name, '?') ? Config::has(substr($name, 1), $range) : Config::get($name, $range); | ||
107 | + } else { | ||
108 | + return Config::set($name, $value, $range); | ||
109 | + } | ||
110 | + } | ||
111 | +} | ||
112 | + | ||
113 | +if (!function_exists('input')) { | ||
114 | + /** | ||
115 | + * 获取输入数据 支持默认值和过滤 | ||
116 | + * @param string $key 获取的变量名 | ||
117 | + * @param mixed $default 默认值 | ||
118 | + * @param string $filter 过滤方法 | ||
119 | + * @return mixed | ||
120 | + */ | ||
121 | + function input($key = '', $default = null, $filter = '') | ||
122 | + { | ||
123 | + if (0 === strpos($key, '?')) { | ||
124 | + $key = substr($key, 1); | ||
125 | + $has = true; | ||
126 | + } | ||
127 | + if ($pos = strpos($key, '.')) { | ||
128 | + // 指定参数来源 | ||
129 | + list($method, $key) = explode('.', $key, 2); | ||
130 | + if (!in_array($method, ['get', 'post', 'put', 'patch', 'delete', 'route', 'param', 'request', 'session', 'cookie', 'server', 'env', 'path', 'file'])) { | ||
131 | + $key = $method . '.' . $key; | ||
132 | + $method = 'param'; | ||
133 | + } | ||
134 | + } else { | ||
135 | + // 默认为自动判断 | ||
136 | + $method = 'param'; | ||
137 | + } | ||
138 | + if (isset($has)) { | ||
139 | + return request()->has($key, $method, $default); | ||
140 | + } else { | ||
141 | + return request()->$method($key, $default, $filter); | ||
142 | + } | ||
143 | + } | ||
144 | +} | ||
145 | + | ||
146 | +if (!function_exists('widget')) { | ||
147 | + /** | ||
148 | + * 渲染输出Widget | ||
149 | + * @param string $name Widget名称 | ||
150 | + * @param array $data 传入的参数 | ||
151 | + * @return mixed | ||
152 | + */ | ||
153 | + function widget($name, $data = []) | ||
154 | + { | ||
155 | + return Loader::action($name, $data, 'widget'); | ||
156 | + } | ||
157 | +} | ||
158 | + | ||
159 | +if (!function_exists('model')) { | ||
160 | + /** | ||
161 | + * 实例化Model | ||
162 | + * @param string $name Model名称 | ||
163 | + * @param string $layer 业务层名称 | ||
164 | + * @param bool $appendSuffix 是否添加类名后缀 | ||
165 | + * @return \think\Model | ||
166 | + */ | ||
167 | + function model($name = '', $layer = 'model', $appendSuffix = false) | ||
168 | + { | ||
169 | + return Loader::model($name, $layer, $appendSuffix); | ||
170 | + } | ||
171 | +} | ||
172 | + | ||
173 | +if (!function_exists('validate')) { | ||
174 | + /** | ||
175 | + * 实例化验证器 | ||
176 | + * @param string $name 验证器名称 | ||
177 | + * @param string $layer 业务层名称 | ||
178 | + * @param bool $appendSuffix 是否添加类名后缀 | ||
179 | + * @return \think\Validate | ||
180 | + */ | ||
181 | + function validate($name = '', $layer = 'validate', $appendSuffix = false) | ||
182 | + { | ||
183 | + return Loader::validate($name, $layer, $appendSuffix); | ||
184 | + } | ||
185 | +} | ||
186 | + | ||
187 | +if (!function_exists('db')) { | ||
188 | + /** | ||
189 | + * 实例化数据库类 | ||
190 | + * @param string $name 操作的数据表名称(不含前缀) | ||
191 | + * @param array|string $config 数据库配置参数 | ||
192 | + * @param bool $force 是否强制重新连接 | ||
193 | + * @return \think\db\Query | ||
194 | + */ | ||
195 | + function db($name = '', $config = [], $force = false) | ||
196 | + { | ||
197 | + return Db::connect($config, $force)->name($name); | ||
198 | + } | ||
199 | +} | ||
200 | + | ||
201 | +if (!function_exists('controller')) { | ||
202 | + /** | ||
203 | + * 实例化控制器 格式:[模块/]控制器 | ||
204 | + * @param string $name 资源地址 | ||
205 | + * @param string $layer 控制层名称 | ||
206 | + * @param bool $appendSuffix 是否添加类名后缀 | ||
207 | + * @return \think\Controller | ||
208 | + */ | ||
209 | + function controller($name, $layer = 'controller', $appendSuffix = false) | ||
210 | + { | ||
211 | + return Loader::controller($name, $layer, $appendSuffix); | ||
212 | + } | ||
213 | +} | ||
214 | + | ||
215 | +if (!function_exists('action')) { | ||
216 | + /** | ||
217 | + * 调用模块的操作方法 参数格式 [模块/控制器/]操作 | ||
218 | + * @param string $url 调用地址 | ||
219 | + * @param string|array $vars 调用参数 支持字符串和数组 | ||
220 | + * @param string $layer 要调用的控制层名称 | ||
221 | + * @param bool $appendSuffix 是否添加类名后缀 | ||
222 | + * @return mixed | ||
223 | + */ | ||
224 | + function action($url, $vars = [], $layer = 'controller', $appendSuffix = false) | ||
225 | + { | ||
226 | + return Loader::action($url, $vars, $layer, $appendSuffix); | ||
227 | + } | ||
228 | +} | ||
229 | + | ||
230 | +if (!function_exists('import')) { | ||
231 | + /** | ||
232 | + * 导入所需的类库 同java的Import 本函数有缓存功能 | ||
233 | + * @param string $class 类库命名空间字符串 | ||
234 | + * @param string $baseUrl 起始路径 | ||
235 | + * @param string $ext 导入的文件扩展名 | ||
236 | + * @return boolean | ||
237 | + */ | ||
238 | + function import($class, $baseUrl = '', $ext = EXT) | ||
239 | + { | ||
240 | + return Loader::import($class, $baseUrl, $ext); | ||
241 | + } | ||
242 | +} | ||
243 | + | ||
244 | +if (!function_exists('vendor')) { | ||
245 | + /** | ||
246 | + * 快速导入第三方框架类库 所有第三方框架的类库文件统一放到 系统的Vendor目录下面 | ||
247 | + * @param string $class 类库 | ||
248 | + * @param string $ext 类库后缀 | ||
249 | + * @return boolean | ||
250 | + */ | ||
251 | + function vendor($class, $ext = EXT) | ||
252 | + { | ||
253 | + return Loader::import($class, VENDOR_PATH, $ext); | ||
254 | + } | ||
255 | +} | ||
256 | + | ||
257 | +if (!function_exists('dump')) { | ||
258 | + /** | ||
259 | + * 浏览器友好的变量输出 | ||
260 | + * @param mixed $var 变量 | ||
261 | + * @param boolean $echo 是否输出 默认为true 如果为false 则返回输出字符串 | ||
262 | + * @param string $label 标签 默认为空 | ||
263 | + * @return void|string | ||
264 | + */ | ||
265 | + function dump($var, $echo = true, $label = null) | ||
266 | + { | ||
267 | + return Debug::dump($var, $echo, $label); | ||
268 | + } | ||
269 | +} | ||
270 | + | ||
271 | +if (!function_exists('url')) { | ||
272 | + /** | ||
273 | + * Url生成 | ||
274 | + * @param string $url 路由地址 | ||
275 | + * @param string|array $vars 变量 | ||
276 | + * @param bool|string $suffix 生成的URL后缀 | ||
277 | + * @param bool|string $domain 域名 | ||
278 | + * @return string | ||
279 | + */ | ||
280 | + function url($url = '', $vars = '', $suffix = true, $domain = false) | ||
281 | + { | ||
282 | + return Url::build($url, $vars, $suffix, $domain); | ||
283 | + } | ||
284 | +} | ||
285 | + | ||
286 | +if (!function_exists('session')) { | ||
287 | + /** | ||
288 | + * Session管理 | ||
289 | + * @param string|array $name session名称,如果为数组表示进行session设置 | ||
290 | + * @param mixed $value session值 | ||
291 | + * @param string $prefix 前缀 | ||
292 | + * @return mixed | ||
293 | + */ | ||
294 | + function session($name, $value = '', $prefix = null) | ||
295 | + { | ||
296 | + if (is_array($name)) { | ||
297 | + // 初始化 | ||
298 | + Session::init($name); | ||
299 | + } elseif (is_null($name)) { | ||
300 | + // 清除 | ||
301 | + Session::clear('' === $value ? null : $value); | ||
302 | + } elseif ('' === $value) { | ||
303 | + // 判断或获取 | ||
304 | + return 0 === strpos($name, '?') ? Session::has(substr($name, 1), $prefix) : Session::get($name, $prefix); | ||
305 | + } elseif (is_null($value)) { | ||
306 | + // 删除 | ||
307 | + return Session::delete($name, $prefix); | ||
308 | + } else { | ||
309 | + // 设置 | ||
310 | + return Session::set($name, $value, $prefix); | ||
311 | + } | ||
312 | + } | ||
313 | +} | ||
314 | + | ||
315 | +if (!function_exists('cookie')) { | ||
316 | + /** | ||
317 | + * Cookie管理 | ||
318 | + * @param string|array $name cookie名称,如果为数组表示进行cookie设置 | ||
319 | + * @param mixed $value cookie值 | ||
320 | + * @param mixed $option 参数 | ||
321 | + * @return mixed | ||
322 | + */ | ||
323 | + function cookie($name, $value = '', $option = null) | ||
324 | + { | ||
325 | + if (is_array($name)) { | ||
326 | + // 初始化 | ||
327 | + Cookie::init($name); | ||
328 | + } elseif (is_null($name)) { | ||
329 | + // 清除 | ||
330 | + Cookie::clear($value); | ||
331 | + } elseif ('' === $value) { | ||
332 | + // 获取 | ||
333 | + return 0 === strpos($name, '?') ? Cookie::has(substr($name, 1), $option) : Cookie::get($name, $option); | ||
334 | + } elseif (is_null($value)) { | ||
335 | + // 删除 | ||
336 | + return Cookie::delete($name); | ||
337 | + } else { | ||
338 | + // 设置 | ||
339 | + return Cookie::set($name, $value, $option); | ||
340 | + } | ||
341 | + } | ||
342 | +} | ||
343 | + | ||
344 | +if (!function_exists('cache')) { | ||
345 | + /** | ||
346 | + * 缓存管理 | ||
347 | + * @param mixed $name 缓存名称,如果为数组表示进行缓存设置 | ||
348 | + * @param mixed $value 缓存值 | ||
349 | + * @param mixed $options 缓存参数 | ||
350 | + * @param string $tag 缓存标签 | ||
351 | + * @return mixed | ||
352 | + */ | ||
353 | + function cache($name, $value = '', $options = null, $tag = null) | ||
354 | + { | ||
355 | + if (is_array($options)) { | ||
356 | + // 缓存操作的同时初始化 | ||
357 | + $cache = Cache::connect($options); | ||
358 | + } elseif (is_array($name)) { | ||
359 | + // 缓存初始化 | ||
360 | + return Cache::connect($name); | ||
361 | + } else { | ||
362 | + $cache = Cache::init(); | ||
363 | + } | ||
364 | + | ||
365 | + if (is_null($name)) { | ||
366 | + return $cache->clear($value); | ||
367 | + } elseif ('' === $value) { | ||
368 | + // 获取缓存 | ||
369 | + return 0 === strpos($name, '?') ? $cache->has(substr($name, 1)) : $cache->get($name); | ||
370 | + } elseif (is_null($value)) { | ||
371 | + // 删除缓存 | ||
372 | + return $cache->rm($name); | ||
373 | + } elseif (0 === strpos($name, '?') && '' !== $value) { | ||
374 | + $expire = is_numeric($options) ? $options : null; | ||
375 | + return $cache->remember(substr($name, 1), $value, $expire); | ||
376 | + } else { | ||
377 | + // 缓存数据 | ||
378 | + if (is_array($options)) { | ||
379 | + $expire = isset($options['expire']) ? $options['expire'] : null; //修复查询缓存无法设置过期时间 | ||
380 | + } else { | ||
381 | + $expire = is_numeric($options) ? $options : null; //默认快捷缓存设置过期时间 | ||
382 | + } | ||
383 | + if (is_null($tag)) { | ||
384 | + return $cache->set($name, $value, $expire); | ||
385 | + } else { | ||
386 | + return $cache->tag($tag)->set($name, $value, $expire); | ||
387 | + } | ||
388 | + } | ||
389 | + } | ||
390 | +} | ||
391 | + | ||
392 | +if (!function_exists('trace')) { | ||
393 | + /** | ||
394 | + * 记录日志信息 | ||
395 | + * @param mixed $log log信息 支持字符串和数组 | ||
396 | + * @param string $level 日志级别 | ||
397 | + * @return void|array | ||
398 | + */ | ||
399 | + function trace($log = '[think]', $level = 'log') | ||
400 | + { | ||
401 | + if ('[think]' === $log) { | ||
402 | + return Log::getLog(); | ||
403 | + } else { | ||
404 | + Log::record($log, $level); | ||
405 | + } | ||
406 | + } | ||
407 | +} | ||
408 | + | ||
409 | +if (!function_exists('request')) { | ||
410 | + /** | ||
411 | + * 获取当前Request对象实例 | ||
412 | + * @return Request | ||
413 | + */ | ||
414 | + function request() | ||
415 | + { | ||
416 | + return Request::instance(); | ||
417 | + } | ||
418 | +} | ||
419 | + | ||
420 | +if (!function_exists('response')) { | ||
421 | + /** | ||
422 | + * 创建普通 Response 对象实例 | ||
423 | + * @param mixed $data 输出数据 | ||
424 | + * @param int|string $code 状态码 | ||
425 | + * @param array $header 头信息 | ||
426 | + * @param string $type | ||
427 | + * @return Response | ||
428 | + */ | ||
429 | + function response($data = [], $code = 200, $header = [], $type = 'html') | ||
430 | + { | ||
431 | + return Response::create($data, $type, $code, $header); | ||
432 | + } | ||
433 | +} | ||
434 | + | ||
435 | +if (!function_exists('view')) { | ||
436 | + /** | ||
437 | + * 渲染模板输出 | ||
438 | + * @param string $template 模板文件 | ||
439 | + * @param array $vars 模板变量 | ||
440 | + * @param array $replace 模板替换 | ||
441 | + * @param integer $code 状态码 | ||
442 | + * @return \think\response\View | ||
443 | + */ | ||
444 | + function view($template = '', $vars = [], $replace = [], $code = 200) | ||
445 | + { | ||
446 | + return Response::create($template, 'view', $code)->replace($replace)->assign($vars); | ||
447 | + } | ||
448 | +} | ||
449 | + | ||
450 | +if (!function_exists('json')) { | ||
451 | + /** | ||
452 | + * 获取\think\response\Json对象实例 | ||
453 | + * @param mixed $data 返回的数据 | ||
454 | + * @param integer $code 状态码 | ||
455 | + * @param array $header 头部 | ||
456 | + * @param array $options 参数 | ||
457 | + * @return \think\response\Json | ||
458 | + */ | ||
459 | + function json($data = [], $code = 200, $header = [], $options = []) | ||
460 | + { | ||
461 | + return Response::create($data, 'json', $code, $header, $options); | ||
462 | + } | ||
463 | +} | ||
464 | + | ||
465 | +if (!function_exists('jsonp')) { | ||
466 | + /** | ||
467 | + * 获取\think\response\Jsonp对象实例 | ||
468 | + * @param mixed $data 返回的数据 | ||
469 | + * @param integer $code 状态码 | ||
470 | + * @param array $header 头部 | ||
471 | + * @param array $options 参数 | ||
472 | + * @return \think\response\Jsonp | ||
473 | + */ | ||
474 | + function jsonp($data = [], $code = 200, $header = [], $options = []) | ||
475 | + { | ||
476 | + return Response::create($data, 'jsonp', $code, $header, $options); | ||
477 | + } | ||
478 | +} | ||
479 | + | ||
480 | +if (!function_exists('xml')) { | ||
481 | + /** | ||
482 | + * 获取\think\response\Xml对象实例 | ||
483 | + * @param mixed $data 返回的数据 | ||
484 | + * @param integer $code 状态码 | ||
485 | + * @param array $header 头部 | ||
486 | + * @param array $options 参数 | ||
487 | + * @return \think\response\Xml | ||
488 | + */ | ||
489 | + function xml($data = [], $code = 200, $header = [], $options = []) | ||
490 | + { | ||
491 | + return Response::create($data, 'xml', $code, $header, $options); | ||
492 | + } | ||
493 | +} | ||
494 | + | ||
495 | +if (!function_exists('redirect')) { | ||
496 | + /** | ||
497 | + * 获取\think\response\Redirect对象实例 | ||
498 | + * @param mixed $url 重定向地址 支持Url::build方法的地址 | ||
499 | + * @param array|integer $params 额外参数 | ||
500 | + * @param integer $code 状态码 | ||
501 | + * @param array $with 隐式传参 | ||
502 | + * @return \think\response\Redirect | ||
503 | + */ | ||
504 | + function redirect($url = [], $params = [], $code = 302, $with = []) | ||
505 | + { | ||
506 | + if (is_integer($params)) { | ||
507 | + $code = $params; | ||
508 | + $params = []; | ||
509 | + } | ||
510 | + return Response::create($url, 'redirect', $code)->params($params)->with($with); | ||
511 | + } | ||
512 | +} | ||
513 | + | ||
514 | +if (!function_exists('abort')) { | ||
515 | + /** | ||
516 | + * 抛出HTTP异常 | ||
517 | + * @param integer|Response $code 状态码 或者 Response对象实例 | ||
518 | + * @param string $message 错误信息 | ||
519 | + * @param array $header 参数 | ||
520 | + */ | ||
521 | + function abort($code, $message = null, $header = []) | ||
522 | + { | ||
523 | + if ($code instanceof Response) { | ||
524 | + throw new HttpResponseException($code); | ||
525 | + } else { | ||
526 | + throw new HttpException($code, $message, null, $header); | ||
527 | + } | ||
528 | + } | ||
529 | +} | ||
530 | + | ||
531 | +if (!function_exists('halt')) { | ||
532 | + /** | ||
533 | + * 调试变量并且中断输出 | ||
534 | + * @param mixed $var 调试变量或者信息 | ||
535 | + */ | ||
536 | + function halt($var) | ||
537 | + { | ||
538 | + dump($var); | ||
539 | + throw new HttpResponseException(new Response); | ||
540 | + } | ||
541 | +} | ||
542 | + | ||
543 | +if (!function_exists('token')) { | ||
544 | + /** | ||
545 | + * 生成表单令牌 | ||
546 | + * @param string $name 令牌名称 | ||
547 | + * @param mixed $type 令牌生成方法 | ||
548 | + * @return string | ||
549 | + */ | ||
550 | + function token($name = '__token__', $type = 'md5') | ||
551 | + { | ||
552 | + $token = Request::instance()->token($name, $type); | ||
553 | + return '<input type="hidden" name="' . $name . '" value="' . $token . '" />'; | ||
554 | + } | ||
555 | +} | ||
556 | + | ||
557 | +if (!function_exists('load_relation')) { | ||
558 | + /** | ||
559 | + * 延迟预载入关联查询 | ||
560 | + * @param mixed $resultSet 数据集 | ||
561 | + * @param mixed $relation 关联 | ||
562 | + * @return array | ||
563 | + */ | ||
564 | + function load_relation($resultSet, $relation) | ||
565 | + { | ||
566 | + $item = current($resultSet); | ||
567 | + if ($item instanceof Model) { | ||
568 | + $item->eagerlyResultSet($resultSet, $relation); | ||
569 | + } | ||
570 | + return $resultSet; | ||
571 | + } | ||
572 | +} | ||
573 | + | ||
574 | +if (!function_exists('collection')) { | ||
575 | + /** | ||
576 | + * 数组转换为数据集对象 | ||
577 | + * @param array $resultSet 数据集数组 | ||
578 | + * @return \think\model\Collection|\think\Collection | ||
579 | + */ | ||
580 | + function collection($resultSet) | ||
581 | + { | ||
582 | + $item = current($resultSet); | ||
583 | + if ($item instanceof Model) { | ||
584 | + return \think\model\Collection::make($resultSet); | ||
585 | + } else { | ||
586 | + return \think\Collection::make($resultSet); | ||
587 | + } | ||
588 | + } | ||
589 | +} |
1 | -<?php | ||
2 | -// +---------------------------------------------------------------------- | ||
3 | -// | ThinkPHP [ WE CAN DO IT JUST THINK ] | ||
4 | -// +---------------------------------------------------------------------- | ||
5 | -// | Copyright (c) 2006~2018 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 | - 'Undefined variable' => '未定义变量', | ||
16 | - 'Undefined index' => '未定义数组索引', | ||
17 | - 'Undefined offset' => '未定义数组下标', | ||
18 | - 'Parse error' => '语法解析错误', | ||
19 | - 'Type error' => '类型错误', | ||
20 | - 'Fatal error' => '致命错误', | ||
21 | - 'syntax error' => '语法错误', | ||
22 | - | ||
23 | - // 框架核心错误提示 | ||
24 | - 'dispatch type not support' => '不支持的调度类型', | ||
25 | - 'method param miss' => '方法参数错误', | ||
26 | - 'method not exists' => '方法不存在', | ||
27 | - 'module not exists' => '模块不存在', | ||
28 | - 'controller not exists' => '控制器不存在', | ||
29 | - 'class not exists' => '类不存在', | ||
30 | - 'property not exists' => '类的属性不存在', | ||
31 | - 'template not exists' => '模板文件不存在', | ||
32 | - 'illegal controller name' => '非法的控制器名称', | ||
33 | - 'illegal action name' => '非法的操作名称', | ||
34 | - 'url suffix deny' => '禁止的URL后缀访问', | ||
35 | - 'Route Not Found' => '当前访问路由未定义', | ||
36 | - 'Undefined db type' => '未定义数据库类型', | ||
37 | - 'variable type error' => '变量类型错误', | ||
38 | - 'PSR-4 error' => 'PSR-4 规范错误', | ||
39 | - 'not support total' => '简洁模式下不能获取数据总数', | ||
40 | - 'not support last' => '简洁模式下不能获取最后一页', | ||
41 | - 'error session handler' => '错误的SESSION处理器类', | ||
42 | - 'not allow php tag' => '模板不允许使用PHP语法', | ||
43 | - 'not support' => '不支持', | ||
44 | - 'redisd master' => 'Redisd 主服务器错误', | ||
45 | - 'redisd slave' => 'Redisd 从服务器错误', | ||
46 | - 'must run at sae' => '必须在SAE运行', | ||
47 | - 'memcache init error' => '未开通Memcache服务,请在SAE管理平台初始化Memcache服务', | ||
48 | - 'KVDB init error' => '没有初始化KVDB,请在SAE管理平台初始化KVDB服务', | ||
49 | - 'fields not exists' => '数据表字段不存在', | ||
50 | - 'where express error' => '查询表达式错误', | ||
51 | - 'not support data' => '不支持的数据表达式', | ||
52 | - 'no data to update' => '没有任何数据需要更新', | ||
53 | - 'miss data to insert' => '缺少需要写入的数据', | ||
54 | - 'miss complex primary data' => '缺少复合主键数据', | ||
55 | - 'miss update condition' => '缺少更新条件', | ||
56 | - 'model data Not Found' => '模型数据不存在', | ||
57 | - 'table data not Found' => '表数据不存在', | ||
58 | - 'delete without condition' => '没有条件不会执行删除操作', | ||
59 | - 'miss relation data' => '缺少关联表数据', | ||
60 | - 'tag attr must' => '模板标签属性必须', | ||
61 | - 'tag error' => '模板标签错误', | ||
62 | - 'cache write error' => '缓存写入失败', | ||
63 | - 'sae mc write error' => 'SAE mc 写入错误', | ||
64 | - 'route name not exists' => '路由标识不存在(或参数不够)', | ||
65 | - 'invalid request' => '非法请求', | ||
66 | - 'bind attr has exists' => '模型的属性已经存在', | ||
67 | - 'relation data not exists' => '关联数据不存在', | ||
68 | - 'relation not support' => '关联不支持', | ||
69 | - 'chunk not support order' => 'Chunk不支持调用order方法', | ||
70 | - 'closure not support cache(true)' => '使用闭包查询不支持cache(true),请指定缓存Key', | ||
71 | - | ||
72 | - // 上传错误信息 | ||
73 | - 'unknown upload error' => '未知上传错误!', | ||
74 | - 'file write error' => '文件写入失败!', | ||
75 | - 'upload temp dir not found' => '找不到临时文件夹!', | ||
76 | - 'no file to uploaded' => '没有文件被上传!', | ||
77 | - 'only the portion of file is uploaded' => '文件只有部分被上传!', | ||
78 | - 'upload File size exceeds the maximum value' => '上传文件大小超过了最大值!', | ||
79 | - 'upload write error' => '文件上传保存错误!', | ||
80 | - 'has the same filename: {:filename}' => '存在同名文件:{:filename}', | ||
81 | - 'upload illegal files' => '非法上传文件', | ||
82 | - 'illegal image files' => '非法图片文件', | ||
83 | - 'extensions to upload is not allowed' => '上传文件后缀不允许', | ||
84 | - 'mimetype to upload is not allowed' => '上传文件MIME类型不允许!', | ||
85 | - 'filesize not match' => '上传文件大小不符!', | ||
86 | - 'directory {:path} creation failed' => '目录 {:path} 创建失败!', | ||
87 | - | ||
88 | - // Validate Error Message | ||
89 | - ':attribute require' => ':attribute不能为空', | ||
90 | - ':attribute must be numeric' => ':attribute必须是数字', | ||
91 | - ':attribute must be integer' => ':attribute必须是整数', | ||
92 | - ':attribute must be float' => ':attribute必须是浮点数', | ||
93 | - ':attribute must be bool' => ':attribute必须是布尔值', | ||
94 | - ':attribute not a valid email address' => ':attribute格式不符', | ||
95 | - ':attribute not a valid mobile' => ':attribute格式不符', | ||
96 | - ':attribute must be a array' => ':attribute必须是数组', | ||
97 | - ':attribute must be yes,on or 1' => ':attribute必须是yes、on或者1', | ||
98 | - ':attribute not a valid datetime' => ':attribute不是一个有效的日期或时间格式', | ||
99 | - ':attribute not a valid file' => ':attribute不是有效的上传文件', | ||
100 | - ':attribute not a valid image' => ':attribute不是有效的图像文件', | ||
101 | - ':attribute must be alpha' => ':attribute只能是字母', | ||
102 | - ':attribute must be alpha-numeric' => ':attribute只能是字母和数字', | ||
103 | - ':attribute must be alpha-numeric, dash, underscore' => ':attribute只能是字母、数字和下划线_及破折号-', | ||
104 | - ':attribute not a valid domain or ip' => ':attribute不是有效的域名或者IP', | ||
105 | - ':attribute must be chinese' => ':attribute只能是汉字', | ||
106 | - ':attribute must be chinese or alpha' => ':attribute只能是汉字、字母', | ||
107 | - ':attribute must be chinese,alpha-numeric' => ':attribute只能是汉字、字母和数字', | ||
108 | - ':attribute must be chinese,alpha-numeric,underscore, dash' => ':attribute只能是汉字、字母、数字和下划线_及破折号-', | ||
109 | - ':attribute not a valid url' => ':attribute不是有效的URL地址', | ||
110 | - ':attribute not a valid ip' => ':attribute不是有效的IP地址', | ||
111 | - ':attribute must be dateFormat of :rule' => ':attribute必须使用日期格式 :rule', | ||
112 | - ':attribute must be in :rule' => ':attribute必须在 :rule 范围内', | ||
113 | - ':attribute be notin :rule' => ':attribute不能在 :rule 范围内', | ||
114 | - ':attribute must between :1 - :2' => ':attribute只能在 :1 - :2 之间', | ||
115 | - ':attribute not between :1 - :2' => ':attribute不能在 :1 - :2 之间', | ||
116 | - 'size of :attribute must be :rule' => ':attribute长度不符合要求 :rule', | ||
117 | - 'max size of :attribute must be :rule' => ':attribute长度不能超过 :rule', | ||
118 | - 'min size of :attribute must be :rule' => ':attribute长度不能小于 :rule', | ||
119 | - ':attribute cannot be less than :rule' => ':attribute日期不能小于 :rule', | ||
120 | - ':attribute cannot exceed :rule' => ':attribute日期不能超过 :rule', | ||
121 | - ':attribute not within :rule' => '不在有效期内 :rule', | ||
122 | - 'access IP is not allowed' => '不允许的IP访问', | ||
123 | - 'access IP denied' => '禁止的IP访问', | ||
124 | - ':attribute out of accord with :2' => ':attribute和确认字段:2不一致', | ||
125 | - ':attribute cannot be same with :2' => ':attribute和比较字段:2不能相同', | ||
126 | - ':attribute must greater than or equal :rule' => ':attribute必须大于等于 :rule', | ||
127 | - ':attribute must greater than :rule' => ':attribute必须大于 :rule', | ||
128 | - ':attribute must less than or equal :rule' => ':attribute必须小于等于 :rule', | ||
129 | - ':attribute must less than :rule' => ':attribute必须小于 :rule', | ||
130 | - ':attribute must equal :rule' => ':attribute必须等于 :rule', | ||
131 | - ':attribute has exists' => ':attribute已存在', | ||
132 | - ':attribute not conform to the rules' => ':attribute不符合指定规则', | ||
133 | - 'invalid Request method' => '无效的请求类型', | ||
134 | - 'invalid token' => '令牌数据无效', | ||
135 | - 'not conform to the rules' => '规则错误', | ||
136 | -]; | 1 | +<?php |
2 | +// +---------------------------------------------------------------------- | ||
3 | +// | ThinkPHP [ WE CAN DO IT JUST THINK ] | ||
4 | +// +---------------------------------------------------------------------- | ||
5 | +// | Copyright (c) 2006~2018 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 | + 'Undefined variable' => '未定义变量', | ||
16 | + 'Undefined index' => '未定义数组索引', | ||
17 | + 'Undefined offset' => '未定义数组下标', | ||
18 | + 'Parse error' => '语法解析错误', | ||
19 | + 'Type error' => '类型错误', | ||
20 | + 'Fatal error' => '致命错误', | ||
21 | + 'syntax error' => '语法错误', | ||
22 | + | ||
23 | + // 框架核心错误提示 | ||
24 | + 'dispatch type not support' => '不支持的调度类型', | ||
25 | + 'method param miss' => '方法参数错误', | ||
26 | + 'method not exists' => '方法不存在', | ||
27 | + 'module not exists' => '模块不存在', | ||
28 | + 'controller not exists' => '控制器不存在', | ||
29 | + 'class not exists' => '类不存在', | ||
30 | + 'property not exists' => '类的属性不存在', | ||
31 | + 'template not exists' => '模板文件不存在', | ||
32 | + 'illegal controller name' => '非法的控制器名称', | ||
33 | + 'illegal action name' => '非法的操作名称', | ||
34 | + 'url suffix deny' => '禁止的URL后缀访问', | ||
35 | + 'Route Not Found' => '当前访问路由未定义', | ||
36 | + 'Undefined db type' => '未定义数据库类型', | ||
37 | + 'variable type error' => '变量类型错误', | ||
38 | + 'PSR-4 error' => 'PSR-4 规范错误', | ||
39 | + 'not support total' => '简洁模式下不能获取数据总数', | ||
40 | + 'not support last' => '简洁模式下不能获取最后一页', | ||
41 | + 'error session handler' => '错误的SESSION处理器类', | ||
42 | + 'not allow php tag' => '模板不允许使用PHP语法', | ||
43 | + 'not support' => '不支持', | ||
44 | + 'redisd master' => 'Redisd 主服务器错误', | ||
45 | + 'redisd slave' => 'Redisd 从服务器错误', | ||
46 | + 'must run at sae' => '必须在SAE运行', | ||
47 | + 'memcache init error' => '未开通Memcache服务,请在SAE管理平台初始化Memcache服务', | ||
48 | + 'KVDB init error' => '没有初始化KVDB,请在SAE管理平台初始化KVDB服务', | ||
49 | + 'fields not exists' => '数据表字段不存在', | ||
50 | + 'where express error' => '查询表达式错误', | ||
51 | + 'not support data' => '不支持的数据表达式', | ||
52 | + 'no data to update' => '没有任何数据需要更新', | ||
53 | + 'miss data to insert' => '缺少需要写入的数据', | ||
54 | + 'miss complex primary data' => '缺少复合主键数据', | ||
55 | + 'miss update condition' => '缺少更新条件', | ||
56 | + 'model data Not Found' => '模型数据不存在', | ||
57 | + 'table data not Found' => '表数据不存在', | ||
58 | + 'delete without condition' => '没有条件不会执行删除操作', | ||
59 | + 'miss relation data' => '缺少关联表数据', | ||
60 | + 'tag attr must' => '模板标签属性必须', | ||
61 | + 'tag error' => '模板标签错误', | ||
62 | + 'cache write error' => '缓存写入失败', | ||
63 | + 'sae mc write error' => 'SAE mc 写入错误', | ||
64 | + 'route name not exists' => '路由标识不存在(或参数不够)', | ||
65 | + 'invalid request' => '非法请求', | ||
66 | + 'bind attr has exists' => '模型的属性已经存在', | ||
67 | + 'relation data not exists' => '关联数据不存在', | ||
68 | + 'relation not support' => '关联不支持', | ||
69 | + 'chunk not support order' => 'Chunk不支持调用order方法', | ||
70 | + 'closure not support cache(true)' => '使用闭包查询不支持cache(true),请指定缓存Key', | ||
71 | + | ||
72 | + // 上传错误信息 | ||
73 | + 'unknown upload error' => '未知上传错误!', | ||
74 | + 'file write error' => '文件写入失败!', | ||
75 | + 'upload temp dir not found' => '找不到临时文件夹!', | ||
76 | + 'no file to uploaded' => '没有文件被上传!', | ||
77 | + 'only the portion of file is uploaded' => '文件只有部分被上传!', | ||
78 | + 'upload File size exceeds the maximum value' => '上传文件大小超过了最大值!', | ||
79 | + 'upload write error' => '文件上传保存错误!', | ||
80 | + 'has the same filename: {:filename}' => '存在同名文件:{:filename}', | ||
81 | + 'upload illegal files' => '非法上传文件', | ||
82 | + 'illegal image files' => '非法图片文件', | ||
83 | + 'extensions to upload is not allowed' => '上传文件后缀不允许', | ||
84 | + 'mimetype to upload is not allowed' => '上传文件MIME类型不允许!', | ||
85 | + 'filesize not match' => '上传文件大小不符!', | ||
86 | + 'directory {:path} creation failed' => '目录 {:path} 创建失败!', | ||
87 | + | ||
88 | + // Validate Error Message | ||
89 | + ':attribute require' => ':attribute不能为空', | ||
90 | + ':attribute must be numeric' => ':attribute必须是数字', | ||
91 | + ':attribute must be integer' => ':attribute必须是整数', | ||
92 | + ':attribute must be float' => ':attribute必须是浮点数', | ||
93 | + ':attribute must be bool' => ':attribute必须是布尔值', | ||
94 | + ':attribute not a valid email address' => ':attribute格式不符', | ||
95 | + ':attribute not a valid mobile' => ':attribute格式不符', | ||
96 | + ':attribute must be a array' => ':attribute必须是数组', | ||
97 | + ':attribute must be yes,on or 1' => ':attribute必须是yes、on或者1', | ||
98 | + ':attribute not a valid datetime' => ':attribute不是一个有效的日期或时间格式', | ||
99 | + ':attribute not a valid file' => ':attribute不是有效的上传文件', | ||
100 | + ':attribute not a valid image' => ':attribute不是有效的图像文件', | ||
101 | + ':attribute must be alpha' => ':attribute只能是字母', | ||
102 | + ':attribute must be alpha-numeric' => ':attribute只能是字母和数字', | ||
103 | + ':attribute must be alpha-numeric, dash, underscore' => ':attribute只能是字母、数字和下划线_及破折号-', | ||
104 | + ':attribute not a valid domain or ip' => ':attribute不是有效的域名或者IP', | ||
105 | + ':attribute must be chinese' => ':attribute只能是汉字', | ||
106 | + ':attribute must be chinese or alpha' => ':attribute只能是汉字、字母', | ||
107 | + ':attribute must be chinese,alpha-numeric' => ':attribute只能是汉字、字母和数字', | ||
108 | + ':attribute must be chinese,alpha-numeric,underscore, dash' => ':attribute只能是汉字、字母、数字和下划线_及破折号-', | ||
109 | + ':attribute not a valid url' => ':attribute不是有效的URL地址', | ||
110 | + ':attribute not a valid ip' => ':attribute不是有效的IP地址', | ||
111 | + ':attribute must be dateFormat of :rule' => ':attribute必须使用日期格式 :rule', | ||
112 | + ':attribute must be in :rule' => ':attribute必须在 :rule 范围内', | ||
113 | + ':attribute be notin :rule' => ':attribute不能在 :rule 范围内', | ||
114 | + ':attribute must between :1 - :2' => ':attribute只能在 :1 - :2 之间', | ||
115 | + ':attribute not between :1 - :2' => ':attribute不能在 :1 - :2 之间', | ||
116 | + 'size of :attribute must be :rule' => ':attribute长度不符合要求 :rule', | ||
117 | + 'max size of :attribute must be :rule' => ':attribute长度不能超过 :rule', | ||
118 | + 'min size of :attribute must be :rule' => ':attribute长度不能小于 :rule', | ||
119 | + ':attribute cannot be less than :rule' => ':attribute日期不能小于 :rule', | ||
120 | + ':attribute cannot exceed :rule' => ':attribute日期不能超过 :rule', | ||
121 | + ':attribute not within :rule' => '不在有效期内 :rule', | ||
122 | + 'access IP is not allowed' => '不允许的IP访问', | ||
123 | + 'access IP denied' => '禁止的IP访问', | ||
124 | + ':attribute out of accord with :2' => ':attribute和确认字段:2不一致', | ||
125 | + ':attribute cannot be same with :2' => ':attribute和比较字段:2不能相同', | ||
126 | + ':attribute must greater than or equal :rule' => ':attribute必须大于等于 :rule', | ||
127 | + ':attribute must greater than :rule' => ':attribute必须大于 :rule', | ||
128 | + ':attribute must less than or equal :rule' => ':attribute必须小于等于 :rule', | ||
129 | + ':attribute must less than :rule' => ':attribute必须小于 :rule', | ||
130 | + ':attribute must equal :rule' => ':attribute必须等于 :rule', | ||
131 | + ':attribute has exists' => ':attribute已存在', | ||
132 | + ':attribute not conform to the rules' => ':attribute不符合指定规则', | ||
133 | + 'invalid Request method' => '无效的请求类型', | ||
134 | + 'invalid token' => '令牌数据无效', | ||
135 | + 'not conform to the rules' => '规则错误', | ||
136 | +]; |
-
请 注册 或 登录 后发表评论