2020
2121$ config = array (
2222
23- 'md5file ' => 'tripwire_filelist.md5 ' , // File Containing the MD5 Keys
24- 'delim ' => '&&& ' , // Delimited for Filelist
23+ // File Containing the MD5 Keys
24+ 'md5file ' => 'tripwire_filelist.md5 ' ,
25+ // Delimited for Filelist
26+ 'delim ' => '&&& ' ,
2527
2628 'exclude ' => array (
27- 'files ' => array ( // Files to Exclude from Scanning
29+ // Specific Files to Exclude from Scanning
30+ 'files ' => array (
2831 '. ' ,
2932 '.. ' ,
3033 'tripwire_filelist.md5 ' ,
3134 'error_log ' ,
3235 'backup.zip ' ,
3336 '.bash_history '
3437 ) ,
35- 'extns ' => array ( // Extensions to Exclude from Scanning
36- 'flv ' ,
38+ // Extensions to Exclude from Scanning
39+ 'extensions ' => array (
40+ 'afm ' ,
41+ // Flash
42+ 'flv ' , 'swf ' ,
43+ // Images
44+ 'bmp ' , 'gif ' , 'jpeg ' , 'jpg ' , 'png ' , 'psd ' ,
3745 'log ' ,
3846 'txt ' ,
39- 'mp4 ' ,
40- 'mov ' ,
41- 'psd ' ,
42- 'swf ' ,
47+ // Videos
48+ 'mp4 ' , 'mov ' , 'ogv ' , 'webm ' ,
49+ // Dreamweaver
4350 'mno ' ,
44- ' jpg ' ,
45- 'aif ' ,
46- ' doc ' ,
47- 'webm ' ,
48- ' ogv ' ,
49- 'afm ' ,
50- ' sitx '
51- )
51+ // Audio
52+ 'aif ' , ' mp3 ' ,
53+ // Microsoft Word Files
54+ 'doc ' , ' docx ' , ' xls ' , ' xlsx ' ,
55+ // Compressed Files
56+ '7z ' , ' rar ' , ' sitx ' , ' zip '
57+ ) ,
58+ ' reg '
5259 ) ,
5360
5461 'email ' => array (
6572
6673function makeHash ( $ dir =false ){
6774 global $ config , $ filelist ;
68-
69- if ( !$ dir ) // Default to the Root of the Site the script is executed under
75+
76+ // If no Directory Specified, Default to the Root of the Site the script is executed under
77+ if ( !$ dir )
7078 $ dir = $ _SERVER ['DOCUMENT_ROOT ' ];
7179
72- if ( substr ( $ dir , -1 )=='/ ' ) // Strip slash from end of directory
80+ // If last character is a slash, strip it off the end
81+ if ( substr ( $ dir , -1 )=='/ ' )
7382 $ dir = substr ( $ dir , 0 , -1 );
7483
75- if ( !is_dir ( $ dir ) ) // If the supplied variable is not a Directory, terminate
84+ // If the supplied variable is not a Directory, terminate
85+ if ( !is_dir ( $ dir ) )
7686 return false ;
7787
7888 $ temp = array ();
7989 $ d = dir ( $ dir );
8090
81- while ( false !==( $ entry = $ d ->read () ) ){ // Loop through the files
82- if ( is_link ( $ entry ) ){
83- continue ; // Symbolic Link - Excluded
84- }
85- if ( in_array ( $ entry , $ config ['exclude ' ]['files ' ] ) ){
86- continue ; // Excluded File/Folder
87- }
88- if ( in_array ( pathinfo ( $ entry , PATHINFO_EXTENSION ) , $ config ['exclude ' ]['extns ' ] ) ){
89- continue ; // Excluded File Extension
90- }
91+ // Loop through the files
92+ while ( false !==( $ entry = $ d ->read () ) ){
93+ // Symbolic Link - Excluded
94+ if ( is_link ( $ entry ) )
95+ continue ;
96+
97+ // Excluded File/Folder
98+ if ( in_array ( $ entry , $ config ['exclude ' ]['files ' ] ) )
99+ continue ;
100+
101+ // Excluded File Extension
102+ if ( in_array ( pathinfo ( $ entry , PATHINFO_EXTENSION ) , $ config ['exclude ' ]['extensions ' ] ) )
103+ continue ;
104+
91105 if ( is_dir ( $ dir .'/ ' .$ entry ) ){
92106 // Recurse
93107 $ temp = array_merge ( $ temp , makeHash ( $ dir .'/ ' .$ entry ) );
@@ -173,7 +187,7 @@ function file_put_contents( $filename , $data ){
173187 || ( count ( $ new ) || count ( $ deleted ) || count ( $ modified ) ) ){ // Or a change was detected
174188
175189 # Update the file list
176-
190+
177191 // Init an Array for Lines
178192 $ log = array ();
179193
@@ -191,13 +205,14 @@ function file_put_contents( $filename , $data ){
191205
192206if ( count ( $ last ) // If there was a Filelist from the last run to compare against
193207 && ( count ( $ new ) || count ( $ deleted ) || count ( $ modified ) ) ){ // And changes occurred
194-
208+
195209 # Changes Detected
196-
197- if ( count ( $ config ['email ' ]['to ' ] ) ){ // If there are email addresses to notify
198-
210+
211+ // If there are email addresses to notify
212+ if ( count ( $ config ['email ' ]['to ' ] ) ){
213+
199214 # Compile the Email
200-
215+
201216 // Prepare the placeholder details
202217 $ body_replacements = array (
203218 '[AN] ' => count ( $ new ) ,
@@ -207,7 +222,7 @@ function file_put_contents( $filename , $data ){
207222 '[DN] ' => count ( $ deleted ) ,
208223 '[DF] ' => ( count ( $ deleted ) ? implode ( "\n" , $ deleted ) : 'No Files ' ) ,
209224 );
210-
225+
211226 // Prepare the recipients
212227 $ to = implode ( ', ' , $ config ['email ' ]['to ' ] );
213228 // Prepare the Subject Line
@@ -218,14 +233,14 @@ function file_put_contents( $filename , $data ){
218233 $ body_replacements ,
219234 $ config ['email ' ]['body ' ]
220235 );
221-
236+
222237 // Send it
223238 if ( mail ( $ to , $ title , $ body ) ){
224239 echo "Email Sent Successfully \n" ;
225240 }else {
226241 echo "Email Failed \n" ;
227242 }
228-
243+
229244 }
230245
231246}else {
0 commit comments