1702433374

Spam catch


Even with a strong Captcha system in place, you will still find users trying to manually spam your web site. They tend to be people who discover your site through a very specific search engine query, for which they would like their own site to also rank well, and they hope that by adding a link back to their site from yours this will happen. Using this recipe, you can specify a set of keywords that will trigger spam detection, and then use the level of spam certainty returned by the function to decide whether to ignore a user post. ## <br>About the recife This recipe accepts a user-supplied string and matches it against a list of keywords to determine the likelihood that the string contains spam. It takes these arguments: + $text   The e-mail address to be validated. + $words   An array of keywords against which to check. ## The recipe ```php function WordSelector($text, $matches, $replace){ foreach($matches as $match) { switch($replace) { case "u": case "b": case "i": $text = preg_replace("/([^\w]+)($match)([^\w]+)/", "$1$2$3", $text); break; default: $text = preg_match("/([^\w]+)$match([^\w]+)/", "$1$replace$2", $text); } } return $text; } function SpamCatch($text, $words) { return strlen($text) - strlen(WordSelector($text, $words, "")); } ``` ## How to use it ```php $words = array("rolex", "replica", "loan", "mortgage", "viagra", "cialis", "acal", "free", "stock", "guarenteed", "refinancing", "cartier", "manhood", "drugs"); if(SpamCatch($text, $world) < 15) echo "Probably not spam"; else echo "Probably spam"; ```

(0) Comments