Changeset 8d4bcda in github
- Timestamp:
- Aug 18, 2006 8:48:33 AM (7 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- 9960666
- Parents:
- 89406f3
- Location:
- program
- Files:
-
- 9 edited
-
include/main.inc (modified) (1 diff)
-
include/rcube_imap.inc (modified) (12 diffs)
-
include/rcube_shared.inc (modified) (2 diffs)
-
steps/mail/compose.inc (modified) (24 diffs)
-
steps/mail/func.inc (modified) (20 diffs)
-
steps/mail/get.inc (modified) (6 diffs)
-
steps/mail/rss.inc (modified) (3 diffs)
-
steps/mail/show.inc (modified) (5 diffs)
-
steps/mail/viewsource.inc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/include/main.inc
rc39957c r8d4bcda 1789 1789 function console($msg) 1790 1790 { 1791 if ( is_string($msg))1791 if (!is_string($msg)) 1792 1792 $msg = var_export($msg, true); 1793 1793 -
program/include/rcube_imap.inc
r4d4264c r8d4bcda 710 710 711 711 712 // return sorted array of message UIDs 712 /** 713 * Return sorted array of message UIDs 714 * 715 * @param string Mailbox to get index from 716 * @param string Sort column 717 * @param string Sort order [ASC, DESC] 718 * @return array Indexed array with message ids 719 */ 713 720 function message_index($mbox_name='', $sort_field=NULL, $sort_order=NULL) 714 721 { … … 781 788 if ($cache_index[$id] == $uid) 782 789 { 783 // console("$id / $uid: OK");784 790 unset($cache_index[$id]); 785 791 continue; … … 789 795 if (in_array((string)$uid, $cache_index, TRUE)) 790 796 { 791 // console("$id / $uid: Moved");792 797 unset($cache_index[$id]); 793 798 } … … 796 801 if (isset($cache_index[$id])) 797 802 { 798 // console("$id / $uid: Delete");799 803 $this->remove_message_cache($cache_key, $id); 800 804 unset($cache_index[$id]); 801 805 } 802 806 803 804 // console("$id / $uid: Add");805 807 806 808 // fetch complete headers and add to cache … … 868 870 869 871 872 /** 873 * Return message headers object of a specific message 874 * 875 * @param int Message ID 876 * @param string Mailbox to read from 877 * @param boolean True if $id is the message UID 878 * @return object Message headers representation 879 */ 870 880 function get_headers($id, $mbox_name=NULL, $is_uid=TRUE) 871 881 { 872 882 $mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox; 883 $uid = $is_uid ? $id : $this->_id2uid($id); 873 884 874 885 // get cached headers 875 if ($ is_uid && ($headers = $this->get_cached_message($mailbox.'.msg', $id)))886 if ($uid && ($headers = $this->get_cached_message($mailbox.'.msg', $uid))) 876 887 return $headers; 877 888 … … 887 898 888 899 889 function get_body($uid, $part=1) 900 /** 901 * Fetch body structure from the IMAP server and build 902 * an object structure similar to the one generated by PEAR::Mail_mimeDecode 903 * 904 * @param Int Message UID to fetch 905 * @return object Standard object tree or False on failure 906 */ 907 function &get_structure($uid) 890 908 { 891 909 if (!($msg_id = $this->_uid2id($uid))) … … 894 912 $structure_str = iil_C_FetchStructureString($this->conn, $this->mailbox, $msg_id); 895 913 $structure = iml_GetRawStructureArray($structure_str); 896 $body = iil_C_FetchPartBody($this->conn, $this->mailbox, $msg_id, $part); 897 898 $encoding = iml_GetPartEncodingCode($structure, $part); 899 900 if ($encoding==3) $body = $this->mime_decode($body, 'base64'); 901 else if ($encoding==4) $body = $this->mime_decode($body, 'quoted-printable'); 902 903 return $body; 904 } 905 906 907 function get_raw_body($uid) 914 $struct = false; 915 916 // parse structure and add headers 917 if (!empty($structure)) 918 { 919 $this->_msg_id = $msg_id; 920 $headers = $this->get_headers($msg_id, NULL, FALSE); 921 922 $struct = &$this->_structure_part($structure); 923 $struct->headers = get_object_vars($headers); 924 925 // don't trust given content-type 926 if (empty($struct->parts)) 927 { 928 $struct->mime_id = '1'; 929 $struct->mimetype = strtolower($struct->headers['ctype']); 930 list($struct->ctype_primary, $struct->ctype_secondary) = explode('/', $struct->mimetype); 931 } 932 } 933 934 return $struct; 935 } 936 937 938 /** 939 * Build message part object 940 * 941 * @access private 942 */ 943 function &_structure_part($part, $count=0, $parent='') 944 { 945 $struct = new rcube_message_part; 946 $struct->mime_id = empty($parent) ? (string)$count : "$parent.$count"; 947 948 // multipart 949 if (is_array($part[0])) 950 { 951 $struct->ctype_primary = 'multipart'; 952 953 // find first non-array entry 954 for ($i=1; count($part); $i++) 955 if (!is_array($part[$i])) 956 { 957 $struct->ctype_secondary = strtolower($part[$i]); 958 break; 959 } 960 961 $struct->mimetype = 'multipart/'.$struct->ctype_secondary; 962 963 $struct->parts = array(); 964 for ($i=0, $count=0; $i<count($part); $i++) 965 if (is_array($part[$i]) && count($part[$i]) > 5) 966 $struct->parts[] = $this->_structure_part($part[$i], ++$count, $struct->mime_id); 967 968 return $struct; 969 } 970 971 972 // regular part 973 $struct->ctype_primary = strtolower($part[0]); 974 $struct->ctype_secondary = strtolower($part[1]); 975 $struct->mimetype = $struct->ctype_primary.'/'.$struct->ctype_secondary; 976 977 // read content type parameters 978 if (is_array($part[2])) 979 { 980 $struct->ctype_parameters = array(); 981 for ($i=0; $i<count($part[2]); $i+=2) 982 $struct->ctype_parameters[strtolower($part[2][$i])] = $part[2][$i+1]; 983 984 if (isset($struct->ctype_parameters['charset'])) 985 $struct->charset = $struct->ctype_parameters['charset']; 986 } 987 988 // read content encoding 989 if (!empty($part[5]) && $part[5]!='NIL') 990 { 991 $struct->encoding = strtolower($part[5]); 992 $struct->headers['content-transfer-encoding'] = $struct->encoding; 993 } 994 995 // get part size 996 if (!empty($part[6]) && $part[6]!='NIL') 997 $struct->size = intval($part[6]); 998 999 // read part disposition 1000 $di = count($part) - 3; 1001 if (is_array($part[$di])) 1002 { 1003 $struct->disposition = strtolower($part[$di][0]); 1004 1005 if (is_array($part[$di][1])) 1006 for ($n=0; $n<count($part[$di][1]); $n+=2) 1007 $struct->d_parameters[strtolower($part[$di][1][$n])] = $part[$di][1][$n+1]; 1008 } 1009 1010 // get child parts 1011 if (is_array($part[8]) && $di != 8) 1012 { 1013 $struct->parts = array(); 1014 for ($i=0, $count=0; $i<count($part[8]); $i++) 1015 if (is_array($part[8][$i]) && count($part[8][$i]) > 5) 1016 $struct->parts[] = $this->_structure_part($part[8][$i], ++$count, $struct->mime_id); 1017 } 1018 1019 // get part ID 1020 if (!empty($part[3]) && $part[3]!='NIL') 1021 { 1022 $struct->content_id = $part[3]; 1023 $struct->headers['content-id'] = $part[3]; 1024 1025 if (empty($struct->disposition)) 1026 $struct->disposition = 'inline'; 1027 } 1028 1029 // fetch message headers if message/rfc822 1030 if ($struct->ctype_primary=='message') 1031 { 1032 $headers = iil_C_FetchPartBody($this->conn, $this->mailbox, $this->_msg_id, $struct->mime_id.'.HEADER'); 1033 $struct->headers = $this->_parse_headers($headers); 1034 } 1035 1036 return $struct; 1037 } 1038 1039 1040 /** 1041 * Return a flat array with references to all parts, indexed by part numbmers 1042 * 1043 * @param object Message body structure 1044 * @return Array with part number -> object pairs 1045 */ 1046 function get_mime_numbers(&$structure) 1047 { 1048 $a_parts = array(); 1049 $this->_get_part_numbers($structure, $a_parts); 1050 return $a_parts; 1051 } 1052 1053 1054 /** 1055 * Helper method for recursive calls 1056 * 1057 * @access 1058 */ 1059 function _get_part_numbers(&$part, &$a_parts) 1060 { 1061 if ($part->mime_id) 1062 $a_parts[$part->mime_id] = &$part; 1063 1064 if (is_array($part->parts)) 1065 for ($i=0; $i<count($part->parts); $i++) 1066 $this->_get_part_numbers($part->parts[$i], &$a_parts); 1067 } 1068 1069 1070 /** 1071 * Fetch message body of a specific message from the server 1072 * 1073 * @param int Message UID 1074 * @param string Part number 1075 * @param object Part object created by get_structure() 1076 * @param mixed True to print part, ressource to write part contents in 1077 * @return Message/part body if not printed 1078 */ 1079 function &get_message_part($uid, $part=1, $o_part=NULL, $print=NULL) 908 1080 { 909 1081 if (!($msg_id = $this->_uid2id($uid))) 910 1082 return FALSE; 1083 1084 // get part encoding if not provided 1085 if (!is_object($o_part)) 1086 { 1087 $structure_str = iil_C_FetchStructureString($this->conn, $this->mailbox, $msg_id); 1088 $structure = iml_GetRawStructureArray($structure_str); 1089 $part_type = iml_GetPartTypeCode($structure, $part); 1090 $o_part = new rcube_message_part; 1091 $o_part->ctype_primary = $part_type==0 ? 'text' : ($part_type==2 ? 'message' : 'other'); 1092 $o_part->encoding = strtolower(iml_GetPartEncodingString($structure, $part)); 1093 $o_part->charset = iml_GetPartCharset($structure, $part); 1094 } 1095 1096 // TODO: Add caching for message parts 1097 1098 if ($print) 1099 { 1100 iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, $part, ($o_part->encoding=='base64'?3:2)); 1101 $body = TRUE; 1102 } 1103 else 1104 { 1105 $body = iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, $part, 1); 1106 1107 // decode part body 1108 if ($o_part->encoding=='base64' || $o_part->encoding=='quoted-printable') 1109 $body = $this->mime_decode($body, $o_part->encoding); 1110 1111 // convert charset (if text or message part) 1112 if (!empty($o_part->charset) && ($o_part->ctype_primary=='text' || $o_part->ctype_primary=='message') && !stristr($body, 'charset=')) 1113 $body = rcube_charset_convert($body, $o_part->charset); 1114 } 1115 1116 return $body; 1117 } 1118 1119 1120 /** 1121 * Fetch message body of a specific message from the server 1122 * 1123 * @param int Message UID 1124 * @return Message/part body 1125 * @see ::get_message_part() 1126 */ 1127 function &get_body($uid, $part=1) 1128 { 1129 return $this->get_message_part($uid, $part); 1130 } 1131 1132 1133 /** 1134 * Returns the whole message source as string 1135 * 1136 * @param int Message UID 1137 * @return Message source string 1138 */ 1139 function &get_raw_body($uid) 1140 { 1141 if (!($msg_id = $this->_uid2id($uid))) 1142 return FALSE; 911 1143 912 1144 $body = iil_C_FetchPartHeader($this->conn, $this->mailbox, $msg_id, NULL); … … 915 1147 return $body; 916 1148 } 917 918 919 // set message flag to one or several messages 920 // possible flags are: SEEN, UNDELETED, DELETED, RECENT, ANSWERED, DRAFT 1149 1150 1151 /** 1152 * Sends the whole message source to stdout 1153 * 1154 * @param int Message UID 1155 */ 1156 function print_raw_body($uid) 1157 { 1158 if (!($msg_id = $this->_uid2id($uid))) 1159 return FALSE; 1160 1161 print iil_C_FetchPartHeader($this->conn, $this->mailbox, $msg_id, NULL); 1162 flush(); 1163 iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, NULL, 2); 1164 } 1165 1166 1167 /** 1168 * Set message flag to one or several messages 1169 * 1170 * @param mixed Message UIDs as array or as comma-separated string 1171 * @param string Flag to set: SEEN, UNDELETED, DELETED, RECENT, ANSWERED, DRAFT 1172 * @return True on success, False on failure 1173 */ 921 1174 function set_flag($uids, $flag) 922 1175 { … … 1590 1843 1591 1844 1592 function get_cached_message($key, $uid, $body=FALSE)1845 function &get_cached_message($key, $uid, $body=FALSE) 1593 1846 { 1594 1847 if (!$this->caching_enabled) … … 2049 2302 2050 2303 2304 // split RFC822 header string into an associative array 2305 function _parse_headers($headers) 2306 { 2307 $a_headers = array(); 2308 $lines = explode("\n", $headers); 2309 $c = count($lines); 2310 for ($i=0; $i<$c; $i++) 2311 { 2312 if ($p = strpos($lines[$i], ': ')) 2313 { 2314 $field = strtolower(substr($lines[$i], 0, $p)); 2315 $value = trim(substr($lines[$i], $p+1)); 2316 if (!empty($value)) 2317 $a_headers[$field] = $value; 2318 } 2319 } 2320 2321 return $a_headers; 2322 } 2323 2324 2051 2325 function _parse_address_list($str) 2052 2326 { … … 2093 2367 } 2094 2368 2369 2370 /** 2371 * Class representing a message part 2372 */ 2373 class rcube_message_part 2374 { 2375 var $mime_id = ''; 2376 var $ctype_primary = 'text'; 2377 var $ctype_secondary = 'plain'; 2378 var $mimetype = 'text/plain'; 2379 var $disposition = ''; 2380 var $encoding = '8bit'; 2381 var $charset = ''; 2382 var $size = 0; 2383 var $headers = array(); 2384 var $d_parameters = array(); 2385 var $ctype_parameters = array(); 2386 2387 } 2095 2388 2096 2389 … … 2234 2527 } 2235 2528 2529 2236 2530 ?> -
program/include/rcube_shared.inc
r41fa0b9 r8d4bcda 34 34 var $script_tag_file = "<script type=\"text/javascript\" src=\"%s%s\"></script>\n"; 35 35 var $script_tag = "<script type=\"text/javascript\">\n<!--\n%s\n\n//-->\n</script>\n"; 36 var $default_template = "<html>\n< body></body>\n</html>";36 var $default_template = "<html>\n<head><title></title></head>\n<body></body>\n</html>"; 37 37 38 38 var $title = ''; … … 117 117 { 118 118 $output = empty($templ) ? $this->default_template : trim($templ); 119 119 120 120 // set default page title 121 121 if (!strlen($this->title)) -
program/steps/mail/compose.inc
raade7b9 r8d4bcda 20 20 */ 21 21 22 23 22 require_once('Mail/mimeDecode.php'); 23 24 // define constants for message compose mode 25 define('RCUBE_COMPOSE_REPLY', 0x0106); 26 define('RCUBE_COMPOSE_FORWARD', 0x0107); 27 define('RCUBE_COMPOSE_DRAFT', 0x0108); 28 24 29 25 30 // remove an attachment … … 39 44 40 45 $MESSAGE_FORM = NULL; 41 $REPLY_MESSAGE = NULL; 42 $FORWARD_MESSAGE = NULL; 43 $DRAFT_MESSAGE = NULL; 46 $MESSAGE = NULL; 44 47 45 48 // nothing below is called during message composition, only at "new/forward/reply/draft" initialization … … 54 57 55 58 56 if ($_GET['_reply_uid'] || $_GET['_forward_uid'] || $_GET['_draft_uid']) 57 { 58 $msg_uid = ($_GET['_reply_uid'] ? $_GET['_reply_uid'] : ($_GET['_forward_uid'] ? $_GET['_forward_uid'] : $_GET['_draft_uid'])); 59 59 // get reference message and set compose mode 60 if ($msg_uid = get_input_value('_reply_uid', RCUBE_INPUT_GET)) 61 $compose_mode = RCUBE_COMPOSE_REPLY; 62 else if ($msg_uid = get_input_value('_forward_uid', RCUBE_INPUT_GET)) 63 $compose_mode = RCUBE_COMPOSE_FORWARD; 64 else if ($msg_uid = get_input_value('_draft_uid', RCUBE_INPUT_GET)) 65 $compose_mode = RCUBE_COMPOSE_DRAFT; 66 67 68 if (!empty($msg_uid)) 69 { 60 70 // similar as in program/steps/mail/show.inc 61 $MESSAGE = array(); 62 $MESSAGE['headers'] = $IMAP->get_headers($msg_uid); 63 64 $MESSAGE['source'] = rcmail_message_source($msg_uid); 65 66 $mmd = new Mail_mimeDecode($MESSAGE['source']); 67 $MESSAGE['structure'] = $mmd->decode(array('include_bodies' => TRUE, 68 'decode_headers' => TRUE, 69 'decode_bodies' => FALSE)); 70 71 $MESSAGE = array('UID' => $msg_uid); 72 $MESSAGE['headers'] = &$IMAP->get_headers($msg_uid); 73 $MESSAGE['structure'] = &$IMAP->get_structure($msg_uid); 71 74 $MESSAGE['subject'] = $IMAP->decode_header($MESSAGE['headers']->subject); 72 $MESSAGE['parts'] = $mmd->getMimeNumbers($MESSAGE['structure']); 73 74 if ($_GET['_reply_uid']) 75 { 76 $REPLY_MESSAGE = &$MESSAGE; 77 $_SESSION['compose']['reply_uid'] = $_GET['_reply_uid']; 78 $_SESSION['compose']['reply_msgid'] = $REPLY_MESSAGE['headers']->messageID; 79 $_SESSION['compose']['references'] = $REPLY_MESSAGE['headers']->reference; 80 $_SESSION['compose']['references'] .= !empty($REPLY_MESSAGE['headers']->reference) ? ' ' : ''; 81 $_SESSION['compose']['references'] .= $REPLY_MESSAGE['headers']->messageID; 82 83 if ($_GET['_all']) 84 $REPLY_MESSAGE['reply_all'] = 1; 85 86 } 87 else if ($_GET['_forward_uid']) 88 { 89 $FORWARD_MESSAGE = $MESSAGE; 90 $_SESSION['compose']['forward_uid'] = $_GET['_forward_uid']; 91 } 92 else 93 { 94 $DRAFT_MESSAGE = $MESSAGE; 95 $_SESSION['compose']['draft_uid'] = $_GET['_draft_uid']; 75 $MESSAGE['parts'] = $IMAP->get_mime_numbers($MESSAGE['structure']); 76 77 if ($compose_mode == RCUBE_COMPOSE_REPLY) 78 { 79 $_SESSION['compose']['reply_uid'] = $msg_uid; 80 $_SESSION['compose']['reply_msgid'] = $MESSAGE['headers']->messageID; 81 $_SESSION['compose']['references'] = $MESSAGE['headers']->reference; 82 $_SESSION['compose']['references'] .= !empty($MESSAGE['headers']->reference) ? ' ' : ''; 83 $_SESSION['compose']['references'] .= $MESSAGE['headers']->messageID; 84 85 if (!empty($_GET['_all'])) 86 $MESSAGE['reply_all'] = 1; 87 } 88 else if ($compose_mode == RCUBE_COMPOSE_FORWARD) 89 { 90 $_SESSION['compose']['forward_uid'] = $msg_uid; 91 } 92 else if ($compose_mode == RCUBE_COMPOSE_DRAFT) 93 { 94 $_SESSION['compose']['draft_uid'] = $msg_uid; 96 95 } 97 96 … … 103 102 function rcmail_compose_headers($attrib) 104 103 { 105 global $IMAP, $ REPLY_MESSAGE, $DRAFT_MESSAGE, $DB;104 global $IMAP, $MESSAGE, $DB, $compose_mode; 106 105 static $sa_recipients = array(); 107 106 … … 138 137 } 139 138 else if (!empty($_GET['_to'])) 140 $fvalue = $_GET['_to'];139 $fvalue = get_input_value('_to', RCUBE_INPUT_GET); 141 140 142 141 case 'cc': … … 165 164 if ($fname && !empty($_POST[$fname])) 166 165 $fvalue = get_input_value($fname, RCUBE_INPUT_POST, TRUE); 167 else if ($header && is_object($REPLY_MESSAGE['headers'])) 166 167 else if ($header && $compose_mode == RCUBE_COMPOSE_REPLY) 168 168 { 169 169 // get recipent address(es) out of the message headers 170 if ($header=='to' && $REPLY_MESSAGE['headers']->replyto)171 $fvalue = $IMAP->decode_header($ REPLY_MESSAGE['headers']->replyto);172 173 else if ($header=='to' && $REPLY_MESSAGE['headers']->from)174 $fvalue = $IMAP->decode_header($ REPLY_MESSAGE['headers']->from);170 if ($header=='to' && !empty($MESSAGE['headers']->replyto)) 171 $fvalue = $IMAP->decode_header($MESSAGE['headers']->replyto); 172 173 else if ($header=='to' && !empty($MESSAGE['headers']->from)) 174 $fvalue = $IMAP->decode_header($MESSAGE['headers']->from); 175 175 176 176 // add recipent of original message if reply to all 177 else if ($header=='cc' && $REPLY_MESSAGE['reply_all'])177 else if ($header=='cc' && !empty($MESSAGE['reply_all'])) 178 178 { 179 if ($IMAP->decode_header($REPLY_MESSAGE['headers']->to)) 180 $fvalue .= $IMAP->decode_header($REPLY_MESSAGE['headers']->to); 181 182 if ($IMAP->decode_header($REPLY_MESSAGE['headers']->cc)) 183 { 184 if($fvalue) 185 $fvalue .= ', '; 186 187 $fvalue .= $IMAP->decode_header($REPLY_MESSAGE['headers']->cc); 188 } 179 if ($v = $IMAP->decode_header($MESSAGE['headers']->to)) 180 $fvalue .= $v; 181 182 if ($v = $IMAP->decode_header($MESSAGE['headers']->cc)) 183 $fvalue .= (!empty($fvalue) ? ', ' : '') . $v; 189 184 } 190 185 … … 196 191 foreach ($to_addresses as $addr_part) 197 192 { 198 if (!in_array($addr_part['mailto'], $sa_recipients) && (!$ REPLY_MESSAGE['FROM'] || !in_array($addr_part['mailto'], $REPLY_MESSAGE['FROM'])))193 if (!in_array($addr_part['mailto'], $sa_recipients) && (!$MESSAGE['FROM'] || !in_array($addr_part['mailto'], $MESSAGE['FROM']))) 199 194 { 200 195 $fvalue .= (strlen($fvalue) ? ', ':'').$addr_part['string']; … … 204 199 } 205 200 } 206 else if ($header && is_object($DRAFT_MESSAGE['headers']))201 else if ($header && $compose_mode == RCUBE_COMPOSE_DRAFT) 207 202 { 208 203 // get drafted headers 209 if ($header=='to' && $DRAFT_MESSAGE['headers']->to)210 $fvalue = $IMAP->decode_header($ DRAFT_MESSAGE['headers']->to);211 212 if ($header=='cc' && $DRAFT_MESSAGE['headers']->cc)213 $fvalue = $IMAP->decode_header($ DRAFT_MESSAGE['headers']->cc);214 215 if ($header=='bcc' && $DRAFT_MESSAGE['headers']->bcc)216 $fvalue = $IMAP->decode_header($ DRAFT_MESSAGE['headers']->bcc);204 if ($header=='to' && !empty($MESSAGE['headers']->to)) 205 $fvalue = $IMAP->decode_header($MESSAGE['headers']->to); 206 207 if ($header=='cc' && !empty($MESSAGE['headers']->cc)) 208 $fvalue = $IMAP->decode_header($MESSAGE['headers']->cc); 209 210 if ($header=='bcc' && !empty($MESSAGE['headers']->bcc)) 211 $fvalue = $IMAP->decode_header($MESSAGE['headers']->bcc); 217 212 218 213 } … … 242 237 function rcmail_compose_header_from($attrib) 243 238 { 244 global $IMAP, $ REPLY_MESSAGE, $DRAFT_MESSAGE, $DB, $OUTPUT, $JS_OBJECT_NAME;239 global $IMAP, $MESSAGE, $DB, $OUTPUT, $JS_OBJECT_NAME, $compose_mode; 245 240 246 241 // pass the following attributes to the form class … … 252 247 // extract all recipients of the reply-message 253 248 $a_recipients = array(); 254 if ($ REPLY_MESSAGE && is_object($REPLY_MESSAGE['headers']))255 { 256 $ REPLY_MESSAGE['FROM'] = array();257 258 $a_to = $IMAP->decode_address_list($ REPLY_MESSAGE['headers']->to);249 if ($compose_mode == RCUBE_COMPOSE_REPLY && is_object($MESSAGE['headers'])) 250 { 251 $MESSAGE['FROM'] = array(); 252 253 $a_to = $IMAP->decode_address_list($MESSAGE['headers']->to); 259 254 foreach ($a_to as $addr) 260 255 { … … 263 258 } 264 259 265 if (!empty($ REPLY_MESSAGE['headers']->cc))260 if (!empty($MESSAGE['headers']->cc)) 266 261 { 267 $a_cc = $IMAP->decode_address_list($ REPLY_MESSAGE['headers']->cc);262 $a_cc = $IMAP->decode_address_list($MESSAGE['headers']->cc); 268 263 foreach ($a_cc as $addr) 269 264 { … … 302 297 $from_id = $sql_arr['identity_id']; 303 298 304 if ($ REPLY_MESSAGE && is_array($REPLY_MESSAGE['FROM']))305 $ REPLY_MESSAGE['FROM'][] = $sql_arr['email'];306 307 if ( strstr($DRAFT_MESSAGE['headers']->from,$sql_arr['email']))299 if ($compose_mode == RCUBE_COMPOSE_REPLY && is_array($MESSAGE['FROM'])) 300 $MESSAGE['FROM'][] = $sql_arr['email']; 301 302 if ($compose_mode == RCUBE_COMPOSE_DRAFT && strstr($MESSAGE['headers']->from, $sql_arr['email'])) 308 303 $from_id = $sql_arr['identity_id']; 309 304 … … 312 307 // overwrite identity selection with post parameter 313 308 if (isset($_POST['_from'])) 314 $from_id = $_POST['_from'];309 $from_id = get_input_value('_from', RCUBE_INPUT_POST); 315 310 316 311 $out = $select_from->show($from_id); … … 336 331 function rcmail_compose_body($attrib) 337 332 { 338 global $CONFIG, $OUTPUT, $ REPLY_MESSAGE, $FORWARD_MESSAGE, $DRAFT_MESSAGE, $JS_OBJECT_NAME;333 global $CONFIG, $OUTPUT, $MESSAGE, $JS_OBJECT_NAME, $compose_mode; 339 334 340 335 list($form_start, $form_end) = get_form_tags($attrib); … … 354 349 355 350 // compose reply-body 356 else if ( is_array($REPLY_MESSAGE['parts']))357 { 358 $body = rcmail_first_text_part($ REPLY_MESSAGE['parts']);351 else if ($compose_mode == RCUBE_COMPOSE_REPLY) 352 { 353 $body = rcmail_first_text_part($MESSAGE); 359 354 if (strlen($body)) 360 355 $body = rcmail_create_reply_body($body); … … 362 357 363 358 // forward message body inline 364 else if ( is_array($FORWARD_MESSAGE['parts']))365 { 366 $body = rcmail_first_text_part($ FORWARD_MESSAGE['parts']);359 else if ($compose_mode == RCUBE_COMPOSE_FORWARD) 360 { 361 $body = rcmail_first_text_part($MESSAGE); 367 362 if (strlen($body)) 368 363 $body = rcmail_create_forward_body($body); … … 370 365 371 366 // forward message body inline 372 else if ( is_array($DRAFT_MESSAGE['parts']))373 { 374 $body = rcmail_first_text_part($ DRAFT_MESSAGE['parts']);367 else if ($compose_mode == RCUBE_COMPOSE_DRAFT) 368 { 369 $body = rcmail_first_text_part($MESSAGE); 375 370 if (strlen($body)) 376 371 $body = rcmail_create_draft_body($body); … … 379 374 $out = $form_start ? "$form_start\n" : ''; 380 375 381 $saveid = new hiddenfield(array('name' => '_draft_saveid', 'value' => str_replace(array('<','>'),"",$ DRAFT_MESSAGE['headers']->messageID) ));376 $saveid = new hiddenfield(array('name' => '_draft_saveid', 'value' => str_replace(array('<','>'),"",$MESSAGE['headers']->messageID) )); 382 377 $out .= $saveid->show(); 383 378 … … 420 415 function rcmail_create_reply_body($body) 421 416 { 422 global $IMAP, $ REPLY_MESSAGE;417 global $IMAP, $MESSAGE; 423 418 424 419 // soft-wrap message first … … 441 436 // add title line 442 437 $pefix = sprintf("\n\n\nOn %s, %s wrote:\n", 443 $ REPLY_MESSAGE['headers']->date,444 $IMAP->decode_header($ REPLY_MESSAGE['headers']->from));438 $MESSAGE['headers']->date, 439 $IMAP->decode_header($MESSAGE['headers']->from)); 445 440 446 441 … … 458 453 function rcmail_create_forward_body($body) 459 454 { 460 global $IMAP, $ FORWARD_MESSAGE;455 global $IMAP, $MESSAGE; 461 456 462 457 // soft-wrap message first … … 464 459 465 460 $prefix = sprintf("\n\n\n-------- Original Message --------\nSubject: %s\nDate: %s\nFrom: %s\nTo: %s\n\n", 466 $ FORWARD_MESSAGE['subject'],467 $ FORWARD_MESSAGE['headers']->date,468 $IMAP->decode_header($ FORWARD_MESSAGE['headers']->from),469 $IMAP->decode_header($ FORWARD_MESSAGE['headers']->to));470 461 $MESSAGE['subject'], 462 $MESSAGE['headers']->date, 463 $IMAP->decode_header($MESSAGE['headers']->from), 464 $IMAP->decode_header($MESSAGE['headers']->to)); 465 471 466 // add attachments 472 if (!isset($_SESSION['compose']['forward_attachments']) && is_array($FORWARD_MESSAGE['parts']) && sizeof($FORWARD_MESSAGE['parts'])>1) 473 { 474 $temp_dir = rcmail_create_compose_tempdir(); 475 476 if (!is_array($_SESSION['compose']['attachments'])) 477 $_SESSION['compose']['attachments'] = array(); 478 479 foreach ($FORWARD_MESSAGE['parts'] as $part) 467 if (!isset($_SESSION['compose']['forward_attachments']) && 468 is_array($MESSAGE['parts']) && sizeof($MESSAGE['parts'])>1) 469 rcmail_write_compose_attachments($MESSAGE); 470 471 return $prefix.$body; 472 } 473 474 475 function rcmail_create_draft_body($body) 476 { 477 global $IMAP, $MESSAGE; 478 479 // add attachments 480 if (!isset($_SESSION['compose']['forward_attachments']) && 481 is_array($MESSAGE['parts']) && sizeof($MESSAGE['parts'])>1) 482 rcmail_write_compose_attachments($MESSAGE); 483 484 return $body; 485 } 486 487 488 function rcmail_write_compose_attachments(&$message) 489 { 490 global $IMAP; 491 492 $temp_dir = rcmail_create_compose_tempdir(); 493 494 if (!is_array($_SESSION['compose']['attachments'])) 495 $_SESSION['compose']['attachments'] = array(); 496 497 foreach ($message['parts'] as $pid => $part) 498 { 499 if ($part->ctype_primary != 'message' && $part->ctype_primary != 'text' && 500 ($part->disposition=='attachment' || $part->disposition=='inline' || $part->headers['content-id'] || 501 (empty($part->disposition) && ($part->d_parameters['filename'] || $part->ctype_parameters['name'])))) 480 502 { 481 if ($part->disposition=='attachment' || $part->disposition=='inline' || $part->headers['content-id'] ||482 (empty($part->disposition) && ($part->d_parameters['filename'] || $part->ctype_parameters['name'])))503 $tmp_path = tempnam($temp_dir, 'rcmAttmnt'); 504 if ($fp = fopen($tmp_path, 'w')) 483 505 { 484 $tmp_path = tempnam($temp_dir, 'rcmAttmnt'); 485 if ($fp = fopen($tmp_path, 'w')) 486 { 487 fwrite($fp, $IMAP->mime_decode($part->body, $part->headers['content-transfer-encoding'])); 488 fclose($fp); 489 490 if ($part->d_parameters['filename']) 491 $_SESSION['compose']['attachments'][] = array('name' => $part->d_parameters['filename'], 492 'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, 493 'path' => $tmp_path); 494 495 else if ($part->ctype_parameters['name']) 496 $_SESSION['compose']['attachments'][] = array('name' => $part->ctype_parameters['name'], 497 'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, 498 'path' => $tmp_path); 499 500 else if ($part->headers['content-description']) 501 $_SESSION['compose']['attachments'][] = array('name' => $part->headers['content-description'], 502 'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, 503 'path' => $tmp_path); 504 } 505 } 506 } 507 508 $_SESSION['compose']['forward_attachments'] = TRUE; 509 } 510 511 return $prefix.$body; 512 } 513 514 function rcmail_create_draft_body($body) 515 { 516 global $IMAP, $DRAFT_MESSAGE; 517 518 // add attachments 519 if (!isset($_SESSION['compose']['forward_attachments']) && is_array($DRAFT_MESSAGE['parts']) && sizeof($DRAFT_MESSAGE['parts'])>1) 520 { 521 $temp_dir = rcmail_create_compose_tempdir(); 522 523 if (!is_array($_SESSION['compose']['attachments'])) 524 $_SESSION['compose']['attachments'] = array(); 525 526 foreach ($DRAFT_MESSAGE['parts'] as $part) 527 { 528 if ($part->disposition=='attachment' || $part->disposition=='inline' || $part->headers['content-id'] || 529 (empty($part->disposition) && ($part->d_parameters['filename'] || $part->ctype_parameters['name']))) 530 { 531 $tmp_path = tempnam($temp_dir, 'rcmAttmnt'); 532 if ($fp = fopen($tmp_path, 'w')) 533 { 534 fwrite($fp, $IMAP->mime_decode($part->body, $part->headers['content-transfer-encoding'])); 535 fclose($fp); 536 537 if ($part->d_parameters['filename']) 538 $_SESSION['compose']['attachments'][] = array('name' => $part->d_parameters['filename'], 539 'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, 540 'path' => $tmp_path); 541 542 else if ($part->ctype_parameters['name']) 543 $_SESSION['compose']['attachments'][] = array('name' => $part->ctype_parameters['name'], 544 'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, 545 'path' => $tmp_path); 546 547 else if ($part->headers['content-description']) 548 $_SESSION['compose']['attachments'][] = array('name' => $part->headers['content-description'], 549 'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, 550 'path' => $tmp_path); 551 } 506 fwrite($fp, $IMAP->get_message_part($message['UID'], $pid, $part->encoding)); 507 fclose($fp); 508 509 $filename = !empty($part->d_parameters['filename']) ? $part->d_parameters['filename'] : 510 (!empty($part->ctype_parameters['name']) ? $part->ctype_parameters['name'] : 511 (!empty($part->headers['content-description']) ? $part->headers['content-description'] : 'file')); 512 513 $_SESSION['compose']['attachments'][] = array( 514 'name' => rcube_imap::decode_mime_string($filename), 515 'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, 516 'path' => $tmp_path 517 ); 552 518 } 553 519 } 554 555 $_SESSION['compose']['forward_attachments'] = TRUE; 556 } 557 558 return $body; 520 } 521 522 $_SESSION['compose']['forward_attachments'] = TRUE; 559 523 } 560 524 … … 562 526 function rcmail_compose_subject($attrib) 563 527 { 564 global $CONFIG, $ REPLY_MESSAGE, $FORWARD_MESSAGE, $DRAFT_MESSAGE;528 global $CONFIG, $MESSAGE, $compose_mode; 565 529 566 530 list($form_start, $form_end) = get_form_tags($attrib); … … 577 541 578 542 // create a reply-subject 579 else if ( isset($REPLY_MESSAGE['subject']))580 { 581 if (eregi('^re:', $ REPLY_MESSAGE['subject']))582 $subject = $ REPLY_MESSAGE['subject'];543 else if ($compose_mode == RCUBE_COMPOSE_REPLY) 544 { 545 if (eregi('^re:', $MESSAGE['subject'])) 546 $subject = $MESSAGE['subject']; 583 547 else 584 $subject = 'Re: '.$ REPLY_MESSAGE['subject'];548 $subject = 'Re: '.$MESSAGE['subject']; 585 549 } 586 550 587 551 // create a forward-subject 588 else if ( isset($FORWARD_MESSAGE['subject']))589 { 590 if (eregi('^fwd:', $ REPLY_MESSAGE['subject']))591 $subject = $ FORWARD_MESSAGE['subject'];552 else if ($compose_mode == RCUBE_COMPOSE_FORWARD) 553 { 554 if (eregi('^fwd:', $MESSAGE['subject'])) 555 $subject = $MESSAGE['subject']; 592 556 else 593 $subject = 'Fwd: '.$ FORWARD_MESSAGE['subject'];557 $subject = 'Fwd: '.$MESSAGE['subject']; 594 558 } 595 559 596 560 // creeate a draft-subject 597 else if ( isset($DRAFT_MESSAGE['subject']))598 $subject = $ DRAFT_MESSAGE['subject'];561 else if ($compose_mode == RCUBE_COMPOSE_DRAFT) 562 $subject = $MESSAGE['subject']; 599 563 600 564 $out = $form_start ? "$form_start\n" : ''; -
program/steps/mail/func.inc
rc39957c r8d4bcda 428 428 429 429 // set attachment icon 430 if ($attrib['attachmenticon'] && preg_match("/multipart\/ m/i", $header->ctype))430 if ($attrib['attachmenticon'] && preg_match("/multipart\/[mr]/i", $header->ctype)) 431 431 $attach_icon = $attrib['attachmenticon']; 432 432 … … 529 529 { 530 530 if ($col=='from' || $col=='to') 531 $cont = rep_specialchars_output(rcmail_address_string($header->$col, 3) );531 $cont = rep_specialchars_output(rcmail_address_string($header->$col, 3), 'html'); 532 532 else if ($col=='subject') 533 533 $cont = rep_specialchars_output($IMAP->decode_header($header->$col), 'html', 'all'); … … 663 663 664 664 665 function rcmail_print_body($part, $safe=FALSE, $plain=FALSE) // $body, $ctype_primary='text', $ctype_secondary='plain', $encoding='7bit', $safe=FALSE, $plain=FALSE)665 function rcmail_print_body($part, $safe=FALSE, $plain=FALSE) 666 666 { 667 667 global $IMAP, $REMOTE_OBJECTS, $JS_OBJECT_NAME; 668 669 // extract part properties: body, ctype_primary, ctype_secondary, encoding, parameters 670 extract($part); 671 672 $block = $plain ? '%s' : '%s'; //'<div style="display:block;">%s</div>'; 673 $body = $IMAP->mime_decode($body, $encoding); 674 $body = $IMAP->charset_decode($body, $parameters); 675 668 669 $body = is_array($part->replaces) ? strtr($part->body, $part->replaces) : $part->body; 670 676 671 // text/html 677 if ($ ctype_secondary=='html')672 if ($part->ctype_secondary=='html') 678 673 { 679 674 if (!$safe) // remove remote images and scripts … … 708 703 } 709 704 710 return sprintf($block, rep_specialchars_output($body, 'html', '', FALSE));705 return rep_specialchars_output($body, 'html', '', FALSE); 711 706 } 712 707 713 708 // text/enriched 714 if ($ctype_secondary=='enriched') 715 { 716 $body = enriched_to_html($body); 717 return sprintf($block, rep_specialchars_output($body, 'html')); 709 if ($part->ctype_secondary=='enriched') 710 { 711 return rep_specialchars_output(enriched_to_html($body), 'html'); 718 712 } 719 713 else … … 765 759 $body = preg_replace("/##string_replacement\{([0-9]+)\}##/e", "\$replace_strings[\\1]", join("\n", $a_lines)); 766 760 767 return sprintf($block, "<pre>\n".$body."\n</pre>");761 return "<pre>\n".$body."\n</pre>"; 768 762 } 769 763 } … … 780 774 781 775 782 function rcmail_parse_message( $structure, $arg=array(), $recursive=FALSE)776 function rcmail_parse_message(&$structure, $arg=array(), $recursive=FALSE) 783 777 { 784 778 global $IMAP; … … 797 791 // show message headers 798 792 if ($recursive && is_array($structure->headers) && isset($structure->headers['subject'])) 799 $a_return_parts[] = array('type' => 'headers', 800 'headers' => $structure->headers); 793 { 794 $c = new stdClass; 795 $c->type = 'headers'; 796 $c->headers = &$structure->headers; 797 $a_return_parts[] = $c; 798 } 801 799 802 800 // print body if message doesn't have multiple parts 803 801 if ($message_ctype_primary=='text') 804 802 { 805 $a_return_parts[] = array('type' => 'content', 806 'body' => $structure->body, 807 'ctype_primary' => $message_ctype_primary, 808 'ctype_secondary' => $message_ctype_secondary, 809 'parameters' => $structure->ctype_parameters, 810 'encoding' => $structure->headers['content-transfer-encoding']); 803 $structure->type = 'content'; 804 $a_return_parts[] = &$structure; 811 805 } 812 806 … … 843 837 // print html/plain part 844 838 else if ($html_part!==NULL && $prefer_html) 845 $print_part = $structure->parts[$html_part];839 $print_part = &$structure->parts[$html_part]; 846 840 else if ($enriched_part!==NULL) 847 $print_part = $structure->parts[$enriched_part];841 $print_part = &$structure->parts[$enriched_part]; 848 842 else if ($plain_part!==NULL) 849 $print_part = $structure->parts[$plain_part];843 $print_part = &$structure->parts[$plain_part]; 850 844 851 845 // show message body 852 846 if (is_object($print_part)) 853 $a_return_parts[] = array('type' => 'content', 854 'body' => $print_part->body, 855 'ctype_primary' => strtolower($print_part->ctype_primary), 856 'ctype_secondary' => strtolower($print_part->ctype_secondary), 857 'parameters' => $print_part->ctype_parameters, 858 'encoding' => $print_part->headers['content-transfer-encoding']); 847 { 848 $print_part->type = 'content'; 849 $a_return_parts[] = $print_part; 850 } 859 851 // show plaintext warning 860 852 else if ($html_part!==NULL) 861 $a_return_parts[] = array('type' => 'content', 862 'body' => rcube_label('htmlmessage'), 863 'ctype_primary' => 'text', 864 'ctype_secondary' => 'plain'); 853 { 854 $c = new stdClass; 855 $c->type = 'content'; 856 $c->body = rcube_label('htmlmessage'); 857 $c->ctype_primary = 'text'; 858 $c->ctype_secondary = 'plain'; 859 860 $a_return_parts[] = $c; 861 } 865 862 866 863 // add html part as attachment 867 864 if ($html_part!==NULL && $structure->parts[$html_part]!==$print_part) 868 865 { 869 $html_part = $structure->parts[$html_part]; 870 $a_attachments[] = array('filename' => rcube_label('htmlmessage'), 871 'encoding' => $html_part->headers['content-transfer-encoding'], 872 'mimetype' => 'text/html', 873 'part_id' => $html_part->mime_id, 874 'size' => strlen($IMAP->mime_decode($html_part->body, $html_part->headers['content-transfer-encoding']))); 866 $html_part = &$structure->parts[$html_part]; 867 $html_part->filename = rcube_label('htmlmessage'); 868 $html_part->mimetype = 'text/html'; 869 870 $a_attachments[] = $html_part; 875 871 } 876 872 } 877 873 878 874 // message contains multiple parts 879 else if ($message_ctype_primary=='multipart' && is_array($structure->parts)) 880 { 881 foreach ($structure->parts as $mail_part) 882 { 875 else if (is_array($structure->parts) && !empty($structure->parts)) 876 { 877 for ($i=0; $i<count($structure->parts); $i++) 878 { 879 $mail_part = &$structure->parts[$i]; 883 880 $primary_type = strtolower($mail_part->ctype_primary); 884 881 $secondary_type = strtolower($mail_part->ctype_secondary); 885 882 886 883 // multipart/alternative 887 if ($primary_type=='multipart') // && ($secondary_type=='alternative' || $secondary_type=='mixed' || $secondary_type=='related'))884 if ($primary_type=='multipart') 888 885 { 889 886 list($parts, $attachmnts) = rcmail_parse_message($mail_part, $arg, TRUE); … … 897 894 ($primary_type=='message' && $secondary_type=='delivery-status')) 898 895 { 899 $a_return_parts[] = array('type' => 'content', 900 'body' => $mail_part->body, 901 'ctype_primary' => $primary_type, 902 'ctype_secondary' => $secondary_type, 903 'parameters' => $mail_part->ctype_parameters, 904 'encoding' => $mail_part->headers['content-transfer-encoding']); 896 $mail_part->type = 'content'; 897 $a_return_parts[] = $mail_part; 905 898 } 906 899 … … 908 901 else if ($primary_type=='message') 909 902 { 910 /* don't parse headers here; they're parsed within the recursive call to rcmail_parse_message() 911 if ($mail_part->parts[0]->headers) 912 $a_return_parts[] = array('type' => 'headers', 913 'headers' => $mail_part->parts[0]->headers); 914 */ 915 916 list($parts, $attachmnts) = rcmail_parse_message($mail_part->parts[0], $arg, TRUE); 917 903 list($parts, $attachmnts) = rcmail_parse_message($mail_part, $arg, TRUE); 904 918 905 $a_return_parts = array_merge($a_return_parts, $parts); 919 906 $a_attachments = array_merge($a_attachments, $attachmnts); … … 924 911 (empty($mail_part->disposition) && ($mail_part->d_parameters['filename'] || $mail_part->ctype_parameters['name']))) 925 912 { 913 // skip apple ressource files 914 if ($message_ctype_secondary=='appledouble' && $secondary_type=='applefile') 915 continue; 916 917 // part belongs to a related message 926 918 if ($message_ctype_secondary=='related' && $mail_part->headers['content-id']) 927 $sa_inline_objects[] = array('filename' => rcube_imap::decode_mime_string($mail_part->d_parameters['filename']), 928 'mimetype' => strtolower("$primary_type/$secondary_type"), 929 'part_id' => $mail_part->mime_id, 930 'content_id' => preg_replace(array('/^</', '/>$/'), '', $mail_part->headers['content-id'])); 931 932 else if ($mail_part->d_parameters['filename']) 933 $a_attachments[] = array('filename' => rcube_imap::decode_mime_string($mail_part->d_parameters['filename']), 934 'encoding' => strtolower($mail_part->headers['content-transfer-encoding']), 935 'mimetype' => strtolower("$primary_type/$secondary_type"), 936 'part_id' => $mail_part->mime_id, 937 'size' => strlen($IMAP->mime_decode($mail_part->body, $mail_part->headers['content-transfer-encoding'])) /*, 938 'content' => $mail_part->body */); 939 940 else if ($mail_part->ctype_parameters['name']) 941 $a_attachments[] = array('filename' => rcube_imap::decode_mime_string($mail_part->ctype_parameters['name']), 942 'encoding' => strtolower($mail_part->headers['content-transfer-encoding']), 943 'mimetype' => strtolower("$primary_type/$secondary_type"), 944 'part_id' => $mail_part->mime_id, 945 'size' => strlen($IMAP->mime_decode($mail_part->body, $mail_part->headers['content-transfer-encoding'])) /*, 946 'content' => $mail_part->body */); 947 948 else if ($mail_part->headers['content-description']) 949 $a_attachments[] = array('filename' => rcube_imap::decode_mime_string($mail_part->headers['content-description']), 950 'encoding' => strtolower($mail_part->headers['content-transfer-encoding']), 951 'mimetype' => strtolower("$primary_type/$secondary_type"), 952 'part_id' => $mail_part->mime_id, 953 'size' => strlen($IMAP->mime_decode($mail_part->body, $mail_part->headers['content-transfer-encoding'])) /*, 954 'content' => $mail_part->body */); 919 { 920 $mail_part->filename = rcube_imap::decode_mime_string($mail_part->d_parameters['filename']); 921 $mail_part->content_id = preg_replace(array('/^</', '/>$/'), '', $mail_part->headers['content-id']); 922 $sa_inline_objects[] = $mail_part; 923 } 924 // is regular attachment 925 else if (($fname = $mail_part->d_parameters['filename']) || 926 ($fname = $mail_part->ctype_parameters['name']) || 927 ($fname = $mail_part->headers['content-description'])) 928 { 929 $mail_part->filename = rcube_imap::decode_mime_string($fname); 930 $a_attachments[] = $mail_part; 931 } 955 932 } 956 933 } … … 960 937 if ($message_ctype_secondary=='related' && sizeof($sa_inline_objects)) 961 938 { 962 $a_replace_patters = array(); 963 $a_replace_strings = array(); 939 $a_replaces = array(); 964 940 965 941 foreach ($sa_inline_objects as $inline_object) 942 $a_replaces['cid:'.$inline_object->content_id] = sprintf($get_url, $inline_object->mime_id); 943 944 // add replace array to each content part 945 // (will be applied later when part body is available) 946 for ($i=0; $i<count($a_return_parts); $i++) 966 947 { 967 $a_replace_patters[] = 'cid:'.$inline_object['content_id'];968 $a_replace_strings[] = sprintf($get_url, $inline_object['part_id']);948 if ($a_return_parts[$i]->type=='content') 949 $a_return_parts[$i]->replaces = $a_replaces; 969 950 } 970 971 foreach ($a_return_parts as $i => $return_part) 972 { 973 if ($return_part['type']!='content') 974 continue; 975 976 // decode body and replace cid:... 977 $a_return_parts[$i]['body'] = str_replace($a_replace_patters, $a_replace_strings, $IMAP->mime_decode($return_part['body'], $return_part['encoding'])); 978 $a_return_parts[$i]['encoding'] = '7bit'; 979 } 980 } 981 } 982 983 984 // join all parts together 985 //$out .= join($part_delimiter, $a_return_parts); 951 } 952 } 986 953 987 954 return array($a_return_parts, $a_attachments); … … 1047 1014 function rcmail_message_body($attrib) 1048 1015 { 1049 global $CONFIG, $OUTPUT, $MESSAGE, $ GET_URL, $REMOTE_OBJECTS, $JS_OBJECT_NAME;1016 global $CONFIG, $OUTPUT, $MESSAGE, $IMAP, $GET_URL, $REMOTE_OBJECTS, $JS_OBJECT_NAME; 1050 1017 1051 1018 if (!is_array($MESSAGE['parts']) && !$MESSAGE['body']) … … 1069 1036 if (!sizeof($MESSAGE['parts']) && $MESSAGE['headers']->ctype=='multipart/encrypted') 1070 1037 { 1071 $MESSAGE['parts'][0] = array('type' => 'content', 1072 'ctype_primary' => 'text', 1073 'ctype_secondary' => 'plain', 1074 'body' => rcube_label('encryptedmessage')); 1038 $p = new stdClass; 1039 $p->type = 'content'; 1040 $p->ctype_primary = 'text'; 1041 $p->ctype_secondary = 'plain'; 1042 $p->body = rcube_label('encryptedmessage'); 1043 $MESSAGE['parts'][0] = $p; 1075 1044 } 1076 1045 … … 1079 1048 foreach ($MESSAGE['parts'] as $i => $part) 1080 1049 { 1081 if ($part ['type']=='headers')1082 $out .= rcmail_message_headers(sizeof($header_attrib) ? $header_attrib : NULL, $part ['headers']);1083 else if ($part ['type']=='content')1050 if ($part->type=='headers') 1051 $out .= rcmail_message_headers(sizeof($header_attrib) ? $header_attrib : NULL, $part->headers); 1052 else if ($part->type=='content') 1084 1053 { 1085 if (empty($part['parameters']) || empty($part['parameters']['charset'])) 1086 $part['parameters']['charset'] = $MESSAGE['headers']->charset; 1054 if (empty($part->ctype_parameters) || empty($part->ctype_parameters['charset'])) 1055 $$part->ctype_parameters['charset'] = $MESSAGE['headers']->charset; 1056 1057 // fetch part if not available 1058 if (!isset($part->body)) 1059 $part->body = $IMAP->get_message_part($MESSAGE['UID'], $part->mime_id, $part); 1087 1060 1088 // $body = rcmail_print_body($part['body'], $part['ctype_primary'], $part['ctype_secondary'], $part['encoding'], $safe_mode);1089 1061 $body = rcmail_print_body($part, $safe_mode); 1090 1062 $out .= '<div class="message-part">'; 1091 1063 1092 if ($part ['ctype_secondary']!='plain')1064 if ($part->ctype_secondary != 'plain') 1093 1065 $out .= rcmail_mod_html_body($body, $attrib['id']); 1094 1066 else … … 1112 1084 foreach ($MESSAGE['attachments'] as $attach_prop) 1113 1085 { 1114 if (strpos($attach_prop ['mimetype'], 'image/')===0)1086 if (strpos($attach_prop->mimetype, 'image/')===0) 1115 1087 $out .= sprintf("\n<hr />\n<p align=\"center\"><img src=\"%s&_part=%s\" alt=\"%s\" title=\"%s\" /></p>\n", 1116 $GET_URL, $attach_prop ['part_id'],1117 $attach_prop ['filename'],1118 $attach_prop ['filename']);1088 $GET_URL, $attach_prop->mime_id, 1089 $attach_prop->filename, 1090 $attach_prop->filename); 1119 1091 } 1120 1092 } … … 1243 1215 1244 1216 // return first text part of a message 1245 function rcmail_first_text_part($message_parts) 1246 { 1247 if (!is_array($message_parts)) 1217 function rcmail_first_text_part($message_struct) 1218 { 1219 global $IMAP; 1220 1221 if (!is_array($message_struct['parts'])) 1248 1222 return FALSE; 1249 1223 1250 $html_part = NULL; 1224 // check all message parts 1225 foreach ($message_struct['parts'] as $pid => $part) 1226 { 1227 $mimetype = strtolower($part->ctype_primary.'/'.$part->ctype_secondary); 1228 1229 if ($mimetype=='text/plain') 1230 return $IMAP->get_message_part($message_struct['UID'], $pid, $part); 1231 1232 else if ($mimetype=='text/html') 1233 { 1234 $html_part = $IMAP->get_message_part($message_struct['UID'], $pid, $part); 1251 1235 1252 // check all message parts 1253 foreach ($message_parts as $pid => $part) 1254 { 1255 $mimetype = strtolower($part->ctype_primary.'/'.$part->ctype_secondary); 1256 if ($mimetype=='text/plain') 1257 { 1258 $body = rcube_imap::mime_decode($part->body, $part->headers['content-transfer-encoding']); 1259 $body = rcube_imap::charset_decode($body, $part->ctype_parameters); 1260 return $body; 1261 } 1262 else if ($mimetype=='text/html') 1263 { 1264 $html_part = rcube_imap::mime_decode($part->body, $part->headers['content-transfer-encoding']); 1265 $html_part = rcube_imap::charset_decode($html_part, $part->ctype_parameters); 1266 } 1267 } 1268 1269 1270 // convert HTML to plain text 1271 if ($html_part) 1272 { 1273 // remove special chars encoding 1274 $trans = array_flip(get_html_translation_table(HTML_ENTITIES)); 1275 $html_part = strtr($html_part, $trans); 1276 1277 // create instance of html2text class 1278 $txt = new html2text($html_part); 1279 return $txt->get_text(); 1236 // remove special chars encoding 1237 $trans = array_flip(get_html_translation_table(HTML_ENTITIES)); 1238 $html_part = strtr($html_part, $trans); 1239 1240 // create instance of html2text class 1241 $txt = new html2text($html_part); 1242 return $txt->get_text(); 1243 } 1280 1244 } 1281 1245 … … 1285 1249 1286 1250 // get source code of a specific message and cache it 1251 // deprecated 1287 1252 function rcmail_message_source($uid) 1288 1253 { … … 1436 1401 return ''; 1437 1402 1438 $part = $MESSAGE['parts'][$_GET['_part']];1403 $part = &$MESSAGE['parts'][$_GET['_part']]; 1439 1404 1440 1405 $attrib_str = create_attrib_string($attrib, array('id', 'class', 'style', 'cellspacing', 'cellpadding', 'border', 'summary')); … … 1442 1407 1443 1408 $filename = $part->d_parameters['filename'] ? $part->d_parameters['filename'] : $part->ctype_parameters['name']; 1444 $filesize = strlen($IMAP->mime_decode($part->body, $part->headers['content-transfer-encoding']));1409 $filesize = $part->size; 1445 1410 1446 1411 if ($filename) -
program/steps/mail/get.inc
r13c1afb r8d4bcda 38 38 39 39 40 41 40 // similar code as in program/steps/mail/show.inc 42 41 if ($_GET['_uid']) 43 42 { 44 $MESSAGE = array(); 45 $MESSAGE['source'] = rcmail_message_source($_GET['_uid']); 46 47 $mmd = new Mail_mimeDecode($MESSAGE['source']); 48 $MESSAGE['structure'] = $mmd->decode(array('include_bodies' => TRUE, 49 'decode_headers' => FALSE, 50 'decode_bodies' => FALSE)); 51 52 $MESSAGE['parts'] = $mmd->getMimeNumbers($MESSAGE['structure']); 43 $MESSAGE = array('UID' => get_input_value('_uid', RCUBE_INPUT_GET)); 44 $MESSAGE['structure'] = $IMAP->get_structure($MESSAGE['UID']); 45 $MESSAGE['parts'] = $IMAP->get_mime_numbers($MESSAGE['structure']); 53 46 } 54 55 47 56 48 … … 62 54 } 63 55 64 else if ($ _GET['_part'])56 else if ($pid = get_input_value('_part', RCUBE_INPUT_GET)) 65 57 { 66 if ($part = $MESSAGE['parts'][$ _GET['_part']]);58 if ($part = $MESSAGE['parts'][$pid]); 67 59 { 68 60 $ctype_primary = strtolower($part->ctype_primary); … … 71 63 $mimetype = sprintf('%s/%s', $ctype_primary, $ctype_secondary); 72 64 $filename = $part->d_parameters['filename'] ? $part->d_parameters['filename'] : $part->ctype_parameters['name']; 73 74 if ($ctype_primary=='text' && $ctype_secondary=='html')75 {76 list($MESSAGE['parts']) = rcmail_parse_message($part,77 array('safe' => (bool)$_GET['_safe'],78 'prefer_html' => TRUE,79 'get_url' => $GET_URL.'&_part=%s'));80 81 $cont = rcmail_print_body($MESSAGE['parts'][0], (bool)$_GET['_safe']);82 }83 else84 $cont = $IMAP->mime_decode($part->body, $part->headers['content-transfer-encoding']);85 65 86 66 // send correct headers for content type and length … … 98 78 } 99 79 100 header(sprintf('Content-Length: %d', strlen($cont)));101 102 80 // We need to set the following headers to make downloads work using IE in HTTPS mode. 103 81 if (isset($_SERVER['HTTPS'])) … … 108 86 109 87 // deliver part content 110 echo $cont; 88 if ($ctype_primary=='text' && $ctype_secondary=='html') 89 { 90 // get part body if not available 91 if (!$part->body) 92 $part->body = $IMAP->get_message_part($MESSAGE['UID'], $part->mime_id, $part); 93 94 list($MESSAGE['parts']) = rcmail_parse_message($part, 95 array('safe' => (bool)$_GET['_safe'], 96 'prefer_html' => TRUE, 97 'get_url' => $GET_URL.'&_part=%s')); 98 99 print rcmail_print_body($MESSAGE['parts'][0], (bool)$_GET['_safe']); 100 } 101 else 102 { 103 // turn off output buffering and print part content 104 //@ob_end_clean(); 105 $IMAP->get_message_part($MESSAGE['UID'], $part->mime_id, $part->encoding, true); 106 } 107 111 108 exit; 112 109 } … … 128 125 'get_url' => $GET_URL.'&_part=%s')); 129 126 130 if ($MESSAGE['parts'] && $ctype_primary=='multipart') 131 { 132 // reset output page 133 $OUTPUT = new rcube_html_page(); 134 parse_template('messagepart'); 135 exit; 136 } 137 else if ($MESSAGE['parts'][0]) 138 { 139 $part = $MESSAGE['parts'][0]; 140 $cont = rcmail_print_body($part, (bool)$_GET['_safe']); 141 } 142 else 143 $cont = $IMAP->get_body($_GET['_uid']); 127 $cont = "<html>\n<head><title></title>\n</head>\n<body>"; 128 $cont .= rcmail_message_body(array()); 129 $cont .= "\n</body>\n</html>"; 144 130 145 131 $OUTPUT = new rcube_html_page(); 146 132 $OUTPUT->write($cont); 147 133 148 /*149 if ($mimetype=='text/html')150 print $cont;151 else152 {153 print "<html>\n<body>\n";154 print $cont;155 print "\n</body>\n</html>";156 }157 */158 134 exit; 159 135 } -
program/steps/mail/rss.inc
r88375ff r8d4bcda 43 43 $webmail_url .= dirname($_SERVER['SCRIPT_NAME']).'/'; 44 44 45 $ auth_webmail_url = $webmail_url.'?_auth='.$GLOBALS['sess_auth'];45 $webmail_url .= '?_task=mail'; 46 46 47 47 $messagecount_unread = $IMAP->messagecount('INBOX', 'UNSEEN', TRUE); … … 69 69 <docs>http://blogs.law.harvard.edu/tech/rss</docs> 70 70 <description>INBOX contains '.$messagecount.' messages, of which '.$messagecount_unread.' unread</description> 71 <link>'.rss_encode($ auth_webmail_url, 'xml') .'</link>71 <link>'.rss_encode($webmail_url, 'xml') .'</link> 72 72 <title>webmail for '.rss_encode($_SESSION['username'].' @ '.$_SESSION['imap_host']).'</title> 73 73 <generator>'.rss_encode($CONFIG['useragent'], 'xml').' (RSS extension by Sjon Hortensius)</generator> … … 93 93 $item->from = preg_replace('~"?([^"]*)"? <([^>]*)>~', '\2 (\1)', $item->from); 94 94 95 $item->link = $ auth_webmail_url.'&_task=mail&_action=show&_uid='.$item->uid.'&_mbox=INBOX';95 $item->link = $webmail_url.'&_task=mail&_action=show&_uid='.$item->uid.'&_mbox=INBOX'; 96 96 97 97 $item->body = $IMAP->get_body($item->uid); -
program/steps/mail/show.inc
r078adf9 r8d4bcda 28 28 if ($_GET['_uid']) 29 29 { 30 $MESSAGE = array( );31 $MESSAGE['headers'] = $IMAP->get_headers($ _GET['_uid']);32 $MESSAGE['s ource'] = rcmail_message_source($_GET['_uid']);33 30 $MESSAGE = array('UID' => get_input_value('_uid', RCUBE_INPUT_GET)); 31 $MESSAGE['headers'] = $IMAP->get_headers($MESSAGE['UID']); 32 $MESSAGE['structure'] = $IMAP->get_structure($MESSAGE['UID']); 33 34 34 // go back to list if message not found (wrong UID) 35 if (!$MESSAGE['headers'] || !$MESSAGE['s ource'])35 if (!$MESSAGE['headers'] || !$MESSAGE['structure']) 36 36 { 37 37 $_action = 'list'; … … 39 39 } 40 40 41 $mmd = new Mail_mimeDecode($MESSAGE['source']); 42 $MESSAGE['structure'] = $mmd->decode(array('include_bodies' => TRUE, 43 'decode_headers' => FALSE, 44 'decode_bodies' => FALSE)); 45 46 $mmd->getMimeNumbers($MESSAGE['structure']); 47 48 $MESSAGE['subject'] = $IMAP->decode_header($MESSAGE['structure']->headers['subject']); 49 41 $MESSAGE['subject'] = $IMAP->decode_header($MESSAGE['headers']->subject); 42 50 43 if ($MESSAGE['structure']) 51 list($MESSAGE['parts'], $MESSAGE['attachments']) = rcmail_parse_message($MESSAGE['structure'], 52 array('safe' => (bool)$_GET['_safe'], 53 'prefer_html' => $CONFIG['prefer_html'], 54 'get_url' => $GET_URL.'&_part=%s')); 44 list($MESSAGE['parts'], $MESSAGE['attachments']) = rcmail_parse_message( 45 $MESSAGE['structure'], 46 array('safe' => (bool)$_GET['_safe'], 47 'prefer_html' => $CONFIG['prefer_html'], 48 'get_url' => $GET_URL.'&_part=%s') 49 ); 55 50 else 56 $MESSAGE['body'] = $IMAP->get_body($ _GET['_uid']);51 $MESSAGE['body'] = $IMAP->get_body($MESSAGE['UID']); 57 52 58 53 … … 62 57 63 58 // give message uid to the client 64 $javascript = sprintf("%s.set_env('uid', '%s');\n", $JS_OBJECT_NAME, $ _GET['_uid']);59 $javascript = sprintf("%s.set_env('uid', '%s');\n", $JS_OBJECT_NAME, $MESSAGE['UID']); 65 60 $javascript .= sprintf("%s.set_env('safemode', '%b');", $JS_OBJECT_NAME, $_GET['_safe']); 66 61 … … 68 63 // get previous and next message UID 69 64 if (!($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] == 'DESC') && 70 $IMAP->get_capability('sort')) { 71 // Only if we use custom sorting 72 $a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']); 65 $IMAP->get_capability('sort')) 66 { 67 // Only if we use custom sorting 68 $a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']); 73 69 74 $MESSAGE['index'] = array_search((string)$_GET['_uid'], $a_msg_index, TRUE); 75 $prev = isset($a_msg_index[$MESSAGE['index']-1]) ? $a_msg_index[$MESSAGE['index']-1] : -1 ; 76 $next = isset($a_msg_index[$MESSAGE['index']+1]) ? $a_msg_index[$MESSAGE['index']+1] : -1 ; 77 } else { 78 // this assumes that we are sorted by date_DESC 79 $seq = $IMAP->get_id($_GET['_uid']); 80 $prev = $IMAP->get_uid($seq + 1); 81 $next = $IMAP->get_uid($seq - 1); 82 $MESSAGE['index'] = $IMAP->messagecount() - $seq; 83 } 70 $MESSAGE['index'] = array_search((string)$MESSAGE['UID'], $a_msg_index, TRUE); 71 $prev = isset($a_msg_index[$MESSAGE['index']-1]) ? $a_msg_index[$MESSAGE['index']-1] : -1 ; 72 $next = isset($a_msg_index[$MESSAGE['index']+1]) ? $a_msg_index[$MESSAGE['index']+1] : -1 ; 73 } 74 else 75 { 76 // this assumes that we are sorted by date_DESC 77 $seq = $IMAP->get_id($MESSAGE['UID']); 78 $prev = $IMAP->get_uid($seq + 1); 79 $next = $IMAP->get_uid($seq - 1); 80 $MESSAGE['index'] = $IMAP->messagecount() - $seq; 81 } 84 82 85 83 if ($prev > 0) … … 107 105 if ($PRINT_MODE) 108 106 $out .= sprintf('<li>%s (%s)</li>'."\n", 109 $attach_prop ['filename'],110 show_bytes($attach_prop ['size']));107 $attach_prop->filename, 108 show_bytes($attach_prop->size)); 111 109 else 112 110 $out .= sprintf('<li><a href="%s&_part=%s" onclick="return %s.command(\'load-attachment\',{part:\'%s\', mimetype:\'%s\'},this)">%s</a></li>'."\n", 113 111 htmlentities($GET_URL), 114 $attach_prop ['part_id'],112 $attach_prop->mime_id, 115 113 $JS_OBJECT_NAME, 116 $attach_prop ['part_id'],117 $attach_prop ['mimetype'],118 $attach_prop ['filename']);114 $attach_prop->mime_id, 115 $attach_prop->mimetype, 116 $attach_prop->filename); 119 117 } 120 118 -
program/steps/mail/viewsource.inc
r30233b8 r8d4bcda 22 22 23 23 // similar code as in program/steps/mail/get.inc 24 if ($ _GET['_uid'])24 if ($uid = get_input_value('_uid', RCUBE_INPUT_GET)) 25 25 { 26 26 header('Content-Type: text/plain'); 27 print rcmail_message_source($_GET['_uid']); 27 //@ob_end_clean(); 28 $IMAP->print_raw_body($uid); 28 29 } 29 30 else … … 31 32 raise_error(array('code' => 500, 32 33 'type' => 'php', 33 'message' => 'Message UID '.$ _GET['_uid'].' not found'),34 'message' => 'Message UID '.$uid.' not found'), 34 35 TRUE, 35 36 TRUE);
Note: See TracChangeset
for help on using the changeset viewer.
