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")); |
|
$newvalue=ereg_replace('(.*)"(.*)"(.*)',"\\1".decode_quoted_pair("\\2")."\\3",$value); |
|
|
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); |
497 |
$header->id=$value; |
$header->id=$value; |
498 |
break; |
break; |
499 |
case "subject:": |
case "subject:": |
500 |
$header->subject=headerDecode($value); |
$header->subject = decode_unstructured_body($value); |
501 |
break; |
break; |
502 |
case "newsgroups:": |
case "newsgroups:": |
503 |
$header->newsgroups=$value; |
$header->newsgroups=$value; |
504 |
break; |
break; |
505 |
case "organization:": |
case "organization:": |
506 |
$header->organization=$value; |
$header->organization = decode_unstructured_body($value); |
507 |
break; |
break; |
508 |
case "content-transfer-encoding:": |
case "content-transfer-encoding:": |
509 |
$header->content_transfer_encoding=trim(strtolower($value)); |
$header->content_transfer_encoding=trim(strtolower($value)); |
550 |
case "x-newsreader:": |
case "x-newsreader:": |
551 |
case "x-mailer:": |
case "x-mailer:": |
552 |
case "user-agent:": |
case "user-agent:": |
553 |
$header->user_agent=trim(headerDecode($value)); |
$header->user_agent= decode_structured_body($value); |
554 |
|
break; |
555 |
|
case "x-moe:": |
556 |
|
$header->x_moe= decode_structured_body($value); |
557 |
break; |
break; |
558 |
case "x-face:": |
case "x-face:": |
559 |
// echo "<p>-".base64_decode($value)."-</p>"; |
// echo "<p>-".base64_decode($value)."-</p>"; |
568 |
return $header; |
return $header; |
569 |
} |
} |
570 |
|
|
571 |
|
function decode_unstructured_body ($body) { |
572 |
|
$patterns = array ( |
573 |
|
"/(=\\?[^\\x00-\\x20()<>@,;:\\\"\\/\\[\\]?.=\\x7F]+\\?[BQ]\\?[^\\x00-\\x20\\x3F\\x7F]*\\?=)/ei", |
574 |
|
); |
575 |
|
$replace = array ( |
576 |
|
"mb_decode_mimeheader('\\1')", |
577 |
|
); |
578 |
|
return preg_replace ($patterns, $replace, |
579 |
|
mb_convert_encoding(fake_jisx0213($body), "EUC-JP", "auto")); |
580 |
|
} |
581 |
|
|
582 |
|
function decode_structured_body ($body) { |
583 |
|
$patterns = array ( |
584 |
|
"/\"((?:[^\"\\\\]+|\\\\.)*)\"/e", |
585 |
|
"/\(((?:[^()\\\\]+|\\\\.|(?:\((?:[^()\\\\]+|\\\\.|(?:\((?:[^)\\\\]+|\\\\.\ |
586 |
|
)*\)))*\)))*)\)/e", |
587 |
|
); |
588 |
|
$replace = array ( |
589 |
|
"mb_convert_encoding(fake_jisx0213(decode_quoted_pair('\\1')),'EUC-JP','auto')", |
590 |
|
"'('.mb_convert_encoding(fake_jisx0213(decode_quoted_pair('\\1')), |
591 |
|
'EUC-JP','auto').')'", |
592 |
|
); |
593 |
|
return preg_replace ($patterns, $replace, $body); |
594 |
|
} |
595 |
|
|
596 |
|
function decode_quoted_pair($value) { |
597 |
|
$value = ereg_replace('\\\\(\\\\")', "\\1", $value); |
598 |
|
return ereg_replace('\\\\(.)', "\\1", $value); |
599 |
|
} |
600 |
|
|
601 |
|
function fake_jisx0213 ($value) { |
602 |
|
$value = preg_replace ("/\\x1B\\\$\\(O/", "\x1B\\\$B", $value); |
603 |
|
$value = preg_replace ("/\\x1B\\\$\\(P/", "\x1B\\\$(D", $value); |
604 |
|
return $value; |
605 |
|
} |
606 |
|
|
607 |
function decode_body($body,$encoding) { |
function decode_body($body,$encoding) { |
608 |
$bodyzeile=""; |
$bodyzeile=""; |
609 |
switch ($encoding) { |
switch ($encoding) { |
721 |
// if ($body=="") $body=" "; |
// if ($body=="") $body=" "; |
722 |
// } |
// } |
723 |
$body=decode_body($body,$message->header->content_transfer_encoding); |
$body=decode_body($body,$message->header->content_transfer_encoding); |
724 |
$message->body[0]=$body; |
$message->body[0] = mb_convert_encoding($body, "EUC-JP", "auto"); |
725 |
} |
} |
726 |
if (!isset($message->header->content_type_charset)) |
if (!isset($message->header->content_type_charset)) |
727 |
$message->header->content_type_charset=array("ISO-8859-1"); |
$message->header->content_type_charset=array("ISO-8859-1"); |
1537 |
echo "<!-- User-Agent: ".htmlspecialchars($head->user_agent)." -->\n"; |
echo "<!-- User-Agent: ".htmlspecialchars($head->user_agent)." -->\n"; |
1538 |
} |
} |
1539 |
} |
} |
1540 |
|
if (isset($head->x_moe)) { |
1541 |
|
if ((isset($article_show["X-Moe"])) && ($article_show["X-Moe"])) { |
1542 |
|
echo "<span class=\"field x-moe\"><span class=\"name\">".$text_header["X-Moe"] |
1543 |
|
."</span> <span class=\"body\">" |
1544 |
|
.htmlspecialchars($head->x_moe)."</span>\n"; |
1545 |
|
} |
1546 |
|
} |
1547 |
if ((isset($attachment_show)) && ($attachment_show==true) && |
if ((isset($attachment_show)) && ($attachment_show==true) && |
1548 |
(isset($head->content_type[1]))) { |
(isset($head->content_type[1]))) { |
1549 |
echo $text_header["attachments"]; |
echo $text_header["attachments"]; |