#breaklinks: # reduce the value of comment-spamming by breaking all URLs in # a field in a way that people can fix if they really want # to go there. Include an approval mechanism so the blog # author can turn replacement off on a per-comment basis. # # Usage: # <$MTCommentBody breaklinks="password"$> # <$MTCommentAuthorLink breaklinks="password"$> # # Unless the field contains the string "[password]", # all URLs will be modified like so: # # http://spam.example.com/ -> http://spam-DOT-example-DOT-com/ # # The script doesn't care if they're http, https, ftp, itms, or # some other protocol; it's just looking for the "://" # use strict; use MT::Template::Context; MT::Template::Context->add_global_filter(breaklinks => \&breaklinks); sub breaklinks { my ($string, $arg, $ctx) = @_; my $tmp; #leave it alone if it's been approved return $string if $arg and $string =~ s/\[$arg\]//; $string =~ s|(://[-_.a-z0-9]+)|$tmp=$1;$tmp=~s/\./-DOT-/g;$tmp|ieg; return $string; }