diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 325b5191c..777e3e25b 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -1584,7 +1584,7 @@ function getGameList($partner_id) { } function getAdminData ($uid) { - $adminData = M('auth_group_access') + $adminData = SM('auth_group_access','sys_') ->field('data_empower_type,data_president,show_data,show_market_admin,show_promote') ->join('left join sys_auth_group on sys_auth_group_access.group_id=sys_auth_group.id') ->where(array('uid'=>$uid))->find(); diff --git a/Application/Admin/Conf/config.php b/Application/Admin/Conf/config.php index f27decb08..b598e027c 100644 --- a/Application/Admin/Conf/config.php +++ b/Application/Admin/Conf/config.php @@ -120,6 +120,7 @@ return array( "sys_auth_group_access", "sys_ucenter_member", "sys_menu", + 'sys_auth_rule', "sys_action_log", "sub_user_statement", diff --git a/Application/Admin/Controller/AdminController.class.php b/Application/Admin/Controller/AdminController.class.php index e1fa9e103..871080661 100644 --- a/Application/Admin/Controller/AdminController.class.php +++ b/Application/Admin/Controller/AdminController.class.php @@ -20,6 +20,7 @@ class AdminController extends Controller { * 后台控制器初始化 */ protected function _initialize(){ + // 获取当前用户ID if(defined('UID')) return ; define('UID',is_login()); @@ -90,12 +91,11 @@ class AdminController extends Controller { } $map2['uid'] = session("user_auth.uid"); - $res = M('auth_group_access','sys_')->field('uid,group_id')->where($map2)->find(); + $res = SM('auth_group_access','sys_')->field('uid,group_id')->where($map2)->find(); $map1['id'] = $res['group_id']; - $res1 = M('auth_group','sys_')->field('title')->where($map1)->find(); + $res1 = SM('auth_group','sys_')->field('title')->where($map1)->find(); $this->assign('res',$res); $this->assign('res1',$res1); - $this->assign('__MENU__', $this->getMenus()); $this->assign('is_admin', IS_ROOT); } @@ -106,7 +106,7 @@ class AdminController extends Controller { { $flag =false; $id= 0; - $ruleres = M("auth_rule")->field("id,type")->where("name LIKE '%{$rule}%'")->select(); + $ruleres = SM("auth_rule","sys_")->field("id,type")->where("name LIKE '%{$rule}%'")->select(); foreach ($ruleres as $k => $v) { $checkRule = $this->checkRule($rule,array('eq',$v['type'])); if(!$checkRule){ @@ -123,10 +123,10 @@ class AdminController extends Controller { $where['pid'] = 0; $where['hide'] = 0; $where['url'] = array("like",$rulearr[1]."/".$rulearr[2]); - $second_id = M('Menu')->where($where)->field('id')->find()['id']; + $second_id = SM('Menu',"sys_")->where($where)->field('id')->find()['id']; $where2['pid'] = $second_id; $where2['hide'] = 0; - $menu = M('Menu')->where($where2)->field('id,url')->order('sort asc')->select(); + $menu = SM('Menu',"sys_")->where($where2)->field('id,url')->order('sort asc')->select(); foreach ($menu as $k=>$v) { $to_check_url = $v['url']; if( stripos($to_check_url,MODULE_NAME)!==0 ){ @@ -324,7 +324,7 @@ class AdminController extends Controller { if(!C('DEVELOP_MODE')){ // 是否开发者模式 $where['is_dev'] = 0; } - $menus['main'] = M('Menu')->where($where)->order('sort asc')->field('id,title,url')->select(); + $menus['main'] = SM('Menu','sys_')->where($where)->order('sort asc')->field('id,title,url')->select(); $menus['child'] = array(); //设置子节点 foreach ($menus['main'] as $key => $item) { @@ -340,16 +340,16 @@ class AdminController extends Controller { } // 查找当前子菜单 - $pid = M('Menu')->where("pid !=0 AND url like '%{$controller}/".ACTION_NAME."%'")->getField('pid'); + $pid = SM('Menu','sys_')->where("pid !=0 AND url like '%{$controller}/".ACTION_NAME."%'")->getField('pid'); if($pid){ // 查找当前主菜单 - $nav = M('Menu')->find($pid); + $nav = SM('Menu','sys_')->find($pid); // if($nav['pid']){ // $nav = M('Menu')->find($nav['pid']); // } while ($nav['pid'] != 0) { - $nav = M('Menu')->find($nav['pid']); + $nav = SM('Menu','sys_')->find($nav['pid']); } //var_dump($nav);exit; foreach ($menus['main'] as $key => $item) { @@ -358,7 +358,7 @@ class AdminController extends Controller { if($item['id'] == $nav['id']){ $menus['main'][$key]['class']='current'; //生成child树 - $groups = M('Menu')->where(array('group'=>array('neq',''),'pid' =>$item['id']))->order('sort asc')->distinct(true)->getField("group",true); + $groups = SM('Menu','sys_')->where(array('group'=>array('neq',''),'pid' =>$item['id']))->order('sort asc')->distinct(true)->getField("group",true); //获取二级分类的合法url $where = array(); $where['pid'] = $item['id']; @@ -366,7 +366,7 @@ class AdminController extends Controller { if(!C('DEVELOP_MODE')){ // 是否开发者模式 $where['is_dev'] = 0; } - $second_urls = M('Menu')->where($where)->getField('id,url'); + $second_urls = SM('Menu','sys_')->where($where)->getField('id,url'); if(!IS_ROOT){ // 检测菜单权限 @@ -397,7 +397,7 @@ class AdminController extends Controller { if(!C('DEVELOP_MODE')){ // 是否开发者模式 $map['is_dev'] = 0; } - $menuList = M('Menu')->where($map)->field('id,pid,title,url,tip')->order('sort asc')->select(); + $menuList = SM('Menu','sys_')->where($map)->field('id,pid,title,url,tip')->order('sort asc')->select(); $menus['child'][$g] = list_to_tree($menuList, 'id', 'pid', 'operater', $item['id']); } @@ -425,7 +425,7 @@ class AdminController extends Controller { return $tree_nodes[$tree]; } if((int)$tree){ - $list = M('Menu')->field('id,pid,title,url,tip,hide')->where('hide = 0')->order('sort asc')->select(); + $list = SM('Menu',"sys_")->field('id,pid,title,url,tip,hide')->where('hide = 0')->order('sort asc')->select(); foreach ($list as $key => $value) { if( stripos($value['url'],MODULE_NAME)!==0 ){ $list[$key]['url'] = MODULE_NAME.'/'.$value['url']; @@ -439,7 +439,7 @@ class AdminController extends Controller { } } }else{ - $nodes = M('Menu')->field('title,url,tip,pid')->order('sort asc')->select(); + $nodes = SM('Menu',"sys_")->field('title,url,tip,pid')->order('sort asc')->select(); foreach ($nodes as $key => $value) { if( stripos($value['url'],MODULE_NAME)!==0 ){ $nodes[$key]['url'] = MODULE_NAME.'/'.$value['url']; diff --git a/Application/Admin/Controller/PublicController.class.php b/Application/Admin/Controller/PublicController.class.php index 9b31d6136..b1a5c93e8 100644 --- a/Application/Admin/Controller/PublicController.class.php +++ b/Application/Admin/Controller/PublicController.class.php @@ -24,10 +24,6 @@ class PublicController extends \Think\Controller if (!check_verify($verify)) { $this->error('验证码输入错误!'); } - /* 财务账号只能登陆子系统*/ - if(!IS_SUBSITE && $username == "cw"){ - $this->error('账户或密码错误!'); - } /* 调用UC登录接口登录 */ $User = new UserApi; diff --git a/Application/Admin/Model/MemberModel.class.php b/Application/Admin/Model/MemberModel.class.php index d81965260..811fb087b 100644 --- a/Application/Admin/Model/MemberModel.class.php +++ b/Application/Admin/Model/MemberModel.class.php @@ -69,10 +69,6 @@ class MemberModel extends Model { 'last_login_time' => NOW_TIME, 'last_login_ip' => get_client_ip(1), ); - if(!IS_SUBSITE){ - $this->save($data); - } - $adminData = getAdminData($user['uid']); $groupId = getGameGroup($user['uid']); diff --git a/Application/Common/Common/function.php b/Application/Common/Common/function.php index 99f47e653..d100b7532 100644 --- a/Application/Common/Common/function.php +++ b/Application/Common/Common/function.php @@ -659,7 +659,7 @@ function action_log($action = null, $model = null, $record_id = null, $user_id = } //查询行为,判断是否执行 - $action_info = M('Action')->getByName($action); + $action_info = SM('Action','sys_')->getByName($action); if ($action_info['status'] != 1) { return '该行为被禁用或删除'; } @@ -1445,7 +1445,7 @@ function getAdminNickname($adminId) { $adminId = intval($adminId); if ($adminId) { - return M('member')->where(array('id' => $adminId))->getField('nickname'); + return SM('member',"sys_")->where(array('id' => $adminId))->getField('nickname'); } return '未知'; } @@ -1480,7 +1480,7 @@ function getGameTypes() function getGameGroup($uid) { - $groupId = M('auth_group_access')->field('group_id')->where(['uid'=>$uid])->find(); + $groupId = SM('auth_group_access',"sys_")->field('group_id')->where(['uid'=>$uid])->find(); return $groupId['group_id']?$groupId['group_id']:0; diff --git a/Application/User/Model/UcenterMemberModel.class.php b/Application/User/Model/UcenterMemberModel.class.php index d86b98453..91a5098fb 100644 --- a/Application/User/Model/UcenterMemberModel.class.php +++ b/Application/User/Model/UcenterMemberModel.class.php @@ -24,6 +24,14 @@ class UcenterMemberModel extends Model{ */ protected $connection = UC_DB_DSN; + public function __construct() + { + if(IS_SUBSITE){ + parent::__construct("UcenterMember", $this->tablePrefix, SUBSITE_DB); + }else{ + parent::__construct("UcenterMember", $this->tablePrefix); + } + } /* 用户模型自动验证 */ protected $_validate = array( /* 验证用户名 */ @@ -123,14 +131,14 @@ class UcenterMemberModel extends Model{ $data['mobile'] = $mobile; // dump($data);die(); try { - $status = M('UcenterMember', 'sys_')->add($data); + $status = SM('UcenterMember', 'sys_')->add($data); } catch (\Throwable $th) { $status = false; dump($th); } $uid = 0; if ($status) { - $uid = M()->getLastInsID(); + $uid = SM()->getLastInsID(); } return $uid; //0-未知错误,大于0-注册成功 } else { diff --git a/ThinkPHP/Library/Think/Auth.class.php b/ThinkPHP/Library/Think/Auth.class.php index 3001a6d9c..2246f6488 100644 --- a/ThinkPHP/Library/Think/Auth.class.php +++ b/ThinkPHP/Library/Think/Auth.class.php @@ -148,7 +148,7 @@ class Auth{ static $groups = array(); if (isset($groups[$uid])) return $groups[$uid]; - $user_base = M()->table($this->_config['AUTH_GROUP_ACCESS'])->where("uid = {$uid}")->field('uid,group_id')->find(); + $user_base = SM()->table($this->_config['AUTH_GROUP_ACCESS'])->where("uid = {$uid}")->field('uid,group_id')->find(); $user_rule= SM("auth_group","sys_")->where("id = {$user_base['group_id']} and status = 1")->field('title,rules')->find(); if(empty($user_base) || empty($user_rule)){ return []; @@ -164,6 +164,7 @@ class Auth{ * @param integer $type */ protected function getAuthList($uid,$type) { + static $_authList = array(); //保存用户验证通过的权限列表 $t = implode(',',(array)$type); if (isset($_authList[$uid.$t])) { @@ -175,6 +176,7 @@ class Auth{ //读取用户所属用户组 $groups = $this->getGroups($uid); + $ids = array();//保存用户所属用户组设置的所有权限规则id foreach ($groups as $g) { $ids = array_merge($ids, explode(',', trim($g['rules'], ','))); @@ -191,7 +193,7 @@ class Auth{ 'status'=>1, ); //读取用户组所有权限规则 - $rules = M()->table($this->_config['AUTH_RULE'])->where($map)->field('condition,name')->select(); + $rules = SM()->table($this->_config['AUTH_RULE'])->where($map)->field('condition,name')->select(); //循环规则,判断结果。 $authList = array(); // @@ -224,7 +226,7 @@ class Auth{ protected function getUserInfo($uid) { static $userinfo=array(); if(!isset($userinfo[$uid])){ - $userinfo[$uid]=M()->where(array('uid'=>$uid))->table($this->_config['AUTH_USER'])->find(); + $userinfo[$uid]=SM()->where(array('uid'=>$uid))->table($this->_config['AUTH_USER'])->find(); } return $userinfo[$uid]; }