From befbfca2fc10458fcf2f4d171b2280dc579c8581 Mon Sep 17 00:00:00 2001 From: trendschau Date: Tue, 16 Jul 2024 20:08:00 +0200 Subject: [PATCH] Finish 2.7.0 --- composer.lock | 48 +++++++------- .../Controllers/ControllerApiImage.php | 3 - system/typemill/Models/License.php | 62 ++++++++++++++++++- system/typemill/settings/defaults.yaml | 2 +- 4 files changed, 86 insertions(+), 29 deletions(-) diff --git a/composer.lock b/composer.lock index 53fd7f3..6380cb6 100644 --- a/composer.lock +++ b/composer.lock @@ -1810,16 +1810,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" + "reference": "0424dff1c58f028c451efff2045f5d92410bd540" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", - "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/0424dff1c58f028c451efff2045f5d92410bd540", + "reference": "0424dff1c58f028c451efff2045f5d92410bd540", "shasum": "" }, "require": { @@ -1869,7 +1869,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.30.0" }, "funding": [ { @@ -1885,20 +1885,20 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" + "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", - "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fd22ab50000ef01661e2a31d850ebaa297f8e03c", + "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c", "shasum": "" }, "require": { @@ -1949,7 +1949,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.30.0" }, "funding": [ { @@ -1965,20 +1965,20 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-06-19T12:30:46+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b" + "reference": "77fa7995ac1b21ab60769b7323d600a991a90433" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", - "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/77fa7995ac1b21ab60769b7323d600a991a90433", + "reference": "77fa7995ac1b21ab60769b7323d600a991a90433", "shasum": "" }, "require": { @@ -2029,7 +2029,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.30.0" }, "funding": [ { @@ -2045,20 +2045,20 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/polyfill-php81", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "c565ad1e63f30e7477fc40738343c62b40bc672d" + "reference": "3fb075789fb91f9ad9af537c4012d523085bd5af" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/c565ad1e63f30e7477fc40738343c62b40bc672d", - "reference": "c565ad1e63f30e7477fc40738343c62b40bc672d", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/3fb075789fb91f9ad9af537c4012d523085bd5af", + "reference": "3fb075789fb91f9ad9af537c4012d523085bd5af", "shasum": "" }, "require": { @@ -2105,7 +2105,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-php81/tree/v1.30.0" }, "funding": [ { @@ -2121,7 +2121,7 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-06-19T12:30:46+00:00" }, { "name": "symfony/yaml", diff --git a/system/typemill/Controllers/ControllerApiImage.php b/system/typemill/Controllers/ControllerApiImage.php index 4498765..5a6b053 100644 --- a/system/typemill/Controllers/ControllerApiImage.php +++ b/system/typemill/Controllers/ControllerApiImage.php @@ -191,9 +191,6 @@ class ControllerApiImage extends Controller # for all other image types, check if they should be transformed to webp if(!isset($params['keepformat']) && $this->settingActive('convertwebp')) { - echo '
';
-			var_dump($params);
-			die('set wp');
 			$media->setExtension('webp');
 		}
 
diff --git a/system/typemill/Models/License.php b/system/typemill/Models/License.php
index 20e5f4d..8137683 100644
--- a/system/typemill/Models/License.php
+++ b/system/typemill/Models/License.php
@@ -353,6 +353,66 @@ class License
 		return true;
 	}
 
+	# get the local token to make calls to premium services
+	public function getToken($refresh = false)
+	{
+		$storage 			= new StorageWrapper('\Typemill\Models\Storage');
+
+		# if not force a token refresh, use the stored token if not valid
+		if(!$refresh)
+		{			
+			$tokenfile 		= $storage->getFile('settingsFolder', '', 'token.txt');
+
+			if($tokenfile)
+			{
+				# check if still valid 
+				$filepath 	= $storage->getFolderPath('settingsFolder') . 'token.txt';
+				$filetime 	= filemtime($filepath);
+				$oneHourAgo = time() - 3600;
+
+				if ($filetime > $oneHourAgo)
+				{
+					return $tokenfile;
+				}
+			}
+		}
+
+		# if we try to get a fresh token, make sure old token is deleted
+		$storage->deleteFile('settingsFolder', '', 'token.txt');
+
+		$licensefile 		= $this->getLicenseFile();
+		if(!$licensefile)
+		{
+			$this->message 	= Translations::translate('Please check if there is a readable file license.yaml in your settings folder.');
+
+			return false;
+		}
+
+		$readableMail 		= trim($licensefile['email']);
+
+		$licensedata = [ 
+			'license'		=> $licensefile['license'], 
+			'email'			=> $this->hashMail($readableMail),
+			'domain'		=> $licensefile['domain'],
+			'signature'		=> $licensefile['signature'],
+			'plan'			=> $licensefile['plan'],
+			'payed_until' 	=> $licensefile['payed_until']
+		];
+
+		$url 				= 'https://service.typemill.net/api/v1/gettoken';
+
+		$tokenresponse 		= $this->callLicenseServer($licensedata, $url);
+
+		if($tokenresponse && isset($tokenresponse['token']) && $tokenresponse['token'])
+		{
+			$storage->writeFile('settingsFolder', '', 'token.txt', $tokenresponse['token']);
+
+			return $tokenresponse['token'];
+		}
+
+		return false;
+	}
+
 	private function callLicenseServer( $licensedata, $url )
 	{
 		$authstring 		= $this->getPublicKeyPem();
@@ -439,7 +499,7 @@ class License
 		return $responseJson;
 	}
 
-	private function hashMail(string $mail)
+	public function hashMail(string $mail)
 	{
 		return hash('sha256', trim($mail) . 'TYla5xa8JUur');
 	}
diff --git a/system/typemill/settings/defaults.yaml b/system/typemill/settings/defaults.yaml
index 75e4986..243f269 100644
--- a/system/typemill/settings/defaults.yaml
+++ b/system/typemill/settings/defaults.yaml
@@ -1,4 +1,4 @@
-version: '2.6.1'
+version: '2.7.0'
 title: 'Typemill'
 author: 'Unknown'
 copyright: false