Changeset 1897 for trunk/expressoMail1_2/inc/class.imap_functions.inc.php
- Timestamp:
- 12/28/09 13:55:19 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/inc/class.imap_functions.inc.php
r1887 r1897 869 869 $attachments = $att -> get_attachment_info($this->mbox,$msg_number); 870 870 if($attachments['number_attachments'] > 0) { 871 foreach($attachments ['attachment'] as $index => $attachment){ 872 if(strtolower($attachment['type']) == "delivery-status" || 873 strtolower($attachment['type']) == "rfc822" || 874 strtolower($attachment['type']) == "rfc822-headers" || 875 strtolower($attachment['type']) == "plain" 876 ){ 877 $obj = imap_rfc822_parse_headers(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values]); 878 $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>"; 879 $content .= "<br><table style='margin:2px;border:1px solid black;background:#EAEAEA'>"; 880 $content .= "<tr><td><b>".$this->functions->getLang("Subject").":</b></td><td>".$this->decode_string($obj->subject)."</td></tr>"; 881 $content .= "<tr><td><b>".$this->functions->getLang("From").":</b></td><td>".$this->decode_string($obj->from[0]->mailbox."@".$obj->from[0]->host)."</td></tr>"; 882 $content .= "<tr><td><b>".$this->functions->getLang("Date").":</b></td><td>".$obj->date."</td></tr>"; 883 $content .= "<tr><td><b>".$this->functions->getLang("TO").":</b></td><td>".$this->decode_string($obj->to[0]->mailbox."@".$obj->to[0]->host)."</td></tr>"; 884 $content .= !$obj->cc ? "</table><br>" :"<tr><td><b>".$this->functions->getLang("CC").":</b></td><td>".$this->decode_string($obj->cc[0]->mailbox."@".$obj->cc[0]->host)."</td></tr></table><br>"; 871 foreach($attachments ['attachment'] as $index => $attachment) 872 { 873 if ( in_array( strtolower( $attachment[ 'type' ] ), array( 'delivery-status', 'rfc822', 'rfc822-headers', 'plain' ) ) ) 874 { 875 $obj = imap_rfc822_parse_headers( imap_fetchbody( $this -> mbox, $msg_number, $msg_part, FT_UID ), $msg -> encoding[ $msg_number ][ $values ] ); 876 877 $content .= '<hr align="left" width="95%" style="border:1px solid #DCDCDC">'; 878 $content .= '<br><table style="margin:2px;border:1px solid black;background:#EAEAEA">'; 879 880 $content .= '<tr><td><b>' . $this->functions->getLang("Subject") 881 . ':</b></td><td>' .$this->decode_string($obj->subject) . '</td></tr>'; 882 883 $content .= '<tr><td><b>' . $this -> functions -> getLang( 'From' ) . ':</b></td><td>' 884 . $this -> replace_links( $this -> decode_string( $obj -> from[ 0 ] -> mailbox . '@' . $obj -> from[ 0 ] -> host) ) 885 . '</td></tr>'; 886 887 $content .= '<tr><td><b>' . $this->functions->getLang("Date") . ':</b></td><td>' . $obj->date . '</td></tr>'; 888 889 $content .= '<tr><td><b>' . $this -> functions -> getLang( 'TO' ) . ':</b></td><td>' 890 . $this -> replace_links( $this -> decode_string( $obj -> to[ 0 ] -> mailbox . '@' . $obj -> to[ 0 ] -> host ) ) 891 . '</td></tr>'; 892 893 if ( $obj->cc ) 894 $content .= '<tr><td><b>' . $this -> functions -> getLang( 'CC' ) . ':</b></td><td>' 895 . $this -> replace_links( $this -> decode_string( $obj -> cc[ 0 ] -> mailbox . '@' . $obj -> cc[ 0 ] -> host ) ) 896 . '</td></tr>'; 897 898 $content .= '</table><br>'; 899 885 900 $content .= $this->decodeBody( 886 901 imap_fetchbody( … … 1132 1147 } 1133 1148 1134 function replace_links($body) { 1135 $matches = array(); 1149 function replace_links( $body ) 1150 { 1151 $matches = array( ); 1136 1152 // Verify exception. 1137 @preg_match("/<a href=\"notes:\/\/\//",$body,$matches); 1138 // If there is no exception,then open the link in new window. 1139 if(count($matches)) 1153 @preg_match( "/<a href=\"notes:\/\/\//", $body, $matches ); 1154 1155 // If there is no exception, then open the link in new window. 1156 if ( count( $matches ) ) 1140 1157 return $body; 1141 1158 1142 / * Replace links tags <a href="" ></a> to links with target=_blank */1159 // All links should be moderated and they should only have the attribute 'target="blank"'. 1143 1160 $pattern = '/<a[^>]+href="([^>"]+)"[^>]*>(.*)<\/a>/im'; 1144 1161 $replacement = '<a href="$1" target="_blank">$2</a>'; 1145 $body = preg_replace( $pattern, $replacement, $body);1146 1147 / *Replace websites that does NOT begin with href=" to links */1148 $pattern = '/( [^h][^r][^e][^f][^=][^"])((https?:\/\/)[A-Za-z0-9\.~?\/_=&#;\-:]*)/m';1149 $replacement = '$1<a href=" $2" target="_blank">$2</a>';1150 $body = preg_replace( $pattern, $replacement, $body);1151 1152 / *Transform email address in new_message_to*/1153 $pattern = '/([A-Za-z0-9\.~?\/_=#\-]*@[A-Za-z0-9\.~?\/_=#\-]*)/im';1154 $replacement = ' <a href="javascript:new_message_to(\'$1\')">$1</a>';1155 $body = preg_replace( $pattern, $replacement, $body);1156 1157 / *Subs. email links to expresso*/1158 $ body = mb_ereg_replace("<a[^>]*href=[\'\"]mailto:([^\"\']+)[\'\"]>([^<]+)</a>",1159 "<a href=\"javascript:new_message_to('\\1')\">\\2</a>",$body);1160 1162 $body = preg_replace( $pattern, $replacement, $body ); 1163 1164 // Url found in the text and which is not a link yet should be replaced by one. 1165 $pattern = '/(^|\w>|[ \(\[])((http(s)?:\/\/)?([\w\d_\-@]{2,}(\.[\w\d~?\/_=&#;\-:@$]+)+))/im'; 1166 $replacement = '$1<a href="http$4://$5" target="_blank">$2</a>'; 1167 $body = preg_replace( $pattern, $replacement, $body ); 1168 1169 // E-mail address in the text should create a new e-mail on ExpressoMail 1170 $pattern = '/( |<|<|>)([A-Za-z0-9\.~?\/_=#\-]*@[A-Za-z0-9\.~?\/_=#\-]*)( |>|>|<)/im'; 1171 $replacement = '$1<a href="javascript:new_message_to(\'$2\')">$2</a>$3'; 1172 $body = preg_replace( $pattern, $replacement, $body ); 1173 1174 // If there is an link with a "mailto:" in href attribute, it will changed to create a new e-mail on ExpressoMail. 1175 $pattern = '/<a[^>]+href=["\']mailto:([^"]+)["\'][^>]*>([^<]+)<\/a>/im'; 1176 $replacement = '<a href="javascript:new_message_to(\'$1\')">$2</a>'; 1177 $body = preg_replace( $pattern, $replacement, $body ); 1161 1178 1162 1179 return $body;
Note: See TracChangeset
for help on using the changeset viewer.