/** * @return string */ function GetPlainLowerCaseBodyText() { $mailText = ''; if ($this->TextBodies->PlainTextBodyPart != '') { $mailText = $this->TextBodies->PlainTextBodyPart; } elseif ($this->TextBodies->HtmlTextBodyPart != '') { $mailText = $this->TextBodies->HtmlToPlain(); } $mailText = preg_replace('/[\\s]+/', ' ', str_replace(array(CRLF, "\t", "\r", "\n"), ' ', $mailText)); $i18String = new I18nString($mailText, $GLOBALS[MailOutputCharset]); return $i18String->ToLower($GLOBALS[MailOutputCharset]); }
/** * @param string $from_encoding * @param string $to_encoding * @param string $str * @return string */ function ClassIconv($from_encoding, $to_encoding, $str) { /*if ($from_encoding != CPAGE_UTF7_Imap && ConvertUtils::IsLatin($str)) { return ConvertUtils::IsUtf7($str) ? str_replace('&', '&-', $str) : $str; }/**/ if ($from_encoding == CPAGE_UTF7_Imap || $to_encoding == CPAGE_UTF7_Imap) { $i18str = new I18nString($str, $from_encoding); return $i18str->GetText($to_encoding); } if (strtolower($from_encoding) == 'ascii') { $from_encoding = 'iso-8859-1'; } if (strtolower($from_encoding) == 'ks_c_5601-1987') { $from_encoding = 'EUC-KR'; } $iconv_encodings_array = array('ascii', 'iso-8859-1', 'iso-8859-2', 'iso-8859-3', 'iso-8859-4', 'iso-8859-5', 'iso-8859-6', 'iso-8859-7', 'iso-8859-8', 'iso-8859-9', 'iso-8859-10', 'iso-8859-11', 'iso-8859-12', 'iso-8859-13', 'iso-8859-14', 'iso-8859-15', 'iso-8859-16', 'koi8-r', 'koi8-u', 'koi8-ru', 'cp1250', 'cp1251', 'cp1252', 'cp1253', 'cp1254', 'cp1257', 'cp949', 'cp1133', 'cp850', 'cp866', 'cp1255', 'cp1256', 'cp862', 'cp874', 'cp932', 'cp950', 'cp1258', 'windows-1250', 'windows-1251', 'windows-1252', 'windows-1253', 'windows-1254', 'windows-1255', 'windows-1256', 'windows-1257', 'windows-1258', 'windows-874', 'macroman', 'maccentraleurope', 'maciceland', 'maccroatian', 'macromania', 'maccyrillic', 'macukraine', 'macgreek', 'macturkish', 'macintosh', 'machebrew', 'macarabic', 'euc-jp', 'shift_jis', 'iso-2022-jp', 'iso-2022-jp-2', 'iso-2022-jp-1', 'euc-cn', 'gb2312', 'hz', 'gbk', 'gb18030', 'euc-tw', 'big5', 'big5-hkscs', 'iso-2022-cn', 'iso-2022-cn-ext', 'euc-kr', 'iso-2022-kr', 'johab', 'armscii-8', 'georgian-academy', 'georgian-ps', 'koi8-t', 'tis-620', 'macthai', 'mulelao-1', 'viscii', 'tcvn', 'hp-roman8', 'nextstep', 'utf-8', 'ucs-2', 'ucs-2be', 'ucs-2le', 'ucs-4', 'ucs-4be', 'ucs-4le', 'utf-16', 'utf-16be', 'utf-16le', 'utf-32', 'utf-32be', 'utf-32le', 'utf-7', 'c99', 'java', 'ucs-2-internal', 'ucs-4-internal'); if (in_array(strtolower($from_encoding), $iconv_encodings_array)) { $result = @iconv($from_encoding, $to_encoding . '//IGNORE', $str); return $result !== false ? $result : $str; } return $str; }
/** * @param WebMailMessage $message * @param Folder $folder * @param bool $downloaded * @param Account $account * @return string */ function SaveMessageHeader($message, $folder, $downloaded, $account) { /* save message header */ $sql = 'INSERT INTO %sawm_messages (id_msg, id_acct, id_folder_srv, id_folder_db, str_uid, int_uid, from_msg, to_msg, cc_msg, bcc_msg, subject, msg_date, attachments, size, downloaded, x_spam, seen, flagged, rtl, deleted, replied, grayed, flags, priority, body_text, forwarded, charset, sensitivity) VALUES (%d, %d, %d, %d, %s, %d, %s, %s, %s, %s, %s, %s, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %s, 0, -1, %d)'; $date =& $message->GetDate(); $from = new I18nString($message->GetFromAsString(), $account->DbCharset); $to = new I18nString($message->GetToAsString(), $account->DbCharset); $cc = new I18nString($message->GetCcAsString(), $account->DbCharset); $bcc = new I18nString($message->GetBccAsString(), $account->DbCharset); $subject = new I18nString($message->GetSubject(), $account->DbCharset); $str_uid = $int_uid = null; if ($account->MailProtocol == MAILPROTOCOL_IMAP4) { $str_uid = ''; $int_uid = $message->Uid; } else { $str_uid = $message->Uid; $int_uid = 0; } return sprintf($sql, $this->_settings->DbPrefix, $message->IdMsg, $account->Id, $folder->IdDb, $folder->IdDb, $this->_escapeString($str_uid), $int_uid, $this->_escapeString($from->Truncate(255)), $this->_escapeString($to->Truncate(255)), $this->_escapeString($cc->Truncate(255)), $this->_escapeString($bcc->Truncate(255)), $this->_escapeString($subject->Truncate(255)), $this->UpdateDateFormat($date->ToANSI()), (int) $message->HasAttachments(), $message->GetMailSize(), (int) $downloaded, (int) $message->GetXSpamStatus(), ($message->Flags & MESSAGEFLAGS_Seen) == MESSAGEFLAGS_Seen, ($message->Flags & MESSAGEFLAGS_Flagged) == MESSAGEFLAGS_Flagged, 0, ($message->Flags & MESSAGEFLAGS_Deleted) == MESSAGEFLAGS_Deleted, ($message->Flags & MESSAGEFLAGS_Answered) == MESSAGEFLAGS_Answered, ($message->Flags & MESSAGEFLAGS_Grayed) == MESSAGEFLAGS_Grayed, $message->Flags, $message->GetPriorityStatus(), $this->_escapeString(substr($message->GetPlainLowerCaseBodyText(), 0, 500000)), $message->GetSensitivity()); }