$updates = $messages = $license = '';
$params = $restrictions = [];
if (!empty($data)) {
// Check if we can parse server response
if (strpos($data, '<?xml') !== false) {
$xml = simplexml_load_string($data);
$updates = (string) $xml->Updates;
$messages = $xml->Messages;
$license = (string) $xml->License;
if (isset($xml->TrialExpiryTime)) {
$params['trial_expiry_time'] = (int) $xml->TrialExpiryTime;
}
if (isset($xml->TrialLeftTime)) {
$params['trial_left_time'] = (int) $xml->TrialLeftTime;
}
if (isset($xml->AllowedNumberOfStores)) {
fn_set_storage_data('allowed_number_of_stores', (int) $xml->AllowedNumberOfStores);
} else {
fn_set_storage_data('allowed_number_of_stores', null);
}
if (isset($xml->Restrictions)) {
$json_restrictions = json_encode($xml->Restrictions);
$restrictions = json_decode($json_restrictions, true);
fn_set_storage_data('restrictions', serialize($restrictions));
} else {
fn_set_storage_data('restrictions', '');
}
if (isset($xml->LicenseKey)) {
Settings::instance()->updateValue('license_number', (string) $xml->LicenseKey, '', false, null, false);
}
if (isset($xml->FreeMode) && fn_allowed_for('ULTIMATE:FREE') && YesNo::isFalse(fn_get_storage_data('free_mode', false))) {
fn_set_storage_data('free_mode', YesNo::YES);
}
if (isset($xml->LatestAvailableVersion)) {
fn_set_storage_data('latest_available_version', (string) $xml->LatestAvailableVersion->Version);
fn_set_storage_data('latest_available_version_timestamp', (string) $xml->LatestAvailableVersion->Timestamp);
}
} else {
$license = $data;
}
}
if (!empty($auth)) {
if (Registry::get('settings.General.auto_check_updates') === YesNo::YES &&
fn_check_user_access($auth['user_id'], 'upgrade_store') &&
$updates == 'AVAILABLE'
) {
/** @var \Tygh\NotificationsCenter\NotificationsCenter $notifications_center */
$notifications_center = Tygh::$app['notifications_center'];
$notifications_center->add([
'user_id' => $auth['user_id'],
'title' => __('notification.upgrade_available.title'),
'message' => __('notification.upgrade_available.message', [
'[product]' => PRODUCT_NAME,
]),
'area' => 'A',
'section' => NotificationsCenter::SECTION_ADMINISTRATION,
'tag' => NotificationsCenter::TAG_UPDATE,
'action_url' => fn_url('upgrade_center.manage'),
'language_code' => Registry::get('settings.Appearance.backend_default_language'),
]);
}
if (!empty($data)) {
$_SESSION['last_status'] = $license;
}
}
$messages = self::processMessages($messages, $process_messages, $license);
return [$license, $updates, $messages, $params, $restrictions];