diff --git a/phpseclib/File/ANSI.php b/phpseclib/File/ANSI.php index 123b7643..aa5b1bba 100644 --- a/phpseclib/File/ANSI.php +++ b/phpseclib/File/ANSI.php @@ -5,7 +5,7 @@ * * PHP versions 4 and 5 * - * If you call read() in Net_SSH2 you may get {@link http://en.wikipedia.org/wiki/ANSI_escape_code ANSI escape codes} back. + * If you call read() in \phpseclib\Net\SSH2 you may get {@link http://en.wikipedia.org/wiki/ANSI_escape_code ANSI escape codes} back. * They'd look like chr(0x1B) . '[00m' or whatever (0x1B = ESC). They tell a * {@link http://en.wikipedia.org/wiki/Terminal_emulator terminal emulator} how to format the characters, what * color to display them in, etc. \phpseclib\File\ANSI is a {@link http://en.wikipedia.org/wiki/VT100 VT100} terminal emulator. diff --git a/phpseclib/Net/SCP.php b/phpseclib/Net/SCP.php index 892f6a3a..79bf30dc 100644 --- a/phpseclib/Net/SCP.php +++ b/phpseclib/Net/SCP.php @@ -10,39 +10,43 @@ * Here's a short example of how to use this library: * * login('username', 'password')) { * exit('bad login'); * } - * $scp = new Net_SCP($ssh); + * $scp = new \phpseclib\Net\SCP($ssh); * $scp->put('abcd', str_repeat('x', 1024*1024)); * ?> * * * @category Net - * @package Net_SCP + * @package SCP * @author Jim Wigginton * @copyright 2010 Jim Wigginton * @license http://www.opensource.org/licenses/mit-license.html MIT License * @link http://phpseclib.sourceforge.net */ +namespace phpseclib\Net; + +use phpseclib\Net\SSH1; +use phpseclib\Net\SSH2; + /** * Pure-PHP implementations of SCP. * - * @package Net_SCP + * @package SCP * @author Jim Wigginton * @access public */ -class Net_SCP +class SCP { /**#@+ * @access public - * @see Net_SCP::put() + * @see \phpseclib\Net\SCP::put() */ /** * Reads data from a local file. @@ -56,8 +60,8 @@ class Net_SCP /**#@+ * @access private - * @see Net_SCP::_send() - * @see Net_SCP::_receive() + * @see \phpseclib\Net\SCP::_send() + * @see \phpseclib\Net\SCP::_receive() */ /** * SSH1 is being used. @@ -101,7 +105,7 @@ class Net_SCP * @param String $host * @param optional Integer $port * @param optional Integer $timeout - * @return Net_SCP + * @return \phpseclib\Net\SCP * @access public */ function __construct($ssh) @@ -110,11 +114,11 @@ class Net_SCP return; } - switch (strtolower(get_class($ssh))) { - case 'net_ssh2': + switch (get_class($ssh)) { + case 'phpseclib\Net\SSH2': $this->mode = self::MODE_SSH2; break; - case 'net_ssh1': + case 'phpseclib\Net\SSH1': $this->packet_size = 50000; $this->mode = self::MODE_SSH1; break; @@ -128,8 +132,8 @@ class Net_SCP /** * Uploads a file to the SCP server. * - * By default, Net_SCP::put() does not read from the local filesystem. $data is dumped directly into $remote_file. - * So, for example, if you set $data to 'filename.ext' and then do Net_SCP::get(), you will get a file, twelve bytes + * By default, \phpseclib\Net\SCP::put() does not read from the local filesystem. $data is dumped directly into $remote_file. + * So, for example, if you set $data to 'filename.ext' and then do \phpseclib\Net\SCP::get(), you will get a file, twelve bytes * long, containing 'filename.ext' as its contents. * * Setting $mode to self::SOURCE_LOCAL_FILE will change the above behavior. With self::SOURCE_LOCAL_FILE, $remote_file will @@ -162,7 +166,7 @@ class Net_SCP } if ($this->mode == self::MODE_SSH2) { - $this->packet_size = $this->ssh->packet_size_client_to_server[Net_SSH2::CHANNEL_EXEC] - 4; + $this->packet_size = $this->ssh->packet_size_client_to_server[SSH2::CHANNEL_EXEC] - 4; } $remote_file = basename($remote_file); @@ -280,7 +284,7 @@ class Net_SCP { switch ($this->mode) { case self::MODE_SSH2: - $this->ssh->_send_channel_packet(Net_SSH2::CHANNEL_EXEC, $data); + $this->ssh->_send_channel_packet(SSH2::CHANNEL_EXEC, $data); break; case self::MODE_SSH1: $data = pack('CNa*', NET_SSH1_CMSG_STDIN_DATA, strlen($data), $data); @@ -298,17 +302,17 @@ class Net_SCP { switch ($this->mode) { case self::MODE_SSH2: - return $this->ssh->_get_channel_packet(Net_SSH2::CHANNEL_EXEC, true); + return $this->ssh->_get_channel_packet(SSH2::CHANNEL_EXEC, true); case self::MODE_SSH1: if (!$this->ssh->bitmap) { return false; } while (true) { $response = $this->ssh->_get_binary_packet(); - switch ($response[Net_SSH1::RESPONSE_TYPE]) { + switch ($response[SSH1::RESPONSE_TYPE]) { case NET_SSH1_SMSG_STDOUT_DATA: - extract(unpack('Nlength', $response[Net_SSH1::RESPONSE_DATA])); - return $this->ssh->_string_shift($response[Net_SSH1::RESPONSE_DATA], $length); + extract(unpack('Nlength', $response[SSH1::RESPONSE_DATA])); + return $this->ssh->_string_shift($response[SSH1::RESPONSE_DATA], $length); case NET_SSH1_SMSG_STDERR_DATA: break; case NET_SSH1_SMSG_EXITSTATUS: @@ -333,7 +337,7 @@ class Net_SCP { switch ($this->mode) { case self::MODE_SSH2: - $this->ssh->_close_channel(Net_SSH2::CHANNEL_EXEC, true); + $this->ssh->_close_channel(SSH2::CHANNEL_EXEC, true); break; case self::MODE_SSH1: $this->ssh->disconnect(); diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index f5b32554..b3363aa8 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -14,9 +14,9 @@ * Here's a short example of how to use this library: * * login('username', 'password')) { * exit('Login Failed'); * } @@ -28,43 +28,40 @@ * * * @category Net - * @package Net_SFTP + * @package SFTP * @author Jim Wigginton * @copyright 2009 Jim Wigginton * @license http://www.opensource.org/licenses/mit-license.html MIT License * @link http://phpseclib.sourceforge.net */ -/** - * Include Net_SSH2 - */ -if (!class_exists('Net_SSH2')) { - include_once 'SSH2.php'; -} +namespace phpseclib\Net; + +use phpseclib\Net\SSH2; /** * Pure-PHP implementations of SFTP. * - * @package Net_SFTP + * @package SFTP * @author Jim Wigginton * @access public */ -class Net_SFTP extends Net_SSH2 +class SFTP extends SSH2 { /** * SFTP channel constant * - * Net_SSH2::exec() uses 0 and Net_SSH2::read() / Net_SSH2::write() use 1. + * \phpseclib\Net\SSH2::exec() uses 0 and \phpseclib\Net\SSH2::read() / \phpseclib\Net\SSH2::write() use 1. * - * @see Net_SSH2::_send_channel_packet() - * @see Net_SSH2::_get_channel_packet() + * @see \phpseclib\Net\SSH2::_send_channel_packet() + * @see \phpseclib\Net\SSH2::_get_channel_packet() * @access private */ const CHANNEL = 0x100; /**#@+ * @access public - * @see Net_SFTP::put() + * @see \phpseclib\Net\SFTP::put() */ /** * Reads data from a local file. @@ -88,7 +85,7 @@ class Net_SFTP extends Net_SSH2 /** * Packet Types * - * @see Net_SFTP::__construct() + * @see \phpseclib\Net\SFTP::__construct() * @var Array * @access private */ @@ -97,7 +94,7 @@ class Net_SFTP extends Net_SSH2 /** * Status Codes * - * @see Net_SFTP::__construct() + * @see \phpseclib\Net\SFTP::__construct() * @var Array * @access private */ @@ -110,7 +107,7 @@ class Net_SFTP extends Net_SSH2 * concurrent actions, so it's somewhat academic, here. * * @var Integer - * @see Net_SFTP::_send_sftp_packet() + * @see \phpseclib\Net\SFTP::_send_sftp_packet() * @access private */ var $request_id = false; @@ -122,7 +119,7 @@ class Net_SFTP extends Net_SSH2 * concurrent actions, so it's somewhat academic, here. * * @var Integer - * @see Net_SFTP::_get_sftp_packet() + * @see \phpseclib\Net\SFTP::_get_sftp_packet() * @access private */ var $packet_type = -1; @@ -131,7 +128,7 @@ class Net_SFTP extends Net_SSH2 * Packet Buffer * * @var String - * @see Net_SFTP::_get_sftp_packet() + * @see \phpseclib\Net\SFTP::_get_sftp_packet() * @access private */ var $packet_buffer = ''; @@ -140,7 +137,7 @@ class Net_SFTP extends Net_SSH2 * Extensions supported by the server * * @var Array - * @see Net_SFTP::_initChannel() + * @see \phpseclib\Net\SFTP::_initChannel() * @access private */ var $extensions = array(); @@ -149,7 +146,7 @@ class Net_SFTP extends Net_SSH2 * Server SFTP version * * @var Integer - * @see Net_SFTP::_initChannel() + * @see \phpseclib\Net\SFTP::_initChannel() * @access private */ var $version; @@ -158,8 +155,8 @@ class Net_SFTP extends Net_SSH2 * Current working directory * * @var String - * @see Net_SFTP::_realpath() - * @see Net_SFTP::chdir() + * @see \phpseclib\Net\SFTP::_realpath() + * @see \phpseclib\Net\SFTP::chdir() * @access private */ var $pwd = false; @@ -167,7 +164,7 @@ class Net_SFTP extends Net_SSH2 /** * Packet Type Log * - * @see Net_SFTP::getLog() + * @see \phpseclib\Net\SFTP::getLog() * @var Array * @access private */ @@ -176,7 +173,7 @@ class Net_SFTP extends Net_SSH2 /** * Packet Log * - * @see Net_SFTP::getLog() + * @see \phpseclib\Net\SFTP::getLog() * @var Array * @access private */ @@ -185,8 +182,8 @@ class Net_SFTP extends Net_SSH2 /** * Error information * - * @see Net_SFTP::getSFTPErrors() - * @see Net_SFTP::getLastSFTPError() + * @see \phpseclib\Net\SFTP::getSFTPErrors() + * @see \phpseclib\Net\SFTP::getLastSFTPError() * @var String * @access private */ @@ -198,9 +195,9 @@ class Net_SFTP extends Net_SSH2 * Rather than always having to open a directory and close it immediately there after to see if a file is a directory * we'll cache the results. * - * @see Net_SFTP::_update_stat_cache() - * @see Net_SFTP::_remove_from_stat_cache() - * @see Net_SFTP::_query_stat_cache() + * @see \phpseclib\Net\SFTP::_update_stat_cache() + * @see \phpseclib\Net\SFTP::_remove_from_stat_cache() + * @see \phpseclib\Net\SFTP::_query_stat_cache() * @var Array * @access private */ @@ -209,8 +206,8 @@ class Net_SFTP extends Net_SSH2 /** * Max SFTP Packet Size * - * @see Net_SFTP::__construct() - * @see Net_SFTP::get() + * @see \phpseclib\Net\SFTP::__construct() + * @see \phpseclib\Net\SFTP::get() * @var Array * @access private */ @@ -219,8 +216,8 @@ class Net_SFTP extends Net_SSH2 /** * Stat Cache Flag * - * @see Net_SFTP::disableStatCache() - * @see Net_SFTP::enableStatCache() + * @see \phpseclib\Net\SFTP::disableStatCache() + * @see \phpseclib\Net\SFTP::enableStatCache() * @var Boolean * @access private */ @@ -229,8 +226,8 @@ class Net_SFTP extends Net_SSH2 /** * Sort Options * - * @see Net_SFTP::_comparator() - * @see Net_SFTP::setListOrder() + * @see \phpseclib\Net\SFTP::_comparator() + * @see \phpseclib\Net\SFTP::setListOrder() * @var Array * @access private */ @@ -244,7 +241,7 @@ class Net_SFTP extends Net_SSH2 * @param String $host * @param optional Integer $port * @param optional Integer $timeout - * @return Net_SFTP + * @return \phpseclib\Net\SFTP * @access public */ function __construct($host, $port = 22, $timeout = 10) @@ -325,7 +322,7 @@ class Net_SFTP extends Net_SSH2 31 => 'NET_SFTP_STATUS_NO_MATCHING_BYTE_RANGE_LOCK' ); // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-7.1 - // the order, in this case, matters quite a lot - see Net_SFTP::_parseAttributes() to understand why + // the order, in this case, matters quite a lot - see \phpseclib\Net\SFTP::_parseAttributes() to understand why $this->attributes = array( 0x00000001 => 'NET_SFTP_ATTR_SIZE', 0x00000002 => 'NET_SFTP_ATTR_UIDGID', // defined in SFTPv3, removed in SFTPv4+ @@ -349,7 +346,7 @@ class Net_SFTP extends Net_SSH2 0x00000020 => 'NET_SFTP_OPEN_EXCL' ); // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-5.2 - // see Net_SFTP::_parseLongname() for an explanation + // see \phpseclib\Net\SFTP::_parseLongname() for an explanation $this->file_types = array( 1 => 'NET_SFTP_TYPE_REGULAR', 2 => 'NET_SFTP_TYPE_DIRECTORY', @@ -495,7 +492,7 @@ class Net_SFTP extends Net_SSH2 So what do you do if you have a client whose initial SSH_FXP_INIT packet says it implements v3 and a server whose initial SSH_FXP_VERSION reply says it implements v4 and only v4? If it only implements v4, the "versions" extension is likely not going to have been sent so version re-negotiation as discussed - in draft-ietf-secsh-filexfer-13 would be quite impossible. As such, what Net_SFTP would do is close the + in draft-ietf-secsh-filexfer-13 would be quite impossible. As such, what \phpseclib\Net\SFTP would do is close the channel and reopen it with a new and updated SSH_FXP_INIT packet. */ switch ($this->version) { @@ -583,7 +580,7 @@ class Net_SFTP extends Net_SSH2 * SFTP doesn't provide a mechanism by which the current working directory can be changed, so we'll emulate it. Returns * the absolute (canonicalized) path. * - * @see Net_SFTP::chdir() + * @see \phpseclib\Net\SFTP::chdir() * @param String $path * @return Mixed * @access private @@ -646,7 +643,7 @@ class Net_SFTP extends Net_SSH2 */ function chdir($dir) { - if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) { + if (!($this->bitmap & SSH2::MASK_LOGIN)) { return false; } @@ -675,7 +672,7 @@ class Net_SFTP extends Net_SSH2 return false; } - // see Net_SFTP::nlist() for a more thorough explanation of the following + // see \phpseclib\Net\SFTP::nlist() for a more thorough explanation of the following $response = $this->_get_sftp_packet(); switch ($this->packet_type) { case NET_SFTP_HANDLE: @@ -792,7 +789,7 @@ class Net_SFTP extends Net_SSH2 */ function _list($dir, $raw = true) { - if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) { + if (!($this->bitmap & SSH2::MASK_LOGIN)) { return false; } @@ -1001,7 +998,7 @@ class Net_SFTP extends Net_SSH2 */ function size($filename) { - if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) { + if (!($this->bitmap & SSH2::MASK_LOGIN)) { return false; } @@ -1097,7 +1094,7 @@ class Net_SFTP extends Net_SSH2 */ function stat($filename) { - if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) { + if (!($this->bitmap & SSH2::MASK_LOGIN)) { return false; } @@ -1154,7 +1151,7 @@ class Net_SFTP extends Net_SSH2 */ function lstat($filename) { - if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) { + if (!($this->bitmap & SSH2::MASK_LOGIN)) { return false; } @@ -1211,7 +1208,7 @@ class Net_SFTP extends Net_SSH2 /** * Returns general information about a file or symbolic link * - * Determines information without calling Net_SFTP::_realpath(). + * Determines information without calling \phpseclib\Net\SFTP::_realpath(). * The second parameter can be either NET_SFTP_STAT or NET_SFTP_LSTAT. * * @param String $filename @@ -1268,7 +1265,7 @@ class Net_SFTP extends Net_SSH2 */ function touch($filename, $time = null, $atime = null) { - if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) { + if (!($this->bitmap & SSH2::MASK_LOGIN)) { return false; } @@ -1405,7 +1402,7 @@ class Net_SFTP extends Net_SSH2 */ function _setstat($filename, $attr, $recursive) { - if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) { + if (!($this->bitmap & SSH2::MASK_LOGIN)) { return false; } @@ -1532,7 +1529,7 @@ class Net_SFTP extends Net_SSH2 */ function readlink($link) { - if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) { + if (!($this->bitmap & SSH2::MASK_LOGIN)) { return false; } @@ -1576,7 +1573,7 @@ class Net_SFTP extends Net_SSH2 */ function symlink($target, $link) { - if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) { + if (!($this->bitmap & SSH2::MASK_LOGIN)) { return false; } @@ -1612,7 +1609,7 @@ class Net_SFTP extends Net_SSH2 */ function mkdir($dir, $mode = -1, $recursive = false) { - if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) { + if (!($this->bitmap & SSH2::MASK_LOGIN)) { return false; } @@ -1675,7 +1672,7 @@ class Net_SFTP extends Net_SSH2 */ function rmdir($dir) { - if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) { + if (!($this->bitmap & SSH2::MASK_LOGIN)) { return false; } @@ -1713,8 +1710,8 @@ class Net_SFTP extends Net_SSH2 /** * Uploads a file to the SFTP server. * - * By default, Net_SFTP::put() does not read from the local filesystem. $data is dumped directly into $remote_file. - * So, for example, if you set $data to 'filename.ext' and then do Net_SFTP::get(), you will get a file, twelve bytes + * By default, \phpseclib\Net\SFTP::put() does not read from the local filesystem. $data is dumped directly into $remote_file. + * So, for example, if you set $data to 'filename.ext' and then do \phpseclib\Net\SFTP::get(), you will get a file, twelve bytes * long, containing 'filename.ext' as its contents. * * Setting $mode to self::SOURCE_LOCAL_FILE will change the above behavior. With self::SOURCE_LOCAL_FILE, $remote_file will @@ -1750,11 +1747,11 @@ class Net_SFTP extends Net_SSH2 * @param optional Integer $local_start * @return Boolean * @access public - * @internal ASCII mode for SFTPv4/5/6 can be supported by adding a new function - Net_SFTP::setMode(). + * @internal ASCII mode for SFTPv4/5/6 can be supported by adding a new function - \phpseclib\Net\SFTP::setMode(). */ function put($remote_file, $data, $mode = self::SOURCE_STRING, $start = -1, $local_start = -1) { - if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) { + if (!($this->bitmap & SSH2::MASK_LOGIN)) { return false; } @@ -1953,7 +1950,7 @@ class Net_SFTP extends Net_SSH2 */ function get($remote_file, $local_file = false, $offset = 0, $length = -1) { - if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) { + if (!($this->bitmap & SSH2::MASK_LOGIN)) { return false; } @@ -2067,7 +2064,7 @@ class Net_SFTP extends Net_SSH2 */ function delete($path, $recursive = true) { - if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) { + if (!($this->bitmap & SSH2::MASK_LOGIN)) { return false; } @@ -2382,7 +2379,7 @@ class Net_SFTP extends Net_SSH2 */ function rename($oldname, $newname) { - if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) { + if (!($this->bitmap & SSH2::MASK_LOGIN)) { return false; } @@ -2557,8 +2554,8 @@ class Net_SFTP extends Net_SSH2 * * @param Integer $type * @param String $data - * @see Net_SFTP::_get_sftp_packet() - * @see Net_SSH2::_send_channel_packet() + * @see \phpseclib\Net\SFTP::_get_sftp_packet() + * @see \phpseclib\Net\SSH2::_send_channel_packet() * @return Boolean * @access private */ @@ -2599,7 +2596,7 @@ class Net_SFTP extends Net_SSH2 * There can be one SSH_MSG_CHANNEL_DATA messages containing two SFTP packets or there can be two SSH_MSG_CHANNEL_DATA * messages containing one SFTP packet. * - * @see Net_SFTP::_send_sftp_packet() + * @see \phpseclib\Net\SFTP::_send_sftp_packet() * @return String * @access private */ diff --git a/phpseclib/Net/SFTP/Stream.php b/phpseclib/Net/SFTP/Stream.php index 84c97aea..0ad0d88a 100644 --- a/phpseclib/Net/SFTP/Stream.php +++ b/phpseclib/Net/SFTP/Stream.php @@ -8,21 +8,25 @@ * PHP version 5 * * @category Net - * @package Net_SFTP_Stream + * @package SFTP * @author Jim Wigginton * @copyright 2013 Jim Wigginton * @license http://www.opensource.org/licenses/mit-license.html MIT License * @link http://phpseclib.sourceforge.net */ +namespace phpseclib\Net\SFTP; + +use phpseclib\Net\SFTP; + /** * SFTP Stream Wrapper * - * @package Net_SFTP_Stream + * @package SFTP * @author Jim Wigginton * @access public */ -class Net_SFTP_Stream +class Stream { /** * SFTP instances @@ -133,10 +137,6 @@ class Net_SFTP_Stream if (defined('NET_SFTP_STREAM_LOGGING')) { echo "__construct()\r\n"; } - - if (!class_exists('Net_SFTP')) { - include_once 'Net/SFTP.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) != 'phpseclib\Net\SFTP') { return false; } $this->sftp = $$host; @@ -183,7 +183,7 @@ class Net_SFTP_Stream if (isset($context[$scheme]['sftp'])) { $sftp = $context[$scheme]['sftp']; } - if (isset($sftp) && is_object($sftp) && get_class($sftp) == 'Net_SFTP') { + if (isset($sftp) && is_object($sftp) && get_class($sftp) == 'phpseclib\Net\SFTP') { $this->sftp = $sftp; return $path; } @@ -205,7 +205,7 @@ class Net_SFTP_Stream if (isset(self::$instances[$host][$port][$user][(string) $pass])) { $this->sftp = self::$instances[$host][$port][$user][(string) $pass]; } else { - $this->sftp = new Net_SFTP($host, $port); + $this->sftp = new SFTP($host, $port); $this->sftp->disableStatCache(); if (isset($this->notification) && is_callable($this->notification)) { /* if !is_callable($this->notification) we could do this: @@ -334,7 +334,7 @@ class Net_SFTP_Stream return false; } - $result = $this->sftp->put($this->path, $data, Net_SFTP::SOURCE_STRING, $this->pos); + $result = $this->sftp->put($this->path, $data, SFTP::SOURCE_STRING, $this->pos); if (isset($this->notification) && is_callable($this->notification)) { if (!$result) { call_user_func($this->notification, STREAM_NOTIFY_FAILURE, STREAM_NOTIFY_SEVERITY_ERR, $this->sftp->getLastSFTPError(), NET_SFTP_OPEN, 0, 0); @@ -474,7 +474,7 @@ class Net_SFTP_Stream * Renames a file or directory * * Attempts to rename oldname to newname, moving it between directories if necessary. - * If newname exists, it will be overwritten. This is a departure from what Net_SFTP + * If newname exists, it will be overwritten. This is a departure from what \phpseclib\Net\SFTP * does. * * @param String $path_from @@ -630,7 +630,7 @@ class Net_SFTP_Stream /** * Flushes the output * - * See . Always returns true because Net_SFTP doesn't cache stuff before writing + * See . Always returns true because \phpseclib\Net\SFTP doesn't cache stuff before writing * * @return Boolean * @access public @@ -675,7 +675,7 @@ class Net_SFTP_Stream /** * Retrieve information about a file * - * Ignores the STREAM_URL_STAT_QUIET flag because the entirety of Net_SFTP_Stream is quiet by default + * Ignores the STREAM_URL_STAT_QUIET flag because the entirety of \phpseclib\Net\SFTP\Stream is quiet by default * might be worthwhile to reconstruct bits 12-16 (ie. the file type) if mode doesn't have them but we'll * cross that bridge when and if it's reached * @@ -722,7 +722,7 @@ class Net_SFTP_Stream * Change stream options * * STREAM_OPTION_WRITE_BUFFER isn't supported for the same reason stream_flush isn't. - * The other two aren't supported because of limitations in Net_SFTP. + * The other two aren't supported because of limitations in \phpseclib\Net\SFTP. * * @param Integer $option * @param Integer $arg1 diff --git a/phpseclib/Net/SSH1.php b/phpseclib/Net/SSH1.php index dd81b92f..94392aea 100644 --- a/phpseclib/Net/SSH1.php +++ b/phpseclib/Net/SSH1.php @@ -8,9 +8,9 @@ * Here's a short example of how to use this library: * * login('username', 'password')) { * exit('Login Failed'); * } @@ -22,9 +22,9 @@ * Here's another short example: * * login('username', 'password')) { * exit('Login Failed'); * } @@ -39,29 +39,36 @@ * {@link http://www.snailbook.com/docs/protocol-1.5.txt protocol-1.5.txt}. * * @category Net - * @package Net_SSH1 + * @package SSH1 * @author Jim Wigginton * @copyright 2007 Jim Wigginton * @license http://www.opensource.org/licenses/mit-license.html MIT License * @link http://phpseclib.sourceforge.net */ -use \phpseclib\Crypt\Random; -use \phpseclib\Math\BigInteger; +namespace phpseclib\Net; + +// These should be removed once the Crypt package is fully namespaced +use Crypt_DES; +use Crypt_TripleDES; +// End unnecessary Use Statements + +use phpseclib\Crypt\Random; +use phpseclib\Math\BigInteger; /** * Pure-PHP implementation of SSHv1. * - * @package Net_SSH1 + * @package SSH1 * @author Jim Wigginton * @access public */ -class Net_SSH1 +class SSH1 { /**#@+ * Encryption Methods * - * @see Net_SSH1::getSupportedCiphers() + * @see \phpseclib\Net\SSH1::getSupportedCiphers() * @access public */ /** @@ -121,7 +128,7 @@ class Net_SSH1 /**#@+ * Authentication Methods * - * @see Net_SSH1::getSupportedAuthentications() + * @see \phpseclib\Net\SSH1::getSupportedAuthentications() * @access public */ /** @@ -156,7 +163,7 @@ class Net_SSH1 /** * The Response Type * - * @see Net_SSH1::_get_binary_packet() + * @see \phpseclib\Net\SSH1::_get_binary_packet() * @access private */ const RESPONSE_TYPE = 1; @@ -164,7 +171,7 @@ class Net_SSH1 /** * The Response Data * - * @see Net_SSH1::_get_binary_packet() + * @see \phpseclib\Net\SSH1::_get_binary_packet() * @access private */ const RESPONSE_DATA = 2; @@ -172,7 +179,7 @@ class Net_SSH1 /**#@+ * Execution Bitmap Masks * - * @see Net_SSH1::bitmap + * @see \phpseclib\Net\SSH1::bitmap * @access private */ const MASK_CONSTRUCTOR = 0x00000001; @@ -183,7 +190,7 @@ class Net_SSH1 /**#@+ * @access public - * @see Net_SSH1::getLog() + * @see \phpseclib\Net\SSH1::getLog() */ /** * Returns the message numbers @@ -205,7 +212,7 @@ class Net_SSH1 /**#@+ * @access public - * @see Net_SSH1::read() + * @see \phpseclib\Net\SSH1::read() */ /** * Returns when a string matching $expect exactly is found @@ -257,7 +264,7 @@ class Net_SSH1 * * Logged for debug purposes * - * @see Net_SSH1::getServerKeyPublicExponent() + * @see \phpseclib\Net\SSH1::getServerKeyPublicExponent() * @var String * @access private */ @@ -268,7 +275,7 @@ class Net_SSH1 * * Logged for debug purposes * - * @see Net_SSH1::getServerKeyPublicModulus() + * @see \phpseclib\Net\SSH1::getServerKeyPublicModulus() * @var String * @access private */ @@ -279,7 +286,7 @@ class Net_SSH1 * * Logged for debug purposes * - * @see Net_SSH1::getHostKeyPublicExponent() + * @see \phpseclib\Net\SSH1::getHostKeyPublicExponent() * @var String * @access private */ @@ -290,7 +297,7 @@ class Net_SSH1 * * Logged for debug purposes * - * @see Net_SSH1::getHostKeyPublicModulus() + * @see \phpseclib\Net\SSH1::getHostKeyPublicModulus() * @var String * @access private */ @@ -301,7 +308,7 @@ class Net_SSH1 * * Logged for debug purposes * - * @see Net_SSH1::getSupportedCiphers() + * @see \phpseclib\Net\SSH1::getSupportedCiphers() * @var Array * @access private */ @@ -320,7 +327,7 @@ class Net_SSH1 * * Logged for debug purposes * - * @see Net_SSH1::getSupportedAuthentications() + * @see \phpseclib\Net\SSH1::getSupportedAuthentications() * @var Array * @access private */ @@ -334,7 +341,7 @@ class Net_SSH1 /** * Server Identification * - * @see Net_SSH1::getServerIdentification() + * @see \phpseclib\Net\SSH1::getServerIdentification() * @var String * @access private */ @@ -343,7 +350,7 @@ class Net_SSH1 /** * Protocol Flags * - * @see Net_SSH1::__construct() + * @see \phpseclib\Net\SSH1::__construct() * @var Array * @access private */ @@ -352,7 +359,7 @@ class Net_SSH1 /** * Protocol Flag Log * - * @see Net_SSH1::getLog() + * @see \phpseclib\Net\SSH1::getLog() * @var Array * @access private */ @@ -361,7 +368,7 @@ class Net_SSH1 /** * Message Log * - * @see Net_SSH1::getLog() + * @see \phpseclib\Net\SSH1::getLog() * @var Array * @access private */ @@ -370,7 +377,7 @@ class Net_SSH1 /** * Real-time log file pointer * - * @see Net_SSH1::_append_log() + * @see \phpseclib\Net\SSH1::_append_log() * @var Resource * @access private */ @@ -379,7 +386,7 @@ class Net_SSH1 /** * Real-time log file size * - * @see Net_SSH1::_append_log() + * @see \phpseclib\Net\SSH1::_append_log() * @var Integer * @access private */ @@ -388,7 +395,7 @@ class Net_SSH1 /** * Real-time log file wrap boolean * - * @see Net_SSH1::_append_log() + * @see \phpseclib\Net\SSH1::_append_log() * @var Boolean * @access private */ @@ -397,7 +404,7 @@ class Net_SSH1 /** * Interactive Buffer * - * @see Net_SSH1::read() + * @see \phpseclib\Net\SSH1::read() * @var Array * @access private */ @@ -406,7 +413,7 @@ class Net_SSH1 /** * Timeout * - * @see Net_SSH1::setTimeout() + * @see \phpseclib\Net\SSH1::setTimeout() * @access private */ var $timeout; @@ -414,7 +421,7 @@ class Net_SSH1 /** * Current Timeout * - * @see Net_SSH1::_get_channel_packet() + * @see \phpseclib\Net\SSH1::_get_channel_packet() * @access private */ var $curTimeout; @@ -422,7 +429,7 @@ class Net_SSH1 /** * Log Boundary * - * @see Net_SSH1::_format_log + * @see \phpseclib\Net\SSH1::_format_log * @access private */ var $log_boundary = ':'; @@ -430,7 +437,7 @@ class Net_SSH1 /** * Log Long Width * - * @see Net_SSH1::_format_log + * @see \phpseclib\Net\SSH1::_format_log * @access private */ var $log_long_width = 65; @@ -438,7 +445,7 @@ class Net_SSH1 /** * Log Short Width * - * @see Net_SSH1::_format_log + * @see \phpseclib\Net\SSH1::_format_log * @access private */ var $log_short_width = 16; @@ -446,8 +453,8 @@ class Net_SSH1 /** * Hostname * - * @see Net_SSH1::__construct() - * @see Net_SSH1::_connect() + * @see \phpseclib\Net\SSH1::__construct() + * @see \phpseclib\Net\SSH1::_connect() * @var String * @access private */ @@ -456,8 +463,8 @@ class Net_SSH1 /** * Port Number * - * @see Net_SSH1::__construct() - * @see Net_SSH1::_connect() + * @see \phpseclib\Net\SSH1::__construct() + * @see \phpseclib\Net\SSH1::_connect() * @var Integer * @access private */ @@ -471,8 +478,8 @@ class Net_SSH1 * however, is non-optional. There will be a timeout, whether or not you set it. If you don't it'll be * 10 seconds. It is used by fsockopen() in that function. * - * @see Net_SSH1::__construct() - * @see Net_SSH1::_connect() + * @see \phpseclib\Net\SSH1::__construct() + * @see \phpseclib\Net\SSH1::_connect() * @var Integer * @access private */ @@ -481,8 +488,8 @@ class Net_SSH1 /** * Default cipher * - * @see Net_SSH1::__construct() - * @see Net_SSH1::_connect() + * @see \phpseclib\Net\SSH1::__construct() + * @see \phpseclib\Net\SSH1::_connect() * @var Integer * @access private */ @@ -497,7 +504,7 @@ class Net_SSH1 * @param optional Integer $port * @param optional Integer $timeout * @param optional Integer $cipher - * @return Net_SSH1 + * @return \phpseclib\Net\SSH1 * @access public */ function __construct($host, $port = 22, $timeout = 10, $cipher = self::CIPHER_3DES) @@ -789,12 +796,12 @@ class Net_SSH1 * {@link http://www.faqs.org/docs/bashman/bashref_65.html http://www.faqs.org/docs/bashman/bashref_65.html} * {@link http://www.faqs.org/docs/bashman/bashref_62.html http://www.faqs.org/docs/bashman/bashref_62.html} * - * To execute further commands, a new Net_SSH1 object will need to be created. + * To execute further commands, a new \phpseclib\Net\SSH1 object will need to be created. * * Returns false on failure and the output, otherwise. * - * @see Net_SSH1::interactiveRead() - * @see Net_SSH1::interactiveWrite() + * @see \phpseclib\Net\SSH1::interactiveRead() + * @see \phpseclib\Net\SSH1::interactiveWrite() * @param String $cmd * @return mixed * @access public @@ -834,7 +841,7 @@ class Net_SSH1 fclose($this->fsock); - // reset the execution bitmap - a new Net_SSH1 object needs to be created. + // reset the execution bitmap - a new \phpseclib\Net\SSH1 object needs to be created. $this->bitmap = 0; return $output; @@ -843,8 +850,8 @@ class Net_SSH1 /** * Creates an interactive shell * - * @see Net_SSH1::interactiveRead() - * @see Net_SSH1::interactiveWrite() + * @see \phpseclib\Net\SSH1::interactiveRead() + * @see \phpseclib\Net\SSH1::interactiveWrite() * @return Boolean * @access private */ @@ -887,7 +894,7 @@ class Net_SSH1 /** * Inputs a command into an interactive shell. * - * @see Net_SSH1::interactiveWrite() + * @see \phpseclib\Net\SSH1::interactiveWrite() * @param String $cmd * @return Boolean * @access public @@ -903,7 +910,7 @@ class Net_SSH1 * $expect can take the form of a string literal or, if $mode == self::READ__REGEX, * a regular expression. * - * @see Net_SSH1::write() + * @see \phpseclib\Net\SSH1::write() * @param String $expect * @param Integer $mode * @return Boolean @@ -943,7 +950,7 @@ class Net_SSH1 /** * Inputs a command into an interactive shell. * - * @see Net_SSH1::interactiveRead() + * @see \phpseclib\Net\SSH1::interactiveRead() * @param String $cmd * @return Boolean * @access public @@ -979,7 +986,7 @@ class Net_SSH1 * does not support ANSI escape sequences in Win32 Console applications", so if you're a Windows user, * there's not going to be much recourse. * - * @see Net_SSH1::interactiveRead() + * @see \phpseclib\Net\SSH1::interactiveRead() * @return String * @access public */ @@ -1068,7 +1075,7 @@ class Net_SSH1 * Also, this function could be improved upon by adding detection for the following exploit: * http://www.securiteam.com/securitynews/5LP042K3FY.html * - * @see Net_SSH1::_send_binary_packet() + * @see \phpseclib\Net\SSH1::_send_binary_packet() * @return Array * @access private */ @@ -1143,7 +1150,7 @@ class Net_SSH1 * * Returns true on success, false on failure. * - * @see Net_SSH1::_get_binary_packet() + * @see \phpseclib\Net\SSH1::_get_binary_packet() * @param String $data * @return Boolean * @access private @@ -1190,8 +1197,8 @@ class Net_SSH1 * we've reimplemented it. A more detailed discussion of the differences can be found after * $crc_lookup_table's initialization. * - * @see Net_SSH1::_get_binary_packet() - * @see Net_SSH1::_send_binary_packet() + * @see \phpseclib\Net\SSH1::_get_binary_packet() + * @see \phpseclib\Net\SSH1::_send_binary_packet() * @param String $data * @return Integer * @access private @@ -1307,7 +1314,7 @@ class Net_SSH1 * should be a number with the property that gcd($e, ($p - 1) * ($q - 1)) == 1. Could just make anything that * calls this call modexp, instead, but I think this makes things clearer, maybe... * - * @see Net_SSH1::__construct() + * @see \phpseclib\Net\SSH1::__construct() * @param BigInteger $m * @param Array $key * @return BigInteger diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index b298df1e..80bf6d48 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -8,9 +8,9 @@ * Here are some examples of how to use this library: * * login('username', 'password')) { * exit('Login Failed'); * } @@ -23,13 +23,13 @@ * * setPassword('whatever'); * $key->loadKey(file_get_contents('privatekey')); * - * $ssh = new Net_SSH2('www.domain.tld'); + * $ssh = new \phpseclib\Net\SSH2('www.domain.tld'); * if (!$ssh->login('username', $key)) { * exit('Login Failed'); * } @@ -41,30 +41,42 @@ * * * @category Net - * @package Net_SSH2 + * @package SSH2 * @author Jim Wigginton * @copyright 2007 Jim Wigginton * @license http://www.opensource.org/licenses/mit-license.html MIT License * @link http://phpseclib.sourceforge.net */ -use \phpseclib\Crypt\Random; +namespace phpseclib\Net; + +// These should be removed once the Crypt package is fully namespaced +use Crypt_Blowfish; +use Crypt_Hash; +use Crypt_RC4; +use Crypt_Rijndael; +use Crypt_RSA; +use Crypt_TripleDES; +use Crypt_Twofish; +// End unnecessary Use Statements + +use phpseclib\Crypt\Random; // Used to do Diffie-Hellman key exchange and DSA/RSA signature verification. -use \phpseclib\Math\BigInteger; +use phpseclib\Math\BigInteger; /** * Pure-PHP implementation of SSHv2. * - * @package Net_SSH2 + * @package SSH2 * @author Jim Wigginton * @access public */ -class Net_SSH2 +class SSH2 { /**#@+ * Execution Bitmap Masks * - * @see Net_SSH2::bitmap + * @see \phpseclib\Net\SSH2::bitmap * @access private */ const MASK_CONSTRUCTOR = 0x00000001; @@ -87,8 +99,8 @@ class Net_SSH2 * open request, and 'sender channel' is the channel number allocated by * the other side. * - * @see Net_SSH2::_send_channel_packet() - * @see Net_SSH2::_get_channel_packet() + * @see \phpseclib\Net\SSH2::_send_channel_packet() + * @see \phpseclib\Net\SSH2::_get_channel_packet() * @access private */ const CHANNEL_EXEC = 0; // PuTTy uses 0x100 @@ -98,7 +110,7 @@ class Net_SSH2 /**#@+ * @access public - * @see Net_SSH2::getLog() + * @see \phpseclib\Net\SSH2::getLog() */ /** * Returns the message numbers @@ -120,7 +132,7 @@ class Net_SSH2 /**#@+ * @access public - * @see Net_SSH2::read() + * @see \phpseclib\Net\SSH2::read() */ /** * Returns when a string matching $expect exactly is found @@ -166,8 +178,8 @@ class Net_SSH2 /** * Error information * - * @see Net_SSH2::getErrors() - * @see Net_SSH2::getLastError() + * @see \phpseclib\Net\SSH2::getErrors() + * @see \phpseclib\Net\SSH2::getLastError() * @var String * @access private */ @@ -176,7 +188,7 @@ class Net_SSH2 /** * Server Identifier * - * @see Net_SSH2::getServerIdentification() + * @see \phpseclib\Net\SSH2::getServerIdentification() * @var mixed false or Array * @access private */ @@ -185,7 +197,7 @@ class Net_SSH2 /** * Key Exchange Algorithms * - * @see Net_SSH2::getKexAlgorithims() + * @see \phpseclib\Net\SSH2::getKexAlgorithims() * @var mixed false or Array * @access private */ @@ -194,7 +206,7 @@ class Net_SSH2 /** * Server Host Key Algorithms * - * @see Net_SSH2::getServerHostKeyAlgorithms() + * @see \phpseclib\Net\SSH2::getServerHostKeyAlgorithms() * @var mixed false or Array * @access private */ @@ -203,7 +215,7 @@ class Net_SSH2 /** * Encryption Algorithms: Client to Server * - * @see Net_SSH2::getEncryptionAlgorithmsClient2Server() + * @see \phpseclib\Net\SSH2::getEncryptionAlgorithmsClient2Server() * @var mixed false or Array * @access private */ @@ -212,7 +224,7 @@ class Net_SSH2 /** * Encryption Algorithms: Server to Client * - * @see Net_SSH2::getEncryptionAlgorithmsServer2Client() + * @see \phpseclib\Net\SSH2::getEncryptionAlgorithmsServer2Client() * @var mixed false or Array * @access private */ @@ -221,7 +233,7 @@ class Net_SSH2 /** * MAC Algorithms: Client to Server * - * @see Net_SSH2::getMACAlgorithmsClient2Server() + * @see \phpseclib\Net\SSH2::getMACAlgorithmsClient2Server() * @var mixed false or Array * @access private */ @@ -230,7 +242,7 @@ class Net_SSH2 /** * MAC Algorithms: Server to Client * - * @see Net_SSH2::getMACAlgorithmsServer2Client() + * @see \phpseclib\Net\SSH2::getMACAlgorithmsServer2Client() * @var mixed false or Array * @access private */ @@ -239,7 +251,7 @@ class Net_SSH2 /** * Compression Algorithms: Client to Server * - * @see Net_SSH2::getCompressionAlgorithmsClient2Server() + * @see \phpseclib\Net\SSH2::getCompressionAlgorithmsClient2Server() * @var mixed false or Array * @access private */ @@ -248,7 +260,7 @@ class Net_SSH2 /** * Compression Algorithms: Server to Client * - * @see Net_SSH2::getCompressionAlgorithmsServer2Client() + * @see \phpseclib\Net\SSH2::getCompressionAlgorithmsServer2Client() * @var mixed false or Array * @access private */ @@ -257,7 +269,7 @@ class Net_SSH2 /** * Languages: Server to Client * - * @see Net_SSH2::getLanguagesServer2Client() + * @see \phpseclib\Net\SSH2::getLanguagesServer2Client() * @var mixed false or Array * @access private */ @@ -266,7 +278,7 @@ class Net_SSH2 /** * Languages: Client to Server * - * @see Net_SSH2::getLanguagesClient2Server() + * @see \phpseclib\Net\SSH2::getLanguagesClient2Server() * @var mixed false or Array * @access private */ @@ -282,8 +294,8 @@ class Net_SSH2 * * -- http://tools.ietf.org/html/rfc4253#section-6 * - * @see Net_SSH2::__construct() - * @see Net_SSH2::_send_binary_packet() + * @see \phpseclib\Net\SSH2::__construct() + * @see \phpseclib\Net\SSH2::_send_binary_packet() * @var Integer * @access private */ @@ -292,8 +304,8 @@ class Net_SSH2 /** * Block Size for Client to Server Encryption * - * @see Net_SSH2::__construct() - * @see Net_SSH2::_get_binary_packet() + * @see \phpseclib\Net\SSH2::__construct() + * @see \phpseclib\Net\SSH2::_get_binary_packet() * @var Integer * @access private */ @@ -302,7 +314,7 @@ class Net_SSH2 /** * Server to Client Encryption Object * - * @see Net_SSH2::_get_binary_packet() + * @see \phpseclib\Net\SSH2::_get_binary_packet() * @var Object * @access private */ @@ -311,7 +323,7 @@ class Net_SSH2 /** * Client to Server Encryption Object * - * @see Net_SSH2::_send_binary_packet() + * @see \phpseclib\Net\SSH2::_send_binary_packet() * @var Object * @access private */ @@ -320,7 +332,7 @@ class Net_SSH2 /** * Client to Server HMAC Object * - * @see Net_SSH2::_send_binary_packet() + * @see \phpseclib\Net\SSH2::_send_binary_packet() * @var Object * @access private */ @@ -329,7 +341,7 @@ class Net_SSH2 /** * Server to Client HMAC Object * - * @see Net_SSH2::_get_binary_packet() + * @see \phpseclib\Net\SSH2::_get_binary_packet() * @var Object * @access private */ @@ -342,7 +354,7 @@ class Net_SSH2 * For the client to server side, the HMAC object will make the HMAC as long as it needs to be. All we need to do is * append it. * - * @see Net_SSH2::_get_binary_packet() + * @see \phpseclib\Net\SSH2::_get_binary_packet() * @var Integer * @access private */ @@ -351,7 +363,7 @@ class Net_SSH2 /** * Server Public Host Key * - * @see Net_SSH2::getServerPublicHostKey() + * @see \phpseclib\Net\SSH2::getServerPublicHostKey() * @var String * @access private */ @@ -366,7 +378,7 @@ class Net_SSH2 * * -- http://tools.ietf.org/html/rfc4253#section-7.2 * - * @see Net_SSH2::_key_exchange() + * @see \phpseclib\Net\SSH2::_key_exchange() * @var String * @access private */ @@ -377,7 +389,7 @@ class Net_SSH2 * * The current exchange hash * - * @see Net_SSH2::_key_exchange() + * @see \phpseclib\Net\SSH2::_key_exchange() * @var String * @access private */ @@ -386,7 +398,7 @@ class Net_SSH2 /** * Message Numbers * - * @see Net_SSH2::__construct() + * @see \phpseclib\Net\SSH2::__construct() * @var Array * @access private */ @@ -395,7 +407,7 @@ class Net_SSH2 /** * Disconnection Message 'reason codes' defined in RFC4253 * - * @see Net_SSH2::__construct() + * @see \phpseclib\Net\SSH2::__construct() * @var Array * @access private */ @@ -404,7 +416,7 @@ class Net_SSH2 /** * SSH_MSG_CHANNEL_OPEN_FAILURE 'reason codes', defined in RFC4254 * - * @see Net_SSH2::__construct() + * @see \phpseclib\Net\SSH2::__construct() * @var Array * @access private */ @@ -414,7 +426,7 @@ class Net_SSH2 * Terminal Modes * * @link http://tools.ietf.org/html/rfc4254#section-8 - * @see Net_SSH2::__construct() + * @see \phpseclib\Net\SSH2::__construct() * @var Array * @access private */ @@ -424,7 +436,7 @@ class Net_SSH2 * SSH_MSG_CHANNEL_EXTENDED_DATA's data_type_codes * * @link http://tools.ietf.org/html/rfc4254#section-5.2 - * @see Net_SSH2::__construct() + * @see \phpseclib\Net\SSH2::__construct() * @var Array * @access private */ @@ -435,7 +447,7 @@ class Net_SSH2 * * See 'Section 6.4. Data Integrity' of rfc4253 for more info. * - * @see Net_SSH2::_send_binary_packet() + * @see \phpseclib\Net\SSH2::_send_binary_packet() * @var Integer * @access private */ @@ -446,7 +458,7 @@ class Net_SSH2 * * See 'Section 6.4. Data Integrity' of rfc4253 for more info. * - * @see Net_SSH2::_get_binary_packet() + * @see \phpseclib\Net\SSH2::_get_binary_packet() * @var Integer * @access private */ @@ -457,8 +469,8 @@ class Net_SSH2 * * Maps client channels to server channels * - * @see Net_SSH2::_get_channel_packet() - * @see Net_SSH2::exec() + * @see \phpseclib\Net\SSH2::_get_channel_packet() + * @see \phpseclib\Net\SSH2::exec() * @var Array * @access private */ @@ -470,8 +482,8 @@ class Net_SSH2 * If a client requests a packet from one channel but receives two packets from another those packets should * be placed in a buffer * - * @see Net_SSH2::_get_channel_packet() - * @see Net_SSH2::exec() + * @see \phpseclib\Net\SSH2::_get_channel_packet() + * @see \phpseclib\Net\SSH2::exec() * @var Array * @access private */ @@ -482,7 +494,7 @@ class Net_SSH2 * * Contains the type of the last sent message * - * @see Net_SSH2::_get_channel_packet() + * @see \phpseclib\Net\SSH2::_get_channel_packet() * @var Array * @access private */ @@ -493,7 +505,7 @@ class Net_SSH2 * * Maximum packet size indexed by channel * - * @see Net_SSH2::_send_channel_packet() + * @see \phpseclib\Net\SSH2::_send_channel_packet() * @var Array * @access private */ @@ -502,7 +514,7 @@ class Net_SSH2 /** * Message Number Log * - * @see Net_SSH2::getLog() + * @see \phpseclib\Net\SSH2::getLog() * @var Array * @access private */ @@ -511,7 +523,7 @@ class Net_SSH2 /** * Message Log * - * @see Net_SSH2::getLog() + * @see \phpseclib\Net\SSH2::getLog() * @var Array * @access private */ @@ -523,8 +535,8 @@ class Net_SSH2 * Bytes the other party can send before it must wait for the window to be adjusted (0x7FFFFFFF = 2GB) * * @var Integer - * @see Net_SSH2::_send_channel_packet() - * @see Net_SSH2::exec() + * @see \phpseclib\Net\SSH2::_send_channel_packet() + * @see \phpseclib\Net\SSH2::exec() * @access private */ var $window_size = 0x7FFFFFFF; @@ -534,7 +546,7 @@ class Net_SSH2 * * Window size indexed by channel * - * @see Net_SSH2::_send_channel_packet() + * @see \phpseclib\Net\SSH2::_send_channel_packet() * @var Array * @access private */ @@ -545,7 +557,7 @@ class Net_SSH2 * * Window size indexed by channel * - * @see Net_SSH2::_get_channel_packet() + * @see \phpseclib\Net\SSH2::_get_channel_packet() * @var Array * @access private */ @@ -556,7 +568,7 @@ class Net_SSH2 * * Verified against $this->session_id * - * @see Net_SSH2::getServerPublicHostKey() + * @see \phpseclib\Net\SSH2::getServerPublicHostKey() * @var String * @access private */ @@ -567,7 +579,7 @@ class Net_SSH2 * * ssh-rsa or ssh-dss. * - * @see Net_SSH2::getServerPublicHostKey() + * @see \phpseclib\Net\SSH2::getServerPublicHostKey() * @var String * @access private */ @@ -576,7 +588,7 @@ class Net_SSH2 /** * Interactive Buffer * - * @see Net_SSH2::read() + * @see \phpseclib\Net\SSH2::read() * @var Array * @access private */ @@ -587,8 +599,8 @@ class Net_SSH2 * * Should never exceed self::LOG_MAX_SIZE * - * @see Net_SSH2::_send_binary_packet() - * @see Net_SSH2::_get_binary_packet() + * @see \phpseclib\Net\SSH2::_send_binary_packet() + * @see \phpseclib\Net\SSH2::_get_binary_packet() * @var Integer * @access private */ @@ -597,7 +609,7 @@ class Net_SSH2 /** * Timeout * - * @see Net_SSH2::setTimeout() + * @see \phpseclib\Net\SSH2::setTimeout() * @access private */ var $timeout; @@ -605,7 +617,7 @@ class Net_SSH2 /** * Current Timeout * - * @see Net_SSH2::_get_channel_packet() + * @see \phpseclib\Net\SSH2::_get_channel_packet() * @access private */ var $curTimeout; @@ -613,7 +625,7 @@ class Net_SSH2 /** * Real-time log file pointer * - * @see Net_SSH2::_append_log() + * @see \phpseclib\Net\SSH2::_append_log() * @var Resource * @access private */ @@ -622,7 +634,7 @@ class Net_SSH2 /** * Real-time log file size * - * @see Net_SSH2::_append_log() + * @see \phpseclib\Net\SSH2::_append_log() * @var Integer * @access private */ @@ -631,7 +643,7 @@ class Net_SSH2 /** * Has the signature been validated? * - * @see Net_SSH2::getServerPublicHostKey() + * @see \phpseclib\Net\SSH2::getServerPublicHostKey() * @var Boolean * @access private */ @@ -640,7 +652,7 @@ class Net_SSH2 /** * Real-time log file wrap boolean * - * @see Net_SSH2::_append_log() + * @see \phpseclib\Net\SSH2::_append_log() * @access private */ var $realtime_log_wrap; @@ -648,7 +660,7 @@ class Net_SSH2 /** * Flag to suppress stderr from output * - * @see Net_SSH2::enableQuietMode() + * @see \phpseclib\Net\SSH2::enableQuietMode() * @access private */ var $quiet_mode = false; @@ -673,7 +685,7 @@ class Net_SSH2 * Flag to request a PTY when using exec() * * @var Boolean - * @see Net_SSH2::enablePTY() + * @see \phpseclib\Net\SSH2::enablePTY() * @access private */ var $request_pty = false; @@ -705,7 +717,7 @@ class Net_SSH2 /** * The Last Interactive Response * - * @see Net_SSH2::_keyboard_interactive_process() + * @see \phpseclib\Net\SSH2::_keyboard_interactive_process() * @var String * @access private */ @@ -714,7 +726,7 @@ class Net_SSH2 /** * Keyboard Interactive Request / Responses * - * @see Net_SSH2::_keyboard_interactive_process() + * @see \phpseclib\Net\SSH2::_keyboard_interactive_process() * @var Array * @access private */ @@ -726,8 +738,8 @@ class Net_SSH2 * Quoting from the RFC, "in some jurisdictions, sending a warning message before * authentication may be relevant for getting legal protection." * - * @see Net_SSH2::_filter() - * @see Net_SSH2::getBannerMessage() + * @see \phpseclib\Net\SSH2::_filter() + * @see \phpseclib\Net\SSH2::getBannerMessage() * @var String * @access private */ @@ -736,7 +748,7 @@ class Net_SSH2 /** * Did read() timeout or return normally? * - * @see Net_SSH2::isTimeout() + * @see \phpseclib\Net\SSH2::isTimeout() * @var Boolean * @access private */ @@ -745,7 +757,7 @@ class Net_SSH2 /** * Log Boundary * - * @see Net_SSH2::_format_log() + * @see \phpseclib\Net\SSH2::_format_log() * @var String * @access private */ @@ -754,7 +766,7 @@ class Net_SSH2 /** * Log Long Width * - * @see Net_SSH2::_format_log() + * @see \phpseclib\Net\SSH2::_format_log() * @var Integer * @access private */ @@ -763,7 +775,7 @@ class Net_SSH2 /** * Log Short Width * - * @see Net_SSH2::_format_log() + * @see \phpseclib\Net\SSH2::_format_log() * @var Integer * @access private */ @@ -772,8 +784,8 @@ class Net_SSH2 /** * Hostname * - * @see Net_SSH2::__construct() - * @see Net_SSH2::_connect() + * @see \phpseclib\Net\SSH2::__construct() + * @see \phpseclib\Net\SSH2::_connect() * @var String * @access private */ @@ -782,8 +794,8 @@ class Net_SSH2 /** * Port Number * - * @see Net_SSH2::__construct() - * @see Net_SSH2::_connect() + * @see \phpseclib\Net\SSH2::__construct() + * @see \phpseclib\Net\SSH2::_connect() * @var Integer * @access private */ @@ -797,8 +809,8 @@ class Net_SSH2 * however, is non-optional. There will be a timeout, whether or not you set it. If you don't it'll be * 10 seconds. It is used by fsockopen() and the initial stream_select in that function. * - * @see Net_SSH2::__construct() - * @see Net_SSH2::_connect() + * @see \phpseclib\Net\SSH2::__construct() + * @see \phpseclib\Net\SSH2::_connect() * @var Integer * @access private */ @@ -807,9 +819,9 @@ class Net_SSH2 /** * Number of columns for terminal window size * - * @see Net_SSH2::getWindowColumns() - * @see Net_SSH2::setWindowColumns() - * @see Net_SSH2::setWindowSize() + * @see \phpseclib\Net\SSH2::getWindowColumns() + * @see \phpseclib\Net\SSH2::setWindowColumns() + * @see \phpseclib\Net\SSH2::setWindowSize() * @var Integer * @access private */ @@ -818,9 +830,9 @@ class Net_SSH2 /** * Number of columns for terminal window size * - * @see Net_SSH2::getWindowRows() - * @see Net_SSH2::setWindowRows() - * @see Net_SSH2::setWindowSize() + * @see \phpseclib\Net\SSH2::getWindowRows() + * @see \phpseclib\Net\SSH2::setWindowRows() + * @see \phpseclib\Net\SSH2::setWindowSize() * @var Integer * @access private */ @@ -832,8 +844,8 @@ class Net_SSH2 * @param String $host * @param optional Integer $port * @param optional Integer $timeout - * @see Net_SSH2::login() - * @return Net_SSH2 + * @see \phpseclib\Net\SSH2::login() + * @return \phpseclib\Net\SSH2 * @access public */ function __construct($host, $port = 22, $timeout = 10) @@ -2237,7 +2249,7 @@ class Net_SSH2 /** * Execute Command * - * If $callback is set to false then Net_SSH2::_get_channel_packet(self::CHANNEL_EXEC) will need to be called manually. + * If $callback is set to false then \phpseclib\Net\SSH2::_get_channel_packet(self::CHANNEL_EXEC) will need to be called manually. * In all likelihood, this is not a feature you want to be taking advantage of. * * @param String $command @@ -2307,7 +2319,7 @@ class Net_SSH2 } // sending a pty-req SSH_MSG_CHANNEL_REQUEST message is unnecessary and, in fact, in most cases, slows things - // down. the one place where it might be desirable is if you're doing something like Net_SSH2::exec('ping localhost &'). + // down. the one place where it might be desirable is if you're doing something like \phpseclib\Net\SSH2::exec('ping localhost &'). // with a pty-req SSH_MSG_CHANNEL_REQUEST, exec() will return immediately and the ping process will then // then immediately terminate. without such a request exec() will loop indefinitely. the ping process won't end but // neither will your script. @@ -2358,8 +2370,8 @@ class Net_SSH2 /** * Creates an interactive shell * - * @see Net_SSH2::read() - * @see Net_SSH2::write() + * @see \phpseclib\Net\SSH2::read() + * @see \phpseclib\Net\SSH2::write() * @return Boolean * @access private */ @@ -2436,8 +2448,8 @@ class Net_SSH2 /** * Return the channel to be used with read() / write() * - * @see Net_SSH2::read() - * @see Net_SSH2::write() + * @see \phpseclib\Net\SSH2::read() + * @see \phpseclib\Net\SSH2::write() * @return Integer * @access public */ @@ -2459,7 +2471,7 @@ class Net_SSH2 * Returns when there's a match for $expect, which can take the form of a string literal or, * if $mode == self::READ_REGEX, a regular expression. * - * @see Net_SSH2::write() + * @see \phpseclib\Net\SSH2::write() * @param String $expect * @param Integer $mode * @return String @@ -2505,7 +2517,7 @@ class Net_SSH2 /** * Inputs a command into an interactive shell. * - * @see Net_SSH2::read() + * @see \phpseclib\Net\SSH2::read() * @param String $cmd * @return Boolean * @access public @@ -2534,7 +2546,7 @@ class Net_SSH2 * returns that and then that that was passed into stopSubsystem() but that'll be saved for a future date and implemented * if there's sufficient demand for such a feature. * - * @see Net_SSH2::stopSubsystem() + * @see \phpseclib\Net\SSH2::stopSubsystem() * @param String $subsystem * @return Boolean * @access public @@ -2582,7 +2594,7 @@ class Net_SSH2 /** * Stops a subsystem. * - * @see Net_SSH2::startSubsystem() + * @see \phpseclib\Net\SSH2::startSubsystem() * @return Boolean * @access public */ @@ -2659,7 +2671,7 @@ class Net_SSH2 * * See '6. Binary Packet Protocol' of rfc4253 for more info. * - * @see Net_SSH2::_send_binary_packet() + * @see \phpseclib\Net\SSH2::_send_binary_packet() * @return String * @access private */ @@ -2752,7 +2764,7 @@ class Net_SSH2 * * Because some binary packets need to be ignored... * - * @see Net_SSH2::_get_binary_packet() + * @see \phpseclib\Net\SSH2::_get_binary_packet() * @return String * @access private */ @@ -2865,8 +2877,8 @@ class Net_SSH2 /** * Returns whether Quiet Mode is enabled or not * - * @see Net_SSH2::enableQuietMode() - * @see Net_SSH2::disableQuietMode() + * @see \phpseclib\Net\SSH2::enableQuietMode() + * @see \phpseclib\Net\SSH2::disableQuietMode() * * @access public * @return boolean @@ -2899,8 +2911,8 @@ class Net_SSH2 /** * Returns whether request-pty is enabled or not * - * @see Net_SSH2::enablePTY() - * @see Net_SSH2::disablePTY() + * @see \phpseclib\Net\SSH2::enablePTY() + * @see \phpseclib\Net\SSH2::disablePTY() * * @access public * @return boolean @@ -3109,7 +3121,7 @@ class Net_SSH2 * * @param String $data * @param optional String $logged - * @see Net_SSH2::_get_binary_packet() + * @see \phpseclib\Net\SSH2::_get_binary_packet() * @return Boolean * @access private */ @@ -3287,7 +3299,7 @@ class Net_SSH2 /** * Closes and flushes a channel * - * Net_SSH2 doesn't properly close most channels. For exec() channels are normally closed by the server + * \phpseclib\Net\SSH2 doesn't properly close most channels. For exec() channels are normally closed by the server * and for SFTP channels are presumably closed when the client disconnects. This functions is intended * for SCP more than anything. * diff --git a/phpseclib/System/SSH/Agent.php b/phpseclib/System/SSH/Agent.php index c4c79918..c597b386 100644 --- a/phpseclib/System/SSH/Agent.php +++ b/phpseclib/System/SSH/Agent.php @@ -8,11 +8,11 @@ * * login('username', $agent)) { * exit('Login Failed'); * } diff --git a/tests/Functional/Net/SCPSSH2UserStoryTest.php b/tests/Functional/Net/SCPSSH2UserStoryTest.php index 295e982f..6abd7e5f 100644 --- a/tests/Functional/Net/SCPSSH2UserStoryTest.php +++ b/tests/Functional/Net/SCPSSH2UserStoryTest.php @@ -6,6 +6,9 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +use phpseclib\Net\SCP; +use phpseclib\Net\SSH2; + class Functional_Net_SCPSSH2UserStoryTest extends PhpseclibFunctionalTestCase { static protected $remoteFile; @@ -22,7 +25,7 @@ class Functional_Net_SCPSSH2UserStoryTest extends PhpseclibFunctionalTestCase public function testConstructSSH2() { - $ssh = new Net_SSH2($this->getEnv('SSH_HOSTNAME')); + $ssh = new SSH2($this->getEnv('SSH_HOSTNAME')); $this->assertTrue( $ssh->login( $this->getEnv('SSH_USERNAME'), @@ -32,18 +35,24 @@ class Functional_Net_SCPSSH2UserStoryTest extends PhpseclibFunctionalTestCase return $ssh; } - /** @depends testConstructSSH2 */ + /** + * @depends testConstructSSH2 + * @param \phpseclib\Net\SSH2 $ssh + */ public function testConstructor($ssh) { - $scp = new Net_SCP($ssh); + $scp = new SCP($ssh); $this->assertTrue( is_object($scp), - 'Could not construct Net_SCP object.' + 'Could not construct \phpseclib\Net\SCP object.' ); return $scp; } - /** @depends testConstructor */ + /** + * @depends testConstructor + * @param \phpseclib\Net\SCP $scp + */ public function testPutGetString($scp) { $this->assertTrue( @@ -65,7 +74,10 @@ class Functional_Net_SCPSSH2UserStoryTest extends PhpseclibFunctionalTestCase return $scp; } - /** @depends testPutGetString */ + /** + * @depends testPutGetString + * @param \phpseclib\Net\SCP $scp + */ public function testGetFile($scp) { $localFilename = $this->createTempFile(); diff --git a/tests/Functional/Net/SFTPLargeFileTest.php b/tests/Functional/Net/SFTPLargeFileTest.php index 0e58ea7b..f875e799 100644 --- a/tests/Functional/Net/SFTPLargeFileTest.php +++ b/tests/Functional/Net/SFTPLargeFileTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +use phpseclib\Net\SFTP; + class Functional_Net_SFTPLargeFileTest extends PhpseclibFunctionalTestCase { protected $sftp; @@ -30,7 +32,7 @@ class Functional_Net_SFTPLargeFileTest extends PhpseclibFunctionalTestCase { $this->scratchDir = uniqid('phpseclib-sftp-large-scratch-'); - $this->sftp = new Net_SFTP($this->getEnv('SSH_HOSTNAME')); + $this->sftp = new SFTP($this->getEnv('SSH_HOSTNAME')); $this->assertTrue($this->sftp->login( $this->getEnv('SSH_USERNAME'), $this->getEnv('SSH_PASSWORD') @@ -59,7 +61,7 @@ class Functional_Net_SFTPLargeFileTest extends PhpseclibFunctionalTestCase $filename = 'file-large-from-local.txt'; $this->assertTrue( - $this->sftp->put($filename, $tmp_filename, Net_SFTP::SOURCE_LOCAL_FILE), + $this->sftp->put($filename, $tmp_filename, SFTP::SOURCE_LOCAL_FILE), 'Failed asserting that local file could be successfully put().' ); diff --git a/tests/Functional/Net/SFTPUserStoryTest.php b/tests/Functional/Net/SFTPUserStoryTest.php index 707bc9ad..aa03edaf 100644 --- a/tests/Functional/Net/SFTPUserStoryTest.php +++ b/tests/Functional/Net/SFTPUserStoryTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +use phpseclib\Net\SFTP; + class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase { static protected $scratchDir; @@ -30,7 +32,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase public function testConstructor() { - $sftp = new Net_SFTP($this->getEnv('SSH_HOSTNAME')); + $sftp = new SFTP($this->getEnv('SSH_HOSTNAME')); $this->assertTrue( is_object($sftp), diff --git a/tests/Functional/Net/SSH2AgentTest.php b/tests/Functional/Net/SSH2AgentTest.php index e8dc4403..ea10110e 100644 --- a/tests/Functional/Net/SSH2AgentTest.php +++ b/tests/Functional/Net/SSH2AgentTest.php @@ -6,6 +6,7 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +use phpseclib\Net\SSH2; use phpseclib\System\SSH\Agent; class Functional_Net_SSH2AgentTest extends PhpseclibFunctionalTestCase @@ -22,7 +23,7 @@ class Functional_Net_SSH2AgentTest extends PhpseclibFunctionalTestCase public function testAgentLogin() { - $ssh = new Net_SSH2($this->getEnv('SSH_HOSTNAME')); + $ssh = new SSH2($this->getEnv('SSH_HOSTNAME')); $agent = new Agent; $this->assertTrue( diff --git a/tests/Functional/Net/SSH2Test.php b/tests/Functional/Net/SSH2Test.php index 4b7d552a..185e6453 100644 --- a/tests/Functional/Net/SSH2Test.php +++ b/tests/Functional/Net/SSH2Test.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +use phpseclib\Net\SSH2; + class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase { public function setUp() @@ -20,7 +22,7 @@ class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase public function testConstructor() { - $ssh = new Net_SSH2($this->getEnv('SSH_HOSTNAME')); + $ssh = new SSH2($this->getEnv('SSH_HOSTNAME')); $this->assertTrue( is_object($ssh), @@ -91,7 +93,7 @@ class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase public function testGetServerPublicHostKey() { - $ssh = new Net_SSH2($this->getEnv('SSH_HOSTNAME')); + $ssh = new SSH2($this->getEnv('SSH_HOSTNAME')); $this->assertInternalType('string', $ssh->getServerPublicHostKey()); } diff --git a/tests/Unit/Net/SFTPStreamTest.php b/tests/Unit/Net/SFTPStreamTest.php index e90075fc..6f98bb0c 100644 --- a/tests/Unit/Net/SFTPStreamTest.php +++ b/tests/Unit/Net/SFTPStreamTest.php @@ -5,11 +5,13 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +use phpseclib\Net\SFTP\Stream; + class Unit_Net_SFTPStreamTest extends PhpseclibTestCase { public function testRegisterWithoutArgument() { - $this->assertTrue(Net_SFTP_Stream::register()); + $this->assertTrue(Stream::register()); $this->assertContains('sftp', stream_get_wrappers()); $this->assertTrue(stream_wrapper_unregister('sftp')); } @@ -17,7 +19,7 @@ class Unit_Net_SFTPStreamTest extends PhpseclibTestCase public function testRegisterWithArgument() { $protocol = 'sftptest'; - $this->assertTrue(Net_SFTP_Stream::register($protocol)); + $this->assertTrue(Stream::register($protocol)); $this->assertContains($protocol, stream_get_wrappers()); $this->assertTrue(stream_wrapper_unregister($protocol)); } diff --git a/tests/Unit/Net/SSH1Test.php b/tests/Unit/Net/SSH1Test.php index b0b2aaed..6073e1ff 100644 --- a/tests/Unit/Net/SSH1Test.php +++ b/tests/Unit/Net/SSH1Test.php @@ -29,7 +29,7 @@ class Unit_Net_SSH1Test extends PhpseclibTestCase */ public function testFormatLog(array $message_log, array $message_number_log, $expected) { - $ssh = $this->getMockBuilder('Net_SSH1') + $ssh = $this->getMockBuilder('phpseclib\Net\SSH1') ->disableOriginalConstructor() ->setMethods(null) ->getMock(); diff --git a/tests/Unit/Net/SSH2Test.php b/tests/Unit/Net/SSH2Test.php index d166ae45..a16b6b47 100644 --- a/tests/Unit/Net/SSH2Test.php +++ b/tests/Unit/Net/SSH2Test.php @@ -102,11 +102,11 @@ class Unit_Net_SSH2Test extends PhpseclibTestCase } /** - * @return Net_SSH2 + * @return \phpseclib\Net\SSH2 */ protected function createSSHMock() { - return $this->getMockBuilder('Net_SSH2') + return $this->getMockBuilder('phpseclib\Net\SSH2') ->disableOriginalConstructor() ->setMethods(array('__destruct')) ->getMock();