448 |
$newvalue=headerDecode($newvalue); // maybe there are more encoded |
$newvalue=headerDecode($newvalue); // maybe there are more encoded |
449 |
return(mb_convert_encoding($newvalue, "EUC-JP", "auto")); // parts |
return(mb_convert_encoding($newvalue, "EUC-JP", "auto")); // parts |
450 |
} else { |
} else { |
451 |
if (eregi('".*"',$value)) { // quoted-pair |
return(mb_convert_encoding(decode_structured_body($value), "EUC-JP", "auto")); |
|
ereg('([^"]*)"(([^"]+|\\\\.)*)"(.*)',$value,$vals); |
|
|
$newvalue = $vals[1].decode_quoted_pair($vals[2]).$vals[4]; |
|
|
return(mb_convert_encoding($newvalue, "EUC-JP", "auto")); |
|
|
} else { // there wasn't anything encoded, return the original string |
|
|
return(mb_convert_encoding($value, "EUC-JP", "auto")); |
|
|
} |
|
452 |
} |
} |
453 |
} |
} |
454 |
|
|
|
function decode_quoted_pair($value) { |
|
|
return(ereg_replace('\\\\(.)',"\\1",$value)); |
|
|
} |
|
|
|
|
455 |
function getTimestamp($value) { |
function getTimestamp($value) { |
456 |
$months=array("Jan"=>1,"Feb"=>2,"Mar"=>3,"Apr"=>4,"May"=>5,"Jun"=>6,"Jul"=>7,"Aug"=>8,"Sep"=>9,"Oct"=>10,"Nov"=>11,"Dec"=>12); |
$months=array("Jan"=>1,"Feb"=>2,"Mar"=>3,"Apr"=>4,"May"=>5,"Jun"=>6,"Jul"=>7,"Aug"=>8,"Sep"=>9,"Oct"=>10,"Nov"=>11,"Dec"=>12); |
457 |
$value=str_replace(" "," ",$value); |
$value=str_replace(" "," ",$value); |
566 |
} |
} |
567 |
|
|
568 |
function decode_structured_body ($body) { |
function decode_structured_body ($body) { |
569 |
ereg("(\"([^\"]+|\\\\.)*\"|\\(([^()]+|\\\\.)*\\)|[^\"])+", $body, $element); |
$patterns = array ( |
570 |
return join('-', $element); |
"/\"((?:[^\"\\\\]+|\\\\.)*)\"/e", |
571 |
|
"/\(((?:[^)\\\\]+|\\\\.)*)\)/e", |
572 |
|
); |
573 |
|
$replace = array ( |
574 |
|
"mb_convert_encoding(decode_quoted_pair('\\1'), 'EUC-JP', 'auto')", |
575 |
|
"'('.mb_convert_encoding(decode_quoted_pair('\\1'), 'EUC-JP', 'auto').')'", |
576 |
|
); |
577 |
|
return preg_replace ($patterns, $replace, $body); |
578 |
|
} |
579 |
|
|
580 |
|
function decode_quoted_pair($value) { |
581 |
|
$value = ereg_replace('\\\\(\\\\")', "\\1", $value); |
582 |
|
return ereg_replace('\\\\(.)', "\\1", $value); |
583 |
} |
} |
584 |
|
|
585 |
function decode_body($body,$encoding) { |
function decode_body($body,$encoding) { |
699 |
// if ($body=="") $body=" "; |
// if ($body=="") $body=" "; |
700 |
// } |
// } |
701 |
$body=decode_body($body,$message->header->content_transfer_encoding); |
$body=decode_body($body,$message->header->content_transfer_encoding); |
702 |
$message->body[0]=$body; |
$message->body[0] = mb_convert_encoding($body, "EUC-JP", "auto"); |
703 |
} |
} |
704 |
if (!isset($message->header->content_type_charset)) |
if (!isset($message->header->content_type_charset)) |
705 |
$message->header->content_type_charset=array("ISO-8859-1"); |
$message->header->content_type_charset=array("ISO-8859-1"); |