public function initRepository()
 {
     if (is_array($this->pluginConf)) {
         $this->driverConf = $this->pluginConf;
     } else {
         $this->driverConf = array();
     }
     $smbclientPath = $this->driverConf["SMBCLIENT"];
     define('SMB4PHP_SMBCLIENT', $smbclientPath);
     $smbtmpPath = $this->driverConf["SMB_PATH_TMP"];
     define('SMB4PHP_SMBTMP', $smbtmpPath);
     require_once $this->getBaseDir() . "/smb.php";
     $create = $this->repository->getOption("CREATE");
     $recycle = $this->repository->getOption("RECYCLE_BIN");
     $this->detectStreamWrapper(true);
     $this->urlBase = "pydio://" . $this->repository->getId();
     if ($recycle != "" && !is_dir($this->urlBase . "/" . $recycle)) {
         @mkdir($this->urlBase . "/" . $recycle);
         if (!is_dir($this->urlBase . "/" . $recycle)) {
             throw new AJXP_Exception("Cannot create recycle bin folder. Please check repository configuration or that your folder is writeable!");
         }
     }
     if ($recycle != "") {
         RecycleBinManager::init($this->urlBase, "/" . $recycle);
     }
 }
 public function initRepository()
 {
     if (is_array($this->pluginConf)) {
         $this->driverConf = $this->pluginConf;
     } else {
         $this->driverConf = array();
     }
     if (!function_exists('ssh2_connect')) {
         throw new Exception("You must have the php ssh2 extension active!");
     }
     ConfService::setConf("PROBE_REAL_SIZE", false);
     $path = $this->repository->getOption("PATH");
     $recycle = $this->repository->getOption("RECYCLE_BIN");
     $this->detectStreamWrapper(true);
     $this->urlBase = "pydio://" . $this->repository->getId();
     restore_error_handler();
     if (!file_exists($this->urlBase)) {
         if ($this->repository->getOption("CREATE")) {
             $test = @mkdir($this->urlBase);
             if (!$test) {
                 throw new AJXP_Exception("Cannot create path ({$path}) for your repository! Please check the configuration.");
             }
         } else {
             throw new AJXP_Exception("Cannot find base path ({$path}) for your repository! Please check the configuration!");
         }
     }
     if ($recycle != "") {
         RecycleBinManager::init($this->urlBase, "/" . $recycle);
     }
 }
 public function initRepository()
 {
     $wrapperData = $this->detectStreamWrapper(true);
     if (is_array($this->pluginConf)) {
         $this->driverConf = $this->pluginConf;
     } else {
         $this->driverConf = array();
     }
     $recycle = $this->repository->getOption("RECYCLE_BIN");
     ConfService::setConf("PROBE_REAL_SIZE", false);
     $this->wrapperClassName = $wrapperData["classname"];
     $this->urlBase = $wrapperData["protocol"] . "://" . $this->repository->getId();
     if ($recycle != "") {
         RecycleBinManager::init($this->urlBase, "/" . $recycle);
     }
 }
 function initRepository()
 {
     if (is_array($this->pluginConf)) {
         $this->driverConf = $this->pluginConf;
     } else {
         $this->driverConf = array();
     }
     $create = $this->repository->getOption("CREATE");
     $wrapperData = $this->detectStreamWrapper(true);
     $this->wrapperClassName = $wrapperData["classname"];
     $this->urlBase = $wrapperData["protocol"] . "://" . $this->repository->getId();
     $recycle = $this->repository->getOption("RECYCLE_BIN");
     if ($recycle != "") {
         RecycleBinManager::init($this->urlBase, "/" . $recycle);
     }
 }
 function initRepository()
 {
     @(include_once "HTTP/WebDAV/Client.php");
     if (is_array($this->pluginConf)) {
         $this->driverConf = $this->pluginConf;
     } else {
         $this->driverConf = array();
     }
     if (!class_exists('HTTP_WebDAV_Client_Stream')) {
         throw new Exception("You must have Pear HTTP/WebDAV/Client package installed to use this access driver!");
     }
     $create = $this->repository->getOption("CREATE");
     $path = $this->repository->getOption("PATH");
     $recycle = $this->repository->getOption("RECYCLE_BIN");
     ConfService::setConf("PROBE_REAL_SIZE", false);
     /*
     if($create == true){
     	if(!is_dir($path)) @mkdir($path);
     	if(!is_dir($path)){
     		throw new AJXP_Exception("Cannot create root path for repository (".$this->repository->getDisplay()."). Please check repository configuration or that your folder is writeable!");
     	}
     	if($recycle!= "" && !is_dir($path."/".$recycle)){
     		@mkdir($path."/".$recycle);
     		if(!is_dir($path."/".$recycle)){
     			throw new AJXP_Exception("Cannot create recycle bin folder. Please check repository configuration or that your folder is writeable!");
     		}
     	}
     }else{
     	if(!is_dir($path)){
     		throw new AJXP_Exception("Cannot find base path ($path) for your repository! Please check the configuration!");
     	}
     }
     */
     $wrapperData = $this->detectStreamWrapper(true);
     $this->wrapperClassName = $wrapperData["classname"];
     $this->urlBase = $wrapperData["protocol"] . "://" . $this->repository->getId();
     if (!is_dir($this->urlBase)) {
         if (webdavAccessWrapper::$lastException) {
             throw webdavAccessWrapper::$lastException;
         }
         throw new AJXP_Exception("Cannot find base path ({$path}) for your repository! Please check the configuration!");
     }
     if ($recycle != "") {
         RecycleBinManager::init($this->urlBase, "/" . $recycle);
     }
 }
 public function initRepository()
 {
     if (is_array($this->pluginConf)) {
         $this->driverConf = $this->pluginConf;
     } else {
         $this->driverConf = array();
     }
     require_once $this->getBaseDir() . "/openstack-sdk-php/vendor/autoload.php";
     Bootstrap::useStreamWrappers();
     Bootstrap::setConfiguration(array('username' => $this->repository->getOption("USERNAME"), 'password' => $this->repository->getOption("PASSWORD"), 'tenantid' => $this->repository->getOption("TENANT_ID"), 'endpoint' => $this->repository->getOption("ENDPOINT"), 'openstack.swift.region' => $this->repository->getOption("REGION"), 'transport.ssl.verify' => false));
     $path = $this->repository->getOption("PATH");
     $recycle = $this->repository->getOption("RECYCLE_BIN");
     ConfService::setConf("PROBE_REAL_SIZE", false);
     $this->detectStreamWrapper(true);
     $this->urlBase = "pydio://" . $this->repository->getId();
     if ($recycle != "") {
         RecycleBinManager::init($this->urlBase, "/" . $recycle);
     }
 }
Example #7
0
 public function initRepository()
 {
     require_once $this->getBaseDir() . "/aS3StreamWrapper/lib/wrapper/aS3StreamWrapper.class.php";
     if (!in_array("s3", stream_get_wrappers())) {
         $wrapper = new aS3StreamWrapper();
         $wrapper->register(array('protocol' => 's3', 'acl' => AmazonS3::ACL_OWNER_FULL_CONTROL, 'key' => $this->repository->getOption("API_KEY"), 'secretKey' => $this->repository->getOption("SECRET_KEY"), 'region' => $this->repository->getOption("REGION")));
     }
     if (is_array($this->pluginConf)) {
         $this->driverConf = $this->pluginConf;
     } else {
         $this->driverConf = array();
     }
     $path = $this->repository->getOption("PATH");
     $recycle = $this->repository->getOption("RECYCLE_BIN");
     ConfService::setConf("PROBE_REAL_SIZE", false);
     $wrapperData = $this->detectStreamWrapper(true);
     $this->wrapperClassName = $wrapperData["classname"];
     $this->urlBase = $wrapperData["protocol"] . "://" . $this->repository->getId();
     if ($recycle != "") {
         RecycleBinManager::init($this->urlBase, "/" . $recycle);
     }
 }
Example #8
0
 public function preProcessMove($actionName, &$httpVars, &$fileVars)
 {
     $destO = AJXP_Utils::decodeSecureMagic($httpVars["dest"]);
     $dest = substr($destO, 1, strpos(ltrim($destO, "/"), "/"));
     if (empty($dest)) {
         $dest = ltrim($destO, "/");
     }
     $userSelection = new UserSelection();
     $userSelection->initFromHttpVars($httpVars);
     if (!$userSelection->isEmpty()) {
         $testFileO = $userSelection->getUniqueFile();
         $testFile = substr($testFileO, 1, strpos(ltrim($testFileO, "/"), "/"));
         if (empty($testFile)) {
             $testFile = ltrim($testFileO, "/");
         }
         if ($actionName == "move") {
             if (strstr($dest, "ENCFS_CLEAR_") != false && strstr($testFile, "ENCFS_CLEAR_") === false || strstr($dest, "ENCFS_CLEAR_") === false && strstr($testFile, "ENCFS_CLEAR_") !== false || strstr($dest, "ENCFS_CLEAR_") != false && strstr($testFile, "ENCFS_CLEAR_") !== false && $testFile != $dest) {
                 $httpVars["force_copy_delete"] = "true";
                 $this->logDebug("One mount to another, copy/delete instead of move ({$dest}, {$testFile})");
             }
         } else {
             if ($actionName == "delete" && RecycleBinManager::recycleEnabled()) {
                 if (strstr($testFile, "ENCFS_CLEAR_") !== false) {
                     $httpVars["force_copy_delete"] = "true";
                     $this->logDebug("One mount to another, copy/delete instead of move");
                 }
             } else {
                 if ($actionName == "restore") {
                     if (strstr(RecycleBinManager::getFileOrigin($testFile), "ENCFS_CLEAR_")) {
                         $httpVars["force_copy_delete"] = "true";
                         $this->logDebug("One mount to another, copy/delete instead of move");
                     }
                 }
             }
         }
     }
 }
 function deldir($location)
 {
     if (is_dir($location)) {
         $all = opendir($location);
         while ($file = readdir($all)) {
             if (is_dir("{$location}/{$file}") && $file != ".." && $file != ".") {
                 $this->deldir("{$location}/{$file}");
                 if (file_exists("{$location}/{$file}")) {
                     rmdir("{$location}/{$file}");
                 }
                 unset($file);
             } elseif (!is_dir("{$location}/{$file}")) {
                 if (file_exists("{$location}/{$file}")) {
                     unlink("{$location}/{$file}");
                 }
                 unset($file);
             }
         }
         closedir($all);
         rmdir($location);
     } else {
         if (file_exists("{$location}")) {
             $test = @unlink("{$location}");
             if (!$test) {
                 throw new Exception("Cannot delete file " . $location);
             }
         }
     }
     if (basename(dirname($location)) == $this->repository->getOption("RECYCLE_BIN")) {
         // DELETING FROM RECYCLE
         RecycleBinManager::deleteFromRecycle($location);
     }
 }
 /**
  * We have to override the standard copyOrMoveFile, as feof() does
  * not seem to work with ssh2.ftp stream... 
  * Maybe something to search hear http://www.mail-archive.com/php-general@lists.php.net/msg169992.html?
  *
  * @param string $destDir
  * @param string $srcFile
  * @param array $error
  * @param array $success
  * @param boolean $move
  */
 function copyOrMoveFile($destDir, $srcFile, &$error, &$success, $move = false)
 {
     $mess = ConfService::getMessages();
     $destFile = $this->urlBase . $destDir . "/" . basename($srcFile);
     $realSrcFile = $this->urlBase . $srcFile;
     if (!file_exists($realSrcFile)) {
         $error[] = $mess[100] . $srcFile;
         return;
     }
     if (dirname($realSrcFile) == dirname($destFile)) {
         if ($move) {
             $error[] = $mess[101];
             return;
         } else {
             $base = basename($srcFile);
             $i = 1;
             if (is_file($realSrcFile)) {
                 $dotPos = strrpos($base, ".");
                 if ($dotPos > -1) {
                     $radic = substr($base, 0, $dotPos);
                     $ext = substr($base, $dotPos);
                 }
             }
             // auto rename file
             $i = 1;
             $newName = $base;
             while (file_exists($this->urlBase . $destDir . "/" . $newName)) {
                 $suffix = "-{$i}";
                 if (isset($radic)) {
                     $newName = $radic . $suffix . $ext;
                 } else {
                     $newName = $base . $suffix;
                 }
                 $i++;
             }
             $destFile = $this->urlBase . $destDir . "/" . $newName;
         }
     }
     if (!is_file($realSrcFile)) {
         $errors = array();
         $succFiles = array();
         if ($move) {
             if (file_exists($destFile)) {
                 $this->deldir($destFile);
             }
             $res = rename($realSrcFile, $destFile);
         } else {
             $dirRes = $this->dircopy($realSrcFile, $destFile, $errors, $succFiles);
         }
         if (count($errors) || isset($res) && $res !== true) {
             $error[] = $mess[114];
             return;
         }
     } else {
         if ($move) {
             if (file_exists($destFile)) {
                 unlink($destFile);
             }
             $res = rename($realSrcFile, $destFile);
             AJXP_Controller::applyHook("move.metadata", array($realSrcFile, $destFile, false));
         } else {
             try {
                 // BEGIN OVERRIDING
                 list($connection, $remote_base_path) = sftpAccessWrapper::getSshConnection($realSrcFile);
                 $remoteSrc = $remote_base_path . $srcFile;
                 $remoteDest = $remote_base_path . $destDir;
                 AJXP_Logger::debug("SSH2 CP", array("cmd" => 'cp ' . $remoteSrc . ' ' . $remoteDest));
                 ssh2_exec($connection, 'cp ' . $remoteSrc . ' ' . $remoteDest);
                 AJXP_Controller::applyHook("move.metadata", array($realSrcFile, $destFile, true));
                 // END OVERRIDING
             } catch (Exception $e) {
                 $error[] = $e->getMessage();
                 return;
             }
         }
     }
     if ($move) {
         // Now delete original
         // $this->deldir($realSrcFile); // both file and dir
         $messagePart = $mess[74] . " " . SystemTextEncoding::toUTF8($destDir);
         if (RecycleBinManager::recycleEnabled() && $destDir == RecycleBinManager::getRelativeRecycle()) {
             RecycleBinManager::fileToRecycle($srcFile);
             $messagePart = $mess[123] . " " . $mess[122];
         }
         if (isset($dirRes)) {
             $success[] = $mess[117] . " " . SystemTextEncoding::toUTF8(basename($srcFile)) . " " . $messagePart . " (" . SystemTextEncoding::toUTF8($dirRes) . " " . $mess[116] . ") ";
         } else {
             $success[] = $mess[34] . " " . SystemTextEncoding::toUTF8(basename($srcFile)) . " " . $messagePart;
         }
     } else {
         if (RecycleBinManager::recycleEnabled() && $destDir == "/" . $this->repository->getOption("RECYCLE_BIN")) {
             RecycleBinManager::fileToRecycle($srcFile);
         }
         if (isset($dirRes)) {
             $success[] = $mess[117] . " " . SystemTextEncoding::toUTF8(basename($srcFile)) . " " . $mess[73] . " " . SystemTextEncoding::toUTF8($destDir) . " (" . SystemTextEncoding::toUTF8($dirRes) . " " . $mess[116] . ")";
         } else {
             $success[] = $mess[34] . " " . SystemTextEncoding::toUTF8(basename($srcFile)) . " " . $mess[73] . " " . SystemTextEncoding::toUTF8($destDir);
         }
     }
 }
Example #11
0
 function switchAction($action, $httpVars, $fileVars)
 {
     if (!isset($this->actions[$action])) {
         return;
     }
     $xmlBuffer = "";
     foreach ($httpVars as $getName => $getValue) {
         ${$getName} = Utils::securePath(SystemTextEncoding::magicDequote($getValue));
     }
     $selection = new UserSelection();
     $selection->initFromHttpVars($httpVars);
     if (isset($dir) && $action != "upload") {
         $safeDir = $dir;
         $dir = SystemTextEncoding::fromUTF8($dir);
     }
     if (isset($dest)) {
         $dest = SystemTextEncoding::fromUTF8($dest);
     }
     $mess = ConfService::getMessages();
     $recycleBinOption = $this->repository->getOption("RECYCLE_BIN");
     // FILTER ACTION FOR DELETE
     if ($recycleBinOption != "" && $action == "delete" && $dir != "/" . $recycleBinOption) {
         $action = "move";
         $dest = "/" . $recycleBinOption;
         $dest_node = "AJAXPLORER_RECYCLE_NODE";
     }
     // FILTER ACTION FOR RESTORE
     if ($recycleBinOption != "" && $action == "restore" && $dir == "/" . $recycleBinOption) {
         $originalRep = RecycleBinManager::getFileOrigin($selection->getUniqueFile());
         if ($originalRep != "") {
             $action = "move";
             $dest = $originalRep;
         }
     }
     switch ($action) {
         //------------------------------------
         //	DOWNLOAD, IMAGE & MP3 PROXYS
         //------------------------------------
         case "download":
             AJXP_Logger::logAction("Download", array("files" => $selection));
             $zip = false;
             if ($selection->isUnique()) {
                 if (is_dir($this->getPath() . "/" . $selection->getUniqueFile())) {
                     $zip = true;
                     $dir .= "/" . basename($selection->getUniqueFile());
                 }
             } else {
                 $zip = true;
             }
             if ($zip) {
                 // Make a temp zip and send it as download
                 $this->downFile($this->makeName($selection->getFiles()), "force-download", "archive.zip");
             } else {
                 $this->downFile($this->makeName($selection->getUniqueFile()), "force-download", $selection->getUniqueFile());
             }
             exit(0);
             break;
         case "image_proxy":
             $this->downFile($this->makeName($file), "image", $file);
             exit(0);
             break;
         case "mp3_proxy":
             $this->downFile($this->makeName($file), "mp3", $file);
             exit(0);
             break;
             //------------------------------------
             //	ONLINE EDIT
             //------------------------------------
         //------------------------------------
         //	ONLINE EDIT
         //------------------------------------
         case "edit":
             if (isset($save) && $save == 1) {
                 AJXP_Logger::logAction("Online Edition", array("file" => SystemTextEncoding::fromUTF8($file)));
                 $code = stripslashes($code);
                 $code = str_replace("&lt;", "<", $code);
                 $this->SSHOperation->setRemoteContent($this->makeName($file), $code);
                 echo $mess[115];
             } else {
                 $this->sendFile($this->SSHOperation->getRemoteContent($this->makeName($file)), "plain", $file);
             }
             exit(0);
             break;
             //------------------------------------
             //	COPY / MOVE
             //------------------------------------
         //------------------------------------
         //	COPY / MOVE
         //------------------------------------
         case "copy":
         case "move":
             if ($selection->isEmpty()) {
                 $errorMessage = $mess[113];
                 break;
             }
             $result = "";
             if ($action == "move") {
                 $result = $this->SSHOperation->moveFile($this->makeName($selection->getFiles()), $this->makeName($dest));
             } else {
                 $result = $this->SSHOperation->copyFile($this->makeName($selection->getFiles()), $this->makeName($dest));
             }
             $mess = ConfService::getMessages();
             if (strlen($result)) {
                 $errorMessage = $mess[114];
             } else {
                 foreach ($selection->getFiles() as $files) {
                     $logMessage .= $mess[34] . " " . SystemTextEncoding::toUTF8(basename($file)) . " " . $mess[$action == "move" ? 74 : 73] . " " . SystemTextEncoding::toUTF8($dest) . "\n";
                 }
                 AJXP_Logger::logAction($action == "move" ? "Move" : "Copy", array("files" => $selection, "destination" => $dest));
             }
             $reload_current_node = true;
             if (isset($dest_node)) {
                 $reload_dest_node = $dest_node;
             }
             $reload_file_list = true;
             break;
             //------------------------------------
             //  CHANGE FILE PERMISSION
             //------------------------------------
         //------------------------------------
         //  CHANGE FILE PERMISSION
         //------------------------------------
         case "chmod":
             $messtmp = "";
             $changedFiles = array();
             $value = "0" . decoct(octdec(ltrim($chmod_value, "0")));
             // On error, the command will fail
             $result = $this->SSHOperation->chmodFile($this->makeName($selection->getFiles()), $chmod_value);
             $mess = ConfService::getMessages();
             if (strlen($result)) {
                 $errorMessage = $mess[114];
             } else {
                 $logMessage = "Successfully changed permission to " . $chmod_value . " for " . count($selection->getFiles()) . " files or folders";
                 AJXP_Logger::logAction("Chmod", array("dir" => $dir, "filesCount" => count($selection->getFiles())));
                 $reload_file_list = $dir;
             }
             break;
             //------------------------------------
             //	SUPPRIMER / DELETE
             //------------------------------------
         //------------------------------------
         //	SUPPRIMER / DELETE
         //------------------------------------
         case "delete":
             if ($selection->isEmpty()) {
                 $errorMessage = $mess[113];
                 break;
             }
             $logMessages = array();
             $result = $this->SSHOperation->deleteFile($this->makeName($selection->getFiles()));
             if (strlen($result)) {
                 $mess = ConfService::getMessages();
                 $errorMessage = $mess[120];
             } else {
                 $mess = ConfService::getMessages();
                 foreach ($selection->getFiles() as $file) {
                     $logMessages[] = "{$mess['34']} " . SystemTextEncoding::toUTF8($file) . " {$mess['44']}.";
                 }
                 $logMessage = join("\n", $logMessages);
             }
             AJXP_Logger::logAction("Delete", array("files" => $selection));
             $reload_current_node = true;
             $reload_file_list = true;
             break;
             //------------------------------------
             //	RENOMMER / RENAME
             //------------------------------------
         //------------------------------------
         //	RENOMMER / RENAME
         //------------------------------------
         case "rename":
             $filename_new = $dir . "/" . $filename_new;
             $error = $this->SSHOperation->moveFile($this->makeName($file), $this->makeName($filename_new));
             if ($error != null) {
                 $errorMessage = $error;
                 break;
             }
             $logMessage = SystemTextEncoding::toUTF8($file) . " {$mess['41']} " . SystemTextEncoding::toUTF8($filename_new);
             $reload_current_node = true;
             $reload_file_list = basename($filename_new);
             AJXP_Logger::logAction("Rename", array("original" => $file, "new" => $filename_new));
             break;
             //------------------------------------
             //	CREER UN REPERTOIRE / CREATE DIR
             //------------------------------------
         //------------------------------------
         //	CREER UN REPERTOIRE / CREATE DIR
         //------------------------------------
         case "mkdir":
             $messtmp = "";
             $dirname = Utils::processFileName($dirname);
             $error = $this->SSHOperation->createRemoteDirectory($this->makeName($dir . "/" . $dirname));
             if (isset($error)) {
                 $errorMessage = $error;
                 break;
             }
             $reload_file_list = $dirname;
             $messtmp .= "{$mess['38']} " . SystemTextEncoding::toUTF8($dirname) . " {$mess['39']} ";
             if ($dir == "") {
                 $messtmp .= "/";
             } else {
                 $messtmp .= SystemTextEncoding::toUTF8($dir);
             }
             $logMessage = $messtmp;
             $reload_current_node = true;
             AJXP_Logger::logAction("Create Dir", array("dir" => $dir . "/" . $dirname));
             break;
             //------------------------------------
             //	CREER UN FICHIER / CREATE FILE
             //------------------------------------
         //------------------------------------
         //	CREER UN FICHIER / CREATE FILE
         //------------------------------------
         case "mkfile":
             $messtmp = "";
             $filename = Utils::processFileName($filename);
             $error = $this->SSHOperation->setRemoteContent($this->makeName($dir . "/" . $filename), "");
             if (isset($error)) {
                 $errorMessage = $error;
                 break;
             }
             $messtmp .= "{$mess['34']} " . SystemTextEncoding::toUTF8($filename) . " {$mess['39']} ";
             if ($dir == "") {
                 $messtmp .= "/";
             } else {
                 $messtmp .= SystemTextEncoding::toUTF8($dir);
             }
             $logMessage = $messtmp;
             $reload_file_list = $filename;
             AJXP_Logger::logAction("Create File", array("file" => $dir . "/" . $filename));
             break;
             //------------------------------------
             //	UPLOAD
             //------------------------------------
         //------------------------------------
         //	UPLOAD
         //------------------------------------
         case "upload":
             $fancyLoader = false;
             if (isset($fileVars["Filedata"])) {
                 $fancyLoader = true;
                 if ($dir != "") {
                     $dir = "/" . base64_decode($dir);
                 }
             }
             if ($dir != "") {
                 $rep_source = "/{$dir}";
             } else {
                 $rep_source = "";
             }
             $destination = $rep_source;
             $logMessage = "";
             //$fancyLoader = false;
             foreach ($fileVars 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;
                 }
                 $userfile_name = $boxData["name"];
                 $userfile_name = Utils::processFileName($userfile_name);
                 if (!$this->SSHOperation->uploadFile($boxData["tmp_name"], $this->makeName($destination . "/" . $userfile_name))) {
                     $errorMessage = ($fancyLoader ? "411 " : "") . "{$mess['33']} " . $userfile_name;
                     break;
                 }
                 $logMessage .= "{$mess['34']} " . SystemTextEncoding::toUTF8($userfile_name) . " {$mess['35']} {$dir}";
                 AJXP_Logger::logAction("Upload File", array("file" => $dir . "/" . $userfile_name));
             }
             if ($fancyLoader) {
                 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>";
             }
             exit;
             break;
             //------------------------------------
             // Public URL
             //------------------------------------
         //------------------------------------
         // Public URL
         //------------------------------------
         case "public_url":
             $file = SystemTextEncoding::fromUTF8($file);
             $url = $this->makePubliclet($file, $password, $expiration);
             header("Content-type:text/plain");
             echo $url;
             exit(1);
             break;
             //------------------------------------
             //	XML LISTING
             //------------------------------------
         //------------------------------------
         //	XML LISTING
         //------------------------------------
         case "ls":
             if (!isset($dir) || $dir == "/") {
                 $dir = "";
             }
             $searchMode = $fileListMode = $completeMode = false;
             if (isset($mode)) {
                 if ($mode == "search") {
                     $searchMode = true;
                 } else {
                     if ($mode == "file_list") {
                         $fileListMode = true;
                     } else {
                         if ($mode == "complete") {
                             $completeMode = true;
                         }
                     }
                 }
             }
             $nom_rep = $dir;
             AJXP_Exception::errorToXml($nom_rep);
             $result = $this->SSHOperation->listFilesIn($nom_rep);
             AJXP_XMLWriter::header();
             foreach ($result as $file) {
                 $attributes = "";
                 $fileName = SystemTextEncoding::toUTF8($file["name"]);
                 $icon = Utils::mimetype($fileName, "image", $file["isDir"] == 1);
                 if ($searchMode) {
                     if ($file["isDir"] == 0) {
                         $attributes = "is_file=\"true\" icon=\"" . SystemTextEncoding::toUTF8($icon) . "\"";
                     }
                 } else {
                     if ($fileListMode) {
                         $atts = array();
                         $atts[] = "is_file=\"" . (1 - $file["isDir"]) . "\"";
                         $atts[] = "is_image=\"" . Utils::is_image($fileName) . "\"";
                         $atts[] = "mimestring=\"" . Utils::mimetype($fileName, "type", $file["isDir"] == 1) . "\"";
                         $atts[] = "ajxp_modiftime=\"" . $this->dateModif($file["time"]) . "\"";
                         $atts[] = "filesize=\"" . Utils::roundSize($file["size"]) . "\"";
                         $atts[] = "bytesize=\"" . $file["size"] . "\"";
                         $atts[] = "filename=\"" . str_replace("&", "&amp;", $dir . "/" . $fileName) . "\"";
                         $atts[] = "icon=\"" . ($file["isDir"] == 1 ? "folder.png" : SystemTextEncoding::toUTF8($icon)) . "\"";
                         $attributes = join(" ", $atts);
                     } else {
                         if ($file["isDir"] == 1) {
                             $link = SERVER_ACCESS . "?dir=" . $dir . "/" . $fileName;
                             $link = urlencode($link);
                             $folderBaseName = str_replace("&", "&amp;", $fileName);
                             $folderFullName = "{$dir}/" . $folderBaseName;
                             $parentFolderName = $dir;
                             if (!$completeMode) {
                                 $icon = CLIENT_RESOURCES_FOLDER . "/images/foldericon.png";
                                 $openicon = CLIENT_RESOURCES_FOLDER . "/images/openfoldericon.png";
                                 if (preg_match("/\\.zip\$/", $file["name"])) {
                                     $icon = $openicon = CLIENT_RESOURCES_FOLDER . "/images/crystal/actions/16/accessories-archiver.png";
                                 }
                                 $attributes = "icon=\"{$icon}\"  openicon=\"{$openicon}\" filename=\"" . $folderFullName . "\" src=\"{$link}\"";
                             }
                         }
                     }
                 }
                 if (strlen($attributes) > 0) {
                     print "<tree text=\"" . str_replace("&", "&amp;", SystemTextEncoding::toUTF8($this->SSHOperation->unescapeFileName($file["name"]))) . "\" {$attributes}>";
                     print "</tree>";
                 }
             }
             AJXP_XMLWriter::close();
             exit(1);
             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);
     }
     if (isset($reload_current_node) && $reload_current_node == "true") {
         $xmlBuffer .= AJXP_XMLWriter::reloadCurrentNode(false);
     }
     if (isset($reload_dest_node) && $reload_dest_node != "") {
         $xmlBuffer .= AJXP_XMLWriter::reloadNode($reload_dest_node, false);
     }
     if (isset($reload_file_list)) {
         $xmlBuffer .= AJXP_XMLWriter::reloadFileList($reload_file_list, false);
     }
     return $xmlBuffer;
 }
 public function filterNodeName($nodePath, $nodeName, &$isLeaf, $lsOptions)
 {
     $showHiddenFiles = $this->getFilteredOption("SHOW_HIDDEN_FILES", $this->repository->getId());
     $isLeaf = is_file($nodePath . "/" . $nodeName) || AJXP_Utils::isBrowsableArchive($nodeName);
     if (AJXP_Utils::isHidden($nodeName) && !$showHiddenFiles) {
         return false;
     }
     $nodeType = "d";
     if ($isLeaf) {
         if (AJXP_Utils::isBrowsableArchive($nodeName)) {
             $nodeType = "z";
         } else {
             $nodeType = "f";
         }
     }
     if (!$lsOptions[$nodeType]) {
         return false;
     }
     if ($nodeType == "d") {
         if (RecycleBinManager::recycleEnabled() && $nodePath . "/" . $nodeName == RecycleBinManager::getRecyclePath()) {
             return false;
         }
         return !$this->filterFolder($nodeName);
     } else {
         if ($nodeName == "." || $nodeName == "..") {
             return false;
         }
         if (RecycleBinManager::recycleEnabled() && $nodePath == RecycleBinManager::getRecyclePath() && $nodeName == RecycleBinManager::getCacheFileName()) {
             return false;
         }
         return !$this->filterFile($nodeName);
     }
 }
 /**
  * @param $location
  * @param $repoData
  * @throws Exception
  */
 protected function deldir($location, $repoData)
 {
     if (is_dir($location)) {
         AJXP_Controller::applyHook("node.before_path_change", array(new AJXP_Node($location)));
         $all = opendir($location);
         while ($file = readdir($all)) {
             if (is_dir("{$location}/{$file}") && $file != ".." && $file != ".") {
                 $this->deldir("{$location}/{$file}", $repoData);
                 if (file_exists("{$location}/{$file}")) {
                     rmdir("{$location}/{$file}");
                 }
                 unset($file);
             } elseif (!is_dir("{$location}/{$file}")) {
                 if (file_exists("{$location}/{$file}")) {
                     unlink("{$location}/{$file}");
                 }
                 unset($file);
             }
         }
         closedir($all);
         rmdir($location);
     } else {
         if (file_exists("{$location}")) {
             AJXP_Controller::applyHook("node.before_path_change", array(new AJXP_Node($location)));
             $test = @unlink("{$location}");
             if (!$test) {
                 throw new Exception("Cannot delete file " . $location);
             }
         }
     }
     if (isset($repoData["recycle"]) && basename(dirname($location)) == $repoData["recycle"]) {
         // DELETING FROM RECYCLE
         RecycleBinManager::deleteFromRecycle($location);
     }
 }
 public function initRepository()
 {
     $this->detectStreamWrapper(true);
     if (is_array($this->pluginConf)) {
         $this->driverConf = $this->pluginConf;
     } else {
         $this->driverConf = array();
     }
     $recycle = $this->repository->getOption("RECYCLE_BIN");
     ConfService::setConf("PROBE_REAL_SIZE", false);
     $this->urlBase = "pydio://" . $this->repository->getId();
     if ($recycle != "" && !is_dir($this->urlBase . "/" . $recycle . "/")) {
         @mkdir($this->urlBase . "/" . $recycle . "/", 0777, true);
         if (!is_dir($this->urlBase . "/" . $recycle . "/")) {
             throw new AJXP_Exception("Cannot create recycle bin folder. Please check repository configuration or that your folder is writeable!");
         } else {
             $this->setHiddenAttribute(new AJXP_Node($this->urlBase . "/" . $recycle . "/"));
         }
     }
     if ($recycle != "") {
         RecycleBinManager::init($this->urlBase, "/" . $recycle);
     }
 }
Example #15
0
 /**
  * @param AJXP_Node $ajxpNode
  * @param bool $parentNode
  * @param bool $details
  * @return void
  */
 public function loadNodeInfo(&$ajxpNode, $parentNode = false, $details = false)
 {
     $mess = ConfService::getMessages();
     $nodeName = basename($ajxpNode->getPath());
     $metaData = $ajxpNode->metadata;
     if (!isset($metaData["is_file"])) {
         $isLeaf = is_file($ajxpNode->getUrl()) || AJXP_Utils::isBrowsableArchive($nodeName);
         $metaData["is_file"] = $isLeaf ? "1" : "0";
     } else {
         $isLeaf = $metaData["is_file"] == "1" ? true : false;
     }
     $metaData["filename"] = $ajxpNode->getPath();
     if (RecycleBinManager::recycleEnabled() && $ajxpNode->getPath() == RecycleBinManager::getRelativeRecycle()) {
         $recycleIcon = $this->countFiles($ajxpNode->getUrl(), false, true) > 0 ? "trashcan_full.png" : "trashcan.png";
         $metaData["icon"] = $recycleIcon;
         $metaData["mimestring"] = $mess[122];
         $ajxpNode->setLabel($mess[122]);
         $metaData["ajxp_mime"] = "ajxp_recycle";
     } else {
         $mimeData = AJXP_Utils::mimeData($ajxpNode->getUrl(), !$isLeaf);
         $metaData["mimestring_id"] = $mimeData[0];
         //AJXP_Utils::mimetype($ajxpNode->getUrl(), "type", !$isLeaf);
         $metaData["icon"] = $mimeData[1];
         //AJXP_Utils::mimetype($nodeName, "image", !$isLeaf);
         if ($metaData["icon"] == "folder.png") {
             $metaData["openicon"] = "folder_open.png";
         }
         if (!$isLeaf) {
             $metaData["ajxp_mime"] = "ajxp_folder";
         }
     }
     //if ($lsOptions["l"]) {
     $metaData["file_group"] = @filegroup($ajxpNode->getUrl()) || "unknown";
     $metaData["file_owner"] = @fileowner($ajxpNode->getUrl()) || "unknown";
     $crtPath = $ajxpNode->getPath();
     $vRoots = $this->repository->listVirtualRoots();
     $metaData["ajxp_readonly"] = "false";
     if (!@$this->isWriteable($ajxpNode->getUrl())) {
         $metaData["ajxp_readonly"] = "true";
     }
     if (!empty($crtPath)) {
         if (isset($vRoots[ltrim($crtPath, "/")])) {
             $metaData["ajxp_readonly"] = $vRoots[ltrim($crtPath, "/")]["right"] == "r" ? "true" : "false";
         }
     } else {
         if (count($vRoots)) {
             $metaData["ajxp_readonly"] = "true";
         }
     }
     $fPerms = @fileperms($ajxpNode->getUrl());
     if ($fPerms !== false) {
         $fPerms = substr(decoct($fPerms), $isLeaf ? 2 : 1);
     } else {
         $fPerms = '0000';
     }
     $metaData["file_perms"] = $fPerms;
     $datemodif = $this->date_modif($ajxpNode->getUrl());
     $metaData["ajxp_modiftime"] = $datemodif ? $datemodif : "0";
     $metaData["ajxp_description"] = $metaData["ajxp_relativetime"] = $mess[4] . " " . AJXP_Utils::relativeDate($datemodif, $mess);
     $metaData["bytesize"] = 0;
     if ($isLeaf) {
         $metaData["bytesize"] = filesize($ajxpNode->getUrl());
     }
     $metaData["filesize"] = AJXP_Utils::roundSize($metaData["bytesize"]);
     if (AJXP_Utils::isBrowsableArchive($nodeName)) {
         $metaData["ajxp_mime"] = "ajxp_browsable_archive";
     }
     if ($details == "minimal") {
         $miniMeta = array("is_file" => $metaData["is_file"], "filename" => $metaData["filename"], "bytesize" => $metaData["bytesize"], "ajxp_modiftime" => $metaData["ajxp_modiftime"]);
         $ajxpNode->mergeMetadata($miniMeta);
     } else {
         $ajxpNode->mergeMetadata($metaData);
     }
 }
 function saveCache($value)
 {
     if (!RecycleBinManager::recycleEnabled()) {
         return null;
     }
     $cachePath = RecycleBinManager::getRecyclePath() . "/" . RecycleBinManager::getCacheFileName();
     $fp = fopen($cachePath, "w");
     if ($fp) {
         fwrite($fp, serialize($value));
         fflush($fp);
         fclose($fp);
     }
 }
 /**
  * Initialize manager
  *
  * @param String $recyclePath Full path to the recycle folder, INCLUDED optional wrapper data (ajxp.fs://repoId/path/to/recycle).
  */
 public static function init($repositoryWrapperURL, $recyclePath)
 {
     self::$rbmRecycle = $repositoryWrapperURL . $recyclePath;
     self::$rbmRelativeRecycle = $recyclePath;
 }
 function delete($selectedFiles, &$logMessages, $dir = "")
 {
     $mess = ConfService::getMessages();
     $result = $this->listing($this->secureFtpPath($this->getPath() . $dir));
     foreach ($selectedFiles as $selectedFile) {
         $data = "";
         $selectedFile = basename($selectedFile);
         if ($selectedFile == "" || $selectedFile == DIRECTORY_SEPARATOR) {
             return $mess[120];
         }
         if (array_key_exists($selectedFile, $result[0])) {
             $data = $result[0][$selectedFile];
             $this->deldir($data['name'], $dir, $data['isDir']);
             if ($data['isDir']) {
                 $logMessages[] = "{$mess['38']} " . SystemTextEncoding::toUTF8($selectedFile) . " {$mess['44']}.";
             } else {
                 $logMessages[] = "{$mess['34']} " . SystemTextEncoding::toUTF8($selectedFile) . " {$mess['44']}.";
             }
             if (RecycleBinManager::currentLocationIsRecycle($dir)) {
                 RecycleBinManager::deleteFromRecycle($selectedFile);
             }
         } else {
             $logMessages[] = $mess[100] . " " . SystemTextEncoding::toUTF8($selectedFile);
             continue;
         }
     }
     return null;
 }
Example #19
0
 public function deleteSelection($actionName, &$httpVars, $filesVars)
 {
     $init = $this->initDirAndSelection($httpVars, array(), true);
     if (isset($init["RECYCLE"]) && isset($init["RECYCLE"]["action"]) && $init["RECYCLE"]["action"] != "delete") {
         $httpVars["dest"] = SystemTextEncoding::fromUTF8($init["RECYCLE"]["dest"]);
         $this->copyOrMoveSelection("move", $httpVars, $filesVars);
         $userSelection = $init["ORIGINAL_SELECTION"];
         $files = $userSelection->getFiles();
         if ($actionName == "delete") {
             foreach ($files as $file) {
                 RecycleBinManager::fileToRecycle($file);
             }
         } else {
             if ($actionName == "restore") {
                 foreach ($files as $file) {
                     RecycleBinManager::deleteFromRecycle($file);
                 }
             }
         }
         $this->commitChanges($actionName, array("dir" => RecycleBinManager::getRelativeRecycle()), $filesVars);
         return;
     }
     foreach ($init["SELECTION"] as $selectedFile) {
         $res = ExecSvnCmd('svn delete', $selectedFile, '--force');
     }
     $this->commitMessageParams = "[" . implode(",", $init["SELECTION"]) . "]";
     $this->commitChanges($actionName, $httpVars, $filesVars);
     $this->logInfo("Delete (svn delegate)", array("files" => $init["SELECTION"]));
     AJXP_XMLWriter::header();
     AJXP_XMLWriter::sendMessage("The selected files/folders have been deleted (by SVN)", null);
     AJXP_XMLWriter::reloadDataNode();
     AJXP_XMLWriter::close();
 }
 public function deldir($location, $repoData)
 {
     if (is_dir($location)) {
         $dirsToRecurse = array();
         $all = opendir($location);
         while ($file = readdir($all)) {
             if (is_dir("{$location}/{$file}") && $file != ".." && $file != ".") {
                 $dirsToRecurse[] = "{$location}/{$file}";
             } elseif (!is_dir("{$location}/{$file}")) {
                 if (file_exists("{$location}/{$file}")) {
                     unlink("{$location}/{$file}");
                 }
                 unset($file);
             }
         }
         closedir($all);
         foreach ($dirsToRecurse as $recurse) {
             $this->deldir($recurse, $repoData);
         }
         rmdir($location);
     } else {
         if (file_exists("{$location}")) {
             $test = @unlink("{$location}");
             if (!$test) {
                 throw new Exception("Cannot delete file " . $location);
             }
         }
     }
     if (isset($repoData["recycle"]) && basename(dirname($location)) == $repoData["recycle"]) {
         // DELETING FROM RECYCLE
         RecycleBinManager::deleteFromRecycle($location);
     }
 }