1

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.

AstroCB
  • 12,337
  • 20
  • 57
  • 73
  • 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 Answers3

0

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.

RonaldBarzell
  • 3,822
  • 1
  • 16
  • 23
0

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.

ComFreek
  • 29,044
  • 18
  • 104
  • 156
0

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.

tonino.j
  • 3,837
  • 28
  • 27