Blesta
  • Package
  • Class
  • Tree
  • Deprecated

Packages

  • blesta
    • app
      • components
        • events
          • default
      • controllers
      • models
    • components
      • auth
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • exchange
        • rates
          • foxrate
          • google
            • finance
          • yahoo
            • finance
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
      • json
      • modules
      • net
        • http
        • net
          • amazon
            • s3
          • geo
            • ip
      • plugins
      • recaptcha
      • security
      • session
        • cart
      • settingscollection
      • upgrades
      • upload
      • vcard
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
  • com
    • tecnick
      • tcpdf
        • blesta
          • components
            • invoice
              • templates
                • quickbooks
                  • invoice
                • templates
                  • default
  • Crypt
    • AES
    • DES
    • Hash
    • Random
    • RC4
    • Rijndael
    • RSA
    • TerraDES
  • File
    • ANSI
    • ASN1
    • X509
  • Math
    • BigInteger
  • minPHP
    • components
      • input
      • record
    • helpers
      • color
      • data
        • structure
      • date
      • html
      • xml
    • lib
  • Net
    • SFTP
    • SSH1
    • SSH2
  • None
  • PHP
  • PHPMailer
  • Services
    • JSON
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Net_SFTP

Class Net_SFTP

Pure-PHP implementations of SFTP.

Net_SSH2
Extended by Net_SFTP
Package: Net\SFTP
Copyright: MMIX Jim Wigginton
License: MIT License
Author: Jim Wigginton <terrafrost@php.net>
Version: 0.1.0
Located at vendors/phpseclib/Net/SFTP.php

Methods summary

public Net_SFTP
# Net_SFTP( String $host, optional $port = 22, optional $timeout = 10 )

Default Constructor.

Default Constructor.

Connects to an SFTP server

Parameters

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

Returns

Net_SFTP
public Boolean
# login( String $username, optional $password = '' )

Login

Login

Parameters

$username
String
$username
$password
optional
String $password

Returns

Boolean

Overrides

Net_SSH2::login
public Mixed
# pwd( )

Returns the current directory name

Returns the current directory name

Returns

Mixed
public Mixed
# _realpath( String $dir, optional $check_dir = true )

Canonicalize the Server-Side Path Name

Canonicalize the Server-Side Path Name

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. If $mode is set to NET_SFTP_CONFIRM_DIR (as opposed to NET_SFTP_CONFIRM_NONE, which is what it is set to by default), false is returned if $dir is not a valid directory.

Parameters

$dir
String
$dir
$check_dir
optional
Integer $mode

Returns

Mixed

See

Net_SFTP::chdir()
public Boolean
# chdir( String $dir )

Changes the current directory

Changes the current directory

Parameters

$dir
String
$dir

Returns

Boolean
public Mixed
# nlist( optional $dir = '.' )

Returns a list of files in the given directory

Returns a list of files in the given directory

Parameters

$dir
optional
String $dir

Returns

Mixed
public Mixed
# rawlist( optional $dir = '.' )

Returns a detailed list of files in the given directory

Returns a detailed list of files in the given directory

Parameters

$dir
optional
String $dir

Returns

Mixed
public Mixed
# _list( optional $dir, mixed $raw = true, mixed $realpath = true )

Reads a list, be it detailed or not, of files in the given directory

Reads a list, be it detailed or not, of files in the given directory

Parameters

$dir
optional
String $dir
$raw
$realpath

Returns

Mixed
public Mixed
# size( String $filename )

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

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

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

Parameters

$filename
String
$filename

Returns

Mixed
public
# _save_dir( String $dir )

Save directories to cache

Save directories to cache

Parameters

$dir
String
$dir
public
# _remove_dir( String $dir )

Remove directories from cache

Remove directories from cache

Parameters

$dir
String
$dir
public
# _is_dir( String $dir )

Checks cache for directory

Checks cache for directory

Parameters

$dir
String
$dir
public Mixed
# stat( String $filename )

Returns general information about a file.

Returns general information about a file.

Returns an array on success and false otherwise.

Parameters

$filename
String
$filename

Returns

Mixed
public Mixed
# lstat( String $filename )

Returns general information about a file or symbolic link.

Returns general information about a file or symbolic link.

Returns an array on success and false otherwise.

Parameters

$filename
String
$filename

Returns

Mixed
public Mixed
# _stat( String $filename, Integer $type )

Returns general information about a file or symbolic link

Returns general information about a file or symbolic link

Determines information without calling Net_SFTP::_realpath(). The second parameter can be either NET_SFTP_STAT or NET_SFTP_LSTAT.

Parameters

$filename
String
$filename
$type
Integer
$type

Returns

Mixed
public Integer
# _identify_type( String $path, Array $stat1, Array $stat2 )

Attempt to identify the file type

Attempt to identify the file type

Parameters

$path
String
$path
$stat1
Array
$stat
$stat2
Array
$lstat

Returns

Integer
public Mixed
# _size( String $filename )

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

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

Determines the size without calling Net_SFTP::_realpath()

Parameters

$filename
String
$filename

Returns

Mixed
public Mixed
# chmod( Integer $mode, String $filename, mixed $recursive = false )

Set permissions on a file.

Set permissions on a file.

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

Parameters

$mode
Integer
$mode
$filename
String
$filename
$recursive

Returns

Mixed
public Boolean
# _chmod_recursive( Integer $mode, String $path, mixed & $i )

Recursively chmods directories on the SFTP server

Recursively chmods directories on the SFTP server

Minimizes directory lookups and SSH_FXP_STATUS requests for speed.

Parameters

$mode
Integer
$mode
$path
String
$filename
$i

Returns

Boolean
public Boolean
# mkdir( String $dir )

Creates a directory.

Creates a directory.

Parameters

$dir
String
$dir

Returns

Boolean
public Boolean
# rmdir( String $dir )

Removes a directory.

Removes a directory.

Parameters

$dir
String
$dir

Returns

Boolean
public Boolean
# put( String $remote_file, String $data, optional $mode = NET_SFTP_STRING )

Uploads a file to the SFTP server.

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.

Parameters

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

Returns

Boolean
public Boolean
# _read_put_responses( Integer $i )

Reads multiple successive SSH_FXP_WRITE responses

Reads multiple successive SSH_FXP_WRITE responses

Sending an SSH_FXP_WRITE packet and immediately reading its response isn't as efficient as blindly sending out $i SSH_FXP_WRITEs, in succession, and then reading $i responses.

Parameters

$i
Integer
$i

Returns

Boolean
public Mixed
# get( String $remote_file, optional $local_file = false )

Downloads a file from the SFTP server.

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

Parameters

$remote_file
String
$remote_file
$local_file
optional
String $local_file

Returns

Mixed
public Boolean
# delete( String $path, Boolean $recursive = true )

Deletes a file on the SFTP server.

Deletes a file on the SFTP server.

Parameters

$path
String
$path
$recursive
Boolean
$recursive

Returns

Boolean
public Boolean
# _delete_recursive( String $path, Integer & $i )

Recursively deletes directories on the SFTP server

Recursively deletes directories on the SFTP server

Minimizes directory lookups and SSH_FXP_STATUS requests for speed.

Parameters

$path
String
$path
$i
Integer
$i

Returns

Boolean
public Boolean
# rename( String $oldname, String $newname )

Renames a file or a directory on the SFTP server

Renames a file or a directory on the SFTP server

Parameters

$oldname
String
$oldname
$newname
String
$newname

Returns

Boolean
public Array
# _parseAttributes( String & $response )

Parse Attributes

Parse Attributes

See '7. File Attributes' of draft-ietf-secsh-filexfer-13 for more info.

Parameters

$response
String
$response

Returns

Array
public Mixed
# _parseLongname( String $longname )

Parse Longname

Parse Longname

SFTPv3 doesn't provide any easy way of identifying a file type. You could try to open a file as a directory and see if an error is returned or you could try to parse the SFTPv3-specific longname field of the SSH_FXP_NAME packet. That's what this function does. The result is returned using the SFTPv4 type constants.

If the longname is in an unrecognized format bool(false) is returned.

Parameters

$longname
String
$longname

Returns

Mixed
public Boolean
# _send_sftp_packet( Integer $type, String $data )

Sends SFTP Packets

Sends SFTP Packets

See '6. General Packet Format' of draft-ietf-secsh-filexfer-13 for more info.

Parameters

$type
Integer
$type
$data
String
$data

Returns

Boolean

See

Net_SFTP::_get_sftp_packet()
Net_SSH2::_send_channel_packet()
public String
# _get_sftp_packet( )

Receives SFTP Packets

Receives SFTP Packets

See '6. General Packet Format' of draft-ietf-secsh-filexfer-13 for more info.

Incidentally, the number of SSH_MSG_CHANNEL_DATA messages has no bearing on the number of SFTP packets present. 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.

Returns

String

See

Net_SFTP::_send_sftp_packet()
public String
# getSFTPLog( )

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

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')

Returns

String
or Array
public String
# getSFTPErrors( )

Returns all errors

Returns all errors

Returns

String
public String
# getLastSFTPError( )

Returns the last error

Returns the last error

Returns

String
public Array
# getSupportedVersions( )

Get supported SFTP versions

Get supported SFTP versions

Returns

Array
public Boolean
# _disconnect( Integer $reason )

Disconnect

Disconnect

Parameters

$reason
Integer
$reason

Returns

Boolean

Overrides

Net_SSH2::_disconnect

Methods inherited from Net_SSH2

Net_SSH2(), __destruct(), _append_log(), _close_channel(), _define_array(), _filter(), _format_log(), _get_binary_packet(), _get_channel_packet(), _initShell(), _key_exchange(), _keyboard_interactive_login(), _keyboard_interactive_process(), _privatekey_login(), _send_binary_packet(), _send_channel_packet(), _string_shift(), disconnect(), exec(), getCompressionAlgorithmsClient2Server(), getCompressionAlgorithmsServer2Client(), getEncryptionAlgorithmsClient2Server(), getEncryptionAlgorithmsServer2Client(), getErrors(), getKexAlgorithms(), getLanguagesClient2Server(), getLanguagesServer2Client(), getLastError(), getLog(), getMACAlgorithmsClient2Server(), getMACAlgorithmsServer2Client(), getServerHostKeyAlgorithms(), getServerIdentification(), getServerPublicHostKey(), read(), setTimeout(), write()

Magic methods summary

Properties summary

public Array $packet_types
#

Packet Types

Packet Types

See

Net_SFTP::Net_SFTP()
public Array $status_codes
#

Status Codes

Status Codes

See

Net_SFTP::Net_SFTP()
public Integer $request_id
#

The Request ID

The Request ID

The request ID exists in the off chance that a packet is sent out-of-order. Of course, this library doesn't support concurrent actions, so it's somewhat academic, here.

See

Net_SFTP::_send_sftp_packet()
public Integer $packet_type
#

The Packet Type

The Packet Type

The request ID exists in the off chance that a packet is sent out-of-order. Of course, this library doesn't support concurrent actions, so it's somewhat academic, here.

See

Net_SFTP::_get_sftp_packet()
public String $packet_buffer
#

Packet Buffer

Packet Buffer

See

Net_SFTP::_get_sftp_packet()
public Array $extensions
#

Extensions supported by the server

Extensions supported by the server

See

Net_SFTP::_initChannel()
public Integer $version
#

Server SFTP version

Server SFTP version

See

Net_SFTP::_initChannel()
public String $pwd
#

Current working directory

Current working directory

See

Net_SFTP::_realpath()
Net_SFTP::chdir()
public Array $packet_type_log
#

Packet Type Log

Packet Type Log

See

Net_SSH2::getLog()
public Array $packet_log
#

Packet Log

Packet Log

See

Net_SSH2::getLog()
public String $sftp_errors
#

Error information

Error information

See

Net_SFTP::getSFTPErrors()
Net_SFTP::getLastSFTPError()
public Integer $fileType
#

File Type

File Type

See

Net_SFTP::_parseLongname()
public Array $dirs
#

Directory Cache

Directory Cache

Rather than always having to open a directory and close it immediately there after to see if a file is a directory or rather than always

See

Net_SFTP::_save_dir()
Net_SFTP::_remove_dir()
Net_SFTP::_is_dir()

Properties inherited from Net_SSH2

$bitmap, $channel_buffers, $channel_extended_data_type_codes, $channel_open_failure_reasons, $channel_status, $compression_algorithms_client_to_server, $compression_algorithms_server_to_client, $curTimeout, $decrypt, $decrypt_block_size, $disconnect_reasons, $encrypt, $encrypt_block_size, $encryption_algorithms_client_to_server, $encryption_algorithms_server_to_client, $errors, $exchange_hash, $fsock, $get_seq_no, $hmac_check, $hmac_create, $hmac_size, $identifier, $interactiveBuffer, $kex_algorithms, $languages_client_to_server, $languages_server_to_client, $log_size, $mac_algorithms_client_to_server, $mac_algorithms_server_to_client, $message_log, $message_number_log, $message_numbers, $packet_size_client_to_server, $realtime_log_file, $realtime_log_size, $realtime_log_wrap, $send_seq_no, $server_channels, $server_host_key_algorithms, $server_identifier, $server_public_host_key, $session_id, $signature, $signature_format, $signature_validated, $terminal_modes, $timeout, $window_size, $window_size_client_to_server

Blesta API documentation generated by ApiGen 2.8.0