本文整理匯總了PHP中MailSo\Base\Utils::StripSpaces方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utils::StripSpaces方法的具體用法?PHP Utils::StripSpaces怎麽用?PHP Utils::StripSpaces使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MailSo\Base\Utils
的用法示例。
在下文中一共展示了Utils::StripSpaces方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: filterToSieveScript
/**
* @param \RainLoop\Providers\Filters\Classes\Filter $oFilter
* @param array $aCapa
*
* @return string
*/
private function filterToSieveScript($oFilter, &$aCapa)
{
$sNL = \RainLoop\Providers\Filters\SieveStorage::NEW_LINE;
$sTab = ' ';
$bAll = false;
$aResult = array();
// Conditions
$aConditions = $oFilter->Conditions();
if (\is_array($aConditions)) {
if (1 < \count($aConditions)) {
if (\RainLoop\Providers\Filters\Enumerations\ConditionsType::ANY === $oFilter->ConditionsType()) {
$aResult[] = 'if anyof(';
$bTrim = false;
foreach ($aConditions as $oCond) {
$bTrim = true;
$sCons = $this->conditionToSieveScript($oCond);
if (!empty($sCons)) {
$aResult[] = $sTab . $sCons . ',';
}
}
if ($bTrim) {
$aResult[\count($aResult) - 1] = \rtrim($aResult[\count($aResult) - 1], ',');
}
$aResult[] = ')';
} else {
$aResult[] = 'if allof(';
foreach ($aConditions as $oCond) {
$aResult[] = $sTab . $this->conditionToSieveScript($oCond) . ',';
}
$aResult[\count($aResult) - 1] = \rtrim($aResult[\count($aResult) - 1], ',');
$aResult[] = ')';
}
} else {
if (1 === \count($aConditions)) {
$aResult[] = 'if ' . $this->conditionToSieveScript($aConditions[0]) . '';
} else {
$bAll = true;
}
}
}
// actions
if (!$bAll) {
$aResult[] = '{';
} else {
$sTab = '';
}
if ($oFilter->MarkAsRead() && \in_array($oFilter->ActionType(), array(\RainLoop\Providers\Filters\Enumerations\ActionType::NONE, \RainLoop\Providers\Filters\Enumerations\ActionType::MOVE_TO, \RainLoop\Providers\Filters\Enumerations\ActionType::FORWARD))) {
$aCapa['imap4flags'] = true;
$aResult[] = $sTab . 'addflag "\\\\Seen";';
}
switch ($oFilter->ActionType()) {
case \RainLoop\Providers\Filters\Enumerations\ActionType::NONE:
$aResult[] = $sTab . 'stop;';
break;
case \RainLoop\Providers\Filters\Enumerations\ActionType::DISCARD:
$aResult[] = $sTab . 'discard;';
$aResult[] = $sTab . 'stop;';
break;
case \RainLoop\Providers\Filters\Enumerations\ActionType::VACATION:
$sValue = \trim($oFilter->ActionValue());
$sValueSecond = \trim($oFilter->ActionValueSecond());
$sValueThird = \trim($oFilter->ActionValueThird());
if (0 < \strlen($sValue)) {
$aCapa['vacation'] = true;
$iDays = 1;
$sSubject = '';
if (0 < \strlen($sValueSecond)) {
$sSubject = ':subject "' . $this->quote(\MailSo\Base\Utils::StripSpaces($sValueSecond)) . '" ';
}
if (0 < \strlen($sValueThird) && \is_numeric($sValueThird) && 1 < (int) $sValueThird) {
$iDays = (int) $sValueThird;
}
$aResult[] = $sTab . 'vacation :days ' . $iDays . ' ' . $sSubject . '"' . $this->quote($sValue) . '";';
if ($oFilter->Stop()) {
$aResult[] = $sTab . 'stop;';
}
} else {
$aResult[] = $sTab . '# @Error (vacation): empty action value';
}
break;
case \RainLoop\Providers\Filters\Enumerations\ActionType::REJECT:
$sValue = \trim($oFilter->ActionValue());
if (0 < \strlen($sValue)) {
$aCapa['reject'] = true;
$aResult[] = $sTab . 'reject "' . $this->quote($sValue) . '";';
$aResult[] = $sTab . 'stop;';
} else {
$aResult[] = $sTab . '# @Error (reject): empty action value';
}
break;
case \RainLoop\Providers\Filters\Enumerations\ActionType::FORWARD:
$sValue = $oFilter->ActionValue();
if (0 < \strlen($sValue)) {
if ($oFilter->Keep()) {
//.........這裏部分代碼省略.........
示例2: ConvertHtmlToPlain
/**
* @param string $sText
*
* @return string
*/
public static function ConvertHtmlToPlain($sText)
{
$sText = \trim(\stripslashes($sText));
$sText = \MailSo\Base\Utils::StripSpaces($sText);
$sText = \preg_replace(array("/\r/", "/[\n\t]+/", '/<script[^>]*>.*?<\\/script>/i', '/<style[^>]*>.*?<\\/style>/i', '/<title[^>]*>.*?<\\/title>/i', '/<h[123][^>]*>(.+?)<\\/h[123]>/i', '/<h[456][^>]*>(.+?)<\\/h[456]>/i', '/<p[^>]*>/i', '/<br[^>]*>/i', '/<b[^>]*>(.+?)<\\/b>/i', '/<i[^>]*>(.+?)<\\/i>/i', '/(<ul[^>]*>|<\\/ul>)/i', '/(<ol[^>]*>|<\\/ol>)/i', '/<li[^>]*>/i', '/<a[^>]*href="([^"]+)"[^>]*>(.+?)<\\/a>/i', '/<hr[^>]*>/i', '/(<table[^>]*>|<\\/table>)/i', '/(<tr[^>]*>|<\\/tr>)/i', '/<td[^>]*>(.+?)<\\/td>/i', '/<th[^>]*>(.+?)<\\/th>/i', '/ /i', '/"/i', '/>/i', '/</i', '/&/i', '/©/i', '/™/i', '/“/', '/”/', '/–/', '/’/', '/&/', '/©/', '/™/', '/—/', '/“/', '/”/', '/•/', '/®/i', '/•/i', '/&[&;]+;/i', '/'/', '/ /'), array('', ' ', '', '', '', "\n\n\\1\n\n", "\n\n\\1\n\n", "\n\n\t", "\n", '\\1', '\\1', "\n\n", "\n\n", "\n\t* ", '\\2 (\\1)', "\n------------------------------------\n", "\n", "\n", "\t\\1\n", "\t\\1\n", ' ', '"', '>', '<', '&', '(c)', '(tm)', '"', '"', '-', "'", '&', '(c)', '(tm)', '--', '"', '"', '*', '(R)', '*', '', '\'', ''), $sText);
$sText = \str_ireplace('<div>', "\n<div>", $sText);
$sText = \strip_tags($sText, '');
$sText = \preg_replace("/\n\\s+\n/", "\n", $sText);
$sText = \preg_replace("/[\n]{3,}/", "\n\n", $sText);
return \trim($sText);
}
示例3: getImapSearchCriterias
//.........這裏部分代碼省略.........
$aCriteriasResult[] = 'FLAGGED';
$bUseCache = false;
} else {
if (\count($aCompareArray2) > \count(\array_diff($aCompareArray2, $aValue))) {
$aCriteriasResult[] = 'UNFLAGGED';
$bUseCache = false;
}
}
$aCompareArray = array('unread', 'unseen');
$aCompareArray2 = array('read', 'seen');
if (\count($aCompareArray) > \count(\array_diff($aCompareArray, $aValue))) {
$aCriteriasResult[] = 'UNSEEN';
$bUseCache = false;
} else {
if (\count($aCompareArray2) > \count(\array_diff($aCompareArray2, $aValue))) {
$aCriteriasResult[] = 'SEEN';
$bUseCache = false;
}
}
break;
case 'LARGER':
$aCriteriasResult[] = 'LARGER';
$aCriteriasResult[] = $this->parseFriendlySize($sRawValue);
break;
case 'SMALLER':
$aCriteriasResult[] = 'SMALLER';
$aCriteriasResult[] = $this->parseFriendlySize($sRawValue);
break;
case 'DATE':
$iDateStampFrom = $iDateStampTo = 0;
$sDate = $sRawValue;
$aDate = \explode('/', $sDate);
if (\is_array($aDate) && 2 === \count($aDate)) {
if (0 < \strlen($aDate[0])) {
$iDateStampFrom = $this->parseSearchDate($aDate[0], $iTimeZoneOffset);
}
if (0 < \strlen($aDate[1])) {
$iDateStampTo = $this->parseSearchDate($aDate[1], $iTimeZoneOffset);
$iDateStampTo += 60 * 60 * 24;
}
} else {
if (0 < \strlen($sDate)) {
$iDateStampFrom = $this->parseSearchDate($sDate, $iTimeZoneOffset);
$iDateStampTo = $iDateStampFrom + 60 * 60 * 24;
}
}
if (0 < $iDateStampFrom) {
$aCriteriasResult[] = 'SINCE';
$aCriteriasResult[] = \gmdate('j-M-Y', $iTimeFilter > $iDateStampFrom ? $iTimeFilter : $iDateStampFrom);
$iTimeFilter = 0;
}
if (0 < $iDateStampTo) {
$aCriteriasResult[] = 'BEFORE';
$aCriteriasResult[] = \gmdate('j-M-Y', $iDateStampTo);
}
break;
}
}
if ('' !== \trim($sMainText)) {
$sMainText = \trim(\MailSo\Base\Utils::StripSpaces($sMainText), '"');
if ($bIsGmail) {
$sGmailRawSearch .= ' ' . $sMainText;
} else {
$sResultBodyTextSearch .= ' ' . $sMainText;
}
}
}
$sGmailRawSearch = \trim($sGmailRawSearch);
if ($bIsGmail && 0 < \strlen($sGmailRawSearch)) {
$aCriteriasResult[] = 'X-GM-RAW';
$aCriteriasResult[] = $this->escapeSearchString($sGmailRawSearch, false);
}
$sResultBodyTextSearch = \trim($sResultBodyTextSearch);
if (0 < \strlen($sResultBodyTextSearch)) {
$aCriteriasResult[] = 'BODY';
$aCriteriasResult[] = $this->escapeSearchString($sResultBodyTextSearch);
}
}
$sCriteriasResult = \trim(\implode(' ', $aCriteriasResult));
if (0 < $iTimeFilter) {
$sCriteriasResult .= ' SINCE ' . \gmdate('j-M-Y', $iTimeFilter);
}
$sCriteriasResult = \trim($sCriteriasResult);
if (\MailSo\Config::$MessageListUndeletedOnly) {
$sCriteriasResult = \trim($sCriteriasResult . ' UNDELETED');
}
$sFilter = \trim($sFilter);
if ('' !== $sFilter) {
$sCriteriasResult .= ' ' . $sFilter;
}
$sCriteriasResult = \trim($sCriteriasResult);
if ('' !== \MailSo\Config::$MessageListPermanentFilter) {
$sCriteriasResult = \trim($sCriteriasResult . ' ' . \MailSo\Config::$MessageListPermanentFilter);
}
$sCriteriasResult = \trim($sCriteriasResult);
if ('' === $sCriteriasResult) {
$sCriteriasResult = 'ALL';
}
return $sCriteriasResult;
}
示例4: MainClearFileName
/**
* @param string $sFileName
* @param string $sContentType
* @param string $sMimeIndex
* @param int $iMaxLength = 250
*
* @return string
*/
public function MainClearFileName($sFileName, $sContentType, $sMimeIndex, $iMaxLength = 250)
{
$sFileName = 0 === \strlen($sFileName) ? \preg_replace('/[^a-zA-Z0-9]/', '.', (empty($sMimeIndex) ? '' : $sMimeIndex . '.') . $sContentType) : $sFileName;
$sClearedFileName = \MailSo\Base\Utils::StripSpaces(\preg_replace('/[\\.]+/', '.', $sFileName));
$sExt = \MailSo\Base\Utils::GetFileExtension($sClearedFileName);
if (10 < $iMaxLength && $iMaxLength < \strlen($sClearedFileName) - \strlen($sExt)) {
$sClearedFileName = \substr($sClearedFileName, 0, $iMaxLength) . (empty($sExt) ? '' : '.' . $sExt);
}
return \MailSo\Base\Utils::ClearFileName(\MailSo\Base\Utils::Utf8Clear($sClearedFileName));
}
示例5: ClearFileName
/**
* @param string $sFileName
*
* @return string
*/
public static function ClearFileName($sFileName)
{
return \MailSo\Base\Utils::Trim(\MailSo\Base\Utils::ClearNullBite(\MailSo\Base\Utils::StripSpaces(\str_replace(array('"', '/', '\\', '*', '?', '<', '>', '|', ':'), ' ', $sFileName))));
}
示例6: SetReferences
/**
* @param string $sReferences
*
* @return \MailSo\Mime\Message
*/
public function SetReferences($sReferences)
{
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::REFERENCES] = \MailSo\Base\Utils::StripSpaces($sReferences);
return $this;
}
示例7: UpdateDependentValues
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::StrToLowerIfAscii($this->Value);
}
if ($this->IsName()) {
$this->Value = \MailSo\Base\Utils::StripSpaces($this->Value);
}
// lower value for searching
if (\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);
}
}
}
示例8: InitByFetchResponse
/**
* @param string $sFolder
* @param \MailSo\Imap\FetchResponse $oFetchResponse
* @param \MailSo\Imap\BodyStructure $oBodyStructure = null
*
* @return \MailSo\Mail\Message
*/
public function InitByFetchResponse($sFolder, $oFetchResponse, $oBodyStructure = null)
{
if (!$oBodyStructure) {
$oBodyStructure = $oFetchResponse->GetFetchBodyStructure();
}
$sUid = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::UID);
$sSize = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::RFC822_SIZE);
$sInternalDate = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::INTERNALDATE);
$aFlags = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::FLAGS);
$this->sFolder = $sFolder;
$this->iUid = \is_numeric($sUid) ? (int) $sUid : 0;
$this->iSize = \is_numeric($sSize) ? (int) $sSize : 0;
$this->aFlags = \is_array($aFlags) ? $aFlags : array();
$this->aFlagsLowerCase = \array_map('strtolower', $this->aFlags);
$this->iInternalTimeStampInUTC = \MailSo\Base\DateTimeHelper::ParseInternalDateString($sInternalDate);
$sCharset = $oBodyStructure ? $oBodyStructure->SearchCharset() : '';
$sCharset = \MailSo\Base\Utils::NormalizeCharset($sCharset);
$sHeaders = $oFetchResponse->GetHeaderFieldsValue();
if (0 < \strlen($sHeaders)) {
$oHeaders = \MailSo\Mime\HeaderCollection::NewInstance()->Parse($sHeaders, false, $sCharset);
$sContentTypeCharset = $oHeaders->ParameterValue(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE, \MailSo\Mime\Enumerations\Parameter::CHARSET);
if (0 < \strlen($sContentTypeCharset)) {
$sCharset = $sContentTypeCharset;
$sCharset = \MailSo\Base\Utils::NormalizeCharset($sCharset);
}
if (0 < \strlen($sCharset)) {
$oHeaders->SetParentCharset($sCharset);
}
$bCharsetAutoDetect = 0 === \strlen($sCharset);
$this->sSubject = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::SUBJECT, $bCharsetAutoDetect);
$this->sMessageId = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::MESSAGE_ID);
$this->sContentType = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE);
$this->oFrom = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::FROM_, $bCharsetAutoDetect);
$this->oTo = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::TO_, $bCharsetAutoDetect);
$this->oCc = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::CC, $bCharsetAutoDetect);
$this->oBcc = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::BCC, $bCharsetAutoDetect);
$oHeaders->PopulateEmailColectionByDkim($this->oFrom);
$this->oSender = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::SENDER, $bCharsetAutoDetect);
$this->oReplyTo = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::REPLY_TO, $bCharsetAutoDetect);
$this->oDeliveredTo = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::DELIVERED_TO, $bCharsetAutoDetect);
$this->sInReplyTo = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::IN_REPLY_TO);
$this->sReferences = \MailSo\Base\Utils::StripSpaces($oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::REFERENCES));
$sHeaderDate = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::DATE);
$this->sHeaderDate = $sHeaderDate;
$this->iHeaderTimeStampInUTC = \MailSo\Base\DateTimeHelper::ParseRFC2822DateString($sHeaderDate);
// Sensitivity
$this->iSensitivity = \MailSo\Mime\Enumerations\Sensitivity::NOTHING;
$sSensitivity = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::SENSITIVITY);
switch (\strtolower($sSensitivity)) {
case 'personal':
$this->iSensitivity = \MailSo\Mime\Enumerations\Sensitivity::PERSONAL;
break;
case 'private':
$this->iSensitivity = \MailSo\Mime\Enumerations\Sensitivity::PRIVATE_;
break;
case 'company-confidential':
$this->iSensitivity = \MailSo\Mime\Enumerations\Sensitivity::CONFIDENTIAL;
break;
}
// Priority
$this->iPriority = \MailSo\Mime\Enumerations\MessagePriority::NORMAL;
$sPriority = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_MSMAIL_PRIORITY);
if (0 === \strlen($sPriority)) {
$sPriority = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::IMPORTANCE);
}
if (0 === \strlen($sPriority)) {
$sPriority = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_PRIORITY);
}
if (0 < \strlen($sPriority)) {
switch (\str_replace(' ', '', \strtolower($sPriority))) {
case 'high':
case '1(highest)':
case '2(high)':
case '1':
case '2':
$this->iPriority = \MailSo\Mime\Enumerations\MessagePriority::HIGH;
break;
case 'low':
case '4(low)':
case '5(lowest)':
case '4':
case '5':
$this->iPriority = \MailSo\Mime\Enumerations\MessagePriority::LOW;
break;
}
}
// Delivery Receipt
$this->sDeliveryReceipt = \trim($oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::RETURN_RECEIPT_TO));
// Read Receipt
$this->sReadReceipt = \trim($oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::DISPOSITION_NOTIFICATION_TO));
if (empty($this->sReadReceipt)) {
$this->sReadReceipt = \trim($oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_CONFIRM_READING_TO));
}
//.........這裏部分代碼省略.........