- Timestamp:
- 07/18/11 13:09:29 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/inc/class.imap_functions.inc.php
r4781 r4784 1218 1218 $content = str_replace(array('<', '>'), array(' #$<$# ', ' #$>$# '), $content); 1219 1219 $content = htmlentities($content); 1220 $ content = $this ->replace_links($content);1220 $this->replace_links($content); 1221 1221 $content = str_replace(array(' #$<$# ', ' #$>$# '), array('<', '>'), $content); 1222 1222 $content = '<pre>' . $content . '</pre>'; … … 1523 1523 1524 1524 1525 function replace_links_callback($matches) 1526 { 1527 if($matches[3]) 1528 $pref = $matches[3]; 1529 else 1530 $pref = $matches[3] = 'http'; 1531 1532 return '<a href="'.$pref.'://'.$matches[4].$matches[5].'" target="_blank">'.$matches[4].$matches[5].'</a>'; 1533 } 1534 1535 1525 1536 /** 1526 1537 * @license http://www.gnu.org/copyleft/gpl.html GPL … … 1530 1541 function replace_links(&$body) 1531 1542 { 1532 // Domains and IPs addresses found in the text and which is not a link yet should be replaced by one. 1533 // See more informations in www.iana.org 1534 $octets = array( 1535 'first' => '(2[0-3][0-9]|1[0-9]{2}|[1-9][0-9]?)', 1536 'middle' => '(25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})', 1537 'last' => '(25[0-4]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)' 1538 ); 1539 1540 $ip = "\b{$octets[ 'first' ]}\.({$octets[ 'middle' ]}\.){2}{$octets[ 'last' ]}\b"; 1541 1542 $top_level_domains = '(\.(ac|ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|as|asia|at|au|aw|ax|az|' 1543 . 'ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bl|bm|bn|bo|br|bs|bt|bv|bw|by|bz|' 1544 . 'ca|cat|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cu|cv|cx|cy|cz|' 1545 . 'de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|' 1546 . 'ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|' 1547 . 'hk|hm|hn|hr|ht|hu|id|ie|il|im|in|info|int|io|iq|ir|is|it|je|jm|jo|jobs|jp|' 1548 . 'ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|' 1549 . 'ma|mc|md|me|mf|mg|mh|mil|mk|ml|mm|mn|mo|mobi|mp|mq|mr|ms|mt|mu|museum|' 1550 . 'mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|' 1551 . 'pa|pe|pf|pg|ph|pk|pl|pm|pn|pro|ps|pt|pw|py|qa|re|ro|rs|ru|rw|' 1552 . 'sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|' 1553 . 'tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|travel|tt|tv|tw|tz|' 1554 . 'ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw))+\b'; 1555 1556 $path = '(?>\/[\w\d\/\.\'\(\)\-\+~?!&#@$%|:;,*=_]+)?'; 1557 $port = '(?>:\d{2,5})?'; 1558 $domain = '(?>[\w\d_\-]+)'; 1559 $subdomain = "(?>{$domain}\.)*"; 1560 $protocol = '(?>(http|ftp)(s)?:\/\/)?'; 1561 $url = "(?>{$protocol}((?>{$subdomain}{$domain}{$top_level_domains}|{$ip}){$port}{$path}))"; 1562 1563 $pattern = "/(<\w[^>]+|[\/\"'@=])?{$url}/"; 1564 1565 ini_set( 'pcre.backtrack_limit', 300000 ); 1566 /* 1567 // PHP 5.3 1568 $replace = function( $matches ) 1569 { 1570 if ( $matches[ 1 ] ) 1571 return $matches[ 0 ]; 1572 1573 $url = ( $matches[ 2 ] ) ? $matches[ 2 ] : 'http'; 1574 $url .= "{$matches[ 3 ]}://{$matches[ 4 ]}"; 1575 return "<a href=\"{$url}\" target=\"_blank\">{$matches[ 4 ]}</a>"; 1576 }; 1577 $body = preg_replace_callback( $pattern, $replace, $body ); 1578 */ 1579 1580 // PHP 5.2.x - Remover assim que possível 1581 $body = preg_replace_callback( $pattern, 1582 create_function( 1583 '$matches', 1584 'if ( $matches[ 1 ] ) return $matches[ 0 ];' 1585 . '$url = ( $matches[ 2 ] ) ? $matches[ 2 ] : "http";' 1586 . '$url .= "{$matches[ 3 ]}://{$matches[ 4 ]}";' 1587 . 'return "<a href=\"{$url}\" target=\"_blank\">{$matches[ 4 ]}</a>";' 1588 ), $body 1589 ); 1590 ini_set( 'pcre.backtrack_limit', 100000 ); 1591 1592 // E-mail address in the text should create a new e-mail on ExpressoMail 1593 $pattern = '/( |<|<|>)([A-Za-z0-9\.~?\/_=#\-]*@[A-Za-z0-9\.~?\/_=#\-]*)( |>|>|<)/im'; 1594 $replacement = '$1<a href="mailto:$2">$2</a>$3'; 1595 $body = preg_replace( $pattern, $replacement, $body ); 1596 1597 return $body; 1598 } 1543 // Trata urls do tipo aaaa.bbb.empresa 1544 // Usadas na intranet. 1545 $pattern = '/(?<=[\s|(<br>)|\n|\r|;])(((http|https|ftp|ftps)?:\/\/((?:[\w]\.?)+(?::[\d]+)?[:\/.\-~&=?%;@#,+\w]*))|((?:www?\.)(?:\w\.?)*(?::\d+)?[\:\/\w.\-~&=?%;@+]*))/i'; 1546 $replacement = '<a href="://$4$5" target="_blank">$4$5</a>'; 1547 $body = preg_replace_callback($pattern,array( &$this, 'replace_links_callback'), $body); 1548 // E-mail address in the text should create a new e-mail on ExpressoMail 1549 $pattern = '/( |<|<|>)([A-Za-z0-9\.~?\/_=#\-]*@[A-Za-z0-9\.~?\/_=#\-]*)( |>|>|<)/im'; 1550 $replacement = '$1<a href="mailto:$2">$2</a>$3'; 1551 $body = preg_replace($pattern, $replacement, $body); 1552 1553 } 1599 1554 1600 1555 function get_signature($msg, $msg_number, $msg_folder)
Note: See TracChangeset
for help on using the changeset viewer.