예제 #1
0
 public static function send()
 {
     $sql = 'SELECT `id_ebay_stat`, `tries`, `version`, `data`, `date_add`
         FROM ' . _DB_PREFIX_ . 'ebay_stat';
     $res = Db::getInstance()->executeS($sql);
     foreach ($res as $row) {
         $data = array('version' => $row['version'], 'data' => Tools::stripslashes($row['data']), 'date' => $row['date_add'], 'sig' => EbayStat::_computeSignature($row['version'], Tools::stripslashes($row['data']), $row['date_add']));
         $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => http_build_query($data)));
         $context = stream_context_create($opts);
         $ret = Tools::file_get_contents(self::$server . '/stats.php', false, $context);
         if ($ret == 'OK' || $row['tries'] > 0) {
             // if upload is OK or if it's the second try already
             $sql = 'DELETE FROM `' . _DB_PREFIX_ . 'ebay_stat`
                 WHERE `id_ebay_stat` = ' . (int) $row['id_ebay_stat'];
         } else {
             $sql = 'UPDATE `' . _DB_PREFIX_ . 'ebay_stat`
                 SET `tries` = `tries` + 1
                 WHERE `id_ebay_stat` = ' . (int) $row['id_ebay_stat'];
         }
         Db::getInstance()->execute($sql);
     }
 }
예제 #2
0
 /**
  * Main Form Method
  *
  */
 public function getContent()
 {
     if ($this->ebay_profile && !Configuration::get('EBAY_CATEGORY_MULTI_SKU_UPDATE')) {
         $ebay = new EbayRequest();
         EbayCategory::updateCategoryTable($ebay->getCategoriesSkuCompliancy());
     }
     if (Tools::getValue('refresh_store_cat')) {
         $ebay = new EbayRequest();
         EbayStoreCategory::updateStoreCategoryTable($ebay->getStoreCategories(), $this->ebay_profile);
     }
     if ($this->ebay_profile) {
         $this->ebay_profile->loadStoreCategories();
     }
     // Checking Extension
     if (!extension_loaded('curl') || !ini_get('allow_url_fopen')) {
         if (!extension_loaded('curl') && !ini_get('allow_url_fopen')) {
             return $this->html . $this->displayError($this->l('You must enable cURL extension and allow_url_fopen option on your server if you want to use this module.'));
         } elseif (!extension_loaded('curl')) {
             return $this->html . $this->displayError($this->l('You must enable cURL extension on your server if you want to use this module.'));
         } elseif (!ini_get('allow_url_fopen')) {
             return $this->html . $this->displayError($this->l('You must enable allow_url_fopen option on your server if you want to use this module.'));
         }
     }
     // If isset Post Var, post process else display form
     if (!empty($_POST) && (Tools::isSubmit('submitSave') || Tools::isSubmit('btnSubmitSyncAndPublish') || Tools::isSubmit('btnSubmitSync'))) {
         $errors = $this->_postValidation();
         if (!count($errors)) {
             $this->_postProcess();
         } else {
             foreach ($errors as $error) {
                 $this->html .= '<div class="alert error"><img src="../modules/ebay/views/img/forbbiden.gif" alt="nok" />&nbsp;' . $error . '</div>';
             }
         }
         if (Configuration::get('EBAY_SEND_STATS')) {
             $ebay_stat = new EbayStat($this->stats_version, $this->ebay_profile);
             $ebay_stat->save();
         }
     }
     $this->html .= $this->_displayForm();
     // Set old Context Shop
     /* RAPH
     		if (version_compare(_PS_VERSION_, '1.5', '>') && Shop::isFeatureActive())
     			$this->_setContextShop($old_context_shop);
     		*/
     return $this->html;
 }