If you are looking for code that can fix files and folder permissions in just one click here is the code to do it. Once you save it in a .php file and run it will run automatically locate the folder or directories and scan them after it will apply the give permissions to files and folders.
To use it copy the code below create a file with .php extension example ” fix.php in public_html folder or main directory of your website and open it with code editor by right click on it and paste the code and save it.
Then open the file in browser like: lvato.com/fix.php . Once you will open it in browser it will scan the folders and files and fix the permission by changing which you applied.
<?php
function chmod_r($dir, $dirPermissions, $filePermissions) {
$dp = opendir($dir);
while($file = readdir($dp)) {
if (($file == ".") || ($file == "..")) continue;
$fullPath = $dir. "/". $file;
if(is_dir($fullPath)) {
chmod($fullPath, $dirPermissions);
chmod_r($fullPath, $dirPermissions, $filePermissions);
} else {
chmod($fullPath, $filePermissions);
}
}
closedir($dp);
}
$startDir = dirname(__FILE__);
chmod_r($startDir, 0755, 0655);
echo "All folders and files in the directory have been found and their permissions have been set.";
?>