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 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; $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 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; }