The goal is to take the current working directory split it at /clients/
and see if the user is in
[something]/clients/[their username]/[something]
for example, the goal would be for input:
cwd = "/volumes/raid0/www/clients/mikey/test_folder/"
$session->username = "mikey"
to return with
$authorized = true
I would like this to recognize both UNIX and Windows paths, so it should look for "/" or "\". It is assumed that filenames won't contain these characters.
Also, the isAdmin()
bit is supposed to give admins access to all directories.
right now, PHP says:
Warning: unexpected regex error (8) in c:\apache\htdocs\clients\mikey\index.php on line 69
here's the code as it stands. (line 69 is noted in the comments.)
if($session->isAdmin())
{
$authorized = true;
}
else
{
// split cwd at the first instance of /clients/
$dir = spliti('%(\/|\\)clients(\/|\\)%',getcwd(),2); //this is line 69
if(count($dir) == 2) // if /clients/ was in cwd
{
// check if the second piece of cwd starts with the username.
$authorized = (preg_match('/^'.$session->username.'//*.$/', $dir[1]));
}
else
$authorized = false;
}