* Supprime du code inutile
authorx2003bruneau <x2003bruneau@9869982d-c50d-0410-be91-f2a2ec7c7c7b>
Thu, 2 Mar 2006 12:23:41 +0000 (12:23 +0000)
committerx2003bruneau <x2003bruneau@9869982d-c50d-0410-be91-f2a2ec7c7c7b>
Thu, 2 Mar 2006 12:23:41 +0000 (12:23 +0000)
* Ajoute le support de la couleur de fond pour les messages en html

git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@17 9869982d-c50d-0410-be91-f2a2ec7c7c7b

banana/misc.inc.php
banana/post.inc.php

index 1197c69..04bd09c 100644 (file)
@@ -65,6 +65,9 @@ function htmlToPlainText($res)
 {
     $res = trim(html_entity_decode(strip_tags($res, '<br>')));
     $res = preg_replace("@<br[^>]>@i", "\n", $res);
+    if (!is_utf8($res)) {
+        $res = utf8_encode($res);
+    }   
     return $res;
 }
 
@@ -304,9 +307,9 @@ function wrap($text, $_prefix="")
 function formatbody($_text, $format='plain')
 {
     if ($format == 'html') {
-        $res = '<br/>'.removeEvilTags(html_entity_decode(to_entities($_text))).'<br/>';
+        $res = '<br/>'.removeEvilTags($_text).'<br/>';
     } else if ($format == 'richtext') {
-        $res = '<br/>'.richtextToHtml(html_entity_decode(to_entities($_text))).'<br/>';
+        $res = '<br/>'.richtextToHtml($_text).'<br/>';
         $format = 'html';
     } else {
         $res  = "\n\n" . to_entities(wrap($_text, ""))."\n\n";
index a1cb4d4..c994908 100644 (file)
@@ -318,11 +318,14 @@ class BananaPost
  
         preg_match("@text/([^;]+);@", $this->headers['content-type'], $format);
         $format = $format[1];
-        $res .= '<tr><td colspan="2">';
+        $res .= '<tr><td colspan="2"';
         if ($format == 'html') {
-            $res .= formatbody($this->body, $format); 
+            if (preg_match('@<body[^>]*bgcolor="?([#0-9a-f]+)"?[^>]*>@i', $this->body, $bgcolor)) {
+                $res .= ' bgcolor="'.$bgcolor[1].'"';
+            }
+            $res .= '>'.formatbody($this->body, $format); 
         } else {
-            $res .= '<pre>'.formatbody($this->body).'</pre>';
+            $res .= '><pre>'.formatbody($this->body).'</pre>';
         }
         $res .= '</td></tr>';