function _auditfiles_make_preg in Audit Files 5
Same name and namespace in other branches
- 6.3 notindb.admin.inc \_auditfiles_make_preg()
- 6.2 notindb.admin.inc \_auditfiles_make_preg()
- 7.4 auditfiles.notindatabase.inc \_auditfiles_make_preg()
- 7.3 auditfiles.notindatabase.inc \_auditfiles_make_preg()
Helper function: create an exclusion string for the preg
1 call to _auditfiles_make_preg()
- _auditfiles_filesnotindb in ./
auditfiles.module - Helper function - retrieve sorted list of files that are on the server but not in the database
File
- ./
auditfiles.module, line 397
Code
function _auditfiles_make_preg() {
// Get exclusion lists from the database
$files = trim(variable_get('auditfiles_exclude_files', '.htaccess'));
$extensions = trim(variable_get('auditfiles_exclude_extensions', ''));
$paths = trim(variable_get('auditfiles_exclude_paths', 'color'));
// Prepare an empty array
$exclusions_array = array();
// Create file exclusions as required
if ($files) {
$exclude_files = explode(' ', $files);
array_walk($exclude_files, '_auditfiles_preg_quote', FALSE);
$exclusions_array = array_merge($exclusions_array, $exclude_files);
}
// Create path exclusions as required
if ($paths) {
$exclude_paths = explode(' ', $paths);
array_walk($exclude_paths, '_auditfiles_preg_quote', TRUE);
$exclusions_array = array_merge($exclusions_array, $exclude_paths);
}
// Create extension exclusions as required (this is a little more complicated)
if ($extensions) {
// Prepare initial string as for files and paths
$exclude_extensions = explode(' ', $extensions);
array_walk($exclude_extensions, '_auditfiles_preg_quote', FALSE);
$extensions = implode('|', $exclude_extensions);
// Add grouping around string, add end marker, and append to exlusions_array
$extensions = '(' . $extensions . ')$';
$exclusions_array[] = $extensions;
}
// Implode exclusions array to a string
$exclusions = implode('|', $exclusions_array);
// Return prepared exclusion string
return $exclusions;
}