<tfoot id='gouKg'></tfoot>
  • <legend id='gouKg'><style id='gouKg'><dir id='gouKg'><q id='gouKg'></q></dir></style></legend>

    <small id='gouKg'></small><noframes id='gouKg'>

    1. <i id='gouKg'><tr id='gouKg'><dt id='gouKg'><q id='gouKg'><span id='gouKg'><b id='gouKg'><form id='gouKg'><ins id='gouKg'></ins><ul id='gouKg'></ul><sub id='gouKg'></sub></form><legend id='gouKg'></legend><bdo id='gouKg'><pre id='gouKg'><center id='gouKg'></center></pre></bdo></b><th id='gouKg'></th></span></q></dt></tr></i><div id='gouKg'><tfoot id='gouKg'></tfoot><dl id='gouKg'><fieldset id='gouKg'></fieldset></dl></div>

          <bdo id='gouKg'></bdo><ul id='gouKg'></ul>

        递归 chmod/chown/chgrp 目录中的所有文件和文件夹

        Recursively chmod/chown/chgrp all files and folder within a directory(递归 chmod/chown/chgrp 目录中的所有文件和文件夹)
        <i id='mX5G4'><tr id='mX5G4'><dt id='mX5G4'><q id='mX5G4'><span id='mX5G4'><b id='mX5G4'><form id='mX5G4'><ins id='mX5G4'></ins><ul id='mX5G4'></ul><sub id='mX5G4'></sub></form><legend id='mX5G4'></legend><bdo id='mX5G4'><pre id='mX5G4'><center id='mX5G4'></center></pre></bdo></b><th id='mX5G4'></th></span></q></dt></tr></i><div id='mX5G4'><tfoot id='mX5G4'></tfoot><dl id='mX5G4'><fieldset id='mX5G4'></fieldset></dl></div>

        1. <tfoot id='mX5G4'></tfoot><legend id='mX5G4'><style id='mX5G4'><dir id='mX5G4'><q id='mX5G4'></q></dir></style></legend>

              <bdo id='mX5G4'></bdo><ul id='mX5G4'></ul>

              <small id='mX5G4'></small><noframes id='mX5G4'>

                  <tbody id='mX5G4'></tbody>

                • 本文介绍了递归 chmod/chown/chgrp 目录中的所有文件和文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在一个建立其他网站的网站上工作.有些如果我使用 copy() 来创建文件和目录,其他时候我正在用 php 构建 XML 文件并使用 DOMDocument::save 来保存它们.最终结果是一个具有各种混乱权限的根文件夹.我一直在修改文件和文件夹,这在一定程度上是这样的,但在使用 copy() 时我特别遇到麻烦.

                  I am working on a site which builds other sites. Some if it I use copy() to create the files and directories, other times I'm building XML files in php and using DOMDocument::save to save them. The end result is a root folder with all sorts of messed up permissions. I've beening modding files and folders as I go, which words to some extent, but I'm particularly having trouble when it comes to using copy().

                  (这是我目前所处的位置http://pastebin.com/SBE8vtFX,请注意:function modPath($path))

                  (This is where I'm at so far http://pastebin.com/SBE8vtFX, attn: function modPath($path))

                  我想采用不同的方法,并chmod/chown/chgrp根据我的规范chmod/chown/chgrp将我的文档根目录中的所有文件和文件夹一次递归.

                  I want to take a different approach and recursively chmod/chown/chgrp all the files and folders within my document root to my specifications at once.

                  以文档根目录为例

                  /home/mysite/public_html
                  

                  public_html 中我有

                  -rwxrwxrwx  1 mysite mysite  348 Aug 31 10:49 index.php
                  d--------x  5 root   root   4096 Aug 30 10:21 folder1
                  drwxrwxrwx  2 mysite mysite 4096 Aug 30 09:41 folder2
                  


                  我的问题:

                  如何一次修改指定目录中的所有文件?我也想区分目录和文件夹之间的不同 chmod 设置.这需要一个 PHP 解决方案.


                  My question:

                  How can I mod all files within a specified directory at once? I want to differentiate different chmod settings between directories and folders as well. This needs to be a PHP solution.

                  这是我能做到的

                  <?php
                  
                      function modAll($root) {
                          
                          $aPath = explode("/", $root);
                          
                          $user = $aPath[2];
                          
                          /* Some sort of looping through $root */ {
                              
                              $mod = (is_dir($thisfileorfolder) ? 0755 : 0644);
                                      
                              chmod($thisfileorfolder, $mod);
                              chown($thisfileorfolder, $user);
                              chgrp($thisfileorfolder, $user);
                          }
                      }
                      
                  ?>
                  

                  推荐答案

                  这应该会有所帮助.更正了一些语法错误

                  This should be helpful. EDITED: some syntax errors corrected

                      function fsmodify($obj) {
                         $chunks = explode('/', $obj);
                         chmod($obj, is_dir($obj) ? 0755 : 0644);
                         chown($obj, $chunks[2]);
                         chgrp($obj, $chunks[2]);
                      }
                  
                  
                      function fsmodifyr($dir) 
                      {
                         if($objs = glob($dir."/*")) {        
                             foreach($objs as $obj) {
                                 fsmodify($obj);
                                 if(is_dir($obj)) fsmodifyr($obj);
                             }
                         }
                  
                         return fsmodify($dir);
                      }   
                  

                  这篇关于递归 chmod/chown/chgrp 目录中的所有文件和文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  <tfoot id='iHlis'></tfoot>

                    1. <small id='iHlis'></small><noframes id='iHlis'>

                        <bdo id='iHlis'></bdo><ul id='iHlis'></ul>
                        • <legend id='iHlis'><style id='iHlis'><dir id='iHlis'><q id='iHlis'></q></dir></style></legend>
                            <tbody id='iHlis'></tbody>
                        • <i id='iHlis'><tr id='iHlis'><dt id='iHlis'><q id='iHlis'><span id='iHlis'><b id='iHlis'><form id='iHlis'><ins id='iHlis'></ins><ul id='iHlis'></ul><sub id='iHlis'></sub></form><legend id='iHlis'></legend><bdo id='iHlis'><pre id='iHlis'><center id='iHlis'></center></pre></bdo></b><th id='iHlis'></th></span></q></dt></tr></i><div id='iHlis'><tfoot id='iHlis'></tfoot><dl id='iHlis'><fieldset id='iHlis'></fieldset></dl></div>