From 07acd2fa848c546f7161a1d0b9bae76c72288895 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 3 May 2026 13:53:31 +0000 Subject: [PATCH] update license issue --- lib/LicenseService.php | 47 +++++++++++++++++++++++++++++++++++++-- license_client_config.php | 10 +++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 license_client_config.php diff --git a/lib/LicenseService.php b/lib/LicenseService.php index 5f3615c..41b1604 100644 --- a/lib/LicenseService.php +++ b/lib/LicenseService.php @@ -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'; diff --git a/license_client_config.php b/license_client_config.php new file mode 100644 index 0000000..c633227 --- /dev/null +++ b/license_client_config.php @@ -0,0 +1,10 @@ + 'https://omanapp.cloud/central_license_manager', + 'license_app_name' => 'Bilingual Accounting', + 'license_app_slug' => 'bilingual-accounting', + // 'license_api_secret' => '1485-5215-2578', +];