mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-16 02:07:09 +00:00
SFTP: Add a NO_REALPATH option to put()
This commit is contained in:
parent
a451dd69f8
commit
5979ed571f
@ -96,25 +96,29 @@ define('NET_SFTP_CHANNEL', 0x100);
|
|||||||
/**
|
/**
|
||||||
* Reads data from a local file.
|
* Reads data from a local file.
|
||||||
*/
|
*/
|
||||||
define('NET_SFTP_LOCAL_FILE', 1);
|
define('NET_SFTP_LOCAL_FILE', 0x1);
|
||||||
/**
|
/**
|
||||||
* Reads data from a string.
|
* Reads data from a string.
|
||||||
*/
|
*/
|
||||||
// this value isn't really used anymore but i'm keeping it reserved for historical reasons
|
// this value isn't really used anymore but i'm keeping it reserved for historical reasons
|
||||||
define('NET_SFTP_STRING', 2);
|
define('NET_SFTP_STRING', 0x2);
|
||||||
/**
|
/**
|
||||||
* Reads data from callback:
|
* Reads data from callback:
|
||||||
* function callback($length) returns string to proceed, null for EOF
|
* function callback($length) returns string to proceed, null for EOF
|
||||||
*/
|
*/
|
||||||
define('NET_SFTP_CALLBACK', 16);
|
define('NET_SFTP_CALLBACK', 0x10);
|
||||||
/**
|
/**
|
||||||
* Resumes an upload
|
* Resumes an upload
|
||||||
*/
|
*/
|
||||||
define('NET_SFTP_RESUME', 4);
|
define('NET_SFTP_RESUME', 0x4);
|
||||||
/**
|
/**
|
||||||
* Append a local file to an already existing remote file
|
* Append a local file to an already existing remote file
|
||||||
*/
|
*/
|
||||||
define('NET_SFTP_RESUME_START', 8);
|
define('NET_SFTP_RESUME_START', 0x8);
|
||||||
|
/**
|
||||||
|
* Skip canonicalizing the remote path
|
||||||
|
*/
|
||||||
|
define('NET_SFTP_NO_REALPATH', 0x20);
|
||||||
/**#@-*/
|
/**#@-*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1887,8 +1891,9 @@ class Net_SFTP extends Net_SSH2
|
|||||||
* Currently, only binary mode is supported. As such, if the line endings need to be adjusted, you will need to take
|
* Currently, only binary mode is supported. As such, if the line endings need to be adjusted, you will need to take
|
||||||
* care of that, yourself.
|
* care of that, yourself.
|
||||||
*
|
*
|
||||||
* $mode can take an additional two parameters - NET_SFTP_RESUME and NET_SFTP_RESUME_START. These are bitwise AND'd with
|
* $mode can take three additional parameters - NET_SFTP_RESUME, NET_SFTP_RESUME_START and NET_SFTP_NO_REALPATH. These
|
||||||
* $mode. So if you want to resume upload of a 300mb file on the local file system you'd set $mode to the following:
|
* are bitwise AND'd with $mode. So if you want to resume upload of a 300mb file on the local file system you'd set $mode
|
||||||
|
* to the following:
|
||||||
*
|
*
|
||||||
* NET_SFTP_LOCAL_FILE | NET_SFTP_RESUME
|
* NET_SFTP_LOCAL_FILE | NET_SFTP_RESUME
|
||||||
*
|
*
|
||||||
@ -1904,6 +1909,9 @@ class Net_SFTP extends Net_SSH2
|
|||||||
*
|
*
|
||||||
* Setting $local_start to > 0 or $mode | NET_SFTP_RESUME_START doesn't do anything unless $mode | NET_SFTP_LOCAL_FILE.
|
* Setting $local_start to > 0 or $mode | NET_SFTP_RESUME_START doesn't do anything unless $mode | NET_SFTP_LOCAL_FILE.
|
||||||
*
|
*
|
||||||
|
* Passing self::NO_REALPATH skips canonicalization of the remote path; $remote_file will be passed verbatim to the
|
||||||
|
* remote host.
|
||||||
|
*
|
||||||
* @param string $remote_file
|
* @param string $remote_file
|
||||||
* @param string|resource $data
|
* @param string|resource $data
|
||||||
* @param int $mode
|
* @param int $mode
|
||||||
@ -1920,9 +1928,11 @@ class Net_SFTP extends Net_SSH2
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$remote_file = $this->_realpath($remote_file);
|
if (!($mode & NET_SFTP_NO_REALPATH)) {
|
||||||
if ($remote_file === false) {
|
$remote_file = $this->_realpath($remote_file);
|
||||||
return false;
|
if ($remote_file === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_remove_from_stat_cache($remote_file);
|
$this->_remove_from_stat_cache($remote_file);
|
||||||
|
Loading…
Reference in New Issue
Block a user