1 ftp.inc | static FileTransferFTP::factory($jail, $settings) |
Return value
FileTransferFTP: The appropriate FileTransferFTP subclass based on the available options. If the FTP PHP extension is available, use it.
Throws
Overrides FileTransfer::factory
File
- core/
includes/ filetransfer/ ftp.inc, line 25
Class
- FileTransferFTP
- Base class for FTP implementations.
Code
static function factory($jail, $settings) {
$username = empty($settings['username']) ? '' : $settings['username'];
$password = empty($settings['password']) ? '' : $settings['password'];
$hostname = empty($settings['advanced']['hostname']) ? 'localhost' : $settings['advanced']['hostname'];
$port = empty($settings['advanced']['port']) ? 21 : $settings['advanced']['port'];
if (function_exists('ftp_connect')) {
$class = 'FileTransferFTPExtension';
}
else {
throw new FileTransferException('No FTP backend available.');
}
return new $class($jail, $username, $password, $hostname, $port);
}