Esempio n. 1
0
 /**
  * Test the FTP connection.
  *
  * @return bool|string  True on success, error message on failure
  */
 public function testFTP()
 {
     $config = array('host' => $this->getState('host'), 'port' => $this->getState('port'), 'user' => $this->getState('user'), 'pass' => $this->getState('pass'), 'initdir' => $this->getState('initdir'), 'usessl' => $this->getState('usessl'), 'passive' => $this->getState('passive'));
     // Check for bad settings
     if (substr($config['host'], 0, 6) == 'ftp://') {
         return JText::_('CONFIG_FTPTEST_BADPREFIX');
     }
     // Perform the FTP connection test
     $test = new \Akeeba\Engine\Archiver\Directftp();
     $test->initialize('', $config);
     $errors = $test->getError();
     if (empty($errors) || $test->connect_ok) {
         $result = true;
     } else {
         $result = $errors;
     }
     return $result;
 }
Esempio n. 2
0
 /**
  * Handles an AJAX request
  *
  * @return  mixed
  */
 public function doAjax()
 {
     $ajax = $this->getState('ajax');
     switch ($ajax) {
         // FTP Connection test for DirectFTP
         case 'testftp':
             // Grab request parameters
             $config = array('host' => $this->input->get('host', '', 'none', 2), 'port' => $this->input->get('port', 21, 'int'), 'user' => $this->input->get('user', '', 'none', 2), 'pass' => $this->input->get('pass', '', 'none', 2), 'initdir' => $this->input->get('initdir', '', 'none', 2), 'usessl' => $this->input->get('usessl', 'cmd') == 'true', 'passive' => $this->input->get('passive', 'cmd') == 'true');
             // Perform the FTP connection test
             $test = new \Akeeba\Engine\Archiver\Directftp();
             $test->initialize('', $config);
             $errors = $test->getError();
             if (empty($errors)) {
                 $result = true;
             } else {
                 $result = $errors;
             }
             break;
             // Unrecognized AJAX task
         // Unrecognized AJAX task
         default:
             $result = false;
             break;
     }
     return $result;
 }