From 2d2fd172e1548dd24e1719accd0b856cff6a31a0 Mon Sep 17 00:00:00 2001 From: Falko Timme <ft@falkotimme.com> Date: Fri, 18 Oct 2013 12:20:13 -0400 Subject: [PATCH] - Added funtion to convert currency formatted numbers back to floating numbers. - Improved getSearchSQL() function so that users can use their native date format so search for dates in lists. --- interface/lib/classes/ispcmail.inc.php | 59 ++++++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 46 insertions(+), 13 deletions(-) diff --git a/interface/lib/classes/ispcmail.inc.php b/interface/lib/classes/ispcmail.inc.php index 388a638..d49af96 100644 --- a/interface/lib/classes/ispcmail.inc.php +++ b/interface/lib/classes/ispcmail.inc.php @@ -414,16 +414,22 @@ $this->body = "This is a multi-part message in MIME format.\n\n"; if($text) { - $this->body .= "--{$this->mime_boundary}\n" . + /*$this->body .= "--{$this->mime_boundary}\n" . "Content-Type:text/plain; charset=\"" . strtolower($this->mail_charset) . "\"\n" . - "Content-Transfer-Encoding: 7bit\n\n" . $this->text_part . "\n\n"; - } + "Content-Transfer-Encoding: 7bit\n\n" . $this->text_part . "\n\n";*/ + $this->body .= "--{$this->mime_boundary}\n" . + "Content-Type:text/plain; charset=\"UTF-8\"\n" . + "Content-Transfer-Encoding: 8bit\n\n" . $this->text_part . "\n\n"; + } if($html) { - $this->body .= "--{$this->mime_boundary}\n" . + /*$this->body .= "--{$this->mime_boundary}\n" . "Content-Type:text/html; charset=\"" . strtolower($this->mail_charset) . "\"\n" . - "Content-Transfer-Encoding: 7bit\n\n" . $this->html_part . "\n\n"; - } + "Content-Transfer-Encoding: 7bit\n\n" . $this->html_part . "\n\n";*/ + $this->body .= "--{$this->mime_boundary}\n" . + "Content-Type:text/html; charset=\"UTF-8\"\n" . + "Content-Transfer-Encoding: 8bit\n\n" . $this->html_part . "\n\n"; + } if($attach) { foreach($this->attachments as $att) { @@ -490,17 +496,42 @@ $this->_is_signed = true; } + private function _char_to_hex($matches) { + return '=' . strtoupper(dechex(ord($matches[1]))); + } + /** * Function to encode a header if necessary * according to RFC2047 * @access private */ private function _encodeHeader($input, $charset = 'ISO-8859-1') { - preg_match_all('/(\s?\w*[\x80-\xFF]+\w*\s?)/', $input, $matches); - foreach ($matches[1] as $value) { - $replacement = preg_replace('/([\x20\x80-\xFF])/e', '"=" . strtoupper(dechex(ord("\1")))', $value); - $input = str_replace($value, '=?' . $charset . '?Q?' . $replacement . '?=', $input); - } + preg_match_all('/(\s?\w*[\x80-\xFF]+\w*\s?)/', $input, $matches); + foreach ($matches[1] as $value) { + $replacement = preg_replace_callback('/([\x20\x80-\xFF])/', array($this, '_char_to_hex'), $value); + $input = str_replace($value, '=?' . $charset . '?Q?' . $replacement . '?=', $input); + } + + return $input; + } + + /** + * Function to encode the subject if necessary + * according to RFC2047 + * @access private + */ + private function _encodeSubject($input, $charset = 'ISO-8859-1') { + /* + if($charset == 'UTF-8' && function_exists('imap_8bit')) { + $input = "=?utf-8?Q?" . imap_8bit($input) . "?="; + } else { + preg_match_all('/(\s?\w*[\x80-\xFF]+\w*\s?)/', $input, $matches); + foreach ($matches[1] as $value) { + $replacement = preg_replace('/([\x20\x80-\xFF])/e', '"=" . strtoupper(dechex(ord("\1")))', $value); + $input = str_replace($value, '=?' . $charset . '?Q?' . $replacement . '?=', $input); + } + }*/ + $input='=?UTF-8?B?'.base64_encode($input).'?='; return $input; } @@ -578,7 +609,8 @@ //$subject = $this->_encodeHeader($this->headers['Subject'], $this->mail_charset); $subject = $this->headers['Subject']; - $enc_subject = $this->_encodeHeader($subject, $this->mail_charset); + //$enc_subject = $this->_encodeHeader($subject, $this->mail_charset); + $enc_subject = $this->_encodeSubject($subject, $this->mail_charset); unset($this->headers['Subject']); } @@ -652,7 +684,8 @@ else $rec_string .= $recip; } $to = $this->_encodeHeader($rec_string, $this->mail_charset); - $result = mail($to, $subject, $this->body, implode($this->_crlf, $headers)); + //$result = mail($to, $subject, $this->body, implode($this->_crlf, $headers)); + $result = mail($to, $enc_subject, $this->body, implode($this->_crlf, $headers)); } // Reset the subject in case mail is resent -- Gitblit v1.9.1