I need to use the $_SERVER["REMOTE_USER"] varible and .htgroup file and check to which of three groups the user belongs.
I tried:
<?php
$user = $_SERVER["REMOTE_USER"];
$groups = file ('/home/.htgroup');
$redgroup = explode(" ", $groups[0]);
$yellowgroup = explode(" ", $groups[1]);
$greengroup = explode(" ", $groups[2]);
if (in_array ($user, $redgroup)) {
print "Got $user in red";
}
if (in_array ($user, $yellowgroup)) {
print "Got $user in yellow";
}
if (in_array ($user, $greengroup)) {
print "Got $user in green";
}
?>
Unfortunately it doesn't seem to work that well... It seems that php won't accept that $redgroup, $yellowgroup and $greengroups are arrays. (They are, aren't they?) Because if I define them by writing
$redgroup =array ("John", "Mike", "Peter",);
then the in_array function works fine.
Any ideas as to what I'm missing?
Thanks,
Laajo