ZenCart v1.5.5e
Apache server (Hostmatters)
PHP 5.6.31 (Zend: 2.6.0)
MySQL 5.6.37
About_us page
dbio 1.3.0
MainImageReplacer-v1.0
Image_Handler4_v4.3.2
This seemed as good a spot as any for this post. If not, just remember that I am a senile old man.
I was looking around for a bad word filter for my CAPTCHA with very little luck. The consensus seemed to be that it was too rare a scenario for anyone to be bothered with. Personally, I have very little traffic as of yet and I would hate to lose one customer (plus word of mouth) because 'mother dog' (I got censored) showed up in my CAPTCHA box as some little old lady was looking to buy my antique doll.
so for anyone that wants it, here it is. I used the Google 'bad word list' for my database. It is a very simple filter so even words like grass and sassy will be filtered.
PHP Code:
<?php
function bad_word($word)
//---- open bad_word db here ----//
require ("local_db_conn.php");
$word_table= "bad";
$bad_word= "words";
$captcha_ID = "ID";
$word = strtoupper($word);
$query = "SELECT $bad_word from $word_table";
if ($result = $conn->query($query))
{
/* fetch object array */
while ($row = $result->fetch_row())
{
$google = strtoupper($row[0]);
if (strstr($word,$google))
{
$word = "";
goto done;
}
}
}
done:
/* free result set */
$result->close();
/* close database */
mysqli_close($conn);
return($word)
?>
Bookmarks