function output()
 {
     global $application;
     $request = $application->getInstance('Request');
     $ext_name = $request->getValueByKey('ext_name');
     $update = $request->getValueByKey('update');
     $reset = $request->getValueByKey('reset');
     $upgrade = $request->getValueByKey('upgrade');
     $isReset = isset($reset) ? true : false;
     $isUpgrade = isset($upgrade) ? true : false;
     if ($isReset) {
         $this->resetExtensionDetails($ext_name);
         return;
     }
     if (isset($ext_name)) {
         $extensionDetail = $this->getExtensionDetail($ext_name);
         if ($extensionDetail == false) {
             loadCoreFile('bouncer.php');
             $bnc = new Bouncer();
             $bnc->setMethod('POST');
             $data = modApiFunc("Extension_Manager", 'getLicenseDetail');
             $data['ext_name'] = $ext_name;
             if (isset($update)) {
                 $data['previous'] = $isUpgrade;
             }
             $bnc->setPOSTstring($bnc->prepareDATAstring($data));
             $bnc->setURL($application->getAppIni('MARKETPLACE_SERVER') . '/download_extension.php?asc_action=GetExtensionDetails');
             $bnc->setProto('HTTPS');
             $result = $bnc->RunRequest();
             if ($result != false && $bnc->responseCode < 400) {
                 $response = unserialize($result['body']);
                 if (isset($response) && !empty($response)) {
                     $this->setExtensionDetails($ext_name, $response);
                     return $response;
                 }
                 return $this->noOutput('A server connection error has occurred.  Please try again in a few moments');
             }
         } else {
             return $extensionDetail;
         }
     }
     $this->noOutput();
 }
 function onAction()
 {
     global $application;
     $request = $_POST;
     $_state = modApiFunc("License", "checkLicense");
     $licenseInfo = modApiFunc("License", "getLicenseInfo", $_state);
     if (class_exists('ZipArchive')) {
         $this->marketplace_server = $application->getAppIni('MARKETPLACE_SERVER');
         $data = array('license' => $licenseInfo["license_key"], 'store_url' => $_SERVER['HTTP_HOST'] . $_SERVER['CONTEXT_PREFIX'], 'store_version' => PRODUCT_VERSION_NUMBER);
         loadCoreFile('bouncer.php');
         $bnc = new Bouncer();
         $bnc->setMethod('POST');
         $bnc->setPOSTstring($bnc->prepareDATAstring($data));
         $bnc->setURL($this->marketplace_server . "/download_extension.php?asc_action=SendLatestCoreFile");
         $bnc->setProto('HTTPS');
         $result = $bnc->RunRequest();
         $response = $result['body'];
         if ($response != false && $bnc->responseCode < 400) {
             if (strpos($response, "ERR_") === 0) {
                 modApiFunc("Session", "set", "ErrorMessage", $response);
             } else {
                 $file = fopen($application->getAppIni('PATH_CACHE_DIR') . "avactis-upgrade.zip", 'w+');
                 fwrite($file, $response);
                 fclose($file);
                 $core_response = modApiFunc("Extension_Manager", "upgradeCore");
                 if (strpos($core_response, "ERR_") === 0) {
                     modApiFunc("Session", "set", "ErrorMessage", $core_response);
                 } else {
                     CCacheFactory::clearAll();
                     $request = new Request();
                     $request->setView(CURRENT_REQUEST_URL);
                     $application->redirect($request);
                 }
             }
         } else {
             $error = "ERR_MARKETPLACE_NOT_AVAILABLE";
             modApiFunc("Session", "set", "ErrorMessage", $error);
         }
     } else {
         $error = "ERR_CHK_ZIP_OR_PERMISSIONS";
         modApiFunc("Session", "set", "ErrorMessage", $error);
     }
 }
 function onAction()
 {
     global $application;
     $request = $_POST;
     $extension_name = $request["extn_name"];
     $_state = modApiFunc("License", "checkLicense");
     $licenseInfo = modApiFunc("License", "getLicenseInfo", $_state);
     $data = array('license' => $licenseInfo["license_key"], 'store_url' => $_SERVER['HTTP_HOST'] . $_SERVER['CONTEXT_PREFIX'], 'extn_name' => $extension_name, 'store_version' => PRODUCT_VERSION_NUMBER);
     $marketplace_server = $application->getAppIni('MARKETPLACE_SERVER');
     loadCoreFile('bouncer.php');
     $bnc = new Bouncer();
     $bnc->setMethod('POST');
     $bnc->setPOSTstring($bnc->prepareDATAstring($data));
     $bnc->setURL($marketplace_server . "/download_extension.php?asc_action=SendExtension");
     $bnc->setProto('HTTPS');
     $result = $bnc->RunRequest();
     $response = $result['body'];
     if ($response != false && $bnc->responseCode < 400) {
         if (strpos($response, "ERR_") === 0) {
             modApiFunc("Session", "set", "ErrorMessage", $response);
             //return $response['err_msg'];
         } else {
             $file = fopen($application->getAppIni(PATH_CACHE_DIR) . $extension_name . ".zip", 'w+');
             fwrite($file, $response);
             fclose($file);
             $installed = modApiFunc("Extension_Manager", "installExtension", $extension_name);
             if ($installed) {
                 modApiFunc("Session", "set", "InstallMessage", "1");
                 CCacheFactory::clearAll();
                 $request = new Request();
                 $request->setView(CURRENT_REQUEST_URL);
                 $request->setKey('identifier', 'ExtensionManager_ListView');
                 $application->redirect($request);
             } else {
                 modApiFunc("Session", "set", "ErrorMessage", "ERR_CHK_ZIP_OR_PERMISSIONS");
             }
         }
     } else {
         modApiFunc("Session", "set", "ErrorMessage", "ERR_MARKETPLACE_NOT_AVAILABLE");
     }
 }
 function _process_request(&$xml_request, &$default_response)
 {
     $xml_request = urlencode($xml_request);
     loadCoreFile('bouncer.php');
     $bnc = new Bouncer();
     $bnc->setMethod(UPDATESERVER_METHOD);
     $bnc->setURL(UPDATESERVER_PROTO . '://' . UPDATESERVER_HOST_PATH . '?xml=' . $xml_request);
     switch (UPDATESERVER_METHOD) {
         case "GET":
             $bnc->setURL(UPDATESERVER_PROTO . '://' . UPDATESERVER_HOST_PATH . '?xml=' . $xml_request);
             break;
         case "POST":
             $bnc->setURL(UPDATESERVER_PROTO . '://' . UPDATESERVER_HOST_PATH);
             $bnc->setPOSTstring($bnc->prepareDATAstring(array("xml" => $xml_request)));
             break;
     }
     $result = $bnc->RunRequest();
     if ($result == false) {
         return false;
     }
     //die(print_r($result['body'], true));
     loadCoreFile('obj_xml.php');
     $xml = new xml_doc($result['body']);
     //die(print_r($result['body'], true));
     $xml->parse();
     if (!is_object($xml->document)) {
         return false;
     }
     //die(print_r($xml->document,true));
     foreach ($default_response as $key => $val) {
         $xml_tag = $xml->document->findChild($key);
         if ($xml_tag != FALSE) {
             $default_response[$key] = $xml_tag->contents;
         }
     }
     //die(print_r($default_response,true));
     return $default_response;
 }
 function __getRateFromWebServiceX($from, $to)
 {
     loadCoreFile('bouncer.php');
     $bnc = new Bouncer();
     $bnc->setHTTPversion("1.0");
     $bnc->setMethod("GET");
     $bnc->setURL("http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate");
     $bnc->setSocketReadTimeout(10);
     $get_params = array("FromCurrency" => $from, "ToCurrency" => $to);
     $bnc->setGETstring($bnc->prepareDATAstring($get_params));
     $res = $bnc->RunRequest();
     if ($res != false) {
         $xml = $res["body"];
         loadCoreFile('obj_xml.php');
         $parser = new xml_doc($xml);
         $parser->parse();
         foreach ($parser->xml_index as $node) {
             if ($node->name = "DOUBLE") {
                 $rate = $node->contents;
                 if ($rate == 0) {
                     $rate = false;
                 }
                 $this->__addRequestToTimeline('www.webservicex.net', $from, $to, $rate, $bnc, $res);
                 return $rate;
             }
         }
     }
     $this->__addRequestToTimeline('www.webservicex.net', $from, $to, false, $bnc, $res);
     return false;
 }
 function sendRequest($HTTPSURL)
 {
     loadCoreFile('bouncer.php');
     $bnc = new Bouncer();
     $bnc->setMethod('GET');
     $bnc->setGETstring($bnc->prepareDATAstring(array("request" => "is_connection_available")));
     $bnc->setURL($HTTPSURL . "avactis-system/admin/test_connection.php");
     $result = $bnc->RunRequest();
     $URL_correct = false;
     if (is_array($result) && isset($result["body"]) && strstr($result["body"], "YES")) {
         $URL_correct = true;
     }
     return $URL_correct;
 }
 function _makeTest($test_number, $coming_answer)
 {
     $this->updateTestRewriteBase($test_number);
     $req = new Request();
     $base_url = $req->getURL();
     $base_url = preg_replace("/\\/[^\\/]*\$/", "", $base_url);
     $test_url = $base_url . '/mod_rewrite_test_' . sprintf("%02d", $test_number) . '/test.html';
     echo "{$test_url}\n";
     loadCoreFile('bouncer.php');
     $bnc = new Bouncer();
     $bnc->setMethod("GET");
     $bnc->setHTTPversion("1.0");
     $bnc->setURL($test_url);
     echo date("Y-m-d H:i:s", time()) . "\n";
     $res = $bnc->RunRequest();
     echo date("Y-m-d H:i:s", time()) . "\n";
     if ($res != false) {
         if (trim($res["body"]) == $coming_answer) {
             return true;
         }
     }
     return false;
 }
示例#8
0
 function __makeTestHttpsRequest($get_array, $url)
 {
     loadCoreFile('bouncer.php');
     $bnc = new Bouncer();
     if (!$bnc->isSSLavailable()) {
         return "SSL_not_available";
     }
     $bnc->setMethod('GET');
     $bnc->setGETstring($bnc->prepareDATAstring($get_array));
     $bnc->setURL($url);
     $result = $bnc->RunRequest();
     if (is_array($result) && isset($result["body"]) && strstr($result["body"], "YES")) {
         return true;
     } else {
         return false;
     }
 }
 function getLatestCoreVer()
 {
     global $application;
     $_state = modApiFunc("License", "checkLicense");
     $licenseInfo = modApiFunc("License", "getLicenseInfo", $_state);
     if ($licenseInfo["license_key"] == LICENSE_KEY_UNDEFINED) {
         $result['body'] = PRODUCT_VERSION_NUMBER;
     }
     if ($this->isMarketplaceUpdateRequired()) {
         $this->marketplace_server = $application->getAppIni('MARKETPLACE_SERVER');
         $data = array('license' => $licenseInfo["license_key"], 'store_url' => urlencode(modApiFunc('Request', 'selfURL')), 'store_version' => PRODUCT_VERSION_NUMBER);
         loadCoreFile('bouncer.php');
         $bnc = new Bouncer();
         $bnc->setMethod('POST');
         $bnc->setPOSTstring($bnc->prepareDATAstring($data));
         $bnc->setURL($this->marketplace_server . "/download_extension.php?asc_action=GetLatestCoreVersion");
         $bnc->setProto('HTTPS');
         $result = $bnc->RunRequest();
         if ($result != false && $bnc->responseCode < 400) {
             $latest_core_version = $result['body'];
             /* Update Latest core version */
             $params = array('group_name' => 'AVACTIS_LATEST_VERSION', 'param_name' => 'AVACTIS_LATEST_VERSION', 'value' => $latest_core_version);
             execQuery('UPDATE_SETTINGS_PARAM_VALUE', $params);
             return $latest_core_version;
         }
     }
     //Error while calling marketplace or TTL not expired then return from database
     $result = execQuery('SELECT_SETTINGS_PARAM_BASE_INFO', array('group_name' => 'AVACTIS_LATEST_VERSION', 'param_name' => 'AVACTIS_LATEST_VERSION'));
     $latest_core_version = $result[0]['param_current_value'];
     return $latest_core_version;
 }
 function _process_request(&$data, $response_required = false)
 {
     $xml_request = urlencode($data);
     loadCoreFile('bouncer.php');
     $bnc = new Bouncer();
     $bnc->setHTTPversion("1.0");
     $bnc->setMethod(LICENSESERVER_METHOD);
     $bnc->setURL(LICENSESERVER_PROTO . '://' . ACCOUNTSERVER_URL . '?xml=' . $xml_request);
     $result = $bnc->RunRequest();
     if ($result == false) {
         return false;
     }
     if ($response_required) {
         loadCoreFile('obj_xml.php');
         $xml = new xml_doc($result['body']);
         $res = $xml->parse();
         if ($res !== true) {
             return false;
         }
         if (!is_object($xml->document)) {
             return false;
         }
         // general check
         // response data
         $response = array("CODE" => "not_set", "MESSAGE" => "not_set", "CERT" => "not_set");
         foreach ($response as $key => $val) {
             $xml_tag = $xml->findTag($key);
             if ($xml_tag != FALSE) {
                 $response[$key] = $xml_tag->contents;
             }
         }
         return $response;
     } else {
         return true;
     }
 }