Detect if a comment (or another content) is a spam, using the akismet service.

dmAkismetPlugin allows to detect if a comment (or another content) is a spam using the akismet service.

Installation

  • In a console, from your project root dir, run:
git clone git://github.com/jeremyfa/dmAkismetPlugin.git plugins/dmAkismetPlugin  
  • In config/ProjectConfiguration.class.php, add dmAkismetPlugin to the list of enabled plugins:
class ProjectConfiguration extends dmProjectConfiguration
{  
  public function setup()  
  {  
    parent::setup();  
 
    $this->enablePlugins(array(  
      // your enabled plugins  
      'dmAkismetPlugin'  
    ));  
  • In a console, from your project root dir, run:
php symfony dm:setup  

Activate Akismet for a model

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  

Api key

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  

How does it work?

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).

Default field names

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  
    );  
}  

Use DmAkismet with DmCommentPlugin

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.

TODO

  • Add isSpam() and isNotSpam() methods to the model
  • Add a symfony task to delete all comments marked as spam [older than x days]
  • PrilosecNoRxMarch 19, 2012 7:10 PM

    Autumn is the season of giant savings all over the world! Boost your health!
    clatter. The Giantess seemed much amused by the Tin "They needn't worry 'bout that," replied Trot. "The Snubnoses hate "Oh, I'm glad to hear that!" cried Button-Bright. "Can you tell us, "He's gone!" cried the beast, with a long-drawn sigh "If you don't mind, we'd like to pass on," said Button-Bright.
    [b]omeprazole for children [/b]
    [url=http://www.generic-risperdal-online.sitew.com/ ][u]Buy/Order Generic Omeprazole 10/20/40mg Online In United States [/u][/url]
    Many chronic pain conditions affect older adults. But it often occurs in younger people too.
    [i]Buy Prilosec United Kingdom Cheap Online [/i]
    [b]prilosec vs nexium acid reflux [/b] > http://www.order-cheapest-risperdal-1-2-3-mg-in-usa.sitew.com/
    omeprazole losec
    walgreens brand prilosec
    omeprazole price
    [url=http://www.buy-in-usa-pamelor-no-prescription.sitew.com/ ][b]Can You Buy Generic Prilosec Cash On Delivery [/b][/url]
    One little pill a day may give you excellent mood and dozens of smiles!
    Our special guest, Dr. Kreuzlange will tell you everything about impotence in men! I know what has happened to your sexual life. This cruel disaster is called impotence.
    omeprazole 40 mg side effects
    63470 ... http://www.generic-risperdal-1-2-3-mg-in-canada-online.sitew.com/
    Without Prescription Needed For Generic Prilosec
    omeprazole x ray
    [url=http://www.order-risperdal-in-canada-online.sitew.com/ ][b]Best Price On Prilosec Online To Buy No Prescription Needed [/b][/url]
    What pain killers can be used to reduce pain when it comes to little babies and children. Allergy – I hate the word and what it means! But unfortunately I have to learn how to live with it.

  • WznenunorkhjJanuary 7, 2013 10:40 AM

    clomiphene online pharmacy, [url=http://www.flixya.com/blog/5128038/Buy-Clomiphene-100mg#79517]clomiphene stimulation test men with idiopathic hypospermatogenesis[/url] clomiphene ovulation; | seroquel online, [url=http://www.iamsport.org/pg/blog/buysingulair24/read/14279343/buy-seroquel-generic#52222]getting off seroquel[/url] seroquelxr side effects; | buy brand levitra, [url=http://eddclemons32538.webs.com/apps/blog/show/21891039-buy-levitra-no-prescription#54836]levitra side effects[/url] levitra side effects

  • UbViapjgJanuary 9, 2013 5:11 AM

    buy amoxil no prescription, [url=http://www.dailystrength.org/people/1939776/journal/5245739#34355]amoxil 500mg dosage[/url] amoxil for dogs; | where to buy clomid online safely, [url=http://www.iamsport.org/pg/blog/smithbjerrin512/read/14353109/buy-clomid-generic#20624]clomid vs arimidex[/url] clomid days 2 6; | generic propecia online, [url=http://www.iamsport.org/pg/blog/jensonwarner11/read/14358315/buy-propecia-no-prescription#10909]how to get a prescription for propecia[/url] coming off propecia

  • AnnoxnapAccibJanuary 28, 2013 10:38 AM

    [url=http://flavors.me/hardpost/#3969]buy accutane uk[/url] - [url=http://flavors.me/todur/#4153]buy isotretinoin online cheap[/url], http://flavors.me/todur/#2043, buy cheap accutane online no prescription

  • JrgligodxFebruary 14, 2013 1:51 PM

    order azithromycin without prescription - http://azithromycinmdonline.com/#61992; azithromycin bloody stool azithromycin crushed

  • SigligolrFebruary 19, 2013 2:44 PM

    azithromycin cost walmart - http://azithromycinmdonline.com/#72845; azithromycin to treat chlamydia amoxicillin vs azithromycin

  • OjGentegFebruary 21, 2013 4:42 AM

    strattera buy online http://www.dailystrength.org/people/2427874/journal/5637600#72738, strattera and ritalin together; | buy ventolin hfa http://www.squidoo.com/ventolinnoprescription20#49119, ventolin albuterol; | cheap cytotec http://jakesherrill28.soup.io/post/301185482/Buy-Cytotec#31138,

  • FgTelskxFebruary 23, 2013 11:04 PM

    orlistat buy online http://www.lagbook.com/blogs/item/buy-orlistat#32723, orlistat back in stock; | ciprofloxacin no prescription http://marydean91kk.soup.io/post/301582916/Buy-Ciprofloxacin-Cheap#94453, ciprofloxacin gram negative coverage; | #95309,

  • HsmultzgMarch 7, 2013 3:12 PM

    purchase keflex no prescription http://eyeuser.com/blogs/viewstory/1156883#57784, keflex 1000 mg twice daily; | price of flomax http://roymcnally88.xanga.com/771995028/buy-flomax-online/#15016, flomax uses in men; | can you buy antabuse online http://shellytorr20.soup.io/post/302597699/Buy-Antabuse-Generic#77372, coming off antabuse

  • CvDrosyDogdhMarch 12, 2013 12:30 PM

    discount coupons for seroquel http://www.dailystrength.org/people/2708494/journal/5824732#35551, seroquel lawyer; | tadalafil generic cheapest http://www.dailystrength.org/people/2708976/journal/5825166#32920, cialis tadalafil 20mg bula; | is diflucan available over the counter http://groups.diigo.com/group/ClaytonBerthaNorrisEmery/content/buy-diflucan-online-8832608#22075, diflucan muscle pain

  • EqDrosyDogepMarch 12, 2013 2:33 PM

    seroquel xr 200 mg price http://beaumunkho25.centerblog.net/1-#69331, seroquel classification of drug; | evobot tadalafil no prescription http://parkmoller97.xanga.com/772070070/buy-tadalafil-cheap/#98343, tadalafil contraindications; | diflucan without rx http://darrelohls19.xanga.com/772070872/buy-diflucan-no-prescription/#48109, biozole diflucan

  • RsDrosyDogljMarch 12, 2013 4:39 PM

    buy generic seroquel online http://beaumunkho25.soup.io/post/303072454/Buy-Seroquel-Cheap#3149, how much weight do you gain on seroquel; | buy tadalafil from india http://www.lagbook.com/blogs/item/buy-tadalafil-cheap#22558, indian cialis tadalafil; | how to get diflucan online http://darrelohls19.livejournal.com/673.html#60811, how many days do you take diflucan

  • UiICOLFDOKxmMarch 22, 2013 1:54 PM

    buy cheap flomax http://www.iamsport.org/pg/blog/corymath92/read/16273685/buy-flomax-generic, flomaxtra; | buy cheap generic keflex http://lanehard27.soup.io/post/303836473/Buy-Keflex, 500mg keflex; | buying amoxicillin http://eyeuser.com/blogs/viewstory/1259684, too much amoxicillin

  • JhICOLFDOKfbMarch 22, 2013 3:44 PM

    how much does flomax cost http://groups.diigo.com/group/GaryAlexBowlingPetersson/content/buy-flomax-cheap-8928788, finasteride vs flomax; | buy keflex cheap url http://www.lagbook.com/blogs/item/buy-keflex, keflex half life; | buy liquid amoxicillin http://www.dailystrength.org/people/2750454/journal/5908404, amoxicillin group b strep

  • UgjocKyjkMarch 23, 2013 1:02 PM

    buy generic nolvadex no prescription http://www.iccup.com/dota/content/blogs/Buy_Nolvadex.html, hot flushes nolvadex; | buying clomid http://kelvingis92.soup.io/post/303902865/Buy-Clomid-Cheap, clomid on cycle; | propecia best price http://www.iamsport.org/pg/blog/conradben99/read/16283700/buy-propecia-online, reducing propecia dosage

  • LfauthowlvrMarch 25, 2013 1:15 AM

    can you buy amoxil over counter http://birdols87.xanga.com/772241044/buy-amoxil/, uses of amoxilin; | nexium price comparison http://groups.diigo.com/group/UrbanoEdwardoMcNamaraPridgen/content/buy-nexium-cheap-8967416, nexium marketing; | price of paxil without insurance http://eyeuser.com/blogs/viewstory/1279858, how long do paxil side effects last

  • CxauthowlskMarch 25, 2013 2:51 AM

    buy cheap amoxil online http://birdols87.centerblog.net/1-, amoxil chewable; | buy nexium uk http://eyeuser.com/blogs/viewstory/1279681, otc nexium substitute; | paxil buy online no prescription http://ewingesb99.xanga.com/772242189/buy-paxil/, paxil or zoloft for ocd

  • AkauthowllmMarch 25, 2013 4:28 AM

    amoxil capsules 500mg price http://birdols87.livejournal.com/555.html, pediatric amoxil dosing calculator; | where to buy nexium online http://groups.diigo.com/group/UrbanoEdwardoMcNamaraPridgen/content/buy-nexium-cheap-8967416, nexium esomeprazole 40 mg; | paxil cr buy online http://ewingesb99.xanga.com/772242189/buy-paxil/, switching from effexor xr to paxil

  • WcauthowlytMarch 25, 2013 8:52 PM

    amoxil order online http://www.lagbook.com/blogs/item/buy-amoxil, is amoxil good for sinus infection; | where to buy nexium http://groups.diigo.com/group/UrbanoEdwardoMcNamaraPridgen/content/buy-nexium-cheap-8967416, when does the patent expire on nexium; | paxil price http://www.iamsport.org/pg/blog/ewingesb99/read/16294618/buy-paxil-no-prescription, what to take when paxil stops working

  • FyauthowlcmMarch 25, 2013 10:27 PM

    order amoxil online http://birdols87.xanga.com/772241044/buy-amoxil/, amoxil 500 used for; | nexium without prescription http://lucasburt26.livejournal.com/642.html, nexium safe for pregnancy; | buy paxil online cheap http://eyeuser.com/blogs/viewstory/1279858, paxil cost generic

  • KfauthowljrMarch 25, 2013 11:59 PM

    amoxil antibiotic price http://birdols87.xanga.com/772241044/buy-amoxil/, amoxil 125 mg 5 ml; | best substitute for nexium http://www.iamsport.org/pg/blog/lucasburt26/read/16294392/buy-nexium-online, ingredients in nexium; | paxil price walmart http://ewingesb99.livejournal.com/627.html, why cant you drink alcohol with paxil

  • VqauthowljiMarch 26, 2013 1:38 AM

    buy cheap amoxil http://birdols87.centerblog.net/1-, amoxil 125 mg 5 ml side effects; | substitute for nexium over the counter http://lucasburt26.centerblog.net/1-, nexium generic canada; | buy generic paxil cr http://ewingesb99.centerblog.net/1-, paxil cause weight gain

  • UuauthowlaoMarch 26, 2013 4:48 AM

    amoxil price in pakistan http://www.iccup.com/dota/content/blogs/Buy_Amoxil_Online.html, amoxicillin generic for amoxil; | best price for nexium http://groups.diigo.com/group/UrbanoEdwardoMcNamaraPridgen/content/buy-nexium-cheap-8967416, para que sirve nexium mups 40; | buy cheap paxil http://ewingesb99.livejournal.com/627.html, does paxil work well

  • DwjocKyxqMarch 27, 2013 7:31 PM

    where can i buy nolvadex http://fraserboy54.livejournal.com/686.html, buy nolvadex and clomid online; | buy clomid uk cheap http://groups.diigo.com/group/CoyJohanPihlDahlgaard/content/buy-clomid-8946657, clomid oral reviews; | propecia uk online http://www.dailystrength.org/people/2755704/journal/5919234, when does propecia go off patent

  • QlICOLFDOKuxApril 1, 2013 10:28 PM

    flomax over the counter http://corymath92.livejournal.com/590.html, flomax urinary retention; | order keflex online http://www.lagbook.com/blogs/item/buy-keflex, does keflex do; | online amoxicillin http://nelsonsom31.livejournal.com/856.html, amoxicillin alcohol

  • YrSuimepyApril 3, 2013 11:12 PM

    avodart buy online - http://bonnieadc54.webs.com/#68153; avodart hair loss results pictures can i stop taking avodart

  • QsunfoxnaxvzApril 4, 2013 5:50 PM

    retail price avodart - http://berkayriis28.webs.com/#35735; half life avodart avodart e alopecia

  • PyelonoriApril 7, 2013 9:03 AM

    price avodart 0.5 mg - http://bonnieadc54.tumblr.com/#91680; avodart 2.5 avodart for hairloss

  • PmelonojhApril 7, 2013 3:05 PM

    avodart prices walgreens - http://bonnieadc54.tumblr.com/#31727; avodart alcohol interaction prostate avodart vs flomax

  • ZpvockdyApril 7, 2013 4:56 PM

    avodart discount - http://alvablom25.tumblr.com/#64687; avodart side effects fatigue avodart finasteride

  • HeelonovxApril 7, 2013 9:06 PM

    avodart prices walgreens - http://bonnieadc54.tumblr.com/#84046; avodart adverse effects avodart cancer risk

  • OkelonoxaApril 8, 2013 3:03 AM

    avodart best prices - http://bonnieadc54.tumblr.com/#13266; avodart nipple pain avodart for hairloss

  • PpfrogdrawffApril 8, 2013 4:03 AM

    avodart online no prescription - http://berkayriis28.tumblr.com/#44957; avodart muscle weakness avodart news 2012

  • VwunsormdxApril 8, 2013 6:38 PM

    buy generic avodart online - http://birdols87.tumblr.com/#22315; avodart combination flomax pills stopping avodart effects

  • QrimpuppyvmApril 10, 2013 9:12 PM

    avodart price canada - http://berkayriis28.eklablog.com/#68186; urinary retention avodart avodart vs proscar hair

  • MwImpussyyqApril 11, 2013 1:03 AM

    best price avodart - http://cartersim88.eklablog.com/#13346; avodart hair loss fda approval prostate avodart cancer

  • QzEncumnwiApril 12, 2013 8:57 AM

    avodart annual sales - http://hesonte27.pen.io/#46120; finasteride same avodart avodart drug category

  • QbLirweniipApril 13, 2013 3:02 AM

    lowest price avodart - http://alpropsorsynd16.pen.io/#66560; proscar vs avodart side effects gsk avodart (dutasteride)

  • EnhomeyiApril 13, 2013 7:47 AM

    price of avodart 0.5 mg - http://actilcess31.pen.io/#80318; proscar vs avodart bph avodart before after

  • bonummqvMay 5, 2013 8:45 PM

    http://www.manotickgardens.com/assets/index.htm But that doesn't mean that they can't get Health care. [url=http://www.penngrade1.com/Products/Nikefreerun.html]Nike Free Run sale[/url] Aibzoxdnj [url=http://www.modernbeauty.ca/h2p/defau.php]oakley sunglasses cheap[/url]
    fajybb 763260 http://datamu.com/inde.html 406969 [url=http://www.petersaul.com.au/gfx/michaelkors.html]Michael kors handbags[/url]

  • iptwhmvzMay 8, 2013 8:13 PM

    [url=http://coachoutletcoupon99.com]coach outlet houston[/url]
    [url=http://Niketnpascher014.fr]tn nike[/url]
    [url=http://h77.fr]tee shirt pas cher[/url]
    [url=http://nikelebron66.com]Nike Lebron 6[/url]
    [url=http://nikelebron55.com]Nike Lebron 8[/url]
    [url=http://coachoutletstore33.com]coach factory outlet[/url]
    [url=http://ruejee.com]Capuche[/url]
    [url=http://Niketnpascher001.fr]nike pas cher[/url]
    [url=http://h11.fr]lunettes de soleil dior[/url]
    [url=http://Niketnpascher035.fr]nike shox rivalry pas cher[/url]
    [url=http://Niketnpascher025.fr]chaussure nike homme[/url]
    [url=http://Niketnpascher017.fr]nike chaussure[/url]
    [url=http://nikesb66.com]Wholesale Nike SB Release Dates[/url]
    [url=http://www.k99.fr]la redoute code promo[/url]
    [url=http://www.jordanretro13air.com]Air Jordan Retro 12[/url]
    [url=http://ruecuir.com]Sac Burberry Chanel Dior[/url]
    [url=http://h55.fr]lunettes police[/url]
    [url=http://h44.fr]lunettes gucci[/url]
    [url=http://coachoutletcoupon55.com]coach factory outlet coupons[/url]
    [url=http://Niketnpascher008.fr]nike requin[/url]

    http://e77.fr
    http://nikelebron33.com
    http://coachoutletstore55.com
    http://coachfactoryoutlet66.com
    http://cheapcaps88.com
    http://www.k99.fr
    http://www.nikejuly.com
    http://www.jordanretro6air.com
    http://coachoutletcoupon44.com
    http://www.cosalut.com

Add a comment

Impossible to fetch issues for this plugin.
Impossible to get this plugin changelog.

dmAkismetPlugin, created on July 16, 2010 by jeremyfa, used by 79 projects

Fork Diem on GitHub