Joomla CMS  3.8.5 (avec JPlatform 13.1 inclus)
Documentation des API du CMS Joomla en version 3.8.5 et du framework Joomla Platform intégré
Référence de la classe FtpClient

Fonctions membres publiques

 __construct (array $options=array())
 
 __destruct ()
 
 setOptions (array $options)
 
 connect ($host='127.0.0.1', $port=21)
 
 isConnected ()
 
 login ($user='anonymous', $pass='jftp @joomla.org')
 
 quit ()
 
 pwd ()
 
 syst ()
 
 chdir ($path)
 
 reinit ()
 
 rename ($from, $to)
 
 chmod ($path, $mode)
 
 delete ($path)
 
 mkdir ($path)
 
 restart ($point)
 
 create ($path)
 
 read ($remote, &$buffer)
 
 get ($local, $remote)
 
 store ($local, $remote=null)
 
 write ($remote, $buffer)
 
 append ($remote, $buffer)
 
 size ($remote)
 
 listNames ($path=null)
 
 listDetails ($path=null, $type='all')
 

Fonctions membres publiques statiques

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

Fonctions membres protégées

 _putCmd ($cmd, $expectedResponse)
 
 _verifyResponse ($expected)
 
 _passive ()
 
 _findMode ($fileName)
 
 _mode ($mode)
 

Attributs protégés

 $_conn = null
 
 $_dataconn = null
 
 $_pasv = null
 
 $_response = null
 
 $_timeout = 15
 
 $_type = null
 
 $_autoAscii
 
 $_lineEndings = array('UNIX' => "\n", 'WIN' => "\r\n")
 

Attributs protégés statiques

static $instances = array()
 

Description détaillée

Error Codes:

  • 30 : Unable to connect to host
  • 31 : Not connected
  • 32 : Unable to send command to server
  • 33 : Bad username
  • 34 : Bad password
  • 35 : Bad response
  • 36 : Passive mode failed
  • 37 : Data transfer error
  • 38 : Local filesystem error FTP client class
Depuis
12.1

Documentation des constructeurs et destructeur

◆ __construct()

__construct ( array  $options = array())

FtpClient object constructor

Paramètres
array$optionsAssociative array of options to set
Depuis
12.1

Références $options, FtpClient\setOptions(), et BufferStreamHandler\stream_register().

◆ __destruct()

__destruct ( )

FtpClient object destructor

Closes an existing connection, if we have one

Depuis
12.1

Références FtpClient\quit().

Documentation des fonctions membres

◆ _findMode()

_findMode (   $fileName)
protected

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

Paramètres
string$fileNameName of the file
Renvoie
integer Transfer-mode for this filetype [FTP_ASCII|FTP_BINARY]
Depuis
12.1

Références $mode, et elseif.

Référencé par FtpClient\append(), FtpClient\get(), FtpClient\read(), FtpClient\store(), et FtpClient\write().

◆ _mode()

_mode (   $mode)
protected

Set transfer mode

Paramètres
integer$modeInteger representation of data transfer mode [1:Binary|0:Ascii] Defined constants can also be used [FTP_BINARY|FTP_ASCII]
Renvoie
boolean True if successful
Depuis
12.1

Références $mode, FtpClient\_putCmd(), Log\add(), et Log\WARNING.

Référencé par FtpClient\append(), FtpClient\get(), FtpClient\read(), FtpClient\store(), et FtpClient\write().

◆ _passive()

_passive ( )
protected

Set server to passive mode and open a data port connection

Renvoie
boolean True if successful
Depuis
12.1

Références FtpClient\$_timeout, $parts, Log\add(), null, et Log\WARNING.

Référencé par FtpClient\append(), FtpClient\create(), FtpClient\get(), FtpClient\listDetails(), FtpClient\listNames(), FtpClient\read(), FtpClient\size(), FtpClient\store(), et FtpClient\write().

◆ _putCmd()

_putCmd (   $cmd,
  $expectedResponse 
)
protected

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

Paramètres
string$cmdCommand to send to the FTP server
mixed$expectedResponseInteger response code or array of integer response codes
Renvoie
boolean True if command executed successfully
Depuis
12.1

Références FtpClient\_verifyResponse(), Log\add(), et Log\WARNING.

Référencé par FtpClient\_mode(), FtpClient\append(), FtpClient\chdir(), FtpClient\chmod(), FtpClient\create(), FtpClient\delete(), FtpClient\get(), FtpClient\listDetails(), FtpClient\listNames(), FtpClient\login(), FtpClient\mkdir(), FtpClient\pwd(), FtpClient\read(), FtpClient\reinit(), FtpClient\rename(), FtpClient\restart(), FtpClient\size(), FtpClient\store(), FtpClient\syst(), et FtpClient\write().

◆ _verifyResponse()

_verifyResponse (   $expected)
protected

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

Paramètres
mixed$expectedInteger response code or array of integer response codes
Renvoie
boolean True if response code from the server is expected
Depuis
12.1

Références FtpClient\$_timeout, $parts, Log\add(), null, et Log\WARNING.

Référencé par FtpClient\_putCmd(), FtpClient\append(), FtpClient\connect(), FtpClient\create(), FtpClient\get(), FtpClient\listDetails(), FtpClient\listNames(), FtpClient\read(), FtpClient\store(), et FtpClient\write().

◆ append()

append (   $remote,
  $buffer 
)

Method to append a string to the FTP server

Paramètres
string$remoteFTP path to file to append to
string$bufferContents to append to the FTP server
Renvoie
boolean True if successful
Depuis
3.6.0

Références $buffer, $mode, $tmp, FtpClient\_findMode(), FtpClient\_mode(), FtpClient\_passive(), FtpClient\_putCmd(), FtpClient\_verifyResponse(), et FtpClient\size().

◆ chdir()

chdir (   $path)

Method to change the current working directory on the FTP server

Paramètres
string$pathPath to change into on the server
Renvoie
boolean True if successful
Depuis
12.1

Références $path, FtpClient\_putCmd(), Log\add(), et Log\WARNING.

◆ chmod()

chmod (   $path,
  $mode 
)

Method to change mode for a path on the FTP server

Paramètres
string$pathPath to change mode on
mixed$modeOctal value to change mode to, e.g. '0777', 0777 or 511 (string or integer)
Renvoie
boolean True if successful
Depuis
12.1

Références $mode, $path, FtpClient\_putCmd(), Log\add(), et Log\WARNING.

◆ connect()

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

Method to connect to a FTP server

Paramètres
string$hostHost to connect to [Default: 127.0.0.1]
string$portPort to connect on [Default: port 21]
Renvoie
boolean True if successful
Depuis
12.1

Références FtpClient\_verifyResponse(), Log\add(), null, et Log\WARNING.

◆ create()

create (   $path)

Method to create an empty file on the FTP server

Paramètres
string$pathPath local file to store on the FTP server
Renvoie
boolean True if successful
Depuis
12.1

Références $buffer, $path, FtpClient\_passive(), FtpClient\_putCmd(), FtpClient\_verifyResponse(), Log\add(), et Log\WARNING.

◆ delete()

delete (   $path)

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

Paramètres
string$pathPath to delete
Renvoie
boolean True if successful
Depuis
12.1

Références $path, FtpClient\_putCmd(), Log\add(), et Log\WARNING.

◆ get()

get (   $local,
  $remote 
)

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

Paramètres
string$localLocal path to save remote file to
string$remotePath to remote file to get on the FTP server
Renvoie
boolean True if successful
Depuis
12.1

Références $buffer, $mode, FtpClient\_findMode(), FtpClient\_mode(), FtpClient\_passive(), FtpClient\_putCmd(), FtpClient\_verifyResponse(), Log\add(), et Log\WARNING.

◆ getInstance()

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

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.

Paramètres
string$hostHost to connect to
string$portPort to connect to
array$optionsArray with any of these options: type=>[FTP_AUTOASCII|FTP_ASCII|FTP_BINARY], timeout=>(int)
string$userUsername to use for a connection
string$passPassword to use for a connection
Renvoie
FtpClient The FTP Client object.
Depuis
12.1

Références $options, $return, $user, FtpClient\isConnected(), et null.

Référencé par ClientHelper\setCredentials().

◆ isConnected()

isConnected ( )

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

Renvoie
boolean True if connected
Depuis
12.1

Référencé par FtpClient\getInstance().

◆ listDetails()

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

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

Paramètres
string$pathPath to the local file to be stored on the FTP server
string$typeReturn type [raw|all|folders|files]
Renvoie
mixed If $type is raw: string Directory listing, otherwise array of string with file-names
Depuis
12.1

Références $data, $file, $path, $type, FtpClient\_passive(), FtpClient\_putCmd(), FtpClient\_verifyResponse(), Log\add(), null, et Log\WARNING.

Référencé par FtpClient\listNames().

◆ listNames()

listNames (   $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

Paramètres
string$pathPath local file to store on the FTP server
Renvoie
string Directory listing
Depuis
12.1

Références $data, $key, $list, $path, FtpClient\_passive(), FtpClient\_putCmd(), FtpClient\_verifyResponse(), Log\add(), FtpClient\listDetails(), null, et Log\WARNING.

◆ login()

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

Method to login to a server once connected

Paramètres
string$userUsername to login to the server
string$passPassword to login to the server
Renvoie
boolean True if successful
Depuis
12.1

Références $user, FtpClient\_putCmd(), Log\add(), et Log\WARNING.

◆ mkdir()

mkdir (   $path)

Method to create a directory on the FTP server

Paramètres
string$pathDirectory to create
Renvoie
boolean True if successful
Depuis
12.1

Références $path, FtpClient\_putCmd(), Log\add(), et Log\WARNING.

◆ pwd()

pwd ( )

Method to retrieve the current working directory on the FTP server

Renvoie
string Current working directory
Depuis
12.1

Références FtpClient\_putCmd(), Log\add(), null, et Log\WARNING.

◆ quit()

quit ( )

Method to quit and close the connection

Renvoie
boolean True if successful
Depuis
12.1

Référencé par FtpClient\__destruct().

◆ read()

read (   $remote,
$buffer 
)

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

Paramètres
string$remotePath to remote file to read on the FTP server
string&$bufferBuffer variable to read file contents into
Renvoie
boolean True if successful
Depuis
12.1

Références $buffer, $mode, $os, $tmp, FtpClient\_findMode(), FtpClient\_mode(), FtpClient\_passive(), FtpClient\_putCmd(), FtpClient\_verifyResponse(), Log\add(), et Log\WARNING.

◆ reinit()

reinit ( )

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

NOTE: This command not available on all servers

Renvoie
boolean True if successful
Depuis
12.1

Références FtpClient\_putCmd(), Log\add(), et Log\WARNING.

◆ rename()

rename (   $from,
  $to 
)

Method to rename a file/folder on the FTP server

Paramètres
string$fromPath to change file/folder from
string$toPath to change file/folder to
Renvoie
boolean True if successful
Depuis
12.1

Références FtpClient\_putCmd(), Log\add(), et Log\WARNING.

◆ restart()

restart (   $point)

Method to restart data transfer at a given byte

Paramètres
integer$pointByte to restart transfer at
Renvoie
boolean True if successful
Depuis
12.1

Références FtpClient\_putCmd(), Log\add(), et Log\WARNING.

◆ setOptions()

setOptions ( array  $options)

Set client options

Paramètres
array$optionsAssociative array of options to set
Renvoie
boolean True if successful
Depuis
12.1

Références $options.

Référencé par FtpClient\__construct().

◆ size()

size (   $remote)

Get the size of the remote file.

Paramètres
string$remoteFTP path to file whose size to get
Renvoie
mixed number of bytes or false on error
Depuis
3.6.0

Références FtpClient\_passive(), et FtpClient\_putCmd().

Référencé par FtpClient\append().

◆ store()

store (   $local,
  $remote = null 
)

Method to store a file to the FTP server

Paramètres
string$localPath to local file to store on the FTP server
string$remoteFTP path to file to create
Renvoie
boolean True if successful
Depuis
12.1

Références $mode, FtpClient\_findMode(), FtpClient\_mode(), FtpClient\_passive(), FtpClient\_putCmd(), FtpClient\_verifyResponse(), Log\add(), null, et Log\WARNING.

◆ syst()

syst ( )

Method to system string from the FTP server

Renvoie
string System identifier string
Depuis
12.1

Références FtpClient\$_response, FtpClient\_putCmd(), Log\add(), elseif, et Log\WARNING.

◆ write()

write (   $remote,
  $buffer 
)

Method to write a string to the FTP server

Paramètres
string$remoteFTP path to file to write to
string$bufferContents to write to the FTP server
Renvoie
boolean True if successful
Depuis
12.1

Références $buffer, $mode, $tmp, FtpClient\_findMode(), FtpClient\_mode(), FtpClient\_passive(), FtpClient\_putCmd(), FtpClient\_verifyResponse(), Log\add(), et Log\WARNING.

Documentation des champs

◆ $_autoAscii

$_autoAscii
protected
Valeur initiale :
= array(
'asp',
'bat',
'c',
'cpp',
'csv',
'h',
'htm',
'html',
'shtml',
'ini',
'inc',
'log',
'php',
'php3',
'pl',
'perl',
'sh',
'sql',
'txt',
'xhtml',
'xml',
)

◆ $_conn

$_conn = null
protected

◆ $_dataconn

$_dataconn = null
protected

◆ $_lineEndings

$_lineEndings = array('UNIX' => "\n", 'WIN' => "\r\n")
protected

◆ $_pasv

$_pasv = null
protected

◆ $_response

$_response = null
protected

Référencé par FtpClient\syst().

◆ $_timeout

$_timeout = 15
protected

◆ $_type

$_type = null
protected

◆ $instances

$instances = array()
staticprotected

La documentation de cette classe a été générée à partir du fichier suivant :