function _backup_migrate_clean_filename in Backup and Migrate 5.2
Same name and namespace in other branches
- 8.3 includes/files.inc \_backup_migrate_clean_filename()
- 5 backup_migrate.module \_backup_migrate_clean_filename()
- 6.3 includes/files.inc \_backup_migrate_clean_filename()
- 6 backup_migrate.module \_backup_migrate_clean_filename()
- 7.3 includes/files.inc \_backup_migrate_clean_filename()
Construct a filename using token and some cleaning.
2 calls to _backup_migrate_clean_filename()
- backup_migrate_perform_backup in ./
backup_migrate.module - Perform a backup with the given settings.
- _backup_migrate_default_filename in includes/
files.inc - Construct a default filename using the site's name.
File
- includes/
files.inc, line 349 - General file handling code for Backup and Migrate.
Code
function _backup_migrate_clean_filename($filename) {
if (module_exists('token') && function_exists('token_replace')) {
$filename = token_replace($filename, 'global');
}
$filename = preg_replace("/[^a-zA-Z0-9\\.\\-_]/", "", $filename);
if (drupal_strlen($filename) > 50) {
$filename = drupal_substr($filename, 0, 50);
}
if (drupal_strlen($filename) == 0) {
$filename = 'untitled';
}
return $filename;
}