From: moodler Date: Thu, 2 Sep 2004 04:14:06 +0000 (+0000) Subject: New filter for Email protection ... filters all email addresses in Moodle X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=e3f19cb089e266f65b3ba2d05b314eb9dd7e76b1;p=moodle.git New filter for Email protection ... filters all email addresses in Moodle text and obfuscates them from spammer's robotic eyes Thanks Mike Churchward! http://moodle.org/mod/forum/discuss.php?d=11302 --- diff --git a/filter/emailprotect/filter.php b/filter/emailprotect/filter.php new file mode 100644 index 0000000000..3a6131858f --- /dev/null +++ b/filter/emailprotect/filter.php @@ -0,0 +1,40 @@ +)'.'(.*)'.'()|iU'; + $text = preg_replace_callback($pattern, 'alter_mailto', $text); + +/// pattern to find any other email address in the text. + $pattern = '/(^|\s+|>)'.$emailregex.'($|\s+|\.\s+|\.$|<)/i'; + $text = preg_replace_callback($pattern, 'alter_email', $text); + + return $text; +} + + +function alter_email($matches) { + return $matches[1].obfuscate_text($matches[2]).$matches[3]; +} + + +function alter_mailto($matches) { + return obfuscate_mailto($matches[2], $matches[4]); +} + +?> diff --git a/lang/en/emailprotect.php b/lang/en/emailprotect.php new file mode 100644 index 0000000000..2f013e5031 --- /dev/null +++ b/lang/en/emailprotect.php @@ -0,0 +1,6 @@ + +