Bad word Filter

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
patsd102
Veteran Member
Posts: 142
Joined: 2013-01-15 19:59

Bad word Filter

Post by patsd102 » 2013-10-22 19:50

Anyone using a code to filter out unwanted words in the database fields.

Thanks
23.17

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: Bad word Filter

Post by AhmedBR » 2013-10-22 22:39

I use the following code in Hook before insert:

Code: Select all

$product = $data['Product'];
$bannedWords = array('Word1','Word2','Word3', 'Word4', 'Word5', 'Word6');
if(preg_match('#('.implode('|',$bannedWords).')#i', $product)) {
$data['Product'] = 'Error';
The above code will filter any of the 6 words (of course you should write the words your need to filter instead of Word1 etc).
If one these words was detected it will register the word Error in the database instead; as I need to raise an alert in the system.

The error will be accepted only ONCE as it is set as Unique, we will train the user who caused the error, edit the error, and wait for the next one to happen.

Off course you can changed that part and do anything else you want, like return FALSE in order not to register anything in the database etc.
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

patsd102
Veteran Member
Posts: 142
Joined: 2013-01-15 19:59

Re: Bad word Filter

Post by patsd102 » 2013-10-23 05:27

Many thanks, Will try this

Pat
23.17

Post Reply