mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-08 22:18:28 +03:00
Drop unused RainLoop/Utils functions
This commit is contained in:
parent
efcefbaf78
commit
87e214aef7
2 changed files with 16 additions and 109 deletions
|
|
@ -18,19 +18,7 @@ class Utils
|
|||
|
||||
static $RsaKey = null;
|
||||
|
||||
static public function PgpVerifyFile(string $sFileName, string $sSignature) : bool
|
||||
{
|
||||
$sKeyFile = APP_VERSION_ROOT_PATH.'app/resources/RainLoop.asc';
|
||||
if (\file_exists($sKeyFile) && \file_exists($sFileName) && !empty($sSignature))
|
||||
{
|
||||
$sKeyFile = \file_get_contents($sKeyFile);
|
||||
return !empty($sKeyFile); // TODO
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static public function RsaPrivateKey() : string
|
||||
public static function RsaPrivateKey() : string
|
||||
{
|
||||
if (!empty(static::$RsaKey))
|
||||
{
|
||||
|
|
@ -43,7 +31,7 @@ class Utils
|
|||
static::$RsaKey = \is_string(static::$RsaKey) ? static::$RsaKey : '';
|
||||
}
|
||||
|
||||
static public function EncryptStringRSA(string $sString, string $sKey = '') : string
|
||||
public static function EncryptStringRSA(string $sString, string $sKey = '') : string
|
||||
{
|
||||
$sResult = '';
|
||||
$sKey = \md5($sKey);
|
||||
|
|
@ -80,7 +68,7 @@ class Utils
|
|||
return $sResult;
|
||||
}
|
||||
|
||||
static public function DecryptStringRSA(string $sString, string $sKey = '') : string
|
||||
public static function DecryptStringRSA(string $sString, string $sKey = '') : string
|
||||
{
|
||||
$sResult = '';
|
||||
$sKey = \md5($sKey);
|
||||
|
|
@ -112,17 +100,17 @@ class Utils
|
|||
return $sResult;
|
||||
}
|
||||
|
||||
static public function EncryptString(string $sString, string $sKey) : string
|
||||
public static function EncryptString(string $sString, string $sKey) : string
|
||||
{
|
||||
return \MailSo\Base\Crypt::Encrypt($sString, $sKey);
|
||||
}
|
||||
|
||||
static public function DecryptString(string $sEncryptedString, string $sKey) : string
|
||||
public static function DecryptString(string $sEncryptedString, string $sKey) : string
|
||||
{
|
||||
return \MailSo\Base\Crypt::Decrypt($sEncryptedString, $sKey);
|
||||
}
|
||||
|
||||
static public function EncryptStringQ(string $sString, string $sKey) : string
|
||||
public static function EncryptStringQ(string $sString, string $sKey) : string
|
||||
{
|
||||
// if (\MailSo\Base\Utils::FunctionExistsAndEnabled('openssl_pkey_get_private'))
|
||||
// {
|
||||
|
|
@ -134,7 +122,7 @@ class Utils
|
|||
$sKey.'Q'.static::GetShortToken());
|
||||
}
|
||||
|
||||
static public function DecryptStringQ(string $sEncryptedString, string $sKey) : string
|
||||
public static function DecryptStringQ(string $sEncryptedString, string $sKey) : string
|
||||
{
|
||||
// if (\MailSo\Base\Utils::FunctionExistsAndEnabled('openssl_pkey_get_private'))
|
||||
// {
|
||||
|
|
@ -146,13 +134,13 @@ class Utils
|
|||
$sKey.'Q'.static::GetShortToken());
|
||||
}
|
||||
|
||||
static public function EncodeKeyValues(array $aValues, string $sCustomKey = '') : string
|
||||
public static function EncodeKeyValues(array $aValues, string $sCustomKey = '') : string
|
||||
{
|
||||
return \MailSo\Base\Utils::UrlSafeBase64Encode(
|
||||
static::EncryptString(\serialize($aValues), \md5(APP_SALT.$sCustomKey)));
|
||||
}
|
||||
|
||||
static public function DecodeKeyValues(string $sEncodedValues, string $sCustomKey = '') : array
|
||||
public static function DecodeKeyValues(string $sEncodedValues, string $sCustomKey = '') : array
|
||||
{
|
||||
$aResult = \unserialize(
|
||||
static::DecryptString(
|
||||
|
|
@ -161,14 +149,14 @@ class Utils
|
|||
return \is_array($aResult) ? $aResult : array();
|
||||
}
|
||||
|
||||
static public function EncodeKeyValuesQ(array $aValues, string $sCustomKey = '') : string
|
||||
public static function EncodeKeyValuesQ(array $aValues, string $sCustomKey = '') : string
|
||||
{
|
||||
return \MailSo\Base\Utils::UrlSafeBase64Encode(
|
||||
static::EncryptStringQ(
|
||||
\serialize($aValues), \md5(APP_SALT.$sCustomKey)));
|
||||
}
|
||||
|
||||
static public function DecodeKeyValuesQ(string $sEncodedValues, string $sCustomKey = '') : array
|
||||
public static function DecodeKeyValuesQ(string $sEncodedValues, string $sCustomKey = '') : array
|
||||
{
|
||||
$aResult = \unserialize(
|
||||
static::DecryptStringQ(
|
||||
|
|
@ -177,7 +165,7 @@ class Utils
|
|||
return \is_array($aResult) ? $aResult : array();
|
||||
}
|
||||
|
||||
static public function GetConnectionToken() : string
|
||||
public static function GetConnectionToken() : string
|
||||
{
|
||||
$sKey = 'rltoken';
|
||||
|
||||
|
|
@ -191,12 +179,12 @@ class Utils
|
|||
return \md5('Connection'.APP_SALT.$sToken.'Token'.APP_SALT);
|
||||
}
|
||||
|
||||
static public function Fingerprint() : string
|
||||
public static function Fingerprint() : string
|
||||
{
|
||||
return \md5(empty($_SERVER['HTTP_USER_AGENT']) ? 'RainLoopFingerprint' : $_SERVER['HTTP_USER_AGENT']);
|
||||
}
|
||||
|
||||
static public function GetShortToken() : string
|
||||
public static function GetShortToken() : string
|
||||
{
|
||||
$sKey = 'rlsession';
|
||||
|
||||
|
|
@ -210,7 +198,7 @@ class Utils
|
|||
return \md5('Session'.APP_SALT.$sToken.'Token'.APP_SALT);
|
||||
}
|
||||
|
||||
static public function UpdateConnectionToken() : void
|
||||
public static function UpdateConnectionToken() : void
|
||||
{
|
||||
$sKey = 'rltoken';
|
||||
|
||||
|
|
@ -221,7 +209,7 @@ class Utils
|
|||
}
|
||||
}
|
||||
|
||||
static public function GetCsrfToken() : string
|
||||
public static function GetCsrfToken() : string
|
||||
{
|
||||
return \md5('Csrf'.APP_SALT.self::GetConnectionToken().'Token'.APP_SALT);
|
||||
}
|
||||
|
|
@ -326,20 +314,6 @@ class Utils
|
|||
))))));
|
||||
}
|
||||
|
||||
public static function FastCheck(string $sKey) : bool
|
||||
{
|
||||
$bResult = false;
|
||||
|
||||
$aMatches = array();
|
||||
if (!empty($sKey) && 0 < \strlen($sKey) && \preg_match('/^(RL[\d]+)\-(.+)\-([^\-]+)$/', $sKey, $aMatches) && 3 === \count($aMatches))
|
||||
{
|
||||
$bResult = $aMatches[3] === \strtoupper(\base_convert(\crc32(\md5(
|
||||
$aMatches[1].'-'.$aMatches[2].'-')), 10, 32));
|
||||
}
|
||||
|
||||
return $bResult;
|
||||
}
|
||||
|
||||
public static function CompileTemplates(array &$aList, string $sDirName, string $sNameSuffix = '')
|
||||
{
|
||||
if (\file_exists($sDirName))
|
||||
|
|
@ -463,53 +437,4 @@ class Utils
|
|||
|
||||
return @\parse_ini_string(\file_get_contents($sFileName), $bProcessSections) ?: array();
|
||||
}
|
||||
|
||||
public static function CustomBaseConvert(string $sNumberInput, string $sFromBaseInput = '0123456789', string $sToBaseInput = '0123456789')
|
||||
{
|
||||
if ($sFromBaseInput === $sToBaseInput)
|
||||
{
|
||||
return $sNumberInput;
|
||||
}
|
||||
|
||||
$mFromBase = \str_split($sFromBaseInput, 1);
|
||||
$mToBase = \str_split($sToBaseInput, 1);
|
||||
$aNumber = \str_split($sNumberInput, 1);
|
||||
$iFromLen = \strlen($sFromBaseInput);
|
||||
$iToLen = \strlen($sToBaseInput);
|
||||
$numberLen = \strlen($sNumberInput);
|
||||
$mRetVal = '';
|
||||
|
||||
if ($sToBaseInput === '0123456789')
|
||||
{
|
||||
$mRetVal = 0;
|
||||
for ($iIndex = 1; $iIndex <= $numberLen; $iIndex++)
|
||||
{
|
||||
$mRetVal = \bcadd($mRetVal, \bcmul(\array_search($aNumber[$iIndex - 1], $mFromBase), \bcpow($iFromLen, $numberLen - $iIndex)));
|
||||
}
|
||||
|
||||
return $mRetVal;
|
||||
}
|
||||
|
||||
if ($sFromBaseInput != '0123456789')
|
||||
{
|
||||
$sBase10 = static::CustomBaseConvert($sNumberInput, $sFromBaseInput, '0123456789');
|
||||
}
|
||||
else
|
||||
{
|
||||
$sBase10 = $sNumberInput;
|
||||
}
|
||||
|
||||
if ($sBase10 < \strlen($sToBaseInput))
|
||||
{
|
||||
return $mToBase[$sBase10];
|
||||
}
|
||||
|
||||
while ($sBase10 !== '0')
|
||||
{
|
||||
$mRetVal = $mToBase[\bcmod($sBase10, $iToLen)].$mRetVal;
|
||||
$sBase10 = \bcdiv($sBase10, $iToLen, 0);
|
||||
}
|
||||
|
||||
return $mRetVal;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
Version: GnuPG v2
|
||||
|
||||
mQENBFVN/RoBCAD4NYpb/iMtDARKdTnvV/9ycoTOWdAJoGAasuLprVqyI8bB0z6X
|
||||
ztJTqswgQcMzEwba5hQ9vuJ/Ylfww6mPvWJs/nmTUKxs2LlBldoSg25UDm7hyt59
|
||||
hi9zvOTwmeDNjGf5DXMib4Uuk5pH/jsmprRDZx25xA8qD2pDo0LOv5hexTwl5teA
|
||||
Zh8EAAzyiNsXbX+kab9IFwSArsvYK0YJln+tPHvT29X5B5YVt9gkwY+CWA3QV/ZG
|
||||
d71KEp+zReHICSjSy9G646JHDoG8CQ4Nytaih5oboqjU+Hkt8GeGlRlaPm3AIXqc
|
||||
3q76Og/KD1Itx7MKrfXUvCau/4HowSiO9neJABEBAAG0H1JhaW5Mb29wIDxzdXBw
|
||||
b3J0QHJhaW5sb29wLm5ldD6JATkEEwEIACMFAlVN/RoCGw8HCwkIBwMCAQYVCAIJ
|
||||
CgsEFgIDAQIeAQIXgAAKCRDtfEnZh9pFkTxVCAD0S4RMXVKsbjLm22zXE01yHWQM
|
||||
25QBRb5Z8p4ER3GcRNiKRWsNRTMRpiTdPgCyfj+tgIooMbBravDJwTkoztfWOb/P
|
||||
l3oazxhY/ivvLalk5kVY7lflWyYYn9tfGwVJYIZCKuZ67VZwtTcf6dBhbc4DizVw
|
||||
LuJAY6VNwycSHe8nrESabWzYRnw5c5ex/dmk8a1rsFXcDJBUB9MdZR7pxpniS9qB
|
||||
JByxjP6hHo5vo1y6mPDiN1wWBd+objA7ZJaXd0jnsXRHlBAk74/O5cWvmVeExYjx
|
||||
aERJEMQdBoAZNG1uTnQwjNdHfVoWDpqDSUr4QPfRv8M2pwvP4V1i6qji1r5T
|
||||
=dVNE
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
Loading…
Add table
Add a link
Reference in a new issue