Reply to Re: Removing Bad Words

Your name:

Reply:


Posted by Jim Carlock on 02/23/06 01:25

Jim Carlock wrote:
> So the next thoughts involved employing a list of good words
> and if any word in the $_GET['item'] list doesn't fall into the
> list of good words, then an empty string gets returned.
>
> Any suggestions on how to handle this?
>
"Michael Austin" replied:
> Jim, Not knowing your requirments or what the website will be
> used for makes it a little difficult to give you a solution. Would
> a drop-down list of acceptable words be better than expecting
> the user to type them correctly?

Well a drop down list will go into the making for some things, but
anyone can edit the line of text in the address-bar. And so instead
of filtering for bad words, I'm looking for suggestions on how to
parse through a list of good words (stored inside an array) and if
any of the words in the address bar fail to match the words in the
any of the words in the array, the individual gets routed to a
bad-word page (the website homepage). I see a database as a
very useful option but I'm working with PHP arrays at the
moment. The database will be the future, but for the moment, I
think an array of 200 possible words might work very well.

Just need an effective way to compare a word to a list of words
inside an array and return true if it matches, false if it fails the
match.

My thoughts include:

function IsValidWord($sCheckThis) {
global $aWords;
foreach($aWords as $sWord) {
if ($sWord === $sCheckThis) {
return(TRUE);
}
}
return(FALSE);
}

So I'm looking for any other suggestions.

> That being said, if you type as badly as I do, you have probably
> made all of teh tpying errors most commonly seen. Including a
> str_replace() for all of those examples would not be that difficult
> - better yet include it into a javascript and let the client-side
> handle the word-corrections (onclick or onsubmit).

The list of words is to remain on the server, so JavaScript in this
case, seems to be an invalid option. Any mistyped words are to
route the client to the homepage, or perhaps present the page in
question with no selections selected. Either/or seems appropriate
in this case.

<snip>...</snip>

Jim Carlock
Post replies to the group.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация