MyBB Community Forums

Full Version: Wild card in word filters?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I apologise if one like this exists already, but can someone please try and make a plugin/mod (or if it requires a simple edit of the files tell me what to put and where lol) that allows the censors to have like a wildcard feature. Ie, if you want to censor dog, but you also wanted to censor that combination of letters in ANY word, you could select to do so. If you get what I mean.


Maybe this will make it clearer lol:

If you censor the letters dog, then someone posted dogg, or doggy it would not censor the letters dog, but I am looking for a plugin/mod that allows the option of this. Smile
This is a way to do the above for ALL words in the word filter. I personally prefer this method, as it also makes the parser run faster, but it's debatable as to which one is best.

In /inc/class_parser.php
FIND
				$badword['badword'] = preg_quote($badword['badword']);
				$message = preg_replace("#(\W|^)".$badword['badword']."(\W|$)#i", "\\1".$badword['replacement']."\\2", $message);
Replace with:
$message = str_replace($badword['badword'], $badword['replacement'], $message);

(If you are always going to manually stick in a replacement, you can actually make the badword filter slightly faster by removing the loop altogether, does take more work though)
It works Big Grin thanks Smile
ZiNga BuRgA Wrote:This is a way to do the above for ALL words in the word filter. I personally prefer this method, as it also makes the parser run faster, but it's debatable as to which one is best.

In /inc/class_parser.php
FIND
				$badword['badword'] = preg_quote($badword['badword']);
				$message = preg_replace("#(\W|^)".$badword['badword']."(\W|$)#i", "\\1".$badword['replacement']."\\2", $message);
Replace with:
$message = str_replace($badword['badword'], $badword['replacement'], $message);

(If you are always going to manually stick in a replacement, you can actually make the badword filter slightly faster by removing the loop altogether, does take more work though)

wont that make it case sensitive?
^ Yes it will. I believe PHP 5 has a case insensitive str_replace() (can't remember).

Is case insensitivity needed though?
ZiNga BuRgA Wrote:^ Yes it will. I believe PHP 5 has a case insensitive str_replace() (can't remember).

Is case insensitivity needed though?

yes of course,

for example if someone bans the word "dog"

then the user could just type DOG and it would get through. easy peasy.