Alright ... the last review ('cause I never like what I write ... )
here:
function naughty_words($text) {
$query="select naughty_words from prude_list";
$result=mysql_query($query);
while ($loop=mysql_fetch_array($result)) {
if(stristr("$text","$loop[naughty_words]")) {
return true;
}
}
}
if(!nasty_words($text))
header("Location: error.php?reason=prudes_wont_like_it");
else
header("Location: insert_stuff.php?comment=$text");
Cheers,
Maxim Maletsky
-----Original Message-----
From: Maxim Maletsky
Sent: Wednesday, January 31, 2001 3:52 PM
To: 'Chris Aitken'; [EMAIL PROTECTED]
Subject: RE: [PHP] Naughty Word Catcher
Actually your function does header() on each loop ...
This is correct ..
<snip>
$query="select naughty_words from prude_list";
$result=mysql_query($query);
while ($loop=mysql_fetch_array($result)) {
if(stristr("$block_of_text","$loop[naughty_words]")) {
$Gotcha = 1;
Break;
}
if(!$Gotcha)
header("Location: error.php?reason=prudes_wont_like_it");
else
header("Location: insert_stuff.php?comment=$block_of_text");
</snip>
Cheers,
Maxim Maletsky
-----Original Message-----
From: Chris Aitken [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 31, 2001 2:04 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Naughty Word Catcher
Hi all,
Ive just been asked whether I can do the following task.....
When a block of text is submitted via a web form, for it to be checked for
offensive words, and rejected if there is.
So I put my brain hard to work and came up with a possibly solution. I know
this method should work but im wondering if I should tackle it a different
way.
This is just a rough, typed-off-the-top-of-my-head to show the method
rather than correct code.
The idea was to have a list of offensive words or phrases in a MySQL
database, and the script would take the block of text, and do the following
$query="select naughty_words from prude_list";
$result=mysql_query($query);
while ($loop=mysql_fetch_array($result)) {
$naughty_word_checker =
stristr("$block_of_text","$loop[naughty_words]");
if ($naughty_word_checker) {
header("Location: error.php?reason=prudes_wont_like_it");
} else {
header("Location: insert_stuff.php?comment=$block_of_text");
}
}
or is there a better, more efficient way of doing it. Im pretty sure the
concept of above will work because if there is a match, stristr() should
return text, otherwise it shouldnt return anything (or if im wrong, a
little fine tuning will sort that out).
Thanks
Chris
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]