Fix others PHP Notices
[banana.git] / banana / post.inc.php
index 9f3dc59..a7921ae 100644 (file)
@@ -58,8 +58,10 @@ class BananaPost
 
         if ($this->_split_multipart($this->headers, $this->body)) {
             $this->set_body_to_part(0);
-        } elseif(isset($mpart_type)) {
-            $this->_split_multipart($mpart_type[1], $mpart_boundary[1]);
+        } else {
+            if(isset($mpart_type)) {
+                $this->_split_multipart($mpart_type[1], $mpart_boundary[1]);
+            }
             $this->_find_uuencode();
             $this->_fix_charset();
         }
@@ -207,7 +209,8 @@ class BananaPost
      */
     function _fix_charset()
     {
-        if (preg_match('!charset="?([^;"]*)"?\s*(;|$)?!', $this->headers['content-type'], $matches)) {
+        if (isset($this->headers['content-type'])
+                && preg_match('!charset="?([^;"]*)"?\s*(;|$)?!', $this->headers['content-type'], $matches)) {
             $body = iconv($matches[1], 'utf-8', $this->body);
             if (strlen($body) == 0) {
                 return false;
@@ -468,8 +471,12 @@ class BananaPost
             $res .= '</th></tr>';
         }
  
-        preg_match("@text/([^;]+);@", $this->headers['content-type'], $format);
-        $format = $format[1];
+        if (isset($this->headers['content-type'])
+                && preg_match("@text/([^;]+);@", $this->headers['content-type'], $format)) {
+            $format = $format[1];
+        } else {
+            $format = 'plain';
+        }
         $res .= '<tr class="impair"><td colspan="2" class="body"';
         if ($format == 'html') {
             if (preg_match('@<body[^>]*bgcolor="?([#0-9a-f]+)"?[^>]*>@i', $this->body, $bgcolor)) {