PHP Class phpseclib\Net\SCP

Author: Jim Wigginton ([email protected])
Show file Open project: phpseclib/phpseclib Class Usage Examples

Public Properties

Property Type Description
$mode integer Mode
$packet_size integer Packet Size
$ssh object SSH Object

Public Methods

Method Description
__construct ( SSH1 | SSH2 $ssh ) : SCP Default Constructor.
_close ( ) Closes the connection to an SSH server
_receive ( ) : string Receives a packet from an SSH server
_send ( string $data ) Sends a packet to an SSH server
get ( string $remote_file, string $local_file = false ) : mixed Downloads a file from the SCP server.
put ( string $remote_file, string $data, integer $mode = self::SOURCE_STRING, callable $callback = null ) : boolean Uploads a file to the SCP server.

Method Details

__construct() public method

Connects to an SSH server
public __construct ( SSH1 | SSH2 $ssh ) : SCP
$ssh SSH1 | SSH2
return SCP

_close() public method

Closes the connection to an SSH server
public _close ( )

_receive() public method

Receives a packet from an SSH server
public _receive ( ) : string
return string

_send() public method

Sends a packet to an SSH server
public _send ( string $data )
$data string

get() public method

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
public get ( string $remote_file, string $local_file = false ) : mixed
$remote_file string
$local_file string
return mixed

put() public method

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 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.
public put ( string $remote_file, string $data, integer $mode = self::SOURCE_STRING, callable $callback = null ) : boolean
$remote_file string
$data string
$mode integer
$callback callable
return boolean

Property Details

$mode public property

Mode
public int $mode
return integer

$packet_size public property

Packet Size
public int $packet_size
return integer

$ssh public property

SSH Object
public object $ssh
return object