CREATE TABLE `tk_auth_group` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`title` char(100) NOT NULL DEFAULT '',
`status` tinyint(1) NOT NULL DEFAULT '1',
`rules` char(80) NOT NULL DEFAULT '',
`describe` char(50) NOT NULL DEFAULT '', #新增,对用户组作简单的说明
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
2) tk_auth_rule 规则表 CREATE TABLE `tk_auth_rule` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`name` char(80) NOT NULL DEFAULT '',
`title` char(20) NOT NULL DEFAULT '',
`type` tinyint(1) NOT NULL DEFAULT '1',
`status` tinyint(1) NOT NULL DEFAULT '1',
`condition` char(100) NOT NULL DEFAULT '',
`mid` tinyint(3) unsigned NOT NULL DEFAULT '0', #新增,外键,和tk_modules的id对应,对规则分类处理,方便管理
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
3) tk_modules 模块表CREATE TABLE `tk_modules` (
`id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
`moduleName` varchar(20) NOT NULL DEFAULT '', #模块名称
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
4) tk_members 用户表CREATE TABLE `tk_members` (
`uid` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(20) NOT NULL DEFAULT '',
`password` char(32) NOT NULL DEFAULT '',
`score` mediumint(8) unsigned NOT NULL, #用户积分
PRIMARY KEY (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
2、配置文件//数据库配置
//pdo类型,采用dsn方式连接
'DB_TYPE'=>'pdo',
'DB_USER'=>'root',
'DB_PWD'=>'123456',
'DB_PREFIX'=>'tk_',
'DB_PORT'=>'3306',
'DB_DSN'=>'mysql:host=localhost;dbname=auth;charset=utf8',
2) 角色组设置,设置超级管理员组,直接跳过认证 //超级管理员id,拥有全部权限,只要用户uid在这个角色组里的,就跳出认证.可以设置多个值,如array('1','2','3')
'ADMINISTRATOR'=>array('1'),
3、注意事项$user_groups = M()
->table($this->_config['AUTH_GROUP_ACCESS'] . ' a')
->where("a.uid='$uid' and g.status='1'")
->join($this->_config['AUTH_GROUP']." g on a.group_id=g.id")
->field('id,rules')->select(); //原field方法的参数为field('rules'),增加id主要是获取用户组的id,便于验证超级管理员.
$groups[$uid]=$user_groups?:array();
建议官方在下次更新能添加id,或增加一个参数,便于用户灵活设置auth.zip ( 1.26 MB 下载:2854 次 )