Changeset 345 for trunk/expressoMail1_2/inc/class.imap_functions.inc.php
- Timestamp:
- 07/04/08 17:14:41 (16 years ago)
- File:
-
- 1 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);
Note: See TracChangeset
for help on using the changeset viewer.