function _handleFile($file, $isDir = false, $flush = false) { // Take care of first scan if ($this->_isFirstScan) { $this->_mismatches[] = $file; return; } $data = null; $count = 0; $attribs = $this->_params->get('file_integrity_property_check', array()); if (!is_array($attribs)) { settype($attribs, 'array'); } if ($isDir) { if ($file) { $this->_dirs[$file] = 1; } $count = count($this->_dirs); $data =& $this->_dirs; $attribs = array_merge($attribs, array('permission')); $attribs = array_diff($attribs, array('hash_md')); } else { if ($file) { $this->_files[$file] = 1; } $count = count($this->_files); $data =& $this->_files; $attribs = array_merge($attribs, array('permission', 'size')); } if ($flush || $count > 50) { $model =& JModel::getInstance('Filesystem', 'JDefenderModel'); $files = $model->getFiles(array_keys($data)); // Process if ($files) { foreach ($files as $f) { $info =& JTable::getInstance('Filesystem', 'Table'); // what attribs of files to check // get file info if (!$info->loadFromFile($f->fullpath)) { return; } // Compare files $mismatch = $info->compare($f, $attribs); if ($mismatch) { // File is changed. $info = new stdClass(); $info->mismatch = $mismatch; $info->file = $file; $info->reason = 'changed'; $this->_mismatches[] = $info; } // :) unset($data[$f->fullpath]); } } // New files if (count($data)) { foreach ($data as $f => $dummy) { $info =& JTable::getInstance('Filesystem', 'Table'); if ($info->loadFromFile($f)) { $log = new stdClass(); $log->file = $f; $log->reason = 'new'; $log->mismatch = $info->compare(null, $attribs); $this->_mismatches[] = $log; } } } if ($isDir) { $this->_dirs = array(); } else { $this->_files = array(); } } }