You are here

function advagg_missing_file_create_path in Advanced CSS/JS Aggregation 7

Same name and namespace in other branches
  1. 6 advagg.missing.inc \advagg_missing_file_create_path()

Make sure the destination is a complete path and resides in the file system directory, if it is not prepend the file system directory.

Parameters

$dest A string containing the path to verify. If this value is: omitted, Drupal's 'files' directory will be used.

Return value

A string containing the path to file, with file system directory appended if necessary, or FALSE if the path is invalid (i.e. outside the configured 'files' or temp directories).

1 call to advagg_missing_file_create_path()
advagg_missing_file_transfer in includes/missing.inc
Transfer file using http to client. Pipes a file through Drupal to the client.

File

includes/missing.inc, line 325
Advanced aggregation module; 404 handler.

Code

function advagg_missing_file_create_path($dest = 0) {
  list($css_path, $js_path) = advagg_get_root_files_dir();
  $valid_paths = array();
  $valid_paths[] = file_directory_path();
  $valid_paths[] = $css_path;
  $valid_paths[] = $js_path;
  foreach ($valid_paths as $file_path) {
    if (!$dest) {
      return $file_path;
    }

    // file_check_location() checks whether the destination is inside the Drupal files directory.
    if (file_check_location($dest, $file_path)) {
      return $dest;
    }
    else {
      if (file_check_location($dest, file_directory_temp())) {
        return $dest;
      }
      else {
        if (file_check_location($file_path . '/' . $dest, $file_path)) {
          return $file_path . '/' . $dest;
        }
      }
    }
  }

  // File not found.
  return FALSE;
}