Version: 0.9, by FractalizeR
Developer Last Online: Nov 2014
Category: Show Thread Enhancements -
Version: 3.6.8
Rating:
Released: 11-11-2007
Last Update: Never
Installs: 28
Uses Plugins
Translations Is in Beta Stage
No support by the author.
What this hack does?
This hack is a post censor, that will replace unwanted words and phrases by the values you specify.
Features:
Supports standard replace
Supports replacing using regular expressions
Allows to apply censor only to specified usergroups
On-the-fly regular expression syntax checking
Some use cases:
I don't like posts with multiple exclamation or question marks. Maximum three signs is allowed.
Sometimes you ban competitor forum names from using on your forum. But users enter them separating letters by spaces or underscores. This is unwanted and it is difficult to deal with using standard censor
Any forms of curses and bad words should be replaced by XXX
Version was tested under VB 3.6.8, but supposed to work on any 3.6.x release. Please report all compatibility issues here.
Please look at control panel screenshot below (please mind, that I am russian and screenshots are from russian forum, so for example usergroup names are incorrectly displayed when I set langauge to English).
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
Yes, '?' is a special sign in regular expressions language that means, that preceding symbol can be in string, or can be omitted. You need to escape it by '\' to use as a string.
To replace many question marks by some string use the following regex:
'/\?{3,}/' => '???'
The expression in {} tells, that preceding symbol is repeated three or more times. We can write {,3} for example and it will mean, that something repeated up to three times. We can specify {3,6} and it will mean, that something is repeated from 3 to 6 times.
dot (".") means one any symbol.
plus ("+") means, that preceding symbol or expression is repeated one or more times. It is actually equal to {1,}.
asterisk ("*") means, that preceding symbol or expression is repeated zero or more times.
\d - means one any digit.
\s - means any space character
For example we can replace multiple spaces by one:
'/\s+/' => '' " - remember, + means "one or more"
If you need to apply + or * or any other "quantifier" to several characters you need to put these characters into brackets:
/(abc)+/ => "abc" - replace one or more abc sttrings by one copy so that "abcabcabc" becomes "abc"
So, about your case - yes, all correct, just escape ? by \
Actually, censor makes no changes to DB. So, words are replaced on post is displayed.
Preview is not affected preventing users from experimenting with filter faking.
Actually, censor makes no changes to DB. So, words are replaced on post is displayed.
Preview is not affected preventing users from experimenting with filter faking.
Awesome, thank you! That's what I was afraid of, if it happened during preview
Interesting concept and one our forums could benefit from if the follow works as desired.
What would happen if you wanted to replace the "U" with "You" in the following sentence: "U should bring an umbrella."
Would the outcome be "You should bring an umbrella." or You shoyould bring an youmbrella."?
In this case we need to change a single "u" with "you". You can try this one: /\w+u\w+/ =>"you"
\w - is any "non-word" character
Quote:
Originally Posted by Elenna
This is working nicely, thank you!
How would I have it reduce
"?!?!?!?!?" to just "?!"
I kno wmy members will 'get around' it by alternating them. :P
Make it like: "/((\?\!)|(\!\?))+/" = > "?!"
It means, replace any number of "?!" or "!?" sequences by single "?!". "|" - means "or"
Small update: to prevent users from using different combinations of "!", "?" and spaces one may try something like this: "/((\!\s*)|(\?\s*)){3,}/" => "Exclamation!"