mirror of
https://github.com/typemill/typemill.git
synced 2025-07-25 00:02:28 +02:00
Add license notiice to themes
This commit is contained in:
2
cache/timer.yaml
vendored
2
cache/timer.yaml
vendored
@@ -1,2 +1,2 @@
|
||||
licenseupdate: 1751827655
|
||||
refreshnavi: 1752466762
|
||||
refreshnavi: 1752870527
|
||||
|
@@ -343,6 +343,12 @@ class ControllerWebFrontend extends Controller
|
||||
$assets->addMeta('twitter_card','<meta name="twitter:card" content="summary_large_image">');
|
||||
}
|
||||
|
||||
$notice = $this->missingRessources();
|
||||
if($notice !== false)
|
||||
{
|
||||
$contentHtml = $notice . $contentHtml;
|
||||
}
|
||||
|
||||
$pagedata = [
|
||||
'home' => $home,
|
||||
'navigation' => $liveNavigation,
|
||||
@@ -470,4 +476,18 @@ class ControllerWebFrontend extends Controller
|
||||
|
||||
return $restrictionNotice;
|
||||
}
|
||||
|
||||
private function missingRessources()
|
||||
{
|
||||
$prothemes = ['lume', 'guide', 'pilot'];
|
||||
$theme = $this->settings['theme'];
|
||||
$license = $this->settings['license'] ?? false;
|
||||
if(in_array($theme, $prothemes) && !$license)
|
||||
{
|
||||
$notice = '<p style="display:block;width:100%;min-height:20px;color:white;background:red;padding:2px;text-align:center">Resources are missing for this theme.</p>';
|
||||
return $notice;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -537,97 +537,6 @@ class License
|
||||
return $responseJson;
|
||||
}
|
||||
|
||||
private function callLicenseServerOld( $licensedata, $url )
|
||||
{
|
||||
$authstring = $this->getPublicKeyPem();
|
||||
|
||||
if(!$authstring)
|
||||
{
|
||||
$this->message = Translations::translate('Please check if there is a readable file public_key.pem in your settings folder.');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$authstring = hash('sha256', substr($authstring, 0, 50));
|
||||
|
||||
$postdata = http_build_query($licensedata);
|
||||
|
||||
if(in_array('curl', get_loaded_extensions()))
|
||||
{
|
||||
$curl = curl_init($url);
|
||||
if (defined('CURLSSLOPT_NATIVE_CA') && version_compare(curl_version()['version'], '7.71', '>='))
|
||||
{
|
||||
curl_setopt($curl, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NATIVE_CA);
|
||||
}
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
|
||||
# "Content-Type: application/x-www-form-urlencoded",
|
||||
"Content-Type: application/json",
|
||||
"Accept: application/json",
|
||||
"Authorization: $authstring",
|
||||
"Connection: close"
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
if (curl_errno($curl))
|
||||
{
|
||||
$this->message = Translations::translate('We got a curl error: ') . curl_error($curl);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
curl_close($curl);
|
||||
}
|
||||
else
|
||||
{
|
||||
$options = array (
|
||||
'http' => array (
|
||||
'method' => 'POST',
|
||||
'ignore_errors' => true,
|
||||
'header' => "Content-Type: application/x-www-form-urlencoded\r\n" .
|
||||
"Accept: application/json\r\n" .
|
||||
"Authorization: $authstring\r\n" .
|
||||
"Connection: close\r\n",
|
||||
'content' => $postdata
|
||||
)
|
||||
);
|
||||
|
||||
$context = stream_context_create($options);
|
||||
|
||||
$response = file_get_contents($url, false, $context);
|
||||
|
||||
if ($response === FALSE)
|
||||
{
|
||||
if (!empty($http_response_header))
|
||||
{
|
||||
list($version, $status_code, $msg) = explode(' ', $http_response_header[0], 3);
|
||||
|
||||
$this->message = Translations::translate('We got an error from file_get_contents: ') . $status_code . ' ' . $msg;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->message = Translations::translate('No HTTP response received or file_get_contents is blocked.');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$responseJson = json_decode($response,true);
|
||||
|
||||
if(isset($responseJson['code']))
|
||||
{
|
||||
$this->message = $responseJson['code'];
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $responseJson;
|
||||
}
|
||||
|
||||
public function hashMail(string $mail)
|
||||
{
|
||||
return hash('sha256', trim($mail) . 'TYla5xa8JUur');
|
||||
|
Reference in New Issue
Block a user