From 5e0d58f0827717f7cd699afc0bd6e0d4192a9ead Mon Sep 17 00:00:00 2001 From: John Sterling Date: Thu, 11 Jul 2013 17:18:42 -0400 Subject: [PATCH] SFTP: Add optimization for put() with NET_SFTP_LOCAL_FILE Use substr() instead of _string_shift(). --- phpseclib/Net/SFTP.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 9249421c..29f692a7 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -1516,7 +1516,7 @@ class Net_SFTP extends Net_SSH2 { $sftp_packet_size = 4096; // PuTTY uses 4096 $i = 0; while ($sent < $size) { - $temp = $mode & NET_SFTP_LOCAL_FILE ? fread($fp, $sftp_packet_size) : $this->_string_shift($data, $sftp_packet_size); + $temp = $mode & NET_SFTP_LOCAL_FILE ? fread($fp, $sftp_packet_size) : substr($data, $sent, $sftp_packet_size); $subtemp = $offset + $sent; $packet = pack('Na*N3a*', strlen($handle), $handle, $subtemp / 0x100000000, $subtemp, strlen($temp), $temp); if (!$this->_send_sftp_packet(NET_SFTP_WRITE, $packet)) { @@ -2201,4 +2201,4 @@ class Net_SFTP extends Net_SSH2 { $this->pwd = false; parent::_disconnect($reason); } -} \ No newline at end of file +}