/[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 by wakaba, Sat Dec 1 11:17:31 2001 UTC revision 1.27 by wakaba, Sun Dec 2 00:59:42 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($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(decode_quoted_pair('\\1'), 'EUC-JP', 'auto')",
590          "'('.mb_convert_encoding(decode_quoted_pair('\\1'), 'EUC-JP', 'auto').')'",
591      );
592      return preg_replace ($patterns, $replace, $body);
593    }
594    
595    function decode_quoted_pair($value) {
596      $value = ereg_replace('\\\\(\\\\")', "\\1", $value);
597      return ereg_replace('\\\\(.)', "\\1", $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 1498  function show_header($head,$group) { Line 1530  function show_header($head,$group) {
1530        echo "<!-- User-Agent: ".htmlspecialchars($head->user_agent)." -->\n";        echo "<!-- User-Agent: ".htmlspecialchars($head->user_agent)." -->\n";
1531      }      }
1532    }    }
1533      if (isset($head->x_moe)) {
1534        if ((isset($article_show["X-Moe"])) && ($article_show["X-Moe"])) {
1535          echo "<span class=\"field x-moe\"><span class=\"name\">".$text_header["X-Moe"]
1536              ."</span> <span class=\"body\">"
1537              .htmlspecialchars($head->x_moe)."</span>\n";
1538        }
1539      }
1540    if ((isset($attachment_show)) && ($attachment_show==true) &&    if ((isset($attachment_show)) && ($attachment_show==true) &&
1541        (isset($head->content_type[1]))) {        (isset($head->content_type[1]))) {
1542      echo $text_header["attachments"];      echo $text_header["attachments"];
# Line 1675  function verschicken($subject,$from,$new Line 1714  function verschicken($subject,$from,$new
1714      fputs($ns,"post\r\n");      fputs($ns,"post\r\n");
1715      $weg=lieszeile($ns);      $weg=lieszeile($ns);
1716  //    fputs($ns,'Subject: '.quoted_printable_encode($subject)."\r\n");  //    fputs($ns,'Subject: '.quoted_printable_encode($subject)."\r\n");
1717  //    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");
1718      fputs($ns,'Subject: '.mb_encode_mimeheader($subject)."\r\n");  //    fputs($ns,'Subject: '.mb_encode_mimeheader($subject)."\r\n");
1719      fputs($ns,'From: '.$from."\r\n");      fputs($ns,'From: '.$from."\r\n");
1720      fputs($ns,'Newsgroups: '.$newsgroups."\r\n");      fputs($ns,'Newsgroups: '.$newsgroups."\r\n");
1721  //    fputs($ns,"Mime-Version: 1.0\r\n");  //    fputs($ns,"Mime-Version: 1.0\r\n");
1722  //    fputs($ns,"Content-Type: text/plain; charset=ISO-8859-1\r\n");  //    fputs($ns,"Content-Type: text/plain; charset=ISO-8859-1\r\n");
1723  //    fputs($ns,"Content-Transfer-Encoding: 8bit\r\n");  //    fputs($ns,"Content-Transfer-Encoding: 8bit\r\n");
1724      fputs($ns,"User-Agent: NewsPortal 0.24pre3\r\n");      fputs($ns,"User-Agent: ".$text_ua["user_agent"]."\r\n");
1725      if ($send_poster_host)      if ($send_poster_host)
1726        fputs($ns,'X-HTTP-Posting-Host: '.gethostbyaddr(getenv("REMOTE_ADDR"))."\r\n");        fputs($ns,'X-HTTP-Posting-Host: '.gethostbyaddr(getenv("REMOTE_ADDR"))."\r\n");
1727      if ($ref!=false) fputs($ns,'References: '.$ref."\r\n");      if ($ref!=false) fputs($ns,'References: '.$ref."\r\n");

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.27

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24