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());
$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;
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;
}