Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sg_news
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TYPO3
sg_news
Commits
309b3e65
Commit
309b3e65
authored
3 years ago
by
Georgi Mateev
Browse files
Options
Downloads
Patches
Plain Diff
[BUGFIX] Restored LicensingService
parent
682ef582
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Classes/Service/LicensingService.php
+99
-0
99 additions, 0 deletions
Classes/Service/LicensingService.php
with
99 additions
and
0 deletions
Classes/Service/LicensingService.php
0 → 100644
+
99
−
0
View file @
309b3e65
<?php
namespace
SGalinski\SgNews\Service
;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use
Psr\Http\Message\ResponseInterface
;
use
Psr\Http\Message\ServerRequestInterface
;
use
SGalinski\SgNews\Utility\ExtensionUtility
;
use
TYPO3\CMS\Core\Authentication\BackendUserAuthentication
;
use
TYPO3\CMS\Core\Http\NullResponse
;
use
TYPO3\CMS\Core\Utility\GeneralUtility
;
/**
* Class SGalinski\SgNews\Service\LicensingService
*/
class
LicensingService
{
/**
* Licensing Service Url
*/
const
URL
=
'https://www.sgalinski.de/?eID=sgLicensing'
;
/**
* Licensing Service Url
*/
const
EXTENSION_KEY
=
'sg_news'
;
/** @var bool|NULL */
private
static
$isLicenseKeyValid
;
/**
* @return boolean
*/
public
static
function
checkKey
():
bool
{
if
(
static
::
$isLicenseKeyValid
===
NULL
)
{
static
::
$isLicenseKeyValid
=
FALSE
;
$configuration
=
$GLOBALS
[
'TYPO3_CONF_VARS'
][
'EXTENSIONS'
][
self
::
EXTENSION_KEY
]
??
[];
if
(
isset
(
$configuration
[
'key'
])
&&
$key
=
trim
(
$configuration
[
'key'
]))
{
static
::
$isLicenseKeyValid
=
(
bool
)
preg_match
(
'/^([A-Z\d]{6}-?){4}$/'
,
$key
);
}
}
return
static
::
$isLicenseKeyValid
;
}
/**
* Licensing Service ping
*
* @param boolean $returnUrl
* @return string
*/
public
static
function
ping
(
$returnUrl
=
FALSE
):
string
{
try
{
$configuration
=
$GLOBALS
[
'TYPO3_CONF_VARS'
][
'EXTENSIONS'
][
self
::
EXTENSION_KEY
]
??
[];
$key
=
''
;
if
(
isset
(
$configuration
[
'key'
]))
{
$key
=
trim
(
$configuration
[
'key'
]);
}
$params
=
[
'extension'
=>
self
::
EXTENSION_KEY
,
'host'
=>
GeneralUtility
::
getIndpEnv
(
'HTTP_HOST'
),
'key'
=>
$key
];
$params
=
http_build_query
(
$params
);
$pingUrl
=
self
::
URL
;
$pingUrl
.
=
$params
!==
''
?
(
strpos
(
$pingUrl
,
'?'
)
===
FALSE
?
'?'
:
'&'
)
.
$params
:
''
;
if
(
$returnUrl
)
{
return
$pingUrl
;
}
GeneralUtility
::
getUrl
(
$pingUrl
);
}
catch
(
\Exception
$exception
)
{
}
return
''
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment