/** * Returns a parsed MIME message * * @param string $text The text of the message * * @return array An array with the MIME parsed headers and body. */ function _mimeParse(&$text) { /* Taken from Horde's MIME/Structure.php */ 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 array($structure->headers, $ret =& MIME_Structure::parse($structure)); }
function &_getICal($filename) { $requestText = ''; $handle = fopen($filename, 'r'); while (!feof($handle)) { $requestText .= fread($handle, 8192); } $mime =& MIME_Structure::parseTextMIMEMessage($requestText); $parts = $mime->contentTypeMap(); foreach ($parts as $mimeid => $conttype) { if ($conttype == 'text/calendar') { $part = $mime->getPart($mimeid); $iCalendar = new Horde_Icalendar(); $iCalendar->parsevCalendar($part->transferDecode()); return $iCalendar; } } // No iCal found return false; }