Forum Moderators: coopster
This is for an old site using phpBB for it's forum. Despite the TOS etc asking users to disguise email addys (or even better to use the PrivateMessage facility) to prevent a spam bot harvest fest, they're still doing it. It's a busy forum, and I don't want the mods to have to bother manually editing.
I don't want to stop users posting an email addy, I just want to stop phpBB doing the auto "Mailto:" and to disguise it while we're at it.
Here's the function make_clickable that does the parse and the subsequent "mailto:":-
function make_clickable($text)
{// pad it with a space so we can match things at the start of the 1st line.
$ret = ' ' . $text;// matches an "****x://yyyy" URL at the start of a line, or after a space.
// ****x can only be alpha characters.
// yyyy is anything up to the first space, newline, comma, double quote or <
$ret = preg_replace("#([\t\r\n ])([a-z0-9]+?){1}://([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)#i", '\1<a href="\2://\3" target="_blank">\2://\3</a>', $ret);// matches a "www¦ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
// Must contain at least 2 dots. xxxx contains either alphanum, or "-"
// zzzz is optional.. will contain everything up to the first space, newline,
// comma, double quote or <.
$ret = preg_replace("#([\t\r\n ])(www¦ftp)\.(([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)#i", '\1<a href="http://\2.\3" target="_blank">\2.\3</a>', $ret);// matches an email@domain type address at the start of a line, or after a space.
// Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
$ret = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);// Remove our padding..
$ret = substr($ret, 1);return($ret);
}
Can someone help me alter the mailto: part?
I could just take the whole thing out and return($text) as handed to the function, that would stop URL's and emails being clickable links, but I'd prefer to just have any email address parsed and turned into something like:-
tj <!at> domain.com
I tried something along the lines of the following:-
$ret = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\2 <!at> \3\", $ret);
As an outright guess (I don't usually do php so it's a language I'm not familiar with), but it didn't work.
Any help with this one line would be much appreciated.
TJ