public static \Joomla\CMS\Filesystem\Stream
getStream
(mixed $usePrefix = true, mixed $useNetwork = true, mixed $userAgentSuffix = 'Joomla', mixed $maskUserAgent = false)
/**
* Creates a new stream object with appropriate prefix
*
* @param boolean $usePrefix Prefix the connections for writing
* @param boolean $useNetwork Use network if available for writing; use false to disable (e.g. FTP, SCP)
* @param string $userAgentSuffix String to append to user agent
* @param boolean $maskUserAgent User agent masking (prefix Mozilla)
*
* @return Stream
*
* @see Stream
* @since 1.7.0
*/
public static function getStream($usePrefix = true, $useNetwork = true, $userAgentSuffix = 'Joomla', $maskUserAgent = false)
{
// Setup the context; Joomla! UA and overwrite
$context = array();
$version = new Version();
// Set the UA for HTTP and overwrite for FTP
$context['http']['user_agent'] = $version->getUserAgent($userAgentSuffix, $maskUserAgent);
$context['ftp']['overwrite'] = true;
if ($usePrefix) {
$FTPOptions = ClientHelper::getCredentials('ftp');
$SCPOptions = ClientHelper::getCredentials('scp');
if ($FTPOptions['enabled'] == 1 && $useNetwork) {
$prefix = 'ftp://' . $FTPOptions['user'] . ':' . $FTPOptions['pass'] . '@' . $FTPOptions['host'];
$prefix .= $FTPOptions['port'] ? ':' . $FTPOptions['port'] : '';
$prefix .= $FTPOptions['root'];
} elseif ($SCPOptions['enabled'] == 1 && $useNetwork) {
$prefix = 'ssh2.sftp://' . $SCPOptions['user'] . ':' . $SCPOptions['pass'] . '@' . $SCPOptions['host'];
$prefix .= $SCPOptions['port'] ? ':' . $SCPOptions['port'] : '';
$prefix .= $SCPOptions['root'];
} else {
$prefix = JPATH_ROOT . '/';
}
$retval = new Stream($prefix, JPATH_ROOT, $context);
} else {
$retval = new Stream('', '', $context);
}
return $retval;
}