Пример #1
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');
     }
 }
Пример #2
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();
 }
 public function main()
 {
     $href = '/mp_api2';
     $GET = $this->request->get;
     // if set subfolder for request(seo requests) - concatenate it to url
     if (isset($GET['path'])) {
         $href .= $GET['path'];
         unset($GET['path']);
     }
     $unset = array('s', 'rt', 'token', 'path', 'store_id', 'store_ip', 'store_url', 'store_version', 'language_code');
     foreach ($unset as $key) {
         unset($GET[$key]);
     }
     $GET['store_id'] = UNIQUE_ID;
     $GET['store_ip'] = $_SERVER['SERVER_ADDR'];
     $GET['store_url'] = HTTP_SERVER;
     $GET['store_version'] = VERSION;
     $GET['language_code'] = $this->request->cookie['language'];
     // place your affiliate id here
     define('MP_AFFILIATE_ID', '');
     if (MP_AFFILIATE_ID) {
         $GET['aff_id'] = MP_AFFILIATE_ID;
     }
     $href .= '?' . http_build_query($GET);
     $connect = new AConnect();
     $html = $connect->getResponse($href);
     if (!$html) {
         $this->loadLanguage('extension/extensions_store', 'silent');
         $error = is_array($connect->error) ? $connect->error : array($connect->error);
         foreach ($error as $err) {
             $this->log->write($err);
         }
         $html = '<div style="padding: 10px 10px 10px 20px;	margin-bottom: 15px; background: #FFDFE0 !important;	border: 1px solid #FF9999;	font-size: 12px;">' . $this->language->get('error_connect') . '</div>';
     } else {
         //then parse response
         // get base href and remove it from response
         preg_match('/\\<base.*?href=(\\")(.*?)(\\")/is', $html, $basehref);
         $basehref = $basehref[2];
         $html = str_replace('<base href="' . $basehref . '" />', '', $html);
         // then replace relative url by absolute (css, js, img)
         $html = str_replace('<link href="/', '<link href="' . $basehref, $html);
         $html = str_replace(' src="/', ' src="' . $basehref, $html);
         // then need to replace url of http-links except anchors and absolute urls
         preg_match_all('/href=(\\")(.*?)(\\")/i', $html, $orig_hrefs);
         for ($i = 0; $i < count($orig_hrefs[0]); $i++) {
             $replace = $orig_hrefs[0][$i];
             $ohref = $orig_hrefs[2][$i];
             $link1 = 'href="' . AEncryption::addEncoded_stid($ohref) . (MP_AFFILIATE_ID ? '&aff_id=' . MP_AFFILIATE_ID : '') . '"';
             $link2 = 'href="' . $this->html->getSecureUrl('tool/extensions_store', '&path=' . $ohref . (MP_AFFILIATE_ID ? '&aff_id=' . MP_AFFILIATE_ID : '')) . '"';
             if (substr($ohref, 0, 4) == 'http' || substr($ohref, 0, 1) == '#') {
                 $html = str_replace($replace, $link1, $html);
             } else {
                 $html = str_replace($replace, $link2, $html);
             }
         }
         // construct action for search form
         $action = $this->html->getSecureUrl('tool/extensions_store', MP_AFFILIATE_ID ? '&aff_id=' . MP_AFFILIATE_ID : '');
         $html = str_replace(' action="/', ' action="' . $action, $html);
         $hidden = '<input type="hidden" name="search_performed" value="Y">';
         $hidden .= '<input type="hidden" name="rt" value="tool/extensions_store">';
         $hidden .= '<input type="hidden" name="s" value="' . ADMIN_PATH . '">';
         $hidden .= '<input type="hidden" name="token" value="' . $this->request->get['token'] . '">';
         $hidden .= '<input type="hidden" name="aff_id" value="' . MP_AFFILIATE_ID . '">';
         $html = preg_replace('/<input.*name="search_performed".*>/', $hidden, $html);
         $html = $this->html->convertLinks($html);
         $html = str_replace('<span>Store ID</span>', '<span><font size="1"> ' . UNIQUE_ID . '</font></span>', $html);
     }
     $this->response->setOutput($html);
 }
Пример #4
0
 private function _run_task()
 {
     $connect = new AConnect(true);
     $url = $this->config->get('config_url') . 'task.php';
     $connect->getDataHeaders($url);
 }
Пример #5
0
 public function main()
 {
     // disable for login-logout pages
     if (in_array($this->request->get['rt'], array('index/logout', 'index/login'))) {
         unset($this->session->data['ant_messages']);
         return null;
     }
     if (!has_value($this->session->data['ant_messages']['date_modified'])) {
         unset($this->session->data['ant_messages']);
     }
     // prevent repeats of requests or if last update older then 24hours
     if (has_value($this->session->data['ant_messages']) && time() - $this->session->data['ant_messages']['date_modified'] < 86400) {
         return null;
     }
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $url = "/?option=com_antresponses&format=raw";
     $url .= "&store_id=" . UNIQUE_ID;
     $url .= "&store_ip=" . $_SERVER['SERVER_ADDR'];
     $url .= "&store_url=" . HTTP_SERVER;
     $url .= "&software_name=AbanteCart";
     $url .= "&store_version=" . VERSION;
     $url .= "&language_code=" . $this->request->cookie['language'];
     if ($this->request->cookie['new_cart']) {
         $url .= "&new_cart=1";
         setcookie("new_cart", 0, 0, "/");
     }
     //send extension info
     $extensions_list = $this->extensions->getExtensionsList();
     if ($extensions_list) {
         foreach ($extensions_list->rows as $ext) {
             $url .= "&extension[]=" . $ext['key'] . "~" . $ext['version'];
         }
     }
     //do connect without any http-redirects
     $connect = new AConnect(true, true);
     $result = $connect->getResponse($url);
     $this->session->data['ant_messages'] = array();
     // prevent requests in future at this session
     // insert new messages in database
     if ($result && is_array($result)) {
         //set array for check response
         $check_array = array('message_id', 'type', 'date_added', 'date_modified', 'start_date', 'end_date', 'priority', 'title', 'description', 'version', 'prior_version', 'html', 'url', 'published', 'language_code');
         $banners = array();
         foreach ($result as $notify) {
             $tmp = array();
             foreach ($notify as $key => $value) {
                 if (!in_array($key, $check_array)) {
                     continue;
                 }
                 $tmp[$key] = $value;
             }
             // lets insert
             switch ($tmp['type']) {
                 case 'W':
                     $this->messages->saveWarning($tmp['title'], $tmp['description']);
                     break;
                 case 'E':
                     $this->messages->saveError($tmp['title'], $tmp['description']);
                     break;
                 case 'B':
                     $banners[] = $tmp['message_id'];
                     $this->messages->saveANTMessage($tmp);
                     break;
                 default:
                     $this->messages->saveNotice($tmp['title'], $tmp['description']);
                     break;
             }
         }
         // purge messages except just saved
         $this->messages->purgeANTMessages($banners);
     }
     // in case when answer from server is empty
     $this->session->data['ant_messages']['date_modified'] = time();
     // check for extensions updates
     $this->loadModel('tool/updater');
     $this->model_tool_updater->check4updates();
 }
Пример #6
0
 /**
  * @param string $url
  * @return bool|string
  */
 public function getRemoteFileHeaders($url)
 {
     if (!$url) {
         return false;
     }
     $file = new AConnect();
     $file->connect_method = 'socket';
     //use this method because curl returns no header 'Content-Disposition' with file name
     $url = $url . (!is_int(strpos($url, '?')) ? '?file_size=1' : '&file_size=1');
     $result = $file->getDataHeaders($url);
     if (!$result) {
         $this->error = $file->error;
         return false;
     }
     return $result;
 }
Пример #7
0
 /**
  * this method download xml-file with updates info from remote server.
  * @return boolean
  */
 private function getUpdateInfo()
 {
     if (file_exists($this->updates_path . 'updates.xml')) {
         unlink($this->updates_path . 'updates.xml');
     }
     $pack = new AConnect();
     $info = $pack->getFile($this->updates_url, $this->updates_path . 'updates.xml');
     // get xml-file with updates information
     if ($info) {
         return true;
     }
     return false;
 }