This is not the first time i have noticed a libary fail to include default config values. I created ftp.php and it was not working. With the values being passed via array to the connect() function it worked fine, with them in the /config/ftp.php config file… no dice! So im wondering why, I look at the user manual and it says:
If you prefer you can store your FTP preferences in a config file. Simply create a new file called the ftp.php, add the $config array in that file. Then save the file at config/ftp.php and it will be used automatically.
But there is no code in the FTP class that does anything close! I made a dodgy little hack below to add the functionality the class is intended to have but im sure there is a nice way to do this.
/**
* is a value equal to a certain value
*
* @access public
* @param array
* @return bool
*/
function connect($config = array())
{
if (count($config) > 0)
{
$this->initialize($config);
}
// If no config variable was passed then load the default config file
else
{
$this->CI =& get_instance();
$this->CI->config->load('ftp');
$config['hostname'] = $this->CI->config->item('hostname');
$config['username'] = $this->CI->config->item('username');
$config['password'] = $this->CI->config->item('password');
$config['port'] = $this->CI->config->item('port');
$config['passive'] = $this->CI->config->item('passive');
$config['debug'] = $this->CI->config->item('debug');
$this->initialize($config);
} // End -- Where was this part?!
if (FALSE === ($this->conn_id = @ftp_connect($this->hostname, $this->port)))
{
if ($this->debug == TRUE)
{
$this->_error('ftp_unable_to_connect');
}
return FALSE;
}
if ( ! $this->_login())
{
if ($this->debug == TRUE)
{
$this->_error('ftp_unable_to_login');
}
return FALSE;
}
// Set passive mode if needed
if ($this->passive == TRUE)
{
ftp_pasv($this->conn_id, TRUE);
}
return TRUE;
}
If you prefer you can store your FTP preferences in a config file. Simply create a new file called the ftp.php, add the $config array in that file. Then save the file at config/ftp.php and it will be used automatically.
