From 4b8f60b26fa89d1efe2dd2f1a34e933f936cde60 Mon Sep 17 00:00:00 2001 From: trendschau Date: Tue, 13 Aug 2024 15:54:32 +0200 Subject: [PATCH] Fix license check for localhost when activating extensions --- .../ControllerApiSystemExtensions.php | 20 +++++++++++-------- system/typemill/Models/License.php | 14 +++++++++++++ system/typemill/Static/Plugins.php | 2 ++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/system/typemill/Controllers/ControllerApiSystemExtensions.php b/system/typemill/Controllers/ControllerApiSystemExtensions.php index 9c58b75..7343e1c 100644 --- a/system/typemill/Controllers/ControllerApiSystemExtensions.php +++ b/system/typemill/Controllers/ControllerApiSystemExtensions.php @@ -55,17 +55,21 @@ class ControllerApiSystemExtensions extends Controller if(isset($definitions['license']) && in_array($definitions['license'], ['MAKER', 'BUSINESS'])) { $license = new License(); + $urlinfo = $this->c->get('urlinfo'); - # checks if license is valid and returns scope - $licenseScope = $license->getLicenseScope($this->c->get('urlinfo')); - - if(!isset($licenseScope[$definitions['license']])) + if(!$license->checkIfTest($urlinfo)) { - $response->getBody()->write(json_encode([ - 'message' => Translations::translate('Activation failed because you need a valid ') . $definitions['license'] . Translations::translate('-license and your website must run under the domain of your license.'), - ])); + # checks if license is valid and returns scope + $licenseScope = $license->getLicenseScope($urlinfo); - return $response->withHeader('Content-Type', 'application/json')->withStatus(400); + if(!isset($licenseScope[$definitions['license']])) + { + $response->getBody()->write(json_encode([ + 'message' => Translations::translate('Activation failed because you need a valid ') . $definitions['license'] . Translations::translate('-license and your website must run under the domain of your license.'), + ])); + + return $response->withHeader('Content-Type', 'application/json')->withStatus(400); + } } } } diff --git a/system/typemill/Models/License.php b/system/typemill/Models/License.php index 8137683..fb7497d 100644 --- a/system/typemill/Models/License.php +++ b/system/typemill/Models/License.php @@ -165,6 +165,20 @@ class License return false; } + public function checkIfTest(array $urlinfo) + { + $thishost = parse_url($urlinfo['baseurl'], PHP_URL_HOST); + $thishost = str_replace("www.", "", $thishost); + $test = substr($thishost, 0, 9); + + if($test == 'localhost' OR $test = '127.0.0.1') + { + return true; + } + + return false; + } + private function validateLicense($data) { # if openssl-extension is missing, check the license once a day remotely on license server diff --git a/system/typemill/Static/Plugins.php b/system/typemill/Static/Plugins.php index 004a3b9..def143a 100644 --- a/system/typemill/Static/Plugins.php +++ b/system/typemill/Static/Plugins.php @@ -83,7 +83,9 @@ class Plugins '\Plugins\html\seo' => 'MAKER', '\Plugins\html\embed' => 'MAKER', '\Plugins\html\ebookproducts' => 'MAKER', + '\Plugins\html\bettersearch' => 'MAKER', '\Plugins\html\templates' => 'BUSINESS', + '\Plugins\html\revisions' => 'BUSINESS', ]; if(isset($premiumList['className']))