[Pmwiki-users] email protection
Reimer Behrends
behrends
Wed Feb 25 16:04:19 CST 2004
On Wed, Feb 25, 2004 at 05:32:06PM +0100, Dipl.-Ing.(FH) Karl Loncarek wrote:
> Hi erveyone,
>
> is there a way to protect email links?
See below for a solution that uses a very simple obfuscation
technique. It should be easy to extend it to different things.
Caveat: Currently it's only been tested with pmwiki 0.5.
Reimer Behrends
<?php
$LinkPatterns[201]["\\bmailto:($UrlPathPattern)"] = "FmtMailTo";
function ObfuscateHTML($text)
{
$out = "";
foreach (preg_split("//", $text, -1, PREG_SPLIT_NO_EMPTY) as $ch)
$out .= "&#" . ord($ch) . ";";
return $out;
}
function FmtMailTo($pattern, $link, $text)
{
$hrefaddr = preg_replace("/^mailto:/", "", $link);
if (is_null($text))
$textaddr = ObfuscateHTML($hrefaddr);
else
$textaddr = $text;
$mailto = 'mailto:';
$hrefaddr = ObfuscateHTML($hrefaddr);
$textaddr = str_replace("@", "<span>@</span>", $textaddr);
return "<a href='$mailto$hrefaddr'>$textaddr</a>";
}
?>
More information about the pmwiki-users
mailing list