Example #1
0
 /**
  * Register the new install with the LC API
  *  
  * @access private      
  * @return string
  */
 private function _doRegister($data)
 {
     global $lC_Database, $lC_Cache;
     if (isset($data['activation_email']) && $data['activation_email'] != NULL) {
         $storeEmail = $data['activation_email'];
     } else {
         $storeEmail = STORE_OWNER_EMAIL_ADDRESS;
     }
     if (isset($data['activation_serial']) && $data['activation_serial'] != NULL) {
         $storeSerial = $data['activation_serial'];
     } else {
         $storeSerial = '';
     }
     // register the install with LC API
     $registerArr = array('serial' => $storeSerial, 'storeName' => STORE_NAME, 'storeEmail' => $storeEmail, 'storeWWW' => HTTP_SERVER . DIR_WS_HTTP_CATALOG, 'storeSSL' => HTTPS_SERVER . DIR_WS_HTTPS_CATALOG, 'systemMetaData' => base64_encode(json_encode(lc_get_system_information())), 'serverMetaData' => isset($_SERVER) && is_array($_SERVER) ? base64_encode(json_encode($_SERVER)) : NULL, 'envMetaData' => isset($_ENV) && is_array($_ENV) ? base64_encode(json_encode($_ENV)) : NULL);
     $checksum = hash('sha256', json_encode($registerArr));
     $registerArr['checksum'] = $checksum;
     $api_version = defined('API_VERSION') && API_VERSION != NULL ? API_VERSION : '1_0';
     $registerArr['ver'] = utility::getVersion();
     $request_type = getRequestType();
     $resultXML = transport::getResponse(array('url' => $request_type . '://api.loadedcommerce.com/' . $api_version . '/register/install/', 'method' => 'post', 'parameters' => $registerArr, 'timeout' => 10));
     $newInstallationID = preg_match("'<installationID[^>]*?>(.*?)</installationID>'i", $resultXML, $regs) == 1 ? $regs[1] : NULL;
     $products = preg_match("'<products[^>]*?>(.*?)</products>'i", $resultXML, $regs) == 1 ? $regs[1] : NULL;
     if (lC_Server_info_Admin::updateInstallID($newInstallationID)) {
         return utility::arr2xml(array('error' => FALSE, 'installationID' => $newInstallationID, 'products' => $products));
     } else {
         return utility::arr2xml(array('error' => TRUE, 'message' => 'error processing the request'));
     }
 }
 public function initialize()
 {
     global $lC_Product;
     if (defined('MODULE_CONTENT_PRODUCT_ON_HOMEPAGE')) {
         $lC_Product = new lC_Product(MODULE_CONTENT_PRODUCT_ON_HOMEPAGE);
         $product_url = HTTP_SERVER . DIR_WS_HTTP_CATALOG . 'products.php?' . $lC_Product->getKeyword();
         $resultHTML = transport::getResponse(array('url' => $product_url, 'method' => 'get'));
         $content = substr($resultHTML, strpos($resultHTML, '<!--content/products/info.php start'));
         $this->_content = substr($content, strpos($content, '<!--content/products/info.php start'), strpos($content, 'content/products/info.php end-->') + 32);
     }
 }
Example #3
0
 public static function apiCheck()
 {
     $api_version = defined('API_VERSION') && API_VERSION != NULL ? API_VERSION : '1_0';
     $request_type = getRequestType();
     $apiCheck = transport::getResponse(array('url' => $request_type . '://api.loadedcommerce.com/' . $api_version . '/updates/available/?ver=' . utility::getVersion() . '&ref=' . $_SERVER['SCRIPT_FILENAME'], 'method' => 'get', 'timeout' => 10));
     $versions = utility::xml2arr($apiCheck);
     $error = false;
     if (count($versions) == 0) {
         // there was an error with the api
         $error = true;
         $errorMsg = preg_match("'<title[^>]*?>.*?</title>'si", $versions, $regs);
         $errorMsg = is_array($regs) ? strip_tags(end($regs)) : NULL;
         if ($errorMsg == '') {
             $errorMsg = 'Resource Unavailable at ' . $request_type . '://api.loadedcommerce.com/' . $api_version . '/updates/available/?ver=' . utility::getVersion() . '&ref=' . $_SERVER['SCRIPT_FILENAME'];
         }
         $error = true;
         // log the error
         self::log('Error: ' . $errorMsg);
     }
     if ($versions == null || $error) {
         // set the error flag
         return -1;
     }
     return 1;
 }
Example #4
0
 private function _upsGetQuote()
 {
     if (!isset($this->_upsActionCode)) {
         $this->_upsActionCode = '4';
     }
     $request = join('&', array('accept_UPS_license_agreement=yes', '10_action=' . $this->_upsActionCode, '13_product=' . $this->_upsProductCode, '14_origCountry=' . $this->_upsOriginCountryCode, '15_origPostal=' . $this->_upsOriginPostalCode, '19_destPostal=' . $this->_upsDestPostalCode, '22_destCountry=' . $this->_upsDestCountryCode, '23_weight=' . $this->_upsPackageWeight, '47_rate_chart=' . $this->_upsRateCode, '48_container=' . $this->_upsContainerCode, '49_residential=' . $this->_upsResComCode));
     $response = transport::getResponse(array('url' => 'http://www.ups.com/using/services/rave/qcostcgi.cgi?' . $request, 'method' => 'get'));
     $body_array = explode("\n", $response);
     $returnval = array();
     $errorret = 'error';
     // only return error if NO rates returned
     $n = sizeof($body_array);
     for ($i = 0; $i < $n; $i++) {
         $result = explode('%', $body_array[$i]);
         $errcode = substr($result[0], -1);
         switch ($errcode) {
             case 3:
                 if (is_array($returnval)) {
                     $returnval[] = array($result[1] => $result[8]);
                 }
                 break;
             case 4:
                 if (is_array($returnval)) {
                     $returnval[] = array($result[1] => $result[8]);
                 }
                 break;
             case 5:
                 $errorret = $result[1];
                 break;
             case 6:
                 if (is_array($returnval)) {
                     $returnval[] = array($result[3] => $result[10]);
                 }
                 break;
         }
     }
     if (empty($returnval)) {
         $returnval = $errorret;
     }
     return $returnval;
 }
Example #5
0
 /**
  * Get all available update packages
  *  
  * @access public      
  * @return array
  */
 public static function getAvailablePackages()
 {
     global $lC_Api;
     $result = array('entries' => array());
     $api_version = defined('API_VERSION') && API_VERSION != NULL ? API_VERSION : '1_0';
     $request_type = getRequestType();
     $versions = transport::getResponse(array('url' => $request_type . '://api.loadedcommerce.com/' . $api_version . '/updates/available/?ref=' . $_SERVER['SCRIPT_FILENAME'], 'method' => 'get', 'timeout' => 10));
     $versions_array = utility::xml2arr($versions);
     $counter = 0;
     foreach ($versions_array['data'] as $l => $v) {
         if (version_compare(utility::getVersion(), $v['version'], '<')) {
             $result['entries'][] = array('key' => $counter, 'version' => $v['version'], 'date' => lC_DateTime::getShort(lC_DateTime::fromUnixTimestamp(lC_DateTime::getTimestamp($v['dateCreated'], 'Ymd'))), 'announcement' => $v['newsLink'], 'update_package' => isset($v['pharLink']) ? $v['pharLink'] . '?ref=' . urlencode($_SERVER['SCRIPT_FILENAME']) : null);
             $counter++;
         }
     }
     @usort($result['entries'], function ($a, $b) {
         return version_compare($a['version'], $b['version'], '>');
     });
     $result['total'] = count($result['entries']);
     return $result;
 }
Example #6
0
 public static function getAddonPhar($key, $type = 'addon')
 {
     // remove the old phar if it exists
     if (file_exists(DIR_FS_WORK . 'addons/' . $key . '.phar')) {
         unlink(DIR_FS_WORK . 'addons/' . $key . '.phar');
     }
     $api_version = defined('API_VERSION') && API_VERSION != NULL ? API_VERSION : '1_0';
     // add the pubkey
     $pubkey = file_get_contents(DIR_FS_WORK . 'addons/update.phar.pubkey');
     file_put_contents(DIR_FS_WORK . 'addons/' . $key . '.phar.pubkey', $pubkey);
     $request_type = getRequestType();
     $response = transport::getResponse(array('url' => $request_type . '://api.loadedcommerce.com/' . $api_version . '/get/' . $key . '?type=addon&ver=' . utility::getVersion() . '&ref=' . urlencode($_SERVER['SCRIPT_FILENAME']), 'method' => 'get', 'timeout' => 10));
     if (strlen($response) == 0) {
         $response = file_get_contents($request_type . '://api.loadedcommerce.com/' . $api_version . '/get/' . $key . '?type=addon&ver=' . utility::getVersion() . '&ref=' . urlencode($_SERVER['SCRIPT_FILENAME']));
     }
     return file_put_contents(DIR_FS_WORK . 'addons/' . $key . '.phar', $response);
 }