Path

ez.no / developer / contribs / workflow / peter's random anti-spam image


Peter's Random Anti-Spam Image

Author Version Downloads Compatible with
Peter Keung 1.1 766 eZ Publish 3.8+
Stop comment spam with this Captcha solution that generates random anti-spam words. The GD Library is required to display the Captcha image, and the FreeType library is needed to be able to use fonts within the image.

Description

Peter's Custom Anti-Spam Image for eZ Publish
Version 1.1
Compatible with eZ Publish 3.8+

Install instructions:

French instructions here: http://luxpopuli.fr/ez_publish__1...spam_image_image_anti_spam_aleatoire

1) Unzip the customantispam directory into the eZ Publish extension directory.

2) Activate the extension in the eZ Publish Administration Interface by clicking on the Setup tab, then the Extensions menu item.

3) Run the SQL query in customantispamtables.sql to insert the necessary tables into the same database as your eZ Publish installation.

4) Add a policy under the Anonymous Role (click the User accounts tab, then the Roles and Policies link) to grant full access to the customantispam module.

5) Add a new workflow. Click the Setup tab, then the Workflows menu item. Click the New workflow group button and enter any name you want (such as "Anti-spam").

a) In the new workflow group, click the New workflow button. Name it "Anti-spam" and select the event "Event / Custom anti-spam", then click the Add event button.

b) Alternatively, you can add the "Custom anti-spam" event to a multiplexer workflow. This is useful if you have several events that you need to run in the "content / publish / before" trigger (in step 6). In that case, select the event "Event / Multiplexer", then click the Add event button. There are many more options in the Multiplexer event, such as affected sections, languages, classes, versions and users. For this workflow, you can leave all of the options as "all". If you are using this extension to filter objects of the Comment class, select that under the Classes to run workflow list box. In the Workflow to run dropdown list, select the "Anti-spam" workflow. Then, click the OK button.

6) Add a new trigger by clicking the Setup tab, then the Triggers menu item. Under the "content" module, "publish" function and "before" connection type, select the workflow "anti-spam" then click the Apply changes button.

7) Find your comment template (for ezwebin, it's extension/ezwebin/design/ezwebin/override/templates/edit/comment.tpl).

Add {set-block scope=root variable=cache_ttl}0{/set-block} at the top of your template.

If you are putting the anti-spam protection into a different template (such as directly in a blog post if you are using Kristof's powercontent extension at http://ezpedia.org/wiki/en/ez/powercontent to add a comment form directly in a template), add cache-blocks around the sections of the page preceding and following the anti-spam code:

{cache-block}
Start of page
{/cache-block}
anti-spam code
{cache-block}
Rest of page
{/cache-block}

However, cache-blocks are probably not necessary if you are editing the edit/comment.tpl template.

Add the following code to the form, usually above the message text area:

<div class="block">
{def $antispam = custom_anti_spam()}
<label>Anti-spam word</label><div class="labelbreak"></div>
<input type="hidden" name="matchthis" value="{$antispam}" />
<a href={concat("/customantispam/audio/(audio)/",$antispam)|ezurl("double")}><img src={concat("/customantispam/image/(image)/",$antispam)|ezurl("double")} style="border: 1px solid black" alt="Click to hear an audio file of the anti-spam word"/></a><div class="labelbreak"></div>
<input type="text" name="securitycode" size="10" />
</div>

Changelog

1.1
- Massive code overhaul to be more in line with proper eZ Publish extension conventions.
- Added an audio anti-spam feature so that if you click on the word, an mp3 is generated to spell out the letters in the word.

1.0
- First public release

Comments

Registration

At the moment, this extension does not readily plug into the user module :(

Any suggestions to modify it for the user module are welcome!

User register and Anti-Spam

Hi, I'm testing that extension in eZ 3.9.3
Is it possible to use this ext. for user registration form? I know, that I need trigger for "user" module for that but I have no idea how to do it. Can anybody give me advice?

No more .htaccess hacking required

With version 1.1, image generation is now done in a module, so you just have to provide access to that module to the Anonymous role, as explained in the instructions :D

Add a Rewrite Cond in .htaccess

Hi! Sorry for the slow reply -- I only just subscribed to notifications on this page...

The customantispamhandler.php is an error on my part, as I shouldn't have included settings/content.ini.append.php in the package. That will be fixed when I release the next version.

However, that shouldn't have caused the problem. Is the image simply showing "Anti-Spam image" (the alt value)? If so, you probably need to add a RewriteCond to your .htaccess file in order to prevent that specific image files from being rewritten according to the other rewrite rules:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/extension/customantispam/cas_image\.php

Object edit handler?

Hi, thank you for this extension. I chose it mainly because it is the one with the best instruction for installation :) I followed them carefully but the Antispam image is not showing up. GD.so is installed and loaded, libfreetype is also installed. The only error I get is this one in eZ:

Error:

Cound not find content object edit handler ( defined in content.ini ) : extension/customantispam/content/customantispamhandler.php

What did I do wrong? Running it on eZP 3.8.6. Thanks

log in or create a user account to comment.

Contribution info (beta)

Download