View Full Version : Replacing certain censored words with other words, rather than *'s
AaronJH
08-14-2004, 05:34 PM
Hello, everyone! I have been having a bit of a problem, but I think somebody will be able to help me out!
At my forum, I want to have the following filters:
liberal = Capulet
liberals = Capulets
conservative = Montague
conservatives = Montagues
First, I put liberal, liberals, conservative, and conservatives in the vB censorship box.
Then I tried to accomplish my goal by putting the following code in functions.php in the censorship code:
$text = strtolower($text);
if ($text == 'liberals')
{ $text = 'Capulets'; }
else if ($text == 'liberal')
{ $text = 'Capulet'; }
else if ($text == 'conservatives')
{ $text = 'Montagues'; }
else if ($text == 'conservative')
{ $text = 'Montague'; }
It works only if the offending word is the ONLY word in the post. If there is anything else, it simply converts the word to asterisks. Anybody have any suggestions?
Zachery
08-14-2004, 06:00 PM
Hello, everyone! I have been having a bit of a problem, but I think somebody will be able to help me out!
At my forum, I want to have the following filters:
liberal = Capulet
liberals = Capulets
conservative = Montague
conservatives = Montagues
First, I put liberal, liberals, conservative, and conservatives in the vB censorship box.
Then I tried to accomplish my goal by putting the following code in functions.php in the censorship code:
$text = strtolower($text);
if ($text == 'liberals')
{ $text = 'Capulets'; }
else if ($text == 'liberal')
{ $text = 'Capulet'; }
else if ($text == 'conservatives')
{ $text = 'Montagues'; }
else if ($text == 'conservative')
{ $text = 'Montague'; }
It works only if the offending word is the ONLY word in the post. If there is anything else, it simply converts the word to asterisks. Anybody have any suggestions?
You would need to do a string replace or use a regular expression i think :)
but without getting complicated you can use replacements, but this will effect the whole site.
Aaron Freed
08-14-2004, 06:09 PM
I applaud your taste in replacements.
Tigga
08-14-2004, 06:13 PM
Is there a reason why you can't just add those as replacement variables?
Zachery
08-14-2004, 06:17 PM
Is there a reason why you can't just add those as replacement variables?
Because they would replace the words apperance anywhere on the whole site.
CarCdr
08-15-2004, 01:19 AM
Modest Proposal For Replacement Text for vBulletin
One approach to offering text replacement in posts, and other user inputs, would be to change the specification for the censored word list in the AdminCP.
Right now, one can specify two types of censored word matching:
foo
matches any occurrence of the 3 characters, words or otherwise
{foo}
matches any occurrence of the word "foo"; anywhere it finds the 3 characters not preceded and followed by a letter. Matches 3 times in this text: Foo is 3foo or _foo
Extending This Implementation (= syntax)
A fairly localized hack could extend this so that AdminCP censored word could include replacement text. An admin could specify these new types in the list of censored words:
{Conservative}=Montague
Replace any occurrence of the first word with the second word.
{/home}=www.mydomain.com
Provides an abbreviation for the word match "/home".
This would be a fairly simple hack, although I would suggest that one would not want to apply the replacer specifications to text inside of [CODE], [PHP], etc.
The other caveat would be that the replacement text may not contain any HTML-special characters.
AN-net
08-15-2004, 02:52 AM
well he could modify the censor text function to change those certain words to a desired word:)
CarCdr
08-15-2004, 05:27 AM
AaronJH,
Please see: Process post text replacements, abbreviations, fake BBCODE's (https://vborg.vbsupport.ru/showthread.php?t=68367)
To do what you want to do, you can add the following to your AdminCP :: vBulletin Options :: Censorship Options:
{conservative}==montague {liberal}==capulet
The mod (the '==' operator) will take care of matching case for these words, for example, "Conservative" will be translated to "Montague" and "CONSERVATIVE" will be translated to "MONTAGUE".
--------------------------
This post was originally where I posted the mod. I thought it would be better to post it properly, so I removed all the duplicate text here.
BTW, the attached version in the above linked post was modified ever so slightly from the one posted last night. It now allows "=" (equals) in replacement text, which allows one to define fake bbcodes, a la:
{[h1]}=[size=4][color=navy][i]
which would process [h1] bbcodes found in user input and turn them into big, coloured, italicised text.
CarCdr
08-15-2004, 12:30 PM
Oh yes, I should have mentioned that this can also be used to remove words or strings rather than replace them with *'s. One would use this syntax to remove a string or a word:
anychars= {word}=
One simply does not specify a replacement -- the '=' is followed by a space.
AaronJH
08-17-2004, 01:09 AM
Thanks for the hack! :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.