fix for MIME troubles

Gaudenz Steinlin gaudenz.steinlin@id.unibe.ch
Mon, 8 Jan 2001 22:06:13 +0100


I first updated my cvs and then read the log for MIME.php, so I fixed things
myself.
I replaced every reference to Mime.php by MIME.php and every call to
mime_decode by MIME::decode.
Below is a patch, in case you have the same problems or you [chuk] don't
want to type it again.

-Gaudenz

Index: problem.php
===================================================================
RCS file: /cvs/horde/horde/problem.php,v
retrieving revision 2.51
diff -u -r2.51 problem.php
--- problem.php 2001/01/07 04:25:06 2.51
+++ problem.php 2001/01/08 20:54:28
@@ -23,7 +23,7 @@
 require_once './lib/Horde.php';
 require_once './lib/version.php';
 require_once './lib/Browser.php';
-require_once './lib/Mime.php';
+require_once './lib/MIME.php';
 $browser = new Browser();

 require './config/mime.php';
Index: imp/compose.php
===================================================================
RCS file: /cvs/horde/imp/compose.php,v
retrieving revision 2.245
diff -u -r2.245 compose.php
--- imp/compose.php 2001/01/08 00:33:46 2.245
+++ imp/compose.php 2001/01/08 20:54:29
@@ -201,7 +201,7 @@

 require_once './lib/base.php';
 require_once '../lib/Registry.php';
-require_once '../lib/Mime.php';
+require_once '../lib/MIME.php';
 require_once './lib/folder.php';
 require './config/mime.php';
 require './lib/mimetypes.php';
@@ -326,10 +326,10 @@

 case COMPOSE:
     if (isset($HTTP_GET_VARS['to'])) {
-        $to = mime_decode($HTTP_GET_VARS['to']);
+        $to = MIME::decode($HTTP_GET_VARS['to']);
     }
     if (isset($HTTP_GET_VARS['subject'])) {
-        $subject = mime_decode($HTTP_GET_VARS['subject']);
+        $subject = MIME::decode($HTTP_GET_VARS['subject']);
     }
     $ACTION_TEXT = _("Compose a message");
     break;
@@ -338,7 +338,7 @@
     if (!empty($HTTP_GET_VARS['index'])) {
         $h = @imap_header($imp['stream'], imap_msgno($imp['stream'],
$HTTP_GET_VARS['index']));
         if (isset($mailto) && isset($h->$mailto)) {
-            $to = mime_decode($h->$mailto);
+            $to = MIME::decode($h->$mailto);
         } else if (!empty($h->reply_to)) {
             $to = IMP::addrArray2String($h->reply_to);
         } else if (isset($h->from)) {
@@ -368,7 +368,7 @@
                 $reply_to = IMP::addrArray2String($h->reply_to);
             }
             if (isset($h->subject)) {
-                $subject = mime_decode($h->subject);
+                $subject = MIME::decode($h->subject);
             }
         }

@@ -421,10 +421,10 @@
         $msg  = _("Quoting") . ' ' . $qfrom . ":\n$quote_str$msg";
         $msg .= "\n";

-        if (isset($h->subject) &&
(strtolower(substr(mime_decode($h->subject), 0, 3)) != 're:')) {
-            $subject = 'Re: ' . mime_decode($h->subject);
+        if (isset($h->subject) &&
(strtolower(substr(MIME::decode($h->subject), 0, 3)) != 're:')) {
+            $subject = 'Re: ' . MIME::decode($h->subject);
         } else if (isset($h->subject)) {
-            $subject = mime_decode($h->subject);
+            $subject = MIME::decode($h->subject);
         } else {
             $subject = 'Re: ';
         }
@@ -492,10 +492,10 @@
         $msg  = _("Quoting") . ' ' . IMP::addrObject2String($h->from[0]) .
":\n$quote_str$msg";
         $msg .= "\n";

-        if (isset($h->subject) &&
strtolower(substr(mime_decode($h->subject), 0, 3)) != 're:') {
-            $subject = 'Re: ' . mime_decode($h->subject);
+        if (isset($h->subject) &&
strtolower(substr(MIME::decode($h->subject), 0, 3)) != 're:') {
+            $subject = 'Re: ' . MIME::decode($h->subject);
         } else if (isset($h->subject)) {
-            $subject = mime_decode($h->subject);
+            $subject = MIME::decode($h->subject);
         } else {
             $subject = '';
         }
@@ -521,7 +521,7 @@
         $msg .= " -----\n";

         if (isset($h->date) && $h->date) {
-            $msg .= _("    Date: ") . mime_decode($h->date);
+            $msg .= _("    Date: ") . MIME::decode($h->date);
             $msg .= "\n";
         }
         if (isset($h->from) && is_array($h->from)) {
@@ -533,7 +533,7 @@
             $msg .= "\n";
         }
         if (isset($h->subject) && $h->subject) {
-            $msg .= _(" Subject: ") . mime_decode($h->subject);
+            $msg .= _(" Subject: ") . MIME::decode($h->subject);
             $msg .= "\n";
         }
         if (isset($h->to) && is_array($h->to)) {
@@ -551,8 +551,8 @@
         }

         if (isset($h->subject)) {
-            $subject = _("Fwd:") . ' ' . mime_decode($h->subject);
-            $ACTION_TEXT = _("Forward:") . ' ' . mime_decode($h->subject);
+            $subject = _("Fwd:") . ' ' . MIME::decode($h->subject);
+            $ACTION_TEXT = _("Forward:") . ' ' . MIME::decode($h->subject);
         } else {
             $subject = _("Fwd:");
             $ACTION_TEXT = _("Forward");
Index: imp/mailbox.php
===================================================================
RCS file: /cvs/horde/imp/mailbox.php,v
retrieving revision 2.232
diff -u -r2.232 mailbox.php
--- imp/mailbox.php 2001/01/07 20:02:30 2.232
+++ imp/mailbox.php 2001/01/08 20:54:29
@@ -76,7 +76,7 @@

 require_once './lib/base.php';
 require_once './lib/message.php';
-require_once '../lib/Mime.php';
+require_once '../lib/MIME.php';
 require_once '../lib/Registry.php';
 require './config/mime.php';

@@ -507,7 +507,7 @@
             $fullfrom = '';

             if (isset($h->from[0]->personal)) {
-                $fullfrom = $frm = mime_decode($h->from[0]->personal);
+                $fullfrom = $frm = MIME::decode($h->from[0]->personal);
             }

             if (isset($h->from[0]->mailbox) && isset($h->from[0]->host)) {
@@ -519,7 +519,7 @@
         if (display_toaddress($imp['user'], $imp['server'], $fullfrom)) {
             if (isset($h->to[0])) {
                 if (isset($h->to[0]->personal)) {
-                    $to = mime_decode($h->to[0]->personal);
+                    $to = MIME::decode($h->to[0]->personal);
                 }
                 if (empty($to) && isset($h->to[0]->mailbox) &&
isset($h->to[0]->host)) {
                     $to = $h->to[0]->mailbox . '@' . $h->to[0]->host;
@@ -531,7 +531,7 @@
         }

         if (isset($h->subject)) {
-            $sub = mime_decode($h->subject);
+            $sub = MIME::decode($h->subject);
         }
         if (isset($h->Size)) {
             $msg_size = ($h->Size > 1024)
Index: imp/message.php
===================================================================
RCS file: /cvs/horde/imp/message.php,v
retrieving revision 2.186
diff -u -r2.186 message.php
--- imp/message.php 2001/01/08 00:33:47 2.186
+++ imp/message.php 2001/01/08 20:54:29
@@ -11,7 +11,7 @@

 require_once './lib/base.php';
 require_once './lib/mimetypes.php';
-require_once '../lib/Mime.php';
+require_once '../lib/MIME.php';
 require_once './lib/message.php';
 require_once '../lib/Registry.php';
 require './config/mime.php';
@@ -32,7 +32,7 @@
     while (list(,$ob) = each($array)) {

         /* Ensure we're working with initialized values. */
-        $ob->personal = isset($ob->personal) ? mime_decode($ob->personal) :
'';
+        $ob->personal = isset($ob->personal) ? MIME::decode($ob->personal)
: '';
         if (!isset($ob->mailbox)) $ob->mailbox = '';
         if (!isset($ob->host)) $ob->host = '';

@@ -316,7 +316,7 @@
 if (isset($h->reply_to)) $rep = buildAddressLinks($h->reply_to);

 if ((isset($h->subject)) && (strlen($h->subject) != 0)) {
-    $sub = htmlspecialchars(mime_decode($h->subject));
+    $sub = htmlspecialchars(MIME::decode($h->subject));

     /* filter the subject text, if requested */
     if ($prefs->getValue('filtering')) {
Index: imp/view.php
===================================================================
RCS file: /cvs/horde/imp/view.php,v
retrieving revision 2.81
diff -u -r2.81 view.php
--- imp/view.php 2001/01/08 00:33:47 2.81
+++ imp/view.php 2001/01/08 20:54:29
@@ -11,7 +11,7 @@

 require_once './lib/base.php';
 require_once './lib/mimetypes.php';
-require_once '../lib/Mime.php';
+require_once '../lib/MIME.php';
 require './config/mime.php';

 session_name($horde['session_name']);
@@ -51,7 +51,7 @@
       * according to a note in MSDN, the suggested filename should NOT
       * be in quotes. */
      header('Content-Type: application/x-unknown-' .
$mime_types[$mime->type] . '-' . $mime->subtype);
-     header('Content-Disposition: inline; filename=' .
mime_decode($mime->name));
+     header('Content-Disposition: inline; filename=' .
MIME::decode($mime->name));
      break;

  case VIEW_ATTACH:
@@ -64,14 +64,14 @@

      if (isset($mime->conf['view_function'])) {
          header('Content-Type: text/html');
-         header('Content-Disposition: inline; filename=' .
mime_decode($mime->name));
+         header('Content-Disposition: inline; filename=' .
MIME::decode($mime->name));
          $func = $mime->conf['view_function'];
          echo $func($mime);
          exit;
      }

      header('Content-Type: ' . $mime_types[$mime->type] . '/' .
$mime->subtype);
-     header('Content-Disposition: inline; filename=' .
mime_decode($mime->name));
+     header('Content-Disposition: inline; filename=' .
MIME::decode($mime->name));
      break;

  case VIEW_SOURCE:
@@ -86,7 +86,7 @@
      $h = imap_header($imp['stream'], imap_msgno($imp['stream'],
$HTTP_GET_VARS['index']));

      if (!empty($h->subject)) {
-         $name = preg_replace('|\W|', '_', mime_decode($h->subject));
+         $name = preg_replace('|\W|', '_', MIME::decode($h->subject));
      } else {
          $name = 'message';
      }
Index: imp/lib/IMP.php
===================================================================
RCS file: /cvs/horde/imp/lib/IMP.php,v
retrieving revision 1.116
diff -u -r1.116 IMP.php
--- imp/lib/IMP.php 2001/01/08 00:33:49 1.116
+++ imp/lib/IMP.php 2001/01/08 20:54:30
@@ -410,7 +410,7 @@
     function addrObject2String($ob, $filter = '')
     {
         /* If the personal name is set, decode it. */
-        $ob->personal = isset($ob->personal) ? mime_decode($ob->personal) :
'';
+        $ob->personal = isset($ob->personal) ? MIME::decode($ob->personal)
: '';

         /*
          * If both the mailbox and the host are empty, return an empty
@@ -672,9 +672,9 @@
             // name/text part column
             $row .= '<td>';
             if ($mime->conf['view'])
-                $row .= "<a href=\"javascript:view('" . VIEW_ATTACH . "',
'" . $mime->imap_id . "', '" . SessionCache::putObject($mime) . "');\">" .
htmlspecialchars(mime_decode($mime->description)) . '</a>';
+                $row .= "<a href=\"javascript:view('" . VIEW_ATTACH . "',
'" . $mime->imap_id . "', '" . SessionCache::putObject($mime) . "');\">" .
htmlspecialchars(MIME::decode($mime->description)) . '</a>';
             else
-                $row .= htmlspecialchars(mime_decode($mime->description));
+                $row .= htmlspecialchars(MIME::decode($mime->description));
             $row .= '</td>';

             // type column