5 class Integrity extends \Rsi\Fred\Security\Server{
16 if($this->root = \
Rsi\Http::docRoot())
$log->warning(
'Using default root: ' . $this->root,__FILE__,__LINE__);
17 else $log->error(
'No root set',__FILE__,__LINE__);
21 if(!$this->log) $this->log = \Rsi\File::tempDir() .
'integrity.log';
22 $files = \Rsi\File::unserialize($this->log,[]);
23 foreach(\
Rsi\File::find($this->root,[\
Rsi\File::FIND_FILTER_TYPE => \
Rsi\File::FIND_TYPE_FILE,\
Rsi\File::FIND_FILTER_NAME .
'//' => $this->filter],
true) as $filename => $info){
24 $hash = md5(file_get_contents($filename));
26 if(!array_key_exists($filename,$files)) $error =
'New file';
27 elseif($files[$filename] != $hash) $error =
'Changed file';
29 $log->error($error .
': ' . $filename,__FILE__,__LINE__);
30 $errors[$filename] = $error;
31 $files[$filename] = $hash;
34 \Rsi\File::serialize($this->log,$files,$this->mode);
$log
File to store statistics (in temp dir when empty).
$filter
Pattern for files to check.
$root
Root directory for check.
component($name)
Get a component (local or default).