Liam Delahunty: Home Tips Web Contact
Recommended laptop
under £500
.

Think I deserve a present? See my Amazon Wish List

PHP URL Count Check for Comment Spam

This simple little bit of code can be added to your spam filtering section on your contact forms, it checks for "http", "href" and "[url" in the message block. It counts them and repors them. It could be used within a spam detection routine on a form to filter away all those annoying "Your site is great" messgae that arrive with a dozen links in them...

$http = substr_count($text, "http");
$href = substr_count($text, "href");
$url = substr_count($text, "[url");

Here's the ever so simple code:

if($submit){
  $text = addslashes($comments);
  // annoying URL spams
  $http = substr_count($text, "http");
  $href = substr_count($text, "href");
  $url = substr_count($text, "[url");
}

Now simply check the values of $http, $href and $url and if beyond your limit, mark the message as spam. Here's a form for you to paste in some spam and see it in action.

Share this!  



Php Uk Mailing List | Php Url Count Check For Comment Spam | Php What Does Php Stand For


 

  Tips | Home | Search | Contact

Link here: