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


PHP AJXP_Utils::getAjxpTmpDir方法代码示例

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


在下文中一共展示了AJXP_Utils::getAjxpTmpDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getRealFSReference

 public static function getRealFSReference($path)
 {
     $fake = new ftpAccessWrapper();
     $tmpFile = AJXP_Utils::getAjxpTmpDir() . "/" . md5(time());
     $tmpHandle = fopen($tmpFile, "wb");
     $fake->copyFileInStream($path, $tmpHandle);
     fclose($tmpHandle);
     //register_shutdown_function("unlink", $tmpFile);
     return $tmpFile;
 }
开发者ID:BackupTheBerlios,项目名称:ascore,代码行数:10,代码来源:class.ftpAccessWrapper.php

示例2: getRealFSReference

 public static function getRealFSReference($path, $persistent = false)
 {
     $tmpFile = AJXP_Utils::getAjxpTmpDir() . "/" . md5(time());
     $tmpHandle = fopen($tmpFile, "wb");
     self::copyFileInStream($path, $tmpHandle);
     fclose($tmpHandle);
     if (!$persistent) {
         register_shutdown_function(array("AJXP_Utils", "silentUnlink"), $tmpFile);
     }
     return $tmpFile;
 }
开发者ID:thermalpaste,项目名称:pydio-core,代码行数:11,代码来源:class.ftpAccessWrapper.php

示例3: getRealFSReference

 /**
  * Implementation of AjxpStream
  *
  * @param String $path
  * @return string
  */
 public static function getRealFSReference($path, $persistent = false)
 {
     if ($persistent) {
         $tmpFile = AJXP_Utils::getAjxpTmpDir() . "/" . md5(time());
         $tmpHandle = fopen($tmpFile, "wb");
         self::copyFileInStream($path, $tmpHandle);
         fclose($tmpHandle);
         return $tmpFile;
     } else {
         return self::initPath($path);
     }
 }
开发者ID:ad-m,项目名称:pydio-core,代码行数:18,代码来源:class.sftpPSLAccessWrapper.php

示例4: extractIndexableContent

 /**
  * @param AJXP_Node $ajxpNode
  * @return null|string
  */
 protected function extractIndexableContent($ajxpNode)
 {
     $ext = strtolower(pathinfo($ajxpNode->getLabel(), PATHINFO_EXTENSION));
     if (in_array($ext, explode(",", $this->getFilteredOption("PARSE_CONTENT_TXT")))) {
         return file_get_contents($ajxpNode->getUrl());
     }
     $unoconv = $this->getFilteredOption("UNOCONV");
     $pipe = false;
     if (!empty($unoconv) && in_array($ext, array("doc", "odt", "xls", "ods"))) {
         $targetExt = "txt";
         if (in_array($ext, array("xls", "ods"))) {
             $targetExt = "csv";
         } else {
             if (in_array($ext, array("odp", "ppt"))) {
                 $targetExt = "pdf";
                 $pipe = true;
             }
         }
         $realFile = call_user_func(array($ajxpNode->wrapperClassName, "getRealFSReference"), $ajxpNode->getUrl());
         $unoconv = "HOME=" . AJXP_Utils::getAjxpTmpDir() . " " . $unoconv . " --stdout -f {$targetExt} " . escapeshellarg($realFile);
         if ($pipe) {
             $newTarget = str_replace(".{$ext}", ".pdf", $realFile);
             $unoconv .= " > {$newTarget}";
             register_shutdown_function("unlink", $newTarget);
         }
         $output = array();
         exec($unoconv, $output, $return);
         if (!$pipe) {
             $out = implode("\n", $output);
             $enc = 'ISO-8859-1';
             $asciiString = iconv($enc, 'ASCII//TRANSLIT//IGNORE', $out);
             return $asciiString;
         } else {
             $ext = "pdf";
         }
     }
     $pdftotext = $this->getFilteredOption("PDFTOTEXT");
     if (!empty($pdftotext) && in_array($ext, array("pdf"))) {
         $realFile = call_user_func(array($ajxpNode->wrapperClassName, "getRealFSReference"), $ajxpNode->getUrl());
         if ($pipe && isset($newTarget) && is_file($newTarget)) {
             $realFile = $newTarget;
         }
         $cmd = $pdftotext . " " . escapeshellarg($realFile) . " -";
         $output = array();
         exec($cmd, $output, $return);
         $out = implode("\n", $output);
         $enc = 'UTF8';
         $asciiString = iconv($enc, 'ASCII//TRANSLIT//IGNORE', $out);
         return $asciiString;
     }
     return null;
 }
开发者ID:floffel03,项目名称:pydio-core,代码行数:56,代码来源:class.AbstractSearchEngineIndexer.php

示例5: stream_open

 public function stream_open($url, $mode, $options, &$context)
 {
     if ($mode == "w" || $mode == "rw") {
         $this->crtMode = 'write';
         $parts = $this->parseUrl($url);
         $this->crtParameters = array("get_action" => "put_content", "encode" => "base64", "file" => urldecode(AJXP_Utils::securePath($parts["path"])));
         $tmpFileBuffer = realpath(AJXP_Utils::getAjxpTmpDir()) . md5(time());
         $this->postFileData = $tmpFileBuffer;
         $this->fp = fopen($tmpFileBuffer, "w");
     } else {
         $this->crtMode = 'read';
         $this->fp = tmpfile();
         $this->copyFileInStream($url, $this->fp);
         rewind($this->fp);
     }
     return $this->fp !== false;
 }
开发者ID:BackupTheBerlios,项目名称:ascore,代码行数:17,代码来源:class.remote_fsAccessWrapper.php

示例6: setBruteForceLoginArray

 /**
  * Store the array
  * @static
  * @param $loginArray
  * @return void
  */
 static function setBruteForceLoginArray($loginArray)
 {
     $failedLog = AJXP_Utils::getAjxpTmpDir() . "/failedAJXP.log";
     @file_put_contents($failedLog, serialize($loginArray));
 }
开发者ID:crodriguezn,项目名称:administrator-files,代码行数:11,代码来源:class.AuthService.php

示例7: switchAction


//.........这里部分代码省略.........
             }
             foreach ($allUsers as $userId => $userObject) {
                 if ($userObject->getId() == $loggedUser->getId()) {
                     continue;
                 }
                 if (!$userObject->hasParent() && ConfService::getCoreConf("ALLOW_CROSSUSERS_SHARING", "conf") || $userObject->getParent() == $loggedUser->getId()) {
                     $userLabel = $userObject->personalRole->filterParameterValue("core.conf", "USER_DISPLAY_NAME", AJXP_REPO_SCOPE_ALL, $userId);
                     //if($regexp != null && ! (preg_match("/$regexp/i", $userId) || preg_match("/$regexp/i", $userLabel)) ) continue;
                     if (empty($userLabel)) {
                         $userLabel = $userId;
                     }
                     $userDisplay = $userLabel == $userId ? $userId : $userLabel . " ({$userId})";
                     if (ConfService::getCoreConf("USERS_LIST_HIDE_LOGIN", "conf") == true && $userLabel != $userId) {
                         $userDisplay = $userLabel;
                     }
                     $users .= "<li class='complete_user_entry' data-label='{$userLabel}' data-entry_id='{$userId}'><span class='user_entry_label'>" . $userDisplay . "</span></li>";
                     $index++;
                 }
                 if ($index == $limit) {
                     break;
                 }
             }
             if (strlen($users)) {
                 print "<ul>" . $users . "</ul>";
             }
             AuthService::setGroupFiltering(true);
             break;
         case "load_repository_info":
             $data = array();
             $repo = ConfService::getRepository();
             if ($repo != null) {
                 $users = AuthService::countUsersForRepository(ConfService::getRepository()->getId(), true);
                 $data["core.users"] = $users;
                 if (isset($httpVars["collect"]) && $httpVars["collect"] == "true") {
                     AJXP_Controller::applyHook("repository.load_info", array(&$data));
                 }
             }
             HTMLWriter::charsetHeader("application/json");
             echo json_encode($data);
             break;
         case "get_binary_param":
             if (isset($httpVars["tmp_file"])) {
                 $file = AJXP_Utils::getAjxpTmpDir() . "/" . AJXP_Utils::securePath($httpVars["tmp_file"]);
                 if (isset($file)) {
                     header("Content-Type:image/png");
                     readfile($file);
                 }
             } else {
                 if (isset($httpVars["binary_id"])) {
                     if (isset($httpVars["user_id"]) && AuthService::getLoggedUser() != null && AuthService::getLoggedUser()->isAdmin()) {
                         $context = array("USER" => $httpVars["user_id"]);
                     } else {
                         $context = array("USER" => AuthService::getLoggedUser()->getId());
                     }
                     $this->loadBinary($context, $httpVars["binary_id"]);
                 }
             }
             break;
         case "get_global_binary_param":
             if (isset($httpVars["tmp_file"])) {
                 $file = AJXP_Utils::getAjxpTmpDir() . "/" . AJXP_Utils::securePath($httpVars["tmp_file"]);
                 if (isset($file)) {
                     header("Content-Type:image/png");
                     readfile($file);
                 }
             } else {
                 if (isset($httpVars["binary_id"])) {
                     $this->loadBinary(array(), $httpVars["binary_id"]);
                 }
             }
             break;
         case "store_binary_temp":
             if (count($fileVars)) {
                 $keys = array_keys($fileVars);
                 $boxData = $fileVars[$keys[0]];
                 $err = AJXP_Utils::parseFileDataErrors($boxData);
                 if ($err != null) {
                 } else {
                     $rand = substr(md5(time()), 0, 6);
                     $tmp = $rand . "-" . $boxData["name"];
                     @move_uploaded_file($boxData["tmp_name"], AJXP_Utils::getAjxpTmpDir() . "/" . $tmp);
                 }
             }
             if (isset($tmp) && file_exists(AJXP_Utils::getAjxpTmpDir() . "/" . $tmp)) {
                 print '<script type="text/javascript">';
                 print 'parent.formManagerHiddenIFrameSubmission("' . $tmp . '");';
                 print '</script>';
             }
             break;
         default:
             break;
     }
     if (isset($logMessage) || isset($errorMessage)) {
         $xmlBuffer .= AJXP_XMLWriter::sendMessage(isset($logMessage) ? $logMessage : null, isset($errorMessage) ? $errorMessage : null, false);
     }
     if (isset($requireAuth)) {
         $xmlBuffer .= AJXP_XMLWriter::requireAuth(false);
     }
     return $xmlBuffer;
 }
开发者ID:rcmarotz,项目名称:pydio-core,代码行数:101,代码来源:class.AbstractConfDriver.php

示例8: print_thumbnail


//.........这里部分代码省略.........
         }
     }
     //Cache it
     if ($this->is_cacheable()) {
         switch ($format) {
             case 1:
                 $cached = @imagegif($thumbnail, $cache_file);
                 break;
             case 2:
                 $cached = @imageJPEG($thumbnail, $cache_file, 100);
                 break;
             case 3:
                 $cached = @imagepng($thumbnail, $cache_file);
                 break;
             case 15:
                 $cached = @imagewbmp($thumbnail, $cache_file);
                 break;
             case 16:
                 $cached = @imagexbm($thumbnail, $cache_file);
                 break;
             default:
                 $cached = false;
         }
         if (!$cached) {
             return $this->set_error("Method print_thumbnail 1: Error in cache generation of image '{$image}'.");
         }
     }
     if ($target_file != false) {
         $wrappers = stream_get_wrappers();
         $wrappers_re = '(' . implode('|', $wrappers) . ')';
         $isStream = preg_match("!^{$wrappers_re}://!", $target_file) === 1;
         if ($isStream) {
             $backToStreamTarget = $target_file;
             $target_file = tempnam(AJXP_Utils::getAjxpTmpDir(), "pthumb_");
         }
         switch ($format) {
             case 1:
                 $cached = @imagegif($thumbnail, $target_file);
                 break;
             case 2:
                 $cached = @imageJPEG($thumbnail, $target_file, 100);
                 break;
             case 3:
                 $cached = @imagepng($thumbnail, $target_file);
                 break;
             case 15:
                 $cached = @imagewbmp($thumbnail, $target_file);
                 break;
             case 16:
                 $cached = @imagexbm($thumbnail, $target_file);
                 break;
             default:
                 $cached = false;
         }
         if ($cached && $isStream) {
             $cached = @copy($target_file, $backToStreamTarget);
             @unlink($target_file);
         }
         if (!$cached) {
             return $this->set_error("Method print_thumbnail: Error in cache generation of image '{$image}'.");
         }
         return true;
     }
     if ($return_img == false) {
         header("Expires: " . gmdate("D, d M Y H:i:s") . " GMT");
         header("Cache-Control: no-store, no-cache, must-revalidate");
开发者ID:rbrdevs,项目名称:pydio-core,代码行数:67,代码来源:PThumb.lib.php

示例9: define

//     you must ensure that you have included PclError library.
// [2,...] : reserved for futur use
if (!defined('PCLZIP_ERROR_EXTERNAL')) {
    define('PCLZIP_ERROR_EXTERNAL', 0);
}
// ----- Optional static temporary directory
//       By default temporary files are generated in the script current
//       path.
//       If defined :
//       - MUST BE terminated by a '/'.
//       - MUST be a valid, already created directory
//       Samples :
// define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
// define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
if (!defined('PCLZIP_TEMPORARY_DIR')) {
    define('PCLZIP_TEMPORARY_DIR', AJXP_Utils::getAjxpTmpDir() . DIRECTORY_SEPARATOR);
}
// ----- Optional threshold ratio for use of temporary files
//       Pclzip sense the size of the file to add/extract and decide to
//       use or not temporary file. The algorythm is looking for
//       memory_limit of PHP and apply a ratio.
//       threshold = memory_limit * ratio.
//       Recommended values are under 0.5. Default 0.47.
//       Samples :
// define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 );
if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
    define('PCLZIP_TEMPORARY_FILE_RATIO', 0.47);
}
// --------------------------------------------------------------------------------
// ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED *****
// --------------------------------------------------------------------------------
开发者ID:victoravalos,项目名称:SGC,代码行数:31,代码来源:pclzip.lib.php

示例10: initPath

 /**
  * Initialize the stream from the given path. 
  *
  * @param string $path
  * @return mixed Real path or -1 if currentListing contains the listing : original path converted to real path
  */
 protected static function initPath($path, $streamType, $storeOpenContext = false, $skipZip = false)
 {
     $path = self::unPatchPathForBaseDir($path);
     $url = parse_url($path);
     $repoId = $url["host"];
     if (isset($url["fragment"]) && strlen($url["fragment"]) > 0) {
         $url["path"] .= "#" . $url["fragment"];
     }
     $repoObject = ConfService::getRepositoryById($repoId);
     if (!isset($repoObject)) {
         throw new Exception("Cannot find repository with id " . $repoId);
     }
     $split = UserSelection::detectZip($url["path"]);
     $insideZip = false;
     if ($split && $streamType == "file" && $split[1] != "/") {
         $insideZip = true;
     }
     if ($split && $streamType == "dir") {
         $insideZip = true;
     }
     if ($skipZip) {
         $insideZip = false;
     }
     //var_dump($path);
     //var_dump($skipZip);
     // Inside a zip : copy the file to a tmp file and return a reference to it
     if ($insideZip) {
         $zipPath = $split[0];
         $localPath = $split[1];
         require_once AJXP_BIN_FOLDER . "/pclzip.lib.php";
         //print($streamType.$path);
         if ($streamType == "file") {
             if (self::$crtZip == null || !is_array(self::$currentListingKeys)) {
                 $tmpDir = AJXP_Utils::getAjxpTmpDir() . DIRECTORY_SEPARATOR . md5(time() - rand());
                 mkdir($tmpDir);
                 $tmpFileName = $tmpDir . DIRECTORY_SEPARATOR . basename($localPath);
                 AJXP_Logger::debug("Tmp file {$tmpFileName}");
                 register_shutdown_function(array("fsAccessWrapper", "removeTmpFile"), $tmpDir, $tmpFileName);
                 $crtZip = new PclZip(AJXP_Utils::securePath(realpath($repoObject->getOption("PATH")) . $zipPath));
                 $content = $crtZip->listContent();
                 foreach ($content as $item) {
                     $fName = AJXP_Utils::securePath($item["stored_filename"]);
                     if ($fName == $localPath || "/" . $fName == $localPath) {
                         $localPath = $fName;
                         break;
                     }
                 }
                 $res = $crtZip->extract(PCLZIP_OPT_BY_NAME, $localPath, PCLZIP_OPT_PATH, $tmpDir, PCLZIP_OPT_REMOVE_ALL_PATH);
                 AJXP_Logger::debug("Extracted " . $path . " to " . dirname($localPath));
                 if ($storeOpenContext) {
                     self::$crtZip = $crtZip;
                 }
                 return $tmpFileName;
             } else {
                 $key = basename($localPath);
                 if (array_key_exists($key, self::$currentListing)) {
                     self::$currentFileKey = $key;
                     return -1;
                 } else {
                     throw new AJXP_Exception("Cannot find key");
                 }
             }
         } else {
             $crtZip = new PclZip(AJXP_Utils::securePath(realpath($repoObject->getOption("PATH")) . $zipPath));
             $liste = $crtZip->listContent();
             if ($storeOpenContext) {
                 self::$crtZip = $crtZip;
             }
             $folders = array();
             $files = array();
             $builtFolders = array();
             if ($localPath[strlen($localPath) - 1] != "/") {
                 $localPath .= "/";
             }
             foreach ($liste as $item) {
                 $stored = $item["stored_filename"];
                 if ($stored[0] != "/") {
                     $stored = "/" . $stored;
                 }
                 $pathPos = strpos($stored, $localPath);
                 if ($pathPos !== false) {
                     $afterPath = substr($stored, $pathPos + strlen($localPath));
                     if ($afterPath != "" && substr_count($afterPath, "/") < 2) {
                         $statValue = array();
                         if (substr_count($afterPath, "/") == 0) {
                             $statValue[2] = $statValue["mode"] = $item["folder"] ? "00040000" : "0100000";
                             $statValue[7] = $statValue["size"] = $item["size"];
                             $statValue[8] = $statValue["atime"] = $item["mtime"];
                             $statValue[9] = $statValue["mtime"] = $item["mtime"];
                             $statValue[10] = $statValue["ctime"] = $item["mtime"];
                             if (strpos($afterPath, "/") == strlen($afterPath) - 1) {
                                 $afterPath = substr($afterPath, 0, strlen($afterPath) - 1);
                             }
                             //$statValue["filename"] = $zipPath.$localPath.$afterPath;
//.........这里部分代码省略.........
开发者ID:crodriguezn,项目名称:administrator-files,代码行数:101,代码来源:class.fsAccessWrapper.php

示例11: parseStandardFormParameters

 public static function parseStandardFormParameters(&$repDef, &$options, $userId = null, $prefix = "DRIVER_OPTION_", $binariesContext = null, $cypheredPassPrefix = "")
 {
     if ($binariesContext === null) {
         $binariesContext = array("USER" => AuthService::getLoggedUser() != null ? AuthService::getLoggedUser()->getId() : "shared");
     }
     $replicationGroups = array();
     $switchesGroups = array();
     foreach ($repDef as $key => $value) {
         if ((!empty($prefix) && strpos($key, $prefix) !== false && strpos($key, $prefix) == 0 || empty($prefix)) && strpos($key, "ajxptype") === false && strpos($key, "_original_binary") === false && strpos($key, "_replication") === false && strpos($key, "_checkbox") === false) {
             if (isset($repDef[$key . "_ajxptype"])) {
                 $type = $repDef[$key . "_ajxptype"];
                 if ($type == "boolean") {
                     $value = $value == "true" ? true : false;
                 } else {
                     if ($type == "integer") {
                         $value = intval($value);
                     } else {
                         if ($type == "array") {
                             $value = explode(",", $value);
                         } else {
                             if ($type == "password" && $userId != null) {
                                 if (trim($value) != "" && $value != "__AJXP_VALUE_SET__" && function_exists('mcrypt_encrypt')) {
                                     // We encode as base64 so if we need to store the result in a database, it can be stored in text column
                                     $value = $cypheredPassPrefix . base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($userId . "CDAFx¨op#"), $value, MCRYPT_MODE_ECB));
                                 }
                             } else {
                                 if ($type == "binary" && $binariesContext !== null) {
                                     if (!empty($value)) {
                                         if ($value == "ajxp-remove-original") {
                                             if (!empty($repDef[$key . "_original_binary"])) {
                                                 ConfService::getConfStorageImpl()->deleteBinary($binariesContext, $repDef[$key . "_original_binary"]);
                                             }
                                             $value = "";
                                         } else {
                                             $file = AJXP_Utils::getAjxpTmpDir() . "/" . $value;
                                             if (file_exists($file)) {
                                                 $id = !empty($repDef[$key . "_original_binary"]) ? $repDef[$key . "_original_binary"] : null;
                                                 $id = ConfService::getConfStorageImpl()->saveBinary($binariesContext, $file, $id);
                                                 $value = $id;
                                             }
                                         }
                                     } else {
                                         if (!empty($repDef[$key . "_original_binary"])) {
                                             $value = $repDef[$key . "_original_binary"];
                                         }
                                     }
                                 } else {
                                     if (strpos($type, "group_switch:") === 0) {
                                         $tmp = explode(":", $type);
                                         $gSwitchName = $tmp[1];
                                         $switchesGroups[substr($key, strlen($prefix))] = $gSwitchName;
                                     } else {
                                         if ($type == "text/json") {
                                             $value = json_decode($value, true);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if (!in_array($type, array("textarea", "boolean", "text/json"))) {
                     $value = AJXP_Utils::sanitize($value, AJXP_SANITIZE_HTML);
                 }
                 unset($repDef[$key . "_ajxptype"]);
             }
             if (isset($repDef[$key . "_checkbox"])) {
                 $checked = $repDef[$key . "_checkbox"] == "checked";
                 unset($repDef[$key . "_checkbox"]);
                 if (!$checked) {
                     continue;
                 }
             }
             if (isset($repDef[$key . "_replication"])) {
                 $repKey = $repDef[$key . "_replication"];
                 if (!is_array($replicationGroups[$repKey])) {
                     $replicationGroups[$repKey] = array();
                 }
                 $replicationGroups[$repKey][] = $key;
             }
             $options[substr($key, strlen($prefix))] = $value;
             unset($repDef[$key]);
         } else {
             $repDef[$key] = $value;
         }
     }
     // DO SOMETHING WITH REPLICATED PARAMETERS?
     if (count($switchesGroups)) {
         $gValues = array();
         foreach ($switchesGroups as $fieldName => $groupName) {
             if (isset($options[$fieldName])) {
                 $gValues = array();
                 $radic = $groupName . "_" . $options[$fieldName] . "_";
                 foreach ($options as $optN => $optV) {
                     if (strpos($optN, $radic) === 0) {
                         $newName = substr($optN, strlen($radic));
                         $gValues[$newName] = $optV;
                     }
                 }
             }
//.........这里部分代码省略.........
开发者ID:rbrdevs,项目名称:pydio-core,代码行数:101,代码来源:class.AJXP_Utils.php

示例12: 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

示例13: switchAction

 public function switchAction($action, $httpVars, $fileVars)
 {
     if (!isset($this->actions[$action])) {
         return;
     }
     parent::accessPreprocess($action, $httpVars, $fileVars);
     $selection = new UserSelection();
     $dir = $httpVars["dir"] or "";
     if ($this->wrapperClassName == "fsAccessWrapper") {
         $dir = fsAccessWrapper::patchPathForBaseDir($dir);
     }
     $dir = AJXP_Utils::securePath($dir);
     if ($action != "upload") {
         $dir = AJXP_Utils::decodeSecureMagic($dir);
     }
     $selection->initFromHttpVars($httpVars);
     if (!$selection->isEmpty()) {
         $this->filterUserSelectionToHidden($selection->getFiles());
     }
     $mess = ConfService::getMessages();
     $newArgs = RecycleBinManager::filterActions($action, $selection, $dir, $httpVars);
     if (isset($newArgs["action"])) {
         $action = $newArgs["action"];
     }
     if (isset($newArgs["dest"])) {
         $httpVars["dest"] = SystemTextEncoding::toUTF8($newArgs["dest"]);
     }
     //Re-encode!
     // FILTER DIR PAGINATION ANCHOR
     $page = null;
     if (isset($dir) && strstr($dir, "%23") !== false) {
         $parts = explode("%23", $dir);
         $dir = $parts[0];
         $page = $parts[1];
     }
     $pendingSelection = "";
     $logMessage = null;
     $reloadContextNode = false;
     switch ($action) {
         //------------------------------------
         //	DOWNLOAD
         //------------------------------------
         case "download":
             $this->logInfo("Download", array("files" => $this->addSlugToPath($selection)));
             @set_error_handler(array("HTMLWriter", "javascriptErrorHandler"), E_ALL & ~E_NOTICE);
             @register_shutdown_function("restore_error_handler");
             $zip = false;
             if ($selection->isUnique()) {
                 if (is_dir($this->urlBase . $selection->getUniqueFile())) {
                     $zip = true;
                     $base = basename($selection->getUniqueFile());
                     $uniqDir = dirname($selection->getUniqueFile());
                     if (!empty($uniqDir) && $uniqDir != "/") {
                         $dir = dirname($selection->getUniqueFile());
                     }
                 } else {
                     if (!file_exists($this->urlBase . $selection->getUniqueFile())) {
                         throw new Exception("Cannot find file!");
                     }
                 }
                 $node = $selection->getUniqueNode($this);
             } else {
                 $zip = true;
             }
             if ($zip) {
                 // Make a temp zip and send it as download
                 $loggedUser = AuthService::getLoggedUser();
                 $file = AJXP_Utils::getAjxpTmpDir() . "/" . ($loggedUser ? $loggedUser->getId() : "shared") . "_" . time() . "tmpDownload.zip";
                 $zipFile = $this->makeZip($selection->getFiles(), $file, empty($dir) ? "/" : $dir);
                 if (!$zipFile) {
                     throw new AJXP_Exception("Error while compressing");
                 }
                 if (!$this->getFilteredOption("USE_XSENDFILE", $this->repository->getId()) && !$this->getFilteredOption("USE_XACCELREDIRECT", $this->repository->getId())) {
                     register_shutdown_function("unlink", $file);
                 }
                 $localName = ($base == "" ? "Files" : $base) . ".zip";
                 if (isset($httpVars["archive_name"])) {
                     $localName = AJXP_Utils::decodeSecureMagic($httpVars["archive_name"]);
                 }
                 $this->readFile($file, "force-download", $localName, false, false, true);
             } else {
                 $localName = "";
                 AJXP_Controller::applyHook("dl.localname", array($this->urlBase . $selection->getUniqueFile(), &$localName, $this->wrapperClassName));
                 $this->readFile($this->urlBase . $selection->getUniqueFile(), "force-download", $localName);
             }
             if (isset($node)) {
                 AJXP_Controller::applyHook("node.read", array(&$node));
             }
             break;
         case "prepare_chunk_dl":
             $chunkCount = intval($httpVars["chunk_count"]);
             $fileId = $this->urlBase . $selection->getUniqueFile();
             $sessionKey = "chunk_file_" . md5($fileId . time());
             $totalSize = $this->filesystemFileSize($fileId);
             $chunkSize = intval($totalSize / $chunkCount);
             $realFile = call_user_func(array($this->wrapperClassName, "getRealFSReference"), $fileId, true);
             $chunkData = array("localname" => basename($fileId), "chunk_count" => $chunkCount, "chunk_size" => $chunkSize, "total_size" => $totalSize, "file_id" => $sessionKey);
             $_SESSION[$sessionKey] = array_merge($chunkData, array("file" => $realFile));
             HTMLWriter::charsetHeader("application/json");
             print json_encode($chunkData);
//.........这里部分代码省略.........
开发者ID:biggtfish,项目名称:cms,代码行数:101,代码来源:class.fsAccessDriver.php

示例14: getRealFSReference

 /**
  * Get a "usable" reference to a file : the real file or a tmp copy.
  *
  * @param string $path
  * @param bool $persistent
  * @return string
  */
 public static function getRealFSReference($path, $persistent = false)
 {
     $url = self::translateURL($path);
     if (self::$linkNode !== null) {
         $isRemote = AJXP_MetaStreamWrapper::wrapperIsRemote($url);
         $realFilePointer = AJXP_MetaStreamWrapper::getRealFSReference($url, true);
         if (!$isRemote) {
             $ext = pathinfo(parse_url($url, PHP_URL_PATH), PATHINFO_EXTENSION);
             $tmpname = tempnam(AJXP_Utils::getAjxpTmpDir(), "real-file-inbox-pointer") . "." . $ext;
             copy($realFilePointer, $tmpname);
             $realFilePointer = $tmpname;
         }
         ConfService::loadDriverForRepository(self::$linkNode->getRepository());
         return $realFilePointer;
     } else {
         $tmpname = tempnam(AJXP_Utils::getAjxpTmpDir(), "real-file-inbox-pointer");
         $source = fopen($url, "r");
         $dest = fopen($tmpname, "w");
         stream_copy_to_stream($source, $dest);
         return $tmpname;
     }
 }
开发者ID:Nanomani,项目名称:pydio-core,代码行数:29,代码来源:class.inboxAccessWrapper.php

示例15: 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


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