Changeset 1472
- Timestamp:
- 09/30/09 15:18:10 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/inc/class.imap_functions.inc.php
r1467 r1472 8 8 { 9 9 var $public_functions = array 10 ( 10 ( 11 11 'get_range_msgs' => True, 12 12 'get_info_msg' => True, … … 31 31 $this->imap_port = $_SESSION['phpgw_info']['expressomail']['email_server']['imapPort']; 32 32 $this->imap_delimiter = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDelimiter']; 33 $this->functions = new functions(); 33 $this->functions = new functions(); 34 34 $this->has_cid = false; 35 35 36 36 if ($_SESSION['phpgw_info']['expressomail']['email_server']['imapTLSEncryption'] == 'yes') 37 37 { … … 66 66 } 67 67 // This condition verifies if SESSION is expired. 68 elseif(!count($_SESSION)) 68 elseif(!count($_SESSION)) 69 69 return "nosession"; 70 70 71 71 return $error; 72 72 } 73 73 74 74 function get_range_msgs2($params) 75 75 { … … 77 77 $msg_range_begin = $params['msg_range_begin']; 78 78 $msg_range_end = $params['msg_range_end']; 79 $sort_box_type = $params['sort_box_type']; 79 $sort_box_type = $params['sort_box_type']; 80 80 $sort_box_reverse = $params['sort_box_reverse']; 81 81 $search_box_type = $params['search_box_type'] != "ALL" && $params['search_box_type'] != "" ? $params['search_box_type'] : false; 82 82 $sort_array_msg = $this-> get_msgs($folder, $sort_box_type, $search_box_type, $sort_box_reverse,$msg_range_begin,$msg_range_end); 83 83 84 84 $return = array(); 85 85 $i = 0; 86 86 $num_msgs = imap_num_msg($this->mbox); 87 87 if(is_array($sort_array_msg)){ 88 foreach($sort_array_msg as $msg_number => $value) 88 foreach($sort_array_msg as $msg_number => $value) 89 89 { 90 90 $temp = $this->get_info_head_msg($msg_number); … … 108 108 109 109 110 /*Como eu preciso do atributo Importance para saber se o email é 110 /*Como eu preciso do atributo Importance para saber se o email é 111 111 * importante ou não, uso abaixo a função imap_fetchheader e busco 112 112 * o atributo importance nela. Isso faz com que eu acesse o cabeçalho … … 184 184 185 185 function decode_string($string) 186 { 187 186 { 187 188 188 if ((strpos(strtolower($string), '=?iso-8859-1') !== false) || (strpos(strtolower($string), '=?windows-1252') !== false)) 189 189 { … … 191 191 foreach ($tmp as $tmp1) 192 192 $return .= $this->htmlspecialchars_encode($tmp1->text); 193 193 194 194 return $return; 195 195 } … … 227 227 if(!$this->mbox) 228 228 $this->mbox = $this->open_mbox(); 229 229 230 230 if( preg_match('/local_/',$params["folder"]) ) 231 231 { … … 239 239 $errors = array(); 240 240 $invalid_format = false; 241 $filename = $params['FILES'][0]['name']; 241 $filename = $params['FILES'][0]['name']; 242 242 $params["folder"] = mb_convert_encoding($params["folder"], "UTF7-IMAP","ISO_8859-1"); 243 243 $quota = imap_get_quotaroot($this->mbox, $params["folder"]); … … 323 323 $return["status"] = true; 324 324 $header = ""; 325 325 326 326 $headertemp = explode("\n",imap_fetchheader($this->mbox, imap_msgno($this->mbox, $params["msg_num"]))); 327 327 foreach($headertemp as $head) {//Se eu colocar todo o header do email dá pau no append, então procuro apenas o que interessa. 328 328 $head1 = explode(":",$head); 329 if ( (strtoupper($head1[0]) == "TO") || 330 (strtoupper($head1[0]) == "FROM") || 329 if ( (strtoupper($head1[0]) == "TO") || 330 (strtoupper($head1[0]) == "FROM") || 331 331 (strtoupper($head1[0]) == "SUBJECT") || 332 332 (strtoupper($head1[0]) == "DATE") ) 333 333 $header .= $head."\r\n"; 334 334 } 335 335 336 336 $msg = &new message_components($this->mbox); 337 $msg->fetch_structure($params["msg_num"]);/* O fetchbody tava trazendo o email com problemas na acentuação. 338 Então uso essa classe para verificar a codificação e o charset, 337 $msg->fetch_structure($params["msg_num"]);/* O fetchbody tava trazendo o email com problemas na acentuação. 338 Então uso essa classe para verificar a codificação e o charset, 339 339 para que o método decodeBody do expresso possa trazer tudo certinho*/ 340 340 341 341 $status = imap_append($this->mbox, 342 342 "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$params["folder"], … … 346 346 imap_fetchbody($this->mbox,imap_msgno($this->mbox, $params["msg_num"]),"1"), 347 347 $msg->encoding[$params["msg_num"]][0], $msg->charset[$params["msg_num"]][0] 348 ) 348 ) 349 349 ), "\\Seen"); //Append do novo email, só com header e conteúdo sem anexos. 350 350 351 351 if(!$status) 352 352 { … … 357 357 { 358 358 $status = imap_status($this->mbox, "{".$this->imap_server.":".$this->imap_port."}".$params['folder'], SA_UIDNEXT); 359 $return['msg_no'] = $status->uidnext - 1; 359 $return['msg_no'] = $status->uidnext - 1; 360 360 imap_delete($this->mbox, imap_msgno($this->mbox, $params["msg_num"])); 361 361 imap_expunge($this->mbox); 362 362 } 363 363 364 364 return $return; 365 365 366 366 } 367 367 368 368 /** 369 * 370 * @return 369 * 370 * @return 371 371 * @param $params Object 372 372 */ … … 395 395 $this->mbox=false; 396 396 array_push($return,serialize($msg_info)); 397 397 398 398 if($msg_info['Unseen'] == "U" || $msg_info['Recent'] == "N"){ 399 array_push($unseen_msgs,$msg_number); 400 } 401 } 399 array_push($unseen_msgs,$msg_number); 400 } 401 } 402 402 if($unseen_msgs){ 403 403 $msgs_list = implode(",",$unseen_msgs); 404 404 $array_msgs = array('folder' => $new_params["msg_folder"], "msgs_to_set" => $msgs_list, "flag" => "unseen"); 405 $this->set_messages_flag($array_msgs); 406 } 407 405 $this->set_messages_flag($array_msgs); 406 } 407 408 408 return $return; 409 409 } … … 414 414 $msg_number = $params['msg_number']; 415 415 $msg_folder = $params['msg_folder']; 416 416 417 417 if(!$this->mbox || !is_resource($this->mbox)) 418 $this->mbox = $this->open_mbox($msg_folder); 419 418 $this->mbox = $this->open_mbox($msg_folder); 419 420 420 $header = $this->get_header($msg_number); 421 421 if (!$header) { 422 $return['status_get_msg_info'] = "false"; 422 $return['status_get_msg_info'] = "false"; 423 423 return $return; 424 424 } 425 425 426 426 $header_ = imap_fetchheader($this->mbox, $msg_number, FT_UID); 427 427 428 428 $return_get_body = $this->get_body_msg($msg_number, $msg_folder); 429 429 430 430 //Substituição de links em email para abrir no próprio expresso 431 431 $body = mb_ereg_replace("<a[^>]*href=[\'\"]mailto:([^\"\']+)[\'\"]>([^<]+)</a>","<a href=\"javascript:new_message_to('\\1')\">\\2</a>",$return_get_body['body']); … … 454 454 $return['Recent'] = $header->Recent; 455 455 $return['Unseen'] = $header->Unseen; 456 $return['Deleted'] = $header->Deleted; 456 $return['Deleted'] = $header->Deleted; 457 457 $return['Flagged'] = $header->Flagged; 458 458 … … 460 460 $return['Forwarded'] = 'F'; 461 461 } 462 462 463 463 else { 464 464 $return['Answered'] = $header->Answered; 465 $return['Draft'] = $header->Draft; 465 $return['Draft'] = $header->Draft; 466 466 } 467 467 468 468 $return['msg_number'] = $msg_number; 469 469 $return['msg_folder'] = $msg_folder; 470 470 471 471 $date_msg = gmdate("d/m/Y",$header->udate); 472 472 if (date("d/m/Y") == $date_msg) … … 474 474 else 475 475 $return['udate'] = $date_msg; 476 477 $return['msg_day'] = $date_msg; 476 477 $return['msg_day'] = $date_msg; 478 478 $return['msg_hour'] = gmdate("H:i",$header->udate); 479 479 480 480 if (date("d/m/Y") == $date_msg) //no dia 481 481 { … … 483 483 $return['smalldate'] = gmdate("H:i",$header->udate); 484 484 485 $timestamp_now = strtotime("now"); 485 $timestamp_now = strtotime("now"); 486 486 $timestamp_msg_time = $header->udate; 487 // $timestamp_now is GMT and $timestamp_msg_time is MailDate TZ. 487 // $timestamp_now is GMT and $timestamp_msg_time is MailDate TZ. 488 488 // The variable $timestamp_diff is calculated without MailDate TZ. 489 489 $pdate = date_parse($header->MailDate); 490 490 $timestamp_diff = $timestamp_now - $timestamp_msg_time + ($pdate['zone']*(-60)); 491 491 492 492 if (gmdate("H",$timestamp_diff) > 0) 493 493 { … … 511 511 $return['smalldate'] = gmdate("d/m/Y",$header->udate); 512 512 } 513 513 514 514 $from = $header->from; 515 515 $return['from'] = array(); … … 525 525 else 526 526 $return['from']['full'] = $return['from']['email']; 527 527 528 528 // Sender attribute 529 529 $sender = $header->sender; 530 $return['sender'] = array(); 530 $return['sender'] = array(); 531 531 $return['sender']['name'] = $this->decode_string($sender[0]->personal); 532 532 $return['sender']['email'] = $this->decode_string($sender[0]->mailbox . "@" . $sender[0]->host); … … 576 576 { 577 577 $return['toaddress2'] = "<Empty>"; 578 } 579 578 } 579 580 580 $cc = $header->cc; 581 581 $return['cc'] = ""; … … 605 605 { 606 606 $return['cc'] = ""; 607 } 607 } 608 608 609 609 ## … … 639 639 { 640 640 $return['bcc'] = ""; 641 } 641 } 642 642 643 643 $reply_to = $header->reply_to; … … 679 679 return $return; 680 680 } 681 681 682 682 function get_body_msg($msg_number, $msg_folder) 683 683 { … … 686 686 $msg->fetch_structure($msg_number); 687 687 $return = array(); 688 $return['attachments'] = $this-> download_attachment($msg,$msg_number); 688 $return['attachments'] = $this-> download_attachment($msg,$msg_number); 689 689 if(!$this->has_cid) 690 690 { 691 691 $return['thumbs'] = $this->get_thumbs($msg,$msg_number,urlencode($msg_folder)); 692 692 $return['signature'] = $this->get_signature($msg,$msg_number,$msg_folder); 693 } 694 693 } 694 695 695 if(!$msg->structure[$msg_number]->parts) //Simple message, only 1 piece 696 696 { … … 717 717 } 718 718 } 719 else 719 else 720 720 { //Complicated message, multiple parts 721 721 $html_body = ''; … … 723 723 $has_multipart = true; 724 724 $this->has_cid = false; 725 725 726 726 if (strtolower($msg->structure[$msg_number]->subtype) == "related") 727 727 $this->has_cid = true; 728 728 729 729 if (strtolower($msg->structure[$msg_number]->subtype) == "alternative") { 730 730 $show_only_html = false; … … 732 732 $file_type = strtolower($msg->file_type[$msg_number][$values]); 733 733 if($file_type == "text/html") 734 $show_only_html = true; 734 $show_only_html = true; 735 735 } 736 736 } … … 740 740 foreach($msg->pid[$msg_number] as $values => $msg_part) 741 741 { 742 742 743 743 $file_type = strtolower($msg->file_type[$msg_number][$values]); 744 744 if($file_type == "message/rfc822") 745 745 $has_multipart = false; 746 746 747 747 if($file_type == "multipart/alternative") 748 748 $has_multipart = false; 749 750 if(($file_type == "text/plain" 749 750 if(($file_type == "text/plain" 751 751 || $file_type == "text/html") 752 752 && $file_type != 'attachment') … … 756 756 // if TXT file size > 100kb, then it will not expand. 757 757 if(!($file_type == "text/plain" && $msg->fsize[$msg_number][$values] > 102400)) { 758 $content .= nl2br(htmlentities($this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values]))); 758 $content .= nl2br(htmlentities($this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values]))); 759 759 } 760 760 } … … 768 768 else if($file_type == "message/delivery-status"){ 769 769 $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>"; 770 $content .= nl2br($this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values])); 770 $content .= nl2br($this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values])); 771 771 772 772 } 773 773 else if($file_type == "message/rfc822" || $file_type == "text/rfc822-headers"){ 774 774 775 775 include_once("class.imap_attachment.inc.php"); 776 776 $att = new imap_attachment(); 777 777 $attachments = $att -> get_attachment_info($this->mbox,$msg_number); 778 if($attachments['number_attachments'] > 0) { 778 if($attachments['number_attachments'] > 0) { 779 779 foreach($attachments ['attachment'] as $index => $attachment){ 780 780 if(strtolower($attachment['type']) == "delivery-status" || 781 strtolower($attachment['type']) == "rfc822" || 781 strtolower($attachment['type']) == "rfc822" || 782 782 strtolower($attachment['type']) == "rfc822-headers" || 783 783 strtolower($attachment['type']) == "plain" 784 784 ){ 785 $obj = imap_rfc822_parse_headers(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values]); 786 $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>"; 785 $obj = imap_rfc822_parse_headers(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values]); 786 $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>"; 787 787 $content .= "<br><table style='margin:2px;border:1px solid black;background:#EAEAEA'>"; 788 788 $content .= "<tr><td><b>".$this->functions->getLang("Subject").":</b></td><td>".$this->decode_string($obj->subject)."</td></tr>"; … … 790 790 $content .= "<tr><td><b>".$this->functions->getLang("Date").":</b></td><td>".$obj->date."</td></tr>"; 791 791 $content .= "<tr><td><b>".$this->functions->getLang("TO").":</b></td><td>".$this->decode_string($obj->to[0]->mailbox."@".$obj->to[0]->host)."</td></tr>"; 792 $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>"; 792 $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>"; 793 793 $ix_part = strtolower($attachment['type']) == "delivery-status" ? 1 : 0; 794 $content .= nl2br($this->decodeBody(imap_fetchbody($this->mbox, $msg_number, ($attachment['part_in_msg']+$ix_part).".1", FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values]));795 break; 794 $content .= ($this->decodeBody(imap_fetchbody($this->mbox, $msg_number, ($attachment['part_in_msg']+$ix_part).".1", FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values])); 795 break; 796 796 } 797 797 } … … 803 803 $content .= nl2br(imap_base64(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID))); 804 804 else if(!strtolower($msg->structure[$msg_number]->subtype) == "mixed") 805 $content .= nl2br(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID)); 806 } 807 } 805 $content .= nl2br(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID)); 806 } 807 } 808 808 // Force message with flag Seen (imap_fetchbody not works correctly) 809 $params = array('folder' => $msg_folder, "msgs_to_set" => $msg_number, "flag" => "seen"); 809 $params = array('folder' => $msg_folder, "msgs_to_set" => $msg_number, "flag" => "seen"); 810 810 $this->set_messages_flag($params); 811 811 $content = $this->process_embedded_images($msg,$msg_number,$content, $msg_folder); … … 814 814 return $return; 815 815 } 816 816 817 817 function htmlfilter($body) 818 818 { 819 819 require_once('htmlfilter.inc'); 820 820 821 821 $tag_list = Array( 822 822 false, … … 891 891 '\\1round:\\2\\1' 892 892 ) 893 ), 894 893 ), 894 895 895 '/^style/i' => 896 896 Array( … … 918 918 '/^a$/i' => Array('target' => '"_new"') 919 919 ); 920 921 920 921 922 922 $trusted_body = sanitize($body, 923 923 $tag_list, … … 929 929 $add_attr_to_tag 930 930 ); 931 931 932 932 return $trusted_body; 933 933 } 934 934 935 935 function decodeBody($body, $encoding, $charset=null) 936 936 { … … 944 944 { 945 945 /* 946 946 947 947 for($i=0;$i<256;$i++) { 948 948 $c1=dechex($i); … … 951 951 $myqprinta[]=$c1; 952 952 $myqprintb[]=chr($i); 953 } 953 } 954 954 */ 955 955 $body = str_replace($myqprinta,$myqprintb,($body)); 956 956 $body = quoted_printable_decode($body); 957 while (ereg("=\n", $body)) 957 while (ereg("=\n", $body)) 958 958 { 959 959 $body = ereg_replace ("=\n", '', $body); 960 960 } 961 961 } 962 else if ($encoding == 'base64') 962 else if ($encoding == 'base64') 963 963 { 964 964 $body = base64_decode($body); 965 965 } 966 else if ($encoding == '7bit') 966 else if ($encoding == '7bit') 967 967 { 968 $body = quoted_printable_decode($body); 968 $body = quoted_printable_decode($body); 969 969 } 970 970 // All other encodings are returned raw. … … 974 974 return $body; 975 975 } 976 976 977 977 function process_embedded_images($msg, $msgno, $body, $msg_folder) 978 978 { … … 991 991 } 992 992 } 993 993 994 994 return $body; 995 995 } 996 996 997 997 function replace_special_characters($body) 998 998 { 999 999 // Suspected TAGS! 1000 /*$tag_list = Array( 1000 /*$tag_list = Array( 1001 1001 'blink','object','meta', 1002 1002 'html','link','frame', … … 1007 1007 */ 1008 1008 1009 // Layout problem: Change html elements 1010 // with absolute position to relate position, CASE INSENSITIVE. 1009 // Layout problem: Change html elements 1010 // with absolute position to relate position, CASE INSENSITIVE. 1011 1011 $body = @mb_eregi_replace("POSITION: ABSOLUTE;","",$body); 1012 1012 … … 1016 1016 1017 1017 $body = $this-> replace_links($body); 1018 $blocked_tags = array(); 1018 $blocked_tags = array(); 1019 1019 foreach($tag_list as $index => $tag) { 1020 1020 $new_body = @mb_eregi_replace("<$tag", "<!--$tag", $body); … … 1034 1034 } 1035 1035 1036 function replace_links($body) { 1036 function replace_links($body) { 1037 1037 $matches = array(); 1038 1038 // Verify exception. … … 1041 1041 if(count($matches)) 1042 1042 return $body; 1043 1043 1044 1044 $pattern = '/[\s\r\n>;]+((http(s?):\/\/((?:[\w]\.?)+(?::[\d]+)?[:\/.\-~&=?%;@#,+\w]*))|((?:www?\.)(?:\w\.?)*(?::\d+)?[\:\/\w.\-~&=?%;@+]*))/i'; 1045 1045 $replacement = '<a href="http$3://$4$5" target="_blank">$1</a>'; 1046 return preg_replace($pattern, $replacement, $body); 1047 1046 return preg_replace($pattern, $replacement, $body); 1047 1048 1048 // Original 1049 1049 //return preg_replace('/(?<=[\s|(<br>)|\n|\r|;])((http(s?):\/\/((?:[\w]\.?)+(?::[\d]+)?[\/.\-~&=?%;@#,+\w]*))|((?:www?\.)(?:\w\.?)*(?::\d+)?[\/\w.\-~&=?%;@+]*))/i', '<a href="http$3://$4$5" target="_blank">http$3://$4$5</a>', $body); … … 1060 1060 if($temp['ContentType'] =='normal') return $sign; 1061 1061 $file_type = strtolower($file_type); 1062 if(strtolower($msg->encoding[$msg_number][$index]) == 'base64') 1062 if(strtolower($msg->encoding[$msg_number][$index]) == 'base64') 1063 1063 { 1064 if ($file_type == 'application/x-pkcs7-signature' || $file_type == 'application/pkcs7-signature') 1064 if ($file_type == 'application/x-pkcs7-signature' || $file_type == 'application/pkcs7-signature') 1065 1065 { 1066 1066 if(!$this->mbox || !is_resource($this->mbox)) … … 1186 1186 } 1187 1187 } 1188 return $sign; 1188 return $sign; 1189 1189 } 1190 1190 … … 1207 1207 return $thumbs_array; 1208 1208 } 1209 1209 1210 1210 /*function delete_msg($params) 1211 1211 { 1212 1212 $folder = $params['folder']; 1213 1213 $msgs_to_delete = explode(",",$params['msgs_to_delete']); 1214 1214 1215 1215 $mbox_stream = $this->open_mbox($folder); 1216 1216 1217 1217 foreach ($msgs_to_delete as $msg_number){ 1218 1218 imap_delete($mbox_stream, $msg_number, FT_UID); … … 1225 1225 function delete_msgs($params) 1226 1226 { 1227 1227 1228 1228 $folder = $params['folder']; 1229 1229 $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO-8859-1"); 1230 1230 $msgs_number = explode(",",$params['msgs_number']); 1231 1231 $border_ID = $params['border_ID']; 1232 1232 1233 1233 $return = array(); 1234 1234 1235 1235 if ($params['get_previous_msg']){ 1236 1236 $return['previous_msg'] = $this->get_info_previous_msg($params); … … 1239 1239 } 1240 1240 1241 //$mbox_stream = $this->open_mbox($folder); 1241 //$mbox_stream = $this->open_mbox($folder); 1242 1242 $mbox_stream = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$folder, $this->username, $this->password) or die(serialize(array('imap_error' => $this->parse_error(imap_last_error())))); 1243 1243 1244 1244 foreach ($msgs_number as $msg_number) 1245 1245 { … … 1247 1247 $return['msgs_number'][] = $msg_number; 1248 1248 } 1249 1249 1250 1250 $return['folder'] = $folder; 1251 1251 $return['border_ID'] = $border_ID; 1252 1252 1253 1253 if($mbox_stream) 1254 1254 imap_close($mbox_stream, CL_EXPUNGE); … … 1256 1256 } 1257 1257 1258 1258 1259 1259 function refresh($params) 1260 1260 { 1261 1261 include_once("class.imap_attachment.inc.php"); 1262 $imap_attachment = new imap_attachment(); 1262 $imap_attachment = new imap_attachment(); 1263 1263 $folder = $params['folder']; 1264 1264 $msg_range_begin = $params['msg_range_begin']; 1265 1265 $msg_range_end = $params['msg_range_end']; 1266 1266 $msgs_existent = $params['msgs_existent']; 1267 $sort_box_type = $params['sort_box_type']; 1267 $sort_box_type = $params['sort_box_type']; 1268 1268 $sort_box_reverse = $params['sort_box_reverse']; 1269 1269 $msgs_in_the_server = array(); … … 1273 1273 if(!count($msgs_in_the_server)) 1274 1274 return array(); 1275 1275 1276 1276 $num_msgs = (count($msgs_in_the_server) - imap_num_recent($this->mbox)); 1277 $msgs_in_the_client = explode(",", $msgs_existent); 1277 $msgs_in_the_client = explode(",", $msgs_existent); 1278 1278 1279 1279 $msg_to_insert = array_diff($msgs_in_the_server, $msgs_in_the_client); 1280 1280 $msg_to_delete = array_diff($msgs_in_the_client, $msgs_in_the_server); 1281 1281 1282 1282 $msgs_to_exec = array(); 1283 1283 if ((count($msg_to_insert)) && ($msgs_existent)) … … 1305 1305 } 1306 1306 } 1307 1307 1308 1308 $return = array(); 1309 1309 $i = 0; … … 1311 1311 { 1312 1312 /*A função imap_headerinfo não traz o cabeçalho completo, e sim alguns 1313 * atributos do cabeçalho. Como eu preciso do atributo Importance 1313 * atributos do cabeçalho. Como eu preciso do atributo Importance 1314 1314 * para saber se o email é importante ou não, uso abaixo a função 1315 1315 * imap_fetchheader e busco o atributo importance nela para passar … … 1323 1323 $flag = preg_match('/importance *: *(.*)\r/i', $tempHeader, $importance); 1324 1324 $return[$i]['Importance'] = $flag==0?"Normal":$importance[1]; 1325 1325 1326 1326 $header = $this->get_header($msg_number); 1327 1327 if (!is_object($header)) … … 1330 1330 $return[$i]['msg_number'] = $msg_number; 1331 1331 $return[$i]['command'] = $command; 1332 1332 1333 1333 $return[$i]['msg_folder'] = $folder; 1334 1334 // Atribui o tipo (normal, signature ou cipher) ao campo Content-Type … … 1346 1346 else 1347 1347 $return[$i]['udate'] = $date_msg; 1348 1348 1349 1349 $from = $header->from; 1350 1350 $return[$i]['from'] = array(); … … 1352 1352 $return[$i]['from']['name'] = $tmp[0]->text; 1353 1353 $return[$i]['from']['email'] = $from[0]->mailbox . "@" . $from[0]->host; 1354 //$return[$i]['from']['full'] ='"' . $return[$i]['from']['name'] . '" ' . '<' . $return[$i]['from']['email'] . '>'; 1354 //$return[$i]['from']['full'] ='"' . $return[$i]['from']['name'] . '" ' . '<' . $return[$i]['from']['email'] . '>'; 1355 1355 if(!$return[$i]['from']['name']) 1356 1356 $return[$i]['from']['name'] = $return[$i]['from']['email']; 1357 1357 1358 1358 /*$toaddress = imap_mime_header_decode($header->toaddress); 1359 1359 $return[$i]['toaddress'] = ''; … … 1366 1366 $return[$i]['to']['email'] = $to[0]->mailbox . "@" . $to[0]->host; 1367 1367 $return[$i]['to']['full'] ='"' . $return[$i]['to']['name'] . '" ' . '<' . $return[$i]['to']['email'] . '>'; 1368 1368 1369 1369 $return[$i]['subject'] = $this->decode_string($header->fetchsubject); 1370 1370 1371 1371 $return[$i]['Size'] = $header->Size; 1372 1372 $return[$i]['reply_toaddress'] = $header->reply_toaddress; 1373 1373 1374 1374 $return[$i]['attachment'] = array(); 1375 1375 $return[$i]['attachment'] = $imap_attachment->get_attachment_headerinfo($this->mbox, $msg_number); … … 1413 1413 * Se usar $params['noSharedFolders'] = true, ira retornar todas as pastas do usuário logado, 1414 1414 * excluindo as compartilhadas para ele. 1415 * @return Retorna um array contendo as seguintes informacoes de cada pasta: folder_unseen, 1415 * @return Retorna um array contendo as seguintes informacoes de cada pasta: folder_unseen, 1416 1416 * folder_id, folder_name, folder_parent e folder_hasChildren. 1417 */ 1417 */ 1418 1418 function get_folders_list($params = null) 1419 1419 { 1420 $mbox_stream = $this->open_mbox(); 1420 $mbox_stream = $this->open_mbox(); 1421 1421 $serverString = "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}"; 1422 1422 $folders_list = imap_getmailboxes($mbox_stream, $serverString, ($params && $params['noSharedFolders']) ? "INBOX/*" : "*"); … … 1425 1425 $tmp = array(); 1426 1426 $result = array(); 1427 1427 1428 1428 if (is_array($folders_list)) { 1429 1429 reset($folders_list); 1430 1430 $this->ldap = new ldap_functions(); 1431 1431 1432 1432 $i = 0; 1433 1433 while (list($key, $val) = each($folders_list)) { … … 1444 1444 $folder_id = $tmp_folder_id[1]; 1445 1445 $result[$i]['folder_id'] = $folder_id; 1446 1446 1447 1447 $tmp_folder_parent = explode($this->imap_delimiter, $folder_id); 1448 1448 $result[$i]['folder_name'] = array_pop($tmp_folder_parent); … … 1454 1454 } 1455 1455 } 1456 1456 1457 1457 $tmp_folder_parent = implode($this->imap_delimiter, $tmp_folder_parent); 1458 1458 $result[$i]['folder_parent'] = $tmp_folder_parent == 'INBOX' ? '' : $tmp_folder_parent; 1459 1459 1460 1460 if (($val->attributes == 32) && ($result[$i]['folder_name'] != 'Inbox')) 1461 1461 $result[$i]['folder_hasChildren'] = 1; … … 1463 1463 $result[$i]['folder_hasChildren'] = 0; 1464 1464 1465 $i++; 1465 $i++; 1466 1466 } 1467 1467 } 1468 1468 1469 1469 foreach ($result as $folder_info) 1470 1470 { 1471 1471 $array_tmp[] = $folder_info['folder_id']; 1472 1472 } 1473 1473 1474 1474 natcasesort($array_tmp); 1475 1475 1476 1476 foreach ($array_tmp as $key => $folder_id) 1477 1477 { 1478 1478 $result2[] = $result[$key]; 1479 1479 } 1480 1480 1481 1481 $current_folder = "INBOX"; 1482 1482 if($params && $params['folder']) … … 1484 1484 return array_merge($result2, $this->get_quota(array(folder_id => $current_folder))); 1485 1485 } 1486 1486 1487 1487 function create_mailbox($arr) 1488 1488 { … … 1491 1491 $imap_server = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer']; 1492 1492 $namebox = mb_convert_encoding($namebox, "UTF7-IMAP", "UTF-8"); 1493 1493 1494 1494 $result = "Ok"; 1495 1495 if(!imap_createmailbox($mbox_stream,"{".$imap_server."}$namebox")) 1496 1496 { 1497 1497 $result = implode("<br />\n", imap_errors()); 1498 } 1499 1498 } 1499 1500 1500 if($mbox_stream) 1501 1501 imap_close($mbox_stream); 1502 1502 1503 1503 return $result; 1504 1505 } 1506 1504 1505 } 1506 1507 1507 function create_extra_mailbox($arr) 1508 1508 { … … 1511 1511 $mbox_stream = $this->open_mbox(); 1512 1512 $imap_server = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer']; 1513 foreach($nameboxs as $key=>$tmp){ 1513 foreach($nameboxs as $key=>$tmp){ 1514 1514 if($tmp != ""){ 1515 1515 if(!imap_createmailbox($mbox_stream,imap_utf7_encode("{".$imap_server."}$tmp"))){ 1516 1516 $result = implode("<br />\n", imap_errors()); 1517 1517 if($mbox_stream) 1518 imap_close($mbox_stream); 1518 imap_close($mbox_stream); 1519 1519 return $result; 1520 1520 } … … 1525 1525 return true; 1526 1526 } 1527 1527 1528 1528 function delete_mailbox($arr) 1529 1529 { … … 1532 1532 $mbox_stream = $this->open_mbox(); 1533 1533 //$del_folder = imap_deletemailbox($mbox_stream,"{".$imap_server."}INBOX.$namebox"); 1534 1534 1535 1535 $result = "Ok"; 1536 1536 $namebox = mb_convert_encoding($namebox, "UTF7-IMAP","UTF-8"); … … 1543 1543 return $result; 1544 1544 } 1545 1545 1546 1546 function ren_mailbox($arr) 1547 1547 { … … 1551 1551 $mbox_stream = $this->open_mbox(); 1552 1552 //$ren_folder = imap_renamemailbox($mbox_stream,"{".$imap_server."}INBOX.$namebox","{".$imap_server."}INBOX.$new_box"); 1553 1553 1554 1554 $result = "Ok"; 1555 1555 $namebox = mb_convert_encoding($namebox, "UTF7-IMAP","UTF-8"); 1556 1556 $new_box = mb_convert_encoding($new_box, "UTF7-IMAP","UTF-8"); 1557 1557 1558 1558 if(!imap_renamemailbox($mbox_stream,"{".$imap_server."}$namebox","{".$imap_server."}$new_box")) 1559 1559 { 1560 $result = imap_errors(); 1560 $result = imap_errors(); 1561 1561 } 1562 1562 if($mbox_stream) 1563 1563 imap_close($mbox_stream); 1564 1564 return $result; 1565 1566 } 1567 1565 1566 } 1567 1568 1568 function get_num_msgs($params) 1569 1569 { … … 1573 1573 if(!$this->mbox || !is_resource($this->mbox)) 1574 1574 return imap_last_error(); 1575 } 1575 } 1576 1576 $num_msgs = imap_num_msg($this->mbox); 1577 1577 if($this->mbox && is_resource($this->mbox)) 1578 1578 imap_close($this->mbox); 1579 1579 1580 1580 return $num_msgs; 1581 1581 } 1582 1582 1583 1583 function send_mail($params) 1584 1584 { … … 1661 1661 $forwarding_attachments = $params['forwarding_attachments']; 1662 1662 $local_attachments = $params['local_attachments']; 1663 1663 1664 1664 $folder =$params['folder']; 1665 $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1"); 1666 $folder_name = $params['folder_name']; 1665 $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1"); 1666 $folder_name = $params['folder_name']; 1667 1667 // Fix problem with cyrus delimiter changes. 1668 // Dots in names: enabled/disabled. 1668 // Dots in names: enabled/disabled. 1669 1669 $folder = @eregi_replace("INBOX/", "INBOX".$this->imap_delimiter, $folder); 1670 1670 $folder = @eregi_replace("INBOX.", "INBOX".$this->imap_delimiter, $folder); 1671 1671 // End Fix. 1672 if ($folder != 'null'){ 1672 if ($folder != 'null'){ 1673 1673 $mail->SaveMessageInFolder = $folder; 1674 1674 } … … 1683 1683 else 1684 1684 $mail->IsSMTP(); 1685 1685 1686 1686 $mail->Host = $_SESSION['phpgw_info']['expressomail']['email_server']['smtpServer']; 1687 1687 $mail->Port = $_SESSION['phpgw_info']['expressomail']['email_server']['smtpPort']; … … 1694 1694 $mail->From = $fromaddress[1]; 1695 1695 } 1696 1696 1697 1697 $this->add_recipients("to", $toaddress, &$mail); 1698 1698 $this->add_recipients("cc", $ccaddress, &$mail); … … 1806 1806 $cid_array[$cid_imgs[4][$j].$val] = base_convert(microtime(), 10, 36); 1807 1807 } 1808 $cid = $cid_array[$cid_imgs[4][$j].$val]; 1808 $cid = $cid_array[$cid_imgs[4][$j].$val]; 1809 1809 $mail->Body = str_replace($cid_imgs[1][$j], "cid:".$cid, $mail->Body); 1810 1810 1811 1811 if ($msg_uid != $cid_imgs[4][$j]) // The image isn't in the same mail? 1812 1812 { … … 1821 1821 $file_description = unserialize(rawurldecode($attach_img)); 1822 1822 1823 foreach($file_description as $i => $descriptor){ 1823 foreach($file_description as $i => $descriptor){ 1824 1824 $file_description[$i] = eregi_replace('\'*\'','',$descriptor); 1825 1825 } … … 1831 1831 } 1832 1832 $tempDir = ini_get("session.save_path"); 1833 $file = "cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].$cid_imgs[6][$j].".dat"; 1833 $file = "cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].$cid_imgs[6][$j].".dat"; 1834 1834 $f = fopen($tempDir.'/'.$file,"w"); 1835 1835 fputs($f,$fileContent); … … 1838 1838 $mail->AddEmbeddedImage($tempDir.'/'.$file, $cid, $fileName, $fileCode, $fileType); 1839 1839 //else 1840 // return "Error loading image attachment content"; 1840 // return "Error loading image attachment content"; 1841 1841 1842 1842 } … … 1853 1853 } 1854 1854 if( $total_uploaded_size > $upload_max_filesize) 1855 return $this->parse_error("message file too big"); 1855 return $this->parse_error("message file too big"); 1856 1856 } 1857 1857 else if(($params['is_local_forward']=="1") && (count($local_attachments))) { //Caso seja forward de mensagens locais 1858 1858 1859 1859 $total_uploaded_size = 0; 1860 $upload_max_filesize = str_replace("M","",ini_get('upload_max_filesize')) * 1024 * 1024; 1860 $upload_max_filesize = str_replace("M","",ini_get('upload_max_filesize')) * 1024 * 1024; 1861 1861 foreach($local_attachments as $local_attachment) { 1862 1862 $file_description = unserialize(rawurldecode($local_attachment)); 1863 1863 $tmp = array_values($file_description); 1864 foreach($file_description as $i => $descriptor){ 1864 foreach($file_description as $i => $descriptor){ 1865 1865 $tmp[$i] = eregi_replace('\'*\'','',$descriptor); 1866 1866 } … … 1879 1879 $name_cid_files[count($name_cid_files)] = $name_cid_files[0]; 1880 1880 $name_cid_files[0] = null; 1881 } 1882 1881 } 1882 1883 1883 foreach($forwarding_attachments as $forwarding_attachment) 1884 1884 { 1885 1885 $file_description = unserialize(rawurldecode($forwarding_attachment)); 1886 1886 $tmp = array_values($file_description); 1887 foreach($file_description as $i => $descriptor){ 1887 foreach($file_description as $i => $descriptor){ 1888 1888 $tmp[$i] = eregi_replace('\'*\'','',$descriptor); 1889 1889 } 1890 $file_description = $tmp; 1890 $file_description = $tmp; 1891 1891 $fileContent = $this->get_forwarding_attachment($file_description[0], $file_description[1], $file_description[3],$file_description[4]); 1892 1892 $fileName = $file_description[2]; … … 1909 1909 1910 1910 $sent = $mail->Send(); 1911 1911 1912 1912 if(!$sent) 1913 1913 { … … 1920 1920 return $sent; 1921 1921 } 1922 if($_SESSION['phpgw_info']['server']['expressomail']['expressoMail_enable_log_messages'] == "True") 1922 if($_SESSION['phpgw_info']['server']['expressomail']['expressoMail_enable_log_messages'] == "True") 1923 1923 { 1924 1924 $userid = $_SESSION['phpgw_info']['expressomail']['user']['userid']; … … 1926 1926 $now = date("d/m/y H:i:s"); 1927 1927 $addrs = $toaddress.$ccaddress.$ccoaddress; 1928 $sent = trim($sent); 1928 $sent = trim($sent); 1929 1929 error_log("$now - $userip - $sent [$subject] - $userid => $addrs\r\n", 3, "/home/expressolivre/mail_senders.log"); 1930 1930 } 1931 if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['number_of_contacts'] && 1931 if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['number_of_contacts'] && 1932 1932 $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts']) { 1933 1933 $contacts = new dynamic_contacts(); … … 1961 1961 function add_recipients($recipient_type, $full_address, $mail) 1962 1962 { 1963 $parse_address = imap_rfc822_parse_adrlist($full_address, ""); 1964 foreach ($parse_address as $val) 1963 $parse_address = imap_rfc822_parse_adrlist($full_address, ""); 1964 foreach ($parse_address as $val) 1965 1965 { 1966 1966 //echo "<script language=\"javascript\">javascript:alert('".$val->mailbox."@".$val->host."');</script>"; 1967 1967 if ($val->mailbox == "INVALID_ADDRESS") 1968 1968 continue; 1969 1969 1970 1970 if (empty($val->personal)) 1971 1971 { … … 2001 2001 return true; 2002 2002 } 2003 2003 2004 2004 function get_forwarding_attachment($msg_folder, $msg_number, $msg_part, $encoding) 2005 2005 { 2006 2006 $mbox_stream = $this->open_mbox(utf8_decode(urldecode($msg_folder))); 2007 $fileContent = imap_fetchbody($mbox_stream, $msg_number, $msg_part, FT_UID); 2007 $fileContent = imap_fetchbody($mbox_stream, $msg_number, $msg_part, FT_UID); 2008 2008 if($encoding == 'base64') 2009 2009 # The function imap_base64 adds a new line … … 2014 2014 $fileContent = base64_decode($fileContent); 2015 2015 else if($encoding == 'quoted-printable') 2016 $fileContent = quoted_printable_decode($fileContent); 2016 $fileContent = quoted_printable_decode($fileContent); 2017 2017 return $fileContent; 2018 2018 } 2019 2019 2020 2020 function del_last_caracter($string) 2021 2021 { 2022 2022 $string = substr($string,0,(strlen($string) - 1)); 2023 return $string; 2024 } 2025 2023 return $string; 2024 } 2025 2026 2026 function del_last_two_caracters($string) 2027 2027 { 2028 2028 $string = substr($string,0,(strlen($string) - 2)); 2029 return $string; 2030 } 2031 2029 return $string; 2030 } 2031 2032 2032 function messages_sort($sort_box_type,$sort_box_reverse, $search_box_type,$offsetBegin,$offsetEnd) 2033 2033 { … … 2101 2101 if(!is_array($sort)) 2102 2102 $sort = array(); 2103 2103 2104 2104 if ($slice_array) 2105 2105 $sort = array_slice($sort,$offsetBegin-1,$offsetEnd-($offsetBegin-1),true); 2106 2106 2107 2107 2108 2108 return $sort; … … 2111 2111 2112 2112 2113 function move_search_messages($params){ 2114 $params['selected_messages'] = urldecode($params['selected_messages']); 2113 function move_search_messages($params){ 2114 $params['selected_messages'] = urldecode($params['selected_messages']); 2115 2115 $params['new_folder'] = urldecode($params['new_folder']); 2116 2116 $params['new_folder_name'] = urldecode($params['new_folder_name']); 2117 2117 $sel_msgs = explode(",", $params['selected_messages']); 2118 @reset($sel_msgs); 2118 @reset($sel_msgs); 2119 2119 $sorted_msgs = array(); 2120 2120 foreach($sel_msgs as $idx => $sel_msg) { … … 2122 2122 if(array_key_exists($sel_msg[0], $sorted_msgs)){ 2123 2123 $sorted_msgs[$sel_msg[0]] .= ",".$sel_msg[1]; 2124 } 2124 } 2125 2125 else { 2126 2126 $sorted_msgs[$sel_msg[0]] = $sel_msg[1]; … … 2128 2128 } 2129 2129 @ksort($sorted_msgs); 2130 $last_return = false; 2131 foreach($sorted_msgs as $folder => $msgs_number) { 2130 $last_return = false; 2131 foreach($sorted_msgs as $folder => $msgs_number) { 2132 2132 $params['msgs_number'] = $msgs_number; 2133 $params['folder'] = $folder; 2133 $params['folder'] = $folder; 2134 2134 if($params['new_folder'] && $folder != $params['new_folder']){ 2135 $last_return = $this -> move_messages($params); 2135 $last_return = $this -> move_messages($params); 2136 2136 } 2137 2137 elseif(!$params['new_folder'] || $params['delete'] ){ … … 2142 2142 return $last_return; 2143 2143 } 2144 2144 2145 2145 function move_messages($params) 2146 2146 { 2147 $folder = $params['folder']; 2148 $mbox_stream = $this->open_mbox($folder); 2147 $folder = $params['folder']; 2148 $mbox_stream = $this->open_mbox($folder); 2149 2149 $newmailbox = ($params['new_folder']); 2150 2150 $newmailbox = mb_convert_encoding($newmailbox, "UTF7-IMAP","ISO_8859-1"); … … 2156 2156 'border_ID' => $params['border_ID'], 2157 2157 'status' => true); //Status foi adicionado para validar as permissoes ACL 2158 2158 2159 2159 //Este bloco tem a finalidade de averiguar as permissoes para pastas compartilhadas 2160 2160 if (substr($folder,0,4) == 'user'){ … … 2177 2177 } 2178 2178 //Este bloco tem a finalidade de transformar o CPF das pastas compartilhadas em common name 2179 if (substr($new_folder_name,0,4) == 'user'){ 2179 if (substr($new_folder_name,0,4) == 'user'){ 2180 2180 $this->ldap = new ldap_functions(); 2181 2181 $tmp_folder_name = explode($this->imap_delimiter, $new_folder_name); … … 2185 2185 $return['new_folder_name'] = $cn; 2186 2186 } 2187 2188 // Caso estejamos no box principal, nao eh necessario pegar a informacao da mensagem anterior. 2187 2188 // Caso estejamos no box principal, nao eh necessario pegar a informacao da mensagem anterior. 2189 2189 if (($params['get_previous_msg']) && ($params['border_ID'] != 'null') && ($params['border_ID'] != '')) 2190 2190 { … … 2193 2193 $return['previous_msg']['body'] = str_replace(array('{','}'), array('{','}'), $return['previous_msg']['body']); 2194 2194 } 2195 2196 $mbox_stream = $this->open_mbox($folder); 2195 2196 $mbox_stream = $this->open_mbox($folder); 2197 2197 if(imap_mail_move($mbox_stream, $msgs_number, $newmailbox, CP_UID)) { 2198 2198 imap_expunge($mbox_stream); … … 2201 2201 return $return; 2202 2202 }else { 2203 if(strstr(imap_last_error(),'Over quota')) { 2203 if(strstr(imap_last_error(),'Over quota')) { 2204 2204 $accountID = $_SESSION['phpgw_info']['expressomail']['email_server']['imapAdminUsername']; 2205 $pass = $_SESSION['phpgw_info']['expressomail']['email_server']['imapAdminPW']; 2206 $userID = $_SESSION['phpgw_info']['expressomail']['user']['userid']; 2205 $pass = $_SESSION['phpgw_info']['expressomail']['email_server']['imapAdminPW']; 2206 $userID = $_SESSION['phpgw_info']['expressomail']['user']['userid']; 2207 2207 $server = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer']; 2208 2208 $mbox = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}INBOX", $accountID, $pass) or die(serialize(array('imap_error' => $this->parse_error(imap_last_error())))); 2209 2209 if(!$mbox) 2210 2210 return imap_last_error(); 2211 $quota = imap_get_quotaroot($mbox_stream, "INBOX"); 2211 $quota = imap_get_quotaroot($mbox_stream, "INBOX"); 2212 2212 if(! imap_set_quota($mbox, "user".$this->imap_delimiter.$userID, 2.1 * $quota['usage'])) { 2213 2213 if($mbox_stream) 2214 2214 imap_close($mbox_stream); 2215 if($mbox) 2215 if($mbox) 2216 2216 imap_close($mbox); 2217 return "move_messages(): Error setting quota for MOVE or DELETE!! ". "user".$this->imap_delimiter.$userID." line ".__LINE__."\n"; 2217 return "move_messages(): Error setting quota for MOVE or DELETE!! ". "user".$this->imap_delimiter.$userID." line ".__LINE__."\n"; 2218 2218 } 2219 2219 if(imap_mail_move($mbox_stream, $msgs_number, $newmailbox, CP_UID)) { … … 2225 2225 if($mbox) 2226 2226 imap_close($mbox); 2227 return "move_messages(): Error setting quota for MOVE or DELETE!! line ".__LINE__."\n"; 2227 return "move_messages(): Error setting quota for MOVE or DELETE!! line ".__LINE__."\n"; 2228 2228 } 2229 return $return; 2229 return $return; 2230 2230 } 2231 2231 else { … … 2235 2235 if($mbox) 2236 2236 imap_close($mbox); 2237 return "move_messages(): Error setting quota for MOVE or DELETE!! line ".__LINE__."\n"; 2237 return "move_messages(): Error setting quota for MOVE or DELETE!! line ".__LINE__."\n"; 2238 2238 } 2239 return imap_last_error(); 2240 } 2241 2239 return imap_last_error(); 2240 } 2241 2242 2242 } 2243 2243 else { … … 2246 2246 return "move_messages() line ".__LINE__.": ". imap_last_error()." folder:".$newmailbox; 2247 2247 } 2248 } 2249 } 2250 2248 } 2249 } 2250 2251 2251 function save_msg($params) 2252 2252 { 2253 2253 2254 2254 include_once("class.phpmailer.php"); 2255 2255 $mail = new PHPMailer(); … … 2266 2266 $attachments = $params['FILES']; 2267 2267 $return_files = $params['FILES']; 2268 2268 2269 2269 $folder = $params['folder']; 2270 $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1"); 2270 $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1"); 2271 2271 // Fix problem with cyrus delimiter changes. 2272 // Dots in names: enabled/disabled. 2272 // Dots in names: enabled/disabled. 2273 2273 $folder = @eregi_replace("INBOX/", "INBOX".$this->imap_delimiter, $folder); 2274 2274 $folder = @eregi_replace("INBOX.", "INBOX".$this->imap_delimiter, $folder); 2275 2275 // End Fix. 2276 2276 2277 2277 $mail->SaveMessageInFolder = $folder; 2278 2278 $mail->SMTPDebug = false; 2279 2279 2280 2280 $mail->IsSMTP(); 2281 2281 $mail->Host = $_SESSION['phpgw_info']['expressomail']['email_server']['smtpServer']; … … 2283 2283 $mail->From = $_SESSION['phpgw_info']['expressomail']['user']['email']; 2284 2284 $mail->FromName = $_SESSION['phpgw_info']['expressomail']['user']['fullname']; 2285 2285 2286 2286 $mail->Sender = $mail->From; 2287 2287 $mail->SenderName = $mail->FromName; 2288 2288 $mail->FromName = $_SESSION['phpgw_info']['expressomail']['user']['fullname']; 2289 2289 $mail->From = $_SESSION['phpgw_info']['expressomail']['user']['email']; 2290 2290 2291 2291 $this->add_recipients("to", $toaddress, &$mail); 2292 2292 $this->add_recipients("cc", $ccaddress, &$mail); … … 2294 2294 $mail->IsHTML(true); 2295 2295 $mail->Body = $body; 2296 2296 2297 2297 // Build CID for embedded Images!!! 2298 2298 $pattern = '/src="([^"]*?show_embedded_attach.php\?msg_folder=(.+)?&(amp;)?msg_num=(.+)?&(amp;)?msg_part=(.+)?)"/isU'; … … 2306 2306 $cid_array[$cid_imgs[4][$j].$val] = base_convert(microtime(), 10, 36); 2307 2307 } 2308 $cid = $cid_array[$cid_imgs[4][$j].$val]; 2308 $cid = $cid_array[$cid_imgs[4][$j].$val]; 2309 2309 $mail->Body = str_replace($cid_imgs[1][$j], "cid:".$cid, $mail->Body); 2310 2310 2311 2311 if ($msg_uid != $cid_imgs[4][$j]) // The image isn't in the same mail? 2312 2312 { … … 2328 2328 $attach_img = $forwarding_attachments[$cid_imgs[6][$j]-2]; 2329 2329 $file_description = unserialize(rawurldecode($attach_img)); 2330 foreach($file_description as $i => $descriptor){ 2330 foreach($file_description as $i => $descriptor){ 2331 2331 $file_description[$i] = eregi_replace('\'*\'','',$descriptor); 2332 2332 } … … 2343 2343 } 2344 2344 $tempDir = ini_get("session.save_path"); 2345 $file = "cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].$cid_imgs[6][$j].".dat"; 2345 $file = "cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].$cid_imgs[6][$j].".dat"; 2346 2346 $f = fopen($tempDir.'/'.$file,"w"); 2347 2347 fputs($f,$fileContent); … … 2350 2350 $mail->AddEmbeddedImage($tempDir.'/'.$file, $cid, $fileName, $fileCode, $fileType); 2351 2351 //else 2352 // return "Error loading image attachment content"; 2353 2354 } 2355 2356 // Build Forwarding Attachments!!! 2352 // return "Error loading image attachment content"; 2353 2354 } 2355 2356 // Build Forwarding Attachments!!! 2357 2357 if (count($forwarding_attachments) > 0) 2358 2358 { … … 2361 2361 $file_description = unserialize(rawurldecode($forwarding_attachment)); 2362 2362 $tmp = array_values($file_description); 2363 foreach($file_description as $i => $descriptor){ 2363 foreach($file_description as $i => $descriptor){ 2364 2364 $tmp[$i] = eregi_replace('\'*\'','',$descriptor); 2365 2365 } 2366 2366 $file_description = $tmp; 2367 2367 2368 2368 $fileContent = $this->get_forwarding_attachment($file_description[0], $file_description[1], $file_description[3],$file_description[4]); 2369 2369 $fileName = $file_description[2]; 2370 2370 2371 2371 $file_description[5] = strlen($fileContent); //Size of file 2372 2372 $return_forward[] = $file_description; 2373 2373 2374 2374 $mail->AddStringAttachment($fileContent, $fileName, $file_description[4], $this->get_file_type($file_description[2])); 2375 2375 } 2376 2376 } 2377 2377 2378 2378 if ((count($return_forward) > 0) && (count($return_files) > 0)) 2379 2379 $return_files = array_merge_recursive($return_forward,$return_files); … … 2381 2381 if (count($return_files) < 1) 2382 2382 $return_files = $return_forward; 2383 2383 2384 2384 // Build Uploading Attachments!!! 2385 2385 $sizeof_attachments = count($attachments); … … 2419 2419 imagecopyresampled($image_new, $image_big, 0, 0, 0, 0, $new_width, $new_height, $width, $height); 2420 2420 $tmpDir = ini_get("session.save_path"); 2421 $_file = "/cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].".dat"; 2421 $_file = "/cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].".dat"; 2422 2422 imagejpeg($image_new,$tmpDir.$_file, 85); 2423 2423 $mail->AddAttachment($tmpDir.$_file, $attach['name'], "base64", $this->get_file_type($tmpDir.$_file)); … … 2427 2427 // optional name 2428 2428 } 2429 2430 2431 2432 2429 2430 2431 2432 2433 2433 if(!empty($mail->AltBody)) 2434 2434 $mail->ContentType = "multipart/alternative"; … … 2437 2437 $mail->SetMessageType(); 2438 2438 $header = $mail->CreateHeader(); 2439 $body = $mail->CreateBody(); 2440 2441 $mbox_stream = $this->open_mbox($folder); 2439 $body = $mail->CreateBody(); 2440 2441 $mbox_stream = $this->open_mbox($folder); 2442 2442 $new_header = str_replace("\n", "\r\n", $header); 2443 2443 $new_body = str_replace("\n", "\r\n", $body); … … 2449 2449 if($mbox_stream) 2450 2450 imap_close($mbox_stream); 2451 if (is_array($return_files)) 2451 if (is_array($return_files)) 2452 2452 foreach ($return_files as $index => $_attachment) { 2453 2453 if (array_key_exists("name",$_attachment)){ … … 2461 2461 } 2462 2462 } 2463 2463 2464 2464 $return['files'] = serialize($return_files); 2465 2465 $return["subject"] = $subject; 2466 2466 2467 2467 if (!$return['append']) 2468 2468 $return['append'] = imap_last_error(); 2469 2469 2470 2470 return $return; 2471 2471 } 2472 2472 2473 2473 function set_messages_flag($params) 2474 2474 { … … 2479 2479 $return["msgs_to_set"] = $msgs_to_set; 2480 2480 $return["flag"] = $flag; 2481 2481 2482 2482 if(!$this->mbox && !is_resource($this->mbox)) 2483 2483 $this->mbox = $this->open_mbox($folder); 2484 2484 2485 2485 if ($flag == "unseen") 2486 2486 $return["status"] = imap_clearflag_full($this->mbox, $msgs_to_set, "\\Seen", ST_UID); … … 2502 2502 preg_match('/importance *: *(.*)\r/i', 2503 2503 imap_fetchheader($this->mbox, imap_msgno($this->mbox, $msg_number)) 2504 ,$importance); 2504 ,$importance); 2505 2505 if(strtolower($importance[1])=="high" && $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_important_flag']) { 2506 2506 $flag_importance=true; … … 2508 2508 else { 2509 2509 $unflagged_msgs.=$msg_number.","; 2510 } 2510 } 2511 2511 } 2512 2512 … … 2527 2527 } 2528 2528 } 2529 2529 2530 2530 if($this->mbox && is_resource($this->mbox)) 2531 2531 imap_close($this->mbox); 2532 2532 return $return; 2533 2533 } 2534 2534 2535 2535 function get_file_type($file_name) 2536 2536 { 2537 2537 $file_name = strtolower($file_name); 2538 2538 $strFileType = strrev(substr(strrev($file_name),0,4)); 2539 if ($strFileType == ".asf") 2539 if ($strFileType == ".asf") 2540 2540 return "video/x-ms-asf"; 2541 2541 if ($strFileType == ".avi") … … 2563 2563 if ($strFileType == ".htm" || $strFileType == "html") 2564 2564 return "text/html"; 2565 if ($strFileType == ".xml") 2565 if ($strFileType == ".xml") 2566 2566 return "text/xml"; 2567 if ($strFileType == ".xsl") 2567 if ($strFileType == ".xsl") 2568 2568 return "text/xsl"; 2569 if ($strFileType == ".css") 2569 if ($strFileType == ".css") 2570 2570 return "text/css"; 2571 if ($strFileType == ".php") 2571 if ($strFileType == ".php") 2572 2572 return "text/php"; 2573 if ($strFileType == ".asp") 2573 if ($strFileType == ".asp") 2574 2574 return "text/asp"; 2575 2575 if ($strFileType == ".pdf") … … 2599 2599 if ($strFileType == ".stw") 2600 2600 return "application/vnd.sun.xml.writer.template"; 2601 2602 2603 return "application/octet-stream"; 2604 } 2605 2601 2602 2603 return "application/octet-stream"; 2604 } 2605 2606 2606 function htmlspecialchars_encode($str) 2607 2607 { … … 2612 2612 return str_replace( array('&','"',''','<','>','{','}'), array('&', '"','\'','<','>','{','}'), $str); 2613 2613 } 2614 2614 2615 2615 function get_msgs($folder, $sort_box_type, $search_box_type, $sort_box_reverse,$offsetBegin = 0,$offsetEnd = 0) 2616 2616 { … … 2620 2620 return $this->messages_sort($sort_box_type,$sort_box_reverse, $search_box_type,$offsetBegin,$offsetEnd); 2621 2621 } 2622 2622 2623 2623 function get_info_next_msg($params) 2624 2624 { … … 2629 2629 $reuse_border = $params['reuse_border']; 2630 2630 $search_box_type = $params['search_box_type'] != "ALL" && $params['search_box_type'] != "" ? $params['search_box_type'] : false; 2631 $sort_array_msg = $this -> get_msgs($folder, $sort_box_type, $search_box_type, $sort_box_reverse); 2632 2631 $sort_array_msg = $this -> get_msgs($folder, $sort_box_type, $search_box_type, $sort_box_reverse); 2632 2633 2633 $success = false; 2634 2634 if (is_array($sort_array_msg)) … … 2649 2649 return $params; 2650 2650 } 2651 2651 2652 2652 $params = array(); 2653 2653 $params['msg_number'] = $sort_array_msg[($i+1)]; 2654 2654 $params['msg_folder'] = $folder; 2655 2656 $return = $this->get_info_msg($params); 2655 2656 $return = $this->get_info_msg($params); 2657 2657 $return["reuse_border"] = $reuse_border; 2658 2658 return $return; … … 2668 2668 $search_box_type = $params['search_box_type'] != "ALL" && $params['search_box_type'] != "" ? $params['search_box_type'] : false; 2669 2669 $sort_array_msg = $this -> get_msgs($folder, $sort_box_type, $search_box_type, $sort_box_reverse); 2670 2670 2671 2671 $success = false; 2672 2672 if (is_array($sort_array_msg)) … … 2686 2686 return $params; 2687 2687 } 2688 2688 2689 2689 $params = array(); 2690 2690 $params['msg_number'] = $sort_array_msg[($i-1)]; 2691 2691 $params['msg_folder'] = $folder; 2692 2692 2693 2693 $return = $this->get_info_msg($params); 2694 2694 $return["reuse_border"] = $reuse_border; 2695 2695 return $return; 2696 2696 } 2697 2697 2698 2698 // This function updates the values: quota, paging and new messages menu. 2699 2699 function get_menu_values($params){ 2700 2700 $return_array = array(); 2701 2701 $return_array = $this->get_quota($params); 2702 2702 2703 2703 $mbox_stream = $this->open_mbox($params['folder']); 2704 $return_array['num_msgs'] = imap_num_msg($mbox_stream); 2704 $return_array['num_msgs'] = imap_num_msg($mbox_stream); 2705 2705 if($mbox_stream) 2706 2706 imap_close($mbox_stream); 2707 2708 return $return_array; 2709 } 2710 2707 2708 return $return_array; 2709 } 2710 2711 2711 function get_quota($params){ 2712 2712 // folder_id = user/{uid} for shared folders 2713 2713 if(substr($params['folder_id'],0,5) != 'INBOX' && preg_match('/user\\'.$this->imap_delimiter.'/i', $params['folder_id'])){ 2714 2714 $array_folder = explode($this->imap_delimiter,$params['folder_id']); 2715 $folder_id = "user".$this->imap_delimiter.$array_folder[1]; 2715 $folder_id = "user".$this->imap_delimiter.$array_folder[1]; 2716 2716 } 2717 2717 // folder_id = INBOX for inbox folders 2718 2718 else 2719 2719 $folder_id = "INBOX"; 2720 2720 2721 2721 if(!$this->mbox || !is_resource($this->mbox)) 2722 2722 $this->mbox = $this->open_mbox(); … … 2725 2725 if($this->mbox && is_resource($this->mbox)) 2726 2726 imap_close($this->mbox); 2727 2727 2728 2728 if (!$quota){ 2729 2729 return array( … … 2733 2733 ); 2734 2734 } 2735 2735 2736 2736 if(count($quota) && $quota['limit']) { 2737 2737 $quota_limit = (($quota['limit']/1024)* 100 + .5 )* .01; … … 2752 2752 ); 2753 2753 } 2754 else 2754 else 2755 2755 return array(); 2756 2756 } 2757 2757 2758 2758 function send_notification($params){ 2759 2759 require_once("class.phpmailer.php"); 2760 2760 $mail = new PHPMailer(); 2761 2761 2762 2762 $toaddress = $params['notificationto']; 2763 2763 2764 2764 $subject = 'Confirmação de leitura: ' . $params['subject']; 2765 2765 $body = 'Sua mensagem: ' . $params['subject'] . '<br>'; … … 2776 2776 $mail->IsHTML(true); 2777 2777 $mail->Body = $body; 2778 2778 2779 2779 if(!$mail->Send()){ 2780 2780 return $mail->ErrorInfo; … … 2783 2783 return true; 2784 2784 } 2785 2785 2786 2786 function empty_trash() 2787 2787 { 2788 $folder = 'INBOX' . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder']; 2788 $folder = 'INBOX' . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder']; 2789 2789 $mbox_stream = $this->open_mbox($folder); 2790 2790 $return = imap_delete($mbox_stream,'1:*'); … … 2793 2793 return $return; 2794 2794 } 2795 2795 2796 2796 function search($params) 2797 2797 { 2798 2798 include("class.imap_attachment.inc.php"); 2799 $imap_attachment = new imap_attachment(); 2799 $imap_attachment = new imap_attachment(); 2800 2800 $criteria = $params['criteria']; 2801 2801 $return = array(); 2802 2802 $folders = $this->get_folders_list(); 2803 2803 2804 2804 $j = 0; 2805 2805 foreach($folders as $folder) … … 2807 2807 $mbox_stream = $this->open_mbox($folder); 2808 2808 $messages = imap_search($mbox_stream, $criteria, SE_UID); 2809 2809 2810 2810 if ($messages == '') 2811 2811 continue; 2812 2812 2813 2813 $i = 0; 2814 2814 $return[$j] = array(); 2815 2815 $return[$j]['folder_name'] = $folder['name']; 2816 2816 2817 2817 foreach($messages as $msg_number) 2818 2818 { … … 2820 2820 if (!is_object($header)) 2821 2821 return false; 2822 2822 2823 2823 $return[$j][$i]['msg_folder'] = $folder['name']; 2824 2824 $return[$j][$i]['msg_number'] = $msg_number; … … 2829 2829 $return[$j][$i]['Draft'] = $header->Draft; 2830 2830 $return[$j][$i]['Flagged'] = $header->Flagged; 2831 2831 2832 2832 $date_msg = gmdate("d/m/Y",$header->udate); 2833 2833 if (gmdate("d/m/Y") == $date_msg) … … 2835 2835 else 2836 2836 $return[$j][$i]['udate'] = $date_msg; 2837 2837 2838 2838 $fromaddress = imap_mime_header_decode($header->fromaddress); 2839 2839 $return[$j][$i]['fromaddress'] = ''; 2840 2840 foreach ($fromaddress as $tmp) 2841 2841 $return[$j][$i]['fromaddress'] .= $this->replace_maior_menor($tmp->text); 2842 2842 2843 2843 $from = $header->from; 2844 2844 $return[$j][$i]['from'] = array(); … … 2846 2846 $return[$j][$i]['from']['name'] = $tmp[0]->text; 2847 2847 $return[$j][$i]['from']['email'] = $from[0]->mailbox . "@" . $from[0]->host; 2848 $return[$j][$i]['from']['full'] ='"' . $return[$j][$i]['from']['name'] . '" ' . '<' . $return[$j][$i]['from']['email'] . '>'; 2848 $return[$j][$i]['from']['full'] ='"' . $return[$j][$i]['from']['name'] . '" ' . '<' . $return[$j][$i]['from']['email'] . '>'; 2849 2849 2850 2850 $to = $header->to; … … 2853 2853 $return[$j][$i]['to']['name'] = $tmp[0]->text; 2854 2854 $return[$j][$i]['to']['email'] = $to[0]->mailbox . "@" . $to[0]->host; 2855 $return[$j][$i]['to']['full'] ='"' . $return[$i]['to']['name'] . '" ' . '<' . $return[$i]['to']['email'] . '>'; 2855 $return[$j][$i]['to']['full'] ='"' . $return[$i]['to']['name'] . '" ' . '<' . $return[$i]['to']['email'] . '>'; 2856 2856 2857 2857 $subject = imap_mime_header_decode($header->fetchsubject); … … 2862 2862 $return[$j][$i]['Size'] = $header->Size; 2863 2863 $return[$j][$i]['reply_toaddress'] = $header->reply_toaddress; 2864 2864 2865 2865 $return[$j][$i]['attachment'] = array(); 2866 2866 $return[$j][$i]['attachment'] = $imap_attachment->get_attachment_headerinfo($mbox_stream, $msg_number); 2867 2867 2868 2868 $i++; 2869 2869 } … … 2872 2872 imap_close($mbox_stream); 2873 2873 } 2874 2874 2875 2875 return $return; 2876 2876 } 2877 2877 2878 2878 function delete_and_show_previous_message($params) 2879 2879 { 2880 2880 $return = $this->get_info_previous_msg($params); 2881 2881 2882 2882 $params_tmp1 = array(); 2883 2883 $params_tmp1['msgs_to_delete'] = $params['msg_number']; 2884 2884 $params_tmp1['folder'] = $params['msg_folder']; 2885 2885 $return_tmp1 = $this->delete_msg($params_tmp1); 2886 2886 2887 2887 $return['msg_number_deleted'] = $return_tmp1; 2888 2888 2889 2889 return $return; 2890 2890 } 2891 2892 2891 2892 2893 2893 function automatic_trash_cleanness($params) 2894 2894 { … … 2908 2908 // Fix the search problem with special characters!!!! 2909 2909 function remove_accents($string) { 2910 return strtr($string, 2911 "?Ó??ó?Ý?úÁÀÃÂÄÇÉÈÊËÍÌ?ÎÏÑÕÔÓÒÖÚÙ?ÛÜ?áàãâäçéèêëíì?îïñóòõôöúù?ûüýÿ", 2910 return strtr($string, 2911 "?Ó??ó?Ý?úÁÀÃÂÄÇÉÈÊËÍÌ?ÎÏÑÕÔÓÒÖÚÙ?ÛÜ?áàãâäçéèêëíì?îïñóòõôöúù?ûüýÿ", 2912 2912 "SOZsozYYuAAAAACEEEEIIIIINOOOOOUUUUUsaaaaaceeeeiiiiinooooouuuuuyy"); 2913 2913 } 2914 2914 2915 function search_msg($params = ''){ 2915 function search_msg($params = ''){ 2916 2916 $retorno = ""; 2917 2917 $mbox_stream = ""; … … 2920 2920 } 2921 2921 else { 2922 $search = explode(",",$params['condition']); 2922 $search = explode(",",$params['condition']); 2923 2923 } 2924 2924 … … 2938 2938 $filter .= '"'.$filter_array[1].'"'; 2939 2939 } 2940 } 2941 $name_box = mb_convert_encoding(utf8_decode($name_box), "UTF7-IMAP", "ISO_8859-1" ); 2940 } 2941 $name_box = mb_convert_encoding(utf8_decode($name_box), "UTF7-IMAP", "ISO_8859-1" ); 2942 2942 $filter = $this->remove_accents($filter); 2943 2943 //Este bloco tem a finalidade de transformar o login (quando numerico) das pastas compartilhadas em common name … … 2950 2950 } 2951 2951 $folder_name = implode($this->imap_delimiter,$folder_name); 2952 2952 2953 2953 if(!is_resource($mbox_stream)) 2954 2954 $mbox_stream = $this->open_mbox($name_box); 2955 2955 else 2956 2956 imap_reopen($mbox_stream, "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$name_box); 2957 2958 if (preg_match("/^.?\bALL\b/", $filter)){ // Quick Search, note: this ALL isn't the same ALL from imap_search 2959 2957 2958 if (preg_match("/^.?\bALL\b/", $filter)){ // Quick Search, note: this ALL isn't the same ALL from imap_search 2959 2960 2960 $all_criterias = array ("TO","SUBJECT","FROM","CC"); 2961 2961 foreach($all_criterias as $criteria_fixed) 2962 2962 { 2963 2963 $_filter = $criteria_fixed . substr($filter,4); 2964 2964 2965 2965 $search_criteria = imap_search($mbox_stream, $_filter, SE_UID); 2966 2966 2967 2967 if($search_criteria && count($search_criteria) < 50) 2968 2968 { … … 2972 2972 $retorno .= $m_token; 2973 2973 } 2974 } 2975 else if(count($search_criteria) >= 50) 2976 return "many results"; 2974 } 2975 else if(count($search_criteria) >= 50) 2976 return "many results"; 2977 2977 } 2978 2978 } … … 2988 2988 } 2989 2989 if($mbox_stream) 2990 imap_close($mbox_stream); 2991 2990 imap_close($mbox_stream); 2991 2992 2992 return $retorno ? $retorno : "none"; 2993 2993 } 2994 2994 2995 2995 function get_msg($uid_msg,$name_box, $mbox_stream ) 2996 2996 { … … 3014 3014 $from = $header->from[0]->personal; 3015 3015 $ret_msg = $this->decode_string($from) . "--" . $subject . "--". gmdate("d/m/Y",$header ->udate)."--". $this->size_msg($header->Size) ."--". $flag; 3016 return $ret_msg; 3017 } 3016 return $ret_msg; 3017 } 3018 3018 3019 3019 function size_msg($size){ 3020 3020 $var = floor($size/1024); 3021 3021 if($var >= 1){ 3022 return $var." kb"; 3022 return $var." kb"; 3023 3023 }else{ 3024 return $size ." b"; 3024 return $size ." b"; 3025 3025 } 3026 3026 } … … 3049 3049 } 3050 3050 } 3051 3051 3052 3052 function getacl() 3053 3053 { 3054 3054 $this->ldap = new ldap_functions(); 3055 3055 3056 3056 $return = array(); 3057 $mbox_stream = $this->open_mbox(); 3057 $mbox_stream = $this->open_mbox(); 3058 3058 $mbox_acl = imap_getacl($mbox_stream, 'INBOX'); 3059 3059 3060 3060 $i = 0; 3061 3061 foreach ($mbox_acl as $user => $acl) … … 3070 3070 return $return; 3071 3071 } 3072 3072 3073 3073 function setacl($params) 3074 3074 { … … 3076 3076 if (!count($old_users)) 3077 3077 $old_users = array(); 3078 3078 3079 3079 $tmp_array = array(); 3080 3080 foreach ($old_users as $index => $user_info) … … 3083 3083 } 3084 3084 $old_users = $tmp_array; 3085 3085 3086 3086 $users = unserialize($params['users']); 3087 3087 if (!count($users)) 3088 3088 $users = array(); 3089 3089 3090 3090 //$add_share = array_diff($users, $old_users); 3091 3091 $remove_share = array_diff($old_users, $users); … … 3110 3110 } 3111 3111 }*/ 3112 3112 3113 3113 if (count($remove_share)) 3114 3114 { … … 3123 3123 } 3124 3124 } 3125 } 3126 } 3127 3125 } 3126 } 3127 3128 3128 return true; 3129 3129 } 3130 3130 3131 3131 function getaclfromuser($params) 3132 3132 { 3133 3133 $useracl = $params['user']; 3134 3134 3135 3135 $return = array(); 3136 3136 $return[$useracl] = 'false'; 3137 $mbox_stream = $this->open_mbox(); 3137 $mbox_stream = $this->open_mbox(); 3138 3138 $mbox_acl = imap_getacl($mbox_stream, 'INBOX'); 3139 3139 3140 3140 foreach ($mbox_acl as $user => $acl) 3141 3141 { … … 3161 3161 return $mbox_acl[$this->username]; 3162 3162 } 3163 3163 3164 3164 3165 3165 function setaclfromuser($params) … … 3167 3167 $user = $params['user']; 3168 3168 $acl = $params['acl']; 3169 3169 3170 3170 $mbox_stream = $this->open_mbox(); 3171 3171 … … 3190 3190 return true; 3191 3191 } 3192 3192 3193 3193 function download_attachment($msg,$msgno) 3194 3194 { 3195 $array_parts_attachments = array(); 3195 $array_parts_attachments = array(); 3196 3196 $array_parts_attachments['names'] = ''; 3197 3197 include_once("class.imap_attachment.inc.php"); 3198 $imap_attachment = new imap_attachment(); 3199 3198 $imap_attachment = new imap_attachment(); 3199 3200 3200 if (count($msg->fname[$msgno]) > 0) 3201 3201 { … … 3214 3214 $array_parts_attachments['names'] = substr($array_parts_attachments['names'],0,(strlen($array_parts_attachments['names']) - 2)); 3215 3215 return $array_parts_attachments; 3216 } 3216 } 3217 3217 3218 3218 function spam($params) … … 3265 3265 $pdate = date_parse($header->MailDate); 3266 3266 $header->udate += $pdate['zone']*(-60); 3267 3267 3268 3268 if($header->Flagged != "F" && $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_important_flag']) { 3269 3269 $flag = preg_match('/importance *: *(.*)\r/i', 3270 3270 imap_fetchheader($this->mbox, imap_msgno($this->mbox, $msg_number)) 3271 ,$importance); 3271 ,$importance); 3272 3272 $header->Flagged = $flag==0?false:strtolower($importance[1])=="high"?"F":false; 3273 3273 } 3274 3274 3275 3275 return $header; 3276 3276 } … … 3314 3314 //error_log("source: $source\nversao: " . PHP_VERSION, 3, '/tmp/teste.log'); 3315 3315 $source = str_replace(" ", "+", $source,$i); 3316 3316 3317 3317 if (version_compare(PHP_VERSION, '5.2.0', '>=')){ 3318 3318 if(!$source = base64_decode($source,true)) … … 3356 3356 3357 3357 } 3358 3358 3359 3359 //Por Bruno Costa(bruno.vieira-costa@serpro.gov.br - Trata fontes de emails enviados via POST para o servidor por um xmlhttprequest, as partes codificados com 3360 3360 //Base64 os "+" são substituidos por " " no envio e essa função arruma esse efeito.
Note: See TracChangeset
for help on using the changeset viewer.