fix permissions

  1. <?php
  2.  
  3. file_fix_directory(dirname(__FILE__));
  4.  
  5. function file_fix_directory($dir, $nomask = array('.', '..', 'CVS')) {
  6.   if (is_dir($dir)) {
  7.      // Try to make each directory world writable.
  8.      if (@chmod($dir, 0777)) {
  9.        echo "<P>Made writable: " . $dir . "</p>";
  10.      }
  11.   }
  12.   if (is_dir($dir) && $handle = opendir($dir)) {
  13.     while (false !== ($file = readdir($handle))) {
  14.       if (!in_array($file, $nomask) && $file[0] != '.') {
  15.         if (is_dir("$dir/$file")) {
  16.           // Recurse into subdirectories
  17.           file_fix_directory("$dir/$file", $nomask);
  18.         }
  19.         else {
  20.           $filename = "$dir/$file";
  21.             // Try to make each file world writable.
  22.             if (@chmod($filename, 0666)) {
  23.               echo "<P>Made writable: " . $filename . "</p>";
  24.             }
  25.         }
  26.       }
  27.     }
  28.  
  29.     closedir($handle);
  30.   }
  31.  
  32. }
  33. ?>