aceb0d5c |
1 | <? |
2 | /** mime.php |
3 | ** |
4 | ** This contains the functions necessary to detect and decode MIME messages. |
5 | **/ |
6 | |
7 | |
8 | function decodeMime($body, $bound, $type0, $type1) { |
9 | if ($type0 == "multipart") { |
10 | if ($body[0] == "") |
11 | $i = 1; |
12 | else |
13 | $i = 0; |
14 | |
15 | $bound = trim($bound); |
16 | $bound = "--$bound"; |
17 | while ($i < count($body)) { |
18 | if (trim($body[$i]) == $bound) { |
19 | $j = $i + 1; |
20 | $p = 0; |
21 | |
22 | while (substr(trim($body[$j]), 0, strlen($bound)) != $bound) { |
23 | $entity[$p] = $body[$j]; |
24 | $j++; |
25 | $p++; |
26 | } |
27 | fetchEntityHeader($imapConnection, $entity, $ent_type0, $ent_type1, $ent_bound); |
28 | $entity = decodeMime($entity, $ent_bound, $ent_type0, $ent_type1); |
29 | |
30 | $q = count($full_message); |
31 | $full_message[$q] = $entity; |
32 | } |
33 | $i++; |
34 | } |
35 | } else if ($type0 == "text") { |
36 | $entity_msg["TYPE0"] = "text"; |
37 | if ($type1 == "plain") { |
38 | $entity_msg["TYPE1"] = "plain"; |
39 | for ($p = 0;$p < count($body);$p++) { |
40 | $entity_msg["BODY"][$p] = parsePlainTextMessage($body[$p]); |
41 | } |
42 | |
43 | } else if ($type1 == "html") { |
44 | $entity_msg["TYPE1"] = "html"; |
45 | $entity_msg["BODY"] = $body; |
46 | } |
47 | $full_message[0] = $entity_msg; |
48 | } |
49 | |
50 | return $full_message; |
51 | } |
52 | ?> |