/[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.28 by wakaba, Sun Dec 2 01:34:45 2001 UTC
# Line 447  function headerDecode($value) { Line 447  function headerDecode($value) {
447      else      else
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 {   // there wasn't anything encoded, return the original string    } else {
451      return(mb_convert_encoding($value, "EUC-JP", "auto"));      return(mb_convert_encoding(decode_structured_body($value), "EUC-JP", "auto"));
452    }    }
453  }  }
454    
# Line 497  function parse_header($hdr,$number="") { Line 497  function parse_header($hdr,$number="") {
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));
# Line 550  function parse_header($hdr,$number="") { Line 550  function parse_header($hdr,$number="") {
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($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>";
# Line 565  function parse_header($hdr,$number="") { Line 568  function parse_header($hdr,$number="") {
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) {
# Line 682  function parse_message($rawmessage) { Line 721  function parse_message($rawmessage) {
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");
# Line 754  function read_message($id,$bodynum=0,$gr Line 793  function read_message($id,$bodynum=0,$gr
793        return false;        return false;
794      $rawmessage=array();      $rawmessage=array();
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      while(strcmp($line,".") != 0) {      while(strcmp($line,".") != 0) {
798        $rawmessage[]=$line;        $rawmessage[]=$line;
799        $line=lieszeile($ns);        $line=lieszeile($ns);
800   $line=mb_convert_encoding($line, "EUC-JP", "ISO-2022-JP");   #$line=mb_convert_encoding($line, "EUC-JP", "ISO-2022-JP");
801      }      }
802      $message=parse_message($rawmessage);      $message=parse_message($rawmessage);
803      if (ereg('^[0-9]+$',$id)) $message->header->number=$id;      if (ereg('^[0-9]+$',$id)) $message->header->number=$id;
# Line 1177  function formatTreeGraphic($newtree) { Line 1216  function formatTreeGraphic($newtree) {
1216          break;          break;
1217        }        }
1218      $return .= '" alt="'.$alt.'"';      $return .= '" alt="'.$alt.'"';
1219      if (strcmp($k,".") == 0) $return .=(' width="12" height="9"');      if (strcmp($k,".") == 0) $return .=(' style="width: 12px; height: 9px"');
1220      $return .= ' />';      $return .= '>';
1221    }    }
1222    return($return);    return($return);
1223  }  }
# Line 1256  function showThread(&$headers,&$liste,$d Line 1295  function showThread(&$headers,&$liste,$d
1295            echo "<br>\n";            echo "<br>\n";
1296            break;            break;
1297          case 1: // html-auflistung, kein baum          case 1: // html-auflistung, kein baum
1298            echo "<li><nobr>".$thread_fontPre;            echo "<li>".$thread_fontPre;
1299            if ($thread_showDate)            if ($thread_showDate)
1300              echo formatDate($c)." ";              echo formatDate($c)." ";
1301            if ($thread_showSubject)            if ($thread_showSubject)
1302              echo formatSubject($c,$group)." ";              echo formatSubject($c,$group)." ";
1303            if ($thread_showAuthor)            if ($thread_showAuthor)
1304              echo "<i>(".formatAuthor($c).")</i>";              echo "<em>(".formatAuthor($c).")</em>";
1305            echo $thread_fontPost."</nobr></li>";            echo $thread_fontPost."</li>";
1306            break;            break;
1307          case 2:   // table          case 2:   // table
1308            echo "<tr>";            echo "<tr>";
# Line 1275  function showThread(&$headers,&$liste,$d Line 1314  function showThread(&$headers,&$liste,$d
1314            }            }
1315            if ($thread_showAuthor) {            if ($thread_showAuthor) {
1316              echo "<td></td>";              echo "<td></td>";
1317              echo '<td nowrap="nowrap">'.$thread_fontPre.formatAuthor($c);              echo '<td>'.$thread_fontPre.formatAuthor($c);
1318              echo $thread_fontPost."</td>";              echo $thread_fontPost."</td>";
1319            }            }
1320            echo "</tr>\n";            echo "</tr>\n";
1321            break;            break;
1322          case 3: // html-tree          case 3: // html-tree
1323            echo "<li><nobr>".$thread_fontPre;            echo "<li>".$thread_fontPre;
1324            if ($thread_showDate)            if ($thread_showDate)
1325              echo formatDate($c)." ";              echo formatDate($c)." ";
1326            if ($thread_showSubject)            if ($thread_showSubject)
1327              echo formatSubject($c,$group)." ";              echo formatSubject($c,$group)." ";
1328            if ($thread_showAuthor)            if ($thread_showAuthor)
1329              echo "<i>(".formatAuthor($c).")</i>";              echo "<em>(".formatAuthor($c).")</em>";
1330            echo $thread_fontPost."</nobr>\n";            echo $thread_fontPost."\n";
1331            break;            break;
1332          case 4:  // thread          case 4:  // thread
1333            echo "<nobr><tt>".$thread_fontPre;            echo "".$thread_fontPre;
1334            if ($thread_showDate)            if ($thread_showDate)
1335              echo formatDate($c)." ";              echo formatDate($c)." ";
1336            echo formatTreeText($newtree)." ";            echo formatTreeText($newtree)." ";
1337            if ($thread_showSubject)            if ($thread_showSubject)
1338              echo formatSubject($c,$group)." ";              echo formatSubject($c,$group)." ";
1339            if ($thread_showAuthor)            if ($thread_showAuthor)
1340              echo "<i>(".formatAuthor($c).")</i>";              echo "<em>(".formatAuthor($c).")</em>";
1341            echo $thread_fontPost."</tt></nobr><br>";            echo $thread_fontPost."<br>";
1342            break;            break;
1343          case 5:  // thread, graphic          case 5:  // thread, graphic
1344            echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr>\n";            echo "<table><tr>\n";
1345            if ($thread_showDate)            if ($thread_showDate)
1346              echo '<td nowrap="nowrap">'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</td>";              echo '<td>'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</td>";
1347            echo "<td>".$thread_fontPre.formatTreeGraphic($newtree).$thread_fontPost."</td>";            echo "<td>".$thread_fontPre.formatTreeGraphic($newtree).$thread_fontPost."</td>";
1348            if ($thread_showSubject)            if ($thread_showSubject)
1349              echo '<td nowrap="nowrap">'.$thread_fontPre."&nbsp;".formatSubject($c,$group)." ";              echo '<td>'.$thread_fontPre."&nbsp;".formatSubject($c,$group)." ";
1350            if ($thread_showAuthor)            if ($thread_showAuthor)
1351              echo "(".formatAuthor($c).")".$thread_fontPost."</td>";              echo "(".formatAuthor($c).")".$thread_fontPost."</td>";
1352            echo "</tr></table>";            echo "</tr></table>";
# Line 1315  function showThread(&$headers,&$liste,$d Line 1354  function showThread(&$headers,&$liste,$d
1354          case 6:  // thread, table          case 6:  // thread, table
1355            echo "<tr>";            echo "<tr>";
1356            if ($thread_showDate)            if ($thread_showDate)
1357              echo '<td nowrap="nowrap"><tt>'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</tt></td>";              echo '<td>'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</td>";
1358            echo '<td nowrap="nowrap"><tt>'.$thread_fontPre.formatTreeText($newtree)." ";            echo '<td>'.$thread_fontPre.formatTreeText($newtree)." ";
1359            if ($thread_showSubject) {            if ($thread_showSubject) {
1360              echo formatSubject($c,$group).$thread_fontPost."</tt></td>";              echo formatSubject($c,$group).$thread_fontPost."</td>";
1361              echo "<td></td>";              echo "<td></td>";
1362            }            }
1363            if ($thread_showAuthor)            if ($thread_showAuthor)
1364              echo '<td nowrap="nowrap"><tt>'.$thread_fontPre.formatAuthor($c).$thread_fontPost."</tt></td>";              echo '<td>'.$thread_fontPre.formatAuthor($c).$thread_fontPost."</td>";
1365            echo "</tr>";            echo "</tr>";
1366            break;            break;
1367          case 7:  // thread, table, graphic          case 7:  // thread, table, graphic
1368            echo "<tr>";            echo "<tr>";
1369            if ($thread_showDate)            if ($thread_showDate)
1370              echo '<td nowrap="nowrap">'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</td>";              echo '<td>'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</td>";
1371            echo "<td><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";            echo "<td><table>\n";
1372            echo "<td>".formatTreeGraphic($newtree)."</td>";            echo "<td>".formatTreeGraphic($newtree)."</td>";
1373            if ($thread_showSubject)            if ($thread_showSubject)
1374              echo '<td nowrap="nowrap">'.$thread_fontPre."&nbsp;".formatSubject($c,$group).$thread_fontPost."</td>";              echo '<td>'.$thread_fontPre."&nbsp;".formatSubject($c,$group).$thread_fontPost."</td>";
1375            echo "</table></td>";            echo "</table></td>";
1376            if ($thread_showSubject) echo "<td></td>";            if ($thread_showSubject) echo "<td></td>";
1377            if ($thread_showAuthor)            if ($thread_showAuthor)
1378              echo '<td nowrap="nowrap">'.$thread_fontPre.formatAuthor($c).$thread_fontPost."</td>";              echo '<td>'.$thread_fontPre.formatAuthor($c).$thread_fontPost."</td>";
1379            echo "</tr>";            echo "</tr>";
1380            break;            break;
1381        }        }
# Line 1498  function show_header($head,$group) { Line 1537  function show_header($head,$group) {
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"];
# Line 1675  function verschicken($subject,$from,$new Line 1721  function verschicken($subject,$from,$new
1721      fputs($ns,"post\r\n");      fputs($ns,"post\r\n");
1722      $weg=lieszeile($ns);      $weg=lieszeile($ns);
1723  //    fputs($ns,'Subject: '.quoted_printable_encode($subject)."\r\n");  //    fputs($ns,'Subject: '.quoted_printable_encode($subject)."\r\n");
1724  //    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");
1725      fputs($ns,'Subject: '.mb_encode_mimeheader($subject)."\r\n");  //    fputs($ns,'Subject: '.mb_encode_mimeheader($subject)."\r\n");
1726      fputs($ns,'From: '.$from."\r\n");      fputs($ns,'From: '.$from."\r\n");
1727      fputs($ns,'Newsgroups: '.$newsgroups."\r\n");      fputs($ns,'Newsgroups: '.$newsgroups."\r\n");
1728  //    fputs($ns,"Mime-Version: 1.0\r\n");  //    fputs($ns,"Mime-Version: 1.0\r\n");
1729  //    fputs($ns,"Content-Type: text/plain; charset=ISO-8859-1\r\n");  //    fputs($ns,"Content-Type: text/plain; charset=ISO-8859-1\r\n");
1730  //    fputs($ns,"Content-Transfer-Encoding: 8bit\r\n");  //    fputs($ns,"Content-Transfer-Encoding: 8bit\r\n");
1731      fputs($ns,"User-Agent: NewsPortal 0.24pre3\r\n");      fputs($ns,"User-Agent: ".$text_ua["user_agent"]."\r\n");
1732      if ($send_poster_host)      if ($send_poster_host)
1733        fputs($ns,'X-HTTP-Posting-Host: '.gethostbyaddr(getenv("REMOTE_ADDR"))."\r\n");        fputs($ns,'X-HTTP-Posting-Host: '.gethostbyaddr(getenv("REMOTE_ADDR"))."\r\n");
1734      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.28

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24