This commit has been accessed 737 times via Git panel.
commit 222ce1ee50a85ee10c8d9a7f6eeb3c6ee46adc48
tree 867e7e64ad81778efa7d8e577afb74f2da60ea6d
parent 273e04338f5c76bb26d4795bb1293b995075e906
author Engels Antonio <engels@majcms.org> 1358122727 +0800
committer Engels Antonio <engels@majcms.org> 1358122727 +0800
Improve UTF-8 support
diff --git a/inbox.php b/inbox.php
index e263b7b..5e2d87e 100644
--- a/inbox.php
+++ b/inbox.php
@@ -113,20 +113,20 @@ foreach ($mbox_sort as $mbox_num => $mbox_row) {
$size = $val[0]->size;
if ($folder == "Sent") {
- $from = header_mime2text($val[0]->to);
+ $from = imap_utf8($val[0]->to);
}
else {
- $from = header_mime2text($val[0]->from);
+ $from = imap_utf8($val[0]->from);
}
- $from = htmlentities($from,ENT_QUOTES);
+ $from = htmlentities($from,ENT_QUOTES,"UTF-8");
$from = "<b>" . $from;
$from = str_replace(""","",$from);
$from = str_replace(">","",$from);
$from = str_replace(" <","</b><br>",$from);
$from = ereg_replace("\"","",$from);
- $subj = header_mime2text($val[0]->subject);
+ $subj = imap_utf8($val[0]->subject);
if (strlen($subj) > 75) {
$subj = substr($subj,0,74) . "...";
@@ -185,7 +185,7 @@ foreach ($mbox_sort as $mbox_num => $mbox_row) {
$status_img = "mail-replied.png";
}
- $header_fetch = imap_fetchheader($mbox,$mbox_row,FT_UID|FT_PREFETCHTEXT);
+ $header_fetch = imap_utf8(imap_fetchheader($mbox,$mbox_row,FT_UID|FT_PREFETCHTEXT));
$header_raw_lines = explode("\r\n",$header_fetch);
diff --git a/post.php b/post.php
index d2b111b..0f0bd74 100644
--- a/post.php
+++ b/post.php
@@ -9,7 +9,7 @@ if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset
if (isset($_POST['new']) and !empty($_POST['new']) and is_numeric($_POST['new'])) {
$reply_from = "$usr_name <{$_SESSION['logged_uid']}>";
- $reply_from = htmlentities($reply_from,ENT_QUOTES);
+ $reply_from = htmlentities($reply_from,ENT_QUOTES,"UTF-8");
$post_alias_query = mysql_query("select domains.id, aliases.id from aliases, domains where aliases.alias='{$_SESSION['logged_uid']}' and aliases.mode='1' and aliases.domain=domains.id and domains.mode='1' order by aliases.domain, aliases.id");
diff --git a/read.php b/read.php
index cddf4af..87553a9 100644
--- a/read.php
+++ b/read.php
@@ -12,26 +12,26 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$header = imap_rfc822_parse_headers(imap_fetchbody($mbox,$msgno,0,FT_UID));
- $header_subject = header_mime2text($header->subject);
+ $header_subject = imap_utf8($header->subject);
- $header_fromaddress = header_mime2text($header->fromaddress);
- $header_fromaddress = htmlentities($header_fromaddress,ENT_QUOTES);
+ $header_fromaddress = imap_utf8($header->fromaddress);
+ $header_fromaddress = htmlentities($header_fromaddress,ENT_QUOTES,"UTF-8");
- $header_toaddress = header_mime2text($header->toaddress);
- $header_toaddress = htmlentities($header_toaddress,ENT_QUOTES);
+ $header_toaddress = imap_utf8($header->toaddress);
+ $header_toaddress = htmlentities($header_toaddress,ENT_QUOTES,"UTF-8");
- $header_date = header_mime2text($header->date);
+ $header_date = imap_utf8($header->date);
$header_date = preg_replace("/\([^\)]+\)/","",$header_date);
$header_date = trim($header_date);
$header_date_age = time_elapsed_string(strtotime($header_date));
- $header_ccaddress = header_mime2text($header->ccaddress);
- $header_ccaddress = htmlentities($header_ccaddress,ENT_QUOTES);
+ $header_ccaddress = imap_utf8($header->ccaddress);
+ $header_ccaddress = htmlentities($header_ccaddress,ENT_QUOTES,"UTF-8");
- $header_bccaddress = header_mime2text($header->bccaddress);
- $header_bccaddress = htmlentities($header_bccaddress,ENT_QUOTES);
+ $header_bccaddress = imap_utf8($header->bccaddress);
+ $header_bccaddress = htmlentities($header_bccaddress,ENT_QUOTES,"UTF-8");
- $header_fetch = imap_fetchheader($mbox,$msgno,FT_UID|FT_PREFETCHTEXT);
+ $header_fetch = imap_utf8(imap_fetchheader($mbox,$msgno,FT_UID|FT_PREFETCHTEXT));
$header_raw_lines = explode("\r\n",$header_fetch);
@@ -173,7 +173,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<div class=\"spacer\"></div>";
echo "<div id=\"header1\" class=\"hide\">";
- echo nl2br(htmlentities(preg_replace('/^\n+|^[\t\s]*\n+/m','',$header_fetch),ENT_QUOTES));
+ echo nl2br(htmlentities(preg_replace('/^\n+|^[\t\s]*\n+/m','',$header_fetch),ENT_QUOTES,"UTF-8"));
echo "</div>";
echo "<div id=\"header2\" class=\"hide\"></div>";
@@ -565,7 +565,7 @@ if (isset($header_rr) and (strlen($header_rr) > 0)) {
if ((strlen($rcpt_mail) > 0) and ($folder != "Sent") and ($folder != "Trash") and ($folder != "Spam") and ($folder != "Junk") and ($header_ov[0]->answered == "0")) {
- $header_message_id = header_mime2text($header->message_id);
+ $header_message_id = imap_utf8($header->message_id);
echo "<form id=\"receipt\" method=\"post\" action=\"rcpt.php\" target=\"rcpt\" style=\"display: none;\">";
echo "<input type=\"hidden\" name=\"rcpt_mail\" value=\"$rcpt_mail\">";
diff --git a/send.php b/send.php
index cac817e..2ab8324 100644
--- a/send.php
+++ b/send.php
@@ -12,11 +12,11 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$header = imap_rfc822_parse_headers(imap_fetchbody($mbox,$msgno,0,FT_UID));
- $header_subject = $header->subject;
- $header_fromaddress = $header->senderaddress;
- $header_date = $header->date;
- $header_toaddress = $header->toaddress;
- $header_ccaddress = $header->ccaddress;
+ $header_subject = imap_utf8($header->subject);
+ $header_fromaddress = imap_utf8($header->senderaddress);
+ $header_date = imap_utf8($header->date);
+ $header_toaddress = imap_utf8($header->toaddress);
+ $header_ccaddress = imap_utf8($header->ccaddress);
$reply_quote = trim(get_part($mbox, $msgno, "TEXT/PLAIN"));
@@ -35,18 +35,18 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$reply_from = "$usr_name <{$_SESSION['logged_uid']}>";
- $reply_to = $header->reply_toaddress;
+ $reply_to = imap_utf8($header->reply_toaddress);
if ($reply_to != "") {
- $reply_to = $header->reply_toaddress;
+ $reply_to = imap_utf8($header->reply_toaddress);
}
else {
- $reply_to = $header->fromaddress;
+ $reply_to = imap_utf8($header->fromaddress);
}
- if (($_POST['rep'] == 3) and strpos($header->toaddress,",")) {
+ if (($_POST['rep'] == 3) and strpos(imap_utf8($header->toaddress),",")) {
- $reply_to = $reply_to . ", " . $header->toaddress;
+ $reply_to = $reply_to . ", " . imap_utf8($header->toaddress);
}
if (($_POST['rep'] == 2) or ($_POST['rep'] == 4)) {
@@ -54,17 +54,17 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$reply_cc ="";
}
else {
- $reply_cc = $header->ccaddress;
+ $reply_cc = imap_utf8($header->ccaddress);
}
- $reply_subject = $header->subject;
+ $reply_subject = imap_utf8($header->subject);
$reply_subject = str_replace("FWD: ","Fwd: ",$reply_subject);
$reply_subject = str_replace("RE: ","Re: ",$reply_subject);
if (($_POST['rep'] == 2) or ($_POST['rep'] == 4)) {
- $redirect_from = htmlentities($reply_to,ENT_QUOTES);
+ $redirect_from = htmlentities($reply_to,ENT_QUOTES,"UTF-8");
$reply_to = "";
@@ -93,10 +93,10 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
}
}
- $reply_from = htmlentities($reply_from,ENT_QUOTES);
- $reply_to = htmlentities($reply_to,ENT_QUOTES);
- $reply_subject = htmlentities($reply_subject,ENT_QUOTES);
- $reply_cc = htmlentities($reply_cc,ENT_QUOTES);
+ $reply_from = htmlentities($reply_from,ENT_QUOTES,"UTF-8");
+ $reply_to = htmlentities($reply_to,ENT_QUOTES,"UTF-8");
+ $reply_subject = htmlentities($reply_subject,ENT_QUOTES,"UTF-8");
+ $reply_cc = htmlentities($reply_cc,ENT_QUOTES,"UTF-8");
if ($folder == "Sent") {
$header_tos = extract_emails_from($header_fromaddress);
@@ -225,7 +225,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo $reply_quote;
}
else {
- $reply_personal = $header->fromaddress;
+ $reply_personal = imap_utf8($header->fromaddress);
echo "On $header_date, $reply_personal wrote:\r\n";
foreach ($reply_quote_lines as $reply_quote_line) {
tree 867e7e64ad81778efa7d8e577afb74f2da60ea6d
parent 273e04338f5c76bb26d4795bb1293b995075e906
author Engels Antonio <engels@majcms.org> 1358122727 +0800
committer Engels Antonio <engels@majcms.org> 1358122727 +0800
Improve UTF-8 support
diff --git a/inbox.php b/inbox.php
index e263b7b..5e2d87e 100644
--- a/inbox.php
+++ b/inbox.php
@@ -113,20 +113,20 @@ foreach ($mbox_sort as $mbox_num => $mbox_row) {
$size = $val[0]->size;
if ($folder == "Sent") {
- $from = header_mime2text($val[0]->to);
+ $from = imap_utf8($val[0]->to);
}
else {
- $from = header_mime2text($val[0]->from);
+ $from = imap_utf8($val[0]->from);
}
- $from = htmlentities($from,ENT_QUOTES);
+ $from = htmlentities($from,ENT_QUOTES,"UTF-8");
$from = "<b>" . $from;
$from = str_replace(""","",$from);
$from = str_replace(">","",$from);
$from = str_replace(" <","</b><br>",$from);
$from = ereg_replace("\"","",$from);
- $subj = header_mime2text($val[0]->subject);
+ $subj = imap_utf8($val[0]->subject);
if (strlen($subj) > 75) {
$subj = substr($subj,0,74) . "...";
@@ -185,7 +185,7 @@ foreach ($mbox_sort as $mbox_num => $mbox_row) {
$status_img = "mail-replied.png";
}
- $header_fetch = imap_fetchheader($mbox,$mbox_row,FT_UID|FT_PREFETCHTEXT);
+ $header_fetch = imap_utf8(imap_fetchheader($mbox,$mbox_row,FT_UID|FT_PREFETCHTEXT));
$header_raw_lines = explode("\r\n",$header_fetch);
diff --git a/post.php b/post.php
index d2b111b..0f0bd74 100644
--- a/post.php
+++ b/post.php
@@ -9,7 +9,7 @@ if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset
if (isset($_POST['new']) and !empty($_POST['new']) and is_numeric($_POST['new'])) {
$reply_from = "$usr_name <{$_SESSION['logged_uid']}>";
- $reply_from = htmlentities($reply_from,ENT_QUOTES);
+ $reply_from = htmlentities($reply_from,ENT_QUOTES,"UTF-8");
$post_alias_query = mysql_query("select domains.id, aliases.id from aliases, domains where aliases.alias='{$_SESSION['logged_uid']}' and aliases.mode='1' and aliases.domain=domains.id and domains.mode='1' order by aliases.domain, aliases.id");
diff --git a/read.php b/read.php
index cddf4af..87553a9 100644
--- a/read.php
+++ b/read.php
@@ -12,26 +12,26 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$header = imap_rfc822_parse_headers(imap_fetchbody($mbox,$msgno,0,FT_UID));
- $header_subject = header_mime2text($header->subject);
+ $header_subject = imap_utf8($header->subject);
- $header_fromaddress = header_mime2text($header->fromaddress);
- $header_fromaddress = htmlentities($header_fromaddress,ENT_QUOTES);
+ $header_fromaddress = imap_utf8($header->fromaddress);
+ $header_fromaddress = htmlentities($header_fromaddress,ENT_QUOTES,"UTF-8");
- $header_toaddress = header_mime2text($header->toaddress);
- $header_toaddress = htmlentities($header_toaddress,ENT_QUOTES);
+ $header_toaddress = imap_utf8($header->toaddress);
+ $header_toaddress = htmlentities($header_toaddress,ENT_QUOTES,"UTF-8");
- $header_date = header_mime2text($header->date);
+ $header_date = imap_utf8($header->date);
$header_date = preg_replace("/\([^\)]+\)/","",$header_date);
$header_date = trim($header_date);
$header_date_age = time_elapsed_string(strtotime($header_date));
- $header_ccaddress = header_mime2text($header->ccaddress);
- $header_ccaddress = htmlentities($header_ccaddress,ENT_QUOTES);
+ $header_ccaddress = imap_utf8($header->ccaddress);
+ $header_ccaddress = htmlentities($header_ccaddress,ENT_QUOTES,"UTF-8");
- $header_bccaddress = header_mime2text($header->bccaddress);
- $header_bccaddress = htmlentities($header_bccaddress,ENT_QUOTES);
+ $header_bccaddress = imap_utf8($header->bccaddress);
+ $header_bccaddress = htmlentities($header_bccaddress,ENT_QUOTES,"UTF-8");
- $header_fetch = imap_fetchheader($mbox,$msgno,FT_UID|FT_PREFETCHTEXT);
+ $header_fetch = imap_utf8(imap_fetchheader($mbox,$msgno,FT_UID|FT_PREFETCHTEXT));
$header_raw_lines = explode("\r\n",$header_fetch);
@@ -173,7 +173,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<div class=\"spacer\"></div>";
echo "<div id=\"header1\" class=\"hide\">";
- echo nl2br(htmlentities(preg_replace('/^\n+|^[\t\s]*\n+/m','',$header_fetch),ENT_QUOTES));
+ echo nl2br(htmlentities(preg_replace('/^\n+|^[\t\s]*\n+/m','',$header_fetch),ENT_QUOTES,"UTF-8"));
echo "</div>";
echo "<div id=\"header2\" class=\"hide\"></div>";
@@ -565,7 +565,7 @@ if (isset($header_rr) and (strlen($header_rr) > 0)) {
if ((strlen($rcpt_mail) > 0) and ($folder != "Sent") and ($folder != "Trash") and ($folder != "Spam") and ($folder != "Junk") and ($header_ov[0]->answered == "0")) {
- $header_message_id = header_mime2text($header->message_id);
+ $header_message_id = imap_utf8($header->message_id);
echo "<form id=\"receipt\" method=\"post\" action=\"rcpt.php\" target=\"rcpt\" style=\"display: none;\">";
echo "<input type=\"hidden\" name=\"rcpt_mail\" value=\"$rcpt_mail\">";
diff --git a/send.php b/send.php
index cac817e..2ab8324 100644
--- a/send.php
+++ b/send.php
@@ -12,11 +12,11 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$header = imap_rfc822_parse_headers(imap_fetchbody($mbox,$msgno,0,FT_UID));
- $header_subject = $header->subject;
- $header_fromaddress = $header->senderaddress;
- $header_date = $header->date;
- $header_toaddress = $header->toaddress;
- $header_ccaddress = $header->ccaddress;
+ $header_subject = imap_utf8($header->subject);
+ $header_fromaddress = imap_utf8($header->senderaddress);
+ $header_date = imap_utf8($header->date);
+ $header_toaddress = imap_utf8($header->toaddress);
+ $header_ccaddress = imap_utf8($header->ccaddress);
$reply_quote = trim(get_part($mbox, $msgno, "TEXT/PLAIN"));
@@ -35,18 +35,18 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$reply_from = "$usr_name <{$_SESSION['logged_uid']}>";
- $reply_to = $header->reply_toaddress;
+ $reply_to = imap_utf8($header->reply_toaddress);
if ($reply_to != "") {
- $reply_to = $header->reply_toaddress;
+ $reply_to = imap_utf8($header->reply_toaddress);
}
else {
- $reply_to = $header->fromaddress;
+ $reply_to = imap_utf8($header->fromaddress);
}
- if (($_POST['rep'] == 3) and strpos($header->toaddress,",")) {
+ if (($_POST['rep'] == 3) and strpos(imap_utf8($header->toaddress),",")) {
- $reply_to = $reply_to . ", " . $header->toaddress;
+ $reply_to = $reply_to . ", " . imap_utf8($header->toaddress);
}
if (($_POST['rep'] == 2) or ($_POST['rep'] == 4)) {
@@ -54,17 +54,17 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$reply_cc ="";
}
else {
- $reply_cc = $header->ccaddress;
+ $reply_cc = imap_utf8($header->ccaddress);
}
- $reply_subject = $header->subject;
+ $reply_subject = imap_utf8($header->subject);
$reply_subject = str_replace("FWD: ","Fwd: ",$reply_subject);
$reply_subject = str_replace("RE: ","Re: ",$reply_subject);
if (($_POST['rep'] == 2) or ($_POST['rep'] == 4)) {
- $redirect_from = htmlentities($reply_to,ENT_QUOTES);
+ $redirect_from = htmlentities($reply_to,ENT_QUOTES,"UTF-8");
$reply_to = "";
@@ -93,10 +93,10 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
}
}
- $reply_from = htmlentities($reply_from,ENT_QUOTES);
- $reply_to = htmlentities($reply_to,ENT_QUOTES);
- $reply_subject = htmlentities($reply_subject,ENT_QUOTES);
- $reply_cc = htmlentities($reply_cc,ENT_QUOTES);
+ $reply_from = htmlentities($reply_from,ENT_QUOTES,"UTF-8");
+ $reply_to = htmlentities($reply_to,ENT_QUOTES,"UTF-8");
+ $reply_subject = htmlentities($reply_subject,ENT_QUOTES,"UTF-8");
+ $reply_cc = htmlentities($reply_cc,ENT_QUOTES,"UTF-8");
if ($folder == "Sent") {
$header_tos = extract_emails_from($header_fromaddress);
@@ -225,7 +225,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo $reply_quote;
}
else {
- $reply_personal = $header->fromaddress;
+ $reply_personal = imap_utf8($header->fromaddress);
echo "On $header_date, $reply_personal wrote:\r\n";
foreach ($reply_quote_lines as $reply_quote_line) {