805f33cb16cfdc9f900117c80cf2c20460ac0561
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2011 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
13 if (!defined('_ECRIRE_INC_VERSION')) return;
15 // pour le support des vieux dump
16 // pff ou vous l'avez trouve ce dump ?
17 // http://doc.spip.org/@inc_import_0_0_dist
18 function inc_import_0_0_dist($f, $request, $gz='fread') {
21 // detruire les tables a restaurer
22 $init = $request['init'];
23 $tables = $init($request);
27 if (!($type = xml_fetch_tag($f, $b, $gz))) return false;
28 if ($type == '/SPIP') return !($import_ok = true);
29 $is_art = ($type == 'article');
30 $is_mot = ($type == 'mot');
33 if (!($col = xml_fetch_tag($f, $b, $gz))) return false;
34 if ($col == ("/$type")) break;
36 if (!xml_fetch_tag($f, $value, $gz)) return false;
37 if ($is_art AND $col == 'id_auteur') {
40 else if ($is_mot AND $col == 'id_article') {
43 else if ($is_mot AND $col == 'id_breve') {
46 else if ($is_mot AND $col == 'id_forum') {
49 else if ($is_mot AND $col == 'id_rubrique') {
50 $rubriques[] = $value;
52 else if ($is_mot AND $col == 'id_syndic') {
55 else if ($col != 'maj') {
57 $values[] = sql_quote($value);
58 if ($is_art && ($col == 'id_article')) $id_article = $value;
59 if ($is_mot && ($col == 'id_mot')) $id_mot = $value;
63 $table = "spip_$type";
64 if ($type != 'forum' AND $type != 'syndic') $table .= 's';
65 spip_query("REPLACE $table (" . join(",", $cols) . ") VALUES (" . join(",", $values) . ")");
67 if ($is_art && $id_article) {
68 sql_delete("spip_auteurs_articles", "id_article=$id_article");
71 while (list(, $auteur) = each($auteurs)) {
72 sql_insert("spip_auteurs_articles", "(id_auteur, id_article)", "($auteur, $id_article)");
76 if ($is_mot && $id_mot) {
77 sql_delete("spip_mots_articles", "id_mot=$id_mot");
78 sql_delete("spip_mots_breves", "id_mot=$id_mot");
79 sql_delete("spip_mots_forum", "id_mot=$id_mot");
80 sql_delete("spip_mots_rubriques", "id_mot=$id_mot");
81 sql_delete("spip_mots_syndic", "id_mot=$id_mot");
84 while (list(, $article) = each($articles)) {
86 sql_insert("spip_mots_articles", "(id_mot, id_article)", "($id_mot, $article)");
91 while (list(, $breve) = each($breves)) {
93 sql_insert("spip_mots_breves", "(id_mot, id_breve)", "($id_mot, $breve)");
98 while (list(, $forum) = each($forums)) {
100 sql_insert("spip_mots_forum", "(id_mot, id_forum)", "($id_mot, $forum)");
105 while (list(, $rubrique) = each($rubriques)) {
107 sql_insert("spip_mots_rubriques", "(id_mot, id_rubrique)", "($id_mot, $id_rubrique)");
112 while (list(, $syndic) = each($syndics)) {
114 sql_insert("spip_mots_syndic", "(id_mot, id_syndic)", "($id_mot, $syndic)");
119 return $import_ok = " ";