API16:JFTP/getInstance
From Joomla! Documentation
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
Contents |
Description
Returns the global FTP connector object, only creating it if it doesn't already exist.
Syntax
getInstance($host= '127.0.0.1', $port= '21', $options=null, $user=null, $pass=null)
| Parameter Name | Default Value | Description |
|---|---|---|
| $host | '127.0.0.1' | $host Host to connect to |
| $port | '21' | $port Port to connect to |
| $options | null | FTP_ASCII|FTP_BINARY], timeout=>(int) |
| $user | null | $user Username to use for a connection |
| $pass | null | $pass Password to use for a connection |
Returns
The FTP Client object.
Defined in
libraries/joomla/client/ftp.php
Importing
jimport( 'joomla.client.ftp' );
Source Body
function getInstance($host = '127.0.0.1', $port = '21', $options = null, $user = null, $pass = null) { static $instances = array(); $signature = $user.':'.$pass.'@'.$host.":".$port; // Create a new instance, or set the options of an existing one if (!isset ($instances[$signature]) || !is_object($instances[$signature])) { $instances[$signature] = new JFTP($options); } else { $instances[$signature]->setOptions($options); } // Connect to the server, and login, if requested if (!$instances[$signature]->isConnected()) { $return = $instances[$signature]->connect($host, $port); if ($return && $user !== null && $pass !== null) { $instances[$signature]->login($user, $pass); } } return $instances[$signature]; }
[Edit See Also] SeeAlso:JFTP/getInstance
Examples
<CodeExamplesForm />
