本文整理汇总了PHP中AJXP_Node::loadNodeInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP AJXP_Node::loadNodeInfo方法的具体用法?PHP AJXP_Node::loadNodeInfo怎么用?PHP AJXP_Node::loadNodeInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AJXP_Node
的用法示例。
在下文中一共展示了AJXP_Node::loadNodeInfo方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scanFile
/**
* @param AJXP_Node $oldNode
* @param AJXP_Node $newNode
* Main function, it is called by the hook.
*/
public function scanFile($oldNode = null, $newNode = null)
{
if ($oldNode != null || $newNode == null) {
return;
}
// ADD THOSE TWO LINES
$newNode->loadNodeInfo();
if (!$newNode->isLeaf()) {
return;
}
$this->callSet($newNode);
//initializes attributes
// This block scans or doesn't scan the file. This is based on plugin parameters
if ($this->file_size < $this->scan_max_size) {
if ($this->scan_all == true) {
if ($this->inList() == true) {
if ($this->getFilteredOption("TRACE") == false) {
return;
}
$this->scanLater();
return;
} else {
$this->scanNow();
return;
}
} else {
if ($this->inList() == true) {
$this->scanNow();
return;
} else {
if ($this->getFilteredOption("TRACE") == false) {
return;
}
$this->scanLater();
return;
}
}
} else {
$this->scanLater();
return;
}
}
示例2: switchAction
public function switchAction($action, $httpVars, $filesVars)
{
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(true)) {
return false;
}
$selection = new UserSelection($repository, $httpVars);
$selectedNode = $selection->getUniqueNode();
$selectedNodeUrl = $selectedNode->getUrl();
if ($action == "post_to_server") {
// Backward compat
if (strpos($httpVars["file"], "base64encoded:") !== 0) {
$legacyFilePath = AJXP_Utils::decodeSecureMagic(base64_decode($httpVars["file"]));
$selectedNode = new AJXP_Node($selection->currentBaseUrl() . $legacyFilePath);
$selectedNodeUrl = $selectedNode->getUrl();
}
$target = rtrim(base64_decode($httpVars["parent_url"]), '/') . "/plugins/editor.pixlr";
$tmp = AJXP_MetaStreamWrapper::getRealFSReference($selectedNodeUrl);
$tmp = SystemTextEncoding::fromUTF8($tmp);
$this->logInfo('Preview', 'Sending content of ' . $selectedNodeUrl . ' to Pixlr server.', array("files" => $selectedNodeUrl));
AJXP_Controller::applyHook("node.read", array($selectedNode));
$saveTarget = $target . "/fake_save_pixlr.php";
if ($this->getFilteredOption("CHECK_SECURITY_TOKEN", $repository->getId())) {
$saveTarget = $target . "/fake_save_pixlr_" . md5($httpVars["secure_token"]) . ".php";
}
$params = array("referrer" => "Pydio", "method" => "get", "loc" => ConfService::getLanguage(), "target" => $saveTarget, "exit" => $target . "/fake_close_pixlr.php", "title" => urlencode(basename($selectedNodeUrl)), "locktarget" => "false", "locktitle" => "true", "locktype" => "source");
require_once AJXP_BIN_FOLDER . "/http_class/http_class.php";
$arguments = array();
$httpClient = new http_class();
$httpClient->request_method = "POST";
$httpClient->GetRequestArguments("https://pixlr.com/editor/", $arguments);
$arguments["PostValues"] = $params;
$arguments["PostFiles"] = array("image" => array("FileName" => $tmp, "Content-Type" => "automatic/name"));
$err = $httpClient->Open($arguments);
if (empty($err)) {
$err = $httpClient->SendRequest($arguments);
if (empty($err)) {
$response = "";
while (true) {
$header = array();
$error = $httpClient->ReadReplyHeaders($header, 1000);
if ($error != "" || $header != null) {
break;
}
$response .= $header;
}
}
}
header("Location: {$header['location']}");
//$response");
} else {
if ($action == "retrieve_pixlr_image") {
$file = AJXP_Utils::decodeSecureMagic($httpVars["original_file"]);
$selectedNode = new AJXP_Node($selection->currentBaseUrl() . $file);
$selectedNode->loadNodeInfo();
$this->logInfo('Edit', 'Retrieving content of ' . $file . ' from Pixlr server.', array("files" => $file));
AJXP_Controller::applyHook("node.before_change", array(&$selectedNode));
$url = $httpVars["new_url"];
$urlParts = parse_url($url);
$query = $urlParts["query"];
if ($this->getFilteredOption("CHECK_SECURITY_TOKEN", $repository->getId())) {
$scriptName = basename($urlParts["path"]);
$token = str_replace(array("fake_save_pixlr_", ".php"), "", $scriptName);
if ($token != md5($httpVars["secure_token"])) {
throw new AJXP_Exception("Invalid Token, this could mean some security problem!");
}
}
$params = array();
parse_str($query, $params);
$image = $params['image'];
$headers = get_headers($image, 1);
$content_type = explode("/", $headers['Content-Type']);
if ($content_type[0] != "image") {
throw new AJXP_Exception("Invalid File Type");
}
$content_length = intval($headers["Content-Length"]);
if ($content_length != 0) {
AJXP_Controller::applyHook("node.before_change", array(&$selectedNode, $content_length));
}
$orig = fopen($image, "r");
$target = fopen($selectedNode->getUrl(), "w");
if (is_resource($orig) && is_resource($target)) {
while (!feof($orig)) {
fwrite($target, fread($orig, 4096));
}
fclose($orig);
fclose($target);
}
clearstatcache(true, $selectedNode->getUrl());
$selectedNode->loadNodeInfo(true);
AJXP_Controller::applyHook("node.change", array(&$selectedNode, &$selectedNode));
}
}
}
示例3: updateNodeSharedData
/**
*
* Hooked to node.change, this will update the index
* if $oldNode = null => create node $newNode
* if $newNode = null => delete node $oldNode
* Else copy or move oldNode to newNode.
*
* @param AJXP_Node $oldNode
*/
public function updateNodeSharedData($oldNode)
{
if (empty($this->accessDriver) || $this->accessDriver->getId() == "access.imap") {
return;
}
if ($oldNode == null || !$oldNode->hasMetaStore()) {
return;
}
$metadata = $oldNode->retrieveMetadata("ajxp_shared", true);
if (count($metadata) && !empty($metadata["element"])) {
// TODO
// Make sure node info is loaded, to check if it's a dir or a file.
// Maybe could be directly embedded in metadata, to avoid having to load here.
$oldNode->loadNodeInfo();
try {
$type = $oldNode->isLeaf() ? "file" : "repository";
$elementIds = array();
if ($type == "file") {
if (!is_array($metadata["element"])) {
$elementIds[] = $metadata["element"];
} else {
$elementIds = array_keys($metadata["element"]);
}
} else {
$elementIds[] = $metadata["element"];
}
foreach ($elementIds as $elementId) {
self::deleteSharedElement($type, $elementId, AuthService::getLoggedUser());
}
$oldNode->removeMetadata("ajxp_shared", true, AJXP_METADATA_SCOPE_REPOSITORY, true);
} catch (Exception $e) {
$this->logError("Exception", $e->getMessage(), $e->getTrace());
}
}
}
示例4: createIndexedDocument
/**
* @param AJXP_Node $ajxpNode
* @throws Exception
*/
public function createIndexedDocument($ajxpNode)
{
$ajxpNode->loadNodeInfo();
$parseContent = $this->indexContent;
if ($parseContent && $ajxpNode->bytesize > $this->getFilteredOption("PARSE_CONTENT_MAX_SIZE")) {
$parseContent = false;
}
$data = array();
$data["node_url"] = $ajxpNode->getUrl();
$data["node_path"] = str_replace("/", "AJXPFAKESEP", $ajxpNode->getPath());
$data["basename"] = basename($ajxpNode->getPath());
$data["ajxp_node"] = "yes";
$data["ajxp_scope"] = "shared";
$data["serialized_metadata"] = base64_encode(serialize($ajxpNode->metadata));
$data["ajxp_modiftime"] = date("Ymd", $ajxpNode->ajxp_modiftime);
$data["ajxp_bytesize"] = $ajxpNode->bytesize;
$ajxpMime = $ajxpNode->ajxp_mime;
if (empty($ajxpMime)) {
$data["ajxp_mime"] = pathinfo($ajxpNode->getLabel(), PATHINFO_EXTENSION);
} else {
$data["ajxp_mime"] = $ajxpNode->ajxp_mime;
}
if (isset($ajxpNode->indexableMetaKeys["shared"])) {
foreach ($ajxpNode->indexableMetaKeys["shared"] as $sharedField) {
if ($ajxpNode->{$sharedField}) {
$data[$sharedField] = $ajxpNode->{$sharedField};
}
}
}
foreach ($this->metaFields as $field) {
if ($ajxpNode->{$field} != null) {
$data["ajxp_meta_{$field}"] = $ajxpNode->{$field};
}
}
if ($parseContent) {
$body = $this->extractIndexableContent($ajxpNode);
if (!empty($body)) {
$data["body"] = $body;
}
}
$mapping = new Elastica\Type\Mapping();
$mapping->setType($this->currentType);
$mapping->setProperties($this->dataToMappingProperties($data));
$mapping->send();
$doc = new Elastica\Document($this->nextId, $data);
$this->currentType->addDocument($doc);
$this->nextId++;
if (isset($ajxpNode->indexableMetaKeys["user"]) && count($ajxpNode->indexableMetaKeys["user"]) && AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
$userData = array("ajxp_scope" => "user", "user" => AuthService::getLoggedUser()->getId(), "serialized_metadata" => $data["serialized_metadata"], "node_url" => $data["node_url"], "node_path" => $data["node_path"]);
$userData["ajxp_user"] = AuthService::getLoggedUser()->getId();
foreach ($ajxpNode->indexableMetaKeys["user"] as $userField) {
if ($ajxpNode->{$userField}) {
$userData[$userField] = $ajxpNode->{$userField};
}
}
$mapping = new Elastica\Type\Mapping();
$mapping->setType($this->currentType);
$mapping->setProperties($this->dataToMappingProperties($userData));
$mapping->send();
$doc = new Elastica\Document($this->nextId, $userData);
$this->currentType->addDocument($doc);
$this->nextId++;
}
/* we update the last id in the file */
$file = fopen($this->lastIdPath, "w");
fputs($file, $this->nextId - 1);
fclose($file);
}
示例5: createIndexedDocument
/**
* @param AJXP_Node $ajxpNode
* @param Zend_Search_Lucene_Interface $index
* @throws Exception
* @return Zend_Search_Lucene_Document
*/
public function createIndexedDocument($ajxpNode, &$index)
{
if (!empty($this->metaFields)) {
$ajxpNode->loadNodeInfo(false, false, "all");
} else {
$ajxpNode->loadNodeInfo();
}
$ext = strtolower(pathinfo($ajxpNode->getLabel(), PATHINFO_EXTENSION));
$parseContent = $this->indexContent;
if ($parseContent && $ajxpNode->bytesize > $this->getFilteredOption("PARSE_CONTENT_MAX_SIZE")) {
$parseContent = false;
}
if ($parseContent && in_array($ext, explode(",", $this->getFilteredOption("PARSE_CONTENT_HTML")))) {
$doc = @Zend_Search_Lucene_Document_Html::loadHTMLFile($ajxpNode->getUrl());
} elseif ($parseContent && $ext == "docx" && class_exists("Zend_Search_Lucene_Document_Docx")) {
$realFile = call_user_func(array($ajxpNode->wrapperClassName, "getRealFSReference"), $ajxpNode->getUrl());
$doc = @Zend_Search_Lucene_Document_Docx::loadDocxFile($realFile);
} elseif ($parseContent && $ext == "docx" && class_exists("Zend_Search_Lucene_Document_Pptx")) {
$realFile = call_user_func(array($ajxpNode->wrapperClassName, "getRealFSReference"), $ajxpNode->getUrl());
$doc = @Zend_Search_Lucene_Document_Pptx::loadPptxFile($realFile);
} elseif ($parseContent && $ext == "xlsx" && class_exists("Zend_Search_Lucene_Document_Xlsx")) {
$realFile = call_user_func(array($ajxpNode->wrapperClassName, "getRealFSReference"), $ajxpNode->getUrl());
$doc = @Zend_Search_Lucene_Document_Xlsx::loadXlsxFile($realFile);
} else {
$doc = new Zend_Search_Lucene_Document();
}
if ($doc == null) {
throw new Exception("Could not load document");
}
$doc->addField(Zend_Search_Lucene_Field::Keyword("node_url", $ajxpNode->getUrl()), SystemTextEncoding::getEncoding());
$doc->addField(Zend_Search_Lucene_Field::Keyword("node_path", str_replace("/", "AJXPFAKESEP", $ajxpNode->getPath())), SystemTextEncoding::getEncoding());
$doc->addField(Zend_Search_Lucene_Field::Text("basename", basename($ajxpNode->getPath())), SystemTextEncoding::getEncoding());
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_node", "yes"), SystemTextEncoding::getEncoding());
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_scope", "shared"));
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_modiftime", date("Ymd", $ajxpNode->ajxp_modiftime)));
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_bytesize", $ajxpNode->bytesize));
$ajxpMime = $ajxpNode->ajxp_mime;
if (empty($ajxpMime)) {
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_mime", pathinfo($ajxpNode->getLabel(), PATHINFO_EXTENSION)));
} else {
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_mime", $ajxpNode->ajxp_mime));
}
// Store a cached copy of the metadata
$serializedMeta = base64_encode(serialize($ajxpNode->metadata));
$doc->addField(Zend_Search_Lucene_Field::Binary("serialized_metadata", $serializedMeta));
if (isset($ajxpNode->indexableMetaKeys["shared"])) {
foreach ($ajxpNode->indexableMetaKeys["shared"] as $sharedField) {
if ($ajxpNode->{$sharedField}) {
$doc->addField(Zend_search_Lucene_Field::keyword($sharedField, $ajxpNode->{$sharedField}));
}
}
}
foreach ($this->metaFields as $field) {
if ($ajxpNode->{$field} != null) {
$doc->addField(Zend_Search_Lucene_Field::Text("ajxp_meta_{$field}", $ajxpNode->{$field}), SystemTextEncoding::getEncoding());
}
}
if (isset($ajxpNode->indexableMetaKeys["user"]) && count($ajxpNode->indexableMetaKeys["user"]) && AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
$privateDoc = new Zend_Search_Lucene_Document();
$privateDoc->addField(Zend_Search_Lucene_Field::Keyword("node_url", $ajxpNode->getUrl(), SystemTextEncoding::getEncoding()));
$privateDoc->addField(Zend_Search_Lucene_Field::Keyword("node_path", str_replace("/", "AJXPFAKESEP", $ajxpNode->getPath()), SystemTextEncoding::getEncoding()));
$privateDoc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_scope", "user"));
$privateDoc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_user", AuthService::getLoggedUser()->getId()));
foreach ($ajxpNode->indexableMetaKeys["user"] as $userField) {
if ($ajxpNode->{$userField}) {
$privateDoc->addField(Zend_search_Lucene_Field::keyword($userField, $ajxpNode->{$userField}));
}
}
$privateDoc->addField(Zend_Search_Lucene_Field::Binary("serialized_metadata", $serializedMeta));
$index->addDocument($privateDoc);
}
if ($parseContent) {
$body = $this->extractIndexableContent($ajxpNode);
if (!empty($body)) {
$doc->addField(Zend_Search_Lucene_Field::unStored("body", $body));
}
}
$index->addDocument($doc);
return $doc;
}
示例6: switchAction
//.........这里部分代码省略.........
if (!isset($threshold) || intval($threshold) == 0) {
$threshold = 500;
}
$limitPerPage = $this->repository->getOption("PAGINATION_NUMBER");
if (!isset($limitPerPage) || intval($limitPerPage) == 0) {
$limitPerPage = 200;
}
}
$countFiles = $this->countFiles($path, !$lsOptions["f"]);
if (isset($crt_nodes)) {
$crt_nodes += $countFiles;
}
if (isset($threshold) && isset($limitPerPage) && $countFiles > $threshold) {
if (isset($uniqueFile)) {
$originalLimitPerPage = $limitPerPage;
$offset = $limitPerPage = 0;
} else {
$offset = 0;
$crtPage = 1;
if (isset($page)) {
$offset = (intval($page) - 1) * $limitPerPage;
$crtPage = $page;
}
$totalPages = floor($countFiles / $limitPerPage) + 1;
}
} else {
$offset = $limitPerPage = 0;
}
$metaData = array();
if (RecycleBinManager::recycleEnabled() && $dir == "") {
$metaData["repo_has_recycle"] = "true";
}
$parentAjxpNode = new AJXP_Node($nonPatchedPath, $metaData);
$parentAjxpNode->loadNodeInfo(false, true, $lsOptions["l"] ? "all" : "minimal");
AJXP_Controller::applyHook("node.read", array(&$parentAjxpNode));
if (AJXP_XMLWriter::$headerSent == "tree") {
AJXP_XMLWriter::renderAjxpNode($parentAjxpNode, false);
} else {
AJXP_XMLWriter::renderAjxpHeaderNode($parentAjxpNode);
}
if (isset($totalPages) && isset($crtPage)) {
$remoteOptions = null;
if ($this->getFilteredOption("REMOTE_SORTING")) {
$remoteOptions = array("remote_order" => "true", "currentOrderCol" => isset($orderField) ? $orderField : "ajxp_label", "currentOrderDir" => isset($orderDirection) ? $orderDirection : "asc");
}
AJXP_XMLWriter::renderPaginationData($countFiles, $crtPage, $totalPages, $this->countFiles($path, TRUE), $remoteOptions);
if (!$lsOptions["f"]) {
AJXP_XMLWriter::close();
exit(1);
}
}
$cursor = 0;
$handle = opendir($path);
if (!$handle) {
throw new AJXP_Exception("Cannot open dir " . $nonPatchedPath);
}
closedir($handle);
$fullList = array("d" => array(), "z" => array(), "f" => array());
if (isset($orderField) && isset($orderDirection) && $orderField == "ajxp_label" && $orderDirection == "desc") {
$nodes = scandir($path, 1);
} else {
$nodes = scandir($path);
}
if (!empty($this->driverConf["SCANDIR_RESULT_SORTFONC"])) {
usort($nodes, $this->driverConf["SCANDIR_RESULT_SORTFONC"]);
}
示例7: loadUserAlerts
public function loadUserAlerts($actionName, $httpVars, $fileVars)
{
if (!$this->eventStore) {
return;
}
$u = AuthService::getLoggedUser();
$userId = $u->getId();
$repositoryFilter = null;
if (isset($httpVars["repository_id"]) && $u->mergedRole->canRead($httpVars["repository_id"])) {
$repositoryFilter = $httpVars["repository_id"];
}
if ($repositoryFilter == null) {
$repositoryFilter = ConfService::getRepository()->getId();
}
$res = $this->eventStore->loadAlerts($userId, $repositoryFilter);
if (!count($res)) {
return;
}
// Recompute children notifs
$format = $httpVars["format"];
$skipContainingTags = isset($httpVars["skip_container_tags"]);
$mess = ConfService::getMessages();
if (!$skipContainingTags) {
if ($format == "html") {
echo "<h2>" . $mess["notification_center.3"] . "</h2>";
echo "<ul class='notification_list'>";
} else {
AJXP_XMLWriter::header();
}
}
$parentRepository = ConfService::getRepositoryById($repositoryFilter);
$parentRoot = $parentRepository->getOption("PATH");
$cumulated = array();
foreach ($res as $notification) {
if ($format == "html") {
echo "<li>";
echo $notification->getDescriptionLong(true);
echo "</li>";
} else {
$node = $notification->getNode();
$path = $node->getPath();
$nodeRepo = $node->getRepository();
if ($nodeRepo != null && $nodeRepo->hasParent() && $nodeRepo->getParentId() == $repositoryFilter) {
$currentRoot = $nodeRepo->getOption("PATH");
$contentFilter = $nodeRepo->getContentFilter();
if (isset($contentFilter)) {
$nodePath = $contentFilter->filterExternalPath($node->getPath());
if ($nodePath == "/") {
$k = array_keys($contentFilter->filters);
$nodePath = $k[0];
}
} else {
$nodePath = $node->getPath();
}
$relative = rtrim(substr($currentRoot, strlen($parentRoot)), "/") . rtrim($nodePath, "/");
$parentNodeURL = $node->getScheme() . "://" . $repositoryFilter . $relative;
$this->logDebug("action.share", "Recompute alert to " . $parentNodeURL);
$node = new AJXP_Node($parentNodeURL);
}
if (isset($cumulated[$path])) {
$cumulated[$path]->event_occurence++;
continue;
}
try {
$node->loadNodeInfo();
} catch (Exception $e) {
if ($notification->alert_id) {
$this->eventStore->dismissAlertById($notification->alert_id);
}
continue;
}
$node->event_is_alert = true;
$node->event_description = ucfirst($notification->getDescriptionBlock()) . " " . $mess["notification.tpl.block.user_link"] . " " . $notification->getAuthorLabel();
$node->event_description_long = $notification->getDescriptionLong(true);
$node->event_date = SystemTextEncoding::fromUTF8(AJXP_Utils::relativeDate($notification->getDate(), $mess));
$node->event_type = "alert";
$node->alert_id = $notification->alert_id;
if ($node->getRepository() != null) {
$node->repository_id = '' . $node->getRepository()->getId();
if ($node->repository_id != $repositoryFilter && $node->getRepository()->getDisplay() != null) {
$node->event_repository_label = "[" . $node->getRepository()->getDisplay() . "]";
}
} else {
$node->event_repository_label = "[N/A]";
}
$node->event_author = $notification->getAuthor();
$node->event_occurence = 1;
$cumulated[$path] = $node;
}
}
$index = 1;
foreach ($cumulated as $nodeToSend) {
$nodeOcc = $nodeToSend->event_occurence > 1 ? "(" . $nodeToSend->event_occurence . ")" : "";
if (isset($httpVars["merge_description"]) && $httpVars["merge_description"] == "true") {
if (isset($httpVars["description_as_label"]) && $httpVars["description_as_label"] == "true") {
$nodeToSend->setLabel($nodeToSend->event_description . " " . $nodeOcc . " " . $nodeToSend->event_date);
} else {
$nodeToSend->setLabel(basename($nodeToSend->getPath()) . " " . $nodeOcc . " " . " <small class='notif_desc'>" . $nodeToSend->event_description . " " . $nodeToSend->event_date . "</small>");
}
} else {
//.........这里部分代码省略.........
示例8: switchAction
public function switchAction($action, $httpVars, $filesVars)
{
if (!isset($this->actions[$action])) {
return false;
}
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(true)) {
return false;
}
$streamData = $repository->streamData;
$destStreamURL = $streamData["protocol"] . "://" . $repository->getId();
if ($action == "post_to_server") {
$file = base64_decode($httpVars["file"]);
$file = AJXP_Utils::securePath($file);
$target = base64_decode($httpVars["parent_url"]) . "/plugins/editor.pixlr";
$tmp = call_user_func(array($streamData["classname"], "getRealFSReference"), $destStreamURL . $file);
$tmp = SystemTextEncoding::fromUTF8($tmp);
$fData = array("tmp_name" => $tmp, "name" => urlencode(basename($file)), "type" => "image/jpg");
//var_dump($fData);
$node = new AJXP_Node($destStreamURL . $file);
AJXP_Controller::applyHook("node.read", array($node));
$httpClient = new HttpClient("pixlr.com");
//$httpClient->setDebug(true);
$postData = array();
$httpClient->setHandleRedirects(false);
$saveTarget = $target . "/fake_save_pixlr.php";
if ($this->getFilteredOption("CHECK_SECURITY_TOKEN", $repository->getId())) {
$saveTarget = $target . "/fake_save_pixlr_" . md5($httpVars["secure_token"]) . ".php";
}
$params = array("referrer" => "AjaXplorer", "method" => "get", "loc" => ConfService::getLanguage(), "target" => $saveTarget, "exit" => $target . "/fake_close_pixlr.php", "title" => urlencode(basename($file)), "locktarget" => "false", "locktitle" => "true", "locktype" => "source");
$httpClient->postFile("/editor/", $params, "image", $fData);
$loc = $httpClient->getHeader("location");
header("Location:{$loc}");
} else {
if ($action == "retrieve_pixlr_image") {
$file = AJXP_Utils::decodeSecureMagic($httpVars["original_file"]);
$node = new AJXP_Node($destStreamURL . $file);
$node->loadNodeInfo();
AJXP_Controller::applyHook("node.before_change", array(&$node));
$url = $httpVars["new_url"];
$urlParts = parse_url($url);
$query = $urlParts["query"];
if ($this->getFilteredOption("CHECK_SECURITY_TOKEN", $repository->getId())) {
$scriptName = basename($urlParts["path"]);
$token = str_replace(array("fake_save_pixlr_", ".php"), "", $scriptName);
if ($token != md5($httpVars["secure_token"])) {
throw new AJXP_Exception("Invalid Token, this could mean some security problem!");
}
}
$params = array();
parse_str($query, $params);
$image = $params['image'];
$headers = get_headers($image, 1);
$content_type = explode("/", $headers['Content-Type']);
if ($content_type[0] != "image") {
throw new AJXP_Exception("Invalid File Type");
}
$content_length = intval($headers["Content-Length"]);
if ($content_length != 0) {
AJXP_Controller::applyHook("node.before_change", array(&$node, $content_length));
}
$orig = fopen($image, "r");
$target = fopen($destStreamURL . $file, "w");
while (!feof($orig)) {
fwrite($target, fread($orig, 4096));
}
fclose($orig);
fclose($target);
AJXP_Controller::applyHook("node.change", array(&$node, &$node));
//header("Content-Type:text/plain");
//print($mess[115]);
}
}
return;
}
示例9: createIndexedDocument
/**
* @param AJXP_Node $ajxpNode
* @param Zend_Search_Lucene_Interface $index
* @throws Exception
* @return Zend_Search_Lucene_Document
*/
public function createIndexedDocument($ajxpNode, &$index)
{
$ajxpNode->loadNodeInfo();
$ext = strtolower(pathinfo($ajxpNode->getLabel(), PATHINFO_EXTENSION));
$parseContent = $this->indexContent;
if ($parseContent && $ajxpNode->bytesize > $this->getFilteredOption("PARSE_CONTENT_MAX_SIZE")) {
$parseContent = false;
}
if ($parseContent && in_array($ext, explode(",", $this->getFilteredOption("PARSE_CONTENT_HTML")))) {
$doc = @Zend_Search_Lucene_Document_Html::loadHTMLFile($ajxpNode->getUrl());
} elseif ($parseContent && $ext == "docx" && class_exists("Zend_Search_Lucene_Document_Docx")) {
$realFile = call_user_func(array($ajxpNode->wrapperClassName, "getRealFSReference"), $ajxpNode->getUrl());
$doc = @Zend_Search_Lucene_Document_Docx::loadDocxFile($realFile);
} elseif ($parseContent && $ext == "docx" && class_exists("Zend_Search_Lucene_Document_Pptx")) {
$realFile = call_user_func(array($ajxpNode->wrapperClassName, "getRealFSReference"), $ajxpNode->getUrl());
$doc = @Zend_Search_Lucene_Document_Pptx::loadPptxFile($realFile);
} elseif ($parseContent && $ext == "xlsx" && class_exists("Zend_Search_Lucene_Document_Xlsx")) {
$realFile = call_user_func(array($ajxpNode->wrapperClassName, "getRealFSReference"), $ajxpNode->getUrl());
$doc = @Zend_Search_Lucene_Document_Xlsx::loadXlsxFile($realFile);
} else {
$doc = new Zend_Search_Lucene_Document();
}
if ($doc == null) {
throw new Exception("Could not load document");
}
$doc->addField(Zend_Search_Lucene_Field::Keyword("node_url", $ajxpNode->getUrl()), SystemTextEncoding::getEncoding());
$doc->addField(Zend_Search_Lucene_Field::Keyword("node_path", str_replace("/", "AJXPFAKESEP", $ajxpNode->getPath())), SystemTextEncoding::getEncoding());
$doc->addField(Zend_Search_Lucene_Field::Text("basename", basename($ajxpNode->getPath())), SystemTextEncoding::getEncoding());
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_node", "yes"), SystemTextEncoding::getEncoding());
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_scope", "shared"));
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_modiftime", date("Ymd", $ajxpNode->ajxp_modiftime)));
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_bytesize", $ajxpNode->bytesize));
$ajxpMime = $ajxpNode->ajxp_mime;
if (empty($ajxpMime)) {
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_mime", pathinfo($ajxpNode->getLabel(), PATHINFO_EXTENSION)));
} else {
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_mime", $ajxpNode->ajxp_mime));
}
// Store a cached copy of the metadata
$serializedMeta = base64_encode(serialize($ajxpNode->metadata));
$doc->addField(Zend_Search_Lucene_Field::Binary("serialized_metadata", $serializedMeta));
if (isset($ajxpNode->indexableMetaKeys["shared"])) {
foreach ($ajxpNode->indexableMetaKeys["shared"] as $sharedField) {
if ($ajxpNode->{$sharedField}) {
$doc->addField(Zend_search_Lucene_Field::keyword($sharedField, $ajxpNode->{$sharedField}));
}
}
}
foreach ($this->metaFields as $field) {
if ($ajxpNode->{$field} != null) {
$doc->addField(Zend_Search_Lucene_Field::Text("ajxp_meta_{$field}", $ajxpNode->{$field}), SystemTextEncoding::getEncoding());
}
}
if (isset($ajxpNode->indexableMetaKeys["user"]) && count($ajxpNode->indexableMetaKeys["user"]) && AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
$privateDoc = new Zend_Search_Lucene_Document();
$privateDoc->addField(Zend_Search_Lucene_Field::Keyword("node_url", $ajxpNode->getUrl(), SystemTextEncoding::getEncoding()));
$privateDoc->addField(Zend_Search_Lucene_Field::Keyword("node_path", str_replace("/", "AJXPFAKESEP", $ajxpNode->getPath()), SystemTextEncoding::getEncoding()));
$privateDoc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_scope", "user"));
$privateDoc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_user", AuthService::getLoggedUser()->getId()));
foreach ($ajxpNode->indexableMetaKeys["user"] as $userField) {
if ($ajxpNode->{$userField}) {
$privateDoc->addField(Zend_search_Lucene_Field::keyword($userField, $ajxpNode->{$userField}));
}
}
$privateDoc->addField(Zend_Search_Lucene_Field::Binary("serialized_metadata", $serializedMeta));
$index->addDocument($privateDoc);
}
if ($parseContent && in_array($ext, explode(",", $this->getFilteredOption("PARSE_CONTENT_TXT")))) {
$doc->addField(Zend_Search_Lucene_Field::unStored("body", file_get_contents($ajxpNode->getUrl())));
}
$unoconv = $this->getFilteredOption("UNOCONV");
$pipe = false;
if ($parseContent && !empty($unoconv) && in_array($ext, array("doc", "odt", "xls", "ods"))) {
$targetExt = "txt";
if (in_array($ext, array("xls", "ods"))) {
$targetExt = "csv";
} else {
if (in_array($ext, array("odp", "ppt"))) {
$targetExt = "pdf";
$pipe = true;
}
}
$realFile = call_user_func(array($ajxpNode->wrapperClassName, "getRealFSReference"), $ajxpNode->getUrl());
$unoconv = "HOME=" . AJXP_Utils::getAjxpTmpDir() . " " . $unoconv . " --stdout -f {$targetExt} " . escapeshellarg($realFile);
if ($pipe) {
$newTarget = str_replace(".{$ext}", ".pdf", $realFile);
$unoconv .= " > {$newTarget}";
register_shutdown_function("unlink", $newTarget);
}
$output = array();
exec($unoconv, $output, $return);
if (!$pipe) {
$out = implode("\n", $output);
$enc = 'ISO-8859-1';
//.........这里部分代码省略.........
示例10: createIndexedDocument
/**
* @param AJXP_Node $ajxpNode
* @throws Exception
*/
public function createIndexedDocument($ajxpNode)
{
$ajxpNode->loadNodeInfo();
/*
$ext = strtolower(pathinfo($ajxpNode->getLabel(), PATHINFO_EXTENSION));
$parseContent = $this->indexContent;
if ($parseContent && $ajxpNode->bytesize > $this->getFilteredOption("PARSE_CONTENT_MAX_SIZE")) {
$parseContent = false;
}
if ($parseContent && in_array($ext, explode(",",$this->getFilteredOption("PARSE_CONTENT_HTML")))) {
$doc = @Zend_Search_Lucene_Document_Html::loadHTMLFile($ajxpNode->getUrl());
} elseif ($parseContent && $ext == "docx" && class_exists("Zend_Search_Lucene_Document_Docx")) {
$realFile = call_user_func(array($ajxpNode->wrapperClassName, "getRealFSReference"), $ajxpNode->getUrl());
$doc = @Zend_Search_Lucene_Document_Docx::loadDocxFile($realFile);
} elseif ($parseContent && $ext == "docx" && class_exists("Zend_Search_Lucene_Document_Pptx")) {
$realFile = call_user_func(array($ajxpNode->wrapperClassName, "getRealFSReference"), $ajxpNode->getUrl());
$doc = @Zend_Search_Lucene_Document_Pptx::loadPptxFile($realFile);
} elseif ($parseContent && $ext == "xlsx" && class_exists("Zend_Search_Lucene_Document_Xlsx")) {
$realFile = call_user_func(array($ajxpNode->wrapperClassName, "getRealFSReference"), $ajxpNode->getUrl());
$doc = @Zend_Search_Lucene_Document_Xlsx::loadXlsxFile($realFile);
} else {
$doc = new Zend_Search_Lucene_Document();
}
if($doc == null) throw new Exception("Could not load document");
*/
$mapping_properties = array();
/* we construct the array that will contain all the data for the document we create */
$data = array();
$data["node_url"] = $ajxpNode->getUrl();
$data["node_path"] = str_replace("/", "AJXPFAKESEP", $ajxpNode->getPath());
$data["basename"] = basename($ajxpNode->getPath());
$data["ajxp_node"] = "yes";
$data["ajxp_scope"] = "shared";
$data["serialized_metadata"] = base64_encode(serialize($ajxpNode->metadata));
if (isset($ajxpNode->indexableMetaKeys["shared"])) {
foreach ($ajxpNode->indexableMetaKeys["shared"] as $sharedField) {
if ($ajxpNode->{$sharedField}) {
$data[$sharedField] = $ajxpNode->{$sharedField};
}
}
}
foreach ($this->metaFields as $field) {
if ($ajxpNode->{$field} != null) {
$data["ajxp_meta_{$field}"] = $ajxpNode->{$field};
}
}
/*
We want some fields not to be analyzed when they are indexed.
To achieve this we have to dynamically define a mapping.
When you define a mapping you have to set the type of data you will put
in each field and you can define other parameters.
Here we want some fields not to be analyzed so we just precise the
property index and set it to "not_analyzed".
*/
foreach ($data as $key => $value) {
if ($key == "node_url" || ($key = "node_path")) {
$mapping_properties[$key] = array("type" => "string", "index" => "not_analyzed");
} else {
$type = gettype($value);
if ($type != "integer" && $type != "boolean" && $type != "double") {
$type = "string";
}
$mapping_properties[$key] = array("type" => $type, "index" => "simple");
}
}
$mapping = new Elastica\Type\Mapping();
$mapping->setType($this->currentType);
$mapping->setProperties($mapping_properties);
$mapping->send();
$doc = new Elastica\Document($this->nextId, $data);
$this->nextId++;
/*if (isSet($ajxpNode->indexableMetaKeys["user"]) && count($ajxpNode->indexableMetaKeys["user"]) && AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
$privateDoc = new Zend_Search_Lucene_Document();
$privateDoc->addField(Zend_Search_Lucene_Field::Keyword("node_url", $ajxpNode->getUrl()), SystemTextEncoding::getEncoding());
$privateDoc->addField(Zend_Search_Lucene_Field::Keyword("node_path", str_replace("/", "AJXPFAKESEP", $ajxpNode->getPath())), SystemTextEncoding::getEncoding());
$privateDoc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_scope", "user"));
$privateDoc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_user", AuthService::getLoggedUser()->getId()));
foreach ($ajxpNode->indexableMetaKeys["user"] as $userField) {
if ($ajxpNode->$userField) {
$privateDoc->addField(Zend_search_Lucene_Field::keyword($userField, $ajxpNode->$userField));
}
}
$privateDoc->addField(Zend_Search_Lucene_Field::Binary("serialized_metadata", $serializedMeta));
$index->addDocument($privateDoc);
}
/*
if ($parseContent && in_array($ext, explode(",",$this->getFilteredOption("PARSE_CONTENT_TXT")))) {
$doc->addField(Zend_Search_Lucene_Field::unStored("body", file_get_contents($ajxpNode->getUrl())));
}
$unoconv = $this->getFilteredOption("UNOCONV");
if ($parseContent && !empty($unoconv) && in_array($ext, array("doc", "odt", "xls", "ods"))) {
$targetExt = "txt";
$pipe = false;
//.........这里部分代码省略.........
示例11: updateNodesIndex
/**
* @param AJXP_Node $oldNode
* @param AJXP_Node $newNode
* @param bool $copy
*/
public function updateNodesIndex($oldNode = null, $newNode = null, $copy = false)
{
require_once AJXP_BIN_FOLDER . "/dibi.compact.php";
try {
if ($newNode == null) {
$repoId = $this->computeIdentifier($oldNode->getRepository());
// DELETE
dibi::query("DELETE FROM [ajxp_index] WHERE [node_path] LIKE %like~ AND [repository_identifier] = %s", $oldNode->getPath(), $repoId);
} else {
if ($oldNode == null) {
// CREATE
$stat = stat($newNode->getUrl());
$res = dibi::query("INSERT INTO [ajxp_index]", array("node_path" => $newNode->getPath(), "bytesize" => $stat["size"], "mtime" => $stat["mtime"], "md5" => $newNode->isLeaf() ? md5_file($newNode->getUrl()) : "directory", "repository_identifier" => $repoId = $this->computeIdentifier($newNode->getRepository())));
} else {
$repoId = $this->computeIdentifier($oldNode->getRepository());
if ($oldNode->getPath() == $newNode->getPath()) {
// CONTENT CHANGE
clearstatcache();
$stat = stat($newNode->getUrl());
$this->logDebug("Content changed", "current stat size is : " . $stat["size"]);
dibi::query("UPDATE [ajxp_index] SET ", array("bytesize" => $stat["size"], "mtime" => $stat["mtime"], "md5" => md5_file($newNode->getUrl())), "WHERE [node_path] = %s AND [repository_identifier] = %s", $oldNode->getPath(), $repoId);
} else {
// PATH CHANGE ONLY
$newNode->loadNodeInfo();
if ($newNode->isLeaf()) {
dibi::query("UPDATE [ajxp_index] SET ", array("node_path" => $newNode->getPath()), "WHERE [node_path] = %s AND [repository_identifier] = %s", $oldNode->getPath(), $repoId);
} else {
dibi::query("UPDATE [ajxp_index] SET [node_path]=REPLACE( REPLACE(CONCAT('\$\$\$',[node_path]), CONCAT('\$\$\$', %s), CONCAT('\$\$\$', %s)) , '\$\$\$', '') ", $oldNode->getPath(), $newNode->getPath(), "WHERE [node_path] LIKE %like~ AND [repository_identifier] = %s", $oldNode->getPath(), $repoId);
}
}
}
}
} catch (Exception $e) {
AJXP_Logger::error("[meta.syncable]", "Indexation", $e->getMessage());
}
}
示例12: switchAction
public function switchAction($action, $httpVars, $filesVars)
{
if (!isset($this->actions[$action])) {
return false;
}
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(true)) {
return false;
}
$streamData = $repository->streamData;
$destStreamURL = $streamData["protocol"] . "://" . $repository->getId();
if ($action == "post_to_zohoserver") {
$sheetExt = explode(",", "xls,xlsx,ods,sxc,csv,tsv");
$presExt = explode(",", "ppt,pps,odp,sxi");
$docExt = explode(",", "doc,docx,rtf,odt,sxw");
require_once AJXP_BIN_FOLDER . "/http_class/http_class.php";
$selection = new UserSelection($repository, $httpVars);
// Backward compat
if (strpos($httpVars["file"], "base64encoded:") !== 0) {
$file = AJXP_Utils::decodeSecureMagic(base64_decode($httpVars["file"]));
} else {
$file = $selection->getUniqueFile();
}
$target = base64_decode($httpVars["parent_url"]);
$tmp = call_user_func(array($streamData["classname"], "getRealFSReference"), $destStreamURL . $file);
$tmp = SystemTextEncoding::fromUTF8($tmp);
$node = new AJXP_Node($destStreamURL . $file);
AJXP_Controller::applyHook("node.read", array($node));
$this->logInfo('Preview', 'Posting content of ' . $file . ' to Zoho server');
$extension = strtolower(pathinfo(urlencode(basename($file)), PATHINFO_EXTENSION));
$httpClient = new http_class();
$httpClient->request_method = "POST";
$secureToken = $httpVars["secure_token"];
$_SESSION["ZOHO_CURRENT_EDITED"] = $destStreamURL . $file;
$_SESSION["ZOHO_CURRENT_UUID"] = md5(rand() . "-" . microtime());
if ($this->getFilteredOption("USE_ZOHO_AGENT", $repository->getId())) {
$saveUrl = $this->getFilteredOption("ZOHO_AGENT_URL", $repository->getId());
} else {
$saveUrl = $target . "/" . AJXP_PLUGINS_FOLDER . "/editor.zoho/agent/save_zoho.php";
}
$b64Sig = $this->signID($_SESSION["ZOHO_CURRENT_UUID"]);
$params = array('id' => $_SESSION["ZOHO_CURRENT_UUID"], 'apikey' => $this->getFilteredOption("ZOHO_API_KEY", $repository->getId()), 'output' => 'url', 'lang' => "en", 'filename' => urlencode(basename($file)), 'persistence' => 'false', 'format' => $extension, 'mode' => 'normaledit', 'saveurl' => $saveUrl . "?signature=" . $b64Sig);
$service = "exportwriter";
if (in_array($extension, $sheetExt)) {
$service = "sheet";
} else {
if (in_array($extension, $presExt)) {
$service = "show";
} else {
if (in_array($extension, $docExt)) {
$service = "exportwriter";
}
}
}
$arguments = array();
$httpClient->GetRequestArguments("https://" . $service . ".zoho.com/remotedoc.im", $arguments);
$arguments["PostValues"] = $params;
$arguments["PostFiles"] = array("content" => array("FileName" => $tmp, "Content-Type" => "automatic/name"));
$err = $httpClient->Open($arguments);
if (empty($err)) {
$err = $httpClient->SendRequest($arguments);
if (empty($err)) {
$response = "";
while (true) {
$body = "";
$error = $httpClient->ReadReplyBody($body, 1000);
if ($error != "" || strlen($body) == 0) {
break;
}
$response .= $body;
}
$result = trim($response);
$matchlines = explode("\n", $result);
$resultValues = array();
foreach ($matchlines as $line) {
list($key, $val) = explode("=", $line, 2);
$resultValues[$key] = $val;
}
if ($resultValues["RESULT"] == "TRUE" && isset($resultValues["URL"])) {
header("Location: " . $resultValues["URL"]);
} else {
echo "Zoho API Error " . $resultValues["ERROR_CODE"] . " : " . $resultValues["WARNING"];
echo "<script>window.parent.setTimeout(function(){parent.hideLightBox();}, 2000);</script>";
}
}
$httpClient->Close();
}
} else {
if ($action == "retrieve_from_zohoagent") {
$targetFile = $_SESSION["ZOHO_CURRENT_EDITED"];
$id = $_SESSION["ZOHO_CURRENT_UUID"];
$ext = pathinfo($targetFile, PATHINFO_EXTENSION);
$node = new AJXP_Node($targetFile);
$node->loadNodeInfo();
AJXP_Controller::applyHook("node.before_change", array(&$node));
$b64Sig = $this->signID($id);
if ($this->getFilteredOption("USE_ZOHO_AGENT", $repository->getId())) {
$url = $this->getFilteredOption("ZOHO_AGENT_URL", $repository->getId()) . "?ajxp_action=get_file&name=" . $id . "&ext=" . $ext . "&signature=" . $b64Sig;
$data = AJXP_Utils::getRemoteContent($url);
if (strlen($data)) {
//.........这里部分代码省略.........