Skip to content

Commit

Permalink
Remove Ioncube and License stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Palm committed Oct 28, 2024
1 parent d155c99 commit 57e79d4
Show file tree
Hide file tree
Showing 24 changed files with 65 additions and 1,421 deletions.
10 changes: 1 addition & 9 deletions classes/Components/EnvironmentConfig/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ private static function onInitEnvironmentConfigProvider(ContainerInterface $cont
/** @var LegacyApplication $app */
$app = $container->get('LegacyApplication');

if (!class_exists('License')) {
$test = dirname(__DIR__, 3) . '/phpwf/plugins/class.license.php';
$file = new SplFileInfo($test);
if ($file->isFile()) {
include $test;
}
}

return new EnvironmentConfigProvider(new License(), $app->Conf);
return new EnvironmentConfigProvider($app->Conf);
}
}
127 changes: 1 addition & 126 deletions classes/Components/EnvironmentConfig/EnvironmentConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,28 @@ final class EnvironmentConfig
*/
private $userdataDirectoryPath;

/**
* @var array|null $ioncubeSystemInformation
*/
private $ioncubeSystemInformation;

/**
* @param string $databaseHost
* @param string $databaseName
* @param string $databaseUser
* @param string $databasePassword
* @param int $databasePort
* @param string $userdataDirectoryPath
* @param array $ioncubeSystemInformation
*/
public function __construct(
string $databaseHost,
string $databaseName,
string $databaseUser,
string $databasePassword,
int $databasePort,
string $userdataDirectoryPath,
?array $ioncubeSystemInformation
string $userdataDirectoryPath
) {
$this->databaseHost = $databaseHost;
$this->databaseName = $databaseName;
$this->databaseUser = $databaseUser;
$this->databasePassword = $databasePassword;
$this->databasePort = $databasePort;
$this->userdataDirectoryPath = $userdataDirectoryPath;
$this->ioncubeSystemInformation = $ioncubeSystemInformation;
}

/**
Expand Down Expand Up @@ -113,121 +105,4 @@ public function getUserdataDirectoryPath(): string
{
return $this->userdataDirectoryPath;
}

/**
* @return ?array
*/
public function getIoncubeSystemInformation(): ?array
{
return $this->ioncubeSystemInformation;
}

/**
* @return bool
*/
public function isSystemHostedOnCloud(): bool
{
return !empty($this->ioncubeSystemInformation['iscloud']['value']);
}

/**
* @return bool
*/
public function isSystemFlaggedAsDevelopmentVersion(): bool
{
return !empty($this->ioncubeSystemInformation['isdevelopmentversion']['value']);
}

/**
* @return bool
*/
public function isSystemFlaggedAsTestVersion(): bool
{
return !empty($this->ioncubeSystemInformation['testlizenz']['value']);
}

/**
* @return int
*/
public function getMaxUser(): int
{
if (!isset($this->ioncubeSystemInformation['maxuser']['value'])) {
return 0;
}

return (int)$this->ioncubeSystemInformation['maxuser']['value'];
}

/**
* @return int
*/
public function getMaxLightUser(): int
{
if (!isset($this->ioncubeSystemInformation['maxlightuser']['value'])) {
return 0;
}

return (int)$this->ioncubeSystemInformation['maxlightuser']['value'];
}

/**
* @return int|null
*/
public function getExpirationTimeStamp(): ?int
{
if (!isset($this->ioncubeSystemInformation['expdate']['value'])) {
return 0;
}

return (int)$this->ioncubeSystemInformation['expdate']['value'];
}

/**
* @param string $name
*
* @return string|null
*/
public function getValueOfSpecificIoncubeSystemInformation(string $name): ?string
{
if ($this->ioncubeSystemInformation === null) {
return null;
}

if (array_key_exists($name, $this->ioncubeSystemInformation)) {
return $this->ioncubeSystemInformation[$name]['value'];
}

return null;
}

/**
* @return array
*/
public function getSystemFallbackEmailAddresses(): array
{
$emailAddresses = [];
$mailAddressSelfBuyCustomer = (string)$this->getValueOfSpecificIoncubeSystemInformation('buyemail');
if ($mailAddressSelfBuyCustomer !== '') {
$emailAddresses[] = $mailAddressSelfBuyCustomer;
}

$mailAddressCustomerLicence = (string)$this->getValueOfSpecificIoncubeSystemInformation('emaillicence');
if ($mailAddressCustomerLicence !== ''
&& strpos($mailAddressCustomerLicence, '@') !== false
&& strpos($mailAddressCustomerLicence, '@xentral.com') === false
&& strpos($mailAddressCustomerLicence, '@xentral.biz') === false) {
$emailAddresses[] = $mailAddressCustomerLicence;
}

//in old licences email-address of customer can be insert in name instead email
$nameCustomerLicence = (string)$this->getValueOfSpecificIoncubeSystemInformation('namelicence');
if ($nameCustomerLicence !== ''
&& strpos($nameCustomerLicence, '@') !== false
&& strpos($nameCustomerLicence, '@xentral.com') === false
&& strpos($nameCustomerLicence, '@xentral.biz') === false) {
$emailAddresses[] = $nameCustomerLicence;
}

return $emailAddresses;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,14 @@

final class EnvironmentConfigProvider
{
/** @var License $license */
private $license;

/** @var Config $config */
private $config;

/**
* @param License $license
* @param Config $config
*/
public function __construct(License $license, Config $config)
public function __construct(Config $config)
{
$this->license = $license;
$this->config = $config;
}

Expand All @@ -30,8 +25,7 @@ public function createEnvironmentConfig(): EnvironmentConfig
{
$environmentConfig = new EnvironmentConfig(
$this->config->WFdbhost, $this->config->WFdbname, $this->config->WFdbuser,
$this->config->WFdbpass, $this->config->WFdbport, $this->config->WFuserdata,
(array)$this->license->getProperties()
$this->config->WFdbpass, $this->config->WFdbport, $this->config->WFuserdata
);

return $environmentConfig;
Expand Down
96 changes: 0 additions & 96 deletions classes/Core/ErrorHandler/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ public function handleError($code, $message, $file, $line)
public function handleException($exception)
{
$title = null;
if ($this->isIoncubeError($exception)) {
$title = $this->handleIoncubeError($exception);
}

$data = new ErrorPageData($exception, $title);
$renderer = new ErrorPageRenderer($data);
header('HTTP/1.1 500 Internal Server Error');
Expand Down Expand Up @@ -125,96 +121,4 @@ private function isErrorTypeHaltingExecution($type)
{
return in_array((int)$type, self::THROWABLE_ERROR_TYPES, true);
}

/**
* @param Throwable $exception
*
* @return bool
*/
private function isIoncubeError($exception)
{
if ((int)$exception->getCode() !== E_CORE_ERROR) {
return false;
}
if (strpos($exception->getMessage(), 'requires a license file.') !== false) {
return true;
}
if (strpos($exception->getMessage(), 'ionCube Encoder') !== false) {
return true;
}

return false;
}

/**
* @param Throwable $exception
*
* @return string|null
*/
private function handleIoncubeError($exception)
{
$file = $this->extractFileFromIoncubeError($exception);
if (empty($file)) {
return null;
}

if (!$this->isDeleteableFile($file)) {
return null;
}

@unlink($file);
if(is_file($file)) {
return sprintf('Es wurde eine alte Systemdatei gefunden die nicht manuell gelöscht werden konnte.
Bitte löschen Sie die Datei %s', $file);
}
return 'Es wurde eine alte Systemdatei gefunden und automatisch gelöscht.
Bitte führen Sie das Update nochmal durch dann sollte diese Meldung nicht mehr erscheinen.';
}

/**
* @param string $file
*
* @return bool
*/
private function isDeleteableFile(string $file)
{
if (!is_file($file)) {
return false;
}
$dir = dirname($file);
foreach (self::DELETE_FILE_FOLDERS as $folder) {
if (substr($dir, -strlen($folder)) === $folder) {
return true;
}
}

return false;
}

/**
* @example "<br>The encoded file <b>/var/www/xentral/www/pages/adresse.php</b> requires a license file.<br>"
* "The license file <b>/var/www/xentral/key.php</b> is corrupt."
*
* @param Throwable $exception
*
* @return string|null
*/
private function extractFileFromIoncubeError($exception)
{
$message = strip_tags($exception->getMessage());
$theFilePos = stripos($message, 'The File ');
if ($theFilePos === false) {
$theFilePos = strpos($message, 'The encoded file');
if ($theFilePos === false) {
return null;
}
$theFilePos += 16;
} else {
$theFilePos += 9;
}
$file = trim(substr($message, $theFilePos));
$file = explode(' ', $file);

return reset($file);
}
}
9 changes: 0 additions & 9 deletions classes/Core/ErrorHandler/ErrorPageData.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,15 +323,6 @@ private function getPhpExtensionsDefinedCallbacks()
'ldap' => function () {
return function_exists('ldap_connect');
},
'ioncube' => function () {
if (!function_exists('ioncube_loader_version')) {
return false;
}

$ioncubeMajorVersion = (int)@ioncube_loader_version();

return $ioncubeMajorVersion >= 5;
},
];
}

Expand Down
Loading

0 comments on commit 57e79d4

Please sign in to comment.