class JFTP extends JObject


Located at : UKNOWVA_ROOT/libraries/joomla/client/ftp.php

FTP client class

Properties

resource $_conn
resource $_dataconn
array $_pasv
string $_response
integer $_timeout
integer $_type
string $_OS
array $_autoAscii
array $_lineEndings Array to hold native line ending characters

Methods

__construct(array $options = array())

JFTP object constructor

string
__toString()

Magic method to convert the object to a string gracefully.

from JObject
mixed
def(string $property, mixed $default = null)

Sets a default value if not alreay assigned

from JObject
mixed
get(string $local, string $remote)

Method to get a file from the FTP server and save it to a local file

array
getProperties(boolean $public = true)

Returns an associative array of object properties.

from JObject
string
getError(integer $i = null, boolean $toString = true)

Get the most recent error message.

from JObject
array
getErrors()

Return all errors, if any.

from JObject
mixed
set(string $property, mixed $value = null)

Modifies a property of the object, creating it if it does not already exist.

from JObject
boolean
setProperties(mixed $properties)

Set the object properties based on a named array/hash.

from JObject
void
setError(string $error)

Add an error message.

from JObject
string
toString() deprecated

No description

from JObject
void
__destruct()

JFTP object destructor

getInstance(string $host = '127.0.0.1', string $port = '21', array $options = null, string $user = null, string $pass = null)

Returns the global FTP connector object, only creating it if it doesn't already exist.

boolean
setOptions(array $options)

Set client options

boolean
connect(string $host = '127.0.0.1', string $port = 21)

Method to connect to a FTP server

boolean
isConnected()

Method to determine if the object is connected to an FTP server

boolean
login(string $user = 'anonymous', string $pass = 'jftp@joomla.org')

Method to login to a server once connected

boolean
quit()

Method to quit and close the connection

string
pwd()

Method to retrieve the current working directory on the FTP server

string
syst()

Method to system string from the FTP server

boolean
chdir(string $path)

Method to change the current working directory on the FTP server

boolean
reinit()

Method to reinitialise the server, ie. need to login again

boolean
rename(string $from, string $to)

Method to rename a file/folder on the FTP server

boolean
chmod(string $path, mixed $mode)

Method to change mode for a path on the FTP server

boolean
delete(string $path)

Method to delete a path [file/folder] on the FTP server

boolean
mkdir(string $path)

Method to create a directory on the FTP server

boolean
restart(integer $point)

Method to restart data transfer at a given byte

boolean
create(string $path)

Method to create an empty file on the FTP server

boolean
read(string $remote, string $buffer)

Method to read a file from the FTP server's contents into a buffer

boolean
store(string $local, string $remote = null)

Method to store a file to the FTP server

boolean
write(string $remote, string $buffer)

Method to write a string to the FTP server

string
listNames(string $path = null)

Method to list the filenames of the contents of a directory on the FTP server

mixed
listDetails($path = null, $type = 'all')

Method to list the contents of a directory on the FTP server

boolean
_putCmd(string $cmd, mixed $expectedResponse)

Send command to the FTP server and validate an expected response code

boolean
_verifyResponse(mixed $expected)

Verify the response code from the server and log response if flag is set

boolean
_passive()

Set server to passive mode and open a data port connection

integer
_findMode(string $fileName)

Method to find out the correct transfer mode for a specific file

boolean
_mode(integer $mode)

Set transfer mode

Details

at line 123
JObject __construct(array $options = array())

JFTP object constructor

Parameters

array $options Associative array of options to set

Return Value

JObject

in JObject at line 56
string __toString()

Magic method to convert the object to a string gracefully.

Return Value

string The classname.

in JObject at line 70
mixed def(string $property, mixed $default = null)

Sets a default value if not alreay assigned

Parameters

string $property The name of the property.
mixed $default The default value.

Return Value

mixed

at line 768
mixed get(string $local, string $remote)

Method to get a file from the FTP server and save it to a local file

Parameters

string $local Local path to save remote file to
string $remote Path to remote file to get on the FTP server

Return Value

mixed The value of the property.

in JObject at line 107
array getProperties(boolean $public = true)

Returns an associative array of object properties.

Parameters

boolean $public If true, returns only the public properties.

Return Value

array

See also

get()

in JObject at line 133
string getError(integer $i = null, boolean $toString = true)

Get the most recent error message.

Parameters

integer $i Option error index.
boolean $toString Indicates if JError objects should return their error message.

Return Value

string Error message

in JObject at line 165
array getErrors()

Return all errors, if any.

Return Value

array Array of error messages or JErrors.

in JObject at line 180
mixed set(string $property, mixed $value = null)

Modifies a property of the object, creating it if it does not already exist.

Parameters

string $property The name of the property.
mixed $value The value of the property to set.

Return Value

mixed Previous value of the property.

in JObject at line 198
boolean setProperties(mixed $properties)

Set the object properties based on a named array/hash.

Parameters

mixed $properties Either an associative array or another object.

Return Value

boolean

See also

set()

in JObject at line 222
void setError(string $error)

Add an error message.

Parameters

string $error Error message.

Return Value

void

in JObject at line 235
string toString() deprecated

deprecated 12.1 Use magic method __toString()

Return Value

string

See also

__toString()

at line 156
void __destruct()

JFTP object destructor

Closes an existing connection, if we have one

Return Value

void

at line 180
JFTP getInstance(string $host = '127.0.0.1', string $port = '21', array $options = null, string $user = null, string $pass = null)

Returns the global FTP connector object, only creating it if it doesn't already exist.

You may optionally specify a username and password in the parameters. If you do so, you may not login() again with different credentials using the same object. If you do not use this option, you must quit() the current connection when you are done, to free it for use by others.

Parameters

string $host Host to connect to
string $port Port to connect to
array $options Array with any of these options: type=>[FTPAUTOASCII|FTPASCII|FTP_BINARY], timeout=>(int)
string $user Username to use for a connection
string $pass Password to use for a connection

Return Value

JFTP The FTP Client object.

at line 212
boolean setOptions(array $options)

Set client options

Parameters

array $options Associative array of options to set

Return Value

boolean True if successful

at line 232
boolean connect(string $host = '127.0.0.1', string $port = 21)

Method to connect to a FTP server

Parameters

string $host Host to connect to [Default: 127.0.0.1]
string $port Port to connect on [Default: port 21]

Return Value

boolean True if successful

at line 280
boolean isConnected()

Method to determine if the object is connected to an FTP server

Return Value

boolean True if connected

at line 294
boolean login(string $user = 'anonymous', string $pass = 'jftp@joomla.org')

Method to login to a server once connected

Parameters

string $user Username to login to the server
string $pass Password to login to the server

Return Value

boolean True if successful

at line 331
boolean quit()

Method to quit and close the connection

Return Value

boolean True if successful

at line 352
string pwd()

Method to retrieve the current working directory on the FTP server

Return Value

string Current working directory

at line 385
string syst()

Method to system string from the FTP server

Return Value

string System identifier string

at line 423
boolean chdir(string $path)

Method to change the current working directory on the FTP server

Parameters

string $path Path to change into on the server

Return Value

boolean True if successful

at line 451
boolean reinit()

Method to reinitialise the server, ie. need to login again

NOTE: This command not available on all servers

Return Value

boolean True if successful

at line 480
boolean rename(string $from, string $to)

Method to rename a file/folder on the FTP server

Parameters

string $from Path to change file/folder from
string $to Path to change file/folder to

Return Value

boolean True if successful

at line 515
boolean chmod(string $path, mixed $mode)

Method to change mode for a path on the FTP server

Parameters

string $path Path to change mode on
mixed $mode Octal value to change mode to, e.g. '0777', 0777 or 511 (string or integer)

Return Value

boolean True if successful

at line 556
boolean delete(string $path)

Method to delete a path [file/folder] on the FTP server

Parameters

string $path Path to delete

Return Value

boolean True if successful

at line 587
boolean mkdir(string $path)

Method to create a directory on the FTP server

Parameters

string $path Directory to create

Return Value

boolean True if successful

at line 614
boolean restart(integer $point)

Method to restart data transfer at a given byte

Parameters

integer $point Byte to restart transfer at

Return Value

boolean True if successful

at line 642
boolean create(string $path)

Method to create an empty file on the FTP server

Parameters

string $path Path local file to store on the FTP server

Return Value

boolean True if successful

at line 694
boolean read(string $remote, string $buffer)

Method to read a file from the FTP server's contents into a buffer

Parameters

string $remote Path to remote file to read on the FTP server
string $buffer Buffer variable to read file contents into

Return Value

boolean True if successful

at line 837
boolean store(string $local, string $remote = null)

Method to store a file to the FTP server

Parameters

string $local Path to local file to store on the FTP server
string $remote FTP path to file to create

Return Value

boolean True if successful

at line 924
boolean write(string $remote, string $buffer)

Method to write a string to the FTP server

Parameters

string $remote FTP path to file to write to
string $buffer Contents to write to the FTP server

Return Value

boolean True if successful

at line 997
string listNames(string $path = null)

Method to list the filenames of the contents of a directory on the FTP server

Note: Some servers also return folder names. However, to be sure to list folders on all servers, you should use listDetails() instead if you also need to deal with folders

Parameters

string $path Path local file to store on the FTP server

Return Value

string Directory listing

at line 1081
mixed listDetails($path = null, $type = 'all')

Method to list the contents of a directory on the FTP server

Parameters

$path
$type

Return Value

mixed If $type is raw: string Directory listing, otherwise array of string with file-names

at line 1280
boolean _putCmd(string $cmd, mixed $expectedResponse)

Send command to the FTP server and validate an expected response code

Parameters

string $cmd Command to send to the FTP server
mixed $expectedResponse Integer response code or array of integer response codes

Return Value

boolean True if command executed successfully

at line 1303
boolean _verifyResponse(mixed $expected)

Verify the response code from the server and log response if flag is set

Parameters

mixed $expected Integer response code or array of integer response codes

Return Value

boolean True if response code from the server is expected

at line 1348
boolean _passive()

Set server to passive mode and open a data port connection

Return Value

boolean True if successful

at line 1418
integer _findMode(string $fileName)

Method to find out the correct transfer mode for a specific file

Parameters

string $fileName Name of the file

Return Value

integer Transfer-mode for this filetype [FTPASCII|FTPBINARY]

at line 1445
boolean _mode(integer $mode)

Set transfer mode

Parameters

integer $mode Integer representation of data transfer mode [1:Binary|0:Ascii] Defined constants can also be used [FTPBINARY|FTPASCII]

Return Value

boolean True if successful