steffen: server/kolab-horde-framework/kolab-horde-framework/MIME/MIME Contents.php, NONE, 1.1 Headers.php, NONE, 1.1 Magic.php, NONE, 1.1 Message.php, NONE, 1.1 Part.php, NONE, 1.1 Structure.php, NONE, 1.1 Viewer.php, NONE, 1.1 mime.magic.php, NONE, 1.1 mime.mapping.php, NONE, 1.1

cvs at intevation.de cvs at intevation.de
Fri Oct 14 16:33:09 CEST 2005


Author: steffen

Update of /kolabrepository/server/kolab-horde-framework/kolab-horde-framework/MIME/MIME
In directory doto:/tmp/cvs-serv28903/kolab-horde-framework/kolab-horde-framework/MIME/MIME

Added Files:
	Contents.php Headers.php Magic.php Message.php Part.php 
	Structure.php Viewer.php mime.magic.php mime.mapping.php 
Log Message:
Separated Horde Framework from kolab-resource-handlers

--- NEW FILE: Contents.php ---
<?php

require_once dirname(__FILE__) . '/Message.php';
require_once dirname(__FILE__) . '/Part.php';
require_once HORDE_BASE . '/config/mime_drivers.php';

/* @constant MIME_CONTENTS_CACHE The name of the URL parameter that holds the MIME_Contents cache identifier. */
define('MIME_CONTENTS_CACHE', 'mimecache');

/**
 * The MIME_Contents:: class contains functions related to handling
 * the output of MIME content.
 *
 * $Horde: framework/MIME/MIME/Contents.php,v 1.111 2004/05/28 08:57:21 jan Exp $
 *
 * Copyright 2002-2004 Michael Slusarz <slusarz at bigworm.colorado.edu>
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
[...1109 lines suppressed...]

        require_once 'Horde/SessionObjects.php';
        $cache = &Horde_SessionObjects::singleton();
        return $ret = &$cache->query($cacheid);
    }

    /**
     * Add the current object to the cache, and return the cache identifier
     * to be used in URLs.
     *
     * @access public
     *
     * @return array  The parameter key/value set to use in URLs.
     */
    function cacheIDURLParam()
    {
        return array(MIME_CONTENTS_CACHE => $this->_addCache());
    }

}

--- NEW FILE: Headers.php ---
<?php

require_once HORDE_BASE . '/lib/version.php';

/** @constant HORDE_AGENT_HEADER The description of Horde to use in the 'User-Agent:' header. */
define('HORDE_AGENT_HEADER', 'Horde Application Framework ' . HORDE_VERSION);

/**
 * The MIME_Headers:: class contains generic functions related to
 * handling the headers of mail messages.
 *
 * $Horde: framework/MIME/MIME/Headers.php,v 1.20 2004/04/14 16:59:33 slusarz Exp $
 *
 * Copyright 2002-2004 Michael Slusarz <slusarz at bigworm.colorado.edu>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  Michael Slusarz <slusarz at bigworm.colorado.edu>
 * @version $Revision: 1.1 $
 * @since   Horde 3.0
 * @package Horde_MIME
 */
class MIME_Headers {

    /**
     * The internal headers array.
     *
     * @var array $_headers
     */
    var $_headers = array();

    /**
     * Cached output of the MIME_Structure::parseMIMEHeaders() command.
     *
     * @var array $_allHeaders
     */
    var $_allHeaders;

    /**
     * Cached output of the imap_fetchheader() command.
     *
     * @var string $_headerText
     */
    var $_headerText;

    /**
     * The header object returned from imap_headerinfo().
     *
     * @var stdClass $_headerObject
     */
    var $_headerObject;

    /**
     * The internal flags array.
     *
     * @var array $_flags
     */
    var $_flags = array();

    /**
     * The User-Agent string to use.
     * THIS VALUE SHOULD BE OVERRIDEN BY ALL SUBCLASSES.
     *
     * @var string $_agent
     */
    var $_agent = HORDE_AGENT_HEADER;

    /**
     * The sequence to use as EOL for the headers.
     * The default is currently to output the EOL sequence internally as
     * just "\n" instead of the canonical "\r\n" required in RFC 822 & 2045.
     * To be RFC complaint, the full <CR><LF> EOL combination should be used
     * when sending a message.
     *
     * @var string $_eol
     */
    var $_eol = "\n";

    /**
     * The index of the message.
     *
     * @var integer $_index
     */
    var $_index;

    /**
     * Constructor.
     *
     * @access public
     *
     * @param optional integer $index  The message index to parse headers.
     */
    function MIME_Headers($index = null)
    {
        $this->_index = $index;
    }

    /**
     * Returns a reference to a currently open IMAP stream.
     * THIS VALUE SHOULD BE OVERRIDEN BY ALL SUBCLASSES.
     *
     * @return resource  An IMAP resource stream.
     */
    function &_getStream()
    {
        return false;
    }

    /**
     * Return the full list of headers from the imap_fetchheader() function.
     *
     * @access public
     *
     * @return string  See imap_fetchheader().
     */
    function getHeaderText()
    {
        if (!is_null($this->_index) && empty($this->_headerText)) {
            $this->_headerText = @imap_fetchheader($this->_getStream(), $this->_index, FT_UID);
        }

        return $this->_headerText;
    }

    /**
     * Return the full list of headers.
     *
     * @access public
     *
     * @param optional boolean $decode  Decode the headers?
     *
     * @return array  See MIME_Structure::parseMIMEHeaders().
     */
    function getAllHeaders($decode = true)
    {
        require_once 'Horde/MIME/Structure.php';

        if (!is_null($this->_index) && empty($this->_allHeaders)) {
            $this->_allHeaders = MIME_Structure::parseMIMEHeaders($this->getHeaderText(), $decode);
        }

        return $this->_allHeaders;
    }

    /**
     * Return the header object from imap_headerinfo().
     *
     * @access public
     *
     * @return object stdClass  See imap_headerinfo().
     */
    function getHeaderObject()
    {
        if (!is_null($this->_index) && empty($this->_headerObject)) {
            $stream = &$this->_getStream();
            $this->_headerObject = @imap_headerinfo($stream, @imap_msgno($stream, $this->_index));
        }

        return $this->_headerObject;
    }

    /**
     * Build the header array. The headers are MIME decoded.
     *
     * @access public
     */
    function buildHeaders()
    {
        if (!empty($this->_headers)) {
            return;
        }

        /* Parse through the list of all headers. */
        foreach ($this->getAllHeaders() as $key => $val) {
            $this->addHeader($key, $val);
        }
    }

    /**
     * Build the flags array.
     *
     * @access public
     */
    function buildFlags()
    {
        if (!empty($this->_flags)) {
            return;
        }

        /* Get the IMAP header object. */
        $ob = $this->getHeaderObject();
        if (!isset($ob)) {
            return;
        }

        /* Unseen flag */
        if (($ob->Unseen == 'U') || ($ob->Recent == 'N')) {
            $this->_flags['unseen'] = true;
        }

        /* Recent flag */
        if (($ob->Recent == 'N') || ($ob->Recent == 'R')) {
            $this->_flags['recent'] = true;
        }

        /* Answered flag */
        if ($ob->Answered == 'A') {
            $this->_flags['answered'] = true;
        }

        /* Draft flag */
        if (isset($ob->Draft) && ($ob->Draft == 'X')) {
            $this->_flags['draft'] = true;
        }

        /* Important flag */
        if ($ob->Flagged == 'F') {
            $this->_flags['important'] = true;
        }

        /* Deleted flag */
        if ($ob->Deleted == 'D') {
            $this->_flags['deleted'] = true;
        }
    }

    /**
     * Returns the internal header array in array format.
     *
     * @access public
     *
     * @return array  The headers in array format.
     */
    function toArray()
    {
        $return_array = array();

        foreach ($this->_headers as $ob) {
            $eol = $this->getEOL();
            $header = $ob['header'];
            if (is_array($ob['value'])) {
                require_once dirname(__FILE__) . '/../MIME.php';
                $return_array[$header] = MIME::wrapHeaders($header, reset($ob['value']));
                next($ob['value']);
                while (list(,$val) = each($ob['value'])) {
                    $return_array[$header] .= $eol . $header . ': ' . MIME::wrapHeaders($header, $val, $eol);
                }
            } else {
                $return_array[$header] = $ob['value'];
            }
        }

        return $return_array;
    }

    /**
     * Returns the internal header array in string format.
     *
     * @access public
     *
     * @return string  The headers in string format.
     */
    function toString()
    {
        $eol = $this->getEOL();
        $text = '';

        foreach ($this->_headers as $ob) {
            if (!is_array($ob['value'])) {
                $ob['value'] = array($ob['value']);
            }
            foreach ($ob['value'] as $entry) {
                $text .= $ob['header'] . ': ' . $entry . $eol;
            }
        }

        return $text . $eol;
    }

    /**
     * Generate the 'Received' header for the Web browser->Horde hop
     * (attempts to conform to guidelines in RFC 2821).
     *
     * @access public
     */
    function addReceivedHeader()
    {
        if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            /* This indicates the user is connecting through a proxy. */
            $remote_path = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
            $remote_addr = $remote_path[0];
            $remote = gethostbyaddr($remote_addr);
        } else {
            $remote_addr = $_SERVER['REMOTE_ADDR'];
            if (empty($_SERVER['REMOTE_HOST'])) {
                $remote = gethostbyaddr($remote_addr);
            } else {
                $remote = $_SERVER['REMOTE_HOST'];
            }
        }
        $received = 'from ' . $remote . ' (';

        if (!empty($_SERVER['REMOTE_IDENT'])) {
            $received .= $_SERVER['REMOTE_IDENT'] . '@' . $remote . ' ';
        } elseif ($remote != $_SERVER['REMOTE_ADDR']) {
            $received .= $remote . ' ';
        }
        $received .= '[' . $remote_addr . ']) ';
        $received .= 'by ' . $GLOBALS['conf']['server']['name'] . ' (Horde) with HTTP ';

        $user = Auth::getAuth();
        if (strpos($user, '@') === false) {
            $user .= '@' . $GLOBALS['conf']['server']['name'];
        }
        $received .= 'for <' . $user . '>; ' . date('r');

        $this->addHeader('Received', $received);
    }

    /**
     * Generate the 'Message-ID' header.
     *
     * @access public
     */
    function addMessageIdHeader()
    {
        require_once dirname(__FILE__) . '/../MIME.php';
        $this->addHeader('Message-ID', MIME::generateMessageID());
    }

    /**
     * Generate the 'Resent' headers (conforms to guidelines in
     * RFC 2822 [3.6.6]).
     *
     * @access public
     *
     * @param string $from  The address to use for 'Resent-From'.
     * @param string $to    The address to use for 'Resent-To'.
     */
    function addResentHeaders($from, $to)
    {
        require_once dirname(__FILE__) . '/../MIME.php';

        /* We don't set Resent-Sender, Resent-Cc, or Resent-Bcc. */
        $this->addHeader('Resent-Date', date('r'));
        $this->addHeader('Resent-From', $from);
        $this->addHeader('Resent-To', $to);
        $this->addHeader('Resent-Message-ID', MIME::generateMessageID());
    }

    /**
     * Generate read receipt headers.
     *
     * @access public
     *
     * @param string $to  The address the receipt should be mailed to.
     */
    function addReadReceiptHeaders($to)
    {
        /* This is the RFC 2298 way of requesting a receipt. */
        $this->addHeader('Disposition-Notification-To', $to);

        /* For certain Pegasus mail installations. */
        $this->addHeader('X-Confirm-Reading-To', $to);
        $this->addHeader('X-PMRQC', 1);
    }

    /**
     * Generate delivery receipt headers.
     *
     * @access public
     *
     * @param string $to  The address the receipt should be mailed to.
     */
    function addDeliveryReceiptHeaders($to)
    {
        /* This is old sendmail (pre-8.7) behavior. */
        $this->addHeader('Return-Receipt-To', $to);
    }

    /**
     * Generate the user agent description header.
     *
     * @access public
     */
    function addAgentHeader()
    {
        $this->addHeader('User-Agent', $this->_agent);
    }

    /**
     * Add a header to the header array.
     *
     * @access public
     *
     * @param string $header  The header name.
     * @param string $value   The header value.
     */
    function addHeader($header, $value)
    {
        $header = trim($header);
        $lcHeader = String::lower($header);

        if (!isset($this->_headers[$lcHeader])) {
            $this->_headers[$lcHeader] = array();
        }
        $this->_headers[$lcHeader]['header'] = $header;
        $this->_headers[$lcHeader]['value'] = $value;
        $this->_headers[$lcHeader]['_alter'] = false;
    }

    /**
     * Remove a header from the header array.
     *
     * @access public
     *
     * @param string $header  The header name.
     */
    function removeHeader($header)
    {
        $header = trim($header);
        $lcHeader = String::lower($header);
        unset($this->_headers[$lcHeader]);
    }

    /**
     * Set a value for a particular header ONLY if that header is set.
     *
     * @access public
     *
     * @param string $header  The header name.
     * @param string $value   The original header value.
     *
     * @return boolean  True if string was set, false if not.
     */
    function setString($header, $value)
    {
        $header = trim($header);
        $lcHeader = String::lower($header);
        if (isset($this->_headers[$lcHeader])) {
            $this->_headers[$lcHeader]['header'] = $value;
            $this->_headers[$lcHeader]['_alter'] = true;
            return true;
        } else {
            return false;
        }
    }

    /**
     * Set a value for a particular header ONLY if that header is set.
     *
     * @access public
     *
     * @param string $header  The header name.
     * @param string $value   The header value.
     *
     * @return boolean  True if value was set, false if not.
     */
    function setValue($header, $value)
    {
        $lcHeader = String::lower($header);
        if (isset($this->_headers[$lcHeader])) {
            $this->_headers[$lcHeader]['value'] = $value;
            $this->_headers[$lcHeader]['_alter'] = true;
            return true;
        } else {
            return false;
        }
    }

    /**
     * Attempts to return the header in the correct case.
     *
     * @access public
     *
     * @param string $header  The header to search for.
     *
     * @return string  The value for the given header.
     *                 If the header is not found, returns null.
     */
    function getString($header)
    {
        $lcHeader = String::lower($header);
        return (isset($this->_headers[$lcHeader])) ? $this->_headers[$lcHeader]['header'] : null;
    }

    /**
     * Attempt to return the value for a given header.
     * The following header fields can only have 1 entry, so if duplicate
     * entries exist, the first value will be used (RFC 2822 [3.6]):
     *   To, From, Cc, Bcc, Date, Sender, Reply-to, Message-ID, In-Reply-To,
     *   References, Subject
     *
     * @access public
     *
     * @param string $header  The header to search for.
     *
     * @return mixed  The value for the given header.
     *                If the header is not found, returns null.
     */
    function getValue($header)
    {
        $header = String::lower($header);

        if (isset($this->_headers[$header])) {
            $single = array('to', 'from', 'cc', 'bcc', 'date', 'sender', 
                            'reply-to', 'message-id', 'in-reply-to',
                            'references', 'subject', 'x-priority');
            if (is_array($this->_headers[$header]['value']) &&
                in_array($header, $single)) {
                return $this->_headers[$header]['value'][0];
            } else {
                return $this->_headers[$header]['value'];
            }
        } else {
            return null;
        }
    }

    /**
     * Has the header been altered from the original?
     *
     * @access public
     *
     * @param string $header  The header to analyze.
     *
     * @return boolean  True if the header has been altered.
     */
    function alteredHeader($header)
    {
        $lcHeader = String::lower($header);
        return (isset($this->_headers[$lcHeader])) ? $this->_headers[$lcHeader]['_alter'] : false;
    }

    /**
     * Transforms a Header value using the list of functions provided.
     *
     * @access public
     *
     * @param string $header  The header to alter.
     * @param mixed $funcs    A function, or an array of functions.
     *                        The functions will be performed from right to
     *                        left.
     */
    function setValueByFunction($header, $funcs)
    {
        $header = String::lower($header);

        if (is_array($funcs)) {
            $funcs = array_reverse($funcs);
        } else {
            $funcs = array($funcs);
        }

        if (isset($this->_headers[$header])) {
            $val = $this->getValue($header);
            if (is_array($val)) {
                $val = implode("\n", $val);
            }
            foreach ($funcs as $func) {
                $val = call_user_func($func, $val);
            }
            $this->setValue($header, $val);
        }
    }

    /**
     * Add any MIME headers required for the MIME_Part.
     *
     * @access public
     *
     * @param object MIME_Part &$mime_part  The MIME_Part object.
     */
    function addMIMEHeaders(&$mime_part)
    {
        foreach ($mime_part->header(array()) as $head => $val) {
            $this->addHeader($head, $val);
        }
    }

    /**
     * Return the list of addresses for a header object.
     *
     * @access public
     *
     * @param array $obs  An array of header objects (See imap_headerinfo()
     *                    for the object structure).
     *
     * @return array  An array of objects.
     * <pre>
     * Object elements:
     * 'address'   -  Full address
     * 'host'      -  Host name
     * 'inner'     -  Trimmed, bare address
     * 'personal'  -  Personal string
     * </pre>
     */
    function getAddressesFromObject($obs)
    {
        $retArray = array();

        if (!is_array($obs) || empty($obs)) {
            return $retArray;
        }

        foreach ($obs as $ob) {
            /* Ensure we're working with initialized values. */
            $ob->personal = isset($ob->personal) ? trim(MIME::decode($ob->personal), '"') : '';

            if (isset($ob->mailbox)) {
                /* Don't process invalid addresses. */
                if (strstr($ob->mailbox, 'UNEXPECTED_DATA_AFTER_ADDRESS') ||
                    strstr($ob->mailbox, 'INVALID_ADDRESS')) {
                    continue;
                }
            } else {
                $ob->mailbox = '';
            }

            if (!isset($ob->host)) {
                $ob->host = '';
            }

            /* Generate the new object. */
            $newOb = &new stdClass;
            $newOb->address = MIME::addrObject2String($ob, array('undisclosed-recipients@', 'Undisclosed recipients@'));
            $newOb->host = $ob->host;
            $newOb->inner = MIME::trimEmailAddress(MIME::rfc822WriteAddress($ob->mailbox, $ob->host, ''));
            $newOb->personal = $ob->personal;

            $retArray[] = &$newOb;
        }

        return $retArray;
    }

    /**
     * Returns the list of valid mailing list headers.
     *
     * @access public
     *
     * @return array  The list of valid mailing list headers.
     */
    function listHeaders()
    {
        return array(
            /* RFC 2369 */
            'list-help'         =>  _("List-Help"),
            'list-unsubscribe'  =>  _("List-Unsubscribe"),
            'list-subscribe'    =>  _("List-Subscribe"),
            'list-owner'        =>  _("List-Owner"),
            'list-post'         =>  _("List-Post"),
            'list-archive'      =>  _("List-Archive"),
            /* RFC 2919 */
            'list-id'           =>  _("List-Id")
        );
    }

    /**
     * Do any mailing list headers exist?
     *
     * @access public
     *
     * @return boolean  True if any mailing list headers exist.
     */
    function listHeadersExist()
    {
        foreach ($this->listHeaders() as $val => $str) {
            if (isset($this->_headers[$val])) {
                return true;
            }
        }

        return false;
    }

    /**
     * Sets a new string to use for EOLs.
     *
     * @access public
     *
     * @param string $eol  The string to use for EOLs.
     */
    function setEOL($eol)
    {
        $this->_eol = $eol;
    }

    /**
     * Get the string to use for EOLs.
     *
     * @access public
     *
     * @return string  The string to use for EOLs.
     */
    function getEOL()
    {
        return $this->_eol;
    }

    /**
     * Returns the flag status.
     *
     * @access public
     *
     * @param string $flag  Is this flag set?
     *                      Flags: recent, unseen, answered, draft, important,
     *                             deleted
     *
     * @return boolean  True if the flag has been set, false if not.
     */
    function getFlag($flag)
    {
        if (!empty($this->_flags[String::lower($flag)])) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * Get the primary from address (first address in the From: header).
     *
     * @access public
     *
     * @return string  The from address (user at host).
     */
    function getFromAddress()
    {
        if (!($ob = $this->getOb('from'))) {
            return null;
        }

        require_once 'Horde/MIME.php';

        return trim(MIME::trimEmailAddress(MIME::rfc822WriteAddress($ob[0]->mailbox, (isset($ob[0]->host)) ? $ob[0]->host : '', '')));
    }

    /**
     * Get a header from the header object.
     *
     * @access public
     *
     * @param string $field    The object field to retrieve (see
     *                         imap_headerinfo() for the list of fields).
     * @param boolean $decode  Should the return value be MIME decoded?
     *                         It will only be decoded if it is not an object
     *                         itself.
     *
     * @return mixed  The field requested.
     */
    function getOb($field, $decode = false)
    {
        $data = array();

        $ob = $this->getHeaderObject();
        if (!is_object($ob)) {
            return $data;
        }

        if (isset($ob->$field)) {
            $data = $ob->$field;
            if (!empty($decode) && !is_object($data) && !is_array($data)) {
                include_once 'Horde/MIME.php';
                $data = MIME::decode($data);
            }
        }

        return (is_string($data)) ? strtr($data, "\t", " ") : $data;
    }

}

--- NEW FILE: Magic.php ---
<?php
/**
 * The MIME_Magic:: class provides an interface to determine a
 * MIME type for various content, if it provided with different
 * levels of information.
 *
 * $Horde: framework/MIME/MIME/Magic.php,v 1.49 2004/05/24 22:38:25 jan Exp $
 *
 * Copyright 1999-2004 Anil Madhavapeddy <anil at recoil.org>
 * Copyright 2002-2004 Michael Slusarz <slusarz at bigworm.colorado.edu>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  Anil Madhavapeddy <anil at recoil.org>
 * @author  Michael Slusarz <slusarz at bigworm.colorado.edu>
 * @version $Revision: 1.1 $
 * @since   Horde 1.3
 * @package Horde_MIME
 */
class MIME_Magic {

    /**
     * Returns a copy of the MIME extension map.
     *
     * @access private
     *
     * @return array  The MIME extension map.
     */
    function &_getMimeExtensionMap()
    {
        static $mime_extension_map;

        if (!isset($mime_extension_map)) {
            require dirname(__FILE__) . '/mime.mapping.php';
        }

        return $mime_extension_map;
    }

    /**
     * Returns a copy of the MIME magic file.
     *
     * @access private
     *
     * @return array  The MIME magic file.
     */
    function &_getMimeMagicFile()
    {
        static $mime_magic;

        if (!isset($mime_magic)) {
            require dirname(__FILE__) . '/mime.magic.php';
        }

        return $mime_magic;
    }

    /**
     * Attempt to convert a file extension to a MIME type, based
     * on the global Horde and application specific config files.
     *
     * If we cannot map the file extension to a specific type, then
     * we fall back to a custom MIME handler 'x-extension/$ext', which
     * can be used as a normal MIME type internally throughout Horde.
     *
     * @access public
     *
     * @param string $ext  The file extension to be mapped to a MIME type.
     *
     * @return string  The MIME type of the file extension.
     */
    function extToMIME($ext)
    {
        if (empty($ext)) {
           return 'text/plain';
        } else {
            $ext = String::lower($ext);
            $map = &MIME_Magic::_getMimeExtensionMap();
            $pos = 0;
            while (!isset($map[$ext]) && $pos !== false) {
                $pos = strpos($ext, '.');
                if ($pos !== false) {
                    $ext = substr($ext, $pos + 1);
                }
            }

            if (isset($map[$ext])) {
                return $map[$ext];
            } else {
                return 'x-extension/' . $ext;
            }
        }
    }

    /**
     * Attempt to convert a filename to a MIME type, based on the
     * global Horde and application specific config files.
     *
     * @access public
     *
     * @param string $filename           The filename to be mapped to a MIME
     *                                   type.
     * @param optional boolean $unknown  How should unknown extensions be
     *                                   handled?  If true, will return
     *                                   'x-extension/*' types.  If false,
     *                                   will return
     *                                   'application/octet-stream'.
     *
     * @return string  The MIME type of the filename.
     */
    function filenameToMIME($filename, $unknown = true)
    {
        $pos = strlen($filename) + 1;
        $type = '';

        $map = &MIME_Magic::_getMimeExtensionMap();
        for ($i = 0;
             $i <= $map['__MAXPERIOD__'] &&
                 strrpos(substr($filename, 0, $pos - 1), '.') !== false;
             $i++) {
            $pos = strrpos(substr($filename, 0, $pos - 1), '.') + 1;
        }
        $type = MIME_Magic::extToMIME(substr($filename, $pos));

        if (empty($type) ||
            (!$unknown && (strpos($type, 'x-extension') !== false))) {
            return 'application/octet-stream';
        } else {
            return $type;
        }
    }

    /**
     * Attempt to convert a MIME type to a file extension, based
     * on the global Horde and application specific config files.
     *
     * If we cannot map the type to a file extension, we return false.
     *
     * @access public
     *
     * @param string $type  The MIME type to be mapped to a file extension.
     *
     * @return string  The file extension of the MIME type.
     */
    function MIMEToExt($type)
    {
        $key = array_search($type, MIME_Magic::_getMimeExtensionMap());
        if (empty($type) || ($key === false)) {
            list($major, $minor) = explode('/', $type);
            if ($major == 'x-extension') {
                return $minor;
            }
            if (strpos($minor, 'x-') === 0) {
                return substr($minor, 2);
            }
            return false;
        } else {
            return $key;
        }
    }

    /**
     * Uses variants of the UNIX "file" command to attempt to determine the
     * MIME type of an unknown file.
     *
     * @access public
     *
     * @param string $path  The path to the file to analyze.
     *
     * @return string  The MIME type of the file.  Returns false if either
     *                 the file type isn't recognized or the file command is
     *                 not available.
     */
    function analyzeFile($path)
    {
        /* If the PHP Mimetype extension is available, use that. */
        if (Util::extensionExists('fileinfo')) {
            $res = finfo_open(FILEINFO_MIME);
            $type = finfo_file($res, $path);
            finfo_close($res);
            return $type;
        } else {
            /* Use a built-in magic file. */
            $mime_magic = &MIME_Magic::_getMimeMagicFile();
            if (!($fp = @fopen($path, 'rb'))) {
                return false;
            }
            foreach ($mime_magic as $offset => $odata) {
                foreach ($odata as $length => $ldata) {
                    @fseek($fp, $offset, SEEK_SET);
                    $lookup = @fread($fp, $length);
                    if (!empty($ldata[$lookup])) {
                        fclose($fp);
                        return $ldata[$lookup];
                    }
                }
            }
            fclose($fp);
        }

        return false;
    }


    /**
     * Uses variants of the UNIX "file" command to attempt to determine the
     * MIME type of an unknown byte stream.
     *
     * @access public
     *
     * @param string $data  The file data to analyze.
     *
     * @return string  The MIME type of the file.  Returns false if either
     *                 the file type isn't recognized or the file command is
     *                 not available.
     */
    function analyzeData($data)
    {
        /* Use a built-in magic file. */
        $mime_magic = &MIME_Magic::_getMimeMagicFile();
        foreach ($mime_magic as $offset => $odata) {
            foreach ($odata as $length => $ldata) {
                $lookup = substr($data, $offset, $length);
                if (!empty($ldata[$lookup])) {
                    return $ldata[$lookup];
                }
            }
        }

        return false;
    }

}

--- NEW FILE: Message.php ---
<?php

require_once dirname(__FILE__) . '/Part.php';

/**
 * The MIME_Message:: class provides methods for creating and manipulating
 * MIME email messages.
 *
 * $Horde: framework/MIME/MIME/Message.php,v 1.76 2004/04/16 21:00:42 jan Exp $
 *
 * Copyright 1999-2004 Chuck Hagenbuch <chuck at horde.org>
 * Copyright 2002-2004 Michael Slusarz <slusarz at bigworm.colorado.edu>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  Chuck Hagenbuch <chuck at horde.org>
 * @author  Michael Slusarz <slusarz at bigworm.colorado.edu>
 * @version $Revision: 1.1 $
 * @since   Horde 1.3
 * @package Horde_MIME
 */
class MIME_Message extends MIME_Part {

    /**
     * Has the message been parsed via buildMessage()?
     *
     * @var boolean $_build
     */
    var $_build = false;

    /**
     * The server to default unqualified addresses to.
     *
     * @var string $_defaultServer
     */
    var $_defaultServer = null;

    /**
     * Constructor - creates a new MIME email message.
     *
     * @access public
     *
     * @param optional string $defaultServer  The server to default
     *                                        unqualified addresses to.
     */
    function MIME_Message($defaultServer = null)
    {
        if (is_null($defaultServer)) {
            $this->_defaultServer = $_SERVER['SERVER_NAME'];
        } else {
            $this->_defaultServer = $defaultServer;
        }
    }

    /**
     * Create a MIME_Message object from a MIME_Part object.
     * This function can be called statically via:
     *    MIME_Message::convertMIMEPart();
     *
     * @access public
     *
     * @param object MIME_Part &$mime_part  The MIME_Part object.
     * @param optional string $server       The server to default unqualified
     *                                      addresses to.
     *
     * @return object MIME_Message  The new MIME_Message object.
     */
    function &convertMIMEPart(&$mime_part, $server = null)
    {
        if (!$mime_part->getMIMEId()) {
            $mime_part->setMIMEId(1);
        }

        $mime_message = &new MIME_Message($server);
        $mime_message->addPart($mime_part);
        $mime_message->buildMessage();

        return $mime_message;
    }

    /**
     * Send a message.
     *
     * @access public
     *
     * @param string  $email      The address list to send to.
     * @param mixed  &$headers    The MIME_Headers object holding
     *                            this message's headers, *or* a hash
     *                            with header->value mappings.
     *
     * @return mixed  True on success, PEAR_Error object on error.
     */
    function send($email, &$headers)
    {
        global $conf;
        static $mailer;

        if (!isset($mailer)) {
            require_once 'Mail.php';
            $mailer = &Mail::factory($conf['mailer']['type'], $conf['mailer']['params']);
        }

        $msg = $this->toString();
        if (is_object($headers)) {
            $headerArray = $this->encode($headers->toArray(), $this->getCharset());
        } else {
            $headerArray = $this->encode($headers, $this->getCharset());
        }

        /* Make sure the message has a trailing newline. */
        if (substr($msg, -1) != "\n") {
            $msg .= "\n";
        }

        return $mailer->send(MIME::encodeAddress($email), $headerArray, $msg);
    }

    /**
     * Take a set of headers and make sure they are encoded properly.
     *
     * @access public
     *
     * @param array $headers   The headers to encode.
     * @param string $charset  The character set to use.
     *
     * @return array  The array of encoded headers.
     */
    function encode($headers, $charset)
    {
        require_once 'Horde/MIME.php';

        $addressKeys = array('To', 'Cc', 'Bcc', 'From');
        foreach ($headers as $key => $val) {
            if (in_array($key, $addressKeys)) {
                $text = MIME::encodeAddress($val, $charset, $this->_defaultServer);
            } else {
                $text = MIME::encode($val, $charset);
            }
            $headers[$key] = MIME::wrapHeaders($key, $text, $this->getEOL());
        }

        return $headers;
    }

    /**
     * Add the proper set of MIME headers for this message to an array.
     *
     * @access public
     *
     * @param optional array $headers  The headers to add the MIME headers to.
     *
     * @return array  The full set of headers including MIME headers.
     */
    function header($headers = array())
    {
        /* Per RFC 2045 [4], this MUST appear in the message headers. */
        $headers['MIME-Version'] = '1.0';

        if ($this->_build) {
            return parent::header($headers);
        } else {
            $this->buildMessage();
            return $this->encode($this->header($headers), $this->getCharset());
        } 
    }

    /**
     * Return the entire message contents, including headers, as a string.
     *
     * @access public
     *
     * @return string  The encoded, generated message.
     */
    function toString()
    {
        if ($this->_build) {
            return parent::toString(false);
        } else {
            $this->buildMessage();
            return $this->toString();
        }
    }

    /**
     * Build message from current contents.
     *
     * @access public
     */
    function buildMessage()
    {
        if ($this->_build) {
            return;
        }

        if (empty($this->_flags['setType'])) {
            if (count($this->_parts) > 1) {
                $this->setType('multipart/mixed');
            } else {
                /* Copy the information from the single part to the current
                   base part. */
                if (($obVars = get_object_vars(reset($this->_parts)))) {
                    foreach ($obVars as $key => $val) {
                        $this->$key = $val;
                    }
                }
            }
        }

        /* Set the build flag now. */
        $this->_build = true;
    }

    /**
     * Get a list of all MIME subparts.
     *
     * @access public
     *
     * @return array  An array of the MIME_Part subparts.
     */
    function getParts()
    {
        if ($this->_build) {
            return parent::getParts();
        } else {
            $this->buildMessage();
            return $this->getParts();
        }
    }

    /**
     * Return the base part of the message. This function does NOT
     * return a reference to make sure that the whole MIME_Message
     * object isn't accidentally modified.
     *
     * @access public
     *
     * @return object MIME_Message  The base MIME_Part of the message.
     */
    function getBasePart()
    {
        $this->buildMessage();
        return $this;
    }

    /**
     * Retrieve a specific MIME part.
     *
     * @access public
     *
     * @param string $id  The MIME_Part ID string.
     *
     * @return object MIME_Part  The MIME_Part requested.  Returns false if
     *                           the part doesn't exist.
     */
    function getPart($id)
    {
        if ($this->_build) {
            return parent::getPart($id);
        } else {
            $this->buildMessage();
            return $this->getPart($id);
        }
    }

}

--- NEW FILE: Part.php ---
<?php

require_once 'Horde/String.php';
require_once dirname(__FILE__) . '/../MIME.php';

/** @constant MIME_PART_EOL The character(s) used internally for EOLs. */
define('MIME_PART_EOL', "\n");

/** @constant MIME_PART_RFC_EOL The character string designated by RFCs 822/2045 to designate EOLs in MIME messages. */
define('MIME_PART_RFC_EOL', "\r\n");

/* Default MIME parameters. */
/** @constant MIME_DEFAULT_CHARSET The default MIME character set. */
define('MIME_DEFAULT_CHARSET', 'us-ascii');

/** @constant MIME_DEFAULT_DESCRIPTION The default MIME description. */
define('MIME_DEFAULT_DESCRIPTION', _("unnamed"));

/** @constant MIME_DEFAULT_DISPOSITION The default MIME disposition. */
[...1467 lines suppressed...]
        }
        return $map;
    }

    /**
     * Generate the unique boundary string (if not already done).
     *
     * @access private
     *
     * @return string  The boundary string.
     */
    function _generateBoundary()
    {
        if (is_null($this->_boundary)) {
            $this->_boundary = '=_' . base_convert(microtime(), 10, 36);
        }
        return $this->_boundary;
    }

}

--- NEW FILE: Structure.php ---
<?php

require_once dirname(__FILE__) . '/Message.php';
require_once dirname(__FILE__) . '/Part.php';
require_once dirname(__FILE__) . '/../MIME.php';

/**
 * $Horde: framework/MIME/MIME/Structure.php,v 1.87 2004/05/18 09:17:18 jan Exp $
 *
 * The MIME_Structure:: class provides methods for dealing with MIME mail.
 *
 * Copyright 1999-2004 Chuck Hagenbuch <chuck at horde.org>
 * Copyright 2002-2004 Michael Slusarz <slusarz at bigworm.colorado.edu>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  Chuck Hagenbuch <chuck at horde.org>
 * @author  Michael Slusarz <slusarz at bigworm.colorado.edu>
 * @version $Revision: 1.1 $
 * @since   Horde 1.3
 * @package Horde_MIME
 */
class MIME_Structure {

    /**
     * Given the results of imap_fetchstructure(), parse the structure
     * of the message, figuring out correct bodypart numbers, etc.
     *
     * @access public
     *
     * @param object stdClass $body  The result of imap_fetchstructure().
     *
     * @return object &MIME_Message  The message parsed into a MIME_Message
     *                               object.
     */
    function &parse($body)
    {
        $msgOb = &new MIME_Message();
        $msgOb->addPart(MIME_Structure::_parse($body));
        $msgOb->buildMessage();

        $ptr = array(&$msgOb);
        MIME_Structure::_addMultipartInfo($ptr);

        return $msgOb;
    }

    /**
     * Given the results of imap_fetchstructure(), parse the structure
     * of the message, figuring out correct bodypart numbers, etc.
     *
     * @access private
     *
     * @param object stdClass $body    The result of imap_fetchstructure().
     * @param optional string $ref     The current bodypart.
     *
     * @return object MIME_Part  A MIME_Part object.
     */
    function &_parse($body, $ref = null)
    {
        static $message, $multipart;

        if (!isset($message)) {
            $message = MIME::type('message');
            $multipart = MIME::type('multipart');
        }

        $mime_part = &new MIME_Part();

        /* Top multiparts don't get their own line. */
        if (is_null($ref) &&
            (!isset($body->type) || ($body->type != $multipart))) {
            $ref = 1;
        }

        MIME_Structure::_setInfo($body, $mime_part, $ref);

        /* Deal with multipart headers. */
        if (is_null($ref)) {
            $mime_part->setMIMEId(0);
        } elseif ($body->subtype == 'RFC822') {
            $mime_part->setMIMEId($ref . '.0');
        } elseif ((($body->subtype != 'MIXED') &&
                   ($body->subtype != 'ALTERNATIVE')) ||
                  ($body->type == $multipart)) {
            $mime_part->setMIMEId($ref);
        }

        /* Deal with multipart data. */
        if (isset($body->parts)) {
            $sub_id = 1;
            foreach ($body->parts as $sub_part) {
                /* Are we dealing with a multipart message? */
                if (isset($body->type) && ($body->type == $message) &&
                    isset($sub_part->type) && ($sub_part->type == $multipart)) {
                    $sub_ref = $ref;
                } else {
                    $sub_ref = (is_null($ref)) ? $sub_id : $ref . '.' . $sub_id;
                }
                $mime_part->addPart(MIME_Structure::_parse($sub_part, $sub_ref), $sub_id++);
            }
        }

        return $mime_part;
    }

    /**
     * Given a mime part from imap_fetchstructure(), munge it into a
     * useful form and make sure that any parameters which are missing
     * are given default values.
     *
     * @access private
     *
     * @param object stdClass $part   The original part info.
     * @param object MIME_Part &$ob   A MIME_Part object.
     * @param string $ref             The ID of this part.
     */
    function _setInfo($part, &$ob, $ref)
    {
        /* Store Content-type information. */
        $primary_type = (isset($part->type)) ? $part->type : MIME::type('text');
        $sec_type = ($part->ifsubtype && $part->subtype) ? String::lower($part->subtype) : 'x-unknown';
        $ob->setType($primary_type . '/' . $sec_type);

        /* Set transfer encoding. */
        if (isset($part->encoding)) {
            $encoding = $part->encoding;
            $ob->setTransferEncoding($encoding);
        } else {
            $encoding = null;
        }

        /* Set transfer disposition. */
        $ob->setDisposition(($part->ifdisposition) ? String::lower($part->disposition) : MIME_DEFAULT_DISPOSITION);

        /* If 'body' is set, set as the contents of the part. */
        if (isset($part->body)) {
            $ob->setContents($part->body, $encoding);
        }

        /* If 'bytes' is set, store as information variable. */
        if (isset($part->bytes)) {
            $ob->setBytes($part->bytes);
        }

        /* Set the part's identification string, if available. */
        if (!is_null($ref) && $part->ifid) {
            $ob->setInformation('id', $part->id);
        } else {
            $ob->setInformation('id', false);
        }

        /* Set the default character set. */
        $ob->setCharset(MIME_DEFAULT_CHARSET);

        /* Go through the content-type parameters, if any. */
        foreach (MIME_Structure::_getParameters($part, 1) as $key => $val) {
            if ($key == 'charset') {
                $ob->setCharset($val);
            } else {
                $ob->setContentTypeParameter($key, $val);
            }
        }

        /* Go through the disposition parameters, if any. */
        foreach (MIME_Structure::_getParameters($part, 2) as $key => $val) {
            $ob->setDispositionParameter($key, $val);
        }

        /* Set the name. */
        if ($ob->getContentTypeParameter('filename')) {
            $ob->setName($ob->getContentTypeParameter('filename'));
        } elseif ($ob->getDispositionParameter('filename')) {
            $ob->setName($ob->getDispositionParameter('filename'));
        }

        /* Set the description. */
        if (isset($part->description)) {
            $ob->setDescription($part->description);
        }
    }

    /**
     * Get all parameters for a given portion of a message.
     *
     * @access private
     *
     * @param object stdClass $part  The original part info.
     * @param integer $type          The parameter type to retrieve.
     *                               1 = content
     *                               2 = disposition
     *
     * @return array  An array of parameter key/value pairs.
     */
    function _getParameters($part, $type)
    {
        $param_list = array();

        if ($type == 1) {
            $ptype = 'parameters';
        } elseif ($type == 2) {
            $ptype = 'dparameters';
        }
        $pexists = 'if' . $ptype;

        if ($part->$pexists) {
            foreach ($part->$ptype as $param) {
                $param->value = str_replace("\t", ' ', $param->value);
                $res = MIME::decodeRFC2231($param->attribute . '=' . $param->value);
                if ($res) {
                    $param->attribute = $res['attribute'];
                    $param->value = $res['value'];
                }
                $field = String::lower($param->attribute);
                if ($field == 'type') {
                    if (($type = MIME::type($param->value))) {
                        $param_list['type'] = $type;
                    }
                } else {
                    $param_list[$field] = $param->value;
                }
            }
        }

        return $param_list;
    }

    /**
     * Set the special information for certain MIME types.
     *
     * @access private
     *
     * @param array &$parts         TODO
     * @param optional array $info  TODO
     */
    function _addMultipartInfo(&$parts, $info = array())
    {
        if (empty($parts)) {
            return;
        }

        foreach (array_keys($parts) as $key) {
            $ptr = &$parts[$key];
            $new_info = $info;

            if (isset($info['alt'])) {
                $ptr->setInformation('alternative', (is_null($info['alt'])) ? '-' : $info['alt']);
            }
            if (isset($info['related'])) {
                $ptr->setInformation('related_part', $info['related']->getMIMEId());
                if (($id = $ptr->getInformation('id'))) {
                    $info['related']->addCID(array($ptr->getMIMEId() => $id));
                }
            }
            if (isset($info['rfc822'])) {
                $ptr->setInformation('rfc822_part', $info['rfc822']);
            }

            switch ($ptr->getType()) {
            case 'multipart/alternative':
                $new_info['alt'] = $ptr->getMIMEId();
                break;

            case 'multipart/related':
                $new_info['related'] = &$ptr;
                break;

            case 'message/rfc822':
                $new_info['rfc822'] = $ptr->getMIMEId();
                $ptr->setInformation('header', true);
                break;
            }

            MIME_Structure::_addMultipartInfo($ptr->_parts, $new_info);
        }
    }


    /**
     * Attempts to build a MIME_Message object from a text message.
     *
     * @access public
     *
     * @param string $text  The text of the MIME message.
     *
     * @return object MIME_Message  A MIME_Message object if successful.
     *                              Returns false on error.
     */
    function &parseTextMIMEMessage($text)
    {
        require_once 'Mail/mimeDecode.php';

        /* Set up the options for the mimeDecode class. */
        $decode_args = array();
        $decode_args['include_bodies'] = true;
        $decode_args['decode_bodies'] = false;
        $decode_args['decode_headers'] = false;

        $mimeDecode = &new Mail_mimeDecode($text, MIME_PART_EOL);
        if (!($structure = $mimeDecode->decode($decode_args))) {
            return false;
        }

        /* Put the object into imap_parsestructure() form. */
        MIME_Structure::_convertMimeDecodeData($structure);

        return $ret = &MIME_Structure::parse($structure);
    }

    /**
     * Convert the output from mimeDecode::decode() into a structure that
     * matches imap_fetchstructure() output.
     *
     * @access private
     *
     * @param object stdClass &$ob  The output from mimeDecode::decode().
     */
    function _convertMimeDecodeData(&$ob)
    {
        /* Primary content-type. */
        $ob->type = intval(MIME::type($ob->ctype_primary));

        /* Secondary content-type. */
        if (isset($ob->ctype_secondary)) {
            $ob->subtype = String::upper($ob->ctype_secondary);
            $ob->ifsubtype = 1;
        } else {
            $ob->ifsubtype = 0;
        }

        /* Content transfer encoding. */
        if (isset($ob->headers['content-transfer-encoding'])) {
            $ob->encoding = MIME::encoding($ob->headers['content-transfer-encoding']);
        }

        /* Content-type and Disposition parameters. */
        $param_types = array ('ctype_parameters' => 'parameters',
                              'd_parameters' => 'dparameters');
        foreach ($param_types as $param_key => $param_value) {
            $if_var = 'if' . $param_value;
            if (isset($ob->$param_key)) {
                $ob->$if_var = 1;
                $ob->$param_value = array();
                foreach ($ob->$param_key as $key => $val) {
                    $newOb = &new stdClass;
                    $newOb->attribute = $key;
                    $newOb->value = $val;
                    array_push($ob->$param_value, $newOb);
                }
            } else {
                $ob->$if_var = 0;
            }
        }

        /* Content-Disposition. */
        if (isset($ob->headers['content-disposition'])) {
            $ob->ifdisposition = 1;
            $hdr = $ob->headers['content-disposition'];
            $pos = strpos($hdr, ';');
            if ($pos !== false) {
                $hdr = substr($hdr, 0, $pos);
            }
            $ob->disposition = $hdr;
        } else {
            $ob->ifdisposition = 0;
        }

        /* Content-ID. */
        if (isset($ob->headers['content-id'])) {
            $ob->ifid = 1;
            $ob->id = $ob->headers['content-id'];
        } else {
            $ob->ifid = 0;
        }

        /* Get file size (if 'body' text is set). */
        if (isset($ob->body)) {
            $ob->bytes = strlen($ob->body);
        }

        /* Process parts also. */
        if (isset($ob->parts)) {
            foreach (array_keys($ob->parts) as $key) {
                MIME_Structure::_convertMimeDecodeData($ob->parts[$key]);
            }
        }
    }

    /**
     * Builds an object consisting of MIME header/value pairs.
     *
     * @access public
     *
     * @param string $headers              A text string containing the headers
     *                                     (e.g. output from
     *                                     imap_fetchheader()).
     * @param optional boolean $decode     Should the headers be decoded?
     * @param optional boolean $lowercase  Should the keys be in lowercase?
     *
     * @return array  An array consisting of the header name as the key and
     *                the header value as the value.
     *                A header with multiple entries will be stored in
     *                'value' as an array.
     */
    function parseMIMEHeaders($headers, $decode = true, $lowercase = false)
    {
        $header = '';
        $ob = array();

        foreach (explode("\n", $headers) as $val) {
            if ($decode) {
                $val = MIME::decode($val);
            }
            if (preg_match("/^([^\s]+)\:(.*)/", $val, $matches)) {
                $val = trim($matches[2]);
                $header = $matches[1];
                if (isset($ob[$header])) {
                    if (!is_array($ob[$header])) {
                        $temp = $ob[$header];
                        $ob[$header] = array();
                        $ob[$header][] = $temp;
                    }
                    $ob[$header][] = $val;
                    continue;
                }
            } else {
                $val = ' ' . trim($val);
            }

            if (!empty($header)) {
                if (isset($ob[$header])) {
                    if (is_array($ob[$header])) {
                        end($ob[$header]);
                        $ob[$header][key($ob[$header])] .= $val;
                    } else {
                        $ob[$header] .= $val;
                    }
                } else {
                    $ob[$header] = $val;
                }
            }
        }

        return ($lowercase) ? array_change_key_case($ob, CASE_LOWER) : $ob;
    }

}

--- NEW FILE: Viewer.php ---
<?php
/**
 * The MIME_Viewer:: class provides an abstracted interface to
 * render out MIME types into HTML format.  It depends on a
 * set of MIME_Viewer_* drivers which handle the actual rendering,
 * and also a configuration file to map MIME types to drivers.
 *
 * $Horde: framework/MIME/MIME/Viewer.php,v 1.60 2004/04/13 18:03:51 slusarz Exp $
 *
 * Copyright 1999-2004 Anil Madhavapeddy <anil at recoil.org>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  Anil Madhavapeddy <anil at recoil.org>
 * @version $Revision: 1.1 $
 * @since   Horde 1.3
 * @package Horde_MIME_Viewer
 */
class MIME_Viewer {

    /**
     * The MIME_Part object to render.
     *
     * @var object MIME_Part $mime_part
     */
    var $mime_part;

    /**
     * Configuration parameters.
     *
     * @var array $_conf
     */
    var $_conf = array();

    /**
     * getDriver cache.
     *
     * @var array $_driverCache
     */
    var $_driverCache = array();

    /**
     * Attempts to return a concert MIME_Viewer_* object based on the
     * type of MIME_Part passed onto it.
     *
     * @param object MIME_Part &$mime_part  Reference to a MIME_Part object
     *                                      with the information to be
     *                                      rendered.
     * @param optional string $mime_type    Use this MIME type instead of the
     *                                      type stored in the $mime_part.
     *
     * @return object MIME_Viewer  The MIME_Viewer object.
     *                             Returns false on error.
     */
    function &factory(&$mime_part, $mime_type = null)
    {
        /* Check that we have a valid MIME_Part object */
        if (!is_a($mime_part, 'MIME_Part')) {
            return false;
        }

        /* Determine driver type from the MIME type */
        if (empty($mime_type)) {
            $mime_type = $mime_part->getType();
            if (empty($mime_type)) {
                return false;
            }
        }

        /* Spawn the relevant driver, and return it (or false on failure) */
        if (($ob = MIME_Viewer::includeDriver($mime_type))) {
            $class = (($ob->module == 'horde') ? '' : $ob->module . '_') . 'MIME_Viewer_' . $ob->driver;
            if (class_exists($class)) {
               return $ret = &new $class($mime_part, $GLOBALS['mime_drivers'][$ob->module][$ob->driver]);
            }
        }

        return false;
    }

    /**
     * Include the code for the relevant driver.
     *
     * @access public
     *
     * @param string $mime_type  The Content-type of the part to be rendered.
     *
     * @return object stdClass  See MIME_Driver::getDriver().
     */
    function includeDriver($mime_type)
    {
        global $registry;

        /* Figure the correct driver for this MIME type. If there is no
           application-specific module, a general Horde one will attempt to
           be used. */
        if (($ob = MIME_Viewer::getDriver($mime_type, $registry->getApp()))) {
            /* Include the class. */
            require_once MIME_Viewer::resolveDriver($ob->driver, $ob->module);
        }

        return $ob;
    }

    /**
     * Constructor for MIME_Viewer
     *
     * @access public
     *
     * @param object MIME_Part &$mime_part  Reference to a MIME_Part object
     *                                      with the information to be rendered
     */
    function MIME_Viewer(&$mime_part, $conf = array())
    {
        $this->mime_part = &$mime_part;
        $this->_conf = $conf;
    }

    /**
     * Sets the MIME_Part object for the class.
     *
     * @access public
     *
     * @param object MIME_Part &$mime_part  Reference to a MIME_Part object
     *                                      with the information to be rendered
     */
    function setMIMEPart(&$mime_part)
    {
        $this->mime_part = &$mime_part;
    }

    /**
     * Return the MIME type of the rendered content.  This can be
     * overridden by the individual drivers, depending on what format
     * they output in. By default, it passes through the MIME type of
     * the object, or replaces custom extension types with
     * 'text/plain' to let the browser do a best-guess render.
     *
     * @access public
     *
     * @return string  MIME-type of the output content.
     */
    function getType()
    {
        if ($this->mime_part->getPrimaryType() == 'x-extension') {
            return 'text/plain';
        } else {
            return $this->mime_part->getType();
        }
    }

    /**
     * Return the rendered version of the object.
     * Should be overridden by individual drivers to perform custom tasks.
     * The $mime_part class variable has the information to render,
     * encapsulated in a MIME_Part object.
     *
     * @access public
     *
     * @param mixed $params  Any optional parameters this driver needs at
     *                       runtime.
     *
     * @return string  Rendered version of the object.
     */
    function render($params = null)
    {
        return $this->mime_part->getContents();
    }

    /**
     * Return text/html output used as alternative output when the fully
     * rendered object can not (or should not) be displayed.  For example,
     * this function should be used for MIME attachments that can not be
     * viewed inline, where the user may be given options on how to view
     * the attachment.
     * Should be overridden by individual drivers to perform custom tasks.
     * The $mime_part class variable has the information to render,
     * encapsulated in a MIME_Part object.
     *
     * @access public
     *
     * @param mixed $params  Any optional parameters this driver needs at
     *                       runtime.
     *
     * @return string  Text/html rendered information.
     */
    function renderAttachmentInfo()
    {
    }

    /**
     * Can this driver render the the data inline?
     *
     * @access public
     *
     * @return boolean  True if the driver can display inline.
     */
    function canDisplayInline()
    {
        if ($this->getConfigParam('inline')) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * Given a driver and an application, this returns the fully
     * qualified filesystem path to the driver source file.
     *
     * @access public
     *
     * @param optional string $driver  Driver name.
     * @param optional string $app     Application name.
     *
     * @return string  Filesystem path of the driver/application queried.
     */
    function resolveDriver($driver = 'default', $app = 'horde')
    {
        if ($app == 'horde') {
            return dirname(__FILE__) . '/Viewer/' . $driver . '.php';
        } else {
            return $GLOBALS['registry']->applications[$app]['fileroot'] . '/lib/MIME/Viewer/' . $driver . '.php';
        }
    }

    /**
     * Given an input MIME type and a module name, this function
     * resolves it into a specific output driver which can handle it.
     *
     * @param string $mimeType  MIME type to resolve.
     * @param string $module    Module in which to search for the driver.
     *
     * @return object stdClass  Object with the following items:
     * <pre>
     * 'driver'  --  Name of driver (e.g. 'enscript')
     * 'exact'   --  Was the driver and exact match? (true/false)
     * 'module'  --  The module containing driver (e.g. 'horde')
     * </pre>
     * Returns false if driver could not be found.
     */
    function getDriver($mimeType, $module = 'horde')
    {
        global $mime_drivers, $mime_drivers_map;

        $cacheName = $mimeType . '|' . $module;
        if (isset($this) && isset($this->_driverCache[$cacheName])) {
            return $this->_driverCache[$cacheName];
        }

        $driver = '';
        $exactDriver = false;

        list($primary_type, ) = explode('/', $mimeType, 2);
        $allSub = $primary_type . '/*';

        /* If the module doesn't exist in $mime_drivers_map, check for
           Horde viewers. */
        if (!isset($mime_drivers_map[$module]) && $module != 'horde') {
            return MIME_Viewer::getDriver($mimeType, 'horde');
        }

        $dr = &$mime_drivers[$module];
        $map = &$mime_drivers_map[$module];

        /* If an override exists for this MIME type, then use that */
        if (isset($map['overrides'][$mimeType])) {
            $driver = $map['overrides'][$mimeType];
            $exactDriver = true;
        } elseif (isset($map['overrides'][$allSub])) {
            $driver = $map['overrides'][$allSub];
            $exactDriver = true;
        } elseif (isset($map['registered'])) {
            /* Iterate through the list of registered drivers, and see if
               this MIME type exists in the MIME types that they claim to
               handle. If the driver handles it, then assign it as the
               rendering driver. If we find a generic handler, keep iterating
               to see if we can find a specific handler. */
            foreach ($map['registered'] as $val) {
                if (in_array($mimeType, $dr[$val]['handles'])) {
                    $driver = $val;
                    $exactDriver = true;
                    break;
                } elseif (in_array($allSub, $dr[$val]['handles'])) {
                    $driver = $val;
                }
            }
        }

        /* If this is an application specific module, and an exact match was
           not found, search for a Horde-wide specific driver. Only use the
           Horde-specific driver if it is NOT the 'default' driver AND the
           Horde driver is an exact match. */
        if (!$exactDriver && $module != 'horde') {
            $ob = MIME_Viewer::getDriver($mimeType, 'horde');
            if (empty($driver) ||
                (($ob->driver != 'default') && $ob->exact)) {
                $driver = $ob->driver;
                $module = 'horde';
            }
        }

        /* If the 'default' driver exists in this module, fall back to that. */
        if (empty($driver) &&
            @is_file(MIME_Viewer::resolveDriver('default', $module))) {
            $driver = 'default';
        }

        if (empty($driver)) {
            $this->_driverCache[$cacheName] = false;
            return false;
        } else {
            $ob = new stdClass;
            $ob->driver = $driver;
            $ob->exact  = $exactDriver;
            $ob->module = $module;
            if (isset($this)) {
                $this->_driverCache[$cacheName] = $ob;
            }
            return $ob;
        }
    }

    /**
     * Given a MIME type, this function will return an appropriate
     * icon.
     *
     * @access public
     *
     * @param string $mimeType  The MIME type that we need an icon for.
     *
     * @return string  The URL to the appropriate icon.
     */
    function getIcon($mimeType)
    {
        $app = $GLOBALS['registry']->getApp();
        $ob = MIME_Viewer::_getIcon($mimeType, $app);

        if (!isset($ob) && ($app != 'horde')) {
            $obHorde = MIME_Viewer::_getIcon($mimeType, 'horde');
            $icon = $obHorde->url;
        } elseif (!isset($ob)) {
            return null;
        } elseif (($ob->match !== 0) && ($app != 'horde')) {
            $obHorde = MIME_Viewer::_getIcon($mimeType, 'horde');
            if (!is_null($ob->match) && ($ob->match <= $obHorde->match)) {
                $icon = $ob->url;
            } else {
                $icon = $obHorde->url;
            }
        } else {
            $icon = $ob->url;
        }

        return $icon;
    }

    /**
     * Given an input MIME type and module, this function returns the
     * URL of an icon that can be associated with it
     *
     * @access private
     *
     * @param string $mimeType  MIME type to get the icon for.
     *
     * @return object stdClass  url:   URL to an icon, or null if none
     *                                 could be found.
     *                          exact: How exact the match is.
     *                                 0 => 'exact', 1 => 'primary',
     *                                 2 => 'driver', 3 => 'default'
     *                                 or null.
     */
    function _getIcon($mimeType, $module = 'horde')
    {
        global $mime_drivers;

        $ob = MIME_Viewer::getDriver($mimeType, $module);
        if (!is_object($ob)) {
            return array(false, null);
        }
        $driver = $ob->driver;

        list($primary_type,) = explode('/', $mimeType, 2);
        $allSub = $primary_type . '/*';
        $retOb = &new stdClass();
        $retOb->match = null;
        $retOb->url = null;

        /* If the module doesn't exist in $mime_drivers, return now. */
        if (!isset($mime_drivers[$module])) {
            return null;
        }
        $dr = &$mime_drivers[$module];

        /* If a specific icon for this driver and mimetype is defined,
           then use that. */
        if (isset($dr[$driver]['icons'])) {
            $icondr = &$mime_drivers[$module][$driver]['icons'];
            $iconList = array($mimeType => 0, $allSub => 1, 'default' => 2);
            foreach ($iconList as $key => $val) {
                if (isset($icondr[$key])) {
                    $retOb->url = $icondr[$key];
                    $retOb->match = $val;
                    break;
                }
            }
        }

        /* Try to use a default icon if none already obtained. */
        if (is_null($retOb->url) && isset($dr['default'])) {
            $dr = &$mime_drivers[$module]['default'];
            if (isset($dr['icons']['default'])) {
                $retOb->url = $dr['default']['icons']['default'];
                $retOb->match = 3;
            }
        }

        if (!is_null($retOb->url)) {
            $retOb->url = $GLOBALS['registry']->applicationWebPath("%application%/graphics/mime/" . $retOb->url, $module);
        }

        return $retOb;
    }

    /**
     * Returns the character set used for the Viewer.
     * Should be overridden by individual drivers to perform custom tasks.
     *
     * @access public
     *
     * @return string  The character set used by this Viewer.
     */
    function getCharset()
    {
        return $this->mime_part->getCharset();
    }

    /**
     * Return a configuration parameter for the current viewer.
     *
     * @access public
     *
     * @param string $param  The parameter name.
     *
     * @return mixed  The value of the parameter; returns null if the parameter
     *                doesn't exist.
     */
    function getConfigParam($param)
    {
        return (isset($this->_conf[$param])) ? $this->_conf[$param] : null;
    }

}

--- NEW FILE: mime.magic.php ---
<?php
/**
 * Data file used by MIME_Magic::.
 *
 * $Horde: framework/MIME/MIME/mime.magic.php,v 1.5 2004/03/20 22:45:37 jan Exp $
 *
 * @package Horde_MIME
 */
$mime_magic[0][30]["\145\166\141\154\40\42\145\170\145\143\40\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\160\145\162\154"] = 'application/x-perl';
$mime_magic[0][24]["\145\166\141\154\40\42\145\170\145\143\40\57\165\163\162\57\142\151\156\57\160\145\162\154"] = 'application/x-perl';
$mime_magic[0][23]["\103\157\155\155\157\156\40\163\165\142\144\151\162\145\143\164\157\162\151\145\163\72\40"] = 'text/x-patch';
$mime_magic[0][23]["\75\74\154\151\163\164\76\156\74\160\162\157\164\157\143\157\154\40\142\142\156\55\155"] = 'application/data';
$mime_magic[0][22]["\101\115\101\116\104\101\72\40\124\101\120\105\123\124\101\122\124\40\104\101\124\105"] = 'application/x-amanda-header';
$mime_magic[0][22]["\107\106\61\120\101\124\103\110\61\60\60\60\111\104\43\60\60\60\60\60\62\60"] = 'audio/x-gus-patch';
$mime_magic[0][22]["\107\106\61\120\101\124\103\110\61\61\60\60\111\104\43\60\60\60\60\60\62\60"] = 'audio/x-gus-patch';
$mime_magic[0][22]["\43\41\11\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\142\141\163\150"] = 'application/x-sh';
$mime_magic[0][22]["\43\41\11\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\147\141\167\153"] = 'application/x-awk';
$mime_magic[0][22]["\43\41\11\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\156\141\167\153"] = 'application/x-awk';
$mime_magic[0][22]["\43\41\11\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\160\145\162\154"] = 'application/x-perl';
$mime_magic[0][22]["\43\41\11\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\164\143\163\150"] = 'application/x-csh';
$mime_magic[0][22]["\43\41\40\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\142\141\163\150"] = 'application/x-sh';
$mime_magic[0][22]["\43\41\40\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\147\141\167\153"] = 'application/x-awk';
$mime_magic[0][22]["\43\41\40\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\156\141\167\153"] = 'application/x-awk';
$mime_magic[0][22]["\43\41\40\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\160\145\162\154"] = 'application/x-perl';
$mime_magic[0][22]["\43\41\40\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\164\143\163\150"] = 'application/x-csh';
$mime_magic[0][21]["\43\41\11\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\141\163\150"] = 'application/x-zsh';
$mime_magic[0][21]["\43\41\11\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\172\163\150"] = 'application/x-zsh';
$mime_magic[0][21]["\43\41\40\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\141\163\150"] = 'application/x-zsh';
$mime_magic[0][21]["\43\41\40\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\172\163\150"] = 'application/x-zsh';
$mime_magic[0][21]["\43\41\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\142\141\163\150"] = 'application/x-sh';
$mime_magic[0][21]["\43\41\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\147\141\167\153"] = 'application/x-awk';
$mime_magic[0][21]["\43\41\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\156\141\167\153"] = 'application/x-awk';
$mime_magic[0][21]["\43\41\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\160\145\162\154"] = 'application/x-perl';
$mime_magic[0][21]["\43\41\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\164\143\163\150"] = 'application/x-csh';
$mime_magic[0][20]["\145\166\141\154\40\42\145\170\145\143\40\57\142\151\156\57\160\145\162\154"] = 'application/x-perl';
$mime_magic[0][20]["\43\41\11\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\141\145"] = 'text/script';
$mime_magic[0][20]["\43\41\40\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\141\145"] = 'text/script';
$mime_magic[0][20]["\43\41\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\141\163\150"] = 'application/x-sh';
$mime_magic[0][20]["\43\41\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\172\163\150"] = 'application/x-zsh';
$mime_magic[0][19]["\103\162\145\141\164\151\166\145\40\126\157\151\143\145\40\106\151\154\145"] = 'audio/x-voc';
$mime_magic[0][19]["\41\74\141\162\143\150\76\156\137\137\137\137\137\137\137\137\137\137\105"] = 'application/x-ar';
$mime_magic[0][19]["\41\74\141\162\143\150\76\156\137\137\137\137\137\137\137\137\66\64\105"] = 'application/data';
$mime_magic[0][19]["\43\41\57\165\163\162\57\154\157\143\141\154\57\142\151\156\57\141\145"] = 'text/script';
$mime_magic[0][18]["\106\151\114\145\123\164\101\162\124\146\111\154\105\163\124\141\122\164"] = 'text/x-apple-binscii';
$mime_magic[0][18]["\43\41\40\57\165\163\162\57\154\157\143\141\154\57\164\143\163\150"] = 'application/x-csh';
$mime_magic[0][18]["\45\41\120\123\55\101\144\157\142\145\106\157\156\164\55\61\56\60"] = 'font/type1';
$mime_magic[0][17]["\43\41\57\165\163\162\57\154\157\143\141\154\57\164\143\163\150"] = 'application/x-csh';
$mime_magic[0][16]["\105\170\164\145\156\144\145\144\40\115\157\144\165\154\145\72"] = 'audio/x-ft2-mod';
$mime_magic[0][16]["\123\164\141\162\164\106\157\156\164\115\145\164\162\151\143\163"] = 'font/x-sunos-news';
$mime_magic[0][16]["\43\41\11\57\165\163\162\57\142\151\156\57\147\141\167\153"] = 'application/x-awk';
$mime_magic[0][16]["\43\41\11\57\165\163\162\57\142\151\156\57\156\141\167\153"] = 'application/x-awk';
$mime_magic[0][16]["\43\41\11\57\165\163\162\57\142\151\156\57\160\145\162\154"] = 'application/x-perl';
$mime_magic[0][16]["\43\41\40\57\165\163\162\57\142\151\156\57\147\141\167\153"] = 'application/x-awk';
$mime_magic[0][16]["\43\41\40\57\165\163\162\57\142\151\156\57\156\141\167\153"] = 'application/x-awk';
$mime_magic[0][16]["\43\41\40\57\165\163\162\57\142\151\156\57\160\145\162\154"] = 'application/x-perl';
$mime_magic[0][16]["\74\115\141\153\145\162\104\151\143\164\151\157\156\141\162\171"] = 'application/x-framemaker';
$mime_magic[0][16]["\74\115\141\153\145\162\123\143\162\145\145\156\106\157\156\164"] = 'font/x-framemaker';
$mime_magic[0][15]["\43\41\11\57\165\163\162\57\142\151\156\57\141\167\153"] = 'application/x-awk';
$mime_magic[0][15]["\43\41\40\57\165\163\162\57\142\151\156\57\141\167\153"] = 'application/x-awk';
$mime_magic[0][15]["\43\41\57\165\163\162\57\142\151\156\57\147\141\167\153"] = 'application/x-awk';
$mime_magic[0][15]["\43\41\57\165\163\162\57\142\151\156\57\156\141\167\153"] = 'application/x-awk';
$mime_magic[0][15]["\43\41\57\165\163\162\57\142\151\156\57\160\145\162\154"] = 'application/x-perl';
$mime_magic[0][14]["\41\74\141\162\143\150\76\156\144\145\142\151\141\156"] = 'application/x-dpkg';
$mime_magic[0][14]["\43\41\57\165\163\162\57\142\151\156\57\141\167\153"] = 'application/x-awk';
$mime_magic[0][14]["\74\41\104\117\103\124\131\120\105\40\110\124\115\114"] = 'text/html';
$mime_magic[0][14]["\74\41\144\157\143\164\171\160\145\40\150\164\155\154"] = 'text/html';
$mime_magic[0][13]["\107\111\115\120\40\107\162\141\144\151\145\156\164"] = 'application/x-gimp-gradient';
$mime_magic[0][12]["\122\145\164\165\162\156\55\120\141\164\150\72"] = 'message/rfc822';
$mime_magic[0][12]["\43\41\11\57\142\151\156\57\142\141\163\150"] = 'application/x-sh';
$mime_magic[0][12]["\43\41\11\57\142\151\156\57\147\141\167\153"] = 'application/x-awk';
$mime_magic[0][12]["\43\41\11\57\142\151\156\57\156\141\167\153"] = 'application/x-awk';
$mime_magic[0][12]["\43\41\11\57\142\151\156\57\160\145\162\154"] = 'application/x-perl';
$mime_magic[0][12]["\43\41\11\57\142\151\156\57\164\143\163\150"] = 'application/x-csh';
$mime_magic[0][12]["\43\41\40\57\142\151\156\57\142\141\163\150"] = 'application/x-sh';
$mime_magic[0][12]["\43\41\40\57\142\151\156\57\147\141\167\153"] = 'application/x-awk';
$mime_magic[0][12]["\43\41\40\57\142\151\156\57\156\141\167\153"] = 'application/x-awk';
$mime_magic[0][12]["\43\41\40\57\142\151\156\57\160\145\162\154"] = 'application/x-perl';
$mime_magic[0][12]["\43\41\40\57\142\151\156\57\164\143\163\150"] = 'application/x-csh';
$mime_magic[0][11]["\43\41\11\57\142\151\156\57\141\167\153"] = 'application/x-awk';
$mime_magic[0][11]["\43\41\11\57\142\151\156\57\143\163\150"] = 'application/x-csh';
$mime_magic[0][11]["\43\41\11\57\142\151\156\57\153\163\150"] = 'application/x-ksh';
$mime_magic[0][11]["\43\41\40\57\142\151\156\57\141\167\153"] = 'application/x-awk';
$mime_magic[0][11]["\43\41\40\57\142\151\156\57\143\163\150"] = 'application/x-csh';
$mime_magic[0][11]["\43\41\40\57\142\151\156\57\153\163\150"] = 'application/x-ksh';
$mime_magic[0][11]["\43\41\57\142\151\156\57\142\141\163\150"] = 'application/x-sh';
$mime_magic[0][11]["\43\41\57\142\151\156\57\147\141\167\153"] = 'application/x-awk';
$mime_magic[0][11]["\43\41\57\142\151\156\57\156\141\167\153"] = 'application/x-awk';
$mime_magic[0][11]["\43\41\57\142\151\156\57\160\145\162\154"] = 'application/x-perl';
$mime_magic[0][11]["\43\41\57\142\151\156\57\164\143\163\150"] = 'application/x-csh';
$mime_magic[0][10]["\102\151\164\155\141\160\146\151\154\145"] = 'image/unknown';
$mime_magic[0][10]["\123\124\101\122\124\106\117\116\124\40"] = 'font/x-bdf';
$mime_magic[0][10]["\43\41\11\57\142\151\156\57\162\143"] = 'text/script';
$mime_magic[0][10]["\43\41\11\57\142\151\156\57\163\150"] = 'application/x-sh';
$mime_magic[0][10]["\43\41\40\57\142\151\156\57\162\143"] = 'text/script';
$mime_magic[0][10]["\43\41\40\57\142\151\156\57\163\150"] = 'application/x-sh';
$mime_magic[0][10]["\43\41\57\142\151\156\57\141\167\153"] = 'application/x-awk';
$mime_magic[0][10]["\43\41\57\142\151\156\57\143\163\150"] = 'application/x-csh';
$mime_magic[0][10]["\43\41\57\142\151\156\57\153\163\150"] = 'application/x-ksh';
$mime_magic[0][10]["\74\115\141\153\145\162\106\151\154\145"] = 'application/x-framemaker';
$mime_magic[0][9]["\122\145\143\145\151\166\145\144\72"] = 'message/rfc822';
$mime_magic[0][9]["\123\164\141\162\164\106\157\156\164"] = 'font/x-sunos-news';
$mime_magic[0][9]["\211\114\132\117\0\15\12\32\12"] = 'application/data';
$mime_magic[0][9]["\43\41\57\142\151\156\57\162\143"] = 'text/script';
$mime_magic[0][9]["\43\41\57\142\151\156\57\163\150"] = 'application/x-sh';
$mime_magic[0][9]["\55\162\157\155\61\146\163\55\60"] = 'application/x-filesystem';
$mime_magic[0][9]["\74\102\157\157\153\106\151\154\145"] = 'application/x-framemaker';
$mime_magic[0][8]["\117\156\154\171\40\151\156\40"] = 'text/x-patch';
$mime_magic[0][8]["\147\151\155\160\40\170\143\146"] = 'application/x-gimp-image';
$mime_magic[0][8]["\155\163\147\143\141\164\60\61"] = 'application/x-locale';
$mime_magic[0][8]["\32\141\162\143\150\151\166\145"] = 'application/data';
$mime_magic[0][8]["\41\74\120\104\106\76\41\156"] = 'application/x-prof';
$mime_magic[0][8]["\74\115\111\106\106\151\154\145"] = 'application/x-framemaker';
$mime_magic[0][7]["\101\162\164\151\143\154\145"] = 'message/news';
$mime_magic[0][7]["\120\103\104\137\117\120\101"] = 'x/x-photo-cd-overfiew-file';
$mime_magic[0][7]["\351\54\1\112\101\115\11"] = 'application/data';
$mime_magic[0][7]["\41\74\141\162\143\150\76"] = 'application/x-ar';
$mime_magic[0][7]["\72\40\163\150\145\154\154"] = 'application/data';
$mime_magic[0][6]["\116\165\106\151\154\145"] = 'application/data';
$mime_magic[0][6]["\116\365\106\351\154\345"] = 'application/data';
$mime_magic[0][6]["\60\67\60\67\60\61"] = 'application/x-cpio';
$mime_magic[0][6]["\60\67\60\67\60\62"] = 'application/x-cpio';
$mime_magic[0][6]["\60\67\60\67\60\67"] = 'application/x-cpio';
$mime_magic[0][6]["\74\115\141\153\145\162"] = 'application/x-framemaker';
$mime_magic[0][6]["\74\124\111\124\114\105"] = 'text/html';
$mime_magic[0][6]["\74\164\151\164\154\145"] = 'text/html';
$mime_magic[0][5]["\0\1\0\0\0"] = 'font/ttf';
$mime_magic[0][5]["\0\4\36\212\200"] = 'application/core';
$mime_magic[0][5]["\102\101\102\131\114"] = 'message/x-gnu-rmail';
$mime_magic[0][5]["\102\105\107\111\116"] = 'application/x-awk';
$mime_magic[0][5]["\103\157\162\145\1"] = 'application/x-executable-file';
$mime_magic[0][5]["\104\61\56\60\15"] = 'font/x-speedo';
$mime_magic[0][5]["\106\162\157\155\72"] = 'message/rfc822';
$mime_magic[0][5]["\115\101\123\137\125"] = 'audio/x-multimate-mod';
$mime_magic[0][5]["\120\117\136\121\140"] = 'text/vnd.ms-word';
$mime_magic[0][5]["\120\141\164\150\72"] = 'message/news';
$mime_magic[0][5]["\130\162\145\146\72"] = 'message/news';
$mime_magic[0][5]["\144\151\146\146\40"] = 'text/x-patch';
$mime_magic[0][5]["\225\64\62\62\336"] = 'application/x-locale';
$mime_magic[0][5]["\336\62\62\64\225"] = 'application/x-locale';
$mime_magic[0][5]["\74\110\105\101\104"] = 'text/html';
$mime_magic[0][5]["\74\110\124\115\114"] = 'text/html';
$mime_magic[0][5]["\74\150\145\141\144"] = 'text/html';
$mime_magic[0][5]["\74\150\164\155\154"] = 'text/html';
$mime_magic[0][5]["\75\74\141\162\76"] = 'application/x-ar';
$mime_magic[0][4]["\0\0\0\314"] = 'application/x-executable-file';
$mime_magic[0][4]["\0\0\0\4"] = 'font/x-snf';
$mime_magic[0][4]["\0\0\1\107"] = 'application/x-object-file';
$mime_magic[0][4]["\0\0\1\113"] = 'application/x-executable-file';
$mime_magic[0][4]["\0\0\1\115"] = 'application/x-executable-file';
$mime_magic[0][4]["\0\0\1\117"] = 'application/x-executable-file';
$mime_magic[0][4]["\0\0\1\201"] = 'application/x-object-file';
$mime_magic[0][4]["\0\0\1\207"] = 'application/data';
$mime_magic[0][4]["\0\0\1\263"] = 'video/mpeg';
$mime_magic[0][4]["\0\0\1\272"] = 'video/mpeg';
$mime_magic[0][4]["\0\0\1\6"] = 'application/x-executable-file';
$mime_magic[0][4]["\0\0\201\154"] = 'application/x-apl-workspace';
$mime_magic[0][4]["\0\0\377\145"] = 'application/x-library-file';
$mime_magic[0][4]["\0\0\377\155"] = 'application/data';
$mime_magic[0][4]["\0\0\3\347"] = 'application/x-library-file';
$mime_magic[0][4]["\0\0\3\363"] = 'application/x-executable-file';
$mime_magic[0][4]["\0\144\163\56"] = 'audio/basic';
$mime_magic[0][4]["\0\1\22\127"] = 'application/core';
$mime_magic[0][4]["\0\22\326\207"] = 'image/x11';
$mime_magic[0][4]["\0\3\233\355"] = 'application/data';
$mime_magic[0][4]["\0\3\233\356"] = 'application/data';
$mime_magic[0][4]["\0\5\26\0"] = 'application/data';
$mime_magic[0][4]["\0\5\26\7"] = 'application/data';
$mime_magic[0][4]["\0\5\61\142"] = 'application/x-db';
$mime_magic[0][4]["\0\6\25\141"] = 'application/x-db';
$mime_magic[0][4]["\103\124\115\106"] = 'audio/x-cmf';
$mime_magic[0][4]["\105\115\117\104"] = 'audio/x-emod';
$mime_magic[0][4]["\106\106\111\114"] = 'font/ttf';
$mime_magic[0][4]["\106\117\116\124"] = 'font/x-vfont';
$mime_magic[0][4]["\107\104\102\115"] = 'application/x-gdbm';
$mime_magic[0][4]["\107\111\106\70"] = 'image/gif';
$mime_magic[0][4]["\10\16\12\17"] = 'application/data';
$mime_magic[0][4]["\110\120\101\113"] = 'application/data';
$mime_magic[0][4]["\111\111\116\61"] = 'image/tiff';
$mime_magic[0][4]["\111\111\52\0"] = 'image/tiff';
$mime_magic[0][4]["\114\104\110\151"] = 'application/data';
$mime_magic[0][4]["\114\127\106\116"] = 'font/type1';
$mime_magic[0][4]["\115\115\0\52"] = 'image/tiff';
$mime_magic[0][4]["\115\117\126\111"] = 'video/x-sgi-movie';
$mime_magic[0][4]["\115\124\150\144"] = 'audio/midi';
$mime_magic[0][4]["\115\247\356\350"] = 'font/x-hp-windows';
$mime_magic[0][4]["\116\124\122\113"] = 'audio/x-multitrack';
$mime_magic[0][4]["\120\113\3\4"] = 'application/zip';
$mime_magic[0][4]["\122\111\106\106"] = 'audio/x-wav';
$mime_magic[0][4]["\122\141\162\41"] = 'application/x-rar';
$mime_magic[0][4]["\123\121\123\110"] = 'application/data';
$mime_magic[0][4]["\124\101\104\123"] = 'application/x-tads-game';
$mime_magic[0][4]["\125\103\62\32"] = 'application/data';
$mime_magic[0][4]["\125\116\60\65"] = 'audio/x-mikmod-uni';
$mime_magic[0][4]["\12\17\10\16"] = 'application/data';
$mime_magic[0][4]["\131\246\152\225"] = 'x/x-image-sun-raster';
$mime_magic[0][4]["\145\377\0\0"] = 'application/x-ar';
$mime_magic[0][4]["\150\163\151\61"] = 'image/x-jpeg-proprietary';
$mime_magic[0][4]["\16\10\17\12"] = 'application/data';
$mime_magic[0][4]["\177\105\114\106"] = 'application/x-executable-file';
$mime_magic[0][4]["\17\12\16\10"] = 'application/data';
$mime_magic[0][4]["\1\130\41\246"] = 'application/core';
$mime_magic[0][4]["\1\146\143\160"] = 'font/x-pcf';
$mime_magic[0][4]["\211\120\116\107"] = 'image/x-png';
$mime_magic[0][4]["\23\127\232\316"] = 'application/x-gdbm';
$mime_magic[0][4]["\23\172\51\104"] = 'font/x-sunos-news';
$mime_magic[0][4]["\23\172\51\107"] = 'font/x-sunos-news';
$mime_magic[0][4]["\23\172\51\120"] = 'font/x-sunos-news';
$mime_magic[0][4]["\23\172\51\121"] = 'font/x-sunos-news';
$mime_magic[0][4]["\24\2\131\31"] = 'font/x-libgrx';
$mime_magic[0][4]["\260\61\63\140"] = 'application/x-bootable';
$mime_magic[0][4]["\2\10\1\10"] = 'application/x-executable-file';
$mime_magic[0][4]["\2\10\1\6"] = 'application/x-executable-file';
$mime_magic[0][4]["\2\10\1\7"] = 'application/x-executable-file';
$mime_magic[0][4]["\2\10\377\145"] = 'application/x-library-file';
$mime_magic[0][4]["\2\12\1\10"] = 'application/x-executable-file';
$mime_magic[0][4]["\2\12\1\7"] = 'application/x-executable-file';
$mime_magic[0][4]["\2\12\377\145"] = 'application/x-library-file';
$mime_magic[0][4]["\2\13\1\10"] = 'application/x-executable-file';
$mime_magic[0][4]["\2\13\1\13"] = 'application/x-executable-file';
$mime_magic[0][4]["\2\13\1\15"] = 'application/x-library-file';
$mime_magic[0][4]["\2\13\1\16"] = 'application/x-library-file';
$mime_magic[0][4]["\2\13\1\6"] = 'application/x-object-file';
$mime_magic[0][4]["\2\13\1\7"] = 'application/x-executable-file';
$mime_magic[0][4]["\2\14\1\10"] = 'application/x-executable-file';
$mime_magic[0][4]["\2\14\1\13"] = 'application/x-executable-file';
$mime_magic[0][4]["\2\14\1\14"] = 'application/x-lisp';
$mime_magic[0][4]["\2\14\1\15"] = 'application/x-library-file';
$mime_magic[0][4]["\2\14\1\16"] = 'application/x-library-file';
$mime_magic[0][4]["\2\14\1\6"] = 'application/x-executable-file';
$mime_magic[0][4]["\2\14\1\7"] = 'application/x-executable-file';
$mime_magic[0][4]["\2\14\377\145"] = 'application/x-library-file';
$mime_magic[0][4]["\2\20\1\10"] = 'application/x-executable-file';
$mime_magic[0][4]["\2\20\1\13"] = 'application/x-executable-file';
$mime_magic[0][4]["\2\20\1\15"] = 'application/x-library-file';
$mime_magic[0][4]["\2\20\1\16"] = 'application/x-library-file';
$mime_magic[0][4]["\2\20\1\6"] = 'application/x-object-file';
$mime_magic[0][4]["\2\20\1\7"] = 'application/x-executable-file';
$mime_magic[0][4]["\2\24\1\10"] = 'application/x-executable-file';
$mime_magic[0][4]["\2\24\1\13"] = 'application/x-executable-file';
$mime_magic[0][4]["\2\24\1\15"] = 'application/x-object-file';
$mime_magic[0][4]["\2\24\1\16"] = 'application/x-library-file';
$mime_magic[0][4]["\2\24\1\6"] = 'application/x-object-file';
$mime_magic[0][4]["\2\24\1\7"] = 'application/x-executable-file';
$mime_magic[0][4]["\361\60\100\273"] = 'image/x-cmu-raster';
$mime_magic[0][4]["\366\366\366\366"] = 'application/x-pc-floppy';
$mime_magic[0][4]["\377\106\117\116"] = 'font/x-dos';
$mime_magic[0][4]["\41\74\141\162"] = 'application/x-ar';
$mime_magic[0][4]["\43\41\11\57"] = 'text/script';
$mime_magic[0][4]["\43\41\40\57"] = 'text/script';
$mime_magic[0][4]["\52\123\124\101"] = 'application/data';
$mime_magic[0][4]["\52\52\52\40"] = 'text/x-patch';
$mime_magic[0][4]["\56\162\141\375"] = 'audio/x-pn-realaudio';
$mime_magic[0][4]["\56\163\156\144"] = 'audio/basic';
$mime_magic[0][4]["\61\143\167\40"] = 'application/data';
$mime_magic[0][4]["\61\276\0\0"] = 'text/vnd.ms-word';
$mime_magic[0][4]["\62\62\67\70"] = 'application/data';
$mime_magic[0][4]["\74\115\115\114"] = 'application/x-framemaker';
$mime_magic[0][4]["\74\141\162\76"] = 'application/x-ar';
$mime_magic[0][3]["\102\132\150"] = 'application/x-bzip2';
$mime_magic[0][3]["\106\101\122"] = 'audio/mod';
$mime_magic[0][3]["\115\124\115"] = 'audio/x-multitrack';
$mime_magic[0][3]["\123\102\111"] = 'audio/x-sbi';
$mime_magic[0][3]["\124\117\103"] = 'audio/x-toc';
$mime_magic[0][3]["\12\107\114"] = 'application/data';
$mime_magic[0][3]["\146\154\143"] = 'application/x-font';
$mime_magic[0][3]["\146\154\146"] = 'font/x-figlet';
$mime_magic[0][3]["\33\105\33"] = 'image/x-pcl-hp';
$mime_magic[0][3]["\33\143\33"] = 'application/data';
$mime_magic[0][3]["\377\377\174"] = 'application/data';
$mime_magic[0][3]["\377\377\176"] = 'application/data';
$mime_magic[0][3]["\377\377\177"] = 'application/data';
$mime_magic[0][3]["\43\41\40"] = 'text/script';
$mime_magic[0][3]["\43\41\57"] = 'text/script';
$mime_magic[0][3]["\4\45\41"] = 'application/postscript';
$mime_magic[0][3]["\55\150\55"] = 'application/data';
$mime_magic[0][3]["\61\143\167"] = 'application/data';
$mime_magic[0][2]["\0\0"] = 'application/x-executable-file';
$mime_magic[0][2]["\102\115"] = 'image/x-bmp';
$mime_magic[0][2]["\102\132"] = 'application/x-bzip';
$mime_magic[0][2]["\111\103"] = 'image/x-ico';
$mime_magic[0][2]["\112\116"] = 'audio/x-669-mod';
$mime_magic[0][2]["\115\132"] = 'application/x-ms-dos-executable';
$mime_magic[0][2]["\120\61"] = 'image/x-portable-bitmap';
$mime_magic[0][2]["\120\62"] = 'image/x-portable-graymap';
$mime_magic[0][2]["\120\63"] = 'image/x-portable-pixmap';
$mime_magic[0][2]["\120\64"] = 'image/x-portable-bitmap';
$mime_magic[0][2]["\120\65"] = 'image/x-portable-graymap';
$mime_magic[0][2]["\120\66"] = 'image/x-portable-pixmap';
$mime_magic[0][2]["\151\146"] = 'audio/x-669-mod';
$mime_magic[0][2]["\161\307"] = 'application/x-cpio';
$mime_magic[0][2]["\166\377"] = 'application/data';
$mime_magic[0][2]["\1\110"] = 'application/x-executable-file';
$mime_magic[0][2]["\1\111"] = 'application/x-executable-file';
$mime_magic[0][2]["\1\124"] = 'application/data';
$mime_magic[0][2]["\1\125"] = 'application/x-executable-file';
$mime_magic[0][2]["\1\160"] = 'application/x-executable-file';
$mime_magic[0][2]["\1\161"] = 'application/x-executable-file';
$mime_magic[0][2]["\1\175"] = 'application/x-executable-file';
$mime_magic[0][2]["\1\177"] = 'application/x-executable-file';
$mime_magic[0][2]["\1\20"] = 'application/x-executable-file';
$mime_magic[0][2]["\1\203"] = 'application/x-executable-file';
$mime_magic[0][2]["\1\21"] = 'application/x-executable-file';
$mime_magic[0][2]["\1\210"] = 'application/x-executable-file';
$mime_magic[0][2]["\1\217"] = 'application/x-object-file';
$mime_magic[0][2]["\1\224"] = 'application/x-executable-file';
$mime_magic[0][2]["\1\227"] = 'application/x-executable-file';
$mime_magic[0][2]["\1\332"] = 'x/x-image-sgi';
$mime_magic[0][2]["\1\36"] = 'font/x-vfont';
$mime_magic[0][2]["\1\6"] = 'application/x-executable-file';
$mime_magic[0][2]["\307\161"] = 'application/x-bcpio';
$mime_magic[0][2]["\313\5"] = 'application/data';
$mime_magic[0][2]["\352\140"] = 'application/x-arj';
$mime_magic[0][2]["\367\131"] = 'font/x-tex';
$mime_magic[0][2]["\367\203"] = 'font/x-tex';
$mime_magic[0][2]["\367\312"] = 'font/x-tex';
$mime_magic[0][2]["\36\1"] = 'font/x-vfont';
$mime_magic[0][2]["\375\166"] = 'application/x-lzh';
$mime_magic[0][2]["\376\166"] = 'application/data';
$mime_magic[0][2]["\377\145"] = 'application/data';
$mime_magic[0][2]["\377\155"] = 'application/data';
$mime_magic[0][2]["\377\166"] = 'application/data';
$mime_magic[0][2]["\377\330"] = 'image/jpeg';
$mime_magic[0][2]["\377\37"] = 'application/data';
$mime_magic[0][2]["\37\213"] = 'application/x-gzip';
$mime_magic[0][2]["\37\235"] = 'application/compress';
$mime_magic[0][2]["\37\236"] = 'application/data';
$mime_magic[0][2]["\37\237"] = 'application/data';
$mime_magic[0][2]["\37\240"] = 'application/data';
$mime_magic[0][2]["\37\36"] = 'application/data';
$mime_magic[0][2]["\37\37"] = 'application/data';
$mime_magic[0][2]["\37\377"] = 'application/data';
$mime_magic[0][2]["\45\41"] = 'application/postscript';
$mime_magic[0][2]["\4\66"] = 'font/linux-psf';
$mime_magic[0][2]["\57\57"] = 'text/cpp';
$mime_magic[0][2]["\5\1"] = 'application/x-locale';
$mime_magic[0][2]["\6\1"] = 'application/x-executable-file';
$mime_magic[0][2]["\6\2"] = 'application/x-alan-adventure-game';
$mime_magic[0][2]["\7\1"] = 'application/x-executable-file';
$mime_magic[1][3]["\120\116\107"] = 'image/x-png';
$mime_magic[1][3]["\127\120\103"] = 'application/vnd.wordperfect';
$mime_magic[2][6]["\55\154\150\64\60\55"] = 'application/x-lha';
$mime_magic[2][5]["\55\154\150\144\55"] = 'application/x-lha';
$mime_magic[2][5]["\55\154\150\60\55"] = 'application/x-lha';
$mime_magic[2][5]["\55\154\150\61\55"] = 'application/x-lha';
$mime_magic[2][5]["\55\154\150\62\55"] = 'application/x-lha';
$mime_magic[2][5]["\55\154\150\63\55"] = 'application/x-lha';
$mime_magic[2][5]["\55\154\150\64\55"] = 'application/x-lha';
$mime_magic[2][5]["\55\154\150\65\55"] = 'application/x-lha';
$mime_magic[2][5]["\55\154\172\163\55"] = 'application/x-lha';
$mime_magic[2][5]["\55\154\172\64\55"] = 'application/x-lha';
$mime_magic[2][5]["\55\154\172\65\55"] = 'application/x-lha';
$mime_magic[2][2]["\0\21"] = 'font/x-tex-tfm';
$mime_magic[2][2]["\0\22"] = 'font/x-tex-tfm';
$mime_magic[4][4]["\155\144\141\164"] = 'video/quicktime';
$mime_magic[4][4]["\155\157\157\166"] = 'video/quicktime';
$mime_magic[4][4]["\160\151\160\145"] = 'application/data';
$mime_magic[4][4]["\160\162\157\146"] = 'application/data';
$mime_magic[4][2]["\257\21"] = 'video/fli';
$mime_magic[4][2]["\257\22"] = 'video/flc';
$mime_magic[6][18]["\45\41\120\123\55\101\144\157\142\145\106\157\156\164\55\61\56\60"] = 'font/type1';
$mime_magic[7][22]["\357\20\60\60\60\60\60\60\60\60\60\60\60\60\60\60\60\60\60\60\60\60"] = 'application/core';
$mime_magic[7][4]["\0\105\107\101"] = 'font/x-dos';
$mime_magic[7][4]["\0\126\111\104"] = 'font/x-dos';
$mime_magic[8][4]["\23\172\53\105"] = 'font/x-sunos-news';
$mime_magic[8][4]["\23\172\53\110"] = 'font/x-sunos-news';
$mime_magic[10][25]["\43\40\124\150\151\163\40\151\163\40\141\40\163\150\145\154\154\40\141\162\143\150\151\166\145"] = 'application/x-shar';
$mime_magic[20][4]["\107\111\115\120"] = 'application/x-gimp-brush';
$mime_magic[20][4]["\107\120\101\124"] = 'application/x-gimp-pattern';
$mime_magic[20][4]["\375\304\247\334"] = 'application/x-zoo';
$mime_magic[21][8]["\41\123\103\122\105\101\115\41"] = 'audio/x-st2-mod';
$mime_magic[24][4]["\0\0\352\153"] = 'application/x-dump';
$mime_magic[24][4]["\0\0\352\154"] = 'application/x-dump';
$mime_magic[24][4]["\0\0\352\155"] = 'application/data';
$mime_magic[24][4]["\0\0\352\156"] = 'application/data';
$mime_magic[65][4]["\106\106\111\114"] = 'font/ttf';
$mime_magic[65][4]["\114\127\106\116"] = 'font/type1';
$mime_magic[257][8]["\165\163\164\141\162\40\40\60"] = 'application/x-gtar';
$mime_magic[257][6]["\165\163\164\141\162\60"] = 'application/x-tar';
$mime_magic[0774][2]["\332\276"] = 'application/data';
$mime_magic[1080][4]["\103\104\70\61"] = 'audio/x-oktalyzer-mod';
$mime_magic[1080][4]["\106\114\124\64"] = 'audio/x-startracker-mod';
$mime_magic[1080][4]["\115\41\113\41"] = 'audio/x-protracker-mod';
$mime_magic[1080][4]["\115\56\113\56"] = 'audio/x-protracker-mod';
$mime_magic[1080][4]["\117\113\124\101"] = 'audio/x-oktalyzer-mod';
$mime_magic[1080][4]["\61\66\103\116"] = 'audio/x-taketracker-mod';
$mime_magic[1080][4]["\63\62\103\116"] = 'audio/x-taketracker-mod';
$mime_magic[1080][4]["\64\103\110\116"] = 'audio/x-fasttracker-mod';
$mime_magic[1080][4]["\66\103\110\116"] = 'audio/x-fasttracker-mod';
$mime_magic[1080][4]["\70\103\110\116"] = 'audio/x-fasttracker-mod';
$mime_magic[2048][7]["\120\103\104\137\111\120\111"] = 'x/x-photo-cd-pack-file';
$mime_magic[2080][29]["\115\151\143\162\157\163\157\146\164\40\105\170\143\145\154\40\65\56\60\40\127\157\162\153\163\150\145\145\164"] = 'application/vnd.ms-excel';
$mime_magic[2080][27]["\115\151\143\162\157\163\157\146\164\40\127\157\162\144\40\66\56\60\40\104\157\143\165\155\145\156\164"] = 'text/vnd.ms-word';
$mime_magic[2080][26]["\104\157\143\165\155\145\156\164\157\40\115\151\143\162\157\163\157\146\164\40\127\157\162\144\40\66"] = 'text/vnd.ms-word';
$mime_magic[2112][9]["\115\123\127\157\162\144\104\157\143"] = 'text/vnd.ms-word';
$mime_magic[2114][5]["\102\151\146\146\65"] = 'application/vnd.ms-excel';
$mime_magic[4098][7]["\104\117\123\106\117\116\124"] = 'font/x-dos';
$mime_magic[68158480][2]["\23\177"] = 'application/x-filesystem';
$mime_magic[68158480][2]["\23\217"] = 'application/x-filesystem';
$mime_magic[68158480][2]["\44\150"] = 'application/x-filesystem';
$mime_magic[68158480][2]["\44\170"] = 'application/x-filesystem';
$mime_magic[70779960][2]["\357\123"] = 'application/x-linux-ext2fs';

--- NEW FILE: mime.mapping.php ---
<?php
/**
 * This file contains a mapping of common file extensions to
 * MIME types. It has been automatically generated from the
 * horde/scripts/mime_mapping directory.
 *
 * ALL changes should be made to horde/scripts/mime_mapping/mime.types.horde
 * or else they will be lost when this file is regenerated.
 *
 * Any unknown file extensions will automatically be mapped to
 * 'x-extension/<ext>' where <ext> is the unknown file extension.
 *
 * @package Horde_MIME
 *
 * $Horde: framework/MIME/MIME/mime.mapping.php,v 1.5 2004/03/24 22:39:28 jan Exp $
 *
 * Generated: 03/24/04 23:40:21 by jan on neo
 */
$mime_extension_map = array(
    '__MAXPERIOD__' => '1',
    '3ds'           => 'image/x-3ds',
    'BLEND'         => 'application/x-blender',
    'C'             => 'text/x-c++src',
    'CSSL'          => 'text/css',
    'NSV'           => 'video/x-nsv',
    'XM'            => 'audio/x-mod',
    'Z'             => 'application/x-compress',
    'a'             => 'application/x-archive',
    'abw'           => 'application/x-abiword',
    'abw.gz'        => 'application/x-abiword',
    'ac3'           => 'audio/ac3',
    'adb'           => 'text/x-adasrc',
    'ads'           => 'text/x-adasrc',
    'afm'           => 'application/x-font-afm',
    'ag'            => 'image/x-applix-graphics',
    'ai'            => 'application/illustrator',
    'aif'           => 'audio/x-aiff',
    'aifc'          => 'audio/x-aiff',
    'aiff'          => 'audio/x-aiff',
    'al'            => 'application/x-perl',
    'arj'           => 'application/x-arj',
    'as'            => 'application/x-applix-spreadsheet',
    'asc'           => 'text/plain',
    'asf'           => 'video/x-ms-asf',
    'asp'           => 'application/x-asp',
    'asx'           => 'video/x-ms-asf',
    'au'            => 'audio/basic',
    'avi'           => 'video/x-msvideo',
    'aw'            => 'application/x-applix-word',
    'bak'           => 'application/x-trash',
    'bcpio'         => 'application/x-bcpio',
    'bdf'           => 'application/x-font-bdf',
    'bib'           => 'text/x-bibtex',
    'bin'           => 'application/octet-stream',
    'blend'         => 'application/x-blender',
    'blender'       => 'application/x-blender',
    'bmp'           => 'image/bmp',
    'bz'            => 'application/x-bzip',
    'bz2'           => 'application/x-bzip',
    'c'             => 'text/x-csrc',
    'c++'           => 'text/x-c++src',
    'cc'            => 'text/x-c++src',
    'cdf'           => 'application/x-netcdf',
    'cdr'           => 'application/vnd.corel-draw',
    'cer'           => 'application/x-x509-ca-cert',
    'cert'          => 'application/x-x509-ca-cert',
    'cgi'           => 'application/x-cgi',
    'cgm'           => 'image/cgm',
    'chrt'          => 'application/x-kchart',
    'class'         => 'application/x-java',
    'cls'           => 'text/x-tex',
    'cpio'          => 'application/x-cpio',
    'cpio.gz'       => 'application/x-cpio-compressed',
    'cpp'           => 'text/x-c++src',
    'cpt'           => 'application/mac-compactpro',
    'crt'           => 'application/x-x509-ca-cert',
    'cs'            => 'text/x-csharp',
    'csh'           => 'application/x-shellscript',
    'css'           => 'text/css',
    'csv'           => 'text/x-comma-separated-values',
    'cur'           => 'image/x-win-bitmap',
    'cxx'           => 'text/x-c++src',
    'dat'           => 'video/mpeg',
    'dbf'           => 'application/x-dbase',
    'dc'            => 'application/x-dc-rom',
    'dcl'           => 'text/x-dcl',
    'dcm'           => 'image/x-dcm',
    'dcr'           => 'application/x-director',
    'deb'           => 'application/x-deb',
    'der'           => 'application/x-x509-ca-cert',
    'desktop'       => 'application/x-desktop',
    'dia'           => 'application/x-dia-diagram',
    'diff'          => 'text/x-patch',
    'dir'           => 'application/x-director',
    'djv'           => 'image/vnd.djvu',
    'djvu'          => 'image/vnd.djvu',
    'dll'           => 'application/octet-stream',
    'dms'           => 'application/octet-stream',
    'doc'           => 'application/msword',
    'dsl'           => 'text/x-dsl',
    'dtd'           => 'text/x-dtd',
    'dvi'           => 'application/x-dvi',
    'dwg'           => 'image/vnd.dwg',
    'dxf'           => 'image/vnd.dxf',
    'dxr'           => 'application/x-director',
    'egon'          => 'application/x-egon',
    'el'            => 'text/x-emacs-lisp',
    'eps'           => 'image/x-eps',
    'epsf'          => 'image/x-eps',
    'epsi'          => 'image/x-eps',
    'etheme'        => 'application/x-e-theme',
    'etx'           => 'text/x-setext',
    'exe'           => 'application/x-executable',
    'ez'            => 'application/andrew-inset',
    'f'             => 'text/x-fortran',
    'fig'           => 'image/x-xfig',
    'fits'          => 'image/x-fits',
    'flac'          => 'audio/x-flac',
    'flc'           => 'video/x-flic',
    'fli'           => 'video/x-flic',
    'flw'           => 'application/x-kivio',
    'fo'            => 'text/x-xslfo',
    'g3'            => 'image/fax-g3',
    'gb'            => 'application/x-gameboy-rom',
    'gcrd'          => 'text/x-vcard',
    'gen'           => 'application/x-genesis-rom',
    'gg'            => 'application/x-sms-rom',
    'gif'           => 'image/gif',
    'glade'         => 'application/x-glade',
    'gmo'           => 'application/x-gettext-translation',
    'gnc'           => 'application/x-gnucash',
    'gnucash'       => 'application/x-gnucash',
    'gnumeric'      => 'application/x-gnumeric',
    'gra'           => 'application/x-graphite',
    'gsf'           => 'application/x-font-type1',
    'gtar'          => 'application/x-gtar',
    'gz'            => 'application/x-gzip',
    'h'             => 'text/x-chdr',
    'h++'           => 'text/x-chdr',
    'hdf'           => 'application/x-hdf',
    'hh'            => 'text/x-c++hdr',
    'hp'            => 'text/x-chdr',
    'hpgl'          => 'application/vnd.hp-hpgl',
    'hqx'           => 'application/mac-binhex40',
    'hs'            => 'text/x-haskell',
    'htm'           => 'text/html',
    'html'          => 'text/html',
    'icb'           => 'image/x-icb',
    'ice'           => 'x-conference/x-cooltalk',
    'ico'           => 'image/x-ico',
    'ics'           => 'text/calendar',
    'idl'           => 'text/x-idl',
    'ief'           => 'image/ief',
    'ifb'           => 'text/calendar',
    'iff'           => 'image/x-iff',
    'iges'          => 'model/iges',
    'igs'           => 'model/iges',
    'ilbm'          => 'image/x-ilbm',
    'iso'           => 'application/x-cd-image',
    'it'            => 'audio/x-it',
    'jar'           => 'application/x-jar',
    'java'          => 'text/x-java',
    'jng'           => 'image/x-jng',
    'jp2'           => 'image/jpeg2000',
    'jpe'           => 'image/jpeg',
    'jpeg'          => 'image/jpeg',
    'jpg'           => 'image/jpeg',
    'jpr'           => 'application/x-jbuilder-project',
    'jpx'           => 'application/x-jbuilder-project',
    'js'            => 'application/x-javascript',
    'kar'           => 'audio/midi',
    'karbon'        => 'application/x-karbon',
    'kdelnk'        => 'application/x-desktop',
    'kfo'           => 'application/x-kformula',
    'kil'           => 'application/x-killustrator',
    'kon'           => 'application/x-kontour',
    'kpm'           => 'application/x-kpovmodeler',
    'kpr'           => 'application/x-kpresenter',
    'kpt'           => 'application/x-kpresenter',
    'kra'           => 'application/x-krita',
    'ksp'           => 'application/x-kspread',
    'kud'           => 'application/x-kugar',
    'kwd'           => 'application/x-kword',
    'kwt'           => 'application/x-kword',
    'la'            => 'application/x-shared-library-la',
    'latex'         => 'application/x-latex',
    'lha'           => 'application/x-lha',
    'lhs'           => 'text/x-literate-haskell',
    'lhz'           => 'application/x-lhz',
    'log'           => 'text/x-log',
    'ltx'           => 'text/x-tex',
    'lwo'           => 'image/x-lwo',
    'lwob'          => 'image/x-lwo',
    'lws'           => 'image/x-lws',
    'lyx'           => 'application/x-lyx',
    'lzh'           => 'application/x-lha',
    'lzo'           => 'application/x-lzop',
    'm'             => 'text/x-objcsrc',
    'm15'           => 'audio/x-mod',
    'm3u'           => 'audio/x-mpegurl',
    'man'           => 'application/x-troff-man',
    'md'            => 'application/x-genesis-rom',
    'me'            => 'text/x-troff-me',
    'mesh'          => 'model/mesh',
    'mgp'           => 'application/x-magicpoint',
    'mid'           => 'audio/midi',
    'midi'          => 'audio/midi',
    'mif'           => 'application/x-mif',
    'mkv'           => 'application/x-matroska',
    'mm'            => 'text/x-troff-mm',
    'mml'           => 'text/mathml',
    'mng'           => 'video/x-mng',
    'moc'           => 'text/x-moc',
    'mod'           => 'audio/x-mod',
    'moov'          => 'video/quicktime',
    'mov'           => 'video/quicktime',
    'movie'         => 'video/x-sgi-movie',
    'mp2'           => 'video/mpeg',
    'mp3'           => 'audio/x-mp3',
    'mpe'           => 'video/mpeg',
    'mpeg'          => 'video/mpeg',
    'mpg'           => 'video/mpeg',
    'mpga'          => 'audio/mpeg',
    'ms'            => 'text/x-troff-ms',
    'msh'           => 'model/mesh',
    'msod'          => 'image/x-msod',
    'msx'           => 'application/x-msx-rom',
    'mtm'           => 'audio/x-mod',
    'mxu'           => 'video/vnd.mpegurl',
    'n64'           => 'application/x-n64-rom',
    'nc'            => 'application/x-netcdf',
    'nes'           => 'application/x-nes-rom',
    'nsv'           => 'video/x-nsv',
    'o'             => 'application/x-object',
    'obj'           => 'application/x-tgif',
    'oda'           => 'application/oda',
    'ogg'           => 'application/ogg',
    'old'           => 'application/x-trash',
    'oleo'          => 'application/x-oleo',
    'p'             => 'text/x-pascal',
    'p12'           => 'application/x-pkcs12',
    'p7s'           => 'application/pkcs7-signature',
    'pas'           => 'text/x-pascal',
    'patch'         => 'text/x-patch',
    'pbm'           => 'image/x-portable-bitmap',
    'pcd'           => 'image/x-photo-cd',
    'pcf'           => 'application/x-font-pcf',
    'pcf.Z'         => 'application/x-font-type1',
    'pcl'           => 'application/vnd.hp-pcl',
    'pdb'           => 'application/vnd.palm',
    'pdf'           => 'application/pdf',
    'pem'           => 'application/x-x509-ca-cert',
    'perl'          => 'application/x-perl',
    'pfa'           => 'application/x-font-type1',
    'pfb'           => 'application/x-font-type1',
    'pfx'           => 'application/x-pkcs12',
    'pgm'           => 'image/x-portable-graymap',
    'pgn'           => 'application/x-chess-pgn',
    'pgp'           => 'application/pgp',
    'php'           => 'application/x-php',
    'php3'          => 'application/x-php',
    'php4'          => 'application/x-php',
    'pict'          => 'image/x-pict',
    'pict1'         => 'image/x-pict',
    'pict2'         => 'image/x-pict',
    'pl'            => 'application/x-perl',
    'pls'           => 'audio/x-scpls',
    'pm'            => 'application/x-perl',
    'png'           => 'image/png',
    'pnm'           => 'image/x-portable-anymap',
    'po'            => 'text/x-gettext-translation',
    'pot'           => 'application/vnd.ms-powerpoint',
    'ppm'           => 'image/x-portable-pixmap',
    'pps'           => 'application/vnd.ms-powerpoint',
    'ppt'           => 'application/vnd.ms-powerpoint',
    'ppz'           => 'application/vnd.ms-powerpoint',
    'ps'            => 'application/postscript',
    'ps.gz'         => 'application/x-gzpostscript',
    'psd'           => 'image/x-psd',
    'psf'           => 'application/x-font-linux-psf',
    'psid'          => 'audio/prs.sid',
    'pw'            => 'application/x-pw',
    'py'            => 'application/x-python',
    'pyc'           => 'application/x-python-bytecode',
    'pyo'           => 'application/x-python-bytecode',
    'qif'           => 'application/x-qw',
    'qt'            => 'video/quicktime',
    'qtvr'          => 'video/quicktime',
    'ra'            => 'audio/x-pn-realaudio',
    'ram'           => 'audio/x-pn-realaudio',
    'rar'           => 'application/x-rar',
    'ras'           => 'image/x-cmu-raster',
    'rdf'           => 'text/rdf',
    'rej'           => 'application/x-reject',
    'rgb'           => 'image/x-rgb',
    'rle'           => 'image/rle',
    'rm'            => 'audio/x-pn-realaudio',
    'roff'          => 'application/x-troff',
    'rpm'           => 'application/x-rpm',
    'rss'           => 'text/rss',
    'rtf'           => 'application/rtf',
    'rtx'           => 'text/richtext',
    's3m'           => 'audio/x-s3m',
    'sam'           => 'application/x-amipro',
    'scm'           => 'text/x-scheme',
    'sda'           => 'application/vnd.stardivision.draw',
    'sdc'           => 'application/vnd.stardivision.calc',
    'sdd'           => 'application/vnd.stardivision.impress',
    'sdp'           => 'application/vnd.stardivision.impress',
    'sds'           => 'application/vnd.stardivision.chart',
    'sdw'           => 'application/vnd.stardivision.writer',
    'sgi'           => 'image/x-sgi',
    'sgl'           => 'application/vnd.stardivision.writer',
    'sgm'           => 'text/sgml',
    'sgml'          => 'text/sgml',
    'sh'            => 'application/x-shellscript',
    'shar'          => 'application/x-shar',
    'shtml'         => 'text/html',
    'siag'          => 'application/x-siag',
    'sid'           => 'audio/prs.sid',
    'sik'           => 'application/x-trash',
    'silo'          => 'model/mesh',
    'sit'           => 'application/x-stuffit',
    'skd'           => 'application/x-koan',
    'skm'           => 'application/x-koan',
    'skp'           => 'application/x-koan',
    'skt'           => 'application/x-koan',
    'slk'           => 'text/spreadsheet',
    'smd'           => 'application/vnd.stardivision.mail',
    'smf'           => 'application/vnd.stardivision.math',
    'smi'           => 'application/smil',
    'smil'          => 'application/smil',
    'sml'           => 'application/smil',
    'sms'           => 'application/x-sms-rom',
    'snd'           => 'audio/basic',
    'so'            => 'application/x-sharedlib',
    'spd'           => 'application/x-font-speedo',
    'spl'           => 'application/x-futuresplash',
    'sql'           => 'text/x-sql',
    'src'           => 'application/x-wais-source',
    'stc'           => 'application/vnd.sun.xml.calc.template',
    'std'           => 'application/vnd.sun.xml.draw.template',
    'sti'           => 'application/vnd.sun.xml.impress.template',
    'stm'           => 'audio/x-stm',
    'stw'           => 'application/vnd.sun.xml.writer.template',
    'sty'           => 'text/x-tex',
    'sun'           => 'image/x-sun-raster',
    'sv4cpio'       => 'application/x-sv4cpio',
    'sv4crc'        => 'application/x-sv4crc',
    'svg'           => 'image/svg+xml',
    'swf'           => 'application/x-shockwave-flash',
    'sxc'           => 'application/vnd.sun.xml.calc',
    'sxd'           => 'application/vnd.sun.xml.draw',
    'sxg'           => 'application/vnd.sun.xml.writer.global',
    'sxi'           => 'application/vnd.sun.xml.impress',
    'sxm'           => 'application/vnd.sun.xml.math',
    'sxw'           => 'application/vnd.sun.xml.writer',
    'sylk'          => 'text/spreadsheet',
    't'             => 'application/x-troff',
    'tar'           => 'application/x-tar',
    'tar.Z'         => 'application/x-tarz',
    'tar.bz'        => 'application/x-bzip-compressed-tar',
    'tar.bz2'       => 'application/x-bzip-compressed-tar',
    'tar.gz'        => 'application/x-compressed-tar',
    'tar.lzo'       => 'application/x-tzo',
    'tcl'           => 'text/x-tcl',
    'tex'           => 'text/x-tex',
    'texi'          => 'text/x-texinfo',
    'texinfo'       => 'text/x-texinfo',
    'tga'           => 'image/x-tga',
    'tgz'           => 'application/x-compressed-tar',
    'theme'         => 'application/x-theme',
    'tif'           => 'image/tiff',
    'tiff'          => 'image/tiff',
    'tk'            => 'text/x-tcl',
    'torrent'       => 'application/x-bittorrent',
    'tr'            => 'application/x-troff',
    'ts'            => 'application/x-linguist',
    'tsv'           => 'text/tab-separated-values',
    'ttf'           => 'application/x-font-ttf',
    'txt'           => 'text/plain',
    'tzo'           => 'application/x-tzo',
    'ui'            => 'application/x-designer',
    'uil'           => 'text/x-uil',
    'ult'           => 'audio/x-mod',
    'uni'           => 'audio/x-mod',
    'uri'           => 'text/x-uri',
    'url'           => 'text/x-uri',
    'ustar'         => 'application/x-ustar',
    'vcd'           => 'application/x-cdlink',
    'vcf'           => 'text/x-vcalendar',
    'vcs'           => 'text/x-vcalendar',
    'vct'           => 'text/x-vcard',
    'vfb'           => 'text/calendar',
    'vob'           => 'video/mpeg',
    'voc'           => 'audio/x-voc',
    'vor'           => 'application/vnd.stardivision.writer',
    'vrml'          => 'model/vrml',
    'vsd'           => 'application/vnd.visio',
    'wav'           => 'audio/x-wav',
    'wax'           => 'audio/x-ms-wax',
    'wb1'           => 'application/x-quattropro',
    'wb2'           => 'application/x-quattropro',
    'wb3'           => 'application/x-quattropro',
    'wbmp'          => 'image/vnd.wap.wbmp',
    'wbxml'         => 'application/vnd.wap.wbxml',
    'wk1'           => 'application/vnd.lotus-1-2-3',
    'wk3'           => 'application/vnd.lotus-1-2-3',
    'wk4'           => 'application/vnd.lotus-1-2-3',
    'wks'           => 'application/vnd.lotus-1-2-3',
    'wm'            => 'video/x-ms-wm',
    'wma'           => 'audio/x-ms-wma',
    'wmd'           => 'application/x-ms-wmd',
    'wmf'           => 'image/x-wmf',
    'wml'           => 'text/vnd.wap.wml',
    'wmlc'          => 'application/vnd.wap.wmlc',
    'wmls'          => 'text/vnd.wap.wmlscript',
    'wmlsc'         => 'application/vnd.wap.wmlscriptc',
    'wmv'           => 'video/x-ms-wmv',
    'wmx'           => 'video/x-ms-wmx',
    'wmz'           => 'application/x-ms-wmz',
    'wpd'           => 'application/wordperfect',
    'wpg'           => 'application/x-wpg',
    'wri'           => 'application/x-mswrite',
    'wrl'           => 'model/vrml',
    'wvx'           => 'video/x-ms-wvx',
    'xac'           => 'application/x-gnucash',
    'xbel'          => 'application/x-xbel',
    'xbm'           => 'image/x-xbitmap',
    'xcf'           => 'image/x-xcf',
    'xcf.bz2'       => 'image/x-compressed-xcf',
    'xcf.gz'        => 'image/x-compressed-xcf',
    'xht'           => 'application/xhtml+xml',
    'xhtml'         => 'application/xhtml+xml',
    'xi'            => 'audio/x-xi',
    'xla'           => 'application/vnd.ms-excel',
    'xlc'           => 'application/vnd.ms-excel',
    'xld'           => 'application/vnd.ms-excel',
    'xll'           => 'application/vnd.ms-excel',
    'xlm'           => 'application/vnd.ms-excel',
    'xls'           => 'application/vnd.ms-excel',
    'xlt'           => 'application/vnd.ms-excel',
    'xlw'           => 'application/vnd.ms-excel',
    'xm'            => 'audio/x-xm',
    'xml'           => 'text/xml',
    'xpm'           => 'image/x-xpixmap',
    'xsl'           => 'text/x-xslt',
    'xslfo'         => 'text/x-xslfo',
    'xslt'          => 'text/x-xslt',
    'xwd'           => 'image/x-xwindowdump',
    'xyz'           => 'chemical/x-xyz',
    'zabw'          => 'application/x-abiword',
    'zip'           => 'application/zip',
    'zoo'           => 'application/x-zoo',
    '123'           => 'application/vnd.lotus-1-2-3',
    '669'           => 'audio/x-mod'
);




More information about the commits mailing list