/**
* 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
*
* @since 1.5
*/
public function login($user = 'anonymous', $pass = 'jftp@joomla.org')
{
// If native FTP support is enabled let's use it...
if (FTP_NATIVE) {
if (@ftp_login($this->_conn, $user, $pass) === false) {
Log::add('JFtp::login: Unable to login', Log::WARNING, 'jerror');
return false;
}
return true;
}
// Send the username
if (!$this->_putCmd('USER ' . $user, array(331, 503))) {
Log::add(Text::sprintf('JLIB_CLIENT_ERROR_FTP_BAD_USERNAME', __METHOD__, $this->_response, $user), Log::WARNING, 'jerror');
return false;
}
// If we are already logged in, continue :)
if ($this->_responseCode == 503) {
return true;
}
// Send the password
if (!$this->_putCmd('PASS ' . $pass, 230)) {
Log::add(Text::sprintf('JLIB_CLIENT_ERROR_FTP_BAD_PASSWORD', __METHOD__, $this->_response, str_repeat('*', \strlen($pass))), Log::WARNING, 'jerror');
return false;
}
return true;
}