Changeset 5119 for branches/2.3
- Timestamp:
- 10/26/11 09:08:59 (12 years ago)
- Location:
- branches/2.3/expressoMail1_2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.3/expressoMail1_2/inc/class.imap_functions.inc.php
r5107 r5119 1371 1371 } 1372 1372 1373 function replace_links ( $body )1373 function replace_links_aux( $body ) 1374 1374 { 1375 // Trata urls do tipo aaaa.bbb.empresa 1376 // Usadas na intranet. 1377 // Substitui a função logo a seguir...(replace_links_OLD). 1378 $pattern = '/(?<=[\s|(<br>)|\n|\r|;])(((http|https|ftp|ftps)?:\/\/((?:[\w]\.?)+(?::[\d]+)?[:\/.\-~&=?%;@#,+\w]*))|((?:www?\.)(?:\w\.?)*(?::\d+)?[\:\/\w.\-~&=?%;@+]*))/i'; 1375 // Trata urls do tipo aaaa.bbb.empresa 1376 $pattern = '/(?<=[\s|(<br>)|\n|\r|;])(((http|https|ftp|ftps)?:\/\/((?:[\w]\.?)+(?::[\d]+)?[:\/.\-~&=?%;@#,+\w]*))|((?:www?\.)(?:\w\.?)*(?::\d+)?[\:\/\w.\-~&=?%;@+]*))/i'; 1379 1377 $replacement = '<a href="$3://$4$5" target="_blank">$4$5</a>'; 1380 1378 $body = preg_replace($pattern, $replacement, $body); 1381 // E-mail address in the text should create a new e-mail on ExpressoMail 1382 $pattern = '/( |<|<|>)([A-Za-z0-9\.~?\/_=#\-]*@[A-Za-z0-9\.~?\/_=#\-]*)( |>|>|<)/im'; 1383 $replacement = '$1<a href="mailto:$2">$2</a>$3'; 1384 $body = preg_replace( $pattern, $replacement, $body ); 1379 $body = preg_replace('/href=":\/\//', 'href="http://', $body); 1380 1381 // Trata tags <a href=" sem protocolo.... 1382 $body_aux = explode('<a href="',$body); 1383 $body = $body_aux[0]; 1384 $protocolos = array('http','https','ftp','ftps'); 1385 for ($i=1;$i<count($body_aux);$i++) 1386 { 1387 $flgproto = false; 1388 foreach($protocolos as $protocolo) 1389 { 1390 if(substr($body_aux[$i],0,strlen($protocolo)) == $protocolo) 1391 { 1392 $flgproto = true; 1393 break; 1394 } 1395 } 1396 if(!$flgproto) 1397 { 1398 $body = $body . '<a target="_blanck" href="http://' . $body_aux[$i]; 1399 } 1400 else 1401 { 1402 $body = $body . '<a href="' . $body_aux[$i]; 1403 } 1404 } 1385 1405 return $body; 1386 1406 } 1387 1407 1388 function replace_links _OLD( $body )1389 { 1390 // Domains and IPs addresses found in the text and which is not a link yet should be replaced by one. 1391 // See more informations in www.iana.org 1392 $octets = array( 1393 'first' => '(2[0-3][0-9]|1[0-9]{2}|[1-9][0-9]?)', 1394 'middle' => '(25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})', 1395 'last' => '(25[0-4]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)' 1396 ); 1397 1398 $ip = "\b{$octets[ 'first' ]}\.({$octets[ 'middle' ]}\.){2}{$octets[ 'last' ]}\b"; 1399 1400 $top_level_domains = '(\.(ac|ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|as|asia|at|au|aw|ax|az|' 1401 . 'ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bl|bm|bn|bo|br|bs|bt|bv|bw|by|bz|' 1402 . 'ca|cat|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cu|cv|cx|cy|cz|' 1403 . 'de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|' 1404 . 'ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|' 1405 . 'hk|hm|hn|hr|ht|hu|id|ie|il|im|in|info|int|io|iq|ir|is|it|je|jm|jo|jobs|jp|' 1406 . 'ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|' 1407 . 'ma|mc|md|me|mf|mg|mh|mil|mk|ml|mm|mn|mo|mobi|mp|mq|mr|ms|mt|mu|museum|' 1408 . 'mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|' 1409 . 'pa|pe|pf|pg|ph|pk|pl|pm|pn|pro|ps|pt|pw|py|qa|re|ro|rs|ru|rw|' 1410 . 'sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|' 1411 . 'tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|travel|tt|tv|tw|tz|' 1412 . 'ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw))+\b'; 1413 1414 $path = '(?>\/[\w\d\/\.\'\(\)\-\+~?!&#@$%|:;,*=_]+)?'; 1415 $port = '(?>:\d{2,5})?'; 1416 $domain = '(?>[\w\d_\-]+)'; 1417 $subdomain = "(?>{$domain}\.)*"; 1418 $protocol = '(?>(http|ftp)(s)?:\/\/)?'; 1419 $url = "(?>{$protocol}((?>{$subdomain}{$domain}{$top_level_domains}|{$ip}){$port}{$path}))"; 1408 function replace_links( $body ) 1409 { 1410 // Domains and IPs addresses found in the text and which is not a link yet should be replaced by one. 1411 // See more informations in www.iana.org 1412 $octets = array( 1413 'first' => '(2[0-3][0-9]|1[0-9]{2}|[1-9][0-9]?)', 1414 'middle' => '(25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})', 1415 'last' => '(25[0-4]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)' 1416 ); 1417 1418 $ip = "\b{$octets[ 'first' ]}\.({$octets[ 'middle' ]}\.){2}{$octets[ 'last' ]}\b"; 1419 1420 $top_level_domains = '(\.(ac|ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|as|asia|at|au|aw|ax|az|' 1421 . 'ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bl|bm|bn|bo|br|bs|bt|bv|bw|by|bz|' 1422 . 'ca|cat|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cu|cv|cx|cy|cz|' 1423 . 'de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|' 1424 . 'ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|' 1425 . 'hk|hm|hn|hr|ht|hu|id|ie|il|im|in|info|int|io|iq|ir|is|it|je|jm|jo|jobs|jp|' 1426 . 'ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|' 1427 . 'ma|mc|md|me|mf|mg|mh|mil|mk|ml|mm|mn|mo|mobi|mp|mq|mr|ms|mt|mu|museum|' 1428 . 'mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|' 1429 . 'pa|pe|pf|pg|ph|pk|pl|pm|pn|pro|ps|pt|pw|py|qa|re|ro|rs|ru|rw|' 1430 . 'sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|' 1431 . 'tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|travel|tt|tv|tw|tz|' 1432 . 'ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw))+\b'; 1433 1434 $path = '(?>\/[\w\d\/\.\'\(\)\-\+~?!&#@$%|:;,*=_]+)?'; 1435 $port = '(?>:\d{2,5})?'; 1436 $domain = '(?>[\w\d_\-]+)'; 1437 $subdomain = "(?>{$domain}\.)*"; 1438 $protocol = '(?>(http|ftp)(s)?:\/\/)?'; 1439 $url = "(?>{$protocol}((?>{$subdomain}{$domain}{$top_level_domains}|{$ip}){$port}{$path}))"; 1420 1440 1421 1441 $pattern = "/(<\w[^>]+|[\/\"'@=])?{$url}/"; 1422 ini_set( 'pcre.backtrack_limit', 300000 ); 1423 1424 /* 1425 // PHP 5.3 1426 $replace = function( $matches ) 1427 { 1428 if ( $matches[ 1 ] ) 1429 return $matches[ 0 ]; 1430 1431 $url = ( $matches[ 2 ] ) ? $matches[ 2 ] : 'http'; 1432 $url .= "{$matches[ 3 ]}://{$matches[ 4 ]}"; 1433 return "<a href=\"{$url}\" target=\"_blank\">{$matches[ 4 ]}</a>"; 1434 }; 1435 $body = preg_replace_callback( $pattern, $replace, $body ); 1436 */ 1437 1438 // PHP 5.2.x - Remover assim que possível 1439 $body = preg_replace_callback( $pattern, 1440 create_function( 1441 '$matches', 1442 'if ( $matches[ 1 ] ) return $matches[ 0 ];' 1442 ini_set( 'pcre.backtrack_limit', 300000 ); 1443 1444 /* 1445 // PHP 5.3 1446 $replace = function( $matches ) 1447 { 1448 if ( $matches[ 1 ] ) 1449 return $matches[ 0 ]; 1450 1451 $url = ( $matches[ 2 ] ) ? $matches[ 2 ] : 'http'; 1452 $url .= "{$matches[ 3 ]}://{$matches[ 4 ]}"; 1453 return "<a href=\"{$url}\" target=\"_blank\">{$matches[ 4 ]}</a>"; 1454 }; 1455 $body = preg_replace_callback( $pattern, $replace, $body ); 1456 */ 1457 1458 // PHP 5.2.x - Remover assim que possível 1459 $body = preg_replace_callback( $pattern, 1460 create_function( 1461 '$matches', 1462 'if ( $matches[ 1 ] ) return $matches[ 0 ];' 1443 1463 . '$url = ( $matches[ 2 ] ) ? $matches[ 2 ] : "http";' 1444 1464 . '$url .= "{$matches[ 3 ]}://{$matches[ 4 ]}";' … … 1446 1466 ), $body 1447 1467 ); 1448 ini_set( 'pcre.backtrack_limit', 100000 ); 1468 ini_set( 'pcre.backtrack_limit', 100000 ); 1449 1469 // E-mail address in the text should create a new e-mail on ExpressoMail 1450 $pattern = '/( |<|<|>)([A-Za-z0-9\.~?\/_=#\-]*@[A-Za-z0-9\.~?\/_=#\-]*)( |>|>|<)/im'; 1470 $pattern = '/( |<|<|>)([A-Za-z0-9\.~?\/_=#\-]*@[A-Za-z0-9\.~?\/_=#\-]*)( |>|>|<)/im'; 1451 1471 $replacement = '$1<a href="mailto:$2">$2</a>$3'; 1452 1472 $body = preg_replace( $pattern, $replacement, $body ); 1453 1473 1454 return $body;1474 return $this->replace_links_aux($body); 1455 1475 } 1456 1476 -
branches/2.3/expressoMail1_2/js/rich_text_editor.js
r5006 r5119 432 432 } 433 433 } 434 var szURL = prompt(get_lang('Enter with link URL: '), 'http://');434 var szURL = prompt(get_lang('Enter with link URL: '), 'http://'); 435 435 if ((szURL != null) && (szURL != "")){ 436 if (szURL.indexOf('://') == -1) szURL = 'http://' + szURL; 436 437 this.editorCommand("CreateLink", szURL); 437 438 }
Note: See TracChangeset
for help on using the changeset viewer.