You are here

function _auditfiles_get_exclusions in Audit Files 6.2

Same name and namespace in other branches
  1. 6.3 notindb.admin.inc \_auditfiles_get_exclusions()
  2. 7.4 auditfiles.notindatabase.inc \_auditfiles_get_exclusions()
  3. 7.3 auditfiles.notindatabase.inc \_auditfiles_get_exclusions()

Helper function: create an exclusion string for the preg

1 call to _auditfiles_get_exclusions()
_auditfiles_filesnotindb in ./notindb.admin.inc
Helper function - retrieve sorted list of files that are on the server but not in the database

File

./notindb.admin.inc, line 272
Callback and functions to generate files not in database report

Code

function _auditfiles_get_exclusions() {

  // Get exclusion lists from the variables table
  $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_make_preg', 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_make_preg', 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_make_preg', 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;
}