1
0
mirror of https://github.com/typemill/typemill.git synced 2025-07-31 19:30:40 +02:00

Fix license check for localhost when activating extensions

This commit is contained in:
trendschau
2024-08-13 15:54:32 +02:00
parent e672ff7011
commit 4b8f60b26f
3 changed files with 28 additions and 8 deletions

View File

@@ -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);
}
}
}
}

View File

@@ -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

View File

@@ -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']))