* $Id: utf_migration.php,v 1.2 2008/01/06 12:30:00 andig2 Exp $ */ chdir('..'); require_once './core/functions.php'; require_once './core/encoding.php'; ?> Migrate database contents to UTF-8 Attention: Be sure to perform a backup before running the encoding migration!

1. Choose source and target encoding

Source encoding:
Target encoding:
Simulate only:
Edit the database settings in ".CONFIG_FILE.".

Alternatively, consider running the installation script.

"); } $res = mysqli_query($db_native, $sql_string); // mysqli_db_query returns either positive result ressource or true/false for an insert/update statement if ($res === false) { // report DB Problem errorpage('Database Problem', mysqli_error($db_native)."\n
\n".$sql_string); } elseif ($res === true) { // on insert, return id of created record $result = mysqli_insert_id($db_native); } else { // return associative result array $result = array(); for ($i=0; $i'latin1', 'iso-8859-7'=>'latin7', 'iso-8859-9'=>'latin9', 'windows-1251'=>'cp1251', 'koi8-r'=>'koi8r', 'utf-8'=>'utf8'); $tables = array(TBL_DATA, TBL_ACTORS); extract($_REQUEST); $db_sourceencoding = $db_encodings[$sourceencoding]; $db_targetencoding = $db_encodings[$targetencoding]; if ($sourceencoding && $targetencoding && ($sourceencoding != $targetencoding)) { # if (!preg_match('/^(\w\d)+$/', $sourceencoding)) die ('Security violation'); # if (!preg_match('/^(\w\d)+$/', $targetencoding)) die ('Security violation'); ?>

2. Validate data correctness and execute

"); $enc = iconv_array($sourceencoding, $targetencoding, $res); for ($i=0; $i$val) { if ($SQL) $SQL .= ', '; $SQL .= $key.'='.db_encode($val); } $SQL = "UPDATE $table SET ".$SQL." WHERE id=".$id; dump($SQL); if (!$simulate) sql_native($SQL); } } } ?>