本文整理汇总了PHP中AJXP_Controller::findActionAndApply方法的典型用法代码示例。如果您正苦于以下问题:PHP AJXP_Controller::findActionAndApply方法的具体用法?PHP AJXP_Controller::findActionAndApply怎么用?PHP AJXP_Controller::findActionAndApply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AJXP_Controller
的用法示例。
在下文中一共展示了AJXP_Controller::findActionAndApply方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processUserAccessPoint
public function processUserAccessPoint($action, $httpVars, $fileVars)
{
switch ($action) {
case "user_access_point":
$uri = explode("/", trim($_SERVER["REQUEST_URI"], "/"));
array_shift($uri);
$action = array_shift($uri);
$this->processSubAction($action, $uri);
$_SESSION['OVERRIDE_GUI_START_PARAMETERS'] = array("REBASE" => "../../", "USER_GUI_ACTION" => $action);
AJXP_Controller::findActionAndApply("get_boot_gui", array(), array());
unset($_SESSION['OVERRIDE_GUI_START_PARAMETERS']);
break;
case "reset-password-ask":
// This is a reset password request, generate a token and store it.
// Find user by id
if (AuthService::userExists($httpVars["email"])) {
// Send email
$userObject = ConfService::getConfStorageImpl()->createUserObject($httpVars["email"]);
$email = $userObject->personalRole->filterParameterValue("core.conf", "email", AJXP_REPO_SCOPE_ALL, "");
if (!empty($email)) {
$uuid = AJXP_Utils::generateRandomString(48);
ConfService::getConfStorageImpl()->saveTemporaryKey("password-reset", $uuid, AJXP_Utils::decodeSecureMagic($httpVars["email"]), array());
$mailer = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("mailer");
if ($mailer !== false) {
$mess = ConfService::getMessages();
$link = AJXP_Utils::detectServerURL() . "/user/reset-password/" . $uuid;
$mailer->sendMail(array($email), $mess["gui.user.1"], $mess["gui.user.7"] . "<a href=\"{$link}\">{$link}</a>");
} else {
echo 'ERROR: There is no mailer configured, please contact your administrator';
}
}
}
// Prune existing expired tokens
ConfService::getConfStorageImpl()->pruneTemporaryKeys("password-reset", 20);
echo "SUCCESS";
break;
case "reset-password":
ConfService::getConfStorageImpl()->pruneTemporaryKeys("password-reset", 20);
// This is a reset password
if (isset($httpVars["key"]) && isset($httpVars["user_id"])) {
$key = ConfService::getConfStorageImpl()->loadTemporaryKey("password-reset", $httpVars["key"]);
if ($key != null && $key["user_id"] == $httpVars["user_id"] && AuthService::userExists($key["user_id"])) {
AuthService::updatePassword($key["user_id"], $httpVars["new_pass"]);
}
ConfService::getConfStorageImpl()->deleteTemporaryKey("password-reset", $httpVars["key"]);
}
AuthService::disconnect();
echo 'SUCCESS';
break;
default:
break;
}
}
示例2: switchAction
public function switchAction($actionName, $httpVars, $fileVars)
{
if ($actionName == "search-cart-download") {
// Pipe SEARCH + DOWNLOAD actions.
$indexer = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("index");
if ($indexer == false) {
return;
}
$httpVars["return_selection"] = true;
unset($httpVars["get_action"]);
$res = AJXP_Controller::findActionAndApply("search", $httpVars, $fileVars);
if (isset($res) && is_array($res)) {
$newHttpVars = array("selection_nodes" => $res, "dir" => "__AJXP_ZIP_FLAT__/", "archive_name" => $httpVars["archive_name"]);
AJXP_Controller::findActionAndApply("download", $newHttpVars, array());
}
}
}
示例3: updateNodesIndex
/**
* @param AJXP_Node $oldNode
* @param AJXP_Node $newNode
* @param bool $copy
*/
public function updateNodesIndex($oldNode = null, $newNode = null, $copy = false)
{
if (!dibi::isConnected()) {
dibi::connect($this->sqlDriver);
}
//$this->logInfo("Syncable index", array($oldNode == null?'null':$oldNode->getUrl(), $newNode == null?'null':$newNode->getUrl()));
try {
if ($newNode != null && $this->excludeNode($newNode)) {
// CREATE
if ($oldNode == null) {
AJXP_Logger::debug("Ignoring " . $newNode->getUrl() . " for indexation");
return;
} else {
AJXP_Logger::debug("Target node is excluded, see it as a deletion: " . $newNode->getUrl());
$newNode = null;
}
}
if ($newNode == null) {
$repoId = $this->computeIdentifier($oldNode->getRepository(), $oldNode->getUser());
// DELETE
$this->logDebug('DELETE', $oldNode->getUrl());
dibi::query("DELETE FROM [ajxp_index] WHERE [node_path] LIKE %like~ AND [repository_identifier] = %s", SystemTextEncoding::toUTF8($oldNode->getPath()), $repoId);
} else {
if ($oldNode == null || $copy) {
// CREATE
$stat = stat($newNode->getUrl());
$newNode->setLeaf(!($stat['mode'] & 040000));
$this->logDebug('INSERT', $newNode->getUrl());
dibi::query("INSERT INTO [ajxp_index]", array("node_path" => SystemTextEncoding::toUTF8($newNode->getPath()), "bytesize" => $stat["size"], "mtime" => $stat["mtime"], "md5" => $newNode->isLeaf() ? md5_file($newNode->getUrl()) : "directory", "repository_identifier" => $repoId = $this->computeIdentifier($newNode->getRepository(), $newNode->getUser())));
} else {
$repoId = $this->computeIdentifier($oldNode->getRepository(), $oldNode->getUser());
if ($oldNode->getPath() == $newNode->getPath()) {
// CONTENT CHANGE
clearstatcache();
$stat = stat($newNode->getUrl());
$this->logDebug("Content changed", "current stat size is : " . $stat["size"]);
$this->logDebug('UPDATE CONTENT', $newNode->getUrl());
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", SystemTextEncoding::toUTF8($oldNode->getPath()), $repoId);
try {
$rowCount = dibi::getAffectedRows();
if ($rowCount === 0) {
$this->logError(__FUNCTION__, "There was an update event on a non-indexed node (" . $newNode->getPath() . "), creating index entry!");
$this->updateNodesIndex(null, $newNode, false);
}
} catch (Exception $e) {
}
} else {
// PATH CHANGE ONLY
$newNode->loadNodeInfo();
if ($newNode->isLeaf()) {
$this->logDebug('UPDATE LEAF PATH', $newNode->getUrl());
dibi::query("UPDATE [ajxp_index] SET ", array("node_path" => SystemTextEncoding::toUTF8($newNode->getPath())), "WHERE [node_path] = %s AND [repository_identifier] = %s", SystemTextEncoding::toUTF8($oldNode->getPath()), $repoId);
try {
$rowCount = dibi::getAffectedRows();
if ($rowCount === 0) {
$this->logError(__FUNCTION__, "There was an update event on a non-indexed node (" . $newNode->getPath() . "), creating index entry!");
$this->updateNodesIndex(null, $newNode, false);
}
} catch (Exception $e) {
}
} else {
$this->logDebug('UPDATE FOLDER PATH', $newNode->getUrl());
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", SystemTextEncoding::toUTF8($oldNode->getPath()), $repoId);
try {
$rowCount = dibi::getAffectedRows();
if ($rowCount === 0) {
$this->logError(__FUNCTION__, "There was an update event on a non-indexed folder (" . $newNode->getPath() . "), relaunching a recursive indexation!");
AJXP_Controller::findActionAndApply("index", array("file" => $newNode->getPath()), array());
}
} catch (Exception $e) {
}
}
}
}
}
} catch (Exception $e) {
AJXP_Logger::error("[meta.syncable]", "Exception", $e->getTraceAsString());
AJXP_Logger::error("[meta.syncable]", "Indexation", $e->getMessage());
}
}
示例4: receiveAction
//.........这里部分代码省略.........
} 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);
}
}
}
}
示例5: header
//------------------------------------------------------------
if (AuthService::usersEnabled()) {
$loggedUser = AuthService::getLoggedUser();
if ($action == "upload" && ($loggedUser == null || !$loggedUser->canWrite(ConfService::getCurrentRepositoryId() . "")) && isset($_FILES['Filedata'])) {
header('HTTP/1.0 ' . '410 Not authorized');
die('Error 410 Not authorized!');
}
}
// THIS FIRST DRIVERS DO NOT NEED ID CHECK
//$ajxpDriver = AJXP_PluginsService::findPlugin("gui", "ajax");
$authDriver = ConfService::getAuthDriverImpl();
// DRIVERS BELOW NEED IDENTIFICATION CHECK
if (!AuthService::usersEnabled() || ConfService::getCoreConf("ALLOW_GUEST_BROWSING", "auth") || AuthService::getLoggedUser() != null) {
$confDriver = ConfService::getConfStorageImpl();
$Driver = ConfService::loadRepositoryDriver();
}
AJXP_PluginsService::getInstance()->initActivePlugins();
require_once AJXP_BIN_FOLDER . "/class.AJXP_Controller.php";
$xmlResult = AJXP_Controller::findActionAndApply($action, array_merge($_GET, $_POST), $_FILES);
if ($xmlResult !== false && $xmlResult != "") {
AJXP_XMLWriter::header();
print $xmlResult;
AJXP_XMLWriter::close();
} else {
if (isset($requireAuth) && AJXP_Controller::$lastActionNeedsAuth) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::requireAuth();
AJXP_XMLWriter::close();
}
}
session_write_close();
示例6: render
//.........这里部分代码省略.........
$images = array("button", "background_1");
$confs = $options;
$confs["CUSTOM_SHAREPAGE_BACKGROUND_ATTRIBUTES_1"] = "background-repeat:repeat;background-position:50% 50%;";
$confs["CUSTOM_SHAREPAGE_BACKGROUND_1"] = "plugins/action.share/res/hi-res/02.jpg";
$confs["CUSTOM_SHAREPAGE_TEXT_COLOR"] = "#ffffff";
$confs["CUSTOM_SHAREPAGE_TEXTSHADOW_COLOR"] = "rgba(0,0,0,5)";
foreach ($customs as $custom) {
$varName = "CUSTOM_SHAREPAGE_" . strtoupper($custom);
${$varName} = $confs[$varName];
}
$dlFolder = realpath(ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER"));
foreach ($images as $custom) {
$varName = "CUSTOM_SHAREPAGE_" . strtoupper($custom);
if (!empty($confs[$varName])) {
if (strpos($confs[$varName], "plugins/") === 0 && is_file(AJXP_INSTALL_PATH . "/" . $confs[$varName])) {
$realFile = AJXP_INSTALL_PATH . "/" . $confs[$varName];
copy($realFile, $dlFolder . "/binary-" . basename($realFile));
${$varName} = "binary-" . basename($realFile);
} else {
${$varName} = "binary-" . $confs[$varName];
if (is_file($dlFolder . "/binary-" . $confs[$varName])) {
continue;
}
$copiedImageName = $dlFolder . "/binary-" . $confs[$varName];
$imgFile = fopen($copiedImageName, "wb");
ConfService::getConfStorageImpl()->loadBinary(array(), $confs[$varName], $imgFile);
fclose($imgFile);
}
}
}
HTMLWriter::charsetHeader();
// Check password
if (strlen($data["PASSWORD"])) {
if (!isset($_POST['password']) || $_POST['password'] != $data["PASSWORD"]) {
$AJXP_LINK_HAS_PASSWORD = true;
$AJXP_LINK_WRONG_PASSWORD = isset($_POST['password']) && $_POST['password'] != $data["PASSWORD"];
include AJXP_INSTALL_PATH . "/plugins/action.share/res/public_links.php";
$res = '<div style="position: absolute;z-index: 10000; bottom: 0; right: 0; color: #666;font-family: HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size: 13px;text-align: right;padding: 6px; line-height: 20px;text-shadow: 0px 1px 0px white;" class="no_select_bg"><br>Build your own box with Pydio : <a style="color: #000000;" target="_blank" href="http://pyd.io/">http://pyd.io/</a><br/>Community - Free non supported version © C. du Jeu 2008-2014 </div>';
AJXP_Controller::applyHook("tpl.filter_html", array(&$res));
echo $res;
return;
}
} else {
if (!isset($_GET["dl"])) {
include AJXP_INSTALL_PATH . "/plugins/action.share/res/public_links.php";
$res = '<div style="position: absolute;z-index: 10000; bottom: 0; right: 0; color: #666;font-family: HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size: 13px;text-align: right;padding: 6px; line-height: 20px;text-shadow: 0px 1px 0px white;" class="no_select_bg"><br>Build your own box with Pydio : <a style="color: #000000;" target="_blank" href="http://pyd.io/">http://pyd.io/</a><br/>Community - Free non supported version © C. du Jeu 2008-2014 </div>';
AJXP_Controller::applyHook("tpl.filter_html", array(&$res));
echo $res;
return;
}
}
$filePath = AJXP_INSTALL_PATH . "/plugins/access." . $data["DRIVER"] . "/class." . $className . ".php";
if (!is_file($filePath)) {
die("Warning, cannot find driver for conf storage! ({$className}, {$filePath})");
}
require_once $filePath;
$driver = new $className($data["PLUGIN_ID"], $data["BASE_DIR"]);
$driver->loadManifest();
//$hash = md5(serialize($data));
$shareStore->incrementDownloadCounter($shortHash);
//AuthService::logUser($data["OWNER_ID"], "", true);
AuthService::logTemporaryUser($data["OWNER_ID"], $shortHash);
if (isset($data["SAFE_USER"]) && isset($data["SAFE_PASS"])) {
// FORCE SESSION MODE
AJXP_Safe::getInstance()->forceSessionCredentialsUsage();
AJXP_Safe::storeCredentials($data["SAFE_USER"], $data["SAFE_PASS"]);
}
$repoObject = $data["REPOSITORY"];
ConfService::switchRootDir($repoObject->getId());
ConfService::loadRepositoryDriver();
AJXP_PluginsService::getInstance()->initActivePlugins();
try {
$params = array("file" => SystemTextEncoding::toUTF8($data["FILE_PATH"]));
if (isset($data["PLUGINS_DATA"])) {
$params["PLUGINS_DATA"] = $data["PLUGINS_DATA"];
}
if (isset($_GET["ct"]) && $_GET["ct"] == "true") {
$mime = pathinfo($params["file"], PATHINFO_EXTENSION);
$editors = AJXP_PluginsService::searchAllManifests("//editor[contains(@mimes,'{$mime}') and @previewProvider='true']", "node", true, true, false);
if (count($editors)) {
foreach ($editors as $editor) {
$xPath = new DOMXPath($editor->ownerDocument);
$callbacks = $xPath->query("//action[@contentTypedProvider]", $editor);
if ($callbacks->length) {
$data["ACTION"] = $callbacks->item(0)->getAttribute("name");
if ($data["ACTION"] == "audio_proxy") {
$params["file"] = base64_encode($params["file"]);
}
break;
}
}
}
}
AJXP_Controller::findActionAndApply($data["ACTION"], $params, null);
register_shutdown_function(array("AuthService", "clearTemporaryUser"), $shortHash);
} catch (Exception $e) {
AuthService::clearTemporaryUser($shortHash);
die($e->getMessage());
}
}
示例7: array
ConfService::setLanguage($_COOKIE["AJXP_lang"]);
}
}
$mess = ConfService::getMessages();
// THIS FIRST DRIVERS DO NOT NEED ID CHECK
//$ajxpDriver = AJXP_PluginsService::findPlugin("gui", "ajax");
$authDriver = ConfService::getAuthDriverImpl();
// DRIVERS BELOW NEED IDENTIFICATION CHECK
if (!AuthService::usersEnabled() || ConfService::getCoreConf("ALLOW_GUEST_BROWSING", "auth") || AuthService::getLoggedUser() != null) {
$confDriver = ConfService::getConfStorageImpl();
$loadRepo = ConfService::getRepository();
$Driver = ConfService::loadDriverForRepository($loadRepo);
}
AJXP_PluginsService::getInstance()->initActivePlugins();
require_once AJXP_BIN_FOLDER . "/class.AJXP_Controller.php";
$xmlResult = AJXP_Controller::findActionAndApply($optAction, $optArgs, array());
if ($xmlResult !== false && $xmlResult != "") {
AJXP_XMLWriter::header();
print $xmlResult;
AJXP_XMLWriter::close();
} else {
if (isset($requireAuth) && AJXP_Controller::$lastActionNeedsAuth) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::requireAuth();
AJXP_XMLWriter::close();
}
}
//echo("NEXT REPO ".$nextRepositories." (".$options["r"].")\n");
//echo("NEXT USERS ".$nextUsers." ( ".$originalOptUser." )\n");
if (!empty($nextUsers) || !empty($nextRepositories) || !empty($optUserQueue)) {
if (!empty($nextUsers)) {
示例8: unifyChunks
//.........这里部分代码省略.........
$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")) {
$fileVars["file"]["tmp_name"] = $target;
$fileVars["file"]["name"] = $filename;
$driver->storeFileToCopy($fileVars["file"]);
AJXP_Controller::findActionAndApply("next_to_remote", array(), array());
} else {
// Remote Driver case: copy temp file to destination
$node = new AJXP_Node($destStreamURL . $filename);
AJXP_Controller::applyHook("node.before_create", array($node, filesize($target)));
AJXP_Controller::applyHook("node.before_change", array(new AJXP_Node($destStreamURL)));
$res = copy($target, $destStreamURL . $filename);
if ($res) {
@unlink($target);
}
AJXP_Controller::applyHook("node.change", array(null, $node, false));
}
}
}
// Return JSON-RPC response
die('{"jsonrpc" : "2.0", "result" : null, "id" : "id"}');
}
示例9: switchActions
public function switchActions($actionName, $httpVars, $fileVars)
{
if ($actionName != "changes" || !isset($httpVars["seq_id"])) {
return false;
}
if (!dibi::isConnected()) {
dibi::connect($this->sqlDriver);
}
$filter = null;
$currentRepo = $this->accessDriver->repository;
$recycle = $currentRepo->getOption("RECYCLE_BIN");
$recycle = !empty($recycle) ? $recycle : false;
if ($this->options["OBSERVE_STORAGE_CHANGES"] === true) {
// Do it every XX minutes
$minutes = 5;
if (isset($this->options["OBSERVE_STORAGE_EVERY"])) {
$minutes = intval($this->options["OBSERVE_STORAGE_EVERY"]);
}
$file = $this->getResyncTimestampFile();
$last = 0;
if (is_file($file)) {
$last = intval(file_get_contents($file));
}
if (time() - $last > $minutes * 60) {
$this->resyncAction("resync_storage", array(), array());
}
}
if ($this->options["REQUIRES_INDEXATION"]) {
if (ConfService::backgroundActionsSupported()) {
AJXP_Controller::applyActionInBackground(ConfService::getRepository()->getId(), "index", array());
} else {
AJXP_Controller::findActionAndApply("index", array(), array());
}
// Unset the REQUIRES_INDEXATION FLAG
$meta = $currentRepo->getOption("META_SOURCES");
unset($meta["meta.syncable"]["REQUIRES_INDEXATION"]);
$currentRepo->addOption("META_SOURCES", $meta);
ConfService::replaceRepository($currentRepo->getId(), $currentRepo);
}
HTMLWriter::charsetHeader('application/json', 'UTF-8');
$stream = isset($httpVars["stream"]);
$separator = $stream ? "\n" : ",";
$veryLastSeq = intval(dibi::query("SELECT MAX([seq]) FROM [ajxp_changes]")->fetchSingle());
$seqId = intval(AJXP_Utils::sanitize($httpVars["seq_id"], AJXP_SANITIZE_ALPHANUM));
if ($veryLastSeq > 0 && $seqId > $veryLastSeq) {
// This is not normal! Send a signal reload all changes from start.
if (!$stream) {
echo json_encode(array('changes' => array(), 'last_seq' => 1));
} else {
echo 'LAST_SEQ:1';
}
return null;
}
if (isset($httpVars["filter"])) {
$filter = AJXP_Utils::decodeSecureMagic($httpVars["filter"]);
$res = dibi::query("SELECT\n [seq] , [ajxp_changes].[repository_identifier] , [ajxp_changes].[node_id] , [type] , [source] , [target] , [ajxp_index].[bytesize], [ajxp_index].[md5], [ajxp_index].[mtime], [ajxp_index].[node_path]\n FROM [ajxp_changes]\n LEFT JOIN [ajxp_index]\n ON [ajxp_changes].[node_id] = [ajxp_index].[node_id]\n WHERE [ajxp_changes].[repository_identifier] = %s AND ([source] LIKE %like~ OR [target] LIKE %like~ ) AND [seq] > %i\n ORDER BY [ajxp_changes].[node_id], [seq] ASC", $this->computeIdentifier($currentRepo), rtrim($filter, "/") . "/", rtrim($filter, "/") . "/", $seqId);
} else {
$res = dibi::query("SELECT\n [seq] , [ajxp_changes].[repository_identifier] , [ajxp_changes].[node_id] , [type] , [source] , [target] , [ajxp_index].[bytesize], [ajxp_index].[md5], [ajxp_index].[mtime], [ajxp_index].[node_path]\n FROM [ajxp_changes]\n LEFT JOIN [ajxp_index]\n ON [ajxp_changes].[node_id] = [ajxp_index].[node_id]\n WHERE [ajxp_changes].[repository_identifier] = %s AND [seq] > %i\n ORDER BY [ajxp_changes].[node_id], [seq] ASC", $this->computeIdentifier($currentRepo), $seqId);
}
if (!$stream) {
echo '{"changes":[';
}
$previousNodeId = -1;
$previousRow = null;
$order = array("path" => 0, "content" => 1, "create" => 2, "delete" => 3);
$relocateAttrs = array("bytesize", "md5", "mtime", "node_path", "repository_identifier");
$valuesSent = false;
foreach ($res as $row) {
$row->node = array();
foreach ($relocateAttrs as $att) {
$row->node[$att] = $row->{$att};
unset($row->{$att});
}
if (!empty($recycle)) {
$this->cancelRecycleNodes($row, $recycle);
}
if (!isset($httpVars["flatten"]) || $httpVars["flatten"] == "false") {
if (!$this->filterRow($row, $filter)) {
if ($valuesSent) {
echo $separator;
}
echo json_encode($row);
$valuesSent = true;
}
} else {
if ($row->node_id == $previousNodeId) {
$previousRow->target = $row->target;
$previousRow->seq = $row->seq;
if ($order[$row->type] > $order[$previousRow->type]) {
$previousRow->type = $row->type;
}
} else {
if (isset($previousRow) && ($previousRow->source != $previousRow->target || $previousRow->type == "content")) {
if ($this->filterRow($previousRow, $filter)) {
$previousRow = $row;
$previousNodeId = $row->node_id;
$lastSeq = $row->seq;
continue;
}
if ($valuesSent) {
//.........这里部分代码省略.........
示例10: setName
/**
* Renames the node
*
* @param string $name The new name
* @return void
*/
public function setName($name)
{
$data = $this->getResourceData();
ob_start();
AJXP_Controller::findActionAndApply("rename", array("filename_new" => $name, "dir" => dirname($this->path), "file" => $this->path), array());
ob_get_flush();
$this->putResourceData(array());
$this->putResourceData($data, dirname($this->getUrl()) . "/" . $name);
}
示例11: createDirectory
/**
* Creates a new subdirectory
*
* @param string $name
* @return void
*/
public function createDirectory($name)
{
if (isset($this->children)) {
$this->children = null;
}
AJXP_Controller::findActionAndApply("mkdir", array("dir" => $this->path, "dirname" => $name), array());
}
示例12: performDelete
/**
* Deletes everything below a path.
*
* Deletes the resource identified by $path recursively. Returns an
* instance of {@link ezcWebdavMultistatusResponse} if the deletion failed,
* and null on success.
*
* @param string $path
* @return ezcWebdavMultitstatusResponse|null
*/
protected function performDelete($path)
{
$path = $this->fixPath($path);
$logs = array();
//$this->getAccessDriver()->delete(array($path), $logs);
ob_start();
try {
AJXP_Controller::findActionAndApply("delete", array("dir" => dirname($path), "file_0" => $path), array());
} catch (Exception $e) {
}
$result = ob_get_flush();
AJXP_Logger::debug("RESULT : " . $result);
$metaStore = $this->getMetastore();
if ($metaStore == false) {
return;
}
$metaStore->removeMetadata(new AJXP_Node($this->getAccessDriver()->getRessourceUrl($path)), "ezcWEBDAV", false, AJXP_METADATA_SCOPE_GLOBAL);
return null;
}
示例13: loadMinisite
//.........这里部分代码省略.........
$html = str_replace("PYDIO_APP_TITLE", ConfService::getCoreConf("APPLICATION_TITLE"), $html);
if (isset($repository) && isset($repoObject)) {
$html = str_replace("AJXP_START_REPOSITORY", $repository, $html);
$html = str_replace("AJXP_REPOSITORY_LABEL", ConfService::getRepositoryById($repository)->getDisplay(), $html);
}
$html = str_replace('AJXP_HASH_LOAD_ERROR', isset($error) ? $error : '', $html);
$html = str_replace("AJXP_TEMPLATE_NAME", $templateName, $html);
$html = str_replace("AJXP_LINK_HASH", $hash, $html);
$guiConfigs = AJXP_PluginsService::findPluginById("gui.ajax")->getConfigs();
$html = str_replace("AJXP_THEME", $guiConfigs["GUI_THEME"], $html);
if (isset($_GET["dl"]) && isset($_GET["file"])) {
AuthService::$useSession = false;
} else {
session_name("AjaXplorer_Shared" . str_replace(".", "_", $hash));
session_start();
AuthService::disconnect();
}
if (!empty($data["PRELOG_USER"])) {
AuthService::logUser($data["PRELOG_USER"], "", true);
$html = str_replace("AJXP_PRELOGED_USER", "ajxp_preloged_user", $html);
} else {
if (isset($data["PRESET_LOGIN"])) {
$_SESSION["PENDING_REPOSITORY_ID"] = $repository;
$_SESSION["PENDING_FOLDER"] = "/";
$html = str_replace("AJXP_PRELOGED_USER", $data["PRESET_LOGIN"], $html);
} else {
$html = str_replace("AJXP_PRELOGED_USER", "ajxp_legacy_minisite", $html);
}
}
if (isset($hash)) {
$_SESSION["CURRENT_MINISITE"] = $hash;
}
if (isset($_GET["dl"]) && isset($_GET["file"]) && (!isset($data["DOWNLOAD_DISABLED"]) || $data["DOWNLOAD_DISABLED"] === false)) {
ConfService::switchRootDir($repository);
ConfService::loadRepositoryDriver();
AJXP_PluginsService::deferBuildingRegistry();
AJXP_PluginsService::getInstance()->initActivePlugins();
AJXP_PluginsService::flushDeferredRegistryBuilding();
$errMessage = null;
try {
$params = $_GET;
$ACTION = "download";
if (isset($_GET["ct"])) {
$mime = pathinfo($params["file"], PATHINFO_EXTENSION);
$editors = AJXP_PluginsService::searchAllManifests("//editor[contains(@mimes,'{$mime}') and @previewProvider='true']", "node", true, true, false);
if (count($editors)) {
foreach ($editors as $editor) {
$xPath = new DOMXPath($editor->ownerDocument);
$callbacks = $xPath->query("//action[@contentTypedProvider]", $editor);
if ($callbacks->length) {
$ACTION = $callbacks->item(0)->getAttribute("name");
if ($ACTION == "audio_proxy") {
$params["file"] = "base64encoded:" . base64_encode($params["file"]);
}
break;
}
}
}
}
AJXP_Controller::registryReset();
AJXP_Controller::findActionAndApply($ACTION, $params, null);
} catch (Exception $e) {
$errMessage = $e->getMessage();
}
if ($errMessage == null) {
return;
}
$html = str_replace('AJXP_HASH_LOAD_ERROR', $errMessage, $html);
}
if (isset($_GET["lang"])) {
$loggedUser =& AuthService::getLoggedUser();
if ($loggedUser != null) {
$loggedUser->setPref("lang", $_GET["lang"]);
} else {
setcookie("AJXP_lang", $_GET["lang"]);
}
}
if (!empty($data["AJXP_APPLICATION_BASE"])) {
$tPath = $data["AJXP_APPLICATION_BASE"];
} else {
$tPath = !empty($data["TRAVEL_PATH_TO_ROOT"]) ? $data["TRAVEL_PATH_TO_ROOT"] : "../..";
}
$serverBaseUrl = AJXP_Utils::detectServerURL(true);
// Update Host dynamically if it differ from registered one.
$registeredHost = parse_url($tPath, PHP_URL_HOST);
$currentHost = parse_url($serverBaseUrl, PHP_URL_HOST);
if ($registeredHost != $currentHost) {
$tPath = str_replace($registeredHost, $currentHost, $tPath);
}
// Update scheme dynamically if it differ from registered one.
$registeredScheme = parse_url($tPath, PHP_URL_SCHEME);
$currentScheme = parse_url($serverBaseUrl, PHP_URL_SCHEME);
if ($registeredScheme != $currentScheme) {
$tPath = str_replace($registeredScheme . "://", $currentScheme . "://", $tPath);
}
$html = str_replace("AJXP_PATH_TO_ROOT", rtrim($tPath, "/") . "/", $html);
HTMLWriter::internetExplorerMainDocumentHeader();
HTMLWriter::charsetHeader();
echo $html;
}
示例14: loadPubliclet
/**
* @static
* @param Array $data
* @return void
*/
static function loadPubliclet($data)
{
// create driver from $data
$className = $data["DRIVER"] . "AccessDriver";
$hash = md5(serialize($data));
if ($data["EXPIRE_TIME"] && time() > $data["EXPIRE_TIME"] || $data["DOWNLOAD_LIMIT"] && $data["DOWNLOAD_LIMIT"] > 0 && $data["DOWNLOAD_LIMIT"] <= PublicletCounter::getCount($hash)) {
// Remove the publiclet, it's done
if (strstr(realpath($_SERVER["SCRIPT_FILENAME"]), realpath(ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER"))) !== FALSE) {
PublicletCounter::delete($hash);
unlink($_SERVER["SCRIPT_FILENAME"]);
}
echo "Link is expired, sorry.";
exit;
}
// Load language messages
$language = "en";
if (isset($_GET["lang"])) {
$language = $_GET["lang"];
}
$messages = array();
if (is_file(dirname(__FILE__) . "/res/i18n/" . $language . ".php")) {
include dirname(__FILE__) . "/res/i18n/" . $language . ".php";
$messages = $mess;
} else {
include dirname(__FILE__) . "/res/i18n/en.php";
}
$AJXP_LINK_HAS_PASSWORD = false;
$AJXP_LINK_BASENAME = SystemTextEncoding::toUTF8(basename($data["FILE_PATH"]));
// Check password
if (strlen($data["PASSWORD"])) {
if (!isset($_POST['password']) || $_POST['password'] != $data["PASSWORD"]) {
$AJXP_LINK_HAS_PASSWORD = true;
$AJXP_LINK_WRONG_PASSWORD = isset($_POST['password']) && $_POST['password'] != $data["PASSWORD"];
include AJXP_INSTALL_PATH . "/plugins/action.share/res/public_links.php";
return;
}
} else {
if (!isset($_GET["dl"])) {
include AJXP_INSTALL_PATH . "/plugins/action.share/res/public_links.php";
return;
}
}
$filePath = AJXP_INSTALL_PATH . "/plugins/access." . $data["DRIVER"] . "/class." . $className . ".php";
if (!is_file($filePath)) {
die("Warning, cannot find driver for conf storage! ({$className}, {$filePath})");
}
require_once $filePath;
$driver = new $className($data["PLUGIN_ID"], $data["BASE_DIR"]);
$driver->loadManifest();
$hash = md5(serialize($data));
PublicletCounter::increment($hash);
AuthService::logUser($data["OWNER_ID"], "", true);
if ($driver->hasMixin("credentials_consumer") && isset($data["SAFE_USER"]) && isset($data["SAFE_PASS"])) {
// FORCE SESSION MODE
AJXP_Safe::getInstance()->forceSessionCredentialsUsage();
AJXP_Safe::storeCredentials($data["SAFE_USER"], $data["SAFE_PASS"]);
}
$repoObject = $data["REPOSITORY"];
ConfService::switchRootDir($repoObject->getId());
ConfService::loadRepositoryDriver();
ConfService::initActivePlugins();
try {
$params = array("file" => SystemTextEncoding::toUTF8($data["FILE_PATH"]));
if (isset($data["PLUGINS_DATA"])) {
$params["PLUGINS_DATA"] = $data["PLUGINS_DATA"];
}
AJXP_Controller::findActionAndApply($data["ACTION"], $params, null);
} catch (Exception $e) {
die($e->getMessage());
}
}
示例15: downloadFile
public function downloadFile($nodeName)
{
$nodeName = urldecode($nodeName);
//ob_start();
$alreadyInstanciated = true;
if (AuthService::getLoggedUser() == null) {
AuthService::logUser($this->authLogin, $this->authPwd, true);
$alreadyInstanciated = false;
}
$parts = explode("/", trim($nodeName, "/"));
$repoAlias = array_shift($parts);
$fileName = implode("/", $parts);
$nbRep = ConfService::getRepositoryByAlias($repoAlias);
$defaultRepoId = $nbRep->getId();
ConfService::switchRootDir($defaultRepoId);
ConfService::getConfStorageImpl();
ConfService::loadRepositoryDriver();
if (!$alreadyInstanciated) {
AJXP_PluginsService::getInstance()->initActivePlugins();
}
//ob_end_clean();
AJXP_Controller::findActionAndApply("download", array("file" => "/" . $fileName), array());
exit;
}