Created
July 30, 2015 03:26
-
-
Save sarathlal-old/78248ba89eef24f42720 to your computer and use it in GitHub Desktop.
A simple script to change folder & file permissions of Web Applications like WordPress, Magento etc.
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 | |
//Put this file on the installation folder and run script via browser. This script will change all folders permission as 755 & all file's permission as 644. | |
//Function to set file permissions to 0644 and folder permissions to 0755 | |
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 ); | |
} | |
} | |
echo "----------------------- CLEANUP START -------------------------<br/>"; | |
$start = (float) array_sum(explode(' ',microtime())); | |
echo "<br/>*************** SETTING PERMISSIONS ***************<br/>"; | |
echo "Setting all folder permissions to 755<br/>"; | |
echo "Setting all file permissions to 644<br/>"; | |
AllDirChmod( "." ); | |
$end = (float) array_sum(explode(' ',microtime())); | |
echo "<br/>------------ Files and folders permission changed in:". sprintf("%.4f", ($end-$start))." seconds ---------<br/>"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works very well, thanks!