예제 #1
0
 /**
  * @param string $url
  * @param boolean $save
  * @param string $new_file_name
  * @return boolean|array
  */
 public function getRemoteFile($url, $save = true, $new_file_name = '')
 {
     if (!$url) {
         return false;
     }
     $file = new AConnect();
     if ($save) {
         $result = $file->getFile($url, $new_file_name);
         //download
     } else {
         $result = $file->getResponse($url);
         // just get data
     }
     if (!$result) {
         $this->error = $file->error;
         return false;
     }
     return $result;
 }
 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);
 }
예제 #3
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();
 }