Changeset 93641 in spip-zone for _core_/plugins/grenier/base/convert_sql_utf8.php
- Timestamp:
- Dec 13, 2015, 2:41:19 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
_core_/plugins/grenier/base/convert_sql_utf8.php
r89285 r93641 15 15 16 16 // http://code.spip.net/@base_convert_sql_utf8_dist 17 function base_convert_sql_utf8_dist($titre ='', $reprise=false)17 function base_convert_sql_utf8_dist($titre = '', $reprise = false) 18 18 { 19 19 if (!$titre) return; // anti-testeur automatique 20 ecrire_meta('convert_sql_utf8', 'oui','non');20 ecrire_meta('convert_sql_utf8', 'oui', 'non'); 21 21 echo install_debut_html($titre); 22 22 … … 36 36 37 37 // http://code.spip.net/@convert_sql_utf8 38 function convert_sql_utf8($titre) {38 function convert_sql_utf8($titre) { 39 39 40 40 define('_DEBUG_CONVERT', false); 41 41 $charset_spip = $GLOBALS['meta']['charset']; 42 42 $charset_supporte = false; 43 $utf8_supporte = false; 43 $utf8_supporte = false; 44 44 // verifier que mysql gere le charset courant pour effectuer les conversions 45 45 if ($c = sql_get_charset($charset_spip)){ … … 51 51 $res = spip_query("SHOW CHARACTER SET"); 52 52 while ($row = sql_fetch($res)){ 53 if ($row['Charset'] =='utf8') $utf8_supporte = true;53 if ($row['Charset'] == 'utf8') $utf8_supporte = true; 54 54 } 55 55 echo install_debut_html($titre); … … 76 76 while (($row = sql_fetch($res)) /*&& ($count<1)*/){ 77 77 $nom = array_shift($row); 78 if (preg_match(',^'.$GLOBALS['table_prefix'].'_(.*)$,', $nom,$regs)){78 if (preg_match(',^'.$GLOBALS['table_prefix'].'_(.*)$,', $nom, $regs)){ 79 79 $count++; 80 80 $nom = $regs[1]; … … 85 85 $collation = $row2['Collation']; 86 86 $champ = $row2['Field']; 87 if ($collation !="NULL"88 && isset($charset2collations[$collation]) 89 && $charset2collations[$collation] =='latin1'){87 if ($collation != "NULL" 88 && isset($charset2collations[$collation]) 89 && $charset2collations[$collation] == 'latin1'){ 90 90 echo "Conversion de '$champ' depuis $collation (".$charset2collations[$collation]."):"; 91 91 // conversion de latin1 vers le charset reel du contenu 92 $type_texte = $row2['Type'];92 $type_texte = $row2['Type']; 93 93 $type_blob = "blob"; 94 if (strpos($type_texte, "text")!==FALSE)95 $type_blob = str_replace("text", "blob",$type_texte);94 if (strpos($type_texte, "text") !== false) 95 $type_blob = str_replace("text", "blob", $type_texte); 96 96 97 97 // sauf si blob expressement demande dans la description ! 98 98 if (( 99 99 $a = $GLOBALS['tables_principales']['spip_'.$nom]['field'][$champ] 100 OR$a = $GLOBALS['tables_auxiliaires']['spip_'.$nom]['field'][$champ]101 ) ANDpreg_match(',blob,i', $a)) {100 or $a = $GLOBALS['tables_auxiliaires']['spip_'.$nom]['field'][$champ] 101 ) and preg_match(',blob,i', $a)) { 102 102 echo "On ignore le champ blob $nom.$champ <hr />\n"; 103 103 } else { 104 104 105 105 $default = $row2['Default']?(" DEFAULT ".sql_quote($row2['Default'])):""; 106 $notnull = ($row2['Null'] =='YES')?"":" NOT NULL";106 $notnull = ($row2['Null'] == 'YES')?"":" NOT NULL"; 107 107 $q = "ALTER TABLE spip_$nom CHANGE $champ $champ $type_blob $default $notnull"; 108 108 if (!_DEBUG_CONVERT) … … 123 123 } 124 124 } 125 ecrire_meta('charset_sql_base', $sql_charset,'non');126 ecrire_meta('charset_sql_connexion', $sql_charset,'non');125 ecrire_meta('charset_sql_base', $sql_charset, 'non'); 126 ecrire_meta('charset_sql_connexion', $sql_charset, 'non'); 127 127 } 128 128 } 129 ?>
Note: See TracChangeset
for help on using the changeset viewer.