Stefan Bellon wrote:
What I need to know is basically the information "which user can
access which file?"
In the meantime I've come up with a solution. Just in case somebody
else needs something similar, here is my PHP code:
<?php
## Read in the .htgroups file and build array of groups of array of
## users.
$tmp=file('.htg roups');
$groups=array() ;
foreach($tmp as $line)
{
$exploded=explo de(": ", $line);
$groups[$exploded[0]] = explode(" ", $exploded[1]);
}
## Read in the .htaccess file looking for group accesses for files.
$tmp=file('.hta ccess');
$file="";
$files=array();
foreach($tmp as $line)
{
## htmlentities necessary in order to get at HTML-like tags at all,
## but then they're escaped, so < and > are necessary.
if (ereg("<File s .*>", htmlentities($l ine)))
{
## We have a file section starting, so remember the file name.
$file=trim(ereg _replace("<F iles (.*)>", "\\1",
htmlentities($l ine)));
}
elseif (($file != "") &&
($file != "index.php" ) &&
(ereg("AuthName \".*\"", $line)))
{
## Get the authentication name of the file.
$files[$file]=array
('Name' => ereg_replace("A uthName \"(.*)\"", "\\1", $line),
'access' => 0);
}
elseif (($file != "") &&
($file != "index.php" ) &&
(ereg("Require user .*", $line)))
{
## We have a user permission.
$user=trim(ereg _replace("Requi re user (.*)", "\\1", $line));
if ($user == $_SERVER['REMOTE_USER'])
{
$files[$file]['access']=1;
}
}
elseif (($file != "") &&
($file != "index.php" ) &&
(ereg("Require group .*", $line)))
{
## We have a group permission, so get the group.
$group=trim(ere g_replace("Requ ire group (.*)", "\\1", $line));
## Look in the users of the group whether REMOTE_USER is listed.
foreach($groups[$group] as $user)
{
if ($user == $_SERVER['REMOTE_USER'])
{
$files[$file]['access']=1;
break;
}
}
}
}
## Do whatever HTML stuff you want here, and later on:
## Now loop through the file permission data and built HTML code.
foreach($files as $file => $data)
{
if (($data['access'] == 1) && (file_exists($f ile)))
{
## Do something with $file and/or data['Name']
}
}
## Rest of HTML stuff.
?>
--
Stefan Bellon