NobuNobu
nobun****@users*****
2006年 5月 16日 (火) 22:11:28 JST
Index: xoops2jp/html/language/japanese/xoopsmailerlocal.php diff -u xoops2jp/html/language/japanese/xoopsmailerlocal.php:1.1.8.2 xoops2jp/html/language/japanese/xoopsmailerlocal.php:1.1.8.3 --- xoops2jp/html/language/japanese/xoopsmailerlocal.php:1.1.8.2 Fri Nov 25 22:19:00 2005 +++ xoops2jp/html/language/japanese/xoopsmailerlocal.php Tue May 16 22:11:28 2006 @@ -1,5 +1,5 @@ <?php -// $Id: xoopsmailerlocal.php,v 1.1.8.2 2005/11/25 13:19:00 nobunobu Exp $ +// $Id: xoopsmailerlocal.php,v 1.1.8.3 2006/05/16 13:11:28 nobunobu Exp $ // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // // Copyright (c) 2000 XOOPS.org // @@ -63,7 +63,7 @@ --------------------------------------*/ function STRtoJIS($str, $from_charset){ if (function_exists('mb_convert_encoding')) { //Use mb_string extension if exists. - $str_JIS = mb_convert_encoding($str, "ISO-2022-JP", $from_charset); + $str_JIS = mb_convert_encoding($str, "ISO-2022-JP", $from_charset); } else if ($from_charset=='EUC-JP') { $str_JIS = ''; $mode = 0; @@ -120,53 +120,67 @@ if(empty($addr[1])) { $formatted = $addr[0]; } else { - $formatted = $this->EncodeHeader($addr[1], 'text') . " <" . - $addr[0] . ">"; + $formatted = $this->EncodeHeader($addr[1], 'text') . " <" . + $addr[0] . ">"; } return $formatted; } function EncodeHeader ($str, $position = 'text', $force=false) { - $encode_charset = strtoupper($this->CharSet); - if (function_exists('mb_convert_encoding')) { //Using mb_string extension if exists. - if ($this->needs_encode || $force) { - $str_encoding = mb_detect_encoding($str, 'ASCII,'.$encode_charset ); - if ($str_encoding == 'ASCII') { // Return original if string from only ASCII chars. - return $str; - } else if ($str_encoding != $encode_charset) { // Maybe this case may not occur. - $str = mb_convert_encoding($str, $encode_charset, $str_encoding); + if (!preg_match('/^4\.4\.[01]([^0-9]+|$)/',PHP_VERSION)) { + if (function_exists('mb_convert_encoding')) { //Use mb_string extension if exists. + if ($this->needs_encode || $force) { + $encoded = mb_convert_encoding($str, _CHARSET, mb_detect_encoding($str)); + $encoded = mb_encode_mimeheader($encoded, "ISO-2022-JP", "B", "\n"); + } else { + $encoded = $str; } - //Following Logic are made for recovering PHP4.4.x mb_encode_mimeheader() bug. - //TODO: If mb_encode_mimeheader() bug is fixed. Replace this to simple logic. - $cut_start = 0; - $encoded =''; - $cut_length = floor((76-strlen('Subject: =?'.$encode_charset.'?B?'.'?='))/4)*3; - while($cut_start < strlen($str)) { - $partstr = mb_strcut ( $str, $cut_start, $cut_length, $encode_charset); - $partstr_length = strlen($partstr); - if (!$partstr_length) break; - if ($encode_charset == 'ISO-2022-JP') { - //Should Adjust next cutting place for SO & SI char insertion. - if ((substr($partstr, 0, 3)===chr(27).'$B') - && (substr($str, $cut_start, 3) !== chr(27).'$B')) { - $partstr_length -= 3; - } - if ((substr($partstr,-3)===chr(27).'(B') - && (substr($str, $cut_start+$partstr_length-3, 3) !== chr(27).'(B')) { - $partstr_length -= 3; + } else { + $encoded = parent::EncodeHeader($str, $position); + } + return $encoded; + } else { + //Following Logic are made for recovering PHP4.4.0 and 4.4.1 mb_encode_mimeheader() bug. + //TODO: If mb_encode_mimeheader() bug is fixed. Replace this to simple logic. + $encode_charset = strtoupper($this->CharSet); + if (function_exists('mb_convert_encoding')) { //Using mb_string extension if exists. + if ($this->needs_encode || $force) { + $str_encoding = mb_detect_encoding($str, 'ASCII,'.$encode_charset ); + if ($str_encoding == 'ASCII') { // Return original if string from only ASCII chars. + return $str; + } else if ($str_encoding != $encode_charset) { // Maybe this case may not occur. + $str = mb_convert_encoding($str, $encode_charset, $str_encoding); + } + $cut_start = 0; + $encoded =''; + $cut_length = floor((76-strlen('Subject: =?'.$encode_charset.'?B?'.'?='))/4)*3; + while($cut_start < strlen($str)) { + $partstr = mb_strcut ( $str, $cut_start, $cut_length, $encode_charset); + $partstr_length = strlen($partstr); + if (!$partstr_length) break; + if ($encode_charset == 'ISO-2022-JP') { + //Should Adjust next cutting place for SO & SI char insertion. + if ((substr($partstr, 0, 3)===chr(27).'$B') + && (substr($str, $cut_start, 3) !== chr(27).'$B')) { + $partstr_length -= 3; + } + if ((substr($partstr,-3)===chr(27).'(B') + && (substr($str, $cut_start+$partstr_length-3, 3) !== chr(27).'(B')) { + $partstr_length -= 3; + } } - } - if ($cut_start) $encoded .= "\r\n\t"; - $encoded .= '=?' . $encode_charset . '?B?' . base64_encode($partstr) . '?='; - $cut_start += $partstr_length; + if ($cut_start) $encoded .= "\r\n\t"; + $encoded .= '=?' . $encode_charset . '?B?' . base64_encode($partstr) . '?='; + $cut_start += $partstr_length; + } + } else { + $encoded = $str; } } else { - $encoded = $str; + $encoded = parent::EncodeHeader($str, $position); } - } else { - $encoded = parent::encode_header($str, $position); - } - return $encoded; + return $encoded; + } } } ?>