http://www.test.com/a/b/c.html
* with a nicer [test.com]
*/
function __urlfilter_filter($in) {
$match = '#]+?href="(.*?)">\\1#im';
// matches non-linkified URLs
$match2 = '#[^>"\'/=\?](http[^\s<$]+)[\s$]?#im';
$ret= preg_replace_callback($match, '__filter_callback', $in);
$ret2= preg_replace_callback($match2,'__filter_callback', $ret);
return $ret2;
}
/**
* We need a callback because for some obscure reason the /ie modifier wouldnt work
* in preg_replace alone. This basically formats the output
*/
function __filter_callback($matches) {
$ret = preg_match("/^(http:\/\/)?([^\/<]+)/i", $matches[1], $outmatches);
if ($outmatches && isset ($outmatches[2])) {
return " [" . $outmatches[2] . "] ";
}
return " [" . $matches[1] . "] ";
}
rss_set_hook('rss.plugins.import.description','__urlfilter_filter');
?>