Created
June 11, 2013 10:05
Revisions
-
jasperf created this gist
Jun 11, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ <?php //http://www.webhostingtalk.com/showthread.php?t=218863 $start_dir = 'whatever'; // Starting directory no trailing slashes. $perms['file'] = 0644; // chmod value for files don't enclose value in quotes. $perms['folder'] = 0755; // chmod value for folders don't enclose value in quotes. function chmod_file_folder($dir) { global $perms; $dh=@opendir($dir); if ($dh) { while (false!==($file = readdir($dh))) { if($file!="." && $file!="..") { $fullpath = $dir .'/'. $file; if(!is_dir($fullpath)) { if(chmod($fullpath, $perms['file'])) { echo "\n<br><span style=\"font-weight:bold;\">File</span> ". $fullpath .' permissions changed to '. decoct($perms['file']); }else { echo "\n<br><span style=\"font-weight:bold; color:#ff0000;\">Failed</span> to set file permissions on ". $fullpath; } }else { if(chmod($fullpath, $perms['folder'])) { echo "\n<br><span style=\"font-weight:bold;\">Directory</span> ". $fullpath .' permissions changed to '. decoct($perms['folder']); chmod_file_folder($fullpath); }else { echo "\n<br><span style=\"font-weight:bold; color:#ff0000;\">Failed</span> to set directory permissions on ". $fullpath; } } } } closedir($dh); } } chmod_file_folder($start_dir); ?>