/**
  * @param \RainLoop\Account $oAccount
  * @param array $aSmtpCredentials
  */
 public function FilterSmtpCredentials($oAccount, &$aSmtpCredentials)
 {
     if ($oAccount instanceof \RainLoop\Account && \is_array($aSmtpCredentials)) {
         $sEmail = $oAccount->Email();
         $sHost = \trim($this->Config()->Get('plugin', 'smtp_host', ''));
         $sWhiteList = \trim($this->Config()->Get('plugin', 'override_users', ''));
         if (0 < strlen($sWhiteList) && 0 < \strlen($sHost) && \RainLoop\Plugins\Helper::ValidateWildcardValues($sEmail, $sWhiteList)) {
             $aSmtpCredentials['Host'] = $sHost;
             $aSmtpCredentials['Port'] = (int) $this->Config()->Get('plugin', 'smtp_port', 25);
             $sSecure = \trim($this->Config()->Get('plugin', 'smtp_secure', 'None'));
             switch ($sSecure) {
                 case 'SSL':
                     $aSmtpCredentials['Secure'] = MailSo\Net\Enumerations\ConnectionSecurityType::SSL;
                     break;
                 case 'TLS':
                     $aSmtpCredentials['Secure'] = MailSo\Net\Enumerations\ConnectionSecurityType::STARTTLS;
                     break;
                 default:
                     $aSmtpCredentials['Secure'] = MailSo\Net\Enumerations\ConnectionSecurityType::NONE;
                     break;
             }
             $aSmtpCredentials['UseAuth'] = (bool) $this->Config()->Get('plugin', 'smtp_auth', true);
             $aSmtpCredentials['Login'] = \trim($this->Config()->Get('plugin', 'smtp_user', ''));
             $aSmtpCredentials['Password'] = (string) $this->Config()->Get('plugin', 'smtp_password', '');
         }
     }
 }
Example #2
0
 /**
  * @param string $sEmail
  * @param string $sLogin
  * @param string $sPassword
  *
  * @throws \RainLoop\Exceptions\ClientException
  */
 public function FilterLoginCredentials(&$sEmail, &$sLogin, &$sPassword)
 {
     $sWhiteList = \trim($this->Config()->Get('plugin', 'white_list', ''));
     if (0 < strlen($sWhiteList) && !\RainLoop\Plugins\Helper::ValidateWildcardValues($sEmail, $sWhiteList)) {
         $sExceptions = \trim($this->Config()->Get('plugin', 'exceptions', ''));
         if (0 === \strlen($sExceptions) || !\RainLoop\Plugins\Helper::ValidateWildcardValues($sEmail, $sExceptions)) {
             throw new \RainLoop\Exceptions\ClientException($this->Config()->Get('plugin', 'auth_error', true) ? \RainLoop\Notifications::AuthError : \RainLoop\Notifications::AccountNotAllowed);
         }
     }
 }
 /**
  * @param \RainLoop\Account $oAccount
  *
  * @return bool
  */
 public function PasswordChangePossibility($oAccount)
 {
     return $oAccount && $oAccount->Email() && \RainLoop\Plugins\Helper::ValidateWildcardValues($oAccount->Email(), $this->sAllowedEmails);
 }
 /**
  * @param string $sName
  * @param bool $bFindWithWildCard = false
  * @param bool $bCheckDisabled = true
  *
  * @return \RainLoop\Model\Domain|null
  */
 public function Load($sName, $bFindWithWildCard = false, $bCheckDisabled = true)
 {
     $mResult = null;
     $sDisabled = '';
     $sFoundedValue = '';
     $sRealFileName = $this->codeFileName($sName);
     if (\file_exists($this->sDomainPath . '/disabled')) {
         $sDisabled = @\file_get_contents($this->sDomainPath . '/disabled');
     }
     if (\file_exists($this->sDomainPath . '/' . $sRealFileName . '.ini') && (!$bCheckDisabled || 0 === \strlen($sDisabled) || false === \strpos(',' . $sDisabled . ',', ',' . \MailSo\Base\Utils::IdnToAscii($sName, true) . ','))) {
         $aDomain = \RainLoop\Utils::CustomParseIniFile($this->sDomainPath . '/' . $sRealFileName . '.ini');
         // fix misspellings (#119)
         if (\is_array($aDomain)) {
             if (isset($aDomain['smpt_host'])) {
                 $aDomain['smtp_host'] = $aDomain['smpt_host'];
             }
             if (isset($aDomain['smpt_port'])) {
                 $aDomain['smtp_port'] = $aDomain['smpt_port'];
             }
             if (isset($aDomain['smpt_secure'])) {
                 $aDomain['smtp_secure'] = $aDomain['smpt_secure'];
             }
             if (isset($aDomain['smpt_auth'])) {
                 $aDomain['smtp_auth'] = $aDomain['smpt_auth'];
             }
         }
         //---
         $mResult = \RainLoop\Model\Domain::NewInstanceFromDomainConfigArray($sName, $aDomain);
     } else {
         if ($bFindWithWildCard) {
             $sNames = $this->getWildcardDomainsLine();
             if (0 < \strlen($sNames)) {
                 if (\RainLoop\Plugins\Helper::ValidateWildcardValues(\MailSo\Base\Utils::IdnToUtf8($sName, true), $sNames, $sFoundedValue) && 0 < \strlen($sFoundedValue)) {
                     if (!$bCheckDisabled || 0 === \strlen($sDisabled) || false === \strpos(',' . $sDisabled . ',', ',' . $sFoundedValue . ',')) {
                         $mResult = $this->Load($sFoundedValue, false);
                     }
                 }
             }
         }
     }
     return $mResult;
 }
 /**
  * @param \RainLoop\Model\Account $oAccount
  * @param string $sQuery
  * @param int $iLimit = 20
  *
  * @return array
  */
 public function Process($oAccount, $sQuery, $iLimit = 20)
 {
     $sQuery = \trim($sQuery);
     if (2 > \strlen($sQuery)) {
         return array();
     } else {
         if (!$oAccount || !\RainLoop\Plugins\Helper::ValidateWildcardValues($oAccount->Email(), $this->sAllowedEmails)) {
             return array();
         }
     }
     $aResult = $this->ldapSearch($oAccount, $sQuery);
     $aResult = \RainLoop\Utils::RemoveSuggestionDuplicates($aResult);
     if ($iLimit < \count($aResult)) {
         $aResult = \array_slice($aResult, 0, $iLimit);
     }
     return $aResult;
 }