From fde1debf6dfc57618b873c043baba25c2c3e4159 Mon Sep 17 00:00:00 2001 From: james Date: Thu, 3 Dec 2009 19:41:25 +0000 Subject: [PATCH] COnversion script to convert all emails to UTF8, but still display properly on the site by back-encoding them to ISO-8859-1 (until such a time that we can switch the entire system to UTF8) --- admin/communication.php | 9 ++++++--- db/db.code.version.txt | 2 +- db/db.update.155.php | 14 ++++++++++++++ db/db.update.155.sql | 7 +++++++ 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 db/db.update.155.php create mode 100644 db/db.update.155.sql diff --git a/admin/communication.php b/admin/communication.php index ad5ffce..400d295 100644 --- a/admin/communication.php +++ b/admin/communication.php @@ -244,6 +244,9 @@ case 'dialog_edit': \n"; + } else { ?> @@ -725,12 +728,12 @@ case "email_get_list": echo ""; echo ""; echo "Date:".date("r").""; - echo "Subject:".htmlspecialchars($r->subject).""; + echo "Subject:".htmlspecialchars(iconv("utf-8","ISO-8859-1",$r->subject)).""; if($r->bodyhtml) { - $body=$r->bodyhtml; + $body=iconv("utf-8","ISO-8859-1",$r->bodyhtml); } else - $body=nl2br(htmlspecialchars($r->body)); + $body=nl2br(htmlspecialchars(iconv("utf-8","ISO-8859-1",$r->body))); echo "".$body.""; diff --git a/db/db.code.version.txt b/db/db.code.version.txt index a2ecc45..bb79365 100644 --- a/db/db.code.version.txt +++ b/db/db.code.version.txt @@ -1 +1 @@ -154 +155 diff --git a/db/db.update.155.php b/db/db.update.155.php new file mode 100644 index 0000000..51a3a05 --- /dev/null +++ b/db/db.update.155.php @@ -0,0 +1,14 @@ +body))."' , + bodyhtml='".mysql_real_escape_string(iconv("ISO-8859-1","UTF-8",$r->bodyhtml))."' , + subject='".mysql_real_escape_string(iconv("ISO-8859-1","UTF-8",$r->subject))."' + WHERE id='$r->id'"); + } +} + +?> diff --git a/db/db.update.155.sql b/db/db.update.155.sql new file mode 100644 index 0000000..6c8e8ab --- /dev/null +++ b/db/db.update.155.sql @@ -0,0 +1,7 @@ +ALTER TABLE `emails` CHANGE `body` `body` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; +ALTER TABLE `emails` CHANGE `bodyhtml` `bodyhtml` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; +ALTER TABLE `emails` CHANGE `subject` `subject` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; +ALTER TABLE `emailqueue` CHANGE `body` `body` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; +ALTER TABLE `emailqueue` CHANGE `bodyhtml` `bodyhtml` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; +ALTER TABLE `emailqueue` CHANGE `subject` `subject` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; +ALTER TABLE `emailqueue_recipients` CHANGE `replacements` `replacements` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;