Index: demo.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/demo/demo.module,v
retrieving revision 1.1.2.10
diff -u -p -r1.1.2.10 demo.module
--- demo.module	10 Sep 2007 20:12:14 -0000	1.1.2.10
+++ demo.module	19 Sep 2007 16:06:17 -0000
@@ -356,10 +356,20 @@ function demo_get_fileconfig($filename =
   $fileconfig['dumppath'] = $fileconfig['path'] . $fileconfig['site'];
   
   // Check if directory exists.
-  if (!file_check_directory($fileconfig['dumppath'], FILE_CREATE_DIRECTORY, 'path')) {
+  if (!file_check_directory($fileconfig['path'], FILE_CREATE_DIRECTORY, 'path') && !file_check_directory($fileconfig['dumppath'], FILE_CREATE_DIRECTORY, 'path')) {
     return false;
   }
   
+  // Protect dump files.
+  $htaccess = $fileconfig['path'] ."/.htaccess";
+  if (!is_file($htaccess)) {
+    $htaccess_lines = "# demo.module snapshots\n# Do not let the webserver serve anything under here!\n#\nDeny from all\n";
+    if (($fp = fopen($htaccess, 'w')) && fputs($fp, $htaccess_lines)) {
+      fclose($fp);
+      chmod($htaccess, 0664);
+    }
+  }
+    
   // Build SQL filename.
   $fileconfig['sql'] = $filename .'.sql';
   $fileconfig['sqlfile'] = $fileconfig['path'] . $fileconfig['site'] .'/'. $filename .'.sql';
