From 07a8dcdc05f40c4675630ac18c6b52ec29292ca3 Mon Sep 17 00:00:00 2001
From: Cerdic <cedric@yterium.com>
Date: Sun, 6 Apr 2008 23:31:17 +0000
Subject: [PATCH] permettre l'import securise depuis une version stable
 precedente : - recreer un jeu de table avec l'ancienne structure et un
 prefixe different - importer dedans - mettre a jour - recopier TODO :
 remonter a des versions stables plus anciennes etre sur que le prefixe
 temporaire est bien disponible interpoler entre versions stables par une maj
 partielle reprise sur timeout pendant la recopie traiter les tables des
 plugins qui sont ignores dans le process

---
 .gitattributes                               |  10 +
 ecrire/base/import_all.php                   |   3 +
 ecrire/inc/import.php                        |  53 +++
 ecrire/maj/vieille_base/1917/auxiliaires.php | 328 ++++++++++++++++
 ecrire/maj/vieille_base/1917/create.php      |  62 +++
 ecrire/maj/vieille_base/1917/serial.php      | 386 +++++++++++++++++++
 ecrire/maj/vieille_base/1917/typedoc.php     | 197 ++++++++++
 ecrire/maj/vieille_base/1927/auxiliaires.php | 329 ++++++++++++++++
 ecrire/maj/vieille_base/1927/create.php      |  52 +++
 ecrire/maj/vieille_base/1927/serial.php      | 372 ++++++++++++++++++
 ecrire/maj/vieille_base/1927/typedoc.php     | 211 ++++++++++
 ecrire/maj/vieille_base/charger.php          |  47 +++
 ecrire/maj/vieille_base/create.php           |  56 +++
 13 files changed, 2106 insertions(+)
 create mode 100644 ecrire/maj/vieille_base/1917/auxiliaires.php
 create mode 100644 ecrire/maj/vieille_base/1917/create.php
 create mode 100644 ecrire/maj/vieille_base/1917/serial.php
 create mode 100644 ecrire/maj/vieille_base/1917/typedoc.php
 create mode 100644 ecrire/maj/vieille_base/1927/auxiliaires.php
 create mode 100644 ecrire/maj/vieille_base/1927/create.php
 create mode 100644 ecrire/maj/vieille_base/1927/serial.php
 create mode 100644 ecrire/maj/vieille_base/1927/typedoc.php
 create mode 100644 ecrire/maj/vieille_base/charger.php
 create mode 100644 ecrire/maj/vieille_base/create.php

diff --git a/.gitattributes b/.gitattributes
index dd833d4395..d85a146ef3 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -754,6 +754,16 @@ ecrire/maj/v017.php -text
 ecrire/maj/v018.php -text
 ecrire/maj/v019.php -text
 ecrire/maj/v019_pre193.php -text
+ecrire/maj/vieille_base/1917/auxiliaires.php -text
+ecrire/maj/vieille_base/1917/create.php -text
+ecrire/maj/vieille_base/1917/serial.php -text
+ecrire/maj/vieille_base/1917/typedoc.php -text
+ecrire/maj/vieille_base/1927/auxiliaires.php -text
+ecrire/maj/vieille_base/1927/create.php -text
+ecrire/maj/vieille_base/1927/serial.php -text
+ecrire/maj/vieille_base/1927/typedoc.php -text
+ecrire/maj/vieille_base/charger.php -text
+ecrire/maj/vieille_base/create.php -text
 ecrire/prive.php -text
 ecrire/public/index.php -text
 ecrire/public/jointures.php -text
diff --git a/ecrire/base/import_all.php b/ecrire/base/import_all.php
index 6d993f1e73..115524adf3 100644
--- a/ecrire/base/import_all.php
+++ b/ecrire/base/import_all.php
@@ -110,6 +110,9 @@ function import_all_fin($request) {
 	effacer_meta('version_archive_restauration');
 	effacer_meta('tag_archive_restauration');
 	effacer_meta('restauration_charset_sql_connexion');
+	effacer_meta('attributs_archive_restauration');
+	effacer_meta('restauration_table_prefix');
+	effacer_meta('vieille_version_installee');
 	if ($request['insertion'] == 'passe2') 
 		sql_drop_table("spip_translate");
 	 
diff --git a/ecrire/inc/import.php b/ecrire/inc/import.php
index 0215f31fbb..f401eabf95 100644
--- a/ecrire/inc/import.php
+++ b/ecrire/inc/import.php
@@ -184,6 +184,17 @@ function detruit_restaurateur()
 function import_tables($request, $dir) {
 	global $import_ok, $abs_pos,  $affiche_progression_pourcent;
 
+	// regarder si on est pas en train d'importer dans une copie des tables
+	if (isset($GLOBALS['meta']['restauration_table_prefix'])) {
+		$charger = charger_fonction('charger','maj/vieille_base');
+		$charger($GLOBALS['meta']['vieille_version_installee']);
+		$GLOBALS['serveur_vieille_base'] = 0;
+		$GLOBALS['connexions'][$GLOBALS['serveur_vieille_base']]['prefixe'] = $GLOBALS['meta']['restauration_table_prefix'];
+		// recharger les metas
+		lire_metas();
+	}
+
+
 	$abs_pos = (!isset($GLOBALS['meta']["status_restauration"])) ? 0 :
 		$GLOBALS['meta']["status_restauration"];
 
@@ -274,6 +285,33 @@ function import_tables($request, $dir) {
 		$res = '';
 		affiche_progression_javascript('100 %', $size);
 	}
+	
+	if ($GLOBALS['spip_version'] != (str_replace(',','.',$GLOBALS['meta']['version_installee']))){
+		include_spip('base/upgrade');
+		maj_base(); // upgrade jusqu'a la version courante
+	}
+	// regarder si on est pas en train d'importer dans une copie des tables
+	if (isset($GLOBALS['meta']['restauration_table_prefix_source'])){
+		$prefixe_source = $GLOBALS['meta']['restauration_table_prefix_source'];
+		
+		$GLOBALS['connexions']['-1'] = $GLOBALS['connexions'][0];
+		// rebasculer le serveur sur les bonnes tables pour finir proprement
+		$GLOBALS['connexions'][0]['prefixe'] = $prefixe_source;
+
+		$tables = import_table_choix($request);
+		// recopier les tables l'une sur l'autre
+		// il FAUT recharger les bonnes desc serial/aux avant ...
+		$GLOBALS['tables_principales'] = $GLOBALS['nouvelle_base']['tables_principales'];
+		$GLOBALS['tables_auxiliaires'] = $GLOBALS['nouvelle_base']['tables_auxiliaires'];
+		foreach ($tables as $table){
+			$res = sql_select('*',$table,'','','','','','-1');
+			while ($row = sql_fetch($res,'-1')){
+				sql_insertq($table,$row);
+			}
+			sql_drop_table($table,'','-1');
+		}
+	}
+	
 
 	return $res ;
 }
@@ -281,6 +319,21 @@ function import_tables($request, $dir) {
 // http://doc.spip.org/@import_init_meta
 function import_init_meta($tag, $atts, $charset, $request)
 {
+	$version_base = $atts['version_base'];
+	if (version_compare($version_base,$GLOBALS['spip_version'],'<')
+	 && !isset($GLOBALS['meta']['restauration_table_prefix'])
+	 && ($request['insertion']!='on')
+	 && ($request['insertion']!='passe2')){
+		// effacer les tables ici
+		$init = $request['init'];
+		$init($request);
+
+		// creer une base avec les tables dans l'ancienne version
+		// et changer de contexte
+		$creer_base_anterieure = charger_fonction('create','maj/vieille_base');
+		$creer_base_anterieure($version_base);
+	}
+	
 	$version_archive = $atts['version_archive'];
 	$insert = $request['insertion'] ;
 	ecrire_meta('attributs_archive_restauration', serialize($atts),'non');
diff --git a/ecrire/maj/vieille_base/1917/auxiliaires.php b/ecrire/maj/vieille_base/1917/auxiliaires.php
new file mode 100644
index 0000000000..d0610dcc85
--- /dev/null
+++ b/ecrire/maj/vieille_base/1917/auxiliaires.php
@@ -0,0 +1,328 @@
+<?php
+
+/***************************************************************************\
+ *  SPIP, Systeme de publication pour l'internet                           *
+ *                                                                         *
+ *  Copyright (c) 2001-2006                                                *
+ *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
+ *                                                                         *
+ *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
+ *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
+\***************************************************************************/
+
+
+if (!defined("_ECRIRE_INC_VERSION")) return;
+
+$spip_petitions = array(
+		"id_article"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"email_unique"	=> "CHAR (3) NOT NULL",
+		"site_obli"	=> "CHAR (3) NOT NULL",
+		"site_unique"	=> "CHAR (3) NOT NULL",
+		"message"	=> "CHAR (3) NOT NULL",
+		"texte"	=> "LONGBLOB NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_petitions_key = array(
+		"PRIMARY KEY"	=> "id_article");
+
+$spip_visites = array(
+		"date"	=> "DATE NOT NULL",
+		"visites"	=> "INT UNSIGNED NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_visites_key = array(
+		"PRIMARY KEY"	=> "date");
+
+$spip_visites_articles = array(
+		"date"	=> "DATE NOT NULL",
+		"id_article"	=> "INT UNSIGNED NOT NULL",
+		"visites"	=> "INT UNSIGNED NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_visites_articles_key = array(
+		"PRIMARY KEY"	=> "date, id_article");
+
+$spip_referers = array(
+		"referer_md5"	=> "BIGINT UNSIGNED NOT NULL",
+		"date"		=> "DATE NOT NULL",
+		"referer"	=> "VARCHAR (255) NOT NULL",
+		"visites"	=> "INT UNSIGNED NOT NULL",
+		"visites_jour"	=> "INT UNSIGNED NOT NULL",
+		"visites_veille"=> "INT UNSIGNED NOT NULL",
+		"maj"		=> "TIMESTAMP");
+
+$spip_referers_key = array(
+		"PRIMARY KEY"	=> "referer_md5");
+
+$spip_referers_articles = array(
+		"id_article"	=> "INT UNSIGNED NOT NULL",
+		"referer_md5"	=> "BIGINT UNSIGNED NOT NULL",
+		"date"		=> "DATE NOT NULL",
+		"referer"	=> "VARCHAR (255) NOT NULL",
+		"visites"	=> "INT UNSIGNED NOT NULL",
+		"maj"		=> "TIMESTAMP");
+
+$spip_referers_articles_key = array(
+		"PRIMARY KEY"	=> "id_article, referer_md5",
+		"KEY referer_md5"	=> "referer_md5");
+
+$spip_auteurs_articles = array(
+		"id_auteur"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_article"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_auteurs_articles_key = array(
+		"PRIMARY KEY"	=> "id_auteur, id_article",
+		"KEY id_article"	=> "id_article");
+
+$spip_auteurs_rubriques = array(
+		"id_auteur"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_rubrique"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_auteurs_rubriques_key = array(
+		"PRIMARY KEY"	=> "id_auteur, id_rubrique",
+		"KEY id_rubrique"	=> "id_rubrique");
+
+$spip_auteurs_messages = array(
+		"id_auteur"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_message"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"vu"		=> "CHAR (3) NOT NULL");
+
+$spip_auteurs_messages_key = array(
+		"PRIMARY KEY"	=> "id_auteur, id_message",
+		"KEY id_message"	=> "id_message");
+
+
+$spip_documents_articles = array(
+		"id_document"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_article"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_documents_articles_key = array(
+		"KEY id_document"	=> "id_document",
+		"KEY id_article"	=> "id_article");
+
+$spip_documents_rubriques = array(
+		"id_document"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_rubrique"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_documents_rubriques_key = array(
+		"KEY id_document"	=> "id_document",
+		"KEY id_rubrique"	=> "id_rubrique");
+
+$spip_documents_breves = array(
+		"id_document"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_breve"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_documents_breves_key = array(
+		"KEY id_document"	=> "id_document",
+		"KEY id_breve"	=> "id_breve");
+
+$spip_mots_articles = array(
+		"id_mot"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_article"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_mots_articles_key = array(
+		"PRIMARY KEY"	=> "id_article, id_mot",
+		"KEY id_mot"	=> "id_mot");
+
+$spip_mots_breves = array(
+		"id_mot"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_breve"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_mots_breves_key = array(
+		"PRIMARY KEY"	=> "id_breve, id_mot",
+		"KEY id_mot"	=> "id_mot");
+
+$spip_mots_rubriques = array(
+		"id_mot"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_rubrique"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_mots_rubriques_key = array(
+		"PRIMARY KEY"	=> "id_rubrique, id_mot",
+		"KEY id_mot"	=> "id_mot");
+
+$spip_mots_syndic = array(
+		"id_mot"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_syndic"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_mots_syndic_key = array(
+		"PRIMARY KEY"	=> "id_syndic, id_mot",
+		"KEY id_mot"	=> "id_mot");
+
+$spip_mots_forum = array(
+		"id_mot"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_forum"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_mots_forum_key = array(
+		"PRIMARY KEY"	=> "id_forum, id_mot",
+		"KEY id_mot"	=> "id_mot");
+
+$spip_mots_documents = array(
+		"id_mot"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_document"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_mots_documents_key = array(
+		"PRIMARY KEY"	=> "id_document, id_mot",
+		"KEY id_mot"	=> "id_mot");
+
+$spip_meta = array(
+		"nom"	=> "VARCHAR (255) NOT NULL",
+		"valeur"	=> "text DEFAULT ''",
+		"maj"	=> "TIMESTAMP");
+
+$spip_meta_key = array(
+		"PRIMARY KEY"	=> "nom");
+
+$spip_index = array(
+ 		"`hash`"	=> "BIGINT UNSIGNED NOT NULL",
+ 		"points"	=> "INT UNSIGNED DEFAULT '0' NOT NULL",
+		"id_objet"	=> "INT UNSIGNED NOT NULL",
+		"id_table"	=> "TINYINT UNSIGNED NOT NULL"	);
+
+$spip_index_key = array(
+ 		"KEY `hash`"	=> "`hash`",
+		"KEY id_objet"	=> "id_objet",
+		"KEY id_table"	=> "id_table");
+
+$spip_index_dico = array(
+		"`hash`"	=> "BIGINT UNSIGNED NOT NULL",
+		"dico"		=> "VARCHAR (30) NOT NULL");
+
+$spip_index_dico_key = array(
+		"PRIMARY KEY"	=> "dico");
+
+$spip_versions = array (
+		"id_article"	=> "bigint(21) NOT NULL",
+		"id_version"	=> "int unsigned DEFAULT '0' NOT NULL",
+		"date"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"id_auteur"	=> "bigint(21) NOT NULL",
+		"titre_version"	=> "text DEFAULT '' NOT NULL",
+		"permanent"	=> "char(3) NOT NULL",
+		"champs"	=> "text NOT NULL");
+
+$spip_versions_key = array (
+		"PRIMARY KEY"	=> "id_article, id_version",
+		"KEY date"	=> "id_article, date",
+		"KEY id_auteur"	=> "id_auteur");
+
+$spip_versions_fragments = array(
+		"id_fragment"	=> "int unsigned DEFAULT '0' NOT NULL",
+		"version_min"	=> "int unsigned DEFAULT '0' NOT NULL",
+		"version_max"	=> "int unsigned DEFAULT '0' NOT NULL",
+		"id_article"	=> "bigint(21) NOT NULL",
+		"compress"	=> "tinyint NOT NULL",
+		"fragment"	=> "longblob NOT NULL");
+
+$spip_versions_fragments_key = array(
+	     "PRIMARY KEY"	=> "id_article, id_fragment, version_min");
+
+$spip_caches = array(
+		"fichier" => "char (64) NOT NULL",
+		"id" => "char (64) NOT NULL",
+		// i=par id, t=timer, x=suppression
+		"type" => "CHAR (1) DEFAULT 'i' NOT NULL",
+		"taille" => "integer DEFAULT '0' NOT NULL");
+$spip_caches_key = array(
+		"PRIMARY KEY"	=> "fichier, id",
+		"KEY fichier" => "fichier",
+		"KEY id" => "id");
+
+$spip_ortho_cache = array(
+	"lang" => "VARCHAR(10) NOT NULL",
+	"mot" => "VARCHAR(255) BINARY NOT NULL",
+	"ok" => "TINYINT NOT NULL",
+	"suggest" => "BLOB NOT NULL",
+	"maj" => "TIMESTAMP");
+$spip_ortho_cache_key = array(
+	"PRIMARY KEY" => "lang, mot",
+	"KEY maj" => "maj");
+
+$spip_ortho_dico = array(
+	"lang" => "VARCHAR(10) NOT NULL",
+	"mot" => "VARCHAR(255) BINARY NOT NULL",
+	"id_auteur" => "BIGINT UNSIGNED NOT NULL",
+	"maj" => "TIMESTAMP");
+$spip_ortho_dico_key = array(
+	"PRIMARY KEY" => "lang, mot");
+
+
+
+
+global $tables_auxiliaires;
+
+$tables_auxiliaires['spip_petitions'] = array(
+	'field' => &$spip_petitions,
+	'key' => &$spip_petitions_key
+);
+$tables_auxiliaires['spip_visites'] = array(
+	'field' => &$spip_visites,
+	'key' => &$spip_visites_key);
+$tables_auxiliaires['spip_visites_articles'] = array(
+	'field' => &$spip_visites_articles,
+	'key' => &$spip_visites_articles_key);
+$tables_auxiliaires['spip_referers'] = array(
+	'field' => &$spip_referers,
+	'key' => &$spip_referers_key);
+$tables_auxiliaires['spip_referers_articles'] = array(
+	'field' => &$spip_referers_articles,
+	'key' => &$spip_referers_articles_key);
+$tables_auxiliaires['spip_auteurs_articles'] = array(
+	'field' => &$spip_auteurs_articles,
+	'key' => &$spip_auteurs_articles_key);
+$tables_auxiliaires['spip_auteurs_rubriques'] = array(
+	'field' => &$spip_auteurs_rubriques,
+	'key' => &$spip_auteurs_rubriques_key);
+$tables_auxiliaires['spip_auteurs_messages'] = array(
+	'field' => &$spip_auteurs_messages,
+	'key' => &$spip_auteurs_messages_key);
+$tables_auxiliaires['spip_documents_articles'] = array(
+	'field' => &$spip_documents_articles,
+	'key' => &$spip_documents_articles_key);
+$tables_auxiliaires['spip_documents_rubriques'] = array(
+	'field' => &$spip_documents_rubriques,
+	'key' => &$spip_documents_rubriques_key);
+$tables_auxiliaires['spip_documents_breves'] = array(
+	'field' => &$spip_documents_breves,
+	'key' => &$spip_documents_breves_key);
+$tables_auxiliaires['spip_mots_articles'] = array(
+	'field' => &$spip_mots_articles,
+	'key' => &$spip_mots_articles_key);
+$tables_auxiliaires['spip_mots_breves'] = array(
+	'field' => &$spip_mots_breves,
+	'key' => &$spip_mots_breves_key);
+$tables_auxiliaires['spip_mots_rubriques'] = array(
+	'field' => &$spip_mots_rubriques,
+	'key' => &$spip_mots_rubriques_key);
+$tables_auxiliaires['spip_mots_syndic'] = array(
+	'field' => &$spip_mots_syndic,
+	'key' => &$spip_mots_syndic_key);
+$tables_auxiliaires['spip_mots_forum'] = array(
+	'field' => &$spip_mots_forum,
+	'key' => &$spip_mots_forum_key);
+$tables_auxiliaires['spip_mots_documents'] = array(
+	'field' => &$spip_mots_documents,
+	'key' => &$spip_mots_documents_key);
+$tables_auxiliaires['spip_meta'] = array(
+	'field' => &$spip_meta,
+	'key' => &$spip_meta_key);
+$tables_auxiliaires['spip_index'] = array(
+	'field' => &$spip_index,
+	'key' => &$spip_index_key);
+$tables_auxiliaires['spip_index_dico'] = array(
+	'field' => &$spip_index_dico,
+	'key' => &$spip_index_dico_key);
+$tables_auxiliaires['spip_versions'] = array(
+	'field' => &$spip_versions,
+	'key' => &$spip_versions_key);
+$tables_auxiliaires['spip_versions_fragments'] = array(
+	'field' => &$spip_versions_fragments,
+	'key' => &$spip_versions_fragments_key);
+$tables_auxiliaires['spip_caches'] = array(
+	'field' => &$spip_caches,
+	'key' => &$spip_caches_key);
+$tables_auxiliaires['spip_ortho_cache'] = array(
+	'field' => &$spip_ortho_cache,
+	'key' => &$spip_ortho_cache_key);
+$tables_auxiliaires['spip_ortho_dico'] = array(
+	'field' => &$spip_ortho_dico,
+	'key' => &$spip_ortho_dico_key);
+?>
diff --git a/ecrire/maj/vieille_base/1917/create.php b/ecrire/maj/vieille_base/1917/create.php
new file mode 100644
index 0000000000..5057e10c30
--- /dev/null
+++ b/ecrire/maj/vieille_base/1917/create.php
@@ -0,0 +1,62 @@
+<?php
+
+/***************************************************************************\
+ *  SPIP, Systeme de publication pour l'internet                           *
+ *                                                                         *
+ *  Copyright (c) 2001-2006                                                *
+ *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
+ *                                                                         *
+ *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
+ *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
+\***************************************************************************/
+
+if (!defined("_ECRIRE_INC_VERSION")) return;
+include_spip('maj/vieille_base/1917/serial');
+include_spip('maj/vieille_base/1917/auxiliaires');
+include_spip('maj/vieille_base/1917/typedoc');
+
+// http://doc.spip.org/@creer_base
+function maj_vieille_base_1917_create() {
+  global $tables_principales, $tables_auxiliaires, $tables_images, $tables_sequences, $tables_documents, $tables_mime;
+
+	// ne pas revenir plusieurs fois (si, au contraire, il faut pouvoir
+	// le faire car certaines mises a jour le demandent explicitement)
+	# static $vu = false;
+	# if ($vu) return; else $vu = true;
+
+	foreach($tables_principales as $k => $v)
+		spip_create_table($k, $v['field'], $v['key'], true);
+
+	foreach($tables_auxiliaires as $k => $v)
+		spip_create_table($k, $v['field'], $v['key'], false);
+
+	foreach($tables_images as $k => $v)
+		spip_query("INSERT IGNORE INTO spip_types_documents (extension, inclus, titre, id_type) VALUES ('$k', 'image', '" .
+			      (is_numeric($v) ?
+			       (strtoupper($k) . "', $v") :
+			       "$v', 0") .
+			      ")");
+
+	foreach($tables_sequences as $k => $v)
+		spip_query("INSERT IGNORE INTO spip_types_documents (extension, titre, inclus) VALUES ('$k', '$v', 'embed')");
+
+	foreach($tables_documents as $k => $v)
+		spip_query("INSERT IGNORE INTO spip_types_documents (extension, titre, inclus) VALUES ('$k', '$v', 'non')");
+
+	foreach ($tables_mime as $extension => $type_mime)
+	  spip_query("UPDATE spip_types_documents
+		SET mime_type='$type_mime' WHERE extension='$extension'");
+}
+/*
+// http://doc.spip.org/@stripslashes_base
+function stripslashes_base($table, $champs) {
+	$modifs = '';
+	reset($champs);
+	while (list(, $champ) = each($champs)) {
+		$modifs[] = $champ . '=REPLACE(REPLACE(' .$champ. ',"\\\\\'", "\'"), \'\\\\"\', \'"\')';
+	}
+	spip_query("UPDATE $table SET ".join(',', $modifs));
+
+}*/
+
+?>
\ No newline at end of file
diff --git a/ecrire/maj/vieille_base/1917/serial.php b/ecrire/maj/vieille_base/1917/serial.php
new file mode 100644
index 0000000000..767d0973df
--- /dev/null
+++ b/ecrire/maj/vieille_base/1917/serial.php
@@ -0,0 +1,386 @@
+<?php
+
+/***************************************************************************\
+ *  SPIP, Systeme de publication pour l'internet                           *
+ *                                                                         *
+ *  Copyright (c) 2001-2006                                                *
+ *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
+ *                                                                         *
+ *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
+ *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
+\***************************************************************************/
+
+
+if (!defined("_ECRIRE_INC_VERSION")) return;
+
+
+$spip_articles = array(
+		"id_article"	=> "bigint(21) NOT NULL",
+		"surtitre"	=> "text NOT NULL",
+		"titre"	=> "text NOT NULL",
+		"soustitre"	=> "text NOT NULL",
+		"id_rubrique"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"descriptif"	=> "text NOT NULL",
+		"chapo"	=> "mediumtext NOT NULL",
+		"texte"	=> "longblob NOT NULL",
+		"ps"	=> "mediumtext NOT NULL",
+		"date"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"statut"	=> "varchar(10) DEFAULT '0' NOT NULL",
+		"id_secteur"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"maj"	=> "TIMESTAMP",
+		"export"	=> "VARCHAR(10) DEFAULT 'oui'",
+		"date_redac"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"visites"	=> "INTEGER DEFAULT '0' NOT NULL",
+		"referers"	=> "INTEGER DEFAULT '0' NOT NULL",
+		"popularite"	=> "DOUBLE DEFAULT '0' NOT NULL",
+		"accepter_forum"	=> "CHAR(3) NOT NULL",
+		"date_modif"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"lang"		=> "VARCHAR(10) DEFAULT '' NOT NULL",
+		"langue_choisie"	=> "VARCHAR(3) DEFAULT 'non'",
+		"id_trad"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"extra"		=> "longblob NULL",
+		"idx"		=> "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL",
+		"id_version"	=> "int unsigned DEFAULT '0' NOT NULL",
+		"nom_site"	=> "tinytext NOT NULL",
+		"url_site"	=> "VARCHAR(255) NOT NULL",
+		"url_propre" => "VARCHAR(255) NOT NULL");
+
+$spip_articles_key = array(
+		"PRIMARY KEY"		=> "id_article",
+		"KEY id_rubrique"	=> "id_rubrique",
+		"KEY id_secteur"	=> "id_secteur",
+		"KEY id_trad"		=> "id_trad",
+		"KEY lang"			=> "lang",
+		"KEY statut"		=> "statut, date",
+		"KEY url_site"		=> "url_site",
+		"KEY date_modif"	=> "date_modif",
+		"KEY idx"			=> "idx",
+		"KEY url_propre"	=> "url_propre");
+
+$spip_auteurs = array(
+		"id_auteur"	=> "bigint(21) NOT NULL",
+		"nom"	=> "text NOT NULL",
+		"bio"	=> "text NOT NULL",
+		"email"	=> "tinytext NOT NULL",
+		"nom_site"	=> "tinytext NOT NULL",
+		"url_site"	=> "text NOT NULL",
+		"login"	=> "VARCHAR(255) BINARY NOT NULL",
+		"pass"	=> "tinytext NOT NULL",
+		"low_sec"	=> "tinytext NOT NULL",
+		"statut"	=> "VARCHAR(255) NOT NULL",
+		"maj"	=> "TIMESTAMP",
+		"pgp"	=> "BLOB NOT NULL",
+		"htpass"	=> "tinyblob NOT NULL",
+		"en_ligne"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"imessage"	=> "VARCHAR(3) NOT NULL",
+		"messagerie"	=> "VARCHAR(3) NOT NULL",
+		"alea_actuel"	=> "tinytext NOT NULL",
+		"alea_futur"	=> "tinytext NOT NULL",
+		"prefs"	=> "tinytext NOT NULL",
+		"cookie_oubli"	=> "tinytext NOT NULL",
+		"source"	=> "VARCHAR(10) DEFAULT 'spip' NOT NULL",
+		"lang"	=> "VARCHAR(10) DEFAULT '' NOT NULL",
+		"idx"		=> "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL",
+		"url_propre" => "VARCHAR(255) NOT NULL",
+		"extra"	=> "longblob NULL");
+
+$spip_auteurs_key = array(
+		"PRIMARY KEY"	=> "id_auteur",
+		"KEY login"	=> "login",
+		"KEY statut"	=> "statut",
+		"KEY lang"	=> "lang",
+		"KEY idx"	=> "idx",
+		"KEY en_ligne"	=> "en_ligne",
+		"KEY url_propre"	=> "url_propre");
+
+$spip_breves = array(
+		"id_breve"	=> "bigint(21) NOT NULL",
+		"date_heure"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"titre"	=> "text NOT NULL",
+		"texte"	=> "longblob NOT NULL",
+		"lien_titre"	=> "text NOT NULL",
+		"lien_url"	=> "text NOT NULL",
+		"statut"	=> "varchar(6) NOT NULL",
+		"id_rubrique"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"lang"	=> "VARCHAR(10) DEFAULT '' NOT NULL",
+		"langue_choisie"	=> "VARCHAR(3) DEFAULT 'non'",
+		"maj"	=> "TIMESTAMP",
+		"idx"		=> "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL",
+		"extra"	=> "longblob NULL",
+		"url_propre" => "VARCHAR(255) NOT NULL");
+
+$spip_breves_key = array(
+		"PRIMARY KEY"	=> "id_breve",
+		"KEY idx"	=> "idx",
+		"KEY id_rubrique"	=> "id_rubrique",
+		"KEY url_propre"	=> "url_propre");
+
+$spip_messages = array(
+		"id_message"	=> "bigint(21) NOT NULL",
+		"titre"	=> "text NOT NULL",
+		"texte"	=> "longblob NOT NULL",
+		"type"	=> "varchar(6) NOT NULL",
+		"date_heure"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"date_fin"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"rv"	=> "varchar(3) NOT NULL",
+		"statut"	=> "varchar(6) NOT NULL",
+		"id_auteur"	=> "bigint(21) NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_messages_key = array(
+		"PRIMARY KEY"	=> "id_message",
+		"KEY id_auteur"	=> "id_auteur");
+
+$spip_mots = array(
+		"id_mot"	=> "bigint(21) NOT NULL",
+		"titre"	=> "text NOT NULL",
+		"descriptif"	=> "text NOT NULL",
+		"texte"	=> "longblob NOT NULL",
+		"id_groupe"	=> "bigint(21) NOT NULL",
+		"type"	=> "text NOT NULL",
+		"extra"	=> "longblob NULL",
+		"idx"		=> "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL",
+		"url_propre" => "VARCHAR(255) NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_mots_key = array(
+		"PRIMARY KEY"	=> "id_mot",
+		"KEY idx"	=> "idx",
+		"KEY url_propre"	=> "url_propre");
+
+$spip_groupes_mots = array(
+		"id_groupe"	=> "bigint(21) NOT NULL",
+		"titre"	=> "text NOT NULL",
+		"descriptif"	=> "text NOT NULL",
+		"texte"	=> "longblob NOT NULL",
+		"unseul"	=> "varchar(3) NOT NULL",
+		"obligatoire"	=> "varchar(3) NOT NULL",
+		"articles"	=> "varchar(3) NOT NULL",
+		"breves"	=> "varchar(3) NOT NULL",
+		"rubriques"	=> "varchar(3) NOT NULL",
+		"syndic"	=> "varchar(3) NOT NULL",
+		"minirezo"	=> "varchar(3) NOT NULL",
+		"comite"	=> "varchar(3) NOT NULL",
+		"forum"	=> "varchar(3) NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_groupes_mots_key = array(
+		"PRIMARY KEY"	=> "id_groupe");
+
+$spip_rubriques = array(
+		"id_rubrique"	=> "bigint(21) NOT NULL",
+		"id_parent"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"titre"	=> "text NOT NULL",
+		"descriptif"	=> "text NOT NULL",
+		"texte"	=> "longblob NOT NULL",
+		"id_secteur"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"maj"	=> "TIMESTAMP",
+		"export"	=> "VARCHAR(10) DEFAULT 'oui'",
+		"id_import"	=> "BIGINT DEFAULT '0'",
+		"statut"	=> "VARCHAR(10) NOT NULL",
+		"date"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"lang"	=> "VARCHAR(10) DEFAULT '' NOT NULL",
+		"langue_choisie"	=> "VARCHAR(3) DEFAULT 'non'",
+		"idx"		=> "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL",
+		"extra"	=> "longblob NULL",
+		"url_propre" => "VARCHAR(255) NOT NULL",
+		"statut_tmp"	=> "VARCHAR(10) NOT NULL",
+		"date_tmp"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL"
+		);
+
+$spip_rubriques_key = array(
+		"PRIMARY KEY"	=> "id_rubrique",
+		"KEY lang"	=> "lang",
+		"KEY idx"	=> "idx",
+		"KEY id_parent"	=> "id_parent",
+		"KEY url_propre"	=> "url_propre");
+
+$spip_documents = array(
+		"id_document"	=> "bigint(21) NOT NULL",
+		"id_vignette"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"id_type"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"titre"	=> "text NOT NULL",
+		"date"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"descriptif"	=> "text NOT NULL",
+		"fichier"	=> "varchar(255) NOT NULL",
+		"taille"	=> "integer NOT NULL",
+		"largeur"	=> "integer NOT NULL",
+		"hauteur"	=> "integer NOT NULL",
+		"mode"	=> "ENUM('vignette', 'document') NOT NULL",
+		"distant"	=> "VARCHAR(3) DEFAULT 'non'",
+		"idx"		=> "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_documents_key = array(
+		"PRIMARY KEY"	=> "id_document",
+		"KEY id_vignette"	=> "id_vignette",
+		"KEY mode"	=> "mode",
+		"KEY id_type"	=> "id_type");
+
+$spip_types_documents = array(
+		"id_type"	=> "bigint(21) NOT NULL",
+		"titre"	=> "text NOT NULL",
+		"descriptif"	=> "text NOT NULL",
+		"extension"	=> "varchar(10) NOT NULL",
+		"mime_type"	=> "varchar(100) NOT NULL",
+		"inclus"	=> "ENUM('non', 'image', 'embed') NOT NULL DEFAULT 'non'",
+		"upload"	=> "ENUM('oui', 'non') NOT NULL DEFAULT 'oui'",
+		"maj"	=> "TIMESTAMP");
+
+$spip_types_documents_key = array(
+		"PRIMARY KEY"	=> "id_type",
+		"UNIQUE extension"	=> "extension",
+		"KEY inclus"	=> "inclus");
+
+$spip_syndic = array(
+		"id_syndic"	=> "bigint(21) NOT NULL",
+		"id_rubrique"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"id_secteur"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"nom_site"	=> "blob NOT NULL",
+		"url_site"	=> "blob NOT NULL",
+		"url_syndic"	=> "blob NOT NULL",
+		"descriptif"	=> "blob NOT NULL",
+		"url_propre"	=> "VARCHAR(255) NOT NULL",
+		"idx"		=> "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL",
+		"maj"	=> "TIMESTAMP",
+		"syndication"	=> "VARCHAR(3) NOT NULL",
+		"statut"	=> "VARCHAR(10) NOT NULL",
+		"date"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"date_syndic"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"date_index"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"extra"			=> "longblob NULL",
+		"moderation"	=> "VARCHAR(3) DEFAULT 'non'",
+		"miroir"	=> "VARCHAR(3) DEFAULT 'non'",
+		"oubli"	=> "VARCHAR(3) DEFAULT 'non'",
+		"resume"	=> "VARCHAR(3) DEFAULT 'oui'"
+);
+
+$spip_syndic_key = array(
+		"PRIMARY KEY"	=> "id_syndic",
+		"KEY id_rubrique"	=> "id_rubrique",
+		"KEY id_secteur"	=> "id_secteur",
+		"KEY idx"		=> "idx",
+		"KEY statut"	=> "statut, date_syndic",
+		"KEY url_propre"	=> "url_propre");
+
+$spip_syndic_articles = array(
+		"id_syndic_article"	=> "bigint(21) NOT NULL",
+		"id_syndic"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"titre"	=> "text NOT NULL",
+		"url"	=> "VARCHAR(255) NOT NULL",
+		"date"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"lesauteurs"	=> "text NOT NULL",
+		"maj"	=> "TIMESTAMP",
+		"statut"	=> "VARCHAR(10) NOT NULL",
+		"descriptif"	=> "blob NOT NULL",
+		"lang"	=> "VARCHAR(10) DEFAULT '' NOT NULL",
+		"url_source" => "TINYTEXT DEFAULT '' NOT NULL",
+		"source" => "TINYTEXT DEFAULT '' NOT NULL",
+		"tags" => "TEXT DEFAULT '' NOT NULL");
+
+$spip_syndic_articles_key = array(
+		"PRIMARY KEY"	=> "id_syndic_article",
+		"KEY id_syndic"	=> "id_syndic",
+		"KEY statut"	=> "statut",
+		"KEY url"	=> "url");
+
+$spip_forum = array(
+		"id_forum"	=> "bigint(21) NOT NULL",
+		"id_parent"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"id_thread"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"id_rubrique"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"id_article"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"id_breve"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"date_heure"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"titre"	=> "text NOT NULL",
+		"texte"	=> "mediumtext NOT NULL",
+		"auteur"	=> "text NOT NULL",
+		"email_auteur"	=> "text NOT NULL",
+		"nom_site"	=> "text NOT NULL",
+		"url_site"	=> "text NOT NULL",
+		"statut"	=> "varchar(8) NOT NULL",
+		"idx"		=> "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL",
+		"ip"	=> "varchar(16)",
+		"maj"	=> "TIMESTAMP",
+		"id_auteur"	=> "BIGINT DEFAULT '0' NOT NULL",
+		"id_message"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"id_syndic"	=> "bigint(21) DEFAULT '0' NOT NULL");
+
+$spip_forum_key = array(
+		"PRIMARY KEY"	=> "id_forum",
+		"KEY id_parent"	=> "id_parent",
+		"KEY id_article"	=> "id_article",
+		"KEY id_breve"	=> "id_breve",
+		"KEY id_message"	=> "id_message",
+		"KEY id_syndic"	=> "id_syndic",
+		"KEY id_rubrique"	=> "id_rubrique",
+		"KEY idx"	=> "idx",
+		"KEY statut"	=> "statut, date_heure");
+
+$spip_signatures = array(
+		"id_signature"	=> "bigint(21) NOT NULL",
+		"id_article"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"date_time"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"nom_email"	=> "text NOT NULL",
+		"ad_email"	=> "text NOT NULL",
+		"nom_site"	=> "text NOT NULL",
+		"url_site"	=> "text NOT NULL",
+		"message"	=> "mediumtext NOT NULL",
+		"statut"	=> "varchar(10) NOT NULL",
+		"idx"		=> "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_signatures_key = array(
+		"PRIMARY KEY"	=> "id_signature",
+		"KEY id_article"	=> "id_article",
+		"KEY idx"		=> "idx",
+		"KEY statut" => "statut");
+
+
+$spip_ajax_fonc = array(
+		"id_ajax_fonc" => "bigint(21) NOT NULL",
+		"id_auteur" => "bigint(21) NOT NULL",
+		"variables" => "text NOT NULL",
+		"date"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"`hash`"	=> "BIGINT UNSIGNED NOT NULL" );
+
+$spip_ajax_fonc_key = array(
+		"PRIMARY KEY"		=> "id_ajax_fonc",
+		"KEY `hash`"	=> "`hash`");
+
+
+global $tables_principales;
+
+/// Attention: mes_fonctions peut avoir deja defini cette variable
+/// il faut donc rajouter, mais pas reinitialiser
+
+$tables_principales['spip_articles'] =
+	array('field' => &$spip_articles, 'key' => &$spip_articles_key);
+$tables_principales['spip_auteurs']  =
+	array('field' => &$spip_auteurs, 'key' => &$spip_auteurs_key);
+$tables_principales['spip_breves']   =
+	array('field' => &$spip_breves, 'key' => &$spip_breves_key);
+$tables_principales['spip_messages'] =
+	array('field' => &$spip_messages, 'key' => &$spip_messages_key);
+$tables_principales['spip_mots']     =
+	array('field' => &$spip_mots, 'key' => &$spip_mots_key);
+$tables_principales['spip_groupes_mots'] =
+	array('field' => &$spip_groupes_mots, 'key' => &$spip_groupes_mots_key);
+$tables_principales['spip_rubriques'] =
+	array('field' => &$spip_rubriques, 'key' => &$spip_rubriques_key);
+$tables_principales['spip_documents'] =
+	array('field' => &$spip_documents,  'key' => &$spip_documents_key);
+$tables_principales['spip_types_documents']	=
+	array('field' => &$spip_types_documents, 'key' => &$spip_types_documents_key);
+$tables_principales['spip_syndic'] =
+	array('field' => &$spip_syndic, 'key' => &$spip_syndic_key);
+$tables_principales['spip_syndic_articles']	=
+	array('field' => &$spip_syndic_articles, 'key' => &$spip_syndic_articles_key);
+$tables_principales['spip_forum'] =
+	array('field' => &$spip_forum,	'key' => &$spip_forum_key);
+$tables_principales['spip_signatures'] =
+	array('field' => &$spip_signatures, 'key' => &$spip_signatures_key);
+$tables_principales['spip_ajax_fonc'] =
+	array('field' => &$spip_ajax_fonc, 'key' => &$spip_ajax_fonc_key);
+
+?>
diff --git a/ecrire/maj/vieille_base/1917/typedoc.php b/ecrire/maj/vieille_base/1917/typedoc.php
new file mode 100644
index 0000000000..7defd6facd
--- /dev/null
+++ b/ecrire/maj/vieille_base/1917/typedoc.php
@@ -0,0 +1,197 @@
+<?php
+
+/***************************************************************************\
+ *  SPIP, Systeme de publication pour l'internet                           *
+ *                                                                         *
+ *  Copyright (c) 2001-2006                                                *
+ *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
+ *                                                                         *
+ *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
+ *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
+\***************************************************************************/
+
+
+//
+if (!defined("_ECRIRE_INC_VERSION")) return;
+
+## cette API ne sait pas gerer les aliases ; a revoir...
+
+global $tables_images, $tables_sequences, $tables_documents, $tables_mime;
+
+$tables_images = array(
+		       // Images reconnues par PHP
+		       'jpg' => 1, 
+		       'png' => 2, 
+		       'gif' => 3,
+
+		       // Autres images (peuvent utiliser le tag <img>)
+		       'bmp' => 'BMP',
+		       'psd' => 'Photoshop',
+		       'tif' => 'TIFF'
+		       );
+
+// Multimedia (peuvent utiliser le tag <embed>)
+
+$tables_sequences = array(
+			  'aiff' => 'AIFF',
+			  'asf' => 'Windows Media',
+			  'avi' => 'Windows Media',
+			  'flv' => 'Flash Video',
+			  'mid' => 'Midi',
+			  'mng' => 'MNG',
+			  'mov' => 'QuickTime',
+			  'mp3' => 'MP3',
+			  'mpg' => 'MPEG',
+			  'ogg' => 'Ogg',
+			  'qt' => 'QuickTime',
+			  'ra' => 'RealAudio',
+			  'ram' => 'RealAudio',
+			  'rm' => 'RealAudio',
+			  'swf' => 'Flash',
+			  'wav' => 'WAV',
+			  'wmv' => 'Windows Media',
+			  'svg' => 'Scalable Vector Graphics'
+			  );
+
+// Documents varies
+$tables_documents = array(
+			  'abw' => 'Abiword',
+			  'ai' => 'Adobe Illustrator',
+			  'bz2' => 'BZip',
+			  'bin' => 'Binary Data',
+			  'blend' => 'Blender',
+			  'c' => 'C source',
+			  'css' => 'Cascading Style Sheet',
+			  'deb' => 'Debian',
+			  'doc' => 'Word',
+			  'djvu' => 'DjVu',
+			  'dvi' => 'LaTeX DVI',
+			  'eps' => 'PostScript',
+			  'gz' => 'GZ',
+			  'h' => 'C header',
+			  'html' => 'HTML',
+			  'pas' => 'Pascal',
+			  'pdf' => 'PDF',
+			  'pgn' => 'Portable Game Notation',
+			  'ppt' => 'PowerPoint',
+			  'ps' => 'PostScript',
+			  'rpm' => 'RedHat/Mandrake/SuSE',
+			  'rtf' => 'RTF',
+			  'sdd' => 'StarOffice',
+			  'sdw' => 'StarOffice',
+			  'sit' => 'Stuffit',
+			  'sxc' => 'OpenOffice Calc',
+			  'sxi' => 'OpenOffice Impress',
+			  'sxw' => 'OpenOffice',
+			  'tex' => 'LaTeX',
+			  'tgz' => 'TGZ',
+			  'torrent' => 'BitTorrent',
+			  'ttf' => 'TTF Font',
+			  'txt' => 'texte',
+			  'xcf' => 'GIMP multi-layer',
+			  'xls' => 'Excel',
+			  'xml' => 'XML',
+			  'zip' => 'Zip',
+
+			// open document format
+			'odt' => 'opendocument text',
+			'ods' => 'opendocument spreadsheet',
+			'odp' => 'opendocument presentation',
+			'odg' => 'opendocument graphics',
+			'odc' => 'opendocument chart',
+			'odf' => 'opendocument formula',
+			'odb' => 'opendocument database',
+			'odi' => 'opendocument image',
+			'odm' => 'opendocument text-master',
+			'ott' => 'opendocument text-template',
+			'ots' => 'opendocument spreadsheet-template',
+			'otp' => 'opendocument presentation-template',
+			'otg' => 'opendocument graphics-template'
+			  );
+
+$tables_mime = array(
+		// Images reconnues par PHP
+		'jpg'=>'image/jpeg',
+		'png'=>'image/png',
+		'gif'=>'image/gif',
+
+		// Autres images (peuvent utiliser le tag <img>)
+		'bmp'=>'image/x-ms-bmp', // pas enregistre par IANA, variante: image/bmp
+		'psd'=>'image/x-photoshop',	// pas IANA
+		'tif'=>'image/tiff',
+
+		// Multimedia (peuvent utiliser le tag <embed>)
+		'aiff'=>'audio/x-aiff',
+		'asf'=>'video/x-ms-asf',
+		'avi'=>'video/x-msvideo',
+		'flv' => 'video/x-flv',
+		'mid'=>'audio/midi',
+		'mng'=>'video/x-mng',
+		'mov'=>'video/quicktime',
+		'mp3'=>'audio/mpeg',
+		'mpg'=>'video/mpeg',
+		'ogg'=>'application/ogg',
+		'qt' =>'video/quicktime',
+		'ra' =>'audio/x-pn-realaudio',
+		'ram'=>'audio/x-pn-realaudio',
+		'rm' =>'audio/x-pn-realaudio',
+		'swf'=>'application/x-shockwave-flash',
+		'wav'=>'audio/x-wav',
+		'wmv'=>'video/x-ms-wmv',
+		'svg'=>'image/svg+xml',
+
+		// Documents varies
+		'ai' =>'application/illustrator',
+		'abw' =>'application/abiword',
+		'bin' => 'application/octet-stream', # le tout-venant
+		'blend' => 'application/x-blender',
+		'bz2'=>'application/x-bzip2',
+		'c'  =>'text/x-csrc',
+		'css'=>'text/css',
+		'deb'=>'application/x-debian-package',
+		'doc'=>'application/msword',
+		'djvu'=>'image/vnd.djvu',
+		'dvi'=>'application/x-dvi',
+		'eps'=>'application/postscript',
+		'gz' =>'application/x-gzip',
+		'h'  =>'text/x-chdr',
+		'html'=>'text/html',
+		'pas'=>'text/x-pascal',
+		'pdf'=>'application/pdf',
+		'pgn' =>'application/x-chess-pgn',
+		'ppt'=>'application/vnd.ms-powerpoint',
+		'ps' =>'application/postscript',
+		'rpm'=>'application/x-redhat-package-manager',
+		'rtf'=>'application/rtf',
+		'sdd'=>'application/vnd.stardivision.impress',
+		'sdw'=>'application/vnd.stardivision.writer',
+		'sit'=>'application/x-stuffit',
+		'sxc'=>'application/vnd.sun.xml.calc',
+		'sxi'=>'application/vnd.sun.xml.impress',
+		'sxw'=>'application/vnd.sun.xml.writer',
+		'tex'=>'text/x-tex',
+		'tgz'=>'application/x-gtar',
+		'torrent' => 'application/x-bittorrent',
+		'ttf'=>'application/x-font-ttf',
+		'txt'=>'text/plain',
+		'xcf'=>'application/x-xcf',
+		'xls'=>'application/vnd.ms-excel',
+		'xml'=>'application/xml',
+		'zip'=>'application/zip',
+
+		// open document format
+		'odt' => 'application/vnd.oasis.opendocument.text',
+		'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
+		'odp' => 'application/vnd.oasis.opendocument.presentation',
+		'odg' => 'application/vnd.oasis.opendocument.graphics',
+		'odc' => 'application/vnd.oasis.opendocument.chart',
+		'odf' => 'application/vnd.oasis.opendocument.formula',
+		'odb' => 'application/vnd.oasis.opendocument.database',
+		'odi' => 'application/vnd.oasis.opendocument.image',
+		'odm' => 'application/vnd.oasis.opendocument.text-master',
+		'ott' => 'application/vnd.oasis.opendocument.text-template',
+		'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
+		'otp' => 'application/vnd.oasis.opendocument.presentation-template',
+		'otg' => 'application/vnd.oasis.opendocument.graphics-template'
+	);
+?>
diff --git a/ecrire/maj/vieille_base/1927/auxiliaires.php b/ecrire/maj/vieille_base/1927/auxiliaires.php
new file mode 100644
index 0000000000..63786f9190
--- /dev/null
+++ b/ecrire/maj/vieille_base/1927/auxiliaires.php
@@ -0,0 +1,329 @@
+<?php
+
+/***************************************************************************\
+ *  SPIP, Systeme de publication pour l'internet                           *
+ *                                                                         *
+ *  Copyright (c) 2001-2007                                                *
+ *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
+ *                                                                         *
+ *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
+ *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
+\***************************************************************************/
+
+
+if (!defined("_ECRIRE_INC_VERSION")) return;
+
+$spip_petitions = array(
+		"id_article"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"email_unique"	=> "CHAR (3) NOT NULL",
+		"site_obli"	=> "CHAR (3) NOT NULL",
+		"site_unique"	=> "CHAR (3) NOT NULL",
+		"message"	=> "CHAR (3) NOT NULL",
+		"texte"	=> "LONGBLOB NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_petitions_key = array(
+		"PRIMARY KEY"	=> "id_article");
+
+$spip_visites = array(
+		"date"	=> "DATE NOT NULL",
+		"visites"	=> "INT UNSIGNED NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_visites_key = array(
+		"PRIMARY KEY"	=> "date");
+
+$spip_visites_articles = array(
+		"date"	=> "DATE NOT NULL",
+		"id_article"	=> "INT UNSIGNED NOT NULL",
+		"visites"	=> "INT UNSIGNED NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_visites_articles_key = array(
+		"PRIMARY KEY"	=> "date, id_article");
+
+$spip_referers = array(
+		"referer_md5"	=> "BIGINT UNSIGNED NOT NULL",
+		"date"		=> "DATE NOT NULL",
+		"referer"	=> "VARCHAR (255) NOT NULL",
+		"visites"	=> "INT UNSIGNED NOT NULL",
+		"visites_jour"	=> "INT UNSIGNED NOT NULL",
+		"visites_veille"=> "INT UNSIGNED NOT NULL",
+		"maj"		=> "TIMESTAMP");
+
+$spip_referers_key = array(
+		"PRIMARY KEY"	=> "referer_md5");
+
+$spip_referers_articles = array(
+		"id_article"	=> "INT UNSIGNED NOT NULL",
+		"referer_md5"	=> "BIGINT UNSIGNED NOT NULL",
+		"date"		=> "DATE NOT NULL",
+		"referer"	=> "VARCHAR (255) NOT NULL",
+		"visites"	=> "INT UNSIGNED NOT NULL",
+		"maj"		=> "TIMESTAMP");
+
+$spip_referers_articles_key = array(
+		"PRIMARY KEY"	=> "id_article, referer_md5",
+		"KEY referer_md5"	=> "referer_md5");
+
+$spip_auteurs_articles = array(
+		"id_auteur"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_article"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_auteurs_articles_key = array(
+		"PRIMARY KEY"	=> "id_auteur, id_article",
+		"KEY id_article"	=> "id_article");
+
+$spip_auteurs_rubriques = array(
+		"id_auteur"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_rubrique"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_auteurs_rubriques_key = array(
+		"PRIMARY KEY"	=> "id_auteur, id_rubrique",
+		"KEY id_rubrique"	=> "id_rubrique");
+
+$spip_auteurs_messages = array(
+		"id_auteur"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_message"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"vu"		=> "CHAR (3) NOT NULL");
+
+$spip_auteurs_messages_key = array(
+		"PRIMARY KEY"	=> "id_auteur, id_message",
+		"KEY id_message"	=> "id_message");
+
+
+$spip_documents_articles = array(
+		"id_document"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_article"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_documents_articles_key = array(
+		"PRIMARY KEY"		=> "id_article, id_document",
+		"KEY id_document"	=> "id_document");
+
+$spip_documents_rubriques = array(
+		"id_document"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_rubrique"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_documents_rubriques_key = array(
+		"PRIMARY KEY"		=> "id_rubrique, id_document",
+		"KEY id_document"	=> "id_document");
+
+$spip_documents_breves = array(
+		"id_document"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_breve"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_documents_breves_key = array(
+		"PRIMARY KEY"		=> "id_breve, id_document",
+		"KEY id_document"	=> "id_document");
+
+$spip_mots_articles = array(
+		"id_mot"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_article"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_mots_articles_key = array(
+		"PRIMARY KEY"	=> "id_article, id_mot",
+		"KEY id_mot"	=> "id_mot");
+
+$spip_mots_breves = array(
+		"id_mot"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_breve"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_mots_breves_key = array(
+		"PRIMARY KEY"	=> "id_breve, id_mot",
+		"KEY id_mot"	=> "id_mot");
+
+$spip_mots_rubriques = array(
+		"id_mot"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_rubrique"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_mots_rubriques_key = array(
+		"PRIMARY KEY"	=> "id_rubrique, id_mot",
+		"KEY id_mot"	=> "id_mot");
+
+$spip_mots_syndic = array(
+		"id_mot"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_syndic"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_mots_syndic_key = array(
+		"PRIMARY KEY"	=> "id_syndic, id_mot",
+		"KEY id_mot"	=> "id_mot");
+
+$spip_mots_forum = array(
+		"id_mot"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_forum"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_mots_forum_key = array(
+		"PRIMARY KEY"	=> "id_forum, id_mot",
+		"KEY id_mot"	=> "id_mot");
+
+$spip_mots_documents = array(
+		"id_mot"	=> "BIGINT (21) DEFAULT '0' NOT NULL",
+		"id_document"	=> "BIGINT (21) DEFAULT '0' NOT NULL");
+
+$spip_mots_documents_key = array(
+		"PRIMARY KEY"	=> "id_document, id_mot",
+		"KEY id_mot"	=> "id_mot");
+
+$spip_meta = array(
+		"nom"	=> "VARCHAR (255) NOT NULL",
+		"valeur"	=> "text DEFAULT ''",
+		"impt"	=> "ENUM('non', 'oui') DEFAULT 'oui' NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_meta_key = array(
+		"PRIMARY KEY"	=> "nom");
+
+$spip_index = array(
+ 		"`hash`"	=> "BIGINT UNSIGNED NOT NULL",
+ 		"points"	=> "INT UNSIGNED DEFAULT '0' NOT NULL",
+		"id_objet"	=> "INT UNSIGNED NOT NULL",
+		"id_table"	=> "TINYINT UNSIGNED NOT NULL"	);
+
+$spip_index_key = array(
+ 		"KEY `hash`"	=> "`hash`",
+		"KEY id_objet"	=> "id_objet",
+		"KEY id_table"	=> "id_table");
+
+$spip_index_dico = array(
+		"`hash`"	=> "BIGINT UNSIGNED NOT NULL",
+		"dico"		=> "VARCHAR (30) NOT NULL");
+
+$spip_index_dico_key = array(
+		"PRIMARY KEY"	=> "dico");
+
+$spip_versions = array (
+		"id_article"	=> "bigint(21) NOT NULL",
+		"id_version"	=> "int unsigned DEFAULT '0' NOT NULL",
+		"date"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"id_auteur"	=> "VARCHAR(23) NOT NULL", # stocke aussi IP(v6)
+		"titre_version"	=> "text DEFAULT '' NOT NULL",
+		"permanent"	=> "char(3) NOT NULL",
+		"champs"	=> "text NOT NULL");
+
+$spip_versions_key = array (
+		"PRIMARY KEY"	=> "id_article, id_version",
+		"KEY date"	=> "id_article, date",
+		"KEY id_auteur"	=> "id_auteur");
+
+$spip_versions_fragments = array(
+		"id_fragment"	=> "int unsigned DEFAULT '0' NOT NULL",
+		"version_min"	=> "int unsigned DEFAULT '0' NOT NULL",
+		"version_max"	=> "int unsigned DEFAULT '0' NOT NULL",
+		"id_article"	=> "bigint(21) NOT NULL",
+		"compress"	=> "tinyint NOT NULL",
+		"fragment"	=> "longblob NOT NULL");
+
+$spip_versions_fragments_key = array(
+	     "PRIMARY KEY"	=> "id_article, id_fragment, version_min");
+
+$spip_caches = array(
+		"fichier" => "char (64) NOT NULL",
+		"id" => "char (64) NOT NULL",
+		// i=par id, t=timer, x=suppression
+		"type" => "CHAR (1) DEFAULT 'i' NOT NULL",
+		"taille" => "integer DEFAULT '0' NOT NULL");
+$spip_caches_key = array(
+		"PRIMARY KEY"	=> "fichier, id",
+		"KEY fichier" => "fichier",
+		"KEY id" => "id");
+
+$spip_ortho_cache = array(
+	"lang" => "VARCHAR(10) NOT NULL",
+	"mot" => "VARCHAR(255) BINARY NOT NULL",
+	"ok" => "TINYINT NOT NULL",
+	"suggest" => "BLOB NOT NULL",
+	"maj" => "TIMESTAMP");
+$spip_ortho_cache_key = array(
+	"PRIMARY KEY" => "lang, mot",
+	"KEY maj" => "maj");
+
+$spip_ortho_dico = array(
+	"lang" => "VARCHAR(10) NOT NULL",
+	"mot" => "VARCHAR(255) BINARY NOT NULL",
+	"id_auteur" => "BIGINT UNSIGNED NOT NULL",
+	"maj" => "TIMESTAMP");
+$spip_ortho_dico_key = array(
+	"PRIMARY KEY" => "lang, mot");
+
+
+
+
+global $tables_auxiliaires;
+
+$tables_auxiliaires['spip_petitions'] = array(
+	'field' => &$spip_petitions,
+	'key' => &$spip_petitions_key
+);
+$tables_auxiliaires['spip_visites'] = array(
+	'field' => &$spip_visites,
+	'key' => &$spip_visites_key);
+$tables_auxiliaires['spip_visites_articles'] = array(
+	'field' => &$spip_visites_articles,
+	'key' => &$spip_visites_articles_key);
+$tables_auxiliaires['spip_referers'] = array(
+	'field' => &$spip_referers,
+	'key' => &$spip_referers_key);
+$tables_auxiliaires['spip_referers_articles'] = array(
+	'field' => &$spip_referers_articles,
+	'key' => &$spip_referers_articles_key);
+$tables_auxiliaires['spip_auteurs_articles'] = array(
+	'field' => &$spip_auteurs_articles,
+	'key' => &$spip_auteurs_articles_key);
+$tables_auxiliaires['spip_auteurs_rubriques'] = array(
+	'field' => &$spip_auteurs_rubriques,
+	'key' => &$spip_auteurs_rubriques_key);
+$tables_auxiliaires['spip_auteurs_messages'] = array(
+	'field' => &$spip_auteurs_messages,
+	'key' => &$spip_auteurs_messages_key);
+$tables_auxiliaires['spip_documents_articles'] = array(
+	'field' => &$spip_documents_articles,
+	'key' => &$spip_documents_articles_key);
+$tables_auxiliaires['spip_documents_rubriques'] = array(
+	'field' => &$spip_documents_rubriques,
+	'key' => &$spip_documents_rubriques_key);
+$tables_auxiliaires['spip_documents_breves'] = array(
+	'field' => &$spip_documents_breves,
+	'key' => &$spip_documents_breves_key);
+$tables_auxiliaires['spip_mots_articles'] = array(
+	'field' => &$spip_mots_articles,
+	'key' => &$spip_mots_articles_key);
+$tables_auxiliaires['spip_mots_breves'] = array(
+	'field' => &$spip_mots_breves,
+	'key' => &$spip_mots_breves_key);
+$tables_auxiliaires['spip_mots_rubriques'] = array(
+	'field' => &$spip_mots_rubriques,
+	'key' => &$spip_mots_rubriques_key);
+$tables_auxiliaires['spip_mots_syndic'] = array(
+	'field' => &$spip_mots_syndic,
+	'key' => &$spip_mots_syndic_key);
+$tables_auxiliaires['spip_mots_forum'] = array(
+	'field' => &$spip_mots_forum,
+	'key' => &$spip_mots_forum_key);
+$tables_auxiliaires['spip_mots_documents'] = array(
+	'field' => &$spip_mots_documents,
+	'key' => &$spip_mots_documents_key);
+$tables_auxiliaires['spip_meta'] = array(
+	'field' => &$spip_meta,
+	'key' => &$spip_meta_key);
+$tables_auxiliaires['spip_index'] = array(
+	'field' => &$spip_index,
+	'key' => &$spip_index_key);
+$tables_auxiliaires['spip_index_dico'] = array(
+	'field' => &$spip_index_dico,
+	'key' => &$spip_index_dico_key);
+$tables_auxiliaires['spip_versions'] = array(
+	'field' => &$spip_versions,
+	'key' => &$spip_versions_key);
+$tables_auxiliaires['spip_versions_fragments'] = array(
+	'field' => &$spip_versions_fragments,
+	'key' => &$spip_versions_fragments_key);
+$tables_auxiliaires['spip_caches'] = array(
+	'field' => &$spip_caches,
+	'key' => &$spip_caches_key);
+$tables_auxiliaires['spip_ortho_cache'] = array(
+	'field' => &$spip_ortho_cache,
+	'key' => &$spip_ortho_cache_key);
+$tables_auxiliaires['spip_ortho_dico'] = array(
+	'field' => &$spip_ortho_dico,
+	'key' => &$spip_ortho_dico_key);
+?>
diff --git a/ecrire/maj/vieille_base/1927/create.php b/ecrire/maj/vieille_base/1927/create.php
new file mode 100644
index 0000000000..99182556f0
--- /dev/null
+++ b/ecrire/maj/vieille_base/1927/create.php
@@ -0,0 +1,52 @@
+<?php
+
+/***************************************************************************\
+ *  SPIP, Systeme de publication pour l'internet                           *
+ *                                                                         *
+ *  Copyright (c) 2001-2007                                                *
+ *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
+ *                                                                         *
+ *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
+ *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
+\***************************************************************************/
+
+if (!defined("_ECRIRE_INC_VERSION")) return;
+include_spip('maj/vieille_base/1927/serial');
+include_spip('maj/vieille_base/1927/auxiliaires');
+include_spip('maj/vieille_base/1927/typedoc');
+
+// http://doc.spip.org/@creer_base
+function maj_vieille_base_1927_create() {
+  global $tables_principales, $tables_auxiliaires, $tables_images, $tables_sequences, $tables_documents, $tables_mime;
+
+	// ne pas revenir plusieurs fois (si, au contraire, il faut pouvoir
+	// le faire car certaines mises a jour le demandent explicitement)
+	# static $vu = false;
+	# if ($vu) return; else $vu = true;
+
+	foreach($tables_principales as $k => $v)
+		spip_mysql_create($k, $v['field'], $v['key'], true);
+
+	foreach($tables_auxiliaires as $k => $v)
+		spip_mysql_create($k, $v['field'], $v['key'], false);
+
+	foreach($tables_images as $k => $v)
+		spip_query_db("INSERT IGNORE INTO spip_types_documents (extension, inclus, titre, id_type) VALUES ('$k', 'image', '" .
+			      (is_numeric($v) ?
+			       (strtoupper($k) . "', $v") :
+			       "$v', 0") .
+			      ")");
+
+	foreach($tables_sequences as $k => $v)
+		spip_query_db("INSERT IGNORE INTO spip_types_documents (extension, titre, inclus) VALUES ('$k', '$v', 'embed')");
+
+	foreach($tables_documents as $k => $v)
+		spip_query_db("INSERT IGNORE INTO spip_types_documents (extension, titre, inclus) VALUES ('$k', '$v', 'non')");
+
+	foreach ($tables_mime as $extension => $type_mime)
+	  spip_query_db("UPDATE spip_types_documents
+		SET mime_type='$type_mime' WHERE extension='$extension'");
+}
+
+
+?>
\ No newline at end of file
diff --git a/ecrire/maj/vieille_base/1927/serial.php b/ecrire/maj/vieille_base/1927/serial.php
new file mode 100644
index 0000000000..6e29e0dc18
--- /dev/null
+++ b/ecrire/maj/vieille_base/1927/serial.php
@@ -0,0 +1,372 @@
+<?php
+
+/***************************************************************************\
+ *  SPIP, Systeme de publication pour l'internet                           *
+ *                                                                         *
+ *  Copyright (c) 2001-2007                                                *
+ *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
+ *                                                                         *
+ *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
+ *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
+\***************************************************************************/
+
+
+if (!defined("_ECRIRE_INC_VERSION")) return;
+
+
+$spip_articles = array(
+		"id_article"	=> "bigint(21) NOT NULL",
+		"surtitre"	=> "text NOT NULL",
+		"titre"	=> "text NOT NULL",
+		"soustitre"	=> "text NOT NULL",
+		"id_rubrique"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"descriptif"	=> "text NOT NULL",
+		"chapo"	=> "mediumtext NOT NULL",
+		"texte"	=> "longblob NOT NULL",
+		"ps"	=> "mediumtext NOT NULL",
+		"date"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"statut"	=> "varchar(10) DEFAULT '0' NOT NULL",
+		"id_secteur"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"maj"	=> "TIMESTAMP",
+		"export"	=> "VARCHAR(10) DEFAULT 'oui'",
+		"date_redac"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"visites"	=> "INTEGER DEFAULT '0' NOT NULL",
+		"referers"	=> "INTEGER DEFAULT '0' NOT NULL",
+		"popularite"	=> "DOUBLE DEFAULT '0' NOT NULL",
+		"accepter_forum"	=> "CHAR(3) NOT NULL",
+		"date_modif"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"lang"		=> "VARCHAR(10) DEFAULT '' NOT NULL",
+		"langue_choisie"	=> "VARCHAR(3) DEFAULT 'non'",
+		"id_trad"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"extra"		=> "longblob NULL",
+		"idx"		=> "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL",
+		"id_version"	=> "int unsigned DEFAULT '0' NOT NULL",
+		"nom_site"	=> "tinytext NOT NULL",
+		"url_site"	=> "VARCHAR(255) NOT NULL",
+		"url_propre" => "VARCHAR(255) NOT NULL");
+
+$spip_articles_key = array(
+		"PRIMARY KEY"		=> "id_article",
+		"KEY id_rubrique"	=> "id_rubrique",
+		"KEY id_secteur"	=> "id_secteur",
+		"KEY id_trad"		=> "id_trad",
+		"KEY lang"			=> "lang",
+		"KEY statut"		=> "statut, date",
+		"KEY url_site"		=> "url_site",
+		"KEY date_modif"	=> "date_modif",
+		"KEY idx"			=> "idx",
+		"KEY url_propre"	=> "url_propre");
+
+$spip_auteurs = array(
+		"id_auteur"	=> "bigint(21) NOT NULL",
+		"nom"	=> "text NOT NULL",
+		"bio"	=> "text NOT NULL",
+		"email"	=> "tinytext NOT NULL",
+		"nom_site"	=> "tinytext NOT NULL",
+		"url_site"	=> "text NOT NULL",
+		"login"	=> "VARCHAR(255) BINARY NOT NULL",
+		"pass"	=> "tinytext NOT NULL",
+		"low_sec"	=> "tinytext NOT NULL",
+		"statut"	=> "VARCHAR(255) NOT NULL",
+		"maj"	=> "TIMESTAMP",
+		"pgp"	=> "BLOB NOT NULL",
+		"htpass"	=> "tinyblob NOT NULL",
+		"en_ligne"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"imessage"	=> "VARCHAR(3) NOT NULL",
+		"messagerie"	=> "VARCHAR(3) NOT NULL",
+		"alea_actuel"	=> "tinytext NOT NULL",
+		"alea_futur"	=> "tinytext NOT NULL",
+		"prefs"	=> "tinytext NOT NULL",
+		"cookie_oubli"	=> "tinytext NOT NULL",
+		"source"	=> "VARCHAR(10) DEFAULT 'spip' NOT NULL",
+		"lang"	=> "VARCHAR(10) DEFAULT '' NOT NULL",
+		"idx"		=> "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL",
+		"url_propre" => "VARCHAR(255) NOT NULL",
+		"extra"	=> "longblob NULL");
+
+$spip_auteurs_key = array(
+		"PRIMARY KEY"	=> "id_auteur",
+		"KEY login"	=> "login",
+		"KEY statut"	=> "statut",
+		"KEY lang"	=> "lang",
+		"KEY idx"	=> "idx",
+		"KEY en_ligne"	=> "en_ligne",
+		"KEY url_propre"	=> "url_propre");
+
+$spip_breves = array(
+		"id_breve"	=> "bigint(21) NOT NULL",
+		"date_heure"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"titre"	=> "text NOT NULL",
+		"texte"	=> "longblob NOT NULL",
+		"lien_titre"	=> "text NOT NULL",
+		"lien_url"	=> "text NOT NULL",
+		"statut"	=> "varchar(6) NOT NULL",
+		"id_rubrique"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"lang"	=> "VARCHAR(10) DEFAULT '' NOT NULL",
+		"langue_choisie"	=> "VARCHAR(3) DEFAULT 'non'",
+		"maj"	=> "TIMESTAMP",
+		"idx"		=> "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL",
+		"extra"	=> "longblob NULL",
+		"url_propre" => "VARCHAR(255) NOT NULL");
+
+$spip_breves_key = array(
+		"PRIMARY KEY"	=> "id_breve",
+		"KEY idx"	=> "idx",
+		"KEY id_rubrique"	=> "id_rubrique",
+		"KEY url_propre"	=> "url_propre");
+
+$spip_messages = array(
+		"id_message"	=> "bigint(21) NOT NULL",
+		"titre"	=> "text NOT NULL",
+		"texte"	=> "longblob NOT NULL",
+		"type"	=> "varchar(6) NOT NULL",
+		"date_heure"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"date_fin"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"rv"	=> "varchar(3) NOT NULL",
+		"statut"	=> "varchar(6) NOT NULL",
+		"id_auteur"	=> "bigint(21) NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_messages_key = array(
+		"PRIMARY KEY"	=> "id_message",
+		"KEY id_auteur"	=> "id_auteur");
+
+$spip_mots = array(
+		"id_mot"	=> "bigint(21) NOT NULL",
+		"titre"	=> "text NOT NULL",
+		"descriptif"	=> "text NOT NULL",
+		"texte"	=> "longblob NOT NULL",
+		"id_groupe"	=> "bigint(21) NOT NULL",
+		"type"	=> "text NOT NULL",
+		"extra"	=> "longblob NULL",
+		"idx"		=> "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL",
+		"url_propre" => "VARCHAR(255) NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_mots_key = array(
+		"PRIMARY KEY"	=> "id_mot",
+		"KEY idx"	=> "idx",
+		"KEY url_propre"	=> "url_propre");
+
+$spip_groupes_mots = array(
+		"id_groupe"	=> "bigint(21) NOT NULL",
+		"titre"	=> "text NOT NULL",
+		"descriptif"	=> "text NOT NULL",
+		"texte"	=> "longblob NOT NULL",
+		"unseul"	=> "varchar(3) NOT NULL",
+		"obligatoire"	=> "varchar(3) NOT NULL",
+		"articles"	=> "varchar(3) NOT NULL",
+		"breves"	=> "varchar(3) NOT NULL",
+		"rubriques"	=> "varchar(3) NOT NULL",
+		"syndic"	=> "varchar(3) NOT NULL",
+		"minirezo"	=> "varchar(3) NOT NULL",
+		"comite"	=> "varchar(3) NOT NULL",
+		"forum"	=> "varchar(3) NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_groupes_mots_key = array(
+		"PRIMARY KEY"	=> "id_groupe");
+
+$spip_rubriques = array(
+		"id_rubrique"	=> "bigint(21) NOT NULL",
+		"id_parent"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"titre"	=> "text NOT NULL",
+		"descriptif"	=> "text NOT NULL",
+		"texte"	=> "longblob NOT NULL",
+		"id_secteur"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"maj"	=> "TIMESTAMP",
+		"export"	=> "VARCHAR(10) DEFAULT 'oui'",
+		"id_import"	=> "BIGINT DEFAULT '0'",
+		"statut"	=> "VARCHAR(10) NOT NULL",
+		"date"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"lang"	=> "VARCHAR(10) DEFAULT '' NOT NULL",
+		"langue_choisie"	=> "VARCHAR(3) DEFAULT 'non'",
+		"idx"		=> "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL",
+		"extra"	=> "longblob NULL",
+		"url_propre" => "VARCHAR(255) NOT NULL",
+		"statut_tmp"	=> "VARCHAR(10) NOT NULL",
+		"date_tmp"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL"
+		);
+
+$spip_rubriques_key = array(
+		"PRIMARY KEY"	=> "id_rubrique",
+		"KEY lang"	=> "lang",
+		"KEY idx"	=> "idx",
+		"KEY id_parent"	=> "id_parent",
+		"KEY url_propre"	=> "url_propre");
+
+$spip_documents = array(
+		"id_document"	=> "bigint(21) NOT NULL",
+		"id_vignette"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"id_type"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"titre"	=> "text NOT NULL",
+		"date"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"descriptif"	=> "text NOT NULL",
+		"fichier"	=> "varchar(255) NOT NULL",
+		"taille"	=> "integer NOT NULL",
+		"largeur"	=> "integer NOT NULL",
+		"hauteur"	=> "integer NOT NULL",
+		"mode"	=> "ENUM('vignette', 'document') NOT NULL",
+		"distant"	=> "VARCHAR(3) DEFAULT 'non'",
+		"idx"		=> "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_documents_key = array(
+		"PRIMARY KEY"	=> "id_document",
+		"KEY id_vignette"	=> "id_vignette",
+		"KEY mode"	=> "mode",
+		"KEY id_type"	=> "id_type");
+
+$spip_types_documents = array(
+		"id_type"	=> "bigint(21) NOT NULL",
+		"titre"	=> "text NOT NULL",
+		"descriptif"	=> "text NOT NULL",
+		"extension"	=> "varchar(10) NOT NULL",
+		"mime_type"	=> "varchar(100) NOT NULL",
+		"inclus"	=> "ENUM('non', 'image', 'embed') NOT NULL DEFAULT 'non'",
+		"upload"	=> "ENUM('oui', 'non') NOT NULL DEFAULT 'oui'",
+		"maj"	=> "TIMESTAMP");
+
+$spip_types_documents_key = array(
+		"PRIMARY KEY"	=> "id_type",
+		"UNIQUE extension"	=> "extension",
+		"KEY inclus"	=> "inclus");
+
+$spip_syndic = array(
+		"id_syndic"	=> "bigint(21) NOT NULL",
+		"id_rubrique"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"id_secteur"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"nom_site"	=> "blob NOT NULL",
+		"url_site"	=> "blob NOT NULL",
+		"url_syndic"	=> "blob NOT NULL",
+		"descriptif"	=> "blob NOT NULL",
+		"url_propre"	=> "VARCHAR(255) NOT NULL",
+		"idx"		=> "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL",
+		"maj"	=> "TIMESTAMP",
+		"syndication"	=> "VARCHAR(3) NOT NULL",
+		"statut"	=> "VARCHAR(10) NOT NULL",
+		"date"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"date_syndic"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"date_index"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"extra"			=> "longblob NULL",
+		"moderation"	=> "VARCHAR(3) DEFAULT 'non'",
+		"miroir"	=> "VARCHAR(3) DEFAULT 'non'",
+		"oubli"	=> "VARCHAR(3) DEFAULT 'non'",
+		"resume"	=> "VARCHAR(3) DEFAULT 'oui'"
+);
+
+$spip_syndic_key = array(
+		"PRIMARY KEY"	=> "id_syndic",
+		"KEY id_rubrique"	=> "id_rubrique",
+		"KEY id_secteur"	=> "id_secteur",
+		"KEY idx"		=> "idx",
+		"KEY statut"	=> "statut, date_syndic",
+		"KEY url_propre"	=> "url_propre");
+
+$spip_syndic_articles = array(
+		"id_syndic_article"	=> "bigint(21) NOT NULL",
+		"id_syndic"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"titre"	=> "text NOT NULL",
+		"url"	=> "VARCHAR(255) NOT NULL",
+		"date"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"lesauteurs"	=> "text NOT NULL",
+		"maj"	=> "TIMESTAMP",
+		"statut"	=> "VARCHAR(10) NOT NULL",
+		"descriptif"	=> "blob NOT NULL",
+		"lang"	=> "VARCHAR(10) DEFAULT '' NOT NULL",
+		"url_source" => "TINYTEXT DEFAULT '' NOT NULL",
+		"source" => "TINYTEXT DEFAULT '' NOT NULL",
+		"tags" => "TEXT DEFAULT '' NOT NULL");
+
+$spip_syndic_articles_key = array(
+		"PRIMARY KEY"	=> "id_syndic_article",
+		"KEY id_syndic"	=> "id_syndic",
+		"KEY statut"	=> "statut",
+		"KEY url"	=> "url");
+
+$spip_forum = array(
+		"id_forum"	=> "bigint(21) NOT NULL",
+		"id_parent"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"id_thread"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"id_rubrique"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"id_article"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"id_breve"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"date_heure"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"titre"	=> "text NOT NULL",
+		"texte"	=> "mediumtext NOT NULL",
+		"auteur"	=> "text NOT NULL",
+		"email_auteur"	=> "text NOT NULL",
+		"nom_site"	=> "text NOT NULL",
+		"url_site"	=> "text NOT NULL",
+		"statut"	=> "varchar(8) NOT NULL",
+		"idx"		=> "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL",
+		"ip"	=> "varchar(16)",
+		"maj"	=> "TIMESTAMP",
+		"id_auteur"	=> "BIGINT DEFAULT '0' NOT NULL",
+		"id_message"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"id_syndic"	=> "bigint(21) DEFAULT '0' NOT NULL");
+
+$spip_forum_key = array(
+		"PRIMARY KEY"	=> "id_forum",
+		"KEY id_parent"	=> "id_parent",
+		"KEY id_article"	=> "id_article",
+		"KEY id_breve"	=> "id_breve",
+		"KEY id_message"	=> "id_message",
+		"KEY id_syndic"	=> "id_syndic",
+		"KEY id_rubrique"	=> "id_rubrique",
+		"KEY idx"	=> "idx",
+		"KEY statut"	=> "statut, date_heure");
+
+$spip_signatures = array(
+		"id_signature"	=> "bigint(21) NOT NULL",
+		"id_article"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"date_time"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"nom_email"	=> "text NOT NULL",
+		"ad_email"	=> "text NOT NULL",
+		"nom_site"	=> "text NOT NULL",
+		"url_site"	=> "text NOT NULL",
+		"message"	=> "mediumtext NOT NULL",
+		"statut"	=> "varchar(10) NOT NULL",
+		"idx"		=> "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_signatures_key = array(
+		"PRIMARY KEY"	=> "id_signature",
+		"KEY id_article"	=> "id_article",
+		"KEY idx"		=> "idx",
+		"KEY statut" => "statut");
+
+
+global $tables_principales;
+
+/// Attention: mes_fonctions peut avoir deja defini cette variable
+/// il faut donc rajouter, mais pas reinitialiser
+
+$tables_principales['spip_articles'] =
+	array('field' => &$spip_articles, 'key' => &$spip_articles_key);
+$tables_principales['spip_auteurs']  =
+	array('field' => &$spip_auteurs, 'key' => &$spip_auteurs_key);
+$tables_principales['spip_breves']   =
+	array('field' => &$spip_breves, 'key' => &$spip_breves_key);
+$tables_principales['spip_messages'] =
+	array('field' => &$spip_messages, 'key' => &$spip_messages_key);
+$tables_principales['spip_mots']     =
+	array('field' => &$spip_mots, 'key' => &$spip_mots_key);
+$tables_principales['spip_groupes_mots'] =
+	array('field' => &$spip_groupes_mots, 'key' => &$spip_groupes_mots_key);
+$tables_principales['spip_rubriques'] =
+	array('field' => &$spip_rubriques, 'key' => &$spip_rubriques_key);
+$tables_principales['spip_documents'] =
+	array('field' => &$spip_documents,  'key' => &$spip_documents_key);
+$tables_principales['spip_types_documents']	=
+	array('field' => &$spip_types_documents, 'key' => &$spip_types_documents_key);
+$tables_principales['spip_syndic'] =
+	array('field' => &$spip_syndic, 'key' => &$spip_syndic_key);
+$tables_principales['spip_syndic_articles']	=
+	array('field' => &$spip_syndic_articles, 'key' => &$spip_syndic_articles_key);
+$tables_principales['spip_forum'] =
+	array('field' => &$spip_forum,	'key' => &$spip_forum_key);
+$tables_principales['spip_signatures'] =
+	array('field' => &$spip_signatures, 'key' => &$spip_signatures_key);
+
+?>
diff --git a/ecrire/maj/vieille_base/1927/typedoc.php b/ecrire/maj/vieille_base/1927/typedoc.php
new file mode 100644
index 0000000000..2cb28c0c6e
--- /dev/null
+++ b/ecrire/maj/vieille_base/1927/typedoc.php
@@ -0,0 +1,211 @@
+<?php
+
+/***************************************************************************\
+ *  SPIP, Systeme de publication pour l'internet                           *
+ *                                                                         *
+ *  Copyright (c) 2001-2007                                                *
+ *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
+ *                                                                         *
+ *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
+ *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
+\***************************************************************************/
+
+
+//
+if (!defined("_ECRIRE_INC_VERSION")) return;
+
+## cette API ne sait pas gerer les aliases ; a revoir...
+
+global $tables_images, $tables_sequences, $tables_documents, $tables_mime;
+
+$tables_images = array(
+		       // Images reconnues par PHP
+		       'jpg' => 1, 
+		       'png' => 2, 
+		       'gif' => 3,
+
+		       // Autres images (peuvent utiliser le tag <img>)
+		       'bmp' => 'BMP',
+		       'tif' => 'TIFF'
+		       );
+
+// Multimedia (peuvent utiliser le tag <embed>)
+
+$tables_sequences = array(
+			  'aiff' => 'AIFF',
+			  'asf' => 'Windows Media',
+			  'avi' => 'AVI',
+			  'flv' => 'Flash Video',
+			  'mid' => 'Midi',
+			  'mng' => 'MNG',
+			  'mka' => 'Matroska Audio',
+			  'mkv' => 'Matroska Video',
+			  'mov' => 'QuickTime',
+			  'mp3' => 'MP3',
+			  'mp4' => 'MPEG4',
+			  'mpg' => 'MPEG',
+			  'ogg' => 'Ogg',
+			  'qt' => 'QuickTime',
+			  'ra' => 'RealAudio',
+			  'ram' => 'RealAudio',
+			  'rm' => 'RealAudio',
+			  'svg' => 'Scalable Vector Graphics',
+			  'swf' => 'Flash',
+			  'wav' => 'WAV',
+			  'wmv' => 'Windows Media'
+			  );
+
+// Documents varies
+$tables_documents = array(
+			  'abw' => 'Abiword',
+			  'ai' => 'Adobe Illustrator',
+			  'bz2' => 'BZip',
+			  'bin' => 'Binary Data',
+			  'blend' => 'Blender',
+			  'c' => 'C source',
+			  'css' => 'Cascading Style Sheet',
+			  'csv' => 'Comma Separated Values',
+			  'deb' => 'Debian',
+			  'doc' => 'Word',
+			  'djvu' => 'DjVu',
+			  'dvi' => 'LaTeX DVI',
+			  'eps' => 'PostScript',
+			  'gz' => 'GZ',
+			  'h' => 'C header',
+			  'html' => 'HTML',
+			  'kml' => 'Keyhole Markup Language',
+			  'kmz' => 'Google Earth Placemark File',
+			  'pas' => 'Pascal',
+			  'pdf' => 'PDF',
+			  'pgn' => 'Portable Game Notation',
+			  'ppt' => 'PowerPoint',
+			  'ps' => 'PostScript',
+			  'psd' => 'Photoshop',
+			  'rpm' => 'RedHat/Mandrake/SuSE',
+			  'rtf' => 'RTF',
+			  'sdd' => 'StarOffice',
+			  'sdw' => 'StarOffice',
+			  'sit' => 'Stuffit',
+			  'sxc' => 'OpenOffice Calc',
+			  'sxi' => 'OpenOffice Impress',
+			  'sxw' => 'OpenOffice',
+			  'tex' => 'LaTeX',
+			  'tgz' => 'TGZ',
+			  'torrent' => 'BitTorrent',
+			  'ttf' => 'TTF Font',
+			  'txt' => 'texte',
+			  'xcf' => 'GIMP multi-layer',
+			  'xls' => 'Excel',
+			  'xml' => 'XML',
+			  'zip' => 'Zip',
+
+			// open document format
+			'odt' => 'opendocument text',
+			'ods' => 'opendocument spreadsheet',
+			'odp' => 'opendocument presentation',
+			'odg' => 'opendocument graphics',
+			'odc' => 'opendocument chart',
+			'odf' => 'opendocument formula',
+			'odb' => 'opendocument database',
+			'odi' => 'opendocument image',
+			'odm' => 'opendocument text-master',
+			'ott' => 'opendocument text-template',
+			'ots' => 'opendocument spreadsheet-template',
+			'otp' => 'opendocument presentation-template',
+			'otg' => 'opendocument graphics-template',
+		
+			  );
+
+$tables_mime = array(
+		// Images reconnues par PHP
+		'jpg'=>'image/jpeg',
+		'png'=>'image/png',
+		'gif'=>'image/gif',
+
+		// Autres images (peuvent utiliser le tag <img>)
+		'bmp'=>'image/x-ms-bmp', // pas enregistre par IANA, variante: image/bmp
+		'tif'=>'image/tiff',
+
+		// Multimedia (peuvent utiliser le tag <embed>)
+		'aiff'=>'audio/x-aiff',
+		'asf'=>'video/x-ms-asf',
+		'avi'=>'video/x-msvideo',
+		'flv' => 'video/x-flv',
+		'mid'=>'audio/midi',
+		'mka' => 'audio/mka',
+		'mkv' => 'video/mkv',
+		'mng'=>'video/x-mng',
+		'mov'=>'video/quicktime',
+		'mp3'=>'audio/mpeg',
+		'mp4' => 'application/mp4',
+		'mpg'=>'video/mpeg',
+		'ogg'=>'application/ogg',
+		'qt' =>'video/quicktime',
+		'ra' =>'audio/x-pn-realaudio',
+		'ram'=>'audio/x-pn-realaudio',
+		'rm' =>'audio/x-pn-realaudio',
+		'svg'=>'image/svg+xml',
+		'swf'=>'application/x-shockwave-flash',
+		'wav'=>'audio/x-wav',
+		'wmv'=>'video/x-ms-wmv',
+
+		// Documents varies
+		'ai' =>'application/illustrator',
+		'abw' =>'application/abiword',
+		'bin' => 'application/octet-stream', # le tout-venant
+		'blend' => 'application/x-blender',
+		'bz2'=>'application/x-bzip2',
+		'c'  =>'text/x-csrc',
+		'css'=>'text/css',
+		'csv'=>'text/csv',
+		'deb'=>'application/x-debian-package',
+		'doc'=>'application/msword',
+		'djvu'=>'image/vnd.djvu',
+		'dvi'=>'application/x-dvi',
+		'eps'=>'application/postscript',
+		'gz' =>'application/x-gzip',
+		'h'  =>'text/x-chdr',
+		'html'=>'text/html',
+		'kml'=>'application/vnd.google-earth.kml+xml',
+		'kmz'=>'application/vnd.google-earth.kmz',
+		'pas'=>'text/x-pascal',
+		'pdf'=>'application/pdf',
+		'pgn' =>'application/x-chess-pgn',
+		'ppt'=>'application/vnd.ms-powerpoint',
+		'ps' =>'application/postscript',
+		'psd'=>'image/x-photoshop', // pas enregistre par IANA
+		'rpm'=>'application/x-redhat-package-manager',
+		'rtf'=>'application/rtf',
+		'sdd'=>'application/vnd.stardivision.impress',
+		'sdw'=>'application/vnd.stardivision.writer',
+		'sit'=>'application/x-stuffit',
+		'sxc'=>'application/vnd.sun.xml.calc',
+		'sxi'=>'application/vnd.sun.xml.impress',
+		'sxw'=>'application/vnd.sun.xml.writer',
+		'tex'=>'text/x-tex',
+		'tgz'=>'application/x-gtar',
+		'torrent' => 'application/x-bittorrent',
+		'ttf'=>'application/x-font-ttf',
+		'txt'=>'text/plain',
+		'xcf'=>'application/x-xcf',
+		'xls'=>'application/vnd.ms-excel',
+		'xml'=>'application/xml',
+		'zip'=>'application/zip',
+
+		// open document format
+		'odt' => 'application/vnd.oasis.opendocument.text',
+		'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
+		'odp' => 'application/vnd.oasis.opendocument.presentation',
+		'odg' => 'application/vnd.oasis.opendocument.graphics',
+		'odc' => 'application/vnd.oasis.opendocument.chart',
+		'odf' => 'application/vnd.oasis.opendocument.formula',
+		'odb' => 'application/vnd.oasis.opendocument.database',
+		'odi' => 'application/vnd.oasis.opendocument.image',
+		'odm' => 'application/vnd.oasis.opendocument.text-master',
+		'ott' => 'application/vnd.oasis.opendocument.text-template',
+		'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
+		'otp' => 'application/vnd.oasis.opendocument.presentation-template',
+		'otg' => 'application/vnd.oasis.opendocument.graphics-template'
+		
+	);
+?>
diff --git a/ecrire/maj/vieille_base/charger.php b/ecrire/maj/vieille_base/charger.php
new file mode 100644
index 0000000000..5df2648957
--- /dev/null
+++ b/ecrire/maj/vieille_base/charger.php
@@ -0,0 +1,47 @@
+<?php
+
+/***************************************************************************\
+ *  SPIP, Systeme de publication pour l'internet                           *
+ *                                                                         *
+ *  Copyright (c) 2001-2008                                                *
+ *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
+ *                                                                         *
+ *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
+ *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
+\***************************************************************************/
+
+if (!defined("_ECRIRE_INC_VERSION")) return;
+include_spip('base/abstract_sql');
+
+function maj_vieille_base_charger_dist($version_cible){
+	$vieilles_bases = array(
+	'1.917'=>'1917',
+	'1.927'=>'1927',
+	);
+	$version = false;
+	foreach($vieilles_bases as $v=>$n){
+		if (!$version OR version_compare($v,$version_cible,'<'))
+			$version = $n;
+	}
+	
+	include_spip('base/serial');
+	include_spip('base/auxiliaires');
+	$GLOBALS['nouvelle_base']['tables_principales'] = $GLOBALS['tables_principales'];
+	$GLOBALS['nouvelle_base']['tables_auxiliaires'] = $GLOBALS['tables_auxiliaires'];
+
+	unset($GLOBALS['tables_principales']);
+	unset($GLOBALS['tables_auxiliaires']);
+	unset($GLOBALS['tables_images']);
+	unset($GLOBALS['tables_sequences']);
+	unset($GLOBALS['tables_documents']);
+	unset($GLOBALS['tables_mime']);
+
+	// chargera les descriptions de table
+	$create = charger_fonction('create',"maj/vieille_base/$version");
+	if (!isset($GLOBALS['tables_auxiliaires']['spip_meta']['field']['impt']))
+			$GLOBALS['tables_auxiliaires']['spip_meta']['field']['impt'] = "ENUM('non', 'oui') DEFAULT 'oui' NOT NULL";
+
+	return $version;
+}
+
+?>
\ No newline at end of file
diff --git a/ecrire/maj/vieille_base/create.php b/ecrire/maj/vieille_base/create.php
new file mode 100644
index 0000000000..7509e2aa22
--- /dev/null
+++ b/ecrire/maj/vieille_base/create.php
@@ -0,0 +1,56 @@
+<?php
+
+/***************************************************************************\
+ *  SPIP, Systeme de publication pour l'internet                           *
+ *                                                                         *
+ *  Copyright (c) 2001-2008                                                *
+ *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
+ *                                                                         *
+ *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
+ *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
+\***************************************************************************/
+
+if (!defined("_ECRIRE_INC_VERSION")) return;
+
+$serveur_vieille_base =0;
+
+function	spip_create_table($table,$fields,$keys,$autoinc){
+	static $fcreate = null;
+	$serveur = $GLOBALS['serveur_vieille_base'];
+	if (!$fcreate) $fcreate = sql_serveur('create', $serveur);
+	$fcreate($table,$fields,$keys,$autoinc,false,$serveur);
+}
+
+function maj_vieille_base_create_dist($version_cible){
+
+	$charger = charger_fonction('charger','maj/vieille_base');
+	$version = $charger($version_cible);
+
+	// choisir un nouveau prefixe de table, le noter, et switcher en redefinissant le serveur
+	$new_prefixe = "XXspip$version";
+	// ici on ecrit la meta dans la table 'officielle'
+	ecrire_meta('restauration_table_prefix',$new_prefixe,'non');
+	ecrire_meta('vieille_version_installee',$version,'non');
+	
+	//$GLOBALS['table_prefix'] = $new_prefixe;
+	//lire_metas();
+	$prefixe_source = $GLOBALS['connexions'][0]['prefixe'];
+	$GLOBALS['serveur_vieille_base'] = 0;
+	$GLOBALS['connexions'][$GLOBALS['serveur_vieille_base']] = $GLOBALS['connexions'][0];
+	$GLOBALS['connexions'][$GLOBALS['serveur_vieille_base']]['prefixe'] = $new_prefixe;
+
+	$create = charger_fonction('create',"maj/vieille_base/$version");
+	$create();
+	
+	// reecrire les metas dans la table provisoire
+	foreach($GLOBALS['meta'] as $k=>$v)
+		ecrire_meta($k,$v);
+	ecrire_meta('restauration_table_prefix_source',$prefixe_source,'non');
+	
+	// noter le numero de version installee
+	ecrire_meta('version_installee',$version_cible,'non');
+
+}
+
+
+?>
\ No newline at end of file
-- 
GitLab