当前位置: 首页>>代码示例>>PHP>>正文


PHP AJXP_XMLWriter::triggerBgAction方法代码示例

本文整理汇总了PHP中AJXP_XMLWriter::triggerBgAction方法的典型用法代码示例。如果您正苦于以下问题:PHP AJXP_XMLWriter::triggerBgAction方法的具体用法?PHP AJXP_XMLWriter::triggerBgAction怎么用?PHP AJXP_XMLWriter::triggerBgAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AJXP_XMLWriter的用法示例。


在下文中一共展示了AJXP_XMLWriter::triggerBgAction方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
 }
开发者ID:rcmarotz,项目名称:pydio-core,代码行数:60,代码来源:class.CoreIndexer.php

示例2: 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);
//.........这里部分代码省略.........
开发者ID:Nanomani,项目名称:pydio-core,代码行数:101,代码来源:class.PluginCompression.php

示例3: 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();
//.........这里部分代码省略.........
开发者ID:Nanomani,项目名称:pydio-core,代码行数:101,代码来源:class.PowerFSController.php

示例4: uploadActions

 public function uploadActions($action, $httpVars, $filesVars)
 {
     switch ($action) {
         case "trigger_remote_copy":
             if (!$this->hasFilesToCopy()) {
                 break;
             }
             $toCopy = $this->getFileNameToCopy();
             $this->logDebug("trigger_remote", $toCopy);
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::triggerBgAction("next_to_remote", array(), "Copying file " . $toCopy . " to remote 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();
             }
             $crtRep = ConfService::getRepository();
             session_write_close();
             $secureToken = "";
             $httpClient = $this->getRemoteConnexion($secureToken);
             //$httpClient->setDebug(true);
             $postData = array("get_action" => "upload", "dir" => base64_encode($fData["destination"]), "secure_token" => $secureToken);
             $httpClient->postFile($crtRep->getOption("URI") . "?", $postData, "Filedata", $fData);
             if (strpos($httpClient->getHeader("content-type"), "text/xml") !== false && strpos($httpClient->getContent(), "require_auth") != false) {
                 $httpClient = $this->getRemoteConnexion($secureToken, true);
                 $postData["secure_token"] = $secureToken;
                 $httpClient->postFile($crtRep->getOption("URI"), $postData, "Filedata", $fData);
             }
             unlink($fData["tmp_name"]);
             $response = $httpClient->getContent();
             AJXP_XMLWriter::header();
             $this->logDebug("next_to_remote", $nextFile);
             if (intval($response) >= 400) {
                 AJXP_XMLWriter::sendMessage(null, "Error : " . intval($response));
             } else {
                 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;
                 }
                 $boxData["destination"] = $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 (!is_writeable($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");
                         $sizeRead = 0;
                         while ($sizeRead < intval($boxData["size"])) {
                             $chunk = fread($input, 4096);
                             $sizeRead += strlen($chunk);
                             fwrite($output, $chunk, strlen($chunk));
                         }
                         fclose($input);
                         fclose($output);
                         $boxData["tmp_name"] = $destName;
                         $this->storeFileToCopy($boxData);
//.........这里部分代码省略.........
开发者ID:rcmarotz,项目名称:pydio-core,代码行数:101,代码来源:class.remote_fsAccessDriver.php

示例5: 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");
//.........这里部分代码省略.........
开发者ID:rcmarotz,项目名称:pydio-core,代码行数:101,代码来源:class.ftpAccessDriver.php

示例6: uploadActions

 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 remote 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();
             }
             $crtRep = ConfService::getRepository();
             session_write_close();
             $sessionId = "";
             $httpClient = $this->getRemoteConnexion($sessionId);
             //$httpClient->setDebug(true);
             $postData = array("get_action" => "upload", "dir" => base64_encode($fData["destination"]));
             $httpClient->postFile($crtRep->getOption("URI") . "?ajxp_sessid={$sessionId}", $postData, "Filedata", $fData);
             if (strpos($httpClient->getHeader("content-type"), "text/xml") !== false && strpos($httpClient->getContent(), "require_auth") != false) {
                 $httpClient = $this->getRemoteConnexion($sessionId, true);
                 $postData["ajxp_sessid"] = $sessionId;
                 $httpClient->postFile($crtRep->getOption("URI"), $postData, "Filedata", $fData);
             }
             unlink($fData["tmp_name"]);
             $response = $httpClient->getContent();
             AJXP_XMLWriter::header();
             if (intval($response) >= 400) {
                 AJXP_XMLWriter::sendMessage(null, "Error : " . intval($response));
             } else {
                 if ($nextFile != '') {
                     AJXP_XMLWriter::triggerBgAction("next_to_remote", array(), "Copying file " . $nextFile . " to remote server");
                 } else {
                     AJXP_XMLWriter::sendMessage("Done", null);
                 }
             }
             AJXP_XMLWriter::close();
             exit(1);
             break;
         case "upload":
             $fancyLoader = false;
             if (isset($fileVars["Filedata"])) {
                 $fancyLoader = true;
                 if ($httpVars['dir'] != "") {
                     $httpVars['dir'] = "/" . base64_decode($httpVars['dir']);
                 }
             }
             if (isset($httpVars['dir']) && $httpVars['dir'] != "") {
                 $rep_source = $httpVars['dir'];
             } else {
                 $rep_source = "/";
             }
             $logMessage = "";
             //$fancyLoader = false;
             foreach ($filesVars as $boxName => $boxData) {
                 if ($boxName != "Filedata" && substr($boxName, 0, 9) != "userfile_") {
                     continue;
                 }
                 if ($boxName == "Filedata") {
                     $fancyLoader = true;
                 }
                 $err = Utils::parseFileDataErrors($boxData, $fancyLoader);
                 if ($err != null) {
                     $errorMessage = $err;
                     break;
                 }
                 $boxData["destination"] = $rep_source;
                 $destCopy = INSTALL_PATH . "/" . $this->repository->getOption("TMP_UPLOAD");
                 if (!is_dir($destCopy)) {
                     if (!@mkdir($destCopy)) {
                         $errorMessage = "Warning, cannot create folder for temporary copy.";
                         break;
                     }
                 }
                 if (!is_writeable($destCopy)) {
                     $errorMessage = "Warning, cannot write into temporary folder.";
                     break;
                 }
                 $destName = $destCopy . "/" . basename($boxData["tmp_name"]);
                 if (move_uploaded_file($boxData["tmp_name"], $destName)) {
                     $boxData["tmp_name"] = $destName;
                     $this->storeFileToCopy($boxData);
                 } else {
                     $mess = ConfService::getMessages();
                     $errorMessage = ($fancyLoader ? "411 " : "") . "{$mess['33']} " . $boxData["name"];
                 }
             }
             if ($fancyLoader) {
                 session_write_close();
                 if (isset($errorMessage)) {
//.........这里部分代码省略.........
开发者ID:bloveing,项目名称:openulteo,代码行数:101,代码来源:class.remote_fsAccessDriver.php

示例7: 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);
//.........这里部分代码省略.........
开发者ID:crodriguezn,项目名称:administrator-files,代码行数:101,代码来源:class.PowerFSController.php

示例8: 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);
//.........这里部分代码省略.........
开发者ID:crodriguezn,项目名称:administrator-files,代码行数:101,代码来源:class.HttpDownloader.php

示例9: 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();
//.........这里部分代码省略.........
开发者ID:rcmarotz,项目名称:pydio-core,代码行数:101,代码来源:class.HttpDownloader.php

示例10: 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);
//.........这里部分代码省略.........
开发者ID:thermalpaste,项目名称:pydio-core,代码行数:101,代码来源:class.AjxpLuceneIndexer.php

示例11: 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";
             }
//.........这里部分代码省略.........
开发者ID:crodriguezn,项目名称:administrator-files,代码行数:101,代码来源:class.AjxpLuceneIndexer.php

示例12: uploadActions

 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();
             }
             @ftp_put($this->connect, $this->secureFtpPath($this->path . base64_decode($fData['destination']) . "/" . $fData['name']), $fData['tmp_name'], FTP_BINARY);
             unlink($fData["tmp_name"]);
             AJXP_XMLWriter::header();
             if ($nextFile != '') {
                 AJXP_XMLWriter::triggerBgAction("next_to_remote", array(), "Copying file " . $nextFile . " to remote server");
             } else {
                 AJXP_XMLWriter::sendMessage("Done", null);
             }
             AJXP_XMLWriter::close();
             exit(1);
             break;
         case "upload":
             $fancyLoader = false;
             if (isset($fileVars["Filedata"])) {
                 $fancyLoader = true;
                 if ($httpVars['dir'] != "") {
                     $httpVars['dir'] = "/" . base64_decode($httpVars['dir']);
                 }
             }
             if (isset($httpVars['dir']) && $httpVars['dir'] != "") {
                 $rep_source = $httpVars['dir'];
             } else {
                 $rep_source = "/";
             }
             $logMessage = "";
             //$fancyLoader = false;
             foreach ($filesVars as $boxName => $boxData) {
                 if ($boxName != "Filedata" && substr($boxName, 0, 9) != "userfile_") {
                     continue;
                 }
                 if ($boxName == "Filedata") {
                     $fancyLoader = true;
                 }
                 $err = Utils::parseFileDataErrors($boxData, $fancyLoader);
                 if ($err != null) {
                     $errorMessage = $err;
                     break;
                 }
                 $boxData["destination"] = $rep_source;
                 $destCopy = INSTALL_PATH . "/tmp";
                 if (!is_dir($destCopy)) {
                     if (!@mkdir($destCopy)) {
                         $errorMessage = "Warning, cannot create folder for temporary copy.";
                         break;
                     }
                 }
                 if (!is_writeable($destCopy)) {
                     $errorMessage = "Warning, cannot write into temporary folder.";
                     break;
                 }
                 $destName = $destCopy . "/" . basename($boxData["tmp_name"]);
                 if (move_uploaded_file($boxData["tmp_name"], $destName)) {
                     $boxData["tmp_name"] = $destName;
                     $this->storeFileToCopy($boxData);
                 } else {
                     $mess = ConfService::getMessages();
                     $errorMessage = ($fancyLoader ? "411 " : "") . "{$mess['33']} " . $boxData["name"];
                 }
             }
             if ($fancyLoader) {
                 session_write_close();
                 if (isset($errorMessage)) {
                     header('HTTP/1.0 ' . $errorMessage);
                     die('Error ' . $errorMessage);
                 } else {
                     header('HTTP/1.0 200 OK');
                     die("200 OK");
                 }
             } else {
                 print "<html><script language=\"javascript\">\n";
                 if (isset($errorMessage)) {
                     print "\n if(parent.ajaxplorer.actionBar.multi_selector)parent.ajaxplorer.actionBar.multi_selector.submitNext('" . str_replace("'", "\\'", $errorMessage) . "');";
                 } else {
                     print "\n if(parent.ajaxplorer.actionBar.multi_selector)parent.ajaxplorer.actionBar.multi_selector.submitNext();";
                 }
                 print "</script></html>";
             }
             session_write_close();
//.........这里部分代码省略.........
开发者ID:bloveing,项目名称:openulteo,代码行数:101,代码来源:class.ftpAccessDriver.php

示例13: 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();
                     }
                 }
             }
         }
     }
 }
开发者ID:rmxcc,项目名称:pydio-core,代码行数:101,代码来源:class.AjxpElasticSearch.php


注:本文中的AJXP_XMLWriter::triggerBgAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。