Antispam Module

11/06/2005 10:05:28
tags: OddMuse, web

Installing a module is easy: Create a modules subdirectory in your data directory, and put the Perl file in there. It will be loaded automatically.

Download module:

I wrote my first module for OddMuse today, the Antispam Module. It is designed to locate email addresses within pages, and replace them with a masked version that will at least keep a few spambots off your back for a while. It isn’t foolproof, but it helps, and it is invisible to human visitors.

Whenever you include an email address:

foo@bar.com

It is replaced with an encoded version:

foo@ba
r.com

This encoded version is displayed normally by your web browser, but MIGHT be able to fool a few spambots…

Additionally, you can have the module automatically create mailto links for each address.

foo@bar.com

Becomes:

<a href="mailto:foo@bar.com">foo@bar.com</a>

(In live use, this would be encoded, of course.)

Additionally, you can create more complicated links:

[Email Me](foo@bar.com)

Becomes:

<a href="mailto:foo@bar.com">Email Me</a>

Currently, the regexp used to match email is:

$EmailRegExp = '[\w\.\-]+@([\w\-]+\.)+[\w]+';

I am sure that there is room to improve this…

$DoMaskEmail

Default: 1

If enabled, any email address found, not just those inside BracketText, will be masked

$CreateMailtoLinks

Default: 1

If enabled, any email address found, not just those inside BracketText, will be converted into a mailto link.

Similar Pages

Comments

Leave a comment