update license issue
This commit is contained in:
parent
0b7a05f3a8
commit
07acd2fa84
@ -7,6 +7,35 @@ class LicenseService {
|
|||||||
private static $app_name = null;
|
private static $app_name = null;
|
||||||
private static $settings_cache = null;
|
private static $settings_cache = null;
|
||||||
private static $identity_cache = null;
|
private static $identity_cache = null;
|
||||||
|
private static $client_config_cache = null;
|
||||||
|
|
||||||
|
private static function loadClientConfig() {
|
||||||
|
if (self::$client_config_cache !== null) {
|
||||||
|
return self::$client_config_cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
self::$client_config_cache = [];
|
||||||
|
$configPath = __DIR__ . '/../license_client_config.php';
|
||||||
|
if (!is_file($configPath)) {
|
||||||
|
return self::$client_config_cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$config = include $configPath;
|
||||||
|
if (is_array($config)) {
|
||||||
|
self::$client_config_cache = $config;
|
||||||
|
}
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
self::$client_config_cache = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$client_config_cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getClientConfigValue($key) {
|
||||||
|
$config = self::loadClientConfig();
|
||||||
|
return trim((string)($config[$key] ?? ''));
|
||||||
|
}
|
||||||
|
|
||||||
private static function normalizeApiBaseUrl($url) {
|
private static function normalizeApiBaseUrl($url) {
|
||||||
$url = trim((string)$url);
|
$url = trim((string)$url);
|
||||||
@ -118,6 +147,12 @@ class LicenseService {
|
|||||||
return self::$remote_api_url;
|
return self::$remote_api_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$configOverride = self::normalizeApiBaseUrl(self::getClientConfigValue('license_api_url'));
|
||||||
|
if ($configOverride !== '') {
|
||||||
|
self::$remote_api_url = $configOverride;
|
||||||
|
return self::$remote_api_url;
|
||||||
|
}
|
||||||
|
|
||||||
$configured = self::normalizeApiBaseUrl(getenv('LICENSE_API_URL') ?: '');
|
$configured = self::normalizeApiBaseUrl(getenv('LICENSE_API_URL') ?: '');
|
||||||
if ($configured !== '') {
|
if ($configured !== '') {
|
||||||
if (self::isLocalHostUrl($configured) && !self::urlLooksLikeHealthyLicenseApi($configured)) {
|
if (self::isLocalHostUrl($configured) && !self::urlLooksLikeHealthyLicenseApi($configured)) {
|
||||||
@ -135,13 +170,13 @@ class LicenseService {
|
|||||||
return self::$remote_api_url;
|
return self::$remote_api_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$remote_api_url = 'https://omanapp.cloud/meezan_register';
|
self::$remote_api_url = 'https://omanapp.cloud/central_license_manager';
|
||||||
return self::$remote_api_url;
|
return self::$remote_api_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getApiSecret() {
|
private static function getApiSecret() {
|
||||||
if (self::$api_secret === null) {
|
if (self::$api_secret === null) {
|
||||||
$secret = trim((string)(getenv('LICENSE_API_SECRET') ?: getenv('CLM_API_SECRET') ?: '1485-5215-2578'));
|
$secret = trim((string)(self::getClientConfigValue('license_api_secret') ?: getenv('LICENSE_API_SECRET') ?: getenv('CLM_API_SECRET') ?: '1485-5215-2578'));
|
||||||
self::$api_secret = $secret !== '' ? $secret : '1485-5215-2578';
|
self::$api_secret = $secret !== '' ? $secret : '1485-5215-2578';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,11 +237,15 @@ class LicenseService {
|
|||||||
|
|
||||||
$settings = self::loadIdentitySettings();
|
$settings = self::loadIdentitySettings();
|
||||||
$storedName = trim((string)($settings['license_app_name'] ?? ''));
|
$storedName = trim((string)($settings['license_app_name'] ?? ''));
|
||||||
|
$configName = self::getClientConfigValue('license_app_name');
|
||||||
$envName = trim((string)(getenv('LICENSE_APP_NAME') ?: ''));
|
$envName = trim((string)(getenv('LICENSE_APP_NAME') ?: ''));
|
||||||
|
|
||||||
if ($storedName !== '') {
|
if ($storedName !== '') {
|
||||||
$name = $storedName;
|
$name = $storedName;
|
||||||
$nameSource = 'settings';
|
$nameSource = 'settings';
|
||||||
|
} elseif ($configName !== '') {
|
||||||
|
$name = $configName;
|
||||||
|
$nameSource = 'project_config';
|
||||||
} elseif ($envName !== '') {
|
} elseif ($envName !== '') {
|
||||||
$name = $envName;
|
$name = $envName;
|
||||||
$nameSource = 'environment';
|
$nameSource = 'environment';
|
||||||
@ -216,11 +255,15 @@ class LicenseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$storedSlug = trim((string)($settings['license_app_slug'] ?? ''));
|
$storedSlug = trim((string)($settings['license_app_slug'] ?? ''));
|
||||||
|
$configSlug = self::getClientConfigValue('license_app_slug');
|
||||||
$envSlug = trim((string)(getenv('LICENSE_APP_SLUG') ?: ''));
|
$envSlug = trim((string)(getenv('LICENSE_APP_SLUG') ?: ''));
|
||||||
|
|
||||||
if ($storedSlug !== '') {
|
if ($storedSlug !== '') {
|
||||||
$slug = self::sanitizeAppSlug($storedSlug);
|
$slug = self::sanitizeAppSlug($storedSlug);
|
||||||
$slugSource = 'settings';
|
$slugSource = 'settings';
|
||||||
|
} elseif ($configSlug !== '') {
|
||||||
|
$slug = self::sanitizeAppSlug($configSlug);
|
||||||
|
$slugSource = 'project_config';
|
||||||
} elseif ($envSlug !== '') {
|
} elseif ($envSlug !== '') {
|
||||||
$slug = self::sanitizeAppSlug($envSlug);
|
$slug = self::sanitizeAppSlug($envSlug);
|
||||||
$slugSource = 'environment';
|
$slugSource = 'environment';
|
||||||
|
|||||||
10
license_client_config.php
Normal file
10
license_client_config.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
// Project-level license client overrides for hosts where Apache/PHP env vars
|
||||||
|
// are not editable or cannot be reloaded on demand.
|
||||||
|
'license_api_url' => 'https://omanapp.cloud/central_license_manager',
|
||||||
|
'license_app_name' => 'Bilingual Accounting',
|
||||||
|
'license_app_slug' => 'bilingual-accounting',
|
||||||
|
// 'license_api_secret' => '1485-5215-2578',
|
||||||
|
];
|
||||||
Loading…
x
Reference in New Issue
Block a user