]> _ Git - cubist_net.git/commitdiff
wip #7328 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 12 Feb 2025 09:35:13 +0000 (10:35 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 12 Feb 2025 09:35:13 +0000 (10:35 +0100)
src/Transfer/FTP.php
src/Transfer/FTPES.php [new file with mode: 0644]

index f15cb5e9aa570d86659248c055634c450202e838..51946468bb3c6bde646f23d81bcba70902189e1b 100644 (file)
@@ -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 (file)
index 0000000..5babd62
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+
+namespace Cubist\Net\Transfer;
+
+use Cubist\Util\CommandLine\LFTP;
+use Cubist\Util\Files\Files;
+
+class FTPES extends FTP
+{
+
+}