Permalink
Browse files

[ja] copy xoopsmailerlocal.php from extra

  • Loading branch information...
nao-pon committed Jun 7, 2014
1 parent ff91380 commit 6124a62474254b53c5eed6da7242f2fbd505cbaf
Showing with 195 additions and 195 deletions.
  1. +1 −1 html/language/ja_utf8/xoopsmailerlocal.php
  2. +194 −194 html/language/japanese/xoopsmailerlocal.php
@@ -137,7 +137,7 @@ function EncodeHeader ($str, $position = 'text', $force=false) {
if ($this->needs_encode || $force) {
$enc = mb_internal_encoding();
mb_internal_encoding('ISO-2022-JP');
$eol = $this->Mailer=='mail'?"\r\n":"\n"; // XXX: this for bugs in PHP mail() subject with linefeed handling
$eol = $this->Mailer=='mail'?(defined('XCUBE_MAILERLOCAL_MAIL_LE')?XCUBE_MAILERLOCAL_MAIL_LE:"\r\n"):"\n"; // XXX: this for bugs in PHP mail() subject with linefeed handling
$encoded = mb_encode_mimeheader($str, 'ISO-2022-JP', 'B', $eol, 9); // offset strlen("Subject: ") as 9
mb_internal_encoding($enc);
} else {
@@ -1,194 +1,194 @@
<?php
// $Id: xoopsmailerlocal.php,v 1.4 2008/07/05 07:45:33 minahito Exp $
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000 XOOPS.org //
// <http://www.xoops.org/> //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
// Author: NobuNobu (Nobuki@Kowa.ORG) //
// URL: http://jp.xoops.org //
// Project: The XOOPS Project //
// ------------------------------------------------------------------------- //
if (!defined('XOOPS_ROOT_PATH')) exit();
class XoopsMailerLocal extends XoopsMailer {
function XoopsMailerLocal(){
$this->multimailer = new XoopsMultiMailerLocal();
$this->reset();
$this->charSet = 'iso-2022-jp';
$this->encoding = '7bit';
$this->multimailer->CharSet = $this->charSet;
$this->multimailer->SetLanguage('ja', XOOPS_ROOT_PATH . '/class/mail/phpmailer/language/');
$this->multimailer->Encoding = '7bit';
}
function encodeFromName($text){
return $this->STRtoJIS($text,_CHARSET);
}
function encodeSubject($text){
if ($this->multimailer->needs_encode) {
return $this->STRtoJIS($text,_CHARSET);
} else {
return $text;
}
}
function encodeBody(&$text){
if ($this->multimailer->needs_encode) {
$text = $this->STRtoJIS($text,_CHARSET);
}
}
/*-------------------------------------
PHP FORM MAIL 1.01 by TOMO
URL : http://www.spencernetwork.org/
E-Mail : groove@spencernetwork.org
--------------------------------------*/
function STRtoJIS($str, $from_charset){
if (function_exists('mb_convert_encoding')) { //Use mb_string extension if exists.
$str_JIS = mb_convert_encoding(mb_convert_kana($str,"KV", $from_charset), "JIS", $from_charset);
} else if ($from_charset=='EUC-JP') {
$str_JIS = '';
$mode = 0;
$b = unpack("C*", $str);
$n = count($b);
for ($i = 1; $i <= $n; $i++) {
if ($b[$i] == 0x8E) {
if ($mode != 2) {
$mode = 2;
$str_JIS .= pack("CCC", 0x1B, 0x28, 0x49);
}
$b[$i+1] -= 0x80;
$str_JIS .= pack("C", $b[$i+1]);
$i++;
} elseif ($b[$i] > 0x8E) {
if ($mode != 1){
$mode = 1;
$str_JIS .= pack("CCC", 0x1B, 0x24, 0x42);
}
$b[$i] -= 0x80; $b[$i+1] -= 0x80;
$str_JIS .= pack("CC", $b[$i], $b[$i+1]);
$i++;
} else {
if ($mode != 0) {
$mode = 0;
$str_JIS .= pack("CCC", 0x1B, 0x28, 0x42);
}
$str_JIS .= pack("C", $b[$i]);
}
}
if ($mode != 0) $str_JIS .= pack("CCC", 0x1B, 0x28, 0x42);
}
return $str_JIS;
}
}
class XoopsMultiMailerLocal extends XoopsMultiMailer {
var $needs_encode;
function XoopsMultiMailerLocal() {
$this->XoopsMultiMailer();
$this->needs_encode = true;
if (function_exists('mb_convert_encoding')) {
$mb_overload = ini_get('mbstring.func_overload');
if (($this->Mailer == 'mail') && (intval($mb_overload) & 1)) { //check if mbstring extension overloads mail()
$this->needs_encode = false;
}
}
}
function AddrFormat($addr) {
if(empty($addr[1])) {
$formatted = $addr[0];
} else {
$formatted = $this->EncodeHeader($addr[1], 'text') . " <" .
$addr[0] . ">";
}
return $formatted;
}
function EncodeHeader ($str, $position = 'text', $force=false) {
if (version_compare(PHP_VERSION, '4.4.1')>0) {
if (function_exists('mb_convert_encoding')) { //Use mb_string extension if exists.
if ($this->needs_encode || $force) {
$enc = mb_internal_encoding();
mb_internal_encoding('ISO-2022-JP');
$eol = $this->Mailer=='mail'?"\r\n":"\n"; // XXX: this for bugs in PHP mail() subject with linefeed handling
$encoded = mb_encode_mimeheader($str, 'ISO-2022-JP', 'B', $eol, 9); // offset strlen("Subject: ") as 9
mb_internal_encoding($enc);
} else {
$encoded = $str;
}
} 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;
}
} else {
$encoded = $str;
}
} else {
$encoded = parent::EncodeHeader($str, $position);
}
return $encoded;
}
}
}
?>
<?php
// $Id: xoopsmailerlocal.php,v 1.4 2008/07/05 07:45:33 minahito Exp $
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000 XOOPS.org //
// <http://www.xoops.org/> //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
// Author: NobuNobu (Nobuki@Kowa.ORG) //
// URL: http://jp.xoops.org //
// Project: The XOOPS Project //
// ------------------------------------------------------------------------- //
if (!defined('XOOPS_ROOT_PATH')) exit();
class XoopsMailerLocal extends XoopsMailer {
function XoopsMailerLocal(){
$this->multimailer = new XoopsMultiMailerLocal();
$this->reset();
$this->charSet = 'iso-2022-jp';
$this->encoding = '7bit';
$this->multimailer->CharSet = $this->charSet;
$this->multimailer->SetLanguage('ja', XOOPS_ROOT_PATH . '/class/mail/phpmailer/language/');
$this->multimailer->Encoding = '7bit';
}
function encodeFromName($text){
return $this->STRtoJIS($text,_CHARSET);
}
function encodeSubject($text){
if ($this->multimailer->needs_encode) {
return $this->STRtoJIS($text,_CHARSET);
} else {
return $text;
}
}
function encodeBody(&$text){
if ($this->multimailer->needs_encode) {
$text = $this->STRtoJIS($text,_CHARSET);
}
}
/*-------------------------------------
PHP FORM MAIL 1.01 by TOMO
URL : http://www.spencernetwork.org/
E-Mail : groove@spencernetwork.org
--------------------------------------*/
function STRtoJIS($str, $from_charset){
if (function_exists('mb_convert_encoding')) { //Use mb_string extension if exists.
$str_JIS = mb_convert_encoding(mb_convert_kana($str,"KV", $from_charset), "JIS", $from_charset);
} else if ($from_charset=='EUC-JP') {
$str_JIS = '';
$mode = 0;
$b = unpack("C*", $str);
$n = count($b);
for ($i = 1; $i <= $n; $i++) {
if ($b[$i] == 0x8E) {
if ($mode != 2) {
$mode = 2;
$str_JIS .= pack("CCC", 0x1B, 0x28, 0x49);
}
$b[$i+1] -= 0x80;
$str_JIS .= pack("C", $b[$i+1]);
$i++;
} elseif ($b[$i] > 0x8E) {
if ($mode != 1){
$mode = 1;
$str_JIS .= pack("CCC", 0x1B, 0x24, 0x42);
}
$b[$i] -= 0x80; $b[$i+1] -= 0x80;
$str_JIS .= pack("CC", $b[$i], $b[$i+1]);
$i++;
} else {
if ($mode != 0) {
$mode = 0;
$str_JIS .= pack("CCC", 0x1B, 0x28, 0x42);
}
$str_JIS .= pack("C", $b[$i]);
}
}
if ($mode != 0) $str_JIS .= pack("CCC", 0x1B, 0x28, 0x42);
}
return $str_JIS;
}
}
class XoopsMultiMailerLocal extends XoopsMultiMailer {
var $needs_encode;
function XoopsMultiMailerLocal() {
$this->XoopsMultiMailer();
$this->needs_encode = true;
if (function_exists('mb_convert_encoding')) {
$mb_overload = ini_get('mbstring.func_overload');
if (($this->Mailer == 'mail') && (intval($mb_overload) & 1)) { //check if mbstring extension overloads mail()
$this->needs_encode = false;
}
}
}
function AddrFormat($addr) {
if(empty($addr[1])) {
$formatted = $addr[0];
} else {
$formatted = $this->EncodeHeader($addr[1], 'text') . " <" .
$addr[0] . ">";
}
return $formatted;
}
function EncodeHeader ($str, $position = 'text', $force=false) {
if (version_compare(PHP_VERSION, '4.4.1')>0) {
if (function_exists('mb_convert_encoding')) { //Use mb_string extension if exists.
if ($this->needs_encode || $force) {
$enc = mb_internal_encoding();
mb_internal_encoding('ISO-2022-JP');
$eol = $this->Mailer=='mail'?(defined('XCUBE_MAILERLOCAL_MAIL_LE')?XCUBE_MAILERLOCAL_MAIL_LE:"\r\n"):"\n"; // XXX: this for bugs in PHP mail() subject with linefeed handling
$encoded = mb_encode_mimeheader($str, 'ISO-2022-JP', 'B', $eol, 9); // offset strlen("Subject: ") as 9
mb_internal_encoding($enc);
} else {
$encoded = $str;
}
} 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;
}
} else {
$encoded = $str;
}
} else {
$encoded = parent::EncodeHeader($str, $position);
}
return $encoded;
}
}
}
?>

0 comments on commit 6124a62

Please sign in to comment.