예제 #1
0
 /**
  * @return string
  */
 public static function SetupDefaultMailSoConfig()
 {
     if (\class_exists('MailSo\\Config')) {
         if (\RainLoop\Api::Config()->Get('labs', 'disable_iconv_if_mbstring_supported', false) && \MailSo\Base\Utils::IsMbStringSupported() && \MailSo\Config::$MBSTRING) {
             \MailSo\Config::$ICONV = false;
         }
         \MailSo\Config::$MessageListFastSimpleSearch = !!\RainLoop\Api::Config()->Get('labs', 'imap_message_list_fast_simple_search', true);
         \MailSo\Config::$MessageListCountLimitTrigger = (int) \RainLoop\Api::Config()->Get('labs', 'imap_message_list_count_limit_trigger', 0);
         \MailSo\Config::$MessageListDateFilter = (int) \RainLoop\Api::Config()->Get('labs', 'imap_message_list_date_filter', 0);
         \MailSo\Config::$MessageListPermanentFilter = \trim(\RainLoop\Api::Config()->Get('labs', 'imap_message_list_permanent_filter', ''));
         \MailSo\Config::$MessageAllHeaders = !!\RainLoop\Api::Config()->Get('labs', 'imap_message_all_headers', false);
         \MailSo\Config::$LargeThreadLimit = (int) \RainLoop\Api::Config()->Get('labs', 'imap_large_thread_limit', 50);
         \MailSo\Config::$BoundaryPrefix = '_RainLoop_';
         \MailSo\Config::$SystemLogger = \RainLoop\Api::Logger();
         $sSslCafile = \RainLoop\Api::Config()->Get('ssl', 'cafile', '');
         $sSslCapath = \RainLoop\Api::Config()->Get('ssl', 'capath', '');
         if (!empty($sSslCafile) || !empty($sSslCapath)) {
             \MailSo\Hooks::Add('Net.NetClient.StreamContextSettings/Filter', function (&$aStreamContextSettings) use($sSslCafile, $sSslCapath) {
                 if (isset($aStreamContextSettings['ssl']) && \is_array($aStreamContextSettings['ssl'])) {
                     if (empty($aStreamContextSettings['ssl']['cafile']) && !empty($sSslCafile)) {
                         $aStreamContextSettings['ssl']['cafile'] = $sSslCafile;
                     }
                     if (empty($aStreamContextSettings['ssl']['capath']) && !empty($sSslCapath)) {
                         $aStreamContextSettings['ssl']['capath'] = $sSslCapath;
                     }
                 }
             });
         }
     }
 }
 /**
  * @return string
  */
 public static function SetupDefaultMailSoConfig()
 {
     if (\class_exists('MailSo\\Config')) {
         if (\RainLoop\Api::Config()->Get('labs', 'disable_iconv_if_mbstring_supported', false) && \MailSo\Base\Utils::IsMbStringSupported() && \MailSo\Config::$MBSTRING) {
             \MailSo\Config::$ICONV = false;
         }
         \MailSo\Config::$MessageListFastSimpleSearch = !!\RainLoop\Api::Config()->Get('labs', 'imap_message_list_fast_simple_search', true);
         \MailSo\Config::$MessageListCountLimitTrigger = (int) \RainLoop\Api::Config()->Get('labs', 'imap_message_list_count_limit_trigger', 0);
         \MailSo\Config::$MessageListDateFilter = (int) \RainLoop\Api::Config()->Get('labs', 'imap_message_list_date_filter', 0);
         \MailSo\Config::$MessageListUndeletedFilter = !!\RainLoop\Api::Config()->Get('labs', 'imap_message_list_hide_deleted_messages', true);
         \MailSo\Config::$SystemLogger = \RainLoop\Api::Logger();
     }
 }
예제 #3
0
 /**
  * @return bool
  */
 public static function Handle()
 {
     static $bOne = null;
     if ($bOne) {
         return true;
     }
     if (!\class_exists('MailSo\\Version')) {
         return false;
     }
     if (self::Config()->Get('labs', 'disable_iconv_if_mbstring_supported', false) && \class_exists('MailSo\\Capa') && \MailSo\Base\Utils::IsMbStringSupported()) {
         \MailSo\Config::$ICONV = false;
     }
     $bOne = true;
     return true;
 }
예제 #4
0
 /**
  * @return void
  */
 private function __construct()
 {
     $this->oHttp = \MailSo\Base\Http::SingletonInstance();
     $this->oActions = Actions::NewInstance();
     \set_error_handler(array(&$this, 'LogPhpErrorHandler'));
     $this->oServiceActions = new \RainLoop\ServiceActions($this->oHttp, $this->oActions);
     if ($this->oActions->Config()->Get('debug', 'enable', false)) {
         \error_reporting(E_ALL);
         \ini_set('display_errors', 1);
     }
     if ($this->oActions->Config()->Get('labs', 'disable_iconv_if_mbstring_supported', false) && \class_exists('MailSo\\Capa') && \MailSo\Base\Utils::IsMbStringSupported()) {
         \MailSo\Config::$ICONV = false;
     }
     $sServer = \trim($this->oActions->Config()->Get('security', 'custom_server_signature', ''));
     if (0 < \strlen($sServer)) {
         @\header('Server: ' . $sServer, true);
     }
     if ($this->oActions->Config()->Get('labs', 'force_https', false) && !$this->oHttp->IsSecure()) {
         @\header('Location: https://' . $this->oHttp->GetHost(false, false) . $this->oHttp->GetUrl(), true);
         exit;
     }
 }
예제 #5
0
 /**
  * @param string $sStr
  *
  * @return string
  */
 public static function CharsetDetect($sStr)
 {
     $mResult = '';
     if (!\MailSo\Base\Utils::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' : '';
         }
     }
     return \is_string($mResult) && 0 < \strlen($mResult) ? $mResult : '';
 }
예제 #6
0
파일: Utils.php 프로젝트: pigi72333/MailSo
 /**
  * @param string $sInputString
  * @param string $sInputFromEncoding
  * @param string $sInputToEncoding
  *
  * @return string
  */
 public static function ConvertEncoding($sInputString, $sInputFromEncoding, $sInputToEncoding)
 {
     $sResult = $sInputString;
     $sFromEncoding = \MailSo\Base\Utils::normalizeCharset($sInputFromEncoding);
     $sToEncoding = \MailSo\Base\Utils::normalizeCharset($sInputToEncoding);
     if ('' === \trim($sResult) || $sFromEncoding === $sToEncoding && \MailSo\Base\Enumerations\Charset::UTF_8 !== $sFromEncoding) {
         return $sResult;
     }
     $bUnknown = false;
     switch (true) {
         default:
             $bUnknown = true;
             break;
         case $sFromEncoding === \MailSo\Base\Enumerations\Charset::ISO_8859_1 && $sToEncoding === \MailSo\Base\Enumerations\Charset::UTF_8 && \function_exists('utf8_encode'):
             $sResult = \utf8_encode($sResult);
             break;
         case $sFromEncoding === \MailSo\Base\Enumerations\Charset::UTF_8 && $sToEncoding === \MailSo\Base\Enumerations\Charset::ISO_8859_1 && \function_exists('utf8_decode'):
             $sResult = \utf8_decode($sResult);
             break;
         case $sFromEncoding === \MailSo\Base\Enumerations\Charset::UTF_7_IMAP && $sToEncoding === \MailSo\Base\Enumerations\Charset::UTF_8:
             $sResult = \MailSo\Base\Utils::Utf7ModifiedToUtf8($sResult);
             if (false === $sResult) {
                 $sResult = $sInputString;
             }
             break;
         case $sFromEncoding === \MailSo\Base\Enumerations\Charset::UTF_8 && $sToEncoding === \MailSo\Base\Enumerations\Charset::UTF_7_IMAP:
             $sResult = \MailSo\Base\Utils::Utf8ToUtf7Modified($sResult);
             if (false === $sResult) {
                 $sResult = $sInputString;
             }
             break;
         case $sFromEncoding === \MailSo\Base\Enumerations\Charset::UTF_7_IMAP:
             $sResult = \MailSo\Base\Utils::ConvertEncoding(\MailSo\Base\Utils::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 = @\iconv(\strtoupper($sFromEncoding), \strtoupper($sToEncoding) . '//IGNORE', $sResult);
             } else {
                 if (\MailSo\Base\Utils::IsMbStringSupported()) {
                     $sResult = @\mb_convert_encoding($sResult, \strtoupper($sToEncoding), \strtoupper($sFromEncoding));
                 } else {
                     if (\MailSo\Base\Utils::IsLibIconvSupported()) {
                         $sResult = @\libiconv(\strtoupper($sFromEncoding), \strtoupper($sToEncoding), $sResult);
                     }
                 }
             }
             $sResult = false !== $sResult ? $sResult : $sInputString;
             break;
     }
     if ($bUnknown && \MailSo\Base\Utils::IsMbStringSupported()) {
         $sResult = @\mb_convert_encoding($sResult, $sToEncoding);
     }
     return $sResult;
 }