public static function analyzeData($data, $magic_db = null,
                                       $opts = array())
    {
        /* If the PHP Mimetype extension is available, use that. */
        if (Horde_Util::extensionExists('fileinfo')) {
            $res = empty($magic_db)
                ? @finfo_open(FILEINFO_MIME)
                : @finfo_open(FILEINFO_MIME, $magic_db);

            if (!$res) {
                return false;
            }

            $type = trim(finfo_buffer($res, $data));
            finfo_close($res);

            /* Remove any additional information. */
            if (empty($opts['nostrip'])) {
                if (($pos = strpos($type, ';')) !== false) {
                    $type = rtrim(substr($type, 0, $pos));
                }

                if (($pos = strpos($type, ',')) !== false) {
                    $type = rtrim(substr($type, 0, $pos));
                }
            }

            return $type;
        }

        return false;
    }