Text, Text = TypeText, Typemultipart = multipart, multipart = typemultipart, typemessage = message, Messag E = typemessage, typeapplication = Application, application = typeapplication, Typeaudio = audio, audio =& Gt Typeaudio, Typeimage = image, Image + Typeimage, Typevideo = video, video = Typevideo, Typeother = UNK Nown, unknown = Typeother); $mime _encodings = Array (enc7bit = 7bit, 7bit = enc7bit, Enc8bit = 8bit, 8bit = enc8bit, encbinary = b inary, binary = encbinary, ENCBASE64 = base64, base64 = ENCBASE64, encquotedprintable = quoted-printable, quoted-printable = encquotedprintable, Encother = unknown, unknown = Encother); /** * The MIME:: class provides methods for dealing with MIME standards. * * @author Chuck Hagenbuch * @version $Revision: 1.64 $ * @since Horde 1.3 * @package Horde.mime */class MIME {/** * determine if a string contai NS 8-bit characters. * @access Private * * @param string $string the string to check. * @return Boolean True if it does, false if it doesnt. */function Is8bit ($string) {if (is_string ($string)) {for ($i = 0; $i < strlen ($string); $i + +) {if (Ord ($string [$i]) >> 7) return true; } return false; } return false; }/** * Encode A string containing non-ascii characters according to RFC 2047. * * @param string $text the text to encode. * @param string $charset (optional) The character set of the text. * @param boolean $outer is this final iteration? * * @return String The text, encoded only if it contains non-ascii characters. */function Encode ($text, $charset = null, $outer = True) {if (Mime::is8bit ($text)) {if ((strlen ($text) * 3) + strlen ($ CharSet) (+ 7) >) {$text = Mime::encode (substr ($text, 0, (23-strlen ($charset))), $charset). Mime::encode(Substr ($text, (23-strlen ($charset))), $charset, false); } else {$text = "=? $charset? B? ". STRTR (Trim (Base64_encode ($text)), _). "?="; }}//If this was the final iteration, take off any trailing//Newline/tab chars. if ($outer && (substr ($text, 2 ) = = "") $text = substr ($text, 0,-2); return $text; }/** * Encode A string containing email addresses according to RFC 2047. * * This differs from Mime::encode () because it keeps e-mail * addresses legal, only encoding the personal information. * * @param string $text The email addresses to encode. * @param string $charset (optional) The character set of the text. * @param string $defserver (optional) The default domain to append to mailboxes. * * @return String The text, encoded only if it contains non-ascii characters. */function Encodeaddress ($text, $charset = null, $defserver = null) {include_once mail/rfc822.php; $addr _arr = Mail_rfc8 ::p arseaddresslist ($text, $defserver, False, false); $text =; if (Is_array ($addr _arR) {foreach ($addr _arr as $addr) {if (Empty ($addr->personal)) {$personal =;} else {if ((substr ($addr->persona L, 0, 1) = = ") && (substr ($addr->personal,-1) = =")) {$addr->personal = substr ($addr->personal, 1,-1); } $personal = Mime::encode ($addr->personal, $charset); } if (strlen ($text)! = 0) $text. =,; Fixme:dependency on IMAP module $TEXT. = Mime::trimemailaddress (imap_rfc822_write_address ($addr->mailbox, $addr- >host, $personal)); }} return $text; }/** * Decode an RFC 2047-encoded string. * * @param string $string the text to decode. * @return String The decoded text, or the original string if it is not encoded. */function decode ($string) {$pos = Strpos ($string, =?); if ($pos = = = False) {return $string;}//Take out any spaces b Etween multiple encoded words $string = Preg_replace (|? =s=?|,? = =?, $string); $preceding = substr ($string, 0, $pos); Save any preceding text $search = substr ($string, $pos + 2, 75); The MIME header SPEC says the longest a single encoded word can be $d 1 = Strpos ($search,?); if (!is_int ($d 1)) {return $string;} $charset = substr ($string, $pos + 2, $d 1); $search = substr ($search, $d 1 + 1); $d 2 = Strpos ($search,?); if (!is_int ($d 2)) {return $string;} $encoding = substr ($search, 0, $d 2); $search = substr ($search, $d 2+1); $end = Strpos ($search,? =); if (!is_int ($end)) {return $string;} $encoded _text = substr ($search, 0, $end); $rest = substr ($string, (strlen ($preceding. $charset. $encoding. $encoded _text) + 6)); Switch ($encoding) {case Q:case Q: $encoded _text = Str_replace (_,%20, $encoded _text); $encoded _text = str_replace (=,%, $encoded _text); $decoded = UrlDecode ($encoded _text); /* Convert Cyrillic character Sets. */if (STRISTR ($GLOBALS [Registry]->getcharset (), windows-1251)) {if (Stristr ($charset, koi8-r)) {$decoded = Convert_ Cyr_string ($decoded, K, W); }} if (Stristr ($GLOBALS [Registry]->getcharset (), koi8-r)) {if (Stristr ($charset, windows-1251)) {$decoded = Convert_cyr_string ($decoded, W, K); }} break; Case B:case B: $decoded = UrlDecode (Base64_decode ($encoded _text)); if (Stristr ($GLOBALS [Registry]->getcharset (), windows-1251)) {if (Stristr ($charset, koi8-r)) {$decoded = Convert_ Cyr_string ($decoded, K, W); }} if (Stristr ($GLOBALS [Registry]->getcharset (), koi8-r)) {if (Stristr ($charset, windows-1251)) {$decoded = Convert_ Cyr_string ($decoded, W, K); }} break; Default: $decoded = =?. $charset. ? . $encoding. ? . $encoded _text. ?=; Break } return $preceding. $decoded. MIME::d ecode ($rest); }/** * If an email address have no personal information, get rid of any * angle brackets (<>) around it. * * @param string $address the address to trim. * @return string The trimmed address. */function Trimemailaddress ($address) {$address = Trim ($address), if (substr ($address, 0, 1) = = <) && (subst R ($address,-1) = = >) {$address = substr ($address, 1,-1);} return $address; }}?>
http://www.bkjia.com/PHPjc/531855.html www.bkjia.com true http://www.bkjia.com/PHPjc/531855.html techarticle text, Text = TypeText, Typemultipart = multipart, multipart = typemultipart, typemessage = message, ME Ssage = typemessage, typeapplication = Application, application = TypeA ...