Help - Search - Members - Calendar
Full Version: String search
HTMLHelp Forums > Programming > Server-side Scripting
CodeKing
I made a guestbook for one of my clients, and there was inappropiate post. How can I search a string for certain words? I want to make a simple filter.
Darin McGrew
What guestbook software are you using? Does it already have any filters (spam, offensive words, etc.)? How comfortable are you programming in whatever language the guestbook software is written in?

But ultimately, you'll need a human moderator. Filt3rs c@n on1y d0 $o muİh...
pandy
Some filters are mean and filter totally appropriate words in Swedish. angry.gif
CodeKing
I MADE a guestbook for one of my clients, I did not use pre-programmed PHP. I still want to know if there's a string search function. And also, there will be a moderator, but to prevent most of the junk posts I want a filter.

P.S. I forgot to mention, I programmed the guestbook in PHP, so a PHP function would be nice.
Christian J
You can make an array of the forbidden words, then loop through it, each time using str_replace(). This may not catch letters made by HTML entities.

Google should turn up plenty of more elaborate code examples.
Peter1968
There are also canned spam and obsenity filters made for a bunch of apps. I've seen them for Mediawiki, PostNuke, phpBB, etc, so I'm sure if you Google for them, you'll find something.
CodeKing
I don't want a prewritten PHP file for my filter, I would prefer to custom-make the filter. Is there a function that searches a string and returns true if it found something? (replace won't work, I want to not let a inappropiate post to be posted, rather than starring out the bad words)
Christian J
QUOTE(CodeKing @ Mar 8 2007, 12:55 AM) *

replace won't work, I want to not let a inappropiate post to be posted, rather than starring out the bad words

http://php.net/manual/en/function.strpos.php then?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.