Give group writable permissions to uploaded files.

Add a new function chown_group to recursively change permissions.
Tweak some of the coding style.
Replace some of the redundant string concatenation with a variable.

Thanks to Dan McGee for chmod_group.

Signed-off-by: Loui Chang <louipc.ist@gmail.com>
This commit is contained in:
Loui Chang 2008-11-09 22:35:00 -05:00
parent 2ac75bd812
commit f12b11abc7
2 changed files with 47 additions and 17 deletions

View file

@ -381,6 +381,34 @@ function rm_rf($dirname="") {
return;
}
# Recursive chmod to set group write permissions
#
function chmod_group($path) {
if (!is_dir($path))
return chmod($path, 0664);
$d = dir($path);
while ($f = $d->read()) {
if ($f != '.' && $f != '..') {
$fullpath = $path.'/'.$f;
if (is_link($fullpath))
continue;
elseif (!is_dir($fullpath)) {
if (!chmod($fullpath, 0664))
return FALSE;
}
elseif(!chmod_group($fullpath))
return FALSE;
}
}
$d->close();
if(chmod($path, 0775))
return TRUE;
else
return FALSE;
}
# obtain the uid given a Users.Username
#
function uid_from_username($username="")