CVS: spip/ecrire export_all.php3, 1.17, 1.18 import_all.php3, 1.9, 1.10 inc_import.php3, 1.21, 1.22 index.php3, 1.84, 1.85

Update of /home/spip-cvs/spip/ecrire
In directory miel:/tmp/cvs-serv14815/ecrire

Modified Files:
  export_all.php3 import_all.php3 inc_import.php3 index.php3
Log Message:
charset restauration

Index: export_all.php3

RCS file: /home/spip-cvs/spip/ecrire/export_all.php3,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- export_all.php3 15 Mar 2003 22:53:02 -0000 1.17
+++ export_all.php3 26 Oct 2003 21:22:25 -0000 1.18
@@ -33,7 +33,8 @@
}
$_fputs = ($gz) ? gzputs : fputs;

-if ($etape < 2) $_fputs($f, "<"."?xml version=\"1.0\" encoding=\"ISO-8859-1\"?".">\n<SPIP version=\"$spip_version_affichee\" version_base=\"$spip_version\" version_archive=\"$version_archive\">\n\n");
+if ($etape < 2)
+ $_fputs($f, "<"."?xml version=\"1.0\" encoding=\"".lire_meta('charset')."\"?".">\n<SPIP version=\"$spip_version_affichee\" version_base=\"$spip_version\" version_archive=\"$version_archive\">\n\n");

$query = "SELECT * FROM spip_rubriques";
export_objets($query, "rubrique", $f, $gz, $etape, 1, _T('info_sauvegarde_rubriques'));
@@ -62,7 +63,7 @@
//$query = "SELECT * FROM spip_messages";
//export_objets($query, "message", $f, $gz, $etape, 9, _T('info_sauvegarde_messages'));

-$query = "SELECT * FROM spip_forum WHERE statut='publie'".$debug_limit;
+$query = "SELECT * FROM spip_forum".$debug_limit;
export_objets($query, "forum", $f, $gz, $etape, 9, _T('info_sauvegarde_forums'));

$query = "SELECT * FROM spip_petitions";
@@ -86,23 +87,19 @@

if (!$etape OR $etape == 13){
   $_fputs ($f, build_end_tag("SPIP")."\n");
-
-
-
   echo "<p>"._T('info_sauvegarde_reussi_01')."</b><p>"._T('info_sauvegarde_reussi_02', array('archive' => $archive))." <a href='index.php3'>"._T('info_sauvegarde_reussi_03')."</a> "._T('info_sauvegarde_reussi_04')."\n";
}
else {
   $etape_suivante = $etape + 1;
   if ($debut_limit > 1) echo "<p align='right'> <a href='export_all.php3?etape=$etape&debut_limit=$debut_limit&gz=$gz'>>>>> "._T('info_etape_suivante')."</a>";
- else echo "<p align='right'> <a href='export_all.php3?etape=$etape_suivante&gz=$gz'>>>>> "._T('info_etape_suivante')."</a>";
+ else echo "<p align='right'> <a href='export_all.php3?etape=$etape_suivante&gz=$gz'>>>>> "._T('info_etape_suivante')."</a>";
}
install_fin_html();
- if ($gz) gzclose($f);
- else fclose($f);

+if ($gz) gzclose($f);
+else fclose($f);

if (!$etape OR $etape == 14) fin_admin($action);
-

exit;

Index: import_all.php3

RCS file: /home/spip-cvs/spip/ecrire/import_all.php3,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- import_all.php3 10 Jan 2003 21:21:03 -0000 1.9
+++ import_all.php3 26 Oct 2003 21:22:25 -0000 1.10
@@ -24,13 +24,12 @@
     $buf = $_fread($f, $buf_len);

     if (ereg("<SPIP [^>]* version_base=\"([0-9\.]+)\" ", $buf, $regs)
- AND $regs[1] == $spip_version)
+ AND $regs[1] == $spip_version)
       return false; // c'est bon
     else
       return _T('avis_erreur_version_archive', array('archive' => $archive));
- } else
+ } else
     return _T('avis_probleme_archive', array('archive' => $archive));
-
}

if ($archive) {

Index: inc_import.php3

RCS file: /home/spip-cvs/spip/ecrire/inc_import.php3,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- inc_import.php3 4 May 2003 12:16:37 -0000 1.21
+++ inc_import.php3 26 Oct 2003 21:22:25 -0000 1.22
@@ -22,7 +22,7 @@
     if (!$q AND substr($buf, $p, 1) != '<') {
       if ($_feof($f)) return false;
       $before .= substr($buf, $p);
- $abs_pos = $_ftell($f);
+// $abs_pos = $_ftell($f);
       $buf = $_fread($f, $buf_len);
       $q = 0;
       continue;
@@ -30,7 +30,7 @@
     $before .= substr($buf, $p, $q - $p);
     if (++$q >= strlen($buf)) {
       if ($_feof($f)) return false;
- $abs_pos = $_ftell($f);
+// $abs_pos = $_ftell($f);
       $buf = $_fread($f, $buf_len);
       $q = 0;
     }
@@ -44,7 +44,7 @@
     if (!$q AND substr($buf, $p, 1) != '>') {
       if ($_feof($f)) return false;
       $tag .= substr($buf, $p);
- $abs_pos = $_ftell($f);
+// $abs_pos = $_ftell($f);
       $buf = $_fread($f, $buf_len);
       $q = 0;
       continue;
@@ -52,6 +52,7 @@
     $pos = $q + 1;
     $tag .= substr($buf, $p, $q - $p);
     $before = str_replace('&amp;', '&', str_replace('&lt;', '<', $before));
+ $abs_pos = $_ftell($f) - strlen($buf);
     return $tag;
   }
}
@@ -73,6 +74,8 @@
   $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 = "";
   }
@@ -87,7 +90,6 @@
// 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;
@@ -156,7 +158,7 @@

   $table = $tables[$type];
   $query = "REPLACE $table (" . join(',', $cols) . ') VALUES (' . join(',', $values) . ')';
- if (! spip_query($query)) {
+ if (!spip_query($query)) {
     echo "--><br><font color='red'><b>"._T('avis_erreur_mysql')."</b></font>\n<font color='black'><tt>".spip_sql_error()."</tt></font>\n<!--";
     $GLOBALS['erreur_restauration'] = true;
   }
@@ -326,6 +328,9 @@
   $query = "DELETE FROM spip_auteurs WHERE id_auteur=0";
   spip_query($query);

+ if ($charset = lire_meta('charset_restauration'))
+ ecrire_meta('charset', $charset);
+ effacer_meta("charset_restauration");
   effacer_meta("status_restauration");
   effacer_meta("debut_restauration");
   effacer_meta("date_optimisation");
@@ -336,6 +341,7 @@
function import_abandon() {
   // Probleme pour restaurer l'ancien acces admin : il conserve un id_auteur = 0

+ effacer_meta("charset_restauration");
   effacer_meta("status_restauration");
   effacer_meta("debut_restauration");
   effacer_meta("date_optimisation");
@@ -357,6 +363,7 @@

   if (!$my_pos) {
     // Debut de l'importation
+ ecrire_meta('charset_restauration', 'iso-8859-1');
     if (!($r = import_debut($f, $gz))) {
       ecrire_meta("erreur", _T('avis_archive_incorrect'));
       return false;
@@ -434,7 +441,7 @@
   global $affiche_progression_pourcent;
   include_ecrire('inc_charsets.php3');
   flush();
- echo " --><script type='text/javascript'><!--\n";
+ echo " -->\n<script type='text/javascript'><!--\n";

   if ($abs_pos == '100 %') {
     $taille = $abs_pos;
@@ -449,7 +456,7 @@
     $taille = floor(100 * $abs_pos / $affiche_progression_pourcent)." %";

   echo "document.progression.taille.value='$taille';\n";
- echo "//--></script><!--\n";
+ echo "//--></script>\n<!--\n";
   flush();
}

Index: index.php3

RCS file: /home/spip-cvs/spip/ecrire/index.php3,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- index.php3 29 Sep 2003 12:20:03 -0000 1.84
+++ index.php3 26 Oct 2003 21:22:25 -0000 1.85
@@ -18,7 +18,7 @@
     $id_parent=$row['id_parent'];
     $titre=$row['titre'];
     $descriptif=propre($row['descriptif']);
-
+
     $bouton_layer = bouton_block_invisible("enfants$id_rubrique");
     $les_sous_enfants = sous_enfant($id_rubrique);

@@ -231,7 +231,7 @@
   else {
     $texte_boite = _T('info_erreur_restauration');
   }
-
+
   debut_boite_alerte();
   echo "<font FACE='Verdana,Arial,Helvetica,sans-serif' SIZE=4 color='black'><B>$texte_boite</B></font>";
   fin_boite_alerte();