You are here

function zoomapi_clean_filename in Zoom API 7.2

Clean up the file name, munging extensions and transliterating.

Parameters

string $filepath: A string containing a file name or full path. Only the file name will actually be modified.

Return value

string A file path with a cleaned-up file name.

See also

filefield_sources_clean_filename()

1 call to zoomapi_clean_filename()
zoomapi_api_download_recording in ./zoomapi.api.inc
Download Recording.

File

./zoomapi.module, line 1211
Main file for the Zoom API module.

Code

function zoomapi_clean_filename($filepath, $extensions = '') {
  $filename = basename($filepath);
  if (module_exists('transliteration')) {
    module_load_include('inc', 'transliteration');
    $langcode = NULL;
    if (!empty($_POST['language'])) {
      $languages = language_list();
      $langcode = isset($languages[$_POST['language']]) ? $_POST['language'] : NULL;
    }
    $filename = transliteration_clean_filename($filename, $langcode);
  }

  // Because this transfer mechanism does not use file_save_upload(), we need
  // to manually munge the filename to prevent dangerous extensions.
  // See file_save_upload().
  if (empty($extensions)) {
    $extensions = 'mp4 m4a';
  }
  $filename = file_munge_filename($filename, $extensions);
  $directory = drupal_dirname($filepath);
  return ($directory != '.' ? $directory . '/' : '') . $filename;
}