From fce3efdec5fc93b7060d510ea4872d25f560bf69 Mon Sep 17 00:00:00 2001 From: trendschau Date: Thu, 3 Oct 2024 02:57:48 +0200 Subject: [PATCH] Alternative license check --- system/typemill/Models/License.php | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/system/typemill/Models/License.php b/system/typemill/Models/License.php index 59751bc..f863cb2 100644 --- a/system/typemill/Models/License.php +++ b/system/typemill/Models/License.php @@ -165,6 +165,46 @@ class License return false; } + # NOT IN USE: Compare only domain without subdomains or subfolders + private function checkLicenseBaseDomain(string $licensedomain, array $urlinfo) + { + $licensehost = parse_url($licensedomain, PHP_URL_HOST); + $licensehost = preg_replace('/^www\./', '', $licensehost); + $licensehost = $this->extractBaseDomain($licensehost); + + $thishost = parse_url($urlinfo['baseurl'], PHP_URL_HOST); + $thishost = preg_replace('/^www\./', '', $thishost); + $thishost = $this->extractBaseDomain($thishost); + + $whitelist = ['localhost', '127.0.0.1', 'typemilltest.', $licensehost]; + + foreach($whitelist as $domain) + { + if ($thishost === $domain) + { + return true; + } + } + + return false; + } + + # NOT IN USE: Function to extract the base domain (ignoring subdomains) + private function extractBaseDomain($host) + { + $parts = explode('.', $host); + $numParts = count($parts); + + # Check if we have at least 2 parts for a valid base domain + if ($numParts >= 2) + { + return $parts[$numParts - 2] . '.' . $parts[$numParts - 1]; + } + + # Return original host if it's not a valid domain + return $host; + } + public function checkIfTest(array $urlinfo) { $thishost = parse_url($urlinfo['baseurl'], PHP_URL_HOST);