Last active
March 24, 2016 08:45
-
-
Save Pierozi/615bdcdc4d4c4c49bd3a to your computer and use it in GitHub Desktop.
Zafrira_Storepickup | Magento workarround licence key because Zafrira no longer exist !
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php class Zafrira_Storepickup_Helper_Data extends Mage_Core_Helper_Abstract | |
{ | |
public function isFreeMethod($method, $storeId = null) | |
{ | |
$arr = explode('_', $method, 2); | |
if (!isset($arr[1])) { | |
return false; | |
} | |
$freeMethod = Mage::getStoreConfig('carriers/' . $arr[0] . '/free_method', $storeId); | |
return $freeMethod == $arr[1]; | |
} | |
private function _check_zafrira_storepickup_license($licensekey) | |
{ | |
$ZafValidTrial = false; | |
$ZafValidLicense = false; | |
$ZafStoreHost = $_SERVER['SERVER_NAME']; | |
$ZafStoreIP = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR']; | |
$ZafStartStamp = $licensekey[$this->ZafEnc('ZEhKaGFXeGtZWFJs')]; | |
$ZafLicenseKey = $licensekey["licensekey"]; | |
$ZafLicenseCode = sha1($this->ZafEnc('VTNSdmNtVlFhV05yZFhBekxqQmZaRFUwTXpBMkxXWTFNamsyWHc9PQ==' | |
) . sha1($ZafStoreHost) . 'd54306-f5296-6a5ca-be2d8-c9690f8' . sha1($ZafLicenseKey | |
) . $ZafStoreIP . sha1(hexdec(0)) . '8adb47dbfb233892e7da' | |
); | |
$ZafTsStamp = time(); | |
$ZafTsStamp = $ZafTsStamp - substr($ZafTsStamp, -5); | |
$ZafTsCode = sha1($ZafTsStamp . $ZafLicenseKey . dechex($ZafTsStamp) . $ZafLicenseCode); | |
if (!($ZafStartStamp == $ZafTsCode)) { | |
$ZafCheckParams = array( | |
'key' => base64_encode($ZafLicenseKey), | |
'host' => base64_encode($ZafStoreHost), | |
'ip' => base64_encode($ZafStoreIP), | |
'code' => base64_encode($ZafLicenseCode), | |
'version' => base64_encode('MagentoStorePickup3')); | |
$ZafCheckURL = $this->ZafEnc('YUhSMGNITTZMeTk2WVdaeWFYSmhMbTVsZEM5MllXeHBaR0YwYVc5dUwyRjFkRzh2'); | |
$ZafCheckReply = $this->getHttpsPage($ZafCheckURL, $ZafCheckParams); | |
$ZafCheckArray = unserialize(base64_decode(base64_decode($ZafCheckReply))); | |
$ZafReplyInfo = array(); | |
foreach ($ZafCheckArray as $keyNum => $keyVal) { | |
$tmpVal = explode('|#|', base64_decode($keyVal)); | |
$ZafReplyInfo[base64_decode($tmpVal[1])] = base64_decode($tmpVal[0]); | |
} | |
$ZafReplyInfo[$this->ZafEnc('YzI5MWNtTmw=')] = $this->ZafEnc('VEVsRFJVNVRSVk5GVWxaRlVnPT0='); | |
} else { | |
$ZafReplyInfo = array( | |
'valid' => true, | |
$this->ZafEnc('ZG1Gc2FXUmhkR2x2Ym1OdlpHVT0=' | |
) => $licensekey[$this->ZafEnc('ZG1Gc2FXUmhkR2x2Ym1OdlpHVT0=' | |
)], | |
$this->ZafEnc('ZEhKaGFXeGtZWFJs') => $ZafTsCode, | |
'userip' => $ZafStoreIP, | |
'hostname' => $ZafStoreHost, | |
$this->ZafEnc('YzI5MWNtTmw=' | |
) => $this->ZafEnc('VEU5RFFVeEpUbE5VUVV4TQ==' | |
)); | |
} | |
return $ZafReplyInfo; | |
} | |
private function ZafEnc($input) { return base64_decode(base64_decode($input)); } | |
private function getHttpsPage($host, $parameter) | |
{ | |
$client = new Varien_Http_Client(); | |
$client->setUri($host)->setConfig(array('timeout' => 30))->setHeaders('accept-encoding', '' | |
)->setParameterGet($parameter)->setMethod(Zend_Http_Client::GET); | |
$request = $client->request(); | |
if (!preg_match("/^([\da-fA-F]+)[^\r\n]*\r\n/sm", $request->getRawBody(), $m)) { | |
return $request->getRawBody(); | |
} | |
return $request->getBody(); | |
} | |
public function check_zafrira_storepickup_license($store_id = 0, $storecode = 'websites') | |
{ | |
return 'YES'; | |
$codePre = 'ZW1GbWNtbHlZUzl6ZEc5eVpYQnBZMnQxY0M5'; | |
$codeLicensereply = $this->ZafEnc($codePre . 'c2FXTmxibk5sY21Wd2JIaz0='); | |
$codeLicensekey = $this->ZafEnc($codePre . 'c2FXTmxibk5sYTJWNQ=='); | |
$codeValidationcode = $this->ZafEnc($codePre . 'MllXeHBaR0YwYVc5dVkyOWtaUT09'); | |
$codeLocalkey = $this->ZafEnc($codePre . 'c2IyTmhiR3RsZVE9PQ=='); | |
$codeValidip = $this->ZafEnc($codePre . 'MllXeHBaR2x3'); | |
$codeValidhost = $this->ZafEnc($codePre . 'MllXeHBaR2h2YzNRPQ=='); | |
$licenseinfo = array(); | |
if ($storecode == 'websites') { | |
$licenseinfo[$this->ZafEnc('YkdsalpXNXpaV3RsZVE9PQ==')] = Mage::app()->getWebsite($store_id | |
)->getConfig($codeLicensekey); | |
$licenseinfo[$this->ZafEnc('ZG1Gc2FXUmhkR2x2Ym1OdlpHVT0=')] = Mage::app()->getWebsite($store_id | |
)->getConfig($codeValidationcode); | |
$licenseinfo[$this->ZafEnc('YkdsalpXNXpaWEpsY0d4NQ==')] = Mage::app()->getWebsite($store_id | |
)->getConfig($codeLicensereply); | |
$licenseinfo[$this->ZafEnc('ZEhKaGFXeGtZWFJs')] = Mage::app()->getWebsite($store_id | |
)->getConfig($codeLocalkey); | |
} else { | |
if ($storecode == 'stores') { | |
$licenseinfo[$this->ZafEnc('YkdsalpXNXpaV3RsZVE9PQ==')] = Mage::app()->getStore($store_id | |
)->getConfig($codeLicensekey); | |
$licenseinfo[$this->ZafEnc('ZG1Gc2FXUmhkR2x2Ym1OdlpHVT0=')] = Mage::app()->getStore($store_id | |
)->getConfig($codeValidationcode); | |
$licenseinfo[$this->ZafEnc('YkdsalpXNXpaWEpsY0d4NQ==')] = Mage::app()->getStore($store_id | |
)->getConfig($codeLicensereply); | |
$licenseinfo[$this->ZafEnc('ZEhKaGFXeGtZWFJs')] = Mage::app()->getStore($store_id | |
)->getConfig($codeLocalkey); | |
} else { | |
if ($storecode == 'default') { | |
$licenseinfo[$this->ZafEnc('YkdsalpXNXpaV3RsZVE9PQ==')] = Mage::app()->getStore(0 | |
)->getConfig($codeLicensekey); | |
$licenseinfo[$this->ZafEnc('ZG1Gc2FXUmhkR2x2Ym1OdlpHVT0=')] = Mage::app()->getStore(0 | |
)->getConfig($codeValidationcode); | |
$licenseinfo[$this->ZafEnc('YkdsalpXNXpaWEpsY0d4NQ==')] = Mage::app()->getStore(0 | |
)->getConfig($codeLicensereply); | |
$licenseinfo[$this->ZafEnc('ZEhKaGFXeGtZWFJs')] = Mage::app()->getStore(0 | |
)->getConfig($codeLocalkey); | |
} | |
} | |
} | |
$results = $this->_check_zafrira_storepickup_license($licenseinfo); | |
if (!isset($results['traildate'])) { | |
$results['traildate'] = ''; | |
} | |
if ($results[$this->ZafEnc('ZG1Gc2FXUT0=')] == 'YES') { | |
if (isset($results[$this->ZafEnc('ZG1Gc2FXUmhkR2x2Ym1OdlpHVT0=')])) { | |
$zafSwitch = new Mage_Core_Model_Config(); | |
$zafSwitch->saveConfig($codeValidationcode, $results[$this->ZafEnc('ZG1Gc2FXUmhkR2x2Ym1OdlpHVT0=')], | |
$storecode, $store_id | |
); | |
$zafSwitch->saveConfig($codeValidip, $results[$this->ZafEnc('ZFhObGNtbHc=')], $storecode, $store_id); | |
$zafSwitch->saveConfig($codeValidhost, $results[$this->ZafEnc('YUc5emRHNWhiV1U9')], $storecode, | |
$store_id | |
); | |
$zafSwitch->saveConfig($codeLocalkey, $results[$this->ZafEnc('ZEhKaGFXeGtZWFJs')], $storecode, $store_id | |
); | |
$zafSwitch->saveConfig('zafrira/storepickup/licensestatus', 'the license key is succesfully validated', | |
$storecode, $store_id | |
); | |
} | |
return $results[$this->ZafEnc('ZG1Gc2FXUT0=')]; | |
} else { | |
$zafSwitch = new Mage_Core_Model_Config(); | |
$zafSwitch->saveConfig('zafrira/storepickup/licensestatus', 'the license key is invalid or expired', | |
$storecode, $store_id | |
); | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment