[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/joomla/filesystem/src/Clients/ -> FtpClient.php (summary)

Part of the Joomla Framework Filesystem Package

Copyright: Copyright (C) 2005 - 2021 Open Source Matters, Inc. All rights reserved.
License: GNU General Public License version 2 or later; see LICENSE
File Size: 1816 lines (42 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

FtpClient:: (29 methods):
  __construct()
  __destruct()
  getInstance()
  setOptions()
  connect()
  isConnected()
  login()
  quit()
  pwd()
  syst()
  chdir()
  reinit()
  rename()
  chmod()
  delete()
  mkdir()
  restart()
  create()
  read()
  get()
  store()
  write()
  listNames()
  listDetails()
  _putCmd()
  _verifyResponse()
  _passive()
  _findMode()
  _mode()


Class: FtpClient  - X-Ref

FTP client class

__construct(array $options = [])   X-Ref
FtpClient object constructor

param: array  $options  Associative array of options to set

__destruct()   X-Ref
FtpClient object destructor

Closes an existing connection, if we have one


getInstance($host = '127.0.0.1', $port = '21', array $options = [], $user = null, $pass = null)   X-Ref
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: string  $host     Host to connect to
param: string  $port     Port to connect to
param: array   $options  Array with any of these options: type=>[FTP_AUTOASCII|FTP_ASCII|FTP_BINARY], timeout=>(int)
param: string  $user     Username to use for a connection
param: string  $pass     Password to use for a connection
return: FtpClient  The FTP Client object.

setOptions(array $options)   X-Ref
Set client options

param: array  $options  Associative array of options to set
return: boolean  True if successful

connect($host = '127.0.0.1', $port = 21)   X-Ref
Method to connect to a FTP server

param: string   $host  Host to connect to [Default: 127.0.0.1]
param: integer  $port  Port to connect on [Default: port 21]
return: boolean  True if successful

isConnected()   X-Ref
Method to determine if the object is connected to an FTP server

return: boolean  True if connected

login($user = 'anonymous', $pass = '[email protected]')   X-Ref
Method to login to a server once connected

param: string  $user  Username to login to the server
param: string  $pass  Password to login to the server
return: boolean  True if successful

quit()   X-Ref
Method to quit and close the connection

return: boolean  True if successful

pwd()   X-Ref
Method to retrieve the current working directory on the FTP server

return: string   Current working directory

syst()   X-Ref
Method to system string from the FTP server

return: string   System identifier string

chdir($path)   X-Ref
Method to change the current working directory on the FTP server

param: string  $path  Path to change into on the server
return: boolean True if successful

reinit()   X-Ref
Method to reinitialise the server, ie. need to login again

NOTE: This command not available on all servers

return: boolean  True if successful

rename($from, $to)   X-Ref
Method to rename a file/folder on the FTP server

param: string  $from  Path to change file/folder from
param: string  $to    Path to change file/folder to
return: boolean  True if successful

chmod($path, $mode)   X-Ref
Method to change mode for a path on the FTP server

param: string  $path  Path to change mode on
param: mixed   $mode  Octal value to change mode to, e.g. '0777', 0777 or 511 (string or integer)
return: boolean  True if successful

delete($path)   X-Ref
Method to delete a path [file/folder] on the FTP server

param: string  $path  Path to delete
return: boolean  True if successful

mkdir($path)   X-Ref
Method to create a directory on the FTP server

param: string  $path  Directory to create
return: boolean  True if successful

restart($point)   X-Ref
Method to restart data transfer at a given byte

param: integer  $point  Byte to restart transfer at
return: boolean  True if successful

create($path)   X-Ref
Method to create an empty file on the FTP server

param: string  $path  Path local file to store on the FTP server
return: boolean  True if successful

read($remote, &$buffer)   X-Ref
Method to read a file from the FTP server's contents into a buffer

param: string  $remote  Path to remote file to read on the FTP server
param: string  $buffer  Buffer variable to read file contents into
return: boolean  True if successful

get($local, $remote)   X-Ref
Method to get a file from the FTP server and save it to a local file

param: string  $local   Local path to save remote file to
param: string  $remote  Path to remote file to get on the FTP server
return: boolean  True if successful

store($local, $remote = null)   X-Ref
Method to store a file to the FTP server

param: string  $local   Path to local file to store on the FTP server
param: string  $remote  FTP path to file to create
return: boolean  True if successful

write($remote, $buffer)   X-Ref
Method to write a string to the FTP server

param: string  $remote  FTP path to file to write to
param: string  $buffer  Contents to write to the FTP server
return: boolean  True if successful

listNames($path = null)   X-Ref
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: string  $path  Path local file to store on the FTP server
return: string  Directory listing

listDetails($path = null, $type = 'all')   X-Ref
Method to list the contents of a directory on the FTP server

param: string  $path  Path to the local file to be stored on the FTP server
param: string  $type  Return type [raw|all|folders|files]
return: string[]  If $type is raw: string Directory listing, otherwise array of string with file-names

_putCmd($cmd, $expectedResponse)   X-Ref
Send command to the FTP server and validate an expected response code

param: string  $cmd               Command to send to the FTP server
param: mixed   $expectedResponse  Integer response code or array of integer response codes
return: boolean  True if command executed successfully

_verifyResponse($expected)   X-Ref
Verify the response code from the server and log response if flag is set

param: mixed  $expected  Integer response code or array of integer response codes
return: boolean  True if response code from the server is expected

_passive()   X-Ref
Set server to passive mode and open a data port connection

return: boolean  True if successful

_findMode($fileName)   X-Ref
Method to find out the correct transfer mode for a specific file

param: string  $fileName  Name of the file
return: integer Transfer-mode for this filetype [FTP_ASCII|FTP_BINARY]

_mode($mode)   X-Ref
Set transfer mode

param: integer  $mode  Integer representation of data transfer mode [1:Binary|0:Ascii]
return: boolean  True if successful



Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer