'.__('Error(s)').' : '.$err.'
');
}
$dc_ini_file = dirname(__FILE__).'/../../../conf/dotclear.ini';
$err = '';
buffer::str(
''.__('UTF-8 conversion').'
'
);
$step = (!empty($_GET['step'])) ? $_GET['step'] : 1;
if (!is_writable($dc_ini_file))
{
buffer::str(
''.sprintf(__('Config file %s, is not writable.'),'conf/dotclear.ini').'
'
);
}
elseif (dc_encoding == 'UTF-8' && $step != 7)
{
buffer::str(
''.__('Your blog is still in UTF-8.').'
'
);
}
else
{
if ($step == 1)
{
buffer::str(
''.__('Please read carrefully').'
'.
''.__('If you still did the conversion, don\'t do it again.').'
'.
''.__('BACKUP YOUR DATABASE ! That\'s not an advise, that\'s an order ;-)').'
'.
''.__('Next step').'
'
);
}
elseif ($step == 2)
{
buffer::str(
''.__('Converting entries').'
'
);
$strReq = 'SELECT post_id, user_id, post_titre, post_chapo, post_chapo_wiki, '.
'post_content, post_content_wiki, post_notes '.
'FROM '.DB_PREFIX.'post ';
$rs = $con->select($strReq);
while (!$rs->EOF())
{
$updReq = 'UPDATE '.DB_PREFIX.'post SET '.
'user_id = \''.$con->escapeStr(util::latin1utf8($rs->f('user_id'))).'\', '.
'post_titre = \''.$con->escapeStr(util::latin1utf8($rs->f('post_titre'))).'\', '.
'post_chapo = \''.$con->escapeStr(util::latin1utf8($rs->f('post_chapo'))).'\', '.
'post_chapo_wiki = \''.$con->escapeStr(util::latin1utf8($rs->f('post_chapo_wiki'))).'\', '.
'post_content = \''.$con->escapeStr(util::latin1utf8($rs->f('post_content'))).'\', '.
'post_content_wiki = \''.$con->escapeStr(util::latin1utf8($rs->f('post_content_wiki'))).'\', '.
'post_notes = \''.$con->escapeStr(util::latin1utf8($rs->f('post_notes'))).'\' '.
'WHERE post_id = '.$rs->f('post_id').' ';
if ($con->execute($updReq) === false) {
$err = $con->error();
break(1);
}
$rs->moveNext();
}
if ($err != '') {
conversionError($err);
} else {
buffer::str(
''.__('Entries successfully converted.').'
'.
''.__('Next step').'
'
);
}
}
elseif ($step == 3)
{
buffer::str(
''.__('Converting categories').'
'
);
$strReq = 'SELECT cat_id, cat_libelle, cat_desc '.
'FROM '.DB_PREFIX.'categorie ';
$rs = $con->select($strReq);
while (!$rs->EOF())
{
$updReq = 'UPDATE '.DB_PREFIX.'categorie SET '.
'cat_libelle = \''.$con->escapeStr(util::latin1utf8($rs->f('cat_libelle'))).'\', '.
'cat_desc = \''.$con->escapeStr(util::latin1utf8($rs->f('cat_desc'))).'\' '.
'WHERE cat_id = '.$rs->f('cat_id').' ';
if ($con->execute($updReq) === false) {
$err = $con->error();
break(1);
}
$rs->moveNext();
}
if ($err != '') {
conversionError($err);
} else {
buffer::str(
''.__('Categories successfully converted.').'
'.
''.__('Next step').'
'
);
}
}
elseif ($step == 4)
{
buffer::str(
''.__('Converting comments').'
'
);
$strReq = 'SELECT comment_id, comment_auteur, comment_email, comment_site, '.
'comment_content '.
'FROM '.DB_PREFIX.'comment';
$rs = $con->select($strReq);
while (!$rs->EOF())
{
$updReq = 'UPDATE '.DB_PREFIX.'comment SET '.
'comment_auteur = \''.$con->escapeStr(util::latin1utf8($rs->f('comment_auteur'))).'\', '.
'comment_email = \''.$con->escapeStr(util::latin1utf8($rs->f('comment_email'))).'\', '.
'comment_site = \''.$con->escapeStr(util::latin1utf8($rs->f('comment_site'))).'\', '.
'comment_content = \''.$con->escapeStr(util::latin1utf8($rs->f('comment_content'))).'\' '.
'WHERE comment_id = '.$rs->f('comment_id').' ';
if ($con->execute($updReq) === false) {
$err = $con->error();
break(1);
}
$rs->moveNext();
}
if ($err != '') {
conversionError($err);
} else {
buffer::str(
''.__('Comments successfully converted.').'
'.
''.__('Next step').'
'
);
}
}
elseif ($step == 5)
{
buffer::str(
''.__('Converting users').'
'
);
$strReq = 'SELECT user_id, user_nom, user_prenom, user_pseudo, '.
'user_email '.
'FROM '.DB_PREFIX.'user ';
$rs = $con->select($strReq);
while (!$rs->EOF())
{
$updReq = 'UPDATE '.DB_PREFIX.'user SET '.
'user_id = \''.$con->escapeStr(util::latin1utf8($rs->f('user_id'))).'\', '.
'user_nom = \''.$con->escapeStr(util::latin1utf8($rs->f('user_nom'))).'\', '.
'user_prenom = \''.$con->escapeStr(util::latin1utf8($rs->f('user_prenom'))).'\', '.
'user_pseudo = \''.$con->escapeStr(util::latin1utf8($rs->f('user_pseudo'))).'\', '.
'user_email = \''.$con->escapeStr(util::latin1utf8($rs->f('user_email'))).'\' '.
'WHERE user_id = \''.$con->escapeStr($rs->f('user_id')).'\' ';
if ($con->execute($updReq) === false) {
$err = $con->error();
break(1);
}
$rs->moveNext();
}
if ($err != '') {
conversionError($err);
} else {
buffer::str(
''.__('Users successfully converted.').'
'.
''.__('Next step').'
'
);
}
}
elseif ($step == 6)
{
buffer::str(
''.__('Converting links').'
'
);
$strReq = 'SELECT link_id, label, title '.
'FROM '.DB_PREFIX.'link ';
$rs = $con->select($strReq);
while (!$rs->EOF())
{
$updReq = 'UPDATE '.DB_PREFIX.'link SET '.
'label = \''.$con->escapeStr(util::latin1utf8($rs->f('label'))).'\', '.
'title = \''.$con->escapeStr(util::latin1utf8($rs->f('title'))).'\' '.
'WHERE link_id = '.$con->escapeStr($rs->f('link_id')).' ';
if ($con->execute($updReq) === false) {
$err = $con->error();
break(1);
}
$rs->moveNext();
}
if ($err != '') {
conversionError($err);
} else {
buffer::str(
''.__('Links successfully converted.').'
'.
''.__('Next step').'
'
);
}
}
elseif ($step == 7)
{
# Ecriture du dotclear.ini
$objIni = new iniFile($dc_ini_file);
$objIni->editVar('dc_encoding','UTF-8');
$objIni->saveFile();
buffer::str(
''.__('UTF-8 conversion of your blog is finished.').'
'
);
}
}
?>