diff options
author | Loui Chang <louipc.ist@gmail.com> | 2008-11-09 22:35:00 -0500 |
---|---|---|
committer | Loui Chang <louipc.ist@gmail.com> | 2008-11-13 15:19:26 -0500 |
commit | f12b11abc70b03fa75faf211a6311acb1cc1b32d (patch) | |
tree | 7c43e9a46d0a560d1bd6f550c105b8179543fc05 /web/lib | |
parent | 2ac75bd81278a6a51d3eef56e9088c198a887a6d (diff) | |
download | aurweb-f12b11abc70b03fa75faf211a6311acb1cc1b32d.tar.xz |
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>
Diffstat (limited to 'web/lib')
-rw-r--r-- | web/lib/aur.inc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/web/lib/aur.inc b/web/lib/aur.inc index a126bb9..d08ff0c 100644 --- a/web/lib/aur.inc +++ b/web/lib/aur.inc @@ -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="") |