Beispiel #1
0
 /**
  * Determine whether input fields for client settings need to be shown
  *
  * If valid credentials were passed along with the request, they are saved to the session.
  * This functions returns an exception if invalid credentials have been given or if the
  * connection to the server failed for some other reason.
  *
  * @param   string  $client  The name of the client.
  *
  * @return  mixed  True, if FTP settings should be shown or an exception
  *
  * @since   11.1
  */
 public static function setCredentialsFromRequest($client)
 {
     // Determine wether FTP credentials have been passed along with the current request
     $user = JRequest::getString('username', null, 'POST', JREQUEST_ALLOWRAW);
     $pass = JRequest::getString('password', null, 'POST', JREQUEST_ALLOWRAW);
     if ($user != '' && $pass != '') {
         // Add credentials to the session
         if (JClientHelper::setCredentials($client, $user, $pass)) {
             $return = false;
         } else {
             $return = JError::raiseWarning('SOME_ERROR_CODE', JText::_('JLIB_CLIENT_ERROR_HELPER_SETCREDENTIALSFROMREQUEST_FAILED'));
         }
     } else {
         // Just determine if the FTP input fields need to be shown
         $return = !JClientHelper::hasCredentials('ftp');
     }
     return $return;
 }
Beispiel #2
0
 /**
  * Applies FTP credentials to Joomla! itself, when required
  *
  * @return  void
  *
  * @since	2.5.4
  */
 protected function _applyCredentials()
 {
     if (!JClientHelper::hasCredentials('ftp')) {
         $user = JFactory::getApplication()->getUserStateFromRequest('com_joomlaupdate.ftp_user', 'ftp_user', null, 'raw');
         $pass = JFactory::getApplication()->getUserStateFromRequest('com_joomlaupdate.ftp_pass', 'ftp_pass', null, 'raw');
         if ($user != '' && $pass != '') {
             // Add credentials to the session
             if (!JClientHelper::setCredentials('ftp', $user, $pass)) {
                 JError::raiseWarning('SOME_ERROR_CODE', JText::_('JLIB_CLIENT_ERROR_HELPER_SETCREDENTIALSFROMREQUEST_FAILED'));
             }
         }
     }
 }
Beispiel #3
0
 /**
  * Determine wether input fields for client settings need to be shown
  *
  * If valid credentials were passed along with the request, they are saved to the session.
  * This functions returns an exeption if invalid credentials have been given or if the
  * connection to the server failed for some other reason.
  * @static
  * @return	boolean|JExeption	True, if FTP settings should be shown, or an exeption
  * @since	1.5
  */
 function &setCredentialsFromRequest($client)
 {
     // Determine wether FTP credentials have been passed along with the current request
     $user = JRequest::getString('username', null, 'POST', JREQUEST_ALLOWRAW);
     $pass = JRequest::getString('password', null, 'POST', JREQUEST_ALLOWRAW);
     if ($user != '' && $pass != '') {
         // Add credentials to the session
         if (JClientHelper::setCredentials($client, $user, $pass)) {
             $return = false;
         } else {
             $return =& JError::raiseWarning('SOME_ERROR_CODE', 'JClientHelper::setCredentialsFromRequest failed');
         }
     } else {
         // Just determine if the FTP input fields need to be shown
         $return = !JClientHelper::hasCredentials('ftp');
     }
     return $return;
 }
Beispiel #4
0
 /**
  * Helper wrapper method for setCredentials
  *
  * @param   string  $client  Client name, currently only 'ftp' is supported
  * @param   string  $user    Username
  * @param   string  $pass    Password
  *
  * @return boolean  True if the given login credentials have been set and are valid
  *
  * @see     JClientHelper::setCredentials()
  * @since   3.4
  */
 public function setCredentials($client, $user, $pass)
 {
     return JClientHelper::setCredentials($client, $user, $pass);
 }
Beispiel #5
0
 /**
  * Does the user need to provide FTP credentials? It also registers any FTP credentials provided in the URL.
  *
  * @return  bool  True if the user needs to provide FTP credentials
  */
 public function needsFTPCredentials()
 {
     // Determine wether FTP credentials have been passed along with the current request
     \JLoader::import('joomla.client.helper');
     $user = $this->input->get('username', null, 'raw');
     $pass = $this->input->get('password', null, 'raw');
     if (!($user == '' && $pass == '')) {
         // Add credentials to the session
         if (\JClientHelper::setCredentials('ftp', $user, $pass)) {
             return false;
         }
         return true;
     }
     return !\JClientHelper::hasCredentials('ftp');
 }
Beispiel #6
0
 private function _applyFTPCredentials()
 {
     $session = JFactory::getSession();
     $credentials = $session->get('ftp', array('user' => '', 'pass' => ''), 'akeeba');
     JClientHelper::setCredentials('ftp', $credentials['user'], $credentials['pass']);
 }
Beispiel #7
0
 /**
  * Returns an array with the configured FTP options
  *
  * @return  array
  */
 public function getFTPOptions()
 {
     // Initialise from Joomla! Global Configuration
     $config = JFactory::getConfig();
     $retArray = array('enable' => $config->get('ftp_enable', 0), 'host' => $config->get('ftp_host', 'localhost'), 'port' => $config->get('ftp_port', '21'), 'user' => $config->get('ftp_user', ''), 'pass' => $config->get('ftp_pass', ''), 'root' => $config->get('ftp_root', ''), 'tempdir' => $config->get('tmp_path', ''));
     // Get the username and password from the state variables, if it exists
     $stateUser = '';
     //$this->getState('user', '', 'raw');
     $statePass = '';
     //$this->getState('pass', '', 'raw');
     if (!empty($stateUser)) {
         $retArray['user'] = $stateUser;
     }
     if (!empty($statePass)) {
         $retArray['pass'] = $statePass;
     }
     // Apply the FTP credentials to Joomla! itself
     JLoader::import('joomla.client.helper');
     JClientHelper::setCredentials('ftp', $retArray['user'], $retArray['pass']);
     return $retArray;
 }