', $p); while (!$q AND substr($buf, $p, 1) != '>') { if ($_feof($f)) return false; $tag .= substr($buf, $p); $buf = $_fread($f, $buf_len); $p = 0; $q = strpos($buf, '>'); } $pos = $q + 1; $tag .= substr($buf, $p, $q - $p); $before = str_replace('&', '&', str_replace('<', '<', $before)); $abs_pos = $_ftell($f) - strlen($buf); return $tag; } function xml_parse_tag($texte) { list($tag, $atts) = split('[[:space:]]+', $texte, 2); $result[0] = $tag; $result[1] = ''; if (!$atts) return $result; while (ereg('^([^[:space:]]+)[[:space:]]*=[[:space:]]*"([^"]*)"([[:space:]]+(.*))?', $atts, $regs)) { $result[1][$regs[1]] = $regs[2]; $atts = $regs[4]; } return $result; } function import_debut($f, $gz=false) { $b = ""; while ($t = xml_fetch_tag($f, $b, $gz)) { $r = xml_parse_tag($t); if ($r[0] == '?xml' AND $r[1]['encoding']) ecrire_meta('charset_restauration', strtolower($r[1]['encoding'])); if ($r[0] == "SPIP") return $r; $b = ""; } return false; } // // $f = handle fichier // $gz = flag utilisation zlib // // importe un objet depuis le fichier, retourne true si ok, false si erreur ou fin de fichier // function import_objet_1_2($f, $gz=false) { global $import_ok, $pos, $abs_pos; static $time_javascript; if (time() - $time_javascript > 3) { // 3 secondes affiche_progression_javascript($abs_pos); $time_javascript = time(); } static $tables; if (!$tables) $tables = array( 'article' => 'spip_articles', 'auteur' => 'spip_auteurs', 'breve' => 'spip_breves', 'document' => 'spip_documents', 'forum' => 'spip_forum', 'groupe_mots' => 'spip_groupes_mots', 'message' => 'spip_messages', 'mot' => 'spip_mots', 'petition' => 'spip_petitions', 'rubrique' => 'spip_rubriques', 'signature' => 'spip_signatures', 'syndic' => 'spip_syndic', 'syndic_article' => 'spip_syndic_articles', 'type_document' => 'spip_types_documents' ); $import_ok = false; $b = ''; // Lire le type d'objet if (!($type = xml_fetch_tag($f, $b, $gz))) return false; if ($type == '/SPIP') return !($import_ok = true); $id = "id_$type"; $id_objet = 0; // Lire les champs de l'objet for (;;) { $b = ''; if (!($col = xml_fetch_tag($f, $b, $gz))) return false; if ($col == '/'.$type) break; $value = ''; if (!xml_fetch_tag($f, $value, $gz)) return false; if (substr($col, 0, 5) == 'lien:') { $type_lien = substr($col, 5); $liens[$type_lien][] = '('.$id_objet.','.$value.')'; } else if ($col != 'maj') { // tentative de restauration d'une base sauvegardee avec le champ 'images' ; d'experience, ca arrive... // mieux vaut accepter que canner silencieusement... if (($type == 'article') && ($col == 'images')) { if ($value) { // ne pas afficher de message si on a un champ suppl mais vide echo "-->
"._T('avis_erreur_sauvegarde', array('type' => $type, 'id_objet' => $id_objet))."\n"._T('avis_colonne_inexistante', array('col' => $col)); if ($col == 'images') echo _T('info_verifier_image'); echo "\n
"._T('avis_erreur_mysql')."\n".spip_sql_error()."\n\n\n