/usr/bin/wicked-convert-to-utf8 is in php-horde-wicked 2.0.4-2ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | #!/usr/bin/php
<?php
/**
* This script converts the data in an SQL backend from any supported charset
* to UTF-8.
*
* Copyright 2008-2015 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Jan Schneider <jan@horde.org>
*/
require_once __DIR__ . '/../lib/Application.php';
Horde_Registry::appInit('wicked', array('cli' => true));
// Create driver instance.
if ($conf['storage']['driver'] != 'sql') {
exit("You must have an SQL backend configured.\n");
}
$db = $injector->getInstance('Wicked_Factory_Driver')->getDb($injector);
// Get current charset.
$charset = $cli->prompt('Please specify the current charset of the data',
null, 'ISO-8859-1');
// Read existing attachments.
echo 'Converting attachments';
$rows = $db->selectAll(
'SELECT page_id, attachment_name, change_log FROM '
. $conf['storage']['params']['attachmenttable']);
$updateSql =
'UPDATE ' . $conf['storage']['params']['attachmenttable']
. ' SET attachment_name = ?, change_log = ?'
. ' WHERE page_id = ? AND attachment_name = ?';
foreach ($rows as $row) {
$values = Horde_String::convertCharset(
array($row['attachment_name'], $row['change_log']),
$charset, 'UTF-8');
$values[] = $row['page_id'];
$values[] = $row['attachment_name'];
$db->update($updateSql, $values);
echo '.';
}
$rows = $db->selectAll(
'SELECT page_id, attachment_name, change_log FROM '
. $conf['storage']['params']['attachmenthistorytable']);
$updateSql =
'UPDATE ' . $conf['storage']['params']['attachmenthistorytable']
. ' SET attachment_name = ?, change_log = ?'
. ' WHERE page_id = ? AND attachment_name = ?';
foreach ($rows as $row) {
$values = Horde_String::convertCharset(
array($row['attachment_name'], $row['change_log']),
$charset, 'UTF-8');
$values[] = $row['page_id'];
$values[] = $row['attachment_name'];
$db->update($updateSql, $values);
echo '.';
}
$cli->writeln($cli->green('Done'));
// Read existing history.
$rows = $db->selectAll(
'SELECT page_id, page_version, page_name, page_text, change_log FROM '
. $conf['storage']['params']['historytable']);
$updateSql =
'UPDATE ' . $conf['storage']['params']['historytable']
. ' SET page_name = ?, page_text = ?, change_log = ?'
. ' WHERE page_id = ? AND page_version = ?';
echo 'Converting history';
foreach ($rows as $row) {
$values = Horde_String::convertCharset(
array($row['page_name'], $row['page_text'], $row['change_log']),
$charset, 'UTF-8');
$values[] = $row['page_id'];
$values[] = $row['page_version'];
$db->update($updateSql, $values);
}
$cli->writeln($cli->green('Done'));
// Read existing pages.
$rows = $db->selectAll(
'SELECT page_id, page_name, page_text, change_log FROM '
. $conf['storage']['params']['table']);
$updateSql =
'UPDATE ' . $conf['storage']['params']['table']
. ' SET page_name = ?, page_text = ?, change_log = ?'
. ' WHERE page_id = ?';
echo 'Converting pages';
foreach ($rows as $row) {
$values = Horde_String::convertCharset(
array($row['page_name'], $row['page_text'], $row['change_log']),
$charset, 'UTF-8');
$values[] = $row['page_id'];
$db->update($updateSql, $values);
echo '.';
}
$cli->writeln($cli->green('Done'));
|