public function chown($mypath, $uid, $gid) { chown($mypath, $uid); chgrp($mypath, $gid); $d = opendir($mypath); while (($file = readdir($d)) !== false) { if ($file != "." && $file != "..") { $typepath = $mypath . "/" . $file; if (filetype($typepath) == 'dir') { recurse_chown_chgrp($typepath, $uid, $gid); } chown($typepath, $uid); chgrp($typepath, $gid); } } }
function recurse_chown_chgrp($mypath, $uid, $gid) { $d = opendir($mypath); while (($file = readdir($d)) !== false) { if ($file != "." && $file != "..") { $typepath = $mypath . "/" . $file; //print $typepath. " : " . filetype ($typepath). "<BR>" ; if (filetype($typepath) == 'dir') { recurse_chown_chgrp($typepath, $uid, $gid); } if (is_numeric($uid)) { chown($typepath, intval($uid)); } else { chown($typepath, $uid); } if (is_numeric($gid)) { chgrp($typepath, intval($gid)); } else { chgrp($typepath, $gid); } } } }