Zen Cart Logo

bad word filter

Views: 601

Results 1 to 4 of 4
12 Aug 2017, 12:09 PM
#1
iatia avatar

iatia

Zen Follower

Join Date:
Nov 2009
Location:
Aransas Pass, TX
Posts:
102
Plugin Contributions:
1

bad word filter

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. :D

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

	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)
?>
12 Aug 2017, 2:45 PM
#2
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: bad word filter

FWIW (keeping in mind that I'm not exactly a spring chicken), I boycott any site that uses CAPTCHA. My time is more important to me than a merchants dislike of spam. Even if I did get the captcha right the 1st time (never happens) it still sucks a little more of my life away.... and dont get me started on "bad word" filters... with a surname of "Gasson" and "######" often considered to be a "bad word" you can only imagine the trouble I have with some sites.

Just sayin'

12 Aug 2017, 2:48 PM
#3
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: bad word filter

LOL.. seems that even this forum considers another name for donkey to be a bad word... thankfully it didnt filter the same word embeded in my name as being bad.

12 Aug 2017, 11:23 PM
#4
iatia avatar

iatia

Zen Follower

Join Date:
Nov 2009
Location:
Aransas Pass, TX
Posts:
102
Plugin Contributions:
1

Re: bad word filter

I have been to quite a few forums that would censor your surname. I was on a car forum and it did not like Matsushita. WIKI - > Matsushita (written: 松下 lit. "below the pine tree") is a Japanese surname. Notable people with the surname include ...