You are here

function backup_migrate_destination_files::test_file_readable_remotely in Backup and Migrate 8.3

Same name and namespace in other branches
  1. 8.2 includes/destinations.file.inc \backup_migrate_destination_files::test_file_readable_remotely()
  2. 6.3 includes/destinations.file.inc \backup_migrate_destination_files::test_file_readable_remotely()
  3. 6.2 includes/destinations.file.inc \backup_migrate_destination_files::test_file_readable_remotely()
  4. 7.3 includes/destinations.file.inc \backup_migrate_destination_files::test_file_readable_remotely()
  5. 7.2 includes/destinations.file.inc \backup_migrate_destination_files::test_file_readable_remotely()

Check if a file can be read remotely via http.

1 call to backup_migrate_destination_files::test_file_readable_remotely()
backup_migrate_destination_files::check_web_dir in includes/destinations.file.inc
Check that a web accessible directory has been properly secured, othewise attempt to secure it.

File

includes/destinations.file.inc, line 280
A destination type for saving locally to the server.

Class

backup_migrate_destination_files
A destination type for saving locally to the server.

Code

function test_file_readable_remotely($directory, $contents) {
  $real_dir = drupal_realpath($directory);
  $real_root = drupal_realpath(DRUPAL_ROOT);
  if ($real_dir && $real_root) {

    // Get the root relative path.
    $path = substr($real_dir, strlen($real_root));
    $url = $GLOBALS['base_url'] . str_replace('\\', '/', $path);
    $result = drupal_http_request($url);
    if (!empty($result->data) && strpos($result->data, $contents) !== FALSE) {
      return TRUE;
    }
  }
  return FALSE;
}