/[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.26 by wakaba, Sun Dec 2 00:08:29 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;
# 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=trim(decode_structured_body($value));
554            break;            break;
555          case "x-face:":          case "x-face:":
556  //          echo "<p>-".base64_decode($value)."-</p>";  //          echo "<p>-".base64_decode($value)."-</p>";
# Line 565  function parse_header($hdr,$number="") { Line 565  function parse_header($hdr,$number="") {
565    return $header;    return $header;
566  }  }
567    
568    function decode_unstructured_body ($body) {
569      $patterns = array (
570          "/(=\\?[^\\x00-\\x20()<>@,;:\\\\\"/\\[\\]?.=\\x7F]+\\?[BQ]\\?[^\\x00-\\x20\\x3F\\x7F]*\\?=)/ei",
571      );
572      $replace = array (
573          "mb_decode_mimeheader('\\1')",
574      );
575      return preg_replace ($patterns, $replace, $body);
576    }
577    
578    function decode_structured_body ($body) {
579      $patterns = array (
580          "/\"((?:[^\"\\\\]+|\\\\.)*)\"/e",
581          "/\(((?:[^()\\\\]+|\\\\.|(?:\((?:[^()\\\\]+|\\\\.|(?:\((?:[^)\\\\]+|\\\\.\
582    )*\)))*\)))*)\)/e",
583      );
584      $replace = array (
585          "mb_convert_encoding(decode_quoted_pair('\\1'), 'EUC-JP', 'auto')",
586          "'('.mb_convert_encoding(decode_quoted_pair('\\1'), 'EUC-JP', 'auto').')'",
587      );
588      return preg_replace ($patterns, $replace, $body);
589    }
590    
591    function decode_quoted_pair($value) {
592      $value = ereg_replace('\\\\(\\\\")', "\\1", $value);
593      return ereg_replace('\\\\(.)', "\\1", $value);
594    }
595    
596  function decode_body($body,$encoding) {  function decode_body($body,$encoding) {
597    $bodyzeile="";    $bodyzeile="";
598    switch ($encoding) {    switch ($encoding) {
# Line 682  function parse_message($rawmessage) { Line 710  function parse_message($rawmessage) {
710  //      if ($body=="") $body=" ";  //      if ($body=="") $body=" ";
711  //    }  //    }
712      $body=decode_body($body,$message->header->content_transfer_encoding);      $body=decode_body($body,$message->header->content_transfer_encoding);
713      $message->body[0]=$body;      $message->body[0] = mb_convert_encoding($body, "EUC-JP", "auto");
714    }    }
715      if (!isset($message->header->content_type_charset))      if (!isset($message->header->content_type_charset))
716        $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 782  function read_message($id,$bodynum=0,$gr
782        return false;        return false;
783      $rawmessage=array();      $rawmessage=array();
784      $line=lieszeile($ns);      $line=lieszeile($ns);
785   $line=mb_convert_encoding($line, "EUC-JP", "ISO-2022-JP");   #$line=mb_convert_encoding($line, "EUC-JP", "ISO-2022-JP");
786      while(strcmp($line,".") != 0) {      while(strcmp($line,".") != 0) {
787        $rawmessage[]=$line;        $rawmessage[]=$line;
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      }      }
791      $message=parse_message($rawmessage);      $message=parse_message($rawmessage);
792      if (ereg('^[0-9]+$',$id)) $message->header->number=$id;      if (ereg('^[0-9]+$',$id)) $message->header->number=$id;
# Line 1177  function formatTreeGraphic($newtree) { Line 1205  function formatTreeGraphic($newtree) {
1205          break;          break;
1206        }        }
1207      $return .= '" alt="'.$alt.'"';      $return .= '" alt="'.$alt.'"';
1208      if (strcmp($k,".") == 0) $return .=(' width="12" height="9"');      if (strcmp($k,".") == 0) $return .=(' style="width: 12px; height: 9px"');
1209      $return .= ' />';      $return .= '>';
1210    }    }
1211    return($return);    return($return);
1212  }  }
# Line 1256  function showThread(&$headers,&$liste,$d Line 1284  function showThread(&$headers,&$liste,$d
1284            echo "<br>\n";            echo "<br>\n";
1285            break;            break;
1286          case 1: // html-auflistung, kein baum          case 1: // html-auflistung, kein baum
1287            echo "<li><nobr>".$thread_fontPre;            echo "<li>".$thread_fontPre;
1288            if ($thread_showDate)            if ($thread_showDate)
1289              echo formatDate($c)." ";              echo formatDate($c)." ";
1290            if ($thread_showSubject)            if ($thread_showSubject)
1291              echo formatSubject($c,$group)." ";              echo formatSubject($c,$group)." ";
1292            if ($thread_showAuthor)            if ($thread_showAuthor)
1293              echo "<i>(".formatAuthor($c).")</i>";              echo "<em>(".formatAuthor($c).")</em>";
1294            echo $thread_fontPost."</nobr></li>";            echo $thread_fontPost."</li>";
1295            break;            break;
1296          case 2:   // table          case 2:   // table
1297            echo "<tr>";            echo "<tr>";
# Line 1275  function showThread(&$headers,&$liste,$d Line 1303  function showThread(&$headers,&$liste,$d
1303            }            }
1304            if ($thread_showAuthor) {            if ($thread_showAuthor) {
1305              echo "<td></td>";              echo "<td></td>";
1306              echo '<td nowrap="nowrap">'.$thread_fontPre.formatAuthor($c);              echo '<td>'.$thread_fontPre.formatAuthor($c);
1307              echo $thread_fontPost."</td>";              echo $thread_fontPost."</td>";
1308            }            }
1309            echo "</tr>\n";            echo "</tr>\n";
1310            break;            break;
1311          case 3: // html-tree          case 3: // html-tree
1312            echo "<li><nobr>".$thread_fontPre;            echo "<li>".$thread_fontPre;
1313            if ($thread_showDate)            if ($thread_showDate)
1314              echo formatDate($c)." ";              echo formatDate($c)." ";
1315            if ($thread_showSubject)            if ($thread_showSubject)
1316              echo formatSubject($c,$group)." ";              echo formatSubject($c,$group)." ";
1317            if ($thread_showAuthor)            if ($thread_showAuthor)
1318              echo "<i>(".formatAuthor($c).")</i>";              echo "<em>(".formatAuthor($c).")</em>";
1319            echo $thread_fontPost."</nobr>\n";            echo $thread_fontPost."\n";
1320            break;            break;
1321          case 4:  // thread          case 4:  // thread
1322            echo "<nobr><tt>".$thread_fontPre;            echo "".$thread_fontPre;
1323            if ($thread_showDate)            if ($thread_showDate)
1324              echo formatDate($c)." ";              echo formatDate($c)." ";
1325            echo formatTreeText($newtree)." ";            echo formatTreeText($newtree)." ";
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."</tt></nobr><br>";            echo $thread_fontPost."<br>";
1331            break;            break;
1332          case 5:  // thread, graphic          case 5:  // thread, graphic
1333            echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr>\n";            echo "<table><tr>\n";
1334            if ($thread_showDate)            if ($thread_showDate)
1335              echo '<td nowrap="nowrap">'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</td>";              echo '<td>'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</td>";
1336            echo "<td>".$thread_fontPre.formatTreeGraphic($newtree).$thread_fontPost."</td>";            echo "<td>".$thread_fontPre.formatTreeGraphic($newtree).$thread_fontPost."</td>";
1337            if ($thread_showSubject)            if ($thread_showSubject)
1338              echo '<td nowrap="nowrap">'.$thread_fontPre."&nbsp;".formatSubject($c,$group)." ";              echo '<td>'.$thread_fontPre."&nbsp;".formatSubject($c,$group)." ";
1339            if ($thread_showAuthor)            if ($thread_showAuthor)
1340              echo "(".formatAuthor($c).")".$thread_fontPost."</td>";              echo "(".formatAuthor($c).")".$thread_fontPost."</td>";
1341            echo "</tr></table>";            echo "</tr></table>";
# Line 1315  function showThread(&$headers,&$liste,$d Line 1343  function showThread(&$headers,&$liste,$d
1343          case 6:  // thread, table          case 6:  // thread, table
1344            echo "<tr>";            echo "<tr>";
1345            if ($thread_showDate)            if ($thread_showDate)
1346              echo '<td nowrap="nowrap"><tt>'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</tt></td>";              echo '<td>'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</td>";
1347            echo '<td nowrap="nowrap"><tt>'.$thread_fontPre.formatTreeText($newtree)." ";            echo '<td>'.$thread_fontPre.formatTreeText($newtree)." ";
1348            if ($thread_showSubject) {            if ($thread_showSubject) {
1349              echo formatSubject($c,$group).$thread_fontPost."</tt></td>";              echo formatSubject($c,$group).$thread_fontPost."</td>";
1350              echo "<td></td>";              echo "<td></td>";
1351            }            }
1352            if ($thread_showAuthor)            if ($thread_showAuthor)
1353              echo '<td nowrap="nowrap"><tt>'.$thread_fontPre.formatAuthor($c).$thread_fontPost."</tt></td>";              echo '<td>'.$thread_fontPre.formatAuthor($c).$thread_fontPost."</td>";
1354            echo "</tr>";            echo "</tr>";
1355            break;            break;
1356          case 7:  // thread, table, graphic          case 7:  // thread, table, graphic
1357            echo "<tr>";            echo "<tr>";
1358            if ($thread_showDate)            if ($thread_showDate)
1359              echo '<td nowrap="nowrap">'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</td>";              echo '<td>'.$thread_fontPre.formatDate($c)." ".$thread_fontPost."</td>";
1360            echo "<td><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";            echo "<td><table>\n";
1361            echo "<td>".formatTreeGraphic($newtree)."</td>";            echo "<td>".formatTreeGraphic($newtree)."</td>";
1362            if ($thread_showSubject)            if ($thread_showSubject)
1363              echo '<td nowrap="nowrap">'.$thread_fontPre."&nbsp;".formatSubject($c,$group).$thread_fontPost."</td>";              echo '<td>'.$thread_fontPre."&nbsp;".formatSubject($c,$group).$thread_fontPost."</td>";
1364            echo "</table></td>";            echo "</table></td>";
1365            if ($thread_showSubject) echo "<td></td>";            if ($thread_showSubject) echo "<td></td>";
1366            if ($thread_showAuthor)            if ($thread_showAuthor)
1367              echo '<td nowrap="nowrap">'.$thread_fontPre.formatAuthor($c).$thread_fontPost."</td>";              echo '<td>'.$thread_fontPre.formatAuthor($c).$thread_fontPost."</td>";
1368            echo "</tr>";            echo "</tr>";
1369            break;            break;
1370        }        }
# Line 1675  function verschicken($subject,$from,$new Line 1703  function verschicken($subject,$from,$new
1703      fputs($ns,"post\r\n");      fputs($ns,"post\r\n");
1704      $weg=lieszeile($ns);      $weg=lieszeile($ns);
1705  //    fputs($ns,'Subject: '.quoted_printable_encode($subject)."\r\n");  //    fputs($ns,'Subject: '.quoted_printable_encode($subject)."\r\n");
1706  //    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");
1707      fputs($ns,'Subject: '.mb_encode_mimeheader($subject)."\r\n");  //    fputs($ns,'Subject: '.mb_encode_mimeheader($subject)."\r\n");
1708      fputs($ns,'From: '.$from."\r\n");      fputs($ns,'From: '.$from."\r\n");
1709      fputs($ns,'Newsgroups: '.$newsgroups."\r\n");      fputs($ns,'Newsgroups: '.$newsgroups."\r\n");
1710  //    fputs($ns,"Mime-Version: 1.0\r\n");  //    fputs($ns,"Mime-Version: 1.0\r\n");
1711  //    fputs($ns,"Content-Type: text/plain; charset=ISO-8859-1\r\n");  //    fputs($ns,"Content-Type: text/plain; charset=ISO-8859-1\r\n");
1712  //    fputs($ns,"Content-Transfer-Encoding: 8bit\r\n");  //    fputs($ns,"Content-Transfer-Encoding: 8bit\r\n");
1713      fputs($ns,"User-Agent: NewsPortal 0.24pre3\r\n");      fputs($ns,"User-Agent: ".$text_ua["user_agent"]."\r\n");
1714      if ($send_poster_host)      if ($send_poster_host)
1715        fputs($ns,'X-HTTP-Posting-Host: '.gethostbyaddr(getenv("REMOTE_ADDR"))."\r\n");        fputs($ns,'X-HTTP-Posting-Host: '.gethostbyaddr(getenv("REMOTE_ADDR"))."\r\n");
1716      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.26

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24