function backup_migrate_destination_files::check_web_dir

cis7 backup_migrate_destination_files::check_web_dir($directory)
cle7 backup_migrate_destination_files::check_web_dir($directory)
elmsmedia7 backup_migrate_destination_files::check_web_dir($directory)
icor7 backup_migrate_destination_files::check_web_dir($directory)
meedjum_blog7 backup_migrate_destination_files::check_web_dir($directory)
mooc7 backup_migrate_destination_files::check_web_dir($directory)

Check that a web accessible directory has been properly secured, othewise attempt to secure it.

1 call to backup_migrate_destination_files::check_web_dir()
backup_migrate_destination_files::check_dir in sites/all/modules/ulmus/backup_migrate/includes/
Prepare the destination directory for the backups.


sites/all/modules/ulmus/backup_migrate/includes/, line 194
A destination type for saving locally to the server.




function check_web_dir($directory) {
  // If the directory is specified with an absolute path, strip the site root.
  $directory = substr(drupal_realpath($directory), strlen(DRUPAL_ROOT . '/'));

  file_create_htaccess($directory, TRUE);

  // Check the user agent to make sure we're not responding to a request from drupal itself.
  // That should prevent infinite loops which could be caused by poormanscron in some circumstances.
  if (strpos($_SERVER['HTTP_USER_AGENT'], 'Drupal') !== FALSE) {
    return FALSE;

  // Check to see if the destination is publicly accessible
  $test_contents = "this file should not be publicly accessible";
  // Create the the text.txt file if it's not already there.
  if (!is_file($directory . '/test.txt') || file_get_contents($directory . '/test.txt') != $test_contents) {
    if ($fp = fopen($directory . '/test.txt', 'w')) {
      @fputs($fp, $test_contents);
    else {
      $message = t("Security notice: Backup and Migrate was unable to write a test text file to the destination directory %directory, and is therefore unable to check the security of the backup destination. Backups to the server will be disabled until the destination becomes writable and secure.", array('%directory' => $directory));
      drupal_set_message($message, "error");
      return FALSE;

  // Attempt to read the test file via http. This may fail for other reasons,
  // so it's not a bullet-proof check.
  if ($this->test_file_readable_remotely($directory . '/test.txt', $test_contents)) {
    $message = t("Security notice: Backup and Migrate will not save backup files to the server because the destination directory is publicly accessible. If you want to save files to the server, please secure the '%directory' directory", array('%directory' => $directory));
    drupal_set_message($message, "error");
    return FALSE;
  return $directory;



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.