dmAkismetPlugin allows to detect if a comment (or another content) is a spam using the akismet service.
git clone git://github.com/jeremyfa/dmAkismetPlugin.git plugins/dmAkismetPlugin
class ProjectConfiguration extends dmProjectConfiguration { public function setup() { parent::setup(); $this->enablePlugins(array( // your enabled plugins 'dmAkismetPlugin' ));
php symfony dm:setup
As this plugin is intended to check if your model's record get spammed, the first thing to do is to declare that a model acts as DmAkismet.
In this documentation we will assume we have a Comment model.
Note: dmAkismetPlugin needs your model to have an "is_active" field.
schema.yml
Comment:
actAs:
DmAkismet:
columns:
is_active:
name: { type: string(255), notnull: true }
email: { type: string(255), notnull: false }
website: { type: string(255), notnull: false, extra: link }
body: { type: clob, notnull: true }
Then, run doctrine migrations and update the model. In a console, from your project root dir, run:
php symfony doctrine:generate-migrations-diff
php symfony doctrine:migrate
php symfony dm:setup
In order to use akismet, you have to add your akismet api key (get one on http://akismet.com).
Add this configuration into both
apps/front/config/app.yml
and
apps/admin/config/app.yml
all:
akismet:
api_key: 205784-this-is-a-dummy-api-key
dmAkismetPlugin is using the php5 akismet port written by Alex Potsides and the akismet service.
The DmAkismet Doctrine behaviour adds an "is_not_spam" field. The field is set to true by default (that means it's not a spam).
Typical situation
A user is posting a new comment. When the comment's save() method is called, the model is asking the akismet service if it is spam or not.
If akismet tells this is a spam, the record is still saved into database but its "is_active" and "is_not_spam" fields will be set to false and the comment will not be shown on front.
Later, the administrator can go to the admin panel and completely delete the comment as he would do for another comment.
If akismet made a mistake (it marked a comment as spam when it's not), the administrator just has to set the record's "is_not_spam" field to true and re-active the comment. It will notify akismet that the comment is not a spam.
In contrary, if akismet didn't mark a comment as a spam when it should have done it, the administrator just has to mark the record's "is_not_spam" field to false, and the akismet service will be notified that this is a spam (he can also disable the comment or delete it after).
dmAkismetPlugin is trying to use the most common field names in order to guess which field in the model is the author's name, wich one is the message etc... Here is a list of the default recognized field names.
"Author Name" recognized fields:
author_name, author, name, user_name, username, user
"Author Email" recognized fields:
author_email, author_mail, email, mail
"Author Url" recognized fields:
author_url, author_website, author_link, author_blog, url, website, link, blog
"Content" recognized fields:
content, body, data, description, text, comment, message
If you are using other field names for theses informations, you can add some options to the DmAkismet behaviour in your schema.yml and the plugin will use those names instead of the default ones:
Comment:
actAs:
DmAkismet:
author_name: nickname
author_email: mel
author_url: portfolio
content: story
columns:
is_active:
nickname: { type: string(255), notnull: true }
mel: { type: string(255), notnull: false }
portfolio: { type: string(255), notnull: false, extra: link }
story: { type: clob, notnull: true }
If you want to read more complex data (for example the author name is stored in another record), you can add a getAkismet() method into your model class and do what you want:
public function getAkismetData() { // Note: remember that this code is gonna be executed when the record is not saved yet. return array( 'author_name' => $this->getAuthor()->getFirstname().' '.this->getAuthor()->getLastname(), 'author_email' => $this->getEmail(), 'author_url' => $this->getBlog()->getUrl(), 'content' => $this->description ); }
DmAkismetPlugin can work with DmCommentPlugin. You just have to follow those instructions:
Add this code to your config/doctrine/schema.yml
DmComment:
actAs:
DmAkismet:
Now copy plugins/dmCommentPlugin/modules/dmCommentAdmin/config/generator.yml to apps/admin/modules/dmCommentAdmin/config/generator.yml and modify the copied file to add the "is_not_spam" field in the list display, filter display and form display options like this:
generator:
class: dmAdminDoctrineGenerator
param:
...
config:
actions: ~
fields:
...
list:
display:
- ...
- is_active
- is_not_spam
- created_at
- updated_at
...
filter:
display:
- id
- is_active
- is_not_spam
- ...
form:
display:
NONE: [..., is_active, is_not_spam]
...
Then, run doctrine migrations and update the model. In a console, from your project root dir, run:
php symfony doctrine:generate-migrations-diff
php symfony doctrine:migrate
php symfony dm:setup
That's all.
Open issues
Closed issues
dmAkismetPlugin, created on July 16, 2010 by jeremyfa, used by 29 projects
clusialaereriMay 27, 2011 12:34 AM
<a href=http://carolinescomedy.ning.com/forum/topics/buy-accutane-buy-cheap>buy accutane</a>
http://carolinescomedy.ning.com/forum/topics/buy-accutane-buy-cheap - buy accutane
opergofooldNovember 20, 2011 8:09 PM
[b][url=http://mybuymeds.com][color=green]Click Here To Buy Viagra Online
Discreet packaging, ANONYMOUS delivery.
24/7/365 Customer Support
TOP QUALITY for brand and generic drugs!
Many payment options: Visa, Mastercard, eCheck etc.
Order Erectalis online without prescription![/color][/url][/b]
[b][url=http://mybuymeds.com][color=red]Welcome Online Canadian Pharmacy[/color][/url][/b]
[url=http://mybuymeds.com][img]http://buypills.telehost.biz/ris/5.gif[/img][/url]
[url=http://mybuymeds.com][img]http://i001.radikal.ru/0907/68/a982d889724a.jpg[/img][/url]
http://zovirax.webnode.com
[url=http://valle.cba.pl/index.php?topic=520.new#new]CHEAP ZEBETA WITH CASH ON DELIVERY[/url]
[url=http://rikyzdj.altervista.org/forum/viewtopic.php?f=3&t=11711]ORDER SEROQUEL WITHOUT A PRESCRIPTION[/url]
[url=http://www.mikile.ggl.tw/viewthread.php?tid=68491&extra=]CELEXA NO RX FED EX[/url]
[url=http://objetivovida.org/foro/viewtopic.php?f=17&t=4142]PRAVACHOL ONLINE WITH NO PRESCRIPTION OR MEMBERSHIP[/url]
[url=http://www.trenchmasters.com/lng/viewtopic.php?f=3&t=23693]BUYING CYTOTEC OVER THE COUNTER FOR SALE[/url]