diff --git a/application/admin/controller/AuthGroup.php b/application/admin/controller/AuthGroup.php index 93bf855a..dfec60b3 100644 --- a/application/admin/controller/AuthGroup.php +++ b/application/admin/controller/AuthGroup.php @@ -5,18 +5,17 @@ namespace app\admin\controller; // 引用控制器基类 use app\common\controller\Base; // 引用角色数据模型类 -use app\admin\model\AuthGroup as agmod; +use app\admin\model\AuthGroup as AG; + class AuthGroup extends Base { // 角色列表 public function index() { - // 实例化角色数据模型类 - $agmod = new agmod(); // 设置数据总数 - $list['count'] = $agmod->count(); + $list['count'] = AG::count(); // 设置页面标题 $list['title'] = '角色列表'; @@ -33,8 +32,6 @@ class AuthGroup extends Base // 获取角色列表 public function ajaxData() { - // 实例化角色数据模型类 - $agmod = new agmod(); // 获取DT的传值 $getdt = request()->param(); @@ -53,10 +50,9 @@ class AuthGroup extends Base // 获取记录集总数 - $cnt = $agmod->count(); + $cnt = AG::count(); //查询数据 - $data = $agmod - ->field('id,title,miaoshu,status') + $data = AG::field('id,title,miaoshu,status') ->order([$order_field=>$order]) ->limit($limit_start,$limit_length) ->all(); @@ -64,8 +60,7 @@ class AuthGroup extends Base // 如果需要查询 if($search){ - $data = $agmod - ->field('id,title,miaoshu,status') + $data = AG::field('id,title,miaoshu,status') ->order([$order_field=>$order]) ->limit($limit_start,$limit_length) ->where('title|miaoshu','like','%'.$search.'%') @@ -107,8 +102,6 @@ class AuthGroup extends Base // 保存角色信息 public function save() { - // 实例化角色数据模型类 - $agmod = new agmod(); // 实例化验证模型 $validate = new \app\admin\validate\RuleGroup; @@ -130,7 +123,7 @@ class AuthGroup extends Base } // 保存数据 - $data = $agmod->save($list); + $data = AG::create($list); $msg = array(); @@ -162,8 +155,7 @@ class AuthGroup extends Base $agmod = new agmod(); // 获取角色信息 - $list = $agmod - ->field('id,title,miaoshu,rules') + $list = AG::field('id,title,miaoshu,rules') ->get($id); $list->rules = explode(',',$list->rules); @@ -180,8 +172,7 @@ class AuthGroup extends Base // 更新角色信息 public function update($id) { - // 实例化角色数据模型类 - $agmod = new agmod(); + // 实例化验证模型 $validate = new \app\admin\validate\RuleGroup; @@ -199,7 +190,7 @@ class AuthGroup extends Base } - $data = $agmod->save($list,['id'=>$id]); + $data = $agmod->where('id',$id)->update($list); // 根据更新结果设置返回提示信息 $data ? $data=['msg'=>'更新成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; @@ -214,15 +205,13 @@ class AuthGroup extends Base // 删除角色 public function delete($id) { - //实例化角色数据模型类 - $agmod = new agmod(); if($id == 'm') { $id = request()->delete('ids/a');// 获取delete请求方式传送过来的数据并转换成数据 } - $data = $agmod->destroy($id); + $data = AG::destroy($id); // 根据更新结果设置返回提示信息 $data ? $data=['msg'=>'删除成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; @@ -236,21 +225,13 @@ class AuthGroup extends Base // 设置角色状态 public function setStatus() { - // 实例化角色数据模型类 - $agmod = new agmod(); // 获取id变量 $id = request()->post('id'); $value = request()->post('value'); - // 获取角色信息 - $list = $agmod->get($id); - - // 修改状态值 - $list->status = $value; - // 更新数据 - $data = $list->save(); + $data= AG::where('id',$id)->update(['status'=>$value]); // 根据更新结果设置返回提示信息 $data ? $data=['msg'=>'状态设置成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; diff --git a/application/admin/controller/AuthGroupAccess.php b/application/admin/controller/AuthGroupAccess.php index eb390a87..c5649fb7 100644 --- a/application/admin/controller/AuthGroupAccess.php +++ b/application/admin/controller/AuthGroupAccess.php @@ -4,82 +4,14 @@ namespace app\admin\controller; // 引用控制器基类 use app\common\controller\Base; +// 引用用户权限关联数据模型 +use app\admin\model\AuthGroupAccess as AGA; +// 引用用户组数据模型 +use app\admin\model\AuthGroup as AG; +// 引用用户数据模型 +use app\admin\model\Admin as AD; class AuthGroupAccess extends Base { - /** - * 显示资源列表 - * - * @return \think\Response - */ - public function index() - { - // - } - /** - * 显示创建资源表单页. - * - * @return \think\Response - */ - public function create() - { - // - } - - /** - * 保存新建的资源 - * - * @param \think\Request $request - * @return \think\Response - */ - public function save(Request $request) - { - // - } - - /** - * 显示指定的资源 - * - * @param int $id - * @return \think\Response - */ - public function read($id) - { - // - } - - /** - * 显示编辑资源表单页. - * - * @param int $id - * @return \think\Response - */ - public function edit($id) - { - // - } - - /** - * 保存更新的资源 - * - * @param \think\Request $request - * @param int $id - * @return \think\Response - */ - public function update(Request $request, $id) - { - // - } - - /** - * 删除指定资源 - * - * @param int $id - * @return \think\Response - */ - public function delete($id) - { - // - } } diff --git a/application/admin/controller/AuthRule.php b/application/admin/controller/AuthRule.php index ea31f74d..b78cd731 100644 --- a/application/admin/controller/AuthRule.php +++ b/application/admin/controller/AuthRule.php @@ -5,18 +5,16 @@ namespace app\admin\controller; // 引用控制器基类 use app\common\controller\Base; // 引用权限数据模型类 -use app\admin\model\AuthRule as authrulemod; +use app\admin\model\AuthRule as AR; class AuthRule extends Base { // 显示权限列表 public function index() { - // 实例化权限数据模型类 - $authrulemod = new authrulemod(); // 设置数据总数 - $list['count'] = $authrulemod->count(); + $list['count'] = AR::count(); // 设置页面标题 $list['title'] = '权限列表'; @@ -32,8 +30,6 @@ class AuthRule extends Base // 获取权限信息列表 public function ajaxData() { - // 实例化权限数据模型类 - $authrulemod = new authrulemod(); // 获取DT的传值 $getdt = request()->param(); @@ -52,10 +48,9 @@ class AuthRule extends Base // 获取记录集总数 - $cnt = $authrulemod->count(); + $cnt = AR::count(); //查询数据 - $data = $authrulemod - ->field('id,title,name,condition,paixu,ismenu,font,status,pid') + $data =AR::field('id,title,name,condition,paixu,ismenu,font,status,pid') ->order([$order_field=>$order]) ->limit($limit_start,$limit_length) ->all(); @@ -64,9 +59,6 @@ class AuthRule extends Base // 如果需要查询 if($search){ $data = $authrulemod - ->field('id,title,name,condition,paixu,ismenu,font,status,pid') - ->order([$order_field=>$order]) - ->limit($limit_start,$limit_length) ->where('title|name|pid','like','%'.$search.'%') ->all(); } @@ -106,9 +98,6 @@ class AuthRule extends Base // 保存信息 public function save() { - // 实例化权限数据模型类 - $authrulemod = new authrulemod(); - // 实例化验证模型 $validate = new \app\admin\validate\Rule; @@ -128,7 +117,7 @@ class AuthRule extends Base } // 保存数据 - $data = $authrulemod->save($list); + $data = AR::create($list); $msg = array(); @@ -151,12 +140,9 @@ class AuthRule extends Base // 修改权限信息 public function edit($id) { - //实例化权限数据模型 - $authrulemod = new authrulemod(); // 获取权限信息 - $list = $authrulemod - ->field('id,title,name,condition,pid,paixu,ismenu,font') + $list = AR::field('id,title,name,condition,pid,paixu,ismenu,font') ->get($id); @@ -172,9 +158,6 @@ class AuthRule extends Base // 更新权限信息 public function update($id) { - // 实例化权限数据模型类 - $authrulemod = new authrulemod(); - // 实例化验证模型 $validate = new \app\admin\validate\Rule; // 获取表单数据 @@ -190,7 +173,7 @@ class AuthRule extends Base } - $data = $authrulemod->save($list,['id'=>$id]); + $data = AR::where('id',$id)->update($list); // 根据更新结果设置返回提示信息 $data ? $data=['msg'=>'更新成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; @@ -206,15 +189,13 @@ class AuthRule extends Base // 删除权限 public function delete($id) { - //实例化权限数据模型类 - $authrulemod = new authrulemod(); if($id == 'm') { $id = request()->delete('ids/a');// 获取delete请求方式传送过来的数据并转换成数据 } - $data = $authrulemod->destroy($id); + $data = AR::destroy($id); // 根据更新结果设置返回提示信息 $data ? $data=['msg'=>'删除成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; @@ -228,21 +209,13 @@ class AuthRule extends Base // 设置权限状态 public function setStatus() { - // 实例化权限数据模型类 - $authrulemod = new authrulemod(); // 获取id变量 $id = request()->post('id'); $value = request()->post('value'); // 获取权限信息 - $list = $authrulemod->get($id); - - // 修改状态值 - $list->status = $value; - - // 更新数据 - $data = $list->save(); + $data = AR::where('id',$id)->update(['status'=>$value]); // 根据更新结果设置返回提示信息 $data ? $data=['msg'=>'状态设置成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php index c6ba151e..c8100eca 100644 --- a/application/admin/controller/Index.php +++ b/application/admin/controller/Index.php @@ -5,7 +5,9 @@ namespace app\admin\controller; // 引用控制器基类 use app\common\controller\Base; // 引用用户数据模型 -use app\admin\model\Admin; +use app\admin\model\Admin as AD; +// 引用用户与组关联数据表模型 +use app\admin\model\AuthGroupAccess as AGA; // 引用加密类 use WhiteHat101\Crypt\APR1_MD5; @@ -14,10 +16,8 @@ class Index extends Base // 管理员列表 public function index() { - //实例化管理员数据模型类 - $admin = new Admin(); - $count = $admin->where('id','<>',1)->count(); + $count = AD::where('id','>',1)->count(); // 设置要给模板赋值的信息 $list['title'] = '管理员列表'; @@ -36,8 +36,7 @@ class Index extends Base // 获取数据管理员数据 public function ajaxData() { - //实例化管理员数据模型类 - $admin = new Admin(); + // 获取DT的传值 $getdt = request()->param(); @@ -56,10 +55,9 @@ class Index extends Base // 获取记录集总数 - $cnt = $admin->where('id','<>',1)->count(); + $cnt = AD::where('id','>',1)->count(); //查询数据 - $data = $admin - ->field('id,xingming,sex,username,phone,shengri,denglucishu,status,create_time') + $data = AD::field('id,xingming,sex,username,phone,shengri,denglucishu,status,create_time') ->where('id','>','1') ->order([$order_field=>$order]) ->limit($limit_start,$limit_length) @@ -68,8 +66,7 @@ class Index extends Base // 如果需要查询 if($search){ - $data = $admin - ->field('id,xingming,sex,username,phone,shengri,denglucishu,status,create_time') + $data = AD::field('id,xingming,sex,username,phone,shengri,denglucishu,status,create_time') ->where('id','>','1') ->order([$order_field=>$order]) ->limit($limit_start,$limit_length) @@ -111,9 +108,7 @@ class Index extends Base // 保存管理员 public function save() { - - // 实例化管理员数据模型类 - $admin = new Admin(); + // 实例化加密类 $md5 = new APR1_MD5(); // 实例化验证模型 @@ -138,7 +133,13 @@ class Index extends Base } // 保存数据 - $data = $admin->save($list); + $data = AD::create($list); + + $group_id = request()->post('group_id'); + + $data = AGA::create(['uid'=>$data->id,'group_id'=>$group_id]); + + $msg = array(); @@ -156,11 +157,9 @@ class Index extends Base // 读取用户信息 public function read($id) { - // 实例化管理员数据模型类 - $admin = new Admin(); // 获取管理员信息 - $list = $admin->get($id); + $list = AD::get($id); // 模板赋值 $this->assign('list',$list); @@ -175,13 +174,11 @@ class Index extends Base // public function edit($id) { - //实例化管理员数据模型 - $admin = new Admin(); // 获取用户信息 - $list = $admin - ->field('id,username,xingming,sex,shengri,phone,beizhu') + $list = AD::field('id,username,xingming,sex,shengri,phone,beizhu') ->get($id); + $list->group_id = AGA::where('uid',$id)->value('group_id'); $this->assign('list',$list); @@ -193,13 +190,12 @@ class Index extends Base // 更新管理员信息 public function update($id) { - // 实例化管理员数据模型类 - $admin = new Admin(); + // 实例化验证模型 $validate = new \app\admin\validate\Admin; // 获取表单数据 - $list = request()->put(); + $list = request()->only(['xingming','username','sex','shengri','phone','beizhu'],'put'); // 验证表单数据 $result = $validate->check($list); @@ -210,8 +206,12 @@ class Index extends Base return json(['msg'=>$msg,'val'=>0]);; } + // 更新管理员信息 + $data = AD::where('id',$id)->update($list); - $data = $admin->save($list,['id'=>$id]); + // 更新管理员角色 + $group_id = request()->put('group_id'); + $data = AGA::where('uid',$id)->update(['group_id'=>$group_id]); // 根据更新结果设置返回提示信息 $data ? $data=['msg'=>'更新成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; @@ -228,15 +228,13 @@ class Index extends Base */ public function delete($id) { - //实例化管理员数据模型类 - $admin = new Admin(); if($id == 'm') { $id = request()->delete('ids/a'); } - $data = $admin->destroy($id); + $data = AD::destroy($id); // 根据更新结果设置返回提示信息 $data ? $data=['msg'=>'删除成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; @@ -249,21 +247,13 @@ class Index extends Base // 修改管理员状态 public function setStatus() { - // 实例化管理员数据模型类 - $admin = new Admin(); // 获取id变量 $id = request()->post('id'); $value = request()->post('value'); - // 获取管理员信息 - $list = $admin->get($id); - - // 修改状态值 - $list->status = $value; - - // 更新数据 - $data = $list->save(); + // 更新管理员信息 + $data = AD::where('id',$id)->update(['status'=>$value]); // 根据更新结果设置返回提示信息 $data ? $data=['msg'=>'状态设置成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; @@ -277,8 +267,6 @@ class Index extends Base public function resetpassword($id) { - // 实例化管理员数据模型类 - $admin = new Admin(); // 实例化加密类 $md5 = new APR1_MD5(); @@ -286,13 +274,7 @@ class Index extends Base $password = $md5->hash('123456'); // 查询用户信息 - $list = $admin->get($id); - - // 设置管理员新信息 - $list->password = $password; - - // 更新密码 - $data = $list->save(); + $data = AD::where('id',$id)->update(['password'=>$password]); // 根据更新结果设置返回提示信息 $data ? $data=['msg'=>'密码已经重置为:
123456','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; @@ -302,4 +284,5 @@ class Index extends Base } + } diff --git a/application/admin/view/auth_group/index.html b/application/admin/view/auth_group/index.html index 7ed45878..e5f14d3a 100644 --- a/application/admin/view/auth_group/index.html +++ b/application/admin/view/auth_group/index.html @@ -21,7 +21,7 @@ 批量删除 - + 添加角色 diff --git a/application/admin/view/auth_rule/index.html b/application/admin/view/auth_rule/index.html index d1de45d4..f87c2608 100644 --- a/application/admin/view/auth_rule/index.html +++ b/application/admin/view/auth_rule/index.html @@ -21,7 +21,7 @@ 批量删除 - + 添加权限 diff --git a/application/admin/view/index/create.html b/application/admin/view/index/create.html index 6a8e6124..22f99691 100644 --- a/application/admin/view/index/create.html +++ b/application/admin/view/index/create.html @@ -13,6 +13,20 @@ +
+ +
+ {php} + $group = db('auth_group')->where('status',true)->field('id,title')->all(); + {/php} + {volist name="group" id="vo"} +
+ + +
+ {/volist} +
+
@@ -83,6 +97,9 @@ ustr:true, rangelength:[5,20] }, + group_id:{ + required:true, + }, sex:{ required:true, }, diff --git a/application/admin/view/index/edit.html b/application/admin/view/index/edit.html index c89bb80c..28aa393f 100644 --- a/application/admin/view/index/edit.html +++ b/application/admin/view/index/edit.html @@ -13,6 +13,20 @@
+
+ +
+ {php} + $group = db('auth_group')->where('status',true)->field('id,title')->all(); + {/php} + {volist name="group" id="vo"} +
+ + +
+ {/volist} +
+
diff --git a/application/admin/view/index/index.html b/application/admin/view/index/index.html index 666588fb..65786c97 100644 --- a/application/admin/view/index/index.html +++ b/application/admin/view/index/index.html @@ -21,7 +21,7 @@ 批量删除 - + 添加管理员 @@ -91,21 +91,22 @@ "className":'.td-manage', "render": function(data, type, row, meta) { // 初始化密码 - resetpwbut = ''; + resetpwbut = ''; // 停用按钮 - stopbut = ''; + stopbut = ''; // 启用按钮 - startbut = ''; + startbut = ''; // 详细信息按钮 readbut = ''; // 编辑按钮 editbut = ''; delbut = ''; + buts = startbut + readbut + editbut + delbut; if(row.status == '已停用') { - buts = resetpwbut + startbut + readbut + editbut + delbut; + buts = resetpwbut + buts; }else{ - buts = resetpwbut + stopbut + readbut + editbut + delbut; + buts = resetpwbut + buts; } return buts; diff --git a/application/http/middleware/YanZheng.php b/application/http/middleware/YanZheng.php index a969e7d5..65c5381f 100644 --- a/application/http/middleware/YanZheng.php +++ b/application/http/middleware/YanZheng.php @@ -39,11 +39,12 @@ class YanZheng extends Controller // 实例化权限验证类 $auth = new Auth(); + // 获取当前地址 $mod = $request->module(); $con = $request->controller(); $act = $request->action(); - $url = $request->module().'/'.$request->controller().'/'.$request->action(); + $url = $mod.'/'.$con.'/'.$act; // 排除模块 $uneed_m = array('home'); @@ -63,7 +64,7 @@ class YanZheng extends Controller } // 验证方法 - if( !$auth->check($url, $yz ) && $except == false ){// 第一个参数是规则名称,第二个参数是用户UID + if( !$auth->check($url, session('userid')) && $except == false ){// 第一个参数是规则名称,第二个参数是用户UID $this->error('哎哟~ 权限不足'); } diff --git a/application/index/view/index/index.html b/application/index/view/index/index.html index 3ca2cab8..f186b4e8 100644 --- a/application/index/view/index/index.html +++ b/application/index/view/index/index.html @@ -156,7 +156,7 @@
  • 系统设置
  • -
  • 栏目管理
  • +
  • 栏目管理
  • 数据字典
  • 屏蔽词
  • 系统日志
  • diff --git a/application/index/view/index/welcome.html b/application/index/view/index/welcome.html index 62a8f3fb..be6f1fa3 100644 --- a/application/index/view/index/welcome.html +++ b/application/index/view/index/welcome.html @@ -94,6 +94,10 @@ 服务器计算机名 http://127.0.0.1/ + + ThinkPhp版本号 + {$Think.version} + 服务器IP地址 192.168.1.1 diff --git a/application/login/controller/Index.php b/application/login/controller/Index.php index bbd2f196..2d0a09fa 100644 --- a/application/login/controller/Index.php +++ b/application/login/controller/Index.php @@ -4,9 +4,11 @@ namespace app\login\controller; // 引用控制器类 use think\Controller; // 引用用户数据模型 -use app\admin\model\Admin as admin; -// 引用与此控制器同名的数据模型 -use app\system\model\SystemBase as sysbasemod; +use app\admin\model\Admin as AD; +// 引用权限类 +use app\admin\model\AuthRule as AR; + + // 引用加密类 use WhiteHat101\Crypt\APR1_MD5; @@ -24,8 +26,7 @@ class Index extends Controller // 登录验证 public function yanzheng() { - // 实例化模型 - $admin = new admin(); + // 实例化验证模型 $validate = new \app\login\validate\Yanzheng; @@ -51,12 +52,13 @@ class Index extends Controller if( request()->post('online') == true ) { // 设置 + cookie('userid', session('userid') ,259200); cookie('username', $data['username'] ,259200); cookie('password', $data['password'] ,259200); } // 将本次信息上传到服务器上 - $userinfo = $admin->getByUsername($data['username']); + $userinfo = AD::getByUsername($data['username']); $userinfo->lastip = $userinfo->ip; $userinfo->ip = request()->host(); $userinfo->denglucishu = ['inc', 1]; @@ -78,20 +80,29 @@ class Index extends Controller // 已知密码进行验证 public function check($username,$password) { - // 实例化管理员数据模型类 - $admin = new admin(); // 实例化加密类 $md5 = new APR1_MD5(); // 获取服务器密码 - $serpw = $admin->password('admin'); - $serpw == null ? $serpw ='$apr1$tzQxnliW$f' : $serpw ; #serpw为随意字符 + $userinfo = AD::where('username',$username)->find(); + + if($userinfo == null) + { + // 提示错误信息 + $this->error('帐号不存在'); + } + + + // 实例化权限类 + $ar = new AR(); + //验证密码 - $check = $md5->check($password,$serpw); + $check = $md5->check($password,$userinfo->password); if($check) { // Session存值 + session('userid', $userinfo->id); session('username', $username); session('password', $password); }else{ @@ -102,60 +113,5 @@ class Index extends Controller } return $check; } - - - - // 首次登录添加admin - public function first() - { - // 实例化模型 - $admin = new admin(); - // 实例化加密类 - $md5 = new APR1_MD5(); - // 实例化系统参数类 - $sysbasemod = new sysbasemod(); - - $userinfo = $admin->get(1); - - $msg = array(); - - $sysbase = $sysbasemod->get(1); - - if( $sysbase == null ) - { - $sysbasemod->title = '学生成绩统计系统'; - $sysbasemod->save(); - $msg[] = '、系统参数初始化完成;'; - }else{ - $msg[] = '、系统参数已经初始化不再重复操作;'; - } - - $userinfo = $admin->get(1); - - if( $userinfo == null ) - { - $admin->id =1; - $admin->xingming ='管理员'; - $admin->username = 'admin'; - $admin->password = $md5->hash('123'); - $data = $admin->save(); - $msg[] = '、超级管理员信息初始化完成;'; - }else{ - $msg[] = '、超级管理员已经初始化不再重复操作;'; - } - - - - - - - foreach ($msg as $key => $value) { - echo $key+1 .$value; - echo '
    '; - } - echo '
    '; - echo '现在可以重新登录页系统'; - - return ''; - } + } diff --git a/application/system/controller/Category.php b/application/system/controller/Category.php new file mode 100644 index 00000000..0e8a0fdf --- /dev/null +++ b/application/system/controller/Category.php @@ -0,0 +1,85 @@ +addColumn('create_time','integer',['limit'=>11,'default'=>'1539158918','null'=>false,'comment'=>'创建时间']) - ->addColumn('update_time','integer',['limit'=>11,'default'=>'1539158918','null'=>false,'comment'=>'更新时间']) - ->addColumn('title','string',['limit'=>50,'default'=>'学生成绩统计系统','null'=>false,'comment'=>'网站名称']) - ->addColumn('keywords','string',['limit'=>100,'default'=>'成绩统计,成绩管理','null'=>false,'comment'=>'关键词']) - ->addColumn('description','string',['limit'=>100,'default'=>'这是我们自己开发的系统','null'=>false,'comment'=>'网站说明']) - ->addColumn('copyright','string',['limit'=>15,'default'=>'2018-'.date('Y').'-'.date('y'),'null'=>false,'comment'=>'版权']) - ->addColumn('thinks','string',['limit'=>200,'default'=>'H-ui前端框架、ThinkPhp框架','null'=>false,'comment'=>'网站感谢']) + ->addColumn('create_time','integer',['limit'=>11,'null'=>false,'comment'=>'创建时间']) + ->addColumn('update_time','integer',['limit'=>11,'null'=>false,'comment'=>'更新时间']) + ->addColumn('title','string',['limit'=>50,'null'=>false,'comment'=>'网站名称']) + ->addColumn('keywords','string',['limit'=>100,'null'=>false,'comment'=>'关键词']) + ->addColumn('description','string',['limit'=>100,'null'=>false,'comment'=>'网站说明']) + ->addColumn('copyright','string',['limit'=>15,'null'=>false,'comment'=>'版权']) + ->addColumn('thinks','string',['limit'=>200,'null'=>false,'comment'=>'网站感谢']) ->addColumn('delete_time','integer',['limit'=>11,'null'=>true,'comment'=>'删除时间']) ->create(); } diff --git a/database/migrations/20181010075304_auth_group.php b/database/migrations/20181010075304_auth_group.php index d4e7c2c2..010184c0 100644 --- a/database/migrations/20181010075304_auth_group.php +++ b/database/migrations/20181010075304_auth_group.php @@ -38,6 +38,7 @@ class AuthGroup extends Migrator ->addColumn('miaoshu','string',['limit'=>200,'default'=>'','null'=>false,'comment'=>'用户组功能描述']) ->addColumn('status','boolean',['default'=>true,'null'=>false,'comment'=>'用户组状态']) ->addColumn('delete_time','integer',['limit'=>11,'null'=>true,'comment'=>'删除时间']) + ->addIndex(array('title'), array('unique' => true)) ->create(); } } diff --git a/database/migrations/20181010075553_auth_rule.php b/database/migrations/20181010075553_auth_rule.php index 91da9735..d45a65bf 100644 --- a/database/migrations/20181010075553_auth_rule.php +++ b/database/migrations/20181010075553_auth_rule.php @@ -33,14 +33,15 @@ class AuthRule extends Migrator // 添加当前表字段 $table - ->addColumn('name','string',['limit'=>80,'default'=>'','null'=>false,'comment'=>'规则唯一标识']) - ->addColumn('title','string',['limit'=>80,'default'=>'','null'=>false,'comment'=>'规则中文名']) + ->addColumn('name','string',['limit'=>80,'null'=>false,'comment'=>'规则唯一标识']) + ->addColumn('title','string',['limit'=>80,'null'=>false,'comment'=>'规则中文名']) ->addColumn('type','boolean',['default'=>false,'null'=>true,'comment'=>'']) ->addColumn('status','boolean',['default'=>true,'null'=>false,'comment'=>'规则状态']) - ->addColumn('condition','string',['limit'=>100,'default'=>'','null'=>true,'comment'=>'规则表达式']) + ->addColumn('condition','string',['limit'=>100,'null'=>true,'comment'=>'规则表达式']) ->addColumn('paixu','integer',['limit'=>11,'default'=>999,'null'=>false,'comment'=>'排序']) ->addColumn('ismenu','boolean',['limit'=>1,'default'=>false,'null'=>false,'comment'=>'是否是菜单']) - ->addColumn('font','string',['limit'=>40,'default'=>'','null'=>true,'comment'=>'菜单字体']) + ->addColumn('font','string',['limit'=>40,'null'=>true,'comment'=>'菜单字体']) + ->addColumn('url','string',['limit'=>40,'null'=>true,'comment'=>'菜单地址']) ->addColumn('pid','integer',['limit'=>3,'default'=>0,'null'=>true,'comment'=>'父ID']) ->addColumn('delete_time','integer',['limit'=>11,'null'=>true,'comment'=>'删除时间']) ->addIndex(array('name'), array('unique' => true)) diff --git a/database/seeds/Admin.php b/database/seeds/Admin.php new file mode 100644 index 00000000..05e08d8c --- /dev/null +++ b/database/seeds/Admin.php @@ -0,0 +1,28 @@ + 1, + 'xingming' => '超级管理员', + 'username' => 'admin', + 'password' => '$apr1$RSUodBwI$zOhVq9RQWfQDOW2sbeCDS1', + ]; + // 保存数据 + $this->table('admin')->insert($rows)->save(); + } + +} \ No newline at end of file diff --git a/database/seeds/Rule.php b/database/seeds/Rule.php new file mode 100644 index 00000000..1ee85385 --- /dev/null +++ b/database/seeds/Rule.php @@ -0,0 +1,84 @@ + 1, + 'title' => '系统管理', + 'name' => 'admin', + 'paixu' => 1, + 'ismenu' => true, + 'font' => '.Hui-iconfont-system', + 'pid' => 0, + 'url' => '', + ], + [ + 'id' => 2, + 'title' => '管理员列表', + 'name' => '/admin', + 'paixu' => 1, + 'ismenu' => true, + 'font' => '', + 'pid' => 0, + 'url' => '/admin', + ], + [ + 'id' => 3, + 'title' => '添加', + 'name' => 'admin/index/create', + 'paixu' => 1, + 'ismenu' => false, + 'font' => '', + 'pid' => 2, + 'url' => '', + ], + [ + 'id' => 4, + 'title' => '删除', + 'name' => 'admin/index/delete', + 'paixu' => 5, + 'ismenu' => false, + 'font' => '', + 'pid' => 2, + 'url' => '', + ], + [ + 'id' => 5, + 'title' => '编辑', + 'name' => 'admin/index/edit', + 'paixu' => 3, + 'ismenu' => false, + 'font' => '', + 'pid' => 2, + 'url' => '', + ], + [ + 'id' => 6, + 'title' => '查看', + 'name' => 'admin/index/read', + 'paixu' => 4, + 'ismenu' => false, + 'font' => '', + 'pid' => 2, + 'url' => '', + ], + + ]; + // 保存数据 + $this->table('auth_rule')->insert($rows)->save(); + } +} \ No newline at end of file diff --git a/database/seeds/SystemBase.php b/database/seeds/SystemBase.php new file mode 100644 index 00000000..3c827314 --- /dev/null +++ b/database/seeds/SystemBase.php @@ -0,0 +1,30 @@ + time(), + 'update_time' => time(), + 'title' => '学生成绩统计系统', + 'keywords' => '成绩统计,成绩管理', + 'description' => '这是我们自己开发的系统', + 'copyright' => '2018-2018', + 'thinks' => 'H-ui前端框架、ThinkPhp框架', + ]; + // 保存数据 + $this->table('system_base')->insert($rows)->save(); + } +} \ No newline at end of file diff --git a/thinkphp/helper.php b/thinkphp/helper.php index f2941466..4aa73722 100644 --- a/thinkphp/helper.php +++ b/thinkphp/helper.php @@ -130,19 +130,19 @@ if (!function_exists('cache')) { } elseif (is_null($value)) { // 删除缓存 return Cache::rm($name); - } else { - // 缓存数据 - if (is_array($options)) { - $expire = isset($options['expire']) ? $options['expire'] : null; //修复查询缓存无法设置过期时间 - } else { - $expire = is_numeric($options) ? $options : null; //默认快捷缓存设置过期时间 - } + } - if (is_null($tag)) { - return Cache::set($name, $value, $expire); - } else { - return Cache::tag($tag)->set($name, $value, $expire); - } + // 缓存数据 + if (is_array($options)) { + $expire = isset($options['expire']) ? $options['expire'] : null; //修复查询缓存无法设置过期时间 + } else { + $expire = is_numeric($options) ? $options : null; //默认快捷缓存设置过期时间 + } + + if (is_null($tag)) { + return Cache::set($name, $value, $expire); + } else { + return Cache::tag($tag)->set($name, $value, $expire); } } } diff --git a/thinkphp/lang/zh-cn.php b/thinkphp/lang/zh-cn.php index e2067a76..1e050820 100644 --- a/thinkphp/lang/zh-cn.php +++ b/thinkphp/lang/zh-cn.php @@ -50,6 +50,7 @@ return [ 'KVDB init error' => '没有初始化KVDB,请在SAE管理平台初始化KVDB服务', 'fields not exists' => '数据表字段不存在', 'where express error' => '查询表达式错误', + 'order express error' => '排序表达式错误', 'no data to update' => '没有任何数据需要更新', 'miss data to insert' => '缺少需要写入的数据', 'not support data' => '不支持的数据表达式', diff --git a/thinkphp/library/think/App.php b/thinkphp/library/think/App.php index 27f3251f..d888e3c9 100644 --- a/thinkphp/library/think/App.php +++ b/thinkphp/library/think/App.php @@ -20,7 +20,7 @@ use think\route\Dispatch; */ class App extends Container { - const VERSION = '5.1.25'; + const VERSION = '5.1.27 LTS'; /** * 当前模块路径 diff --git a/thinkphp/library/think/Build.php b/thinkphp/library/think/Build.php index 4f90476d..7a531d74 100644 --- a/thinkphp/library/think/Build.php +++ b/thinkphp/library/think/Build.php @@ -190,22 +190,28 @@ class Build public function buildRoute($suffix = false, $layer = '') { $namespace = $this->app->getNameSpace(); - $modules = glob($this->basePath . '*', GLOB_ONLYDIR); $content = 'app->config('app.url_controller_layer'); } - foreach ($modules as $module) { - $module = basename($module); + if ($this->app->config('app.app_multi_module')) { + $modules = glob($this->basePath . '*', GLOB_ONLYDIR); - if (in_array($module, $this->app->config('app.deny_module_list'))) { - continue; + foreach ($modules as $module) { + $module = basename($module); + + if (in_array($module, $this->app->config('app.deny_module_list'))) { + continue; + } + + $path = $this->basePath . $module . DIRECTORY_SEPARATOR . $layer . DIRECTORY_SEPARATOR; + $content .= $this->buildDirRoute($path, $namespace, $module, $suffix, $layer); } - - $path = $this->basePath . $module . DIRECTORY_SEPARATOR . $layer . DIRECTORY_SEPARATOR; - $content .= $this->buildDirRoute($path, $namespace, $module, $suffix, $layer); + } else { + $path = $this->basePath . $layer . DIRECTORY_SEPARATOR; + $content .= $this->buildDirRoute($path, $namespace, '', $suffix, $layer); } $filename = $this->app->getRuntimePath() . 'build_route.php'; @@ -232,7 +238,7 @@ class Build foreach ($controllers as $controller) { $controller = basename($controller, '.php'); - $class = new \ReflectionClass($namespace . '\\' . $module . '\\' . $layer . '\\' . $controller); + $class = new \ReflectionClass($namespace . '\\' . ($module ? $module . '\\' : '') . $layer . '\\' . $controller); if (strpos($layer, '\\')) { // 多级控制器 @@ -274,12 +280,12 @@ class Build if (false !== strpos($comment, '@route(')) { $comment = $this->parseRouteComment($comment); - $route = $module . '/' . $controller; + $route = ($module ? $module . '/' : '') . $controller; $comment = preg_replace('/route\(\s?([\'\"][\-\_\/\:\<\>\?\$\[\]\w]+[\'\"])\s?\)/is', 'Route::resource(\1,\'' . $route . '\')', $comment); $content .= PHP_EOL . $comment; } elseif (false !== strpos($comment, '@alias(')) { $comment = $this->parseRouteComment($comment, '@alias('); - $route = $module . '/' . $controller; + $route = ($module ? $module . '/' : '') . $controller; $comment = preg_replace('/alias\(\s?([\'\"][\-\_\/\w]+[\'\"])\s?\)/is', 'Route::alias(\1,\'' . $route . '\')', $comment); $content .= PHP_EOL . $comment; } @@ -344,7 +350,7 @@ class Build $action = substr($action, 0, -strlen($suffix)); } - $route = $module . '/' . $controller . '/' . $action; + $route = ($module ? $module . '/' : '') . $controller . '/' . $action; $comment = preg_replace('/route\s?\(\s?([\'\"][\-\_\/\:\<\>\?\$\[\]\w]+[\'\"])\s?\,?\s?[\'\"]?(\w+?)[\'\"]?\s?\)/is', 'Route::\2(\1,\'' . $route . '\')', $comment); $comment = preg_replace('/route\s?\(\s?([\'\"][\-\_\/\:\<\>\?\$\[\]\w]+[\'\"])\s?\)/is', 'Route::rule(\1,\'' . $route . '\')', $comment); diff --git a/thinkphp/library/think/Collection.php b/thinkphp/library/think/Collection.php index 4de97255..d58c8999 100644 --- a/thinkphp/library/think/Collection.php +++ b/thinkphp/library/think/Collection.php @@ -429,15 +429,20 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria * @access public * @param string $field 排序字段 * @param string $order 排序 + * @param bool $intSort 是否为数字排序 * @return $this */ - public function order($field, $order = null) + public function order($field, $order = null, $intSort = true) { - return $this->sort(function ($a, $b) use ($field, $order) { + return $this->sort(function ($a, $b) use ($field, $order, $intSort) { $fieldA = isset($a[$field]) ? $a[$field] : null; $fieldB = isset($b[$field]) ? $b[$field] : null; - return 'desc' == strtolower($order) ? strcmp($fieldB, $fieldA) : strcmp($fieldA, $fieldB); + if ($intSort) { + return 'desc' == strtolower($order) ? $fieldB >= $fieldA : $fieldA >= $fieldB; + } else { + return 'desc' == strtolower($order) ? strcmp($fieldB, $fieldA) : strcmp($fieldA, $fieldB); + } }); } diff --git a/thinkphp/library/think/Model.php b/thinkphp/library/think/Model.php index d47ce3e3..93914f0d 100644 --- a/thinkphp/library/think/Model.php +++ b/thinkphp/library/think/Model.php @@ -124,6 +124,12 @@ abstract class Model implements \JsonSerializable, \ArrayAccess */ protected $defaultSoftDelete; + /** + * 全局查询范围 + * @var array + */ + protected $globalScope = []; + /** * 架构函数 * @access public @@ -272,7 +278,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess /** * 获取当前模型的数据库查询对象 * @access public - * @param bool $useBaseQuery 是否调用全局查询范围 + * @param bool|array $useBaseQuery 是否调用全局查询范围(或者指定查询范围名称) * @return Query */ public function db($useBaseQuery = true) @@ -289,10 +295,16 @@ abstract class Model implements \JsonSerializable, \ArrayAccess } // 全局作用域 - if ($useBaseQuery && method_exists($this, 'base')) { + if (true === $useBaseQuery && method_exists($this, 'base')) { call_user_func_array([$this, 'base'], [ & $query]); } + $globalScope = is_array($useBaseQuery) && $useBaseQuery ?: $this->globalScope; + + if ($globalScope) { + $query->scope($globalScope); + } + // 返回当前模型的数据库查询对象 return $query; } @@ -427,6 +439,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess // 重新记录原始数据 $this->origin = $this->data; + $this->set = []; return true; } @@ -1030,7 +1043,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess /** * 设置是否使用全局查询范围 * @access public - * @param bool $use 是否启用全局查询范围 + * @param bool|array $use 是否启用全局查询范围(或者用数组指定查询范围名称) * @return Query */ public static function useGlobalScope($use) diff --git a/thinkphp/library/think/Request.php b/thinkphp/library/think/Request.php index 948e1844..61f7fedc 100644 --- a/thinkphp/library/think/Request.php +++ b/thinkphp/library/think/Request.php @@ -1174,13 +1174,13 @@ class Request $files = $this->file; if (!empty($files)) { - // 处理上传文件 - $array = $this->dealUploadFile($files); - if (strpos($name, '.')) { list($name, $sub) = explode('.', $name); } + // 处理上传文件 + $array = $this->dealUploadFile($files, $name); + if ('' === $name) { // 获取全部文件 return $array; @@ -1194,18 +1194,24 @@ class Request return; } - protected function dealUploadFile($files) + protected function dealUploadFile($files, $name) { $array = []; foreach ($files as $key => $file) { - if (is_array($file['name'])) { + if ($file instanceof File) { + $array[$key] = $file; + } elseif (is_array($file['name'])) { $item = []; $keys = array_keys($file); $count = count($file['name']); for ($i = 0; $i < $count; $i++) { if ($file['error'][$i] > 0) { - $this->throwUploadFileError($file['error'][$i]); + if ($name == $key) { + $this->throwUploadFileError($file['error'][$i]); + } else { + continue; + } } $temp['key'] = $key; @@ -1219,15 +1225,15 @@ class Request $array[$key] = $item; } else { - if ($file instanceof File) { - $array[$key] = $file; - } else { - if ($file['error'] > 0) { + if ($file['error'] > 0) { + if ($key == $name) { $this->throwUploadFileError($file['error']); + } else { + continue; } - - $array[$key] = (new File($file['tmp_name']))->setUploadInfo($file); } + + $array[$key] = (new File($file['tmp_name']))->setUploadInfo($file); } } diff --git a/thinkphp/library/think/db/Builder.php b/thinkphp/library/think/db/Builder.php index 507cda98..daa7eda5 100644 --- a/thinkphp/library/think/db/Builder.php +++ b/thinkphp/library/think/db/Builder.php @@ -113,6 +113,10 @@ abstract class Builder $result = []; foreach ($data as $key => $val) { + if ('*' != $options['field'] && !in_array($key, $fields, true)) { + continue; + } + $item = $this->parseKey($query, $key, true); if ($val instanceof Expression) { @@ -129,7 +133,7 @@ abstract class Builder list($key, $name) = explode('->', $key); $item = $this->parseKey($query, $key); $result[$item] = 'json_set(' . $item . ', \'$.' . $name . '\', ' . $this->parseDataBind($query, $key, $val, $bind) . ')'; - } elseif (false === strpos($key, '.') && !in_array($key, $fields, true)) { + } elseif ('*' == $options['field'] && false === strpos($key, '.') && !in_array($key, $fields, true)) { if ($options['strict']) { throw new Exception('fields not exists:[' . $key . ']'); } @@ -788,16 +792,10 @@ abstract class Builder */ protected function parseOrder(Query $query, $order) { - if (empty($order)) { - return ''; - } - - $array = []; - foreach ($order as $key => $val) { if ($val instanceof Expression) { $array[] = $val->getValue(); - } elseif (is_array($val) && !preg_match('/\W/', $key)) { + } elseif (is_array($val) && preg_match('/^[\w\.]+$/', $key)) { $array[] = $this->parseOrderField($query, $key, $val); } elseif ('[rand]' == $val) { $array[] = $this->parseRand($query); @@ -808,15 +806,17 @@ abstract class Builder $sort = $val; } - if (false === strpos($key, ')') && false === strpos($key, '#')) { + if (preg_match('/^[\w\.]+$/', $key)) { $sort = strtoupper($sort); $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : ''; $array[] = $this->parseKey($query, $key, true) . $sort; + } else { + throw new Exception('order express error:' . $key); } } } - return ' ORDER BY ' . implode(',', $array); + return empty($array) ? '' : ' ORDER BY ' . implode(',', $array); } /** diff --git a/thinkphp/library/think/db/Query.php b/thinkphp/library/think/db/Query.php index bcf6964c..cea5a4c8 100644 --- a/thinkphp/library/think/db/Query.php +++ b/thinkphp/library/think/db/Query.php @@ -1887,10 +1887,21 @@ class Query * 表达式方式指定Field排序 * @access public * @param string $field 排序字段 + * @param array $bind 参数绑定 * @return $this */ - public function orderRaw($field) + public function orderRaw($field, $bind = []) { + if ($bind) { + foreach ($bind as $key => $value) { + if (!is_numeric($key)) { + $field = str_replace(':' . $key, '?', $field); + } + } + + $this->bind(array_values($bind)); + } + $this->options['order'][] = $this->raw($field); return $this; diff --git a/thinkphp/library/think/db/builder/Mysql.php b/thinkphp/library/think/db/builder/Mysql.php index ab21648e..7ec3bf85 100644 --- a/thinkphp/library/think/db/builder/Mysql.php +++ b/thinkphp/library/think/db/builder/Mysql.php @@ -14,6 +14,7 @@ namespace think\db\builder; use think\db\Builder; use think\db\Expression; use think\db\Query; +use think\Exception; /** * mysql数据库驱动 @@ -124,7 +125,7 @@ class Mysql extends Builder // JSON字段支持 list($field, $name) = explode('->', $key, 2); - return 'json_extract(' . $this->parseKey($query, $field) . ', \'$.' . str_replace('->', '.', $name) . '\')'; + return 'json_extract(' . $this->parseKey($query, $field, true) . ', \'$.' . str_replace('->', '.', $name) . '\')'; } elseif (strpos($key, '.') && !preg_match('/[,\'\"\(\)`\s]/', $key)) { list($table, $key) = explode('.', $key, 2); @@ -140,6 +141,10 @@ class Mysql extends Builder } } + if ($strict && !preg_match('/^[\w\.\*]+$/', $key)) { + throw new Exception('not support data:' . $key); + } + if ('*' != $key && ($strict || !preg_match('/[,\'\"\*\(\)`.\s]/', $key))) { $key = '`' . $key . '`'; } diff --git a/thinkphp/library/think/db/builder/Sqlsrv.php b/thinkphp/library/think/db/builder/Sqlsrv.php index 25da4d9f..e24f7d25 100644 --- a/thinkphp/library/think/db/builder/Sqlsrv.php +++ b/thinkphp/library/think/db/builder/Sqlsrv.php @@ -14,6 +14,7 @@ namespace think\db\builder; use think\db\Builder; use think\db\Expression; use think\db\Query; +use think\Exception; /** * Sqlsrv数据库驱动 @@ -40,8 +41,6 @@ class Sqlsrv extends Builder return ' ORDER BY rand()'; } - $array = []; - foreach ($order as $key => $val) { if ($val instanceof Expression) { $array[] = $val->getValue(); @@ -54,12 +53,17 @@ class Sqlsrv extends Builder $sort = $val; } - $sort = in_array(strtolower($sort), ['asc', 'desc'], true) ? ' ' . $sort : ''; - $array[] = $this->parseKey($query, $key, true) . $sort; + if (preg_match('/^[\w\.]+$/', $key)) { + $sort = strtoupper($sort); + $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : ''; + $array[] = $this->parseKey($query, $key, true) . $sort; + } else { + throw new Exception('order express error:' . $key); + } } } - return ' ORDER BY ' . implode(',', $array); + return empty($array) ? '' : ' ORDER BY ' . implode(',', $array); } /** @@ -106,6 +110,10 @@ class Sqlsrv extends Builder } } + if ($strict && !preg_match('/^[\w\.\*]+$/', $key)) { + throw new Exception('not support data:' . $key); + } + if ('*' != $key && ($strict || !preg_match('/[,\'\"\*\(\)\[.\s]/', $key))) { $key = '[' . $key . ']'; } diff --git a/thinkphp/library/think/model/concern/Attribute.php b/thinkphp/library/think/model/concern/Attribute.php index 9b06b9ad..76342b9f 100644 --- a/thinkphp/library/think/model/concern/Attribute.php +++ b/thinkphp/library/think/model/concern/Attribute.php @@ -72,6 +72,12 @@ trait Attribute */ private $data = []; + /** + * 修改器执行记录 + * @var array + */ + private $set = []; + /** * 原始数据 * @var array @@ -304,10 +310,14 @@ trait Attribute * @param string $name 属性名 * @param mixed $value 属性值 * @param array $data 数据 - * @return $this + * @return void */ public function setAttr($name, $value, $data = []) { + if (isset($this->set[$name])) { + return; + } + if (is_null($value) && $this->autoWriteTimestamp && in_array($name, [$this->createTime, $this->updateTime])) { // 自动写入的时间戳字段 $value = $this->autoWriteTimestamp($name); @@ -325,8 +335,7 @@ trait Attribute // 设置数据对象属性 $this->data[$name] = $value; - - return $this; + $this->set[$name] = true; } /** diff --git a/thinkphp/library/think/route/Dispatch.php b/thinkphp/library/think/route/Dispatch.php index 76c30d19..93afe73b 100644 --- a/thinkphp/library/think/route/Dispatch.php +++ b/thinkphp/library/think/route/Dispatch.php @@ -13,6 +13,7 @@ namespace think\route; use think\Container; use think\exception\ValidateException; +use think\App; use think\Request; use think\Response; diff --git a/thinkphp/library/think/route/Domain.php b/thinkphp/library/think/route/Domain.php index 260ca500..80950dc2 100644 --- a/thinkphp/library/think/route/Domain.php +++ b/thinkphp/library/think/route/Domain.php @@ -20,8 +20,6 @@ use think\route\dispatch\Module as ModuleDispatch; class Domain extends RuleGroup { - protected $bind; - /** * 架构函数 * @access public @@ -86,9 +84,7 @@ class Domain extends RuleGroup */ public function bind($bind) { - $this->bind = $bind; $this->router->bind($bind, $this->domain); - return $this; } @@ -117,8 +113,9 @@ class Domain extends RuleGroup */ private function checkUrlBind($request, $url) { - if (!empty($this->bind)) { - $bind = $this->bind; + $bind = $this->router->getBind($this->domain); + + if (!empty($bind)) { $this->parseBindAppendParam($bind); // 记录绑定信息 @@ -163,12 +160,13 @@ class Domain extends RuleGroup { $array = explode('|', $url, 2); $action = !empty($array[0]) ? $array[0] : $this->router->config('default_action'); + $param = []; if (!empty($array[1])) { - $this->parseUrlParams($request, $array[1]); + $this->parseUrlParams($request, $array[1], $param); } - return new CallbackDispatch($request, $this, [$class, $action]); + return new CallbackDispatch($request, $this, [$class, $action], $param); } /** @@ -184,12 +182,13 @@ class Domain extends RuleGroup $array = explode('|', $url, 3); $class = !empty($array[0]) ? $array[0] : $this->router->config('default_controller'); $method = !empty($array[1]) ? $array[1] : $this->router->config('default_action'); + $param = []; if (!empty($array[2])) { - $this->parseUrlParams($request, $array[2]); + $this->parseUrlParams($request, $array[2], $param); } - return new CallbackDispatch($request, $this, [$namespace . '\\' . Loader::parseName($class, 1), $method]); + return new CallbackDispatch($request, $this, [$namespace . '\\' . Loader::parseName($class, 1), $method], $param); } /** @@ -204,12 +203,13 @@ class Domain extends RuleGroup { $array = explode('|', $url, 2); $action = !empty($array[0]) ? $array[0] : $this->router->config('default_action'); + $param = []; if (!empty($array[1])) { - $this->parseUrlParams($request, $array[1]); + $this->parseUrlParams($request, $array[1], $param); } - return new ControllerDispatch($request, $this, $controller . '/' . $action); + return new ControllerDispatch($request, $this, $controller . '/' . $action, $param); } /** @@ -224,12 +224,13 @@ class Domain extends RuleGroup { $array = explode('|', $url, 2); $action = !empty($array[0]) ? $array[0] : $this->router->config('default_action'); + $param = []; if (!empty($array[1])) { - $this->parseUrlParams($request, $array[1]); + $this->parseUrlParams($request, $array[1], $param); } - return new ModuleDispatch($request, $this, $controller . '/' . $action); + return new ModuleDispatch($request, $this, $controller . '/' . $action, $param); } } diff --git a/thinkphp/library/think/route/dispatch/Module.php b/thinkphp/library/think/route/dispatch/Module.php index 4224b362..bfffec0f 100644 --- a/thinkphp/library/think/route/dispatch/Module.php +++ b/thinkphp/library/think/route/dispatch/Module.php @@ -114,6 +114,7 @@ class Module extends Dispatch $vars = $this->rule->getConfig('url_param_type') ? $this->request->route() : $this->request->param(); + $vars = array_merge($vars, $this->param); } elseif (is_callable([$instance, '_empty'])) { // 空操作 $call = [$instance, '_empty']; diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 9cb06f02..d17efb4a 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -45,17 +45,17 @@ }, { "name": "topthink/framework", - "version": "v5.1.25", - "version_normalized": "5.1.25.0", + "version": "v5.1.27", + "version_normalized": "5.1.27.0", "source": { "type": "git", "url": "https://github.com/top-think/framework.git", - "reference": "2e684d5fa38bd2d8ee864982f3114a28992da895" + "reference": "f607b8fd51cc25e4da7e2f4ef0d5e64f390d36bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/framework/zipball/2e684d5fa38bd2d8ee864982f3114a28992da895", - "reference": "2e684d5fa38bd2d8ee864982f3114a28992da895", + "url": "https://api.github.com/repos/top-think/framework/zipball/f607b8fd51cc25e4da7e2f4ef0d5e64f390d36bd", + "reference": "f607b8fd51cc25e4da7e2f4ef0d5e64f390d36bd", "shasum": "", "mirrors": [ { @@ -77,7 +77,7 @@ "sebastian/phpcpd": "2.*", "squizlabs/php_codesniffer": "2.*" }, - "time": "2018-10-04T05:04:50+00:00", + "time": "2018-10-22T02:10:08+00:00", "type": "think-framework", "installation-source": "dist", "notification-url": "https://packagist.org/downloads/", diff --git a/vendor/php4world/auth/src/Auth.php b/vendor/php4world/auth/src/Auth.php index 9a5b2219..844389fb 100644 --- a/vendor/php4world/auth/src/Auth.php +++ b/vendor/php4world/auth/src/Auth.php @@ -48,7 +48,7 @@ class Auth 'auth_rule' => 'auth_rule', // 权限规则表 'auth_user' => 'user', // 用户信息表 'auth_user_id_field'=> 'id', // 用户表ID字段名 - 'administrator' => [], // 超级管理员列表 + 'administrator' => [1], // 超级管理员列表 ]; public function __construct()