本文整理汇总了PHP中ConfService::backgroundActionsSupported方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfService::backgroundActionsSupported方法的具体用法?PHP ConfService::backgroundActionsSupported怎么用?PHP ConfService::backgroundActionsSupported使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfService
的用法示例。
在下文中一共展示了ConfService::backgroundActionsSupported方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: applyAction
public function applyAction($actionName, $httpVars, $fileVars)
{
$messages = ConfService::getMessages();
if ($actionName == "index") {
$repository = ConfService::getRepository();
$repositoryId = $repository->getId();
$userSelection = new UserSelection($repository, $httpVars);
if ($userSelection->isEmpty()) {
$userSelection->addFile("/");
}
$nodes = $userSelection->buildNodes($repository->driverInstance);
if (isset($httpVars["verbose"]) && $httpVars["verbose"] == "true") {
$this->verboseIndexation = true;
}
if (ConfService::backgroundActionsSupported() && !ConfService::currentContextIsCommandLine()) {
AJXP_Controller::applyActionInBackground($repositoryId, "index", $httpVars);
AJXP_XMLWriter::header();
AJXP_XMLWriter::triggerBgAction("check_index_status", array("repository_id" => $repositoryId), sprintf($messages["core.index.8"], $nodes[0]->getPath()), true, 2);
if (!isset($httpVars["inner_apply"])) {
AJXP_XMLWriter::close();
}
return null;
}
// GIVE BACK THE HAND TO USER
session_write_close();
foreach ($nodes as $node) {
$dir = $node->getPath() == "/" || is_dir($node->getUrl());
// SIMPLE FILE
if (!$dir) {
try {
$this->logDebug("Indexing - node.index " . $node->getUrl());
AJXP_Controller::applyHook("node.index", array($node));
} catch (Exception $e) {
$this->logDebug("Error Indexing Node " . $node->getUrl() . " (" . $e->getMessage() . ")");
}
} else {
try {
$this->recursiveIndexation($node);
} catch (Exception $e) {
$this->logDebug("Indexation of " . $node->getUrl() . " interrupted by error: (" . $e->getMessage() . ")");
}
}
}
} else {
if ($actionName == "check_index_status") {
$repoId = $httpVars["repository_id"];
list($status, $message) = $this->getIndexStatus(ConfService::getRepositoryById($repoId), AuthService::getLoggedUser());
if (!empty($status)) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::triggerBgAction("check_index_status", array("repository_id" => $repoId), $message, true, 3);
AJXP_XMLWriter::close();
} else {
AJXP_XMLWriter::header();
AJXP_XMLWriter::triggerBgAction("info_message", array(), $messages["core.index.5"], true, 5);
AJXP_XMLWriter::close();
}
}
}
return null;
}
示例2: performChecks
public function performChecks()
{
if (!ConfService::backgroundActionsSupported()) {
throw new Exception("The command line must be supported. See 'Pydio Core Options'.");
}
if (!is_dir(dirname($this->getDbFile()))) {
throw new Exception("Could not create the db folder!");
}
}
示例3: 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;
$masks = array();
$currentRepo = $this->accessDriver->repository;
AJXP_Controller::applyHook("role.masks", array($currentRepo->getId(), &$masks, AJXP_Permission::READ));
$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;
}
$ands = array();
$ands[] = array("[ajxp_changes].[repository_identifier] = %s", $this->computeIdentifier($currentRepo));
$ands[] = array("[seq] > %i", $seqId);
if (isset($httpVars["filter"])) {
$filter = AJXP_Utils::decodeSecureMagic($httpVars["filter"]);
$filterLike = rtrim($filter, "/") . "/";
$ands[] = array("[source] LIKE %like~ OR [target] LIKE %like~", $filterLike, $filterLike);
}
if (count($masks)) {
$ors = array();
foreach ($masks as $mask) {
$filterLike = rtrim($mask, "/") . "/";
$ors[] = array("[source] LIKE %like~ OR [target] LIKE %like~", $filterLike, $filterLike);
}
if (count($ors)) {
$ands[] = array("%or", $ors);
}
}
$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 %and\n ORDER BY [ajxp_changes].[node_id], [seq] ASC", $ands);
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->filterMasks($row, $masks) && !$this->filterRow($row, $filter)) {
if ($valuesSent) {
echo $separator;
}
echo json_encode($row);
$valuesSent = true;
}
} else {
//.........这里部分代码省略.........
示例4: receiveAction
/**
* @param String $action
* @param Array $httpVars
* @param Array $fileVars
* @throws Exception
*/
public function receiveAction($action, $httpVars, $fileVars)
{
//VAR CREATION OUTSIDE OF ALL CONDITIONS, THEY ARE "MUST HAVE" VAR !!
$messages = ConfService::getMessages();
$repository = ConfService::getRepository();
$userSelection = new UserSelection($repository, $httpVars);
$nodes = $userSelection->buildNodes();
$currentDirPath = AJXP_Utils::safeDirname($userSelection->getUniqueNode()->getPath());
$currentDirPath = rtrim($currentDirPath, "/") . "/";
$currentDirUrl = $userSelection->currentBaseUrl() . $currentDirPath;
if (empty($httpVars["compression_id"])) {
$compressionId = sha1(rand());
$httpVars["compression_id"] = $compressionId;
} else {
$compressionId = $httpVars["compression_id"];
}
$progressCompressionFileName = $this->getPluginCacheDir(false, true) . DIRECTORY_SEPARATOR . "progressCompressionID-" . $compressionId . ".txt";
if (empty($httpVars["extraction_id"])) {
$extractId = sha1(rand());
$httpVars["extraction_id"] = $extractId;
} else {
$extractId = $httpVars["extraction_id"];
}
$progressExtractFileName = $this->getPluginCacheDir(false, true) . DIRECTORY_SEPARATOR . "progressExtractID-" . $extractId . ".txt";
if ($action == "compression") {
$archiveName = AJXP_Utils::sanitize(AJXP_Utils::decodeSecureMagic($httpVars["archive_name"]), AJXP_SANITIZE_FILENAME);
$archiveFormat = $httpVars["type_archive"];
$tabTypeArchive = array(".tar", ".tar.gz", ".tar.bz2");
$acceptedExtension = false;
foreach ($tabTypeArchive as $extensionArchive) {
if ($extensionArchive == $archiveFormat) {
$acceptedExtension = true;
break;
}
}
if ($acceptedExtension == false) {
file_put_contents($progressCompressionFileName, "Error : " . $messages["compression.16"]);
throw new AJXP_Exception($messages["compression.16"]);
}
$typeArchive = $httpVars["type_archive"];
//if we can run in background we do it
if (ConfService::backgroundActionsSupported() && !ConfService::currentContextIsCommandLine()) {
$archivePath = $currentDirPath . $archiveName;
file_put_contents($progressCompressionFileName, $messages["compression.5"]);
AJXP_Controller::applyActionInBackground($repository->getId(), "compression", $httpVars);
AJXP_XMLWriter::header();
AJXP_XMLWriter::triggerBgAction("check_compression_status", array("repository_id" => $repository->getId(), "compression_id" => $compressionId, "archive_path" => SystemTextEncoding::toUTF8($archivePath)), $messages["compression.5"], true, 2);
AJXP_XMLWriter::close();
return null;
} else {
$maxAuthorizedSize = 4294967296;
$currentDirUrlLength = strlen($currentDirUrl);
$tabFolders = array();
$tabAllRecursiveFiles = array();
$tabFilesNames = array();
foreach ($nodes as $node) {
$nodeUrl = $node->getUrl();
if (is_file($nodeUrl) && filesize($nodeUrl) < $maxAuthorizedSize) {
array_push($tabAllRecursiveFiles, $nodeUrl);
array_push($tabFilesNames, substr($nodeUrl, $currentDirUrlLength));
}
if (is_dir($nodeUrl)) {
array_push($tabFolders, $nodeUrl);
}
}
//DO A FOREACH OR IT'S GONNA HAVE SOME SAMES FILES NAMES
foreach ($tabFolders as $value) {
$dossiers = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($value));
foreach ($dossiers as $file) {
if ($file->isDir()) {
continue;
}
array_push($tabAllRecursiveFiles, $file->getPathname());
array_push($tabFilesNames, substr($file->getPathname(), $currentDirUrlLength));
}
}
//WE STOP IF IT'S JUST AN EMPTY FOLDER OR NO FILES
if (empty($tabFilesNames)) {
file_put_contents($progressCompressionFileName, "Error : " . $messages["compression.17"]);
throw new AJXP_Exception($messages["compression.17"]);
}
try {
$tmpArchiveName = tempnam(AJXP_Utils::getAjxpTmpDir(), "tar-compression") . ".tar";
$archive = new PharData($tmpArchiveName);
} catch (Exception $e) {
file_put_contents($progressCompressionFileName, "Error : " . $e->getMessage());
throw $e;
}
$counterCompression = 0;
//THE TWO ARRAY ARE MERGED FOR THE FOREACH LOOP
$tabAllFiles = array_combine($tabAllRecursiveFiles, $tabFilesNames);
foreach ($tabAllFiles as $fullPath => $fileName) {
try {
$archive->addFile(AJXP_MetaStreamWrapper::getRealFSReference($fullPath), $fileName);
//.........这里部分代码省略.........
示例5: switchAction
public function switchAction($action, $httpVars, $fileVars)
{
$selection = new UserSelection();
$dir = $httpVars["dir"] or "";
$dir = AJXP_Utils::decodeSecureMagic($dir);
if ($dir == "/") {
$dir = "";
}
$selection->initFromHttpVars($httpVars);
if (!$selection->isEmpty()) {
//$this->filterUserSelectionToHidden($selection->getFiles());
}
$urlBase = "pydio://" . ConfService::getRepository()->getId();
$mess = ConfService::getMessages();
switch ($action) {
case "monitor_compression":
$percentFile = fsAccessWrapper::getRealFSReference($urlBase . $dir . "/.zip_operation_" . $httpVars["ope_id"]);
$percent = 0;
if (is_file($percentFile)) {
$percent = intval(file_get_contents($percentFile));
}
if ($percent < 100) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::triggerBgAction("monitor_compression", $httpVars, $mess["powerfs.1"] . " ({$percent}%)", true, 1);
AJXP_XMLWriter::close();
} else {
@unlink($percentFile);
AJXP_XMLWriter::header();
if ($httpVars["on_end"] == "reload") {
AJXP_XMLWriter::triggerBgAction("reload_node", array(), "powerfs.2", true, 2);
} else {
$archiveName = AJXP_Utils::sanitize($httpVars["archive_name"], AJXP_SANITIZE_FILENAME);
$archiveName = str_replace("'", "\\'", $archiveName);
$jsCode = "\n PydioApi.getClient().downloadSelection(null, \$('download_form'), 'postcompress_download', {ope_id:'" . $httpVars["ope_id"] . "',archive_name:'" . $archiveName . "'});\n ";
AJXP_XMLWriter::triggerBgJsAction($jsCode, $mess["powerfs.3"], true);
AJXP_XMLWriter::triggerBgAction("reload_node", array(), "powerfs.2", true, 2);
}
AJXP_XMLWriter::close();
}
break;
case "postcompress_download":
$archive = AJXP_Utils::getAjxpTmpDir() . DIRECTORY_SEPARATOR . $httpVars["ope_id"] . "_" . AJXP_Utils::sanitize(AJXP_Utils::decodeSecureMagic($httpVars["archive_name"]), AJXP_SANITIZE_FILENAME);
$fsDriver = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("access");
if (is_file($archive)) {
if (!$fsDriver->getFilteredOption("USE_XSENDFILE", ConfService::getRepository()) && !$fsDriver->getFilteredOption("USE_XACCELREDIRECT", ConfService::getRepository())) {
register_shutdown_function("unlink", $archive);
}
$fsDriver->readFile($archive, "force-download", $httpVars["archive_name"], false, null, true);
} else {
echo "<script>alert('Cannot find archive! Is ZIP correctly installed?');</script>";
}
break;
case "compress":
case "precompress":
$archiveName = AJXP_Utils::sanitize(AJXP_Utils::decodeSecureMagic($httpVars["archive_name"]), AJXP_SANITIZE_FILENAME);
if (!ConfService::currentContextIsCommandLine() && ConfService::backgroundActionsSupported()) {
$opeId = substr(md5(time()), 0, 10);
$httpVars["ope_id"] = $opeId;
AJXP_Controller::applyActionInBackground(ConfService::getRepository()->getId(), $action, $httpVars);
AJXP_XMLWriter::header();
$bgParameters = array("dir" => SystemTextEncoding::toUTF8($dir), "archive_name" => SystemTextEncoding::toUTF8($archiveName), "on_end" => isset($httpVars["on_end"]) ? $httpVars["on_end"] : "reload", "ope_id" => $opeId);
AJXP_XMLWriter::triggerBgAction("monitor_compression", $bgParameters, $mess["powerfs.1"] . " (0%)", true);
AJXP_XMLWriter::close();
session_write_close();
exit;
}
$rootDir = fsAccessWrapper::getRealFSReference($urlBase) . $dir;
$percentFile = $rootDir . "/.zip_operation_" . $httpVars["ope_id"];
$compressLocally = $action == "compress" ? true : false;
// List all files
$todo = array();
$args = array();
$replaceSearch = array($rootDir, "\\");
$replaceReplace = array("", "/");
foreach ($selection->getFiles() as $selectionFile) {
$baseFile = $selectionFile;
$args[] = escapeshellarg(substr($selectionFile, strlen($dir) + ($dir == "/" ? 0 : 1)));
$selectionFile = fsAccessWrapper::getRealFSReference($urlBase . $selectionFile);
$todo[] = ltrim(str_replace($replaceSearch, $replaceReplace, $selectionFile), "/");
if (is_dir($selectionFile)) {
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($selectionFile), RecursiveIteratorIterator::SELF_FIRST);
foreach ($objects as $name => $object) {
$todo[] = str_replace($replaceSearch, $replaceReplace, $name);
}
}
if (trim($baseFile, "/") == "") {
// ROOT IS SELECTED, FIX IT
$args = array(escapeshellarg(basename($rootDir)));
$rootDir = dirname($rootDir);
break;
}
}
$cmdSeparator = PHP_OS == "WIN32" || PHP_OS == "WINNT" || PHP_OS == "Windows" ? "&" : ";";
if (!$compressLocally) {
$archiveName = AJXP_Utils::getAjxpTmpDir() . DIRECTORY_SEPARATOR . $httpVars["ope_id"] . "_" . $archiveName;
}
chdir($rootDir);
$cmd = $this->getFilteredOption("ZIP_PATH") . " -r " . escapeshellarg($archiveName) . " " . implode(" ", $args);
$fsDriver = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("access");
$c = $fsDriver->getConfigs();
//.........这里部分代码省略.........
示例6: switchAction
function switchAction($action, $httpVars, $fileVars)
{
if (!isset($this->actions[$action])) {
return;
}
$selection = new UserSelection();
$dir = $httpVars["dir"] or "";
$dir = AJXP_Utils::securePath($dir);
if ($dir == "/") {
$dir = "";
}
$selection->initFromHttpVars($httpVars);
if (!$selection->isEmpty()) {
//$this->filterUserSelectionToHidden($selection->getFiles());
}
$urlBase = "ajxp.fs://" . ConfService::getRepository()->getId();
$mess = ConfService::getMessages();
switch ($action) {
case "monitor_compression":
$percentFile = fsAccessWrapper::getRealFSReference($urlBase . $dir . "/.zip_operation_" . $httpVars["ope_id"]);
$percent = 0;
if (is_file($percentFile)) {
$percent = intval(file_get_contents($percentFile));
}
if ($percent < 100) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::triggerBgAction("monitor_compression", $httpVars, $mess["powerfs.1"] . " ({$percent}%)", true, 1);
AJXP_XMLWriter::close();
} else {
@unlink($percentFile);
AJXP_XMLWriter::header();
if ($httpVars["on_end"] == "reload") {
AJXP_XMLWriter::triggerBgAction("reload_node", array(), "powerfs.2", true, 2);
} else {
$archiveName = $httpVars["archive_name"];
$jsCode = "\n \$('download_form').action = window.ajxpServerAccessPath;\n \$('download_form').secure_token.value = window.Connexion.SECURE_TOKEN;\n \$('download_form').select('input').each(function(input){\n if(input.name!='get_action' && input.name!='secure_token') input.remove();\n });\n \$('download_form').insert(new Element('input', {type:'hidden', name:'ope_id', value:'" . $httpVars["ope_id"] . "'}));\n \$('download_form').insert(new Element('input', {type:'hidden', name:'archive_name', value:'" . $archiveName . "'}));\n \$('download_form').insert(new Element('input', {type:'hidden', name:'get_action', value:'postcompress_download'}));\n \$('download_form').submit();\n ";
AJXP_XMLWriter::triggerBgJsAction($jsCode, "powerfs.3", true);
AJXP_XMLWriter::triggerBgAction("reload_node", array(), "powerfs.2", true, 2);
}
AJXP_XMLWriter::close();
}
break;
case "postcompress_download":
$archive = AJXP_Utils::getAjxpTmpDir() . "/" . $httpVars["ope_id"] . "_" . $httpVars["archive_name"];
//$fsDriver = new fsAccessDriver("fake", "");
$fsDriver = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("access");
$fsDriver->readFile($archive, "force-download", $httpVars["archive_name"], false, null, true);
break;
case "compress":
case "precompress":
if (!ConfService::currentContextIsCommandLine() && ConfService::backgroundActionsSupported()) {
$opeId = substr(md5(time()), 0, 10);
$httpVars["ope_id"] = $opeId;
AJXP_Controller::applyActionInBackground(ConfService::getRepository()->getId(), $action, $httpVars);
AJXP_XMLWriter::header();
$bgParameters = array("dir" => $dir, "archive_name" => $httpVars["archive_name"], "on_end" => isset($httpVars["on_end"]) ? $httpVars["on_end"] : "reload", "ope_id" => $opeId);
AJXP_XMLWriter::triggerBgAction("monitor_compression", $bgParameters, $mess["powerfs.1"] . " (0%)", true);
AJXP_XMLWriter::close();
session_write_close();
exit;
}
$rootDir = fsAccessWrapper::getRealFSReference($urlBase) . $dir;
$percentFile = $rootDir . "/.zip_operation_" . $httpVars["ope_id"];
$compressLocally = $action == "compress" ? true : false;
// List all files
$todo = array();
$args = array();
$replaceSearch = array($rootDir, "\\");
$replaceReplace = array("", "/");
foreach ($selection->getFiles() as $selectionFile) {
$args[] = '"' . substr($selectionFile, strlen($dir) + ($dir == "/" ? 0 : 1)) . '"';
$selectionFile = fsAccessWrapper::getRealFSReference($urlBase . $selectionFile);
$todo[] = ltrim(str_replace($replaceSearch, $replaceReplace, $selectionFile), "/");
if (is_dir($selectionFile)) {
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($selectionFile), RecursiveIteratorIterator::SELF_FIRST);
foreach ($objects as $name => $object) {
$todo[] = str_replace($replaceSearch, $replaceReplace, $name);
}
}
}
$cmdSeparator = PHP_OS == "WIN32" || PHP_OS == "WINNT" || PHP_OS == "Windows" ? "&" : ";";
$archiveName = $httpVars["archive_name"];
if (!$compressLocally) {
$archiveName = AJXP_Utils::getAjxpTmpDir() . "/" . $httpVars["ope_id"] . "_" . $archiveName;
}
chdir($rootDir);
$cmd = "zip -r \"" . $archiveName . "\" " . implode(" ", $args);
$fsDriver = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("access");
$c = $fsDriver->getConfigs();
if (!isset($c["SHOW_HIDDEN_FILES"]) || $c["SHOW_HIDDEN_FILES"] == false) {
$cmd .= " -x .\\*";
}
$cmd .= " " . $cmdSeparator . " echo ZIP_FINISHED";
$proc = popen($cmd, "r");
$toks = array();
$handled = array();
$finishedEchoed = false;
while (!feof($proc)) {
set_time_limit(20);
$results = fgets($proc, 256);
//.........这里部分代码省略.........
示例7: switchAction
public function switchAction($action, $httpVars, $fileVars)
{
//AJXP_Logger::logAction("DL file", $httpVars);
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(false)) {
return false;
}
$plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType());
$streamData = $plugin->detectStreamWrapper(true);
$dir = AJXP_Utils::decodeSecureMagic($httpVars["dir"]);
$destStreamURL = $streamData["protocol"] . "://" . $repository->getId() . $dir . "/";
if (isset($httpVars["file"])) {
$parts = parse_url($httpVars["file"]);
$getPath = $parts["path"];
$basename = basename($getPath);
}
if (isset($httpVars["dlfile"])) {
$dlFile = $streamData["protocol"] . "://" . $repository->getId() . AJXP_Utils::decodeSecureMagic($httpVars["dlfile"]);
$realFile = file_get_contents($dlFile);
if (empty($realFile)) {
throw new Exception("cannot find file {$dlFile} for download");
}
$parts = parse_url($realFile);
$getPath = $parts["path"];
$basename = basename($getPath);
}
switch ($action) {
case "external_download":
if (!ConfService::currentContextIsCommandLine() && ConfService::backgroundActionsSupported()) {
$unixProcess = AJXP_Controller::applyActionInBackground($repository->getId(), "external_download", $httpVars);
if ($unixProcess !== null) {
@file_put_contents($destStreamURL . "." . $basename . ".pid", $unixProcess->getPid());
}
AJXP_XMLWriter::header();
AJXP_XMLWriter::triggerBgAction("reload_node", array(), "Triggering DL ", true, 2);
AJXP_XMLWriter::close();
session_write_close();
exit;
}
require_once AJXP_BIN_FOLDER . "/class.HttpClient.php";
$mess = ConfService::getMessages();
session_write_close();
$client = new HttpClient($parts["host"]);
$collectHeaders = array("ajxp-last-redirection" => "", "content-disposition" => "", "content-length" => "");
$client->setHeadersOnly(true, $collectHeaders);
$client->setMaxRedirects(8);
$client->setDebug(false);
$client->get($getPath);
$pidHiddenFileName = $destStreamURL . "." . $basename . ".pid";
if (is_file($pidHiddenFileName)) {
$pid = file_get_contents($pidHiddenFileName);
@unlink($pidHiddenFileName);
}
AJXP_Logger::debug("COLLECTED HEADERS", $client->collectHeaders);
$collectHeaders = $client->collectHeaders;
$totalSize = -1;
if (!empty($collectHeaders["content-disposition"]) && strstr($collectHeaders["content-disposition"], "filename") !== false) {
$ar = explode("filename=", $collectHeaders["content-disposition"]);
$basename = trim(array_pop($ar));
$basename = str_replace("\"", "", $basename);
// Remove quotes
}
if (!empty($collectHeaders["content-length"])) {
$totalSize = intval($collectHeaders["content-length"]);
AJXP_Logger::debug("Should download {$totalSize} bytes!");
}
if ($totalSize != -1) {
$node = new AJXP_Node($destStreamURL . $basename);
AJXP_Controller::applyHook("node.before_create", array($node, $totalSize));
}
$qData = false;
if (!empty($collectHeaders["ajxp-last-redirection"])) {
$newParsed = parse_url($collectHeaders["ajxp-last-redirection"]);
$client->host = $newParsed["host"];
$getPath = $newParsed["path"];
if (isset($newParsed["query"])) {
$qData = parse_url($newParsed["query"]);
}
}
$tmpFilename = $destStreamURL . $basename . ".dlpart";
$hiddenFilename = $destStreamURL . "__" . $basename . ".ser";
$filename = $destStreamURL . $basename;
$dlData = array("sourceUrl" => $getPath, "totalSize" => $totalSize);
if (isset($pid)) {
$dlData["pid"] = $pid;
}
//file_put_contents($hiddenFilename, serialize($dlData));
$fpHid = fopen($hiddenFilename, "w");
fputs($fpHid, serialize($dlData));
fclose($fpHid);
$client->redirect_count = 0;
$client->setHeadersOnly(false);
$destStream = fopen($tmpFilename, "w");
if ($destStream !== false) {
$client->writeContentToStream($destStream);
$client->get($getPath, $qData);
fclose($destStream);
}
rename($tmpFilename, $filename);
unlink($hiddenFilename);
//.........这里部分代码省略.........
示例8: switchAction
public function switchAction($action, $httpVars, $fileVars)
{
//$this->logInfo("DL file", $httpVars);
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(false)) {
return false;
}
$plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType());
$streamData = $plugin->detectStreamWrapper(true);
$dir = AJXP_Utils::decodeSecureMagic($httpVars["dir"]);
$destStreamURL = $streamData["protocol"] . "://" . $repository->getId() . $dir . "/";
$dlURL = null;
if (isset($httpVars["file"])) {
$parts = parse_url($httpVars["file"]);
$getPath = $parts["path"];
$basename = basename($getPath);
$dlURL = $httpVars["file"];
}
if (isset($httpVars["dlfile"])) {
$dlFile = $streamData["protocol"] . "://" . $repository->getId() . AJXP_Utils::decodeSecureMagic($httpVars["dlfile"]);
$realFile = file_get_contents($dlFile);
if (empty($realFile)) {
throw new Exception("cannot find file {$dlFile} for download");
}
$parts = parse_url($realFile);
$getPath = $parts["path"];
$basename = basename($getPath);
$dlURL = $realFile;
}
switch ($action) {
case "external_download":
if (!ConfService::currentContextIsCommandLine() && ConfService::backgroundActionsSupported()) {
$unixProcess = AJXP_Controller::applyActionInBackground($repository->getId(), "external_download", $httpVars);
if ($unixProcess !== null) {
@file_put_contents($destStreamURL . "." . $basename . ".pid", $unixProcess->getPid());
}
AJXP_XMLWriter::header();
AJXP_XMLWriter::triggerBgAction("reload_node", array(), "Triggering DL ", true, 2);
AJXP_XMLWriter::close();
session_write_close();
exit;
}
require_once AJXP_BIN_FOLDER . "/http_class/http_class.php";
session_write_close();
$httpClient = new http_class();
$arguments = array();
$httpClient->GetRequestArguments($httpVars["file"], $arguments);
$err = $httpClient->Open($arguments);
$collectHeaders = array("ajxp-last-redirection" => "", "content-disposition" => "", "content-length" => "");
if (empty($err)) {
$err = $httpClient->SendRequest($arguments);
$httpClient->follow_redirect = true;
$pidHiddenFileName = $destStreamURL . "." . $basename . ".pid";
if (is_file($pidHiddenFileName)) {
$pid = file_get_contents($pidHiddenFileName);
@unlink($pidHiddenFileName);
}
if (empty($err)) {
$httpClient->ReadReplyHeaders($collectHeaders);
$totalSize = -1;
if (!empty($collectHeaders["content-disposition"]) && strstr($collectHeaders["content-disposition"], "filename") !== false) {
$ar = explode("filename=", $collectHeaders["content-disposition"]);
$basename = trim(array_pop($ar));
$basename = str_replace("\"", "", $basename);
// Remove quotes
}
if (!empty($collectHeaders["content-length"])) {
$totalSize = intval($collectHeaders["content-length"]);
$this->logDebug("Should download {$totalSize} bytes!");
}
if ($totalSize != -1) {
$node = new AJXP_Node($destStreamURL . $basename);
AJXP_Controller::applyHook("node.before_create", array($node, $totalSize));
}
$tmpFilename = $destStreamURL . $basename . ".dlpart";
$hiddenFilename = $destStreamURL . "__" . $basename . ".ser";
$filename = $destStreamURL . $basename;
$dlData = array("sourceUrl" => $getPath, "totalSize" => $totalSize);
if (isset($pid)) {
$dlData["pid"] = $pid;
}
//file_put_contents($hiddenFilename, serialize($dlData));
$fpHid = fopen($hiddenFilename, "w");
fputs($fpHid, serialize($dlData));
fclose($fpHid);
// NOW READ RESPONSE
$destStream = fopen($tmpFilename, "w");
while (true) {
$body = "";
$error = $httpClient->ReadReplyBody($body, 1000);
if ($error != "" || strlen($body) == 0) {
break;
}
fwrite($destStream, $body, strlen($body));
}
fclose($destStream);
rename($tmpFilename, $filename);
unlink($hiddenFilename);
}
$httpClient->Close();
//.........这里部分代码省略.........
示例9: applyAction
public function applyAction($actionName, $httpVars, $fileVars)
{
$messages = ConfService::getMessages();
$repoId = $this->accessDriver->repository->getId();
if ($actionName == "search") {
// TMP
if (strpos($httpVars["query"], "keyword:") === 0) {
$parts = explode(":", $httpVars["query"]);
$this->applyAction("search_by_keyword", array("field" => $parts[1]), array());
return null;
}
require_once "Zend/Search/Lucene.php";
try {
$index = $this->loadIndex($repoId, false);
} catch (Exception $ex) {
AJXP_XMLWriter::header();
if ($this->seemsCurrentlyIndexing($repoId, 3)) {
AJXP_XMLWriter::sendMessage($messages["index.lucene.11"], null);
} else {
if (ConfService::backgroundActionsSupported() && !ConfService::currentContextIsCommandLine()) {
AJXP_Controller::applyActionInBackground($repoId, "index", array());
sleep(2);
AJXP_XMLWriter::triggerBgAction("check_index_status", array("repository_id" => $repoId), sprintf($messages["index.lucene.8"], "/"), true, 5);
AJXP_XMLWriter::sendMessage($messages["index.lucene.7"], null);
} else {
AJXP_XMLWriter::sendMessage($messages["index.lucene.12"], null);
}
}
AJXP_XMLWriter::close();
return null;
}
$textQuery = $httpVars["query"];
if ($this->getFilteredOption("AUTO_WILDCARD") === true && strlen($textQuery) > 0 && ctype_alnum($textQuery)) {
if ($textQuery[0] == '"' && $textQuery[strlen($textQuery) - 1] == '"') {
$textQuery = substr($textQuery, 1, -1);
} else {
if ($textQuery[strlen($textQuery) - 1] != "*") {
$textQuery .= "*";
}
}
}
if (strpos($textQuery, ":") !== false) {
$textQuery = str_replace("ajxp_meta_ajxp_document_content:", "body:", $textQuery);
$textQuery = $this->filterSearchRangesKeywords($textQuery);
$query = "ajxp_scope:shared AND ({$textQuery})";
} else {
if ((isset($this->metaFields) || $this->indexContent) && isset($httpVars["fields"])) {
$sParts = array();
foreach (explode(",", $httpVars["fields"]) as $searchField) {
if ($searchField == "filename") {
$sParts[] = "basename:" . $textQuery;
} else {
if ($searchField == "ajxp_document_content") {
$sParts[] = $textQuery;
} else {
if (in_array($searchField, $this->metaFields)) {
$sParts[] = "ajxp_meta_" . $searchField . ":" . $textQuery;
} else {
if ($searchField == "ajxp_document_content") {
$sParts[] = "title:" . $textQuery;
$sParts[] = "body:" . $textQuery;
$sParts[] = "keywords:" . $textQuery;
}
}
}
}
}
$query = implode(" OR ", $sParts);
$query = "ajxp_scope:shared AND ({$query})";
$this->logDebug("Query : {$query}");
} else {
$index->setDefaultSearchField("basename");
$query = $this->filterSearchRangesKeywords($textQuery);
}
}
$this->setDefaultAnalyzer();
if ($query == "*") {
$index->setDefaultSearchField("ajxp_node");
$query = "yes";
$hits = $index->find($query, "node_url", SORT_STRING);
} else {
$hits = $index->find($query);
}
$commitIndex = false;
if (isset($httpVars['return_selection'])) {
$returnNodes = array();
} else {
AJXP_XMLWriter::header();
}
$cursor = 0;
if (isset($httpVars['limit'])) {
$limit = intval($httpVars['limit']);
}
foreach ($hits as $hit) {
// Backward compatibility
$hit->node_url = preg_replace("#ajxp\\.[a-z_]+://#", "pydio://", $hit->node_url);
if ($hit->serialized_metadata != null) {
$meta = unserialize(base64_decode($hit->serialized_metadata));
if (isset($meta["ajxp_modiftime"])) {
$meta["ajxp_relativetime"] = $meta["ajxp_description"] = $messages[4] . " " . AJXP_Utils::relativeDate($meta["ajxp_modiftime"], $messages);
//.........这里部分代码省略.........
示例10: applyAction
public function applyAction($actionName, $httpVars, $fileVars)
{
$messages = ConfService::getMessages();
if ($actionName == "search") {
require_once "Zend/Search/Lucene.php";
if ($this->isIndexLocked(ConfService::getRepository()->getId())) {
throw new Exception($messages["index.lucene.6"]);
}
try {
$index = $this->loadIndex(ConfService::getRepository()->getId(), false);
} catch (Exception $ex) {
$this->applyAction("index", array(), array());
throw new Exception($messages["index.lucene.7"]);
}
if ((isset($this->metaFields) || $this->indexContent) && isset($httpVars["fields"])) {
$sParts = array();
foreach (explode(",", $httpVars["fields"]) as $searchField) {
if ($searchField == "filename") {
$sParts[] = "basename:" . $httpVars["query"];
} else {
if (in_array($searchField, $this->metaFields)) {
$sParts[] = "ajxp_meta_" . $searchField . ":" . $httpVars["query"];
} else {
if ($searchField == "ajxp_document_content") {
$sParts[] = "title:" . $httpVars["query"];
$sParts[] = "body:" . $httpVars["query"];
$sParts[] = "keywords:" . $httpVars["query"];
}
}
}
}
$query = implode(" OR ", $sParts);
AJXP_Logger::debug("Query : {$query}");
} else {
$index->setDefaultSearchField("basename");
$query = $httpVars["query"];
}
$hits = $index->find($query);
$commitIndex = false;
AJXP_XMLWriter::header();
foreach ($hits as $hit) {
$meta = array();
//$isDir = false; // TO BE STORED IN INDEX
//$meta["icon"] = AJXP_Utils::mimetype(SystemTextEncoding::fromUTF8($hit->node_url), "image", $isDir);
if ($hit->serialized_metadata != null) {
$meta = unserialize(base64_decode($hit->serialized_metadata));
$tmpNode = new AJXP_Node(SystemTextEncoding::fromUTF8($hit->node_url), $meta);
} else {
$tmpNode = new AJXP_Node(SystemTextEncoding::fromUTF8($hit->node_url), array());
$tmpNode->loadNodeInfo();
}
if (!file_exists($tmpNode->getUrl())) {
$index->delete($hit->id);
$commitIndex = true;
continue;
}
$tmpNode->search_score = sprintf("%0.2f", $hit->score);
AJXP_XMLWriter::renderAjxpNode($tmpNode);
}
AJXP_XMLWriter::close();
if ($commitIndex) {
$index->commit();
}
} else {
if ($actionName == "index") {
$dir = AJXP_Utils::decodeSecureMagic($httpVars["dir"]);
if (empty($dir)) {
$dir = "/";
}
$repo = ConfService::getRepository();
if ($this->isIndexLocked($repo->getId())) {
throw new Exception($messages["index.lucene.6"]);
}
$accessType = $repo->getAccessType();
$accessPlug = AJXP_PluginsService::getInstance()->getPluginByTypeName("access", $accessType);
$stData = $accessPlug->detectStreamWrapper(true);
$repoId = $repo->getId();
$url = $stData["protocol"] . "://" . $repoId . $dir;
if (isset($httpVars["verbose"]) && $httpVars["verbose"] == "true") {
$this->verboseIndexation = true;
}
if (ConfService::backgroundActionsSupported() && !ConfService::currentContextIsCommandLine()) {
AJXP_Controller::applyActionInBackground($repoId, "index", $httpVars);
AJXP_XMLWriter::header();
AJXP_XMLWriter::triggerBgAction("check_lock", array(), sprintf($messages["index.lucene.8"], $dir), true, 2);
AJXP_XMLWriter::close();
return;
}
$this->lockIndex($repoId);
// GIVE BACK THE HAND TO USER
session_write_close();
$this->currentIndex = $this->loadIndex($repoId);
$this->recursiveIndexation($url);
if (ConfService::currentContextIsCommandLine() && $this->verboseIndexation) {
print "Optimizing\n";
}
$this->currentIndex->optimize();
if (ConfService::currentContextIsCommandLine() && $this->verboseIndexation) {
print "Commiting Index\n";
}
//.........这里部分代码省略.........
示例11: applyAction
//.........这里部分代码省略.........
throw new Exception($messages["index.lucene.7"]);
}
$sParts = array();
$searchField = $httpVars["field"];
if ($searchField == "ajxp_node") {
$sParts[] = "$searchField:yes";
} else {
$sParts[] = "$searchField:true";
}
if ($scope == "user") {
if (AuthService::usersEnabled() && AuthService::getLoggedUser() == null) {
throw new Exception("Cannot find current user");
}
$sParts[] = "ajxp_scope:user";
$sParts[] = "ajxp_user:".AuthService::getLoggedUser()->getId();
} else {
$sParts[] = "ajxp_scope:shared";
}
$query = implode(" AND ", $sParts);
$this->logDebug("Query : $query");
$hits = $this->currentIndex->find($query);
$commitIndex = false;
AJXP_XMLWriter::header();
foreach ($hits as $hit) {
if ($hit->serialized_metadata!=null) {
$meta = unserialize(base64_decode($hit->serialized_metadata));
$tmpNode = new AJXP_Node(SystemTextEncoding::fromUTF8($hit->node_url), $meta);
} else {
$tmpNode = new AJXP_Node(SystemTextEncoding::fromUTF8($hit->node_url), array());
$tmpNode->loadNodeInfo();
}
if (!file_exists($tmpNode->getUrl())) {
$this->currentIndex->delete($hit->id);
$commitIndex = true;
continue;
}
$tmpNode->search_score = sprintf("%0.2f", $hit->score);
AJXP_XMLWriter::renderAjxpNode($tmpNode);
}
AJXP_XMLWriter::close();
if ($commitIndex) {
$this->currentIndex->commit();
}*/
} else {
if ($actionName == "index") {
$dir = AJXP_Utils::decodeSecureMagic($httpVars["dir"]);
if (empty($dir)) {
$dir = "/";
}
$repo = ConfService::getRepository();
if ($this->isIndexLocked($repo->getId())) {
throw new Exception($messages["index.lucene.6"]);
}
$accessType = $repo->getAccessType();
$accessPlug = AJXP_PluginsService::getInstance()->getPluginByTypeName("access", $accessType);
$stData = $accessPlug->detectStreamWrapper(true);
$repoId = $repo->getId();
$url = $stData["protocol"] . "://" . $repoId . $dir;
if (isset($httpVars["verbose"]) && $httpVars["verbose"] == "true") {
$this->verboseIndexation = true;
}
if (ConfService::backgroundActionsSupported() && !ConfService::currentContextIsCommandLine()) {
AJXP_Controller::applyActionInBackground($repoId, "index", $httpVars);
AJXP_XMLWriter::header();
AJXP_XMLWriter::triggerBgAction("check_lock", array("repository_id" => $repoId), sprintf($messages["index.lucene.8"], $dir), true, 2);
AJXP_XMLWriter::close();
return;
}
$this->lockIndex($repoId);
// GIVE BACK THE HAND TO USER
session_write_close();
$this->loadIndex($repoId);
$this->currentIndex->open();
$this->recursiveIndexation($url);
if (ConfService::currentContextIsCommandLine() && $this->verboseIndexation) {
print "Optimizing\n";
$this->currentIndex->optimize();
}
$this->currentIndex->close();
$this->currentIndex = null;
$this->releaseLock($repoId);
} else {
if ($actionName == "check_lock") {
$repoId = $httpVars["repository_id"];
if ($this->isIndexLocked($repoId)) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::triggerBgAction("check_lock", array("repository_id" => $repoId), $messages["index.lucene.10"], true, 3);
AJXP_XMLWriter::close();
} else {
AJXP_XMLWriter::header();
AJXP_XMLWriter::triggerBgAction("info_message", array(), $messages["index.lucene.5"], true, 5);
AJXP_XMLWriter::close();
}
}
}
}
}
}