method __construct documentation in bbn\File\Ftp

function($cfg = []) { if ( \is_array($cfg) ) { $this->dir = $cfg['dir'] ?? ''; if ( isset($cfg['host']) ){ $host = $cfg['host']; } else if ( \defined('BBN_FTP_HOST') ){ $host = BBN_FTP_HOST; } if ( isset($cfg['user']) ){ $login = $cfg['user']; } else if ( \defined('BBN_FTP_USER') ){ $login = BBN_FTP_LOGIN; } if ( isset($cfg['pass']) ){ // $this->pass = bbn\Util\Enc::decrypt($cfg['pass']); $pass = $cfg['pass']; } else if ( \defined('BBN_FTP_PASS') ){ $pass = bbn\Util\Enc::decrypt(BBN_FTP_PASS); } if ( isset($this->dir, $host, $login, $pass) && ($this->dir = $this->checkPath($this->dir)) ){ if ( empty($cfg['ssl']) ){ $this->cn = ftp_connect($host, $cfg['port'] ?? 21, $cfg['timeout'] ?? self::TIMEOUT); } else{ $this->cn = ftp_ssl_connect($host, $cfg['port'] ?? 21, $cfg['timeout'] ?? self::TIMEOUT); } if ( $this->cn ){ if ( ftp_login($this->cn, $login, $pass) ) { if ( @ftp_chdir($this->cn, $this->dir) ) { ftp_pasv($this->cn,TRUE); return; } else { $this->error = \defined('BBN_IMPOSSIBLE_TO_FIND_THE_SPECIFIED_FOLDER') ? BBN_IMPOSSIBLE_TO_FIND_THE_SPECIFIED_FOLDER : 'Impossible to find the specified folder'; } } else { $this->cn = false; $this->error = \defined('BBN_IMPOSSIBLE_TO_CONNECT_TO_THE_FTP_HOST') ? BBN_IMPOSSIBLE_TO_CONNECT_TO_THE_FTP_HOST : 'Impossible to connect to the FTP host'; } } else { $this->error = \defined('BBN_IMPOSSIBLE_TO_FIND_THE_FTP_HOST') ? BBN_IMPOSSIBLE_TO_FIND_THE_FTP_HOST : 'Unable to find the FTP host'; } } } }

BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.