App::ZofCMS::Plugin::AntiSpamMailTo - "smart" HTML escapes to protect mailto:foo@bar.com links from not-so-smart spam bots
In your Main Config file or ZofCMS template:
# include the plugin plugins => [ qw/AntiSpamMailTo/ ], # then this: plug_anti_spam_mailto => 'bar', # or this: plug_anti_spam_mailto => [ qw/foo bar baz/ ], # or this: plug_anti_spam_mailto => { foo => 'bar', baz => 'beer', },
In your HTML::Template template:
<tmpl_var name="mailto"> # or this: <tmpl_var name="mailto_0"> <tmpl_var name="mailto_1"> <tmpl_var name="mailto_2"> # or this: <tmpl_var name="foo"> <tmpl_var name="baz">
The module is an App::ZofCMS plugin which provides means to deploy a technique that many claim to be effective in protecting your <a href="mailto:foo@bar.com"></a> links from dumb spam bots.
<a href="mailto:foo@bar.com"></a>
The technique is quite simple (and simple to circumvent, but we are talking about dumb spam bots) - the entire contents of href="" attribute are encoded as HTML entities. Dumb spam bots miss the mailto: and go their way. As of the day of this writing, I have about 14 sites that have been using this plugin for 3+ years and I might have received one spam email to the email address shown by the plugin. Anyway, on to the business.
href=""
mailto:
This documentation assumes you have read App::ZofCMS, App::ZofCMS::Config and App::ZofCMS::Template
plug_anti_spam_mailto
plug_anti_spam_mailto => 'bar', plug_anti_spam_mailto => [ qw/foo bar baz/ ], plug_anti_spam_mailto => { foo => 'bar', baz => 'beer', },
The plugin takes it's data from plug_anti_spam_mailto first-level key that is in either ZofCMS template or config file. The key takes either a string, arrayref or a hashref as its value. If the key is specified in both main config file and ZofCMS template and the value is of the same type (string, arrayref or hashref) then both values will be interpreted by the plugin; in case of the hashref, any duplicate keys will obtain the value assigned to them in ZofCMS template. Note: if the value is of "type" string specified in both main config file and ZofCMS template it will interpreted as an arrayref with two elements. Now I'll tell you why this all matters:
string
plug_anti_spam_mailto => 'bar',
When the value is a string then in HTML::Template template you'd access the converted data via variable mailto, i.e. <tmpl_var name="mailto">
mailto
<tmpl_var name="mailto">
plug_anti_spam_mailto => [ qw/foo bar baz/ ],
To access converted data when the value is an arrayref you'd use mailto_NUM where NUM is the index of the element in the arrayref. In other words, to access value bar in the example above you'd use <tmpl_var name="mailto_1">
mailto_NUM
NUM
bar
<tmpl_var name="mailto_1">
plug_anti_spam_mailto => { foo => 'bar', baz => 'beer', },
You do not have to keep typing mailto to access your converted data. When value is a hashref the values of that hashref are the data to be converted and the keys are the names of <tmpl_var name"">s into which to stick that data. In the example above, to access converted data for beer you'd use <tmpl_var name="baz">
<tmpl_var name"">
beer
<tmpl_var name="baz">
ZofCMS template:
plugins => [ qw/AntiSpamMailTo/ ], plug_anti_spam_mailto => 'mailto:john.foo@example.com',
HTML::Template template:
<a href="<tmpl_var name="mailto">">email to John Foo</a>
Fork this module on GitHub: https://github.com/zoffixznet/App-ZofCMS
To report bugs or request features, please use https://github.com/zoffixznet/App-ZofCMS/issues
If you can't access GitHub, you can email your request to bug-App-ZofCMS at rt.cpan.org
bug-App-ZofCMS at rt.cpan.org
Zoffix Znet <zoffix at cpan.org> (http://zoffix.com/, http://haslayout.net/)
You can use and distribute this module under the same terms as Perl itself. See the LICENSE file included in this distribution for complete details.
LICENSE
To install App::ZofCMS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::ZofCMS
CPAN shell
perl -MCPAN -e shell install App::ZofCMS
For more information on module installation, please visit the detailed CPAN module installation guide.