Filter comment Spam? Php

I am looking for articles on how to filter spam. When I look through all that I find, it is Wordpress, ways to filter abusive words, etc., which I am not looking for. I am looking for ways to write my own filter system and best practices.

Any links to textbooks from anyone who has done this before will be appreciated.

Only good article I can do so far http://snook.ca/archives/other/effective_blog_comment_spam_blocker

+6
source share
8 answers

When writing your own method, you will need to use a combination of heuristics.

For example, very often there are 2 or more URL links for spam comments.

I would start writing my filter like this, using a dictionary of trigger words and scroll it and use it to determine the probability:

function spamProbability($text){ $probability = 0; $text = strtolower($text); // lowercase it to speed up the loop $myDict = array("http","penis","pills","sale","cheapest"); foreach($myDict as $word){ $count = substr_count($text, $word); $probability += .2 * $count; } return $probability; } 

Please note that this method will lead to many false positives, depending on your set of words; you could have your flag flag for moderation (but it goes straight ahead) with a probability of> .3 and <.6, require that those> .6 and <.9 enter the queue for moderation (where they are not displayed before approval), and then nothing more than> 1 is simply rejected.

Obviously, these are all the values ​​that you will need to configure for thresholds, but this should start you with a fairly simple system. You can add several other qualifiers to it to increase / decrease the likelihood of spam, such as checking the relationship of bad words to words, changing the weight of words, etc.

+11
source

I am surprised that no one mentioned Akismet . I have never had a message flagged incorrectly (be it spam or law). My WordPress installation came with it. All I had to do was allow the hit.

+2
source

Are you looking for a way to stop spam from bots, etc.? If so, you can always add CAPTCHA: http://en.wikipedia.org/wiki/CAPTCHA It should be easy enough to host any project if that is what you are trying to do. Otherwise, I'm not sure what you are saying in terms of spam filtering.

+1
source

Here is another good tutorial on working with spammers and there is spam ...:

How to stop spammers manual comments

Here is a link to a good similar SO question:

non-captcha spam blocking methods in my comments

Hope this helps.

+1
source

You can look at the b8 spam filter: http://nasauber.de/opensource/b8/

+1
source

Consider implementing reCAPTCHA - here's the link - http://www.google.com/recaptcha as well as http://code.google.com/apis/recaptcha/docs/php.html

0
source

I think this spam comment war article can give you some tips. Of course, some bots are smart enough at the moment, so you might need to add CAPTCHA.

0
source

I hope this script helps you detect and protect spam.

 <?php function isspam($text) { $sfil[0] = "link"; $sfil[1] = "http"; $sfil[2] = "www"; $sfil[3] = "any slang"; $sfil[4] = "any word"; $sfil[5] = "any website"; $text = str_replace(" ", "", $text); $text = strtolower($text); for($i=0;$i<count($sfil);$i++) { $nosf = substr_count($text,$sfil[$i]); if($nosf>0) { return true; } } return false; } ?> 

Create a spam filter in PHP More

0
source

Source: https://habr.com/ru/post/903308/


All Articles