diff --git a/.gitattributes b/.gitattributes
index 515da694649e8b1da963f3cb8f380a73457c45cf..01f470d2ddbfef6316025272aaab26e954cbd067 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -409,6 +409,14 @@ 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/10000/auxiliaires.php -text
+ecrire/maj/vieille_base/10000/create.php -text
+ecrire/maj/vieille_base/10000/serial.php -text
+ecrire/maj/vieille_base/10000/typedoc.php -text
+ecrire/maj/vieille_base/13000/auxiliaires.php -text
+ecrire/maj/vieille_base/13000/create.php -text
+ecrire/maj/vieille_base/13000/serial.php -text
+ecrire/maj/vieille_base/13000/typedoc.php -text
 ecrire/maj/vieille_base/1813/create.php -text
 ecrire/maj/vieille_base/1813/inc_auxbase.php -text
 ecrire/maj/vieille_base/1813/inc_serialbase.php -text
diff --git a/ecrire/base/import_all.php b/ecrire/base/import_all.php
index ef2d18eed28282ffe36d46071c57c0b9b0a29925..f419548aa8a40f1e59b47a03d715b6e582ae6993 100644
--- a/ecrire/base/import_all.php
+++ b/ecrire/base/import_all.php
@@ -102,6 +102,7 @@ function import_all_milieu($request, $archive)
 // http://doc.spip.org/@import_all_debut
 function import_all_debut() {
 	ecrire_meta("restauration_status", "0",'non');
+	ecrire_meta("restauration_status_copie", "0",'non');
 }
 
 // http://doc.spip.org/@import_all_fin
@@ -118,6 +119,7 @@ function import_all_fin($request) {
 	effacer_meta('restauration_table_prefix');
 	effacer_meta('restauration_table_prefix_source');
 	effacer_meta('vieille_version_installee');
+	effacer_meta('restauration_status_tables');
 	effacer_meta('restauration_recopie_tables');
 	if ($request['insertion'] == 'passe2') 
 		sql_drop_table("spip_translate");
diff --git a/ecrire/inc/import.php b/ecrire/inc/import.php
index 268b295cd2260835704d93cdbf1fbc3f379e9087..627df52c49fc9a716ed12ab72b3e324c92dd9a3d 100644
--- a/ecrire/inc/import.php
+++ b/ecrire/inc/import.php
@@ -189,7 +189,14 @@ function import_tables($request, $archive) {
 		$charger = charger_fonction('charger','maj/vieille_base');
 		$charger($GLOBALS['meta']['vieille_version_installee']);
 		$GLOBALS['serveur_vieille_base'] = 0;
+		$prefix = $GLOBALS['connexions'][$GLOBALS['serveur_vieille_base']]['prefixe'];
 		$GLOBALS['connexions'][$GLOBALS['serveur_vieille_base']]['prefixe'] = $GLOBALS['meta']['restauration_table_prefix'];
+		// verifier qu'une table meta existe bien
+		// sinon c'est une restauration anterieure echouee
+		if (!sql_getfetsel('valeur','spip_meta','','','','0,1')){
+				$GLOBALS['connexions'][$GLOBALS['serveur_vieille_base']]['prefixe'] = $prefix;
+				return;
+		}
 		// recharger les metas
 		lire_metas();
 	}
@@ -283,6 +290,16 @@ function import_tables($request, $archive) {
 	    _T('taille_octets', array('taille' => $pos)) ;
 	
 	if ($GLOBALS['spip_version_base'] != (str_replace(',','.',$GLOBALS['meta']['version_installee']))){
+		// il FAUT recharger les bonnes desc serial/aux avant ...
+		include_spip('base/serial');
+		$GLOBALS['tables_principales']=array();
+		base_serial($GLOBALS['tables_principales']);
+		include_spip('base/auxiliaires');
+		$GLOBALS['tables_auxiliaires']=array();
+		base_auxiliaires($GLOBALS['tables_auxiliaires']);
+		$GLOBALS['tables_jointures']=array();
+		include_spip('public/interfaces');
+		declarer_interfaces();
 		include_spip('base/upgrade');
 		maj_base(); // upgrade jusqu'a la version courante
 	}
@@ -293,42 +310,65 @@ function import_tables($request, $archive) {
 		$GLOBALS['connexions']['-1'] = $GLOBALS['connexions'][0];
 		// rebasculer le serveur sur les bonnes tables pour finir proprement
 		$GLOBALS['connexions'][0]['prefixe'] = $prefixe_source;
+		// et relire les meta de la bonne base
+		lire_metas();
+
 
-		$tables = import_table_choix($request);
 		$tables_recopiees = isset($GLOBALS['meta']['restauration_recopie_tables'])?unserialize($GLOBALS['meta']['restauration_recopie_tables']):array();
-		
+		spip_log("charge tables_recopiees ".serialize($tables_recopiees),'dbdump');
+
 		// 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'];
+		include_spip('base/serial');
+		$GLOBALS['tables_principales']=array();
+		base_serial($GLOBALS['tables_principales']);
+		include_spip('base/auxiliaires');
+		$GLOBALS['tables_auxiliaires']=array();
+		base_auxiliaires($GLOBALS['tables_auxiliaires']);
+		$GLOBALS['tables_jointures']=array();
+		include_spip('public/interfaces');
+		declarer_interfaces();
+		
+		// puis relister les tables a importer
+		$tables = import_table_choix($request);
+#		var_dump($tables);die();
+
 		if (in_array('spip_auteurs',$tables)){
 			$tables = array_diff($tables,array('spip_auteurs'));
 			$tables[] = 'spip_auteurs';
 		}
+		if (in_array('spip_meta',$tables)){
+			$tables = array_diff($tables,array('spip_meta'));
+			$tables[] = 'spip_meta';
+		}
 		sql_drop_table('spip_test','','-1');
 		foreach ($tables as $table){
-			if (!isset($tables_recopiees[$table])) $tables_recopiees[$table] = 0;
-			if ($tables_recopiees[$table]!==-1){
-				affiche_progression_javascript(0,0,$table);
-				while (true) {
-					$n = intval($tables_recopiees[$table]);
-					$res = sql_select('*',$table,'','','',"$n,400",'','-1');
-					while ($row = sql_fetch($res,'-1')){
-						sql_insertq($table,$row);
-						$tables_recopiees[$table]++;
+			if (sql_showtable($table,false,-1)){
+				if (!isset($tables_recopiees[$table])) $tables_recopiees[$table] = 0;
+				if ($tables_recopiees[$table]!==-1){
+					affiche_progression_javascript(0,0,$table);
+					while (true) {
+						$n = intval($tables_recopiees[$table]);
+						$res = sql_select('*',$table,'','','',"$n,400",'','-1');
+						while ($row = sql_fetch($res,'-1')){
+							sql_insertq($table,$row);
+							$tables_recopiees[$table]++;
+						}
+						if ($n == $tables_recopiees[$table])
+							break;
+						spip_log("recopie $table ".$tables_recopiees[$table],'dbdump');
+						affiche_progression_javascript($tables_recopiees[$table],0,$table);
+						ecrire_meta('restauration_recopie_tables',serialize($tables_recopiees));
 					}
-					if ($n == $tables_recopiees[$table])
-						break;
-					affiche_progression_javascript($tables_recopiees[$table],0,$table);
+					sql_drop_table($table,'','-1');
+					spip_log("drop $table",'dbdump');
+					$tables_recopiees[$table]=-1;
 					ecrire_meta('restauration_recopie_tables',serialize($tables_recopiees));
+					spip_log("tables_recopiees ".serialize($tables_recopiees),'dbdump');
 				}
-				sql_drop_table($table,'','-1');
-				$tables_recopiees[$table]=-1;
-				ecrire_meta('restauration_recopie_tables',serialize($tables_recopiees));
 			}
 		}
 	}
-	
 	return '' ;
 }
 
@@ -342,17 +382,17 @@ function import_init_meta($tag, $atts, $charset, $request)
 	$old = (version_compare($version_base,$GLOBALS['spip_version_base'],'<')
 		&& !isset($GLOBALS['meta']['restauration_table_prefix']));
 
-	if ($old OR $insert) {
-		$init = $request['init'];
-		spip_log("import_init_meta lance $init");
-		$init($request);
-	}
 	if ($old) {
 		// 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);
 	}
+	if ($old OR $insert) {
+		$init = $request['init'];
+		spip_log("import_init_meta lance $init");
+		$init($request);
+	}
 	
 	ecrire_meta('restauration_attributs_archive', serialize($atts),'non');
 	ecrire_meta('restauration_version_archive', $version_archive,'non');
diff --git a/ecrire/maj/vieille_base/10000/auxiliaires.php b/ecrire/maj/vieille_base/10000/auxiliaires.php
new file mode 100644
index 0000000000000000000000000000000000000000..21e9b470d137888b3f23f413674ede1b2f0cbf9d
--- /dev/null
+++ b/ecrire/maj/vieille_base/10000/auxiliaires.php
@@ -0,0 +1,271 @@
+<?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) DEFAULT '' NOT NULL",
+		"site_obli"	=> "CHAR (3) DEFAULT '' NOT NULL",
+		"site_unique"	=> "CHAR (3) DEFAULT '' NOT NULL",
+		"message"	=> "CHAR (3) DEFAULT '' NOT NULL",
+		"texte"	=> "LONGTEXT DEFAULT '' NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_petitions_key = array(
+		"PRIMARY KEY"	=> "id_article");
+
+$spip_visites = array(
+		"date"	=> "DATE NOT NULL",
+		"visites"	=> "int UNSIGNED DEFAULT '0' 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 DEFAULT '0' 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)",
+		"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) DEFAULT '' 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)");
+
+$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",
+		"vu"	=> "ENUM('non', 'oui') DEFAULT 'non' 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",
+		"vu"	=> "ENUM('non', 'oui') DEFAULT 'non' 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",
+		"vu"	=> "ENUM('non', 'oui') DEFAULT 'non' 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_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) DEFAULT '' NOT NULL", # stocke aussi IP(v6)
+		"titre_version"	=> "text DEFAULT '' NOT NULL",
+		"permanent"	=> "char(3)",
+		"champs"	=> "text");
+
+$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"  # ici c'est VRAIMENT un blob (on y stocke du gzip)
+	);
+
+$spip_versions_fragments_key = array(
+	     "PRIMARY KEY"	=> "id_article, id_fragment, version_min");
+
+
+
+
+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_versions'] = array(
+	'field' => &$spip_versions,
+	'key' => &$spip_versions_key);
+$tables_auxiliaires['spip_versions_fragments'] = array(
+	'field' => &$spip_versions_fragments,
+	'key' => &$spip_versions_fragments_key);
+?>
diff --git a/ecrire/maj/vieille_base/10000/create.php b/ecrire/maj/vieille_base/10000/create.php
new file mode 100644
index 0000000000000000000000000000000000000000..89a52e08299a7a9dddf557c5269f9d5b29078ffe
--- /dev/null
+++ b/ecrire/maj/vieille_base/10000/create.php
@@ -0,0 +1,79 @@
+<?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/10000/serial');
+include_spip('maj/vieille_base/10000/auxiliaires');
+include_spip('maj/vieille_base/10000/typedoc');
+
+// http://doc.spip.org/@creer_base
+function maj_vieille_base_10000_create($server='') {
+	global $tables_principales, $tables_auxiliaires, $tables_images, $tables_sequences, $tables_documents, $tables_mime;
+
+	// Note: les mises à jour reexecutent ce code pour s'assurer
+	// de la conformite de la base
+	// pas de panique sur  "already exists" et "duplicate entry" donc.
+
+	$fcreate = sql_serveur('create', $server);
+	$freplace = sql_serveur('replace', $server);
+	$fupdate = sql_serveur('update', $server);
+	foreach($tables_principales as $k => $v)
+		$fcreate($k, $v['field'], $v['key'], true);
+
+	foreach($tables_auxiliaires as $k => $v)
+		$fcreate($k, $v['field'], $v['key'], false);
+
+
+	// Init ou Re-init ==> replace pas insert
+	$desc = $tables_principales['spip_types_documents'];
+	foreach($tables_images as $k => $v) {
+		$freplace('spip_types_documents',
+			 array('extension' => $k,
+			       'inclus' => 'image',
+			       'titre' => $v),
+			 $desc);
+	}
+
+	foreach($tables_sequences as $k => $v)
+		$freplace('spip_types_documents',
+			 array('extension' => $k,
+			       'titre' => $v,
+			       'inclus'=> 'embed'),
+			 $desc);
+
+	foreach($tables_documents as $k => $v)
+		$freplace('spip_types_documents',
+			 array('extension' => $k,
+			       'titre' => $v,
+			       'inclus' => 'non'),
+			 $desc);
+
+	foreach ($tables_mime as $extension => $type_mime)
+		$freplace('spip_types_documents',
+			 array("mime_type" => $type_mime,
+			       "extension" => $extension),
+			 $desc);
+}
+
+// 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));
+
+}*/
+
+?>
diff --git a/ecrire/maj/vieille_base/10000/serial.php b/ecrire/maj/vieille_base/10000/serial.php
new file mode 100644
index 0000000000000000000000000000000000000000..c8b45bb6d93a52c44d17d9ff5f61e051349ab46c
--- /dev/null
+++ b/ecrire/maj/vieille_base/10000/serial.php
@@ -0,0 +1,390 @@
+<?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 DEFAULT '' NOT NULL",
+		"titre"	=> "text DEFAULT '' NOT NULL",
+		"soustitre"	=> "text DEFAULT '' NOT NULL",
+		"id_rubrique"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"descriptif"	=> "text DEFAULT '' NOT NULL",
+		"chapo"	=> "mediumtext DEFAULT '' NOT NULL",
+		"texte"	=> "longtext DEFAULT '' NOT NULL",
+		"ps"	=> "mediumtext DEFAULT '' 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) DEFAULT '' 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"		=> "longtext NULL",
+		"id_version"	=> "int unsigned DEFAULT '0' NOT NULL",
+		"nom_site"	=> "tinytext DEFAULT '' NOT NULL",
+		"url_site"	=> "VARCHAR(255) DEFAULT '' NOT NULL",
+		"url_propre" => "VARCHAR(255) DEFAULT '' 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 url_propre"	=> "url_propre");
+$spip_articles_join = array(
+		"id_article"=>"id_article",
+		"id_rubrique"=>"id_rubrique");
+
+$spip_auteurs = array(
+		"id_auteur"	=> "bigint(21) NOT NULL",
+		"nom"	=> "text DEFAULT '' NOT NULL",
+		"bio"	=> "text DEFAULT '' NOT NULL",
+		"email"	=> "tinytext DEFAULT '' NOT NULL",
+		"nom_site"	=> "tinytext DEFAULT '' NOT NULL",
+		"url_site"	=> "text DEFAULT '' NOT NULL",
+		"login"	=> "VARCHAR(255) BINARY",
+		"pass"	=> "tinytext DEFAULT '' NOT NULL",
+		"low_sec"	=> "tinytext DEFAULT '' NOT NULL",
+		"statut"	=> "varchar(255)  DEFAULT '0' NOT NULL",
+		"maj"	=> "TIMESTAMP",
+		"pgp"	=> "TEXT DEFAULT '' NOT NULL",
+		"htpass"	=> "tinytext DEFAULT '' NOT NULL",
+		"en_ligne"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"imessage"	=> "VARCHAR(3)",
+		"messagerie"	=> "VARCHAR(3)",
+		"alea_actuel"	=> "tinytext",
+		"alea_futur"	=> "tinytext",
+		"prefs"	=> "tinytext",
+		"cookie_oubli"	=> "tinytext",
+		"source"	=> "VARCHAR(10) DEFAULT 'spip' NOT NULL",
+		"lang"	=> "VARCHAR(10) DEFAULT '' NOT NULL",
+		"url_propre" => "VARCHAR(255)",
+		"extra"	=> "longtext NULL");
+
+$spip_auteurs_key = array(
+		"PRIMARY KEY"	=> "id_auteur",
+		"KEY login"	=> "login",
+		"KEY statut"	=> "statut",
+		"KEY lang"	=> "lang",
+		"KEY en_ligne"	=> "en_ligne",
+		"KEY url_propre"	=> "url_propre");
+$spip_auteurs_join = array(
+		"id_auteur"=>"id_auteur",
+		"login"=>"login");
+
+
+$spip_breves = array(
+		"id_breve"	=> "bigint(21) NOT NULL",
+		"date_heure"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"titre"	=> "text DEFAULT '' NOT NULL",
+		"texte"	=> "longtext DEFAULT '' NOT NULL",
+		"lien_titre"	=> "text DEFAULT '' NOT NULL",
+		"lien_url"	=> "text DEFAULT '' NOT NULL",
+		"statut"	=> "varchar(6)  DEFAULT '0' NOT NULL",
+		"id_rubrique"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"lang"	=> "VARCHAR(10) DEFAULT '' NOT NULL",
+		"langue_choisie"	=> "VARCHAR(3) DEFAULT 'non'",
+		"maj"	=> "TIMESTAMP",
+		"extra"	=> "longtext NULL",
+		"url_propre" => "VARCHAR(255) DEFAULT '' NOT NULL");
+
+$spip_breves_key = array(
+		"PRIMARY KEY"	=> "id_breve",
+		"KEY id_rubrique"	=> "id_rubrique",
+		"KEY url_propre"	=> "url_propre");
+$spip_breves_join = array(
+		"id_breve"=>"id_breve",
+		"id_rubrique"=>"id_rubrique");
+
+$spip_messages = array(
+		"id_message"	=> "bigint(21) NOT NULL",
+		"titre"	=> "text DEFAULT '' NOT NULL",
+		"texte"	=> "longtext DEFAULT '' NOT NULL",
+		"type"	=> "varchar(6) DEFAULT '' 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) DEFAULT '' NOT NULL",
+		"statut"	=> "varchar(6)  DEFAULT '0' 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 DEFAULT '' NOT NULL",
+		"descriptif"	=> "text DEFAULT '' NOT NULL",
+		"texte"	=> "longtext DEFAULT '' NOT NULL",
+		"id_groupe"	=> "bigint(21) NOT NULL",
+		"type"	=> "text DEFAULT '' NOT NULL",
+		"extra"	=> "longtext NULL",
+		"url_propre" => "VARCHAR(255) DEFAULT '' NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_mots_key = array(
+		"PRIMARY KEY"	=> "id_mot",
+		"KEY url_propre"	=> "url_propre");
+
+$spip_groupes_mots = array(
+		"id_groupe"	=> "bigint(21) NOT NULL",
+		"titre"	=> "text DEFAULT '' NOT NULL",
+		"descriptif"	=> "text DEFAULT '' NOT NULL",
+		"texte"	=> "longtext DEFAULT '' NOT NULL",
+		"unseul"	=> "varchar(3) DEFAULT '' NOT NULL",
+		"obligatoire"	=> "varchar(3) DEFAULT '' NOT NULL",
+		"articles"	=> "varchar(3) DEFAULT '' NOT NULL",
+		"breves"	=> "varchar(3) DEFAULT '' NOT NULL",
+		"rubriques"	=> "varchar(3) DEFAULT '' NOT NULL",
+		"syndic"	=> "varchar(3) DEFAULT '' NOT NULL",
+		"minirezo"	=> "varchar(3) DEFAULT '' NOT NULL",
+		"comite"	=> "varchar(3) DEFAULT '' NOT NULL",
+		"forum"	=> "varchar(3) DEFAULT '' 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 DEFAULT '' NOT NULL",
+		"descriptif"	=> "text DEFAULT '' NOT NULL",
+		"texte"	=> "longtext DEFAULT '' 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) DEFAULT '0' 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'",
+		"extra"	=> "longtext NULL",
+		"url_propre" => "VARCHAR(255) DEFAULT '' NOT NULL",
+		"statut_tmp"	=> "varchar(10) DEFAULT '0' 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 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", */
+		"extension"	=> "VARCHAR(10) DEFAULT '' NOT NULL",
+		"titre"	=> "text DEFAULT '' NOT NULL",
+		"date"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"descriptif"	=> "text DEFAULT '' NOT NULL",
+		"fichier"	=> "varchar(255) DEFAULT '' NOT NULL",
+		"taille"	=> "integer",
+		"largeur"	=> "integer",
+		"hauteur"	=> "integer",
+		"mode"	=> "ENUM('vignette', 'document') NOT NULL",//+distant
+		"distant"	=> "VARCHAR(3) DEFAULT 'non'",
+		"maj"	=> "TIMESTAMP");
+
+$spip_documents_key = array(
+		"PRIMARY KEY"	=> "id_document",
+		"KEY id_vignette"	=> "id_vignette",
+		"KEY mode"	=> "mode",
+		"KEY extension"	=> "extension");
+$spip_documents_join = array(
+		"id_document"=>"id_document",
+		"extension"=>"extension");
+
+$spip_types_documents = array(
+/*		"id_type"	=> "bigint(21) NOT NULL", */
+		"extension"	=> "varchar(10) DEFAULT '' NOT NULL",
+		"titre"	=> "text DEFAULT '' NOT NULL",
+		"descriptif"	=> "text DEFAULT '' NOT NULL",
+		"mime_type"	=> "varchar(100) DEFAULT '' 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",
+*/
+		"PRIMARY KEY"	=> "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"	=> "text DEFAULT '' NOT NULL",
+		"url_site"	=> "text DEFAULT '' NOT NULL",
+		"url_syndic"	=> "text DEFAULT '' NOT NULL",
+		"descriptif"	=> "text DEFAULT '' NOT NULL",
+		"url_propre"	=> "VARCHAR(255) DEFAULT '' NOT NULL",
+		"maj"	=> "TIMESTAMP",
+		"syndication"	=> "VARCHAR(3) DEFAULT '' NOT NULL",
+		"statut"	=> "varchar(10) DEFAULT '0' 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"			=> "longtext 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 statut"	=> "statut, date_syndic",
+		"KEY url_propre"	=> "url_propre");
+$spip_syndic_join = array(
+		"id_syndic"=>"id_syndic",
+		"id_rubrique"=>"id_rubrique");
+		
+$spip_syndic_articles = array(
+		"id_syndic_article"	=> "bigint(21) NOT NULL",
+		"id_syndic"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"titre"	=> "text DEFAULT '' NOT NULL",
+		"url"	=> "VARCHAR(255) DEFAULT '' NOT NULL",
+		"date"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"lesauteurs"	=> "text DEFAULT '' NOT NULL",
+		"maj"	=> "TIMESTAMP",
+		"statut"	=> "varchar(10) DEFAULT '0' NOT NULL",
+		"descriptif"	=> "text DEFAULT '' 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_syndic_articles_join = array(
+		"id_syndic_article"=>"id_syndic_article",
+		"id_syndic"=>"id_syndic");
+
+$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",
+		"date_thread"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"titre"	=> "text DEFAULT '' NOT NULL",
+		"texte"	=> "mediumtext DEFAULT '' NOT NULL",
+		"auteur"	=> "text DEFAULT '' NOT NULL",
+		"email_auteur"	=> "text DEFAULT '' NOT NULL",
+		"nom_site"	=> "text DEFAULT '' NOT NULL",
+		"url_site"	=> "text DEFAULT '' NOT NULL",
+		"statut"	=> "varchar(8) DEFAULT '0' NOT NULL",
+		"ip"	=> "varchar(16) DEFAULT '' NOT NULL",
+		"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 statut"	=> "statut, date_heure",
+		"KEY date_thread" => "date_thread");
+$spip_forum_join = array(
+		"id_forum"=>"id_forum",
+		"id_parent"=>"id_parent",
+		"id_article"=>"id_article",
+		"id_breve"=>"id_breve",
+		"id_message"=>"id_message",
+		"id_syndic"=>"id_syndic",
+		"id_rubrique"=>"id_rubrique");
+
+$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 DEFAULT '' NOT NULL",
+		"ad_email"	=> "text DEFAULT '' NOT NULL",
+		"nom_site"	=> "text DEFAULT '' NOT NULL",
+		"url_site"	=> "text DEFAULT '' NOT NULL",
+		"message"	=> "mediumtext DEFAULT '' NOT NULL",
+		"statut"	=> "varchar(10) DEFAULT '0' NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_signatures_key = array(
+		"PRIMARY KEY"	=> "id_signature",
+		"KEY id_article"	=> "id_article",
+		"KEY statut" => "statut");
+$spip_signatures_join = array(
+		"id_signature"=>"id_signature",
+		"id_article"=>"id_article");
+
+
+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, 'join' => &$spip_articles_join);
+$tables_principales['spip_auteurs']  =
+	array('field' => &$spip_auteurs, 'key' => &$spip_auteurs_key,'join' => &$spip_auteurs_join);
+$tables_principales['spip_breves']   =
+	array('field' => &$spip_breves, 'key' => &$spip_breves_key,'join' => &$spip_breves_join);
+$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, 'join' => &$spip_documents_join);
+$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, 'join' => &$spip_syndic_join);
+$tables_principales['spip_syndic_articles']	=
+	array('field' => &$spip_syndic_articles, 'key' => &$spip_syndic_articles_key, 'join' => &$spip_syndic_articles_join);
+$tables_principales['spip_forum'] =
+	array('field' => &$spip_forum,	'key' => &$spip_forum_key, 'join' => &$spip_forum_join);
+$tables_principales['spip_signatures'] =
+	array('field' => &$spip_signatures, 'key' => &$spip_signatures_key, 'join' => &$spip_signatures_join);
+
+?>
diff --git a/ecrire/maj/vieille_base/10000/typedoc.php b/ecrire/maj/vieille_base/10000/typedoc.php
new file mode 100644
index 0000000000000000000000000000000000000000..fd97463719646dd99d78a7f31efe170b558c1929
--- /dev/null
+++ b/ecrire/maj/vieille_base/10000/typedoc.php
@@ -0,0 +1,208 @@
+<?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;
+
+global $tables_images, $tables_sequences, $tables_documents, $tables_mime, $mime_alias;
+
+$tables_images = array(
+		       // Images reconnues par PHP
+		       'jpg' => 'JPEG', 
+		       'png' => 'PNG', 
+		       'gif' =>'GIF',
+
+		       // 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',
+				'mp4' => 'MPEG4'
+			  );
+
+// 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',
+		'mp4' => 'application/mp4',
+
+		// 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'
+		
+	);
+
+
+	$mime_alias = array (
+		'audio/x-mpeg' => 'audio/mpeg',
+		'application/x-ogg' => 'application/ogg',
+		'video/mp4' => 'application/mp4',
+		'video/flv' => 'video/x-flv'
+	);
+
+?>
diff --git a/ecrire/maj/vieille_base/13000/auxiliaires.php b/ecrire/maj/vieille_base/13000/auxiliaires.php
new file mode 100644
index 0000000000000000000000000000000000000000..d5c6a03e2ed62636e4103b788ab7eea9cb467cff
--- /dev/null
+++ b/ecrire/maj/vieille_base/13000/auxiliaires.php
@@ -0,0 +1,331 @@
+<?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;
+
+// http://doc.spip.org/@base_auxiliaires
+function base_auxiliaires_13000(&$tables_auxiliaires){
+$spip_petitions = array(
+		"id_article"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"email_unique"	=> "CHAR (3) DEFAULT '' NOT NULL",
+		"site_obli"	=> "CHAR (3) DEFAULT '' NOT NULL",
+		"site_unique"	=> "CHAR (3) DEFAULT '' NOT NULL",
+		"message"	=> "CHAR (3) DEFAULT '' NOT NULL",
+		"texte"	=> "LONGTEXT DEFAULT '' NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_petitions_key = array(
+		"PRIMARY KEY"	=> "id_article");
+
+$spip_visites = array(
+		"date"	=> "DATE NOT NULL",
+		"visites"	=> "int UNSIGNED DEFAULT '0' 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 DEFAULT '0' NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_visites_articles_key = array(
+		"PRIMARY KEY"	=> "date, id_article");
+
+$spip_resultats = array(
+ 		"recherche"	=> "char(16) not null default ''",
+		"id"	=> "INT UNSIGNED NOT NULL",
+ 		"points"	=> "INT UNSIGNED DEFAULT '0' NOT NULL",
+		"maj"	=> "TIMESTAMP" );
+
+$spip_resultats_key = array(
+// pas de cle ni index, ca fait des insertions plus rapides et les requetes jointes utilisees en recheche ne sont pas plus lentes ...
+);
+
+$spip_referers = array(
+		"referer_md5"	=> "bigint UNSIGNED NOT NULL",
+		"date"		=> "DATE NOT NULL",
+		"referer"	=> "VARCHAR (255)",
+		"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",
+		"referer"	=> "VARCHAR (255) DEFAULT '' 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)");
+
+$spip_auteurs_messages_key = array(
+		"PRIMARY KEY"	=> "id_auteur, id_message",
+		"KEY id_message"	=> "id_message");
+
+$spip_documents_liens = array(
+		"id_document"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"id_objet"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"objet"	=> "VARCHAR (25) DEFAULT '' NOT NULL",
+		"vu"	=> "ENUM('non', 'oui') DEFAULT 'non' NOT NULL");
+
+$spip_documents_liens_key = array(
+		"PRIMARY KEY"		=> "id_document,id_objet,objet",
+		"KEY id_document"	=> "id_document");
+
+/*
+$spip_documents_articles = array(
+		"id_document"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"id_article"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"vu"	=> "ENUM('non', 'oui') DEFAULT 'non' 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",
+		"vu"	=> "ENUM('non', 'oui') DEFAULT 'non' 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",
+		"vu"	=> "ENUM('non', 'oui') DEFAULT 'non' NOT NULL");
+
+$spip_documents_breves_key = array(
+		"PRIMARY KEY"		=> "id_breve, id_document",
+		"KEY id_document"	=> "id_document");
+
+$spip_documents_forum = array(
+		"id_document"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"id_forum"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"vu"	=> "ENUM('non', 'oui') DEFAULT 'non' NOT NULL");
+
+$spip_documents_forum_key = array(
+		"PRIMARY KEY"		=> "id_forum, 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_versions = array (
+		"id_article"	=> "bigint(21) NOT NULL",
+		"id_version"	=> "bigint(21) DEFAULT 0 NOT NULL",
+		"date"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"id_auteur"	=> "VARCHAR(23) DEFAULT '' NOT NULL", # stocke aussi IP(v6)
+		"titre_version"	=> "text DEFAULT '' NOT NULL",
+		"permanent"	=> "char(3)",
+		"champs"	=> "text");
+
+$spip_versions_key = array (
+		"PRIMARY KEY"	=> "id_article, id_version");
+
+$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"  # ici c'est VRAIMENT un blob (on y stocke du gzip)
+	);
+
+$spip_versions_fragments_key = array(
+	     "PRIMARY KEY"	=> "id_article, id_fragment, version_min");
+
+
+$spip_urls = array(
+	"url"			=> "VARCHAR(255) NOT NULL",
+	// la table cible
+	"type"			=> "varchar(15) DEFAULT 'article' NOT NULL",
+	// l'id dans la table
+	"id_objet"		=> "bigint(21) NOT NULL",
+	// pour connaitre la plus recente. 
+	// ATTENTION, pas on update CURRENT_TIMESTAMP implicite
+	// et pas le nom maj, surinterprete par inc/import_1_3
+	"date"			=> "DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL");
+
+$spip_urls_key = array(
+	"PRIMARY KEY"		=> "url",
+	"KEY type"		=> "type, id_objet");
+
+$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_liens'] = array(
+	'field' => &$spip_documents_liens,
+	'key' => &$spip_documents_liens_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_documents_forum'] = array(
+	'field' => &$spip_documents_forum,
+	'key' => &$spip_documents_forum_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_resultats'] = array(
+	'field' => &$spip_resultats,
+	'key' => &$spip_resultats_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_urls'] = array(
+	'field' => &$spip_urls,
+	'key' => &$spip_urls_key);
+	
+	$tables_auxiliaires = pipeline('declarer_tables_auxiliaires',$tables_auxiliaires);
+}
+
+global $tables_auxiliaires;
+base_auxiliaires_13000($tables_auxiliaires);
+?>
diff --git a/ecrire/maj/vieille_base/13000/create.php b/ecrire/maj/vieille_base/13000/create.php
new file mode 100644
index 0000000000000000000000000000000000000000..6eeeeb9165105ff48555222da5af84142d285e53
--- /dev/null
+++ b/ecrire/maj/vieille_base/13000/create.php
@@ -0,0 +1,35 @@
+<?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/13000/serial');
+include_spip('maj/vieille_base/13000/auxiliaires');
+include_spip('maj/vieille_base/13000/typedoc');
+include_spip('base/create');
+
+// http://doc.spip.org/@creer_base
+function maj_vieille_base_13000_create($serveur='') {
+	global $tables_principales, $tables_auxiliaires;
+
+	// Note: les mises a jour reexecutent ce code pour s'assurer
+	// de la conformite de la base
+	// pas de panique sur  "already exists" et "duplicate entry" donc.
+
+	foreach($tables_principales as $k => $v)
+		creer_ou_upgrader_table($k,$v,true,false,$serveur);
+
+	foreach($tables_auxiliaires as $k => $v)
+		creer_ou_upgrader_table($k,$v,false,false,$serveur);
+}
+
+
+?>
diff --git a/ecrire/maj/vieille_base/13000/serial.php b/ecrire/maj/vieille_base/13000/serial.php
new file mode 100644
index 0000000000000000000000000000000000000000..4133a65740078fb859352dfe78b32db6a7c85c70
--- /dev/null
+++ b/ecrire/maj/vieille_base/13000/serial.php
@@ -0,0 +1,393 @@
+<?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;
+
+// http://doc.spip.org/@base_serial
+function base_serial_13000(&$tables_principales){
+$spip_articles = array(
+		"id_article"	=> "bigint(21) NOT NULL",
+		"surtitre"	=> "text DEFAULT '' NOT NULL",
+		"titre"	=> "text DEFAULT '' NOT NULL",
+		"soustitre"	=> "text DEFAULT '' NOT NULL",
+		"id_rubrique"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"descriptif"	=> "text DEFAULT '' NOT NULL",
+		"chapo"	=> "mediumtext DEFAULT '' NOT NULL",
+		"texte"	=> "longtext DEFAULT '' NOT NULL",
+		"ps"	=> "mediumtext DEFAULT '' 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) DEFAULT '' 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"		=> "longtext NULL",
+		"id_version"	=> "int unsigned DEFAULT '0' NOT NULL",
+		"nom_site"	=> "tinytext DEFAULT '' NOT NULL",
+		"url_site"	=> "VARCHAR(255) DEFAULT '' NOT NULL",
+#		"url_propre" => "VARCHAR(255) DEFAULT '' 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_propre"	=> "url_propre"
+);
+$spip_articles_join = array(
+		"id_article"=>"id_article",
+		"id_rubrique"=>"id_rubrique");
+
+$spip_auteurs = array(
+		"id_auteur"	=> "bigint(21) NOT NULL",
+		"nom"	=> "text DEFAULT '' NOT NULL",
+		"bio"	=> "text DEFAULT '' NOT NULL",
+		"email"	=> "tinytext DEFAULT '' NOT NULL",
+		"nom_site"	=> "tinytext DEFAULT '' NOT NULL",
+		"url_site"	=> "text DEFAULT '' NOT NULL",
+		"login"	=> "VARCHAR(255) BINARY",
+		"pass"	=> "tinytext DEFAULT '' NOT NULL",
+		"low_sec"	=> "tinytext DEFAULT '' NOT NULL",
+		"statut"	=> "varchar(255)  DEFAULT '0' NOT NULL",
+		"maj"	=> "TIMESTAMP",
+		"pgp"	=> "TEXT DEFAULT '' NOT NULL",
+		"htpass"	=> "tinytext DEFAULT '' NOT NULL",
+		"en_ligne"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"imessage"	=> "VARCHAR(3)",
+		"messagerie"	=> "VARCHAR(3)",
+		"alea_actuel"	=> "tinytext",
+		"alea_futur"	=> "tinytext",
+		"prefs"	=> "tinytext",
+		"cookie_oubli"	=> "tinytext",
+		"source"	=> "VARCHAR(10) DEFAULT 'spip' NOT NULL",
+		"lang"	=> "VARCHAR(10) DEFAULT '' NOT NULL",
+#		"url_propre" => "VARCHAR(255)",
+		"extra"	=> "longtext NULL");
+
+$spip_auteurs_key = array(
+		"PRIMARY KEY"	=> "id_auteur",
+		"KEY login"	=> "login",
+		"KEY statut"	=> "statut",
+		"KEY en_ligne"	=> "en_ligne",
+#		"KEY url_propre"	=> "url_propre"
+);
+$spip_auteurs_join = array(
+		"id_auteur"=>"id_auteur",
+		"login"=>"login");
+
+
+$spip_breves = array(
+		"id_breve"	=> "bigint(21) NOT NULL",
+		"date_heure"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"titre"	=> "text DEFAULT '' NOT NULL",
+		"texte"	=> "longtext DEFAULT '' NOT NULL",
+		"lien_titre"	=> "text DEFAULT '' NOT NULL",
+		"lien_url"	=> "text DEFAULT '' NOT NULL",
+		"statut"	=> "varchar(6)  DEFAULT '0' NOT NULL",
+		"id_rubrique"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"lang"	=> "VARCHAR(10) DEFAULT '' NOT NULL",
+		"langue_choisie"	=> "VARCHAR(3) DEFAULT 'non'",
+		"maj"	=> "TIMESTAMP",
+		"extra"	=> "longtext NULL",
+#		"url_propre" => "VARCHAR(255) DEFAULT '' NOT NULL"
+);
+
+$spip_breves_key = array(
+		"PRIMARY KEY"	=> "id_breve",
+		"KEY id_rubrique"	=> "id_rubrique",
+#		"KEY url_propre"	=> "url_propre"
+);
+$spip_breves_join = array(
+		"id_breve"=>"id_breve",
+		"id_rubrique"=>"id_rubrique");
+
+$spip_messages = array(
+		"id_message"	=> "bigint(21) NOT NULL",
+		"titre"	=> "text DEFAULT '' NOT NULL",
+		"texte"	=> "longtext DEFAULT '' NOT NULL",
+		"type"	=> "varchar(6) DEFAULT '' 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) DEFAULT '' NOT NULL",
+		"statut"	=> "varchar(6)  DEFAULT '0' 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 DEFAULT '' NOT NULL",
+		"descriptif"	=> "text DEFAULT '' NOT NULL",
+		"texte"	=> "longtext DEFAULT '' NOT NULL",
+		"id_groupe"	=> "bigint(21) DEFAULT 0 NOT NULL",
+		"type"	=> "text DEFAULT '' NOT NULL",
+		"extra"	=> "longtext NULL",
+#		"url_propre" => "VARCHAR(255) DEFAULT '' NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_mots_key = array(
+		"PRIMARY KEY"	=> "id_mot",
+#		"KEY url_propre"	=> "url_propre"
+);
+
+$spip_groupes_mots = array(
+		"id_groupe"	=> "bigint(21) NOT NULL",
+		"titre"	=> "text DEFAULT '' NOT NULL",
+		"descriptif"	=> "text DEFAULT '' NOT NULL",
+		"texte"	=> "longtext DEFAULT '' NOT NULL",
+		"unseul"	=> "varchar(3) DEFAULT '' NOT NULL",
+		"obligatoire"	=> "varchar(3) DEFAULT '' NOT NULL",
+		"tables_liees" => "text DEFAULT '' NOT NULL",
+		# suppression des champs a faire dans la maj
+		#"articles"	=> "varchar(3) DEFAULT '' NOT NULL",
+		#"breves"	=> "varchar(3) DEFAULT '' NOT NULL",
+		#"rubriques"	=> "varchar(3) DEFAULT '' NOT NULL",
+		#"syndic"	=> "varchar(3) DEFAULT '' NOT NULL",
+		"minirezo"	=> "varchar(3) DEFAULT '' NOT NULL",
+		"comite"	=> "varchar(3) DEFAULT '' NOT NULL",
+		"forum"	=> "varchar(3) DEFAULT '' 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 DEFAULT '' NOT NULL",
+		"descriptif"	=> "text DEFAULT '' NOT NULL",
+		"texte"	=> "longtext DEFAULT '' 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) DEFAULT '0' 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'",
+		"extra"	=> "longtext NULL",
+#		"url_propre" => "VARCHAR(255) DEFAULT '' NOT NULL",
+		"statut_tmp"	=> "varchar(10) DEFAULT '0' 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 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",
+		"extension"	=> "VARCHAR(10) DEFAULT '' NOT NULL",
+		"titre"	=> "text DEFAULT '' NOT NULL",
+		"date"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"descriptif"	=> "text DEFAULT '' NOT NULL",
+		"fichier"	=> "varchar(255) DEFAULT '' NOT NULL",
+		"taille"	=> "integer",
+		"largeur"	=> "integer",
+		"hauteur"	=> "integer",
+		"mode"	=> "ENUM('vignette', 'image', 'document') DEFAULT 'document' NOT NULL",
+		"distant"	=> "VARCHAR(3) DEFAULT 'non'",
+		"maj"	=> "TIMESTAMP");
+
+$spip_documents_key = array(
+		"PRIMARY KEY"	=> "id_document",
+		"KEY id_vignette"	=> "id_vignette",
+		"KEY mode"	=> "mode",
+		"KEY extension"	=> "extension");
+$spip_documents_join = array(
+		"id_document"=>"id_document",
+		"extension"=>"extension");
+
+$spip_types_documents = array(
+		"extension"	=> "varchar(10) DEFAULT '' NOT NULL",
+		"titre"	=> "text DEFAULT '' NOT NULL",
+		"descriptif"	=> "text DEFAULT '' NOT NULL",
+		"mime_type"	=> "varchar(100) DEFAULT '' 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"	=> "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"	=> "text DEFAULT '' NOT NULL",
+		"url_site"	=> "text DEFAULT '' NOT NULL",
+		"url_syndic"	=> "text DEFAULT '' NOT NULL",
+		"descriptif"	=> "text DEFAULT '' NOT NULL",
+#		"url_propre"	=> "VARCHAR(255) DEFAULT '' NOT NULL",
+		"maj"	=> "TIMESTAMP",
+		"syndication"	=> "VARCHAR(3) DEFAULT '' NOT NULL",
+		"statut"	=> "varchar(10) DEFAULT '0' 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"			=> "longtext 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 statut"	=> "statut, date_syndic",
+#		"KEY url_propre"	=> "url_propre"
+);
+$spip_syndic_join = array(
+		"id_syndic"=>"id_syndic",
+		"id_rubrique"=>"id_rubrique");
+		
+$spip_syndic_articles = array(
+		"id_syndic_article"	=> "bigint(21) NOT NULL",
+		"id_syndic"	=> "bigint(21) DEFAULT '0' NOT NULL",
+		"titre"	=> "text DEFAULT '' NOT NULL",
+		"url"	=> "VARCHAR(255) DEFAULT '' NOT NULL",
+		"date"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"lesauteurs"	=> "text DEFAULT '' NOT NULL",
+		"maj"	=> "TIMESTAMP",
+		"statut"	=> "varchar(10) DEFAULT '0' NOT NULL",
+		"descriptif"	=> "text DEFAULT '' 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_syndic_articles_join = array(
+		"id_syndic_article"=>"id_syndic_article",
+		"id_syndic"=>"id_syndic");
+
+$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",
+		"date_thread"	=> "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
+		"titre"	=> "text DEFAULT '' NOT NULL",
+		"texte"	=> "mediumtext DEFAULT '' NOT NULL",
+		"auteur"	=> "text DEFAULT '' NOT NULL",
+		"email_auteur"	=> "text DEFAULT '' NOT NULL",
+		"nom_site"	=> "text DEFAULT '' NOT NULL",
+		"url_site"	=> "text DEFAULT '' NOT NULL",
+		"statut"	=> "varchar(8) DEFAULT '0' NOT NULL",
+		"ip"	=> "varchar(16) DEFAULT '' NOT NULL",
+		"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_auteur"	=> "id_auteur",
+		"KEY id_parent"	=> "id_parent",
+		"KEY id_thread"	=> "id_thread",
+		"KEY optimal" => "statut,id_parent,id_article,date_heure,id_breve,id_syndic,id_rubrique");
+
+$spip_forum_join = array(
+		"id_forum"=>"id_forum",
+		"id_parent"=>"id_parent",
+		"id_article"=>"id_article",
+		"id_breve"=>"id_breve",
+		"id_message"=>"id_message",
+		"id_syndic"=>"id_syndic",
+		"id_rubrique"=>"id_rubrique");
+
+$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 DEFAULT '' NOT NULL",
+		"ad_email"	=> "text DEFAULT '' NOT NULL",
+		"nom_site"	=> "text DEFAULT '' NOT NULL",
+		"url_site"	=> "text DEFAULT '' NOT NULL",
+		"message"	=> "mediumtext DEFAULT '' NOT NULL",
+		"statut"	=> "varchar(10) DEFAULT '0' NOT NULL",
+		"maj"	=> "TIMESTAMP");
+
+$spip_signatures_key = array(
+		"PRIMARY KEY"	=> "id_signature",
+		"KEY id_article"	=> "id_article",
+		"KEY statut" => "statut");
+$spip_signatures_join = array(
+		"id_signature"=>"id_signature",
+		"id_article"=>"id_article");
+
+/// 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, 'join' => &$spip_articles_join);
+$tables_principales['spip_auteurs']  =
+	array('field' => &$spip_auteurs, 'key' => &$spip_auteurs_key,'join' => &$spip_auteurs_join);
+$tables_principales['spip_breves']   =
+	array('field' => &$spip_breves, 'key' => &$spip_breves_key,'join' => &$spip_breves_join);
+$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, 'join' => &$spip_documents_join);
+$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, 'join' => &$spip_syndic_join);
+$tables_principales['spip_syndic_articles']	=
+	array('field' => &$spip_syndic_articles, 'key' => &$spip_syndic_articles_key, 'join' => &$spip_syndic_articles_join);
+$tables_principales['spip_forum'] =
+	array('field' => &$spip_forum,	'key' => &$spip_forum_key, 'join' => &$spip_forum_join);
+$tables_principales['spip_signatures'] =
+	array('field' => &$spip_signatures, 'key' => &$spip_signatures_key, 'join' => &$spip_signatures_join);
+	
+	$tables_principales = pipeline('declarer_tables_principales',$tables_principales);
+}
+
+global $tables_principales;
+base_serial_13000($tables_principales);
+
+?>
diff --git a/ecrire/maj/vieille_base/13000/typedoc.php b/ecrire/maj/vieille_base/13000/typedoc.php
new file mode 100644
index 0000000000000000000000000000000000000000..7cf2a7ab99a4ae07f87896d829751cd5870e8e1d
--- /dev/null
+++ b/ecrire/maj/vieille_base/13000/typedoc.php
@@ -0,0 +1,224 @@
+<?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;
+
+global $tables_images, $tables_sequences, $tables_documents, $tables_mime, $mime_alias;
+
+$tables_images = array(
+		       // Images reconnues par PHP
+		       'jpg' => 'JPEG', 
+		       'png' => 'PNG', 
+		       'gif' =>'GIF',
+
+		       // 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',
+			  '3gp' => '3rd Generation Partnership Project'
+			  );
+
+// Documents varies
+$tables_documents = array(
+			  'abw' => 'Abiword',
+			  'ai' => 'Adobe Illustrator',
+			  'bz2' => 'BZip',
+			  'bin' => 'Binary Data',
+			  'blend' => 'Blender',
+			  'c' => 'C source',
+			  'cls' => 'LaTeX Class',
+			  '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',
+			  'sty' => 'LaTeX Style Sheet',
+			  'sxc' => 'OpenOffice.org Calc',
+			  'sxi' => 'OpenOffice.org Impress',
+			  'sxw' => 'OpenOffice.org',
+			  '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',
+		'3gp'=>'video/3gpp',
+
+		// 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',
+		'cls'=>'text/x-tex',
+		'sty'=>'text/x-tex',
+	);
+
+
+	$mime_alias = array (
+		'audio/x-mpeg' => 'audio/mpeg',
+		'application/x-ogg' => 'application/ogg',
+		'video/mp4' => 'application/mp4',
+		'video/flv' => 'video/x-flv',
+		'audio/3gpp' => 'video/3gpp'
+	);
+
+?>
diff --git a/ecrire/maj/vieille_base/charger.php b/ecrire/maj/vieille_base/charger.php
index 6fc32917701cbccdc5560f2cb9a5f7738cf76487..f66e69dd7d3a896bc9068bda5929ac00ae7822ec 100644
--- a/ecrire/maj/vieille_base/charger.php
+++ b/ecrire/maj/vieille_base/charger.php
@@ -20,13 +20,16 @@ function maj_vieille_base_charger_dist($version_cible){
 	'1.915'=>'1915',
 	'1.917'=>'1917',
 	'1.927'=>'1927',
+	'10000'=>'10000',
+	'12000'=>'13000',
 	);
 	$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'];
@@ -47,4 +50,4 @@ function maj_vieille_base_charger_dist($version_cible){
 	return $version;
 }
 
-?>
\ No newline at end of file
+?>
diff --git a/ecrire/req/mysql.php b/ecrire/req/mysql.php
index 2d0e13e9dad1c3db53827934a68841a702411c85..e082b201085bf5ed5ce30367225bed1e7944253d 100644
--- a/ecrire/req/mysql.php
+++ b/ecrire/req/mysql.php
@@ -665,18 +665,18 @@ function spip_mysql_multi ($objet, $lang) {
 		"     CONCAT( ".
 		"          LEFT(".$objet.", INSTR(".$objet.", '<multi>')-1), ".
 		"          IF( ".
-		"               INSTR(TRIM(RIGHT(".$objet.", LENGTH(".$objet.") -(6+INSTR(".$objet.", '<multi>')))),'[".$lang."]') = 0, ".
+		"               INSTR(TRIM(RIGHT(".$objet.", CHAR_LENGTH(".$objet.") -(6+INSTR(".$objet.", '<multi>')))),'[".$lang."]') = 0, ".
 		"               IF( ".
-		"                     TRIM(RIGHT(".$objet.", LENGTH(".$objet.") -(6+INSTR(".$objet.", '<multi>')))) REGEXP '^\\[[a-z\_]{2,}\\]', ".
+		"                     TRIM(RIGHT(".$objet.", CHAR_LENGTH(".$objet.") -(6+INSTR(".$objet.", '<multi>')))) REGEXP '^\\[[a-z\_]{2,}\\]', ".
 		"                     INSERT( ".
-		"                          TRIM(RIGHT(".$objet.", LENGTH(".$objet.") -(6+INSTR(".$objet.", '<multi>')))), ".
+		"                          TRIM(RIGHT(".$objet.", CHAR_LENGTH(".$objet.") -(6+INSTR(".$objet.", '<multi>')))), ".
 		"                          1, ".
-		"                          INSTR(TRIM(RIGHT(".$objet.", LENGTH(".$objet.") -(6+INSTR(".$objet.", '<multi>')))), ']'), ".
+		"                          INSTR(TRIM(RIGHT(".$objet.", CHAR_LENGTH(".$objet.") -(6+INSTR(".$objet.", '<multi>')))), ']'), ".
 		"                          '' ".
 		"                     ), ".
-		"                     TRIM(RIGHT(".$objet.", LENGTH(".$objet.") -(6+INSTR(".$objet.", '<multi>')))) ".
+		"                     TRIM(RIGHT(".$objet.", CHAR_LENGTH(".$objet.") -(6+INSTR(".$objet.", '<multi>')))) ".
 		"                ), ".
-		"               TRIM(RIGHT(".$objet.", ( LENGTH(".$objet.") - (INSTR(".$objet.", '[".$lang."]')+ LENGTH('[".$lang."]')-1) ) )) ".
+		"               TRIM(RIGHT(".$objet.", ( CHAR_LENGTH(".$objet.") - (INSTR(".$objet.", '[".$lang."]')+ CHAR_LENGTH('[".$lang."]')-1) ) )) ".
 		"          ) ".
 		"     ) ".
 		"))) AS multi";
diff --git a/ecrire/req/pg.php b/ecrire/req/pg.php
index a2a882c717351d79f647ca2b62ebce1366d36c5b..2da7480bf6a4663d9cb92d58e115e34da24b1713 100644
--- a/ecrire/req/pg.php
+++ b/ecrire/req/pg.php
@@ -111,7 +111,7 @@ function spip_pg_trace_query($query, $serveur='')
 	$db = $connexion['db'];
 
 	$t = !isset($_GET['var_profile']) ? 0 : trace_query_start();
-	$r = pg_query($link, $query);
+	$r = spip_pg_query_simple($link, $query);
 
 	if ($e = spip_pg_errno())	// Log de l'erreur eventuelle
 		$e .= spip_pg_error($query); // et du fautif
@@ -134,13 +134,58 @@ function spip_pg_query($query, $serveur='',$requeter=true)
 		$query = substr($query, 0, -strlen($suite));
 	} else $suite ='';
 	$query = preg_replace('/([,\s])spip_/', '\1'.$prefixe.'_', $query) . $suite;
-	
+
 	// renvoyer la requete inerte si demandee
 	if (!$requeter) return $query;
 
 	return spip_pg_trace_query($query, $serveur);
 }
 
+function spip_pg_query_simple($link, $query){
+	#spip_log(var_export($query,true), 'pg_queries');
+	return pg_query($link, $query);
+}
+
+/*
+ * Retrouver les champs 'timestamp'
+ * pour les ajouter aux 'insert' ou 'replace'
+ * afin de simuler le fonctionnement de mysql 
+ * 
+ * stocke le resultat pour ne pas faire 
+ * de requetes showtable intempestives
+ */
+function spip_pg_ajouter_champs_timestamp($table, $couples, $desc='', $serveur=''){
+	static $tables = array();
+	
+	if (!isset($tables[$table])){
+		
+		if (!$desc){
+			$f = charger_fonction('trouver_table', 'base');
+			$desc = $f($table, $serveur);
+			// si pas de description, on ne fait rien, ou on die() ?
+			if (!$desc) return $couples;
+		}
+		
+		// recherche des champs avec simplement 'TIMESTAMP'
+		// cependant, il faudra peut etre etendre
+		// avec la gestion de DEFAULT et ON UPDATE
+		// mais ceux-ci ne sont pas utilises dans le core
+		$tables[$table] = array();
+		foreach ($desc['field'] as $k=>$v){
+			if (strpos(strtolower(ltrim($v)), 'timestamp')===0)
+			$tables[$table][] = $k;
+		}
+	}
+	
+	// ajout des champs type 'timestamp' absents
+	foreach ($tables[$table] as $maj){
+		if (!array_key_exists($maj, $couples))
+			$couples[$maj] = "NOW()";	
+	}
+	return $couples;
+}
+ 	
+	
 // Alter en PG ne traite pas les index
 // http://doc.spip.org/@spip_pg_alter
 function spip_pg_alter($query, $serveur='',$requeter=true) {
@@ -347,7 +392,7 @@ function spip_pg_explain($query, $serveur='',$requeter=true){
 	} else $suite ='';
 	$query = 'EXPLAIN ' . preg_replace('/([,\s])spip_/', '\1'.$prefixe.'_', $query) . $suite;
 
-	$r = pg_query($link,$query);
+	$r = spip_pg_query_simple($link,$query);
 	if (!$requeter) return $r;
 	return spip_pg_fetch($r, NULL, $serveur);
 }
@@ -369,7 +414,7 @@ function spip_pg_selectdb($db, $serveur='',$requeter=true) {
 
 // http://doc.spip.org/@spip_pg_listdbs
 function spip_pg_listdbs() {
-	return pg_query("select * from pg_database");
+	return spip_pg_query_simple("select * from pg_database");
 }
 
 // http://doc.spip.org/@spip_pg_select
@@ -512,7 +557,12 @@ function spip_pg_frommysql($arg)
 
 	$res = preg_replace('/UNIX_TIMESTAMP\s*[(]\s*[)]/',
 			    ' EXTRACT(epoch FROM NOW())', $res);
-
+	
+	// la fonction md5(integer) n'est pas connu en pg
+	// il faut donc forcer les types en text (cas de md5(id_article))
+	$res = preg_replace('/md5\s*[(]([^)]*)[)]/i',
+			    'MD5(CAST(\1 AS text))', $res);
+											
 	$res = preg_replace('/UNIX_TIMESTAMP\s*[(]([^)]*)[)]/',
 			    ' EXTRACT(epoch FROM \1)', $res);
 
@@ -713,7 +763,7 @@ function spip_pg_insert($table, $champs, $valeurs, $desc=array(), $serveur='',$r
 	$ins = (strlen($champs)<3)
 	  ? " DEFAULT VALUES"
 	  : "$champs VALUES $valeurs";
-	$r = pg_query($link, $q="INSERT INTO $table $ins $ret");
+	$r = spip_pg_query_simple($link, $q="INSERT INTO $table $ins $ret");
 #	spip_log($q);
 	if ($r) {
 		if (!$ret) return 0;
@@ -732,11 +782,14 @@ function spip_pg_insertq($table, $couples=array(), $desc=array(), $serveur='',$r
 	if (!$desc) $desc = description_table($table);
 	if (!$desc) die("$table insertion sans description");
 	$fields =  $desc['field'];
-		
+	
 	foreach ($couples as $champ => $val) {
 		$couples[$champ]=  spip_pg_cite($val, $fields[$champ]);
 	}
 
+	// recherche de champs 'timestamp' pour mise a jour auto de ceux-ci
+	$couples = spip_pg_ajouter_champs_timestamp($table, $couples, $desc, $serveur);
+	
 	return spip_pg_insert($table, "(".join(',',array_keys($couples)).")", "(".join(',', $couples).")", $desc, $serveur, $requeter);
 }
 
@@ -749,12 +802,19 @@ function spip_pg_insertq_multi($table, $tab_couples=array(), $desc=array(), $ser
 	if (!$desc) die("$table insertion sans description");
 	$fields =  isset($desc['field'])?$desc['field']:array();
 	
-	$cles = "(" . join(',',array_keys($tab_couples[0])). ')';
+	// recherche de champs 'timestamp' pour mise a jour auto de ceux-ci
+	// une premiere fois pour ajouter maj dans les cles
+	$les_cles = spip_pg_ajouter_champs_timestamp($table, $tab_couples[0], $desc, $serveur);
+	
+	$cles = "(" . join(',',array_keys($les_cles)). ')';
 	$valeurs = array();
 	foreach ($tab_couples as $couples) {
 		foreach ($couples as $champ => $val){
 			$couples[$champ]= spip_pg_cite($val, $fields[$champ]);
 		}
+		// recherche de champs 'timestamp' pour mise a jour auto de ceux-ci
+		$couples = spip_pg_ajouter_champs_timestamp($table, $couples, $desc, $serveur);
+		
 		$valeurs[] = '(' .join(',', $couples) . ')';
 	}
 	$valeurs = implode(', ',$valeurs);
@@ -764,16 +824,20 @@ function spip_pg_insertq_multi($table, $tab_couples=array(), $desc=array(), $ser
 
 
 // http://doc.spip.org/@spip_pg_update
-function spip_pg_update($table, $champs, $where='', $desc='', $serveur='',$requeter=true) {
+function spip_pg_update($table, $couples, $where='', $desc='', $serveur='',$requeter=true) {
 
-	if (!$champs) return;
+	if (!$couples) return;
 	$connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0];
 	$prefixe = $connexion['prefixe'];
 	$link = $connexion['link'];
 	$db = $connexion['db'];
 	if ($prefixe) $table = preg_replace('/^spip/', $prefixe, $table);
+
+	// recherche de champs 'timestamp' pour mise a jour auto de ceux-ci
+	$couples = spip_pg_ajouter_champs_timestamp($table, $couples, $desc, $serveur);
+
 	$set = array();
-	foreach ($champs as $champ => $val) {
+	foreach ($couples as $champ => $val) {
 		$set[] = $champ . '=' . $val; 
 	}
 
@@ -790,21 +854,20 @@ function spip_pg_update($table, $champs, $where='', $desc='', $serveur='',$reque
 // idem, mais les valeurs sont des constantes a mettre entre apostrophes
 // sauf les expressions de date lorsqu'il s'agit de fonctions SQL (NOW etc)
 // http://doc.spip.org/@spip_pg_updateq
-function spip_pg_updateq($table, $champs, $where='', $desc=array(), $serveur='',$requeter=true) {
-	if (!$champs) return;
+function spip_pg_updateq($table, $couples, $where='', $desc=array(), $serveur='',$requeter=true) {
+	if (!$couples) return;
 	if (!$desc) $desc = description_table($table);
 	$fields = $desc['field'];
-	foreach ($champs as $k => $val) {
-		$champs[$k] = spip_pg_cite($val, $fields[$k]);
+	foreach ($couples as $k => $val) {
+		$couples[$k] = spip_pg_cite($val, $fields[$k]);
 	}
 
-	return spip_pg_update($table, $champs, $where, $desc, $serveur, $requeter);
+	return spip_pg_update($table, $couples, $where, $desc, $serveur, $requeter);
 }
 
 
 // http://doc.spip.org/@spip_pg_replace
 function spip_pg_replace($table, $values, $desc, $serveur='',$requeter=true) {
-
 	if (!$values) {spip_log("replace vide $table"); return 0;}
 	$connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0];
 	$prefixe = $connexion['prefixe'];
@@ -824,6 +887,9 @@ function spip_pg_replace($table, $values, $desc, $serveur='',$requeter=true) {
 		else $prims[$k]= "$k=$v";
 	}
 
+	// recherche de champs 'timestamp' pour mise a jour auto de ceux-ci
+	$values = spip_pg_ajouter_champs_timestamp($table, $values, $desc, $serveur);
+	
 	$where = join(' AND ', $prims);
 	if (!$where) {
 		return spip_pg_insert($table, "(".join(',',array_keys($values)).")", "(".join(',', $values).")", $desc, $serveur);
@@ -837,7 +903,7 @@ function spip_pg_replace($table, $values, $desc, $serveur='',$requeter=true) {
 	}
 
 	if ($couples) {
-	  $couples = pg_query($link, $q = "UPDATE $table SET $couples WHERE $where");
+	  $couples = spip_pg_query_simple($link, $q = "UPDATE $table SET $couples WHERE $where");
 #	  spip_log($q);
 	  if (!$couples) {
 	    $n = spip_pg_errno();
@@ -850,7 +916,7 @@ function spip_pg_replace($table, $values, $desc, $serveur='',$requeter=true) {
 		$ret = !$seq ? '' :
 		  (" RETURNING nextval('$seq') < $prim");
 
-		$couples = pg_query($link, $q = "INSERT INTO $table (" . join(',',array_keys($values)) . ') VALUES (' .join(',', $values) . ")$ret");
+		$couples = spip_pg_query_simple($link, $q = "INSERT INTO $table (" . join(',',array_keys($values)) . ') VALUES (' .join(',', $values) . ")$ret");
 	    if (!$couples) {
 	      $n = spip_pg_errno();
 	      $m = spip_pg_error($q);
@@ -997,7 +1063,7 @@ function spip_pg_showbase($match, $serveur='',$requeter=true)
 	$connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0];
 	$link = $connexion['link'];
 	  
-	return pg_query($link, "SELECT tablename FROM pg_tables WHERE tablename ILIKE '$match'");
+	return spip_pg_query_simple($link, "SELECT tablename FROM pg_tables WHERE tablename ILIKE '$match'");
 }
 
 // http://doc.spip.org/@spip_pg_showtable
@@ -1006,7 +1072,7 @@ function spip_pg_showtable($nom_table, $serveur='',$requeter=true)
 	$connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0];
 	$link = $connexion['link'];
 
-	$res = pg_query($link, "SELECT column_name, column_default, data_type FROM information_schema.columns WHERE table_name ILIKE " . _q($nom_table));
+	$res = spip_pg_query_simple($link, "SELECT column_name, column_default, data_type FROM information_schema.columns WHERE table_name ILIKE " . _q($nom_table));
 	if (!$res) return false;
 	
 	// etrangement, $res peut ne rien contenir, mais arriver ici...
@@ -1016,7 +1082,7 @@ function spip_pg_showtable($nom_table, $serveur='',$requeter=true)
 		$fields[$field[0]] = $field[2] . (!$field[1] ? '' : (" DEFAULT " . $field[1]));
 	}
 
-	$res = pg_query($link, "SELECT indexdef FROM pg_indexes WHERE tablename ILIKE " . _q($nom_table));
+	$res = spip_pg_query_simple($link, "SELECT indexdef FROM pg_indexes WHERE tablename ILIKE " . _q($nom_table));
 	$keys = array();
 	while($index = pg_fetch_array($res, NULL, PGSQL_NUM)) {
 		if (preg_match('/CREATE\s+(UNIQUE\s+)?INDEX\s([^\s]+).*\((.*)\)$/', $index[0],$r)) {
diff --git a/ecrire/req/sqlite_generique.php b/ecrire/req/sqlite_generique.php
index e78d59859c2147dd9acfa649ca6d5d0760b04fb9..9ac8024cc81c913d7d9da887a46810a2d97b808a 100644
--- a/ecrire/req/sqlite_generique.php
+++ b/ecrire/req/sqlite_generique.php
@@ -1500,7 +1500,7 @@ function _sqlite_ajouter_champs_timestamp($table, $couples, $desc='', $serveur='
 		$tables[$table] = array();
 
 		foreach ($desc['field'] as $k=>$v){
-			if (strpos('timestamp', strtolower(ltrim($v)))===0)
+			if (strpos(strtolower(ltrim($v)), 'timestamp')===0)
 			$tables[$table][] = $k;
 		}
 	}