public function preProcess($action, &$httpVars, &$fileVars) { $repository = ConfService::getRepository(); if ($repository->detectStreamWrapper(false)) { $plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType()); $streamData = $plugin->detectStreamWrapper(true); if ($streamData["protocol"] == "ajxp.ftp" || $streamData["protocol"] == "ajxp.remotefs") { AJXP_Logger::debug("Skip decoding"); self::$skipDecoding = true; } } AJXP_Logger::debug("Jumploader HttpVars", $httpVars); AJXP_Logger::debug("Jumploader FileVars", $fileVars); $httpVars["dir"] = base64_decode($httpVars["dir"]); if (isset($httpVars["partitionCount"]) && intval($httpVars["partitionCount"]) > 1) { $index = $httpVars["partitionIndex"]; $realName = $fileVars["userfile_0"]["name"]; $fileId = $httpVars["fileId"]; $clientId = $httpVars["clientId"]; $fileVars["userfile_0"]["name"] = "{$clientId}.{$fileId}.{$index}"; if (intval($index) == intval($httpVars["partitionCount"]) - 1) { $httpVars["partitionRealName"] = $realName; } } }
public function preProcess($action, &$httpVars, &$fileVars) { if (isset($httpVars["simple_uploader"]) || isset($httpVars["xhr_uploader"])) { return; } $repository = ConfService::getRepository(); if ($repository->detectStreamWrapper(false)) { $plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType()); $streamData = $plugin->detectStreamWrapper(true); if ($streamData["protocol"] == "ajxp.ftp" || $streamData["protocol"] == "ajxp.remotefs") { AJXP_Logger::debug("Skip decoding"); self::$skipDecoding = true; } } AJXP_Logger::debug("Jumploader HttpVars", $httpVars); AJXP_Logger::debug("Jumploader FileVars", $fileVars); $httpVars["dir"] = base64_decode(str_replace(" ", "+", $httpVars["dir"])); if (isset($httpVars["partitionCount"]) && intval($httpVars["partitionCount"]) > 1) { AJXP_LOGGER::debug("Partitioned upload"); $index = $httpVars["partitionIndex"]; $realName = $fileVars["userfile_0"]["name"]; //$realName = $httpVars["relativePath"]; $fileId = $httpVars["fileId"]; $clientId = $httpVars["ajxp_sessid"]; $fileVars["userfile_0"]["name"] = "{$clientId}.{$fileId}.{$index}"; if (intval($index) == intval($httpVars["partitionCount"]) - 1) { $httpVars["partitionRealName"] = $realName; } } else { if (isset($httpVars["partitionCount"]) && $httpVars["partitionCount"] == 1) { $httpVars["checkRelativePath"] = true; } } }
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(false)) { $plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType()); $streamData = $plugin->detectStreamWrapper(true); if ($streamData["protocol"] == "ajxp.ftp" || $streamData["protocol"] == "ajxp.remotefs") { $this->logDebug("Skip decoding"); self::$skipDecoding = true; } $this->logDebug("Stream ", $streamData); self::$wrapperIsRemote = call_user_func(array($streamData["classname"], "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"); $plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType()); $streamData = $plugin->detectStreamWrapper(true); $dir = AJXP_Utils::decodeSecureMagic($httpVars["dir"]); $destStreamURL = $streamData["protocol"] . "://" . $repository->getId() . $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; } }