Skip to content

Instantly share code, notes, and snippets.

@ChristianOellers
Created April 26, 2019 12:10
Show Gist options
  • Save ChristianOellers/1ebf9b4b7dc67f247a2a91ab017574a0 to your computer and use it in GitHub Desktop.
Save ChristianOellers/1ebf9b4b7dc67f247a2a91ab017574a0 to your computer and use it in GitHub Desktop.
Contao CMS - Reset directory CHMOD recursively to defaults
<?php
/**
* Set default CHMOD if you completely messed up a setup.
* By default the Contao CMS setup should reset the CHMOD.
*
* Copy to web root and run from a webbrowser.
*
* @param string $dir Base directory
* @param octal $dirModes Directory CHMOD
* @param octal $fileModes File CHMOD
*/
function AllDirChmod ($dir = './', $dirModes = 0755, $fileModes = 0644) {
$d = new RecursiveDirectoryIterator($dir);
foreach (new RecursiveIteratorIterator($d, 1) as $path) {
if ($path->isDir()) {
chmod($path, $dirModes);
}
else if (is_file($path)) {
chmod($path, $fileModes);
}
}
}
AllDirChmod('.');
echo 'AllDirChmod() finished.';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment