title: set permissions for all files and folders recursively
body: <p>I want to recursively set the folder and file permissions. Folders should get 750 and files 644. I found <a href="http://www.php.de/php-tipps-2007/44154-ftp-chmod-rekursiv.html" rel="noreferrer">this</a> and made some adaptions. Would this one work?</p>
  
  <pre><code>&lt;?php
  
  function chmod_r($Path) {
     $dp = opendir($Path);
     while($File = readdir($dp)) {
        if($File != "." AND $File != "..") {
           if(is_dir($File)){
              chmod($File, 0750);
           }else{
               chmod($Path."/".$File, 0644);
               if(is_dir($Path."/".$File)) {
                  chmod_r($Path."/".$File);
               }
           }
        }
     }
     closedir($dp);
  }
  
  ?&gt; 
  </code></pre>