/[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.2 by wakaba, Sat Dec 1 11:51:33 2001 UTC revision 1.29 by wakaba, Sun Dec 2 01:58:09 2001 UTC
# Line 57  class headerType { Line 57  class headerType {
57    var $isAnswer;    var $isAnswer;
58    var $username;    var $username;
59    var $user_agent;    var $user_agent;
60      var $field;
61    var $isReply;    var $isReply;
62  }  }
63    
# Line 326  function address_decode($adrstring,$defa Line 327  function address_decode($adrstring,$defa
327    $result["mailbox"]=trim($mailbox);    $result["mailbox"]=trim($mailbox);
328    $result["host"]=trim($host);    $result["host"]=trim($host);
329  //  $personal = mb_convert_encoding($personal, "EUC-JP", "auto");  //  $personal = mb_convert_encoding($personal, "EUC-JP", "auto");
   $personal = ereg_replace("\\(.)", $regs[1], $personal);  
330    if ($personal!="") $result["personal"]=$personal;    if ($personal!="") $result["personal"]=$personal;
331    $complete[]=$result;    $complete[]=$result;
332    return ($complete);    return ($complete);
# Line 448  function headerDecode($value) { Line 448  function headerDecode($value) {
448      else      else
449        $newvalue=headerDecode($newvalue);  // maybe there are more encoded        $newvalue=headerDecode($newvalue);  // maybe there are more encoded
450      return(mb_convert_encoding($newvalue, "EUC-JP", "auto"));      // parts      return(mb_convert_encoding($newvalue, "EUC-JP", "auto"));      // parts
451    } else {   // there wasn't anything encoded, return the original string    } else {
452      return(mb_convert_encoding($value, "EUC-JP", "auto"));      return(mb_convert_encoding(decode_structured_body($value), "EUC-JP", "auto"));
453    }    }
454  }  }
455    
# Line 480  function parse_header($hdr,$number="") { Line 480  function parse_header($hdr,$number="") {
480    $header = new headerType;    $header = new headerType;
481    $header->isAnswer=false;    $header->isAnswer=false;
482    for ($count=0;$count<count($hdr);$count++) {    for ($count=0;$count<count($hdr);$count++) {
483      $variable=substr($hdr[$count],0,strpos($hdr[$count]," "));      $variable=substr($hdr[$count],0,strpos($hdr[$count],":"));
484      $value=trim(substr($hdr[$count],strpos($hdr[$count]," ")+1));      $value=trim(substr($hdr[$count],strpos($hdr[$count],":")+1));
485        $header->field[$variable][] = $value;
486        switch (strtolower($variable)) {        switch (strtolower($variable)) {
487          case "from:":          case "from": cs
488            $fromline=address_decode(headerDecode($value),"nirgendwo");            $fromline=address_decode(headerDecode($value),"nirgendwo");
489            if (!isset($fromline[0]["host"])) $fromline[0]["host"]="";            if (!isset($fromline[0]["host"])) $fromline[0]["host"]="";
490            $header->from=$fromline[0]["mailbox"]."@".$fromline[0]["host"];            $header->from=$fromline[0]["mailbox"]."@".$fromline[0]["host"];
# Line 494  function parse_header($hdr,$number="") { Line 495  function parse_header($hdr,$number="") {
495              $header->name=$fromline[0]["personal"];              $header->name=$fromline[0]["personal"];
496            }            }
497            break;            break;
498          case "message-id:":          case "message-id":
499            $header->id=$value;            $header->id=$value;
500            break;            break;
501          case "subject:":          case "subject":
502            $header->subject=headerDecode($value);            $header->subject = decode_unstructured_body($value);
503            break;            break;
504          case "newsgroups:":          case "newsgroups":
505            $header->newsgroups=$value;            $header->newsgroups=$value;
506            break;            break;
507          case "organization:":          case "organization":
508            $header->organization=$value;            $header->organization = decode_unstructured_body($value);
509            break;            break;
510          case "content-transfer-encoding:":          case "content-transfer-encoding":
511            $header->content_transfer_encoding=trim(strtolower($value));            $header->content_transfer_encoding=trim(strtolower($value));
512            break;            break;
513          case "content-type:":          case "content-type":
514            $header->content_type=array();            $header->content_type=array();
515            $subheader=split(";",$value);            $subheader=split(";",$value);
516            $header->content_type[0]=strtolower(trim($subheader[0]));            $header->content_type[0]=strtolower(trim($subheader[0]));
# Line 534  function parse_header($hdr,$number="") { Line 535  function parse_header($hdr,$number="") {
535              }              }
536            }            }
537            break;            break;
538          case "references:":          case "references":
539            $ref=ereg_replace("> *<", "> <", trim($value));            $ref=ereg_replace("> *<", "> <", trim($value));
540            while (strpos($ref,"> <") != false) {            while (strpos($ref,"> <") != false) {
541              $header->references[]=substr($ref,0,strpos($ref," "));              $header->references[]=substr($ref,0,strpos($ref," "));
# Line 542  function parse_header($hdr,$number="") { Line 543  function parse_header($hdr,$number="") {
543            }            }
544            $header->references[]=trim($ref);            $header->references[]=trim($ref);
545            break;            break;
546          case "date:":          case "date":
547            $header->date=getTimestamp(trim($value));            $header->date=getTimestamp(trim($value));
548            break;            break;
549          case "followup-to:":          case "followup-to":
550            $header->followup=trim($value);            $header->followup=trim($value);
551            break;            break;
552          case "x-newsreader:":          case "x-newsreader":
553          case "x-mailer:":          case "x-mailer":
554          case "user-agent:":          case "user-agent":
555            $header->user_agent=trim($value);            $header->user_agent= decode_structured_body($value);
           break;  
         case "x-face:":  
 //          echo "<p>-".base64_decode($value)."-</p>";  
556            break;            break;
557        }        }
558    }    }
# Line 566  function parse_header($hdr,$number="") { Line 564  function parse_header($hdr,$number="") {
564    return $header;    return $header;
565  }  }
566    
567    function decode_unstructured_body ($body) {
568      $patterns = array (
569          "/(=\\?[^\\x00-\\x20()<>@,;:\\\"\\/\\[\\]?.=\\x7F]+\\?[BQ]\\?[^\\x00-\\x20\\x3F\\x7F]*\\?=)/ei",
570      );
571      $replace = array (
572          "mb_decode_mimeheader('\\1')",
573      );
574      return preg_replace ($patterns, $replace,
575                           mb_convert_encoding(fake_jisx0213($body), "EUC-JP", "auto"));
576    }
577    
578    function decode_structured_body ($body) {
579      $patterns = array (
580          "/\"((?:[^\"\\\\]+|\\\\.)*)\"/e",
581          "/\(((?:[^()\\\\]+|\\\\.|(?:\((?:[^()\\\\]+|\\\\.|(?:\((?:[^)\\\\]+|\\\\.\
582    )*\)))*\)))*)\)/e",
583      );
584      $replace = array (
585        "mb_convert_encoding(fake_jisx0213(decode_quoted_pair('\\1')),'EUC-JP','auto')",
586        "'('.mb_convert_encoding(fake_jisx0213(decode_quoted_pair('\\1')),
587                                 'EUC-JP','auto').')'",
588      );
589      return preg_replace ($patterns, $replace, $body);
590    }
591    
592    function decode_quoted_pair($value) {
593      $value = ereg_replace('\\\\(\\\\")', "\\1", $value);
594      return ereg_replace('\\\\(.)', "\\1", $value);
595    }
596    
597    function fake_jisx0213 ($value) {
598      $value = preg_replace ("/\\x1B\\\$\\(O/", "\x1B\\\$B", $value);
599      $value = preg_replace ("/\\x1B\\\$\\(P/", "\x1B\\\$(D", $value);
600      return $value;
601    }
602    
603  function decode_body($body,$encoding) {  function decode_body($body,$encoding) {
604    $bodyzeile="";    $bodyzeile="";
605    switch ($encoding) {    switch ($encoding) {
# Line 683  function parse_message($rawmessage) { Line 717  function parse_message($rawmessage) {
717  //      if ($body=="") $body=" ";  //      if ($body=="") $body=" ";
718  //    }  //    }
719      $body=decode_body($body,$message->header->content_transfer_encoding);      $body=decode_body($body,$message->header->content_transfer_encoding);
720      $message->body[0]=$body;      $message->body[0] = mb_convert_encoding($body, "EUC-JP", "auto");
721    }    }
722      if (!isset($message->header->content_type_charset))      if (!isset($message->header->content_type_charset))
723        $message->header->content_type_charset=array("ISO-8859-1");        $message->header->content_type_charset=array("ISO-8859-1");
# Line 755  function read_message($id,$bodynum=0,$gr Line 789  function read_message($id,$bodynum=0,$gr
789        return false;        return false;
790      $rawmessage=array();      $rawmessage=array();
791      $line=lieszeile($ns);      $line=lieszeile($ns);
792   $line=mb_convert_encoding($line, "EUC-JP", "ISO-2022-JP");   #$line=mb_convert_encoding($line, "EUC-JP", "ISO-2022-JP");
793      while(strcmp($line,".") != 0) {      while(strcmp($line,".") != 0) {
794        $rawmessage[]=$line;        $rawmessage[]=$line;
795        $line=lieszeile($ns);        $line=lieszeile($ns);
796   $line=mb_convert_encoding($line, "EUC-JP", "ISO-2022-JP");   #$line=mb_convert_encoding($line, "EUC-JP", "ISO-2022-JP");
797      }      }
798      $message=parse_message($rawmessage);      $message=parse_message($rawmessage);
799      if (ereg('^[0-9]+$',$id)) $message->header->number=$id;      if (ereg('^[0-9]+$',$id)) $message->header->number=$id;
# Line 1178  function formatTreeGraphic($newtree) { Line 1212  function formatTreeGraphic($newtree) {
1212          break;          break;
1213        }        }
1214      $return .= '" alt="'.$alt.'"';      $return .= '" alt="'.$alt.'"';
1215      if (strcmp($k,".") == 0) $return .=(' width="12" height="9"');      if (strcmp($k,".") == 0) $return .=(' style="width: 12px; height: 9px"');
1216      $return .= ' />';      $return .= '>';
1217    }    }
1218    return($return);    return($return);
1219  }  }
# Line 1257  function showThread(&$headers,&$liste,$d Line 1291  function showThread(&$headers,&$liste,$d
1291            echo "<br>\n";            echo "<br>\n";
1292            break;            break;
1293          case 1: // html-auflistung, kein baum          case 1: // html-auflistung, kein baum
1294            echo "<li><nobr>".$thread_fontPre;            echo "<li>".$thread_fontPre;
1295            if ($thread_showDate)            if ($thread_showDate)
1296              echo formatDate($c)." ";              echo formatDate($c)." ";
1297            if ($thread_showSubject)            if ($thread_showSubject)
1298              echo formatSubject($c,$group)." ";              echo formatSubject($c,$group)." ";
1299            if ($thread_showAuthor)            if ($thread_showAuthor)
1300              echo "<i>(".formatAuthor($c).")</i>";              echo "<em>(".formatAuthor($c).")</em>";
1301            echo $thread_fontPost."</nobr></li>";            echo $thread_fontPost."</li>";
1302            break;            break;
1303          case 2:   // table          case 2:   // table
1304            echo "<tr>";            echo "<tr>";
# Line 1276  function showThread(&$headers,&$liste,$d Line 1310  function showThread(&$headers,&$liste,$d
1310            }            }
1311            if ($thread_showAuthor) {            if ($thread_showAuthor) {
1312              echo "<td></td>";              echo "<td></td>";
1313              echo '<td nowrap="nowrap">'.$thread_fontPre.formatAuthor($c);              echo '<td>'.$thread_fontPre.formatAuthor($c);
1314              echo $thread_fontPost."</td>";              echo $thread_fontPost."</td>";
1315            }            }
1316            echo "</tr>\n";            echo "</tr>\n";
1317            break;            break;
1318          case 3: // html-tree          case 3: // html-tree
1319            echo "<li><nobr>".$thread_fontPre;            echo "<li>".$thread_fontPre;
1320            if ($thread_showDate)            if ($thread_showDate)
1321              echo formatDate($c)." ";              echo formatDate($c)." ";
1322            if ($thread_showSubject)            if ($thread_showSubject)
1323              echo formatSubject($c,$group)." ";              echo formatSubject($c,$group)." ";
1324            if ($thread_showAuthor)            if ($thread_showAuthor)
1325              echo "<i>(".formatAuthor($c).")</i>";              echo "<em>(".formatAuthor($c).")</em>";
1326            echo $thread_fontPost."</nobr>\n";            echo $thread_fontPost."\n";
1327            break;            break;
1328          case 4:  // thread          case 4:  // thread
1329            echo "<nobr><tt>".$thread_fontPre;            echo "".$thread_fontPre;
1330            if ($thread_showDate)            if ($thread_showDate)
1331              echo formatDate($c)." ";              echo formatDate($c)." ";
1332            echo formatTreeText($newtree)." ";            echo formatTreeText($newtree)." ";
1333            if ($thread_showSubject)            if ($thread_showSubject)
1334              echo formatSubject($c,$group)." ";              echo formatSubject($c,$group)." ";
1335            if ($thread_showAuthor)            if ($thread_showAuthor)
1336              echo "<i>(".formatAuthor($c).")</i>";              echo "<em>(".formatAuthor($c).")</em>";
1337            echo $thread_fontPost."</tt></nobr><br>";            echo $thread_fontPost."<br>";
1338            break;            break;
1339          case 5:  // thread, graphic          case 5:  // thread, graphic
1340            echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr>\n";            echo "<table><tr>\n";
1341            if ($thread_showDate)            if ($thread_showDate)
1342              echo '<td nowrap="nowrap">'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</td>";              echo '<td>'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</td>";
1343            echo "<td>".$thread_fontPre.formatTreeGraphic($newtree).$thread_fontPost."</td>";            echo "<td>".$thread_fontPre.formatTreeGraphic($newtree).$thread_fontPost."</td>";
1344            if ($thread_showSubject)            if ($thread_showSubject)
1345              echo '<td nowrap="nowrap">'.$thread_fontPre."&nbsp;".formatSubject($c,$group)." ";              echo '<td>'.$thread_fontPre."&nbsp;".formatSubject($c,$group)." ";
1346            if ($thread_showAuthor)            if ($thread_showAuthor)
1347              echo "(".formatAuthor($c).")".$thread_fontPost."</td>";              echo "(".formatAuthor($c).")".$thread_fontPost."</td>";
1348            echo "</tr></table>";            echo "</tr></table>";
# Line 1316  function showThread(&$headers,&$liste,$d Line 1350  function showThread(&$headers,&$liste,$d
1350          case 6:  // thread, table          case 6:  // thread, table
1351            echo "<tr>";            echo "<tr>";
1352            if ($thread_showDate)            if ($thread_showDate)
1353              echo '<td nowrap="nowrap"><tt>'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</tt></td>";              echo '<td>'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</td>";
1354            echo '<td nowrap="nowrap"><tt>'.$thread_fontPre.formatTreeText($newtree)." ";            echo '<td>'.$thread_fontPre.formatTreeText($newtree)." ";
1355            if ($thread_showSubject) {            if ($thread_showSubject) {
1356              echo formatSubject($c,$group).$thread_fontPost."</tt></td>";              echo formatSubject($c,$group).$thread_fontPost."</td>";
1357              echo "<td></td>";              echo "<td></td>";
1358            }            }
1359            if ($thread_showAuthor)            if ($thread_showAuthor)
1360              echo '<td nowrap="nowrap"><tt>'.$thread_fontPre.formatAuthor($c).$thread_fontPost."</tt></td>";              echo '<td>'.$thread_fontPre.formatAuthor($c).$thread_fontPost."</td>";
1361            echo "</tr>";            echo "</tr>";
1362            break;            break;
1363          case 7:  // thread, table, graphic          case 7:  // thread, table, graphic
1364            echo "<tr>";            echo "<tr>";
1365            if ($thread_showDate)            if ($thread_showDate)
1366              echo '<td nowrap="nowrap">'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</td>";              echo '<td>'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</td>";
1367            echo "<td><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";            echo "<td><table>\n";
1368            echo "<td>".formatTreeGraphic($newtree)."</td>";            echo "<td>".formatTreeGraphic($newtree)."</td>";
1369            if ($thread_showSubject)            if ($thread_showSubject)
1370              echo '<td nowrap="nowrap">'.$thread_fontPre."&nbsp;".formatSubject($c,$group).$thread_fontPost."</td>";              echo '<td>'.$thread_fontPre."&nbsp;".formatSubject($c,$group).$thread_fontPost."</td>";
1371            echo "</table></td>";            echo "</table></td>";
1372            if ($thread_showSubject) echo "<td></td>";            if ($thread_showSubject) echo "<td></td>";
1373            if ($thread_showAuthor)            if ($thread_showAuthor)
1374              echo '<td nowrap="nowrap">'.$thread_fontPre.formatAuthor($c).$thread_fontPost."</td>";              echo '<td>'.$thread_fontPre.formatAuthor($c).$thread_fontPost."</td>";
1375            echo "</tr>";            echo "</tr>";
1376            break;            break;
1377        }        }
# Line 1499  function show_header($head,$group) { Line 1533  function show_header($head,$group) {
1533        echo "<!-- User-Agent: ".htmlspecialchars($head->user_agent)." -->\n";        echo "<!-- User-Agent: ".htmlspecialchars($head->user_agent)." -->\n";
1534      }      }
1535    }    }
1536      if (isset($head->field["x-moe"])) {
1537        if ((isset($article_show["X-Moe"])) && ($article_show["X-Moe"])) {
1538          echo "<span class=\"field x-moe\"><span class=\"name\">".$text_header["X-Moe"]
1539              ."</span> <span class=\"body\">"
1540              .htmlspecialchars(decode_structured_body(
1541                                  join(', ', $head->field["x-moe"])))
1542              ."</span>\n";
1543        }
1544      }
1545    if ((isset($attachment_show)) && ($attachment_show==true) &&    if ((isset($attachment_show)) && ($attachment_show==true) &&
1546        (isset($head->content_type[1]))) {        (isset($head->content_type[1]))) {
1547      echo $text_header["attachments"];      echo $text_header["attachments"];
# Line 1676  function verschicken($subject,$from,$new Line 1719  function verschicken($subject,$from,$new
1719      fputs($ns,"post\r\n");      fputs($ns,"post\r\n");
1720      $weg=lieszeile($ns);      $weg=lieszeile($ns);
1721  //    fputs($ns,'Subject: '.quoted_printable_encode($subject)."\r\n");  //    fputs($ns,'Subject: '.quoted_printable_encode($subject)."\r\n");
1722  //    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");
1723      fputs($ns,'Subject: '.mb_encode_mimeheader($subject)."\r\n");  //    fputs($ns,'Subject: '.mb_encode_mimeheader($subject)."\r\n");
1724      fputs($ns,'From: '.$from."\r\n");      fputs($ns,'From: '.$from."\r\n");
1725      fputs($ns,'Newsgroups: '.$newsgroups."\r\n");      fputs($ns,'Newsgroups: '.$newsgroups."\r\n");
1726  //    fputs($ns,"Mime-Version: 1.0\r\n");  //    fputs($ns,"Mime-Version: 1.0\r\n");
1727  //    fputs($ns,"Content-Type: text/plain; charset=ISO-8859-1\r\n");  //    fputs($ns,"Content-Type: text/plain; charset=ISO-8859-1\r\n");
1728  //    fputs($ns,"Content-Transfer-Encoding: 8bit\r\n");  //    fputs($ns,"Content-Transfer-Encoding: 8bit\r\n");
1729      fputs($ns,"User-Agent: NewsPortal 0.24pre3\r\n");      fputs($ns,"User-Agent: ".$text_ua["user_agent"]."\r\n");
1730      if ($send_poster_host)      if ($send_poster_host)
1731        fputs($ns,'X-HTTP-Posting-Host: '.gethostbyaddr(getenv("REMOTE_ADDR"))."\r\n");        fputs($ns,'X-HTTP-Posting-Host: '.gethostbyaddr(getenv("REMOTE_ADDR"))."\r\n");
1732      if ($ref!=false) fputs($ns,'References: '.$ref."\r\n");      if ($ref!=false) fputs($ns,'References: '.$ref."\r\n");

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.29

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24