예제 #1
0
 /**
  * @param string $sStr
  * @param bool $bLowerIfAscii = false
  *
  * @return string
  */
 public static function IdnToAscii($sStr, $bLowerIfAscii = false)
 {
     $sStr = $bLowerIfAscii ? \MailSo\Base\Utils::StrMailDomainToLowerIfAscii($sStr) : $sStr;
     $sUser = '';
     $sDomain = $sStr;
     if (false !== \strpos($sStr, '@')) {
         $sUser = \MailSo\Base\Utils::GetAccountNameFromEmail($sStr);
         $sDomain = \MailSo\Base\Utils::GetDomainFromEmail($sStr);
     }
     if (0 < \strlen($sDomain) && \preg_match('/[^\\x20-\\x7E]/', $sDomain)) {
         try {
             $sDomain = self::idn()->encode($sDomain);
         } catch (\Exception $oException) {
         }
     }
     return ('' === $sUser ? '' : $sUser . '@') . $sDomain;
 }
예제 #2
0
 public function UpdateDependentValues()
 {
     $this->Value = \trim($this->Value);
     $this->ValueCustom = \trim($this->ValueCustom);
     $this->TypeStr = \trim($this->TypeStr);
     $this->ValueLower = '';
     if (0 < \strlen($this->Value)) {
         // lower
         if ($this->IsEmail()) {
             $this->Value = \MailSo\Base\Utils::StrMailDomainToLowerIfAscii($this->Value);
         }
         if ($this->IsName()) {
             $this->Value = \MailSo\Base\Utils::StripSpaces($this->Value);
         }
         // lower value for searching
         if ($this->IsValueForLower() && \MailSo\Base\Utils::FunctionExistsAndEnabled('mb_strtolower')) {
             $this->ValueLower = (string) @\mb_strtolower($this->Value, 'UTF-8');
         }
         // phone value for searching
         if ($this->IsPhone()) {
             $sPhone = \trim($this->Value);
             $sPhone = \preg_replace('/^[+]+/', '', $sPhone);
             $sPhone = \preg_replace('/[^\\d]/', '', $sPhone);
             $this->ValueCustom = \trim($sPhone);
         }
     }
 }