/** * Upload Feed to FTP server if required. */ protected function _sendFeed() { if (Mage::getStoreConfigFlag(self::CONFIG_FTP_ENABLED)) { $oFtp = new Varien_Io_Ftp(); $bSuccess = $oFtp->open(array('host' => Mage::getStoreConfig(self::CONFIG_FTP_HOST), 'user' => Mage::getStoreConfig(self::CONFIG_FTP_USER), 'password' => Mage::getStoreConfig(self::CONFIG_FTP_PASS))); if (!$bSuccess) { Mage::getSingleton('aligent_feeds/log')->log("Unable to connect to FTP Server"); Mage::getSingleton('aligent_feeds/status')->addError("", "Unable to connect to FTP Server"); return; } $bSuccess = $oFtp->cd(Mage::getStoreConfig(self::CONFIG_FTP_PATH)); if (!$bSuccess) { Mage::getSingleton('aligent_feeds/log')->log("Unable change directories on FTP Server"); Mage::getSingleton('aligent_feeds/status')->addError("", "Unable to connect to FTP Server"); return; } foreach ($this->_oWriters as $oWriter) { $vFilename = $oWriter->getFilename(); $bSuccess = $oFtp->write(basename($vFilename), $vFilename); if (!$bSuccess) { Mage::getSingleton('aligent_feeds/log')->log("Unable to upload {$vFilename} to FTP server"); Mage::getSingleton('aligent_feeds/status')->addError("", "Unable to upload {$vFilename} to FTP server"); return; } } $oFtp->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(); } }