SFTP/Stream: use $scheme instead of 'sftp'

This makes it easier for someone to change the scheme (which can be
done by changng the stream_wrapper_register call at the bottom
of the file)
This commit is contained in:
terrafrost 2014-05-29 16:14:03 -05:00
parent aa5f9b77ec
commit 3dd92e56e4

View File

@ -180,24 +180,24 @@ class Net_SFTP_Stream
if (isset($this->context)) {
$context = stream_context_get_options($this->context);
}
if (isset($context['sftp']['session'])) {
$sftp = $context['sftp']['session'];
if (isset($context[$scheme]['session'])) {
$sftp = $context[$scheme]['session'];
}
if (isset($context['sftp']['sftp'])) {
$sftp = $context['sftp']['sftp'];
if (isset($context[$scheme]['sftp'])) {
$sftp = $context[$scheme]['sftp'];
}
if (isset($sftp) && is_object($sftp) && get_class($sftp) == 'Net_SFTP') {
$this->sftp = $sftp;
return $path;
}
if (isset($context['sftp']['username'])) {
$user = $context['sftp']['username'];
if (isset($context[$scheme]['username'])) {
$user = $context[$scheme]['username'];
}
if (isset($context['sftp']['password'])) {
$pass = $context['sftp']['password'];
if (isset($context[$scheme]['password'])) {
$pass = $context[$scheme]['password'];
}
if (isset($context['sftp']['privkey']) && is_object($context['sftp']['privkey']) && get_Class($context['sftp']['privkey']) == 'Crypt_RSA') {
$pass = $context['sftp']['privkey'];
if (isset($context[$scheme]['privkey']) && is_object($context[$scheme]['privkey']) && get_Class($context[$scheme]['privkey']) == 'Crypt_RSA') {
$pass = $context[$scheme]['privkey'];
}
if (!isset($user) || !isset($pass)) {