| 48 | | /** |
| 49 | | * We need a callback because for some obscure reason the /ie modifier wouldnt work |
| 50 | | * in preg_replace alone. This basically formats the output |
| 51 | | */ |
| 52 | | function __filter_callback($matches) { |
| 53 | | $ret = preg_match("/^(http:\/\/)?([^\/]+)/i", $matches[1], $outmatches); |
| 54 | | if ($outmatches && isset ($outmatches[2])) { |
| 55 | | return " <a href=\"". $matches[1]."\">[" . $outmatches[2] . "]</a> "; |
| 56 | | } |
| 57 | | return " <a href=\"". $matches[1]."\">[" . $matches[1] . "]</a> "; |
| 58 | | } |
| | 40 | function __urlfilter_filter($in) { |
| | 41 | $match = '#<a[^>]+?href="(.*?)">\\1</a>#im'; |
| | 42 | // matches non-linkified URLs |
| | 43 | $match2 = '#[^>"\'/=\?](http[^\s<$]+)[\s$]?#im'; |
| | 44 | $ret= preg_replace_callback($match, '__filter_callback', $in); |
| | 45 | $ret2= preg_replace_callback($match2,'__filter_callback', $ret); |
| | 46 | return $ret2; |
| | 47 | } |
| | 48 | |
| | 49 | /** |
| | 50 | * We need a callback because for some obscure reason the /ie modifier wouldnt work |
| | 51 | * in preg_replace alone. This basically formats the output |
| | 52 | */ |
| | 53 | function __filter_callback($matches) { |
| | 54 | $ret = preg_match("/^(http:\/\/)?([^\/<]+)/i", $matches[1], $outmatches); |
| | 55 | if ($outmatches && isset ($outmatches[2])) { |
| | 56 | return " <a href=\"". $matches[1]."\">[" . $outmatches[2] . "]</a> "; |
| | 57 | } |
| | 58 | return " <a href=\"". $matches[1]."\">[" . $matches[1] . "]</a> "; |
| | 59 | } |