public function applyAction($actionName, $httpVars, $fileVars) { $messages = ConfService::getMessages(); if ($actionName == "index") { $repository = ConfService::getRepository(); $repositoryId = $repository->getId(); $userSelection = new UserSelection($repository, $httpVars); if ($userSelection->isEmpty()) { $userSelection->addFile("/"); } $nodes = $userSelection->buildNodes($repository->driverInstance); if (isset($httpVars["verbose"]) && $httpVars["verbose"] == "true") { $this->verboseIndexation = true; } if (ConfService::backgroundActionsSupported() && !ConfService::currentContextIsCommandLine()) { AJXP_Controller::applyActionInBackground($repositoryId, "index", $httpVars); AJXP_XMLWriter::header(); AJXP_XMLWriter::triggerBgAction("check_index_status", array("repository_id" => $repositoryId), sprintf($messages["core.index.8"], $nodes[0]->getPath()), true, 2); if (!isset($httpVars["inner_apply"])) { AJXP_XMLWriter::close(); } return null; } // GIVE BACK THE HAND TO USER session_write_close(); foreach ($nodes as $node) { $dir = $node->getPath() == "/" || is_dir($node->getUrl()); // SIMPLE FILE if (!$dir) { try { $this->logDebug("Indexing - node.index " . $node->getUrl()); AJXP_Controller::applyHook("node.index", array($node)); } catch (Exception $e) { $this->logDebug("Error Indexing Node " . $node->getUrl() . " (" . $e->getMessage() . ")"); } } else { try { $this->recursiveIndexation($node); } catch (Exception $e) { $this->logDebug("Indexation of " . $node->getUrl() . " interrupted by error: (" . $e->getMessage() . ")"); } } } } else { if ($actionName == "check_index_status") { $repoId = $httpVars["repository_id"]; list($status, $message) = $this->getIndexStatus(ConfService::getRepositoryById($repoId), AuthService::getLoggedUser()); if (!empty($status)) { AJXP_XMLWriter::header(); AJXP_XMLWriter::triggerBgAction("check_index_status", array("repository_id" => $repoId), $message, true, 3); AJXP_XMLWriter::close(); } else { AJXP_XMLWriter::header(); AJXP_XMLWriter::triggerBgAction("info_message", array(), $messages["core.index.5"], true, 5); AJXP_XMLWriter::close(); } } } return null; }
/** * @param String $action * @param Array $httpVars * @param Array $fileVars * @throws Exception */ public function receiveAction($action, $httpVars, $fileVars) { //VAR CREATION OUTSIDE OF ALL CONDITIONS, THEY ARE "MUST HAVE" VAR !! $messages = ConfService::getMessages(); $repository = ConfService::getRepository(); $userSelection = new UserSelection($repository, $httpVars); $nodes = $userSelection->buildNodes(); $currentDirPath = AJXP_Utils::safeDirname($userSelection->getUniqueNode()->getPath()); $currentDirPath = rtrim($currentDirPath, "/") . "/"; $currentDirUrl = $userSelection->currentBaseUrl() . $currentDirPath; if (empty($httpVars["compression_id"])) { $compressionId = sha1(rand()); $httpVars["compression_id"] = $compressionId; } else { $compressionId = $httpVars["compression_id"]; } $progressCompressionFileName = $this->getPluginCacheDir(false, true) . DIRECTORY_SEPARATOR . "progressCompressionID-" . $compressionId . ".txt"; if (empty($httpVars["extraction_id"])) { $extractId = sha1(rand()); $httpVars["extraction_id"] = $extractId; } else { $extractId = $httpVars["extraction_id"]; } $progressExtractFileName = $this->getPluginCacheDir(false, true) . DIRECTORY_SEPARATOR . "progressExtractID-" . $extractId . ".txt"; if ($action == "compression") { $archiveName = AJXP_Utils::sanitize(AJXP_Utils::decodeSecureMagic($httpVars["archive_name"]), AJXP_SANITIZE_FILENAME); $archiveFormat = $httpVars["type_archive"]; $tabTypeArchive = array(".tar", ".tar.gz", ".tar.bz2"); $acceptedExtension = false; foreach ($tabTypeArchive as $extensionArchive) { if ($extensionArchive == $archiveFormat) { $acceptedExtension = true; break; } } if ($acceptedExtension == false) { file_put_contents($progressCompressionFileName, "Error : " . $messages["compression.16"]); throw new AJXP_Exception($messages["compression.16"]); } $typeArchive = $httpVars["type_archive"]; //if we can run in background we do it if (ConfService::backgroundActionsSupported() && !ConfService::currentContextIsCommandLine()) { $archivePath = $currentDirPath . $archiveName; file_put_contents($progressCompressionFileName, $messages["compression.5"]); AJXP_Controller::applyActionInBackground($repository->getId(), "compression", $httpVars); AJXP_XMLWriter::header(); AJXP_XMLWriter::triggerBgAction("check_compression_status", array("repository_id" => $repository->getId(), "compression_id" => $compressionId, "archive_path" => SystemTextEncoding::toUTF8($archivePath)), $messages["compression.5"], true, 2); AJXP_XMLWriter::close(); return null; } else { $maxAuthorizedSize = 4294967296; $currentDirUrlLength = strlen($currentDirUrl); $tabFolders = array(); $tabAllRecursiveFiles = array(); $tabFilesNames = array(); foreach ($nodes as $node) { $nodeUrl = $node->getUrl(); if (is_file($nodeUrl) && filesize($nodeUrl) < $maxAuthorizedSize) { array_push($tabAllRecursiveFiles, $nodeUrl); array_push($tabFilesNames, substr($nodeUrl, $currentDirUrlLength)); } if (is_dir($nodeUrl)) { array_push($tabFolders, $nodeUrl); } } //DO A FOREACH OR IT'S GONNA HAVE SOME SAMES FILES NAMES foreach ($tabFolders as $value) { $dossiers = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($value)); foreach ($dossiers as $file) { if ($file->isDir()) { continue; } array_push($tabAllRecursiveFiles, $file->getPathname()); array_push($tabFilesNames, substr($file->getPathname(), $currentDirUrlLength)); } } //WE STOP IF IT'S JUST AN EMPTY FOLDER OR NO FILES if (empty($tabFilesNames)) { file_put_contents($progressCompressionFileName, "Error : " . $messages["compression.17"]); throw new AJXP_Exception($messages["compression.17"]); } try { $tmpArchiveName = tempnam(AJXP_Utils::getAjxpTmpDir(), "tar-compression") . ".tar"; $archive = new PharData($tmpArchiveName); } catch (Exception $e) { file_put_contents($progressCompressionFileName, "Error : " . $e->getMessage()); throw $e; } $counterCompression = 0; //THE TWO ARRAY ARE MERGED FOR THE FOREACH LOOP $tabAllFiles = array_combine($tabAllRecursiveFiles, $tabFilesNames); foreach ($tabAllFiles as $fullPath => $fileName) { try { $archive->addFile(AJXP_MetaStreamWrapper::getRealFSReference($fullPath), $fileName); $counterCompression++; file_put_contents($progressCompressionFileName, sprintf($messages["compression.6"], round($counterCompression / count($tabAllFiles) * 100, 0, PHP_ROUND_HALF_DOWN) . " %")); } catch (Exception $e) { unlink($tmpArchiveName); file_put_contents($progressCompressionFileName, "Error : " . $e->getMessage()); throw $e; } } $finalArchive = $tmpArchiveName; if ($typeArchive != ".tar") { $archiveTypeCompress = substr(strrchr($typeArchive, "."), 1); file_put_contents($progressCompressionFileName, sprintf($messages["compression.7"], strtoupper($archiveTypeCompress))); if ($archiveTypeCompress == "gz") { $archive->compress(Phar::GZ); } elseif ($archiveTypeCompress == "bz2") { $archive->compress(Phar::BZ2); } $finalArchive = $tmpArchiveName . "." . $archiveTypeCompress; } $destArchive = AJXP_MetaStreamWrapper::getRealFSReference($currentDirUrl . $archiveName); rename($finalArchive, $destArchive); AJXP_Controller::applyHook("node.before_create", array($destArchive, filesize($destArchive))); if (file_exists($tmpArchiveName)) { unlink($tmpArchiveName); unlink(substr($tmpArchiveName, 0, -4)); } $newNode = new AJXP_Node($currentDirUrl . $archiveName); AJXP_Controller::applyHook("node.change", array(null, $newNode, false)); file_put_contents($progressCompressionFileName, "SUCCESS"); } } elseif ($action == "check_compression_status") { $archivePath = AJXP_Utils::decodeSecureMagic($httpVars["archive_path"]); $progressCompression = file_get_contents($progressCompressionFileName); $substrProgressCompression = substr($progressCompression, 0, 5); if ($progressCompression != "SUCCESS" && $substrProgressCompression != "Error") { AJXP_XMLWriter::header(); AJXP_XMLWriter::triggerBgAction("check_compression_status", array("repository_id" => $repository->getId(), "compression_id" => $compressionId, "archive_path" => SystemTextEncoding::toUTF8($archivePath)), $progressCompression, true, 5); AJXP_XMLWriter::close(); } elseif ($progressCompression == "SUCCESS") { $newNode = new AJXP_Node($userSelection->currentBaseUrl() . $archivePath); $nodesDiffs = array("ADD" => array($newNode), "REMOVE" => array(), "UPDATE" => array()); AJXP_Controller::applyHook("node.change", array(null, $newNode, false)); AJXP_XMLWriter::header(); AJXP_XMLWriter::sendMessage($messages["compression.8"], null); AJXP_XMLWriter::writeNodesDiff($nodesDiffs, true); AJXP_XMLWriter::close(); if (file_exists($progressCompressionFileName)) { unlink($progressCompressionFileName); } } elseif ($substrProgressCompression == "Error") { AJXP_XMLWriter::header(); AJXP_XMLWriter::sendMessage(null, $progressCompression); AJXP_XMLWriter::close(); if (file_exists($progressCompressionFileName)) { unlink($progressCompressionFileName); } } } elseif ($action == "extraction") { $fileArchive = AJXP_Utils::sanitize(AJXP_Utils::decodeSecureMagic($httpVars["file"]), AJXP_SANITIZE_DIRNAME); $fileArchive = substr(strrchr($fileArchive, DIRECTORY_SEPARATOR), 1); $authorizedExtension = array("tar" => 4, "gz" => 7, "bz2" => 8); $acceptedArchive = false; $extensionLength = 0; $counterExtract = 0; $currentAllPydioPath = $currentDirUrl . $fileArchive; $pharCurrentAllPydioPath = "phar://" . AJXP_MetaStreamWrapper::getRealFSReference($currentAllPydioPath); $pathInfoCurrentAllPydioPath = pathinfo($currentAllPydioPath, PATHINFO_EXTENSION); //WE TAKE ONLY TAR, TAR.GZ AND TAR.BZ2 ARCHIVES foreach ($authorizedExtension as $extension => $strlenExtension) { if ($pathInfoCurrentAllPydioPath == $extension) { $acceptedArchive = true; $extensionLength = $strlenExtension; break; } } if ($acceptedArchive == false) { file_put_contents($progressExtractFileName, "Error : " . $messages["compression.15"]); throw new AJXP_Exception($messages["compression.15"]); } $onlyFileName = substr($fileArchive, 0, -$extensionLength); $lastPosOnlyFileName = strrpos($onlyFileName, "-"); $tmpOnlyFileName = substr($onlyFileName, 0, $lastPosOnlyFileName); $counterDuplicate = substr($onlyFileName, $lastPosOnlyFileName + 1); if (!is_int($lastPosOnlyFileName) || !is_int($counterDuplicate)) { $tmpOnlyFileName = $onlyFileName; $counterDuplicate = 1; } while (file_exists($currentDirUrl . $onlyFileName)) { $onlyFileName = $tmpOnlyFileName . "-" . $counterDuplicate; $counterDuplicate++; } if (ConfService::backgroundActionsSupported() && !ConfService::currentContextIsCommandLine()) { file_put_contents($progressExtractFileName, $messages["compression.12"]); AJXP_Controller::applyActionInBackground($repository->getId(), "extraction", $httpVars); AJXP_XMLWriter::header(); AJXP_XMLWriter::triggerBgAction("check_extraction_status", array("repository_id" => $repository->getId(), "extraction_id" => $extractId, "currentDirUrl" => $currentDirUrl, "onlyFileName" => $onlyFileName), $messages["compression.12"], true, 2); AJXP_XMLWriter::close(); return null; } mkdir($currentDirUrl . $onlyFileName, 0777, true); chmod(AJXP_MetaStreamWrapper::getRealFSReference($currentDirUrl . $onlyFileName), 0777); try { $archive = new PharData(AJXP_MetaStreamWrapper::getRealFSReference($currentAllPydioPath)); $fichiersArchive = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($pharCurrentAllPydioPath)); foreach ($fichiersArchive as $file) { $fileGetPathName = $file->getPathname(); if ($file->isDir()) { continue; } $fileNameInArchive = substr(strstr($fileGetPathName, $fileArchive), strlen($fileArchive) + 1); try { $archive->extractTo(AJXP_MetaStreamWrapper::getRealFSReference($currentDirUrl . $onlyFileName), $fileNameInArchive, false); } catch (Exception $e) { file_put_contents($progressExtractFileName, "Error : " . $e->getMessage()); throw new AJXP_Exception($e); } $counterExtract++; file_put_contents($progressExtractFileName, sprintf($messages["compression.13"], round($counterExtract / $archive->count() * 100, 0, PHP_ROUND_HALF_DOWN) . " %")); } } catch (Exception $e) { file_put_contents($progressExtractFileName, "Error : " . $e->getMessage()); throw new AJXP_Exception($e); } file_put_contents($progressExtractFileName, "SUCCESS"); $newNode = new AJXP_Node($currentDirUrl . $onlyFileName); AJXP_Controller::findActionAndApply("index", array("file" => $newNode->getPath()), array()); } elseif ($action == "check_extraction_status") { $currentDirUrl = $httpVars["currentDirUrl"]; $onlyFileName = $httpVars["onlyFileName"]; $progressExtract = file_get_contents($progressExtractFileName); $substrProgressExtract = substr($progressExtract, 0, 5); if ($progressExtract != "SUCCESS" && $progressExtract != "INDEX" && $substrProgressExtract != "Error") { AJXP_XMLWriter::header(); AJXP_XMLWriter::triggerBgAction("check_extraction_status", array("repository_id" => $repository->getId(), "extraction_id" => $extractId, "currentDirUrl" => $currentDirUrl, "onlyFileName" => $onlyFileName), $progressExtract, true, 4); AJXP_XMLWriter::close(); } elseif ($progressExtract == "SUCCESS") { $newNode = new AJXP_Node($currentDirUrl . $onlyFileName); $nodesDiffs = array("ADD" => array($newNode), "REMOVE" => array(), "UPDATE" => array()); AJXP_Controller::applyHook("node.change", array(null, $newNode, false)); AJXP_XMLWriter::header(); AJXP_XMLWriter::sendMessage(sprintf($messages["compression.14"], $onlyFileName), null); AJXP_XMLWriter::triggerBgAction("check_index_status", array("repository_id" => $newNode->getRepositoryId()), "starting indexation", true, 5); AJXP_XMLWriter::writeNodesDiff($nodesDiffs, true); AJXP_XMLWriter::close(); if (file_exists($progressExtractFileName)) { unlink($progressExtractFileName); } } elseif ($substrProgressExtract == "Error") { AJXP_XMLWriter::header(); AJXP_XMLWriter::sendMessage(null, $progressExtract); AJXP_XMLWriter::close(); if (file_exists($progressExtractFileName)) { unlink($progressExtractFileName); } } } }
public function editMeta($actionName, $httpVars, $fileVars) { if (is_a($this->accessDriver, "demoAccessDriver")) { throw new Exception("Write actions are disabled in demo mode!"); } $repo = $this->accessDriver->repository; $user = AuthService::getLoggedUser(); if (!AuthService::usersEnabled() && $user != null && !$user->canWrite($repo->getId())) { throw new Exception("You have no right on this action."); } $selection = new UserSelection($repo, $httpVars); $nodes = $selection->buildNodes(); $nodesDiffs = array(); $def = $this->getMetaDefinition(); foreach ($nodes as $ajxpNode) { $newValues = array(); //$ajxpNode->setDriver($this->accessDriver); AJXP_Controller::applyHook("node.before_change", array(&$ajxpNode)); foreach ($def as $key => $data) { if (isset($httpVars[$key])) { $newValues[$key] = AJXP_Utils::decodeSecureMagic($httpVars[$key]); if ($data["type"] == "tags") { $this->updateTags(AJXP_Utils::decodeSecureMagic($httpVars[$key])); } } else { if (!isset($original)) { $original = $ajxpNode->retrieveMetadata("users_meta", false, AJXP_METADATA_SCOPE_GLOBAL); } if (isset($original) && isset($original[$key])) { $newValues[$key] = $original[$key]; } } } $ajxpNode->setMetadata("users_meta", $newValues, false, AJXP_METADATA_SCOPE_GLOBAL); AJXP_Controller::applyHook("node.meta_change", array($ajxpNode)); $nodesDiffs[$ajxpNode->getPath()] = $ajxpNode; } AJXP_XMLWriter::header(); AJXP_XMLWriter::writeNodesDiff(array("UPDATE" => $nodesDiffs), true); AJXP_XMLWriter::close(); }
/** * @param array $httpVars * @param UserSelection $userSelection * @return int * @throws Exception */ public function filterHttpVarsForLeafPath(&$httpVars, $userSelection) { // ANALYSE SELECTION // TO CREATE PROPER FILTER / PATH FOR SHARED REPO $httpVars["minisite"] = true; $httpVars["selection"] = true; $setFilter = false; if ($userSelection->isUnique()) { $node = $userSelection->getUniqueNode(); $node->loadNodeInfo(); if ($node->isLeaf()) { $setFilter = true; $httpVars["file"] = "/"; $httpVars["nodes"] = array("/"); } } else { $setFilter = true; } $nodes = $userSelection->buildNodes(); $hasDir = false; $hasFile = false; foreach ($nodes as $n) { $n->loadNodeInfo(); if ($n->isLeaf()) { $hasFile = true; } else { $hasDir = true; } } if ($hasDir && !$this->getAuthorization("folder", "minisite") || $hasFile && !$this->getAuthorization("file")) { throw new Exception(103); } if ($setFilter) { // Either it's a file, or many nodes are shared $httpVars["filter_nodes"] = $nodes; } if (!isset($httpVars["repo_label"])) { $first = $userSelection->getUniqueNode(); $httpVars["repo_label"] = SystemTextEncoding::toUTF8($first->getLabel()); } }
/** * @param $httpVars * @param Repository $repository * @param AbstractAccessDriver $accessDriver * @return mixed An array containing the hash (0) and the generated url (1) */ public function createSharedMinisite($httpVars, $repository, $accessDriver) { $uniqueUser = null; if (isset($httpVars["repository_id"]) && isset($httpVars["guest_user_id"])) { $existingData = $this->getShareStore()->loadShare($httpVars["hash"]); $existingU = ""; if (isset($existingData["PRELOG_USER"])) { $existingU = $existingData["PRELOG_USER"]; } else { if (isset($existingData["PRESET_LOGIN"])) { $existingU = $existingData["PRESET_LOGIN"]; } } $uniqueUser = $httpVars["guest_user_id"]; if (isset($httpVars["guest_user_pass"]) && strlen($httpVars["guest_user_pass"]) && $uniqueUser == $existingU) { //$userPass = $httpVars["guest_user_pass"]; // UPDATE GUEST USER PASS HERE AuthService::updatePassword($uniqueUser, $httpVars["guest_user_pass"]); } else { if (isset($httpVars["guest_user_pass"]) && $httpVars["guest_user_pass"] == "") { } else { if (isset($existingData["PRESET_LOGIN"])) { $httpVars["KEEP_PRESET_LOGIN"] = true; } } } } else { if (isset($httpVars["create_guest_user"])) { // Create a guest user $userId = substr(md5(time()), 0, 12); $pref = $this->getFilteredOption("SHARED_USERS_TMP_PREFIX", $this->repository->getId()); if (!empty($pref)) { $userId = $pref . $userId; } if (!empty($httpVars["guest_user_pass"])) { $userPass = $httpVars["guest_user_pass"]; } else { $userPass = substr(md5(time()), 13, 24); } $uniqueUser = $userId; } } if (isset($uniqueUser)) { if (isset($userPass)) { $httpVars["user_pass_0"] = $httpVars["shared_pass"] = $userPass; } $httpVars["user_0"] = $uniqueUser; $httpVars["entry_type_0"] = "user"; $httpVars["right_read_0"] = isset($httpVars["simple_right_read"]) ? "true" : "false"; $httpVars["right_write_0"] = isset($httpVars["simple_right_write"]) ? "true" : "false"; $httpVars["right_watch_0"] = "false"; $httpVars["disable_download"] = isset($httpVars["simple_right_download"]) ? false : true; if ($httpVars["right_read_0"] == "false" && !$httpVars["disable_download"]) { $httpVars["right_read_0"] = "true"; } if ($httpVars["right_write_0"] == "false" && $httpVars["right_read_0"] == "false") { return "share_center.58"; } } $httpVars["minisite"] = true; $httpVars["selection"] = true; if (!isset($userSelection)) { $userSelection = new UserSelection($repository, $httpVars); $setFilter = false; if ($userSelection->isUnique()) { $node = $userSelection->getUniqueNode($this->accessDriver); $node->loadNodeInfo(); if ($node->isLeaf()) { $setFilter = true; $httpVars["file"] = "/"; } } else { $setFilter = true; } $nodes = $userSelection->buildNodes($this->accessDriver); $hasDir = false; $hasFile = false; foreach ($nodes as $n) { $n->loadNodeInfo(); if ($n->isLeaf()) { $hasFile = true; } else { $hasDir = true; } } if ($hasDir && !$this->getAuthorization("folder", "minisite") || $hasFile && !$this->getAuthorization("file")) { return 103; } if ($setFilter) { $httpVars["filter_nodes"] = $nodes; } if (!isset($httpVars["repo_label"])) { $first = $userSelection->getUniqueNode($this->accessDriver); $httpVars["repo_label"] = SystemTextEncoding::toUTF8($first->getLabel()); } } $newRepo = $this->createSharedRepository($httpVars, $repository, $accessDriver, $uniqueUser); if (!is_a($newRepo, "Repository")) { return $newRepo; } $newId = $newRepo->getId(); $downloadFolder = ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER"); $this->initPublicFolder($downloadFolder); if (isset($existingData)) { $data = $existingData; } else { $data = array("REPOSITORY" => $newId); } if (isset($data["PRELOG_USER"])) { unset($data["PRELOG_USER"]); } if (isset($data["PRESET_LOGIN"])) { unset($data["PRESET_LOGIN"]); } if (isset($httpVars["create_guest_user"]) && isset($userId) || isset($httpVars["guest_user_id"])) { if (!isset($userId)) { $userId = $httpVars["guest_user_id"]; } if (empty($httpVars["guest_user_pass"]) && !isset($httpVars["KEEP_PRESET_LOGIN"])) { $data["PRELOG_USER"] = $userId; } else { $data["PRESET_LOGIN"] = $userId; } } $data["DOWNLOAD_DISABLED"] = $httpVars["disable_download"]; $data["AJXP_APPLICATION_BASE"] = AJXP_Utils::detectServerURL(true); if (isset($httpVars["minisite_layout"])) { $data["AJXP_TEMPLATE_NAME"] = $httpVars["minisite_layout"]; } if (isset($httpVars["expiration"]) && intval($httpVars["expiration"]) > 0) { $data["EXPIRE_TIME"] = time() + intval($httpVars["expiration"]) * 86400; } if (isset($httpVars["downloadlimit"]) && intval($httpVars["downloadlimit"]) > 0) { $data["DOWNLOAD_LIMIT"] = intval($httpVars["downloadlimit"]); } if (AuthService::usersEnabled()) { $data["OWNER_ID"] = AuthService::getLoggedUser()->getId(); } if (!isset($httpVars["repository_id"])) { try { $forceHash = null; if (isset($httpVars["custom_handle"]) && !empty($httpVars["custom_handle"])) { // Existing already $value = AJXP_Utils::sanitize($httpVars["custom_handle"], AJXP_SANITIZE_ALPHANUM); $value = strtolower($value); $test = $this->getShareStore()->loadShare($value); $mess = ConfService::getMessages(); if (!empty($test)) { throw new Exception($mess["share_center.172"]); } $forceHash = $value; } $hash = $this->getShareStore()->storeShare($repository->getId(), $data, "minisite", $forceHash); } catch (Exception $e) { return $e->getMessage(); } $url = $this->buildPublicletLink($hash); $this->logInfo("New Share", array("file" => "'" . $httpVars['file'] . "'", "url" => $url, "expiration" => $data['EXPIRE_TIME'], "limit" => $data['DOWNLOAD_LIMIT'], "repo_uuid" => $repository->uuid)); AJXP_Controller::applyHook("node.share.create", array('type' => 'minisite', 'repository' => &$repository, 'accessDriver' => &$accessDriver, 'data' => &$data, 'url' => $url, 'new_repository' => &$newRepo)); } else { try { $hash = $httpVars["hash"]; $updateHash = null; if (isset($httpVars["custom_handle"]) && !empty($httpVars["custom_handle"]) && $httpVars["custom_handle"] != $httpVars["hash"]) { // Existing already $value = AJXP_Utils::sanitize($httpVars["custom_handle"], AJXP_SANITIZE_ALPHANUM); $value = strtolower($value); $test = $this->getShareStore()->loadShare($value); if (!empty($test)) { throw new Exception("Sorry hash already exists"); } $updateHash = $value; } $hash = $this->getShareStore()->storeShare($repository->getId(), $data, "minisite", $hash, $updateHash); } catch (Exception $e) { return $e->getMessage(); } $url = $this->buildPublicletLink($hash); $this->logInfo("Update Share", array("file" => "'" . $httpVars['file'] . "'", "url" => $url, "expiration" => $data['EXPIRE_TIME'], "limit" => $data['DOWNLOAD_LIMIT'], "repo_uuid" => $repository->uuid)); AJXP_Controller::applyHook("node.share.update", array('type' => 'minisite', 'repository' => &$repository, 'accessDriver' => &$accessDriver, 'data' => &$data, 'url' => $url, 'new_repository' => &$newRepo)); } return array($hash, $url); }