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 |
|
|
200 |
} |
} |
201 |
|
|
202 |
function showPageSelectMenu($article_count,$first) { |
function showPageSelectMenu($article_count,$first) { |
203 |
global $articles_per_page,$file_thread,$file_framethread,$name; |
global $articles_per_page,$name; |
|
/* if (isset($file_framethread)) { |
|
|
$thread=$file_framethread; |
|
|
} else { |
|
|
$thread=$file_thread; |
|
|
} |
|
|
*/ |
|
204 |
$pages=ceil($article_count / $articles_per_page); |
$pages=ceil($article_count / $articles_per_page); |
205 |
if ($article_count > $articles_per_page) |
if ($article_count > $articles_per_page) |
206 |
for ($i = 0; $i < $pages; $i++) { |
for ($i = 0; $i < $pages; $i++) { |
207 |
echo '['; |
echo '['; |
208 |
if ($first != $i*$articles_per_page+1) |
if ($first != $i*$articles_per_page+1) |
209 |
echo '<a href="'.($i*$articles_per_page+1).'_'. |
echo '<a href="'.($i*$articles_per_page+1).'-'. |
210 |
($i+1)*$articles_per_page.'.html">'; |
($i+1)*$articles_per_page.'">'; |
211 |
echo ($i*$articles_per_page+1).'-'; |
echo ($i*$articles_per_page+1).'-'; |
212 |
if ($i == $pages-1) { |
if ($i == $pages-1) { |
213 |
echo $article_count; |
echo $article_count; |
378 |
*/ |
*/ |
379 |
function showgroups($gruppen) { |
function showgroups($gruppen) { |
380 |
if ($gruppen == false) return; |
if ($gruppen == false) return; |
381 |
global $file_thread,$text_groups; |
global $uri_thread,$text_groups; |
382 |
$c = count($gruppen); |
$c = count($gruppen); |
383 |
echo "<table>\n"; |
echo "<table>\n"; |
384 |
echo "<tr><td>#</td><td>".$text_groups["newsgroup"]. |
echo "<tr><td>#</td><td>".$text_groups["newsgroup"]. |
390 |
echo '<a '; |
echo '<a '; |
391 |
if ((isset($frame_threadframeset)) && ($frame_threadframeset != "")) |
if ((isset($frame_threadframeset)) && ($frame_threadframeset != "")) |
392 |
echo 'target="'.$frame_threadframeset.'" '; |
echo 'target="'.$frame_threadframeset.'" '; |
393 |
echo 'href="'.$file_thread.'/'.urlencode($g->name).'/index.html">'.$g->name."</a></td>\n"; |
echo 'href="'.$uri_thread.'/'.encode_newsgroup ($g->name).'/">'.$g->name."</a></td>\n"; |
394 |
echo "<td>$g->description</td></tr>\n"; |
echo "<td>$g->description</td></tr>\n"; |
395 |
flush(); |
flush(); |
396 |
} |
} |
397 |
echo "</table>\n"; |
echo "</table>\n"; |
398 |
} |
} |
399 |
|
|
400 |
|
function encode_newsgroup ($groupname) { |
401 |
|
return urlencode (str_replace ('.', ':', $groupname)); |
402 |
|
} |
403 |
|
|
404 |
/* |
/* |
405 |
* gets a list of aviable articles in the group $groupname |
* gets a list of aviable articles in the group $groupname |
406 |
*/ |
*/ |
445 |
$newvalue=headerDecode($newvalue); // maybe there are more encoded |
$newvalue=headerDecode($newvalue); // maybe there are more encoded |
446 |
return(mb_convert_encoding($newvalue, "EUC-JP", "auto")); // parts |
return(mb_convert_encoding($newvalue, "EUC-JP", "auto")); // parts |
447 |
} else { |
} else { |
448 |
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")); |
|
|
} |
|
449 |
} |
} |
450 |
} |
} |
451 |
|
|
|
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; |
|
|
} |
|
452 |
|
|
453 |
function parse_header($hdr,$number="") { |
function parse_header($hdr,$number="") { |
454 |
for ($i=count($hdr)-1; $i>0; $i--) |
for ($i=count($hdr)-1; $i>0; $i--) |
457 |
$header = new headerType; |
$header = new headerType; |
458 |
$header->isAnswer=false; |
$header->isAnswer=false; |
459 |
for ($count=0;$count<count($hdr);$count++) { |
for ($count=0;$count<count($hdr);$count++) { |
460 |
$variable=substr($hdr[$count],0,strpos($hdr[$count]," ")); |
$variable=substr($hdr[$count],0,strpos($hdr[$count],":")); |
461 |
$value=trim(substr($hdr[$count],strpos($hdr[$count]," ")+1)); |
$value=trim(substr($hdr[$count],strpos($hdr[$count],":")+1)); |
462 |
|
$header->field[strtolower($variable)][] = $value; |
463 |
switch (strtolower($variable)) { |
switch (strtolower($variable)) { |
464 |
case "from:": |
case "from": |
465 |
$fromline=address_decode(headerDecode($value),"nirgendwo"); |
$fromline=address_decode(headerDecode($value),"nirgendwo"); |
466 |
if (!isset($fromline[0]["host"])) $fromline[0]["host"]=""; |
if (!isset($fromline[0]["host"])) $fromline[0]["host"]=""; |
467 |
$header->from=$fromline[0]["mailbox"]."@".$fromline[0]["host"]; |
$header->from=$fromline[0]["mailbox"]."@".$fromline[0]["host"]; |
472 |
$header->name=$fromline[0]["personal"]; |
$header->name=$fromline[0]["personal"]; |
473 |
} |
} |
474 |
break; |
break; |
475 |
case "message-id:": |
case "message-id": |
476 |
$header->id=$value; |
$header->id=$value; |
477 |
break; |
break; |
478 |
case "subject:": |
case "subject": |
479 |
$header->subject=headerDecode($value); |
$header->subject = decode_unstructured_body($value); |
480 |
break; |
break; |
481 |
case "newsgroups:": |
case "newsgroups": |
482 |
$header->newsgroups=$value; |
$header->newsgroups=$value; |
483 |
break; |
break; |
484 |
case "organization:": |
case "content-transfer-encoding": |
|
$header->organization=$value; |
|
|
break; |
|
|
case "content-transfer-encoding:": |
|
485 |
$header->content_transfer_encoding=trim(strtolower($value)); |
$header->content_transfer_encoding=trim(strtolower($value)); |
486 |
break; |
break; |
487 |
case "content-type:": |
case "content-type": |
488 |
$header->content_type=array(); |
$header->content_type=array(); |
489 |
$subheader=split(";",$value); |
$subheader=split(";",$value); |
490 |
$header->content_type[0]=strtolower(trim($subheader[0])); |
$header->content_type[0]=strtolower(trim($subheader[0])); |
509 |
} |
} |
510 |
} |
} |
511 |
break; |
break; |
512 |
case "references:": |
case "references": |
513 |
$ref=ereg_replace("> *<", "> <", trim($value)); |
$ref=ereg_replace("> *<", "> <", trim($value)); |
514 |
while (strpos($ref,"> <") != false) { |
while (strpos($ref,"> <") != false) { |
515 |
$header->references[]=substr($ref,0,strpos($ref," ")); |
$header->references[]=substr($ref,0,strpos($ref," ")); |
517 |
} |
} |
518 |
$header->references[]=trim($ref); |
$header->references[]=trim($ref); |
519 |
break; |
break; |
520 |
case "date:": |
case "date": |
521 |
$header->date=getTimestamp(trim($value)); |
$header->date = strtotime(trim($value)); |
522 |
break; |
break; |
523 |
case "followup-to:": |
case "followup-to": |
524 |
$header->followup=trim($value); |
$header->followup=trim($value); |
525 |
break; |
break; |
526 |
case "x-newsreader:": |
/* |
527 |
case "x-mailer:": |
case "x-newsreader": |
528 |
case "user-agent:": |
case "x-mailer": |
529 |
$header->user_agent=trim(headerDecode($value)); |
case "user-agent": |
530 |
break; |
$header->user_agent= decode_structured_body($value); |
|
case "x-face:": |
|
|
// echo "<p>-".base64_decode($value)."-</p>"; |
|
531 |
break; |
break; |
532 |
|
*/ |
533 |
} |
} |
534 |
} |
} |
535 |
if (!isset($header->content_type[0])) |
if (!isset($header->content_type[0])) |
540 |
return $header; |
return $header; |
541 |
} |
} |
542 |
|
|
543 |
|
function decode_unstructured_body ($body) { |
544 |
|
$patterns = array ( |
545 |
|
"/(=\\?[^\\x00-\\x20()<>@,;:\\\"\\/\\[\\]?.=\\x7F]+\\?[BQ]\\?[^\\x00-\\x20\\x3F\\x7F]*\\?=)/ei", |
546 |
|
); |
547 |
|
$replace = array ( |
548 |
|
"mb_decode_mimeheader('\\1')", |
549 |
|
); |
550 |
|
return preg_replace ($patterns, $replace, |
551 |
|
mb_convert_encoding(fake_jisx0213($body), "EUC-JP", "auto")); |
552 |
|
} |
553 |
|
|
554 |
|
function decode_structured_body ($body) { |
555 |
|
$patterns = array ( |
556 |
|
"/\"((?:[^\"\\\\]+|\\\\.)*)\"/e", |
557 |
|
"/\(((?:[^()\\\\]+|\\\\.|(?:\((?:[^()\\\\]+|\\\\.|(?:\((?:[^)\\\\]+|\\\\.\ |
558 |
|
)*\)))*\)))*)\)/e", |
559 |
|
); |
560 |
|
$replace = array ( |
561 |
|
"mb_convert_encoding(fake_jisx0213(decode_quoted_pair('\\1')),'EUC-JP','auto')", |
562 |
|
"'('.mb_convert_encoding(fake_jisx0213(decode_quoted_pair('\\1')), |
563 |
|
'EUC-JP','auto').')'", |
564 |
|
); |
565 |
|
return preg_replace ($patterns, $replace, $body); |
566 |
|
} |
567 |
|
|
568 |
|
function decode_quoted_pair($value) { |
569 |
|
$value = ereg_replace('\\\\(\\\\")', "\\1", $value); |
570 |
|
return ereg_replace('\\\\(.)', "\\1", $value); |
571 |
|
} |
572 |
|
|
573 |
|
function fake_jisx0213 ($value) { |
574 |
|
$value = preg_replace ("/\\x1B\\\$\\(O/", "\x1B\\\$B", $value); |
575 |
|
$value = preg_replace ("/\\x1B\\\$\\(P/", "\x1B\\\$(D", $value); |
576 |
|
return $value; |
577 |
|
} |
578 |
|
|
579 |
function decode_body($body,$encoding) { |
function decode_body($body,$encoding) { |
580 |
$bodyzeile=""; |
$bodyzeile=""; |
581 |
switch ($encoding) { |
switch ($encoding) { |
693 |
// if ($body=="") $body=" "; |
// if ($body=="") $body=" "; |
694 |
// } |
// } |
695 |
$body=decode_body($body,$message->header->content_transfer_encoding); |
$body=decode_body($body,$message->header->content_transfer_encoding); |
696 |
$message->body[0]=$body; |
$message->body[0] = mb_convert_encoding($body, "EUC-JP", "auto"); |
697 |
} |
} |
698 |
if (!isset($message->header->content_type_charset)) |
if (!isset($message->header->content_type_charset)) |
699 |
$message->header->content_type_charset=array("ISO-8859-1"); |
$message->header->content_type_charset=array("ISO-8859-1"); |
854 |
return($comment); |
return($comment); |
855 |
} |
} |
856 |
|
|
857 |
|
function uri_to_link($comment, $group = "", $msgidregex = "") { |
858 |
|
global $frame_externallink; |
859 |
|
global $file_article; |
860 |
|
$comment = preg_replace ( |
861 |
|
'"((?:https?|mailto|urn|news|ftp|irc|mid|data|nntp|gother)):((?:[-_.!~*\'()A-Z0-9:;@=+$,%?/]+|&)+)(#(?:[-_.!~*\'()A-Z0-9;/?:@&=+$,%]+|&)+)?"ie', |
862 |
|
'uri_to_link_uri("\1", "\2", "\3")', |
863 |
|
$comment); |
864 |
|
return($comment); |
865 |
|
} |
866 |
|
|
867 |
|
function uri_to_link_uri ($scheme, $body, $fragment) { |
868 |
|
global $file_article; |
869 |
|
switch (strtolower($scheme)) { |
870 |
|
case "urn": |
871 |
|
case "data": |
872 |
|
$uri = '/uri-res/N2L?'.urlencode($scheme.':'.$body); |
873 |
|
break; |
874 |
|
case "news": |
875 |
|
if (!preg_match('"^//"', $body)) { |
876 |
|
$uri = "../../".addslashes($file_article).'/junk/%3C'.$nbody.'%3E'; |
877 |
|
} else { |
878 |
|
$uri = $scheme.':'.$body; |
879 |
|
} |
880 |
|
break; |
881 |
|
case "mid": |
882 |
|
$nbody = preg_replace('"/.*$"', "", $body); |
883 |
|
$uri = "../../".addslashes($file_article).'/junk/%3C'.$nbody.'%3E'; |
884 |
|
break; |
885 |
|
default: |
886 |
|
$uri = $scheme.':'.$body; |
887 |
|
break; |
888 |
|
} |
889 |
|
$uri = $uri . $fragment; |
890 |
|
if (!empty($uri)) { |
891 |
|
$uri = '<a href="'.$uri.'">'.$scheme.':'.$body.$fragment.'</a>'; |
892 |
|
} |
893 |
|
return $uri; |
894 |
|
} |
895 |
|
|
896 |
|
|
897 |
|
|
955 |
$article->subject=$subject; |
$article->subject=$subject; |
956 |
} |
} |
957 |
if ($overviewfmt[$i]=="Date:") { |
if ($overviewfmt[$i]=="Date:") { |
958 |
$article->date=getTimestamp($over[$i+1]); |
$article->date = strtotime($over[$i+1]); |
959 |
} |
} |
960 |
if ($overviewfmt[$i]=="From:") { |
if ($overviewfmt[$i]=="From:") { |
961 |
$fromline=address_decode(headerDecode($over[$i+1]),"nirgendwo"); |
$fromline=address_decode(headerDecode($over[$i+1]),"nirgendwo"); |
1521 |
echo $text_header["newsgroups"].htmlspecialchars(str_replace(',',', ',$head->newsgroups))."<br>\n"; |
echo $text_header["newsgroups"].htmlspecialchars(str_replace(',',', ',$head->newsgroups))."<br>\n"; |
1522 |
if (isset($head->followup) && ($article_show["Followup"]) && ($head->followup != "")) |
if (isset($head->followup) && ($article_show["Followup"]) && ($head->followup != "")) |
1523 |
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"; |
|
1524 |
if ($article_show["Date"]) |
if ($article_show["Date"]) |
1525 |
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"; |
1526 |
if ($article_show["Message-ID"]) |
if ($article_show["Message-ID"]) |
1535 |
} |
} |
1536 |
echo "<br>"; |
echo "<br>"; |
1537 |
} |
} |
1538 |
if (isset($head->user_agent)) { |
$fields = array ("x-moe", "x-brother", "x-syster", "x-wife", |
1539 |
if ((isset($article_show["User-Agent"])) && |
"x-daughter", "x-respect", |
1540 |
($article_show["User-Agent"])) { |
"user-agent", "x-mailer", "x-newsreader", |
1541 |
echo $text_header["user-agent"].htmlspecialchars($head->user_agent)."<br>\n"; |
"list-id", "x-uri", "x-mail-count", "keywords"); |
1542 |
} else { |
for ($i = 0; $i < count($fields); $i++) { |
1543 |
echo "<!-- User-Agent: ".htmlspecialchars($head->user_agent)." -->\n"; |
if (count($head->field[$fields[$i]])) { |
1544 |
|
if ((isset($article_show[$fields[$i]])) && ($article_show[$fields[$i]])) { |
1545 |
|
echo "<div class=\"field ".$fields[$i]."\"><span class=\"name\">" |
1546 |
|
.$text_header[$fields[$i]]."</span> <span class=\"body\">" |
1547 |
|
.uri_to_link(htmlspecialchars(decode_structured_body( |
1548 |
|
join(', ', $head->field[$fields[$i]])))) |
1549 |
|
."</span></div>\n"; |
1550 |
|
} |
1551 |
|
} |
1552 |
|
} |
1553 |
|
$fields = array ("x-weather", "x-copyright", "comments", "organization"); |
1554 |
|
for ($i = 0; $i < count($fields); $i++) { |
1555 |
|
if (count($head->field[$fields[$i]])) { |
1556 |
|
if ((isset($article_show[$fields[$i]])) && ($article_show[$fields[$i]])) { |
1557 |
|
for ($j = 0; $j > count($head->field[$fields[$i]]); $j++) { |
1558 |
|
echo "<div class=\"field ".$fields[$i]."\"><span class=\"name\">" |
1559 |
|
.$text_header[$fields[$i]]."</span> <span class=\"body\">" |
1560 |
|
.uri_to_link(htmlspecialchars(decode_unstructured_body( |
1561 |
|
$head->field[$fields[$i]][$j]))) |
1562 |
|
."</span></div>\n"; |
1563 |
|
} |
1564 |
|
} |
1565 |
} |
} |
1566 |
} |
} |
1567 |
if ((isset($attachment_show)) && ($attachment_show==true) && |
if ((isset($attachment_show)) && ($attachment_show==true) && |
1630 |
// } |
// } |
1631 |
// echo $body[$i]."\n"; |
// echo $body[$i]."\n"; |
1632 |
$b=$body[$i]; |
$b=$body[$i]; |
1633 |
echo html_parse(htmlspecialchars($b)."\n", $group, $msgidregex); |
echo uri_to_link(htmlspecialchars($b)."\n", $group, $msgidregex); |
1634 |
} |
} |
1635 |
echo "\n</pre>\n"; |
echo "\n</pre>\n"; |
1636 |
} else { |
} else { |
1733 |
* $body: The article itself |
* $body: The article itself |
1734 |
*/ |
*/ |
1735 |
function verschicken($subject,$from,$newsgroups,$ref,$body) { |
function verschicken($subject,$from,$newsgroups,$ref,$body) { |
1736 |
global $server,$port,$send_poster_host,$organization,$text_error; |
global $server,$port,$send_poster_host,$organization,$text_error,$text_ua; |
1737 |
global $file_footer; |
global $file_footer; |
1738 |
flush(); |
flush(); |
1739 |
$ns=OpenNNTPconnection($server,$port); |
$ns=OpenNNTPconnection($server,$port); |