| | 625 | function _make_url_clickable_cb($matches) { |
|---|
| | 626 | $url = $matches[2]; |
|---|
| | 627 | $url = clean_url($url); |
|---|
| | 628 | if ( empty($url) ) |
|---|
| | 629 | return $matches[0]; |
|---|
| | 630 | error_log($matches[0], 0); |
|---|
| | 631 | return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>"; |
|---|
| | 632 | } |
|---|
| | 633 | |
|---|
| | 634 | function _make_web_ftp_clickable_cb($matches) { |
|---|
| | 635 | $dest = $matches[2]; |
|---|
| | 636 | $dest = 'http://' . $dest; |
|---|
| | 637 | $dest = clean_url($dest); |
|---|
| | 638 | if ( empty($dest) ) |
|---|
| | 639 | return $matches[0]; |
|---|
| | 640 | |
|---|
| | 641 | return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>"; |
|---|
| | 642 | } |
|---|
| | 643 | |
|---|
| | 644 | function _make_email_clickable_cb($matches) { |
|---|
| | 645 | $email = $matches[2] . '@' . $matches[3]; |
|---|
| | 646 | return $matches[1] . "<a href=\"mailto:$email\">$email</a>"; |
|---|
| | 647 | } |
|---|
| | 648 | |
|---|
| 628 | | $ret = preg_replace( |
|---|
| 629 | | array( |
|---|
| 630 | | '#([\s>])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is', |
|---|
| 631 | | '#([\s>])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is', |
|---|
| 632 | | '#([\s>])([a-z0-9\-_.]+)@([^,< \n\r]+)#i'), |
|---|
| 633 | | array( |
|---|
| 634 | | '$1<a href="$2" rel="nofollow">$2</a>', |
|---|
| 635 | | '$1<a href="http://$2" rel="nofollow">$2</a>', |
|---|
| 636 | | '$1<a href="mailto:$2@$3">$2@$3</a>'),$ret); |
|---|
| | 652 | $ret = preg_replace_callback('#([\s>])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_url_clickable_cb', $ret); |
|---|
| | 653 | $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_web_ftp_clickable_cb', $ret); |
|---|
| | 654 | $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret); |
|---|