Net_SFTP

# Class: Net_SFTP

Source Location: /lib/3rdParty/phpseclib/Net/SFTP.php

### Class Overview

    Net_SSH2
       |
       --Net_SFTP

Pure-PHP implementations of SFTP.

#### Author(s):

- Jim Wigginton <terrafrost@php.net>

#### Version:

- 0.1.0

### Methods

- Net_SFTP
- chdir
- chmod
- delete
- get
- getLastSFTPError
- getSFTPErrors
- getSFTPLog
- getSupportedVersions
- login
- lstat
- mkdir
- nlist
- put
- pwd
- rawlist
- rename
- rmdir
- size
- stat

### Inherited Methods

#### Class: Net_SSH2

Net_SSH2::Net_SSH2()
  Default Constructor.
Net_SSH2::disconnect()
  Disconnect
Net_SSH2::exec()
  Execute Command
Net_SSH2::getCompressionAlgorithmsClient2Server()
  Return a list of the compression algorithms the server supports, when receiving stuff from the client.
Net_SSH2::getCompressionAlgorithmsServer2Client()
  Return a list of the compression algorithms the server supports, when sending stuff to the client.
Net_SSH2::getEncryptionAlgorithmsClient2Server()
  Return a list of the (symmetric key) encryption algorithms the server supports, when receiving stuff from the client.
Net_SSH2::getEncryptionAlgorithmsServer2Client()
  Return a list of the (symmetric key) encryption algorithms the server supports, when sending stuff to the client.
Net_SSH2::getErrors()
  Returns all errors
Net_SSH2::getKexAlgorithms()
  Return a list of the key exchange algorithms the server supports.
Net_SSH2::getLanguagesClient2Server()
  Return a list of the languages the server supports, when receiving stuff from the client.
Net_SSH2::getLanguagesServer2Client()
  Return a list of the languages the server supports, when sending stuff to the client.
Net_SSH2::getLastError()
  Returns the last error
Net_SSH2::getLog()
  Returns a log of the packets that have been sent and received.
Net_SSH2::getMACAlgorithmsClient2Server()
  Return a list of the MAC algorithms the server supports, when receiving stuff from the client.
Net_SSH2::getMACAlgorithmsServer2Client()
  Return a list of the MAC algorithms the server supports, when sending stuff to the client.
Net_SSH2::getServerHostKeyAlgorithms()
  Return a list of the host key (public key) algorithms the server supports.
Net_SSH2::getServerIdentification()
  Return the server identification.
Net_SSH2::getServerPublicHostKey()
  Returns the server public host key.
Net_SSH2::login()
  Login
Net_SSH2::read()
  Returns the output of an interactive shell
Net_SSH2::write()
  Inputs a command into an interactive shell.
Net_SSH2::__destruct()
  Destructor.

### Class Details

[line 109]
Pure-PHP implementations of SFTP.

#### Tags:

author: | Jim Wigginton <terrafrost@php.net>
version: | 0.1.0
access: | public

[ Top ]

### Class Methods

### constructor Net_SFTP [line 237]

`Net_SFTP Net_SFTP( String $host, [optional $port = 22], [optional $timeout = 10])`

Default Constructor.

Connects to an SFTP server

#### Tags:

access: | public

#### Parameters:

String | $host |
optional | $port | Integer $port
optional | $timeout | Integer $timeout

[ Top ]

### method chdir [line 546]

`Boolean chdir( String $dir)`

Changes the current directory

#### Tags:

access: | public

#### Parameters:

String | $dir |

[ Top ]

### method chmod [line 862]

`Mixed chmod( Integer $mode, String $filename)`

Set permissions on a file.

Returns the new file permissions on success or FALSE on error.

#### Tags:

access: | public

#### Parameters:

Integer | $mode |
String | $filename |

[ Top ]

### method delete [line 1275]

`Boolean delete( String $path)`

Deletes a file on the SFTP server.

#### Tags:

access: | public

#### Parameters:

String | $path |

[ Top ]

### method get [line 1163]

`Mixed get( String $remote_file, [optional $local_file = false])`

Downloads a file from the SFTP server.

Returns a string containing the contents of $remote_file if $local_file is left undefined or a boolean false if the operation was unsuccessful. If $local_file is defined, returns true or false depending on the success of the operation

#### Tags:

access: | public

#### Parameters:

String | $remote_file |
optional | $local_file | String $local_file

[ Top ]

### method getLastSFTPError [line 1577]

`String getLastSFTPError( )`

Returns the last error

#### Tags:

access: | public

[ Top ]

### method getSFTPErrors [line 1566]

`String getSFTPErrors( )`

Returns all errors

#### Tags:

access: | public

[ Top ]

### method getSFTPLog [line 1544]

`String getSFTPLog( )`

Returns a log of the packets that have been sent and received.

Returns a string if NET_SFTP_LOGGING == NET_SFTP_LOG_COMPLEX, an array if NET_SFTP_LOGGING == NET_SFTP_LOG_SIMPLE and false if !defined('NET_SFTP_LOGGING')

#### Tags:

return: | or Array
access: | public

[ Top ]

### method getSupportedVersions [line 1588]

`Array getSupportedVersions( )`

Get supported SFTP versions

#### Tags:

access: | public

[ Top ]

### method login [line 333]

`Boolean login( String $username, [optional $password = ''])`

Login

#### Tags:

access: | public

Overrides Net_SSH2::login() (Login)

#### Parameters:

String | $username |
optional | $password | String $password

[ Top ]

### method lstat [line 786]

`Mixed lstat( String $filename)`

Returns general information about a file or symbolic link.

Returns an array on success and false otherwise.

#### Tags:

access: | public

#### Parameters:

String | $filename |

[ Top ]

### method mkdir [line 929]

`Boolean mkdir( String $dir)`

Creates a directory.

#### Tags:

access: | public

#### Parameters:

String | $dir |

[ Top ]

### method nlist [line 605]

`Mixed nlist( [optional $dir = '.'])`

Returns a list of files in the given directory

#### Tags:

access: | public

#### Parameters:

optional | $dir | String $dir

[ Top ]

### method put [line 1022]

`Boolean put( String $remote_file, String $data, [optional $mode = NET_SFTP_STRING])`

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 long, containing 'filename.ext' as its contents.

Setting $mode to NET_SFTP_LOCAL_FILE will change the above behavior. With NET_SFTP_LOCAL_FILE, $remote_file will contain as many bytes as filename.ext does on your local filesystem. If your filename.ext is 1MB then that is how large $remote_file will be, as well.

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.

#### Tags:

access: | public

#### Parameters:

String | $remote_file |
String | $data |
optional | $mode | Integer $mode

[ Top ]

### method pwd [line 444]

`Mixed pwd( )`

Returns the current directory name

#### Tags:

access: | public

[ Top ]

### method rawlist [line 617]

`Mixed rawlist( [optional $dir = '.'])`

Returns a detailed list of files in the given directory

#### Tags:

access: | public

#### Parameters:

optional | $dir | String $dir

[ Top ]

### method rename [line 1316]

`Boolean rename( String $oldname, String $newname)`

Renames a file or a directory on the SFTP server

#### Tags:

access: | public

#### Parameters:

String | $oldname |
String | $newname |

[ Top ]

### method rmdir [line 969]

`Boolean rmdir( String $dir)`

Removes a directory.

#### Tags:

access: | public

#### Parameters:

String | $dir |

[ Top ]

### method size [line 740]

`Mixed size( String $filename)`

Returns the file size, in bytes, or false, on failure

Files larger than 4GB will show up as being exactly 4GB.

#### Tags:

access: | public

#### Parameters:

String | $filename |

[ Top ]

### method stat [line 763]

`Mixed stat( String $filename)`

Returns general information about a file.

Returns an array on success and false otherwise.

#### Tags:

access: | public

#### Parameters:

String | $filename |

[ Top ]

Documentation generated on Tue, 22 Nov 2011 16:30:10 +0100 by phpDocumentor 1.4.1