/** * @param AJXP_Node $ajxpNode * @param Boolean $isParent */ public function extractMimeHeaders(&$ajxpNode, $isParent = false) { if ($isParent) { return; } $currentNode = $ajxpNode->getUrl(); $metadata = $ajxpNode->metadata; $wrapperClassName = $ajxpNode->wrapperClassName; $noMail = true; if ($metadata["is_file"] && ($wrapperClassName == "imapAccessWrapper" || preg_match("/\\.eml\$/i", $currentNode))) { $noMail = false; } if ($wrapperClassName == "imapAccessWrapper" && !$metadata["is_file"]) { $metadata["mimestring"] = "Mailbox"; } $parsed = parse_url($currentNode); if ($noMail || isset($parsed["fragment"]) && strpos($parsed["fragment"], "attachments") === 0) { EmlParser::$currentListingOnlyEmails = FALSE; return; } if (EmlParser::$currentListingOnlyEmails === NULL) { EmlParser::$currentListingOnlyEmails = true; } if ($wrapperClassName == "imapAccessWrapper") { $cachedFile = AJXP_Cache::getItem("eml_remote", $currentNode, null, array("EmlParser", "computeCacheId")); $realFile = $cachedFile->getId(); if (!is_file($realFile)) { $cachedFile->getData(); // trigger loading! } } else { $realFile = $ajxpNode->getRealFile(); } $cacheItem = AJXP_Cache::getItem("eml_mimes", $realFile, array($this, "mimeExtractorCallback")); $data = unserialize($cacheItem->getData()); $data["ajxp_mime"] = "eml"; $data["mimestring"] = "Email"; $metadata = array_merge($metadata, $data); if ($wrapperClassName == "imapAccessWrapper" && $metadata["eml_attachments"] != "0" && strpos($_SERVER["HTTP_USER_AGENT"], "ajaxplorer-ios") !== false) { $metadata["is_file"] = false; $metadata["nodeName"] = basename($currentNode) . "#attachments"; } $ajxpNode->metadata = $metadata; }
public function dir_opendir($path, $options) { // Reset self::$attachmentsMetadata = null; $st = ''; $stream = $this->stream_open($path, 'np', $options, $st); if (!$stream) { return false; } if (empty($this->mailbox)) { // We are browsing root, we want the list of mailboxes $this->mailboxes = imap_getmailboxes($this->ih, self::$currentRef, "*"); $this->dir = count($this->mailboxes); self::$currentCount = count($this->mailboxes); $this->pos = $this->dir - 1; } else { if ($this->fragment == "attachments") { require_once AJXP_INSTALL_PATH . '/plugins/editor.eml/class.EmlParser.php'; $parser = new EmlParser("", ""); $ar = explode("#", $path); $path = array_shift($ar); // remove fragment self::$attachmentsMetadata = array(); $parser->listAttachments($path, true, self::$attachmentsMetadata); $this->dir = count(self::$attachmentsMetadata); $this->pos = $this->dir - 1; self::$currentCount = $this->dir; } else { // We are in a mailbox, we want the messages number $this->dir = imap_num_msg($this->ih); self::$currentCount = $this->dir; $this->pos = $this->dir; } } $this->stream_close(); return true; }