update license issue

This commit is contained in:
Flatlogic Bot 2026-05-03 13:53:31 +00:00
parent 0b7a05f3a8
commit 07acd2fa84
2 changed files with 55 additions and 2 deletions

View File

@ -7,6 +7,35 @@ class LicenseService {
private static $app_name = null;
private static $settings_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) {
$url = trim((string)$url);
@ -118,6 +147,12 @@ class LicenseService {
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') ?: '');
if ($configured !== '') {
if (self::isLocalHostUrl($configured) && !self::urlLooksLikeHealthyLicenseApi($configured)) {
@ -135,13 +170,13 @@ class LicenseService {
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;
}
private static function getApiSecret() {
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';
}
@ -202,11 +237,15 @@ class LicenseService {
$settings = self::loadIdentitySettings();
$storedName = trim((string)($settings['license_app_name'] ?? ''));
$configName = self::getClientConfigValue('license_app_name');
$envName = trim((string)(getenv('LICENSE_APP_NAME') ?: ''));
if ($storedName !== '') {
$name = $storedName;
$nameSource = 'settings';
} elseif ($configName !== '') {
$name = $configName;
$nameSource = 'project_config';
} elseif ($envName !== '') {
$name = $envName;
$nameSource = 'environment';
@ -216,11 +255,15 @@ class LicenseService {
}
$storedSlug = trim((string)($settings['license_app_slug'] ?? ''));
$configSlug = self::getClientConfigValue('license_app_slug');
$envSlug = trim((string)(getenv('LICENSE_APP_SLUG') ?: ''));
if ($storedSlug !== '') {
$slug = self::sanitizeAppSlug($storedSlug);
$slugSource = 'settings';
} elseif ($configSlug !== '') {
$slug = self::sanitizeAppSlug($configSlug);
$slugSource = 'project_config';
} elseif ($envSlug !== '') {
$slug = self::sanitizeAppSlug($envSlug);
$slugSource = 'environment';

10
license_client_config.php Normal file
View 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',
];