44 |
var $newsgroups; // the Newsgroups where the article belongs to |
var $newsgroups; // the Newsgroups where the article belongs to |
45 |
var $followup; |
var $followup; |
46 |
var $date; |
var $date; |
|
var $organization; |
|
47 |
var $references; |
var $references; |
48 |
var $content_transfer_encoding; |
var $content_transfer_encoding; |
49 |
var $mime_version; |
var $mime_version; |
55 |
var $answers; |
var $answers; |
56 |
var $isAnswer; |
var $isAnswer; |
57 |
var $username; |
var $username; |
58 |
var $user_agent; |
var $field; |
59 |
var $isReply; |
var $isReply; |
60 |
} |
} |
61 |
|
|
447 |
$newvalue=headerDecode($newvalue); // maybe there are more encoded |
$newvalue=headerDecode($newvalue); // maybe there are more encoded |
448 |
return(mb_convert_encoding($newvalue, "EUC-JP", "auto")); // parts |
return(mb_convert_encoding($newvalue, "EUC-JP", "auto")); // parts |
449 |
} else { |
} else { |
450 |
if (eregi('".*"',$value)) { // quoted-pair |
return(mb_convert_encoding(decode_structured_body($value), "EUC-JP", "auto")); |
|
$newvalue=ereg_replace('(.*)"(.*)"(.*)',"\\1"."\\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")); |
|
|
} |
|
451 |
} |
} |
452 |
} |
} |
453 |
|
|
|
function decode_quoted_pair($value) { |
|
|
return(ereg_replace('\\\\(.)',"\\1",$value)); |
|
|
} |
|
|
|
|
|
function getTimestamp($value) { |
|
|
$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); |
|
|
$value=str_replace(" "," ",$value); |
|
|
$d=split(" ",$value,5); |
|
|
if (strcmp(substr($d[0],strlen($d[0])-1,1),",") == 0) { |
|
|
$date[0]=$d[1]; // day |
|
|
$date[1]=$d[2]; // month |
|
|
$date[2]=$d[3]; // year |
|
|
$date[3]=$d[4]; // hours:minutes:seconds |
|
|
} else { |
|
|
$date[0]=$d[0]; // day |
|
|
$date[1]=$d[1]; // month |
|
|
$date[2]=$d[2]; // year |
|
|
$date[3]=$d[3]; // hours:minutes:seconds |
|
|
} |
|
|
$time=split(":",$date[3]); |
|
|
$timestamp=mktime($time[0],$time[1],$time[2],$months[$date[1]],$date[0],$date[2]); |
|
|
return $timestamp; |
|
|
} |
|
454 |
|
|
455 |
function parse_header($hdr,$number="") { |
function parse_header($hdr,$number="") { |
456 |
for ($i=count($hdr)-1; $i>0; $i--) |
for ($i=count($hdr)-1; $i>0; $i--) |
459 |
$header = new headerType; |
$header = new headerType; |
460 |
$header->isAnswer=false; |
$header->isAnswer=false; |
461 |
for ($count=0;$count<count($hdr);$count++) { |
for ($count=0;$count<count($hdr);$count++) { |
462 |
$variable=substr($hdr[$count],0,strpos($hdr[$count]," ")); |
$variable=substr($hdr[$count],0,strpos($hdr[$count],":")); |
463 |
$value=trim(substr($hdr[$count],strpos($hdr[$count]," ")+1)); |
$value=trim(substr($hdr[$count],strpos($hdr[$count],":")+1)); |
464 |
|
$header->field[strtolower($variable)][] = $value; |
465 |
switch (strtolower($variable)) { |
switch (strtolower($variable)) { |
466 |
case "from:": |
case "from": |
467 |
$fromline=address_decode(headerDecode($value),"nirgendwo"); |
$fromline=address_decode(headerDecode($value),"nirgendwo"); |
468 |
if (!isset($fromline[0]["host"])) $fromline[0]["host"]=""; |
if (!isset($fromline[0]["host"])) $fromline[0]["host"]=""; |
469 |
$header->from=$fromline[0]["mailbox"]."@".$fromline[0]["host"]; |
$header->from=$fromline[0]["mailbox"]."@".$fromline[0]["host"]; |
474 |
$header->name=$fromline[0]["personal"]; |
$header->name=$fromline[0]["personal"]; |
475 |
} |
} |
476 |
break; |
break; |
477 |
case "message-id:": |
case "message-id": |
478 |
$header->id=$value; |
$header->id=$value; |
479 |
break; |
break; |
480 |
case "subject:": |
case "subject": |
481 |
$header->subject=headerDecode($value); |
$header->subject = decode_unstructured_body($value); |
482 |
break; |
break; |
483 |
case "newsgroups:": |
case "newsgroups": |
484 |
$header->newsgroups=$value; |
$header->newsgroups=$value; |
485 |
break; |
break; |
486 |
case "organization:": |
case "content-transfer-encoding": |
|
$header->organization=$value; |
|
|
break; |
|
|
case "content-transfer-encoding:": |
|
487 |
$header->content_transfer_encoding=trim(strtolower($value)); |
$header->content_transfer_encoding=trim(strtolower($value)); |
488 |
break; |
break; |
489 |
case "content-type:": |
case "content-type": |
490 |
$header->content_type=array(); |
$header->content_type=array(); |
491 |
$subheader=split(";",$value); |
$subheader=split(";",$value); |
492 |
$header->content_type[0]=strtolower(trim($subheader[0])); |
$header->content_type[0]=strtolower(trim($subheader[0])); |
511 |
} |
} |
512 |
} |
} |
513 |
break; |
break; |
514 |
case "references:": |
case "references": |
515 |
$ref=ereg_replace("> *<", "> <", trim($value)); |
$ref=ereg_replace("> *<", "> <", trim($value)); |
516 |
while (strpos($ref,"> <") != false) { |
while (strpos($ref,"> <") != false) { |
517 |
$header->references[]=substr($ref,0,strpos($ref," ")); |
$header->references[]=substr($ref,0,strpos($ref," ")); |
519 |
} |
} |
520 |
$header->references[]=trim($ref); |
$header->references[]=trim($ref); |
521 |
break; |
break; |
522 |
case "date:": |
case "date": |
523 |
$header->date=getTimestamp(trim($value)); |
$header->date = strtotime(trim($value)); |
524 |
break; |
break; |
525 |
case "followup-to:": |
case "followup-to": |
526 |
$header->followup=trim($value); |
$header->followup=trim($value); |
527 |
break; |
break; |
528 |
case "x-newsreader:": |
/* |
529 |
case "x-mailer:": |
case "x-newsreader": |
530 |
case "user-agent:": |
case "x-mailer": |
531 |
$header->user_agent=trim(headerDecode($value)); |
case "user-agent": |
532 |
break; |
$header->user_agent= decode_structured_body($value); |
|
case "x-face:": |
|
|
// echo "<p>-".base64_decode($value)."-</p>"; |
|
533 |
break; |
break; |
534 |
|
*/ |
535 |
} |
} |
536 |
} |
} |
537 |
if (!isset($header->content_type[0])) |
if (!isset($header->content_type[0])) |
542 |
return $header; |
return $header; |
543 |
} |
} |
544 |
|
|
545 |
|
function decode_unstructured_body ($body) { |
546 |
|
$patterns = array ( |
547 |
|
"/(=\\?[^\\x00-\\x20()<>@,;:\\\"\\/\\[\\]?.=\\x7F]+\\?[BQ]\\?[^\\x00-\\x20\\x3F\\x7F]*\\?=)/ei", |
548 |
|
); |
549 |
|
$replace = array ( |
550 |
|
"mb_decode_mimeheader('\\1')", |
551 |
|
); |
552 |
|
return preg_replace ($patterns, $replace, |
553 |
|
mb_convert_encoding(fake_jisx0213($body), "EUC-JP", "auto")); |
554 |
|
} |
555 |
|
|
556 |
|
function decode_structured_body ($body) { |
557 |
|
$patterns = array ( |
558 |
|
"/\"((?:[^\"\\\\]+|\\\\.)*)\"/e", |
559 |
|
"/\(((?:[^()\\\\]+|\\\\.|(?:\((?:[^()\\\\]+|\\\\.|(?:\((?:[^)\\\\]+|\\\\.\ |
560 |
|
)*\)))*\)))*)\)/e", |
561 |
|
); |
562 |
|
$replace = array ( |
563 |
|
"mb_convert_encoding(fake_jisx0213(decode_quoted_pair('\\1')),'EUC-JP','auto')", |
564 |
|
"'('.mb_convert_encoding(fake_jisx0213(decode_quoted_pair('\\1')), |
565 |
|
'EUC-JP','auto').')'", |
566 |
|
); |
567 |
|
return preg_replace ($patterns, $replace, $body); |
568 |
|
} |
569 |
|
|
570 |
|
function decode_quoted_pair($value) { |
571 |
|
$value = ereg_replace('\\\\(\\\\")', "\\1", $value); |
572 |
|
return ereg_replace('\\\\(.)', "\\1", $value); |
573 |
|
} |
574 |
|
|
575 |
|
function fake_jisx0213 ($value) { |
576 |
|
$value = preg_replace ("/\\x1B\\\$\\(O/", "\x1B\\\$B", $value); |
577 |
|
$value = preg_replace ("/\\x1B\\\$\\(P/", "\x1B\\\$(D", $value); |
578 |
|
return $value; |
579 |
|
} |
580 |
|
|
581 |
function decode_body($body,$encoding) { |
function decode_body($body,$encoding) { |
582 |
$bodyzeile=""; |
$bodyzeile=""; |
583 |
switch ($encoding) { |
switch ($encoding) { |
695 |
// if ($body=="") $body=" "; |
// if ($body=="") $body=" "; |
696 |
// } |
// } |
697 |
$body=decode_body($body,$message->header->content_transfer_encoding); |
$body=decode_body($body,$message->header->content_transfer_encoding); |
698 |
$message->body[0]=$body; |
$message->body[0] = mb_convert_encoding($body, "EUC-JP", "auto"); |
699 |
} |
} |
700 |
if (!isset($message->header->content_type_charset)) |
if (!isset($message->header->content_type_charset)) |
701 |
$message->header->content_type_charset=array("ISO-8859-1"); |
$message->header->content_type_charset=array("ISO-8859-1"); |
856 |
return($comment); |
return($comment); |
857 |
} |
} |
858 |
|
|
859 |
|
function uri_to_link($comment, $group = "", $msgidregex = "") { |
860 |
|
global $frame_externallink; |
861 |
|
global $file_article; |
862 |
|
$comment = preg_replace ( |
863 |
|
'"((?:https?|mailto|urn|news|ftp|irc|mid|data|nntp|gother)):((?:[-_.!~*\'()A-Z0-9:;@=+$,%?/]+|&)+)(#(?:[-_.!~*\'()A-Z0-9;/?:@&=+$,%]+|&)+)?"ie', |
864 |
|
'uri_to_link_uri("\1", "\2", "\3")', |
865 |
|
$comment); |
866 |
|
return($comment); |
867 |
|
} |
868 |
|
|
869 |
|
function uri_to_link_uri ($scheme, $body, $fragment) { |
870 |
|
global $file_article; |
871 |
|
switch (strtolower($scheme)) { |
872 |
|
case "urn": |
873 |
|
case "data": |
874 |
|
$uri = '/uri-res/N2L?'.urlencode($scheme.':'.$body); |
875 |
|
break; |
876 |
|
case "news": |
877 |
|
if (!preg_match('"^//"', $body)) { |
878 |
|
$uri = "../../".addslashes($file_article).'/junk/%3C'.$nbody.'%3E'; |
879 |
|
} else { |
880 |
|
$uri = $scheme.':'.$body; |
881 |
|
} |
882 |
|
break; |
883 |
|
case "mid": |
884 |
|
$nbody = preg_replace('"/.*$"', "", $body); |
885 |
|
$uri = "../../".addslashes($file_article).'/junk/%3C'.$nbody.'%3E'; |
886 |
|
break; |
887 |
|
default: |
888 |
|
$uri = $scheme.':'.$body; |
889 |
|
break; |
890 |
|
} |
891 |
|
$uri = $uri . $fragment; |
892 |
|
if (!empty($uri)) { |
893 |
|
$uri = '<a href="'.$uri.'">'.$scheme.':'.$body.$fragment.'</a>'; |
894 |
|
} |
895 |
|
return $uri; |
896 |
|
} |
897 |
|
|
898 |
|
|
899 |
|
|
957 |
$article->subject=$subject; |
$article->subject=$subject; |
958 |
} |
} |
959 |
if ($overviewfmt[$i]=="Date:") { |
if ($overviewfmt[$i]=="Date:") { |
960 |
$article->date=getTimestamp($over[$i+1]); |
$article->date = strtotime($over[$i+1]); |
961 |
} |
} |
962 |
if ($overviewfmt[$i]=="From:") { |
if ($overviewfmt[$i]=="From:") { |
963 |
$fromline=address_decode(headerDecode($over[$i+1]),"nirgendwo"); |
$fromline=address_decode(headerDecode($over[$i+1]),"nirgendwo"); |
1523 |
echo $text_header["newsgroups"].htmlspecialchars(str_replace(',',', ',$head->newsgroups))."<br>\n"; |
echo $text_header["newsgroups"].htmlspecialchars(str_replace(',',', ',$head->newsgroups))."<br>\n"; |
1524 |
if (isset($head->followup) && ($article_show["Followup"]) && ($head->followup != "")) |
if (isset($head->followup) && ($article_show["Followup"]) && ($head->followup != "")) |
1525 |
echo $text_header["followup"].htmlspecialchars($head->followup)."<br>\n"; |
echo $text_header["followup"].htmlspecialchars($head->followup)."<br>\n"; |
|
if ((isset($head->organization)) && ($article_show["Organization"]) && |
|
|
($head->organization != "")) |
|
|
echo $text_header["organization"]. |
|
|
html_parse(htmlspecialchars($head->organization))."<br>\n"; |
|
1526 |
if ($article_show["Date"]) |
if ($article_show["Date"]) |
1527 |
echo $text_header["date"].date($text_header["date_format"],$head->date)."<br>\n"; |
echo $text_header["date"].date($text_header["date_format"],$head->date)."<br>\n"; |
1528 |
if ($article_show["Message-ID"]) |
if ($article_show["Message-ID"]) |
1537 |
} |
} |
1538 |
echo "<br>"; |
echo "<br>"; |
1539 |
} |
} |
1540 |
if (isset($head->user_agent)) { |
$fields = array ("x-moe", "x-brother", "x-syster", "x-wife", |
1541 |
if ((isset($article_show["User-Agent"])) && |
"x-daughter", "x-respect", |
1542 |
($article_show["User-Agent"])) { |
"user-agent", "x-mailer", "x-newsreader", |
1543 |
echo $text_header["user-agent"].htmlspecialchars($head->user_agent)."<br>\n"; |
"list-id", "x-uri", "x-mail-count", "keywords"); |
1544 |
} else { |
for ($i = 0; $i < count($fields); $i++) { |
1545 |
echo "<!-- User-Agent: ".htmlspecialchars($head->user_agent)." -->\n"; |
if (count($head->field[$fields[$i]])) { |
1546 |
|
if ((isset($article_show[$fields[$i]])) && ($article_show[$fields[$i]])) { |
1547 |
|
echo "<div class=\"field ".$fields[$i]."\"><span class=\"name\">" |
1548 |
|
.$text_header[$fields[$i]]."</span> <span class=\"body\">" |
1549 |
|
.uri_to_link(htmlspecialchars(decode_structured_body( |
1550 |
|
join(', ', $head->field[$fields[$i]])))) |
1551 |
|
."</span></div>\n"; |
1552 |
|
} |
1553 |
|
} |
1554 |
|
} |
1555 |
|
$fields = array ("x-weather", "x-copyright", "comments", "organization"); |
1556 |
|
for ($i = 0; $i < count($fields); $i++) { |
1557 |
|
if (count($head->field[$fields[$i]])) { |
1558 |
|
if ((isset($article_show[$fields[$i]])) && ($article_show[$fields[$i]])) { |
1559 |
|
for ($j = 0; $j > count($head->field[$fields[$i]]); $j++) { |
1560 |
|
echo "<div class=\"field ".$fields[$i]."\"><span class=\"name\">" |
1561 |
|
.$text_header[$fields[$i]]."</span> <span class=\"body\">" |
1562 |
|
.uri_to_link(htmlspecialchars(decode_unstructured_body( |
1563 |
|
$head->field[$fields[$i]][$j]))) |
1564 |
|
."</span></div>\n"; |
1565 |
|
} |
1566 |
|
} |
1567 |
} |
} |
1568 |
} |
} |
1569 |
if ((isset($attachment_show)) && ($attachment_show==true) && |
if ((isset($attachment_show)) && ($attachment_show==true) && |
1632 |
// } |
// } |
1633 |
// echo $body[$i]."\n"; |
// echo $body[$i]."\n"; |
1634 |
$b=$body[$i]; |
$b=$body[$i]; |
1635 |
echo html_parse(htmlspecialchars($b)."\n", $group, $msgidregex); |
echo uri_to_link(htmlspecialchars($b)."\n", $group, $msgidregex); |
1636 |
} |
} |
1637 |
echo "\n</pre>\n"; |
echo "\n</pre>\n"; |
1638 |
} else { |
} else { |
1735 |
* $body: The article itself |
* $body: The article itself |
1736 |
*/ |
*/ |
1737 |
function verschicken($subject,$from,$newsgroups,$ref,$body) { |
function verschicken($subject,$from,$newsgroups,$ref,$body) { |
1738 |
global $server,$port,$send_poster_host,$organization,$text_error; |
global $server,$port,$send_poster_host,$organization,$text_error,$text_ua; |
1739 |
global $file_footer; |
global $file_footer; |
1740 |
flush(); |
flush(); |
1741 |
$ns=OpenNNTPconnection($server,$port); |
$ns=OpenNNTPconnection($server,$port); |