/** * (non-PHPDoc) * * @see \phpbu\App\Backup\Sync::setup() * @param array $config * @throws \phpbu\App\Backup\Sync\Exception */ public function setup(array $config) { if (!class_exists('\\phpseclib\\Net\\SFTP')) { throw new Exception('phpseclib not installed - use composer to install "phpseclib/phpseclib" version 2.x'); } if (!Arr::isSetAndNotEmptyString($config, 'host')) { throw new Exception('option \'host\' is missing'); } if (!Arr::isSetAndNotEmptyString($config, 'user')) { throw new Exception('option \'user\' is missing'); } if (!Arr::isSetAndNotEmptyString($config, 'password')) { throw new Exception('option \'password\' is missing'); } $path = Arr::getValue($config, 'path', ''); if ('/' === substr($path, 0, 1)) { throw new Exception('absolute path is not allowed'); } $this->host = $config['host']; $this->user = $config['user']; $this->password = $config['password']; $this->remotePath = Str::withoutTrailingSlash(Str::replaceDatePlaceholders($path)); }
public function setup(array $config) { if (!function_exists('ftp_connect')) { throw new Exception('ftp functions not enabled'); } if (!Arr::isSetAndNotEmptyString($config, 'host')) { throw new Exception('option \'host\' is missing'); } if (!Arr::isSetAndNotEmptyString($config, 'user')) { throw new Exception('option \'user\' is missing'); } if (!Arr::isSetAndNotEmptyString($config, 'password')) { throw new Exception('option \'password\' is missing'); } $path = Arr::getValue($config, 'path', ''); if ('/' === substr($path, 0, 1)) { throw new Exception('absolute path is not allowed'); } $this->host = $config['host']; $this->user = $config['user']; $this->password = $config['password']; $this->remotePath = Str::withoutTrailingSlash(Str::replaceDatePlaceholders($path)); }