Changeset 345
- Timestamp:
- 07/04/08 17:14:41 (16 years ago)
- Location:
- trunk/expressoMail1_2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/inc/class.imap_functions.inc.php
r325 r345 692 692 693 693 function replace_links($body) { 694 // Search for links,then open the link in new window. 695 //$body = @ereg_replace('[a-zA-Z]+://(([.]?[a-zA-Z0-9_/-])*)', '<a href="\\0" title="'.$this->functions->getLang("Open in New Window").'">\\0</a>',$body); 696 //Search for emails, then open a new message tab. 697 //$body = @ereg_replace('[a-zA-Z0-9!#$%&\'*+/=?^_`{|}~]+@([.]?[a-zA-Z0-9_/-])*', '<a title=\''.$this->functions->getLang("New Message").' -> \\0\'" onclick="Element(\'msg_number\').value=\'\\0\';new_message(\'new\',\'null\')" href="#">\\0</a>',$body); 698 //$matches = array(); 694 $matches = array(); 699 695 // Verify exception. 700 //@preg_match("/<a href=\"notes:\/\/\//",$body,$matches);696 @preg_match("/<a href=\"notes:\/\/\//",$body,$matches); 701 697 // It no has exception,then open the link in new window. 702 /*if(!count($matches)){ 703 $body = @eregi_replace("<a (.*) href=", "<a \\1 target='_blank' href=", $body); 704 $body = @str_replace("<a href=", "<a target='_blank' href=", $body); 705 $body = @eregi_replace("target=\"\"", "target='_blank'", $body); 706 $body = @eregi_replace("target=''", "target='_blank'", $body); 707 }*/ 708 $body = 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); 709 return $body; 698 if(count($matches)) 699 return $body; 700 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); 710 701 } 711 702 … … 790 781 $return = array(); 791 782 792 if ($params['get_previous_msg']) 783 if ($params['get_previous_msg']){ 793 784 $return['previous_msg'] = $this->get_info_previous_msg($params); 785 // Fix problem in unserialize function JS. 786 $return['previous_msg']['body'] = str_replace(array('{','}'), array('{','}'), $return['previous_msg']['body']); 787 } 794 788 795 789 //$mbox_stream = $this->open_mbox($folder); … … 937 931 } 938 932 939 function get_folders_list( )933 function get_folders_list($params = null) 940 934 { 941 935 $mbox_stream = $this->open_mbox(); … … 967 961 } 968 962 } 969 963 970 964 $tmp_folder_parent = implode($this->imap_delimiter, $tmp_folder_parent); 971 965 $result[$i]['folder_parent'] = $tmp_folder_parent == 'INBOX' ? '' : $tmp_folder_parent; … … 992 986 } 993 987 994 if($mbox_stream) 995 imap_close($mbox_stream); 996 return array_merge($result2); 988 $current_folder = "INBOX"; 989 if($params && $params['folder']) 990 $current_folder = $params['folder']; 991 return array_merge($result2, $this->get_quota(array(folder_id => $current_folder))); 997 992 } 998 993 … … 1146 1141 //////////////////////////////////////////////////////////////////////////////////////////////////// 1147 1142 // Build CID for embedded Images!!! 1148 $pattern = '/src="([^"]*?show_embedded_attach.php\?msg_folder=(.+)?& amp;msg_num=(.+)?&msg_part=(.+)?)"/isU';1143 $pattern = '/src="([^"]*?show_embedded_attach.php\?msg_folder=(.+)?&(amp;)?msg_num=(.+)?&(amp;)?msg_part=(.+)?)"/isU'; 1149 1144 $cid_imgs = ''; 1150 1145 $name_cid_files = array(); 1151 1146 preg_match_all($pattern,$mail->Body,$cid_imgs,PREG_PATTERN_ORDER); 1152 1147 $cid_array = array(); 1153 foreach($cid_imgs[ 4] as $j => $val){1154 if ( !array_key_exists($cid_imgs[ 3][$j].$val, $cid_array) )1148 foreach($cid_imgs[6] as $j => $val){ 1149 if ( !array_key_exists($cid_imgs[4][$j].$val, $cid_array) ) 1155 1150 { 1156 $cid_array[$cid_imgs[ 3][$j].$val] = base_convert(microtime(), 10, 36);1151 $cid_array[$cid_imgs[4][$j].$val] = base_convert(microtime(), 10, 36); 1157 1152 } 1158 $cid = $cid_array[$cid_imgs[ 3][$j].$val];1153 $cid = $cid_array[$cid_imgs[4][$j].$val]; 1159 1154 $mail->Body = str_replace($cid_imgs[1][$j], "cid:".$cid, $mail->Body); 1160 1155 1161 if ($msg_uid != $cid_imgs[ 3][$j]) // The image isn't in the same mail?1156 if ($msg_uid != $cid_imgs[4][$j]) // The image isn't in the same mail? 1162 1157 { 1163 $fileContent = $this->get_forwarding_attachment($cid_imgs[2][$j], $cid_imgs[ 3][$j], $cid_imgs[4][$j], 'base64');1158 $fileContent = $this->get_forwarding_attachment($cid_imgs[2][$j], $cid_imgs[4][$j], $cid_imgs[6][$j], 'base64'); 1164 1159 $fileName = "image_".($j).".jpg"; 1165 1160 $fileCode = "base64"; … … 1168 1163 else 1169 1164 { 1170 $attach_img = $forwarding_attachments[$cid_imgs[ 4][$j]-2];1165 $attach_img = $forwarding_attachments[$cid_imgs[6][$j]-2]; 1171 1166 $file_description = unserialize(rawurldecode($attach_img)); 1172 1167 … … 1178 1173 $fileCode = $file_description[4]; 1179 1174 $fileType = $this->get_file_type($file_description[2]); 1180 unset($forwarding_attachments[$cid_imgs[ 4][$j]-2]);1175 unset($forwarding_attachments[$cid_imgs[6][$j]-2]); 1181 1176 } 1182 1177 $tempDir = ini_get("session.save_path"); … … 1442 1437 // Caso estejamos no box principal, nï¿œo ï¿œ necessï¿œrio pegar a informaᅵᅵo da mensagem anterior. 1443 1438 if (($params['get_previous_msg']) && ($params['border_ID'] != 'null') && ($params['border_ID'] != '')) 1439 { 1444 1440 $return['previous_msg'] = $this->get_info_previous_msg($params); 1441 // Fix problem in unserialize function JS. 1442 $return['previous_msg']['body'] = str_replace(array('{','}'), array('{','}'), $return['previous_msg']['body']); 1443 } 1445 1444 1446 1445 $mbox_stream = $this->open_mbox($folder); … … 1789 1788 function htmlspecialchars_encode($str) 1790 1789 { 1791 /*// replace ' and " with htmlspecialchars */ 1792 $str = ereg_replace('&', '&', $str); 1793 // any ampersand & that ia already in a "&" should NOT be encoded 1794 //$str = preg_replace("/&(?![:alnum:]*;)/", "&", $str); 1795 $str = ereg_replace('"', '"', $str); 1796 $str = ereg_replace('\'', ''', $str); 1797 1798 $str = ereg_replace('<', '<', $str); 1799 $str = ereg_replace('>', '>', $str); 1800 // these { and } must be html encoded or else they conflict with the template system 1801 $str = str_replace("{", '{', $str); 1802 $str = str_replace("}", '}', $str); 1803 return $str; 1790 return str_replace( array('&', '"','\'','<','>','{','}'), array('&','"',''','<','>','{','}'), $str); 1804 1791 } 1805 1792 function htmlspecialchars_decode($str) 1806 1793 { 1807 /*// replace ' and " with htmlspecialchars */ 1808 $str = ereg_replace('&','&', $str); 1809 // any ampersand & that ia already in a "&" should NOT be encoded 1810 //$str = preg_replace("/&(?![:alnum:]*;)/", "&", $str); 1811 $str = ereg_replace('"', '"', $str); 1812 $str = ereg_replace(''', '\'', $str); 1813 $str = ereg_replace('<','<', $str); 1814 $str = ereg_replace('>', '>', $str); 1815 // these { and } must be html encoded or else they conflict with the template system 1816 $str = str_replace('{', "{", $str); 1817 $str = str_replace( '}',"}", $str); 1818 return $str; 1794 return str_replace( array('&','"',''','<','>','{','}'), array('&', '"','\'','<','>','{','}'), $str); 1819 1795 } 1820 1796 … … 1925 1901 1926 1902 function get_quota($params){ 1927 $folder_id = $params['folder_id']; 1903 // folder_id = user/{uid} for shared folders 1904 if(substr($params['folder_id'],0,5) != 'INBOX' && preg_match('/user\\'.$this->imap_delimiter.'/i', $params['folder_id'])){ 1905 $array_folder = explode($this->imap_delimiter,$params['folder_id']); 1906 $folder_id = "user".$this->imap_delimiter.$array_folder[1]; 1907 } 1908 // folder_id = INBOX for inbox folders 1909 else 1910 $folder_id = "INBOX"; 1911 1928 1912 if(!$this->mbox) 1929 1913 $this->mbox = $this->open_mbox(); 1930 1914 1931 1915 $quota = imap_get_quotaroot($this->mbox, $folder_id); 1932 1916 if($this->mbox) … … 1965 1949 $toaddress = $params['notificationto']; 1966 1950 1967 $subject = 'Confirma ᅵᅵo de leitura: ' . $params['subject'];1951 $subject = 'Confirmação de leitura: ' . $params['subject']; 1968 1952 $body = 'Sua mensagem: ' . $params['subject'] . '<br>'; 1969 1953 $body .= 'foi lida por: ' . $_SESSION['phpgw_info']['expressomail']['user']['fullname'] . ' <' . $_SESSION['phpgw_info']['expressomail']['user']['email'] . '> em ' . date("d/m/Y H:i"); … … 2112 2096 function remove_accents($string) { 2113 2097 return strtr($string, 2114 "? ï¿œ??ï¿œ?ï¿œ?ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵ?ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵ?ᅵᅵ?ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵ?ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵ?ᅵᅵᅵᅵ",2098 "?Ó??ó?Ý?úÁÀÃÂÄÇÉÈÊËÍÌ?ÎÏÑÕÔÓÒÖÚÙ?ÛÜ?áàãâäçéèêëíì?îïñóòõôöúù?ûüýÿ", 2115 2099 "SOZsozYYuAAAAACEEEEIIIIINOOOOOUUUUUsaaaaaceeeeiiiiinooooouuuuuyy"); 2116 2100 } … … 2321 2305 //No caso de se tratar da caixa do proprio usuario logado, utiliza a sintaxe abaixo 2322 2306 if(substr($user,0,4) != 'user') 2323 2307 $mbox_acl = imap_getacl($mbox_stream, 'user'.$this->imap_delimiter.$user); 2324 2308 else 2325 2309 $mbox_acl = imap_getacl($mbox_stream, $user); … … 2390 2374 $msg = $header . $body; 2391 2375 $email = $_SESSION['phpgw_info']['expressomail']['user']['email']; 2392 //$tmp_file = $tmp_dir . "msg." . $email . '.'. $msg_number . time(); 2393 // maybe we can get it faster with regex, don't know how :'( 2394 $signature = trim(substr($header, strpos($header, 'X-DSPAM-Signature:') + 18)); 2376 $username = $this->username; 2395 2377 strtok($email, '@'); 2396 2378 $domain = strtok('@'); 2397 2379 2380 //Encontrar a assinatura do dspam no cabecalho 2381 $v = explode("\r\n", $header); 2382 foreach ($v as $linha){ 2383 if (eregi("^X-DSPAM-Signature", $linha)) { 2384 2385 $args = explode(" ",$linha); 2386 $signature = $args[1]; 2387 } 2388 } 2389 2398 2390 // feed dspam 2399 if ($is_spam) 2400 $cmd = str_replace( 2401 array('##EMAIL##', '##USERNAME##', '##DOMAIN##', '##SIGNATURE##'), 2402 array($email, $this->username, $domain, $signature), $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_command_for_spam'] 2403 ); 2404 else 2405 $cmd = str_replace( 2406 array('##EMAIL##', '##USERNAME##', '##DOMAIN##', '##SIGNATURE##'), 2407 array($email, $this->username, $domain, $signature), $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_command_for_ham'] 2408 ); 2409 2391 switch($is_spam){ 2392 case 'true': $cmd = $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_command_for_spam']; break; 2393 case 'false': $cmd = $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_command_for_ham']; break; 2394 } 2395 $tags = array('##EMAIL##', '##USERNAME##', '##DOMAIN##', '##SIGNATURE##'); 2396 $cmd = str_replace($tags,array($email,$username,$domain,$signature),$cmd); 2410 2397 system($cmd); 2411 2412 2398 } 2413 2399 imap_close($mbox_stream); -
trunk/expressoMail1_2/js/TreeShow.js
r320 r345 29 29 tree_folders.getNodeById(get_current_folder())._select(); 30 30 } 31 cExecute ("$this.imap_functions.get_folders_list ", handler_update_folders);31 cExecute ("$this.imap_functions.get_folders_list&folder="+current_folder, handler_update_folders); 32 32 } 33 33 -
trunk/expressoMail1_2/js/draw_api.js
r325 r345 10 10 if (Element('dftree_tree_folders')){ 11 11 var update_tree_folders = function(data){ 12 build_quota(data); 12 13 for (var i=0; i<data.length; i++){ 13 14 var folder_unseen = Element('dftree_'+data[i].folder_id+'_unseen'); … … 34 35 // } 35 36 Element('new_m').innerHTML = data[i].folder_unseen ? '<font color="RED">'+data[i].folder_unseen+'</font>' : 0; 36 draw_paging(Element('tot_m').innerHTML); 37 draw_paging(Element('tot_m').innerHTML); 37 38 } 38 39 } 39 40 } 40 cExecute ("$this.imap_functions.get_folders_list ", update_tree_folders);41 cExecute ("$this.imap_functions.get_folders_list&folder="+current_folder, update_tree_folders); 41 42 return; 42 43 } … … 114 115 draw_tree_folders(data); 115 116 if(data) { 116 update_quota('INBOX');117 build_quota(data); 117 118 var f_unseen = Element('dftree_'+get_current_folder()+'_unseen'); 118 119 if(f_unseen && f_unseen.innerHTML) … … 148 149 Element("tot_m").innerHTML = data.num_msgs; 149 150 update_menu(); 150 update_quota(folder);151 151 return true; 152 152 } … … 157 157 158 158 function open_folder(folder, folder_name){ 159 if (get_current_folder() 159 if (get_current_folder()!= folder) { 160 160 current_folder = folder; 161 161 var handler_draw_box = function(data){ 162 if (!verify_session(data)) 163 return; 164 Element("border_id_0").innerHTML = " " + lang_folder(folder_name) + ' <font face="Verdana" size="1" color="#505050">[<span id="new_m"> </span> / <span id="tot_m"></span>]</font>'; 165 draw_box(data, current_folder); 166 draw_paging(data.num_msgs); 167 Element("tot_m").innerHTML = data.num_msgs; 168 update_menu(); 169 update_quota(folder); 170 alternate_border(0); 171 } 172 cExecute("$this.imap_functions.get_range_msgs2&folder=" + current_folder + "&msg_range_begin=1&msg_range_end=" + preferences.max_email_per_page + "&sort_box_type=" + sort_box_type + "&search_box_type=" + search_box_type + "&sort_box_reverse=" + sort_box_reverse + "", handler_draw_box); 162 if(!verify_session(data)) 163 return false; 164 numBox++; 165 create_border(folder_name,numBox.toString()); 166 draw_box(data, current_folder, false); 167 alternate_border(numBox); 168 return true; 169 } 170 cExecute ("$this.imap_functions.get_range_msgs2&folder="+current_folder+"&msg_range_begin=1&msg_range_end="+preferences.max_email_per_page+"&sort_box_type="+sort_box_type+ "&search_box_type="+ search_box_type +"&sort_box_reverse="+sort_box_reverse+"", handler_draw_box); 173 171 } 174 172 else 175 alternate_border(0); 173 alternate_border(numBox); 174 return true; 176 175 } 177 176 … … 1845 1844 } 1846 1845 else{ 1847 div.innerHTML = null; 1846 if(div) 1847 div.innerHTML = null; 1848 1848 value = data['quota_percent']; 1849 1849 q_used = data['quota_used']; … … 1914 1914 } 1915 1915 1916 function update_quota(folder_id){ 1916 function update_quota(folder_id){ 1917 1917 cExecute ("$this.imap_functions.get_quota&folder_id="+folder_id,build_quota); 1918 1918 } -
trunk/expressoMail1_2/js/main.js
r336 r345 160 160 if(data.new_msgs > 0){ 161 161 Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) + parseInt(data.new_msgs); //refresh tab title 162 update_quota( );162 update_quota(get_current_folder()); 163 163 } 164 164 } … … 250 250 var main_list = Element("tbody_resultsearch_"+border_id.substr(18)).childNodes; 251 251 for (j = 0; j < main_list.length; j++) { 252 var check_box = Element("check_box_message_"+main_list[j].id);252 var check_box = main_list[j].firstChild.firstChild; 253 253 if(check_box && check_box.checked) { 254 254 selected_messages += main_list[j].id + ','; … … 321 321 return false; 322 322 } 323 324 323 325 324 Element('chk_box_select_all_messages').checked = false; 326 mail_msg = Element("tbody_box"); 327 //mail_msg = document.getElementById("divScrollMain_"+numBox).firstChild.firstChild; 325 326 mail_msg = ( Element("divScrollMain_"+numBox) ) ? Element("divScrollMain_"+numBox).firstChild.firstChild : Element("divScrollMain_0").firstChild.firstChild; 327 if (! mail_msg) 328 mail_msg = Element("tbody_box"); 328 329 data.msgs_number = data.msgs_number.split(","); 329 330 330 var msg_to_delete; 331 all_search_msg = msgs_number.split(','); 331 var msg_to_delete; 332 if( typeof(msgs_number) == 'string' ) 333 all_search_msg = msgs_number.split(','); 334 else if( typeof(msgs_number) == 'number') 335 all_search_msg = msgs_number; 332 336 for (var i=0; i <= all_search_msg.length; i++) 333 337 { … … 390 394 391 395 function get_selected_messages(){ 392 main = Element("tbody_box"); 393 // main = document.getElementById("divScrollMain_"+numBox).firstChild.firstChild; 396 main = document.getElementById("divScrollMain_"+numBox).firstChild.firstChild; 397 if (! main) 398 main = Element("tbody_box"); 394 399 395 400 // Get all TR (messages) in tBody. … … 516 521 } 517 522 else{ 518 523 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'></body></html>"); 519 524 } 520 525 body.contentWindow.document.close(); … … 545 550 } 546 551 else { 547 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>" + block_quoted_body +"</body></html>");552 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>"+block_quoted_body+"</body></html>"); 548 553 } 549 554 body.contentWindow.document.close(); … … 590 595 } 591 596 else { 592 597 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'></body></html>"); 593 598 } 594 599 body.contentWindow.document.close(); … … 635 640 } 636 641 else { 637 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>" + block_quoted_body +"</body></html>");642 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>"+block_quoted_body+"</body></html>"); 638 643 } 639 644 body.contentWindow.document.close(); … … 683 688 } 684 689 else { 685 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>" + make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc) +"</body></html>");690 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>"+make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc)+"</body></html>"); 686 691 } 687 692 body.contentWindow.document.close(); … … 716 721 } 717 722 else { 718 723 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'></body></html>"); 719 724 } 720 725 body.contentWindow.document.close();
Note: See TracChangeset
for help on using the changeset viewer.