Peter’s Random Anti-Spam Image Version 1.1 for eZ Publish 3.8+
First published on May 6, 2007
I’ve spun off my anti-spam WordPress plugin — this time for eZ Publish!
I work for eZ Systems, the maker of eZ Publish, as an editor. So I certainly don’t have awesome technical skills, but I’ve managed to create an extension for eZ Publish to help fight comment spam (just as the comment plugin on this blog works where you have to type in the anti-spam word before being submitting a comment). eZ Publish is a rockin’ Open Source Enterprise Content Management System.
First, download Peter’s Random Anti-Spam Image for eZ Publish. Then:
(French instructions available here.)
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 this at the top of your template:
{set-block scope=root variable=cache_ttl}0{/set-block}
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>
January 7th, 2008 at 7:36 am
Oliver Frommel says:
nice extension, thanks. You might consider to add some short instructions on how to set it up when you already have a workflow connected to the “content/publish/before” trigger.
I set up a multiplexer workflow that runs the antispam workflow only when the object type matches a comment. Or is there any other way?
best
Oliver
May 2nd, 2008 at 6:43 am
Angel says:
I wonder though if the eZ descriptor should be temporarily dropped in honor of the actual process.
November 20th, 2008 at 8:08 am
mmo says:
On one of my personal blogs I was relying on Askimet. Pretty hardcore you came up with your own solution for this.