Źródło:


Komentarze (0)


Ocena:
0

źródło pochodzi od: sympozjon

Opis:
Klasa dekoduje załączniki Mime. Inaczej mówiąc możesz dzięki niej przetwarzać praktycznie wszystkie załączniki.

Język: php



class MimeDecode {
var $attachments;
var $text_version;

# This accepts the body of a message (in Array form, split on n) and the
# MIME encoded boundary.

# This returns a two dimensional array, with the 'ContentType', 'filename',
# 'ContentTypeEncoding' and the attachment 'data' for each indexed
# attachment.
function MimeDecode($body, $boundary) {

$attach_no = -1;

while ( list(, $line) = each($body) ) {

$line = trim($line);

if ( strstr($line, "--$boundary") ) {
$this->attachments['number'] = ++$attach_no;
continue;
}

if ( !$this->attachments[$attach_no]['ContentType'] &&
    preg_match("/^Content-Type: ([w-/]*);?(.*)?/", $line, $matches) ) {
$this->attachments[$attach_no]['ContentType'] = trim($matches[1]);
if ( $matches[2] &&
    preg_match("/name="(.*)"/i", $matches[2],
                $new_match)) {
if (!$this->attachments[$attach_no]['filename'])
$this->attachments[$attach_no ]['filename']=trim($new_match[1]);
}
continue;
}

if ( !$this->attachments[$attach_no]['filename'] &&
    preg_match("/name="(.*)"/i", $line, $matches) ) {
$this->attachments[$attach_no]['filename'] = trim($matches[1]);
continue;
}

if ( !$this->attachments[$attach_no]['ContentTransferEncoding'] &&
    preg_match("/^Content-Transfer-Encoding: (.*)/", $line, $matches) ) {
$this->attachments[$attach_no]['ContentTransferEncoding'] = trim($matches[1]);
continue;
}


if ( !$line && !$this->attachments[$attach_no]['data'] ) {
$data[0] = "";
while ( list (, $line) = each($body) ) {
$line = trim($line);
$line = preg_replace("/< */? *HTML *>/i", "", $line);
if (strstr($line, $boundary)) {
prev($body);
break;
}
array_push($data, $line."n");
}

# Decode attachment data before leaving...
# Base64 encoded messages...
if ( !strcasecmp($this->attachments[$attach_no]['ContentTransferEncoding'], "base64") ) {
$this->attachments[$attach_no]['data'][0] = "";
foreach ($data as $line) array_push($this->attachments[$attach_no]['data'],  base64_decode($line));

# Quoted-Printable encoded messages
} else if ( !strcasecmp($this->attachments[$attach_no]['ContentTransferEncoding'], "quoted-printable") ) {
$this->attachments[$attach_no]['data'][0] = "";
foreach ($data as $line) array_push($this->attachments[$attach_no]['data'],  quoted_printable_decode($line));

# 7 or 8 bit "encoding"
} else if ( !strcasecmp($this->attachments[$attach_no]['ContentTransferEncoding'], "7bit") || !strcasecmp($this->attachments[$attach_no]['ContentTransferEncoding'], "8bit") ) {
$this->attachments[$attach_no]['data'] = $data;

# defualt to just dumping the data
} else {
$this->attachments[$attach_no]['data'] = $data;
}
$data = NULL;
continue;

}

} # end foreach

} # end MimeDecode


}


</body>
</html>
powrót

Tagi do źródła:
Dekodowanie Mime, mail, php


Nikt jeszcze nie skomentował tego źródła.


assembler baza danych bot c crawler delphi html java kontakt box loader mail obsługa sieci obsługa zapyt(..) own os php pop3 porównywanie (..) przeszukiwanie(..) robot sieciowy rozmowa symulator rozm(..) system operacy(..) voteban stop wysyłanie e-m(..) boot dekodowanie mim(..) java juzef kolejny skrypt (..) mysql pobieranie zawa(..) przeglądanie e(..) sdl whois wysyłanie e-ma(..)

Wszystkie...


sources.pl to strona przeznaczona dla programistów, początkujących programistów i zupełnych amatorów programowania. Tu możesz umieścić swój kod, program napisany przez Ciebie, lub po prostu skomentować kod innego programisty.

Szukaj:


Źródeł: 30, oczekujących: 3, odrzuconych: 11

O stronie | kontakt |

Sources.pl

Ilość wejść: dzisiaj - 48 (unikalne: 43), ogółem - 688251 (unikalne: 613202)