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(); }
private function downloadFile() { $ftpHost = $this->getRequest()->getParam('ftp_host'); $ftpLogin = $this->getRequest()->getParam('ftp_login'); $ftpPassword = $this->getRequest()->getParam('ftp_password'); $ftpDir = $this->getRequest()->getParam('ftp_dir'); $useSftp = $this->getRequest()->getParam('use_sftp'); $ftpActive = $this->getRequest()->getParam('ftp_active'); if ($useSftp) { $ftp = new Varien_Io_Sftp(); } else { $ftp = new Varien_Io_Ftp(); } try { $ftp->open(array('host' => $ftpHost, 'user' => $ftpLogin, 'username' => $ftpLogin, 'password' => $ftpPassword, 'timeout' => '120', 'path' => $ftpDir, 'passive' => !$ftpActive)); if ($ftp->cd($ftpDir)) { $filename = 'var/tmp/stock_import_' . time() . '.csv'; $io = new Varien_Io_File(); $realPath = $io->getCleanPath(Mage::getBaseDir() . '/var/tmp/'); if (is_readable($realPath)) { $content = $ftp->read($this->getRequest()->getParam('file_path'), $filename); $ftp->close(); if (!$content) { return array("The file '" . $this->getRequest()->getParam('file_path') . "' cannot be fetched."); } return $filename; } else { $ftp->close(); return array("Please make sure that var/tmp is writable."); } } else { $ftp->close(); return array("Cannot access '{$ftpDir}' on this server."); } } catch (Exception $e) { return $e->getMessage(); } }
private function x91() { $x7a = "stristr"; $x7b = "is_readable"; $x7c = "time"; $x7d = "file_get_contents"; $x7e = "in_array"; $x7f = "implode"; $x80 = "array_key_exists"; $x81 = "trim"; $x82 = "str_replace"; $x83 = "log"; $x84 = "is_array"; $x85 = "json_encode"; $x86 = "json_decode"; $x87 = "array_splice"; $x88 = "array_unshift"; $x89 = "count"; $x8a = "is_numeric"; $x8b = "array_push"; $x8c = "strtolower"; $x8d = "strstr"; $x8e = "explode"; $x8f = "addslashes"; $x33 = $this->getFtpHost(); $x34 = $this->getFtpLogin(); $x35 = $this->getFtpPassword(); $x36 = $this->getFtpDir(); $x37 = $this->getUseSftp(); $x38 = $this->getFtpActive(); if ($x37) { $x39 = new Varien_Io_Sftp(); } else { $x39 = new Varien_Io_Ftp(); } try { $x39->open(array('host' => $x33, 'user' => $x34, 'username' => $x34, 'password' => $x35, 'timeout' => '120', 'path' => $x36, 'passive' => !$x38)); if ($x39->cd($x36)) { $x3a = 'var/tmp/stock_import_' . $x7c() . '.csv'; $x31 = new Varien_Io_File(); $x32 = $x31->getCleanPath(Mage::getBaseDir() . '/var/tmp/'); if ($x7b($x32)) { $x3b = $x39->read($this->getFilePath(), $x3a); $x39->close(); if (!$x3b) { return array("The file '" . $this->getFilePath() . "' cannot be fetched."); } return $x3a; } else { $x39->close(); return array("Please make sure that var/tmp is writable."); } } else { $x39->close(); return array("Cannot access '{$x36}' on this server."); } } catch (Exception $x3c) { return $x3c->getMessage(); } }