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