If you like this, you could buy me a beer :)

Examples / Instructions

The snippet can be used in some different ways:

The full functioncall for the snippet is:

CheckFileSystem ($period , $maxchecks , $email_report , $force_debug , $filter_array )

where:

$period = the interval in minutes between 2 checks.

$maxchecks = the amount of files to check in a single run.

$email_report = the email address that should receive the mail with changed files.

$force_debug = an option to output all checks to the screen. Used on pages you call manually.

$filter_array = an array of directorynames that should not be scanned. Usefull for mail, stats and log directories in your webspace.

Used in your template

Somewhere in your template add the call:

<?php checkfilesystem ( 5 , 250, 'myaddress@mydomain.tld' ) ; ?>

This will check 250 files every 5 minutes, on every visit to your website. If any changes are found, they will be sent by email to myaddress@mydomain.tld

Used in a special hidden page

Create a page of the type "code" and add:

  checkfilesystem ( -1 , 1000 , 'myaddress@mydomain.tld', 0 , array('/awstats/','/stats/') ) ;

Get a (free) website-alive account somewhere and let them test your special hidden page.
The interval is determend by the website-alive account interval.
Groups of 1000 files will be tested, and any report will be sent by email to myaddress@mydomain.tld
Dirctories with either /stats/ or /awstats/ in the name will be skipped.
Note, this call could take some time. This can cause the website-alive service to generate an alarm. If this happens, lower the amount of pages to check to the point where no timeouts are reported.

Used in a hidden manual page

Create a password protected hidden page of the type "code" and add:

 checkfilesystem ( -1 , 0 , '', 2 ) ; 

Every time this page is opened by you, all files will be checked, and all checks are displayed on screen.
This is a long operation, so be aware it will take some time before you see any result.
The result is a long list, since it will also display all files that are not modified.

Setting the 4th parameter to 0 will only show changed or added files.
This is a good option if your website has many regular changes, but you still want to see every change or added file.
 

The first run!

The first time the snippet is called, it will fill it's database table with records for all files found in your webspace.
Since this is a very long lasting operation, use the "hidden manual page" method to do the first scan!