/[suikacvs]/messaging/newsportal/newsportal.php
Suika

Diff of /messaging/newsportal/newsportal.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.1 by wakaba, Sat Dec 1 11:17:31 2001 UTC revision 1.32 by wakaba, Sun Dec 2 02:55:25 2001 UTC
# Line 44  class headerType { Line 44  class headerType {
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;
# Line 56  class headerType { Line 55  class headerType {
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    
# Line 447  function headerDecode($value) { Line 446  function headerDecode($value) {
446      else      else
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 {   // there wasn't anything encoded, return the original string    } else {
450      return(mb_convert_encoding($value, "EUC-JP", "auto"));      return(mb_convert_encoding(decode_structured_body($value), "EUC-JP", "auto"));
451    }    }
452  }  }
453    
# Line 479  function parse_header($hdr,$number="") { Line 478  function parse_header($hdr,$number="") {
478    $header = new headerType;    $header = new headerType;
479    $header->isAnswer=false;    $header->isAnswer=false;
480    for ($count=0;$count<count($hdr);$count++) {    for ($count=0;$count<count($hdr);$count++) {
481      $variable=substr($hdr[$count],0,strpos($hdr[$count]," "));      $variable=substr($hdr[$count],0,strpos($hdr[$count],":"));
482      $value=trim(substr($hdr[$count],strpos($hdr[$count]," ")+1));      $value=trim(substr($hdr[$count],strpos($hdr[$count],":")+1));
483        $header->field[strtolower($variable)][] = $value;
484        switch (strtolower($variable)) {        switch (strtolower($variable)) {
485          case "from:":          case "from":
486            $fromline=address_decode(headerDecode($value),"nirgendwo");            $fromline=address_decode(headerDecode($value),"nirgendwo");
487            if (!isset($fromline[0]["host"])) $fromline[0]["host"]="";            if (!isset($fromline[0]["host"])) $fromline[0]["host"]="";
488            $header->from=$fromline[0]["mailbox"]."@".$fromline[0]["host"];            $header->from=$fromline[0]["mailbox"]."@".$fromline[0]["host"];
# Line 493  function parse_header($hdr,$number="") { Line 493  function parse_header($hdr,$number="") {
493              $header->name=$fromline[0]["personal"];              $header->name=$fromline[0]["personal"];
494            }            }
495            break;            break;
496          case "message-id:":          case "message-id":
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 "content-transfer-encoding":
           $header->organization=$value;  
           break;  
         case "content-transfer-encoding:":  
506            $header->content_transfer_encoding=trim(strtolower($value));            $header->content_transfer_encoding=trim(strtolower($value));
507            break;            break;
508          case "content-type:":          case "content-type":
509            $header->content_type=array();            $header->content_type=array();
510            $subheader=split(";",$value);            $subheader=split(";",$value);
511            $header->content_type[0]=strtolower(trim($subheader[0]));            $header->content_type[0]=strtolower(trim($subheader[0]));
# Line 533  function parse_header($hdr,$number="") { Line 530  function parse_header($hdr,$number="") {
530              }              }
531            }            }
532            break;            break;
533          case "references:":          case "references":
534            $ref=ereg_replace("> *<", "> <", trim($value));            $ref=ereg_replace("> *<", "> <", trim($value));
535            while (strpos($ref,"> <") != false) {            while (strpos($ref,"> <") != false) {
536              $header->references[]=substr($ref,0,strpos($ref," "));              $header->references[]=substr($ref,0,strpos($ref," "));
# Line 541  function parse_header($hdr,$number="") { Line 538  function parse_header($hdr,$number="") {
538            }            }
539            $header->references[]=trim($ref);            $header->references[]=trim($ref);
540            break;            break;
541          case "date:":          case "date":
542            $header->date=getTimestamp(trim($value));            $header->date=getTimestamp(trim($value));
543            break;            break;
544          case "followup-to:":          case "followup-to":
545            $header->followup=trim($value);            $header->followup=trim($value);
546            break;            break;
547          case "x-newsreader:":  /*
548          case "x-mailer:":          case "x-newsreader":
549          case "user-agent:":          case "x-mailer":
550            $header->user_agent=trim($value);          case "user-agent":
551            break;            $header->user_agent= decode_structured_body($value);
         case "x-face:":  
 //          echo "<p>-".base64_decode($value)."-</p>";  
552            break;            break;
553    */
554        }        }
555    }    }
556    if (!isset($header->content_type[0]))    if (!isset($header->content_type[0]))
# Line 565  function parse_header($hdr,$number="") { Line 561  function parse_header($hdr,$number="") {
561    return $header;    return $header;
562  }  }
563    
564    function decode_unstructured_body ($body) {
565      $patterns = array (
566          "/(=\\?[^\\x00-\\x20()<>@,;:\\\"\\/\\[\\]?.=\\x7F]+\\?[BQ]\\?[^\\x00-\\x20\\x3F\\x7F]*\\?=)/ei",
567      );
568      $replace = array (
569          "mb_decode_mimeheader('\\1')",
570      );
571      return preg_replace ($patterns, $replace,
572                           mb_convert_encoding(fake_jisx0213($body), "EUC-JP", "auto"));
573    }
574    
575    function decode_structured_body ($body) {
576      $patterns = array (
577          "/\"((?:[^\"\\\\]+|\\\\.)*)\"/e",
578          "/\(((?:[^()\\\\]+|\\\\.|(?:\((?:[^()\\\\]+|\\\\.|(?:\((?:[^)\\\\]+|\\\\.\
579    )*\)))*\)))*)\)/e",
580      );
581      $replace = array (
582        "mb_convert_encoding(fake_jisx0213(decode_quoted_pair('\\1')),'EUC-JP','auto')",
583        "'('.mb_convert_encoding(fake_jisx0213(decode_quoted_pair('\\1')),
584                                 'EUC-JP','auto').')'",
585      );
586      return preg_replace ($patterns, $replace, $body);
587    }
588    
589    function decode_quoted_pair($value) {
590      $value = ereg_replace('\\\\(\\\\")', "\\1", $value);
591      return ereg_replace('\\\\(.)', "\\1", $value);
592    }
593    
594    function fake_jisx0213 ($value) {
595      $value = preg_replace ("/\\x1B\\\$\\(O/", "\x1B\\\$B", $value);
596      $value = preg_replace ("/\\x1B\\\$\\(P/", "\x1B\\\$(D", $value);
597      return $value;
598    }
599    
600  function decode_body($body,$encoding) {  function decode_body($body,$encoding) {
601    $bodyzeile="";    $bodyzeile="";
602    switch ($encoding) {    switch ($encoding) {
# Line 682  function parse_message($rawmessage) { Line 714  function parse_message($rawmessage) {
714  //      if ($body=="") $body=" ";  //      if ($body=="") $body=" ";
715  //    }  //    }
716      $body=decode_body($body,$message->header->content_transfer_encoding);      $body=decode_body($body,$message->header->content_transfer_encoding);
717      $message->body[0]=$body;      $message->body[0] = mb_convert_encoding($body, "EUC-JP", "auto");
718    }    }
719      if (!isset($message->header->content_type_charset))      if (!isset($message->header->content_type_charset))
720        $message->header->content_type_charset=array("ISO-8859-1");        $message->header->content_type_charset=array("ISO-8859-1");
# Line 754  function read_message($id,$bodynum=0,$gr Line 786  function read_message($id,$bodynum=0,$gr
786        return false;        return false;
787      $rawmessage=array();      $rawmessage=array();
788      $line=lieszeile($ns);      $line=lieszeile($ns);
789   $line=mb_convert_encoding($line, "EUC-JP", "ISO-2022-JP");   #$line=mb_convert_encoding($line, "EUC-JP", "ISO-2022-JP");
790      while(strcmp($line,".") != 0) {      while(strcmp($line,".") != 0) {
791        $rawmessage[]=$line;        $rawmessage[]=$line;
792        $line=lieszeile($ns);        $line=lieszeile($ns);
793   $line=mb_convert_encoding($line, "EUC-JP", "ISO-2022-JP");   #$line=mb_convert_encoding($line, "EUC-JP", "ISO-2022-JP");
794      }      }
795      $message=parse_message($rawmessage);      $message=parse_message($rawmessage);
796      if (ereg('^[0-9]+$',$id)) $message->header->number=$id;      if (ereg('^[0-9]+$',$id)) $message->header->number=$id;
# Line 1177  function formatTreeGraphic($newtree) { Line 1209  function formatTreeGraphic($newtree) {
1209          break;          break;
1210        }        }
1211      $return .= '" alt="'.$alt.'"';      $return .= '" alt="'.$alt.'"';
1212      if (strcmp($k,".") == 0) $return .=(' width="12" height="9"');      if (strcmp($k,".") == 0) $return .=(' style="width: 12px; height: 9px"');
1213      $return .= ' />';      $return .= '>';
1214    }    }
1215    return($return);    return($return);
1216  }  }
# Line 1256  function showThread(&$headers,&$liste,$d Line 1288  function showThread(&$headers,&$liste,$d
1288            echo "<br>\n";            echo "<br>\n";
1289            break;            break;
1290          case 1: // html-auflistung, kein baum          case 1: // html-auflistung, kein baum
1291            echo "<li><nobr>".$thread_fontPre;            echo "<li>".$thread_fontPre;
1292            if ($thread_showDate)            if ($thread_showDate)
1293              echo formatDate($c)." ";              echo formatDate($c)." ";
1294            if ($thread_showSubject)            if ($thread_showSubject)
1295              echo formatSubject($c,$group)." ";              echo formatSubject($c,$group)." ";
1296            if ($thread_showAuthor)            if ($thread_showAuthor)
1297              echo "<i>(".formatAuthor($c).")</i>";              echo "<em>(".formatAuthor($c).")</em>";
1298            echo $thread_fontPost."</nobr></li>";            echo $thread_fontPost."</li>";
1299            break;            break;
1300          case 2:   // table          case 2:   // table
1301            echo "<tr>";            echo "<tr>";
# Line 1275  function showThread(&$headers,&$liste,$d Line 1307  function showThread(&$headers,&$liste,$d
1307            }            }
1308            if ($thread_showAuthor) {            if ($thread_showAuthor) {
1309              echo "<td></td>";              echo "<td></td>";
1310              echo '<td nowrap="nowrap">'.$thread_fontPre.formatAuthor($c);              echo '<td>'.$thread_fontPre.formatAuthor($c);
1311              echo $thread_fontPost."</td>";              echo $thread_fontPost."</td>";
1312            }            }
1313            echo "</tr>\n";            echo "</tr>\n";
1314            break;            break;
1315          case 3: // html-tree          case 3: // html-tree
1316            echo "<li><nobr>".$thread_fontPre;            echo "<li>".$thread_fontPre;
1317            if ($thread_showDate)            if ($thread_showDate)
1318              echo formatDate($c)." ";              echo formatDate($c)." ";
1319            if ($thread_showSubject)            if ($thread_showSubject)
1320              echo formatSubject($c,$group)." ";              echo formatSubject($c,$group)." ";
1321            if ($thread_showAuthor)            if ($thread_showAuthor)
1322              echo "<i>(".formatAuthor($c).")</i>";              echo "<em>(".formatAuthor($c).")</em>";
1323            echo $thread_fontPost."</nobr>\n";            echo $thread_fontPost."\n";
1324            break;            break;
1325          case 4:  // thread          case 4:  // thread
1326            echo "<nobr><tt>".$thread_fontPre;            echo "".$thread_fontPre;
1327            if ($thread_showDate)            if ($thread_showDate)
1328              echo formatDate($c)." ";              echo formatDate($c)." ";
1329            echo formatTreeText($newtree)." ";            echo formatTreeText($newtree)." ";
1330            if ($thread_showSubject)            if ($thread_showSubject)
1331              echo formatSubject($c,$group)." ";              echo formatSubject($c,$group)." ";
1332            if ($thread_showAuthor)            if ($thread_showAuthor)
1333              echo "<i>(".formatAuthor($c).")</i>";              echo "<em>(".formatAuthor($c).")</em>";
1334            echo $thread_fontPost."</tt></nobr><br>";            echo $thread_fontPost."<br>";
1335            break;            break;
1336          case 5:  // thread, graphic          case 5:  // thread, graphic
1337            echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr>\n";            echo "<table><tr>\n";
1338            if ($thread_showDate)            if ($thread_showDate)
1339              echo '<td nowrap="nowrap">'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</td>";              echo '<td>'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</td>";
1340            echo "<td>".$thread_fontPre.formatTreeGraphic($newtree).$thread_fontPost."</td>";            echo "<td>".$thread_fontPre.formatTreeGraphic($newtree).$thread_fontPost."</td>";
1341            if ($thread_showSubject)            if ($thread_showSubject)
1342              echo '<td nowrap="nowrap">'.$thread_fontPre."&nbsp;".formatSubject($c,$group)." ";              echo '<td>'.$thread_fontPre."&nbsp;".formatSubject($c,$group)." ";
1343            if ($thread_showAuthor)            if ($thread_showAuthor)
1344              echo "(".formatAuthor($c).")".$thread_fontPost."</td>";              echo "(".formatAuthor($c).")".$thread_fontPost."</td>";
1345            echo "</tr></table>";            echo "</tr></table>";
# Line 1315  function showThread(&$headers,&$liste,$d Line 1347  function showThread(&$headers,&$liste,$d
1347          case 6:  // thread, table          case 6:  // thread, table
1348            echo "<tr>";            echo "<tr>";
1349            if ($thread_showDate)            if ($thread_showDate)
1350              echo '<td nowrap="nowrap"><tt>'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</tt></td>";              echo '<td>'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</td>";
1351            echo '<td nowrap="nowrap"><tt>'.$thread_fontPre.formatTreeText($newtree)." ";            echo '<td>'.$thread_fontPre.formatTreeText($newtree)." ";
1352            if ($thread_showSubject) {            if ($thread_showSubject) {
1353              echo formatSubject($c,$group).$thread_fontPost."</tt></td>";              echo formatSubject($c,$group).$thread_fontPost."</td>";
1354              echo "<td></td>";              echo "<td></td>";
1355            }            }
1356            if ($thread_showAuthor)            if ($thread_showAuthor)
1357              echo '<td nowrap="nowrap"><tt>'.$thread_fontPre.formatAuthor($c).$thread_fontPost."</tt></td>";              echo '<td>'.$thread_fontPre.formatAuthor($c).$thread_fontPost."</td>";
1358            echo "</tr>";            echo "</tr>";
1359            break;            break;
1360          case 7:  // thread, table, graphic          case 7:  // thread, table, graphic
1361            echo "<tr>";            echo "<tr>";
1362            if ($thread_showDate)            if ($thread_showDate)
1363              echo '<td nowrap="nowrap">'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</td>";              echo '<td>'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</td>";
1364            echo "<td><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";            echo "<td><table>\n";
1365            echo "<td>".formatTreeGraphic($newtree)."</td>";            echo "<td>".formatTreeGraphic($newtree)."</td>";
1366            if ($thread_showSubject)            if ($thread_showSubject)
1367              echo '<td nowrap="nowrap">'.$thread_fontPre."&nbsp;".formatSubject($c,$group).$thread_fontPost."</td>";              echo '<td>'.$thread_fontPre."&nbsp;".formatSubject($c,$group).$thread_fontPost."</td>";
1368            echo "</table></td>";            echo "</table></td>";
1369            if ($thread_showSubject) echo "<td></td>";            if ($thread_showSubject) echo "<td></td>";
1370            if ($thread_showAuthor)            if ($thread_showAuthor)
1371              echo '<td nowrap="nowrap">'.$thread_fontPre.formatAuthor($c).$thread_fontPost."</td>";              echo '<td>'.$thread_fontPre.formatAuthor($c).$thread_fontPost."</td>";
1372            echo "</tr>";            echo "</tr>";
1373            break;            break;
1374        }        }
# Line 1472  function show_header($head,$group) { Line 1504  function show_header($head,$group) {
1504      echo $text_header["newsgroups"].htmlspecialchars(str_replace(',',', ',$head->newsgroups))."<br>\n";      echo $text_header["newsgroups"].htmlspecialchars(str_replace(',',', ',$head->newsgroups))."<br>\n";
1505    if (isset($head->followup) && ($article_show["Followup"]) && ($head->followup != ""))    if (isset($head->followup) && ($article_show["Followup"]) && ($head->followup != ""))
1506      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";  
1507    if ($article_show["Date"])    if ($article_show["Date"])
1508      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";
1509    if ($article_show["Message-ID"])    if ($article_show["Message-ID"])
# Line 1490  function show_header($head,$group) { Line 1518  function show_header($head,$group) {
1518      }      }
1519      echo "<br>";      echo "<br>";
1520    }    }
1521    if (isset($head->user_agent)) {    $fields = array ("x-moe", "x-brother", "x-syster", "x-wife",
1522      if ((isset($article_show["User-Agent"])) &&                     "x-daughter", "x-respect",
1523         ($article_show["User-Agent"])) {                     "user-agent", "x-mailer", "x-newsreader",
1524        echo $text_header["user-agent"].htmlspecialchars($head->user_agent)."<br>\n";                     "list-id", "x-uri", "x-mail-count", "keywords");
1525      } else {    for ($i = 0; $i < count($fields); $i++) {
1526        echo "<!-- User-Agent: ".htmlspecialchars($head->user_agent)." -->\n";      if (count($head->field[$fields[$i]])) {
1527          if ((isset($article_show[$fields[$i]])) && ($article_show[$fields[$i]])) {
1528            echo "<div class=\"field ".$fields[$i]."\"><span class=\"name\">"
1529                .$text_header[$fields[$i]]."</span> <span class=\"body\">"
1530                .htmlspecialchars(decode_structured_body(
1531                                    join(', ', $head->field[$fields[$i]])))
1532                ."</span></div>\n";
1533          }
1534        }
1535      }
1536      $fields = array ("x-weather", "x-copyright", "comments", "organization");
1537      for ($i = 0; $i < count($fields); $i++) {
1538        if (count($head->field[$fields[$i]])) {
1539          if ((isset($article_show[$fields[$i]])) && ($article_show[$fields[$i]])) {
1540            for ($j = 0; $j > count($head->field[$fields[$i]]); $j++) {
1541              echo "<div class=\"field ".$fields[$i]."\"><span class=\"name\">"
1542                  .$text_header[$fields[$i]]."</span> <span class=\"body\">"
1543                  .htmlspecialchars(decode_unstructured_body(
1544                                               $head->field[$fields[$i]][$j]))
1545                  ."</span></div>\n";
1546            }
1547          }
1548      }      }
1549    }    }
1550    if ((isset($attachment_show)) && ($attachment_show==true) &&    if ((isset($attachment_show)) && ($attachment_show==true) &&
# Line 1667  function quoted_printable_encode($line) Line 1716  function quoted_printable_encode($line)
1716   * $body: The article itself   * $body: The article itself
1717   */   */
1718  function verschicken($subject,$from,$newsgroups,$ref,$body) {  function verschicken($subject,$from,$newsgroups,$ref,$body) {
1719    global $server,$port,$send_poster_host,$organization,$text_error;    global $server,$port,$send_poster_host,$organization,$text_error,$text_ua;
1720    global $file_footer;    global $file_footer;
1721    flush();    flush();
1722    $ns=OpenNNTPconnection($server,$port);    $ns=OpenNNTPconnection($server,$port);
# Line 1675  function verschicken($subject,$from,$new Line 1724  function verschicken($subject,$from,$new
1724      fputs($ns,"post\r\n");      fputs($ns,"post\r\n");
1725      $weg=lieszeile($ns);      $weg=lieszeile($ns);
1726  //    fputs($ns,'Subject: '.quoted_printable_encode($subject)."\r\n");  //    fputs($ns,'Subject: '.quoted_printable_encode($subject)."\r\n");
1727  //    fputs($ns,'Subject: '.mb_convert_encoding($subject, "ISO-2022-JP", "EUC-JP")."\r\n");      fputs($ns,'Subject: '.mb_convert_encoding($subject, "ISO-2022-JP", "EUC-JP")."\r\n");
1728      fputs($ns,'Subject: '.mb_encode_mimeheader($subject)."\r\n");  //    fputs($ns,'Subject: '.mb_encode_mimeheader($subject)."\r\n");
1729      fputs($ns,'From: '.$from."\r\n");      fputs($ns,'From: '.$from."\r\n");
1730      fputs($ns,'Newsgroups: '.$newsgroups."\r\n");      fputs($ns,'Newsgroups: '.$newsgroups."\r\n");
1731  //    fputs($ns,"Mime-Version: 1.0\r\n");  //    fputs($ns,"Mime-Version: 1.0\r\n");
1732  //    fputs($ns,"Content-Type: text/plain; charset=ISO-8859-1\r\n");  //    fputs($ns,"Content-Type: text/plain; charset=ISO-8859-1\r\n");
1733  //    fputs($ns,"Content-Transfer-Encoding: 8bit\r\n");  //    fputs($ns,"Content-Transfer-Encoding: 8bit\r\n");
1734      fputs($ns,"User-Agent: NewsPortal 0.24pre3\r\n");      fputs($ns,"User-Agent: ".$text_ua["user_agent"]."\r\n");
1735      if ($send_poster_host)      if ($send_poster_host)
1736        fputs($ns,'X-HTTP-Posting-Host: '.gethostbyaddr(getenv("REMOTE_ADDR"))."\r\n");        fputs($ns,'X-HTTP-Posting-Host: '.gethostbyaddr(getenv("REMOTE_ADDR"))."\r\n");
1737      if ($ref!=false) fputs($ns,'References: '.$ref."\r\n");      if ($ref!=false) fputs($ns,'References: '.$ref."\r\n");

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.32

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24