diff --git a/.gitattributes b/.gitattributes
index bad91ba3da7e7bd083d77e706eac760fe1503ac2..80fc0a230d0b75635855c23e1ad5e7c02ce5a754 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -391,7 +391,6 @@ ecrire/action/regler_moderation.php -text
 ecrire/action/reorganiser.php -text
 ecrire/action/supprimer.php -text
 ecrire/action/supprimer_traduction.php -text
-ecrire/action/test_dirs.php -text
 ecrire/action/tester.php -text
 ecrire/action/tester_taille.php -text
 ecrire/action/tourner.php -text
@@ -616,6 +615,7 @@ ecrire/install/etape_1.php -text
 ecrire/install/etape_2.php -text
 ecrire/install/etape_3.php -text
 ecrire/install/etape_4.php -text
+ecrire/install/etape_chmod.php -text
 ecrire/install/etape_ldap1.php -text
 ecrire/install/etape_ldap2.php -text
 ecrire/install/etape_ldap3.php -text
diff --git a/ecrire/exec/export_all.php b/ecrire/exec/export_all.php
index dc906fea4c1188017c98bf584c2e8d99abced419..10ce6e4e5cef415081b6702aebc4f1834b29d375 100644
--- a/ecrire/exec/export_all.php
+++ b/ecrire/exec/export_all.php
@@ -27,12 +27,6 @@ function exec_export_all_dist()
 		$dir = _DIR_DUMP;
 	else $dir = determine_upload();
 
-	if (!is_writable($dir)) {
-		include_spip('inc/headers');
-		$dir = preg_replace(",^" . _DIR_RACINE .",", '', $dir);
-		redirige_par_entete(generer_test_dirs($dir, true));
-	}
-
 	// utiliser une version fraiche des metas (ie pas le cache)
 	include_spip('inc/meta');
 	lire_metas();
diff --git a/ecrire/exec/install.php b/ecrire/exec/install.php
index beeba8b1eafe168a948b4a2255824785b340548c..0c721096d42e46b7655c9ad4c87c44adb65af381 100644
--- a/ecrire/exec/install.php
+++ b/ecrire/exec/install.php
@@ -21,7 +21,7 @@ define('_FILE_TMP', '_install');
 function exec_install_dist()
 {
 	$etape = _request('etape');
-	if (_FILE_CONNECT) {
+	if (_FILE_CONNECT AND ($etape != 'chmod')) {
 		echo minipres();
 		exit;
 	}
diff --git a/ecrire/inc/flock.php b/ecrire/inc/flock.php
index 6c1db0cd85422da1834685976ef97c32087ece46..8f5cd1ae9c744fb70b5020f71b53e0e34c24988f 100644
--- a/ecrire/inc/flock.php
+++ b/ecrire/inc/flock.php
@@ -122,9 +122,12 @@ function raler_fichier($fichier)
 {
 	include_spip('inc/minipres');
 	$dir = dirname($fichier);
+	http_status(401);
 	echo minipres(_T('texte_inc_meta_2'), "<h4 style='color: red'>"
 		. _T('texte_inc_meta_1', array('fichier' => $fichier))
-		. " <a href='" . generer_test_dirs($dir) . "'>"
+		. " <a href='"
+		. generer_url_ecrire('install', "etape=chmod&test_dir=$dir")
+		. "'>"
 		. _T('texte_inc_meta_2')
 		. "</a> "
 		. _T('texte_inc_meta_3',
@@ -206,12 +209,11 @@ function sous_repertoire($base, $subdir='', $nobase = false, $tantpis=false) {
 		fclose($f);
 	else {
 		spip_log("echec creation $base${subdir}");
+		if ($tantpis) return '';
 		if (!_DIR_RESTREINT)
 			$base = preg_replace(',^' . _DIR_RACINE .',', '',$base);
 		if ($test) $base .= $subdir;
-		if ($tantpis) return '';
-		include_spip('inc/headers');
-		redirige_par_entete(generer_test_dirs($base, true));
+		raler_fichier($base . '/.ok');
 	}
 	spip_log("faux sous-repertoire $base${subdir}");
 	return "$baseaff${subdir}";
diff --git a/ecrire/inc/getdocument.php b/ecrire/inc/getdocument.php
index 8928c5c776a7267e8693aabe651ba60a59c8ad57..7c40b9bba7209895c3f7831b6cca264f71d74258 100644
--- a/ecrire/inc/getdocument.php
+++ b/ecrire/inc/getdocument.php
@@ -94,8 +94,8 @@ function deplacer_fichier_upload($source, $dest, $move=false) {
 		if ($f) {
 			fclose ($f);
 		} else {
-			include_spip('inc/headers');
-			redirige_par_entete(generer_test_dirs(dirname($dest), true));
+			include_spip('inc/flock');
+			raler_fichier($dest);
 		}
 		@unlink($dest);
 	}
diff --git a/ecrire/inc/headers.php b/ecrire/inc/headers.php
index 5dacb329deb20a3addd4e2bf0b6388f855712b62..50f57c3bf88f3aa52c8f3c3268e81ecce841895c 100644
--- a/ecrire/inc/headers.php
+++ b/ecrire/inc/headers.php
@@ -112,11 +112,4 @@ function envoie_image_vide() {
 }
 */
 
-// http://doc.spip.org/@generer_test_dirs
-function generer_test_dirs($arg='', $redirect=false)
-{
-	if (!is_string($redirect))
-		return  generer_url_public('', "action=test_dirs" . ($arg ? "&test_dir=$arg" : ''),  $redirect);
-	else return generer_form_public('test_dirs', $redirect);
-}
 ?>
diff --git a/ecrire/install/etape_.php b/ecrire/install/etape_.php
index d1f934909e6c6d36ef731e8a1aca611e9138fe5c..936a5ef2fe8155841046ccc37e92b4602efef51c 100644
--- a/ecrire/install/etape_.php
+++ b/ecrire/install/etape_.php
@@ -15,20 +15,19 @@ if (!defined("_ECRIRE_INC_VERSION")) return;	#securite
 // http://doc.spip.org/@inc_install_
 function install_etape__dist()
 {
-	include_spip('inc/headers');
 	utiliser_langue_visiteur();
 	$menu_langues = menu_langues('var_lang_ecrire');
 	if (!$menu_langues) {
-		redirige_par_entete(generer_test_dirs());
+		redirige_par_entete(generer_url_ecrire('install', "etape=chmod", true));
 	} else {
 		include_spip('inc/presentation'); // pour info_copyright
-		echo install_debut_html();
-		echo "<div><img alt='SPIP' src='" . _DIR_IMG_PACK . "logo-spip2.gif' /></div>\n",
-			"<div class='petit-centre'><p>",info_copyright(),"</p></div>\n",
-			"<p>",_T('install_select_langue'),"</p>",
-			"<div>",$menu_langues,"</div>\n",
-			generer_test_dirs('', bouton_suivant());
-		echo install_fin_html();
+
+		$res = "<div><img alt='SPIP' src='" . _DIR_IMG_PACK . "logo-spip2.gif' /></div>\n" .
+			"<div class='petit-centre'><p>" .info_copyright() ."</p></div>\n" .
+			"<p>" ._T('install_select_langue') ."</p>" .
+			"<div>" .$menu_langues ."</div>\n" .
+			generer_form_ecrire('install', "<input type='hidden' name='etape' value='chmod' />" . bouton_suivant());
+		echo minipres('AUTO', $res);
 	}
 }
 ?>
diff --git a/ecrire/action/test_dirs.php b/ecrire/install/etape_chmod.php
similarity index 80%
rename from ecrire/action/test_dirs.php
rename to ecrire/install/etape_chmod.php
index 99fa338dd4f79061a9ce2d36c4d70e1e46b21123..bfcfb769fde4110b5e6fbf34b64d91a3c10b18e4 100644
--- a/ecrire/action/test_dirs.php
+++ b/ecrire/install/etape_chmod.php
@@ -71,16 +71,15 @@ function test_ecrire($my_dir) {
 // rajouter celui passer dans l'url ou celui du source (a l'installation)
 //
 
-// http://doc.spip.org/@action_test_dirs_dist
-function action_test_dirs_dist()
+function install_etape_chmod_dist()
 {
 	global $test_dirs;
-	$test_dir = _request('test_dir');
+	$test_dir =  _request('test_dir');
 	$chmod = 0;
 
 	if ($test_dir) {
 		if (substr($test_dir,-1)!=='/') $test_dir .= '/';
-		if (!in_array($test_dir, $test_dirs)) $test_dirs[] = $test_dir;
+		if (!in_array($test_dir, $test_dirs)) $test_dirs[] = _DIR_RACINE  . $test_dir;
 	} else {
 		if (!_FILE_CONNECT)
 			$test_dirs[] = dirname(_FILE_CONNECT_INS).'/';
@@ -91,13 +90,13 @@ function action_test_dirs_dist()
 
 	while (list(, $my_dir) = each($test_dirs)) {
 		$test = test_ecrire($my_dir);
-		if (!test_ecrire($my_dir)) {
+		if (!$test) {
+			$m = preg_replace(',^' . _DIR_RACINE . ',', '',$my_dir);
 			if (@file_exists($my_dir)) {
-				$bad_dirs[] = "<li>".$my_dir."</li>";
+				$bad_dirs[] = "<li>".$m."</li>";
 			} else
-				$absent_dirs[] = "<li>".$my_dir."</li>";
-		}
-		$chmod = max($chmod, $test);
+				$absent_dirs[] = "<li>".$m."</li>";
+		} else $chmod = max($chmod, $test);
 	}
 
 	if ($bad_dirs OR $absent_dirs) {
@@ -124,19 +123,20 @@ function action_test_dirs_dist()
 			   array('bad_dirs' => join(" ", $absent_dirs))) .
 			"<b>". _T('login_recharger')."</b>.";
 	}
+	$res = "<p>" . $continuer  . $res . aide ("install0") . "</p>";
+
 	$t = _T('login_recharger');
-	$res = "<p>" . $continuer  . $res . aide ("install0") . "</p>" .
-	  generer_test_dirs('',
-		(!$test_dir ? "" : 
+	$t = (!$test_dir ? "" : 
 		 "<input type='hidden' name='test_dir' value='$test_dir' />")
-		 . "<div style='text-align: right'><input type='submit' class='fondl' value='$t' /></div>"); 
-	echo minipres($titre, $res);
-
- } else {
-	if (!_FILE_CONNECT)
-	  redirige_par_entete(generer_url_ecrire("install", "etape=1&chmod=".$chmod, true));
-	else
-		redirige_par_entete(_DIR_RESTREINT_ABS);
- }
+	. "<input type='hidden' name='etape' value='chmod' />"
+	. "<div style='text-align: right'><input type='submit' class='fondl' value='$t' /></div>"; 
+
+	echo minipres($titre, $res . generer_form_ecrire('install',  $t));
+
+	} else {
+		if (!_FILE_CONNECT)
+			redirige_par_entete(generer_url_ecrire("install", "etape=1&chmod=".$chmod, true));
+		else	redirige_par_entete(generer_url_ecrire());
+	}
 }
 ?>