本文整理汇总了PHP中AJXP_Controller::applyHook方法的典型用法代码示例。如果您正苦于以下问题:PHP AJXP_Controller::applyHook方法的具体用法?PHP AJXP_Controller::applyHook怎么用?PHP AJXP_Controller::applyHook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AJXP_Controller
的用法示例。
在下文中一共展示了AJXP_Controller::applyHook方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switchAction
public function switchAction($action, $httpVars, $filesVars)
{
if (!isset($this->actions[$action])) {
return false;
}
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(true)) {
return false;
}
if (!isset($this->pluginConf)) {
$this->pluginConf = array("GENERATE_THUMBNAIL" => false);
}
$streamData = $repository->streamData;
$this->streamData = $streamData;
$destStreamURL = $streamData["protocol"] . "://" . $repository->getId();
if ($action == "preview_data_proxy") {
$file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
if (!file_exists($destStreamURL . $file)) {
header("Content-Type: " . AJXP_Utils::getImageMimeType(basename($file)) . "; name=\"" . basename($file) . "\"");
header("Content-Length: 0");
return;
}
if (isset($httpVars["get_thumb"]) && $this->getFilteredOption("GENERATE_THUMBNAIL", $repository->getId())) {
$dimension = 200;
if (isset($httpVars["dimension"]) && is_numeric($httpVars["dimension"])) {
$dimension = $httpVars["dimension"];
}
$this->currentDimension = $dimension;
$cacheItem = AJXP_Cache::getItem("diaporama_" . $dimension, $destStreamURL . $file, array($this, "generateThumbnail"));
$data = $cacheItem->getData();
$cId = $cacheItem->getId();
header("Content-Type: " . AJXP_Utils::getImageMimeType(basename($cId)) . "; name=\"" . basename($cId) . "\"");
header("Content-Length: " . strlen($data));
header('Cache-Control: public');
header("Pragma:");
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time() - 10000) . " GMT");
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 5 * 24 * 3600) . " GMT");
print $data;
} else {
//$filesize = filesize($destStreamURL.$file);
$node = new AJXP_Node($destStreamURL . $file);
$fp = fopen($destStreamURL . $file, "r");
$stat = fstat($fp);
$filesize = $stat["size"];
header("Content-Type: " . AJXP_Utils::getImageMimeType(basename($file)) . "; name=\"" . basename($file) . "\"");
header("Content-Length: " . $filesize);
header('Cache-Control: public');
header("Pragma:");
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time() - 10000) . " GMT");
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 5 * 24 * 3600) . " GMT");
$class = $streamData["classname"];
$stream = fopen("php://output", "a");
call_user_func(array($streamData["classname"], "copyFileInStream"), $destStreamURL . $file, $stream);
fflush($stream);
fclose($stream);
AJXP_Controller::applyHook("node.read", array($node));
}
}
}
示例2: switchAction
public function switchAction($action, $httpVars, $postProcessData)
{
if (!isset($this->actions[$action])) {
return false;
}
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(false)) {
return false;
}
$plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType());
$streamData = $plugin->detectStreamWrapper(true);
$destStreamURL = $streamData["protocol"] . "://" . $repository->getId() . "/";
if ($action == "audio_proxy") {
$file = AJXP_Utils::decodeSecureMagic(base64_decode($httpVars["file"]));
$cType = "audio/" . array_pop(explode(".", $file));
$localName = basename($file);
header("Content-Type: " . $cType . "; name=\"" . $localName . "\"");
header("Content-Length: " . filesize($destStreamURL . $file));
$stream = fopen("php://output", "a");
call_user_func(array($streamData["classname"], "copyFileInStream"), $destStreamURL . $file, $stream);
fflush($stream);
fclose($stream);
$node = new AJXP_Node($destStreamURL . $file);
AJXP_Controller::applyHook("node.read", array($node));
//exit(1);
} else {
if ($action == "ls") {
if (!isset($httpVars["playlist"])) {
// This should not happen anyway, because of the applyCondition.
AJXP_Controller::passProcessDataThrough($postProcessData);
return;
}
// We transform the XML into XSPF
$xmlString = $postProcessData["ob_output"];
$xmlDoc = new DOMDocument();
$xmlDoc->loadXML($xmlString);
$xElement = $xmlDoc->documentElement;
header("Content-Type:application/xspf+xml;charset=UTF-8");
print '<?xml version="1.0" encoding="UTF-8"?>';
print '<playlist version="1" xmlns="http://xspf.org/ns/0/">';
print "<trackList>";
foreach ($xElement->childNodes as $child) {
$isFile = $child->getAttribute("is_file") == "true";
$label = $child->getAttribute("text");
$ar = explode(".", $label);
$ext = strtolower(end($ar));
if (!$isFile || $ext != "mp3") {
continue;
}
print "<track><location>" . AJXP_SERVER_ACCESS . "?secure_token=" . AuthService::getSecureToken() . "&get_action=audio_proxy&file=" . base64_encode($child->getAttribute("filename")) . "</location><title>" . $label . "</title></track>";
}
print "</trackList>";
AJXP_XMLWriter::close("playlist");
}
}
}
示例3: consumeQueue
public function consumeQueue($action, $httpVars, $fileVars)
{
if ($action != "consume_notification_queue" || $this->msgExchanger === false) {
return;
}
$queueObjects = $this->msgExchanger->consumeWorkerChannel("user_notifications");
if (is_array($queueObjects)) {
$this->logDebug("Processing notification queue, " . count($queueObjects) . " notifs to handle");
foreach ($queueObjects as $notification) {
AJXP_Controller::applyHook("msg.notification", array(&$notification));
}
}
}
示例4: getNodeData
public static function getNodeData($nodePath)
{
$basename = basename(parse_url($nodePath, PHP_URL_PATH));
if (empty($basename)) {
return ['stat' => stat(AJXP_Utils::getAjxpTmpDir())];
}
$allNodes = self::getNodes(false);
$nodeData = $allNodes[$basename];
if (!isset($nodeData["stat"])) {
if (in_array(pathinfo($basename, PATHINFO_EXTENSION), array("error", "invitation"))) {
$stat = stat(AJXP_Utils::getAjxpTmpDir());
} else {
$url = $nodeData["url"];
$node = new AJXP_Node($nodeData["url"]);
$node->getRepository()->driverInstance = null;
try {
ConfService::loadDriverForRepository($node->getRepository());
$node->getRepository()->detectStreamWrapper(true);
if ($node->getRepository()->hasContentFilter()) {
$node->setLeaf(true);
}
AJXP_Controller::applyHook("node.read", array(&$node));
$stat = stat($url);
} catch (Exception $e) {
$stat = stat(AJXP_Utils::getAjxpTmpDir());
}
if (is_array($stat) && AuthService::getLoggedUser() != null) {
$acl = AuthService::getLoggedUser()->mergedRole->getAcl($nodeData["meta"]["shared_repository_id"]);
if ($acl == "r") {
self::disableWriteInStat($stat);
}
}
self::$output[$basename]["stat"] = $stat;
}
$nodeData["stat"] = $stat;
}
return $nodeData;
}
示例5: postProcess
public function postProcess($action, $httpVars, $postProcessData)
{
if (!self::$active) {
return false;
}
$this->logDebug("FlexProc is active=" . self::$active, $postProcessData);
$result = $postProcessData["processor_result"];
if (isset($result["SUCCESS"]) && $result["SUCCESS"] === true) {
header('HTTP/1.0 200 OK');
if (isset($result["UPDATED_NODE"])) {
AJXP_Controller::applyHook("node.change", array($result["UPDATED_NODE"], $result["UPDATED_NODE"], false));
} else {
AJXP_Controller::applyHook("node.change", array(null, $result["CREATED_NODE"], false));
}
//die("200 OK");
} else {
if (isset($result["ERROR"]) && is_array($result["ERROR"])) {
$code = $result["ERROR"]["CODE"];
$message = $result["ERROR"]["MESSAGE"];
//header("HTTP/1.0 $code $message");
die("Error {$code} {$message}");
}
}
}
示例6: 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));
}
}
}
示例7: copyOrMoveFile
/**
* We have to override the standard copyOrMoveFile, as feof() does
* not seem to work with ssh2.ftp stream...
* Maybe something to search hear http://www.mail-archive.com/php-general@lists.php.net/msg169992.html?
*
* @param string $destDir
* @param string $srcFile
* @param array $error
* @param array $success
* @param boolean $move
*/
function copyOrMoveFile($destDir, $srcFile, &$error, &$success, $move = false)
{
$mess = ConfService::getMessages();
$destFile = $this->urlBase . $destDir . "/" . basename($srcFile);
$realSrcFile = $this->urlBase . $srcFile;
if (!file_exists($realSrcFile)) {
$error[] = $mess[100] . $srcFile;
return;
}
if (dirname($realSrcFile) == dirname($destFile)) {
if ($move) {
$error[] = $mess[101];
return;
} else {
$base = basename($srcFile);
$i = 1;
if (is_file($realSrcFile)) {
$dotPos = strrpos($base, ".");
if ($dotPos > -1) {
$radic = substr($base, 0, $dotPos);
$ext = substr($base, $dotPos);
}
}
// auto rename file
$i = 1;
$newName = $base;
while (file_exists($this->urlBase . $destDir . "/" . $newName)) {
$suffix = "-{$i}";
if (isset($radic)) {
$newName = $radic . $suffix . $ext;
} else {
$newName = $base . $suffix;
}
$i++;
}
$destFile = $this->urlBase . $destDir . "/" . $newName;
}
}
if (!is_file($realSrcFile)) {
$errors = array();
$succFiles = array();
if ($move) {
if (file_exists($destFile)) {
$this->deldir($destFile);
}
$res = rename($realSrcFile, $destFile);
} else {
$dirRes = $this->dircopy($realSrcFile, $destFile, $errors, $succFiles);
}
if (count($errors) || isset($res) && $res !== true) {
$error[] = $mess[114];
return;
}
} else {
if ($move) {
if (file_exists($destFile)) {
unlink($destFile);
}
$res = rename($realSrcFile, $destFile);
AJXP_Controller::applyHook("move.metadata", array($realSrcFile, $destFile, false));
} else {
try {
// BEGIN OVERRIDING
list($connection, $remote_base_path) = sftpAccessWrapper::getSshConnection($realSrcFile);
$remoteSrc = $remote_base_path . $srcFile;
$remoteDest = $remote_base_path . $destDir;
AJXP_Logger::debug("SSH2 CP", array("cmd" => 'cp ' . $remoteSrc . ' ' . $remoteDest));
ssh2_exec($connection, 'cp ' . $remoteSrc . ' ' . $remoteDest);
AJXP_Controller::applyHook("move.metadata", array($realSrcFile, $destFile, true));
// END OVERRIDING
} catch (Exception $e) {
$error[] = $e->getMessage();
return;
}
}
}
if ($move) {
// Now delete original
// $this->deldir($realSrcFile); // both file and dir
$messagePart = $mess[74] . " " . SystemTextEncoding::toUTF8($destDir);
if (RecycleBinManager::recycleEnabled() && $destDir == RecycleBinManager::getRelativeRecycle()) {
RecycleBinManager::fileToRecycle($srcFile);
$messagePart = $mess[123] . " " . $mess[122];
}
if (isset($dirRes)) {
$success[] = $mess[117] . " " . SystemTextEncoding::toUTF8(basename($srcFile)) . " " . $messagePart . " (" . SystemTextEncoding::toUTF8($dirRes) . " " . $mess[116] . ") ";
} else {
$success[] = $mess[34] . " " . SystemTextEncoding::toUTF8(basename($srcFile)) . " " . $messagePart;
}
//.........这里部分代码省略.........
示例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();
$wrapperClassName = $streamData["classname"];
if (empty($httpVars["file"])) {
return;
}
$file = $destStreamURL . AJXP_Utils::decodeSecureMagic($httpVars["file"]);
$mess = ConfService::getMessages();
$node = new AJXP_Node($file);
AJXP_Controller::applyHook("node.read", array($node));
switch ($action) {
case "eml_get_xml_structure":
$params = array('include_bodies' => false, 'decode_bodies' => false, 'decode_headers' => 'UTF-8');
$decoder = $this->getStructureDecoder($file, $wrapperClassName == "imapAccessWrapper");
$xml = $decoder->getXML($decoder->decode($params));
if (function_exists("imap_mime_header_decode")) {
$doc = new DOMDocument();
$doc->loadXML($xml);
$xPath = new DOMXPath($doc);
$headers = $xPath->query("//headername");
$changes = false;
foreach ($headers as $headerNode) {
if ($headerNode->firstChild->nodeValue == "Subject") {
$headerValueNode = $headerNode->nextSibling->nextSibling;
$value = $headerValueNode->nodeValue;
$elements = imap_mime_header_decode($value);
$decoded = "";
foreach ($elements as $element) {
$decoded .= $element->text;
$charset = $element->charset;
}
if ($decoded != $value) {
$value = SystemTextEncoding::changeCharset($charset, "UTF-8", $decoded);
$node = $doc->createElement("headervalue", $value);
$res = $headerNode->parentNode->replaceChild($node, $headerValueNode);
$changes = true;
}
}
}
if ($changes) {
$xml = $doc->saveXML();
}
}
print $xml;
break;
case "eml_get_bodies":
require_once "Mail/mimeDecode.php";
$params = array('include_bodies' => true, 'decode_bodies' => true, 'decode_headers' => false);
if ($wrapperClassName == "imapAccessWrapper") {
$cache = AJXP_Cache::getItem("eml_remote", $file, null, array("EmlParser", "computeCacheId"));
$content = $cache->getData();
} else {
$content = file_get_contents($file);
}
$decoder = new Mail_mimeDecode($content);
$structure = $decoder->decode($params);
$html = $this->_findPartByCType($structure, "text", "html");
$text = $this->_findPartByCType($structure, "text", "plain");
if ($html != false && isset($html->ctype_parameters) && isset($html->ctype_parameters["charset"])) {
$charset = $html->ctype_parameters["charset"];
}
if (isset($charset)) {
header('Content-Type: text/xml; charset=' . $charset);
header('Cache-Control: no-cache');
print '<?xml version="1.0" encoding="' . $charset . '"?>';
print '<email_body>';
} else {
AJXP_XMLWriter::header("email_body");
}
if ($html !== false) {
print '<mimepart type="html"><![CDATA[';
$text = $html->body;
print $text;
print "]]></mimepart>";
}
if ($text !== false) {
print '<mimepart type="plain"><![CDATA[';
print $text->body;
print "]]></mimepart>";
}
AJXP_XMLWriter::close("email_body");
break;
case "eml_dl_attachment":
$attachId = $httpVars["attachment_id"];
if (!isset($attachId)) {
break;
}
require_once "Mail/mimeDecode.php";
$params = array('include_bodies' => true, 'decode_bodies' => true, 'decode_headers' => false);
if ($wrapperClassName == "imapAccessWrapper") {
$cache = AJXP_Cache::getItem("eml_remote", $file, null, array("EmlParser", "computeCacheId"));
//.........这里部分代码省略.........
示例9: uploadActions
public function uploadActions($action, $httpVars, $filesVars)
{
switch ($action) {
case "trigger_remote_copy":
if (!$this->hasFilesToCopy()) {
break;
}
$toCopy = $this->getFileNameToCopy();
AJXP_XMLWriter::header();
AJXP_XMLWriter::triggerBgAction("next_to_remote", array(), "Copying file " . $toCopy . " to ftp server");
AJXP_XMLWriter::close();
exit(1);
break;
case "next_to_remote":
if (!$this->hasFilesToCopy()) {
break;
}
$fData = $this->getNextFileToCopy();
$nextFile = '';
if ($this->hasFilesToCopy()) {
$nextFile = $this->getFileNameToCopy();
}
$this->logDebug("Base64 : ", array("from" => $fData["destination"], "to" => base64_decode($fData['destination'])));
$destPath = $this->urlBase . base64_decode($fData['destination']) . "/" . $fData['name'];
//$destPath = AJXP_Utils::decodeSecureMagic($destPath);
// DO NOT "SANITIZE", THE URL IS ALREADY IN THE FORM ajxp.ftp://repoId/filename
$destPath = SystemTextEncoding::fromPostedFileName($destPath);
$node = new AJXP_Node($destPath);
$this->logDebug("Copying file to server", array("from" => $fData["tmp_name"], "to" => $destPath, "name" => $fData["name"]));
try {
AJXP_Controller::applyHook("node.before_create", array(&$node));
$fp = fopen($destPath, "w");
$fSource = fopen($fData["tmp_name"], "r");
while (!feof($fSource)) {
fwrite($fp, fread($fSource, 4096));
}
fclose($fSource);
$this->logDebug("Closing target : begin ftp copy");
// Make sur the script does not time out!
@set_time_limit(240);
fclose($fp);
$this->logDebug("FTP Upload : end of ftp copy");
@unlink($fData["tmp_name"]);
AJXP_Controller::applyHook("node.change", array(null, &$node));
} catch (Exception $e) {
$this->logDebug("Error during ftp copy", array($e->getMessage(), $e->getTrace()));
}
$this->logDebug("FTP Upload : shoud trigger next or reload nextFile={$nextFile}");
AJXP_XMLWriter::header();
if ($nextFile != '') {
AJXP_XMLWriter::triggerBgAction("next_to_remote", array(), "Copying file " . SystemTextEncoding::toUTF8($nextFile) . " to remote server");
} else {
AJXP_XMLWriter::triggerBgAction("reload_node", array(), "Upload done, reloading client.");
}
AJXP_XMLWriter::close();
exit(1);
break;
case "upload":
$rep_source = AJXP_Utils::securePath("/" . $httpVars['dir']);
$this->logDebug("Upload : rep_source ", array($rep_source));
$logMessage = "";
foreach ($filesVars as $boxName => $boxData) {
if (substr($boxName, 0, 9) != "userfile_") {
continue;
}
$this->logDebug("Upload : rep_source ", array($rep_source));
$err = AJXP_Utils::parseFileDataErrors($boxData);
if ($err != null) {
$errorCode = $err[0];
$errorMessage = $err[1];
break;
}
if (isset($httpVars["auto_rename"])) {
$destination = $this->urlBase . $rep_source;
$boxData["name"] = fsAccessDriver::autoRenameForDest($destination, $boxData["name"]);
}
$boxData["destination"] = base64_encode($rep_source);
$destCopy = AJXP_XMLWriter::replaceAjxpXmlKeywords($this->repository->getOption("TMP_UPLOAD"));
$this->logDebug("Upload : tmp upload folder", array($destCopy));
if (!is_dir($destCopy)) {
if (!@mkdir($destCopy)) {
$this->logDebug("Upload error : cannot create temporary folder", array($destCopy));
$errorCode = 413;
$errorMessage = "Warning, cannot create folder for temporary copy.";
break;
}
}
if (!$this->isWriteable($destCopy)) {
$this->logDebug("Upload error: cannot write into temporary folder");
$errorCode = 414;
$errorMessage = "Warning, cannot write into temporary folder.";
break;
}
$this->logDebug("Upload : tmp upload folder", array($destCopy));
if (isset($boxData["input_upload"])) {
try {
$destName = tempnam($destCopy, "");
$this->logDebug("Begining reading INPUT stream");
$input = fopen("php://input", "r");
$output = fopen($destName, "w");
//.........这里部分代码省略.........
示例10: saveMetaFileData
protected function saveMetaFileData($currentFile)
{
$metaFile = dirname($currentFile) . "/" . $this->options["meta_file_name"];
if (is_file($metaFile) && call_user_func(array($this->accessDriver, "isWriteable"), $metaFile) || call_user_func(array($this->accessDriver, "isWriteable"), dirname($metaFile))) {
$fp = fopen($metaFile, "w");
fwrite($fp, serialize(self::$metaCache), strlen(serialize(self::$metaCache)));
fclose($fp);
AJXP_Controller::applyHook("version.commit_file", $metaFile);
}
}
示例11: switchAction
public function switchAction($action, $httpVars, $fileVars)
{
if (!isset($this->actions[$action])) {
return;
}
parent::accessPreprocess($action, $httpVars, $fileVars);
$loggedUser = AuthService::getLoggedUser();
if (AuthService::usersEnabled() && !$loggedUser->isAdmin()) {
return;
}
if (AuthService::usersEnabled()) {
$currentBookmarks = AuthService::getLoggedUser()->getBookmarks();
// FLATTEN
foreach ($currentBookmarks as $bm) {
$this->currentBookmarks[] = $bm["PATH"];
}
}
if ($action == "edit") {
if (isset($httpVars["sub_action"])) {
$action = $httpVars["sub_action"];
}
}
$mess = ConfService::getMessages();
$currentUserIsGroupAdmin = AuthService::getLoggedUser() != null && AuthService::getLoggedUser()->getGroupPath() != "/";
if ($currentUserIsGroupAdmin && ConfService::getAuthDriverImpl()->isAjxpAdmin(AuthService::getLoggedUser()->getId())) {
$currentUserIsGroupAdmin = false;
}
switch ($action) {
//------------------------------------
// BASIC LISTING
//------------------------------------
case "ls":
$rootNodes = array("data" => array("LABEL" => $mess["ajxp_conf.110"], "ICON" => "user.png", "DESCRIPTION" => $mess["ajxp_conf.137"], "CHILDREN" => array("repositories" => array("AJXP_MIME" => "workspaces_zone", "LABEL" => $mess["ajxp_conf.3"], "DESCRIPTION" => $mess["ajxp_conf.138"], "ICON" => "hdd_external_unmount.png", "LIST" => "listRepositories"), "users" => array("AJXP_MIME" => "users_zone", "LABEL" => $mess["ajxp_conf.2"], "DESCRIPTION" => $mess["ajxp_conf.139"], "ICON" => "users-folder.png", "LIST" => "listUsers"), "roles" => array("AJXP_MIME" => "roles_zone", "LABEL" => $mess["ajxp_conf.69"], "DESCRIPTION" => $mess["ajxp_conf.140"], "ICON" => "user-acl.png", "LIST" => "listRoles"))), "config" => array("AJXP_MIME" => "plugins_zone", "LABEL" => $mess["ajxp_conf.109"], "ICON" => "preferences_desktop.png", "DESCRIPTION" => $mess["ajxp_conf.136"], "CHILDREN" => array("core" => array("AJXP_MIME" => "plugins_zone", "LABEL" => $mess["ajxp_conf.98"], "DESCRIPTION" => $mess["ajxp_conf.133"], "ICON" => "preferences_desktop.png", "LIST" => "listPlugins"), "plugins" => array("AJXP_MIME" => "plugins_zone", "LABEL" => $mess["ajxp_conf.99"], "DESCRIPTION" => $mess["ajxp_conf.134"], "ICON" => "folder_development.png", "LIST" => "listPlugins"), "core_plugins" => array("AJXP_MIME" => "plugins_zone", "LABEL" => $mess["ajxp_conf.123"], "DESCRIPTION" => $mess["ajxp_conf.135"], "ICON" => "folder_development.png", "LIST" => "listPlugins"))), "admin" => array("LABEL" => $mess["ajxp_conf.111"], "ICON" => "toggle_log.png", "DESCRIPTION" => $mess["ajxp_conf.141"], "CHILDREN" => array("logs" => array("LABEL" => $mess["ajxp_conf.4"], "DESCRIPTION" => $mess["ajxp_conf.142"], "ICON" => "toggle_log.png", "LIST" => "listLogFiles"), "diagnostic" => array("LABEL" => $mess["ajxp_conf.5"], "DESCRIPTION" => $mess["ajxp_conf.143"], "ICON" => "susehelpcenter.png", "LIST" => "printDiagnostic"))), "developer" => array("LABEL" => $mess["ajxp_conf.144"], "ICON" => "applications_engineering.png", "DESCRIPTION" => $mess["ajxp_conf.145"], "CHILDREN" => array("actions" => array("LABEL" => $mess["ajxp_conf.146"], "DESCRIPTION" => $mess["ajxp_conf.147"], "ICON" => "book.png", "LIST" => "listActions"), "hooks" => array("LABEL" => $mess["ajxp_conf.148"], "DESCRIPTION" => $mess["ajxp_conf.149"], "ICON" => "book.png", "LIST" => "listHooks"))));
if ($currentUserIsGroupAdmin) {
unset($rootNodes["config"]);
unset($rootNodes["admin"]);
unset($rootNodes["developer"]);
}
AJXP_Controller::applyHook("ajxp_conf.list_config_nodes", array(&$rootNodes));
$parentName = "";
$dir = trim(AJXP_Utils::decodeSecureMagic(isset($httpVars["dir"]) ? $httpVars["dir"] : ""), " /");
if ($dir != "") {
$hash = null;
if (strstr(urldecode($dir), "#") !== false) {
list($dir, $hash) = explode("#", urldecode($dir));
}
$splits = explode("/", $dir);
$root = array_shift($splits);
if (count($splits)) {
$returnNodes = false;
if (isset($httpVars["file"])) {
$returnNodes = true;
}
$child = $splits[0];
if (isset($rootNodes[$root]["CHILDREN"][$child])) {
$atts = array();
if ($child == "users") {
$atts["remote_indexation"] = "admin_search";
}
$callback = $rootNodes[$root]["CHILDREN"][$child]["LIST"];
if (is_string($callback) && method_exists($this, $callback)) {
if (!$returnNodes) {
AJXP_XMLWriter::header("tree", $atts);
}
$res = call_user_func(array($this, $callback), implode("/", $splits), $root, $hash, $returnNodes, isset($httpVars["file"]) ? $httpVars["file"] : '');
if (!$returnNodes) {
AJXP_XMLWriter::close();
}
} else {
if (is_array($callback)) {
$res = call_user_func($callback, implode("/", $splits), $root, $hash, $returnNodes, isset($httpVars["file"]) ? $httpVars["file"] : '');
}
}
if ($returnNodes) {
AJXP_XMLWriter::header("tree", $atts);
if (isset($res["/" . $dir . "/" . $httpVars["file"]])) {
print $res["/" . $dir . "/" . $httpVars["file"]];
}
AJXP_XMLWriter::close();
}
return;
}
} else {
$parentName = "/" . $root . "/";
$nodes = $rootNodes[$root]["CHILDREN"];
}
} else {
$parentName = "/";
$nodes = $rootNodes;
}
if (isset($httpVars["file"])) {
$parentName = $httpVars["dir"] . "/";
$nodes = array(basename($httpVars["file"]) => array("LABEL" => basename($httpVars["file"])));
}
if (isset($nodes)) {
AJXP_XMLWriter::header();
if (!isset($httpVars["file"])) {
AJXP_XMLWriter::sendFilesListComponentConfig('<columns switchDisplayMode="detail"><column messageId="ajxp_conf.1" attributeName="ajxp_label" sortType="String"/><column messageId="ajxp_conf.102" attributeName="description" sortType="String"/></columns>');
}
foreach ($nodes as $key => $data) {
//.........这里部分代码省略.........
示例12: editMeta
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();
}
示例13: unifyChunks
public function unifyChunks($action, &$httpVars, &$fileVars)
{
$filename = AJXP_Utils::decodeSecureMagic($httpVars["name"]);
$tmpName = $fileVars["file"]["tmp_name"];
$chunk = $httpVars["chunk"];
$chunks = $httpVars["chunks"];
//error_log("currentChunk:".$chunk." chunks: ".$chunks);
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(false)) {
return false;
}
$plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType());
$streamData = $plugin->detectStreamWrapper(true);
$wrapperName = $streamData["classname"];
$dir = AJXP_Utils::securePath($httpVars["dir"]);
$destStreamURL = $streamData["protocol"] . "://" . $repository->getId() . $dir . "/";
$driver = ConfService::loadDriverForRepository($repository);
$remote = false;
if (method_exists($driver, "storeFileToCopy")) {
$remote = true;
$destCopy = AJXP_XMLWriter::replaceAjxpXmlKeywords($repository->getOption("TMP_UPLOAD"));
// Make tmp folder a bit more unique using secure_token
$tmpFolder = $destCopy . "/" . $httpVars["secure_token"];
if (!is_dir($tmpFolder)) {
@mkdir($tmpFolder, 0700, true);
}
$target = $tmpFolder . '/' . $filename;
$fileVars["file"]["destination"] = base64_encode($dir);
} else {
if (call_user_func(array($wrapperName, "isRemote"))) {
$remote = true;
$tmpFolder = AJXP_Utils::getAjxpTmpDir() . "/" . $httpVars["secure_token"];
if (!is_dir($tmpFolder)) {
@mkdir($tmpFolder, 0700, true);
}
$target = $tmpFolder . '/' . $filename;
} else {
$target = $destStreamURL . $filename;
}
}
//error_log("Directory: ".$dir);
// Clean the fileName for security reasons
//$filename = preg_replace('/[^\w\._]+/', '', $filename);
// Look for the content type header
if (isset($_SERVER["HTTP_CONTENT_TYPE"])) {
$contentType = $_SERVER["HTTP_CONTENT_TYPE"];
}
if (isset($_SERVER["CONTENT_TYPE"])) {
$contentType = $_SERVER["CONTENT_TYPE"];
}
// Handle non multipart uploads older WebKit versions didn't support multipart in HTML5
if (strpos($contentType, "multipart") !== false) {
if (isset($tmpName) && is_uploaded_file($tmpName)) {
//error_log("tmpName: ".$tmpName);
// Open temp file
$out = fopen($target, $chunk == 0 ? "wb" : "ab");
if ($out) {
// Read binary input stream and append it to temp file
$in = fopen($tmpName, "rb");
if ($in) {
while ($buff = fread($in, 4096)) {
fwrite($out, $buff);
}
} else {
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
}
fclose($in);
fclose($out);
@unlink($tmpName);
} else {
die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
}
} else {
die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}');
}
} else {
// Open temp file
$out = fopen($target, $chunk == 0 ? "wb" : "ab");
if ($out) {
// Read binary input stream and append it to temp file
$in = fopen("php://input", "rb");
if ($in) {
while ($buff = fread($in, 4096)) {
fwrite($out, $buff);
}
} else {
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
}
fclose($in);
fclose($out);
} else {
die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
}
}
/* we apply the hook if we are uploading the last chunk */
if ($chunk == $chunks - 1) {
if (!$remote) {
AJXP_Controller::applyHook("node.change", array(null, new AJXP_Node($destStreamURL . $filename), false));
} else {
if (method_exists($driver, "storeFileToCopy")) {
//.........这里部分代码省略.........
示例14: shareNode
/**
* @param AJXP_Node $ajxpNode
* @param array $httpVars
* @param bool $update
* @return Repository[]|ShareLink[]
* @throws Exception
*/
public function shareNode($ajxpNode, $httpVars, &$update)
{
$hiddenUserEntries = array();
$originalHttpVars = $httpVars;
$ocsStore = new Pydio\OCS\Model\SQLStore();
$ocsClient = new Pydio\OCS\Client\OCSClient();
$userSelection = new UserSelection($this->repository, $httpVars);
$mess = ConfService::getMessages();
/**
* @var ShareLink[] $shareObjects
*/
$shareObjects = array();
// PUBLIC LINK
if (isset($httpVars["enable_public_link"])) {
if (!$this->getAuthorization($ajxpNode->isLeaf() ? "file" : "folder", "minisite")) {
throw new Exception($mess["share_center." . ($ajxpNode->isLeaf() ? "225" : "226")]);
}
$this->shareObjectFromParameters($httpVars, $hiddenUserEntries, $shareObjects, "public");
} else {
if (isset($httpVars["disable_public_link"])) {
$this->getShareStore()->deleteShare("minisite", $httpVars["disable_public_link"], true);
}
}
if (isset($httpVars["ocs_data"])) {
$ocsData = json_decode($httpVars["ocs_data"], true);
$removeLinks = $ocsData["REMOVE"];
foreach ($removeLinks as $linkHash) {
// Delete Link, delete invitation(s)
$this->getShareStore()->deleteShare("minisite", $linkHash, true);
$invitations = $ocsStore->invitationsForLink($linkHash);
foreach ($invitations as $invitation) {
$ocsStore->deleteInvitation($invitation);
$ocsClient->cancelInvitation($invitation);
}
}
$newLinks = $ocsData["LINKS"];
foreach ($newLinks as $linkData) {
$this->shareObjectFromParameters($linkData, $hiddenUserEntries, $shareObjects, "targetted", $userSelection->getUniqueNode()->getLabel());
}
}
$this->filterHttpVarsFromUniqueNode($httpVars, $ajxpNode);
$users = array();
$groups = array();
$this->getRightsManager()->createUsersFromParameters($httpVars, $users, $groups);
if ((count($users) || count($groups)) && !$this->getAuthorization($ajxpNode->isLeaf() ? "file" : "folder", "workspace")) {
$users = $groups = array();
}
foreach ($hiddenUserEntries as $entry) {
$users[$entry["ID"]] = $entry;
}
if (!count($users) && !count($groups)) {
ob_start();
unset($originalHttpVars["hash"]);
$this->switchAction("unshare", $originalHttpVars, array());
ob_end_clean();
return null;
}
$newRepo = $this->createSharedRepository($httpVars, $repoUpdate, $users, $groups);
foreach ($shareObjects as $shareObject) {
$shareObject->setParentRepositoryId($this->repository->getId());
$shareObject->attachToRepository($newRepo->getId());
$shareObject->save();
if ($shareObject instanceof \Pydio\OCS\Model\TargettedLink) {
$invitation = $shareObject->getPendingInvitation();
if (!empty($invitation)) {
$ocsStore->generateInvitationId($invitation);
try {
$ocsClient->sendInvitation($invitation);
} catch (Exception $e) {
$this->getShareStore()->deleteShare("minisite", $shareObject->getHash(), true);
$shareUserId = $shareObject->getUniqueUser();
unset($users[$shareUserId]);
if (!count($users) && !count($groups)) {
$this->getShareStore()->deleteShare("repository", $newRepo->getId());
}
throw $e;
}
$ocsStore->storeInvitation($invitation);
}
} else {
$this->getPublicAccessManager()->initFolder();
$url = $this->getPublicAccessManager()->buildPublicLink($shareObject->getHash());
$existingShortForm = $shareObject->getShortFormUrl();
if (empty($existingShortForm)) {
$shortForm = "";
AJXP_Controller::applyHook("url.shorten", array($url, &$shortForm));
if (!empty($shortForm)) {
$shareObject->setShortFormUrl($shortForm);
$shareObject->save();
}
}
}
}
//.........这里部分代码省略.........
示例15: loadNodeInfo
/**
* Applies the "node.info" hook, thus going through the plugins that have registered this node, and loading
* all metadata at once.
* @param bool $forceRefresh
* @param bool $contextNode The parent node, if it can be useful for the hooks callbacks
* @param mixed $details A specification of expected metadata fields, or minimal
* @return void
*/
public function loadNodeInfo($forceRefresh = false, $contextNode = false, $details = false)
{
if ($this->nodeInfoLoaded && $this->nodeInfoLevel != $details) {
$forceRefresh = true;
}
if ($this->nodeInfoLoaded && !$forceRefresh) {
return;
}
if (!empty($this->_wrapperClassName)) {
$registered = AJXP_PluginsService::getInstance()->getRegisteredWrappers();
if (!isset($registered[$this->getScheme()])) {
$driver = $this->getDriver();
if (is_object($driver)) {
$driver->detectStreamWrapper(true);
}
}
}
AJXP_Controller::applyHook("node.info", array(&$this, $contextNode, $details));
$this->nodeInfoLoaded = true;
$this->nodeInfoLevel = $details;
}