77 public function open(array $args = [])
79 if (empty($args[
'host'])) {
84 if (empty($args[
'port'])) {
88 if (empty($args[
'user'])) {
89 $args[
'user'] =
'anonymous';
93 if (empty($args[
'password'])) {
94 $args[
'password'] =
'';
97 if (empty($args[
'timeout'])) {
98 $args[
'timeout'] = 90;
101 if (empty($args[
'file_mode'])) {
102 $args[
'file_mode'] = FTP_BINARY;
105 $this->_config = $args;
107 if (empty($this->_config[
'ssl'])) {
108 $this->_conn = @ftp_connect($this->_config[
'host'], $this->_config[
'port'], $this->_config[
'timeout']);
110 $this->_conn = @ftp_ssl_connect($this->_config[
'host'], $this->_config[
'port'], $this->_config[
'timeout']);
115 new Phrase(
"The FTP connection couldn't be established because of an invalid host or port.")
119 if (!@ftp_login($this->_conn, $this->_config[
'user'], $this->_config[
'password'])) {
125 if (!empty($this->_config[
'path'])) {
126 if (!@ftp_chdir($this->_conn, $this->_config[
'path'])) {
133 if (!empty($this->_config[
'passive'])) {
134 if (!@ftp_pasv($this->_conn,
true)) {
151 return @ftp_close($this->_conn);
166 return @ftp_mkdir($this->_conn, $dir);
177 public function rmdir($dir, $recursive =
false)
179 return @ftp_rmdir($this->_conn, $dir);
189 return @ftp_pwd($this->_conn);
199 public function cd($dir)
201 return @ftp_chdir($this->_conn, $dir);
211 public function read($filename, $dest =
null)
213 if (is_string($dest)) {
214 $result = ftp_get($this->_conn, $dest, $filename, $this->_config[
'file_mode']);
218 }
elseif ($dest ===
null) {
225 $result = ftp_fget($this->_conn, $stream, $filename, $this->_config[
'file_mode']);
227 if ($dest ===
null) {
250 return @ftp_put($this->_conn, $filename, $src, $this->_config[
'file_mode']);
252 if (is_string($src)) {
254 fputs($stream, $src);
263 $result = ftp_fput($this->_conn, $filename, $stream, $this->_config[
'file_mode']);
264 if (is_string($src)) {
278 public function rm($filename)
280 return @ftp_delete($this->_conn, $filename);
291 public function mv($src, $dest)
293 return @ftp_rename($this->_conn, $src, $dest);
305 return @ftp_chmod($this->_conn,
$mode, $filename);
314 public function ls($grep =
null)
316 $ls = @ftp_nlist($this->_conn,
'.');
319 foreach ($ls as $file) {
320 $list[] = [
'text' => $file,
'id' => $this->
pwd() .
'/' . $file];
333 $this->
_tmpFilename = tempnam(md5(uniqid(rand(),
true)),
'');
elseif(isset( $params[ 'redirect_parent']))
mkdir($dir, $mode=0777, $recursive=true)
const ERROR_INVALID_DESTINATION
const ERROR_INVALID_CONNECTION
read($filename, $dest=null)
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
const ERROR_INVALID_SOURCE
const ERROR_INVALID_LOGIN
rmdir($dir, $recursive=false)
write($filename, $src, $mode=null)