mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 03:29:20 +03:00
Hide X-Mailer header by default
Remove iconv support Cleanup MailSo
This commit is contained in:
parent
234e5a5014
commit
9aa0cf92a9
12 changed files with 94 additions and 376 deletions
|
|
@ -9,8 +9,8 @@ if (!\defined('RAINLOOP_APP_LIBRARIES_PATH'))
|
|||
|
||||
function rainLoopSplAutoloadNamespaces() : array
|
||||
{
|
||||
return RAINLOOP_INCLUDE_AS_API_DEF ? array('RainLoop', 'Predis') :
|
||||
array('RainLoop', 'PHPThumb', 'Predis', 'SabreForRainLoop', 'Imagine', 'Detection');
|
||||
return RAINLOOP_INCLUDE_AS_API_DEF ? array('RainLoop', 'Predis', 'MailSo') :
|
||||
array('RainLoop', 'PHPThumb', 'Predis', 'SabreForRainLoop', 'Imagine', 'Detection', 'MailSo');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -44,37 +44,31 @@ if (!\defined('RAINLOOP_APP_LIBRARIES_PATH'))
|
|||
|
||||
if (\class_exists('RainLoop\Api'))
|
||||
{
|
||||
if (!\class_exists('MailSo\Version', false))
|
||||
{
|
||||
include APP_VERSION_ROOT_PATH.'app/libraries/MailSo/MailSo.php';
|
||||
}
|
||||
\MailSo\Base\Loader::Init();
|
||||
|
||||
if (!\function_exists('spyc_load_file'))
|
||||
{
|
||||
include APP_VERSION_ROOT_PATH.'app/libraries/spyc/Spyc.php';
|
||||
}
|
||||
|
||||
if (\class_exists('MailSo\Version'))
|
||||
if (RAINLOOP_INCLUDE_AS_API_DEF)
|
||||
{
|
||||
if (RAINLOOP_INCLUDE_AS_API_DEF)
|
||||
if (!\defined('APP_API_STARTED'))
|
||||
{
|
||||
if (!\defined('APP_API_STARTED'))
|
||||
{
|
||||
\define('APP_API_STARTED', true);
|
||||
|
||||
\RainLoop\Api::Handle();
|
||||
}
|
||||
}
|
||||
else if (!\defined('APP_STARTED'))
|
||||
{
|
||||
\define('APP_STARTED', true);
|
||||
\define('APP_API_STARTED', true);
|
||||
|
||||
\RainLoop\Api::Handle();
|
||||
\RainLoop\Service::Handle();
|
||||
|
||||
\RainLoop\Api::ExitOnEnd();
|
||||
}
|
||||
}
|
||||
else if (!\defined('APP_STARTED'))
|
||||
{
|
||||
\define('APP_STARTED', true);
|
||||
|
||||
\RainLoop\Api::Handle();
|
||||
\RainLoop\Service::Handle();
|
||||
|
||||
\RainLoop\Api::ExitOnEnd();
|
||||
}
|
||||
}
|
||||
else if (\function_exists('rainLoopSplAutoloadRegisterFunction'))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace MailSo\Base;
|
|||
* @category MailSo
|
||||
* @package Base
|
||||
*/
|
||||
class Utils
|
||||
abstract class Utils
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
|
|
@ -114,13 +114,6 @@ END;
|
|||
'.949' => 'euc-kr',
|
||||
);
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -130,7 +123,7 @@ END;
|
|||
$sLocale = @\setlocale(LC_ALL, '');
|
||||
$sLocaleLower = \strtolower(\trim($sLocale));
|
||||
|
||||
foreach (\MailSo\Base\Utils::$aLocaleMapping as $sKey => $sValue)
|
||||
foreach (static::$aLocaleMapping as $sKey => $sValue)
|
||||
{
|
||||
if (false !== \strpos($sLocaleLower, $sKey) ||
|
||||
false !== \strpos($sLocaleLower, '.'.$sValue))
|
||||
|
|
@ -149,12 +142,12 @@ END;
|
|||
public static function ConvertSystemString($sSrt)
|
||||
{
|
||||
$sSrt = \trim($sSrt);
|
||||
if (!empty($sSrt) && !\MailSo\Base\Utils::IsUtf8($sSrt))
|
||||
if (!empty($sSrt) && !static::IsUtf8($sSrt))
|
||||
{
|
||||
$sCharset = \MailSo\Base\Utils::DetectSystemCharset();
|
||||
$sCharset = static::DetectSystemCharset();
|
||||
if (!empty($sCharset))
|
||||
{
|
||||
$sSrt = \MailSo\Base\Utils::ConvertEncoding(
|
||||
$sSrt = static::ConvertEncoding(
|
||||
$sSrt, $sCharset, \MailSo\Base\Enumerations\Charset::UTF_8);
|
||||
}
|
||||
else
|
||||
|
|
@ -229,10 +222,10 @@ END;
|
|||
*/
|
||||
public static function NormalizeCharsetByValue($sCharset, $sValue)
|
||||
{
|
||||
$sCharset = \MailSo\Base\Utils::NormalizeCharset($sCharset);
|
||||
$sCharset = static::NormalizeCharset($sCharset);
|
||||
|
||||
if (\MailSo\Base\Enumerations\Charset::UTF_8 !== $sCharset &&
|
||||
\MailSo\Base\Utils::IsUtf8($sValue) &&
|
||||
static::IsUtf8($sValue) &&
|
||||
false === \strpos($sCharset, \MailSo\Base\Enumerations\Charset::ISO_2022_JP)
|
||||
)
|
||||
{
|
||||
|
|
@ -292,70 +285,6 @@ END;
|
|||
return $sFilePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function IsMbStringSupported()
|
||||
{
|
||||
return \MailSo\Config::$MBSTRING &&
|
||||
\MailSo\Base\Utils::FunctionExistsAndEnabled('mb_convert_encoding');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function IsIconvSupported()
|
||||
{
|
||||
return \MailSo\Config::$ICONV &&
|
||||
\MailSo\Base\Utils::FunctionExistsAndEnabled('iconv');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function IsIconvIgnoreSupported()
|
||||
{
|
||||
static $bCache = null;
|
||||
if (null !== $bCache)
|
||||
{
|
||||
return $bCache;
|
||||
}
|
||||
|
||||
$bCache = false;
|
||||
if (\MailSo\Base\Utils::IsIconvSupported())
|
||||
{
|
||||
if (false !== @\iconv('', '//IGNORE', ''))
|
||||
{
|
||||
$bCache = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $bCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function IsIconvTranslitSupported()
|
||||
{
|
||||
static $bCache = null;
|
||||
if (null !== $bCache)
|
||||
{
|
||||
return $bCache;
|
||||
}
|
||||
|
||||
$bCache = false;
|
||||
if (\MailSo\Base\Utils::IsIconvSupported())
|
||||
{
|
||||
if (false !== @\iconv('', '//TRANSLIT', ''))
|
||||
{
|
||||
$bCache = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $bCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sCharset
|
||||
*
|
||||
|
|
@ -363,49 +292,9 @@ END;
|
|||
*/
|
||||
public static function ValidateCharsetName($sCharset)
|
||||
{
|
||||
$sCharset = \strtolower(\MailSo\Base\Utils::NormalizeCharset($sCharset));
|
||||
$sCharset = \strtolower(static::NormalizeCharset($sCharset));
|
||||
return 0 < \strlen($sCharset) && (\in_array($sCharset, array(\MailSo\Base\Enumerations\Charset::UTF_7_IMAP)) ||
|
||||
\in_array($sCharset, \MailSo\Base\Utils::$SuppostedCharsets));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sInputString
|
||||
* @param string $sInputFromEncoding
|
||||
* @param string $sInputToEncoding
|
||||
*
|
||||
* @return string|bool
|
||||
*/
|
||||
public static function IconvConvertEncoding($sInputString, $sInputFromEncoding, $sInputToEncoding)
|
||||
{
|
||||
$sIconvOptions = '';
|
||||
if (\MailSo\Base\Utils::IsIconvIgnoreSupported())
|
||||
{
|
||||
$sIconvOptions .= '//IGNORE';
|
||||
}
|
||||
// if (\MailSo\Base\Utils::IsIconvTranslitSupported())
|
||||
// {
|
||||
// $sIconvOptions .= '//TRANSLIT';
|
||||
// }
|
||||
|
||||
$mResult = @\iconv(\strtoupper($sInputFromEncoding), \strtoupper($sInputToEncoding).$sIconvOptions, $sInputString);
|
||||
if (false === $mResult)
|
||||
{
|
||||
if (\MailSo\Log\Logger::IsSystemEnabled())
|
||||
{
|
||||
\MailSo\Log\Logger::SystemLog(array(
|
||||
'inc' => \strtoupper($sInputFromEncoding),
|
||||
'out' => \strtoupper($sInputToEncoding).$sIconvOptions,
|
||||
'val' => 500 < \strlen($sInputString) ? \substr($sInputString, 0, 500) : $sInputString,
|
||||
'hex' => 500 < \strlen($sInputString) ? '-- to long --' : \bin2hex($sInputString)
|
||||
), \MailSo\Log\Enumerations\Type::NOTICE);
|
||||
}
|
||||
|
||||
if (\MailSo\Config::$FixIconvByMbstring && \MailSo\Base\Utils::IsMbStringSupported())
|
||||
{
|
||||
$mResult = \MailSo\Base\Utils::MbConvertEncoding($sInputString, $sInputFromEncoding, $sInputToEncoding);
|
||||
}
|
||||
}
|
||||
return $mResult;
|
||||
\in_array($sCharset, static::$SuppostedCharsets));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -424,7 +313,7 @@ END;
|
|||
}
|
||||
|
||||
\mb_substitute_character('none');
|
||||
$sResult = @\mb_convert_encoding($sInputString, \strtoupper($sInputToEncoding), \strtoupper($sInputFromEncoding));
|
||||
$sResult = \mb_convert_encoding($sInputString, \strtoupper($sInputToEncoding), \strtoupper($sInputFromEncoding));
|
||||
\mb_substitute_character($sMbstringSubCh);
|
||||
|
||||
return $sResult;
|
||||
|
|
@ -441,8 +330,8 @@ END;
|
|||
{
|
||||
$sResult = $sInputString;
|
||||
|
||||
$sFromEncoding = \MailSo\Base\Utils::NormalizeCharset($sInputFromEncoding);
|
||||
$sToEncoding = \MailSo\Base\Utils::NormalizeCharset($sInputToEncoding);
|
||||
$sFromEncoding = static::NormalizeCharset($sInputFromEncoding);
|
||||
$sToEncoding = static::NormalizeCharset($sInputToEncoding);
|
||||
|
||||
if ('' === \trim($sResult) || ($sFromEncoding === $sToEncoding && \MailSo\Base\Enumerations\Charset::UTF_8 !== $sFromEncoding))
|
||||
{
|
||||
|
|
@ -473,7 +362,7 @@ END;
|
|||
case ($sFromEncoding === \MailSo\Base\Enumerations\Charset::UTF_7_IMAP &&
|
||||
$sToEncoding === \MailSo\Base\Enumerations\Charset::UTF_8):
|
||||
|
||||
$sResult = \MailSo\Base\Utils::Utf7ModifiedToUtf8($sResult);
|
||||
$sResult = static::Utf7ModifiedToUtf8($sResult);
|
||||
if (false === $sResult)
|
||||
{
|
||||
$sResult = $sInputString;
|
||||
|
|
@ -483,7 +372,7 @@ END;
|
|||
case ($sFromEncoding === \MailSo\Base\Enumerations\Charset::UTF_8 &&
|
||||
$sToEncoding === \MailSo\Base\Enumerations\Charset::UTF_7_IMAP):
|
||||
|
||||
$sResult = \MailSo\Base\Utils::Utf8ToUtf7Modified($sResult);
|
||||
$sResult = static::Utf8ToUtf7Modified($sResult);
|
||||
if (false === $sResult)
|
||||
{
|
||||
$sResult = $sInputString;
|
||||
|
|
@ -492,31 +381,23 @@ END;
|
|||
|
||||
case ($sFromEncoding === \MailSo\Base\Enumerations\Charset::UTF_7_IMAP):
|
||||
|
||||
$sResult = \MailSo\Base\Utils::ConvertEncoding(
|
||||
\MailSo\Base\Utils::ModifiedToPlainUtf7($sResult),
|
||||
$sResult = static::ConvertEncoding(
|
||||
static::ModifiedToPlainUtf7($sResult),
|
||||
\MailSo\Base\Enumerations\Charset::UTF_7,
|
||||
$sToEncoding
|
||||
);
|
||||
break;
|
||||
|
||||
case (\in_array(\strtolower($sFromEncoding), \MailSo\Base\Utils::$SuppostedCharsets)):
|
||||
|
||||
if (\MailSo\Base\Utils::IsIconvSupported())
|
||||
{
|
||||
$sResult = \MailSo\Base\Utils::IconvConvertEncoding($sResult, $sFromEncoding, $sToEncoding);
|
||||
}
|
||||
else if (\MailSo\Base\Utils::IsMbStringSupported())
|
||||
{
|
||||
$sResult = \MailSo\Base\Utils::MbConvertEncoding($sResult, $sFromEncoding, $sToEncoding);
|
||||
}
|
||||
case (\in_array(\strtolower($sFromEncoding), static::$SuppostedCharsets)):
|
||||
|
||||
$sResult = static::MbConvertEncoding($sResult, $sFromEncoding, $sToEncoding);
|
||||
$sResult = (false !== $sResult) ? $sResult : $sInputString;
|
||||
break;
|
||||
}
|
||||
|
||||
if ($bUnknown && \MailSo\Base\Utils::IsMbStringSupported())
|
||||
if ($bUnknown)
|
||||
{
|
||||
$sResult = @\mb_convert_encoding($sResult, $sToEncoding);
|
||||
$sResult = \mb_convert_encoding($sResult, $sToEncoding);
|
||||
}
|
||||
|
||||
return $sResult;
|
||||
|
|
@ -544,7 +425,7 @@ END;
|
|||
*/
|
||||
public static function StrToLowerIfAscii($sValue)
|
||||
{
|
||||
return \MailSo\Base\Utils::IsAscii($sValue) ? \strtolower($sValue) : $sValue;
|
||||
return static::IsAscii($sValue) ? \strtolower($sValue) : $sValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -554,7 +435,7 @@ END;
|
|||
*/
|
||||
public static function StrToUpperIfAscii($sValue)
|
||||
{
|
||||
return \MailSo\Base\Utils::IsAscii($sValue) ? \strtoupper($sValue) : $sValue;
|
||||
return static::IsAscii($sValue) ? \strtoupper($sValue) : $sValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -567,7 +448,7 @@ END;
|
|||
$aParts = \explode('@', $sValue, 2);
|
||||
if (!empty($aParts[1]))
|
||||
{
|
||||
$aParts[1] = \MailSo\Base\Utils::IsAscii($aParts[1]) ? \strtolower($aParts[1]) : $aParts[1];
|
||||
$aParts[1] = static::IsAscii($aParts[1]) ? \strtolower($aParts[1]) : $aParts[1];
|
||||
}
|
||||
|
||||
return \implode('@', $aParts);
|
||||
|
|
@ -580,7 +461,7 @@ END;
|
|||
*/
|
||||
public static function StripSpaces($sValue)
|
||||
{
|
||||
return \MailSo\Base\Utils::Trim(
|
||||
return static::Trim(
|
||||
\preg_replace('/[\s]+/u', ' ', $sValue));
|
||||
}
|
||||
|
||||
|
|
@ -629,7 +510,7 @@ END;
|
|||
break;
|
||||
case 'b':
|
||||
case 'base64':
|
||||
$sResult = \MailSo\Base\Utils::Base64Decode($sResult);
|
||||
$sResult = static::Base64Decode($sResult);
|
||||
break;
|
||||
}
|
||||
return $sResult;
|
||||
|
|
@ -657,9 +538,9 @@ END;
|
|||
$sValue = $sEncodedValue;
|
||||
if (0 < \strlen($sIncomingCharset))
|
||||
{
|
||||
$sIncomingCharset = \MailSo\Base\Utils::NormalizeCharsetByValue($sIncomingCharset, $sValue);
|
||||
$sIncomingCharset = static::NormalizeCharsetByValue($sIncomingCharset, $sValue);
|
||||
|
||||
$sValue = \MailSo\Base\Utils::ConvertEncoding($sValue, $sIncomingCharset,
|
||||
$sValue = static::ConvertEncoding($sValue, $sIncomingCharset,
|
||||
\MailSo\Base\Enumerations\Charset::UTF_8);
|
||||
}
|
||||
|
||||
|
|
@ -710,7 +591,7 @@ END;
|
|||
break;
|
||||
case 'B':
|
||||
$sHeaderValuePart = $aTempArr[1];
|
||||
$aTempArr[1] = \MailSo\Base\Utils::Base64Decode(\substr(
|
||||
$aTempArr[1] = static::Base64Decode(\substr(
|
||||
$sHeaderValuePart, $iPos + 3, \strlen($sHeaderValuePart) - $iPos - 5));
|
||||
break;
|
||||
}
|
||||
|
|
@ -719,7 +600,7 @@ END;
|
|||
if (0 < \strlen($aTempArr[0]))
|
||||
{
|
||||
$sCharset = 0 === \strlen($sForcedIncomingCharset) ? $aTempArr[0] : $sForcedIncomingCharset;
|
||||
$sCharset = \MailSo\Base\Utils::NormalizeCharset($sCharset, true);
|
||||
$sCharset = static::NormalizeCharset($sCharset, true);
|
||||
|
||||
if ('' === $sMainCharset)
|
||||
{
|
||||
|
|
@ -748,18 +629,18 @@ END;
|
|||
}
|
||||
else
|
||||
{
|
||||
$aParts[$iIndex][2] = \MailSo\Base\Utils::NormalizeCharsetByValue($aParts[$iIndex][2], $aParts[$iIndex][1]);
|
||||
$aParts[$iIndex][2] = static::NormalizeCharsetByValue($aParts[$iIndex][2], $aParts[$iIndex][1]);
|
||||
|
||||
$sValue = \str_replace($aParts[$iIndex][0],
|
||||
\MailSo\Base\Utils::ConvertEncoding($aParts[$iIndex][1], $aParts[$iIndex][2], \MailSo\Base\Enumerations\Charset::UTF_8),
|
||||
static::ConvertEncoding($aParts[$iIndex][1], $aParts[$iIndex][2], \MailSo\Base\Enumerations\Charset::UTF_8),
|
||||
$sValue);
|
||||
}
|
||||
}
|
||||
|
||||
if ($bOneCharset && 0 < \strlen($sMainCharset))
|
||||
{
|
||||
$sMainCharset = \MailSo\Base\Utils::NormalizeCharsetByValue($sMainCharset, $sValue);
|
||||
$sValue = \MailSo\Base\Utils::ConvertEncoding($sValue, $sMainCharset, \MailSo\Base\Enumerations\Charset::UTF_8);
|
||||
$sMainCharset = static::NormalizeCharsetByValue($sMainCharset, $sValue);
|
||||
$sValue = static::ConvertEncoding($sValue, $sMainCharset, \MailSo\Base\Enumerations\Charset::UTF_8);
|
||||
}
|
||||
|
||||
return $sValue;
|
||||
|
|
@ -832,7 +713,7 @@ END;
|
|||
public static function EncodeUnencodedValue($sEncodeType, $sValue)
|
||||
{
|
||||
$sValue = \trim($sValue);
|
||||
if (0 < \strlen($sValue) && !\MailSo\Base\Utils::IsAscii($sValue))
|
||||
if (0 < \strlen($sValue) && !static::IsAscii($sValue))
|
||||
{
|
||||
switch (\strtoupper($sEncodeType))
|
||||
{
|
||||
|
|
@ -864,7 +745,7 @@ END;
|
|||
public static function EncodeHeaderValue($sEncodeType, $sEncodeCharset, $sValue)
|
||||
{
|
||||
$sValue = \trim($sValue);
|
||||
if (0 < \strlen($sValue) && !\MailSo\Base\Utils::IsAscii($sValue))
|
||||
if (0 < \strlen($sValue) && !static::IsAscii($sValue))
|
||||
{
|
||||
switch (\strtoupper($sEncodeType))
|
||||
{
|
||||
|
|
@ -936,7 +817,7 @@ END;
|
|||
$sAttrName = \trim($sAttrName);
|
||||
$sValue = \trim($sValue);
|
||||
|
||||
if (0 < \strlen($sValue) && !\MailSo\Base\Utils::IsAscii($sValue))
|
||||
if (0 < \strlen($sValue) && !static::IsAscii($sValue))
|
||||
{
|
||||
if (!empty($_SERVER['HTTP_USER_AGENT']) && 0 < \strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE'))
|
||||
{
|
||||
|
|
@ -944,7 +825,7 @@ END;
|
|||
}
|
||||
else
|
||||
{
|
||||
$sValue = \MailSo\Base\Utils::AttributeRfc2231Encode($sAttrName, $sValue);
|
||||
$sValue = static::AttributeRfc2231Encode($sAttrName, $sValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -1195,7 +1076,7 @@ END;
|
|||
|
||||
);
|
||||
|
||||
$sExt = \MailSo\Base\Utils::GetFileExtension($sFileName);
|
||||
$sExt = static::GetFileExtension($sFileName);
|
||||
if (0 < \strlen($sExt) && isset($aMimeTypes[$sExt]))
|
||||
{
|
||||
$sResult = $aMimeTypes[$sExt];
|
||||
|
|
@ -1253,7 +1134,7 @@ END;
|
|||
|
||||
if ('' === $sResult)
|
||||
{
|
||||
switch (\strtolower(\MailSo\Base\Utils::GetFileExtension($sFileName)))
|
||||
switch (\strtolower(static::GetFileExtension($sFileName)))
|
||||
{
|
||||
case 'zip':
|
||||
case '7z':
|
||||
|
|
@ -1294,7 +1175,7 @@ END;
|
|||
$sSafeMode = \strtolower(\trim(@\ini_get('safe_mode')));
|
||||
$bSafeMode = 'on' === $sSafeMode || '1' === $sSafeMode || 'true' === $sSafeMode;
|
||||
|
||||
$bValidateAction = !$bSafeMode && \MailSo\Base\Utils::FunctionExistsAndEnabled('set_time_limit');
|
||||
$bValidateAction = !$bSafeMode && static::FunctionExistsAndEnabled('set_time_limit');
|
||||
}
|
||||
|
||||
if ($bValidateAction && $iTimeToReset < $iTime - $iResetTimer)
|
||||
|
|
@ -1339,11 +1220,11 @@ END;
|
|||
{
|
||||
if (\is_string($mItem))
|
||||
{
|
||||
$aInput[$mKey] = \MailSo\Base\Utils::Utf8Clear($mItem);
|
||||
$aInput[$mKey] = static::Utf8Clear($mItem);
|
||||
}
|
||||
else if (\is_array($mItem))
|
||||
{
|
||||
\MailSo\Base\Utils::ClearArrayUtf8Values($mItem);
|
||||
static::ClearArrayUtf8Values($mItem);
|
||||
$aInput[$mKey] = $mItem;
|
||||
}
|
||||
}
|
||||
|
|
@ -1380,8 +1261,8 @@ END;
|
|||
if ($oLogger)
|
||||
{
|
||||
$oLogger->Write('json_encode: '.\trim(
|
||||
(\MailSo\Base\Utils::FunctionExistsAndEnabled('json_last_error') ? ' [Error Code: '.\json_last_error().']' : '').
|
||||
(\MailSo\Base\Utils::FunctionExistsAndEnabled('json_last_error_msg') ? ' [Error Message: '.\json_last_error_msg().']' : '')
|
||||
(static::FunctionExistsAndEnabled('json_last_error') ? ' [Error Code: '.\json_last_error().']' : '').
|
||||
(static::FunctionExistsAndEnabled('json_last_error_msg') ? ' [Error Message: '.\json_last_error_msg().']' : '')
|
||||
), \MailSo\Log\Enumerations\Type::WARNING, 'JSON'
|
||||
);
|
||||
}
|
||||
|
|
@ -1394,7 +1275,7 @@ END;
|
|||
$oLogger->Write('Trying to clear Utf8 before json_encode', \MailSo\Log\Enumerations\Type::INFO, 'JSON');
|
||||
}
|
||||
|
||||
\MailSo\Base\Utils::ClearArrayUtf8Values($mInput);
|
||||
static::ClearArrayUtf8Values($mInput);
|
||||
$sResult = @\json_encode($mInput, $iOpt);
|
||||
}
|
||||
}
|
||||
|
|
@ -1409,8 +1290,8 @@ END;
|
|||
*/
|
||||
public static function ClearFileName($sFileName)
|
||||
{
|
||||
return \MailSo\Base\Utils::Trim(\MailSo\Base\Utils::ClearNullBite(
|
||||
\MailSo\Base\Utils::StripSpaces(
|
||||
return static::Trim(static::ClearNullBite(
|
||||
static::StripSpaces(
|
||||
\str_replace(array('"', '/', '\\', '*', '?', '<', '>', '|', ':'), ' ', $sFileName))));
|
||||
}
|
||||
|
||||
|
|
@ -1421,7 +1302,7 @@ END;
|
|||
*/
|
||||
public static function ClearXss($sValue)
|
||||
{
|
||||
return \MailSo\Base\Utils::Trim(\MailSo\Base\Utils::ClearNullBite(
|
||||
return static::Trim(static::ClearNullBite(
|
||||
\str_replace(array('"', '/', '\\', '*', '?', '<', '>', '|', ':'), ' ', $sValue)));
|
||||
}
|
||||
|
||||
|
|
@ -1494,7 +1375,7 @@ END;
|
|||
$sPathDir = $sSource.'/'.$sRead;
|
||||
if (\is_dir($sPathDir))
|
||||
{
|
||||
\MailSo\Base\Utils::CopyDir($sPathDir, $sDestination.'/'.$sRead);
|
||||
static::CopyDir($sPathDir, $sDestination.'/'.$sRead);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -1530,7 +1411,7 @@ END;
|
|||
{
|
||||
if (@\is_dir($sTempPath.'/'.$sFile))
|
||||
{
|
||||
if (!\MailSo\Base\Utils::RecTimeDirRemove($sTempPath.'/'.$sFile, $iTime2Kill, $iNow))
|
||||
if (!static::RecTimeDirRemove($sTempPath.'/'.$sFile, $iTime2Kill, $iNow))
|
||||
{
|
||||
$bRemoveAllDirs = false;
|
||||
}
|
||||
|
|
@ -1547,7 +1428,7 @@ END;
|
|||
|
||||
if ($iFileCount > 0)
|
||||
{
|
||||
if (\MailSo\Base\Utils::TimeFilesRemove($sTempPath, $iTime2Kill, $iNow))
|
||||
if (static::TimeFilesRemove($sTempPath, $iTime2Kill, $iNow))
|
||||
{
|
||||
return @\rmdir($sTempPath);
|
||||
}
|
||||
|
|
@ -1639,7 +1520,7 @@ END;
|
|||
return $sUtfString;
|
||||
}
|
||||
|
||||
$sUtfString = \preg_replace(\MailSo\Base\Utils::$sValidUtf8Regexp, '$1', $sUtfString);
|
||||
$sUtfString = \preg_replace(static::$sValidUtf8Regexp, '$1', $sUtfString);
|
||||
|
||||
$sUtfString = \preg_replace(
|
||||
'/\xE0[\x80-\x9F][\x80-\xBF]'.
|
||||
|
|
@ -1648,16 +1529,7 @@ END;
|
|||
|
||||
$sUtfString = \preg_replace('/\xEF\xBF\xBD/', '?', $sUtfString);
|
||||
|
||||
$sNewUtfString = false;
|
||||
if (false === $sNewUtfString && \MailSo\Base\Utils::IsMbStringSupported())
|
||||
{
|
||||
$sNewUtfString = \MailSo\Base\Utils::MbConvertEncoding($sUtfString, 'UTF-8', 'UTF-8');
|
||||
}
|
||||
|
||||
if (false === $sNewUtfString && \MailSo\Base\Utils::IsIconvSupported())
|
||||
{
|
||||
$sNewUtfString = \MailSo\Base\Utils::IconvConvertEncoding($sUtfString, 'UTF-8', 'UTF-8');
|
||||
}
|
||||
$sNewUtfString = static::MbConvertEncoding($sUtfString, 'UTF-8', 'UTF-8');
|
||||
|
||||
if (false !== $sNewUtfString)
|
||||
{
|
||||
|
|
@ -1733,7 +1605,7 @@ END;
|
|||
public static function UrlSafeBase64Decode($sValue)
|
||||
{
|
||||
$sValue = \rtrim(\strtr($sValue, '-_.', '+/='), '=');
|
||||
return \MailSo\Base\Utils::Base64Decode(\str_pad($sValue, \strlen($sValue) + (\strlen($sValue) % 4), '=', STR_PAD_RIGHT));
|
||||
return static::Base64Decode(\str_pad($sValue, \strlen($sValue) + (\strlen($sValue) % 4), '=', STR_PAD_RIGHT));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1838,7 +1710,7 @@ END;
|
|||
if (false !== $sBuffer)
|
||||
{
|
||||
echo $sBuffer;
|
||||
\MailSo\Base\Utils::ResetTimeLimit();
|
||||
static::ResetTimeLimit();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -1900,7 +1772,7 @@ END;
|
|||
|
||||
if ($bResetTimeLimit)
|
||||
{
|
||||
\MailSo\Base\Utils::ResetTimeLimit();
|
||||
static::ResetTimeLimit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2228,7 +2100,7 @@ END;
|
|||
{
|
||||
foreach ($mFunctionNameOrNames as $sFunctionName)
|
||||
{
|
||||
if (!\MailSo\Base\Utils::FunctionExistsAndEnabled($sFunctionName))
|
||||
if (!static::FunctionExistsAndEnabled($sFunctionName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2295,13 +2167,13 @@ END;
|
|||
|
||||
if (!$bIsMagicQuotesOn)
|
||||
{
|
||||
return $bClearNullBite && \is_string($mValue) ? \MailSo\Base\Utils::ClearNullBite($mValue) : $mValue;
|
||||
return $bClearNullBite && \is_string($mValue) ? static::ClearNullBite($mValue) : $mValue;
|
||||
}
|
||||
|
||||
$sType = \gettype($mValue);
|
||||
if ('string' === $sType)
|
||||
{
|
||||
return \stripslashes($bClearNullBite ? \MailSo\Base\Utils::ClearNullBite($mValue) : $mValue);
|
||||
return \stripslashes($bClearNullBite ? static::ClearNullBite($mValue) : $mValue);
|
||||
}
|
||||
else if ('array' === $sType)
|
||||
{
|
||||
|
|
@ -2309,7 +2181,7 @@ END;
|
|||
$mValueKeys = \array_keys($mValue);
|
||||
foreach ($mValueKeys as $sKey)
|
||||
{
|
||||
$aReturnValue[$sKey] = \MailSo\Base\Utils::StripSlashesValue($mValue[$sKey], $bClearNullBite);
|
||||
$aReturnValue[$sKey] = static::StripSlashesValue($mValue[$sKey], $bClearNullBite);
|
||||
}
|
||||
|
||||
return $aReturnValue;
|
||||
|
|
@ -2326,16 +2198,9 @@ END;
|
|||
public static function CharsetDetect($sStr)
|
||||
{
|
||||
$mResult = '';
|
||||
if (!\MailSo\Base\Utils::IsAscii($sStr))
|
||||
if (!static::IsAscii($sStr))
|
||||
{
|
||||
$mResult = \MailSo\Base\Utils::IsMbStringSupported() &&
|
||||
\MailSo\Base\Utils::FunctionExistsAndEnabled('mb_detect_encoding') ?
|
||||
@\mb_detect_encoding($sStr, 'auto', true) : false;
|
||||
|
||||
if (false === $mResult && \MailSo\Base\Utils::IsIconvSupported())
|
||||
{
|
||||
$mResult = \md5(@\iconv('utf-8', 'utf-8//IGNORE', $sStr)) === \md5($sStr) ? 'utf-8' : '';
|
||||
}
|
||||
$mResult = \mb_detect_encoding($sStr, 'auto', true);
|
||||
}
|
||||
|
||||
return \is_string($mResult) && 0 < \strlen($mResult) ? $mResult : '';
|
||||
|
|
@ -2427,7 +2292,7 @@ END;
|
|||
static $oIdn = null;
|
||||
if (null === $oIdn)
|
||||
{
|
||||
include_once MAILSO_LIBRARY_ROOT_PATH.'Vendors/Net/IDNA2.php';
|
||||
include_once dirname(__DIR__).'/Vendors/Net/IDNA2.php';
|
||||
$oIdn = new \Net_IDNA2();
|
||||
$oIdn->setParams('utf8', true);
|
||||
}
|
||||
|
|
@ -2452,7 +2317,7 @@ END;
|
|||
catch (\Exception $oException) {}
|
||||
}
|
||||
|
||||
return $bLowerIfAscii ? \MailSo\Base\Utils::StrMailDomainToLowerIfAscii($sStr) : $sStr;
|
||||
return $bLowerIfAscii ? static::StrMailDomainToLowerIfAscii($sStr) : $sStr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2463,14 +2328,14 @@ END;
|
|||
*/
|
||||
public static function IdnToAscii($sStr, $bLowerIfAscii = false)
|
||||
{
|
||||
$sStr = $bLowerIfAscii ? \MailSo\Base\Utils::StrMailDomainToLowerIfAscii($sStr) : $sStr;
|
||||
$sStr = $bLowerIfAscii ? static::StrMailDomainToLowerIfAscii($sStr) : $sStr;
|
||||
|
||||
$sUser = '';
|
||||
$sDomain = $sStr;
|
||||
if (false !== \strpos($sStr, '@'))
|
||||
{
|
||||
$sUser = \MailSo\Base\Utils::GetAccountNameFromEmail($sStr);
|
||||
$sDomain = \MailSo\Base\Utils::GetDomainFromEmail($sStr);
|
||||
$sUser = static::GetAccountNameFromEmail($sStr);
|
||||
$sDomain = static::GetDomainFromEmail($sStr);
|
||||
}
|
||||
|
||||
if (0 < \strlen($sDomain) && \preg_match('/[^\x20-\x7E]/', $sDomain))
|
||||
|
|
|
|||
|
|
@ -16,16 +16,6 @@ namespace MailSo;
|
|||
*/
|
||||
class Config
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public static $ICONV = true;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public static $MBSTRING = true;
|
||||
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
|
|
@ -41,11 +31,6 @@ class Config
|
|||
*/
|
||||
public static $HtmlStrictDebug = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public static $FixIconvByMbstring = true;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of MailSo.
|
||||
*
|
||||
* (c) 2014 Usenko Timur
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace MailSo;
|
||||
|
||||
if (!\defined('MAILSO_LIBRARY_ROOT_PATH'))
|
||||
{
|
||||
\define('MAILSO_LIBRARY_ROOT_PATH', \defined('MAILSO_LIBRARY_USE_PHAR')
|
||||
? 'phar://mailso.phar/' : \rtrim(\realpath(__DIR__), '\\/').'/');
|
||||
|
||||
/**
|
||||
* @param string $sClassName
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function MailSoSplAutoloadRegisterFunction($sClassName)
|
||||
{
|
||||
return (0 === \strpos($sClassName, 'MailSo') && false !== \strpos($sClassName, '\\')) ?
|
||||
include MAILSO_LIBRARY_ROOT_PATH.\str_replace('\\', '/', \substr($sClassName, 7)).'.php' : false;
|
||||
}
|
||||
|
||||
\spl_autoload_register('MailSo\MailSoSplAutoloadRegisterFunction', false);
|
||||
|
||||
if (\class_exists('MailSo\Base\Loader'))
|
||||
{
|
||||
\MailSo\Base\Loader::Init();
|
||||
}
|
||||
else
|
||||
{
|
||||
\spl_autoload_unregister('MailSo\MailSoSplAutoloadRegisterFunction');
|
||||
}
|
||||
}
|
||||
|
|
@ -220,7 +220,6 @@ class Header
|
|||
if ($this->IsSubject())
|
||||
{
|
||||
if (!\MailSo\Base\Utils::IsAscii($sResult) &&
|
||||
\MailSo\Base\Utils::IsIconvSupported() &&
|
||||
\function_exists('iconv_mime_encode'))
|
||||
{
|
||||
$aPreferences = array(
|
||||
|
|
|
|||
|
|
@ -868,7 +868,7 @@ class Message
|
|||
|
||||
if (!isset($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::X_MAILER]) && $this->bAddDefaultXMailer)
|
||||
{
|
||||
$oIncPart->Headers->SetByName(\MailSo\Mime\Enumerations\Header::X_MAILER, \MailSo\Version::XMailer(), true);
|
||||
$oIncPart->Headers->SetByName(\MailSo\Mime\Enumerations\Header::X_MAILER, 'MailSo/2.0.1-djmaze', true);
|
||||
}
|
||||
|
||||
if (!isset($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::MIME_VERSION]))
|
||||
|
|
|
|||
|
|
@ -27,8 +27,7 @@
|
|||
//require_once 'Net/IDNA2/Exception.php';
|
||||
//require_once 'Net/IDNA2/Exception/Nameprep.php';
|
||||
|
||||
defined('MAILSO_LIBRARY_ROOT_PATH') || die();
|
||||
require_once MAILSO_LIBRARY_ROOT_PATH.'Vendors/Net/IDNA2CustomExceptions.php';
|
||||
require_once __DIR__ . '/IDNA2CustomExceptions.php';
|
||||
|
||||
/**
|
||||
* Encode/decode Internationalized Domain Names.
|
||||
|
|
@ -43,7 +42,7 @@ require_once MAILSO_LIBRARY_ROOT_PATH.'Vendors/Net/IDNA2CustomExceptions.php';
|
|||
* simple strings and complete email addresses as well. That means, that you might
|
||||
* use any of the following notations:
|
||||
*
|
||||
* - www.n<EFBFBD>rgler.com
|
||||
* - www.nörgler.com
|
||||
* - xn--nrgler-wxa
|
||||
* - xn--brse-5qa.xn--knrz-1ra.info
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of MailSo.
|
||||
*
|
||||
* (c) 2014 Usenko Timur
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace MailSo;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
*/
|
||||
final class Version
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const APP_VERSION = '2.0.1';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const MIME_X_MAILER = 'MailSo';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function AppVersion()
|
||||
{
|
||||
return \MailSo\Version::APP_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function XMailer()
|
||||
{
|
||||
return \MailSo\Version::MIME_X_MAILER.'/'.\MailSo\Version::APP_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function Signature()
|
||||
{
|
||||
$sSignature = '';
|
||||
if (\defined('MAILSO_LIBRARY_USE_PHAR'))
|
||||
{
|
||||
$oPhar = new \Phar('mailso.phar');
|
||||
$sSignature = $oPhar->getSignature();
|
||||
}
|
||||
|
||||
return $sSignature;
|
||||
}
|
||||
}
|
||||
|
|
@ -21,15 +21,9 @@ class Api
|
|||
static $bOne = null;
|
||||
if (null === $bOne)
|
||||
{
|
||||
$bOne = \class_exists('MailSo\Version');
|
||||
if ($bOne)
|
||||
{
|
||||
static::SetupDefaultMailSoConfig();
|
||||
|
||||
$bOne = static::RunResult();
|
||||
}
|
||||
static::SetupDefaultMailSoConfig();
|
||||
$bOne = static::RunResult();
|
||||
}
|
||||
|
||||
return $bOne;
|
||||
}
|
||||
|
||||
|
|
@ -64,12 +58,6 @@ class Api
|
|||
{
|
||||
if (\class_exists('MailSo\Config'))
|
||||
{
|
||||
if (static::Config()->Get('labs', 'disable_iconv_if_mbstring_supported', false) &&
|
||||
\MailSo\Base\Utils::IsMbStringSupported() && \MailSo\Config::$MBSTRING)
|
||||
{
|
||||
\MailSo\Config::$ICONV = false;
|
||||
}
|
||||
|
||||
\MailSo\Config::$MessageListFastSimpleSearch =
|
||||
!!static::Config()->Get('labs', 'imap_message_list_fast_simple_search', true);
|
||||
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ class Application extends \RainLoop\Config\AbstractConfig
|
|||
'allow_admin_panel' => array(true, 'Access settings'),
|
||||
'allow_two_factor_auth' => array(false),
|
||||
'force_two_factor_auth' => array(false),
|
||||
'hide_x_mailer_header' => array(false),
|
||||
'hide_x_mailer_header' => array(true),
|
||||
'admin_panel_host' => array(''),
|
||||
'admin_panel_key' => array('admin'),
|
||||
'content_security_policy' => array(''),
|
||||
|
|
@ -342,7 +342,6 @@ Enables caching in the system'),
|
|||
'date_from_headers' => array(true),
|
||||
'autocreate_system_folders' => array(true),
|
||||
'allow_message_append' => array(false),
|
||||
'disable_iconv_if_mbstring_supported' => array(false),
|
||||
'login_fault_delay' => array(1),
|
||||
'log_ajax_response_write_limit' => array(300),
|
||||
'allow_html_editor_source_button' => array(false),
|
||||
|
|
|
|||
|
|
@ -72,12 +72,7 @@ class Service
|
|||
static $bOne = null;
|
||||
if (null === $bOne)
|
||||
{
|
||||
$oService = null;
|
||||
if (\class_exists('MailSo\Version'))
|
||||
{
|
||||
$oService = new self();
|
||||
}
|
||||
|
||||
$oService = new self();
|
||||
$bOne = $oService->RunResult();
|
||||
}
|
||||
|
||||
|
|
@ -86,11 +81,6 @@ class Service
|
|||
|
||||
private function localHandle() : self
|
||||
{
|
||||
if (!\class_exists('MailSo\Version'))
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
$sResult = '';
|
||||
$bCached = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,15 +3,13 @@
|
|||
if (defined('APP_VERSION'))
|
||||
{
|
||||
$aRequirements = array(
|
||||
'cURL' => function_exists('curl_init'),
|
||||
'iconv' => function_exists('iconv'),
|
||||
'cURL' => extension_loaded('curl'),
|
||||
'mbstring' => extension_loaded('mbstring'),
|
||||
'Zlib' => extension_loaded('zlib'),
|
||||
// enabled by default:
|
||||
'json' => function_exists('json_decode'),
|
||||
'DateTime' => class_exists('DateTime') && class_exists('DateTimeZone'),
|
||||
'libxml' => function_exists('libxml_use_internal_errors'),
|
||||
'dom' => class_exists('DOMDocument'),
|
||||
'Zlib' => function_exists('gzopen') || function_exists('gzopen64'),
|
||||
'PCRE' => function_exists('preg_replace'),
|
||||
'SPL' => function_exists('spl_autoload_register')
|
||||
'dom' => class_exists('DOMDocument')
|
||||
);
|
||||
|
||||
if (version_compare(PHP_VERSION, '7.3.0', '<'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue