I want to recursively set the folder and file permissions. Folders should get 750 and files 644. I found this and made some adaptions. Would this one work?
My solution will change all files and folder recursively to 0777. I use DirecotryIterator, it's much cleaner instead of opendir and while loop.
function chmod_r($path) {
$dir = new DirectoryIterator($path);
foreach ($dir as $item) {
chmod($item->getPathname(), 0777);
if ($item->isDir() && !$item->isDot()) {
chmod_r($item->getPathname());
}
}
}