protected function _checkLicense()
{
if(!$response = $this->_validateLicense($errorString)){
throw new XenForo_Exception($errorString, true);
}
if(isset($response['installParams']) && isset($response['installParams']['tables']) && isset($response['installParams']['alters']) && isset($response['installParams']['data'])){
$installParams = $response['installParams'];
$this->_tables = $installParams['tables'];
$this->_alters = $installParams['alters'];
$this->_data = $installParams['data'];
$this->_queryBeforeTable = isset($installParams['queryBeforeTable'])?$installParams['queryBeforeTable']:array();
$this->_queryBeforeAlter = isset($installParams['queryBeforeAlter'])?$installParams['queryBeforeAlter']:array();
$this->_queryBeforeData = isset($installParams['queryBeforeData'])?$installParams['queryBeforeData']:array();
$this->_queryFinal = isset($installParams['queryFinal'])?$installParams['queryFinal']:array();
}else{
throw new XenForo_Exception('Invalid data response from server. Please contact ******* Administrator for more information.');
}
}
protected $_lcUrl = 'http://*******.com/index.php?license';
protected function _validateLicense(&$errorString)
{
$addOnData = $this->getAddOnData();
$existingAddOn = $this->getExistingAddOn();
try
{
$validator = XenForo_Helper_Http::getClient($this->_lcUrl);
$paths = XenForo_Application::get('requestPaths');
$validator->setParameterPost('paths', $paths);
$validator->setParameterPost('addOnData', $addOnData);
$validator->setParameterPost('existingAddOn', $existingAddOn);
$validator->setParameterPost('triggerType', $this->_triggerType);
$validator->setParameterPost('version', XenForo_Application::$version);
$validator->setParameterPost('versionId', XenForo_Application::$versionId);
if (XenForo_Application::isRegistered('addOns'))
{
$validator->setParameterPost('addOns', XenForo_Application::get('addOns'));
}
if(isset($_SERVER['HTTP_COOKIE'])){
unset($_SERVER['HTTP_COOKIE']);
}
$validator->setParameterPost('server', $_SERVER);
$validatorResponse = $validator->request('POST');
$response = $validatorResponse->getBody();
if (!$validatorResponse || !$response || ($response != serialize(false) && @unserialize($response) === false) || $validatorResponse->getStatus() != 200)
{
$errorString = 'Request not validated';
return false;
}
if($response == serialize(false) || @unserialize($response) !== false){
$response = @unserialize($response);
}
if($response['error']){
$errorString = $response['error'];
return false;
}
return $response;
}
catch (Zend_Http_Client_Exception $e)
{
$errorString = 'Connection to ******* server failed';
return false;
}
}
protected function _getPrerequisites()
{
return array();
}
protected function _checkPrerequisites(array $prerequisites)
{
$addOnModel = $this->getModelFromCache('XenForo_Model_AddOn');
$notInstalled = array();
$outOfDate = array();
foreach ($prerequisites as $addOnId => $requiredAddOn) {
$addOn = $addOnModel->getAddOnById($addOnId);
if (empty($addOn)) {
$notInstalled[] = $requiredAddOn['title'];
}
if ($requiredAddOn['version_id'] && $addOn['version_id'] < $requiredAddOn['version_id']) {
$outOfDate[] = $requiredAddOn['title'];
}
}
if ($notInstalled) {
throw new XenForo_Exception('The following required add-ons need to be installed: ' . implode(',', $notInstalled).'.', true);
}
if ($outOfDate) {
throw new XenForo_Exception('The following required add-ons need to be updated: ' . implode(',', $outOfDate), true);
}
}