Spam stripper code anyone?

  • Willy
  • Graduate
  • Graduate
  • Willy
  • Posts: 199

Post 3+ Months Ago

I've been writing my own php class for people to comment on things for my site.

i've realized spam might be a problem for this... I was wondering if anyone had a good string span stripper... like removing A hrefs or antying

just looking for some free code :-p
  • Scorpius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 401
  • Loc: Scorpion Hole

Post 3+ Months Ago

Well, you could use <a href="">preg_replace()</a> and do it yourself, which would probably be the easiest way of them all.
  • Managedlinks
  • Proficient
  • Proficient
  • Managedlinks
  • Posts: 294

Post 3+ Months Ago

I always replace '<' with &lt;

that way the html simply becomes text
it also breaks anyone trying to insert a script on to the page
  • joebert
  • Genius
  • Genius
  • User avatar
  • Posts: 13511
  • Loc: Florida

Post 3+ Months Ago

The problems with simply replacing certain tags is that it's dirty, a cleaner way would be to search for theese tags and if found cancel logging of the comments and redirect to a "To help prevent spam" page asking the user to please remove offending tags and resubmit. I dont know much about php but in an ASP enviroment it would look somthing like this,
Code: [ Select ]
array of banned strings...............
cmnt = Request.Form("comment")
For i=0 To banned.length-1
 If Instr(cmnt, banned(i)) Then
   spam = "spamcheck.asp?comment=" & cmnt
 End If
  1. array of banned strings...............
  2. cmnt = Request.Form("comment")
  3. For i=0 To banned.length-1
  4.  If Instr(cmnt, banned(i)) Then
  5.    spam = "spamcheck.asp?comment=" & cmnt
  6.    Response.Redirect(spam)
  7.  End If
  8. Next

Redirect submission to a light version of the submit page with a list of banned tags.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 53 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2017. Ozzu® is a registered trademark of Unmelted, LLC.