Created
April 26, 2019 12:10
-
-
Save ChristianOellers/1ebf9b4b7dc67f247a2a91ab017574a0 to your computer and use it in GitHub Desktop.
Contao CMS - Reset directory CHMOD recursively to defaults
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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