diff --git a/inc-public-global.php3 b/inc-public-global.php3
index b66f8c7507a0f8aa64a3b8b4bc0d7bd6308ef2d8..37ebf8c6ebe4d300e97780ac8b7a9e56198576ba 100644
--- a/inc-public-global.php3
+++ b/inc-public-global.php3
@@ -4,6 +4,8 @@ include ("ecrire/inc_version.php3");
 include_local ("inc-cache.php3");
 
 if ($INSECURE['fond'] || $INSECURE['delais']) exit;
+if (!isset($delais))
+	$delais = 1 * 3600;
 
 /*function t($s = '') {
 	global $t0, $t1;
diff --git a/spip_login.php3 b/spip_login.php3
index b1adf4a3f9e240aefe9c836b060197c69649af03..8011fff27b903196408c5cf0ee982ad32a19a204 100644
--- a/spip_login.php3
+++ b/spip_login.php3
@@ -2,6 +2,7 @@
 $fond = "login";
 $delais = 3600;
 $flag_dynamique = true;
+$flag_preserver = true;
 
 include ("inc-public.php3");
 
diff --git a/spip_test_dirs.php3 b/spip_test_dirs.php3
index 35724da1a570e02b333d8736778325db86b3e095..42bc88fd5263631de8bfba588553c3cc781b61b9 100644
--- a/spip_test_dirs.php3
+++ b/spip_test_dirs.php3
@@ -62,7 +62,18 @@ function absent_dirs($bad_dirs, $test_dir) {
 	install_fin_html();
 }
 
-
+//
+// Tente d'ecrire
+//
+function test_ecrire($my_dir) {
+	$ok = true;
+	$nom_fich = "$my_dir/test.txt";
+	$f = @fopen($nom_fich, "w");
+	if (!$f) $ok = false;
+	else if (!@fclose($f)) $ok = false;
+	else if (!@unlink($nom_fich)) $ok = false;
+	return $ok;
+}
 
 //
 // teste les droits sur les repertoires
@@ -72,36 +83,42 @@ $install = !file_exists("ecrire/inc_connect.php3");
 
 if ($test_dir)
 	$test_dirs[] = $test_dir;
-else
-	$test_dirs = array("CACHE", "IMG", "ecrire", "ecrire/data");
+else {
+	$test_dirs = array("CACHE", "IMG", "ecrire/data");
+	if ($install)
+		$test_dirs[] = "ecrire";
+}
 
 unset($bad_dirs);
 unset($absent_dirs);
 
 while (list(, $my_dir) = each($test_dirs)) {
-	$ok = true;
-	$nom_fich = "$my_dir/test.txt";
-	$f = @fopen($nom_fich, "w");
-	if (!$f) $ok = false;
-	else if (!@fclose($f)) $ok = false;
-	else if (!@unlink($nom_fich)) $ok = false;
-
-	if (!$ok) {
-		if (file_exists($my_dir))
-			$bad_dirs[] = "<LI>".$my_dir;
-		else
+	if (!test_ecrire($my_dir)) {
+		@umask(0); 
+		if (!@file_exists($my_dir))
+			mkdir($my_dir, 0777);
+
+		if (@file_exists($my_dir)) {
+			@chmod($my_dir, 0777);
+			if (!test_ecrire($my_dir))
+				@chmod($my_dir, 0775);
+			if (!test_ecrire($my_dir))
+				@chmod($my_dir, 0755);
+			if (!test_ecrire($my_dir))
+				$bad_dirs[] = "<LI>".$my_dir;
+		} else
 			$absent_dirs[] = "<LI>".$my_dir;
 	}
 }
 
-if ($absent_dirs) {
-	$absent_dirs = join(" ", $absent_dirs);
-	absent_dirs($absent_dirs, $test_dir);
-}
-else if ($bad_dirs) {
+if ($bad_dirs) {
 	$bad_dirs = join(" ", $bad_dirs);
 	bad_dirs($bad_dirs, $test_dir, $install);
 }
+else if ($absent_dirs) {
+	$absent_dirs = join(" ", $absent_dirs);
+	absent_dirs($absent_dirs, $test_dir);
+}
 else {
 	if ($install)
 		header("Location: ./ecrire/install.php3?etape=1");