mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 13:09:21 +03:00
Privacy/GDPR friendly version (removed: Social, Gravatar, Facebook, Google, Twitter, DropBox, OwnCloud)
Also removed: POP3, OAuth2 and update feature Added: admin password_hash/password_verify Requires: PHP 7.3+ Replaced: CRLF with LF Replaced: pclZip with ZipArchive
This commit is contained in:
parent
15ceddc202
commit
2cada68f41
293 changed files with 23728 additions and 85420 deletions
|
|
@ -18,20 +18,11 @@ class Utils
|
|||
|
||||
static $RsaKey = null;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sFileName
|
||||
* @param string $sSignature
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
static public function PgpVerifyFile($sFileName, $sSignature)
|
||||
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))
|
||||
|
|
@ -43,10 +34,7 @@ class Utils
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
static public function RsaPrivateKey()
|
||||
static public function RsaPrivateKey() : string
|
||||
{
|
||||
if (!empty(\RainLoop\Utils::$RsaKey))
|
||||
{
|
||||
|
|
@ -60,12 +48,9 @@ class Utils
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $sString
|
||||
* @param string $sKey = ''
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
static public function EncryptStringRSA($sString, $sKey = '')
|
||||
static public function EncryptStringRSA(string $sString, string $sKey = '')
|
||||
{
|
||||
$sResult = '';
|
||||
$sKey = \md5($sKey);
|
||||
|
|
@ -103,12 +88,9 @@ class Utils
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $sString
|
||||
* @param string $sKey = ''
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
static public function DecryptStringRSA($sString, $sKey = '')
|
||||
static public function DecryptStringRSA(string $sString, string $sKey = '')
|
||||
{
|
||||
$sResult = '';
|
||||
$sKey = \md5($sKey);
|
||||
|
|
@ -140,35 +122,17 @@ class Utils
|
|||
return $sResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sString
|
||||
* @param string $sKey
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static public function EncryptString($sString, $sKey)
|
||||
static public function EncryptString(string $sString, string $sKey) : string
|
||||
{
|
||||
return \MailSo\Base\Crypt::XxteaEncrypt($sString, $sKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sEncriptedString
|
||||
* @param string $sKey
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static public function DecryptString($sEncriptedString, $sKey)
|
||||
static public function DecryptString(string $sEncriptedString, string $sKey) : string
|
||||
{
|
||||
return \MailSo\Base\Crypt::XxteaDecrypt($sEncriptedString, $sKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sString
|
||||
* @param string $sKey
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static public function EncryptStringQ($sString, $sKey)
|
||||
static public function EncryptStringQ(string $sString, string $sKey) : string
|
||||
{
|
||||
// if (\MailSo\Base\Utils::FunctionExistsAndEnabled('openssl_pkey_get_private'))
|
||||
// {
|
||||
|
|
@ -180,13 +144,7 @@ class Utils
|
|||
$sKey.'Q'.\RainLoop\Utils::GetShortToken());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sEncriptedString
|
||||
* @param string $sKey
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static public function DecryptStringQ($sEncriptedString, $sKey)
|
||||
static public function DecryptStringQ(string $sEncriptedString, string $sKey) : string
|
||||
{
|
||||
// if (\MailSo\Base\Utils::FunctionExistsAndEnabled('openssl_pkey_get_private'))
|
||||
// {
|
||||
|
|
@ -198,25 +156,13 @@ class Utils
|
|||
$sKey.'Q'.\RainLoop\Utils::GetShortToken());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $aValues
|
||||
* @param string $sCustomKey = ''
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static public function EncodeKeyValues(array $aValues, $sCustomKey = '')
|
||||
static public function EncodeKeyValues(array $aValues, string $sCustomKey = '') : string
|
||||
{
|
||||
return \MailSo\Base\Utils::UrlSafeBase64Encode(
|
||||
\RainLoop\Utils::EncryptString(@\serialize($aValues), \md5(APP_SALT.$sCustomKey)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sEncodedValues
|
||||
* @param string $sCustomKey = ''
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static public function DecodeKeyValues($sEncodedValues, $sCustomKey = '')
|
||||
static public function DecodeKeyValues(string $sEncodedValues, string $sCustomKey = '') : array
|
||||
{
|
||||
$aResult = @\unserialize(
|
||||
\RainLoop\Utils::DecryptString(
|
||||
|
|
@ -225,26 +171,14 @@ class Utils
|
|||
return \is_array($aResult) ? $aResult : array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $aValues
|
||||
* @param string $sCustomKey = ''
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static public function EncodeKeyValuesQ(array $aValues, $sCustomKey = '')
|
||||
static public function EncodeKeyValuesQ(array $aValues, string $sCustomKey = '') : string
|
||||
{
|
||||
return \MailSo\Base\Utils::UrlSafeBase64Encode(
|
||||
\RainLoop\Utils::EncryptStringQ(
|
||||
@\serialize($aValues), \md5(APP_SALT.$sCustomKey)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sEncodedValues
|
||||
* @param string $sCustomKey = ''
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static public function DecodeKeyValuesQ($sEncodedValues, $sCustomKey = '')
|
||||
static public function DecodeKeyValuesQ(string $sEncodedValues, string $sCustomKey = '') : array
|
||||
{
|
||||
$aResult = @\unserialize(
|
||||
\RainLoop\Utils::DecryptStringQ(
|
||||
|
|
@ -253,10 +187,7 @@ class Utils
|
|||
return \is_array($aResult) ? $aResult : array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
static public function GetConnectionToken()
|
||||
static public function GetConnectionToken() : string
|
||||
{
|
||||
$sKey = 'rltoken';
|
||||
|
||||
|
|
@ -270,18 +201,12 @@ class Utils
|
|||
return \md5('Connection'.APP_SALT.$sToken.'Token'.APP_SALT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
static public function Fingerprint()
|
||||
static public function Fingerprint() : string
|
||||
{
|
||||
return \md5(empty($_SERVER['HTTP_USER_AGENT']) ? 'RainLoopFingerprint' : $_SERVER['HTTP_USER_AGENT']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
static public function GetShortToken()
|
||||
static public function GetShortToken() : string
|
||||
{
|
||||
$sKey = 'rlsession';
|
||||
|
||||
|
|
@ -309,20 +234,12 @@ class Utils
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
static public function GetCsrfToken()
|
||||
static public function GetCsrfToken() : string
|
||||
{
|
||||
return \md5('Csrf'.APP_SALT.self::GetConnectionToken().'Token'.APP_SALT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sPath
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function PathMD5($sPath)
|
||||
public static function PathMD5(string $sPath) : string
|
||||
{
|
||||
$sResult = '';
|
||||
if (@\is_dir($sPath))
|
||||
|
|
@ -340,12 +257,9 @@ class Utils
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $sFileName
|
||||
* @param array $aResultLang
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function ReadAndAddLang($sFileName, &$aResultLang)
|
||||
public static function ReadAndAddLang(string $sFileName, array &$aResultLang)
|
||||
{
|
||||
if (\file_exists($sFileName))
|
||||
{
|
||||
|
|
@ -392,12 +306,7 @@ class Utils
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sDir
|
||||
* @param string $sType = ''
|
||||
* @return array
|
||||
*/
|
||||
public static function FolderFiles($sDir, $sType = '')
|
||||
public static function FolderFiles(string $sDir, string $sType = '') : array
|
||||
{
|
||||
$aResult = array();
|
||||
if (@\is_dir($sDir))
|
||||
|
|
@ -422,12 +331,7 @@ class Utils
|
|||
return $aResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sHtml
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function ClearHtmlOutput($sHtml)
|
||||
public static function ClearHtmlOutput(string $sHtml) : string
|
||||
{
|
||||
// return $sHtml;
|
||||
return \trim(\str_replace('> <', '><',
|
||||
|
|
@ -439,11 +343,7 @@ class Utils
|
|||
))))));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sKey
|
||||
* @return bool
|
||||
*/
|
||||
public static function FastCheck($sKey)
|
||||
public static function FastCheck(string $sKey) : bool
|
||||
{
|
||||
$bResult = false;
|
||||
|
||||
|
|
@ -457,12 +357,7 @@ class Utils
|
|||
return $bResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $aList
|
||||
* @param string $sDirName
|
||||
* @param string $sNameSuffix = ''
|
||||
*/
|
||||
public static function CompileTemplates(&$aList, $sDirName, $sNameSuffix = '')
|
||||
public static function CompileTemplates(array &$aList, string $sDirName, string $sNameSuffix = '')
|
||||
{
|
||||
if (\file_exists($sDirName))
|
||||
{
|
||||
|
|
@ -477,11 +372,10 @@ class Utils
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $sName
|
||||
* @param mixed $mDefault = null
|
||||
* @return mixed
|
||||
*/
|
||||
public static function GetCookie($sName, $mDefault = null)
|
||||
public static function GetCookie(string $sName, $mDefault = null)
|
||||
{
|
||||
if (null === \RainLoop\Utils::$Cookies)
|
||||
{
|
||||
|
|
@ -491,7 +385,7 @@ class Utils
|
|||
return isset(\RainLoop\Utils::$Cookies[$sName]) ? \RainLoop\Utils::$Cookies[$sName] : $mDefault;
|
||||
}
|
||||
|
||||
public static function SetCookie($sName, $sValue = '', $iExpire = 0, $sPath = null, $sDomain = null, $bSecure = null, $bHttpOnly = true)
|
||||
public static function SetCookie(string $sName, string $sValue = '', int $iExpire = 0, ?string $sPath = null, ?string $sDomain = null, ?bool $bSecure = null, bool $bHttpOnly = true)
|
||||
{
|
||||
if (null === \RainLoop\Utils::$Cookies)
|
||||
{
|
||||
|
|
@ -513,7 +407,7 @@ class Utils
|
|||
@\setcookie($sName, $sValue, $iExpire, $sPath, $sDomain, $bSecure, $bHttpOnly);
|
||||
}
|
||||
|
||||
public static function ClearCookie($sName)
|
||||
public static function ClearCookie(string $sName)
|
||||
{
|
||||
if (null === \RainLoop\Utils::$Cookies)
|
||||
{
|
||||
|
|
@ -527,81 +421,27 @@ class Utils
|
|||
@\setcookie($sName, '', \time() - 3600 * 24 * 30, $sPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function IsOwnCloud()
|
||||
{
|
||||
return isset($_ENV['RAINLOOP_OWNCLOUD']) && $_ENV['RAINLOOP_OWNCLOUD'] &&
|
||||
\class_exists('OC');
|
||||
}
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function IsOwnCloudLoggedIn()
|
||||
{
|
||||
return self::IsOwnCloud() && \class_exists('OCP\User') && \OCP\User::isLoggedIn();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sV
|
||||
* @param bool $bEncode = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function UrlEncode($sV, $bEncode = false)
|
||||
public static function UrlEncode(string $sV, bool $bEncode = false) : string
|
||||
{
|
||||
return $bEncode ? \urlencode($sV) : $sV;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function WebPath()
|
||||
public static function WebPath() : string
|
||||
{
|
||||
$sAppPath = '';
|
||||
if (\RainLoop\Utils::IsOwnCloud())
|
||||
{
|
||||
if (\class_exists('OC_App'))
|
||||
{
|
||||
$sAppPath = \rtrim(\trim(\OC_App::getAppWebPath('rainloop')), '\\/').'/app/';
|
||||
}
|
||||
|
||||
if (empty($sAppPath))
|
||||
{
|
||||
$sUrl = \MailSo\Base\Http::SingletonInstance()->GetUrl();
|
||||
if ($sUrl && \preg_match('/\/index\.php\/apps\/rainloop/', $sUrl))
|
||||
{
|
||||
$sAppPath = \preg_replace('/\/index\.php\/apps\/rainloop.+$/',
|
||||
'/apps/rainloop/app/', $sUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $sAppPath;
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function WebVersionPath()
|
||||
public static function WebVersionPath() : string
|
||||
{
|
||||
return self::WebPath().'rainloop/v/'.APP_VERSION.'/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function WebStaticPath()
|
||||
public static function WebStaticPath() : string
|
||||
{
|
||||
return self::WebVersionPath().'static/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $aSuggestions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function RemoveSuggestionDuplicates($aSuggestions)
|
||||
public static function RemoveSuggestionDuplicates(array $aSuggestions) : array
|
||||
{
|
||||
$aResult = array();
|
||||
|
||||
|
|
@ -622,13 +462,7 @@ class Utils
|
|||
return $aResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sFileName
|
||||
* @param bool $bProcessSections = false
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function CustomParseIniFile($sFileName, $bProcessSections = false)
|
||||
public static function CustomParseIniFile(string $sFileName, bool $bProcessSections = false) : array
|
||||
{
|
||||
// if (\MailSo\Base\Utils::FunctionExistsAndEnabled('parse_ini_file'))
|
||||
// {
|
||||
|
|
@ -639,7 +473,7 @@ class Utils
|
|||
return \is_string($sData) ? @\parse_ini_string($sData, !!$bProcessSections) : null;
|
||||
}
|
||||
|
||||
public static function CustomBaseConvert($sNumberInput, $sFromBaseInput = '0123456789', $sToBaseInput = '0123456789')
|
||||
public static function CustomBaseConvert(string $sNumberInput, string $sFromBaseInput = '0123456789', string $sToBaseInput = '0123456789')
|
||||
{
|
||||
if ($sFromBaseInput === $sToBaseInput)
|
||||
{
|
||||
|
|
@ -687,4 +521,4 @@ class Utils
|
|||
|
||||
return $mRetVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue