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

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

    • <bdo id='iU5k5'></bdo><ul id='iU5k5'></ul>
    <tfoot id='iU5k5'></tfoot>

        <legend id='iU5k5'><style id='iU5k5'><dir id='iU5k5'><q id='iU5k5'></q></dir></style></legend>
      1. 有没有办法在windows和linux上使用php检测文件夹中的变化?

        Is there a way to detect changes in a folder using php on both windows and linux?(有没有办法在windows和linux上使用php检测文件夹中的变化?)
          <i id='NCS4e'><tr id='NCS4e'><dt id='NCS4e'><q id='NCS4e'><span id='NCS4e'><b id='NCS4e'><form id='NCS4e'><ins id='NCS4e'></ins><ul id='NCS4e'></ul><sub id='NCS4e'></sub></form><legend id='NCS4e'></legend><bdo id='NCS4e'><pre id='NCS4e'><center id='NCS4e'></center></pre></bdo></b><th id='NCS4e'></th></span></q></dt></tr></i><div id='NCS4e'><tfoot id='NCS4e'></tfoot><dl id='NCS4e'><fieldset id='NCS4e'></fieldset></dl></div>

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

              <tbody id='NCS4e'></tbody>

            • <legend id='NCS4e'><style id='NCS4e'><dir id='NCS4e'><q id='NCS4e'></q></dir></style></legend>

                <tfoot id='NCS4e'></tfoot>
                  <bdo id='NCS4e'></bdo><ul id='NCS4e'></ul>

                • 本文介绍了有没有办法在windows和linux上使用php检测文件夹中的变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在寻找一种使用 php 检测文件夹更改的解决方案.该应用程序可以在两个平台(linuxwindows)上运行.只要结果相同,我可能会为每个平台使用不同的方法.我想要的是:

                  I'm looking for a solution to detect changes in folder(s) using php. The application may run on both platforms(linux and windows). I may use different methods for each platform as long as results are the same. What I desire is :

                  1. 如果将文件/文件夹添加到目录中,我希望我的应用检测到这个新文件并读取其属性(size,filetime 等)
                  2. 如果保存了现有文件/文件夹/更改/删除了内容,我需要检测此文件是否已更改
                  3. 如果我可以监视 apache 的 webroot 之外的基本文件夹(例如 c: mpd:music 在 windows 上或 /home/ertunc 在 linux 上)
                  1. If a file/folder is added to a directory, I want my app to detect this new file and read its attributes (size,filetime etc)
                  2. If a existing file/folder is saved/contents changed/deleted, I need to detect this file is changed
                  3. It would be better if I can monitor a base folder outside webroot of apache (such as c: mp, or d:music on windows or /home/ertunc on linux)

                  我在 inotify 上阅读了一些内容,但我不确定它是否满足我的需求.

                  I read something on inotify but I'm not sure it meets my needs.

                  推荐答案

                  因此,如果您正在与上次检查相比进行检查,而不仅仅是在更改后立即更新,您可以执行以下操作.

                  So if you are checking compared to the last time you checked rather than just being updated as soon as it changes you could do the following.

                  您可以创建一个目录的 MD5,存储此 MD5,然后将新的 MD5 与旧的进行比较,看看情况是否发生了变化.

                  You could create an MD5 of a directory, storew this MD5 then compare the new MD5 with the old to see if things have changed.

                  下面的函数取自 http://php.net/manual/en/function.md5-file.php 会为你做这件事.

                  The function below taken from http://php.net/manual/en/function.md5-file.php would do this for you.

                  function MD5_DIR($dir)
                  {
                      if (!is_dir($dir))
                      {
                          return false;
                      }
                  
                      $filemd5s = array();
                      $d = dir($dir);
                  
                      while (false !== ($entry = $d->read()))
                      {
                          if ($entry != '.' && $entry != '..')
                          {
                               if (is_dir($dir.'/'.$entry))
                               {
                                   $filemd5s[] = MD5_DIR($dir.'/'.$entry);
                               }
                               else
                               {
                                   $filemd5s[] = md5_file($dir.'/'.$entry);
                               }
                           }
                      }
                      $d->close();
                      return md5(implode('', $filemd5s));
                  }
                  

                  尽管如此,这相当低效,因为您可能知道,如果第一位不同,则检查目录的全部内容是没有意义的.

                  This is rather inefficient though, since as you probably know, there is no point checking the entire contents of a directory if the first bit is different.

                  这篇关于有没有办法在windows和linux上使用php检测文件夹中的变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Appending GET parameters to URL from lt;formgt; action(将 GET 参数附加到来自 lt;formgt; 的 URL行动)
                  Forcing quot;Save Asquot; dialog via jQuery GET(强制“另存为通过 jQuery GET 对话框)
                  PHP - get certain word from string(PHP - 从字符串中获取某个单词)
                  How to debug a get request in php using curl(如何使用 curl 在 php 中调试 get 请求)
                  get a # from a url in php(从 php 中的 url 获取 #)
                  PHP - include() file not working when variables are put in url?(PHP - 将变量放入 url 时,include() 文件不起作用?)
                    <bdo id='cQrOr'></bdo><ul id='cQrOr'></ul>
                      • <i id='cQrOr'><tr id='cQrOr'><dt id='cQrOr'><q id='cQrOr'><span id='cQrOr'><b id='cQrOr'><form id='cQrOr'><ins id='cQrOr'></ins><ul id='cQrOr'></ul><sub id='cQrOr'></sub></form><legend id='cQrOr'></legend><bdo id='cQrOr'><pre id='cQrOr'><center id='cQrOr'></center></pre></bdo></b><th id='cQrOr'></th></span></q></dt></tr></i><div id='cQrOr'><tfoot id='cQrOr'></tfoot><dl id='cQrOr'><fieldset id='cQrOr'></fieldset></dl></div>
                        1. <tfoot id='cQrOr'></tfoot>

                            <tbody id='cQrOr'></tbody>
                        2. <small id='cQrOr'></small><noframes id='cQrOr'>

                          <legend id='cQrOr'><style id='cQrOr'><dir id='cQrOr'><q id='cQrOr'></q></dir></style></legend>