35 public function open(array $args = [])
37 if (!isset($args[
'timeout'])) {
40 if (strpos($args[
'host'],
':') !==
false) {
41 list($host, $port) = explode(
':', $args[
'host'], 2);
43 $host = $args[
'host'];
46 $this->_connection = new \phpseclib\Net\SFTP($host, $port, $args[
'timeout']);
47 if (!$this->_connection->login($args[
'username'], $args[
'password'])) {
49 sprintf(
"Unable to open SFTP connection as %s@%s", $args[
'username'], $args[
'host'])
61 $this->_connection->disconnect();
78 public function mkdir($dir,
$mode = 0777, $recursive =
true)
84 $currentWorkingDir = $this->_connection->pwd();
85 while ($no_errors && ($dir_item = next(
$dirList))) {
86 $no_errors = $this->_connection->mkdir($dir_item) && $this->_connection->chdir($dir_item);
88 $this->_connection->chdir($currentWorkingDir);
91 return $this->_connection->mkdir($dir);
104 public function rmdir($dir, $recursive =
false)
108 $currentWorkingDir = $this->
pwd();
109 if (!$this->_connection->chdir($dir)) {
110 throw new \Exception(
"chdir(): {$dir}: Not a directory");
112 $list = $this->_connection->nlist();
115 $this->_connection->chdir($currentWorkingDir);
116 return $this->
rmdir($dir,
false);
118 foreach ($list as $filename) {
119 if ($this->_connection->chdir($filename)) {
121 $this->_connection->chdir(
'..');
122 $no_errors = $no_errors && $this->
rmdir($filename, $recursive);
124 $no_errors = $no_errors && $this->
rm($filename);
128 $no_errors = $no_errors && ($this->_connection->chdir(
130 ) && $this->_connection->rmdir(
135 return $this->_connection->rmdir($dir);
146 return $this->_connection->pwd();
156 public function cd($dir)
158 return $this->_connection->chdir($dir);
168 public function read($filename, $destination =
null)
170 if ($destination ===
null) {
171 $destination =
false;
173 return $this->_connection->get($filename, $destination);
187 return $this->_connection->put($filename,
$source,
$mode);
197 public function rm($filename)
199 return $this->_connection->delete($filename);
212 return $this->_connection->rename(
$source, $destination);
224 return $this->_connection->chmod(
$mode, $filename);
235 public function ls($grep =
null)
237 $list = $this->_connection->nlist();
238 $currentWorkingDir = $this->
pwd();
240 foreach ($list as
$name) {
241 $result[] = [
'text' =>
$name,
'id' =>
"{$currentWorkingDir}/{$name}"];
253 $list = $this->_connection->rawlist();
if(!file_exists($installConfigFile)) $dirList
mkdir($dir, $mode=0777, $recursive=true)
read($filename, $destination=null)
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
rmdir($dir, $recursive=false)
mv($source, $destination)
write($filename, $source, $mode=null)
if(!isset($_GET['name'])) $name