The main purpose of this class is to overcome problems with access rights
when working with the local file system. When FTP access is enabled in the site
configuration, Joomla! will attempt to use FTP instead of PHP file system functions.
Whenever we connect to an FTP server we require certain settings to be in place. If
we want to use the FTP settings defined in the global configuration, we can use the
JClientHelper class to easily access these settings.
This example demonstrates how we can use JClientHelper static getCredentials()
method to get the FTP settings:
jimport('joomla.client.helper');
$FTP_Settings = JClientHelper::getCredentials('ftp');
The JClientHelper static getCredentials() method returns an associative array
with the following keys: enabled, host, port, user, pass, and root. We briefly
mentioned earlier that the global FTP access can be enabled and disabled; the
enabled key provides us with the value of this option. We must never attempt to use
the global FTP settings if this value is not equivalent to 1:
if ($FTP_Settings['enabled'] == 1)
{
// It is OK, we can use the global FTP settings
}
Of course we don't have to use the global FTP settings.
Pages:
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409