function _auditfiles_get_exclusions in Audit Files 7.3
Same name and namespace in other branches
- 6.3 notindb.admin.inc \_auditfiles_get_exclusions()
- 6.2 notindb.admin.inc \_auditfiles_get_exclusions()
- 7.4 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.
2 calls to _auditfiles_get_exclusions()
- _auditfiles_not_in_database_batch_display_get_files in ./
auditfiles.notindatabase.inc - Recurse directories and add files to an array.
- _auditfiles_not_in_database_get_files in ./
auditfiles.notindatabase.inc - Retrieves a list of files in the given path.
File
- ./
auditfiles.notindatabase.inc, line 1044 - Generates a report showing files on the server, but not in the database.
Code
function _auditfiles_get_exclusions() {
// Get the static paths necessary for processing the files.
$file_system_stream = variable_get('auditfiles_file_system_path', 'public');
// The full file system path to the Drupal root directory.
$real_files_path = drupal_realpath($file_system_stream . '://');
$user_data['real_files_path'] = $real_files_path;
$exclusions_array = array();
// Create the list of requested file exclusions.
$files = trim(variable_get('auditfiles_exclude_files', '.htaccess'));
if ($files) {
$exclude_files = explode(';', $files);
$user_data['make_file_path'] = FALSE;
array_walk($exclude_files, '_auditfiles_make_preg', $user_data);
$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);
$user_data['make_file_path'] = TRUE;
array_walk($exclude_paths, '_auditfiles_make_preg', $user_data);
$exclusions_array = array_merge($exclusions_array, $exclude_paths);
}
// Exclude other file streams that may be defined and in use.
$exclude_streams = array();
$auditfiles_file_system_path = variable_get('auditfiles_file_system_path', 'public');
$file_system_paths = file_get_stream_wrappers();
foreach ($file_system_paths as $file_system_path_id => $file_system_path) {
if ($file_system_path_id != $auditfiles_file_system_path) {
$uri = $file_system_path_id . '://';
if ($wrapper = file_stream_wrapper_get_instance_by_uri($uri)) {
$exclude_streams[] = $wrapper
->realpath();
}
}
}
$user_data['make_file_path'] = FALSE;
array_walk($exclude_streams, '_auditfiles_make_preg', $user_data);
$exclusions_array = array_merge($exclusions_array, $exclude_streams);
// 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);
$user_data['make_file_path'] = FALSE;
array_walk($exclude_extensions, '_auditfiles_make_preg', $user_data);
$extensions = implode('|', $exclude_extensions);
// Add grouping around string & end marker and append to exlusions_array.
$extensions = '(' . $extensions . ')$';
$exclusions_array[] = $extensions;
}
// Filter out any empty exclusions.
$exclusions_array = array_filter($exclusions_array);
// Implode exclusions array to a string.
$exclusions = implode('|', $exclusions_array);
// Return prepared exclusion string.
return $exclusions;
}