Split Domains and Extensions actions from ActionsAdmin in separate traits

This commit is contained in:
the-djmaze 2022-12-22 14:20:21 +01:00
parent bafc5ad921
commit 6cd1007938
5 changed files with 382 additions and 387 deletions

View file

@ -0,0 +1,204 @@
<?php
namespace RainLoop\Actions;
use RainLoop\Enumerations\PluginPropertyType;
use RainLoop\Exceptions\ClientException;
trait AdminDomains
{
public function DoAdminDomainLoad() : array
{
$this->IsAdminLoggined();
return $this->DefaultResponse($this->DomainProvider()->Load($this->GetActionParam('Name', ''), false, false));
}
public function DoAdminDomainList() : array
{
$this->IsAdminLoggined();
$bIncludeAliases = !empty($this->GetActionParam('IncludeAliases', '1'));
return $this->DefaultResponse($this->DomainProvider()->GetList($bIncludeAliases));
}
public function DoAdminDomainDelete() : array
{
$this->IsAdminLoggined();
return $this->DefaultResponse($this->DomainProvider()->Delete((string) $this->GetActionParam('Name', '')));
}
public function DoAdminDomainDisable() : array
{
$this->IsAdminLoggined();
return $this->DefaultResponse($this->DomainProvider()->Disable(
(string) $this->GetActionParam('Name', ''),
'1' === (string) $this->GetActionParam('Disabled', '0')
));
}
public function DoAdminDomainSave() : array
{
$this->IsAdminLoggined();
$oDomain = $this->DomainProvider()->LoadOrCreateNewFromAction($this);
return $this->DefaultResponse($oDomain ? $this->DomainProvider()->Save($oDomain) : false);
}
public function DoAdminDomainAliasSave() : array
{
$this->IsAdminLoggined();
return $this->DefaultResponse($this->DomainProvider()->SaveAlias(
(string) $this->GetActionParam('Name', ''),
(string) $this->GetActionParam('Alias', '')
));
}
public function DoAdminDomainMatch() : array
{
$sEmail = $this->GetActionParam('username');
$sPassword = '********';
$sLogin = '';
$this->resolveLoginCredentials($sEmail, $sPassword, $sLogin);
$oDomain = \str_contains($sEmail, '@')
? $this->DomainProvider()->Load(\MailSo\Base\Utils::GetDomainFromEmail($sEmail), true)
: null;
return $this->DefaultResponse(array(
'email' => $sEmail,
'login' => $sLogin,
'domain' => $oDomain,
'whitelist' => $oDomain ? $oDomain->ValidateWhiteList($sEmail, $sLogin) : null
));
}
public function DoAdminDomainTest() : array
{
$this->IsAdminLoggined();
$bImapResult = false;
$sImapErrorDesc = '';
$bSmtpResult = false;
$sSmtpErrorDesc = '';
$bSieveResult = false;
$sSieveErrorDesc = '';
$oDomain = $this->DomainProvider()->LoadOrCreateNewFromAction($this, 'test.example.com');
if ($oDomain) {
$aAuth = $this->GetActionParam('auth');
try
{
$oImapClient = new \MailSo\Imap\ImapClient();
$oImapClient->SetLogger($this->Logger());
$oSettings = $oDomain->ImapSettings();
$oImapClient->Connect($oSettings);
if (!empty($aAuth['user'])) {
$oSettings->Login = $aAuth['user'];
$oSettings->Password = $aAuth['pass'];
$oImapClient->Login($oSettings);
}
$oImapClient->Disconnect();
$bImapResult = true;
}
catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException)
{
$this->Logger()->WriteException($oException, \LOG_ERR);
$sImapErrorDesc = $oException->getSocketMessage();
if (empty($sImapErrorDesc)) {
$sImapErrorDesc = $oException->getMessage();
}
}
catch (\Throwable $oException)
{
$this->Logger()->WriteException($oException, \LOG_ERR);
$sImapErrorDesc = $oException->getMessage();
}
if ($oDomain->OutUsePhpMail()) {
$bSmtpResult = \MailSo\Base\Utils::FunctionCallable('mail');
if (!$bSmtpResult) {
$sSmtpErrorDesc = 'PHP: mail() function is undefined';
}
} else {
try
{
$oSmtpClient = new \MailSo\Smtp\SmtpClient();
$oSmtpClient->SetLogger($this->Logger());
$oSettings = $oDomain->SmtpSettings();
$oSmtpClient->Connect($oSettings, \MailSo\Smtp\SmtpClient::EhloHelper());
if (!empty($aAuth['user'])) {
$oSettings->Login = $aAuth['user'];
$oSettings->Password = $aAuth['pass'];
$oSmtpClient->Login($oSettings);
}
$oSmtpClient->Disconnect();
$bSmtpResult = true;
}
catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException)
{
$this->Logger()->WriteException($oException, \LOG_ERR);
$sSmtpErrorDesc = $oException->getSocketMessage();
if (empty($sSmtpErrorDesc)) {
$sSmtpErrorDesc = $oException->getMessage();
}
}
catch (\Throwable $oException)
{
$this->Logger()->WriteException($oException, \LOG_ERR);
$sSmtpErrorDesc = $oException->getMessage();
}
}
if ($oDomain->UseSieve()) {
try
{
$oSieveClient = new \MailSo\Sieve\SieveClient();
$oSieveClient->SetLogger($this->Logger());
$oSettings = $oDomain->SieveSettings();
$oSieveClient->Connect($oSettings);
if (!empty($aAuth['user'])) {
$oSettings->Login = $aAuth['user'];
$oSettings->Password = $aAuth['pass'];
$oSieveClient->Login($oSettings);
}
$oSieveClient->Disconnect();
$bSieveResult = true;
}
catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException)
{
$this->Logger()->WriteException($oException, \LOG_ERR);
$sSieveErrorDesc = $oException->getSocketMessage();
if (empty($sSieveErrorDesc)) {
$sSieveErrorDesc = $oException->getMessage();
}
}
catch (\Throwable $oException)
{
$this->Logger()->WriteException($oException, \LOG_ERR);
$sSieveErrorDesc = $oException->getMessage();
}
} else {
$bSieveResult = true;
}
}
return $this->DefaultResponse(array(
'Imap' => $bImapResult ? true : $sImapErrorDesc,
'Smtp' => $bSmtpResult ? true : $sSmtpErrorDesc,
'Sieve' => $bSieveResult ? true : $sSieveErrorDesc
));
}
}

View file

@ -0,0 +1,170 @@
<?php
namespace RainLoop\Actions;
use RainLoop\Enumerations\PluginPropertyType;
use RainLoop\Exceptions\ClientException;
trait AdminExtensions
{
public function DoAdminPackagesList() : array
{
return $this->DefaultResponse(\SnappyMail\Repository::getPackagesList());
}
public function DoAdminPackageDelete() : array
{
$sId = $this->GetActionParam('Id', '');
$bResult = \SnappyMail\Repository::deletePackage($sId);
static::pluginEnable($sId, false);
return $this->DefaultResponse($bResult);
}
public function DoAdminPackageInstall() : array
{
$sType = $this->GetActionParam('Type', '');
$bResult = \SnappyMail\Repository::installPackage(
$sType,
$this->GetActionParam('Id', ''),
$this->GetActionParam('File', '')
);
return $this->DefaultResponse($bResult ?
('plugin' !== $sType ? array('Reload' => true) : true) : false);
}
public function DoAdminPluginDisable() : array
{
$this->IsAdminLoggined();
$sId = (string) $this->GetActionParam('Id', '');
$bDisable = '1' === (string) $this->GetActionParam('Disabled', '1');
if (!$bDisable) {
$oPlugin = $this->Plugins()->CreatePluginByName($sId);
if ($oPlugin) {
$sValue = $oPlugin->Supported();
if (\strlen($sValue)) {
return $this->FalseResponse(Notifications::UnsupportedPluginPackage, $sValue);
}
} else {
return $this->FalseResponse(Notifications::InvalidPluginPackage);
}
}
return $this->DefaultResponse($this->pluginEnable($sId, !$bDisable));
}
public function DoAdminPluginLoad() : array
{
$this->IsAdminLoggined();
$mResult = false;
$sId = (string) $this->GetActionParam('Id', '');
if (!empty($sId)) {
$oPlugin = $this->Plugins()->CreatePluginByName($sId);
if ($oPlugin) {
$mResult = array(
'@Object' => 'Object/Plugin',
'Id' => $sId,
'Name' => $oPlugin->Name(),
'Readme' => $oPlugin->Description(),
'Config' => array()
);
$aMap = $oPlugin->ConfigMap();
if (\is_array($aMap)) {
$oConfig = $oPlugin->Config();
foreach ($aMap as $oItem) {
if ($oItem) {
if ($oItem instanceof \RainLoop\Plugins\Property) {
if (PluginPropertyType::PASSWORD === $oItem->Type()) {
$oItem->SetValue(static::APP_DUMMY);
} else {
$oItem->SetValue($oConfig->Get('plugin', $oItem->Name(), ''));
}
$mResult['Config'][] = $oItem;
} else if ($oItem instanceof \RainLoop\Plugins\PropertyCollection) {
foreach ($oItem as $oSubItem) {
if ($oSubItem && $oSubItem instanceof \RainLoop\Plugins\Property) {
if (PluginPropertyType::PASSWORD === $oSubItem->Type()) {
$oSubItem->SetValue(static::APP_DUMMY);
} else {
$oSubItem->SetValue($oConfig->Get('plugin', $oSubItem->Name(), ''));
}
}
}
$mResult['Config'][] = $oItem;
}
}
}
}
}
}
return $this->DefaultResponse($mResult);
}
public function DoAdminPluginSettingsUpdate() : array
{
$this->IsAdminLoggined();
$sId = (string) $this->GetActionParam('Id', '');
if (!empty($sId)) {
$oPlugin = $this->Plugins()->CreatePluginByName($sId);
if ($oPlugin) {
$oConfig = $oPlugin->Config();
$aMap = $oPlugin->ConfigMap(true);
if (\is_array($aMap)) {
$aSettings = (array) $this->GetActionParam('Settings', []);
foreach ($aMap as $oItem) {
$sKey = $oItem->Name();
$sValue = $aSettings[$sKey] ?? $oConfig->Get('plugin', $sKey);
if (PluginPropertyType::PASSWORD !== $oItem->Type() || static::APP_DUMMY !== $sValue) {
$oItem->SetValue($sValue);
$mResultValue = $oItem->Value();
if (null !== $mResultValue) {
$oConfig->Set('plugin', $sKey, $mResultValue);
}
}
}
}
if ($oConfig->Save()) {
return $this->TrueResponse();
}
}
}
throw new ClientException(Notifications::CantSavePluginSettings);
}
private function pluginEnable(string $sName, bool $bEnable = true) : bool
{
if (!\strlen($sName)) {
return false;
}
$oConfig = $this->Config();
$aEnabledPlugins = \SnappyMail\Repository::getEnabledPackagesNames();
$aNewEnabledPlugins = array();
if ($bEnable) {
$aNewEnabledPlugins = $aEnabledPlugins;
$aNewEnabledPlugins[] = $sName;
} else {
foreach ($aEnabledPlugins as $sPlugin) {
if ($sName !== $sPlugin && \strlen($sPlugin)) {
$aNewEnabledPlugins[] = $sPlugin;
}
}
}
$oConfig->Set('plugins', 'enabled_list', \trim(\implode(',', \array_unique($aNewEnabledPlugins)), ' ,'));
return $oConfig->Save();
}
}

View file

@ -7,6 +7,8 @@ use RainLoop\Exceptions\ClientException;
class ActionsAdmin extends Actions
{
use Actions\AdminDomains;
use Actions\AdminExtensions;
public function DoAdminClearCache() : array
{
@ -200,211 +202,6 @@ class ActionsAdmin extends Actions
: false);
}
public function DoAdminDomainLoad() : array
{
$this->IsAdminLoggined();
return $this->DefaultResponse($this->DomainProvider()->Load($this->GetActionParam('Name', ''), false, false));
}
public function DoAdminDomainList() : array
{
$this->IsAdminLoggined();
$bIncludeAliases = !empty($this->GetActionParam('IncludeAliases', '1'));
return $this->DefaultResponse($this->DomainProvider()->GetList($bIncludeAliases));
}
public function DoAdminDomainDelete() : array
{
$this->IsAdminLoggined();
return $this->DefaultResponse($this->DomainProvider()->Delete((string) $this->GetActionParam('Name', '')));
}
public function DoAdminDomainDisable() : array
{
$this->IsAdminLoggined();
return $this->DefaultResponse($this->DomainProvider()->Disable(
(string) $this->GetActionParam('Name', ''),
'1' === (string) $this->GetActionParam('Disabled', '0')
));
}
public function DoAdminDomainSave() : array
{
$this->IsAdminLoggined();
$oDomain = $this->DomainProvider()->LoadOrCreateNewFromAction($this);
return $this->DefaultResponse($oDomain ? $this->DomainProvider()->Save($oDomain) : false);
}
public function DoAdminDomainAliasSave() : array
{
$this->IsAdminLoggined();
return $this->DefaultResponse($this->DomainProvider()->SaveAlias(
(string) $this->GetActionParam('Name', ''),
(string) $this->GetActionParam('Alias', '')
));
}
public function DoAdminDomainMatch() : array
{
$sEmail = $this->GetActionParam('username');
$sPassword = '********';
$sLogin = '';
$this->resolveLoginCredentials($sEmail, $sPassword, $sLogin);
$oDomain = \str_contains($sEmail, '@')
? $this->DomainProvider()->Load(\MailSo\Base\Utils::GetDomainFromEmail($sEmail), true)
: null;
return $this->DefaultResponse(array(
'email' => $sEmail,
'login' => $sLogin,
'domain' => $oDomain,
'whitelist' => $oDomain ? $oDomain->ValidateWhiteList($sEmail, $sLogin) : null
));
}
public function DoAdminDomainTest() : array
{
$this->IsAdminLoggined();
$bImapResult = false;
$sImapErrorDesc = '';
$bSmtpResult = false;
$sSmtpErrorDesc = '';
$bSieveResult = false;
$sSieveErrorDesc = '';
$oDomain = $this->DomainProvider()->LoadOrCreateNewFromAction($this, 'test.example.com');
if ($oDomain)
{
$aAuth = $this->GetActionParam('auth');
try
{
$oImapClient = new \MailSo\Imap\ImapClient();
$oImapClient->SetLogger($this->Logger());
$oSettings = $oDomain->ImapSettings();
$oImapClient->Connect($oSettings);
if (!empty($aAuth['user'])) {
$oSettings->Login = $aAuth['user'];
$oSettings->Password = $aAuth['pass'];
$oImapClient->Login($oSettings);
}
$oImapClient->Disconnect();
$bImapResult = true;
}
catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException)
{
$this->Logger()->WriteException($oException, \LOG_ERR);
$sImapErrorDesc = $oException->getSocketMessage();
if (empty($sImapErrorDesc))
{
$sImapErrorDesc = $oException->getMessage();
}
}
catch (\Throwable $oException)
{
$this->Logger()->WriteException($oException, \LOG_ERR);
$sImapErrorDesc = $oException->getMessage();
}
if ($oDomain->OutUsePhpMail())
{
$bSmtpResult = \MailSo\Base\Utils::FunctionCallable('mail');
if (!$bSmtpResult)
{
$sSmtpErrorDesc = 'PHP: mail() function is undefined';
}
}
else
{
try
{
$oSmtpClient = new \MailSo\Smtp\SmtpClient();
$oSmtpClient->SetLogger($this->Logger());
$oSettings = $oDomain->SmtpSettings();
$oSmtpClient->Connect($oSettings, \MailSo\Smtp\SmtpClient::EhloHelper());
if (!empty($aAuth['user'])) {
$oSettings->Login = $aAuth['user'];
$oSettings->Password = $aAuth['pass'];
$oSmtpClient->Login($oSettings);
}
$oSmtpClient->Disconnect();
$bSmtpResult = true;
}
catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException)
{
$this->Logger()->WriteException($oException, \LOG_ERR);
$sSmtpErrorDesc = $oException->getSocketMessage();
if (empty($sSmtpErrorDesc))
{
$sSmtpErrorDesc = $oException->getMessage();
}
}
catch (\Throwable $oException)
{
$this->Logger()->WriteException($oException, \LOG_ERR);
$sSmtpErrorDesc = $oException->getMessage();
}
}
if ($oDomain->UseSieve())
{
try
{
$oSieveClient = new \MailSo\Sieve\SieveClient();
$oSieveClient->SetLogger($this->Logger());
$oSettings = $oDomain->SieveSettings();
$oSieveClient->Connect($oSettings);
if (!empty($aAuth['user'])) {
$oSettings->Login = $aAuth['user'];
$oSettings->Password = $aAuth['pass'];
$oSieveClient->Login($oSettings);
}
$oSieveClient->Disconnect();
$bSieveResult = true;
}
catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException)
{
$this->Logger()->WriteException($oException, \LOG_ERR);
$sSieveErrorDesc = $oException->getSocketMessage();
if (empty($sSieveErrorDesc))
{
$sSieveErrorDesc = $oException->getMessage();
}
}
catch (\Throwable $oException)
{
$this->Logger()->WriteException($oException, \LOG_ERR);
$sSieveErrorDesc = $oException->getMessage();
}
}
else
{
$bSieveResult = true;
}
}
return $this->DefaultResponse(array(
'Imap' => $bImapResult ? true : $sImapErrorDesc,
'Smtp' => $bSmtpResult ? true : $sSmtpErrorDesc,
'Sieve' => $bSieveResult ? true : $sSieveErrorDesc
));
}
public function DoAdminPHPExtensions() : array
{
$aResult = [
@ -434,31 +231,6 @@ class ActionsAdmin extends Actions
return $this->DefaultResponse($aResult);
}
public function DoAdminPackagesList() : array
{
return $this->DefaultResponse(\SnappyMail\Repository::getPackagesList());
}
public function DoAdminPackageDelete() : array
{
$sId = $this->GetActionParam('Id', '');
$bResult = \SnappyMail\Repository::deletePackage($sId);
static::pluginEnable($sId, false);
return $this->DefaultResponse($bResult);
}
public function DoAdminPackageInstall() : array
{
$sType = $this->GetActionParam('Type', '');
$bResult = \SnappyMail\Repository::installPackage(
$sType,
$this->GetActionParam('Id', ''),
$this->GetActionParam('File', '')
);
return $this->DefaultResponse($bResult ?
('plugin' !== $sType ? array('Reload' => true) : true) : false);
}
// /?admin/Backup
public function DoAdminBackup() : void
{
@ -528,118 +300,6 @@ class ActionsAdmin extends Actions
return $this->DefaultResponse(\SnappyMail\Upgrade::core());
}
public function DoAdminPluginDisable() : array
{
$this->IsAdminLoggined();
$sId = (string) $this->GetActionParam('Id', '');
$bDisable = '1' === (string) $this->GetActionParam('Disabled', '1');
if (!$bDisable)
{
$oPlugin = $this->Plugins()->CreatePluginByName($sId);
if ($oPlugin)
{
$sValue = $oPlugin->Supported();
if (\strlen($sValue))
{
return $this->FalseResponse(Notifications::UnsupportedPluginPackage, $sValue);
}
}
else
{
return $this->FalseResponse(Notifications::InvalidPluginPackage);
}
}
return $this->DefaultResponse($this->pluginEnable($sId, !$bDisable));
}
public function DoAdminPluginLoad() : array
{
$this->IsAdminLoggined();
$mResult = false;
$sId = (string) $this->GetActionParam('Id', '');
if (!empty($sId)) {
$oPlugin = $this->Plugins()->CreatePluginByName($sId);
if ($oPlugin) {
$mResult = array(
'@Object' => 'Object/Plugin',
'Id' => $sId,
'Name' => $oPlugin->Name(),
'Readme' => $oPlugin->Description(),
'Config' => array()
);
$aMap = $oPlugin->ConfigMap();
if (\is_array($aMap)) {
$oConfig = $oPlugin->Config();
foreach ($aMap as $oItem) {
if ($oItem) {
if ($oItem instanceof \RainLoop\Plugins\Property) {
if (PluginPropertyType::PASSWORD === $oItem->Type()) {
$oItem->SetValue(static::APP_DUMMY);
} else {
$oItem->SetValue($oConfig->Get('plugin', $oItem->Name(), ''));
}
$mResult['Config'][] = $oItem;
} else if ($oItem instanceof \RainLoop\Plugins\PropertyCollection) {
foreach ($oItem as $oSubItem) {
if ($oSubItem && $oSubItem instanceof \RainLoop\Plugins\Property) {
if (PluginPropertyType::PASSWORD === $oSubItem->Type()) {
$oSubItem->SetValue(static::APP_DUMMY);
} else {
$oSubItem->SetValue($oConfig->Get('plugin', $oSubItem->Name(), ''));
}
}
}
$mResult['Config'][] = $oItem;
}
}
}
}
}
}
return $this->DefaultResponse($mResult);
}
public function DoAdminPluginSettingsUpdate() : array
{
$this->IsAdminLoggined();
$sId = (string) $this->GetActionParam('Id', '');
if (!empty($sId)) {
$oPlugin = $this->Plugins()->CreatePluginByName($sId);
if ($oPlugin) {
$oConfig = $oPlugin->Config();
$aMap = $oPlugin->ConfigMap(true);
if (\is_array($aMap)) {
$aSettings = (array) $this->GetActionParam('Settings', []);
foreach ($aMap as $oItem) {
$sKey = $oItem->Name();
$sValue = $aSettings[$sKey] ?? $oConfig->Get('plugin', $sKey);
if (PluginPropertyType::PASSWORD !== $oItem->Type() || static::APP_DUMMY !== $sValue) {
$oItem->SetValue($sValue);
$mResultValue = $oItem->Value();
if (null !== $mResultValue) {
$oConfig->Set('plugin', $sKey, $mResultValue);
}
}
}
}
if ($oConfig->Save()) {
return $this->TrueResponse();
}
}
}
throw new ClientException(Notifications::CantSavePluginSettings);
}
public function DoAdminQRCode() : array
{
$user = (string) $this->GetActionParam('username', '');
@ -667,39 +327,6 @@ class ActionsAdmin extends Actions
return $sToken;
}
private function pluginEnable(string $sName, bool $bEnable = true) : bool
{
if (!\strlen($sName))
{
return false;
}
$oConfig = $this->Config();
$aEnabledPlugins = \SnappyMail\Repository::getEnabledPackagesNames();
$aNewEnabledPlugins = array();
if ($bEnable)
{
$aNewEnabledPlugins = $aEnabledPlugins;
$aNewEnabledPlugins[] = $sName;
}
else
{
foreach ($aEnabledPlugins as $sPlugin)
{
if ($sName !== $sPlugin && \strlen($sPlugin))
{
$aNewEnabledPlugins[] = $sPlugin;
}
}
}
$oConfig->Set('plugins', 'enabled_list', \trim(\implode(',', \array_unique($aNewEnabledPlugins)), ' ,'));
return $oConfig->Save();
}
private function setConfigFromParams(\RainLoop\Config\Application $oConfig, string $sParamName, string $sConfigSector, string $sConfigName, string $sType = 'string', ?callable $mStringCallback = null): void
{
if ($this->HasActionParam($sParamName)) {

View file

@ -18,8 +18,7 @@ abstract class Api
public static function Actions() : Actions
{
static $oActions = null;
if (null === $oActions)
{
if (null === $oActions) {
$oActions = new Actions();
}
@ -121,19 +120,16 @@ abstract class Api
public static function ClearUserData(string $sEmail) : bool
{
if (\strlen($sEmail))
{
if (\strlen($sEmail)) {
$sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail);
$oStorageProvider = static::Actions()->StorageProvider();
if ($oStorageProvider && $oStorageProvider->IsActive())
{
if ($oStorageProvider && $oStorageProvider->IsActive()) {
$oStorageProvider->DeleteStorage($sEmail);
}
$oAddressBookProvider = static::Actions()->AddressBookProvider();
if ($oAddressBookProvider)
{
if ($oAddressBookProvider) {
$oAddressBookProvider->DeleteAllContacts($sEmail);
}

View file

@ -75,8 +75,7 @@ class Utils
public static function GetConnectionToken() : string
{
$sToken = static::GetCookie(self::CONNECTION_TOKEN);
if (!$sToken)
{
if (!$sToken) {
$sToken = \MailSo\Base\Utils::Sha1Rand(APP_SALT);
static::SetCookie(self::CONNECTION_TOKEN, $sToken, \time() + 3600 * 24 * 30);
}
@ -92,8 +91,7 @@ class Utils
public static function UpdateConnectionToken() : void
{
$sToken = static::GetCookie(self::CONNECTION_TOKEN);
if ($sToken)
{
if ($sToken) {
static::SetCookie(self::CONNECTION_TOKEN, $sToken, \time() + 3600 * 24 * 30);
}
}