/** * Apply specific operation to set a node as hidden. * Can be overwritten, or will probably do nothing. * @param AJXP_Node $node */ public function setHiddenAttribute($node) { if (AJXP_MetaStreamWrapper::actualRepositoryWrapperClass($node->getRepositoryId()) == "fsAccessWrapper" && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $realPath = AJXP_MetaStreamWrapper::getRealFSReference($node->getUrl()); @shell_exec("attrib +H " . escapeshellarg($realPath)); } }
/** * @param AJXP_Node $ajxpNode * @param Boolean $isParent */ public function extractMimeHeaders(&$ajxpNode, $isParent = false) { if ($isParent) { return; } $currentNode = $ajxpNode->getUrl(); $metadata = $ajxpNode->metadata; $wrapperClassName = AJXP_MetaStreamWrapper::actualRepositoryWrapperClass($ajxpNode->getRepositoryId()); $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 preProcess($action, &$httpVars, &$fileVars) { if (isset($httpVars["simple_uploader"]) || isset($httpVars["xhr_uploader"])) { return; } $repository = ConfService::getRepository(); $driver = ConfService::loadDriverForRepository($repository); if (method_exists($driver, "storeFileToCopy")) { self::$remote = true; } if ($repository->detectStreamWrapper(true)) { $wrapperName = AJXP_MetaStreamWrapper::actualRepositoryWrapperClass($repository->getId()); if ($wrapperName == "ajxp.ftp" || $wrapperName == "ajxp.remotefs") { $this->logDebug("Skip decoding"); self::$skipDecoding = true; } $this->logDebug("Stream is", $wrapperName); self::$wrapperIsRemote = call_user_func(array($wrapperName, "isRemote")); } $this->logDebug("Jumploader HttpVars", $httpVars); $this->logDebug("Jumploader FileVars", $fileVars); $httpVars["dir"] = base64_decode(str_replace(" ", "+", $httpVars["dir"])); $index = $httpVars["partitionIndex"]; $realName = $fileVars["userfile_0"]["name"]; /* if fileId is not set, request for cross-session resume (only if the protocol is not ftp)*/ if (!isset($httpVars["fileId"])) { $this->logDebug("Trying Cross-Session Resume request"); $dir = AJXP_Utils::decodeSecureMagic($httpVars["dir"]); $repository->detectStreamWrapper(true); $context = new UserSelection($repository); $destStreamURL = $context->currentBaseUrl() . $dir; $fileHash = md5($httpVars["fileName"]); if (!self::$remote) { $resumeIndexes = array(); $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($destStreamURL)); $it->setMaxDepth(0); while ($it->valid()) { if (!$it->isDot()) { $subPathName = $it->getSubPathName(); AJXP_LOGGER::debug("Iterator SubPathName: " . $it->getSubPathName()); if (strstr($subPathName, $fileHash) != false) { $explodedSubPathName = explode('.', $subPathName); $resumeFileId = $explodedSubPathName[1]; $resumeIndexes[] = $explodedSubPathName[2]; $this->logDebug("Current Index: " . $explodedSubPathName[2]); } } $it->next(); } /* no valid temp file found. return. */ if (empty($resumeIndexes)) { $this->logDebug("No Cross-Session Resume request"); return; } AJXP_LOGGER::debug("ResumeFileID: " . $resumeFileId); AJXP_LOGGER::debug("Max Resume Index: " . max($resumeIndexes)); $nextResumeIndex = max($resumeIndexes) + 1; AJXP_LOGGER::debug("Next Resume Index: " . $nextResumeIndex); if (isset($resumeFileId)) { $this->logDebug("ResumeFileId is set. Returning values: fileId: " . $resumeFileId . ", partitionIndex: " . $nextResumeIndex); $httpVars["resumeFileId"] = $resumeFileId; $httpVars["resumePartitionIndex"] = $nextResumeIndex; } } return; } /* if the file has to be partitioned */ if (isset($httpVars["partitionCount"]) && intval($httpVars["partitionCount"]) > 1) { $this->logDebug("Partitioned upload"); $fileId = $httpVars["fileId"]; $fileHash = md5($realName); /* In order to enable cross-session resume, temp files must not depend on session. * Now named after and md5() of the original file name. */ $this->logDebug("Filename: " . $realName . ", File hash: " . $fileHash); $fileVars["userfile_0"]["name"] = "{$fileHash}.{$fileId}.{$index}"; $httpVars["lastPartition"] = false; } else { /* * If we wan to upload a folderUpload to folderServer * Temporarily,put all files in this folder to folderServer. * But a same file name may be existed in folderServer, * this can cause error of uploading. * * We rename this file by his relativePath. At the postProcess session, we will use this name * to copy to right location * */ $file_tmp_md5 = md5($httpVars["relativePath"]); $fileVars["userfile_0"]["name"] = $file_tmp_md5; } /* if we received the last partition */ if (intval($index) == intval($httpVars["partitionCount"]) - 1) { $httpVars["lastPartition"] = true; $httpVars["partitionRealName"] = $realName; } }