function recurse_chmod($mypath, $arg)
 {
     $d = opendir($mypath);
     while (($file = readdir($d)) !== false) {
         if ($file != "." && $file != "..") {
             $typepath = $mypath . "/" . $file;
             if (filetype($typepath) == 'dir') {
                 recurse_chmod($typepath, $arg);
             }
             chmod($typepath, $arg);
         }
     }
 }
 function recurse_chmod($mypath, $arg)
 {
     $d = opendir($mypath);
     while (($file = readdir($d)) !== false) {
         if ('.' !== $file && '..' !== $file) {
             $typepath = $mypath . '/' . $file;
             if ('dir' === filetype($typepath)) {
                 recurse_chmod($typepath, $arg);
             }
             chmod($typepath, $arg);
         }
     }
 }