From ccad4b7d0808f1a6db2a7cdd9b8c9708da074e51 Mon Sep 17 00:00:00 2001 From: Brian Nesbitt Date: Fri, 1 Nov 2013 12:15:28 -0400 Subject: [PATCH 1/5] Added a callable to put for progress updates This in combination with https://github.com/maximebf/ConsoleKit ProgressBar makes me feel good. --- phpseclib/Net/SCP.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpseclib/Net/SCP.php b/phpseclib/Net/SCP.php index 5f9517e1..88180cac 100644 --- a/phpseclib/Net/SCP.php +++ b/phpseclib/Net/SCP.php @@ -161,10 +161,11 @@ class Net_SCP { * @param String $remote_file * @param String $data * @param optional Integer $mode + * @param optional Callable $callback * @return Boolean * @access public */ - function put($remote_file, $data, $mode = NET_SCP_STRING) + function put($remote_file, $data, $mode = NET_SCP_STRING, $callback = null) { if (!isset($this->ssh)) { return false; @@ -213,6 +214,10 @@ class Net_SCP { $temp = $mode & NET_SCP_STRING ? substr($data, $sent, $this->packet_size) : fread($fp, $this->packet_size); $this->_send($temp); $sent+= strlen($temp); + + if (is_callable($callback)) { + $callback($sent); + } } $this->_close(); From 71ae795460025fdc20758a717de68b10d8636e62 Mon Sep 17 00:00:00 2001 From: Jesse Schalken Date: Mon, 4 Nov 2013 17:48:01 +1100 Subject: [PATCH 2/5] Fixed typo in object class name comparison --- phpseclib/Net/SFTP/Stream.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpseclib/Net/SFTP/Stream.php b/phpseclib/Net/SFTP/Stream.php index 30cbc86b..4df25c16 100644 --- a/phpseclib/Net/SFTP/Stream.php +++ b/phpseclib/Net/SFTP/Stream.php @@ -169,7 +169,7 @@ class Net_SFTP_Stream { if ($host[0] == '$') { $host = substr($host, 1); global $$host; - if (!is_object($$host) || get_class($$host) != 'Net_sFTP') { + if (!is_object($$host) || get_class($$host) != 'Net_SFTP') { return false; } $this->sftp = $$host; From 9f1108e52e4787610a488868d774992e1ca28979 Mon Sep 17 00:00:00 2001 From: Frank de Jonge Date: Tue, 5 Nov 2013 11:27:16 +0100 Subject: [PATCH 3/5] Check wether CRYPT_RANDOM_IS_WINDOWS is defined before defining it. --- phpseclib/Crypt/Random.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/phpseclib/Crypt/Random.php b/phpseclib/Crypt/Random.php index 948512da..f7cdc7c5 100644 --- a/phpseclib/Crypt/Random.php +++ b/phpseclib/Crypt/Random.php @@ -21,10 +21,10 @@ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -46,7 +46,9 @@ * * @access private */ -define('CRYPT_RANDOM_IS_WINDOWS', strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'); +if (defined('CRYPT_RANDOM_IS_WINDOWS') === false) { + define('CRYPT_RANDOM_IS_WINDOWS', strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'); +} /** * Generate a random string. From 4976cd16226ad432e6973038d4611890fd71297e Mon Sep 17 00:00:00 2001 From: Frank de Jonge Date: Tue, 5 Nov 2013 13:01:03 +0100 Subject: [PATCH 4/5] Fixed coding style to comply with other not defined statements --- phpseclib/Crypt/Random.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpseclib/Crypt/Random.php b/phpseclib/Crypt/Random.php index f7cdc7c5..e38bdf8d 100644 --- a/phpseclib/Crypt/Random.php +++ b/phpseclib/Crypt/Random.php @@ -46,7 +46,7 @@ * * @access private */ -if (defined('CRYPT_RANDOM_IS_WINDOWS') === false) { +if (!defined('CRYPT_RANDOM_IS_WINDOWS')) { define('CRYPT_RANDOM_IS_WINDOWS', strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'); } From 2241d0e6f45df686270dc53b9e029189ee2e0a5a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 6 Nov 2013 23:12:00 +0100 Subject: [PATCH 5/5] Partial revert of 9f1108e52e4787610a488868d774992e1ca28979. This change should not be necessary. --- phpseclib/Crypt/Random.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/phpseclib/Crypt/Random.php b/phpseclib/Crypt/Random.php index e38bdf8d..8532aab5 100644 --- a/phpseclib/Crypt/Random.php +++ b/phpseclib/Crypt/Random.php @@ -46,9 +46,7 @@ * * @access private */ -if (!defined('CRYPT_RANDOM_IS_WINDOWS')) { - define('CRYPT_RANDOM_IS_WINDOWS', strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'); -} +define('CRYPT_RANDOM_IS_WINDOWS', strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'); /** * Generate a random string.