- Re-wrote user_mail_encode().
parent
a33df1de5d
commit
cb6e232990
|
@ -324,33 +324,21 @@ function user_mail($mail, $subject, $message, $header) {
|
||||||
$mail,
|
$mail,
|
||||||
user_mail_encode($subject),
|
user_mail_encode($subject),
|
||||||
str_replace("\r", "", $message),
|
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, $charset = "UTF-8") {
|
||||||
function user_mail_encode($string) {
|
/*
|
||||||
|
** Used to encodes mail headers that contain non US- ASCII
|
||||||
// define start delimimter, end delimiter and spacer
|
** characters.
|
||||||
$end = "?=";
|
** http://www.rfc-editor.org/rfc/rfc2047.txt
|
||||||
$start = "=?UTF-8?B?";
|
*/
|
||||||
$spacer = "{$end}\r\n{$start}";
|
$maxlen = 75 - 7 - strlen($charset);
|
||||||
|
$string = trim(chunk_split(base64_encode($string), $maxlen, "\n"));
|
||||||
// determine length of encoded text within
|
$string = trim(preg_replace('/^(.*)$/m', " =?$charset?B?\\1?=", $string));
|
||||||
// chunks and ensure length is even
|
return $string;
|
||||||
$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_deny($type, $mask) {
|
function user_deny($type, $mask) {
|
||||||
|
|
|
@ -324,33 +324,21 @@ function user_mail($mail, $subject, $message, $header) {
|
||||||
$mail,
|
$mail,
|
||||||
user_mail_encode($subject),
|
user_mail_encode($subject),
|
||||||
str_replace("\r", "", $message),
|
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, $charset = "UTF-8") {
|
||||||
function user_mail_encode($string) {
|
/*
|
||||||
|
** Used to encodes mail headers that contain non US- ASCII
|
||||||
// define start delimimter, end delimiter and spacer
|
** characters.
|
||||||
$end = "?=";
|
** http://www.rfc-editor.org/rfc/rfc2047.txt
|
||||||
$start = "=?UTF-8?B?";
|
*/
|
||||||
$spacer = "{$end}\r\n{$start}";
|
$maxlen = 75 - 7 - strlen($charset);
|
||||||
|
$string = trim(chunk_split(base64_encode($string), $maxlen, "\n"));
|
||||||
// determine length of encoded text within
|
$string = trim(preg_replace('/^(.*)$/m', " =?$charset?B?\\1?=", $string));
|
||||||
// chunks and ensure length is even
|
return $string;
|
||||||
$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_deny($type, $mask) {
|
function user_deny($type, $mask) {
|
||||||
|
|
Loading…
Reference in New Issue