本文整理匯總了PHP中MailSo\Base\Utils::Trim方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utils::Trim方法的具體用法?PHP Utils::Trim怎麽用?PHP Utils::Trim使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MailSo\Base\Utils
的用法示例。
在下文中一共展示了Utils::Trim方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
/**
* @access protected
*
* @param string $sEmailAddresses = ''
*/
protected function __construct($sEmailAddresses = '')
{
parent::__construct();
$sEmailAddresses = \MailSo\Base\Utils::Trim($sEmailAddresses);
if (0 < \strlen($sEmailAddresses)) {
$this->parseEmailAddresses($sEmailAddresses);
}
}
示例2: Login
/**
* @param string $sLogin
* @param string $sPassword
* @param string $sProxyAuthUser = ''
* @param bool $bUseAuthPlainIfSupported = false
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function Login($sLogin, $sPassword, $sProxyAuthUser = '', $bUseAuthPlainIfSupported = false)
{
if (!\MailSo\Base\Validator::NotEmptyString($sLogin, true) || !\MailSo\Base\Validator::NotEmptyString($sPassword, true)) {
$this->writeLogException(new \MailSo\Base\Exceptions\InvalidArgumentException(), \MailSo\Log\Enumerations\Type::ERROR, true);
}
$sLogin = \MailSo\Base\Utils::IdnToAscii(\MailSo\Base\Utils::Trim($sLogin));
$sPassword = $sPassword;
$this->sLogginedUser = $sLogin;
try {
// TODO
if (false && $this->IsSupported('AUTH=CRAM-MD5')) {
$this->SendRequest('AUTHENTICATE', array('CRAM-MD5'));
$aResponse = $this->parseResponseWithValidation();
if ($aResponse && \is_array($aResponse) && 0 < \count($aResponse) && \MailSo\Imap\Enumerations\ResponseType::CONTINUATION === $aResponse[\count($aResponse) - 1]->ResponseType) {
$oContinuationResponse = null;
foreach ($aResponse as $oResponse) {
if ($oResponse && \MailSo\Imap\Enumerations\ResponseType::CONTINUATION === $oResponse->ResponseType) {
$oContinuationResponse = $oResponse;
}
}
if ($oContinuationResponse) {
$sToken = \base64_encode("" . $sLogin . "" . $sPassword);
if ($this->oLogger) {
$this->oLogger->AddSecret($sToken);
}
$this->Logger()->WriteDump($aResponse);
$this->sendRaw($sToken, true, '*******');
$this->parseResponseWithValidation();
} else {
// TODO
}
}
} else {
if ($bUseAuthPlainIfSupported && $this->IsSupported('AUTH=PLAIN')) {
$sToken = \base64_encode("" . $sLogin . "" . $sPassword);
if ($this->oLogger) {
$this->oLogger->AddSecret($sToken);
}
if ($this->IsSupported('AUTH=SASL-IR') && false) {
$this->SendRequestWithCheck('AUTHENTICATE', array('PLAIN', $sToken));
} else {
$this->SendRequest('AUTHENTICATE', array('PLAIN'));
$this->parseResponseWithValidation();
$this->sendRaw($sToken, true, '*******');
$this->parseResponseWithValidation();
}
} else {
if ($this->oLogger) {
$this->oLogger->AddSecret($this->EscapeString($sPassword));
}
$this->SendRequestWithCheck('LOGIN', array($this->EscapeString($sLogin), $this->EscapeString($sPassword)));
}
}
// else
// {
// $this->writeLogException(
// new \MailSo\Imap\Exceptions\LoginBadMethodException(),
// \MailSo\Log\Enumerations\Type::NOTICE, true);
// }
if (0 < \strlen($sProxyAuthUser)) {
$this->SendRequestWithCheck('PROXYAUTH', array($this->EscapeString($sProxyAuthUser)));
}
} catch (\MailSo\Imap\Exceptions\NegativeResponseException $oException) {
$this->writeLogException(new \MailSo\Imap\Exceptions\LoginBadCredentialsException($oException->GetResponses(), '', 0, $oException), \MailSo\Log\Enumerations\Type::NOTICE, true);
}
$this->bIsLoggined = true;
$this->aCapabilityItems = null;
return $this;
}
示例3: DoLogin
/**
* @return array
*
* @throws \MailSo\Base\Exceptions\Exception
*/
public function DoLogin()
{
$sEmail = \MailSo\Base\Utils::Trim($this->GetActionParam('Email', ''));
$sPassword = $this->GetActionParam('Password', '');
$sLanguage = $this->GetActionParam('Language', '');
$bSignMe = '1' === (string) $this->GetActionParam('SignMe', '0');
$sAdditionalCode = $this->GetActionParam('AdditionalCode', '');
$bAdditionalCodeSignMe = '1' === (string) $this->GetActionParam('AdditionalCodeSignMe', '0');
$oAccount = null;
$sPassword = $this->clientRsaDecryptHelper($sPassword);
$this->Logger()->AddSecret($sPassword);
if (0 < \strlen($sEmail) && 0 < \strlen($sPassword) && $this->Config()->Get('security', 'allow_universal_login', true) && $this->Config()->Get('security', 'allow_admin_panel', true) && $sEmail === $this->Config()->Get('security', 'admin_login', '')) {
if ($this->Config()->ValidatePassword($sPassword)) {
$this->setAdminAuthToken($this->getAdminToken());
return $this->DefaultResponse(__FUNCTION__, true, array('Admin' => true));
} else {
$this->loginErrorDelay();
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError);
}
} else {
if ('sleep@sleep.dev' === $sEmail && 0 < \strlen($sPassword) && \is_numeric($sPassword) && $this->Config()->Get('debug', 'enable', false)) {
\sleep((int) $sPassword);
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError);
}
}
try {
$oAccount = $this->LoginProcess($sEmail, $sPassword, $bSignMe ? $this->generateSignMeToken($sEmail) : '', $sAdditionalCode, $bAdditionalCodeSignMe);
} catch (\RainLoop\Exceptions\ClientException $oException) {
if ($oException && \RainLoop\Notifications::AccountTwoFactorAuthRequired === $oException->getCode()) {
return $this->DefaultResponse(__FUNCTION__, true, array('TwoFactorAuth' => true));
} else {
throw $oException;
}
}
$this->AuthToken($oAccount);
if ($oAccount && 0 < \strlen($sLanguage)) {
$oSettings = $this->SettingsProvider()->Load($oAccount);
if ($oSettings) {
$sLanguage = $this->ValidateLanguage($sLanguage);
$sCurrentLanguage = $oSettings->GetConf('Language', '');
if ($sCurrentLanguage !== $sLanguage) {
$oSettings->SetConf('Language', $sLanguage);
$this->SettingsProvider()->Save($oAccount, $oSettings);
}
}
}
return $this->TrueResponse(__FUNCTION__);
}
示例4: ClearXss
/**
* @param string $sValue
*
* @return string
*/
public static function ClearXss($sValue)
{
return \MailSo\Base\Utils::Trim(\MailSo\Base\Utils::ClearNullBite(\str_replace(array('"', '/', '\\', '*', '?', '<', '>', '|', ':'), ' ', $sValue)));
}
示例5: Vrfy
/**
* @return \MailSo\Smtp\SmtpClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception
*/
public function Vrfy($sUser)
{
$sUser = \MailSo\Base\Utils::IdnToAscii(\MailSo\Base\Utils::Trim($sUser));
$this->sendRequestWithCheck('VRFY', array(250, 251, 252), $sUser);
return $this;
}
示例6: Parse
/**
* @param string $sEmailAddress
* @return \MailSo\Mime\Email
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public static function Parse($sEmailAddress)
{
$sEmailAddress = \MailSo\Base\Utils::Trim($sEmailAddress);
if (!\MailSo\Base\Validator::NotEmptyString($sEmailAddress, true)) {
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
}
$sName = '';
$sEmail = '';
$sComment = '';
$bInName = false;
$bInAddress = false;
$bInComment = false;
$iStartIndex = 0;
$iEndIndex = 0;
$iCurrentIndex = 0;
while ($iCurrentIndex < \strlen($sEmailAddress)) {
switch ($sEmailAddress[$iCurrentIndex]) {
// case '\'':
case '"':
// $sQuoteChar = $sEmailAddress{$iCurrentIndex};
if (!$bInName && !$bInAddress && !$bInComment) {
$bInName = true;
$iStartIndex = $iCurrentIndex;
} else {
if (!$bInAddress && !$bInComment) {
$iEndIndex = $iCurrentIndex;
$sName = \substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1);
$sEmailAddress = \substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1);
$iEndIndex = 0;
$iCurrentIndex = 0;
$iStartIndex = 0;
$bInName = false;
}
}
break;
case '<':
if (!$bInName && !$bInAddress && !$bInComment) {
if ($iCurrentIndex > 0 && \strlen($sName) === 0) {
$sName = \substr($sEmailAddress, 0, $iCurrentIndex);
}
$bInAddress = true;
$iStartIndex = $iCurrentIndex;
}
break;
case '>':
if ($bInAddress) {
$iEndIndex = $iCurrentIndex;
$sEmail = \substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1);
$sEmailAddress = \substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1);
$iEndIndex = 0;
$iCurrentIndex = 0;
$iStartIndex = 0;
$bInAddress = false;
}
break;
case '(':
if (!$bInName && !$bInAddress && !$bInComment) {
$bInComment = true;
$iStartIndex = $iCurrentIndex;
}
break;
case ')':
if ($bInComment) {
$iEndIndex = $iCurrentIndex;
$sComment = \substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1);
$sEmailAddress = \substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1);
$iEndIndex = 0;
$iCurrentIndex = 0;
$iStartIndex = 0;
$bInComment = false;
}
break;
case '\\':
$iCurrentIndex++;
break;
}
$iCurrentIndex++;
}
if (\strlen($sEmail) === 0) {
$aRegs = array('');
if (\preg_match('/[^@\\s]+@\\S+/i', $sEmailAddress, $aRegs) && isset($aRegs[0])) {
$sEmail = $aRegs[0];
} else {
$sName = $sEmailAddress;
}
}
if (\strlen($sEmail) > 0 && \strlen($sName) == 0 && \strlen($sComment) == 0) {
$sName = \str_replace($sEmail, '', $sEmailAddress);
}
$sEmail = \trim(\trim($sEmail), '<>');
$sEmail = \rtrim(\trim($sEmail), '.');
$sEmail = \trim($sEmail);
$sName = \trim(\trim($sName), '"');
$sName = \trim($sName, '\'');
//.........這裏部分代碼省略.........