I am a beginner with the htaccess use, i searched an answer on google but didn’t find something good to me.
I would like to do something easy to understand (so I’m sure there is a proper way to do it) but don’t know how to do.
I have those 3 files:
.htaccess
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /path/.htpasswd
AuthGroupFile /path/.htgroups
require group intern
require group extern
require group test
.htpasswd
user1:xxx
user2:yyy
user3:zzz
.htgroups
group1:user1 user3
group2:user2
And in php i would like to make a test on the group. I will have a lot of user in some groups and i will add and remove some so i don’t want to do :
if($_SERVER['PHP_AUTH_USER'] == 'user1' || $_SERVER['PHP_AUTH_USER'] == 'user2')
but
if($group == 'group1')
Could you help finding an easy way to get this variable $group ?
Thanks a lot,
Bastien
After some research on php.net, i found a way by matching a pattern in a file (here in .htgoups), so i did this function to get a group of a logged user.