Commit cb6e2329 authored by Kjartan's avatar Kjartan

- Re-wrote user_mail_encode().

parent a33df1de
......@@ -324,33 +324,21 @@ function user_mail($mail, $subject, $message, $header) {
$mail,
user_mail_encode($subject),
str_replace("\r", "", $message),
"MIME-version: 1.0\nContent-type: text/plain; charset=UTF-8; format=flowed\nContent-transfer-encoding: 8BIT\n" . $header
"MIME-Version: 1.0\nContent-type: text/plain; charset=UTF-8; format=flowed\nContent-transfer-encoding: 8Bit\n" . $header
);
}
}
// Original code by <gordon at kanazawa-gu dot ac dot jp>
function user_mail_encode($string) {
// define start delimimter, end delimiter and spacer
$end = "?=";
$start = "=?UTF-8?B?";
$spacer = "{$end}\r\n{$start}";
// determine length of encoded text within
// chunks and ensure length is even
$length = 75 - strlen($start) - strlen($end);
$length = floor($length/2) * 2;
// encode the string and split it into chunks
// with spacers after each chunk
$string = base64_encode($string);
$string = chunk_split($string, $length, $spacer);
// remove trailing spacer and add start and end delimiters
$spacer = preg_quote($spacer);
$string = preg_replace("/{$spacer}$/", "", $string);
return ($start . $string . $end);
function user_mail_encode($string, $charset = "UTF-8") {
/*
** Used to encodes mail headers that contain non US- ASCII
** characters.
** http://www.rfc-editor.org/rfc/rfc2047.txt
*/
$maxlen = 75 - 7 - strlen($charset);
$string = trim(chunk_split(base64_encode($string), $maxlen, "\n"));
$string = trim(preg_replace('/^(.*)$/m', " =?$charset?B?\\1?=", $string));
return $string;
}
function user_deny($type, $mask) {
......
......@@ -324,33 +324,21 @@ function user_mail($mail, $subject, $message, $header) {
$mail,
user_mail_encode($subject),
str_replace("\r", "", $message),
"MIME-version: 1.0\nContent-type: text/plain; charset=UTF-8; format=flowed\nContent-transfer-encoding: 8BIT\n" . $header
"MIME-Version: 1.0\nContent-type: text/plain; charset=UTF-8; format=flowed\nContent-transfer-encoding: 8Bit\n" . $header
);
}
}
// Original code by <gordon at kanazawa-gu dot ac dot jp>
function user_mail_encode($string) {
// define start delimimter, end delimiter and spacer
$end = "?=";
$start = "=?UTF-8?B?";
$spacer = "{$end}\r\n{$start}";
// determine length of encoded text within
// chunks and ensure length is even
$length = 75 - strlen($start) - strlen($end);
$length = floor($length/2) * 2;
// encode the string and split it into chunks
// with spacers after each chunk
$string = base64_encode($string);
$string = chunk_split($string, $length, $spacer);
// remove trailing spacer and add start and end delimiters
$spacer = preg_quote($spacer);
$string = preg_replace("/{$spacer}$/", "", $string);
return ($start . $string . $end);
function user_mail_encode($string, $charset = "UTF-8") {
/*
** Used to encodes mail headers that contain non US- ASCII
** characters.
** http://www.rfc-editor.org/rfc/rfc2047.txt
*/
$maxlen = 75 - 7 - strlen($charset);
$string = trim(chunk_split(base64_encode($string), $maxlen, "\n"));
$string = trim(preg_replace('/^(.*)$/m', " =?$charset?B?\\1?=", $string));
return $string;
}
function user_deny($type, $mask) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment