Пример #1
0
 /**
  * this method gets json-formatted response from remote server and write it to cache
  * @return array
  */
 private function _getUpdateInfo()
 {
     $el = $this->getExtensionsList();
     $this->load->model('tool/mp_api');
     $url = $this->model_tool_mp_api->getMPURL() . '?rt=a/product/updates';
     $url .= "&store_id=" . UNIQUE_ID;
     $url .= "&store_ip=" . $_SERVER['SERVER_ADDR'];
     $url .= "&store_url=" . HTTP_SERVER;
     $url .= "&software_name=AbanteCart";
     $url .= "&software_version=" . VERSION;
     $url .= "&language_code=" . $this->request->cookie['language'];
     foreach ($el as $key => $extension) {
         $url .= '&extensions[' . $key . ']=' . $extension['version'];
     }
     //do connect without any http-redirects
     $pack = new AConnect(true, true);
     $info = $pack->getData($url);
     // get array with updates information
     if ($info) {
         return $info;
     }
     return array();
 }
Пример #2
0
 public function updateCurrencies()
 {
     if (extension_loaded('curl')) {
         $data = array();
         $query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t   FROM " . DB_PREFIX . "currencies\n\t\t\t\t\t\t\t\t\t   WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "'\n\t\t\t\t\t\t\t\t\t        AND date_modified > '" . date(strtotime('-1 day')) . "'");
         foreach ($query->rows as $result) {
             $data[] = $this->config->get('config_currency') . $result['code'] . '=X';
         }
         $url = 'http://download.finance.yahoo.com/d/quotes.csv?s=' . implode(',', $data) . '&f=sl1&e=.csv';
         $connect = new AConnect(true);
         $content = $connect->getData($url);
         $lines = explode("\n", trim($content));
         foreach ($lines as $line) {
             $currency = substr($line, 4, 3);
             $value = substr($line, 11, 6);
             if ((double) $value) {
                 $sql = "UPDATE " . DB_PREFIX . "currencies\n\t\t\t\t\t\t\t\t\t  SET value = '" . (double) $value . "', date_modified = NOW()\n\t\t\t\t\t\t\t\t\t  WHERE code = '" . $this->db->escape($currency) . "'";
                 $this->db->query($sql);
             }
         }
         $sql = "UPDATE " . DB_PREFIX . "currencies\n\t\t\t\t\t\t\t  SET value = '1.00000',\n\t\t\t\t\t\t\t      date_modified = NOW()\n\t\t\t\t\t\t\t  WHERE code = '" . $this->db->escape($this->config->get('config_currency')) . "'";
         $this->db->query($sql);
         $this->cache->delete('currency');
     }
 }