Class JFTP

Description

FTP client class

  • since: 11.1

Located in /libraries/joomla/client/ftp.php (line 65)


	
			
Variable Summary
static array $instances
array $_autoAscii
resource $_conn
resource $_dataconn
string $_OS
array $_pasv
string $_response
integer $_timeout
integer $_type
Method Summary
JFTP __construct ([array $options = array()])
void __destruct ()
boolean chdir (string $path)
boolean chmod (string $path, mixed $mode)
boolean connect ([string $host = '127.0.0.1'], [string $port = 21])
boolean create (string $path)
boolean delete (string $path)
boolean get (string $local, string $remote)
JFTP getInstance ([string $host = '127.0.0.1'], [string $port = '21'], [array $options = null], [string $user = null], [string $pass = null])
boolean isConnected ()
mixed listDetails ([string $path = null], [string $type = 'all'])
string listNames ([string $path = null])
boolean login ([string $user = 'anonymous'], [string $pass = 'jftp@joomla.org'])
boolean mkdir (string $path)
string pwd ()
boolean quit ()
boolean read (string $remote, string &$buffer)
boolean reinit ()
boolean rename (string $from, string $to)
boolean restart (integer $point)
boolean setOptions (array $options)
boolean store (string $local, [string $remote = null])
string syst ()
boolean write (string $remote, string $buffer)
integer _findMode (string $fileName)
boolean _mode (integer $mode)
boolean _passive ()
boolean _putCmd (string $cmd, mixed $expectedResponse)
boolean _verifyResponse (mixed $expected)
Variables
static array $instances = array() (line 148)
  • var: JFTP instances container.
  • since: 11.3
  • access: protected
array $_autoAscii = array(
"asp",
"bat",
"c",
"cpp",
"csv",
"h",
"htm",
"html",
"shtml",
"ini",
"inc",
"log",
"php",
"php3",
"pl",
"perl",
"sh",
"sql",
"txt",
"xhtml",
"xml")
(line 113)
  • var: Array to hold ascii format file extensions
  • since: 11.1
  • access: private
resource $_conn = null (line 71)
  • var: Socket resource
  • since: 11.1
  • access: private
resource $_dataconn = null (line 77)
  • var: Data port connection resource
  • since: 11.1
  • access: private
array $_lineEndings = array('UNIX' => "\n", 'MAC' => "\r", 'WIN' => "\r\n") (line 142)

Array to hold native line ending characters

  • since: 11.1
  • access: private
string $_OS = null (line 107)
  • var: Native OS Type
  • since: 11.1
  • access: private
array $_pasv = null (line 83)
  • var: Passive connection information
  • since: 11.1
  • access: private
string $_response = null (line 89)
  • var: Response Message
  • since: 11.1
  • access: private
integer $_timeout = 15 (line 95)
  • var: Timeout limit
  • since: 11.1
  • access: private
integer $_type = null (line 101)
  • var: Transfer Type
  • since: 11.1
  • access: private
Methods
Constructor __construct (line 157)

JFTP object constructor

  • since: 11.1
  • access: public
JFTP __construct ([array $options = array()])
  • array $options: Associative array of options to set
Destructor __destruct (line 195)

JFTP object destructor

Closes an existing connection, if we have one

  • since: 11.1
  • access: public
void __destruct ()
chdir (line 502)

Method to change the current working directory on the FTP server

  • return: True if successful
  • since: 11.1
  • access: public
boolean chdir (string $path)
  • string $path: Path to change into on the server
chmod (line 607)

Method to change mode for a path on the FTP server

  • return: True if successful
  • since: 11.1
  • access: public
boolean chmod (string $path, mixed $mode)
  • string $path: Path to change mode on
  • mixed $mode: Octal value to change mode to, e.g. '0777', 0777 or 511 (string or integer)
connect (line 281)

Method to connect to a FTP server

  • return: True if successful
  • since: 11.1
  • access: public
boolean connect ([string $host = '127.0.0.1'], [string $port = 21])
  • string $host: Host to connect to [Default: 127.0.0.1]
  • string $port: Port to connect on [Default: port 21]
create (line 756)

Method to create an empty file on the FTP server

  • return: True if successful
  • since: 11.1
  • access: public
boolean create (string $path)
  • string $path: Path local file to store on the FTP server
delete (line 656)

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

  • return: True if successful
  • since: 11.1
  • access: public
boolean delete (string $path)
  • string $path: Path to delete
get (line 899)

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

  • return: True if successful
  • since: 11.1
  • access: public
boolean get (string $local, string $remote)
  • string $local: Local path to save remote file to
  • string $remote: Path to remote file to get on the FTP server
getInstance (line 222)

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.

  • return: The FTP Client object.
  • since: 11.1
  • access: public
JFTP getInstance ([string $host = '127.0.0.1'], [string $port = '21'], [array $options = null], [string $user = null], [string $pass = null])
  • string $host: Host to connect to
  • string $port: Port to connect to
  • array $options: Array with any of these options: type=>[FTP_AUTOASCII|FTP_ASCII|FTP_BINARY], timeout=>(int)
  • string $user: Username to use for a connection
  • string $pass: Password to use for a connection
isConnected (line 335)

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

  • return: True if connected
  • since: 11.1
  • access: public
boolean isConnected ()
listDetails (line 1259)

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

  • return: If $type is raw: string Directory listing, otherwise array of string with file-names
  • access: public
mixed listDetails ([string $path = null], [string $type = 'all'])
  • string $path: Path to the local file to be stored on the FTP server
  • string $type: Return type [raw|all|folders|files]
listNames (line 1162)

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

  • return: Directory listing
  • since: 11.1
  • access: public
string listNames ([string $path = null])
  • string $path: Path local file to store on the FTP server
login (line 350)

Method to login to a server once connected

  • return: True if successful
  • since: 11.1
  • access: public
boolean login ([string $user = 'anonymous'], [string $pass = 'jftp@joomla.org'])
  • string $user: Username to login to the server
  • string $pass: Password to login to the server
mkdir (line 693)

Method to create a directory on the FTP server

  • return: True if successful
  • since: 11.1
  • access: public
boolean mkdir (string $path)
  • string $path: Directory to create
pwd (line 416)

Method to retrieve the current working directory on the FTP server

  • return: Current working directory
  • since: 11.1
  • access: public
string pwd ()
quit (line 393)

Method to quit and close the connection

  • return: True if successful
  • since: 11.1
  • access: public
boolean quit ()
read (line 815)

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

  • return: True if successful
  • since: 11.1
  • access: public
boolean read (string $remote, string &$buffer)
  • string $remote: Path to remote file to read on the FTP server
  • string &$buffer: Buffer variable to read file contents into
reinit (line 534)

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

NOTE: This command not available on all servers

  • return: True if successful
  • since: 11.1
  • access: public
boolean reinit ()
rename (line 567)

Method to rename a file/folder on the FTP server

  • return: True if successful
  • since: 11.1
  • access: public
boolean rename (string $from, string $to)
  • string $from: Path to change file/folder from
  • string $to: Path to change file/folder to
restart (line 724)

Method to restart data transfer at a given byte

  • return: True if successful
  • since: 11.1
  • access: public
boolean restart (integer $point)
  • integer $point: Byte to restart transfer at
setOptions (line 258)

Set client options

  • return: True if successful
  • since: 11.1
  • access: public
boolean setOptions (array $options)
  • array $options: Associative array of options to set
store (line 976)

Method to store a file to the FTP server

  • return: True if successful
  • since: 11.1
  • access: public
boolean store (string $local, [string $remote = null])
  • string $local: Path to local file to store on the FTP server
  • string $remote: FTP path to file to create
syst (line 453)

Method to system string from the FTP server

  • return: System identifier string
  • since: 11.1
  • access: public
string syst ()
write (line 1079)

Method to write a string to the FTP server

  • return: True if successful
  • since: 11.1
  • access: public
boolean write (string $remote, string $buffer)
  • string $remote: FTP path to file to write to
  • string $buffer: Contents to write to the FTP server
_findMode (line 1661)

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

  • return: Transfer-mode for this filetype [FTP_ASCII|FTP_BINARY]
  • since: 11.1
  • access: protected
integer _findMode (string $fileName)
  • string $fileName: Name of the file
_mode (line 1698)

Set transfer mode

  • return: True if successful
  • since: 11.1
  • access: protected
boolean _mode (integer $mode)
  • integer $mode: Integer representation of data transfer mode [1:Binary|0:Ascii] Defined constants can also be used [FTP_BINARY|FTP_ASCII]
_passive (line 1583)

Set server to passive mode and open a data port connection

  • return: True if successful
  • since: 11.1
  • access: protected
boolean _passive ()
_putCmd (line 1498)

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

  • return: True if command executed successfully
  • since: 11.1
  • access: protected
boolean _putCmd (string $cmd, mixed $expectedResponse)
  • string $cmd: Command to send to the FTP server
  • mixed $expectedResponse: Integer response code or array of integer response codes
_verifyResponse (line 1525)

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

  • return: True if response code from the server is expected
  • since: 11.1
  • access: protected
boolean _verifyResponse (mixed $expected)
  • mixed $expected: Integer response code or array of integer response codes

Documentation generated on Mon, 25 Jun 2012 13:54:58 -0500 by phpDocumentor 1.4.4