Good day guys..i'm currently working as an sys ad assistant. i just want to know if how can i know that a file from a directory(and it's subdirectory) has been modified..do i need to put every php code on a database? and is there a possibility to know which part of the file has been modified?thanks. please help.
-
You could use something like a filesystemwatcher to catch updates, or store md5 file hashes in a database and continually crawl the folder: http://stackoverflow.com/questions/540339/how-to-check-if-directory-contents-has-changed-with-php – mellamokb Nov 14 '12 at 18:45
-
pass hidden values when file modify.hidden value like date-time and file name to your database. – Ankur Saxena Nov 14 '12 at 18:52
3 Answers
Not sure what you mean by the database reference... but in general, if you know a file's creation date, you could check to see if filemtime is different from that. I'm a bit leery of using file modification times however; I've found some instances in which they were misleading, so take this with a grain of salt.
Outside of having a previous version of the file (via backup or a RCS), I can't think of how you'd see what part was modified.

- 3,822
- 1
- 16
- 23
-
Now i somehow find the answer. and it is by means of bash scripting..thnx for d help anyway. – Franz Darelle Sasondoncillo Ma Nov 19 '12 at 21:34
-
Would you mind posting the answer you found as a comment or answer? Someone might have a similar problem and stumble on this thread, and this could be very valuable to them. – RonaldBarzell Nov 19 '12 at 22:07
Use filemtime()
which will give you the last time that the file was changed.
But you cannot know any made differences as far as you aren't running a version control system.

- 29,044
- 18
- 104
- 156
Since you are working as sys ad assistant, I presume you can also use python. If so, consider using watchdog library. I think it is a perfect fit.
When you're at it, you can also use programatically, with python, linux/unix diff
command.
For this, you can also check out python sh module, which enables you to call diff
from your python code.
php is hardly perfect solution for your sysadmin needs. And python may be even easier to learn than php.

- 3,837
- 28
- 27