Provides various official and user-released code examples. For code reference, you are welcome to exchange and learn about a permission authentication class you have written. It is very convenient to support wildcard definition.
QQ group number for this code: 148397843
The source code is updated again and two bugs have been modified.
I. Installation Method:
1. Run the database. SQL file in mysql.
2. Copy Antauth. class. php to the ThinkPHP \ Library \ Think folder.
Ii. Call method:
You can use the asterisk (*) as a wildcard for authentication, for example:
Admin/Index /*
Admin/*/Index
+ Code.1 permission Verification:
If (C ('auth _ config ')){
$ Auth = new \ Think \ Antauth ();
$ Check = $ Auth-> check (MODULE_NAME. '/'. CONTROLLER_NAME. '/'. ACTION_NAME, 'user id ');
If (! $ Check ){
$ This-> error ('You do not have this permission yet, please contact the postmaster if necessary ');
} Else {
$ This-> success ('passes permission verification! ');
}
}+ Code.2 Logon:
$ Auth = new \ Think \ Antauth ();
$ Info = $ Auth-> login ('user id', 'username', 'Password ');
If ($ info> 0 ){
$ This-> success ('logon successful ');
} Else {
$ This-> error ($ this-> getMessage ($ info ));
}+ Code.3 registration:
$ Auth = new \ Think \ Antauth ();
$ Data = array ('username' => 'abc ',
'Password' => '123 ',
'Repassword' => '123 ',
'Email '=> 'abc @ aaa.com ',
);
$ Info = $ Auth-> regUser ($ data );
If ($ info> 0 ){
$ This-> success ('registration successful! ');
} Else {
$ This-> error ($ this-> getMessage ($ info ));
}
AntAuth-beta0.1.1-20140902.zip (8.46 KB download: 79 times)
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB