You are here

function _auditfiles_get_exclusions in Audit Files 7.4

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

Creates an exclusion string.

This function creates a list of file and/or directory exclusions to be used with a preg_* function.

Return value

string The excluions.

1 call to _auditfiles_get_exclusions()
_auditfiles_not_in_database_get_file_list in ./auditfiles.notindatabase.inc
Recurse directories and add files to an array.

File

./auditfiles.notindatabase.inc, line 790
Generates a report showing files on the server, but not in the database.

Code

function _auditfiles_get_exclusions() {
  $exclusions_array = array();

  // Create the list of requested file exclusions.
  $files = trim(variable_get('auditfiles_exclude_files', '.htaccess'));
  if ($files) {
    $exclude_files = explode(';', $files);
    array_walk($exclude_files, '_auditfiles_make_preg', FALSE);
    $exclusions_array = array_merge($exclusions_array, $exclude_files);
  }

  // Create the list of requested path exclusions.
  $paths = trim(variable_get('auditfiles_exclude_paths', 'color css ctools js'));
  if ($paths) {
    $exclude_paths = explode(';', $paths);
    array_walk($exclude_paths, '_auditfiles_make_preg', TRUE);
    $exclusions_array = array_merge($exclusions_array, $exclude_paths);
  }

  // Create the list of requested extension exclusions. (This is a little more
  // complicated.)
  $extensions = trim(variable_get('auditfiles_exclude_extensions', ''));
  if ($extensions) {
    $exclude_extensions = explode(';', $extensions);
    array_walk($exclude_extensions, '_auditfiles_make_preg', FALSE);
    $extensions = implode('|', $exclude_extensions);

    // Add grouping around string & 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;
}