From b41ef814eeb53b93622d19a92557f32b9f962404 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 12 Feb 2025 10:35:13 +0100 Subject: [PATCH] wip #7328 @0.5 --- src/Transfer/FTP.php | 20 +++++++++++++++++--- src/Transfer/FTPES.php | 11 +++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 src/Transfer/FTPES.php diff --git a/src/Transfer/FTP.php b/src/Transfer/FTP.php index f15cb5e..5194646 100644 --- a/src/Transfer/FTP.php +++ b/src/Transfer/FTP.php @@ -20,7 +20,14 @@ class FTP extends Driver protected $port = 21; - protected function synchronizeFiles($source, $dest, $mirror = false, $dryrun = false) + /** + * @param $source + * @param $dest + * @param $mirror + * @param $dryrun + * @return LFTP + */ + protected function _lftp($source, $dest, $mirror = false, $dryrun = false) { $lftp = new LFTP(); $lftp->setServer($this->getServer()); @@ -28,13 +35,19 @@ class FTP extends Driver $lftp->setDest($dest); $lftp->setMirror($mirror); $lftp->setDryRun($dryrun); + return $lftp; + } + + protected function synchronizeFiles($source, $dest, $mirror = false, $dryrun = false) + { + $lftp = $this->_lftp($source, $dest, $mirror, $dryrun); $lftp->execute(); return $lftp; } public function checkConnexion($data = []) { - if(!$this->checkConnection){ + if (!$this->checkConnection) { return true; } $data['port'] = $data['port'] ?? $this->port; @@ -48,8 +61,9 @@ class FTP extends Driver if (!$data['host']) { return self::ERROR_MISSING_HOST; } else { + $ftp_connect = $this->getServer()->getProtocol() === 'FTP' ? 'ftp_connect' : 'ftp_ssl_connect'; try { - $ftp = $data['port'] ? ftp_connect($data['host'], $data['port']) : ftp_connect($data['host']); + $ftp = $ftp_connect($data['host'], $data['port'], 12); } catch (\Exception $e) { return static::ERROR_INVALID_PARAM; } diff --git a/src/Transfer/FTPES.php b/src/Transfer/FTPES.php new file mode 100644 index 0000000..5babd62 --- /dev/null +++ b/src/Transfer/FTPES.php @@ -0,0 +1,11 @@ +