Example #1
0
 public function download(Varien_Object $connectionInfo, $target)
 {
     $file = $connectionInfo->getFile();
     $this->_log($this->_getLog()->__("Connecting to FTP server %s", $connectionInfo->getHost()));
     $ftp = new Varien_Io_Ftp();
     $ftp->open(array('host' => $connectionInfo->getHost(), 'user' => $connectionInfo->getUsername(), 'password' => $connectionInfo->getPassword(), 'timeout' => $connectionInfo->hasTimeout() ? $connectionInfo->getTimeout() : 10, 'passive' => $connectionInfo->hasPassive() ? $connectionInfo->getPassive() : true, 'ssl' => $connectionInfo->hasSsl() ? $connectionInfo->getSsl() : null, 'file_mode' => $connectionInfo->hasFileMode() ? $connectionInfo->getFileMode() : null));
     if (!is_writable(Mage::getBaseDir() . DS . $target)) {
         Mage::throwException($this->_getLog()->__("Can not write file %s to %s, folder not writable (doesn't exist?)", $connectionInfo->getFile(), $target));
     }
     $this->_log($this->_getLog()->__("Downloading file %s from %s, to %s", $connectionInfo->getFile(), $connectionInfo->getHost(), $target));
     $targetPath = $this->_getTargetPath($target, basename($file));
     $ftp->read($file, $targetPath);
     $ftp->close();
 }
 /**
  * Initializes service from gateway
  * @param Varien_Object $gateway Object with all connection params
  * @return
  */
 public function initFromVarienObject(Varien_Object $gateway)
 {
     $this->setType($gateway->getProtocol())->setHost($gateway->getHost())->setLogin($gateway->getLogin())->setPassword($gateway->getPassword())->setPort($gateway->getPort())->setSecure($this->_getGatewaySecure($gateway));
     $instanceConstructor = $this->_getConnectionConstructor();
     try {
         // Try to connect
         $this->setInstance(new $instanceConstructor($this->_getConnectionParams()));
     } catch (Zend_Mail_Protocol_Exception $e) {
         $this->log($e->getMessage());
         return $e->getMessage();
     }
     return true;
 }