示例#1
0
 public function viewfileAction()
 {
     $file = null;
     $plain = false;
     if ($this->getRequest()->getParam('file')) {
         // download file
         $file = Mage::helper('core')->urlDecode($this->getRequest()->getParam('file'));
     } else {
         if ($this->getRequest()->getParam('image')) {
             // show plain image
             $file = Mage::helper('core')->urlDecode($this->getRequest()->getParam('image'));
             $plain = true;
         } else {
             return $this->norouteAction();
         }
     }
     if (strpos($file, 'medma_avatar') !== false) {
         $path = Mage::getBaseDir('media') . DS . 'medma_avatar' . DS;
     } else {
         $path = Mage::getBaseDir('media') . DS . 'customer';
     }
     $ioFile = new Varien_Io_File();
     $ioFile->open(array('path' => $path));
     $fileName = $ioFile->getCleanPath($path . $file);
     $path = $ioFile->getCleanPath($path);
     if ((!$ioFile->fileExists($fileName) || strpos($fileName, $path) !== 0) && !Mage::helper('core/file_storage')->processStorageFile(str_replace('/', DS, $fileName))) {
         return $this->norouteAction();
     }
     if ($plain) {
         $extension = pathinfo($fileName, PATHINFO_EXTENSION);
         switch (strtolower($extension)) {
             case 'gif':
                 $contentType = 'image/gif';
                 break;
             case 'jpg':
                 $contentType = 'image/jpeg';
                 break;
             case 'png':
                 $contentType = 'image/png';
                 break;
             default:
                 $contentType = 'application/octet-stream';
                 break;
         }
         $ioFile->streamOpen($fileName, 'r');
         $contentLength = $ioFile->streamStat('size');
         $contentModify = $ioFile->streamStat('mtime');
         $this->getResponse()->setHttpResponseCode(200)->setHeader('Pragma', 'public', true)->setHeader('Content-type', $contentType, true)->setHeader('Content-Length', $contentLength)->setHeader('Last-Modified', date('r', $contentModify))->clearBody();
         $this->getResponse()->sendHeaders();
         while (false !== ($buffer = $ioFile->streamRead())) {
             echo $buffer;
         }
     } else {
         $name = pathinfo($fileName, PATHINFO_BASENAME);
         $this->_prepareDownloadResponse($name, array('type' => 'filename', 'value' => $fileName));
     }
     exit;
 }
示例#2
0
 protected function _beforeSave()
 {
     $io = new Varien_Io_File();
     $realPath = $io->getCleanPath(Mage::getBaseDir() . '/' . $this->getSitemapPath());
     /**
      * Check path is allow
      */
     if (!$io->allowedPath($realPath, Mage::getBaseDir())) {
         Mage::throwException(Mage::helper('sitemap')->__('Please define correct path'));
     }
     /**
      * Check exists and writeable path
      */
     if (!$io->fileExists($realPath, false)) {
         Mage::throwException(Mage::helper('sitemap')->__('Please create the specified folder "%s" before saving the sitemap.', Mage::helper('core')->htmlEscape($this->getSitemapPath())));
     }
     if (!$io->isWriteable($realPath)) {
         Mage::throwException(Mage::helper('sitemap')->__('Please make sure that "%s" is writable by web-server.', $this->getSitemapPath()));
     }
     /**
      * Check allow filename
      */
     if (!preg_match('#^[a-zA-Z0-9_\\.]+$#', $this->getSitemapFilename())) {
         Mage::throwException(Mage::helper('sitemap')->__('Please use only letters (a-z or A-Z), numbers (0-9) or underscore (_) in the filename. No spaces or other characters are allowed.'));
     }
     if (!preg_match('#\\.xml$#', $this->getSitemapFilename())) {
         $this->setSitemapFilename($this->getSitemapFilename() . '.xml');
     }
     $this->setSitemapPath(rtrim(str_replace(str_replace('\\', '/', Mage::getBaseDir()), '', $realPath), '/') . '/');
     return parent::_beforeSave();
 }
示例#3
0
 protected function open($write = false)
 {
     $ioAdapter = new Varien_Io_File();
     try {
         $path = $ioAdapter->getCleanPath($this->getPath());
         $ioAdapter->checkAndCreateFolder($path);
         $filePath = $path . DS . $this->getFileName();
     } catch (Exception $e) {
         Mage::helper('mailchimp')->addException($e);
     }
     if ($write && $ioAdapter->fileExists($filePath)) {
         $ioAdapter->rm($filePath);
     }
     if (!$write && !$ioAdapter->fileExists($filePath)) {
         $message = Mage::helper('mailchimp')->__('File "%s" does not exist.', $this->getFileName());
         Mage::getSingleton('adminhtml/session')->addError($this->__('Mailchimp General Error: ') . $message);
     }
     $mode = $write ? 'wb' . self::COMPRESS_RATE : 'rb';
     try {
         $this->_handler = gzopen($filePath, $mode);
     } catch (Exception $e) {
         Mage::helper('mailchimp')->addException($e);
     }
     return $this;
 }
 protected function _removeOldFiles()
 {
     $io = new Varien_Io_File();
     $realPath = $io->getCleanPath($this->getPath());
     $fileName = $this->getSitemapFilename();
     $pos = strpos($fileName, ".xml");
     $noExtensionFileName = substr($fileName, 0, $pos);
     $fullFilePath = $realPath . $noExtensionFileName . "_*";
     array_map("unlink", glob($fullFilePath));
 }
示例#5
0
 public function _ToHtml()
 {
     $txt = null;
     $i = 0;
     $io = new Varien_Io_File();
     $realPath = $io->getCleanPath(Mage::getBaseDir() . $this->getRequest()->getParam('file'));
     $io->streamOpen($realPath, "r+");
     while (false !== ($line = $io->streamRead())) {
         if (stripos($line, str_replace('__', '&', $this->getRequest()->getParam('s'))) !== FALSE) {
             $txt .= $line;
         }
     }
     return $txt;
 }
示例#6
0
 /**
  * Create new sitemap file
  *
  * @param string $fileName
  * @param string $type
  * @return void
  */
 protected function _createSitemap($fileName = null, $type = self::TYPE_URL)
 {
     if (!$fileName) {
         $this->_sitemapIncrement++;
         $fileName = $this->_getCurrentSitemapFilename($this->_sitemapIncrement);
     }
     $this->_fileHandler = $this->_getFileObject();
     $this->_fileHandler->setAllowCreateFolders(true);
     $path = $this->_fileHandler->getCleanPath($this->_getBaseDir() . $this->getSitemapPath());
     $this->_fileHandler->open(array('path' => $path));
     if ($this->_fileHandler->fileExists($fileName) && !$this->_fileHandler->isWriteable($fileName)) {
         Mage::throwException(Mage::helper('Mage_Sitemap_Helper_Data')->__('File "%s" cannot be saved. Please, make sure the directory "%s" is writable by web server.', $fileName, $path));
     }
     $fileHeader = sprintf($this->_tags[$type][self::OPEN_TAG_KEY], $type);
     $this->_fileHandler->streamOpen($fileName);
     $this->_fileHandler->streamWrite($fileHeader);
     $this->_fileSize = strlen($fileHeader . sprintf($this->_tags[$type][self::CLOSE_TAG_KEY], $type));
 }
示例#7
0
 public function loadfileAction()
 {
     $tmp_file = $this->getRequest()->getParam('file');
     if ($this->getRequest()->getParam('file_system_type') === "1") {
         $content = $this->downloadFile();
         if (is_array($content)) {
             $rtn['status'] = 'error';
             $rtn['body'] = $content[0];
             die(json_encode($rtn));
         } else {
             $tmp_file = $content;
         }
     }
     $io = new Varien_Io_File();
     $realPath = $io->getCleanPath(Mage::getBaseDir() . '/' . $tmp_file);
     if ($tmp_file == '') {
         $rtn['status'] = 'error';
         $rtn['body'] = Mage::helper('massstockupdate')->__('File path can\'t be empty.');
     } elseif (stripos($tmp_file, 'csv') < 1 && stripos($tmp_file, 'xml') < 1) {
         $rtn['status'] = 'error';
         $rtn['body'] = Mage::helper('massstockupdate')->__('Wrong file type. "%s" must be a csv or xml file.', $realPath);
     } elseif (!$io->fileExists($realPath, false)) {
         $rtn['status'] = 'error';
         $rtn['body'] = Mage::helper('massstockupdate')->__('Wrong file path. "%s" is not a file.', $realPath);
     } elseif (!is_readable($realPath)) {
         $rtn['status'] = 'error';
         $rtn['body'] = Mage::helper('massstockupdate')->__('Please make sure that "%s" is readable by web-server.', $realPath);
     } else {
         $rtn['status'] = 'valid';
         if ($this->getRequest()->getParam('file_type') == 1) {
             // xml
             $csv_file = $this->transformXmlToCsv($realPath, $this->getRequest()->getParam('xpath'), 1000);
             if (is_array($csv_file)) {
                 $rtn['status'] = 'error';
                 $rtn['body'] = $csv_file[0];
                 die(json_encode($rtn));
             }
             $realPath = $io->getCleanPath(Mage::getBaseDir() . '/' . $csv_file);
         }
         if ($this->getRequest()->getParam('file_type') === "1") {
             $fileSeparator = ";";
             $fileEnclosure = "none";
         } else {
             $fileSeparator = $this->getRequest()->getParam('separator');
             $fileEnclosure = $this->getRequest()->getParam('enclosure');
         }
         $io->streamOpen($realPath, 'r');
         $rtn = array();
         $i = 0;
         if (Mage::helper('core')->isModuleEnabled('Wyomind_Advancedinventory')) {
             $places = Mage::getModel('pointofsale/pointofsale')->getPlaces();
             foreach ($places as $p) {
                 $rtn["places"][$i]['label'] = $p->getName();
                 $rtn["places"][$i]['value'] = $p->getPlaceId();
                 $rtn["places"][$i]['id'] = $p->getPlaceId();
                 $rtn["places"][$i]['style'] = "store " . $p->getPlaceId();
                 $i++;
             }
             $rtn["places"][$i]['label'] = "Manage Local Stock";
             $rtn["places"][$i]['value'] = "manage_local_stock";
             $rtn["places"][$i]['id'] = 'manage_local_stock';
             $rtn["places"][$i]['style'] = "manage_local_stock";
             $i++;
         }
         if ($this->getRequest()->getParam('autoSetInStock') == "0") {
             $rtn["places"][$i]['label'] = "Stock status";
             $rtn["places"][$i]['value'] = "is_in_stock";
             $rtn["places"][$i]['id'] = 'is_in_stock';
             $rtn["places"][$i]['style'] = "is_in_stock";
             $i++;
         }
         /* if ($this->getRequest()->getParam('autoSetManageStock') == "0") {
            $rtn["places"][$i]['label'] = "Manage stock";
            $rtn["places"][$i]['value'] = "manage_stock";
            $rtn["places"][$i]['id'] = 'manage_stock';
            $rtn["places"][$i]['style'] = "manage_stock";
            $i++;
            } */
         // if total stock are not sync with local stocks or  if total stock are sync with local stocks but sync is done by user
         if ($this->getRequest()->getParam('autoSetTotal') == "0") {
             $rtn["places"][$i]['label'] = "Total Stock";
             $rtn["places"][$i]['value'] = "total";
             $rtn["places"][$i]['id'] = 'total';
             $rtn["places"][$i]['style'] = "total";
             $i++;
         } else {
             $rtn["places"][$i]['label'] = "used";
             $rtn["places"][$i]['value'] = "used";
             $rtn["places"][$i]['id'] = 'used';
             $rtn["places"][$i]['style'] = "used";
             $i++;
         }
         $resource = Mage::getSingleton('core/resource');
         $read = $resource->getConnection('core_read');
         $tableEet = $resource->getTableName('eav_entity_type');
         $select = $read->select()->from($tableEet)->where('entity_type_code=\'catalog_product\'');
         $data = $read->fetchAll($select);
         $typeId = $data[0]['entity_type_id'];
         function cmp($a, $b)
         {
             return $a['attribute_code'] < $b['attribute_code'] ? -1 : 1;
         }
         /*  Liste des  attributs disponible dans la bdd */
         $attributesList = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter($typeId)->addSetInfo()->getData();
         usort($attributesList, "cmp");
         foreach ($attributesList as $attribute) {
             if (!empty($attribute['frontend_label'])) {
                 $rtn["places"][$i]['label'] = $attribute['attribute_code'];
                 $rtn["places"][$i]['value'] = $attribute['attribute_code'];
                 $rtn["places"][$i]['id'] = "attribute-" . $attribute['attribute_code'] . "-" . $attribute['attribute_id'] . "-" . $attribute['backend_type'];
                 $rtn["places"][$i]['style'] = "attribute";
                 $i++;
             }
         }
         $rtn["places"][$i]['label'] = "not used";
         $rtn["places"][$i]['value'] = "not-used";
         $rtn["places"][$i]['id'] = 'not-used';
         $rtn["places"][$i]['style'] = "not-used";
         $i++;
         $sku_offset = $this->getRequest()->getParam('skuOffset');
         $offset = $sku_offset - 1;
         $l = 0;
         if ($fileEnclosure != "none") {
             while (false !== ($csvLine = $io->streamReadCsv($fileSeparator, $fileEnclosure)) && $l < 1000) {
                 $skus = array_splice($csvLine, $offset, 1);
                 array_unshift($csvLine, $skus[0]);
                 if (strlen($csvLine[0]) > 50) {
                     $csvLine[0] = '<span title="' . $csvLine[0] . '">' . substr($csvLine[0], 0, 50) . '...' . '</span>';
                 }
                 $rtn['body'][$l] = $csvLine;
                 $rtn['body'][$l][] = 0;
                 $l++;
             }
         } else {
             while (false !== ($csvLine = $io->streamReadCsv($fileSeparator)) && $l < 1000) {
                 $skus = array_splice($csvLine, $offset, 1);
                 array_unshift($csvLine, $skus[0]);
                 if (strlen($csvLine[0]) > 50) {
                     $csvLine[0] = '<span title="' . $csvLine[0] . '">' . substr($csvLine[0], 0, 50) . '...' . '</span>';
                 }
                 $rtn['body'][$l] = $csvLine;
                 $rtn['body'][$l][] = 0;
                 $l++;
             }
         }
         $io->streamClose();
         if ($this->getRequest()->getParam('useCustomRules')) {
             $rules = $this->getRequest()->getParam('customRules');
             foreach ($rtn['body'] as $i => $line) {
                 eval(str_replace('$C[', '$line[', $rules));
                 $rtn['body'][$i] = $line;
             }
         }
     }
     die(json_encode($rtn));
 }
 protected function _beforeSave()
 {
     $x147 = "str_replace";
     $x148 = "utf8_encode";
     $x149 = "preg_match_all";
     $x14a = "preg_match";
     $x14b = "is_null";
     $x14c = "number_format";
     $x14d = "is_numeric";
     $x14e = "preg_split";
     $x14f = "utf8_decode";
     $x150 = "is_string";
     $x151 = "json_decode";
     $x152 = "is_array";
     $x153 = "array_push";
     $x154 = "print_r";
     $x155 = "version_compare";
     $x156 = "in_array";
     $x157 = "array_pop";
     $x158 = "str_pad";
     $x159 = "array_shift";
     $x15a = "array_reverse";
     $x15b = "array_values";
     $x15c = "preg_replace";
     $x15d = "strip_tags";
     $x15e = "html_entity_decode";
     $x15f = "mb_strtolower";
     $x160 = "mb_strtoupper";
     $x3a = new Varien_Io_File();
     $x3b = $x3a->getCleanPath(Mage::getBaseDir() . '/' . $this->getSimplegoogleshoppingPath());
     if (!$x3a->fileExists($x3b, false)) {
         Mage::throwException(Mage::helper('simplegoogleshopping')->__('Please create the specified folder %s before saving the googleshopping.', Mage::helper('core')->htmlEscape($this->getSimplegoogleshoppingPath())));
     }
     if (!$x3a->isWriteable($x3b)) {
         Mage::throwException(Mage::helper('simplegoogleshopping')->__('Please make sure that %s is writable by web-server.', $this->getSimplegoogleshoppingPath()));
     }
     if (!$x14a('#^[a-zA-Z0-9_\\-\\.]+$#', $this->x165())) {
         Mage::throwException(Mage::helper('simplegoogleshopping')->__('Please use only letters (a-z or A-Z), numbers (0-9) or underscore (_) in the filename. No spaces or other characters are allowed.'));
     }
     if (!$x14a('#\\.xml$#', $this->getSimplegoogleshoppingFilename())) {
         $this->setSimplegoogleshoppingFilename($this->getSimplegoogleshoppingFilename() . '.xml');
     }
     if (!$this->getSimplegoogleshoppingId() && $this->x164($this->x165())) {
         Mage::throwException(Mage::helper('simplegoogleshopping')->__('This data feed name is already used. Please specify a new one.'));
     }
     $this->setSimplegoogleshoppingPath(rtrim($x147($x147('\\', '/', Mage::getBaseDir()), '', $x3b), '/') . '/');
     return parent::_beforeSave();
 }
示例#9
0
 protected function _beforeSave()
 {
     $io = new Varien_Io_File();
     $pathmap = $this->getHelper()->getGeneralConf($this->getStoreId())->getPathMap();
     if ($pathmap) {
         $pathmap = DS . $pathmap;
     }
     $realPath = $io->getCleanPath(Mage::getBaseDir() . $pathmap . DS . $this->getSitemapPath());
     $realPath_save = $io->getCleanPath(Mage::getBaseDir() . DS . $this->getSitemapPath());
     $_isCompressed = $this->getHelper()->getGeneralConf($this->getStoreId())->getUsecompression();
     /**
      * Check path is allow
      */
     if (!$pathmap) {
         if (!$io->allowedPath($realPath, Mage::getBaseDir())) {
             Mage::throwException(Mage::helper('sitemap')->__('Please define correct path'));
         }
     }
     /**
      * Check exists and writeable path
      */
     if (!$io->fileExists($realPath, false)) {
         Mage::throwException(Mage::helper('sitemap')->__('Please create the specified folder "%s" before saving the sitemap.', Mage::helper('core')->htmlEscape($realPath)));
     }
     if (!$io->isWriteable($realPath)) {
         Mage::throwException(Mage::helper('sitemap')->__('Please make sure that "%s" is writable by web-server.', $realPath));
     }
     /**
      * Check allow filename
      */
     if (!preg_match('#^[a-zA-Z0-9_\\.]+$#', $this->getSitemapFilename())) {
         Mage::throwException(Mage::helper('sitemap')->__('Please use only letters (a-z or A-Z), numbers (0-9) or underscore (_) in the filename. No spaces or other characters are allowed.'));
     }
     if ($_isCompressed) {
         $this->setSitemapFilename($this->getHelper()->clearExtension($this->getSitemapFilename()) . '.xml.gz');
     } else {
         $this->setSitemapFilename($this->getHelper()->clearExtension($this->getSitemapFilename()) . '.xml');
     }
     if (!$this->getHelper()->isUnique($this)) {
         Mage::throwException(Mage::helper('sitemap')->__('Please select another filename/path, as another sitemap with same filename already exists on the specified location.'));
     }
     $this->setSitemapPath(rtrim(str_replace(str_replace('\\', '/', Mage::getBaseDir()), '', $realPath_save), '/') . '/');
     return Mage_Core_Model_Abstract::_beforeSave();
 }
 public function categoriesAction()
 {
     $i = 0;
     $io = new Varien_Io_File();
     $realPath = $io->getCleanPath(Mage::getBaseDir() . "/lib/Google/taxonomy.txt");
     $io->streamOpen($realPath, "r+");
     while (false !== ($line = $io->streamRead())) {
         if (stripos($line, $this->getRequest()->getParam('s')) !== FALSE) {
             echo $line;
         }
     }
     die;
 }
 protected function _beforeSave()
 {
     $io = new Varien_Io_File();
     $io->setAllowCreateFolders(true);
     $pathmap = $this->getConfig()->getPathMap();
     // this is the path that will be used for save the files ( pathmap )
     $realPath = $io->getCleanPath(Mage::getBaseDir() . DS . $this->getSitemapPath());
     // this is the path that will be displayed
     $realPath_db = $realPath;
     if ($pathmap != '') {
         $realPath = $io->getCleanPath(Mage::getBaseDir() . DS . $pathmap . DS . $this->getSitemapPath());
     }
     /**
      * Check exists and writeable path
      */
     if (!$io->fileExists($realPath, false)) {
         if (!$io->checkAndCreateFolder($realPath)) {
             Mage::throwException(Mage::helper('sitemapEnhancedPlus')->__('Please create the specified folder "%s" before saving the sitemap.', Mage::helper('core')->htmlEscape($realPath)));
         }
     }
     if (!$io->isWriteable($realPath)) {
         Mage::throwException(Mage::helper('sitemapEnhancedPlus')->__('Please make sure that "%s" is writable by web-server.', $realPath));
     }
     /**
      * Check allow filename
      */
     if (preg_match('#^[a-zA-Z0-9_\\.]+$#', $this->getSitemapFilename())) {
         //Mage::throwException(Mage::helper('sitemapEnhancedPlus')->__('Please use only letters (a-z or A-Z), numbers (0-9) or underscore (_) in the filename. No spaces or other characters are allowed.'));
     }
     if ($this->getConfig()->getUseCompression()) {
         $this->setSitemapFilename($this->getHelper()->clearExtension($this->getSitemapFilename()) . '.xml.gz');
     } else {
         $this->setSitemapFilename($this->getHelper()->clearExtension($this->getSitemapFilename()) . '.xml');
     }
     if (!$this->getHelper()->isUnique($this)) {
         Mage::throwException(Mage::helper('sitemapEnhancedPlus')->__('Please select another filename/path, as another sitemap with same filename already exists on the specified location.'));
     }
     $this->setSitemapPath(rtrim(str_replace(str_replace('\\', '/', Mage::getBaseDir()), '', $realPath_db), '/') . '/');
     return Mage_Core_Model_Abstract::_beforeSave();
 }
示例#12
0
文件: Import.php 项目: rcclaudrey/dev
 public function importProcess()
 {
     $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";
     Mage::$x83("-------------------- IMPORTATION PROCESS ---------------", null, "MassStockUpate.{$x83}");
     $this->x90();
     $x4a = $this->getFilePath();
     if ($this->getFileSystemType() === "1") {
         $x3b = $this->x91();
         if ($x84($x3b)) {
             $x4b['status'] = 'error';
             $x4b['body'] = $x3b[0];
             die($x85($x4b));
         } else {
             $x4a = $x3b;
         }
     }
     $x31 = new Varien_Io_File();
     $x32 = $x31->getCleanPath(Mage::getBaseDir() . "/" . $x4a);
     if ($this->getFileType() === "1") {
         $x49 = $this->x92($x32, $this->getXpathToProduct());
         if ($x84($x49)) {
             $x4b['status'] = 'error';
             $x4b['body'] = $x49[0];
             die($x85($x4b));
         }
         $x32 = $x31->getCleanPath(Mage::getBaseDir() . '/' . $x49);
     }
     $x31->streamOpen($x32, "r");
     Mage::$x83("--> File opened : " . $x32, null, "MassStockUpate.{$x83}");
     $x4c = $this->getIdentifierCode() ? $this->getIdentifierCode() : "sku";
     $x41 = Mage::getModel("catalog/product")->getCollection()->addAttributeToSelect($x4c);
     foreach ($x41 as $x4d) {
         $this->_products[$x81($x4d->getData($x4c))] = $x4d->getId();
     }
     Mage::$x83("--> Products collected", null, "MassStockUpate.{$x83}");
     if (Mage::helper("core")->isModuleEnabled("Wyomind_Advancedinventory")) {
         $x4e = Mage::getModel("advancedinventory/stock")->getCollection();
         foreach ($x4e as $x4f) {
             $this->_stocks[$x4f->getProductId()] = $x4f->getId();
         }
         Mage::$x83("--> Local stocks collected (Advanced Inventory)", null, "MassStockUpate.{$x83}");
     }
     $x50 = array("ac" => "activation_code", "ak" => "activation_key", "bu" => "base_url", "md" => "md5", "th" => "this", "dm" => "_demo", "ext" => "msi", "ver" => "3.9.2");
     $x51 = Mage::getSingleton("core/resource");
     $x52 = $x51->getConnection("core_read");
     $this->_tables["csi"] = Mage::getSingleton("core/resource")->getTableName("cataloginventory_stock_item");
     if (Mage::helper("core")->isModuleEnabled("Wyomind_Advancedinventory")) {
         $this->_tables["aip"] = Mage::getSingleton("core/resource")->getTableName("advancedinventory_item");
         $this->_tables["ais"] = Mage::getSingleton("core/resource")->getTableName("advancedinventory_stock");
         $x53 = "SELECT MAX(id) AS INC FROM " . $this->_tables["aip"] . " ;";
         $x54 = $x52->fetchAll($x53);
         $this->_autoInc = $x54[0]["INC"];
         Mage::$x83("--> Max increment found #" . $x54[0]["INC"] . "(Advanced Inventory)", null, "MassStockUpate.{$x83}");
     }
     $x55 = array("activation_key" => Mage::getStoreConfig("massstockupdate/license/activation_key"), "activation_code" => Mage::getStoreConfig("massstockupdate/license/activation_code"), "base_url" => Mage::getStoreConfig("web/secure/base_url"));
     $x40 = $x86($this->getMapping());
     foreach ($x40->columns as $x44 => $x56) {
         if (!$x7e($x56->id, array("not-used", "total", "is_in_stock", "manage_local_stock"))) {
             $this->_columns[] = $x56->id;
         } elseif ($x7e($x56->id, array("total"))) {
             $this->_columns[] = "total";
             $this->_total = $x44 + 1;
         } elseif ($x7e($x56->id, array("is_in_stock"))) {
             $this->_columns[] = "is_in_stock";
             $this->_is_in_stock = $x44 + 1;
         } elseif ($x7e($x56->id, array("manage_local_stock"))) {
             $this->_columns[] = "manage_local_stock";
             $this->_manage_local_stock = $x44 + 1;
         } else {
             $this->_columns[] = false;
         }
     }
     Mage::$x83("--> Column mapping analyzed", null, "MassStockUpate.{$x83}");
     if ($x55[$x50["ac"]] != $x50["md"]($x50["md"]($x55[$x50["ak"]]) . $x50["md"]($x55[$x50["bu"]]) . $x50["md"]($x50["ext"]) . $x50["md"]($x50["ver"]))) {
         ${$x50}["ext"] = "valid";
         ${$x50}["th"]->{$x50}["dm"] = true;
     } else {
         ${$x50}["th"]->{$x50}["dm"] = false;
         ${$x50}["ext"] = "valid";
     }
     if (!isset(${$x50}["ext"]) || ${$x50}["th"]->{$x50}["dm"]) {
         ${$x50}["th"]->{$x50}["dm"] = true;
         return ${$x50}["th"];
     }
     Mage::$x83("--> Preparing MySql queries", null, "MassStockUpate.{$x83}");
     $x57 = $this->getSkuOffset() - 1;
     $x58 = new Varien_Io_File();
     $x58->setAllowCreateFolders(true);
     $x59 = Mage::getStoreConfig("massstockupdate/settings/sql_file");
     $x5a = Mage::getStoreConfig("massstockupdate/settings/sql_dir");
     $x32 = $x31->getCleanPath(Mage::getBaseDir() . '/' . $x5a);
     if (!$x58->fileExists($x32, false)) {
         Mage::throwException(Mage::helper('massstockupdate')->__('Please create the specified folder "%s".', $x32));
     }
     if (!$x58->isWriteable($x32)) {
         Mage::throwException(Mage::helper('massstockupdate')->__('Please make sure that "%s" is writable by web-server.', $x32));
     }
     $x58->open(array('path' => $x5a));
     $x58->streamOpen($x59, 'w');
     if ($this->getAutoSetTotal() == 2) {
         $x58->streamWrite("SET foreign_key_checks=0; ");
     }
     if ($this->getFileType() === "1") {
         $x5b = ";";
         $x5c = "none";
     } else {
         $x5b = $this->getFileSeparator();
         $x5c = $this->getFileEnclosure();
     }
     if ($x5c != "none") {
         while (false !== ($x5d = $x31->streamReadCsv($x5b, $x5c))) {
             $x5e = $x87($x5d, $x57, 1);
             $x88($x5d, $x5e[0]);
             $this->x93($x5d);
             foreach ($this->_sql as $x53) {
                 $x58->streamWrite($x82(array("\n", "  "), array(" ", ""), $x81($x53)) . "\n");
             }
         }
     } else {
         while (false !== ($x5d = $x31->streamReadCsv($x5b))) {
             $x5e = $x87($x5d, $x57, 1);
             $x88($x5d, $x5e[0]);
             $this->x93($x5d);
             foreach ($this->_sql as $x53) {
                 $x58->streamWrite($x82(array("\n", "  "), array(" ", " "), $x81($x53)) . "\n");
             }
         }
     }
     Mage::$x83("--> File closed : " . $x32 . $x59, null, "MassStockUpate.{$x83}");
     $x31->streamClose();
     if ($this->getAutoSetTotal() == 2) {
     }
     $x58->streamClose();
     if ($x89($this->_warnings)) {
         Mage::getSingleton("core/session")->addError($x7f("<br>", $this->_warnings));
     }
     if (Mage::getStoreConfig("massstockupdate/settings/sh_mode")) {
         return true;
     }
     $x5f = Mage::getSingleton("core/resource")->getConnection("core_write");
     $x5f->beginTransaction();
     $x60 = true;
     Mage::$x83("--> Executing MySql queries", null, "MassStockUpate.{$x83}");
     $x31 = new Varien_Io_File();
     $x31->streamOpen($x32 . $x59, "r");
     while (false !== ($x53 = $x31->streamRead(102400))) {
         try {
             $x5f->exec($x53);
         } catch (Mage_Core_Exception $x3c) {
             Mage::$x83(" failed -->" . $x53, null, "MassStockUpate.{$x83}");
             $x60 = false;
         } catch (Exception $x3c) {
             Mage::$x83(" failed -->" . $x53, null, "MassStockUpate.{$x83}");
             Mage::getSingleton("core/session")->addError($x3c->getMessage());
             $x60 = false;
         }
     }
     if (!$x60) {
         Mage::$x83("--> MySql Rollback", null, "MassStockUpate.{$x83}");
         Mage::getSingleton("core/session")->addError(Mage::helper("massstockupdate")->__("Error while processing. Rollback happened."));
         $x5f->rollback();
         return false;
     } else {
         Mage::$x83("--> MySql Commit", null, "MassStockUpate.{$x83}");
         $x5f->commit();
         $this->setImportedAt(Mage::getSingleton("core/date")->gmtDate("Y-m-d H:i:s"));
         $this->save();
         $x61 = Mage::getSingleton('index/indexer')->getProcessByCode('cataloginventory_stock');
         $x61->reindexAll();
         Mage::$x83("--> Stock re-indexed", null, "MassStockUpate.{$x83}");
         $x31->open(array('path' => $x5a));
         $x31->rm($x59);
         return true;
     }
 }
示例#13
0
 /**
  * Open backup file (write or read mode)
  *
  * @param string      $mode
  * @param string|null $filePath
  *
  * @throws Mageplace_Backup_Exception
  * @return Mage_Backup_Model_Backup
  */
 public function openGz($mode, $filePath = null)
 {
     if (is_null($this->getPath())) {
         Mage::exception('Mage_Backup', Mage::helper('backup')->__('Backup file path was not specified.'));
     }
     $ioAdapter = new Varien_Io_File();
     if ($filePath === null) {
         try {
             $path = $ioAdapter->getCleanPath($this->getPath());
             $ioAdapter->checkAndCreateFolder($path);
             $filePath = $path . $this->getFileName();
         } catch (Exception $e) {
             throw new Mageplace_Backup_Exception($e->getMessage());
         }
     }
     if ($mode != self::OPEN_MODE_APPEND && $mode != self::OPEN_MODE_WRITE && $mode != self::OPEN_MODE_READ) {
         $mode = self::OPEN_MODE_WRITE;
     }
     if ($mode == self::OPEN_MODE_WRITE && $ioAdapter->fileExists($filePath)) {
         $ioAdapter->rm($filePath);
     }
     if ($mode != self::OPEN_MODE_WRITE && !$ioAdapter->fileExists($filePath)) {
         throw new Mageplace_Backup_Exception(Mage::helper('backup')->__('Backup file "%s" does not exist.', $this->getFileName()));
     }
     $this->_handler = @gzopen($filePath, $mode);
     if (!$this->_handler) {
         throw new Mageplace_Backup_Exception(Mage::helper('backup')->__('Backup file "%s" cannot be read from or written to.', $this->getFileName()));
     }
     return $this;
 }
示例#14
0
 protected function _beforeSave()
 {
     $xb4 = "array_push";
     $xb5 = "count";
     $xb6 = "date";
     $xb7 = "eval";
     $xb8 = "explode";
     $xb9 = "header";
     $xba = "htmlspecialchars";
     $xbb = "html_entity_decode";
     $xbc = "htmlentities";
     $xbd = "in_array";
     $xbe = "implode";
     $xbf = "ini_get";
     $xc0 = "is_bool";
     $xc1 = "is_array";
     $xc2 = "is_null";
     $xc3 = "is_numeric";
     $xc4 = "mb_strtolower";
     $xc5 = "mb_strtoupper";
     $xc6 = "number_format";
     $xc7 = "preg_match";
     $xc8 = "preg_match_all";
     $xc9 = "preg_split";
     $xca = "preg_replace";
     $xcb = "print_r";
     $xcc = "round";
     $xcd = "rtrim";
     $xce = "set_time_limit";
     $xcf = "sprintf";
     $xd0 = "str_replace";
     $xd1 = "strlen";
     $xd2 = "stristr";
     $xd3 = "strip_tags";
     $xd4 = "substr";
     $xd5 = "strrpos";
     $xd6 = "trim";
     $xd7 = "ucwords";
     $xd8 = "utf8_decode";
     $x0b = new Varien_Io_File();
     $x0c = $x0b->getCleanPath(Mage::getBaseDir() . '/' . $this->getFeedPath());
     if (!$x0b->allowedPath($x0c, Mage::getBaseDir())) {
         Mage::throwException(Mage::helper('datafeedmanager')->__('Please define correct path'));
     }
     if (!$x0b->fileExists($x0c, false)) {
         Mage::throwException(Mage::helper('datafeedmanager')->__('Please create the specified folder "%s" before saving the data feed configuration.', Mage::helper('core')->htmlEscape($this->getFeedPath())));
     }
     if (!$x0b->isWriteable($x0c)) {
         Mage::throwException(Mage::helper('datafeedmanager')->__('Please make sure that "%s" is writable by web-server.', $this->getFeedPath()));
     }
     if (!$xc7('#^[a-zA-Z0-9_\\.]+$#', $this->getFeedName())) {
         Mage::throwException(Mage::helper('datafeedmanager')->__('Please use only letters (a-z or A-Z), numbers (0-9) or underscore (_) in the filename. No spaces or other characters are allowed.'));
     }
     $this->setFeedPath($xcd($xd0($xd0('\\', '/', Mage::getBaseDir()), '', $x0c), '/') . '/');
     return parent::_beforeSave();
 }
 protected function _beforeSave()
 {
     $xd6 = "str_replace";
     $xd7 = "utf8_encode";
     $xd8 = "preg_match_all";
     $xd9 = "preg_match";
     $xda = "rtrim";
     $xdb = "is_null";
     $xdc = "count";
     $xdd = "is_numeric";
     $xde = "explode";
     $xdf = "substr";
     $xe0 = "trim";
     $xe1 = "preg_split";
     $xe2 = "strlen";
     $xe3 = "utf8_decode";
     $xe4 = "is_string";
     $xe5 = "json_decode";
     $xe6 = "is_array";
     $xe7 = "header";
     $xe8 = "ucwords";
     $xe9 = "array_push";
     $xea = "print_r";
     $xeb = "version_compare";
     $xec = "in_array";
     $xed = "round";
     $xee = "implode";
     $xef = "sprintf";
     $xf0 = "array_pop";
     $xf1 = "ini_get";
     $xf2 = "set_time_limit";
     $xf3 = "number_format";
     $xf4 = "preg_replace";
     $xf5 = "strip_tags";
     $xf6 = "html_entity_decode";
     $xf7 = "htmlspecialchars";
     $xf8 = "strrpos";
     $xf9 = "stristr";
     $xfa = "mb_strtolower";
     $xfb = "mb_strtoupper";
     $xfc = "htmlentities";
     $x20 = new Varien_Io_File();
     $x21 = $x20->getCleanPath(Mage::getBaseDir() . '/' . $this->getSimplegoogleshoppingPath());
     if (!$x20->allowedPath($x21, Mage::getBaseDir())) {
     }
     if (!$x20->fileExists($x21, false)) {
         Mage::throwException(Mage::helper('simplegoogleshopping')->__('Please create the specified folder "%s" before saving the googleshopping.', Mage::helper('core')->htmlEscape($this->getSimplegoogleshoppingPath())));
     }
     if (!$x20->isWriteable($x21)) {
         Mage::throwException(Mage::helper('simplegoogleshopping')->__('Please make sure that "%s" is writable by web-server.', $this->getSimplegoogleshoppingPath()));
     }
     if (!$xd9('#^[a-zA-Z0-9_\\.]+$#', $this->getSimplegoogleshoppingFilename())) {
         Mage::throwException(Mage::helper('simplegoogleshopping')->__('Please use only letters (a-z or A-Z), numbers (0-9) or underscore (_) in the filename. No spaces or other characters are allowed.'));
     }
     if (!$xd9('#\\.xml$#', $this->getSimplegoogleshoppingFilename())) {
         $this->setSimplegoogleshoppingFilename($this->getSimplegoogleshoppingFilename() . '.xml');
     }
     $this->setSimplegoogleshoppingPath($xda($xd6($xd6('\\', '/', Mage::getBaseDir()), '', $x21), '/') . '/');
     return parent::_beforeSave();
 }
 protected function _beforeSave()
 {
     $x114 = "preg_split";
     $x115 = "implode";
     $x116 = "str_replace";
     $x117 = "utf8_encode";
     $x118 = "preg_match_all";
     $x119 = "preg_match";
     $x11a = "rtrim";
     $x11b = "is_null";
     $x11c = "count";
     $x11d = "is_numeric";
     $x11e = "explode";
     $x11f = "substr";
     $x120 = "trim";
     $x121 = "strlen";
     $x122 = "htmlentities";
     $x123 = "html_entity_decode";
     $x124 = "preg_replace";
     $x125 = "json_decode";
     $x126 = "is_array";
     $x127 = "stristr";
     $x128 = "print_r";
     $x129 = "is_string";
     $x12a = "ucwords";
     $x12b = "array_push";
     $x12c = "version_compare";
     $x12d = "in_array";
     $x12e = "sprintf";
     $x12f = "array_pop";
     $x130 = "ceil";
     $x131 = "ini_get";
     $x132 = "set_time_limit";
     $x133 = "number_format";
     $x134 = "strip_tags";
     $x135 = "htmlspecialchars";
     $x136 = "strrpos";
     $x137 = "is_bool";
     $x138 = "mb_strtolower";
     $x139 = "mb_strtoupper";
     $x13a = "ftp_connect";
     $x13b = "ftp_login";
     $x13c = "ftp_pasv";
     $x13d = "ftp_put";
     $x13e = "ftp_close";
     $x43 = new Varien_Io_File();
     $x44 = $x43->getCleanPath(Mage::getBaseDir() . '/' . $this->getFeedPath());
     if (!$x43->allowedPath($x44, Mage::getBaseDir())) {
         Mage::throwException(Mage::helper('datafeedmanager')->__('Please define correct path'));
     }
     if (!$x43->fileExists($x44, false)) {
         Mage::throwException(Mage::helper('datafeedmanager')->__('Please create the specified folder "%s" before saving the data feed configuration.', Mage::helper('core')->htmlEscape($this->getFeedPath())));
     }
     if (!$x43->isWriteable($x44)) {
         Mage::throwException(Mage::helper('datafeedmanager')->__('Please make sure that "%s" is writable by web-server.', $this->getFeedPath()));
     }
     if (!$x119('#^[a-zA-Z0-9_\\.]+$#', $this->getFeedName())) {
         Mage::throwException(Mage::helper('datafeedmanager')->__('Please use only letters (a-z or A-Z), numbers (0-9) or underscore (_) in the filename. No spaces or other characters are allowed.'));
     }
     $this->setFeedPath($x11a($x116($x116('\\', '/', Mage::getBaseDir()), '', $x44), '/') . '/');
     return parent::_beforeSave();
 }
示例#17
0
 protected function _beforeSave()
 {
     $x11f = "strlen";
     $x120 = "implode";
     $x121 = "str_replace";
     $x122 = "utf8_encode";
     $x123 = "preg_match_all";
     $x124 = "preg_match";
     $x125 = "rtrim";
     $x126 = "is_null";
     $x127 = "number_format";
     $x128 = "count";
     $x129 = "is_numeric";
     $x12a = "explode";
     $x12b = "substr";
     $x12c = "trim";
     $x12d = "preg_split";
     $x12e = "utf8_decode";
     $x12f = "is_string";
     $x130 = "json_decode";
     $x131 = "is_array";
     $x132 = "ucwords";
     $x133 = "array_push";
     $x134 = "print_r";
     $x135 = "version_compare";
     $x136 = "in_array";
     $x137 = "sprintf";
     $x138 = "array_pop";
     $x139 = "ceil";
     $x13a = "ini_get";
     $x13b = "set_time_limit";
     $x13c = "unserialize";
     $x13d = "getType";
     $x13e = "round";
     $x13f = "str_pad";
     $x140 = "abs";
     $x141 = "floor";
     $x142 = "usort";
     $x143 = "array_shift";
     $x144 = "array_reverse";
     $x145 = "array_values";
     $x146 = "preg_replace";
     $x147 = "strip_tags";
     $x148 = "html_entity_decode";
     $x149 = "htmlspecialchars";
     $x14a = "strrpos";
     $x14b = "stristr";
     $x14c = "mb_strtolower";
     $x14d = "mb_strtoupper";
     $x14e = "htmlentities";
     $x3d = new Varien_Io_File();
     $x3e = $x3d->getCleanPath(Mage::getBaseDir() . '/' . $this->getSimplegoogleshoppingPath());
     if (!$x3d->allowedPath($x3e, Mage::getBaseDir())) {
     }
     if (!$x3d->fileExists($x3e, false)) {
         Mage::throwException(Mage::helper('simplegoogleshopping')->__('Please create the specified folder %s before saving the googleshopping.', Mage::helper('core')->htmlEscape($this->getSimplegoogleshoppingPath())));
     }
     if (!$x3d->isWriteable($x3e)) {
         Mage::throwException(Mage::helper('simplegoogleshopping')->__('Please make sure that %s is writable by web-server.', $this->getSimplegoogleshoppingPath()));
     }
     if (!$x124('#^[a-zA-Z0-9_\\.]+$#', $this->getSimplegoogleshoppingFilename())) {
         Mage::throwException(Mage::helper('simplegoogleshopping')->__('Please use only letters (a-z or A-Z), numbers (0-9) or underscore (_) in the filename. No spaces or other characters are allowed.'));
     }
     if (!$x124('#\\.xml$#', $this->getSimplegoogleshoppingFilename())) {
         $this->setSimplegoogleshoppingFilename($this->getSimplegoogleshoppingFilename() . '.xml');
     }
     $this->setSimplegoogleshoppingPath($x125($x121($x121('\\', '/', Mage::getBaseDir()), '', $x3e), '/') . '/');
     return parent::_beforeSave();
 }
示例#18
0
 /**
  * Open backup file (write or read mode)
  *
  * @param bool $write
  * @return Mage_Backup_Model_Backup
  */
 public function open($write = false)
 {
     if (is_null($this->getPath())) {
         Mage::exception('Mage_Backup', Mage::helper('backup')->__('Backup file path was not specified.'));
     }
     $ioAdapter = new Varien_Io_File();
     try {
         $path = $ioAdapter->getCleanPath($this->getPath());
         $ioAdapter->checkAndCreateFolder($path);
         $filePath = $path . DS . $this->getFileName();
     } catch (Exception $e) {
         Mage::exception('Mage_Backup', $e->getMessage());
     }
     if ($write && $ioAdapter->fileExists($filePath)) {
         $ioAdapter->rm($filePath);
     }
     if (!$write && !$ioAdapter->fileExists($filePath)) {
         Mage::exception('Mage_Backup', Mage::helper('backup')->__('Backup file "%s" does not exist.', $this->getFileName()));
     }
     $mode = $write ? 'wb' . self::COMPRESS_RATE : 'rb';
     try {
         $this->_handler = gzopen($filePath, $mode);
     } catch (Exception $e) {
         Mage::exception('Mage_Backup', Mage::helper('backup')->__('Backup file "%s" cannot be read from or written to.', $this->getFileName()));
     }
     return $this;
 }
示例#19
0
 public function uploadThumbnail($thumbnail, $correctFile = null)
 {
     // If no thumbnail specified, use placeholder image
     if (!$thumbnail) {
         // Check if placeholder defined in config
         $isConfigPlaceholder = Mage::getStoreConfig("catalog/placeholder/image_placeholder");
         $configPlaceholder = '/placeholder/' . $isConfigPlaceholder;
         if ($isConfigPlaceholder && file_exists(Mage::getBaseDir('media') . '/catalog/product' . $configPlaceholder)) {
             $thumbnail = Mage::getBaseDir('media') . '/catalog/product' . $configPlaceholder;
         } else {
             // Replace file with skin or default skin placeholder
             $skinBaseDir = Mage::getDesign()->getSkinBaseDir();
             $skinPlaceholder = "/images/catalog/product/placeholder/image.jpg";
             $thumbnail = $skinPlaceholder;
             if (file_exists($skinBaseDir . $thumbnail)) {
                 $baseDir = $skinBaseDir;
             } else {
                 $baseDir = Mage::getDesign()->getSkinBaseDir(array('_theme' => 'default'));
                 if (!file_exists($baseDir . $thumbnail)) {
                     $baseDir = Mage::getDesign()->getSkinBaseDir(array('_theme' => 'default', '_package' => 'base'));
                 }
                 if (!file_exists($baseDir . $thumbnail)) {
                     $baseDir = Mage::getDesign()->getSkinBaseDir(array('_theme' => 'default', '_package' => 'default'));
                 }
             }
             $thumbnail = str_replace('adminhtml', 'frontend', $baseDir) . $thumbnail;
         }
     }
     if (!$correctFile) {
         $correctFile = basename($thumbnail);
     }
     $tempFile = null;
     if (Mage::helper('videogallery')->isUrl($thumbnail)) {
         // Get Temporary location where we can save thumbnail to
         $adapter = new Varien_Io_File();
         $tempFile = $adapter->getCleanPath(Mage::getBaseDir('tmp')) . $correctFile;
         // Download to the temp location
         $thumbData = Mage::helper('videogallery')->file_get_contents_curl($thumbnail);
         @file_put_contents($tempFile, $thumbData);
         @chmod($tempFile, 0777);
         unset($thumbData);
         $thumbnail = $tempFile;
     }
     // Getting ready to download and save thumbnail
     $fileName = Varien_File_Uploader::getCorrectFileName($correctFile);
     $dispretionPath = Varien_File_Uploader::getDispretionPath($fileName);
     //$fileName       = $dispretionPath . DS . $fileName;
     $fileName = $dispretionPath . DS . Varien_File_Uploader::getNewFileName($this->_getConfig()->getMediaPath($fileName));
     $ioAdapter = new Varien_Io_File();
     $ioAdapter->setAllowCreateFolders(true);
     $destinationDirectory = dirname($this->_getConfig()->getMediaPath($fileName));
     try {
         $ioAdapter->open(array('path' => $destinationDirectory));
         if (!$ioAdapter->cp($thumbnail, $this->_getConfig()->getMediaPath($fileName))) {
             return false;
         }
         $ioAdapter->chmod($this->_getConfig()->getMediaPath($fileName), 0777);
         if ($tempFile) {
             $ioAdapter->rm($tempFile);
         }
     } catch (Exception $e) {
         Mage::throwException(Mage::helper('videogallery')->__($e->getMessage()));
     }
     $fileName = str_replace(DS, '/', $fileName);
     return $fileName;
 }