您好,欢迎访问一九零五行业门户网

不用类,三张表,几行代码搞定权限分配

不用类,三张表,几行代码搞定权限分配
用户表create table if not exists `zycms_user` (
  `id` int(10) unsigned not null auto_increment,
  `username` varchar(50) not null,
  `ncname` varchar(20) not null,
  `password` char(32) not null,
  `role` smallint(6) unsigned not null comment '组id',
  `status` tinyint(1) unsigned not null default '0' comment '状态 1:启用 0:禁止',
  `remark` varchar(255) default null comment '备注说明',
  `last_login_time` int(11) unsigned not null comment '最后登录时间',
  `last_login_ip` varchar(15) default null comment '最后登录ip',
  `last_location` varchar(100) default null comment '最后登录位置',
  primary key (`id`),
  key `username` (`username`)
) engine=myisam  default charset=utf8 comment='用户表' auto_increment=29 ;用户组表create table if not exists `zycms_role` (
  `id` smallint(6) unsigned not null auto_increment,
  `rolename` varchar(20) not null comment '后台组名',
  `roleid` smallint(6) unsigned not null default '0' comment '父id',
  `status` tinyint(1) unsigned default '0' comment '是否激活 1:是 0:否',
  `sort` smallint(6) unsigned not null default '0' comment '排序权重',
  `remark` varchar(255) default null comment '备注说明',
  `rules` text not null,
  primary key (`id`),
  key `pid` (`roleid`),
  key `status` (`status`)
) engine=myisam  default charset=utf8 auto_increment=7 ;节点表create table if not exists `zycms_menu` (
  `id` smallint(6) unsigned not null auto_increment,
  `name` char(40) not null default '',
  `pid` smallint(6) not null default '0',
  `m` char(20) not null default '',
  `c` char(20) not null default '',
  `ac` char(20) not null,
  `data` char(100) not null default '',
  `listorder` smallint(6) unsigned not null default '0',
  `isdisplay` enum('1','0') not null default '1',
  `path` text not null,
  `tb` varchar(20) not null,
  primary key (`id`),
  key `listorder` (`listorder`),
  key `parentid` (`pid`),
  key `module` (`m`,`c`,`ac`)
) engine=myisam  default charset=utf8 auto_increment=41 ;功能实现:$rs=m('role')->where(id='{$_session['roleid']}')->find();
$rules=explode(',', $rs['rules']);
$thisaction=m('menu')->where(m='.group_name.' and c='.module_name.' and ac='.action_name.')->find();
if(!in_array($thisaction['id'], $rules))
$this->error('你无权访问');
栏目权限分配与此类似
ad:真正免费,域名+虚机+企业邮箱=0元
其它类似信息

推荐信息